@swc/wasm-web 1.2.219 → 1.2.222

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/wasm-web.js CHANGED
@@ -1,28 +1,43 @@
1
1
 
2
2
  let wasm;
3
3
 
4
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
4
+ const heap = new Array(32).fill(undefined);
5
+
6
+ heap.push(undefined, null, true, false);
7
+
8
+ function getObject(idx) { return heap[idx]; }
9
+
10
+ let heap_next = heap.length;
11
+
12
+ function dropObject(idx) {
13
+ if (idx < 36) return;
14
+ heap[idx] = heap_next;
15
+ heap_next = idx;
16
+ }
17
+
18
+ function takeObject(idx) {
19
+ const ret = getObject(idx);
20
+ dropObject(idx);
21
+ return ret;
22
+ }
23
+
24
+ const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
5
25
 
6
26
  cachedTextDecoder.decode();
7
27
 
8
- let cachegetUint8Memory0 = null;
28
+ let cachedUint8Memory0 = new Uint8Array();
29
+
9
30
  function getUint8Memory0() {
10
- if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
11
- cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
31
+ if (cachedUint8Memory0.byteLength === 0) {
32
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
12
33
  }
13
- return cachegetUint8Memory0;
34
+ return cachedUint8Memory0;
14
35
  }
15
36
 
16
37
  function getStringFromWasm0(ptr, len) {
17
38
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
18
39
  }
19
40
 
