@poe-platform/safe-js 0.1.725 → 0.1.727
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/README.md +12 -0
- package/dist/safe-js/chunks/{chunk-ECTNNLWN.js → chunk-4QDOJTAL.js} +4 -4
- package/dist/safe-js/chunks/{chunk-Y7LSEUWV.js → chunk-EBNKJYZV.js} +3 -3
- package/dist/safe-js/chunks/{chunk-HG5QP5UC.js → chunk-EG3QWREA.js} +2 -2
- package/dist/safe-js/chunks/{chunk-V2ESZF34.js → chunk-EZEB4AIH.js} +4 -4
- package/dist/safe-js/chunks/{chunk-K6F5QLZQ.js → chunk-GZT57PW4.js} +3 -3
- package/dist/safe-js/chunks/{chunk-6YSHQ5ET.js → chunk-IZX26NC7.js} +2 -2
- package/dist/safe-js/chunks/{chunk-6OE64YMG.js → chunk-MFCEBCGV.js} +2 -2
- package/dist/safe-js/chunks/{chunk-PKRGP34X.js → chunk-RXESEKV6.js} +6 -6
- package/dist/safe-js/chunks/{chunk-O2CPPE6M.js → chunk-TFLQJ5NE.js} +2 -2
- package/dist/safe-js/chunks/{chunk-FYSWUSHN.js → chunk-VW2VLHK2.js} +3 -3
- package/dist/safe-js/chunks/{chunk-KOO6YGQG.js → chunk-Y5EZYHU6.js} +86 -29
- package/dist/safe-js/chunks/chunk-Y5EZYHU6.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-QU2F65UQ.js → chunk-ZSIY6K54.js} +47 -5
- package/dist/safe-js/chunks/{chunk-QU2F65UQ.js.map → chunk-ZSIY6K54.js.map} +2 -2
- package/dist/safe-js/chunks/{chunk-YRALPIEZ.js → chunk-ZTKMQHXB.js} +2 -2
- package/dist/safe-js/chunks/{cli-runtime-5HVEFMDB.js → cli-runtime-OZPDDD6M.js} +13 -13
- package/dist/safe-js/chunks/{dump-VKSKINUI.js → dump-3TMEMH6D.js} +4 -4
- package/dist/safe-js/chunks/{fs-CZ2TAPHK.js → fs-YSBEA2WW.js} +4 -4
- package/dist/safe-js/chunks/harness-YC3FLN5N.js +10 -0
- package/dist/safe-js/chunks/mcp-3GOG43VR.js +11 -0
- package/dist/safe-js/chunks/migration-file-IFKOIPNA.js +12 -0
- package/dist/safe-js/chunks/restore-ZOAQTM7X.js +13 -0
- package/dist/safe-js/chunks/run-XH62V323.js +17 -0
- package/dist/safe-js/chunks/runtime-modules-BUR3QGOJ.js +10 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +7 -7
- package/dist/safe-js/index.js +13 -13
- package/dist/safe-js/interp/budget.d.ts +1 -0
- package/dist/safe-js/parse/tokenizer.d.ts +1 -1
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-KOO6YGQG.js.map +0 -7
- package/dist/safe-js/chunks/harness-WNABEKDH.js +0 -10
- package/dist/safe-js/chunks/mcp-ZZDGN5CA.js +0 -11
- package/dist/safe-js/chunks/migration-file-QVT4W464.js +0 -12
- package/dist/safe-js/chunks/restore-PTIQHGKI.js +0 -13
- package/dist/safe-js/chunks/run-WNR7QYUJ.js +0 -17
- package/dist/safe-js/chunks/runtime-modules-YEOG62RU.js +0 -10
- /package/dist/safe-js/chunks/{chunk-ECTNNLWN.js.map → chunk-4QDOJTAL.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-Y7LSEUWV.js.map → chunk-EBNKJYZV.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-HG5QP5UC.js.map → chunk-EG3QWREA.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-V2ESZF34.js.map → chunk-EZEB4AIH.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-K6F5QLZQ.js.map → chunk-GZT57PW4.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-6YSHQ5ET.js.map → chunk-IZX26NC7.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-6OE64YMG.js.map → chunk-MFCEBCGV.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-PKRGP34X.js.map → chunk-RXESEKV6.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-O2CPPE6M.js.map → chunk-TFLQJ5NE.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-FYSWUSHN.js.map → chunk-VW2VLHK2.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-YRALPIEZ.js.map → chunk-ZTKMQHXB.js.map} +0 -0
- /package/dist/safe-js/chunks/{cli-runtime-5HVEFMDB.js.map → cli-runtime-OZPDDD6M.js.map} +0 -0
- /package/dist/safe-js/chunks/{dump-VKSKINUI.js.map → dump-3TMEMH6D.js.map} +0 -0
- /package/dist/safe-js/chunks/{fs-CZ2TAPHK.js.map → fs-YSBEA2WW.js.map} +0 -0
- /package/dist/safe-js/chunks/{harness-WNABEKDH.js.map → harness-YC3FLN5N.js.map} +0 -0
- /package/dist/safe-js/chunks/{mcp-ZZDGN5CA.js.map → mcp-3GOG43VR.js.map} +0 -0
- /package/dist/safe-js/chunks/{migration-file-QVT4W464.js.map → migration-file-IFKOIPNA.js.map} +0 -0
- /package/dist/safe-js/chunks/{restore-PTIQHGKI.js.map → restore-ZOAQTM7X.js.map} +0 -0
- /package/dist/safe-js/chunks/{run-WNR7QYUJ.js.map → run-XH62V323.js.map} +0 -0
- /package/dist/safe-js/chunks/{runtime-modules-YEOG62RU.js.map → runtime-modules-BUR3QGOJ.js.map} +0 -0
package/README.md
CHANGED
|
@@ -53,6 +53,18 @@ console.log(result.returnValue);
|
|
|
53
53
|
|
|
54
54
|
Scripts have no ambient `process`, `require`, `fetch`, or filesystem access. Host functions still execute with the host's privileges. Register only the capabilities the script needs; this is not OS or process isolation.
|
|
55
55
|
|
|
56
|
+
`new Promise(executor)` is supported, as are the Promise static helpers and
|
|
57
|
+
`then`, `catch`, and `finally`. The executor runs synchronously with `resolve`
|
|
58
|
+
and `reject`; its return value is ignored, thrown errors reject the promise,
|
|
59
|
+
and the first resolve or reject call wins. Resolving adopts promises and
|
|
60
|
+
thenables; resolving a promise with itself rejects with a `TypeError`.
|
|
61
|
+
Executor work uses the interpreter's existing budgets, and budget exhaustion
|
|
62
|
+
remains fatal even after settlement. For example,
|
|
63
|
+
`await run("return await new Promise(resolve => resolve(42));")` returns a
|
|
64
|
+
successful result with `returnValue: 42`. Browser event and timer adapters
|
|
65
|
+
require the host to grant those capabilities; Promise construction does not
|
|
66
|
+
provide ambient browser APIs.
|
|
67
|
+
|
|
56
68
|
```js
|
|
57
69
|
const result = await run(`
|
|
58
70
|
function Counter(value) { this.value = value; }
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
validateMigrationReconciliation,
|
|
8
8
|
validateMigrationSemantics,
|
|
9
9
|
validateSnapshotMigration
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EBNKJYZV.js";
|
|
11
11
|
import {
|
|
12
12
|
DUMP_FORMAT_VERSION,
|
|
13
13
|
EXECUTION_SEMANTICS,
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
serializeSafeJSSnapshot,
|
|
18
18
|
validateDumpEnvelope,
|
|
19
19
|
validateSnapshotData
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ZSIY6K54.js";
|
|
21
21
|
import {
|
|
22
22
|
parseModule
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-Y5EZYHU6.js";
|
|
24
24
|
|
|
25
25
|
// packages/safe-js/src/migration-file.ts
|
|
26
26
|
import { randomUUID } from "node:crypto";
|
|
@@ -179,4 +179,4 @@ export {
|
|
|
179
179
|
migrateSnapshot,
|
|
180
180
|
migrateSnapshotFile
|
|
181
181
|
};
|
|
182
|
-
//# sourceMappingURL=chunk-
|
|
182
|
+
//# sourceMappingURL=chunk-4QDOJTAL.js.map
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
HostCallJournal,
|
|
3
3
|
decodeReplayData,
|
|
4
4
|
validateSnapshotData
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZSIY6K54.js";
|
|
6
6
|
import {
|
|
7
7
|
CompileScope,
|
|
8
8
|
SandboxError,
|
|
9
9
|
functionSources,
|
|
10
10
|
parse,
|
|
11
11
|
parseModule
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Y5EZYHU6.js";
|
|
13
13
|
|
|
14
14
|
// packages/safe-js/src/parse/hash.ts
|
|
15
15
|
var FNV_OFFSET_BASIS = 2166136261;
|
|
@@ -219,4 +219,4 @@ export {
|
|
|
219
219
|
validateMigrationReconciliation,
|
|
220
220
|
validateSnapshotMigration
|
|
221
221
|
};
|
|
222
|
-
//# sourceMappingURL=chunk-
|
|
222
|
+
//# sourceMappingURL=chunk-EBNKJYZV.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
numericTypedArrayConstructors,
|
|
9
9
|
parseModule,
|
|
10
10
|
tokenize
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-Y5EZYHU6.js";
|
|
12
12
|
|
|
13
13
|
// packages/safe-js/src/lint/rules/AS001.ts
|
|
14
14
|
function AS001(source, options = {}) {
|
|
@@ -11177,4 +11177,4 @@ function hasOnlyRegexLiteralDiagnostics(diagnostics) {
|
|
|
11177
11177
|
export {
|
|
11178
11178
|
lint
|
|
11179
11179
|
};
|
|
11180
|
-
//# sourceMappingURL=chunk-
|
|
11180
|
+
//# sourceMappingURL=chunk-EG3QWREA.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
hashParsedAst,
|
|
3
3
|
hashSource,
|
|
4
4
|
validateSnapshotMigration
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EBNKJYZV.js";
|
|
6
6
|
import {
|
|
7
7
|
SnapshotValidationError,
|
|
8
8
|
assertSnapshotInactive,
|
|
@@ -15,13 +15,13 @@ import {
|
|
|
15
15
|
validateGuestFunctionAst,
|
|
16
16
|
validateRuntimeSnapshotDescriptors,
|
|
17
17
|
validateTemplateObjects
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ZSIY6K54.js";
|
|
19
19
|
import {
|
|
20
20
|
ParseError,
|
|
21
21
|
parseExecutableModule,
|
|
22
22
|
parseModule,
|
|
23
23
|
replaceErrorStack
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-Y5EZYHU6.js";
|
|
25
25
|
|
|
26
26
|
// packages/safe-js/src/restore.ts
|
|
27
27
|
var SnapshotMismatchError = class extends Error {
|
|
@@ -111,4 +111,4 @@ export {
|
|
|
111
111
|
SnapshotMismatchError,
|
|
112
112
|
restore
|
|
113
113
|
};
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-EZEB4AIH.js.map
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
declareHostOperation,
|
|
8
8
|
runResources
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZSIY6K54.js";
|
|
10
10
|
import {
|
|
11
11
|
hostErrorData
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Y5EZYHU6.js";
|
|
13
13
|
|
|
14
14
|
// packages/safe-js/src/modules/mcp.ts
|
|
15
15
|
var DEFAULT_TOOL_BATCH_CONCURRENCY = 4;
|
|
@@ -402,4 +402,4 @@ function isPlainObjectRecord(value) {
|
|
|
402
402
|
export {
|
|
403
403
|
makeMcpModule
|
|
404
404
|
};
|
|
405
|
-
//# sourceMappingURL=chunk-
|
|
405
|
+
//# sourceMappingURL=chunk-GZT57PW4.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
accessDeniedSystemError,
|
|
6
6
|
declareBudgetedHostOperation,
|
|
7
7
|
declareHostOperation
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZSIY6K54.js";
|
|
9
9
|
|
|
10
10
|
// packages/safe-js/src/modules/fs.ts
|
|
11
11
|
import { constants as nodeFsConstants } from "node:fs";
|
|
@@ -721,4 +721,4 @@ export {
|
|
|
721
721
|
FS_OPTION_SURFACE,
|
|
722
722
|
makeFsModule
|
|
723
723
|
};
|
|
724
|
-
//# sourceMappingURL=chunk-
|
|
724
|
+
//# sourceMappingURL=chunk-IZX26NC7.js.map
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
safeRecordException,
|
|
15
15
|
safeStartSpan,
|
|
16
16
|
splitSourceLines
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-Y5EZYHU6.js";
|
|
18
18
|
|
|
19
19
|
// packages/safe-js/src/error/format.ts
|
|
20
20
|
var DEFAULT_MAX_MESSAGE_LENGTH = 1e4;
|
|
@@ -2841,4 +2841,4 @@ export {
|
|
|
2841
2841
|
makeLogModule,
|
|
2842
2842
|
makeMetricModule
|
|
2843
2843
|
};
|
|
2844
|
-
//# sourceMappingURL=chunk-
|
|
2844
|
+
//# sourceMappingURL=chunk-MFCEBCGV.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
restore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EZEB4AIH.js";
|
|
4
4
|
import {
|
|
5
5
|
attachDumpController,
|
|
6
6
|
createDumpController
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VW2VLHK2.js";
|
|
8
8
|
import {
|
|
9
9
|
getOwnErrorCode,
|
|
10
10
|
hasOwnErrorCode
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
hashParsedAst,
|
|
14
14
|
hashSource
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EBNKJYZV.js";
|
|
16
16
|
import {
|
|
17
17
|
DUMP_FORMAT_VERSION,
|
|
18
18
|
EXECUTION_SEMANTICS,
|
|
@@ -100,7 +100,7 @@ import {
|
|
|
100
100
|
withSandboxPromiseRejectionTracker,
|
|
101
101
|
wrapCallerInjectedBindings,
|
|
102
102
|
wrapCancelableBindings
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-ZSIY6K54.js";
|
|
104
104
|
import {
|
|
105
105
|
Budget,
|
|
106
106
|
CompileScope,
|
|
@@ -115,7 +115,7 @@ import {
|
|
|
115
115
|
parseSourceModule,
|
|
116
116
|
replaceErrorStack,
|
|
117
117
|
safeAddEvent
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-Y5EZYHU6.js";
|
|
119
119
|
|
|
120
120
|
// packages/safe-js/src/realm.ts
|
|
121
121
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
@@ -2825,4 +2825,4 @@ export {
|
|
|
2825
2825
|
UnhandledRejectionError,
|
|
2826
2826
|
run
|
|
2827
2827
|
};
|
|
2828
|
-
//# sourceMappingURL=chunk-
|
|
2828
|
+
//# sourceMappingURL=chunk-RXESEKV6.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deepCopyToSandbox
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZSIY6K54.js";
|
|
4
4
|
|
|
5
5
|
// packages/safe-js/src/modules/harness.ts
|
|
6
6
|
function makeHarnessModule(frontmatter, meta) {
|
|
@@ -52,4 +52,4 @@ ${prompt}`;
|
|
|
52
52
|
export {
|
|
53
53
|
makeHarnessModule
|
|
54
54
|
};
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-TFLQJ5NE.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SnapshotNotReadyError,
|
|
3
3
|
serializeSafeJSSnapshot
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZSIY6K54.js";
|
|
5
5
|
import {
|
|
6
6
|
SandboxError
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Y5EZYHU6.js";
|
|
8
8
|
|
|
9
9
|
// packages/safe-js/src/snapshot/dump.ts
|
|
10
10
|
var RUN_DUMP_CONTROLLER = /* @__PURE__ */ Symbol("SafeJS.run-dump-controller");
|
|
@@ -195,4 +195,4 @@ export {
|
|
|
195
195
|
dumpCurrent,
|
|
196
196
|
serializeRunSnapshot
|
|
197
197
|
};
|
|
198
|
-
//# sourceMappingURL=chunk-
|
|
198
|
+
//# sourceMappingURL=chunk-VW2VLHK2.js.map
|
|
@@ -362,6 +362,15 @@ var Budget = class _Budget {
|
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
|
+
reserveString(length) {
|
|
366
|
+
if (!Number.isSafeInteger(length) || length < 0) {
|
|
367
|
+
throw new RangeError("string length must be a nonnegative safe integer");
|
|
368
|
+
}
|
|
369
|
+
if (this.accounting.allChecksSuspended === 0 && this.accounting.limits.stringLength !== void 0 && length > this.accounting.limits.stringLength) {
|
|
370
|
+
throw new SandboxError({ budget: "stringLength", current: length, limit: this.accounting.limits.stringLength });
|
|
371
|
+
}
|
|
372
|
+
return this.provisionDataUsage(length);
|
|
373
|
+
}
|
|
365
374
|
allocateArrayLength(length) {
|
|
366
375
|
if (this.accounting.allChecksSuspended === 0 && this.accounting.limits.arrayLength !== void 0 && length > this.accounting.limits.arrayLength) {
|
|
367
376
|
throw new SandboxError({
|
|
@@ -2009,8 +2018,30 @@ var stride = 3;
|
|
|
2009
2018
|
var legacyEscape = 256;
|
|
2010
2019
|
var tokenCacheSize = 256;
|
|
2011
2020
|
var CompactTokens = class {
|
|
2012
|
-
constructor(sourcePositions) {
|
|
2021
|
+
constructor(sourcePositions, lazyPositions = false) {
|
|
2013
2022
|
this.sourcePositions = sourcePositions;
|
|
2023
|
+
if (!lazyPositions) return;
|
|
2024
|
+
class ParserToken {
|
|
2025
|
+
constructor(type, value, start, end) {
|
|
2026
|
+
this.type = type;
|
|
2027
|
+
this.value = value;
|
|
2028
|
+
this.#start = start;
|
|
2029
|
+
this.#end = end;
|
|
2030
|
+
}
|
|
2031
|
+
type;
|
|
2032
|
+
value;
|
|
2033
|
+
#start;
|
|
2034
|
+
#end;
|
|
2035
|
+
get start() {
|
|
2036
|
+
if (typeof this.#start === "number") this.#start = sourcePositions.position(this.#start);
|
|
2037
|
+
return this.#start;
|
|
2038
|
+
}
|
|
2039
|
+
get end() {
|
|
2040
|
+
if (typeof this.#end === "number") this.#end = sourcePositions.position(this.#end);
|
|
2041
|
+
return this.#end;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
this.parserToken = (type, value, start, end) => new ParserToken(type, value, start, end);
|
|
2014
2045
|
}
|
|
2015
2046
|
sourcePositions;
|
|
2016
2047
|
rows = new Uint32Array(1024 * stride);
|
|
@@ -2018,6 +2049,7 @@ var CompactTokens = class {
|
|
|
2018
2049
|
templates = /* @__PURE__ */ new Map();
|
|
2019
2050
|
tokens = /* @__PURE__ */ new Map();
|
|
2020
2051
|
last;
|
|
2052
|
+
parserToken;
|
|
2021
2053
|
// Only indexing, iteration, length, push and at are used by the lexer/parser.
|
|
2022
2054
|
// Historical tokens are materialized on demand in a bounded cache.
|
|
2023
2055
|
indexed = new Proxy([], {
|
|
@@ -2065,7 +2097,12 @@ var CompactTokens = class {
|
|
|
2065
2097
|
if (cached !== void 0) return cached;
|
|
2066
2098
|
const base = index * stride;
|
|
2067
2099
|
const bits = this.rows[base + 2];
|
|
2068
|
-
const token =
|
|
2100
|
+
const token = this.parserToken?.(
|
|
2101
|
+
types[bits & 255],
|
|
2102
|
+
this.values[index],
|
|
2103
|
+
this.rows[base],
|
|
2104
|
+
this.rows[base + 1]
|
|
2105
|
+
) ?? {
|
|
2069
2106
|
type: types[bits & 255],
|
|
2070
2107
|
value: this.values[index],
|
|
2071
2108
|
start: this.sourcePositions.position(this.rows[base]),
|
|
@@ -2194,8 +2231,8 @@ function tokenize(source, options = {}) {
|
|
|
2194
2231
|
const lexer = new Lexer(source, options);
|
|
2195
2232
|
return lexer.tokenize();
|
|
2196
2233
|
}
|
|
2197
|
-
function tokenizeCompact(source, options, positions) {
|
|
2198
|
-
const tokens = new CompactTokens(positions);
|
|
2234
|
+
function tokenizeCompact(source, options, positions, lazyPositions = false) {
|
|
2235
|
+
const tokens = new CompactTokens(positions, lazyPositions);
|
|
2199
2236
|
new Lexer(source, { ...options, sharedPositions: true }, tokens.indexed).tokenize();
|
|
2200
2237
|
return tokens.finish();
|
|
2201
2238
|
}
|
|
@@ -4233,7 +4270,7 @@ function parseSourceModule(source, filename = "<input>", owner, options = {}) {
|
|
|
4233
4270
|
throw new SandboxError({ budget: "stringLength", current: source.length, limit });
|
|
4234
4271
|
owner?.budget.visitNode(source.length);
|
|
4235
4272
|
const tokenOptions = { allowRegexLiterals: true, statementList: true, compilation, sharedPositions: options.sharedPositions };
|
|
4236
|
-
const tokens = options.compactAst ? tokenizeCompact(source, tokenOptions, new CompactSourcePositions(source)) : tokenize(source, tokenOptions);
|
|
4273
|
+
const tokens = options.compactAst ? tokenizeCompact(source, tokenOptions, new CompactSourcePositions(source), true) : tokenize(source, tokenOptions);
|
|
4237
4274
|
parser = new Parser(
|
|
4238
4275
|
tokens,
|
|
4239
4276
|
source,
|
|
@@ -4323,7 +4360,7 @@ function parseEvalScript(source, context = {}, owner, filename = "<eval>", optio
|
|
|
4323
4360
|
allowHtmlComments: true,
|
|
4324
4361
|
compilation
|
|
4325
4362
|
};
|
|
4326
|
-
const tokens = options.compactAst ? tokenizeCompact(source, tokenOptions, new CompactSourcePositions(source)) : tokenize(source, tokenOptions);
|
|
4363
|
+
const tokens = options.compactAst ? tokenizeCompact(source, tokenOptions, new CompactSourcePositions(source), true) : tokenize(source, tokenOptions);
|
|
4327
4364
|
const parser = new Parser(tokens, source, compilation, "normal", {
|
|
4328
4365
|
grammar,
|
|
4329
4366
|
newTarget: context.newTarget === true,
|
|
@@ -5012,30 +5049,50 @@ var Parser = class {
|
|
|
5012
5049
|
return { type: "BlockStatement", body: [statement], span: statement.span };
|
|
5013
5050
|
}
|
|
5014
5051
|
parseIfStatement() {
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
throw new Error(
|
|
5018
|
-
`If statement nesting limit exceeded at line ${token.start.line}, column ${token.start.column}.`
|
|
5019
|
-
);
|
|
5020
|
-
}
|
|
5021
|
-
this.ifStatementDepth += 1;
|
|
5052
|
+
const pending = [];
|
|
5053
|
+
let entered = 0;
|
|
5022
5054
|
try {
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5055
|
+
for (; ; ) {
|
|
5056
|
+
if (this.ifStatementDepth >= MAX_IF_STATEMENT_DEPTH) {
|
|
5057
|
+
const token2 = this.currentToken();
|
|
5058
|
+
throw new Error(
|
|
5059
|
+
`If statement nesting limit exceeded at line ${token2.start.line}, column ${token2.start.column}.`
|
|
5060
|
+
);
|
|
5061
|
+
}
|
|
5062
|
+
this.ifStatementDepth++;
|
|
5063
|
+
entered++;
|
|
5064
|
+
const token = this.expectKeyword("if");
|
|
5065
|
+
this.expectPunctuator("(");
|
|
5066
|
+
const test = this.parseExpression({ allowSequence: true }).node;
|
|
5067
|
+
this.expectPunctuator(")");
|
|
5068
|
+
const consequent = this.parseIfClause();
|
|
5069
|
+
const hasElse = this.consumeKeyword("else") !== void 0;
|
|
5070
|
+
if (hasElse && this.currentToken().type === "keyword" && this.currentToken().value === "if") {
|
|
5071
|
+
pending.push({ token, test, consequent });
|
|
5072
|
+
continue;
|
|
5073
|
+
}
|
|
5074
|
+
const alternate = hasElse ? this.parseIfClause() : void 0;
|
|
5075
|
+
let result = {
|
|
5076
|
+
type: "IfStatement",
|
|
5077
|
+
test,
|
|
5078
|
+
consequent,
|
|
5079
|
+
alternate,
|
|
5080
|
+
span: createSpan2(token.start, alternate?.span.end ?? consequent.span.end)
|
|
5081
|
+
};
|
|
5082
|
+
while (pending.length > 0) {
|
|
5083
|
+
const parent = pending.pop();
|
|
5084
|
+
result = {
|
|
5085
|
+
type: "IfStatement",
|
|
5086
|
+
test: parent.test,
|
|
5087
|
+
consequent: parent.consequent,
|
|
5088
|
+
alternate: result,
|
|
5089
|
+
span: createSpan2(parent.token.start, result.span.end)
|
|
5090
|
+
};
|
|
5091
|
+
}
|
|
5092
|
+
return result;
|
|
5093
|
+
}
|
|
5037
5094
|
} finally {
|
|
5038
|
-
this.ifStatementDepth -=
|
|
5095
|
+
this.ifStatementDepth -= entered;
|
|
5039
5096
|
}
|
|
5040
5097
|
}
|
|
5041
5098
|
parseSwitchStatement() {
|
|
@@ -8661,4 +8718,4 @@ export {
|
|
|
8661
8718
|
Float16Array2 as Float16Array,
|
|
8662
8719
|
numericTypedArrayConstructors
|
|
8663
8720
|
};
|
|
8664
|
-
//# sourceMappingURL=chunk-
|
|
8721
|
+
//# sourceMappingURL=chunk-Y5EZYHU6.js.map
|