提交 934d5662 编写于 作者: Q qiang

Merge branch 'dev' of github.com:dcloudio/uni-app into dev

...@@ -5,3 +5,4 @@ packages/*/packages ...@@ -5,3 +5,4 @@ packages/*/packages
packages/*/template/**/* packages/*/template/**/*
packages/uni-h5/src packages/uni-h5/src
packages/uni-stat packages/uni-stat
node_modules
...@@ -21,7 +21,7 @@ del.sync(['node_modules/.cache']) ...@@ -21,7 +21,7 @@ del.sync(['node_modules/.cache'])
let pluginDir = process.argv[2] let pluginDir = process.argv[2]
if (!pluginDir) { if (!pluginDir) {
console.error(`缺少参数`) console.error('缺少参数')
process.exit(0) process.exit(0)
} }
...@@ -31,7 +31,7 @@ if (pluginDir.indexOf('/') === -1) { ...@@ -31,7 +31,7 @@ if (pluginDir.indexOf('/') === -1) {
const pkg = require(path.join(pluginDir, 'package.json')) const pkg = require(path.join(pluginDir, 'package.json'))
if (!pkg['uni-app']) { if (!pkg['uni-app']) {
console.error(`缺少 uni-app 配置`) console.error('缺少 uni-app 配置')
process.exit(0) process.exit(0)
} }
...@@ -51,8 +51,8 @@ service.webpackRawConfigFns.push(function () { ...@@ -51,8 +51,8 @@ service.webpackRawConfigFns.push(function () {
use: [{ use: [{
loader: path.resolve(__dirname, '../lib/extends-loader'), loader: path.resolve(__dirname, '../lib/extends-loader'),
options: { options: {
'extends': path.resolve(pluginDir, 'src/service/api'), extends: path.resolve(pluginDir, 'src/service/api'),
'base': path.resolve(__dirname, '../src/platforms/h5/service/api') base: path.resolve(__dirname, '../src/platforms/h5/service/api')
} }
}] }]
}] }]
......
...@@ -24,33 +24,33 @@ const TOAST_DEPS = [ ...@@ -24,33 +24,33 @@ const TOAST_DEPS = [
// TODO 暂不考虑 head,tabBar 的动态拆分 // TODO 暂不考虑 head,tabBar 的动态拆分
const DEPS = { const DEPS = {
'chooseLocation': [ chooseLocation: [
['/platforms/h5/components/system-routes/choose-location/index.vue', 'ChooseLocation'] ['/platforms/h5/components/system-routes/choose-location/index.vue', 'ChooseLocation']
], ],
'openLocation': [ openLocation: [
['/platforms/h5/components/system-routes/open-location/index.vue', 'OpenLocation'] ['/platforms/h5/components/system-routes/open-location/index.vue', 'OpenLocation']
], ],
'previewImage': [ previewImage: [
['/core/view/components/swiper/index.vue', 'Swiper'], ['/core/view/components/swiper/index.vue', 'Swiper'],
['/core/view/components/swiper-item/index.vue', 'SwiperItem'], ['/core/view/components/swiper-item/index.vue', 'SwiperItem'],
['/platforms/h5/components/system-routes/preview-image/index.vue', 'PreviewImage'] ['/platforms/h5/components/system-routes/preview-image/index.vue', 'PreviewImage']
], ],
'showToast': TOAST_DEPS, showToast: TOAST_DEPS,
'hideToast': TOAST_DEPS, hideToast: TOAST_DEPS,
'showLoading': TOAST_DEPS, showLoading: TOAST_DEPS,
'hideLoading': TOAST_DEPS, hideLoading: TOAST_DEPS,
'showModal': [ showModal: [
['/platforms/h5/components/app/popup/modal.vue', 'Modal'], ['/platforms/h5/components/app/popup/modal.vue', 'Modal'],
['/platforms/h5/components/app/popup/mixins/modal.js', 'ModalMixin'] ['/platforms/h5/components/app/popup/mixins/modal.js', 'ModalMixin']
], ],
'showActionSheet': [ showActionSheet: [
['/platforms/h5/components/app/popup/actionSheet.vue', 'ActionSheet'], ['/platforms/h5/components/app/popup/actionSheet.vue', 'ActionSheet'],
['/platforms/h5/components/app/popup/mixins/action-sheet.js', 'ActionSheetMixin'] ['/platforms/h5/components/app/popup/mixins/action-sheet.js', 'ActionSheetMixin']
], ],
'createSelectorQuery': [ createSelectorQuery: [
['/core/view/bridge/subscribe/api/request-component-info.js', 'requestComponentInfo'] ['/core/view/bridge/subscribe/api/request-component-info.js', 'requestComponentInfo']
], ],
'createIntersectionObserver': [ createIntersectionObserver: [
['/core/view/bridge/subscribe/api/request-component-observer.js', 'requestComponentObserver'], ['/core/view/bridge/subscribe/api/request-component-observer.js', 'requestComponentObserver'],
['/core/view/bridge/subscribe/api/request-component-observer.js', 'destroyComponentObserver'] ['/core/view/bridge/subscribe/api/request-component-observer.js', 'destroyComponentObserver']
] ]
......
const path = require('path') const path = require('path')
const alias = require('rollup-plugin-alias') const alias = require('@rollup/plugin-alias')
const replace = require('rollup-plugin-replace') const replace = require('@rollup/plugin-replace')
const nodeResolve = require('rollup-plugin-node-resolve') const nodeResolve = require('@rollup/plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs') const commonjs = require('@rollup/plugin-commonjs')
const requireContext = require('../lib/rollup-plugin-require-context') const requireContext = require('../lib/rollup-plugin-require-context')
let input = 'src/platforms/app-plus/service/framework/create-instance-context.js' let input = 'src/platforms/app-plus/service/framework/create-instance-context.js'
...@@ -27,9 +27,9 @@ if (process.env.UNI_SERVICE === 'legacy') { ...@@ -27,9 +27,9 @@ if (process.env.UNI_SERVICE === 'legacy') {
} else { } else {
input = 'src/platforms/app-plus/service/index.js' input = 'src/platforms/app-plus/service/index.js'
if (process.env.UNI_PLATFORM === 'app-plus') { if (process.env.UNI_PLATFORM === 'app-plus') {
output.file = `packages/uni-app-plus/dist/index.v3.js` output.file = 'packages/uni-app-plus/dist/index.v3.js'
} else { } else {
output.file = `packages/uni-app-plus-nvue/dist/index.js` output.file = 'packages/uni-app-plus-nvue/dist/index.js'
} }
output.format = 'iife' output.format = 'iife'
output.name = 'serviceContext' output.name = 'serviceContext'
...@@ -63,19 +63,35 @@ module.exports = { ...@@ -63,19 +63,35 @@ module.exports = {
output, output,
plugins: [ plugins: [
alias({ alias({
// 'vue': resolve('packages/uni-app-plus/dist/service.runtime.esm.js'), entries: [{
'uni-core': resolve('src/core'), find: 'uni-core',
'uni-platform': resolve('src/platforms/' + process.env.UNI_PLATFORM), replacement: resolve('src/core')
'uni-platforms': resolve('src/platforms'), }, {
'uni-shared': resolve('src/shared/index.js'), find: 'uni-platform',
'uni-helpers': resolve('src/core/helpers'), replacement: resolve('src/platforms/' + process.env.UNI_PLATFORM)
'uni-invoke-api': resolve('src/platforms/app-plus/service/api'), }, {
'uni-service-api': resolve('src/core/service/platform-api'), find: 'uni-platforms',
'uni-api-protocol': resolve('src/core/helpers/protocol') replacement: resolve('src/platforms')
}, {
find: 'uni-shared',
replacement: resolve('src/shared/index.js')
}, {
find: 'uni-helpers',
replacement: resolve('src/core/helpers')
}, {
find: 'uni-invoke-api',
replacement: resolve('src/platforms/app-plus/service/api')
}, {
find: 'uni-service-api',
replacement: resolve('src/core/service/platform-api')
}, {
find: 'uni-api-protocol',
replacement: resolve('src/core/helpers/protocol')
}]
}), }),
nodeResolve(), nodeResolve(),
commonjs(),
requireContext(), requireContext(),
commonjs(),
replace({ replace({
__GLOBAL__: 'getGlobalUni()', __GLOBAL__: 'getGlobalUni()',
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM), __PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM),
......
const path = require('path') const path = require('path')
const alias = require('rollup-plugin-alias') const alias = require('@rollup/plugin-alias')
const replace = require('rollup-plugin-replace') const replace = require('@rollup/plugin-replace')
const PLATFORMS = { const PLATFORMS = {
'mp-weixin': { 'mp-weixin': {
...@@ -51,10 +51,19 @@ module.exports = { ...@@ -51,10 +51,19 @@ module.exports = {
output, output,
plugins: [ plugins: [
alias({ alias({
'uni-shared': path.resolve(__dirname, '../src/shared/util.js'), entries: [{
'uni-platform': path.resolve(__dirname, '../src/platforms/' + process.env.UNI_PLATFORM), find: 'uni-shared',
'uni-wrapper': path.resolve(__dirname, '../src/core/runtime/wrapper'), replacement: path.resolve(__dirname, '../src/shared/util.js')
'uni-helpers': path.resolve(__dirname, '../src/core/helpers') }, {
find: 'uni-platform',
replacement: path.resolve(__dirname, '../src/platforms/' + process.env.UNI_PLATFORM)
}, {
find: 'uni-wrapper',
replacement: path.resolve(__dirname, '../src/core/runtime/wrapper')
}, {
find: 'uni-helpers',
replacement: path.resolve(__dirname, '../src/core/helpers')
}]
}), }),
replace({ replace({
__GLOBAL__: platform.prefix, __GLOBAL__: platform.prefix,
......
const path = require('path') const path = require('path')
const alias = require('rollup-plugin-alias') const alias = require('@rollup/plugin-alias')
const replace = require('rollup-plugin-replace') const replace = require('@rollup/plugin-replace')
const nodeResolve = require('rollup-plugin-node-resolve') const nodeResolve = require('@rollup/plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs') const commonjs = require('@rollup/plugin-commonjs')
const terser = require('rollup-plugin-terser') const terser = require('rollup-plugin-terser')
const requireContext = require('../lib/rollup-plugin-require-context') const requireContext = require('../lib/rollup-plugin-require-context')
...@@ -31,14 +31,31 @@ const plugins = [{ ...@@ -31,14 +31,31 @@ const plugins = [{
} }
}, },
alias({ alias({
'uni-core': resolve('src/core'), entries: [{
'uni-platform': resolve('src/platforms/quickapp-vue'), find: 'uni-core',
'uni-platforms': resolve('src/platforms'), replacement: resolve('src/core')
'uni-shared': resolve('src/shared/index.js'), }, {
'uni-helpers': resolve('src/core/helpers'), find: 'uni-platform',
'uni-invoke-api': resolve('src/platforms/quickapp-vue/service/invoke-api'), replacement: resolve('src/platforms/quickapp-vue')
'uni-service-api': resolve('src/platforms/quickapp-vue/service/api'), }, {
'uni-api-protocol': resolve('src/core/helpers/protocol') find: 'uni-platforms',
replacement: resolve('src/platforms')
}, {
find: 'uni-shared',
replacement: resolve('src/shared/index.js')
}, {
find: 'uni-helpers',
replacement: resolve('src/core/helpers')
}, {
find: 'uni-invoke-api',
replacement: resolve('src/platforms/quickapp-vue/service/invoke-api')
}, {
find: 'uni-service-api',
replacement: resolve('src/platforms/quickapp-vue/service/api')
}, {
find: 'uni-api-protocol',
replacement: resolve('src/core/helpers/protocol')
}]
}), }),
nodeResolve(), nodeResolve(),
requireContext(), requireContext(),
......
const path = require('path') const path = require('path')
const alias = require('rollup-plugin-alias') const alias = require('@rollup/plugin-alias')
const replace = require('rollup-plugin-replace') const replace = require('@rollup/plugin-replace')
module.exports = { module.exports = {
input: 'src/platforms/app-plus-nvue/services/index.legacy.old.js', input: 'src/platforms/app-plus-nvue/services/index.legacy.old.js',
output: { output: {
file: `packages/uni-app-plus-nvue/dist/service.legacy.js`, file: 'packages/uni-app-plus-nvue/dist/service.legacy.js',
format: 'es' format: 'es'
}, },
plugins: [ plugins: [
alias({ alias({
'uni-core': path.resolve(__dirname, '../src/core'), entries: [{
'uni-shared': path.resolve(__dirname, '../src/shared/util.js'), find: 'uni-core',
'uni-helpers': path.resolve(__dirname, '../src/core/helpers') replacement: path.resolve(__dirname, '../src/core')
},
{
find: 'uni-shared',
replacement: path.resolve(__dirname, '../src/shared/util.js')
},
{
find: 'uni-helpers',
replacement: path.resolve(__dirname, '../src/core/helpers')
}
]
}), }),
replace({ replace({
__GLOBAL__: 'getGlobalUni()', __GLOBAL__: 'getGlobalUni()',
......
const path = require('path') const path = require('path')
const babel = require('rollup-plugin-babel') const babel = require('rollup-plugin-babel')
const alias = require('rollup-plugin-alias') const alias = require('@rollup/plugin-alias')
const uglify = require('rollup-plugin-uglify') const terser = require('rollup-plugin-terser')
module.exports = { module.exports = {
input: 'src/core/runtime/web-view/index.js', input: 'src/core/runtime/web-view/index.js',
output: { output: {
name: 'uni', name: 'uni',
file: `dist/uni.webview.1.5.2.js`, file: 'dist/uni.webview.1.5.2.js',
format: 'umd' format: 'umd'
}, },
plugins: [ plugins: [
alias({ alias({
'uni-platforms': path.resolve(__dirname, '../src/platforms') entries: [{
find: 'uni-shared',
replacement: path.resolve(__dirname, '../src/shared/index.js')
}, {
find: 'uni-platforms',
replacement: path.resolve(__dirname, '../src/platforms')
}]
}), }),
babel(), babel(),
uglify.uglify({ terser.terser()
output: {
ascii_only: true
}
})
] ]
} }
...@@ -8,7 +8,7 @@ const pkg = require('../package.json') ...@@ -8,7 +8,7 @@ const pkg = require('../package.json')
const externals = {} const externals = {}
if (process.env.UNI_VIEW !== 'true') { if (process.env.UNI_VIEW !== 'true') {
externals['vue'] = { externals.vue = {
commonjs: 'vue', commonjs: 'vue',
commonjs2: 'vue', commonjs2: 'vue',
root: 'Vue' root: 'Vue'
...@@ -41,16 +41,16 @@ const alias = { ...@@ -41,16 +41,16 @@ const alias = {
} }
const provides = { const provides = {
'console': [resolve('src/core/helpers/console'), 'default'], console: [resolve('src/core/helpers/console'), 'default'],
'UniViewJSBridge': [resolve('src/core/view/bridge/index')], UniViewJSBridge: [resolve('src/core/view/bridge/index')],
'UniServiceJSBridge': [resolve('src/core/service/bridge/index')] UniServiceJSBridge: [resolve('src/core/service/bridge/index')]
} }
if (process.env.UNI_VIEW) { // 方便调试 if (process.env.UNI_VIEW) { // 方便调试
delete provides['console'] delete provides.console
} }
if (process.env.UNI_VIEW === 'true') { if (process.env.UNI_VIEW === 'true') {
alias['vue$'] = resolve('packages/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js') alias.vue$ = resolve('packages/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js')
} }
module.exports = { module.exports = {
......
...@@ -49,9 +49,9 @@ config.plugins = config.plugins.concat([ ...@@ -49,9 +49,9 @@ config.plugins = config.plugins.concat([
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM) __PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM)
}), }),
new webpack.ProvidePlugin({ new webpack.ProvidePlugin({
'console': [resolve('src/core/helpers/console'), 'default'], console: [resolve('src/core/helpers/console'), 'default'],
'UniViewJSBridge': [resolve('src/core/view/bridge/index')], UniViewJSBridge: [resolve('src/core/view/bridge/index')],
'UniServiceJSBridge': [resolve('src/core/service/bridge/index')] UniServiceJSBridge: [resolve('src/core/service/bridge/index')]
}) })
]) ])
module.exports = config module.exports = config
!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";function i(e,n){var i={options:{timestamp:+new Date},name:e,arg:n};if(window.__dcloud_weex_postMessage||window.__dcloud_weex_){if("postMessage"===e){var t={data:[n]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(t):window.__dcloud_weex_.postMessage(JSON.stringify(t))}var o={type:c,args:{data:i,webviewIds:w}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(o):window.__dcloud_weex_.postMessageToService(JSON.stringify(o))}if(!window.plus)return window.parent.postMessage({type:c,data:i,pageId:""},"*");if(0===w.length){var a=plus.webview.currentWebview();if(!a)throw new Error("plus.webview.currentWebview() is undefined");var d=a.parent(),r="";r=d?d.id:a.id,w.push(r)}if(plus.webview.getWebviewById(u))plus.webview.postMessageToUniNView({type:c,args:{data:i,webviewIds:w}},u);else{var s=JSON.stringify(i);plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat(c,'",').concat(s,",").concat(JSON.stringify(w),");"))}}var w=[],u="__uniapp__service",c="WEB_INVOKE_APPSERVICE",n={navigateTo:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("navigateTo",{url:encodeURI(n)})},navigateBack:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).delta;i("navigateBack",{delta:parseInt(n)||1})},switchTab:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("switchTab",{url:encodeURI(n)})},reLaunch:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("reLaunch",{url:encodeURI(n)})},redirectTo:function(e){var n=(0<arguments.length&&void 0!==e?e:{}).url;i("redirectTo",{url:encodeURI(n)})},getEnv:function(e){window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(e){i("postMessage",(0<arguments.length&&void 0!==e?e:{}).data||{})}},t=/uni-app/i.test(navigator.userAgent),o=/complete|loaded|interactive/;var a=window.my&&-1<navigator.userAgent.indexOf("AlipayClient");var d=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var r=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var s=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);for(var e,v=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},p=[function(e){if(t)return window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",e):window.plus&&o.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),n},function(e){if(g)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(r)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(a){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(d)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(s)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){return document.addEventListener("DOMContentLoaded",e),n}],l=0;l<p.length&&!(e=p[l](v));l++);e=e||{};var f="undefined"!=typeof uni?uni:{};if(!f.navigateTo)for(var _ in e)e.hasOwnProperty(_)&&(f[_]=e[_]);return f.webView=e,f}); !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}));
{ {
"name": "uniapp-js-framework", "name": "uni-app",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build:service:legacy": "npm run lint && rollup -c build/rollup.config.service.js",
"lint": "eslint --fix --config package.json --ext .js --ext .vue --ignore-path .eslintignore build src", "lint": "eslint --fix --config package.json --ext .js --ext .vue --ignore-path .eslintignore build src",
"lint:cli": "eslint --fix --config package.json --ext .js --ext .vue --ignore-path .eslintignore packages/uni-cli-shared packages/uni-template-compiler \"packages/uni-*/lib/*.js\" \"packages/vue-cli-*/**/*.js\" \"packages/webpack-uni-*/**/*.js\"", "lint:cli": "eslint --fix --config package.json --ext .js --ext .vue --ignore-path .eslintignore packages/uni-cli-shared packages/uni-template-compiler \"packages/uni-*/lib/*.js\" \"packages/vue-cli-*/**/*.js\" \"packages/webpack-uni-*/**/*.js\"",
"dev:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.js", "dev:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.js",
"build:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.js", "build:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.js",
"build:h5:ui": "cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 UNI_UI=true node build/build.js",
"dev:plugin": "cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.plugin.js", "dev:plugin": "cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.plugin.js",
"build:plugin": "cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.plugin.js", "build:plugin": "cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.plugin.js",
"build:app-plus": "cross-env UNI_PLATFORM=app-plus rollup -c build/rollup.config.mp.js", "build:app-plus": "cross-env UNI_PLATFORM=app-plus rollup -c build/rollup.config.mp.js",
"build:app:all": "npm run lint && npm run build:app:nvue && npm run build:app:legacy && npm run build:app:service && npm run build:app:view", "build:app:v3": "npm run lint && npm run build:app:service && npm run build:app:view",
"build:app:v3": "npm run lint && npm run build:app:service && npm run dev:app:view",
"build:app:service": "cross-env UNI_PLATFORM=app-plus rollup -c build/rollup.config.app.js", "build:app:service": "cross-env UNI_PLATFORM=app-plus rollup -c build/rollup.config.app.js",
"build:app:view": "cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=app-plus UNI_VIEW=true node build/build.js", "build:app:view": "cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=app-plus UNI_VIEW=true node build/build.js",
"dev:app:view": "cross-env NODE_ENV=development UNI_WATCH=true UNI_PLATFORM=app-plus UNI_VIEW=true node build/build.js", "dev:app:view": "cross-env NODE_ENV=development UNI_WATCH=true UNI_PLATFORM=app-plus UNI_VIEW=true node build/build.js",
"build:app:nvue": "cross-env UNI_PLATFORM=app-plus-nvue rollup -c build/rollup.config.app.js",
"build:app:legacy": "cross-env UNI_PLATFORM=app-plus-nvue UNI_SERVICE=legacy rollup -c build/rollup.config.app.js",
"build:mp-qq": "cross-env UNI_PLATFORM=mp-qq rollup -c build/rollup.config.mp.js", "build:mp-qq": "cross-env UNI_PLATFORM=mp-qq rollup -c build/rollup.config.mp.js",
"build:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin rollup -c build/rollup.config.mp.js", "build:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin rollup -c build/rollup.config.mp.js",
"build:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu rollup -c build/rollup.config.mp.js", "build:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu rollup -c build/rollup.config.mp.js",
"build:mp-alipay": "cross-env UNI_PLATFORM=mp-alipay rollup -c build/rollup.config.mp.js", "build:mp-alipay": "cross-env UNI_PLATFORM=mp-alipay rollup -c build/rollup.config.mp.js",
"build:mp-toutiao": "cross-env UNI_PLATFORM=mp-toutiao rollup -c build/rollup.config.mp.js", "build:mp-toutiao": "cross-env UNI_PLATFORM=mp-toutiao rollup -c build/rollup.config.mp.js",
"build:quickapp-light": "cross-env UNI_PLATFORM=quickapp-light rollup -c build/rollup.config.mp.js", "build:quickapp-light": "cross-env UNI_PLATFORM=quickapp-light rollup -c build/rollup.config.mp.js",
"build:mp-weixin:mp": "npm run lint && cross-env UNI_PLATFORM=mp-weixin UNI_MP=true rollup -c build/rollup.config.mp.js", "build:mp-weixin:mp": "cross-env UNI_PLATFORM=mp-weixin UNI_MP=true rollup -c build/rollup.config.mp.js",
"build:mp-weixin:wxs": "rollup -c build/rollup.config.wxs.js", "build:mp-weixin:wxs": "rollup -c build/rollup.config.wxs.js",
"build:quickapp-vue": "cross-env NODE_ENV=development node build/build.qa.js && cross-env NODE_ENV=production node build/build.qa.js", "build:quickapp-vue": "cross-env NODE_ENV=development node build/build.qa.js && cross-env NODE_ENV=production node build/build.qa.js",
"build:runtime": "npm run lint && npm run build:mp-weixin && npm run build:mp-qq && npm run build:mp-alipay && npm run build:mp-baidu && npm run build:mp-toutiao && npm run build:app-plus && npm run build:quickapp-light && npm run build:quickapp-vue", "build:runtime": "npm run lint && npm run build:mp-weixin && npm run build:mp-qq && npm run build:mp-alipay && npm run build:mp-baidu && npm run build:mp-toutiao && npm run build:app-plus && npm run build:quickapp-light && npm run build:quickapp-vue",
"build:stat": "npm run lint && rollup -c build/rollup.config.stat.js", "build:stat": "npm run lint && rollup -c build/rollup.config.stat.js",
"build:web-view": "npm run lint && rollup -c build/rollup.config.web-view.js", "build:web-view": "rollup -c build/rollup.config.web-view.js",
"test:cli": "cross-env NODE_ENV=test jest", "test:cli": "cross-env NODE_ENV=test jest",
"test:unit": "cross-env NODE_ENV=test UNI_PLATFORM=h5 mocha-webpack --require tests/unit/setup.js --webpack-config build/webpack.config.test.js tests/unit/**/*.spec.js", "test:unit": "cross-env NODE_ENV=test UNI_PLATFORM=h5 mocha-webpack --require tests/unit/setup.js --webpack-config build/webpack.config.test.js tests/unit/**/*.spec.js",
"release": "npm run lint:cli && lerna publish --force-publish=*", "release": "npm run lint:cli && lerna publish --force-publish=*",
...@@ -44,49 +39,46 @@ ...@@ -44,49 +39,46 @@
}, },
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"@rollup/plugin-alias": "^3.1.0",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-replace": "^2.3.1",
"@types/html5plus": "^1.0.0", "@types/html5plus": "^1.0.0",
"@vue/cli-plugin-babel": "^4.1.1", "@vue/cli-plugin-babel": "^4.3.1",
"@vue/cli-plugin-eslint": "^4.1.1", "@vue/cli-plugin-eslint": "^4.3.1",
"@vue/cli-plugin-unit-mocha": "^4.1.1", "@vue/cli-plugin-unit-mocha": "^4.3.1",
"@vue/cli-service": "^4.1.1", "@vue/cli-service": "^4.3.1",
"@vue/test-utils": "^1.0.0-beta.25", "@vue/test-utils": "^1.0.0-beta.33",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.1.0",
"babylon": "^6.18.0", "babylon": "^6.18.0",
"browserslist": "^4.4.2", "browserslist": "^4.11.1",
"caniuse-lite": "^1.0.30000940", "caniuse-lite": "^1.0.30001040",
"chai": "^4.1.2", "chai": "^4.2.0",
"copy": "^0.3.2", "copy": "^0.3.2",
"cross-env": "^5.2.0", "cross-env": "^7.0.2",
"del": "^5.0.0", "del": "^5.1.0",
"eslint": "^5.5.0", "eslint": "^6.8.0",
"eslint-config-standard": "^12.0.0", "eslint-config-standard": "^14.1.0",
"eslint-loader": "^2.1.0", "eslint-loader": "^3.0.3",
"eslint-plugin-import": "^2.14.0", "eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^7.0.1", "eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.0.0", "eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0", "eslint-plugin-standard": "^4.0.1",
"eslint-plugin-vue": "^4.7.1", "eslint-plugin-vue": "^6.2.2",
"jest": "^24.9.0", "jest": "^25.1.0",
"jsdom": "^13.0.0", "jsdom": "^16.2.1",
"jsdom-global": "^3.0.2", "jsdom-global": "^3.0.2",
"jsonfile": "^5.0.0", "jsonfile": "^6.0.1",
"rollup": "^1.17.0", "rollup": "^2.6.1",
"rollup-plugin-alias": "^1.4.0", "rollup-plugin-babel": "^4.4.0",
"rollup-plugin-babel": "^4.3.3", "rollup-plugin-terser": "^5.3.0",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-inject": "^3.0.2",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-terser": "^5.2.0",
"rollup-plugin-uglify": "^6.0.3",
"shell-exec": "^1.0.2", "shell-exec": "^1.0.2",
"strip-json-comments": "^2.0.1", "strip-json-comments": "^3.1.0",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-router": "^3.0.1", "vue-router": "^3.0.1",
"vue-template-compiler": "^2.6.11", "vue-template-compiler": "^2.6.11",
"webpack": "^4.18.0", "webpack": "^4.42.0",
"webpack-bundle-analyzer": "^3.0.3", "webpack-bundle-analyzer": "^3.6.1"
"webpack-virtual-modules": "^0.1.10"
}, },
"eslintConfig": { "eslintConfig": {
"root": true, "root": true,
......
...@@ -348,14 +348,12 @@ const interceptors = { ...@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor promiseInterceptor
}; };
var baseApi = /*#__PURE__*/Object.freeze({ var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null, __proto__: null,
upx2px: upx2px, upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor, addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor removeInterceptor: removeInterceptor,
interceptors: interceptors
}); });
const protocols = {}; const protocols = {};
...@@ -376,7 +374,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k ...@@ -376,7 +374,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) { if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {}; argsOption = argsOption(fromArgs, toArgs) || {};
} }
for (let key in fromArgs) { for (const key in fromArgs) {
if (hasOwn(argsOption, key)) { if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key]; let keyOption = argsOption[key];
if (isFn(keyOption)) { if (isFn(keyOption)) {
...@@ -538,7 +536,7 @@ function wrapper$1 (webview) { ...@@ -538,7 +536,7 @@ function wrapper$1 (webview) {
return return
} }
const maskColor = webview.__uniapp_mask; const maskColor = webview.__uniapp_mask;
let maskWebview = webview.__uniapp_mask_id === '0' ? { const maskWebview = webview.__uniapp_mask_id === '0' ? {
setStyle ({ setStyle ({
mask mask
}) { }) {
...@@ -584,8 +582,6 @@ function getSubNVueById (id) { ...@@ -584,8 +582,6 @@ function getSubNVueById (id) {
return webview return webview
} }
var api = /*#__PURE__*/Object.freeze({ var api = /*#__PURE__*/Object.freeze({
__proto__: null, __proto__: null,
getSubNVueById: getSubNVueById, getSubNVueById: getSubNVueById,
...@@ -774,14 +770,14 @@ function createObserver (name) { ...@@ -774,14 +770,14 @@ function createObserver (name) {
} }
function initBehaviors (vueOptions, initBehavior) { function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors']; const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions['extends']; const vueExtends = vueOptions.extends;
const vueMixins = vueOptions['mixins']; const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props']; let vueProps = vueOptions.props;
if (!vueProps) { if (!vueProps) {
vueOptions['props'] = vueProps = []; vueOptions.props = vueProps = [];
} }
const behaviors = []; const behaviors = [];
...@@ -793,11 +789,11 @@ function initBehaviors (vueOptions, initBehavior) { ...@@ -793,11 +789,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name'); vueProps.push('name');
vueProps.push('value'); vueProps.push('value');
} else { } else {
vueProps['name'] = { vueProps.name = {
type: String, type: String,
default: '' default: ''
}; };
vueProps['value'] = { vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date], type: [String, Number, Boolean, Array, Object, Date],
default: '' default: ''
}; };
...@@ -866,7 +862,7 @@ function initProperties (props, isBehavior = false, file = '') { ...@@ -866,7 +862,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => { Object.keys(props).forEach(key => {
const opts = props[key]; const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''} if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default']; let value = opts.default;
if (isFn(value)) { if (isFn(value)) {
value = value(); value = value();
} }
...@@ -1057,11 +1053,11 @@ function handleEvent (event) { ...@@ -1057,11 +1053,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]] // [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset; const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) { if (!dataset) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰 const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) { if (!eventOpts) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
// [['handle',[1,2,a]],['handle1',[1,2,a]]] // [['handle',[1,2,a]],['handle1',[1,2,a]]]
...@@ -1317,7 +1313,7 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1317,7 +1313,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage, isPage,
initRelation initRelation
} = {}) { } = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions); const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = { const options = {
multipleSlots: true, multipleSlots: true,
......
...@@ -45,7 +45,7 @@ module.exports = { ...@@ -45,7 +45,7 @@ module.exports = {
let devtool = false let devtool = false
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
if (process.env.UNI_USING_V3) { if (process.env.UNI_USING_V3) {
if (vueOptions.pluginOptions['uni-app-plus']['service']) { if (vueOptions.pluginOptions['uni-app-plus'].service) {
devtool = 'eval-source-map' devtool = 'eval-source-map'
} }
} else { } else {
......
...@@ -10,7 +10,7 @@ describe('shared:pages', () => { ...@@ -10,7 +10,7 @@ describe('shared:pages', () => {
'van-button': '/wxcomponents/vant/button/index', 'van-button': '/wxcomponents/vant/button/index',
'van-card': '../../wxcomponents/vant/card/index' 'van-card': '../../wxcomponents/vant/card/index'
})).toBe( })).toBe(
`;import VanButton from '@/wxcomponents/vant/button/index.vue';import VanCard from '../../wxcomponents/vant/card/index.vue';exports.default.components=Object.assign({'van-button':VanButton,'van-card':VanCard},exports.default.components||{});` ';import VanButton from \'@/wxcomponents/vant/button/index.vue\';import VanCard from \'../../wxcomponents/vant/card/index.vue\';exports.default.components=Object.assign({\'van-button\':VanButton,\'van-card\':VanCard},exports.default.components||{});'
) )
}) })
it('generate global usingComponents', () => { it('generate global usingComponents', () => {
...@@ -21,7 +21,7 @@ describe('shared:pages', () => { ...@@ -21,7 +21,7 @@ describe('shared:pages', () => {
'van-cell': 'wxcomponents/vant/cell/index', 'van-cell': 'wxcomponents/vant/cell/index',
'van-cell-group': './wxcomponents/vant/cell-group/index' 'van-cell-group': './wxcomponents/vant/cell-group/index'
})).toBe( })).toBe(
`import VanButton from '@/wxcomponents/vant/button/index.vue';import VanCell from './wxcomponents/vant/cell/index.vue';import VanCellGroup from './wxcomponents/vant/cell-group/index.vue';Vue.component('van-button',VanButton);Vue.component('van-cell',VanCell);Vue.component('van-cell-group',VanCellGroup);` 'import VanButton from \'@/wxcomponents/vant/button/index.vue\';import VanCell from \'./wxcomponents/vant/cell/index.vue\';import VanCellGroup from \'./wxcomponents/vant/cell-group/index.vue\';Vue.component(\'van-button\',VanButton);Vue.component(\'van-cell\',VanCell);Vue.component(\'van-cell-group\',VanCellGroup);'
) )
}) })
}) })
...@@ -83,8 +83,8 @@ export default { ...@@ -83,8 +83,8 @@ export default {
} }
}, },
created () { created () {
let pages = getCurrentPages() const pages = getCurrentPages()
let page = pages[pages.length - 1] const page = pages[pages.length - 1]
this.$watch('title', () => { this.$watch('title', () => {
this.setNavigationBarTitle() this.setNavigationBarTitle()
}) })
...@@ -103,13 +103,13 @@ export default { ...@@ -103,13 +103,13 @@ export default {
// #ifdef APP-PLUS // #ifdef APP-PLUS
this._webview = page.$getAppWebview() this._webview = page.$getAppWebview()
attrs.forEach(key => { attrs.forEach(key => {
let titleNView = {} const titleNView = {}
if (this[key] || this[key].length > 0) { if (this[key] || this[key].length > 0) {
titleNView[key] = this[key] titleNView[key] = this[key]
} }
this.setTitleNView(titleNView) this.setTitleNView(titleNView)
this.$watch(key, (val) => { this.$watch(key, (val) => {
let titleStyle = {} const titleStyle = {}
titleStyle[key] = val titleStyle[key] = val
this.setTitleNView(titleStyle) this.setTitleNView(titleStyle)
}) })
......
...@@ -24,13 +24,13 @@ function getPagesJson () { ...@@ -24,13 +24,13 @@ function getPagesJson () {
const pagesJson = { const pagesJson = {
pages: {} pages: {}
} }
for (let name of pageSet.values()) { for (const name of pageSet.values()) {
const style = JSON.parse(getJsonFile(name) || '{}') const style = JSON.parse(getJsonFile(name) || '{}')
delete style.customUsingComponents delete style.customUsingComponents
pagesJson.pages[name] = style pagesJson.pages[name] = style
} }
const appJson = JSON.parse(getJsonFile('app') || '{}') const appJson = JSON.parse(getJsonFile('app') || '{}')
pagesJson.globalStyle = appJson['window'] || {} pagesJson.globalStyle = appJson.window || {}
return pagesJson return pagesJson
} }
...@@ -48,7 +48,7 @@ function getJsonFile (name) { ...@@ -48,7 +48,7 @@ function getJsonFile (name) {
function getChangedJsonFileMap (clear = true) { function getChangedJsonFileMap (clear = true) {
const changedJsonFileMap = new Map() const changedJsonFileMap = new Map()
for (let name of changedJsonFileSet.values()) { for (const name of changedJsonFileSet.values()) {
changedJsonFileMap.set(name + '.json', jsonFileMap.get(name)) changedJsonFileMap.set(name + '.json', jsonFileMap.get(name))
} }
clear && changedJsonFileSet.clear() clear && changedJsonFileSet.clear()
...@@ -328,7 +328,7 @@ module.exports = { ...@@ -328,7 +328,7 @@ module.exports = {
globalUsingComponents = jsonCache.globalUsingComponents globalUsingComponents = jsonCache.globalUsingComponents
appJsonUsingComponents = jsonCache.appJsonUsingComponents appJsonUsingComponents = jsonCache.appJsonUsingComponents
// restore 时,所有 file 均触发 change // restore 时,所有 file 均触发 change
for (let name of jsonFileMap.keys()) { for (const name of jsonFileMap.keys()) {
changedJsonFileSet.add(name) changedJsonFileSet.add(name)
} }
return true return true
......
...@@ -52,7 +52,7 @@ function getH5Options (manifestJson) { ...@@ -52,7 +52,7 @@ function getH5Options (manifestJson) {
h5.router = Object.assign({}, defaultRouter, h5.router || {}) h5.router = Object.assign({}, defaultRouter, h5.router || {})
h5['async'] = Object.assign({}, defaultAsync, h5['async'] || {}) h5.async = Object.assign({}, defaultAsync, h5.async || {})
let base = h5.router.base let base = h5.router.base
......
...@@ -15,8 +15,8 @@ module.exports = { ...@@ -15,8 +15,8 @@ module.exports = {
let scriptOptions = false let scriptOptions = false
if (uniAppOptions && uniAppOptions['scripts']) { if (uniAppOptions && uniAppOptions.scripts) {
scriptOptions = uniAppOptions['scripts'][name] scriptOptions = uniAppOptions.scripts[name]
} }
if (!scriptOptions) { if (!scriptOptions) {
......
...@@ -37,8 +37,8 @@ module.exports = { ...@@ -37,8 +37,8 @@ module.exports = {
runByHBuilderX: isInHBuilderX || fs.existsSync(path.resolve(process.env.UNI_HBUILDERX_PLUGINS || '', 'weapp-tools')), runByHBuilderX: isInHBuilderX || fs.existsSync(path.resolve(process.env.UNI_HBUILDERX_PLUGINS || '', 'weapp-tools')),
getFlexDirection (json) { getFlexDirection (json) {
let flexDir = 'column' let flexDir = 'column'
if (json && json['nvue'] && json['nvue']['flex-direction']) { if (json && json.nvue && json.nvue['flex-direction']) {
flexDir = json['nvue']['flex-direction'] flexDir = json.nvue['flex-direction']
const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse'] const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse']
if (flexDirs.indexOf(flexDir) === -1) { if (flexDirs.indexOf(flexDir) === -1) {
flexDir = 'column' flexDir = 'column'
......
...@@ -67,10 +67,10 @@ function resolvePlugins () { ...@@ -67,10 +67,10 @@ function resolvePlugins () {
} }
function initExtends (name, plugin, plugins) { function initExtends (name, plugin, plugins) {
const extendsPlatform = plugin.config['extends'] const extendsPlatform = plugin.config.extends
if (extendsPlatform) { if (extendsPlatform) {
if (extendsPlatform !== 'h5') { if (extendsPlatform !== 'h5') {
console.error(`目前仅支持基于 h5 平台做扩展`) console.error('目前仅支持基于 h5 平台做扩展')
process.exit(0) process.exit(0)
} }
const extendsPlugin = plugins.find(plugin => plugin.name === extendsPlatform) const extendsPlugin = plugins.find(plugin => plugin.name === extendsPlatform)
......
...@@ -28,19 +28,19 @@ module.exports = function initPreprocess (name, platforms, userDefines = {}) { ...@@ -28,19 +28,19 @@ module.exports = function initPreprocess (name, platforms, userDefines = {}) {
vueContext[normalize(name)] = true vueContext[normalize(name)] = true
if (name === 'app-plus') { if (name === 'app-plus') {
vueContext['APP_VUE'] = true vueContext.APP_VUE = true
nvueContext['APP_PLUS'] = true nvueContext.APP_PLUS = true
nvueContext['APP_NVUE'] = true nvueContext.APP_NVUE = true
nvueContext['APP_PLUS_NVUE'] = true nvueContext.APP_PLUS_NVUE = true
} }
if (name.startsWith('mp-')) { if (name.startsWith('mp-')) {
vueContext['MP'] = true vueContext.MP = true
} }
if (name.startsWith('app-')) { if (name.startsWith('app-')) {
vueContext['APP'] = true vueContext.APP = true
} }
userDefineKeys.forEach(name => { userDefineKeys.forEach(name => {
......
module.exports = { module.exports = {
'resize-sensor': ['h5'], 'resize-sensor': ['h5'],
'ad': ['mp-weixin'], ad: ['mp-weixin'],
'audio': ['app-plus', 'mp-weixin', 'h5'], audio: ['app-plus', 'mp-weixin', 'h5'],
'button': ['app-plus', 'mp-weixin', 'h5'], button: ['app-plus', 'mp-weixin', 'h5'],
'camera': ['mp-weixin'], camera: ['mp-weixin'],
'canvas': ['app-plus', 'mp-weixin'], canvas: ['app-plus', 'mp-weixin'],
'checkbox': ['app-plus', 'mp-weixin', 'h5'], checkbox: ['app-plus', 'mp-weixin', 'h5'],
'checkbox-group': ['app-plus', 'mp-weixin', 'h5'], 'checkbox-group': ['app-plus', 'mp-weixin', 'h5'],
'cover-image': ['app-plus', 'mp-weixin'], 'cover-image': ['app-plus', 'mp-weixin'],
'cover-view': ['app-plus', 'mp-weixin'], 'cover-view': ['app-plus', 'mp-weixin'],
'editor': ['app-plus', 'mp-weixin', 'h5'], editor: ['app-plus', 'mp-weixin', 'h5'],
'form': ['app-plus', 'mp-weixin', 'h5'], form: ['app-plus', 'mp-weixin', 'h5'],
'functional-page-navigator': ['mp-weixin'], 'functional-page-navigator': ['mp-weixin'],
'icon': ['app-plus', 'mp-weixin'], icon: ['app-plus', 'mp-weixin'],
'image': ['app-plus', 'mp-weixin', 'h5'], image: ['app-plus', 'mp-weixin', 'h5'],
'input': ['app-plus', 'mp-weixin', 'h5'], input: ['app-plus', 'mp-weixin', 'h5'],
'label': ['app-plus', 'mp-weixin', 'h5'], label: ['app-plus', 'mp-weixin', 'h5'],
'live-player': ['mp-weixin'], 'live-player': ['mp-weixin'],
'live-pusher': ['mp-weixin'], 'live-pusher': ['mp-weixin'],
'map': ['app-plus', 'mp-weixin', 'h5'], map: ['app-plus', 'mp-weixin', 'h5'],
'movable-area': ['app-plus', 'mp-weixin'], 'movable-area': ['app-plus', 'mp-weixin'],
'movable-view': ['app-plus', 'mp-weixin'], 'movable-view': ['app-plus', 'mp-weixin'],
'navigator': ['app-plus', 'mp-weixin', 'h5'], navigator: ['app-plus', 'mp-weixin', 'h5'],
'official-account': ['mp-weixin'], 'official-account': ['mp-weixin'],
'open-data': ['mp-weixin'], 'open-data': ['mp-weixin'],
'picker': ['app-plus', 'mp-weixin', 'h5'], picker: ['app-plus', 'mp-weixin', 'h5'],
'picker-view': ['app-plus', 'mp-weixin', 'h5'], 'picker-view': ['app-plus', 'mp-weixin', 'h5'],
'picker-view-column': ['app-plus', 'mp-weixin', 'h5'], 'picker-view-column': ['app-plus', 'mp-weixin', 'h5'],
'progress': ['app-plus', 'mp-weixin', 'h5'], progress: ['app-plus', 'mp-weixin', 'h5'],
'radio': ['app-plus', 'mp-weixin', 'h5'], radio: ['app-plus', 'mp-weixin', 'h5'],
'radio-group': ['app-plus', 'mp-weixin', 'h5'], 'radio-group': ['app-plus', 'mp-weixin', 'h5'],
'rich-text': ['app-plus', 'mp-weixin', 'h5'], 'rich-text': ['app-plus', 'mp-weixin', 'h5'],
'scroll-view': ['app-plus', 'mp-weixin', 'h5'], 'scroll-view': ['app-plus', 'mp-weixin', 'h5'],
'slider': ['app-plus', 'mp-weixin', 'h5'], slider: ['app-plus', 'mp-weixin', 'h5'],
'swiper': ['app-plus', 'mp-weixin', 'h5'], swiper: ['app-plus', 'mp-weixin', 'h5'],
'swiper-item': ['app-plus', 'mp-weixin', 'h5'], 'swiper-item': ['app-plus', 'mp-weixin', 'h5'],
'switch': ['app-plus', 'mp-weixin', 'h5'], switch: ['app-plus', 'mp-weixin', 'h5'],
'text': ['app-plus', 'mp-weixin', 'h5'], text: ['app-plus', 'mp-weixin', 'h5'],
'textarea': ['app-plus', 'mp-weixin', 'h5'], textarea: ['app-plus', 'mp-weixin', 'h5'],
'video': ['app-plus', 'mp-weixin', 'h5'], video: ['app-plus', 'mp-weixin', 'h5'],
'view': ['app-plus', 'mp-weixin', 'h5'], view: ['app-plus', 'mp-weixin', 'h5'],
'web-view': ['app-plus', 'mp-weixin'] 'web-view': ['app-plus', 'mp-weixin']
} }
...@@ -98,13 +98,15 @@ function normalizeNodeModules (str) { ...@@ -98,13 +98,15 @@ function normalizeNodeModules (str) {
return str return str
} }
const _hasOwnProperty = Object.prototype.hasOwnProperty
module.exports = { module.exports = {
isInHBuilderX, isInHBuilderX,
isInHBuilderXAlpha, isInHBuilderXAlpha,
normalizeNodeModules, normalizeNodeModules,
md5, md5,
hasOwn (obj, key) { hasOwn (obj, key) {
return hasOwnProperty.call(obj, key) return _hasOwnProperty.call(obj, key)
}, },
hasModule, hasModule,
parseStyle (style = {}) { parseStyle (style = {}) {
......
...@@ -19,7 +19,7 @@ module.exports = function patchVant (files, assets, out) { ...@@ -19,7 +19,7 @@ module.exports = function patchVant (files, assets, out) {
} else if (filepath.indexOf('/notify/index.vue') !== -1) { } else if (filepath.indexOf('/notify/index.vue') !== -1) {
changed = true changed = true
// notify show方法与show属性冲突 // notify show方法与show属性冲突
file.content = file.content.replace(`show()`, 'showNotify()') file.content = file.content.replace('show()', 'showNotify()')
} }
changed && fs.outputFileSync(file.path, file.content) changed && fs.outputFileSync(file.path, file.content)
}) })
...@@ -29,13 +29,13 @@ module.exports = function patchVant (files, assets, out) { ...@@ -29,13 +29,13 @@ module.exports = function patchVant (files, assets, out) {
if (dest.indexOf('array.wxs') !== -1) { if (dest.indexOf('array.wxs') !== -1) {
// 兼容 Array.isArray // 兼容 Array.isArray
const content = fs.readFileSync(dest, 'utf8').toString() const content = fs.readFileSync(dest, 'utf8').toString()
.replace(`array && array.constructor === 'Array'`, .replace('array && array.constructor === \'Array\'',
`array && (array.constructor === 'Array' || (typeof Array !== 'undefined' && Array.isArray(array)))`) 'array && (array.constructor === \'Array\' || (typeof Array !== \'undefined\' && Array.isArray(array)))')
fs.outputFileSync(dest, content) fs.outputFileSync(dest, content)
} else if (dest.indexOf('notify/notify.js') !== -1) { } else if (dest.indexOf('notify/notify.js') !== -1) {
// notify.js show 方法与 show 属性冲突 // notify.js show 方法与 show 属性冲突
const content = fs.readFileSync(dest, 'utf8').toString() const content = fs.readFileSync(dest, 'utf8').toString()
.replace(`show()`, 'showNotify()') .replace('show()', 'showNotify()')
fs.outputFileSync(dest, content) fs.outputFileSync(dest, content)
} }
} }
......
...@@ -348,14 +348,12 @@ const interceptors = { ...@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor promiseInterceptor
}; };
var baseApi = /*#__PURE__*/Object.freeze({ var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null, __proto__: null,
upx2px: upx2px, upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor, addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor removeInterceptor: removeInterceptor,
interceptors: interceptors
}); });
// 不支持的 API 列表 // 不支持的 API 列表
...@@ -803,7 +801,7 @@ const protocols = { // 需要做转换的 API 列表 ...@@ -803,7 +801,7 @@ const protocols = { // 需要做转换的 API 列表
chooseAddress: { chooseAddress: {
name: 'getAddress', name: 'getAddress',
returnValue (result) { returnValue (result) {
let info = result.result || {}; const info = result.result || {};
result.userName = info.fullname; result.userName = info.fullname;
result.provinceName = info.prov; result.provinceName = info.prov;
result.cityName = info.city; result.cityName = info.city;
...@@ -828,7 +826,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k ...@@ -828,7 +826,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) { if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {}; argsOption = argsOption(fromArgs, toArgs) || {};
} }
for (let key in fromArgs) { for (const key in fromArgs) {
if (hasOwn(argsOption, key)) { if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key]; let keyOption = argsOption[key];
if (isFn(keyOption)) { if (isFn(keyOption)) {
...@@ -1234,14 +1232,14 @@ function createObserver (name) { ...@@ -1234,14 +1232,14 @@ function createObserver (name) {
} }
function initBehaviors (vueOptions, initBehavior) { function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors']; const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions['extends']; const vueExtends = vueOptions.extends;
const vueMixins = vueOptions['mixins']; const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props']; let vueProps = vueOptions.props;
if (!vueProps) { if (!vueProps) {
vueOptions['props'] = vueProps = []; vueOptions.props = vueProps = [];
} }
const behaviors = []; const behaviors = [];
...@@ -1253,11 +1251,11 @@ function initBehaviors (vueOptions, initBehavior) { ...@@ -1253,11 +1251,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name'); vueProps.push('name');
vueProps.push('value'); vueProps.push('value');
} else { } else {
vueProps['name'] = { vueProps.name = {
type: String, type: String,
default: '' default: ''
}; };
vueProps['value'] = { vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date], type: [String, Number, Boolean, Array, Object, Date],
default: '' default: ''
}; };
...@@ -1326,7 +1324,7 @@ function initProperties (props, isBehavior = false, file = '') { ...@@ -1326,7 +1324,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => { Object.keys(props).forEach(key => {
const opts = props[key]; const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''} if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default']; let value = opts.default;
if (isFn(value)) { if (isFn(value)) {
value = value(); value = value();
} }
...@@ -1517,11 +1515,11 @@ function handleEvent (event) { ...@@ -1517,11 +1515,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]] // [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset; const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) { if (!dataset) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰 const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) { if (!eventOpts) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
// [['handle',[1,2,a]],['handle1',[1,2,a]]] // [['handle',[1,2,a]],['handle1',[1,2,a]]]
...@@ -2001,7 +1999,7 @@ const hooks$1 = [ ...@@ -2001,7 +1999,7 @@ const hooks$1 = [
hooks$1.push(...PAGE_EVENT_HOOKS); hooks$1.push(...PAGE_EVENT_HOOKS);
function parsePage (vuePageOptions) { function parsePage (vuePageOptions) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vuePageOptions); const [VueComponent, vueOptions] = initVueComponent(Vue, vuePageOptions);
const pageOptions = { const pageOptions = {
mixins: initBehaviors(vueOptions, initBehavior), mixins: initBehaviors(vueOptions, initBehavior),
...@@ -2110,7 +2108,7 @@ function initVm (VueComponent) { ...@@ -2110,7 +2108,7 @@ function initVm (VueComponent) {
} }
function parseComponent (vueComponentOptions) { function parseComponent (vueComponentOptions) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions); const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const properties = initProperties(vueOptions.props, false, vueOptions.__file); const properties = initProperties(vueOptions.props, false, vueOptions.__file);
......
...@@ -11,41 +11,41 @@ const capitalize = cached(str => { ...@@ -11,41 +11,41 @@ const capitalize = cached(str => {
}) })
const EVENTS = { const EVENTS = {
'click': 'tap', click: 'tap',
'touchstart': 'touchStart', touchstart: 'touchStart',
'touchmove': 'touchMove', touchmove: 'touchMove',
'touchend': 'touchEnd', touchend: 'touchEnd',
'touchcancel': 'touchCancel', touchcancel: 'touchCancel',
'longtap': 'longTap', longtap: 'longTap',
'longpress': 'longTap', longpress: 'longTap',
'transitionend': 'transitionEnd', transitionend: 'transitionEnd',
'animationstart': 'animationStart', animationstart: 'animationStart',
'animationiteration': 'animationIteration', animationiteration: 'animationIteration',
'animationend': 'animationEnd', animationend: 'animationEnd',
'firstappear': 'firstAppear', firstappear: 'firstAppear',
// map // map
'markertap': 'markerTap', markertap: 'markerTap',
'callouttap': 'calloutTap', callouttap: 'calloutTap',
'controltap': 'controlTap', controltap: 'controlTap',
'regionchange': 'regionChange', regionchange: 'regionChange',
// scroll-view // scroll-view
'scrolltoupper': 'scrollToUpper', scrolltoupper: 'scrollToUpper',
'scrolltolower': 'scrollToLower', scrolltolower: 'scrollToLower',
// movable-view // movable-view
'changeend': 'changeEnd' changeend: 'changeEnd'
} }
module.exports = { module.exports = {
directive: 'a:', directive: 'a:',
specialEvents: { specialEvents: {
'form': { form: {
'reset': 'onReset' reset: 'onReset'
}, },
'map': { map: {
'markertap': 'onMarkerTap', markertap: 'onMarkerTap',
'controltap': 'onControlTap', controltap: 'onControlTap',
'callouttap': 'onCalloutTap', callouttap: 'onCalloutTap',
'regionchange': 'onRegionChange' regionchange: 'onRegionChange'
} }
}, },
createFilterTag (filterTag, { createFilterTag (filterTag, {
......
...@@ -348,14 +348,12 @@ const interceptors = { ...@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor promiseInterceptor
}; };
var baseApi = /*#__PURE__*/Object.freeze({ var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null, __proto__: null,
upx2px: upx2px, upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor, addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor removeInterceptor: removeInterceptor,
interceptors: interceptors
}); });
var previewImage = { var previewImage = {
...@@ -519,7 +517,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k ...@@ -519,7 +517,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) { if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {}; argsOption = argsOption(fromArgs, toArgs) || {};
} }
for (let key in fromArgs) { for (const key in fromArgs) {
if (hasOwn(argsOption, key)) { if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key]; let keyOption = argsOption[key];
if (isFn(keyOption)) { if (isFn(keyOption)) {
...@@ -886,14 +884,14 @@ function createObserver (name) { ...@@ -886,14 +884,14 @@ function createObserver (name) {
} }
function initBehaviors (vueOptions, initBehavior) { function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors']; const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions['extends']; const vueExtends = vueOptions.extends;
const vueMixins = vueOptions['mixins']; const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props']; let vueProps = vueOptions.props;
if (!vueProps) { if (!vueProps) {
vueOptions['props'] = vueProps = []; vueOptions.props = vueProps = [];
} }
const behaviors = []; const behaviors = [];
...@@ -905,11 +903,11 @@ function initBehaviors (vueOptions, initBehavior) { ...@@ -905,11 +903,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name'); vueProps.push('name');
vueProps.push('value'); vueProps.push('value');
} else { } else {
vueProps['name'] = { vueProps.name = {
type: String, type: String,
default: '' default: ''
}; };
vueProps['value'] = { vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date], type: [String, Number, Boolean, Array, Object, Date],
default: '' default: ''
}; };
...@@ -994,7 +992,7 @@ function initProperties (props, isBehavior = false, file = '') { ...@@ -994,7 +992,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => { Object.keys(props).forEach(key => {
const opts = props[key]; const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''} if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default']; let value = opts.default;
if (isFn(value)) { if (isFn(value)) {
value = value(); value = value();
} }
...@@ -1195,11 +1193,11 @@ function handleEvent (event) { ...@@ -1195,11 +1193,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]] // [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset; const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) { if (!dataset) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰 const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) { if (!eventOpts) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
// [['handle',[1,2,a]],['handle1',[1,2,a]]] // [['handle',[1,2,a]],['handle1',[1,2,a]]]
...@@ -1451,7 +1449,7 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1451,7 +1449,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage, isPage,
initRelation initRelation
} = {}) { } = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions); const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = { const options = {
multipleSlots: true, multipleSlots: true,
...@@ -1579,9 +1577,9 @@ function parseComponent (vueOptions) { ...@@ -1579,9 +1577,9 @@ function parseComponent (vueOptions) {
} }
componentOptions.messages = { componentOptions.messages = {
'__l': componentOptions.methods['__l'] __l: componentOptions.methods.__l
}; };
delete componentOptions.methods['__l']; delete componentOptions.methods.__l;
return componentOptions return componentOptions
} }
......
...@@ -348,14 +348,12 @@ const interceptors = { ...@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor promiseInterceptor
}; };
var baseApi = /*#__PURE__*/Object.freeze({ var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null, __proto__: null,
upx2px: upx2px, upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor, addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor removeInterceptor: removeInterceptor,
interceptors: interceptors
}); });
var previewImage = { var previewImage = {
...@@ -479,7 +477,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k ...@@ -479,7 +477,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) { if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {}; argsOption = argsOption(fromArgs, toArgs) || {};
} }
for (let key in fromArgs) { for (const key in fromArgs) {
if (hasOwn(argsOption, key)) { if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key]; let keyOption = argsOption[key];
if (isFn(keyOption)) { if (isFn(keyOption)) {
...@@ -646,8 +644,6 @@ var eventApi = /*#__PURE__*/Object.freeze({ ...@@ -646,8 +644,6 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit $emit: $emit
}); });
var api = /*#__PURE__*/Object.freeze({ var api = /*#__PURE__*/Object.freeze({
__proto__: null __proto__: null
}); });
...@@ -829,14 +825,14 @@ function createObserver (name) { ...@@ -829,14 +825,14 @@ function createObserver (name) {
} }
function initBehaviors (vueOptions, initBehavior) { function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors']; const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions['extends']; const vueExtends = vueOptions.extends;
const vueMixins = vueOptions['mixins']; const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props']; let vueProps = vueOptions.props;
if (!vueProps) { if (!vueProps) {
vueOptions['props'] = vueProps = []; vueOptions.props = vueProps = [];
} }
const behaviors = []; const behaviors = [];
...@@ -848,11 +844,11 @@ function initBehaviors (vueOptions, initBehavior) { ...@@ -848,11 +844,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name'); vueProps.push('name');
vueProps.push('value'); vueProps.push('value');
} else { } else {
vueProps['name'] = { vueProps.name = {
type: String, type: String,
default: '' default: ''
}; };
vueProps['value'] = { vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date], type: [String, Number, Boolean, Array, Object, Date],
default: '' default: ''
}; };
...@@ -921,7 +917,7 @@ function initProperties (props, isBehavior = false, file = '') { ...@@ -921,7 +917,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => { Object.keys(props).forEach(key => {
const opts = props[key]; const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''} if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default']; let value = opts.default;
if (isFn(value)) { if (isFn(value)) {
value = value(); value = value();
} }
...@@ -1112,11 +1108,11 @@ function handleEvent (event) { ...@@ -1112,11 +1108,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]] // [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset; const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) { if (!dataset) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰 const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) { if (!eventOpts) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
// [['handle',[1,2,a]],['handle1',[1,2,a]]] // [['handle',[1,2,a]],['handle1',[1,2,a]]]
...@@ -1369,7 +1365,7 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1369,7 +1365,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage, isPage,
initRelation initRelation
} = {}) { } = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions); const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = { const options = {
multipleSlots: true, multipleSlots: true,
...@@ -1379,8 +1375,8 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1379,8 +1375,8 @@ function parseBaseComponent (vueComponentOptions, {
{ {
// 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项 // 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) { if (vueOptions['mp-weixin'] && vueOptions['mp-weixin'].options) {
Object.assign(options, vueOptions['mp-weixin']['options']); Object.assign(options, vueOptions['mp-weixin'].options);
} }
} }
......
...@@ -348,14 +348,12 @@ const interceptors = { ...@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor promiseInterceptor
}; };
var baseApi = /*#__PURE__*/Object.freeze({ var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null, __proto__: null,
upx2px: upx2px, upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor, addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor removeInterceptor: removeInterceptor,
interceptors: interceptors
}); });
var previewImage = { var previewImage = {
...@@ -571,7 +569,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k ...@@ -571,7 +569,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) { if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {}; argsOption = argsOption(fromArgs, toArgs) || {};
} }
for (let key in fromArgs) { for (const key in fromArgs) {
if (hasOwn(argsOption, key)) { if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key]; let keyOption = argsOption[key];
if (isFn(keyOption)) { if (isFn(keyOption)) {
...@@ -738,8 +736,6 @@ var eventApi = /*#__PURE__*/Object.freeze({ ...@@ -738,8 +736,6 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit $emit: $emit
}); });
var api = /*#__PURE__*/Object.freeze({ var api = /*#__PURE__*/Object.freeze({
__proto__: null __proto__: null
}); });
...@@ -921,14 +917,14 @@ function createObserver (name) { ...@@ -921,14 +917,14 @@ function createObserver (name) {
} }
function initBehaviors (vueOptions, initBehavior) { function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors']; const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions['extends']; const vueExtends = vueOptions.extends;
const vueMixins = vueOptions['mixins']; const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props']; let vueProps = vueOptions.props;
if (!vueProps) { if (!vueProps) {
vueOptions['props'] = vueProps = []; vueOptions.props = vueProps = [];
} }
const behaviors = []; const behaviors = [];
...@@ -940,11 +936,11 @@ function initBehaviors (vueOptions, initBehavior) { ...@@ -940,11 +936,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name'); vueProps.push('name');
vueProps.push('value'); vueProps.push('value');
} else { } else {
vueProps['name'] = { vueProps.name = {
type: String, type: String,
default: '' default: ''
}; };
vueProps['value'] = { vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date], type: [String, Number, Boolean, Array, Object, Date],
default: '' default: ''
}; };
...@@ -1013,7 +1009,7 @@ function initProperties (props, isBehavior = false, file = '') { ...@@ -1013,7 +1009,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => { Object.keys(props).forEach(key => {
const opts = props[key]; const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''} if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default']; let value = opts.default;
if (isFn(value)) { if (isFn(value)) {
value = value(); value = value();
} }
...@@ -1204,11 +1200,11 @@ function handleEvent (event) { ...@@ -1204,11 +1200,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]] // [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset; const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) { if (!dataset) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰 const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) { if (!eventOpts) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
// [['handle',[1,2,a]],['handle1',[1,2,a]]] // [['handle',[1,2,a]],['handle1',[1,2,a]]]
...@@ -1541,7 +1537,7 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1541,7 +1537,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage, isPage,
initRelation initRelation
} = {}) { } = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions); const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = { const options = {
multipleSlots: true, multipleSlots: true,
......
...@@ -348,14 +348,12 @@ const interceptors = { ...@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor promiseInterceptor
}; };
var baseApi = /*#__PURE__*/Object.freeze({ var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null, __proto__: null,
upx2px: upx2px, upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor, addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor removeInterceptor: removeInterceptor,
interceptors: interceptors
}); });
var previewImage = { var previewImage = {
...@@ -431,7 +429,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k ...@@ -431,7 +429,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) { if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {}; argsOption = argsOption(fromArgs, toArgs) || {};
} }
for (let key in fromArgs) { for (const key in fromArgs) {
if (hasOwn(argsOption, key)) { if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key]; let keyOption = argsOption[key];
if (isFn(keyOption)) { if (isFn(keyOption)) {
...@@ -598,8 +596,6 @@ var eventApi = /*#__PURE__*/Object.freeze({ ...@@ -598,8 +596,6 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit $emit: $emit
}); });
var api = /*#__PURE__*/Object.freeze({ var api = /*#__PURE__*/Object.freeze({
__proto__: null __proto__: null
}); });
...@@ -786,14 +782,14 @@ function createObserver (name) { ...@@ -786,14 +782,14 @@ function createObserver (name) {
} }
function initBehaviors (vueOptions, initBehavior) { function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors']; const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions['extends']; const vueExtends = vueOptions.extends;
const vueMixins = vueOptions['mixins']; const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props']; let vueProps = vueOptions.props;
if (!vueProps) { if (!vueProps) {
vueOptions['props'] = vueProps = []; vueOptions.props = vueProps = [];
} }
const behaviors = []; const behaviors = [];
...@@ -805,11 +801,11 @@ function initBehaviors (vueOptions, initBehavior) { ...@@ -805,11 +801,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name'); vueProps.push('name');
vueProps.push('value'); vueProps.push('value');
} else { } else {
vueProps['name'] = { vueProps.name = {
type: String, type: String,
default: '' default: ''
}; };
vueProps['value'] = { vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date], type: [String, Number, Boolean, Array, Object, Date],
default: '' default: ''
}; };
...@@ -878,7 +874,7 @@ function initProperties (props, isBehavior = false, file = '') { ...@@ -878,7 +874,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => { Object.keys(props).forEach(key => {
const opts = props[key]; const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''} if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default']; let value = opts.default;
if (isFn(value)) { if (isFn(value)) {
value = value(); value = value();
} }
...@@ -1069,11 +1065,11 @@ function handleEvent (event) { ...@@ -1069,11 +1065,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]] // [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset; const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) { if (!dataset) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰 const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) { if (!eventOpts) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
// [['handle',[1,2,a]],['handle1',[1,2,a]]] // [['handle',[1,2,a]],['handle1',[1,2,a]]]
...@@ -1322,7 +1318,7 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1322,7 +1318,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage, isPage,
initRelation initRelation
} = {}) { } = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions); const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = { const options = {
multipleSlots: true, multipleSlots: true,
...@@ -1332,8 +1328,8 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1332,8 +1328,8 @@ function parseBaseComponent (vueComponentOptions, {
{ {
// 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项 // 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) { if (vueOptions['mp-weixin'] && vueOptions['mp-weixin'].options) {
Object.assign(options, vueOptions['mp-weixin']['options']); Object.assign(options, vueOptions['mp-weixin'].options);
} }
} }
......
...@@ -8,7 +8,7 @@ function parseData (data, vueComponentOptions) { ...@@ -8,7 +8,7 @@ function parseData (data, vueComponentOptions) {
} }
function parseComponents (vueComponentOptions) { function parseComponents (vueComponentOptions) {
vueComponentOptions.components = global['__wxVueOptions'].components; vueComponentOptions.components = global.__wxVueOptions.components;
} }
const _toString = Object.prototype.toString; const _toString = Object.prototype.toString;
...@@ -50,11 +50,11 @@ const camelize = cached((str) => { ...@@ -50,11 +50,11 @@ const camelize = cached((str) => {
const SOURCE_KEY = '__data__'; const SOURCE_KEY = '__data__';
const COMPONENT_LIFECYCLE = { const COMPONENT_LIFECYCLE = {
'created': 'onServiceCreated', created: 'onServiceCreated',
'attached': 'onServiceAttached', attached: 'onServiceAttached',
'ready': 'mounted', ready: 'mounted',
'moved': 'moved', moved: 'moved',
'detached': 'destroyed' detached: 'destroyed'
}; };
const COMPONENT_LIFECYCLE_KEYS = Object.keys(COMPONENT_LIFECYCLE); const COMPONENT_LIFECYCLE_KEYS = Object.keys(COMPONENT_LIFECYCLE);
...@@ -135,7 +135,7 @@ function parseMethods (methods, vueComponentOptions) { ...@@ -135,7 +135,7 @@ function parseMethods (methods, vueComponentOptions) {
return return
} }
if (methods.$emit) { if (methods.$emit) {
console.warn(`Method "$emit" conflicts with an existing Vue instance method`); console.warn('Method "$emit" conflicts with an existing Vue instance method');
delete methods.$emit; delete methods.$emit;
} }
vueComponentOptions.methods = methods; vueComponentOptions.methods = methods;
...@@ -299,7 +299,7 @@ function parseRelations (relations, vueComponentOptions) { ...@@ -299,7 +299,7 @@ function parseRelations (relations, vueComponentOptions) {
Object.keys(relations).forEach(name => { Object.keys(relations).forEach(name => {
const relation = relations[name]; const relation = relations[name];
relation.name = name; relation.name = name;
relation.target = relation.target ? String(relation.target) : relative(global['__wxRoute'], name); relation.target = relation.target ? String(relation.target) : relative(global.__wxRoute, name);
}); });
vueComponentOptions.mpOptions.relations = relations; vueComponentOptions.mpOptions.relations = relations;
} }
...@@ -772,23 +772,23 @@ var polyfill = { ...@@ -772,23 +772,23 @@ var polyfill = {
} }
}; };
global['__wxRoute'] = ''; global.__wxRoute = '';
global['__wxComponents'] = Object.create(null); global.__wxComponents = Object.create(null);
global['__wxVueOptions'] = Object.create(null); global.__wxVueOptions = Object.create(null);
function Page (options) { function Page (options) {
const pageOptions = parsePage(options); const pageOptions = parsePage(options);
pageOptions.mixins.unshift(polyfill); pageOptions.mixins.unshift(polyfill);
pageOptions.mpOptions.path = global['__wxRoute']; pageOptions.mpOptions.path = global.__wxRoute;
global['__wxComponents'][global['__wxRoute']] = pageOptions; global.__wxComponents[global.__wxRoute] = pageOptions;
} }
function initRelationsHandler (vueComponentOptions) { function initRelationsHandler (vueComponentOptions) {
// linked 需要在当前组件 attached 之后再执行 // linked 需要在当前组件 attached 之后再执行
if (!vueComponentOptions['onServiceAttached']) { if (!vueComponentOptions.onServiceAttached) {
vueComponentOptions['onServiceAttached'] = []; vueComponentOptions.onServiceAttached = [];
} }
vueComponentOptions['onServiceAttached'].push(function onServiceAttached () { vueComponentOptions.onServiceAttached.push(function onServiceAttached () {
handleRelations(this, 'linked'); handleRelations(this, 'linked');
}); });
} }
...@@ -796,9 +796,9 @@ function initRelationsHandler (vueComponentOptions) { ...@@ -796,9 +796,9 @@ function initRelationsHandler (vueComponentOptions) {
function Component (options) { function Component (options) {
const componentOptions = parseComponent(options); const componentOptions = parseComponent(options);
componentOptions.mixins.unshift(polyfill); componentOptions.mixins.unshift(polyfill);
componentOptions.mpOptions.path = global['__wxRoute']; componentOptions.mpOptions.path = global.__wxRoute;
initRelationsHandler(componentOptions); initRelationsHandler(componentOptions);
global['__wxComponents'][global['__wxRoute']] = componentOptions; global.__wxComponents[global.__wxRoute] = componentOptions;
} }
function Behavior (options) { function Behavior (options) {
......
...@@ -12,6 +12,10 @@ wx.createComponent({ ...@@ -12,6 +12,10 @@ wx.createComponent({
` `
} }
function hasOwn (obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key)
}
module.exports = { module.exports = {
directive: 'wx:', directive: 'wx:',
createScopedSlots (slotName, props, state) { createScopedSlots (slotName, props, state) {
...@@ -43,7 +47,7 @@ module.exports = { ...@@ -43,7 +47,7 @@ module.exports = {
state.scopedSlots = {} state.scopedSlots = {}
} }
let componentName = `${ownerName}-${parentName}-${slotName}` let componentName = `${ownerName}-${parentName}-${slotName}`
if (!state.scopedSlots.hasOwnProperty(componentName)) { if (!hasOwn(state.scopedSlots, componentName)) {
state.scopedSlots[componentName] = 0 state.scopedSlots[componentName] = 0
} }
if (state.scopedSlots[componentName]) { if (state.scopedSlots[componentName]) {
......
...@@ -348,14 +348,12 @@ const interceptors = { ...@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor promiseInterceptor
}; };
var baseApi = /*#__PURE__*/Object.freeze({ var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null, __proto__: null,
upx2px: upx2px, upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor, addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor removeInterceptor: removeInterceptor,
interceptors: interceptors
}); });
var previewImage = { var previewImage = {
...@@ -412,7 +410,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k ...@@ -412,7 +410,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) { if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {}; argsOption = argsOption(fromArgs, toArgs) || {};
} }
for (let key in fromArgs) { for (const key in fromArgs) {
if (hasOwn(argsOption, key)) { if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key]; let keyOption = argsOption[key];
if (isFn(keyOption)) { if (isFn(keyOption)) {
...@@ -587,8 +585,6 @@ var eventApi = /*#__PURE__*/Object.freeze({ ...@@ -587,8 +585,6 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit $emit: $emit
}); });
var api = /*#__PURE__*/Object.freeze({ var api = /*#__PURE__*/Object.freeze({
__proto__: null __proto__: null
}); });
...@@ -770,14 +766,14 @@ function createObserver (name) { ...@@ -770,14 +766,14 @@ function createObserver (name) {
} }
function initBehaviors (vueOptions, initBehavior) { function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors']; const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions['extends']; const vueExtends = vueOptions.extends;
const vueMixins = vueOptions['mixins']; const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props']; let vueProps = vueOptions.props;
if (!vueProps) { if (!vueProps) {
vueOptions['props'] = vueProps = []; vueOptions.props = vueProps = [];
} }
const behaviors = []; const behaviors = [];
...@@ -789,11 +785,11 @@ function initBehaviors (vueOptions, initBehavior) { ...@@ -789,11 +785,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name'); vueProps.push('name');
vueProps.push('value'); vueProps.push('value');
} else { } else {
vueProps['name'] = { vueProps.name = {
type: String, type: String,
default: '' default: ''
}; };
vueProps['value'] = { vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date], type: [String, Number, Boolean, Array, Object, Date],
default: '' default: ''
}; };
...@@ -862,7 +858,7 @@ function initProperties (props, isBehavior = false, file = '') { ...@@ -862,7 +858,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => { Object.keys(props).forEach(key => {
const opts = props[key]; const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''} if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default']; let value = opts.default;
if (isFn(value)) { if (isFn(value)) {
value = value(); value = value();
} }
...@@ -1053,11 +1049,11 @@ function handleEvent (event) { ...@@ -1053,11 +1049,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]] // [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset; const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) { if (!dataset) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰 const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) { if (!eventOpts) {
return console.warn(`事件信息不存在`) return console.warn('事件信息不存在')
} }
// [['handle',[1,2,a]],['handle1',[1,2,a]]] // [['handle',[1,2,a]],['handle1',[1,2,a]]]
...@@ -1371,7 +1367,7 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -1371,7 +1367,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage, isPage,
initRelation initRelation
} = {}) { } = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions); const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = { const options = {
multipleSlots: true, multipleSlots: true,
......
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
<div <div
:class="viewClass" :class="viewClass"
class="uni-button" class="uni-button"
v-on="$listeners"> v-on="$listeners"
>
<text <text
:class="textClass" :class="textClass"
class="uni-button-t"> class="uni-button-t"
>
<slot /> <slot />
</text> </text>
</div> </div>
......
...@@ -37,6 +37,8 @@ function genPriorities (entryPagePath) { ...@@ -37,6 +37,8 @@ function genPriorities (entryPagePath) {
return o return o
} }
const uniCloudPath = require.resolve('@dcloudio/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js')
module.exports = { module.exports = {
devtool: false, devtool: false,
entry () { entry () {
...@@ -72,6 +74,9 @@ module.exports = { ...@@ -72,6 +74,9 @@ module.exports = {
ENV_PHASE_QA: env.NODE_PHASE === 'test', ENV_PHASE_QA: env.NODE_PHASE === 'test',
ENV_PHASE_OL: env.NODE_PHASE === 'prod' ENV_PHASE_OL: env.NODE_PHASE === 'prod'
}), }),
new webpack.ProvidePlugin({
uniCloud: [uniCloudPath, 'default']
}),
new CopyPlugin([{ new CopyPlugin([{
from: path.resolve(__dirname, '../dist/' + dslFilename), from: path.resolve(__dirname, '../dist/' + dslFilename),
to: 'dsl.js' to: 'dsl.js'
......
...@@ -5,7 +5,7 @@ module.exports = function () { ...@@ -5,7 +5,7 @@ module.exports = function () {
const manifest = global.framework.manifest const manifest = global.framework.manifest
if (manifest.package === 'Bundle') { if (manifest.package === 'Bundle') {
console.error(`> 建议配置 manifest.json->quickapp-vue->package 应用包名`) console.error('> 建议配置 manifest.json->quickapp-vue->package 应用包名')
} }
const signPath = './sign/' + (process.env.NODE_ENV === 'production' ? 'release' : 'debug') const signPath = './sign/' + (process.env.NODE_ENV === 'production' ? 'release' : 'debug')
......
const compiler = require('../lib') const compiler = require('../lib')
function assertCodegen (template, templateCode, renderCode = `with(this){}`, options = {}) { function assertCodegen (template, templateCode, renderCode = 'with(this){}', options = {}) {
const res = compiler.compile(template, { const res = compiler.compile(template, {
resourcePath: 'test.wxml', resourcePath: 'test.wxml',
mp: Object.assign({ mp: Object.assign({
...@@ -18,20 +18,20 @@ describe('mp:compiler-mp-qq', () => { ...@@ -18,20 +18,20 @@ describe('mp:compiler-mp-qq', () => {
it('generate text trim', () => { it('generate text trim', () => {
assertCodegen( assertCodegen(
'<text>\nN: {{title}}\n′</text>', '<text>\nN: {{title}}\n′</text>',
`<text>{{'N: '+title+"\\\\n′"}}</text>` '<text>{{\'N: \'+title+"\\\\n′"}}</text>'
) )
assertCodegen( assertCodegen(
'<text>我是第一行1\n我的第二行</text>', '<text>我是第一行1\n我的第二行</text>',
`<text>我是第一行1\n我的第二行</text>` '<text>我是第一行1\n我的第二行</text>'
) )
assertCodegen( assertCodegen(
'<text>我是第一行2\n我的第二行1{{title}}</text>', '<text>我是第一行2\n我的第二行1{{title}}</text>',
`<text>{{"我是第一行2\\\\n我的第二行1"+title}}</text>` '<text>{{"我是第一行2\\\\n我的第二行1"+title}}</text>'
) )
assertCodegen( assertCodegen(
`<text>我是第一行3 `<text>我是第一行3
我的第二行2{{title}}</text>`, 我的第二行2{{title}}</text>`,
`<text>{{"我是第一行3\\\\n 我的第二行2"+title}}</text>` '<text>{{"我是第一行3\\\\n 我的第二行2"+title}}</text>'
) )
}) })
}) })
const compiler = require('../lib') const compiler = require('../lib')
function assertCodegen (template, templateCode, renderCode = `with(this){}`, options = {}) { function assertCodegen (template, templateCode, renderCode = 'with(this){}', options = {}) {
const res = compiler.compile(template, { const res = compiler.compile(template, {
resourcePath: 'test.qxml', resourcePath: 'test.qxml',
mp: Object.assign({ mp: Object.assign({
...@@ -18,14 +18,14 @@ describe('mp:compiler-quickapp-light', () => { ...@@ -18,14 +18,14 @@ describe('mp:compiler-quickapp-light', () => {
it('generate v-for directive', () => { it('generate v-for directive', () => {
assertCodegen( assertCodegen(
'<view><view v-for="(item,index) in items" :key="index"></view></view>', '<view><view v-for="(item,index) in items" :key="index"></view></view>',
`<view><block qa:for="{{items}}" qa:for-item="item" qa:for-index="index" qa:key="index"><view></view></block></view>` '<view><block qa:for="{{items}}" qa:for-item="item" qa:for-index="index" qa:key="index"><view></view></block></view>'
) )
}) })
it('generate v-else-if with v-else directive', () => { it('generate v-else-if with v-else directive', () => {
assertCodegen( assertCodegen(
'<view><view v-if="show">hello</view><view v-else-if="hide">world</view><view v-else>bye</view></view>', '<view><view v-if="show">hello</view><view v-else-if="hide">world</view><view v-else>bye</view></view>',
`<view><block qa:if="{{show}}"><view>hello</view></block><block qa:else><block qa:if="{{hide}}"><view>world</view></block><block qa:else><view>bye</view></block></block></view>` '<view><block qa:if="{{show}}"><view>hello</view></block><block qa:else><block qa:if="{{hide}}"><view>world</view></block><block qa:else><view>bye</view></block></block></view>'
) )
}) })
}) })
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册