solve-engine 1.0.0-beta.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BytecodeBuilder-3egMyuDi.d.cts → BytecodeBuilder-B0xskcv5.d.cts} +2 -1
- package/dist/{BytecodeBuilder-3egMyuDi.d.ts → BytecodeBuilder-B0xskcv5.d.ts} +2 -1
- package/dist/{Configuration-fVpd-HC-.d.cts → Configuration-B-G5gTRn.d.cts} +107 -29
- package/dist/{Configuration-fVpd-HC-.d.ts → Configuration-B-G5gTRn.d.ts} +107 -29
- package/dist/{EngineError-DvPSnhZi.d.cts → EngineError-LU7W7AgI.d.cts} +96 -16
- package/dist/{EngineError-DvPSnhZi.d.ts → EngineError-LU7W7AgI.d.ts} +96 -16
- package/dist/{Lexer-W9MBOP0V.d.ts → Lexer-BN5mt30n.d.ts} +16 -0
- package/dist/{Lexer-Cfm79Dak.d.cts → Lexer-D78E2yDW.d.cts} +16 -0
- package/dist/{PackageRegistry-CjDt-Jy_.d.ts → PackageRegistry-DFeINv2O.d.ts} +54 -13
- package/dist/{PackageRegistry-pHtKythi.d.cts → PackageRegistry-u2zdfFaj.d.cts} +54 -13
- package/dist/{Parselet-DEdF9I7n.d.ts → Parselet-BaySkMV3.d.ts} +37 -5
- package/dist/{Parselet-Cu0bLSis.d.cts → Parselet-DuI1Pjiq.d.cts} +37 -5
- package/dist/{ScopeManager-CKfQtl7l.d.cts → ScopeManager-B6GzdhVG.d.cts} +75 -6
- package/dist/{ScopeManager-B5k0nk05.d.ts → ScopeManager-udv4Twwq.d.ts} +75 -6
- package/dist/{VMCheckpoints-BmDwIXgK.d.ts → VMCheckpoints-BiaIlOOY.d.ts} +4 -4
- package/dist/{VMCheckpoints-CqFuLwrT.d.cts → VMCheckpoints-DwLjivM7.d.cts} +4 -4
- package/dist/{Value-KtAQNHur.d.cts → Value-CXJqDH9J.d.cts} +5 -2
- package/dist/{Value-KtAQNHur.d.ts → Value-CXJqDH9J.d.ts} +5 -2
- package/dist/{chunk-CSG5XVNJ.cjs → chunk-3AFRJYP4.cjs} +556 -414
- package/dist/chunk-3AFRJYP4.cjs.map +1 -0
- package/dist/chunk-3BOK2LDK.js +17 -0
- package/dist/chunk-3BOK2LDK.js.map +1 -0
- package/dist/{chunk-6RDSQURE.js → chunk-3D7V24DG.js} +57 -6
- package/dist/chunk-3D7V24DG.js.map +1 -0
- package/dist/{chunk-MEOHSQEH.js → chunk-3LAEG75D.js} +47 -15
- package/dist/chunk-3LAEG75D.js.map +1 -0
- package/dist/{chunk-P75775WC.js → chunk-3VNGREMU.js} +118 -41
- package/dist/chunk-3VNGREMU.js.map +1 -0
- package/dist/{chunk-4AVD7NZW.cjs → chunk-4B2CNWQU.cjs} +13 -7
- package/dist/chunk-4B2CNWQU.cjs.map +1 -0
- package/dist/{chunk-6GCKCWLB.js → chunk-526PMQOA.js} +126 -69
- package/dist/chunk-526PMQOA.js.map +1 -0
- package/dist/{chunk-2CS6OMZK.js → chunk-5F4C26RU.js} +8 -5
- package/dist/chunk-5F4C26RU.js.map +1 -0
- package/dist/{chunk-M4N5GA5Z.cjs → chunk-5KMIY374.cjs} +57 -6
- package/dist/chunk-5KMIY374.cjs.map +1 -0
- package/dist/{chunk-R24DI24X.cjs → chunk-5LI5EPGJ.cjs} +6 -5
- package/dist/chunk-5LI5EPGJ.cjs.map +1 -0
- package/dist/{chunk-BAMZT3GL.js → chunk-5WVP4YHP.js} +939 -134
- package/dist/chunk-5WVP4YHP.js.map +1 -0
- package/dist/{chunk-MZOVP3WI.cjs → chunk-6KFYJ6TD.cjs} +3 -2
- package/dist/chunk-6KFYJ6TD.cjs.map +1 -0
- package/dist/{chunk-BXKJLM5R.cjs → chunk-6WFMPTGB.cjs} +972 -636
- package/dist/chunk-6WFMPTGB.cjs.map +1 -0
- package/dist/{chunk-2MV4HBKC.cjs → chunk-A2N2GFCG.cjs} +10 -10
- package/dist/{chunk-2MV4HBKC.cjs.map → chunk-A2N2GFCG.cjs.map} +1 -1
- package/dist/chunk-ADBA3XBE.cjs +20 -0
- package/dist/chunk-ADBA3XBE.cjs.map +1 -0
- package/dist/{chunk-MBNQVDVC.cjs → chunk-AMOJYLG2.cjs} +16 -10
- package/dist/chunk-AMOJYLG2.cjs.map +1 -0
- package/dist/{chunk-CLVQBF5C.cjs → chunk-AQNHHJMJ.cjs} +5 -5
- package/dist/{chunk-CLVQBF5C.cjs.map → chunk-AQNHHJMJ.cjs.map} +1 -1
- package/dist/{chunk-AHCLWAM5.cjs → chunk-BHTNFEGZ.cjs} +13 -13
- package/dist/chunk-BHTNFEGZ.cjs.map +1 -0
- package/dist/{chunk-35IWNZPJ.cjs → chunk-E4NUZXVK.cjs} +58 -27
- package/dist/chunk-E4NUZXVK.cjs.map +1 -0
- package/dist/{chunk-P33SBYGG.js → chunk-GLG5ZMX7.js} +54 -23
- package/dist/chunk-GLG5ZMX7.js.map +1 -0
- package/dist/{chunk-BVAR5J2F.js → chunk-GQCOSXMG.js} +117 -6
- package/dist/chunk-GQCOSXMG.js.map +1 -0
- package/dist/{chunk-QDMPOAI7.cjs → chunk-HDP7VK3C.cjs} +1118 -313
- package/dist/chunk-HDP7VK3C.cjs.map +1 -0
- package/dist/{chunk-GVWHCL2N.js → chunk-HMOISHXR.js} +217 -75
- package/dist/chunk-HMOISHXR.js.map +1 -0
- package/dist/{chunk-MTX2KVU7.cjs → chunk-HVQFNJKE.cjs} +122 -90
- package/dist/chunk-HVQFNJKE.cjs.map +1 -0
- package/dist/{chunk-OC6LTXYS.cjs → chunk-JMXUNXQS.cjs} +126 -7
- package/dist/chunk-JMXUNXQS.cjs.map +1 -0
- package/dist/{chunk-WWOLFXTX.cjs → chunk-KBSXGXPM.cjs} +10 -7
- package/dist/chunk-KBSXGXPM.cjs.map +1 -0
- package/dist/{chunk-YU2CUNFO.js → chunk-KV7UW6T6.js} +11 -5
- package/dist/chunk-KV7UW6T6.js.map +1 -0
- package/dist/{chunk-CCJPSHGI.cjs → chunk-N7FNVFXW.cjs} +4 -12
- package/dist/chunk-N7FNVFXW.cjs.map +1 -0
- package/dist/{chunk-CYFK5SY2.js → chunk-O3ANBHSA.js} +169 -39
- package/dist/chunk-O3ANBHSA.js.map +1 -0
- package/dist/{chunk-NZFKROS7.cjs → chunk-PA4VC73I.cjs} +130 -72
- package/dist/chunk-PA4VC73I.cjs.map +1 -0
- package/dist/{chunk-NJTXJ5AG.cjs → chunk-PFUESQTW.cjs} +18 -18
- package/dist/{chunk-NJTXJ5AG.cjs.map → chunk-PFUESQTW.cjs.map} +1 -1
- package/dist/{chunk-SFQWJMKT.js → chunk-QY25VWBF.js} +51 -12
- package/dist/chunk-QY25VWBF.js.map +1 -0
- package/dist/{chunk-WC5FFSHB.js → chunk-R3PY4G7J.js} +3 -3
- package/dist/{chunk-WC5FFSHB.js.map → chunk-R3PY4G7J.js.map} +1 -1
- package/dist/{chunk-M5E34VG5.js → chunk-SBUFNJVE.js} +3 -3
- package/dist/{chunk-M5E34VG5.js.map → chunk-SBUFNJVE.js.map} +1 -1
- package/dist/{chunk-UKPGSAZW.js → chunk-TMA4RCEN.js} +3 -3
- package/dist/{chunk-UKPGSAZW.js.map → chunk-TMA4RCEN.js.map} +1 -1
- package/dist/{chunk-V6HA6JJZ.cjs → chunk-U5VAY32K.cjs} +215 -138
- package/dist/chunk-U5VAY32K.cjs.map +1 -0
- package/dist/{chunk-DUEZFTK2.js → chunk-UKQHXPGW.js} +4 -12
- package/dist/chunk-UKQHXPGW.js.map +1 -0
- package/dist/{chunk-4CVLFLOB.cjs → chunk-UM6BVY2S.cjs} +201 -69
- package/dist/chunk-UM6BVY2S.cjs.map +1 -0
- package/dist/{chunk-75JP4BZX.js → chunk-UQ3UIZJC.js} +3 -2
- package/dist/chunk-UQ3UIZJC.js.map +1 -0
- package/dist/{chunk-PCPX42KL.js → chunk-V4XG5QF6.js} +16 -10
- package/dist/chunk-V4XG5QF6.js.map +1 -0
- package/dist/{chunk-GPPLSM2Z.js → chunk-VB37OC6I.js} +6 -5
- package/dist/chunk-VB37OC6I.js.map +1 -0
- package/dist/{chunk-MVBEL57Q.js → chunk-Y7FT4IQT.js} +500 -170
- package/dist/chunk-Y7FT4IQT.js.map +1 -0
- package/dist/{chunk-OFXOTECC.js → chunk-YPPPYLSR.js} +7 -7
- package/dist/chunk-YPPPYLSR.js.map +1 -0
- package/dist/{chunk-M4F66R4O.cjs → chunk-YWQ6V4ZN.cjs} +121 -82
- package/dist/chunk-YWQ6V4ZN.cjs.map +1 -0
- package/dist/constants.cjs +5 -5
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +2 -2
- package/dist/engine.cjs +31 -31
- package/dist/engine.d.cts +11 -11
- package/dist/engine.d.ts +11 -11
- package/dist/engine.js +21 -21
- package/dist/errors.cjs +19 -19
- package/dist/errors.d.cts +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +1 -1
- package/dist/format.cjs +29 -22
- package/dist/format.cjs.map +1 -1
- package/dist/format.d.cts +1 -2
- package/dist/format.d.ts +1 -2
- package/dist/format.js +23 -16
- package/dist/format.js.map +1 -1
- package/dist/index.cjs +31 -31
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +22 -22
- package/dist/language.cjs +8 -8
- package/dist/language.cjs.map +1 -1
- package/dist/language.d.cts +10 -10
- package/dist/language.d.ts +10 -10
- package/dist/language.js +6 -6
- package/dist/language.js.map +1 -1
- package/dist/lexer.cjs +18 -18
- package/dist/lexer.d.cts +2 -2
- package/dist/lexer.d.ts +2 -2
- package/dist/lexer.js +6 -6
- package/dist/normalizer.cjs +12 -12
- package/dist/normalizer.js +6 -6
- package/dist/packages.cjs +39 -39
- package/dist/packages.d.cts +9 -9
- package/dist/packages.d.ts +9 -9
- package/dist/packages.js +16 -16
- package/dist/parser.cjs +15 -15
- package/dist/parser.d.cts +23 -9
- package/dist/parser.d.ts +23 -9
- package/dist/parser.js +5 -5
- package/dist/{pipeline-CrsRPmsv.d.ts → pipeline-B6k5lCB7.d.ts} +1 -1
- package/dist/{pipeline-DPUQt7yL.d.cts → pipeline-BEb3hujr.d.cts} +1 -1
- package/dist/resolvers.d.cts +2 -2
- package/dist/resolvers.d.ts +2 -2
- package/dist/uom.cjs +17 -17
- package/dist/uom.d.cts +2 -2
- package/dist/uom.d.ts +2 -2
- package/dist/uom.js +7 -7
- package/dist/utilities.cjs +8 -4
- package/dist/utilities.d.cts +19 -3
- package/dist/utilities.d.ts +19 -3
- package/dist/utilities.js +2 -2
- package/dist/vm.cjs +43 -31
- package/dist/vm.d.cts +105 -9
- package/dist/vm.d.ts +105 -9
- package/dist/vm.js +9 -9
- package/package.json +1 -1
- package/dist/chunk-2CS6OMZK.js.map +0 -1
- package/dist/chunk-35IWNZPJ.cjs.map +0 -1
- package/dist/chunk-4AVD7NZW.cjs.map +0 -1
- package/dist/chunk-4CVLFLOB.cjs.map +0 -1
- package/dist/chunk-6GCKCWLB.js.map +0 -1
- package/dist/chunk-6RDSQURE.js.map +0 -1
- package/dist/chunk-75JP4BZX.js.map +0 -1
- package/dist/chunk-AHCLWAM5.cjs.map +0 -1
- package/dist/chunk-BAMZT3GL.js.map +0 -1
- package/dist/chunk-BVAR5J2F.js.map +0 -1
- package/dist/chunk-BXKJLM5R.cjs.map +0 -1
- package/dist/chunk-CCJPSHGI.cjs.map +0 -1
- package/dist/chunk-CSG5XVNJ.cjs.map +0 -1
- package/dist/chunk-CYFK5SY2.js.map +0 -1
- package/dist/chunk-DUEZFTK2.js.map +0 -1
- package/dist/chunk-GPPLSM2Z.js.map +0 -1
- package/dist/chunk-GVWHCL2N.js.map +0 -1
- package/dist/chunk-M4F66R4O.cjs.map +0 -1
- package/dist/chunk-M4N5GA5Z.cjs.map +0 -1
- package/dist/chunk-MBNQVDVC.cjs.map +0 -1
- package/dist/chunk-MEOHSQEH.js.map +0 -1
- package/dist/chunk-MTX2KVU7.cjs.map +0 -1
- package/dist/chunk-MVBEL57Q.js.map +0 -1
- package/dist/chunk-MZOVP3WI.cjs.map +0 -1
- package/dist/chunk-N5YFR4UP.cjs +0 -10
- package/dist/chunk-N5YFR4UP.cjs.map +0 -1
- package/dist/chunk-NZFKROS7.cjs.map +0 -1
- package/dist/chunk-OC6LTXYS.cjs.map +0 -1
- package/dist/chunk-OFXOTECC.js.map +0 -1
- package/dist/chunk-P33SBYGG.js.map +0 -1
- package/dist/chunk-P75775WC.js.map +0 -1
- package/dist/chunk-PCPX42KL.js.map +0 -1
- package/dist/chunk-PFSDGGYL.js +0 -8
- package/dist/chunk-PFSDGGYL.js.map +0 -1
- package/dist/chunk-QDMPOAI7.cjs.map +0 -1
- package/dist/chunk-R24DI24X.cjs.map +0 -1
- package/dist/chunk-SFQWJMKT.js.map +0 -1
- package/dist/chunk-V6HA6JJZ.cjs.map +0 -1
- package/dist/chunk-WWOLFXTX.cjs.map +0 -1
- package/dist/chunk-YU2CUNFO.js.map +0 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkHVQFNJKE_cjs = require('./chunk-HVQFNJKE.cjs');
|
|
4
4
|
var chunkX6K3HUOY_cjs = require('./chunk-X6K3HUOY.cjs');
|
|
5
5
|
var chunk5X2PTP6F_cjs = require('./chunk-5X2PTP6F.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkHDP7VK3C_cjs = require('./chunk-HDP7VK3C.cjs');
|
|
7
7
|
var chunk47LRVGOT_cjs = require('./chunk-47LRVGOT.cjs');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
8
|
+
var chunk3AFRJYP4_cjs = require('./chunk-3AFRJYP4.cjs');
|
|
9
|
+
var chunkPA4VC73I_cjs = require('./chunk-PA4VC73I.cjs');
|
|
10
|
+
var chunkBHTNFEGZ_cjs = require('./chunk-BHTNFEGZ.cjs');
|
|
11
|
+
var chunkADBA3XBE_cjs = require('./chunk-ADBA3XBE.cjs');
|
|
11
12
|
var chunkZ2XP767T_cjs = require('./chunk-Z2XP767T.cjs');
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
13
|
+
var chunk6WFMPTGB_cjs = require('./chunk-6WFMPTGB.cjs');
|
|
14
|
+
var chunkUM6BVY2S_cjs = require('./chunk-UM6BVY2S.cjs');
|
|
15
|
+
var chunkJMXUNXQS_cjs = require('./chunk-JMXUNXQS.cjs');
|
|
16
|
+
var chunkE4NUZXVK_cjs = require('./chunk-E4NUZXVK.cjs');
|
|
17
|
+
var chunkKBSXGXPM_cjs = require('./chunk-KBSXGXPM.cjs');
|
|
17
18
|
var chunkTY3TLZAW_cjs = require('./chunk-TY3TLZAW.cjs');
|
|
18
|
-
var
|
|
19
|
+
var chunk5KMIY374_cjs = require('./chunk-5KMIY374.cjs');
|
|
19
20
|
var chunkB7LXJ6LC_cjs = require('./chunk-B7LXJ6LC.cjs');
|
|
20
21
|
|
|
21
22
|
// node_modules/semver/internal/constants.js
|
|
@@ -2203,7 +2204,7 @@ function checkPackageCompatibility(candidate, existing) {
|
|
|
2203
2204
|
|
|
2204
2205
|
// src/api/EngineVersionCompatibility.ts
|
|
2205
2206
|
var import_semver = chunkB7LXJ6LC_cjs.__toESM(require_semver2(), 1);
|
|
2206
|
-
function checkEngineVersionCompatibility(pkg, engineVersion =
|
|
2207
|
+
function checkEngineVersionCompatibility(pkg, engineVersion = chunkE4NUZXVK_cjs.ENGINE_VERSION) {
|
|
2207
2208
|
if (!pkg.engineVersion) return { compatible: true };
|
|
2208
2209
|
if ((0, import_semver.validRange)(pkg.engineVersion) === null) {
|
|
2209
2210
|
return { compatible: false, reason: "invalid-range", declaredRange: pkg.engineVersion, engineVersion };
|
|
@@ -2214,11 +2215,11 @@ function checkEngineVersionCompatibility(pkg, engineVersion = chunk35IWNZPJ_cjs.
|
|
|
2214
2215
|
}
|
|
2215
2216
|
return { compatible: true };
|
|
2216
2217
|
}
|
|
2217
|
-
function assertEngineVersionCompatible(pkg, engineVersion =
|
|
2218
|
+
function assertEngineVersionCompatible(pkg, engineVersion = chunkE4NUZXVK_cjs.ENGINE_VERSION) {
|
|
2218
2219
|
const result = checkEngineVersionCompatibility(pkg, engineVersion);
|
|
2219
2220
|
if (result.compatible) return;
|
|
2220
2221
|
if (result.reason === "invalid-range") {
|
|
2221
|
-
throw
|
|
2222
|
+
throw chunk5KMIY374_cjs.ErrorFactory.config({
|
|
2222
2223
|
code: "PACKAGE_ENGINE_VERSION_INVALID_RANGE",
|
|
2223
2224
|
message: `Package "${pkg.name}" declares an invalid engineVersion range: "${result.declaredRange}" is not a valid semver range.`,
|
|
2224
2225
|
expected: `a valid semver range string (e.g. "^0.1.0", ">=0.2.0 <1.0.0")`,
|
|
@@ -2227,7 +2228,7 @@ function assertEngineVersionCompatible(pkg, engineVersion = chunk35IWNZPJ_cjs.EN
|
|
|
2227
2228
|
context: { packageName: pkg.name, declaredRange: result.declaredRange }
|
|
2228
2229
|
});
|
|
2229
2230
|
}
|
|
2230
|
-
throw
|
|
2231
|
+
throw chunk5KMIY374_cjs.ErrorFactory.config({
|
|
2231
2232
|
code: "PACKAGE_ENGINE_VERSION_MISMATCH",
|
|
2232
2233
|
message: `Package "${pkg.name}" declares engineVersion "${result.declaredRange}", which is not satisfied by the running engine version "${result.engineVersion}".`,
|
|
2233
2234
|
expected: `an engine version satisfying "${result.declaredRange}"`,
|
|
@@ -2251,7 +2252,7 @@ function getCompileEngine() {
|
|
|
2251
2252
|
var executeVm = null;
|
|
2252
2253
|
function getExecuteVm() {
|
|
2253
2254
|
if (!executeVm) {
|
|
2254
|
-
executeVm =
|
|
2255
|
+
executeVm = chunkHDP7VK3C_cjs.createVM(chunk6WFMPTGB_cjs.sharedOpRegistry, 200, 5e4);
|
|
2255
2256
|
}
|
|
2256
2257
|
return executeVm;
|
|
2257
2258
|
}
|
|
@@ -2323,7 +2324,7 @@ function executeOne(item) {
|
|
|
2323
2324
|
const numbers = new Float64Array(item.numbersBuffer, 0, item.numbersLength);
|
|
2324
2325
|
const bytecode = { opcodes, numbers, strings: item.strings };
|
|
2325
2326
|
try {
|
|
2326
|
-
const result =
|
|
2327
|
+
const result = chunkHDP7VK3C_cjs.executeBytecode(bytecode, vmm);
|
|
2327
2328
|
if (result.type === "pending") {
|
|
2328
2329
|
return {
|
|
2329
2330
|
lineNumber: item.lineNumber,
|
|
@@ -2577,29 +2578,29 @@ var ExecutionPool = class {
|
|
|
2577
2578
|
function reconstructValue(result) {
|
|
2578
2579
|
switch (result.valueType) {
|
|
2579
2580
|
case 0 /* Number */:
|
|
2580
|
-
return
|
|
2581
|
+
return chunkJMXUNXQS_cjs.numberValue(result.value);
|
|
2581
2582
|
case 1 /* Hex */:
|
|
2582
|
-
return
|
|
2583
|
+
return chunkJMXUNXQS_cjs.hexValue(result.value);
|
|
2583
2584
|
case 2 /* BigInt */:
|
|
2584
|
-
return
|
|
2585
|
+
return chunkJMXUNXQS_cjs.bigIntValue(BigInt(result.value));
|
|
2585
2586
|
case 3 /* String */:
|
|
2586
|
-
return
|
|
2587
|
+
return chunkJMXUNXQS_cjs.stringValue(String(result.value));
|
|
2587
2588
|
case 4 /* Datetime */:
|
|
2588
|
-
return
|
|
2589
|
+
return chunkJMXUNXQS_cjs.datetimeValue(result.value);
|
|
2589
2590
|
case 5 /* Percentage */:
|
|
2590
|
-
return
|
|
2591
|
+
return chunkJMXUNXQS_cjs.percentageValue(result.value);
|
|
2591
2592
|
case 6 /* Uom */:
|
|
2592
|
-
return
|
|
2593
|
+
return chunkJMXUNXQS_cjs.uomValue(result.value, result.unit ?? "");
|
|
2593
2594
|
case 7 /* Matrix */:
|
|
2594
|
-
return
|
|
2595
|
+
return chunkJMXUNXQS_cjs.numberValue(result.value);
|
|
2595
2596
|
case 10 /* Boolean */:
|
|
2596
|
-
return
|
|
2597
|
+
return chunkJMXUNXQS_cjs.boolValue(result.value !== 0);
|
|
2597
2598
|
case 12 /* Pending */:
|
|
2598
|
-
return
|
|
2599
|
+
return chunkJMXUNXQS_cjs.pendingValue(result.queryKey ?? "");
|
|
2599
2600
|
case 13 /* Error */:
|
|
2600
|
-
return
|
|
2601
|
+
return chunkJMXUNXQS_cjs.errorValue("WORKER_EXECUTION_ERROR", result.unit ?? "Unknown worker error");
|
|
2601
2602
|
default:
|
|
2602
|
-
return
|
|
2603
|
+
return chunkJMXUNXQS_cjs.numberValue(result.value);
|
|
2603
2604
|
}
|
|
2604
2605
|
}
|
|
2605
2606
|
|
|
@@ -2715,7 +2716,7 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
|
|
|
2715
2716
|
try {
|
|
2716
2717
|
this.flush();
|
|
2717
2718
|
} catch (e) {
|
|
2718
|
-
const engineError =
|
|
2719
|
+
const engineError = chunk5KMIY374_cjs.normalizeUnknownError(e);
|
|
2719
2720
|
console.error(`[AsyncResolutionBatcher] flush() failed unexpectedly \u2014 this should never happen; please report: ${engineError.format()}`);
|
|
2720
2721
|
}
|
|
2721
2722
|
});
|
|
@@ -2840,7 +2841,7 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
|
|
|
2840
2841
|
entryMap.set(lineNumber, this.lineCache.getEntryForLine(lineNumber));
|
|
2841
2842
|
}
|
|
2842
2843
|
void this.reExecuteViaWorkerPool(ordered, entryMap, allQueryKeys).catch((e) => {
|
|
2843
|
-
const engineError =
|
|
2844
|
+
const engineError = chunk5KMIY374_cjs.normalizeUnknownError(e);
|
|
2844
2845
|
console.error(`[AsyncResolutionBatcher] reExecuteViaWorkerPool() failed unexpectedly: ${engineError.format()}`);
|
|
2845
2846
|
});
|
|
2846
2847
|
return;
|
|
@@ -2988,7 +2989,7 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
|
|
|
2988
2989
|
if (!entry || entry.bytecode.opcodes.length === 0) continue;
|
|
2989
2990
|
const stackBefore = this.vm.getStack().length;
|
|
2990
2991
|
try {
|
|
2991
|
-
const result =
|
|
2992
|
+
const result = chunkHDP7VK3C_cjs.executeBytecode(entry.bytecode, this.vm);
|
|
2992
2993
|
while (this.vm.getStack().length > stackBefore) {
|
|
2993
2994
|
this.vm.pop();
|
|
2994
2995
|
}
|
|
@@ -2998,7 +2999,7 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
|
|
|
2998
2999
|
this.onLineResult?.(lineNumber, result.value);
|
|
2999
3000
|
updatedLineNumbers.push(lineNumber);
|
|
3000
3001
|
} else if (result.type === "error") {
|
|
3001
|
-
const value =
|
|
3002
|
+
const value = chunkJMXUNXQS_cjs.errorValue(result.error.code, result.error.message);
|
|
3002
3003
|
entry.result = value;
|
|
3003
3004
|
this.warnIfUnwired();
|
|
3004
3005
|
this.warnIfUnwired();
|
|
@@ -3009,8 +3010,8 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
|
|
|
3009
3010
|
while (this.vm.getStack().length > stackBefore) {
|
|
3010
3011
|
this.vm.pop();
|
|
3011
3012
|
}
|
|
3012
|
-
const engineError =
|
|
3013
|
-
const value =
|
|
3013
|
+
const engineError = chunk5KMIY374_cjs.normalizeUnknownError(e);
|
|
3014
|
+
const value = chunkJMXUNXQS_cjs.errorValue(engineError.code, engineError.message);
|
|
3014
3015
|
entry.result = value;
|
|
3015
3016
|
this.warnIfUnwired();
|
|
3016
3017
|
this.onLineResult?.(lineNumber, value);
|
|
@@ -3213,7 +3214,7 @@ function percentile(sorted, p) {
|
|
|
3213
3214
|
// src/engine/ExpressionEngineSafety.ts
|
|
3214
3215
|
function checkExpressionLength(expression, config) {
|
|
3215
3216
|
if (expression.length > config.maxExpressionLength) {
|
|
3216
|
-
const err =
|
|
3217
|
+
const err = chunk5KMIY374_cjs.ErrorFactory.validation(
|
|
3217
3218
|
"EXPRESSION_TOO_LONG",
|
|
3218
3219
|
`Expression exceeds max length of ${config.maxExpressionLength} characters (got ${expression.length})`,
|
|
3219
3220
|
{ expressionLength: expression.length, maxLength: config.maxExpressionLength }
|
|
@@ -3221,7 +3222,7 @@ function checkExpressionLength(expression, config) {
|
|
|
3221
3222
|
return {
|
|
3222
3223
|
passed: false,
|
|
3223
3224
|
error: {
|
|
3224
|
-
value:
|
|
3225
|
+
value: chunkJMXUNXQS_cjs.numberValue(0),
|
|
3225
3226
|
tokens: [],
|
|
3226
3227
|
program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false },
|
|
3227
3228
|
error: err.message,
|
|
@@ -3245,7 +3246,7 @@ function checkExpressionComplexity(tokens, config) {
|
|
|
3245
3246
|
}
|
|
3246
3247
|
const complexityScore = tokens.length + functionCallCount * 5 + maxParens * 10;
|
|
3247
3248
|
if (complexityScore > config.maxComplexity) {
|
|
3248
|
-
const err =
|
|
3249
|
+
const err = chunk5KMIY374_cjs.ErrorFactory.validation(
|
|
3249
3250
|
"EXPRESSION_TOO_COMPLEX",
|
|
3250
3251
|
`Expression complexity score ${complexityScore} exceeds maximum of ${config.maxComplexity}`,
|
|
3251
3252
|
{ complexity: complexityScore, maxComplexity: config.maxComplexity }
|
|
@@ -3294,7 +3295,7 @@ function extractReadsAndWrites(tokens) {
|
|
|
3294
3295
|
const t = tokens[i];
|
|
3295
3296
|
if (t.type === "GLOBAL") {
|
|
3296
3297
|
if (i + 2 < tokens.length && tokens[i + 1].type === "COLON" && isVarName(tokens[i + 2])) {
|
|
3297
|
-
const key =
|
|
3298
|
+
const key = chunk6WFMPTGB_cjs.globalDagKey(tokens[i + 2].value);
|
|
3298
3299
|
reads.push(key);
|
|
3299
3300
|
if (i + 3 < tokens.length && tokens[i + 3].type === "EQUALS") {
|
|
3300
3301
|
writes.push(key);
|
|
@@ -3333,11 +3334,11 @@ function extractReadsAndWrites(tokens) {
|
|
|
3333
3334
|
return { reads, writes };
|
|
3334
3335
|
}
|
|
3335
3336
|
function isEmptyLine(lineText) {
|
|
3336
|
-
const classification =
|
|
3337
|
+
const classification = chunkKBSXGXPM_cjs.sharedLexer.classifyLine(lineText);
|
|
3337
3338
|
return classification.skip;
|
|
3338
3339
|
}
|
|
3339
3340
|
function findInlineSolvesInLine(lineText, lineNumber) {
|
|
3340
|
-
const spans =
|
|
3341
|
+
const spans = chunkKBSXGXPM_cjs.sharedLexer.findInlineSolves(lineText);
|
|
3341
3342
|
return spans.map((s) => ({
|
|
3342
3343
|
start: s.start,
|
|
3343
3344
|
end: s.end,
|
|
@@ -3353,9 +3354,9 @@ var ExpressionEngine = class {
|
|
|
3353
3354
|
//#region Constructor
|
|
3354
3355
|
constructor(localeCode = "en", diagnosticMode = false, config, diagnosticPipeline, packages) {
|
|
3355
3356
|
//#region Private Properties
|
|
3356
|
-
this.dag = new
|
|
3357
|
+
this.dag = new chunkHDP7VK3C_cjs.DependencyGraph();
|
|
3357
3358
|
this.lineCache = new LineCache();
|
|
3358
|
-
this.scopeManager = new
|
|
3359
|
+
this.scopeManager = new chunkHDP7VK3C_cjs.ScopeManager();
|
|
3359
3360
|
/** Registry of async resolvers from registered packages. */
|
|
3360
3361
|
this.resolverRegistry = new chunkX6K3HUOY_cjs.ResolverRegistry();
|
|
3361
3362
|
/**
|
|
@@ -3411,20 +3412,20 @@ var ExpressionEngine = class {
|
|
|
3411
3412
|
this.bytecodeCache = /* @__PURE__ */ new Map();
|
|
3412
3413
|
// Pre-allocated BytecodeBuilder pool
|
|
3413
3414
|
this.builderPool = [
|
|
3414
|
-
new
|
|
3415
|
-
new
|
|
3416
|
-
new
|
|
3417
|
-
new
|
|
3415
|
+
new chunkPA4VC73I_cjs.BytecodeBuilder(),
|
|
3416
|
+
new chunkPA4VC73I_cjs.BytecodeBuilder(),
|
|
3417
|
+
new chunkPA4VC73I_cjs.BytecodeBuilder(),
|
|
3418
|
+
new chunkPA4VC73I_cjs.BytecodeBuilder()
|
|
3418
3419
|
];
|
|
3419
3420
|
// Index into the builder pool, incremented modulo pool size.
|
|
3420
3421
|
this.builderPoolIndex = 0;
|
|
3421
3422
|
// Most recent pipeline telemetry, populated when AllocationTracker.isEnabled().
|
|
3422
3423
|
this.lastTelemetry = null;
|
|
3423
3424
|
this.localeCode = localeCode;
|
|
3424
|
-
this.config =
|
|
3425
|
-
this.lexer = new
|
|
3426
|
-
this.registry = new
|
|
3427
|
-
this.context =
|
|
3425
|
+
this.config = chunkE4NUZXVK_cjs.mergeEngineConfig(chunkE4NUZXVK_cjs.DEFAULT_CONFIG, config ?? {});
|
|
3426
|
+
this.lexer = new chunkKBSXGXPM_cjs.Lexer(localeCode, chunkKBSXGXPM_cjs.buildTokenLookup(localeCode));
|
|
3427
|
+
this.registry = new chunkHVQFNJKE_cjs.ParseletRegistry();
|
|
3428
|
+
this.context = chunk6WFMPTGB_cjs.createEngineContext();
|
|
3428
3429
|
if (diagnosticPipeline) {
|
|
3429
3430
|
this.diagnosticPipeline = diagnosticPipeline;
|
|
3430
3431
|
} else if (diagnosticMode) {
|
|
@@ -3434,31 +3435,36 @@ var ExpressionEngine = class {
|
|
|
3434
3435
|
} else {
|
|
3435
3436
|
this.diagnosticPipeline = new chunk47LRVGOT_cjs.DiagnosticPipeline();
|
|
3436
3437
|
}
|
|
3437
|
-
this.normalizer = new
|
|
3438
|
-
for (const [phrase, tokenType] of Object.entries(
|
|
3438
|
+
this.normalizer = new chunkBHTNFEGZ_cjs.TokenNormalizer();
|
|
3439
|
+
for (const [phrase, tokenType] of Object.entries(chunkBHTNFEGZ_cjs.BUILTIN_PHRASES)) {
|
|
3439
3440
|
this.normalizer.addPhrase(phrase, tokenType);
|
|
3440
3441
|
}
|
|
3441
|
-
this.normalizer.register(
|
|
3442
|
+
this.normalizer.register(chunkBHTNFEGZ_cjs.implicitMultiplyRule(
|
|
3442
3443
|
50,
|
|
3443
3444
|
(word) => this.normalizer.canStartPhrase(word)
|
|
3444
3445
|
));
|
|
3445
|
-
const pkgList = packages ??
|
|
3446
|
+
const pkgList = packages ?? chunk3AFRJYP4_cjs.BUILTIN_PACKAGES;
|
|
3446
3447
|
for (const pkg of pkgList) {
|
|
3447
3448
|
try {
|
|
3448
3449
|
this.registerPackage(pkg);
|
|
3449
3450
|
} catch (e) {
|
|
3450
|
-
const engineError =
|
|
3451
|
+
const engineError = chunk5KMIY374_cjs.normalizeUnknownError(e);
|
|
3451
3452
|
console.error(
|
|
3452
3453
|
`[ExpressionEngine] Failed to register package "${pkg.name}" \u2014 skipping it and continuing construction with the remaining packages: ${engineError.format()}`
|
|
3453
3454
|
);
|
|
3454
3455
|
}
|
|
3455
3456
|
}
|
|
3456
|
-
this.parser = new
|
|
3457
|
-
this.vm =
|
|
3457
|
+
this.parser = new chunkHVQFNJKE_cjs.PrecedenceParser(this.registry, this.config.validation.maxNestingDepth, localeCode);
|
|
3458
|
+
this.vm = chunkHDP7VK3C_cjs.createVM(
|
|
3458
3459
|
this.context.opRegistry,
|
|
3459
3460
|
this.config.vm.maxStackDepth,
|
|
3460
3461
|
this.config.vm.maxInstructions,
|
|
3461
3462
|
void 0,
|
|
3463
|
+
this.config.vm.maxCollectionSize,
|
|
3464
|
+
this.config.vm.maxAllocatedElements,
|
|
3465
|
+
this.config.vm.maxFunctionCalls,
|
|
3466
|
+
this.config.date.maxOffsetYears,
|
|
3467
|
+
this.config.date.minOffsetYears,
|
|
3462
3468
|
this.context
|
|
3463
3469
|
);
|
|
3464
3470
|
this.queryClient = chunkZ2XP767T_cjs.createQueryClient();
|
|
@@ -3579,7 +3585,8 @@ var ExpressionEngine = class {
|
|
|
3579
3585
|
resolverNamespaces: [],
|
|
3580
3586
|
tokenCategories: [],
|
|
3581
3587
|
lexerVocabulary: pkg.lexerVocabulary,
|
|
3582
|
-
asConverterNames: []
|
|
3588
|
+
asConverterNames: [],
|
|
3589
|
+
normalizerRuleNames: []
|
|
3583
3590
|
};
|
|
3584
3591
|
if (pkg.lexerVocabulary) {
|
|
3585
3592
|
this.lexer.registerVocabulary(pkg.lexerVocabulary);
|
|
@@ -3621,6 +3628,7 @@ var ExpressionEngine = class {
|
|
|
3621
3628
|
if (pkg.normalizerRules) {
|
|
3622
3629
|
for (const rule of pkg.normalizerRules) {
|
|
3623
3630
|
this.normalizer.register(rule);
|
|
3631
|
+
contribution.normalizerRuleNames.push(rule.name);
|
|
3624
3632
|
}
|
|
3625
3633
|
}
|
|
3626
3634
|
if (pkg.tokenCategories) {
|
|
@@ -3634,7 +3642,7 @@ var ExpressionEngine = class {
|
|
|
3634
3642
|
}
|
|
3635
3643
|
if (pkg.asConverters) {
|
|
3636
3644
|
for (const [name, handler] of Object.entries(pkg.asConverters)) {
|
|
3637
|
-
|
|
3645
|
+
chunk6WFMPTGB_cjs.registerAsConverter(name, handler);
|
|
3638
3646
|
contribution.asConverterNames.push(name);
|
|
3639
3647
|
}
|
|
3640
3648
|
}
|
|
@@ -3654,9 +3662,17 @@ var ExpressionEngine = class {
|
|
|
3654
3662
|
* own contract). This engine-instance-local registration is reversed
|
|
3655
3663
|
* here too, even though it isn't a "shared" registry, so a package's
|
|
3656
3664
|
* lexer and highlighting contributions clean up together rather than
|
|
3657
|
-
* only half-reversing on unregister.
|
|
3658
|
-
*
|
|
3659
|
-
*
|
|
3665
|
+
* only half-reversing on unregister. Normalizer rules are reversed here
|
|
3666
|
+
* for the same reason: they are per-engine, but they live in an ARRAY the
|
|
3667
|
+
* normalizer walks at every token position, so re-registering a package
|
|
3668
|
+
* appended a second copy of every rule and lexing got slower with every
|
|
3669
|
+
* register/unregister cycle.
|
|
3670
|
+
*
|
|
3671
|
+
* Per-engine parselets and phrases are still left in place: a parselet
|
|
3672
|
+
* lives in this engine's isolated registry and a phrase goes into a
|
|
3673
|
+
* text-keyed trie where registering the same phrase twice is the same as
|
|
3674
|
+
* registering it once, so neither accumulates and both are discarded with
|
|
3675
|
+
* the engine instance.
|
|
3660
3676
|
*
|
|
3661
3677
|
* Clears the bytecode cache, removing handlers changes what compiled
|
|
3662
3678
|
* bytecode is valid.
|
|
@@ -3684,7 +3700,10 @@ var ExpressionEngine = class {
|
|
|
3684
3700
|
this.lexer.unregisterVocabulary(contribution.lexerVocabulary);
|
|
3685
3701
|
}
|
|
3686
3702
|
for (const name of contribution.asConverterNames) {
|
|
3687
|
-
|
|
3703
|
+
chunk6WFMPTGB_cjs.unregisterAsConverter(name);
|
|
3704
|
+
}
|
|
3705
|
+
for (const ruleName of contribution.normalizerRuleNames) {
|
|
3706
|
+
this.normalizer.unregister(ruleName);
|
|
3688
3707
|
}
|
|
3689
3708
|
this.packageCompletionItems.delete(packageName);
|
|
3690
3709
|
this.packageContributions.delete(packageName);
|
|
@@ -3756,7 +3775,7 @@ var ExpressionEngine = class {
|
|
|
3756
3775
|
controller.abort();
|
|
3757
3776
|
};
|
|
3758
3777
|
chunkZ2XP767T_cjs.setActiveQueryClient(this.queryClient);
|
|
3759
|
-
const result =
|
|
3778
|
+
const result = chunkHDP7VK3C_cjs.executeBytecode(program, this.vm, tracePipeline, traceExpression, this.makeLineContext(lineNumber));
|
|
3760
3779
|
while (this.vm.getStack().length > stackBefore) {
|
|
3761
3780
|
this.vm.pop();
|
|
3762
3781
|
}
|
|
@@ -3767,7 +3786,7 @@ var ExpressionEngine = class {
|
|
|
3767
3786
|
result.packageId || packageId,
|
|
3768
3787
|
[result.queryKey]
|
|
3769
3788
|
);
|
|
3770
|
-
const pending =
|
|
3789
|
+
const pending = chunkJMXUNXQS_cjs.pendingValue(result.queryKey);
|
|
3771
3790
|
this.storeLineResult(lineNumber, pending, program, reads, writes, expression);
|
|
3772
3791
|
return pending;
|
|
3773
3792
|
}
|
|
@@ -3807,7 +3826,7 @@ var ExpressionEngine = class {
|
|
|
3807
3826
|
controller.abort();
|
|
3808
3827
|
};
|
|
3809
3828
|
chunkZ2XP767T_cjs.setActiveQueryClient(this.queryClient);
|
|
3810
|
-
const result =
|
|
3829
|
+
const result = chunkHDP7VK3C_cjs.executeBytecode(program, this.vm, void 0, void 0, this.makeLineContext(lineNumber));
|
|
3811
3830
|
while (this.vm.getStack().length > stackBefore) {
|
|
3812
3831
|
this.vm.pop();
|
|
3813
3832
|
}
|
|
@@ -3863,6 +3882,14 @@ var ExpressionEngine = class {
|
|
|
3863
3882
|
* with precise coordinate mapping for inline solves.
|
|
3864
3883
|
*/
|
|
3865
3884
|
parseDocument(input, options = { inputType: "markdown" }) {
|
|
3885
|
+
const maxLines = this.config.performance.maxDocumentLines;
|
|
3886
|
+
if (chunkADBA3XBE_cjs.countLines(input, maxLines) > maxLines) {
|
|
3887
|
+
throw chunk5KMIY374_cjs.ErrorFactory.execution(
|
|
3888
|
+
"DOCUMENT_TOO_LARGE",
|
|
3889
|
+
`This document has more than ${maxLines.toLocaleString("en-US")} lines, which is the most the engine will process in one pass`,
|
|
3890
|
+
{ maxLines }
|
|
3891
|
+
);
|
|
3892
|
+
}
|
|
3866
3893
|
const scanResults = this.lexer.scanDocument(input);
|
|
3867
3894
|
const processedLines = this.processScanResults(scanResults);
|
|
3868
3895
|
const result = {
|
|
@@ -4011,8 +4038,14 @@ var ExpressionEngine = class {
|
|
|
4011
4038
|
* parseExpression(). Abstracts the API difference between the two parsers:
|
|
4012
4039
|
* - PrecedenceParser: parser.setBuilder(builder); parser.parseExpression(0)
|
|
4013
4040
|
* - RD: parser.builder = builder; parser.parseExpression(0)
|
|
4041
|
+
*
|
|
4042
|
+
* @param allowLabelFallback - Whether a line that does not parse whole may
|
|
4043
|
+
* be retried as "<label>: <expression>". True for a real line, false for
|
|
4044
|
+
* the retries that fallback makes itself, which is what stops it costing
|
|
4045
|
+
* exponential time; see the loop below, and the comment on its recursive
|
|
4046
|
+
* call for the measurement.
|
|
4014
4047
|
*/
|
|
4015
|
-
parseExpression(builder, tokens, hasParens) {
|
|
4048
|
+
parseExpression(builder, tokens, hasParens, allowLabelFallback = true) {
|
|
4016
4049
|
this.parser.setBuilder(builder);
|
|
4017
4050
|
this.parser.load(tokens, this.config.validation.autoBalanceParens ? hasParens : false);
|
|
4018
4051
|
this.parser.parseExpression(0);
|
|
@@ -4021,17 +4054,33 @@ var ExpressionEngine = class {
|
|
|
4021
4054
|
if (leftover.type === "EQUALS" && !this.parser.peekAt(1)) {
|
|
4022
4055
|
return;
|
|
4023
4056
|
}
|
|
4024
|
-
for (let i = tokens.length - 1; i >= 1; i--) {
|
|
4057
|
+
for (let i = allowLabelFallback ? tokens.length - 1 : 0; i >= 1; i--) {
|
|
4025
4058
|
if (tokens[i].type !== "COLON") continue;
|
|
4026
4059
|
if (i + 1 >= tokens.length) continue;
|
|
4060
|
+
let labelIsAllNumeric = true;
|
|
4061
|
+
for (let j = 0; j < i; j++) {
|
|
4062
|
+
const type = tokens[j].type;
|
|
4063
|
+
if (type !== "NUMBER" && type !== "COLON") {
|
|
4064
|
+
labelIsAllNumeric = false;
|
|
4065
|
+
break;
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
if (labelIsAllNumeric) {
|
|
4069
|
+
const literal = tokens.slice(0, i + 2).map((t) => t.value).join("");
|
|
4070
|
+
throw chunk5KMIY374_cjs.ErrorFactory.parsing(
|
|
4071
|
+
"INVALID_TIME_LITERAL",
|
|
4072
|
+
`"${literal}" is not a valid time`,
|
|
4073
|
+
{ tokenType: tokens[i].type, tokenValue: literal }
|
|
4074
|
+
);
|
|
4075
|
+
}
|
|
4027
4076
|
builder.reset();
|
|
4028
4077
|
try {
|
|
4029
|
-
this.parseExpression(builder, tokens.slice(i + 1), hasParens);
|
|
4078
|
+
this.parseExpression(builder, tokens.slice(i + 1), hasParens, false);
|
|
4030
4079
|
return;
|
|
4031
4080
|
} catch {
|
|
4032
4081
|
}
|
|
4033
4082
|
}
|
|
4034
|
-
throw
|
|
4083
|
+
throw chunk5KMIY374_cjs.ErrorFactory.parsing(
|
|
4035
4084
|
"UNEXPECTED_TRAILING_TOKEN",
|
|
4036
4085
|
`Unexpected token after expression: "${leftover.value}"`,
|
|
4037
4086
|
{ tokenType: leftover.type, tokenValue: leftover.value }
|
|
@@ -4049,7 +4098,7 @@ var ExpressionEngine = class {
|
|
|
4049
4098
|
* (this grammar is rare, a per-call allocation here is a non-issue).
|
|
4050
4099
|
*/
|
|
4051
4100
|
compileAdHoc(tokens) {
|
|
4052
|
-
const builder = new
|
|
4101
|
+
const builder = new chunkPA4VC73I_cjs.BytecodeBuilder();
|
|
4053
4102
|
this.parseExpression(builder, tokens);
|
|
4054
4103
|
return builder.build();
|
|
4055
4104
|
}
|
|
@@ -4062,21 +4111,29 @@ var ExpressionEngine = class {
|
|
|
4062
4111
|
* (a bare assignment's RHS, and an equation's own RHS at solve time)
|
|
4063
4112
|
*, every one of these needs forward-tolerant reads of not-yet-defined
|
|
4064
4113
|
* names, which ordinary evaluation deliberately never allows.
|
|
4114
|
+
*
|
|
4115
|
+
* `lineNumber` is the 1-based document line this program belongs to, so
|
|
4116
|
+
* the RHS still receives a {@link makeLineContext}, a bare assignment's
|
|
4117
|
+
* right-hand side (`total = prev`, `x = line2`) can therefore read
|
|
4118
|
+
* cross-line results exactly as a bare expression line does. Defaults to
|
|
4119
|
+
* `-1` (the "no real document" sentinel) for the expression-level and
|
|
4120
|
+
* `=>`-without-a-document callers, which naturally yields the same
|
|
4121
|
+
* `LINE_REF_NO_DOCUMENT` a single-expression eval already returns.
|
|
4065
4122
|
*/
|
|
4066
|
-
executeSymbolicTolerant(program) {
|
|
4067
|
-
const result =
|
|
4123
|
+
executeSymbolicTolerant(program, lineNumber = -1) {
|
|
4124
|
+
const result = chunkHDP7VK3C_cjs.executeBytecode(program, this.vm, void 0, void 0, this.makeLineContext(lineNumber), true);
|
|
4068
4125
|
if (result.type === "error") throw result.error;
|
|
4069
4126
|
if (result.type === "pending") {
|
|
4070
|
-
throw
|
|
4127
|
+
throw chunk5KMIY374_cjs.ErrorFactory.execution(
|
|
4071
4128
|
"THEREFORE_ASYNC_UNSUPPORTED",
|
|
4072
4129
|
`"=>" doesn't support expressions that call an async operation (weather/stocks/currency).`
|
|
4073
4130
|
);
|
|
4074
4131
|
}
|
|
4075
4132
|
return result.value;
|
|
4076
4133
|
}
|
|
4077
|
-
/** Compiles and executes `tokens` in symbolic-tolerant mode, the "just simplify this" `=>` fallback when there's no stored equation to solve. */
|
|
4078
|
-
simplifySymbolically(tokens) {
|
|
4079
|
-
return this.executeSymbolicTolerant(this.compileAdHoc(tokens));
|
|
4134
|
+
/** Compiles and executes `tokens` in symbolic-tolerant mode, the "just simplify this" `=>` fallback when there's no stored equation to solve. `lineNumber` (1-based, `-1` outside a document) is forwarded so a bare assignment's RHS can resolve cross-line references. */
|
|
4135
|
+
simplifySymbolically(tokens, lineNumber = -1) {
|
|
4136
|
+
return this.executeSymbolicTolerant(this.compileAdHoc(tokens), lineNumber);
|
|
4080
4137
|
}
|
|
4081
4138
|
/**
|
|
4082
4139
|
* Parses a bare (colon-less) equation's left-hand side, `factor1 *
|
|
@@ -4121,18 +4178,18 @@ var ExpressionEngine = class {
|
|
|
4121
4178
|
* errors propagate as values" convention (DIMENSION_MISMATCH,
|
|
4122
4179
|
* SINGULAR_MATRIX, ...).
|
|
4123
4180
|
*/
|
|
4124
|
-
solveEquation(equation) {
|
|
4181
|
+
solveEquation(equation, lineNumber = -1) {
|
|
4125
4182
|
const factorValues = [];
|
|
4126
4183
|
for (const name of equation.factorNames) {
|
|
4127
4184
|
const v = this.vm.getVar(name);
|
|
4128
4185
|
if (v === void 0) {
|
|
4129
|
-
return
|
|
4186
|
+
return chunkJMXUNXQS_cjs.errorValue(
|
|
4130
4187
|
"EQUATION_FACTOR_UNDEFINED",
|
|
4131
4188
|
`Cannot solve for "${equation.variable}": "${name}" is not yet defined.`
|
|
4132
4189
|
);
|
|
4133
4190
|
}
|
|
4134
4191
|
if (v.type !== 7 /* Matrix */) {
|
|
4135
|
-
return
|
|
4192
|
+
return chunkJMXUNXQS_cjs.errorValue(
|
|
4136
4193
|
"EQUATION_FACTOR_NOT_MATRIX",
|
|
4137
4194
|
`Cannot solve for "${equation.variable}": "${name}" must be a Matrix (got a different value type).`
|
|
4138
4195
|
);
|
|
@@ -4141,20 +4198,20 @@ var ExpressionEngine = class {
|
|
|
4141
4198
|
}
|
|
4142
4199
|
let combined = factorValues[0].value;
|
|
4143
4200
|
for (let i = 1; i < factorValues.length; i++) {
|
|
4144
|
-
const product =
|
|
4201
|
+
const product = chunkUM6BVY2S_cjs.matrixMultiply(combined, factorValues[i].value);
|
|
4145
4202
|
if (product.type === 13 /* Error */) return product;
|
|
4146
4203
|
combined = product.value;
|
|
4147
4204
|
}
|
|
4148
|
-
const inv =
|
|
4205
|
+
const inv = chunkUM6BVY2S_cjs.inverse(combined);
|
|
4149
4206
|
if (inv.type === 13 /* Error */) return inv;
|
|
4150
|
-
const rhsValue = this.executeSymbolicTolerant(equation.rhsProgram);
|
|
4207
|
+
const rhsValue = this.executeSymbolicTolerant(equation.rhsProgram, lineNumber);
|
|
4151
4208
|
if (rhsValue.type !== 7 /* Matrix */) {
|
|
4152
|
-
return
|
|
4209
|
+
return chunkJMXUNXQS_cjs.errorValue(
|
|
4153
4210
|
"EQUATION_RHS_NOT_MATRIX",
|
|
4154
4211
|
`Cannot solve for "${equation.variable}": the right-hand side must be a Matrix.`
|
|
4155
4212
|
);
|
|
4156
4213
|
}
|
|
4157
|
-
return
|
|
4214
|
+
return chunkUM6BVY2S_cjs.matrixMultiply(inv.value, rhsValue.value);
|
|
4158
4215
|
}
|
|
4159
4216
|
/**
|
|
4160
4217
|
* Detects and handles this session's two new symbolic-algebra grammar
|
|
@@ -4187,31 +4244,31 @@ var ExpressionEngine = class {
|
|
|
4187
4244
|
* session's own Phase H.2 scope decision (full symbolic MATRICES, not
|
|
4188
4245
|
* a general CAS).
|
|
4189
4246
|
*/
|
|
4190
|
-
trySymbolicGrammar(normalizedTokens) {
|
|
4247
|
+
trySymbolicGrammar(normalizedTokens, lineNumber = -1) {
|
|
4191
4248
|
if (normalizedTokens.length === 0) return null;
|
|
4192
4249
|
const last = normalizedTokens[normalizedTokens.length - 1];
|
|
4193
4250
|
if (last.type === "THEREFORE") {
|
|
4194
4251
|
const beforeTokens = normalizedTokens.slice(0, -1);
|
|
4195
4252
|
if (beforeTokens.length === 0) {
|
|
4196
|
-
throw
|
|
4253
|
+
throw chunk5KMIY374_cjs.ErrorFactory.parsing("THEREFORE_REQUIRES_EXPRESSION", `"=>" needs an expression or variable name before it.`);
|
|
4197
4254
|
}
|
|
4198
4255
|
if (beforeTokens.length === 1 && (beforeTokens[0].type === "IDENT" || beforeTokens[0].type === "UNIT")) {
|
|
4199
4256
|
const name = beforeTokens[0].value;
|
|
4200
4257
|
const equation = this.vm.getEquation(name);
|
|
4201
4258
|
const scalar = this.vm.getScalarEquation(name);
|
|
4202
4259
|
if (equation) {
|
|
4203
|
-
const solved = this.solveEquation(equation);
|
|
4260
|
+
const solved = this.solveEquation(equation, lineNumber);
|
|
4204
4261
|
const isNotMatrix = solved.type === 13 /* Error */ && solved.value === "EQUATION_FACTOR_NOT_MATRIX";
|
|
4205
4262
|
if (!isNotMatrix || !scalar) return solved;
|
|
4206
4263
|
}
|
|
4207
4264
|
if (scalar) {
|
|
4208
|
-
return this.solveScalarEquation(scalar);
|
|
4265
|
+
return this.solveScalarEquation(scalar, lineNumber);
|
|
4209
4266
|
}
|
|
4210
4267
|
}
|
|
4211
|
-
return this.simplifySymbolically(beforeTokens);
|
|
4268
|
+
return this.simplifySymbolically(beforeTokens, lineNumber);
|
|
4212
4269
|
}
|
|
4213
|
-
if (
|
|
4214
|
-
return this.simplifySymbolically(normalizedTokens);
|
|
4270
|
+
if (chunk3AFRJYP4_cjs.containsSymbolicCall(normalizedTokens)) {
|
|
4271
|
+
return this.simplifySymbolically(normalizedTokens, lineNumber);
|
|
4215
4272
|
}
|
|
4216
4273
|
if (normalizedTokens[0].type === "COLON" || normalizedTokens[0].type === "GLOBAL") return null;
|
|
4217
4274
|
const eqIdx = normalizedTokens.findIndex((t) => t.type === "EQUALS");
|
|
@@ -4222,7 +4279,7 @@ var ExpressionEngine = class {
|
|
|
4222
4279
|
}
|
|
4223
4280
|
const rhsTokens = normalizedTokens.slice(eqIdx + 1);
|
|
4224
4281
|
if (names.length === 1) {
|
|
4225
|
-
const result = this.simplifySymbolically(rhsTokens);
|
|
4282
|
+
const result = this.simplifySymbolically(rhsTokens, lineNumber);
|
|
4226
4283
|
this.vm.setVar(names[0], result);
|
|
4227
4284
|
return result;
|
|
4228
4285
|
}
|
|
@@ -4230,7 +4287,7 @@ var ExpressionEngine = class {
|
|
|
4230
4287
|
const factorNames = names.slice(0, -1);
|
|
4231
4288
|
this.vm.defineEquation(freeVar, factorNames, this.compileAdHoc(rhsTokens));
|
|
4232
4289
|
this.vm.defineScalarEquation(freeVar, this.compileAdHoc(normalizedTokens.slice(0, eqIdx)), this.compileAdHoc(rhsTokens));
|
|
4233
|
-
return
|
|
4290
|
+
return chunkJMXUNXQS_cjs.stringValue(`${freeVar} stored as an equation \u2014 solve with "${freeVar} =>"`);
|
|
4234
4291
|
}
|
|
4235
4292
|
/**
|
|
4236
4293
|
* Stores a general scalar equation (`x^2 - 4 = 0`) keyed by its unknown, or
|
|
@@ -4272,7 +4329,7 @@ var ExpressionEngine = class {
|
|
|
4272
4329
|
if (unknowns.length !== 1) return null;
|
|
4273
4330
|
const variable = unknowns[0];
|
|
4274
4331
|
this.vm.defineScalarEquation(variable, this.compileAdHoc(lhsTokens), this.compileAdHoc(rhsTokens));
|
|
4275
|
-
return
|
|
4332
|
+
return chunkJMXUNXQS_cjs.stringValue(`${variable} stored as an equation \u2014 solve with "${variable} =>"`);
|
|
4276
4333
|
}
|
|
4277
4334
|
/**
|
|
4278
4335
|
* The names in an equation that have no value yet, which is what makes them
|
|
@@ -4308,10 +4365,10 @@ var ExpressionEngine = class {
|
|
|
4308
4365
|
* @returns The solution, rendered by the same helper `solve()` uses, so the
|
|
4309
4366
|
* two surfaces cannot disagree about how an outcome reads.
|
|
4310
4367
|
*/
|
|
4311
|
-
solveScalarEquation(equation) {
|
|
4312
|
-
const lhs = this.executeSymbolicTolerant(equation.lhsProgram);
|
|
4313
|
-
const rhs = this.executeSymbolicTolerant(equation.rhsProgram);
|
|
4314
|
-
return
|
|
4368
|
+
solveScalarEquation(equation, lineNumber = -1) {
|
|
4369
|
+
const lhs = this.executeSymbolicTolerant(equation.lhsProgram, lineNumber);
|
|
4370
|
+
const rhs = this.executeSymbolicTolerant(equation.rhsProgram, lineNumber);
|
|
4371
|
+
return chunk6WFMPTGB_cjs.solveEquationValues(lhs, rhs, equation.variable);
|
|
4315
4372
|
}
|
|
4316
4373
|
//#endregion
|
|
4317
4374
|
/**
|
|
@@ -4388,7 +4445,7 @@ var ExpressionEngine = class {
|
|
|
4388
4445
|
* produced negative-allocation readings (a GC sweep landing inside the
|
|
4389
4446
|
* wider window) in `AllocationTracker.spec.ts` well over half the time.
|
|
4390
4447
|
*/
|
|
4391
|
-
prepareExpression(expression, tokens, hasParens, onFusion) {
|
|
4448
|
+
prepareExpression(expression, tokens, hasParens, onFusion, lineNumber = -1) {
|
|
4392
4449
|
const lengthCheck = checkExpressionLength(expression, this.config.validation);
|
|
4393
4450
|
if (!lengthCheck.passed) {
|
|
4394
4451
|
return { kind: "error", stage: "length", error: lengthCheck.error.engineError };
|
|
@@ -4402,7 +4459,7 @@ var ExpressionEngine = class {
|
|
|
4402
4459
|
if (!complexityCheck.passed) {
|
|
4403
4460
|
return { kind: "error", stage: "complexity", error: complexityCheck.engineError, normalizedTokens };
|
|
4404
4461
|
}
|
|
4405
|
-
const symbolicResult = this.trySymbolicGrammar(normalizedTokens);
|
|
4462
|
+
const symbolicResult = this.trySymbolicGrammar(normalizedTokens, lineNumber);
|
|
4406
4463
|
if (symbolicResult !== null) {
|
|
4407
4464
|
return { kind: "symbolic-solve", normalizedTokens, value: symbolicResult };
|
|
4408
4465
|
}
|
|
@@ -4423,7 +4480,7 @@ var ExpressionEngine = class {
|
|
|
4423
4480
|
program = parseResult.result;
|
|
4424
4481
|
parserAlloc = parseResult.alloc;
|
|
4425
4482
|
} catch (e) {
|
|
4426
|
-
return { kind: "error", stage: "parse", error:
|
|
4483
|
+
return { kind: "error", stage: "parse", error: chunk5KMIY374_cjs.normalizeUnknownError(e), reads, writes, normalizedTokens };
|
|
4427
4484
|
}
|
|
4428
4485
|
this.cacheBytecode(expression, program);
|
|
4429
4486
|
return { kind: "ready", normalizedTokens, reads, writes, program, cached: false, parserAlloc };
|
|
@@ -4485,7 +4542,7 @@ var ExpressionEngine = class {
|
|
|
4485
4542
|
asyncCheck.packageId || "_engine",
|
|
4486
4543
|
[asyncCheck.queryKey]
|
|
4487
4544
|
);
|
|
4488
|
-
const pending =
|
|
4545
|
+
const pending = chunkJMXUNXQS_cjs.pendingValue(asyncCheck.queryKey);
|
|
4489
4546
|
this.storeLineResult(lineNumber, pending, program, reads, writes, expression);
|
|
4490
4547
|
return { kind: "pending", value: pending };
|
|
4491
4548
|
}
|
|
@@ -4509,9 +4566,9 @@ var ExpressionEngine = class {
|
|
|
4509
4566
|
* {@link preflightAsync}) + VM execution (via {@link executeAndStore}).
|
|
4510
4567
|
*/
|
|
4511
4568
|
evaluateWithTokens(lineNumber, expression, tokens, hasParens) {
|
|
4512
|
-
const prep = this.prepareExpression(expression, tokens, hasParens);
|
|
4569
|
+
const prep = this.prepareExpression(expression, tokens, hasParens, void 0, lineNumber);
|
|
4513
4570
|
if (prep.kind === "empty") {
|
|
4514
|
-
const v =
|
|
4571
|
+
const v = chunkJMXUNXQS_cjs.numberValue(0);
|
|
4515
4572
|
this.lineCache.set(lineNumber, new LineCacheEntry(v, { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, [], null), expression);
|
|
4516
4573
|
return v;
|
|
4517
4574
|
}
|
|
@@ -4554,13 +4611,13 @@ var ExpressionEngine = class {
|
|
|
4554
4611
|
if (result.engineError) {
|
|
4555
4612
|
throw result.engineError;
|
|
4556
4613
|
}
|
|
4557
|
-
throw
|
|
4614
|
+
throw chunk5KMIY374_cjs.ErrorFactory.execution(
|
|
4558
4615
|
"EVALUATION_ERROR",
|
|
4559
4616
|
result.error,
|
|
4560
4617
|
{ lineNumber }
|
|
4561
4618
|
);
|
|
4562
4619
|
}
|
|
4563
|
-
return { values: [
|
|
4620
|
+
return { values: [chunkJMXUNXQS_cjs.freezeIfDev(result.value)] };
|
|
4564
4621
|
}
|
|
4565
4622
|
/**
|
|
4566
4623
|
* Evaluate a line with diagnostic information, supporting both regular expressions and inline solves.
|
|
@@ -4795,7 +4852,7 @@ var ExpressionEngine = class {
|
|
|
4795
4852
|
});
|
|
4796
4853
|
}
|
|
4797
4854
|
if (tokens.length === 0) {
|
|
4798
|
-
const v =
|
|
4855
|
+
const v = chunkJMXUNXQS_cjs.numberValue(0);
|
|
4799
4856
|
this.lineCache.set(lineNumber, new LineCacheEntry(v, { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, [], null), expression);
|
|
4800
4857
|
if (hasCollectors) {
|
|
4801
4858
|
pipeline.firePipelineEnd({
|
|
@@ -4838,7 +4895,7 @@ var ExpressionEngine = class {
|
|
|
4838
4895
|
if (hasCollectors && !cachedBefore) {
|
|
4839
4896
|
this.parser.setDiagnosticPipeline(pipeline, expression);
|
|
4840
4897
|
}
|
|
4841
|
-
const prep = this.prepareExpression(expression, tokens, hasParens, onFusion);
|
|
4898
|
+
const prep = this.prepareExpression(expression, tokens, hasParens, onFusion, lineNumber);
|
|
4842
4899
|
if (trackEnabled && prep.kind === "ready" && prep.parserAlloc) {
|
|
4843
4900
|
stageAllocs.push(prep.parserAlloc);
|
|
4844
4901
|
}
|
|
@@ -4888,12 +4945,12 @@ var ExpressionEngine = class {
|
|
|
4888
4945
|
});
|
|
4889
4946
|
}
|
|
4890
4947
|
if (prep.kind === "empty") {
|
|
4891
|
-
const v =
|
|
4948
|
+
const v = chunkJMXUNXQS_cjs.numberValue(0);
|
|
4892
4949
|
this.lineCache.set(lineNumber, new LineCacheEntry(v, { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, [], null), expression);
|
|
4893
4950
|
return { value: v, tokens, program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, debug: void 0, diagnostic: void 0 };
|
|
4894
4951
|
}
|
|
4895
4952
|
return {
|
|
4896
|
-
value:
|
|
4953
|
+
value: chunkJMXUNXQS_cjs.numberValue(0),
|
|
4897
4954
|
tokens: [],
|
|
4898
4955
|
program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false },
|
|
4899
4956
|
error: prep.error.message,
|
|
@@ -4927,7 +4984,7 @@ var ExpressionEngine = class {
|
|
|
4927
4984
|
});
|
|
4928
4985
|
}
|
|
4929
4986
|
return {
|
|
4930
|
-
value:
|
|
4987
|
+
value: chunkJMXUNXQS_cjs.numberValue(0),
|
|
4931
4988
|
tokens: [],
|
|
4932
4989
|
program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false },
|
|
4933
4990
|
error: complexityCheck.errorMessage,
|
|
@@ -5003,7 +5060,7 @@ var ExpressionEngine = class {
|
|
|
5003
5060
|
});
|
|
5004
5061
|
}
|
|
5005
5062
|
return {
|
|
5006
|
-
value:
|
|
5063
|
+
value: chunkJMXUNXQS_cjs.numberValue(0),
|
|
5007
5064
|
tokens: normalizedTokens,
|
|
5008
5065
|
program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false },
|
|
5009
5066
|
error: prep.error.message,
|
|
@@ -5013,7 +5070,7 @@ var ExpressionEngine = class {
|
|
|
5013
5070
|
};
|
|
5014
5071
|
}
|
|
5015
5072
|
if (prep.kind !== "ready") {
|
|
5016
|
-
throw
|
|
5073
|
+
throw chunk5KMIY374_cjs.ErrorFactory.internal({
|
|
5017
5074
|
code: "UNEXPECTED_ERROR",
|
|
5018
5075
|
message: "Internal error: prepareExpression() returned an unexpected variant after all other cases were handled"
|
|
5019
5076
|
});
|
|
@@ -5099,7 +5156,7 @@ var ExpressionEngine = class {
|
|
|
5099
5156
|
result = vmResult.result;
|
|
5100
5157
|
if (trackEnabled && vmResult.alloc) stageAllocs.push(vmResult.alloc);
|
|
5101
5158
|
} catch (e) {
|
|
5102
|
-
const engineError =
|
|
5159
|
+
const engineError = chunk5KMIY374_cjs.normalizeUnknownError(e);
|
|
5103
5160
|
if (hasCollectors) {
|
|
5104
5161
|
pipeline.firePipelineEnd({
|
|
5105
5162
|
type: chunk47LRVGOT_cjs.DiagnosticEventType.PipelineEnd,
|
|
@@ -5111,7 +5168,7 @@ var ExpressionEngine = class {
|
|
|
5111
5168
|
});
|
|
5112
5169
|
}
|
|
5113
5170
|
return {
|
|
5114
|
-
value:
|
|
5171
|
+
value: chunkJMXUNXQS_cjs.numberValue(0),
|
|
5115
5172
|
tokens: normalizedTokens,
|
|
5116
5173
|
program,
|
|
5117
5174
|
error: engineError.message,
|
|
@@ -5305,14 +5362,14 @@ var ExpressionEngine = class {
|
|
|
5305
5362
|
packageId: asyncCheck.packageId || "_engine",
|
|
5306
5363
|
signal: asyncCheck.signal
|
|
5307
5364
|
});
|
|
5308
|
-
return
|
|
5365
|
+
return chunkJMXUNXQS_cjs.pendingValue(asyncCheck.queryKey);
|
|
5309
5366
|
}
|
|
5310
5367
|
this.keystrokeSignal?.removeEventListener("abort", abortPreflight);
|
|
5311
5368
|
}
|
|
5312
5369
|
const evalResult = this.executeRaw(program, lineNumber);
|
|
5313
5370
|
if (evalResult.type === "pending") {
|
|
5314
5371
|
void this.resolveAsync(evalResult);
|
|
5315
|
-
return
|
|
5372
|
+
return chunkJMXUNXQS_cjs.pendingValue(evalResult.queryKey);
|
|
5316
5373
|
}
|
|
5317
5374
|
if (evalResult.type === "error") {
|
|
5318
5375
|
throw evalResult.error;
|
|
@@ -5579,7 +5636,7 @@ var ExpressionEngine = class {
|
|
|
5579
5636
|
}
|
|
5580
5637
|
if (prep.kind === "error") {
|
|
5581
5638
|
if (prep.stage === "parse" && (prep.reads?.length || prep.writes?.length)) {
|
|
5582
|
-
throw new
|
|
5639
|
+
throw new chunk5KMIY374_cjs.EngineError(prep.error.category, {
|
|
5583
5640
|
code: prep.error.code,
|
|
5584
5641
|
message: prep.error.message,
|
|
5585
5642
|
expected: prep.error.expected,
|
|
@@ -5649,12 +5706,12 @@ var ExpressionEngine = class {
|
|
|
5649
5706
|
*/
|
|
5650
5707
|
executeCached(program, lineNumber = -1) {
|
|
5651
5708
|
if (program.opcodes.length === 0) {
|
|
5652
|
-
return
|
|
5709
|
+
return chunkJMXUNXQS_cjs.numberValue(0);
|
|
5653
5710
|
}
|
|
5654
5711
|
const evalResult = this.executeRaw(program, lineNumber);
|
|
5655
5712
|
if (evalResult.type === "pending") {
|
|
5656
5713
|
void this.resolveAsync(evalResult);
|
|
5657
|
-
return
|
|
5714
|
+
return chunkJMXUNXQS_cjs.pendingValue(evalResult.queryKey);
|
|
5658
5715
|
}
|
|
5659
5716
|
if (evalResult.type === "error") {
|
|
5660
5717
|
throw evalResult.error;
|
|
@@ -5713,7 +5770,7 @@ var ExpressionEngine = class {
|
|
|
5713
5770
|
*/
|
|
5714
5771
|
evaluateIncremental(variable, newValue) {
|
|
5715
5772
|
const affectedLines = this.dag.getAffectedLinesInOrder(variable);
|
|
5716
|
-
this.vm.setVar(variable,
|
|
5773
|
+
this.vm.setVar(variable, chunkJMXUNXQS_cjs.numberValue(newValue));
|
|
5717
5774
|
const updated = /* @__PURE__ */ new Map();
|
|
5718
5775
|
for (const lineNumber of affectedLines) {
|
|
5719
5776
|
const entry = this.lineCache.getEntryForLine(lineNumber);
|
|
@@ -5724,7 +5781,7 @@ var ExpressionEngine = class {
|
|
|
5724
5781
|
continue;
|
|
5725
5782
|
}
|
|
5726
5783
|
if (evalResult.type === "error") {
|
|
5727
|
-
const value =
|
|
5784
|
+
const value = chunkJMXUNXQS_cjs.errorValue(evalResult.error.code, evalResult.error.message);
|
|
5728
5785
|
updated.set(lineNumber, value);
|
|
5729
5786
|
entry.result = value;
|
|
5730
5787
|
continue;
|
|
@@ -5947,7 +6004,14 @@ function pseudoRandom(seed) {
|
|
|
5947
6004
|
|
|
5948
6005
|
// src/engine/DocumentModel.ts
|
|
5949
6006
|
var DocumentModel = class {
|
|
5950
|
-
|
|
6007
|
+
/**
|
|
6008
|
+
* @param maxLines - Ceiling on the line count, defaulting to the engine's
|
|
6009
|
+
* configured one. Every line costs a LineState with six arrays in it
|
|
6010
|
+
* whatever the line says, so the cost of a document is its line count and
|
|
6011
|
+
* nothing else bounds it: two hundred thousand lines of `1 + 1` exhausted
|
|
6012
|
+
* the heap here, before a single expression had been looked at.
|
|
6013
|
+
*/
|
|
6014
|
+
constructor(maxLines = chunkE4NUZXVK_cjs.DEFAULT_CONFIG.performance.maxDocumentLines) {
|
|
5951
6015
|
/** Persistent line ID → LineState. */
|
|
5952
6016
|
this.lines = /* @__PURE__ */ new Map();
|
|
5953
6017
|
/** Order-statistic treap representing the current document line order. */
|
|
@@ -5972,13 +6036,26 @@ var DocumentModel = class {
|
|
|
5972
6036
|
* bottom of a 20k-line document before this fix.
|
|
5973
6037
|
*/
|
|
5974
6038
|
this.dirtyLineIds = /* @__PURE__ */ new Set();
|
|
6039
|
+
this.maxLines = maxLines;
|
|
5975
6040
|
}
|
|
5976
6041
|
// ── Initialization ──────────────────────────────────────────────────
|
|
5977
6042
|
/**
|
|
5978
6043
|
* Initialize or replace the entire document from a text blob.
|
|
5979
6044
|
* Clears all existing state and assigns new persistent line IDs.
|
|
6045
|
+
*
|
|
6046
|
+
* @throws `DOCUMENT_TOO_LARGE` for a document past {@link maxLines}, before
|
|
6047
|
+
* any of it is stored. Recoverable: nothing has been replaced yet, so the
|
|
6048
|
+
* model still holds whatever it held.
|
|
5980
6049
|
*/
|
|
5981
6050
|
setDocument(text) {
|
|
6051
|
+
const lineCount = chunkADBA3XBE_cjs.countLines(text, this.maxLines);
|
|
6052
|
+
if (lineCount > this.maxLines) {
|
|
6053
|
+
throw chunk5KMIY374_cjs.ErrorFactory.execution(
|
|
6054
|
+
"DOCUMENT_TOO_LARGE",
|
|
6055
|
+
`This document has more than ${this.maxLines.toLocaleString("en-US")} lines, which is the most the engine will hold at once`,
|
|
6056
|
+
{ maxLines: this.maxLines }
|
|
6057
|
+
);
|
|
6058
|
+
}
|
|
5982
6059
|
this.lines.clear();
|
|
5983
6060
|
this.orderTree.clear();
|
|
5984
6061
|
this._positionCache = null;
|
|
@@ -6693,7 +6770,7 @@ var PageManager = class _PageManager {
|
|
|
6693
6770
|
});
|
|
6694
6771
|
}
|
|
6695
6772
|
} else {
|
|
6696
|
-
const inlineSpans =
|
|
6773
|
+
const inlineSpans = chunkKBSXGXPM_cjs.sharedLexer.findInlineSolves(state.text);
|
|
6697
6774
|
if (inlineSpans.length > 0) {
|
|
6698
6775
|
for (const span of inlineSpans) {
|
|
6699
6776
|
if (!span.expression.trim()) continue;
|
|
@@ -6799,8 +6876,8 @@ var ThreeTierEvaluator = class {
|
|
|
6799
6876
|
this.checkpointer = checkpointer ?? null;
|
|
6800
6877
|
this.pageManager = new PageManager();
|
|
6801
6878
|
this.engine.setDocumentModel(this.doc);
|
|
6802
|
-
this.globalUnsubscribe =
|
|
6803
|
-
for (const lineNumber of this.dag.getAffectedLines(
|
|
6879
|
+
this.globalUnsubscribe = chunk6WFMPTGB_cjs.sharedGlobalVariableStore.subscribe((name) => {
|
|
6880
|
+
for (const lineNumber of this.dag.getAffectedLines(chunk6WFMPTGB_cjs.globalDagKey(name))) {
|
|
6804
6881
|
this.doc.markDirtyByLineNumber(lineNumber);
|
|
6805
6882
|
}
|
|
6806
6883
|
});
|
|
@@ -6817,7 +6894,7 @@ var ThreeTierEvaluator = class {
|
|
|
6817
6894
|
*/
|
|
6818
6895
|
evaluate(viewport, signal) {
|
|
6819
6896
|
this.engine.setKeystrokeSignal(signal ?? null);
|
|
6820
|
-
|
|
6897
|
+
chunkJMXUNXQS_cjs.enableValueArena();
|
|
6821
6898
|
try {
|
|
6822
6899
|
const lines = [];
|
|
6823
6900
|
const resultMap = /* @__PURE__ */ new Map();
|
|
@@ -6845,7 +6922,7 @@ var ThreeTierEvaluator = class {
|
|
|
6845
6922
|
return { lines, resultMap, tierCounts };
|
|
6846
6923
|
} finally {
|
|
6847
6924
|
this.engine.setKeystrokeSignal(null);
|
|
6848
|
-
|
|
6925
|
+
chunkJMXUNXQS_cjs.disableValueArena();
|
|
6849
6926
|
}
|
|
6850
6927
|
}
|
|
6851
6928
|
/**
|
|
@@ -6978,13 +7055,13 @@ var ThreeTierEvaluator = class {
|
|
|
6978
7055
|
this.pageManager.maintainAfterEval(viewport, this.doc);
|
|
6979
7056
|
this.preloadNextPages(viewport);
|
|
6980
7057
|
this.restoreTo(viewport.startLine - 1);
|
|
6981
|
-
|
|
7058
|
+
chunkJMXUNXQS_cjs.enableValueArena();
|
|
6982
7059
|
try {
|
|
6983
7060
|
const result = this.collectEvalResults(viewport.startLine, viewport.endLine);
|
|
6984
7061
|
return result;
|
|
6985
7062
|
} finally {
|
|
6986
7063
|
this.engine.setKeystrokeSignal(null);
|
|
6987
|
-
|
|
7064
|
+
chunkJMXUNXQS_cjs.disableValueArena();
|
|
6988
7065
|
}
|
|
6989
7066
|
}
|
|
6990
7067
|
/**
|
|
@@ -7187,7 +7264,7 @@ var ThreeTierEvaluator = class {
|
|
|
7187
7264
|
if (value) {
|
|
7188
7265
|
allResults.push(value);
|
|
7189
7266
|
} else {
|
|
7190
|
-
allResults.push([
|
|
7267
|
+
allResults.push([chunkJMXUNXQS_cjs.errorValue("eval_failed", firstError ?? "unknown error")]);
|
|
7191
7268
|
}
|
|
7192
7269
|
if (entry) {
|
|
7193
7270
|
allBytecodes.push(entry.bytecode);
|
|
@@ -7205,7 +7282,7 @@ var ThreeTierEvaluator = class {
|
|
|
7205
7282
|
if (writes2.length > 0) hasVariableDef = true;
|
|
7206
7283
|
} catch (compileErr) {
|
|
7207
7284
|
allBytecodes.push({ opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false });
|
|
7208
|
-
if (compileErr instanceof
|
|
7285
|
+
if (compileErr instanceof chunk5KMIY374_cjs.EngineError && compileErr.context) {
|
|
7209
7286
|
const errReads = compileErr.context.reads;
|
|
7210
7287
|
const errWrites = compileErr.context.writes;
|
|
7211
7288
|
if (Array.isArray(errReads)) for (const r of errReads) allReads.add(r);
|
|
@@ -7281,7 +7358,7 @@ var ThreeTierEvaluator = class {
|
|
|
7281
7358
|
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
7282
7359
|
if (!firstError) firstError = errorMessage;
|
|
7283
7360
|
anyFailed = true;
|
|
7284
|
-
results.push([
|
|
7361
|
+
results.push([chunkJMXUNXQS_cjs.errorValue("exec_failed", errorMessage)]);
|
|
7285
7362
|
}
|
|
7286
7363
|
}
|
|
7287
7364
|
this.dag.registerLine(lineNumber, state.reads, state.writes);
|
|
@@ -7459,7 +7536,7 @@ var ThreeTierEvaluator = class {
|
|
|
7459
7536
|
}
|
|
7460
7537
|
const trimmed = state.text.trim();
|
|
7461
7538
|
if (trimmed.length === 0) return { expressions: [], inlineSolveCount: 0 };
|
|
7462
|
-
const inlineSpans =
|
|
7539
|
+
const inlineSpans = chunkKBSXGXPM_cjs.sharedLexer.findInlineSolves(state.text);
|
|
7463
7540
|
if (inlineSpans.length > 0) {
|
|
7464
7541
|
return {
|
|
7465
7542
|
expressions: inlineSpans.map((s) => s.expression),
|
|
@@ -7483,5 +7560,5 @@ exports.checkPackageCompatibility = checkPackageCompatibility;
|
|
|
7483
7560
|
exports.extractReadsAndWrites = extractReadsAndWrites;
|
|
7484
7561
|
exports.findInlineSolvesInLine = findInlineSolvesInLine;
|
|
7485
7562
|
exports.isEmptyLine = isEmptyLine;
|
|
7486
|
-
//# sourceMappingURL=chunk-
|
|
7487
|
-
//# sourceMappingURL=chunk-
|
|
7563
|
+
//# sourceMappingURL=chunk-U5VAY32K.cjs.map
|
|
7564
|
+
//# sourceMappingURL=chunk-U5VAY32K.cjs.map
|