@@ -5,213 +5,241 @@ const heap = new Array(32).fill(undefined);
5
5
6
6
heap . push ( undefined , null , true , false ) ;
7
7
8
- function getObject ( idx ) { return heap [ idx ] ; }
8
+ function getObject ( idx ) {
9
+ return heap [ idx ] ;
10
+ }
9
11
10
12
let WASM_VECTOR_LEN = 0 ;
11
13
12
14
let cachegetUint8Memory0 = null ;
13
15
function getUint8Memory0 ( ) {
14
- if ( cachegetUint8Memory0 === null || cachegetUint8Memory0 . buffer !== wasm . memory . buffer ) {
15
- cachegetUint8Memory0 = new Uint8Array ( wasm . memory . buffer ) ;
16
- }
17
- return cachegetUint8Memory0 ;
16
+ if (
17
+ cachegetUint8Memory0 === null ||
18
+ cachegetUint8Memory0 . buffer !== wasm . memory . buffer
19
+ ) {
20
+ cachegetUint8Memory0 = new Uint8Array ( wasm . memory . buffer ) ;
21
+ }
22
+ return cachegetUint8Memory0 ;
18
23
}
19
24
20
- let cachedTextEncoder = new TextEncoder ( ' utf-8' ) ;
25
+ let cachedTextEncoder = new TextEncoder ( " utf-8" ) ;
21
26
22
- const encodeString = ( typeof cachedTextEncoder . encodeInto === 'function'
27
+ const encodeString =
28
+ ( typeof cachedTextEncoder . encodeInto === "function"
23
29
? function ( arg , view ) {
24
- return cachedTextEncoder . encodeInto ( arg , view ) ;
25
- }
30
+ return cachedTextEncoder . encodeInto ( arg , view ) ;
31
+ }
26
32
: function ( arg , view ) {
27
- const buf = cachedTextEncoder . encode ( arg ) ;
28
- view . set ( buf ) ;
29
- return {
33
+ const buf = cachedTextEncoder . encode ( arg ) ;
34
+ view . set ( buf ) ;
35
+ return {
30
36
read : arg . length ,
31
- written : buf . length
32
- } ;
33
- } ) ;
37
+ written : buf . length ,
38
+ } ;
39
+ } ) ;
34
40
35
41
function passStringToWasm0 ( arg , malloc , realloc ) {
42
+ if ( realloc === undefined ) {
43
+ const buf = cachedTextEncoder . encode ( arg ) ;
44
+ const ptr = malloc ( buf . length ) ;
45
+ getUint8Memory0 ( ) . subarray ( ptr , ptr + buf . length ) . set ( buf ) ;
46
+ WASM_VECTOR_LEN = buf . length ;
47
+ return ptr ;
48
+ }
36
49
37
- if ( realloc === undefined ) {
38
- const buf = cachedTextEncoder . encode ( arg ) ;
39
- const ptr = malloc ( buf . length ) ;
40
- getUint8Memory0 ( ) . subarray ( ptr , ptr + buf . length ) . set ( buf ) ;
41
- WASM_VECTOR_LEN = buf . length ;
42
- return ptr ;
43
- }
50
+ let len = arg . length ;
51
+ let ptr = malloc ( len ) ;
44
52
45
- let len = arg . length ;
46
- let ptr = malloc ( len ) ;
53
+ const mem = getUint8Memory0 ( ) ;
47
54
48
- const mem = getUint8Memory0 ( ) ;
55
+ let offset = 0 ;
49
56
50
- let offset = 0 ;
57
+ for ( ; offset < len ; offset ++ ) {
58
+ const code = arg . charCodeAt ( offset ) ;
59
+ if ( code > 0x7F ) break ;
60
+ mem [ ptr + offset ] = code ;
61
+ }
51
62
52
- for ( ; offset < len ; offset ++ ) {
53
- const code = arg . charCodeAt ( offset ) ;
54
- if ( code > 0x7F ) break ;
55
- mem [ ptr + offset ] = code ;
63
+ if ( offset !== len ) {
64
+ if ( offset !== 0 ) {
65
+ arg = arg . slice ( offset ) ;
56
66
}
67
+ ptr = realloc ( ptr , len , len = offset + arg . length * 3 ) ;
68
+ const view = getUint8Memory0 ( ) . subarray ( ptr + offset , ptr + len ) ;
69
+ const ret = encodeString ( arg , view ) ;
57
70
58
- if ( offset !== len ) {
59
- if ( offset !== 0 ) {
60
- arg = arg . slice ( offset ) ;
61
- }
62
- ptr = realloc ( ptr , len , len = offset + arg . length * 3 ) ;
63
- const view = getUint8Memory0 ( ) . subarray ( ptr + offset , ptr + len ) ;
64
- const ret = encodeString ( arg , view ) ;
65
-
66
- offset += ret . written ;
67
- }
71
+ offset += ret . written ;
72
+ }
68
73
69
- WASM_VECTOR_LEN = offset ;
70
- return ptr ;
74
+ WASM_VECTOR_LEN = offset ;
75
+ return ptr ;
71
76
}
72
77
73
78
let cachegetInt32Memory0 = null ;
74
79
function getInt32Memory0 ( ) {
75
- if ( cachegetInt32Memory0 === null || cachegetInt32Memory0 . buffer !== wasm . memory . buffer ) {
76
- cachegetInt32Memory0 = new Int32Array ( wasm . memory . buffer ) ;
77
- }
78
- return cachegetInt32Memory0 ;
80
+ if (
81
+ cachegetInt32Memory0 === null ||
82
+ cachegetInt32Memory0 . buffer !== wasm . memory . buffer
83
+ ) {
84
+ cachegetInt32Memory0 = new Int32Array ( wasm . memory . buffer ) ;
85
+ }
86
+ return cachegetInt32Memory0 ;
79
87
}
80
88
81
89
let heap_next = heap . length ;
82
90
83
91
function dropObject ( idx ) {
84
- if ( idx < 36 ) return ;
85
- heap [ idx ] = heap_next ;
86
- heap_next = idx ;
92
+ if ( idx < 36 ) return ;
93
+ heap [ idx ] = heap_next ;
94
+ heap_next = idx ;
87
95
}
88
96
89
97
function takeObject ( idx ) {
90
- const ret = getObject ( idx ) ;
91
- dropObject ( idx ) ;
92
- return ret ;
98
+ const ret = getObject ( idx ) ;
99
+ dropObject ( idx ) ;
100
+ return ret ;
93
101
}
94
102
95
- let cachedTextDecoder = new TextDecoder ( 'utf-8' , { ignoreBOM : true , fatal : true } ) ;
103
+ let cachedTextDecoder = new TextDecoder ( "utf-8" , {
104
+ ignoreBOM : true ,
105
+ fatal : true ,
106
+ } ) ;
96
107
97
108
cachedTextDecoder . decode ( ) ;
98
109
99
110
function getStringFromWasm0 ( ptr , len ) {
100
- return cachedTextDecoder . decode ( getUint8Memory0 ( ) . subarray ( ptr , ptr + len ) ) ;
111
+ return cachedTextDecoder . decode ( getUint8Memory0 ( ) . subarray ( ptr , ptr + len ) ) ;
101
112
}
102
113
103
114
function addHeapObject ( obj ) {
104
- if ( heap_next === heap . length ) heap . push ( heap . length + 1 ) ;
105
- const idx = heap_next ;
106
- heap_next = heap [ idx ] ;
115
+ if ( heap_next === heap . length ) heap . push ( heap . length + 1 ) ;
116
+ const idx = heap_next ;
117
+ heap_next = heap [ idx ] ;
107
118
108
- heap [ idx ] = obj ;
109
- return idx ;
119
+ heap [ idx ] = obj ;
120
+ return idx ;
110
121
}
111
122
/**
112
- * @param {string } s
113
- * @param {any } opts
123
+ * @param {string } url
124
+ * @param {string } code
125
+ * @param {any } options
114
126
* @returns {any }
115
127
*/
116
- export function transformSync ( s , opts ) {
117
- var ptr0 = passStringToWasm0 ( s , wasm . __wbindgen_malloc , wasm . __wbindgen_realloc ) ;
118
- var len0 = WASM_VECTOR_LEN ;
119
- var ret = wasm . transformSync ( ptr0 , len0 , addHeapObject ( opts ) ) ;
120
- return takeObject ( ret ) ;
128
+ export function transformSync ( url , code , options ) {
129
+ var ptr0 = passStringToWasm0 (
130
+ url ,
131
+ wasm . __wbindgen_malloc ,
132
+ wasm . __wbindgen_realloc ,
133
+ ) ;
134
+ var len0 = WASM_VECTOR_LEN ;
135
+ var ptr1 = passStringToWasm0 (
136
+ code ,
137
+ wasm . __wbindgen_malloc ,
138
+ wasm . __wbindgen_realloc ,
139
+ ) ;
140
+ var len1 = WASM_VECTOR_LEN ;
141
+ var ret = wasm . transformSync ( ptr0 , len0 , ptr1 , len1 , addHeapObject ( options ) ) ;
142
+ return takeObject ( ret ) ;
121
143
}
122
144
123
145
async function load ( module , imports ) {
124
- if ( typeof Response === 'function' && module instanceof Response ) {
125
-
126
- if ( typeof WebAssembly . instantiateStreaming === 'function' ) {
127
- try {
128
- return await WebAssembly . instantiateStreaming ( module , imports ) ;
129
-
130
- } catch ( e ) {
131
- if ( module . headers . get ( 'Content-Type' ) != 'application/wasm' ) {
132
- console . warn ( "`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n" , e ) ;
133
-
134
- } else {
135
- throw e ;
136
- }
137
- }
146
+ if ( typeof Response === "function" && module instanceof Response ) {
147
+ if ( typeof WebAssembly . instantiateStreaming === "function" ) {
148
+ try {
149
+ return await WebAssembly . instantiateStreaming ( module , imports ) ;
150
+ } catch ( e ) {
151
+ if ( module . headers . get ( "Content-Type" ) != "application/wasm" ) {
152
+ console . warn (
153
+ "`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n" ,
154
+ e ,
155
+ ) ;
156
+ } else {
157
+ throw e ;
138
158
}
159
+ }
160
+ }
139
161
140
- const bytes = await module . arrayBuffer ( ) ;
141
- return await WebAssembly . instantiate ( bytes , imports ) ;
162
+ const bytes = await module . arrayBuffer ( ) ;
163
+ return await WebAssembly . instantiate ( bytes , imports ) ;
164
+ } else {
165
+ const instance = await WebAssembly . instantiate ( module , imports ) ;
142
166
167
+ if ( instance instanceof WebAssembly . Instance ) {
168
+ return { instance, module } ;
143
169
} else {
144
-
145
- const instance = await WebAssembly . instantiate ( module , imports ) ;
146
-
147
- if ( instance instanceof WebAssembly . Instance ) {
148
- return { instance, module } ;
149
-
150
- } else {
151
- return instance ;
152
- }
170
+ return instance ;
153
171
}
172
+ }
154
173
}
155
174
156
175
async function init ( input ) {
157
- if ( typeof input === 'undefined' ) {
158
- input = import . meta. url . replace ( / \. j s $ / , '_bg.wasm' ) ;
176
+ if ( typeof input === "undefined" ) {
177
+ input = import . meta. url . replace ( / \. j s $ / , "_bg.wasm" ) ;
178
+ }
179
+ const imports = { } ;
180
+ imports . wbg = { } ;
181
+ imports . wbg . __wbindgen_json_serialize = function ( arg0 , arg1 ) {
182
+ const obj = getObject ( arg1 ) ;
183
+ var ret = JSON . stringify ( obj === undefined ? null : obj ) ;
184
+ var ptr0 = passStringToWasm0 (
185
+ ret ,
186
+ wasm . __wbindgen_malloc ,
187
+ wasm . __wbindgen_realloc ,
188
+ ) ;
189
+ var len0 = WASM_VECTOR_LEN ;
190
+ getInt32Memory0 ( ) [ arg0 / 4 + 1 ] = len0 ;
191
+ getInt32Memory0 ( ) [ arg0 / 4 + 0 ] = ptr0 ;
192
+ } ;
193
+ imports . wbg . __wbindgen_object_drop_ref = function ( arg0 ) {
194
+ takeObject ( arg0 ) ;
195
+ } ;
196
+ imports . wbg . __wbindgen_json_parse = function ( arg0 , arg1 ) {
197
+ var ret = JSON . parse ( getStringFromWasm0 ( arg0 , arg1 ) ) ;
198
+ return addHeapObject ( ret ) ;
199
+ } ;
200
+ imports . wbg . __wbg_new_59cb74e423758ede = function ( ) {
201
+ var ret = new Error ( ) ;
202
+ return addHeapObject ( ret ) ;
203
+ } ;
204
+ imports . wbg . __wbg_stack_558ba5917b466edd = function ( arg0 , arg1 ) {
205
+ var ret = getObject ( arg1 ) . stack ;
206
+ var ptr0 = passStringToWasm0 (
207
+ ret ,
208
+ wasm . __wbindgen_malloc ,
209
+ wasm . __wbindgen_realloc ,
210
+ ) ;
211
+ var len0 = WASM_VECTOR_LEN ;
212
+ getInt32Memory0 ( ) [ arg0 / 4 + 1 ] = len0 ;
213
+ getInt32Memory0 ( ) [ arg0 / 4 + 0 ] = ptr0 ;
214
+ } ;
215
+ imports . wbg . __wbg_error_4bb6c2a97407129a = function ( arg0 , arg1 ) {
216
+ try {
217
+ const msg = getStringFromWasm0 ( arg0 , arg1 ) ;
218
+ if ( msg . includes ( 'DiagnosticBuffer(["' ) ) {
219
+ const diagnostic = msg . split ( 'DiagnosticBuffer(["' ) [ 1 ] . split ( '"])' ) [ 0 ] ;
220
+ log . error ( "swc:" , diagnostic ) ;
221
+ } else {
222
+ log . error ( msg ) ;
223
+ }
224
+ } finally {
225
+ wasm . __wbindgen_free ( arg0 , arg1 ) ;
159
226
}
160
- const imports = { } ;
161
- imports . wbg = { } ;
162
- imports . wbg . __wbindgen_json_serialize = function ( arg0 , arg1 ) {
163
- const obj = getObject ( arg1 ) ;
164
- var ret = JSON . stringify ( obj === undefined ? null : obj ) ;
165
- var ptr0 = passStringToWasm0 ( ret , wasm . __wbindgen_malloc , wasm . __wbindgen_realloc ) ;
166
- var len0 = WASM_VECTOR_LEN ;
167
- getInt32Memory0 ( ) [ arg0 / 4 + 1 ] = len0 ;
168
- getInt32Memory0 ( ) [ arg0 / 4 + 0 ] = ptr0 ;
169
- } ;
170
- imports . wbg . __wbindgen_object_drop_ref = function ( arg0 ) {
171
- takeObject ( arg0 ) ;
172
- } ;
173
- imports . wbg . __wbindgen_json_parse = function ( arg0 , arg1 ) {
174
- var ret = JSON . parse ( getStringFromWasm0 ( arg0 , arg1 ) ) ;
175
- return addHeapObject ( ret ) ;
176
- } ;
177
- imports . wbg . __wbg_new_59cb74e423758ede = function ( ) {
178
- var ret = new Error ( ) ;
179
- return addHeapObject ( ret ) ;
180
- } ;
181
- imports . wbg . __wbg_stack_558ba5917b466edd = function ( arg0 , arg1 ) {
182
- var ret = getObject ( arg1 ) . stack ;
183
- var ptr0 = passStringToWasm0 ( ret , wasm . __wbindgen_malloc , wasm . __wbindgen_realloc ) ;
184
- var len0 = WASM_VECTOR_LEN ;
185
- getInt32Memory0 ( ) [ arg0 / 4 + 1 ] = len0 ;
186
- getInt32Memory0 ( ) [ arg0 / 4 + 0 ] = ptr0 ;
187
- } ;
188
- imports . wbg . __wbg_error_4bb6c2a97407129a = function ( arg0 , arg1 ) {
189
- try {
190
-
191
- const msg = getStringFromWasm0 ( arg0 , arg1 ) ;
192
- if ( msg . includes ( "DiagnosticBuffer" ) ) {
193
- const diagnostic = msg . split ( 'DiagnosticBuffer(["' ) [ 1 ] . split ( '"])' ) [ 0 ]
194
- log . error ( "swc:" , diagnostic )
195
- } else {
196
- log . error ( msg )
197
- }
198
-
199
- } finally {
200
- wasm . __wbindgen_free ( arg0 , arg1 ) ;
201
- }
202
- } ;
227
+ } ;
203
228
204
- if ( typeof input === 'string' || ( typeof Request === 'function' && input instanceof Request ) || ( typeof URL === 'function' && input instanceof URL ) ) {
205
- input = fetch ( input ) ;
206
- }
229
+ if (
230
+ typeof input === "string" ||
231
+ ( typeof Request === "function" && input instanceof Request ) ||
232
+ ( typeof URL === "function" && input instanceof URL )
233
+ ) {
234
+ input = fetch ( input ) ;
235
+ }
207
236
208
- const { instance, module } = await load ( await input , imports ) ;
237
+ const { instance, module } = await load ( await input , imports ) ;
209
238
210
- wasm = instance . exports ;
211
- init . __wbindgen_wasm_module = module ;
239
+ wasm = instance . exports ;
240
+ init . __wbindgen_wasm_module = module ;
212
241
213
- return wasm ;
242
+ return wasm ;
214
243
}
215
244
216
245
export default init ;
217
-
0 commit comments