@poe-platform/safe-js 0.1.169 → 0.1.170
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/safe-js/chunks/{chunk-MWL55BSP.js → chunk-MZW43CYT.js} +2 -2
- package/dist/safe-js/chunks/{chunk-6UY4Z7WY.js → chunk-WPI4GGVU.js} +296 -134
- package/dist/safe-js/chunks/chunk-WPI4GGVU.js.map +7 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/interp/regexp-properties.d.ts +3 -0
- package/dist/safe-js/interp/values.d.ts +1 -0
- package/dist/safe-js/snapshot/regexp-properties.d.ts +18 -0
- package/dist/safe-js/snapshot/replay-data.d.ts +3 -2
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-6UY4Z7WY.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-MWL55BSP.js.map → chunk-MZW43CYT.js.map} +0 -0
|
@@ -6165,87 +6165,6 @@ function matchingOpeningPunctuator(value) {
|
|
|
6165
6165
|
return "{";
|
|
6166
6166
|
}
|
|
6167
6167
|
|
|
6168
|
-
// packages/safe-js/src/extensions.ts
|
|
6169
|
-
import { types } from "node:util";
|
|
6170
|
-
var definitions = /* @__PURE__ */ new WeakMap();
|
|
6171
|
-
function readDataRecord(value, label) {
|
|
6172
|
-
if (typeof value !== "object" || value === null || types.isProxy(value)) {
|
|
6173
|
-
throw new TypeError(`${label} must be a plain data record.`);
|
|
6174
|
-
}
|
|
6175
|
-
const prototype = Object.getPrototypeOf(value);
|
|
6176
|
-
if (prototype !== null && prototype !== Object.prototype) {
|
|
6177
|
-
throw new TypeError(`${label} must be a plain data record.`);
|
|
6178
|
-
}
|
|
6179
|
-
const keys = Reflect.ownKeys(value);
|
|
6180
|
-
if (keys.length > 4096) throw new RangeError(`${label} has too many fields.`);
|
|
6181
|
-
const result = /* @__PURE__ */ Object.create(null);
|
|
6182
|
-
for (const key of keys) {
|
|
6183
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
6184
|
-
if (typeof key !== "string" || !("value" in descriptor)) {
|
|
6185
|
-
throw new TypeError(`${label} requires string-keyed data properties, not accessors.`);
|
|
6186
|
-
}
|
|
6187
|
-
result[key] = descriptor.value;
|
|
6188
|
-
}
|
|
6189
|
-
return result;
|
|
6190
|
-
}
|
|
6191
|
-
function readStringList(value, label) {
|
|
6192
|
-
if (!Array.isArray(value) || types.isProxy(value) || value.length > 4096) {
|
|
6193
|
-
throw new TypeError(`${label} must be a bounded string array.`);
|
|
6194
|
-
}
|
|
6195
|
-
const result = [];
|
|
6196
|
-
for (let index = 0; index < value.length; index++) {
|
|
6197
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
6198
|
-
if (descriptor === void 0 || !("value" in descriptor) || typeof descriptor.value !== "string" || descriptor.value.length === 0) {
|
|
6199
|
-
throw new TypeError(`${label} requires nonempty string data properties.`);
|
|
6200
|
-
}
|
|
6201
|
-
if (result.includes(descriptor.value))
|
|
6202
|
-
throw new TypeError(`${label} contains a duplicate name.`);
|
|
6203
|
-
result.push(descriptor.value);
|
|
6204
|
-
}
|
|
6205
|
-
if (Reflect.ownKeys(value).length !== result.length + 1)
|
|
6206
|
-
throw new TypeError(`${label} has unexpected fields.`);
|
|
6207
|
-
return Object.freeze(result);
|
|
6208
|
-
}
|
|
6209
|
-
function defineExtension(definition) {
|
|
6210
|
-
const input = readDataRecord(definition, "Extension definition");
|
|
6211
|
-
if (Object.keys(input).some((key) => key !== "manifest" && key !== "setup"))
|
|
6212
|
-
throw new TypeError("Unknown extension definition field.");
|
|
6213
|
-
if (typeof input.setup !== "function") throw new TypeError("Extension setup must be a function.");
|
|
6214
|
-
if (types.isAsyncFunction(input.setup))
|
|
6215
|
-
throw new TypeError("Extension setup must be synchronous.");
|
|
6216
|
-
const manifest = readDataRecord(input.manifest, "Extension manifest");
|
|
6217
|
-
if (Object.keys(manifest).some(
|
|
6218
|
-
(key) => !["version", "name", "capabilities", "globals", "modules"].includes(key)
|
|
6219
|
-
))
|
|
6220
|
-
throw new TypeError("Unknown extension manifest field.");
|
|
6221
|
-
if (manifest.version !== 1) throw new TypeError("Unsupported extension manifest version.");
|
|
6222
|
-
if (typeof manifest.name !== "string" || manifest.name.length === 0 || manifest.name.length > 256)
|
|
6223
|
-
throw new TypeError("Extension name must be a nonempty bounded string.");
|
|
6224
|
-
const modules = /* @__PURE__ */ Object.create(null);
|
|
6225
|
-
for (const [name, exports] of Object.entries(
|
|
6226
|
-
readDataRecord(manifest.modules ?? {}, "Extension modules")
|
|
6227
|
-
)) {
|
|
6228
|
-
if (name.length === 0) throw new TypeError("Module names must be nonempty.");
|
|
6229
|
-
modules[name] = readStringList(exports, `Module '${name}' exports`);
|
|
6230
|
-
}
|
|
6231
|
-
const extension = Object.freeze({
|
|
6232
|
-
manifest: Object.freeze({
|
|
6233
|
-
version: 1,
|
|
6234
|
-
name: manifest.name,
|
|
6235
|
-
capabilities: readStringList(manifest.capabilities ?? [], "Extension capabilities"),
|
|
6236
|
-
globals: readStringList(manifest.globals ?? [], "Extension globals"),
|
|
6237
|
-
modules: Object.freeze(modules)
|
|
6238
|
-
})
|
|
6239
|
-
});
|
|
6240
|
-
definitions.set(extension, input.setup);
|
|
6241
|
-
return extension;
|
|
6242
|
-
}
|
|
6243
|
-
function getExtensionSetup(extension) {
|
|
6244
|
-
const setup = definitions.get(extension);
|
|
6245
|
-
if (setup === void 0) throw new TypeError("Extensions must be created by defineExtension.");
|
|
6246
|
-
return setup;
|
|
6247
|
-
}
|
|
6248
|
-
|
|
6249
6168
|
// packages/safe-js/src/observability/otel.ts
|
|
6250
6169
|
var noopOtelSink = {
|
|
6251
6170
|
startSpan: () => noopOtelSpan,
|
|
@@ -6337,6 +6256,87 @@ function readErrorMessage(error) {
|
|
|
6337
6256
|
return error instanceof Error ? error.message : String(error);
|
|
6338
6257
|
}
|
|
6339
6258
|
|
|
6259
|
+
// packages/safe-js/src/extensions.ts
|
|
6260
|
+
import { types } from "node:util";
|
|
6261
|
+
var definitions = /* @__PURE__ */ new WeakMap();
|
|
6262
|
+
function readDataRecord(value, label) {
|
|
6263
|
+
if (typeof value !== "object" || value === null || types.isProxy(value)) {
|
|
6264
|
+
throw new TypeError(`${label} must be a plain data record.`);
|
|
6265
|
+
}
|
|
6266
|
+
const prototype = Object.getPrototypeOf(value);
|
|
6267
|
+
if (prototype !== null && prototype !== Object.prototype) {
|
|
6268
|
+
throw new TypeError(`${label} must be a plain data record.`);
|
|
6269
|
+
}
|
|
6270
|
+
const keys = Reflect.ownKeys(value);
|
|
6271
|
+
if (keys.length > 4096) throw new RangeError(`${label} has too many fields.`);
|
|
6272
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
6273
|
+
for (const key of keys) {
|
|
6274
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
6275
|
+
if (typeof key !== "string" || !("value" in descriptor)) {
|
|
6276
|
+
throw new TypeError(`${label} requires string-keyed data properties, not accessors.`);
|
|
6277
|
+
}
|
|
6278
|
+
result[key] = descriptor.value;
|
|
6279
|
+
}
|
|
6280
|
+
return result;
|
|
6281
|
+
}
|
|
6282
|
+
function readStringList(value, label) {
|
|
6283
|
+
if (!Array.isArray(value) || types.isProxy(value) || value.length > 4096) {
|
|
6284
|
+
throw new TypeError(`${label} must be a bounded string array.`);
|
|
6285
|
+
}
|
|
6286
|
+
const result = [];
|
|
6287
|
+
for (let index = 0; index < value.length; index++) {
|
|
6288
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
6289
|
+
if (descriptor === void 0 || !("value" in descriptor) || typeof descriptor.value !== "string" || descriptor.value.length === 0) {
|
|
6290
|
+
throw new TypeError(`${label} requires nonempty string data properties.`);
|
|
6291
|
+
}
|
|
6292
|
+
if (result.includes(descriptor.value))
|
|
6293
|
+
throw new TypeError(`${label} contains a duplicate name.`);
|
|
6294
|
+
result.push(descriptor.value);
|
|
6295
|
+
}
|
|
6296
|
+
if (Reflect.ownKeys(value).length !== result.length + 1)
|
|
6297
|
+
throw new TypeError(`${label} has unexpected fields.`);
|
|
6298
|
+
return Object.freeze(result);
|
|
6299
|
+
}
|
|
6300
|
+
function defineExtension(definition) {
|
|
6301
|
+
const input = readDataRecord(definition, "Extension definition");
|
|
6302
|
+
if (Object.keys(input).some((key) => key !== "manifest" && key !== "setup"))
|
|
6303
|
+
throw new TypeError("Unknown extension definition field.");
|
|
6304
|
+
if (typeof input.setup !== "function") throw new TypeError("Extension setup must be a function.");
|
|
6305
|
+
if (types.isAsyncFunction(input.setup))
|
|
6306
|
+
throw new TypeError("Extension setup must be synchronous.");
|
|
6307
|
+
const manifest = readDataRecord(input.manifest, "Extension manifest");
|
|
6308
|
+
if (Object.keys(manifest).some(
|
|
6309
|
+
(key) => !["version", "name", "capabilities", "globals", "modules"].includes(key)
|
|
6310
|
+
))
|
|
6311
|
+
throw new TypeError("Unknown extension manifest field.");
|
|
6312
|
+
if (manifest.version !== 1) throw new TypeError("Unsupported extension manifest version.");
|
|
6313
|
+
if (typeof manifest.name !== "string" || manifest.name.length === 0 || manifest.name.length > 256)
|
|
6314
|
+
throw new TypeError("Extension name must be a nonempty bounded string.");
|
|
6315
|
+
const modules = /* @__PURE__ */ Object.create(null);
|
|
6316
|
+
for (const [name, exports] of Object.entries(
|
|
6317
|
+
readDataRecord(manifest.modules ?? {}, "Extension modules")
|
|
6318
|
+
)) {
|
|
6319
|
+
if (name.length === 0) throw new TypeError("Module names must be nonempty.");
|
|
6320
|
+
modules[name] = readStringList(exports, `Module '${name}' exports`);
|
|
6321
|
+
}
|
|
6322
|
+
const extension = Object.freeze({
|
|
6323
|
+
manifest: Object.freeze({
|
|
6324
|
+
version: 1,
|
|
6325
|
+
name: manifest.name,
|
|
6326
|
+
capabilities: readStringList(manifest.capabilities ?? [], "Extension capabilities"),
|
|
6327
|
+
globals: readStringList(manifest.globals ?? [], "Extension globals"),
|
|
6328
|
+
modules: Object.freeze(modules)
|
|
6329
|
+
})
|
|
6330
|
+
});
|
|
6331
|
+
definitions.set(extension, input.setup);
|
|
6332
|
+
return extension;
|
|
6333
|
+
}
|
|
6334
|
+
function getExtensionSetup(extension) {
|
|
6335
|
+
const setup = definitions.get(extension);
|
|
6336
|
+
if (setup === void 0) throw new TypeError("Extensions must be created by defineExtension.");
|
|
6337
|
+
return setup;
|
|
6338
|
+
}
|
|
6339
|
+
|
|
6340
6340
|
// packages/safe-js/src/snapshot/policy.ts
|
|
6341
6341
|
var MODULE_PENDING_HOST_CALL_POLICIES = Object.assign(
|
|
6342
6342
|
/* @__PURE__ */ Object.create(null),
|
|
@@ -6583,6 +6583,14 @@ function serializedDateTime(value) {
|
|
|
6583
6583
|
// packages/safe-js/src/interp/internal-symbols.ts
|
|
6584
6584
|
var internalSymbols = /* @__PURE__ */ new Set();
|
|
6585
6585
|
|
|
6586
|
+
// packages/safe-js/src/interp/regexp-properties.ts
|
|
6587
|
+
var regexGuestProperties = /* @__PURE__ */ new WeakMap();
|
|
6588
|
+
function getRegexProperties(value) {
|
|
6589
|
+
const properties = regexGuestProperties.get(value);
|
|
6590
|
+
if (properties === void 0) throw new TypeError("Invalid sandbox RegExp storage.");
|
|
6591
|
+
return properties;
|
|
6592
|
+
}
|
|
6593
|
+
|
|
6586
6594
|
// packages/safe-js/src/interp/accessors.ts
|
|
6587
6595
|
var accessorClosures = /* @__PURE__ */ new WeakMap();
|
|
6588
6596
|
var getterAdapters = /* @__PURE__ */ new WeakMap();
|
|
@@ -7236,6 +7244,96 @@ var wellKnownSymbols = Object.freeze({
|
|
|
7236
7244
|
unscopables: Symbol.unscopables
|
|
7237
7245
|
});
|
|
7238
7246
|
|
|
7247
|
+
// packages/safe-js/src/snapshot/symbols.ts
|
|
7248
|
+
function symbolData(value) {
|
|
7249
|
+
const wellKnown = Object.keys(wellKnownSymbols).find((key) => wellKnownSymbols[key] === value);
|
|
7250
|
+
return {
|
|
7251
|
+
kind: "symbol",
|
|
7252
|
+
...wellKnown === void 0 ? value.description === void 0 ? {} : { description: value.description } : { wellKnown }
|
|
7253
|
+
};
|
|
7254
|
+
}
|
|
7255
|
+
function serializeSymbol(value, heapIds, heap) {
|
|
7256
|
+
let id = heapIds.get(value);
|
|
7257
|
+
if (id === void 0) {
|
|
7258
|
+
id = heapIds.size + 1;
|
|
7259
|
+
heapIds.set(value, id);
|
|
7260
|
+
heap[String(id)] = symbolData(value);
|
|
7261
|
+
}
|
|
7262
|
+
return { kind: "ref", id };
|
|
7263
|
+
}
|
|
7264
|
+
function ownSerializableSymbolKeys(value) {
|
|
7265
|
+
return Object.getOwnPropertySymbols(value).filter((key) => !internalSymbols.has(key));
|
|
7266
|
+
}
|
|
7267
|
+
function serializeSymbolProperties(value, encode) {
|
|
7268
|
+
return ownSerializableSymbolKeys(value).map((key) => {
|
|
7269
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
7270
|
+
if (!("value" in descriptor)) throw new TypeError("Symbol accessor properties cannot be serialized.");
|
|
7271
|
+
return [encode(key), { value: encode(descriptor.value), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true }];
|
|
7272
|
+
});
|
|
7273
|
+
}
|
|
7274
|
+
function restoreSymbolProperties(target, entries, decode) {
|
|
7275
|
+
for (const [key, descriptor] of entries ?? []) {
|
|
7276
|
+
const symbol = decode(key);
|
|
7277
|
+
if (typeof symbol !== "symbol") throw new TypeError("Expected a symbol property key");
|
|
7278
|
+
Object.defineProperty(target, symbol, { ...descriptor, value: decode(descriptor.value) });
|
|
7279
|
+
}
|
|
7280
|
+
}
|
|
7281
|
+
|
|
7282
|
+
// packages/safe-js/src/snapshot/regexp-properties.ts
|
|
7283
|
+
function hasCustomRegexProperties(value) {
|
|
7284
|
+
const properties = getRegexProperties(value);
|
|
7285
|
+
return Reflect.ownKeys(properties).length !== 1 || !Object.isExtensible(properties) || Object.getOwnPropertyDescriptor(properties, "lastIndex")?.writable !== true;
|
|
7286
|
+
}
|
|
7287
|
+
function serializeRegexProperties(value, encode) {
|
|
7288
|
+
if (!hasCustomRegexProperties(value)) return {};
|
|
7289
|
+
const source = getRegexProperties(value);
|
|
7290
|
+
const properties = /* @__PURE__ */ Object.create(null);
|
|
7291
|
+
for (const key of Object.getOwnPropertyNames(source)) {
|
|
7292
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
7293
|
+
if (!("value" in descriptor)) throw new TypeError("RegExp accessor properties cannot be serialized as data.");
|
|
7294
|
+
properties[key] = {
|
|
7295
|
+
value: encode(descriptor.value),
|
|
7296
|
+
enumerable: descriptor.enumerable === true,
|
|
7297
|
+
configurable: descriptor.configurable === true,
|
|
7298
|
+
writable: descriptor.writable === true
|
|
7299
|
+
};
|
|
7300
|
+
}
|
|
7301
|
+
const symbolEntries = serializeSymbolProperties(source, encode);
|
|
7302
|
+
return {
|
|
7303
|
+
properties,
|
|
7304
|
+
...symbolEntries.length === 0 ? {} : { symbolEntries },
|
|
7305
|
+
...Object.isExtensible(source) ? {} : { extensible: false }
|
|
7306
|
+
};
|
|
7307
|
+
}
|
|
7308
|
+
function validateRegexProperties(data) {
|
|
7309
|
+
const descriptor = (value) => {
|
|
7310
|
+
if (typeof value !== "object" || value === null || Array.isArray(value) || !Object.hasOwn(value, "value") || !["enumerable", "configurable", "writable"].every((key) => Object.hasOwn(value, key) && typeof value[key] === "boolean") || Object.keys(value).some((key) => !["value", "enumerable", "configurable", "writable"].includes(key)))
|
|
7311
|
+
throw new TypeError("Invalid RegExp data property descriptor.");
|
|
7312
|
+
};
|
|
7313
|
+
if (data.extensible !== void 0 && typeof data.extensible !== "boolean")
|
|
7314
|
+
throw new TypeError("Invalid RegExp extensibility.");
|
|
7315
|
+
if (data.properties !== void 0) {
|
|
7316
|
+
if (typeof data.properties !== "object" || data.properties === null || Array.isArray(data.properties))
|
|
7317
|
+
throw new TypeError("Invalid RegExp property data.");
|
|
7318
|
+
for (const entry of Object.values(data.properties)) descriptor(entry);
|
|
7319
|
+
}
|
|
7320
|
+
if (data.symbolEntries !== void 0) {
|
|
7321
|
+
if (!Array.isArray(data.symbolEntries)) throw new TypeError("Invalid RegExp symbol properties.");
|
|
7322
|
+
for (const entry of data.symbolEntries) {
|
|
7323
|
+
if (!Array.isArray(entry) || entry.length !== 2) throw new TypeError("Invalid RegExp symbol property.");
|
|
7324
|
+
descriptor(entry[1]);
|
|
7325
|
+
}
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
7328
|
+
function restoreRegexProperties(value, data, decode) {
|
|
7329
|
+
validateRegexProperties(data);
|
|
7330
|
+
const properties = getRegexProperties(value);
|
|
7331
|
+
for (const [key, descriptor] of Object.entries(data.properties ?? {}))
|
|
7332
|
+
Object.defineProperty(properties, key, { ...descriptor, value: decode(descriptor.value) });
|
|
7333
|
+
restoreSymbolProperties(properties, data.symbolEntries, decode);
|
|
7334
|
+
if (data.extensible === false) Object.preventExtensions(properties);
|
|
7335
|
+
}
|
|
7336
|
+
|
|
7239
7337
|
// packages/safe-js/src/snapshot/validation.ts
|
|
7240
7338
|
import { types as types5 } from "node:util";
|
|
7241
7339
|
|
|
@@ -7343,6 +7441,11 @@ function walkGraphDepth(root, rootPath, assertDepth) {
|
|
|
7343
7441
|
}
|
|
7344
7442
|
}
|
|
7345
7443
|
function graphEntries(value) {
|
|
7444
|
+
const properties = regexGuestProperties.get(value);
|
|
7445
|
+
if (properties !== void 0) return Reflect.ownKeys(properties).flatMap((key) => {
|
|
7446
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
7447
|
+
return "value" in descriptor ? [[`.${String(key)}`, descriptor.value]] : [];
|
|
7448
|
+
});
|
|
7346
7449
|
if (isSandboxBox(value)) return boxedDataProperties(value).map(([key, descriptor]) => [`.${key}`, descriptor.value]);
|
|
7347
7450
|
if (isSandboxArguments(value)) {
|
|
7348
7451
|
return getSandboxArgumentEntries(value).map(([key, entry]) => [`.${key}`, entry]);
|
|
@@ -7497,8 +7600,8 @@ function getSandboxPropertyDescriptor(value, key, budget) {
|
|
|
7497
7600
|
return hostProperties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(hostProperties, key);
|
|
7498
7601
|
let current = value;
|
|
7499
7602
|
let depth = 0;
|
|
7500
|
-
while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxDate(current) || isPrototypeRecord(current))) {
|
|
7501
|
-
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : current;
|
|
7603
|
+
while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxDate(current) || isSandboxRegex(current) || isPrototypeRecord(current))) {
|
|
7604
|
+
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : current;
|
|
7502
7605
|
const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key);
|
|
7503
7606
|
if (descriptor !== void 0) return descriptor;
|
|
7504
7607
|
current = getSandboxPrototype(current, budget);
|
|
@@ -7514,6 +7617,7 @@ function getSandboxDataProperty(value, key, budget) {
|
|
|
7514
7617
|
let depth = 0;
|
|
7515
7618
|
while (typeof current === "object" && current !== null) {
|
|
7516
7619
|
if (isGuestHostObject(current)) return typeof key === "symbol" ? void 0 : getHostObjectMember(current, String(key));
|
|
7620
|
+
if (isSandboxRegex(current)) return Object.getOwnPropertyDescriptor(getRegexProperties(current), key)?.value;
|
|
7517
7621
|
if (isGuestClosure(current)) {
|
|
7518
7622
|
const entry = getGuestFunctionProperty(current, key);
|
|
7519
7623
|
if (entry !== void 0 || Object.hasOwn(current.properties ?? {}, key)) return entry;
|
|
@@ -7676,34 +7780,6 @@ function decodeFloat32Storage(value, resolve) {
|
|
|
7676
7780
|
return new Float32Array(buffer, Number(value.byteOffset), Number(value.length));
|
|
7677
7781
|
}
|
|
7678
7782
|
|
|
7679
|
-
// packages/safe-js/src/snapshot/symbols.ts
|
|
7680
|
-
function symbolData(value) {
|
|
7681
|
-
const wellKnown = Object.keys(wellKnownSymbols).find((key) => wellKnownSymbols[key] === value);
|
|
7682
|
-
return {
|
|
7683
|
-
kind: "symbol",
|
|
7684
|
-
...wellKnown === void 0 ? value.description === void 0 ? {} : { description: value.description } : { wellKnown }
|
|
7685
|
-
};
|
|
7686
|
-
}
|
|
7687
|
-
function serializeSymbol(value, heapIds, heap) {
|
|
7688
|
-
let id = heapIds.get(value);
|
|
7689
|
-
if (id === void 0) {
|
|
7690
|
-
id = heapIds.size + 1;
|
|
7691
|
-
heapIds.set(value, id);
|
|
7692
|
-
heap[String(id)] = symbolData(value);
|
|
7693
|
-
}
|
|
7694
|
-
return { kind: "ref", id };
|
|
7695
|
-
}
|
|
7696
|
-
function ownSerializableSymbolKeys(value) {
|
|
7697
|
-
return Object.getOwnPropertySymbols(value).filter((key) => !internalSymbols.has(key));
|
|
7698
|
-
}
|
|
7699
|
-
function serializeSymbolProperties(value, encode) {
|
|
7700
|
-
return ownSerializableSymbolKeys(value).map((key) => {
|
|
7701
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
7702
|
-
if (!("value" in descriptor)) throw new TypeError("Symbol accessor properties cannot be serialized.");
|
|
7703
|
-
return [encode(key), { value: encode(descriptor.value), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true }];
|
|
7704
|
-
});
|
|
7705
|
-
}
|
|
7706
|
-
|
|
7707
7783
|
// packages/safe-js/src/snapshot/date-properties.ts
|
|
7708
7784
|
function serializeDate(value, encode) {
|
|
7709
7785
|
const properties = /* @__PURE__ */ Object.create(null);
|
|
@@ -7813,7 +7889,7 @@ function serializeDumpValue(value, path, state) {
|
|
|
7813
7889
|
if (hasGuestObjectState(value)) {
|
|
7814
7890
|
throw new TypeError("Guest function properties and prototype links cannot be serialized.");
|
|
7815
7891
|
}
|
|
7816
|
-
if (isSandboxBox(value) || isSandboxDate(value) || isFloat32Array(value)) return serializeHeapReference(value, path, state);
|
|
7892
|
+
if (isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxBox(value) || isSandboxDate(value) || isFloat32Array(value)) return serializeHeapReference(value, path, state);
|
|
7817
7893
|
if (Array.isArray(value)) {
|
|
7818
7894
|
const reference2 = serializeHeapReference(value, path, state);
|
|
7819
7895
|
if (reference2 !== void 0) {
|
|
@@ -7837,7 +7913,20 @@ function serializeHeapReference(value, path, state) {
|
|
|
7837
7913
|
}
|
|
7838
7914
|
if (!state.serializedHeapIds.has(id)) {
|
|
7839
7915
|
state.serializedHeapIds.add(id);
|
|
7840
|
-
if (
|
|
7916
|
+
if (isSandboxRegex(value) && hasCustomRegexProperties(value)) {
|
|
7917
|
+
const encode = (entry) => {
|
|
7918
|
+
const serialized = serializeDumpValue(entry, `${path}.<regex-property>`, state);
|
|
7919
|
+
if (serialized === SKIP_VALUE) throw new TypeError("Unsupported RegExp property in public dump.");
|
|
7920
|
+
return serialized;
|
|
7921
|
+
};
|
|
7922
|
+
state.heap[String(id)] = {
|
|
7923
|
+
kind: "regex-object",
|
|
7924
|
+
source: value.source,
|
|
7925
|
+
flags: value.flags,
|
|
7926
|
+
lastIndex: encode(value.lastIndex),
|
|
7927
|
+
...serializeRegexProperties(value, encode)
|
|
7928
|
+
};
|
|
7929
|
+
} else if (isSandboxBox(value)) {
|
|
7841
7930
|
state.heap[String(id)] = encodeBoxedData(value, (entry, key) => {
|
|
7842
7931
|
if (Object.is(entry, -0)) return { kind: "number", value: "-0" };
|
|
7843
7932
|
const serialized = serializeDumpValue(entry, `${path}.${key}`, state);
|
|
@@ -7916,7 +8005,7 @@ function indexHeapContainers(snapshot) {
|
|
|
7916
8005
|
const heapIds = /* @__PURE__ */ new Map();
|
|
7917
8006
|
let nextId = 1;
|
|
7918
8007
|
for (const [value, stat2] of stats.entries()) {
|
|
7919
|
-
if (stat2.count > 1 || stat2.cyclic || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
8008
|
+
if (stat2.count > 1 || stat2.cyclic || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
7920
8009
|
heapIds.set(value, nextId);
|
|
7921
8010
|
nextId += 1;
|
|
7922
8011
|
}
|
|
@@ -7949,7 +8038,10 @@ function collectContainerStats(value, stats, ancestors) {
|
|
|
7949
8038
|
}
|
|
7950
8039
|
stat2.expanded = true;
|
|
7951
8040
|
ancestors.add(value);
|
|
7952
|
-
const entries =
|
|
8041
|
+
const entries = isSandboxRegex(value) ? Reflect.ownKeys(getRegexProperties(value)).flatMap((key) => {
|
|
8042
|
+
const descriptor = Object.getOwnPropertyDescriptor(getRegexProperties(value), key);
|
|
8043
|
+
return "value" in descriptor ? [descriptor.value] : [];
|
|
8044
|
+
}) : isSandboxDate(value) ? dateDataProperties(value).flatMap(([key, descriptor]) => typeof key === "string" ? [descriptor.value] : []) : isSandboxBox(value) ? boxedDataProperties(value).map(([, descriptor]) => descriptor.value) : isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) : getEnumerableDataValues(value);
|
|
7953
8045
|
for (const entry of entries) {
|
|
7954
8046
|
collectContainerStats(entry, stats, ancestors);
|
|
7955
8047
|
}
|
|
@@ -8069,6 +8161,10 @@ function validateDumpHeap(root, state) {
|
|
|
8069
8161
|
const entry = requireRecord(value, path);
|
|
8070
8162
|
validateErrorType(entry, path);
|
|
8071
8163
|
validateSymbolEntries(entry, path, state, heap);
|
|
8164
|
+
if (entry.kind === "regex-object") {
|
|
8165
|
+
validateTaggedValue(entry, path, state);
|
|
8166
|
+
continue;
|
|
8167
|
+
}
|
|
8072
8168
|
if (entry.kind === "boxed") {
|
|
8073
8169
|
validateBoxedRecord(entry, path, heap);
|
|
8074
8170
|
continue;
|
|
@@ -8200,6 +8296,11 @@ function validateTaggedValue(record2, path, state) {
|
|
|
8200
8296
|
requireString(record2.source, `${path}.source`, state.limits);
|
|
8201
8297
|
requireString(record2.flags, `${path}.flags`, state.limits);
|
|
8202
8298
|
if (!Object.hasOwn(record2, "lastIndex")) fail("invalidValue", `${path}.lastIndex`, "missing regex cursor");
|
|
8299
|
+
try {
|
|
8300
|
+
validateRegexProperties(record2);
|
|
8301
|
+
} catch {
|
|
8302
|
+
fail("invalidValue", path, "invalid RegExp property data");
|
|
8303
|
+
}
|
|
8203
8304
|
return;
|
|
8204
8305
|
case "array":
|
|
8205
8306
|
case "arguments":
|
|
@@ -8249,7 +8350,7 @@ function validateGeneratorShape(record2, path, state) {
|
|
|
8249
8350
|
}
|
|
8250
8351
|
function validateSymbolEntries(record2, path, state, heap) {
|
|
8251
8352
|
if (record2.symbolEntries === void 0) return;
|
|
8252
|
-
if (record2.kind !== "object" && record2.kind !== "array" && record2.kind !== "date" && record2.kind !== "boxed")
|
|
8353
|
+
if (record2.kind !== "object" && record2.kind !== "array" && record2.kind !== "date" && record2.kind !== "boxed" && record2.kind !== "regex-object")
|
|
8253
8354
|
fail("invalidValue", `${path}.symbolEntries`, "symbol properties are unsupported for this heap kind");
|
|
8254
8355
|
const entries = requireArray(record2.symbolEntries, `${path}.symbolEntries`, state);
|
|
8255
8356
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -10138,10 +10239,11 @@ function escapeRegexSource(source, budget) {
|
|
|
10138
10239
|
return budget === void 0 ? text : budget.allocateString(text);
|
|
10139
10240
|
}
|
|
10140
10241
|
function setRegexMember(target, property, value) {
|
|
10141
|
-
|
|
10242
|
+
const properties = getRegexProperties(target);
|
|
10243
|
+
if (!Object.hasOwn(properties, property) && (property === "source" || property === "flags" || Object.hasOwn(regexFlagProperties, property))) {
|
|
10142
10244
|
throw new TypeError(`RegExp#${String(property)} is not writable.`);
|
|
10143
10245
|
}
|
|
10144
|
-
|
|
10246
|
+
if (!Reflect.set(properties, property, value)) throw new TypeError(`RegExp#${String(property)} is not writable.`);
|
|
10145
10247
|
}
|
|
10146
10248
|
async function callRegexMethod(target, methodName, args, budget, context) {
|
|
10147
10249
|
if (target === null || typeof target !== "object" || methodName === "exec" && !isSandboxRegex(target)) {
|
|
@@ -10953,14 +11055,14 @@ function createObjectArrayGlobals(options) {
|
|
|
10953
11055
|
call: ([value]) => {
|
|
10954
11056
|
if (isGuestHostObject(value))
|
|
10955
11057
|
throw new TypeError("Live host objects cannot be made non-extensible.");
|
|
10956
|
-
Object.preventExtensions(isGuestClosure(value) ? materializeFunctionProperties(value) : value);
|
|
11058
|
+
Object.preventExtensions(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value);
|
|
10957
11059
|
return value;
|
|
10958
11060
|
},
|
|
10959
11061
|
name: "preventExtensions"
|
|
10960
11062
|
}),
|
|
10961
11063
|
isExtensible: createSandboxClosure({
|
|
10962
11064
|
sandbox: true,
|
|
10963
|
-
call: ([value]) => Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : value),
|
|
11065
|
+
call: ([value]) => Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value),
|
|
10964
11066
|
name: "isExtensible"
|
|
10965
11067
|
}),
|
|
10966
11068
|
seal: createSandboxClosure({
|
|
@@ -10968,14 +11070,14 @@ function createObjectArrayGlobals(options) {
|
|
|
10968
11070
|
call: ([value]) => {
|
|
10969
11071
|
if (isGuestHostObject(value))
|
|
10970
11072
|
throw new TypeError("Live host objects cannot be sealed.");
|
|
10971
|
-
Object.seal(isGuestClosure(value) ? materializeFunctionProperties(value) : value);
|
|
11073
|
+
Object.seal(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value);
|
|
10972
11074
|
return value;
|
|
10973
11075
|
},
|
|
10974
11076
|
name: "seal"
|
|
10975
11077
|
}),
|
|
10976
11078
|
isSealed: createSandboxClosure({
|
|
10977
11079
|
sandbox: true,
|
|
10978
|
-
call: ([value]) => Object.isSealed(isGuestClosure(value) ? materializeFunctionProperties(value) : value),
|
|
11080
|
+
call: ([value]) => Object.isSealed(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value),
|
|
10979
11081
|
name: "isSealed"
|
|
10980
11082
|
}),
|
|
10981
11083
|
freeze: createSandboxClosure({
|
|
@@ -10984,7 +11086,7 @@ function createObjectArrayGlobals(options) {
|
|
|
10984
11086
|
if (isGuestHostObject(value))
|
|
10985
11087
|
throw new TypeError("Live host objects cannot be frozen.");
|
|
10986
11088
|
if (typeof value === "object" && value !== null) {
|
|
10987
|
-
Object.freeze(isGuestClosure(value) ? materializeFunctionProperties(value) : value);
|
|
11089
|
+
Object.freeze(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value);
|
|
10988
11090
|
}
|
|
10989
11091
|
return value;
|
|
10990
11092
|
},
|
|
@@ -10992,7 +11094,7 @@ function createObjectArrayGlobals(options) {
|
|
|
10992
11094
|
}),
|
|
10993
11095
|
isFrozen: createSandboxClosure({
|
|
10994
11096
|
sandbox: true,
|
|
10995
|
-
call: ([value]) => Object.isFrozen(isGuestClosure(value) ? materializeFunctionProperties(value) : value),
|
|
11097
|
+
call: ([value]) => Object.isFrozen(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value),
|
|
10996
11098
|
name: "isFrozen"
|
|
10997
11099
|
}),
|
|
10998
11100
|
assign: createSandboxClosure({
|
|
@@ -11196,6 +11298,7 @@ function assignSandboxValues(target, sources, budget, context) {
|
|
|
11196
11298
|
})();
|
|
11197
11299
|
}
|
|
11198
11300
|
function objectProperties(value, mutable = false) {
|
|
11301
|
+
if (isSandboxRegex(value)) return getRegexProperties(value);
|
|
11199
11302
|
if (isSandboxDate(value)) {
|
|
11200
11303
|
return value;
|
|
11201
11304
|
}
|
|
@@ -15464,7 +15567,7 @@ async function evaluateDeleteExpression(node, context) {
|
|
|
15464
15567
|
}
|
|
15465
15568
|
throw new TypeError("Cannot delete properties of null or undefined.");
|
|
15466
15569
|
}
|
|
15467
|
-
if (!isIndexableSandboxValue(member.object)) {
|
|
15570
|
+
if (!isIndexableSandboxValue(member.object) && !isSandboxRegex(member.object)) {
|
|
15468
15571
|
throw new TypeError("Unary operator 'delete' requires a sandbox object property.");
|
|
15469
15572
|
}
|
|
15470
15573
|
const property = await toPropertyKey(member.property, context.budget, createCoercionContext(context));
|
|
@@ -15867,10 +15970,10 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
15867
15970
|
member.object
|
|
15868
15971
|
);
|
|
15869
15972
|
}
|
|
15870
|
-
if (isSandboxRegex(member.object)
|
|
15973
|
+
if (isSandboxRegex(member.object)) {
|
|
15871
15974
|
return evaluateResolvedCallExpression(
|
|
15872
15975
|
node,
|
|
15873
|
-
|
|
15976
|
+
await getPropertyValue(member.object, member.property, context),
|
|
15874
15977
|
context,
|
|
15875
15978
|
member.object
|
|
15876
15979
|
);
|
|
@@ -16371,7 +16474,6 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
|
|
|
16371
16474
|
return;
|
|
16372
16475
|
}
|
|
16373
16476
|
if (isSandboxRegex(target)) {
|
|
16374
|
-
if (typeof property === "symbol") throw new TypeError("RegExp symbol properties are not yet supported.");
|
|
16375
16477
|
setRegexMember(target, property, value);
|
|
16376
16478
|
return;
|
|
16377
16479
|
}
|
|
@@ -16433,6 +16535,7 @@ function setSuperProperty(base, receiver, key, value, context) {
|
|
|
16433
16535
|
function deleteSandboxProperty(target, property) {
|
|
16434
16536
|
if (isGuestHostObject(target)) return deleteHostObjectMember(target, String(property));
|
|
16435
16537
|
if (isGuestClosure(target)) target = materializeFunctionProperties(target);
|
|
16538
|
+
if (isSandboxRegex(target)) target = getRegexProperties(target);
|
|
16436
16539
|
if (Array.isArray(target)) {
|
|
16437
16540
|
assertCollectionMutable(target);
|
|
16438
16541
|
}
|
|
@@ -17141,7 +17244,8 @@ function encodeReplayData(value, options = {}) {
|
|
|
17141
17244
|
kind: "regex",
|
|
17142
17245
|
source: entry.source,
|
|
17143
17246
|
flags: entry.flags,
|
|
17144
|
-
lastIndex: child(entry.lastIndex, "lastIndex")
|
|
17247
|
+
lastIndex: child(entry.lastIndex, "lastIndex"),
|
|
17248
|
+
...serializeRegexProperties(entry, (value2) => child(value2, "<regex-property>"))
|
|
17145
17249
|
};
|
|
17146
17250
|
} else if (isSandboxArguments(entry)) {
|
|
17147
17251
|
nodes[id] = { kind: "arguments", data: serializeArguments(entry, child) };
|
|
@@ -17344,6 +17448,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
17344
17448
|
const result3 = createSandboxRegex(node.source, node.flags, 0, compilation);
|
|
17345
17449
|
restored.set(id, result3);
|
|
17346
17450
|
result3.lastIndex = child(own(node, "lastIndex"));
|
|
17451
|
+
restoreRegexProperties(result3, node, child);
|
|
17347
17452
|
return result3;
|
|
17348
17453
|
}
|
|
17349
17454
|
if (kind === "arguments") {
|
|
@@ -18826,7 +18931,7 @@ function hasOwnSandboxProperty(value, key, enumerable) {
|
|
|
18826
18931
|
properties = value.properties ?? /* @__PURE__ */ Object.create(null);
|
|
18827
18932
|
} else if (isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxGenerator(value))
|
|
18828
18933
|
return false;
|
|
18829
|
-
else if (isSandboxRegex(value))
|
|
18934
|
+
else if (isSandboxRegex(value)) properties = getRegexProperties(value);
|
|
18830
18935
|
else properties = Object(value);
|
|
18831
18936
|
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
18832
18937
|
return descriptor !== void 0 && (!enumerable || descriptor.enumerable === true);
|
|
@@ -20373,6 +20478,7 @@ function ownEnumerableSandboxEntries(value, excludedKeys) {
|
|
|
20373
20478
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
20374
20479
|
let entries;
|
|
20375
20480
|
if (isGuestClosure(value)) entries = Object.entries(value.properties ?? {});
|
|
20481
|
+
else if (isSandboxRegex(value)) entries = Object.entries(getRegexProperties(value));
|
|
20376
20482
|
else if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
20377
20483
|
else entries = Object.entries(Object(value));
|
|
20378
20484
|
return excludedKeys === void 0 ? entries : entries.filter(([key]) => !excludedKeys.has(key));
|
|
@@ -20381,17 +20487,19 @@ function ownSandboxSymbolKeys(value) {
|
|
|
20381
20487
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
20382
20488
|
if (isGuestHostObject(value)) return [];
|
|
20383
20489
|
if (isSandboxClosure(value)) value = value.properties ?? {};
|
|
20490
|
+
else if (isSandboxRegex(value)) value = getRegexProperties(value);
|
|
20384
20491
|
else if (isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
20385
20492
|
return Object.getOwnPropertySymbols(Object(value)).filter((key) => !internalSymbols.has(key));
|
|
20386
20493
|
}
|
|
20387
20494
|
function ownEnumerableSandboxKeys(value, includeSymbols = false) {
|
|
20388
20495
|
if (includeSymbols) {
|
|
20389
|
-
const properties = isSandboxClosure(value) ? value.properties ?? {} : Object(value);
|
|
20496
|
+
const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxRegex(value) ? getRegexProperties(value) : Object(value);
|
|
20390
20497
|
return [...ownEnumerableSandboxKeys(value), ...ownSandboxSymbolKeys(value).filter((key) => Object.getOwnPropertyDescriptor(properties, key)?.enumerable === true)];
|
|
20391
20498
|
}
|
|
20392
20499
|
if (isGuestHostObject(value)) return getHostObjectKeys(value);
|
|
20393
20500
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
20394
20501
|
if (isGuestClosure(value)) return Object.keys(value.properties ?? {});
|
|
20502
|
+
if (isSandboxRegex(value)) return Object.keys(getRegexProperties(value));
|
|
20395
20503
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
20396
20504
|
return Object.keys(Object(value));
|
|
20397
20505
|
}
|
|
@@ -20483,6 +20591,28 @@ function createSandboxRegex(source, flags = "", lastIndex = 0, compilation) {
|
|
|
20483
20591
|
}
|
|
20484
20592
|
const pattern = parseRegex(source, flags, compilation, 7 + source.length + flags.length);
|
|
20485
20593
|
const regex = { kind: "regex", source, flags, lastIndex };
|
|
20594
|
+
const storage = /* @__PURE__ */ Object.create(null);
|
|
20595
|
+
Object.defineProperty(storage, "lastIndex", { value: lastIndex, writable: true });
|
|
20596
|
+
const syncCursor = () => {
|
|
20597
|
+
const descriptor = Object.getOwnPropertyDescriptor(regex, "lastIndex");
|
|
20598
|
+
Object.defineProperty(storage, "lastIndex", { value: descriptor.value, writable: descriptor.writable });
|
|
20599
|
+
};
|
|
20600
|
+
const properties = new Proxy(storage, {
|
|
20601
|
+
get: (target, key, receiver) => key === "lastIndex" ? regex.lastIndex : Reflect.get(target, key, receiver),
|
|
20602
|
+
set: (target, key, value, receiver) => key === "lastIndex" ? Reflect.set(regex, key, value) : Reflect.set(target, key, value, receiver),
|
|
20603
|
+
getOwnPropertyDescriptor(target, key) {
|
|
20604
|
+
if (key === "lastIndex") syncCursor();
|
|
20605
|
+
return Object.getOwnPropertyDescriptor(target, key);
|
|
20606
|
+
},
|
|
20607
|
+
defineProperty(target, key, descriptor) {
|
|
20608
|
+
if (key !== "lastIndex") return Reflect.defineProperty(target, key, descriptor);
|
|
20609
|
+
syncCursor();
|
|
20610
|
+
if (!Reflect.defineProperty(target, key, descriptor)) return false;
|
|
20611
|
+
const cursor = Object.getOwnPropertyDescriptor(target, key);
|
|
20612
|
+
return Reflect.defineProperty(regex, key, { value: cursor.value, writable: cursor.writable });
|
|
20613
|
+
}
|
|
20614
|
+
});
|
|
20615
|
+
regexGuestProperties.set(regex, properties);
|
|
20486
20616
|
Object.defineProperties(regex, {
|
|
20487
20617
|
[sandboxRegexBrand]: { value: true },
|
|
20488
20618
|
[sandboxRegexPattern]: { value: pattern }
|
|
@@ -20658,6 +20788,14 @@ function measureSandboxData(values, options = {}) {
|
|
|
20658
20788
|
usage += Math.max(6 + source.length + flags.length + compiled.units, staged - 1);
|
|
20659
20789
|
if (compiled.ticket !== void 0) options.compileTickets?.add(compiled.ticket);
|
|
20660
20790
|
visit(lastIndex, depth + 1);
|
|
20791
|
+
for (const key of Reflect.ownKeys(getRegexProperties(value))) {
|
|
20792
|
+
if (key === "lastIndex") continue;
|
|
20793
|
+
const descriptor = Object.getOwnPropertyDescriptor(getRegexProperties(value), key);
|
|
20794
|
+
usage += 1 + (typeof key === "string" ? key.length : 0);
|
|
20795
|
+
if (typeof key === "symbol") visit(key, depth + 1);
|
|
20796
|
+
if ("value" in descriptor) visit(descriptor.value, depth + 1);
|
|
20797
|
+
else for (const closure of retainedAccessorClosures(descriptor)) visit(closure, depth + 1);
|
|
20798
|
+
}
|
|
20661
20799
|
return;
|
|
20662
20800
|
}
|
|
20663
20801
|
if (isSandboxArguments(value)) {
|
|
@@ -20718,7 +20856,7 @@ function captureRegexData(value) {
|
|
|
20718
20856
|
"Invalid sandbox RegExp source or flags: expected own string data properties."
|
|
20719
20857
|
);
|
|
20720
20858
|
}
|
|
20721
|
-
const cursor = Object.getOwnPropertyDescriptor(value, "lastIndex");
|
|
20859
|
+
const cursor = Object.getOwnPropertyDescriptor(regexGuestProperties.get(value) ?? value, "lastIndex");
|
|
20722
20860
|
if (cursor === void 0 || !("value" in cursor)) {
|
|
20723
20861
|
throw new TypeError("Invalid sandbox RegExp lastIndex: expected an own data property.");
|
|
20724
20862
|
}
|
|
@@ -20747,6 +20885,18 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
20747
20885
|
const copy = createSandboxRegex(value.source, value.flags, 0, state.compilation);
|
|
20748
20886
|
state.seen.set(value, copy);
|
|
20749
20887
|
if (!state.resetRegexLastIndex) copy.lastIndex = copyToSandbox(value.lastIndex, state, `${path}.lastIndex`, true, depth + 1);
|
|
20888
|
+
if (!state.structuredClone) {
|
|
20889
|
+
const properties = getRegexProperties(value);
|
|
20890
|
+
for (const key of Reflect.ownKeys(properties)) {
|
|
20891
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
20892
|
+
if (!("value" in descriptor)) throw new TypeError("RegExp accessor properties cannot be copied as data.");
|
|
20893
|
+
Object.defineProperty(getRegexProperties(copy), key, {
|
|
20894
|
+
...descriptor,
|
|
20895
|
+
value: key === "lastIndex" && state.resetRegexLastIndex ? 0 : copyToSandbox(descriptor.value, state, `${path}.${String(key)}`, true, depth + 1)
|
|
20896
|
+
});
|
|
20897
|
+
}
|
|
20898
|
+
if (!Object.isExtensible(properties)) Object.preventExtensions(getRegexProperties(copy));
|
|
20899
|
+
}
|
|
20750
20900
|
return copy;
|
|
20751
20901
|
}
|
|
20752
20902
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxPromise(value)) {
|
|
@@ -20995,6 +21145,18 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
20995
21145
|
const regex = new RegExp(source, flags);
|
|
20996
21146
|
state.seen.set(value, regex);
|
|
20997
21147
|
Reflect.set(regex, "lastIndex", copyFromSandbox(lastIndex, state, `${path}.lastIndex`, options, depth + 1));
|
|
21148
|
+
const properties = regexGuestProperties.get(value);
|
|
21149
|
+
if (properties !== void 0) {
|
|
21150
|
+
for (const key of Reflect.ownKeys(properties)) {
|
|
21151
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
21152
|
+
if (!("value" in descriptor)) throw new TypeError("RegExp accessor properties cannot be copied as data.");
|
|
21153
|
+
Object.defineProperty(regex, key, {
|
|
21154
|
+
...descriptor,
|
|
21155
|
+
value: copyFromSandbox(descriptor.value, state, `${path}.${String(key)}`, options, depth + 1)
|
|
21156
|
+
});
|
|
21157
|
+
}
|
|
21158
|
+
if (!Object.isExtensible(properties)) Object.preventExtensions(regex);
|
|
21159
|
+
}
|
|
20998
21160
|
guard.retainScratch();
|
|
20999
21161
|
return regex;
|
|
21000
21162
|
} finally {
|
|
@@ -35945,7 +36107,6 @@ export {
|
|
|
35945
36107
|
parse,
|
|
35946
36108
|
parseModule,
|
|
35947
36109
|
hashSource,
|
|
35948
|
-
defineExtension,
|
|
35949
36110
|
noopOtelSink,
|
|
35950
36111
|
bindOtelSpan,
|
|
35951
36112
|
activateOtelSpan,
|
|
@@ -35954,6 +36115,7 @@ export {
|
|
|
35954
36115
|
safeAddEvent,
|
|
35955
36116
|
safeRecordException,
|
|
35956
36117
|
safeEndSpan,
|
|
36118
|
+
defineExtension,
|
|
35957
36119
|
encodeReplayData,
|
|
35958
36120
|
HostOperationResumePolicyError,
|
|
35959
36121
|
registerPendingHostCallPolicy,
|
|
@@ -35986,4 +36148,4 @@ export {
|
|
|
35986
36148
|
FileSnapshotBackend,
|
|
35987
36149
|
run
|
|
35988
36150
|
};
|
|
35989
|
-
//# sourceMappingURL=chunk-
|
|
36151
|
+
//# sourceMappingURL=chunk-WPI4GGVU.js.map
|