solve-engine 2.25.0 → 2.27.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/CalendarBackend-MdS3Bb4P.d.cts +181 -0
- package/dist/CalendarBackend-MdS3Bb4P.d.ts +181 -0
- package/dist/{Configuration-DnzYPmoK.d.cts → Configuration-BxriK9Kw.d.cts} +63 -4
- package/dist/{Configuration-DnzYPmoK.d.ts → Configuration-BxriK9Kw.d.ts} +63 -4
- package/dist/DateCalendar-B85t6Vk6.d.ts +90 -0
- package/dist/DateCalendar-CUGI1fT4.d.cts +90 -0
- package/dist/{EngineError-fR1K1rvx.d.cts → EngineError-C-kBwYlN.d.cts} +31 -4
- package/dist/{EngineError-fR1K1rvx.d.ts → EngineError-C-kBwYlN.d.ts} +31 -4
- package/dist/{FormattingSettings-bRKjU7wI.d.ts → FormattingSettings-ByO-4wiM.d.cts} +14 -0
- package/dist/{FormattingSettings-bRKjU7wI.d.cts → FormattingSettings-CvCzAfsz.d.ts} +14 -0
- package/dist/{Lexer-aB95pjoX.d.cts → Lexer-DhGhoAa2.d.cts} +13 -3
- package/dist/{Lexer-Bmctxl0n.d.ts → Lexer-DqtnZMC5.d.ts} +13 -3
- package/dist/{PackageCompatibility-CUVg8tmt.d.cts → PackageCompatibility-CNiTtC6S.d.cts} +1 -1
- package/dist/{PackageCompatibility-BludTs7v.d.ts → PackageCompatibility-fj_f7uqC.d.ts} +1 -1
- package/dist/{PackageRegistry-Dvn4i2QK.d.cts → PackageRegistry-BHBCFswo.d.cts} +328 -14
- package/dist/{PackageRegistry-DT-x32OM.d.ts → PackageRegistry-CNZUwWHJ.d.ts} +328 -14
- package/dist/{Parselet-BawfGuTF.d.cts → Parselet-DF3864la.d.cts} +19 -3
- package/dist/{Parselet-DqTbbtWA.d.ts → Parselet-Dgymjxzd.d.ts} +19 -3
- package/dist/{Token-CbP_OutD.d.cts → Token-D8f7yaz1.d.cts} +17 -0
- package/dist/{Token-CbP_OutD.d.ts → Token-D8f7yaz1.d.ts} +17 -0
- package/dist/{TokenNormalizer-CLBtiE8M.d.ts → TokenNormalizer-IF7nPRMp.d.ts} +1 -1
- package/dist/{TokenNormalizer-CjTDmHgB.d.cts → TokenNormalizer-Pe3_390t.d.cts} +1 -1
- package/dist/{ScopeManager-B636am7Y.d.ts → VMBuiltins-CZiZRKn-.d.ts} +91 -9
- package/dist/{ScopeManager-CdwX0VTw.d.cts → VMBuiltins-kv4rr0y5.d.cts} +91 -9
- package/dist/{VMCheckpoints-DDlxNssY.d.ts → VMCheckpoints-DXze6ypg.d.ts} +2 -2
- package/dist/{VMCheckpoints-CYqeq8IV.d.cts → VMCheckpoints-yun4ocSv.d.cts} +2 -2
- package/dist/{Value-Ds3Gy07C.d.cts → Value-BYHw-x7q.d.cts} +57 -1
- package/dist/{Value-Ds3Gy07C.d.ts → Value-BYHw-x7q.d.ts} +57 -1
- package/dist/{WorkerError-B1dF3VYT.d.cts → WorkerError-BLZyNq6M.d.cts} +1 -1
- package/dist/{WorkerError-dneODN-u.d.ts → WorkerError-CfBJYueR.d.ts} +1 -1
- package/dist/chunk-2SYYKQ4Q.cjs +2 -0
- package/dist/chunk-2SYYKQ4Q.cjs.map +1 -0
- package/dist/chunk-6EYKVQT3.cjs +2 -0
- package/dist/chunk-6EYKVQT3.cjs.map +1 -0
- package/dist/chunk-7RC6RBS6.cjs +2 -0
- package/dist/chunk-7RC6RBS6.cjs.map +1 -0
- package/dist/chunk-AZX4NTYN.cjs +3 -0
- package/dist/chunk-AZX4NTYN.cjs.map +1 -0
- package/dist/{chunk-JFZ5SLF7.js → chunk-BCR53EIL.js} +2 -2
- package/dist/{chunk-JFZ5SLF7.js.map → chunk-BCR53EIL.js.map} +1 -1
- package/dist/chunk-BCY2WY5P.js +5 -0
- package/dist/chunk-BCY2WY5P.js.map +1 -0
- package/dist/chunk-BLJ6E577.js +2 -0
- package/dist/chunk-BLJ6E577.js.map +1 -0
- package/dist/chunk-CL7DM2FX.js +2 -0
- package/dist/chunk-CL7DM2FX.js.map +1 -0
- package/dist/{chunk-BMXYR5LI.cjs → chunk-CQLCTKMX.cjs} +2 -2
- package/dist/{chunk-BMXYR5LI.cjs.map → chunk-CQLCTKMX.cjs.map} +1 -1
- package/dist/chunk-D4VBWPWN.js +2 -0
- package/dist/chunk-D4VBWPWN.js.map +1 -0
- package/dist/chunk-DFMAZ6XM.cjs +3 -0
- package/dist/chunk-DFMAZ6XM.cjs.map +1 -0
- package/dist/chunk-E4HAKNBQ.cjs +2 -0
- package/dist/chunk-E4HAKNBQ.cjs.map +1 -0
- package/dist/{chunk-XHQYHXRE.js → chunk-ESZNJQ2C.js} +3 -3
- package/dist/{chunk-XHQYHXRE.js.map → chunk-ESZNJQ2C.js.map} +1 -1
- package/dist/{chunk-IJMNVBIS.js → chunk-FAO6DQ74.js} +2 -2
- package/dist/chunk-FAO6DQ74.js.map +1 -0
- package/dist/{chunk-WGP4UUO5.cjs → chunk-FDKTESBC.cjs} +2 -2
- package/dist/{chunk-WGP4UUO5.cjs.map → chunk-FDKTESBC.cjs.map} +1 -1
- package/dist/{chunk-NEGZZB7F.cjs → chunk-G2V33LFM.cjs} +2 -2
- package/dist/{chunk-NEGZZB7F.cjs.map → chunk-G2V33LFM.cjs.map} +1 -1
- package/dist/chunk-GJZIJK2Q.cjs +2 -0
- package/dist/chunk-GJZIJK2Q.cjs.map +1 -0
- package/dist/chunk-GVL3ZMS7.cjs +2 -0
- package/dist/chunk-GVL3ZMS7.cjs.map +1 -0
- package/dist/{chunk-YBQPEWT7.cjs → chunk-GXO7TSXQ.cjs} +3 -3
- package/dist/chunk-GXO7TSXQ.cjs.map +1 -0
- package/dist/{chunk-OONQ3V3I.js → chunk-HANGBVEE.js} +2 -2
- package/dist/{chunk-OONQ3V3I.js.map → chunk-HANGBVEE.js.map} +1 -1
- package/dist/chunk-J4K72CQN.js +2 -0
- package/dist/chunk-J4K72CQN.js.map +1 -0
- package/dist/{chunk-72PYPENZ.js → chunk-LE6WZLJ4.js} +2 -2
- package/dist/{chunk-72PYPENZ.js.map → chunk-LE6WZLJ4.js.map} +1 -1
- package/dist/chunk-LQIRBP4Q.js +2 -0
- package/dist/chunk-LQIRBP4Q.js.map +1 -0
- package/dist/{chunk-RDYXH7ML.js → chunk-LTUYWJGO.js} +2 -2
- package/dist/{chunk-RDYXH7ML.js.map → chunk-LTUYWJGO.js.map} +1 -1
- package/dist/chunk-O5PO4D2A.cjs +2 -0
- package/dist/chunk-O5PO4D2A.cjs.map +1 -0
- package/dist/chunk-PQFI55AC.js +3 -0
- package/dist/chunk-PQFI55AC.js.map +1 -0
- package/dist/chunk-QQHHZPEW.cjs +2 -0
- package/dist/chunk-QQHHZPEW.cjs.map +1 -0
- package/dist/chunk-REZQFPVX.js +2 -0
- package/dist/chunk-REZQFPVX.js.map +1 -0
- package/dist/chunk-RRUGQ6DM.js +2 -0
- package/dist/chunk-RRUGQ6DM.js.map +1 -0
- package/dist/chunk-S3ODNMJS.js +2 -0
- package/dist/chunk-S3ODNMJS.js.map +1 -0
- package/dist/{chunk-SAF3B3AX.cjs → chunk-SE6ZCGZ5.cjs} +2 -2
- package/dist/{chunk-SAF3B3AX.cjs.map → chunk-SE6ZCGZ5.cjs.map} +1 -1
- package/dist/chunk-TC23XEAV.js +2 -0
- package/dist/chunk-TC23XEAV.js.map +1 -0
- package/dist/{chunk-FYAMQFZZ.cjs → chunk-TMQ37JQY.cjs} +3 -3
- package/dist/{chunk-FYAMQFZZ.cjs.map → chunk-TMQ37JQY.cjs.map} +1 -1
- package/dist/chunk-TPPM4QSS.cjs +2 -0
- package/dist/chunk-TPPM4QSS.cjs.map +1 -0
- package/dist/chunk-UVHD7BBC.js +3 -0
- package/dist/{chunk-ZDCZ5IDD.js.map → chunk-UVHD7BBC.js.map} +1 -1
- package/dist/{chunk-57PSJQQW.js → chunk-VB6QMU2W.js} +3 -3
- package/dist/chunk-VB6QMU2W.js.map +1 -0
- package/dist/chunk-VQO54ZMA.js +2 -0
- package/dist/chunk-VQO54ZMA.js.map +1 -0
- package/dist/{chunk-7DP57BA7.js → chunk-Y7XRA2EV.js} +2 -2
- package/dist/{chunk-7DP57BA7.js.map → chunk-Y7XRA2EV.js.map} +1 -1
- package/dist/{chunk-5IJD5L3O.cjs → chunk-YBQOQTVL.cjs} +2 -2
- package/dist/chunk-YBQOQTVL.cjs.map +1 -0
- package/dist/{chunk-EL2XUOWX.js → chunk-YG7UWQFV.js} +2 -2
- package/dist/{chunk-EL2XUOWX.js.map → chunk-YG7UWQFV.js.map} +1 -1
- package/dist/chunk-YSHWNCDH.cjs +5 -0
- package/dist/chunk-YSHWNCDH.cjs.map +1 -0
- package/dist/chunk-ZC2NPRLO.js +3 -0
- package/dist/chunk-ZC2NPRLO.js.map +1 -0
- package/dist/{chunk-FYTB7SDP.cjs → chunk-ZDJTDFTR.cjs} +2 -2
- package/dist/{chunk-FYTB7SDP.cjs.map → chunk-ZDJTDFTR.cjs.map} +1 -1
- package/dist/chunk-ZE5KKMBV.cjs +2 -0
- package/dist/chunk-ZE5KKMBV.cjs.map +1 -0
- package/dist/{chunk-4BAUQE6A.cjs → chunk-ZPHUTCJ5.cjs} +3 -3
- package/dist/{chunk-4BAUQE6A.cjs.map → chunk-ZPHUTCJ5.cjs.map} +1 -1
- package/dist/{chunk-GBCN7FNV.cjs → chunk-ZSLVLMO5.cjs} +2 -2
- package/dist/{chunk-GBCN7FNV.cjs.map → chunk-ZSLVLMO5.cjs.map} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +14 -12
- package/dist/engine.d.ts +14 -12
- package/dist/engine.js +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.d.cts +4 -3
- package/dist/format.d.ts +4 -3
- package/dist/format.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -13
- package/dist/index.d.ts +15 -13
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/language.d.cts +12 -11
- package/dist/language.d.ts +12 -11
- package/dist/lexer.cjs +1 -1
- package/dist/lexer.d.cts +4 -4
- package/dist/lexer.d.ts +4 -4
- package/dist/lexer.js +1 -1
- package/dist/normalizer.cjs +1 -1
- package/dist/normalizer.d.cts +3 -3
- package/dist/normalizer.d.ts +3 -3
- package/dist/normalizer.js +1 -1
- package/dist/packages.cjs +1 -1
- package/dist/packages.d.cts +11 -10
- package/dist/packages.d.ts +11 -10
- package/dist/packages.js +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.d.cts +5 -4
- package/dist/parser.d.ts +5 -4
- package/dist/parser.js +1 -1
- package/dist/{pipeline-69q2tsLE.d.cts → pipeline-BYkKNpql.d.cts} +1 -1
- package/dist/{pipeline-DTqGLPsV.d.ts → pipeline-Cl7KW8CB.d.ts} +1 -1
- package/dist/resolvers.d.cts +2 -2
- package/dist/resolvers.d.ts +2 -2
- package/dist/temporal.cjs +2 -0
- package/dist/temporal.cjs.map +1 -0
- package/dist/temporal.d.cts +201 -0
- package/dist/temporal.d.ts +201 -0
- package/dist/temporal.js +2 -0
- package/dist/temporal.js.map +1 -0
- package/dist/testing.cjs +2 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +12 -11
- package/dist/testing.d.ts +12 -11
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/uom.cjs +1 -1
- package/dist/uom.d.cts +2 -2
- package/dist/uom.d.ts +2 -2
- package/dist/uom.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.cjs.map +1 -1
- package/dist/vm.d.cts +8 -56
- package/dist/vm.d.ts +8 -56
- package/dist/vm.js +1 -1
- package/dist/vm.js.map +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +35 -13
- package/dist/worker.d.ts +35 -13
- package/dist/worker.js +2 -2
- package/dist/worker.js.map +1 -1
- package/package.json +12 -1
- package/dist/chunk-4BRTUFTH.js +0 -2
- package/dist/chunk-4BRTUFTH.js.map +0 -1
- package/dist/chunk-4NZXCHQL.cjs +0 -2
- package/dist/chunk-4NZXCHQL.cjs.map +0 -1
- package/dist/chunk-57PSJQQW.js.map +0 -1
- package/dist/chunk-5IJD5L3O.cjs.map +0 -1
- package/dist/chunk-634ILVMP.cjs +0 -2
- package/dist/chunk-634ILVMP.cjs.map +0 -1
- package/dist/chunk-63ZOOUOL.js +0 -2
- package/dist/chunk-63ZOOUOL.js.map +0 -1
- package/dist/chunk-77KI7AKJ.cjs +0 -2
- package/dist/chunk-77KI7AKJ.cjs.map +0 -1
- package/dist/chunk-7N3IJSWF.js +0 -5
- package/dist/chunk-7N3IJSWF.js.map +0 -1
- package/dist/chunk-DUYTXLO2.js +0 -2
- package/dist/chunk-DUYTXLO2.js.map +0 -1
- package/dist/chunk-IJMNVBIS.js.map +0 -1
- package/dist/chunk-JSM3O7EM.cjs +0 -2
- package/dist/chunk-JSM3O7EM.cjs.map +0 -1
- package/dist/chunk-MZMA32NE.js +0 -3
- package/dist/chunk-MZMA32NE.js.map +0 -1
- package/dist/chunk-N4SSR7Q6.js +0 -2
- package/dist/chunk-N4SSR7Q6.js.map +0 -1
- package/dist/chunk-NMU5E7W7.js +0 -2
- package/dist/chunk-NMU5E7W7.js.map +0 -1
- package/dist/chunk-OB2VX4IL.js +0 -2
- package/dist/chunk-OB2VX4IL.js.map +0 -1
- package/dist/chunk-RAPEZR5L.cjs +0 -2
- package/dist/chunk-RAPEZR5L.cjs.map +0 -1
- package/dist/chunk-SPOVFRZO.cjs +0 -5
- package/dist/chunk-SPOVFRZO.cjs.map +0 -1
- package/dist/chunk-SQHBOWES.cjs +0 -2
- package/dist/chunk-SQHBOWES.cjs.map +0 -1
- package/dist/chunk-UF5XMZTT.js +0 -2
- package/dist/chunk-UF5XMZTT.js.map +0 -1
- package/dist/chunk-UV3EUIBT.cjs +0 -3
- package/dist/chunk-UV3EUIBT.cjs.map +0 -1
- package/dist/chunk-VMSCRVNX.cjs +0 -2
- package/dist/chunk-VMSCRVNX.cjs.map +0 -1
- package/dist/chunk-XBGK3TTU.cjs +0 -3
- package/dist/chunk-XBGK3TTU.cjs.map +0 -1
- package/dist/chunk-XX55RR4Q.js +0 -3
- package/dist/chunk-XX55RR4Q.js.map +0 -1
- package/dist/chunk-YBQPEWT7.cjs.map +0 -1
- package/dist/chunk-ZDCZ5IDD.js +0 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { V as Value } from './Value-
|
|
1
|
+
import { V as Value } from './Value-BYHw-x7q.js';
|
|
2
2
|
import { U as UserFunctionDef, A as AnonymousBodyDef, a as BytecodeProgram } from './BytecodeBuilder-DSWKZi4f.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { C as CalendarBackend } from './CalendarBackend-MdS3Bb4P.js';
|
|
4
|
+
import { E as EngineError } from './EngineError-C-kBwYlN.js';
|
|
5
|
+
import { D as DiagnosticPipeline } from './pipeline-Cl7KW8CB.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Create a new VM instance with the given opcode registry and configurable limits.
|
|
@@ -83,6 +84,14 @@ interface LineExecutionContext {
|
|
|
83
84
|
* message that describes a different fault. Absent means enabled.
|
|
84
85
|
*/
|
|
85
86
|
networkEnabled?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* The calendar backend this engine computes dates with (`EngineContext.calendar`).
|
|
89
|
+
* A plugin function that reads or steps a date computes through it, so the
|
|
90
|
+
* date it answers agrees with the one the VM's own opcodes would produce.
|
|
91
|
+
* Absent means the `Date` backend; `calendarOf()` in
|
|
92
|
+
* `calendar/DateCalendar.ts` resolves either case.
|
|
93
|
+
*/
|
|
94
|
+
calendar?: CalendarBackend;
|
|
86
95
|
/** Look up another line's cached result by 1-based line number. `undefined` = not evaluated yet (or out of range), distinct from a line that evaluated to an actual `undefined`-like Value, which can't happen (every Value type has a concrete representation). */
|
|
87
96
|
getLineResult?: (lineNumber: number) => Value | undefined;
|
|
88
97
|
/** Whether line `lineNumber` is a blank line or a `#` heading, the stopping condition for "total above"/"sum above"/"average above" aggregation. */
|
|
@@ -190,11 +199,13 @@ declare function executeBytecode(bytecode: Bytecode, vm: VM, pipeline?: Diagnost
|
|
|
190
199
|
* by that engine. Anything that needs one of these registries receives the
|
|
191
200
|
* context rather than importing a singleton.
|
|
192
201
|
*
|
|
193
|
-
* Runtime imports here are restricted to leaf modules of `vm
|
|
194
|
-
* imported by `vm/`, which `engine/` imports in
|
|
195
|
-
* that reaches back into `engine/` would close a
|
|
196
|
-
* because it imports only types plus the error
|
|
197
|
-
*
|
|
202
|
+
* Runtime imports here are restricted to leaf modules of `vm/` and
|
|
203
|
+
* `calendar/`. This file is imported by `vm/`, which `engine/` imports in
|
|
204
|
+
* turn, so pulling in anything that reaches back into `engine/` would close a
|
|
205
|
+
* cycle. `OpRegistry` is safe because it imports only types plus the error
|
|
206
|
+
* factory, and the `Date` calendar backend imports nothing of the engine's at
|
|
207
|
+
* all. Everything else arrives through `import type`, which is erased before
|
|
208
|
+
* the code runs.
|
|
198
209
|
*/
|
|
199
210
|
|
|
200
211
|
/**
|
|
@@ -268,6 +279,18 @@ interface EngineContext {
|
|
|
268
279
|
* the context is the one object every VM already holds.
|
|
269
280
|
*/
|
|
270
281
|
readonly networkEnabled: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* The calendar this engine computes dates with, from the engine's
|
|
284
|
+
* `calendar` option.
|
|
285
|
+
*
|
|
286
|
+
* One backend per engine, held here for the same reason the network
|
|
287
|
+
* switch is: the VM is where a date literal is stepped, a working-day
|
|
288
|
+
* walk runs and `now` is read, and every plugin function that touches a
|
|
289
|
+
* date reaches it through the execution context the VM builds from this
|
|
290
|
+
* one object. Defaults to Temporal where the runtime has it and `Date`
|
|
291
|
+
* where it does not. See `calendar/resolveCalendar.ts`.
|
|
292
|
+
*/
|
|
293
|
+
readonly calendar: CalendarBackend;
|
|
271
294
|
}
|
|
272
295
|
|
|
273
296
|
/**
|
|
@@ -705,4 +728,63 @@ declare class ScopeManager {
|
|
|
705
728
|
clear(): void;
|
|
706
729
|
}
|
|
707
730
|
|
|
708
|
-
|
|
731
|
+
/**
|
|
732
|
+
* Registry of built-in mathematical functions.
|
|
733
|
+
* Indexed by the number pushed as an operand of OpCode.CALL_BUILTIN.
|
|
734
|
+
*/
|
|
735
|
+
declare const builtinFunctions: Record<number, (args: Value[]) => Value>;
|
|
736
|
+
/**
|
|
737
|
+
* Registry of package-registered functions, indexed by the number pushed as an
|
|
738
|
+
* operand of `OpCode.CALL_PLUGIN`.
|
|
739
|
+
*
|
|
740
|
+
* Functions may return a promise. The orchestrator resolves it and re-executes
|
|
741
|
+
* rather than blocking the VM.
|
|
742
|
+
*
|
|
743
|
+
* Populated declaratively via {@link IEnginePackage.pluginFunctions} at
|
|
744
|
+
* package-registration time. Entries are cleared on unregister.
|
|
745
|
+
*
|
|
746
|
+
* @deprecated This is the {@link defaultEngineContext}'s map, kept as a
|
|
747
|
+
* module-level alias so existing callers keep working during the context
|
|
748
|
+
* migration. An engine registers into its own context, so writing here affects
|
|
749
|
+
* only code that has not been migrated. Take an {@link EngineContext} instead.
|
|
750
|
+
*/
|
|
751
|
+
declare const pluginFunctionRegistry: Record<number, PluginFunctionHandler>;
|
|
752
|
+
/**
|
|
753
|
+
* Allocate a unique index into {@link pluginFunctionRegistry} for a package's
|
|
754
|
+
* plugin function.
|
|
755
|
+
*
|
|
756
|
+
* Call once per function, typically at module scope, right where the
|
|
757
|
+
* function is defined, and store the result in a constant. Don't hardcode
|
|
758
|
+
* an index: two packages independently picking the same arbitrary number
|
|
759
|
+
* would silently overwrite each other's handler in the shared registry.
|
|
760
|
+
*
|
|
761
|
+
* @throws If the index pool is exhausted (up to 65536: two opcode-stream bytes
|
|
762
|
+
* via CALL_PLUGIN_WIDE, the first 256 via the one-byte CALL_PLUGIN).
|
|
763
|
+
*/
|
|
764
|
+
declare function allocatePluginFunctionIndex(): number;
|
|
765
|
+
/**
|
|
766
|
+
* The stable index for a package's named plugin function, allocated once per
|
|
767
|
+
* `${packageName}:${functionName}` and cached process-wide, so the same function
|
|
768
|
+
* always maps to the same {@link pluginFunctionRegistry} slot no matter which
|
|
769
|
+
* engine registers it or in what order: the property compiled bytecode, and so
|
|
770
|
+
* a snapshot, relies on.
|
|
771
|
+
*
|
|
772
|
+
* The engine calls this at {@link ExpressionEngine.registerPackage} time for each
|
|
773
|
+
* entry of a package's `pluginFunctions` record, so a package author names the
|
|
774
|
+
* function and never sees an index. {@link allocatePluginFunctionIndex} remains
|
|
775
|
+
* for a host that needs a raw index directly.
|
|
776
|
+
*/
|
|
777
|
+
declare function pluginFunctionIndexFor(qualifiedName: string): number;
|
|
778
|
+
/**
|
|
779
|
+
* A package-registered `as <name>` converter: the value on the left of `as`
|
|
780
|
+
* in, the converted value out.
|
|
781
|
+
*
|
|
782
|
+
* The optional `context` is the per-line execution context the VM passes to
|
|
783
|
+
* a plugin function, handed to a converter for the same reason: a converter
|
|
784
|
+
* that reads a date computes through the engine's calendar backend on it
|
|
785
|
+
* rather than a module-level default, so `<date> as weekday` and `weekday on
|
|
786
|
+
* <date>` cannot disagree. A converter that needs nothing from it ignores it.
|
|
787
|
+
*/
|
|
788
|
+
type AsConverter = (value: Value, context?: LineExecutionContext) => Value;
|
|
789
|
+
|
|
790
|
+
export { type AsConverter as A, type Bytecode as B, DependencyGraph as D, type ExpressionRecord as E, type LineExecutionContext as L, OpRegistry as O, type PluginFunctionHandler as P, ScopeManager as S, type VM as V, allocatePluginFunctionIndex as a, builtinFunctions as b, createVM as c, pluginFunctionRegistry as d, executeBytecode as e, type DagSnapshot as f, type EngineContext as g, pluginFunctionIndexFor as p, sharedOpRegistry as s };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { V as Value } from './Value-
|
|
1
|
+
import { V as Value } from './Value-BYHw-x7q.cjs';
|
|
2
2
|
import { U as UserFunctionDef, A as AnonymousBodyDef, a as BytecodeProgram } from './BytecodeBuilder-DSWKZi4f.cjs';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { C as CalendarBackend } from './CalendarBackend-MdS3Bb4P.cjs';
|
|
4
|
+
import { E as EngineError } from './EngineError-C-kBwYlN.cjs';
|
|
5
|
+
import { D as DiagnosticPipeline } from './pipeline-BYkKNpql.cjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Create a new VM instance with the given opcode registry and configurable limits.
|
|
@@ -83,6 +84,14 @@ interface LineExecutionContext {
|
|
|
83
84
|
* message that describes a different fault. Absent means enabled.
|
|
84
85
|
*/
|
|
85
86
|
networkEnabled?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* The calendar backend this engine computes dates with (`EngineContext.calendar`).
|
|
89
|
+
* A plugin function that reads or steps a date computes through it, so the
|
|
90
|
+
* date it answers agrees with the one the VM's own opcodes would produce.
|
|
91
|
+
* Absent means the `Date` backend; `calendarOf()` in
|
|
92
|
+
* `calendar/DateCalendar.ts` resolves either case.
|
|
93
|
+
*/
|
|
94
|
+
calendar?: CalendarBackend;
|
|
86
95
|
/** Look up another line's cached result by 1-based line number. `undefined` = not evaluated yet (or out of range), distinct from a line that evaluated to an actual `undefined`-like Value, which can't happen (every Value type has a concrete representation). */
|
|
87
96
|
getLineResult?: (lineNumber: number) => Value | undefined;
|
|
88
97
|
/** Whether line `lineNumber` is a blank line or a `#` heading, the stopping condition for "total above"/"sum above"/"average above" aggregation. */
|
|
@@ -190,11 +199,13 @@ declare function executeBytecode(bytecode: Bytecode, vm: VM, pipeline?: Diagnost
|
|
|
190
199
|
* by that engine. Anything that needs one of these registries receives the
|
|
191
200
|
* context rather than importing a singleton.
|
|
192
201
|
*
|
|
193
|
-
* Runtime imports here are restricted to leaf modules of `vm
|
|
194
|
-
* imported by `vm/`, which `engine/` imports in
|
|
195
|
-
* that reaches back into `engine/` would close a
|
|
196
|
-
* because it imports only types plus the error
|
|
197
|
-
*
|
|
202
|
+
* Runtime imports here are restricted to leaf modules of `vm/` and
|
|
203
|
+
* `calendar/`. This file is imported by `vm/`, which `engine/` imports in
|
|
204
|
+
* turn, so pulling in anything that reaches back into `engine/` would close a
|
|
205
|
+
* cycle. `OpRegistry` is safe because it imports only types plus the error
|
|
206
|
+
* factory, and the `Date` calendar backend imports nothing of the engine's at
|
|
207
|
+
* all. Everything else arrives through `import type`, which is erased before
|
|
208
|
+
* the code runs.
|
|
198
209
|
*/
|
|
199
210
|
|
|
200
211
|
/**
|
|
@@ -268,6 +279,18 @@ interface EngineContext {
|
|
|
268
279
|
* the context is the one object every VM already holds.
|
|
269
280
|
*/
|
|
270
281
|
readonly networkEnabled: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* The calendar this engine computes dates with, from the engine's
|
|
284
|
+
* `calendar` option.
|
|
285
|
+
*
|
|
286
|
+
* One backend per engine, held here for the same reason the network
|
|
287
|
+
* switch is: the VM is where a date literal is stepped, a working-day
|
|
288
|
+
* walk runs and `now` is read, and every plugin function that touches a
|
|
289
|
+
* date reaches it through the execution context the VM builds from this
|
|
290
|
+
* one object. Defaults to Temporal where the runtime has it and `Date`
|
|
291
|
+
* where it does not. See `calendar/resolveCalendar.ts`.
|
|
292
|
+
*/
|
|
293
|
+
readonly calendar: CalendarBackend;
|
|
271
294
|
}
|
|
272
295
|
|
|
273
296
|
/**
|
|
@@ -705,4 +728,63 @@ declare class ScopeManager {
|
|
|
705
728
|
clear(): void;
|
|
706
729
|
}
|
|
707
730
|
|
|
708
|
-
|
|
731
|
+
/**
|
|
732
|
+
* Registry of built-in mathematical functions.
|
|
733
|
+
* Indexed by the number pushed as an operand of OpCode.CALL_BUILTIN.
|
|
734
|
+
*/
|
|
735
|
+
declare const builtinFunctions: Record<number, (args: Value[]) => Value>;
|
|
736
|
+
/**
|
|
737
|
+
* Registry of package-registered functions, indexed by the number pushed as an
|
|
738
|
+
* operand of `OpCode.CALL_PLUGIN`.
|
|
739
|
+
*
|
|
740
|
+
* Functions may return a promise. The orchestrator resolves it and re-executes
|
|
741
|
+
* rather than blocking the VM.
|
|
742
|
+
*
|
|
743
|
+
* Populated declaratively via {@link IEnginePackage.pluginFunctions} at
|
|
744
|
+
* package-registration time. Entries are cleared on unregister.
|
|
745
|
+
*
|
|
746
|
+
* @deprecated This is the {@link defaultEngineContext}'s map, kept as a
|
|
747
|
+
* module-level alias so existing callers keep working during the context
|
|
748
|
+
* migration. An engine registers into its own context, so writing here affects
|
|
749
|
+
* only code that has not been migrated. Take an {@link EngineContext} instead.
|
|
750
|
+
*/
|
|
751
|
+
declare const pluginFunctionRegistry: Record<number, PluginFunctionHandler>;
|
|
752
|
+
/**
|
|
753
|
+
* Allocate a unique index into {@link pluginFunctionRegistry} for a package's
|
|
754
|
+
* plugin function.
|
|
755
|
+
*
|
|
756
|
+
* Call once per function, typically at module scope, right where the
|
|
757
|
+
* function is defined, and store the result in a constant. Don't hardcode
|
|
758
|
+
* an index: two packages independently picking the same arbitrary number
|
|
759
|
+
* would silently overwrite each other's handler in the shared registry.
|
|
760
|
+
*
|
|
761
|
+
* @throws If the index pool is exhausted (up to 65536: two opcode-stream bytes
|
|
762
|
+
* via CALL_PLUGIN_WIDE, the first 256 via the one-byte CALL_PLUGIN).
|
|
763
|
+
*/
|
|
764
|
+
declare function allocatePluginFunctionIndex(): number;
|
|
765
|
+
/**
|
|
766
|
+
* The stable index for a package's named plugin function, allocated once per
|
|
767
|
+
* `${packageName}:${functionName}` and cached process-wide, so the same function
|
|
768
|
+
* always maps to the same {@link pluginFunctionRegistry} slot no matter which
|
|
769
|
+
* engine registers it or in what order: the property compiled bytecode, and so
|
|
770
|
+
* a snapshot, relies on.
|
|
771
|
+
*
|
|
772
|
+
* The engine calls this at {@link ExpressionEngine.registerPackage} time for each
|
|
773
|
+
* entry of a package's `pluginFunctions` record, so a package author names the
|
|
774
|
+
* function and never sees an index. {@link allocatePluginFunctionIndex} remains
|
|
775
|
+
* for a host that needs a raw index directly.
|
|
776
|
+
*/
|
|
777
|
+
declare function pluginFunctionIndexFor(qualifiedName: string): number;
|
|
778
|
+
/**
|
|
779
|
+
* A package-registered `as <name>` converter: the value on the left of `as`
|
|
780
|
+
* in, the converted value out.
|
|
781
|
+
*
|
|
782
|
+
* The optional `context` is the per-line execution context the VM passes to
|
|
783
|
+
* a plugin function, handed to a converter for the same reason: a converter
|
|
784
|
+
* that reads a date computes through the engine's calendar backend on it
|
|
785
|
+
* rather than a module-level default, so `<date> as weekday` and `weekday on
|
|
786
|
+
* <date>` cannot disagree. A converter that needs nothing from it ignores it.
|
|
787
|
+
*/
|
|
788
|
+
type AsConverter = (value: Value, context?: LineExecutionContext) => Value;
|
|
789
|
+
|
|
790
|
+
export { type AsConverter as A, type Bytecode as B, DependencyGraph as D, type ExpressionRecord as E, type LineExecutionContext as L, OpRegistry as O, type PluginFunctionHandler as P, ScopeManager as S, type VM as V, allocatePluginFunctionIndex as a, builtinFunctions as b, createVM as c, pluginFunctionRegistry as d, executeBytecode as e, type DagSnapshot as f, type EngineContext as g, pluginFunctionIndexFor as p, sharedOpRegistry as s };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as Value } from './Value-
|
|
2
|
-
import { V as VM } from './
|
|
1
|
+
import { V as Value } from './Value-BYHw-x7q.js';
|
|
2
|
+
import { V as VM } from './VMBuiltins-CZiZRKn-.js';
|
|
3
3
|
import { U as UserFunctionDef } from './BytecodeBuilder-DSWKZi4f.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as Value } from './Value-
|
|
2
|
-
import { V as VM } from './
|
|
1
|
+
import { V as Value } from './Value-BYHw-x7q.cjs';
|
|
2
|
+
import { V as VM } from './VMBuiltins-kv4rr0y5.cjs';
|
|
3
3
|
import { U as UserFunctionDef } from './BytecodeBuilder-DSWKZi4f.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -250,6 +250,23 @@ interface SplitData {
|
|
|
250
250
|
* switches on `kind` keeps working for the ones it already knows.
|
|
251
251
|
*/
|
|
252
252
|
type ChartKind = "sparkline" | "plot";
|
|
253
|
+
/**
|
|
254
|
+
* What a `Datetime`'s epoch-millisecond payload anchors.
|
|
255
|
+
*
|
|
256
|
+
* Three questions share one number and mean different things by it, which is
|
|
257
|
+
* why the distinction is recorded rather than inferred:
|
|
258
|
+
*
|
|
259
|
+
* - `date`: a calendar day, held as its local midnight (`2026-04-03`,
|
|
260
|
+
* `3 April 2026`, `03/04/2026`). The time of day carries no meaning.
|
|
261
|
+
* - `datetime`: a wall-clock reading on a day, in the calendar backend's own
|
|
262
|
+
* zone (`2026-04-03T09:30`, `6pm`). The reading is what was named; the
|
|
263
|
+
* instant follows from the zone it is read in.
|
|
264
|
+
* - `instant`: a fixed point on the timeline, named without depending on a
|
|
265
|
+
* zone (`2026-04-03T10:30:00Z`, `...+09:00`, `now`).
|
|
266
|
+
*
|
|
267
|
+
* See {@link Value.grain} for why the number cannot answer this on its own.
|
|
268
|
+
*/
|
|
269
|
+
type DatetimeGrain = "date" | "datetime" | "instant";
|
|
253
270
|
/**
|
|
254
271
|
* A chart specification: the DATA to draw, never pixels. One shape holds every
|
|
255
272
|
* visual the engine produces, `[1,2,3] as sparkline` and `plot sin(x) from 0 to
|
|
@@ -407,6 +424,45 @@ declare class Value {
|
|
|
407
424
|
* by {@link recycle} alongside the other sidecars.
|
|
408
425
|
*/
|
|
409
426
|
decimalPlaces?: number;
|
|
427
|
+
/**
|
|
428
|
+
* What this instant anchors: a calendar day, a wall-clock reading on one, or
|
|
429
|
+
* a fixed point on the timeline.
|
|
430
|
+
*
|
|
431
|
+
* The fifth sidecar, the same shape as {@link exact}, {@link rational},
|
|
432
|
+
* {@link uncertainty} and {@link decimalPlaces} and for the same reason: a
|
|
433
|
+
* `Datetime`'s payload is epoch milliseconds and has to stay a plain number,
|
|
434
|
+
* because the arena union, the worker DTO, the snapshot's Datetime variant
|
|
435
|
+
* and the `Datetime` SUB path all read it as one. The number cannot say
|
|
436
|
+
* which of three questions it is the answer to, and the difference is not
|
|
437
|
+
* recoverable from it: `formatDatetime` decides whether to print a time by
|
|
438
|
+
* testing whether the local hour, minute, second and millisecond are all
|
|
439
|
+
* zero, which is a guess that `2026-04-03T09:00:00+09:00` under `TZ=UTC`
|
|
440
|
+
* gets wrong, because the nine o'clock the reader typed IS UTC midnight.
|
|
441
|
+
*
|
|
442
|
+
* Set only where the shape is known: a date literal is `'date'`, a
|
|
443
|
+
* wall-clock literal (`2026-04-03T09:30`, `6pm`) is `'datetime'`, a literal
|
|
444
|
+
* carrying `Z` or an offset is `'instant'`, and so is `now`. Absent means
|
|
445
|
+
* not recorded, which every reader treats as an instant rather than
|
|
446
|
+
* inferring one. Nothing in 2.26.0 displays it: the formatter does not read
|
|
447
|
+
* it, so every rendered date is byte-identical to 2.25.0. Cleared by
|
|
448
|
+
* {@link recycle} alongside the other sidecars.
|
|
449
|
+
*/
|
|
450
|
+
grain?: DatetimeGrain;
|
|
451
|
+
/**
|
|
452
|
+
* The zone this instant should be read and displayed in, when the line
|
|
453
|
+
* named one.
|
|
454
|
+
*
|
|
455
|
+
* A zone reference in the encoding `calendar/IntlZone.ts` documents: an IANA
|
|
456
|
+
* name (`"Asia/Tokyo"`) or a fixed offset (`"UTCOFFSET:540"`). Set by
|
|
457
|
+
* `<datetime> in <zone>` and by an ISO literal carrying `Z` or an explicit
|
|
458
|
+
* offset, which names an offset rather than a zone and so records one.
|
|
459
|
+
* Absent means the value is read in the calendar backend's own zone, which
|
|
460
|
+
* is what every `Datetime` meant before this sidecar existed. Like
|
|
461
|
+
* {@link grain} it is recorded and readable in 2.26.0 and read by the
|
|
462
|
+
* formatter from 3.0. Cleared by {@link recycle} alongside the other
|
|
463
|
+
* sidecars.
|
|
464
|
+
*/
|
|
465
|
+
zone?: string;
|
|
410
466
|
constructor(type: ValueType, value: number | bigint | string | boolean | MatrixData | RangeData | ColourData | SplitData | ChartData | IpCidrData | SymbolicNode, unit?: string);
|
|
411
467
|
/**
|
|
412
468
|
* Phase 5.3: Reset all fields for arena reuse.
|
|
@@ -533,4 +589,4 @@ declare function colVectorValue(data: readonly number[]): Value;
|
|
|
533
589
|
/** Create a Range value, a first-class integer range `min:max`, both bounds inclusive. */
|
|
534
590
|
declare function rangeValue(min: number, max: number): Value;
|
|
535
591
|
|
|
536
|
-
export { type ColourData as C, type IpCidrData as I, type MatrixData as M, type RangeData as R, type SplitData as S, Value as V,
|
|
592
|
+
export { type ColourData as C, type DatetimeGrain as D, type IpCidrData as I, type MatrixData as M, type RangeData as R, type SplitData as S, Value as V, type MatrixEntry as a, ValueType as b, bigIntValue as c, colVectorValue as d, rowVectorValue as e, type ChartData as f, type SymbolicNode as g, hexValue as h, type ColourFormat as i, matrixValue as m, numberValue as n, rangeValue as r, stringValue as s, uomValue as u };
|
|
@@ -250,6 +250,23 @@ interface SplitData {
|
|
|
250
250
|
* switches on `kind` keeps working for the ones it already knows.
|
|
251
251
|
*/
|
|
252
252
|
type ChartKind = "sparkline" | "plot";
|
|
253
|
+
/**
|
|
254
|
+
* What a `Datetime`'s epoch-millisecond payload anchors.
|
|
255
|
+
*
|
|
256
|
+
* Three questions share one number and mean different things by it, which is
|
|
257
|
+
* why the distinction is recorded rather than inferred:
|
|
258
|
+
*
|
|
259
|
+
* - `date`: a calendar day, held as its local midnight (`2026-04-03`,
|
|
260
|
+
* `3 April 2026`, `03/04/2026`). The time of day carries no meaning.
|
|
261
|
+
* - `datetime`: a wall-clock reading on a day, in the calendar backend's own
|
|
262
|
+
* zone (`2026-04-03T09:30`, `6pm`). The reading is what was named; the
|
|
263
|
+
* instant follows from the zone it is read in.
|
|
264
|
+
* - `instant`: a fixed point on the timeline, named without depending on a
|
|
265
|
+
* zone (`2026-04-03T10:30:00Z`, `...+09:00`, `now`).
|
|
266
|
+
*
|
|
267
|
+
* See {@link Value.grain} for why the number cannot answer this on its own.
|
|
268
|
+
*/
|
|
269
|
+
type DatetimeGrain = "date" | "datetime" | "instant";
|
|
253
270
|
/**
|
|
254
271
|
* A chart specification: the DATA to draw, never pixels. One shape holds every
|
|
255
272
|
* visual the engine produces, `[1,2,3] as sparkline` and `plot sin(x) from 0 to
|
|
@@ -407,6 +424,45 @@ declare class Value {
|
|
|
407
424
|
* by {@link recycle} alongside the other sidecars.
|
|
408
425
|
*/
|
|
409
426
|
decimalPlaces?: number;
|
|
427
|
+
/**
|
|
428
|
+
* What this instant anchors: a calendar day, a wall-clock reading on one, or
|
|
429
|
+
* a fixed point on the timeline.
|
|
430
|
+
*
|
|
431
|
+
* The fifth sidecar, the same shape as {@link exact}, {@link rational},
|
|
432
|
+
* {@link uncertainty} and {@link decimalPlaces} and for the same reason: a
|
|
433
|
+
* `Datetime`'s payload is epoch milliseconds and has to stay a plain number,
|
|
434
|
+
* because the arena union, the worker DTO, the snapshot's Datetime variant
|
|
435
|
+
* and the `Datetime` SUB path all read it as one. The number cannot say
|
|
436
|
+
* which of three questions it is the answer to, and the difference is not
|
|
437
|
+
* recoverable from it: `formatDatetime` decides whether to print a time by
|
|
438
|
+
* testing whether the local hour, minute, second and millisecond are all
|
|
439
|
+
* zero, which is a guess that `2026-04-03T09:00:00+09:00` under `TZ=UTC`
|
|
440
|
+
* gets wrong, because the nine o'clock the reader typed IS UTC midnight.
|
|
441
|
+
*
|
|
442
|
+
* Set only where the shape is known: a date literal is `'date'`, a
|
|
443
|
+
* wall-clock literal (`2026-04-03T09:30`, `6pm`) is `'datetime'`, a literal
|
|
444
|
+
* carrying `Z` or an offset is `'instant'`, and so is `now`. Absent means
|
|
445
|
+
* not recorded, which every reader treats as an instant rather than
|
|
446
|
+
* inferring one. Nothing in 2.26.0 displays it: the formatter does not read
|
|
447
|
+
* it, so every rendered date is byte-identical to 2.25.0. Cleared by
|
|
448
|
+
* {@link recycle} alongside the other sidecars.
|
|
449
|
+
*/
|
|
450
|
+
grain?: DatetimeGrain;
|
|
451
|
+
/**
|
|
452
|
+
* The zone this instant should be read and displayed in, when the line
|
|
453
|
+
* named one.
|
|
454
|
+
*
|
|
455
|
+
* A zone reference in the encoding `calendar/IntlZone.ts` documents: an IANA
|
|
456
|
+
* name (`"Asia/Tokyo"`) or a fixed offset (`"UTCOFFSET:540"`). Set by
|
|
457
|
+
* `<datetime> in <zone>` and by an ISO literal carrying `Z` or an explicit
|
|
458
|
+
* offset, which names an offset rather than a zone and so records one.
|
|
459
|
+
* Absent means the value is read in the calendar backend's own zone, which
|
|
460
|
+
* is what every `Datetime` meant before this sidecar existed. Like
|
|
461
|
+
* {@link grain} it is recorded and readable in 2.26.0 and read by the
|
|
462
|
+
* formatter from 3.0. Cleared by {@link recycle} alongside the other
|
|
463
|
+
* sidecars.
|
|
464
|
+
*/
|
|
465
|
+
zone?: string;
|
|
410
466
|
constructor(type: ValueType, value: number | bigint | string | boolean | MatrixData | RangeData | ColourData | SplitData | ChartData | IpCidrData | SymbolicNode, unit?: string);
|
|
411
467
|
/**
|
|
412
468
|
* Phase 5.3: Reset all fields for arena reuse.
|
|
@@ -533,4 +589,4 @@ declare function colVectorValue(data: readonly number[]): Value;
|
|
|
533
589
|
/** Create a Range value, a first-class integer range `min:max`, both bounds inclusive. */
|
|
534
590
|
declare function rangeValue(min: number, max: number): Value;
|
|
535
591
|
|
|
536
|
-
export { type ColourData as C, type IpCidrData as I, type MatrixData as M, type RangeData as R, type SplitData as S, Value as V,
|
|
592
|
+
export { type ColourData as C, type DatetimeGrain as D, type IpCidrData as I, type MatrixData as M, type RangeData as R, type SplitData as S, Value as V, type MatrixEntry as a, ValueType as b, bigIntValue as c, colVectorValue as d, rowVectorValue as e, type ChartData as f, type SymbolicNode as g, hexValue as h, type ColourFormat as i, matrixValue as m, numberValue as n, rangeValue as r, stringValue as s, uomValue as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as ErrorCategory, S as SourceSpan, E as EngineError } from './EngineError-
|
|
1
|
+
import { c as ErrorCategory, S as SourceSpan, E as EngineError } from './EngineError-C-kBwYlN.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Structured errors for the off-main-thread worker harness, and the pair of
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as ErrorCategory, S as SourceSpan, E as EngineError } from './EngineError-
|
|
1
|
+
import { c as ErrorCategory, S as SourceSpan, E as EngineError } from './EngineError-C-kBwYlN.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Structured errors for the off-main-thread worker harness, and the pair of
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkHG4NPDN5_cjs=require('./chunk-HG4NPDN5.cjs'),chunkZDJTDFTR_cjs=require('./chunk-ZDJTDFTR.cjs'),chunkTPPM4QSS_cjs=require('./chunk-TPPM4QSS.cjs'),chunkYBQOQTVL_cjs=require('./chunk-YBQOQTVL.cjs'),chunkS3DFU33X_cjs=require('./chunk-S3DFU33X.cjs'),chunkGXO7TSXQ_cjs=require('./chunk-GXO7TSXQ.cjs');var D=/^\d{1,3}(\.\d{3}){2,}$/,T=/^\d*\.\d*$/,n=class n{constructor(e,t=50,r="en",l,a=chunkTPPM4QSS_cjs.b){this.tokens=[];this.current=0;this.depth=0;this.currentExpression="";this.infixMinBindingPower=0;this.registry=e,this.maxDepth=t,this.localeCode=r;let p=chunkS3DFU33X_cjs.a(r).display;this.decimalSeparator=p.decimalSeparator,this.thousandsSeparator=p.thousandsSeparator,this.pluginFunctionIndex=l,this.calendar=a;}getLocaleCode(){return this.localeCode}getCalendar(){return this.calendar}setDiagnosticPipeline(e,t){this.diagnosticPipeline=e,this.currentExpression=t??"";}load(e,t){if(t===false){this.tokens=e,this.current=0,this.depth=0;return}let r=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.LPAREN),l=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.RPAREN),a=0;for(let p=0;p<e.length;p++)e[p].typeId===r?a++:e[p].typeId===l&&a--;this.tokens=a===0?e:this.balanceParens(e,a),this.current=0,this.depth=0;}balanceParens(e,t){let r=e.slice();if(t>0){let l=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.RPAREN);for(let a=0;a<t;a++){let p=e[e.length-1];r.push({type:chunkYBQOQTVL_cjs.a.RPAREN,typeId:l,value:")",text:")",offset:p?p.offset+p.text.length:0,lineBreaks:0,line:p?p.line:1,col:p?p.col+p.text.length:1});}}else if(t<0){let l=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.LPAREN);for(let a=0;a<-t;a++)r.unshift({type:chunkYBQOQTVL_cjs.a.LPAREN,typeId:l,value:"(",text:"(",offset:0,lineBreaks:0,line:1,col:1});}return r}parseExpression(e=0,t){let r=this.builder;t&&(this.builder=t),this.depth++;try{if(this.depth>this.maxDepth)throw chunkGXO7TSXQ_cjs.c.parsing("NESTING_DEPTH_EXCEEDED",`Parse nesting depth ${this.depth} exceeds maximum of ${this.maxDepth}`,{maxDepth:this.maxDepth,currentDepth:this.depth});this.parseExpressionBody(e);}finally{this.depth--,t&&(this.builder=r);}}parseExpressionBody(e){let t=this.consume();if(!t)throw chunkGXO7TSXQ_cjs.c.parsing({code:"UNEXPECTED_END",message:"Unexpected end of expression",span:this.spanAtEnd()});this.parsePrefix(t);let r=this.tokens,l=r.length,a=n.BP_TABLE,p=this.registry,o=this.builder,h=this.current;for(;h<l;){let d=r[h];if(!d)break;let c=a[d.typeId];if(c>0){if(c<=e)break;if(this.diagnosticPipeline){let I=p.getInfix(d.typeId);I&&this.fireParseletMatched(I,d,false,c);}this.current=++h;let f=d.typeId;if(f===n.PERCENT_ID)o.emitOpcode(10),o.emitNumber(100),o.emitOpcode(23),o.emitOpcode(74);else if(!(f===n.CARET_ID&&this.tryEmitMatrixCaretOp(o))){let I=f===n.CARET_ID?c-1:c+1;this.parseExpression(I,o),o.emitOpcode(n.INFIX_OPCODE[f]);}}else {let f=p.getInfix(d.typeId);if(!f||f.bindingPower<=e)break;this.current=++h,this.diagnosticPipeline&&this.fireParseletMatched(f,d,false,f.bindingPower);let I=this.infixMinBindingPower;this.infixMinBindingPower=e;try{f.parse(this,t,d,o);}finally{this.infixMinBindingPower=I;}}h=this.current;}this.current=h;}parsePrefix(e){let t=this.builder,r=e.typeId;if(this.diagnosticPipeline){let a=this.registry.getPrefix(r);a&&this.fireParseletMatched(a,e,true);}switch(r){case n.NUMBER_ID:{let a,p=null,o=e.value;if(this.decimalSeparator==="."){let h=0,d=o.length>0;for(let c=0;c<o.length;c++){let f=o.charCodeAt(c);if(!(f>=48&&f<=57)){if(f===46&&h===0){h=1;continue}d=false;break}}if(d){if(h===1){t.emitOpcode(16),t.emitString(o);return}t.emitOpcode(10),t.emitNumber(+o);return}}if(o.startsWith("0x")||o.startsWith("0X")){if(a=parseInt(o,16),Number.isNaN(a))throw chunkGXO7TSXQ_cjs.c.parsing({code:"INVALID_NUMBER_LITERAL",message:`Invalid hex literal: "${o}"`,context:{raw:o},span:this.spanOf(e)})}else if(o.startsWith("0b")||o.startsWith("0B")){if(a=parseInt(o.slice(2),2),Number.isNaN(a))throw chunkGXO7TSXQ_cjs.c.parsing({code:"INVALID_NUMBER_LITERAL",message:`Invalid binary literal: "${o}"`,context:{raw:o},span:this.spanOf(e)})}else if(o.startsWith("0o")||o.startsWith("0O")){if(a=parseInt(o.slice(2),8),Number.isNaN(a))throw chunkGXO7TSXQ_cjs.c.parsing({code:"INVALID_NUMBER_LITERAL",message:`Invalid octal literal: "${o}"`,context:{raw:o},span:this.spanOf(e)})}else if(D.test(o))a=parseFloat(o.split(".").join(""));else {let h=this.decimalSeparator,d=this.thousandsSeparator,c=o;d&&c.indexOf(d)!==-1&&(c=c.split(d).join("")),h&&h!=="."&&(c=c.replace(h,".")),a=parseFloat(c),T.test(c)&&(p=c);}if(p!==null){t.emitOpcode(16),t.emitString(p);return}t.emitOpcode(10),t.emitNumber(a);return}case n.BIGINT_ID:{t.emitOpcode(11),t.emitString(chunkZDJTDFTR_cjs.e(e.value,this.localeCode));return}case n.STRING_ID:{t.emitOpcode(13),t.emitString(e.value);return}case n.IDENT_ID:{if(this.peek()?.typeId===n.LPAREN_ID){this.parseUserFunctionDefOrCall(e,t);return}t.emitOpcode(60),t.emitString(e.value);return}case n.LPAREN_ID:{this.parseExpression(0,t);let a=1;for(;this.match(chunkYBQOQTVL_cjs.a.COMMA);)this.parseExpression(0,t),a++;this.consume(chunkYBQOQTVL_cjs.a.RPAREN),a>1&&(t.emitOpcode(152),t.emitIndex(1),t.emitIndex(a));return}case n.MINUS_ID:{this.parseExpression(chunkZDJTDFTR_cjs.a.Prefix,t),t.emitOpcode(26);return}case n.PLUS_ID:{this.parseExpression(chunkZDJTDFTR_cjs.a.Prefix,t),t.emitOpcode(27);return}case n.KEYWORD_ID:}let l=this.registry.getPrefix(r);if(!l)throw chunkGXO7TSXQ_cjs.c.parsing({code:"NO_PREFIX_PARSELET",message:`No prefix parselet found for token: ${e.type} ("${e.value}")`,context:{tokenType:e.type,tokenValue:e.value},span:this.spanOf(e)});l.parse(this,e,t);}tryEmitMatrixCaretOp(e){for(let t of n.CARET_SUFFIX_RULES)if(t.matches(this))return t.emit(this,e),true;return false}findMatchingRParen(e){let t=0;for(let r=e;r<this.tokens.length;r++){let l=this.tokens[r];if(l.typeId===n.LPAREN_ID)t++;else if(l.typeId===n.RPAREN_ID&&(t--,t===0))return r}return null}parseUserFunctionDefOrCall(e,t){let r=this.findMatchingRParen(this.current);if(r===null){t.emitOpcode(60),t.emitString(e.value);return}this.tokens[r+1]?.type===chunkYBQOQTVL_cjs.a.EQUALS?this.parseUserFunctionDefinition(e,t):this.parseUserFunctionCall(e,t);}consumeParamName(){let e=this.peek();if(e?.type===chunkYBQOQTVL_cjs.a.IDENT||e?.type===chunkYBQOQTVL_cjs.a.UNIT)return this.consume(),e.value;throw chunkGXO7TSXQ_cjs.c.parsing({code:"USER_FUNCTION_INVALID_PARAM_NAME",message:`Expected a parameter name but got "${e?.type??"end of input"}"${e?` ("${e.value}")`:""}`,context:{actualType:e?.type},span:e?this.spanOf(e):this.spanAtEnd()})}parseUserFunctionDefinition(e,t){this.consume(chunkYBQOQTVL_cjs.a.LPAREN);let r=[];if(this.peek()?.type!==chunkYBQOQTVL_cjs.a.RPAREN)for(r.push(this.consumeParamName());this.match(chunkYBQOQTVL_cjs.a.COMMA);)r.push(this.consumeParamName());if(this.consume(chunkYBQOQTVL_cjs.a.RPAREN),this.consume(chunkYBQOQTVL_cjs.a.EQUALS),r.length===0)throw chunkGXO7TSXQ_cjs.c.parsing({code:"USER_FUNCTION_NO_PARAMS",message:`"${e.value}()" has no parameters -- user-defined functions need at least one (a zero-argument definition is indistinguishable from a plain function CALL with no args, which this grammar doesn't otherwise support)`,context:{name:e.value},span:this.spanOf(e)});let l=new chunkZDJTDFTR_cjs.d(this.pluginFunctionIndex);this.parseExpression(chunkZDJTDFTR_cjs.a.Lowest,l),this.setBuilder(t);let a=l.build();if(a.hasAsync)throw chunkGXO7TSXQ_cjs.c.parsing({code:"FUNCTION_BODY_MUST_BE_SYNCHRONOUS",message:`"${e.value}(...)"'s body calls an async operation (weather, stocks, currency, ...) \u2014 user-defined function bodies must be synchronous`,context:{name:e.value},span:this.spanOf(e)});let p=t.emitUserFunctionBody(e.value,r,a);t.emitOpcode(150),t.emitIndex(p),t.emitOpcode(13),t.emitString(`${e.value}(${r.join(", ")}) defined`);}parseUserFunctionCall(e,t){this.consume(chunkYBQOQTVL_cjs.a.LPAREN);let r=0;if(this.peek()?.type!==chunkYBQOQTVL_cjs.a.RPAREN)for(this.parseExpression(chunkZDJTDFTR_cjs.a.Lowest,t),r++;this.match(chunkYBQOQTVL_cjs.a.COMMA);)this.parseExpression(chunkZDJTDFTR_cjs.a.Lowest,t),r++;this.consume(chunkYBQOQTVL_cjs.a.RPAREN),t.emitOpcode(151),t.emitString(e.value),t.emitByte(r);}spanOf(e){return {start:e.offset,end:e.sourceEnd??e.offset+e.text.length,line:e.line,col:e.col}}spanAtEnd(){let e=this.tokens[this.tokens.length-1];if(!e)return {start:0,end:0};let t=e.sourceEnd??e.offset+e.text.length;return {start:t,end:t,line:e.line,col:e.col+(t-e.offset)}}consume(e){let t=this.tokens[this.current];if(!t)throw chunkGXO7TSXQ_cjs.c.parsing({code:"UNEXPECTED_END_OF_INPUT",message:"Unexpected end of input",span:this.spanAtEnd()});if(e!==void 0){let r=chunkYBQOQTVL_cjs.c(e);if(t.typeId!==r)throw chunkGXO7TSXQ_cjs.c.parsing({code:"UNEXPECTED_TOKEN_TYPE",message:`Expected token type "${e}" but got "${t.type}" ("${t.value}")`,context:{expectedType:e,actualType:t.type,actualValue:t.value},span:this.spanOf(t)})}return this.current++,t}match(e){let t=this.peek();return t&&t.typeId===chunkYBQOQTVL_cjs.c(e)?(this.advance(),true):false}peek(){return this.tokens[this.current]}peekAt(e){return this.tokens[this.current+e]}previous(){return this.current>0?this.tokens[this.current-1]:void 0}advance(){this.current++;}setBuilder(e){this.builder=e;}fireParseletMatched(e,t,r,l){let a=this.diagnosticPipeline,p={type:chunkHG4NPDN5_cjs.c.ParseletMatched,elapsedNs:0,expression:this.currentExpression,tokenType:t.type,tokenValue:t.value,parseletCategory:e.category,parseletType:e.constructor?.name??"unknown",isPrefix:r,bindingPower:l,tokenOffset:t.offset||0};a.fireParseletMatched(p);}};n.BP_TABLE=chunkZDJTDFTR_cjs.b(),n.NUMBER_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.NUMBER),n.BIGINT_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.BIGINT),n.STRING_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.STRING),n.IDENT_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.IDENT),n.LPAREN_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.LPAREN),n.RPAREN_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.RPAREN),n.MINUS_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.MINUS),n.PLUS_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.PLUS),n.KEYWORD_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.KEYWORD),n.STAR_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.STAR),n.SLASH_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.SLASH),n.MOD_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.MOD),n.CARET_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.CARET),n.LSHIFT_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.LSHIFT),n.RSHIFT_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.RSHIFT),n.URSHIFT_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.URSHIFT),n.BIT_AND_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.BIT_AND),n.BIT_OR_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.BIT_OR),n.BIT_XOR_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.BIT_XOR),n.PERCENT_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.PERCENT),n.OF_ID=chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.OF),n.INFIX_OPCODE={[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.PLUS)]:20,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.MINUS)]:21,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.STAR)]:22,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.SLASH)]:23,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.MOD)]:24,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.CARET)]:25,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.LSHIFT)]:30,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.RSHIFT)]:31,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.URSHIFT)]:32,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.BIT_AND)]:33,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.BIT_OR)]:34,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.BIT_XOR)]:35,[chunkYBQOQTVL_cjs.c(chunkYBQOQTVL_cjs.a.OF)]:22},n.CARET_SUFFIX_RULES=[{name:"transpose (^T)",matches:e=>{let t=e.peek();return t?.type===chunkYBQOQTVL_cjs.a.IDENT&&t.value==="T"},emit:(e,t)=>{e.advance(),t.emitOpcode(51),t.emitIndex(63),t.emitIndex(1);}},{name:"inverse (^-1)",matches:e=>{if(e.peek()?.typeId!==n.MINUS_ID)return false;let r=e.peekAt(1);return r?.type===chunkYBQOQTVL_cjs.a.NUMBER&&r.value==="1"},emit:(e,t)=>{e.advance(),e.advance(),t.emitOpcode(51),t.emitIndex(65),t.emitIndex(1);}}];var v=n;var m=class{constructor(){this.prefixParselets=new Map;this.infixParselets=new Map;this.prefixById=new Map;this.infixById=new Map;}registerPrefix(e,t){let r=this.prefixParselets.get(e);r&&r!==t&&console.warn(`[ParseletRegistry] Prefix parselet for token "${e}" is already registered (category: "${r.category??"unknown"}"). Overwriting with a new parselet (category: "${t.category??"unknown"}") \u2014 the previous parselet is now unreachable. Two packages may be claiming the same token type.`),this.prefixParselets.set(e,t),this.prefixById.set(chunkYBQOQTVL_cjs.c(e),t);}registerInfix(e,t){let r=this.infixParselets.get(e);r&&r!==t&&console.warn(`[ParseletRegistry] Infix parselet for token "${e}" is already registered (category: "${r.category??"unknown"}"). Overwriting with a new parselet (category: "${t.category??"unknown"}") \u2014 the previous parselet is now unreachable. Two packages may be claiming the same token type.`),this.infixParselets.set(e,t),this.infixById.set(chunkYBQOQTVL_cjs.c(e),t);}getAllPrefix(){let e=[];for(let[t,r]of this.prefixParselets)e.push({tokenType:t,bindingPower:r.bindingPower??chunkZDJTDFTR_cjs.a.Prefix,category:r.category});return e}getAllInfix(){let e=[];for(let[t,r]of this.infixParselets){let l=r.bindingPower??0;e.push({tokenType:t,leftBindingPower:l,rightBindingPower:l+1,category:r.category});}return e}get prefixCount(){return this.prefixParselets.size}get infixCount(){return this.infixParselets.size}getPrefix(e){return typeof e=="number"?this.prefixById.get(e):this.prefixParselets.get(e)}getInfix(e){return typeof e=="number"?this.infixById.get(e):this.infixParselets.get(e)}hasPrefix(e){return this.prefixParselets.has(e)}hasInfix(e){return this.infixParselets.has(e)}clear(){this.prefixParselets.clear(),this.infixParselets.clear(),this.prefixById.clear(),this.infixById.clear();}},$=new m;exports.a=v;exports.b=m;exports.c=$;//# sourceMappingURL=chunk-2SYYKQ4Q.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-2SYYKQ4Q.cjs.map
|