solve-engine 1.0.2 → 1.1.1
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-DpjdaQ98.d.cts → Lexer-BOs7euZe.d.cts} +28 -1
- package/dist/{Lexer-CNmWxabg.d.ts → Lexer-CSI_lwbW.d.ts} +28 -1
- package/dist/PackageCompatibility-B-7rK1TD.d.cts +76 -0
- package/dist/PackageCompatibility-Dh59eF-X.d.ts +76 -0
- package/dist/{PackageRegistry-zuzqt51V.d.cts → PackageRegistry-BHWJP83F.d.cts} +449 -11
- package/dist/{PackageRegistry-ClIFXxAe.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-YXCTLWOH.js → chunk-4HQKTMWG.js} +1530 -57
- package/dist/chunk-4HQKTMWG.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-IP7ASJEW.js → chunk-BYJBUL7U.js} +5 -5
- package/dist/{chunk-IP7ASJEW.js.map → chunk-BYJBUL7U.js.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-T556MJDZ.cjs → chunk-CUR2WLI4.cjs} +11 -11
- package/dist/{chunk-T556MJDZ.cjs.map → chunk-CUR2WLI4.cjs.map} +1 -1
- package/dist/{chunk-AA3KTWTX.js → chunk-DLEBSLF4.js} +4 -4
- package/dist/{chunk-AA3KTWTX.js.map → chunk-DLEBSLF4.js.map} +1 -1
- package/dist/{chunk-524F3ATQ.cjs → chunk-E23GZEWL.cjs} +15 -9
- package/dist/chunk-E23GZEWL.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-7FSDNNNC.js → chunk-GLA4JXBO.js} +11 -5
- package/dist/chunk-GLA4JXBO.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-FQGX2PA2.js → chunk-JG6ZJ2WU.js} +128 -4
- package/dist/chunk-JG6ZJ2WU.js.map +1 -0
- package/dist/chunk-L2TE7PMO.cjs +14 -0
- package/dist/chunk-L2TE7PMO.cjs.map +1 -0
- package/dist/chunk-LHZ6VOA7.js +1764 -0
- package/dist/chunk-LHZ6VOA7.js.map +1 -0
- package/dist/{chunk-SESSWASV.cjs → chunk-MN3LHRGV.cjs} +1868 -393
- package/dist/chunk-MN3LHRGV.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-FE23VSSA.cjs → chunk-N5NNW4VG.cjs} +6 -6
- package/dist/{chunk-FE23VSSA.cjs.map → chunk-N5NNW4VG.cjs.map} +1 -1
- 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-NG2JHZHE.js → chunk-NNZAEUDW.js} +1853 -2640
- package/dist/chunk-NNZAEUDW.js.map +1 -0
- package/dist/{chunk-5LI5EPGJ.cjs → chunk-QFTDTX6K.cjs} +40 -3
- package/dist/chunk-QFTDTX6K.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-HBVFFBRR.cjs → chunk-T6ZYQJ63.cjs} +1962 -2748
- package/dist/chunk-T6ZYQJ63.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-YRIKITGF.cjs +1768 -0
- package/dist/chunk-YRIKITGF.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-R7YVBHCV.cjs → chunk-ZMW6NU2K.cjs} +197 -73
- package/dist/chunk-ZMW6NU2K.cjs.map +1 -0
- package/dist/{chunk-A2N2GFCG.cjs → chunk-ZVTWQLK4.cjs} +10 -10
- package/dist/{chunk-A2N2GFCG.cjs.map → chunk-ZVTWQLK4.cjs.map} +1 -1
- 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-3D7V24DG.js.map +0 -1
- package/dist/chunk-3LAEG75D.js.map +0 -1
- package/dist/chunk-4B2CNWQU.cjs.map +0 -1
- package/dist/chunk-524F3ATQ.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-7FSDNNNC.js.map +0 -1
- package/dist/chunk-AJA6LUI7.js.map +0 -1
- package/dist/chunk-FQGX2PA2.js.map +0 -1
- package/dist/chunk-GQCOSXMG.js.map +0 -1
- package/dist/chunk-HBVFFBRR.cjs.map +0 -1
- package/dist/chunk-HDP7VK3C.cjs.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-NG2JHZHE.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-R3PY4G7J.js.map +0 -1
- package/dist/chunk-R7YVBHCV.cjs.map +0 -1
- package/dist/chunk-SESSWASV.cjs.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-VB37OC6I.js.map +0 -1
- package/dist/chunk-Y7FT4IQT.js.map +0 -1
- package/dist/chunk-YXCTLWOH.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,92 +1,128 @@
|
|
|
1
|
-
import { I as IEnginePackage } from './PackageRegistry-
|
|
2
|
-
export {
|
|
1
|
+
import { I as IEnginePackage } from './PackageRegistry-BHWJP83F.cjs';
|
|
2
|
+
export { a as EngineRestoreOptions, b as EngineSnapshot, c as EvalResults, d as Explanation, e as ExplanationStep, E as ExpressionEngine, f as IPackageRegistry, L as LineEvaluation, P as PackageRegistry, S as SNAPSHOT_FORMAT, g as SNAPSHOT_VERSION, h as SerializedAnonymousBody, i as SerializedBytecode, j as SerializedDecimal, k as SerializedLineCacheEntry, l as SerializedNumber, m as SerializedRational, n as SerializedUserFunction, o as SerializedValue, p as SnapshotErrorCodes, q as packageRegistry } from './PackageRegistry-BHWJP83F.cjs';
|
|
3
|
+
export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-B-7rK1TD.cjs';
|
|
3
4
|
export { ENGINE_VERSION } from './constants.cjs';
|
|
4
|
-
import './Parselet-
|
|
5
|
-
import './BytecodeBuilder-
|
|
6
|
-
import './Token-
|
|
7
|
-
import './pipeline-
|
|
8
|
-
import './Value-
|
|
5
|
+
import './Parselet-BHcgK9S7.cjs';
|
|
6
|
+
import './BytecodeBuilder-Bp9xeTmX.cjs';
|
|
7
|
+
import './Token-B1hdkedD.cjs';
|
|
8
|
+
import './pipeline-CtfJtPQc.cjs';
|
|
9
|
+
import './Value-BUi1RA3S.cjs';
|
|
9
10
|
import './variables.cjs';
|
|
10
|
-
import './Lexer-
|
|
11
|
+
import './Lexer-BOs7euZe.cjs';
|
|
11
12
|
import './resolvers.cjs';
|
|
12
13
|
import '@tanstack/query-core';
|
|
13
|
-
import './TokenNormalizer-
|
|
14
|
-
import './ScopeManager-
|
|
15
|
-
import './EngineError-
|
|
16
|
-
import './Configuration-
|
|
14
|
+
import './TokenNormalizer-DRc1Js1V.cjs';
|
|
15
|
+
import './ScopeManager-8vf02dwj.cjs';
|
|
16
|
+
import './EngineError-B61GS1jp.cjs';
|
|
17
|
+
import './Configuration-C9W8tJv_.cjs';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* A higher-level, declarative way to contribute a single `name(args)`
|
|
21
|
+
* function, sitting ON TOP OF the package contract rather than replacing it.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* `ParseletRegistry.registerPrefix()`'s collision-visibility fix closed for
|
|
29
|
-
* parselets specifically (see `ARCHITECTURE.md`'s punch list). And none of
|
|
30
|
-
* these existing checks can be run BEFORE registration, they only fire at
|
|
31
|
-
* the moment a collision actually happens, deep inside a live engine.
|
|
32
|
-
*
|
|
33
|
-
* `checkPackageCompatibility()` is a single, pure, side-effect-free function
|
|
34
|
-
* that statically compares one candidate package's declared descriptor
|
|
35
|
-
* against a list of already-registered packages' descriptors, across every
|
|
36
|
-
* collision-capable field `IEnginePackage` has, callable standalone (a host
|
|
37
|
-
* building a plugin marketplace could run it before ever constructing an
|
|
38
|
-
* engine) or wired into registration itself (see
|
|
39
|
-
* `ExpressionEngine.registerPackage()`, which calls this automatically and
|
|
40
|
-
* logs every conflict found, the "load-up resiliency" half of this
|
|
41
|
-
* mechanism).
|
|
42
|
-
*
|
|
43
|
-
* A real, concrete motivating bug (found the same session this module was
|
|
44
|
-
* built): the currency package's real `IEnginePackage` descriptor
|
|
45
|
-
* (`CurrencyPackage.ts`) and its parallel test-harness registration helper
|
|
46
|
-
* (`parselets/index.ts`'s `registerCurrencyParselets()`) drifted out of sync
|
|
47
|
-
*, new currency-symbol token types were wired into one but not the other
|
|
48
|
-
* caught only by a test happening to exercise the stale path. This module
|
|
49
|
-
* doesn't catch THAT specific class of bug (two hand-written registration
|
|
50
|
-
* functions for the same logical package diverging is a source-consistency
|
|
51
|
-
* problem, not a runtime collision), but it DOES catch the more common and
|
|
52
|
-
* more dangerous sibling: two DIFFERENT, independently-authored packages
|
|
53
|
-
* unknowingly claiming the same token type, phrase, converter name, plugin
|
|
54
|
-
* function index, or lexer keyword.
|
|
23
|
+
* The low-level contract (allocate a plugin function index, write a parselet,
|
|
24
|
+
* emit `CALL_PLUGIN`) stays exactly as it was and remains the way to add
|
|
25
|
+
* anything that needs custom parsing. This module derives that same wiring
|
|
26
|
+
* from a declaration for the common case, a function called with parenthesised
|
|
27
|
+
* arguments, so adding `vat(x)` costs a spec object rather than an
|
|
28
|
+
* understanding of the parser and the VM. See `defineFunction`.
|
|
55
29
|
*/
|
|
56
|
-
/**
|
|
57
|
-
type
|
|
58
|
-
/** The
|
|
59
|
-
type
|
|
60
|
-
/** One
|
|
61
|
-
interface
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
/** The two package names involved, [existing, candidate]. */
|
|
67
|
-
packages: [string, string];
|
|
30
|
+
/** The value types a declared argument or return may take. */
|
|
31
|
+
type FunctionValueType = "number" | "string" | "boolean";
|
|
32
|
+
/** The JavaScript type a {@link FunctionValueType} maps to at the `call` boundary. */
|
|
33
|
+
type JsValue<T extends FunctionValueType> = T extends "number" ? number : T extends "string" ? string : boolean;
|
|
34
|
+
/** One declared parameter: a name (for error messages) and a value type. */
|
|
35
|
+
interface FunctionArg {
|
|
36
|
+
/** Parameter name, used only in the generated type-mismatch messages. */
|
|
37
|
+
name: string;
|
|
38
|
+
/** The value type this parameter accepts. */
|
|
39
|
+
type: FunctionValueType;
|
|
68
40
|
}
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
41
|
+
/** Map a tuple of {@link FunctionArg} specs to the tuple of JS values `call` receives. */
|
|
42
|
+
type CallArgs<A extends readonly FunctionArg[]> = {
|
|
43
|
+
[K in keyof A]: JsValue<A[K]["type"]>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A declarative function definition.
|
|
47
|
+
*
|
|
48
|
+
* `A` and `R` are inferred from the literal `args`/`returns` (via
|
|
49
|
+
* `defineFunction`'s `const` type parameter), so `call`'s parameters and
|
|
50
|
+
* return are typed from the declaration with no annotations: an
|
|
51
|
+
* `{ type: "number" }` argument arrives as a `number`, and a `returns:
|
|
52
|
+
* "string"` demands a `string` back.
|
|
53
|
+
*/
|
|
54
|
+
interface FunctionSpec<A extends readonly FunctionArg[] = readonly FunctionArg[], R extends FunctionValueType = FunctionValueType> {
|
|
55
|
+
/**
|
|
56
|
+
* The call name, a single identifier (`/^[a-z_][a-z0-9_]*$/i`). Registered
|
|
57
|
+
* as a lexer keyword, so it is matched case-insensitively and cannot collide
|
|
58
|
+
* with a built-in keyword (that collision throws at registration time).
|
|
59
|
+
*/
|
|
60
|
+
name: string;
|
|
61
|
+
/** The parameters, in order. A fixed-length list: variadic and optional args are out of scope (see {@link defineFunction}). */
|
|
62
|
+
args: A;
|
|
63
|
+
/** The value type the function returns. */
|
|
64
|
+
returns: R;
|
|
65
|
+
/** The implementation, receiving plain JS values and returning one. Must be synchronous (see {@link defineFunction}). */
|
|
66
|
+
call: (...args: CallArgs<A>) => JsValue<R>;
|
|
74
67
|
}
|
|
75
68
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
|
|
69
|
+
* Error codes the declarative function API raises. Kept as a co-located const
|
|
70
|
+
* (the convention `errors/ErrorCode.ts` documents for a domain's own codes) so
|
|
71
|
+
* the strings have one source of truth.
|
|
72
|
+
*/
|
|
73
|
+
declare const DefineFunctionErrorCodes: {
|
|
74
|
+
/** The spec's `name` is not a single identifier. Thrown by `defineFunction`, before any engine sees it. */
|
|
75
|
+
readonly DEFINE_FUNCTION_INVALID_NAME: "DEFINE_FUNCTION_INVALID_NAME";
|
|
76
|
+
/** The spec is otherwise malformed (bad `args`, unsupported type, missing `call`). Thrown by `defineFunction`. */
|
|
77
|
+
readonly DEFINE_FUNCTION_INVALID_SPEC: "DEFINE_FUNCTION_INVALID_SPEC";
|
|
78
|
+
/** The call site passed the wrong number of arguments. Raised at evaluation time. */
|
|
79
|
+
readonly DEFINE_FUNCTION_ARITY_MISMATCH: "DEFINE_FUNCTION_ARITY_MISMATCH";
|
|
80
|
+
/** An argument was the wrong value type. Raised at evaluation time. */
|
|
81
|
+
readonly DEFINE_FUNCTION_ARGUMENT_TYPE: "DEFINE_FUNCTION_ARGUMENT_TYPE";
|
|
82
|
+
/** The `call` implementation returned a value that did not match `returns`. Raised at evaluation time, an authoring bug rather than a user one. */
|
|
83
|
+
readonly DEFINE_FUNCTION_RETURN_TYPE: "DEFINE_FUNCTION_RETURN_TYPE";
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Turn a declarative {@link FunctionSpec} into a ready-to-register
|
|
87
|
+
* {@link IEnginePackage}.
|
|
88
|
+
*
|
|
89
|
+
* This is the higher-level API from issue #102. It derives, from the
|
|
90
|
+
* declaration alone, everything the low-level contract asks an author to write
|
|
91
|
+
* by hand: a plugin function index ({@link allocatePluginFunctionIndex}), a
|
|
92
|
+
* lexer keyword so the name tokenises, a call-syntax parselet emitting
|
|
93
|
+
* `CALL_PLUGIN`, and a handler that checks arity and argument types (yielding
|
|
94
|
+
* the engine's own structured errors) before invoking `call` and wrapping its
|
|
95
|
+
* result. Anything needing custom parsing keeps writing a raw parselet exactly
|
|
96
|
+
* as before, this sits on top of that contract and does not change it.
|
|
80
97
|
*
|
|
81
98
|
* @example
|
|
82
99
|
* ```ts
|
|
83
|
-
* const
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
100
|
+
* const engine = new ExpressionEngine("en", false, undefined, undefined, [
|
|
101
|
+
* ...BUILTIN_PACKAGES,
|
|
102
|
+
* defineFunction({
|
|
103
|
+
* name: "vat",
|
|
104
|
+
* args: [{ name: "amount", type: "number" }],
|
|
105
|
+
* returns: "number",
|
|
106
|
+
* call: (amount) => amount * 1.2,
|
|
107
|
+
* }),
|
|
108
|
+
* ]);
|
|
109
|
+
* engine.evaluateExpression("vat(100)"); // 120
|
|
87
110
|
* ```
|
|
111
|
+
*
|
|
112
|
+
* The returned package is self-contained and composes with any others through
|
|
113
|
+
* the engine's `packages` array; register several functions by passing several
|
|
114
|
+
* packages. Its name is `solve-fn-<name>`.
|
|
115
|
+
*
|
|
116
|
+
* Scope: arguments are a fixed-length list of `number`/`string`/`boolean`, and
|
|
117
|
+
* `call` is synchronous. Variadic and optional arguments, other value types
|
|
118
|
+
* (units, percentages, dates, matrices), and async work are deliberately out
|
|
119
|
+
* of scope, a function needing any of those keeps using the low-level
|
|
120
|
+
* contract, whose parselets and async resolvers are unchanged.
|
|
121
|
+
*
|
|
122
|
+
* @throws {EngineError} (category CONFIG) if the spec is malformed, at the
|
|
123
|
+
* point `defineFunction` is called, before the package reaches an engine.
|
|
88
124
|
*/
|
|
89
|
-
declare function
|
|
125
|
+
declare function defineFunction<const A extends readonly FunctionArg[], R extends FunctionValueType>(spec: FunctionSpec<A, R>): IEnginePackage;
|
|
90
126
|
|
|
91
127
|
/**
|
|
92
128
|
* Engine-version package compatibility gating, the "reject a package built
|
|
@@ -149,4 +185,4 @@ declare function checkEngineVersionCompatibility(pkg: IEnginePackage, engineVers
|
|
|
149
185
|
*/
|
|
150
186
|
declare function assertEngineVersionCompatible(pkg: IEnginePackage, engineVersion?: string): void;
|
|
151
187
|
|
|
152
|
-
export {
|
|
188
|
+
export { DefineFunctionErrorCodes, type EngineVersionCheckResult, type FunctionArg, type FunctionSpec, type FunctionValueType, IEnginePackage, assertEngineVersionCompatible, checkEngineVersionCompatibility, defineFunction };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,92 +1,128 @@
|
|
|
1
|
-
import { I as IEnginePackage } from './PackageRegistry-
|
|
2
|
-
export {
|
|
1
|
+
import { I as IEnginePackage } from './PackageRegistry-_8rDlvxI.js';
|
|
2
|
+
export { a as EngineRestoreOptions, b as EngineSnapshot, c as EvalResults, d as Explanation, e as ExplanationStep, E as ExpressionEngine, f as IPackageRegistry, L as LineEvaluation, P as PackageRegistry, S as SNAPSHOT_FORMAT, g as SNAPSHOT_VERSION, h as SerializedAnonymousBody, i as SerializedBytecode, j as SerializedDecimal, k as SerializedLineCacheEntry, l as SerializedNumber, m as SerializedRational, n as SerializedUserFunction, o as SerializedValue, p as SnapshotErrorCodes, q as packageRegistry } from './PackageRegistry-_8rDlvxI.js';
|
|
3
|
+
export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-Dh59eF-X.js';
|
|
3
4
|
export { ENGINE_VERSION } from './constants.js';
|
|
4
|
-
import './Parselet-
|
|
5
|
-
import './BytecodeBuilder-
|
|
6
|
-
import './Token-
|
|
7
|
-
import './pipeline-
|
|
8
|
-
import './Value-
|
|
5
|
+
import './Parselet-BBT8riYh.js';
|
|
6
|
+
import './BytecodeBuilder-Bp9xeTmX.js';
|
|
7
|
+
import './Token-B1hdkedD.js';
|
|
8
|
+
import './pipeline-DCd5M6Gk.js';
|
|
9
|
+
import './Value-BUi1RA3S.js';
|
|
9
10
|
import './variables.js';
|
|
10
|
-
import './Lexer-
|
|
11
|
+
import './Lexer-CSI_lwbW.js';
|
|
11
12
|
import './resolvers.js';
|
|
12
13
|
import '@tanstack/query-core';
|
|
13
|
-
import './TokenNormalizer-
|
|
14
|
-
import './ScopeManager-
|
|
15
|
-
import './EngineError-
|
|
16
|
-
import './Configuration-
|
|
14
|
+
import './TokenNormalizer-C6VzZgHa.js';
|
|
15
|
+
import './ScopeManager-CxA24W5n.js';
|
|
16
|
+
import './EngineError-B61GS1jp.js';
|
|
17
|
+
import './Configuration-C9W8tJv_.js';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* A higher-level, declarative way to contribute a single `name(args)`
|
|
21
|
+
* function, sitting ON TOP OF the package contract rather than replacing it.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* `ParseletRegistry.registerPrefix()`'s collision-visibility fix closed for
|
|
29
|
-
* parselets specifically (see `ARCHITECTURE.md`'s punch list). And none of
|
|
30
|
-
* these existing checks can be run BEFORE registration, they only fire at
|
|
31
|
-
* the moment a collision actually happens, deep inside a live engine.
|
|
32
|
-
*
|
|
33
|
-
* `checkPackageCompatibility()` is a single, pure, side-effect-free function
|
|
34
|
-
* that statically compares one candidate package's declared descriptor
|
|
35
|
-
* against a list of already-registered packages' descriptors, across every
|
|
36
|
-
* collision-capable field `IEnginePackage` has, callable standalone (a host
|
|
37
|
-
* building a plugin marketplace could run it before ever constructing an
|
|
38
|
-
* engine) or wired into registration itself (see
|
|
39
|
-
* `ExpressionEngine.registerPackage()`, which calls this automatically and
|
|
40
|
-
* logs every conflict found, the "load-up resiliency" half of this
|
|
41
|
-
* mechanism).
|
|
42
|
-
*
|
|
43
|
-
* A real, concrete motivating bug (found the same session this module was
|
|
44
|
-
* built): the currency package's real `IEnginePackage` descriptor
|
|
45
|
-
* (`CurrencyPackage.ts`) and its parallel test-harness registration helper
|
|
46
|
-
* (`parselets/index.ts`'s `registerCurrencyParselets()`) drifted out of sync
|
|
47
|
-
*, new currency-symbol token types were wired into one but not the other
|
|
48
|
-
* caught only by a test happening to exercise the stale path. This module
|
|
49
|
-
* doesn't catch THAT specific class of bug (two hand-written registration
|
|
50
|
-
* functions for the same logical package diverging is a source-consistency
|
|
51
|
-
* problem, not a runtime collision), but it DOES catch the more common and
|
|
52
|
-
* more dangerous sibling: two DIFFERENT, independently-authored packages
|
|
53
|
-
* unknowingly claiming the same token type, phrase, converter name, plugin
|
|
54
|
-
* function index, or lexer keyword.
|
|
23
|
+
* The low-level contract (allocate a plugin function index, write a parselet,
|
|
24
|
+
* emit `CALL_PLUGIN`) stays exactly as it was and remains the way to add
|
|
25
|
+
* anything that needs custom parsing. This module derives that same wiring
|
|
26
|
+
* from a declaration for the common case, a function called with parenthesised
|
|
27
|
+
* arguments, so adding `vat(x)` costs a spec object rather than an
|
|
28
|
+
* understanding of the parser and the VM. See `defineFunction`.
|
|
55
29
|
*/
|
|
56
|
-
/**
|
|
57
|
-
type
|
|
58
|
-
/** The
|
|
59
|
-
type
|
|
60
|
-
/** One
|
|
61
|
-
interface
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
/** The two package names involved, [existing, candidate]. */
|
|
67
|
-
packages: [string, string];
|
|
30
|
+
/** The value types a declared argument or return may take. */
|
|
31
|
+
type FunctionValueType = "number" | "string" | "boolean";
|
|
32
|
+
/** The JavaScript type a {@link FunctionValueType} maps to at the `call` boundary. */
|
|
33
|
+
type JsValue<T extends FunctionValueType> = T extends "number" ? number : T extends "string" ? string : boolean;
|
|
34
|
+
/** One declared parameter: a name (for error messages) and a value type. */
|
|
35
|
+
interface FunctionArg {
|
|
36
|
+
/** Parameter name, used only in the generated type-mismatch messages. */
|
|
37
|
+
name: string;
|
|
38
|
+
/** The value type this parameter accepts. */
|
|
39
|
+
type: FunctionValueType;
|
|
68
40
|
}
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
41
|
+
/** Map a tuple of {@link FunctionArg} specs to the tuple of JS values `call` receives. */
|
|
42
|
+
type CallArgs<A extends readonly FunctionArg[]> = {
|
|
43
|
+
[K in keyof A]: JsValue<A[K]["type"]>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A declarative function definition.
|
|
47
|
+
*
|
|
48
|
+
* `A` and `R` are inferred from the literal `args`/`returns` (via
|
|
49
|
+
* `defineFunction`'s `const` type parameter), so `call`'s parameters and
|
|
50
|
+
* return are typed from the declaration with no annotations: an
|
|
51
|
+
* `{ type: "number" }` argument arrives as a `number`, and a `returns:
|
|
52
|
+
* "string"` demands a `string` back.
|
|
53
|
+
*/
|
|
54
|
+
interface FunctionSpec<A extends readonly FunctionArg[] = readonly FunctionArg[], R extends FunctionValueType = FunctionValueType> {
|
|
55
|
+
/**
|
|
56
|
+
* The call name, a single identifier (`/^[a-z_][a-z0-9_]*$/i`). Registered
|
|
57
|
+
* as a lexer keyword, so it is matched case-insensitively and cannot collide
|
|
58
|
+
* with a built-in keyword (that collision throws at registration time).
|
|
59
|
+
*/
|
|
60
|
+
name: string;
|
|
61
|
+
/** The parameters, in order. A fixed-length list: variadic and optional args are out of scope (see {@link defineFunction}). */
|
|
62
|
+
args: A;
|
|
63
|
+
/** The value type the function returns. */
|
|
64
|
+
returns: R;
|
|
65
|
+
/** The implementation, receiving plain JS values and returning one. Must be synchronous (see {@link defineFunction}). */
|
|
66
|
+
call: (...args: CallArgs<A>) => JsValue<R>;
|
|
74
67
|
}
|
|
75
68
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
|
|
69
|
+
* Error codes the declarative function API raises. Kept as a co-located const
|
|
70
|
+
* (the convention `errors/ErrorCode.ts` documents for a domain's own codes) so
|
|
71
|
+
* the strings have one source of truth.
|
|
72
|
+
*/
|
|
73
|
+
declare const DefineFunctionErrorCodes: {
|
|
74
|
+
/** The spec's `name` is not a single identifier. Thrown by `defineFunction`, before any engine sees it. */
|
|
75
|
+
readonly DEFINE_FUNCTION_INVALID_NAME: "DEFINE_FUNCTION_INVALID_NAME";
|
|
76
|
+
/** The spec is otherwise malformed (bad `args`, unsupported type, missing `call`). Thrown by `defineFunction`. */
|
|
77
|
+
readonly DEFINE_FUNCTION_INVALID_SPEC: "DEFINE_FUNCTION_INVALID_SPEC";
|
|
78
|
+
/** The call site passed the wrong number of arguments. Raised at evaluation time. */
|
|
79
|
+
readonly DEFINE_FUNCTION_ARITY_MISMATCH: "DEFINE_FUNCTION_ARITY_MISMATCH";
|
|
80
|
+
/** An argument was the wrong value type. Raised at evaluation time. */
|
|
81
|
+
readonly DEFINE_FUNCTION_ARGUMENT_TYPE: "DEFINE_FUNCTION_ARGUMENT_TYPE";
|
|
82
|
+
/** The `call` implementation returned a value that did not match `returns`. Raised at evaluation time, an authoring bug rather than a user one. */
|
|
83
|
+
readonly DEFINE_FUNCTION_RETURN_TYPE: "DEFINE_FUNCTION_RETURN_TYPE";
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Turn a declarative {@link FunctionSpec} into a ready-to-register
|
|
87
|
+
* {@link IEnginePackage}.
|
|
88
|
+
*
|
|
89
|
+
* This is the higher-level API from issue #102. It derives, from the
|
|
90
|
+
* declaration alone, everything the low-level contract asks an author to write
|
|
91
|
+
* by hand: a plugin function index ({@link allocatePluginFunctionIndex}), a
|
|
92
|
+
* lexer keyword so the name tokenises, a call-syntax parselet emitting
|
|
93
|
+
* `CALL_PLUGIN`, and a handler that checks arity and argument types (yielding
|
|
94
|
+
* the engine's own structured errors) before invoking `call` and wrapping its
|
|
95
|
+
* result. Anything needing custom parsing keeps writing a raw parselet exactly
|
|
96
|
+
* as before, this sits on top of that contract and does not change it.
|
|
80
97
|
*
|
|
81
98
|
* @example
|
|
82
99
|
* ```ts
|
|
83
|
-
* const
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
100
|
+
* const engine = new ExpressionEngine("en", false, undefined, undefined, [
|
|
101
|
+
* ...BUILTIN_PACKAGES,
|
|
102
|
+
* defineFunction({
|
|
103
|
+
* name: "vat",
|
|
104
|
+
* args: [{ name: "amount", type: "number" }],
|
|
105
|
+
* returns: "number",
|
|
106
|
+
* call: (amount) => amount * 1.2,
|
|
107
|
+
* }),
|
|
108
|
+
* ]);
|
|
109
|
+
* engine.evaluateExpression("vat(100)"); // 120
|
|
87
110
|
* ```
|
|
111
|
+
*
|
|
112
|
+
* The returned package is self-contained and composes with any others through
|
|
113
|
+
* the engine's `packages` array; register several functions by passing several
|
|
114
|
+
* packages. Its name is `solve-fn-<name>`.
|
|
115
|
+
*
|
|
116
|
+
* Scope: arguments are a fixed-length list of `number`/`string`/`boolean`, and
|
|
117
|
+
* `call` is synchronous. Variadic and optional arguments, other value types
|
|
118
|
+
* (units, percentages, dates, matrices), and async work are deliberately out
|
|
119
|
+
* of scope, a function needing any of those keeps using the low-level
|
|
120
|
+
* contract, whose parselets and async resolvers are unchanged.
|
|
121
|
+
*
|
|
122
|
+
* @throws {EngineError} (category CONFIG) if the spec is malformed, at the
|
|
123
|
+
* point `defineFunction` is called, before the package reaches an engine.
|
|
88
124
|
*/
|
|
89
|
-
declare function
|
|
125
|
+
declare function defineFunction<const A extends readonly FunctionArg[], R extends FunctionValueType>(spec: FunctionSpec<A, R>): IEnginePackage;
|
|
90
126
|
|
|
91
127
|
/**
|
|
92
128
|
* Engine-version package compatibility gating, the "reject a package built
|
|
@@ -149,4 +185,4 @@ declare function checkEngineVersionCompatibility(pkg: IEnginePackage, engineVers
|
|
|
149
185
|
*/
|
|
150
186
|
declare function assertEngineVersionCompatible(pkg: IEnginePackage, engineVersion?: string): void;
|
|
151
187
|
|
|
152
|
-
export {
|
|
188
|
+
export { DefineFunctionErrorCodes, type EngineVersionCheckResult, type FunctionArg, type FunctionSpec, type FunctionValueType, IEnginePackage, assertEngineVersionCompatible, checkEngineVersionCompatibility, defineFunction };
|