提交 1de259ec 编写于 作者: Q qiang

Merge commit 'a7035ab7'

......@@ -3,4 +3,6 @@ src/platforms/app-plus-nvue/runtime
build/rollup-plugin-require-context
packages/*/packages
packages/*/template/**/*
qh-api.js
packages/uni-h5/src
packages/uni-stat
node_modules
const path = require('path')
const del = require('del')
const {
error
} = require('@vue/cli-shared-utils')
const Service = require('@vue/cli-service')
const vueConfig = require('./vue.config.js')
const extendsApiPath = path.resolve(__dirname, '../lib/h5/extends-api')
vueConfig.configureWebpack.resolve.alias['uni-invoke-api'] = extendsApiPath
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd(), {
inlineOptions: vueConfig
})
// 删除 cache 目录
del.sync(['node_modules/.cache'])
let pluginDir = process.argv[2]
if (!pluginDir) {
console.error('缺少参数')
process.exit(0)
}
if (pluginDir.indexOf('/') === -1) {
pluginDir = path.resolve(__dirname, '../packages/uni-' + pluginDir)
}
const pkg = require(path.join(pluginDir, 'package.json'))
if (!pkg['uni-app']) {
console.error('缺少 uni-app 配置')
process.exit(0)
}
service.webpackRawConfigFns.push(function () {
return {
resolve: {
alias: {
'uni-platform/service/api.js': extendsApiPath,
'uni-sub-platform': path.resolve(pluginDir, 'src'),
'uni-platform-api': path.resolve(__dirname, '../src/platforms/h5/service/api'),
'uni-sub-platform-api': path.resolve(pluginDir, 'src/service/api')
}
},
module: {
rules: [{
test: path.resolve(__dirname, '../src/platforms/h5/service/api/index.js'),
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')
}
}]
}]
}
}
})
service.run('build', {
name: 'index',
watch: process.env.UNI_WATCH === 'true',
target: 'lib',
formats: process.env.UNI_WATCH === 'true' ? 'umd' : 'umd-min',
entry: './lib/h5/main.js',
dest: path.join(pluginDir, 'dist'),
clean: true,
mode: process.env.NODE_ENV
}).then(function () {}).catch(err => {
error(err)
process.exit(1)
})
......@@ -51,18 +51,18 @@ dsl.onInitApp(function({
});`
})
const pageCode = pageOutput[0].code
const vueCode = fs.readFileSync(path.resolve(__dirname, '../packages/uni-quickapp/assets/' + filename))
const vueCode = fs.readFileSync(path.resolve(__dirname, '../packages/uni-quickapp-vue/assets/' + filename))
fs.writeFileSync(
path.resolve(__dirname, '../packages/uni-quickapp/dist/' + filename),
path.resolve(__dirname, '../packages/uni-quickapp-vue/dist/' + filename),
vueCode + bridgeCode + appCode + pageCode, {
encoding: 'utf8'
}
)
if (process.env.NODE_ENV === 'production') { // 命令会执行dev,prod两次,仅prod时执行copy
const componentsSrc = path.resolve(__dirname, '../src/platforms/quickapp/view/components/**/*')
const componentsDest = path.resolve(__dirname, '../packages/uni-quickapp/components')
const componentsSrc = path.resolve(__dirname, '../src/platforms/quickapp-vue/view/components/**/*')
const componentsDest = path.resolve(__dirname, '../packages/uni-quickapp-vue/components')
del.sync([componentsDest])
......
......@@ -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': {
......@@ -23,6 +23,10 @@ const PLATFORMS = {
prefix: 'tt',
title: '头条小程序'
},
'quickapp-light': {
prefix: 'qa',
title: '快应用(Light)版'
},
'app-plus': {
prefix: 'wx',
title: 'app-plus'
......@@ -47,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,
......
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')
process.env.UNI_PLATFORM = 'quickapp'
process.env.UNI_PLATFORM = 'quickapp-vue'
const external = []
......@@ -31,21 +31,38 @@ const plugins = [{
}
},
alias({
'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/quickapp/service/invoke-api'),
'uni-service-api': resolve('src/platforms/quickapp/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(),
requireContext(),
commonjs(),
replace({
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM),
__PLATFORM_TITLE__: '快应用'
__PLATFORM_TITLE__: '快应用(Vue)版'
})
]
......@@ -57,11 +74,11 @@ module.exports = function (type) {
let input = ''
if (type === 'bridge') {
input = 'src/platforms/quickapp/runtime/bridge.js'
input = 'src/platforms/quickapp-vue/runtime/bridge.js'
} else if (type === 'app') {
input = 'src/platforms/quickapp/runtime/app.js'
input = 'src/platforms/quickapp-vue/runtime/app.js'
} else if (type === 'page') {
input = 'src/platforms/quickapp/runtime/page.js'
input = 'src/platforms/quickapp-vue/runtime/page.js'
}
return {
......
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,34 +41,33 @@ 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')
}
module.exports = function configureWebpack (config) {
if (process.env.UNI_VIEW === 'true') {
alias['vue$'] = resolve('packages/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js')
}
return {
mode: 'production',
devtool: false,
externals,
resolve: {
alias
},
module: {
rules: []
},
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM)
}),
new webpack.ProvidePlugin(provides)
]
}
module.exports = {
mode: 'production',
devtool: false,
externals,
resolve: {
alias
},
module: {
rules: []
},
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM)
}),
new webpack.ProvidePlugin(provides)
]
}
......@@ -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}));
......@@ -29,7 +29,7 @@ App端如需要更丰富的相机拍照API(如直接调用前置摄像头)
|参数|类型|说明|
|:-|:-|:-|
|tempFilePaths|Array&lt;String&gt;|图片的本地文件路径列表|
|tempFiles|Array&lt;Object&gt;|图片的本地文件列表,每一项是一个 File 对象|
|tempFiles|Array&lt;Object&gt;、Array&lt;File&gt;|图片的本地文件列表,每一项是一个 File 对象|
**File 对象结构如下**
......@@ -38,6 +38,7 @@ App端如需要更丰富的相机拍照API(如直接调用前置摄像头)
|path|String|本地文件路径|
|size|Number|本地文件大小,单位:B|
|name|String|包含扩展名的文件名称,仅H5支持|
|type|String|文件类型,仅H5支持|
**示例**
......
......@@ -21,14 +21,15 @@
**success 返回参数说明**
|参数|说明|平台差异说明说明|
|:-|:-|:-|
|tempFilePath|选定视频的临时文件路径||
|duration|选定视频的时间长度,单位为 s|APP平台 2.1.0+、微信小程序|
|size|选定视频的数据量大小|APP平台 2.1.0+、微信小程序|
|height|返回选定视频的高|APP平台 2.1.0+、微信小程序|
|width|返回选定视频的宽|APP平台 2.1.0+、微信小程序|
|name|包含扩展名的文件名称|仅H5支持|
|参数|类型|说明|平台差异说明说明|
|:-|:-|:-|:-|
|tempFilePath|String|选定视频的临时文件路径||
|tempFile|File|选定的视频文件|仅H5(2.7.0+)支持|
|duration|Number|选定视频的时间长度,单位为 s|APP 2.1.0+、H5、微信小程序|
|size|Number|选定视频的数据量大小|APP 2.1.0+、H5、微信小程序|
|height|Number|返回选定视频的高|APP 2.1.0+、H5、微信小程序|
|width|Number|返回选定视频的宽|APP 2.1.0+、H5、微信小程序|
|name|String|包含扩展名的文件名称|仅H5支持|
**注意:**
* 文件的临时路径,在应用本次启动期间可以正常使用,如需持久保存,需在主动调用 [uni.saveFile](api/file/file?id=savefile),在应用下次启动时才能访问得到。
......
......@@ -9,8 +9,9 @@
|参数名|类型|必填|说明|平台差异说明|
|:-|:-|:-|:-|:-|
|url|String|是|开发者服务器 url||
|files|Array|否|需要上传的文件列表。**使用 files 时,filePath 和 name 不生效。**|App|
|files|Array|否|需要上传的文件列表。**使用 files 时,filePath 和 name 不生效。**|App、H5( 2.7.0+)|
|fileType|String|见平台差异说明|文件类型,image/video/audio|仅支付宝小程序,且必填。|
|file|File|否|要上传的文件对象。|仅H5(2.7.0+)支持|
|filePath|String|是|要上传文件资源的路径。||
|name|String|是|文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容||
|header|Object|否|HTTP 请求 Header, header 中不能设置 Referer。||
......@@ -33,6 +34,7 @@ files 参数是一个 file 对象的数组,file 对象的结构如下:
|参数名|类型|必填|说明|
|:-|:-|:-|:-|
|name|String|否|multipart 提交时,表单的项目名,默认为 file|
|file|File|否|要上传的文件对象,仅H5(2.7.0+)支持|
|uri|String|是|文件的本地地址|
Tip:
......
......@@ -15,6 +15,7 @@
|dataType|String|否|json |如果设为 json,会尝试对返回的数据做一次 JSON.parse||
|responseType|String|否|text |设置响应的数据类型。合法值:text、arraybuffer|App和支付宝小程序不支持|
|sslVerify|Boolean|否|true|验证 ssl 证书|仅App安卓端支持(HBuilderX 2.3.3+)|
|withCredentials|Boolean|否|false|跨域请求时是否携带凭证(cookies)|仅H5支持(HBuilderX 2.7.0+)|
|success|Function|否||收到开发者服务成功返回的回调函数||
|fail|Function|否||接口调用失败的回调函数||
|complete|Function|否||接口调用结束的回调函数(调用成功、失败都会执行)|&nbsp;|
......
......@@ -12,5 +12,5 @@
"message": "chore(release): publish %s"
}
},
"version": "2.0.0-26920200403001"
"version": "2.0.0-26920200421003"
}
......@@ -154,7 +154,8 @@ const ui = [
'startPullDownRefresh',
'stopPullDownRefresh',
'createSelectorQuery',
'createIntersectionObserver'
'createIntersectionObserver',
'getMenuButtonBoundingClientRect'
]
const event = [
......
const fs = require('fs')
const path = require('path')
const glob = require('glob')
const loaderUtils = require('loader-utils')
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
module.exports = function loader(source) {
const options = loaderUtils.getOptions(this)
const baseDir = options['base']
const extendsDir = options['extends']
const exportCode = []
const extendsFiles = []
// extends目录均导出
glob.sync('**/*.js', {
cwd: extendsDir
}).forEach(file => {
if (file === 'index.js') {
return
}
extendsFiles.push(file)
exportCode.push(`export * from 'uni-sub-platform-api/${normalizePath(file)}'`)
})
//base目录中有,extends无的导出
glob.sync('**/*.js', {
cwd: baseDir
}).forEach(file => {
if (file === 'index.js') {
return
}
if (!extendsFiles.includes(file)) {
exportCode.push(`export * from 'uni-platform-api/${normalizePath(file)}'`)
}
})
// console.log(exportCode.join('\n'))
return exportCode.join('\n')
}
import 'uni-sub-platform/service/index'
import * as api from 'uni-platform/service/api/index'
export default api
const fs = require('fs')
const path = require('path')
function getTemplatePath(template) {
if (template) {
return path.resolve(process.env.UNI_INPUT_DIR, template)
}
return path.resolve(process.env.UNI_CLI_CONTEXT, 'public/index.html')
}
function transform(content) {
if (process.env.NODE_ENV === 'production') {
return content + // shadow
`body::after{position:fixed;content:'';left:-1000px;top:-1000px;-webkit-animation:shadow-preload .1s;-webkit-animation-delay:3s;animation:shadow-preload .1s;animation-delay:3s}@-webkit-keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}`
}
return content
}
function getIndexCssPath(assetsDir, template) {
const VUE_APP_INDEX_CSS_HASH = process.env.VUE_APP_INDEX_CSS_HASH
if (VUE_APP_INDEX_CSS_HASH) {
try {
const templateContent = fs.readFileSync(getTemplatePath(template))
if (/\bVUE_APP_INDEX_CSS_HASH\b/.test(templateContent)) {
return path.join(assetsDir, `[name].${VUE_APP_INDEX_CSS_HASH}.[ext]`)
}
} catch (e) {}
}
return assetsDir
}
module.exports = {
options: {
cssVars: {
'--status-bar-height': '0px'
},
filterTag: 'wxs',
vue: '@dcloudio/vue-cli-plugin-uni/packages/h5-vue'
},
copyWebpackOptions(platformOptions, vueOptions) {
return [{
from: require.resolve('@dcloudio/uni-h5/dist/index.css'),
to: getIndexCssPath(vueOptions.assetsDir, platformOptions.template),
transform
},
'hybrid/html'
]
},
configureWebpack() {
return {
devtool: process.env.NODE_ENV === 'production' ? false : 'cheap-module-eval-source-map'
}
}
}
{
"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/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",
"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:mp-weixin:mp": "npm run lint && cross-env UNI_PLATFORM=mp-weixin UNI_MP=true 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": "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": "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",
"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=*",
......@@ -41,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,
......@@ -108,8 +103,9 @@
"my": true,
"swan": true,
"tt": true,
"qh": true,
"qh": true,
"qa": true,
"HWH5": true,
"weex": true,
"__id__": true,
"__uniConfig": true,
......
{
"name": "@dcloudio/uni-app-plus-nvue",
"version": "2.0.0-26920200403001",
"version": "2.0.0-26920200421003",
"description": "uni-app app-plus-nvue",
"main": "dist/index.js",
"repository": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804"
"gitHead": "5ed6c58ef3a74a43b11bd65f8f6f488e470716c8"
}
......@@ -235,12 +235,16 @@ const SYNC_API_RE =
const CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
const CONTEXT_API_RE_EXC = ['createBLEConnection'];
// 同步例外情况
const ASYNC_API = ['createBLEConnection'];
const CALLBACK_API_RE = /^on|^off/;
function isContextApi (name) {
return CONTEXT_API_RE.test(name)
return CONTEXT_API_RE.test(name) && CONTEXT_API_RE_EXC.indexOf(name) === -1
}
function isSyncApi (name) {
return SYNC_API_RE.test(name) && ASYNC_API.indexOf(name) === -1
......@@ -344,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 = {};
......@@ -372,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)) {
......@@ -534,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
}) {
......@@ -580,8 +582,6 @@ function getSubNVueById (id) {
return webview
}
var api = /*#__PURE__*/Object.freeze({
__proto__: null,
getSubNVueById: getSubNVueById,
......@@ -770,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 = [];
......@@ -789,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: ''
};
......@@ -862,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();
}
......@@ -897,10 +897,14 @@ function wrapper$2 (event) {
event.target = event.target || {};
if (!hasOwn(event, 'detail')) {
if (!hasOwn(event, 'detail') || !event.detail) {
event.detail = {};
}
if (!('markerId' in event.detail) && 'markerId' in event) {
event.detail.markerId = event.markerId;
}
if (isPlainObject(event.detail)) {
event.target = Object.assign({}, event.target, event.detail);
}
......@@ -1053,11 +1057,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]]]
......@@ -1085,18 +1089,18 @@ function handleEvent (event) {
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
return
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
return
}
const handler = handlerCtx[methodName];
if (!isFn(handler)) {
......@@ -1313,7 +1317,7 @@ function parseBaseComponent (vueComponentOptions, {
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
const options = {
multipleSlots: true,
......
此差异已折叠。
module.exports = require('@dcloudio/uni-mp-weixin/lib/uni.compiler.js')
const fs = require('fs')
const path = require('path')
const COMPONENTS_DIR_NAME = 'wxcomponents'
function getComponentsCopyOption () {
if (process.env.UNI_OUTPUT_TMP_DIR) { // TODO v3不需要,即将废弃
const componentsDir = path.resolve(process.env.UNI_INPUT_DIR, COMPONENTS_DIR_NAME)
if (fs.existsSync(componentsDir)) {
return {
from: componentsDir,
to: COMPONENTS_DIR_NAME,
ignore: ['**/*.vue', '**/*.css']
}
}
}
}
module.exports = {
options: {
extnames: { // TODO v3不需要此配置
style: '.wxss',
template: '.wxml',
filter: '.wxs'
},
filterTag: 'wxs'
},
copyWebpackOptions (platformOptions, vueOptions) {
const copyOptions = []
const componentsCopyOption = getComponentsCopyOption()
if (componentsCopyOption) {
copyOptions.push(componentsCopyOption)
}
copyOptions.push('hybrid/html')
if (process.env.UNI_USING_V3) { // TODO 将仅保留v3逻辑
copyOptions.push(path.resolve(__dirname, '../dist/view.css'))
copyOptions.push(path.resolve(__dirname, '../dist/view.umd.min.js'))
// TODO 后续common与v3目录应该合并
copyOptions.push(path.resolve(__dirname, '../template/common'))
copyOptions.push(path.resolve(__dirname, '../template/v3'))
}
return copyOptions
},
configureWebpack (webpackConfig, vueOptions) {
let devtool = false
if (process.env.NODE_ENV !== 'production') {
if (process.env.UNI_USING_V3) {
if (vueOptions.pluginOptions['uni-app-plus'].service) {
devtool = 'eval-source-map'
}
} else {
devtool = 'eval-source-map'
}
}
return {
devtool
}
}
}
{
"name": "@dcloudio/uni-app-plus",
"version": "2.0.0-26920200403001",
"version": "2.0.0-26920200421003",
"description": "uni-app app-plus",
"main": "dist/index.js",
"repository": {
......@@ -13,5 +13,9 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804"
"uni-app": {
"name": "app-plus",
"title": "APP-PLUS"
},
"gitHead": "5ed6c58ef3a74a43b11bd65f8f6f488e470716c8"
}
此差异已折叠。
!function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=43)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,o,r,i,s,c,u){var l,f="function"==typeof e?e.options:e;if(c&&(f.components=Object.assign(c,f.components||{})),u&&((u.beforeCreate||(u.beforeCreate=[])).unshift(function(){this[u.__module]=this}),(f.mixins||(f.mixins=[])).push(u)),t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),a&&(f.functional=!0),r&&(f._scopeId="data-v-"+r),i?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},f._ssrRegister=l):o&&(l=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(f.functional){f._injectStyles=l;var d=f.render;f.render=function(e,t){return l.call(t),d(e,t)}}else{var p=f.beforeCreate;f.beforeCreate=p?[].concat(p,l):[l]}return{exports:e,options:f}}n.d(t,"a",function(){return a})},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=/^\$|^on|^create|Sync$|Manager$|^pause/,n=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],a=function(e){return!(t.test(e)&&"createBLEConnection"!==e||~n.indexOf(e))},r=function(t){return function(){for(var n=arguments.length,a=Array(n>1?n-1:0),o=1;o<n;o++)a[o-1]=arguments[o];var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e(r.success)||e(r.fail)||e(r.complete)?t.apply(void 0,[r].concat(a)):new Promise(function(e,n){t.apply(void 0,[Object.assign({},r,{success:e,fail:n})].concat(a)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})}}).then(function(e){return[null,e]}).catch(function(e){return[e]})}},i=[],s=void 0;function c(e){i.forEach(function(t){return t({origin:s,data:e})})}var u=o.webview.currentWebview().id,l=new BroadcastChannel("UNI-APP-SUBNVUE");function f(e){e.$processed=!0;var t=o.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?l.postMessage({data:e,to:t?n:a}):_({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){i.push(e)},e.__uniapp_mask_id){s=e.__uniapp_host;var r=e.__uniapp_mask,c=o.webview.getWebviewById(e.__uniapp_mask_id);c=c.parent()||c;var u=e.show,f=e.hide,d=e.close,p=function(){c.setStyle({mask:"none"})};e.show=function(){c.setStyle({mask:r});for(var t=arguments.length,n=Array(t),a=0;a<t;a++)n[a]=arguments[a];return u.apply(e,n)},e.hide=function(){p();for(var t=arguments.length,n=Array(t),a=0;a<t;a++)n[a]=arguments[a];return f.apply(e,n)},e.close=function(){p();for(var t=arguments.length,n=Array(t),a=0;a<t;a++)n[a]=arguments[a];return d.apply(e,n)}}}function d(e){var t=o.webview.getWebviewById(e);return t&&!t.$processed&&f(t),t}l.onmessage=function(e){e.data.to===u&&c(e.data.data)};var p=weex.requireModule("plus"),g=weex.requireModule("globalEvent"),v=0,h={},y="__uniapp__service";g.addEventListener("plusMessage",function(e){"UniAppJsApi"===e.data.type?A(e.data.id,e.data.data):"UniAppSubNVue"===e.data.type?c(e.data.data,e.data.options):"onNavigationBarButtonTap"===e.data.type?"function"==typeof S&&S(e.data.data):"onNavigationBarSearchInputChanged"===e.data.type?"function"==typeof C&&C(e.data.data):"onNavigationBarSearchInputConfirmed"===e.data.type?"function"==typeof w&&w(e.data.data):"onNavigationBarSearchInputClicked"===e.data.type&&"function"==typeof E&&E(e.data.data)});var A=function(e,t){var n=h[e];n?(n(t),n.keepAlive||delete h[e]):console.error("callback["+e+"] is undefined")},m=function(t){var n,a,o=t.id,r=t.type,i=t.params;h[o]=(a=function(t){e(n)?n(t):n&&(~t.errMsg.indexOf(":ok")?e(n.success)&&n.success(t):~t.errMsg.indexOf(":fail")&&e(n.fail)&&n.fail(t),e(n.complete)&&n.complete(t))},(e(n=i)||n&&e(n.callback))&&(a.keepAlive=!0),a),p.postMessage({id:o,type:r,params:i},y)};function _(e){p.postMessage(e,y)}var b=function(e){return function(t){m({id:v++,type:e,params:t})}},S=void 0,C=void 0,w=void 0,E=void 0;function M(e){S=e}function k(e){C=e}function B(e){w=e}function O(e){E=e}function I(e){return weex.requireModule(e)}var N=weex.requireModule("dom"),P=weex.requireModule("globalEvent"),T=[];function D(e){"function"==typeof e&&(this.isUniAppReady?e():T.push(e))}P.addEventListener("plusMessage",function(e){"UniAppReady"===e.data.type&&(D.isUniAppReady=!0,T.length&&(T.forEach(function(e){return e()}),T=[]))});var x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U=weex.requireModule("stream"),R="GET",V=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:R,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":x(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&"):e},F=weex.requireModule("plusstorage"),j="__TYPE",$=weex.requireModule("clipboard"),L=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function Q(e,t,n){return e[t].apply(e,n)}var J=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,o=(t.desc,t.success),r=(t.fail,t.complete);N.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var i={errMsg:"loadFontFace:ok",status:"loaded"};e(o)&&o(i),e(r)&&r(i)},ready:D,request:function(t){var n=t.url,a=t.data,o=t.header,r=t.method,i=void 0===r?"GET":r,s=t.dataType,c=void 0===s?"json":s,u=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,g={};if(o)for(var v in o)p||"content-type"!==v.toLowerCase()?g[v]=o[v]:(p=!0,g["Content-Type"]=o[v]);return i===R&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+V(a)),U.fetch({url:n,method:i,headers:g,type:"json"===c?"json":"text",body:i!==R?V(a,i,g["Content-Type"]):""},function(t){var n=t.status,a=(t.ok,t.statusText,t.data),o=t.headers,r={};!n||-1===n||d?(r.errMsg="request:fail",e(l)&&l(r)):(r.data=a,r.statusCode=n,r.header=o,e(u)&&u(r)),e(f)&&f(r)}),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;F.getItem(n+j,function(t){if("success"===t.result){var i=t.data;F.getItem(n,function(t){if("success"===t.result){var n=t.data;i&&n?("String"!==i&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(o)&&o(t))}else t.errMsg="setStorage:fail",e(o)&&o(t);e(r)&&r(t)})}else t.errMsg="setStorage:fail",e(o)&&o(t),e(r)&&r(t)})},setStorage:function(t){var n=t.key,a=t.data,o=t.success,r=t.fail,i=t.complete,s="String";"object"===(void 0===a?"undefined":x(a))&&(s="Object",a=JSON.stringify(a)),F.setItem(n,a,function(t){"success"===t.result?F.setItem(n+j,s,function(t){"success"===t.result?e(o)&&o({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(r)&&r(t))}):(t.errMsg="setStorage:fail",e(r)&&r(t)),e(i)&&i(t)})},removeStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;F.removeItem(n,function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(o)&&o(t)),e(r)&&r(t)}),F.removeItem(n+j)},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);$.getString(function(t){var o={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(o),e(a)&&a(o)})},setClipboardData:function(t){var n=t.data,a=t.success,o=(t.fail,t.complete),r={errMsg:"setClipboardData:ok"};$.setString(n),e(a)&&a(r),e(o)&&o(r)},onSubNVueMessage:c,getSubNVueById:d,getCurrentSubNVue:function(){return d(o.webview.currentWebview().id)},$on:function(){return Q(L(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return Q(L(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return Q(L(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return Q(L(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),q={os:{nvue:!0}},K={};return"undefined"!=typeof Proxy?K=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return _;if("requireNativePlugin"===t)return I;if("onNavigationBarButtonTap"===t)return M;if("onNavigationBarSearchInputChanged"===t)return k;if("onNavigationBarSearchInputConfirmed"===t)return B;if("onNavigationBarSearchInputClicked"===t)return O;var n=J[t];return n||(n=b(t)),a(t)?r(n):n}}):(Object.keys(q).forEach(function(e){K[e]=q[e]}),K.postMessage=_,K.requireNativePlugin=I,K.onNavigationBarButtonTap=M,K.onNavigationBarSearchInputChanged=k,K.onNavigationBarSearchInputConfirmed=B,K.onNavigationBarSearchInputClicked=O,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach(function(e){var t=J[e];t||(t=b(e)),a(e)?K[e]=r(t):K[e]=t})),K};var o=new WeexPlus(weex);t.weexPlus=o;var r=a(weex,o,BroadcastChannel);t.default=r},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,function(){return a[e]})}(r);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){this.initMessage()},methods:{initMessage:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,o=(n.callback,n.runtime),r=n.data,i=void 0===r?{}:r,s=n.useGlobalEvent;this.__from=a,this.__runtime=o,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(i)),e.key.addEventListener("backbutton",function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")});var c=this,u=function(e){var t=e.data&&e.data.__message;t&&c.__onMessageCallback&&c.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",u):new BroadcastChannel(this.__page).onmessage=u},postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a={__message:{__page:this.__page,data:t,keep:n}},o=this.__from;if("v8"===this.__runtime){if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,o);else new BroadcastChannel(o).postMessage(a)}else{var r=e.webview.getWebviewById(o);r&&r.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},,,function(e,t,n){"use strict";var a=n(32),o=n(17),r=n(1);var i=Object(r.a)(o.default,a.b,a.c,!1,null,null,"57707442",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(38).default,this.options.style):Object.assign(this.options.style,n(38).default)}).call(i),t.default=i.exports},,,,,,,,,function(e,t,n){"use strict";var a=n(18),o=n.n(a);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a,o,r=(a=n(5))&&a.__esModule?a:{default:a};function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=e.barcode,c={qrCode:[s.QR,s.AZTEC,s.MAXICODE],barCode:[s.EAN13,s.EAN8,s.UPCA,s.UPCE,s.CODABAR,s.CODE128,s.CODE39,s.CODE93,s.ITF,s.RSS14,s.RSSEXPANDED],datamatrix:[s.DATAMATRIX],pdf417:[s.PDF417]},u=(i(o={},s.QR,"QR_CODE"),i(o,s.EAN13,"EAN_13"),i(o,s.EAN8,"EAN_8"),i(o,s.DATAMATRIX,"DATA_MATRIX"),i(o,s.UPCA,"UPC_A"),i(o,s.UPCE,"UPC_E"),i(o,s.CODABAR,"CODABAR"),i(o,s.CODE39,"CODE_39"),i(o,s.CODE93,"CODE_93"),i(o,s.CODE128,"CODE_128"),i(o,s.ITF,"CODE_25"),i(o,s.PDF417,"PDF_417"),i(o,s.AZTEC,"AZTEC"),i(o,s.RSS14,"RSS_14"),i(o,s.RSSEXPANDED,"RSSEXPANDED"),o),l={mixins:[r.default],data:{filters:[0,2,1],backgroud:"#000000",frameColor:"#118ce9",scanbarColor:"#118ce9",enabledFlash:!1,flashImage0:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABjklEQVRoQ+1ZbVHEQAx9TwE4ABTcOQAknANQAKcAUAAOAAXgAHAACsDCKQiTmbYDzJZtNt2bFrJ/m6+Xl2yyU2LmhzOPH/8PgIjcADirxNyapNoffMwMiMgzgMPBHmyCLySPLCoBwJKtAbJbYaBmD1yRvBwAtBMxl5DF+DZkiwCIyBLAzsgBbki+Wm2WAlCaL6zOMvKnJO+sNksB7ALQbO1ZHfbIv5FUVs2nCIB6EZETALdmj2mFY5I6X8ynGEADQllYmL1+VzBfnV/VvQB0aj45ARyQ/Ci14QLQsOBZLe5JaikWnzEA7AN4L4hgA2Dpyb76dANwsOCq/TZhASAYKGie0a7R1lDPI0ebtF0NUi+4yfdAtxr3PEMnD6BbD0QkNfACQO05EAwMuaBqDrIVycdmTpwDuP4R0OR7QFftVRP0g+49cwOQq4DJMxAAchmofY3m/EcJBQOZbTRKKJeBKKEoIePvpFRJ1VzmciUccyCa+C81cerBkuuB7sGTE/zt+yhN7AnAqxsAvBn06n8CkyPwMZKwm+UAAAAASUVORK5CYII=",flashImage1:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEUAAAA3kvI3lfY2k/VAl+43k/U3k/Q4k/M3kvI3k/M4k/Q4lPU2lPU2k/Vdq843k/WWSpNKAAAAD3RSTlMAwD+QINCAcPBgUDDgoBAE044kAAAAdklEQVQ4y2OgOrD/DwffUSTkERIfyZXAtOMbca7iVoKDDSgSbAijJqBI8J2HiX9FM2s+TOITmgQrTEIATYIJJuEA5mJ68S+Gg/0hEi0YEoxQK2gs0WyPQyKBGYeEAhPtJRaw45AIccXpwVEJekuwQyQWMFAfAACeDBJY9aXa3QAAAABJRU5ErkJggg=="},onLoad:function(){var e=this,t=this.data.scanType,n=[];Array.isArray(t)&&t.length&&t.forEach(function(e){var t=c[e];t&&(n=n.concat(t))}),n.length||(n=n.concat(c.qrCode).concat(c.barCode).concat(c.datamatrix).concat(c.pdf417)),this.filters=n,this.onMessage(function(t){e.gallery()})},onUnload:function(){this.cancel()},methods:{start:function(){this.$refs.barcode.start({conserve:!0,filename:"_doc/barcode/"})},scan:function(t){var n=this;s.scan(t,function(e,t,a){n.scanSuccess(e,t,a)},function(){e.nativeUI.toast("识别失败")},this.filters)},cancel:function(){this.$refs.barcode.cancel()},gallery:function(){var t=this;e.gallery.pick(function(e){t.scan(e)},function(t){12!==t.code&&e.nativeUI.toast("选择失败")},{multiple:!1,system:!1})},onmarked:function(e){var t=e.detail;this.scanSuccess(t.code,t.message,t.file)},scanSuccess:function(e,t,n){this.postMessage({event:"marked",detail:{scanType:u[e],result:t,charSet:"utf8",path:n||""}})},onerror:function(e){this.postMessage({event:"fail",message:JSON.stringify(e)})},setFlash:function(){this.enabledFlash=!this.enabledFlash,this.$refs.barcode.setFlash(this.enabledFlash)}}};t.default=l}).call(this,n(2).weexPlus)},function(e,t){e.exports={content:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"#000000"},barcode:{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:1},"set-flash":{alignItems:"center",justifyContent:"center",transform:"translateY(80px)",zIndex:2},"image-flash":{width:"26",height:"26",marginBottom:"2"},"image-flash-text":{fontSize:"10",color:"#FFFFFF"}}},,,,,,,,,,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["content"]},[n("barcode",{ref:"barcode",staticClass:["barcode"],attrs:{autostart:"true",backgroud:e.backgroud,frameColor:e.frameColor,scanbarColor:e.scanbarColor,filters:e.filters},on:{marked:e.onmarked,error:e.onerror}}),n("view",{staticClass:["set-flash"],on:{click:e.setFlash}},[n("u-image",{staticClass:["image-flash"],attrs:{src:e.enabledFlash?e.flashImage1:e.flashImage0,resize:"stretch"}}),n("u-text",{staticClass:["image-flash-text"]},[e._v(e._s(e.enabledFlash?"轻触关闭":"轻触照亮"))])],1)],1)])},o=[];n.d(t,"b",function(){return a}),n.d(t,"c",function(){return o}),n.d(t,"a",function(){})},,,,,,function(e,t,n){"use strict";n.r(t);var a=n(19),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,function(){return a[e]})}(r);t.default=o.a},,,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(8);a.default.mpType="page",a.default.route="template/__uniappscan",a.default.el="#root",new Vue(a.default)}]);
\ No newline at end of file
此差异已折叠。
此差异已折叠。
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<script>
var __UniViewStartTime__ = Date.now();
document.addEventListener('DOMContentLoaded', function() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
})
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title>View</title>
<link rel="stylesheet" href="view.css" />
</head>
<body>
<div id="app"></div>
<script src="__uniappes6.js"></script>
<script src="view.umd.min.js"></script>
<script src="app-view.js"></script>
</body>
</html>
......@@ -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
......
......@@ -22,7 +22,7 @@ const {
} = require('./pages')
const {
md5,
md5,
hasOwn,
hasModule,
hashify,
......@@ -40,7 +40,6 @@ const {
getPlatformProject,
isSupportSubPackages,
getPlatforms,
getPlatformGlobal,
getPlatformScss,
getPlatformSass,
runByHBuilderX,
......@@ -48,7 +47,6 @@ const {
isInHBuilderXAlpha,
getPlatformExts,
getPlatformTarget,
getPlatformVue,
getShadowCss,
getPlatformCssVars,
getPlatformCssnano,
......@@ -59,12 +57,12 @@ const {
nvueJsPreprocessOptions,
nvueCssPreprocessOptions,
nvueHtmlPreprocessOptions,
devtoolModuleFilenameTemplate
getPlatformGlobal
} = require('./platform')
module.exports = {
md5,
tags,
tags,
hasOwn,
getJson,
parseJson,
......@@ -93,8 +91,6 @@ module.exports = {
getPlatformExts,
getPlatformTarget,
getPlatformProject,
getPlatformVue,
getPlatformGlobal,
getShadowCss,
getPlatformCssVars,
getPlatformCssnano,
......@@ -110,5 +106,5 @@ module.exports = {
nvueJsPreprocessOptions,
nvueCssPreprocessOptions,
nvueHtmlPreprocessOptions,
devtoolModuleFilenameTemplate
getPlatformGlobal
}
......@@ -44,7 +44,7 @@ function getH5Options (manifestJson) {
manifestJson = getManifestJson()
}
const h5 = manifestJson.h5 || {}
const h5 = manifestJson[process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM] || {}
h5.appid = (manifestJson.appid || '').replace('__UNI__', '')
......@@ -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
......@@ -75,7 +75,7 @@ function getH5Options (manifestJson) {
if (!h5.publicPath.endsWith('/')) {
h5.publicPath = h5.publicPath + '/'
}
} else { // 其他模式,启用 base
} else { // 其他模式,启用 base
if (base.startsWith('./')) {
// 在开发模式, publicPath 如果为 './' webpack-dev-server 匹配文件时会失败
h5.publicPath = base.substr(1)
......@@ -90,6 +90,11 @@ function getH5Options (manifestJson) {
h5.devServer = h5.devServer || {}
// 插件修改 h5Options
global.uniPlugin.configureH5.forEach(configureH5 => {
configureH5(h5)
})
return h5
}
......@@ -98,4 +103,4 @@ module.exports = {
parseManifestJson,
getNetworkTimeout,
getH5Options
}
}
......@@ -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) {
......
......@@ -366,10 +366,10 @@ function initAutoImportScanComponents () {
const components = getAutoComponentsByDir(componentsPath)
if (process.env.UNI_PLATFORM === 'quickapp') {
if (process.env.UNI_PLATFORM === 'quickapp-vue') {
if (!uniQuickAppAutoImportScanComponents) {
uniQuickAppAutoImportScanComponents = getAutoComponentsByDir(
path.resolve(require.resolve('@dcloudio/uni-quickapp'), '../../components'),
path.resolve(require.resolve('@dcloudio/uni-quickapp-vue'), '../../components'),
true
)
}
......
const path = require('path')
const initPreprocessContext = require('./preprocess')
const Plugin = {
options: {},
// 初步校验相关配置是否正确
validate: [], // (platformOptions, manifestJson) {},
configureEnv: [], // (){},
// 以 H5 为基准的平台特殊配置
configureH5: [], // (h5Options) {},
// 链式修改 webpack config
chainWebpack: [], // (config, vueOptions, api) {},
// 修改 webpack config
configureWebpack: [], // (config, vueOptions, api) {},
// 配置额外的资源拷贝
copyWebpackOptions: [] // (platformOptions, vueOptions) {}
}
const PLUGIN_KEYS = Object.keys(Plugin)
function initPlugin (plugin) {
let pluginApi
try {
pluginApi = require(path.join(plugin.id, (plugin.config.main || '/lib/uni.config.js')))
} catch (e) {
console.warn(`${plugin.id} 缺少 uni.config.js `)
}
pluginApi && PLUGIN_KEYS.forEach(name => {
if (pluginApi[name]) {
if (Array.isArray(Plugin[name])) { // hooks
Plugin[name].push(pluginApi[name])
} else { // options
Object.assign(Plugin[name], pluginApi[name])
}
}
})
}
const pluginRE = /^(uni-|@[\w-]+(\.)?[\w-]+\/uni-)/
function resolvePlugins () {
const pkg = require(path.resolve(process.env.UNI_CLI_CONTEXT, 'package.json'))
return Object.keys(pkg.devDependencies || {})
.concat(Object.keys(pkg.dependencies || {}))
.map(id => {
if (!pluginRE.test(id)) {
return
}
try {
const pluginPkg = require(id + '/package.json')
const config = pluginPkg['uni-app']
if (!config) {
return
}
if (!config.name) {
return console.warn(`${id}/package.json->uni-app 缺少 name 属性`)
}
return {
id,
name: config.name,
config
}
} catch (e) {}
}).filter(Boolean)
}
function initExtends (name, plugin, plugins) {
const extendsPlatform = plugin.config.extends
if (extendsPlatform) {
if (extendsPlatform !== 'h5') {
console.error('目前仅支持基于 h5 平台做扩展')
process.exit(0)
}
const extendsPlugin = plugins.find(plugin => plugin.name === extendsPlatform)
if (!plugin) {
console.error(`缺少平台 ${extendsPlatform} 插件`)
process.exit(0)
}
process.env.UNI_SUB_PLATFORM = name
process.env.UNI_PLATFORM = extendsPlatform
initPlugin(extendsPlugin)
}
}
module.exports = {
init () {
const plugins = resolvePlugins()
const plugin = plugins.find(plugin => plugin.name === process.env.UNI_PLATFORM)
if (!plugin) {
console.error(`缺少平台 ${process.env.UNI_PLATFORM} 插件`)
process.exit(0)
}
const name = plugin.name
initExtends(name, plugin, plugins)
initPlugin(plugin)
Plugin.name = name
Plugin.id = plugin.id
Plugin.config = plugin.config
Plugin.platforms = plugins.map(plugin => plugin.name)
Plugin.preprocess = initPreprocessContext(name, Plugin.platforms, process.UNI_SCRIPT_DEFINE)
return Plugin
}
}
const DEFAULT_KEYS = [
'MP',
'APP',
'APP-PLUS-NVUE',
'APP-VUE',
'APP-NVUE'
]
function normalize (name) {
return name.replace(/-/g, '_').toUpperCase()
}
module.exports = function initPreprocess (name, platforms, userDefines = {}) {
const vueContext = {} // vue 值为true的条件编译
const nvueContext = {} // nvue 值为true的条件编译
const defaultContext = {}
const userDefineKeys = Object.keys(userDefines)
platforms
.concat(DEFAULT_KEYS)
.concat(userDefineKeys)
.forEach(name => {
defaultContext[normalize(name)] = false
})
vueContext[normalize(name)] = true
if (name === 'app-plus') {
vueContext.APP_VUE = true
nvueContext.APP_PLUS = true
nvueContext.APP_NVUE = true
nvueContext.APP_PLUS_NVUE = true
}
if (name.startsWith('mp-')) {
vueContext.MP = true
}
if (name.startsWith('app-')) {
vueContext.APP = true
}
userDefineKeys.forEach(name => {
if (userDefines[name]) {
const key = normalize(name)
vueContext[key] = nvueContext[key] = true
}
})
return {
vueContext: {
...defaultContext,
...vueContext
},
nvueContext: {
...defaultContext,
...nvueContext
}
}
}
此差异已折叠。
此差异已折叠。
{
"name": "@dcloudio/uni-cli-shared",
"version": "2.0.0-26920200403001",
"version": "2.0.0-26920200421003",
"description": "uni-cli-shared",
"main": "lib/index.js",
"repository": {
......@@ -23,5 +23,5 @@
"postcss-urlrewrite": "^0.2.2",
"strip-json-comments": "^2.0.1"
},
"gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804"
"gitHead": "5ed6c58ef3a74a43b11bd65f8f6f488e470716c8"
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册