@swc/wasm 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.
Files changed (4) hide show
  1. package/package.json +1 -1
  2. package/wasm.d.ts +2822 -27
  3. package/wasm.js +219 -59
  4. package/wasm_bg.wasm +0 -0
package/wasm.js CHANGED
@@ -3,28 +3,43 @@ imports['__wbindgen_placeholder__'] = module.exports;
3
3
  let wasm;
4
4
  const { TextDecoder, TextEncoder } = require(`util`);
5
5
 
6
+ const heap = new Array(32).fill(undefined);
7
+
8
+ heap.push(undefined, null, true, false);
9
+
10
+ function getObject(idx) { return heap[idx]; }
11
+
12
+ let heap_next = heap.length;
13
+
14
+ function dropObject(idx) {
15
+ if (idx < 36) return;
16
+ heap[idx] = heap_next;
17
+ heap_next = idx;
18
+ }
19
+
20
+ function takeObject(idx) {
21
+ const ret = getObject(idx);
22
+ dropObject(idx);
23
+ return ret;
24
+ }
25
+
6
26
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
7
27
 
8
28
  cachedTextDecoder.decode();
9
29
 
10
- let cachegetUint8Memory0 = null;
30
+ let cachedUint8Memory0 = new Uint8Array();
31
+
11
32
  function getUint8Memory0() {
12
- if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
13
- cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
33
+ if (cachedUint8Memory0.byteLength === 0) {
34
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
14
35
  }
15
- return cachegetUint8Memory0;
36
+ return cachedUint8Memory0;
16
37
  }
17
38
 
18
39
  function getStringFromWasm0(ptr, len) {
19
40
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
20
41
  }
21
42
 
