@yowasp/yosys 0.59.84-dev.1025 → 0.59.1037

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/gen/bundle.js CHANGED
@@ -1,137 +1,13 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __esm = (fn, res) => function __init() {
4
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
5
- };
6
2
  var __export = (target, all) => {
7
3
  for (var name in all)
8
4
  __defProp(target, name, { get: all[name], enumerable: true });
9
5
  };
10
6
 
11
- // node_modules/nanotar/dist/index.mjs
12
- function parseTar(data, opts) {
13
- const buffer = data.buffer || data;
14
- const files = [];
15
- let offset = 0;
16
- while (offset < buffer.byteLength - 512) {
17
- const name = _readString(buffer, offset, 100);
18
- if (name.length === 0) {
19
- break;
20
- }
21
- const mode = _readString(buffer, offset + 100, 8).trim();
22
- const uid = Number.parseInt(_readString(buffer, offset + 108, 8));
23
- const gid = Number.parseInt(_readString(buffer, offset + 116, 8));
24
- const size = _readNumber(buffer, offset + 124, 12);
25
- const seek = 512 + 512 * Math.trunc(size / 512) + (size % 512 ? 512 : 0);
26
- const mtime = _readNumber(buffer, offset + 136, 12);
27
- const _type = _readNumber(buffer, offset + 156, 1);
28
- const type = _type === TAR_TYPE_FILE ? "file" : _type === TAR_TYPE_DIR ? "directory" : _type;
29
- const user = _readString(buffer, offset + 265, 32);
30
- const group = _readString(buffer, offset + 297, 32);
31
- const meta = {
32
- name,
33
- type,
34
- size,
35
- attrs: {
36
- mode,
37
- uid,
38
- gid,
39
- mtime,
40
- user,
41
- group
42
- }
43
- };
44
- if (opts?.filter && !opts.filter(meta)) {
45
- offset += seek;
46
- continue;
47
- }
48
- if (opts?.metaOnly) {
49
- files.push(meta);
50
- offset += seek;
51
- continue;
52
- }
53
- const data2 = _type === TAR_TYPE_DIR ? void 0 : new Uint8Array(buffer, offset + 512, size);
54
- files.push({
55
- ...meta,
56
- data: data2,
57
- get text() {
58
- return new TextDecoder().decode(this.data);
59
- }
60
- });
61
- offset += seek;
62
- }
63
- return files;
64
- }
65
- function _readString(buffer, offset, size) {
66
- const view = new Uint8Array(buffer, offset, size);
67
- const i = view.indexOf(0);
68
- const td = new TextDecoder();
69
- return td.decode(i === -1 ? view : view.slice(0, i));
70
- }
71
- function _readNumber(buffer, offset, size) {
72
- const view = new Uint8Array(buffer, offset, size);
73
- let str = "";
74
- for (let i = 0; i < size; i++) {
75
- str += String.fromCodePoint(view[i]);
76
- }
77
- return Number.parseInt(str, 8);
78
- }
79
- var TAR_TYPE_FILE, TAR_TYPE_DIR;
80
- var init_dist = __esm({
81
- "node_modules/nanotar/dist/index.mjs"() {
82
- TAR_TYPE_FILE = 0;
83
- TAR_TYPE_DIR = 5;
84
- }
85
- });
86
-
87
- // gen/yosys-resources.js
88
- var yosys_resources_exports = {};
89
- __export(yosys_resources_exports, {
90
- filesystem: () => filesystem,
91
- modules: () => modules
92
- });
93
- function unpackResources(url) {
94
- function defaultFetchFn(url2) {
95
- return fetch(url2).then((resp) => resp.arrayBuffer());
96
- }
97
- return async (fetchFn = defaultFetchFn) => {
98
- const root = {};
99
- for (const tarEntry of parseTar(await fetchFn(url))) {
100
- const nameParts = tarEntry.name.split("/");
101
- const dirNames = nameParts.slice(0, -1);
102
- const fileName = nameParts[nameParts.length - 1];
103
- let dir = root;
104
- for (const dirName of dirNames)
105
- dir = dir[dirName];
106
- if (tarEntry.type === "directory") {
107
- dir[fileName] = {};
108
- } else {
109
- dir[fileName] = tarEntry.data;
110
- }
111
- }
112
- return root;
113
- };
114
- }
115
- var modules, filesystem;
116
- var init_yosys_resources = __esm({
117
- "gen/yosys-resources.js"() {
118
- init_dist();
119
- modules = {
120
- "yosys.core.wasm": new URL("./yosys.core.wasm", import.meta.url),
121
- "yosys.core2.wasm": new URL("./yosys.core2.wasm", import.meta.url),
122
- "yosys.core3.wasm": new URL("./yosys.core3.wasm", import.meta.url),
123
- "yosys.core4.wasm": new URL("./yosys.core4.wasm", import.meta.url)
124
- };
125
- filesystem = {
126
- share: unpackResources(new URL("./yosys-resources.tar", import.meta.url))
127
- };
128
- }
129
- });
130
-
131
7
  // node_modules/@yowasp/runtime/lib/fetch.js
