solve-engine 2.38.20 → 2.38.22
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/{PackageCompatibility-ZCZVGHws.d.ts → PackageCompatibility-C7ILySsH.d.ts} +1 -1
- package/dist/{PackageCompatibility-Bv42nEm2.d.cts → PackageCompatibility-CzDzOIg9.d.cts} +1 -1
- package/dist/{PackageRegistry-7dFbaAZp.d.cts → PackageRegistry-Bd8ErpwZ.d.cts} +78 -1
- package/dist/{PackageRegistry-B6s8LGCu.d.ts → PackageRegistry-D7_B0mxv.d.ts} +78 -1
- package/dist/{VMBuiltins-0C4z3yDS.d.cts → VMBuiltins-Baa90D2v.d.cts} +232 -1
- package/dist/{VMBuiltins-Bu6qaKi0.d.ts → VMBuiltins-BqkoJtHt.d.ts} +232 -1
- package/dist/chunk-54QMY2VL.cjs +2 -0
- package/dist/chunk-54QMY2VL.cjs.map +1 -0
- package/dist/{chunk-UOLCBH37.cjs → chunk-5GJUECKG.cjs} +5 -5
- package/dist/chunk-5GJUECKG.cjs.map +1 -0
- package/dist/chunk-CR7IHPA2.cjs +2 -0
- package/dist/chunk-CR7IHPA2.cjs.map +1 -0
- package/dist/{chunk-I4PKEUMZ.cjs → chunk-FJBWZW45.cjs} +2 -2
- package/dist/{chunk-I4PKEUMZ.cjs.map → chunk-FJBWZW45.cjs.map} +1 -1
- package/dist/chunk-NYJTBXSI.js +3 -0
- package/dist/chunk-NYJTBXSI.js.map +1 -0
- package/dist/{chunk-H4G3UXJV.js → chunk-NZUFFOB3.js} +3 -3
- package/dist/chunk-NZUFFOB3.js.map +1 -0
- package/dist/chunk-OBQC7KDY.cjs +2 -0
- package/dist/chunk-OBQC7KDY.cjs.map +1 -0
- package/dist/{chunk-3JSXJSMT.js → chunk-OC65AGRR.js} +2 -2
- package/dist/{chunk-3JSXJSMT.js.map → chunk-OC65AGRR.js.map} +1 -1
- package/dist/{chunk-EPLOL7WC.cjs → chunk-OQHRKHP7.cjs} +2 -2
- package/dist/{chunk-EPLOL7WC.cjs.map → chunk-OQHRKHP7.cjs.map} +1 -1
- package/dist/chunk-QP4VIEXZ.js +2 -0
- package/dist/chunk-QP4VIEXZ.js.map +1 -0
- package/dist/chunk-RAZ6IYUQ.js +5 -0
- package/dist/chunk-RAZ6IYUQ.js.map +1 -0
- package/dist/chunk-RMBUP4XA.js +2 -0
- package/dist/chunk-RMBUP4XA.js.map +1 -0
- package/dist/{chunk-BHHTXIUL.js → chunk-TVM5VYCM.js} +2 -2
- package/dist/{chunk-BHHTXIUL.js.map → chunk-TVM5VYCM.js.map} +1 -1
- package/dist/chunk-VNNRAHDE.cjs +3 -0
- package/dist/chunk-VNNRAHDE.cjs.map +1 -0
- package/dist/chunk-X2QJE3SV.js +2 -0
- package/dist/chunk-X2QJE3SV.js.map +1 -0
- package/dist/{chunk-7PUNL5CJ.cjs → chunk-ZJJ54J4L.cjs} +3 -3
- package/dist/{chunk-H4G3UXJV.js.map → chunk-ZJJ54J4L.cjs.map} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +128 -5
- package/dist/engine.d.ts +128 -5
- package/dist/engine.js +1 -1
- package/dist/engine.worker.cjs +1 -1
- package/dist/engine.worker.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/language.d.cts +3 -3
- package/dist/language.d.ts +3 -3
- package/dist/packages.cjs +1 -1
- package/dist/packages.d.cts +2 -2
- package/dist/packages.d.ts +2 -2
- package/dist/packages.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +3 -3
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.d.cts +1 -1
- package/dist/vm.d.ts +1 -1
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.d.cts +2 -2
- package/dist/worker.d.ts +2 -2
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2YHOWQ43.js +0 -2
- package/dist/chunk-2YHOWQ43.js.map +0 -1
- package/dist/chunk-6W3JFXPQ.cjs +0 -2
- package/dist/chunk-6W3JFXPQ.cjs.map +0 -1
- package/dist/chunk-7PUNL5CJ.cjs.map +0 -1
- package/dist/chunk-HNXV35Q2.cjs +0 -2
- package/dist/chunk-HNXV35Q2.cjs.map +0 -1
- package/dist/chunk-JZQRUOO6.js +0 -2
- package/dist/chunk-JZQRUOO6.js.map +0 -1
- package/dist/chunk-K2OUNZZG.cjs +0 -2
- package/dist/chunk-K2OUNZZG.cjs.map +0 -1
- package/dist/chunk-KZPA4DUF.cjs +0 -3
- package/dist/chunk-KZPA4DUF.cjs.map +0 -1
- package/dist/chunk-MXMMDSX4.js +0 -3
- package/dist/chunk-MXMMDSX4.js.map +0 -1
- package/dist/chunk-RTEWTZ6I.js +0 -5
- package/dist/chunk-RTEWTZ6I.js.map +0 -1
- package/dist/chunk-SIUHB77U.js +0 -2
- package/dist/chunk-SIUHB77U.js.map +0 -1
- package/dist/chunk-UOLCBH37.cjs.map +0 -1
package/dist/constants.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkFJBWZW45_cjs=require('./chunk-FJBWZW45.cjs');require('./chunk-6SYU4MH7.cjs');Object.defineProperty(exports,"ConfigManager",{enumerable:true,get:function(){return chunkFJBWZW45_cjs.d}});Object.defineProperty(exports,"DEFAULT_CONFIG",{enumerable:true,get:function(){return chunkFJBWZW45_cjs.b}});Object.defineProperty(exports,"ENGINE_VERSION",{enumerable:true,get:function(){return chunkFJBWZW45_cjs.a}});//# sourceMappingURL=constants.cjs.map
|
|
2
2
|
//# sourceMappingURL=constants.cjs.map
|
package/dist/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{d as ConfigManager,b as DEFAULT_CONFIG,a as ENGINE_VERSION}from'./chunk-
|
|
1
|
+
export{d as ConfigManager,b as DEFAULT_CONFIG,a as ENGINE_VERSION}from'./chunk-TVM5VYCM.js';import'./chunk-6G2NES2I.js';//# sourceMappingURL=constants.js.map
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
package/dist/engine.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkVNNRAHDE_cjs=require('./chunk-VNNRAHDE.cjs');require('./chunk-EFJCC6FJ.cjs');var chunk5GJUECKG_cjs=require('./chunk-5GJUECKG.cjs');require('./chunk-P5YWBIIU.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-R3W53ZMP.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-CR7IHPA2.cjs'),require('./chunk-OBQC7KDY.cjs'),require('./chunk-HG4NPDN5.cjs'),require('./chunk-EZ7R3ZHM.cjs'),require('./chunk-W4XLVZ6R.cjs'),require('./chunk-OQHRKHP7.cjs'),require('./chunk-K3PZ66XR.cjs'),require('./chunk-YV4GDW5A.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-GDLYXRMA.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-54QMY2VL.cjs'),require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-Z4MIX43O.cjs');var chunkEQNKDTMX_cjs=require('./chunk-EQNKDTMX.cjs');require('./chunk-E4HAKNBQ.cjs'),require('./chunk-NH74IT7B.cjs'),require('./chunk-PHWIO4P3.cjs'),require('./chunk-FJBWZW45.cjs'),require('./chunk-3MG7VIPL.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-72J5V7SN.cjs'),require('./chunk-YBQOQTVL.cjs'),require('./chunk-S3DFU33X.cjs'),require('./chunk-J4LSAHCY.cjs'),require('./chunk-EZKR44MA.cjs'),require('./chunk-6SYU4MH7.cjs');Object.defineProperty(exports,"DocumentModel",{enumerable:true,get:function(){return chunkVNNRAHDE_cjs.a}});Object.defineProperty(exports,"EvalTier",{enumerable:true,get:function(){return chunkVNNRAHDE_cjs.b}});Object.defineProperty(exports,"ThreeTierEvaluator",{enumerable:true,get:function(){return chunkVNNRAHDE_cjs.c}});Object.defineProperty(exports,"evaluateDocument",{enumerable:true,get:function(){return chunkVNNRAHDE_cjs.d}});Object.defineProperty(exports,"AsyncResolutionBatcher",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.i}});Object.defineProperty(exports,"ExpressionEngine",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.o}});Object.defineProperty(exports,"SNAPSHOT_FORMAT",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.d}});Object.defineProperty(exports,"SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.e}});Object.defineProperty(exports,"SnapshotErrorCodes",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.f}});Object.defineProperty(exports,"checkExpressionComplexity",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.k}});Object.defineProperty(exports,"checkExpressionLength",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.j}});Object.defineProperty(exports,"extractReadsAndWrites",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.l}});Object.defineProperty(exports,"findInlineSolvesInLine",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.n}});Object.defineProperty(exports,"isEmptyLine",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.m}});Object.defineProperty(exports,"setEngineWorkerFactory",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.g}});Object.defineProperty(exports,"DATE_CALENDAR",{enumerable:true,get:function(){return chunkEQNKDTMX_cjs.b}});Object.defineProperty(exports,"DateCalendar",{enumerable:true,get:function(){return chunkEQNKDTMX_cjs.a}});Object.defineProperty(exports,"calendarOf",{enumerable:true,get:function(){return chunkEQNKDTMX_cjs.c}});Object.defineProperty(exports,"dateCalendarInZone",{enumerable:true,get:function(){return chunkEQNKDTMX_cjs.d}});//# sourceMappingURL=engine.cjs.map
|
|
2
2
|
//# sourceMappingURL=engine.cjs.map
|
package/dist/engine.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as DocumentModel, E as ExpressionEngine, V as ViewportRange, u as LineChange, U as UnifiedParsingOptions, P as ParsingResult, v as InlineSolvePosition } from './PackageRegistry-
|
|
2
|
-
export { A as ApplyChangesResult, w as AsyncCachePackageInfo, x as AsyncErrorEvent, y as AsyncResolutionBatcher, z as AsyncResolutionEvent, B as BatcherMetrics, F as BytecodeCacheEntry, G as CacheSnapshot, H as CheckpointSnapshot, D as DateOrderSource, b as DateReading, c as DateReadingPolicy, a as EngineOptions, d as EngineRestoreOptions, e as EngineSnapshot, f as Explanation, g as ExplanationStep, J as LineCacheEntryInfo, K as LineState, M as LinesUpdatedEvent, N as ParsedLine, R as ResolvedDateOrder, S as SNAPSHOT_FORMAT, h as SNAPSHOT_VERSION, i as SerializedAnonymousBody, j as SerializedBytecode, k as SerializedDecimal, l as SerializedLineCacheEntry, m as SerializedNumber, n as SerializedRational, o as SerializedUserFunction, p as SerializedValue, q as SnapshotErrorCodes } from './PackageRegistry-
|
|
1
|
+
import { t as DocumentModel, E as ExpressionEngine, V as ViewportRange, u as LineChange, U as UnifiedParsingOptions, P as ParsingResult, v as InlineSolvePosition } from './PackageRegistry-Bd8ErpwZ.cjs';
|
|
2
|
+
export { A as ApplyChangesResult, w as AsyncCachePackageInfo, x as AsyncErrorEvent, y as AsyncResolutionBatcher, z as AsyncResolutionEvent, B as BatcherMetrics, F as BytecodeCacheEntry, G as CacheSnapshot, H as CheckpointSnapshot, D as DateOrderSource, b as DateReading, c as DateReadingPolicy, a as EngineOptions, d as EngineRestoreOptions, e as EngineSnapshot, f as Explanation, g as ExplanationStep, J as LineCacheEntryInfo, K as LineState, M as LinesUpdatedEvent, N as ParsedLine, R as ResolvedDateOrder, S as SNAPSHOT_FORMAT, h as SNAPSHOT_VERSION, i as SerializedAnonymousBody, j as SerializedBytecode, k as SerializedDecimal, l as SerializedLineCacheEntry, m as SerializedNumber, n as SerializedRational, o as SerializedUserFunction, p as SerializedValue, q as SnapshotErrorCodes } from './PackageRegistry-Bd8ErpwZ.cjs';
|
|
3
3
|
export { C as CalendarBackend, a as CalendarFields, Z as ZonedFields } from './CalendarBackend-MdS3Bb4P.cjs';
|
|
4
4
|
export { D as DATE_CALENDAR, a as DateCalendar, E as EngineWorkerFactory, c as calendarOf, d as dateCalendarInZone, s as setEngineWorkerFactory } from './DateCalendar-GFQDX1ng.cjs';
|
|
5
5
|
import { V as Value } from './Value-B55Hvn3e.cjs';
|
|
6
|
-
import { b as VMCheckpointer } from './VMBuiltins-
|
|
7
|
-
export { h as DagSnapshot } from './VMBuiltins-
|
|
6
|
+
import { b as VMCheckpointer } from './VMBuiltins-Baa90D2v.cjs';
|
|
7
|
+
export { h as DagSnapshot } from './VMBuiltins-Baa90D2v.cjs';
|
|
8
8
|
import { T as Token } from './Token-D8f7yaz1.cjs';
|
|
9
9
|
import { E as EngineError } from './EngineError-Bm4OYmw8.cjs';
|
|
10
10
|
import { a as BytecodeProgram } from './BytecodeBuilder-DSWKZi4f.cjs';
|
|
@@ -205,6 +205,37 @@ declare class ThreeTierEvaluator {
|
|
|
205
205
|
private checkpointer;
|
|
206
206
|
private compilationWorker;
|
|
207
207
|
private pageManager;
|
|
208
|
+
/**
|
|
209
|
+
* The text hash each line had when the graph last recorded what it reads,
|
|
210
|
+
* by line id.
|
|
211
|
+
*
|
|
212
|
+
* A positional edge is recorded at run time and pinned, so it outlives the
|
|
213
|
+
* text that produced it until the line runs again. Between an edit and
|
|
214
|
+
* that run the graph still describes the old text, and a line edited out
|
|
215
|
+
* of the viewport is compiled there without running, so the window can be
|
|
216
|
+
* as long as the reader likes. The document model records the edit as a
|
|
217
|
+
* new hash, and this is the hash the graph's edges for the line describe:
|
|
218
|
+
* a line arriving at the pass with a different one has its positions
|
|
219
|
+
* forgotten before anything else happens to it. See
|
|
220
|
+
* {@link forgetPositionsOfEditedText}.
|
|
221
|
+
*/
|
|
222
|
+
private textHashOfRecordedEdges;
|
|
223
|
+
/**
|
|
224
|
+
* The names each line genuinely reads among those it writes, by line id.
|
|
225
|
+
*
|
|
226
|
+
* `:v3 = v3 + 3` reads `v3` on its right-hand side; `:v3 = 44` does not,
|
|
227
|
+
* although the graph records both as readers of `v3` by convention. The
|
|
228
|
+
* difference is visible only in the per-expression extraction, where the
|
|
229
|
+
* name appears twice, and only while Tier 1 has that in hand; the stored
|
|
230
|
+
* read set is deduplicated. Recorded there, read by Tier 2, which puts such
|
|
231
|
+
* a name back to the prefix before the line runs. Keyed by id so a
|
|
232
|
+
* structural edit does not lose it.
|
|
233
|
+
*/
|
|
234
|
+
private selfReadingWrites;
|
|
235
|
+
/**
|
|
236
|
+
* The lines that sit on a cycle, by line id. See {@link settleCycles}.
|
|
237
|
+
*/
|
|
238
|
+
private cycleMemberIds;
|
|
208
239
|
/**
|
|
209
240
|
* Unsubscribe from sharedGlobalVariableStore, set in the constructor
|
|
210
241
|
* called from terminateWorker(). See the subscription itself below for
|
|
@@ -339,6 +370,81 @@ declare class ThreeTierEvaluator {
|
|
|
339
370
|
inserted: number[];
|
|
340
371
|
removed: number[];
|
|
341
372
|
};
|
|
373
|
+
/**
|
|
374
|
+
* Forget the positions the graph says a line reads, once its text changed.
|
|
375
|
+
*
|
|
376
|
+
* A positional edge is discovered while the line runs and pinned, because
|
|
377
|
+
* the text cannot put it back when the line re-registers. That is right
|
|
378
|
+
* while the text is the same and wrong the moment it is not: `prev + 1`
|
|
379
|
+
* edited to `7` went on reading line 1 in the graph until it ran, and a
|
|
380
|
+
* line edited out of the viewport is compiled there without running, so
|
|
381
|
+
* it could go on for as long as the reader liked. Three of the attempts
|
|
382
|
+
* recorded on #444 found cycles that had already been edited away for
|
|
383
|
+
* exactly that reason.
|
|
384
|
+
*
|
|
385
|
+
* Keyed on the edit itself, which the document model records as a new
|
|
386
|
+
* text hash, rather than on anything the graph knows. Done at the line's
|
|
387
|
+
* first visit after the edit, whatever tier that visit takes, and only
|
|
388
|
+
* when the line is dirty, since an edit always dirties, so a clean line's
|
|
389
|
+
* text is the text its edges describe. The run that follows records what
|
|
390
|
+
* the new text reads, and {@link DependencyGraph.reconcilePositionReads}
|
|
391
|
+
* keeps that exact from then on.
|
|
392
|
+
*/
|
|
393
|
+
private forgetPositionsOfEditedText;
|
|
394
|
+
/**
|
|
395
|
+
* Keep the record of which lines sit on a cycle current.
|
|
396
|
+
*
|
|
397
|
+
* A cycle can only appear or vanish with an edge, so the record is
|
|
398
|
+
* recomputed only when the graph changed this pass, by a walk from what
|
|
399
|
+
* changed: readers that gained a position, lines whose edge set changed
|
|
400
|
+
* (a dropped positional edge included, which is how a cycle is broken), and
|
|
401
|
+
* the readers of a name whose producers changed, which is how a name that
|
|
402
|
+
* pinned a cycle is withdrawn. A line whose status flips is marked to run
|
|
403
|
+
* again, so it runs the other way on the next pass. A settled pass changes
|
|
404
|
+
* nothing and walks nothing.
|
|
405
|
+
*
|
|
406
|
+
* What membership does is decided where a line runs: see
|
|
407
|
+
* {@link evaluateSingleLine} and `ExpressionEngine.setLineOnCycle`. Earlier
|
|
408
|
+
* versions reset a member's answer here instead, at the end of the pass,
|
|
409
|
+
* and that was one line too late: the number the member computed had
|
|
410
|
+
* already been read by the lines below it during the pass. Deciding how the
|
|
411
|
+
* member runs means no number ever exists to be read.
|
|
412
|
+
*/
|
|
413
|
+
private settleCycles;
|
|
414
|
+
/**
|
|
415
|
+
* Recompute which lines sit on a cycle, for every line the change reaches.
|
|
416
|
+
*
|
|
417
|
+
* Tarjan's components, iteratively: a `prev` chain can be thousands of
|
|
418
|
+
* lines deep, which is deeper than a recursive walk should go. A line the
|
|
419
|
+
* walk visits is on a cycle if its component has more than one member, and
|
|
420
|
+
* off one otherwise; a line the walk does not reach kept its edges and its
|
|
421
|
+
* status. Membership is by line id, so a structural edit does not lose it;
|
|
422
|
+
* such an edit clears the graph and every line re-registers on the next
|
|
423
|
+
* pass, so the walk then reaches everything.
|
|
424
|
+
*/
|
|
425
|
+
private recomputeCycleMembership;
|
|
426
|
+
/**
|
|
427
|
+
* The lines whose answers are computed from this line's: the readers of its
|
|
428
|
+
* position, and the readers of each name it writes.
|
|
429
|
+
*
|
|
430
|
+
* Both kinds of edge, because a cycle can run through either. `line 2 + 5`
|
|
431
|
+
* above `prev + 5` is a cycle of positions; `:v1 = v2 + 5` above
|
|
432
|
+
* `:v2 = v1 + 8` is a cycle of names; `spent += line 3` above `spent` is
|
|
433
|
+
* one of each. A walk that followed positions alone found the first and
|
|
434
|
+
* declared the other two out of scope.
|
|
435
|
+
*
|
|
436
|
+
* Edges point the way the graph's consumer index points, from a line to
|
|
437
|
+
* what reads it, which is the transpose of "what this line reads". The
|
|
438
|
+
* strongly connected components of a graph and its transpose are the same
|
|
439
|
+
* sets, so the walk finds the same cycles, and the consumer index is the one
|
|
440
|
+
* the graph keeps clear of a definition's conventional read of its own name
|
|
441
|
+
* and of a running total's read of its own total. Followed as raw reads,
|
|
442
|
+
* every definition was a self-loop and every twice-defined name a cycle.
|
|
443
|
+
*
|
|
444
|
+
* Only variable names among the keys: a tag, a global or a data source is
|
|
445
|
+
* not a line's answer, and a cycle cannot run through one.
|
|
446
|
+
*/
|
|
447
|
+
private dependantsOf;
|
|
342
448
|
/**
|
|
343
449
|
* Reset running-total accumulators and mark the lines that touch them
|
|
344
450
|
* dirty, so the from-line-1 pass in {@link evaluate} recomputes each total
|
|
@@ -404,8 +510,16 @@ declare class ThreeTierEvaluator {
|
|
|
404
510
|
* - Dirty + not in viewport → Tier 3 (compile-only, execute variable defs)
|
|
405
511
|
* - Clean + has bytecode + in viewport → Tier 2 (execute from cache)
|
|
406
512
|
* - Clean + no bytecode → skipped (non-evaluable)
|
|
513
|
+
*
|
|
514
|
+
* Around the dispatch, the graph is kept honest about what the line reads
|
|
515
|
+
* by position: an edited line's old positions go before it runs, and a
|
|
516
|
+
* line that executed is cut back to the positions that run read. Only an
|
|
517
|
+
* executing tier is reconciled, since a line compiled without running, or
|
|
518
|
+
* skipped, read nothing for a reason that says nothing about its text.
|
|
407
519
|
*/
|
|
408
520
|
private evaluateSingleLine;
|
|
521
|
+
/** The tier dispatch itself; see {@link evaluateSingleLine} for what wraps it. */
|
|
522
|
+
private dispatchLine;
|
|
409
523
|
/**
|
|
410
524
|
* A line edited into something with nothing to evaluate stops defining.
|
|
411
525
|
*
|
|
@@ -418,7 +532,11 @@ declare class ThreeTierEvaluator {
|
|
|
418
532
|
*
|
|
419
533
|
* Registering it with no edges is what says so. Only when the line is dirty,
|
|
420
534
|
* since a line that was already empty has nothing to withdraw, and its own
|
|
421
|
-
* write set is dropped as part of registering nothing.
|
|
535
|
+
* write set is dropped as part of registering nothing. What it wrote goes
|
|
536
|
+
* back to the prefix first, as it does when a line is compiled again: the
|
|
537
|
+
* graph unbinds only a name no other line produces, and `:f = 5` under
|
|
538
|
+
* `f(x) = x + 4` produces `f` too, so emptying it left the variable and
|
|
539
|
+
* emptying the function's line left the function.
|
|
422
540
|
*
|
|
423
541
|
* Any unit it defined goes the same way, and for the same reason: a line
|
|
424
542
|
* drops its own definitions as it is compiled again, which a line nothing
|
|
@@ -650,6 +768,11 @@ declare function checkExpressionComplexity(tokens: Token[], config: ValidationCo
|
|
|
650
768
|
* own name falls through to the ordinary bare-identifier read-tracking
|
|
651
769
|
* below, the same as any other `LOAD_VAR`-producing identifier. This is
|
|
652
770
|
* already correct once calls compile successfully, no change needed.
|
|
771
|
+
*
|
|
772
|
+
* A goal seek's unknown (`solve line 4 for rate = 900`) is neither a read nor
|
|
773
|
+
* a write, although `rate =` has the shape of a definition: the seek binds it
|
|
774
|
+
* in its own call frame and the document's variable is untouched. See
|
|
775
|
+
* {@link goalSeekUnknownIndex}.
|
|
653
776
|
*/
|
|
654
777
|
declare function extractReadsAndWrites(tokens: Token[]): {
|
|
655
778
|
reads: string[];
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as DocumentModel, E as ExpressionEngine, V as ViewportRange, u as LineChange, U as UnifiedParsingOptions, P as ParsingResult, v as InlineSolvePosition } from './PackageRegistry-
|
|
2
|
-
export { A as ApplyChangesResult, w as AsyncCachePackageInfo, x as AsyncErrorEvent, y as AsyncResolutionBatcher, z as AsyncResolutionEvent, B as BatcherMetrics, F as BytecodeCacheEntry, G as CacheSnapshot, H as CheckpointSnapshot, D as DateOrderSource, b as DateReading, c as DateReadingPolicy, a as EngineOptions, d as EngineRestoreOptions, e as EngineSnapshot, f as Explanation, g as ExplanationStep, J as LineCacheEntryInfo, K as LineState, M as LinesUpdatedEvent, N as ParsedLine, R as ResolvedDateOrder, S as SNAPSHOT_FORMAT, h as SNAPSHOT_VERSION, i as SerializedAnonymousBody, j as SerializedBytecode, k as SerializedDecimal, l as SerializedLineCacheEntry, m as SerializedNumber, n as SerializedRational, o as SerializedUserFunction, p as SerializedValue, q as SnapshotErrorCodes } from './PackageRegistry-
|
|
1
|
+
import { t as DocumentModel, E as ExpressionEngine, V as ViewportRange, u as LineChange, U as UnifiedParsingOptions, P as ParsingResult, v as InlineSolvePosition } from './PackageRegistry-D7_B0mxv.js';
|
|
2
|
+
export { A as ApplyChangesResult, w as AsyncCachePackageInfo, x as AsyncErrorEvent, y as AsyncResolutionBatcher, z as AsyncResolutionEvent, B as BatcherMetrics, F as BytecodeCacheEntry, G as CacheSnapshot, H as CheckpointSnapshot, D as DateOrderSource, b as DateReading, c as DateReadingPolicy, a as EngineOptions, d as EngineRestoreOptions, e as EngineSnapshot, f as Explanation, g as ExplanationStep, J as LineCacheEntryInfo, K as LineState, M as LinesUpdatedEvent, N as ParsedLine, R as ResolvedDateOrder, S as SNAPSHOT_FORMAT, h as SNAPSHOT_VERSION, i as SerializedAnonymousBody, j as SerializedBytecode, k as SerializedDecimal, l as SerializedLineCacheEntry, m as SerializedNumber, n as SerializedRational, o as SerializedUserFunction, p as SerializedValue, q as SnapshotErrorCodes } from './PackageRegistry-D7_B0mxv.js';
|
|
3
3
|
export { C as CalendarBackend, a as CalendarFields, Z as ZonedFields } from './CalendarBackend-MdS3Bb4P.js';
|
|
4
4
|
export { D as DATE_CALENDAR, a as DateCalendar, E as EngineWorkerFactory, c as calendarOf, d as dateCalendarInZone, s as setEngineWorkerFactory } from './DateCalendar-CTz538dw.js';
|
|
5
5
|
import { V as Value } from './Value-B55Hvn3e.js';
|
|
6
|
-
import { b as VMCheckpointer } from './VMBuiltins-
|
|
7
|
-
export { h as DagSnapshot } from './VMBuiltins-
|
|
6
|
+
import { b as VMCheckpointer } from './VMBuiltins-BqkoJtHt.js';
|
|
7
|
+
export { h as DagSnapshot } from './VMBuiltins-BqkoJtHt.js';
|
|
8
8
|
import { T as Token } from './Token-D8f7yaz1.js';
|
|
9
9
|
import { E as EngineError } from './EngineError-Bm4OYmw8.js';
|
|
10
10
|
import { a as BytecodeProgram } from './BytecodeBuilder-DSWKZi4f.js';
|
|
@@ -205,6 +205,37 @@ declare class ThreeTierEvaluator {
|
|
|
205
205
|
private checkpointer;
|
|
206
206
|
private compilationWorker;
|
|
207
207
|
private pageManager;
|
|
208
|
+
/**
|
|
209
|
+
* The text hash each line had when the graph last recorded what it reads,
|
|
210
|
+
* by line id.
|
|
211
|
+
*
|
|
212
|
+
* A positional edge is recorded at run time and pinned, so it outlives the
|
|
213
|
+
* text that produced it until the line runs again. Between an edit and
|
|
214
|
+
* that run the graph still describes the old text, and a line edited out
|
|
215
|
+
* of the viewport is compiled there without running, so the window can be
|
|
216
|
+
* as long as the reader likes. The document model records the edit as a
|
|
217
|
+
* new hash, and this is the hash the graph's edges for the line describe:
|
|
218
|
+
* a line arriving at the pass with a different one has its positions
|
|
219
|
+
* forgotten before anything else happens to it. See
|
|
220
|
+
* {@link forgetPositionsOfEditedText}.
|
|
221
|
+
*/
|
|
222
|
+
private textHashOfRecordedEdges;
|
|
223
|
+
/**
|
|
224
|
+
* The names each line genuinely reads among those it writes, by line id.
|
|
225
|
+
*
|
|
226
|
+
* `:v3 = v3 + 3` reads `v3` on its right-hand side; `:v3 = 44` does not,
|
|
227
|
+
* although the graph records both as readers of `v3` by convention. The
|
|
228
|
+
* difference is visible only in the per-expression extraction, where the
|
|
229
|
+
* name appears twice, and only while Tier 1 has that in hand; the stored
|
|
230
|
+
* read set is deduplicated. Recorded there, read by Tier 2, which puts such
|
|
231
|
+
* a name back to the prefix before the line runs. Keyed by id so a
|
|
232
|
+
* structural edit does not lose it.
|
|
233
|
+
*/
|
|
234
|
+
private selfReadingWrites;
|
|
235
|
+
/**
|
|
236
|
+
* The lines that sit on a cycle, by line id. See {@link settleCycles}.
|
|
237
|
+
*/
|
|
238
|
+
private cycleMemberIds;
|
|
208
239
|
/**
|
|
209
240
|
* Unsubscribe from sharedGlobalVariableStore, set in the constructor
|
|
210
241
|
* called from terminateWorker(). See the subscription itself below for
|
|
@@ -339,6 +370,81 @@ declare class ThreeTierEvaluator {
|
|
|
339
370
|
inserted: number[];
|
|
340
371
|
removed: number[];
|
|
341
372
|
};
|
|
373
|
+
/**
|
|
374
|
+
* Forget the positions the graph says a line reads, once its text changed.
|
|
375
|
+
*
|
|
376
|
+
* A positional edge is discovered while the line runs and pinned, because
|
|
377
|
+
* the text cannot put it back when the line re-registers. That is right
|
|
378
|
+
* while the text is the same and wrong the moment it is not: `prev + 1`
|
|
379
|
+
* edited to `7` went on reading line 1 in the graph until it ran, and a
|
|
380
|
+
* line edited out of the viewport is compiled there without running, so
|
|
381
|
+
* it could go on for as long as the reader liked. Three of the attempts
|
|
382
|
+
* recorded on #444 found cycles that had already been edited away for
|
|
383
|
+
* exactly that reason.
|
|
384
|
+
*
|
|
385
|
+
* Keyed on the edit itself, which the document model records as a new
|
|
386
|
+
* text hash, rather than on anything the graph knows. Done at the line's
|
|
387
|
+
* first visit after the edit, whatever tier that visit takes, and only
|
|
388
|
+
* when the line is dirty, since an edit always dirties, so a clean line's
|
|
389
|
+
* text is the text its edges describe. The run that follows records what
|
|
390
|
+
* the new text reads, and {@link DependencyGraph.reconcilePositionReads}
|
|
391
|
+
* keeps that exact from then on.
|
|
392
|
+
*/
|
|
393
|
+
private forgetPositionsOfEditedText;
|
|
394
|
+
/**
|
|
395
|
+
* Keep the record of which lines sit on a cycle current.
|
|
396
|
+
*
|
|
397
|
+
* A cycle can only appear or vanish with an edge, so the record is
|
|
398
|
+
* recomputed only when the graph changed this pass, by a walk from what
|
|
399
|
+
* changed: readers that gained a position, lines whose edge set changed
|
|
400
|
+
* (a dropped positional edge included, which is how a cycle is broken), and
|
|
401
|
+
* the readers of a name whose producers changed, which is how a name that
|
|
402
|
+
* pinned a cycle is withdrawn. A line whose status flips is marked to run
|
|
403
|
+
* again, so it runs the other way on the next pass. A settled pass changes
|
|
404
|
+
* nothing and walks nothing.
|
|
405
|
+
*
|
|
406
|
+
* What membership does is decided where a line runs: see
|
|
407
|
+
* {@link evaluateSingleLine} and `ExpressionEngine.setLineOnCycle`. Earlier
|
|
408
|
+
* versions reset a member's answer here instead, at the end of the pass,
|
|
409
|
+
* and that was one line too late: the number the member computed had
|
|
410
|
+
* already been read by the lines below it during the pass. Deciding how the
|
|
411
|
+
* member runs means no number ever exists to be read.
|
|
412
|
+
*/
|
|
413
|
+
private settleCycles;
|
|
414
|
+
/**
|
|
415
|
+
* Recompute which lines sit on a cycle, for every line the change reaches.
|
|
416
|
+
*
|
|
417
|
+
* Tarjan's components, iteratively: a `prev` chain can be thousands of
|
|
418
|
+
* lines deep, which is deeper than a recursive walk should go. A line the
|
|
419
|
+
* walk visits is on a cycle if its component has more than one member, and
|
|
420
|
+
* off one otherwise; a line the walk does not reach kept its edges and its
|
|
421
|
+
* status. Membership is by line id, so a structural edit does not lose it;
|
|
422
|
+
* such an edit clears the graph and every line re-registers on the next
|
|
423
|
+
* pass, so the walk then reaches everything.
|
|
424
|
+
*/
|
|
425
|
+
private recomputeCycleMembership;
|
|
426
|
+
/**
|
|
427
|
+
* The lines whose answers are computed from this line's: the readers of its
|
|
428
|
+
* position, and the readers of each name it writes.
|
|
429
|
+
*
|
|
430
|
+
* Both kinds of edge, because a cycle can run through either. `line 2 + 5`
|
|
431
|
+
* above `prev + 5` is a cycle of positions; `:v1 = v2 + 5` above
|
|
432
|
+
* `:v2 = v1 + 8` is a cycle of names; `spent += line 3` above `spent` is
|
|
433
|
+
* one of each. A walk that followed positions alone found the first and
|
|
434
|
+
* declared the other two out of scope.
|
|
435
|
+
*
|
|
436
|
+
* Edges point the way the graph's consumer index points, from a line to
|
|
437
|
+
* what reads it, which is the transpose of "what this line reads". The
|
|
438
|
+
* strongly connected components of a graph and its transpose are the same
|
|
439
|
+
* sets, so the walk finds the same cycles, and the consumer index is the one
|
|
440
|
+
* the graph keeps clear of a definition's conventional read of its own name
|
|
441
|
+
* and of a running total's read of its own total. Followed as raw reads,
|
|
442
|
+
* every definition was a self-loop and every twice-defined name a cycle.
|
|
443
|
+
*
|
|
444
|
+
* Only variable names among the keys: a tag, a global or a data source is
|
|
445
|
+
* not a line's answer, and a cycle cannot run through one.
|
|
446
|
+
*/
|
|
447
|
+
private dependantsOf;
|
|
342
448
|
/**
|
|
343
449
|
* Reset running-total accumulators and mark the lines that touch them
|
|
344
450
|
* dirty, so the from-line-1 pass in {@link evaluate} recomputes each total
|
|
@@ -404,8 +510,16 @@ declare class ThreeTierEvaluator {
|
|
|
404
510
|
* - Dirty + not in viewport → Tier 3 (compile-only, execute variable defs)
|
|
405
511
|
* - Clean + has bytecode + in viewport → Tier 2 (execute from cache)
|
|
406
512
|
* - Clean + no bytecode → skipped (non-evaluable)
|
|
513
|
+
*
|
|
514
|
+
* Around the dispatch, the graph is kept honest about what the line reads
|
|
515
|
+
* by position: an edited line's old positions go before it runs, and a
|
|
516
|
+
* line that executed is cut back to the positions that run read. Only an
|
|
517
|
+
* executing tier is reconciled, since a line compiled without running, or
|
|
518
|
+
* skipped, read nothing for a reason that says nothing about its text.
|
|
407
519
|
*/
|
|
408
520
|
private evaluateSingleLine;
|
|
521
|
+
/** The tier dispatch itself; see {@link evaluateSingleLine} for what wraps it. */
|
|
522
|
+
private dispatchLine;
|
|
409
523
|
/**
|
|
410
524
|
* A line edited into something with nothing to evaluate stops defining.
|
|
411
525
|
*
|
|
@@ -418,7 +532,11 @@ declare class ThreeTierEvaluator {
|
|
|
418
532
|
*
|
|
419
533
|
* Registering it with no edges is what says so. Only when the line is dirty,
|
|
420
534
|
* since a line that was already empty has nothing to withdraw, and its own
|
|
421
|
-
* write set is dropped as part of registering nothing.
|
|
535
|
+
* write set is dropped as part of registering nothing. What it wrote goes
|
|
536
|
+
* back to the prefix first, as it does when a line is compiled again: the
|
|
537
|
+
* graph unbinds only a name no other line produces, and `:f = 5` under
|
|
538
|
+
* `f(x) = x + 4` produces `f` too, so emptying it left the variable and
|
|
539
|
+
* emptying the function's line left the function.
|
|
422
540
|
*
|
|
423
541
|
* Any unit it defined goes the same way, and for the same reason: a line
|
|
424
542
|
* drops its own definitions as it is compiled again, which a line nothing
|
|
@@ -650,6 +768,11 @@ declare function checkExpressionComplexity(tokens: Token[], config: ValidationCo
|
|
|
650
768
|
* own name falls through to the ordinary bare-identifier read-tracking
|
|
651
769
|
* below, the same as any other `LOAD_VAR`-producing identifier. This is
|
|
652
770
|
* already correct once calls compile successfully, no change needed.
|
|
771
|
+
*
|
|
772
|
+
* A goal seek's unknown (`solve line 4 for rate = 900`) is neither a read nor
|
|
773
|
+
* a write, although `rate =` has the shape of a definition: the seek binds it
|
|
774
|
+
* in its own call frame and the document's variable is untouched. See
|
|
775
|
+
* {@link goalSeekUnknownIndex}.
|
|
653
776
|
*/
|
|
654
777
|
declare function extractReadsAndWrites(tokens: Token[]): {
|
|
655
778
|
reads: string[];
|
package/dist/engine.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as DocumentModel,b as EvalTier,c as ThreeTierEvaluator,d as evaluateDocument}from'./chunk-
|
|
1
|
+
export{a as DocumentModel,b as EvalTier,c as ThreeTierEvaluator,d as evaluateDocument}from'./chunk-NYJTBXSI.js';import'./chunk-RAF57WYO.js';export{i as AsyncResolutionBatcher,o as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,k as checkExpressionComplexity,j as checkExpressionLength,l as extractReadsAndWrites,n as findInlineSolvesInLine,m as isEmptyLine,g as setEngineWorkerFactory}from'./chunk-RAZ6IYUQ.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-X2QJE3SV.js';import'./chunk-RMBUP4XA.js';import'./chunk-JP4JMQOG.js';import'./chunk-TFZNEEJR.js';import'./chunk-HLZRNZEU.js';import'./chunk-OC65AGRR.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-QP4VIEXZ.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-ZSFOIBIH.js';export{b as DATE_CALENDAR,a as DateCalendar,c as calendarOf,d as dateCalendarInZone}from'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import'./chunk-A34R65WT.js';import'./chunk-BWTVJD5L.js';import'./chunk-TVM5VYCM.js';import'./chunk-6NL7RBAG.js';import'./chunk-JPFCXLJV.js';import'./chunk-APYRNAU2.js';import'./chunk-FAO6DQ74.js';import'./chunk-LHLW7JLS.js';import'./chunk-CHVGFTO3.js';import'./chunk-PRSXXDTA.js';import'./chunk-6G2NES2I.js';//# sourceMappingURL=engine.js.map
|
|
2
2
|
//# sourceMappingURL=engine.js.map
|
package/dist/engine.worker.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk5GJUECKG_cjs=require('./chunk-5GJUECKG.cjs');require('./chunk-P5YWBIIU.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-R3W53ZMP.cjs'),require('./chunk-TTFO4YDP.cjs');var chunkOBQC7KDY_cjs=require('./chunk-OBQC7KDY.cjs');require('./chunk-HG4NPDN5.cjs'),require('./chunk-EZ7R3ZHM.cjs'),require('./chunk-W4XLVZ6R.cjs');var chunkZJJ54J4L_cjs=require('./chunk-ZJJ54J4L.cjs');require('./chunk-NMZRAJLJ.cjs'),require('./chunk-OQHRKHP7.cjs'),require('./chunk-K3PZ66XR.cjs'),require('./chunk-YV4GDW5A.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-GDLYXRMA.cjs'),require('./chunk-ZLRJ7TDP.cjs');var chunk54QMY2VL_cjs=require('./chunk-54QMY2VL.cjs');require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-Z4MIX43O.cjs'),require('./chunk-EQNKDTMX.cjs'),require('./chunk-E4HAKNBQ.cjs'),require('./chunk-NH74IT7B.cjs'),require('./chunk-PHWIO4P3.cjs'),require('./chunk-FJBWZW45.cjs'),require('./chunk-3MG7VIPL.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-72J5V7SN.cjs'),require('./chunk-YBQOQTVL.cjs'),require('./chunk-S3DFU33X.cjs'),require('./chunk-J4LSAHCY.cjs'),require('./chunk-EZKR44MA.cjs'),require('./chunk-6SYU4MH7.cjs');var i=null;function E(){return i||(i=new chunk5GJUECKG_cjs.o({packages:chunkZJJ54J4L_cjs.z})),i}var f=null;function h(){return f||(f=chunkOBQC7KDY_cjs.b(chunk54QMY2VL_cjs.A,200,5e4)),f}function B(e){let r={lineId:e.lineId,expression:e.expression,compiledAgainstHash:e.textHash,strings:[],reads:[],writes:[],isVariableDef:false,error:null};try{let n=E(),{program:u,reads:s,writes:t}=n.compileExpression(e.expression),o=t.length>0,a=u.opcodes,l=u.numbers,y=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),d=l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength);return {...r,opcodesBuffer:y,numbersBuffer:d,opcodesLength:a.length,numbersLength:l.length,strings:[...u.strings],reads:s,writes:t,isVariableDef:o}}catch(n){return {...r,opcodesBuffer:new ArrayBuffer(0),numbersBuffer:new ArrayBuffer(0),opcodesLength:0,numbersLength:0,error:n instanceof Error?n.message:String(n)}}}function L(e){let r=[],n=[];for(let u of e.items){let s=B(u);r.push(s),s.opcodesBuffer.byteLength>0&&n.push(s.opcodesBuffer),s.numbersBuffer.byteLength>0&&n.push(s.numbersBuffer);}self.postMessage({id:e.id,type:"COMPILE_RESULT",results:r},n);}function M(e){let r=h();r.reset();let n=new Uint8Array(e.opcodesBuffer,0,e.opcodesLength),u=new Float64Array(e.numbersBuffer,0,e.numbersLength),s={opcodes:n,numbers:u,strings:e.strings};try{let t=chunkOBQC7KDY_cjs.c(s,r);if(t.type==="pending")return {lineNumber:e.lineNumber,valueType:12,value:0,isPending:!0,queryKey:t.queryKey};if(t.type==="error")return {lineNumber:e.lineNumber,valueType:13,value:0,isPending:!1,unit:t.error.message};let o=t.value;return {lineNumber:e.lineNumber,valueType:o.type,value:typeof o.value=="number"?o.value:typeof o.value=="bigint"?Number(o.value):0,unit:o.unit,isPending:!1}}catch{return {lineNumber:e.lineNumber,valueType:13,value:0,isPending:false,unit:"Worker execution failed"}}}function T(e){let r=[];for(let n of e.items)r.push(M(n));self.postMessage({id:e.id,type:"EXECUTE_RESULT",results:r});}var x=typeof self<"u"&&typeof window>"u",C=e=>{if(e.origin&&self.location&&e.origin!==self.location.origin)return;let r=e.data;switch(r.type){case "COMPILE_BATCH":L(r);break;case "EXECUTE_BATCH":T(r);break;case "TERMINATE":{i&&(i.clear(),i=null),f&&(f.reset(),f=null),self.postMessage({id:r.id,type:"COMPILE_RESULT",results:[]});break}default:self.postMessage({id:-1,type:"COMPILE_RESULT",results:[],error:`Unknown message type: ${r.type}`});}};x&&(self.onmessage=C);//# sourceMappingURL=engine.worker.cjs.map
|
|
2
2
|
//# sourceMappingURL=engine.worker.cjs.map
|
package/dist/engine.worker.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {o}from'./chunk-
|
|
1
|
+
import {o}from'./chunk-RAZ6IYUQ.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import {c,b}from'./chunk-RMBUP4XA.js';import'./chunk-JP4JMQOG.js';import'./chunk-TFZNEEJR.js';import'./chunk-HLZRNZEU.js';import {z}from'./chunk-NZUFFOB3.js';import'./chunk-AWGSR2GZ.js';import'./chunk-OC65AGRR.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import {A}from'./chunk-QP4VIEXZ.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-ZSFOIBIH.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import'./chunk-A34R65WT.js';import'./chunk-BWTVJD5L.js';import'./chunk-TVM5VYCM.js';import'./chunk-6NL7RBAG.js';import'./chunk-JPFCXLJV.js';import'./chunk-APYRNAU2.js';import'./chunk-FAO6DQ74.js';import'./chunk-LHLW7JLS.js';import'./chunk-CHVGFTO3.js';import'./chunk-PRSXXDTA.js';import'./chunk-6G2NES2I.js';var i=null;function E(){return i||(i=new o({packages:z})),i}var f=null;function h(){return f||(f=b(A,200,5e4)),f}function B(e){let r={lineId:e.lineId,expression:e.expression,compiledAgainstHash:e.textHash,strings:[],reads:[],writes:[],isVariableDef:false,error:null};try{let n=E(),{program:u,reads:s,writes:t}=n.compileExpression(e.expression),o=t.length>0,a=u.opcodes,l=u.numbers,y=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),d=l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength);return {...r,opcodesBuffer:y,numbersBuffer:d,opcodesLength:a.length,numbersLength:l.length,strings:[...u.strings],reads:s,writes:t,isVariableDef:o}}catch(n){return {...r,opcodesBuffer:new ArrayBuffer(0),numbersBuffer:new ArrayBuffer(0),opcodesLength:0,numbersLength:0,error:n instanceof Error?n.message:String(n)}}}function L(e){let r=[],n=[];for(let u of e.items){let s=B(u);r.push(s),s.opcodesBuffer.byteLength>0&&n.push(s.opcodesBuffer),s.numbersBuffer.byteLength>0&&n.push(s.numbersBuffer);}self.postMessage({id:e.id,type:"COMPILE_RESULT",results:r},n);}function M(e){let r=h();r.reset();let n=new Uint8Array(e.opcodesBuffer,0,e.opcodesLength),u=new Float64Array(e.numbersBuffer,0,e.numbersLength),s={opcodes:n,numbers:u,strings:e.strings};try{let t=c(s,r);if(t.type==="pending")return {lineNumber:e.lineNumber,valueType:12,value:0,isPending:!0,queryKey:t.queryKey};if(t.type==="error")return {lineNumber:e.lineNumber,valueType:13,value:0,isPending:!1,unit:t.error.message};let o=t.value;return {lineNumber:e.lineNumber,valueType:o.type,value:typeof o.value=="number"?o.value:typeof o.value=="bigint"?Number(o.value):0,unit:o.unit,isPending:!1}}catch{return {lineNumber:e.lineNumber,valueType:13,value:0,isPending:false,unit:"Worker execution failed"}}}function T(e){let r=[];for(let n of e.items)r.push(M(n));self.postMessage({id:e.id,type:"EXECUTE_RESULT",results:r});}var x=typeof self<"u"&&typeof window>"u",C=e=>{if(e.origin&&self.location&&e.origin!==self.location.origin)return;let r=e.data;switch(r.type){case "COMPILE_BATCH":L(r);break;case "EXECUTE_BATCH":T(r);break;case "TERMINATE":{i&&(i.clear(),i=null),f&&(f.reset(),f=null),self.postMessage({id:r.id,type:"COMPILE_RESULT",results:[]});break}default:self.postMessage({id:-1,type:"COMPILE_RESULT",results:[],error:`Unknown message type: ${r.type}`});}};x&&(self.onmessage=C);//# sourceMappingURL=engine.worker.js.map
|
|
2
2
|
//# sourceMappingURL=engine.worker.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';require('./chunk-
|
|
1
|
+
'use strict';require('./chunk-VNNRAHDE.cjs'),require('./chunk-EFJCC6FJ.cjs');var chunk5GJUECKG_cjs=require('./chunk-5GJUECKG.cjs');require('./chunk-P5YWBIIU.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-R3W53ZMP.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-CR7IHPA2.cjs'),require('./chunk-OBQC7KDY.cjs'),require('./chunk-HG4NPDN5.cjs');var chunkEZ7R3ZHM_cjs=require('./chunk-EZ7R3ZHM.cjs');require('./chunk-W4XLVZ6R.cjs');var chunkZJJ54J4L_cjs=require('./chunk-ZJJ54J4L.cjs');require('./chunk-NMZRAJLJ.cjs'),require('./chunk-OQHRKHP7.cjs');var chunkK3PZ66XR_cjs=require('./chunk-K3PZ66XR.cjs');require('./chunk-YV4GDW5A.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-GDLYXRMA.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-54QMY2VL.cjs'),require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-Z4MIX43O.cjs');var chunkEQNKDTMX_cjs=require('./chunk-EQNKDTMX.cjs');require('./chunk-E4HAKNBQ.cjs');var chunkNH74IT7B_cjs=require('./chunk-NH74IT7B.cjs');require('./chunk-PHWIO4P3.cjs');var chunkFJBWZW45_cjs=require('./chunk-FJBWZW45.cjs');require('./chunk-3MG7VIPL.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-72J5V7SN.cjs'),require('./chunk-YBQOQTVL.cjs'),require('./chunk-S3DFU33X.cjs'),require('./chunk-J4LSAHCY.cjs'),require('./chunk-EZKR44MA.cjs');var chunk6SYU4MH7_cjs=require('./chunk-6SYU4MH7.cjs');var r={DEFINE_FUNCTION_INVALID_NAME:"DEFINE_FUNCTION_INVALID_NAME",DEFINE_FUNCTION_INVALID_SPEC:"DEFINE_FUNCTION_INVALID_SPEC",DEFINE_FUNCTION_ARITY_MISMATCH:"DEFINE_FUNCTION_ARITY_MISMATCH",DEFINE_FUNCTION_ARGUMENT_TYPE:"DEFINE_FUNCTION_ARGUMENT_TYPE",DEFINE_FUNCTION_RETURN_TYPE:"DEFINE_FUNCTION_RETURN_TYPE"},O=/^[a-z_][a-z0-9_]*$/i,N=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function d(e){switch(e.type){case 0:case 1:return "a number";case 3:return "a string";case 10:return "a boolean";case 2:return "a big integer";case 5:return "a percentage";case 6:return "a value with a unit";case 4:return "a date";case 7:return "a matrix";case 8:return "a range";case 9:return "a symbolic expression";default:return "an unsupported value"}}function k(e,n,t){switch(n.type){case "number":if(e.type===0||e.type===1)return e.toNumber();break;case "string":if(e.type===3)return e.value;break;case "boolean":if(e.type===10)return e.value;break}throw chunk6SYU4MH7_cjs.c.execution({code:r.DEFINE_FUNCTION_ARGUMENT_TYPE,message:`${t}() expects "${n.name}" to be a ${n.type}, but was given ${d(e)}`,expected:`a ${n.type}`,found:d(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function R(e,n,t){switch(n){case "number":if(typeof e=="number")return chunkNH74IT7B_cjs.n(e);break;case "string":if(typeof e=="string")return chunkNH74IT7B_cjs.t(e);break;case "boolean":if(typeof e=="boolean")return chunkNH74IT7B_cjs.L(e);break}throw chunk6SYU4MH7_cjs.c.internal({code:r.DEFINE_FUNCTION_RETURN_TYPE,message:`${t}() is declared to return a ${n}, but its implementation returned ${typeof e}`,expected:`a ${n}`,found:typeof e,context:{functionName:t,expectedType:n}})}var p=class{constructor(n){this.fnName=n;this.category="Function";}parse(n,t,a){n.consume("LPAREN");let i=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,a),i++;n.match("COMMA");)n.parseExpression(chunkK3PZ66XR_cjs.a.Lowest,a),i++;n.consume("RPAREN"),a.emitPluginCall(this.fnName,i);}};function D(e){let n=e.args.length;return t=>{if(t.length!==n)throw chunk6SYU4MH7_cjs.c.execution({code:r.DEFINE_FUNCTION_ARITY_MISMATCH,message:`${e.name}() takes ${u(n)}, but was given ${t.length===0?"none":u(t.length)}`,expected:u(n),found:t.length===0?"none":u(t.length),context:{functionName:e.name,expected:n,actual:t.length}});let a=new Array(n);for(let s=0;s<n;s++)a[s]=k(t[s],e.args[s],e.name);let i=e.call(...a);return R(i,e.returns,e.name)}}function h(e){if(typeof e?.name!="string"||!O.test(e.name))throw chunk6SYU4MH7_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_NAME,message:`defineFunction: name must be a single identifier, got ${JSON.stringify(e?.name)}`,suggestion:'e.g. "vat" or "net_price"',context:{name:e?.name}});if(!Array.isArray(e.args))throw chunk6SYU4MH7_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" args must be an array`,context:{name:e.name}});for(let n of e.args){if(typeof n?.name!="string"||n.name.length===0)throw chunk6SYU4MH7_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has an argument with no name`,context:{name:e.name}});if(!N.has(n.type))throw chunk6SYU4MH7_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" argument "${n.name}" has unsupported type ${JSON.stringify(n.type)}`,suggestion:"supported argument types are number, string, boolean",context:{name:e.name,argName:n.name,type:n.type}})}if(!N.has(e.returns))throw chunk6SYU4MH7_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has unsupported return type ${JSON.stringify(e.returns)}`,suggestion:"supported return types are number, string, boolean",context:{name:e.name,returns:e.returns}});if(typeof e.call!="function")throw chunk6SYU4MH7_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" is missing a call implementation`,context:{name:e.name}})}function w(e){h(e);let n=e.name,t=`DEFINE_FN_${n.toUpperCase()}`;return {name:`solve-fn-${n}`,lexerVocabulary:{keywords:{[n.toLowerCase()]:t}},prefixParselets:{[t]:new p(n)},pluginFunctions:{[n]:D(e)}}}function U(e={}){let{extraPackages:n=[],...t}=e;return new chunk5GJUECKG_cjs.o({...t,packages:n.length>0?[...chunkZJJ54J4L_cjs.z,...n]:chunkZJJ54J4L_cjs.z})}Object.defineProperty(exports,"ExpressionEngine",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.o}});Object.defineProperty(exports,"SNAPSHOT_FORMAT",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.d}});Object.defineProperty(exports,"SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.e}});Object.defineProperty(exports,"SnapshotErrorCodes",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.f}});Object.defineProperty(exports,"assertEngineVersionCompatible",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.c}});Object.defineProperty(exports,"checkEngineVersionCompatibility",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.b}});Object.defineProperty(exports,"checkPackageCompatibility",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.a}});Object.defineProperty(exports,"setEngineWorkerFactory",{enumerable:true,get:function(){return chunk5GJUECKG_cjs.g}});Object.defineProperty(exports,"formatValue",{enumerable:true,get:function(){return chunkEZ7R3ZHM_cjs.c}});Object.defineProperty(exports,"dateCalendarInZone",{enumerable:true,get:function(){return chunkEQNKDTMX_cjs.d}});Object.defineProperty(exports,"Value",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.m}});Object.defineProperty(exports,"ValueType",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.g}});Object.defineProperty(exports,"ENGINE_VERSION",{enumerable:true,get:function(){return chunkFJBWZW45_cjs.a}});exports.DefineFunctionErrorCodes=r;exports.createEngine=U;exports.defineFunction=w;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-
|
|
2
|
-
export { D as DateOrderSource, b as DateReading, c as DateReadingPolicy, d as EngineRestoreOptions, e as EngineSnapshot, f as Explanation, g as ExplanationStep, R as ResolvedDateOrder, S as SNAPSHOT_FORMAT, h as SNAPSHOT_VERSION, i as SerializedAnonymousBody, j as SerializedBytecode, k as SerializedDecimal, l as SerializedLineCacheEntry, m as SerializedNumber, n as SerializedRational, o as SerializedUserFunction, p as SerializedValue, q as SnapshotErrorCodes } from './PackageRegistry-
|
|
3
|
-
export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-
|
|
1
|
+
import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-Bd8ErpwZ.cjs';
|
|
2
|
+
export { D as DateOrderSource, b as DateReading, c as DateReadingPolicy, d as EngineRestoreOptions, e as EngineSnapshot, f as Explanation, g as ExplanationStep, R as ResolvedDateOrder, S as SNAPSHOT_FORMAT, h as SNAPSHOT_VERSION, i as SerializedAnonymousBody, j as SerializedBytecode, k as SerializedDecimal, l as SerializedLineCacheEntry, m as SerializedNumber, n as SerializedRational, o as SerializedUserFunction, p as SerializedValue, q as SnapshotErrorCodes } from './PackageRegistry-Bd8ErpwZ.cjs';
|
|
3
|
+
export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-CzDzOIg9.cjs';
|
|
4
4
|
export { E as EngineWorkerFactory, d as dateCalendarInZone, s as setEngineWorkerFactory } from './DateCalendar-GFQDX1ng.cjs';
|
|
5
5
|
export { E as EngineConfigOverride } from './Configuration-BxriK9Kw.cjs';
|
|
6
6
|
export { D as DatetimeGrain, V as Value, b as ValueType } from './Value-B55Hvn3e.cjs';
|
|
@@ -17,7 +17,7 @@ import './EngineError-Bm4OYmw8.cjs';
|
|
|
17
17
|
import './resolvers.cjs';
|
|
18
18
|
import '@tanstack/query-core';
|
|
19
19
|
import './TokenNormalizer-D382VSYh.cjs';
|
|
20
|
-
import './VMBuiltins-
|
|
20
|
+
import './VMBuiltins-Baa90D2v.cjs';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* A higher-level, declarative way to contribute a single `name(args)`
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-
|
|
2
|
-
export { D as DateOrderSource, b as DateReading, c as DateReadingPolicy, d as EngineRestoreOptions, e as EngineSnapshot, f as Explanation, g as ExplanationStep, R as ResolvedDateOrder, S as SNAPSHOT_FORMAT, h as SNAPSHOT_VERSION, i as SerializedAnonymousBody, j as SerializedBytecode, k as SerializedDecimal, l as SerializedLineCacheEntry, m as SerializedNumber, n as SerializedRational, o as SerializedUserFunction, p as SerializedValue, q as SnapshotErrorCodes } from './PackageRegistry-
|
|
3
|
-
export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-
|
|
1
|
+
import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-D7_B0mxv.js';
|
|
2
|
+
export { D as DateOrderSource, b as DateReading, c as DateReadingPolicy, d as EngineRestoreOptions, e as EngineSnapshot, f as Explanation, g as ExplanationStep, R as ResolvedDateOrder, S as SNAPSHOT_FORMAT, h as SNAPSHOT_VERSION, i as SerializedAnonymousBody, j as SerializedBytecode, k as SerializedDecimal, l as SerializedLineCacheEntry, m as SerializedNumber, n as SerializedRational, o as SerializedUserFunction, p as SerializedValue, q as SnapshotErrorCodes } from './PackageRegistry-D7_B0mxv.js';
|
|
3
|
+
export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-C7ILySsH.js';
|
|
4
4
|
export { E as EngineWorkerFactory, d as dateCalendarInZone, s as setEngineWorkerFactory } from './DateCalendar-CTz538dw.js';
|
|
5
5
|
export { E as EngineConfigOverride } from './Configuration-BxriK9Kw.js';
|
|
6
6
|
export { D as DatetimeGrain, V as Value, b as ValueType } from './Value-B55Hvn3e.js';
|
|
@@ -17,7 +17,7 @@ import './EngineError-Bm4OYmw8.js';
|
|
|
17
17
|
import './resolvers.js';
|
|
18
18
|
import '@tanstack/query-core';
|
|
19
19
|
import './TokenNormalizer-DAzPp-j1.js';
|
|
20
|
-
import './VMBuiltins-
|
|
20
|
+
import './VMBuiltins-BqkoJtHt.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* A higher-level, declarative way to contribute a single `name(args)`
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./chunk-
|
|
1
|
+
import'./chunk-NYJTBXSI.js';import'./chunk-RAF57WYO.js';import {o}from'./chunk-RAZ6IYUQ.js';export{o as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,c as assertEngineVersionCompatible,b as checkEngineVersionCompatibility,a as checkPackageCompatibility,g as setEngineWorkerFactory}from'./chunk-RAZ6IYUQ.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-X2QJE3SV.js';import'./chunk-RMBUP4XA.js';import'./chunk-JP4JMQOG.js';export{c as formatValue}from'./chunk-TFZNEEJR.js';import'./chunk-HLZRNZEU.js';import {z}from'./chunk-NZUFFOB3.js';import'./chunk-AWGSR2GZ.js';import'./chunk-OC65AGRR.js';import {a}from'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-QP4VIEXZ.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-ZSFOIBIH.js';export{d as dateCalendarInZone}from'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import {L,t,n}from'./chunk-A34R65WT.js';export{m as Value,g as ValueType}from'./chunk-A34R65WT.js';import'./chunk-BWTVJD5L.js';export{a as ENGINE_VERSION}from'./chunk-TVM5VYCM.js';import'./chunk-6NL7RBAG.js';import'./chunk-JPFCXLJV.js';import'./chunk-APYRNAU2.js';import'./chunk-FAO6DQ74.js';import'./chunk-LHLW7JLS.js';import'./chunk-CHVGFTO3.js';import'./chunk-PRSXXDTA.js';import {c}from'./chunk-6G2NES2I.js';var r={DEFINE_FUNCTION_INVALID_NAME:"DEFINE_FUNCTION_INVALID_NAME",DEFINE_FUNCTION_INVALID_SPEC:"DEFINE_FUNCTION_INVALID_SPEC",DEFINE_FUNCTION_ARITY_MISMATCH:"DEFINE_FUNCTION_ARITY_MISMATCH",DEFINE_FUNCTION_ARGUMENT_TYPE:"DEFINE_FUNCTION_ARGUMENT_TYPE",DEFINE_FUNCTION_RETURN_TYPE:"DEFINE_FUNCTION_RETURN_TYPE"},O=/^[a-z_][a-z0-9_]*$/i,N=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function d(e){switch(e.type){case 0:case 1:return "a number";case 3:return "a string";case 10:return "a boolean";case 2:return "a big integer";case 5:return "a percentage";case 6:return "a value with a unit";case 4:return "a date";case 7:return "a matrix";case 8:return "a range";case 9:return "a symbolic expression";default:return "an unsupported value"}}function k(e,n,t){switch(n.type){case "number":if(e.type===0||e.type===1)return e.toNumber();break;case "string":if(e.type===3)return e.value;break;case "boolean":if(e.type===10)return e.value;break}throw c.execution({code:r.DEFINE_FUNCTION_ARGUMENT_TYPE,message:`${t}() expects "${n.name}" to be a ${n.type}, but was given ${d(e)}`,expected:`a ${n.type}`,found:d(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function R(e,n$1,t$1){switch(n$1){case "number":if(typeof e=="number")return n(e);break;case "string":if(typeof e=="string")return t(e);break;case "boolean":if(typeof e=="boolean")return L(e);break}throw c.internal({code:r.DEFINE_FUNCTION_RETURN_TYPE,message:`${t$1}() is declared to return a ${n$1}, but its implementation returned ${typeof e}`,expected:`a ${n$1}`,found:typeof e,context:{functionName:t$1,expectedType:n$1}})}var p=class{constructor(n){this.fnName=n;this.category="Function";}parse(n,t,a$1){n.consume("LPAREN");let i=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(a.Lowest,a$1),i++;n.match("COMMA");)n.parseExpression(a.Lowest,a$1),i++;n.consume("RPAREN"),a$1.emitPluginCall(this.fnName,i);}};function D(e){let n=e.args.length;return t=>{if(t.length!==n)throw c.execution({code:r.DEFINE_FUNCTION_ARITY_MISMATCH,message:`${e.name}() takes ${u(n)}, but was given ${t.length===0?"none":u(t.length)}`,expected:u(n),found:t.length===0?"none":u(t.length),context:{functionName:e.name,expected:n,actual:t.length}});let a=new Array(n);for(let s=0;s<n;s++)a[s]=k(t[s],e.args[s],e.name);let i=e.call(...a);return R(i,e.returns,e.name)}}function h(e){if(typeof e?.name!="string"||!O.test(e.name))throw c.config({code:r.DEFINE_FUNCTION_INVALID_NAME,message:`defineFunction: name must be a single identifier, got ${JSON.stringify(e?.name)}`,suggestion:'e.g. "vat" or "net_price"',context:{name:e?.name}});if(!Array.isArray(e.args))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" args must be an array`,context:{name:e.name}});for(let n of e.args){if(typeof n?.name!="string"||n.name.length===0)throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has an argument with no name`,context:{name:e.name}});if(!N.has(n.type))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" argument "${n.name}" has unsupported type ${JSON.stringify(n.type)}`,suggestion:"supported argument types are number, string, boolean",context:{name:e.name,argName:n.name,type:n.type}})}if(!N.has(e.returns))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has unsupported return type ${JSON.stringify(e.returns)}`,suggestion:"supported return types are number, string, boolean",context:{name:e.name,returns:e.returns}});if(typeof e.call!="function")throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" is missing a call implementation`,context:{name:e.name}})}function w(e){h(e);let n=e.name,t=`DEFINE_FN_${n.toUpperCase()}`;return {name:`solve-fn-${n}`,lexerVocabulary:{keywords:{[n.toLowerCase()]:t}},prefixParselets:{[t]:new p(n)},pluginFunctions:{[n]:D(e)}}}function U(e={}){let{extraPackages:n=[],...t}=e;return new o({...t,packages:n.length>0?[...z,...n]:z})}export{r as DefineFunctionErrorCodes,U as createEngine,w as defineFunction};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/language.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CompletionItem } from './PackageRegistry-
|
|
2
|
-
export { L as LanguageService, r as LanguageServiceOptions, s as SemanticToken } from './PackageRegistry-
|
|
1
|
+
import { C as CompletionItem } from './PackageRegistry-Bd8ErpwZ.cjs';
|
|
2
|
+
export { L as LanguageService, r as LanguageServiceOptions, s as SemanticToken } from './PackageRegistry-Bd8ErpwZ.cjs';
|
|
3
3
|
import { e as TokenCategory } from './Lexer-DaWkCu84.cjs';
|
|
4
4
|
import './Parselet-DmMY2s9Y.cjs';
|
|
5
5
|
import './BytecodeBuilder-DSWKZi4f.cjs';
|
|
@@ -10,7 +10,7 @@ import './CalendarBackend-MdS3Bb4P.cjs';
|
|
|
10
10
|
import './resolvers.cjs';
|
|
11
11
|
import '@tanstack/query-core';
|
|
12
12
|
import './TokenNormalizer-D382VSYh.cjs';
|
|
13
|
-
import './VMBuiltins-
|
|
13
|
+
import './VMBuiltins-Baa90D2v.cjs';
|
|
14
14
|
import './EngineError-Bm4OYmw8.cjs';
|
|
15
15
|
import './Configuration-BxriK9Kw.cjs';
|
|
16
16
|
|
package/dist/language.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CompletionItem } from './PackageRegistry-
|
|
2
|
-
export { L as LanguageService, r as LanguageServiceOptions, s as SemanticToken } from './PackageRegistry-
|
|
1
|
+
import { C as CompletionItem } from './PackageRegistry-D7_B0mxv.js';
|
|
2
|
+
export { L as LanguageService, r as LanguageServiceOptions, s as SemanticToken } from './PackageRegistry-D7_B0mxv.js';
|
|
3
3
|
import { e as TokenCategory } from './Lexer-DPn5dfCH.js';
|
|
4
4
|
import './Parselet-Br1tHash.js';
|
|
5
5
|
import './BytecodeBuilder-DSWKZi4f.js';
|
|
@@ -10,7 +10,7 @@ import './CalendarBackend-MdS3Bb4P.js';
|
|
|
10
10
|
import './resolvers.js';
|
|
11
11
|
import '@tanstack/query-core';
|
|
12
12
|
import './TokenNormalizer-DAzPp-j1.js';
|
|
13
|
-
import './VMBuiltins-
|
|
13
|
+
import './VMBuiltins-BqkoJtHt.js';
|
|
14
14
|
import './EngineError-Bm4OYmw8.js';
|
|
15
15
|
import './Configuration-BxriK9Kw.js';
|
|
16
16
|
|