提交 e695e3ad 编写于 作者: Q qiang

Merge branch 'alpha'

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).uni=n()}(this,(function(){"use strict";try{var e={};Object.defineProperty(e,"passive",{get:function(){!0}}),window.addEventListener("test-passive",null,e)}catch(e){}var n=Object.prototype.hasOwnProperty;function t(e,t){return n.call(e,t)}var i=[],a=function(e,n){var t={options:{timestamp:+new Date},name:e,arg:n};if(window.__dcloud_weex_postMessage||window.__dcloud_weex_){if("postMessage"===e){var a={data:[n]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(a):window.__dcloud_weex_.postMessage(JSON.stringify(a))}var o={type:"WEB_INVOKE_APPSERVICE",args:{data:t,webviewIds:i}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(o):window.__dcloud_weex_.postMessageToService(JSON.stringify(o))}if(!window.plus)return window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:t,pageId:""},"*");if(0===i.length){var r=plus.webview.currentWebview();if(!r)throw new Error("plus.webview.currentWebview() is undefined");var d=r.parent(),s="";s=d?d.id:r.id,i.push(s)}if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:t,webviewIds:i}},"__uniapp__service");else{var w=JSON.stringify(t);plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat("WEB_INVOKE_APPSERVICE",'",').concat(w,",").concat(JSON.stringify(i),");"))}},o={navigateTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("navigateTo",{url:encodeURI(n)})},navigateBack:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.delta;a("navigateBack",{delta:parseInt(n)||1})},switchTab:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("switchTab",{url:encodeURI(n)})},reLaunch:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("reLaunch",{url:encodeURI(n)})},redirectTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("redirectTo",{url:encodeURI(n)})},getEnv:function(e){window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a("postMessage",e.data||{})}},r=/uni-app/i.test(navigator.userAgent),d=/complete|loaded|interactive/;var s=window.my&&navigator.userAgent.indexOf("AlipayClient")>-1;var w=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var u=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var c=window.tt&&window.tt.miniProgram&&/toutiaomicroapp/i.test(navigator.userAgent);var g=window.wx&&window.wx.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var v=window.qa&&/quickapp/i.test(navigator.userAgent);for(var p,l=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},_=[function(e){if(r)return window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",e):window.plus&&d.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),o},function(e){if(g)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(u)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(s){document.addEventListener("DOMContentLoaded",e);var n=window.my;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(w)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(c)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(v){window.QaJSBridge&&window.QaJSBridge.invoke?setTimeout(e,0):document.addEventListener("QaJSBridgeReady",e);var n=window.qa;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){return document.addEventListener("DOMContentLoaded",e),o}],f=0;f<_.length&&!(p=_[f](l));f++);p||(p={});var m="undefined"!=typeof uni?uni:{};if(!m.navigateTo)for(var E in p)t(p,E)&&(m[E]=p[E]);return m.webView=p,m}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).uni=n()}(this,(function(){"use strict";try{var e={};Object.defineProperty(e,"passive",{get:function(){!0}}),window.addEventListener("test-passive",null,e)}catch(e){}var n=Object.prototype.hasOwnProperty;function t(e,t){return n.call(e,t)}var i=[],a=function(e,n){var t={options:{timestamp:+new Date},name:e,arg:n};if(window.__dcloud_weex_postMessage||window.__dcloud_weex_){if("postMessage"===e){var a={data:[n]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(a):window.__dcloud_weex_.postMessage(JSON.stringify(a))}var o={type:"WEB_INVOKE_APPSERVICE",args:{data:t,webviewIds:i}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(o):window.__dcloud_weex_.postMessageToService(JSON.stringify(o))}if(!window.plus)return window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:t,pageId:""},"*");if(0===i.length){var r=plus.webview.currentWebview();if(!r)throw new Error("plus.webview.currentWebview() is undefined");var d=r.parent(),s="";s=d?d.id:r.id,i.push(s)}if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:t,webviewIds:i}},"__uniapp__service");else{var w=JSON.stringify(t);plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat("WEB_INVOKE_APPSERVICE",'",').concat(w,",").concat(JSON.stringify(i),");"))}},o={navigateTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("navigateTo",{url:encodeURI(n)})},navigateBack:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.delta;a("navigateBack",{delta:parseInt(n)||1})},switchTab:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("switchTab",{url:encodeURI(n)})},reLaunch:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("reLaunch",{url:encodeURI(n)})},redirectTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;a("redirectTo",{url:encodeURI(n)})},getEnv:function(e){window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a("postMessage",e.data||{})}},r=/uni-app/i.test(navigator.userAgent),d=/Html5Plus/i.test(navigator.userAgent),s=/complete|loaded|interactive/;var w=window.my&&navigator.userAgent.indexOf("AlipayClient")>-1;var u=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var c=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var g=window.tt&&window.tt.miniProgram&&/toutiaomicroapp/i.test(navigator.userAgent);var v=window.wx&&window.wx.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var p=window.qa&&/quickapp/i.test(navigator.userAgent);for(var l,_=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},f=[function(e){if(r||d)return window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",e):window.plus&&s.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),o},function(e){if(v)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(c)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(w){document.addEventListener("DOMContentLoaded",e);var n=window.my;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(u)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(g)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(p){window.QaJSBridge&&window.QaJSBridge.invoke?setTimeout(e,0):document.addEventListener("QaJSBridgeReady",e);var n=window.qa;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){return document.addEventListener("DOMContentLoaded",e),o}],m=0;m<f.length&&!(l=f[m](_));m++);l||(l={});var E="undefined"!=typeof uni?uni:{};if(!E.navigateTo)for(var b in l)t(l,b)&&(E[b]=l[b]);return E.webView=l,E}));
......@@ -43,6 +43,7 @@
|data|Object/String/ArrayBuffer|开发者服务器返回的数据|
|statusCode|Number|开发者服务器返回的 HTTP 状态码|
|header|Object|开发者服务器返回的 HTTP Response Header|
|cookies|``Array.<string>``|开发者服务器返回的 cookies,格式为字符串数组|
**data 数据说明**
......
......@@ -10,15 +10,16 @@
**OBJECT参数说明:**
|属性|类型|默认值|必填|说明|
|:-|:-|:-|:-|:-|
|index|number||是|tabBar 的哪一项,从左边算起|
|text|String||否|tab 上的按钮文字|
|iconPath|String||否|图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片|
|selectedIconPath|String||否|选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效|
|success|Funtion||否|接口调用成功的回调函数|
|fail|Funtion||否|接口调用失败的回调函数|
|complete|Funtion||否|接口调用结束的回调函数(调用成功、失败都会执行)|
|属性|类型|默认值|必填|说明|平台差异|
|:-|:-|:-|:-|:-|:-|
|index|number||是|tabBar 的哪一项,从左边算起||
|text|String||否|tab 上的按钮文字||
|iconPath|String||否|图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片||
|selectedIconPath|String||否|选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效||
|pagePath|String||否|页面绝对路径,必须在 [pages](/collocation/pages?id=pages) 中先定义|App(2.8.4+)、H5(2.8.4+)|
|success|Funtion||否|接口调用成功的回调函数||
|fail|Funtion||否|接口调用失败的回调函数||
|complete|Funtion||否|接口调用结束的回调函数(调用成功、失败都会执行)||
**示例代码**
......
......@@ -12,5 +12,5 @@
"message": "chore(release): publish %s"
}
},
"version": "2.0.0-alpha-28020200701002"
"version": "2.0.0-alpha-28420200805004"
}
......@@ -55,6 +55,7 @@ const media = [
'compressImage',
'getRecorderManager',
'getBackgroundAudioManager',
'createAudioContext',
'createInnerAudioContext',
'chooseVideo',
'saveVideoToPhotosAlbum',
......@@ -108,7 +109,9 @@ const device = [
'getBLEDeviceServices',
'getBLEDeviceCharacteristics',
'createBLEConnection',
'closeBLEConnection',
'closeBLEConnection',
'setBLEMTU',
'getBLEDeviceRSSI',
'onBeaconServiceChange',
'onBeaconUpdate',
'getBeacons',
......@@ -206,8 +209,8 @@ const third = [
'setPageMeta',
'onNativeEventReceive',
'sendNativeEvent',
'preloadPage',
'unPreloadPage',
'preloadPage',
'unPreloadPage',
'loadSubPackage'
]
......
......@@ -113,7 +113,9 @@
"uni.getBLEDeviceServices": true,
"uni.getBLEDeviceCharacteristics": true,
"uni.createBLEConnection": true,
"uni.closeBLEConnection": true,
"uni.closeBLEConnection": true,
"uni.setBLEMTU": true,
"uni.getBLEDeviceRSSI": true,
"uni.onBeaconServiceChange": true,
"uni.onBeaconUpdate": true,
"uni.getBeacons": true,
......
{
"name": "@dcloudio/uni-app-plus-nvue",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app app-plus-nvue",
"main": "dist/index.js",
"repository": {
......
......@@ -134,7 +134,7 @@ function queue (hooks, data) {
for (let i = 0; i < hooks.length; i++) {
const hook = hooks[i];
if (promise) {
promise = Promise.then(wrapperHook(hook));
promise = Promise.resolve(wrapperHook(hook));
} else {
const res = hook(data);
if (isPromise(res)) {
......@@ -388,7 +388,9 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
toArgs[keyOption.name ? keyOption.name : key] = keyOption.value;
}
} else if (CALLBACKS.indexOf(key) !== -1) {
toArgs[key] = processCallback(methodName, fromArgs[key], returnValue);
if (isFn(fromArgs[key])) {
toArgs[key] = processCallback(methodName, fromArgs[key], returnValue);
}
} else {
if (!keepFromArgs) {
toArgs[key] = fromArgs[key];
......@@ -468,10 +470,6 @@ TODOS.forEach(function (name) {
});
const getEmitter = (function () {
if (typeof getUniEmitter === 'function') {
/* eslint-disable no-undef */
return getUniEmitter
}
let Emitter;
return function getUniEmitter () {
if (!Emitter) {
......@@ -636,6 +634,8 @@ Component = function (options = {}) {
const PAGE_EVENT_HOOKS = [
'onPullDownRefresh',
'onReachBottom',
'onAddToFavorites',
'onShareTimeline',
'onShareAppMessage',
'onPageScroll',
'onResize',
......@@ -837,6 +837,11 @@ function initProperties (props, isBehavior = false, file = '') {
type: String,
value: ''
};
// 用于字节跳动小程序模拟抽象节点
properties.generic = {
type: Object,
value: null
};
properties.vueSlots = { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
type: null,
value: [],
......@@ -1069,6 +1074,15 @@ function isMatchEventType (eventType, optType) {
)
}
function getContextVm (vm) {
let $parent = vm.$parent;
// 父组件是 scoped slots 或者其他自定义组件时继续查找
while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) {
$parent = $parent.$parent;
}
return $parent && $parent.$parent
}
function handleEvent (event) {
event = wrapper$2(event);
......@@ -1101,12 +1115,8 @@ function handleEvent (event) {
const methodName = eventArray[0];
if (methodName) {
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = getContextVm(handlerCtx) || handlerCtx;
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
......@@ -1130,14 +1140,17 @@ function handleEvent (event) {
}
handler.once = true;
}
ret.push(handler.apply(handlerCtx, processEventArgs(
const params = processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
)));
) || [];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret.push(handler.apply(handlerCtx, params.concat([, , , , , , , , , , event])));
}
});
}
......@@ -1157,7 +1170,8 @@ const hooks = [
'onHide',
'onError',
'onPageNotFound',
'onThemeChange'
'onThemeChange',
'onUnhandledRejection'
];
function parseBaseApp (vm, {
......@@ -1517,7 +1531,7 @@ let uni = {};
if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
uni = new Proxy({}, {
get (target, name) {
if (target[name]) {
if (hasOwn(target, name)) {
return target[name]
}
if (baseApi[name]) {
......@@ -1535,7 +1549,7 @@ if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
return promisify(name, wrapper(name, wx[name]))
},
set (target, name, value) {
target[name] = value;
target[name] = value;
return true
}
});
......
此差异已折叠。
{
"name": "@dcloudio/uni-app-plus",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app app-plus",
"main": "dist/index.js",
"repository": {
......
{
"name": "@dcloudio/uni-automator",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app automator",
"main": "dist/index.js",
"repository": {
......
......@@ -111,8 +111,8 @@ function isNVuePage (page, root = '') {
}
function isValidPage (page, root = '') {
if (typeof page === 'string') { // 不合法的配置
console.warn(`${page} 配置错误, 已被忽略, 查看文档: https://uniapp.dcloud.io/collocation/pages?id=pages`)
if (typeof page === 'string' || !page.path) { // 不合法的配置
console.warn('pages.json 页面配置错误, 已被忽略, 查看文档: https://uniapp.dcloud.io/collocation/pages?id=pages')
return false
}
let pagePath = page.path
......
......@@ -88,8 +88,20 @@ module.exports = {
getPlatformFilterTag () {
return uniPluginOptions.filterTag
},
getMPRuntimePath () {
if (process.env.UNI_USING_VUE3) {
return require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM + '/dist/uni.mp.esm.js')
}
return require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM)
},
getPlatformVue (vueOptions) {
return uniPluginOptions.vue || '@dcloudio/vue-cli-plugin-uni/packages/mp-vue'
if (uniPluginOptions.vue) {
return uniPluginOptions.vue
}
if (process.env.UNI_USING_VUE3) {
return '@dcloudio/uni-mp-vue'
}
return '@dcloudio/vue-cli-plugin-uni/packages/mp-vue'
},
getPlatformCssVars () {
return uniPluginOptions.cssVars || {}
......@@ -134,4 +146,4 @@ module.exports = {
]
}
}
}
}
{
"name": "@dcloudio/uni-cli-shared",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-cli-shared",
"main": "lib/index.js",
"repository": {
......
{
"name": "@dcloudio/uni-h5-ui",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app h5 ui",
"main": "dist/index.umd.min.js",
"repository": {
......
此差异已折叠。
......@@ -316,6 +316,15 @@
]
]
],
"createAudioContext": [
"/core/service/api/context/audio.js",
[
[
"/core/helpers/protocol/context/context.js",
"createAudioContext"
]
]
],
"createInnerAudioContext": [
"/platforms/h5/service/api/context/inner-audio.js",
[]
......
{
"name": "@dcloudio/uni-h5",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app h5",
"main": "dist/index.umd.min.js",
"repository": {
......
{
"name": "@dcloudio/uni-migration",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app migration",
"main": "lib/index.js",
"repository": {
......
......@@ -134,7 +134,7 @@ function queue (hooks, data) {
for (let i = 0; i < hooks.length; i++) {
const hook = hooks[i];
if (promise) {
promise = Promise.then(wrapperHook(hook));
promise = Promise.resolve(wrapperHook(hook));
} else {
const res = hook(data);
if (isPromise(res)) {
......@@ -640,16 +640,18 @@ const protocols = { // 需要做转换的 API 列表
getSavedFileInfo: {
args: {
filePath: 'apFilePath'
},
returnValue (result) {
if (result.fileList && result.fileList.length) {
result.fileList.forEach(file => {
file.filePath = file.apFilePath;
delete file.apFilePath;
});
}
return {}
}
},
getSavedFileList: {
returnValue (result) {
if (result.fileList && result.fileList.length) {
result.fileList.forEach(file => {
file.filePath = file.apFilePath;
delete file.apFilePath;
});
}
return {}
}
},
removeSavedFile: {
args: {
......@@ -855,7 +857,9 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
toArgs[keyOption.name ? keyOption.name : key] = keyOption.value;
}
} else if (CALLBACKS.indexOf(key) !== -1) {
toArgs[key] = processCallback(methodName, fromArgs[key], returnValue);
if (isFn(fromArgs[key])) {
toArgs[key] = processCallback(methodName, fromArgs[key], returnValue);
}
} else {
if (!keepFromArgs) {
toArgs[key] = fromArgs[key];
......@@ -970,10 +974,6 @@ var extraApi = /*#__PURE__*/Object.freeze({
});
const getEmitter = (function () {
if (typeof getUniEmitter === 'function') {
/* eslint-disable no-undef */
return getUniEmitter
}
let Emitter;
return function getUniEmitter () {
if (!Emitter) {
......@@ -1123,6 +1123,8 @@ var api = /*#__PURE__*/Object.freeze({
const PAGE_EVENT_HOOKS = [
'onPullDownRefresh',
'onReachBottom',
'onAddToFavorites',
'onShareTimeline',
'onShareAppMessage',
'onPageScroll',
'onResize',
......@@ -1314,6 +1316,11 @@ function initProperties (props, isBehavior = false, file = '') {
type: String,
value: ''
};
// 用于字节跳动小程序模拟抽象节点
properties.generic = {
type: Object,
value: null
};
properties.vueSlots = { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
type: null,
value: [],
......@@ -1546,6 +1553,15 @@ function isMatchEventType (eventType, optType) {
)
}
function getContextVm (vm) {
let $parent = vm.$parent;
// 父组件是 scoped slots 或者其他自定义组件时继续查找
while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) {
$parent = $parent.$parent;
}
return $parent && $parent.$parent
}
function handleEvent (event) {
event = wrapper$1(event);
......@@ -1578,12 +1594,8 @@ function handleEvent (event) {
const methodName = eventArray[0];
if (methodName) {
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = getContextVm(handlerCtx) || handlerCtx;
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
......@@ -1607,14 +1619,17 @@ function handleEvent (event) {
}
handler.once = true;
}
ret.push(handler.apply(handlerCtx, processEventArgs(
const params = processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
)));
) || [];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret.push(handler.apply(handlerCtx, params.concat([, , , , , , , , , , event])));
}
});
}
......@@ -1634,7 +1649,8 @@ const hooks = [
'onHide',
'onError',
'onPageNotFound',
'onThemeChange'
'onThemeChange',
'onUnhandledRejection'
];
function parseBaseApp (vm, {
......@@ -1914,10 +1930,12 @@ function triggerEvent (type, detail, options) {
}
const eventOpts = this.props['data-event-opts'];
const eventParams = this.props['data-event-params'];
const target = {
dataset: {
eventOpts
eventOpts,
eventParams
}
};
......@@ -2088,6 +2106,14 @@ function parsePage (vuePageOptions) {
};
initHooks(pageOptions, hooks$1, vuePageOptions);
if (Array.isArray(vueOptions.wxsCallMethods)) {
vueOptions.wxsCallMethods.forEach(callMethod => {
pageOptions[callMethod] = function (args) {
return this.$vm[callMethod](args)
};
});
}
return pageOptions
}
......@@ -2203,6 +2229,14 @@ function parseComponent (vueComponentOptions) {
componentOptions.deriveDataFromProps = createObserver$1();
} else {
componentOptions.didUpdate = createObserver$1(true);
}
if (Array.isArray(vueOptions.wxsCallMethods)) {
vueOptions.wxsCallMethods.forEach(callMethod => {
componentOptions.methods[callMethod] = function (args) {
return this.$vm[callMethod](args)
};
});
}
return componentOptions
......@@ -2231,7 +2265,7 @@ let uni = {};
if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') {
uni = new Proxy({}, {
get (target, name) {
if (target[name]) {
if (hasOwn(target, name)) {
return target[name]
}
if (baseApi[name]) {
......@@ -2257,7 +2291,7 @@ if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') {
return promisify(name, wrapper(name, my[name]))
},
set (target, name, value) {
target[name] = value;
target[name] = value;
return true
}
});
......
此差异已折叠。
此差异已折叠。
const t = require('@babel/types')
const traverse = require('@babel/traverse').default
function cached (fn) {
const cache = Object.create(null)
return function cachedFn (str) {
......@@ -82,12 +85,55 @@ module.exports = {
type: 'view',
attr: {
slot: slotName
},
children: normalizeChildren(traverseExpr(returnExprNodes, state))
}
}
if (paramExprNode && paramExprNode.type === 'Identifier') {
node.scoped = paramExprNode.name
if (paramExprNode) {
if (t.isIdentifier(paramExprNode)) {
const scoped = paramExprNode.name
node.attr['slot-scope'] = scoped
} else if (t.isObjectPattern(paramExprNode)) {
const paramName = '__SCOPED__'
node.attr['slot-scope'] = paramName
const start = returnExprNodes.start
const end = returnExprNodes.end
const names = []
paramExprNode.properties.forEach(property => {
const key = property.key
const value = property.value
if (t.isIdentifier(value)) {
if (value.name !== key.name) {
state.errors.add(`解构插槽 Prop 时,不支持将${key.name}重命名为${value.name},重命名后会影响性能`)
return
}
} else if (t.isAssignmentPattern(value)) {
state.errors.add(`解构插槽 Prop 时,不支持为${key.name}设置默认值`)
return
}
names.push(key.name)
})
traverse({
type: 'Program',
start,
end,
body: [{
type: 'ExpressionStatement',
start,
end,
expression: returnExprNodes
}],
sourceType: 'module'
}, {
Identifier (path) {
const node = path.node
const name = node.name
if (names.includes(name) && path.key !== 'key' && (path.key !== 'property' || path.parent.computed) && !(path.scope && path.scope.hasBinding(name))) {
path.replaceWithSourceString(`${paramName}.${name}`)
}
}
})
}
}
node.children = normalizeChildren(traverseExpr(returnExprNodes, state))
return node
}
}
}
{
"name": "@dcloudio/uni-mp-alipay",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"repository": {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
{
"name": "@dcloudio/uni-mp-baidu",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"repository": {
......
......@@ -134,7 +134,7 @@ function queue (hooks, data) {
for (let i = 0; i < hooks.length; i++) {
const hook = hooks[i];
if (promise) {
promise = Promise.then(wrapperHook(hook));
promise = Promise.resolve(wrapperHook(hook));
} else {
const res = hook(data);
if (isPromise(res)) {
......@@ -494,7 +494,9 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
toArgs[keyOption.name ? keyOption.name : key] = keyOption.value;
}
} else if (CALLBACKS.indexOf(key) !== -1) {
toArgs[key] = processCallback(methodName, fromArgs[key], returnValue);
if (isFn(fromArgs[key])) {
toArgs[key] = processCallback(methodName, fromArgs[key], returnValue);
}
} else {
if (!keepFromArgs) {
toArgs[key] = fromArgs[key];
......@@ -609,10 +611,6 @@ var extraApi = /*#__PURE__*/Object.freeze({
});
const getEmitter = (function () {
if (typeof getUniEmitter === 'function') {
/* eslint-disable no-undef */
return getUniEmitter
}
let Emitter;
return function getUniEmitter () {
if (!Emitter) {
......@@ -694,6 +692,8 @@ Component = function (options = {}) {
const PAGE_EVENT_HOOKS = [
'onPullDownRefresh',
'onReachBottom',
'onAddToFavorites',
'onShareTimeline',
'onShareAppMessage',
'onPageScroll',
'onResize',
......@@ -895,6 +895,11 @@ function initProperties (props, isBehavior = false, file = '') {
type: String,
value: ''
};
// 用于字节跳动小程序模拟抽象节点
properties.generic = {
type: Object,
value: null
};
properties.vueSlots = { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
type: null,
value: [],
......@@ -1127,6 +1132,15 @@ function isMatchEventType (eventType, optType) {
)
}
function getContextVm (vm) {
let $parent = vm.$parent;
// 父组件是 scoped slots 或者其他自定义组件时继续查找
while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) {
$parent = $parent.$parent;
}
return $parent && $parent.$parent
}
function handleEvent (event) {
event = wrapper$1(event);
......@@ -1159,12 +1173,8 @@ function handleEvent (event) {
const methodName = eventArray[0];
if (methodName) {
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
if (handlerCtx.$options.generic) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = getContextVm(handlerCtx) || handlerCtx;
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
......@@ -1188,14 +1198,17 @@ function handleEvent (event) {
}
handler.once = true;
}
ret.push(handler.apply(handlerCtx, processEventArgs(
const params = processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
)));
) || [];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret.push(handler.apply(handlerCtx, params.concat([, , , , , , , , , , event])));
}
});
}
......@@ -1215,7 +1228,8 @@ const hooks = [
'onHide',
'onError',
'onPageNotFound',
'onThemeChange'
'onThemeChange',
'onUnhandledRejection'
];
function parseBaseApp (vm, {
......@@ -1561,7 +1575,7 @@ let uni = {};
if (typeof Proxy !== 'undefined' && "mp-qq" !== 'app-plus') {
uni = new Proxy({}, {
get (target, name) {
if (target[name]) {
if (hasOwn(target, name)) {
return target[name]
}
if (baseApi[name]) {
......@@ -1587,7 +1601,7 @@ if (typeof Proxy !== 'undefined' && "mp-qq" !== 'app-plus') {
return promisify(name, wrapper(name, wx[name]))
},
set (target, name, value) {
target[name] = value;
target[name] = value;
return true
}
});
......
此差异已折叠。
此差异已折叠。
{
"name": "@dcloudio/uni-mp-qq",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app mp-qq",
"main": "dist/index.js",
"repository": {
......
此差异已折叠。
此差异已折叠。
{
"name": "@dcloudio/uni-mp-toutiao",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app mp-toutiao",
"main": "dist/index.js",
"repository": {
......
此差异已折叠。
此差异已折叠。
{
"name": "@dcloudio/uni-mp-vue",
"version": "2.0.0-alpha-28420200805004",
"description": "@dcloudio/uni-mp-vue",
"main": "dist/vue.runtime.esm.js",
"module": "dist/vue.runtime.esm.js",
"files": [
"dist"
],
"buildOptions": {
"name": "Vue",
"formats": [
"esm-bundler-vue"
]
},
"sideEffects": false,
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-mp-vue"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/dcloudio/uni-app/issues"
}
}
此差异已折叠。
此差异已折叠。
{
"name": "@dcloudio/uni-mp-weixin",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"repository": {
......
{
"name": "@dcloudio/uni-quickapp-native",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app quickapp-native",
"main": "dist/vue.prod.js",
"repository": {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
{
"name": "@dcloudio/uni-quickapp-webview",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app quickapp-webview",
"main": "dist/index.js",
"repository": {
......
{
"name": "@dcloudio/uni-stat",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "",
"main": "dist/index.js",
"repository": {
......
......@@ -380,12 +380,9 @@ const requestData = (done) => {
if (report_status_code === '') {
report_status_code = 1
}
if (report_status_code === 1) {
typeof done === 'function' && done({
enable: res.enable
})
}
// console.error('统计请求错误');
typeof done === 'function' && done({
enable: report_status_code
})
}
});
}
......@@ -62,6 +62,8 @@ module.exports = {
VAR_FILTER: 'F',
ATTR_DATA_EVENT_OPTS: 'data-event-opts',
ATTR_DATA_COM_TYPE: 'data-com-type',
ATTR_DATA_EVENT_PARAMS: 'data-event-params',
ATTE_DATA_CUSTOM_HIDDEN: 'data-custom-hidden',
INTERNAL_GET_ORIG,
INTERNAL_GET_CLASS,
INTERNAL_GET_STYLE,
......@@ -120,4 +122,4 @@ module.exports = {
IDENTIFIER_STYLE: '__$$style$$__',
IDENTIFIER_EVENT: '__$$event$$__',
IDENTIFIER_GLOBAL: '__$$global$$__'
}
}
const {
IDENTIFIER_ATTR
} = require('../../../constants')
// const {
// IDENTIFIER_ATTR
// } = require('../../../constants')
const getMemberExpr = require('../member-expr')
// const getMemberExpr = require('../member-expr')
module.exports = function processAttrs (paths, path, state, isComponent, tagName) {
const attrsPath = paths.attrs
if (attrsPath) {
attrsPath.get('value.properties').forEach(propertyPath => {
const valuePath = propertyPath.get('value')
if (valuePath.isObjectExpression()) {
valuePath.replaceWith(getMemberExpr(null, IDENTIFIER_ATTR, valuePath.node, state))
}
})
}
// 不再单独处理ObjectExpression,改为在转换temlplte时用()包裹(微信、QQ)
// const attrsPath = paths.attrs
// if (attrsPath) {
// attrsPath.get('value.properties').forEach(propertyPath => {
// const valuePath = propertyPath.get('value')
// if (valuePath.isObjectExpression()) {
// valuePath.replaceWith(getMemberExpr(null, IDENTIFIER_ATTR, valuePath.node, state))
// }
// })
// }
return []
}
}
......@@ -43,20 +43,24 @@ function getMapCallExpression (
forIndex
) {
const blockStatement = []
// var $orgi = __get_orig(forItem)
blockStatement.push(t.variableDeclaration('var', [
t.variableDeclarator(t.identifier(VAR_ORIGINAL), t.callExpression(t.identifier(INTERNAL_GET_ORIG), [
t.identifier(forItem)
]))
]))
if (declarationArray.length) {
declarationArray.forEach(declaration => {
blockStatement.push(declaration)
})
blockStatement.push(t.returnStatement(
// return {$orgi:__get_orig(forItem)}
// return {$orgi:$orgi}
t.objectExpression(
[
t.objectProperty(
t.identifier(VAR_ORIGINAL),
t.callExpression(t.identifier(INTERNAL_GET_ORIG), [
t.identifier(forItem)
])
t.identifier(VAR_ORIGINAL)
)
].concat(objectPropertyArray)
)
......@@ -116,4 +120,4 @@ module.exports = {
getMapCallExpression,
getDataExpressionStatement,
getEventExpressionStatement
}
}
......@@ -132,7 +132,7 @@ function checkUsingGlobalComponents (name, globalUsingComponents, state) {
}
module.exports = {
noScope: true,
noScope: false,
MemberExpression (path) {
if ( // t.m(123)
t.isIdentifier(path.node.object) &&
......
{
"name": "@dcloudio/uni-template-compiler",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-template-compiler",
"main": "lib/index.js",
"repository": {
......
......@@ -25,7 +25,7 @@ const postcssLoader = {
options: {
sourceMap: false,
parser: require('postcss-comment'),
plugins: [
plugins: [
require('postcss-import')({
resolve (id, basedir, importOptions) {
if (id.startsWith('~@/')) {
......@@ -77,12 +77,13 @@ if (sassLoaderVersion < 8) {
sassLoader.options.outputStyle = 'expanded'
sassLoader.options.indentedSyntax = true
} else {
scssLoader.options.prependData = sassData
const name = sassLoaderVersion >= 9 ? 'additionalData' : 'prependData'
scssLoader.options[name] = sassData
scssLoader.options.sassOptions = {
outputStyle: 'expanded'
}
sassLoader.options.prependData = sassData
sassLoader.options[name] = sassData
sassLoader.options.sassOptions = {
outputStyle: 'expanded',
indentedSyntax: true
......
......@@ -205,7 +205,14 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
const array = [{
from: path.resolve(process.env.UNI_INPUT_DIR, 'static'),
to: 'static'
}]
}]
const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, 'hybrid/html')
if (fs.existsSync(hybridHtmlPath)) {
array.push({
from: hybridHtmlPath,
to: 'hybrid/html'
})
}
if (process.env.UNI_USING_NVUE_COMPILER) {
array.push({
from: path.resolve(getTemplatePath(), 'common'),
......
{
"name": "@dcloudio/vue-cli-plugin-hbuilderx",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "HBuilderX plugin for vue-cli 3",
"main": "index.js",
"repository": {
......
......@@ -85,8 +85,9 @@ module.exports = function initOptions (options) {
if (sassLoaderVersion < 8) {
options.css.loaderOptions.sass.data = sassData
} else {
options.css.loaderOptions.sass.prependData = sassData
} else {
const name = sassLoaderVersion >= 9 ? 'additionalData' : 'prependData'
options.css.loaderOptions.sass[name] = sassData
}
const userPostcssConfigPath = path.resolve(process.env.UNI_INPUT_DIR, 'postcss.config.js')
......
{
"name": "@dcloudio/webpack-uni-mp-loader",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "webpack-uni-mp-loader",
"main": "index.js",
"repository": {
......
......@@ -12,7 +12,9 @@ const {
const {
addPageUsingComponents
} = require('@dcloudio/uni-cli-shared/lib/pages')
} = require('@dcloudio/uni-cli-shared/lib/pages')
const compilerVersion = require('@dcloudio/webpack-uni-pages-loader/package.json')['uni-app'].compilerVersion
const PLATFORMS = getPlatforms()
......@@ -400,7 +402,8 @@ module.exports = function (pagesJson, manifestJson, loader) {
import Vue from 'vue'
global['____${h5.appid}____'] = true;
delete global['____${h5.appid}____'];
global.__uniConfig = ${JSON.stringify(pagesJson)};
global.__uniConfig = ${JSON.stringify(pagesJson)};
global.__uniConfig.compilerVersion = '${compilerVersion}';
global.__uniConfig.router = ${JSON.stringify(h5.router)};
global.__uniConfig.publicPath = ${JSON.stringify(h5.publicPath)};
global.__uniConfig['async'] = ${JSON.stringify(h5.async)};
......
{
"name": "@dcloudio/webpack-uni-pages-loader",
"version": "2.0.0-alpha-28020200701002",
"version": "2.0.0-alpha-28420200805004",
"description": "uni-app pages.json loader",
"main": "lib/index.js",
"repository": {
......@@ -21,7 +21,7 @@
"strip-json-comments": "^2.0.1"
},
"uni-app": {
"compilerVersion": "2.8.0"
"compilerVersion": "2.8.4"
},
"gitHead": "e62f0398362f2f9de0bf5726046d7951c88d6b1d"
}
......@@ -97,7 +97,7 @@ function queue (hooks, data) {
for (let i = 0; i < hooks.length; i++) {
const hook = hooks[i]
if (promise) {
promise = Promise.then(wrapperHook(hook))
promise = Promise.resolve(wrapperHook(hook))
} else {
const res = hook(data)
if (isPromise(res)) {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册