22
- const heap = new Array(32).fill(undefined);
23
-
24
- heap.push(undefined, null, true, false);
25
-
26
- let heap_next = heap.length;
27
-
28
43
  function addHeapObject(obj) {
29
44
  if (heap_next === heap.length) heap.push(heap.length + 1);
30
45
  const idx = heap_next;
@@ -34,8 +49,6 @@ function addHeapObject(obj) {
34
49
  return idx;
35
50
  }
36
51
 
37
- function getObject(idx) { return heap[idx]; }
38
-
39
52
  let WASM_VECTOR_LEN = 0;
40
53
 
41
54
  let cachedTextEncoder = new TextEncoder('utf-8');
@@ -91,25 +104,47 @@ function passStringToWasm0(arg, malloc, realloc) {
91
104
  return ptr;
92
105
  }
93
106
 
94
- let cachegetInt32Memory0 = null;
107
+ function isLikeNone(x) {
108
+ return x === undefined || x === null;
109
+ }
110
+
111
+ let cachedInt32Memory0 = new Int32Array();
112
+
95
113
  function getInt32Memory0() {
96
- if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
97
- cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
114
+ if (cachedInt32Memory0.byteLength === 0) {
115
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
98
116
  }
99
- return cachegetInt32Memory0;
117
+ return cachedInt32Memory0;
100
118
  }
101
119
 
102
- function dropObject(idx) {
103
- if (idx < 36) return;
104
- heap[idx] = heap_next;
105
- heap_next = idx;
106
- }
120
+ function makeMutClosure(arg0, arg1, dtor, f) {
121
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
122
+ const real = (...args) => {
123
+ // First up with a closure we increment the internal reference
124
+ // count. This ensures that the Rust closure environment won't
125
+ // be deallocated while we're invoking it.
126
+ state.cnt++;
127
+ const a = state.a;
128
+ state.a = 0;
129
+ try {
130
+ return f(a, state.b, ...args);
131
+ } finally {
132
+ if (--state.cnt === 0) {
133
+ wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
134
+
135
+ } else {
136
+ state.a = a;
137
+ }
138
+ }
139
+ };
140
+ real.original = state;
107
141
 
108
- function takeObject(idx) {
109
- const ret = getObject(idx);
110
- dropObject(idx);
111
- return ret;
142
+ return real;
143
+ }
144
+ function __wbg_adapter_22(arg0, arg1, arg2) {
145
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h474a5d2341fab4ae(arg0, arg1, addHeapObject(arg2));
112
146
  }
147
+
113
148
  /**
114
149
  * @param {string} s
115
150
  * @param {any} opts
@@ -118,9 +153,7 @@ function takeObject(idx) {
118
153
  module.exports.minifySync = function(s, opts) {
119
154
  try {
120
155
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
121
- var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
122
- var len0 = WASM_VECTOR_LEN;
123
- wasm.minifySync(retptr, ptr0, len0, addHeapObject(opts));
156
+ wasm.minifySync(retptr, addHeapObject(s), addHeapObject(opts));
124
157
  var r0 = getInt32Memory0()[retptr / 4 + 0];
125
158
  var r1 = getInt32Memory0()[retptr / 4 + 1];
126
159
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -133,6 +166,16 @@ module.exports.minifySync = function(s, opts) {
133
166
  }
134
167
  };
135
168
 
169
+ /**
170
+ * @param {string} s
171
+ * @param {any} opts
172
+ * @returns {Promise<any>}
173
+ */
174
+ module.exports.minify = function(s, opts) {
175
+ const ret = wasm.minify(addHeapObject(s), addHeapObject(opts));
176
+ return takeObject(ret);
177
+ };
178
+
136
179
  /**
137
180
  * @param {string} s
138
181
  * @param {any} opts
@@ -141,9 +184,7 @@ module.exports.minifySync = function(s, opts) {
141
184
  module.exports.parseSync = function(s, opts) {
142
185
  try {
143
186
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
144
- var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
145
- var len0 = WASM_VECTOR_LEN;
146
- wasm.parseSync(retptr, ptr0, len0, addHeapObject(opts));
187
+ wasm.parseSync(retptr, addHeapObject(s), addHeapObject(opts));
147
188
  var r0 = getInt32Memory0()[retptr / 4 + 0];
148
189
  var r1 = getInt32Memory0()[retptr / 4 + 1];
149
190
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -156,6 +197,16 @@ module.exports.parseSync = function(s, opts) {
156
197
  }
157
198
  };
158
199
 
200
+ /**
201
+ * @param {string} s
202
+ * @param {any} opts
203
+ * @returns {Promise<any>}
204
+ */
205
+ module.exports.parse = function(s, opts) {
206
+ const ret = wasm.parse(addHeapObject(s), addHeapObject(opts));
207
+ return takeObject(ret);
208
+ };
209
+
159
210
  /**
160
211
  * @param {any} s
161
212
  * @param {any} opts
@@ -178,7 +229,17 @@ module.exports.printSync = function(s, opts) {
178
229
  };
179
230
 
180
231
  /**
181
- * @param {string} s
232
+ * @param {any} s
233
+ * @param {any} opts
234
+ * @returns {Promise<any>}
235
+ */
236
+ module.exports.print = function(s, opts) {
237
+ const ret = wasm.print(addHeapObject(s), addHeapObject(opts));
238
+ return takeObject(ret);
239
+ };
240
+
241
+ /**
242
+ * @param {any} s
182
243
  * @param {any} opts
183
244
  * @param {any} experimental_plugin_bytes_resolver
184
245
  * @returns {any}
@@ -186,9 +247,7 @@ module.exports.printSync = function(s, opts) {
186
247
  module.exports.transformSync = function(s, opts, experimental_plugin_bytes_resolver) {
187
248
  try {
188
249
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
189
- var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
190
- var len0 = WASM_VECTOR_LEN;
191
- wasm.transformSync(retptr, ptr0, len0, addHeapObject(opts), addHeapObject(experimental_plugin_bytes_resolver));
250
+ wasm.transformSync(retptr, addHeapObject(s), addHeapObject(opts), addHeapObject(experimental_plugin_bytes_resolver));
192
251
  var r0 = getInt32Memory0()[retptr / 4 + 0];
193
252
  var r1 = getInt32Memory0()[retptr / 4 + 1];
194
253
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -201,69 +260,170 @@ module.exports.transformSync = function(s, opts, experimental_plugin_bytes_resol
201
260
  }
202
261
  };
203
262
 
204
- module.exports.__wbindgen_json_parse = function(arg0, arg1) {
205
- var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
263
+ /**
264
+ * @param {any} s
265
+ * @param {any} opts
266
+ * @param {any} experimental_plugin_bytes_resolver
267
+ * @returns {Promise<any>}
268
+ */
269
+ module.exports.transform = function(s, opts, experimental_plugin_bytes_resolver) {
270
+ const ret = wasm.transform(addHeapObject(s), addHeapObject(opts), addHeapObject(experimental_plugin_bytes_resolver));
271
+ return takeObject(ret);
272
+ };
273
+
274
+ function getCachedStringFromWasm0(ptr, len) {
275
+ if (ptr === 0) {
276
+ return getObject(len);
277
+ } else {
278
+ return getStringFromWasm0(ptr, len);
279
+ }
280
+ }
281
+
282
+ function handleError(f, args) {
283
+ try {
284
+ return f.apply(this, args);
285
+ } catch (e) {
286
+ wasm.__wbindgen_exn_store(addHeapObject(e));
287
+ }
288
+ }
289
+ function __wbg_adapter_45(arg0, arg1, arg2, arg3) {
290
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h941e0353bb9b8983(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
291
+ }
292
+
293
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
294
+ takeObject(arg0);
295
+ };
296
+
297
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
298
+ const ret = getStringFromWasm0(arg0, arg1);
206
299
  return addHeapObject(ret);
207
300
  };
208
301
 
209
- module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
302
+ module.exports.__wbg_new_52205195aa880fc2 = function(arg0, arg1) {
303
+ try {
304
+ var state0 = {a: arg0, b: arg1};
305
+ var cb0 = (arg0, arg1) => {
306
+ const a = state0.a;
307
+ state0.a = 0;
308
+ try {
309
+ return __wbg_adapter_45(a, state0.b, arg0, arg1);
310
+ } finally {
311
+ state0.a = a;
312
+ }
313
+ };
314
+ const ret = new Promise(cb0);
315
+ return addHeapObject(ret);
316
+ } finally {
317
+ state0.a = state0.b = 0;
318
+ }
319
+ };
320
+
321
+ module.exports.__wbindgen_is_null = function(arg0) {
322
+ const ret = getObject(arg0) === null;
323
+ return ret;
324
+ };
325
+
326
+ module.exports.__wbindgen_is_undefined = function(arg0) {
327
+ const ret = getObject(arg0) === undefined;
328
+ return ret;
329
+ };
330
+
331
+ module.exports.__wbindgen_is_string = function(arg0) {
332
+ const ret = typeof(getObject(arg0)) === 'string';
333
+ return ret;
334
+ };
335
+
336
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
210
337
  const obj = getObject(arg1);
211
- var ret = JSON.stringify(obj === undefined ? null : obj);
212
- var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
338
+ const ret = typeof(obj) === 'string' ? obj : undefined;
339
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
213
340
  var len0 = WASM_VECTOR_LEN;
214
341
  getInt32Memory0()[arg0 / 4 + 1] = len0;
215
342
  getInt32Memory0()[arg0 / 4 + 0] = ptr0;
216
343
  };
