yavascript 0.0.10 → 0.0.12
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-unknown-linux-gnu/yavascript +0 -0
- package/bin/aarch64-unknown-linux-musl/yavascript +0 -0
- package/bin/aarch64-unknown-linux-static/yavascript +0 -0
- package/bin/x86_64-apple-darwin/yavascript +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-musl/yavascript +0 -0
- package/bin/x86_64-unknown-linux-static/yavascript +0 -0
- package/dist/index-arm64.js +32596 -6506
- package/dist/index-x86_64.js +32596 -6506
- package/dist/primordials-arm64.js +33504 -7641
- package/dist/primordials-x86_64.js +33504 -7641
- package/package.json +1 -1
- package/yavascript.d.ts +957 -640
- package/bin/aarch64-apple-darwin/yavascript-bootstrap +0 -0
- package/bin/aarch64-unknown-linux-gnu/yavascript-bootstrap +0 -0
- package/bin/aarch64-unknown-linux-musl/yavascript-bootstrap +0 -0
- package/bin/aarch64-unknown-linux-static/yavascript-bootstrap +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-unknown-linux-gnu/yavascript-bootstrap +0 -0
- package/bin/x86_64-unknown-linux-musl/yavascript-bootstrap +0 -0
- package/bin/x86_64-unknown-linux-static/yavascript-bootstrap +0 -0
package/yavascript.d.ts
CHANGED
|
@@ -24,8 +24,11 @@ declare var help: {
|
|
|
24
24
|
*
|
|
25
25
|
* If the value is later passed into the `help` function, the provided text
|
|
26
26
|
* will be printed.
|
|
27
|
+
*
|
|
28
|
+
* To set help text for the values `null` or `undefined`, `allowNullish`
|
|
29
|
+
* must be `true`.
|
|
27
30
|
*/
|
|
28
|
-
(value: object, text: string): void;
|
|
31
|
+
(value: object, text: string, allowNullish?: boolean): void;
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* Lazily sets the help text for the provided value using the provided
|
|
@@ -99,6 +102,11 @@ declare const yavascript: {
|
|
|
99
102
|
options?: { filename?: string; expression?: boolean }
|
|
100
103
|
): string;
|
|
101
104
|
|
|
105
|
+
civet(
|
|
106
|
+
code: string,
|
|
107
|
+
options?: { filename?: string; expression?: boolean }
|
|
108
|
+
): string;
|
|
109
|
+
|
|
102
110
|
autodetect(
|
|
103
111
|
code: string,
|
|
104
112
|
options?: { filename?: string; expression?: boolean }
|
|
@@ -244,14 +252,6 @@ declare function remove(path: string | Path): void;
|
|
|
244
252
|
*/
|
|
245
253
|
declare function exists(path: string | Path): boolean;
|
|
246
254
|
|
|
247
|
-
/**
|
|
248
|
-
* Creates directories for each of the provided path components,
|
|
249
|
-
* if they don't already exist.
|
|
250
|
-
*
|
|
251
|
-
* Provides the same functionality as the command `mkdir -p`.
|
|
252
|
-
*/
|
|
253
|
-
declare function ensureDir(path: string | Path): string;
|
|
254
|
-
|
|
255
255
|
/**
|
|
256
256
|
* Options for {@link copy}.
|
|
257
257
|
*/
|
|
@@ -264,17 +264,34 @@ declare type CopyOptions = {
|
|
|
264
264
|
*/
|
|
265
265
|
whenTargetExists?: "overwrite" | "skip" | "error";
|
|
266
266
|
|
|
267
|
-
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
267
|
+
/** Options which control logging. */
|
|
268
|
+
logging?: {
|
|
269
|
+
/**
|
|
270
|
+
* If provided, this function will be called multiple times as `copy`
|
|
271
|
+
* traverses the filesystem, to help you understand what's going on and/or
|
|
272
|
+
* troubleshoot things. In most cases, it makes sense to use a logging
|
|
273
|
+
* function here, like so:
|
|
274
|
+
*
|
|
275
|
+
* ```js
|
|
276
|
+
* copy("./source", "./destination", {
|
|
277
|
+
* logging: { trace: console.log },
|
|
278
|
+
* });
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* Defaults to the current value of {@link logger.trace}. `logger.trace`
|
|
282
|
+
* defaults to a no-op function.
|
|
283
|
+
*/
|
|
284
|
+
trace?: (...args: Array<any>) => void;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* An optional, user-provided logging function to be used for informational
|
|
288
|
+
* messages.
|
|
289
|
+
*
|
|
290
|
+
* Defaults to the current value of {@link logger.info}. `logger.info`
|
|
291
|
+
* defaults to a function which writes to stderr.
|
|
292
|
+
*/
|
|
293
|
+
info?: (...args: Array<any>) => void;
|
|
294
|
+
};
|
|
278
295
|
};
|
|
279
296
|
|
|
280
297
|
/**
|
|
@@ -307,6 +324,14 @@ declare class Path {
|
|
|
307
324
|
*/
|
|
308
325
|
static readonly OS_ENV_VAR_SEPARATOR: ":" | ";";
|
|
309
326
|
|
|
327
|
+
/**
|
|
328
|
+
* A list of suffixes that could appear in the filename for a program on the
|
|
329
|
+
* current OS. For instance, on Windows, programs often end with ".exe".
|
|
330
|
+
*
|
|
331
|
+
* On Unix-like OSes, this is empty. On Windows, it's based on `env.PATHEXT`.
|
|
332
|
+
*/
|
|
333
|
+
static readonly OS_PROGRAM_EXTENSIONS: ReadonlySet<string>;
|
|
334
|
+
|
|
310
335
|
/** Split one or more path strings into an array of path segments. */
|
|
311
336
|
static splitToSegments(inputParts: Array<string> | string): Array<string>;
|
|
312
337
|
|
|
@@ -321,25 +346,13 @@ declare class Path {
|
|
|
321
346
|
fallback: Fallback = Path.OS_SEGMENT_SEPARATOR
|
|
322
347
|
): string | Fallback;
|
|
323
348
|
|
|
324
|
-
/** Join together one or more paths. */
|
|
325
|
-
static join(...inputs: Array<string | Path | Array<string | Path>>): string;
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Turns the input path(s) into an absolute path by resolving all `.` and `..`
|
|
329
|
-
* segments, using `pwd()` as a base dir to use when resolving leading `.` or
|
|
330
|
-
* `..` segments.
|
|
331
|
-
*/
|
|
332
|
-
static resolve(
|
|
333
|
-
...inputs: Array<string | Path | Array<string | Path>>
|
|
334
|
-
): string;
|
|
335
|
-
|
|
336
349
|
/**
|
|
337
350
|
* Concatenates the input path(s) and then resolves all non-leading `.` and
|
|
338
351
|
* `..` segments.
|
|
339
352
|
*/
|
|
340
353
|
static normalize(
|
|
341
354
|
...inputs: Array<string | Path | Array<string | Path>>
|
|
342
|
-
):
|
|
355
|
+
): Path;
|
|
343
356
|
|
|
344
357
|
/**
|
|
345
358
|
* Return whether the provided path is absolute; that is, whether it
|
|
@@ -347,18 +360,6 @@ declare class Path {
|
|
|
347
360
|
*/
|
|
348
361
|
static isAbsolute(path: string | Path): boolean;
|
|
349
362
|
|
|
350
|
-
/** A tagged template literal function that creates a `Path` object. */
|
|
351
|
-
static tag(
|
|
352
|
-
strings: TemplateStringsArray,
|
|
353
|
-
...values: ReadonlyArray<string | Path | Array<string | Path>>
|
|
354
|
-
): Path;
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Returns a tagged template literal that creates a `Path` object. `dir` is
|
|
358
|
-
* used as a prefix for every `Path` object created.
|
|
359
|
-
*/
|
|
360
|
-
static tagUsingBase(dir: string | Path): typeof Path.tag;
|
|
361
|
-
|
|
362
363
|
/**
|
|
363
364
|
* An array of the path segments that make up this path.
|
|
364
365
|
*
|
|
@@ -378,17 +379,12 @@ declare class Path {
|
|
|
378
379
|
/** Create a new Path object using the provided input(s). */
|
|
379
380
|
constructor(...inputs: Array<string | Path | Array<string | Path>>);
|
|
380
381
|
|
|
381
|
-
/** Create a new Path object using the provided segments and separator. */
|
|
382
|
-
static from(segments: Array<string>, separator: string): Path;
|
|
383
|
-
|
|
384
382
|
/**
|
|
385
|
-
*
|
|
386
|
-
* segments, using `from` as a base dir to use when resolving leading `.` or
|
|
387
|
-
* `..` segments.
|
|
383
|
+
* Create a new Path object using the provided segments and separator.
|
|
388
384
|
*
|
|
389
|
-
* If
|
|
385
|
+
* If unspecified, `separator` defaults to `Path.OS_SEGMENT_SEPARATOR`.
|
|
390
386
|
*/
|
|
391
|
-
|
|
387
|
+
static fromRaw(segments: Array<string>, separator?: string): Path;
|
|
392
388
|
|
|
393
389
|
/**
|
|
394
390
|
* Resolve all non-leading `.` and `..` segments in this path.
|
|
@@ -396,21 +392,22 @@ declare class Path {
|
|
|
396
392
|
normalize(): Path;
|
|
397
393
|
|
|
398
394
|
/**
|
|
399
|
-
* Create a new
|
|
400
|
-
* segments.
|
|
395
|
+
* Create a new Path by appending additional path segments onto the end of
|
|
396
|
+
* this Path's segments.
|
|
401
397
|
*
|
|
402
398
|
* The returned path will use this path's separator.
|
|
403
399
|
*/
|
|
404
|
-
concat(other: string | Path | Array<string | Path
|
|
400
|
+
concat(...other: Array<string | Path | Array<string | Path>>): Path;
|
|
405
401
|
|
|
406
402
|
/**
|
|
407
403
|
* Return whether this path is absolute; that is, whether it starts with
|
|
408
|
-
* either
|
|
404
|
+
* either `/`, `\`, or a drive letter (ie `C:`).
|
|
409
405
|
*/
|
|
410
406
|
isAbsolute(): boolean;
|
|
411
407
|
|
|
412
408
|
/**
|
|
413
|
-
* Make a second Path object containing the same
|
|
409
|
+
* Make a second Path object containing the same segments and separator as
|
|
410
|
+
* this one.
|
|
414
411
|
*/
|
|
415
412
|
clone(): this;
|
|
416
413
|
|
|
@@ -437,9 +434,122 @@ declare class Path {
|
|
|
437
434
|
toString(): string;
|
|
438
435
|
|
|
439
436
|
/**
|
|
440
|
-
* Alias for `toString`; causes Path objects to be serialized as strings
|
|
437
|
+
* Alias for `toString`; causes Path objects to be serialized as strings when
|
|
438
|
+
* they (or an object referencing them) are passed into JSON.stringify.
|
|
441
439
|
*/
|
|
442
440
|
toJSON(): string;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Return the final path segment of this path. If this path has no path
|
|
444
|
+
* segments, the empty string is returned.
|
|
445
|
+
*/
|
|
446
|
+
basename(): string;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Return the trailing extension of this path. The `options` parameter works
|
|
450
|
+
* the same as the global `extname`'s `options` parameter.
|
|
451
|
+
*/
|
|
452
|
+
extname(options?: { full?: boolean }): string;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Return a new Path containing all of the path segments in this one except
|
|
456
|
+
* for the last one; ie. the path to the directory that contains this path.
|
|
457
|
+
*/
|
|
458
|
+
dirname(): Path;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Return whether this path starts with the provided value, by comparing one
|
|
462
|
+
* path segment at a time.
|
|
463
|
+
*
|
|
464
|
+
* The starting segments of this path must *exactly* match the segments in the
|
|
465
|
+
* provided value.
|
|
466
|
+
*
|
|
467
|
+
* This means that, given two Paths A and B:
|
|
468
|
+
*
|
|
469
|
+
* ```
|
|
470
|
+
* A: Path { /home/user/.config }
|
|
471
|
+
* B: Path { /home/user/.config2 }
|
|
472
|
+
* ```
|
|
473
|
+
*
|
|
474
|
+
* Path B does *not* start with Path A, because `".config" !== ".config2"`.
|
|
475
|
+
*/
|
|
476
|
+
startsWith(value: string | Path | Array<string | Path>): boolean;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Return whether this path ends with the provided value, by comparing one
|
|
480
|
+
* path segment at a time.
|
|
481
|
+
*
|
|
482
|
+
* The ending segments of this path must *exactly* match the segments in the
|
|
483
|
+
* provided value.
|
|
484
|
+
*
|
|
485
|
+
* This means that, given two Paths A and B:
|
|
486
|
+
*
|
|
487
|
+
* ```
|
|
488
|
+
* A: Path { /home/1user/.config }
|
|
489
|
+
* B: Path { user/.config }
|
|
490
|
+
* ```
|
|
491
|
+
*
|
|
492
|
+
* Path A does *not* end with Path B, because `"1user" !== "user"`.
|
|
493
|
+
*/
|
|
494
|
+
endsWith(value: string | Path | Array<string | Path>): boolean;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Return the path segment index at which `value` appears in this path, or
|
|
498
|
+
* `-1` if it doesn't appear in this path.
|
|
499
|
+
*
|
|
500
|
+
* @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.
|
|
501
|
+
* @param fromIndex - The index into this path's segments to begin searching at. Defaults to `0`.
|
|
502
|
+
*/
|
|
503
|
+
indexOf(
|
|
504
|
+
value: string | Path | Array<string | Path>,
|
|
505
|
+
fromIndex?: number | undefined
|
|
506
|
+
): number;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Return whether `value` appears in this path.
|
|
510
|
+
*
|
|
511
|
+
* @param value - The value to search for.
|
|
512
|
+
* @param fromIndex - The index into this path's segments to begin searching at. Defaults to `0`.
|
|
513
|
+
*/
|
|
514
|
+
includes(
|
|
515
|
+
value: string | Path | Array<string | Path>,
|
|
516
|
+
fromIndex?: number | undefined
|
|
517
|
+
): boolean;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Return a new Path wherein the segments in `value` have been replaced with
|
|
521
|
+
* the segments in `replacement`. If the segments in `value` are not present
|
|
522
|
+
* in this path, a clone of this path is returned.
|
|
523
|
+
*
|
|
524
|
+
* Note that only the first match is replaced.
|
|
525
|
+
*
|
|
526
|
+
* @param value - What should be replaced
|
|
527
|
+
* @param replacement - What it should be replaced with
|
|
528
|
+
*/
|
|
529
|
+
replace(
|
|
530
|
+
value: string | Path | Array<string | Path>,
|
|
531
|
+
replacement: string | Path | Array<string | Path>
|
|
532
|
+
): Path;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Return a new Path wherein all occurrences of the segments in `value` have
|
|
536
|
+
* been replaced with the segments in `replacement`. If the segments in
|
|
537
|
+
* `value` are not present in this path, a clone of this path is returned.
|
|
538
|
+
*
|
|
539
|
+
* @param value - What should be replaced
|
|
540
|
+
* @param replacement - What it should be replaced with
|
|
541
|
+
*/
|
|
542
|
+
replaceAll(
|
|
543
|
+
value: string | Path | Array<string | Path>,
|
|
544
|
+
replacement: string | Path | Array<string | Path>
|
|
545
|
+
): Path;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Return a copy of this path but with the final segment replaced with `replacement`
|
|
549
|
+
*
|
|
550
|
+
* @param replacement - The new final segment(s) for the returned Path
|
|
551
|
+
*/
|
|
552
|
+
replaceLast(replacement: string | Path | Array<string | Path>): Path;
|
|
443
553
|
}
|
|
444
554
|
|
|
445
555
|
/**
|
|
@@ -464,10 +574,36 @@ declare var __dirname: string;
|
|
|
464
574
|
declare function basename(path: string | Path): string;
|
|
465
575
|
|
|
466
576
|
/**
|
|
467
|
-
*
|
|
468
|
-
*
|
|
577
|
+
* Reads the contents of one or more files from disk as either one UTF-8 string
|
|
578
|
+
* or one ArrayBuffer.
|
|
469
579
|
*/
|
|
470
|
-
declare
|
|
580
|
+
declare const cat: {
|
|
581
|
+
/**
|
|
582
|
+
* Read the contents of one or more files from disk, as one UTF-8 string.
|
|
583
|
+
*/
|
|
584
|
+
(paths: string | Path | Array<string | Path>): string;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Read the contents of one or more files from disk, as one UTF-8 string.
|
|
588
|
+
*/
|
|
589
|
+
(paths: string | Path | Array<string | Path>, options: {}): string;
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Read the contents of one or more files from disk, as one UTF-8 string.
|
|
593
|
+
*/
|
|
594
|
+
(
|
|
595
|
+
paths: string | Path | Array<string | Path>,
|
|
596
|
+
options: { binary: false }
|
|
597
|
+
): string;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Read the contents of one or more files from disk, as one ArrayBuffer.
|
|
601
|
+
*/
|
|
602
|
+
(
|
|
603
|
+
paths: string | Path | Array<string | Path>,
|
|
604
|
+
options: { binary: true }
|
|
605
|
+
): ArrayBuffer;
|
|
606
|
+
};
|
|
471
607
|
|
|
472
608
|
/**
|
|
473
609
|
* Change the process's current working directory to the specified path. If no
|
|
@@ -526,13 +662,29 @@ declare function chmod(
|
|
|
526
662
|
*
|
|
527
663
|
* Provides the same functionality as the unix binary of the same name.
|
|
528
664
|
*/
|
|
529
|
-
declare function dirname(path: string | Path):
|
|
665
|
+
declare function dirname(path: string | Path): Path;
|
|
530
666
|
|
|
531
667
|
/**
|
|
532
668
|
* Print one or more values to stdout.
|
|
533
669
|
*/
|
|
534
670
|
declare const echo: typeof console.log;
|
|
535
671
|
|
|
672
|
+
/**
|
|
673
|
+
* Exit the yavascript process.
|
|
674
|
+
*
|
|
675
|
+
* Provides the same functionality as the shell builtin of the same name.
|
|
676
|
+
*
|
|
677
|
+
* If exit is called with an argument, that argument is used as the exit code.
|
|
678
|
+
* Otherwise, `exit.code` is used, which defaults to 0.
|
|
679
|
+
*
|
|
680
|
+
* `exit.code` will also be used as the exit status code for the yavascript
|
|
681
|
+
* process if the process exits normally.
|
|
682
|
+
*/
|
|
683
|
+
declare const exit: {
|
|
684
|
+
(code?: number): never;
|
|
685
|
+
code: number;
|
|
686
|
+
};
|
|
687
|
+
|
|
536
688
|
/**
|
|
537
689
|
* Returns the file extension of the file at a given path.
|
|
538
690
|
*
|
|
@@ -548,14 +700,43 @@ declare function extname(
|
|
|
548
700
|
/**
|
|
549
701
|
* Returns the contents of a directory, as absolute paths. `.` and `..` are
|
|
550
702
|
* omitted.
|
|
703
|
+
*/
|
|
704
|
+
declare function ls(dir?: string | Path): Array<Path>;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Create a directory (folder).
|
|
708
|
+
*
|
|
709
|
+
* Provides the same functionality as the unix binary of the same name.
|
|
710
|
+
*/
|
|
711
|
+
declare function mkdir(
|
|
712
|
+
path: string | Path,
|
|
713
|
+
options?: {
|
|
714
|
+
recursive?: boolean;
|
|
715
|
+
mode?: number;
|
|
716
|
+
logging?: {
|
|
717
|
+
trace?: (...args: Array<any>) => void;
|
|
718
|
+
info?: (...args: Array<any>) => void;
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
): void;
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Create a directory (folder) and all parents, recursively
|
|
551
725
|
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
726
|
+
* Alias for `mkdir(path, { recursive: true })`.
|
|
727
|
+
*
|
|
728
|
+
* Provides the same functionality as `mkdir -p`.
|
|
554
729
|
*/
|
|
555
|
-
declare function
|
|
556
|
-
|
|
557
|
-
options?: {
|
|
558
|
-
|
|
730
|
+
declare function mkdirp(
|
|
731
|
+
path: string | Path,
|
|
732
|
+
options?: {
|
|
733
|
+
mode?: number;
|
|
734
|
+
logging?: {
|
|
735
|
+
trace?: (...args: Array<any>) => void;
|
|
736
|
+
info?: (...args: Array<any>) => void;
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
): void;
|
|
559
740
|
|
|
560
741
|
/**
|
|
561
742
|
* Print data to stdout using C-style format specifiers.
|
|
@@ -571,7 +752,20 @@ declare function printf(format: string, ...args: Array<any>): void;
|
|
|
571
752
|
*
|
|
572
753
|
* Provides the same functionality as the shell builtin of the same name.
|
|
573
754
|
*/
|
|
574
|
-
declare
|
|
755
|
+
declare const pwd: {
|
|
756
|
+
/**
|
|
757
|
+
* Returns the process's current working directory.
|
|
758
|
+
*
|
|
759
|
+
* Provides the same functionality as the shell builtin of the same name.
|
|
760
|
+
*/
|
|
761
|
+
(): Path;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* A frozen, read-only `Path` object containing what `pwd()` was when
|
|
765
|
+
* yavascript first started up.
|
|
766
|
+
*/
|
|
767
|
+
readonly initial: Path;
|
|
768
|
+
};
|
|
575
769
|
|
|
576
770
|
/**
|
|
577
771
|
* Reads a symlink.
|
|
@@ -580,7 +774,7 @@ declare function pwd(): string;
|
|
|
580
774
|
*
|
|
581
775
|
* Provides the same functionality as the unix binary of the same name.
|
|
582
776
|
*/
|
|
583
|
-
declare function readlink(path: string | Path):
|
|
777
|
+
declare function readlink(path: string | Path): Path;
|
|
584
778
|
|
|
585
779
|
/**
|
|
586
780
|
* Get the absolute path given a relative path. Symlinks are also resolved.
|
|
@@ -589,7 +783,7 @@ declare function readlink(path: string | Path): string;
|
|
|
589
783
|
*
|
|
590
784
|
* Provides the same functionality as the unix binary of the same name.
|
|
591
785
|
*/
|
|
592
|
-
declare function realpath(path: string | Path):
|
|
786
|
+
declare function realpath(path: string | Path): Path;
|
|
593
787
|
|
|
594
788
|
/**
|
|
595
789
|
* Blocks the current thread for at least the specified number of milliseconds,
|
|
@@ -634,6 +828,54 @@ declare var sleep: {
|
|
|
634
828
|
*/
|
|
635
829
|
declare function touch(path: string | Path): void;
|
|
636
830
|
|
|
831
|
+
/**
|
|
832
|
+
* Searches the system for the path to a program named `binaryName`.
|
|
833
|
+
*
|
|
834
|
+
* If the program can't be found, `null` is returned.
|
|
835
|
+
*
|
|
836
|
+
* @param binaryName The program to search for
|
|
837
|
+
* @param options Options which affect how the search is performed
|
|
838
|
+
* @param options.searchPaths A list of folders where programs may be found. Defaults to `env.PATH?.split(Path.OS_ENV_VAR_SEPARATOR) || []`.
|
|
839
|
+
* @param options.suffixes A list of filename extension suffixes to include in the search, ie [".exe"]. Defaults to `Path.OS_PROGRAM_EXTENSIONS`.
|
|
840
|
+
* @param options.trace A logging function that will be called at various times during the execution of `which`. Defaults to {@link logger.trace}.
|
|
841
|
+
*/
|
|
842
|
+
declare function which(
|
|
843
|
+
binaryName: string,
|
|
844
|
+
options?: {
|
|
845
|
+
/**
|
|
846
|
+
* A list of folders where programs may be found. Defaults to
|
|
847
|
+
* `env.PATH?.split(Path.OS_ENV_VAR_SEPARATOR) || []`.
|
|
848
|
+
*/
|
|
849
|
+
searchPaths?: Array<Path | string>;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* A list of filename extension suffixes to include in the search, ie
|
|
853
|
+
* `[".exe"]`. Defaults to {@link Path.OS_PROGRAM_EXTENSIONS}.
|
|
854
|
+
*/
|
|
855
|
+
suffixes?: Array<string>;
|
|
856
|
+
|
|
857
|
+
/** Options which control logging. */
|
|
858
|
+
logging?: {
|
|
859
|
+
/**
|
|
860
|
+
* If provided, this logging function will be called multiple times as
|
|
861
|
+
* `which` runs, to help you understand what's going on and/or troubleshoot
|
|
862
|
+
* things. In most cases, it makes sense to use a function from `console`
|
|
863
|
+
* here, like so:
|
|
864
|
+
*
|
|
865
|
+
* ```js
|
|
866
|
+
* which("bash", {
|
|
867
|
+
* logging: { trace: console.log }
|
|
868
|
+
* });
|
|
869
|
+
* ```
|
|
870
|
+
*
|
|
871
|
+
* Defaults to the current value of {@link logger.trace}. `logger.trace`
|
|
872
|
+
* defaults to a no-op function.
|
|
873
|
+
*/
|
|
874
|
+
trace?: (...args: Array<any>) => void;
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
): Path | null;
|
|
878
|
+
|
|
637
879
|
declare type BaseExecOptions = {
|
|
638
880
|
/** Sets the current working directory for the child process. */
|
|
639
881
|
cwd?: string | Path;
|
|
@@ -641,16 +883,34 @@ declare type BaseExecOptions = {
|
|
|
641
883
|
/** Sets environment variables within the process. */
|
|
642
884
|
env?: { [key: string | number]: string | number | boolean };
|
|
643
885
|
|
|
644
|
-
/**
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
886
|
+
/** Options which control logging. */
|
|
887
|
+
logging?: {
|
|
888
|
+
/**
|
|
889
|
+
* If provided, this logging function will be called multiple times as
|
|
890
|
+
* `exec` runs, to help you understand what's going on and/or troubleshoot
|
|
891
|
+
* things. In most cases, it makes sense to use a function from `console`
|
|
892
|
+
* here, like so:
|
|
893
|
+
*
|
|
894
|
+
* ```js
|
|
895
|
+
* exec(["echo", "hi"], {
|
|
896
|
+
* logging: { trace: console.log },
|
|
897
|
+
* });
|
|
898
|
+
* ```
|
|
899
|
+
*
|
|
900
|
+
* Defaults to the current value of {@link logger.trace}. `logger.trace`
|
|
901
|
+
* defaults to a no-op function.
|
|
902
|
+
*/
|
|
903
|
+
trace?: (...args: Array<any>) => void;
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* An optional, user-provided logging function to be used for informational
|
|
907
|
+
* messages. Less verbose than `logging.trace`.
|
|
908
|
+
*
|
|
909
|
+
* Defaults to the current value of {@link logger.info}. `logger.info`
|
|
910
|
+
* defaults to a function which logs to stderr.
|
|
911
|
+
*/
|
|
912
|
+
info?: (...args: Array<any>) => void;
|
|
913
|
+
};
|
|
654
914
|
|
|
655
915
|
/**
|
|
656
916
|
* Whether an Error should be thrown when the process exits with a nonzero
|
|
@@ -667,143 +927,63 @@ declare type BaseExecOptions = {
|
|
|
667
927
|
* Defaults to false. true is an alias for "utf8".
|
|
668
928
|
*/
|
|
669
929
|
captureOutput?: boolean | "utf8" | "arraybuffer";
|
|
670
|
-
};
|
|
671
|
-
|
|
672
|
-
declare interface Exec {
|
|
673
|
-
(
|
|
674
|
-
args: Array<string> | string,
|
|
675
|
-
options: BaseExecOptions & {
|
|
676
|
-
failOnNonZeroStatus: true;
|
|
677
|
-
captureOutput: false;
|
|
678
|
-
}
|
|
679
|
-
): void;
|
|
680
|
-
|
|
681
|
-
(
|
|
682
|
-
args: Array<string> | string,
|
|
683
|
-
options: BaseExecOptions & {
|
|
684
|
-
failOnNonZeroStatus: false;
|
|
685
|
-
captureOutput: false;
|
|
686
|
-
}
|
|
687
|
-
):
|
|
688
|
-
| { status: number; signal: undefined }
|
|
689
|
-
| { status: undefined; signal: number };
|
|
690
|
-
|
|
691
|
-
(
|
|
692
|
-
args: Array<string> | string,
|
|
693
|
-
options: BaseExecOptions & {
|
|
694
|
-
failOnNonZeroStatus: true;
|
|
695
|
-
captureOutput: true;
|
|
696
|
-
}
|
|
697
|
-
): { stdout: string; stderr: string };
|
|
698
|
-
|
|
699
|
-
(
|
|
700
|
-
args: Array<string> | string,
|
|
701
|
-
options: BaseExecOptions & {
|
|
702
|
-
failOnNonZeroStatus: true;
|
|
703
|
-
captureOutput: "utf8";
|
|
704
|
-
}
|
|
705
|
-
): { stdout: string; stderr: string };
|
|
706
|
-
|
|
707
|
-
(
|
|
708
|
-
args: Array<string> | string,
|
|
709
|
-
options: BaseExecOptions & {
|
|
710
|
-
failOnNonZeroStatus: true;
|
|
711
|
-
captureOutput: "arraybuffer";
|
|
712
|
-
}
|
|
713
|
-
): { stdout: ArrayBuffer; stderr: ArrayBuffer };
|
|
714
|
-
|
|
715
|
-
(
|
|
716
|
-
args: Array<string> | string,
|
|
717
|
-
options: BaseExecOptions & {
|
|
718
|
-
failOnNonZeroStatus: false;
|
|
719
|
-
captureOutput: true;
|
|
720
|
-
}
|
|
721
|
-
):
|
|
722
|
-
| { stdout: string; stderr: string; status: number; signal: undefined }
|
|
723
|
-
| { stdout: string; stderr: string; status: undefined; signal: number };
|
|
724
930
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
931
|
+
/**
|
|
932
|
+
* If true, exec doesn't return until the process is done running. If false,
|
|
933
|
+
* exec returns an object with a "wait" method which can be used to wait for
|
|
934
|
+
* the process to be done running.
|
|
935
|
+
*
|
|
936
|
+
* Defaults to true.
|
|
937
|
+
*/
|
|
938
|
+
block?: boolean;
|
|
939
|
+
};
|
|
734
940
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
stderr: ArrayBuffer;
|
|
751
|
-
status: undefined;
|
|
752
|
-
signal: number;
|
|
753
|
-
};
|
|
941
|
+
type ExecWaitResult<ExecOptions extends BaseExecOptions> = ExecOptions extends
|
|
942
|
+
| { captureOutput: true | "utf8" | "arraybuffer" }
|
|
943
|
+
| { failOnNonZeroStatus: false }
|
|
944
|
+
? (ExecOptions["captureOutput"] extends true | "utf8"
|
|
945
|
+
? { stdout: string; stderr: string }
|
|
946
|
+
: {}) &
|
|
947
|
+
(ExecOptions["captureOutput"] extends "arraybuffer"
|
|
948
|
+
? { stdout: ArrayBuffer; stderr: ArrayBuffer }
|
|
949
|
+
: {}) &
|
|
950
|
+
(ExecOptions["failOnNonZeroStatus"] extends false
|
|
951
|
+
?
|
|
952
|
+
| { status: number; signal: undefined }
|
|
953
|
+
| { status: undefined; signal: number }
|
|
954
|
+
: {})
|
|
955
|
+
: void;
|
|
754
956
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
957
|
+
declare interface Exec {
|
|
958
|
+
<
|
|
959
|
+
ExecOptions extends BaseExecOptions = {
|
|
758
960
|
failOnNonZeroStatus: true;
|
|
759
|
-
}
|
|
760
|
-
): void;
|
|
761
|
-
|
|
762
|
-
(
|
|
763
|
-
args: Array<string> | string,
|
|
764
|
-
options: BaseExecOptions & {
|
|
765
|
-
failOnNonZeroStatus: false;
|
|
766
|
-
}
|
|
767
|
-
):
|
|
768
|
-
| { status: number; signal: undefined }
|
|
769
|
-
| { status: undefined; signal: number };
|
|
770
|
-
|
|
771
|
-
(
|
|
772
|
-
args: Array<string> | string,
|
|
773
|
-
options: BaseExecOptions & {
|
|
774
|
-
captureOutput: true;
|
|
775
|
-
}
|
|
776
|
-
): { stdout: string; stderr: string };
|
|
777
|
-
|
|
778
|
-
(
|
|
779
|
-
args: Array<string> | string,
|
|
780
|
-
options: BaseExecOptions & {
|
|
781
|
-
captureOutput: "utf8";
|
|
782
|
-
}
|
|
783
|
-
): { stdout: string; stderr: string };
|
|
784
|
-
|
|
785
|
-
(
|
|
786
|
-
args: Array<string> | string,
|
|
787
|
-
options: BaseExecOptions & {
|
|
788
|
-
captureOutput: "arraybuffer";
|
|
789
|
-
}
|
|
790
|
-
): { stdout: ArrayBuffer; stderr: ArrayBuffer };
|
|
791
|
-
|
|
792
|
-
(
|
|
793
|
-
args: Array<string> | string,
|
|
794
|
-
options: BaseExecOptions & {
|
|
795
961
|
captureOutput: false;
|
|
962
|
+
block: true;
|
|
796
963
|
}
|
|
797
|
-
|
|
964
|
+
>(
|
|
965
|
+
args: Array<string | Path | number> | string | Path,
|
|
966
|
+
options?: ExecOptions
|
|
967
|
+
): ExecOptions["block"] extends false
|
|
968
|
+
? { wait(): ExecWaitResult<ExecOptions> }
|
|
969
|
+
: ExecWaitResult<ExecOptions>;
|
|
798
970
|
|
|
799
|
-
|
|
971
|
+
/**
|
|
972
|
+
* Parse the provided value into an array of command-line argument strings,
|
|
973
|
+
* using the same logic that {@link exec} and {@link ChildProcess} use.
|
|
974
|
+
*/
|
|
975
|
+
toArgv(args: Array<string | Path | number> | string | Path): Array<string>;
|
|
800
976
|
}
|
|
801
977
|
|
|
802
|
-
/**
|
|
978
|
+
/**
|
|
979
|
+
* Runs a child process using the provided arguments.
|
|
980
|
+
*
|
|
981
|
+
* The first value in the arguments array is the program to run.
|
|
982
|
+
*/
|
|
803
983
|
declare const exec: Exec;
|
|
804
984
|
|
|
805
985
|
/** Alias for `exec(args, { captureOutput: true })` */
|
|
806
|
-
declare function $(args: Array<string> | string): {
|
|
986
|
+
declare function $(args: Array<string | Path | number> | string | Path): {
|
|
807
987
|
stdout: string;
|
|
808
988
|
stderr: string;
|
|
809
989
|
};
|
|
@@ -817,7 +997,7 @@ declare interface ChildProcess {
|
|
|
817
997
|
args: Array<string>;
|
|
818
998
|
|
|
819
999
|
/** The current working directory for the process. */
|
|
820
|
-
cwd:
|
|
1000
|
+
cwd: Path;
|
|
821
1001
|
|
|
822
1002
|
/** The environment variables for the process. */
|
|
823
1003
|
env: { [key: string]: string };
|
|
@@ -836,12 +1016,6 @@ declare interface ChildProcess {
|
|
|
836
1016
|
err: FILE;
|
|
837
1017
|
};
|
|
838
1018
|
|
|
839
|
-
/**
|
|
840
|
-
* Optional trace function which, if present, will be called at various times
|
|
841
|
-
* to provide information about the lifecycle of the process.
|
|
842
|
-
*/
|
|
843
|
-
trace?: (...args: Array<any>) => void;
|
|
844
|
-
|
|
845
1019
|
pid: number | null;
|
|
846
1020
|
|
|
847
1021
|
/** Spawns the process and returns its pid (process id). */
|
|
@@ -859,7 +1033,7 @@ declare interface ChildProcess {
|
|
|
859
1033
|
*/
|
|
860
1034
|
declare type ChildProcessOptions = {
|
|
861
1035
|
/** The current working directory for the process. */
|
|
862
|
-
cwd?: string;
|
|
1036
|
+
cwd?: string | Path;
|
|
863
1037
|
|
|
864
1038
|
/** The environment variables for the process. */
|
|
865
1039
|
env?: { [key: string]: string };
|
|
@@ -878,11 +1052,17 @@ declare type ChildProcessOptions = {
|
|
|
878
1052
|
err?: FILE;
|
|
879
1053
|
};
|
|
880
1054
|
|
|
881
|
-
/**
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
1055
|
+
/** Options which control logging */
|
|
1056
|
+
logging?: {
|
|
1057
|
+
/**
|
|
1058
|
+
* Optional trace function which, if present, will be called at various
|
|
1059
|
+
* times to provide information about the lifecycle of the process.
|
|
1060
|
+
*
|
|
1061
|
+
* Defaults to the current value of {@link logger.trace}. `logger.trace`
|
|
1062
|
+
* defaults to a function which writes to stderr.
|
|
1063
|
+
*/
|
|
1064
|
+
trace?: (...args: Array<any>) => void;
|
|
1065
|
+
};
|
|
886
1066
|
};
|
|
887
1067
|
|
|
888
1068
|
declare interface ChildProcessConstructor {
|
|
@@ -893,7 +1073,7 @@ declare interface ChildProcessConstructor {
|
|
|
893
1073
|
* @param options - Options for the process (cwd, env, stdio, etc)
|
|
894
1074
|
*/
|
|
895
1075
|
new (
|
|
896
|
-
args: string | Array<string>,
|
|
1076
|
+
args: string | Path | Array<string | number | Path>,
|
|
897
1077
|
options?: ChildProcessOptions
|
|
898
1078
|
): ChildProcess;
|
|
899
1079
|
|
|
@@ -914,18 +1094,35 @@ declare type GlobOptions = {
|
|
|
914
1094
|
*/
|
|
915
1095
|
followSymlinks?: boolean;
|
|
916
1096
|
|
|
917
|
-
/**
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
trace
|
|
928
|
-
|
|
1097
|
+
/** Options which control logging. */
|
|
1098
|
+
logging?: {
|
|
1099
|
+
/**
|
|
1100
|
+
* If provided, this function will be called multiple times as `glob`
|
|
1101
|
+
* traverses the filesystem, to help you understand what's going on and/or
|
|
1102
|
+
* troubleshoot things. In most cases, it makes sense to use a logging
|
|
1103
|
+
* function here, like so:
|
|
1104
|
+
*
|
|
1105
|
+
* ```js
|
|
1106
|
+
* glob(["./*.js"], {
|
|
1107
|
+
* logging: { trace: console.log }
|
|
1108
|
+
* });
|
|
1109
|
+
* ```
|
|
1110
|
+
*
|
|
1111
|
+
* Defaults to the current value of {@link logger.trace}. `logger.trace`
|
|
1112
|
+
* defaults to a no-op function.
|
|
1113
|
+
*/
|
|
1114
|
+
trace?: (...args: Array<any>) => void;
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* An optional, user-provided logging function to be used for informational
|
|
1118
|
+
* messages. Less verbose than `logging.trace`.
|
|
1119
|
+
*
|
|
1120
|
+
* Defaults to the current value of {@link logger.info}. `logger.info`
|
|
1121
|
+
* defaults to a function which writes to stderr.
|
|
1122
|
+
*/
|
|
1123
|
+
info?: (...args: Array<any>) => void;
|
|
1124
|
+
};
|
|
1125
|
+
|
|
929
1126
|
/**
|
|
930
1127
|
* Directory to interpret glob patterns relative to. Defaults to `pwd()`.
|
|
931
1128
|
*/
|
|
@@ -956,73 +1153,73 @@ interface Console {
|
|
|
956
1153
|
/**
|
|
957
1154
|
* Remove ANSI control characters from a string.
|
|
958
1155
|
*/
|
|
959
|
-
declare function stripAnsi(input: string): string;
|
|
1156
|
+
declare function stripAnsi(input: string | number | Path): string;
|
|
960
1157
|
|
|
961
1158
|
/**
|
|
962
1159
|
* Wrap a string in double quotes, and escape any double-quotes inside using `\"`.
|
|
963
1160
|
*/
|
|
964
|
-
declare function quote(input: string): string;
|
|
1161
|
+
declare function quote(input: string | number | Path): string;
|
|
965
1162
|
|
|
966
1163
|
// Colors
|
|
967
1164
|
|
|
968
1165
|
/** Wrap a string with the ANSI control characters that will make it print as black text. */
|
|
969
|
-
declare function black(input: string | number): string;
|
|
1166
|
+
declare function black(input: string | number | Path): string;
|
|
970
1167
|
/** Wrap a string with the ANSI control characters that will make it print as red text. */
|
|
971
|
-
declare function red(input: string | number): string;
|
|
1168
|
+
declare function red(input: string | number | Path): string;
|
|
972
1169
|
/** Wrap a string with the ANSI control characters that will make it print as green text. */
|
|
973
|
-
declare function green(input: string | number): string;
|
|
1170
|
+
declare function green(input: string | number | Path): string;
|
|
974
1171
|
/** Wrap a string with the ANSI control characters that will make it print as yellow text. */
|
|
975
|
-
declare function yellow(input: string | number): string;
|
|
1172
|
+
declare function yellow(input: string | number | Path): string;
|
|
976
1173
|
/** Wrap a string with the ANSI control characters that will make it print as blue text. */
|
|
977
|
-
declare function blue(input: string | number): string;
|
|
1174
|
+
declare function blue(input: string | number | Path): string;
|
|
978
1175
|
/** Wrap a string with the ANSI control characters that will make it print as magenta text. */
|
|
979
|
-
declare function magenta(input: string | number): string;
|
|
1176
|
+
declare function magenta(input: string | number | Path): string;
|
|
980
1177
|
/** Wrap a string with the ANSI control characters that will make it print as cyan text. */
|
|
981
|
-
declare function cyan(input: string | number): string;
|
|
1178
|
+
declare function cyan(input: string | number | Path): string;
|
|
982
1179
|
/** Wrap a string with the ANSI control characters that will make it print as white text. */
|
|
983
|
-
declare function white(input: string | number): string;
|
|
1180
|
+
declare function white(input: string | number | Path): string;
|
|
984
1181
|
/** Wrap a string with the ANSI control characters that will make it print as gray text. */
|
|
985
|
-
declare function gray(input: string | number): string;
|
|
1182
|
+
declare function gray(input: string | number | Path): string;
|
|
986
1183
|
/** Wrap a string with the ANSI control characters that will make it print as grey text. */
|
|
987
|
-
declare function grey(input: string | number): string;
|
|
1184
|
+
declare function grey(input: string | number | Path): string;
|
|
988
1185
|
|
|
989
1186
|
// Background Colors
|
|
990
1187
|
|
|
991
1188
|
/** Wrap a string with the ANSI control characters that will make it have a black background. */
|
|
992
|
-
declare function bgBlack(input: string | number): string;
|
|
1189
|
+
declare function bgBlack(input: string | number | Path): string;
|
|
993
1190
|
/** Wrap a string with the ANSI control characters that will make it have a red background. */
|
|
994
|
-
declare function bgRed(input: string | number): string;
|
|
1191
|
+
declare function bgRed(input: string | number | Path): string;
|
|
995
1192
|
/** Wrap a string with the ANSI control characters that will make it have a green background. */
|
|
996
|
-
declare function bgGreen(input: string | number): string;
|
|
1193
|
+
declare function bgGreen(input: string | number | Path): string;
|
|
997
1194
|
/** Wrap a string with the ANSI control characters that will make it have a yellow background. */
|
|
998
|
-
declare function bgYellow(input: string | number): string;
|
|
1195
|
+
declare function bgYellow(input: string | number | Path): string;
|
|
999
1196
|
/** Wrap a string with the ANSI control characters that will make it have a blue background. */
|
|
1000
|
-
declare function bgBlue(input: string | number): string;
|
|
1197
|
+
declare function bgBlue(input: string | number | Path): string;
|
|
1001
1198
|
/** Wrap a string with the ANSI control characters that will make it have a magenta background. */
|
|
1002
|
-
declare function bgMagenta(input: string | number): string;
|
|
1199
|
+
declare function bgMagenta(input: string | number | Path): string;
|
|
1003
1200
|
/** Wrap a string with the ANSI control characters that will make it have a cyan background. */
|
|
1004
|
-
declare function bgCyan(input: string | number): string;
|
|
1201
|
+
declare function bgCyan(input: string | number | Path): string;
|
|
1005
1202
|
/** Wrap a string with the ANSI control characters that will make it have a white background. */
|
|
1006
|
-
declare function bgWhite(input: string | number): string;
|
|
1203
|
+
declare function bgWhite(input: string | number | Path): string;
|
|
1007
1204
|
|
|
1008
1205
|
// Modifiers
|
|
1009
1206
|
|
|
1010
1207
|
/** Wrap a string with the ANSI control character that resets all styling. */
|
|
1011
|
-
declare function reset(input: string | number): string;
|
|
1208
|
+
declare function reset(input: string | number | Path): string;
|
|
1012
1209
|
/** Wrap a string with the ANSI control characters that will make it print with a bold style. */
|
|
1013
|
-
declare function bold(input: string | number): string;
|
|
1210
|
+
declare function bold(input: string | number | Path): string;
|
|
1014
1211
|
/** Wrap a string with the ANSI control characters that will make it print with a dimmed style. */
|
|
1015
|
-
declare function dim(input: string | number): string;
|
|
1212
|
+
declare function dim(input: string | number | Path): string;
|
|
1016
1213
|
/** Wrap a string with the ANSI control characters that will make it print italicized. */
|
|
1017
|
-
declare function italic(input: string | number): string;
|
|
1214
|
+
declare function italic(input: string | number | Path): string;
|
|
1018
1215
|
/** Wrap a string with the ANSI control characters that will make it print underlined. */
|
|
1019
|
-
declare function underline(input: string | number): string;
|
|
1216
|
+
declare function underline(input: string | number | Path): string;
|
|
1020
1217
|
/** Wrap a string with ANSI control characters such that its foreground (text) and background colors are swapped. */
|
|
1021
|
-
declare function inverse(input: string | number): string;
|
|
1218
|
+
declare function inverse(input: string | number | Path): string;
|
|
1022
1219
|
/** Wrap a string with ANSI control characters such that it is hidden. */
|
|
1023
|
-
declare function hidden(input: string | number): string;
|
|
1220
|
+
declare function hidden(input: string | number | Path): string;
|
|
1024
1221
|
/** Wrap a string with the ANSI control characters that will make it print with a horizontal line through its center. */
|
|
1025
|
-
declare function strikethrough(input: string | number): string;
|
|
1222
|
+
declare function strikethrough(input: string | number | Path): string;
|
|
1026
1223
|
|
|
1027
1224
|
/** Split `str` on newline and then return lines matching `pattern`. */
|
|
1028
1225
|
declare const grepString: {
|
|
@@ -1418,17 +1615,9 @@ declare const types: {
|
|
|
1418
1615
|
exactSymbol<T extends symbol>(sym: T): TypeValidator<T>;
|
|
1419
1616
|
hasClassName<Name extends string>(
|
|
1420
1617
|
name: Name
|
|
1421
|
-
): TypeValidator<{
|
|
1422
|
-
constructor: Function & {
|
|
1423
|
-
name: Name;
|
|
1424
|
-
};
|
|
1425
|
-
}>;
|
|
1618
|
+
): TypeValidator<{ constructor: Function & { name: Name } }>;
|
|
1426
1619
|
hasToStringTag(name: string): TypeValidator<any>;
|
|
1427
|
-
instanceOf<
|
|
1428
|
-
Klass extends Function & {
|
|
1429
|
-
prototype: any;
|
|
1430
|
-
}
|
|
1431
|
-
>(
|
|
1620
|
+
instanceOf<Klass extends Function & { prototype: any }>(
|
|
1432
1621
|
klass: Klass
|
|
1433
1622
|
): TypeValidator<Klass["prototype"]>;
|
|
1434
1623
|
stringMatching(regexp: RegExp): TypeValidator<string>;
|
|
@@ -2546,7 +2735,6 @@ declare const types: {
|
|
|
2546
2735
|
) => TypeValidator<UnwrapTypeFromCoerceableOrValidator<V>>;
|
|
2547
2736
|
|
|
2548
2737
|
FILE: TypeValidator<FILE>;
|
|
2549
|
-
Module: TypeValidator<{ [key: string]: unknown }>;
|
|
2550
2738
|
Path: TypeValidator<Path>;
|
|
2551
2739
|
JSX: {
|
|
2552
2740
|
unknownElement: TypeValidator<
|
|
@@ -2560,11 +2748,21 @@ declare const types: {
|
|
|
2560
2748
|
};
|
|
2561
2749
|
};
|
|
2562
2750
|
|
|
2751
|
+
/**
|
|
2752
|
+
* Returns whether `value` is of type `type`. Useful for validating that values have the correct type at runtime, in library functions or etc.
|
|
2753
|
+
*
|
|
2754
|
+
* Run `help(is)` for more info.
|
|
2755
|
+
*/
|
|
2563
2756
|
declare const is: <T extends TypeValidator<any> | CoerceableToTypeValidator>(
|
|
2564
2757
|
value: any,
|
|
2565
2758
|
type: T
|
|
2566
2759
|
) => value is UnwrapTypeFromCoerceableOrValidator<T>;
|
|
2567
2760
|
|
|
2761
|
+
/**
|
|
2762
|
+
* Alias to {@link is}, for Civet, because `is` is a reserved keyword in Civet.
|
|
2763
|
+
*/
|
|
2764
|
+
declare const _is: typeof is;
|
|
2765
|
+
|
|
2568
2766
|
declare const assert: {
|
|
2569
2767
|
/**
|
|
2570
2768
|
* Throws an error if `value` is not truthy.
|
|
@@ -2591,83 +2789,6 @@ declare const assert: {
|
|
|
2591
2789
|
) => asserts value is UnwrapTypeFromCoerceableOrValidator<T>;
|
|
2592
2790
|
};
|
|
2593
2791
|
|
|
2594
|
-
/**
|
|
2595
|
-
* The data source of a pipe operation; either an in-memory object, or a
|
|
2596
|
-
* file stream.
|
|
2597
|
-
*
|
|
2598
|
-
* - Use `maxLength` to limit how much data to read.
|
|
2599
|
-
* - Use `until` to stop reading once a certain byte or character has been
|
|
2600
|
-
* read.
|
|
2601
|
-
* - Use `path` or `fd` to open a file (or pass a FILE or Path object).
|
|
2602
|
-
*/
|
|
2603
|
-
declare type PipeSource =
|
|
2604
|
-
| { data: string; maxLength?: number; until?: string | byte }
|
|
2605
|
-
| ArrayBuffer
|
|
2606
|
-
| { data: ArrayBuffer; maxLength?: number; until?: string | byte }
|
|
2607
|
-
| SharedArrayBuffer
|
|
2608
|
-
| { data: SharedArrayBuffer; maxLength?: number; until?: string | byte }
|
|
2609
|
-
| TypedArray
|
|
2610
|
-
| { data: TypedArray; maxLength?: number; until?: string | byte }
|
|
2611
|
-
| DataView
|
|
2612
|
-
| { data: DataView; maxLength?: number; until?: string | byte }
|
|
2613
|
-
| FILE
|
|
2614
|
-
| { data: FILE; maxLength?: number; until?: string | byte }
|
|
2615
|
-
| Path
|
|
2616
|
-
| { path: Path | string; maxLength?: number; until?: string | byte }
|
|
2617
|
-
| { fd: number; maxLength?: number; until?: string | byte };
|
|
2618
|
-
|
|
2619
|
-
/**
|
|
2620
|
-
* The target destination of a pipe operation; either an in-memory object, or a
|
|
2621
|
-
* file stream.
|
|
2622
|
-
*
|
|
2623
|
-
* - Use `intoExisting` to put data into an existing object or file handle.
|
|
2624
|
-
* - Use `intoNew` to put data into a new object.
|
|
2625
|
-
* - Use `path` or `fd` to create a new file handle and put data into it.
|
|
2626
|
-
*/
|
|
2627
|
-
declare type PipeDestination =
|
|
2628
|
-
| ArrayBuffer
|
|
2629
|
-
| SharedArrayBuffer
|
|
2630
|
-
| DataView
|
|
2631
|
-
| TypedArray
|
|
2632
|
-
| Path
|
|
2633
|
-
| FILE
|
|
2634
|
-
| ArrayBufferConstructor
|
|
2635
|
-
| SharedArrayBufferConstructor
|
|
2636
|
-
| DataViewConstructor
|
|
2637
|
-
| TypedArrayConstructor
|
|
2638
|
-
| StringConstructor
|
|
2639
|
-
| { path: string }
|
|
2640
|
-
| { fd: number };
|
|
2641
|
-
|
|
2642
|
-
/**
|
|
2643
|
-
* Copy data from one source into the given target. Returns the number of bytes
|
|
2644
|
-
* written, and the target that data was written into.
|
|
2645
|
-
*/
|
|
2646
|
-
declare function pipe<Dest extends PipeDestination>(
|
|
2647
|
-
from: PipeSource,
|
|
2648
|
-
to: Dest
|
|
2649
|
-
): {
|
|
2650
|
-
bytesTransferred: number;
|
|
2651
|
-
target: Dest extends
|
|
2652
|
-
| ArrayBuffer
|
|
2653
|
-
| SharedArrayBuffer
|
|
2654
|
-
| DataView
|
|
2655
|
-
| FILE
|
|
2656
|
-
| { path: string }
|
|
2657
|
-
| { fd: number }
|
|
2658
|
-
? Dest
|
|
2659
|
-
: Dest extends
|
|
2660
|
-
| ArrayBufferConstructor
|
|
2661
|
-
| SharedArrayBufferConstructor
|
|
2662
|
-
| DataViewConstructor
|
|
2663
|
-
| TypedArrayConstructor
|
|
2664
|
-
| DataViewConstructor
|
|
2665
|
-
? Dest["prototype"]
|
|
2666
|
-
: Dest extends StringConstructor
|
|
2667
|
-
? string
|
|
2668
|
-
: never;
|
|
2669
|
-
};
|
|
2670
|
-
|
|
2671
2792
|
interface InteractivePrompt {
|
|
2672
2793
|
prompt?: () => string;
|
|
2673
2794
|
printInput?: (input: string) => void;
|
|
@@ -2729,6 +2850,7 @@ declare const startRepl: {
|
|
|
2729
2850
|
| "tsx"
|
|
2730
2851
|
| "coffee"
|
|
2731
2852
|
| "coffeescript"
|
|
2853
|
+
| "civet"
|
|
2732
2854
|
): void;
|
|
2733
2855
|
|
|
2734
2856
|
/**
|
|
@@ -2796,31 +2918,38 @@ declare class GitRepo {
|
|
|
2796
2918
|
}
|
|
2797
2919
|
|
|
2798
2920
|
/**
|
|
2799
|
-
*
|
|
2800
|
-
*
|
|
2921
|
+
* The logger used internally by yavascript API functions such as {@link which},
|
|
2922
|
+
* {@link exec}, {@link copy}, {@link glob}, and more.
|
|
2801
2923
|
*
|
|
2802
|
-
*
|
|
2803
|
-
*
|
|
2804
|
-
* - If called with `false`, the default value of `trace` in all functions which
|
|
2805
|
-
* receive a `trace` option will be changed to `undefined`.
|
|
2806
|
-
* - If called with any other value, the provided value will be used as the
|
|
2807
|
-
* default value of `trace` in all functions which receive a `trace` option.
|
|
2924
|
+
* You can modify the properties on this object in order to configure the
|
|
2925
|
+
* amount and style of log output from yavascript API functions.
|
|
2808
2926
|
*
|
|
2809
|
-
*
|
|
2810
|
-
* `trace` as set by this function (in order to get the same behavior as
|
|
2811
|
-
* yavascript API functions which do so), call `traceAll.getDefaultTrace()` to
|
|
2812
|
-
* get the value which should be used as the default value.
|
|
2927
|
+
* This object behaves similarly to the shell builtin `set -x`.
|
|
2813
2928
|
*/
|
|
2814
|
-
declare const
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2929
|
+
declare const logger: {
|
|
2930
|
+
/**
|
|
2931
|
+
* This property is used as the default value for `trace` in yavascript API
|
|
2932
|
+
* functions which receive `logging.trace` as an option, like {@link which},
|
|
2933
|
+
* {@link exec}, {@link copy} and {@link glob}.
|
|
2934
|
+
*
|
|
2935
|
+
* The default value of `logger.trace` is a no-op function.
|
|
2936
|
+
*/
|
|
2937
|
+
trace: (...args: Array<any>) => void;
|
|
2938
|
+
|
|
2939
|
+
/**
|
|
2940
|
+
* This property is used as the default value for `info` in yavascript API
|
|
2941
|
+
* functions which receive `logging.info` as an option, like {@link exec},
|
|
2942
|
+
* {@link copy}, and {@link glob}.
|
|
2943
|
+
*
|
|
2944
|
+
* The default value of `logger.info` writes dimmed text to stdout.
|
|
2945
|
+
*/
|
|
2946
|
+
info: (...args: Array<any>) => void;
|
|
2818
2947
|
};
|
|
2819
2948
|
|
|
2820
2949
|
declare namespace JSX {
|
|
2821
2950
|
/**
|
|
2822
2951
|
* A string containing the expression that should be called to create JSX
|
|
2823
|
-
* elements.
|
|
2952
|
+
* elements. yavascript's internals use this string to transpile JSX syntax.
|
|
2824
2953
|
*
|
|
2825
2954
|
* Defaults to "JSX.createElement".
|
|
2826
2955
|
*
|
|
@@ -2840,7 +2969,8 @@ declare namespace JSX {
|
|
|
2840
2969
|
|
|
2841
2970
|
/**
|
|
2842
2971
|
* A string containing the expression that should be used as the first
|
|
2843
|
-
* parameter when creating JSX fragment elements.
|
|
2972
|
+
* parameter when creating JSX fragment elements. yavascript's internals use
|
|
2973
|
+
* this string to transpile JSX syntax.
|
|
2844
2974
|
*
|
|
2845
2975
|
* Defaults to "JSX.Fragment".
|
|
2846
2976
|
*
|
|
@@ -2880,10 +3010,19 @@ declare namespace JSX {
|
|
|
2880
3010
|
export type Fragment = Element<{}, typeof Fragment>;
|
|
2881
3011
|
|
|
2882
3012
|
/**
|
|
2883
|
-
* The JSX element
|
|
3013
|
+
* The JSX element builder function, which gets invoked whenever JSX syntax is
|
|
2884
3014
|
* used (unless {@link JSX.pragma} is changed).
|
|
3015
|
+
*
|
|
3016
|
+
* Note that if you change this, you need to verify that the following
|
|
3017
|
+
* expression always evaluates to `true` (by changing {@link types.JSX.Element}
|
|
3018
|
+
* and {@link types.JSX.Fragment}):
|
|
3019
|
+
* ```jsx
|
|
3020
|
+
* types.JSX.Element(<a />) && types.JSX.Fragment(<></>)
|
|
3021
|
+
* ```
|
|
3022
|
+
*
|
|
3023
|
+
* Failure to uphold this guarantee indicates a bug.
|
|
2885
3024
|
*/
|
|
2886
|
-
export
|
|
3025
|
+
export let createElement: {
|
|
2887
3026
|
<Type extends string | typeof Fragment | ((...args: any) => any)>(
|
|
2888
3027
|
type: Type
|
|
2889
3028
|
): Element<{}, Type>;
|
|
@@ -2955,11 +3094,66 @@ declare const CSV: {
|
|
|
2955
3094
|
stringify(input: Array<Array<string>>): string;
|
|
2956
3095
|
};
|
|
2957
3096
|
|
|
3097
|
+
declare var TOML: {
|
|
3098
|
+
/**
|
|
3099
|
+
* Parse a TOML document (`data`) into an object.
|
|
3100
|
+
*/
|
|
3101
|
+
parse(data: string): { [key: string]: any };
|
|
3102
|
+
/**
|
|
3103
|
+
* Convert an object into a TOML document.
|
|
3104
|
+
*/
|
|
3105
|
+
stringify(data: { [key: string]: any }): string;
|
|
3106
|
+
};
|
|
3107
|
+
|
|
2958
3108
|
interface RegExpConstructor {
|
|
2959
3109
|
/** See https://github.com/tc39/proposal-regex-escaping */
|
|
2960
3110
|
escape(str: any): string;
|
|
2961
3111
|
}
|
|
2962
3112
|
|
|
3113
|
+
interface StringConstructor {
|
|
3114
|
+
/**
|
|
3115
|
+
* Remove leading minimum indentation from the string.
|
|
3116
|
+
* The first line of the string must be empty.
|
|
3117
|
+
*
|
|
3118
|
+
* https://github.com/tc39/proposal-string-dedent
|
|
3119
|
+
*/
|
|
3120
|
+
dedent: {
|
|
3121
|
+
/**
|
|
3122
|
+
* Remove leading minimum indentation from the string.
|
|
3123
|
+
* The first line of the string must be empty.
|
|
3124
|
+
*
|
|
3125
|
+
* https://github.com/tc39/proposal-string-dedent
|
|
3126
|
+
*/
|
|
3127
|
+
(input: string): string;
|
|
3128
|
+
|
|
3129
|
+
/**
|
|
3130
|
+
* Remove leading minimum indentation from the template literal.
|
|
3131
|
+
* The first line of the string must be empty.
|
|
3132
|
+
*
|
|
3133
|
+
* https://github.com/tc39/proposal-string-dedent
|
|
3134
|
+
*/
|
|
3135
|
+
(
|
|
3136
|
+
strings: readonly string[] | ArrayLike<string>,
|
|
3137
|
+
...substitutions: unknown[]
|
|
3138
|
+
): string;
|
|
3139
|
+
|
|
3140
|
+
/**
|
|
3141
|
+
* Wrap another template tag function such that tagged literals
|
|
3142
|
+
* become dedented before being passed to the wrapped function.
|
|
3143
|
+
*
|
|
3144
|
+
* https://www.npmjs.com/package/string-dedent#usage
|
|
3145
|
+
*/
|
|
3146
|
+
<
|
|
3147
|
+
Func extends (
|
|
3148
|
+
strings: readonly string[] | ArrayLike<string>,
|
|
3149
|
+
...substitutions: any[]
|
|
3150
|
+
) => string
|
|
3151
|
+
>(
|
|
3152
|
+
input: Func
|
|
3153
|
+
): Func;
|
|
3154
|
+
};
|
|
3155
|
+
}
|
|
3156
|
+
|
|
2963
3157
|
// prettier-ignore
|
|
2964
3158
|
/** Any integer in the range [0, 255]. */
|
|
2965
3159
|
declare type byte =
|
|
@@ -3008,6 +3202,10 @@ declare type TypedArrayConstructor =
|
|
|
3008
3202
|
| Float32ArrayConstructor
|
|
3009
3203
|
| Float64ArrayConstructor;
|
|
3010
3204
|
|
|
3205
|
+
interface ErrorOptions {
|
|
3206
|
+
[key: string]: any;
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3011
3209
|
// ==========================================
|
|
3012
3210
|
// ------------------------------------------
|
|
3013
3211
|
// QuickJS APIs, which YavaScript builds upon
|
|
@@ -3034,6 +3232,18 @@ interface ObjectConstructor {
|
|
|
3034
3232
|
isPrimitive(input: any): boolean;
|
|
3035
3233
|
}
|
|
3036
3234
|
|
|
3235
|
+
interface StringConstructor {
|
|
3236
|
+
/**
|
|
3237
|
+
* A no-op template literal tag.
|
|
3238
|
+
*
|
|
3239
|
+
* https://github.com/tc39/proposal-string-cooked
|
|
3240
|
+
*/
|
|
3241
|
+
cooked(
|
|
3242
|
+
strings: readonly string[] | ArrayLike<string>,
|
|
3243
|
+
...substitutions: any[]
|
|
3244
|
+
): string;
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3037
3247
|
interface SymbolConstructor {
|
|
3038
3248
|
/**
|
|
3039
3249
|
* A method that changes the result of using the `typeof` operator on the
|
|
@@ -3873,13 +4083,6 @@ interface BigDecimal {
|
|
|
3873
4083
|
// TypeScript will not understand or handle unary/binary operators for BigFloat
|
|
3874
4084
|
// and BigDecimal properly.
|
|
3875
4085
|
|
|
3876
|
-
// Definitions of the globals and modules added by quickjs-libc
|
|
3877
|
-
|
|
3878
|
-
/**
|
|
3879
|
-
* Provides the command line arguments. The first argument is the script name.
|
|
3880
|
-
*/
|
|
3881
|
-
declare var scriptArgs: Array<string>;
|
|
3882
|
-
|
|
3883
4086
|
/**
|
|
3884
4087
|
* Print the arguments separated by spaces and a trailing newline.
|
|
3885
4088
|
*
|
|
@@ -3907,6 +4110,163 @@ interface Console {
|
|
|
3907
4110
|
|
|
3908
4111
|
declare var console: Console;
|
|
3909
4112
|
|
|
4113
|
+
/** npm: @suchipi/print@2.5.0. License: ISC */
|
|
4114
|
+
/* (with some QuickJS-specific modifications) */
|
|
4115
|
+
|
|
4116
|
+
/*
|
|
4117
|
+
Copyright (c) 2016-2022, John Gardner
|
|
4118
|
+
Copyright (c) 2022 Lily Skye
|
|
4119
|
+
|
|
4120
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4121
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
4122
|
+
copyright notice and this permission notice appear in all copies.
|
|
4123
|
+
|
|
4124
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
4125
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
4126
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
4127
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
4128
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
4129
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
4130
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
4131
|
+
*/
|
|
4132
|
+
|
|
4133
|
+
/**
|
|
4134
|
+
* Options for {@link inspect}.
|
|
4135
|
+
*/
|
|
4136
|
+
declare interface InspectOptions {
|
|
4137
|
+
/** Whether to display non-enumerable properties. Defaults to false. */
|
|
4138
|
+
all?: boolean;
|
|
4139
|
+
|
|
4140
|
+
/** Whether to invoke getter functions. Defaults to false. */
|
|
4141
|
+
followGetters?: boolean;
|
|
4142
|
+
|
|
4143
|
+
/** Whether to display the indexes of iterable entries. Defaults to false. */
|
|
4144
|
+
indexes?: boolean;
|
|
4145
|
+
|
|
4146
|
+
/** Hide object details after 𝑁 recursions. Defaults to Infinity. */
|
|
4147
|
+
maxDepth?: number;
|
|
4148
|
+
|
|
4149
|
+
/** If true, don't identify well-known symbols as `@@…`. Defaults to false. */
|
|
4150
|
+
noAmp?: boolean;
|
|
4151
|
+
|
|
4152
|
+
/** If true, don't format byte-arrays as hexadecimal. Defaults to false. */
|
|
4153
|
+
noHex?: boolean;
|
|
4154
|
+
|
|
4155
|
+
/** If true, don't display function source code. Defaults to false. */
|
|
4156
|
+
noSource?: boolean;
|
|
4157
|
+
|
|
4158
|
+
/** Whether to show `__proto__` properties if possible. Defaults to false. */
|
|
4159
|
+
proto?: boolean;
|
|
4160
|
+
|
|
4161
|
+
/** Whether to sort properties alphabetically. When false, properties are sorted by creation order. Defaults to false. */
|
|
4162
|
+
sort?: boolean;
|
|
4163
|
+
|
|
4164
|
+
/** Options that control whether and how ANSI terminal escape sequences for colours should be added to the output. Defaults to false, meaning no colours. */
|
|
4165
|
+
colours?: boolean | 256 | 8 | InspectColours;
|
|
4166
|
+
|
|
4167
|
+
/** Prefix string to use for indentation. Defaults to '\t'. */
|
|
4168
|
+
indent?: string;
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
declare interface InspectColours {
|
|
4172
|
+
off?: string | number;
|
|
4173
|
+
red?: string | number;
|
|
4174
|
+
grey?: string | number;
|
|
4175
|
+
green?: string | number;
|
|
4176
|
+
darkGreen?: string | number;
|
|
4177
|
+
punct?: string | number;
|
|
4178
|
+
keys?: string | number;
|
|
4179
|
+
keyEscape?: string | number;
|
|
4180
|
+
typeColour?: string | number;
|
|
4181
|
+
primitive?: string | number;
|
|
4182
|
+
escape?: string | number;
|
|
4183
|
+
date?: string | number;
|
|
4184
|
+
hexBorder?: string | number;
|
|
4185
|
+
hexValue?: string | number;
|
|
4186
|
+
hexOffset?: string | number;
|
|
4187
|
+
reference?: string | number;
|
|
4188
|
+
srcBorder?: string | number;
|
|
4189
|
+
srcRowNum?: string | number;
|
|
4190
|
+
srcRowText?: string | number;
|
|
4191
|
+
nul?: string | number;
|
|
4192
|
+
nulProt?: string | number;
|
|
4193
|
+
undef?: string | number;
|
|
4194
|
+
noExts?: string | number;
|
|
4195
|
+
frozen?: string | number;
|
|
4196
|
+
sealed?: string | number;
|
|
4197
|
+
regex?: string | number;
|
|
4198
|
+
string?: string | number;
|
|
4199
|
+
symbol?: string | number;
|
|
4200
|
+
symbolFade?: string | number;
|
|
4201
|
+
braces?: string | number;
|
|
4202
|
+
quotes?: string | number;
|
|
4203
|
+
empty?: string | number;
|
|
4204
|
+
dot?: string | number;
|
|
4205
|
+
}
|
|
4206
|
+
|
|
4207
|
+
declare interface InspectFunction {
|
|
4208
|
+
/**
|
|
4209
|
+
* Generate a human-readable representation of a value.
|
|
4210
|
+
*
|
|
4211
|
+
* @param value - Value to inspect
|
|
4212
|
+
* @param options - Additional settings for refining output
|
|
4213
|
+
* @returns A string representation of `value`.
|
|
4214
|
+
*/
|
|
4215
|
+
(value: any, options?: InspectOptions): string;
|
|
4216
|
+
|
|
4217
|
+
/**
|
|
4218
|
+
* Generate a human-readable representation of a value.
|
|
4219
|
+
*
|
|
4220
|
+
* @param value - Value to inspect
|
|
4221
|
+
* @param key - The value's corresponding member name
|
|
4222
|
+
* @param options - Additional settings for refining output
|
|
4223
|
+
* @returns A string representation of `value`.
|
|
4224
|
+
*/
|
|
4225
|
+
(value: any, key?: string | symbol, options?: InspectOptions): string;
|
|
4226
|
+
|
|
4227
|
+
/**
|
|
4228
|
+
* A symbol which can be used to customize how an object gets printed.
|
|
4229
|
+
*/
|
|
4230
|
+
custom: symbol;
|
|
4231
|
+
}
|
|
4232
|
+
|
|
4233
|
+
/**
|
|
4234
|
+
* Generate a human-readable representation of a value.
|
|
4235
|
+
*
|
|
4236
|
+
* @param value - Value to inspect
|
|
4237
|
+
* @param key - The value's corresponding member name
|
|
4238
|
+
* @param options - Additional settings for refining output
|
|
4239
|
+
* @returns A string representation of `value`.
|
|
4240
|
+
*/
|
|
4241
|
+
declare var inspect: InspectFunction;
|
|
4242
|
+
|
|
4243
|
+
declare interface InspectCustomInputs {
|
|
4244
|
+
key: string | symbol;
|
|
4245
|
+
type: string;
|
|
4246
|
+
brackets: [string, string];
|
|
4247
|
+
oneLine: boolean;
|
|
4248
|
+
linesBefore: Array<string>;
|
|
4249
|
+
linesAfter: Array<string>;
|
|
4250
|
+
propLines: Array<string>;
|
|
4251
|
+
readonly tooDeep: boolean;
|
|
4252
|
+
indent: string;
|
|
4253
|
+
typeSuffix: string;
|
|
4254
|
+
opts: InspectOptions;
|
|
4255
|
+
colours: { [Key in keyof Required<InspectColours>]: string };
|
|
4256
|
+
}
|
|
4257
|
+
|
|
4258
|
+
declare type Interval = { [Symbol.toStringTag]: "Interval" };
|
|
4259
|
+
|
|
4260
|
+
declare function setInterval(func: (...args: any) => any, ms: number): Interval;
|
|
4261
|
+
declare function clearInterval(interval: Interval): void;
|
|
4262
|
+
|
|
4263
|
+
// Definitions of the globals and modules added by quickjs-libc
|
|
4264
|
+
|
|
4265
|
+
/**
|
|
4266
|
+
* Provides the command line arguments. The first argument is the script name.
|
|
4267
|
+
*/
|
|
4268
|
+
declare var scriptArgs: Array<string>;
|
|
4269
|
+
|
|
3910
4270
|
/** An object representing a file handle. */
|
|
3911
4271
|
declare interface FILE {
|
|
3912
4272
|
/**
|
|
@@ -3974,9 +4334,23 @@ declare interface FILE {
|
|
|
3974
4334
|
write(buffer: ArrayBuffer, position: number, length: number): number;
|
|
3975
4335
|
|
|
3976
4336
|
/**
|
|
3977
|
-
*
|
|
4337
|
+
* Write this file into `target`, using a memory buffer of size `bufferSize`.
|
|
3978
4338
|
*
|
|
3979
|
-
* If
|
|
4339
|
+
* If `limit` is specified, only that amount of bytes will be read and
|
|
4340
|
+
* written. Otherwise, data is read and written until this file reaches EOF.
|
|
4341
|
+
*
|
|
4342
|
+
* A `limit` of 0 is treated the same as not specifying a limit.
|
|
4343
|
+
*
|
|
4344
|
+
* Internally, this function uses libc `fread` and `fwrite` in a loop.
|
|
4345
|
+
*
|
|
4346
|
+
* Returns the number of bytes read and written.
|
|
4347
|
+
*/
|
|
4348
|
+
writeTo(target: FILE, bufferSize: number, limit?: number): number;
|
|
4349
|
+
|
|
4350
|
+
/**
|
|
4351
|
+
* Return the next line from the file, assuming UTF-8 encoding, excluding the trailing line feed or EOF.
|
|
4352
|
+
*
|
|
4353
|
+
* If the end of the file has been reached, then `null` will be returned instead of a string.
|
|
3980
4354
|
*
|
|
3981
4355
|
* Note: Although the trailing line feed has been removed, a carriage return (`\r`) may still be present.
|
|
3982
4356
|
*/
|
|
@@ -4004,54 +4378,42 @@ declare interface FILE {
|
|
|
4004
4378
|
|
|
4005
4379
|
declare module "quickjs:std" {
|
|
4006
4380
|
/**
|
|
4007
|
-
*
|
|
4381
|
+
* Set the exit code that the process should exit with in the future, if it
|
|
4382
|
+
* exits normally.
|
|
4008
4383
|
*
|
|
4009
|
-
*
|
|
4010
|
-
*/
|
|
4011
|
-
export function exit(statusCode: number): void;
|
|
4012
|
-
|
|
4013
|
-
/**
|
|
4014
|
-
* Evaluate the string `code` as a script (global eval).
|
|
4384
|
+
* Can only be called from the main thread.
|
|
4015
4385
|
*
|
|
4016
|
-
*
|
|
4017
|
-
*
|
|
4018
|
-
*
|
|
4019
|
-
*
|
|
4020
|
-
*
|
|
4021
|
-
|
|
4022
|
-
export function evalScript(
|
|
4023
|
-
code: string,
|
|
4024
|
-
options?: { backtraceBarrier?: boolean; filename?: string }
|
|
4025
|
-
): any;
|
|
4026
|
-
|
|
4027
|
-
/**
|
|
4028
|
-
* Evaluate the file `filename` as a script (global eval).
|
|
4386
|
+
* This exit code will only be used if the process exits "normally", ie, when
|
|
4387
|
+
* there are no more pending JS tasks/listeners. If an unhandled exception is
|
|
4388
|
+
* thrown, the process will always exit with status `1`, regardless of the
|
|
4389
|
+
* status code passed to `setExitCode`. If someone calls {@link exit} and
|
|
4390
|
+
* passes in a status code, that status code will take precedence over the
|
|
4391
|
+
* status code passed to `setExitCode`.
|
|
4029
4392
|
*
|
|
4030
|
-
* @param
|
|
4031
|
-
* @returns The result of the evaluation.
|
|
4393
|
+
* @param statusCode The future exit code; 0 for success, nonzero for failure.
|
|
4032
4394
|
*/
|
|
4033
|
-
export function
|
|
4395
|
+
export function setExitCode(statusCode: number): void;
|
|
4034
4396
|
|
|
4035
4397
|
/**
|
|
4036
|
-
*
|
|
4398
|
+
* Return the exit code that was previously set by {@link setExitCode}, or 0 if
|
|
4399
|
+
* it hasn't yet been set.
|
|
4037
4400
|
*
|
|
4038
|
-
*
|
|
4039
|
-
* @param basename - If present and `filename` is a relative path, `filename` will be resolved relative to this basename.
|
|
4040
|
-
* @returns The result of the evaluation (module namespace object).
|
|
4401
|
+
* Can only be called from the main thread.
|
|
4041
4402
|
*/
|
|
4042
|
-
export function
|
|
4043
|
-
filename: string,
|
|
4044
|
-
basename?: string
|
|
4045
|
-
): { [key: string]: any };
|
|
4403
|
+
export function getExitCode(): number;
|
|
4046
4404
|
|
|
4047
4405
|
/**
|
|
4048
|
-
*
|
|
4406
|
+
* Exit the process with the provided status code.
|
|
4049
4407
|
*
|
|
4050
|
-
*
|
|
4051
|
-
*
|
|
4052
|
-
*
|
|
4408
|
+
* Can only be called from the main thread.
|
|
4409
|
+
*
|
|
4410
|
+
* If `statusCode` is not provided, a value previously passed into
|
|
4411
|
+
* {@link setExitCode} will be used. If no value was previously passed into
|
|
4412
|
+
* setExitCode, `0` will be used.
|
|
4413
|
+
*
|
|
4414
|
+
* @param statusCode The exit code; 0 for success, nonzero for failure.
|
|
4053
4415
|
*/
|
|
4054
|
-
export function
|
|
4416
|
+
export function exit(statusCode?: number): never;
|
|
4055
4417
|
|
|
4056
4418
|
/**
|
|
4057
4419
|
* Load the file `filename` and return it as a string assuming UTF-8 encoding.
|
|
@@ -4060,15 +4422,6 @@ declare module "quickjs:std" {
|
|
|
4060
4422
|
*/
|
|
4061
4423
|
export function loadFile(filename: string): string;
|
|
4062
4424
|
|
|
4063
|
-
/**
|
|
4064
|
-
* Read the script of module filename from an active stack frame, then return it as a string.
|
|
4065
|
-
*
|
|
4066
|
-
* If there isn't a valid filename for the specified stack frame, an error will be thrown.
|
|
4067
|
-
*
|
|
4068
|
-
* @param stackLevels - How many levels up the stack to search for a filename. Defaults to 0, which uses the current stack frame.
|
|
4069
|
-
*/
|
|
4070
|
-
export function getFileNameFromStack(stackLevels?: number): string;
|
|
4071
|
-
|
|
4072
4425
|
/**
|
|
4073
4426
|
* Return a boolean indicating whether the provided value is a FILE object.
|
|
4074
4427
|
*
|
|
@@ -4153,9 +4506,6 @@ declare module "quickjs:std" {
|
|
|
4153
4506
|
/** Constant for {@link FILE.setvbuf}. Declares that the buffer mode should be 'no buffering'. */
|
|
4154
4507
|
export var _IONBF: number;
|
|
4155
4508
|
|
|
4156
|
-
/** 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. */
|
|
4157
|
-
export function gc(): void;
|
|
4158
|
-
|
|
4159
4509
|
/** Return the value of the environment variable `name` or `undefined` if it is not defined. */
|
|
4160
4510
|
export function getenv(name: string): string | undefined;
|
|
4161
4511
|
|
|
@@ -4806,7 +5156,7 @@ declare module "quickjs:os" {
|
|
|
4806
5156
|
export function dup2(oldfd: number, newfd: number): number;
|
|
4807
5157
|
|
|
4808
5158
|
/** `pipe` Unix system call. Return two handles as `[read_fd, write_fd]`. */
|
|
4809
|
-
export function pipe():
|
|
5159
|
+
export function pipe(): [number, number];
|
|
4810
5160
|
|
|
4811
5161
|
/** Sleep for `delay_ms` milliseconds. */
|
|
4812
5162
|
export function sleep(delay_ms: number): void;
|
|
@@ -4919,126 +5269,14 @@ declare module "quickjs:os" {
|
|
|
4919
5269
|
export function chmod(path: string, mode: number): void;
|
|
4920
5270
|
}
|
|
4921
5271
|
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
*/
|
|
4925
|
-
declare interface InspectOptions {
|
|
4926
|
-
/** Whether to display non-enumerable properties. Defaults to false. */
|
|
4927
|
-
all?: boolean;
|
|
4928
|
-
|
|
4929
|
-
/** Whether to invoke getter functions. Defaults to false. */
|
|
4930
|
-
followGetters?: boolean;
|
|
4931
|
-
|
|
4932
|
-
/** Whether to display the indexes of iterable entries. Defaults to false. */
|
|
4933
|
-
indexes?: boolean;
|
|
4934
|
-
|
|
4935
|
-
/** Hide object details after 𝑁 recursions. Defaults to Infinity. */
|
|
4936
|
-
maxDepth?: number;
|
|
4937
|
-
|
|
4938
|
-
/** If true, don't identify well-known symbols as `@@…`. Defaults to false. */
|
|
4939
|
-
noAmp?: boolean;
|
|
4940
|
-
|
|
4941
|
-
/** If true, don't format byte-arrays as hexadecimal. Defaults to false. */
|
|
4942
|
-
noHex?: boolean;
|
|
4943
|
-
|
|
4944
|
-
/** If true, don't display function source code. Defaults to false. */
|
|
4945
|
-
noSource?: boolean;
|
|
4946
|
-
|
|
4947
|
-
/** Whether to show `__proto__` properties if possible. Defaults to false. */
|
|
4948
|
-
proto?: boolean;
|
|
4949
|
-
|
|
4950
|
-
/** Whether to sort properties alphabetically. When false, properties are sorted by creation order. Defaults to false. */
|
|
4951
|
-
sort?: boolean;
|
|
4952
|
-
|
|
4953
|
-
/** Options that control whether and how ANSI terminal escape sequences for colours should be added to the output. Defaults to false, meaning no colours. */
|
|
4954
|
-
colours?: boolean | 256 | 8 | InspectColours;
|
|
4955
|
-
|
|
4956
|
-
/** Prefix string to use for indentation. Defaults to '\t'. */
|
|
4957
|
-
indent?: string;
|
|
4958
|
-
}
|
|
4959
|
-
|
|
4960
|
-
declare interface InspectColours {
|
|
4961
|
-
off?: string | number;
|
|
4962
|
-
red?: string | number;
|
|
4963
|
-
grey?: string | number;
|
|
4964
|
-
green?: string | number;
|
|
4965
|
-
darkGreen?: string | number;
|
|
4966
|
-
punct?: string | number;
|
|
4967
|
-
keys?: string | number;
|
|
4968
|
-
keyEscape?: string | number;
|
|
4969
|
-
typeColour?: string | number;
|
|
4970
|
-
primitive?: string | number;
|
|
4971
|
-
escape?: string | number;
|
|
4972
|
-
date?: string | number;
|
|
4973
|
-
hexBorder?: string | number;
|
|
4974
|
-
hexValue?: string | number;
|
|
4975
|
-
hexOffset?: string | number;
|
|
4976
|
-
reference?: string | number;
|
|
4977
|
-
srcBorder?: string | number;
|
|
4978
|
-
srcRowNum?: string | number;
|
|
4979
|
-
srcRowText?: string | number;
|
|
4980
|
-
nul?: string | number;
|
|
4981
|
-
nulProt?: string | number;
|
|
4982
|
-
undef?: string | number;
|
|
4983
|
-
noExts?: string | number;
|
|
4984
|
-
frozen?: string | number;
|
|
4985
|
-
sealed?: string | number;
|
|
4986
|
-
regex?: string | number;
|
|
4987
|
-
string?: string | number;
|
|
4988
|
-
symbol?: string | number;
|
|
4989
|
-
symbolFade?: string | number;
|
|
4990
|
-
braces?: string | number;
|
|
4991
|
-
quotes?: string | number;
|
|
4992
|
-
empty?: string | number;
|
|
4993
|
-
dot?: string | number;
|
|
4994
|
-
}
|
|
4995
|
-
|
|
4996
|
-
declare interface InspectFunction {
|
|
4997
|
-
/**
|
|
4998
|
-
* Generate a human-readable representation of a value.
|
|
4999
|
-
*
|
|
5000
|
-
* @param value - Value to inspect
|
|
5001
|
-
* @param options - Additional settings for refining output
|
|
5002
|
-
* @returns A string representation of `value`.
|
|
5003
|
-
*/
|
|
5004
|
-
(value: any, options?: InspectOptions): string;
|
|
5005
|
-
|
|
5006
|
-
/**
|
|
5007
|
-
* Generate a human-readable representation of a value.
|
|
5008
|
-
*
|
|
5009
|
-
* @param value - Value to inspect
|
|
5010
|
-
* @param key - The value's corresponding member name
|
|
5011
|
-
* @param options - Additional settings for refining output
|
|
5012
|
-
* @returns A string representation of `value`.
|
|
5013
|
-
*/
|
|
5014
|
-
(value: any, key?: string | symbol, options?: InspectOptions): string;
|
|
5015
|
-
}
|
|
5016
|
-
|
|
5017
|
-
/**
|
|
5018
|
-
* Generate a human-readable representation of a value.
|
|
5019
|
-
*
|
|
5020
|
-
* @param value - Value to inspect
|
|
5021
|
-
* @param key - The value's corresponding member name
|
|
5022
|
-
* @param options - Additional settings for refining output
|
|
5023
|
-
* @returns A string representation of `value`.
|
|
5024
|
-
*/
|
|
5025
|
-
declare var inspect: InspectFunction;
|
|
5272
|
+
declare var setTimeout: typeof import("quickjs:os").setTimeout;
|
|
5273
|
+
declare var clearTimeout: typeof import("quickjs:os").clearTimeout;
|
|
5026
5274
|
|
|
5027
5275
|
/**
|
|
5028
|
-
*
|
|
5029
|
-
* You can
|
|
5030
|
-
*
|
|
5031
|
-
* This global can also be used to identify whether an object is a module
|
|
5032
|
-
* namespace record.
|
|
5276
|
+
* An object which lets you configure the module loader (import/export/require).
|
|
5277
|
+
* You can change these properties to add support for importing new filetypes.
|
|
5033
5278
|
*/
|
|
5034
|
-
interface
|
|
5035
|
-
/**
|
|
5036
|
-
* Returns true if `target` is a module namespace object.
|
|
5037
|
-
*/
|
|
5038
|
-
[Symbol.hasInstance](target: any): target is {
|
|
5039
|
-
[key: string | number | symbol]: any;
|
|
5040
|
-
};
|
|
5041
|
-
|
|
5279
|
+
interface ModuleDelegate {
|
|
5042
5280
|
/**
|
|
5043
5281
|
* A list of filetype extensions that may be omitted from an import specifier
|
|
5044
5282
|
* string.
|
|
@@ -5050,7 +5288,7 @@ interface ModuleGlobal {
|
|
|
5050
5288
|
* See the doc comment on {@link require} for more information.
|
|
5051
5289
|
*
|
|
5052
5290
|
* NOTE: If you add a new extension to this array, you will likely also want
|
|
5053
|
-
* to add to {@link
|
|
5291
|
+
* to add to {@link compilers}.
|
|
5054
5292
|
*/
|
|
5055
5293
|
searchExtensions: Array<string>;
|
|
5056
5294
|
|
|
@@ -5077,7 +5315,7 @@ interface ModuleGlobal {
|
|
|
5077
5315
|
* ```js
|
|
5078
5316
|
* import * as std from "std";
|
|
5079
5317
|
*
|
|
5080
|
-
*
|
|
5318
|
+
* ModuleDelegate.compilers[".txt"] = (filename, content) => {
|
|
5081
5319
|
* return `export default ${JSON.stringify(content)}`;
|
|
5082
5320
|
* }
|
|
5083
5321
|
* ```
|
|
@@ -5091,24 +5329,20 @@ interface ModuleGlobal {
|
|
|
5091
5329
|
* And `names` will be a string containing the contents of names.txt.
|
|
5092
5330
|
*
|
|
5093
5331
|
* NOTE: When adding to this object, you may also wish to add to
|
|
5094
|
-
* {@link
|
|
5332
|
+
* {@link searchExtensions}.
|
|
5095
5333
|
*/
|
|
5096
5334
|
compilers: {
|
|
5097
5335
|
[extensionWithDot: string]: (filename: string, content: string) => string;
|
|
5098
5336
|
};
|
|
5099
5337
|
|
|
5100
5338
|
/**
|
|
5101
|
-
*
|
|
5102
|
-
*
|
|
5103
|
-
*/
|
|
5104
|
-
define(name: string, obj: { [key: string]: any }): void;
|
|
5105
|
-
|
|
5106
|
-
/**
|
|
5107
|
-
* Resolves a require/import request from `fromFile` into a canonicalized path.
|
|
5339
|
+
* Resolves a require/import request from `fromFile` into a canonicalized
|
|
5340
|
+
* path.
|
|
5108
5341
|
*
|
|
5109
5342
|
* To change native module resolution behavior, replace this function with
|
|
5110
5343
|
* your own implementation. Note that you must handle
|
|
5111
|
-
* `
|
|
5344
|
+
* `ModuleDelegate.searchExtensions` yourself in your replacement
|
|
5345
|
+
* implementation.
|
|
5112
5346
|
*/
|
|
5113
5347
|
resolve(name: string, fromFile: string): string;
|
|
5114
5348
|
|
|
@@ -5116,14 +5350,12 @@ interface ModuleGlobal {
|
|
|
5116
5350
|
* Reads the contents of the given resolved module name into a string.
|
|
5117
5351
|
*
|
|
5118
5352
|
* To change native module loading behavior, replace this function with your
|
|
5119
|
-
* own implementation. Note that you must handle `
|
|
5120
|
-
* in your replacement implementation.
|
|
5353
|
+
* own implementation. Note that you must handle `ModuleDelegate.compilers`
|
|
5354
|
+
* yourself in your replacement implementation.
|
|
5121
5355
|
*/
|
|
5122
5356
|
read(modulePath: string): string;
|
|
5123
5357
|
}
|
|
5124
5358
|
|
|
5125
|
-
declare var Module: ModuleGlobal;
|
|
5126
|
-
|
|
5127
5359
|
interface RequireFunction {
|
|
5128
5360
|
/**
|
|
5129
5361
|
* Synchronously import a module.
|
|
@@ -5132,8 +5364,8 @@ interface RequireFunction {
|
|
|
5132
5364
|
*
|
|
5133
5365
|
* If `source` does not have a file extension, and a file without an extension
|
|
5134
5366
|
* cannot be found, the engine will check for files with the extensions in
|
|
5135
|
-
* {@link
|
|
5136
|
-
* behavior also happens when using normal `import` statements.
|
|
5367
|
+
* {@link ModuleDelegate.searchExtensions}, and use one of those if present.
|
|
5368
|
+
* This behavior also happens when using normal `import` statements.
|
|
5137
5369
|
*
|
|
5138
5370
|
* For example, if you write:
|
|
5139
5371
|
*
|
|
@@ -5142,20 +5374,20 @@ interface RequireFunction {
|
|
|
5142
5374
|
* ```
|
|
5143
5375
|
*
|
|
5144
5376
|
* but there's no file named `somewhere` in the same directory as the file
|
|
5145
|
-
* where that import appears, and `
|
|
5146
|
-
* value:
|
|
5377
|
+
* where that import appears, and `ModuleDelegate.searchExtensions` is the
|
|
5378
|
+
* default value:
|
|
5147
5379
|
*
|
|
5148
5380
|
* ```js
|
|
5149
5381
|
* [".js"]
|
|
5150
5382
|
* ```
|
|
5151
5383
|
*
|
|
5152
5384
|
* then the engine will look for `somewhere.js`. If that doesn't exist, the
|
|
5153
|
-
* engine will look for `somewhere/index.js`. If *that* doesn't exist, an
|
|
5154
|
-
* will be thrown.
|
|
5385
|
+
* engine will look for `somewhere/index.js`. If *that* doesn't exist, an
|
|
5386
|
+
* error will be thrown.
|
|
5155
5387
|
*
|
|
5156
|
-
* If you add more extensions to `
|
|
5157
|
-
* will use those, too. It will search in the same order as the strings
|
|
5158
|
-
* in the `
|
|
5388
|
+
* If you add more extensions to `ModuleDelegate.searchExtensions`, then the
|
|
5389
|
+
* engine will use those, too. It will search in the same order as the strings
|
|
5390
|
+
* appear in the `ModuleDelegate.searchExtensions` array.
|
|
5159
5391
|
*/
|
|
5160
5392
|
(source: string): any;
|
|
5161
5393
|
|
|
@@ -5165,72 +5397,145 @@ interface RequireFunction {
|
|
|
5165
5397
|
resolve: (source: string) => string;
|
|
5166
5398
|
}
|
|
5167
5399
|
|
|
5400
|
+
// global added by QJMS_InitContext
|
|
5168
5401
|
declare var require: RequireFunction;
|
|
5169
5402
|
|
|
5403
|
+
// gets set per-module by QJMS_SetModuleImportMeta
|
|
5170
5404
|
interface ImportMeta {
|
|
5405
|
+
/**
|
|
5406
|
+
* A URL representing the current module.
|
|
5407
|
+
*
|
|
5408
|
+
* Usually starts with `file://`.
|
|
5409
|
+
*/
|
|
5410
|
+
url: string;
|
|
5411
|
+
|
|
5412
|
+
/**
|
|
5413
|
+
* Whether the current module is the "main" module, meaning that it is the
|
|
5414
|
+
* entrypoint file that's been loaded, or, in other terms, the first
|
|
5415
|
+
* user-authored module that's been loaded.
|
|
5416
|
+
*/
|
|
5417
|
+
main: boolean;
|
|
5418
|
+
|
|
5419
|
+
/**
|
|
5420
|
+
* Equivalent to `globalThis.require`. Provided for compatibility with tools
|
|
5421
|
+
* that can leverage a CommonJS require function via `import.meta.require`.
|
|
5422
|
+
*/
|
|
5171
5423
|
require: RequireFunction;
|
|
5424
|
+
|
|
5425
|
+
/**
|
|
5426
|
+
* Resolves a module specifier based on the current module's path.
|
|
5427
|
+
*
|
|
5428
|
+
* Equivalent to `globalThis.require.resolve`.
|
|
5429
|
+
*
|
|
5430
|
+
* Behaves similarly to [the browser
|
|
5431
|
+
* import.meta.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve),
|
|
5432
|
+
* but it does not ensure that the returned string is a valid URL, because it
|
|
5433
|
+
* delegates directly to {@link ModuleDelegate.resolve} to resolve the name.
|
|
5434
|
+
* If you want this to return URL strings, change `ModuleDelegate.resolve` and
|
|
5435
|
+
* `ModuleDelegate.read` to work with URL strings.
|
|
5436
|
+
*/
|
|
5437
|
+
resolve: RequireFunction["resolve"];
|
|
5172
5438
|
}
|
|
5173
5439
|
|
|
5174
|
-
declare
|
|
5175
|
-
|
|
5440
|
+
declare module "quickjs:engine" {
|
|
5441
|
+
/**
|
|
5442
|
+
* Return whether the provided resolved module path is set as the main module.
|
|
5443
|
+
*
|
|
5444
|
+
* In other words, return what the value of `import.meta.main` would be within
|
|
5445
|
+
* the module.
|
|
5446
|
+
*
|
|
5447
|
+
* The main module can be set via {@link setMainModule}.
|
|
5448
|
+
*/
|
|
5449
|
+
export function isMainModule(resolvedFilepath: string): boolean;
|
|
5176
5450
|
|
|
5177
|
-
|
|
5451
|
+
/**
|
|
5452
|
+
* Set the main module to the module with the provided resolved path.
|
|
5453
|
+
*
|
|
5454
|
+
* This will affect the value of `import.meta.main` for modules loaded in the
|
|
5455
|
+
* future, but it will NOT retroactively change the value of
|
|
5456
|
+
* `import.meta.main` in existing already-loaded modules.
|
|
5457
|
+
*/
|
|
5458
|
+
export function setMainModule(resolvedFilepath: string): void;
|
|
5178
5459
|
|
|
5179
|
-
|
|
5180
|
-
|
|
5460
|
+
/**
|
|
5461
|
+
* Evaluate the string `code` as a script (global eval).
|
|
5462
|
+
*
|
|
5463
|
+
* @param code - The code to evaluate.
|
|
5464
|
+
* @param options - An optional object containing the following optional properties:
|
|
5465
|
+
* @property backtraceBarrier - Boolean (default = false). If true, error backtraces do not list the stack frames below the evalScript.
|
|
5466
|
+
* @property filename - String (default = "<evalScript>"). The filename to associate with the code being executed.
|
|
5467
|
+
* @returns The result of the evaluation.
|
|
5468
|
+
*/
|
|
5469
|
+
export function evalScript(
|
|
5470
|
+
code: string,
|
|
5471
|
+
options?: { backtraceBarrier?: boolean; filename?: string }
|
|
5472
|
+
): any;
|
|
5181
5473
|
|
|
5182
|
-
interface StringConstructor {
|
|
5183
5474
|
/**
|
|
5184
|
-
*
|
|
5475
|
+
* Evaluate the file `filename` as a script (global eval).
|
|
5185
5476
|
*
|
|
5186
|
-
*
|
|
5477
|
+
* @param filename - The relative or absolute path to the file to load. Relative paths are resolved relative to the process's current working directory.
|
|
5478
|
+
* @returns The result of the evaluation.
|
|
5187
5479
|
*/
|
|
5188
|
-
|
|
5189
|
-
strings: readonly string[] | ArrayLike<string>,
|
|
5190
|
-
...substitutions: any[]
|
|
5191
|
-
): string;
|
|
5480
|
+
export function runScript(filename: string): any;
|
|
5192
5481
|
|
|
5193
5482
|
/**
|
|
5194
|
-
*
|
|
5195
|
-
* The first line of the string must be empty.
|
|
5483
|
+
* Evaluate the file `filename` as a module. Effectively a synchronous dynamic `import()`.
|
|
5196
5484
|
*
|
|
5197
|
-
*
|
|
5485
|
+
* @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.
|
|
5486
|
+
* @param basename - If present and `filename` is a relative path, `filename` will be resolved relative to this basename.
|
|
5487
|
+
* @returns The result of the evaluation (module namespace object).
|
|
5198
5488
|
*/
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
*
|
|
5204
|
-
* https://github.com/tc39/proposal-string-dedent
|
|
5205
|
-
*/
|
|
5206
|
-
(input: string): string;
|
|
5489
|
+
export function importModule(
|
|
5490
|
+
filename: string,
|
|
5491
|
+
basename?: string
|
|
5492
|
+
): { [key: string]: any };
|
|
5207
5493
|
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
...substitutions: any[]
|
|
5217
|
-
): string;
|
|
5494
|
+
/**
|
|
5495
|
+
* Return the resolved path to a module.
|
|
5496
|
+
*
|
|
5497
|
+
* @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.
|
|
5498
|
+
* @param basename - If present and `filename` is a relative path, `filename` will be resolved relative to this basename.
|
|
5499
|
+
* @returns The resolved module path.
|
|
5500
|
+
*/
|
|
5501
|
+
export function resolveModule(filename: string, basename?: string): string;
|
|
5218
5502
|
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5503
|
+
/**
|
|
5504
|
+
* Read the script of module filename from an active stack frame, then return it as a string.
|
|
5505
|
+
*
|
|
5506
|
+
* If there isn't a valid filename for the specified stack frame, an error will be thrown.
|
|
5507
|
+
*
|
|
5508
|
+
* @param stackLevels - How many levels up the stack to search for a filename. Defaults to 0, which uses the current stack frame.
|
|
5509
|
+
*/
|
|
5510
|
+
export function getFileNameFromStack(stackLevels?: number): string;
|
|
5511
|
+
|
|
5512
|
+
/**
|
|
5513
|
+
* Returns true if `target` is a module namespace object.
|
|
5514
|
+
*/
|
|
5515
|
+
export function isModuleNamespace(target: any): boolean;
|
|
5516
|
+
|
|
5517
|
+
/**
|
|
5518
|
+
* Create a virtual built-in module whose exports consist of the own
|
|
5519
|
+
* enumerable properties of `obj`.
|
|
5520
|
+
*/
|
|
5521
|
+
export function defineBuiltinModule(
|
|
5522
|
+
name: string,
|
|
5523
|
+
obj: { [key: string]: any }
|
|
5524
|
+
): void;
|
|
5525
|
+
|
|
5526
|
+
/**
|
|
5527
|
+
* An object which lets you configure the module loader (import/export/require).
|
|
5528
|
+
* You can change these properties to add support for importing new filetypes.
|
|
5529
|
+
*/
|
|
5530
|
+
export const ModuleDelegate: ModuleDelegate;
|
|
5531
|
+
|
|
5532
|
+
/**
|
|
5533
|
+
* Manually invoke the cycle removal algorithm (garbage collector).
|
|
5534
|
+
*
|
|
5535
|
+
* The cycle removal algorithm is automatically started when needed, so this
|
|
5536
|
+
* function is useful in case of specific memory constraints or for testing.
|
|
5537
|
+
*/
|
|
5538
|
+
export function gc(): void;
|
|
5234
5539
|
}
|
|
5235
5540
|
|
|
5236
5541
|
declare module "quickjs:bytecode" {
|
|
@@ -5241,7 +5546,11 @@ declare module "quickjs:bytecode" {
|
|
|
5241
5546
|
*/
|
|
5242
5547
|
export function fromFile(
|
|
5243
5548
|
path: string,
|
|
5244
|
-
options?: {
|
|
5549
|
+
options?: {
|
|
5550
|
+
byteSwap?: boolean;
|
|
5551
|
+
sourceType?: "module" | "script";
|
|
5552
|
+
encodedFileName?: string;
|
|
5553
|
+
}
|
|
5245
5554
|
): ArrayBuffer;
|
|
5246
5555
|
|
|
5247
5556
|
/**
|
|
@@ -5304,6 +5613,10 @@ declare module "quickjs:context" {
|
|
|
5304
5613
|
* - Symbol
|
|
5305
5614
|
* - eval (but it doesn't work unless the `eval` option is enabled)
|
|
5306
5615
|
* - globalThis
|
|
5616
|
+
*
|
|
5617
|
+
* Note that new contexts don't have a `scriptArgs` global. If you need one
|
|
5618
|
+
* to be present in the new context, you can add one onto the Context's
|
|
5619
|
+
* `globalThis` property.
|
|
5307
5620
|
*/
|
|
5308
5621
|
constructor(options?: {
|
|
5309
5622
|
/** Enables `Date`. Defaults to `true` */
|
|
@@ -5381,33 +5694,22 @@ declare module "quickjs:context" {
|
|
|
5381
5694
|
*/
|
|
5382
5695
|
operators?: boolean;
|
|
5383
5696
|
|
|
5384
|
-
/** Enables "use math"
|
|
5697
|
+
/** Enables `"use math"`. Defaults to `true`. */
|
|
5385
5698
|
useMath?: boolean;
|
|
5386
5699
|
|
|
5700
|
+
/** Enables `inspect`. Defaults to `true`. */
|
|
5701
|
+
inspect?: boolean;
|
|
5702
|
+
/** Enables `console`. Defaults to `true`. */
|
|
5703
|
+
console?: boolean;
|
|
5704
|
+
/** Enables `print`. Defaults to `true`. */
|
|
5705
|
+
print?: boolean;
|
|
5706
|
+
/** Enables `require`. Defaults to `true`. */
|
|
5707
|
+
moduleGlobals?: boolean;
|
|
5387
5708
|
/**
|
|
5388
|
-
* Enables
|
|
5389
|
-
*
|
|
5390
|
-
* - inspect
|
|
5391
|
-
* - console
|
|
5392
|
-
* - print
|
|
5393
|
-
* - require (and require.resolve)
|
|
5394
|
-
* - setTimeout
|
|
5395
|
-
* - clearTimeout
|
|
5396
|
-
* - setInterval
|
|
5397
|
-
* - clearInterval
|
|
5398
|
-
* - String.cooked
|
|
5399
|
-
* - String.dedent
|
|
5400
|
-
*
|
|
5401
|
-
* Defaults to `true`.
|
|
5402
|
-
*
|
|
5403
|
-
* NOTE: The following globals, normally part of `js_std_add_helpers`, are NEVER added:
|
|
5404
|
-
*
|
|
5405
|
-
* - Module
|
|
5406
|
-
* - scriptArgs
|
|
5407
|
-
*
|
|
5408
|
-
* If you need them in the new context, copy them over from your context's globalThis onto the child context's globalThis.
|
|
5709
|
+
* Enables `setTimeout`, `clearTimeout`, `setInterval`, and
|
|
5710
|
+
* `clearInterval`. Defaults to `true`.
|
|
5409
5711
|
*/
|
|
5410
|
-
|
|
5712
|
+
timers?: boolean;
|
|
5411
5713
|
|
|
5412
5714
|
/** Enable builtin modules. */
|
|
5413
5715
|
modules?: {
|
|
@@ -5419,6 +5721,10 @@ declare module "quickjs:context" {
|
|
|
5419
5721
|
"quickjs:bytecode"?: boolean;
|
|
5420
5722
|
/** Enables the "quickjs:context" module. Defaults to `true`. */
|
|
5421
5723
|
"quickjs:context"?: boolean;
|
|
5724
|
+
/** Enables the "quickjs:engine" module. Defaults to `true`. */
|
|
5725
|
+
"quickjs:engine"?: boolean;
|
|
5726
|
+
/** Enables the "quickjs:encoding" module. Defaults to `true`. */
|
|
5727
|
+
"quickjs:encoding"?: boolean;
|
|
5422
5728
|
};
|
|
5423
5729
|
});
|
|
5424
5730
|
|
|
@@ -5438,5 +5744,16 @@ declare module "quickjs:context" {
|
|
|
5438
5744
|
}
|
|
5439
5745
|
}
|
|
5440
5746
|
|
|
5747
|
+
// WHATWG encoding spec at https://encoding.spec.whatwg.org/ would be better,
|
|
5748
|
+
// but this is better than nothing
|
|
5749
|
+
declare module "quickjs:encoding" {
|
|
5750
|
+
export function toUtf8(input: ArrayBuffer): string;
|
|
5751
|
+
export function fromUtf8(input: string): ArrayBuffer;
|
|
5752
|
+
}
|
|
5753
|
+
|
|
5441
5754
|
declare const std: typeof import("quickjs:std");
|
|
5442
5755
|
declare const os: typeof import("quickjs:os");
|
|
5756
|
+
|
|
5757
|
+
// undocumented from quickjs, but it's there
|
|
5758
|
+
/** Get the current unix timestamp with microsecond precision. */
|
|
5759
|
+
declare function __date_clock(): number;
|