@suchipi/quickjs 0.4.0 → 0.4.2

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 (111) hide show
  1. package/.gitmodules +6 -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/qjs +0 -0
  14. package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
  15. package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
  16. package/build/aarch64-unknown-linux-gnu/bin/qjsc +0 -0
  17. package/build/aarch64-unknown-linux-gnu/bin/quickjs-run +0 -0
  18. package/build/aarch64-unknown-linux-gnu/extras/fib.so +0 -0
  19. package/build/aarch64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
  20. package/build/aarch64-unknown-linux-gnu/extras/log-argv +0 -0
  21. package/build/aarch64-unknown-linux-gnu/extras/point.so +0 -0
  22. package/build/aarch64-unknown-linux-gnu/extras/run-test262 +0 -0
  23. package/build/aarch64-unknown-linux-gnu/extras/sample-program/sum +0 -0
  24. package/build/aarch64-unknown-linux-gnu/extras/stack-limit-test +0 -0
  25. package/build/aarch64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
  26. package/build/aarch64-unknown-linux-gnu/lib/quickjs-full.a +0 -0
  27. package/build/aarch64-unknown-linux-musl/bin/qjs +0 -0
  28. package/build/aarch64-unknown-linux-musl/bin/qjsbootstrap +0 -0
  29. package/build/aarch64-unknown-linux-musl/bin/qjsbootstrap-bytecode +0 -0
  30. package/build/aarch64-unknown-linux-musl/bin/qjsc +0 -0
  31. package/build/aarch64-unknown-linux-musl/bin/quickjs-run +0 -0
  32. package/build/aarch64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
  33. package/build/aarch64-unknown-linux-musl/extras/run-test262 +0 -0
  34. package/build/aarch64-unknown-linux-musl/extras/sample-program/sum +0 -0
  35. package/build/aarch64-unknown-linux-musl/extras/stack-limit-test +0 -0
  36. package/build/aarch64-unknown-linux-musl/lib/quickjs-core.a +0 -0
  37. package/build/aarch64-unknown-linux-musl/lib/quickjs-full.a +0 -0
  38. package/build/aarch64-unknown-linux-static/bin/qjs +0 -0
  39. package/build/aarch64-unknown-linux-static/bin/qjsbootstrap +0 -0
  40. package/build/aarch64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
  41. package/build/aarch64-unknown-linux-static/bin/qjsc +0 -0
  42. package/build/aarch64-unknown-linux-static/bin/quickjs-run +0 -0
  43. package/build/aarch64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
  44. package/build/aarch64-unknown-linux-static/extras/run-test262 +0 -0
  45. package/build/aarch64-unknown-linux-static/extras/sample-program/sum +0 -0
  46. package/build/aarch64-unknown-linux-static/extras/stack-limit-test +0 -0
  47. package/build/aarch64-unknown-linux-static/lib/quickjs-core.a +0 -0
  48. package/build/aarch64-unknown-linux-static/lib/quickjs-full.a +0 -0
  49. package/build/dts/quickjs-libc.d.ts +0 -105
  50. package/build/dts/quickjs-modulesys.d.ts +180 -0
  51. package/build/x86_64-apple-darwin/bin/qjs +0 -0
  52. package/build/x86_64-apple-darwin/bin/qjsbootstrap +0 -0
  53. package/build/x86_64-apple-darwin/bin/qjsbootstrap-bytecode +0 -0
  54. package/build/x86_64-apple-darwin/bin/qjsc +0 -0
  55. package/build/x86_64-apple-darwin/bin/quickjs-run +0 -0
  56. package/build/x86_64-apple-darwin/extras/is-stdin-a-tty +0 -0
  57. package/build/x86_64-apple-darwin/extras/run-test262 +0 -0
  58. package/build/x86_64-apple-darwin/extras/sample-program/sum +0 -0
  59. package/build/x86_64-apple-darwin/extras/stack-limit-test +0 -0
  60. package/build/x86_64-apple-darwin/lib/quickjs-core.a +0 -0
  61. package/build/x86_64-apple-darwin/lib/quickjs-full.a +0 -0
  62. package/build/x86_64-pc-windows-static/bin/qjs.exe +0 -0
  63. package/build/x86_64-pc-windows-static/bin/qjsbootstrap-bytecode.exe +0 -0
  64. package/build/x86_64-pc-windows-static/bin/qjsbootstrap.exe +0 -0
  65. package/build/x86_64-pc-windows-static/bin/qjsc.exe +0 -0
  66. package/build/x86_64-pc-windows-static/bin/quickjs-run.exe +0 -0
  67. package/build/x86_64-pc-windows-static/extras/is-stdin-a-tty.exe +0 -0
  68. package/build/x86_64-pc-windows-static/extras/log-argv.exe +0 -0
  69. package/build/x86_64-pc-windows-static/extras/run-test262.exe +0 -0
  70. package/build/x86_64-pc-windows-static/extras/sample-program/sum.exe +0 -0
  71. package/build/x86_64-pc-windows-static/extras/stack-limit-test.exe +0 -0
  72. package/build/x86_64-pc-windows-static/lib/quickjs-core.a +0 -0
  73. package/build/x86_64-pc-windows-static/lib/quickjs-full.a +0 -0
  74. package/build/x86_64-unknown-linux-gnu/bin/qjs +0 -0
  75. package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
  76. package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
  77. package/build/x86_64-unknown-linux-gnu/bin/qjsc +0 -0
  78. package/build/x86_64-unknown-linux-gnu/bin/quickjs-run +0 -0
  79. package/build/x86_64-unknown-linux-gnu/extras/fib.so +0 -0
  80. package/build/x86_64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
  81. package/build/x86_64-unknown-linux-gnu/extras/log-argv +0 -0
  82. package/build/x86_64-unknown-linux-gnu/extras/point.so +0 -0
  83. package/build/x86_64-unknown-linux-gnu/extras/run-test262 +0 -0
  84. package/build/x86_64-unknown-linux-gnu/extras/sample-program/sum +0 -0
  85. package/build/x86_64-unknown-linux-gnu/extras/stack-limit-test +0 -0
  86. package/build/x86_64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
  87. package/build/x86_64-unknown-linux-gnu/lib/quickjs-full.a +0 -0
  88. package/build/x86_64-unknown-linux-musl/bin/qjs +0 -0
  89. package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap +0 -0
  90. package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap-bytecode +0 -0
  91. package/build/x86_64-unknown-linux-musl/bin/qjsc +0 -0
  92. package/build/x86_64-unknown-linux-musl/bin/quickjs-run +0 -0
  93. package/build/x86_64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
  94. package/build/x86_64-unknown-linux-musl/extras/run-test262 +0 -0
  95. package/build/x86_64-unknown-linux-musl/extras/sample-program/sum +0 -0
  96. package/build/x86_64-unknown-linux-musl/extras/stack-limit-test +0 -0
  97. package/build/x86_64-unknown-linux-musl/lib/quickjs-core.a +0 -0
  98. package/build/x86_64-unknown-linux-musl/lib/quickjs-full.a +0 -0
  99. package/build/x86_64-unknown-linux-static/bin/qjs +0 -0
  100. package/build/x86_64-unknown-linux-static/bin/qjsbootstrap +0 -0
  101. package/build/x86_64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
  102. package/build/x86_64-unknown-linux-static/bin/qjsc +0 -0
  103. package/build/x86_64-unknown-linux-static/bin/quickjs-run +0 -0
  104. package/build/x86_64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
  105. package/build/x86_64-unknown-linux-static/extras/run-test262 +0 -0
  106. package/build/x86_64-unknown-linux-static/extras/sample-program/sum +0 -0
  107. package/build/x86_64-unknown-linux-static/extras/stack-limit-test +0 -0
  108. package/build/x86_64-unknown-linux-static/lib/quickjs-core.a +0 -0
  109. package/build/x86_64-unknown-linux-static/lib/quickjs-full.a +0 -0
  110. package/package.json +1 -1
  111. package/tsconfig.json +3 -1
