@swc/wasm-web 1.2.221 → 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/package.json +1 -1
- package/wasm-web.d.ts +39 -16
- package/wasm-web.js +193 -45
- package/wasm-web_bg.wasm +0 -0
package/package.json
CHANGED
package/wasm-web.d.ts
CHANGED
|
@@ -2790,24 +2790,39 @@ export interface Invalid extends Node, HasSpan {
|
|
|
2790
2790
|
|
|
2791
2791
|
|
|
2792
2792
|
|
|
2793
|
+
export function minify(src: string, opts?: JsMinifyOptions): Promise<Output>;
|
|
2793
2794
|
export function minifySync(code: string, opts?: JsMinifyOptions): Output;
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2795
|
+
|
|
2796
|
+
export function parse(src: string, options: ParseOptions & {
|
|
2797
|
+
isModule: false;
|
|
2798
|
+
}): Promise<Script>;
|
|
2799
|
+
export function parse(src: string, options?: ParseOptions): Promise<Module>;
|
|
2800
|
+
export function parseSync(src: string, options: ParseOptions & {
|
|
2801
|
+
isModule: false;
|
|
2802
|
+
}): Script;
|
|
2798
2803
|
export function parseSync(src: string, options?: ParseOptions): Module;
|
|
2799
|
-
|
|
2804
|
+
|
|
2805
|
+
export function print(m: Program, options?: Options): Promise<Output>;
|
|
2800
2806
|
export function printSync(m: Program, options?: Options): Output
|
|
2801
2807
|
|
|
2802
2808
|
/**
|
|
2803
|
-
*
|
|
2804
|
-
*
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2809
|
+
* Note: this interface currently does not do _actual_ async work, only provides
|
|
2810
|
+
* a corresponding async interfaces to the `@swc/core`'s interface.
|
|
2811
|
+
*/
|
|
2812
|
+
export function transform(
|
|
2813
|
+
code: string | Program,
|
|
2814
|
+
options?: Options,
|
|
2815
|
+
experimental_plugin_bytes_resolver?: any
|
|
2816
|
+
): Promise<Output>;
|
|
2817
|
+
/**
|
|
2818
|
+
* @param {string} code
|
|
2819
|
+
* @param {Options} opts
|
|
2820
|
+
* @param {Record<string, ArrayBuffer>} experimental_plugin_bytes_resolver An object contains bytes array for the plugin
|
|
2821
|
+
* specified in config. Key of record represents the name of the plugin specified in config. Note this is an experimental
|
|
2822
|
+
* interface, likely will change.
|
|
2823
|
+
* @returns {Output}
|
|
2824
|
+
*/
|
|
2825
|
+
export function transformSync(code: string | Program, opts?: Options, experimental_plugin_bytes_resolver?: any): Output;
|
|
2811
2826
|
|
|
2812
2827
|
|
|
2813
2828
|
|
|
@@ -2815,14 +2830,22 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
2815
2830
|
|
|
2816
2831
|
export interface InitOutput {
|
|
2817
2832
|
readonly memory: WebAssembly.Memory;
|
|
2818
|
-
readonly minifySync: (a: number, b: number, c: number
|
|
2819
|
-
readonly
|
|
2833
|
+
readonly minifySync: (a: number, b: number, c: number) => void;
|
|
2834
|
+
readonly minify: (a: number, b: number) => number;
|
|
2835
|
+
readonly parseSync: (a: number, b: number, c: number) => void;
|
|
2836
|
+
readonly parse: (a: number, b: number) => number;
|
|
2820
2837
|
readonly printSync: (a: number, b: number, c: number) => void;
|
|
2821
|
-
readonly
|
|
2838
|
+
readonly print: (a: number, b: number) => number;
|
|
2839
|
+
readonly transformSync: (a: number, b: number, c: number, d: number) => void;
|
|
2840
|
+
readonly transform: (a: number, b: number, c: number) => number;
|
|
2822
2841
|
readonly __wbindgen_malloc: (a: number) => number;
|
|
2823
2842
|
readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
|
|
2843
|
+
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
2844
|
+
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h474a5d2341fab4ae: (a: number, b: number, c: number) => void;
|
|
2824
2845
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
2825
2846
|
readonly __wbindgen_free: (a: number, b: number) => void;
|
|
2847
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
2848
|
+
readonly wasm_bindgen__convert__closures__invoke2_mut__h941e0353bb9b8983: (a: number, b: number, c: number, d: number) => void;
|
|
2826
2849
|
}
|
|
2827
2850
|
|
|
2828
2851
|
/**
|
package/wasm-web.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
|
|
2
2
|
let wasm;
|
|
3
3
|
|
|
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
|
+
|
|
4
24
|
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
5
25
|
|
|
6
26
|
cachedTextDecoder.decode();
|
|
@@ -18,12 +38,6 @@ function getStringFromWasm0(ptr, len) {
|
|
|
18
38
|
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
19
39
|
}
|
|
20
40
|
|
|
21
|
-
const heap = new Array(32).fill(undefined);
|
|
22
|
-
|
|
23
|
-
heap.push(undefined, null, true, false);
|
|
24
|
-
|
|
25
|
-
let heap_next = heap.length;
|
|
26
|
-
|
|
27
41
|
function addHeapObject(obj) {
|
|
28
42
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
29
43
|
const idx = heap_next;
|
|
@@ -33,8 +47,6 @@ function addHeapObject(obj) {
|
|
|
33
47
|
return idx;
|
|
34
48
|
}
|
|
35
49
|
|
|
36
|
-
function getObject(idx) { return heap[idx]; }
|
|
37
|
-
|
|
38
50
|
let WASM_VECTOR_LEN = 0;
|
|
39
51
|
|
|
40
52
|
const cachedTextEncoder = new TextEncoder('utf-8');
|
|
@@ -90,6 +102,10 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
90
102
|
return ptr;
|
|
91
103
|
}
|
|
92
104
|
|
|
105
|
+
function isLikeNone(x) {
|
|
106
|
+
return x === undefined || x === null;
|
|
107
|
+
}
|
|
108
|
+
|
|
93
109
|
let cachedInt32Memory0 = new Int32Array();
|
|
94
110
|
|
|
95
111
|
function getInt32Memory0() {
|
|
@@ -99,17 +115,34 @@ function getInt32Memory0() {
|
|
|
99
115
|
return cachedInt32Memory0;
|
|
100
116
|
}
|
|
101
117
|
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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);
|
|
107
132
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
133
|
+
} else {
|
|
134
|
+
state.a = a;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
real.original = state;
|
|
139
|
+
|
|
140
|
+
return real;
|
|
112
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
|
+
|
|
113
146
|
/**
|
|
114
147
|
* @param {string} s
|
|
115
148
|
* @param {any} opts
|
|
@@ -118,9 +151,7 @@ function takeObject(idx) {
|
|
|
118
151
|
export function minifySync(s, opts) {
|
|
119
152
|
try {
|
|
120
153
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
121
|
-
|
|
122
|
-
const len0 = WASM_VECTOR_LEN;
|
|
123
|
-
wasm.minifySync(retptr, ptr0, len0, addHeapObject(opts));
|
|
154
|
+
wasm.minifySync(retptr, addHeapObject(s), addHeapObject(opts));
|
|
124
155
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
125
156
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
126
157
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -133,6 +164,16 @@ export function minifySync(s, opts) {
|
|
|
133
164
|
}
|
|
134
165
|
}
|
|
135
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
|
+
|
|
136
177
|
/**
|
|
137
178
|
* @param {string} s
|
|
138
179
|
* @param {any} opts
|
|
@@ -141,9 +182,7 @@ export function minifySync(s, opts) {
|
|
|
141
182
|
export function parseSync(s, opts) {
|
|
142
183
|
try {
|
|
143
184
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
144
|
-
|
|
145
|
-
const len0 = WASM_VECTOR_LEN;
|
|
146
|
-
wasm.parseSync(retptr, ptr0, len0, addHeapObject(opts));
|
|
185
|
+
wasm.parseSync(retptr, addHeapObject(s), addHeapObject(opts));
|
|
147
186
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
148
187
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
149
188
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -156,6 +195,16 @@ export function parseSync(s, opts) {
|
|
|
156
195
|
}
|
|
157
196
|
}
|
|
158
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
|
+
|
|
159
208
|
/**
|
|
160
209
|
* @param {any} s
|
|
161
210
|
* @param {any} opts
|
|
@@ -178,7 +227,17 @@ export function printSync(s, opts) {
|
|
|
178
227
|
}
|
|
179
228
|
|
|
180
229
|
/**
|
|
181
|
-
* @param {
|
|
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
|
|
182
241
|
* @param {any} opts
|
|
183
242
|
* @param {any} experimental_plugin_bytes_resolver
|
|
184
243
|
* @returns {any}
|
|
@@ -186,9 +245,7 @@ export function printSync(s, opts) {
|
|
|
186
245
|
export function transformSync(s, opts, experimental_plugin_bytes_resolver) {
|
|
187
246
|
try {
|
|
188
247
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
189
|
-
|
|
190
|
-
const len0 = WASM_VECTOR_LEN;
|
|
191
|
-
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));
|
|
192
249
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
193
250
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
194
251
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -201,6 +258,36 @@ export function transformSync(s, opts, experimental_plugin_bytes_resolver) {
|
|
|
201
258
|
}
|
|
202
259
|
}
|
|
203
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
|
+
|
|
204
291
|
async function load(module, imports) {
|
|
205
292
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
206
293
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
@@ -235,10 +322,55 @@ async function load(module, imports) {
|
|
|
235
322
|
function getImports() {
|
|
236
323
|
const imports = {};
|
|
237
324
|
imports.wbg = {};
|
|
238
|
-
imports.wbg.
|
|
239
|
-
|
|
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);
|
|
240
330
|
return addHeapObject(ret);
|
|
241
331
|
};
|
|
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) {
|
|
363
|
+
const obj = getObject(arg1);
|
|
364
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
365
|
+
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
366
|
+
var len0 = WASM_VECTOR_LEN;
|
|
367
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
368
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
369
|
+
};
|
|
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) };
|
|
242
374
|
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
|
|
243
375
|
const obj = getObject(arg1);
|
|
244
376
|
const ret = JSON.stringify(obj === undefined ? null : obj);
|
|
@@ -247,11 +379,8 @@ function getImports() {
|
|
|
247
379
|
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
248
380
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
249
381
|
};
|
|
250
|
-
imports.wbg.
|
|
251
|
-
|
|
252
|
-
};
|
|
253
|
-
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
254
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
382
|
+
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
|
|
383
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
255
384
|
return addHeapObject(ret);
|
|
256
385
|
};
|
|
257
386
|
imports.wbg.__wbg_new0_adda2d4bcb124f0a = function() {
|
|
@@ -278,17 +407,36 @@ function getImports() {
|
|
|
278
407
|
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
279
408
|
};
|
|
280
409
|
imports.wbg.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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;
|
|
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;
|
|
292
440
|
}
|
|
293
441
|
|
|
294
442
|
function initMemory(imports, maybe_memory) {
|
package/wasm-web_bg.wasm
CHANGED
|
Binary file
|