diff --git a/.eslintignore b/.eslintignore index 3ef7c614aaaf88cdb5539368c1047a5f0b219ca9..bbc3713a42b7b7ab3256c47b0f37f2ae6763e552 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,3 +5,4 @@ packages/*/packages packages/*/template/**/* packages/uni-h5/src packages/uni-stat +node_modules diff --git a/build/build.plugin.js b/build/build.plugin.js index 599a72469d4c1f54d2c0c024772c46d469f8c254..76f10ca6d690749a5416698a40b19c5db6fbfae1 100644 --- a/build/build.plugin.js +++ b/build/build.plugin.js @@ -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') } }] }] diff --git a/build/manifest.js b/build/manifest.js index 06bd8f7a27afc51f4d12c4678a19df9c8819bbb0..e6ab74460c036fd979a2c2531d1a25b8e88527d6 100644 --- a/build/manifest.js +++ b/build/manifest.js @@ -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'] ] diff --git a/build/rollup.config.app.js b/build/rollup.config.app.js index 9896a8f26f4eff63b47968acbeb33f116af21454..98e8309aa3560076406088c3d87a6da242101755 100644 --- a/build/rollup.config.app.js +++ b/build/rollup.config.app.js @@ -1,8 +1,8 @@ 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), diff --git a/build/rollup.config.mp.js b/build/rollup.config.mp.js index b39600cebcaf9f67a85ab09a132f0d99a7dc9c1b..92f6fb1b622cd8fb667a7024d7b889d94f3e0877 100644 --- a/build/rollup.config.mp.js +++ b/build/rollup.config.mp.js @@ -1,6 +1,6 @@ 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'] -} +} diff --git a/build/rollup.config.qa.js b/build/rollup.config.qa.js index e739152342d0267db6ff5d10fb216d83f01eab3f..67f43a56c806f8ecb885ed72bf9a528e55fa7891 100644 --- a/build/rollup.config.qa.js +++ b/build/rollup.config.qa.js @@ -1,8 +1,8 @@ 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(), diff --git a/build/rollup.config.service.js b/build/rollup.config.service.js index 6e3cfd5fa4b40b869ec0736cf46494cc6db2e192..1aeed8e29e3cb114bcbc33166d47b391f430bbf2 100644 --- a/build/rollup.config.service.js +++ b/build/rollup.config.service.js @@ -1,22 +1,32 @@ -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' + }) + ] } diff --git a/build/rollup.config.web-view.js b/build/rollup.config.web-view.js index 25e9c089a5152d7a2e47e38e1ff6fa421ede16f7..dcc55f58e0d476adf0e783cc5f491a7a96ea3c8a 100644 --- a/build/rollup.config.web-view.js +++ b/build/rollup.config.web-view.js @@ -1,23 +1,25 @@ 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() ] } diff --git a/build/webpack.config.js b/build/webpack.config.js index 74a2ee56e82971ddf2469e9c3957052326e1e4db..2ca26492e4fe0839517512213f38420a306859d6 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -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 = { diff --git a/build/webpack.config.test.js b/build/webpack.config.test.js index 63059ddfffe8ff831bda34196c8d4ed01a52e562..43942c95e9a20ccd1629c13188b068dc4f0c1aaa 100644 --- a/build/webpack.config.test.js +++ b/build/webpack.config.test.js @@ -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 diff --git a/dist/uni.webview.1.5.2.js b/dist/uni.webview.1.5.2.js index 1b2421df647d91edbdbfeb982e4c3759ef1d4c61..3907c019571084cf9de2ada77a9cf9c1b75c50a7 100644 --- a/dist/uni.webview.1.5.2.js +++ b/dist/uni.webview.1.5.2.js @@ -1 +1 @@ -!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=(00&&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})); diff --git a/package.json b/package.json index d7cb5deec3d3d7d25a3473f4d75fb581206a2598..f20f92adca84237a3d7bf9dbec0a4e9c72027d4c 100644 --- a/package.json +++ b/package.json @@ -1,35 +1,30 @@ { - "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, diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 3ff485cf9e60a1e47599481e4e9b0312a0943dac..f309127324b101c1a4633eb291a2ce3325aa327d 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -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, diff --git a/packages/uni-app-plus/dist/index.v3.js b/packages/uni-app-plus/dist/index.v3.js index 9629ee4edebfe2b75c1fecdb98cf69ff7452062e..371893e0c11d490e1decb1c78e1e9624d565b2df 100644 --- a/packages/uni-app-plus/dist/index.v3.js +++ b/packages/uni-app-plus/dist/index.v3.js @@ -1013,12 +1013,12 @@ var serviceContext = (function () { }); const makePhoneCall = { - 'phoneNumber': { + phoneNumber: { type: String, required: true, validator (phoneNumber) { if (!phoneNumber) { - return `makePhoneCall:fail parameter error: parameter.phoneNumber should not be empty String;` + return 'makePhoneCall:fail parameter error: parameter.phoneNumber should not be empty String;' } } } @@ -1128,7 +1128,7 @@ var serviceContext = (function () { const SOURCE_TYPES = ['album', 'camera']; const chooseImage = { - 'count': { + count: { type: Number, required: false, default: 9, @@ -1138,7 +1138,7 @@ var serviceContext = (function () { } } }, - 'sizeType': { + sizeType: { type: [Array, String], required: false, default: SIZE_TYPES, @@ -1161,7 +1161,7 @@ var serviceContext = (function () { } } }, - 'sourceType': { + sourceType: { type: Array, required: false, default: SOURCE_TYPES, @@ -1189,7 +1189,7 @@ var serviceContext = (function () { const SOURCE_TYPES$1 = ['album', 'camera']; const chooseVideo = { - 'sourceType': { + sourceType: { type: Array, required: false, default: SOURCE_TYPES$1, @@ -1293,7 +1293,7 @@ var serviceContext = (function () { } const getImageInfo = { - 'src': { + src: { type: String, required: true, validator (src, params) { @@ -1393,7 +1393,7 @@ var serviceContext = (function () { item = item.split('='); query[item[0]] = item[1]; }); - for (let key in data) { + for (const key in data) { if (hasOwn(data, key)) { let v = data[key]; if (typeof v === 'undefined' || v === null) { @@ -1748,7 +1748,7 @@ var serviceContext = (function () { }); const getStorage = { - 'key': { + key: { type: String, required: true } @@ -1761,11 +1761,11 @@ var serviceContext = (function () { }]; const setStorage = { - 'key': { + key: { type: String, required: true }, - 'data': { + data: { required: true } }; @@ -1826,7 +1826,7 @@ var serviceContext = (function () { const FRONT_COLORS = ['#ffffff', '#000000']; const setNavigationBarColor = { - 'frontColor': { + frontColor: { type: String, required: true, validator (frontColor, params) { @@ -1835,11 +1835,11 @@ var serviceContext = (function () { } } }, - 'backgroundColor': { + backgroundColor: { type: String, required: true }, - 'animation': { + animation: { type: Object, default () { return { @@ -1856,7 +1856,7 @@ var serviceContext = (function () { } }; const setNavigationBarTitle = { - 'title': { + title: { type: String, required: true } @@ -2161,7 +2161,7 @@ var serviceContext = (function () { } if (value === undefined) { if (hasOwn(paramOptions, 'default')) { - const paramDefault = paramOptions['default']; + const paramDefault = paramOptions.default; value = isFn(paramDefault) ? paramDefault() : paramDefault; paramsData[key] = value; // 默认值 } @@ -2389,7 +2389,7 @@ var serviceContext = (function () { params = Object.assign({}, params); const apiCallbacks = {}; - for (let name in params) { + for (const name in params) { const param = params[name]; if (isFn(param)) { apiCallbacks[name] = tryCatch(param); @@ -2416,7 +2416,7 @@ var serviceContext = (function () { } const wrapperCallbacks = {}; - for (let name in extras) { + for (const name in extras) { const extra = extras[name]; if (isFn(extra)) { wrapperCallbacks[name] = tryCatchFramework(extra); @@ -2446,7 +2446,7 @@ var serviceContext = (function () { res.errMsg = apiName + ':cancel'; } else if (res.errMsg.indexOf(':fail') !== -1) { let errDetail = ''; - let spaceIndex = res.errMsg.indexOf(' '); + const spaceIndex = res.errMsg.indexOf(' '); if (spaceIndex > -1) { errDetail = res.errMsg.substr(spaceIndex); } @@ -2820,7 +2820,7 @@ var serviceContext = (function () { return } if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] setStatusBarStyle`, statusBarStyle); + console.log('[uni-app] setStatusBarStyle', statusBarStyle); } lastStatusBarStyle = statusBarStyle; @@ -2890,18 +2890,18 @@ var serviceContext = (function () { if (t.indexOf('./') === 0) return getRealRoute$1(e, t.substr(2)) let n; let i; - let o = t.split('/'); + const o = t.split('/'); for (n = 0, i = o.length; n < i && o[n] === '..'; n++); o.splice(0, n); t = o.join('/'); - let r = e.length > 0 ? e.split('/') : []; + const r = e.length > 0 ? e.split('/') : []; r.splice(r.length - n - 1, n + 1); return r.concat(o).join('/') }; // 处理 Android 平台解压与非解压模式下获取的路径不一致的情况 const _handleLocalPath = filePath => { - let localUrl = plus.io.convertLocalFileSystemURL(filePath); + const localUrl = plus.io.convertLocalFileSystemURL(filePath); return localUrl.replace(/^\/?apps\//, '/android_asset/apps/').replace(/\/$/, '') }; @@ -3026,7 +3026,7 @@ var serviceContext = (function () { } } - let audios = {}; + const audios = {}; const evts = ['play', 'canplay', 'ended', 'stop', 'waiting', 'seeking', 'seeked', 'pause']; @@ -3102,7 +3102,7 @@ var serviceContext = (function () { }) { const audio = audios[audioId]; if (audio) { - let style = { + const style = { loop, autoplay }; @@ -3132,7 +3132,7 @@ var serviceContext = (function () { errMsg: 'getAudioState:fail' } } - let { + const { src, startTime, volume @@ -3276,12 +3276,12 @@ var serviceContext = (function () { currentPosition: audio.getPosition(), status: audio.isPaused() ? 0 : 1, downloadPercent: Math.round(100 * audio.getBuffered() / audio.getDuration()), - errMsg: `getMusicPlayerState:ok` + errMsg: 'getMusicPlayerState:ok' } } return { status: 2, - errMsg: `getMusicPlayerState:ok` + errMsg: 'getMusicPlayerState:ok' } } function operateMusicPlayer ({ @@ -3314,7 +3314,7 @@ var serviceContext = (function () { function setBackgroundAudioState (args) { setMusicState(args); return { - errMsg: `setBackgroundAudioState:ok` + errMsg: 'setBackgroundAudioState:ok' } } function operateBackgroundAudio ({ @@ -3343,11 +3343,11 @@ var serviceContext = (function () { coverImgUrl: '', webUrl: '', startTime: 0, - errMsg: `getBackgroundAudioState:ok` + errMsg: 'getBackgroundAudioState:ok' }; const audio = getAudio(); if (audio) { - let newData = { + const newData = { duration: audio.getDuration() || 0, currentTime: audio.isStopped ? 0 : audio.getPosition(), paused: audio.isPaused(), @@ -3559,7 +3559,7 @@ var serviceContext = (function () { isFn(callback) && callback(ret); if (type === SUCCESS || type === FAIL) { - const complete = callbacks['complete']; + const complete = callbacks.complete; isFn(complete) && complete(ret); } } @@ -4361,12 +4361,12 @@ var serviceContext = (function () { }, callbackId) { const barcode = plus.barcode; const SCAN_TYPES = { - 'qrCode': [ + qrCode: [ barcode.QR, barcode.AZTEC, barcode.MAXICODE ], - 'barCode': [ + barCode: [ barcode.EAN13, barcode.EAN8, barcode.UPCA, @@ -4379,8 +4379,8 @@ var serviceContext = (function () { barcode.RSS14, barcode.RSSEXPANDED ], - 'datamatrix': [barcode.DATAMATRIX], - 'pdf417': [barcode.PDF417] + datamatrix: [barcode.DATAMATRIX], + pdf417: [barcode.PDF417] }; const SCAN_MAPS = { @@ -4416,8 +4416,8 @@ var serviceContext = (function () { }); } if (!filters.length) { - filters = filters.concat(SCAN_TYPES['qrCode']).concat(SCAN_TYPES['barCode']).concat(SCAN_TYPES['datamatrix']).concat( - SCAN_TYPES['pdf417']); + filters = filters.concat(SCAN_TYPES.qrCode).concat(SCAN_TYPES.barCode).concat(SCAN_TYPES.datamatrix).concat( + SCAN_TYPES.pdf417); } const buttons = []; @@ -4569,7 +4569,8 @@ var serviceContext = (function () { class Page { constructor (webview) { this.webview = webview; - } + } + sendMessage (data) { const message = { __message: { @@ -4583,7 +4584,8 @@ var serviceContext = (function () { } else { plus_.webview.postMessageToUniNView(message, id); } - } + } + close () { this.webview.close(); } @@ -4750,7 +4752,7 @@ var serviceContext = (function () { } function checkIsSupportSoterAuthentication () { - let supportMode = []; + const supportMode = []; if (checkIsSupportFingerPrint()) { supportMode.push('fingerPrint'); } @@ -4829,7 +4831,7 @@ var serviceContext = (function () { errMsg: 'startSoterAuthentication:fail' } } - let supportRequestAuthMode = []; + const supportRequestAuthMode = []; requestAuthModes.map((item, index) => { if (supportMode.indexOf(item) > -1) { supportRequestAuthMode.push(item); @@ -4842,7 +4844,7 @@ var serviceContext = (function () { errMsg: 'startSoterAuthentication:fail no corresponding mode' } } - let enrolledRequestAuthMode = []; + const enrolledRequestAuthMode = []; supportRequestAuthMode.map((item, index) => { const checked = checkIsSoterEnrolledInDevice({ checkAuthMode: item @@ -5043,7 +5045,7 @@ var serviceContext = (function () { }); } - let maskClickCallback = []; + const maskClickCallback = []; var tabBar$1 = { id: '0', @@ -5130,7 +5132,7 @@ var serviceContext = (function () { maskClickCallback.push(callback); }, removeEventListener (name, callback) { - let callbackIndex = maskClickCallback.indexOf(callback); + const callbackIndex = maskClickCallback.indexOf(callback); maskClickCallback.splice(callbackIndex, 1); } }; @@ -5475,7 +5477,7 @@ var serviceContext = (function () { }); } let index = 0; - let onShow = function () { + const onShow = function () { index++; if (index === 2) { webview.evalJS(`__chooseLocation__(${JSON.stringify(params)})`); @@ -5980,7 +5982,7 @@ var serviceContext = (function () { } const invokeChooseVideo = function (callbackId, type, tempFilePath = '') { - let callbackResult = { + const callbackResult = { errMsg: `chooseVideo:${type}`, tempFilePath: tempFilePath, duration: 0, @@ -6035,7 +6037,7 @@ var serviceContext = (function () { camera = 'back' } = {}, callbackId) { let fallback = true; - let cameraIndex = (camera === 'front') ? 2 : 1; + const cameraIndex = (camera === 'front') ? 2 : 1; if (sourceType.length === 1) { if (sourceType[0] === 'album') { fallback = false; @@ -6080,12 +6082,12 @@ var serviceContext = (function () { quality }, () => { invoke$1(callbackId, { - errMsg: `compressImage:ok`, + errMsg: 'compressImage:ok', tempFilePath: dst }); }, () => { invoke$1(callbackId, { - errMsg: `compressImage:fail` + errMsg: 'compressImage:fail' }); }); } @@ -6137,7 +6139,7 @@ var serviceContext = (function () { let itemList = []; let itemColor = ''; let title = ''; - let hasLongPressActions = longPressActions && longPressActions.callbackId; + const hasLongPressActions = longPressActions && longPressActions.callbackId; if (!hasLongPressActions) { itemList = ['保存相册']; itemColor = '#000000'; @@ -6319,7 +6321,7 @@ var serviceContext = (function () { } }); for (const name in header) { - if (header.hasOwnProperty(name)) { + if (hasOwn(header, name)) { downloader.setRequestHeader(name, header[name]); } } @@ -6368,152 +6370,153 @@ var serviceContext = (function () { return createDownloadTaskById(++downloadTaskId, args) } - let requestTaskId = 0; - const requestTasks = {}; - - const publishStateChange$1 = res => { - publish('onRequestTaskStateChange', res); - delete requestTasks[requestTaskId]; - }; - - function createRequestTaskById (requestTaskId, { - url, - data, - header, - method = 'GET', - responseType, - sslVerify = true - } = {}) { - const stream = requireNativePlugin('stream'); - const headers = {}; - - let abortTimeout; - let aborted; - let hasContentType = false; - for (const name in header) { - if (!hasContentType && name.toLowerCase() === 'content-type') { - hasContentType = true; - headers['Content-Type'] = header[name]; - // TODO 需要重构 - if (method !== 'GET' && header[name].indexOf('application/x-www-form-urlencoded') === 0 && typeof data !== 'string' && !(data instanceof ArrayBuffer)) { - let bodyArray = []; - for (let key in data) { - if (data.hasOwnProperty(key)) { - bodyArray.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); - } - } - data = bodyArray.join('&'); - } - } else { - headers[name] = header[name]; - } - } - - if (!hasContentType && method === 'POST') { - headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; - } - - const timeout = __uniConfig.networkTimeout.request; - if (timeout) { - abortTimeout = setTimeout(() => { - aborted = true; - publishStateChange$1({ - requestTaskId, - state: 'fail', - statusCode: 0, - errMsg: 'timeout' - }); - }, (timeout + 200));// TODO +200 发消息到原生层有时间开销,以后考虑由原生层回调超时 - } - const options = { - method, - url: url.trim(), - // weex 官方文档有误,headers 类型实际 object,用 string 类型会无响应 - headers, - type: responseType === 'arraybuffer' ? 'base64' : 'text', - // weex 官方文档未说明实际支持 timeout,单位:ms - timeout: timeout || 6e5, - // 配置和weex模块内相反 - sslVerify: !sslVerify - }; - if (method !== 'GET') { - options.body = data; - } - try { - stream.fetch(options, ({ - ok, - status, - data, - headers - }) => { - if (aborted) { - return - } - if (abortTimeout) { - clearTimeout(abortTimeout); - } - const statusCode = status; - if (statusCode > 0) { - publishStateChange$1({ - requestTaskId, - state: 'success', - data: ok && responseType === 'arraybuffer' ? base64ToArrayBuffer$2(data) : data, - statusCode, - header: headers - }); - } else { - publishStateChange$1({ - requestTaskId, - state: 'fail', - statusCode, - errMsg: 'abort statusCode:' + statusCode - }); - } - }); - requestTasks[requestTaskId] = { - abort () { - aborted = true; - if (abortTimeout) { - clearTimeout(abortTimeout); - } - publishStateChange$1({ - requestTaskId, - state: 'fail', - statusCode: 0, - errMsg: 'abort' - }); - } - }; - } catch (e) { - return { - requestTaskId, - errMsg: 'createRequestTask:fail' - } - } - return { - requestTaskId, - errMsg: 'createRequestTask:ok' - } - } - - function createRequestTask (args) { - return createRequestTaskById(++requestTaskId, args) - } - - function operateRequestTask ({ - requestTaskId, - operationType - } = {}) { - const requestTask = requestTasks[requestTaskId]; - if (requestTask && operationType === 'abort') { - requestTask.abort(); - return { - errMsg: 'operateRequestTask:ok' - } - } - return { - errMsg: 'operateRequestTask:fail' - } + let requestTaskId = 0; + const requestTasks = {}; + + const publishStateChange$1 = res => { + publish('onRequestTaskStateChange', res); + delete requestTasks[requestTaskId]; + }; + + function createRequestTaskById (requestTaskId, { + url, + data, + header, + method = 'GET', + responseType, + sslVerify = true + } = {}) { + const stream = requireNativePlugin('stream'); + const headers = {}; + + let abortTimeout; + let aborted; + let hasContentType = false; + for (const name in header) { + if (!hasContentType && name.toLowerCase() === 'content-type') { + hasContentType = true; + headers['Content-Type'] = header[name]; + // TODO 需要重构 + if (method !== 'GET' && header[name].indexOf('application/x-www-form-urlencoded') === 0 && typeof data !== + 'string' && !(data instanceof ArrayBuffer)) { + const bodyArray = []; + for (const key in data) { + if (hasOwn(data, key)) { + bodyArray.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); + } + } + data = bodyArray.join('&'); + } + } else { + headers[name] = header[name]; + } + } + + if (!hasContentType && method === 'POST') { + headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; + } + + const timeout = __uniConfig.networkTimeout.request; + if (timeout) { + abortTimeout = setTimeout(() => { + aborted = true; + publishStateChange$1({ + requestTaskId, + state: 'fail', + statusCode: 0, + errMsg: 'timeout' + }); + }, (timeout + 200)); // TODO +200 发消息到原生层有时间开销,以后考虑由原生层回调超时 + } + const options = { + method, + url: url.trim(), + // weex 官方文档有误,headers 类型实际 object,用 string 类型会无响应 + headers, + type: responseType === 'arraybuffer' ? 'base64' : 'text', + // weex 官方文档未说明实际支持 timeout,单位:ms + timeout: timeout || 6e5, + // 配置和weex模块内相反 + sslVerify: !sslVerify + }; + if (method !== 'GET') { + options.body = data; + } + try { + stream.fetch(options, ({ + ok, + status, + data, + headers + }) => { + if (aborted) { + return + } + if (abortTimeout) { + clearTimeout(abortTimeout); + } + const statusCode = status; + if (statusCode > 0) { + publishStateChange$1({ + requestTaskId, + state: 'success', + data: ok && responseType === 'arraybuffer' ? base64ToArrayBuffer$2(data) : data, + statusCode, + header: headers + }); + } else { + publishStateChange$1({ + requestTaskId, + state: 'fail', + statusCode, + errMsg: 'abort statusCode:' + statusCode + }); + } + }); + requestTasks[requestTaskId] = { + abort () { + aborted = true; + if (abortTimeout) { + clearTimeout(abortTimeout); + } + publishStateChange$1({ + requestTaskId, + state: 'fail', + statusCode: 0, + errMsg: 'abort' + }); + } + }; + } catch (e) { + return { + requestTaskId, + errMsg: 'createRequestTask:fail' + } + } + return { + requestTaskId, + errMsg: 'createRequestTask:ok' + } + } + + function createRequestTask (args) { + return createRequestTaskById(++requestTaskId, args) + } + + function operateRequestTask ({ + requestTaskId, + operationType + } = {}) { + const requestTask = requestTasks[requestTaskId]; + if (requestTask && operationType === 'abort') { + requestTask.abort(); + return { + errMsg: 'operateRequestTask:ok' + } + } + return { + errMsg: 'operateRequestTask:fail' + } } const socketTasks = {}; @@ -6668,12 +6671,12 @@ var serviceContext = (function () { }); for (const name in header) { - if (header.hasOwnProperty(name)) { + if (hasOwn(header, name)) { uploader.setRequestHeader(name, header[name]); } } for (const name in formData) { - if (formData.hasOwnProperty(name)) { + if (hasOwn(formData, name)) { uploader.addData(name, String(formData[name])); } } @@ -7033,27 +7036,27 @@ var serviceContext = (function () { // 0:图文,1:纯文字,2:纯图片,3:音乐,4:视频,5:小程序 const TYPES = { - '0': { + 0: { name: 'web', title: '图文' }, - '1': { + 1: { name: 'text', title: '纯文字' }, - '2': { + 2: { name: 'image', title: '纯图片' }, - '3': { + 3: { name: 'music', title: '音乐' }, - '4': { + 4: { name: 'video', title: '视频' }, - '5': { + 5: { name: 'miniProgram', title: '小程序' } @@ -7080,7 +7083,7 @@ var serviceContext = (function () { const shareType = TYPES[type + '']; if (shareType) { - let sendMsg = { + const sendMsg = { provider, type: shareType.name, title, @@ -7236,7 +7239,7 @@ var serviceContext = (function () { } plus.share.sendWithSystem({ type, - pictures: imageUrl ? [imageUrl] : void 0, + pictures: imageUrl && [imageUrl], content, href }, function (res) { @@ -7298,7 +7301,7 @@ var serviceContext = (function () { return } const maskColor = webview.__uniapp_mask; - let maskWebview = webview.__uniapp_mask_id === '0' ? { + const maskWebview = webview.__uniapp_mask_id === '0' ? { setStyle ({ mask }) { @@ -7341,7 +7344,7 @@ var serviceContext = (function () { if (webview && !webview.$processed) { wrapper$1(webview); } - let oldSetStyle = webview.setStyle; + const oldSetStyle = webview.setStyle; var parentWebview = plus.webview.getWebviewById(webview.__uniapp_mask_id); webview.setStyle = function (style) { if (style && style.mask) { @@ -7532,9 +7535,9 @@ var serviceContext = (function () { const titleImage = windowOptions.titleImage || ''; const transparentTitle = windowOptions.transparentTitle || 'none'; const titleNViewTypeList = { - 'none': 'default', - 'auto': 'transparent', - 'always': 'float' + none: 'default', + auto: 'transparent', + always: 'float' }; const ret = { @@ -7544,13 +7547,13 @@ var serviceContext = (function () { type: titleNViewTypeList[transparentTitle], backgroundColor: windowOptions.navigationBarBackgroundColor || '#f8f8f8', tags: titleImage === '' ? [] : [{ - 'tag': 'img', - 'src': titleImage, - 'position': { - 'left': 'auto', - 'top': 'auto', - 'width': 'auto', - 'height': '26px' + tag: 'img', + src: titleImage, + position: { + left: 'auto', + top: 'auto', + width: 'auto', + height: '26px' } }] }; @@ -7947,10 +7950,10 @@ var serviceContext = (function () { let id$1 = 2; const WEBVIEW_LISTENERS = { - 'pullToRefresh': 'onPullDownRefresh', - 'titleNViewSearchInputChanged': 'onNavigationBarSearchInputChanged', - 'titleNViewSearchInputConfirmed': 'onNavigationBarSearchInputConfirmed', - 'titleNViewSearchInputClicked': 'onNavigationBarSearchInputClicked' + pullToRefresh: 'onPullDownRefresh', + titleNViewSearchInputChanged: 'onNavigationBarSearchInputChanged', + titleNViewSearchInputConfirmed: 'onNavigationBarSearchInputConfirmed', + titleNViewSearchInputClicked: 'onNavigationBarSearchInputClicked' }; function setPreloadWebview (webview) { @@ -7990,7 +7993,7 @@ var serviceContext = (function () { ); webviewStyle.uniPageUrl = getUniPageUrl(path, query); if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] createWebview`, webviewId, path, webviewStyle); + console.log('[uni-app] createWebview', webviewId, path, webviewStyle); } return plus.webview.create('', String(webviewId), webviewStyle, { nvue: true @@ -8018,7 +8021,7 @@ var serviceContext = (function () { webviewStyle.debugRefresh = getDebugRefresh(path, query, routeOptions); } if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] updateWebview`, webviewStyle); + console.log('[uni-app] updateWebview', webviewStyle); } webview.setStyle(webviewStyle); @@ -8207,7 +8210,7 @@ var serviceContext = (function () { if (!pageFactory[pagePath]) { console.error(`${pagePath} not found`); } - let startTime = Date.now(); + const startTime = Date.now(); const pageVm = new (getPageVueComponent(pagePath))({ mpType: 'page', pageId, @@ -8301,7 +8304,7 @@ var serviceContext = (function () { this.$vm.$destroy(); } if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] removePage`, path, webview.id); + console.log('[uni-app] removePage', path, webview.id); } } }, @@ -8901,7 +8904,7 @@ var serviceContext = (function () { waiting.close(); } if (~['top', 'center', 'bottom'].indexOf(position)) { - let richText = `${title}`; + const richText = `${title}`; plus.nativeUI.toast(richText, { verticalAlign: position, type: 'richtext' @@ -9238,14 +9241,14 @@ var serviceContext = (function () { } function findAttrs (ids, elm, result) { - let nodes = elm.children; + const nodes = elm.children; if (!Array.isArray(nodes)) { return false } for (let i = 0; i < nodes.length; i++) { - let node = nodes[i]; + const node = nodes[i]; if (node.attr) { - let index = ids.indexOf(node.attr.id); + const index = ids.indexOf(node.attr.id); if (index >= 0) { result[index] = { id: ids[index], @@ -9264,7 +9267,7 @@ var serviceContext = (function () { } function getSelectors (queue) { - let ids = []; + const ids = []; for (let i = 0; i < queue.length; i++) { const selector = queue[i].selector; if (selector.indexOf('#') === 0) { @@ -9293,7 +9296,7 @@ var serviceContext = (function () { // TODO 重构,逻辑不对,queue 里的每一项可能有单独的作用域查找(即 component) const dom = pageVm._$weex.requireModule('dom'); const selectors = getSelectors(queue); - let outAttrs = new Array(selectors.length); + const outAttrs = new Array(selectors.length); findAttrs(selectors, pageVm.$el, outAttrs); getComponentRectAll(dom, outAttrs, 0, [], (result) => { callback(result); @@ -9358,6 +9361,7 @@ var serviceContext = (function () { }); this._loadAd(); } + load () { return new Promise((resolve, reject) => { if (this._isLoad) { @@ -9369,6 +9373,7 @@ var serviceContext = (function () { this._loadAd(); }) } + show () { return new Promise((resolve, reject) => { if (this._isLoad) { @@ -9379,16 +9384,20 @@ var serviceContext = (function () { } }) } + getProvider () { return this._rewardAd.getProvider() } + destroy () { this._rewardAd.destroy(); } + _loadAd () { this._isLoad = false; this._rewardAd.load(); } + _dispatchEvent (name, data) { this._callbacks[name].forEach(callback => { if (typeof callback === 'function') { @@ -9402,8 +9411,6 @@ var serviceContext = (function () { return new RewardedVideoAd(options) } - - var api = /*#__PURE__*/Object.freeze({ __proto__: null, startPullDownRefresh: startPullDownRefresh, @@ -9671,28 +9678,34 @@ var serviceContext = (function () { } Object.defineProperty(this, name, data); }); - } + } + play () { this._operate('play'); - } + } + pause () { this._operate('pause'); - } + } + stop () { this._operate('stop'); - } + } + seek (position) { this._operate('seek', { currentTime: position * 1e3 }); - } + } + destroy () { clearInterval(this.__timing); invokeMethod('destroyAudioInstance', { audioId: this.id }); delete innerAudioContexts[this.id]; - } + } + _operate (type, options) { invokeMethod('operateAudio', Object.assign({}, options, { audioId: this.id, @@ -9871,21 +9884,26 @@ var serviceContext = (function () { } Object.defineProperty(this, name, data); }); - } + } + play () { this._operate('play'); - } + } + pause () { this._operate('pause'); - } + } + stop () { this._operate('stop'); - } + } + seek (position) { this._operate('seek', { currentTime: position }); - } + } + _operate (type, options) { invokeMethod('operateBackgroundAudio', Object.assign({}, options, { operationType: type @@ -9911,863 +9929,906 @@ var serviceContext = (function () { getBackgroundAudioManager: getBackgroundAudioManager }); - const canvasEventCallbacks = createCallbacks('canvasEvent'); - - UniServiceJSBridge.subscribe('onDrawCanvas', ({ - callbackId, - data - }) => { - const callback = canvasEventCallbacks.pop(callbackId); - if (callback) { - callback(data); - } - }); - - UniServiceJSBridge.subscribe('onCanvasMethodCallback', ({ - callbackId, - data - }) => { - const callback = canvasEventCallbacks.pop(callbackId); - if (callback) { - callback(data); - } - }); - - function operateCanvas (canvasId, pageId, type, data) { - UniServiceJSBridge.publishHandler(pageId + '-canvas-' + canvasId, { - canvasId, - type, - data - }, pageId); - } - - const predefinedColor = { - aliceblue: '#f0f8ff', - antiquewhite: '#faebd7', - aqua: '#00ffff', - aquamarine: '#7fffd4', - azure: '#f0ffff', - beige: '#f5f5dc', - bisque: '#ffe4c4', - black: '#000000', - blanchedalmond: '#ffebcd', - blue: '#0000ff', - blueviolet: '#8a2be2', - brown: '#a52a2a', - burlywood: '#deb887', - cadetblue: '#5f9ea0', - chartreuse: '#7fff00', - chocolate: '#d2691e', - coral: '#ff7f50', - cornflowerblue: '#6495ed', - cornsilk: '#fff8dc', - crimson: '#dc143c', - cyan: '#00ffff', - darkblue: '#00008b', - darkcyan: '#008b8b', - darkgoldenrod: '#b8860b', - darkgray: '#a9a9a9', - darkgrey: '#a9a9a9', - darkgreen: '#006400', - darkkhaki: '#bdb76b', - darkmagenta: '#8b008b', - darkolivegreen: '#556b2f', - darkorange: '#ff8c00', - darkorchid: '#9932cc', - darkred: '#8b0000', - darksalmon: '#e9967a', - darkseagreen: '#8fbc8f', - darkslateblue: '#483d8b', - darkslategray: '#2f4f4f', - darkslategrey: '#2f4f4f', - darkturquoise: '#00ced1', - darkviolet: '#9400d3', - deeppink: '#ff1493', - deepskyblue: '#00bfff', - dimgray: '#696969', - dimgrey: '#696969', - dodgerblue: '#1e90ff', - firebrick: '#b22222', - floralwhite: '#fffaf0', - forestgreen: '#228b22', - fuchsia: '#ff00ff', - gainsboro: '#dcdcdc', - ghostwhite: '#f8f8ff', - gold: '#ffd700', - goldenrod: '#daa520', - gray: '#808080', - grey: '#808080', - green: '#008000', - greenyellow: '#adff2f', - honeydew: '#f0fff0', - hotpink: '#ff69b4', - indianred: '#cd5c5c', - indigo: '#4b0082', - ivory: '#fffff0', - khaki: '#f0e68c', - lavender: '#e6e6fa', - lavenderblush: '#fff0f5', - lawngreen: '#7cfc00', - lemonchiffon: '#fffacd', - lightblue: '#add8e6', - lightcoral: '#f08080', - lightcyan: '#e0ffff', - lightgoldenrodyellow: '#fafad2', - lightgray: '#d3d3d3', - lightgrey: '#d3d3d3', - lightgreen: '#90ee90', - lightpink: '#ffb6c1', - lightsalmon: '#ffa07a', - lightseagreen: '#20b2aa', - lightskyblue: '#87cefa', - lightslategray: '#778899', - lightslategrey: '#778899', - lightsteelblue: '#b0c4de', - lightyellow: '#ffffe0', - lime: '#00ff00', - limegreen: '#32cd32', - linen: '#faf0e6', - magenta: '#ff00ff', - maroon: '#800000', - mediumaquamarine: '#66cdaa', - mediumblue: '#0000cd', - mediumorchid: '#ba55d3', - mediumpurple: '#9370db', - mediumseagreen: '#3cb371', - mediumslateblue: '#7b68ee', - mediumspringgreen: '#00fa9a', - mediumturquoise: '#48d1cc', - mediumvioletred: '#c71585', - midnightblue: '#191970', - mintcream: '#f5fffa', - mistyrose: '#ffe4e1', - moccasin: '#ffe4b5', - navajowhite: '#ffdead', - navy: '#000080', - oldlace: '#fdf5e6', - olive: '#808000', - olivedrab: '#6b8e23', - orange: '#ffa500', - orangered: '#ff4500', - orchid: '#da70d6', - palegoldenrod: '#eee8aa', - palegreen: '#98fb98', - paleturquoise: '#afeeee', - palevioletred: '#db7093', - papayawhip: '#ffefd5', - peachpuff: '#ffdab9', - peru: '#cd853f', - pink: '#ffc0cb', - plum: '#dda0dd', - powderblue: '#b0e0e6', - purple: '#800080', - rebeccapurple: '#663399', - red: '#ff0000', - rosybrown: '#bc8f8f', - royalblue: '#4169e1', - saddlebrown: '#8b4513', - salmon: '#fa8072', - sandybrown: '#f4a460', - seagreen: '#2e8b57', - seashell: '#fff5ee', - sienna: '#a0522d', - silver: '#c0c0c0', - skyblue: '#87ceeb', - slateblue: '#6a5acd', - slategray: '#708090', - slategrey: '#708090', - snow: '#fffafa', - springgreen: '#00ff7f', - steelblue: '#4682b4', - tan: '#d2b48c', - teal: '#008080', - thistle: '#d8bfd8', - tomato: '#ff6347', - turquoise: '#40e0d0', - violet: '#ee82ee', - wheat: '#f5deb3', - white: '#ffffff', - whitesmoke: '#f5f5f5', - yellow: '#ffff00', - yellowgreen: '#9acd32', - transparent: '#00000000' - }; - - function checkColor (e) { - // 其他开发者适配的echarts会传入一个undefined到这里 - e = e || '#000000'; - var t = null; - if ((t = /^#([0-9|A-F|a-f]{6})$/.exec(e)) != null) { - let n = parseInt(t[1].slice(0, 2), 16); - let o = parseInt(t[1].slice(2, 4), 16); - let r = parseInt(t[1].slice(4), 16); - return [n, o, r, 255] - } - if ((t = /^#([0-9|A-F|a-f]{3})$/.exec(e)) != null) { - let n = t[1].slice(0, 1); - let o = t[1].slice(1, 2); - let r = t[1].slice(2, 3); - n = parseInt(n + n, 16); - o = parseInt(o + o, 16); - r = parseInt(r + r, 16); - return [n, o, r, 255] - } - if ((t = /^rgb\((.+)\)$/.exec(e)) != null) { - return t[1].split(',').map(function (e) { - return Math.min(255, parseInt(e.trim())) - }).concat(255) - } - if ((t = /^rgba\((.+)\)$/.exec(e)) != null) { - return t[1].split(',').map(function (e, t) { - return t === 3 ? Math.floor(255 * parseFloat(e.trim())) : Math.min(255, parseInt(e.trim())) - }) - } - var i = e.toLowerCase(); - if (predefinedColor.hasOwnProperty(i)) { - t = /^#([0-9|A-F|a-f]{6,8})$/.exec(predefinedColor[i]); - let n = parseInt(t[1].slice(0, 2), 16); - let o = parseInt(t[1].slice(2, 4), 16); - let r = parseInt(t[1].slice(4, 6), 16); - let a = parseInt(t[1].slice(6, 8), 16); - a = a >= 0 ? a : 255; - return [n, o, r, a] - } - console.group('非法颜色: ' + e); - console.error('不支持颜色:' + e); - console.groupEnd(); - return [0, 0, 0, 255] - } - - function Pattern (image, repetition) { - this.image = image; - this.repetition = repetition; - } - - class CanvasGradient { - constructor (type, data) { - this.type = type; - this.data = data; - this.colorStop = []; - } - addColorStop (position, color) { - this.colorStop.push([position, checkColor(color)]); - } - } - var methods1 = ['scale', 'rotate', 'translate', 'setTransform', 'transform']; - var methods2 = ['drawImage', 'fillText', 'fill', 'stroke', 'fillRect', 'strokeRect', 'clearRect', - 'strokeText' - ]; - var methods3 = ['setFillStyle', 'setTextAlign', 'setStrokeStyle', 'setGlobalAlpha', 'setShadow', - 'setFontSize', 'setLineCap', 'setLineJoin', 'setLineWidth', 'setMiterLimit', - 'setTextBaseline', 'setLineDash' - ]; - - var tempCanvas; - function getTempCanvas (width = 0, height = 0) { - if (!tempCanvas) { - tempCanvas = document.createElement('canvas'); - } - tempCanvas.width = width; - tempCanvas.height = height; - return tempCanvas - } - - function TextMetrics (width) { - this.width = width; - } - - class CanvasContext { - constructor (id, pageId) { - this.id = id; - this.pageId = pageId; - this.actions = []; - this.path = []; - this.subpath = []; - this.currentTransform = []; - this.currentStepAnimates = []; - this.drawingState = []; - this.state = { - lineDash: [0, 0], - shadowOffsetX: 0, - shadowOffsetY: 0, - shadowBlur: 0, - shadowColor: [0, 0, 0, 0], - font: '10px sans-serif', - fontSize: 10, - fontWeight: 'normal', - fontStyle: 'normal', - fontFamily: 'sans-serif' - }; - } - draw (reserve = false, callback) { - var actions = [...this.actions]; - this.actions = []; - this.path = []; - var callbackId; - - if (typeof callback === 'function') { - callbackId = canvasEventCallbacks.push(callback); - } - - operateCanvas(this.id, this.pageId, 'actionsChanged', { - actions, - reserve, - callbackId - }); - } - createLinearGradient (x0, y0, x1, y1) { - return new CanvasGradient('linear', [x0, y0, x1, y1]) - } - createCircularGradient (x, y, r) { - return new CanvasGradient('radial', [x, y, r]) - } - createPattern (image, repetition) { - if (undefined === repetition) { - console.error("Failed to execute 'createPattern' on 'CanvasContext': 2 arguments required, but only 1 present."); - } else if (['repeat', 'repeat-x', 'repeat-y', 'no-repeat'].indexOf(repetition) < 0) { - console.error("Failed to execute 'createPattern' on 'CanvasContext': The provided type ('" + repetition + "') is not one of 'repeat', 'no-repeat', 'repeat-x', or 'repeat-y'."); - } else { - return new Pattern(image, repetition) - } - } - // TODO - measureText (text) { - if (typeof document === 'object') { - var c2d = getTempCanvas().getContext('2d'); - c2d.font = this.state.font; - return new TextMetrics(c2d.measureText(text).width || 0) - } else { - return new TextMetrics(0) - } - } - save () { - this.actions.push({ - method: 'save', - data: [] - }); - this.drawingState.push(this.state); - } - restore () { - this.actions.push({ - method: 'restore', - data: [] - }); - this.state = this.drawingState.pop() || { - lineDash: [0, 0], - shadowOffsetX: 0, - shadowOffsetY: 0, - shadowBlur: 0, - shadowColor: [0, 0, 0, 0], - font: '10px sans-serif', - fontSize: 10, - fontWeight: 'normal', - fontStyle: 'normal', - fontFamily: 'sans-serif' - }; - } - beginPath () { - this.path = []; - this.subpath = []; - } - moveTo (x, y) { - this.path.push({ - method: 'moveTo', - data: [x, y] - }); - this.subpath = [ - [x, y] - ]; - } - lineTo (x, y) { - if (this.path.length === 0 && this.subpath.length === 0) { - this.path.push({ - method: 'moveTo', - data: [x, y] - }); - } else { - this.path.push({ - method: 'lineTo', - data: [x, y] - }); - } - this.subpath.push([x, y]); - } - quadraticCurveTo (cpx, cpy, x, y) { - this.path.push({ - method: 'quadraticCurveTo', - data: [cpx, cpy, x, y] - }); - this.subpath.push([x, y]); - } - bezierCurveTo (cp1x, cp1y, cp2x, cp2y, x, y) { - this.path.push({ - method: 'bezierCurveTo', - data: [cp1x, cp1y, cp2x, cp2y, x, y] - }); - this.subpath.push([x, y]); - } - arc (x, y, r, sAngle, eAngle, counterclockwise = false) { - this.path.push({ - method: 'arc', - data: [x, y, r, sAngle, eAngle, counterclockwise] - }); - this.subpath.push([x, y]); - } - rect (x, y, width, height) { - this.path.push({ - method: 'rect', - data: [x, y, width, height] - }); - this.subpath = [ - [x, y] - ]; - } - arcTo (x1, y1, x2, y2, radius) { - this.path.push({ - method: 'arcTo', - data: [x1, y1, x2, y2, radius] - }); - this.subpath.push([x2, y2]); - } - clip () { - this.actions.push({ - method: 'clip', - data: [...this.path] - }); - } - closePath () { - this.path.push({ - method: 'closePath', - data: [] - }); - if (this.subpath.length) { - this.subpath = [this.subpath.shift()]; - } - } - clearActions () { - this.actions = []; - this.path = []; - this.subpath = []; - } - getActions () { - var actions = [...this.actions]; - this.clearActions(); - return actions - } - set lineDashOffset (value) { - this.actions.push({ - method: 'setLineDashOffset', - data: [value] - }); - } - set globalCompositeOperation (type) { - this.actions.push({ - method: 'setGlobalCompositeOperation', - data: [type] - }); - } - set shadowBlur (level) { - this.actions.push({ - method: 'setShadowBlur', - data: [level] - }); - } - set shadowColor (color) { - this.actions.push({ - method: 'setShadowColor', - data: [color] - }); - } - set shadowOffsetX (x) { - this.actions.push({ - method: 'setShadowOffsetX', - data: [x] - }); - } - set shadowOffsetY (y) { - this.actions.push({ - method: 'setShadowOffsetY', - data: [y] - }); - } - set font (value) { - var self = this; - this.state.font = value; - // eslint-disable-next-line - var fontFormat = value.match(/^(([\w\-]+\s)*)(\d+r?px)(\/(\d+\.?\d*(r?px)?))?\s+(.*)/); - if (fontFormat) { - var style = fontFormat[1].trim().split(/\s/); - var fontSize = parseFloat(fontFormat[3]); - var fontFamily = fontFormat[7]; - var actions = []; - style.forEach(function (value, index) { - if (['italic', 'oblique', 'normal'].indexOf(value) > -1) { - actions.push({ - method: 'setFontStyle', - data: [value] - }); - self.state.fontStyle = value; - } else if (['bold', 'normal'].indexOf(value) > -1) { - actions.push({ - method: 'setFontWeight', - data: [value] - }); - self.state.fontWeight = value; - } else if (index === 0) { - actions.push({ - method: 'setFontStyle', - data: ['normal'] - }); - self.state.fontStyle = 'normal'; - } else if (index === 1) { - pushAction(); - } - }); - if (style.length === 1) { - pushAction(); - } - style = actions.map(function (action) { - return action.data[0] - }).join(' '); - this.state.fontSize = fontSize; - this.state.fontFamily = fontFamily; - this.actions.push({ - method: 'setFont', - data: [`${style} ${fontSize}px ${fontFamily}`] - }); - } else { - console.warn("Failed to set 'font' on 'CanvasContext': invalid format."); - } - function pushAction () { - actions.push({ - method: 'setFontWeight', - data: ['normal'] - }); - self.state.fontWeight = 'normal'; - } - } - get font () { - return this.state.font - } - set fillStyle (color) { - this.setFillStyle(color); - } - set strokeStyle (color) { - this.setStrokeStyle(color); - } - set globalAlpha (value) { - value = Math.floor(255 * parseFloat(value)); - this.actions.push({ - method: 'setGlobalAlpha', - data: [value] - }); - } - set textAlign (align) { - this.actions.push({ - method: 'setTextAlign', - data: [align] - }); - } - set lineCap (type) { - this.actions.push({ - method: 'setLineCap', - data: [type] - }); - } - set lineJoin (type) { - this.actions.push({ - method: 'setLineJoin', - data: [type] - }); - } - set lineWidth (value) { - this.actions.push({ - method: 'setLineWidth', - data: [value] - }); - } - set miterLimit (value) { - this.actions.push({ - method: 'setMiterLimit', - data: [value] - }); - } - set textBaseline (type) { - this.actions.push({ - method: 'setTextBaseline', - data: [type] - }); - } - } - - [...methods1, ...methods2].forEach(function (method) { - function get (method) { - switch (method) { - case 'fill': - case 'stroke': - return function () { - this.actions.push({ - method: method + 'Path', - data: [...this.path] - }); - } - case 'fillRect': - return function (x, y, width, height) { - this.actions.push({ - method: 'fillPath', - data: [{ - method: 'rect', - data: [x, y, width, height] - }] - }); - } - case 'strokeRect': - return function (x, y, width, height) { - this.actions.push({ - method: 'strokePath', - data: [{ - method: 'rect', - data: [x, y, width, height] - }] - }); - } - case 'fillText': - case 'strokeText': - return function (text, x, y, maxWidth) { - var data = [text.toString(), x, y]; - if (typeof maxWidth === 'number') { - data.push(maxWidth); - } - this.actions.push({ - method, - data - }); - } - case 'drawImage': - return function (imageResource, dx, dy, dWidth, dHeight, sx, sy, sWidth, sHeight) { - if (sHeight === undefined) { - sx = dx; - sy = dy; - sWidth = dWidth; - sHeight = dHeight; - dx = undefined; - dy = undefined; - dWidth = undefined; - dHeight = undefined; - } - var data; - function isNumber (e) { - return typeof e === 'number' - } - data = isNumber(dx) && isNumber(dy) && isNumber(dWidth) && isNumber(dHeight) ? [imageResource, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight] : isNumber(sWidth) && isNumber( - sHeight) ? [imageResource, sx, sy, sWidth, sHeight] : [imageResource, sx, sy]; - this.actions.push({ - method, - data - }); - } - default: - return function (...data) { - this.actions.push({ - method, - data - }); - } - } - } - CanvasContext.prototype[method] = get(method); - }); - methods3.forEach(function (method) { - function get (method) { - switch (method) { - case 'setFillStyle': - case 'setStrokeStyle': - return function (color) { - if (typeof color !== 'object') { - this.actions.push({ - method, - data: ['normal', checkColor(color)] - }); - } else { - this.actions.push({ - method, - data: [color.type, color.data, color.colorStop] - }); - } - } - case 'setGlobalAlpha': - return function (alpha) { - alpha = Math.floor(255 * parseFloat(alpha)); - this.actions.push({ - method, - data: [alpha] - }); - } - case 'setShadow': - return function (offsetX, offsetY, blur, color) { - color = checkColor(color); - this.actions.push({ - method, - data: [offsetX, offsetY, blur, color] - }); - this.state.shadowBlur = blur; - this.state.shadowColor = color; - this.state.shadowOffsetX = offsetX; - this.state.shadowOffsetY = offsetY; - } - case 'setLineDash': - return function (pattern, offset) { - pattern = pattern || [0, 0]; - offset = offset || 0; - this.actions.push({ - method, - data: [pattern, offset] - }); - this.state.lineDash = pattern; - } - case 'setFontSize': - return function (fontSize) { - this.state.font = this.state.font.replace(/\d+\.?\d*px/, fontSize + 'px'); - this.state.fontSize = fontSize; - this.actions.push({ - method, - data: [fontSize] - }); - } - default: - return function (...data) { - this.actions.push({ - method, - data - }); - } - } - } - CanvasContext.prototype[method] = get(method); - }); - - function createCanvasContext$1 (id, context) { - if (context) { - return new CanvasContext(id, context.$page.id) - } - const pageId = getCurrentPageId(); - if (pageId) { - return new CanvasContext(id, pageId) - } else { - UniServiceJSBridge.emit('onError', 'createCanvasContext:fail'); - } - } - - function canvasGetImageData$1 ({ - canvasId, - x, - y, - width, - height - }, callbackId) { - var pageId = getCurrentPageId(); - if (!pageId) { - invoke$1(callbackId, { - errMsg: 'canvasGetImageData:fail' - }); - return - } - var cId = canvasEventCallbacks.push(function (data) { - var imgData = data.data; - if (imgData && imgData.length) { - data.data = new Uint8ClampedArray(imgData); - } - invoke$1(callbackId, data); - }); - operateCanvas(canvasId, pageId, 'getImageData', { - x, - y, - width, - height, - callbackId: cId - }); - } - - function canvasPutImageData$1 ({ - canvasId, - data, - x, - y, - width, - height - }, callbackId) { - var pageId = getCurrentPageId(); - if (!pageId) { - invoke$1(callbackId, { - errMsg: 'canvasPutImageData:fail' - }); - return - } - var cId = canvasEventCallbacks.push(function (data) { - invoke$1(callbackId, data); - }); - // fix ... - operateCanvas(canvasId, pageId, 'putImageData', { - data: Array.prototype.slice.call(data), - x, - y, - width, - height, - callbackId: cId - }); - } - - function canvasToTempFilePath$1 ({ - x = 0, - y = 0, - width, - height, - destWidth, - destHeight, - canvasId, - fileType, - qualit - }, callbackId) { - var pageId = getCurrentPageId(); - if (!pageId) { - invoke$1(callbackId, { - errMsg: 'canvasToTempFilePath:fail' - }); - return - } - const cId = canvasEventCallbacks.push(function ({ - base64 - }) { - if (!base64 || !base64.length) { - invoke$1(callbackId, { - errMsg: 'canvasToTempFilePath:fail' - }); - } - invokeMethod('base64ToTempFilePath', { - base64Data: base64, - x, - y, - width, - height, - destWidth, - destHeight, - canvasId, - fileType, - qualit - }, callbackId); - }); - operateCanvas(canvasId, pageId, 'getDataUrl', { - x, - y, - width, - height, - destWidth, - destHeight, - hidpi: false, - fileType, - qualit, - callbackId: cId - }); + const canvasEventCallbacks = createCallbacks('canvasEvent'); + + UniServiceJSBridge.subscribe('onDrawCanvas', ({ + callbackId, + data + }) => { + const callback = canvasEventCallbacks.pop(callbackId); + if (callback) { + callback(data); + } + }); + + UniServiceJSBridge.subscribe('onCanvasMethodCallback', ({ + callbackId, + data + }) => { + const callback = canvasEventCallbacks.pop(callbackId); + if (callback) { + callback(data); + } + }); + + function operateCanvas (canvasId, pageId, type, data) { + UniServiceJSBridge.publishHandler(pageId + '-canvas-' + canvasId, { + canvasId, + type, + data + }, pageId); + } + + const predefinedColor = { + aliceblue: '#f0f8ff', + antiquewhite: '#faebd7', + aqua: '#00ffff', + aquamarine: '#7fffd4', + azure: '#f0ffff', + beige: '#f5f5dc', + bisque: '#ffe4c4', + black: '#000000', + blanchedalmond: '#ffebcd', + blue: '#0000ff', + blueviolet: '#8a2be2', + brown: '#a52a2a', + burlywood: '#deb887', + cadetblue: '#5f9ea0', + chartreuse: '#7fff00', + chocolate: '#d2691e', + coral: '#ff7f50', + cornflowerblue: '#6495ed', + cornsilk: '#fff8dc', + crimson: '#dc143c', + cyan: '#00ffff', + darkblue: '#00008b', + darkcyan: '#008b8b', + darkgoldenrod: '#b8860b', + darkgray: '#a9a9a9', + darkgrey: '#a9a9a9', + darkgreen: '#006400', + darkkhaki: '#bdb76b', + darkmagenta: '#8b008b', + darkolivegreen: '#556b2f', + darkorange: '#ff8c00', + darkorchid: '#9932cc', + darkred: '#8b0000', + darksalmon: '#e9967a', + darkseagreen: '#8fbc8f', + darkslateblue: '#483d8b', + darkslategray: '#2f4f4f', + darkslategrey: '#2f4f4f', + darkturquoise: '#00ced1', + darkviolet: '#9400d3', + deeppink: '#ff1493', + deepskyblue: '#00bfff', + dimgray: '#696969', + dimgrey: '#696969', + dodgerblue: '#1e90ff', + firebrick: '#b22222', + floralwhite: '#fffaf0', + forestgreen: '#228b22', + fuchsia: '#ff00ff', + gainsboro: '#dcdcdc', + ghostwhite: '#f8f8ff', + gold: '#ffd700', + goldenrod: '#daa520', + gray: '#808080', + grey: '#808080', + green: '#008000', + greenyellow: '#adff2f', + honeydew: '#f0fff0', + hotpink: '#ff69b4', + indianred: '#cd5c5c', + indigo: '#4b0082', + ivory: '#fffff0', + khaki: '#f0e68c', + lavender: '#e6e6fa', + lavenderblush: '#fff0f5', + lawngreen: '#7cfc00', + lemonchiffon: '#fffacd', + lightblue: '#add8e6', + lightcoral: '#f08080', + lightcyan: '#e0ffff', + lightgoldenrodyellow: '#fafad2', + lightgray: '#d3d3d3', + lightgrey: '#d3d3d3', + lightgreen: '#90ee90', + lightpink: '#ffb6c1', + lightsalmon: '#ffa07a', + lightseagreen: '#20b2aa', + lightskyblue: '#87cefa', + lightslategray: '#778899', + lightslategrey: '#778899', + lightsteelblue: '#b0c4de', + lightyellow: '#ffffe0', + lime: '#00ff00', + limegreen: '#32cd32', + linen: '#faf0e6', + magenta: '#ff00ff', + maroon: '#800000', + mediumaquamarine: '#66cdaa', + mediumblue: '#0000cd', + mediumorchid: '#ba55d3', + mediumpurple: '#9370db', + mediumseagreen: '#3cb371', + mediumslateblue: '#7b68ee', + mediumspringgreen: '#00fa9a', + mediumturquoise: '#48d1cc', + mediumvioletred: '#c71585', + midnightblue: '#191970', + mintcream: '#f5fffa', + mistyrose: '#ffe4e1', + moccasin: '#ffe4b5', + navajowhite: '#ffdead', + navy: '#000080', + oldlace: '#fdf5e6', + olive: '#808000', + olivedrab: '#6b8e23', + orange: '#ffa500', + orangered: '#ff4500', + orchid: '#da70d6', + palegoldenrod: '#eee8aa', + palegreen: '#98fb98', + paleturquoise: '#afeeee', + palevioletred: '#db7093', + papayawhip: '#ffefd5', + peachpuff: '#ffdab9', + peru: '#cd853f', + pink: '#ffc0cb', + plum: '#dda0dd', + powderblue: '#b0e0e6', + purple: '#800080', + rebeccapurple: '#663399', + red: '#ff0000', + rosybrown: '#bc8f8f', + royalblue: '#4169e1', + saddlebrown: '#8b4513', + salmon: '#fa8072', + sandybrown: '#f4a460', + seagreen: '#2e8b57', + seashell: '#fff5ee', + sienna: '#a0522d', + silver: '#c0c0c0', + skyblue: '#87ceeb', + slateblue: '#6a5acd', + slategray: '#708090', + slategrey: '#708090', + snow: '#fffafa', + springgreen: '#00ff7f', + steelblue: '#4682b4', + tan: '#d2b48c', + teal: '#008080', + thistle: '#d8bfd8', + tomato: '#ff6347', + turquoise: '#40e0d0', + violet: '#ee82ee', + wheat: '#f5deb3', + white: '#ffffff', + whitesmoke: '#f5f5f5', + yellow: '#ffff00', + yellowgreen: '#9acd32', + transparent: '#00000000' + }; + + function checkColor (e) { + // 其他开发者适配的echarts会传入一个undefined到这里 + e = e || '#000000'; + var t = null; + if ((t = /^#([0-9|A-F|a-f]{6})$/.exec(e)) != null) { + const n = parseInt(t[1].slice(0, 2), 16); + const o = parseInt(t[1].slice(2, 4), 16); + const r = parseInt(t[1].slice(4), 16); + return [n, o, r, 255] + } + if ((t = /^#([0-9|A-F|a-f]{3})$/.exec(e)) != null) { + let n = t[1].slice(0, 1); + let o = t[1].slice(1, 2); + let r = t[1].slice(2, 3); + n = parseInt(n + n, 16); + o = parseInt(o + o, 16); + r = parseInt(r + r, 16); + return [n, o, r, 255] + } + if ((t = /^rgb\((.+)\)$/.exec(e)) != null) { + return t[1].split(',').map(function (e) { + return Math.min(255, parseInt(e.trim())) + }).concat(255) + } + if ((t = /^rgba\((.+)\)$/.exec(e)) != null) { + return t[1].split(',').map(function (e, t) { + return t === 3 ? Math.floor(255 * parseFloat(e.trim())) : Math.min(255, parseInt(e.trim())) + }) + } + var i = e.toLowerCase(); + if (hasOwn(predefinedColor, i)) { + t = /^#([0-9|A-F|a-f]{6,8})$/.exec(predefinedColor[i]); + const n = parseInt(t[1].slice(0, 2), 16); + const o = parseInt(t[1].slice(2, 4), 16); + const r = parseInt(t[1].slice(4, 6), 16); + let a = parseInt(t[1].slice(6, 8), 16); + a = a >= 0 ? a : 255; + return [n, o, r, a] + } + console.group('非法颜色: ' + e); + console.error('不支持颜色:' + e); + console.groupEnd(); + return [0, 0, 0, 255] + } + + function Pattern (image, repetition) { + this.image = image; + this.repetition = repetition; + } + + class CanvasGradient { + constructor (type, data) { + this.type = type; + this.data = data; + this.colorStop = []; + } + + addColorStop (position, color) { + this.colorStop.push([position, checkColor(color)]); + } + } + var methods1 = ['scale', 'rotate', 'translate', 'setTransform', 'transform']; + var methods2 = ['drawImage', 'fillText', 'fill', 'stroke', 'fillRect', 'strokeRect', 'clearRect', + 'strokeText' + ]; + var methods3 = ['setFillStyle', 'setTextAlign', 'setStrokeStyle', 'setGlobalAlpha', 'setShadow', + 'setFontSize', 'setLineCap', 'setLineJoin', 'setLineWidth', 'setMiterLimit', + 'setTextBaseline', 'setLineDash' + ]; + + var tempCanvas; + + function getTempCanvas (width = 0, height = 0) { + if (!tempCanvas) { + tempCanvas = document.createElement('canvas'); + } + tempCanvas.width = width; + tempCanvas.height = height; + return tempCanvas + } + + function TextMetrics (width) { + this.width = width; + } + + class CanvasContext { + constructor (id, pageId) { + this.id = id; + this.pageId = pageId; + this.actions = []; + this.path = []; + this.subpath = []; + this.currentTransform = []; + this.currentStepAnimates = []; + this.drawingState = []; + this.state = { + lineDash: [0, 0], + shadowOffsetX: 0, + shadowOffsetY: 0, + shadowBlur: 0, + shadowColor: [0, 0, 0, 0], + font: '10px sans-serif', + fontSize: 10, + fontWeight: 'normal', + fontStyle: 'normal', + fontFamily: 'sans-serif' + }; + } + + draw (reserve = false, callback) { + var actions = [...this.actions]; + this.actions = []; + this.path = []; + var callbackId; + + if (typeof callback === 'function') { + callbackId = canvasEventCallbacks.push(callback); + } + + operateCanvas(this.id, this.pageId, 'actionsChanged', { + actions, + reserve, + callbackId + }); + } + + createLinearGradient (x0, y0, x1, y1) { + return new CanvasGradient('linear', [x0, y0, x1, y1]) + } + + createCircularGradient (x, y, r) { + return new CanvasGradient('radial', [x, y, r]) + } + + createPattern (image, repetition) { + if (undefined === repetition) { + console.error("Failed to execute 'createPattern' on 'CanvasContext': 2 arguments required, but only 1 present."); + } else if (['repeat', 'repeat-x', 'repeat-y', 'no-repeat'].indexOf(repetition) < 0) { + console.error("Failed to execute 'createPattern' on 'CanvasContext': The provided type ('" + repetition + + "') is not one of 'repeat', 'no-repeat', 'repeat-x', or 'repeat-y'."); + } else { + return new Pattern(image, repetition) + } + } + + // TODO + measureText (text) { + if (typeof document === 'object') { + var c2d = getTempCanvas().getContext('2d'); + c2d.font = this.state.font; + return new TextMetrics(c2d.measureText(text).width || 0) + } else { + return new TextMetrics(0) + } + } + + save () { + this.actions.push({ + method: 'save', + data: [] + }); + this.drawingState.push(this.state); + } + + restore () { + this.actions.push({ + method: 'restore', + data: [] + }); + this.state = this.drawingState.pop() || { + lineDash: [0, 0], + shadowOffsetX: 0, + shadowOffsetY: 0, + shadowBlur: 0, + shadowColor: [0, 0, 0, 0], + font: '10px sans-serif', + fontSize: 10, + fontWeight: 'normal', + fontStyle: 'normal', + fontFamily: 'sans-serif' + }; + } + + beginPath () { + this.path = []; + this.subpath = []; + } + + moveTo (x, y) { + this.path.push({ + method: 'moveTo', + data: [x, y] + }); + this.subpath = [ + [x, y] + ]; + } + + lineTo (x, y) { + if (this.path.length === 0 && this.subpath.length === 0) { + this.path.push({ + method: 'moveTo', + data: [x, y] + }); + } else { + this.path.push({ + method: 'lineTo', + data: [x, y] + }); + } + this.subpath.push([x, y]); + } + + quadraticCurveTo (cpx, cpy, x, y) { + this.path.push({ + method: 'quadraticCurveTo', + data: [cpx, cpy, x, y] + }); + this.subpath.push([x, y]); + } + + bezierCurveTo (cp1x, cp1y, cp2x, cp2y, x, y) { + this.path.push({ + method: 'bezierCurveTo', + data: [cp1x, cp1y, cp2x, cp2y, x, y] + }); + this.subpath.push([x, y]); + } + + arc (x, y, r, sAngle, eAngle, counterclockwise = false) { + this.path.push({ + method: 'arc', + data: [x, y, r, sAngle, eAngle, counterclockwise] + }); + this.subpath.push([x, y]); + } + + rect (x, y, width, height) { + this.path.push({ + method: 'rect', + data: [x, y, width, height] + }); + this.subpath = [ + [x, y] + ]; + } + + arcTo (x1, y1, x2, y2, radius) { + this.path.push({ + method: 'arcTo', + data: [x1, y1, x2, y2, radius] + }); + this.subpath.push([x2, y2]); + } + + clip () { + this.actions.push({ + method: 'clip', + data: [...this.path] + }); + } + + closePath () { + this.path.push({ + method: 'closePath', + data: [] + }); + if (this.subpath.length) { + this.subpath = [this.subpath.shift()]; + } + } + + clearActions () { + this.actions = []; + this.path = []; + this.subpath = []; + } + + getActions () { + var actions = [...this.actions]; + this.clearActions(); + return actions + } + + set lineDashOffset (value) { + this.actions.push({ + method: 'setLineDashOffset', + data: [value] + }); + } + + set globalCompositeOperation (type) { + this.actions.push({ + method: 'setGlobalCompositeOperation', + data: [type] + }); + } + + set shadowBlur (level) { + this.actions.push({ + method: 'setShadowBlur', + data: [level] + }); + } + + set shadowColor (color) { + this.actions.push({ + method: 'setShadowColor', + data: [color] + }); + } + + set shadowOffsetX (x) { + this.actions.push({ + method: 'setShadowOffsetX', + data: [x] + }); + } + + set shadowOffsetY (y) { + this.actions.push({ + method: 'setShadowOffsetY', + data: [y] + }); + } + + set font (value) { + var self = this; + this.state.font = value; + // eslint-disable-next-line + var fontFormat = value.match(/^(([\w\-]+\s)*)(\d+r?px)(\/(\d+\.?\d*(r?px)?))?\s+(.*)/); + if (fontFormat) { + var style = fontFormat[1].trim().split(/\s/); + var fontSize = parseFloat(fontFormat[3]); + var fontFamily = fontFormat[7]; + var actions = []; + style.forEach(function (value, index) { + if (['italic', 'oblique', 'normal'].indexOf(value) > -1) { + actions.push({ + method: 'setFontStyle', + data: [value] + }); + self.state.fontStyle = value; + } else if (['bold', 'normal'].indexOf(value) > -1) { + actions.push({ + method: 'setFontWeight', + data: [value] + }); + self.state.fontWeight = value; + } else if (index === 0) { + actions.push({ + method: 'setFontStyle', + data: ['normal'] + }); + self.state.fontStyle = 'normal'; + } else if (index === 1) { + pushAction(); + } + }); + if (style.length === 1) { + pushAction(); + } + style = actions.map(function (action) { + return action.data[0] + }).join(' '); + this.state.fontSize = fontSize; + this.state.fontFamily = fontFamily; + this.actions.push({ + method: 'setFont', + data: [`${style} ${fontSize}px ${fontFamily}`] + }); + } else { + console.warn("Failed to set 'font' on 'CanvasContext': invalid format."); + } + + function pushAction () { + actions.push({ + method: 'setFontWeight', + data: ['normal'] + }); + self.state.fontWeight = 'normal'; + } + } + + get font () { + return this.state.font + } + + set fillStyle (color) { + this.setFillStyle(color); + } + + set strokeStyle (color) { + this.setStrokeStyle(color); + } + + set globalAlpha (value) { + value = Math.floor(255 * parseFloat(value)); + this.actions.push({ + method: 'setGlobalAlpha', + data: [value] + }); + } + + set textAlign (align) { + this.actions.push({ + method: 'setTextAlign', + data: [align] + }); + } + + set lineCap (type) { + this.actions.push({ + method: 'setLineCap', + data: [type] + }); + } + + set lineJoin (type) { + this.actions.push({ + method: 'setLineJoin', + data: [type] + }); + } + + set lineWidth (value) { + this.actions.push({ + method: 'setLineWidth', + data: [value] + }); + } + + set miterLimit (value) { + this.actions.push({ + method: 'setMiterLimit', + data: [value] + }); + } + + set textBaseline (type) { + this.actions.push({ + method: 'setTextBaseline', + data: [type] + }); + } + } + + [...methods1, ...methods2].forEach(function (method) { + function get (method) { + switch (method) { + case 'fill': + case 'stroke': + return function () { + this.actions.push({ + method: method + 'Path', + data: [...this.path] + }); + } + case 'fillRect': + return function (x, y, width, height) { + this.actions.push({ + method: 'fillPath', + data: [{ + method: 'rect', + data: [x, y, width, height] + }] + }); + } + case 'strokeRect': + return function (x, y, width, height) { + this.actions.push({ + method: 'strokePath', + data: [{ + method: 'rect', + data: [x, y, width, height] + }] + }); + } + case 'fillText': + case 'strokeText': + return function (text, x, y, maxWidth) { + var data = [text.toString(), x, y]; + if (typeof maxWidth === 'number') { + data.push(maxWidth); + } + this.actions.push({ + method, + data + }); + } + case 'drawImage': + return function (imageResource, dx, dy, dWidth, dHeight, sx, sy, sWidth, sHeight) { + if (sHeight === undefined) { + sx = dx; + sy = dy; + sWidth = dWidth; + sHeight = dHeight; + dx = undefined; + dy = undefined; + dWidth = undefined; + dHeight = undefined; + } + var data; + + function isNumber (e) { + return typeof e === 'number' + } + data = isNumber(dx) && isNumber(dy) && isNumber(dWidth) && isNumber(dHeight) ? [imageResource, sx, sy, + sWidth, sHeight, dx, dy, dWidth, dHeight + ] : isNumber(sWidth) && isNumber( + sHeight) ? [imageResource, sx, sy, sWidth, sHeight] : [imageResource, sx, sy]; + this.actions.push({ + method, + data + }); + } + default: + return function (...data) { + this.actions.push({ + method, + data + }); + } + } + } + CanvasContext.prototype[method] = get(method); + }); + methods3.forEach(function (method) { + function get (method) { + switch (method) { + case 'setFillStyle': + case 'setStrokeStyle': + return function (color) { + if (typeof color !== 'object') { + this.actions.push({ + method, + data: ['normal', checkColor(color)] + }); + } else { + this.actions.push({ + method, + data: [color.type, color.data, color.colorStop] + }); + } + } + case 'setGlobalAlpha': + return function (alpha) { + alpha = Math.floor(255 * parseFloat(alpha)); + this.actions.push({ + method, + data: [alpha] + }); + } + case 'setShadow': + return function (offsetX, offsetY, blur, color) { + color = checkColor(color); + this.actions.push({ + method, + data: [offsetX, offsetY, blur, color] + }); + this.state.shadowBlur = blur; + this.state.shadowColor = color; + this.state.shadowOffsetX = offsetX; + this.state.shadowOffsetY = offsetY; + } + case 'setLineDash': + return function (pattern, offset) { + pattern = pattern || [0, 0]; + offset = offset || 0; + this.actions.push({ + method, + data: [pattern, offset] + }); + this.state.lineDash = pattern; + } + case 'setFontSize': + return function (fontSize) { + this.state.font = this.state.font.replace(/\d+\.?\d*px/, fontSize + 'px'); + this.state.fontSize = fontSize; + this.actions.push({ + method, + data: [fontSize] + }); + } + default: + return function (...data) { + this.actions.push({ + method, + data + }); + } + } + } + CanvasContext.prototype[method] = get(method); + }); + + function createCanvasContext$1 (id, context) { + if (context) { + return new CanvasContext(id, context.$page.id) + } + const pageId = getCurrentPageId(); + if (pageId) { + return new CanvasContext(id, pageId) + } else { + UniServiceJSBridge.emit('onError', 'createCanvasContext:fail'); + } + } + + function canvasGetImageData$1 ({ + canvasId, + x, + y, + width, + height + }, callbackId) { + var pageId = getCurrentPageId(); + if (!pageId) { + invoke$1(callbackId, { + errMsg: 'canvasGetImageData:fail' + }); + return + } + var cId = canvasEventCallbacks.push(function (data) { + var imgData = data.data; + if (imgData && imgData.length) { + data.data = new Uint8ClampedArray(imgData); + } + invoke$1(callbackId, data); + }); + operateCanvas(canvasId, pageId, 'getImageData', { + x, + y, + width, + height, + callbackId: cId + }); + } + + function canvasPutImageData$1 ({ + canvasId, + data, + x, + y, + width, + height + }, callbackId) { + var pageId = getCurrentPageId(); + if (!pageId) { + invoke$1(callbackId, { + errMsg: 'canvasPutImageData:fail' + }); + return + } + var cId = canvasEventCallbacks.push(function (data) { + invoke$1(callbackId, data); + }); + // fix ... + operateCanvas(canvasId, pageId, 'putImageData', { + data: Array.prototype.slice.call(data), + x, + y, + width, + height, + callbackId: cId + }); + } + + function canvasToTempFilePath$1 ({ + x = 0, + y = 0, + width, + height, + destWidth, + destHeight, + canvasId, + fileType, + qualit + }, callbackId) { + var pageId = getCurrentPageId(); + if (!pageId) { + invoke$1(callbackId, { + errMsg: 'canvasToTempFilePath:fail' + }); + return + } + const cId = canvasEventCallbacks.push(function ({ + base64 + }) { + if (!base64 || !base64.length) { + invoke$1(callbackId, { + errMsg: 'canvasToTempFilePath:fail' + }); + } + invokeMethod('base64ToTempFilePath', { + base64Data: base64, + x, + y, + width, + height, + destWidth, + destHeight, + canvasId, + fileType, + qualit + }, callbackId); + }); + operateCanvas(canvasId, pageId, 'getDataUrl', { + x, + y, + width, + height, + destWidth, + destHeight, + hidpi: false, + fileType, + qualit, + callbackId: cId + }); } var require_context_module_1_6 = /*#__PURE__*/Object.freeze({ @@ -10837,21 +10898,26 @@ var serviceContext = (function () { play () { operateVideoPlayer$3(this.id, this.pageVm, 'play'); - } + } + pause () { operateVideoPlayer$3(this.id, this.pageVm, 'pause'); - } + } + stop () { operateVideoPlayer$3(this.id, this.pageVm, 'stop'); - } + } + seek (position) { operateVideoPlayer$3(this.id, this.pageVm, 'seek', { position }); - } + } + sendDanmu (args) { operateVideoPlayer$3(this.id, this.pageVm, 'sendDanmu', args); - } + } + playbackRate (rate) { if (!~RATES.indexOf(rate)) { rate = 1.0; @@ -10859,16 +10925,20 @@ var serviceContext = (function () { operateVideoPlayer$3(this.id, this.pageVm, 'playbackRate', { rate }); - } + } + requestFullScreen (args = {}) { operateVideoPlayer$3(this.id, this.pageVm, 'requestFullScreen', args); - } + } + exitFullScreen () { operateVideoPlayer$3(this.id, this.pageVm, 'exitFullScreen'); - } + } + showStatusBar () { operateVideoPlayer$3(this.id, this.pageVm, 'showStatusBar'); - } + } + hideStatusBar () { operateVideoPlayer$3(this.id, this.pageVm, 'hideStatusBar'); } @@ -10909,6 +10979,7 @@ var serviceContext = (function () { this.id = id; this.pageId = pageId; } + format (name, value) { operateEditor(this.id, this.pageId, 'format', { options: { @@ -11133,45 +11204,57 @@ var serviceContext = (function () { } }); } + onError (callback) { callbacks$a.error = callback; } + onFrameRecorded (callback) { } + onInterruptionBegin (callback) { } + onInterruptionEnd (callback) { } + onPause (callback) { callbacks$a.pause = callback; } + onResume (callback) { callbacks$a.resume = callback; } + onStart (callback) { callbacks$a.start = callback; } + onStop (callback) { callbacks$a.stop = callback; } + pause () { invokeMethod('operateRecorder', { operationType: 'pause' }); } + resume () { invokeMethod('operateRecorder', { operationType: 'resume' }); } + start (options) { invokeMethod('operateRecorder', Object.assign({}, options, { operationType: 'start' })); } + stop () { invokeMethod('operateRecorder', { operationType: 'stop' @@ -11195,28 +11278,33 @@ var serviceContext = (function () { this.id = downloadTaskId; this._callbackId = callbackId; this._callbacks = []; - } + } + abort () { invokeMethod('operateRequestTask', { downloadTaskId: this.id, operationType: 'abort' }); - } + } + onProgressUpdate (callback) { if (typeof callback !== 'function') { return } this._callbacks.push(callback); - } + } + onHeadersReceived () { - } + } + offProgressUpdate (callback) { const index = this._callbacks.indexOf(callback); if (index >= 0) { this._callbacks.splice(index, 1); } - } + } + offHeadersReceived () { } @@ -11409,7 +11497,8 @@ var serviceContext = (function () { this.CONNECTING = 0; this.OPEN = 1; this.readyState = this.CLOSED; - } + } + send (args) { if (this.readyState !== this.OPEN) { this._callback(args, 'sendSocketMessage:fail WebSocket is not connected'); @@ -11421,7 +11510,8 @@ var serviceContext = (function () { socketTaskId: this.id })); this._callback(args, errMsg.replace('operateSocketTask', 'sendSocketMessage')); - } + } + close (args) { this.readyState = this.CLOSING; const { @@ -11431,19 +11521,24 @@ var serviceContext = (function () { socketTaskId: this.id })); this._callback(args, errMsg.replace('operateSocketTask', 'closeSocket')); - } + } + onOpen (callback) { this._callbacks.open.push(callback); - } + } + onClose (callback) { this._callbacks.close.push(callback); - } + } + onError (callback) { this._callbacks.error.push(callback); - } + } + onMessage (callback) { this._callbacks.message.push(callback); - } + } + _callback ({ success, fail, @@ -11581,28 +11676,33 @@ var serviceContext = (function () { this.id = uploadTaskId; this._callbackId = callbackId; this._callbacks = []; - } + } + abort () { invokeMethod('operateRequestTask', { uploadTaskId: this.id, operationType: 'abort' }); - } + } + onProgressUpdate (callback) { if (typeof callback !== 'function') { return } this._callbacks.push(callback); - } + } + onHeadersReceived () { - } + } + offProgressUpdate (callback) { const index = this._callbacks.indexOf(callback); if (index >= 0) { this._callbacks.splice(index, 1); } - } + } + offHeadersReceived () { } @@ -11679,28 +11779,33 @@ var serviceContext = (function () { this.currentStepAnimates = []; this.option = Object.assign({}, defaultOption, option); } + _getOption (option) { - let _option = { + const _option = { transition: Object.assign({}, this.option, option) }; _option.transformOrigin = _option.transition.transformOrigin; delete _option.transition.transformOrigin; return _option } + _pushAnimates (type, args) { this.currentStepAnimates.push({ type: type, args: args }); } + _converType (type) { return type.replace(/[A-Z]/g, text => { return `-${text.toLowerCase()}` }) } + _getValue (value) { return typeof value === 'number' ? `${value}px` : value } + export () { const actions = this.actions; this.actions = []; @@ -11708,6 +11813,7 @@ var serviceContext = (function () { actions } } + step (option) { this.currentStepAnimates.forEach(animate => { if (animate.type !== 'style') { @@ -11761,21 +11867,25 @@ var serviceContext = (function () { this.pageId = component.$page.id; this.component = component._$id || component; // app-plus 平台传输_$id this.options = Object.assign({}, defaultOptions, options); - } + } + _makeRootMargin (margins = {}) { this.options.rootMargin = ['top', 'right', 'bottom', 'left'].map(name => `${Number(margins[name]) || 0}px`).join( ' '); - } + } + relativeTo (selector, margins) { this.options.relativeToSelector = selector; this._makeRootMargin(margins); return this - } + } + relativeToViewport (margins) { this.options.relativeToSelector = null; this._makeRootMargin(margins); return this - } + } + observe (selector, callback) { if (typeof callback !== 'function') { return @@ -11789,7 +11899,8 @@ var serviceContext = (function () { component: this.component, options: this.options }, this.pageId); - } + } + disconnect () { UniServiceJSBridge.publishHandler('destroyComponentObserver', { reqId: this.reqId @@ -12201,7 +12312,7 @@ var serviceContext = (function () { return } if (!page.$page.meta.isNVue) { - const target = page.$vm._$vd.elements.find(target => target.type === 'web-view' && target.events['message']); + const target = page.$vm._$vd.elements.find(target => target.type === 'web-view' && target.events.message); if (!target) { return } @@ -12699,7 +12810,7 @@ var serviceContext = (function () { function registerApp (appVm) { if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] registerApp`); + console.log('[uni-app] registerApp'); } appCtx = appVm; diff --git a/packages/uni-app-plus/dist/view.umd.js b/packages/uni-app-plus/dist/view.umd.js index 83fceef0e1a6d8d4689c23175d4ab6ec6f31422a..b7800ba147290497eb7838b7cac6ffc9cfa672f1 100644 --- a/packages/uni-app-plus/dist/view.umd.js +++ b/packages/uni-app-plus/dist/view.umd.js @@ -173,7 +173,7 @@ function normalizeComponent ( // for template-only hot-reload because in that case the render fn doesn't // go through the normalizer options._injectStyles = hook - // register for functioal component in vue file + // register for functional component in vue file var originalRender = options.render options.render = function renderWithStyleInjection (h, context) { hook.call(context) @@ -201,6 +201,18 @@ function normalizeComponent ( "use strict"; +// EXPORTS +__webpack_require__.d(__webpack_exports__, "h", function() { return /* reexport */ supportsPassive; }); +__webpack_require__.d(__webpack_exports__, "d", function() { return /* reexport */ isFn; }); +__webpack_require__.d(__webpack_exports__, "e", function() { return /* reexport */ isPlainObject; }); +__webpack_require__.d(__webpack_exports__, "c", function() { return /* reexport */ hasOwn; }); +__webpack_require__.d(__webpack_exports__, "a", function() { return /* reexport */ cached; }); +__webpack_require__.d(__webpack_exports__, "f", function() { return /* reexport */ kebabCase; }); +__webpack_require__.d(__webpack_exports__, "b", function() { return /* reexport */ disableScrollBounce; }); +__webpack_require__.d(__webpack_exports__, "g", function() { return /* reexport */ plusReady; }); + +// UNUSED EXPORTS: isStr, isObject, noop, toRawType, camelize, setProperties, getLen, formatDateTime, updateElementStyle, guid, debounce, looseEqual, hexToRgba, parseQuery, stringifyQuery, callback + // CONCATENATED MODULE: ./src/shared/env.js var supportsPassive = false; @@ -216,7 +228,7 @@ try { window.addEventListener('test-passive', null, opts); } catch (e) {} // CONCATENATED MODULE: ./src/shared/util.js -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var _toString = Object.prototype.toString; var util_hasOwnProperty = Object.prototype.hasOwnProperty; @@ -318,6 +330,47 @@ function kebabCase(string) { return '-' + str.toLowerCase(); }); } +/** + * Check if two values are loosely equal - that is, + * if they are plain objects, do they have the same shape? + */ + +function looseEqual(a, b) { + if (a === b) return true; + var isObjectA = isObject(a); + var isObjectB = isObject(b); + + if (isObjectA && isObjectB) { + try { + var isArrayA = Array.isArray(a); + var isArrayB = Array.isArray(b); + + if (isArrayA && isArrayB) { + return a.length === b.length && a.every(function (e, i) { + return looseEqual(e, b[i]); + }); + } else if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime(); + } else if (!isArrayA && !isArrayB) { + var keysA = Object.keys(a); + var keysB = Object.keys(b); + return keysA.length === keysB.length && keysA.every(function (key) { + return looseEqual(a[key], b[key]); + }); + } else { + /* istanbul ignore next */ + return false; + } + } catch (e) { + /* istanbul ignore next */ + return false; + } + } else if (!isObjectA && !isObjectB) { + return String(a) === String(b); + } else { + return false; + } +} // CONCATENATED MODULE: ./src/shared/color.js function hexToRgba(hex) { var r; @@ -449,6 +502,7 @@ function plusReady(callback) { var view; var pullToRefreshStyle; var disabled; +var lastAction = {}; function disableScrollBounce(_ref) { var disable = _ref.disable; @@ -470,6 +524,14 @@ function disableScrollBounce(_ref) { } } + var time = Date.now(); + + if (disable === lastAction.disable && time - lastAction.time < 20) { + return; + } + + lastAction.disable = disable; + lastAction.time = time; plusReady(function () { if (plus.os.name === 'iOS') { // 延迟执行避免iOS13触摸卡死 @@ -524,29 +586,6 @@ var callback = { invoke: invoke }; // CONCATENATED MODULE: ./src/shared/index.js -/* concated harmony reexport supportsPassive */__webpack_require__.d(__webpack_exports__, "h", function() { return supportsPassive; }); -/* concated harmony reexport isFn */__webpack_require__.d(__webpack_exports__, "d", function() { return isFn; }); -/* unused concated harmony import isStr */ -/* unused concated harmony import isObject */ -/* concated harmony reexport isPlainObject */__webpack_require__.d(__webpack_exports__, "e", function() { return isPlainObject; }); -/* concated harmony reexport hasOwn */__webpack_require__.d(__webpack_exports__, "c", function() { return hasOwn; }); -/* unused concated harmony import noop */ -/* unused concated harmony import toRawType */ -/* concated harmony reexport cached */__webpack_require__.d(__webpack_exports__, "a", function() { return cached; }); -/* unused concated harmony import camelize */ -/* unused concated harmony import setProperties */ -/* unused concated harmony import getLen */ -/* unused concated harmony import formatDateTime */ -/* unused concated harmony import updateElementStyle */ -/* unused concated harmony import guid */ -/* unused concated harmony import debounce */ -/* concated harmony reexport kebabCase */__webpack_require__.d(__webpack_exports__, "f", function() { return kebabCase; }); -/* unused concated harmony import hexToRgba */ -/* unused concated harmony import parseQuery */ -/* unused concated harmony import stringifyQuery */ -/* concated harmony reexport disableScrollBounce */__webpack_require__.d(__webpack_exports__, "b", function() { return disableScrollBounce; }); -/* concated harmony reexport plusReady */__webpack_require__.d(__webpack_exports__, "g", function() { return plusReady; }); -/* unused concated harmony import callback */ @@ -561,6 +600,15 @@ var callback = { "use strict"; +// EXPORTS +__webpack_require__.d(__webpack_exports__, "a", function() { return /* reexport */ emitter; }); +__webpack_require__.d(__webpack_exports__, "d", function() { return /* reexport */ listeners["a" /* default */]; }); +__webpack_require__.d(__webpack_exports__, "b", function() { return /* reexport */ hover["a" /* default */]; }); +__webpack_require__.d(__webpack_exports__, "e", function() { return /* reexport */ subscriber["a" /* default */]; }); +__webpack_require__.d(__webpack_exports__, "c", function() { return /* reexport */ keyboard["a" /* default */]; }); + +// UNUSED EXPORTS: interact + // CONCATENATED MODULE: ./src/core/view/mixins/emitter.js // 暂不提供通知所有 // function broadcast (componentName, eventName, ...params) { @@ -708,12 +756,6 @@ function removeInteractListener(vm) { } }); // CONCATENATED MODULE: ./src/core/view/mixins/index.js -/* concated harmony reexport emitter */__webpack_require__.d(__webpack_exports__, "a", function() { return emitter; }); -/* concated harmony reexport listeners */__webpack_require__.d(__webpack_exports__, "d", function() { return listeners["a" /* default */]; }); -/* concated harmony reexport hover */__webpack_require__.d(__webpack_exports__, "b", function() { return hover["a" /* default */]; }); -/* concated harmony reexport subscriber */__webpack_require__.d(__webpack_exports__, "e", function() { return subscriber["a" /* default */]; }); -/* concated harmony reexport keyboard */__webpack_require__.d(__webpack_exports__, "c", function() { return keyboard["a" /* default */]; }); -/* unused concated harmony import interact */ @@ -762,8 +804,19 @@ var WEBVIEW_REMOVED = 'webviewRemoved'; /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +// ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); +// EXPORTS +__webpack_require__.d(__webpack_exports__, "on", function() { return /* binding */ on; }); +__webpack_require__.d(__webpack_exports__, "off", function() { return /* binding */ off; }); +__webpack_require__.d(__webpack_exports__, "once", function() { return /* binding */ once; }); +__webpack_require__.d(__webpack_exports__, "emit", function() { return /* binding */ emit; }); +__webpack_require__.d(__webpack_exports__, "subscribe", function() { return /* binding */ view_bridge_subscribe; }); +__webpack_require__.d(__webpack_exports__, "unsubscribe", function() { return /* binding */ unsubscribe; }); +__webpack_require__.d(__webpack_exports__, "subscribeHandler", function() { return /* binding */ subscribeHandler; }); +__webpack_require__.d(__webpack_exports__, "publishHandler", function() { return /* reexport */ bridge["a" /* publishHandler */]; }); + // EXTERNAL MODULE: ./packages/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js var vue_runtime_esm = __webpack_require__(8); @@ -820,14 +873,6 @@ function initSubscribe(subscribe) { var bridge = __webpack_require__(12); // CONCATENATED MODULE: ./src/core/view/bridge/index.js -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "on", function() { return on; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "off", function() { return off; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "once", function() { return once; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "emit", function() { return emit; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subscribe", function() { return view_bridge_subscribe; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unsubscribe", function() { return unsubscribe; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subscribeHandler", function() { return subscribeHandler; }); -/* concated harmony reexport publishHandler */__webpack_require__.d(__webpack_exports__, "publishHandler", function() { return bridge["a" /* publishHandler */]; }); var Emitter = new vue_runtime_esm["a" /* default */](); @@ -1202,7 +1247,7 @@ function getFixed($el) { /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* WEBPACK VAR INJECTION */(function(global) {function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +/* WEBPACK VAR INJECTION */(function(global) {function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } /*! * Vue.js v2.6.11 @@ -1723,7 +1768,7 @@ function parsePath(path) { // can we use __proto__? -var hasProto = '__proto__' in {}; // Browser environment sniffing +var hasProto = ('__proto__' in {}); // Browser environment sniffing var inBrowser = typeof window !== 'undefined'; var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; @@ -1794,9 +1839,7 @@ if (typeof Set !== 'undefined' && isNative(Set)) { _Set = Set; } else { // a non-standard Set polyfill that only works with primitive keys. - _Set = - /*@__PURE__*/ - function () { + _Set = /*@__PURE__*/function () { function Set() { this.set = Object.create(null); } @@ -3299,7 +3342,7 @@ if (true) { var hasHandler = { has: function has(target, key) { - var has = key in target; + var has = (key in target); var isAllowed = allowedGlobals(key) || typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data); if (!has && !isAllowed) { @@ -6979,9 +7022,7 @@ function setStyleScope(node, scopeId) { node.setAttribute(scopeId, ''); } -var nodeOps = -/*#__PURE__*/ -Object.freeze({ +var nodeOps = /*#__PURE__*/Object.freeze({ createElement: createElement$1, createElementNS: createElementNS, createTextNode: createTextNode, @@ -9995,6 +10036,10 @@ function getWindowOffset() { "use strict"; +// EXPORTS +__webpack_require__.d(__webpack_exports__, "b", function() { return /* binding */ processEvent; }); +__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ initEvents; }); + // EXTERNAL MODULE: ./src/shared/index.js + 7 modules var shared = __webpack_require__(1); @@ -10002,7 +10047,7 @@ var shared = __webpack_require__(1); var helpers = __webpack_require__(6); // CONCATENATED MODULE: ./src/core/helpers/patch.js -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } /** @@ -10065,8 +10110,6 @@ function mergeTitleNView(navigationBar, titleNView) { var get_window_offset = __webpack_require__(10); // CONCATENATED MODULE: ./src/core/view/plugins/events.js -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return processEvent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return initEvents; }); @@ -10430,11 +10473,15 @@ var _handleData; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } -function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } +function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } @@ -10452,7 +10499,8 @@ var handleData = (_handleData = {}, _defineProperty(_handleData, _constants__WEB pagePath = _data[1], pageOptions = _data[2]; - document.title = "".concat(pagePath, "[").concat(pageId, "]"); // 设置当前页面伪对象,方便其他地方使用 getCurrentPages 获取当前页面 id,route + document.title = "".concat(pagePath, "[").concat(pageId, "]"); + updateRootFontSize(); // 设置当前页面伪对象,方便其他地方使用 getCurrentPages 获取当前页面 id,route Object(_page__WEBPACK_IMPORTED_MODULE_4__[/* setCurrentPage */ "b"])(pageId, pagePath); // 通知页面创建,根据当前页面配置信息,初始化部分事件 @@ -10502,7 +10550,24 @@ function updateView() { pageVm && broadcast(pageVm, NATIVE_COMPONENTS, 'uni-view-update'); } -window.addEventListener('resize', updateView); +function updateRootFontSize() { + // 页面存在横竖屏切换时,预加载的 webview 的 fontSize 需要再次校正一下 + var oldFontSize = document.documentElement.style.fontSize; + var newFontSize = document.documentElement.clientWidth / 20 + 'px'; + + if (oldFontSize !== newFontSize) { + document.documentElement.style.fontSize = newFontSize; + } +} + +window.addEventListener('resize', function () { + // TODO 与之前逻辑保持一致,仅当前 webview 未被使用时,校准 fontSize,后续考虑动态旋转,调整rootfontSize + if (!getCurrentPages().length) { + updateRootFontSize(); + } + + updateView(); +}); window.addEventListener('updateview', updateView); function vdSync(_ref) { @@ -10582,6 +10647,8 @@ function initData(Vue) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return pixelRatio; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return wrapper; }); +/* harmony import */ var uni_shared__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1); + var pixelRatio = function () { var canvas = document.createElement('canvas'); canvas.height = canvas.width = 0; @@ -10592,29 +10659,29 @@ var pixelRatio = function () { var forEach = function forEach(obj, func) { for (var key in obj) { - if (obj.hasOwnProperty(key)) { + if (Object(uni_shared__WEBPACK_IMPORTED_MODULE_0__[/* hasOwn */ "c"])(obj, key)) { func(obj[key], key); } } }; var ratioArgs = { - 'fillRect': 'all', - 'clearRect': 'all', - 'strokeRect': 'all', - 'moveTo': 'all', - 'lineTo': 'all', - 'arc': [0, 1, 2], - 'arcTo': 'all', - 'bezierCurveTo': 'all', - 'isPointinPath': 'all', - 'isPointinStroke': 'all', - 'quadraticCurveTo': 'all', - 'rect': 'all', - 'translate': 'all', - 'createRadialGradient': 'all', - 'createLinearGradient': 'all', - 'setTransform': [4, 5] + fillRect: 'all', + clearRect: 'all', + strokeRect: 'all', + moveTo: 'all', + lineTo: 'all', + arc: [0, 1, 2], + arcTo: 'all', + bezierCurveTo: 'all', + isPointinPath: 'all', + isPointinStroke: 'all', + quadraticCurveTo: 'all', + rect: 'all', + translate: 'all', + createRadialGradient: 'all', + createLinearGradient: 'all', + setTransform: [4, 5] }; var proto = CanvasRenderingContext2D.prototype; @@ -10867,14 +10934,21 @@ module.exports = g; "use strict"; /* WEBPACK VAR INJECTION */(function(UniViewJSBridge) {/* harmony import */ var uni_mixins__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); /* harmony import */ var uni_helpers_hidpi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15); -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +// +// +// // // // @@ -11389,8 +11463,9 @@ function getTempCanvas() { } if (!callbackId) { + // fix [...]展开TypedArray在低版本手机报错的问题,使用Array.prototype.slice return { - data: _toConsumableArray(imgData.data), + data: Array.prototype.slice.call(imgData.data), width: destWidth, height: destHeight }; @@ -11559,7 +11634,7 @@ function getTempCanvas() { /* WEBPACK VAR INJECTION */(function(UniViewJSBridge) {/* harmony import */ var uni_mixins__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); /* harmony import */ var uni_helpers_html_parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(60); /* harmony import */ var _formats__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(83); -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } // // @@ -11568,6 +11643,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat // // // +// @@ -11665,43 +11741,45 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat if (this.quillReady) { switch (type) { case 'format': - var _options$name = options.name, - name = _options$name === void 0 ? '' : _options$name, - _options$value = options.value, - value = _options$value === void 0 ? false : _options$value; - range = quill.getSelection(true); - var format = quill.getFormat(range)[name] || false; - - if (['bold', 'italic', 'underline', 'strike', 'ins'].includes(name)) { - value = !format; - } else if (name === 'direction') { - value = value === 'rtl' && format ? false : value; - var align = quill.getFormat(range).align; - - if (value === 'rtl' && !align) { - quill.format('align', 'right', Quill.sources.USER); - } else if (!value && align === 'right') { - quill.format('align', false, Quill.sources.USER); - } - } else if (name === 'indent') { - var rtl = quill.getFormat(range).direction === 'rtl'; - value = value === '+1'; + { + var _options$name = options.name, + name = _options$name === void 0 ? '' : _options$name, + _options$value = options.value, + value = _options$value === void 0 ? false : _options$value; + range = quill.getSelection(true); + var format = quill.getFormat(range)[name] || false; + + if (['bold', 'italic', 'underline', 'strike', 'ins'].includes(name)) { + value = !format; + } else if (name === 'direction') { + value = value === 'rtl' && format ? false : value; + var align = quill.getFormat(range).align; + + if (value === 'rtl' && !align) { + quill.format('align', 'right', Quill.sources.USER); + } else if (!value && align === 'right') { + quill.format('align', false, Quill.sources.USER); + } + } else if (name === 'indent') { + var rtl = quill.getFormat(range).direction === 'rtl'; + value = value === '+1'; - if (rtl) { - value = !value; - } + if (rtl) { + value = !value; + } - value = value ? '+1' : '-1'; - } else { - if (name === 'list') { - value = value === 'check' ? 'unchecked' : value; - format = format === 'checked' ? 'unchecked' : format; + value = value ? '+1' : '-1'; + } else { + if (name === 'list') { + value = value === 'check' ? 'unchecked' : value; + format = format === 'checked' ? 'unchecked' : format; + } + + value = format && format !== (value || false) || !format && value ? value : !format; } - value = format && format !== (value || false) || !format && value ? value : !format; + quill.format(name, value, Quill.sources.USER); } - - quill.format(name, value, Quill.sources.USER); break; case 'insertDivider': @@ -11712,43 +11790,48 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat break; case 'insertImage': - range = quill.getSelection(true); - - var _options$src = options.src, - src = _options$src === void 0 ? '' : _options$src, - _options$alt = options.alt, - alt = _options$alt === void 0 ? '' : _options$alt, - _options$data = options.data, - _data = _options$data === void 0 ? {} : _options$data; - - quill.insertEmbed(range.index, 'image', this.$getRealPath(src), Quill.sources.USER); - quill.formatText(range.index, 1, 'alt', alt); - quill.formatText(range.index, 1, 'data-custom', Object.keys(_data).map(function (key) { - return "".concat(key, "=").concat(_data[key]); - }).join('&')); - quill.setSelection(range.index + 1, Quill.sources.SILENT); + { + range = quill.getSelection(true); + + var _options$src = options.src, + src = _options$src === void 0 ? '' : _options$src, + _options$alt = options.alt, + alt = _options$alt === void 0 ? '' : _options$alt, + _options$data = options.data, + _data = _options$data === void 0 ? {} : _options$data; + + quill.insertEmbed(range.index, 'image', this.$getRealPath(src), Quill.sources.USER); + quill.formatText(range.index, 1, 'alt', alt); + quill.formatText(range.index, 1, 'data-custom', Object.keys(_data).map(function (key) { + return "".concat(key, "=").concat(_data[key]); + }).join('&')); + quill.setSelection(range.index + 1, Quill.sources.SILENT); + } break; case 'insertText': - range = quill.getSelection(true); - var _options$text = options.text, - text = _options$text === void 0 ? '' : _options$text; - quill.insertText(range.index, text, Quill.sources.USER); - quill.setSelection(range.index + text.length, 0, Quill.sources.SILENT); + { + range = quill.getSelection(true); + var _options$text = options.text, + text = _options$text === void 0 ? '' : _options$text; + quill.insertText(range.index, text, Quill.sources.USER); + quill.setSelection(range.index + text.length, 0, Quill.sources.SILENT); + } break; case 'setContents': - var delta = options.delta, - html = options.html; + { + var delta = options.delta, + html = options.html; - if (_typeof(delta) === 'object') { - quill.setContents(delta, Quill.sources.SILENT); - } else if (typeof html === 'string') { - quill.setContents(this.html2delta(html), Quill.sources.SILENT); - } else { - errMsg = 'contents is missing'; + if (_typeof(delta) === 'object') { + quill.setContents(delta, Quill.sources.SILENT); + } else if (typeof html === 'string') { + quill.setContents(this.html2delta(html), Quill.sources.SILENT); + } else { + errMsg = 'contents is missing'; + } } - break; case 'getContents': @@ -11760,19 +11843,20 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat break; case 'removeFormat': - range = quill.getSelection(true); - var parchment = Quill.import('parchment'); + { + range = quill.getSelection(true); + var parchment = Quill.import('parchment'); - if (range.length) { - quill.removeFormat(range, Quill.sources.USER); - } else { - Object.keys(quill.getFormat(range)).forEach(function (key) { - if (parchment.query(key, parchment.Scope.INLINE)) { - quill.format(key, false); - } - }); + if (range.length) { + quill.removeFormat(range, Quill.sources.USER); + } else { + Object.keys(quill.getFormat(range)).forEach(function (key) { + if (parchment.query(key, parchment.Scope.INLINE)) { + quill.format(key, false); + } + }); + } } - break; case 'undo': @@ -12000,6 +12084,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat // // // +// /* harmony default export */ __webpack_exports__["a"] = ({ name: 'Label', @@ -12229,6 +12314,8 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat // // // +// +// var methods = ['getCenterLocation', 'moveToLocation', 'getRegion', 'getScale', '$getAppMap']; // const events = [ @@ -12858,7 +12945,7 @@ function findVmById(id, vm) { function findElm(component, pageVm) { if (!pageVm) { - return console.error("page is not ready"); + return console.error('page is not ready'); } if (!component) { @@ -14277,6 +14364,9 @@ Scroller.prototype.isScrolling = function () { "use strict"; +// EXPORTS +__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ getRealPath; }); + // CONCATENATED MODULE: ./src/core/helpers/get-real-route.js function getRealRoute(fromRoute, toRoute) { if (!toRoute) { @@ -14317,7 +14407,6 @@ function getRealRoute(fromRoute, toRoute) { return '/' + fromRouteArray.concat(toRouteArray).join('/'); } // CONCATENATED MODULE: ./src/platforms/app-plus/helpers/get-real-path.js -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getRealPath; }); var SCHEME_RE = /^([a-z-]+:)?\/\//i; var DATA_RE = /^data:.*,.*/; // 处理 Android 平台解压与非解压模式下获取的路径不一致的情况 @@ -14915,6 +15004,16 @@ function switchTab(args) { "use strict"; +// EXPORTS +__webpack_require__.d(__webpack_exports__, "h", function() { return /* reexport */ upx2px; }); +__webpack_require__.d(__webpack_exports__, "d", function() { return /* reexport */ api["b" /* navigateTo */]; }); +__webpack_require__.d(__webpack_exports__, "c", function() { return /* reexport */ api["a" /* navigateBack */]; }); +__webpack_require__.d(__webpack_exports__, "e", function() { return /* reexport */ api["c" /* reLaunch */]; }); +__webpack_require__.d(__webpack_exports__, "f", function() { return /* reexport */ api["d" /* redirectTo */]; }); +__webpack_require__.d(__webpack_exports__, "g", function() { return /* reexport */ api["e" /* switchTab */]; }); +__webpack_require__.d(__webpack_exports__, "b", function() { return /* reexport */ getSystemInfoSync; }); +__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ canIUse; }); + // CONCATENATED MODULE: ./src/core/service/api/base/upx2px.js var EPS = 1e-4; var BASE_DEVICE_WIDTH = 750; @@ -15104,14 +15203,6 @@ function getSystemInfo() { return getSystemInfoSync(); } // CONCATENATED MODULE: ./lib/app-plus/view-api.js -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return canIUse; }); -/* concated harmony reexport upx2px */__webpack_require__.d(__webpack_exports__, "h", function() { return upx2px; }); -/* concated harmony reexport navigateTo */__webpack_require__.d(__webpack_exports__, "d", function() { return api["b" /* navigateTo */]; }); -/* concated harmony reexport navigateBack */__webpack_require__.d(__webpack_exports__, "c", function() { return api["a" /* navigateBack */]; }); -/* concated harmony reexport reLaunch */__webpack_require__.d(__webpack_exports__, "e", function() { return api["c" /* reLaunch */]; }); -/* concated harmony reexport redirectTo */__webpack_require__.d(__webpack_exports__, "f", function() { return api["d" /* redirectTo */]; }); -/* concated harmony reexport switchTab */__webpack_require__.d(__webpack_exports__, "g", function() { return api["e" /* switchTab */]; }); -/* concated harmony reexport getSystemInfoSync */__webpack_require__.d(__webpack_exports__, "b", function() { return getSystemInfoSync; }); @@ -15314,7 +15405,7 @@ function loadFontFace(_ref) { UniViewJSBridge.publishHandler('onLoadFontFaceCallback', { callbackId: callbackId, data: { - errMsg: "loadFontFace:ok" + errMsg: 'loadFontFace:ok' } }); }).catch(function (error) { @@ -15332,7 +15423,7 @@ function loadFontFace(_ref) { UniViewJSBridge.publishHandler('onLoadFontFaceCallback', { callbackId: callbackId, data: { - errMsg: "loadFontFace:ok" + errMsg: 'loadFontFace:ok' } }); } @@ -15571,9 +15662,7 @@ function parseStyleText(cssText) { return res; } -var ComponentDescriptor = -/*#__PURE__*/ -function () { +var ComponentDescriptor = /*#__PURE__*/function () { function ComponentDescriptor(vm) { _classCallCheck(this, ComponentDescriptor); @@ -15757,11 +15846,15 @@ function createComponentDescriptor(vm) { /* WEBPACK VAR INJECTION */(function(UniViewJSBridge) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return VDomSync; }); /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3); /* harmony import */ var _helpers_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(81); -function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } -function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } +function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } @@ -15786,9 +15879,7 @@ function findParent(vm) { } } -var VDomSync = -/*#__PURE__*/ -function () { +var VDomSync = /*#__PURE__*/function () { function VDomSync(pageId) { _classCallCheck(this, VDomSync); @@ -15923,7 +16014,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var plus_; var weex_; @@ -15974,9 +16065,7 @@ function addEventListener(pageId, callback) { callbacks[pageId] = callback; } -var Page = -/*#__PURE__*/ -function () { +var Page = /*#__PURE__*/function () { function Page(webview) { _classCallCheck(this, Page); @@ -16082,33 +16171,40 @@ function showPage(_ref) { "use strict"; +// EXPORTS +__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ register; }); + // CONCATENATED MODULE: ./src/core/view/components/editor/formats/divider.js -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /* harmony default export */ var divider = (function (Quill) { var BlockEmbed = Quill.import('blots/block/embed'); - var Divider = - /*#__PURE__*/ - function (_BlockEmbed) { + var Divider = /*#__PURE__*/function (_BlockEmbed) { _inherits(Divider, _BlockEmbed); + var _super = _createSuper(Divider); + function Divider() { _classCallCheck(this, Divider); - return _possibleConstructorReturn(this, _getPrototypeOf(Divider).apply(this, arguments)); + return _super.apply(this, arguments); } return Divider; @@ -16121,32 +16217,36 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func }; }); // CONCATENATED MODULE: ./src/core/view/components/editor/formats/ins.js -function ins_typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { ins_typeof = function _typeof(obj) { return typeof obj; }; } else { ins_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return ins_typeof(obj); } +function ins_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { ins_typeof = function _typeof(obj) { return typeof obj; }; } else { ins_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return ins_typeof(obj); } function ins_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function ins_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) ins_setPrototypeOf(subClass, superClass); } + +function ins_setPrototypeOf(o, p) { ins_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return ins_setPrototypeOf(o, p); } + +function ins_createSuper(Derived) { return function () { var Super = ins_getPrototypeOf(Derived), result; if (ins_isNativeReflectConstruct()) { var NewTarget = ins_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return ins_possibleConstructorReturn(this, result); }; } + function ins_possibleConstructorReturn(self, call) { if (call && (ins_typeof(call) === "object" || typeof call === "function")) { return call; } return ins_assertThisInitialized(self); } function ins_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function ins_getPrototypeOf(o) { ins_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return ins_getPrototypeOf(o); } +function ins_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } -function ins_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) ins_setPrototypeOf(subClass, superClass); } - -function ins_setPrototypeOf(o, p) { ins_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return ins_setPrototypeOf(o, p); } +function ins_getPrototypeOf(o) { ins_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return ins_getPrototypeOf(o); } /* harmony default export */ var ins = (function (Quill) { var Inline = Quill.import('blots/inline'); - var Ins = - /*#__PURE__*/ - function (_Inline) { + var Ins = /*#__PURE__*/function (_Inline) { ins_inherits(Ins, _Inline); + var _super = ins_createSuper(Ins); + function Ins() { ins_classCallCheck(this, Ins); - return ins_possibleConstructorReturn(this, ins_getPrototypeOf(Ins).apply(this, arguments)); + return _super.apply(this, arguments); } return Ins; @@ -16189,16 +16289,12 @@ function ins_setPrototypeOf(o, p) { ins_setPrototypeOf = Object.setPrototypeOf | }; }); // CONCATENATED MODULE: ./src/core/view/components/editor/formats/list.js -function list_typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { list_typeof = function _typeof(obj) { return typeof obj; }; } else { list_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return list_typeof(obj); } +function list_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { list_typeof = function _typeof(obj) { return typeof obj; }; } else { list_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return list_typeof(obj); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function list_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function list_possibleConstructorReturn(self, call) { if (call && (list_typeof(call) === "object" || typeof call === "function")) { return call; } return list_assertThisInitialized(self); } - -function list_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } @@ -16207,6 +16303,14 @@ function list_inherits(subClass, superClass) { if (typeof superClass !== "functi function list_setPrototypeOf(o, p) { list_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return list_setPrototypeOf(o, p); } +function list_createSuper(Derived) { return function () { var Super = list_getPrototypeOf(Derived), result; if (list_isNativeReflectConstruct()) { var NewTarget = list_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return list_possibleConstructorReturn(this, result); }; } + +function list_possibleConstructorReturn(self, call) { if (call && (list_typeof(call) === "object" || typeof call === "function")) { return call; } return list_assertThisInitialized(self); } + +function list_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function list_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); } function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = list_getPrototypeOf(object); if (object === null) break; } return object; } @@ -16218,11 +16322,11 @@ function list_getPrototypeOf(o) { list_getPrototypeOf = Object.setPrototypeOf ? var Container = Quill.import('blots/container'); var ListItem = Quill.import('formats/list/item'); - var List = - /*#__PURE__*/ - function (_Container) { + var List = /*#__PURE__*/function (_Container) { list_inherits(List, _Container); + var _super = list_createSuper(List); + _createClass(List, null, [{ key: "create", value: function create(value) { @@ -16258,7 +16362,7 @@ function list_getPrototypeOf(o) { list_getPrototypeOf = Object.setPrototypeOf ? list_classCallCheck(this, List); - _this = list_possibleConstructorReturn(this, list_getPrototypeOf(List).call(this, domNode)); + _this = _super.call(this, domNode); var listEventHandler = function listEventHandler(e) { if (e.target.parentNode !== domNode) return; @@ -16429,7 +16533,6 @@ var shared = __webpack_require__(1); }; }); // CONCATENATED MODULE: ./src/core/view/components/editor/formats/index.js -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return register; }); @@ -16595,6 +16698,9 @@ function initEvent(Vue) { "use strict"; +// EXPORTS +__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ initBehaviors; }); + // EXTERNAL MODULE: ./src/shared/index.js + 7 modules var shared = __webpack_require__(1); @@ -16686,15 +16792,14 @@ function beforeDestroy() { Object.assign(vm.constructor.options.methods, mixins["a" /* emitter */].methods); Object.assign(options.methods, mixins["a" /* emitter */].methods); - var createdHooks = options['created']; - vm.constructor.options['created'] = options['created'] = createdHooks ? [].concat(created, createdHooks) : [created]; - var beforeDestroyHooks = options['beforeDestroy']; - vm.constructor.options['beforeDestroy'] = options['beforeDestroy'] = beforeDestroyHooks ? [].concat(beforeDestroy, beforeDestroyHooks) : [beforeDestroy]; + var createdHooks = options.created; + vm.constructor.options.created = options.created = createdHooks ? [].concat(created, createdHooks) : [created]; + var beforeDestroyHooks = options.beforeDestroy; + vm.constructor.options.beforeDestroy = options.beforeDestroy = beforeDestroyHooks ? [].concat(beforeDestroy, beforeDestroyHooks) : [beforeDestroy]; } } }); // CONCATENATED MODULE: ./src/core/view/plugins/behaviors/index.js -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return initBehaviors; }); function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } @@ -16710,44 +16815,79 @@ function initBehaviors(options, vm) { /***/ }), /* 86 */ -/***/ (function(module, exports) { - -// document.currentScript polyfill by Adam Miller +/***/ (function(module, exports, __webpack_require__) { +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// addapted from the document.currentScript polyfill by Adam Miller // MIT license +// source: https://github.com/amiller-gh/currentScript-polyfill -(function(document){ - var currentScript = "currentScript", - scripts = document.getElementsByTagName('script'); // Live NodeList collection - - // If browser needs currentScript polyfill, add get currentScript() to the document object - if (!(currentScript in document)) { - Object.defineProperty(document, currentScript, { - get: function(){ - - // IE 6-10 supports script readyState - // IE 10+ support stack trace - try { throw new Error(); } - catch (err) { +// added support for Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1620505 - // Find the second match for the "at" string to get file src url from stack. - // Specifically works with the format of stack traces in IE. - var i, res = ((/.*at [^\(]*\((.*):.+:.+\)$/ig).exec(err.stack) || [false])[1]; - - // For all scripts on the page, if src matches or if ready state is interactive, return the script tag - for(i in scripts){ - if(scripts[i].src == res || scripts[i].readyState == "interactive"){ - return scripts[i]; - } - } - - // If no match, return null - return null; +(function (root, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else {} +}(typeof self !== 'undefined' ? self : this, function () { + function getCurrentScript () { + if (document.currentScript) { + return document.currentScript + } + + // IE 8-10 support script readyState + // IE 11+ & Firefox support stack trace + try { + throw new Error(); + } + catch (err) { + // Find the second match for the "at" string to get file src url from stack. + var ieStackRegExp = /.*at [^(]*\((.*):(.+):(.+)\)$/ig, + ffStackRegExp = /@([^@]*):(\d+):(\d+)\s*$/ig, + stackDetails = ieStackRegExp.exec(err.stack) || ffStackRegExp.exec(err.stack), + scriptLocation = (stackDetails && stackDetails[1]) || false, + line = (stackDetails && stackDetails[2]) || false, + currentLocation = document.location.href.replace(document.location.hash, ''), + pageSource, + inlineScriptSourceRegExp, + inlineScriptSource, + scripts = document.getElementsByTagName('script'); // Live NodeList collection + + if (scriptLocation === currentLocation) { + pageSource = document.documentElement.outerHTML; + inlineScriptSourceRegExp = new RegExp('(?:[^\\n]+?\\n){0,' + (line - 2) + '}[^<]* diff --git a/src/core/view/components/canvas/index.vue b/src/core/view/components/canvas/index.vue index 910d20c47fefa404ab7abdda2b3e3b2b2ac107a4..000ba276c4f79edc130f38f367a55f1ff9b99808 100644 --- a/src/core/view/components/canvas/index.vue +++ b/src/core/view/components/canvas/index.vue @@ -2,17 +2,20 @@ + v-on="_listeners" + > + height="150" + />
+ @resize="_resize" + />