yavascript 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/aarch64-apple-darwin/yavascript +0 -0
- package/bin/aarch64-apple-darwin/yavascript-bootstrap +0 -0
- package/bin/aarch64-unknown-linux-gnu/yavascript +0 -0
- package/bin/aarch64-unknown-linux-gnu/yavascript-bootstrap +0 -0
- package/bin/aarch64-unknown-linux-musl/yavascript +0 -0
- package/bin/aarch64-unknown-linux-musl/yavascript-bootstrap +0 -0
- package/bin/aarch64-unknown-linux-static/yavascript +0 -0
- package/bin/aarch64-unknown-linux-static/yavascript-bootstrap +0 -0
- package/bin/x86_64-apple-darwin/yavascript +0 -0
- package/bin/x86_64-apple-darwin/yavascript-bootstrap +0 -0
- package/bin/x86_64-pc-windows-static/yavascript-bootstrap.exe +0 -0
- package/bin/x86_64-pc-windows-static/yavascript.exe +0 -0
- package/bin/x86_64-unknown-linux-gnu/yavascript +0 -0
- package/bin/x86_64-unknown-linux-gnu/yavascript-bootstrap +0 -0
- package/bin/x86_64-unknown-linux-musl/yavascript +0 -0
- package/bin/x86_64-unknown-linux-musl/yavascript-bootstrap +0 -0
- package/bin/x86_64-unknown-linux-static/yavascript +0 -0
- package/bin/x86_64-unknown-linux-static/yavascript-bootstrap +0 -0
- package/dist/index-arm64.js +82233 -0
- package/dist/index-x86_64.js +82233 -0
- package/dist/primordials-arm64.js +81082 -0
- package/dist/primordials-x86_64.js +81082 -0
- package/package.json +1 -1
- package/yavascript.d.ts +796 -382
package/yavascript.d.ts
CHANGED
|
@@ -99,6 +99,11 @@ declare const yavascript: {
|
|
|
99
99
|
options?: { filename?: string; expression?: boolean }
|
|
100
100
|
): string;
|
|
101
101
|
|
|
102
|
+
civet(
|
|
103
|
+
code: string,
|
|
104
|
+
options?: { filename?: string; expression?: boolean }
|
|
105
|
+
): string;
|
|
106
|
+
|
|
102
107
|
autodetect(
|
|
103
108
|
code: string,
|
|
104
109
|
options?: { filename?: string; expression?: boolean }
|
|
@@ -128,19 +133,10 @@ declare const env: { [key: string]: string | undefined };
|
|
|
128
133
|
* Anything that appears after `--` is considered a positional argument instead
|
|
129
134
|
* of a flag. `--` is not present in the returned positional arguments Array.
|
|
130
135
|
*
|
|
131
|
-
* Single-character flags must have a single leading dash, and multi-character
|
|
132
|
-
* flags must have two leading dashes.
|
|
133
|
-
*
|
|
134
|
-
* Flags with equals signs in them (eg. `--something=42`) are not supported.
|
|
135
|
-
* Write `--something 42` instead.
|
|
136
|
-
*
|
|
137
|
-
* Flags where you specify them multiple times, like `-vvv`, are not supported.
|
|
138
|
-
* Write something like `-v 3` instead.
|
|
139
|
-
*
|
|
140
136
|
* @param hints - An object whose keys are flag names (in camelCase) and whose values indicate what type to treat that flag as. Valid property values are `String`, `Boolean`, `Number`, and `Path`. `Path` will resolve relative paths into absolute paths for you. If no hints object is specified, `parseScriptArgs` will do its best to guess, based on the command-line args.
|
|
141
137
|
* @param argv - An array containing the command line flags you want to parse. If unspecified, `scriptArgs.slice(2)` will be used (we slice 2 in order to skip the yavascript binary and script name). If you pass in an array here, it should only contain command-line flags, not the binary being called.
|
|
142
138
|
*
|
|
143
|
-
* @returns An object with
|
|
139
|
+
* @returns An object with three properties: `flags`, `args`, and `metadata`. `flags` is an object whose keys are camelCase flag names and whose values are strings, booleans, numbers, or `Path`s corresponding to the input command-line args. `args` is an Array of positional arguments, as found on the command-line. `metadata` contains information about what name and type the flags got mapped to.
|
|
144
140
|
*/
|
|
145
141
|
declare function parseScriptArgs(
|
|
146
142
|
hints?: {
|
|
@@ -150,6 +146,17 @@ declare function parseScriptArgs(
|
|
|
150
146
|
): {
|
|
151
147
|
flags: { [key: string]: any };
|
|
152
148
|
args: Array<string>;
|
|
149
|
+
metadata: {
|
|
150
|
+
keys: {
|
|
151
|
+
[key: string]: string | undefined;
|
|
152
|
+
};
|
|
153
|
+
hints: {
|
|
154
|
+
[key: string]: string | undefined;
|
|
155
|
+
};
|
|
156
|
+
guesses: {
|
|
157
|
+
[key: string]: string | undefined;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
153
160
|
};
|
|
154
161
|
|
|
155
162
|
/**
|
|
@@ -187,6 +194,11 @@ declare function writeFile(
|
|
|
187
194
|
data: string | ArrayBuffer
|
|
188
195
|
): void;
|
|
189
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Function which returns true if the path points to a regular file.
|
|
199
|
+
*/
|
|
200
|
+
declare function isFile(path: string | Path): boolean;
|
|
201
|
+
|
|
190
202
|
/**
|
|
191
203
|
* Function which returns true if the path points to a directory, or if the
|
|
192
204
|
* path points to a symlink which points to a directory. Otherwise, it returns
|
|
@@ -199,6 +211,28 @@ declare function isDir(path: string | Path): boolean;
|
|
|
199
211
|
*/
|
|
200
212
|
declare function isLink(path: string | Path): boolean;
|
|
201
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Returns true if the resource at the provided path can be executed by the
|
|
216
|
+
* current user.
|
|
217
|
+
*
|
|
218
|
+
* If nothing exists at that path, an error will be thrown.
|
|
219
|
+
*/
|
|
220
|
+
declare function isExecutable(path: string | Path): boolean;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Returns true if the resource at the provided path can be read by the current
|
|
224
|
+
* user.
|
|
225
|
+
*
|
|
226
|
+
* If nothing exists at that path, an error will be thrown.
|
|
227
|
+
*/
|
|
228
|
+
declare function isReadable(path: string | Path): boolean;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Returns true if a resource at the provided path could be written to by the
|
|
232
|
+
* current user.
|
|
233
|
+
*/
|
|
234
|
+
declare function isWritable(path: string | Path): boolean;
|
|
235
|
+
|
|
202
236
|
/**
|
|
203
237
|
* Delete the file or directory at the specified path.
|
|
204
238
|
*
|
|
@@ -278,6 +312,14 @@ declare class Path {
|
|
|
278
312
|
*/
|
|
279
313
|
static readonly OS_ENV_VAR_SEPARATOR: ":" | ";";
|
|
280
314
|
|
|
315
|
+
/**
|
|
316
|
+
* A list of suffixes that could appear in the filename for a program on the
|
|
317
|
+
* current OS. For instance, on Windows, programs often end with ".exe".
|
|
318
|
+
*
|
|
319
|
+
* On Unix-like OSes, this is empty, On Windows, it's based on `env.PATHEXT`.
|
|
320
|
+
*/
|
|
321
|
+
static readonly OS_PROGRAM_EXTENSIONS: ReadonlySet<string>;
|
|
322
|
+
|
|
281
323
|
/** Split one or more path strings into an array of path segments. */
|
|
282
324
|
static splitToSegments(inputParts: Array<string> | string): Array<string>;
|
|
283
325
|
|
|
@@ -293,16 +335,14 @@ declare class Path {
|
|
|
293
335
|
): string | Fallback;
|
|
294
336
|
|
|
295
337
|
/** Join together one or more paths. */
|
|
296
|
-
static join(...inputs: Array<string | Path | Array<string | Path>>):
|
|
338
|
+
static join(...inputs: Array<string | Path | Array<string | Path>>): Path;
|
|
297
339
|
|
|
298
340
|
/**
|
|
299
341
|
* Turns the input path(s) into an absolute path by resolving all `.` and `..`
|
|
300
342
|
* segments, using `pwd()` as a base dir to use when resolving leading `.` or
|
|
301
343
|
* `..` segments.
|
|
302
344
|
*/
|
|
303
|
-
static resolve(
|
|
304
|
-
...inputs: Array<string | Path | Array<string | Path>>
|
|
305
|
-
): string;
|
|
345
|
+
static resolve(...inputs: Array<string | Path | Array<string | Path>>): Path;
|
|
306
346
|
|
|
307
347
|
/**
|
|
308
348
|
* Concatenates the input path(s) and then resolves all non-leading `.` and
|
|
@@ -310,7 +350,7 @@ declare class Path {
|
|
|
310
350
|
*/
|
|
311
351
|
static normalize(
|
|
312
352
|
...inputs: Array<string | Path | Array<string | Path>>
|
|
313
|
-
):
|
|
353
|
+
): Path;
|
|
314
354
|
|
|
315
355
|
/**
|
|
316
356
|
* Return whether the provided path is absolute; that is, whether it
|
|
@@ -318,18 +358,6 @@ declare class Path {
|
|
|
318
358
|
*/
|
|
319
359
|
static isAbsolute(path: string | Path): boolean;
|
|
320
360
|
|
|
321
|
-
/** A tagged template literal function that creates a `Path` object. */
|
|
322
|
-
static tag(
|
|
323
|
-
strings: TemplateStringsArray,
|
|
324
|
-
...values: ReadonlyArray<string | Path | Array<string | Path>>
|
|
325
|
-
): Path;
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Returns a tagged template literal that creates a `Path` object. `dir` is
|
|
329
|
-
* used as a prefix for every `Path` object created.
|
|
330
|
-
*/
|
|
331
|
-
static tagUsingBase(dir: string | Path): typeof Path.tag;
|
|
332
|
-
|
|
333
361
|
/**
|
|
334
362
|
* An array of the path segments that make up this path.
|
|
335
363
|
*
|
|
@@ -353,13 +381,11 @@ declare class Path {
|
|
|
353
381
|
static from(segments: Array<string>, separator: string): Path;
|
|
354
382
|
|
|
355
383
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
* If `from` is unspecified, it defaults to `pwd()`.
|
|
384
|
+
* Create an absolute path by `concat`ting `subpaths` onto this Path (which is
|
|
385
|
+
* presumed to be an absolute path) and then using `normalize()` on the
|
|
386
|
+
* result. If the result is not an absolute path, an error will be thrown.
|
|
361
387
|
*/
|
|
362
|
-
resolve(
|
|
388
|
+
resolve(...subpaths: Array<string | Path>): Path;
|
|
363
389
|
|
|
364
390
|
/**
|
|
365
391
|
* Resolve all non-leading `.` and `..` segments in this path.
|
|
@@ -367,21 +393,22 @@ declare class Path {
|
|
|
367
393
|
normalize(): Path;
|
|
368
394
|
|
|
369
395
|
/**
|
|
370
|
-
* Create a new
|
|
371
|
-
* segments.
|
|
396
|
+
* Create a new Path by appending additional path segments onto the end of
|
|
397
|
+
* this Path's segments.
|
|
372
398
|
*
|
|
373
399
|
* The returned path will use this path's separator.
|
|
374
400
|
*/
|
|
375
|
-
concat(other: string | Path | Array<string | Path
|
|
401
|
+
concat(...other: Array<string | Path | Array<string | Path>>): Path;
|
|
376
402
|
|
|
377
403
|
/**
|
|
378
404
|
* Return whether this path is absolute; that is, whether it starts with
|
|
379
|
-
* either
|
|
405
|
+
* either `/`, `\`, or a drive letter (ie `C:`).
|
|
380
406
|
*/
|
|
381
407
|
isAbsolute(): boolean;
|
|
382
408
|
|
|
383
409
|
/**
|
|
384
|
-
* Make a second Path object containing the same
|
|
410
|
+
* Make a second Path object containing the same segments and separator as
|
|
411
|
+
* this one.
|
|
385
412
|
*/
|
|
386
413
|
clone(): this;
|
|
387
414
|
|
|
@@ -408,9 +435,116 @@ declare class Path {
|
|
|
408
435
|
toString(): string;
|
|
409
436
|
|
|
410
437
|
/**
|
|
411
|
-
* Alias for `toString`; causes Path objects to be serialized as strings
|
|
438
|
+
* Alias for `toString`; causes Path objects to be serialized as strings when
|
|
439
|
+
* they (or an object referencing them) are passed into JSON.stringify.
|
|
412
440
|
*/
|
|
413
441
|
toJSON(): string;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Return the final path segment of this path. If this path has no path
|
|
445
|
+
* segments, the empty string is returned.
|
|
446
|
+
*/
|
|
447
|
+
basename(): string;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Return the trailing extension of this path. The `options` parameter works
|
|
451
|
+
* the same as the global `extname`'s `options` parameter.
|
|
452
|
+
*/
|
|
453
|
+
extname(options?: { full?: boolean }): string;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Return whether this path starts with the provided value, by comparing one
|
|
457
|
+
* path segment at a time.
|
|
458
|
+
*
|
|
459
|
+
* The starting segments of this path must *exactly* match the segments in the
|
|
460
|
+
* provided value.
|
|
461
|
+
*
|
|
462
|
+
* This means that, given two Paths A and B:
|
|
463
|
+
*
|
|
464
|
+
* ```
|
|
465
|
+
* A: Path { /home/user/.config }
|
|
466
|
+
* B: Path { /home/user/.config2 }
|
|
467
|
+
* ```
|
|
468
|
+
*
|
|
469
|
+
* Path B does *not* start with Path A, because `".config" !== ".config2"`.
|
|
470
|
+
*/
|
|
471
|
+
startsWith(value: string | Path | Array<string | Path>): boolean;
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Return whether this path ends with the provided value, by comparing one
|
|
475
|
+
* path segment at a time.
|
|
476
|
+
*
|
|
477
|
+
* The ending segments of this path must *exactly* match the segments in the
|
|
478
|
+
* provided value.
|
|
479
|
+
*
|
|
480
|
+
* This means that, given two Paths A and B:
|
|
481
|
+
*
|
|
482
|
+
* ```
|
|
483
|
+
* A: Path { /home/1user/.config }
|
|
484
|
+
* B: Path { user/.config }
|
|
485
|
+
* ```
|
|
486
|
+
*
|
|
487
|
+
* Path A does *not* end with Path B, because `"1user" !== "user"`.
|
|
488
|
+
*/
|
|
489
|
+
endsWith(value: string | Path | Array<string | Path>): boolean;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Return the path segment index at which `value` appears in this path, or
|
|
493
|
+
* `-1` if it doesn't appear in this path.
|
|
494
|
+
*
|
|
495
|
+
* @param value - The value to search for. If the value contains more than one path segment, the returned index will refer to the location of the value's first path segment.
|
|
496
|
+
* @param fromIndex - The index into this path's segments to begin searching at. Defaults to `0`.
|
|
497
|
+
*/
|
|
498
|
+
indexOf(
|
|
499
|
+
value: string | Path | Array<string | Path>,
|
|
500
|
+
fromIndex?: number | undefined
|
|
501
|
+
): number;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Return whether `value` appears in this path.
|
|
505
|
+
*
|
|
506
|
+
* @param value - The value to search for.
|
|
507
|
+
* @param fromIndex - The index into this path's segments to begin searching at. Defaults to `0`.
|
|
508
|
+
*/
|
|
509
|
+
includes(
|
|
510
|
+
value: string | Path | Array<string | Path>,
|
|
511
|
+
fromIndex?: number | undefined
|
|
512
|
+
): boolean;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Return a new Path wherein the segments in `value` have been replaced with
|
|
516
|
+
* the segments in `replacement`. If the segments in `value` are not present
|
|
517
|
+
* in this path, a clone of this path is returned.
|
|
518
|
+
*
|
|
519
|
+
* Note that only the first match is replaced.
|
|
520
|
+
*
|
|
521
|
+
* @param value - What should be replaced
|
|
522
|
+
* @param replacement - What it should be replaced with
|
|
523
|
+
*/
|
|
524
|
+
replace(
|
|
525
|
+
value: string | Path | Array<string | Path>,
|
|
526
|
+
replacement: string | Path | Array<string | Path>
|
|
527
|
+
): Path;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Return a new Path wherein all occurrences of the segments in `value` have
|
|
531
|
+
* been replaced with the segments in `replacement`. If the segments in
|
|
532
|
+
* `value` are not present in this path, a clone of this path is returned.
|
|
533
|
+
*
|
|
534
|
+
* @param value - What should be replaced
|
|
535
|
+
* @param replacement - What it should be replaced with
|
|
536
|
+
*/
|
|
537
|
+
replaceAll(
|
|
538
|
+
value: string | Path | Array<string | Path>,
|
|
539
|
+
replacement: string | Path | Array<string | Path>
|
|
540
|
+
): Path;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Return a copy of this path but with the final segment replaced with `replacement`
|
|
544
|
+
*
|
|
545
|
+
* @param replacement - The new final segment(s) for the returned Path
|
|
546
|
+
*/
|
|
547
|
+
replaceLast(replacement: string | Path | Array<string | Path>): Path;
|
|
414
548
|
}
|
|
415
549
|
|
|
416
550
|
/**
|
|
@@ -435,8 +569,7 @@ declare var __dirname: string;
|
|
|
435
569
|
declare function basename(path: string | Path): string;
|
|
436
570
|
|
|
437
571
|
/**
|
|
438
|
-
*
|
|
439
|
-
* print that string to stdout, then return it.
|
|
572
|
+
* Reads the contents of one of more files from disk as one UTF-8 string.
|
|
440
573
|
*/
|
|
441
574
|
declare function cat(...paths: Array<string | Path>): string;
|
|
442
575
|
|
|
@@ -497,7 +630,7 @@ declare function chmod(
|
|
|
497
630
|
*
|
|
498
631
|
* Provides the same functionality as the unix binary of the same name.
|
|
499
632
|
*/
|
|
500
|
-
declare function dirname(path: string | Path):
|
|
633
|
+
declare function dirname(path: string | Path): Path;
|
|
501
634
|
|
|
502
635
|
/**
|
|
503
636
|
* Print one or more values to stdout.
|
|
@@ -519,14 +652,8 @@ declare function extname(
|
|
|
519
652
|
/**
|
|
520
653
|
* Returns the contents of a directory, as absolute paths. `.` and `..` are
|
|
521
654
|
* omitted.
|
|
522
|
-
*
|
|
523
|
-
* Use the `relativePaths` option to get relative paths instead (relative to
|
|
524
|
-
* the parent directory).
|
|
525
655
|
*/
|
|
526
|
-
declare function ls(
|
|
527
|
-
dir?: string | Path,
|
|
528
|
-
options?: { relativePaths?: boolean }
|
|
529
|
-
): Array<string>;
|
|
656
|
+
declare function ls(dir?: string | Path): Array<Path>;
|
|
530
657
|
|
|
531
658
|
/**
|
|
532
659
|
* Print data to stdout using C-style format specifiers.
|
|
@@ -542,7 +669,20 @@ declare function printf(format: string, ...args: Array<any>): void;
|
|
|
542
669
|
*
|
|
543
670
|
* Provides the same functionality as the shell builtin of the same name.
|
|
544
671
|
*/
|
|
545
|
-
declare
|
|
672
|
+
declare const pwd: {
|
|
673
|
+
/**
|
|
674
|
+
* Returns the process's current working directory.
|
|
675
|
+
*
|
|
676
|
+
* Provides the same functionality as the shell builtin of the same name.
|
|
677
|
+
*/
|
|
678
|
+
(): Path;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* A frozen, read-only `Path` object containing what `pwd()` was when
|
|
682
|
+
* yavascript first started up.
|
|
683
|
+
*/
|
|
684
|
+
readonly initial: Path;
|
|
685
|
+
};
|
|
546
686
|
|
|
547
687
|
/**
|
|
548
688
|
* Reads a symlink.
|
|
@@ -551,7 +691,7 @@ declare function pwd(): string;
|
|
|
551
691
|
*
|
|
552
692
|
* Provides the same functionality as the unix binary of the same name.
|
|
553
693
|
*/
|
|
554
|
-
declare function readlink(path: string | Path):
|
|
694
|
+
declare function readlink(path: string | Path): Path;
|
|
555
695
|
|
|
556
696
|
/**
|
|
557
697
|
* Get the absolute path given a relative path. Symlinks are also resolved.
|
|
@@ -560,7 +700,41 @@ declare function readlink(path: string | Path): string;
|
|
|
560
700
|
*
|
|
561
701
|
* Provides the same functionality as the unix binary of the same name.
|
|
562
702
|
*/
|
|
563
|
-
declare function realpath(path: string | Path):
|
|
703
|
+
declare function realpath(path: string | Path): Path;
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Blocks the current thread for at least the specified number of milliseconds,
|
|
707
|
+
* or maybe a tiny bit longer.
|
|
708
|
+
*
|
|
709
|
+
* alias for `sleep.sync`.
|
|
710
|
+
*/
|
|
711
|
+
declare var sleep: {
|
|
712
|
+
/**
|
|
713
|
+
* Blocks the current thread for at least the specified number of milliseconds,
|
|
714
|
+
* or maybe a tiny bit longer.
|
|
715
|
+
*
|
|
716
|
+
* alias for `sleep.sync`.
|
|
717
|
+
*
|
|
718
|
+
* @param milliseconds - The number of milliseconds to block for.
|
|
719
|
+
*/
|
|
720
|
+
(milliseconds: number): void;
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Blocks the current thread for at least the specified number of milliseconds,
|
|
724
|
+
* or maybe a tiny bit longer.
|
|
725
|
+
*
|
|
726
|
+
* @param milliseconds - The number of milliseconds to block for.
|
|
727
|
+
*/
|
|
728
|
+
sync(milliseconds: number): void;
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Returns a Promise which resolves in at least the specified number of
|
|
732
|
+
* milliseconds, maybe a little longer.
|
|
733
|
+
*
|
|
734
|
+
* @param milliseconds - The number of milliseconds to wait before the returned Promise should be resolved.
|
|
735
|
+
*/
|
|
736
|
+
async(milliseconds: number): Promise<void>;
|
|
737
|
+
};
|
|
564
738
|
|
|
565
739
|
/**
|
|
566
740
|
* If the file at `path` exists, update its creation/modification timestamps.
|
|
@@ -571,6 +745,26 @@ declare function realpath(path: string | Path): string;
|
|
|
571
745
|
*/
|
|
572
746
|
declare function touch(path: string | Path): void;
|
|
573
747
|
|
|
748
|
+
/**
|
|
749
|
+
* Searches the system for the path to a program named `binaryName`.
|
|
750
|
+
*
|
|
751
|
+
* If the program can't be found, `null` is returned.
|
|
752
|
+
*
|
|
753
|
+
* @param binaryName The program to search for
|
|
754
|
+
* @param options Options which affect how the search is performed
|
|
755
|
+
* @param options.searchPaths A list of folders where programs may be found. Defaults to `env.PATH?.split(Path.OS_ENV_VAR_SEPARATOR) || []`.
|
|
756
|
+
* @param options.suffixes A list of filename extension suffixes to include in the search, ie [".exe"]. Defaults to `Path.OS_PROGRAM_EXTENSIONS`.
|
|
757
|
+
* @param options.trace A logging function that will be called at various times during the execution of `which`. Defaults to `traceAll.getDefaultTrace()`.
|
|
758
|
+
*/
|
|
759
|
+
declare function which(
|
|
760
|
+
binaryName: string,
|
|
761
|
+
options?: {
|
|
762
|
+
searchPaths?: Array<Path | string>;
|
|
763
|
+
suffixes?: Array<string>;
|
|
764
|
+
trace?: (...args: Array<any>) => void;
|
|
765
|
+
}
|
|
766
|
+
): Path | null;
|
|
767
|
+
|
|
574
768
|
declare type BaseExecOptions = {
|
|
575
769
|
/** Sets the current working directory for the child process. */
|
|
576
770
|
cwd?: string | Path;
|
|
@@ -598,53 +792,27 @@ declare type BaseExecOptions = {
|
|
|
598
792
|
failOnNonZeroStatus?: boolean;
|
|
599
793
|
|
|
600
794
|
/**
|
|
601
|
-
* If true, stdout and stderr will be collected into strings
|
|
602
|
-
* instead of being printed to the screen.
|
|
795
|
+
* If true, stdout and stderr will be collected into strings or array buffers
|
|
796
|
+
* and returned instead of being printed to the screen.
|
|
603
797
|
*
|
|
604
|
-
* Defaults to false.
|
|
798
|
+
* Defaults to false. true is an alias for "utf8".
|
|
605
799
|
*/
|
|
606
|
-
captureOutput?: boolean;
|
|
800
|
+
captureOutput?: boolean | "utf8" | "arraybuffer";
|
|
607
801
|
};
|
|
608
802
|
|
|
609
803
|
declare interface Exec {
|
|
610
|
-
(args: Array<string> | string, options?: BaseExecOptions): void;
|
|
611
|
-
|
|
612
804
|
(
|
|
613
|
-
args: Array<string> | string,
|
|
805
|
+
args: Array<string | Path | number> | string | Path,
|
|
614
806
|
options: BaseExecOptions & {
|
|
615
|
-
/**
|
|
616
|
-
* Whether an Error should be thrown when the process exits with a nonzero
|
|
617
|
-
* status code.
|
|
618
|
-
*
|
|
619
|
-
* Defaults to true.
|
|
620
|
-
*/
|
|
621
807
|
failOnNonZeroStatus: true;
|
|
622
|
-
/**
|
|
623
|
-
* If true, stdout and stderr will be collected into strings and returned
|
|
624
|
-
* instead of being printed to the screen.
|
|
625
|
-
*
|
|
626
|
-
* Defaults to false.
|
|
627
|
-
*/
|
|
628
808
|
captureOutput: false;
|
|
629
809
|
}
|
|
630
810
|
): void;
|
|
631
811
|
|
|
632
812
|
(
|
|
633
|
-
args: Array<string> | string,
|
|
813
|
+
args: Array<string | Path | number> | string | Path,
|
|
634
814
|
options: BaseExecOptions & {
|
|
635
|
-
/**
|
|
636
|
-
* Whether an Error should be thrown when the process exits with a nonzero
|
|
637
|
-
* status code.
|
|
638
|
-
*
|
|
639
|
-
* Defaults to true.
|
|
640
|
-
*/
|
|
641
815
|
failOnNonZeroStatus: false;
|
|
642
|
-
/**
|
|
643
|
-
* If true, stdout and stderr will be collected into strings and returned
|
|
644
|
-
* instead of being printed to the screen.
|
|
645
|
-
*
|
|
646
|
-
* Defaults to false.
|
|
647
|
-
*/
|
|
648
816
|
captureOutput: false;
|
|
649
817
|
}
|
|
650
818
|
):
|
|
@@ -652,27 +820,79 @@ declare interface Exec {
|
|
|
652
820
|
| { status: undefined; signal: number };
|
|
653
821
|
|
|
654
822
|
(
|
|
655
|
-
args: Array<string> | string,
|
|
823
|
+
args: Array<string | Path | number> | string | Path,
|
|
824
|
+
options: BaseExecOptions & {
|
|
825
|
+
failOnNonZeroStatus: true;
|
|
826
|
+
captureOutput: true;
|
|
827
|
+
}
|
|
828
|
+
): { stdout: string; stderr: string };
|
|
829
|
+
|
|
830
|
+
(
|
|
831
|
+
args: Array<string | Path | number> | string | Path,
|
|
832
|
+
options: BaseExecOptions & {
|
|
833
|
+
failOnNonZeroStatus: true;
|
|
834
|
+
captureOutput: "utf8";
|
|
835
|
+
}
|
|
836
|
+
): { stdout: string; stderr: string };
|
|
837
|
+
|
|
838
|
+
(
|
|
839
|
+
args: Array<string | Path | number> | string | Path,
|
|
840
|
+
options: BaseExecOptions & {
|
|
841
|
+
failOnNonZeroStatus: true;
|
|
842
|
+
captureOutput: "arraybuffer";
|
|
843
|
+
}
|
|
844
|
+
): { stdout: ArrayBuffer; stderr: ArrayBuffer };
|
|
845
|
+
|
|
846
|
+
(
|
|
847
|
+
args: Array<string | Path | number> | string | Path,
|
|
848
|
+
options: BaseExecOptions & {
|
|
849
|
+
failOnNonZeroStatus: false;
|
|
850
|
+
captureOutput: true;
|
|
851
|
+
}
|
|
852
|
+
):
|
|
853
|
+
| { stdout: string; stderr: string; status: number; signal: undefined }
|
|
854
|
+
| { stdout: string; stderr: string; status: undefined; signal: number };
|
|
855
|
+
|
|
856
|
+
(
|
|
857
|
+
args: Array<string | Path | number> | string | Path,
|
|
858
|
+
options: BaseExecOptions & {
|
|
859
|
+
failOnNonZeroStatus: false;
|
|
860
|
+
captureOutput: "utf-8";
|
|
861
|
+
}
|
|
862
|
+
):
|
|
863
|
+
| { stdout: string; stderr: string; status: number; signal: undefined }
|
|
864
|
+
| { stdout: string; stderr: string; status: undefined; signal: number };
|
|
865
|
+
|
|
866
|
+
(
|
|
867
|
+
args: Array<string | Path | number> | string | Path,
|
|
868
|
+
options: BaseExecOptions & {
|
|
869
|
+
failOnNonZeroStatus: false;
|
|
870
|
+
captureOutput: "arraybuffer";
|
|
871
|
+
}
|
|
872
|
+
):
|
|
873
|
+
| {
|
|
874
|
+
stdout: ArrayBuffer;
|
|
875
|
+
stderr: ArrayBuffer;
|
|
876
|
+
status: number;
|
|
877
|
+
signal: undefined;
|
|
878
|
+
}
|
|
879
|
+
| {
|
|
880
|
+
stdout: ArrayBuffer;
|
|
881
|
+
stderr: ArrayBuffer;
|
|
882
|
+
status: undefined;
|
|
883
|
+
signal: number;
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
(
|
|
887
|
+
args: Array<string | Path | number> | string | Path,
|
|
656
888
|
options: BaseExecOptions & {
|
|
657
|
-
/**
|
|
658
|
-
* Whether an Error should be thrown when the process exits with a nonzero
|
|
659
|
-
* status code.
|
|
660
|
-
*
|
|
661
|
-
* Defaults to true.
|
|
662
|
-
*/
|
|
663
889
|
failOnNonZeroStatus: true;
|
|
664
890
|
}
|
|
665
891
|
): void;
|
|
666
892
|
|
|
667
893
|
(
|
|
668
|
-
args: Array<string> | string,
|
|
894
|
+
args: Array<string | Path | number> | string | Path,
|
|
669
895
|
options: BaseExecOptions & {
|
|
670
|
-
/**
|
|
671
|
-
* Whether an Error should be thrown when the process exits with a nonzero
|
|
672
|
-
* status code.
|
|
673
|
-
*
|
|
674
|
-
* Defaults to true.
|
|
675
|
-
*/
|
|
676
896
|
failOnNonZeroStatus: false;
|
|
677
897
|
}
|
|
678
898
|
):
|
|
@@ -680,73 +900,54 @@ declare interface Exec {
|
|
|
680
900
|
| { status: undefined; signal: number };
|
|
681
901
|
|
|
682
902
|
(
|
|
683
|
-
args: Array<string> | string,
|
|
903
|
+
args: Array<string | Path | number> | string | Path,
|
|
684
904
|
options: BaseExecOptions & {
|
|
685
|
-
/**
|
|
686
|
-
* Whether an Error should be thrown when the process exits with a nonzero
|
|
687
|
-
* status code.
|
|
688
|
-
*
|
|
689
|
-
* Defaults to true.
|
|
690
|
-
*/
|
|
691
|
-
failOnNonZeroStatus: true;
|
|
692
|
-
/**
|
|
693
|
-
* If true, stdout and stderr will be collected into strings and returned
|
|
694
|
-
* instead of being printed to the screen.
|
|
695
|
-
*
|
|
696
|
-
* Defaults to false.
|
|
697
|
-
*/
|
|
698
905
|
captureOutput: true;
|
|
699
906
|
}
|
|
700
907
|
): { stdout: string; stderr: string };
|
|
701
908
|
|
|
702
909
|
(
|
|
703
|
-
args: Array<string> | string,
|
|
910
|
+
args: Array<string | Path | number> | string | Path,
|
|
704
911
|
options: BaseExecOptions & {
|
|
705
|
-
|
|
706
|
-
* If true, stdout and stderr will be collected into strings and returned
|
|
707
|
-
* instead of being printed to the screen.
|
|
708
|
-
*
|
|
709
|
-
* Defaults to false.
|
|
710
|
-
*/
|
|
711
|
-
captureOutput: true;
|
|
912
|
+
captureOutput: "utf8";
|
|
712
913
|
}
|
|
713
914
|
): { stdout: string; stderr: string };
|
|
714
915
|
|
|
715
916
|
(
|
|
716
|
-
args: Array<string> | string,
|
|
917
|
+
args: Array<string | Path | number> | string | Path,
|
|
717
918
|
options: BaseExecOptions & {
|
|
718
|
-
|
|
719
|
-
* If true, stdout and stderr will be collected into strings and returned
|
|
720
|
-
* instead of being printed to the screen.
|
|
721
|
-
*
|
|
722
|
-
* Defaults to false.
|
|
723
|
-
*/
|
|
724
|
-
captureOutput: false;
|
|
919
|
+
captureOutput: "arraybuffer";
|
|
725
920
|
}
|
|
726
|
-
):
|
|
921
|
+
): { stdout: ArrayBuffer; stderr: ArrayBuffer };
|
|
727
922
|
|
|
728
923
|
(
|
|
729
|
-
args: Array<string> | string,
|
|
924
|
+
args: Array<string | Path | number> | string | Path,
|
|
730
925
|
options: BaseExecOptions & {
|
|
731
|
-
|
|
732
|
-
* Whether an Error should be thrown when the process exits with a nonzero
|
|
733
|
-
* status code.
|
|
734
|
-
*
|
|
735
|
-
* Defaults to true.
|
|
736
|
-
*/
|
|
737
|
-
failOnNonZeroStatus: false;
|
|
738
|
-
captureOutput: true;
|
|
926
|
+
captureOutput: false;
|
|
739
927
|
}
|
|
740
|
-
):
|
|
741
|
-
|
|
742
|
-
|
|
928
|
+
): void;
|
|
929
|
+
|
|
930
|
+
(
|
|
931
|
+
args: Array<string | Path | number> | string | Path,
|
|
932
|
+
options?: BaseExecOptions
|
|
933
|
+
): void;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Parse the provided value into an array of command-line argument strings,
|
|
937
|
+
* using the same logic that {@link exec} and {@link ChildProcess} use.
|
|
938
|
+
*/
|
|
939
|
+
toArgv(args: Array<string | Path | number> | string | Path): Array<string>;
|
|
743
940
|
}
|
|
744
941
|
|
|
745
|
-
/**
|
|
942
|
+
/**
|
|
943
|
+
* Runs a child process using the provided arguments.
|
|
944
|
+
*
|
|
945
|
+
* The first value in the arguments array is the program to run.
|
|
946
|
+
*/
|
|
746
947
|
declare const exec: Exec;
|
|
747
948
|
|
|
748
949
|
/** Alias for `exec(args, { captureOutput: true })` */
|
|
749
|
-
declare function $(args: Array<string> | string): {
|
|
950
|
+
declare function $(args: Array<string | Path | number> | string | Path): {
|
|
750
951
|
stdout: string;
|
|
751
952
|
stderr: string;
|
|
752
953
|
};
|
|
@@ -760,7 +961,7 @@ declare interface ChildProcess {
|
|
|
760
961
|
args: Array<string>;
|
|
761
962
|
|
|
762
963
|
/** The current working directory for the process. */
|
|
763
|
-
cwd:
|
|
964
|
+
cwd: Path;
|
|
764
965
|
|
|
765
966
|
/** The environment variables for the process. */
|
|
766
967
|
env: { [key: string]: string };
|
|
@@ -802,7 +1003,7 @@ declare interface ChildProcess {
|
|
|
802
1003
|
*/
|
|
803
1004
|
declare type ChildProcessOptions = {
|
|
804
1005
|
/** The current working directory for the process. */
|
|
805
|
-
cwd?: string;
|
|
1006
|
+
cwd?: string | Path;
|
|
806
1007
|
|
|
807
1008
|
/** The environment variables for the process. */
|
|
808
1009
|
env?: { [key: string]: string };
|
|
@@ -836,7 +1037,7 @@ declare interface ChildProcessConstructor {
|
|
|
836
1037
|
* @param options - Options for the process (cwd, env, stdio, etc)
|
|
837
1038
|
*/
|
|
838
1039
|
new (
|
|
839
|
-
args: string | Array<string>,
|
|
1040
|
+
args: string | Path | Array<string | number | Path>,
|
|
840
1041
|
options?: ChildProcessOptions
|
|
841
1042
|
): ChildProcess;
|
|
842
1043
|
|
|
@@ -904,7 +1105,7 @@ declare function stripAnsi(input: string): string;
|
|
|
904
1105
|
/**
|
|
905
1106
|
* Wrap a string in double quotes, and escape any double-quotes inside using `\"`.
|
|
906
1107
|
*/
|
|
907
|
-
declare function quote(input: string): string;
|
|
1108
|
+
declare function quote(input: string | Path): string;
|
|
908
1109
|
|
|
909
1110
|
// Colors
|
|
910
1111
|
|
|
@@ -1026,7 +1227,11 @@ declare const grepString: {
|
|
|
1026
1227
|
str: string,
|
|
1027
1228
|
pattern: string | RegExp,
|
|
1028
1229
|
options: { inverse: true; details: true }
|
|
1029
|
-
): Array<
|
|
1230
|
+
): Array<{
|
|
1231
|
+
lineNumber: number;
|
|
1232
|
+
lineContent: string;
|
|
1233
|
+
matches: RegExpMatchArray;
|
|
1234
|
+
}>;
|
|
1030
1235
|
};
|
|
1031
1236
|
|
|
1032
1237
|
/** Read the content at `path`, split it on newline, and then return lines matching `pattern`. */
|
|
@@ -1092,7 +1297,11 @@ declare const grepFile: {
|
|
|
1092
1297
|
path: string | Path,
|
|
1093
1298
|
pattern: string | RegExp,
|
|
1094
1299
|
options: { inverse: true; details: true }
|
|
1095
|
-
): Array<
|
|
1300
|
+
): Array<{
|
|
1301
|
+
lineNumber: number;
|
|
1302
|
+
lineContent: string;
|
|
1303
|
+
matches: RegExpMatchArray;
|
|
1304
|
+
}>;
|
|
1096
1305
|
};
|
|
1097
1306
|
|
|
1098
1307
|
interface String {
|
|
@@ -1139,7 +1348,11 @@ interface String {
|
|
|
1139
1348
|
(
|
|
1140
1349
|
pattern: string | RegExp,
|
|
1141
1350
|
options: { inverse: true; details: true }
|
|
1142
|
-
): Array<
|
|
1351
|
+
): Array<{
|
|
1352
|
+
lineNumber: number;
|
|
1353
|
+
lineContent: string;
|
|
1354
|
+
matches: RegExpMatchArray;
|
|
1355
|
+
}>;
|
|
1143
1356
|
};
|
|
1144
1357
|
}
|
|
1145
1358
|
|
|
@@ -2491,11 +2704,21 @@ declare const types: {
|
|
|
2491
2704
|
};
|
|
2492
2705
|
};
|
|
2493
2706
|
|
|
2707
|
+
/**
|
|
2708
|
+
* Returns whether `value` is of type `type`. Useful for validating that values have the correct type at runtime, in library functions or etc.
|
|
2709
|
+
*
|
|
2710
|
+
* Run `help(is)` for more info.
|
|
2711
|
+
*/
|
|
2494
2712
|
declare const is: <T extends TypeValidator<any> | CoerceableToTypeValidator>(
|
|
2495
2713
|
value: any,
|
|
2496
2714
|
type: T
|
|
2497
2715
|
) => value is UnwrapTypeFromCoerceableOrValidator<T>;
|
|
2498
2716
|
|
|
2717
|
+
/**
|
|
2718
|
+
* Alias to {@link is}, for Civet, because `is` is a reserved keyword in Civet.
|
|
2719
|
+
*/
|
|
2720
|
+
declare const _is: typeof is;
|
|
2721
|
+
|
|
2499
2722
|
declare const assert: {
|
|
2500
2723
|
/**
|
|
2501
2724
|
* Throws an error if `value` is not truthy.
|
|
@@ -2675,21 +2898,20 @@ declare const startRepl: {
|
|
|
2675
2898
|
*/
|
|
2676
2899
|
declare class GitRepo {
|
|
2677
2900
|
/**
|
|
2678
|
-
* Given a path to a file or folder on disk,
|
|
2679
|
-
*
|
|
2680
|
-
*
|
|
2681
|
-
*
|
|
2682
|
-
* This is done by running `git rev-parse --show-toplevel`.
|
|
2901
|
+
* Given a path to a file or folder on disk, searches upwards through the
|
|
2902
|
+
* directory ancestry to find a `.git` folder, then returns the Path that
|
|
2903
|
+
* contains that `.git` folder. If no `.git` folder is found, an error will be
|
|
2904
|
+
* thrown.
|
|
2683
2905
|
*/
|
|
2684
2906
|
static findRoot(fromPath: string | Path): Path;
|
|
2685
2907
|
|
|
2686
2908
|
/**
|
|
2687
|
-
* Creates a new `
|
|
2909
|
+
* Creates a new `GitRepo` object for the given repo on disk.
|
|
2688
2910
|
*/
|
|
2689
2911
|
constructor(repoDir: string | Path);
|
|
2690
2912
|
|
|
2691
2913
|
/**
|
|
2692
|
-
* The root folder of the git repo that this `
|
|
2914
|
+
* The root folder of the git repo that this `GitRepo` object represents (the
|
|
2693
2915
|
* folder that contains the '.git' folder).
|
|
2694
2916
|
*/
|
|
2695
2917
|
repoDir: Path;
|
|
@@ -2721,15 +2943,16 @@ declare class GitRepo {
|
|
|
2721
2943
|
/**
|
|
2722
2944
|
* Returns whether the provided path is ignored by git.
|
|
2723
2945
|
*
|
|
2724
|
-
* If `path` is an absolute path, it must be a child directory of this
|
|
2946
|
+
* If `path` is an absolute path, it must be a child directory of this GitRepo
|
|
2725
2947
|
* object's `repoDir`, or else an error will be thrown.
|
|
2726
2948
|
*/
|
|
2727
2949
|
isIgnored(path: string | Path): boolean;
|
|
2728
2950
|
}
|
|
2729
2951
|
|
|
2730
2952
|
/**
|
|
2731
|
-
* Configures the default value of `trace` in functions which
|
|
2732
|
-
* as an option
|
|
2953
|
+
* Configures the default value of `trace` in yavascript API functions which
|
|
2954
|
+
* receive `trace` as an option, like {@link which}, {@link exec}, {@link copy}
|
|
2955
|
+
* and {@link glob}.
|
|
2733
2956
|
*
|
|
2734
2957
|
* - If called with `true`, the default value of `trace` in all functions which
|
|
2735
2958
|
* receive a `trace` option will be changed to `console.error`.
|
|
@@ -2738,10 +2961,12 @@ declare class GitRepo {
|
|
|
2738
2961
|
* - If called with any other value, the provided value will be used as the
|
|
2739
2962
|
* default value of `trace` in all functions which receive a `trace` option.
|
|
2740
2963
|
*
|
|
2741
|
-
* If you would like to make your own functions use the default value of
|
|
2742
|
-
*
|
|
2743
|
-
*
|
|
2744
|
-
*
|
|
2964
|
+
* If you would like to make your own functions use the default value of `trace`
|
|
2965
|
+
* as set by this function (in order to get the same behavior as yavascript API
|
|
2966
|
+
* functions which do so), call `traceAll.getDefaultTrace()` to get the current
|
|
2967
|
+
* value which should be used as the default value.
|
|
2968
|
+
*
|
|
2969
|
+
* `traceAll` provides similar functionality to shell builtin `set -x`.
|
|
2745
2970
|
*/
|
|
2746
2971
|
declare const traceAll: ((
|
|
2747
2972
|
trace: boolean | undefined | ((...args: Array<any>) => void)
|
|
@@ -2752,7 +2977,7 @@ declare const traceAll: ((
|
|
|
2752
2977
|
declare namespace JSX {
|
|
2753
2978
|
/**
|
|
2754
2979
|
* A string containing the expression that should be called to create JSX
|
|
2755
|
-
* elements.
|
|
2980
|
+
* elements. yavascript's internals use this string to transpile JSX syntax.
|
|
2756
2981
|
*
|
|
2757
2982
|
* Defaults to "JSX.createElement".
|
|
2758
2983
|
*
|
|
@@ -2772,7 +2997,8 @@ declare namespace JSX {
|
|
|
2772
2997
|
|
|
2773
2998
|
/**
|
|
2774
2999
|
* A string containing the expression that should be used as the first
|
|
2775
|
-
* parameter when creating JSX fragment elements.
|
|
3000
|
+
* parameter when creating JSX fragment elements. yavascript's internals use
|
|
3001
|
+
* this string to transpile JSX syntax.
|
|
2776
3002
|
*
|
|
2777
3003
|
* Defaults to "JSX.Fragment".
|
|
2778
3004
|
*
|
|
@@ -2812,10 +3038,19 @@ declare namespace JSX {
|
|
|
2812
3038
|
export type Fragment = Element<{}, typeof Fragment>;
|
|
2813
3039
|
|
|
2814
3040
|
/**
|
|
2815
|
-
* The JSX element
|
|
3041
|
+
* The JSX element builder function, which gets invoked whenever JSX syntax is
|
|
2816
3042
|
* used (unless {@link JSX.pragma} is changed).
|
|
3043
|
+
*
|
|
3044
|
+
* Note that if you change this, you need to verify that the following
|
|
3045
|
+
* expression always evaluates to `true` (by changing {@link types.JSX.Element}
|
|
3046
|
+
* and {@link types.JSX.Fragment}):
|
|
3047
|
+
* ```jsx
|
|
3048
|
+
* types.JSX.Element(<a />) && types.JSX.Fragment(<></>)
|
|
3049
|
+
* ```
|
|
3050
|
+
*
|
|
3051
|
+
* Failure to uphold this guarantee indicates a bug.
|
|
2817
3052
|
*/
|
|
2818
|
-
export
|
|
3053
|
+
export let createElement: {
|
|
2819
3054
|
<Type extends string | typeof Fragment | ((...args: any) => any)>(
|
|
2820
3055
|
type: Type
|
|
2821
3056
|
): Element<{}, Type>;
|
|
@@ -2966,9 +3201,21 @@ interface ObjectConstructor {
|
|
|
2966
3201
|
isPrimitive(input: any): boolean;
|
|
2967
3202
|
}
|
|
2968
3203
|
|
|
2969
|
-
interface
|
|
3204
|
+
interface StringConstructor {
|
|
2970
3205
|
/**
|
|
2971
|
-
* A
|
|
3206
|
+
* A no-op template literal tag.
|
|
3207
|
+
*
|
|
3208
|
+
* https://github.com/tc39/proposal-string-cooked
|
|
3209
|
+
*/
|
|
3210
|
+
cooked(
|
|
3211
|
+
strings: readonly string[] | ArrayLike<string>,
|
|
3212
|
+
...substitutions: any[]
|
|
3213
|
+
): string;
|
|
3214
|
+
}
|
|
3215
|
+
|
|
3216
|
+
interface SymbolConstructor {
|
|
3217
|
+
/**
|
|
3218
|
+
* A method that changes the result of using the `typeof` operator on the
|
|
2972
3219
|
* object. Called by the semantics of the typeof operator.
|
|
2973
3220
|
*
|
|
2974
3221
|
* Note that the following semantics will come into play when use of the
|
|
@@ -3805,6 +4052,151 @@ interface BigDecimal {
|
|
|
3805
4052
|
// TypeScript will not understand or handle unary/binary operators for BigFloat
|
|
3806
4053
|
// and BigDecimal properly.
|
|
3807
4054
|
|
|
4055
|
+
/** npm: @suchipi/print@2.5.0. License: ISC */
|
|
4056
|
+
/* (with some QuickJS-specific modifications) */
|
|
4057
|
+
|
|
4058
|
+
/*
|
|
4059
|
+
Copyright (c) 2016-2022, John Gardner
|
|
4060
|
+
Copyright (c) 2022 Lily Skye
|
|
4061
|
+
|
|
4062
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4063
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
4064
|
+
copyright notice and this permission notice appear in all copies.
|
|
4065
|
+
|
|
4066
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
4067
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
4068
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
4069
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
4070
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
4071
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
4072
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
4073
|
+
*/
|
|
4074
|
+
|
|
4075
|
+
/**
|
|
4076
|
+
* Options for {@link inspect}.
|
|
4077
|
+
*/
|
|
4078
|
+
declare interface InspectOptions {
|
|
4079
|
+
/** Whether to display non-enumerable properties. Defaults to false. */
|
|
4080
|
+
all?: boolean;
|
|
4081
|
+
|
|
4082
|
+
/** Whether to invoke getter functions. Defaults to false. */
|
|
4083
|
+
followGetters?: boolean;
|
|
4084
|
+
|
|
4085
|
+
/** Whether to display the indexes of iterable entries. Defaults to false. */
|
|
4086
|
+
indexes?: boolean;
|
|
4087
|
+
|
|
4088
|
+
/** Hide object details after 𝑁 recursions. Defaults to Infinity. */
|
|
4089
|
+
maxDepth?: number;
|
|
4090
|
+
|
|
4091
|
+
/** If true, don't identify well-known symbols as `@@…`. Defaults to false. */
|
|
4092
|
+
noAmp?: boolean;
|
|
4093
|
+
|
|
4094
|
+
/** If true, don't format byte-arrays as hexadecimal. Defaults to false. */
|
|
4095
|
+
noHex?: boolean;
|
|
4096
|
+
|
|
4097
|
+
/** If true, don't display function source code. Defaults to false. */
|
|
4098
|
+
noSource?: boolean;
|
|
4099
|
+
|
|
4100
|
+
/** Whether to show `__proto__` properties if possible. Defaults to false. */
|
|
4101
|
+
proto?: boolean;
|
|
4102
|
+
|
|
4103
|
+
/** Whether to sort properties alphabetically. When false, properties are sorted by creation order. Defaults to false. */
|
|
4104
|
+
sort?: boolean;
|
|
4105
|
+
|
|
4106
|
+
/** Options that control whether and how ANSI terminal escape sequences for colours should be added to the output. Defaults to false, meaning no colours. */
|
|
4107
|
+
colours?: boolean | 256 | 8 | InspectColours;
|
|
4108
|
+
|
|
4109
|
+
/** Prefix string to use for indentation. Defaults to '\t'. */
|
|
4110
|
+
indent?: string;
|
|
4111
|
+
}
|
|
4112
|
+
|
|
4113
|
+
declare interface InspectColours {
|
|
4114
|
+
off?: string | number;
|
|
4115
|
+
red?: string | number;
|
|
4116
|
+
grey?: string | number;
|
|
4117
|
+
green?: string | number;
|
|
4118
|
+
darkGreen?: string | number;
|
|
4119
|
+
punct?: string | number;
|
|
4120
|
+
keys?: string | number;
|
|
4121
|
+
keyEscape?: string | number;
|
|
4122
|
+
typeColour?: string | number;
|
|
4123
|
+
primitive?: string | number;
|
|
4124
|
+
escape?: string | number;
|
|
4125
|
+
date?: string | number;
|
|
4126
|
+
hexBorder?: string | number;
|
|
4127
|
+
hexValue?: string | number;
|
|
4128
|
+
hexOffset?: string | number;
|
|
4129
|
+
reference?: string | number;
|
|
4130
|
+
srcBorder?: string | number;
|
|
4131
|
+
srcRowNum?: string | number;
|
|
4132
|
+
srcRowText?: string | number;
|
|
4133
|
+
nul?: string | number;
|
|
4134
|
+
nulProt?: string | number;
|
|
4135
|
+
undef?: string | number;
|
|
4136
|
+
noExts?: string | number;
|
|
4137
|
+
frozen?: string | number;
|
|
4138
|
+
sealed?: string | number;
|
|
4139
|
+
regex?: string | number;
|
|
4140
|
+
string?: string | number;
|
|
4141
|
+
symbol?: string | number;
|
|
4142
|
+
symbolFade?: string | number;
|
|
4143
|
+
braces?: string | number;
|
|
4144
|
+
quotes?: string | number;
|
|
4145
|
+
empty?: string | number;
|
|
4146
|
+
dot?: string | number;
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
declare interface InspectFunction {
|
|
4150
|
+
/**
|
|
4151
|
+
* Generate a human-readable representation of a value.
|
|
4152
|
+
*
|
|
4153
|
+
* @param value - Value to inspect
|
|
4154
|
+
* @param options - Additional settings for refining output
|
|
4155
|
+
* @returns A string representation of `value`.
|
|
4156
|
+
*/
|
|
4157
|
+
(value: any, options?: InspectOptions): string;
|
|
4158
|
+
|
|
4159
|
+
/**
|
|
4160
|
+
* Generate a human-readable representation of a value.
|
|
4161
|
+
*
|
|
4162
|
+
* @param value - Value to inspect
|
|
4163
|
+
* @param key - The value's corresponding member name
|
|
4164
|
+
* @param options - Additional settings for refining output
|
|
4165
|
+
* @returns A string representation of `value`.
|
|
4166
|
+
*/
|
|
4167
|
+
(value: any, key?: string | symbol, options?: InspectOptions): string;
|
|
4168
|
+
|
|
4169
|
+
/**
|
|
4170
|
+
* A symbol which can be used to customize how an object gets printed.
|
|
4171
|
+
*/
|
|
4172
|
+
custom: symbol;
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
/**
|
|
4176
|
+
* Generate a human-readable representation of a value.
|
|
4177
|
+
*
|
|
4178
|
+
* @param value - Value to inspect
|
|
4179
|
+
* @param key - The value's corresponding member name
|
|
4180
|
+
* @param options - Additional settings for refining output
|
|
4181
|
+
* @returns A string representation of `value`.
|
|
4182
|
+
*/
|
|
4183
|
+
declare var inspect: InspectFunction;
|
|
4184
|
+
|
|
4185
|
+
declare interface InspectCustomInputs {
|
|
4186
|
+
key: string | symbol;
|
|
4187
|
+
type: string;
|
|
4188
|
+
brackets: [string, string];
|
|
4189
|
+
oneLine: boolean;
|
|
4190
|
+
linesBefore: Array<string>;
|
|
4191
|
+
linesAfter: Array<string>;
|
|
4192
|
+
propLines: Array<string>;
|
|
4193
|
+
readonly tooDeep: boolean;
|
|
4194
|
+
indent: string;
|
|
4195
|
+
typeSuffix: string;
|
|
4196
|
+
opts: InspectOptions;
|
|
4197
|
+
colours: { [Key in keyof Required<InspectColours>]: string };
|
|
4198
|
+
}
|
|
4199
|
+
|
|
3808
4200
|
// Definitions of the globals and modules added by quickjs-libc
|
|
3809
4201
|
|
|
3810
4202
|
/**
|
|
@@ -3936,54 +4328,42 @@ declare interface FILE {
|
|
|
3936
4328
|
|
|
3937
4329
|
declare module "quickjs:std" {
|
|
3938
4330
|
/**
|
|
3939
|
-
*
|
|
4331
|
+
* Set the exit code that the process should exit with in the future, if it
|
|
4332
|
+
* exits normally.
|
|
3940
4333
|
*
|
|
3941
|
-
*
|
|
3942
|
-
*/
|
|
3943
|
-
export function exit(statusCode: number): void;
|
|
3944
|
-
|
|
3945
|
-
/**
|
|
3946
|
-
* Evaluate the string `code` as a script (global eval).
|
|
4334
|
+
* Can only be called from the main thread.
|
|
3947
4335
|
*
|
|
3948
|
-
*
|
|
3949
|
-
*
|
|
3950
|
-
*
|
|
3951
|
-
*
|
|
3952
|
-
*
|
|
3953
|
-
|
|
3954
|
-
export function evalScript(
|
|
3955
|
-
code: string,
|
|
3956
|
-
options?: { backtraceBarrier?: boolean; filename?: string }
|
|
3957
|
-
): any;
|
|
3958
|
-
|
|
3959
|
-
/**
|
|
3960
|
-
* Evaluate the file `filename` as a script (global eval).
|
|
4336
|
+
* This exit code will only be used if the process exits "normally", ie, when
|
|
4337
|
+
* there are no more pending JS tasks/listeners. If an unhandled exception is
|
|
4338
|
+
* thrown, the process will always exit with status `1`, regardless of the
|
|
4339
|
+
* status code passed to `setExitCode`. If someone calls {@link exit} and
|
|
4340
|
+
* passes in a status code, that status code will take precedence over the
|
|
4341
|
+
* status code passed to `setExitCode`.
|
|
3961
4342
|
*
|
|
3962
|
-
* @param
|
|
3963
|
-
* @returns The result of the evaluation.
|
|
4343
|
+
* @param statusCode The future exit code; 0 for success, nonzero for failure.
|
|
3964
4344
|
*/
|
|
3965
|
-
export function
|
|
4345
|
+
export function setExitCode(statusCode: number): void;
|
|
3966
4346
|
|
|
3967
4347
|
/**
|
|
3968
|
-
*
|
|
4348
|
+
* Return the exit code that was previously set by {@link setExitCode}, or 0 if
|
|
4349
|
+
* it hasn't yet been set.
|
|
3969
4350
|
*
|
|
3970
|
-
*
|
|
3971
|
-
* @param basename - If present and `filename` is a relative path, `filename` will be resolved relative to this basename.
|
|
3972
|
-
* @returns The result of the evaluation (module namespace object).
|
|
4351
|
+
* Can only be called from the main thread.
|
|
3973
4352
|
*/
|
|
3974
|
-
export function
|
|
3975
|
-
filename: string,
|
|
3976
|
-
basename?: string
|
|
3977
|
-
): { [key: string]: any };
|
|
4353
|
+
export function getExitCode(): number;
|
|
3978
4354
|
|
|
3979
4355
|
/**
|
|
3980
|
-
*
|
|
4356
|
+
* Exit the process with the provided status code.
|
|
3981
4357
|
*
|
|
3982
|
-
*
|
|
3983
|
-
*
|
|
3984
|
-
*
|
|
4358
|
+
* Can only be called from the main thread.
|
|
4359
|
+
*
|
|
4360
|
+
* If `statusCode` is not provided, a value previously passed into
|
|
4361
|
+
* {@link setExitCode} will be used. If no value was previously passed into
|
|
4362
|
+
* setExitCode, `0` will be used.
|
|
4363
|
+
*
|
|
4364
|
+
* @param statusCode The exit code; 0 for success, nonzero for failure.
|
|
3985
4365
|
*/
|
|
3986
|
-
export function
|
|
4366
|
+
export function exit(statusCode?: number): never;
|
|
3987
4367
|
|
|
3988
4368
|
/**
|
|
3989
4369
|
* Load the file `filename` and return it as a string assuming UTF-8 encoding.
|
|
@@ -3992,15 +4372,6 @@ declare module "quickjs:std" {
|
|
|
3992
4372
|
*/
|
|
3993
4373
|
export function loadFile(filename: string): string;
|
|
3994
4374
|
|
|
3995
|
-
/**
|
|
3996
|
-
* Read the script of module filename from an active stack frame, then return it as a string.
|
|
3997
|
-
*
|
|
3998
|
-
* If there isn't a valid filename for the specified stack frame, an error will be thrown.
|
|
3999
|
-
*
|
|
4000
|
-
* @param stackLevels - How many levels up the stack to search for a filename. Defaults to 0, which uses the current stack frame.
|
|
4001
|
-
*/
|
|
4002
|
-
export function getFileNameFromStack(stackLevels?: number): string;
|
|
4003
|
-
|
|
4004
4375
|
/**
|
|
4005
4376
|
* Return a boolean indicating whether the provided value is a FILE object.
|
|
4006
4377
|
*
|
|
@@ -4100,6 +4471,38 @@ declare module "quickjs:std" {
|
|
|
4100
4471
|
/** Return an object containing the environment variables as key-value pairs. */
|
|
4101
4472
|
export function getenviron(): { [key: string]: string | undefined };
|
|
4102
4473
|
|
|
4474
|
+
/**
|
|
4475
|
+
* Return the real user ID of the calling process.
|
|
4476
|
+
*
|
|
4477
|
+
* This function throws an error on windows, because windows doesn't support
|
|
4478
|
+
* the same uid/gid paradigm as Unix-like operating systems.
|
|
4479
|
+
*/
|
|
4480
|
+
export function getuid(): number;
|
|
4481
|
+
|
|
4482
|
+
/**
|
|
4483
|
+
* Return the effective user ID of the calling process.
|
|
4484
|
+
*
|
|
4485
|
+
* This function throws an error on windows, because windows doesn't support
|
|
4486
|
+
* the same uid/gid paradigm as Unix-like operating systems.
|
|
4487
|
+
*/
|
|
4488
|
+
export function geteuid(): number;
|
|
4489
|
+
|
|
4490
|
+
/**
|
|
4491
|
+
* Return the real group ID of the calling process.
|
|
4492
|
+
*
|
|
4493
|
+
* This function throws an error on windows, because windows doesn't support
|
|
4494
|
+
* the same uid/gid paradigm as Unix-like operating systems.
|
|
4495
|
+
*/
|
|
4496
|
+
export function getgid(): number;
|
|
4497
|
+
|
|
4498
|
+
/**
|
|
4499
|
+
* Return the effective group ID of the calling process.
|
|
4500
|
+
*
|
|
4501
|
+
* This function throws an error on windows, because windows doesn't support
|
|
4502
|
+
* the same uid/gid paradigm as Unix-like operating systems.
|
|
4503
|
+
*/
|
|
4504
|
+
export function getegid(): number;
|
|
4505
|
+
|
|
4103
4506
|
interface UrlGet {
|
|
4104
4507
|
/**
|
|
4105
4508
|
* Download `url` using the `curl` command line utility. Returns string
|
|
@@ -4217,6 +4620,20 @@ declare module "quickjs:std" {
|
|
|
4217
4620
|
* - octal (0o prefix) and hexadecimal (0x prefix) numbers
|
|
4218
4621
|
*/
|
|
4219
4622
|
export function parseExtJSON(str: string): any;
|
|
4623
|
+
|
|
4624
|
+
/**
|
|
4625
|
+
* A wrapper around the standard C [strftime](https://en.cppreference.com/w/c/chrono/strftime).
|
|
4626
|
+
* Formats a time/date into a format as specified by the user.
|
|
4627
|
+
*
|
|
4628
|
+
* @param maxBytes - The number of bytes to allocate for the string that will be returned
|
|
4629
|
+
* @param format - Format string, using `%`-prefixed sequences as found in [this table](https://en.cppreference.com/w/c/chrono/strftime#Format_string).
|
|
4630
|
+
* @param time - The Date object (or unix timestamp, in ms) to render.
|
|
4631
|
+
*/
|
|
4632
|
+
export function strftime(
|
|
4633
|
+
maxBytes: number,
|
|
4634
|
+
format: string,
|
|
4635
|
+
time: Date | number
|
|
4636
|
+
): string;
|
|
4220
4637
|
}
|
|
4221
4638
|
|
|
4222
4639
|
declare module "quickjs:os" {
|
|
@@ -4805,110 +5222,57 @@ declare module "quickjs:os" {
|
|
|
4805
5222
|
export function chmod(path: string, mode: number): void;
|
|
4806
5223
|
}
|
|
4807
5224
|
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
*/
|
|
4811
|
-
declare interface InspectOptions {
|
|
4812
|
-
/** Whether to display non-enumerable properties. Defaults to false. */
|
|
4813
|
-
all?: boolean;
|
|
4814
|
-
|
|
4815
|
-
/** Whether to invoke getter functions. Defaults to false. */
|
|
4816
|
-
followGetters?: boolean;
|
|
4817
|
-
|
|
4818
|
-
/** Whether to display the indexes of iterable entries. Defaults to false. */
|
|
4819
|
-
indexes?: boolean;
|
|
4820
|
-
|
|
4821
|
-
/** Hide object details after 𝑁 recursions. Defaults to Infinity. */
|
|
4822
|
-
maxDepth?: number;
|
|
4823
|
-
|
|
4824
|
-
/** If true, don't identify well-known symbols as `@@…`. Defaults to false. */
|
|
4825
|
-
noAmp?: boolean;
|
|
4826
|
-
|
|
4827
|
-
/** If true, don't format byte-arrays as hexadecimal. Defaults to false. */
|
|
4828
|
-
noHex?: boolean;
|
|
4829
|
-
|
|
4830
|
-
/** If true, don't display function source code. Defaults to false. */
|
|
4831
|
-
noSource?: boolean;
|
|
4832
|
-
|
|
4833
|
-
/** Whether to show `__proto__` properties if possible. Defaults to false. */
|
|
4834
|
-
proto?: boolean;
|
|
4835
|
-
|
|
4836
|
-
/** Whether to sort properties alphabetically. When false, properties are sorted by creation order. Defaults to false. */
|
|
4837
|
-
sort?: boolean;
|
|
4838
|
-
|
|
4839
|
-
/** Options that control whether and how ANSI terminal escape sequences for colours should be added to the output. Defaults to false, meaning no colours. */
|
|
4840
|
-
colours?: boolean | 256 | 8 | InspectColours;
|
|
5225
|
+
declare var setTimeout: typeof import("quickjs:os").setTimeout;
|
|
5226
|
+
declare var clearTimeout: typeof import("quickjs:os").clearTimeout;
|
|
4841
5227
|
|
|
4842
|
-
|
|
4843
|
-
indent?: string;
|
|
4844
|
-
}
|
|
5228
|
+
declare type Interval = { [Symbol.toStringTag]: "Interval" };
|
|
4845
5229
|
|
|
4846
|
-
declare
|
|
4847
|
-
|
|
4848
|
-
red?: string | number;
|
|
4849
|
-
grey?: string | number;
|
|
4850
|
-
green?: string | number;
|
|
4851
|
-
darkGreen?: string | number;
|
|
4852
|
-
punct?: string | number;
|
|
4853
|
-
keys?: string | number;
|
|
4854
|
-
keyEscape?: string | number;
|
|
4855
|
-
typeColour?: string | number;
|
|
4856
|
-
primitive?: string | number;
|
|
4857
|
-
escape?: string | number;
|
|
4858
|
-
date?: string | number;
|
|
4859
|
-
hexBorder?: string | number;
|
|
4860
|
-
hexValue?: string | number;
|
|
4861
|
-
hexOffset?: string | number;
|
|
4862
|
-
reference?: string | number;
|
|
4863
|
-
srcBorder?: string | number;
|
|
4864
|
-
srcRowNum?: string | number;
|
|
4865
|
-
srcRowText?: string | number;
|
|
4866
|
-
nul?: string | number;
|
|
4867
|
-
nulProt?: string | number;
|
|
4868
|
-
undef?: string | number;
|
|
4869
|
-
noExts?: string | number;
|
|
4870
|
-
frozen?: string | number;
|
|
4871
|
-
sealed?: string | number;
|
|
4872
|
-
regex?: string | number;
|
|
4873
|
-
string?: string | number;
|
|
4874
|
-
symbol?: string | number;
|
|
4875
|
-
symbolFade?: string | number;
|
|
4876
|
-
braces?: string | number;
|
|
4877
|
-
quotes?: string | number;
|
|
4878
|
-
empty?: string | number;
|
|
4879
|
-
dot?: string | number;
|
|
4880
|
-
}
|
|
5230
|
+
declare function setInterval(func: (...args: any) => any, ms: number): Interval;
|
|
5231
|
+
declare function clearInterval(interval: Interval): void;
|
|
4881
5232
|
|
|
4882
|
-
|
|
5233
|
+
interface StringConstructor {
|
|
4883
5234
|
/**
|
|
4884
|
-
*
|
|
5235
|
+
* Remove leading minimum indentation from the string.
|
|
5236
|
+
* The first line of the string must be empty.
|
|
4885
5237
|
*
|
|
4886
|
-
*
|
|
4887
|
-
* @param options - Additional settings for refining output
|
|
4888
|
-
* @returns A string representation of `value`.
|
|
5238
|
+
* https://github.com/tc39/proposal-string-dedent
|
|
4889
5239
|
*/
|
|
4890
|
-
|
|
5240
|
+
dedent: {
|
|
5241
|
+
/**
|
|
5242
|
+
* Remove leading minimum indentation from the string.
|
|
5243
|
+
* The first line of the string must be empty.
|
|
5244
|
+
*
|
|
5245
|
+
* https://github.com/tc39/proposal-string-dedent
|
|
5246
|
+
*/
|
|
5247
|
+
(input: string): string;
|
|
4891
5248
|
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
5249
|
+
/**
|
|
5250
|
+
* Remove leading minimum indentation from the template literal.
|
|
5251
|
+
* The first line of the string must be empty.
|
|
5252
|
+
*
|
|
5253
|
+
* https://github.com/tc39/proposal-string-dedent
|
|
5254
|
+
*/
|
|
5255
|
+
(
|
|
5256
|
+
strings: readonly string[] | ArrayLike<string>,
|
|
5257
|
+
...substitutions: any[]
|
|
5258
|
+
): string;
|
|
4902
5259
|
|
|
4903
|
-
/**
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
5260
|
+
/**
|
|
5261
|
+
* Wrap another template tag function such that tagged literals
|
|
5262
|
+
* become dedented before being passed to the wrapped function.
|
|
5263
|
+
*
|
|
5264
|
+
* https://www.npmjs.com/package/string-dedent#usage
|
|
5265
|
+
*/
|
|
5266
|
+
<
|
|
5267
|
+
Func extends (
|
|
5268
|
+
strings: readonly string[] | ArrayLike<string>,
|
|
5269
|
+
...substitutions: any[]
|
|
5270
|
+
) => string
|
|
5271
|
+
>(
|
|
5272
|
+
input: Func
|
|
5273
|
+
): Func;
|
|
5274
|
+
};
|
|
5275
|
+
}
|
|
4912
5276
|
|
|
4913
5277
|
/**
|
|
4914
5278
|
* A global which lets you configure the module loader (import/export/require).
|
|
@@ -5008,6 +5372,7 @@ interface ModuleGlobal {
|
|
|
5008
5372
|
read(modulePath: string): string;
|
|
5009
5373
|
}
|
|
5010
5374
|
|
|
5375
|
+
// global added by QJMS_AddModuleGlobal
|
|
5011
5376
|
declare var Module: ModuleGlobal;
|
|
5012
5377
|
|
|
5013
5378
|
interface RequireFunction {
|
|
@@ -5051,68 +5416,116 @@ interface RequireFunction {
|
|
|
5051
5416
|
resolve: (source: string) => string;
|
|
5052
5417
|
}
|
|
5053
5418
|
|
|
5419
|
+
// global added by QJMS_AddRequireGlobal
|
|
5054
5420
|
declare var require: RequireFunction;
|
|
5055
5421
|
|
|
5056
|
-
|
|
5057
|
-
|
|
5422
|
+
// gets set per-module by QJMS_SetModuleImportMeta
|
|
5423
|
+
interface ImportMeta {
|
|
5424
|
+
/**
|
|
5425
|
+
* A URL representing the current module.
|
|
5426
|
+
*
|
|
5427
|
+
* Usually starts with `file://`.
|
|
5428
|
+
*/
|
|
5429
|
+
url: string;
|
|
5058
5430
|
|
|
5059
|
-
|
|
5431
|
+
/**
|
|
5432
|
+
* Whether the current module is the "main" module, meaning that it is the
|
|
5433
|
+
* entrypoint file that's been loaded, or, in other terms, the first
|
|
5434
|
+
* user-authored module that's been loaded.
|
|
5435
|
+
*/
|
|
5436
|
+
main: boolean;
|
|
5060
5437
|
|
|
5061
|
-
|
|
5062
|
-
|
|
5438
|
+
/**
|
|
5439
|
+
* Equivalent to `globalThis.require`. Provided for compatibility with tools
|
|
5440
|
+
* that can leverage a CommonJS require function via `import.meta.require`.
|
|
5441
|
+
*/
|
|
5442
|
+
require: RequireFunction;
|
|
5063
5443
|
|
|
5064
|
-
interface StringConstructor {
|
|
5065
5444
|
/**
|
|
5066
|
-
*
|
|
5445
|
+
* Resolves a module specifier based on the current module's path.
|
|
5067
5446
|
*
|
|
5068
|
-
*
|
|
5447
|
+
* Equivalent to `globalThis.require.resolve`.
|
|
5448
|
+
*
|
|
5449
|
+
* Behaves similarly to [the browser import.meta.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve),
|
|
5450
|
+
* but it does not ensure that the returned string is a valid URL, because it
|
|
5451
|
+
* delegates directly to {@link Module.resolve} to resolve the name. If you
|
|
5452
|
+
* want this to return URL strings, change `Module.resolve` and `Module.read`
|
|
5453
|
+
* to work with URL strings.
|
|
5069
5454
|
*/
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
...substitutions: any[]
|
|
5073
|
-
): string;
|
|
5455
|
+
resolve: RequireFunction["resolve"];
|
|
5456
|
+
}
|
|
5074
5457
|
|
|
5458
|
+
declare module "quickjs:module" {
|
|
5075
5459
|
/**
|
|
5076
|
-
*
|
|
5077
|
-
* The first line of the string must be empty.
|
|
5460
|
+
* Return whether the provided resolved module path is set as the main module.
|
|
5078
5461
|
*
|
|
5079
|
-
*
|
|
5462
|
+
* In other words, return what the value of `import.meta.main` would be within
|
|
5463
|
+
* the module.
|
|
5464
|
+
*
|
|
5465
|
+
* The main module can be set via {@link setMainModule}.
|
|
5080
5466
|
*/
|
|
5081
|
-
|
|
5082
|
-
/**
|
|
5083
|
-
* Remove leading minimum indentation from the string.
|
|
5084
|
-
* The first line of the string must be empty.
|
|
5085
|
-
*
|
|
5086
|
-
* https://github.com/tc39/proposal-string-dedent
|
|
5087
|
-
*/
|
|
5088
|
-
(input: string): string;
|
|
5467
|
+
export function isMainModule(resolvedFilepath: string): boolean;
|
|
5089
5468
|
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
...substitutions: any[]
|
|
5099
|
-
): string;
|
|
5469
|
+
/**
|
|
5470
|
+
* Set the main module to the module with the provided resolved path.
|
|
5471
|
+
*
|
|
5472
|
+
* This will affect the value of `import.meta.main` for modules loaded in the
|
|
5473
|
+
* future, but it will NOT retroactively change the value of
|
|
5474
|
+
* `import.meta.main` in existing already-loaded modules.
|
|
5475
|
+
*/
|
|
5476
|
+
export function setMainModule(resolvedFilepath: string): void;
|
|
5100
5477
|
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5478
|
+
/**
|
|
5479
|
+
* Evaluate the string `code` as a script (global eval).
|
|
5480
|
+
*
|
|
5481
|
+
* @param code - The code to evaluate.
|
|
5482
|
+
* @param options - An optional object containing the following optional properties:
|
|
5483
|
+
* @property backtraceBarrier - Boolean (default = false). If true, error backtraces do not list the stack frames below the evalScript.
|
|
5484
|
+
* @property filename - String (default = "<evalScript>"). The filename to associate with the code being executed.
|
|
5485
|
+
* @returns The result of the evaluation.
|
|
5486
|
+
*/
|
|
5487
|
+
export function evalScript(
|
|
5488
|
+
code: string,
|
|
5489
|
+
options?: { backtraceBarrier?: boolean; filename?: string }
|
|
5490
|
+
): any;
|
|
5491
|
+
|
|
5492
|
+
/**
|
|
5493
|
+
* Evaluate the file `filename` as a script (global eval).
|
|
5494
|
+
*
|
|
5495
|
+
* @param filename - The relative or absolute path to the file to load. Relative paths are resolved relative to the process's current working directory.
|
|
5496
|
+
* @returns The result of the evaluation.
|
|
5497
|
+
*/
|
|
5498
|
+
export function runScript(filename: string): any;
|
|
5499
|
+
|
|
5500
|
+
/**
|
|
5501
|
+
* Evaluate the file `filename` as a module. Effectively a synchronous dynamic `import()`.
|
|
5502
|
+
*
|
|
5503
|
+
* @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.
|
|
5504
|
+
* @param basename - If present and `filename` is a relative path, `filename` will be resolved relative to this basename.
|
|
5505
|
+
* @returns The result of the evaluation (module namespace object).
|
|
5506
|
+
*/
|
|
5507
|
+
export function importModule(
|
|
5508
|
+
filename: string,
|
|
5509
|
+
basename?: string
|
|
5510
|
+
): { [key: string]: any };
|
|
5511
|
+
|
|
5512
|
+
/**
|
|
5513
|
+
* Return the resolved path to a module.
|
|
5514
|
+
*
|
|
5515
|
+
* @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.
|
|
5516
|
+
* @param basename - If present and `filename` is a relative path, `filename` will be resolved relative to this basename.
|
|
5517
|
+
* @returns The resolved module path.
|
|
5518
|
+
*/
|
|
5519
|
+
export function resolveModule(filename: string, basename?: string): string;
|
|
5520
|
+
|
|
5521
|
+
/**
|
|
5522
|
+
* Read the script of module filename from an active stack frame, then return it as a string.
|
|
5523
|
+
*
|
|
5524
|
+
* If there isn't a valid filename for the specified stack frame, an error will be thrown.
|
|
5525
|
+
*
|
|
5526
|
+
* @param stackLevels - How many levels up the stack to search for a filename. Defaults to 0, which uses the current stack frame.
|
|
5527
|
+
*/
|
|
5528
|
+
export function getFileNameFromStack(stackLevels?: number): string;
|
|
5116
5529
|
}
|
|
5117
5530
|
|
|
5118
5531
|
declare module "quickjs:bytecode" {
|
|
@@ -5186,6 +5599,10 @@ declare module "quickjs:context" {
|
|
|
5186
5599
|
* - Symbol
|
|
5187
5600
|
* - eval (but it doesn't work unless the `eval` option is enabled)
|
|
5188
5601
|
* - globalThis
|
|
5602
|
+
*
|
|
5603
|
+
* Note that new contexts don't have a `scriptArgs` global. If you need one
|
|
5604
|
+
* to be present in the new context, you can add one onto the Context's
|
|
5605
|
+
* `globalThis` property.
|
|
5189
5606
|
*/
|
|
5190
5607
|
constructor(options?: {
|
|
5191
5608
|
/** Enables `Date`. Defaults to `true` */
|
|
@@ -5197,6 +5614,9 @@ declare module "quickjs:context" {
|
|
|
5197
5614
|
/** Enables `String.prototype.normalize`. Defaults to `true`. */
|
|
5198
5615
|
stringNormalize?: boolean;
|
|
5199
5616
|
|
|
5617
|
+
/** Enables `String.dedent`. Defaults to `true`. */
|
|
5618
|
+
stringDedent?: boolean;
|
|
5619
|
+
|
|
5200
5620
|
/** Enables `RegExp`. Defaults to `true`. */
|
|
5201
5621
|
regExp?: boolean;
|
|
5202
5622
|
|
|
@@ -5263,33 +5683,22 @@ declare module "quickjs:context" {
|
|
|
5263
5683
|
*/
|
|
5264
5684
|
operators?: boolean;
|
|
5265
5685
|
|
|
5266
|
-
/** Enables "use math"
|
|
5686
|
+
/** Enables `"use math"`. Defaults to `true`. */
|
|
5267
5687
|
useMath?: boolean;
|
|
5268
5688
|
|
|
5689
|
+
/** Enables `inspect`. Defaults to `true`. */
|
|
5690
|
+
inspect?: boolean;
|
|
5691
|
+
/** Enables `console`. Defaults to `true`. */
|
|
5692
|
+
console?: boolean;
|
|
5693
|
+
/** Enables `print`. Defaults to `true`. */
|
|
5694
|
+
print?: boolean;
|
|
5695
|
+
/** Enables `require` and `Module`. Defaults to `true`. */
|
|
5696
|
+
moduleGlobals?: boolean;
|
|
5269
5697
|
/**
|
|
5270
|
-
* Enables
|
|
5271
|
-
*
|
|
5272
|
-
* - inspect
|
|
5273
|
-
* - console
|
|
5274
|
-
* - print
|
|
5275
|
-
* - require (and require.resolve)
|
|
5276
|
-
* - setTimeout
|
|
5277
|
-
* - clearTimeout
|
|
5278
|
-
* - setInterval
|
|
5279
|
-
* - clearInterval
|
|
5280
|
-
* - String.cooked
|
|
5281
|
-
* - String.dedent
|
|
5282
|
-
*
|
|
5283
|
-
* Defaults to `true`.
|
|
5284
|
-
*
|
|
5285
|
-
* NOTE: The following globals, normally part of `js_std_add_helpers`, are NEVER added:
|
|
5286
|
-
*
|
|
5287
|
-
* - Module
|
|
5288
|
-
* - scriptArgs
|
|
5289
|
-
*
|
|
5290
|
-
* If you need them in the new context, copy them over from your context's globalThis onto the child context's globalThis.
|
|
5698
|
+
* Enables `setTimeout`, `clearTimeout`, `setInterval`, and
|
|
5699
|
+
* `clearInterval`. Defaults to `true`.
|
|
5291
5700
|
*/
|
|
5292
|
-
|
|
5701
|
+
timers?: boolean;
|
|
5293
5702
|
|
|
5294
5703
|
/** Enable builtin modules. */
|
|
5295
5704
|
modules?: {
|
|
@@ -5301,6 +5710,8 @@ declare module "quickjs:context" {
|
|
|
5301
5710
|
"quickjs:bytecode"?: boolean;
|
|
5302
5711
|
/** Enables the "quickjs:context" module. Defaults to `true`. */
|
|
5303
5712
|
"quickjs:context"?: boolean;
|
|
5713
|
+
/** Enables the "quickjs:module" module. Defaults to `true`. */
|
|
5714
|
+
"quickjs:module"?: boolean;
|
|
5304
5715
|
};
|
|
5305
5716
|
});
|
|
5306
5717
|
|
|
@@ -5319,3 +5730,6 @@ declare module "quickjs:context" {
|
|
|
5319
5730
|
eval(code: string): any;
|
|
5320
5731
|
}
|
|
5321
5732
|
}
|
|
5733
|
+
|
|
5734
|
+
declare const std: typeof import("quickjs:std");
|
|
5735
|
+
declare const os: typeof import("quickjs:os");
|