@locker/near-membrane-base
Advanced tools
Comparing version 0.5.1 to 0.6.0
231
lib/index.js
@@ -1,5 +0,7 @@ | ||
const { __lookupGetter__: ObjectProto__lookupGetter__, hasOwnProperty: ObjectProtoHasOwnProperty, } = Object.prototype; | ||
const { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
__lookupGetter__: ObjectProto__lookupGetter__, hasOwnProperty: ObjectProtoHasOwnProperty, } = Object.prototype; | ||
const { test: RegExpProtoTest } = RegExp.prototype; | ||
const { has: SetProtoHas } = Set.prototype; | ||
const { get: WeakMapProtoGet, has: WeakMapProtoHas, set: WeakMapProtoSet, } = WeakMap.prototype; | ||
const { get: WeakMapProtoGet, has: WeakMapProtoHas, set: WeakMapProtoSet } = WeakMap.prototype; | ||
const ArrayCtor = Array; | ||
@@ -41,5 +43,5 @@ const ErrorCtor = Error; | ||
// istanbul ignore next | ||
const serializedRedEnvSourceText = (function redEnvFactory(blueEnv, hooks) { | ||
const serializedRedEnvSourceText = /* prettier-ignore */ (function redEnvFactory(blueEnv, hooks) { | ||
const LockerLiveValueMarkerSymbol = Symbol.for('@@lockerLiveValue'); | ||
const { blueMap, distortionMap } = blueEnv; | ||
const { blueMap, distortionCallback } = blueEnv; | ||
const { apply: blueApplyHook, construct: blueConstructHook } = hooks; | ||
@@ -53,8 +55,12 @@ const ArrayCtor = Array; | ||
const { assign: ObjectAssign, create: ObjectCreate, defineProperties: ObjectDefineProperties, getOwnPropertyDescriptors: ObjectGetOwnPropertyDescriptors, freeze: ObjectFreeze, seal: ObjectSeal, isSealed: ObjectIsSealed, isFrozen: ObjectIsFrozen, } = Object; | ||
const { __lookupGetter__: ObjectProto__lookupGetter__, __lookupSetter__: ObjectProto__lookupSetter__, hasOwnProperty: ObjectProtoHasOwnProperty, } = Object.prototype; | ||
const { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
__lookupGetter__: ObjectProto__lookupGetter__, | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
__lookupSetter__: ObjectProto__lookupSetter__, hasOwnProperty: ObjectProtoHasOwnProperty, } = Object.prototype; | ||
const { revocable: ProxyRevocable } = Proxy; | ||
const { apply: ReflectApply, isExtensible: ReflectIsExtensible, getOwnPropertyDescriptor: ReflectGetOwnPropertyDescriptor, setPrototypeOf: ReflectSetPrototypeOf, getPrototypeOf: ReflectGetPrototypeOf, preventExtensions: ReflectPreventExtensions, deleteProperty: ReflectDeleteProperty, ownKeys: ReflectOwnKeys, defineProperty: ReflectDefineProperty, get: ReflectGet, set: ReflectSet, has: ReflectHas, } = Reflect; | ||
const { get: WeakMapProtoGet, has: WeakMapProtoHas, } = WeakMap.prototype; | ||
const { get: WeakMapProtoGet } = WeakMap.prototype; | ||
function ObjectHasOwnProperty(obj, key) { | ||
return obj !== null && obj !== undefined && ReflectApply(ObjectProtoHasOwnProperty, obj, [key]); | ||
return (obj !== null && obj !== undefined && ReflectApply(ObjectProtoHasOwnProperty, obj, [key])); | ||
} | ||
@@ -74,5 +80,2 @@ function ObjectLookupGetter(obj, key) { | ||
} | ||
function WeakMapHas(map, key) { | ||
return ReflectApply(WeakMapProtoHas, map, [key]); | ||
} | ||
function copyBlueDescriptorIntoShadowTarget(shadowTarget, normalizedBlueDescriptor, key) { | ||
@@ -107,3 +110,4 @@ // Note: a property might get defined multiple times in the shadowTarget | ||
if (ObjectHasOwnProperty(blueDescriptors, key)) { | ||
// @ts-ignore PropertyDescriptorMap def defines properties as being only of string type | ||
// @ts-ignore PropertyDescriptorMap def defines properties | ||
// as being only of string type | ||
const originalDescriptor = getRedDescriptor(blueDescriptors[key]); | ||
@@ -133,7 +137,14 @@ installDescriptorIntoShadowTarget(shadowTarget, key, originalDescriptor); | ||
function getDistortedValue(target) { | ||
if (!WeakMapHas(distortionMap, target)) { | ||
return target; | ||
let distortedTarget; | ||
try { | ||
distortedTarget = distortionCallback(target); | ||
} | ||
// if a distortion entry is found, it must be a valid proxy target | ||
return WeakMapGet(distortionMap, target); | ||
finally { | ||
// if a distortion entry is found, it must be a valid proxy target | ||
if (distortedTarget !== target && typeof distortedTarget !== typeof target) { | ||
// eslint-disable-next-line no-unsafe-finally | ||
throw new ErrorCtor(`Invalid distortion ${target}.`); | ||
} | ||
} | ||
return distortedTarget; | ||
} | ||
@@ -204,5 +215,7 @@ function getRedDescriptor(blueDescriptor) { | ||
if (ObjectIsFrozen(target)) { | ||
// eslint-disable-next-line no-multi-assign | ||
meta.isFrozen = meta.isSealed = meta.isExtensible = true; | ||
} | ||
else if (ObjectIsSealed(target)) { | ||
// eslint-disable-next-line no-multi-assign | ||
meta.isSealed = meta.isExtensible = true; | ||
@@ -218,7 +231,8 @@ } | ||
catch (_ignored) { | ||
// intentionally swallowing the error because this method is just extracting the metadata | ||
// in a way that it should always succeed except for the cases in which the target is a proxy | ||
// that is either revoked or has some logic that is incompatible with the membrane, in which | ||
// case we will just create the proxy for the membrane but revoke it right after to prevent | ||
// any leakage. | ||
// intentionally swallowing the error because this method is just | ||
// extracting the metadata in a way that it should always succeed | ||
// except for the cases in which the target is a proxy that is | ||
// either revoked or has some logic that is incompatible with the | ||
// membrane, in which case we will just create the proxy for the | ||
// membrane but revoke it right after to prevent any leakage. | ||
meta.proto = null; | ||
@@ -273,5 +287,6 @@ meta.descriptors = {}; | ||
catch (_a) { | ||
// intentionally swallowing the error because this method is just extracting the function | ||
// in a way that it should always succeed except for the cases in which the provider is a proxy | ||
// that is either revoked or has some logic to prevent reading the name property descriptor. | ||
// intentionally swallowing the error because this method is just extracting the | ||
// function in a way that it should always succeed except for the cases in which | ||
// the provider is a proxy that is either revoked or has some logic to prevent | ||
// reading the name property descriptor. | ||
} | ||
@@ -325,9 +340,11 @@ } | ||
/** | ||
* If the target has a non-configurable own data descriptor that was observed by the red side, | ||
* and therefore installed in the shadowTarget, we might get into a situation where a writable, | ||
* non-configurable value in the target is out of sync with the shadowTarget's value for the same | ||
* key. This is fine because this does not violate the object invariants, and even though they | ||
* are out of sync, the original descriptor can only change to something that is compatible with | ||
* what was installed in shadowTarget, and in order to observe that, the getOwnPropertyDescriptor | ||
* trap must be used, which will take care of synchronizing them again. | ||
* If the target has a non-configurable own data descriptor that was observed | ||
* by the red side, and therefore installed in the shadowTarget, we might get | ||
* into a situation where a writable, non-configurable value in the target is | ||
* out of sync with the shadowTarget's value for the same key. This is fine | ||
* because this does not violate the object invariants, and even though they | ||
* are out of sync, the original descriptor can only change to something that | ||
* is compatible with what was installed in shadowTarget, and in order to | ||
* observe that, the getOwnPropertyDescriptor trap must be used, which will | ||
* take care of synchronizing them again. | ||
*/ | ||
@@ -362,3 +379,5 @@ const { target } = this; | ||
*/ | ||
function redProxyDynamicHasTrap(shadowTarget, key) { | ||
function redProxyDynamicHasTrap( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
shadowTarget, key) { | ||
const { target } = this; | ||
@@ -376,6 +395,10 @@ if (ObjectHasOwnProperty(target, key)) { | ||
} | ||
function redProxyDynamicOwnKeysTrap(shadowTarget) { | ||
function redProxyDynamicOwnKeysTrap( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
shadowTarget) { | ||
return ReflectOwnKeys(this.target); | ||
} | ||
function redProxyDynamicIsExtensibleTrap(shadowTarget) { | ||
function redProxyDynamicIsExtensibleTrap( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
shadowTarget) { | ||
// optimization to avoid attempting to lock down the shadowTarget multiple times | ||
@@ -404,7 +427,11 @@ if (!ReflectIsExtensible(shadowTarget)) { | ||
} | ||
function redProxyDynamicGetPrototypeOfTrap(shadowTarget) { | ||
function redProxyDynamicGetPrototypeOfTrap( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
shadowTarget) { | ||
return getRedValue(ReflectGetPrototypeOf(this.target)); | ||
} | ||
// writing traps | ||
function redProxyDynamicSetPrototypeOfTrap(shadowTarget, prototype) { | ||
function redProxyDynamicSetPrototypeOfTrap( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
shadowTarget, prototype) { | ||
return ReflectSetPrototypeOf(this.target, blueEnv.getBlueValue(prototype)); | ||
@@ -428,7 +455,9 @@ } | ||
if (blueSetter) { | ||
// even though the setter function exists, we can't use Reflect.set because there might be | ||
// a distortion for that setter function, in which case we must resolve the red setter | ||
// and call it instead. | ||
// even though the setter function exists, we can't use Reflect.set because | ||
// there might be a distortion for that setter function, in which case we | ||
// must resolve the red setter and call it instead. | ||
ReflectApply(getRedValue(blueSetter), receiver, [value]); | ||
return true; // if there is a callable setter, it either throw or we can assume the value was set | ||
// if there is a callable setter, it either throw or we can assume the | ||
// value was set | ||
return true; | ||
} | ||
@@ -492,3 +521,5 @@ // if it is not an accessor property, is either a getter only accessor | ||
} | ||
function makeRedProxyDynamic(proxyHandler, shadowTarget) { | ||
function makeRedProxyDynamic(proxyHandler, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
shadowTarget) { | ||
// replacing pending traps with dynamic traps that can work with the target | ||
@@ -591,2 +622,3 @@ // without taking snapshots. | ||
try { | ||
// eslint-disable-next-line func-names | ||
shadowTarget = 'prototype' in blue ? function () { } : () => { }; | ||
@@ -598,2 +630,3 @@ } | ||
// appropriate. | ||
// eslint-disable-next-line func-names | ||
shadowTarget = function () { }; | ||
@@ -648,4 +681,3 @@ } | ||
return getRedValue; | ||
}) | ||
.toString() | ||
}).toString() | ||
// We cannot have 'use strict' directly in `redEnvFactory()` because bundlers and | ||
@@ -656,2 +688,3 @@ // minifiers may strip the directive. So, we inject 'use strict' after the function | ||
/* eslint-disable @typescript-eslint/no-use-before-define */ | ||
function renameFunction(provider, receiver) { | ||
@@ -664,5 +697,6 @@ try { | ||
catch (_a) { | ||
// intentionally swallowing the error because this method is just extracting the function | ||
// in a way that it should always succeed except for the cases in which the provider is a proxy | ||
// that is either revoked or has some logic to prevent reading the name property descriptor. | ||
// intentionally swallowing the error because this method is just extracting the | ||
// function in a way that it should always succeed except for the cases in which | ||
// the provider is a proxy that is either revoked or has some logic to prevent | ||
// reading the name property descriptor. | ||
} | ||
@@ -677,2 +711,3 @@ } | ||
try { | ||
// eslint-disable-next-line func-names | ||
shadowTarget = 'prototype' in target ? function () { } : () => { }; | ||
@@ -682,2 +717,3 @@ } | ||
// target is a revoked proxy | ||
// eslint-disable-next-line func-names | ||
shadowTarget = function () { }; | ||
@@ -738,5 +774,7 @@ } | ||
const { value } = blueDescriptor; | ||
blueDescriptor.value = typeof value === 'function' ? | ||
// We are dealing with a method (optimization). | ||
getBlueFunction(value) : getBlueValue(value); | ||
blueDescriptor.value = | ||
typeof value === 'function' | ||
? // We are dealing with a method (optimization). | ||
getBlueFunction(value) | ||
: getBlueValue(value); | ||
} | ||
@@ -769,3 +807,3 @@ else { | ||
} | ||
else if (typeof red === 'object') { | ||
if (typeof red === 'object') { | ||
// arrays and objects | ||
@@ -872,9 +910,11 @@ const blue = env.getBlueRef(red); | ||
/** | ||
* If the target has a non-configurable own data descriptor that was observed by the red side, | ||
* and therefore installed in the shadowTarget, we might get into a situation where a writable, | ||
* non-configurable value in the target is out of sync with the shadowTarget's value for the same | ||
* key. This is fine because this does not violate the object invariants, and even though they | ||
* are out of sync, the original descriptor can only change to something that is compatible with | ||
* what was installed in shadowTarget, and in order to observe that, the getOwnPropertyDescriptor | ||
* trap must be used, which will take care of synchronizing them again. | ||
* If the target has a non-configurable own data descriptor that was observed by the | ||
* red side, and therefore installed in the shadowTarget, we might get into a | ||
* situation where a writable, non-configurable value in the target is out of sync | ||
* with the shadowTarget's value for the same key. This is fine because this does | ||
* not violate the object invariants, and even though they are out of sync, the | ||
* original descriptor can only change to something that is compatible with what | ||
* was installed in shadowTarget, and in order to observe that, the | ||
* getOwnPropertyDescriptor trap must be used, which will take care of synchronizing | ||
* them again. | ||
*/ | ||
@@ -913,2 +953,3 @@ const { target } = this; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
getPrototypeOf(shadowTarget) { | ||
@@ -945,3 +986,5 @@ return env.getBlueValue(ReflectGetPrototypeOf(this.target)); | ||
} | ||
ownKeys(shadowTarget) { | ||
ownKeys( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
shadowTarget) { | ||
return ReflectOwnKeys(this.target); | ||
@@ -983,7 +1026,8 @@ } | ||
else if (ObjectHasOwnProperty(redDescriptor, 'set')) { | ||
// even though the setter function exists, we can't use Reflect.set because there might be | ||
// a distortion for that setter function, and from the blue side, we should not be subject | ||
// to those distortions. | ||
// even though the setter function exists, we can't use Reflect.set because there | ||
// might be a distortion for that setter function, and from the blue side, we | ||
// should not be subject to those distortions. | ||
ReflectApply(getBlueValue(redDescriptor.set), receiver, [value]); | ||
return true; // if there is a callable setter, it either throw or we can assume the value was set | ||
// if there is a callable setter, it either throw or we can assume the value was set | ||
return true; | ||
} | ||
@@ -1005,3 +1049,5 @@ // if it is not an accessor property, is either a getter only accessor | ||
/* eslint-disable @typescript-eslint/no-use-before-define */ | ||
const frameGlobalNamesRegExp = /^\d+$/; | ||
const distortionDefaultCallback = (v) => v; | ||
class VirtualEnvironment { | ||
@@ -1016,11 +1062,4 @@ constructor(options) { | ||
} | ||
const { redGlobalThis, distortionMap } = options; | ||
this.distortionMap = new WeakMapCtor(); | ||
// validating distortion entries | ||
distortionMap === null || distortionMap === void 0 ? void 0 : distortionMap.forEach((value, key) => { | ||
if (typeof key !== typeof value) { | ||
throw new ErrorCtor(`Invalid distortion ${value}.`); | ||
} | ||
WeakMapSet(this.distortionMap, key, value); | ||
}); | ||
const { redGlobalThis, distortionCallback } = options; | ||
this.distortionCallback = distortionCallback || distortionDefaultCallback; | ||
// getting proxy factories ready per environment so we can produce | ||
@@ -1045,9 +1084,18 @@ // the proper errors without leaking instances into a sandbox | ||
} | ||
getBlueValue(red) { | ||
// eslint-disable-next-line class-methods-use-this | ||
getBlueValue( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
red) { | ||
// placeholder since this will be assigned in construction | ||
} | ||
getRedValue(blue) { | ||
// eslint-disable-next-line class-methods-use-this | ||
getRedValue( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
blue) { | ||
// placeholder since this will be assigned in construction | ||
} | ||
getBlueRef(red) { | ||
// eslint-disable-next-line class-methods-use-this | ||
getBlueRef( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
red) { | ||
const blue = WeakMapGet(this.redMap, red); | ||
@@ -1057,3 +1105,6 @@ if (blue !== undefined) { | ||
} | ||
// Explicit to satisfy the consistent-return elint rule | ||
return undefined; | ||
} | ||
// eslint-disable-next-line class-methods-use-this | ||
getRedRef(blue) { | ||
@@ -1064,2 +1115,4 @@ const red = WeakMapGet(this.blueMap, blue); | ||
} | ||
// Explicit to satisfy the consistent-return elint rule | ||
return undefined; | ||
} | ||
@@ -1079,6 +1132,9 @@ setRefMapEntries(red, blue) { | ||
if (typeof key !== 'symbol' && RegExpTest(frameGlobalNamesRegExp, key)) { | ||
// eslint-disable-next-line no-continue | ||
continue; | ||
} | ||
if (!canRedPropertyBeTamed(redValue, key)) { | ||
// eslint-disable-next-line no-console | ||
console.warn(`Property ${String(key)} of ${redValue} cannot be remapped.`); | ||
// eslint-disable-next-line no-continue | ||
continue; | ||
@@ -1103,8 +1159,15 @@ } | ||
const { get: blueGetter } = blueDescriptor; | ||
const blueDistortedGetter = WeakMapGet(this.distortionMap, blueGetter) || blueGetter; | ||
currentBlueGetter = function () { | ||
// Note: The reason why we don't use broker.getRedValue here is because we | ||
// want that proxy to be lazy. This brings other questions: what about error | ||
// control? Do we have test for this? Can we optimize this so after the | ||
// first call we don't pay the cost of wrapping anymore? | ||
// | ||
// TODO: Isn't it easier to just not do any lazy stuff anymore considering | ||
// that the creation of those proxies is now faster? | ||
const blueDistortedGetter = this.distortionCallback(blueGetter); | ||
currentBlueGetter = function currentDistortedBlueGetter() { | ||
const value = ReflectApply(blueDistortedGetter, broker.getBlueValue(this), emptyArray); | ||
return broker.getRedValue(value); | ||
}; | ||
redDescriptor.get = function () { | ||
redDescriptor.get = function get() { | ||
return ReflectApply(currentBlueGetter, this, emptyArray); | ||
@@ -1114,4 +1177,5 @@ }; | ||
if (typeof blueDescriptor.set === 'function') { | ||
redDescriptor.set = function (v) { | ||
// if a global setter is invoke, the value will be use as it is as the result of the getter operation | ||
redDescriptor.set = function set(v) { | ||
// if a global setter is invoke, the value will be use as it | ||
// is as the result of the getter operation | ||
currentBlueGetter = () => v; | ||
@@ -1173,2 +1237,5 @@ }; | ||
'ArrayBuffer', | ||
'BigInt', | ||
'BigInt64Array', | ||
'BigUint64Array', | ||
'Boolean', | ||
@@ -1179,2 +1246,3 @@ 'DataView', | ||
'EvalError', | ||
'FinalizationRegistry', | ||
'Float32Array', | ||
@@ -1209,2 +1277,3 @@ 'Float64Array', | ||
// 'WeakSet', // Remapped | ||
'WeakRef', | ||
// *** 18.4 Other Properties of the Global Object | ||
@@ -1269,5 +1338,5 @@ 'Atomics', | ||
const globalKeys = ReflectOwnKeys(endowments); | ||
for (let i = 0, len = globalKeys.length; i < len; i++) { | ||
// forcing to string here because of TypeScript's PropertyDescriptorMap definition, which doesn't | ||
// support symbols as entries. | ||
for (let i = 0, len = globalKeys.length; i < len; i += 1) { | ||
// forcing to string here because of TypeScript's PropertyDescriptorMap | ||
// definition, which doesn't support symbols as entries. | ||
const key = globalKeys[i]; | ||
@@ -1274,0 +1343,0 @@ // avoid overriding ECMAScript global names that correspond |
@@ -1,2 +0,2 @@ | ||
const{__lookupGetter__:t,hasOwnProperty:e}=Object.prototype,{test:n}=RegExp.prototype,{has:r}=Set.prototype,{get:o,has:i,set:s}=WeakMap.prototype,u=Array,c=Error,l=Set,a=TypeError,f=WeakMap,{isArray:p}=Array,{assign:y,create:g,defineProperties:h,defineProperty:d,freeze:v,getOwnPropertyDescriptors:E}=Object,{revocable:w}=Proxy,{apply:P,construct:b,getPrototypeOf:R,setPrototypeOf:V,defineProperty:O,isExtensible:x,getOwnPropertyDescriptor:B,ownKeys:A,preventExtensions:M,deleteProperty:S,has:m,get:k,set:I}=Reflect;function _(t,n){return null!=t&&P(e,t,[n])}function F(n,r){if(null!=n&&P(e,n,[r]))return P(t,n,[r])}function U(t,e){return P(n,t,[e])}function j(t,e){return P(r,t,[e])}function D(t,e){return P(o,t,[e])}function z(t,e){return P(i,t,[e])}function N(t,e,n){return P(s,t,[e,n])}const K=[],T=function(t,e){const n=Symbol.for("@@lockerLiveValue"),{blueMap:r,distortionMap:o}=t,{apply:i,construct:s}=e,u=Array,c=Error,l=TypeError,a=[],f=()=>{},{isArray:p}=Array,{assign:y,create:g,defineProperties:h,getOwnPropertyDescriptors:d,freeze:v,seal:E,isSealed:w,isFrozen:P}=Object,{__lookupGetter__:b,__lookupSetter__:R,hasOwnProperty:V}=Object.prototype,{revocable:O}=Proxy,{apply:x,isExtensible:B,getOwnPropertyDescriptor:A,setPrototypeOf:M,getPrototypeOf:S,preventExtensions:m,deleteProperty:k,ownKeys:I,defineProperty:_,get:F,set:U,has:j}=Reflect,{get:D,has:z}=WeakMap.prototype;function N(t,e){return null!=t&&x(V,t,[e])}function K(t,e){return x(D,t,[e])}function T(t,e,n){if(void 0!==e){const r=C(e);_(t,n,r)}}function $(t){return x(z,o,[t])?K(o,t):t}function C(t){const e=y(g(null),t);if("writable"in e)e.value=G(e.value);else{const{get:t,set:n}=e;"function"==typeof t&&(e.get=G(t)),"function"==typeof n&&(e.set=G(n))}return e}function G(e){if(null===e)return e;if(void 0!==e){if("object"==typeof e||"function"==typeof e){const n=$(e),o=K(r,n);return void 0!==o?o:function(e){const n=function(t){let e;if("function"==typeof t){try{e="prototype"in t?function(){}:()=>{}}catch(t){e=function(){}}!function(t,e){try{const n=A(t,"name");_(e,"name",n)}catch(t){}}(t,e)}else{let n=!1;try{n=p(t)}catch(t){}e=n?[]:{}}return e}(e),r=new gt(e),{proxy:o,revoke:i}=O(n,r);r.revoke=i;try{t.setRefMapEntries(o,e)}catch(t){throw new c("Internal Error")}try{p(e)}catch(t){i()}return o}(n)}return e}}function W(e){const{length:n}=e,r=new u(n);for(let o=0;o<n;o+=1)o in e&&(r[o]=t.getBlueValue(e[o]));return r}function J(t,e,n){const r=A(t,e);void 0!==r?N(r,"configurable")&&!0===r.configurable?_(t,e,n):N(r,"writable")&&!0===r.writable&&(t[e]=n.value):_(t,e,n)}function L(t,e){!function(t,e){const n=d(e),r=I(n),o=g(null);for(let t=0,e=r.length;t<e;t+=1){const e=r[t],i=C(n[e]);o[e]=i}h(t,o)}(t,e),M(t,G(S(e))),m(t)}function q(e,n,r){const{target:o}=this;let s;try{const e=t.getBlueValue(n),u=W(r);s=i(o,e,u)}catch(t){throw G(t)}return G(s)}function H(e,n,r){const{target:o}=this;if(void 0===r)throw new l;let i;try{const e=t.getBlueValue(r),u=W(n);i=s(o,u,e)}catch(t){throw G(t)}return G(i)}function Q(t,e,n){const{target:r}=this;if(!N(r,e)){const t=S(r);if(null===t)return;const o=G(t);return F(o,e,n)}const o=function(t,e){return null==t?void 0:x(b,t,[e])}(r,e);return o?x(G(o),n,a):G(r[e])}function X(t,e){const{target:n}=this;if(N(n,e))return!0;const r=S(n);if(null===r)return!1;const o=G(r);return j(o,e)}function Y(t){return I(this.target)}function Z(t){if(!B(t))return!1;const{target:e}=this;return!!B(e)||(L(t,e),!1)}function tt(t,e){const{target:n}=this,r=A(n,e);return void 0===r?r:(!1===r.configurable&&T(t,r,e),C(r))}function et(t){return G(S(this.target))}function nt(e,n){return M(this.target,t.getBlueValue(n))}function rt(e,n,r,o){const{target:i}=this;if(!N(i,n)){const t=G(S(i));return null!==t&&U(t,n,r,o)}const s=function(t,e){return null==t?x(R,t,[e]):void 0}(i,n);return s?(x(G(s),o,[r]),!0):U(i,n,t.getBlueValue(r))}function ot(t,e){return k(this.target,e)}function it(t){const{target:e}=this;if(B(t)){if(!m(e))return B(e)||L(t,e),!1;L(t,e)}return!0}function st(e,n,r){const{target:o}=this,i=function(e){const n=y(g(null),e);if("writable"in n)n.value=t.getBlueValue(n.value);else{const{get:e,set:r}=n;"function"==typeof e&&(n.get=t.getBlueValue(e)),"function"==typeof r&&(n.set=t.getBlueValue(r))}return n}(r);if(_(o,n,i)&&!1===i.configurable){T(e,A(o,n),n)}return!0}function ut(t,e){return yt(this,t),this.setPrototypeOf(t,e)}function ct(t,e,n,r){return yt(this,t),this.set(t,e,n,r)}function lt(t,e){return yt(this,t),this.deleteProperty(t,e)}function at(t){return yt(this,t),this.preventExtensions(t)}function ft(t,e,n){return yt(this,t),this.defineProperty(t,e,n)}function pt(t,e){const n=function(t){const e=g(null);e.isBroken=!1,e.isExtensible=!1,e.isFrozen=!1,e.isSealed=!1,e.proto=null;try{e.proto=S(t),e.descriptors=d(t),P(t)?e.isFrozen=e.isSealed=e.isExtensible=!0:w(t)?e.isSealed=e.isExtensible=!0:B(t)&&(e.isExtensible=!0),p(t)}catch(t){e.proto=null,e.descriptors={},e.isBroken=!0}return e}(t.target),{proto:r,isBroken:o}=n;o&&t.revoke();const i=G(r);M(e,i),function(t,e){const n=I(e);for(let r=0,o=n.length;r<o;r+=1){const o=n[r];N(e,o)&&J(t,o,C(e[o]))}}(e,n.descriptors),n.isFrozen?v(e):n.isSealed?E(e):n.isExtensible||m(e);const s=t;delete s.getOwnPropertyDescriptor,delete s.getPrototypeOf,delete s.get,delete s.has,delete s.ownKeys,delete s.isExtensible,t.set=U,t.defineProperty=_,t.deleteProperty=k,t.setPrototypeOf=M,t.preventExtensions=m,v(t)}function yt(t,e){!function(t){let e=!1;try{e=N(t,n)}catch(t){}return e}(t.target)?pt(t,e):function(t,e){t.set=rt,t.deleteProperty=ot,t.setPrototypeOf=nt,t.preventExtensions=it,t.defineProperty=st}(t),v(t)}class gt{constructor(t){this.apply=q,this.construct=H,this.get=Q,this.has=X,this.ownKeys=Y,this.isExtensible=Z,this.getOwnPropertyDescriptor=tt,this.getPrototypeOf=et,this.setPrototypeOf=ut,this.set=ct,this.deleteProperty=lt,this.preventExtensions=at,this.defineProperty=ft,this.revoke=f,this.target=t}}return M(gt.prototype,null),G}.toString().replace("{","{'use strict';");const $=Proxy,{isArray:C}=Array;function G(t){let e;if("function"==typeof t){try{e="prototype"in t?function(){}:()=>{}}catch(t){e=function(){}}!function(t,e){try{const n=B(t,"name");O(e,"name",n)}catch(t){}}(t,e)}else{let n=!1;try{n=C(t)}catch(t){}e=n?[]:{}}return e}function W(t){function e(t,e,n){const o=B(e,n);if(void 0!==o){const e=r(o);O(t,n,e)}}function n(e){const n=G(e),r=new l(e),o=new $(n,r);return t.setRefMapEntries(e,o),o}function r(t){const e=y(g(null),t);if("writable"in e){const{value:t}=e;e.value="function"==typeof t?o(t):i(t)}else{const{get:t,set:n}=e;"function"==typeof t&&(e.get=o(t)),"function"==typeof n&&(e.set=o(n))}return e}function o(e){const r=t.getBlueRef(e);return void 0===r?n(e):r}function i(e){if(null==e)return e;if("function"==typeof e)return o(e);if("object"==typeof e){const r=t.getBlueRef(e);return void 0===r?n(e):r}return e}function s(e){const{length:n}=e,r=new u(n);for(let o=0;o<n;o+=1)o in e&&(r[o]=t.getRedValue(e[o]));return r}function c(t,e){!function(t,e){const n=E(e),o=A(n),i=g(null);for(let t=0,e=o.length;t<e;t+=1){const e=o[t],s=r(n[e]);i[e]=s}h(t,i)}(t,e),V(t,i(R(e))),M(t)}class l{constructor(t){this.target=t,v(this)}apply(e,n,r){const{target:o}=this,i=t.getRedValue(n),u=s(r);let c;try{c=P(o,i,u)}catch(e){throw t.getBlueValue(e)}return t.getBlueValue(c)}construct(e,n,r){const{target:o}=this;if(void 0===r)throw new a;const i=t.getRedValue(r),u=s(n);let c;try{c=b(o,u,i)}catch(e){throw t.getBlueValue(e)}return t.getBlueValue(c)}defineProperty(n,r,o){const{target:i}=this,s=function(e){const n=y(g(null),e);return"value"in n&&(n.value=t.getRedValue(n.value)),"set"in n&&(n.set=t.getRedValue(n.set)),"get"in n&&(n.get=t.getRedValue(n.get)),n}(o);return O(i,r,s)&&!1===s.configurable&&e(n,i,r),!0}deleteProperty(t,e){return S(this.target,e)}get(t,e,n){const{target:r}=this,o=B(r,e);if(void 0===o){const t=i(R(r));if(null===t)return;return k(t,e,n)}return _(o,"get")?P(i(o.get),n,K):i(o.value)}getOwnPropertyDescriptor(t,n){const{target:o}=this,i=B(o,n);return void 0===i?i:(!1===i.configurable&&e(t,o,n),r(i))}getPrototypeOf(e){return t.getBlueValue(R(this.target))}has(t,e){const{target:n}=this;if(_(n,e))return!0;const r=i(R(n));return null!==r&&m(r,e)}isExtensible(t){if(!x(t))return!1;const{target:e}=this;return!!x(e)||(c(t,e),!1)}ownKeys(t){return A(this.target)}preventExtensions(t){const{target:e}=this;if(x(t)){if(!M(e))return x(e)||c(t,e),!1;c(t,e)}return!0}set(e,n,r,o){const{target:s}=this,u=B(s,n);if(void 0===u){const t=i(R(s));if(null!==t)return I(t,n,r,o)}else if(_(u,"set"))return P(i(u.set),o,[r]),!0;return I(s,n,t.getRedValue(r))}setPrototypeOf(e,n){return V(this.target,t.getRedValue(n))}}return V(l.prototype,null),v(l.prototype),i}const J=/^\d+$/;class L{constructor(t){if(this.redMap=new f,this.blueMap=new f,void 0===t)throw new c("Missing VirtualEnvironmentOptions options bag.");const{redGlobalThis:e,distortionMap:n}=t;this.distortionMap=new f,null==n||n.forEach(((t,e)=>{if(typeof e!=typeof t)throw new c(`Invalid distortion ${t}.`);N(this.distortionMap,e,t)}));const r=e.eval(`(${T})`),o={apply:(t,e,n)=>P(t,e,n),construct:(t,e,n)=>b(t,e,n)};this.getRedValue=r(this,o),this.getBlueValue=W(this)}getBlueValue(t){}getRedValue(t){}getBlueRef(t){const e=D(this.redMap,t);if(void 0!==e)return e}getRedRef(t){const e=D(this.blueMap,t);if(void 0!==e)return e}setRefMapEntries(t,e){N(this.redMap,t,e),N(this.blueMap,e,t)}remap(t,e,n){const r=this,o=A(n),i=g(null);for(let e=0,s=o.length;e<s;e+=1){const s=o[e];if("symbol"!=typeof s&&U(J,s))continue;if(!q(t,s)){console.warn(`Property ${String(s)} of ${t} cannot be remapped.`);continue}const u=y(g(null),n[s]),c=y(g(null),u);if("value"in u)c.value=r.getRedValue(u.value);else{let t=()=>{};if("function"==typeof u.get){const{get:e}=u,n=D(this.distortionMap,e)||e;t=function(){const t=P(n,r.getBlueValue(this),K);return r.getRedValue(t)},c.get=function(){return P(t,this,K)}}"function"==typeof u.set&&(c.set=function(e){t=()=>e})}i[s]=c}h(t,i)}}function q(t,e){const n=B(t,e);return void 0===n||!0===n.configurable}const H=new f,Q=new l(["Infinity","NaN","undefined","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","AggregateError","Array","ArrayBuffer","Boolean","DataView","Error","EvalError","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Number","Object","Proxy","RangeError","ReferenceError","RegExp","SharedArrayBuffer","String","Symbol","SyntaxError","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","URIError","Atomics","JSON","Math","Reflect","escape","unescape"]),X=["AggregateError","Array","Error","EvalError","Function","Object","Proxy","RangeError","ReferenceError","SyntaxError","TypeError","URIError"];function Y(t){let e=D(H,t);if(void 0!==e)return e;e=g(null),N(H,t,e);for(let n=0,r=X.length;n<r;n+=1){const r=X[n];e[r]=t[r]}return e}function Z(t,e,n){const r=Y(e),o=Y(n);for(let e=0,n=X.length;e<n;e+=1){const n=X[e],i=r[n],s=o[n];i&&(t.setRefMapEntries(s,i),i.prototype&&t.setRefMapEntries(s.prototype,i.prototype))}}function tt(t){const e=g(null),n=A(t);for(let r=0,o=n.length;r<o;r++){const o=n[r];j(Q,o)||(e[o]=B(t,o))}return e}function et(t){return j(Q,t)}export{u as ArrayCtor,p as ArrayIsArray,c as ErrorCtor,y as ObjectAssign,g as ObjectCreate,h as ObjectDefineProperties,d as ObjectDefineProperty,v as ObjectFreeze,E as ObjectGetOwnPropertyDescriptors,_ as ObjectHasOwnProperty,F as ObjectLookupOwnGetter,w as ProxyRevocable,P as ReflectApply,b as ReflectConstruct,O as ReflectDefineProperty,S as ReflectDeleteProperty,k as ReflectGet,B as ReflectGetOwnPropertyDescriptor,R as ReflectGetPrototypeOf,m as ReflectHas,x as ReflectIsExtensible,A as ReflectOwnKeys,M as ReflectPreventExtensions,I as ReflectSet,V as ReflectSetPrototypeOf,U as RegExpTest,l as SetCtor,j as SetHas,a as TypeErrorCtor,L as VirtualEnvironment,f as WeakMapCtor,D as WeakMapGet,z as WeakMapHas,N as WeakMapSet,K as emptyArray,tt as getFilteredEndowmentDescriptors,et as isIntrinsicGlobalName,Z as linkIntrinsics}; | ||
const{__lookupGetter__:t,hasOwnProperty:e}=Object.prototype,{test:n}=RegExp.prototype,{has:r}=Set.prototype,{get:o,has:i,set:s}=WeakMap.prototype,u=Array,c=Error,l=Set,a=TypeError,f=WeakMap,{isArray:p}=Array,{assign:y,create:g,defineProperties:h,defineProperty:d,freeze:v,getOwnPropertyDescriptors:E}=Object,{revocable:b}=Proxy,{apply:w,construct:P,getPrototypeOf:R,setPrototypeOf:V,defineProperty:O,isExtensible:x,getOwnPropertyDescriptor:B,ownKeys:A,preventExtensions:k,deleteProperty:M,has:S,get:m,set:I}=Reflect;function _(t,n){return null!=t&&w(e,t,[n])}function F(n,r){if(null!=n&&w(e,n,[r]))return w(t,n,[r])}function U(t,e){return w(n,t,[e])}function j(t,e){return w(r,t,[e])}function D(t,e){return w(o,t,[e])}function z(t,e){return w(i,t,[e])}function C(t,e,n){return w(s,t,[e,n])}const N=[],K=function(t,e){const n=Symbol.for("@@lockerLiveValue"),{blueMap:r,distortionCallback:o}=t,{apply:i,construct:s}=e,u=Array,c=Error,l=TypeError,a=[],f=()=>{},{isArray:p}=Array,{assign:y,create:g,defineProperties:h,getOwnPropertyDescriptors:d,freeze:v,seal:E,isSealed:b,isFrozen:w}=Object,{__lookupGetter__:P,__lookupSetter__:R,hasOwnProperty:V}=Object.prototype,{revocable:O}=Proxy,{apply:x,isExtensible:B,getOwnPropertyDescriptor:A,setPrototypeOf:k,getPrototypeOf:M,preventExtensions:S,deleteProperty:m,ownKeys:I,defineProperty:_,get:F,set:U,has:j}=Reflect,{get:D}=WeakMap.prototype;function z(t,e){return null!=t&&x(V,t,[e])}function C(t,e,n){if(void 0!==e){const r=N(e);_(t,n,r)}}function N(t){const e=y(g(null),t);if("writable"in e)e.value=K(e.value);else{const{get:t,set:n}=e;"function"==typeof t&&(e.get=K(t)),"function"==typeof n&&(e.set=K(n))}return e}function K(e){if(null===e)return e;if(void 0!==e){if("object"==typeof e||"function"==typeof e){const n=function(t){let e;try{e=o(t)}finally{if(e!==t&&typeof e!=typeof t)throw new c(`Invalid distortion ${t}.`)}return e}(e),i=x(D,r,[n]);return void 0!==i?i:function(e){const n=function(t){let e;if("function"==typeof t){try{e="prototype"in t?function(){}:()=>{}}catch(t){e=function(){}}!function(t,e){try{const n=A(t,"name");_(e,"name",n)}catch(t){}}(t,e)}else{let n=!1;try{n=p(t)}catch(t){}e=n?[]:{}}return e}(e),r=new ft(e),{proxy:o,revoke:i}=O(n,r);r.revoke=i;try{t.setRefMapEntries(o,e)}catch(t){throw new c("Internal Error")}try{p(e)}catch(t){i()}return o}(n)}return e}}function T(e){const{length:n}=e,r=new u(n);for(let o=0;o<n;o+=1)o in e&&(r[o]=t.getBlueValue(e[o]));return r}function $(t,e,n){const r=A(t,e);void 0!==r?z(r,"configurable")&&!0===r.configurable?_(t,e,n):z(r,"writable")&&!0===r.writable&&(t[e]=n.value):_(t,e,n)}function W(t,e){!function(t,e){const n=d(e),r=I(n),o=g(null);for(let t=0,e=r.length;t<e;t+=1){const e=r[t],i=N(n[e]);o[e]=i}h(t,o)}(t,e),k(t,K(M(e))),S(t)}function G(e,n,r){const{target:o}=this;let s;try{const e=t.getBlueValue(n),u=T(r);s=i(o,e,u)}catch(t){throw K(t)}return K(s)}function J(e,n,r){const{target:o}=this;if(void 0===r)throw new l;let i;try{const e=t.getBlueValue(r),u=T(n);i=s(o,u,e)}catch(t){throw K(t)}return K(i)}function L(t,e,n){const{target:r}=this;if(!z(r,e)){const t=M(r);if(null===t)return;const o=K(t);return F(o,e,n)}const o=function(t,e){return null==t?void 0:x(P,t,[e])}(r,e);return o?x(K(o),n,a):K(r[e])}function q(t,e){const{target:n}=this;if(z(n,e))return!0;const r=M(n);if(null===r)return!1;const o=K(r);return j(o,e)}function H(t){return I(this.target)}function Q(t){if(!B(t))return!1;const{target:e}=this;return!!B(e)||(W(t,e),!1)}function X(t,e){const{target:n}=this,r=A(n,e);return void 0===r?r:(!1===r.configurable&&C(t,r,e),N(r))}function Y(t){return K(M(this.target))}function Z(e,n){return k(this.target,t.getBlueValue(n))}function tt(e,n,r,o){const{target:i}=this;if(!z(i,n)){const t=K(M(i));return null!==t&&U(t,n,r,o)}const s=function(t,e){return null==t?x(R,t,[e]):void 0}(i,n);return s?(x(K(s),o,[r]),!0):U(i,n,t.getBlueValue(r))}function et(t,e){return m(this.target,e)}function nt(t){const{target:e}=this;if(B(t)){if(!S(e))return B(e)||W(t,e),!1;W(t,e)}return!0}function rt(e,n,r){const{target:o}=this,i=function(e){const n=y(g(null),e);if("writable"in n)n.value=t.getBlueValue(n.value);else{const{get:e,set:r}=n;"function"==typeof e&&(n.get=t.getBlueValue(e)),"function"==typeof r&&(n.set=t.getBlueValue(r))}return n}(r);if(_(o,n,i)&&!1===i.configurable){C(e,A(o,n),n)}return!0}function ot(t,e){return at(this,t),this.setPrototypeOf(t,e)}function it(t,e,n,r){return at(this,t),this.set(t,e,n,r)}function st(t,e){return at(this,t),this.deleteProperty(t,e)}function ut(t){return at(this,t),this.preventExtensions(t)}function ct(t,e,n){return at(this,t),this.defineProperty(t,e,n)}function lt(t,e){const n=function(t){const e=g(null);e.isBroken=!1,e.isExtensible=!1,e.isFrozen=!1,e.isSealed=!1,e.proto=null;try{e.proto=M(t),e.descriptors=d(t),w(t)?e.isFrozen=e.isSealed=e.isExtensible=!0:b(t)?e.isSealed=e.isExtensible=!0:B(t)&&(e.isExtensible=!0),p(t)}catch(t){e.proto=null,e.descriptors={},e.isBroken=!0}return e}(t.target),{proto:r,isBroken:o}=n;o&&t.revoke();const i=K(r);k(e,i),function(t,e){const n=I(e);for(let r=0,o=n.length;r<o;r+=1){const o=n[r];z(e,o)&&$(t,o,N(e[o]))}}(e,n.descriptors),n.isFrozen?v(e):n.isSealed?E(e):n.isExtensible||S(e);const s=t;delete s.getOwnPropertyDescriptor,delete s.getPrototypeOf,delete s.get,delete s.has,delete s.ownKeys,delete s.isExtensible,t.set=U,t.defineProperty=_,t.deleteProperty=m,t.setPrototypeOf=k,t.preventExtensions=S,v(t)}function at(t,e){!function(t){let e=!1;try{e=z(t,n)}catch(t){}return e}(t.target)?lt(t,e):function(t,e){t.set=tt,t.deleteProperty=et,t.setPrototypeOf=Z,t.preventExtensions=nt,t.defineProperty=rt}(t),v(t)}class ft{constructor(t){this.apply=G,this.construct=J,this.get=L,this.has=q,this.ownKeys=H,this.isExtensible=Q,this.getOwnPropertyDescriptor=X,this.getPrototypeOf=Y,this.setPrototypeOf=ot,this.set=it,this.deleteProperty=st,this.preventExtensions=ut,this.defineProperty=ct,this.revoke=f,this.target=t}}return k(ft.prototype,null),K}.toString().replace("{","{'use strict';");const T=Proxy,{isArray:$}=Array;function W(t){let e;if("function"==typeof t){try{e="prototype"in t?function(){}:()=>{}}catch(t){e=function(){}}!function(t,e){try{const n=B(t,"name");O(e,"name",n)}catch(t){}}(t,e)}else{let n=!1;try{n=$(t)}catch(t){}e=n?[]:{}}return e}function G(t){function e(t,e,n){const o=B(e,n);if(void 0!==o){const e=r(o);O(t,n,e)}}function n(e){const n=W(e),r=new l(e),o=new T(n,r);return t.setRefMapEntries(e,o),o}function r(t){const e=y(g(null),t);if("writable"in e){const{value:t}=e;e.value="function"==typeof t?o(t):i(t)}else{const{get:t,set:n}=e;"function"==typeof t&&(e.get=o(t)),"function"==typeof n&&(e.set=o(n))}return e}function o(e){const r=t.getBlueRef(e);return void 0===r?n(e):r}function i(e){if(null==e)return e;if("function"==typeof e)return o(e);if("object"==typeof e){const r=t.getBlueRef(e);return void 0===r?n(e):r}return e}function s(e){const{length:n}=e,r=new u(n);for(let o=0;o<n;o+=1)o in e&&(r[o]=t.getRedValue(e[o]));return r}function c(t,e){!function(t,e){const n=E(e),o=A(n),i=g(null);for(let t=0,e=o.length;t<e;t+=1){const e=o[t],s=r(n[e]);i[e]=s}h(t,i)}(t,e),V(t,i(R(e))),k(t)}class l{constructor(t){this.target=t,v(this)}apply(e,n,r){const{target:o}=this,i=t.getRedValue(n),u=s(r);let c;try{c=w(o,i,u)}catch(e){throw t.getBlueValue(e)}return t.getBlueValue(c)}construct(e,n,r){const{target:o}=this;if(void 0===r)throw new a;const i=t.getRedValue(r),u=s(n);let c;try{c=P(o,u,i)}catch(e){throw t.getBlueValue(e)}return t.getBlueValue(c)}defineProperty(n,r,o){const{target:i}=this,s=function(e){const n=y(g(null),e);return"value"in n&&(n.value=t.getRedValue(n.value)),"set"in n&&(n.set=t.getRedValue(n.set)),"get"in n&&(n.get=t.getRedValue(n.get)),n}(o);return O(i,r,s)&&!1===s.configurable&&e(n,i,r),!0}deleteProperty(t,e){return M(this.target,e)}get(t,e,n){const{target:r}=this,o=B(r,e);if(void 0===o){const t=i(R(r));if(null===t)return;return m(t,e,n)}return _(o,"get")?w(i(o.get),n,N):i(o.value)}getOwnPropertyDescriptor(t,n){const{target:o}=this,i=B(o,n);return void 0===i?i:(!1===i.configurable&&e(t,o,n),r(i))}getPrototypeOf(e){return t.getBlueValue(R(this.target))}has(t,e){const{target:n}=this;if(_(n,e))return!0;const r=i(R(n));return null!==r&&S(r,e)}isExtensible(t){if(!x(t))return!1;const{target:e}=this;return!!x(e)||(c(t,e),!1)}ownKeys(t){return A(this.target)}preventExtensions(t){const{target:e}=this;if(x(t)){if(!k(e))return x(e)||c(t,e),!1;c(t,e)}return!0}set(e,n,r,o){const{target:s}=this,u=B(s,n);if(void 0===u){const t=i(R(s));if(null!==t)return I(t,n,r,o)}else if(_(u,"set"))return w(i(u.set),o,[r]),!0;return I(s,n,t.getRedValue(r))}setPrototypeOf(e,n){return V(this.target,t.getRedValue(n))}}return V(l.prototype,null),v(l.prototype),i}const J=/^\d+$/,L=t=>t;class q{constructor(t){if(this.redMap=new f,this.blueMap=new f,void 0===t)throw new c("Missing VirtualEnvironmentOptions options bag.");const{redGlobalThis:e,distortionCallback:n}=t;this.distortionCallback=n||L;const r=e.eval(`(${K})`),o={apply:(t,e,n)=>w(t,e,n),construct:(t,e,n)=>P(t,e,n)};this.getRedValue=r(this,o),this.getBlueValue=G(this)}getBlueValue(t){}getRedValue(t){}getBlueRef(t){const e=D(this.redMap,t);if(void 0!==e)return e}getRedRef(t){const e=D(this.blueMap,t);if(void 0!==e)return e}setRefMapEntries(t,e){C(this.redMap,t,e),C(this.blueMap,e,t)}remap(t,e,n){const r=this,o=A(n),i=g(null);for(let e=0,s=o.length;e<s;e+=1){const s=o[e];if("symbol"!=typeof s&&U(J,s))continue;if(!H(t,s)){console.warn(`Property ${String(s)} of ${t} cannot be remapped.`);continue}const u=y(g(null),n[s]),c=y(g(null),u);if("value"in u)c.value=r.getRedValue(u.value);else{let t=()=>{};if("function"==typeof u.get){const{get:e}=u,n=this.distortionCallback(e);t=function(){const t=w(n,r.getBlueValue(this),N);return r.getRedValue(t)},c.get=function(){return w(t,this,N)}}"function"==typeof u.set&&(c.set=function(e){t=()=>e})}i[s]=c}h(t,i)}}function H(t,e){const n=B(t,e);return void 0===n||!0===n.configurable}const Q=new f,X=new l(["Infinity","NaN","undefined","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","AggregateError","Array","ArrayBuffer","BigInt","BigInt64Array","BigUint64Array","Boolean","DataView","Error","EvalError","FinalizationRegistry","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Number","Object","Proxy","RangeError","ReferenceError","RegExp","SharedArrayBuffer","String","Symbol","SyntaxError","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","URIError","WeakRef","Atomics","JSON","Math","Reflect","escape","unescape"]),Y=["AggregateError","Array","Error","EvalError","Function","Object","Proxy","RangeError","ReferenceError","SyntaxError","TypeError","URIError"];function Z(t){let e=D(Q,t);if(void 0!==e)return e;e=g(null),C(Q,t,e);for(let n=0,r=Y.length;n<r;n+=1){const r=Y[n];e[r]=t[r]}return e}function tt(t,e,n){const r=Z(e),o=Z(n);for(let e=0,n=Y.length;e<n;e+=1){const n=Y[e],i=r[n],s=o[n];i&&(t.setRefMapEntries(s,i),i.prototype&&t.setRefMapEntries(s.prototype,i.prototype))}}function et(t){const e=g(null),n=A(t);for(let r=0,o=n.length;r<o;r+=1){const o=n[r];j(X,o)||(e[o]=B(t,o))}return e}function nt(t){return j(X,t)}export{u as ArrayCtor,p as ArrayIsArray,c as ErrorCtor,y as ObjectAssign,g as ObjectCreate,h as ObjectDefineProperties,d as ObjectDefineProperty,v as ObjectFreeze,E as ObjectGetOwnPropertyDescriptors,_ as ObjectHasOwnProperty,F as ObjectLookupOwnGetter,b as ProxyRevocable,w as ReflectApply,P as ReflectConstruct,O as ReflectDefineProperty,M as ReflectDeleteProperty,m as ReflectGet,B as ReflectGetOwnPropertyDescriptor,R as ReflectGetPrototypeOf,S as ReflectHas,x as ReflectIsExtensible,A as ReflectOwnKeys,k as ReflectPreventExtensions,I as ReflectSet,V as ReflectSetPrototypeOf,U as RegExpTest,l as SetCtor,j as SetHas,a as TypeErrorCtor,q as VirtualEnvironment,f as WeakMapCtor,D as WeakMapGet,z as WeakMapHas,C as WeakMapSet,N as emptyArray,et as getFilteredEndowmentDescriptors,nt as isIntrinsicGlobalName,tt as linkIntrinsics}; | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@locker/near-membrane-base", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"license": "MIT", | ||
@@ -20,3 +20,3 @@ "author": "Caridy Patiño <caridy@gmail.com>", | ||
}, | ||
"gitHead": "9b89f4b07c6b6adffaa11ff9a74acb9730d1a07f" | ||
"gitHead": "3b9547eed3f439d130b02f7080b1bb758d137d3f" | ||
} |
@@ -1,6 +0,6 @@ | ||
import { RedObject, RedFunction, BlueFunction, BlueObject, RedProxyTarget, BlueValue, RedValue, MembraneBroker, DistortionMap, RedProxy, BlueProxy, BlueProxyTarget } from './types'; | ||
import { RedObject, RedFunction, BlueFunction, BlueObject, RedProxyTarget, BlueValue, RedValue, MembraneBroker, RedProxy, BlueProxy, BlueProxyTarget } from './types'; | ||
interface VirtualEnvironmentOptions { | ||
blueGlobalThis: BlueObject & typeof globalThis; | ||
redGlobalThis: RedObject & typeof globalThis; | ||
distortionMap?: Map<RedProxyTarget, RedProxyTarget>; | ||
distortionCallback?: (originalTarget: RedProxyTarget) => RedProxyTarget; | ||
} | ||
@@ -10,3 +10,3 @@ export declare class VirtualEnvironment implements MembraneBroker { | ||
blueMap: WeakMap<BlueFunction | BlueObject, RedProxy | BlueProxyTarget>; | ||
distortionMap: DistortionMap; | ||
distortionCallback: (originalTarget: RedProxyTarget) => RedProxyTarget; | ||
constructor(options: VirtualEnvironmentOptions); | ||
@@ -13,0 +13,0 @@ getBlueValue(red: RedValue): BlueValue; |
@@ -29,7 +29,6 @@ export declare type BlueValue = any; | ||
export declare type BlueProxy = BlueObject | BlueFunction; | ||
export declare type DistortionMap = WeakMap<RedProxyTarget, RedProxyTarget>; | ||
export interface MembraneBroker { | ||
redMap: WeakMap<RedFunction | RedObject, RedProxyTarget | BlueProxy>; | ||
blueMap: WeakMap<BlueFunction | BlueObject, RedProxy | BlueProxyTarget>; | ||
distortionMap: DistortionMap; | ||
distortionCallback: (originalTarget: RedProxyTarget) => RedProxyTarget; | ||
getBlueValue(red: RedValue): BlueValue; | ||
@@ -42,5 +41,5 @@ getRedValue(blue: BlueValue): RedValue; | ||
export interface EnvironmentOptions { | ||
distortionMap?: Map<RedProxyTarget, RedProxyTarget>; | ||
distortionCallback?: (originalTarget: RedProxyTarget) => RedProxyTarget; | ||
endowments?: object; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
288230
1509