diff --git a/lib/apis.js b/lib/apis.js index 80835f2c6bbdd6735bb43bd356d992abacf86760..a603f4e282f3576384ba53d41aed8fd51893c094 100644 --- a/lib/apis.js +++ b/lib/apis.js @@ -237,6 +237,7 @@ const third = [ 'requireNativePlugin', 'upx2px', 'restoreGlobal', + 'requireGlobal', 'getSubNVueById', 'getCurrentSubNVue', 'setPageMeta', @@ -274,4 +275,4 @@ const apis = [ ...ad ] -module.exports = apis +module.exports = apis diff --git a/packages/uni-cli-shared/lib/uni-polyfill.js b/packages/uni-cli-shared/lib/uni-polyfill.js index 21fc12d34261ec7ef39b4940f79df6c5043ca621..bf106b4338f4b59b74e5b3d0d737c7ed63edc337 100644 --- a/packages/uni-cli-shared/lib/uni-polyfill.js +++ b/packages/uni-cli-shared/lib/uni-polyfill.js @@ -12,6 +12,18 @@ if (typeof Promise !== 'undefined' && !Promise.prototype.finally) { }) } } -if (uni.base64ToArrayBuffer) { - ArrayBuffer = uni.base64ToArrayBuffer('').constructor +if (typeof uni !== 'undefined' && uni && uni.requireGlobal) { + const global = uni.requireGlobal() + ArrayBuffer = global.ArrayBuffer + Int8Array = global.Int8Array + Uint8Array = global.Uint8Array + Uint8ClampedArray = global.Uint8ClampedArray + Int16Array = global.Int16Array + Uint16Array = global.Uint16Array + Int32Array = global.Int32Array + Uint32Array = global.Uint32Array + Float32Array = global.Float32Array + Float64Array = global.Float64Array + BigInt64Array = global.BigInt64Array + BigUint64Array = global.BigUint64Array } diff --git a/src/core/helpers/promise.js b/src/core/helpers/promise.js index 83f6cb25b2920f464325b1b93251284e2c02d216..d263739efed8a54fd1865d0f524b0c1bf7bbb282 100644 --- a/src/core/helpers/promise.js +++ b/src/core/helpers/promise.js @@ -8,7 +8,7 @@ import { } from './interceptor' const SYNC_API_RE = - /^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/ + /^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale/ const CONTEXT_API_RE = /^create|Manager$/ diff --git a/src/platforms/app-plus/service/api/index.js b/src/platforms/app-plus/service/api/index.js index d1f5f45f544f734343de1a75dcfe22aa90c692c9..8c2bd331b68c475f13aa84644210df624c64c33f 100644 --- a/src/platforms/app-plus/service/api/index.js +++ b/src/platforms/app-plus/service/api/index.js @@ -50,6 +50,7 @@ export * from './plugin/push' export * from './plugin/require-native-plugin' export * from './plugin/share' export * from './plugin/restore-global' +export * from './plugin/require-global' export * from './plugin/sub-nvue' export * from './plugin/on-native-event-receive' export * from './plugin/send-native-event' @@ -83,4 +84,4 @@ export * from './ad/ad' export * from './ad/rewarded-video-ad' export * from './ad/full-screen-video-ad' export * from './ad/interstitial-ad' -export * from './ad/interactive-ad' +export * from './ad/interactive-ad' diff --git a/src/platforms/app-plus/service/api/plugin/require-global.js b/src/platforms/app-plus/service/api/plugin/require-global.js new file mode 100644 index 0000000000000000000000000000000000000000..8f26aa557b0ed3e0a0c7e74bed6f6e6955ae7ca0 --- /dev/null +++ b/src/platforms/app-plus/service/api/plugin/require-global.js @@ -0,0 +1,22 @@ +export function requireGlobal () { + const list = [ + 'ArrayBuffer', + 'Int8Array', + 'Uint8Array', + 'Uint8ClampedArray', + 'Int16Array', + 'Uint16Array', + 'Int32Array', + 'Uint32Array', + 'Float32Array', + 'Float64Array', + 'BigInt64Array', + 'BigUint64Array', + ] + const object = {} + for (let i = 0; i < list.length; i++) { + const key = list[i] + object[key] = global[key] + } + return object +}