yavascript 0.0.10 → 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/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 }
@@ -307,6 +312,14 @@ declare class Path {
307
312
  */
308
313
  static readonly OS_ENV_VAR_SEPARATOR: ":" | ";";
309
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
+
310
323
  /** Split one or more path strings into an array of path segments. */
311
324
  static splitToSegments(inputParts: Array<string> | string): Array<string>;
312
325
 
@@ -322,16 +335,14 @@ declare class Path {
322
335
  ): string | Fallback;
323
336
 
324
337
  /** Join together one or more paths. */
325
- static join(...inputs: Array<string | Path | Array<string | Path>>): string;
338
+ static join(...inputs: Array<string | Path | Array<string | Path>>): Path;
326
339
 
327
340
  /**
328
341
  * Turns the input path(s) into an absolute path by resolving all `.` and `..`
329
342
  * segments, using `pwd()` as a base dir to use when resolving leading `.` or
330
343
  * `..` segments.
331
344
  */
332
- static resolve(
333
- ...inputs: Array<string | Path | Array<string | Path>>
334
- ): string;
345
+ static resolve(...inputs: Array<string | Path | Array<string | Path>>): Path;
335
346
 
336
347
  /**
337
348
  * Concatenates the input path(s) and then resolves all non-leading `.` and
@@ -339,7 +350,7 @@ declare class Path {
339
350
  */
340
351
  static normalize(
341
352
  ...inputs: Array<string | Path | Array<string | Path>>
342
- ): string;
353
+ ): Path;
343
354
 
344
355
  /**
345
356
  * Return whether the provided path is absolute; that is, whether it
@@ -347,18 +358,6 @@ declare class Path {
347
358
  */
348
359
  static isAbsolute(path: string | Path): boolean;
349
360
 
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
361
  /**
363
362
  * An array of the path segments that make up this path.
364
363
  *
@@ -382,13 +381,11 @@ declare class Path {
382
381
  static from(segments: Array<string>, separator: string): Path;
383
382
 
384
383
  /**
385
- * Turn this path into an absolute path by resolving all `.` and `..`
386
- * segments, using `from` as a base dir to use when resolving leading `.` or
387
- * `..` segments.
388
- *
389
- * 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.
390
387
  */
391
- resolve(from?: string | Path): Path;
388
+ resolve(...subpaths: Array<string | Path>): Path;
392
389
 
393
390
  /**
394
391
  * Resolve all non-leading `.` and `..` segments in this path.
@@ -396,21 +393,22 @@ declare class Path {
396
393
  normalize(): Path;
397
394
 
398
395
  /**
399
- * Create a new path by appending another path's segments after this path's
400
- * segments.
396
+ * Create a new Path by appending additional path segments onto the end of
397
+ * this Path's segments.
401
398
  *
402
399
  * The returned path will use this path's separator.
403
400
  */
404
- concat(other: string | Path | Array<string | Path>): Path;
401
+ concat(...other: Array<string | Path | Array<string | Path>>): Path;
405
402
 
406
403
  /**
407
404
  * Return whether this path is absolute; that is, whether it starts with
408
- * either `/` or a drive letter (ie `C:`).
405
+ * either `/`, `\`, or a drive letter (ie `C:`).
409
406
  */
410
407
  isAbsolute(): boolean;
411
408
 
412
409
  /**
413
- * Make a second Path object containing the same information as this one.
410
+ * Make a second Path object containing the same segments and separator as
411
+ * this one.
414
412
  */
415
413
  clone(): this;
416
414
 
@@ -437,9 +435,116 @@ declare class Path {
437
435
  toString(): string;
438
436
 
439
437
  /**
440
- * 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.
441
440
  */
442
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;
443
548
  }
444
549
 
445
550
  /**
@@ -464,8 +569,7 @@ declare var __dirname: string;
464
569
  declare function basename(path: string | Path): string;
465
570
 
466
571
  /**
467
- * Read the contents of one of more files from disk as one UTF-8 string,
468
- * print that string to stdout, then return it.
572
+ * Reads the contents of one of more files from disk as one UTF-8 string.
469
573
  */
