@bytecodealliance/jco 1.2.3 → 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,22 +113,14 @@ 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
 
123
+
132
124
  let exports0;
133
125
  let exports1;
134
126
  const handleTable2 = [T_FLAG, 0];
@@ -149,36 +141,12 @@ function trampoline5() {
149
141
  }
150
142
  return handle0;
151
143
  }
152
-
153
- function trampoline6(arg0) {
154
- let variant0;
155
- switch (arg0) {
156
- case 0: {
157
- variant0= {
158
- tag: 'ok',
159
- val: undefined
160
- };
161
- break;
162
- }
163
- case 1: {
164
- variant0= {
165
- tag: 'err',
166
- val: undefined
167
- };
168
- break;
169
- }
170
- default: {
171
- throw new TypeError('invalid variant discriminant for expected');
172
- }
173
- }
174
- exit(variant0);
175
- }
176
144
  const handleTable1 = [T_FLAG, 0];
177
145
  const captureTable1= new Map();
178
146
  let captureCnt1 = 0;
179
147
  handleTables[1] = handleTable1;
180
148
 
181
- function trampoline7() {
149
+ function trampoline8() {
182
150
  const ret = getStdin();
183
151
  if (!(ret instanceof InputStream)) {
184
152
  throw new TypeError('Resource error: Not a valid "InputStream" resource.');
@@ -192,7 +160,7 @@ function trampoline7() {
192
160
  return handle0;
193
161
  }
194
162
 
195
- function trampoline8() {
163
+ function trampoline9() {
196
164
  const ret = getStdout();
197
165
  if (!(ret instanceof OutputStream)) {
198
166
  throw new TypeError('Resource error: Not a valid "OutputStream" resource.');
@@ -205,40 +173,58 @@ function trampoline8() {
205
173
  }
206
174
  return handle0;
207
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
+ }
208
200
  let exports2;
209
201
  let memory0;
210
202
  let realloc0;
211
- const handleTable5 = [T_FLAG, 0];
212
- const captureTable5= new Map();
213
- let captureCnt5 = 0;
214
- handleTables[5] = handleTable5;
215
203
 
216
204
  function trampoline11(arg0) {
217
- const ret = getDirectories();
205
+ const ret = getEnvironment();
218
206
  var vec3 = ret;
219
207
  var len3 = vec3.length;
220
- var result3 = realloc0(0, 0, 4, len3 * 12);
208
+ var result3 = realloc0(0, 0, 4, len3 * 16);
221
209
  for (let i = 0; i < vec3.length; i++) {
222
210
  const e = vec3[i];
223
- const base = result3 + i * 12;var [tuple0_0, tuple0_1] = e;
224
- if (!(tuple0_0 instanceof Descriptor)) {
225
- throw new TypeError('Resource error: Not a valid "Descriptor" resource.');
226
- }
227
- var handle1 = tuple0_0[symbolRscHandle];
228
- if (!handle1) {
229
- const rep = tuple0_0[symbolRscRep] || ++captureCnt5;
230
- captureTable5.set(rep, tuple0_0);
231
- handle1 = rscTableCreateOwn(handleTable5, rep);
232
- }
233
- 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);
234
216
  var ptr2 = utf8Encode(tuple0_1, realloc0, memory0);
235
217
  var len2 = utf8EncodedLen;
236
- dataView(memory0).setInt32(base + 8, len2, true);
237
- dataView(memory0).setInt32(base + 4, ptr2, true);
218
+ dataView(memory0).setInt32(base + 12, len2, true);
219
+ dataView(memory0).setInt32(base + 8, ptr2, true);
238
220
  }
239
221
  dataView(memory0).setInt32(arg0 + 4, len3, true);
240
222
  dataView(memory0).setInt32(arg0 + 0, result3, true);
241
223
  }
224
+ const handleTable5 = [T_FLAG, 0];
225
+ const captureTable5= new Map();
226
+ let captureCnt5 = 0;
227
+ handleTables[5] = handleTable5;
242
228
 
243
229
  function trampoline12(arg0, arg1, arg2) {
244
230
  var handle1 = arg0;
@@ -3378,21 +3364,27 @@ function trampoline30(arg0, arg1) {
3378
3364
  }
3379
3365
 
3380
3366
  function trampoline31(arg0) {
3381
- const ret = getEnvironment();
3367
+ const ret = getDirectories();
3382
3368
  var vec3 = ret;
3383
3369
  var len3 = vec3.length;
3384
- var result3 = realloc0(0, 0, 4, len3 * 16);
3370
+ var result3 = realloc0(0, 0, 4, len3 * 12);
3385
3371
  for (let i = 0; i < vec3.length; i++) {
3386
3372
  const e = vec3[i];
3387
- const base = result3 + i * 16;var [tuple0_0, tuple0_1] = e;
3388
- var ptr1 = utf8Encode(tuple0_0, realloc0, memory0);
3389
- var len1 = utf8EncodedLen;
3390
- dataView(memory0).setInt32(base + 4, len1, true);
3391
- 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);
3392
3384
  var ptr2 = utf8Encode(tuple0_1, realloc0, memory0);
3393
3385
  var len2 = utf8EncodedLen;
3394
- dataView(memory0).setInt32(base + 12, len2, true);
3395
- dataView(memory0).setInt32(base + 8, ptr2, true);
3386
+ dataView(memory0).setInt32(base + 8, len2, true);
3387
+ dataView(memory0).setInt32(base + 4, ptr2, true);
3396
3388
  }
3397
3389
  dataView(memory0).setInt32(arg0 + 4, len3, true);
3398
3390
  dataView(memory0).setInt32(arg0 + 0, result3, true);
@@ -3486,6 +3478,19 @@ function trampoline0(handle) {
3486
3478
  }
3487
3479
  }
3488
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) {
3489
3494
  const handleEntry = rscTableRemove(handleTable0, handle);
3490
3495
  if (handleEntry.own) {
3491
3496
 
@@ -3498,7 +3503,7 @@ function trampoline1(handle) {
3498
3503
  }
3499
3504
  }
3500
3505
  }
3501
- function trampoline2(handle) {
3506
+ function trampoline3(handle) {
3502
3507
  const handleEntry = rscTableRemove(handleTable1, handle);
3503
3508
  if (handleEntry.own) {
3504
3509
 
@@ -3511,19 +3516,6 @@ function trampoline2(handle) {
3511
3516
  }
3512
3517
  }
3513
3518
  }
3514
- function trampoline3(handle) {
3515
- const handleEntry = rscTableRemove(handleTable2, handle);
3516
- if (handleEntry.own) {
3517
-
3518
- const rsc = captureTable2.get(handleEntry.rep);
3519
- if (rsc) {
3520
- if (rsc[symbolDispose]) rsc[symbolDispose]();
3521
- captureTable2.delete(handleEntry.rep);
3522
- } else if (OutputStream[symbolCabiDispose]) {
3523
- OutputStream[symbolCabiDispose](handleEntry.rep);
3524
- }
3525
- }
3526
- }
3527
3519
  function trampoline4(handle) {
3528
3520
  const handleEntry = rscTableRemove(handleTable5, handle);
3529
3521
  if (handleEntry.own) {
@@ -3537,7 +3529,7 @@ function trampoline4(handle) {
3537
3529
  }
3538
3530
  }
3539
3531
  }
3540
- function trampoline9(handle) {
3532
+ function trampoline6(handle) {
3541
3533
  const handleEntry = rscTableRemove(handleTable3, handle);
3542
3534
  if (handleEntry.own) {
3543
3535
 
@@ -3550,7 +3542,7 @@ function trampoline9(handle) {
3550
3542
  }
3551
3543
  }
3552
3544
  }
3553
- function trampoline10(handle) {
3545
+ function trampoline7(handle) {
3554
3546
  const handleEntry = rscTableRemove(handleTable4, handle);
3555
3547
  if (handleEntry.own) {
3556
3548
 
@@ -3978,150 +3970,173 @@ function generateTypes(arg0, arg1) {
3978
3970
  }
3979
3971
 
3980
3972
  let _initialized = false;
3981
- export const $init = (async() => {
3982
- const module0 = fetchCompile(new URL('./js-component-bindgen-component.core.wasm', import.meta.url));
3983
- const module1 = fetchCompile(new URL('./js-component-bindgen-component.core2.wasm', import.meta.url));
3984
- const module2 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBX9/f39/AGAEf39/fwBgBH9/f38Bf2AHf39/f39/fwBgAn5/AGAJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAX8Bf2ADf39/AX8DJiUBAwMAAAAABAcABAAAAwMABQUACAEBAQEGCQoLAgIGAgIMAg0BBAUBcAElJQe7ASYBMAAAATEAAQEyAAIBMwADATQABAE1AAUBNgAGATcABwE4AAgBOQAJAjEwAAoCMTEACwIxMgAMAjEzAA0CMTQADgIxNQAPAjE2ABACMTcAEQIxOAASAjE5ABMCMjAAFAIyMQAVAjIyABYCMjMAFwIyNAAYAjI1ABkCMjYAGgIyNwAbAjI4ABwCMjkAHQIzMAAeAjMxAB8CMzIAIAIzMwAhAjM0ACICMzUAIwIzNgAkCCRpbXBvcnRzAQAK+QMlCQAgAEEAEQEACw0AIAAgASACQQERAwALDQAgACABIAJBAhEDAAsLACAAIAFBAxEAAAsLACAAIAFBBBEAAAsLACAAIAFBBREAAAsLACAAIAFBBhEAAAsRACAAIAEgAiADIARBBxEEAAsVACAAIAEgAiADIAQgBSAGQQgRBwALCwAgACABQQkRAAALEQAgACABIAIgAyAEQQoRBAALCwAgACABQQsRAAALCwAgACABQQwRAAALDQAgACABIAJBDREDAAsNACAAIAEgAkEOEQMACwsAIAAgAUEPEQAACw8AIAAgASACIANBEBEFAAsPACAAIAEgAiADQRERBQALCwAgACABQRIRAAALCwAgACABQRMRCAALCQAgAEEUEQEACwkAIABBFREBAAsJACAAQRYRAQALCQAgAEEXEQEACw8AIAAgASACIANBGBEGAAsZACAAIAEgAiADIAQgBSAGIAcgCEEZEQkACxEAIAAgASACIAMgBEEaEQoACxEAIAAgASACIAMgBEEbEQsACwsAIAAgAUEcEQIACwsAIAAgAUEdEQIACw8AIAAgASACIANBHhEGAAsLACAAIAFBHxECAAsLACAAIAFBIBECAAsJACAAQSERDAALCwAgACABQSIRAgALDQAgACABIAJBIxENAAsJACAAQSQRAQALAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMDIuMA');
3985
- const module3 = base64Compile('AGFzbQEAAAABaw9gAX8AYAN/fn8AYAJ/fwBgBX9/f39/AGAHf39/f39/fwBgBH9/f38AYAJ+fwBgBH9/f38Bf2AJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAn9/AX9gAX8Bf2ADf39/AX9gAX8AAuQBJgABMAAAAAExAAEAATIAAQABMwACAAE0AAIAATUAAgABNgACAAE3AAMAATgABAABOQACAAIxMAADAAIxMQACAAIxMgACAAIxMwABAAIxNAABAAIxNQACAAIxNgAFAAIxNwAFAAIxOAACAAIxOQAGAAIyMAAAAAIyMQAAAAIyMgAAAAIyMwAAAAIyNAAHAAIyNQAIAAIyNgAJAAIyNwAKAAIyOAALAAIyOQALAAIzMAAHAAIzMQALAAIzMgALAAIzMwAMAAIzNAALAAIzNQANAAIzNgAOAAgkaW1wb3J0cwFwASUlCSsBAEEACyUAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMDIuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw');
3986
- ({ exports: exports0 } = await instantiateCore(await module2));
3987
- ({ exports: exports1 } = await instantiateCore(await module0, {
3988
- wasi_snapshot_preview1: {
3989
- environ_get: exports0['31'],
3990
- environ_sizes_get: exports0['32'],
3991
- fd_close: exports0['33'],
3992
- fd_filestat_get: exports0['29'],
3993
- fd_prestat_dir_name: exports0['35'],
3994
- fd_prestat_get: exports0['34'],
3995
- fd_read: exports0['30'],
3996
- fd_readdir: exports0['26'],
3997
- fd_write: exports0['24'],
3998
- path_filestat_get: exports0['27'],
3999
- path_open: exports0['25'],
4000
- proc_exit: exports0['36'],
4001
- random_get: exports0['28'],
4002
- },
4003
- }));
4004
- ({ exports: exports2 } = await instantiateCore(await module1, {
4005
- __main_module__: {
4006
- cabi_realloc: exports1.cabi_realloc,
4007
- },
4008
- env: {
4009
- memory: exports1.memory,
4010
- },
4011
- 'wasi:cli/environment@0.2.0': {
4012
- 'get-environment': exports0['20'],
4013
- },
4014
- 'wasi:cli/exit@0.2.0': {
4015
- exit: trampoline6,
4016
- },
4017
- 'wasi:cli/stderr@0.2.0': {
4018
- 'get-stderr': trampoline5,
4019
- },
4020
- 'wasi:cli/stdin@0.2.0': {
4021
- 'get-stdin': trampoline7,
4022
- },
4023
- 'wasi:cli/stdout@0.2.0': {
4024
- 'get-stdout': trampoline8,
4025
- },
4026
- 'wasi:cli/terminal-input@0.2.0': {
4027
- '[resource-drop]terminal-input': trampoline9,
4028
- },
4029
- 'wasi:cli/terminal-output@0.2.0': {
4030
- '[resource-drop]terminal-output': trampoline10,
4031
- },
4032
- 'wasi:cli/terminal-stderr@0.2.0': {
4033
- 'get-terminal-stderr': exports0['23'],
4034
- },
4035
- 'wasi:cli/terminal-stdin@0.2.0': {
4036
- 'get-terminal-stdin': exports0['21'],
4037
- },
4038
- 'wasi:cli/terminal-stdout@0.2.0': {
4039
- 'get-terminal-stdout': exports0['22'],
4040
- },
4041
- 'wasi:filesystem/preopens@0.2.0': {
4042
- 'get-directories': exports0['0'],
4043
- },
4044
- 'wasi:filesystem/types@0.2.0': {
4045
- '[method]descriptor.append-via-stream': exports0['3'],
4046
- '[method]descriptor.get-type': exports0['4'],
4047
- '[method]descriptor.metadata-hash': exports0['9'],
4048
- '[method]descriptor.metadata-hash-at': exports0['10'],
4049
- '[method]descriptor.open-at': exports0['8'],
4050
- '[method]descriptor.read-directory': exports0['5'],
4051
- '[method]descriptor.read-via-stream': exports0['1'],
4052
- '[method]descriptor.stat': exports0['6'],
4053
- '[method]descriptor.stat-at': exports0['7'],
4054
- '[method]descriptor.write-via-stream': exports0['2'],
4055
- '[method]directory-entry-stream.read-directory-entry': exports0['11'],
4056
- '[resource-drop]descriptor': trampoline4,
4057
- '[resource-drop]directory-entry-stream': trampoline0,
4058
- 'filesystem-error-code': exports0['12'],
4059
- },
4060
- 'wasi:io/error@0.2.0': {
4061
- '[resource-drop]error': trampoline1,
4062
- },
4063
- 'wasi:io/streams@0.2.0': {
4064
- '[method]input-stream.blocking-read': exports0['14'],
4065
- '[method]input-stream.read': exports0['13'],
4066
- '[method]output-stream.blocking-flush': exports0['18'],
4067
- '[method]output-stream.blocking-write-and-flush': exports0['17'],
4068
- '[method]output-stream.check-write': exports0['15'],
4069
- '[method]output-stream.write': exports0['16'],
4070
- '[resource-drop]input-stream': trampoline2,
4071
- '[resource-drop]output-stream': trampoline3,
4072
- },
4073
- 'wasi:random/random@0.2.0': {
4074
- 'get-random-bytes': exports0['19'],
4075
- },
4076
- }));
4077
- memory0 = exports1.memory;
4078
- realloc0 = exports2.cabi_import_realloc;
4079
- ({ exports: exports3 } = await instantiateCore(await module3, {
4080
- '': {
4081
- $imports: exports0.$imports,
4082
- '0': trampoline11,
4083
- '1': trampoline12,
4084
- '10': trampoline21,
4085
- '11': trampoline22,
4086
- '12': trampoline23,
4087
- '13': trampoline24,
4088
- '14': trampoline25,
4089
- '15': trampoline26,
4090
- '16': trampoline27,
4091
- '17': trampoline28,
4092
- '18': trampoline29,
4093
- '19': trampoline30,
4094
- '2': trampoline13,
4095
- '20': trampoline31,
4096
- '21': trampoline32,
4097
- '22': trampoline33,
4098
- '23': trampoline34,
4099
- '24': exports2.fd_write,
4100
- '25': exports2.path_open,
4101
- '26': exports2.fd_readdir,
4102
- '27': exports2.path_filestat_get,
4103
- '28': exports2.random_get,
4104
- '29': exports2.fd_filestat_get,
4105
- '3': trampoline14,
4106
- '30': exports2.fd_read,
4107
- '31': exports2.environ_get,
4108
- '32': exports2.environ_sizes_get,
4109
- '33': exports2.fd_close,
4110
- '34': exports2.fd_prestat_get,
4111
- '35': exports2.fd_prestat_dir_name,
4112
- '36': exports2.proc_exit,
4113
- '4': trampoline15,
4114
- '5': trampoline16,
4115
- '6': trampoline17,
4116
- '7': trampoline18,
4117
- '8': trampoline19,
4118
- '9': trampoline20,
4119
- },
4120
- }));
4121
- realloc1 = exports1.cabi_realloc;
4122
- postReturn0 = exports1.cabi_post_generate;
4123
- postReturn1 = exports1['cabi_post_generate-types'];
4124
- _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;
4125
4140
  })();
4126
4141
 
4127
4142
  export { generate, generateTypes, }
Binary file
Binary file