132
- var fetch2;
8
+ var fetch;
133
9
  if (typeof process === "object" && process.release?.name === "node") {
134
- fetch2 = async function(url, options) {
10
+ fetch = async function(url, options) {
135
11
  if (url.protocol === "file:") {
136
12
  const { readFile } = await import("node:fs/promises");
137
13
  const data = await readFile(url);
@@ -146,9 +22,9 @@ if (typeof process === "object" && process.release?.name === "node") {
146
22
  }
147
23
  };
148
24
  } else {
149
- fetch2 = globalThis.fetch;
25
+ fetch = globalThis.fetch;
150
26
  }
151
- var fetch_default = fetch2;
27
+ var fetch_default = fetch;
152
28
 
153
29
  // node_modules/@yowasp/runtime/lib/wasi-virt.js
154
30
  var Exit = class extends Error {
@@ -616,81 +492,13 @@ function lineBuffered(processLine) {
616
492
  }
617
493
 
618
494
  // node_modules/@yowasp/runtime/lib/api.js
619
- async function fetchObject(obj, fetchFn) {
620
- const promises = [];
621
- for (const [key, value] of Object.entries(obj)) {
622
- if (typeof value === "string" || value instanceof Uint8Array) {
623
- promises.push(Promise.resolve([key, value]));
624
- } else if (value instanceof URL) {
625
- promises.push(fetchFn(value).then((fetched) => [key, fetched]));
626
- } else if (value instanceof Function) {
627
- promises.push(await value(fetchFn).then((fetched) => [key, fetched]));
628
- } else {
629
- promises.push(fetchObject(value, fetchFn).then((fetched) => [key, fetched]));
630
- }
631
- }
632
- for (const [key, value] of await Promise.all(promises))
633
- obj[key] = value;
634
- return obj;
635
- }
636
- function fetchWebAssembly(url, monitorProgress) {
637
- const response = fetch_default(url).then(monitorProgress);
638
- if (WebAssembly.compileStreaming !== void 0) {
639
- return response.then(WebAssembly.compileStreaming);
640
- } else {
641
- return response.then((resp) => resp.arrayBuffer()).then(WebAssembly.compile);
642
- }
643
- }
644
- function fetchUint8Array(url, monitorProgress) {
645
- const response = fetch_default(url).then(monitorProgress);
646
- return response.then((resp) => resp.arrayBuffer()).then((buf) => new Uint8Array(buf));
647
- }
648
- function fetchResources({ modules: modules2, filesystem: filesystem2 }, fetchProgress, application) {
649
- let monitorProgress = (response) => response;
650
- if (fetchProgress !== void 0) {
651
- const progress = /* @__PURE__ */ new Map();
652
- const notifyProgress = () => {
653
- let cumTotalLength = 0, cumDoneLength = 0;
654
- for (const { totalLength, doneLength } of progress.values()) {
655
- cumTotalLength += totalLength;
656
- cumDoneLength += doneLength;
657
- }
658
- fetchProgress({
659
- source: application,
660
- totalLength: cumTotalLength,
661
- doneLength: cumDoneLength
662
- });
663
- };
664
- monitorProgress = (response) => {
665
- let totalLength = +response.headers.get("content-length");
666
- let doneLength = 0;
667
- progress.set(response, { totalLength, doneLength });
668
- notifyProgress();
669
- const monitorStream = new TransformStream({
670
- transform(chunk, controller) {
671
- controller.enqueue(chunk);
672
- doneLength += chunk.length;
673
- progress.set(response, { totalLength, doneLength });
674
- notifyProgress();
675
- }
676
- });
677
- return new Response(response.body.pipeThrough(monitorStream), response);
678
- };
679
- }
680
- return Promise.all([
681
- fetchObject(modules2, (url) => fetchWebAssembly(url, monitorProgress)),
682
- fetchObject(filesystem2, (url) => fetchUint8Array(url, monitorProgress))
683
- ]).then(([modules3, filesystem3]) => {
684
- return { modules: modules3, filesystem: filesystem3 };
685
- });
686
- }
687
495
  var Application = class {
688
- #resources;
496
+ #resourceModule;
689
497
  #resourceData;
690
498
  #instantiate;
691
499
  #argv0;
692
- constructor(resources, instantiate2, argv0) {
693
- this.#resources = resources;
500
+ constructor(resourceModule, instantiate2, argv0) {
501
+ this.#resourceModule = resourceModule;
694
502
  this.#resourceData = null;
695
503
  this.#instantiate = instantiate2;
696
504
  this.#argv0 = argv0;
@@ -698,6 +506,28 @@ var Application = class {
698
506
  get argv0() {
699
507
  return this.#argv0;
700
508
  }
509
+ async #fetchResources(fetchProgress) {
510
+ const resourceModule = await this.#resourceModule;
511
+ let fetchFn = fetch_default;
512
+ if (fetchProgress !== void 0) {
513
+ const status = { source: this, totalLength: resourceModule.totalSize, doneLength: 0 };
514
+ fetchProgress(status);
515
+ fetchFn = (input, init) => fetch_default(input, init).then((response) => {
516
+ return new Response(response.body.pipeThrough(new TransformStream({
517
+ transform(chunk, controller) {
518
+ controller.enqueue(chunk);
519
+ status.doneLength += chunk.length;
520
+ fetchProgress(status);
521
+ }
522
+ })), response);
523
+ });
524
+ }
525
+ const [modules2, filesystem2] = await Promise.all([
526
+ resourceModule.modules(fetchFn),
527
+ resourceModule.filesystem(fetchFn)
528
+ ]);
529
+ this.#resourceData = { modules: modules2, filesystem: filesystem2 };
530
+ }
701
531
  // The `printLine` option is deprecated and not documented but still accepted for compatibility.
702
532
  run(args = null, files = {}, options = {}) {
703
533
  if (this.#resourceData === null) {
@@ -707,9 +537,7 @@ var Application = class {
707
537
  const percent = (100 * doneLength / totalLength).toFixed(0);
708
538
  console.log(`${source.argv0}: fetched ${percent}% (${doneLength} / ${totalLength})`);
709
539
  };
710
- const fetchProgress = options.fetchProgress ?? defaultFetchProgress;
711
- return this.#resources().then((resourceObject) => fetchResources(resourceObject, fetchProgress, this)).then((resourceData) => {
712
- this.#resourceData = resourceData;
540
+ return this.#fetchResources(options.fetchProgress ?? defaultFetchProgress).then(() => {
713
541
  return this.run(args, files, options);
714
542
  });
715
543
  }
@@ -755,6 +583,121 @@ var Application = class {
755
583
  }
756
584
  };
757
585
 
586
+ // gen/yosys-resources.js
587
+ var yosys_resources_exports = {};
588
+ __export(yosys_resources_exports, {
589
+ filesystem: () => filesystem,
590
+ modules: () => modules,
591
+ totalSize: () => totalSize
592
+ });
593
+
594
+ // node_modules/nanotar/dist/index.mjs
595
+ var TAR_TYPE_FILE = 0;
596
+ var TAR_TYPE_DIR = 5;
597
+ function parseTar(data, opts) {
598
+ const buffer = data.buffer || data;
599
+ const files = [];
600
+ let offset = 0;
601
+ while (offset < buffer.byteLength - 512) {
602
+ const name = _readString(buffer, offset, 100);
603
+ if (name.length === 0) {
604
+ break;
605
+ }
606
+ const mode = _readString(buffer, offset + 100, 8).trim();
607
+ const uid = Number.parseInt(_readString(buffer, offset + 108, 8));
608
+ const gid = Number.parseInt(_readString(buffer, offset + 116, 8));
609
+ const size = _readNumber(buffer, offset + 124, 12);
610
+ const seek = 512 + 512 * Math.trunc(size / 512) + (size % 512 ? 512 : 0);
611
+ const mtime = _readNumber(buffer, offset + 136, 12);
612
+ const _type = _readNumber(buffer, offset + 156, 1);
613
+ const type = _type === TAR_TYPE_FILE ? "file" : _type === TAR_TYPE_DIR ? "directory" : _type;
614
+ const user = _readString(buffer, offset + 265, 32);
615
+ const group = _readString(buffer, offset + 297, 32);
616
+ const meta = {
617
+ name,
618
+ type,
619
+ size,
620
+ attrs: {
621
+ mode,
622
+ uid,
623
+ gid,
624
+ mtime,
625
+ user,
626
+ group
627
+ }
628
+ };
629
+ if (opts?.filter && !opts.filter(meta)) {
630
+ offset += seek;
631
+ continue;
632
+ }
633
+ if (opts?.metaOnly) {
634
+ files.push(meta);
635
+ offset += seek;
636
+ continue;
637
+ }
638
+ const data2 = _type === TAR_TYPE_DIR ? void 0 : new Uint8Array(buffer, offset + 512, size);
639
+ files.push({
640
+ ...meta,
641
+ data: data2,
642
+ get text() {
643
+ return new TextDecoder().decode(this.data);
644
+ }
645
+ });
646
+ offset += seek;
647
+ }
648
+ return files;
649
+ }
650
+ function _readString(buffer, offset, size) {
651
+ const view = new Uint8Array(buffer, offset, size);
652
+ const i = view.indexOf(0);
653
+ const td = new TextDecoder();
654
+ return td.decode(i === -1 ? view : view.slice(0, i));
655
+ }
656
+ function _readNumber(buffer, offset, size) {
657
+ const view = new Uint8Array(buffer, offset, size);
658
+ let str = "";
659
+ for (let i = 0; i < size; i++) {
660
+ str += String.fromCodePoint(view[i]);
661
+ }
662
+ return Number.parseInt(str, 8);
663
+ }
664
+
665
+ // gen/yosys-resources.js
666
+ function compileWasmModule(response) {
667
+ if (WebAssembly.compileStreaming !== void 0) {
668
+ return WebAssembly.compileStreaming(response);
669
+ } else {
670
+ return WebAssembly.compile(response.arrayBuffer());
671
+ }
672
+ }
673
+ function unpackTarFilesystem(buffer) {
674
+ const root = {};
675
+ for (const tarEntry of parseTar(buffer)) {
676
+ const nameParts = tarEntry.name.split("/");
677
+ const dirNames = nameParts.slice(0, -1);
678
+ const fileName = nameParts[nameParts.length - 1];
679
+ let dir = root;
680
+ for (const dirName of dirNames)
681
+ dir = dir[dirName];
682
+ if (tarEntry.type === "directory") {
683
+ dir[fileName] = {};
684
+ } else {
685
+ dir[fileName] = tarEntry.data;
686
+ }
687
+ }
688
+ return root;
689
+ }
690
+ var modules = async (fetch2) => ({
691
+ "yosys.core.wasm": await fetch2(new URL("./yosys.core.wasm", import.meta.url)).then(compileWasmModule),
692
+ "yosys.core2.wasm": await fetch2(new URL("./yosys.core2.wasm", import.meta.url)).then(compileWasmModule),
693
+ "yosys.core3.wasm": await fetch2(new URL("./yosys.core3.wasm", import.meta.url)).then(compileWasmModule),
694
+ "yosys.core4.wasm": await fetch2(new URL("./yosys.core4.wasm", import.meta.url)).then(compileWasmModule)
695
+ });
696
+ var filesystem = async (fetch2) => ({
697
+ "share": await fetch2(new URL("./yosys-resources.tar", import.meta.url)).then((resp) => resp.arrayBuffer()).then(unpackTarFilesystem)
698
+ });
699
+ var totalSize = 48972600;
700
+
758
701
  // gen/yosys.js
759
702
  var ComponentError = class extends Error {
760
703
  constructor(value) {
@@ -5640,10 +5583,10 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
5640
5583
  }
5641
5584
 
5642
5585
  // lib/api.js
5643
- var yosys = new Application(() => Promise.resolve().then(() => (init_yosys_resources(), yosys_resources_exports)), instantiate, "yowasp-yosys");
5586
+ var yosys = new Application(yosys_resources_exports, instantiate, "yowasp-yosys");
5644
5587
  var runYosys = yosys.run.bind(yosys);
5645
5588
  var commands = { "yosys": runYosys };
5646
- var version = "0.59.84-dev.1025";
5589
+ var version = "0.59.1037";
5647
5590
  export {
5648
5591
  Exit,
5649
5592
  commands,
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yowasp/yosys",
3
- "version": "0.59.84-dev.1025",
3
+ "version": "0.59.1037",
4
4
  "description": "Yosys Open SYnthesis Suite",
5
5
  "author": "Catherine <whitequark@whitequark.org>",
6
6
  "license": "ISC",
@@ -26,13 +26,13 @@
26
26
  "types": "./lib/api.d.ts",
27
27
  "devDependencies": {
28
28
  "@bytecodealliance/jco": "1.3.0",
29
- "@yowasp/runtime": "10.0.64",
29
+ "@yowasp/runtime": "11.0.66",
30
30
  "esbuild": "^0.25.11"
31
31
  },
32
32
  "scripts": {
33
33
  "transpile": "jco new ../yosys-build/yosys.wasm --wasi-command --output yosys.wasm && jco transpile yosys.wasm --instantiation async --no-typescript --no-namespaced-exports --map 'wasi:io/*=runtime#io' --map 'wasi:cli/*=runtime#cli' --map 'wasi:clocks/*=runtime#*' --map 'wasi:filesystem/*=runtime#fs' --map 'wasi:random/*=runtime#random' --out-dir gen/",
34
34
  "pack": "yowasp-pack-resources gen/yosys-resources.js gen ../yosys-build/share",
35
- "build": "esbuild --bundle lib/api.js --outfile=gen/bundle.js --format=esm --platform=node --define:VERSION=\\\"0.59.84-dev.1025\\\"",
35
+ "build": "esbuild --bundle lib/api.js --outfile=gen/bundle.js --format=esm --platform=node --define:VERSION=\\\"0.59.1037\\\"",
36
36
  "all": "npm run transpile && npm run pack && npm run build"
37
37
  }
38
38
  }