From 289611302aa4ae92c0e7816465ca4227a86d81c4 Mon Sep 17 00:00:00 2001 From: LeoTM <1881059+leotm@users.noreply.github.com> Date: Wed, 15 May 2024 18:43:19 +0100 Subject: [PATCH] chore: bump SES - includes https://github.com/endojs/endo/pull/2206 - includes https://github.com/MetaMask/metamask-mobile/pull/8786 `curl -O https://npmfs.com/download/ses/1.5.0/dist/ses.cjs` --- ses.cjs | 1995 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 1166 insertions(+), 829 deletions(-) diff --git a/ses.cjs b/ses.cjs index f6635d3d0a4..5f911b4b02a 100644 --- a/ses.cjs +++ b/ses.cjs @@ -1,9 +1,9 @@ -// ses@1.1.0 +// ses@1.5.0 'use strict'; (() => { const functors = [ // === functors[0] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /* global globalThis */ +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; $h‍_imports([]); /* global globalThis */ /* eslint-disable no-restricted-globals */ /** @@ -51,8 +51,9 @@ const { RangeError, ReferenceError, SyntaxError, - TypeError}= - globalThis;$h‍_once.FERAL_ERROR(FERAL_ERROR);$h‍_once.RangeError(RangeError);$h‍_once.ReferenceError(ReferenceError);$h‍_once.SyntaxError(SyntaxError);$h‍_once.TypeError(TypeError); + TypeError, + AggregateError}= + 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); const { assign, @@ -137,6 +138,10 @@ const { prototype: weakmapPrototype}= WeakMap;$h‍_once.weakmapPrototy const { prototype: weaksetPrototype}= WeakSet;$h‍_once.weaksetPrototype(weaksetPrototype); const { prototype: functionPrototype}= Function;$h‍_once.functionPrototype(functionPrototype); const { prototype: promisePrototype}= Promise;$h‍_once.promisePrototype(promisePrototype); +const { prototype: generatorPrototype}= getPrototypeOf( + // eslint-disable-next-line no-empty-function, func-names + function*() { });$h‍_once.generatorPrototype(generatorPrototype); + const typedArrayPrototype= getPrototypeOf(Uint8Array.prototype);$h‍_once.typedArrayPrototype(typedArrayPrototype); @@ -163,6 +168,9 @@ const arrayIncludes= uncurryThis(arrayPrototype.includes);$h‍_once.arr const arrayJoin= uncurryThis(arrayPrototype.join); /** @type {(thisArg: readonly T[], callbackfn: (value: T, index: number, array: T[]) => U, cbThisArg?: any) => U[]} */$h‍_once.arrayJoin(arrayJoin); const arrayMap= /** @type {any} */ uncurryThis(arrayPrototype.map);$h‍_once.arrayMap(arrayMap); +const arrayFlatMap= /** @type {any} */ + uncurryThis(arrayPrototype.flatMap);$h‍_once.arrayFlatMap(arrayFlatMap); + const arrayPop= uncurryThis(arrayPrototype.pop); /** @type {(thisArg: T[], ...items: T[]) => number} */$h‍_once.arrayPop(arrayPop); const arrayPush= uncurryThis(arrayPrototype.push);$h‍_once.arrayPush(arrayPush); @@ -191,13 +199,16 @@ const matchAllRegExp= uncurryThis(regexpPrototype[matchAllSymbol]); $h‍_once.matchAllRegExp(matchAllRegExp);const stringEndsWith=uncurryThis(stringPrototype.endsWith);$h‍_once.stringEndsWith(stringEndsWith); const stringIncludes= uncurryThis(stringPrototype.includes);$h‍_once.stringIncludes(stringIncludes); const stringIndexOf= uncurryThis(stringPrototype.indexOf);$h‍_once.stringIndexOf(stringIndexOf); -const stringMatch= uncurryThis(stringPrototype.match); +const stringMatch= uncurryThis(stringPrototype.match);$h‍_once.stringMatch(stringMatch); +const generatorNext= uncurryThis(generatorPrototype.next);$h‍_once.generatorNext(generatorNext); +const generatorThrow= uncurryThis(generatorPrototype.throw); + /** * @type { & * ((thisArg: string, searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string) => string) & * ((thisArg: string, searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string) => string) * } - */$h‍_once.stringMatch(stringMatch); + */$h‍_once.generatorThrow(generatorThrow); const stringReplace= /** @type {any} */ uncurryThis(stringPrototype.replace);$h‍_once.stringReplace(stringReplace); @@ -217,9 +228,10 @@ const weakmapSet= uncurryThis(weakmapPrototype.set); $h‍_once.weakmapSet(weakmapSet);const weaksetAdd=uncurryThis(weaksetPrototype.add);$h‍_once.weaksetAdd(weaksetAdd); const weaksetHas= uncurryThis(weaksetPrototype.has); // -$h‍_once.weaksetHas(weaksetHas);const functionToString=uncurryThis(functionPrototype.toString); +$h‍_once.weaksetHas(weaksetHas);const functionToString=uncurryThis(functionPrototype.toString);$h‍_once.functionToString(functionToString); +const functionBind= uncurryThis(bind); // -$h‍_once.functionToString(functionToString);const{all}=Promise; +$h‍_once.functionBind(functionBind);const{all}=Promise; const promiseAll= (promises)=>apply(all, Promise, [promises]);$h‍_once.promiseAll(promiseAll); const promiseCatch= uncurryThis(promisePrototype.catch); /** @type {(thisArg: T, onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null) => Promise} */$h‍_once.promiseCatch(promiseCatch); @@ -294,11 +306,69 @@ $h‍_once.FERAL_EVAL(FERAL_EVAL);const FERAL_FUNCTION=Function;$h‍_once.FERAL const noEvalEvaluate= ()=> { // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_NO_EVAL.md throw TypeError('Cannot eval with evalTaming set to "noEval" (SES_NO_EVAL)'); - };$h‍_once.noEvalEvaluate(noEvalEvaluate); + }; + +// ////////////////// FERAL_STACK_GETTER FERAL_STACK_SETTER //////////////////// +$h‍_once.noEvalEvaluate(noEvalEvaluate); +const er1StackDesc= getOwnPropertyDescriptor(Error('er1'), 'stack'); +const er2StackDesc= getOwnPropertyDescriptor(TypeError('er2'), 'stack'); + +let feralStackGetter; +let feralStackSetter; +if( er1StackDesc&& er2StackDesc&& er1StackDesc.get) { + // We should only encounter this case on v8 because of its problematic + // error own stack accessor behavior. + // Note that FF/SpiderMonkey, Moddable/XS, and the error stack proposal + // all inherit a stack accessor property from Error.prototype, which is + // great. That case needs no heroics to secure. + if( + // In the v8 case as we understand it, all errors have an own stack + // accessor property, but within the same realm, all these accessor + // properties have the same getter and have the same setter. + // This is therefore the case that we repair. + typeof er1StackDesc.get=== 'function'&& + er1StackDesc.get=== er2StackDesc.get&& + typeof er1StackDesc.set=== 'function'&& + er1StackDesc.set=== er2StackDesc.set) + { + // Otherwise, we have own stack accessor properties that are outside + // our expectations, that therefore need to be understood better + // before we know how to repair them. + feralStackGetter= freeze(er1StackDesc.get); + feralStackSetter= freeze(er1StackDesc.set); + }else { + // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_UNEXPECTED_ERROR_OWN_STACK_ACCESSOR.md + throw TypeError( + 'Unexpected Error own stack accessor functions (SES_UNEXPECTED_ERROR_OWN_STACK_ACCESSOR)'); + + } + } + +/** + * If on a v8 with the problematic error own stack accessor behavior, + * `FERAL_STACK_GETTER` will be the shared getter of all those accessors + * and `FERAL_STACK_SETTER` will be the shared setter. On any platform + * without this problem, `FERAL_STACK_GETTER` and `FERAL_STACK_SETTER` are + * both `undefined`. + * + * @type {(() => any) | undefined} + */ +const FERAL_STACK_GETTER= feralStackGetter; + +/** + * If on a v8 with the problematic error own stack accessor behavior, + * `FERAL_STACK_GETTER` will be the shared getter of all those accessors + * and `FERAL_STACK_SETTER` will be the shared setter. On any platform + * without this problem, `FERAL_STACK_GETTER` and `FERAL_STACK_SETTER` are + * both `undefined`. + * + * @type {((newValue: any) => void) | undefined} + */$h‍_once.FERAL_STACK_GETTER(FERAL_STACK_GETTER); +const FERAL_STACK_SETTER= feralStackSetter;$h‍_once.FERAL_STACK_SETTER(FERAL_STACK_SETTER); })() , // === functors[1] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]]]]]); +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let TypeError;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]]]]]); /** getThis returns globalThis in sloppy mode or undefined in strict mode. */ function getThis() { @@ -312,7 +382,7 @@ if( getThis()) { })() , // === functors[2] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /* global globalThis */ +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; $h‍_imports([]); /* global globalThis */ // @ts-check // `@endo/env-options` needs to be imported quite early, and so should @@ -452,11 +522,11 @@ const { })() , // === functors[3] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([["./src/env-options.js", []]]); +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; $h‍_imports([["./src/env-options.js", []]]); })() , // === functors[4] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Set,String,isArray,arrayJoin,arraySlice,arraySort,arrayMap,keys,fromEntries,freeze,is,isError,setAdd,setHas,stringIncludes,stringStartsWith,stringifyJson,toStringTagSymbol;$h‍_imports([["../commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["arraySort", [$h‍_a => (arraySort = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["keys", [$h‍_a => (keys = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isError", [$h‍_a => (isError = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]],["stringIncludes", [$h‍_a => (stringIncludes = $h‍_a)]],["stringStartsWith", [$h‍_a => (stringStartsWith = $h‍_a)]],["stringifyJson", [$h‍_a => (stringifyJson = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]); +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Set,String,isArray,arrayJoin,arraySlice,arraySort,arrayMap,keys,fromEntries,freeze,is,isError,setAdd,setHas,stringIncludes,stringStartsWith,stringifyJson,toStringTagSymbol;$h‍_imports([["../commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["arraySort", [$h‍_a => (arraySort = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["keys", [$h‍_a => (keys = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isError", [$h‍_a => (isError = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]],["stringIncludes", [$h‍_a => (stringIncludes = $h‍_a)]],["stringStartsWith", [$h‍_a => (stringStartsWith = $h‍_a)]],["stringifyJson", [$h‍_a => (stringifyJson = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]); @@ -478,6 +548,8 @@ const { + +/** @import {StringablePayload} from '../../types.js' */ /** * Joins English terms with commas and an optional conjunction. @@ -651,355 +723,9 @@ freeze(bestEffortStringify); })() , // === functors[5] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); // @ts-check - -/** - * @callback BaseAssert - * The `assert` function itself. - * - * @param {any} flag The truthy/falsy value - * @param {Details=} optDetails The details to throw - * @param {ErrorConstructor=} ErrorConstructor An optional alternate error - * constructor to use. - * @returns {asserts flag} - */ - -/** - * @typedef {object} AssertMakeErrorOptions - * @property {string=} errorName - */ - -/** - * @callback AssertMakeError - * - * The `assert.error` method, recording details for the console. - * - * The optional `optDetails` can be a string. - * @param {Details=} optDetails The details of what was asserted - * @param {ErrorConstructor=} ErrorConstructor An optional alternate error - * constructor to use. - * @param {AssertMakeErrorOptions=} options - * @returns {Error} - */ - -/** - * @callback AssertFail - * - * The `assert.fail` method. - * - * Fail an assertion, recording full details to the console and - * raising an exception with a message in which `details` substitution values - * have been redacted. - * - * The optional `optDetails` can be a string for backwards compatibility - * with the nodejs assertion library. - * @param {Details=} optDetails The details of what was asserted - * @param {ErrorConstructor=} ErrorConstructor An optional alternate error - * constructor to use. - * @returns {never} - */ - -/** - * @callback AssertEqual - * The `assert.equal` method - * - * Assert that two values must be `Object.is`. - * @param {any} actual The value we received - * @param {any} expected What we wanted - * @param {Details=} optDetails The details to throw - * @param {ErrorConstructor=} ErrorConstructor An optional alternate error - * constructor to use. - * @returns {void} - */ - -// Type all the overloads of the assertTypeof function. -// There may eventually be a better way to do this, but -// thems the breaks with Typescript 4.0. -/** - * @callback AssertTypeofBigint - * @param {any} specimen - * @param {'bigint'} typename - * @param {Details=} optDetails - * @returns {asserts specimen is bigint} - */ - -/** - * @callback AssertTypeofBoolean - * @param {any} specimen - * @param {'boolean'} typename - * @param {Details=} optDetails - * @returns {asserts specimen is boolean} - */ - -/** - * @callback AssertTypeofFunction - * @param {any} specimen - * @param {'function'} typename - * @param {Details=} optDetails - * @returns {asserts specimen is Function} - */ - -/** - * @callback AssertTypeofNumber - * @param {any} specimen - * @param {'number'} typename - * @param {Details=} optDetails - * @returns {asserts specimen is number} - */ - -/** - * @callback AssertTypeofObject - * @param {any} specimen - * @param {'object'} typename - * @param {Details=} optDetails - * @returns {asserts specimen is Record | null} - */ - -/** - * @callback AssertTypeofString - * @param {any} specimen - * @param {'string'} typename - * @param {Details=} optDetails - * @returns {asserts specimen is string} - */ - -/** - * @callback AssertTypeofSymbol - * @param {any} specimen - * @param {'symbol'} typename - * @param {Details=} optDetails - * @returns {asserts specimen is symbol} - */ - -/** - * @callback AssertTypeofUndefined - * @param {any} specimen - * @param {'undefined'} typename - * @param {Details=} optDetails - * @returns {asserts specimen is undefined} - */ - -/** - * The `assert.typeof` method - * - * @typedef {AssertTypeofBigint & AssertTypeofBoolean & AssertTypeofFunction & AssertTypeofNumber & AssertTypeofObject & AssertTypeofString & AssertTypeofSymbol & AssertTypeofUndefined} AssertTypeof - */ - -/** - * @callback AssertString - * The `assert.string` method. - * - * `assert.string(v)` is equivalent to `assert.typeof(v, 'string')`. We - * special case this one because it is the most frequently used. - * - * Assert an expected typeof result. - * @param {any} specimen The value to get the typeof - * @param {Details=} optDetails The details to throw - * @returns {asserts specimen is string} - */ - -/** - * @callback AssertNote - * The `assert.note` method. - * - * Annotate an error with details, potentially to be used by an - * augmented console such as the causal console of `console.js`, to - * provide extra information associated with logged errors. - * - * @param {Error} error - * @param {Details} detailsNote - * @returns {void} - */ - -// ///////////////////////////////////////////////////////////////////////////// - -/** - * @typedef {{}} DetailsToken - * A call to the `details` template literal makes and returns a fresh details - * token, which is a frozen empty object associated with the arguments of that - * `details` template literal expression. - */ - -/** - * @typedef {string | DetailsToken} Details - * Either a plain string, or made by the `details` template literal tag. - */ - -/** - * @typedef {object} StringablePayload - * Holds the payload passed to quote so that its printed form is visible. - * @property {() => string} toString How to print the payload - */ - -/** - * To "declassify" and quote a substitution value used in a - * ``` details`...` ``` template literal, enclose that substitution expression - * in a call to `quote`. This makes the value appear quoted - * (as if with `JSON.stringify`) in the message of the thrown error. The - * payload itself is still passed unquoted to the console as it would be - * without `quote`. - * - * For example, the following will reveal the expected sky color, but not the - * actual incorrect sky color, in the thrown error's message: - * ```js - * sky.color === expectedColor || Fail`${sky.color} should be ${quote(expectedColor)}`; - * ``` - * - * // TODO Update SES-shim to new convention, where `details` is - * // renamed to `X` rather than `d`. - * The normal convention is to locally rename `details` to `d` and `quote` to `q` - * like `const { details: d, quote: q } = assert;`, so the above example would then be - * ```js - * sky.color === expectedColor || Fail`${sky.color} should be ${q(expectedColor)}`; - * ``` - * - * @callback AssertQuote - * @param {any} payload What to declassify - * @param {(string|number)=} spaces - * @returns {StringablePayload} The declassified payload - */ - -/** - * @callback Raise - * - * To make an `assert` which terminates some larger unit of computation - * like a transaction, vat, or process, call `makeAssert` with a `Raise` - * callback, where that callback actually performs that larger termination. - * If possible, the callback should also report its `reason` parameter as - * the alleged reason for the termination. - * - * @param {Error} reason - */ - -/** - * @callback MakeAssert - * - * Makes and returns an `assert` function object that shares the bookkeeping - * state defined by this module with other `assert` function objects made by - * `makeAssert`. This state is per-module-instance and is exposed by the - * `loggedErrorHandler` above. We refer to `assert` as a "function object" - * because it can be called directly as a function, but also has methods that - * can be called. - * - * If `optRaise` is provided, the returned `assert` function object will call - * `optRaise(reason)` before throwing the error. This enables `optRaise` to - * engage in even more violent termination behavior, like terminating the vat, - * that prevents execution from reaching the following throw. However, if - * `optRaise` returns normally, which would be unusual, the throw following - * `optRaise(reason)` would still happen. - * - * @param {Raise=} optRaise - * @param {boolean=} unredacted - * @returns {Assert} - */ - -/** - * @typedef {(template: TemplateStringsArray | string[], ...args: any) => DetailsToken} DetailsTag - * - * Use the `details` function as a template literal tag to create - * informative error messages. The assertion functions take such messages - * as optional arguments: - * ```js - * assert(sky.isBlue(), details`${sky.color} should be "blue"`); - * ``` - * // TODO Update SES-shim to new convention, where `details` is - * // renamed to `X` rather than `d`. - * or following the normal convention to locally rename `details` to `d` - * and `quote` to `q` like `const { details: d, quote: q } = assert;`: - * ```js - * assert(sky.isBlue(), d`${sky.color} should be "blue"`); - * ``` - * However, note that in most cases it is preferable to instead use the `Fail` - * template literal tag (which has the same input signature as `details` - * but automatically creates and throws an error): - * ```js - * sky.isBlue() || Fail`${sky.color} should be "blue"`; - * ``` - * - * The details template tag returns a `DetailsToken` object that can print - * itself with the formatted message in two ways. - * It will report full details to the console, but - * mask embedded substitution values with their typeof information in the thrown error - * to prevent revealing secrets up the exceptional path. In the example - * above, the thrown error may reveal only that `sky.color` is a string, - * whereas the same diagnostic printed to the console reveals that the - * sky was green. This masking can be disabled for an individual substitution value - * using `quote`. - * - * The `raw` property of an input template array is ignored, so a simple - * array of strings may be provided directly. - */ - -/** - * @typedef {(template: TemplateStringsArray | string[], ...args: any) => never} FailTag - * - * Use the `Fail` function as a template literal tag to efficiently - * create and throw a `details`-style error only when a condition is not satisfied. - * ```js - * condition || Fail`...complaint...`; - * ``` - * This avoids the overhead of creating usually-unnecessary errors like - * ```js - * assert(condition, details`...complaint...`); - * ``` - * while improving readability over alternatives like - * ```js - * condition || assert.fail(details`...complaint...`); - * ``` - * - * However, due to current weakness in TypeScript, static reasoning - * is less powerful with the `||` patterns than with an `assert` call. - * Until/unless https://github.com/microsoft/TypeScript/issues/51426 is fixed, - * for `||`-style assertions where this loss of static reasoning is a problem, - * instead express the assertion as - * ```js - * if (!condition) { - * Fail`...complaint...`; - * } - * ``` - * or, if needed, - * ```js - * if (!condition) { - * // `throw` is noop since `Fail` throws, but it improves static analysis - * throw Fail`...complaint...`; - * } - * ``` - */ - -/** - * assert that expr is truthy, with an optional details to describe - * the assertion. It is a tagged template literal like - * ```js - * assert(expr, details`....`);` - * ``` - * - * The literal portions of the template are assumed non-sensitive, as - * are the `typeof` types of the substitution values. These are - * assembled into the thrown error message. The actual contents of the - * substitution values are assumed sensitive, to be revealed to - * the console only. We assume only the virtual platform's owner can read - * what is written to the console, where the owner is in a privileged - * position over computation running on that platform. - * - * The optional `optDetails` can be a string for backwards compatibility - * with the nodejs assertion library. - * - * @typedef { BaseAssert & { - * typeof: AssertTypeof, - * error: AssertMakeError, - * fail: AssertFail, - * equal: AssertEqual, - * string: AssertString, - * note: AssertNote, - * details: DetailsTag, - * Fail: FailTag, - * quote: AssertQuote, - * bare: AssertQuote, - * makeAssert: MakeAssert, - * } } Assert - */ +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; $h‍_imports([]); // @ts-check -// ///////////////////////////////////////////////////////////////////////////// +/** @import {GenericErrorConstructor, AssertMakeErrorOptions, DetailsToken, StringablePayload} from '../../types.js' */ /** * @typedef {object} VirtualConsole @@ -1053,13 +779,13 @@ freeze(bestEffortStringify); * @callback FilterConsole * @param {VirtualConsole} baseConsole * @param {ConsoleFilter} filter - * @param {string=} topic + * @param {string} [topic] * @returns {VirtualConsole} */ })() , // === functors[6] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); // @ts-check +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; $h‍_imports([]); // @ts-check /** * @typedef {readonly any[]} LogArgs @@ -1130,7 +856,12 @@ freeze(bestEffortStringify); */ /** - * @typedef {{ NOTE: 'ERROR_NOTE:', MESSAGE: 'ERROR_MESSAGE:' }} ErrorInfo + * @typedef {{ + * NOTE: 'ERROR_NOTE:', + * MESSAGE: 'ERROR_MESSAGE:', + * CAUSE: 'cause:', + * ERRORS: 'errors:', + * }} ErrorInfo */ /** @@ -1151,14 +882,15 @@ freeze(bestEffortStringify); })() , // === functors[7] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([["./internal-types.js", []]]); - +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; $h‍_imports([]); // @ts-check +/* eslint-disable @endo/no-polymorphic-call */ - - - -const { freeze}= Object; +// eslint-disable-next-line no-restricted-globals const { isSafeInteger}= Number; +// eslint-disable-next-line no-restricted-globals +const { freeze}= Object; +// eslint-disable-next-line no-restricted-globals +const { toStringTag: toStringTagSymbol}= Symbol; /** * @template Data @@ -1205,9 +937,11 @@ const makeSelfCell= (data)=>{ */ const spliceAfter= (prev, selfCell)=> { if( prev=== selfCell) { + // eslint-disable-next-line no-restricted-globals throw TypeError('Cannot splice a cell into itself'); } if( selfCell.next!== selfCell|| selfCell.prev!== selfCell) { + // eslint-disable-next-line no-restricted-globals throw TypeError('Expected self-linked cell'); } const cell= selfCell; @@ -1255,10 +989,12 @@ const spliceOut= (cell)=>{ */ const makeLRUCacheMap= (keysBudget)=>{ if( !isSafeInteger(keysBudget)|| keysBudget< 0) { + // eslint-disable-next-line no-restricted-globals throw TypeError('keysBudget must be a safe non-negative integer number'); } /** @typedef {DoublyLinkedCell | undefined>} LRUCacheCell */ /** @type {WeakMap} */ + // eslint-disable-next-line no-restricted-globals const keyToCell= new WeakMap(); let size= 0; // `size` must remain <= `keysBudget` // As a sigil, `head` uniquely is not in the `keyToCell` map. @@ -1313,6 +1049,7 @@ const makeLRUCacheMap= (keysBudget)=>{ // Either a fresh cell or a reused condemned cell. size+= 1; // Add its data. + // eslint-disable-next-line no-restricted-globals cell.data= new WeakMap(); // Advertise the cell for this key. keyToCell.set(key, cell); @@ -1359,11 +1096,25 @@ const makeLRUCacheMap= (keysBudget)=>{ get, set, delete: deleteIt, - [Symbol.toStringTag]: 'LRUCacheMap'}); + // eslint-disable-next-line jsdoc/check-types + [/** @type {typeof Symbol.toStringTag} */ toStringTagSymbol]: + 'LRUCacheMap'}); return lruCacheMap; };$h‍_once.makeLRUCacheMap(makeLRUCacheMap); freeze(makeLRUCacheMap); +})() +, +// === functors[8] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let makeLRUCacheMap;$h‍_imports([["../make-lru-cachemap.js", [["makeLRUCacheMap", [$h‍_a => (makeLRUCacheMap = $h‍_a)]]]],["./internal-types.js", []]]); + + + + + + +const { freeze}= Object; +const { isSafeInteger}= Number; const defaultLoggedErrorsBudget= 1000; const defaultArgsPerErrorBudget= 100; @@ -1430,8 +1181,9 @@ const makeNoteLogArgsArrayKit= ( freeze(makeNoteLogArgsArrayKit); })() , -// === functors[8] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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)]]]]]); +// === functors[9] === +({ 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,getOwnPropertyDescriptors,ownKeys,create,objectPrototype,objectHasOwnProperty,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)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["objectPrototype", [$h‍_a => (objectPrototype = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $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)]]]]]); + @@ -1471,6 +1223,16 @@ freeze(makeNoteLogArgsArrayKit); + + + + + + + +/** + * @import {BaseAssert, Assert, AssertionFunctions, AssertionUtilities, StringablePayload, DetailsToken, MakeAssert} from '../../types.js' + */ // For our internal debugging purposes, uncomment // const internalDebugConsole = console; @@ -1480,7 +1242,7 @@ freeze(makeNoteLogArgsArrayKit); /** @type {WeakMap} */ const declassifiers= new WeakMap(); -/** @type {AssertQuote} */ +/** @type {AssertionUtilities['quote']} */ const quote= (payload, spaces= undefined)=> { const result= freeze({ toString: freeze(()=> bestEffortStringify(payload, spaces))}); @@ -1493,19 +1255,7 @@ freeze(quote); const canBeBare= freeze(/^[\w:-]( ?[\w:-])*$/); /** - * Embed a string directly into error details without wrapping punctuation. - * To avoid injection attacks that exploit quoting confusion, this must NEVER - * be used with data that is possibly attacker-controlled. - * As a further safeguard, we fall back to quoting any input that is not a - * string of sufficiently word-like parts separated by isolated spaces (rather - * than throwing an exception, which could hide the original problem for which - * explanatory details are being constructed---i.e., ``` assert.details`...` ``` - * should never be the source of a new exception, nor should an attempt to - * render its output, although we _could_ instead decide to handle the latter - * by inline replacement similar to that of `bestEffortStringify` for producing - * rendered messages like `(an object) was tagged "[Unsafe bare string]"`). - * - * @type {AssertQuote} + * @type {AssertionUtilities['bare']} */ const bare= (payload, spaces= undefined)=> { if( typeof payload!== 'string'|| !regexpTest(canBeBare, payload)) { @@ -1591,7 +1341,7 @@ freeze(DetailsTokenProto.toString); * of them should be uses where the template literal has no redacted * substitution values. In those cases, the two are equivalent. * - * @type {DetailsTag} + * @type {AssertionUtilities['details']} */ const redactedDetails= (template, ...args)=> { // Keep in mind that the vast majority of calls to `details` creates @@ -1600,7 +1350,7 @@ const redactedDetails= (template, ...args)=> { // all the work to happen only if needed, for example, if an assertion fails. const detailsToken= freeze({ __proto__: DetailsTokenProto}); weakmapSet(hiddenDetailsMap, detailsToken, { template, args}); - return detailsToken; + return (/** @type {DetailsToken} */ /** @type {unknown} */ detailsToken); }; freeze(redactedDetails); @@ -1615,7 +1365,7 @@ freeze(redactedDetails); * of safety. `unredactedDetails` also sacrifices the speed of `details`, * which is usually fine in debugging and testing. * - * @type {DetailsTag} + * @type {AssertionUtilities['details']} */ const unredactedDetails= (template, ...args)=> { args= arrayMap(args, (arg)=> @@ -1686,12 +1436,79 @@ const tagError= (err, optErrorName= err.name)=> { }; /** - * @type {AssertMakeError} + * Make reasonable best efforts to make a `Passable` error. + * - `sanitizeError` will remove any "extraneous" own properties already added + * by the host, + * such as `fileName`,`lineNumber` on FireFox or `line` on Safari. + * - If any such "extraneous" properties were removed, `sanitizeError` will + * annotate + * the error with them, so they still appear on the causal console + * log output for diagnostic purposes, but not be otherwise visible. + * - `sanitizeError` will ensure that any expected properties already + * added by the host are data + * properties, converting accessor properties to data properties as needed, + * such as `stack` on v8 (Chrome, Brave, Edge?) + * - `sanitizeError` will freeze the error, preventing any correct engine from + * adding or + * altering any of the error's own properties `sanitizeError` is done. + * + * However, `sanitizeError` will not, for example, `harden` + * (i.e., deeply freeze) + * or ensure that the `cause` or `errors` property satisfy the `Passable` + * constraints. The purpose of `sanitizeError` is only to protect against + * mischief the host may have already added to the error as created, + * not to ensure that the error is actually Passable. For that, + * see `toPassableError` in `@endo/pass-style`. + * + * @param {Error} error */ +const sanitizeError= (error)=>{ + const descs= getOwnPropertyDescriptors(error); + const { + name: _nameDesc, + message: _messageDesc, + errors: _errorsDesc= undefined, + cause: _causeDesc= undefined, + stack: _stackDesc= undefined, + ...restDescs}= + descs; + + const restNames= ownKeys(restDescs); + if( restNames.length>= 1) { + for( const name of restNames) { + delete error[name]; + } + const droppedNote= create(objectPrototype, restDescs); + // eslint-disable-next-line no-use-before-define + note( + error, + redactedDetails `originally with properties ${quote(droppedNote)}`); + + } + for( const name of ownKeys(error)) { + // @ts-expect-error TS still confused by symbols as property names + const desc= descs[name]; + if( desc&& objectHasOwnProperty(desc, 'get')) { + defineProperty(error, name, { + value: error[name] // invoke the getter to convert to data property +}); + } + } + freeze(error); + }; + +/** + * @type {AssertionUtilities['error']} + */$h‍_once.sanitizeError(sanitizeError); const makeError= ( optDetails= redactedDetails `Assert failed`, - ErrorConstructor= globalThis.Error, - { errorName= undefined}= {})=> + errConstructor= globalThis.Error, + { + errorName= undefined, + cause= undefined, + errors= undefined, + sanitize= true}= + {})=> { if( typeof optDetails=== 'string') { // If it is a string, use it as the literal part of the template so @@ -1703,11 +1520,36 @@ const makeError= ( throw TypeError( `unrecognized details ${quote(optDetails)}`); } const messageString= getMessageString(hiddenDetails); - const error= new ErrorConstructor(messageString); + const opts= cause&& { cause}; + let error; + if( + typeof AggregateError!== 'undefined'&& + errConstructor=== AggregateError) + { + error= AggregateError(errors|| [], messageString, opts); + }else { + error= /** @type {ErrorConstructor} */ errConstructor( + messageString, + opts); + + if( errors!== undefined) { + // Since we need to tolerate `errors` on an AggregateError, may as + // well tolerate it on all errors. + defineProperty(error, 'errors', { + value: errors, + writable: true, + enumerable: false, + configurable: true}); + + } + } weakmapSet(hiddenMessageLogArgs, error, getLogArgs(hiddenDetails)); if( errorName!== undefined) { tagError(error, errorName); } + if( sanitize) { + sanitizeError(error); + } // The next line is a particularly fruitful place to put a breakpoint. return error; }; @@ -1731,7 +1573,7 @@ const { addLogArgs, takeLogArgsArray}= makeNoteLogArgsArrayKit(); */ const hiddenNoteCallbackArrays= new WeakMap(); -/** @type {AssertNote} */ +/** @type {AssertionUtilities['note']} */ const note= (error, detailsNote)=> { if( typeof detailsNote=== 'string') { // If it is a string, use it as the literal part of the template so @@ -1812,20 +1654,22 @@ const makeAssert= (optRaise= undefined, unredacted= false)=> { const details= unredacted? unredactedDetails: redactedDetails; const assertFailedDetails= details `Check failed`; - /** @type {AssertFail} */ + /** @type {AssertionFunctions['fail']} */ const fail= ( optDetails= assertFailedDetails, - ErrorConstructor= globalThis.Error)=> + errConstructor= undefined, + options= undefined)=> { - const reason= makeError(optDetails, ErrorConstructor); + const reason= makeError(optDetails, errConstructor, options); if( optRaise!== undefined) { + // @ts-ignore returns `never` doesn't mean it isn't callable optRaise(reason); } throw reason; }; freeze(fail); - /** @type {FailTag} */ + /** @type {AssertionUtilities['Fail']} */ const Fail= (template, ...args)=> fail(details(template, ...args)); // Don't freeze or export `baseAssert` until we add methods. @@ -1835,27 +1679,30 @@ const makeAssert= (optRaise= undefined, unredacted= false)=> { function baseAssert( flag, optDetails= undefined, - ErrorConstructor= undefined) + errConstructor= undefined, + options= undefined) { - flag|| fail(optDetails, ErrorConstructor); + flag|| fail(optDetails, errConstructor, options); } - /** @type {AssertEqual} */ + /** @type {AssertionFunctions['equal']} */ const equal= ( actual, expected, optDetails= undefined, - ErrorConstructor= undefined)=> + errConstructor= undefined, + options= undefined)=> { is(actual, expected)|| fail( optDetails|| details `Expected ${actual} is same as ${expected}`, - ErrorConstructor|| RangeError); + errConstructor|| RangeError, + options); }; freeze(equal); - /** @type {AssertTypeof} */ + /** @type {AssertionFunctions['typeof']} */ const assertTypeof= (specimen, typename, optDetails)=> { // This will safely fall through if typename is not a string, // which is what we want. @@ -1874,7 +1721,7 @@ const makeAssert= (optRaise= undefined, unredacted= false)=> { }; freeze(assertTypeof); - /** @type {AssertString} */ + /** @type {AssertionFunctions['string']} */ const assertString= (specimen, optDetails= undefined)=> assertTypeof(specimen, 'string', optDetails); @@ -1902,8 +1749,8 @@ freeze(makeAssert); const assert= makeAssert();$h‍_once.assert(assert); })() , -// === functors[9] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Set,String,TypeError,WeakMap,WeakSet,globalThis,apply,arrayForEach,defineProperty,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,getPrototypeOf,isInteger,isObject,objectHasOwnProperty,ownKeys,preventExtensions,setAdd,setForEach,setHas,toStringTagSymbol,typedArrayPrototype,weakmapGet,weakmapSet,weaksetAdd,weaksetHas,assert;$h‍_imports([["./commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["isInteger", [$h‍_a => (isInteger = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["preventExtensions", [$h‍_a => (preventExtensions = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["setForEach", [$h‍_a => (setForEach = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]],["typedArrayPrototype", [$h‍_a => (typedArrayPrototype = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); +// === functors[10] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Set,String,TypeError,WeakSet,globalThis,apply,arrayForEach,defineProperty,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,getPrototypeOf,isInteger,isObject,objectHasOwnProperty,ownKeys,preventExtensions,setAdd,setForEach,setHas,toStringTagSymbol,typedArrayPrototype,weaksetAdd,weaksetHas,FERAL_STACK_GETTER,FERAL_STACK_SETTER,isError,assert;$h‍_imports([["./commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["isInteger", [$h‍_a => (isInteger = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["preventExtensions", [$h‍_a => (preventExtensions = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["setForEach", [$h‍_a => (setForEach = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]],["typedArrayPrototype", [$h‍_a => (typedArrayPrototype = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]],["FERAL_STACK_GETTER", [$h‍_a => (FERAL_STACK_GETTER = $h‍_a)]],["FERAL_STACK_SETTER", [$h‍_a => (FERAL_STACK_SETTER = $h‍_a)]],["isError", [$h‍_a => (isError = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); @@ -1958,7 +1805,7 @@ const assert= makeAssert();$h‍_once.assert(assert); /** - * @typedef {import('../types.js').Harden} Harden + * @import {Harden} from '../types.js' */ // Obtain the string tag accessor of of TypedArray so we can indirectly use the @@ -2049,15 +1896,13 @@ const makeHardener= ()=> { */ harden(root) { const toFreeze= new Set(); - const paths= new WeakMap(); // If val is something we should be freezing but aren't yet, // add it to toFreeze. /** * @param {any} val - * @param {string} [path] */ - function enqueue(val, path= undefined) { + function enqueue(val) { if( !isObject(val)) { // ignore primitives return; @@ -2073,13 +1918,12 @@ const makeHardener= ()=> { } // console.warn(`adding ${val} to toFreeze`, val); setAdd(toFreeze, val); - weakmapSet(paths, val, path); } /** * @param {any} obj */ - function freezeAndTraverse(obj) { + const baseFreezeAndTraverse= (obj)=>{ // Now freeze the object to ensure reactive // objects such as proxies won't add properties // during traversal, before they get frozen. @@ -2098,13 +1942,11 @@ const makeHardener= ()=> { // get stable/immutable outbound links before a Proxy has a chance to do // something sneaky. - const path= weakmapGet(paths, obj)|| 'unknown'; const descs= getOwnPropertyDescriptors(obj); const proto= getPrototypeOf(obj); - enqueue(proto, `${path}.__proto__`); + enqueue(proto); arrayForEach(ownKeys(descs), (/** @type {string | symbol} */ name)=> { - const pathname= `${path}.${String(name)}`; // The 'name' may be a symbol, and TypeScript doesn't like us to // index arbitrary symbols on objects, so we pretend they're just // strings. @@ -2117,27 +1959,60 @@ const makeHardener= ()=> { // whether 'value' is present or not, which tells us for sure that // this is a data property. if( objectHasOwnProperty(desc, 'value')) { - enqueue(desc.value, `${pathname}`); + enqueue(desc.value); }else { - enqueue(desc.get, `${pathname}(get)`); - enqueue(desc.set, `${pathname}(set)`); + enqueue(desc.get); + enqueue(desc.set); } }); - } + }; + + const freezeAndTraverse= + FERAL_STACK_GETTER=== undefined&& FERAL_STACK_SETTER=== undefined? + // On platforms without v8's error own stack accessor problem, + // don't pay for any extra overhead. + baseFreezeAndTraverse: + (obj)=>{ + if( isError(obj)) { + // Only pay the overhead if it first passes this cheap isError + // check. Otherwise, it will be unrepaired, but won't be judged + // to be a passable error anyway, so will not be unsafe. + const stackDesc= getOwnPropertyDescriptor(obj, 'stack'); + if( + stackDesc&& + stackDesc.get=== FERAL_STACK_GETTER&& + stackDesc.configurable) + { + // Can only repair if it is configurable. Otherwise, leave + // unrepaired, in which case it will not be judged passable, + // avoiding a safety problem. + defineProperty(obj, 'stack', { + // NOTE: Calls getter during harden, which seems dangerous. + // But we're only calling the problematic getter whose + // hazards we think we understand. + // @ts-expect-error TS should know FERAL_STACK_GETTER + // cannot be `undefined` here. + // See https://github.com/endojs/endo/pull/2232#discussion_r1575179471 + value: apply(FERAL_STACK_GETTER, obj, [])}); + + } + } + return baseFreezeAndTraverse(obj); + }; - function dequeue() { + const dequeue= ()=> { // New values added before forEach() has finished will be visited. setForEach(toFreeze, freezeAndTraverse); - } + }; /** @param {any} value */ - function markHardened(value) { + const markHardened= (value)=>{ weaksetAdd(hardened, value); - } + }; - function commit() { + const commit= ()=> { setForEach(toFreeze, markHardened); - } + }; enqueue(root); dequeue(); @@ -2152,8 +2027,14 @@ const makeHardener= ()=> { };$h‍_once.makeHardener(makeHardener); })() , -// === functors[10] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /* eslint-disable no-restricted-globals */ +// === functors[11] === +({ 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)]]]]]); + + + + +/** @import {GenericErrorConstructor} from '../types.js' */ + /** * @file Exports {@code whitelist}, a recursively defined * JSON record enumerating all intrinsics and their properties @@ -2163,8 +2044,6 @@ const makeHardener= ()=> { * @author Mark S. Miller */ -/* eslint max-lines: 0 */ - /** * constantProperties * non-configurable, non-writable data properties of all global objects. @@ -2208,6 +2087,8 @@ const universalPropertyNames= { Boolean: 'Boolean', DataView: 'DataView', EvalError: 'EvalError', + // https://github.com/tc39/proposal-float16array + Float16Array: 'Float16Array', Float32Array: 'Float32Array', Float64Array: 'Float64Array', Int8Array: 'Int8Array', @@ -2235,6 +2116,8 @@ const universalPropertyNames= { Iterator: 'Iterator', // https://github.com/tc39/proposal-async-iterator-helpers AsyncIterator: 'AsyncIterator', + // https://github.com/endojs/endo/issues/550 + AggregateError: 'AggregateError', // *** Other Properties of the Global Object @@ -2338,14 +2221,25 @@ const uniqueGlobalPropertyNames= { // All the "subclasses" of Error. These are collectively represented in the // ECMAScript spec by the meta variable NativeError. -// TODO Add AggregateError https://github.com/Agoric/SES-shim/issues/550 -$h‍_once.uniqueGlobalPropertyNames(uniqueGlobalPropertyNames);const NativeErrors=[ +/** @type {GenericErrorConstructor[]} */$h‍_once.uniqueGlobalPropertyNames(uniqueGlobalPropertyNames); +const NativeErrors= [ EvalError, RangeError, ReferenceError, SyntaxError, TypeError, - URIError]; + URIError + // https://github.com/endojs/endo/issues/550 + // Commented out to accommodate platforms prior to AggregateError. + // Instead, conditional push below. + // AggregateError, +];$h‍_once.NativeErrors(NativeErrors); + +if( typeof AggregateError!== 'undefined') { + // Conditional, to accommodate platforms prior to AggregateError + arrayPush(NativeErrors, AggregateError); + } + /** @@ -2395,7 +2289,7 @@ $h‍_once.uniqueGlobalPropertyNames(uniqueGlobalPropertyNames);const NativeErro */ // Function Instances -$h‍_once.NativeErrors(NativeErrors);const FunctionInstance={ +const FunctionInstance= { '[[Proto]]': '%FunctionPrototype%', length: 'number', name: 'string' @@ -2536,7 +2430,9 @@ const CommonMath= { // See https://github.com/Moddable-OpenSource/moddable/issues/523 irem: false, // See https://github.com/Moddable-OpenSource/moddable/issues/523 - mod: false}; + mod: false, + // See https://github.com/Moddable-OpenSource/moddable/issues/523#issuecomment-1942904505 + irandom: false}; const permitted= { @@ -2597,7 +2493,9 @@ const permitted= { setPrototypeOf: fn, values: fn, // https://github.com/tc39/proposal-array-grouping - groupBy: fn}, + groupBy: fn, + // Seen on QuickJS + __getClass: false}, '%ObjectPrototype%': { @@ -2643,7 +2541,11 @@ const permitted= { // proposed but not yet std. To be removed if there caller: false, // proposed but not yet std. To be removed if there - arguments: false}, + arguments: false, + // Seen on QuickJS. TODO grab getter for use by console + fileName: false, + // Seen on QuickJS. TODO grab getter for use by console + lineNumber: false}, Boolean: { @@ -2682,7 +2584,9 @@ const permitted= { // Seen at core-js https://github.com/zloirock/core-js#ecmascript-symbol useSimple: false, // Seen at core-js https://github.com/zloirock/core-js#ecmascript-symbol - useSetter: false}, + useSetter: false, + // Seen on QuickJS + operatorSet: false}, '%SymbolPrototype%': { @@ -2742,6 +2646,8 @@ const permitted= { SyntaxError: NativeError('%SyntaxErrorPrototype%'), TypeError: NativeError('%TypeErrorPrototype%'), URIError: NativeError('%URIErrorPrototype%'), + // https://github.com/endojs/endo/issues/550 + AggregateError: NativeError('%AggregateErrorPrototype%'), '%EvalErrorPrototype%': NativeErrorPrototype('EvalError'), '%RangeErrorPrototype%': NativeErrorPrototype('RangeError'), @@ -2749,6 +2655,8 @@ const permitted= { '%SyntaxErrorPrototype%': NativeErrorPrototype('SyntaxError'), '%TypeErrorPrototype%': NativeErrorPrototype('TypeError'), '%URIErrorPrototype%': NativeErrorPrototype('URIError'), + // https://github.com/endojs/endo/issues/550 + '%AggregateErrorPrototype%': NativeErrorPrototype('AggregateError'), // *** Numbers and Dates @@ -2792,7 +2700,31 @@ const permitted= { // See https://github.com/Moddable-OpenSource/moddable/issues/523 bitLength: false, // See https://github.com/Moddable-OpenSource/moddable/issues/523 - fromArrayBuffer: false}, + fromArrayBuffer: false, + // Seen on QuickJS + tdiv: false, + // Seen on QuickJS + fdiv: false, + // Seen on QuickJS + cdiv: false, + // Seen on QuickJS + ediv: false, + // Seen on QuickJS + tdivrem: false, + // Seen on QuickJS + fdivrem: false, + // Seen on QuickJS + cdivrem: false, + // Seen on QuickJS + edivrem: false, + // Seen on QuickJS + sqrt: false, + // Seen on QuickJS + sqrtrem: false, + // Seen on QuickJS + floorLog2: false, + // Seen on QuickJS + ctz: false}, '%BigIntPrototype%': { @@ -2960,7 +2892,9 @@ const permitted= { // https://github.com/tc39/proposal-is-usv-string isWellFormed: fn, toWellFormed: fn, - unicodeSets: fn}, + unicodeSets: fn, + // Seen on QuickJS + __quote: false}, '%StringIteratorPrototype%': { @@ -3200,6 +3134,8 @@ const permitted= { BigInt64Array: TypedArray('%BigInt64ArrayPrototype%'), BigUint64Array: TypedArray('%BigUint64ArrayPrototype%'), + // https://github.com/tc39/proposal-float16array + Float16Array: TypedArray('%Float16ArrayPrototype%'), Float32Array: TypedArray('%Float32ArrayPrototype%'), Float64Array: TypedArray('%Float64ArrayPrototype%'), Int16Array: TypedArray('%Int16ArrayPrototype%'), @@ -3212,6 +3148,8 @@ const permitted= { '%BigInt64ArrayPrototype%': TypedArrayPrototype('BigInt64Array'), '%BigUint64ArrayPrototype%': TypedArrayPrototype('BigUint64Array'), + // https://github.com/tc39/proposal-float16array + '%Float16ArrayPrototype%': TypedArrayPrototype('Float16Array'), '%Float32ArrayPrototype%': TypedArrayPrototype('Float32Array'), '%Float64ArrayPrototype%': TypedArrayPrototype('Float64Array'), '%Int16ArrayPrototype%': TypedArrayPrototype('Int16Array'), @@ -3260,7 +3198,9 @@ const permitted= { // Properties of the Set Constructor '[[Proto]]': '%FunctionPrototype%', prototype: '%SetPrototype%', - '@@species': getter}, + '@@species': getter, + // Seen on QuickJS + groupBy: false}, '%SetPrototype%': { @@ -3377,6 +3317,8 @@ const permitted= { constructor: 'DataView', getBigInt64: fn, getBigUint64: fn, + // https://github.com/tc39/proposal-float16array + getFloat16: fn, getFloat32: fn, getFloat64: fn, getInt8: fn, @@ -3387,6 +3329,8 @@ const permitted= { getUint32: fn, setBigInt64: fn, setBigUint64: fn, + // https://github.com/tc39/proposal-float16array + setFloat16: fn, setFloat32: fn, setFloat64: fn, setInt8: fn, @@ -3438,7 +3382,9 @@ const permitted= { find: fn, '@@toStringTag': 'string', // https://github.com/tc39/proposal-async-iterator-helpers - toAsync: fn}, + toAsync: fn, + // See https://github.com/Moddable-OpenSource/moddable/issues/523#issuecomment-1942904505 + '@@dispose': false}, // https://github.com/tc39/proposal-iterator-helpers @@ -3480,7 +3426,9 @@ const permitted= { some: fn, every: fn, find: fn, - '@@toStringTag': 'string'}, + '@@toStringTag': 'string', + // See https://github.com/Moddable-OpenSource/moddable/issues/523#issuecomment-1942904505 + '@@asyncDispose': false}, // https://github.com/tc39/proposal-async-iterator-helpers @@ -3576,9 +3524,8 @@ const permitted= { '[[Proto]]': '%FunctionPrototype%', all: fn, allSettled: fn, - // To transition from `false` to `fn` once we also have `AggregateError` - // TODO https://github.com/Agoric/SES-shim/issues/550 - any: false, // ES2021 + // https://github.com/Agoric/SES-shim/issues/550 + any: fn, prototype: '%PromisePrototype%', race: fn, reject: fn, @@ -3671,12 +3618,11 @@ const permitted= { evaluate: fn, globalThis: getter, name: getter, - // Should this be proposed? - toString: fn, import: asyncFn, load: asyncFn, importNow: fn, - module: fn}, + module: fn, + '@@toStringTag': 'string'}, lockdown: fn, @@ -3685,8 +3631,8 @@ const permitted= { '%InitialGetStackString%': fn};$h‍_once.permitted(permitted); })() , -// === functors[11] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,WeakSet,arrayFilter,create,defineProperty,entries,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,globalThis,is,isObject,objectHasOwnProperty,values,weaksetHas,constantProperties,sharedGlobalPropertyNames,universalPropertyNames,permitted;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./permits.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]],["permitted", [$h‍_a => (permitted = $h‍_a)]]]]]); +// === functors[12] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let TypeError,WeakSet,arrayFilter,create,defineProperty,entries,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,globalThis,is,isObject,objectHasOwnProperty,values,weaksetHas,constantProperties,sharedGlobalPropertyNames,universalPropertyNames,permitted;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./permits.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]],["permitted", [$h‍_a => (permitted = $h‍_a)]]]]]); @@ -3862,8 +3808,8 @@ const getGlobalIntrinsics= (globalObject)=>{ };$h‍_once.getGlobalIntrinsics(getGlobalIntrinsics); })() , -// === functors[12] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let permitted,FunctionInstance,isAccessorPermit,Map,String,Symbol,TypeError,arrayFilter,arrayIncludes,arrayMap,entries,getOwnPropertyDescriptor,getPrototypeOf,isObject,mapGet,objectHasOwnProperty,ownKeys,symbolKeyFor;$h‍_imports([["./permits.js", [["permitted", [$h‍_a => (permitted = $h‍_a)]],["FunctionInstance", [$h‍_a => (FunctionInstance = $h‍_a)]],["isAccessorPermit", [$h‍_a => (isAccessorPermit = $h‍_a)]]]],["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["Symbol", [$h‍_a => (Symbol = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["symbolKeyFor", [$h‍_a => (symbolKeyFor = $h‍_a)]]]]]); +// === functors[13] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let permitted,FunctionInstance,isAccessorPermit,Map,String,Symbol,TypeError,arrayFilter,arrayIncludes,arrayMap,entries,getOwnPropertyDescriptor,getPrototypeOf,isObject,mapGet,objectHasOwnProperty,ownKeys,symbolKeyFor;$h‍_imports([["./permits.js", [["permitted", [$h‍_a => (permitted = $h‍_a)]],["FunctionInstance", [$h‍_a => (FunctionInstance = $h‍_a)]],["isAccessorPermit", [$h‍_a => (isAccessorPermit = $h‍_a)]]]],["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["Symbol", [$h‍_a => (Symbol = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["symbolKeyFor", [$h‍_a => (symbolKeyFor = $h‍_a)]]]]]); @@ -4195,8 +4141,8 @@ function whitelistIntrinsics( }$h‍_once.default( whitelistIntrinsics); })() , -// === functors[13] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_FUNCTION,SyntaxError,TypeError,defineProperties,getPrototypeOf,setPrototypeOf,freeze;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["setPrototypeOf", [$h‍_a => (setPrototypeOf = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]]]); +// === functors[14] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FERAL_FUNCTION,SyntaxError,TypeError,defineProperties,getPrototypeOf,setPrototypeOf,freeze;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["setPrototypeOf", [$h‍_a => (setPrototypeOf = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]]]); @@ -4334,8 +4280,8 @@ function tameFunctionConstructors() { }$h‍_once.default( tameFunctionConstructors); })() , -// === functors[14] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Date,TypeError,apply,construct,defineProperties;$h‍_imports([["./commons.js", [["Date", [$h‍_a => (Date = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]]]]]); +// === functors[15] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Date,TypeError,apply,construct,defineProperties;$h‍_imports([["./commons.js", [["Date", [$h‍_a => (Date = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]]]]]); @@ -4467,8 +4413,8 @@ function tameDateConstructor(dateTaming= 'safe') { }$h‍_once.default( tameDateConstructor); })() , -// === functors[15] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Math,TypeError,create,getOwnPropertyDescriptors,objectPrototype;$h‍_imports([["./commons.js", [["Math", [$h‍_a => (Math = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["objectPrototype", [$h‍_a => (objectPrototype = $h‍_a)]]]]]); +// === functors[16] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Math,TypeError,create,getOwnPropertyDescriptors,objectPrototype;$h‍_imports([["./commons.js", [["Math", [$h‍_a => (Math = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["objectPrototype", [$h‍_a => (objectPrototype = $h‍_a)]]]]]); @@ -4514,8 +4460,8 @@ function tameMathObject(mathTaming= 'safe') { }$h‍_once.default( tameMathObject); })() , -// === functors[16] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_REG_EXP,TypeError,construct,defineProperties,getOwnPropertyDescriptor,speciesSymbol;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["speciesSymbol", [$h‍_a => (speciesSymbol = $h‍_a)]]]]]); +// === functors[17] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FERAL_REG_EXP,TypeError,construct,defineProperties,getOwnPropertyDescriptor,speciesSymbol;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["speciesSymbol", [$h‍_a => (speciesSymbol = $h‍_a)]]]]]); @@ -4542,21 +4488,28 @@ function tameRegExpConstructor(regExpTaming= 'safe') { return construct(FERAL_REG_EXP, rest, new.target); }; - const speciesDesc= getOwnPropertyDescriptor(FERAL_REG_EXP, speciesSymbol); - if( !speciesDesc) { - throw TypeError('no RegExp[Symbol.species] descriptor'); - } - defineProperties(ResultRegExp, { length: { value: 2}, prototype: { value: RegExpPrototype, writable: false, enumerable: false, - configurable: false}, + configurable: false}}); + - [speciesSymbol]: speciesDesc}); + // Hermes does not have `Symbol.species`. We should support such platforms. + if( speciesSymbol) { + const speciesDesc= getOwnPropertyDescriptor( + FERAL_REG_EXP, + speciesSymbol); + if( !speciesDesc) { + throw TypeError('no RegExp[Symbol.species] descriptor'); + } + defineProperties(ResultRegExp, { + [speciesSymbol]: speciesDesc}); + + } return ResultRegExp; }; @@ -4578,8 +4531,8 @@ function tameRegExpConstructor(regExpTaming= 'safe') { }$h‍_once.default( tameRegExpConstructor); })() , -// === functors[17] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let toStringTagSymbol;$h‍_imports([["./commons.js", [["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]); +// === functors[18] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let toStringTagSymbol,iteratorSymbol;$h‍_imports([["./commons.js", [["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]],["iteratorSymbol", [$h‍_a => (iteratorSymbol = $h‍_a)]]]]]); /** * @file Exports {@code enablements}, a recursively defined @@ -4677,7 +4630,9 @@ const moderateEnablements= { '%ArrayPrototype%': { toString: true, - push: true // set by "Google Analytics" + push: true, // set by "Google Analytics" + concat: true, // set by mobx generated code (old TS compiler?) + [iteratorSymbol]: true // set by mobx generated code (old TS compiler?) }, // Function.prototype has no 'prototype' property to enable. @@ -4728,6 +4683,12 @@ const moderateEnablements= { name: true // set by "node 14" }, + // https://github.com/endojs/endo/issues/550 + '%AggregateErrorPrototype%': { + message: true, // to match TypeErrorPrototype.message + name: true // set by "node 14"? +}, + '%PromisePrototype%': { constructor: true // set by "core-js" }, @@ -4814,8 +4775,8 @@ const severeEnablements= { '%SetPrototype%': '*'};$h‍_once.severeEnablements(severeEnablements); })() , -// === functors[18] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Set,String,TypeError,arrayForEach,defineProperty,getOwnPropertyDescriptor,getOwnPropertyDescriptors,isObject,objectHasOwnProperty,ownKeys,setHas,minEnablements,moderateEnablements,severeEnablements;$h‍_imports([["./commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]]]],["./enablements.js", [["minEnablements", [$h‍_a => (minEnablements = $h‍_a)]],["moderateEnablements", [$h‍_a => (moderateEnablements = $h‍_a)]],["severeEnablements", [$h‍_a => (severeEnablements = $h‍_a)]]]]]); +// === functors[19] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Set,String,TypeError,arrayForEach,defineProperty,getOwnPropertyDescriptor,getOwnPropertyDescriptors,isObject,objectHasOwnProperty,ownKeys,setHas,minEnablements,moderateEnablements,severeEnablements;$h‍_imports([["./commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]]]],["./enablements.js", [["minEnablements", [$h‍_a => (minEnablements = $h‍_a)]],["moderateEnablements", [$h‍_a => (moderateEnablements = $h‍_a)]],["severeEnablements", [$h‍_a => (severeEnablements = $h‍_a)]]]]]); @@ -5025,8 +4986,8 @@ function enablePropertyOverrides( }$h‍_once.default( enablePropertyOverrides); })() , -// === functors[19] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Number,String,TypeError,defineProperty,getOwnPropertyNames,isObject,regexpExec,assert;$h‍_imports([["./commons.js", [["Number", [$h‍_a => (Number = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); +// === functors[20] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Number,String,TypeError,defineProperty,getOwnPropertyNames,isObject,regexpExec,assert;$h‍_imports([["./commons.js", [["Number", [$h‍_a => (Number = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); @@ -5109,8 +5070,8 @@ function tameLocaleMethods(intrinsics, localeTaming= 'safe') { }$h‍_once.default( tameLocaleMethods); })() , -// === functors[20] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /** +// === functors[21] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; $h‍_imports([]); /** * makeEvalFunction() * A safe version of the native eval function which relies on * the safety of safeEvaluate for confinement. @@ -5118,7 +5079,7 @@ function tameLocaleMethods(intrinsics, localeTaming= 'safe') { * @param {Function} safeEvaluate */ const makeEvalFunction= (safeEvaluate)=>{ - // We use the the concise method syntax to create an eval without a + // We use the concise method syntax to create an eval without a // [[Construct]] behavior (such that the invocation "new eval()" throws // TypeError: eval is not a constructor"), but which still accepts a // 'this' binding. @@ -5139,8 +5100,8 @@ const makeEvalFunction= (safeEvaluate)=>{ };$h‍_once.makeEvalFunction(makeEvalFunction); })() , -// === functors[21] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_FUNCTION,arrayJoin,arrayPop,defineProperties,getPrototypeOf,assert;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayPop", [$h‍_a => (arrayPop = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); +// === functors[22] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FERAL_FUNCTION,arrayJoin,arrayPop,defineProperties,getPrototypeOf,assert;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayPop", [$h‍_a => (arrayPop = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); @@ -5220,8 +5181,8 @@ const makeFunctionConstructor= (safeEvaluate)=>{ };$h‍_once.makeFunctionConstructor(makeFunctionConstructor); })() , -// === functors[22] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,assign,create,defineProperty,entries,freeze,objectHasOwnProperty,unscopablesSymbol,makeEvalFunction,makeFunctionConstructor,constantProperties,universalPropertyNames;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["unscopablesSymbol", [$h‍_a => (unscopablesSymbol = $h‍_a)]]]],["./make-eval-function.js", [["makeEvalFunction", [$h‍_a => (makeEvalFunction = $h‍_a)]]]],["./make-function-constructor.js", [["makeFunctionConstructor", [$h‍_a => (makeFunctionConstructor = $h‍_a)]]]],["./permits.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]]]]]); +// === functors[23] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let TypeError,assign,create,defineProperty,entries,freeze,objectHasOwnProperty,unscopablesSymbol,makeEvalFunction,makeFunctionConstructor,constantProperties,universalPropertyNames;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["unscopablesSymbol", [$h‍_a => (unscopablesSymbol = $h‍_a)]]]],["./make-eval-function.js", [["makeEvalFunction", [$h‍_a => (makeEvalFunction = $h‍_a)]]]],["./make-function-constructor.js", [["makeFunctionConstructor", [$h‍_a => (makeFunctionConstructor = $h‍_a)]]]],["./permits.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]]]]]); @@ -5392,8 +5353,8 @@ const setGlobalObjectEvaluators= ( };$h‍_once.setGlobalObjectEvaluators(setGlobalObjectEvaluators); })() , -// === functors[23] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Proxy,String,TypeError,ReferenceError,create,freeze,getOwnPropertyDescriptors,globalThis,immutableObject,assert;$h‍_imports([["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); +// === functors[24] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Proxy,String,TypeError,ReferenceError,create,freeze,getOwnPropertyDescriptors,globalThis,immutableObject,assert;$h‍_imports([["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); @@ -5487,8 +5448,8 @@ const strictScopeTerminator= new Proxy( strictScopeTerminatorHandler);$h‍_once.strictScopeTerminator(strictScopeTerminator); })() , -// === functors[24] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Proxy,create,freeze,getOwnPropertyDescriptors,immutableObject,reflectSet,strictScopeTerminatorHandler,alwaysThrowHandler;$h‍_imports([["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]]]],["./strict-scope-terminator.js", [["strictScopeTerminatorHandler", [$h‍_a => (strictScopeTerminatorHandler = $h‍_a)]],["alwaysThrowHandler", [$h‍_a => (alwaysThrowHandler = $h‍_a)]]]]]); +// === functors[25] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Proxy,create,freeze,getOwnPropertyDescriptors,immutableObject,reflectSet,strictScopeTerminatorHandler,alwaysThrowHandler;$h‍_imports([["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]]]],["./strict-scope-terminator.js", [["strictScopeTerminatorHandler", [$h‍_a => (strictScopeTerminatorHandler = $h‍_a)]],["alwaysThrowHandler", [$h‍_a => (alwaysThrowHandler = $h‍_a)]]]]]); @@ -5544,8 +5505,8 @@ const createSloppyGlobalsScopeTerminator= (globalObject)=>{ freeze(createSloppyGlobalsScopeTerminator); })() , -// === functors[25] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_EVAL,create,defineProperties,freeze,assert;$h‍_imports([["./commons.js", [["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); +// === functors[26] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FERAL_EVAL,create,defineProperties,freeze,assert;$h‍_imports([["./commons.js", [["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); @@ -5636,8 +5597,8 @@ const makeEvalScopeKit= ()=> { };$h‍_once.makeEvalScopeKit(makeEvalScopeKit); })() , -// === functors[26] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_REG_EXP,regexpExec,stringSlice;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]]]]]); +// === functors[27] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FERAL_REG_EXP,regexpExec,stringSlice;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]]]]]); // Captures a key and value of the form #key=value or @key=value const sourceMetaEntryRegExp= @@ -5689,8 +5650,8 @@ const getSourceURL= (src)=>{ };$h‍_once.getSourceURL(getSourceURL); })() , -// === functors[27] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_REG_EXP,SyntaxError,stringReplace,stringSearch,stringSlice,stringSplit,freeze,getSourceURL;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["stringReplace", [$h‍_a => (stringReplace = $h‍_a)]],["stringSearch", [$h‍_a => (stringSearch = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./get-source-url.js", [["getSourceURL", [$h‍_a => (getSourceURL = $h‍_a)]]]]]); +// === functors[28] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FERAL_REG_EXP,SyntaxError,stringReplace,stringSearch,stringSlice,stringSplit,freeze,getSourceURL;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["stringReplace", [$h‍_a => (stringReplace = $h‍_a)]],["stringSearch", [$h‍_a => (stringSearch = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./get-source-url.js", [["getSourceURL", [$h‍_a => (getSourceURL = $h‍_a)]]]]]); @@ -5957,8 +5918,8 @@ $h‍_once.applyTransforms(applyTransforms);const transforms=freeze({ applyTransforms: freeze(applyTransforms)});$h‍_once.transforms(transforms); })() , -// === functors[28] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let arrayFilter,arrayIncludes,getOwnPropertyDescriptor,getOwnPropertyNames,objectHasOwnProperty,regexpTest;$h‍_imports([["./commons.js", [["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]]]]]); +// === functors[29] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let arrayFilter,arrayIncludes,getOwnPropertyDescriptor,getOwnPropertyNames,objectHasOwnProperty,regexpTest;$h‍_imports([["./commons.js", [["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]]]]]); @@ -6140,8 +6101,8 @@ const getScopeConstants= (globalObject, moduleLexicals= {})=> { };$h‍_once.getScopeConstants(getScopeConstants); })() , -// === functors[29] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_FUNCTION,arrayJoin,apply,getScopeConstants;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]]]],["./scope-constants.js", [["getScopeConstants", [$h‍_a => (getScopeConstants = $h‍_a)]]]]]); +// === functors[30] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FERAL_FUNCTION,arrayJoin,apply,getScopeConstants;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]]]],["./scope-constants.js", [["getScopeConstants", [$h‍_a => (getScopeConstants = $h‍_a)]]]]]); @@ -6253,8 +6214,8 @@ const makeEvaluate= (context)=>{ };$h‍_once.makeEvaluate(makeEvaluate); })() , -// === functors[30] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let apply,freeze,strictScopeTerminator,createSloppyGlobalsScopeTerminator,makeEvalScopeKit,applyTransforms,mandatoryTransforms,makeEvaluate,assert;$h‍_imports([["./commons.js", [["apply", [$h‍_a => (apply = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./strict-scope-terminator.js", [["strictScopeTerminator", [$h‍_a => (strictScopeTerminator = $h‍_a)]]]],["./sloppy-globals-scope-terminator.js", [["createSloppyGlobalsScopeTerminator", [$h‍_a => (createSloppyGlobalsScopeTerminator = $h‍_a)]]]],["./eval-scope.js", [["makeEvalScopeKit", [$h‍_a => (makeEvalScopeKit = $h‍_a)]]]],["./transforms.js", [["applyTransforms", [$h‍_a => (applyTransforms = $h‍_a)]],["mandatoryTransforms", [$h‍_a => (mandatoryTransforms = $h‍_a)]]]],["./make-evaluate.js", [["makeEvaluate", [$h‍_a => (makeEvaluate = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); +// === functors[31] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let apply,freeze,strictScopeTerminator,createSloppyGlobalsScopeTerminator,makeEvalScopeKit,applyTransforms,mandatoryTransforms,makeEvaluate,assert;$h‍_imports([["./commons.js", [["apply", [$h‍_a => (apply = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./strict-scope-terminator.js", [["strictScopeTerminator", [$h‍_a => (strictScopeTerminator = $h‍_a)]]]],["./sloppy-globals-scope-terminator.js", [["createSloppyGlobalsScopeTerminator", [$h‍_a => (createSloppyGlobalsScopeTerminator = $h‍_a)]]]],["./eval-scope.js", [["makeEvalScopeKit", [$h‍_a => (makeEvalScopeKit = $h‍_a)]]]],["./transforms.js", [["applyTransforms", [$h‍_a => (applyTransforms = $h‍_a)]],["mandatoryTransforms", [$h‍_a => (mandatoryTransforms = $h‍_a)]]]],["./make-evaluate.js", [["makeEvaluate", [$h‍_a => (makeEvaluate = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); @@ -6366,8 +6327,8 @@ const makeSafeEvaluator= ({ };$h‍_once.makeSafeEvaluator(makeSafeEvaluator); })() , -// === functors[31] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let WeakSet,defineProperty,freeze,functionPrototype,functionToString,stringEndsWith,weaksetAdd,weaksetHas;$h‍_imports([["./commons.js", [["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["functionPrototype", [$h‍_a => (functionPrototype = $h‍_a)]],["functionToString", [$h‍_a => (functionToString = $h‍_a)]],["stringEndsWith", [$h‍_a => (stringEndsWith = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]); +// === functors[32] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let WeakSet,defineProperty,freeze,functionPrototype,functionToString,stringEndsWith,weaksetAdd,weaksetHas;$h‍_imports([["./commons.js", [["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["functionPrototype", [$h‍_a => (functionPrototype = $h‍_a)]],["functionToString", [$h‍_a => (functionToString = $h‍_a)]],["stringEndsWith", [$h‍_a => (stringEndsWith = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]); @@ -6419,8 +6380,8 @@ const tameFunctionToString= ()=> { };$h‍_once.tameFunctionToString(tameFunctionToString); })() , -// === functors[32] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,globalThis,getOwnPropertyDescriptor,defineProperty;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]]]]]);Object.defineProperty(tameDomains, 'name', {value: "tameDomains"});$h‍_once.tameDomains(tameDomains); +// === functors[33] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let TypeError,globalThis,getOwnPropertyDescriptor,defineProperty;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]]]]]);Object.defineProperty(tameDomains, 'name', {value: "tameDomains"});$h‍_once.tameDomains(tameDomains); @@ -6467,8 +6428,12 @@ function tameDomains(domainTaming= 'safe') { } })() , -// === functors[33] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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", []]]); +// === functors[34] === +({ 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", []]]); + + + + @@ -6516,8 +6481,17 @@ function tameDomains(domainTaming= 'safe') { /** @typedef {keyof VirtualConsole | 'profile' | 'profileEnd'} ConsoleProps */ -/** @type {readonly [ConsoleProps, LogSeverity | undefined][]} */ -const consoleLevelMethods= freeze([ +/** + * Those console methods whose actual parameters are `(fmt?, ...args)` + * even if their TypeScript types claim otherwise. + * + * Each is paired with what we consider to be their log severity level. + * This is the same as the log severity of these on other + * platform console implementations when they all agree. + * + * @type {readonly [ConsoleProps, LogSeverity | undefined][]} + */ +const consoleLevelMethods= freeze([ ['debug', 'debug'], // (fmt?, ...args) verbose level on Chrome ['log', 'log'], // (fmt?, ...args) info level on Chrome ['info', 'info'], // (fmt?, ...args) @@ -6525,13 +6499,22 @@ const consoleLevelMethods= freeze([ ['error', 'error'], // (fmt?, ...args) ['trace', 'log'], // (fmt?, ...args) - ['dirxml', 'log'], // (fmt?, ...args) - ['group', 'log'], // (fmt?, ...args) - ['groupCollapsed', 'log'] // (fmt?, ...args) + ['dirxml', 'log'], // (fmt?, ...args) but TS typed (...data) + ['group', 'log'], // (fmt?, ...args) but TS typed (...label) + ['groupCollapsed', 'log'] // (fmt?, ...args) but TS typed (...label) ]); -/** @type {readonly [ConsoleProps, LogSeverity | undefined][]} */ -const consoleOtherMethods= freeze([ +/** + * Those console methods other than those already enumerated by + * `consoleLevelMethods`. + * + * Each is paired with what we consider to be their log severity level. + * This is the same as the log severity of these on other + * platform console implementations when they all agree. + * + * @type {readonly [ConsoleProps, LogSeverity | undefined][]} + */$h‍_once.consoleLevelMethods(consoleLevelMethods); +const consoleOtherMethods= freeze([ ['assert', 'error'], // (value, fmt?, ...args) ['timeLog', 'log'], // (label?, ...args) no fmt string @@ -6554,8 +6537,8 @@ const consoleOtherMethods= freeze([ ['timeStamp', undefined] // (label?) ]); -/** @type {readonly [ConsoleProps, LogSeverity | undefined][]} */ -const consoleWhitelist= freeze([ +/** @type {readonly [ConsoleProps, LogSeverity | undefined][]} */$h‍_once.consoleOtherMethods(consoleOtherMethods); +const consoleWhitelist= freeze([ ...consoleLevelMethods, ...consoleOtherMethods]); @@ -6587,10 +6570,10 @@ const consoleWhitelist= freeze([ * ]); */ -// ///////////////////////////////////////////////////////////////////////////// +// //////////////////////////// Logging Console //////////////////////////////// -/** @type {MakeLoggingConsoleKit} */$h‍_once.consoleWhitelist(consoleWhitelist); -const makeLoggingConsoleKit= ( +/** @type {MakeLoggingConsoleKit} */ +const makeLoggingConsoleKit= ( loggedErrorHandler, { shouldResetForDebugging= false}= {})=> { @@ -6632,18 +6615,34 @@ const makeLoggingConsoleKit= ( };$h‍_once.makeLoggingConsoleKit(makeLoggingConsoleKit); freeze(makeLoggingConsoleKit); +/** + * Makes the same calls on a `baseConsole` that were made on a + * `loggingConsole` to produce this `log`. In this way, a logging console + * can be used as a buffer to delay the application of these calls to a + * `baseConsole`. + * + * @param {LogRecord[]} log + * @param {VirtualConsole} baseConsole + */ +const pumpLogToConsole= (log, baseConsole)=> { + for( const [name, ...args]of log) { + // eslint-disable-next-line @endo/no-polymorphic-call + baseConsole[name](...args); + } + }; +// //////////////////////////// Causal Console ///////////////////////////////// -// ///////////////////////////////////////////////////////////////////////////// - -/** @type {ErrorInfo} */ +/** @type {ErrorInfo} */$h‍_once.pumpLogToConsole(pumpLogToConsole); const ErrorInfo= { NOTE: 'ERROR_NOTE:', - MESSAGE: 'ERROR_MESSAGE:'}; + MESSAGE: 'ERROR_MESSAGE:', + CAUSE: 'cause:', + ERRORS: 'errors:'}; freeze(ErrorInfo); /** @type {MakeCausalConsole} */ -const makeCausalConsole= (baseConsole, loggedErrorHandler)=> { +const makeCausalConsole= (baseConsole, loggedErrorHandler)=> { if( !baseConsole) { return undefined; } @@ -6778,6 +6777,14 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> { // eslint-disable-next-line @endo/no-polymorphic-call baseConsole[severity](stackString); // Show the other annotations on error + if( error.cause) { + logErrorInfo(severity, error, ErrorInfo.CAUSE, [error.cause], subErrors); + } + // @ts-expect-error AggregateError has an `errors` property. + if( error.errors) { + // @ts-expect-error AggregateError has an `errors` property. + logErrorInfo(severity, error, ErrorInfo.ERRORS, error.errors, subErrors); + } for( const noteLogArgs of noteLogArgsArray) { logErrorInfo(severity, error, ErrorInfo.NOTE, noteLogArgs, subErrors); } @@ -6823,11 +6830,105 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> { };$h‍_once.makeCausalConsole(makeCausalConsole); freeze(makeCausalConsole); +/** + * @typedef {(...args: unknown[]) => void} Logger + */ -// ///////////////////////////////////////////////////////////////////////////// +/** + * This is a rather horrible kludge to indent the output to a logger in + * the case where some arguments are strings containing newlines. Part of + * the problem is that console-like loggers, including the one in ava, + * join the string arguments of the log message with a space. + * Because of this, there's an extra space at the beginning of each of + * the split lines. So this kludge compensated by putting an extra empty + * string at the beginning, so that the logger will add the same extra + * joiner. + * TODO: Fix this horrible kludge, and indent in a sane manner. + * + * @param {string} str + * @param {string} sep + * @param {string[]} indents + * @returns {string[]} + */ +const indentAfterAllSeps= (str, sep, indents)=> { + const [firstLine, ...restLines]= stringSplit(str, sep); + const indentedRest= arrayFlatMap(restLines, (line)=>[sep, ...indents, line]); + return ['', firstLine, ...indentedRest]; + }; + +/** + * @param {LoggedErrorHandler} loggedErrorHandler + */ +const defineCausalConsoleFromLogger= (loggedErrorHandler)=>{ + /** + * Implement the `VirtualConsole` API badly by turning all calls into + * calls on `tlogger`. We need to do this to have `console` logging + * turn into calls to Ava's `t.log`, so these console log messages + * are output in the right place. + * + * @param {Logger} tlogger + * @returns {VirtualConsole} + */ + const makeCausalConsoleFromLogger= (tlogger)=>{ + const indents= []; + const logWithIndent= (...args)=> { + if( indents.length> 0) { + args= arrayFlatMap(args, (arg)=> + typeof arg=== 'string'&& stringIncludes(arg, '\n')? + indentAfterAllSeps(arg, '\n', indents): + [arg]); + + args= [...indents, ...args]; + } + return tlogger(...args); + }; + const makeNamed= (name, fn)=> + ({ [name]: (...args)=> fn(...args)})[ name]; + + const baseConsole= fromEntries([ + ...arrayMap(consoleLevelMethods, ([name])=> [ + name, + makeNamed(name, logWithIndent)]), + + ...arrayMap(consoleOtherMethods, ([name])=> [ + name, + makeNamed(name, (...args)=> logWithIndent(name, ...args))])]); + + + // https://console.spec.whatwg.org/#grouping + for( const name of ['group', 'groupCollapsed']) { + if( baseConsole[name]) { + baseConsole[name]= makeNamed(name, (...args)=> { + if( args.length>= 1) { + // Prefix the logged data with "group" or "groupCollapsed". + logWithIndent(...args); + } + // A single space is enough; + // the host console will separate them with additional spaces. + arrayPush(indents, ' '); + }); + } + } + if( baseConsole.groupEnd) { + baseConsole.groupEnd= makeNamed('groupEnd', (...args)=> { + arrayPop(indents); + }); + } + harden(baseConsole); + const causalConsole= makeCausalConsole( + /** @type {VirtualConsole} */ baseConsole, + loggedErrorHandler); + + return (/** @type {VirtualConsole} */ causalConsole); + }; + return freeze(makeCausalConsoleFromLogger); + };$h‍_once.defineCausalConsoleFromLogger(defineCausalConsoleFromLogger); +freeze(defineCausalConsoleFromLogger); + +// ///////////////////////// Filter Console //////////////////////////////////// /** @type {FilterConsole} */ -const filterConsole= (baseConsole, filter, _topic= undefined)=> { +const filterConsole= (baseConsole, filter, _topic= undefined)=> { // TODO do something with optional topic string const whitelist= arrayFilter( consoleWhitelist, @@ -6853,8 +6954,8 @@ const filterConsole= (baseConsole, filter, _topic= undefined)=> { freeze(filterConsole); })() , -// === functors[34] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FinalizationRegistry,Map,mapGet,mapDelete,WeakMap,mapSet,finalizationRegistryRegister,weakmapSet,weakmapGet,mapEntries,mapHas;$h‍_imports([["../commons.js", [["FinalizationRegistry", [$h‍_a => (FinalizationRegistry = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapDelete", [$h‍_a => (mapDelete = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["finalizationRegistryRegister", [$h‍_a => (finalizationRegistryRegister = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["mapEntries", [$h‍_a => (mapEntries = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]]]]]); +// === functors[35] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FinalizationRegistry,Map,mapGet,mapDelete,WeakMap,mapSet,finalizationRegistryRegister,weakmapSet,weakmapGet,mapEntries,mapHas;$h‍_imports([["../commons.js", [["FinalizationRegistry", [$h‍_a => (FinalizationRegistry = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapDelete", [$h‍_a => (mapDelete = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["finalizationRegistryRegister", [$h‍_a => (finalizationRegistryRegister = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["mapEntries", [$h‍_a => (mapEntries = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]]]]]); @@ -6978,8 +7079,8 @@ const makeRejectionHandlers= (reportReason)=>{ };$h‍_once.makeRejectionHandlers(makeRejectionHandlers); })() , -// === functors[35] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,apply,defineProperty,freeze,globalThis,defaultHandler,makeCausalConsole,makeRejectionHandlers;$h‍_imports([["../commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./assert.js", [["loggedErrorHandler", [$h‍_a => (defaultHandler = $h‍_a)]]]],["./console.js", [["makeCausalConsole", [$h‍_a => (makeCausalConsole = $h‍_a)]]]],["./unhandled-rejection.js", [["makeRejectionHandlers", [$h‍_a => (makeRejectionHandlers = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []]]); +// === functors[36] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let TypeError,apply,defineProperty,freeze,globalThis,defaultHandler,makeCausalConsole,makeRejectionHandlers;$h‍_imports([["../commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./assert.js", [["loggedErrorHandler", [$h‍_a => (defaultHandler = $h‍_a)]]]],["./console.js", [["makeCausalConsole", [$h‍_a => (makeCausalConsole = $h‍_a)]]]],["./unhandled-rejection.js", [["makeRejectionHandlers", [$h‍_a => (makeRejectionHandlers = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []]]); @@ -7039,14 +7140,14 @@ const tameConsole= ( typeof globalThis.console!== 'undefined'? globalThis.console: typeof globalThis.print=== 'function'? - // Make a good-enough console for eshost (including only functions that - // log at a specific level with no special argument interpretation). - // https://console.spec.whatwg.org/#logging - ((p)=>freeze({ debug: p, log: p, info: p, warn: p, error: p}))( - // eslint-disable-next-line no-undef - wrapLogger(globalThis.print)): + // Make a good-enough console for eshost (including only functions that + // log at a specific level with no special argument interpretation). + // https://console.spec.whatwg.org/#logging + ((p)=>freeze({ debug: p, log: p, info: p, warn: p, error: p}))( + // eslint-disable-next-line no-undef + wrapLogger(globalThis.print)): - undefined; + undefined; // Upgrade a log-only console (as in `eshost -h SpiderMonkey`). @@ -7176,8 +7277,8 @@ const tameConsole= ( };$h‍_once.tameConsole(tameConsole); })() , -// === functors[36] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]); +// === functors[37] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]); @@ -7516,8 +7617,8 @@ const tameV8ErrorConstructor= ( };$h‍_once.tameV8ErrorConstructor(tameV8ErrorConstructor); })() , -// === functors[37] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_ERROR,TypeError,apply,construct,defineProperties,setPrototypeOf,getOwnPropertyDescriptor,defineProperty,NativeErrors,tameV8ErrorConstructor;$h‍_imports([["../commons.js", [["FERAL_ERROR", [$h‍_a => (FERAL_ERROR = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["setPrototypeOf", [$h‍_a => (setPrototypeOf = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]]]],["../permits.js", [["NativeErrors", [$h‍_a => (NativeErrors = $h‍_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h‍_a => (tameV8ErrorConstructor = $h‍_a)]]]]]); +// === functors[38] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FERAL_ERROR,TypeError,apply,construct,defineProperties,setPrototypeOf,getOwnPropertyDescriptor,defineProperty,NativeErrors,tameV8ErrorConstructor;$h‍_imports([["../commons.js", [["FERAL_ERROR", [$h‍_a => (FERAL_ERROR = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["setPrototypeOf", [$h‍_a => (setPrototypeOf = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]]]],["../permits.js", [["NativeErrors", [$h‍_a => (NativeErrors = $h‍_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h‍_a => (tameV8ErrorConstructor = $h‍_a)]]]]]); @@ -7770,8 +7871,10 @@ function tameErrorConstructor( }$h‍_once.default( tameErrorConstructor); })() , -// === functors[38] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let ReferenceError,TypeError,Map,Set,arrayJoin,arrayMap,arrayPush,create,freeze,mapGet,mapHas,mapSet,setAdd,promiseCatch,promiseThen,values,weakmapGet,assert;$h‍_imports([["./commons.js", [["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["promiseCatch", [$h‍_a => (promiseCatch = $h‍_a)]],["promiseThen", [$h‍_a => (promiseThen = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); +// === functors[39] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let getenv,ReferenceError,TypeError,Map,Set,arrayJoin,arrayMap,arrayPush,create,freeze,mapGet,mapHas,mapSet,setAdd,promiseThen,values,weakmapGet,generatorNext,generatorThrow,assert;$h‍_imports([["@endo/env-options", [["getEnvironmentOption", [$h‍_a => (getenv = $h‍_a)]]]],["./commons.js", [["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["promiseThen", [$h‍_a => (promiseThen = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["generatorNext", [$h‍_a => (generatorNext = $h‍_a)]],["generatorThrow", [$h‍_a => (generatorThrow = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); + + @@ -7804,6 +7907,33 @@ const { Fail, details: d, quote: q}= assert; const noop= ()=> { }; +async function asyncTrampoline(generatorFunc, args, errorWrapper) { + const iterator= generatorFunc(...args); + let result= generatorNext(iterator); + while( !result.done) { + try { + // eslint-disable-next-line no-await-in-loop + const val= await result.value; + result= generatorNext(iterator, val); + }catch( error) { + result= generatorThrow(iterator, errorWrapper(error)); + } + } + return result.value; + } + +function syncTrampoline(generatorFunc, args) { + const iterator= generatorFunc(...args); + let result= generatorNext(iterator); + while( !result.done) { + try { + result= generatorNext(iterator, result.value); + }catch( error) { + result= generatorThrow(iterator, error); + } + } + return result.value; + } // `makeAlias` constructs compartment specifier tuples for the `aliases` // private field of compartments. // These aliases allow a compartment to alias an internal module specifier to a @@ -7833,9 +7963,9 @@ const loadRecord= ( compartment, moduleSpecifier, staticModuleRecord, - pendingJobs, + enqueueJob, + selectImplementation, moduleLoads, - errors, importMeta)=> { const { resolveHook, moduleRecords}= weakmapGet( @@ -7861,20 +7991,14 @@ const loadRecord= ( for( const fullSpecifier of values(resolvedImports)) { // Behold: recursion. // eslint-disable-next-line no-use-before-define - const dependencyLoaded= memoizedLoadWithErrorAnnotation( + enqueueJob(memoizedLoadWithErrorAnnotation, [ compartmentPrivateFields, moduleAliases, compartment, fullSpecifier, - pendingJobs, - moduleLoads, - errors); - - setAdd( - pendingJobs, - promiseThen(dependencyLoaded, noop, (error)=>{ - arrayPush(errors, error); - })); + enqueueJob, + selectImplementation, + moduleLoads]); } @@ -7883,19 +8007,17 @@ const loadRecord= ( return moduleRecord; }; -const loadWithoutErrorAnnotation= async( +function* loadWithoutErrorAnnotation( compartmentPrivateFields, moduleAliases, compartment, moduleSpecifier, - pendingJobs, - moduleLoads, - errors)=> - { - const { importHook, moduleMap, moduleMapHook, moduleRecords}= weakmapGet( - compartmentPrivateFields, - compartment); - + enqueueJob, + selectImplementation, + moduleLoads) + { + const { importHook, importNowHook, moduleMap, moduleMapHook, moduleRecords}= + weakmapGet(compartmentPrivateFields, compartment); // Follow moduleMap, or moduleMapHook if present. let aliasNamespace= moduleMap[moduleSpecifier]; @@ -7923,14 +8045,14 @@ const loadWithoutErrorAnnotation= async( } // Behold: recursion. // eslint-disable-next-line no-use-before-define - const aliasRecord= await memoizedLoadWithErrorAnnotation( + const aliasRecord= yield memoizedLoadWithErrorAnnotation( compartmentPrivateFields, moduleAliases, alias.compartment, alias.specifier, - pendingJobs, - moduleLoads, - errors); + enqueueJob, + selectImplementation, + moduleLoads); mapSet(moduleRecords, moduleSpecifier, aliasRecord); return aliasRecord; @@ -7940,7 +8062,10 @@ const loadWithoutErrorAnnotation= async( return mapGet(moduleRecords, moduleSpecifier); } - const staticModuleRecord= await importHook(moduleSpecifier); + const staticModuleRecord= yield selectImplementation( + importHook, + importNowHook)( + moduleSpecifier); if( staticModuleRecord=== null|| typeof staticModuleRecord!== 'object') { Fail `importHook must return a promise for an object, for module ${q( @@ -7971,9 +8096,9 @@ const loadWithoutErrorAnnotation= async( aliasCompartment, aliasSpecifier, aliasModuleRecord, - pendingJobs, + enqueueJob, + selectImplementation, moduleLoads, - errors, importMeta); mapSet(moduleRecords, moduleSpecifier, aliasRecord); @@ -7990,14 +8115,14 @@ const loadWithoutErrorAnnotation= async( } // Behold: recursion. // eslint-disable-next-line no-use-before-define - const aliasRecord= await memoizedLoadWithErrorAnnotation( + const aliasRecord= yield memoizedLoadWithErrorAnnotation( compartmentPrivateFields, moduleAliases, staticModuleRecord.compartment, staticModuleRecord.specifier, - pendingJobs, - moduleLoads, - errors); + enqueueJob, + selectImplementation, + moduleLoads); mapSet(moduleRecords, moduleSpecifier, aliasRecord); return aliasRecord; @@ -8012,20 +8137,20 @@ const loadWithoutErrorAnnotation= async( compartment, moduleSpecifier, staticModuleRecord, - pendingJobs, - moduleLoads, - errors); + enqueueJob, + selectImplementation, + moduleLoads); - }; + } -const memoizedLoadWithErrorAnnotation= async( +const memoizedLoadWithErrorAnnotation= ( compartmentPrivateFields, moduleAliases, compartment, moduleSpecifier, - pendingJobs, - moduleLoads, - errors)=> + enqueueJob, + selectImplementation, + moduleLoads)=> { const { name: compartmentName}= weakmapGet( compartmentPrivateFields, @@ -8043,15 +8168,16 @@ const memoizedLoadWithErrorAnnotation= async( return moduleLoading; } - moduleLoading= promiseCatch( - loadWithoutErrorAnnotation( + moduleLoading= selectImplementation(asyncTrampoline, syncTrampoline)( + loadWithoutErrorAnnotation, + [ compartmentPrivateFields, moduleAliases, compartment, moduleSpecifier, - pendingJobs, - moduleLoads, - errors), + enqueueJob, + selectImplementation, + moduleLoads], (error)=>{ // eslint-disable-next-line @endo/no-polymorphic-call @@ -8070,6 +8196,64 @@ const memoizedLoadWithErrorAnnotation= async( return moduleLoading; }; +function asyncJobQueue() { + /** @type {Set>} */ + const pendingJobs= new Set(); + /** @type {Array} */ + const errors= []; + + /** + * Enqueues a job that starts immediately but won't be awaited until drainQueue is called. + * + * @template {any[]} T + * @param {(...args: T)=>Promise<*>} func + * @param {T} args + */ + const enqueueJob= (func, args)=> { + setAdd( + pendingJobs, + promiseThen(func(...args), noop, (error)=>{ + arrayPush(errors, error); + })); + + }; + /** + * Sequentially awaits pending jobs and returns an array of errors + * + * @returns {Promise>} + */ + const drainQueue= async()=> { + for( const job of pendingJobs) { + // eslint-disable-next-line no-await-in-loop + await job; + } + return errors; + }; + return { enqueueJob, drainQueue}; + } + +/** + * @param {object} options + * @param {Array} options.errors + * @param {string} options.errorPrefix + */ +function throwAggregateError({ errors, errorPrefix}) { + // Throw an aggregate error if there were any errors. + if( errors.length> 0) { + const verbose= + getenv('COMPARTMENT_LOAD_ERRORS', '', ['verbose'])=== 'verbose'; + throw TypeError( + `${errorPrefix} (${errors.length} underlying failures: ${arrayJoin( + arrayMap(errors, (error)=>error.message+( verbose? error.stack: '')), + ', ') + }`); + + } + } + +const preferSync= (_asyncImpl, syncImpl)=> syncImpl; +const preferAsync= (asyncImpl, _syncImpl)=> asyncImpl; + /* * `load` asynchronously gathers the `StaticModuleRecord`s for a module and its * transitive dependencies. @@ -8088,54 +8272,85 @@ const load= async( compartment); - /** @type {Set>} */ - const pendingJobs= new Set(); /** @type {Map>>>} */ const moduleLoads= new Map(); - /** @type {Array} */ - const errors= []; - const dependencyLoaded= memoizedLoadWithErrorAnnotation( + const { enqueueJob, drainQueue}= asyncJobQueue(); + + enqueueJob(memoizedLoadWithErrorAnnotation, [ compartmentPrivateFields, moduleAliases, compartment, moduleSpecifier, - pendingJobs, - moduleLoads, - errors); + enqueueJob, + preferAsync, + moduleLoads]); + + + // Drain pending jobs queue and throw an aggregate error + const errors= await drainQueue(); + + throwAggregateError({ + errors, + errorPrefix: `Failed to load module ${q(moduleSpecifier)} in package ${q( + compartmentName) + }`}); + + }; + +/* + * `loadNow` synchronously gathers the `StaticModuleRecord`s for a module and its + * transitive dependencies. + * The module records refer to each other by a reference to the dependency's + * compartment and the specifier of the module within its own compartment. + * This graph is then ready to be synchronously linked and executed. + */$h‍_once.load(load); +const loadNow= ( + compartmentPrivateFields, + moduleAliases, + compartment, + moduleSpecifier)=> + { + const { name: compartmentName}= weakmapGet( + compartmentPrivateFields, + compartment); + + + /** @type {Map>>>} */ + const moduleLoads= new Map(); - setAdd( - pendingJobs, - promiseThen(dependencyLoaded, noop, (error)=>{ + /** @type {Array} */ + const errors= []; + + const enqueueJob= (func, args)=> { + try { + func(...args); + }catch( error) { arrayPush(errors, error); - })); + } + }; + enqueueJob(memoizedLoadWithErrorAnnotation, [ + compartmentPrivateFields, + moduleAliases, + compartment, + moduleSpecifier, + enqueueJob, + preferSync, + moduleLoads]); - // Drain pending jobs queue. - // Each job is a promise for undefined, regardless of success or failure. - // Before we add a job to the queue, we catch any error and push it into the - // `errors` accumulator. - for( const job of pendingJobs) { - // eslint-disable-next-line no-await-in-loop - await job; - } - // Throw an aggregate error if there were any errors. - if( errors.length> 0) { - throw TypeError( - `Failed to load module ${q(moduleSpecifier)} in package ${q( - compartmentName) - } (${errors.length} underlying failures: ${arrayJoin( - arrayMap(errors, (error)=>error.message), - ', ') - }`); + throwAggregateError({ + errors, + errorPrefix: `Failed to load module ${q(moduleSpecifier)} in package ${q( + compartmentName) + }`}); - } - };$h‍_once.load(load); + };$h‍_once.loadNow(loadNow); })() , -// === functors[39] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let makeAlias,Proxy,TypeError,create,freeze,mapGet,mapHas,mapSet,ownKeys,reflectGet,reflectGetOwnPropertyDescriptor,reflectHas,reflectIsExtensible,reflectPreventExtensions,toStringTagSymbol,weakmapSet,assert;$h‍_imports([["./module-load.js", [["makeAlias", [$h‍_a => (makeAlias = $h‍_a)]]]],["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["reflectGet", [$h‍_a => (reflectGet = $h‍_a)]],["reflectGetOwnPropertyDescriptor", [$h‍_a => (reflectGetOwnPropertyDescriptor = $h‍_a)]],["reflectHas", [$h‍_a => (reflectHas = $h‍_a)]],["reflectIsExtensible", [$h‍_a => (reflectIsExtensible = $h‍_a)]],["reflectPreventExtensions", [$h‍_a => (reflectPreventExtensions = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); +// === functors[40] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let makeAlias,Proxy,TypeError,create,freeze,mapGet,mapHas,mapSet,ownKeys,reflectGet,reflectGetOwnPropertyDescriptor,reflectHas,reflectIsExtensible,reflectPreventExtensions,toStringTagSymbol,weakmapSet,assert;$h‍_imports([["./module-load.js", [["makeAlias", [$h‍_a => (makeAlias = $h‍_a)]]]],["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["reflectGet", [$h‍_a => (reflectGet = $h‍_a)]],["reflectGetOwnPropertyDescriptor", [$h‍_a => (reflectGetOwnPropertyDescriptor = $h‍_a)]],["reflectHas", [$h‍_a => (reflectHas = $h‍_a)]],["reflectIsExtensible", [$h‍_a => (reflectIsExtensible = $h‍_a)]],["reflectPreventExtensions", [$h‍_a => (reflectPreventExtensions = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); @@ -8337,8 +8552,8 @@ const getDeferredExports= ( };$h‍_once.getDeferredExports(getDeferredExports); })() , -// === functors[40] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,arrayPush,create,getOwnPropertyDescriptors,evadeHtmlCommentTest,evadeImportExpressionTest,rejectSomeDirectEvalExpressions,makeSafeEvaluator;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]]]],["./transforms.js", [["evadeHtmlCommentTest", [$h‍_a => (evadeHtmlCommentTest = $h‍_a)]],["evadeImportExpressionTest", [$h‍_a => (evadeImportExpressionTest = $h‍_a)]],["rejectSomeDirectEvalExpressions", [$h‍_a => (rejectSomeDirectEvalExpressions = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]]]); +// === functors[41] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let TypeError,arrayPush,create,getOwnPropertyDescriptors,evadeHtmlCommentTest,evadeImportExpressionTest,rejectSomeDirectEvalExpressions,makeSafeEvaluator;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]]]],["./transforms.js", [["evadeHtmlCommentTest", [$h‍_a => (evadeHtmlCommentTest = $h‍_a)]],["evadeImportExpressionTest", [$h‍_a => (evadeImportExpressionTest = $h‍_a)]],["rejectSomeDirectEvalExpressions", [$h‍_a => (rejectSomeDirectEvalExpressions = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]]]); @@ -8433,8 +8648,8 @@ const compartmentEvaluate= (compartmentFields, source, options)=> { };$h‍_once.compartmentEvaluate(compartmentEvaluate); })() , -// === functors[41] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let assert,getDeferredExports,ReferenceError,SyntaxError,TypeError,arrayForEach,arrayIncludes,arrayPush,arraySome,arraySort,create,defineProperty,entries,freeze,isArray,keys,mapGet,weakmapGet,reflectHas,assign,compartmentEvaluate;$h‍_imports([["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./module-proxy.js", [["getDeferredExports", [$h‍_a => (getDeferredExports = $h‍_a)]]]],["./commons.js", [["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["arraySome", [$h‍_a => (arraySome = $h‍_a)]],["arraySort", [$h‍_a => (arraySort = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["keys", [$h‍_a => (keys = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["reflectHas", [$h‍_a => (reflectHas = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]]]],["./compartment-evaluate.js", [["compartmentEvaluate", [$h‍_a => (compartmentEvaluate = $h‍_a)]]]]]); +// === functors[42] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let assert,getDeferredExports,ReferenceError,SyntaxError,TypeError,arrayForEach,arrayIncludes,arrayPush,arraySome,arraySort,create,defineProperty,entries,freeze,isArray,keys,mapGet,weakmapGet,reflectHas,assign,compartmentEvaluate;$h‍_imports([["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./module-proxy.js", [["getDeferredExports", [$h‍_a => (getDeferredExports = $h‍_a)]]]],["./commons.js", [["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["arraySome", [$h‍_a => (arraySome = $h‍_a)]],["arraySort", [$h‍_a => (arraySort = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["keys", [$h‍_a => (keys = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["reflectHas", [$h‍_a => (reflectHas = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]]]],["./compartment-evaluate.js", [["compartmentEvaluate", [$h‍_a => (compartmentEvaluate = $h‍_a)]]]]]); @@ -8924,8 +9139,8 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make };$h‍_once.makeModuleInstance(makeModuleInstance); })() , -// === functors[42] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let assert,makeModuleInstance,makeThirdPartyModuleInstance,Map,ReferenceError,TypeError,entries,isArray,isObject,mapGet,mapHas,mapSet,weakmapGet;$h‍_imports([["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./module-instance.js", [["makeModuleInstance", [$h‍_a => (makeModuleInstance = $h‍_a)]],["makeThirdPartyModuleInstance", [$h‍_a => (makeThirdPartyModuleInstance = $h‍_a)]]]],["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]]]]]); +// === functors[43] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let assert,makeModuleInstance,makeThirdPartyModuleInstance,Map,ReferenceError,TypeError,entries,isArray,isObject,mapGet,mapHas,mapSet,weakmapGet;$h‍_imports([["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./module-instance.js", [["makeModuleInstance", [$h‍_a => (makeModuleInstance = $h‍_a)]],["makeThirdPartyModuleInstance", [$h‍_a => (makeThirdPartyModuleInstance = $h‍_a)]]]],["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]]]]]); @@ -9104,8 +9319,9 @@ const instantiate= ( };$h‍_once.instantiate(instantiate); })() , -// === functors[43] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Map,ReferenceError,TypeError,WeakMap,assign,defineProperties,entries,promiseThen,weakmapGet,weakmapSet,setGlobalObjectSymbolUnscopables,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,sharedGlobalPropertyNames,load,link,getDeferredExports,assert,compartmentEvaluate,makeSafeEvaluator;$h‍_imports([["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["promiseThen", [$h‍_a => (promiseThen = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectSymbolUnscopables", [$h‍_a => (setGlobalObjectSymbolUnscopables = $h‍_a)]],["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]],["setGlobalObjectEvaluators", [$h‍_a => (setGlobalObjectEvaluators = $h‍_a)]]]],["./permits.js", [["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]]]],["./module-load.js", [["load", [$h‍_a => (load = $h‍_a)]]]],["./module-link.js", [["link", [$h‍_a => (link = $h‍_a)]]]],["./module-proxy.js", [["getDeferredExports", [$h‍_a => (getDeferredExports = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./compartment-evaluate.js", [["compartmentEvaluate", [$h‍_a => (compartmentEvaluate = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]]]); +// === functors[44] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Map,ReferenceError,TypeError,WeakMap,assign,defineProperties,entries,promiseThen,toStringTagSymbol,weakmapGet,weakmapSet,setGlobalObjectSymbolUnscopables,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,sharedGlobalPropertyNames,load,loadNow,link,getDeferredExports,assert,compartmentEvaluate,makeSafeEvaluator;$h‍_imports([["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["promiseThen", [$h‍_a => (promiseThen = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectSymbolUnscopables", [$h‍_a => (setGlobalObjectSymbolUnscopables = $h‍_a)]],["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]],["setGlobalObjectEvaluators", [$h‍_a => (setGlobalObjectEvaluators = $h‍_a)]]]],["./permits.js", [["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]]]],["./module-load.js", [["load", [$h‍_a => (load = $h‍_a)]],["loadNow", [$h‍_a => (loadNow = $h‍_a)]]]],["./module-link.js", [["link", [$h‍_a => (link = $h‍_a)]]]],["./module-proxy.js", [["getDeferredExports", [$h‍_a => (getDeferredExports = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./compartment-evaluate.js", [["compartmentEvaluate", [$h‍_a => (compartmentEvaluate = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]]]); + @@ -9212,10 +9428,6 @@ const CompartmentPrototype= { return compartmentEvaluate(compartmentFields, source, options); }, - toString() { - return '[object Compartment]'; - }, - module(specifier) { if( typeof specifier!== 'string') { throw TypeError('first argument of module() must be a string'); @@ -9270,9 +9482,21 @@ const CompartmentPrototype= { } assertModuleHooks(this); - + loadNow(privateFields, moduleAliases, this, specifier); return compartmentImportNow(/** @type {Compartment} */ this, specifier); - }};$h‍_once.CompartmentPrototype(CompartmentPrototype); + }}; + + +// This causes `String(new Compartment())` to evaluate to `[object Compartment]`. +// The descriptor follows the conventions of other globals with @@toStringTag +// properties, e.g. Math. +$h‍_once.CompartmentPrototype(CompartmentPrototype);defineProperties(CompartmentPrototype,{ + [toStringTagSymbol]: { + value: 'Compartment', + writable: false, + enumerable: false, + configurable: true}}); + defineProperties(InertCompartment, { @@ -9307,6 +9531,7 @@ const makeCompartmentConstructor= ( __shimTransforms__= [], resolveHook, importHook, + importNowHook, moduleMapHook, importMetaHook}= options; @@ -9383,6 +9608,7 @@ const makeCompartmentConstructor= ( safeEvaluate, resolveHook, importHook, + importNowHook, moduleMap, moduleMapHook, importMetaHook, @@ -9399,8 +9625,8 @@ const makeCompartmentConstructor= ( };$h‍_once.makeCompartmentConstructor(makeCompartmentConstructor); })() , -// === functors[44] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_FUNCTION,Float32Array,Map,Set,String,getOwnPropertyDescriptor,getPrototypeOf,iterateArray,iterateMap,iterateSet,iterateString,matchAllRegExp,matchAllSymbol,regexpPrototype,globalThis,InertCompartment;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["Float32Array", [$h‍_a => (Float32Array = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["iterateArray", [$h‍_a => (iterateArray = $h‍_a)]],["iterateMap", [$h‍_a => (iterateMap = $h‍_a)]],["iterateSet", [$h‍_a => (iterateSet = $h‍_a)]],["iterateString", [$h‍_a => (iterateString = $h‍_a)]],["matchAllRegExp", [$h‍_a => (matchAllRegExp = $h‍_a)]],["matchAllSymbol", [$h‍_a => (matchAllSymbol = $h‍_a)]],["regexpPrototype", [$h‍_a => (regexpPrototype = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./compartment.js", [["InertCompartment", [$h‍_a => (InertCompartment = $h‍_a)]]]]]); +// === functors[45] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let FERAL_FUNCTION,Float32Array,Map,Set,String,getOwnPropertyDescriptor,getPrototypeOf,iterateArray,iterateMap,iterateSet,iterateString,matchAllRegExp,matchAllSymbol,regexpPrototype,globalThis,InertCompartment;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["Float32Array", [$h‍_a => (Float32Array = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["iterateArray", [$h‍_a => (iterateArray = $h‍_a)]],["iterateMap", [$h‍_a => (iterateMap = $h‍_a)]],["iterateSet", [$h‍_a => (iterateSet = $h‍_a)]],["iterateString", [$h‍_a => (iterateString = $h‍_a)]],["matchAllRegExp", [$h‍_a => (matchAllRegExp = $h‍_a)]],["matchAllSymbol", [$h‍_a => (matchAllSymbol = $h‍_a)]],["regexpPrototype", [$h‍_a => (regexpPrototype = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./compartment.js", [["InertCompartment", [$h‍_a => (InertCompartment = $h‍_a)]]]]]); @@ -9563,8 +9789,8 @@ const getAnonymousIntrinsics= ()=> { };$h‍_once.getAnonymousIntrinsics(getAnonymousIntrinsics); })() , -// === functors[45] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,freeze;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]]]); +// === functors[46] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let TypeError,freeze;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]]]); const tameHarden= (safeHarden, hardenTaming)=> { @@ -9595,8 +9821,9 @@ const tameHarden= (safeHarden, hardenTaming)=> { freeze(tameHarden); })() , -// === functors[46] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Symbol,entries,fromEntries,getOwnPropertyDescriptors,defineProperties,arrayMap;$h‍_imports([["./commons.js", [["Symbol", [$h‍_a => (Symbol = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]]]]]); +// === functors[47] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let Symbol,entries,fromEntries,getOwnPropertyDescriptors,defineProperties,arrayMap,functionBind;$h‍_imports([["./commons.js", [["Symbol", [$h‍_a => (Symbol = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["functionBind", [$h‍_a => (functionBind = $h‍_a)]]]]]); + @@ -9635,11 +9862,9 @@ const tameSymbolConstructor= ()=> { const OriginalSymbol= Symbol; const SymbolPrototype= OriginalSymbol.prototype; - const SharedSymbol= { - Symbol(description) { - return OriginalSymbol(description); - }}. - Symbol; + // Bypass Hermes bug, fixed in: https://github.com/facebook/hermes/commit/00f18c89c720e1c34592bb85a1a8d311e6e99599 + // Make a "copy" of the primordial [Symbol "constructor"](https://tc39.es/ecma262/#sec-symbol-description) which maintains all observable behavior. The primordial explicitly throws on `[[Construct]]` and has a `[[Call]]` which ignores the receiver. Binding also maintains the `toString` source as a native function. The `name` is restored below when copying own properties. + const SharedSymbol= functionBind(Symbol, undefined); defineProperties(SymbolPrototype, { constructor: { @@ -9663,8 +9888,8 @@ const tameSymbolConstructor= ()=> { };$h‍_once.tameSymbolConstructor(tameSymbolConstructor); })() , -// === functors[47] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let getOwnPropertyDescriptor,apply,defineProperty,toStringTagSymbol;$h‍_imports([["./commons.js", [["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]); +// === functors[48] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let getOwnPropertyDescriptor,apply,defineProperty,toStringTagSymbol;$h‍_imports([["./commons.js", [["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]); @@ -9876,8 +10101,8 @@ const tameFauxDataProperties= (intrinsics)=>{ };$h‍_once.tameFauxDataProperties(tameFauxDataProperties); })() , -// === functors[48] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let getenv,FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,globalThis,is,ownKeys,stringSplit,noEvalEvaluate,getOwnPropertyNames,getPrototypeOf,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,getAnonymousIntrinsics,makeCompartmentConstructor,tameHarden,tameSymbolConstructor,tameFauxDataProperties;$h‍_imports([["@endo/env-options", [["getEnvironmentOption", [$h‍_a => (getenv = $h‍_a)]]]],["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["noEvalEvaluate", [$h‍_a => (noEvalEvaluate = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]]]],["./make-hardener.js", [["makeHardener", [$h‍_a => (makeHardener = $h‍_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h‍_a => (makeIntrinsicsCollector = $h‍_a)]]]],["./permits-intrinsics.js", [["default", [$h‍_a => (whitelistIntrinsics = $h‍_a)]]]],["./tame-function-constructors.js", [["default", [$h‍_a => (tameFunctionConstructors = $h‍_a)]]]],["./tame-date-constructor.js", [["default", [$h‍_a => (tameDateConstructor = $h‍_a)]]]],["./tame-math-object.js", [["default", [$h‍_a => (tameMathObject = $h‍_a)]]]],["./tame-regexp-constructor.js", [["default", [$h‍_a => (tameRegExpConstructor = $h‍_a)]]]],["./enable-property-overrides.js", [["default", [$h‍_a => (enablePropertyOverrides = $h‍_a)]]]],["./tame-locale-methods.js", [["default", [$h‍_a => (tameLocaleMethods = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]],["setGlobalObjectEvaluators", [$h‍_a => (setGlobalObjectEvaluators = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]],["./permits.js", [["initialGlobalPropertyNames", [$h‍_a => (initialGlobalPropertyNames = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./tame-domains.js", [["tameDomains", [$h‍_a => (tameDomains = $h‍_a)]]]],["./error/tame-console.js", [["tameConsole", [$h‍_a => (tameConsole = $h‍_a)]]]],["./error/tame-error-constructor.js", [["default", [$h‍_a => (tameErrorConstructor = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]],["makeAssert", [$h‍_a => (makeAssert = $h‍_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h‍_a => (getAnonymousIntrinsics = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-harden.js", [["tameHarden", [$h‍_a => (tameHarden = $h‍_a)]]]],["./tame-symbol-constructor.js", [["tameSymbolConstructor", [$h‍_a => (tameSymbolConstructor = $h‍_a)]]]],["./tame-faux-data-properties.js", [["tameFauxDataProperties", [$h‍_a => (tameFauxDataProperties = $h‍_a)]]]]]); +// === functors[49] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let getenv,FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,globalThis,is,ownKeys,stringSplit,noEvalEvaluate,getOwnPropertyNames,getPrototypeOf,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,getAnonymousIntrinsics,makeCompartmentConstructor,tameHarden,tameSymbolConstructor,tameFauxDataProperties;$h‍_imports([["@endo/env-options", [["getEnvironmentOption", [$h‍_a => (getenv = $h‍_a)]]]],["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["noEvalEvaluate", [$h‍_a => (noEvalEvaluate = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]]]],["./make-hardener.js", [["makeHardener", [$h‍_a => (makeHardener = $h‍_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h‍_a => (makeIntrinsicsCollector = $h‍_a)]]]],["./permits-intrinsics.js", [["default", [$h‍_a => (whitelistIntrinsics = $h‍_a)]]]],["./tame-function-constructors.js", [["default", [$h‍_a => (tameFunctionConstructors = $h‍_a)]]]],["./tame-date-constructor.js", [["default", [$h‍_a => (tameDateConstructor = $h‍_a)]]]],["./tame-math-object.js", [["default", [$h‍_a => (tameMathObject = $h‍_a)]]]],["./tame-regexp-constructor.js", [["default", [$h‍_a => (tameRegExpConstructor = $h‍_a)]]]],["./enable-property-overrides.js", [["default", [$h‍_a => (enablePropertyOverrides = $h‍_a)]]]],["./tame-locale-methods.js", [["default", [$h‍_a => (tameLocaleMethods = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]],["setGlobalObjectEvaluators", [$h‍_a => (setGlobalObjectEvaluators = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]],["./permits.js", [["initialGlobalPropertyNames", [$h‍_a => (initialGlobalPropertyNames = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./tame-domains.js", [["tameDomains", [$h‍_a => (tameDomains = $h‍_a)]]]],["./error/tame-console.js", [["tameConsole", [$h‍_a => (tameConsole = $h‍_a)]]]],["./error/tame-error-constructor.js", [["default", [$h‍_a => (tameErrorConstructor = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]],["makeAssert", [$h‍_a => (makeAssert = $h‍_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h‍_a => (getAnonymousIntrinsics = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-harden.js", [["tameHarden", [$h‍_a => (tameHarden = $h‍_a)]]]],["./tame-symbol-constructor.js", [["tameSymbolConstructor", [$h‍_a => (tameSymbolConstructor = $h‍_a)]]]],["./tame-faux-data-properties.js", [["tameFauxDataProperties", [$h‍_a => (tameFauxDataProperties = $h‍_a)]]]]]); @@ -9935,7 +10160,7 @@ const tameFauxDataProperties= (intrinsics)=>{ -/** @typedef {import('../types.js').LockdownOptions} LockdownOptions */ +/** @import {LockdownOptions} from '../types.js' */ const { Fail, details: d, quote: q}= assert; @@ -10319,8 +10544,8 @@ const repairIntrinsics= (options= {})=> { };$h‍_once.repairIntrinsics(repairIntrinsics); })() , -// === functors[49] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let globalThis,repairIntrinsics;$h‍_imports([["./assert-sloppy-mode.js", []],["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./lockdown.js", [["repairIntrinsics", [$h‍_a => (repairIntrinsics = $h‍_a)]]]]]); +// === functors[50] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let globalThis,repairIntrinsics;$h‍_imports([["./assert-sloppy-mode.js", []],["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./lockdown.js", [["repairIntrinsics", [$h‍_a => (repairIntrinsics = $h‍_a)]]]]]); @@ -10329,8 +10554,10 @@ const repairIntrinsics= (options= {})=> { +/** @import {LockdownOptions} from '../types.js' */ + /** - * @param {import('./lockdown.js').LockdownOptions} options + * @param {LockdownOptions} options */ globalThis.lockdown= (options)=>{ const hardenIntrinsics= repairIntrinsics(options); @@ -10338,7 +10565,7 @@ globalThis.lockdown= (options)=>{ }; /** - * @param {import('./lockdown.js').LockdownOptions} options + * @param {LockdownOptions} options */ globalThis.repairIntrinsics= (options)=>{ const hardenIntrinsics= repairIntrinsics(options); @@ -10357,8 +10584,8 @@ globalThis.repairIntrinsics= (options)=>{ }; })() , -// === functors[50] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let globalThis,makeCompartmentConstructor,tameFunctionToString,getGlobalIntrinsics;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./intrinsics.js", [["getGlobalIntrinsics", [$h‍_a => (getGlobalIntrinsics = $h‍_a)]]]]]); +// === functors[51] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let globalThis,makeCompartmentConstructor,tameFunctionToString,getGlobalIntrinsics;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./intrinsics.js", [["getGlobalIntrinsics", [$h‍_a => (getGlobalIntrinsics = $h‍_a)]]]]]); @@ -10374,15 +10601,68 @@ globalThis.Compartment= makeCompartmentConstructor( markVirtualizedNativeFunction); })() , -// === functors[51] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let globalThis,assert;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); +// === functors[52] === +({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 'use strict'; let globalThis,assert;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]); globalThis.assert= assert; })() , -// === functors[52] === -({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([["./src/lockdown-shim.js", []],["./src/compartment-shim.js", []],["./src/assert-shim.js", []]]); +// === functors[53] === +({ 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)]]]]]); + + + +// TODO possible additional exports. Some are privileged. +// export { loggedErrorHandler }; +// export { +// makeCausalConsole, +// consoleLevelMethods, +// consoleOtherMethods, +// makeLoggingConsoleKit, +// filterConsole, +// pumpLogToConsole, +// } from './src/error/console.js'; +// export { assertLogs, throwsAndLogs } from './src/error/throws-and-logs.js'; + +/** + * Makes a Console like the + * [SES causal `console`](https://github.com/endojs/endo/blob/master/packages/ses/src/error/README.md) + * but whose output is redirected to the supplied `logger` function. + */ +const makeCausalConsoleFromLoggerForSesAva= + defineCausalConsoleFromLogger(loggedErrorHandler); + +/** + *`makeCausalConsoleFromLoggerForSesAva` is privileged because it exposes + * unredacted error info onto the `Logger` provided by the caller. It + * should not be made available to non-privileged code. + * + * Further, we consider this particular API choice to be experimental + * and may change in the future. It is currently only intended for use by + * `@endo/ses-ava`, with which it will be co-maintained. + * + * Thus, this `console-shim.js` makes `makeCausalConsoleFromLoggerForSesAva` + * available on `globalThis` which it *assumes* is the global of the start + * compartment and is therefore allowed to hold powers that should not be + * available in constructed compartments. It makes it available as the value of + * a global property named by a registered symbol named + * `MAKE_CAUSAL_CONSOLE_FROM_LOGGER_KEY_FOR_SES_AVA`. + * + * Anyone accessing this, including `@endo/ses-ava`, should feature test for + * this and be tolerant of its absence. It may indeed disappear from later + * versions of the ses-shim. + */ +const MAKE_CAUSAL_CONSOLE_FROM_LOGGER_KEY_FOR_SES_AVA= symbolFor( + 'MAKE_CAUSAL_CONSOLE_FROM_LOGGER_KEY_FOR_SES_AVA'); + + +globalThis[MAKE_CAUSAL_CONSOLE_FROM_LOGGER_KEY_FOR_SES_AVA]= + makeCausalConsoleFromLoggerForSesAva; +})() +, +// === functors[54] === +({ 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", []]]); })() , ]; // functors end @@ -10433,6 +10713,7 @@ globalThis.assert= assert; ReferenceError: cell("ReferenceError"), SyntaxError: cell("SyntaxError"), TypeError: cell("TypeError"), + AggregateError: cell("AggregateError"), assign: cell("assign"), create: cell("create"), defineProperties: cell("defineProperties"), @@ -10483,6 +10764,7 @@ globalThis.assert= assert; weaksetPrototype: cell("weaksetPrototype"), functionPrototype: cell("functionPrototype"), promisePrototype: cell("promisePrototype"), + generatorPrototype: cell("generatorPrototype"), typedArrayPrototype: cell("typedArrayPrototype"), uncurryThis: cell("uncurryThis"), objectHasOwnProperty: cell("objectHasOwnProperty"), @@ -10491,6 +10773,7 @@ globalThis.assert= assert; arrayIncludes: cell("arrayIncludes"), arrayJoin: cell("arrayJoin"), arrayMap: cell("arrayMap"), + arrayFlatMap: cell("arrayFlatMap"), arrayPop: cell("arrayPop"), arrayPush: cell("arrayPush"), arraySlice: cell("arraySlice"), @@ -10515,6 +10798,8 @@ globalThis.assert= assert; stringIncludes: cell("stringIncludes"), stringIndexOf: cell("stringIndexOf"), stringMatch: cell("stringMatch"), + generatorNext: cell("generatorNext"), + generatorThrow: cell("generatorThrow"), stringReplace: cell("stringReplace"), stringSearch: cell("stringSearch"), stringSlice: cell("stringSlice"), @@ -10528,6 +10813,7 @@ globalThis.assert= assert; weaksetAdd: cell("weaksetAdd"), weaksetHas: cell("weaksetHas"), functionToString: cell("functionToString"), + functionBind: cell("functionBind"), promiseAll: cell("promiseAll"), promiseCatch: cell("promiseCatch"), promiseThen: cell("promiseThen"), @@ -10540,6 +10826,8 @@ globalThis.assert= assert; FERAL_EVAL: cell("FERAL_EVAL"), FERAL_FUNCTION: cell("FERAL_FUNCTION"), noEvalEvaluate: cell("noEvalEvaluate"), + FERAL_STACK_GETTER: cell("FERAL_STACK_GETTER"), + FERAL_STACK_SETTER: cell("FERAL_STACK_SETTER"), }, { }, @@ -10562,6 +10850,8 @@ globalThis.assert= assert; }, { makeLRUCacheMap: cell("makeLRUCacheMap"), + }, + { makeNoteLogArgsArrayKit: cell("makeNoteLogArgsArrayKit"), }, { @@ -10569,18 +10859,19 @@ globalThis.assert= assert; loggedErrorHandler: cell("loggedErrorHandler"), makeAssert: cell("makeAssert"), assert: cell("assert"), + sanitizeError: cell("sanitizeError"), }, { isTypedArray: cell("isTypedArray"), makeHardener: cell("makeHardener"), }, { + NativeErrors: cell("NativeErrors"), constantProperties: cell("constantProperties"), universalPropertyNames: cell("universalPropertyNames"), initialGlobalPropertyNames: cell("initialGlobalPropertyNames"), sharedGlobalPropertyNames: cell("sharedGlobalPropertyNames"), uniqueGlobalPropertyNames: cell("uniqueGlobalPropertyNames"), - NativeErrors: cell("NativeErrors"), FunctionInstance: cell("FunctionInstance"), AsyncFunctionInstance: cell("AsyncFunctionInstance"), isAccessorPermit: cell("isAccessorPermit"), @@ -10669,10 +10960,13 @@ globalThis.assert= assert; tameDomains: cell("tameDomains"), }, { + consoleLevelMethods: cell("consoleLevelMethods"), + consoleOtherMethods: cell("consoleOtherMethods"), makeLoggingConsoleKit: cell("makeLoggingConsoleKit"), + pumpLogToConsole: cell("pumpLogToConsole"), makeCausalConsole: cell("makeCausalConsole"), + defineCausalConsoleFromLogger: cell("defineCausalConsoleFromLogger"), filterConsole: cell("filterConsole"), - consoleWhitelist: cell("consoleWhitelist"), }, { makeRejectionHandlers: cell("makeRejectionHandlers"), @@ -10691,6 +10985,7 @@ globalThis.assert= assert; { makeAlias: cell("makeAlias"), load: cell("load"), + loadNow: cell("loadNow"), }, { deferExports: cell("deferExports"), @@ -10737,6 +11032,8 @@ globalThis.assert= assert; }, { }, + { + }, ]; Object.defineProperties(cells[3], Object.getOwnPropertyDescriptors(cells[2])); @@ -10800,6 +11097,7 @@ function observeImports(map, importName, importIndex) { ReferenceError: cells[0].ReferenceError.set, SyntaxError: cells[0].SyntaxError.set, TypeError: cells[0].TypeError.set, + AggregateError: cells[0].AggregateError.set, assign: cells[0].assign.set, create: cells[0].create.set, defineProperties: cells[0].defineProperties.set, @@ -10850,6 +11148,7 @@ function observeImports(map, importName, importIndex) { weaksetPrototype: cells[0].weaksetPrototype.set, functionPrototype: cells[0].functionPrototype.set, promisePrototype: cells[0].promisePrototype.set, + generatorPrototype: cells[0].generatorPrototype.set, typedArrayPrototype: cells[0].typedArrayPrototype.set, uncurryThis: cells[0].uncurryThis.set, objectHasOwnProperty: cells[0].objectHasOwnProperty.set, @@ -10858,6 +11157,7 @@ function observeImports(map, importName, importIndex) { arrayIncludes: cells[0].arrayIncludes.set, arrayJoin: cells[0].arrayJoin.set, arrayMap: cells[0].arrayMap.set, + arrayFlatMap: cells[0].arrayFlatMap.set, arrayPop: cells[0].arrayPop.set, arrayPush: cells[0].arrayPush.set, arraySlice: cells[0].arraySlice.set, @@ -10882,6 +11182,8 @@ function observeImports(map, importName, importIndex) { stringIncludes: cells[0].stringIncludes.set, stringIndexOf: cells[0].stringIndexOf.set, stringMatch: cells[0].stringMatch.set, + generatorNext: cells[0].generatorNext.set, + generatorThrow: cells[0].generatorThrow.set, stringReplace: cells[0].stringReplace.set, stringSearch: cells[0].stringSearch.set, stringSlice: cells[0].stringSlice.set, @@ -10895,6 +11197,7 @@ function observeImports(map, importName, importIndex) { weaksetAdd: cells[0].weaksetAdd.set, weaksetHas: cells[0].weaksetHas.set, functionToString: cells[0].functionToString.set, + functionBind: cells[0].functionBind.set, promiseAll: cells[0].promiseAll.set, promiseCatch: cells[0].promiseCatch.set, promiseThen: cells[0].promiseThen.set, @@ -10907,6 +11210,8 @@ function observeImports(map, importName, importIndex) { FERAL_EVAL: cells[0].FERAL_EVAL.set, FERAL_FUNCTION: cells[0].FERAL_FUNCTION.set, noEvalEvaluate: cells[0].noEvalEvaluate.set, + FERAL_STACK_GETTER: cells[0].FERAL_STACK_GETTER.set, + FERAL_STACK_SETTER: cells[0].FERAL_STACK_SETTER.set, }, importMeta: {}, }); @@ -10983,66 +11288,58 @@ function observeImports(map, importName, importIndex) { functors[7]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./internal-types.js", 6); }, liveVar: { }, onceVar: { makeLRUCacheMap: cells[7].makeLRUCacheMap.set, - makeNoteLogArgsArrayKit: cells[7].makeNoteLogArgsArrayKit.set, }, importMeta: {}, }); functors[8]({ imports(entries) { const map = new Map(entries); - observeImports(map, "../commons.js", 0); - observeImports(map, "./stringify-utils.js", 4); - observeImports(map, "./types.js", 5); + observeImports(map, "../make-lru-cachemap.js", 7); observeImports(map, "./internal-types.js", 6); - observeImports(map, "./note-log-args.js", 7); }, liveVar: { }, onceVar: { - unredactedDetails: cells[8].unredactedDetails.set, - loggedErrorHandler: cells[8].loggedErrorHandler.set, - makeAssert: cells[8].makeAssert.set, - assert: cells[8].assert.set, + makeNoteLogArgsArrayKit: cells[8].makeNoteLogArgsArrayKit.set, }, importMeta: {}, }); functors[9]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./commons.js", 0); - observeImports(map, "./error/assert.js", 8); + observeImports(map, "../commons.js", 0); + observeImports(map, "./stringify-utils.js", 4); + observeImports(map, "./types.js", 5); + observeImports(map, "./internal-types.js", 6); + observeImports(map, "./note-log-args.js", 8); }, liveVar: { }, onceVar: { - isTypedArray: cells[9].isTypedArray.set, - makeHardener: cells[9].makeHardener.set, + unredactedDetails: cells[9].unredactedDetails.set, + loggedErrorHandler: cells[9].loggedErrorHandler.set, + makeAssert: cells[9].makeAssert.set, + assert: cells[9].assert.set, + sanitizeError: cells[9].sanitizeError.set, }, importMeta: {}, }); functors[10]({ imports(entries) { const map = new Map(entries); + observeImports(map, "./commons.js", 0); + observeImports(map, "./error/assert.js", 9); }, liveVar: { }, onceVar: { - constantProperties: cells[10].constantProperties.set, - universalPropertyNames: cells[10].universalPropertyNames.set, - initialGlobalPropertyNames: cells[10].initialGlobalPropertyNames.set, - sharedGlobalPropertyNames: cells[10].sharedGlobalPropertyNames.set, - uniqueGlobalPropertyNames: cells[10].uniqueGlobalPropertyNames.set, - NativeErrors: cells[10].NativeErrors.set, - FunctionInstance: cells[10].FunctionInstance.set, - AsyncFunctionInstance: cells[10].AsyncFunctionInstance.set, - isAccessorPermit: cells[10].isAccessorPermit.set, - permitted: cells[10].permitted.set, + isTypedArray: cells[10].isTypedArray.set, + makeHardener: cells[10].makeHardener.set, }, importMeta: {}, }); @@ -11050,32 +11347,41 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./permits.js", 10); }, liveVar: { }, onceVar: { - makeIntrinsicsCollector: cells[11].makeIntrinsicsCollector.set, - getGlobalIntrinsics: cells[11].getGlobalIntrinsics.set, + NativeErrors: cells[11].NativeErrors.set, + constantProperties: cells[11].constantProperties.set, + universalPropertyNames: cells[11].universalPropertyNames.set, + initialGlobalPropertyNames: cells[11].initialGlobalPropertyNames.set, + sharedGlobalPropertyNames: cells[11].sharedGlobalPropertyNames.set, + uniqueGlobalPropertyNames: cells[11].uniqueGlobalPropertyNames.set, + FunctionInstance: cells[11].FunctionInstance.set, + AsyncFunctionInstance: cells[11].AsyncFunctionInstance.set, + isAccessorPermit: cells[11].isAccessorPermit.set, + permitted: cells[11].permitted.set, }, importMeta: {}, }); functors[12]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./permits.js", 10); observeImports(map, "./commons.js", 0); + observeImports(map, "./permits.js", 11); }, liveVar: { }, onceVar: { - default: cells[12].default.set, + makeIntrinsicsCollector: cells[12].makeIntrinsicsCollector.set, + getGlobalIntrinsics: cells[12].getGlobalIntrinsics.set, }, importMeta: {}, }); functors[13]({ imports(entries) { const map = new Map(entries); + observeImports(map, "./permits.js", 11); observeImports(map, "./commons.js", 0); }, liveVar: { @@ -11129,9 +11435,7 @@ function observeImports(map, importName, importIndex) { liveVar: { }, onceVar: { - minEnablements: cells[17].minEnablements.set, - moderateEnablements: cells[17].moderateEnablements.set, - severeEnablements: cells[17].severeEnablements.set, + default: cells[17].default.set, }, importMeta: {}, }); @@ -11139,12 +11443,13 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./enablements.js", 17); }, liveVar: { }, onceVar: { - default: cells[18].default.set, + minEnablements: cells[18].minEnablements.set, + moderateEnablements: cells[18].moderateEnablements.set, + severeEnablements: cells[18].severeEnablements.set, }, importMeta: {}, }); @@ -11152,7 +11457,7 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./error/assert.js", 8); + observeImports(map, "./enablements.js", 18); }, liveVar: { }, @@ -11164,24 +11469,24 @@ function observeImports(map, importName, importIndex) { functors[20]({ imports(entries) { const map = new Map(entries); + observeImports(map, "./commons.js", 0); + observeImports(map, "./error/assert.js", 9); }, liveVar: { }, onceVar: { - makeEvalFunction: cells[20].makeEvalFunction.set, + default: cells[20].default.set, }, importMeta: {}, }); functors[21]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./commons.js", 0); - observeImports(map, "./error/assert.js", 8); }, liveVar: { }, onceVar: { - makeFunctionConstructor: cells[21].makeFunctionConstructor.set, + makeEvalFunction: cells[21].makeEvalFunction.set, }, importMeta: {}, }); @@ -11189,17 +11494,12 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./make-eval-function.js", 20); - observeImports(map, "./make-function-constructor.js", 21); - observeImports(map, "./permits.js", 10); + observeImports(map, "./error/assert.js", 9); }, liveVar: { }, onceVar: { - setGlobalObjectSymbolUnscopables: cells[22].setGlobalObjectSymbolUnscopables.set, - setGlobalObjectConstantProperties: cells[22].setGlobalObjectConstantProperties.set, - setGlobalObjectMutableProperties: cells[22].setGlobalObjectMutableProperties.set, - setGlobalObjectEvaluators: cells[22].setGlobalObjectEvaluators.set, + makeFunctionConstructor: cells[22].makeFunctionConstructor.set, }, importMeta: {}, }); @@ -11207,14 +11507,17 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./error/assert.js", 8); + observeImports(map, "./make-eval-function.js", 21); + observeImports(map, "./make-function-constructor.js", 22); + observeImports(map, "./permits.js", 11); }, liveVar: { }, onceVar: { - alwaysThrowHandler: cells[23].alwaysThrowHandler.set, - strictScopeTerminatorHandler: cells[23].strictScopeTerminatorHandler.set, - strictScopeTerminator: cells[23].strictScopeTerminator.set, + setGlobalObjectSymbolUnscopables: cells[23].setGlobalObjectSymbolUnscopables.set, + setGlobalObjectConstantProperties: cells[23].setGlobalObjectConstantProperties.set, + setGlobalObjectMutableProperties: cells[23].setGlobalObjectMutableProperties.set, + setGlobalObjectEvaluators: cells[23].setGlobalObjectEvaluators.set, }, importMeta: {}, }); @@ -11222,12 +11525,14 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./strict-scope-terminator.js", 23); + observeImports(map, "./error/assert.js", 9); }, liveVar: { }, onceVar: { - createSloppyGlobalsScopeTerminator: cells[24].createSloppyGlobalsScopeTerminator.set, + alwaysThrowHandler: cells[24].alwaysThrowHandler.set, + strictScopeTerminatorHandler: cells[24].strictScopeTerminatorHandler.set, + strictScopeTerminator: cells[24].strictScopeTerminator.set, }, importMeta: {}, }); @@ -11235,12 +11540,12 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./error/assert.js", 8); + observeImports(map, "./strict-scope-terminator.js", 24); }, liveVar: { }, onceVar: { - makeEvalScopeKit: cells[25].makeEvalScopeKit.set, + createSloppyGlobalsScopeTerminator: cells[25].createSloppyGlobalsScopeTerminator.set, }, importMeta: {}, }); @@ -11248,11 +11553,12 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); + observeImports(map, "./error/assert.js", 9); }, liveVar: { }, onceVar: { - getSourceURL: cells[26].getSourceURL.set, + makeEvalScopeKit: cells[26].makeEvalScopeKit.set, }, importMeta: {}, }); @@ -11260,19 +11566,11 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./get-source-url.js", 26); }, liveVar: { }, onceVar: { - rejectHtmlComments: cells[27].rejectHtmlComments.set, - evadeHtmlCommentTest: cells[27].evadeHtmlCommentTest.set, - rejectImportExpressions: cells[27].rejectImportExpressions.set, - evadeImportExpressionTest: cells[27].evadeImportExpressionTest.set, - rejectSomeDirectEvalExpressions: cells[27].rejectSomeDirectEvalExpressions.set, - mandatoryTransforms: cells[27].mandatoryTransforms.set, - applyTransforms: cells[27].applyTransforms.set, - transforms: cells[27].transforms.set, + getSourceURL: cells[27].getSourceURL.set, }, importMeta: {}, }); @@ -11280,12 +11578,19 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); + observeImports(map, "./get-source-url.js", 27); }, liveVar: { }, onceVar: { - isValidIdentifierName: cells[28].isValidIdentifierName.set, - getScopeConstants: cells[28].getScopeConstants.set, + rejectHtmlComments: cells[28].rejectHtmlComments.set, + evadeHtmlCommentTest: cells[28].evadeHtmlCommentTest.set, + rejectImportExpressions: cells[28].rejectImportExpressions.set, + evadeImportExpressionTest: cells[28].evadeImportExpressionTest.set, + rejectSomeDirectEvalExpressions: cells[28].rejectSomeDirectEvalExpressions.set, + mandatoryTransforms: cells[28].mandatoryTransforms.set, + applyTransforms: cells[28].applyTransforms.set, + transforms: cells[28].transforms.set, }, importMeta: {}, }); @@ -11293,12 +11598,12 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./scope-constants.js", 28); }, liveVar: { }, onceVar: { - makeEvaluate: cells[29].makeEvaluate.set, + isValidIdentifierName: cells[29].isValidIdentifierName.set, + getScopeConstants: cells[29].getScopeConstants.set, }, importMeta: {}, }); @@ -11306,17 +11611,12 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./strict-scope-terminator.js", 23); - observeImports(map, "./sloppy-globals-scope-terminator.js", 24); - observeImports(map, "./eval-scope.js", 25); - observeImports(map, "./transforms.js", 27); - observeImports(map, "./make-evaluate.js", 29); - observeImports(map, "./error/assert.js", 8); + observeImports(map, "./scope-constants.js", 29); }, liveVar: { }, onceVar: { - makeSafeEvaluator: cells[30].makeSafeEvaluator.set, + makeEvaluate: cells[30].makeEvaluate.set, }, importMeta: {}, }); @@ -11324,11 +11624,17 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); + observeImports(map, "./strict-scope-terminator.js", 24); + observeImports(map, "./sloppy-globals-scope-terminator.js", 25); + observeImports(map, "./eval-scope.js", 26); + observeImports(map, "./transforms.js", 28); + observeImports(map, "./make-evaluate.js", 30); + observeImports(map, "./error/assert.js", 9); }, liveVar: { }, onceVar: { - tameFunctionToString: cells[31].tameFunctionToString.set, + makeSafeEvaluator: cells[31].makeSafeEvaluator.set, }, importMeta: {}, }); @@ -11340,24 +11646,19 @@ function observeImports(map, importName, importIndex) { liveVar: { }, onceVar: { - tameDomains: cells[32].tameDomains.set, + tameFunctionToString: cells[32].tameFunctionToString.set, }, importMeta: {}, }); functors[33]({ imports(entries) { const map = new Map(entries); - observeImports(map, "../commons.js", 0); - observeImports(map, "./types.js", 5); - observeImports(map, "./internal-types.js", 6); + observeImports(map, "./commons.js", 0); }, liveVar: { }, onceVar: { - makeLoggingConsoleKit: cells[33].makeLoggingConsoleKit.set, - makeCausalConsole: cells[33].makeCausalConsole.set, - filterConsole: cells[33].filterConsole.set, - consoleWhitelist: cells[33].consoleWhitelist.set, + tameDomains: cells[33].tameDomains.set, }, importMeta: {}, }); @@ -11365,11 +11666,19 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "../commons.js", 0); + observeImports(map, "./types.js", 5); + observeImports(map, "./internal-types.js", 6); }, liveVar: { }, onceVar: { - makeRejectionHandlers: cells[34].makeRejectionHandlers.set, + consoleLevelMethods: cells[34].consoleLevelMethods.set, + consoleOtherMethods: cells[34].consoleOtherMethods.set, + makeLoggingConsoleKit: cells[34].makeLoggingConsoleKit.set, + pumpLogToConsole: cells[34].pumpLogToConsole.set, + makeCausalConsole: cells[34].makeCausalConsole.set, + defineCausalConsoleFromLogger: cells[34].defineCausalConsoleFromLogger.set, + filterConsole: cells[34].filterConsole.set, }, importMeta: {}, }); @@ -11377,16 +11686,11 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "../commons.js", 0); - observeImports(map, "./assert.js", 8); - observeImports(map, "./console.js", 33); - observeImports(map, "./unhandled-rejection.js", 34); - observeImports(map, "./types.js", 5); - observeImports(map, "./internal-types.js", 6); }, liveVar: { }, onceVar: { - tameConsole: cells[35].tameConsole.set, + makeRejectionHandlers: cells[35].makeRejectionHandlers.set, }, importMeta: {}, }); @@ -11394,13 +11698,16 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "../commons.js", 0); + observeImports(map, "./assert.js", 9); + observeImports(map, "./console.js", 34); + observeImports(map, "./unhandled-rejection.js", 35); + observeImports(map, "./types.js", 5); + observeImports(map, "./internal-types.js", 6); }, liveVar: { }, onceVar: { - filterFileName: cells[36].filterFileName.set, - shortenCallSiteString: cells[36].shortenCallSiteString.set, - tameV8ErrorConstructor: cells[36].tameV8ErrorConstructor.set, + tameConsole: cells[36].tameConsole.set, }, importMeta: {}, }); @@ -11408,110 +11715,104 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "../commons.js", 0); - observeImports(map, "../permits.js", 10); - observeImports(map, "./tame-v8-error-constructor.js", 36); }, liveVar: { }, onceVar: { - default: cells[37].default.set, + filterFileName: cells[37].filterFileName.set, + shortenCallSiteString: cells[37].shortenCallSiteString.set, + tameV8ErrorConstructor: cells[37].tameV8ErrorConstructor.set, }, importMeta: {}, }); functors[38]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./commons.js", 0); - observeImports(map, "./error/assert.js", 8); + observeImports(map, "../commons.js", 0); + observeImports(map, "../permits.js", 11); + observeImports(map, "./tame-v8-error-constructor.js", 37); }, liveVar: { }, onceVar: { - makeAlias: cells[38].makeAlias.set, - load: cells[38].load.set, + default: cells[38].default.set, }, importMeta: {}, }); functors[39]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./module-load.js", 38); + observeImports(map, "@endo/env-options", 3); observeImports(map, "./commons.js", 0); - observeImports(map, "./error/assert.js", 8); + observeImports(map, "./error/assert.js", 9); }, liveVar: { }, onceVar: { - deferExports: cells[39].deferExports.set, - getDeferredExports: cells[39].getDeferredExports.set, + makeAlias: cells[39].makeAlias.set, + load: cells[39].load.set, + loadNow: cells[39].loadNow.set, }, importMeta: {}, }); functors[40]({ imports(entries) { const map = new Map(entries); + observeImports(map, "./module-load.js", 39); observeImports(map, "./commons.js", 0); - observeImports(map, "./transforms.js", 27); - observeImports(map, "./make-safe-evaluator.js", 30); + observeImports(map, "./error/assert.js", 9); }, liveVar: { }, onceVar: { - provideCompartmentEvaluator: cells[40].provideCompartmentEvaluator.set, - compartmentEvaluate: cells[40].compartmentEvaluate.set, + deferExports: cells[40].deferExports.set, + getDeferredExports: cells[40].getDeferredExports.set, }, importMeta: {}, }); functors[41]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./error/assert.js", 8); - observeImports(map, "./module-proxy.js", 39); observeImports(map, "./commons.js", 0); - observeImports(map, "./compartment-evaluate.js", 40); + observeImports(map, "./transforms.js", 28); + observeImports(map, "./make-safe-evaluator.js", 31); }, liveVar: { }, onceVar: { - makeThirdPartyModuleInstance: cells[41].makeThirdPartyModuleInstance.set, - makeModuleInstance: cells[41].makeModuleInstance.set, + provideCompartmentEvaluator: cells[41].provideCompartmentEvaluator.set, + compartmentEvaluate: cells[41].compartmentEvaluate.set, }, importMeta: {}, }); functors[42]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./error/assert.js", 8); - observeImports(map, "./module-instance.js", 41); + observeImports(map, "./error/assert.js", 9); + observeImports(map, "./module-proxy.js", 40); observeImports(map, "./commons.js", 0); + observeImports(map, "./compartment-evaluate.js", 41); }, liveVar: { }, onceVar: { - link: cells[42].link.set, - instantiate: cells[42].instantiate.set, + makeThirdPartyModuleInstance: cells[42].makeThirdPartyModuleInstance.set, + makeModuleInstance: cells[42].makeModuleInstance.set, }, importMeta: {}, }); functors[43]({ imports(entries) { const map = new Map(entries); + observeImports(map, "./error/assert.js", 9); + observeImports(map, "./module-instance.js", 42); observeImports(map, "./commons.js", 0); - observeImports(map, "./global-object.js", 22); - observeImports(map, "./permits.js", 10); - observeImports(map, "./module-load.js", 38); - observeImports(map, "./module-link.js", 42); - observeImports(map, "./module-proxy.js", 39); - observeImports(map, "./error/assert.js", 8); - observeImports(map, "./compartment-evaluate.js", 40); - observeImports(map, "./make-safe-evaluator.js", 30); }, liveVar: { }, onceVar: { - InertCompartment: cells[43].InertCompartment.set, - CompartmentPrototype: cells[43].CompartmentPrototype.set, - makeCompartmentConstructor: cells[43].makeCompartmentConstructor.set, + link: cells[43].link.set, + instantiate: cells[43].instantiate.set, }, importMeta: {}, }); @@ -11519,12 +11820,21 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./compartment.js", 43); + observeImports(map, "./global-object.js", 23); + observeImports(map, "./permits.js", 11); + observeImports(map, "./module-load.js", 39); + observeImports(map, "./module-link.js", 43); + observeImports(map, "./module-proxy.js", 40); + observeImports(map, "./error/assert.js", 9); + observeImports(map, "./compartment-evaluate.js", 41); + observeImports(map, "./make-safe-evaluator.js", 31); }, liveVar: { }, onceVar: { - getAnonymousIntrinsics: cells[44].getAnonymousIntrinsics.set, + InertCompartment: cells[44].InertCompartment.set, + CompartmentPrototype: cells[44].CompartmentPrototype.set, + makeCompartmentConstructor: cells[44].makeCompartmentConstructor.set, }, importMeta: {}, }); @@ -11532,11 +11842,12 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); + observeImports(map, "./compartment.js", 44); }, liveVar: { }, onceVar: { - tameHarden: cells[45].tameHarden.set, + getAnonymousIntrinsics: cells[45].getAnonymousIntrinsics.set, }, importMeta: {}, }); @@ -11548,7 +11859,7 @@ function observeImports(map, importName, importIndex) { liveVar: { }, onceVar: { - tameSymbolConstructor: cells[46].tameSymbolConstructor.set, + tameHarden: cells[46].tameHarden.set, }, importMeta: {}, }); @@ -11560,66 +11871,64 @@ function observeImports(map, importName, importIndex) { liveVar: { }, onceVar: { - tameFauxDataProperty: cells[47].tameFauxDataProperty.set, - tameFauxDataProperties: cells[47].tameFauxDataProperties.set, + tameSymbolConstructor: cells[47].tameSymbolConstructor.set, }, importMeta: {}, }); functors[48]({ imports(entries) { const map = new Map(entries); - observeImports(map, "@endo/env-options", 3); observeImports(map, "./commons.js", 0); - observeImports(map, "./make-hardener.js", 9); - observeImports(map, "./intrinsics.js", 11); - observeImports(map, "./permits-intrinsics.js", 12); - observeImports(map, "./tame-function-constructors.js", 13); - observeImports(map, "./tame-date-constructor.js", 14); - observeImports(map, "./tame-math-object.js", 15); - observeImports(map, "./tame-regexp-constructor.js", 16); - observeImports(map, "./enable-property-overrides.js", 18); - observeImports(map, "./tame-locale-methods.js", 19); - observeImports(map, "./global-object.js", 22); - observeImports(map, "./make-safe-evaluator.js", 30); - observeImports(map, "./permits.js", 10); - observeImports(map, "./tame-function-tostring.js", 31); - observeImports(map, "./tame-domains.js", 32); - observeImports(map, "./error/tame-console.js", 35); - observeImports(map, "./error/tame-error-constructor.js", 37); - observeImports(map, "./error/assert.js", 8); - observeImports(map, "./get-anonymous-intrinsics.js", 44); - observeImports(map, "./compartment.js", 43); - observeImports(map, "./tame-harden.js", 45); - observeImports(map, "./tame-symbol-constructor.js", 46); - observeImports(map, "./tame-faux-data-properties.js", 47); }, liveVar: { }, onceVar: { - repairIntrinsics: cells[48].repairIntrinsics.set, + tameFauxDataProperty: cells[48].tameFauxDataProperty.set, + tameFauxDataProperties: cells[48].tameFauxDataProperties.set, }, importMeta: {}, }); functors[49]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./assert-sloppy-mode.js", 1); + observeImports(map, "@endo/env-options", 3); observeImports(map, "./commons.js", 0); - observeImports(map, "./lockdown.js", 48); + observeImports(map, "./make-hardener.js", 10); + observeImports(map, "./intrinsics.js", 12); + observeImports(map, "./permits-intrinsics.js", 13); + observeImports(map, "./tame-function-constructors.js", 14); + observeImports(map, "./tame-date-constructor.js", 15); + observeImports(map, "./tame-math-object.js", 16); + observeImports(map, "./tame-regexp-constructor.js", 17); + observeImports(map, "./enable-property-overrides.js", 19); + observeImports(map, "./tame-locale-methods.js", 20); + observeImports(map, "./global-object.js", 23); + observeImports(map, "./make-safe-evaluator.js", 31); + observeImports(map, "./permits.js", 11); + observeImports(map, "./tame-function-tostring.js", 32); + observeImports(map, "./tame-domains.js", 33); + observeImports(map, "./error/tame-console.js", 36); + observeImports(map, "./error/tame-error-constructor.js", 38); + observeImports(map, "./error/assert.js", 9); + observeImports(map, "./get-anonymous-intrinsics.js", 45); + observeImports(map, "./compartment.js", 44); + observeImports(map, "./tame-harden.js", 46); + observeImports(map, "./tame-symbol-constructor.js", 47); + observeImports(map, "./tame-faux-data-properties.js", 48); }, liveVar: { }, onceVar: { + repairIntrinsics: cells[49].repairIntrinsics.set, }, importMeta: {}, }); functors[50]({ imports(entries) { const map = new Map(entries); + observeImports(map, "./assert-sloppy-mode.js", 1); observeImports(map, "./commons.js", 0); - observeImports(map, "./compartment.js", 43); - observeImports(map, "./tame-function-tostring.js", 31); - observeImports(map, "./intrinsics.js", 11); + observeImports(map, "./lockdown.js", 49); }, liveVar: { }, @@ -11631,7 +11940,9 @@ function observeImports(map, importName, importIndex) { imports(entries) { const map = new Map(entries); observeImports(map, "./commons.js", 0); - observeImports(map, "./error/assert.js", 8); + observeImports(map, "./compartment.js", 44); + observeImports(map, "./tame-function-tostring.js", 32); + observeImports(map, "./intrinsics.js", 12); }, liveVar: { }, @@ -11642,9 +11953,35 @@ function observeImports(map, importName, importIndex) { functors[52]({ imports(entries) { const map = new Map(entries); - observeImports(map, "./src/lockdown-shim.js", 49); - observeImports(map, "./src/compartment-shim.js", 50); - observeImports(map, "./src/assert-shim.js", 51); + observeImports(map, "./commons.js", 0); + observeImports(map, "./error/assert.js", 9); + }, + liveVar: { + }, + onceVar: { + }, + importMeta: {}, + }); + functors[53]({ + imports(entries) { + const map = new Map(entries); + observeImports(map, "./commons.js", 0); + observeImports(map, "./error/console.js", 34); + observeImports(map, "./error/assert.js", 9); + }, + liveVar: { + }, + onceVar: { + }, + importMeta: {}, + }); + functors[54]({ + imports(entries) { + const map = new Map(entries); + observeImports(map, "./src/lockdown-shim.js", 50); + observeImports(map, "./src/compartment-shim.js", 51); + observeImports(map, "./src/assert-shim.js", 52); + observeImports(map, "./src/console-shim.js", 53); }, liveVar: { },