@bytecodealliance/jco 1.2.4 → 1.3.0

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/README.md CHANGED
@@ -25,15 +25,13 @@ Jco provides a fully native JS toolchain for working with [WebAssembly Component
25
25
  Features include:
26
26
 
27
27
  * "Transpiling" Wasm Component binaries into ES modules that can run in any JS environment.
28
- * WASI Preview2 support in Node.js ([undergoing stabilization](https://github.com/bytecodealliance/jco/milestone/1)) & browsers (experimental).
28
+ * WASI Preview2 support in Node.js & browsers (experimental).
29
29
  * Component builds of [Wasm Tools](https://github.com/bytecodealliance/wasm-tools) helpers, available for use as a library or CLI commands for use in native JS environments, as well as optimization helper for Components via Binaryen.
30
30
  * Run and serve commands like Wasmtime, as JS implementations of the Command and HTTP Proxy worlds.
31
31
  * "Componentize" command to easily create components written in JavaScript (wrapper of [ComponentizeJS](https://github.com/bytecodealliance/ComponentizeJS)).
32
32
 
33
33
  For creating components in other languages, see the [Cargo Component](https://github.com/bytecodealliance/cargo-Component) project for Rust and [Wit Bindgen](https://github.com/bytecodealliance/wit-bindgen) for various guest bindgen helpers.
34
34
 
35
- > **Note**: This is an experimental project, no guarantees are provided for stability, security or support and breaking changes may be made without notice.
36
-
37
35
  ## Installation
38
36
 
39
37
  ```shell
@@ -61,8 +59,9 @@ Options:
61
59
  Commands:
62
60
  componentize [options] <js-source> Create a component from a JavaScript module
63
61
  transpile [options] <component-path> Transpile a WebAssembly Component to JS + core Wasm for JavaScript execution
62
+ types [options] <wit-path> Generate types for the given WIT
64
63
  run [options] <command> [args...] Run a WASI Command component
65
- serve [options] <command> [args...] Serve a WASI HTTP component
64
+ serve [options] <server> [args...] Serve a WASI HTTP component
66
65
  opt [options] <component-file> optimizes a Wasm component, including running wasm-opt Binaryen optimizations
67
66
  wit [options] <component-path> extract the WIT from a WebAssembly Component [wasm-tools component wit]
68
67
  print [options] <input> print the WebAssembly WAT text for a binary file [wasm-tools print]
@@ -116,7 +115,7 @@ Options include:
116
115
 
117
116
  #### Bindgen Crate
118
117
 
119
- To directly call into the transpilation in Rust, the bindgen used in jco is also available on crates.io as [js-component-bindgen](https://crates.io/crates/js-component-bindgen).
118
+ To directly call into the transpilation in Rust, the bindgen used in Jco is also available on crates.io as [js-component-bindgen](https://crates.io/crates/js-component-bindgen).
120
119
 
121
120
  ### Run & Serve
122
121
 
@@ -138,6 +137,8 @@ jco serve --port 8080 server.wasm
138
137
 
139
138
  ### Componentize
140
139
 
140
+ > **Note**: `jco componentize` is considered experimental, and breaking changes may be made without notice.
141
+
141
142
  To componentize a JS file run:
142
143
 
143
144
  ```
@@ -190,7 +191,7 @@ Add new producer metadata to a component or core Wasm binary.
190
191
 
191
192
  ## Contributing
192
193
 
193
- See the [Contributing](docs/src/contributing.md) chapter of the jco book.
194
+ See the [Contributing](docs/src/contributing.md) chapter of the Jco book.
194
195
 
195
196
  # License
196
197
 
@@ -113,19 +113,10 @@ function utf8Encode(s, realloc, memory) {
113
113
  utf8EncodedLen = 0;
114
114
  return 1;
115
115
  }
116
- let allocLen = 0;
117
- let ptr = 0;
118
- let writtenTotal = 0;
119
- while (s.length > 0) {
120
- ptr = realloc(ptr, allocLen, 1, allocLen += s.length * 2);
121
- const { read, written } = utf8Encoder.encodeInto(
122
- s,
123
- new Uint8Array(memory.buffer, ptr + writtenTotal, allocLen - writtenTotal),
124
- );
125
- writtenTotal += written;
126
- s = s.slice(read);
127
- }
128
- utf8EncodedLen = writtenTotal;
116
+ let buf = utf8Encoder.encode(s);
117
+ let ptr = realloc(0, 0, 1, buf.length);
118
+ new Uint8Array(memory.buffer).set(buf, ptr);
119
+ utf8EncodedLen = buf.length;
129
120
  return ptr;
130
121
  }
131
122
 
@@ -150,36 +141,12 @@ function trampoline5() {
150
141
  }
151
142
  return handle0;
152
143
  }
153
-
154
- function trampoline6(arg0) {
155
- let variant0;
156
- switch (arg0) {
157
- case 0: {
158
- variant0= {
159
- tag: 'ok',
160
- val: undefined
161
- };
162
- break;
163
- }
164
- case 1: {
165
- variant0= {
166
- tag: 'err',
167
- val: undefined
168
- };
169
- break;
170
- }
171
- default: {
172
- throw new TypeError('invalid variant discriminant for expected');
173
- }
174
- }
175
- exit(variant0);
176
- }
177
144
  const handleTable1 = [T_FLAG, 0];
178
145
  const captureTable1= new Map();
179
146
  let captureCnt1 = 0;
180
147
  handleTables[1] = handleTable1;
181
148
 
182
- function trampoline7() {
149
+ function trampoline8() {
183
150
  const ret = getStdin();
184
151
  if (!(ret instanceof InputStream)) {
185
152
  throw new TypeError('Resource error: Not a valid "InputStream" resource.');
@@ -193,7 +160,7 @@ function trampoline7() {
193
160
  return handle0;
194
161
  }
195
162
 
196
- function trampoline8() {
163
+ function trampoline9() {
197
164
  const ret = getStdout();
198
165
  if (!(ret instanceof OutputStream)) {
199
166
  throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
@@ -206,40 +173,58 @@ function trampoline8() {
206
173
  }
207
174
  return handle0;
208
175
  }
176
+
177
+ function trampoline10(arg0) {
178
+ let variant0;
179
+ switch (arg0) {
180
+ case 0: {
181
+ variant0= {
182
+ tag: 'ok',
183
+ val: undefined
184
+ };
185
+ break;
186
+ }
187
+ case 1: {
188
+ variant0= {
189
+ tag: 'err',
190
+ val: undefined
191
+ };
192
+ break;
193
+ }
194
+ default: {
195
+ throw new TypeError('invalid variant discriminant for expected');
196
+ }
197
+ }
198
+ exit(variant0);
199
+ }
209
200
  let exports2;
210
201
  let memory0;
211
202
  let realloc0;
212
- const handleTable5 = [T_FLAG, 0];
213
- const captureTable5= new Map();
214
- let captureCnt5 = 0;
215
- handleTables[5] = handleTable5;
216
203
 
217
204
  function trampoline11(arg0) {
218
- const ret = getDirectories();
205
+ const ret = getEnvironment();
219
206
  var vec3 = ret;
220
207
  var len3 = vec3.length;
221
- var result3 = realloc0(0, 0, 4, len3 * 12);
208
+ var result3 = realloc0(0, 0, 4, len3 * 16);
222
209
  for (let i = 0; i < vec3.length; i++) {
223
210
  const e = vec3[i];
224
- const base = result3 + i * 12;var [tuple0_0, tuple0_1] = e;
225
- if (!(tuple0_0 instanceof Descriptor)) {
226
- throw new TypeError('Resource error: Not a valid "Descriptor" resource.');
227
- }
228
- var handle1 = tuple0_0[symbolRscHandle];
229
- if (!handle1) {
230
- const rep = tuple0_0[symbolRscRep] || ++captureCnt5;
231
- captureTable5.set(rep, tuple0_0);
232
- handle1 = rscTableCreateOwn(handleTable5, rep);
233
- }
234
- dataView(memory0).setInt32(base + 0, handle1, true);
211
+ const base = result3 + i * 16;var [tuple0_0, tuple0_1] = e;
212
+ var ptr1 = utf8Encode(tuple0_0, realloc0, memory0);
213
+ var len1 = utf8EncodedLen;
214
+ dataView(memory0).setInt32(base + 4, len1, true);
215
+ dataView(memory0).setInt32(base + 0, ptr1, true);
235
216
  var ptr2 = utf8Encode(tuple0_1, realloc0, memory0);
236
217
  var len2 = utf8EncodedLen;
237
- dataView(memory0).setInt32(base + 8, len2, true);
238
- dataView(memory0).setInt32(base + 4, ptr2, true);
218
+ dataView(memory0).setInt32(base + 12, len2, true);
219
+ dataView(memory0).setInt32(base + 8, ptr2, true);
239
220
  }
240
221
  dataView(memory0).setInt32(arg0 + 4, len3, true);
241
222
  dataView(memory0).setInt32(arg0 + 0, result3, true);
242
223
  }
224
+ const handleTable5 = [T_FLAG, 0];
225
+ const captureTable5= new Map();
226
+ let captureCnt5 = 0;
227
+ handleTables[5] = handleTable5;
243
228
 
244
229
  function trampoline12(arg0, arg1, arg2) {
245
230
  var handle1 = arg0;
@@ -3379,21 +3364,27 @@ function trampoline30(arg0, arg1) {
3379
3364
  }
3380
3365
 
3381
3366
  function trampoline31(arg0) {
3382
- const ret = getEnvironment();
3367
+ const ret = getDirectories();
3383
3368
  var vec3 = ret;
3384
3369
  var len3 = vec3.length;
3385
- var result3 = realloc0(0, 0, 4, len3 * 16);
3370
+ var result3 = realloc0(0, 0, 4, len3 * 12);
3386
3371
  for (let i = 0; i < vec3.length; i++) {
3387
3372
  const e = vec3[i];
3388
- const base = result3 + i * 16;var [tuple0_0, tuple0_1] = e;
3389
- var ptr1 = utf8Encode(tuple0_0, realloc0, memory0);
3390
- var len1 = utf8EncodedLen;
3391
- dataView(memory0).setInt32(base + 4, len1, true);
3392
- dataView(memory0).setInt32(base + 0, ptr1, true);
3373
+ const base = result3 + i * 12;var [tuple0_0, tuple0_1] = e;
3374
+ if (!(tuple0_0 instanceof Descriptor)) {
3375
+ throw new TypeError('Resource error: Not a valid "Descriptor" resource.');
3376
+ }
3377
+ var handle1 = tuple0_0[symbolRscHandle];
3378
+ if (!handle1) {
3379
+ const rep = tuple0_0[symbolRscRep] || ++captureCnt5;
3380
+ captureTable5.set(rep, tuple0_0);
3381
+ handle1 = rscTableCreateOwn(handleTable5, rep);
3382
+ }
3383
+ dataView(memory0).setInt32(base + 0, handle1, true);
3393
3384
  var ptr2 = utf8Encode(tuple0_1, realloc0, memory0);
3394
3385
  var len2 = utf8EncodedLen;
3395
- dataView(memory0).setInt32(base + 12, len2, true);
3396
- dataView(memory0).setInt32(base + 8, ptr2, true);
3386
+ dataView(memory0).setInt32(base + 8, len2, true);
3387
+ dataView(memory0).setInt32(base + 4, ptr2, true);
3397
3388
  }
3398
3389
  dataView(memory0).setInt32(arg0 + 4, len3, true);
3399
3390
  dataView(memory0).setInt32(arg0 + 0, result3, true);
@@ -3487,6 +3478,19 @@ function trampoline0(handle) {
3487
3478
  }
3488
3479
  }
3489
3480
  function trampoline1(handle) {
3481
+ const handleEntry = rscTableRemove(handleTable2, handle);
3482
+ if (handleEntry.own) {
3483
+
3484
+ const rsc = captureTable2.get(handleEntry.rep);
3485
+ if (rsc) {
3486
+ if (rsc[symbolDispose]) rsc[symbolDispose]();
3487
+ captureTable2.delete(handleEntry.rep);
3488
+ } else if (OutputStream[symbolCabiDispose]) {
3489
+ OutputStream[symbolCabiDispose](handleEntry.rep);
3490
+ }
3491
+ }
3492
+ }
3493
+ function trampoline2(handle) {
3490
3494
  const handleEntry = rscTableRemove(handleTable0, handle);
3491
3495
  if (handleEntry.own) {
3492
3496
 
@@ -3499,7 +3503,7 @@ function trampoline1(handle) {
3499
3503
  }
3500
3504
  }
3501
3505
  }
3502
- function trampoline2(handle) {
3506
+ function trampoline3(handle) {
3503
3507
  const handleEntry = rscTableRemove(handleTable1, handle);
3504
3508
  if (handleEntry.own) {
3505
3509
 
@@ -3512,19 +3516,6 @@ function trampoline2(handle) {
3512
3516
  }
3513
3517
  }
3514
3518
  }
3515
- function trampoline3(handle) {
3516
- const handleEntry = rscTableRemove(handleTable2, handle);
3517
- if (handleEntry.own) {
3518
-
3519
- const rsc = captureTable2.get(handleEntry.rep);
3520
- if (rsc) {
3521
- if (rsc[symbolDispose]) rsc[symbolDispose]();
3522
- captureTable2.delete(handleEntry.rep);
3523
- } else if (OutputStream[symbolCabiDispose]) {
3524
- OutputStream[symbolCabiDispose](handleEntry.rep);
3525
- }
3526
- }
3527
- }
3528
3519
  function trampoline4(handle) {
3529
3520
  const handleEntry = rscTableRemove(handleTable5, handle);
3530
3521
  if (handleEntry.own) {
@@ -3538,7 +3529,7 @@ function trampoline4(handle) {
3538
3529
  }
3539
3530
  }
3540
3531
  }
3541
- function trampoline9(handle) {
3532
+ function trampoline6(handle) {
3542
3533
  const handleEntry = rscTableRemove(handleTable3, handle);
3543
3534
  if (handleEntry.own) {
3544
3535
 
@@ -3551,7 +3542,7 @@ function trampoline9(handle) {
3551
3542
  }
3552
3543
  }
3553
3544
  }
3554
- function trampoline10(handle) {
3545
+ function trampoline7(handle) {
3555
3546
  const handleEntry = rscTableRemove(handleTable4, handle);
3556
3547
  if (handleEntry.own) {
3557
3548
 
@@ -3979,150 +3970,173 @@ function generateTypes(arg0, arg1) {
3979
3970
  }
3980
3971
 
3981
3972
  let _initialized = false;
3982
- export const $init = (async() => {
3983
- const module0 = fetchCompile(new URL('./js-component-bindgen-component.core.wasm', import.meta.url));
3984
- const module1 = fetchCompile(new URL('./js-component-bindgen-component.core2.wasm', import.meta.url));
3985
- const module2 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBX9/f39/AGAEf39/fwBgBH9/f38Bf2AHf39/f39/fwBgAn5/AGAJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAX8Bf2ADf39/AX8DJiUBAwMAAAAABAcABAAAAwMABQUACAEBAQEGCQoLAgIGAgIMAg0BBAUBcAElJQe7ASYBMAAAATEAAQEyAAIBMwADATQABAE1AAUBNgAGATcABwE4AAgBOQAJAjEwAAoCMTEACwIxMgAMAjEzAA0CMTQADgIxNQAPAjE2ABACMTcAEQIxOAASAjE5ABMCMjAAFAIyMQAVAjIyABYCMjMAFwIyNAAYAjI1ABkCMjYAGgIyNwAbAjI4ABwCMjkAHQIzMAAeAjMxAB8CMzIAIAIzMwAhAjM0ACICMzUAIwIzNgAkCCRpbXBvcnRzAQAK+QMlCQAgAEEAEQEACw0AIAAgASACQQERAwALDQAgACABIAJBAhEDAAsLACAAIAFBAxEAAAsLACAAIAFBBBEAAAsLACAAIAFBBREAAAsLACAAIAFBBhEAAAsRACAAIAEgAiADIARBBxEEAAsVACAAIAEgAiADIAQgBSAGQQgRBwALCwAgACABQQkRAAALEQAgACABIAIgAyAEQQoRBAALCwAgACABQQsRAAALCwAgACABQQwRAAALDQAgACABIAJBDREDAAsNACAAIAEgAkEOEQMACwsAIAAgAUEPEQAACw8AIAAgASACIANBEBEFAAsPACAAIAEgAiADQRERBQALCwAgACABQRIRAAALCwAgACABQRMRCAALCQAgAEEUEQEACwkAIABBFREBAAsJACAAQRYRAQALCQAgAEEXEQEACw8AIAAgASACIANBGBEGAAsZACAAIAEgAiADIAQgBSAGIAcgCEEZEQkACxEAIAAgASACIAMgBEEaEQoACxEAIAAgASACIAMgBEEbEQsACwsAIAAgAUEcEQIACwsAIAAgAUEdEQIACw8AIAAgASACIANBHhEGAAsLACAAIAFBHxECAAsLACAAIAFBIBECAAsJACAAQSERDAALCwAgACABQSIRAgALDQAgACABIAJBIxENAAsJACAAQSQRAQALAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMDIuMA');
3986
- const module3 = base64Compile('AGFzbQEAAAABaw9gAX8AYAN/fn8AYAJ/fwBgBX9/f39/AGAHf39/f39/fwBgBH9/f38AYAJ+fwBgBH9/f38Bf2AJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAn9/AX9gAX8Bf2ADf39/AX9gAX8AAuQBJgABMAAAAAExAAEAATIAAQABMwACAAE0AAIAATUAAgABNgACAAE3AAMAATgABAABOQACAAIxMAADAAIxMQACAAIxMgACAAIxMwABAAIxNAABAAIxNQACAAIxNgAFAAIxNwAFAAIxOAACAAIxOQAGAAIyMAAAAAIyMQAAAAIyMgAAAAIyMwAAAAIyNAAHAAIyNQAIAAIyNgAJAAIyNwAKAAIyOAALAAIyOQALAAIzMAAHAAIzMQALAAIzMgALAAIzMwAMAAIzNAALAAIzNQANAAIzNgAOAAgkaW1wb3J0cwFwASUlCSsBAEEACyUAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMDIuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw');
3987
- ({ exports: exports0 } = await instantiateCore(await module2));
3988
- ({ exports: exports1 } = await instantiateCore(await module0, {
3989
- wasi_snapshot_preview1: {
3990
- environ_get: exports0['31'],
3991
- environ_sizes_get: exports0['32'],
3992
- fd_close: exports0['33'],
3993
- fd_filestat_get: exports0['29'],
3994
- fd_prestat_dir_name: exports0['35'],
3995
- fd_prestat_get: exports0['34'],
3996
- fd_read: exports0['30'],
3997
- fd_readdir: exports0['26'],
3998
- fd_write: exports0['24'],
3999
- path_filestat_get: exports0['27'],
4000
- path_open: exports0['25'],
4001
- proc_exit: exports0['36'],
4002
- random_get: exports0['28'],
4003
- },
4004
- }));
4005
- ({ exports: exports2 } = await instantiateCore(await module1, {
4006
- __main_module__: {
4007
- cabi_realloc: exports1.cabi_realloc,
4008
- },
4009
- env: {
4010
- memory: exports1.memory,
4011
- },
4012
- 'wasi:cli/environment@0.2.0': {
4013
- 'get-environment': exports0['20'],
4014
- },
4015
- 'wasi:cli/exit@0.2.0': {
4016
- exit: trampoline6,
4017
- },
4018
- 'wasi:cli/stderr@0.2.0': {
4019
- 'get-stderr': trampoline5,
4020
- },
4021
- 'wasi:cli/stdin@0.2.0': {
4022
- 'get-stdin': trampoline7,
4023
- },
4024
- 'wasi:cli/stdout@0.2.0': {
4025
- 'get-stdout': trampoline8,
4026
- },
4027
- 'wasi:cli/terminal-input@0.2.0': {
4028
- '[resource-drop]terminal-input': trampoline9,
4029
- },
4030
- 'wasi:cli/terminal-output@0.2.0': {
4031
- '[resource-drop]terminal-output': trampoline10,
4032
- },
4033
- 'wasi:cli/terminal-stderr@0.2.0': {
4034
- 'get-terminal-stderr': exports0['23'],
4035
- },
4036
- 'wasi:cli/terminal-stdin@0.2.0': {
4037
- 'get-terminal-stdin': exports0['21'],
4038
- },
4039
- 'wasi:cli/terminal-stdout@0.2.0': {
4040
- 'get-terminal-stdout': exports0['22'],
4041
- },
4042
- 'wasi:filesystem/preopens@0.2.0': {
4043
- 'get-directories': exports0['0'],
4044
- },
4045
- 'wasi:filesystem/types@0.2.0': {
4046
- '[method]descriptor.append-via-stream': exports0['3'],
4047
- '[method]descriptor.get-type': exports0['4'],
4048
- '[method]descriptor.metadata-hash': exports0['9'],
4049
- '[method]descriptor.metadata-hash-at': exports0['10'],
4050
- '[method]descriptor.open-at': exports0['8'],
4051
- '[method]descriptor.read-directory': exports0['5'],
4052
- '[method]descriptor.read-via-stream': exports0['1'],
4053
- '[method]descriptor.stat': exports0['6'],
4054
- '[method]descriptor.stat-at': exports0['7'],
4055
- '[method]descriptor.write-via-stream': exports0['2'],
4056
- '[method]directory-entry-stream.read-directory-entry': exports0['11'],
4057
- '[resource-drop]descriptor': trampoline4,
4058
- '[resource-drop]directory-entry-stream': trampoline0,
4059
- 'filesystem-error-code': exports0['12'],
4060
- },
4061
- 'wasi:io/error@0.2.0': {
4062
- '[resource-drop]error': trampoline1,
4063
- },
4064
- 'wasi:io/streams@0.2.0': {
4065
- '[method]input-stream.blocking-read': exports0['14'],
4066
- '[method]input-stream.read': exports0['13'],
4067
- '[method]output-stream.blocking-flush': exports0['18'],
4068
- '[method]output-stream.blocking-write-and-flush': exports0['17'],
4069
- '[method]output-stream.check-write': exports0['15'],
4070
- '[method]output-stream.write': exports0['16'],
4071
- '[resource-drop]input-stream': trampoline2,
4072
- '[resource-drop]output-stream': trampoline3,
4073
- },
4074
- 'wasi:random/random@0.2.0': {
4075
- 'get-random-bytes': exports0['19'],
4076
- },
4077
- }));
4078
- memory0 = exports1.memory;
4079
- realloc0 = exports2.cabi_import_realloc;
4080
- ({ exports: exports3 } = await instantiateCore(await module3, {
4081
- '': {
4082
- $imports: exports0.$imports,
4083
- '0': trampoline11,
4084
- '1': trampoline12,
4085
- '10': trampoline21,
4086
- '11': trampoline22,
4087
- '12': trampoline23,
4088
- '13': trampoline24,
4089
- '14': trampoline25,
4090
- '15': trampoline26,
4091
- '16': trampoline27,
4092
- '17': trampoline28,
4093
- '18': trampoline29,
4094
- '19': trampoline30,
4095
- '2': trampoline13,
4096
- '20': trampoline31,
4097
- '21': trampoline32,
4098
- '22': trampoline33,
4099
- '23': trampoline34,
4100
- '24': exports2.fd_write,
4101
- '25': exports2.path_open,
4102
- '26': exports2.fd_readdir,
4103
- '27': exports2.path_filestat_get,
4104
- '28': exports2.random_get,
4105
- '29': exports2.fd_filestat_get,
4106
- '3': trampoline14,
4107
- '30': exports2.fd_read,
4108
- '31': exports2.environ_get,
4109
- '32': exports2.environ_sizes_get,
4110
- '33': exports2.fd_close,
4111
- '34': exports2.fd_prestat_get,
4112
- '35': exports2.fd_prestat_dir_name,
4113
- '36': exports2.proc_exit,
4114
- '4': trampoline15,
4115
- '5': trampoline16,
4116
- '6': trampoline17,
4117
- '7': trampoline18,
4118
- '8': trampoline19,
4119
- '9': trampoline20,
4120
- },
4121
- }));
4122
- realloc1 = exports1.cabi_realloc;
4123
- postReturn0 = exports1.cabi_post_generate;
4124
- postReturn1 = exports1['cabi_post_generate-types'];
4125
- _initialized = true;
3973
+ export const $init = (() => {
3974
+ let gen = (function* init () {
3975
+ const module0 = fetchCompile(new URL('./js-component-bindgen-component.core.wasm', import.meta.url));
3976
+ const module1 = fetchCompile(new URL('./js-component-bindgen-component.core2.wasm', import.meta.url));
3977
+ const module2 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBX9/f39/AGAEf39/fwBgBH9/f38Bf2AHf39/f39/fwBgAn5/AGAJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAX8Bf2ADf39/AX8DJiUBAwMAAAAABAcABAAAAwMABQUACAEBAQEGCQoLAgIGAgIMAg0BBAUBcAElJQe7ASYBMAAAATEAAQEyAAIBMwADATQABAE1AAUBNgAGATcABwE4AAgBOQAJAjEwAAoCMTEACwIxMgAMAjEzAA0CMTQADgIxNQAPAjE2ABACMTcAEQIxOAASAjE5ABMCMjAAFAIyMQAVAjIyABYCMjMAFwIyNAAYAjI1ABkCMjYAGgIyNwAbAjI4ABwCMjkAHQIzMAAeAjMxAB8CMzIAIAIzMwAhAjM0ACICMzUAIwIzNgAkCCRpbXBvcnRzAQAK+QMlCQAgAEEAEQEACw0AIAAgASACQQERAwALDQAgACABIAJBAhEDAAsLACAAIAFBAxEAAAsLACAAIAFBBBEAAAsLACAAIAFBBREAAAsLACAAIAFBBhEAAAsRACAAIAEgAiADIARBBxEEAAsVACAAIAEgAiADIAQgBSAGQQgRBwALCwAgACABQQkRAAALEQAgACABIAIgAyAEQQoRBAALCwAgACABQQsRAAALCwAgACABQQwRAAALDQAgACABIAJBDREDAAsNACAAIAEgAkEOEQMACwsAIAAgAUEPEQAACw8AIAAgASACIANBEBEFAAsPACAAIAEgAiADQRERBQALCwAgACABQRIRAAALCwAgACABQRMRCAALCQAgAEEUEQEACwkAIABBFREBAAsJACAAQRYRAQALCQAgAEEXEQEACw8AIAAgASACIANBGBEGAAsZACAAIAEgAiADIAQgBSAGIAcgCEEZEQkACxEAIAAgASACIAMgBEEaEQoACxEAIAAgASACIAMgBEEbEQsACwsAIAAgAUEcEQIACwsAIAAgAUEdEQIACw8AIAAgASACIANBHhEGAAsLACAAIAFBHxECAAsLACAAIAFBIBECAAsJACAAQSERDAALCwAgACABQSIRAgALDQAgACABIAJBIxENAAsJACAAQSQRAQALAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMDkuMQ');
3978
+ const module3 = base64Compile('AGFzbQEAAAABaw9gAX8AYAN/fn8AYAJ/fwBgBX9/f39/AGAHf39/f39/fwBgBH9/f38AYAJ+fwBgBH9/f38Bf2AJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAn9/AX9gAX8Bf2ADf39/AX9gAX8AAuQBJgABMAAAAAExAAEAATIAAQABMwACAAE0AAIAATUAAgABNgACAAE3AAMAATgABAABOQACAAIxMAADAAIxMQACAAIxMgACAAIxMwABAAIxNAABAAIxNQACAAIxNgAFAAIxNwAFAAIxOAACAAIxOQAGAAIyMAAAAAIyMQAAAAIyMgAAAAIyMwAAAAIyNAAHAAIyNQAIAAIyNgAJAAIyNwAKAAIyOAALAAIyOQALAAIzMAAHAAIzMQALAAIzMgALAAIzMwAMAAIzNAALAAIzNQANAAIzNgAOAAgkaW1wb3J0cwFwASUlCSsBAEEACyUAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMDkuMQAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw');
3979
+ ({ exports: exports0 } = yield instantiateCore(yield module2));
3980
+ ({ exports: exports1 } = yield instantiateCore(yield module0, {
3981
+ wasi_snapshot_preview1: {
3982
+ environ_get: exports0['31'],
3983
+ environ_sizes_get: exports0['32'],
3984
+ fd_close: exports0['33'],
3985
+ fd_filestat_get: exports0['29'],
3986
+ fd_prestat_dir_name: exports0['35'],
3987
+ fd_prestat_get: exports0['34'],
3988
+ fd_read: exports0['30'],
3989
+ fd_readdir: exports0['26'],
3990
+ fd_write: exports0['24'],
3991
+ path_filestat_get: exports0['27'],
3992
+ path_open: exports0['25'],
3993
+ proc_exit: exports0['36'],
3994
+ random_get: exports0['28'],
3995
+ },
3996
+ }));
3997
+ ({ exports: exports2 } = yield instantiateCore(yield module1, {
3998
+ __main_module__: {
3999
+ cabi_realloc: exports1.cabi_realloc,
4000
+ },
4001
+ env: {
4002
+ memory: exports1.memory,
4003
+ },
4004
+ 'wasi:cli/environment@0.2.0': {
4005
+ 'get-environment': exports0['0'],
4006
+ },
4007
+ 'wasi:cli/exit@0.2.0': {
4008
+ exit: trampoline10,
4009
+ },
4010
+ 'wasi:cli/stderr@0.2.0': {
4011
+ 'get-stderr': trampoline5,
4012
+ },
4013
+ 'wasi:cli/stdin@0.2.0': {
4014
+ 'get-stdin': trampoline8,
4015
+ },
4016
+ 'wasi:cli/stdout@0.2.0': {
4017
+ 'get-stdout': trampoline9,
4018
+ },
4019
+ 'wasi:cli/terminal-input@0.2.0': {
4020
+ '[resource-drop]terminal-input': trampoline6,
4021
+ },
4022
+ 'wasi:cli/terminal-output@0.2.0': {
4023
+ '[resource-drop]terminal-output': trampoline7,
4024
+ },
4025
+ 'wasi:cli/terminal-stderr@0.2.0': {
4026
+ 'get-terminal-stderr': exports0['23'],
4027
+ },
4028
+ 'wasi:cli/terminal-stdin@0.2.0': {
4029
+ 'get-terminal-stdin': exports0['21'],
4030
+ },
4031
+ 'wasi:cli/terminal-stdout@0.2.0': {
4032
+ 'get-terminal-stdout': exports0['22'],
4033
+ },
4034
+ 'wasi:filesystem/preopens@0.2.0': {
4035
+ 'get-directories': exports0['20'],
4036
+ },
4037
+ 'wasi:filesystem/types@0.2.0': {
4038
+ '[method]descriptor.append-via-stream': exports0['3'],
4039
+ '[method]descriptor.get-type': exports0['4'],
4040
+ '[method]descriptor.metadata-hash': exports0['9'],
4041
+ '[method]descriptor.metadata-hash-at': exports0['10'],
4042
+ '[method]descriptor.open-at': exports0['8'],
4043
+ '[method]descriptor.read-directory': exports0['5'],
4044
+ '[method]descriptor.read-via-stream': exports0['1'],
4045
+ '[method]descriptor.stat': exports0['6'],
4046
+ '[method]descriptor.stat-at': exports0['7'],
4047
+ '[method]descriptor.write-via-stream': exports0['2'],
4048
+ '[method]directory-entry-stream.read-directory-entry': exports0['11'],
4049
+ '[resource-drop]descriptor': trampoline4,
4050
+ '[resource-drop]directory-entry-stream': trampoline0,
4051
+ 'filesystem-error-code': exports0['12'],
4052
+ },
4053
+ 'wasi:io/error@0.2.0': {
4054
+ '[resource-drop]error': trampoline2,
4055
+ },
4056
+ 'wasi:io/streams@0.2.0': {
4057
+ '[method]input-stream.blocking-read': exports0['14'],
4058
+ '[method]input-stream.read': exports0['13'],
4059
+ '[method]output-stream.blocking-flush': exports0['18'],
4060
+ '[method]output-stream.blocking-write-and-flush': exports0['17'],
4061
+ '[method]output-stream.check-write': exports0['15'],
4062
+ '[method]output-stream.write': exports0['16'],
4063
+ '[resource-drop]input-stream': trampoline3,
4064
+ '[resource-drop]output-stream': trampoline1,
4065
+ },
4066
+ 'wasi:random/random@0.2.0': {
4067
+ 'get-random-bytes': exports0['19'],
4068
+ },
4069
+ }));
4070
+ memory0 = exports1.memory;
4071
+ realloc0 = exports2.cabi_import_realloc;
4072
+ ({ exports: exports3 } = yield instantiateCore(yield module3, {
4073
+ '': {
4074
+ $imports: exports0.$imports,
4075
+ '0': trampoline11,
4076
+ '1': trampoline12,
4077
+ '10': trampoline21,
4078
+ '11': trampoline22,
4079
+ '12': trampoline23,
4080
+ '13': trampoline24,
4081
+ '14': trampoline25,
4082
+ '15': trampoline26,
4083
+ '16': trampoline27,
4084
+ '17': trampoline28,
4085
+ '18': trampoline29,
4086
+ '19': trampoline30,
4087
+ '2': trampoline13,
4088
+ '20': trampoline31,
4089
+ '21': trampoline32,
4090
+ '22': trampoline33,
4091
+ '23': trampoline34,
4092
+ '24': exports2.fd_write,
4093
+ '25': exports2.path_open,
4094
+ '26': exports2.fd_readdir,
4095
+ '27': exports2.path_filestat_get,
4096
+ '28': exports2.random_get,
4097
+ '29': exports2.fd_filestat_get,
4098
+ '3': trampoline14,
4099
+ '30': exports2.fd_read,
4100
+ '31': exports2.environ_get,
4101
+ '32': exports2.environ_sizes_get,
4102
+ '33': exports2.fd_close,
4103
+ '34': exports2.fd_prestat_get,
4104
+ '35': exports2.fd_prestat_dir_name,
4105
+ '36': exports2.proc_exit,
4106
+ '4': trampoline15,
4107
+ '5': trampoline16,
4108
+ '6': trampoline17,
4109
+ '7': trampoline18,
4110
+ '8': trampoline19,
4111
+ '9': trampoline20,
4112
+ },
4113
+ }));
4114
+ realloc1 = exports1.cabi_realloc;
4115
+ postReturn0 = exports1.cabi_post_generate;
4116
+ postReturn1 = exports1['cabi_post_generate-types'];
4117
+ _initialized = true;
4118
+ })();
4119
+ let promise, resolve, reject;
4120
+ function runNext (value) {
4121
+ try {
4122
+ let done;
4123
+ do {
4124
+ ({ value, done } = gen.next(value));
4125
+ } while (!(value instanceof Promise) && !done);
4126
+ if (done) {
4127
+ if (resolve) resolve(value);
4128
+ else return value;
4129
+ }
4130
+ if (!promise) promise = new Promise((_resolve, _reject) => (resolve = _resolve, reject = _reject));
4131
+ value.then(runNext, reject);
4132
+ }
4133
+ catch (e) {
4134
+ if (reject) reject(e);
4135
+ else throw e;
4136
+ }
4137
+ }
4138
+ const maybeSyncReturn = runNext(null);
4139
+ return promise || maybeSyncReturn;
4126
4140
  })();
4127
4141
 
4128
4142
  export { generate, generateTypes, }
Binary file
Binary file