@suchipi/quickjs 0.2.0 → 0.2.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.
Files changed (182) hide show
  1. package/build/aarch64-apple-darwin/bin/qjs +0 -0
  2. package/build/aarch64-apple-darwin/bin/qjsbootstrap +0 -0
  3. package/build/aarch64-apple-darwin/bin/qjsbootstrap-bytecode +0 -0
  4. package/build/aarch64-apple-darwin/bin/qjsc +0 -0
  5. package/build/aarch64-apple-darwin/bin/quickjs-run +0 -0
  6. package/build/aarch64-apple-darwin/extras/fib.so +0 -0
  7. package/build/aarch64-apple-darwin/extras/is-stdin-a-tty +0 -0
  8. package/build/aarch64-apple-darwin/extras/log-argv +0 -0
  9. package/build/aarch64-apple-darwin/extras/point.so +0 -0
  10. package/build/aarch64-apple-darwin/extras/run-test262 +0 -0
  11. package/build/aarch64-apple-darwin/extras/sample-program/sum +0 -0
  12. package/build/aarch64-apple-darwin/extras/stack-limit-test +0 -0
  13. package/build/aarch64-apple-darwin/lib/quickjs-core.a +0 -0
  14. package/build/aarch64-apple-darwin/lib/quickjs-full.a +0 -0
  15. package/build/aarch64-unknown-linux-gnu/bin/qjs +0 -0
  16. package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
  17. package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
  18. package/build/aarch64-unknown-linux-gnu/bin/qjsc +0 -0
  19. package/build/aarch64-unknown-linux-gnu/bin/quickjs-run +0 -0
  20. package/build/aarch64-unknown-linux-gnu/extras/fib.so +0 -0
  21. package/build/aarch64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
  22. package/build/aarch64-unknown-linux-gnu/extras/log-argv +0 -0
  23. package/build/aarch64-unknown-linux-gnu/extras/point.so +0 -0
  24. package/build/aarch64-unknown-linux-gnu/extras/run-test262 +0 -0
  25. package/build/aarch64-unknown-linux-gnu/extras/sample-program/sum +0 -0
  26. package/build/aarch64-unknown-linux-gnu/extras/stack-limit-test +0 -0
  27. package/build/aarch64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
  28. package/build/aarch64-unknown-linux-gnu/lib/quickjs-full.a +0 -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/fib.so +0 -0
  35. package/build/aarch64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
  36. package/build/aarch64-unknown-linux-musl/extras/log-argv +0 -0
  37. package/build/aarch64-unknown-linux-musl/extras/point.so +0 -0
  38. package/build/aarch64-unknown-linux-musl/extras/run-test262 +0 -0
  39. package/build/aarch64-unknown-linux-musl/extras/sample-program/sum +0 -0
  40. package/build/aarch64-unknown-linux-musl/extras/stack-limit-test +0 -0
  41. package/build/aarch64-unknown-linux-musl/lib/quickjs-core.a +0 -0
  42. package/build/aarch64-unknown-linux-musl/lib/quickjs-full.a +0 -0
  43. package/build/aarch64-unknown-linux-static/bin/qjs +0 -0
  44. package/build/aarch64-unknown-linux-static/bin/qjsbootstrap +0 -0
  45. package/build/aarch64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
  46. package/build/aarch64-unknown-linux-static/bin/qjsc +0 -0
  47. package/build/aarch64-unknown-linux-static/bin/quickjs-run +0 -0
  48. package/build/aarch64-unknown-linux-static/extras/fib.so +0 -0
  49. package/build/aarch64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
  50. package/build/aarch64-unknown-linux-static/extras/log-argv +0 -0
  51. package/build/aarch64-unknown-linux-static/extras/point.so +0 -0
  52. package/build/aarch64-unknown-linux-static/extras/run-test262 +0 -0
  53. package/build/aarch64-unknown-linux-static/extras/sample-program/sum +0 -0
  54. package/build/aarch64-unknown-linux-static/extras/stack-limit-test +0 -0
  55. package/build/aarch64-unknown-linux-static/lib/quickjs-core.a +0 -0
  56. package/build/aarch64-unknown-linux-static/lib/quickjs-full.a +0 -0
  57. package/build/{aarch64-unknown-linux-musl/dts → dts}/quickjs-libc.d.ts +4 -0
  58. package/build/x86_64-apple-darwin/bin/qjs +0 -0
  59. package/build/x86_64-apple-darwin/bin/qjsbootstrap +0 -0
  60. package/build/x86_64-apple-darwin/bin/qjsbootstrap-bytecode +0 -0
  61. package/build/x86_64-apple-darwin/bin/qjsc +0 -0
  62. package/build/x86_64-apple-darwin/bin/quickjs-run +0 -0
  63. package/build/x86_64-apple-darwin/extras/fib.so +0 -0
  64. package/build/x86_64-apple-darwin/extras/is-stdin-a-tty +0 -0
  65. package/build/x86_64-apple-darwin/extras/log-argv +0 -0
  66. package/build/x86_64-apple-darwin/extras/point.so +0 -0
  67. package/build/x86_64-apple-darwin/extras/run-test262 +0 -0
  68. package/build/x86_64-apple-darwin/extras/sample-program/sum +0 -0
  69. package/build/x86_64-apple-darwin/extras/stack-limit-test +0 -0
  70. package/build/x86_64-apple-darwin/lib/quickjs-core.a +0 -0
  71. package/build/x86_64-apple-darwin/lib/quickjs-full.a +0 -0
  72. package/build/x86_64-pc-windows-static/bin/qjs.exe +0 -0
  73. package/build/x86_64-pc-windows-static/bin/qjsbootstrap-bytecode.exe +0 -0
  74. package/build/x86_64-pc-windows-static/bin/qjsbootstrap.exe +0 -0
  75. package/build/x86_64-pc-windows-static/bin/qjsc.exe +0 -0
  76. package/build/x86_64-pc-windows-static/bin/quickjs-run.exe +0 -0
  77. package/build/x86_64-pc-windows-static/extras/fib.so +1 -0
  78. package/build/x86_64-pc-windows-static/extras/is-stdin-a-tty.exe +0 -0
  79. package/build/x86_64-pc-windows-static/extras/log-argv.exe +0 -0
  80. package/build/x86_64-pc-windows-static/extras/point.so +1 -0
  81. package/build/x86_64-pc-windows-static/extras/run-test262.exe +0 -0
  82. package/build/x86_64-pc-windows-static/extras/sample-program/sum.exe +0 -0
  83. package/build/x86_64-pc-windows-static/extras/stack-limit-test.exe +0 -0
  84. package/build/x86_64-pc-windows-static/lib/quickjs-core.a +0 -0
  85. package/build/x86_64-pc-windows-static/lib/quickjs-full.a +0 -0
  86. package/build/x86_64-unknown-linux-gnu/bin/qjs +0 -0
  87. package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
  88. package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
  89. package/build/x86_64-unknown-linux-gnu/bin/qjsc +0 -0
  90. package/build/x86_64-unknown-linux-gnu/bin/quickjs-run +0 -0
  91. package/build/x86_64-unknown-linux-gnu/extras/fib.so +0 -0
  92. package/build/x86_64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
  93. package/build/x86_64-unknown-linux-gnu/extras/log-argv +0 -0
  94. package/build/x86_64-unknown-linux-gnu/extras/point.so +0 -0
  95. package/build/x86_64-unknown-linux-gnu/extras/run-test262 +0 -0
  96. package/build/x86_64-unknown-linux-gnu/extras/sample-program/sum +0 -0
  97. package/build/x86_64-unknown-linux-gnu/extras/stack-limit-test +0 -0
  98. package/build/x86_64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
  99. package/build/x86_64-unknown-linux-gnu/lib/quickjs-full.a +0 -0
  100. package/build/x86_64-unknown-linux-musl/bin/qjs +0 -0
  101. package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap +0 -0
  102. package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap-bytecode +0 -0
  103. package/build/x86_64-unknown-linux-musl/bin/qjsc +0 -0
  104. package/build/x86_64-unknown-linux-musl/bin/quickjs-run +0 -0
  105. package/build/x86_64-unknown-linux-musl/extras/fib.so +0 -0
  106. package/build/x86_64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
  107. package/build/x86_64-unknown-linux-musl/extras/log-argv +0 -0
  108. package/build/x86_64-unknown-linux-musl/extras/point.so +0 -0
  109. package/build/x86_64-unknown-linux-musl/extras/run-test262 +0 -0
  110. package/build/x86_64-unknown-linux-musl/extras/sample-program/sum +0 -0
  111. package/build/x86_64-unknown-linux-musl/extras/stack-limit-test +0 -0
  112. package/build/x86_64-unknown-linux-musl/lib/quickjs-core.a +0 -0
  113. package/build/x86_64-unknown-linux-musl/lib/quickjs-full.a +0 -0
  114. package/build/x86_64-unknown-linux-static/bin/qjs +0 -0
  115. package/build/x86_64-unknown-linux-static/bin/qjsbootstrap +0 -0
  116. package/build/x86_64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
  117. package/build/x86_64-unknown-linux-static/bin/qjsc +0 -0
  118. package/build/x86_64-unknown-linux-static/bin/quickjs-run +0 -0
  119. package/build/x86_64-unknown-linux-static/extras/fib.so +0 -0
  120. package/build/x86_64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
  121. package/build/x86_64-unknown-linux-static/extras/log-argv +0 -0
  122. package/build/x86_64-unknown-linux-static/extras/point.so +0 -0
  123. package/build/x86_64-unknown-linux-static/extras/run-test262 +0 -0
  124. package/build/x86_64-unknown-linux-static/extras/sample-program/sum +0 -0
  125. package/build/x86_64-unknown-linux-static/extras/stack-limit-test +0 -0
  126. package/build/x86_64-unknown-linux-static/lib/quickjs-core.a +0 -0
  127. package/build/x86_64-unknown-linux-static/lib/quickjs-full.a +0 -0
  128. package/package.json +1 -1
  129. package/tsconfig.json +11 -2
  130. package/build/aarch64-apple-darwin/dts/quickjs-libc.d.ts +0 -1355
  131. package/build/aarch64-unknown-linux-gnu/dts/inspect.d.ts +0 -123
  132. package/build/aarch64-unknown-linux-gnu/dts/quickjs-libbytecode.d.ts +0 -24
  133. package/build/aarch64-unknown-linux-gnu/dts/quickjs-libc.d.ts +0 -1355
  134. package/build/aarch64-unknown-linux-gnu/dts/quickjs-libcontext.d.ts +0 -179
  135. package/build/aarch64-unknown-linux-gnu/dts/quickjs-libpointer.d.ts +0 -14
  136. package/build/aarch64-unknown-linux-gnu/dts/quickjs.d.ts +0 -859
  137. package/build/aarch64-unknown-linux-musl/dts/inspect.d.ts +0 -123
  138. package/build/aarch64-unknown-linux-musl/dts/quickjs-libbytecode.d.ts +0 -24
  139. package/build/aarch64-unknown-linux-musl/dts/quickjs-libcontext.d.ts +0 -179
  140. package/build/aarch64-unknown-linux-musl/dts/quickjs-libpointer.d.ts +0 -14
  141. package/build/aarch64-unknown-linux-musl/dts/quickjs.d.ts +0 -859
  142. package/build/aarch64-unknown-linux-static/dts/inspect.d.ts +0 -123
  143. package/build/aarch64-unknown-linux-static/dts/quickjs-libbytecode.d.ts +0 -24
  144. package/build/aarch64-unknown-linux-static/dts/quickjs-libc.d.ts +0 -1355
  145. package/build/aarch64-unknown-linux-static/dts/quickjs-libcontext.d.ts +0 -179
  146. package/build/aarch64-unknown-linux-static/dts/quickjs-libpointer.d.ts +0 -14
  147. package/build/aarch64-unknown-linux-static/dts/quickjs.d.ts +0 -859
  148. package/build/x86_64-apple-darwin/dts/inspect.d.ts +0 -123
  149. package/build/x86_64-apple-darwin/dts/quickjs-libbytecode.d.ts +0 -24
  150. package/build/x86_64-apple-darwin/dts/quickjs-libc.d.ts +0 -1355
  151. package/build/x86_64-apple-darwin/dts/quickjs-libcontext.d.ts +0 -179
  152. package/build/x86_64-apple-darwin/dts/quickjs-libpointer.d.ts +0 -14
  153. package/build/x86_64-apple-darwin/dts/quickjs.d.ts +0 -859
  154. package/build/x86_64-pc-windows-static/dts/inspect.d.ts +0 -123
  155. package/build/x86_64-pc-windows-static/dts/quickjs-libbytecode.d.ts +0 -24
  156. package/build/x86_64-pc-windows-static/dts/quickjs-libc.d.ts +0 -1355
  157. package/build/x86_64-pc-windows-static/dts/quickjs-libcontext.d.ts +0 -179
  158. package/build/x86_64-pc-windows-static/dts/quickjs-libpointer.d.ts +0 -14
  159. package/build/x86_64-pc-windows-static/dts/quickjs.d.ts +0 -859
  160. package/build/x86_64-unknown-linux-gnu/dts/inspect.d.ts +0 -123
  161. package/build/x86_64-unknown-linux-gnu/dts/quickjs-libbytecode.d.ts +0 -24
  162. package/build/x86_64-unknown-linux-gnu/dts/quickjs-libc.d.ts +0 -1355
  163. package/build/x86_64-unknown-linux-gnu/dts/quickjs-libcontext.d.ts +0 -179
  164. package/build/x86_64-unknown-linux-gnu/dts/quickjs-libpointer.d.ts +0 -14
  165. package/build/x86_64-unknown-linux-gnu/dts/quickjs.d.ts +0 -859
  166. package/build/x86_64-unknown-linux-musl/dts/inspect.d.ts +0 -123
  167. package/build/x86_64-unknown-linux-musl/dts/quickjs-libbytecode.d.ts +0 -24
  168. package/build/x86_64-unknown-linux-musl/dts/quickjs-libc.d.ts +0 -1355
  169. package/build/x86_64-unknown-linux-musl/dts/quickjs-libcontext.d.ts +0 -179
  170. package/build/x86_64-unknown-linux-musl/dts/quickjs-libpointer.d.ts +0 -14
  171. package/build/x86_64-unknown-linux-musl/dts/quickjs.d.ts +0 -859
  172. package/build/x86_64-unknown-linux-static/dts/inspect.d.ts +0 -123
  173. package/build/x86_64-unknown-linux-static/dts/quickjs-libbytecode.d.ts +0 -24
  174. package/build/x86_64-unknown-linux-static/dts/quickjs-libc.d.ts +0 -1355
  175. package/build/x86_64-unknown-linux-static/dts/quickjs-libcontext.d.ts +0 -179
  176. package/build/x86_64-unknown-linux-static/dts/quickjs-libpointer.d.ts +0 -14
  177. package/build/x86_64-unknown-linux-static/dts/quickjs.d.ts +0 -859
  178. /package/build/{aarch64-apple-darwin/dts → dts}/inspect.d.ts +0 -0
  179. /package/build/{aarch64-apple-darwin/dts → dts}/quickjs-libbytecode.d.ts +0 -0
  180. /package/build/{aarch64-apple-darwin/dts → dts}/quickjs-libcontext.d.ts +0 -0
  181. /package/build/{aarch64-apple-darwin/dts → dts}/quickjs-libpointer.d.ts +0 -0
  182. /package/build/{aarch64-apple-darwin/dts → dts}/quickjs.d.ts +0 -0