217
344
 
218
- module.exports.__wbindgen_object_drop_ref = function(arg0) {
219
- takeObject(arg0);
345
+ module.exports.__wbg_call_65af9f665ab6ade5 = function() { return handleError(function (arg0, arg1, arg2) {
346
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
347
+ return addHeapObject(ret);
348
+ }, arguments) };
349
+
350
+ module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
351
+ const obj = getObject(arg1);
352
+ const ret = JSON.stringify(obj === undefined ? null : obj);
353
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
354
+ const len0 = WASM_VECTOR_LEN;
355
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
356
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
220
357
  };
221
358
 
222
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
223
- var ret = getStringFromWasm0(arg0, arg1);
359
+ module.exports.__wbindgen_json_parse = function(arg0, arg1) {
360
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
224
361
  return addHeapObject(ret);
225
362
  };
226
363
 
227
- module.exports.__wbg_new0_57a6a2c2aaed3fc5 = function() {
228
- var ret = new Date();
364
+ module.exports.__wbg_new0_adda2d4bcb124f0a = function() {
365
+ const ret = new Date();
229
366
  return addHeapObject(ret);
230
367
  };
231
368
 
232
- module.exports.__wbg_getTime_f8ce0ff902444efb = function(arg0) {
233
- var ret = getObject(arg0).getTime();
369
+ module.exports.__wbg_getTime_58b0bdbebd4ef11d = function(arg0) {
370
+ const ret = getObject(arg0).getTime();
234
371
  return ret;
235
372
  };
236
373
 
237
- module.exports.__wbg_getTimezoneOffset_41211a984662508b = function(arg0) {
238
- var ret = getObject(arg0).getTimezoneOffset();
374
+ module.exports.__wbg_getTimezoneOffset_8a39b51acb4f52c9 = function(arg0) {
375
+ const ret = getObject(arg0).getTimezoneOffset();
239
376
  return ret;
240
377
  };
241
378
 
242
379
  module.exports.__wbg_new_693216e109162396 = function() {
243
- var ret = new Error();
380
+ const ret = new Error();
244
381
  return addHeapObject(ret);
245
382
  };
246
383
 
247
384
  module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
248
- var ret = getObject(arg1).stack;
249
- var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
250
- var len0 = WASM_VECTOR_LEN;
385
+ const ret = getObject(arg1).stack;
386
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
387
+ const len0 = WASM_VECTOR_LEN;
251
388
  getInt32Memory0()[arg0 / 4 + 1] = len0;
252
389
  getInt32Memory0()[arg0 / 4 + 0] = ptr0;
253
390
  };
254
391
 
255
392
  module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
256
- try {
257
- console.error(getStringFromWasm0(arg0, arg1));
258
- } finally {
259
- wasm.__wbindgen_free(arg0, arg1);
260
- }
393
+ var v0 = getCachedStringFromWasm0(arg0, arg1);
394
+ if (arg0 !== 0) { wasm.__wbindgen_free(arg0, arg1); }
395
+ console.error(v0);
261
396
  };
262
397
 
263
398
  module.exports.__wbindgen_throw = function(arg0, arg1) {
264
399
  throw new Error(getStringFromWasm0(arg0, arg1));
265
400
  };
266
401
 
402
+ module.exports.__wbg_resolve_0107b3a501450ba0 = function(arg0) {
403
+ const ret = Promise.resolve(getObject(arg0));
404
+ return addHeapObject(ret);
405
+ };
406
+
407
+ module.exports.__wbindgen_cb_drop = function(arg0) {
408
+ const obj = takeObject(arg0).original;
409
+ if (obj.cnt-- == 1) {
410
+ obj.a = 0;
411
+ return true;
412
+ }
413
+ const ret = false;
414
+ return ret;
415
+ };
416
+
417
+ module.exports.__wbg_then_18da6e5453572fc8 = function(arg0, arg1) {
418
+ const ret = getObject(arg0).then(getObject(arg1));
419
+ return addHeapObject(ret);
420
+ };
421
+
422
+ module.exports.__wbindgen_closure_wrapper14169 = function(arg0, arg1, arg2) {
423
+ const ret = makeMutClosure(arg0, arg1, 154, __wbg_adapter_22);
424
+ return addHeapObject(ret);
425
+ };
426
+
267
427
  const path = require('path').join(__dirname, 'wasm_bg.wasm');
268
428
  const bytes = require('fs').readFileSync(path);
269
429
 
package/wasm_bg.wasm CHANGED
Binary file