提交 9c343b09 编写于 作者: Q qiang

feat(App): add requireGlobal

上级 44187725
......@@ -237,6 +237,7 @@ const third = [
'requireNativePlugin',
'upx2px',
'restoreGlobal',
'requireGlobal',
'getSubNVueById',
'getCurrentSubNVue',
'setPageMeta',
......@@ -282,4 +283,4 @@ const apis = [
...plugin
]
module.exports = apis
module.exports = apis
......@@ -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
}
......@@ -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|invokePushCallback/
/^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback/
const CONTEXT_API_RE = /^create|Manager$/
......
......@@ -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'
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
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册