@suchipi/quickjs 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/build/aarch64-apple-darwin/bin/file-to-bytecode.js +27 -0
  2. package/build/aarch64-apple-darwin/bin/qjs +0 -0
  3. package/build/aarch64-apple-darwin/bin/qjsbootstrap +0 -0
  4. package/build/aarch64-apple-darwin/bin/qjsbootstrap-bytecode +0 -0
  5. package/build/aarch64-apple-darwin/bin/qjsc +0 -0
  6. package/build/aarch64-apple-darwin/bin/quickjs-run +0 -0
  7. package/build/aarch64-apple-darwin/extras/is-stdin-a-tty +0 -0
  8. package/build/aarch64-apple-darwin/extras/run-test262 +0 -0
  9. package/build/aarch64-apple-darwin/extras/sample-program/sum +0 -0
  10. package/build/aarch64-apple-darwin/extras/stack-limit-test +0 -0
  11. package/build/aarch64-apple-darwin/lib/quickjs-core.a +0 -0
  12. package/build/aarch64-apple-darwin/lib/quickjs-full.a +0 -0
  13. package/build/aarch64-unknown-linux-gnu/bin/file-to-bytecode.js +27 -0
  14. package/build/aarch64-unknown-linux-gnu/bin/qjs +0 -0
  15. package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
  16. package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
  17. package/build/aarch64-unknown-linux-gnu/bin/qjsc +0 -0
  18. package/build/aarch64-unknown-linux-gnu/bin/quickjs-run +0 -0
  19. package/build/aarch64-unknown-linux-gnu/extras/fib.so +0 -0
  20. package/build/aarch64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
  21. package/build/aarch64-unknown-linux-gnu/extras/log-argv +0 -0
  22. package/build/aarch64-unknown-linux-gnu/extras/point.so +0 -0
  23. package/build/aarch64-unknown-linux-gnu/extras/run-test262 +0 -0
  24. package/build/aarch64-unknown-linux-gnu/extras/sample-program/sum +0 -0
  25. package/build/aarch64-unknown-linux-gnu/extras/stack-limit-test +0 -0
  26. package/build/aarch64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
  27. package/build/aarch64-unknown-linux-gnu/lib/quickjs-full.a +0 -0
  28. package/build/aarch64-unknown-linux-musl/bin/file-to-bytecode.js +27 -0
  29. package/build/aarch64-unknown-linux-musl/bin/qjs +0 -0
  30. package/build/aarch64-unknown-linux-musl/bin/qjsbootstrap +0 -0
  31. package/build/aarch64-unknown-linux-musl/bin/qjsbootstrap-bytecode +0 -0
  32. package/build/aarch64-unknown-linux-musl/bin/qjsc +0 -0
  33. package/build/aarch64-unknown-linux-musl/bin/quickjs-run +0 -0
  34. package/build/aarch64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
  35. package/build/aarch64-unknown-linux-musl/extras/run-test262 +0 -0
  36. package/build/aarch64-unknown-linux-musl/extras/sample-program/sum +0 -0
  37. package/build/aarch64-unknown-linux-musl/extras/stack-limit-test +0 -0
  38. package/build/aarch64-unknown-linux-musl/lib/quickjs-core.a +0 -0
  39. package/build/aarch64-unknown-linux-musl/lib/quickjs-full.a +0 -0
  40. package/build/aarch64-unknown-linux-static/bin/file-to-bytecode.js +27 -0
  41. package/build/aarch64-unknown-linux-static/bin/qjs +0 -0
  42. package/build/aarch64-unknown-linux-static/bin/qjsbootstrap +0 -0
  43. package/build/aarch64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
  44. package/build/aarch64-unknown-linux-static/bin/qjsc +0 -0
  45. package/build/aarch64-unknown-linux-static/bin/quickjs-run +0 -0
  46. package/build/aarch64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
  47. package/build/aarch64-unknown-linux-static/extras/run-test262 +0 -0
  48. package/build/aarch64-unknown-linux-static/extras/sample-program/sum +0 -0
  49. package/build/aarch64-unknown-linux-static/extras/stack-limit-test +0 -0
  50. package/build/aarch64-unknown-linux-static/lib/quickjs-core.a +0 -0
  51. package/build/aarch64-unknown-linux-static/lib/quickjs-full.a +0 -0
  52. package/build/dts/inspect.d.ts +22 -1
  53. package/build/x86_64-apple-darwin/bin/file-to-bytecode.js +27 -0
  54. package/build/x86_64-apple-darwin/bin/qjs +0 -0
  55. package/build/x86_64-apple-darwin/bin/qjsbootstrap +0 -0
  56. package/build/x86_64-apple-darwin/bin/qjsbootstrap-bytecode +0 -0
  57. package/build/x86_64-apple-darwin/bin/qjsc +0 -0
  58. package/build/x86_64-apple-darwin/bin/quickjs-run +0 -0
  59. package/build/x86_64-apple-darwin/extras/is-stdin-a-tty +0 -0
  60. package/build/x86_64-apple-darwin/extras/run-test262 +0 -0
  61. package/build/x86_64-apple-darwin/extras/sample-program/sum +0 -0
  62. package/build/x86_64-apple-darwin/extras/stack-limit-test +0 -0
  63. package/build/x86_64-apple-darwin/lib/quickjs-core.a +0 -0
  64. package/build/x86_64-apple-darwin/lib/quickjs-full.a +0 -0
  65. package/build/x86_64-pc-windows-static/bin/file-to-bytecode.js +27 -0
  66. package/build/x86_64-pc-windows-static/bin/qjs.exe +0 -0
  67. package/build/x86_64-pc-windows-static/bin/qjsbootstrap-bytecode.exe +0 -0
  68. package/build/x86_64-pc-windows-static/bin/qjsbootstrap.exe +0 -0
  69. package/build/x86_64-pc-windows-static/bin/qjsc.exe +0 -0
  70. package/build/x86_64-pc-windows-static/bin/quickjs-run.exe +0 -0
  71. package/build/x86_64-pc-windows-static/extras/is-stdin-a-tty.exe +0 -0
  72. package/build/x86_64-pc-windows-static/extras/log-argv.exe +0 -0
  73. package/build/x86_64-pc-windows-static/extras/run-test262.exe +0 -0
  74. package/build/x86_64-pc-windows-static/extras/sample-program/sum.exe +0 -0
  75. package/build/x86_64-pc-windows-static/extras/stack-limit-test.exe +0 -0
  76. package/build/x86_64-pc-windows-static/lib/quickjs-core.a +0 -0
  77. package/build/x86_64-pc-windows-static/lib/quickjs-full.a +0 -0
  78. package/build/x86_64-unknown-linux-gnu/bin/file-to-bytecode.js +27 -0
  79. package/build/x86_64-unknown-linux-gnu/bin/qjs +0 -0
  80. package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
  81. package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
  82. package/build/x86_64-unknown-linux-gnu/bin/qjsc +0 -0
  83. package/build/x86_64-unknown-linux-gnu/bin/quickjs-run +0 -0
  84. package/build/x86_64-unknown-linux-gnu/extras/fib.so +0 -0
  85. package/build/x86_64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
  86. package/build/x86_64-unknown-linux-gnu/extras/log-argv +0 -0
  87. package/build/x86_64-unknown-linux-gnu/extras/point.so +0 -0
  88. package/build/x86_64-unknown-linux-gnu/extras/run-test262 +0 -0
  89. package/build/x86_64-unknown-linux-gnu/extras/sample-program/sum +0 -0
  90. package/build/x86_64-unknown-linux-gnu/extras/stack-limit-test +0 -0
  91. package/build/x86_64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
  92. package/build/x86_64-unknown-linux-gnu/lib/quickjs-full.a +0 -0
  93. package/build/x86_64-unknown-linux-musl/bin/file-to-bytecode.js +27 -0
  94. package/build/x86_64-unknown-linux-musl/bin/qjs +0 -0
  95. package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap +0 -0
  96. package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap-bytecode +0 -0
  97. package/build/x86_64-unknown-linux-musl/bin/qjsc +0 -0
  98. package/build/x86_64-unknown-linux-musl/bin/quickjs-run +0 -0
  99. package/build/x86_64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
  100. package/build/x86_64-unknown-linux-musl/extras/run-test262 +0 -0
  101. package/build/x86_64-unknown-linux-musl/extras/sample-program/sum +0 -0
  102. package/build/x86_64-unknown-linux-musl/extras/stack-limit-test +0 -0
  103. package/build/x86_64-unknown-linux-musl/lib/quickjs-core.a +0 -0
  104. package/build/x86_64-unknown-linux-musl/lib/quickjs-full.a +0 -0
  105. package/build/x86_64-unknown-linux-static/bin/file-to-bytecode.js +27 -0
  106. package/build/x86_64-unknown-linux-static/bin/qjs +0 -0
  107. package/build/x86_64-unknown-linux-static/bin/qjsbootstrap +0 -0
  108. package/build/x86_64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
  109. package/build/x86_64-unknown-linux-static/bin/qjsc +0 -0
  110. package/build/x86_64-unknown-linux-static/bin/quickjs-run +0 -0
  111. package/build/x86_64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
  112. package/build/x86_64-unknown-linux-static/extras/run-test262 +0 -0
  113. package/build/x86_64-unknown-linux-static/extras/sample-program/sum +0 -0
  114. package/build/x86_64-unknown-linux-static/extras/stack-limit-test +0 -0
  115. package/build/x86_64-unknown-linux-static/lib/quickjs-core.a +0 -0
  116. package/build/x86_64-unknown-linux-static/lib/quickjs-full.a +0 -0
  117. package/npm/cli/qjs.js +1 -1
  118. package/npm/cli/qjsc.js +1 -1
  119. package/npm/cli/quickjs-run.js +1 -1
  120. package/npm/index.js +21 -47
  121. package/npm/platforms.json +65 -0
  122. package/npm/{cli/run-binary.js → run-binary.js} +8 -5
  123. package/package.json +9 -5
  124. 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