20
- const heap = new Array(32).fill(undefined);
21
-
22
- heap.push(undefined, null, true, false);
23
-
24
- let heap_next = heap.length;
25
-
26
41
  function addHeapObject(obj) {
27
42
  if (heap_next === heap.length) heap.push(heap.length + 1);
28
43
  const idx = heap_next;
@@ -32,11 +47,9 @@ function addHeapObject(obj) {
32
47
  return idx;
33
48
  }
34
49
 
35
- function getObject(idx) { return heap[idx]; }
36
-
37
50
  let WASM_VECTOR_LEN = 0;
38
51
 
39
- let cachedTextEncoder = new TextEncoder('utf-8');
52
+ const cachedTextEncoder = new TextEncoder('utf-8');
40
53
 
41
54
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
42
55
  ? function (arg, view) {
@@ -89,25 +102,47 @@ function passStringToWasm0(arg, malloc, realloc) {
89
102
  return ptr;
90
103
  }
91
104
 
92
- let cachegetInt32Memory0 = null;
105
+ function isLikeNone(x) {
106
+ return x === undefined || x === null;
107
+ }
108
+
109
+ let cachedInt32Memory0 = new Int32Array();
110
+
93
111
  function getInt32Memory0() {
94
- if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
95
- cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
112
+ if (cachedInt32Memory0.byteLength === 0) {
113
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
96
114
  }
97
- return cachegetInt32Memory0;
115
+ return cachedInt32Memory0;
98
116
  }
99
117
 
100
- function dropObject(idx) {
101
- if (idx < 36) return;
102
- heap[idx] = heap_next;
103
- heap_next = idx;
104
- }
118
+ function makeMutClosure(arg0, arg1, dtor, f) {
119
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
120
+ const real = (...args) => {
121
+ // First up with a closure we increment the internal reference
122
+ // count. This ensures that the Rust closure environment won't
123
+ // be deallocated while we're invoking it.
124
+ state.cnt++;
125
+ const a = state.a;
126
+ state.a = 0;
127
+ try {
128
+ return f(a, state.b, ...args);
129
+ } finally {
130
+ if (--state.cnt === 0) {
131
+ wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
105
132
 
106
- function takeObject(idx) {
107
- const ret = getObject(idx);
108
- dropObject(idx);
109
- return ret;
133
+ } else {
134
+ state.a = a;
135
+ }
136
+ }
137
+ };
138
+ real.original = state;
139
+
140
+ return real;
110
141
  }
142
+ function __wbg_adapter_22(arg0, arg1, arg2) {
143
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h474a5d2341fab4ae(arg0, arg1, addHeapObject(arg2));
144
+ }
145
+
111
146
  /**
112
147
  * @param {string} s
113
148
  * @param {any} opts
@@ -116,9 +151,7 @@ function takeObject(idx) {
116
151
  export function minifySync(s, opts) {
117
152
  try {
118
153
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
119
- var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
120
- var len0 = WASM_VECTOR_LEN;
121
- wasm.minifySync(retptr, ptr0, len0, addHeapObject(opts));
154
+ wasm.minifySync(retptr, addHeapObject(s), addHeapObject(opts));
122
155
  var r0 = getInt32Memory0()[retptr / 4 + 0];
123
156
  var r1 = getInt32Memory0()[retptr / 4 + 1];
124
157
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -131,6 +164,16 @@ export function minifySync(s, opts) {
131
164
  }
132
165
  }
133
166
 
167
+ /**
168
+ * @param {string} s
169
+ * @param {any} opts
170
+ * @returns {Promise<any>}
171
+ */
172
+ export function minify(s, opts) {
173
+ const ret = wasm.minify(addHeapObject(s), addHeapObject(opts));
174
+ return takeObject(ret);
175
+ }
176
+
134
177
  /**
135
178
  * @param {string} s
136
179
  * @param {any} opts
@@ -139,9 +182,7 @@ export function minifySync(s, opts) {
139
182
  export function parseSync(s, opts) {
140
183
  try {
141
184
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
142
- var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
143
- var len0 = WASM_VECTOR_LEN;
144
- wasm.parseSync(retptr, ptr0, len0, addHeapObject(opts));
185
+ wasm.parseSync(retptr, addHeapObject(s), addHeapObject(opts));
145
186
  var r0 = getInt32Memory0()[retptr / 4 + 0];
146
187
  var r1 = getInt32Memory0()[retptr / 4 + 1];
147
188
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -154,6 +195,16 @@ export function parseSync(s, opts) {
154
195
  }
155
196
  }
156
197
 
198
+ /**
199
+ * @param {string} s
200
+ * @param {any} opts
201
+ * @returns {Promise<any>}
202
+ */
203
+ export function parse(s, opts) {
204
+ const ret = wasm.parse(addHeapObject(s), addHeapObject(opts));
205
+ return takeObject(ret);
206
+ }
207
+
157
208
  /**
158
209
  * @param {any} s
159
210
  * @param {any} opts
@@ -176,7 +227,17 @@ export function printSync(s, opts) {
176
227
  }
177
228
 
178
229
  /**
179
- * @param {string} s
230
+ * @param {any} s
231
+ * @param {any} opts
232
+ * @returns {Promise<any>}
233
+ */
234
+ export function print(s, opts) {
235
+ const ret = wasm.print(addHeapObject(s), addHeapObject(opts));
236
+ return takeObject(ret);
237
+ }
238
+
239
+ /**
240
+ * @param {any} s
180
241
  * @param {any} opts
181
242
  * @param {any} experimental_plugin_bytes_resolver
182
243
  * @returns {any}
@@ -184,9 +245,7 @@ export function printSync(s, opts) {
184
245
  export function transformSync(s, opts, experimental_plugin_bytes_resolver) {
185
246
  try {
186
247
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
187
- var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
188
- var len0 = WASM_VECTOR_LEN;
189
- wasm.transformSync(retptr, ptr0, len0, addHeapObject(opts), addHeapObject(experimental_plugin_bytes_resolver));
248
+ wasm.transformSync(retptr, addHeapObject(s), addHeapObject(opts), addHeapObject(experimental_plugin_bytes_resolver));
190
249
  var r0 = getInt32Memory0()[retptr / 4 + 0];
191
250
  var r1 = getInt32Memory0()[retptr / 4 + 1];
192
251
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -199,6 +258,36 @@ export function transformSync(s, opts, experimental_plugin_bytes_resolver) {
199
258
  }
200
259
  }
201
260
 
261
+ /**
262
+ * @param {any} s
263
+ * @param {any} opts
264
+ * @param {any} experimental_plugin_bytes_resolver
265
+ * @returns {Promise<any>}
266
+ */
267
+ export function transform(s, opts, experimental_plugin_bytes_resolver) {
268
+ const ret = wasm.transform(addHeapObject(s), addHeapObject(opts), addHeapObject(experimental_plugin_bytes_resolver));
269
+ return takeObject(ret);
270
+ }
271
+
272
+ function getCachedStringFromWasm0(ptr, len) {
273
+ if (ptr === 0) {
274
+ return getObject(len);
275
+ } else {
276
+ return getStringFromWasm0(ptr, len);
277
+ }
278
+ }
279
+
280
+ function handleError(f, args) {
281
+ try {
282
+ return f.apply(this, args);
283
+ } catch (e) {
284
+ wasm.__wbindgen_exn_store(addHeapObject(e));
285
+ }
286
+ }
287
+ function __wbg_adapter_45(arg0, arg1, arg2, arg3) {
288
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h941e0353bb9b8983(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
289
+ }
290
+
202
291
  async function load(module, imports) {
203
292
  if (typeof Response === 'function' && module instanceof Response) {
204
293
  if (typeof WebAssembly.instantiateStreaming === 'function') {
@@ -230,78 +319,167 @@ async function load(module, imports) {
230
319
  }
231
320
  }
232
321
 
233
- async function init(input) {
234
- if (typeof input === 'undefined') {
235
- input = new URL('wasm-web_bg.wasm', import.meta.url);
236
- }
322
+ function getImports() {
237
323
  const imports = {};
238
324
  imports.wbg = {};
239
- imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
240
- var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
325
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
326
+ takeObject(arg0);
327
+ };
328
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
329
+ const ret = getStringFromWasm0(arg0, arg1);
241
330
  return addHeapObject(ret);
242
331
  };
243
- imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
332
+ imports.wbg.__wbg_new_52205195aa880fc2 = function(arg0, arg1) {
333
+ try {
334
+ var state0 = {a: arg0, b: arg1};
335
+ var cb0 = (arg0, arg1) => {
336
+ const a = state0.a;
337
+ state0.a = 0;
338
+ try {
339
+ return __wbg_adapter_45(a, state0.b, arg0, arg1);
340
+ } finally {
341
+ state0.a = a;
342
+ }
343
+ };
344
+ const ret = new Promise(cb0);
345
+ return addHeapObject(ret);
346
+ } finally {
347
+ state0.a = state0.b = 0;
348
+ }
349
+ };
350
+ imports.wbg.__wbindgen_is_null = function(arg0) {
351
+ const ret = getObject(arg0) === null;
352
+ return ret;
353
+ };
354
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
355
+ const ret = getObject(arg0) === undefined;
356
+ return ret;
357
+ };
358
+ imports.wbg.__wbindgen_is_string = function(arg0) {
359
+ const ret = typeof(getObject(arg0)) === 'string';
360
+ return ret;
361
+ };
362
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
244
363
  const obj = getObject(arg1);
245
- var ret = JSON.stringify(obj === undefined ? null : obj);
246
- var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
364
+ const ret = typeof(obj) === 'string' ? obj : undefined;
365
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
247
366
  var len0 = WASM_VECTOR_LEN;
248
367
  getInt32Memory0()[arg0 / 4 + 1] = len0;
249
368
  getInt32Memory0()[arg0 / 4 + 0] = ptr0;
250
369
  };
251
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
252
- takeObject(arg0);
370
+ imports.wbg.__wbg_call_65af9f665ab6ade5 = function() { return handleError(function (arg0, arg1, arg2) {
371
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
372
+ return addHeapObject(ret);
373
+ }, arguments) };
374
+ imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
375
+ const obj = getObject(arg1);
376
+ const ret = JSON.stringify(obj === undefined ? null : obj);
377
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
378
+ const len0 = WASM_VECTOR_LEN;
379
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
380
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
253
381
  };
254
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
255
- var ret = getStringFromWasm0(arg0, arg1);
382
+ imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
383
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
256
384
  return addHeapObject(ret);
257
385
  };
258
- imports.wbg.__wbg_new0_57a6a2c2aaed3fc5 = function() {
259
- var ret = new Date();
386
+ imports.wbg.__wbg_new0_adda2d4bcb124f0a = function() {
387
+ const ret = new Date();
260
388
  return addHeapObject(ret);
261
389
  };
262
- imports.wbg.__wbg_getTime_f8ce0ff902444efb = function(arg0) {
263
- var ret = getObject(arg0).getTime();
390
+ imports.wbg.__wbg_getTime_58b0bdbebd4ef11d = function(arg0) {
391
+ const ret = getObject(arg0).getTime();
264
392
  return ret;
265
393
  };
266
- imports.wbg.__wbg_getTimezoneOffset_41211a984662508b = function(arg0) {
267
- var ret = getObject(arg0).getTimezoneOffset();
394
+ imports.wbg.__wbg_getTimezoneOffset_8a39b51acb4f52c9 = function(arg0) {
395
+ const ret = getObject(arg0).getTimezoneOffset();
268
396
  return ret;
269
397
  };
270
398
  imports.wbg.__wbg_new_693216e109162396 = function() {
271
- var ret = new Error();
399
+ const ret = new Error();
272
400
  return addHeapObject(ret);
273
401
  };
274
402
  imports.wbg.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
275
- var ret = getObject(arg1).stack;
276
- var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
277
- var len0 = WASM_VECTOR_LEN;
403
+ const ret = getObject(arg1).stack;
404
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
405
+ const len0 = WASM_VECTOR_LEN;
278
406
  getInt32Memory0()[arg0 / 4 + 1] = len0;
279
407
  getInt32Memory0()[arg0 / 4 + 0] = ptr0;
280
408
  };
281
409
  imports.wbg.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
282
- try {
283
- console.error(getStringFromWasm0(arg0, arg1));
284
- } finally {
285
- wasm.__wbindgen_free(arg0, arg1);
286
- }
287
- };
288
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
289
- throw new Error(getStringFromWasm0(arg0, arg1));
290
- };
291
-
292
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
293
- input = fetch(input);
410
+ var v0 = getCachedStringFromWasm0(arg0, arg1);
411
+ if (arg0 !== 0) { wasm.__wbindgen_free(arg0, arg1); }
412
+ console.error(v0);
413
+ };
414
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
415
+ throw new Error(getStringFromWasm0(arg0, arg1));
416
+ };
417
+ imports.wbg.__wbg_resolve_0107b3a501450ba0 = function(arg0) {
418
+ const ret = Promise.resolve(getObject(arg0));
419
+ return addHeapObject(ret);
420
+ };
421
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
422
+ const obj = takeObject(arg0).original;
423
+ if (obj.cnt-- == 1) {
424
+ obj.a = 0;
425
+ return true;
294
426
  }