@@ -1,1355 +0,0 @@
1
- // Definitions of the globals and modules added by quickjs-libc
2
-
3
- /**
4
- * Provides the command line arguments. The first argument is the script name.
5
- */
6
- declare var scriptArgs: Array<string>;
7
-
8
- /**
9
- * Print the arguments separated by spaces and a trailing newline.
10
- *
11
- * Non-string args are coerced into a string via [ToString](https://tc39.es/ecma262/#sec-tostring).
12
- * Objects can override the default `ToString` behavior by defining a `toString` method.
13
- */
14
- declare var print: (...args: Array<any>) => void;
15
-
16
- /**
17
- * Object that provides functions for logging information.
18
- */
19
- interface Console {
20
- /** Same as {@link print}(). */
21
- log: typeof print;
22
-
23
- /** Same as {@link print}(). */
24
- warn: typeof print;
25
-
26
- /** Same as {@link print}(). */
27
- error: typeof print;
28
-
29
- /** Same as {@link print}(). */
30
- info: typeof print;
31
- }
32
-
33
- declare var console: Console;
34
-
35
- /** An object representing a file handle. */
36
- declare interface FILE {
37
- /**
38
- * Human-readable description of where this FILE points.
39
- *
40
- * If `target` is a number, the FILE was opened with fdopen, and `target` is
41
- * the fd. Otherwise, `target` will be an arbitrary string that describes the
42
- * file; it may be the absolute path to the file, the relative path to the
43
- * file at time of its opening, or some other string like "stdin" or
44
- * "tmpfile".
45
- *
46
- * You should *not* use this property for anything other than logging and
47
- * debugging. It is *only* provided for debugging and/or troubleshooting
48
- * purposes. The value of this property could change at any time when
49
- * upgrading yavascript, even if upgrading by a minor or patch release.
50
- */
51
- target: string | number;
52
-
53
- /**
54
- * Close the file handle. Note that for files other than stdin/stdout/stderr,
55
- * the file will be closed automatically when the `FILE` object is
56
- * garbage-collected.
57
- */
58
- close(): void;
59
-
60
- /** Outputs the string with the UTF-8 encoding. */
61
- puts(...strings: Array<string>): void;
62
-
63
- /**
64
- * Formatted printf.
65
- *
66
- * The same formats as the standard C library `printf` are supported. Integer format types (e.g. `%d`) truncate the Numbers or BigInts to 32 bits. Use the `l` modifier (e.g. `%ld`) to truncate to 64 bits.
67
- */
68
- printf(fmt: string, ...args: Array<any>): void;
69
-
70
- /** Flush the buffered file. Wrapper for C `fflush`. */
71
- flush(): void;
72
-
73
- /** Sync the buffered file to disk. Wrapper for C `fsync`. */
74
- sync(): void;
75
-
76
- /**
77
- * Seek to a given file position (whence is `std.SEEK_*`).
78
- *
79
- * `offset` can be a number or a bigint.
80
- */
81
- seek(offset: number, whence: number): void;
82
-
83
- /** Return the current file position. */
84
- tell(): number;
85
-
86
- /** Return the current file position as a bigint. */
87
- tello(): BigInt;
88
-
89
- /** Return true if end of file. */
90
- eof(): boolean;
91
-
92
- /** Return the associated OS handle. */
93
- fileno(): number;
94
-
95
- /** Read `length` bytes from the file to the ArrayBuffer `buffer` at byte position `position` (wrapper to the libc `fread`). Returns the number of bytes read, or `0` if the end of the file has been reached. */
96
- read(buffer: ArrayBuffer, position: number, length: number): number;
97
-
98
- /** Write `length` bytes from the ArrayBuffer `buffer` at byte position `position` into the file (wrapper to the libc `fwrite`). Returns the number of bytes written. */
99
- write(buffer: ArrayBuffer, position: number, length: number): number;
100
-
101
- /**
102
- * Return the next line from the file, assuming UTF-8 encoding, excluding the trailing line feed or EOF.
103
- *
104
- * If the end of the file has been reached, then `null` will be returned instead of a string.
105
- *
106
- * Note: Although the trailing line feed has been removed, a carriage return (`\r`) may still be present.
107
- */
108
- getline(): string | null;
109
-
110
- /** Read `maxSize` bytes from the file and return them as a string assuming UTF-8 encoding. If `maxSize` is not present, the file is read up its end. */
111
- readAsString(maxSize?: number): string;
112
-
113
- /** Return the next byte from the file. Return -1 if the end of file is reached. */
114
- getByte(): number;
115
-
116
- /** Write one byte to the file. */
117
- putByte(value: number): void;
118
-
119
- /**
120
- * Set the buffering mode and buffer size for the file stream (wrapper to the libc `setvbuf()`).
121
- *
122
- * Note that unlike the libc setvbuf, the "buffer" argument is not supported, and therefore is not present.
123
- *
124
- * @param mode The buffering mode to use. It can be one of the following values: `std._IOFBF` for full buffering, `std._IOLBF` for line buffering, or `std._IONBF` for no buffering.
125
- * @param size The size to resize the internal in-memory buffer for this file to.
126
- */
127
- setvbuf(mode: number, size: number): void;
128
- }
129
-
130
- declare module "quickjs:std" {
131
- /**
132
- * Exit the process with the provided status code.
133
- *
134
- * @param statusCode The exit code; 0 for success, nonzero for failure.
135
- */
136
- export function exit(statusCode: number): void;
137
-
138
- /**
139
- * Evaluate the string `code` as a script (global eval).
140
- *
141
- * @param code - The code to evaluate.
142
- * @param options - An optional object containing the following optional properties:
143
- * @property backtraceBarrier - Boolean (default = false). If true, error backtraces do not list the stack frames below the evalScript.
144
- * @property filename - String (default = "<evalScript>"). The filename to associate with the code being executed.
145
- * @returns The result of the evaluation.
146
- */
147
- export function evalScript(
148
- code: string,
149
- options?: { backtraceBarrier?: boolean; filename?: string }
150
- ): any;
151
-
152
- /**
153
- * Evaluate the file `filename` as a script (global eval).
154
- *
155
- * @param filename - The relative or absolute path to the file to load. Relative paths are resolved relative to the process's current working directory.
156
- * @returns The result of the evaluation.
157
- */
158
- export function loadScript(filename: string): any;
159
-
160
- /**
161
- * Evaluate the file `filename` as a module. Effectively a synchronous dynamic `import()`.
162
- *
163
- * @param filename - The relative or absolute path to the file to import. Relative paths are resolved relative to the file calling `importModule`, or `basename` if present.
164
- * @param basename - If present and `filename` is a relative path, `filename` will be resolved relative to this basename.
165
- * @returns The result of the evaluation (module namespace object).
166
- */
167
- export function importModule(
168
- filename: string,
169
- basename?: string
170
- ): { [key: string]: any };
171
-
172
- /**
173
- * Return the resolved path to a module.
174
- *
175
- * @param filename - The relative or absolute path to the file to import. Relative paths are resolved relative to the file calling `importModule`, or `basename` if present.
176
- * @param basename - If present and `filename` is a relative path, `filename` will be resolved relative to this basename.
177
- * @returns The resolved module path.
178
- */
179
- export function resolveModule(filename: string, basename?: string): string;
180
-
181
- /**
182
- * Load the file `filename` and return it as a string assuming UTF-8 encoding.
183
- *
184
- * @param filename - The relative or absolute path to the file to load. Relative paths are resolved relative to the process's current working directory.
185
- */
186
- export function loadFile(filename: string): string;
187
-
188
- /**
189
- * Read the script of module filename from an active stack frame, then return it as a string.
190
- *
191
- * If there isn't a valid filename for the specified stack frame, an error will be thrown.
192
- *
193
- * @param stackLevels - How many levels up the stack to search for a filename. Defaults to 0, which uses the current stack frame.
194
- */
195
- export function getFileNameFromStack(stackLevels?: number): string;
196
-
197
- /**
198
- * Return a boolean indicating whether the provided value is a FILE object.
199
- *
200
- * @param value - The value to check.
201
- * @returns Whether the value was a `FILE` or not.
202
- */
203
- export function isFILE(value: any): boolean;
204
-
205
- /**
206
- * Open a file (wrapper to the libc `fopen()`).
207
- * Return the FILE object.
208
- *
209
- * @param filename - The relative or absolute path to the file to open. Relative paths are resolved relative to the process's current working directory.
210
- * @param flags - A string containing any combination of the characters 'r', 'w', 'a', '+', and/or 'b'.
211
- * @returns The opened FILE object.
212
- */
213
- export function open(filename: string, flags: string): FILE;
214
-
215
- /**
216
- * Open a process by creating a pipe (wrapper to the libc `popen()`).
217
- * Return the FILE object.
218
- *
219
- * @param command - The command line to execute. Gets passed via `/bin/sh -c`.
220
- * @param flags - A string containing any combination of the characters 'r', 'w', 'a', '+', and/or 'b'.
221
- * @returns The opened FILE object.
222
- */
223
- export function popen(command: string, flags: string): FILE;
224
-
225
- /**
226
- * Open a file from a file handle (wrapper to the libc `fdopen()`).
227
- * Return the FILE object.
228
- *
229
- * @param fd - The file handle to open.
230
- * @param flags - A string containing any combination of the characters 'r', 'w', 'a', '+', and/or 'b'.
231
- * @returns The opened FILE object.
232
- */
233
- export function fdopen(fd: number, flags: string): FILE;
234
-
235
- /**
236
- * Open a temporary file.
237
- * Return the FILE object.
238
- *
239
- * @returns The opened FILE object.
240
- */
241
- export function tmpfile(): FILE;
242
-
243
- /** Equivalent to `std.out.puts(str)`. */
244
- export function puts(...strings: Array<string>): void;
245
-
246
- /** Equivalent to `std.out.printf(fmt, ...args)` */
247
- export function printf(fmt: string, ...args: Array<any>): void;
248
-
249
- /** Equivalent to the libc sprintf(). */
250
- export function sprintf(fmt: string, ...args: Array<any>): void;
251
-
252
- /** Wrapper to the libc file stdin. */
253
- var in_: FILE;
254
-
255
- export { in_ as in };
256
-
257
- /** Wrapper to the libc file stdout. */
258
- export var out: FILE;
259
-
260
- /** Wrapper to the libc file stderr. */
261
- export var err: FILE;
262
-
263
- /** Constant for {@link FILE.seek}. Declares that pointer offset should be relative to the beginning of the file. See also libc `fseek()`. */
264
- export var SEEK_SET: number;
265
-
266
- /** Constant for {@link FILE.seek}. Declares that the offset should be relative to the current position of the FILE handle. See also libc `fseek()`. */
267
- export var SEEK_CUR: number;
268
-
269
- /** Constant for {@link FILE.seek}. Declares that the offset should be relative to the end of the file. See also libc `fseek()`. */
270
- export var SEEK_END: number;
271
-
272
- /** Constant for {@link FILE.setvbuf}. Declares that the buffer mode should be 'full buffering'. */
273
- export var _IOFBF: number;
274
-
275
- /** Constant for {@link FILE.setvbuf}. Declares that the buffer mode should be 'line buffering'. */
276
- export var _IOLBF: number;
277
-
278
- /** Constant for {@link FILE.setvbuf}. Declares that the buffer mode should be 'no buffering'. */
279
- export var _IONBF: number;
280
-
281
- /** Manually invoke the cycle removal algorithm (garbage collector). The cycle removal algorithm is automatically started when needed, so this function is useful in case of specific memory constraints or for testing. */
282
- export function gc(): void;
283
-
284
- /** Return the value of the environment variable `name` or `undefined` if it is not defined. */
285
- export function getenv(name: string): string | undefined;
286
-
287
- /** Set the value of the environment variable `name` to the string `value`. */
288
- export function setenv(name: string, value: string): void;
289
-
290
- /** Delete the environment variable `name`. */
291
- export function unsetenv(name: string): void;
292
-
293
- /** Return an object containing the environment variables as key-value pairs. */
294
- export function getenviron(): { [key: string]: string | undefined };
295
-
296
- /**
297
- * Return the real user ID of the calling process.
298
- *
299
- * This function throws an error on windows, because windows doesn't support
300
- * the same uid/gid paradigm as Unix-like operating systems.
301
- */
302
- export function getuid(): number;
303
-
304
- /**
305
- * Return the effective user ID of the calling process.
306
- *
307
- * This function throws an error on windows, because windows doesn't support
308
- * the same uid/gid paradigm as Unix-like operating systems.
309
- */
310
- export function geteuid(): number;
311
-
312
- /**
313
- * Return the real group ID of the calling process.
314
- *
315
- * This function throws an error on windows, because windows doesn't support
316
- * the same uid/gid paradigm as Unix-like operating systems.
317
- */
318
- export function getgid(): number;
319
-
320
- /**
321
- * Return the effective group ID of the calling process.
322
- *
323
- * This function throws an error on windows, because windows doesn't support
324
- * the same uid/gid paradigm as Unix-like operating systems.
325
- */
326
- export function getegid(): number;
327
-
328
- interface UrlGet {
329
- /**
330
- * Download `url` using the `curl` command line utility. Returns string
331
- * when the http status code is between 200 and 299, and throws otherwise.
332
- *
333
- * Pass an object with { full: true } as the second argument to get
334
- * response headers and status code.
335
- */
336
- (url: string): string;
337
-
338
- /**
339
- * Download `url` using the `curl` command line utility. Returns string
340
- * when the http status code is between 200 and 299, and throws otherwise.
341
- *
342
- * Pass an object with { full: true } as the second argument to get
343
- * response headers and status code.
344
- */
345
- (url: string, options: { binary: false }): string;
346
-
347
- /**
348
- * Download `url` using the `curl` command line utility. Returns string
349
- * when the http status code is between 200 and 299, and throws otherwise.
350
- *
351
- * Pass an object with { full: true } as the second argument to get
352
- * response headers and status code.
353
- */
354
- (url: string, options: { full: false }): string;
355
-
356
- /**
357
- * Download `url` using the `curl` command line utility. Returns string
358
- * when the http status code is between 200 and 299, and throws otherwise.
359
- *
360
- * Pass an object with { full: true } as the second argument to get
361
- * response headers and status code.
362
- */
363
- (url: string, options: { binary: false; full: false }): string;
364
-
365
- /**
366
- * Download `url` using the `curl` command line utility. Returns
367
- * ArrayBuffer when the http status code is between 200 and 299, and throws
368
- * otherwise.
369
- *
370
- * Pass an object with { full: true } as the second argument to get
371
- * response headers and status code.
372
- */
373
- (url: string, options: { binary: true }): ArrayBuffer;
374
-
375
- /**
376
- * Download `url` using the `curl` command line utility. Returns
377
- * ArrayBuffer when the http status code is between 200 and 299, and throws
378
- * otherwise.
379
- *
380
- * Pass an object with { full: true } as the second argument to get
381
- * response headers and status code.
382
- */
383
- (url: string, options: { binary: true; full: false }): ArrayBuffer;
384
-
385
- /**
386
- * Download `url` using the `curl` command line utility.
387
- *
388
- * Returns an object with three properties:
389
- *
390
- * - `response`: response body content (string)
391
- * - `responseHeaders`: headers separated by CRLF (string)
392
- * - `status`: status code (number)
393
- */
394
- (url: string, options: { full: true }): {
395
- status: number;
396
- response: string;
397
- responseHeaders: string;
398
- };
399
-
400
- /**
401
- * Download `url` using the `curl` command line utility.
402
- *
403
- * Returns an object with three properties:
404
- *
405
- * - `response`: response body content (string)
406
- * - `responseHeaders`: headers separated by CRLF (string)
407
- * - `status`: status code (number)
408
- */
409
- (url: string, options: { full: true; binary: false }): {
410
- status: number;
411
- response: string;
412
- responseHeaders: string;
413
- };
414
-
415
- /**
416
- * Download `url` using the `curl` command line utility.
417
- *
418
- * Returns an object with three properties:
419
- *
420
- * - `response`: response body content (ArrayBuffer)
421
- * - `responseHeaders`: headers separated by CRLF (string)
422
- * - `status`: status code (number)
423
- */
424
- (url: string, options: { full: true; binary: true }): {
425
- status: number;
426
- response: ArrayBuffer;
427
- responseHeaders: string;
428
- };
429
- }
430
-
431
- export var urlGet: UrlGet;
432
-
433
- /**
434
- * Parse `str` using a superset of JSON.parse. The following extensions are accepted:
435
- *
436
- * - Single line and multiline comments
437
- * - unquoted properties (ASCII-only Javascript identifiers)
438
- * - trailing comma in array and object definitions
439
- * - single quoted strings
440
- * - `\f` and `\v` are accepted as space characters
441
- * - leading plus in numbers
442
- * - octal (0o prefix) and hexadecimal (0x prefix) numbers
443
- */
444
- export function parseExtJSON(str: string): any;
445
-
446
- /**
447
- * A wrapper around the standard C [strftime](https://en.cppreference.com/w/c/chrono/strftime).
448
- * Formats a time/date into a format as specified by the user.
449
- *
450
- * @param maxBytes - The number of bytes to allocate for the string that will be returned
451
- * @param format - Format string, using `%`-prefixed sequences as found in [this table](https://en.cppreference.com/w/c/chrono/strftime#Format_string).
452
- * @param time - The Date object (or unix timestamp, in ms) to render.
453
- */
454
- export function strftime(
455
- maxBytes: number,
456
- format: string,
457
- time: Date | number
458
- ): string;
459
- }
460
-
461
- declare module "quickjs:os" {
462
- /**
463
- * Open a file handle. Returns a number; the file descriptor.
464
- *
465
- * @param filename - The path to the file to open.
466
- * @param flags - Numeric flags that set the mode to use when opening the file. See `os.O_*`
467
- * @param mode - Octal access mask. Defaults to 0o666.
468
- */
469
- export function open(filename: string, flags: number, mode?: number): number;
470
-
471
- /** POSIX open flag, used in {@link open}. */
472
- export var O_RDONLY: number;
473
-
474
- /** POSIX open flag, used in {@link open}. */
475
- export var O_WRONLY: number;
476
-
477
- /** POSIX open flag, used in {@link open}. */
478
- export var O_RDWR: number;
479
-
480
- /** POSIX open flag, used in {@link open}. */
481
- export var O_APPEND: number;
482
-
483
- /** POSIX open flag, used in {@link open}. */
484
- export var O_CREAT: number;
485
-
486
- /** POSIX open flag, used in {@link open}. */
487
- export var O_EXCL: number;
488
-
489
- /** POSIX open flag, used in {@link open}. */
490
- export var O_TRUNC: number;
491
-
492
- /**
493
- * Windows-specific open flag: open the file in binary mode (which is the default). Used in {@link open}.
494
- *
495
- * NOTE: this property is only present on windows
496
- */
497
- export var O_BINARY: number | undefined;
498
-
499
- /**
500
- * Windows-specific open flag: open the file in text mode. The default is binary mode. Used in {@link open}.
501
- *
502
- * NOTE: this property is only present on windows
503
- */
504
- export var O_TEXT: number | undefined;
505
-
506
- /** Close the file with descriptor `fd`. */
507
- export function close(fd: number): void;
508
-
509
- interface OsSeek {
510
- /** Seek in the file. Use `std.SEEK_*` for `whence`. `offset` is either a number or a bigint. If `offset` is a bigint, a bigint is returned too. */
511
- (fd: number, offset: number, whence: number): number;
512
-
513
- /** Seek in the file. Use `std.SEEK_*` for `whence`. `offset` is either a number or a bigint. If `offset` is a bigint, a bigint is returned too. */
514
- (fd: number, offset: BigInt, whence: number): BigInt;
515
- }
516
-
517
- /** Seek in the file. Use `std.SEEK_*` for `whence`. `offset` is either a number or a bigint. If `offset` is a bigint, a bigint is returned too. */
518
- export var seek: OsSeek;
519
-
520
- /** Read `length` bytes from the file with descriptor `fd` to the ArrayBuffer `buffer` at byte position `offset`. Return the number of read bytes. */
521
- export function read(
522
- fd: number,
523
- buffer: ArrayBuffer,
524
- offset: number,
525
- length: number
526
- ): number;
527
-
528
- /** Write `length` bytes to the file with descriptor `fd` from the ArrayBuffer `buffer` at byte position `offset`. Return the number of written bytes. */
529
- export function write(
530
- fd: number,
531
- buffer: ArrayBuffer,
532
- offset: number,
533
- length: number
534
- ): number;
535
-
536
- /** Return `true` if the file opened with descriptor `fd` is a TTY (terminal). */
537
- export function isatty(fd: number): boolean;
538
-
539
- /** Return the TTY size as `[width, height]` or `null` if not available. */
540
- export function ttyGetWinSize(fd: number): null | [number, number];
541
-
542
- /** Set the TTY in raw mode. */
543
- export function ttySetRaw(fd: number): void;
544
-
545
- /** Remove a file. */
546
- export function remove(filename: string): void;
547
-
548
- /** Rename a file. */
549
- export function rename(oldname: string, newname: string): void;
550
-
551
- /** Return the canonicalized absolute pathname of `path`. */
552
- export function realpath(path: string): string;
553
-
554
- /** Return the current working directory. */
555
- export function getcwd(): string;
556
-
557
- /** Change the current directory. */
558
- export function chdir(path: string): void;
559
-
560
- /** Create a directory at `path`. */
561
- export function mkdir(path: string, mode?: number): void;
562
-
563
- export type Stats = {
564
- dev: number;
565
- ino: number;
566
- mode: number;
567
- nlink: number;
568
- uid: number;
569
- gid: number;
570
- rdev: number;
571
- size: number;
572
- blocks: number;
573
- atime: number;
574
- mtime: number;
575
- ctime: number;
576
- };
577
-
578
- /**
579
- * Return a stats object with the following fields:
580
- *
581
- * - `dev`
582
- * - `ino`
583
- * - `mode`
584
- * - `nlink`
585
- * - `uid`
586
- * - `gid`
587
- * - `rdev`
588
- * - `size`
589
- * - `blocks`
590
- * - `atime`
591
- * - `mtime`
592
- * - `ctime`
593
- *
594
- * The times are specified in milliseconds since 1970. `lstat()` is the same as `stat()` except that it returns information about the link itself.
595
- */
596
- export function stat(path: string): Stats;
597
-
598
- /**
599
- * Return a stats object with the following fields:
600
- *
601
- * - `dev`
602
- * - `ino`
603
- * - `mode`
604
- * - `nlink`
605
- * - `uid`
606
- * - `gid`
607
- * - `rdev`
608
- * - `size`
609
- * - `blocks`
610
- * - `atime`
611
- * - `mtime`
612
- * - `ctime`
613
- *
614
- * The times are specified in milliseconds since 1970. `lstat()` is the same as `stat()` except that it returns information about the link itself.
615
- */
616
- export function lstat(path: string): Stats;
617
-
618
- /**
619
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
620
- *
621
- * Mask for getting type of file from mode.
622
- */
623
- export var S_IFMT: number;
624
-
625
- /**
626
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
627
- *
628
- * File type: named pipe (fifo)
629
- */
630
- export var S_IFIFO: number;
631
-
632
- /**
633
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
634
- *
635
- * File type: character special
636
- */
637
- export var S_IFCHR: number;
638
-
639
- /**
640
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
641
- *
642
- * File type: directory
643
- */
644
- export var S_IFDIR: number;
645
-
646
- /**
647
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
648
- *
649
- * File type: block special
650
- */
651
- export var S_IFBLK: number;
652
-
653
- /**
654
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
655
- *
656
- * File type: regular
657
- */
658
- export var S_IFREG: number;
659
-
660
- /**
661
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
662
- *
663
- * File type: socket
664
- *
665
- * NOTE: this property is not present on windows
666
- */
667
- export var S_IFSOCK: number | undefined;
668
-
669
- /**
670
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
671
- *
672
- * File type: symbolic link
673
- *
674
- * NOTE: this property is not present on windows
675
- */
676
- export var S_IFLNK: number | undefined;
677
-
678
- /**
679
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
680
- *
681
- * Flag: set group id on execution
682
- *
683
- * NOTE: this property is not present on windows
684
- */
685
- export var S_ISGID: number | undefined;
686
-
687
- /**
688
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
689
- *
690
- * Flag: set user id on execution
691
- *
692
- * NOTE: this property is not present on windows
693
- */
694
- export var S_ISUID: number | undefined;
695
-
696
- /**
697
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
698
- *
699
- * Mask for getting RWX permissions for owner
700
- */
701
- export var S_IRWXU: number;
702
-
703
- /**
704
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
705
- *
706
- * Permission: read for owner
707
- */
708
- export var S_IRUSR: number;
709
-
710
- /**
711
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
712
- *
713
- * Permission: write for owner
714
- */
715
- export var S_IWUSR: number;
716
-
717
- /**
718
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
719
- *
720
- * Permission: execute for owner
721
- */
722
- export var S_IXUSR: number;
723
-
724
- /**
725
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
726
- *
727
- * Mask for getting RWX permissions for group
728
- */
729
- export var S_IRWXG: number;
730
-
731
- /**
732
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
733
- *
734
- * Permission: read for group
735
- */
736
- export var S_IRGRP: number;
737
-
738
- /**
739
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
740
- *
741
- * Permission: write for group
742
- */
743
- export var S_IWGRP: number;
744
-
745
- /**
746
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
747
- *
748
- * Permission: execute for group
749
- */
750
- export var S_IXGRP: number;
751
-
752
- /**
753
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
754
- *
755
- * Mask for getting RWX permissions for others
756
- */
757
- export var S_IRWXO: number;
758
-
759
- /**
760
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
761
- *
762
- * Permission: read for others
763
- */
764
- export var S_IROTH: number;
765
-
766
- /**
767
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
768
- *
769
- * Permission: write for others
770
- */
771
- export var S_IWOTH: number;
772
-
773
- /**
774
- * Constant to interpret the `mode` property returned by `stat()`. Has the same value as in the C system header `sys/stat.h`.
775
- *
776
- * Permission: execute for others
777
- */
778
- export var S_IXOTH: number;
779
-
780
- /**
781
- * Change the access and modification times of the file path.
782
- *
783
- * The times are specified in milliseconds since 1970.
784
- */
785
- export function utimes(path: string, atime: number, mtime: number): void;
786
-
787
- /** Create a link at `linkpath` containing the string `target`. */
788
- export function symlink(target: string, linkpath: string): void;
789
-
790
- /** Return the link target. */
791
- export function readlink(path: string): string;
792
-
793
- /** Return an array of strings containing the filenames of the directory `path`. */
794
- export function readdir(path: string): Array<string>;
795
-
796
- /** Add a read handler to the file with descriptor `fd`. `func` is called each time there is data pending for `fd`. A single read handler per file handle is supported. Use `func = null` to remove the handler. */
797
- export function setReadHandler(fd: number, func: null | (() => void)): void;
798
-
799
- /** Add a write handler to the file with descriptor `fd`. `func` is called each time data can be written to `fd`. A single write handler per file handle is supported. Use `func = null` to remove the handler. */
800
- export function setWriteHandler(fd: number, func: null | (() => void)): void;
801
-
802
- /** Call the function `func` when the signal `signal` happens. Only a single handler per signal number is supported. Use `null` to set the default handler or `undefined` to ignore the signal. Signal handlers can only be defined in the main thread. */
803
- export function signal(
804
- signal: number,
805
- func: null | undefined | (() => void)
806
- ): void;
807
-
808
- /** POSIX signal number. */
809
- export var SIGINT: number;
810
-
811
- /** POSIX signal number. */
812
- export var SIGABRT: number;
813
-
814
- /** POSIX signal number. */
815
- export var SIGFPE: number;
816
-
817
- /** POSIX signal number. */
818
- export var SIGILL: number;
819
-
820
- /** POSIX signal number. */
821
- export var SIGSEGV: number;
822
-
823
- /** POSIX signal number. */
824
- export var SIGTERM: number;
825
-
826
- /** POSIX signal number. NOTE: this signal is not present on windows. */
827
- export var SIGQUIT: number | undefined;
828
-
829
- /** POSIX signal number. NOTE: this signal is not present on windows. */
830
- export var SIGPIPE: number | undefined;
831
-
832
- /** POSIX signal number. NOTE: this signal is not present on windows. */
833
- export var SIGALRM: number | undefined;
834
-
835
- /** POSIX signal number. NOTE: this signal is not present on windows. */
836
- export var SIGUSR1: number | undefined;
837
-
838
- /** POSIX signal number. NOTE: this signal is not present on windows. */
839
- export var SIGUSR2: number | undefined;
840
-
841
- /** POSIX signal number. NOTE: this signal is not present on windows. */
842
- export var SIGCHLD: number | undefined;
843
-
844
- /** POSIX signal number. NOTE: this signal is not present on windows. */
845
- export var SIGCONT: number | undefined;
846
-
847
- /** POSIX signal number. NOTE: this signal is not present on windows. */
848
- export var SIGSTOP: number | undefined;
849
-
850
- /** POSIX signal number. NOTE: this signal is not present on windows. */
851
- export var SIGTSTP: number | undefined;
852
-
853
- /** POSIX signal number. NOTE: this signal is not present on windows. */
854
- export var SIGTTIN: number | undefined;
855
-
856
- /** POSIX signal number. NOTE: this signal is not present on windows. */
857
- export var SIGTTOU: number | undefined;
858
-
859
- /** Send the signal `sig` to the process `pid`. Use `os.SIG*` constants. */
860
- export function kill(pid: number, sig: number): void;
861
-
862
- export type ExecOptions = {
863
- /** Boolean (default = true). If true, wait until the process is terminated. In this case, `exec` returns the exit code if positive or the negated signal number if the process was interrupted by a signal. If false, do not block and return the process id of the child. */
864
- block?: boolean;
865
-
866
- /** Boolean (default = true). If true, the file is searched in the `PATH` environment variable. */
867
- usePath?: boolean;
868
-
869
- /** String (default = `args[0]`). Set the file to be executed. */
870
- file?: string;
871
-
872
- /** String. If present, set the working directory of the new process. */
873
- cwd?: string;
874
-
875
- /** If present, set the file descriptor in the child for stdin. */
876
- stdin?: number;
877
-
878
- /** If present, set the file descriptor in the child for stdout. */
879
- stdout?: number;
880
-
881
- /** If present, set the file descriptor in the child for stderr. */
882
- stderr?: number;
883
-
884
- /** Object. If present, set the process environment from the object key-value pairs. Otherwise use the same environment as the current process. To get the current process's environment variables as on object, use `std.getenviron()`. */
885
- env?: { [key: string | number]: string | number | boolean };
886
-
887
- /** Integer. If present, the process uid with `setuid`. */
888
- uid?: number;
889
-
890
- /** Integer. If present, the process gid with `setgid`. */
891
- gid?: number;
892
- };
893
-
894
- /** Execute a process with the arguments args, and the provided options (if any). */
895
- export function exec(args: Array<string>, options?: ExecOptions): number;
896
-
897
- /**
898
- * `waitpid` Unix system call. Returns the array [ret, status].
899
- *
900
- * From man waitpid(2):
901
- *
902
- * waitpid(): on success, returns the process ID of the child whose state has changed; if WNOHANG was specified and one or more child(ren) specified by pid exist, but have not yet changed state, then 0 is returned.
903
- */
904
- export function waitpid(pid: number, options?: number): [number, number];
905
-
906
- /** Constant for the `options` argument of `waitpid`. */
907
- export var WNOHANG: number;
908
- /** Constant for the `options` argument of `waitpid`. */
909
- export var WUNTRACED: number;
910
-
911
- /** Function to be used to interpret the 'status' return value of `waitpid`. */
912
- export function WEXITSTATUS(status: number): number;
913
- /** Function to be used to interpret the 'status' return value of `waitpid`. */
914
- export function WTERMSIG(status: number): number;
915
- /** Function to be used to interpret the 'status' return value of `waitpid`. */
916
- export function WSTOPSIG(status: number): number;
917
-
918
- /** Function to be used to interpret the 'status' return value of `waitpid`. */
919
- export function WIFEXITED(status: number): boolean;
920
- /** Function to be used to interpret the 'status' return value of `waitpid`. */
921
- export function WIFSIGNALED(status: number): boolean;
922
- /** Function to be used to interpret the 'status' return value of `waitpid`. */
923
- export function WIFSTOPPED(status: number): boolean;
924
- /** Function to be used to interpret the 'status' return value of `waitpid`. */
925
- export function WIFCONTINUED(status: number): boolean;
926
-
927
- /** `dup` Unix system call. */
928
- export function dup(fd: number): number;
929
-
930
- /** `dup2` Unix system call. */
931
- export function dup2(oldfd: number, newfd: number): number;
932
-
933
- /** `pipe` Unix system call. Return two handles as `[read_fd, write_fd]`. */
934
- export function pipe(): null | [number, number];
935
-
936
- /** Sleep for `delay_ms` milliseconds. */
937
- export function sleep(delay_ms: number): void;
938
-
939
- export type OSTimer = { [Symbol.toStringTag]: "OSTimer" };
940
-
941
- /** Call the function func after delay ms. Return a handle to the timer. */
942
- export function setTimeout(
943
- func: (...args: any) => any,
944
- delay: number
945
- ): OSTimer;
946
-
947
- /** Cancel a timer. */
948
- export function clearTimeout(handle: OSTimer): void;
949
-
950
- /** Return a string representing the platform: "linux", "darwin", "win32", "freebsd", or "js" (emscripten). */
951
- export var platform: "linux" | "darwin" | "win32" | "freebsd" | "js";
952
-
953
- /**
954
- * Things that can be put into Worker.postMessage.
955
- *
956
- * NOTE: This is effectively the same stuff as supported by the structured
957
- * clone algorithm, but without support for Map/Set (not supported in
958
- * QuickJS yet).
959
- */
960
- export type StructuredClonable =
961
- | string
962
- | number
963
- | boolean
964
- | null
965
- | undefined
966
- | Boolean
967
- | String
968
- | Date
969
- | RegExp
970
- | ArrayBuffer
971
- | Int8Array
972
- | Uint8Array
973
- | Uint8ClampedArray
974
- | Int16Array
975
- | Uint16Array
976
- | Int32Array
977
- | Uint32Array
978
- | Float32Array
979
- | Float64Array
980
- | BigInt64Array
981
- | BigUint64Array
982
- | DataView
983
- | Array<StructuredClonable>
984
- | SharedArrayBuffer
985
- // Map and Set not yet supported
986
- // | Map<StructuredClonable, StructuredClonable>
987
- // | Set<StructuredClonable>
988
- | { [key: string | number]: StructuredClonable };
989
-
990
- export class Worker {
991
- /**
992
- * Constructor to create a new thread (worker) with an API close to the
993
- * `WebWorkers`. `moduleFilename` is a string specifying the module
994
- * filename which is executed in the newly created thread. As for
995
- * dynamically imported module, it is relative to the current script or
996
- * module path. Threads normally don’t share any data and communicate
997
- * between each other with messages. Nested workers are not supported.
998
- */
999
- constructor(moduleFilename: string);
1000
-
1001
- /**
1002
- * In the created worker, Worker.parent represents the parent worker and is
1003
- * used to send or receive messages.
1004
- */
1005
- static parent: Worker;
1006
-
1007
- /**
1008
- * Send a message to the corresponding worker. msg is cloned in the
1009
- * destination worker using an algorithm similar to the HTML structured
1010
- * clone algorithm. SharedArrayBuffer are shared between workers.
1011
- *
1012
- * Current limitations: Map and Set are not supported yet.
1013
- */
1014
- postMessage(msg: StructuredClonable): void;
1015
-
1016
- /**
1017
- * Set a function which is called each time a message is received. The
1018
- * function is called with a single argument. It is an object with a data
1019
- * property containing the received message. The thread is not terminated
1020
- * if there is at least one non null onmessage handler.
1021
- */
1022
- onmessage: null | ((event: { data: StructuredClonable }) => void);
1023
- }
1024
-
1025
- /** constant for {@link access}(); test for read permission. */
1026
- export var R_OK: number;
1027
-
1028
- /** constant for {@link access}(); test for write permission. */
1029
- export var W_OK: number;
1030
-
1031
- /** constant for {@link access}(); test for execute (search) permission. */
1032
- export var X_OK: number;
1033
-
1034
- /** constant for {@link access}(); test for existence of file. */
1035
- export var F_OK: number;
1036
-
1037
- /** `access` Unix system call; checks if a file is readable, writable, executable, and/or exists (use {@link R_OK}, {@link W_OK}, {@link X_OK}, and/or {@link F_OK} for `accessMode`). Throws a descriptive error (with errno property) if the requested access is not available; otherwise, returns undefined. */
1038
- export function access(path: string, accessMode: number): void;
1039
-
1040
- /** gets the path to the executable which is executing this JS code. might be a relative path or symlink. */
1041
- export function execPath(): string;
1042
-
1043
- /** changes the access permission bits of the file at `path` using the octal number `mode`. */
1044
- export function chmod(path: string, mode: number): void;
1045
- }
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
- /**
1153
- * A global which lets you configure the module loader (import/export/require).
1154
- * You can use these properties to add support for importing new filetypes.
1155
- *
1156
- * This global can also be used to identify whether an object is a module
1157
- * namespace record.
1158
- */
1159
- interface ModuleGlobal {
1160
- /**
1161
- * Returns true if `target` is a module namespace object.
1162
- */
1163
- [Symbol.hasInstance](target: any): target is {
1164
- [key: string | number | symbol]: any;
1165
- };
1166
-
1167
- /**
1168
- * A list of filetype extensions that may be omitted from an import specifier
1169
- * string.
1170
- *
1171
- * Defaults to `[".js"]`. You can add more strings to this array to
1172
- * make the engine search for additional files when resolving a
1173
- * require/import.
1174
- *
1175
- * See the doc comment on {@link require} for more information.
1176
- *
1177
- * NOTE: If you add a new extension to this array, you will likely also want
1178
- * to add to {@link Module.compilers}.
1179
- */
1180
- searchExtensions: Array<string>;
1181
-
1182
- /**
1183
- * User-defined functions which will handle getting the JavaScript code
1184
- * associated with a module.
1185
- *
1186
- * The key for each property in this object should be a file extension
1187
- * string with a leading dot, eg `".jsx"`. The value for each property should
1188
- * be a function which receives (1) the filepath to a module, and (2) that
1189
- * file's content as a UTF-8 string, and the function should return a string
1190
- * containing JavaScript code that corresponds to that module. In most cases,
1191
- * these functions will compile the contents of the file from one format into JavaScript.
1192
- *
1193
- * The function does not have to use the second 'content' argument it
1194
- * receives (ie. when loading binary files).
1195
- *
1196
- * By adding to this object, you can make it possible to import non-js
1197
- * filetypes; compile-to-JS languages like JSX, TypeScript, and CoffeeScript
1198
- * can be compiled at import time, and asset files like .txt files or .png
1199
- * files can be converted into an appropriate data structure at import time.
1200
- *
1201
- * As an example, to make it possible to import .txt files, you might do:
1202
- * ```js
1203
- * import * as std from "std";
1204
- *
1205
- * Module.compilers[".txt"] = (filename, content) => {
1206
- * return `export default ${JSON.stringify(content)}`;
1207
- * }
1208
- * ```
1209
- * (leveraging `JSON.stringify`'s ability to escape quotes).
1210
- *
1211
- * Then, later in your code, you can do:
1212
- * ```js
1213
- * import names from "./names.txt";
1214
- * ```
1215
- *
1216
- * And `names` will be a string containing the contents of names.txt.
1217
- *
1218
- * NOTE: When adding to this object, you may also wish to add to
1219
- * {@link Module.searchExtensions}.
1220
- */
1221
- compilers: {
1222
- [extensionWithDot: string]: (filename: string, content: string) => string;
1223
- };
1224
-
1225
- /**
1226
- * Create a virtual built-in module whose exports consist of the own
1227
- * enumerable properties of `obj`.
1228
- */
1229
- define(name: string, obj: { [key: string]: any }): void;
1230
-
1231
- /**
1232
- * Resolves a require/import request from `fromFile` into a canonicalized path.
1233
- *
1234
- * To change native module resolution behavior, replace this function with
1235
- * your own implementation. Note that you must handle
1236
- * `Module.searchExtensions` yourself in your replacement implementation.
1237
- */
1238
- resolve(name: string, fromFile: string): string;
1239
-
1240
- /**
1241
- * Reads the contents of the given resolved module name into a string.
1242
- *
1243
- * To change native module loading behavior, replace this function with your
1244
- * own implementation. Note that you must handle `Module.compilers` yourself
1245
- * in your replacement implementation.
1246
- */
1247
- read(modulePath: string): string;
1248
- }
1249
-
1250
- declare var Module: ModuleGlobal;
1251
-
1252
- interface RequireFunction {
1253
- /**
1254
- * Synchronously import a module.
1255
- *
1256
- * `source` will be resolved relative to the calling file.
1257
- *
1258
- * If `source` does not have a file extension, and a file without an extension
1259
- * cannot be found, the engine will check for files with the extensions in
1260
- * {@link Module.searchExtensions}, and use one of those if present. This
1261
- * behavior also happens when using normal `import` statements.
1262
- *
1263
- * For example, if you write:
1264
- *
1265
- * ```js
1266
- * import something from "./somewhere";
1267
- * ```
1268
- *
1269
- * but there's no file named `somewhere` in the same directory as the file
1270
- * where that import appears, and `Module.searchExtensions` is the default
1271
- * value:
1272
- *
1273
- * ```js
1274
- * [".js"]
1275
- * ```
1276
- *
1277
- * then the engine will look for `somewhere.js`. If that doesn't exist, the
1278
- * engine will look for `somewhere/index.js`. If *that* doesn't exist, an error
1279
- * will be thrown.
1280
- *
1281
- * If you add more extensions to `Module.searchExtensions`, then the engine
1282
- * will use those, too. It will search in the same order as the strings appear
1283
- * in the `Module.searchExtensions` array.
1284
- */
1285
- (source: string): any;
1286
-
1287
- /**
1288
- * Resolves the normalized path to a modules, relative to the calling file.
1289
- */
1290
- resolve: (source: string) => string;
1291
- }
1292
-
1293
- declare var require: RequireFunction;
1294
-
1295
- declare var setTimeout: typeof import("quickjs:os").setTimeout;
1296
- declare var clearTimeout: typeof import("quickjs:os").clearTimeout;
1297
-
1298
- declare type Interval = { [Symbol.toStringTag]: "Interval" };
1299
-
1300
- declare function setInterval(func: (...args: any) => any, ms: number): Interval;
1301
- declare function clearInterval(interval: Interval): void;
1302
-
1303
- interface StringConstructor {
1304
- /**
1305
- * A no-op template literal tag.
1306
- *
1307
- * https://github.com/tc39/proposal-string-cooked
1308
- */
1309
- cooked(
1310
- strings: readonly string[] | ArrayLike<string>,
1311
- ...substitutions: any[]
1312
- ): string;
1313
-
1314
- /**
1315
- * Remove leading minimum indentation from the string.
1316
- * The first line of the string must be empty.
1317
- *
1318
- * https://github.com/tc39/proposal-string-dedent
1319
- */
1320
- dedent: {
1321
- /**
1322
- * Remove leading minimum indentation from the string.
1323
- * The first line of the string must be empty.
1324
- *
1325
- * https://github.com/tc39/proposal-string-dedent
1326
- */
1327
- (input: string): string;
1328
-
1329
- /**
1330
- * Remove leading minimum indentation from the template literal.
1331
- * The first line of the string must be empty.
1332
- *
1333
- * https://github.com/tc39/proposal-string-dedent
1334
- */
1335
- (
1336
- strings: readonly string[] | ArrayLike<string>,
1337
- ...substitutions: any[]
1338
- ): string;
1339
-
1340
- /**
1341
- * Wrap another template tag function such that tagged literals
1342
- * become dedented before being passed to the wrapped function.
1343
- *
1344
- * https://www.npmjs.com/package/string-dedent#usage
1345
- */
1346
- <
1347
- Func extends (
1348
- strings: readonly string[] | ArrayLike<string>,
1349
- ...substitutions: any[]
1350
- ) => string
1351
- >(
1352
- input: Func
1353
- ): Func;
1354
- };
1355
- }