@suchipi/quickjs 0.3.0 → 0.4.1
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/build/aarch64-apple-darwin/bin/file-to-bytecode.js +27 -0
- package/build/aarch64-apple-darwin/bin/qjs +0 -0
- package/build/aarch64-apple-darwin/bin/qjsbootstrap +0 -0
- package/build/aarch64-apple-darwin/bin/qjsbootstrap-bytecode +0 -0
- package/build/aarch64-apple-darwin/bin/qjsc +0 -0
- package/build/aarch64-apple-darwin/bin/quickjs-run +0 -0
- package/build/aarch64-apple-darwin/extras/is-stdin-a-tty +0 -0
- package/build/aarch64-apple-darwin/extras/run-test262 +0 -0
- package/build/aarch64-apple-darwin/extras/sample-program/sum +0 -0
- package/build/aarch64-apple-darwin/extras/stack-limit-test +0 -0
- package/build/aarch64-apple-darwin/lib/quickjs-core.a +0 -0
- package/build/aarch64-apple-darwin/lib/quickjs-full.a +0 -0
- package/build/aarch64-unknown-linux-gnu/bin/file-to-bytecode.js +27 -0
- package/build/aarch64-unknown-linux-gnu/bin/qjs +0 -0
- package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
- package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
- package/build/aarch64-unknown-linux-gnu/bin/qjsc +0 -0
- package/build/aarch64-unknown-linux-gnu/bin/quickjs-run +0 -0
- package/build/aarch64-unknown-linux-gnu/extras/fib.so +0 -0
- package/build/aarch64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
- package/build/aarch64-unknown-linux-gnu/extras/log-argv +0 -0
- package/build/aarch64-unknown-linux-gnu/extras/point.so +0 -0
- package/build/aarch64-unknown-linux-gnu/extras/run-test262 +0 -0
- package/build/aarch64-unknown-linux-gnu/extras/sample-program/sum +0 -0
- package/build/aarch64-unknown-linux-gnu/extras/stack-limit-test +0 -0
- package/build/aarch64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
- package/build/aarch64-unknown-linux-gnu/lib/quickjs-full.a +0 -0
- package/build/aarch64-unknown-linux-musl/bin/file-to-bytecode.js +27 -0
- package/build/aarch64-unknown-linux-musl/bin/qjs +0 -0
- package/build/aarch64-unknown-linux-musl/bin/qjsbootstrap +0 -0
- package/build/aarch64-unknown-linux-musl/bin/qjsbootstrap-bytecode +0 -0
- package/build/aarch64-unknown-linux-musl/bin/qjsc +0 -0
- package/build/aarch64-unknown-linux-musl/bin/quickjs-run +0 -0
- package/build/aarch64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
- package/build/aarch64-unknown-linux-musl/extras/run-test262 +0 -0
- package/build/aarch64-unknown-linux-musl/extras/sample-program/sum +0 -0
- package/build/aarch64-unknown-linux-musl/extras/stack-limit-test +0 -0
- package/build/aarch64-unknown-linux-musl/lib/quickjs-core.a +0 -0
- package/build/aarch64-unknown-linux-musl/lib/quickjs-full.a +0 -0
- package/build/aarch64-unknown-linux-static/bin/file-to-bytecode.js +27 -0
- package/build/aarch64-unknown-linux-static/bin/qjs +0 -0
- package/build/aarch64-unknown-linux-static/bin/qjsbootstrap +0 -0
- package/build/aarch64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
- package/build/aarch64-unknown-linux-static/bin/qjsc +0 -0
- package/build/aarch64-unknown-linux-static/bin/quickjs-run +0 -0
- package/build/aarch64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
- package/build/aarch64-unknown-linux-static/extras/run-test262 +0 -0
- package/build/aarch64-unknown-linux-static/extras/sample-program/sum +0 -0
- package/build/aarch64-unknown-linux-static/extras/stack-limit-test +0 -0
- package/build/aarch64-unknown-linux-static/lib/quickjs-core.a +0 -0
- package/build/aarch64-unknown-linux-static/lib/quickjs-full.a +0 -0
- package/build/dts/inspect.d.ts +22 -1
- package/build/dts/quickjs-modulesys.d.ts +180 -0
- package/build/x86_64-apple-darwin/bin/file-to-bytecode.js +27 -0
- package/build/x86_64-apple-darwin/bin/qjs +0 -0
- package/build/x86_64-apple-darwin/bin/qjsbootstrap +0 -0
- package/build/x86_64-apple-darwin/bin/qjsbootstrap-bytecode +0 -0
- package/build/x86_64-apple-darwin/bin/qjsc +0 -0
- package/build/x86_64-apple-darwin/bin/quickjs-run +0 -0
- package/build/x86_64-apple-darwin/extras/is-stdin-a-tty +0 -0
- package/build/x86_64-apple-darwin/extras/run-test262 +0 -0
- package/build/x86_64-apple-darwin/extras/sample-program/sum +0 -0
- package/build/x86_64-apple-darwin/extras/stack-limit-test +0 -0
- package/build/x86_64-apple-darwin/lib/quickjs-core.a +0 -0
- package/build/x86_64-apple-darwin/lib/quickjs-full.a +0 -0
- package/build/x86_64-pc-windows-static/bin/file-to-bytecode.js +27 -0
- package/build/x86_64-pc-windows-static/bin/qjs.exe +0 -0
- package/build/x86_64-pc-windows-static/bin/qjsbootstrap-bytecode.exe +0 -0
- package/build/x86_64-pc-windows-static/bin/qjsbootstrap.exe +0 -0
- package/build/x86_64-pc-windows-static/bin/qjsc.exe +0 -0
- package/build/x86_64-pc-windows-static/bin/quickjs-run.exe +0 -0
- package/build/x86_64-pc-windows-static/extras/is-stdin-a-tty.exe +0 -0
- package/build/x86_64-pc-windows-static/extras/log-argv.exe +0 -0
- package/build/x86_64-pc-windows-static/extras/run-test262.exe +0 -0
- package/build/x86_64-pc-windows-static/extras/sample-program/sum.exe +0 -0
- package/build/x86_64-pc-windows-static/extras/stack-limit-test.exe +0 -0
- package/build/x86_64-pc-windows-static/lib/quickjs-core.a +0 -0
- package/build/x86_64-pc-windows-static/lib/quickjs-full.a +0 -0
- package/build/x86_64-unknown-linux-gnu/bin/file-to-bytecode.js +27 -0
- package/build/x86_64-unknown-linux-gnu/bin/qjs +0 -0
- package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
- package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
- package/build/x86_64-unknown-linux-gnu/bin/qjsc +0 -0
- package/build/x86_64-unknown-linux-gnu/bin/quickjs-run +0 -0
- package/build/x86_64-unknown-linux-gnu/extras/fib.so +0 -0
- package/build/x86_64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
- package/build/x86_64-unknown-linux-gnu/extras/log-argv +0 -0
- package/build/x86_64-unknown-linux-gnu/extras/point.so +0 -0
- package/build/x86_64-unknown-linux-gnu/extras/run-test262 +0 -0
- package/build/x86_64-unknown-linux-gnu/extras/sample-program/sum +0 -0
- package/build/x86_64-unknown-linux-gnu/extras/stack-limit-test +0 -0
- package/build/x86_64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
- package/build/x86_64-unknown-linux-gnu/lib/quickjs-full.a +0 -0
- package/build/x86_64-unknown-linux-musl/bin/file-to-bytecode.js +27 -0
- package/build/x86_64-unknown-linux-musl/bin/qjs +0 -0
- package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap +0 -0
- package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap-bytecode +0 -0
- package/build/x86_64-unknown-linux-musl/bin/qjsc +0 -0
- package/build/x86_64-unknown-linux-musl/bin/quickjs-run +0 -0
- package/build/x86_64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
- package/build/x86_64-unknown-linux-musl/extras/run-test262 +0 -0
- package/build/x86_64-unknown-linux-musl/extras/sample-program/sum +0 -0
- package/build/x86_64-unknown-linux-musl/extras/stack-limit-test +0 -0
- package/build/x86_64-unknown-linux-musl/lib/quickjs-core.a +0 -0
- package/build/x86_64-unknown-linux-musl/lib/quickjs-full.a +0 -0
- package/build/x86_64-unknown-linux-static/bin/file-to-bytecode.js +27 -0
- package/build/x86_64-unknown-linux-static/bin/qjs +0 -0
- package/build/x86_64-unknown-linux-static/bin/qjsbootstrap +0 -0
- package/build/x86_64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
- package/build/x86_64-unknown-linux-static/bin/qjsc +0 -0
- package/build/x86_64-unknown-linux-static/bin/quickjs-run +0 -0
- package/build/x86_64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
- package/build/x86_64-unknown-linux-static/extras/run-test262 +0 -0
- package/build/x86_64-unknown-linux-static/extras/sample-program/sum +0 -0
- package/build/x86_64-unknown-linux-static/extras/stack-limit-test +0 -0
- package/build/x86_64-unknown-linux-static/lib/quickjs-core.a +0 -0
- package/build/x86_64-unknown-linux-static/lib/quickjs-full.a +0 -0
- package/npm/cli/qjs.js +1 -1
- package/npm/cli/qjsc.js +1 -1
- package/npm/cli/quickjs-run.js +1 -1
- package/npm/index.js +21 -47
- package/npm/platforms.json +65 -0
- package/npm/{cli/run-binary.js → run-binary.js} +8 -5
- package/package.json +9 -5
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env quickjs-run
|
|
2
|
+
|
|
3
|
+
// Simple script which reads in a file, converts it to bytecode, and writes out
|
|
4
|
+
// the bytecode to a new file.
|
|
5
|
+
|
|
6
|
+
/// <reference path="../quickjs/quickjs.d.ts" />
|
|
7
|
+
/// <reference path="../quickjs-libc/quickjs-libc.d.ts" />
|
|
8
|
+
/// <reference path="../quickjs-libbytecode/quickjs-libbytecode.d.ts" />
|
|
9
|
+
|
|
10
|
+
import * as std from "quickjs:std";
|
|
11
|
+
import * as Bytecode from "quickjs:bytecode";
|
|
12
|
+
|
|
13
|
+
function main() {
|
|
14
|
+
const [_quickjsRun, _thisScript, inputFile, outputFile] = scriptArgs;
|
|
15
|
+
|
|
16
|
+
if (!(inputFile && outputFile)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You must pass two positional arguments to this script: the input file path (js) and the output file path (bytecode binary)."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = Bytecode.fromFile(inputFile);
|
|
23
|
+
const out = std.open(outputFile, "wb");
|
|
24
|
+
out.write(bytecode, 0, bytecode.byteLength);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env quickjs-run
|
|
2
|
+
|
|
3
|
+
// Simple script which reads in a file, converts it to bytecode, and writes out
|
|
4
|
+
// the bytecode to a new file.
|
|
5
|
+
|
|
6
|
+
/// <reference path="../quickjs/quickjs.d.ts" />
|
|
7
|
+
/// <reference path="../quickjs-libc/quickjs-libc.d.ts" />
|
|
8
|
+
/// <reference path="../quickjs-libbytecode/quickjs-libbytecode.d.ts" />
|
|
9
|
+
|
|
10
|
+
import * as std from "quickjs:std";
|
|
11
|
+
import * as Bytecode from "quickjs:bytecode";
|
|
12
|
+
|
|
13
|
+
function main() {
|
|
14
|
+
const [_quickjsRun, _thisScript, inputFile, outputFile] = scriptArgs;
|
|
15
|
+
|
|
16
|
+
if (!(inputFile && outputFile)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You must pass two positional arguments to this script: the input file path (js) and the output file path (bytecode binary)."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = Bytecode.fromFile(inputFile);
|
|
23
|
+
const out = std.open(outputFile, "wb");
|
|
24
|
+
out.write(bytecode, 0, bytecode.byteLength);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env quickjs-run
|
|
2
|
+
|
|
3
|
+
// Simple script which reads in a file, converts it to bytecode, and writes out
|
|
4
|
+
// the bytecode to a new file.
|
|
5
|
+
|
|
6
|
+
/// <reference path="../quickjs/quickjs.d.ts" />
|
|
7
|
+
/// <reference path="../quickjs-libc/quickjs-libc.d.ts" />
|
|
8
|
+
/// <reference path="../quickjs-libbytecode/quickjs-libbytecode.d.ts" />
|
|
9
|
+
|
|
10
|
+
import * as std from "quickjs:std";
|
|
11
|
+
import * as Bytecode from "quickjs:bytecode";
|
|
12
|
+
|
|
13
|
+
function main() {
|
|
14
|
+
const [_quickjsRun, _thisScript, inputFile, outputFile] = scriptArgs;
|
|
15
|
+
|
|
16
|
+
if (!(inputFile && outputFile)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You must pass two positional arguments to this script: the input file path (js) and the output file path (bytecode binary)."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = Bytecode.fromFile(inputFile);
|
|
23
|
+
const out = std.open(outputFile, "wb");
|
|
24
|
+
out.write(bytecode, 0, bytecode.byteLength);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env quickjs-run
|
|
2
|
+
|
|
3
|
+
// Simple script which reads in a file, converts it to bytecode, and writes out
|
|
4
|
+
// the bytecode to a new file.
|
|
5
|
+
|
|
6
|
+
/// <reference path="../quickjs/quickjs.d.ts" />
|
|
7
|
+
/// <reference path="../quickjs-libc/quickjs-libc.d.ts" />
|
|
8
|
+
/// <reference path="../quickjs-libbytecode/quickjs-libbytecode.d.ts" />
|
|
9
|
+
|
|
10
|
+
import * as std from "quickjs:std";
|
|
11
|
+
import * as Bytecode from "quickjs:bytecode";
|
|
12
|
+
|
|
13
|
+
function main() {
|
|
14
|
+
const [_quickjsRun, _thisScript, inputFile, outputFile] = scriptArgs;
|
|
15
|
+
|
|
16
|
+
if (!(inputFile && outputFile)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You must pass two positional arguments to this script: the input file path (js) and the output file path (bytecode binary)."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = Bytecode.fromFile(inputFile);
|
|
23
|
+
const out = std.open(outputFile, "wb");
|
|
24
|
+
out.write(bytecode, 0, bytecode.byteLength);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/build/dts/inspect.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/** npm: @suchipi/print@2.
|
|
1
|
+
/** npm: @suchipi/print@2.5.0. License: ISC */
|
|
2
|
+
/* (with some QuickJS-specific modifications) */
|
|
2
3
|
|
|
3
4
|
/*
|
|
4
5
|
Copyright (c) 2016-2022, John Gardner
|
|
@@ -110,6 +111,11 @@ declare interface InspectFunction {
|
|
|
110
111
|
* @returns A string representation of `value`.
|
|
111
112
|
*/
|
|
112
113
|
(value: any, key?: string | symbol, options?: InspectOptions): string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* A symbol which can be used to customize how an object gets printed.
|
|
117
|
+
*/
|
|
118
|
+
custom: symbol;
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
/**
|
|
@@ -121,3 +127,18 @@ declare interface InspectFunction {
|
|
|
121
127
|
* @returns A string representation of `value`.
|
|
122
128
|
*/
|
|
123
129
|
declare var inspect: InspectFunction;
|
|
130
|
+
|
|
131
|
+
declare interface InspectCustomInputs {
|
|
132
|
+
key: string | symbol;
|
|
133
|
+
type: string;
|
|
134
|
+
brackets: [string, string];
|
|
135
|
+
oneLine: boolean;
|
|
136
|
+
linesBefore: Array<string>;
|
|
137
|
+
linesAfter: Array<string>;
|
|
138
|
+
propLines: Array<string>;
|
|
139
|
+
readonly tooDeep: boolean;
|
|
140
|
+
indent: string;
|
|
141
|
+
typeSuffix: string;
|
|
142
|
+
opts: InspectOptions;
|
|
143
|
+
colours: { [Key in keyof Required<InspectColours>]: string };
|
|
144
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A global which lets you configure the module loader (import/export/require).
|
|
3
|
+
* You can use these properties to add support for importing new filetypes.
|
|
4
|
+
*
|
|
5
|
+
* This global can also be used to identify whether an object is a module
|
|
6
|
+
* namespace record.
|
|
7
|
+
*/
|
|
8
|
+
interface ModuleGlobal {
|
|
9
|
+
/**
|
|
10
|
+
* Returns true if `target` is a module namespace object.
|
|
11
|
+
*/
|
|
12
|
+
[Symbol.hasInstance](target: any): target is {
|
|
13
|
+
[key: string | number | symbol]: any;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A list of filetype extensions that may be omitted from an import specifier
|
|
18
|
+
* string.
|
|
19
|
+
*
|
|
20
|
+
* Defaults to `[".js"]`. You can add more strings to this array to
|
|
21
|
+
* make the engine search for additional files when resolving a
|
|
22
|
+
* require/import.
|
|
23
|
+
*
|
|
24
|
+
* See the doc comment on {@link require} for more information.
|
|
25
|
+
*
|
|
26
|
+
* NOTE: If you add a new extension to this array, you will likely also want
|
|
27
|
+
* to add to {@link Module.compilers}.
|
|
28
|
+
*/
|
|
29
|
+
searchExtensions: Array<string>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* User-defined functions which will handle getting the JavaScript code
|
|
33
|
+
* associated with a module.
|
|
34
|
+
*
|
|
35
|
+
* The key for each property in this object should be a file extension
|
|
36
|
+
* string with a leading dot, eg `".jsx"`. The value for each property should
|
|
37
|
+
* be a function which receives (1) the filepath to a module, and (2) that
|
|
38
|
+
* file's content as a UTF-8 string, and the function should return a string
|
|
39
|
+
* containing JavaScript code that corresponds to that module. In most cases,
|
|
40
|
+
* these functions will compile the contents of the file from one format into JavaScript.
|
|
41
|
+
*
|
|
42
|
+
* The function does not have to use the second 'content' argument it
|
|
43
|
+
* receives (ie. when loading binary files).
|
|
44
|
+
*
|
|
45
|
+
* By adding to this object, you can make it possible to import non-js
|
|
46
|
+
* filetypes; compile-to-JS languages like JSX, TypeScript, and CoffeeScript
|
|
47
|
+
* can be compiled at import time, and asset files like .txt files or .png
|
|
48
|
+
* files can be converted into an appropriate data structure at import time.
|
|
49
|
+
*
|
|
50
|
+
* As an example, to make it possible to import .txt files, you might do:
|
|
51
|
+
* ```js
|
|
52
|
+
* import * as std from "std";
|
|
53
|
+
*
|
|
54
|
+
* Module.compilers[".txt"] = (filename, content) => {
|
|
55
|
+
* return `export default ${JSON.stringify(content)}`;
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
* (leveraging `JSON.stringify`'s ability to escape quotes).
|
|
59
|
+
*
|
|
60
|
+
* Then, later in your code, you can do:
|
|
61
|
+
* ```js
|
|
62
|
+
* import names from "./names.txt";
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* And `names` will be a string containing the contents of names.txt.
|
|
66
|
+
*
|
|
67
|
+
* NOTE: When adding to this object, you may also wish to add to
|
|
68
|
+
* {@link Module.searchExtensions}.
|
|
69
|
+
*/
|
|
70
|
+
compilers: {
|
|
71
|
+
[extensionWithDot: string]: (filename: string, content: string) => string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Create a virtual built-in module whose exports consist of the own
|
|
76
|
+
* enumerable properties of `obj`.
|
|
77
|
+
*/
|
|
78
|
+
define(name: string, obj: { [key: string]: any }): void;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Resolves a require/import request from `fromFile` into a canonicalized path.
|
|
82
|
+
*
|
|
83
|
+
* To change native module resolution behavior, replace this function with
|
|
84
|
+
* your own implementation. Note that you must handle
|
|
85
|
+
* `Module.searchExtensions` yourself in your replacement implementation.
|
|
86
|
+
*/
|
|
87
|
+
resolve(name: string, fromFile: string): string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Reads the contents of the given resolved module name into a string.
|
|
91
|
+
*
|
|
92
|
+
* To change native module loading behavior, replace this function with your
|
|
93
|
+
* own implementation. Note that you must handle `Module.compilers` yourself
|
|
94
|
+
* in your replacement implementation.
|
|
95
|
+
*/
|
|
96
|
+
read(modulePath: string): string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// global added by QJMS_AddModuleGlobal
|
|
100
|
+
declare var Module: ModuleGlobal;
|
|
101
|
+
|
|
102
|
+
interface RequireFunction {
|
|
103
|
+
/**
|
|
104
|
+
* Synchronously import a module.
|
|
105
|
+
*
|
|
106
|
+
* `source` will be resolved relative to the calling file.
|
|
107
|
+
*
|
|
108
|
+
* If `source` does not have a file extension, and a file without an extension
|
|
109
|
+
* cannot be found, the engine will check for files with the extensions in
|
|
110
|
+
* {@link Module.searchExtensions}, and use one of those if present. This
|
|
111
|
+
* behavior also happens when using normal `import` statements.
|
|
112
|
+
*
|
|
113
|
+
* For example, if you write:
|
|
114
|
+
*
|
|
115
|
+
* ```js
|
|
116
|
+
* import something from "./somewhere";
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* but there's no file named `somewhere` in the same directory as the file
|
|
120
|
+
* where that import appears, and `Module.searchExtensions` is the default
|
|
121
|
+
* value:
|
|
122
|
+
*
|
|
123
|
+
* ```js
|
|
124
|
+
* [".js"]
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* then the engine will look for `somewhere.js`. If that doesn't exist, the
|
|
128
|
+
* engine will look for `somewhere/index.js`. If *that* doesn't exist, an error
|
|
129
|
+
* will be thrown.
|
|
130
|
+
*
|
|
131
|
+
* If you add more extensions to `Module.searchExtensions`, then the engine
|
|
132
|
+
* will use those, too. It will search in the same order as the strings appear
|
|
133
|
+
* in the `Module.searchExtensions` array.
|
|
134
|
+
*/
|
|
135
|
+
(source: string): any;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Resolves the normalized path to a modules, relative to the calling file.
|
|
139
|
+
*/
|
|
140
|
+
resolve: (source: string) => string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// global added by QJMS_AddRequireGlobal
|
|
144
|
+
declare var require: RequireFunction;
|
|
145
|
+
|
|
146
|
+
// gets set per-module by QJMS_SetModuleImportMeta
|
|
147
|
+
interface ImportMeta {
|
|
148
|
+
/**
|
|
149
|
+
* A URL representing the current module.
|
|
150
|
+
*
|
|
151
|
+
* Usually starts with `file://`.
|
|
152
|
+
*/
|
|
153
|
+
url: string;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Whether the current module is the "main" module, meaning that it is the
|
|
157
|
+
* entrypoint file that's been loaded, or, in other terms, the first
|
|
158
|
+
* user-authored module that's been loaded.
|
|
159
|
+
*/
|
|
160
|
+
main: boolean;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Equivalent to `globalThis.require`. Provided for compatibility with tools
|
|
164
|
+
* that can leverage a CommonJS require function via `import.meta.require`.
|
|
165
|
+
*/
|
|
166
|
+
require: RequireFunction;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Resolves a module specifier based on the current module's path.
|
|
170
|
+
*
|
|
171
|
+
* Equivalent to `globalThis.require.resolve`.
|
|
172
|
+
*
|
|
173
|
+
* Behaves similarly to [the browser import.meta.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve),
|
|
174
|
+
* but it does not ensure that the returned string is a valid URL, because it
|
|
175
|
+
* delegates directly to {@link Module.resolve} to resolve the name. If you
|
|
176
|
+
* want this to return URL strings, change `Module.resolve` and `Module.read`
|
|
177
|
+
* to work with URL strings.
|
|
178
|
+
*/
|
|
179
|
+
resolve: RequireFunction["resolve"];
|
|
180
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env quickjs-run
|
|
2
|
+
|
|
3
|
+
// Simple script which reads in a file, converts it to bytecode, and writes out
|
|
4
|
+
// the bytecode to a new file.
|
|
5
|
+
|
|
6
|
+
/// <reference path="../quickjs/quickjs.d.ts" />
|
|
7
|
+
/// <reference path="../quickjs-libc/quickjs-libc.d.ts" />
|
|
8
|
+
/// <reference path="../quickjs-libbytecode/quickjs-libbytecode.d.ts" />
|
|
9
|
+
|
|
10
|
+
import * as std from "quickjs:std";
|
|
11
|
+
import * as Bytecode from "quickjs:bytecode";
|
|
12
|
+
|
|
13
|
+
function main() {
|
|
14
|
+
const [_quickjsRun, _thisScript, inputFile, outputFile] = scriptArgs;
|
|
15
|
+
|
|
16
|
+
if (!(inputFile && outputFile)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You must pass two positional arguments to this script: the input file path (js) and the output file path (bytecode binary)."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = Bytecode.fromFile(inputFile);
|
|
23
|
+
const out = std.open(outputFile, "wb");
|
|
24
|
+
out.write(bytecode, 0, bytecode.byteLength);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env quickjs-run
|
|
2
|
+
|
|
3
|
+
// Simple script which reads in a file, converts it to bytecode, and writes out
|
|
4
|
+
// the bytecode to a new file.
|
|
5
|
+
|
|
6
|
+
/// <reference path="../quickjs/quickjs.d.ts" />
|
|
7
|
+
/// <reference path="../quickjs-libc/quickjs-libc.d.ts" />
|
|
8
|
+
/// <reference path="../quickjs-libbytecode/quickjs-libbytecode.d.ts" />
|
|
9
|
+
|
|
10
|
+
import * as std from "quickjs:std";
|
|
11
|
+
import * as Bytecode from "quickjs:bytecode";
|
|
12
|
+
|
|
13
|
+
function main() {
|
|
14
|
+
const [_quickjsRun, _thisScript, inputFile, outputFile] = scriptArgs;
|
|
15
|
+
|
|
16
|
+
if (!(inputFile && outputFile)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You must pass two positional arguments to this script: the input file path (js) and the output file path (bytecode binary)."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = Bytecode.fromFile(inputFile);
|
|
23
|
+
const out = std.open(outputFile, "wb");
|
|
24
|
+
out.write(bytecode, 0, bytecode.byteLength);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env quickjs-run
|
|
2
|
+
|
|
3
|
+
// Simple script which reads in a file, converts it to bytecode, and writes out
|
|
4
|
+
// the bytecode to a new file.
|
|
5
|
+
|
|
6
|
+
/// <reference path="../quickjs/quickjs.d.ts" />
|
|
7
|
+
/// <reference path="../quickjs-libc/quickjs-libc.d.ts" />
|
|
8
|
+
/// <reference path="../quickjs-libbytecode/quickjs-libbytecode.d.ts" />
|
|
9
|
+
|
|
10
|
+
import * as std from "quickjs:std";
|
|
11
|
+
import * as Bytecode from "quickjs:bytecode";
|
|
12
|
+
|
|
13
|
+
function main() {
|
|
14
|
+
const [_quickjsRun, _thisScript, inputFile, outputFile] = scriptArgs;
|
|
15
|
+
|
|
16
|
+
if (!(inputFile && outputFile)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You must pass two positional arguments to this script: the input file path (js) and the output file path (bytecode binary)."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = Bytecode.fromFile(inputFile);
|
|
23
|
+
const out = std.open(outputFile, "wb");
|
|
24
|
+
out.write(bytecode, 0, bytecode.byteLength);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env quickjs-run
|
|
2
|
+
|
|
3
|
+
// Simple script which reads in a file, converts it to bytecode, and writes out
|
|
4
|
+
// the bytecode to a new file.
|
|
5
|
+
|
|
6
|
+
/// <reference path="../quickjs/quickjs.d.ts" />
|
|
7
|
+
/// <reference path="../quickjs-libc/quickjs-libc.d.ts" />
|
|
8
|
+
/// <reference path="../quickjs-libbytecode/quickjs-libbytecode.d.ts" />
|
|
9
|
+
|
|
10
|
+
import * as std from "quickjs:std";
|
|
11
|
+
import * as Bytecode from "quickjs:bytecode";
|
|
12
|
+
|
|
13
|
+
function main() {
|
|
14
|
+
const [_quickjsRun, _thisScript, inputFile, outputFile] = scriptArgs;
|
|
15
|
+
|
|
16
|
+
if (!(inputFile && outputFile)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You must pass two positional arguments to this script: the input file path (js) and the output file path (bytecode binary)."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = Bytecode.fromFile(inputFile);
|
|
23
|
+
const out = std.open(outputFile, "wb");
|
|
24
|
+
out.write(bytecode, 0, bytecode.byteLength);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env quickjs-run
|
|
2
|
+
|
|
3
|
+
// Simple script which reads in a file, converts it to bytecode, and writes out
|
|
4
|
+
// the bytecode to a new file.
|
|
5
|
+
|
|
6
|
+
/// <reference path="../quickjs/quickjs.d.ts" />
|
|
7
|
+
/// <reference path="../quickjs-libc/quickjs-libc.d.ts" />
|
|
8
|
+
/// <reference path="../quickjs-libbytecode/quickjs-libbytecode.d.ts" />
|
|
9
|
+
|
|
10
|
+
import * as std from "quickjs:std";
|
|
11
|
+
import * as Bytecode from "quickjs:bytecode";
|
|
12
|
+
|
|
13
|
+
function main() {
|
|
14
|
+
const [_quickjsRun, _thisScript, inputFile, outputFile] = scriptArgs;
|
|
15
|
+
|
|
16
|
+
if (!(inputFile && outputFile)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"You must pass two positional arguments to this script: the input file path (js) and the output file path (bytecode binary)."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = Bytecode.fromFile(inputFile);
|
|
23
|
+
const out = std.open(outputFile, "wb");
|
|
24
|
+
out.write(bytecode, 0, bytecode.byteLength);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/npm/cli/qjs.js
CHANGED
package/npm/cli/qjsc.js
CHANGED
package/npm/cli/quickjs-run.js
CHANGED
package/npm/index.js
CHANGED
|
@@ -1,54 +1,28 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
1
2
|
const path = require("path");
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
function buildArtifactsLocation() {
|
|
4
5
|
return path.resolve(__dirname, "..", "build");
|
|
5
|
-
}
|
|
6
|
+
}
|
|
7
|
+
exports.buildArtifactsLocation = buildArtifactsLocation;
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
switch (platform) {
|
|
10
|
-
case "darwin":
|
|
11
|
-
case "linux":
|
|
12
|
-
case "win32": {
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
default: {
|
|
16
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
9
|
+
const platforms = require("./platforms.json");
|
|
10
|
+
exports.platforms = platforms;
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
arch
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
case "x64": {
|
|
28
|
-
arch = "x86_64";
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
default: {
|
|
32
|
-
throw new Error(`Unsupported processor architecture: ${arch}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
12
|
+
function identifyCurrentPlatform() {
|
|
13
|
+
const matchingPlatform = platforms.find((platform) => {
|
|
14
|
+
return (
|
|
15
|
+
platform.os === process.platform &&
|
|
16
|
+
platform.architectures.includes(process.arch)
|
|
17
|
+
);
|
|
18
|
+
});
|
|
35
19
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
throw new Error(`Architecture is not supported on Windows: ${arch}`);
|
|
43
|
-
}
|
|
44
|
-
return `${arch}-pc-windows-static`;
|
|
45
|
-
}
|
|
46
|
-
case "linux": {
|
|
47
|
-
return `${arch}-unknown-linux-static`;
|
|
48
|
-
}
|
|
49
|
-
default: {
|
|
50
|
-
// should be unreachable
|
|
51
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
52
|
-
}
|
|
20
|
+
if (matchingPlatform) {
|
|
21
|
+
return matchingPlatform;
|
|
22
|
+
} else {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Unsupported platform: ${process.platform}/${process.arch}`
|
|
25
|
+
);
|
|
53
26
|
}
|
|
54
|
-
}
|
|
27
|
+
}
|
|
28
|
+
exports.identifyCurrentPlatform = identifyCurrentPlatform;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "aarch64-apple-darwin",
|
|
4
|
+
"architectures": ["aarch64", "arm64"],
|
|
5
|
+
"os": "darwin",
|
|
6
|
+
"abi": "",
|
|
7
|
+
"programSuffix": ""
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "aarch64-unknown-linux-gnu",
|
|
11
|
+
"architectures": ["aarch64", "arm64"],
|
|
12
|
+
"os": "linux",
|
|
13
|
+
"abi": "gnu",
|
|
14
|
+
"programSuffix": ""
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "aarch64-unknown-linux-musl",
|
|
18
|
+
"architectures": ["aarch64", "arm64"],
|
|
19
|
+
"os": "linux",
|
|
20
|
+
"abi": "musl",
|
|
21
|
+
"programSuffix": ""
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "aarch64-unknown-linux-static",
|
|
25
|
+
"architectures": ["aarch64", "arm64"],
|
|
26
|
+
"os": "linux",
|
|
27
|
+
"abi": "static",
|
|
28
|
+
"programSuffix": ""
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "x86_64-apple-darwin",
|
|
32
|
+
"architectures": ["x86_64", "amd64", "x64"],
|
|
33
|
+
"os": "darwin",
|
|
34
|
+
"abi": "",
|
|
35
|
+
"programSuffix": ""
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "x86_64-pc-windows-static",
|
|
39
|
+
"architectures": ["x86_64", "amd64", "x64"],
|
|
40
|
+
"os": "windows",
|
|
41
|
+
"abi": "",
|
|
42
|
+
"programSuffix": ".exe"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "x86_64-unknown-linux-gnu",
|
|
46
|
+
"architectures": ["x86_64", "amd64", "x64"],
|
|
47
|
+
"os": "linux",
|
|
48
|
+
"abi": "gnu",
|
|
49
|
+
"programSuffix": ""
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "x86_64-unknown-linux-musl",
|
|
53
|
+
"architectures": ["x86_64", "amd64", "x64"],
|
|
54
|
+
"os": "linux",
|
|
55
|
+
"abi": "musl",
|
|
56
|
+
"programSuffix": ""
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "x86_64-unknown-linux-static",
|
|
60
|
+
"architectures": ["x86_64", "amd64", "x64"],
|
|
61
|
+
"os": "linux",
|
|
62
|
+
"abi": "static",
|
|
63
|
+
"programSuffix": ""
|
|
64
|
+
}
|
|
65
|
+
]
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const child_process = require("child_process");
|
|
4
|
-
const { identifyCurrentPlatform } = require("
|
|
4
|
+
const { identifyCurrentPlatform, buildArtifactsLocation } = require(".");
|
|
5
5
|
|
|
6
6
|
module.exports = function runBinary(name) {
|
|
7
|
+
const buildDir = buildArtifactsLocation();
|
|
7
8
|
const platform = identifyCurrentPlatform();
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const bin = path.resolve(
|
|
11
|
+
buildDir,
|
|
12
|
+
platform.name,
|
|
13
|
+
"bin",
|
|
14
|
+
name + platform.programSuffix
|
|
15
|
+
);
|
|
13
16
|
|
|
14
17
|
const argv = process.argv.slice(2);
|
|
15
18
|
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suchipi/quickjs",
|
|
3
3
|
"description": "Suchipi's QuickJS Fork",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"main": "./npm/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"qjs": "
|
|
8
|
-
"qjsc": "
|
|
9
|
-
"quickjs-run": "
|
|
7
|
+
"qjs": "npm/cli/qjs.js",
|
|
8
|
+
"qjsc": "npm/cli/qjsc.js",
|
|
9
|
+
"quickjs-run": "npm/cli/quickjs-run.js"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@babel/core": "^7.20.5",
|
|
13
13
|
"@babel/preset-env": "^7.20.2",
|
|
14
14
|
"@babel/preset-typescript": "^7.18.6",
|
|
15
|
+
"@suchipi/print": "^2.5.0",
|
|
15
16
|
"@suchipi/shinobi": "^0.2.0",
|
|
16
17
|
"@types/jest": "^29.2.4",
|
|
17
18
|
"@types/node": "^18.11.9",
|
|
@@ -28,7 +29,10 @@
|
|
|
28
29
|
},
|
|
29
30
|
"prettier": {},
|
|
30
31
|
"license": "MIT",
|
|
31
|
-
"repository":
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/suchipi/quickjs.git"
|
|
35
|
+
},
|
|
32
36
|
"publishConfig": {
|
|
33
37
|
"access": "public"
|
|
34
38
|
}
|