@swc/wasm 1.2.221 → 1.2.224
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/package.json +1 -1
- package/wasm.d.ts +36 -21
- package/wasm.js +198 -40
- package/wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/wasm.d.ts
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
export function minify(src: string, opts?: JsMinifyOptions): Promise<Output>;
|
|
5
|
+
export function minifySync(code: string, opts?: JsMinifyOptions): Output;
|
|
6
|
+
|
|
7
|
+
export function parse(src: string, options: ParseOptions & {
|
|
8
|
+
isModule: false;
|
|
9
|
+
}): Promise<Script>;
|
|
10
|
+
export function parse(src: string, options?: ParseOptions): Promise<Module>;
|
|
11
|
+
export function parseSync(src: string, options: ParseOptions & {
|
|
12
|
+
isModule: false;
|
|
13
|
+
}): Script;
|
|
14
|
+
export function parseSync(src: string, options?: ParseOptions): Module;
|
|
15
|
+
|
|
16
|
+
export function print(m: Program, options?: Options): Promise<Output>;
|
|
17
|
+
export function printSync(m: Program, options?: Options): Output
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Note: this interface currently does not do _actual_ async work, only provides
|
|
21
|
+
* a corresponding async interfaces to the `@swc/core`'s interface.
|
|
22
|
+
*/
|
|
23
|
+
export function transform(
|
|
24
|
+
code: string | Program,
|
|
25
|
+
options?: Options,
|
|
26
|
+
experimental_plugin_bytes_resolver?: any
|
|
27
|
+
): Promise<Output>;
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} code
|
|
30
|
+
* @param {Options} opts
|
|
31
|
+
* @param {Record<string, ArrayBuffer>} experimental_plugin_bytes_resolver An object contains bytes array for the plugin
|
|
32
|
+
* specified in config. Key of record represents the name of the plugin specified in config. Note this is an experimental
|
|
33
|
+
* interface, likely will change.
|
|
34
|
+
* @returns {Output}
|
|
35
|
+
*/
|
|
36
|
+
export function transformSync(code: string | Program, opts?: Options, experimental_plugin_bytes_resolver?: any): Output;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
4
40
|
export interface Plugin {
|
|
5
41
|
(module: Program): Program;
|
|
6
42
|
}
|
|
@@ -2789,24 +2825,3 @@ export interface Invalid extends Node, HasSpan {
|
|
|
2789
2825
|
}
|
|
2790
2826
|
|
|
2791
2827
|
|
|
2792
|
-
|
|
2793
|
-
export function minifySync(code: string, opts?: JsMinifyOptions): Output;
|
|
2794
|
-
export function parseSync(
|
|
2795
|
-
src: string,
|
|
2796
|
-
options: ParseOptions & { isModule: false }
|
|
2797
|
-
): Script;
|
|
2798
|
-
export function parseSync(src: string, options?: ParseOptions): Module;
|
|
2799
|
-
export function parseSync(src: string, options?: ParseOptions): Program;
|
|
2800
|
-
export function printSync(m: Program, options?: Options): Output
|
|
2801
|
-
|
|
2802
|
-
/**
|
|
2803
|
-
* @param {string} code
|
|
2804
|
-
* @param {Options} opts
|
|
2805
|
-
* @param {Record<string, ArrayBuffer>} experimental_plugin_bytes_resolver An object contains bytes array for the plugin
|
|
2806
|
-
* specified in config. Key of record represents the name of the plugin specified in config. Note this is an experimental
|
|
2807
|
-
* interface, likely will change.
|
|
2808
|
-
* @returns {Output}
|
|
2809
|
-
*/
|
|
2810
|
-
export function transformSync(code: string, opts: Options, experimental_plugin_bytes_resolver?: any): Output;
|
|
2811
|
-
|
|
2812
|
-
|
package/wasm.js
CHANGED
|
@@ -3,6 +3,26 @@ 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();
|
|
@@ -20,12 +40,6 @@ function getStringFromWasm0(ptr, len) {
|
|
|
20
40
|
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
21
41
|
}
|
|
22
42
|
|
|
23
|
-
const heap = new Array(32).fill(undefined);
|
|
24
|
-
|
|
25
|
-
heap.push(undefined, null, true, false);
|
|
26
|
-
|
|
27
|
-
let heap_next = heap.length;
|
|
28
|
-
|
|
29
43
|
function addHeapObject(obj) {
|
|
30
44
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
31
45
|
const idx = heap_next;
|
|
@@ -35,8 +49,6 @@ function addHeapObject(obj) {
|
|
|
35
49
|
return idx;
|
|
36
50
|
}
|
|
37
51
|
|
|
38
|
-
function getObject(idx) { return heap[idx]; }
|
|
39
|
-
|
|
40
52
|
let WASM_VECTOR_LEN = 0;
|
|
41
53
|
|
|
42
54
|
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
@@ -92,6 +104,10 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
92
104
|
return ptr;
|
|
93
105
|
}
|
|
94
106
|
|
|
107
|
+
function isLikeNone(x) {
|
|
108
|
+
return x === undefined || x === null;
|
|
109
|
+
}
|
|
110
|
+
|
|
95
111
|
let cachedInt32Memory0 = new Int32Array();
|
|
96
112
|
|
|
97
113
|
function getInt32Memory0() {
|
|
@@ -101,17 +117,34 @@ function getInt32Memory0() {
|
|
|
101
117
|
return cachedInt32Memory0;
|
|
102
118
|
}
|
|
103
119
|
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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;
|
|
109
141
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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));
|
|
114
146
|
}
|
|
147
|
+
|
|
115
148
|
/**
|
|
116
149
|
* @param {string} s
|
|
117
150
|
* @param {any} opts
|
|
@@ -120,9 +153,7 @@ function takeObject(idx) {
|
|
|
120
153
|
module.exports.minifySync = function(s, opts) {
|
|
121
154
|
try {
|
|
122
155
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
123
|
-
|
|
124
|
-
const len0 = WASM_VECTOR_LEN;
|
|
125
|
-
wasm.minifySync(retptr, ptr0, len0, addHeapObject(opts));
|
|
156
|
+
wasm.minifySync(retptr, addHeapObject(s), addHeapObject(opts));
|
|
126
157
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
127
158
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
128
159
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -135,6 +166,16 @@ module.exports.minifySync = function(s, opts) {
|
|
|
135
166
|
}
|
|
136
167
|
};
|
|
137
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
|
+
|
|
138
179
|
/**
|
|
139
180
|
* @param {string} s
|
|
140
181
|
* @param {any} opts
|
|
@@ -143,9 +184,7 @@ module.exports.minifySync = function(s, opts) {
|
|
|
143
184
|
module.exports.parseSync = function(s, opts) {
|
|
144
185
|
try {
|
|
145
186
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
146
|
-
|
|
147
|
-
const len0 = WASM_VECTOR_LEN;
|
|
148
|
-
wasm.parseSync(retptr, ptr0, len0, addHeapObject(opts));
|
|
187
|
+
wasm.parseSync(retptr, addHeapObject(s), addHeapObject(opts));
|
|
149
188
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
150
189
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
151
190
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -158,6 +197,16 @@ module.exports.parseSync = function(s, opts) {
|
|
|
158
197
|
}
|
|
159
198
|
};
|
|
160
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
|
+
|
|
161
210
|
/**
|
|
162
211
|
* @param {any} s
|
|
163
212
|
* @param {any} opts
|
|
@@ -180,7 +229,17 @@ module.exports.printSync = function(s, opts) {
|
|
|
180
229
|
};
|
|
181
230
|
|
|
182
231
|
/**
|
|
183
|
-
* @param {
|
|
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
|
|
184
243
|
* @param {any} opts
|
|
185
244
|
* @param {any} experimental_plugin_bytes_resolver
|
|
186
245
|
* @returns {any}
|
|
@@ -188,9 +247,7 @@ module.exports.printSync = function(s, opts) {
|
|
|
188
247
|
module.exports.transformSync = function(s, opts, experimental_plugin_bytes_resolver) {
|
|
189
248
|
try {
|
|
190
249
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
191
|
-
|
|
192
|
-
const len0 = WASM_VECTOR_LEN;
|
|
193
|
-
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));
|
|
194
251
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
195
252
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
196
253
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -203,11 +260,93 @@ module.exports.transformSync = function(s, opts, experimental_plugin_bytes_resol
|
|
|
203
260
|
}
|
|
204
261
|
};
|
|
205
262
|
|
|
206
|
-
|
|
207
|
-
|
|
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);
|
|
208
299
|
return addHeapObject(ret);
|
|
209
300
|
};
|
|
210
301
|
|
|
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) {
|
|
337
|
+
const obj = getObject(arg1);
|
|
338
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
339
|
+
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
340
|
+
var len0 = WASM_VECTOR_LEN;
|
|
341
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
342
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
343
|
+
};
|
|
344
|
+
|
|
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
|
+
|
|
211
350
|
module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
|
|
212
351
|
const obj = getObject(arg1);
|
|
213
352
|
const ret = JSON.stringify(obj === undefined ? null : obj);
|
|
@@ -217,12 +356,8 @@ module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
|
|
|
217
356
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
218
357
|
};
|
|
219
358
|
|
|
220
|
-
module.exports.
|
|
221
|
-
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
225
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
359
|
+
module.exports.__wbindgen_json_parse = function(arg0, arg1) {
|
|
360
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
226
361
|
return addHeapObject(ret);
|
|
227
362
|
};
|
|
228
363
|
|
|
@@ -255,17 +390,40 @@ module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
|
|
|
255
390
|
};
|
|
256
391
|
|
|
257
392
|
module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
wasm.__wbindgen_free(arg0, arg1);
|
|
262
|
-
}
|
|
393
|
+
var v0 = getCachedStringFromWasm0(arg0, arg1);
|
|
394
|
+
if (arg0 !== 0) { wasm.__wbindgen_free(arg0, arg1); }
|
|
395
|
+
console.error(v0);
|
|
263
396
|
};
|
|
264
397
|
|
|
265
398
|
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
266
399
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
267
400
|
};
|
|
268
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_wrapper13563 = function(arg0, arg1, arg2) {
|
|
423
|
+
const ret = makeMutClosure(arg0, arg1, 153, __wbg_adapter_22);
|
|
424
|
+
return addHeapObject(ret);
|
|
425
|
+
};
|
|
426
|
+
|
|
269
427
|
const path = require('path').join(__dirname, 'wasm_bg.wasm');
|
|
270
428
|
const bytes = require('fs').readFileSync(path);
|
|
271
429
|
|
package/wasm_bg.wasm
CHANGED
|
Binary file
|