470
574
  declare function cat(...paths: Array<string | Path>): string;
471
575
 
@@ -526,7 +630,7 @@ declare function chmod(
526
630
  *
527
631
  * Provides the same functionality as the unix binary of the same name.
528
632
  */
529
- declare function dirname(path: string | Path): string;
633
+ declare function dirname(path: string | Path): Path;
530
634
 
531
635
  /**
532
636
  * Print one or more values to stdout.
@@ -548,14 +652,8 @@ declare function extname(
548
652
  /**
549
653
  * Returns the contents of a directory, as absolute paths. `.` and `..` are
550
654
  * omitted.
551
- *
552
- * Use the `relativePaths` option to get relative paths instead (relative to
553
- * the parent directory).
554
655
  */
555
- declare function ls(
556
- dir?: string | Path,
557
- options?: { relativePaths?: boolean }
558
- ): Array<string>;
656
+ declare function ls(dir?: string | Path): Array<Path>;
559
657
 
560
658
  /**
561
659
  * Print data to stdout using C-style format specifiers.
@@ -571,7 +669,20 @@ declare function printf(format: string, ...args: Array<any>): void;
571
669
  *
572
670
  * Provides the same functionality as the shell builtin of the same name.
573
671
  */
574
- declare function pwd(): string;
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
+ };
575
686
 
576
687
  /**
577
688
  * Reads a symlink.
@@ -580,7 +691,7 @@ declare function pwd(): string;
580
691
  *
581
692
  * Provides the same functionality as the unix binary of the same name.
582
693
  */
583
- declare function readlink(path: string | Path): string;
694
+ declare function readlink(path: string | Path): Path;
584
695
 
585
696
  /**
586
697
  * Get the absolute path given a relative path. Symlinks are also resolved.
@@ -589,7 +700,7 @@ declare function readlink(path: string | Path): string;
589
700
  *
590
701
  * Provides the same functionality as the unix binary of the same name.
591
702
  */
592
- declare function realpath(path: string | Path): string;
703
+ declare function realpath(path: string | Path): Path;
593
704
 
594
705
  /**
595
706
  * Blocks the current thread for at least the specified number of milliseconds,
@@ -634,6 +745,26 @@ declare var sleep: {
634
745
  */
635
746
  declare function touch(path: string | Path): void;
