@@ -10,6 +10,9 @@ var loader = (function(exports) {
10
10
exports . instantiateStreaming = instantiateStreaming ;
11
11
exports . demangle = demangle ;
12
12
exports . default = void 0 ;
13
+
14
+ var _asyncifyWasm = require ( "asyncify-wasm" ) ;
15
+
13
16
// Runtime header offsets
14
17
const ID_OFFSET = - 8 ;
15
18
const SIZE_OFFSET = - 4 ; // Runtime ids
@@ -171,12 +174,10 @@ var loader = (function(exports) {
171
174
/** Allocates a new string in the module's memory and returns its pointer. */
172
175
173
176
174
- function __newString ( str ) {
177
+ async function __newString ( str ) {
175
178
if ( str == null ) return 0 ;
176
179
const length = str . length ;
177
-
178
- const ptr = __new ( length << 1 , STRING_ID ) ;
179
-
180
+ const ptr = await __new ( length << 1 , STRING_ID ) ;
180
181
const U16 = new Uint16Array ( memory . buffer ) ;
181
182
182
183
for ( var i = 0 , p = ptr >>> 1 ; i < length ; ++ i ) U16 [ p + i ] = str . charCodeAt ( i ) ;
@@ -230,24 +231,19 @@ var loader = (function(exports) {
230
231
/** Allocates a new array in the module's memory and returns its pointer. */
231
232
232
233
233
- function __newArray ( id , values ) {
234
+ async function __newArray ( id , values ) {
234
235
const info = getArrayInfo ( id ) ;
235
236
const align = getValueAlign ( info ) ;
236
237
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 ) ;
240
239
let result ;
241
240
242
241
if ( info & STATICARRAY ) {
243
242
result = buf ;
244
243
} 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 ) ;
251
247
const U32 = new Uint32Array ( memory . buffer ) ;
252
248
U32 [ arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2 ] = buf ;
253
249
U32 [ arr + ARRAYBUFFERVIEW_DATASTART_OFFSET >>> 2 ] = buf ;
@@ -377,7 +373,7 @@ var loader = (function(exports) {
377
373
if ( isResponse ( source = await source ) ) return instantiateStreaming ( source , imports ) ;
378
374
const module = isModule ( source ) ? source : await WebAssembly . compile ( source ) ;
379
375
const extended = preInstantiate ( imports ) ;
380
- const instance = await WebAssembly . instantiate ( module , imports ) ;
376
+ const instance = await ( 0 , _asyncifyWasm . instantiate ) ( module , imports ) ;
381
377
const exports = postInstantiate ( extended , instance ) ;
382
378
return {
383
379
module,
@@ -455,6 +451,10 @@ var loader = (function(exports) {
455
451
456
452
} ;
457
453
454
+ ctor . __new = async function ( ...args ) {
455
+ return ctor . wrap ( await ctor . prototype . constructor ( 0 , ...args ) ) ;
456
+ } ;
457
+
458
458
ctor . wrap = function ( thisValue ) {
459
459
return Object . create ( ctor . prototype , {
460
460
[ THIS ] : {
0 commit comments