package/.gitmodules ADDED
@@ -0,0 +1,6 @@
1
+ [submodule "src/run-test262/test262"]
2
+ path = src/run-test262/test262
3
+ url = https://github.com/tc39/test262.git
4
+ [submodule "src/run-test262/test262o"]
5
+ path = src/run-test262/test262o
6
+ url = https://github.com/tc39/test262.git
Binary file
Binary file
@@ -1044,111 +1044,6 @@ declare module "quickjs:os" {
1044
1044
  export function chmod(path: string, mode: number): void;
1045
1045
  }
1046
1046
 
1047
- /**
1048
- * Options for {@link inspect}.
1049
- */
1050
- declare interface InspectOptions {
1051
- /** Whether to display non-enumerable properties. Defaults to false. */
1052
- all?: boolean;
1053
-
1054
- /** Whether to invoke getter functions. Defaults to false. */
1055
- followGetters?: boolean;
1056
-
1057
- /** Whether to display the indexes of iterable entries. Defaults to false. */
1058
- indexes?: boolean;
1059
-
1060
- /** Hide object details after 𝑁 recursions. Defaults to Infinity. */
1061
- maxDepth?: number;
1062
-
1063
- /** If true, don't identify well-known symbols as `@@…`. Defaults to false. */
1064
- noAmp?: boolean;
1065
-
1066
- /** If true, don't format byte-arrays as hexadecimal. Defaults to false. */
1067
- noHex?: boolean;
1068
-
1069
- /** If true, don't display function source code. Defaults to false. */
1070
- noSource?: boolean;
1071
-
1072
- /** Whether to show `__proto__` properties if possible. Defaults to false. */
1073
- proto?: boolean;
1074
-
1075
- /** Whether to sort properties alphabetically. When false, properties are sorted by creation order. Defaults to false. */
1076
- sort?: boolean;
1077
-
1078
- /** Options that control whether and how ANSI terminal escape sequences for colours should be added to the output. Defaults to false, meaning no colours. */
1079
- colours?: boolean | 256 | 8 | InspectColours;
1080
-
1081
- /** Prefix string to use for indentation. Defaults to '\t'. */
1082
- indent?: string;
1083
- }
1084
-
1085
- declare interface InspectColours {
1086
- off?: string | number;
1087
- red?: string | number;
1088
- grey?: string | number;
1089
- green?: string | number;
1090
- darkGreen?: string | number;
1091
- punct?: string | number;
1092
- keys?: string | number;
1093
- keyEscape?: string | number;
1094
- typeColour?: string | number;
1095
- primitive?: string | number;
1096
- escape?: string | number;
1097
- date?: string | number;
1098
- hexBorder?: string | number;
1099
- hexValue?: string | number;
1100
- hexOffset?: string | number;
1101
- reference?: string | number;
1102
- srcBorder?: string | number;
1103
- srcRowNum?: string | number;
1104
- srcRowText?: string | number;
1105
- nul?: string | number;
1106
- nulProt?: string | number;
1107
- undef?: string | number;
1108
- noExts?: string | number;
1109
- frozen?: string | number;
1110
- sealed?: string | number;
1111
- regex?: string | number;
1112
- string?: string | number;
1113
- symbol?: string | number;
1114
- symbolFade?: string | number;
1115
- braces?: string | number;
1116
- quotes?: string | number;
1117
- empty?: string | number;
1118
- dot?: string | number;
1119
- }
1120
-
1121
- declare interface InspectFunction {
1122
- /**
1123
- * Generate a human-readable representation of a value.
1124
- *
1125
- * @param value - Value to inspect
1126
- * @param options - Additional settings for refining output
1127
- * @returns A string representation of `value`.
1128
- */
1129
- (value: any, options?: InspectOptions): string;
1130
-
1131
- /**
1132
- * Generate a human-readable representation of a value.
1133
- *
1134
- * @param value - Value to inspect
1135
- * @param key - The value's corresponding member name
1136
- * @param options - Additional settings for refining output
1137
- * @returns A string representation of `value`.
1138
- */
1139
- (value: any, key?: string | symbol, options?: InspectOptions): string;
1140
- }
1141
-
1142
- /**
1143
- * Generate a human-readable representation of a value.
1144
- *
1145
- * @param value - Value to inspect
1146
- * @param key - The value's corresponding member name
1147
- * @param options - Additional settings for refining output
1148
- * @returns A string representation of `value`.
1149
- */
1150
- declare var inspect: InspectFunction;
1151
-
1152
1047
  declare var setTimeout: typeof import("quickjs:os").setTimeout;
1153
1048
  declare var clearTimeout: typeof import("quickjs:os").clearTimeout;
1154
1049
 
@@ -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
+ }
Binary file
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@suchipi/quickjs",
3
3
  "description": "Suchipi's QuickJS Fork",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "main": "./npm/index.js",
6
6
  "bin": {
7
7
  "qjs": "npm/cli/qjs.js",
package/tsconfig.json CHANGED
@@ -12,7 +12,9 @@
12
12
  "tests/oldtests/**/*",
13
13
  "build/**/*",
14
14
  "examples/**/*",
15
- "meta/microbench.js"
15
+ "meta/microbench.js",
16
+ "src/run-test262/test262",
17
+ "src/run-test262/test262o"
16
18
  ],
17
19
  "compilerOptions": {
18
20
  "allowJs": true,