427
+ const ret = false;
428
+ return ret;
429
+ };
430
+ imports.wbg.__wbg_then_18da6e5453572fc8 = function(arg0, arg1) {
431
+ const ret = getObject(arg0).then(getObject(arg1));
432
+ return addHeapObject(ret);
433
+ };
434
+ imports.wbg.__wbindgen_closure_wrapper14169 = function(arg0, arg1, arg2) {
435
+ const ret = makeMutClosure(arg0, arg1, 154, __wbg_adapter_22);
436
+ return addHeapObject(ret);
437
+ };
438
+
439
+ return imports;
440
+ }
295
441
 
442
+ function initMemory(imports, maybe_memory) {
296
443
 
444
+ }
297
445
 
298
- const { instance, module } = await load(await input, imports);
299
-
446
+ function finalizeInit(instance, module) {
300
447
  wasm = instance.exports;
301
448
  init.__wbindgen_wasm_module = module;
449
+ cachedInt32Memory0 = new Int32Array();
450
+ cachedUint8Memory0 = new Uint8Array();
451
+
302
452
 
303
453
  return wasm;
304
454
  }
305
455
 
306
- export default init;
456
+ function initSync(bytes) {
457
+ const imports = getImports();
307
458
 
459
+ initMemory(imports);
460
+
461
+ const module = new WebAssembly.Module(bytes);
462
+ const instance = new WebAssembly.Instance(module, imports);
463
+
464
+ return finalizeInit(instance, module);
465
+ }
466
+
467
+ async function init(input) {
468
+ if (typeof input === 'undefined') {
469
+ input = new URL('wasm-web_bg.wasm', import.meta.url);
470
+ }
471
+ const imports = getImports();
472
+
473
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
474
+ input = fetch(input);
475
+ }
476
+
477
+ initMemory(imports);
478
+
479
+ const { instance, module } = await load(await input, imports);
480
+
481
+ return finalizeInit(instance, module);
482
+ }
483
+
484
+ export { initSync }
485
+ export default init;
package/wasm-web_bg.wasm CHANGED
Binary file