@yowasp/yosys 0.37.58-dev.635 → 0.37.67-dev.640

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.
@@ -1,3 +1,22 @@
1
+ // node_modules/@yowasp/runtime/lib/fetch.js
2
+ var fetch;
3
+ if (typeof process === "object" && process.release?.name === "node") {
4
+ fetch = async function(url, options) {
5
+ if (url.protocol === "file:") {
6
+ const { readFile } = await import("fs/promises");
7
+ let contentType = "application/octet-stream";
8
+ if (url.pathname.endsWith(".wasm"))
9
+ contentType = "application/wasm";
10
+ return new Response(await readFile(url), { headers: { "Content-Type": contentType } });
11
+ } else {
12
+ return globalThis.fetch(url, options);
13
+ }
14
+ };
15
+ } else {
16
+ fetch = globalThis.fetch;
17
+ }
18
+ var fetch_default = fetch;
19
+
1
20
  // node_modules/@yowasp/runtime/lib/wasi-virt.js
2
21
  var Exit = class extends Error {
3
22
  constructor(code = 0) {
@@ -14,15 +33,32 @@ function wallClockNow() {
14
33
  const nanoseconds = now % 1e3 * 1e6;
15
34
  return { seconds, nanoseconds };
16
35
  }
17
- var randomBytesImpl = function() {
18
- throw "not implemented";
36
+ var Xoroshiro128StarStar = class {
37
+ constructor(seed) {
38
+ if (BigInt(seed) === 0n) {
39
+ throw new Error("xoroshiro128** must be seeded with a non-zero state");
40
+ }
41
+ this.s = [BigInt(seed) & 0xffffffffffffffffn, BigInt(seed) >> 64n & 0xffffffffffffffffn];
42
+ }
43
+ next() {
44
+ function trunc64(x) {
45
+ return x & 0xffffffffffffffffn;
46
+ }
47
+ function rotl(x, k) {
48
+ return x << k | x >> 64n - k;
49
+ }
50
+ let [s0, s1] = this.s;
51
+ const r = trunc64(rotl(s0 * 5n, 7n) * 9n);
52
+ s1 ^= s0;
53
+ s0 = trunc64(rotl(s0, 24n) ^ s1 ^ s1 << 16n);
54
+ s1 = trunc64(rotl(s1, 37n));
55
+ this.s = [s0, s1];
56
+ return r;
57
+ }
58
+ getBytes(length) {
59
+ return Uint8Array.from({ length }, () => Number(BigInt.asUintN(8, this.next() >> 32n)));
60
+ }
19
61
  };
20
- function setRandomBytesImpl(impl) {
21
- randomBytesImpl = impl;
22
- }
23
- function getRandomBytes(len) {
24
- return randomBytesImpl(Number(len));
25
- }
26
62
  var IoError = class extends Error {
27
63
  };
28
64
  var InputStream = class {
@@ -50,33 +86,27 @@ var OutputStream = class {
50
86
  this.blockingFlush();
51
87
  }
52
88
  };
53
- var TerminalInput = class {
54
- };
55
- var TerminalOutput = class {
56
- };
57
- var TerminalOutputStream = class extends OutputStream {
58
- buffer = "";
59
- constructor(printLine = console.log) {
89
+ var CallbackOutputStream = class extends OutputStream {
90
+ constructor(callback = null) {
60
91
  super();
61
- this.printLine = printLine;
92
+ this.callback = callback;
62
93
  }
63
94
  checkWrite() {
64
95
  return 4096;
65
96
  }
66
97
  write(contents) {
67
- this.buffer += new TextDecoder().decode(contents);
68
- let newlineAt = -1;
69
- while (true) {
70
- const nextNewlineAt = this.buffer.indexOf("\n", newlineAt + 1);
71
- if (nextNewlineAt === -1) {
72
- break;
73
- }
74
- this.printLine(this.buffer.substring(0, nextNewlineAt));
75
- newlineAt = nextNewlineAt;
76
- }
77
- this.buffer = this.buffer.substring(newlineAt + 1);
98
+ if (this.callback !== null)
99
+ this.callback(contents);
100
+ }
101
+ flush() {
102
+ if (this.callback !== null)
103
+ this.callback(null);
78
104
  }
79
105
  };
106
+ var TerminalInput = class {
107
+ };
108
+ var TerminalOutput = class {
109
+ };
80
110
  var File = class {
81
111
  constructor(data = "") {
82
112
  if (data instanceof Uint8Array) {
@@ -295,8 +325,10 @@ var Environment = class {
295
325
  args = [];
296
326
  root = new Directory({});
297
327
  constructor() {
298
- this.terminalInputStream = new InputStream();
299
- this.terminalOutputStream = new TerminalOutputStream();
328
+ this.prng = new Xoroshiro128StarStar(1n);
329
+ this.standardInputStream = new InputStream();
330
+ this.standardOutputStream = new CallbackOutputStream();
331
+ this.standardErrorStream = new CallbackOutputStream();
300
332
  this.terminalInput = new TerminalInput();
301
333
  this.terminalOutput = new TerminalOutput();
302
334
  const $this = this;
@@ -308,7 +340,9 @@ var Environment = class {
308
340
  now: wallClockNow
309
341
  },
310
342
  random: {
311
- getRandomBytes
343
+ getRandomBytes(length) {
344
+ return $this.prng.getBytes(Number(length));
345
+ }
312
346
  },
313
347
  io: {
314
348
  Error: IoError,
@@ -326,13 +360,13 @@ var Environment = class {
326
360
  return $this.args;
327
361
  },
328
362
  getStdin() {
329
- return $this.terminalInputStream;
363
+ return $this.standardInputStream;
330
364
  },
331
365
  getStdout() {
332
- return $this.terminalOutputStream;
366
+ return $this.standardOutputStream;
333
367
  },
334
368
  getStderr() {
335
- return $this.terminalOutputStream;
369
+ return $this.standardErrorStream;
336
370
  },
337
371
  getTerminalStdin() {
338
372
  return $this.terminalInput;
@@ -359,25 +393,83 @@ var Environment = class {
359
393
  }
360
394
  };
361
395
  }
362
- get printLine() {
363
- return this.terminalOutputStream.printLine;
396
+ get stdout() {
397
+ return this.standardOutputStream.callback;
398
+ }
399
+ set stdout(callback) {
400
+ this.standardOutputStream.callback = callback;
364
401
  }
365
- set printLine(fn) {
366
- this.terminalOutputStream.printLine = fn;
402
+ get stderr() {
403
+ return this.standardErrorStream.callback;
404
+ }
405
+ set stderr(callback) {
406
+ this.standardErrorStream.callback = callback;
367
407
  }
368
408
  };
369
409
 
370
- // node_modules/@yowasp/runtime/lib/api-base.js
371
- var BaseApplication = class {
410
+ // node_modules/@yowasp/runtime/lib/util.js
411
+ function lineBuffered(processLine) {
412
+ let buffer = new Uint8Array();
413
+ return (bytes) => {
414
+ if (bytes === null)
415
+ return;
416
+ let newBuffer = new Uint8Array(buffer.length + bytes.length);
417
+ newBuffer.set(buffer);
418
+ newBuffer.set(bytes, buffer.length);
419
+ buffer = newBuffer;
420
+ let newlineAt = -1;
421
+ while (true) {
422
+ const nextNewlineAt = buffer.indexOf(10, newlineAt + 1);
423
+ if (nextNewlineAt === -1)
424
+ break;
425
+ processLine(new TextDecoder().decode(buffer.subarray(newlineAt + 1, nextNewlineAt)));
426
+ newlineAt = nextNewlineAt;
427
+ }
428
+ buffer = buffer.subarray(newlineAt + 1);
429
+ };
430
+ }
431
+
432
+ // node_modules/@yowasp/runtime/lib/api.js
433
+ async function fetchObject(obj, fetchFn) {
434
+ const promises = [];
435
+ for (const [key, value] of Object.entries(obj)) {
436
+ if (typeof value === "string" || value instanceof Uint8Array) {
437
+ promises.push(Promise.resolve([key, value]));
438
+ } else if (value instanceof URL) {
439
+ promises.push(fetchFn(value).then((fetched) => [key, fetched]));
440
+ } else {
441
+ promises.push(fetchObject(value, fetchFn).then((fetched) => [key, fetched]));
442
+ }
443
+ }
444
+ for (const [key, value] of await Promise.all(promises))
445
+ obj[key] = value;
446
+ return obj;
447
+ }
448
+ function fetchWebAssembly(url) {
449
+ return fetch_default(url).then(WebAssembly.compileStreaming);
450
+ }
451
+ function fetchUint8Array(url) {
452
+ return fetch_default(url).then((resp) => resp.arrayBuffer()).then((buf) => new Uint8Array(buf));
453
+ }
454
+ function fetchResources({ modules, filesystem }) {
455
+ return Promise.all([
456
+ fetchObject(modules, fetchWebAssembly),
457
+ fetchObject(filesystem, fetchUint8Array)
458
+ ]).then(([modules2, filesystem2]) => {
459
+ return { modules: modules2, filesystem: filesystem2 };
460
+ });
461
+ }
462
+ var Application = class {
372
463
  constructor(resourceFileURL2, instantiate2, argv0) {
373
464
  this.resourceFileURL = resourceFileURL2;
374
465
  this.resources = null;
375
466
  this.instantiate = instantiate2;
376
467
  this.argv0 = argv0;
377
468
  }
378
- async run(args = null, files = {}, { printLine = console.log, decodeASCII = true } = {}) {
469
+ // The `printLine` option is deprecated and not documented but still accepted for compatibility.
470
+ async run(args = null, files = {}, { stdout, stderr, decodeASCII = true, printLine } = {}) {
379
471
  if (this.resources === null)
380
- this.resources = await this._fetchResources();
472
+ this.resources = await import(this.resourceFileURL).then(fetchResources);
381
473
  if (args === null)
382
474
  return;
383
475
  const environment = new Environment();
@@ -385,7 +477,9 @@ var BaseApplication = class {
385
477
  environment.root = directoryFromTree(files);
386
478
  for (const [dirName, dirContents] of Object.entries(this.resources.filesystem))
387
479
  environment.root.files[dirName] = directoryFromTree(dirContents);
388
- environment.printLine = printLine;
480
+ const lineBufferedConsole = lineBuffered(printLine ?? console.log);
481
+ environment.stdout = stdout === void 0 ? lineBufferedConsole : stdout;
482
+ environment.stderr = stderr === void 0 ? lineBufferedConsole : stderr;
389
483
  const wasmCommand = await this.instantiate(
390
484
  (filename) => this.resources.modules[filename],
391
485
  { runtime: environment.exports }
@@ -409,50 +503,6 @@ var BaseApplication = class {
409
503
  return files;
410
504
  }
411
505
  }
412
- async _fetchResources() {
413
- console.log(`[YoWASP runtime] Fetching resource bundle ${this.resourceFileURL}`);
414
- const { modules, filesystem } = await import(this.resourceFileURL);
415
- return {
416
- modules: await this._fetchObject(modules, this._fetchWebAssembly),
417
- filesystem: await this._fetchObject(filesystem, this._fetchUint8Array)
418
- };
419
- }
420
- async _fetchObject(obj, fetchFn) {
421
- for (const [key, value] of Object.entries(obj)) {
422
- if (value instanceof URL) {
423
- console.log(`[YoWASP runtime] Fetching resource file ${value}`);
424
- obj[key] = await fetchFn(value);
425
- } else if (typeof value === "string" || value instanceof Uint8Array) {
426
- obj[key] = value;
427
- } else {
428
- obj[key] = await this._fetchObject(value, fetchFn);
429
- }
430
- }
431
- return obj;
432
- }
433
- async _fetchUint8Array(_url) {
434
- throw "not implemented";
435
- }
436
- async _fetchWebAssembly(_url) {
437
- throw "not implemented";
438
- }
439
- };
440
-
441
- // node_modules/@yowasp/runtime/lib/api-browser.js
442
- setRandomBytesImpl(function(length) {
443
- const QUOTA = 65536;
444
- const bytes = new Uint8Array(length);
445
- for (var offset = 0; offset < length; offset += QUOTA)
446
- crypto.getRandomValues(bytes.slice(offset, offset + QUOTA));
447
- return bytes;
448
- });
449
- var Application = class extends BaseApplication {
450
- _fetchUint8Array(url) {
451
- return fetch(url).then((resp) => resp.arrayBuffer()).then((buf) => new Uint8Array(buf));
452
- }
453
- _fetchWebAssembly(url) {
454
- return fetch(url).then(WebAssembly.compileStreaming);
455
- }
456
506
  };
457
507
 
458
508
  // gen/yosys.js
@@ -540,7 +590,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
540
590
  const ret = now();
541
591
  return toUint64(ret);
542
592
  }
543
- function trampoline9() {
593
+ function trampoline8() {
544
594
  const ret = getStderr();
545
595
  if (!(ret instanceof OutputStream2)) {
546
596
  throw new Error('Resource error: Not a valid "OutputStream" resource.');
@@ -549,7 +599,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
549
599
  handleTable2.set(handle0, { rep: ret, own: true });
550
600
  return handle0;
551
601
  }
552
- function trampoline10(arg0) {
602
+ function trampoline9(arg0) {
553
603
  let variant0;
554
604
  switch (arg0) {
555
605
  case 0: {
@@ -572,7 +622,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
572
622
  }
573
623
  exit(variant0);
574
624
  }
575
- function trampoline11() {
625
+ function trampoline10() {
576
626
  const ret = getStdin();
577
627
  if (!(ret instanceof InputStream2)) {
578
628
  throw new Error('Resource error: Not a valid "InputStream" resource.');
@@ -581,7 +631,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
581
631
  handleTable1.set(handle0, { rep: ret, own: true });
582
632
  return handle0;
583
633
  }
584
- function trampoline12() {
634
+ function trampoline11() {
585
635
  const ret = getStdout();
586
636
  if (!(ret instanceof OutputStream2)) {
587
637
  throw new Error('Resource error: Not a valid "OutputStream" resource.');
@@ -591,7 +641,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
591
641
  return handle0;
592
642
  }
593
643
  let exports2;
594
- function trampoline13(arg0) {
644
+ function trampoline12(arg0) {
595
645
  const ret = getDirectories();
596
646
  var vec3 = ret;
597
647
  var len3 = vec3.length;
@@ -603,8 +653,8 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
603
653
  if (!(tuple0_0 instanceof Descriptor2)) {
604
654
  throw new Error('Resource error: Not a valid "Descriptor" resource.');
605
655
  }
606
- var handle1 = handleCnt3++;
607
- handleTable3.set(handle1, { rep: tuple0_0, own: true });
656
+ var handle1 = handleCnt5++;
657
+ handleTable5.set(handle1, { rep: tuple0_0, own: true });
608
658
  dataView(memory0).setInt32(base + 0, handle1, true);
609
659
  var ptr2 = utf8Encode(tuple0_1, realloc0, memory0);
610
660
  var len2 = utf8EncodedLen;
@@ -616,15 +666,15 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
616
666
  }
617
667
  let memory0;
618
668
  let realloc0;
619
- function trampoline14(arg0) {
669
+ function trampoline13(arg0) {
620
670
  const ret = now$1();
621
671
  var { seconds: v0_0, nanoseconds: v0_1 } = ret;
622
672
  dataView(memory0).setBigInt64(arg0 + 0, toUint64(v0_0), true);
623
673
  dataView(memory0).setInt32(arg0 + 8, toUint32(v0_1), true);
624
674
  }
625
- function trampoline15(arg0, arg1, arg2) {
675
+ function trampoline14(arg0, arg1, arg2) {
626
676
  var handle1 = arg0;
627
- var rsc0 = handleTable3.get(handle1).rep;
677
+ var rsc0 = handleTable5.get(handle1).rep;
628
678
  let ret;
629
679
  try {
630
680
  ret = { tag: "ok", val: Descriptor2.prototype.readViaStream.call(rsc0, BigInt.asUintN(64, arg1)) };
@@ -813,9 +863,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
813
863
  }
814
864
  }
815
865
  }
816
- function trampoline16(arg0, arg1, arg2) {
866
+ function trampoline15(arg0, arg1, arg2) {
817
867
  var handle1 = arg0;
818
- var rsc0 = handleTable3.get(handle1).rep;
868
+ var rsc0 = handleTable5.get(handle1).rep;
819
869
  let ret;
820
870
  try {
821
871
  ret = { tag: "ok", val: Descriptor2.prototype.writeViaStream.call(rsc0, BigInt.asUintN(64, arg1)) };
@@ -1004,9 +1054,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
1004
1054
  }
1005
1055
  }
1006
1056
  }
1007
- function trampoline17(arg0, arg1) {
1057
+ function trampoline16(arg0, arg1) {
1008
1058
  var handle1 = arg0;
1009
- var rsc0 = handleTable3.get(handle1).rep;
1059
+ var rsc0 = handleTable5.get(handle1).rep;
1010
1060
  let ret;
1011
1061
  try {
1012
1062
  ret = { tag: "ok", val: Descriptor2.prototype.appendViaStream.call(rsc0) };
@@ -1195,9 +1245,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
1195
1245
  }
1196
1246
  }
1197
1247
  }
1198
- function trampoline18(arg0, arg1) {
1248
+ function trampoline17(arg0, arg1) {
1199
1249
  var handle1 = arg0;
1200
- var rsc0 = handleTable3.get(handle1).rep;
1250
+ var rsc0 = handleTable5.get(handle1).rep;
1201
1251
  let ret;
1202
1252
  try {
1203
1253
  ret = { tag: "ok", val: Descriptor2.prototype.getFlags.call(rsc0) };
@@ -1387,9 +1437,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
1387
1437
  }
1388
1438
  }
1389
1439
  }
1390
- function trampoline19(arg0, arg1) {
1440
+ function trampoline18(arg0, arg1) {
1391
1441
  var handle1 = arg0;
1392
- var rsc0 = handleTable3.get(handle1).rep;
1442
+ var rsc0 = handleTable5.get(handle1).rep;
1393
1443
  let ret;
1394
1444
  try {
1395
1445
  ret = { tag: "ok", val: Descriptor2.prototype.getType.call(rsc0) };
@@ -1615,9 +1665,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
1615
1665
  }
1616
1666
  }
1617
1667
  }
1618
- function trampoline20(arg0, arg1) {
1668
+ function trampoline19(arg0, arg1) {
1619
1669
  var handle1 = arg0;
1620
- var rsc0 = handleTable3.get(handle1).rep;
1670
+ var rsc0 = handleTable5.get(handle1).rep;
1621
1671
  let ret;
1622
1672
  try {
1623
1673
  ret = { tag: "ok", val: Descriptor2.prototype.readDirectory.call(rsc0) };
@@ -1632,8 +1682,8 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
1632
1682
  if (!(e instanceof DirectoryEntryStream2)) {
1633
1683
  throw new Error('Resource error: Not a valid "DirectoryEntryStream" resource.');
1634
1684
  }
1635
- var handle2 = handleCnt4++;
1636
- handleTable4.set(handle2, { rep: e, own: true });
1685
+ var handle2 = handleCnt6++;
1686
+ handleTable6.set(handle2, { rep: e, own: true });
1637
1687
  dataView(memory0).setInt32(arg1 + 4, handle2, true);
1638
1688
  break;
1639
1689
  }
@@ -1806,9 +1856,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
1806
1856
  }
1807
1857
  }
1808
1858
  }
1809
- function trampoline21(arg0, arg1, arg2, arg3) {
1859
+ function trampoline20(arg0, arg1, arg2, arg3) {
1810
1860
  var handle1 = arg0;
1811
- var rsc0 = handleTable3.get(handle1).rep;
1861
+ var rsc0 = handleTable5.get(handle1).rep;
1812
1862
  var ptr2 = arg1;
1813
1863
  var len2 = arg2;
1814
1864
  var result2 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr2, len2));
@@ -1994,9 +2044,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
1994
2044
  }
1995
2045
  }
1996
2046
  }
1997
- function trampoline22(arg0, arg1) {
2047
+ function trampoline21(arg0, arg1) {
1998
2048
  var handle1 = arg0;
1999
- var rsc0 = handleTable3.get(handle1).rep;
2049
+ var rsc0 = handleTable5.get(handle1).rep;
2000
2050
  let ret;
2001
2051
  try {
2002
2052
  ret = { tag: "ok", val: Descriptor2.prototype.stat.call(rsc0) };
@@ -2255,9 +2305,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
2255
2305
  }
2256
2306
  }
2257
2307
  }
2258
- function trampoline23(arg0, arg1, arg2, arg3, arg4) {
2308
+ function trampoline22(arg0, arg1, arg2, arg3, arg4) {
2259
2309
  var handle1 = arg0;
2260
- var rsc0 = handleTable3.get(handle1).rep;
2310
+ var rsc0 = handleTable5.get(handle1).rep;
2261
2311
  if ((arg1 & 4294967294) !== 0) {
2262
2312
  throw new TypeError("flags have extraneous bits set");
2263
2313
  }
@@ -2525,9 +2575,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
2525
2575
  }
2526
2576
  }
2527
2577
  }
2528
- function trampoline24(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
2578
+ function trampoline23(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
2529
2579
  var handle1 = arg0;
2530
- var rsc0 = handleTable3.get(handle1).rep;
2580
+ var rsc0 = handleTable5.get(handle1).rep;
2531
2581
  if ((arg1 & 4294967294) !== 0) {
2532
2582
  throw new TypeError("flags have extraneous bits set");
2533
2583
  }
@@ -2571,8 +2621,8 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
2571
2621
  if (!(e instanceof Descriptor2)) {
2572
2622
  throw new Error('Resource error: Not a valid "Descriptor" resource.');
2573
2623
  }
2574
- var handle6 = handleCnt3++;
2575
- handleTable3.set(handle6, { rep: e, own: true });
2624
+ var handle6 = handleCnt5++;
2625
+ handleTable5.set(handle6, { rep: e, own: true });
2576
2626
  dataView(memory0).setInt32(arg6 + 4, handle6, true);
2577
2627
  break;
2578
2628
  }
@@ -2745,9 +2795,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
2745
2795
  }
2746
2796
  }
2747
2797
  }
2748
- function trampoline25(arg0, arg1, arg2, arg3) {
2798
+ function trampoline24(arg0, arg1, arg2, arg3) {
2749
2799
  var handle1 = arg0;
2750
- var rsc0 = handleTable3.get(handle1).rep;
2800
+ var rsc0 = handleTable5.get(handle1).rep;
2751
2801
  var ptr2 = arg1;
2752
2802
  var len2 = arg2;
2753
2803
  var result2 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr2, len2));
@@ -2933,9 +2983,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
2933
2983
  }
2934
2984
  }
2935
2985
  }
2936
- function trampoline26(arg0, arg1, arg2, arg3) {
2986
+ function trampoline25(arg0, arg1, arg2, arg3) {
2937
2987
  var handle1 = arg0;
2938
- var rsc0 = handleTable3.get(handle1).rep;
2988
+ var rsc0 = handleTable5.get(handle1).rep;
2939
2989
  var ptr2 = arg1;
2940
2990
  var len2 = arg2;
2941
2991
  var result2 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr2, len2));
@@ -3121,9 +3171,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
3121
3171
  }
3122
3172
  }
3123
3173
  }
3124
- function trampoline27(arg0, arg1) {
3174
+ function trampoline26(arg0, arg1) {
3125
3175
  var handle1 = arg0;
3126
- var rsc0 = handleTable3.get(handle1).rep;
3176
+ var rsc0 = handleTable5.get(handle1).rep;
3127
3177
  let ret;
3128
3178
  try {
3129
3179
  ret = { tag: "ok", val: Descriptor2.prototype.metadataHash.call(rsc0) };
@@ -3309,9 +3359,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
3309
3359
  }
3310
3360
  }
3311
3361
  }
3312
- function trampoline28(arg0, arg1, arg2, arg3, arg4) {
3362
+ function trampoline27(arg0, arg1, arg2, arg3, arg4) {
3313
3363
  var handle1 = arg0;
3314
- var rsc0 = handleTable3.get(handle1).rep;
3364
+ var rsc0 = handleTable5.get(handle1).rep;
3315
3365
  if ((arg1 & 4294967294) !== 0) {
3316
3366
  throw new TypeError("flags have extraneous bits set");
3317
3367
  }
@@ -3506,9 +3556,9 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
3506
3556
  }
3507
3557
  }
3508
3558
  }
3509
- function trampoline29(arg0, arg1) {
3559
+ function trampoline28(arg0, arg1) {
3510
3560
  var handle1 = arg0;
3511
- var rsc0 = handleTable4.get(handle1).rep;
3561
+ var rsc0 = handleTable6.get(handle1).rep;
3512
3562
  let ret;
3513
3563
  try {
3514
3564
  ret = { tag: "ok", val: DirectoryEntryStream2.prototype.readDirectoryEntry.call(rsc0) };
@@ -3746,7 +3796,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
3746
3796
  }
3747
3797
  }
3748
3798
  }
3749
- function trampoline30(arg0, arg1) {
3799
+ function trampoline29(arg0, arg1) {
3750
3800
  var handle1 = arg0;
3751
3801
  var rsc0 = handleTable0.get(handle1).rep;
3752
3802
  const ret = filesystemErrorCode(rsc0);
@@ -3917,7 +3967,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
3917
3967
  dataView(memory0).setInt8(arg1 + 1, enum2, true);
3918
3968
  }
3919
3969
  }
3920
- function trampoline31(arg0, arg1, arg2) {
3970
+ function trampoline30(arg0, arg1, arg2) {
3921
3971
  var handle1 = arg0;
3922
3972
  var rsc0 = handleTable1.get(handle1).rep;
3923
3973
  let ret;
@@ -3971,7 +4021,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
3971
4021
  }
3972
4022
  }
3973
4023
  }
3974
- function trampoline32(arg0, arg1, arg2) {
4024
+ function trampoline31(arg0, arg1, arg2) {
3975
4025
  var handle1 = arg0;
3976
4026
  var rsc0 = handleTable1.get(handle1).rep;
3977
4027
  let ret;
@@ -4025,7 +4075,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4025
4075
  }
4026
4076
  }
4027
4077
  }
4028
- function trampoline33(arg0, arg1) {
4078
+ function trampoline32(arg0, arg1) {
4029
4079
  var handle1 = arg0;
4030
4080
  var rsc0 = handleTable2.get(handle1).rep;
4031
4081
  let ret;
@@ -4073,7 +4123,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4073
4123
  }
4074
4124
  }
4075
4125
  }
4076
- function trampoline34(arg0, arg1, arg2, arg3) {
4126
+ function trampoline33(arg0, arg1, arg2, arg3) {
4077
4127
  var handle1 = arg0;
4078
4128
  var rsc0 = handleTable2.get(handle1).rep;
4079
4129
  var ptr2 = arg1;
@@ -4123,7 +4173,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4123
4173
  }
4124
4174
  }
4125
4175
  }
4126
- function trampoline35(arg0, arg1, arg2, arg3) {
4176
+ function trampoline34(arg0, arg1, arg2, arg3) {
4127
4177
  var handle1 = arg0;
4128
4178
  var rsc0 = handleTable2.get(handle1).rep;
4129
4179
  var ptr2 = arg1;
@@ -4173,7 +4223,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4173
4223
  }
4174
4224
  }
4175
4225
  }
4176
- function trampoline36(arg0, arg1) {
4226
+ function trampoline35(arg0, arg1) {
4177
4227
  var handle1 = arg0;
4178
4228
  var rsc0 = handleTable2.get(handle1).rep;
4179
4229
  let ret;
@@ -4220,7 +4270,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4220
4270
  }
4221
4271
  }
4222
4272
  }
4223
- function trampoline37(arg0) {
4273
+ function trampoline36(arg0) {
4224
4274
  const ret = getEnvironment();
4225
4275
  var vec3 = ret;
4226
4276
  var len3 = vec3.length;
@@ -4241,7 +4291,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4241
4291
  dataView(memory0).setInt32(arg0 + 4, len3, true);
4242
4292
  dataView(memory0).setInt32(arg0 + 0, result3, true);
4243
4293
  }
4244
- function trampoline38(arg0) {
4294
+ function trampoline37(arg0) {
4245
4295
  const ret = getArguments();
4246
4296
  var vec1 = ret;
4247
4297
  var len1 = vec1.length;
@@ -4257,7 +4307,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4257
4307
  dataView(memory0).setInt32(arg0 + 4, len1, true);
4258
4308
  dataView(memory0).setInt32(arg0 + 0, result1, true);
4259
4309
  }
4260
- function trampoline39(arg0) {
4310
+ function trampoline38(arg0) {
4261
4311
  const ret = getTerminalStdin();
4262
4312
  var variant1 = ret;
4263
4313
  if (variant1 === null || variant1 === void 0) {
@@ -4268,12 +4318,12 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4268
4318
  if (!(e instanceof TerminalInput2)) {
4269
4319
  throw new Error('Resource error: Not a valid "TerminalInput" resource.');
4270
4320
  }
4271
- var handle0 = handleCnt6++;
4272
- handleTable6.set(handle0, { rep: e, own: true });
4321
+ var handle0 = handleCnt3++;
4322
+ handleTable3.set(handle0, { rep: e, own: true });
4273
4323
  dataView(memory0).setInt32(arg0 + 4, handle0, true);
4274
4324
  }
4275
4325
  }
4276
- function trampoline40(arg0) {
4326
+ function trampoline39(arg0) {
4277
4327
  const ret = getTerminalStdout();
4278
4328
  var variant1 = ret;
4279
4329
  if (variant1 === null || variant1 === void 0) {
@@ -4284,12 +4334,12 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4284
4334
  if (!(e instanceof TerminalOutput2)) {
4285
4335
  throw new Error('Resource error: Not a valid "TerminalOutput" resource.');
4286
4336
  }
4287
- var handle0 = handleCnt7++;
4288
- handleTable7.set(handle0, { rep: e, own: true });
4337
+ var handle0 = handleCnt4++;
4338
+ handleTable4.set(handle0, { rep: e, own: true });
4289
4339
  dataView(memory0).setInt32(arg0 + 4, handle0, true);
4290
4340
  }
4291
4341
  }
4292
- function trampoline41(arg0) {
4342
+ function trampoline40(arg0) {
4293
4343
  const ret = getTerminalStderr();
4294
4344
  var variant1 = ret;
4295
4345
  if (variant1 === null || variant1 === void 0) {
@@ -4300,18 +4350,18 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4300
4350
  if (!(e instanceof TerminalOutput2)) {
4301
4351
  throw new Error('Resource error: Not a valid "TerminalOutput" resource.');
4302
4352
  }
4303
- var handle0 = handleCnt7++;
4304
- handleTable7.set(handle0, { rep: e, own: true });
4353
+ var handle0 = handleCnt4++;
4354
+ handleTable4.set(handle0, { rep: e, own: true });
4305
4355
  dataView(memory0).setInt32(arg0 + 4, handle0, true);
4306
4356
  }
4307
4357
  }
4308
4358
  let exports3;
4309
4359
  function trampoline1(handle) {
4310
- const handleEntry = handleTable4.get(handle);
4360
+ const handleEntry = handleTable6.get(handle);
4311
4361
  if (!handleEntry) {
4312
4362
  throw new Error(`Resource error: Invalid handle ${handle}`);
4313
4363
  }
4314
- handleTable4.delete(handle);
4364
+ handleTable6.delete(handle);
4315
4365
  if (handleEntry.own && handleEntry.rep[symbolDispose]) {
4316
4366
  handleEntry.rep[symbolDispose]();
4317
4367
  }
@@ -4347,16 +4397,6 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4347
4397
  }
4348
4398
  }
4349
4399
  function trampoline5(handle) {
4350
- const handleEntry = handleTable3.get(handle);
4351
- if (!handleEntry) {
4352
- throw new Error(`Resource error: Invalid handle ${handle}`);
4353
- }
4354
- handleTable3.delete(handle);
4355
- if (handleEntry.own && handleEntry.rep[symbolDispose]) {
4356
- handleEntry.rep[symbolDispose]();
4357
- }
4358
- }
4359
- function trampoline6(handle) {
4360
4400
  const handleEntry = handleTable5.get(handle);
4361
4401
  if (!handleEntry) {
4362
4402
  throw new Error(`Resource error: Invalid handle ${handle}`);
@@ -4366,22 +4406,22 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4366
4406
  handleEntry.rep[symbolDispose]();
4367
4407
  }
4368
4408
  }
4369
- function trampoline7(handle) {
4370
- const handleEntry = handleTable7.get(handle);
4409
+ function trampoline6(handle) {
4410
+ const handleEntry = handleTable4.get(handle);
4371
4411
  if (!handleEntry) {
4372
4412
  throw new Error(`Resource error: Invalid handle ${handle}`);
4373
4413
  }
4374
- handleTable7.delete(handle);
4414
+ handleTable4.delete(handle);
4375
4415
  if (handleEntry.own && handleEntry.rep[symbolDispose]) {
4376
4416
  handleEntry.rep[symbolDispose]();
4377
4417
  }
4378
4418
  }
4379
- function trampoline8(handle) {
4380
- const handleEntry = handleTable6.get(handle);
4419
+ function trampoline7(handle) {
4420
+ const handleEntry = handleTable3.get(handle);
4381
4421
  if (!handleEntry) {
4382
4422
  throw new Error(`Resource error: Invalid handle ${handle}`);
4383
4423
  }
4384
- handleTable6.delete(handle);
4424
+ handleTable3.delete(handle);
4385
4425
  if (handleEntry.own && handleEntry.rep[symbolDispose]) {
4386
4426
  handleEntry.rep[symbolDispose]();
4387
4427
  }
@@ -4421,35 +4461,35 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4421
4461
  env: {
4422
4462
  memory: exports1.memory
4423
4463
  },
4424
- "wasi:cli/environment@0.2.0-rc-2023-11-10": {
4464
+ "wasi:cli/environment@0.2.0-rc-2023-12-05": {
4425
4465
  "get-arguments": exports0["25"],
4426
4466
  "get-environment": exports0["24"]
4427
4467
  },
4428
- "wasi:cli/exit@0.2.0-rc-2023-11-10": {
4429
- exit: trampoline10
4468
+ "wasi:cli/exit@0.2.0-rc-2023-12-05": {
4469
+ exit: trampoline9
4430
4470
  },
4431
- "wasi:cli/stderr@0.2.0-rc-2023-11-10": {
4432
- "get-stderr": trampoline9
4471
+ "wasi:cli/stderr@0.2.0-rc-2023-12-05": {
4472
+ "get-stderr": trampoline8
4433
4473
  },
4434
- "wasi:cli/stdin@0.2.0-rc-2023-11-10": {
4435
- "get-stdin": trampoline11
4474
+ "wasi:cli/stdin@0.2.0-rc-2023-12-05": {
4475
+ "get-stdin": trampoline10
4436
4476
  },
4437
- "wasi:cli/stdout@0.2.0-rc-2023-11-10": {
4438
- "get-stdout": trampoline12
4477
+ "wasi:cli/stdout@0.2.0-rc-2023-12-05": {
4478
+ "get-stdout": trampoline11
4439
4479
  },
4440
- "wasi:cli/terminal-input@0.2.0-rc-2023-11-10": {
4441
- "[resource-drop]terminal-input": trampoline8
4480
+ "wasi:cli/terminal-input@0.2.0-rc-2023-12-05": {
4481
+ "[resource-drop]terminal-input": trampoline7
4442
4482
  },
4443
- "wasi:cli/terminal-output@0.2.0-rc-2023-11-10": {
4444
- "[resource-drop]terminal-output": trampoline7
4483
+ "wasi:cli/terminal-output@0.2.0-rc-2023-12-05": {
4484
+ "[resource-drop]terminal-output": trampoline6
4445
4485
  },
4446
- "wasi:cli/terminal-stderr@0.2.0-rc-2023-11-10": {
4486
+ "wasi:cli/terminal-stderr@0.2.0-rc-2023-12-05": {
4447
4487
  "get-terminal-stderr": exports0["28"]
4448
4488
  },
4449
- "wasi:cli/terminal-stdin@0.2.0-rc-2023-11-10": {
4489
+ "wasi:cli/terminal-stdin@0.2.0-rc-2023-12-05": {
4450
4490
  "get-terminal-stdin": exports0["26"]
4451
4491
  },
4452
- "wasi:cli/terminal-stdout@0.2.0-rc-2023-11-10": {
4492
+ "wasi:cli/terminal-stdout@0.2.0-rc-2023-12-05": {
4453
4493
  "get-terminal-stdout": exports0["27"]
4454
4494
  },
4455
4495
  "wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10": {
@@ -4493,9 +4533,6 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4493
4533
  "[method]output-stream.write": exports0["21"],
4494
4534
  "[resource-drop]input-stream": trampoline3,
4495
4535
  "[resource-drop]output-stream": trampoline4
4496
- },
4497
- "wasi:sockets/tcp@0.2.0-rc-2023-11-10": {
4498
- "[resource-drop]tcp-socket": trampoline6
4499
4536
  }
4500
4537
  }));
4501
4538
  memory0 = exports1.memory;
@@ -4503,30 +4540,30 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4503
4540
  ({ exports: exports3 } = await instantiateCore(await module3, {
4504
4541
  "": {
4505
4542
  $imports: exports0.$imports,
4506
- "0": trampoline13,
4507
- "1": trampoline14,
4508
- "10": trampoline23,
4509
- "11": trampoline24,
4510
- "12": trampoline25,
4511
- "13": trampoline26,
4512
- "14": trampoline27,
4513
- "15": trampoline28,
4514
- "16": trampoline29,
4515
- "17": trampoline30,
4516
- "18": trampoline31,
4517
- "19": trampoline32,
4518
- "2": trampoline15,
4519
- "20": trampoline33,
4520
- "21": trampoline34,
4521
- "22": trampoline35,
4522
- "23": trampoline36,
4523
- "24": trampoline37,
4524
- "25": trampoline38,
4525
- "26": trampoline39,
4526
- "27": trampoline40,
4527
- "28": trampoline41,
4543
+ "0": trampoline12,
4544
+ "1": trampoline13,
4545
+ "10": trampoline22,
4546
+ "11": trampoline23,
4547
+ "12": trampoline24,
4548
+ "13": trampoline25,
4549
+ "14": trampoline26,
4550
+ "15": trampoline27,
4551
+ "16": trampoline28,
4552
+ "17": trampoline29,
4553
+ "18": trampoline30,
4554
+ "19": trampoline31,
4555
+ "2": trampoline14,
4556
+ "20": trampoline32,
4557
+ "21": trampoline33,
4558
+ "22": trampoline34,
4559
+ "23": trampoline35,
4560
+ "24": trampoline36,
4561
+ "25": trampoline37,
4562
+ "26": trampoline38,
4563
+ "27": trampoline39,
4564
+ "28": trampoline40,
4528
4565
  "29": exports2.args_get,
4529
- "3": trampoline16,
4566
+ "3": trampoline15,
4530
4567
  "30": exports2.args_sizes_get,
4531
4568
  "31": exports2.environ_get,
4532
4569
  "32": exports2.environ_sizes_get,
@@ -4537,7 +4574,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4537
4574
  "37": exports2.fd_prestat_get,
4538
4575
  "38": exports2.fd_prestat_dir_name,
4539
4576
  "39": exports2.fd_read,
4540
- "4": trampoline17,
4577
+ "4": trampoline16,
4541
4578
  "40": exports2.fd_readdir,
4542
4579
  "41": exports2.fd_renumber,
4543
4580
  "42": exports2.fd_seek,
@@ -4548,15 +4585,15 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4548
4585
  "47": exports2.path_remove_directory,
4549
4586
  "48": exports2.path_unlink_file,
4550
4587
  "49": exports2.proc_exit,
4551
- "5": trampoline18,
4552
- "6": trampoline19,
4553
- "7": trampoline20,
4554
- "8": trampoline21,
4555
- "9": trampoline22
4588
+ "5": trampoline17,
4589
+ "6": trampoline18,
4590
+ "7": trampoline19,
4591
+ "8": trampoline20,
4592
+ "9": trampoline21
4556
4593
  }
4557
4594
  }));
4558
4595
  function run() {
4559
- const ret = exports2["wasi:cli/run@0.2.0-rc-2023-11-10#run"]();
4596
+ const ret = exports2["wasi:cli/run@0.2.0-rc-2023-12-05#run"]();
4560
4597
  let variant0;
4561
4598
  switch (ret) {
4562
4599
  case 0: {
@@ -4596,12 +4633,10 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4596
4633
  let handleCnt5 = 0;
4597
4634
  const handleTable6 = /* @__PURE__ */ new Map();
4598
4635
  let handleCnt6 = 0;
4599
- const handleTable7 = /* @__PURE__ */ new Map();
4600
- let handleCnt7 = 0;
4601
- const run0_2_0Rc20231110 = {
4636
+ const run0_2_0Rc20231205 = {
4602
4637
  run
4603
4638
  };
4604
- return { run: run0_2_0Rc20231110, "wasi:cli/run@0.2.0-rc-2023-11-10": run0_2_0Rc20231110 };
4639
+ return { run: run0_2_0Rc20231205, "wasi:cli/run@0.2.0-rc-2023-12-05": run0_2_0Rc20231205 };
4605
4640
  }
4606
4641
 
4607
4642
  // lib/api.js