@@ -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();
@@ -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();
@@ -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();
@@ -1,4 +1,5 @@
1
- /** npm: @suchipi/print@2.3.0. License: ISC */
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,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
@@ -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();
@@ -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();
@@ -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();
@@ -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();
package/npm/cli/qjs.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- const runBinary = require("./run-binary");
2
+ const runBinary = require("../run-binary");
3
3
 
4
4
  runBinary("qjs");
package/npm/cli/qjsc.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- const runBinary = require("./run-binary");
2
+ const runBinary = require("../run-binary");
3
3
 
4
4
  runBinary("qjsc");
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- const runBinary = require("./run-binary");
2
+ const runBinary = require("../run-binary");
3
3
 
4
4
  runBinary("quickjs-run");
package/npm/index.js CHANGED
@@ -1,54 +1,28 @@
1
+ const fs = require("fs");
1
2
  const path = require("path");
2
3
 
3
- exports.buildArtifactsLocation = function buildArtifactsLocation() {
4
+ function buildArtifactsLocation() {
4
5
  return path.resolve(__dirname, "..", "build");
5
- };
6
+ }
7
+ exports.buildArtifactsLocation = buildArtifactsLocation;
6
8
 
7
- exports.identifyCurrentPlatform = function identifyCurrentPlatform() {
8
- const platform = process.platform;
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
- /** @type {string} */
21
- let arch = process.arch;
22
- switch (arch) {
23
- case "arm64": {
24
- arch = "aarch64";
25
- break;
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
- switch (platform) {
37
- case "darwin": {
38
- return `${arch}-apple-darwin`;
39
- }
40
- case "win32": {
41
- if (arch !== "x86_64") {
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
- let bin = path.resolve(__dirname, "..", "..", "build", platform, "bin", name);
10
- if (process.platform === "win32") {
11
- bin += ".exe";
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.3.0",
4
+ "version": "0.4.0",
5
5
  "main": "./npm/index.js",
6
6
  "bin": {
7
- "qjs": "./npm/cli/qjs.js",
8
- "qjsc": "./npm/cli/qjsc.js",
9
- "quickjs-run": "./npm/cli/quickjs-run.js"
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": "suchipi/quickjs",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/suchipi/quickjs.git"
35
+ },
32
36
  "publishConfig": {
33
37
  "access": "public"
34
38
  }
package/tsconfig.json CHANGED
@@ -23,6 +23,7 @@
23
23
  "moduleResolution": "node",
24
24
  "strictNullChecks": true,
25
25
  "esModuleInterop": true,
26
- "types": ["jest"]
26
+ "types": ["jest"],
27
+ "resolveJsonModule": true
27
28
  }
28
29
  }