@@ -10,6 +10,9 @@ var loader = (function(exports) {
1010 exports . instantiateStreaming = instantiateStreaming ;
1111 exports . demangle = demangle ;
1212 exports . default = void 0 ;
13+
14+ var _asyncifyWasm = require ( "asyncify-wasm" ) ;
15+
1316 // Runtime header offsets
1417 const ID_OFFSET = - 8 ;
1518 const SIZE_OFFSET = - 4 ; // Runtime ids
@@ -171,12 +174,10 @@ var loader = (function(exports) {
171174 /** Allocates a new string in the module's memory and returns its pointer. */
172175
173176
174- function __newString ( str ) {
177+ async function __newString ( str ) {
175178 if ( str == null ) return 0 ;
176179 const length = str . length ;
177-
178- const ptr = __new ( length << 1 , STRING_ID ) ;
179-
180+ const ptr = await __new ( length << 1 , STRING_ID ) ;
180181 const U16 = new Uint16Array ( memory . buffer ) ;
181182
182183 for ( var i = 0 , p = ptr >>> 1 ; i < length ; ++ i ) U16 [ p + i ] = str . charCodeAt ( i ) ;
@@ -230,24 +231,19 @@ var loader = (function(exports) {
230231 /** Allocates a new array in the module's memory and returns its pointer. */
231232
232233
233- function __newArray ( id , values ) {
234+ async function __newArray ( id , values ) {
234235 const info = getArrayInfo ( id ) ;
235236 const align = getValueAlign ( info ) ;
236237 const length = values . length ;
237-
238- const buf = __new ( length << align , info & STATICARRAY ? id : ARRAYBUFFER_ID ) ;
239-
238+ const buf = await __new ( length << align , info & STATICARRAY ? id : ARRAYBUFFER_ID ) ;
240239 let result ;
241240
242241 if ( info & STATICARRAY ) {
243242 result = buf ;
244243 } else {
245- __pin ( buf ) ;
246-
247- const arr = __new ( info & ARRAY ? ARRAY_SIZE : ARRAYBUFFERVIEW_SIZE , id ) ;
248-
249- __unpin ( buf ) ;
250-
244+ await __pin ( buf ) ;
245+ const arr = await __new ( info & ARRAY ? ARRAY_SIZE : ARRAYBUFFERVIEW_SIZE , id ) ;
246+ await __unpin ( buf ) ;
251247 const U32 = new Uint32Array ( memory . buffer ) ;
252248 U32 [ arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2 ] = buf ;
253249 U32 [ arr + ARRAYBUFFERVIEW_DATASTART_OFFSET >>> 2 ] = buf ;
@@ -377,7 +373,7 @@ var loader = (function(exports) {
377373 if ( isResponse ( source = await source ) ) return instantiateStreaming ( source , imports ) ;
378374 const module = isModule ( source ) ? source : await WebAssembly . compile ( source ) ;
379375 const extended = preInstantiate ( imports ) ;
380- const instance = await WebAssembly . instantiate ( module , imports ) ;
376+ const instance = await ( 0 , _asyncifyWasm . instantiate ) ( module , imports ) ;
381377 const exports = postInstantiate ( extended , instance ) ;
382378 return {
383379 module,
@@ -455,6 +451,10 @@ var loader = (function(exports) {
455451
456452 } ;
457453
454+ ctor . __new = async function ( ...args ) {
455+ return ctor . wrap ( await ctor . prototype . constructor ( 0 , ...args ) ) ;
456+ } ;
457+
458458 ctor . wrap = function ( thisValue ) {
459459 return Object . create ( ctor . prototype , {
460460 [ THIS ] : {
0 commit comments