solve-engine 1.0.1 → 1.1.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-B0xskcv5.d.cts → BytecodeBuilder-Bp9xeTmX.d.cts} +4 -0
- package/dist/{BytecodeBuilder-B0xskcv5.d.ts → BytecodeBuilder-Bp9xeTmX.d.ts} +4 -0
- package/dist/{Configuration-B-G5gTRn.d.cts → Configuration-C9W8tJv_.d.cts} +53 -1
- package/dist/{Configuration-B-G5gTRn.d.ts → Configuration-C9W8tJv_.d.ts} +53 -1
- package/dist/{EngineError-LU7W7AgI.d.cts → EngineError-B61GS1jp.d.cts} +14 -0
- package/dist/{EngineError-LU7W7AgI.d.ts → EngineError-B61GS1jp.d.ts} +14 -0
- package/dist/FormattingSettings-CJHyxcYu.d.cts +27 -0
- package/dist/FormattingSettings-CJHyxcYu.d.ts +27 -0
- package/dist/{Lexer-D78E2yDW.d.cts → Lexer-BOs7euZe.d.cts} +58 -1
- package/dist/{Lexer-BN5mt30n.d.ts → Lexer-CSI_lwbW.d.ts} +58 -1
- package/dist/PackageCompatibility-B-7rK1TD.d.cts +76 -0
- package/dist/PackageCompatibility-Dh59eF-X.d.ts +76 -0
- package/dist/{PackageRegistry-B37mRvvz.d.cts → PackageRegistry-BHWJP83F.d.cts} +449 -11
- package/dist/{PackageRegistry-DCUEzbQt.d.ts → PackageRegistry-_8rDlvxI.d.ts} +449 -11
- package/dist/{Parselet-BaySkMV3.d.ts → Parselet-BBT8riYh.d.ts} +12 -3
- package/dist/{Parselet-DuI1Pjiq.d.cts → Parselet-BHcgK9S7.d.cts} +12 -3
- package/dist/{ScopeManager-B6GzdhVG.d.cts → ScopeManager-8vf02dwj.d.cts} +56 -5
- package/dist/{ScopeManager-udv4Twwq.d.ts → ScopeManager-CxA24W5n.d.ts} +56 -5
- package/dist/{Token-BzG5G4ja.d.cts → Token-B1hdkedD.d.cts} +9 -0
- package/dist/{Token-BzG5G4ja.d.ts → Token-B1hdkedD.d.ts} +9 -0
- package/dist/{TokenNormalizer-t_GotBxr.d.ts → TokenNormalizer-C6VzZgHa.d.ts} +1 -1
- package/dist/{TokenNormalizer-DGVa24Q-.d.cts → TokenNormalizer-DRc1Js1V.d.cts} +1 -1
- package/dist/{VMCheckpoints-DwLjivM7.d.cts → VMCheckpoints-ELYqITdF.d.cts} +3 -3
- package/dist/{VMCheckpoints-BiaIlOOY.d.ts → VMCheckpoints-MK--EBH2.d.ts} +3 -3
- package/dist/{Value-CXJqDH9J.d.cts → Value-BUi1RA3S.d.cts} +124 -5
- package/dist/{Value-CXJqDH9J.d.ts → Value-BUi1RA3S.d.ts} +124 -5
- package/dist/WorkerError-_-RkoQ5P.d.ts +75 -0
- package/dist/WorkerError-gzmaopj2.d.cts +75 -0
- package/dist/{chunk-GQCOSXMG.js → chunk-267JPOTF.js} +43 -5
- package/dist/chunk-267JPOTF.js.map +1 -0
- package/dist/{chunk-JMXUNXQS.cjs → chunk-2TZKENDH.cjs} +51 -8
- package/dist/chunk-2TZKENDH.cjs.map +1 -0
- package/dist/chunk-3OWCDIPN.js +215 -0
- package/dist/chunk-3OWCDIPN.js.map +1 -0
- package/dist/{chunk-VB37OC6I.js → chunk-4D6NIHE2.js} +40 -3
- package/dist/chunk-4D6NIHE2.js.map +1 -0
- package/dist/{chunk-TY3TLZAW.cjs → chunk-536WPM2V.cjs} +18 -2
- package/dist/chunk-536WPM2V.cjs.map +1 -0
- package/dist/chunk-5HRB36DK.js +405 -0
- package/dist/chunk-5HRB36DK.js.map +1 -0
- package/dist/chunk-5ON7PUAZ.js +12 -0
- package/dist/chunk-5ON7PUAZ.js.map +1 -0
- package/dist/{chunk-KV7UW6T6.js → chunk-7KYSUDQO.js} +12 -5
- package/dist/chunk-7KYSUDQO.js.map +1 -0
- package/dist/{chunk-6WFMPTGB.cjs → chunk-7ZX6B7SY.cjs} +774 -528
- package/dist/chunk-7ZX6B7SY.cjs.map +1 -0
- package/dist/chunk-ALYRJ72W.cjs +434 -0
- package/dist/chunk-ALYRJ72W.cjs.map +1 -0
- package/dist/{chunk-5KMIY374.cjs → chunk-B4HBEFTB.cjs} +17 -2
- package/dist/chunk-B4HBEFTB.cjs.map +1 -0
- package/dist/chunk-B7NLZMQ3.cjs +74 -0
- package/dist/chunk-B7NLZMQ3.cjs.map +1 -0
- package/dist/{chunk-UQ3UIZJC.js → chunk-BLI4NIQY.js} +6 -2
- package/dist/chunk-BLI4NIQY.js.map +1 -0
- package/dist/{chunk-BHTNFEGZ.cjs → chunk-C75AFGVD.cjs} +11 -11
- package/dist/{chunk-BHTNFEGZ.cjs.map → chunk-C75AFGVD.cjs.map} +1 -1
- package/dist/{chunk-G535KJEG.js → chunk-CCBZZQAE.js} +2 -2
- package/dist/{chunk-G535KJEG.js.map → chunk-CCBZZQAE.js.map} +1 -1
- package/dist/chunk-CKQMXMHR.cjs +219 -0
- package/dist/chunk-CKQMXMHR.cjs.map +1 -0
- package/dist/{chunk-PFUESQTW.cjs → chunk-EJ3ILXX6.cjs} +48 -2
- package/dist/chunk-EJ3ILXX6.cjs.map +1 -0
- package/dist/{chunk-526PMQOA.js → chunk-ENKKJYD3.js} +10 -4
- package/dist/chunk-ENKKJYD3.js.map +1 -0
- package/dist/{chunk-5X2PTP6F.cjs → chunk-ENRIK36Q.cjs} +2 -12
- package/dist/chunk-ENRIK36Q.cjs.map +1 -0
- package/dist/{chunk-3D7V24DG.js → chunk-ERCOHGXD.js} +17 -2
- package/dist/chunk-ERCOHGXD.js.map +1 -0
- package/dist/{chunk-IF532O7C.js → chunk-FD5ZZHEU.js} +3 -12
- package/dist/chunk-FD5ZZHEU.js.map +1 -0
- package/dist/{chunk-TBN7DEHO.js → chunk-G7Z4HJQA.js} +11 -5
- package/dist/chunk-G7Z4HJQA.js.map +1 -0
- package/dist/{chunk-QY25VWBF.js → chunk-GQMUHVE3.js} +142 -6
- package/dist/chunk-GQMUHVE3.js.map +1 -0
- package/dist/chunk-GUG7SNSV.js +1764 -0
- package/dist/chunk-GUG7SNSV.js.map +1 -0
- package/dist/{chunk-UM6BVY2S.cjs → chunk-HIQ5HSZL.cjs} +175 -43
- package/dist/chunk-HIQ5HSZL.cjs.map +1 -0
- package/dist/{chunk-HVQFNJKE.cjs → chunk-HVRVSI2Z.cjs} +104 -86
- package/dist/chunk-HVRVSI2Z.cjs.map +1 -0
- package/dist/{chunk-3LAEG75D.js → chunk-I4GAWIPW.js} +24 -6
- package/dist/chunk-I4GAWIPW.js.map +1 -0
- package/dist/{chunk-PA4VC73I.cjs → chunk-J45BCEZ4.cjs} +33 -27
- package/dist/chunk-J45BCEZ4.cjs.map +1 -0
- package/dist/{chunk-V5PYO44Y.js → chunk-JIPATHVY.js} +1853 -2638
- package/dist/chunk-JIPATHVY.js.map +1 -0
- package/dist/{chunk-YPPPYLSR.js → chunk-JJIXHXFQ.js} +5 -5
- package/dist/{chunk-YPPPYLSR.js.map → chunk-JJIXHXFQ.js.map} +1 -1
- package/dist/chunk-L2TE7PMO.cjs +14 -0
- package/dist/chunk-L2TE7PMO.cjs.map +1 -0
- package/dist/{chunk-B7TLZABL.cjs → chunk-MG6Q3DUO.cjs} +1962 -2746
- package/dist/chunk-MG6Q3DUO.cjs.map +1 -0
- package/dist/{chunk-R3PY4G7J.js → chunk-MVTOCRV2.js} +48 -3
- package/dist/chunk-MVTOCRV2.js.map +1 -0
- package/dist/{chunk-Y7FT4IQT.js → chunk-NKW7LKYU.js} +266 -28
- package/dist/chunk-NKW7LKYU.js.map +1 -0
- package/dist/{chunk-O3ANBHSA.js → chunk-NNQ2TYDF.js} +123 -5
- package/dist/chunk-NNQ2TYDF.js.map +1 -0
- package/dist/{chunk-5F4C26RU.js → chunk-OADDUPT3.js} +4 -4
- package/dist/{chunk-5F4C26RU.js.map → chunk-OADDUPT3.js.map} +1 -1
- package/dist/{chunk-3AFRJYP4.cjs → chunk-OTN6SZOD.cjs} +1868 -393
- package/dist/chunk-OTN6SZOD.cjs.map +1 -0
- package/dist/{chunk-5LI5EPGJ.cjs → chunk-QFTDTX6K.cjs} +40 -3
- package/dist/chunk-QFTDTX6K.cjs.map +1 -0
- package/dist/{chunk-HMOISHXR.js → chunk-RRLHC37V.js} +1530 -57
- package/dist/chunk-RRLHC37V.js.map +1 -0
- package/dist/chunk-SNHVVOJK.cjs +1768 -0
- package/dist/chunk-SNHVVOJK.cjs.map +1 -0
- package/dist/{chunk-HDP7VK3C.cjs → chunk-SRGQ72IR.cjs} +649 -349
- package/dist/chunk-SRGQ72IR.cjs.map +1 -0
- package/dist/{chunk-4B2CNWQU.cjs → chunk-SSV46KFA.cjs} +14 -7
- package/dist/chunk-SSV46KFA.cjs.map +1 -0
- package/dist/{chunk-AJA6LUI7.js → chunk-UO6BUV6K.js} +18 -2
- package/dist/chunk-UO6BUV6K.js.map +1 -0
- package/dist/chunk-WWQEY7BV.js +67 -0
- package/dist/chunk-WWQEY7BV.js.map +1 -0
- package/dist/{chunk-5WVP4YHP.js → chunk-WXEHD6TT.js} +333 -33
- package/dist/chunk-WXEHD6TT.js.map +1 -0
- package/dist/{chunk-47LRVGOT.cjs → chunk-XA4CKRML.cjs} +2 -2
- package/dist/{chunk-47LRVGOT.cjs.map → chunk-XA4CKRML.cjs.map} +1 -1
- package/dist/{chunk-6KFYJ6TD.cjs → chunk-XIYYHA65.cjs} +6 -2
- package/dist/chunk-XIYYHA65.cjs.map +1 -0
- package/dist/{chunk-KBSXGXPM.cjs → chunk-XJGJCF2R.cjs} +6 -6
- package/dist/{chunk-KBSXGXPM.cjs.map → chunk-XJGJCF2R.cjs.map} +1 -1
- package/dist/{chunk-YWQ6V4ZN.cjs → chunk-YTIYVHL7.cjs} +211 -75
- package/dist/chunk-YTIYVHL7.cjs.map +1 -0
- package/dist/{chunk-TMA4RCEN.js → chunk-Z7XGGLI2.js} +3 -3
- package/dist/{chunk-TMA4RCEN.js.map → chunk-Z7XGGLI2.js.map} +1 -1
- package/dist/{chunk-A2N2GFCG.cjs → chunk-ZVTWQLK4.cjs} +10 -10
- package/dist/{chunk-A2N2GFCG.cjs.map → chunk-ZVTWQLK4.cjs.map} +1 -1
- package/dist/{chunk-2XLQPQKI.cjs → chunk-ZXCESUJS.cjs} +15 -9
- package/dist/chunk-ZXCESUJS.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 +52 -35
- package/dist/engine.d.cts +13 -13
- package/dist/engine.d.ts +13 -13
- package/dist/engine.js +26 -21
- package/dist/errors.cjs +44 -19
- package/dist/errors.d.cts +3 -2
- package/dist/errors.d.ts +3 -2
- package/dist/errors.js +2 -1
- package/dist/format.cjs +19 -169
- package/dist/format.cjs.map +1 -1
- package/dist/format.d.cts +18 -26
- package/dist/format.d.ts +18 -26
- package/dist/format.js +7 -171
- package/dist/format.js.map +1 -1
- package/dist/index.cjs +250 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -74
- package/dist/index.d.ts +110 -74
- package/dist/index.js +228 -23
- package/dist/index.js.map +1 -1
- package/dist/language.cjs +9 -9
- package/dist/language.d.cts +12 -12
- package/dist/language.d.ts +12 -12
- package/dist/language.js +3 -3
- package/dist/lexer.cjs +16 -16
- package/dist/lexer.d.cts +3 -3
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.js +5 -5
- package/dist/normalizer.cjs +10 -10
- package/dist/normalizer.d.cts +3 -3
- package/dist/normalizer.d.ts +3 -3
- package/dist/normalizer.js +4 -4
- package/dist/packages.cjs +45 -36
- package/dist/packages.d.cts +135 -31
- package/dist/packages.d.ts +135 -31
- package/dist/packages.js +14 -13
- package/dist/parser.cjs +16 -16
- package/dist/parser.d.cts +6 -5
- package/dist/parser.d.ts +6 -5
- package/dist/parser.js +6 -6
- package/dist/{pipeline-BEb3hujr.d.cts → pipeline-CtfJtPQc.d.cts} +3 -3
- package/dist/{pipeline-B6k5lCB7.d.ts → pipeline-DCd5M6Gk.d.ts} +3 -3
- package/dist/resolvers.d.cts +3 -3
- package/dist/resolvers.d.ts +3 -3
- package/dist/testing.cjs +478 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +271 -0
- package/dist/testing.d.ts +271 -0
- package/dist/testing.js +470 -0
- package/dist/testing.js.map +1 -0
- package/dist/uom.cjs +16 -16
- package/dist/uom.d.cts +3 -3
- package/dist/uom.d.ts +3 -3
- package/dist/uom.js +6 -6
- package/dist/utilities.cjs +6 -5
- package/dist/utilities.js +2 -1
- package/dist/vm.cjs +34 -34
- package/dist/vm.d.cts +8 -8
- package/dist/vm.d.ts +8 -8
- package/dist/vm.js +9 -9
- package/dist/worker.cjs +493 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +509 -0
- package/dist/worker.d.ts +509 -0
- package/dist/worker.js +484 -0
- package/dist/worker.js.map +1 -0
- package/package.json +21 -1
- package/dist/chunk-2XLQPQKI.cjs.map +0 -1
- package/dist/chunk-3AFRJYP4.cjs.map +0 -1
- package/dist/chunk-3D7V24DG.js.map +0 -1
- package/dist/chunk-3LAEG75D.js.map +0 -1
- package/dist/chunk-4B2CNWQU.cjs.map +0 -1
- package/dist/chunk-526PMQOA.js.map +0 -1
- package/dist/chunk-5KMIY374.cjs.map +0 -1
- package/dist/chunk-5LI5EPGJ.cjs.map +0 -1
- package/dist/chunk-5WVP4YHP.js.map +0 -1
- package/dist/chunk-5X2PTP6F.cjs.map +0 -1
- package/dist/chunk-6KFYJ6TD.cjs.map +0 -1
- package/dist/chunk-6WFMPTGB.cjs.map +0 -1
- package/dist/chunk-AJA6LUI7.js.map +0 -1
- package/dist/chunk-B7TLZABL.cjs.map +0 -1
- package/dist/chunk-GQCOSXMG.js.map +0 -1
- package/dist/chunk-HDP7VK3C.cjs.map +0 -1
- package/dist/chunk-HMOISHXR.js.map +0 -1
- package/dist/chunk-HVQFNJKE.cjs.map +0 -1
- package/dist/chunk-IF532O7C.js.map +0 -1
- package/dist/chunk-JMXUNXQS.cjs.map +0 -1
- package/dist/chunk-KV7UW6T6.js.map +0 -1
- package/dist/chunk-O3ANBHSA.js.map +0 -1
- package/dist/chunk-PA4VC73I.cjs.map +0 -1
- package/dist/chunk-PFUESQTW.cjs.map +0 -1
- package/dist/chunk-QY25VWBF.js.map +0 -1
- package/dist/chunk-R3PY4G7J.js.map +0 -1
- package/dist/chunk-TBN7DEHO.js.map +0 -1
- package/dist/chunk-TY3TLZAW.cjs.map +0 -1
- package/dist/chunk-UM6BVY2S.cjs.map +0 -1
- package/dist/chunk-UQ3UIZJC.js.map +0 -1
- package/dist/chunk-V5PYO44Y.js.map +0 -1
- package/dist/chunk-VB37OC6I.js.map +0 -1
- package/dist/chunk-Y7FT4IQT.js.map +0 -1
- package/dist/chunk-YWQ6V4ZN.cjs.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { a as PrecedenceParser, b as PrefixParselet, I as InfixParselet } from './Parselet-
|
|
2
|
-
import { V as Value } from './Value-
|
|
1
|
+
import { a as PrecedenceParser, b as PrefixParselet, I as InfixParselet } from './Parselet-BBT8riYh.js';
|
|
2
|
+
import { V as Value, b as ValueType } from './Value-BUi1RA3S.js';
|
|
3
3
|
import { IVariableSource } from './variables.js';
|
|
4
|
-
import { M as MarkdownLineType, L as Lexer, e as TokenCategory, c as LexerVocabulary } from './Lexer-
|
|
4
|
+
import { M as MarkdownLineType, L as Lexer, e as TokenCategory, c as LexerVocabulary } from './Lexer-CSI_lwbW.js';
|
|
5
5
|
import { IAsyncResolver } from './resolvers.js';
|
|
6
|
-
import { T as TokenFusion, c as TokenNormalizer, a as NormalizerRule } from './TokenNormalizer-
|
|
7
|
-
import { a as DependencyGraph, V as VM, D as DagSnapshot, b as EngineContext, S as ScopeManager, L as LineExecutionContext } from './ScopeManager-
|
|
8
|
-
import { a as BytecodeProgram } from './BytecodeBuilder-
|
|
6
|
+
import { T as TokenFusion, c as TokenNormalizer, a as NormalizerRule } from './TokenNormalizer-C6VzZgHa.js';
|
|
7
|
+
import { a as DependencyGraph, V as VM, D as DagSnapshot, b as EngineContext, S as ScopeManager, L as LineExecutionContext } from './ScopeManager-CxA24W5n.js';
|
|
8
|
+
import { a as BytecodeProgram } from './BytecodeBuilder-Bp9xeTmX.js';
|
|
9
9
|
import { QueryClient } from '@tanstack/query-core';
|
|
10
|
-
import { E as EngineError } from './EngineError-
|
|
11
|
-
import { a as DiagnosticReportJSON, D as DiagnosticPipeline } from './pipeline-
|
|
12
|
-
import { T as Token } from './Token-
|
|
13
|
-
import { D as DEFAULT_CONFIG, E as EngineConfig } from './Configuration-
|
|
10
|
+
import { E as EngineError } from './EngineError-B61GS1jp.js';
|
|
11
|
+
import { a as DiagnosticReportJSON, D as DiagnosticPipeline } from './pipeline-DCd5M6Gk.js';
|
|
12
|
+
import { T as Token } from './Token-B1hdkedD.js';
|
|
13
|
+
import { D as DEFAULT_CONFIG, E as EngineConfig } from './Configuration-C9W8tJv_.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* One line's compiled bytecode, plus the variables it reads and writes.
|
|
@@ -73,6 +73,18 @@ declare class LineCache {
|
|
|
73
73
|
* Iterate all cache entries for diagnostics/debugging.
|
|
74
74
|
*/
|
|
75
75
|
forEach(callback: (key: string, entry: LineCacheEntry) => void): void;
|
|
76
|
+
/**
|
|
77
|
+
* Structured iteration for serialization: one record per stored entry,
|
|
78
|
+
* carrying the raw line number and expression key rather than the lossy
|
|
79
|
+
* "line:expression" display key `keys()`/`forEach()` produce (an expression
|
|
80
|
+
* containing a colon cannot be split back apart from that string). Used by
|
|
81
|
+
* the engine snapshot to walk every entry without re-parsing display keys.
|
|
82
|
+
*/
|
|
83
|
+
snapshotEntries(): {
|
|
84
|
+
line: number;
|
|
85
|
+
expression: string;
|
|
86
|
+
entry: LineCacheEntry;
|
|
87
|
+
}[];
|
|
76
88
|
/**
|
|
77
89
|
* Get all entry keys.
|
|
78
90
|
*/
|
|
@@ -416,6 +428,195 @@ declare class DocumentModel {
|
|
|
416
428
|
toJSON(): object;
|
|
417
429
|
}
|
|
418
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Serialise and restore the state a session accumulates in memory.
|
|
433
|
+
*
|
|
434
|
+
* An engine builds up three things while it evaluates a document: named
|
|
435
|
+
* variables, user-defined functions, and a per-line result/bytecode cache.
|
|
436
|
+
* All three live only in memory, so a host that wants to persist a session,
|
|
437
|
+
* warm-start a process, or move a document between contexts has to re-evaluate
|
|
438
|
+
* the whole thing from scratch. This module turns that state into a plain,
|
|
439
|
+
* JSON-safe object (see {@link EngineSnapshot}) and back again, so the host can
|
|
440
|
+
* store it and rehydrate an engine that behaves as though it had evaluated the
|
|
441
|
+
* document itself.
|
|
442
|
+
*
|
|
443
|
+
* What is deliberately NOT carried:
|
|
444
|
+
* - Resolved async values (weather, stocks, currency, any package that fetches).
|
|
445
|
+
* Those are point-in-time and must be re-fetched, not restored stale, so the
|
|
446
|
+
* snapshot omits every line and variable backed by an async resolver. See
|
|
447
|
+
* {@link ExpressionEngine.toJSON}, which filters them out before this module
|
|
448
|
+
* ever sees them.
|
|
449
|
+
* - Package-contributed state (a package's own caches or globals). Core state
|
|
450
|
+
* only for now; a package opt-in is a follow-up. See the guide.
|
|
451
|
+
*
|
|
452
|
+
* JSON safety is the load-bearing contract here. `JSON.stringify` cannot encode
|
|
453
|
+
* a `bigint` (it throws) and turns `NaN`/`Infinity` into `null` (a silent
|
|
454
|
+
* corruption), and typed arrays round-trip as sparse objects rather than
|
|
455
|
+
* arrays. Every value that crosses this boundary therefore goes through
|
|
456
|
+
* {@link encodeNumber} (non-finite numbers become sentinel strings) or is
|
|
457
|
+
* written as a decimal string (every `bigint`), and typed arrays are copied to
|
|
458
|
+
* plain arrays. A snapshot produced here survives `JSON.stringify` followed by
|
|
459
|
+
* `JSON.parse` unchanged.
|
|
460
|
+
*/
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* The magic string every snapshot carries, so a host handing `fromJSON` an
|
|
464
|
+
* arbitrary object (a config file, a different tool's export) is refused with a
|
|
465
|
+
* clear error rather than half-restored. See {@link assertRestorable}.
|
|
466
|
+
*/
|
|
467
|
+
declare const SNAPSHOT_FORMAT: "solve-engine/snapshot";
|
|
468
|
+
/**
|
|
469
|
+
* The snapshot layout version, bumped whenever the serialised shape changes in
|
|
470
|
+
* a way an older reader cannot understand. `fromJSON` accepts only the exact
|
|
471
|
+
* version it was built for and refuses anything else with a coded error, which
|
|
472
|
+
* is the whole point of the field: a snapshot taken by a future (or older)
|
|
473
|
+
* engine is rejected loudly instead of being restored wrongly. This is separate
|
|
474
|
+
* from the engine's own semver (recorded alongside it as {@link
|
|
475
|
+
* EngineSnapshot.engineVersion} for diagnostics), because the serialised shape
|
|
476
|
+
* and the published API version do not have to move together.
|
|
477
|
+
*/
|
|
478
|
+
declare const SNAPSHOT_VERSION: 1;
|
|
479
|
+
/**
|
|
480
|
+
* A number as it appears in a snapshot: an ordinary JSON number when finite, or
|
|
481
|
+
* a sentinel string when not. `JSON.stringify` writes `NaN`/`Infinity`/
|
|
482
|
+
* `-Infinity` as `null`, which would silently turn a real `1/0` into an absent
|
|
483
|
+
* value on the way back, so the three non-finite doubles are named instead.
|
|
484
|
+
*/
|
|
485
|
+
type SerializedNumber = number | "NaN" | "Infinity" | "-Infinity";
|
|
486
|
+
/** {@link DecimalData} with its `bigint` coefficient written as a decimal string. */
|
|
487
|
+
interface SerializedDecimal {
|
|
488
|
+
coef: string;
|
|
489
|
+
scale: number;
|
|
490
|
+
}
|
|
491
|
+
/** {@link Rational} with both `bigint` components written as decimal strings. */
|
|
492
|
+
interface SerializedRational {
|
|
493
|
+
n: string;
|
|
494
|
+
d: string;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* A {@link Value} in JSON-safe form, discriminated by its {@link ValueType}
|
|
498
|
+
* on the `t` field. Only the types a session can leave in a variable, a
|
|
499
|
+
* function result, or a cached line are represented; {@link ValueType.Pending}
|
|
500
|
+
* is filtered out upstream (an in-flight async result), and
|
|
501
|
+
* {@link ValueType.Symbolic} plus symbolic matrix cells are refused with a
|
|
502
|
+
* clear error (deferred, see the module doc).
|
|
503
|
+
*/
|
|
504
|
+
type SerializedValue = {
|
|
505
|
+
t: ValueType.Number;
|
|
506
|
+
v: SerializedNumber;
|
|
507
|
+
exact?: SerializedDecimal;
|
|
508
|
+
rational?: SerializedRational;
|
|
509
|
+
} | {
|
|
510
|
+
t: ValueType.Hex;
|
|
511
|
+
v: SerializedNumber | string;
|
|
512
|
+
big?: boolean;
|
|
513
|
+
base?: string;
|
|
514
|
+
} | {
|
|
515
|
+
t: ValueType.BigInt;
|
|
516
|
+
v: string;
|
|
517
|
+
} | {
|
|
518
|
+
t: ValueType.String;
|
|
519
|
+
v: string;
|
|
520
|
+
} | {
|
|
521
|
+
t: ValueType.Datetime;
|
|
522
|
+
v: SerializedNumber;
|
|
523
|
+
} | {
|
|
524
|
+
t: ValueType.Percentage;
|
|
525
|
+
v: SerializedNumber;
|
|
526
|
+
} | {
|
|
527
|
+
t: ValueType.Uom;
|
|
528
|
+
v: SerializedNumber;
|
|
529
|
+
unit: string;
|
|
530
|
+
exact?: SerializedDecimal;
|
|
531
|
+
} | {
|
|
532
|
+
t: ValueType.Matrix;
|
|
533
|
+
rows: number;
|
|
534
|
+
cols: number;
|
|
535
|
+
data: (SerializedNumber | boolean)[];
|
|
536
|
+
} | {
|
|
537
|
+
t: ValueType.Range;
|
|
538
|
+
min: SerializedNumber;
|
|
539
|
+
max: SerializedNumber;
|
|
540
|
+
} | {
|
|
541
|
+
t: ValueType.Boolean;
|
|
542
|
+
v: boolean;
|
|
543
|
+
} | {
|
|
544
|
+
t: ValueType.Error;
|
|
545
|
+
code: string;
|
|
546
|
+
message: string;
|
|
547
|
+
};
|
|
548
|
+
/** A {@link BytecodeProgram} with its typed arrays copied to plain arrays and non-finite constants named. */
|
|
549
|
+
interface SerializedBytecode {
|
|
550
|
+
opcodes: number[];
|
|
551
|
+
numbers: SerializedNumber[];
|
|
552
|
+
strings: string[];
|
|
553
|
+
hasAsync: boolean;
|
|
554
|
+
constants?: [number, number][];
|
|
555
|
+
userFunctionBodies?: SerializedUserFunction[];
|
|
556
|
+
anonymousBodies?: SerializedAnonymousBody[];
|
|
557
|
+
}
|
|
558
|
+
/** A {@link UserFunctionDef}: name, parameter names, and the body compiled to its own program. */
|
|
559
|
+
interface SerializedUserFunction {
|
|
560
|
+
name: string;
|
|
561
|
+
params: string[];
|
|
562
|
+
program: SerializedBytecode;
|
|
563
|
+
}
|
|
564
|
+
/** An {@link AnonymousBodyDef}: a `map`/`reduce` inline transform body, a user function minus the name. */
|
|
565
|
+
interface SerializedAnonymousBody {
|
|
566
|
+
params: string[];
|
|
567
|
+
program: SerializedBytecode;
|
|
568
|
+
}
|
|
569
|
+
/** One cached line: the result, the compiled program, and the reads/writes the dependency graph needs. */
|
|
570
|
+
interface SerializedLineCacheEntry {
|
|
571
|
+
line: number;
|
|
572
|
+
/** The expression text this entry is keyed under, or "" for an expressionless entry. Mirrors `LineCache`'s own two-level key. */
|
|
573
|
+
expression: string;
|
|
574
|
+
result: SerializedValue;
|
|
575
|
+
bytecode: SerializedBytecode;
|
|
576
|
+
reads: string[];
|
|
577
|
+
writeVar: string | null;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* A complete, JSON-safe snapshot of an engine's session state.
|
|
581
|
+
*
|
|
582
|
+
* Produced by {@link ExpressionEngine.toJSON} and consumed by
|
|
583
|
+
* {@link ExpressionEngine.fromJSON}. Safe to `JSON.stringify`, store, and
|
|
584
|
+
* `JSON.parse` back into `fromJSON`.
|
|
585
|
+
*/
|
|
586
|
+
interface EngineSnapshot {
|
|
587
|
+
/** Always {@link SNAPSHOT_FORMAT}. Identifies the object as a snapshot before anything reads deeper. */
|
|
588
|
+
format: typeof SNAPSHOT_FORMAT;
|
|
589
|
+
/** The serialised-shape version, {@link SNAPSHOT_VERSION} at write time. `fromJSON` refuses any other value. */
|
|
590
|
+
version: number;
|
|
591
|
+
/** The engine's semver at write time, for diagnostics and forward compatibility decisions. Not itself a gate. */
|
|
592
|
+
engineVersion: string;
|
|
593
|
+
/** The locale the snapshot was taken under, so `fromJSON` can rebuild a matching lexer when the caller does not override it. */
|
|
594
|
+
locale: string;
|
|
595
|
+
/** Named variables, by name. Async-backed and in-flight variables are omitted (see the module doc). */
|
|
596
|
+
variables: Record<string, SerializedValue>;
|
|
597
|
+
/** User-defined functions (`f(x) = ...`). */
|
|
598
|
+
userFunctions: SerializedUserFunction[];
|
|
599
|
+
/** Cached lines, minus any backed by an async resolver. */
|
|
600
|
+
lineCache: SerializedLineCacheEntry[];
|
|
601
|
+
/** The expression-keyed bytecode cache, a pure recompilation cache, carried so a warm start skips re-parsing unchanged expressions. */
|
|
602
|
+
bytecodeCache: {
|
|
603
|
+
expression: string;
|
|
604
|
+
program: SerializedBytecode;
|
|
605
|
+
}[];
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* The coded errors this module and `fromJSON` raise. Registered in
|
|
609
|
+
* `errors/ErrorCode.ts` so the catalog test can see them.
|
|
610
|
+
*/
|
|
611
|
+
declare const SnapshotErrorCodes: {
|
|
612
|
+
/** The object handed to `fromJSON` is not a snapshot at all, or its version does not match this engine's reader. */
|
|
613
|
+
readonly SNAPSHOT_VERSION_MISMATCH: "SNAPSHOT_VERSION_MISMATCH";
|
|
614
|
+
/** A snapshot with the right envelope but internally inconsistent contents (a bad number sentinel, a missing field). */
|
|
615
|
+
readonly SNAPSHOT_MALFORMED: "SNAPSHOT_MALFORMED";
|
|
616
|
+
/** A value the snapshot format cannot yet represent (a symbolic expression, a symbolic matrix cell). Deferred, see the module doc. */
|
|
617
|
+
readonly SNAPSHOT_UNSUPPORTED_VALUE: "SNAPSHOT_UNSUPPORTED_VALUE";
|
|
618
|
+
};
|
|
619
|
+
|
|
419
620
|
/** Emitted when one or more lines have updated results after async resolution. */
|
|
420
621
|
interface LinesUpdatedEvent {
|
|
421
622
|
type: "lines-updated";
|
|
@@ -787,6 +988,42 @@ interface UnifiedParsingOptions {
|
|
|
787
988
|
includeDiagnostics?: boolean;
|
|
788
989
|
}
|
|
789
990
|
|
|
991
|
+
/**
|
|
992
|
+
* One line of a derivation: a readable account of a single operation and the
|
|
993
|
+
* value it arrives at.
|
|
994
|
+
*
|
|
995
|
+
* `description` is prose for the person reading the note, not developer
|
|
996
|
+
* diagnostics ("80 less 20%", "64 plus 20%"), and `value` is that step's
|
|
997
|
+
* intermediate result, the same {@link Value} the engine would produce for it.
|
|
998
|
+
*/
|
|
999
|
+
interface ExplanationStep {
|
|
1000
|
+
/** A short, human-readable account of the operation, e.g. "80 less 20%". */
|
|
1001
|
+
readonly description: string;
|
|
1002
|
+
/** The value this step arrives at. */
|
|
1003
|
+
readonly value: Value;
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* A worked-through derivation of how a line reached its answer.
|
|
1007
|
+
*
|
|
1008
|
+
* `steps` is ordered the way the engine evaluates the line: an operand appears
|
|
1009
|
+
* before the operation that consumes it, and each step's left-hand side is the
|
|
1010
|
+
* running value carried down from the steps above it. `result` is the final
|
|
1011
|
+
* value and is identical to what {@link ExpressionEngine.evaluateExpression}
|
|
1012
|
+
* returns for the same line.
|
|
1013
|
+
*
|
|
1014
|
+
* A line with nothing to break down (a bare literal, or a construct this slice
|
|
1015
|
+
* does not derive yet) returns an empty `steps` array with `result` set, rather
|
|
1016
|
+
* than an error: the answer is still reported, just without a derivation.
|
|
1017
|
+
*/
|
|
1018
|
+
interface Explanation {
|
|
1019
|
+
/** The expression as given. */
|
|
1020
|
+
readonly expression: string;
|
|
1021
|
+
/** The ordered derivation, one entry per operation, in evaluation order. */
|
|
1022
|
+
readonly steps: ExplanationStep[];
|
|
1023
|
+
/** The final value, identical to the engine's own answer for the line. */
|
|
1024
|
+
readonly result: Value;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
790
1027
|
/**
|
|
791
1028
|
* DiagnosticPipelineResult, structured pipeline data contract.
|
|
792
1029
|
*
|
|
@@ -1198,6 +1435,31 @@ interface CheckpointSnapshot {
|
|
|
1198
1435
|
variableCount: number;
|
|
1199
1436
|
}
|
|
1200
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* Options for {@link ExpressionEngine.fromJSON}, restoring a snapshot onto a
|
|
1440
|
+
* fresh engine.
|
|
1441
|
+
*/
|
|
1442
|
+
interface EngineRestoreOptions {
|
|
1443
|
+
/**
|
|
1444
|
+
* Packages to register on the restored engine. This MUST be the same set
|
|
1445
|
+
* the snapshot was taken with: a snapshot carries compiled bytecode whose
|
|
1446
|
+
* plugin-function indices and parselet-produced opcodes only line up
|
|
1447
|
+
* against the packages that were present when it was written. Defaults to
|
|
1448
|
+
* {@link BUILTIN_PACKAGES}, exactly like the constructor's own `packages`
|
|
1449
|
+
* parameter, so a host using the default package set needs to pass nothing.
|
|
1450
|
+
*/
|
|
1451
|
+
packages?: IEnginePackage[];
|
|
1452
|
+
/** Config overrides, merged over `DEFAULT_CONFIG`, as in the constructor. */
|
|
1453
|
+
config?: Partial<typeof DEFAULT_CONFIG>;
|
|
1454
|
+
/** Turn on the diagnostic pipeline, as in the constructor's `diagnosticMode`. */
|
|
1455
|
+
diagnosticMode?: boolean;
|
|
1456
|
+
/**
|
|
1457
|
+
* Override the locale the snapshot recorded. Rarely needed: the snapshot's
|
|
1458
|
+
* own {@link EngineSnapshot.locale} is used by default, so a restored engine
|
|
1459
|
+
* lexes the way the one that produced it did.
|
|
1460
|
+
*/
|
|
1461
|
+
locale?: string;
|
|
1462
|
+
}
|
|
1201
1463
|
/**
|
|
1202
1464
|
* Return type of {@link evaluateLine} and {@link evaluateExpression}.
|
|
1203
1465
|
*
|
|
@@ -1313,6 +1575,27 @@ declare class ExpressionEngine {
|
|
|
1313
1575
|
* lifecycle itself.
|
|
1314
1576
|
*/
|
|
1315
1577
|
private documentModel;
|
|
1578
|
+
/**
|
|
1579
|
+
* How deep goal seek is currently re-entering line evaluation, so a goal
|
|
1580
|
+
* seek whose target line is itself a goal seek is refused rather than
|
|
1581
|
+
* multiplying the search cost. One goal-seek line already re-runs its
|
|
1582
|
+
* target up to `maxGoalSeekIterations` times; allowing a nested one would
|
|
1583
|
+
* make that a product. See {@link makeLineContext}'s `evaluateLineWithBinding`.
|
|
1584
|
+
*/
|
|
1585
|
+
private goalSeekDepth;
|
|
1586
|
+
/** The most nesting {@link makeLineContext}'s `evaluateLineWithBinding` allows before refusing, so the bisection re-runs can never compound. */
|
|
1587
|
+
private static readonly GOAL_SEEK_MAX_NESTING_DEPTH;
|
|
1588
|
+
/**
|
|
1589
|
+
* Batch cross-line source, set only for the duration of a
|
|
1590
|
+
* `parseDocument`/`evaluateLines` pass (see {@link processScanResults}).
|
|
1591
|
+
* The incremental path uses {@link documentModel}; the batch path has no
|
|
1592
|
+
* such model, so cross-line closures read earlier lines from the scan and
|
|
1593
|
+
* the results array the pass is already building. Both are references to
|
|
1594
|
+
* arrays that exist regardless, so a document that uses no cross-line
|
|
1595
|
+
* feature pays nothing: the closures are simply never called.
|
|
1596
|
+
*/
|
|
1597
|
+
private batchScanResults;
|
|
1598
|
+
private batchParsedLines;
|
|
1316
1599
|
/**
|
|
1317
1600
|
* Called once by `ThreeTierEvaluator`'s constructor. Not part of the
|
|
1318
1601
|
* public evaluate-a-document contract, purely internal wiring so
|
|
@@ -1328,6 +1611,27 @@ declare class ExpressionEngine {
|
|
|
1328
1611
|
* and return a clear error, never assume line 0 exists.
|
|
1329
1612
|
*/
|
|
1330
1613
|
private makeLineContext;
|
|
1614
|
+
/**
|
|
1615
|
+
* Re-evaluate line `targetLine`'s compiled expression with `variable` bound
|
|
1616
|
+
* to `bound` for that one run, the primitive goal seek drives while
|
|
1617
|
+
* narrowing in on an input. See {@link LineExecutionContext.evaluateLineWithBinding}.
|
|
1618
|
+
*
|
|
1619
|
+
* The binding is a call frame, so `LOAD_VAR` reads it in preference to the
|
|
1620
|
+
* document's own value and the document's value is untouched once the frame
|
|
1621
|
+
* is popped, the same shadowing a function parameter gets. The target's
|
|
1622
|
+
* bytecode is run as-is, so a line that defines a variable is refused: its
|
|
1623
|
+
* `STORE_VAR` would write the probe's candidate into the real variable store
|
|
1624
|
+
* as a side effect. The re-entry is bounded three ways, by
|
|
1625
|
+
* {@link goalSeekDepth} against nesting, by the VM's own per-run instruction
|
|
1626
|
+
* limit, and by the caller's iteration cap.
|
|
1627
|
+
*
|
|
1628
|
+
* @param targetLine - 1-based line whose expression is re-evaluated.
|
|
1629
|
+
* @param variable - The unknown to bind for this run.
|
|
1630
|
+
* @param bound - The value to bind it to (a number to probe, a symbolic node to read the relationship in closed form).
|
|
1631
|
+
* @param symbolicTolerant - Whether an otherwise-undefined variable reads as a symbolic placeholder, needed for the closed-form read.
|
|
1632
|
+
* @returns The line's re-evaluated Value, or an error Value when it cannot be probed.
|
|
1633
|
+
*/
|
|
1634
|
+
private evaluateLineWithBinding;
|
|
1331
1635
|
/**
|
|
1332
1636
|
* Package-contributed completion candidates (`IEnginePackage.completionItems`),
|
|
1333
1637
|
* keyed by package name, engine-instance-local, not a shared registry
|
|
@@ -1354,6 +1658,14 @@ declare class ExpressionEngine {
|
|
|
1354
1658
|
private batcher;
|
|
1355
1659
|
/** Post-lexer token normalizer for phrase fusion, implicit multiply, etc. */
|
|
1356
1660
|
private normalizer;
|
|
1661
|
+
/**
|
|
1662
|
+
* Units defined by the current document (`1 sprint = 2 weeks`). Read by the
|
|
1663
|
+
* user-unit normalizer rule to expand a name back to its definition, written
|
|
1664
|
+
* by {@link tryDefineUserUnit} on a definition line. Document-scoped: cleared
|
|
1665
|
+
* at the start of every {@link parseDocument} pass, so definitions never
|
|
1666
|
+
* cross between documents.
|
|
1667
|
+
*/
|
|
1668
|
+
private readonly userUnits;
|
|
1357
1669
|
/** TanStack Query client, injected into resolvers for cache reads/writes. */
|
|
1358
1670
|
readonly queryClient: QueryClient;
|
|
1359
1671
|
private bytecodeCache;
|
|
@@ -1656,6 +1968,31 @@ declare class ExpressionEngine {
|
|
|
1656
1968
|
* session's own Phase H.2 scope decision (full symbolic MATRICES, not
|
|
1657
1969
|
* a general CAS).
|
|
1658
1970
|
*/
|
|
1971
|
+
/**
|
|
1972
|
+
* Registers a document-scoped user unit from a `1 <name> = <n> <unit>` line
|
|
1973
|
+
* and returns the `<name> defined` confirmation, or `null` when the line is
|
|
1974
|
+
* not a unit definition (so ordinary processing continues unchanged).
|
|
1975
|
+
*
|
|
1976
|
+
* Like the symbolic-grammar shapes it sits beside, this has an effect (a
|
|
1977
|
+
* stored definition) that no cached bytecode program could represent, so it
|
|
1978
|
+
* short-circuits compilation the same way. See {@link UserUnitTable}.
|
|
1979
|
+
*
|
|
1980
|
+
* The pattern is kept deliberately narrow so it cannot swallow an equation:
|
|
1981
|
+
*
|
|
1982
|
+
* - The coefficient must be exactly `1`. `2 x = 10` stays a scalar equation
|
|
1983
|
+
* (`x =>` solves it); only the natural `1 sprint = 2 weeks` shape is a
|
|
1984
|
+
* definition.
|
|
1985
|
+
* - The name is one or more identifiers, never a built-in unit (those lex as
|
|
1986
|
+
* UNIT, not IDENT), so a built-in unit cannot be redefined.
|
|
1987
|
+
* - The base must be a recognized unit (a UNIT token). A non-unit right side
|
|
1988
|
+
* declines here and is left to whatever handled it before, so a defined
|
|
1989
|
+
* unit is always dimensioned, never free-standing.
|
|
1990
|
+
*
|
|
1991
|
+
* `tokens` are already normalized, so the implicit-multiply pass has usually
|
|
1992
|
+
* inserted a STAR between the coefficient and the name (`1 * sprint`); it is
|
|
1993
|
+
* tolerated and skipped.
|
|
1994
|
+
*/
|
|
1995
|
+
private tryDefineUserUnit;
|
|
1659
1996
|
private trySymbolicGrammar;
|
|
1660
1997
|
/**
|
|
1661
1998
|
* Stores a general scalar equation (`x^2 - 4 = 0`) keyed by its unknown, or
|
|
@@ -2108,6 +2445,44 @@ declare class ExpressionEngine {
|
|
|
2108
2445
|
* Returns the Value result. Throws on error.
|
|
2109
2446
|
*/
|
|
2110
2447
|
evaluateExpression(expression: string): EvalResults;
|
|
2448
|
+
/**
|
|
2449
|
+
* Explain how a line reached its answer, as a readable derivation.
|
|
2450
|
+
*
|
|
2451
|
+
* This is a companion to {@link evaluateExpression}, not a replacement:
|
|
2452
|
+
* `explainLine` is for the person reading the note, whereas the diagnostic
|
|
2453
|
+
* pipeline (`evaluateLineWithDiagnostic`) is for the developer and reports
|
|
2454
|
+
* stages, opcodes and timings. A host puts a derivation behind a hover or a
|
|
2455
|
+
* disclosure, so this is an API rather than an `explain` keyword: it never
|
|
2456
|
+
* consumes a word that a prose line might use, and it annotates a line the
|
|
2457
|
+
* host has already chosen to explain.
|
|
2458
|
+
*
|
|
2459
|
+
* The returned {@link Explanation} walks the line's operations in evaluation
|
|
2460
|
+
* order, each with the value it arrives at, and its `result` is identical to
|
|
2461
|
+
* what {@link evaluateExpression} returns for the same line. Every value in
|
|
2462
|
+
* the derivation is the engine's own, the operations are re-evaluated rather
|
|
2463
|
+
* than re-derived, so a step can never disagree with the answer.
|
|
2464
|
+
*
|
|
2465
|
+
* A line with nothing to break down (a bare literal), or one built from a
|
|
2466
|
+
* construct this slice does not derive yet (matrices, dates, function
|
|
2467
|
+
* calls), comes back with an empty `steps` array and the answer in
|
|
2468
|
+
* `result`, rather than an error.
|
|
2469
|
+
*
|
|
2470
|
+
* @param expression - The raw line to explain.
|
|
2471
|
+
* @returns The ordered derivation and final value.
|
|
2472
|
+
* @throws {EngineError} When the line does not evaluate at all, or resolves
|
|
2473
|
+
* data asynchronously (a derivation has no meaning for either).
|
|
2474
|
+
*/
|
|
2475
|
+
explainLine(expression: string): Explanation;
|
|
2476
|
+
/**
|
|
2477
|
+
* Evaluate a self-contained sub-expression without touching document state.
|
|
2478
|
+
*
|
|
2479
|
+
* Used only by {@link explainLine}. Unlike `evaluateExpression`, this never
|
|
2480
|
+
* writes to the line cache or the dependency graph: it is handed the spans
|
|
2481
|
+
* of a single line's own sub-expressions, and evaluating those to build a
|
|
2482
|
+
* derivation must not disturb the document the line belongs to. An async
|
|
2483
|
+
* (pending) result is rejected, a derivation cannot represent one.
|
|
2484
|
+
*/
|
|
2485
|
+
private evaluateIsolated;
|
|
2111
2486
|
/**
|
|
2112
2487
|
* Compile-only path: lex → parse → bytecode, without execution.
|
|
2113
2488
|
*
|
|
@@ -2199,6 +2574,69 @@ declare class ExpressionEngine {
|
|
|
2199
2574
|
*/
|
|
2200
2575
|
evaluateNumber(expression: string): number;
|
|
2201
2576
|
clear(): void;
|
|
2577
|
+
/**
|
|
2578
|
+
* Serialise this engine's session state into a plain, JSON-safe snapshot.
|
|
2579
|
+
*
|
|
2580
|
+
* Carries the three things a session accumulates in memory: named
|
|
2581
|
+
* {@link ExpressionEngine} variables, user-defined functions, and the
|
|
2582
|
+
* per-line result/bytecode cache (plus the expression-keyed bytecode cache).
|
|
2583
|
+
* Restore it with {@link ExpressionEngine.fromJSON} onto a fresh engine, and
|
|
2584
|
+
* later expressions resolve exactly as they would have on the engine that
|
|
2585
|
+
* evaluated the document.
|
|
2586
|
+
*
|
|
2587
|
+
* What is deliberately NOT carried:
|
|
2588
|
+
* - **Resolved async values.** Weather, stocks, currency, any package that
|
|
2589
|
+
* fetches: those results are point-in-time and must be re-fetched, not
|
|
2590
|
+
* restored stale. Every line backed by an async resolver (a DAG
|
|
2591
|
+
* data-source dependency, or an async plugin call in its bytecode) is
|
|
2592
|
+
* dropped from the line cache, and any variable whose most-recent
|
|
2593
|
+
* definition was such a line is dropped too. An in-flight (Pending) value
|
|
2594
|
+
* is likewise never written.
|
|
2595
|
+
* - **Package-contributed state.** Core state only for v1; a package opt-in
|
|
2596
|
+
* is a follow-up.
|
|
2597
|
+
* - **Symbolic (algebra) values.** Deferred: a variable holding one makes
|
|
2598
|
+
* this method throw {@link SnapshotErrorCodes.SNAPSHOT_UNSUPPORTED_VALUE}
|
|
2599
|
+
* (refused by name rather than dropped silently), and a cached line whose
|
|
2600
|
+
* result is symbolic is skipped (it re-evaluates on restore, algebra is
|
|
2601
|
+
* synchronous).
|
|
2602
|
+
*
|
|
2603
|
+
* The result survives `JSON.stringify` then `JSON.parse` unchanged.
|
|
2604
|
+
*
|
|
2605
|
+
* @returns A snapshot safe to store and hand back to `fromJSON`.
|
|
2606
|
+
* @throws {@link SnapshotErrorCodes.SNAPSHOT_UNSUPPORTED_VALUE} if a variable
|
|
2607
|
+
* holds a value this v1 format cannot represent (a symbolic value).
|
|
2608
|
+
*/
|
|
2609
|
+
toJSON(): EngineSnapshot;
|
|
2610
|
+
/**
|
|
2611
|
+
* Restore a snapshot produced by {@link ExpressionEngine.toJSON} onto a
|
|
2612
|
+
* fresh engine.
|
|
2613
|
+
*
|
|
2614
|
+
* The version gate runs first: a snapshot whose {@link EngineSnapshot.format}
|
|
2615
|
+
* or {@link EngineSnapshot.version} does not match this engine's reader is
|
|
2616
|
+
* refused with {@link SnapshotErrorCodes.SNAPSHOT_VERSION_MISMATCH} rather
|
|
2617
|
+
* than restored wrongly. The engine is then built with the snapshot's locale
|
|
2618
|
+
* (unless overridden) and the given `packages`, and its variable table,
|
|
2619
|
+
* user-function registry, line cache, dependency graph, and bytecode cache
|
|
2620
|
+
* are rehydrated from the snapshot.
|
|
2621
|
+
*
|
|
2622
|
+
* @param snapshot - A snapshot object, typically straight from `JSON.parse`.
|
|
2623
|
+
* @param options - Packages (must match those the snapshot was taken with),
|
|
2624
|
+
* plus optional config, diagnostic mode, and locale override. See
|
|
2625
|
+
* {@link EngineRestoreOptions}.
|
|
2626
|
+
* @returns A ready engine that behaves as though it had evaluated the
|
|
2627
|
+
* original document.
|
|
2628
|
+
* @throws {@link SnapshotErrorCodes.SNAPSHOT_VERSION_MISMATCH} for a missing
|
|
2629
|
+
* or mismatched envelope, and
|
|
2630
|
+
* {@link SnapshotErrorCodes.SNAPSHOT_MALFORMED} for internally
|
|
2631
|
+
* inconsistent contents.
|
|
2632
|
+
*/
|
|
2633
|
+
static fromJSON(snapshot: EngineSnapshot, options?: EngineRestoreOptions): ExpressionEngine;
|
|
2634
|
+
/**
|
|
2635
|
+
* Rehydrate this engine's state from a snapshot whose envelope has already
|
|
2636
|
+
* been validated by {@link assertRestorable}. Instance-private, the public
|
|
2637
|
+
* entry point is the static {@link ExpressionEngine.fromJSON}.
|
|
2638
|
+
*/
|
|
2639
|
+
private restoreSnapshot;
|
|
2202
2640
|
/**
|
|
2203
2641
|
* Incrementally re-evaluate lines affected by a variable change.
|
|
2204
2642
|
* Walks the DAG from the changed variable to find exactly which lines
|
|
@@ -2681,4 +3119,4 @@ declare class PackageRegistry implements IPackageRegistry {
|
|
|
2681
3119
|
*/
|
|
2682
3120
|
declare const packageRegistry: PackageRegistry;
|
|
2683
3121
|
|
|
2684
|
-
export { type ApplyChangesResult as A, type BatcherMetrics as B, type CacheSnapshot as C, DocumentModel as D, type
|
|
3122
|
+
export { type ApplyChangesResult as A, type BatcherMetrics as B, type CacheSnapshot as C, DocumentModel as D, ExpressionEngine as E, type LineState as F, type LinesUpdatedEvent as G, type CompletionItem as H, type IEnginePackage as I, LanguageService as J, type LanguageServiceOptions as K, type LineEvaluation as L, type SemanticToken as M, type ParsedLine as N, type ParsingResult as O, PackageRegistry as P, SNAPSHOT_FORMAT as S, type UnifiedParsingOptions as U, type ViewportRange as V, type EngineRestoreOptions as a, type EngineSnapshot as b, type EvalResults as c, type Explanation as d, type ExplanationStep as e, type IPackageRegistry as f, SNAPSHOT_VERSION as g, type SerializedAnonymousBody as h, type SerializedBytecode as i, type SerializedDecimal as j, type SerializedLineCacheEntry as k, type SerializedNumber as l, type SerializedRational as m, type SerializedUserFunction as n, type SerializedValue as o, SnapshotErrorCodes as p, packageRegistry as q, type LineChange as r, type InlineSolvePosition as s, type AsyncCachePackageInfo as t, type AsyncErrorEvent as u, AsyncResolutionBatcher as v, type AsyncResolutionEvent as w, type BytecodeCacheEntry as x, type CheckpointSnapshot as y, type LineCacheEntryInfo as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as BytecodeBuilder } from './BytecodeBuilder-
|
|
2
|
-
import { T as Token } from './Token-
|
|
3
|
-
import { D as DiagnosticPipeline } from './pipeline-
|
|
1
|
+
import { B as BytecodeBuilder } from './BytecodeBuilder-Bp9xeTmX.js';
|
|
2
|
+
import { T as Token } from './Token-B1hdkedD.js';
|
|
3
|
+
import { D as DiagnosticPipeline } from './pipeline-DCd5M6Gk.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Dual-keyed ParseletRegistry, accepts both string token types and
|
|
@@ -148,6 +148,15 @@ declare class PrecedenceParser {
|
|
|
148
148
|
private diagnosticPipeline;
|
|
149
149
|
private currentExpression;
|
|
150
150
|
private localeCode;
|
|
151
|
+
/**
|
|
152
|
+
* The binding power the current infix parselet is being invoked at, i.e. the
|
|
153
|
+
* `minBp` of the expression it sits inside. Set immediately before each Tier-2
|
|
154
|
+
* parselet runs. A parselet that decides whether to swallow a following
|
|
155
|
+
* loose operator (UomLiteralParselet with a trailing `in`/`to`) reads this to
|
|
156
|
+
* respect precedence it cannot otherwise see: `120 km / 2 hours in kph` must
|
|
157
|
+
* group as `(120 km / 2 hours) in kph`, not `120 km / (2 hours in kph)`.
|
|
158
|
+
*/
|
|
159
|
+
infixMinBindingPower: number;
|
|
151
160
|
/**
|
|
152
161
|
* Static binding power table, built once at module load, shared across all instances.
|
|
153
162
|
* Index = tokenTypeId, value = binding power (0 = not a built-in infix).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as BytecodeBuilder } from './BytecodeBuilder-
|
|
2
|
-
import { T as Token } from './Token-
|
|
3
|
-
import { D as DiagnosticPipeline } from './pipeline-
|
|
1
|
+
import { B as BytecodeBuilder } from './BytecodeBuilder-Bp9xeTmX.cjs';
|
|
2
|
+
import { T as Token } from './Token-B1hdkedD.cjs';
|
|
3
|
+
import { D as DiagnosticPipeline } from './pipeline-CtfJtPQc.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Dual-keyed ParseletRegistry, accepts both string token types and
|
|
@@ -148,6 +148,15 @@ declare class PrecedenceParser {
|
|
|
148
148
|
private diagnosticPipeline;
|
|
149
149
|
private currentExpression;
|
|
150
150
|
private localeCode;
|
|
151
|
+
/**
|
|
152
|
+
* The binding power the current infix parselet is being invoked at, i.e. the
|
|
153
|
+
* `minBp` of the expression it sits inside. Set immediately before each Tier-2
|
|
154
|
+
* parselet runs. A parselet that decides whether to swallow a following
|
|
155
|
+
* loose operator (UomLiteralParselet with a trailing `in`/`to`) reads this to
|
|
156
|
+
* respect precedence it cannot otherwise see: `120 km / 2 hours in kph` must
|
|
157
|
+
* group as `(120 km / 2 hours) in kph`, not `120 km / (2 hours in kph)`.
|
|
158
|
+
*/
|
|
159
|
+
infixMinBindingPower: number;
|
|
151
160
|
/**
|
|
152
161
|
* Static binding power table, built once at module load, shared across all instances.
|
|
153
162
|
* Index = tokenTypeId, value = binding power (0 = not a built-in infix).
|