636
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
+
637
768
  declare type BaseExecOptions = {
638
769
  /** Sets the current working directory for the child process. */
639
770
  cwd?: string | Path;
@@ -671,7 +802,7 @@ declare type BaseExecOptions = {
671
802
 
672
803
  declare interface Exec {
673
804
  (
674
- args: Array<string> | string,
805
+ args: Array<string | Path | number> | string | Path,
675
806
  options: BaseExecOptions & {
676
807
  failOnNonZeroStatus: true;
677
808
  captureOutput: false;
@@ -679,7 +810,7 @@ declare interface Exec {
679
810
  ): void;
680
811
 
681
812
  (
682
- args: Array<string> | string,
813
+ args: Array<string | Path | number> | string | Path,
683
814
  options: BaseExecOptions & {
684
815
  failOnNonZeroStatus: false;
685
816
  captureOutput: false;
@@ -689,7 +820,7 @@ declare interface Exec {
689
820
  | { status: undefined; signal: number };
690
821
 
691
822
  (
692
- args: Array<string> | string,
823
+ args: Array<string | Path | number> | string | Path,
693
824
  options: BaseExecOptions & {
694
825
  failOnNonZeroStatus: true;
695
826
  captureOutput: true;
@@ -697,7 +828,7 @@ declare interface Exec {
697
828
  ): { stdout: string; stderr: string };
698
829
 
699
830
  (
700
- args: Array<string> | string,
831
+ args: Array<string | Path | number> | string | Path,
701
832
  options: BaseExecOptions & {
702
833
  failOnNonZeroStatus: true;
703
834
  captureOutput: "utf8";
@@ -705,7 +836,7 @@ declare interface Exec {
705
836
  ): { stdout: string; stderr: string };
706
837
 
707
838
  (
708
- args: Array<string> | string,
839
+ args: Array<string | Path | number> | string | Path,
709
840
  options: BaseExecOptions & {
710
841
  failOnNonZeroStatus: true;
711
842
  captureOutput: "arraybuffer";
@@ -713,7 +844,7 @@ declare interface Exec {
713
844
  ): { stdout: ArrayBuffer; stderr: ArrayBuffer };
714
845
 
715
846
  (
716
- args: Array<string> | string,
847
+ args: Array<string | Path | number> | string | Path,
717
848
  options: BaseExecOptions & {
718
849
  failOnNonZeroStatus: false;
719
850
  captureOutput: true;
@@ -723,7 +854,7 @@ declare interface Exec {
723
854
  | { stdout: string; stderr: string; status: undefined; signal: number };
724
855
 
725
856
  (
726
- args: Array<string> | string,
857
+ args: Array<string | Path | number> | string | Path,
727
858
  options: BaseExecOptions & {
728
859
  failOnNonZeroStatus: false;
729
860
  captureOutput: "utf-8";
@@ -733,7 +864,7 @@ declare interface Exec {
733
864
  | { stdout: string; stderr: string; status: undefined; signal: number };
734
865
 
735
866
  (
736
- args: Array<string> | string,
867
+ args: Array<string | Path | number> | string | Path,
737
868
  options: BaseExecOptions & {
738
869
  failOnNonZeroStatus: false;
739
870
  captureOutput: "arraybuffer";
@@ -753,14 +884,14 @@ declare interface Exec {
753
884
  };
754
885
 
755
886
  (
756
- args: Array<string> | string,
887
+ args: Array<string | Path | number> | string | Path,
757
888
  options: BaseExecOptions & {
758
889
  failOnNonZeroStatus: true;
759
890
  }
760
891
  ): void;
761
892
 
762
893
  (
763
- args: Array<string> | string,
894
+ args: Array<string | Path | number> | string | Path,
764
895
  options: BaseExecOptions & {
765
896
  failOnNonZeroStatus: false;
766
897
  }
@@ -769,41 +900,54 @@ declare interface Exec {
769
900
  | { status: undefined; signal: number };
770
901
 
771
902
  (
772
- args: Array<string> | string,
903
+ args: Array<string | Path | number> | string | Path,
773
904
  options: BaseExecOptions & {
774
905
  captureOutput: true;
775
906
  }
776
907
  ): { stdout: string; stderr: string };
777
908
 
778
909
  (
779
- args: Array<string> | string,
910
+ args: Array<string | Path | number> | string | Path,
780
911
  options: BaseExecOptions & {
781
912
  captureOutput: "utf8";
782
913
  }
783
914
  ): { stdout: string; stderr: string };
784
915
 
785
916
  (
786
- args: Array<string> | string,
917
+ args: Array<string | Path | number> | string | Path,
787
918
  options: BaseExecOptions & {
788
919
  captureOutput: "arraybuffer";
789
920
  }
790
921
  ): { stdout: ArrayBuffer; stderr: ArrayBuffer };
791
922
 
792
923
  (
793
- args: Array<string> | string,
924
+ args: Array<string | Path | number> | string | Path,
794
925
  options: BaseExecOptions & {
795
926
  captureOutput: false;
796
927
  }
797
928
  ): void;
798
929
 
799
- (args: Array<string> | string, options?: BaseExecOptions): void;
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>;
800
940
  }
801
941
 
802
- /** Runs a child process using the provided arguments. The first value in the arguments array is the program to run. */
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
+ */
803
947
  declare const exec: Exec;
804
948
 
805
949
  /** Alias for `exec(args, { captureOutput: true })` */
806
- declare function $(args: Array<string> | string): {
950
+ declare function $(args: Array<string | Path | number> | string | Path): {
807
951
  stdout: string;
808
952
  stderr: string;
809
953
  };
@@ -817,7 +961,7 @@ declare interface ChildProcess {
817
961
  args: Array<string>;
818
962
 
819
963
  /** The current working directory for the process. */
820
- cwd: string;
964
+ cwd: Path;
821
965
 
822
966
  /** The environment variables for the process. */
823
967
  env: { [key: string]: string };
@@ -859,7 +1003,7 @@ declare interface ChildProcess {
859
1003
  */
860
1004
  declare type ChildProcessOptions = {
861
1005
  /** The current working directory for the process. */
862
- cwd?: string;
1006
+ cwd?: string | Path;
863
1007
 
864
1008
  /** The environment variables for the process. */
865
1009
  env?: { [key: string]: string };
@@ -893,7 +1037,7 @@ declare interface ChildProcessConstructor {
893
1037
  * @param options - Options for the process (cwd, env, stdio, etc)
894
1038
  */
895
1039
  new (
896
- args: string | Array<string>,
1040
+ args: string | Path | Array<string | number | Path>,
897
1041
  options?: ChildProcessOptions
898
1042
  ): ChildProcess;
899
1043
 
@@ -961,7 +1105,7 @@ declare function stripAnsi(input: string): string;
961
1105
  /**
962
1106
  * Wrap a string in double quotes, and escape any double-quotes inside using `\"`.
963
1107
  */
964
- declare function quote(input: string): string;
1108
+ declare function quote(input: string | Path): string;
965
1109
 
966
1110
  // Colors
967
1111
 
@@ -2560,11 +2704,21 @@ declare const types: {
2560
2704
  };
2561
2705
  };
2562
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
+ */
2563
2712
  declare const is: <T extends TypeValidator<any> | CoerceableToTypeValidator>(
2564
2713
  value: any,
2565
2714
  type: T
2566
2715
  ) => value is UnwrapTypeFromCoerceableOrValidator<T>;
2567
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
+
2568
2722
  declare const assert: {
2569
2723
  /**
2570
2724
  * Throws an error if `value` is not truthy.
@@ -2796,8 +2950,9 @@ declare class GitRepo {
2796
2950
  }
2797
2951
 
2798
2952
  /**
2799
- * Configures the default value of `trace` in functions which receive `trace`
2800
- * 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}.
2801
2956
  *
2802
2957
  * - If called with `true`, the default value of `trace` in all functions which
2803
2958
  * receive a `trace` option will be changed to `console.error`.
@@ -2806,10 +2961,12 @@ declare class GitRepo {
2806
2961
  * - If called with any other value, the provided value will be used as the
2807
2962
  * default value of `trace` in all functions which receive a `trace` option.
2808
2963
  *
2809
- * If you would like to make your own functions use the default value of
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.
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`.
2813
2970
  */
2814
2971
  declare const traceAll: ((
2815
2972
  trace: boolean | undefined | ((...args: Array<any>) => void)
@@ -2820,7 +2977,7 @@ declare const traceAll: ((
2820
2977
  declare namespace JSX {
2821
2978
  /**
2822
2979
  * A string containing the expression that should be called to create JSX
2823
- * elements.
2980
+ * elements. yavascript's internals use this string to transpile JSX syntax.
2824
2981
  *
2825
2982
  * Defaults to "JSX.createElement".
2826
2983
  *
@@ -2840,7 +2997,8 @@ declare namespace JSX {
2840
2997
 
2841
2998
  /**
2842
2999
  * A string containing the expression that should be used as the first
2843
- * parameter when creating JSX fragment elements.
3000
+ * parameter when creating JSX fragment elements. yavascript's internals use
3001
+ * this string to transpile JSX syntax.
2844
3002
  *
2845
3003
  * Defaults to "JSX.Fragment".
2846
3004
  *
@@ -2880,10 +3038,19 @@ declare namespace JSX {
2880
3038
  export type Fragment = Element<{}, typeof Fragment>;
2881
3039
 
2882
3040
  /**
2883
- * The JSX element constructor, which gets invoked whenever JSX syntax is
3041
+ * The JSX element builder function, which gets invoked whenever JSX syntax is
2884
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.
2885
3052
  */
2886
- export const createElement: {
3053
+ export let createElement: {
2887
3054
  <Type extends string | typeof Fragment | ((...args: any) => any)>(
2888
3055
  type: Type
2889
3056
  ): Element<{}, Type>;
@@ -3034,6 +3201,18 @@ interface ObjectConstructor {
3034
3201
  isPrimitive(input: any): boolean;
3035
3202
  }
3036
3203
 
3204
+ interface StringConstructor {
3205
+ /**
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
+
3037
3216
  interface SymbolConstructor {
3038
3217
  /**
3039
3218
  * A method that changes the result of using the `typeof` operator on the
@@ -3873,6 +4052,151 @@ interface BigDecimal {
3873
4052
  // TypeScript will not understand or handle unary/binary operators for BigFloat
3874
4053
  // and BigDecimal properly.
3875
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
+
3876
4200
  // Definitions of the globals and modules added by quickjs-libc
3877
4201
 
3878
4202
  /**
@@ -4004,71 +4328,50 @@ declare interface FILE {
4004
4328
 
4005
4329
  declare module "quickjs:std" {
4006
4330
  /**
4007
- * Exit the process with the provided status code.
4331
+ * Set the exit code that the process should exit with in the future, if it
4332
+ * exits normally.
4008
4333
  *
4009
- * @param statusCode The exit code; 0 for success, nonzero for failure.
4334
+ * Can only be called from the main thread.
4335
+ *
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`.
4342
+ *
4343
+ * @param statusCode The future exit code; 0 for success, nonzero for failure.
4010
4344
  */
4011
- export function exit(statusCode: number): void;
4345
+ export function setExitCode(statusCode: number): void;
4012
4346
 
4013
4347
  /**
4014
- * Evaluate the string `code` as a script (global eval).
4348
+ * Return the exit code that was previously set by {@link setExitCode}, or 0 if
4349
+ * it hasn't yet been set.
4015
4350
  *
4016
- * @param code - The code to evaluate.
4017
- * @param options - An optional object containing the following optional properties:
4018
- * @property backtraceBarrier - Boolean (default = false). If true, error backtraces do not list the stack frames below the evalScript.
4019
- * @property filename - String (default = "<evalScript>"). The filename to associate with the code being executed.
4020
- * @returns The result of the evaluation.
4351
+ * Can only be called from the main thread.
4021
4352
  */
4022
- export function evalScript(
4023
- code: string,
4024
- options?: { backtraceBarrier?: boolean; filename?: string }
4025
- ): any;
4353
+ export function getExitCode(): number;
4026
4354
 
4027
4355
  /**
4028
- * Evaluate the file `filename` as a script (global eval).
4356
+ * Exit the process with the provided status code.
4029
4357
  *
4030
- * @param filename - The relative or absolute path to the file to load. Relative paths are resolved relative to the process's current working directory.
4031
- * @returns The result of the evaluation.
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.
4032
4365
  */
4033
- export function loadScript(filename: string): any;
4366
+ export function exit(statusCode?: number): never;
4034
4367
 
4035
4368
  /**
4036
- * Evaluate the file `filename` as a module. Effectively a synchronous dynamic `import()`.
4037
- *
4038
- * @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.
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).
4041
- */
4042
- export function importModule(
4043
- filename: string,
4044
- basename?: string
4045
- ): { [key: string]: any };
4046
-
4047
- /**
4048
- * Return the resolved path to a module.
4049
- *
4050
- * @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.
4051
- * @param basename - If present and `filename` is a relative path, `filename` will be resolved relative to this basename.
4052
- * @returns The resolved module path.
4053
- */
4054
- export function resolveModule(filename: string, basename?: string): string;
4055
-
4056
- /**
4057
- * Load the file `filename` and return it as a string assuming UTF-8 encoding.
4369
+ * Load the file `filename` and return it as a string assuming UTF-8 encoding.
4058
4370
  *
4059
4371
  * @param filename - The relative or absolute path to the file to load. Relative paths are resolved relative to the process's current working directory.
4060
4372
  */
4061
4373
  export function loadFile(filename: string): string;
4062
4374
 
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
4375
  /**
4073
4376
  * Return a boolean indicating whether the provided value is a FILE object.
4074
4377
  *
@@ -4919,110 +5222,57 @@ declare module "quickjs:os" {
4919
5222
  export function chmod(path: string, mode: number): void;
4920
5223
  }
4921
5224
 
4922
- /**
4923
- * Options for {@link inspect}.
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;
5225
+ declare var setTimeout: typeof import("quickjs:os").setTimeout;
5226
+ declare var clearTimeout: typeof import("quickjs:os").clearTimeout;
4955
5227
 
4956
- /** Prefix string to use for indentation. Defaults to '\t'. */
4957
- indent?: string;
4958
- }
5228
+ declare type Interval = { [Symbol.toStringTag]: "Interval" };
4959
5229
 
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
- }
5230
+ declare function setInterval(func: (...args: any) => any, ms: number): Interval;
5231
+ declare function clearInterval(interval: Interval): void;
4995
5232
 
4996
- declare interface InspectFunction {
5233
+ interface StringConstructor {
4997
5234
  /**
4998
- * Generate a human-readable representation of a value.
5235
+ * Remove leading minimum indentation from the string.
5236
+ * The first line of the string must be empty.
4999
5237
  *
5000
- * @param value - Value to inspect
5001
- * @param options - Additional settings for refining output
5002
- * @returns A string representation of `value`.
5238
+ * https://github.com/tc39/proposal-string-dedent
5003
5239
  */
5004
- (value: any, options?: InspectOptions): string;
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;
5005
5248
 
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
- }
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;
5016
5259
 
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;
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
+ }
5026
5276
 
5027
5277
  /**
5028
5278
  * A global which lets you configure the module loader (import/export/require).
@@ -5122,6 +5372,7 @@ interface ModuleGlobal {
5122
5372
  read(modulePath: string): string;
5123
5373
  }
5124
5374
 
5375
+ // global added by QJMS_AddModuleGlobal
5125
5376
  declare var Module: ModuleGlobal;
5126
5377
 
5127
5378
  interface RequireFunction {
@@ -5165,72 +5416,116 @@ interface RequireFunction {
5165
5416
  resolve: (source: string) => string;
5166
5417
  }
5167
5418
 
5419
+ // global added by QJMS_AddRequireGlobal
5168
5420
  declare var require: RequireFunction;
5169
5421
 
5422
+ // gets set per-module by QJMS_SetModuleImportMeta
5170
5423
  interface ImportMeta {
5424
+ /**
5425
+ * A URL representing the current module.
5426
+ *
5427
+ * Usually starts with `file://`.
5428
+ */
5429
+ url: string;
5430
+
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;
5437
+
5438
+ /**
5439
+ * Equivalent to `globalThis.require`. Provided for compatibility with tools
5440
+ * that can leverage a CommonJS require function via `import.meta.require`.
5441
+ */
5171
5442
  require: RequireFunction;
5443
+
5444
+ /**
5445
+ * Resolves a module specifier based on the current module's path.
5446
+ *
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.
5454
+ */
5455
+ resolve: RequireFunction["resolve"];
5172
5456
  }
5173
5457
 
5174
- declare var setTimeout: typeof import("quickjs:os").setTimeout;
5175
- declare var clearTimeout: typeof import("quickjs:os").clearTimeout;
5458
+ declare module "quickjs:module" {
5459
+ /**
5460
+ * Return whether the provided resolved module path is set as the main module.
5461
+ *
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}.
5466
+ */
5467
+ export function isMainModule(resolvedFilepath: string): boolean;
5176
5468
 
5177
- declare type Interval = { [Symbol.toStringTag]: "Interval" };
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;
5178
5477
 
5179
- declare function setInterval(func: (...args: any) => any, ms: number): Interval;
5180
- declare function clearInterval(interval: Interval): void;
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;
5181
5491
 
5182
- interface StringConstructor {
5183
5492
  /**
5184
- * A no-op template literal tag.
5493
+ * Evaluate the file `filename` as a script (global eval).
5185
5494
  *
5186
- * https://github.com/tc39/proposal-string-cooked
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.
5187
5497
  */
5188
- cooked(
5189
- strings: readonly string[] | ArrayLike<string>,
5190
- ...substitutions: any[]
5191
- ): string;
5498
+ export function runScript(filename: string): any;
5192
5499
 
5193
5500
  /**
5194
- * Remove leading minimum indentation from the string.
5195
- * The first line of the string must be empty.
5501
+ * Evaluate the file `filename` as a module. Effectively a synchronous dynamic `import()`.
5196
5502
  *
5197
- * https://github.com/tc39/proposal-string-dedent
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).
5198
5506
  */
5199
- dedent: {
5200
- /**
5201
- * Remove leading minimum indentation from the string.
5202
- * The first line of the string must be empty.
5203
- *
5204
- * https://github.com/tc39/proposal-string-dedent
5205
- */
5206
- (input: string): string;
5507
+ export function importModule(
5508
+ filename: string,
5509
+ basename?: string
5510
+ ): { [key: string]: any };
5207
5511
 
5208
- /**
5209
- * Remove leading minimum indentation from the template literal.
5210
- * The first line of the string must be empty.
5211
- *
5212
- * https://github.com/tc39/proposal-string-dedent
5213
- */
5214
- (
5215
- strings: readonly string[] | ArrayLike<string>,
5216
- ...substitutions: any[]
5217
- ): string;
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;
5218
5520
 
5219
- /**
5220
- * Wrap another template tag function such that tagged literals
5221
- * become dedented before being passed to the wrapped function.
5222
- *
5223
- * https://www.npmjs.com/package/string-dedent#usage
5224
- */
5225
- <
5226
- Func extends (
5227
- strings: readonly string[] | ArrayLike<string>,
5228
- ...substitutions: any[]
5229
- ) => string
5230
- >(
5231
- input: Func
5232
- ): Func;
5233
- };
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;
5234
5529
  }
5235
5530
 
5236
5531
  declare module "quickjs:bytecode" {
@@ -5304,6 +5599,10 @@ declare module "quickjs:context" {
5304
5599
  * - Symbol
5305
5600
  * - eval (but it doesn't work unless the `eval` option is enabled)
5306
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.
5307
5606
  */
5308
5607
  constructor(options?: {
5309
5608
  /** Enables `Date`. Defaults to `true` */
@@ -5315,6 +5614,9 @@ declare module "quickjs:context" {
5315
5614
  /** Enables `String.prototype.normalize`. Defaults to `true`. */
5316
5615
  stringNormalize?: boolean;
5317
5616
 
5617
+ /** Enables `String.dedent`. Defaults to `true`. */
5618
+ stringDedent?: boolean;
5619
+
5318
5620
  /** Enables `RegExp`. Defaults to `true`. */
5319
5621
  regExp?: boolean;
5320
5622
 
@@ -5381,33 +5683,22 @@ declare module "quickjs:context" {
5381
5683
  */
5382
5684
  operators?: boolean;
5383
5685
 
5384
- /** Enables "use math". Defaults to `true`. */
5686
+ /** Enables `"use math"`. Defaults to `true`. */
5385
5687
  useMath?: boolean;
5386
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;
5387
5697
  /**
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.
5698
+ * Enables `setTimeout`, `clearTimeout`, `setInterval`, and
5699
+ * `clearInterval`. Defaults to `true`.
5409
5700
  */
5410
- stdHelpers?: boolean;
5701
+ timers?: boolean;
5411
5702
 
5412
5703
  /** Enable builtin modules. */
5413
5704
  modules?: {
@@ -5419,6 +5710,8 @@ declare module "quickjs:context" {
5419
5710
  "quickjs:bytecode"?: boolean;
5420
5711
  /** Enables the "quickjs:context" module. Defaults to `true`. */
5421
5712
  "quickjs:context"?: boolean;
5713
+ /** Enables the "quickjs:module" module. Defaults to `true`. */
5714
+ "quickjs:module"?: boolean;
5422
5715
  };
5423
5716
  });
5424
5717