@@ -63,6 +63,7 @@ export async function instantiateForThread(
63
63
async function _instantiate (
64
64
options
65
65
) {
66
+ const _WebAssembly = options . WebAssembly || WebAssembly ;
66
67
const moduleSource = options . module ;
67
68
/* #if IS_WASI */
68
69
const { wasi } = options ;
@@ -98,23 +99,23 @@ async function _instantiate(
98
99
let module ;
99
100
let instance ;
100
101
let exports ;
101
- if ( moduleSource instanceof WebAssembly . Module ) {
102
+ if ( moduleSource instanceof _WebAssembly . Module ) {
102
103
module = moduleSource ;
103
- instance = await WebAssembly . instantiate ( module , importObject ) ;
104
+ instance = await _WebAssembly . instantiate ( module , importObject ) ;
104
105
} else if ( typeof Response === "function" && ( moduleSource instanceof Response || moduleSource instanceof Promise ) ) {
105
- if ( typeof WebAssembly . instantiateStreaming === "function" ) {
106
- const result = await WebAssembly . instantiateStreaming ( moduleSource , importObject ) ;
106
+ if ( typeof _WebAssembly . instantiateStreaming === "function" ) {
107
+ const result = await _WebAssembly . instantiateStreaming ( moduleSource , importObject ) ;
107
108
module = result . module ;
108
109
instance = result . instance ;
109
110
} else {
110
111
const moduleBytes = await ( await moduleSource ) . arrayBuffer ( ) ;
111
- module = await WebAssembly . compile ( moduleBytes ) ;
112
- instance = await WebAssembly . instantiate ( module , importObject ) ;
112
+ module = await _WebAssembly . compile ( moduleBytes ) ;
113
+ instance = await _WebAssembly . instantiate ( module , importObject ) ;
113
114
}
114
115
} else {
115
116
// @ts -expect-error: Type 'Response' is not assignable to type 'BufferSource'
116
- module = await WebAssembly . compile ( moduleSource ) ;
117
- instance = await WebAssembly . instantiate ( module , importObject ) ;
117
+ module = await _WebAssembly . compile ( moduleSource ) ;
118
+ instance = await _WebAssembly . instantiate ( module , importObject ) ;
118
119
}
119
120
120
121
swift . setInstance ( instance ) ;
0 commit comments