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

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

......@@ -5,3 +5,4 @@ packages/*/packages
packages/*/template/**/*
packages/uni-h5/src
packages/uni-stat
node_modules
......@@ -21,7 +21,7 @@ del.sync(['node_modules/.cache'])
let pluginDir = process.argv[2]
if (!pluginDir) {
console.error(`缺少参数`)
console.error('缺少参数')
process.exit(0)
}
......@@ -31,7 +31,7 @@ if (pluginDir.indexOf('/') === -1) {
const pkg = require(path.join(pluginDir, 'package.json'))
if (!pkg['uni-app']) {
console.error(`缺少 uni-app 配置`)
console.error('缺少 uni-app 配置')
process.exit(0)
}
......@@ -51,8 +51,8 @@ service.webpackRawConfigFns.push(function () {
use: [{
loader: path.resolve(__dirname, '../lib/extends-loader'),
options: {
'extends': path.resolve(pluginDir, 'src/service/api'),
'base': path.resolve(__dirname, '../src/platforms/h5/service/api')
extends: path.resolve(pluginDir, 'src/service/api'),
base: path.resolve(__dirname, '../src/platforms/h5/service/api')
}
}]
}]
......
......@@ -24,33 +24,33 @@ const TOAST_DEPS = [
// TODO 暂不考虑 head,tabBar 的动态拆分
const DEPS = {
'chooseLocation': [
chooseLocation: [
['/platforms/h5/components/system-routes/choose-location/index.vue', 'ChooseLocation']
],
'openLocation': [
openLocation: [
['/platforms/h5/components/system-routes/open-location/index.vue', 'OpenLocation']
],
'previewImage': [
previewImage: [
['/core/view/components/swiper/index.vue', 'Swiper'],
['/core/view/components/swiper-item/index.vue', 'SwiperItem'],
['/platforms/h5/components/system-routes/preview-image/index.vue', 'PreviewImage']
],
'showToast': TOAST_DEPS,
'hideToast': TOAST_DEPS,
'showLoading': TOAST_DEPS,
'hideLoading': TOAST_DEPS,
'showModal': [
showToast: TOAST_DEPS,
hideToast: TOAST_DEPS,
showLoading: TOAST_DEPS,
hideLoading: TOAST_DEPS,
showModal: [
['/platforms/h5/components/app/popup/modal.vue', 'Modal'],
['/platforms/h5/components/app/popup/mixins/modal.js', 'ModalMixin']
],
'showActionSheet': [
showActionSheet: [
['/platforms/h5/components/app/popup/actionSheet.vue', 'ActionSheet'],
['/platforms/h5/components/app/popup/mixins/action-sheet.js', 'ActionSheetMixin']
],
'createSelectorQuery': [
createSelectorQuery: [
['/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', 'destroyComponentObserver']
]
......
const path = require('path')
const alias = require('rollup-plugin-alias')
const replace = require('rollup-plugin-replace')
const nodeResolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const alias = require('@rollup/plugin-alias')
const replace = require('@rollup/plugin-replace')
const nodeResolve = require('@rollup/plugin-node-resolve')
const commonjs = require('@rollup/plugin-commonjs')
const requireContext = require('../lib/rollup-plugin-require-context')
let input = 'src/platforms/app-plus/service/framework/create-instance-context.js'
......@@ -27,9 +27,9 @@ if (process.env.UNI_SERVICE === 'legacy') {
} else {
input = 'src/platforms/app-plus/service/index.js'
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 {
output.file = `packages/uni-app-plus-nvue/dist/index.js`
output.file = 'packages/uni-app-plus-nvue/dist/index.js'
}
output.format = 'iife'
output.name = 'serviceContext'
......@@ -38,8 +38,8 @@ if (process.env.UNI_SERVICE === 'legacy') {
var setTimeout = instanceContext.setTimeout
var clearTimeout = instanceContext.clearTimeout
var setInterval = instanceContext.setInterval
var clearInterval = instanceContext.clearInterval
var __uniConfig = instanceContext.__uniConfig
var clearInterval = instanceContext.clearInterval
var __uniConfig = instanceContext.__uniConfig
var __uniRoutes = instanceContext.__uniRoutes
`
output.footer =
......@@ -47,9 +47,9 @@ var __uniRoutes = instanceContext.__uniRoutes
var uni = serviceContext.uni
var getApp = serviceContext.getApp
var getCurrentPages = serviceContext.getCurrentPages
var __definePage = serviceContext.__definePage
var __registerPage = serviceContext.__registerPage
var __registerPage = serviceContext.__registerPage
return serviceContext \n}
......@@ -61,21 +61,37 @@ const resolve = dir => path.resolve(__dirname, '../', dir)
module.exports = {
input,
output,
plugins: [
alias({
// 'vue': resolve('packages/uni-app-plus/dist/service.runtime.esm.js'),
'uni-core': resolve('src/core'),
'uni-platform': resolve('src/platforms/' + process.env.UNI_PLATFORM),
'uni-platforms': resolve('src/platforms'),
'uni-shared': resolve('src/shared/index.js'),
'uni-helpers': resolve('src/core/helpers'),
'uni-invoke-api': resolve('src/platforms/app-plus/service/api'),
'uni-service-api': resolve('src/core/service/platform-api'),
'uni-api-protocol': resolve('src/core/helpers/protocol')
plugins: [
alias({
entries: [{
find: 'uni-core',
replacement: resolve('src/core')
}, {
find: 'uni-platform',
replacement: resolve('src/platforms/' + process.env.UNI_PLATFORM)
}, {
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/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(),
commonjs(),
nodeResolve(),
requireContext(),
commonjs(),
replace({
__GLOBAL__: 'getGlobalUni()',
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM),
......
const path = require('path')
const alias = require('rollup-plugin-alias')
const replace = require('rollup-plugin-replace')
const alias = require('@rollup/plugin-alias')
const replace = require('@rollup/plugin-replace')
const PLATFORMS = {
'mp-weixin': {
......@@ -51,10 +51,19 @@ module.exports = {
output,
plugins: [
alias({
'uni-shared': path.resolve(__dirname, '../src/shared/util.js'),
'uni-platform': path.resolve(__dirname, '../src/platforms/' + process.env.UNI_PLATFORM),
'uni-wrapper': path.resolve(__dirname, '../src/core/runtime/wrapper'),
'uni-helpers': path.resolve(__dirname, '../src/core/helpers')
entries: [{
find: 'uni-shared',
replacement: path.resolve(__dirname, '../src/shared/util.js')
}, {
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({
__GLOBAL__: platform.prefix,
......@@ -64,4 +73,4 @@ module.exports = {
})
],
external: ['vue']
}
}
const path = require('path')
const alias = require('rollup-plugin-alias')
const replace = require('rollup-plugin-replace')
const nodeResolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const alias = require('@rollup/plugin-alias')
const replace = require('@rollup/plugin-replace')
const nodeResolve = require('@rollup/plugin-node-resolve')
const commonjs = require('@rollup/plugin-commonjs')
const terser = require('rollup-plugin-terser')
const requireContext = require('../lib/rollup-plugin-require-context')
......@@ -31,14 +31,31 @@ const plugins = [{
}
},
alias({
'uni-core': resolve('src/core'),
'uni-platform': resolve('src/platforms/quickapp-vue'),
'uni-platforms': resolve('src/platforms'),
'uni-shared': resolve('src/shared/index.js'),
'uni-helpers': resolve('src/core/helpers'),
'uni-invoke-api': resolve('src/platforms/quickapp-vue/service/invoke-api'),
'uni-service-api': resolve('src/platforms/quickapp-vue/service/api'),
'uni-api-protocol': resolve('src/core/helpers/protocol')
entries: [{
find: 'uni-core',
replacement: resolve('src/core')
}, {
find: 'uni-platform',
replacement: resolve('src/platforms/quickapp-vue')
}, {
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(),
requireContext(),
......
const path = require('path')
const alias = require('rollup-plugin-alias')
const replace = require('rollup-plugin-replace')
module.exports = {
input: 'src/platforms/app-plus-nvue/services/index.legacy.old.js',
output: {
file: `packages/uni-app-plus-nvue/dist/service.legacy.js`,
format: 'es'
},
plugins: [
alias({
'uni-core': path.resolve(__dirname, '../src/core'),
'uni-shared': path.resolve(__dirname, '../src/shared/util.js'),
'uni-helpers': path.resolve(__dirname, '../src/core/helpers')
}),
replace({
__GLOBAL__: 'getGlobalUni()',
__PLATFORM_TITLE__: 'app-plus-nvue'
})
]
const path = require('path')
const alias = require('@rollup/plugin-alias')
const replace = require('@rollup/plugin-replace')
module.exports = {
input: 'src/platforms/app-plus-nvue/services/index.legacy.old.js',
output: {
file: 'packages/uni-app-plus-nvue/dist/service.legacy.js',
format: 'es'
},
plugins: [
alias({
entries: [{
find: 'uni-core',
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({
__GLOBAL__: 'getGlobalUni()',
__PLATFORM_TITLE__: 'app-plus-nvue'
})
]
}
const path = require('path')
const babel = require('rollup-plugin-babel')
const alias = require('rollup-plugin-alias')
const uglify = require('rollup-plugin-uglify')
const alias = require('@rollup/plugin-alias')
const terser = require('rollup-plugin-terser')
module.exports = {
input: 'src/core/runtime/web-view/index.js',
output: {
name: 'uni',
file: `dist/uni.webview.1.5.2.js`,
file: 'dist/uni.webview.1.5.2.js',
format: 'umd'
},
plugins: [
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(),
uglify.uglify({
output: {
ascii_only: true
}
})
terser.terser()
]
}
......@@ -8,7 +8,7 @@ const pkg = require('../package.json')
const externals = {}
if (process.env.UNI_VIEW !== 'true') {
externals['vue'] = {
externals.vue = {
commonjs: 'vue',
commonjs2: 'vue',
root: 'Vue'
......@@ -41,16 +41,16 @@ const alias = {
}
const provides = {
'console': [resolve('src/core/helpers/console'), 'default'],
'UniViewJSBridge': [resolve('src/core/view/bridge/index')],
'UniServiceJSBridge': [resolve('src/core/service/bridge/index')]
console: [resolve('src/core/helpers/console'), 'default'],
UniViewJSBridge: [resolve('src/core/view/bridge/index')],
UniServiceJSBridge: [resolve('src/core/service/bridge/index')]
}
if (process.env.UNI_VIEW) { // 方便调试
delete provides['console']
delete provides.console
}
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 = {
......
......@@ -49,9 +49,9 @@ config.plugins = config.plugins.concat([
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM)
}),
new webpack.ProvidePlugin({
'console': [resolve('src/core/helpers/console'), 'default'],
'UniViewJSBridge': [resolve('src/core/view/bridge/index')],
'UniServiceJSBridge': [resolve('src/core/service/bridge/index')]
console: [resolve('src/core/helpers/console'), 'default'],
UniViewJSBridge: [resolve('src/core/view/bridge/index')],
UniServiceJSBridge: [resolve('src/core/service/bridge/index')]
})
])
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",
"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: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",
"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",
"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: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 dev:app:view",
"build:app:v3": "npm run lint && npm run build:app:service && npm run build:app:view",
"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",
"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-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-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: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: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: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: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=*",
......@@ -44,49 +39,46 @@
},
"private": true,
"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",
"@vue/cli-plugin-babel": "^4.1.1",
"@vue/cli-plugin-eslint": "^4.1.1",
"@vue/cli-plugin-unit-mocha": "^4.1.1",
"@vue/cli-service": "^4.1.1",
"@vue/test-utils": "^1.0.0-beta.25",
"babel-eslint": "^10.0.1",
"@vue/cli-plugin-babel": "^4.3.1",
"@vue/cli-plugin-eslint": "^4.3.1",
"@vue/cli-plugin-unit-mocha": "^4.3.1",
"@vue/cli-service": "^4.3.1",
"@vue/test-utils": "^1.0.0-beta.33",
"babel-eslint": "^10.1.0",
"babylon": "^6.18.0",
"browserslist": "^4.4.2",
"caniuse-lite": "^1.0.30000940",
"chai": "^4.1.2",
"browserslist": "^4.11.1",
"caniuse-lite": "^1.0.30001040",
"chai": "^4.2.0",
"copy": "^0.3.2",
"cross-env": "^5.2.0",
"del": "^5.0.0",
"eslint": "^5.5.0",
"eslint-config-standard": "^12.0.0",
"eslint-loader": "^2.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^4.7.1",
"jest": "^24.9.0",
"jsdom": "^13.0.0",
"cross-env": "^7.0.2",
"del": "^5.1.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.0",
"eslint-loader": "^3.0.3",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-vue": "^6.2.2",
"jest": "^25.1.0",
"jsdom": "^16.2.1",
"jsdom-global": "^3.0.2",
"jsonfile": "^5.0.0",
"rollup": "^1.17.0",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-babel": "^4.3.3",
"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",
"jsonfile": "^6.0.1",
"rollup": "^2.6.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^5.3.0",
"shell-exec": "^1.0.2",
"strip-json-comments": "^2.0.1",
"strip-json-comments": "^3.1.0",
"vue": "^2.6.11",
"vue-router": "^3.0.1",
"vue-template-compiler": "^2.6.11",
"webpack": "^4.18.0",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-virtual-modules": "^0.1.10"
"webpack": "^4.42.0",
"webpack-bundle-analyzer": "^3.6.1"
},
"eslintConfig": {
"root": true,
......
......@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor
};
var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null,
upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor
removeInterceptor: removeInterceptor,
interceptors: interceptors
});
const protocols = {};
......@@ -376,7 +374,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {};
}
for (let key in fromArgs) {
for (const key in fromArgs) {
if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key];
if (isFn(keyOption)) {
......@@ -538,7 +536,7 @@ function wrapper$1 (webview) {
return
}
const maskColor = webview.__uniapp_mask;
let maskWebview = webview.__uniapp_mask_id === '0' ? {
const maskWebview = webview.__uniapp_mask_id === '0' ? {
setStyle ({
mask
}) {
......@@ -584,8 +582,6 @@ function getSubNVueById (id) {
return webview
}
var api = /*#__PURE__*/Object.freeze({
__proto__: null,
getSubNVueById: getSubNVueById,
......@@ -774,14 +770,14 @@ function createObserver (name) {
}
function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors'];
const vueExtends = vueOptions['extends'];
const vueMixins = vueOptions['mixins'];
const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions.extends;
const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props'];
let vueProps = vueOptions.props;
if (!vueProps) {
vueOptions['props'] = vueProps = [];
vueOptions.props = vueProps = [];
}
const behaviors = [];
......@@ -793,11 +789,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name');
vueProps.push('value');
} else {
vueProps['name'] = {
vueProps.name = {
type: String,
default: ''
};
vueProps['value'] = {
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
};
......@@ -866,7 +862,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => {
const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default'];
let value = opts.default;
if (isFn(value)) {
value = value();
}
......@@ -1057,11 +1053,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
......@@ -1317,7 +1313,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = {
multipleSlots: true,
......
......@@ -45,7 +45,7 @@ module.exports = {
let devtool = false
if (process.env.NODE_ENV !== 'production') {
if (process.env.UNI_USING_V3) {
if (vueOptions.pluginOptions['uni-app-plus']['service']) {
if (vueOptions.pluginOptions['uni-app-plus'].service) {
devtool = 'eval-source-map'
}
} else {
......
......@@ -10,7 +10,7 @@ describe('shared:pages', () => {
'van-button': '/wxcomponents/vant/button/index',
'van-card': '../../wxcomponents/vant/card/index'
})).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', () => {
......@@ -21,7 +21,7 @@ describe('shared:pages', () => {
'van-cell': 'wxcomponents/vant/cell/index',
'van-cell-group': './wxcomponents/vant/cell-group/index'
})).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 {
}
},
created () {
let pages = getCurrentPages()
let page = pages[pages.length - 1]
const pages = getCurrentPages()
const page = pages[pages.length - 1]
this.$watch('title', () => {
this.setNavigationBarTitle()
})
......@@ -103,13 +103,13 @@ export default {
// #ifdef APP-PLUS
this._webview = page.$getAppWebview()
attrs.forEach(key => {
let titleNView = {}
const titleNView = {}
if (this[key] || this[key].length > 0) {
titleNView[key] = this[key]
}
this.setTitleNView(titleNView)
this.$watch(key, (val) => {
let titleStyle = {}
const titleStyle = {}
titleStyle[key] = val
this.setTitleNView(titleStyle)
})
......
......@@ -24,13 +24,13 @@ function getPagesJson () {
const pagesJson = {
pages: {}
}
for (let name of pageSet.values()) {
for (const name of pageSet.values()) {
const style = JSON.parse(getJsonFile(name) || '{}')
delete style.customUsingComponents
pagesJson.pages[name] = style
}
const appJson = JSON.parse(getJsonFile('app') || '{}')
pagesJson.globalStyle = appJson['window'] || {}
pagesJson.globalStyle = appJson.window || {}
return pagesJson
}
......@@ -48,7 +48,7 @@ function getJsonFile (name) {
function getChangedJsonFileMap (clear = true) {
const changedJsonFileMap = new Map()
for (let name of changedJsonFileSet.values()) {
for (const name of changedJsonFileSet.values()) {
changedJsonFileMap.set(name + '.json', jsonFileMap.get(name))
}
clear && changedJsonFileSet.clear()
......@@ -328,7 +328,7 @@ module.exports = {
globalUsingComponents = jsonCache.globalUsingComponents
appJsonUsingComponents = jsonCache.appJsonUsingComponents
// restore 时,所有 file 均触发 change
for (let name of jsonFileMap.keys()) {
for (const name of jsonFileMap.keys()) {
changedJsonFileSet.add(name)
}
return true
......
......@@ -52,7 +52,7 @@ function getH5Options (manifestJson) {
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
......
......@@ -15,8 +15,8 @@ module.exports = {
let scriptOptions = false
if (uniAppOptions && uniAppOptions['scripts']) {
scriptOptions = uniAppOptions['scripts'][name]
if (uniAppOptions && uniAppOptions.scripts) {
scriptOptions = uniAppOptions.scripts[name]
}
if (!scriptOptions) {
......
......@@ -37,8 +37,8 @@ module.exports = {
runByHBuilderX: isInHBuilderX || fs.existsSync(path.resolve(process.env.UNI_HBUILDERX_PLUGINS || '', 'weapp-tools')),
getFlexDirection (json) {
let flexDir = 'column'
if (json && json['nvue'] && json['nvue']['flex-direction']) {
flexDir = json['nvue']['flex-direction']
if (json && json.nvue && json.nvue['flex-direction']) {
flexDir = json.nvue['flex-direction']
const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse']
if (flexDirs.indexOf(flexDir) === -1) {
flexDir = 'column'
......
......@@ -67,10 +67,10 @@ function resolvePlugins () {
}
function initExtends (name, plugin, plugins) {
const extendsPlatform = plugin.config['extends']
const extendsPlatform = plugin.config.extends
if (extendsPlatform) {
if (extendsPlatform !== 'h5') {
console.error(`目前仅支持基于 h5 平台做扩展`)
console.error('目前仅支持基于 h5 平台做扩展')
process.exit(0)
}
const extendsPlugin = plugins.find(plugin => plugin.name === extendsPlatform)
......
......@@ -28,19 +28,19 @@ module.exports = function initPreprocess (name, platforms, userDefines = {}) {
vueContext[normalize(name)] = true
if (name === 'app-plus') {
vueContext['APP_VUE'] = true
vueContext.APP_VUE = true
nvueContext['APP_PLUS'] = true
nvueContext['APP_NVUE'] = true
nvueContext['APP_PLUS_NVUE'] = true
nvueContext.APP_PLUS = true
nvueContext.APP_NVUE = true
nvueContext.APP_PLUS_NVUE = true
}
if (name.startsWith('mp-')) {
vueContext['MP'] = true
vueContext.MP = true
}
if (name.startsWith('app-')) {
vueContext['APP'] = true
vueContext.APP = true
}
userDefineKeys.forEach(name => {
......
module.exports = {
'resize-sensor': ['h5'],
'ad': ['mp-weixin'],
'audio': ['app-plus', 'mp-weixin', 'h5'],
'button': ['app-plus', 'mp-weixin', 'h5'],
'camera': ['mp-weixin'],
'canvas': ['app-plus', 'mp-weixin'],
'checkbox': ['app-plus', 'mp-weixin', 'h5'],
ad: ['mp-weixin'],
audio: ['app-plus', 'mp-weixin', 'h5'],
button: ['app-plus', 'mp-weixin', 'h5'],
camera: ['mp-weixin'],
canvas: ['app-plus', 'mp-weixin'],
checkbox: ['app-plus', 'mp-weixin', 'h5'],
'checkbox-group': ['app-plus', 'mp-weixin', 'h5'],
'cover-image': ['app-plus', 'mp-weixin'],
'cover-view': ['app-plus', 'mp-weixin'],
'editor': ['app-plus', 'mp-weixin', 'h5'],
'form': ['app-plus', 'mp-weixin', 'h5'],
editor: ['app-plus', 'mp-weixin', 'h5'],
form: ['app-plus', 'mp-weixin', 'h5'],
'functional-page-navigator': ['mp-weixin'],
'icon': ['app-plus', 'mp-weixin'],
'image': ['app-plus', 'mp-weixin', 'h5'],
'input': ['app-plus', 'mp-weixin', 'h5'],
'label': ['app-plus', 'mp-weixin', 'h5'],
icon: ['app-plus', 'mp-weixin'],
image: ['app-plus', 'mp-weixin', 'h5'],
input: ['app-plus', 'mp-weixin', 'h5'],
label: ['app-plus', 'mp-weixin', 'h5'],
'live-player': ['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-view': ['app-plus', 'mp-weixin'],
'navigator': ['app-plus', 'mp-weixin', 'h5'],
navigator: ['app-plus', 'mp-weixin', 'h5'],
'official-account': ['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-column': ['app-plus', 'mp-weixin', 'h5'],
'progress': ['app-plus', 'mp-weixin', 'h5'],
'radio': ['app-plus', 'mp-weixin', 'h5'],
progress: ['app-plus', 'mp-weixin', 'h5'],
radio: ['app-plus', 'mp-weixin', 'h5'],
'radio-group': ['app-plus', 'mp-weixin', 'h5'],
'rich-text': ['app-plus', 'mp-weixin', 'h5'],
'scroll-view': ['app-plus', 'mp-weixin', 'h5'],
'slider': ['app-plus', 'mp-weixin', 'h5'],
'swiper': ['app-plus', 'mp-weixin', 'h5'],
slider: ['app-plus', 'mp-weixin', 'h5'],
swiper: ['app-plus', 'mp-weixin', 'h5'],
'swiper-item': ['app-plus', 'mp-weixin', 'h5'],
'switch': ['app-plus', 'mp-weixin', 'h5'],
'text': ['app-plus', 'mp-weixin', 'h5'],
'textarea': ['app-plus', 'mp-weixin', 'h5'],
'video': ['app-plus', 'mp-weixin', 'h5'],
'view': ['app-plus', 'mp-weixin', 'h5'],
switch: ['app-plus', 'mp-weixin', 'h5'],
text: ['app-plus', 'mp-weixin', 'h5'],
textarea: ['app-plus', 'mp-weixin', 'h5'],
video: ['app-plus', 'mp-weixin', 'h5'],
view: ['app-plus', 'mp-weixin', 'h5'],
'web-view': ['app-plus', 'mp-weixin']
}
......@@ -98,13 +98,15 @@ function normalizeNodeModules (str) {
return str
}
const _hasOwnProperty = Object.prototype.hasOwnProperty
module.exports = {
isInHBuilderX,
isInHBuilderXAlpha,
normalizeNodeModules,
md5,
hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
return _hasOwnProperty.call(obj, key)
},
hasModule,
parseStyle (style = {}) {
......
......@@ -19,7 +19,7 @@ module.exports = function patchVant (files, assets, out) {
} else if (filepath.indexOf('/notify/index.vue') !== -1) {
changed = true
// notify show方法与show属性冲突
file.content = file.content.replace(`show()`, 'showNotify()')
file.content = file.content.replace('show()', 'showNotify()')
}
changed && fs.outputFileSync(file.path, file.content)
})
......@@ -29,13 +29,13 @@ module.exports = function patchVant (files, assets, out) {
if (dest.indexOf('array.wxs') !== -1) {
// 兼容 Array.isArray
const content = fs.readFileSync(dest, 'utf8').toString()
.replace(`array && array.constructor === 'Array'`,
`array && (array.constructor === 'Array' || (typeof Array !== 'undefined' && Array.isArray(array)))`)
.replace('array && array.constructor === \'Array\'',
'array && (array.constructor === \'Array\' || (typeof Array !== \'undefined\' && Array.isArray(array)))')
fs.outputFileSync(dest, content)
} else if (dest.indexOf('notify/notify.js') !== -1) {
// notify.js show 方法与 show 属性冲突
const content = fs.readFileSync(dest, 'utf8').toString()
.replace(`show()`, 'showNotify()')
.replace('show()', 'showNotify()')
fs.outputFileSync(dest, content)
}
}
......
......@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor
};
var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null,
upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor
removeInterceptor: removeInterceptor,
interceptors: interceptors
});
// 不支持的 API 列表
......@@ -803,7 +801,7 @@ const protocols = { // 需要做转换的 API 列表
chooseAddress: {
name: 'getAddress',
returnValue (result) {
let info = result.result || {};
const info = result.result || {};
result.userName = info.fullname;
result.provinceName = info.prov;
result.cityName = info.city;
......@@ -828,7 +826,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {};
}
for (let key in fromArgs) {
for (const key in fromArgs) {
if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key];
if (isFn(keyOption)) {
......@@ -1234,14 +1232,14 @@ function createObserver (name) {
}
function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors'];
const vueExtends = vueOptions['extends'];
const vueMixins = vueOptions['mixins'];
const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions.extends;
const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props'];
let vueProps = vueOptions.props;
if (!vueProps) {
vueOptions['props'] = vueProps = [];
vueOptions.props = vueProps = [];
}
const behaviors = [];
......@@ -1253,11 +1251,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name');
vueProps.push('value');
} else {
vueProps['name'] = {
vueProps.name = {
type: String,
default: ''
};
vueProps['value'] = {
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
};
......@@ -1326,7 +1324,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => {
const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default'];
let value = opts.default;
if (isFn(value)) {
value = value();
}
......@@ -1517,11 +1515,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
......@@ -2001,7 +1999,7 @@ const hooks$1 = [
hooks$1.push(...PAGE_EVENT_HOOKS);
function parsePage (vuePageOptions) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vuePageOptions);
const [VueComponent, vueOptions] = initVueComponent(Vue, vuePageOptions);
const pageOptions = {
mixins: initBehaviors(vueOptions, initBehavior),
......@@ -2110,7 +2108,7 @@ function initVm (VueComponent) {
}
function parseComponent (vueComponentOptions) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const properties = initProperties(vueOptions.props, false, vueOptions.__file);
......
......@@ -11,41 +11,41 @@ const capitalize = cached(str => {
})
const EVENTS = {
'click': 'tap',
'touchstart': 'touchStart',
'touchmove': 'touchMove',
'touchend': 'touchEnd',
'touchcancel': 'touchCancel',
'longtap': 'longTap',
'longpress': 'longTap',
'transitionend': 'transitionEnd',
'animationstart': 'animationStart',
'animationiteration': 'animationIteration',
'animationend': 'animationEnd',
'firstappear': 'firstAppear',
click: 'tap',
touchstart: 'touchStart',
touchmove: 'touchMove',
touchend: 'touchEnd',
touchcancel: 'touchCancel',
longtap: 'longTap',
longpress: 'longTap',
transitionend: 'transitionEnd',
animationstart: 'animationStart',
animationiteration: 'animationIteration',
animationend: 'animationEnd',
firstappear: 'firstAppear',
// map
'markertap': 'markerTap',
'callouttap': 'calloutTap',
'controltap': 'controlTap',
'regionchange': 'regionChange',
markertap: 'markerTap',
callouttap: 'calloutTap',
controltap: 'controlTap',
regionchange: 'regionChange',
// scroll-view
'scrolltoupper': 'scrollToUpper',
'scrolltolower': 'scrollToLower',
scrolltoupper: 'scrollToUpper',
scrolltolower: 'scrollToLower',
// movable-view
'changeend': 'changeEnd'
changeend: 'changeEnd'
}
module.exports = {
directive: 'a:',
specialEvents: {
'form': {
'reset': 'onReset'
form: {
reset: 'onReset'
},
'map': {
'markertap': 'onMarkerTap',
'controltap': 'onControlTap',
'callouttap': 'onCalloutTap',
'regionchange': 'onRegionChange'
map: {
markertap: 'onMarkerTap',
controltap: 'onControlTap',
callouttap: 'onCalloutTap',
regionchange: 'onRegionChange'
}
},
createFilterTag (filterTag, {
......
......@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor
};
var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null,
upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor
removeInterceptor: removeInterceptor,
interceptors: interceptors
});
var previewImage = {
......@@ -519,7 +517,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {};
}
for (let key in fromArgs) {
for (const key in fromArgs) {
if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key];
if (isFn(keyOption)) {
......@@ -886,14 +884,14 @@ function createObserver (name) {
}
function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors'];
const vueExtends = vueOptions['extends'];
const vueMixins = vueOptions['mixins'];
const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions.extends;
const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props'];
let vueProps = vueOptions.props;
if (!vueProps) {
vueOptions['props'] = vueProps = [];
vueOptions.props = vueProps = [];
}
const behaviors = [];
......@@ -905,11 +903,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name');
vueProps.push('value');
} else {
vueProps['name'] = {
vueProps.name = {
type: String,
default: ''
};
vueProps['value'] = {
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
};
......@@ -994,7 +992,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => {
const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default'];
let value = opts.default;
if (isFn(value)) {
value = value();
}
......@@ -1195,11 +1193,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
......@@ -1451,7 +1449,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = {
multipleSlots: true,
......@@ -1579,9 +1577,9 @@ function parseComponent (vueOptions) {
}
componentOptions.messages = {
'__l': componentOptions.methods['__l']
__l: componentOptions.methods.__l
};
delete componentOptions.methods['__l'];
delete componentOptions.methods.__l;
return componentOptions
}
......
......@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor
};
var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null,
upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor
removeInterceptor: removeInterceptor,
interceptors: interceptors
});
var previewImage = {
......@@ -479,7 +477,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {};
}
for (let key in fromArgs) {
for (const key in fromArgs) {
if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key];
if (isFn(keyOption)) {
......@@ -646,8 +644,6 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit
});
var api = /*#__PURE__*/Object.freeze({
__proto__: null
});
......@@ -829,14 +825,14 @@ function createObserver (name) {
}
function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors'];
const vueExtends = vueOptions['extends'];
const vueMixins = vueOptions['mixins'];
const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions.extends;
const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props'];
let vueProps = vueOptions.props;
if (!vueProps) {
vueOptions['props'] = vueProps = [];
vueOptions.props = vueProps = [];
}
const behaviors = [];
......@@ -848,11 +844,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name');
vueProps.push('value');
} else {
vueProps['name'] = {
vueProps.name = {
type: String,
default: ''
};
vueProps['value'] = {
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
};
......@@ -921,7 +917,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => {
const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default'];
let value = opts.default;
if (isFn(value)) {
value = value();
}
......@@ -1112,11 +1108,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
......@@ -1369,7 +1365,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = {
multipleSlots: true,
......@@ -1379,8 +1375,8 @@ function parseBaseComponent (vueComponentOptions, {
{
// 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) {
Object.assign(options, vueOptions['mp-weixin']['options']);
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin'].options) {
Object.assign(options, vueOptions['mp-weixin'].options);
}
}
......
......@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor
};
var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null,
upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor
removeInterceptor: removeInterceptor,
interceptors: interceptors
});
var previewImage = {
......@@ -571,7 +569,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {};
}
for (let key in fromArgs) {
for (const key in fromArgs) {
if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key];
if (isFn(keyOption)) {
......@@ -738,8 +736,6 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit
});
var api = /*#__PURE__*/Object.freeze({
__proto__: null
});
......@@ -921,14 +917,14 @@ function createObserver (name) {
}
function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors'];
const vueExtends = vueOptions['extends'];
const vueMixins = vueOptions['mixins'];
const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions.extends;
const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props'];
let vueProps = vueOptions.props;
if (!vueProps) {
vueOptions['props'] = vueProps = [];
vueOptions.props = vueProps = [];
}
const behaviors = [];
......@@ -940,11 +936,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name');
vueProps.push('value');
} else {
vueProps['name'] = {
vueProps.name = {
type: String,
default: ''
};
vueProps['value'] = {
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
};
......@@ -1013,7 +1009,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => {
const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default'];
let value = opts.default;
if (isFn(value)) {
value = value();
}
......@@ -1204,11 +1200,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
......@@ -1541,7 +1537,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = {
multipleSlots: true,
......
......@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor
};
var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null,
upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor
removeInterceptor: removeInterceptor,
interceptors: interceptors
});
var previewImage = {
......@@ -431,7 +429,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {};
}
for (let key in fromArgs) {
for (const key in fromArgs) {
if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key];
if (isFn(keyOption)) {
......@@ -598,8 +596,6 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit
});
var api = /*#__PURE__*/Object.freeze({
__proto__: null
});
......@@ -786,14 +782,14 @@ function createObserver (name) {
}
function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors'];
const vueExtends = vueOptions['extends'];
const vueMixins = vueOptions['mixins'];
const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions.extends;
const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props'];
let vueProps = vueOptions.props;
if (!vueProps) {
vueOptions['props'] = vueProps = [];
vueOptions.props = vueProps = [];
}
const behaviors = [];
......@@ -805,11 +801,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name');
vueProps.push('value');
} else {
vueProps['name'] = {
vueProps.name = {
type: String,
default: ''
};
vueProps['value'] = {
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
};
......@@ -878,7 +874,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => {
const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default'];
let value = opts.default;
if (isFn(value)) {
value = value();
}
......@@ -1069,11 +1065,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
......@@ -1322,7 +1318,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = {
multipleSlots: true,
......@@ -1332,8 +1328,8 @@ function parseBaseComponent (vueComponentOptions, {
{
// 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin']['options']) {
Object.assign(options, vueOptions['mp-weixin']['options']);
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin'].options) {
Object.assign(options, vueOptions['mp-weixin'].options);
}
}
......
......@@ -8,7 +8,7 @@ function parseData (data, vueComponentOptions) {
}
function parseComponents (vueComponentOptions) {
vueComponentOptions.components = global['__wxVueOptions'].components;
vueComponentOptions.components = global.__wxVueOptions.components;
}
const _toString = Object.prototype.toString;
......@@ -50,11 +50,11 @@ const camelize = cached((str) => {
const SOURCE_KEY = '__data__';
const COMPONENT_LIFECYCLE = {
'created': 'onServiceCreated',
'attached': 'onServiceAttached',
'ready': 'mounted',
'moved': 'moved',
'detached': 'destroyed'
created: 'onServiceCreated',
attached: 'onServiceAttached',
ready: 'mounted',
moved: 'moved',
detached: 'destroyed'
};
const COMPONENT_LIFECYCLE_KEYS = Object.keys(COMPONENT_LIFECYCLE);
......@@ -135,7 +135,7 @@ function parseMethods (methods, vueComponentOptions) {
return
}
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;
}
vueComponentOptions.methods = methods;
......@@ -299,7 +299,7 @@ function parseRelations (relations, vueComponentOptions) {
Object.keys(relations).forEach(name => {
const relation = relations[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;
}
......@@ -772,23 +772,23 @@ var polyfill = {
}
};
global['__wxRoute'] = '';
global['__wxComponents'] = Object.create(null);
global['__wxVueOptions'] = Object.create(null);
global.__wxRoute = '';
global.__wxComponents = Object.create(null);
global.__wxVueOptions = Object.create(null);
function Page (options) {
const pageOptions = parsePage(options);
pageOptions.mixins.unshift(polyfill);
pageOptions.mpOptions.path = global['__wxRoute'];
global['__wxComponents'][global['__wxRoute']] = pageOptions;
pageOptions.mpOptions.path = global.__wxRoute;
global.__wxComponents[global.__wxRoute] = pageOptions;
}
function initRelationsHandler (vueComponentOptions) {
// linked 需要在当前组件 attached 之后再执行
if (!vueComponentOptions['onServiceAttached']) {
vueComponentOptions['onServiceAttached'] = [];
if (!vueComponentOptions.onServiceAttached) {
vueComponentOptions.onServiceAttached = [];
}
vueComponentOptions['onServiceAttached'].push(function onServiceAttached () {
vueComponentOptions.onServiceAttached.push(function onServiceAttached () {
handleRelations(this, 'linked');
});
}
......@@ -796,9 +796,9 @@ function initRelationsHandler (vueComponentOptions) {
function Component (options) {
const componentOptions = parseComponent(options);
componentOptions.mixins.unshift(polyfill);
componentOptions.mpOptions.path = global['__wxRoute'];
componentOptions.mpOptions.path = global.__wxRoute;
initRelationsHandler(componentOptions);
global['__wxComponents'][global['__wxRoute']] = componentOptions;
global.__wxComponents[global.__wxRoute] = componentOptions;
}
function Behavior (options) {
......
......@@ -12,6 +12,10 @@ wx.createComponent({
`
}
function hasOwn (obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key)
}
module.exports = {
directive: 'wx:',
createScopedSlots (slotName, props, state) {
......@@ -43,7 +47,7 @@ module.exports = {
state.scopedSlots = {}
}
let componentName = `${ownerName}-${parentName}-${slotName}`
if (!state.scopedSlots.hasOwnProperty(componentName)) {
if (!hasOwn(state.scopedSlots, componentName)) {
state.scopedSlots[componentName] = 0
}
if (state.scopedSlots[componentName]) {
......
......@@ -348,14 +348,12 @@ const interceptors = {
promiseInterceptor
};
var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null,
upx2px: upx2px,
interceptors: interceptors,
addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor
removeInterceptor: removeInterceptor,
interceptors: interceptors
});
var previewImage = {
......@@ -412,7 +410,7 @@ function processArgs (methodName, fromArgs, argsOption = {}, returnValue = {}, k
if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {};
}
for (let key in fromArgs) {
for (const key in fromArgs) {
if (hasOwn(argsOption, key)) {
let keyOption = argsOption[key];
if (isFn(keyOption)) {
......@@ -587,8 +585,6 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit
});
var api = /*#__PURE__*/Object.freeze({
__proto__: null
});
......@@ -770,14 +766,14 @@ function createObserver (name) {
}
function initBehaviors (vueOptions, initBehavior) {
const vueBehaviors = vueOptions['behaviors'];
const vueExtends = vueOptions['extends'];
const vueMixins = vueOptions['mixins'];
const vueBehaviors = vueOptions.behaviors;
const vueExtends = vueOptions.extends;
const vueMixins = vueOptions.mixins;
let vueProps = vueOptions['props'];
let vueProps = vueOptions.props;
if (!vueProps) {
vueOptions['props'] = vueProps = [];
vueOptions.props = vueProps = [];
}
const behaviors = [];
......@@ -789,11 +785,11 @@ function initBehaviors (vueOptions, initBehavior) {
vueProps.push('name');
vueProps.push('value');
} else {
vueProps['name'] = {
vueProps.name = {
type: String,
default: ''
};
vueProps['value'] = {
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
};
......@@ -862,7 +858,7 @@ function initProperties (props, isBehavior = false, file = '') {
Object.keys(props).forEach(key => {
const opts = props[key];
if (isPlainObject(opts)) { // title:{type:String,default:''}
let value = opts['default'];
let value = opts.default;
if (isFn(value)) {
value = value();
}
......@@ -1053,11 +1049,11 @@ function handleEvent (event) {
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn(`事件信息不存在`)
return console.warn('事件信息不存在')
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
......@@ -1371,7 +1367,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = {
multipleSlots: true,
......
......@@ -2,10 +2,12 @@
<div
:class="viewClass"
class="uni-button"
v-on="$listeners">
v-on="$listeners"
>
<text
:class="textClass"
class="uni-button-t">
class="uni-button-t"
>
<slot />
</text>
</div>
......
......@@ -37,18 +37,20 @@ function genPriorities (entryPagePath) {
return o
}
const uniCloudPath = require.resolve('@dcloudio/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js')
module.exports = {
devtool: false,
entry () {
return process.UNI_ENTRY
},
output: {
filename: '[name].js',
chunkFilename: '[name].js'
},
optimization: {
splitChunks: false,
runtimeChunk: false
},
output: {
filename: '[name].js',
chunkFilename: '[name].js'
},
optimization: {
splitChunks: false,
runtimeChunk: false
},
externals: {
vue: 'Vue'
......@@ -72,6 +74,9 @@ module.exports = {
ENV_PHASE_QA: env.NODE_PHASE === 'test',
ENV_PHASE_OL: env.NODE_PHASE === 'prod'
}),
new webpack.ProvidePlugin({
uniCloud: [uniCloudPath, 'default']
}),
new CopyPlugin([{
from: path.resolve(__dirname, '../dist/' + dslFilename),
to: 'dsl.js'
......
......@@ -5,7 +5,7 @@ module.exports = function () {
const manifest = global.framework.manifest
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 compiler = require('../lib')
function assertCodegen (template, templateCode, renderCode = `with(this){}`, options = {}) {
function assertCodegen (template, templateCode, renderCode = 'with(this){}', options = {}) {
const res = compiler.compile(template, {
resourcePath: 'test.wxml',
mp: Object.assign({
......@@ -18,72 +18,72 @@ describe('mp:compiler-mp-alipay', () => {
it('generate v-for directive', () => {
assertCodegen(
'<view><view v-for="(item,index) in items" :key="index"></view></view>',
`<view><block a:for="{{items}}" a:for-item="item" a:for-index="index" a:key="index"><view></view></block></view>`
'<view><block a:for="{{items}}" a:for-item="item" a:for-index="index" a:key="index"><view></view></block></view>'
)
})
it('generate v-else-if with v-else directive', () => {
assertCodegen(
'<view><view v-if="show">hello</view><view v-else-if="hide">world</view><view v-else>bye</view></view>',
`<view><block a:if="{{show}}"><view>hello</view></block><block a:else><block a:if="{{hide}}"><view>world</view></block><block a:else><view>bye</view></block></block></view>`
'<view><block a:if="{{show}}"><view>hello</view></block><block a:else><block a:if="{{hide}}"><view>world</view></block><block a:else><view>bye</view></block></block></view>'
)
})
it('generate ref', () => {
assertCodegen(
'<component1 ref="c1">text</component1>',
`<component1 vue-id="551070e6-1" ref="__r" data-ref="c1" onVueInit="__l">text</component1>`
'<component1 vue-id="551070e6-1" ref="__r" data-ref="c1" onVueInit="__l">text</component1>'
)
assertCodegen(
'<component1 :ref="c2">text<text>123213</text></component1>',
`<component1 vue-id="551070e6-1" ref="__r" data-ref="{{c2}}" onVueInit="__l">text<text>123213</text></component1>`
'<component1 vue-id="551070e6-1" ref="__r" data-ref="{{c2}}" onVueInit="__l">text<text>123213</text></component1>'
)
assertCodegen(
'<component1 v-for="item in items" ref="c3"></component1>',
`<block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{'551070e6-1-'+__i0__}}" ref="__r" data-ref-in-for="c3" onVueInit="__l"></component1></block>`
'<block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{\'551070e6-1-\'+__i0__}}" ref="__r" data-ref-in-for="c3" onVueInit="__l"></component1></block>'
)
assertCodegen(
'<component1 v-for="item in items" :ref="c4"></component1>',
`<block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{'551070e6-1-'+__i0__}}" ref="__r" data-ref-in-for="{{c4}}" onVueInit="__l"></component1></block>`
'<block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{\'551070e6-1-\'+__i0__}}" ref="__r" data-ref-in-for="{{c4}}" onVueInit="__l"></component1></block>'
)
})
it('generate default slot', () => {
assertCodegen(
'<component1>text</component1>',
`<component1 vue-id="551070e6-1" onVueInit="__l">text</component1>`
'<component1 vue-id="551070e6-1" onVueInit="__l">text</component1>'
)
assertCodegen(
'<component1>text<text>123213</text></component1>',
`<component1 vue-id="551070e6-1" onVueInit="__l">text<text>123213</text></component1>`
'<component1 vue-id="551070e6-1" onVueInit="__l">text<text>123213</text></component1>'
)
assertCodegen(
'<component1>text<block slot="right"></block></component1>',
`<component1 vue-id="551070e6-1" onVueInit="__l">text<view slot="right"></view></component1>`
'<component1 vue-id="551070e6-1" onVueInit="__l">text<view slot="right"></view></component1>'
)
})
it('generate class binding', () => {
assertCodegen(
'<div :class="{ active: isActive }">1</div>',
`<view class="{{(('_div')+' '+((isActive)?'active':''))}}">1</view>`
'<view class="{{((\'_div\')+\' \'+((isActive)?\'active\':\'\'))}}">1</view>'
)
assertCodegen(
`<p class="static" :class="{ active: isActive, 'text-danger': hasError }">2</p>`,
`<view class="{{((('static _p')+' '+((isActive)?'active':''))+' '+((hasError)?'text-danger':''))}}">2</view>`
'<p class="static" :class="{ active: isActive, \'text-danger\': hasError }">2</p>',
'<view class="{{(((\'static _p\')+\' \'+((isActive)?\'active\':\'\'))+\' \'+((hasError)?\'text-danger\':\'\'))}}">2</view>'
)
assertCodegen(
'<p class="static" :class="[activeClass, errorClass]">3</p>',
`<view class="{{((('static _p')+' '+activeClass)+' '+errorClass)}}">3</view>`
'<view class="{{(((\'static _p\')+\' \'+activeClass)+\' \'+errorClass)}}">3</view>'
)
assertCodegen(
`<p class="static" :class="[isActive ? activeClass : '', errorClass]">4</p>`,
`<view class="{{((('static _p')+' '+(isActive?activeClass:''))+' '+errorClass)}}">4</view>`
'<p class="static" :class="[isActive ? activeClass : \'\', errorClass]">4</p>',
'<view class="{{(((\'static _p\')+\' \'+(isActive?activeClass:\'\'))+\' \'+errorClass)}}">4</view>'
)
assertCodegen(
`<p class="static" :class="[{ active: isActive }, errorClass]">5</p>`,
`<view class="{{((('static _p')+' '+[(isActive)?'active':''])+' '+errorClass)}}">5</view>`
'<p class="static" :class="[{ active: isActive }, errorClass]">5</p>',
'<view class="{{(((\'static _p\')+\' \'+[(isActive)?\'active\':\'\'])+\' \'+errorClass)}}">5</view>'
)
assertCodegen(
`<div class="container" :class="computedClassObject">6</div>`,
`<view class="{{(('container _div')+' '+computedClassObject)}}">6</view>`
'<div class="container" :class="computedClassObject">6</div>',
'<view class="{{((\'container _div\')+\' \'+computedClassObject)}}">6</view>'
)
// assertCodegen(
// `<div class="container" :class="computedClassObject">6</div>`,
......@@ -91,61 +91,61 @@ describe('mp:compiler-mp-alipay', () => {
// `with(this){var c0=__get_class(computedClassObject,"container");$mp.data=Object.assign({},{$root:{c0:c0}})}`
// )
assertCodegen(
`<p :class="index === currentIndex ? activeClass : itemClass">7</p>`,
`<view class="{{(('_p')+' '+(index===currentIndex?activeClass:itemClass))}}">7</view>`
'<p :class="index === currentIndex ? activeClass : itemClass">7</p>',
'<view class="{{((\'_p\')+\' \'+(index===currentIndex?activeClass:itemClass))}}">7</view>'
)
assertCodegen(
`<p :class="'m-content-head-'+message.user">8</p>`,
`<view class="{{(('_p')+' '+('m-content-head-'+message.user))}}">8</view>`
'<p :class="\'m-content-head-\'+message.user">8</p>',
'<view class="{{((\'_p\')+\' \'+(\'m-content-head-\'+message.user))}}">8</view>'
)
assertCodegen(
`<p :class="classStr1 || classStr2" class="bg">9</p>`,
`<view class="{{(('bg _p')+' '+(classStr1||classStr2))}}">9</view>`
'<p :class="classStr1 || classStr2" class="bg">9</p>',
'<view class="{{((\'bg _p\')+\' \'+(classStr1||classStr2))}}">9</view>'
)
})
it('generate getPhoneNumber', () => {
assertCodegen(
'<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button>',
`<button open-type="getAuthorize" scope="phoneNumber" data-event-opts="{{[['getAuthorize',[['$onAliGetAuthorize',['getPhoneNumber','$event']]]],['error',[['$onAliAuthError',['getPhoneNumber','$event']]]]]}}" onGetAuthorize="__e" onError="__e">获取手机号</button>`
'<button open-type="getAuthorize" scope="phoneNumber" data-event-opts="{{[[\'getAuthorize\',[[\'$onAliGetAuthorize\',[\'getPhoneNumber\',\'$event\']]]],[\'error\',[[\'$onAliAuthError\',[\'getPhoneNumber\',\'$event\']]]]]}}" onGetAuthorize="__e" onError="__e">获取手机号</button>'
)
})
it('generate events with v-on directive', () => {
assertCodegen(
`<uni-list-item title="标题文字" note="描述信息" show-extra-icon="true" :extra-icon="{color: '#4cd964',size: '22',type: 'spinner'}"></uni-list-item>`,
`<uni-list-item vue-id="551070e6-1" title="标题文字" note="描述信息" show-extra-icon="true" extra-icon="{{$root.a0}}" onVueInit="__l"></uni-list-item>`,
`with(this){var a0={color:"#4cd964",size:"22",type:"spinner"};$mp.data=Object.assign({},{$root:{a0:a0}})}`
'<uni-list-item title="标题文字" note="描述信息" show-extra-icon="true" :extra-icon="{color: \'#4cd964\',size: \'22\',type: \'spinner\'}"></uni-list-item>',
'<uni-list-item vue-id="551070e6-1" title="标题文字" note="描述信息" show-extra-icon="true" extra-icon="{{$root.a0}}" onVueInit="__l"></uni-list-item>',
'with(this){var a0={color:"#4cd964",size:"22",type:"spinner"};$mp.data=Object.assign({},{$root:{a0:a0}})}'
)
assertCodegen(
`<view @click="onClick" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd" @touchcancel="onTouchCancel" @longtap="onLongTap" @longpress="onLongPress"></view>`,
`<view data-event-opts="{{[['tap',[['onClick',['$event']]]],['touchStart',[['onTouchStart',['$event']]]],['touchMove',[['onTouchMove',['$event']]]],['touchEnd',[['onTouchEnd',['$event']]]],['touchCancel',[['onTouchCancel',['$event']]]],['longTap',[['onLongTap',['$event']]]],['longTap',[['onLongPress',['$event']]]]]}}" onTap="__e" onTouchStart="__e" onTouchMove="__e" onTouchEnd="__e" onTouchCancel="__e" onLongTap="__e"></view>`
'<view @click="onClick" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd" @touchcancel="onTouchCancel" @longtap="onLongTap" @longpress="onLongPress"></view>',
'<view data-event-opts="{{[[\'tap\',[[\'onClick\',[\'$event\']]]],[\'touchStart\',[[\'onTouchStart\',[\'$event\']]]],[\'touchMove\',[[\'onTouchMove\',[\'$event\']]]],[\'touchEnd\',[[\'onTouchEnd\',[\'$event\']]]],[\'touchCancel\',[[\'onTouchCancel\',[\'$event\']]]],[\'longTap\',[[\'onLongTap\',[\'$event\']]]],[\'longTap\',[[\'onLongPress\',[\'$event\']]]]]}}" onTap="__e" onTouchStart="__e" onTouchMove="__e" onTouchEnd="__e" onTouchCancel="__e" onLongTap="__e"></view>'
)
assertCodegen(
`<form @submit="formSubmit" @reset="formReset"/>`,
`<form data-event-opts="{{[['submit',[['formSubmit',['$event']]]]]}}" onSubmit="__e" onReset="formReset"></form>`
'<form @submit="formSubmit" @reset="formReset"/>',
'<form data-event-opts="{{[[\'submit\',[[\'formSubmit\',[\'$event\']]]]]}}" onSubmit="__e" onReset="formReset"></form>'
)
assertCodegen(
`<map @callouttap="calloutTap" @controltap="controlTap" @markertap="markerTap" @regionchange="regionChange" @tap="tap"/>`,
`<map data-event-opts="{{[['tap',[['tap',['$event']]]]]}}" onCalloutTap="calloutTap" onControlTap="controlTap" onMarkerTap="markerTap" onRegionChange="regionChange" onTap="__e"></map>`
'<map @callouttap="calloutTap" @controltap="controlTap" @markertap="markerTap" @regionchange="regionChange" @tap="tap"/>',
'<map data-event-opts="{{[[\'tap\',[[\'tap\',[\'$event\']]]]]}}" onCalloutTap="calloutTap" onControlTap="controlTap" onMarkerTap="markerTap" onRegionChange="regionChange" onTap="__e"></map>'
)
assertCodegen(
`<view @transitionend="transitionEnd" @animationstart="animationStart" @animationiteration="animationIteration" @animationend="animationEnd" @firstappear="firstAppear"/>`,
`<view data-event-opts="{{[['transitionEnd',[['transitionEnd',['$event']]]],['animationStart',[['animationStart',['$event']]]],['animationIteration',[['animationIteration',['$event']]]],['animationEnd',[['animationEnd',['$event']]]],['firstAppear',[['firstAppear',['$event']]]]]}}" onTransitionEnd="__e" onAnimationStart="__e" onAnimationIteration="__e" onAnimationEnd="__e" onFirstAppear="__e"></view>`
'<view @transitionend="transitionEnd" @animationstart="animationStart" @animationiteration="animationIteration" @animationend="animationEnd" @firstappear="firstAppear"/>',
'<view data-event-opts="{{[[\'transitionEnd\',[[\'transitionEnd\',[\'$event\']]]],[\'animationStart\',[[\'animationStart\',[\'$event\']]]],[\'animationIteration\',[[\'animationIteration\',[\'$event\']]]],[\'animationEnd\',[[\'animationEnd\',[\'$event\']]]],[\'firstAppear\',[[\'firstAppear\',[\'$event\']]]]]}}" onTransitionEnd="__e" onAnimationStart="__e" onAnimationIteration="__e" onAnimationEnd="__e" onFirstAppear="__e"></view>'
)
assertCodegen(
`<scroll-view @scrolltoupper="scrollToUpper" @scrolltolower="scrollToLower"/>`,
`<scroll-view data-event-opts="{{[['scrollToUpper',[['scrollToUpper',['$event']]]],['scrollToLower',[['scrollToLower',['$event']]]]]}}" onScrollToUpper="__e" onScrollToLower="__e"></scroll-view>`
'<scroll-view @scrolltoupper="scrollToUpper" @scrolltolower="scrollToLower"/>',
'<scroll-view data-event-opts="{{[[\'scrollToUpper\',[[\'scrollToUpper\',[\'$event\']]]],[\'scrollToLower\',[[\'scrollToLower\',[\'$event\']]]]]}}" onScrollToUpper="__e" onScrollToLower="__e"></scroll-view>'
)
assertCodegen(
`<movable-view @changeend="changeEnd"/>`,
`<movable-view data-event-opts="{{[['changeEnd',[['changeEnd',['$event']]]]]}}" onChangeEnd="__e"></movable-view>`
'<movable-view @changeend="changeEnd"/>',
'<movable-view data-event-opts="{{[[\'changeEnd\',[[\'changeEnd\',[\'$event\']]]]]}}" onChangeEnd="__e"></movable-view>'
)
})
})
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, {
resourcePath: 'test.wxml',
mp: Object.assign({
......@@ -18,20 +18,20 @@ describe('mp:compiler-mp-qq', () => {
it('generate text trim', () => {
assertCodegen(
'<text>\nN: {{title}}\n′</text>',
`<text>{{'N: '+title+"\\\\n′"}}</text>`
'<text>{{\'N: \'+title+"\\\\n′"}}</text>'
)
assertCodegen(
'<text>我是第一行1\n我的第二行</text>',
`<text>我是第一行1\n我的第二行</text>`
'<text>我是第一行1\n我的第二行</text>'
)
assertCodegen(
'<text>我是第一行2\n我的第二行1{{title}}</text>',
`<text>{{"我是第一行2\\\\n我的第二行1"+title}}</text>`
'<text>{{"我是第一行2\\\\n我的第二行1"+title}}</text>'
)
assertCodegen(
`<text>我是第一行3
我的第二行2{{title}}</text>`,
`<text>{{"我是第一行3\\\\n 我的第二行2"+title}}</text>`
'<text>{{"我是第一行3\\\\n 我的第二行2"+title}}</text>'
)
})
})
......@@ -51,7 +51,7 @@ function markStatic (node) {
) {
node.plain = true
}
if (!node.attrsMap || !node.attrsMap['id']) { // 保留 id 属性, selectComponent 需要使用
if (!node.attrsMap || !node.attrsMap.id) { // 保留 id 属性, selectComponent 需要使用
delete node.attrs
}
}
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册