@yowasp/openfpgaloader 0.3.1-892.8 → 0.3.1-894.10
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 +70 -31
- package/gen/openFPGALoader.wasm +0 -0
- package/lib/api.d.ts +5 -2
- package/package.json +2 -1
package/gen/bundle.js
CHANGED
|
@@ -4807,6 +4807,28 @@ var instantiate = (() => {
|
|
|
4807
4807
|
})();
|
|
4808
4808
|
var openFPGALoader_default = instantiate;
|
|
4809
4809
|
|
|
4810
|
+
// node_modules/@yowasp/runtime/lib/util.js
|
|
4811
|
+
function lineBuffered(processLine) {
|
|
4812
|
+
let buffer = new Uint8Array();
|
|
4813
|
+
return (bytes) => {
|
|
4814
|
+
if (bytes === null)
|
|
4815
|
+
return;
|
|
4816
|
+
let newBuffer = new Uint8Array(buffer.length + bytes.length);
|
|
4817
|
+
newBuffer.set(buffer);
|
|
4818
|
+
newBuffer.set(bytes, buffer.length);
|
|
4819
|
+
buffer = newBuffer;
|
|
4820
|
+
let newlineAt = -1;
|
|
4821
|
+
while (true) {
|
|
4822
|
+
const nextNewlineAt = buffer.indexOf(10, newlineAt + 1);
|
|
4823
|
+
if (nextNewlineAt === -1)
|
|
4824
|
+
break;
|
|
4825
|
+
processLine(new TextDecoder().decode(buffer.subarray(newlineAt + 1, nextNewlineAt)));
|
|
4826
|
+
newlineAt = nextNewlineAt;
|
|
4827
|
+
}
|
|
4828
|
+
buffer = buffer.subarray(newlineAt + 1);
|
|
4829
|
+
};
|
|
4830
|
+
}
|
|
4831
|
+
|
|
4810
4832
|
// lib/api.js
|
|
4811
4833
|
var Exit = class extends Error {
|
|
4812
4834
|
constructor(code, files) {
|
|
@@ -4815,36 +4837,59 @@ var Exit = class extends Error {
|
|
|
4815
4837
|
this.files = files;
|
|
4816
4838
|
}
|
|
4817
4839
|
};
|
|
4818
|
-
function
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
}
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4840
|
+
function createStreamDevice(FS, path, index, ops) {
|
|
4841
|
+
const dev = FS.makedev(2, index);
|
|
4842
|
+
FS.registerDevice(dev, {
|
|
4843
|
+
open(stream) {
|
|
4844
|
+
stream.seekable = false;
|
|
4845
|
+
},
|
|
4846
|
+
read(stream, buffer, offset, length, pos) {
|
|
4847
|
+
throw new FS.ErrnoError(29);
|
|
4848
|
+
},
|
|
4849
|
+
write(stream, buffer, offset, length, pos) {
|
|
4850
|
+
if (ops.write !== void 0) {
|
|
4851
|
+
ops.write(new Uint8Array(buffer.slice(offset, offset + length)));
|
|
4852
|
+
return length;
|
|
4853
|
+
}
|
|
4854
|
+
throw new FS.ErrnoError(29);
|
|
4855
|
+
},
|
|
4856
|
+
fsync(stream) {
|
|
4857
|
+
if (ops.write !== void 0)
|
|
4858
|
+
ops.write(null);
|
|
4833
4859
|
}
|
|
4834
|
-
};
|
|
4860
|
+
});
|
|
4861
|
+
FS.mkdev(path, dev);
|
|
4862
|
+
return path;
|
|
4863
|
+
}
|
|
4864
|
+
function createStandardStreams(FS, { stdout, stderr }) {
|
|
4865
|
+
const lineBufferedConsole = lineBuffered(console.log);
|
|
4866
|
+
function makeStream(streamOption) {
|
|
4867
|
+
if (streamOption === void 0)
|
|
4868
|
+
return lineBufferedConsole;
|
|
4869
|
+
if (streamOption === null)
|
|
4870
|
+
return (_bytes) => {
|
|
4871
|
+
};
|
|
4872
|
+
return streamOption;
|
|
4873
|
+
}
|
|
4874
|
+
createStreamDevice(FS, "/dev/stdin", 0, {});
|
|
4875
|
+
createStreamDevice(FS, "/dev/stdout", 1, { write: makeStream(stdout) });
|
|
4876
|
+
createStreamDevice(FS, "/dev/stderr", 2, { write: makeStream(stderr) });
|
|
4877
|
+
FS.open("/dev/stdin", 0);
|
|
4878
|
+
FS.open("/dev/stdout", 1);
|
|
4879
|
+
FS.open("/dev/stderr", 1);
|
|
4835
4880
|
}
|
|
4836
|
-
function
|
|
4881
|
+
function writeTree(FS, tree, path = "/") {
|
|
4837
4882
|
for (const [filename, data] of Object.entries(tree)) {
|
|
4838
4883
|
const filepath = `${path}${filename}`;
|
|
4839
4884
|
if (typeof data === "string" || data instanceof Uint8Array) {
|
|
4840
4885
|
FS.writeFile(filepath, data);
|
|
4841
4886
|
} else {
|
|
4842
4887
|
FS.mkdir(filepath);
|
|
4843
|
-
|
|
4888
|
+
writeTree(FS, data, `${filepath}/`);
|
|
4844
4889
|
}
|
|
4845
4890
|
}
|
|
4846
4891
|
}
|
|
4847
|
-
function
|
|
4892
|
+
function readTree(FS, path = "/") {
|
|
4848
4893
|
const tree = {};
|
|
4849
4894
|
for (const filename of FS.readdir(path)) {
|
|
4850
4895
|
const filepath = `${path}${filename}`;
|
|
@@ -4856,23 +4901,17 @@ function readTreeFromMEMFS(FS, path = "/") {
|
|
|
4856
4901
|
if (FS.isFile(stat.mode)) {
|
|
4857
4902
|
tree[filename] = FS.readFile(filepath, { encoding: "binary" });
|
|
4858
4903
|
} else if (FS.isDir(stat.mode)) {
|
|
4859
|
-
tree[filename] =
|
|
4904
|
+
tree[filename] = readTree(FS, `${filepath}/`);
|
|
4860
4905
|
}
|
|
4861
4906
|
}
|
|
4862
4907
|
return tree;
|
|
4863
4908
|
}
|
|
4864
|
-
async function runOpenFPGALoader(args = null, filesIn = {}, options = {
|
|
4909
|
+
async function runOpenFPGALoader(args = null, filesIn = {}, options = {}) {
|
|
4865
4910
|
if (args === null)
|
|
4866
4911
|
return;
|
|
4867
|
-
const
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
stdout: terminalWrite,
|
|
4871
|
-
stderr: terminalWrite
|
|
4872
|
-
});
|
|
4873
|
-
inst.FS.rmdir("/home/web_user");
|
|
4874
|
-
inst.FS.rmdir("/home");
|
|
4875
|
-
writeTreeToMEMFS(inst.FS, filesIn);
|
|
4912
|
+
const inst = await openFPGALoader_default({ noFSInit: true });
|
|
4913
|
+
createStandardStreams(inst.FS, options);
|
|
4914
|
+
writeTree(inst.FS, filesIn);
|
|
4876
4915
|
const argv = ["openFPGALoader", ...args, null];
|
|
4877
4916
|
const argvPtr = inst.stackAlloc(argv.length * 4);
|
|
4878
4917
|
argv.forEach((arg, off) => inst.HEAPU32[(argvPtr >> 2) + off] = arg === null ? 0 : inst.stringToUTF8OnStack(arg));
|
|
@@ -4884,7 +4923,7 @@ async function runOpenFPGALoader(args = null, filesIn = {}, options = { printLin
|
|
|
4884
4923
|
{ async: true }
|
|
4885
4924
|
);
|
|
4886
4925
|
inst._fflush(0);
|
|
4887
|
-
const filesOut =
|
|
4926
|
+
const filesOut = readTree(inst.FS);
|
|
4888
4927
|
if (exitCode == 0) {
|
|
4889
4928
|
return filesOut;
|
|
4890
4929
|
} else {
|
package/gen/openFPGALoader.wasm
CHANGED
|
Binary file
|
package/lib/api.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export type Tree = {
|
|
|
2
2
|
[name: string]: Tree | string | Uint8Array
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
+
export type OutputStream =
|
|
6
|
+
(bytes: Uint8Array | null) => void;
|
|
7
|
+
|
|
5
8
|
export class Exit extends Error {
|
|
6
9
|
code: number;
|
|
7
10
|
files: Tree;
|
|
@@ -9,8 +12,8 @@ export class Exit extends Error {
|
|
|
9
12
|
|
|
10
13
|
export type Command = {
|
|
11
14
|
(args?: string[], files?: Tree, options?: {
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
stdout?: OutputStream | null,
|
|
16
|
+
stderr?: OutputStream | null,
|
|
14
17
|
}): Promise<Tree>;
|
|
15
18
|
|
|
16
19
|
requiresUSBDevice: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yowasp/openfpgaloader",
|
|
3
|
-
"version": "0.3.1-
|
|
3
|
+
"version": "0.3.1-894.10",
|
|
4
4
|
"description": "WebUSB port of openFPGALoader, universal utility for programming FPGA",
|
|
5
5
|
"author": "Catherine <whitequark@whitequark.org>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"types": "./lib/api.d.ts",
|
|
27
27
|
"devDependencies": {
|
|
28
|
+
"@yowasp/runtime": "^6.0",
|
|
28
29
|
"esbuild": "^0.19.8"
|
|
29
30
|
},
|
|
30
31
|
"scripts": {
|