ses 1.2.0 → 1.4.0
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/NEWS.md +20 -0
- package/dist/lockdown.cjs +397 -91
- package/dist/lockdown.mjs +397 -91
- package/dist/lockdown.umd.js +397 -91
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +397 -91
- package/dist/ses.mjs +397 -91
- package/dist/ses.umd.js +397 -91
- package/dist/ses.umd.min.js +1 -1
- package/index.js +1 -0
- package/package.json +10 -9
- package/src/commons.js +4 -0
- package/src/console-shim.js +50 -0
- package/src/enablements.js +6 -0
- package/src/error/README.md +9 -1
- package/src/error/assert.js +37 -9
- package/src/error/console.js +156 -17
- package/src/error/internal-types.js +6 -1
- package/src/error/tame-console.js +8 -8
- package/src/error/types.js +45 -27
- package/src/make-eval-function.js +1 -1
- package/src/permits.js +25 -7
- package/src/tame-regexp-constructor.js +13 -6
- package/types.d.ts +16 -4
package/dist/lockdown.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ses@1.
|
|
1
|
+
// ses@1.4.0
|
|
2
2
|
'use strict';
|
|
3
3
|
(() => {
|
|
4
4
|
const functors = [
|
|
@@ -51,8 +51,9 @@ const {
|
|
|
51
51
|
RangeError,
|
|
52
52
|
ReferenceError,
|
|
53
53
|
SyntaxError,
|
|
54
|
-
TypeError
|
|
55
|
-
|
|
54
|
+
TypeError,
|
|
55
|
+
AggregateError}=
|
|
56
|
+
globalThis;$h_once.FERAL_ERROR(FERAL_ERROR);$h_once.RangeError(RangeError);$h_once.ReferenceError(ReferenceError);$h_once.SyntaxError(SyntaxError);$h_once.TypeError(TypeError);$h_once.AggregateError(AggregateError);
|
|
56
57
|
|
|
57
58
|
const {
|
|
58
59
|
assign,
|
|
@@ -163,6 +164,9 @@ const arrayIncludes= uncurryThis(arrayPrototype.includes);$h_once.arr
|
|
|
163
164
|
const arrayJoin= uncurryThis(arrayPrototype.join);
|
|
164
165
|
/** @type {<T, U>(thisArg: readonly T[], callbackfn: (value: T, index: number, array: T[]) => U, cbThisArg?: any) => U[]} */$h_once.arrayJoin(arrayJoin);
|
|
165
166
|
const arrayMap= /** @type {any} */ uncurryThis(arrayPrototype.map);$h_once.arrayMap(arrayMap);
|
|
167
|
+
const arrayFlatMap= /** @type {any} */
|
|
168
|
+
uncurryThis(arrayPrototype.flatMap);$h_once.arrayFlatMap(arrayFlatMap);
|
|
169
|
+
|
|
166
170
|
const arrayPop= uncurryThis(arrayPrototype.pop);
|
|
167
171
|
/** @type {<T>(thisArg: T[], ...items: T[]) => number} */$h_once.arrayPop(arrayPop);
|
|
168
172
|
const arrayPush= uncurryThis(arrayPrototype.push);$h_once.arrayPush(arrayPush);
|
|
@@ -653,20 +657,36 @@ freeze(bestEffortStringify);
|
|
|
653
657
|
// === functors[5] ===
|
|
654
658
|
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict'; $h_imports([]); // @ts-check
|
|
655
659
|
|
|
660
|
+
/**
|
|
661
|
+
* TypeScript does not treat `AggregateErrorConstructor` as a subtype of
|
|
662
|
+
* `ErrorConstructor`, which makes sense because their constructors
|
|
663
|
+
* have incompatible signatures. However, we want to parameterize some
|
|
664
|
+
* operations by any error constructor, including possible `AggregateError`.
|
|
665
|
+
* So we introduce `GenericErrorConstructor` as a common supertype. Any call
|
|
666
|
+
* to it to make an instance must therefore first case split on whether the
|
|
667
|
+
* constructor is an AggregateErrorConstructor or a normal ErrorConstructor.
|
|
668
|
+
*
|
|
669
|
+
* @typedef {ErrorConstructor | AggregateErrorConstructor} GenericErrorConstructor
|
|
670
|
+
*/
|
|
671
|
+
|
|
656
672
|
/**
|
|
657
673
|
* @callback BaseAssert
|
|
658
674
|
* The `assert` function itself.
|
|
659
675
|
*
|
|
660
676
|
* @param {any} flag The truthy/falsy value
|
|
661
|
-
* @param {Details
|
|
662
|
-
* @param {
|
|
663
|
-
* constructor to use.
|
|
677
|
+
* @param {Details} [optDetails] The details to throw
|
|
678
|
+
* @param {GenericErrorConstructor} [errConstructor]
|
|
679
|
+
* An optional alternate error constructor to use.
|
|
680
|
+
* @param {AssertMakeErrorOptions} [options]
|
|
664
681
|
* @returns {asserts flag}
|
|
665
682
|
*/
|
|
666
683
|
|
|
667
684
|
/**
|
|
668
685
|
* @typedef {object} AssertMakeErrorOptions
|
|
669
|
-
* @property {string
|
|
686
|
+
* @property {string} [errorName]
|
|
687
|
+
* @property {Error} [cause]
|
|
688
|
+
* @property {Error[]} [errors]
|
|
689
|
+
* Normally only used when the ErrorConstuctor is `AggregateError`
|
|
670
690
|
*/
|
|
671
691
|
|
|
672
692
|
/**
|
|
@@ -675,10 +695,10 @@ freeze(bestEffortStringify);
|
|
|
675
695
|
* The `assert.error` method, recording details for the console.
|
|
676
696
|
*
|
|
677
697
|
* The optional `optDetails` can be a string.
|
|
678
|
-
* @param {Details
|
|
679
|
-
* @param {
|
|
680
|
-
* constructor to use.
|
|
681
|
-
* @param {AssertMakeErrorOptions
|
|
698
|
+
* @param {Details} [optDetails] The details of what was asserted
|
|
699
|
+
* @param {GenericErrorConstructor} [errConstructor]
|
|
700
|
+
* An optional alternate error constructor to use.
|
|
701
|
+
* @param {AssertMakeErrorOptions} [options]
|
|
682
702
|
* @returns {Error}
|
|
683
703
|
*/
|
|
684
704
|
|
|
@@ -693,9 +713,10 @@ freeze(bestEffortStringify);
|
|
|
693
713
|
*
|
|
694
714
|
* The optional `optDetails` can be a string for backwards compatibility
|
|
695
715
|
* with the nodejs assertion library.
|
|
696
|
-
* @param {Details
|
|
697
|
-
* @param {
|
|
698
|
-
* constructor to use.
|
|
716
|
+
* @param {Details} [optDetails] The details of what was asserted
|
|
717
|
+
* @param {GenericErrorConstructor} [errConstructor]
|
|
718
|
+
* An optional alternate error constructor to use.
|
|
719
|
+
* @param {AssertMakeErrorOptions} [options]
|
|
699
720
|
* @returns {never}
|
|
700
721
|
*/
|
|
701
722
|
|
|
@@ -706,9 +727,10 @@ freeze(bestEffortStringify);
|
|
|
706
727
|
* Assert that two values must be `Object.is`.
|
|
707
728
|
* @param {any} actual The value we received
|
|
708
729
|
* @param {any} expected What we wanted
|
|
709
|
-
* @param {Details
|
|
710
|
-
* @param {
|
|
711
|
-
* constructor to use.
|
|
730
|
+
* @param {Details} [optDetails] The details to throw
|
|
731
|
+
* @param {GenericErrorConstructor} [errConstructor]
|
|
732
|
+
* An optional alternate error constructor to use.
|
|
733
|
+
* @param {AssertMakeErrorOptions} [options]
|
|
712
734
|
* @returns {void}
|
|
713
735
|
*/
|
|
714
736
|
|
|
@@ -719,7 +741,7 @@ freeze(bestEffortStringify);
|
|
|
719
741
|
* @callback AssertTypeofBigint
|
|
720
742
|
* @param {any} specimen
|
|
721
743
|
* @param {'bigint'} typename
|
|
722
|
-
* @param {Details
|
|
744
|
+
* @param {Details} [optDetails]
|
|
723
745
|
* @returns {asserts specimen is bigint}
|
|
724
746
|
*/
|
|
725
747
|
|
|
@@ -727,7 +749,7 @@ freeze(bestEffortStringify);
|
|
|
727
749
|
* @callback AssertTypeofBoolean
|
|
728
750
|
* @param {any} specimen
|
|
729
751
|
* @param {'boolean'} typename
|
|
730
|
-
* @param {Details
|
|
752
|
+
* @param {Details} [optDetails]
|
|
731
753
|
* @returns {asserts specimen is boolean}
|
|
732
754
|
*/
|
|
733
755
|
|
|
@@ -735,7 +757,7 @@ freeze(bestEffortStringify);
|
|
|
735
757
|
* @callback AssertTypeofFunction
|
|
736
758
|
* @param {any} specimen
|
|
737
759
|
* @param {'function'} typename
|
|
738
|
-
* @param {Details
|
|
760
|
+
* @param {Details} [optDetails]
|
|
739
761
|
* @returns {asserts specimen is Function}
|
|
740
762
|
*/
|
|
741
763
|
|
|
@@ -743,7 +765,7 @@ freeze(bestEffortStringify);
|
|
|
743
765
|
* @callback AssertTypeofNumber
|
|
744
766
|
* @param {any} specimen
|
|
745
767
|
* @param {'number'} typename
|
|
746
|
-
* @param {Details
|
|
768
|
+
* @param {Details} [optDetails]
|
|
747
769
|
* @returns {asserts specimen is number}
|
|
748
770
|
*/
|
|
749
771
|
|
|
@@ -751,7 +773,7 @@ freeze(bestEffortStringify);
|
|
|
751
773
|
* @callback AssertTypeofObject
|
|
752
774
|
* @param {any} specimen
|
|
753
775
|
* @param {'object'} typename
|
|
754
|
-
* @param {Details
|
|
776
|
+
* @param {Details} [optDetails]
|
|
755
777
|
* @returns {asserts specimen is Record<any, any> | null}
|
|
756
778
|
*/
|
|
757
779
|
|
|
@@ -759,7 +781,7 @@ freeze(bestEffortStringify);
|
|
|
759
781
|
* @callback AssertTypeofString
|
|
760
782
|
* @param {any} specimen
|
|
761
783
|
* @param {'string'} typename
|
|
762
|
-
* @param {Details
|
|
784
|
+
* @param {Details} [optDetails]
|
|
763
785
|
* @returns {asserts specimen is string}
|
|
764
786
|
*/
|
|
765
787
|
|
|
@@ -767,7 +789,7 @@ freeze(bestEffortStringify);
|
|
|
767
789
|
* @callback AssertTypeofSymbol
|
|
768
790
|
* @param {any} specimen
|
|
769
791
|
* @param {'symbol'} typename
|
|
770
|
-
* @param {Details
|
|
792
|
+
* @param {Details} [optDetails]
|
|
771
793
|
* @returns {asserts specimen is symbol}
|
|
772
794
|
*/
|
|
773
795
|
|
|
@@ -775,7 +797,7 @@ freeze(bestEffortStringify);
|
|
|
775
797
|
* @callback AssertTypeofUndefined
|
|
776
798
|
* @param {any} specimen
|
|
777
799
|
* @param {'undefined'} typename
|
|
778
|
-
* @param {Details
|
|
800
|
+
* @param {Details} [optDetails]
|
|
779
801
|
* @returns {asserts specimen is undefined}
|
|
780
802
|
*/
|
|
781
803
|
|
|
@@ -794,7 +816,7 @@ freeze(bestEffortStringify);
|
|
|
794
816
|
*
|
|
795
817
|
* Assert an expected typeof result.
|
|
796
818
|
* @param {any} specimen The value to get the typeof
|
|
797
|
-
* @param {Details
|
|
819
|
+
* @param {Details} [optDetails] The details to throw
|
|
798
820
|
* @returns {asserts specimen is string}
|
|
799
821
|
*/
|
|
800
822
|
|
|
@@ -855,7 +877,7 @@ freeze(bestEffortStringify);
|
|
|
855
877
|
*
|
|
856
878
|
* @callback AssertQuote
|
|
857
879
|
* @param {any} payload What to declassify
|
|
858
|
-
* @param {(string|number)
|
|
880
|
+
* @param {(string|number)} [spaces]
|
|
859
881
|
* @returns {StringablePayload} The declassified payload
|
|
860
882
|
*/
|
|
861
883
|
|
|
@@ -888,8 +910,8 @@ freeze(bestEffortStringify);
|
|
|
888
910
|
* `optRaise` returns normally, which would be unusual, the throw following
|
|
889
911
|
* `optRaise(reason)` would still happen.
|
|
890
912
|
*
|
|
891
|
-
* @param {Raise
|
|
892
|
-
* @param {boolean
|
|
913
|
+
* @param {Raise} [optRaise]
|
|
914
|
+
* @param {boolean} [unredacted]
|
|
893
915
|
* @returns {Assert}
|
|
894
916
|
*/
|
|
895
917
|
|
|
@@ -1053,7 +1075,7 @@ freeze(bestEffortStringify);
|
|
|
1053
1075
|
* @callback FilterConsole
|
|
1054
1076
|
* @param {VirtualConsole} baseConsole
|
|
1055
1077
|
* @param {ConsoleFilter} filter
|
|
1056
|
-
* @param {string
|
|
1078
|
+
* @param {string} [topic]
|
|
1057
1079
|
* @returns {VirtualConsole}
|
|
1058
1080
|
*/
|
|
1059
1081
|
})()
|
|
@@ -1130,7 +1152,12 @@ freeze(bestEffortStringify);
|
|
|
1130
1152
|
*/
|
|
1131
1153
|
|
|
1132
1154
|
/**
|
|
1133
|
-
* @typedef {{
|
|
1155
|
+
* @typedef {{
|
|
1156
|
+
* NOTE: 'ERROR_NOTE:',
|
|
1157
|
+
* MESSAGE: 'ERROR_MESSAGE:',
|
|
1158
|
+
* CAUSE: 'cause:',
|
|
1159
|
+
* ERRORS: 'errors:',
|
|
1160
|
+
* }} ErrorInfo
|
|
1134
1161
|
*/
|
|
1135
1162
|
|
|
1136
1163
|
/**
|
|
@@ -1451,7 +1478,9 @@ freeze(makeNoteLogArgsArrayKit);
|
|
|
1451
1478
|
})()
|
|
1452
1479
|
,
|
|
1453
1480
|
// === functors[9] ===
|
|
1454
|
-
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict'; let RangeError,TypeError,WeakMap,arrayJoin,arrayMap,arrayPop,arrayPush,assign,freeze,globalThis,is,isError,regexpTest,stringIndexOf,stringReplace,stringSlice,stringStartsWith,weakmapDelete,weakmapGet,weakmapHas,weakmapSet,an,bestEffortStringify,makeNoteLogArgsArrayKit;$h_imports([["../commons.js", [["RangeError", [$h_a => (RangeError = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["WeakMap", [$h_a => (WeakMap = $h_a)]],["arrayJoin", [$h_a => (arrayJoin = $h_a)]],["arrayMap", [$h_a => (arrayMap = $h_a)]],["arrayPop", [$h_a => (arrayPop = $h_a)]],["arrayPush", [$h_a => (arrayPush = $h_a)]],["assign", [$h_a => (assign = $h_a)]],["freeze", [$h_a => (freeze = $h_a)]],["globalThis", [$h_a => (globalThis = $h_a)]],["is", [$h_a => (is = $h_a)]],["isError", [$h_a => (isError = $h_a)]],["regexpTest", [$h_a => (regexpTest = $h_a)]],["stringIndexOf", [$h_a => (stringIndexOf = $h_a)]],["stringReplace", [$h_a => (stringReplace = $h_a)]],["stringSlice", [$h_a => (stringSlice = $h_a)]],["stringStartsWith", [$h_a => (stringStartsWith = $h_a)]],["weakmapDelete", [$h_a => (weakmapDelete = $h_a)]],["weakmapGet", [$h_a => (weakmapGet = $h_a)]],["weakmapHas", [$h_a => (weakmapHas = $h_a)]],["weakmapSet", [$h_a => (weakmapSet = $h_a)]]]],["./stringify-utils.js", [["an", [$h_a => (an = $h_a)]],["bestEffortStringify", [$h_a => (bestEffortStringify = $h_a)]]]],["./types.js", []],["./internal-types.js", []],["./note-log-args.js", [["makeNoteLogArgsArrayKit", [$h_a => (makeNoteLogArgsArrayKit = $h_a)]]]]]);
|
|
1481
|
+
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict'; let RangeError,TypeError,WeakMap,arrayJoin,arrayMap,arrayPop,arrayPush,assign,freeze,defineProperty,globalThis,is,isError,regexpTest,stringIndexOf,stringReplace,stringSlice,stringStartsWith,weakmapDelete,weakmapGet,weakmapHas,weakmapSet,AggregateError,an,bestEffortStringify,makeNoteLogArgsArrayKit;$h_imports([["../commons.js", [["RangeError", [$h_a => (RangeError = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["WeakMap", [$h_a => (WeakMap = $h_a)]],["arrayJoin", [$h_a => (arrayJoin = $h_a)]],["arrayMap", [$h_a => (arrayMap = $h_a)]],["arrayPop", [$h_a => (arrayPop = $h_a)]],["arrayPush", [$h_a => (arrayPush = $h_a)]],["assign", [$h_a => (assign = $h_a)]],["freeze", [$h_a => (freeze = $h_a)]],["defineProperty", [$h_a => (defineProperty = $h_a)]],["globalThis", [$h_a => (globalThis = $h_a)]],["is", [$h_a => (is = $h_a)]],["isError", [$h_a => (isError = $h_a)]],["regexpTest", [$h_a => (regexpTest = $h_a)]],["stringIndexOf", [$h_a => (stringIndexOf = $h_a)]],["stringReplace", [$h_a => (stringReplace = $h_a)]],["stringSlice", [$h_a => (stringSlice = $h_a)]],["stringStartsWith", [$h_a => (stringStartsWith = $h_a)]],["weakmapDelete", [$h_a => (weakmapDelete = $h_a)]],["weakmapGet", [$h_a => (weakmapGet = $h_a)]],["weakmapHas", [$h_a => (weakmapHas = $h_a)]],["weakmapSet", [$h_a => (weakmapSet = $h_a)]],["AggregateError", [$h_a => (AggregateError = $h_a)]]]],["./stringify-utils.js", [["an", [$h_a => (an = $h_a)]],["bestEffortStringify", [$h_a => (bestEffortStringify = $h_a)]]]],["./types.js", []],["./internal-types.js", []],["./note-log-args.js", [["makeNoteLogArgsArrayKit", [$h_a => (makeNoteLogArgsArrayKit = $h_a)]]]]]);
|
|
1482
|
+
|
|
1483
|
+
|
|
1455
1484
|
|
|
1456
1485
|
|
|
1457
1486
|
|
|
@@ -1710,8 +1739,8 @@ const tagError= (err, optErrorName= err.name)=> {
|
|
|
1710
1739
|
*/
|
|
1711
1740
|
const makeError= (
|
|
1712
1741
|
optDetails= redactedDetails `Assert failed`,
|
|
1713
|
-
|
|
1714
|
-
{ errorName= undefined}= {})=>
|
|
1742
|
+
errConstructor= globalThis.Error,
|
|
1743
|
+
{ errorName= undefined, cause= undefined, errors= undefined}= {})=>
|
|
1715
1744
|
{
|
|
1716
1745
|
if( typeof optDetails=== 'string') {
|
|
1717
1746
|
// If it is a string, use it as the literal part of the template so
|
|
@@ -1723,7 +1752,29 @@ const makeError= (
|
|
|
1723
1752
|
throw TypeError( `unrecognized details ${quote(optDetails)}`);
|
|
1724
1753
|
}
|
|
1725
1754
|
const messageString= getMessageString(hiddenDetails);
|
|
1726
|
-
const
|
|
1755
|
+
const opts= cause&& { cause};
|
|
1756
|
+
let error;
|
|
1757
|
+
if(
|
|
1758
|
+
typeof AggregateError!== 'undefined'&&
|
|
1759
|
+
errConstructor=== AggregateError)
|
|
1760
|
+
{
|
|
1761
|
+
error= AggregateError(errors|| [], messageString, opts);
|
|
1762
|
+
}else {
|
|
1763
|
+
error= /** @type {ErrorConstructor} */ errConstructor(
|
|
1764
|
+
messageString,
|
|
1765
|
+
opts);
|
|
1766
|
+
|
|
1767
|
+
if( errors!== undefined) {
|
|
1768
|
+
// Since we need to tolerate `errors` on an AggregateError, may as
|
|
1769
|
+
// well tolerate it on all errors.
|
|
1770
|
+
defineProperty(error, 'errors', {
|
|
1771
|
+
value: errors,
|
|
1772
|
+
writable: true,
|
|
1773
|
+
enumerable: false,
|
|
1774
|
+
configurable: true});
|
|
1775
|
+
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1727
1778
|
weakmapSet(hiddenMessageLogArgs, error, getLogArgs(hiddenDetails));
|
|
1728
1779
|
if( errorName!== undefined) {
|
|
1729
1780
|
tagError(error, errorName);
|
|
@@ -1835,9 +1886,10 @@ const makeAssert= (optRaise= undefined, unredacted= false)=> {
|
|
|
1835
1886
|
/** @type {AssertFail} */
|
|
1836
1887
|
const fail= (
|
|
1837
1888
|
optDetails= assertFailedDetails,
|
|
1838
|
-
|
|
1889
|
+
errConstructor= undefined,
|
|
1890
|
+
options= undefined)=>
|
|
1839
1891
|
{
|
|
1840
|
-
const reason= makeError(optDetails,
|
|
1892
|
+
const reason= makeError(optDetails, errConstructor, options);
|
|
1841
1893
|
if( optRaise!== undefined) {
|
|
1842
1894
|
optRaise(reason);
|
|
1843
1895
|
}
|
|
@@ -1855,9 +1907,10 @@ const makeAssert= (optRaise= undefined, unredacted= false)=> {
|
|
|
1855
1907
|
function baseAssert(
|
|
1856
1908
|
flag,
|
|
1857
1909
|
optDetails= undefined,
|
|
1858
|
-
|
|
1910
|
+
errConstructor= undefined,
|
|
1911
|
+
options= undefined)
|
|
1859
1912
|
{
|
|
1860
|
-
flag|| fail(optDetails,
|
|
1913
|
+
flag|| fail(optDetails, errConstructor, options);
|
|
1861
1914
|
}
|
|
1862
1915
|
|
|
1863
1916
|
/** @type {AssertEqual} */
|
|
@@ -1865,12 +1918,14 @@ const makeAssert= (optRaise= undefined, unredacted= false)=> {
|
|
|
1865
1918
|
actual,
|
|
1866
1919
|
expected,
|
|
1867
1920
|
optDetails= undefined,
|
|
1868
|
-
|
|
1921
|
+
errConstructor= undefined,
|
|
1922
|
+
options= undefined)=>
|
|
1869
1923
|
{
|
|
1870
1924
|
is(actual, expected)||
|
|
1871
1925
|
fail(
|
|
1872
1926
|
optDetails|| details `Expected ${actual} is same as ${expected}`,
|
|
1873
|
-
|
|
1927
|
+
errConstructor|| RangeError,
|
|
1928
|
+
options);
|
|
1874
1929
|
|
|
1875
1930
|
};
|
|
1876
1931
|
freeze(equal);
|
|
@@ -2173,7 +2228,11 @@ const makeHardener= ()=> {
|
|
|
2173
2228
|
})()
|
|
2174
2229
|
,
|
|
2175
2230
|
// === functors[11] ===
|
|
2176
|
-
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict';
|
|
2231
|
+
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict'; let arrayPush;$h_imports([["./commons.js", [["arrayPush", [$h_a => (arrayPush = $h_a)]]]]]);
|
|
2232
|
+
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2177
2236
|
/**
|
|
2178
2237
|
* @file Exports {@code whitelist}, a recursively defined
|
|
2179
2238
|
* JSON record enumerating all intrinsics and their properties
|
|
@@ -2183,8 +2242,6 @@ const makeHardener= ()=> {
|
|
|
2183
2242
|
* @author Mark S. Miller
|
|
2184
2243
|
*/
|
|
2185
2244
|
|
|
2186
|
-
/* eslint max-lines: 0 */
|
|
2187
|
-
|
|
2188
2245
|
/**
|
|
2189
2246
|
* constantProperties
|
|
2190
2247
|
* non-configurable, non-writable data properties of all global objects.
|
|
@@ -2257,6 +2314,8 @@ const universalPropertyNames= {
|
|
|
2257
2314
|
Iterator: 'Iterator',
|
|
2258
2315
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
2259
2316
|
AsyncIterator: 'AsyncIterator',
|
|
2317
|
+
// https://github.com/endojs/endo/issues/550
|
|
2318
|
+
AggregateError: 'AggregateError',
|
|
2260
2319
|
|
|
2261
2320
|
// *** Other Properties of the Global Object
|
|
2262
2321
|
|
|
@@ -2360,14 +2419,25 @@ const uniqueGlobalPropertyNames= {
|
|
|
2360
2419
|
|
|
2361
2420
|
// All the "subclasses" of Error. These are collectively represented in the
|
|
2362
2421
|
// ECMAScript spec by the meta variable NativeError.
|
|
2363
|
-
|
|
2364
|
-
|
|
2422
|
+
/** @type {GenericErrorConstructor[]} */$h_once.uniqueGlobalPropertyNames(uniqueGlobalPropertyNames);
|
|
2423
|
+
const NativeErrors= [
|
|
2365
2424
|
EvalError,
|
|
2366
2425
|
RangeError,
|
|
2367
2426
|
ReferenceError,
|
|
2368
2427
|
SyntaxError,
|
|
2369
2428
|
TypeError,
|
|
2370
|
-
URIError
|
|
2429
|
+
URIError
|
|
2430
|
+
// https://github.com/endojs/endo/issues/550
|
|
2431
|
+
// Commented out to accommodate platforms prior to AggregateError.
|
|
2432
|
+
// Instead, conditional push below.
|
|
2433
|
+
// AggregateError,
|
|
2434
|
+
];$h_once.NativeErrors(NativeErrors);
|
|
2435
|
+
|
|
2436
|
+
if( typeof AggregateError!== 'undefined') {
|
|
2437
|
+
// Conditional, to accommodate platforms prior to AggregateError
|
|
2438
|
+
arrayPush(NativeErrors, AggregateError);
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2371
2441
|
|
|
2372
2442
|
|
|
2373
2443
|
/**
|
|
@@ -2417,7 +2487,7 @@ $h_once.uniqueGlobalPropertyNames(uniqueGlobalPropertyNames);const NativeErro
|
|
|
2417
2487
|
*/
|
|
2418
2488
|
|
|
2419
2489
|
// Function Instances
|
|
2420
|
-
|
|
2490
|
+
const FunctionInstance= {
|
|
2421
2491
|
'[[Proto]]': '%FunctionPrototype%',
|
|
2422
2492
|
length: 'number',
|
|
2423
2493
|
name: 'string'
|
|
@@ -2774,6 +2844,8 @@ const permitted= {
|
|
|
2774
2844
|
SyntaxError: NativeError('%SyntaxErrorPrototype%'),
|
|
2775
2845
|
TypeError: NativeError('%TypeErrorPrototype%'),
|
|
2776
2846
|
URIError: NativeError('%URIErrorPrototype%'),
|
|
2847
|
+
// https://github.com/endojs/endo/issues/550
|
|
2848
|
+
AggregateError: NativeError('%AggregateErrorPrototype%'),
|
|
2777
2849
|
|
|
2778
2850
|
'%EvalErrorPrototype%': NativeErrorPrototype('EvalError'),
|
|
2779
2851
|
'%RangeErrorPrototype%': NativeErrorPrototype('RangeError'),
|
|
@@ -2781,6 +2853,8 @@ const permitted= {
|
|
|
2781
2853
|
'%SyntaxErrorPrototype%': NativeErrorPrototype('SyntaxError'),
|
|
2782
2854
|
'%TypeErrorPrototype%': NativeErrorPrototype('TypeError'),
|
|
2783
2855
|
'%URIErrorPrototype%': NativeErrorPrototype('URIError'),
|
|
2856
|
+
// https://github.com/endojs/endo/issues/550
|
|
2857
|
+
'%AggregateErrorPrototype%': NativeErrorPrototype('AggregateError'),
|
|
2784
2858
|
|
|
2785
2859
|
// *** Numbers and Dates
|
|
2786
2860
|
|
|
@@ -3648,9 +3722,8 @@ const permitted= {
|
|
|
3648
3722
|
'[[Proto]]': '%FunctionPrototype%',
|
|
3649
3723
|
all: fn,
|
|
3650
3724
|
allSettled: fn,
|
|
3651
|
-
//
|
|
3652
|
-
|
|
3653
|
-
any: false, // ES2021
|
|
3725
|
+
// https://github.com/Agoric/SES-shim/issues/550
|
|
3726
|
+
any: fn,
|
|
3654
3727
|
prototype: '%PromisePrototype%',
|
|
3655
3728
|
race: fn,
|
|
3656
3729
|
reject: fn,
|
|
@@ -4613,21 +4686,28 @@ function tameRegExpConstructor(regExpTaming= 'safe') {
|
|
|
4613
4686
|
return construct(FERAL_REG_EXP, rest, new.target);
|
|
4614
4687
|
};
|
|
4615
4688
|
|
|
4616
|
-
const speciesDesc= getOwnPropertyDescriptor(FERAL_REG_EXP, speciesSymbol);
|
|
4617
|
-
if( !speciesDesc) {
|
|
4618
|
-
throw TypeError('no RegExp[Symbol.species] descriptor');
|
|
4619
|
-
}
|
|
4620
|
-
|
|
4621
4689
|
defineProperties(ResultRegExp, {
|
|
4622
4690
|
length: { value: 2},
|
|
4623
4691
|
prototype: {
|
|
4624
4692
|
value: RegExpPrototype,
|
|
4625
4693
|
writable: false,
|
|
4626
4694
|
enumerable: false,
|
|
4627
|
-
configurable: false}
|
|
4695
|
+
configurable: false}});
|
|
4696
|
+
|
|
4628
4697
|
|
|
4629
|
-
|
|
4698
|
+
// Hermes does not have `Symbol.species`. We should support such platforms.
|
|
4699
|
+
if( speciesSymbol) {
|
|
4700
|
+
const speciesDesc= getOwnPropertyDescriptor(
|
|
4701
|
+
FERAL_REG_EXP,
|
|
4702
|
+
speciesSymbol);
|
|
4630
4703
|
|
|
4704
|
+
if( !speciesDesc) {
|
|
4705
|
+
throw TypeError('no RegExp[Symbol.species] descriptor');
|
|
4706
|
+
}
|
|
4707
|
+
defineProperties(ResultRegExp, {
|
|
4708
|
+
[speciesSymbol]: speciesDesc});
|
|
4709
|
+
|
|
4710
|
+
}
|
|
4631
4711
|
return ResultRegExp;
|
|
4632
4712
|
};
|
|
4633
4713
|
|
|
@@ -4801,6 +4881,12 @@ const moderateEnablements= {
|
|
|
4801
4881
|
name: true // set by "node 14"
|
|
4802
4882
|
},
|
|
4803
4883
|
|
|
4884
|
+
// https://github.com/endojs/endo/issues/550
|
|
4885
|
+
'%AggregateErrorPrototype%': {
|
|
4886
|
+
message: true, // to match TypeErrorPrototype.message
|
|
4887
|
+
name: true // set by "node 14"?
|
|
4888
|
+
},
|
|
4889
|
+
|
|
4804
4890
|
'%PromisePrototype%': {
|
|
4805
4891
|
constructor: true // set by "core-js"
|
|
4806
4892
|
},
|
|
@@ -5191,7 +5277,7 @@ function tameLocaleMethods(intrinsics, localeTaming= 'safe') {
|
|
|
5191
5277
|
* @param {Function} safeEvaluate
|
|
5192
5278
|
*/
|
|
5193
5279
|
const makeEvalFunction= (safeEvaluate)=>{
|
|
5194
|
-
// We use the
|
|
5280
|
+
// We use the concise method syntax to create an eval without a
|
|
5195
5281
|
// [[Construct]] behavior (such that the invocation "new eval()" throws
|
|
5196
5282
|
// TypeError: eval is not a constructor"), but which still accepts a
|
|
5197
5283
|
// 'this' binding.
|
|
@@ -6541,7 +6627,11 @@ function tameDomains(domainTaming= 'safe') {
|
|
|
6541
6627
|
})()
|
|
6542
6628
|
,
|
|
6543
6629
|
// === functors[34] ===
|
|
6544
|
-
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict'; let WeakSet,arrayFilter,arrayMap,arrayPush,defineProperty,freeze,fromEntries,isError,stringEndsWith,weaksetAdd,weaksetHas;$h_imports([["../commons.js", [["WeakSet", [$h_a => (WeakSet = $h_a)]],["arrayFilter", [$h_a => (arrayFilter = $h_a)]],["arrayMap", [$h_a => (arrayMap = $h_a)]],["arrayPush", [$h_a => (arrayPush = $h_a)]],["defineProperty", [$h_a => (defineProperty = $h_a)]],["freeze", [$h_a => (freeze = $h_a)]],["fromEntries", [$h_a => (fromEntries = $h_a)]],["isError", [$h_a => (isError = $h_a)]],["stringEndsWith", [$h_a => (stringEndsWith = $h_a)]],["weaksetAdd", [$h_a => (weaksetAdd = $h_a)]],["weaksetHas", [$h_a => (weaksetHas = $h_a)]]]],["./types.js", []],["./internal-types.js", []]]);
|
|
6630
|
+
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict'; let WeakSet,arrayFilter,arrayFlatMap,arrayMap,arrayPop,arrayPush,defineProperty,freeze,fromEntries,isError,stringEndsWith,stringIncludes,stringSplit,weaksetAdd,weaksetHas;$h_imports([["../commons.js", [["WeakSet", [$h_a => (WeakSet = $h_a)]],["arrayFilter", [$h_a => (arrayFilter = $h_a)]],["arrayFlatMap", [$h_a => (arrayFlatMap = $h_a)]],["arrayMap", [$h_a => (arrayMap = $h_a)]],["arrayPop", [$h_a => (arrayPop = $h_a)]],["arrayPush", [$h_a => (arrayPush = $h_a)]],["defineProperty", [$h_a => (defineProperty = $h_a)]],["freeze", [$h_a => (freeze = $h_a)]],["fromEntries", [$h_a => (fromEntries = $h_a)]],["isError", [$h_a => (isError = $h_a)]],["stringEndsWith", [$h_a => (stringEndsWith = $h_a)]],["stringIncludes", [$h_a => (stringIncludes = $h_a)]],["stringSplit", [$h_a => (stringSplit = $h_a)]],["weaksetAdd", [$h_a => (weaksetAdd = $h_a)]],["weaksetHas", [$h_a => (weaksetHas = $h_a)]]]],["./types.js", []],["./internal-types.js", []]]);
|
|
6631
|
+
|
|
6632
|
+
|
|
6633
|
+
|
|
6634
|
+
|
|
6545
6635
|
|
|
6546
6636
|
|
|
6547
6637
|
|
|
@@ -6589,8 +6679,17 @@ function tameDomains(domainTaming= 'safe') {
|
|
|
6589
6679
|
|
|
6590
6680
|
/** @typedef {keyof VirtualConsole | 'profile' | 'profileEnd'} ConsoleProps */
|
|
6591
6681
|
|
|
6592
|
-
/**
|
|
6593
|
-
|
|
6682
|
+
/**
|
|
6683
|
+
* Those console methods whose actual parameters are `(fmt?, ...args)`
|
|
6684
|
+
* even if their TypeScript types claim otherwise.
|
|
6685
|
+
*
|
|
6686
|
+
* Each is paired with what we consider to be their log severity level.
|
|
6687
|
+
* This is the same as the log severity of these on other
|
|
6688
|
+
* platform console implementations when they all agree.
|
|
6689
|
+
*
|
|
6690
|
+
* @type {readonly [ConsoleProps, LogSeverity | undefined][]}
|
|
6691
|
+
*/
|
|
6692
|
+
const consoleLevelMethods= freeze([
|
|
6594
6693
|
['debug', 'debug'], // (fmt?, ...args) verbose level on Chrome
|
|
6595
6694
|
['log', 'log'], // (fmt?, ...args) info level on Chrome
|
|
6596
6695
|
['info', 'info'], // (fmt?, ...args)
|
|
@@ -6598,13 +6697,22 @@ const consoleLevelMethods= freeze([
|
|
|
6598
6697
|
['error', 'error'], // (fmt?, ...args)
|
|
6599
6698
|
|
|
6600
6699
|
['trace', 'log'], // (fmt?, ...args)
|
|
6601
|
-
['dirxml', 'log'], // (fmt?, ...args)
|
|
6602
|
-
['group', 'log'], // (fmt?, ...args)
|
|
6603
|
-
['groupCollapsed', 'log'] // (fmt?, ...args)
|
|
6700
|
+
['dirxml', 'log'], // (fmt?, ...args) but TS typed (...data)
|
|
6701
|
+
['group', 'log'], // (fmt?, ...args) but TS typed (...label)
|
|
6702
|
+
['groupCollapsed', 'log'] // (fmt?, ...args) but TS typed (...label)
|
|
6604
6703
|
]);
|
|
6605
6704
|
|
|
6606
|
-
/**
|
|
6607
|
-
|
|
6705
|
+
/**
|
|
6706
|
+
* Those console methods other than those already enumerated by
|
|
6707
|
+
* `consoleLevelMethods`.
|
|
6708
|
+
*
|
|
6709
|
+
* Each is paired with what we consider to be their log severity level.
|
|
6710
|
+
* This is the same as the log severity of these on other
|
|
6711
|
+
* platform console implementations when they all agree.
|
|
6712
|
+
*
|
|
6713
|
+
* @type {readonly [ConsoleProps, LogSeverity | undefined][]}
|
|
6714
|
+
*/$h_once.consoleLevelMethods(consoleLevelMethods);
|
|
6715
|
+
const consoleOtherMethods= freeze([
|
|
6608
6716
|
['assert', 'error'], // (value, fmt?, ...args)
|
|
6609
6717
|
['timeLog', 'log'], // (label?, ...args) no fmt string
|
|
6610
6718
|
|
|
@@ -6627,8 +6735,8 @@ const consoleOtherMethods= freeze([
|
|
|
6627
6735
|
['timeStamp', undefined] // (label?)
|
|
6628
6736
|
]);
|
|
6629
6737
|
|
|
6630
|
-
/** @type {readonly [ConsoleProps, LogSeverity | undefined][]}
|
|
6631
|
-
const
|
|
6738
|
+
/** @type {readonly [ConsoleProps, LogSeverity | undefined][]} */$h_once.consoleOtherMethods(consoleOtherMethods);
|
|
6739
|
+
const consoleWhitelist= freeze([
|
|
6632
6740
|
...consoleLevelMethods,
|
|
6633
6741
|
...consoleOtherMethods]);
|
|
6634
6742
|
|
|
@@ -6660,10 +6768,10 @@ const consoleWhitelist= freeze([
|
|
|
6660
6768
|
* ]);
|
|
6661
6769
|
*/
|
|
6662
6770
|
|
|
6663
|
-
//
|
|
6771
|
+
// //////////////////////////// Logging Console ////////////////////////////////
|
|
6664
6772
|
|
|
6665
|
-
/** @type {MakeLoggingConsoleKit}
|
|
6666
|
-
const
|
|
6773
|
+
/** @type {MakeLoggingConsoleKit} */
|
|
6774
|
+
const makeLoggingConsoleKit= (
|
|
6667
6775
|
loggedErrorHandler,
|
|
6668
6776
|
{ shouldResetForDebugging= false}= {})=>
|
|
6669
6777
|
{
|
|
@@ -6705,18 +6813,34 @@ const makeLoggingConsoleKit= (
|
|
|
6705
6813
|
};$h_once.makeLoggingConsoleKit(makeLoggingConsoleKit);
|
|
6706
6814
|
freeze(makeLoggingConsoleKit);
|
|
6707
6815
|
|
|
6816
|
+
/**
|
|
6817
|
+
* Makes the same calls on a `baseConsole` that were made on a
|
|
6818
|
+
* `loggingConsole` to produce this `log`. In this way, a logging console
|
|
6819
|
+
* can be used as a buffer to delay the application of these calls to a
|
|
6820
|
+
* `baseConsole`.
|
|
6821
|
+
*
|
|
6822
|
+
* @param {LogRecord[]} log
|
|
6823
|
+
* @param {VirtualConsole} baseConsole
|
|
6824
|
+
*/
|
|
6825
|
+
const pumpLogToConsole= (log, baseConsole)=> {
|
|
6826
|
+
for( const [name, ...args]of log) {
|
|
6827
|
+
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
6828
|
+
baseConsole[name](...args);
|
|
6829
|
+
}
|
|
6830
|
+
};
|
|
6831
|
+
// //////////////////////////// Causal Console /////////////////////////////////
|
|
6708
6832
|
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
/** @type {ErrorInfo} */
|
|
6833
|
+
/** @type {ErrorInfo} */$h_once.pumpLogToConsole(pumpLogToConsole);
|
|
6712
6834
|
const ErrorInfo= {
|
|
6713
6835
|
NOTE: 'ERROR_NOTE:',
|
|
6714
|
-
MESSAGE: 'ERROR_MESSAGE:'
|
|
6836
|
+
MESSAGE: 'ERROR_MESSAGE:',
|
|
6837
|
+
CAUSE: 'cause:',
|
|
6838
|
+
ERRORS: 'errors:'};
|
|
6715
6839
|
|
|
6716
6840
|
freeze(ErrorInfo);
|
|
6717
6841
|
|
|
6718
6842
|
/** @type {MakeCausalConsole} */
|
|
6719
|
-
const
|
|
6843
|
+
const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
|
|
6720
6844
|
if( !baseConsole) {
|
|
6721
6845
|
return undefined;
|
|
6722
6846
|
}
|
|
@@ -6851,6 +6975,14 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
|
|
|
6851
6975
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
6852
6976
|
baseConsole[severity](stackString);
|
|
6853
6977
|
// Show the other annotations on error
|
|
6978
|
+
if( error.cause) {
|
|
6979
|
+
logErrorInfo(severity, error, ErrorInfo.CAUSE, [error.cause], subErrors);
|
|
6980
|
+
}
|
|
6981
|
+
// @ts-expect-error AggregateError has an `errors` property.
|
|
6982
|
+
if( error.errors) {
|
|
6983
|
+
// @ts-expect-error AggregateError has an `errors` property.
|
|
6984
|
+
logErrorInfo(severity, error, ErrorInfo.ERRORS, error.errors, subErrors);
|
|
6985
|
+
}
|
|
6854
6986
|
for( const noteLogArgs of noteLogArgsArray) {
|
|
6855
6987
|
logErrorInfo(severity, error, ErrorInfo.NOTE, noteLogArgs, subErrors);
|
|
6856
6988
|
}
|
|
@@ -6896,11 +7028,105 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
|
|
|
6896
7028
|
};$h_once.makeCausalConsole(makeCausalConsole);
|
|
6897
7029
|
freeze(makeCausalConsole);
|
|
6898
7030
|
|
|
7031
|
+
/**
|
|
7032
|
+
* @typedef {(...args: unknown[]) => void} Logger
|
|
7033
|
+
*/
|
|
6899
7034
|
|
|
6900
|
-
|
|
7035
|
+
/**
|
|
7036
|
+
* This is a rather horrible kludge to indent the output to a logger in
|
|
7037
|
+
* the case where some arguments are strings containing newlines. Part of
|
|
7038
|
+
* the problem is that console-like loggers, including the one in ava,
|
|
7039
|
+
* join the string arguments of the log message with a space.
|
|
7040
|
+
* Because of this, there's an extra space at the beginning of each of
|
|
7041
|
+
* the split lines. So this kludge compensated by putting an extra empty
|
|
7042
|
+
* string at the beginning, so that the logger will add the same extra
|
|
7043
|
+
* joiner.
|
|
7044
|
+
* TODO: Fix this horrible kludge, and indent in a sane manner.
|
|
7045
|
+
*
|
|
7046
|
+
* @param {string} str
|
|
7047
|
+
* @param {string} sep
|
|
7048
|
+
* @param {string[]} indents
|
|
7049
|
+
* @returns {string[]}
|
|
7050
|
+
*/
|
|
7051
|
+
const indentAfterAllSeps= (str, sep, indents)=> {
|
|
7052
|
+
const [firstLine, ...restLines]= stringSplit(str, sep);
|
|
7053
|
+
const indentedRest= arrayFlatMap(restLines, (line)=>[sep, ...indents, line]);
|
|
7054
|
+
return ['', firstLine, ...indentedRest];
|
|
7055
|
+
};
|
|
7056
|
+
|
|
7057
|
+
/**
|
|
7058
|
+
* @param {LoggedErrorHandler} loggedErrorHandler
|
|
7059
|
+
*/
|
|
7060
|
+
const defineCausalConsoleFromLogger= (loggedErrorHandler)=>{
|
|
7061
|
+
/**
|
|
7062
|
+
* Implement the `VirtualConsole` API badly by turning all calls into
|
|
7063
|
+
* calls on `tlogger`. We need to do this to have `console` logging
|
|
7064
|
+
* turn into calls to Ava's `t.log`, so these console log messages
|
|
7065
|
+
* are output in the right place.
|
|
7066
|
+
*
|
|
7067
|
+
* @param {Logger} tlogger
|
|
7068
|
+
* @returns {VirtualConsole}
|
|
7069
|
+
*/
|
|
7070
|
+
const makeCausalConsoleFromLogger= (tlogger)=>{
|
|
7071
|
+
const indents= [];
|
|
7072
|
+
const logWithIndent= (...args)=> {
|
|
7073
|
+
if( indents.length> 0) {
|
|
7074
|
+
args= arrayFlatMap(args, (arg)=>
|
|
7075
|
+
typeof arg=== 'string'&& stringIncludes(arg, '\n')?
|
|
7076
|
+
indentAfterAllSeps(arg, '\n', indents):
|
|
7077
|
+
[arg]);
|
|
7078
|
+
|
|
7079
|
+
args= [...indents, ...args];
|
|
7080
|
+
}
|
|
7081
|
+
return tlogger(...args);
|
|
7082
|
+
};
|
|
7083
|
+
const makeNamed= (name, fn)=>
|
|
7084
|
+
({ [name]: (...args)=> fn(...args)})[ name];
|
|
7085
|
+
|
|
7086
|
+
const baseConsole= fromEntries([
|
|
7087
|
+
...arrayMap(consoleLevelMethods, ([name])=> [
|
|
7088
|
+
name,
|
|
7089
|
+
makeNamed(name, logWithIndent)]),
|
|
7090
|
+
|
|
7091
|
+
...arrayMap(consoleOtherMethods, ([name])=> [
|
|
7092
|
+
name,
|
|
7093
|
+
makeNamed(name, (...args)=> logWithIndent(name, ...args))])]);
|
|
7094
|
+
|
|
7095
|
+
|
|
7096
|
+
// https://console.spec.whatwg.org/#grouping
|
|
7097
|
+
for( const name of ['group', 'groupCollapsed']) {
|
|
7098
|
+
if( baseConsole[name]) {
|
|
7099
|
+
baseConsole[name]= makeNamed(name, (...args)=> {
|
|
7100
|
+
if( args.length>= 1) {
|
|
7101
|
+
// Prefix the logged data with "group" or "groupCollapsed".
|
|
7102
|
+
logWithIndent(...args);
|
|
7103
|
+
}
|
|
7104
|
+
// A single space is enough;
|
|
7105
|
+
// the host console will separate them with additional spaces.
|
|
7106
|
+
arrayPush(indents, ' ');
|
|
7107
|
+
});
|
|
7108
|
+
}
|
|
7109
|
+
}
|
|
7110
|
+
if( baseConsole.groupEnd) {
|
|
7111
|
+
baseConsole.groupEnd= makeNamed('groupEnd', (...args)=> {
|
|
7112
|
+
arrayPop(indents);
|
|
7113
|
+
});
|
|
7114
|
+
}
|
|
7115
|
+
harden(baseConsole);
|
|
7116
|
+
const causalConsole= makeCausalConsole(
|
|
7117
|
+
/** @type {VirtualConsole} */ baseConsole,
|
|
7118
|
+
loggedErrorHandler);
|
|
7119
|
+
|
|
7120
|
+
return (/** @type {VirtualConsole} */ causalConsole);
|
|
7121
|
+
};
|
|
7122
|
+
return freeze(makeCausalConsoleFromLogger);
|
|
7123
|
+
};$h_once.defineCausalConsoleFromLogger(defineCausalConsoleFromLogger);
|
|
7124
|
+
freeze(defineCausalConsoleFromLogger);
|
|
7125
|
+
|
|
7126
|
+
// ///////////////////////// Filter Console ////////////////////////////////////
|
|
6901
7127
|
|
|
6902
7128
|
/** @type {FilterConsole} */
|
|
6903
|
-
const
|
|
7129
|
+
const filterConsole= (baseConsole, filter, _topic= undefined)=> {
|
|
6904
7130
|
// TODO do something with optional topic string
|
|
6905
7131
|
const whitelist= arrayFilter(
|
|
6906
7132
|
consoleWhitelist,
|
|
@@ -7112,14 +7338,14 @@ const tameConsole= (
|
|
|
7112
7338
|
typeof globalThis.console!== 'undefined'?
|
|
7113
7339
|
globalThis.console:
|
|
7114
7340
|
typeof globalThis.print=== 'function'?
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7341
|
+
// Make a good-enough console for eshost (including only functions that
|
|
7342
|
+
// log at a specific level with no special argument interpretation).
|
|
7343
|
+
// https://console.spec.whatwg.org/#logging
|
|
7344
|
+
((p)=>freeze({ debug: p, log: p, info: p, warn: p, error: p}))(
|
|
7345
|
+
// eslint-disable-next-line no-undef
|
|
7346
|
+
wrapLogger(globalThis.print)):
|
|
7121
7347
|
|
|
7122
|
-
|
|
7348
|
+
undefined;
|
|
7123
7349
|
|
|
7124
7350
|
|
|
7125
7351
|
// Upgrade a log-only console (as in `eshost -h SpiderMonkey`).
|
|
@@ -10464,7 +10690,60 @@ globalThis.assert= assert;
|
|
|
10464
10690
|
})()
|
|
10465
10691
|
,
|
|
10466
10692
|
// === functors[53] ===
|
|
10467
|
-
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict';
|
|
10693
|
+
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict'; let symbolFor,globalThis,defineCausalConsoleFromLogger,loggedErrorHandler;$h_imports([["./commons.js", [["symbolFor", [$h_a => (symbolFor = $h_a)]],["globalThis", [$h_a => (globalThis = $h_a)]]]],["./error/console.js", [["defineCausalConsoleFromLogger", [$h_a => (defineCausalConsoleFromLogger = $h_a)]]]],["./error/assert.js", [["loggedErrorHandler", [$h_a => (loggedErrorHandler = $h_a)]]]]]);
|
|
10694
|
+
|
|
10695
|
+
|
|
10696
|
+
|
|
10697
|
+
// TODO possible additional exports. Some are privileged.
|
|
10698
|
+
// export { loggedErrorHandler };
|
|
10699
|
+
// export {
|
|
10700
|
+
// makeCausalConsole,
|
|
10701
|
+
// consoleLevelMethods,
|
|
10702
|
+
// consoleOtherMethods,
|
|
10703
|
+
// makeLoggingConsoleKit,
|
|
10704
|
+
// filterConsole,
|
|
10705
|
+
// pumpLogToConsole,
|
|
10706
|
+
// } from './src/error/console.js';
|
|
10707
|
+
// export { assertLogs, throwsAndLogs } from './src/error/throws-and-logs.js';
|
|
10708
|
+
|
|
10709
|
+
/**
|
|
10710
|
+
* Makes a Console like the
|
|
10711
|
+
* [SES causal `console`](https://github.com/endojs/endo/blob/master/packages/ses/src/error/README.md)
|
|
10712
|
+
* but whose output is redirected to the supplied `logger` function.
|
|
10713
|
+
*/
|
|
10714
|
+
const makeCausalConsoleFromLoggerForSesAva=
|
|
10715
|
+
defineCausalConsoleFromLogger(loggedErrorHandler);
|
|
10716
|
+
|
|
10717
|
+
/**
|
|
10718
|
+
*`makeCausalConsoleFromLoggerForSesAva` is privileged because it exposes
|
|
10719
|
+
* unredacted error info onto the `Logger` provided by the caller. It
|
|
10720
|
+
* should not be made available to non-privileged code.
|
|
10721
|
+
*
|
|
10722
|
+
* Further, we consider this particular API choice to be experimental
|
|
10723
|
+
* and may change in the future. It is currently only intended for use by
|
|
10724
|
+
* `@endo/ses-ava`, with which it will be co-maintained.
|
|
10725
|
+
*
|
|
10726
|
+
* Thus, this `console-shim.js` makes `makeCausalConsoleFromLoggerForSesAva`
|
|
10727
|
+
* available on `globalThis` which it *assumes* is the global of the start
|
|
10728
|
+
* compartment and is therefore allowed to hold powers that should not be
|
|
10729
|
+
* available in constructed compartments. It makes it available as the value of
|
|
10730
|
+
* a global property named by a registered symbol named
|
|
10731
|
+
* `MAKE_CAUSAL_CONSOLE_FROM_LOGGER_KEY_FOR_SES_AVA`.
|
|
10732
|
+
*
|
|
10733
|
+
* Anyone accessing this, including `@endo/ses-ava`, should feature test for
|
|
10734
|
+
* this and be tolerant of its absence. It may indeed disappear from later
|
|
10735
|
+
* versions of the ses-shim.
|
|
10736
|
+
*/
|
|
10737
|
+
const MAKE_CAUSAL_CONSOLE_FROM_LOGGER_KEY_FOR_SES_AVA= symbolFor(
|
|
10738
|
+
'MAKE_CAUSAL_CONSOLE_FROM_LOGGER_KEY_FOR_SES_AVA');
|
|
10739
|
+
|
|
10740
|
+
|
|
10741
|
+
globalThis[MAKE_CAUSAL_CONSOLE_FROM_LOGGER_KEY_FOR_SES_AVA]=
|
|
10742
|
+
makeCausalConsoleFromLoggerForSesAva;
|
|
10743
|
+
})()
|
|
10744
|
+
,
|
|
10745
|
+
// === functors[54] ===
|
|
10746
|
+
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { 'use strict'; $h_imports([["./src/lockdown-shim.js", []],["./src/compartment-shim.js", []],["./src/assert-shim.js", []],["./src/console-shim.js", []]]);
|
|
10468
10747
|
})()
|
|
10469
10748
|
,
|
|
10470
10749
|
]; // functors end
|
|
@@ -10515,6 +10794,7 @@ globalThis.assert= assert;
|
|
|
10515
10794
|
ReferenceError: cell("ReferenceError"),
|
|
10516
10795
|
SyntaxError: cell("SyntaxError"),
|
|
10517
10796
|
TypeError: cell("TypeError"),
|
|
10797
|
+
AggregateError: cell("AggregateError"),
|
|
10518
10798
|
assign: cell("assign"),
|
|
10519
10799
|
create: cell("create"),
|
|
10520
10800
|
defineProperties: cell("defineProperties"),
|
|
@@ -10573,6 +10853,7 @@ globalThis.assert= assert;
|
|
|
10573
10853
|
arrayIncludes: cell("arrayIncludes"),
|
|
10574
10854
|
arrayJoin: cell("arrayJoin"),
|
|
10575
10855
|
arrayMap: cell("arrayMap"),
|
|
10856
|
+
arrayFlatMap: cell("arrayFlatMap"),
|
|
10576
10857
|
arrayPop: cell("arrayPop"),
|
|
10577
10858
|
arrayPush: cell("arrayPush"),
|
|
10578
10859
|
arraySlice: cell("arraySlice"),
|
|
@@ -10659,12 +10940,12 @@ globalThis.assert= assert;
|
|
|
10659
10940
|
makeHardener: cell("makeHardener"),
|
|
10660
10941
|
},
|
|
10661
10942
|
{
|
|
10943
|
+
NativeErrors: cell("NativeErrors"),
|
|
10662
10944
|
constantProperties: cell("constantProperties"),
|
|
10663
10945
|
universalPropertyNames: cell("universalPropertyNames"),
|
|
10664
10946
|
initialGlobalPropertyNames: cell("initialGlobalPropertyNames"),
|
|
10665
10947
|
sharedGlobalPropertyNames: cell("sharedGlobalPropertyNames"),
|
|
10666
10948
|
uniqueGlobalPropertyNames: cell("uniqueGlobalPropertyNames"),
|
|
10667
|
-
NativeErrors: cell("NativeErrors"),
|
|
10668
10949
|
FunctionInstance: cell("FunctionInstance"),
|
|
10669
10950
|
AsyncFunctionInstance: cell("AsyncFunctionInstance"),
|
|
10670
10951
|
isAccessorPermit: cell("isAccessorPermit"),
|
|
@@ -10753,10 +11034,13 @@ globalThis.assert= assert;
|
|
|
10753
11034
|
tameDomains: cell("tameDomains"),
|
|
10754
11035
|
},
|
|
10755
11036
|
{
|
|
11037
|
+
consoleLevelMethods: cell("consoleLevelMethods"),
|
|
11038
|
+
consoleOtherMethods: cell("consoleOtherMethods"),
|
|
10756
11039
|
makeLoggingConsoleKit: cell("makeLoggingConsoleKit"),
|
|
11040
|
+
pumpLogToConsole: cell("pumpLogToConsole"),
|
|
10757
11041
|
makeCausalConsole: cell("makeCausalConsole"),
|
|
11042
|
+
defineCausalConsoleFromLogger: cell("defineCausalConsoleFromLogger"),
|
|
10758
11043
|
filterConsole: cell("filterConsole"),
|
|
10759
|
-
consoleWhitelist: cell("consoleWhitelist"),
|
|
10760
11044
|
},
|
|
10761
11045
|
{
|
|
10762
11046
|
makeRejectionHandlers: cell("makeRejectionHandlers"),
|
|
@@ -10821,6 +11105,8 @@ globalThis.assert= assert;
|
|
|
10821
11105
|
},
|
|
10822
11106
|
{
|
|
10823
11107
|
},
|
|
11108
|
+
{
|
|
11109
|
+
},
|
|
10824
11110
|
];
|
|
10825
11111
|
|
|
10826
11112
|
Object.defineProperties(cells[3], Object.getOwnPropertyDescriptors(cells[2]));
|
|
@@ -10884,6 +11170,7 @@ function observeImports(map, importName, importIndex) {
|
|
|
10884
11170
|
ReferenceError: cells[0].ReferenceError.set,
|
|
10885
11171
|
SyntaxError: cells[0].SyntaxError.set,
|
|
10886
11172
|
TypeError: cells[0].TypeError.set,
|
|
11173
|
+
AggregateError: cells[0].AggregateError.set,
|
|
10887
11174
|
assign: cells[0].assign.set,
|
|
10888
11175
|
create: cells[0].create.set,
|
|
10889
11176
|
defineProperties: cells[0].defineProperties.set,
|
|
@@ -10942,6 +11229,7 @@ function observeImports(map, importName, importIndex) {
|
|
|
10942
11229
|
arrayIncludes: cells[0].arrayIncludes.set,
|
|
10943
11230
|
arrayJoin: cells[0].arrayJoin.set,
|
|
10944
11231
|
arrayMap: cells[0].arrayMap.set,
|
|
11232
|
+
arrayFlatMap: cells[0].arrayFlatMap.set,
|
|
10945
11233
|
arrayPop: cells[0].arrayPop.set,
|
|
10946
11234
|
arrayPush: cells[0].arrayPush.set,
|
|
10947
11235
|
arraySlice: cells[0].arraySlice.set,
|
|
@@ -11124,16 +11412,17 @@ function observeImports(map, importName, importIndex) {
|
|
|
11124
11412
|
functors[11]({
|
|
11125
11413
|
imports(entries) {
|
|
11126
11414
|
const map = new Map(entries);
|
|
11415
|
+
observeImports(map, "./commons.js", 0);
|
|
11127
11416
|
},
|
|
11128
11417
|
liveVar: {
|
|
11129
11418
|
},
|
|
11130
11419
|
onceVar: {
|
|
11420
|
+
NativeErrors: cells[11].NativeErrors.set,
|
|
11131
11421
|
constantProperties: cells[11].constantProperties.set,
|
|
11132
11422
|
universalPropertyNames: cells[11].universalPropertyNames.set,
|
|
11133
11423
|
initialGlobalPropertyNames: cells[11].initialGlobalPropertyNames.set,
|
|
11134
11424
|
sharedGlobalPropertyNames: cells[11].sharedGlobalPropertyNames.set,
|
|
11135
11425
|
uniqueGlobalPropertyNames: cells[11].uniqueGlobalPropertyNames.set,
|
|
11136
|
-
NativeErrors: cells[11].NativeErrors.set,
|
|
11137
11426
|
FunctionInstance: cells[11].FunctionInstance.set,
|
|
11138
11427
|
AsyncFunctionInstance: cells[11].AsyncFunctionInstance.set,
|
|
11139
11428
|
isAccessorPermit: cells[11].isAccessorPermit.set,
|
|
@@ -11449,10 +11738,13 @@ function observeImports(map, importName, importIndex) {
|
|
|
11449
11738
|
liveVar: {
|
|
11450
11739
|
},
|
|
11451
11740
|
onceVar: {
|
|
11741
|
+
consoleLevelMethods: cells[34].consoleLevelMethods.set,
|
|
11742
|
+
consoleOtherMethods: cells[34].consoleOtherMethods.set,
|
|
11452
11743
|
makeLoggingConsoleKit: cells[34].makeLoggingConsoleKit.set,
|
|
11744
|
+
pumpLogToConsole: cells[34].pumpLogToConsole.set,
|
|
11453
11745
|
makeCausalConsole: cells[34].makeCausalConsole.set,
|
|
11746
|
+
defineCausalConsoleFromLogger: cells[34].defineCausalConsoleFromLogger.set,
|
|
11454
11747
|
filterConsole: cells[34].filterConsole.set,
|
|
11455
|
-
consoleWhitelist: cells[34].consoleWhitelist.set,
|
|
11456
11748
|
},
|
|
11457
11749
|
importMeta: {},
|
|
11458
11750
|
});
|
|
@@ -11735,11 +12027,25 @@ function observeImports(map, importName, importIndex) {
|
|
|
11735
12027
|
importMeta: {},
|
|
11736
12028
|
});
|
|
11737
12029
|
functors[53]({
|
|
12030
|
+
imports(entries) {
|
|
12031
|
+
const map = new Map(entries);
|
|
12032
|
+
observeImports(map, "./commons.js", 0);
|
|
12033
|
+
observeImports(map, "./error/console.js", 34);
|
|
12034
|
+
observeImports(map, "./error/assert.js", 9);
|
|
12035
|
+
},
|
|
12036
|
+
liveVar: {
|
|
12037
|
+
},
|
|
12038
|
+
onceVar: {
|
|
12039
|
+
},
|
|
12040
|
+
importMeta: {},
|
|
12041
|
+
});
|
|
12042
|
+
functors[54]({
|
|
11738
12043
|
imports(entries) {
|
|
11739
12044
|
const map = new Map(entries);
|
|
11740
12045
|
observeImports(map, "./src/lockdown-shim.js", 50);
|
|
11741
12046
|
observeImports(map, "./src/compartment-shim.js", 51);
|
|
11742
12047
|
observeImports(map, "./src/assert-shim.js", 52);
|
|
12048
|
+
observeImports(map, "./src/console-shim.js", 53);
|
|
11743
12049
|
},
|
|
11744
12050
|
liveVar: {
|
|
11745
12051
|
},
|