diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 39408f4053e04ba48eeba5a877cd326e1b302be4..cab56e940d04d8948de64d7abea8565f905cbe4a 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -40,7 +40,7 @@ const camelize = cached((str) => { return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') }); -const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; +const SYNC_API_RE = /getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -254,6 +254,21 @@ TODOS.forEach(function (name) { function wrapper$1 (webview) { webview.$processed = true; + + webview.postMessage = function (data) { + plus.webview.postMessageToUniNView({ + type: 'UniAppSubNVue', + data + }, webview.id); + }; + let callbacks = []; + webview.onMessage = function (callback) { + callbacks.push(callback); + }; + webview.$consumeMessage = function (e) { + callbacks.forEach(callback => callback(e)); + }; + if (!webview.__uniapp_mask_id) { return } @@ -286,33 +301,15 @@ function wrapper$1 (webview) { callbacks = []; return oldClose.apply(webview, args) }; - webview.postMessage = function (data) { - plus.webview.postMessageToUniNView({ - type: 'UniAppSubNVue', - data, - options: { - id: webview.id - } - }, webview.id); - }; - let callbacks = []; - webview.onMessage = function (callback) { - callbacks.push(callback); - }; - webview.$consumeMessage = function (e) { - callbacks.forEach(callback => callback(e)); - }; } -const subNVue = { - getSubNVueById (id) { - const webview = plus.webview.getWebviewById(id); - if (webview && !webview.$processed) { - wrapper$1(webview); - } - return webview +function getSubNVueById (id) { + const webview = plus.webview.getWebviewById(id); + if (webview && !webview.$processed) { + wrapper$1(webview); } -}; + return webview +} function requireNativePlugin (pluginName) { /* eslint-disable no-undef */ @@ -325,7 +322,7 @@ function requireNativePlugin (pluginName) { var api = /*#__PURE__*/Object.freeze({ requireNativePlugin: requireNativePlugin, - subNVue: subNVue + getSubNVueById: getSubNVueById }); const MPPage = Page; diff --git a/packages/uni-app-plus/package.json b/packages/uni-app-plus/package.json index 5b421a66030e540d82deb4c51cbb1a42c7fbfd44..07652a3822142be070bdade5cb6e2942a1f48d86 100644 --- a/packages/uni-app-plus/package.json +++ b/packages/uni-app-plus/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-app-plus", - "version": "0.0.232", + "version": "0.0.233", "description": "uni-app app-plus", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index 6df0b7e3b7f19bf2e2bab274817daffc6031899a..8e6b98482cd8565a222668cfb6ea77ec69465bab 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -40,7 +40,7 @@ const camelize = cached((str) => { return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') }); -const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; +const SYNC_API_RE = /getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; diff --git a/packages/uni-mp-alipay/package.json b/packages/uni-mp-alipay/package.json index 17d4cfa93cacf496e44e2fed89b30ee1a2664fbb..86c89dd389b9c15ee50205865705a1776dac65b1 100644 --- a/packages/uni-mp-alipay/package.json +++ b/packages/uni-mp-alipay/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-alipay", - "version": "0.0.803", + "version": "0.0.804", "description": "uni-app mp-alipay", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index 2c39c3ec05cb1a7f3d913a9c77be064114e66449..6d2beddfcd7f3e7e14f7c3c301181516c61c4b7b 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -40,7 +40,7 @@ const camelize = cached((str) => { return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') }); -const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/; +const SYNC_API_RE = /getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -88,17 +88,17 @@ function promisify (name, api) { success: resolve, fail: reject }), ...params); - /* eslint-disable no-extend-native */ - if (!Promise.prototype.finally) { - Promise.prototype.finally = function (callback) { - const promise = this.constructor; - return this.then( - value => promise.resolve(callback()).then(() => value), - reason => promise.resolve(callback()).then(() => { - throw reason - }) - ) - }; + /* eslint-disable no-extend-native */ + if (!Promise.prototype.finally) { + Promise.prototype.finally = function (callback) { + const promise = this.constructor; + return this.then( + value => promise.resolve(callback()).then(() => value), + reason => promise.resolve(callback()).then(() => { + throw reason + }) + ) + }; } })) } diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index 7f1254f58815d3a7cc2e796fdc42ba94b13bdbb2..9265a43a1ec8afe33b4fa17eff3fa2d1479df677 100644 --- a/packages/uni-mp-baidu/package.json +++ b/packages/uni-mp-baidu/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-baidu", - "version": "0.0.830", + "version": "0.0.831", "description": "uni-app mp-baidu", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index f7e0e20e4a3be964cabd412fd4f1ccca3b8fa625..28038faeaa712116c3d36eca3b02407eff75975c 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -40,7 +40,7 @@ const camelize = cached((str) => { return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') }); -const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/; +const SYNC_API_RE = /getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -88,17 +88,17 @@ function promisify (name, api) { success: resolve, fail: reject }), ...params); - /* eslint-disable no-extend-native */ - if (!Promise.prototype.finally) { - Promise.prototype.finally = function (callback) { - const promise = this.constructor; - return this.then( - value => promise.resolve(callback()).then(() => value), - reason => promise.resolve(callback()).then(() => { - throw reason - }) - ) - }; + /* eslint-disable no-extend-native */ + if (!Promise.prototype.finally) { + Promise.prototype.finally = function (callback) { + const promise = this.constructor; + return this.then( + value => promise.resolve(callback()).then(() => value), + reason => promise.resolve(callback()).then(() => { + throw reason + }) + ) + }; } })) } diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index 88e1d85d5f5ebc815ab8e6b5e995ab1ec1014f0e..12d8f493dcfd11b0d66c007df19c2752ab3c2f97 100644 --- a/packages/uni-mp-toutiao/package.json +++ b/packages/uni-mp-toutiao/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-toutiao", - "version": "0.0.328", + "version": "0.0.329", "description": "uni-app mp-toutiao", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index e34eb37128ddab56c7cecf1a6c12b82b198267f3..e15a41955c3e8a84b98c2fbd728f2fb83ed41aff 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -40,7 +40,7 @@ const camelize = cached((str) => { return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') }); -const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; +const SYNC_API_RE = /getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index f22169b4c8263121ae57633c15089241e4e7b511..e0a14afd28ae7d6d1c559306b80072cde7f990ca 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-weixin", - "version": "0.0.952", + "version": "0.0.953", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/core/helpers/promise.js b/src/core/helpers/promise.js index f83f3cc15d5b77d8f6c426fd36f8fa565e881689..16aab48f0cae7f5206c6a8697fb22b2a72e7d500 100644 --- a/src/core/helpers/promise.js +++ b/src/core/helpers/promise.js @@ -2,7 +2,7 @@ import { isFn } from 'uni-shared' -const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/ +const SYNC_API_RE = /getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/ const CONTEXT_API_RE = /^create|Manager$/ diff --git a/src/platforms/app-plus/service/api/sub-nvue.js b/src/platforms/app-plus/service/api/sub-nvue.js index 8e14f148d233729c1ba47569197a89c4aa990006..38854aa684d3720f06b2b6199524047dcf5bc7c2 100644 --- a/src/platforms/app-plus/service/api/sub-nvue.js +++ b/src/platforms/app-plus/service/api/sub-nvue.js @@ -4,10 +4,7 @@ function wrapper (webview) { webview.postMessage = function (data) { plus.webview.postMessageToUniNView({ type: 'UniAppSubNVue', - data, - options: { - id: webview.id - } + data }, webview.id) } let callbacks = [] @@ -52,12 +49,10 @@ function wrapper (webview) { } } -export const subNVue = { - getSubNVueById (id) { - const webview = plus.webview.getWebviewById(id) - if (webview && !webview.$processed) { - wrapper(webview) - } - return webview +export function getSubNVueById (id) { + const webview = plus.webview.getWebviewById(id) + if (webview && !webview.$processed) { + wrapper(webview) } + return webview }