solve-engine 2.1.0 → 2.3.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.
Files changed (80) hide show
  1. package/dist/{Configuration-B6W0-T67.d.cts → Configuration-Culg8H_o.d.cts} +17 -0
  2. package/dist/{Configuration-B6W0-T67.d.ts → Configuration-Culg8H_o.d.ts} +17 -0
  3. package/dist/{PackageCompatibility-Bn5jnBtA.d.cts → PackageCompatibility-CN-2CVhu.d.cts} +1 -1
  4. package/dist/{PackageCompatibility-CIvq2MP5.d.ts → PackageCompatibility-DbpyKYOe.d.ts} +1 -1
  5. package/dist/{PackageRegistry-dpdurBVO.d.cts → PackageRegistry-DXsvmpQN.d.cts} +33 -3
  6. package/dist/{PackageRegistry-DzeiWcv4.d.ts → PackageRegistry-jqdAsm6U.d.ts} +33 -3
  7. package/dist/{ScopeManager-C2LDOrDx.d.ts → ScopeManager-DkpnlKuz.d.ts} +1 -1
  8. package/dist/{ScopeManager-D7uMXbhS.d.cts → ScopeManager-t6SnP6Ce.d.cts} +1 -1
  9. package/dist/{VMCheckpoints-I9jg3jWR.d.cts → VMCheckpoints-C_jQvABf.d.cts} +2 -2
  10. package/dist/{VMCheckpoints-CGyFhivM.d.ts → VMCheckpoints-CsHmQVaD.d.ts} +2 -2
  11. package/dist/{chunk-7GK3XEZF.js → chunk-7E7NXKQ5.js} +2 -2
  12. package/dist/chunk-7E7NXKQ5.js.map +1 -0
  13. package/dist/chunk-AIIPKVKO.js +3 -0
  14. package/dist/chunk-AIIPKVKO.js.map +1 -0
  15. package/dist/chunk-BAVZMGTZ.cjs +2 -0
  16. package/dist/chunk-BAVZMGTZ.cjs.map +1 -0
  17. package/dist/chunk-ESXQDRP7.js +2 -0
  18. package/dist/chunk-ESXQDRP7.js.map +1 -0
  19. package/dist/chunk-JFREB45J.cjs +3 -0
  20. package/dist/chunk-JFREB45J.cjs.map +1 -0
  21. package/dist/chunk-L7ZQQ773.cjs +5 -0
  22. package/dist/chunk-L7ZQQ773.cjs.map +1 -0
  23. package/dist/{chunk-ZCNBT44X.cjs → chunk-LNZNJSRW.cjs} +2 -2
  24. package/dist/chunk-LNZNJSRW.cjs.map +1 -0
  25. package/dist/chunk-NNYMXK6H.js +5 -0
  26. package/dist/chunk-NNYMXK6H.js.map +1 -0
  27. package/dist/{chunk-JUIJ6NRD.cjs → chunk-PBGPQM3X.cjs} +3 -3
  28. package/dist/chunk-PBGPQM3X.cjs.map +1 -0
  29. package/dist/chunk-PXWOATTF.js +3 -0
  30. package/dist/chunk-PXWOATTF.js.map +1 -0
  31. package/dist/constants.cjs +1 -1
  32. package/dist/constants.d.cts +1 -1
  33. package/dist/constants.d.ts +1 -1
  34. package/dist/constants.js +1 -1
  35. package/dist/engine.cjs +1 -1
  36. package/dist/engine.d.cts +49 -6
  37. package/dist/engine.d.ts +49 -6
  38. package/dist/engine.js +1 -1
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.d.cts +5 -5
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +1 -1
  43. package/dist/language.d.cts +4 -4
  44. package/dist/language.d.ts +4 -4
  45. package/dist/packages.cjs +1 -1
  46. package/dist/packages.d.cts +12 -3
  47. package/dist/packages.d.ts +12 -3
  48. package/dist/packages.js +1 -1
  49. package/dist/resolvers.cjs +1 -1
  50. package/dist/resolvers.d.cts +14 -0
  51. package/dist/resolvers.d.ts +14 -0
  52. package/dist/resolvers.js +1 -1
  53. package/dist/testing.cjs +2 -2
  54. package/dist/testing.d.cts +4 -4
  55. package/dist/testing.d.ts +4 -4
  56. package/dist/testing.js +1 -1
  57. package/dist/vm.d.cts +3 -3
  58. package/dist/vm.d.ts +3 -3
  59. package/dist/worker.cjs +2 -2
  60. package/dist/worker.d.cts +3 -3
  61. package/dist/worker.d.ts +3 -3
  62. package/dist/worker.js +1 -1
  63. package/package.json +1 -1
  64. package/dist/chunk-4E4YVQKK.js +0 -5
  65. package/dist/chunk-4E4YVQKK.js.map +0 -1
  66. package/dist/chunk-7GK3XEZF.js.map +0 -1
  67. package/dist/chunk-E2Q3PQ2G.js +0 -3
  68. package/dist/chunk-E2Q3PQ2G.js.map +0 -1
  69. package/dist/chunk-EVI6OHQH.cjs +0 -2
  70. package/dist/chunk-EVI6OHQH.cjs.map +0 -1
  71. package/dist/chunk-GK2OHWRF.cjs +0 -5
  72. package/dist/chunk-GK2OHWRF.cjs.map +0 -1
  73. package/dist/chunk-I52MYCVI.js +0 -3
  74. package/dist/chunk-I52MYCVI.js.map +0 -1
  75. package/dist/chunk-JUIJ6NRD.cjs.map +0 -1
  76. package/dist/chunk-OVKDDTXO.cjs +0 -3
  77. package/dist/chunk-OVKDDTXO.cjs.map +0 -1
  78. package/dist/chunk-U4AEVL5Z.js +0 -2
  79. package/dist/chunk-U4AEVL5Z.js.map +0 -1
  80. package/dist/chunk-ZCNBT44X.cjs.map +0 -1
package/dist/engine.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- import { D as DocumentModel, E as ExpressionEngine, V as ViewportRange, L as LineChange, p as InlineSolvePosition } from './PackageRegistry-DzeiWcv4.js';
2
- export { A as ApplyChangesResult, q as AsyncCachePackageInfo, r as AsyncErrorEvent, s as AsyncResolutionBatcher, t as AsyncResolutionEvent, B as BatcherMetrics, u as BytecodeCacheEntry, C as CacheSnapshot, v as CheckpointSnapshot, a as EngineOptions, b as EngineRestoreOptions, c as EngineSnapshot, d as Explanation, e as ExplanationStep, w as LineCacheEntryInfo, x as LineState, y as LinesUpdatedEvent, S as SNAPSHOT_FORMAT, f as SNAPSHOT_VERSION, g as SerializedAnonymousBody, h as SerializedBytecode, i as SerializedDecimal, j as SerializedLineCacheEntry, k as SerializedNumber, l as SerializedRational, m as SerializedUserFunction, n as SerializedValue, o as SnapshotErrorCodes } from './PackageRegistry-DzeiWcv4.js';
1
+ import { D as DocumentModel, E as ExpressionEngine, V as ViewportRange, r as LineChange, U as UnifiedParsingOptions, P as ParsingResult, s as InlineSolvePosition } from './PackageRegistry-jqdAsm6U.js';
2
+ export { A as ApplyChangesResult, t as AsyncCachePackageInfo, u as AsyncErrorEvent, v as AsyncResolutionBatcher, w as AsyncResolutionEvent, B as BatcherMetrics, x as BytecodeCacheEntry, y as CacheSnapshot, z as CheckpointSnapshot, a as EngineOptions, b as EngineRestoreOptions, c as EngineSnapshot, d as Explanation, e as ExplanationStep, F as LineCacheEntryInfo, G as LineState, H as LinesUpdatedEvent, J as ParsedLine, S as SNAPSHOT_FORMAT, f as SNAPSHOT_VERSION, g as SerializedAnonymousBody, h as SerializedBytecode, i as SerializedDecimal, j as SerializedLineCacheEntry, k as SerializedNumber, l as SerializedRational, m as SerializedUserFunction, n as SerializedValue, o as SnapshotErrorCodes } from './PackageRegistry-jqdAsm6U.js';
3
3
  import { V as Value } from './Value-CCi_Eecs.js';
4
- import { V as VMCheckpointer } from './VMCheckpoints-CGyFhivM.js';
4
+ import { a as VMCheckpointer } from './VMCheckpoints-CsHmQVaD.js';
5
5
  import { T as Token } from './Token-CbP_OutD.js';
6
6
  import { E as EngineError } from './EngineError-Ce1lPkjZ.js';
7
7
  import { a as BytecodeProgram } from './BytecodeBuilder-DGGeByAP.js';
8
- export { D as DagSnapshot } from './ScopeManager-C2LDOrDx.js';
8
+ export { a as DagSnapshot } from './ScopeManager-DkpnlKuz.js';
9
9
  import './Parselet-B-zoPrTa.js';
10
10
  import './pipeline-72QmQlGx.js';
11
11
  import './Lexer-DKMlj7Sy.js';
12
12
  import './resolvers.js';
13
13
  import '@tanstack/query-core';
14
14
  import './TokenNormalizer-DCWdZjGz.js';
15
- import './Configuration-B6W0-T67.js';
15
+ import './Configuration-Culg8H_o.js';
16
16
 
17
17
  /**
18
18
  * PageManager, page-based LRU eviction + directional preloading.
@@ -496,6 +496,49 @@ declare class ThreeTierEvaluator {
496
496
  private extractExpressions;
497
497
  }
498
498
 
499
+ /**
500
+ * Whole-document evaluation through the incremental engine.
501
+ *
502
+ * The engine has two ways to read a document, and they are not interchangeable.
503
+ * {@link ExpressionEngine.parseDocument} is the light batch pass: it scans the
504
+ * text, reads earlier lines' results, and skips markdown, which is everything
505
+ * line references, category tags and table columns need. What it has no way to
506
+ * do is re-run an earlier line with a variable bound to a trial value, which is
507
+ * exactly what goal seek (`solve line N for x = target`) is, so goal seek comes
508
+ * back as a `GOAL_SEEK_NO_DOCUMENT` error through `parseDocument`.
509
+ *
510
+ * The re-run primitive lives on the incremental `DocumentModel` +
511
+ * `ThreeTierEvaluator` path (a live editor drives it on every keystroke). This
512
+ * helper stands that path up for a single pass and hands back the familiar
513
+ * {@link ParsingResult}, so a caller reads the answers exactly as it would from
514
+ * `parseDocument`, goal seek included. A documentation notepad that wants goal
515
+ * seek to resolve, and the tests that prove those examples, both go through
516
+ * here.
517
+ *
518
+ * Two boundaries, each deliberate:
519
+ *
520
+ * - It builds a fresh model and evaluator per call and disposes the evaluator
521
+ * before returning, which suits occasional evaluation, not the keystroke loop
522
+ * a real editor runs against one long-lived `ThreeTierEvaluator`.
523
+ * - Unlike `parseDocument`, it does not classify a markdown table's own rows as
524
+ * skippable: they reach the evaluator as expressions and error. A document
525
+ * that mixes a raw table with goal seek is the one case that wants both paths,
526
+ * the table read through `parseDocument` and the goal seek through here.
527
+ */
528
+
529
+ /**
530
+ * Evaluate a whole document with full cross-line context, including the line
531
+ * re-runs goal seek needs, and return per-line results in the same shape
532
+ * {@link ExpressionEngine.parseDocument} produces.
533
+ *
534
+ * @param engine - The engine to borrow for the pass. Its current document model
535
+ * (if any) is restored before returning.
536
+ * @param input - The document text, newline-separated.
537
+ * @param _options - Accepted so a call reads the same as `parseDocument`'s, but
538
+ * not consulted: the incremental pass reads the document as markdown regardless.
539
+ */
540
+ declare function evaluateDocument(engine: ExpressionEngine, input: string, _options?: UnifiedParsingOptions): ParsingResult;
541
+
499
542
  /** Bounds applied to input before parsing: length and nesting depth. */
500
543
  interface ValidationConfig {
501
544
  maxExpressionLength: number;
@@ -599,4 +642,4 @@ declare function isEmptyLine(lineText: string): boolean;
599
642
  */
600
643
  declare function findInlineSolvesInLine(lineText: string, lineNumber: number): InlineSolvePosition[];
601
644
 
602
- export { DocumentModel, type EvalLineResult, type EvalResult, EvalTier, ExpressionEngine, InlineSolvePosition, LineChange, type SafetyCheckResult, ThreeTierEvaluator, type ValidationConfig, ViewportRange, checkExpressionComplexity, checkExpressionLength, extractReadsAndWrites, findInlineSolvesInLine, isEmptyLine };
645
+ export { DocumentModel, type EvalLineResult, type EvalResult, EvalTier, ExpressionEngine, InlineSolvePosition, LineChange, ParsingResult, type SafetyCheckResult, ThreeTierEvaluator, UnifiedParsingOptions, type ValidationConfig, ViewportRange, checkExpressionComplexity, checkExpressionLength, evaluateDocument, extractReadsAndWrites, findInlineSolvesInLine, isEmptyLine };
package/dist/engine.js CHANGED
@@ -1,2 +1,2 @@
1
- export{a as DocumentModel,b as EvalTier,c as ThreeTierEvaluator}from'./chunk-I52MYCVI.js';import'./chunk-RAF57WYO.js';export{h as AsyncResolutionBatcher,n as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,j as checkExpressionComplexity,i as checkExpressionLength,k as extractReadsAndWrites,m as findInlineSolvesInLine,l as isEmptyLine}from'./chunk-4E4YVQKK.js';import'./chunk-XNIWQHXY.js';import'./chunk-2RWAXT6O.js';import'./chunk-7GK3XEZF.js';import'./chunk-MIQBJGGR.js';import'./chunk-YJ2OPULK.js';import'./chunk-TWC7K3ZX.js';import'./chunk-J4LZD4ZY.js';import'./chunk-XEIDV5JP.js';import'./chunk-TN5E6JU6.js';import'./chunk-YVKHEAFT.js';import'./chunk-5FO4PDIG.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-W2JAR233.js';import'./chunk-YAYBVVG2.js';import'./chunk-E6Z4NQAS.js';import'./chunk-HFKDWQUL.js';import'./chunk-R2ENWQ76.js';import'./chunk-RSF25YSJ.js';import'./chunk-EVAOPEO4.js';import'./chunk-WGZ3FNHI.js';import'./chunk-U4AEVL5Z.js';import'./chunk-YAHGSBMC.js';import'./chunk-JPFCXLJV.js';import'./chunk-G7TBEQRQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-TRBXW6HW.js';import'./chunk-2JMFUQZH.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=engine.js.map
1
+ export{a as DocumentModel,b as EvalTier,c as ThreeTierEvaluator,d as evaluateDocument}from'./chunk-PXWOATTF.js';import'./chunk-RAF57WYO.js';export{h as AsyncResolutionBatcher,n as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,j as checkExpressionComplexity,i as checkExpressionLength,k as extractReadsAndWrites,m as findInlineSolvesInLine,l as isEmptyLine}from'./chunk-NNYMXK6H.js';import'./chunk-XNIWQHXY.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-YJ2OPULK.js';import'./chunk-TWC7K3ZX.js';import'./chunk-J4LZD4ZY.js';import'./chunk-XEIDV5JP.js';import'./chunk-TN5E6JU6.js';import'./chunk-YVKHEAFT.js';import'./chunk-5FO4PDIG.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-W2JAR233.js';import'./chunk-YAYBVVG2.js';import'./chunk-E6Z4NQAS.js';import'./chunk-HFKDWQUL.js';import'./chunk-R2ENWQ76.js';import'./chunk-RSF25YSJ.js';import'./chunk-EVAOPEO4.js';import'./chunk-WGZ3FNHI.js';import'./chunk-ESXQDRP7.js';import'./chunk-YAHGSBMC.js';import'./chunk-JPFCXLJV.js';import'./chunk-G7TBEQRQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-TRBXW6HW.js';import'./chunk-2JMFUQZH.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=engine.js.map
2
2
  //# sourceMappingURL=engine.js.map
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';require('./chunk-JUIJ6NRD.cjs'),require('./chunk-EFJCC6FJ.cjs');var chunkGK2OHWRF_cjs=require('./chunk-GK2OHWRF.cjs');require('./chunk-FDE5HWDI.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-ZCNBT44X.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-SYYE3QAX.cjs'),require('./chunk-AXMQG5TS.cjs'),require('./chunk-HLBYHXQD.cjs'),require('./chunk-R2SZFJTT.cjs');var chunkOVKDDTXO_cjs=require('./chunk-OVKDDTXO.cjs');require('./chunk-6INX773F.cjs'),require('./chunk-7BXPCWKM.cjs');var chunk4QVBSG6B_cjs=require('./chunk-4QVBSG6B.cjs');require('./chunk-VAGS5JS7.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-JAK3RAFA.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-JFAJN3C2.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-ESUN2THE.cjs'),require('./chunk-N7N7MPMK.cjs');var chunkPS272DZJ_cjs=require('./chunk-PS272DZJ.cjs');require('./chunk-IANAMBJQ.cjs');var chunkEVI6OHQH_cjs=require('./chunk-EVI6OHQH.cjs');require('./chunk-32GC2FHC.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-2LFLR3VZ.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-FWW3M36J.cjs'),require('./chunk-CIQOK7Q4.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.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"},b=/^[a-z_][a-z0-9_]*$/i,y=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function f(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 A(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 chunkSOMGSIO4_cjs.c.execution({code:r.DEFINE_FUNCTION_ARGUMENT_TYPE,message:`${t}() expects "${n.name}" to be a ${n.type}, but was given ${f(e)}`,expected:`a ${n.type}`,found:f(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function S(e,n,t){switch(n){case "number":if(typeof e=="number")return chunkPS272DZJ_cjs.n(e);break;case "string":if(typeof e=="string")return chunkPS272DZJ_cjs.t(e);break;case "boolean":if(typeof e=="boolean")return chunkPS272DZJ_cjs.J(e);break}throw chunkSOMGSIO4_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,i){n.consume("LPAREN");let a=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,i),a++;n.match("COMMA");)n.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,i),a++;n.consume("RPAREN"),i.emitPluginCall(this.fnName,a);}};function P(e){let n=e.args.length;return t=>{if(t.length!==n)throw chunkSOMGSIO4_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 i=new Array(n);for(let s=0;s<n;s++)i[s]=A(t[s],e.args[s],e.name);let a=e.call(...i);return S(a,e.returns,e.name)}}function V(e){if(typeof e?.name!="string"||!b.test(e.name))throw chunkSOMGSIO4_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 chunkSOMGSIO4_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 chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has an argument with no name`,context:{name:e.name}});if(!y.has(n.type))throw chunkSOMGSIO4_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(!y.has(e.returns))throw chunkSOMGSIO4_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 chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" is missing a call implementation`,context:{name:e.name}})}function O(e){V(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]:P(e)}}}function h(e={}){let{extraPackages:n=[],...t}=e;return new chunkGK2OHWRF_cjs.n({...t,packages:n.length>0?[...chunkOVKDDTXO_cjs.y,...n]:chunkOVKDDTXO_cjs.y})}Object.defineProperty(exports,"ExpressionEngine",{enumerable:true,get:function(){return chunkGK2OHWRF_cjs.n}});Object.defineProperty(exports,"SNAPSHOT_FORMAT",{enumerable:true,get:function(){return chunkGK2OHWRF_cjs.d}});Object.defineProperty(exports,"SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunkGK2OHWRF_cjs.e}});Object.defineProperty(exports,"SnapshotErrorCodes",{enumerable:true,get:function(){return chunkGK2OHWRF_cjs.f}});Object.defineProperty(exports,"assertEngineVersionCompatible",{enumerable:true,get:function(){return chunkGK2OHWRF_cjs.c}});Object.defineProperty(exports,"checkEngineVersionCompatibility",{enumerable:true,get:function(){return chunkGK2OHWRF_cjs.b}});Object.defineProperty(exports,"checkPackageCompatibility",{enumerable:true,get:function(){return chunkGK2OHWRF_cjs.a}});Object.defineProperty(exports,"ENGINE_VERSION",{enumerable:true,get:function(){return chunkEVI6OHQH_cjs.a}});exports.DefineFunctionErrorCodes=r;exports.createEngine=h;exports.defineFunction=O;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';require('./chunk-PBGPQM3X.cjs'),require('./chunk-EFJCC6FJ.cjs');var chunkL7ZQQ773_cjs=require('./chunk-L7ZQQ773.cjs');require('./chunk-FDE5HWDI.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-SYYE3QAX.cjs'),require('./chunk-AXMQG5TS.cjs'),require('./chunk-HLBYHXQD.cjs'),require('./chunk-R2SZFJTT.cjs');var chunkJFREB45J_cjs=require('./chunk-JFREB45J.cjs');require('./chunk-6INX773F.cjs'),require('./chunk-7BXPCWKM.cjs');var chunk4QVBSG6B_cjs=require('./chunk-4QVBSG6B.cjs');require('./chunk-VAGS5JS7.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-JAK3RAFA.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-JFAJN3C2.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-ESUN2THE.cjs'),require('./chunk-N7N7MPMK.cjs');var chunkPS272DZJ_cjs=require('./chunk-PS272DZJ.cjs');require('./chunk-IANAMBJQ.cjs');var chunkBAVZMGTZ_cjs=require('./chunk-BAVZMGTZ.cjs');require('./chunk-32GC2FHC.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-2LFLR3VZ.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-FWW3M36J.cjs'),require('./chunk-CIQOK7Q4.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.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"},b=/^[a-z_][a-z0-9_]*$/i,y=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function f(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 A(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 chunkSOMGSIO4_cjs.c.execution({code:r.DEFINE_FUNCTION_ARGUMENT_TYPE,message:`${t}() expects "${n.name}" to be a ${n.type}, but was given ${f(e)}`,expected:`a ${n.type}`,found:f(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function S(e,n,t){switch(n){case "number":if(typeof e=="number")return chunkPS272DZJ_cjs.n(e);break;case "string":if(typeof e=="string")return chunkPS272DZJ_cjs.t(e);break;case "boolean":if(typeof e=="boolean")return chunkPS272DZJ_cjs.J(e);break}throw chunkSOMGSIO4_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,i){n.consume("LPAREN");let a=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,i),a++;n.match("COMMA");)n.parseExpression(chunk4QVBSG6B_cjs.a.Lowest,i),a++;n.consume("RPAREN"),i.emitPluginCall(this.fnName,a);}};function P(e){let n=e.args.length;return t=>{if(t.length!==n)throw chunkSOMGSIO4_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 i=new Array(n);for(let s=0;s<n;s++)i[s]=A(t[s],e.args[s],e.name);let a=e.call(...i);return S(a,e.returns,e.name)}}function V(e){if(typeof e?.name!="string"||!b.test(e.name))throw chunkSOMGSIO4_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 chunkSOMGSIO4_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 chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has an argument with no name`,context:{name:e.name}});if(!y.has(n.type))throw chunkSOMGSIO4_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(!y.has(e.returns))throw chunkSOMGSIO4_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 chunkSOMGSIO4_cjs.c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" is missing a call implementation`,context:{name:e.name}})}function O(e){V(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]:P(e)}}}function h(e={}){let{extraPackages:n=[],...t}=e;return new chunkL7ZQQ773_cjs.n({...t,packages:n.length>0?[...chunkJFREB45J_cjs.y,...n]:chunkJFREB45J_cjs.y})}Object.defineProperty(exports,"ExpressionEngine",{enumerable:true,get:function(){return chunkL7ZQQ773_cjs.n}});Object.defineProperty(exports,"SNAPSHOT_FORMAT",{enumerable:true,get:function(){return chunkL7ZQQ773_cjs.d}});Object.defineProperty(exports,"SNAPSHOT_VERSION",{enumerable:true,get:function(){return chunkL7ZQQ773_cjs.e}});Object.defineProperty(exports,"SnapshotErrorCodes",{enumerable:true,get:function(){return chunkL7ZQQ773_cjs.f}});Object.defineProperty(exports,"assertEngineVersionCompatible",{enumerable:true,get:function(){return chunkL7ZQQ773_cjs.c}});Object.defineProperty(exports,"checkEngineVersionCompatibility",{enumerable:true,get:function(){return chunkL7ZQQ773_cjs.b}});Object.defineProperty(exports,"checkPackageCompatibility",{enumerable:true,get:function(){return chunkL7ZQQ773_cjs.a}});Object.defineProperty(exports,"ENGINE_VERSION",{enumerable:true,get:function(){return chunkBAVZMGTZ_cjs.a}});exports.DefineFunctionErrorCodes=r;exports.createEngine=h;exports.defineFunction=O;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-dpdurBVO.cjs';
2
- export { b as EngineRestoreOptions, c as EngineSnapshot, d as Explanation, e as ExplanationStep, S as SNAPSHOT_FORMAT, f as SNAPSHOT_VERSION, g as SerializedAnonymousBody, h as SerializedBytecode, i as SerializedDecimal, j as SerializedLineCacheEntry, k as SerializedNumber, l as SerializedRational, m as SerializedUserFunction, n as SerializedValue, o as SnapshotErrorCodes } from './PackageRegistry-dpdurBVO.cjs';
3
- export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-Bn5jnBtA.cjs';
4
- export { E as EngineConfigOverride } from './Configuration-B6W0-T67.cjs';
1
+ import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-DXsvmpQN.cjs';
2
+ export { b as EngineRestoreOptions, c as EngineSnapshot, d as Explanation, e as ExplanationStep, S as SNAPSHOT_FORMAT, f as SNAPSHOT_VERSION, g as SerializedAnonymousBody, h as SerializedBytecode, i as SerializedDecimal, j as SerializedLineCacheEntry, k as SerializedNumber, l as SerializedRational, m as SerializedUserFunction, n as SerializedValue, o as SnapshotErrorCodes } from './PackageRegistry-DXsvmpQN.cjs';
3
+ export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-CN-2CVhu.cjs';
4
+ export { E as EngineConfigOverride } from './Configuration-Culg8H_o.cjs';
5
5
  export { ENGINE_VERSION } from './constants.cjs';
6
6
  import './Parselet-C4Wu055_.cjs';
7
7
  import './BytecodeBuilder-DGGeByAP.cjs';
@@ -12,7 +12,7 @@ import './Lexer-B4C1qHXu.cjs';
12
12
  import './resolvers.cjs';
13
13
  import '@tanstack/query-core';
14
14
  import './TokenNormalizer-DnlL7_8c.cjs';
15
- import './ScopeManager-D7uMXbhS.cjs';
15
+ import './ScopeManager-t6SnP6Ce.cjs';
16
16
  import './EngineError-Ce1lPkjZ.cjs';
17
17
 
18
18
  /**
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-DzeiWcv4.js';
2
- export { b as EngineRestoreOptions, c as EngineSnapshot, d as Explanation, e as ExplanationStep, S as SNAPSHOT_FORMAT, f as SNAPSHOT_VERSION, g as SerializedAnonymousBody, h as SerializedBytecode, i as SerializedDecimal, j as SerializedLineCacheEntry, k as SerializedNumber, l as SerializedRational, m as SerializedUserFunction, n as SerializedValue, o as SnapshotErrorCodes } from './PackageRegistry-DzeiWcv4.js';
3
- export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-CIvq2MP5.js';
4
- export { E as EngineConfigOverride } from './Configuration-B6W0-T67.js';
1
+ import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-jqdAsm6U.js';
2
+ export { b as EngineRestoreOptions, c as EngineSnapshot, d as Explanation, e as ExplanationStep, S as SNAPSHOT_FORMAT, f as SNAPSHOT_VERSION, g as SerializedAnonymousBody, h as SerializedBytecode, i as SerializedDecimal, j as SerializedLineCacheEntry, k as SerializedNumber, l as SerializedRational, m as SerializedUserFunction, n as SerializedValue, o as SnapshotErrorCodes } from './PackageRegistry-jqdAsm6U.js';
3
+ export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-DbpyKYOe.js';
4
+ export { E as EngineConfigOverride } from './Configuration-Culg8H_o.js';
5
5
  export { ENGINE_VERSION } from './constants.js';
6
6
  import './Parselet-B-zoPrTa.js';
7
7
  import './BytecodeBuilder-DGGeByAP.js';
@@ -12,7 +12,7 @@ import './Lexer-DKMlj7Sy.js';
12
12
  import './resolvers.js';
13
13
  import '@tanstack/query-core';
14
14
  import './TokenNormalizer-DCWdZjGz.js';
15
- import './ScopeManager-C2LDOrDx.js';
15
+ import './ScopeManager-DkpnlKuz.js';
16
16
  import './EngineError-Ce1lPkjZ.js';
17
17
 
18
18
  /**
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import'./chunk-I52MYCVI.js';import'./chunk-RAF57WYO.js';import {n}from'./chunk-4E4YVQKK.js';export{n as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,c as assertEngineVersionCompatible,b as checkEngineVersionCompatibility,a as checkPackageCompatibility}from'./chunk-4E4YVQKK.js';import'./chunk-XNIWQHXY.js';import'./chunk-2RWAXT6O.js';import'./chunk-7GK3XEZF.js';import'./chunk-MIQBJGGR.js';import'./chunk-YJ2OPULK.js';import'./chunk-TWC7K3ZX.js';import'./chunk-J4LZD4ZY.js';import'./chunk-XEIDV5JP.js';import {y as y$1}from'./chunk-E2Q3PQ2G.js';import'./chunk-6G3PMEPA.js';import'./chunk-TN5E6JU6.js';import {a}from'./chunk-YVKHEAFT.js';import'./chunk-5FO4PDIG.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-W2JAR233.js';import'./chunk-YAYBVVG2.js';import'./chunk-E6Z4NQAS.js';import'./chunk-HFKDWQUL.js';import'./chunk-R2ENWQ76.js';import'./chunk-RSF25YSJ.js';import {J,t,n as n$1}from'./chunk-EVAOPEO4.js';import'./chunk-WGZ3FNHI.js';export{a as ENGINE_VERSION}from'./chunk-U4AEVL5Z.js';import'./chunk-YAHGSBMC.js';import'./chunk-JPFCXLJV.js';import'./chunk-G7TBEQRQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-TRBXW6HW.js';import'./chunk-2JMFUQZH.js';import {c}from'./chunk-MPB7KUN5.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"},b=/^[a-z_][a-z0-9_]*$/i,y=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function f(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 A(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 ${f(e)}`,expected:`a ${n.type}`,found:f(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function S(e,n,t$1){switch(n){case "number":if(typeof e=="number")return n$1(e);break;case "string":if(typeof e=="string")return t(e);break;case "boolean":if(typeof e=="boolean")return J(e);break}throw c.internal({code:r.DEFINE_FUNCTION_RETURN_TYPE,message:`${t$1}() is declared to return a ${n}, but its implementation returned ${typeof e}`,expected:`a ${n}`,found:typeof e,context:{functionName:t$1,expectedType:n}})}var p=class{constructor(n){this.fnName=n;this.category="Function";}parse(n,t,i){n.consume("LPAREN");let a$1=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(a.Lowest,i),a$1++;n.match("COMMA");)n.parseExpression(a.Lowest,i),a$1++;n.consume("RPAREN"),i.emitPluginCall(this.fnName,a$1);}};function P(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 i=new Array(n);for(let s=0;s<n;s++)i[s]=A(t[s],e.args[s],e.name);let a=e.call(...i);return S(a,e.returns,e.name)}}function V(e){if(typeof e?.name!="string"||!b.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(!y.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(!y.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 O(e){V(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]:P(e)}}}function h(e={}){let{extraPackages:n$1=[],...t}=e;return new n({...t,packages:n$1.length>0?[...y$1,...n$1]:y$1})}export{r as DefineFunctionErrorCodes,h as createEngine,O as defineFunction};//# sourceMappingURL=index.js.map
1
+ import'./chunk-PXWOATTF.js';import'./chunk-RAF57WYO.js';import {n}from'./chunk-NNYMXK6H.js';export{n as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,c as assertEngineVersionCompatible,b as checkEngineVersionCompatibility,a as checkPackageCompatibility}from'./chunk-NNYMXK6H.js';import'./chunk-XNIWQHXY.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-YJ2OPULK.js';import'./chunk-TWC7K3ZX.js';import'./chunk-J4LZD4ZY.js';import'./chunk-XEIDV5JP.js';import {y as y$1}from'./chunk-AIIPKVKO.js';import'./chunk-6G3PMEPA.js';import'./chunk-TN5E6JU6.js';import {a}from'./chunk-YVKHEAFT.js';import'./chunk-5FO4PDIG.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-W2JAR233.js';import'./chunk-YAYBVVG2.js';import'./chunk-E6Z4NQAS.js';import'./chunk-HFKDWQUL.js';import'./chunk-R2ENWQ76.js';import'./chunk-RSF25YSJ.js';import {J,t,n as n$1}from'./chunk-EVAOPEO4.js';import'./chunk-WGZ3FNHI.js';export{a as ENGINE_VERSION}from'./chunk-ESXQDRP7.js';import'./chunk-YAHGSBMC.js';import'./chunk-JPFCXLJV.js';import'./chunk-G7TBEQRQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-TRBXW6HW.js';import'./chunk-2JMFUQZH.js';import {c}from'./chunk-MPB7KUN5.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"},b=/^[a-z_][a-z0-9_]*$/i,y=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function f(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 A(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 ${f(e)}`,expected:`a ${n.type}`,found:f(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function S(e,n,t$1){switch(n){case "number":if(typeof e=="number")return n$1(e);break;case "string":if(typeof e=="string")return t(e);break;case "boolean":if(typeof e=="boolean")return J(e);break}throw c.internal({code:r.DEFINE_FUNCTION_RETURN_TYPE,message:`${t$1}() is declared to return a ${n}, but its implementation returned ${typeof e}`,expected:`a ${n}`,found:typeof e,context:{functionName:t$1,expectedType:n}})}var p=class{constructor(n){this.fnName=n;this.category="Function";}parse(n,t,i){n.consume("LPAREN");let a$1=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(a.Lowest,i),a$1++;n.match("COMMA");)n.parseExpression(a.Lowest,i),a$1++;n.consume("RPAREN"),i.emitPluginCall(this.fnName,a$1);}};function P(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 i=new Array(n);for(let s=0;s<n;s++)i[s]=A(t[s],e.args[s],e.name);let a=e.call(...i);return S(a,e.returns,e.name)}}function V(e){if(typeof e?.name!="string"||!b.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(!y.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(!y.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 O(e){V(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]:P(e)}}}function h(e={}){let{extraPackages:n$1=[],...t}=e;return new n({...t,packages:n$1.length>0?[...y$1,...n$1]:y$1})}export{r as DefineFunctionErrorCodes,h as createEngine,O as defineFunction};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
- import { z as CompletionItem } from './PackageRegistry-dpdurBVO.cjs';
2
- export { F as LanguageService, G as LanguageServiceOptions, H as SemanticToken } from './PackageRegistry-dpdurBVO.cjs';
1
+ import { C as CompletionItem } from './PackageRegistry-DXsvmpQN.cjs';
2
+ export { L as LanguageService, p as LanguageServiceOptions, q as SemanticToken } from './PackageRegistry-DXsvmpQN.cjs';
3
3
  import { e as TokenCategory } from './Lexer-B4C1qHXu.cjs';
4
4
  import './Parselet-C4Wu055_.cjs';
5
5
  import './BytecodeBuilder-DGGeByAP.cjs';
@@ -9,9 +9,9 @@ import './Value-CCi_Eecs.cjs';
9
9
  import './resolvers.cjs';
10
10
  import '@tanstack/query-core';
11
11
  import './TokenNormalizer-DnlL7_8c.cjs';
12
- import './ScopeManager-D7uMXbhS.cjs';
12
+ import './ScopeManager-t6SnP6Ce.cjs';
13
13
  import './EngineError-Ce1lPkjZ.cjs';
14
- import './Configuration-B6W0-T67.cjs';
14
+ import './Configuration-Culg8H_o.cjs';
15
15
 
16
16
  /**
17
17
  * Token types intentionally left uncategorized, either purely structural
@@ -1,5 +1,5 @@
1
- import { z as CompletionItem } from './PackageRegistry-DzeiWcv4.js';
2
- export { F as LanguageService, G as LanguageServiceOptions, H as SemanticToken } from './PackageRegistry-DzeiWcv4.js';
1
+ import { C as CompletionItem } from './PackageRegistry-jqdAsm6U.js';
2
+ export { L as LanguageService, p as LanguageServiceOptions, q as SemanticToken } from './PackageRegistry-jqdAsm6U.js';
3
3
  import { e as TokenCategory } from './Lexer-DKMlj7Sy.js';
4
4
  import './Parselet-B-zoPrTa.js';
5
5
  import './BytecodeBuilder-DGGeByAP.js';
@@ -9,9 +9,9 @@ import './Value-CCi_Eecs.js';
9
9
  import './resolvers.js';
10
10
  import '@tanstack/query-core';
11
11
  import './TokenNormalizer-DCWdZjGz.js';
12
- import './ScopeManager-C2LDOrDx.js';
12
+ import './ScopeManager-DkpnlKuz.js';
13
13
  import './EngineError-Ce1lPkjZ.js';
14
- import './Configuration-B6W0-T67.js';
14
+ import './Configuration-Culg8H_o.js';
15
15
 
16
16
  /**
17
17
  * Token types intentionally left uncategorized, either purely structural
package/dist/packages.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkOVKDDTXO_cjs=require('./chunk-OVKDDTXO.cjs');require('./chunk-6INX773F.cjs');var chunk7BXPCWKM_cjs=require('./chunk-7BXPCWKM.cjs');require('./chunk-4QVBSG6B.cjs'),require('./chunk-VAGS5JS7.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-JAK3RAFA.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-JFAJN3C2.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-ESUN2THE.cjs'),require('./chunk-N7N7MPMK.cjs'),require('./chunk-PS272DZJ.cjs'),require('./chunk-IANAMBJQ.cjs'),require('./chunk-2LFLR3VZ.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-FWW3M36J.cjs'),require('./chunk-CIQOK7Q4.cjs'),require('./chunk-SOMGSIO4.cjs');Object.defineProperty(exports,"ARITHMETIC_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.a}});Object.defineProperty(exports,"BIGINT_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.n}});Object.defineProperty(exports,"BUILTIN_PACKAGES",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.y}});Object.defineProperty(exports,"CONDITIONALS_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.o}});Object.defineProperty(exports,"CONVERTERS_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.p}});Object.defineProperty(exports,"CURRENCY_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.j}});Object.defineProperty(exports,"DATETIME_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.d}});Object.defineProperty(exports,"DICE_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.f}});Object.defineProperty(exports,"FINANCE_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.r}});Object.defineProperty(exports,"FUNCTION_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.c}});Object.defineProperty(exports,"LINES_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.v}});Object.defineProperty(exports,"MAPREDUCE_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.m}});Object.defineProperty(exports,"MATHPHRASES_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.q}});Object.defineProperty(exports,"MATRIX_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.l}});Object.defineProperty(exports,"PERCENTAGE_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.b}});Object.defineProperty(exports,"TABLES_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.w}});Object.defineProperty(exports,"TAGS_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.x}});Object.defineProperty(exports,"TIME_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.e}});Object.defineProperty(exports,"UOM_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.h}});Object.defineProperty(exports,"VARIABLES_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.g}});Object.defineProperty(exports,"VECTOR_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.k}});Object.defineProperty(exports,"WEATHER_PACKAGE",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.s}});Object.defineProperty(exports,"createCurrencyPackage",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.i}});Object.defineProperty(exports,"createKnowledgePackage",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.u}});Object.defineProperty(exports,"createStocksPackage",{enumerable:true,get:function(){return chunkOVKDDTXO_cjs.t}});Object.defineProperty(exports,"SYMBOLIC_PACKAGE",{enumerable:true,get:function(){return chunk7BXPCWKM_cjs.a}});//# sourceMappingURL=packages.cjs.map
1
+ 'use strict';var chunkJFREB45J_cjs=require('./chunk-JFREB45J.cjs');require('./chunk-6INX773F.cjs');var chunk7BXPCWKM_cjs=require('./chunk-7BXPCWKM.cjs');require('./chunk-4QVBSG6B.cjs'),require('./chunk-VAGS5JS7.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-JAK3RAFA.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-JFAJN3C2.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-ESUN2THE.cjs'),require('./chunk-N7N7MPMK.cjs'),require('./chunk-PS272DZJ.cjs'),require('./chunk-IANAMBJQ.cjs'),require('./chunk-2LFLR3VZ.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-FWW3M36J.cjs'),require('./chunk-CIQOK7Q4.cjs'),require('./chunk-SOMGSIO4.cjs');Object.defineProperty(exports,"ARITHMETIC_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.a}});Object.defineProperty(exports,"BIGINT_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.n}});Object.defineProperty(exports,"BUILTIN_PACKAGES",{enumerable:true,get:function(){return chunkJFREB45J_cjs.y}});Object.defineProperty(exports,"CONDITIONALS_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.o}});Object.defineProperty(exports,"CONVERTERS_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.p}});Object.defineProperty(exports,"CURRENCY_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.j}});Object.defineProperty(exports,"DATETIME_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.d}});Object.defineProperty(exports,"DICE_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.f}});Object.defineProperty(exports,"FINANCE_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.r}});Object.defineProperty(exports,"FUNCTION_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.c}});Object.defineProperty(exports,"LINES_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.v}});Object.defineProperty(exports,"MAPREDUCE_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.m}});Object.defineProperty(exports,"MATHPHRASES_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.q}});Object.defineProperty(exports,"MATRIX_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.l}});Object.defineProperty(exports,"PERCENTAGE_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.b}});Object.defineProperty(exports,"TABLES_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.w}});Object.defineProperty(exports,"TAGS_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.x}});Object.defineProperty(exports,"TIME_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.e}});Object.defineProperty(exports,"UOM_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.h}});Object.defineProperty(exports,"VARIABLES_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.g}});Object.defineProperty(exports,"VECTOR_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.k}});Object.defineProperty(exports,"WEATHER_PACKAGE",{enumerable:true,get:function(){return chunkJFREB45J_cjs.s}});Object.defineProperty(exports,"createCurrencyPackage",{enumerable:true,get:function(){return chunkJFREB45J_cjs.i}});Object.defineProperty(exports,"createKnowledgePackage",{enumerable:true,get:function(){return chunkJFREB45J_cjs.u}});Object.defineProperty(exports,"createStocksPackage",{enumerable:true,get:function(){return chunkJFREB45J_cjs.t}});Object.defineProperty(exports,"SYMBOLIC_PACKAGE",{enumerable:true,get:function(){return chunk7BXPCWKM_cjs.a}});//# sourceMappingURL=packages.cjs.map
2
2
  //# sourceMappingURL=packages.cjs.map
@@ -1,4 +1,4 @@
1
- import { I as IEnginePackage } from './PackageRegistry-dpdurBVO.cjs';
1
+ import { I as IEnginePackage } from './PackageRegistry-DXsvmpQN.cjs';
2
2
  import './Parselet-C4Wu055_.cjs';
3
3
  import './BytecodeBuilder-DGGeByAP.cjs';
4
4
  import './Token-CbP_OutD.cjs';
@@ -8,9 +8,9 @@ import './Lexer-B4C1qHXu.cjs';
8
8
  import './resolvers.cjs';
9
9
  import '@tanstack/query-core';
10
10
  import './TokenNormalizer-DnlL7_8c.cjs';
11
- import './ScopeManager-D7uMXbhS.cjs';
11
+ import './ScopeManager-t6SnP6Ce.cjs';
12
12
  import './EngineError-Ce1lPkjZ.cjs';
13
- import './Configuration-B6W0-T67.cjs';
13
+ import './Configuration-Culg8H_o.cjs';
14
14
 
15
15
  /** Core arithmetic: numbers, `()` grouping, `pi`/`e` constants, `+ - * / % ^`, bitwise `<< >> & | ^`, and their `*_by` word forms. */
16
16
  declare const ARITHMETIC_PACKAGE: IEnginePackage;
@@ -544,6 +544,15 @@ interface StocksPackageConfig {
544
544
  * fetches, not because the data could go stale.
545
545
  */
546
546
  historicalStaleTimeMs?: number;
547
+ /**
548
+ * Cadence, in ms, for proactive background refresh of a CURRENT quote that
549
+ * is on screen (say `60_000` to refresh a live price once a minute). Omit
550
+ * (the default) to keep the current quote pull-only, refreshing on the next
551
+ * re-evaluation once stale. It applies only to the current-price resolver, a
552
+ * historical close never refreshes, and takes effect only when the engine has
553
+ * `backgroundRefresh.enabled`.
554
+ */
555
+ refetchIntervalMs?: number;
547
556
  }
548
557
 
549
558
  /**
@@ -1,4 +1,4 @@
1
- import { I as IEnginePackage } from './PackageRegistry-DzeiWcv4.js';
1
+ import { I as IEnginePackage } from './PackageRegistry-jqdAsm6U.js';
2
2
  import './Parselet-B-zoPrTa.js';
3
3
  import './BytecodeBuilder-DGGeByAP.js';
4
4
  import './Token-CbP_OutD.js';
@@ -8,9 +8,9 @@ import './Lexer-DKMlj7Sy.js';
8
8
  import './resolvers.js';
9
9
  import '@tanstack/query-core';
10
10
  import './TokenNormalizer-DCWdZjGz.js';
11
- import './ScopeManager-C2LDOrDx.js';
11
+ import './ScopeManager-DkpnlKuz.js';
12
12
  import './EngineError-Ce1lPkjZ.js';
13
- import './Configuration-B6W0-T67.js';
13
+ import './Configuration-Culg8H_o.js';
14
14
 
15
15
  /** Core arithmetic: numbers, `()` grouping, `pi`/`e` constants, `+ - * / % ^`, bitwise `<< >> & | ^`, and their `*_by` word forms. */
16
16
  declare const ARITHMETIC_PACKAGE: IEnginePackage;
@@ -544,6 +544,15 @@ interface StocksPackageConfig {
544
544
  * fetches, not because the data could go stale.
545
545
  */
546
546
  historicalStaleTimeMs?: number;
547
+ /**
548
+ * Cadence, in ms, for proactive background refresh of a CURRENT quote that
549
+ * is on screen (say `60_000` to refresh a live price once a minute). Omit
550
+ * (the default) to keep the current quote pull-only, refreshing on the next
551
+ * re-evaluation once stale. It applies only to the current-price resolver, a
552
+ * historical close never refreshes, and takes effect only when the engine has
553
+ * `backgroundRefresh.enabled`.
554
+ */
555
+ refetchIntervalMs?: number;
547
556
  }
548
557
 
549
558
  /**
package/dist/packages.js CHANGED
@@ -1,2 +1,2 @@
1
- export{a as ARITHMETIC_PACKAGE,n as BIGINT_PACKAGE,y as BUILTIN_PACKAGES,o as CONDITIONALS_PACKAGE,p as CONVERTERS_PACKAGE,j as CURRENCY_PACKAGE,d as DATETIME_PACKAGE,f as DICE_PACKAGE,r as FINANCE_PACKAGE,c as FUNCTION_PACKAGE,v as LINES_PACKAGE,m as MAPREDUCE_PACKAGE,q as MATHPHRASES_PACKAGE,l as MATRIX_PACKAGE,b as PERCENTAGE_PACKAGE,w as TABLES_PACKAGE,x as TAGS_PACKAGE,e as TIME_PACKAGE,h as UOM_PACKAGE,g as VARIABLES_PACKAGE,k as VECTOR_PACKAGE,s as WEATHER_PACKAGE,i as createCurrencyPackage,u as createKnowledgePackage,t as createStocksPackage}from'./chunk-E2Q3PQ2G.js';import'./chunk-6G3PMEPA.js';export{a as SYMBOLIC_PACKAGE}from'./chunk-TN5E6JU6.js';import'./chunk-YVKHEAFT.js';import'./chunk-5FO4PDIG.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-W2JAR233.js';import'./chunk-YAYBVVG2.js';import'./chunk-E6Z4NQAS.js';import'./chunk-HFKDWQUL.js';import'./chunk-R2ENWQ76.js';import'./chunk-RSF25YSJ.js';import'./chunk-EVAOPEO4.js';import'./chunk-WGZ3FNHI.js';import'./chunk-G7TBEQRQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-TRBXW6HW.js';import'./chunk-2JMFUQZH.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=packages.js.map
1
+ export{a as ARITHMETIC_PACKAGE,n as BIGINT_PACKAGE,y as BUILTIN_PACKAGES,o as CONDITIONALS_PACKAGE,p as CONVERTERS_PACKAGE,j as CURRENCY_PACKAGE,d as DATETIME_PACKAGE,f as DICE_PACKAGE,r as FINANCE_PACKAGE,c as FUNCTION_PACKAGE,v as LINES_PACKAGE,m as MAPREDUCE_PACKAGE,q as MATHPHRASES_PACKAGE,l as MATRIX_PACKAGE,b as PERCENTAGE_PACKAGE,w as TABLES_PACKAGE,x as TAGS_PACKAGE,e as TIME_PACKAGE,h as UOM_PACKAGE,g as VARIABLES_PACKAGE,k as VECTOR_PACKAGE,s as WEATHER_PACKAGE,i as createCurrencyPackage,u as createKnowledgePackage,t as createStocksPackage}from'./chunk-AIIPKVKO.js';import'./chunk-6G3PMEPA.js';export{a as SYMBOLIC_PACKAGE}from'./chunk-TN5E6JU6.js';import'./chunk-YVKHEAFT.js';import'./chunk-5FO4PDIG.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-W2JAR233.js';import'./chunk-YAYBVVG2.js';import'./chunk-E6Z4NQAS.js';import'./chunk-HFKDWQUL.js';import'./chunk-R2ENWQ76.js';import'./chunk-RSF25YSJ.js';import'./chunk-EVAOPEO4.js';import'./chunk-WGZ3FNHI.js';import'./chunk-G7TBEQRQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-TRBXW6HW.js';import'./chunk-2JMFUQZH.js';import'./chunk-MPB7KUN5.js';//# sourceMappingURL=packages.js.map
2
2
  //# sourceMappingURL=packages.js.map
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkZCNBT44X_cjs=require('./chunk-ZCNBT44X.cjs');Object.defineProperty(exports,"ResolverRegistry",{enumerable:true,get:function(){return chunkZCNBT44X_cjs.a}});//# sourceMappingURL=resolvers.cjs.map
1
+ 'use strict';var chunkLNZNJSRW_cjs=require('./chunk-LNZNJSRW.cjs');Object.defineProperty(exports,"ResolverRegistry",{enumerable:true,get:function(){return chunkLNZNJSRW_cjs.a}});//# sourceMappingURL=resolvers.cjs.map
2
2
  //# sourceMappingURL=resolvers.cjs.map
@@ -19,6 +19,20 @@ interface AsyncCheckResult {
19
19
  signal: AbortSignal;
20
20
  /** Optional metadata for diagnostics */
21
21
  metadata?: Record<string, unknown>;
22
+ /**
23
+ * Cadence, in ms, at which this value wants proactive background refresh
24
+ * (a live quote every minute, an FX rate every few minutes). Absent, or
25
+ * paired with no {@link refetch}, means pull-only: the value refreshes on
26
+ * re-evaluation, never on its own. Only acted on when the host has enabled
27
+ * background refresh; see {@link BackgroundRefreshConfig}.
28
+ */
29
+ refetchIntervalMs?: number;
30
+ /**
31
+ * Force a fresh fetch of this exact query, bypassing `staleTime`, and return
32
+ * the new value. Supplied alongside {@link refetchIntervalMs} so the engine
33
+ * can drive the background refresh without re-scanning bytecode.
34
+ */
35
+ refetch?: () => Promise<Value>;
22
36
  }
23
37
  /**
24
38
  * Interface for async resolvers registered by packages/plugins.
@@ -19,6 +19,20 @@ interface AsyncCheckResult {
19
19
  signal: AbortSignal;
20
20
  /** Optional metadata for diagnostics */
21
21
  metadata?: Record<string, unknown>;
22
+ /**
23
+ * Cadence, in ms, at which this value wants proactive background refresh
24
+ * (a live quote every minute, an FX rate every few minutes). Absent, or
25
+ * paired with no {@link refetch}, means pull-only: the value refreshes on
26
+ * re-evaluation, never on its own. Only acted on when the host has enabled
27
+ * background refresh; see {@link BackgroundRefreshConfig}.
28
+ */
29
+ refetchIntervalMs?: number;
30
+ /**
31
+ * Force a fresh fetch of this exact query, bypassing `staleTime`, and return
32
+ * the new value. Supplied alongside {@link refetchIntervalMs} so the engine
33
+ * can drive the background refresh without re-scanning bytecode.
34
+ */
35
+ refetch?: () => Promise<Value>;
22
36
  }
23
37
  /**
24
38
  * Interface for async resolvers registered by packages/plugins.
package/dist/resolvers.js CHANGED
@@ -1,2 +1,2 @@
1
- export{a as ResolverRegistry}from'./chunk-7GK3XEZF.js';//# sourceMappingURL=resolvers.js.map
1
+ export{a as ResolverRegistry}from'./chunk-7E7NXKQ5.js';//# sourceMappingURL=resolvers.js.map
2
2
  //# sourceMappingURL=resolvers.js.map
package/dist/testing.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var chunkGK2OHWRF_cjs=require('./chunk-GK2OHWRF.cjs');require('./chunk-FDE5HWDI.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-ZCNBT44X.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-SYYE3QAX.cjs'),require('./chunk-AXMQG5TS.cjs'),require('./chunk-HLBYHXQD.cjs'),require('./chunk-R2SZFJTT.cjs');var chunkOVKDDTXO_cjs=require('./chunk-OVKDDTXO.cjs');require('./chunk-6INX773F.cjs'),require('./chunk-7BXPCWKM.cjs'),require('./chunk-4QVBSG6B.cjs'),require('./chunk-VAGS5JS7.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-JAK3RAFA.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-JFAJN3C2.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-ESUN2THE.cjs'),require('./chunk-N7N7MPMK.cjs');var chunkPS272DZJ_cjs=require('./chunk-PS272DZJ.cjs');require('./chunk-IANAMBJQ.cjs');var chunkEVI6OHQH_cjs=require('./chunk-EVI6OHQH.cjs');require('./chunk-32GC2FHC.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-2LFLR3VZ.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-FWW3M36J.cjs'),require('./chunk-CIQOK7Q4.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var i=class o extends Error{constructor(t){super(t.message),this.name="ExpectationError",this.code=t.code,this.expected=t.expected,this.actual=t.actual,Object.setPrototypeOf(this,o.prototype);}};function V(o=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new chunkGK2OHWRF_cjs.n({locale:e,packages:r?chunkOVKDDTXO_cjs.y:[]});for(let a of o)s.registerPackage(a);return s}function v(o,t){try{let e=o.evaluateExpression(t);return e.isError()?{status:"error",code:e.errorCode??"",message:e.errorMessage??"",source:e}:e.isPending()?{status:"pending",value:e}:{status:"value",value:e}}catch(e){if(e instanceof chunkSOMGSIO4_cjs.b)return {status:"error",code:e.code,message:e.message,source:e};let r=e instanceof Error?e.message:String(e);return {status:"error",code:"UNKNOWN_ERROR",message:r,source:new chunkPS272DZJ_cjs.m(13,"UNKNOWN_ERROR",r)}}}function x(o,t){if(Object.is(o,t))return true;if(!Number.isFinite(o)||!Number.isFinite(t))return false;let e=1e-9*Math.max(1,Math.abs(o),Math.abs(t));return Math.abs(o-t)<=e}function l(o){return o.type===3?JSON.stringify(o.value):o.type===6&&typeof o.unit=="string"?`${String(o.value)} ${o.unit}`:String(o.value)}function n(o){switch(o.status){case "value":return l(o.value);case "pending":return "a pending async value";case "error":return `an error (${o.code}: ${o.message})`}}var d=class{constructor(t,e){this.expression=t;this.outcome=e;}get value(){if(this.outcome.status==="error")throw new i({code:"EXPECTED_VALUE",message:`Expected "${this.expression}" to evaluate, but it failed with ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this.outcome.value}toEvaluate(){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EVALUATE",message:`Expected "${this.expression}" to evaluate to a value, but got ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this}toEqual(t,e){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but got ${n(this.outcome)}.`,expected:c(t,e),actual:n(this.outcome)});let r=this.outcome.value,s;if(typeof t=="number"?s=x(r.toNumber(),t):typeof t=="boolean"?s=r.type===10&&r.value===t:s=C(r)===t,!s)throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but it was ${l(r)}.`,expected:c(t,e),actual:l(r)});if(e!==void 0&&r.unit!==e)throw new i({code:"EXPECTED_UNIT",message:`Expected "${this.expression}" to carry the unit "${e}", but it was ${r.unit===void 0?"unitless":`"${r.unit}"`}.`,expected:`unit "${e}"`,actual:r.unit===void 0?"no unit":`unit "${r.unit}"`});return this}toBeError(){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_ERROR",message:`Expected "${this.expression}" to fail, but it produced ${n(this.outcome)}.`,expected:"an error",actual:n(this.outcome)});return this}toFailWith(t){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it produced ${n(this.outcome)}.`,expected:`error code "${t}"`,actual:n(this.outcome)});if(this.outcome.code!==t)throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it failed with "${this.outcome.code}" (${this.outcome.message}).`,expected:`error code "${t}"`,actual:`error code "${this.outcome.code}"`});return this}toBePending(){if(this.outcome.status!=="pending")throw new i({code:"EXPECTED_PENDING",message:`Expected "${this.expression}" to be pending, but got ${n(this.outcome)}.`,expected:"a pending async value",actual:n(this.outcome)});return this}};function c(o,t){let e=typeof o=="string"?JSON.stringify(o):String(o);return t===void 0?e:`${e} ${t}`}function C(o){return String(o.value)}function D(o,t){return new d(t,v(o,t))}var O=["a","an","and","or","but","if","then","the","this","that","these","those","in","on","at","to","of","for","from","with","by","as","per","into","over","is","are","was","were","be","been","being","do","does","did","have","has","had","will","would","can","could","should","may","might","must","price","cost","value","total","sum","count","rate","amount","number","time","date","day","week","month","year","hour","minute","second","add","buy","sell","hold","make","take","give","get","set","run","up","down","out","off","all","some","any","no","not","more","less","one","two","three","first","last","next","each","every","here","there"],$=["error","warning","info"];function k(o){let t=[],e=o.lexerVocabulary;if(e?.keywords)for(let[r,s]of Object.entries(e.keywords))t.push({word:r,via:"keyword",tokenType:s});if(e?.units)for(let r of e.units)t.push({word:r,via:"unit"});if(e?.operators)for(let[r,s]of Object.entries(e.operators))t.push({word:r,via:"operator",tokenType:s});if(o.phrases)for(let[r,s]of Object.entries(o.phrases))r.includes(" ")||t.push({word:r,via:"phrase",tokenType:s});return t}var p=class{constructor(t){this.pkg=t;}notToShadow(t=O){let e=new Set(t.map(s=>s.toLowerCase())),r=k(this.pkg).filter(s=>e.has(s.word.toLowerCase()));if(r.length>0){let s=r.map(a=>`"${a.word}" (${a.via})`).join(", ");throw new i({code:"PACKAGE_SHADOWS_PROSE",message:`Package "${this.pkg.name}" claims prose word(s) as syntax: ${s}. A word that is also ordinary English turns prose into arithmetic; prefer a multi-word phrase or a form that requires a parenthesis.`,expected:"no prose words claimed as syntax",actual:s})}return r}notToCollideWith(t,e="error"){let r=chunkGK2OHWRF_cjs.a(this.pkg,t),s=$.indexOf(e),a=r.conflicts.filter(u=>$.indexOf(u.severity)<=s);if(a.length>0){let u=a.map(g=>`[${g.severity}] ${g.detail}`).join(`
1
+ 'use strict';var chunkL7ZQQ773_cjs=require('./chunk-L7ZQQ773.cjs');require('./chunk-FDE5HWDI.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-LNZNJSRW.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-SYYE3QAX.cjs'),require('./chunk-AXMQG5TS.cjs'),require('./chunk-HLBYHXQD.cjs'),require('./chunk-R2SZFJTT.cjs');var chunkJFREB45J_cjs=require('./chunk-JFREB45J.cjs');require('./chunk-6INX773F.cjs'),require('./chunk-7BXPCWKM.cjs'),require('./chunk-4QVBSG6B.cjs'),require('./chunk-VAGS5JS7.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-JAK3RAFA.cjs'),require('./chunk-4BZIYU7S.cjs'),require('./chunk-JFAJN3C2.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-ESUN2THE.cjs'),require('./chunk-N7N7MPMK.cjs');var chunkPS272DZJ_cjs=require('./chunk-PS272DZJ.cjs');require('./chunk-IANAMBJQ.cjs');var chunkBAVZMGTZ_cjs=require('./chunk-BAVZMGTZ.cjs');require('./chunk-32GC2FHC.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-2LFLR3VZ.cjs'),require('./chunk-5IJD5L3O.cjs'),require('./chunk-MSYX32PF.cjs'),require('./chunk-FWW3M36J.cjs'),require('./chunk-CIQOK7Q4.cjs');var chunkSOMGSIO4_cjs=require('./chunk-SOMGSIO4.cjs');var i=class o extends Error{constructor(t){super(t.message),this.name="ExpectationError",this.code=t.code,this.expected=t.expected,this.actual=t.actual,Object.setPrototypeOf(this,o.prototype);}};function V(o=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new chunkL7ZQQ773_cjs.n({locale:e,packages:r?chunkJFREB45J_cjs.y:[]});for(let a of o)s.registerPackage(a);return s}function v(o,t){try{let e=o.evaluateExpression(t);return e.isError()?{status:"error",code:e.errorCode??"",message:e.errorMessage??"",source:e}:e.isPending()?{status:"pending",value:e}:{status:"value",value:e}}catch(e){if(e instanceof chunkSOMGSIO4_cjs.b)return {status:"error",code:e.code,message:e.message,source:e};let r=e instanceof Error?e.message:String(e);return {status:"error",code:"UNKNOWN_ERROR",message:r,source:new chunkPS272DZJ_cjs.m(13,"UNKNOWN_ERROR",r)}}}function x(o,t){if(Object.is(o,t))return true;if(!Number.isFinite(o)||!Number.isFinite(t))return false;let e=1e-9*Math.max(1,Math.abs(o),Math.abs(t));return Math.abs(o-t)<=e}function l(o){return o.type===3?JSON.stringify(o.value):o.type===6&&typeof o.unit=="string"?`${String(o.value)} ${o.unit}`:String(o.value)}function n(o){switch(o.status){case "value":return l(o.value);case "pending":return "a pending async value";case "error":return `an error (${o.code}: ${o.message})`}}var d=class{constructor(t,e){this.expression=t;this.outcome=e;}get value(){if(this.outcome.status==="error")throw new i({code:"EXPECTED_VALUE",message:`Expected "${this.expression}" to evaluate, but it failed with ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this.outcome.value}toEvaluate(){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EVALUATE",message:`Expected "${this.expression}" to evaluate to a value, but got ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this}toEqual(t,e){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but got ${n(this.outcome)}.`,expected:c(t,e),actual:n(this.outcome)});let r=this.outcome.value,s;if(typeof t=="number"?s=x(r.toNumber(),t):typeof t=="boolean"?s=r.type===10&&r.value===t:s=C(r)===t,!s)throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but it was ${l(r)}.`,expected:c(t,e),actual:l(r)});if(e!==void 0&&r.unit!==e)throw new i({code:"EXPECTED_UNIT",message:`Expected "${this.expression}" to carry the unit "${e}", but it was ${r.unit===void 0?"unitless":`"${r.unit}"`}.`,expected:`unit "${e}"`,actual:r.unit===void 0?"no unit":`unit "${r.unit}"`});return this}toBeError(){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_ERROR",message:`Expected "${this.expression}" to fail, but it produced ${n(this.outcome)}.`,expected:"an error",actual:n(this.outcome)});return this}toFailWith(t){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it produced ${n(this.outcome)}.`,expected:`error code "${t}"`,actual:n(this.outcome)});if(this.outcome.code!==t)throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it failed with "${this.outcome.code}" (${this.outcome.message}).`,expected:`error code "${t}"`,actual:`error code "${this.outcome.code}"`});return this}toBePending(){if(this.outcome.status!=="pending")throw new i({code:"EXPECTED_PENDING",message:`Expected "${this.expression}" to be pending, but got ${n(this.outcome)}.`,expected:"a pending async value",actual:n(this.outcome)});return this}};function c(o,t){let e=typeof o=="string"?JSON.stringify(o):String(o);return t===void 0?e:`${e} ${t}`}function C(o){return String(o.value)}function D(o,t){return new d(t,v(o,t))}var O=["a","an","and","or","but","if","then","the","this","that","these","those","in","on","at","to","of","for","from","with","by","as","per","into","over","is","are","was","were","be","been","being","do","does","did","have","has","had","will","would","can","could","should","may","might","must","price","cost","value","total","sum","count","rate","amount","number","time","date","day","week","month","year","hour","minute","second","add","buy","sell","hold","make","take","give","get","set","run","up","down","out","off","all","some","any","no","not","more","less","one","two","three","first","last","next","each","every","here","there"],$=["error","warning","info"];function k(o){let t=[],e=o.lexerVocabulary;if(e?.keywords)for(let[r,s]of Object.entries(e.keywords))t.push({word:r,via:"keyword",tokenType:s});if(e?.units)for(let r of e.units)t.push({word:r,via:"unit"});if(e?.operators)for(let[r,s]of Object.entries(e.operators))t.push({word:r,via:"operator",tokenType:s});if(o.phrases)for(let[r,s]of Object.entries(o.phrases))r.includes(" ")||t.push({word:r,via:"phrase",tokenType:s});return t}var p=class{constructor(t){this.pkg=t;}notToShadow(t=O){let e=new Set(t.map(s=>s.toLowerCase())),r=k(this.pkg).filter(s=>e.has(s.word.toLowerCase()));if(r.length>0){let s=r.map(a=>`"${a.word}" (${a.via})`).join(", ");throw new i({code:"PACKAGE_SHADOWS_PROSE",message:`Package "${this.pkg.name}" claims prose word(s) as syntax: ${s}. A word that is also ordinary English turns prose into arithmetic; prefer a multi-word phrase or a form that requires a parenthesis.`,expected:"no prose words claimed as syntax",actual:s})}return r}notToCollideWith(t,e="error"){let r=chunkL7ZQQ773_cjs.a(this.pkg,t),s=$.indexOf(e),a=r.conflicts.filter(u=>$.indexOf(u.severity)<=s);if(a.length>0){let u=a.map(g=>`[${g.severity}] ${g.detail}`).join(`
2
2
  `);throw new i({code:"PACKAGE_VOCABULARY_COLLISION",message:`Package "${this.pkg.name}" collides with another package:
3
- ${u}`,expected:`no conflicts at or above "${e}" severity`,actual:`${a.length} conflict(s)`})}return r}toDeclareCompatibleEngineVersion(t=chunkEVI6OHQH_cjs.a){let e=chunkGK2OHWRF_cjs.b(this.pkg,t);if(!e.compatible){let r=e.reason==="invalid-range"?`its range "${e.declaredRange}" is not valid semver`:`its range "${e.declaredRange}" is not satisfied by engine version "${e.engineVersion}"`;throw new i({code:"PACKAGE_ENGINE_VERSION_INCOMPATIBLE",message:`Package "${this.pkg.name}" declares an engineVersion that will be rejected at registration: ${r}.`,expected:`an engineVersion satisfied by "${t}"`,actual:`"${e.declaredRange}"`})}return this}};function L(o){return new p(o)}exports.COMMON_PROSE_WORDS=O;exports.ExpectationError=i;exports.ExpressionAssertion=d;exports.PackageAssertion=p;exports.createTestEngine=V;exports.expectExpression=D;exports.expectPackage=L;//# sourceMappingURL=testing.cjs.map
3
+ ${u}`,expected:`no conflicts at or above "${e}" severity`,actual:`${a.length} conflict(s)`})}return r}toDeclareCompatibleEngineVersion(t=chunkBAVZMGTZ_cjs.a){let e=chunkL7ZQQ773_cjs.b(this.pkg,t);if(!e.compatible){let r=e.reason==="invalid-range"?`its range "${e.declaredRange}" is not valid semver`:`its range "${e.declaredRange}" is not satisfied by engine version "${e.engineVersion}"`;throw new i({code:"PACKAGE_ENGINE_VERSION_INCOMPATIBLE",message:`Package "${this.pkg.name}" declares an engineVersion that will be rejected at registration: ${r}.`,expected:`an engineVersion satisfied by "${t}"`,actual:`"${e.declaredRange}"`})}return this}};function L(o){return new p(o)}exports.COMMON_PROSE_WORDS=O;exports.ExpectationError=i;exports.ExpressionAssertion=d;exports.PackageAssertion=p;exports.createTestEngine=V;exports.expectExpression=D;exports.expectPackage=L;//# sourceMappingURL=testing.cjs.map
4
4
  //# sourceMappingURL=testing.cjs.map
@@ -1,7 +1,7 @@
1
- import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-dpdurBVO.cjs';
1
+ import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-DXsvmpQN.cjs';
2
2
  import { V as Value } from './Value-CCi_Eecs.cjs';
3
3
  import { E as EngineError } from './EngineError-Ce1lPkjZ.cjs';
4
- import { C as CompatibilityReport } from './PackageCompatibility-Bn5jnBtA.cjs';
4
+ import { C as CompatibilityReport } from './PackageCompatibility-CN-2CVhu.cjs';
5
5
  import './Parselet-C4Wu055_.cjs';
6
6
  import './BytecodeBuilder-DGGeByAP.cjs';
7
7
  import './Token-CbP_OutD.cjs';
@@ -10,8 +10,8 @@ import './Lexer-B4C1qHXu.cjs';
10
10
  import './resolvers.cjs';
11
11
  import '@tanstack/query-core';
12
12
  import './TokenNormalizer-DnlL7_8c.cjs';
13
- import './ScopeManager-D7uMXbhS.cjs';
14
- import './Configuration-B6W0-T67.cjs';
13
+ import './ScopeManager-t6SnP6Ce.cjs';
14
+ import './Configuration-Culg8H_o.cjs';
15
15
 
16
16
  /**
17
17
  * A test kit for package authors, the supported way to test a package by the
package/dist/testing.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-DzeiWcv4.js';
1
+ import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-jqdAsm6U.js';
2
2
  import { V as Value } from './Value-CCi_Eecs.js';
3
3
  import { E as EngineError } from './EngineError-Ce1lPkjZ.js';
4
- import { C as CompatibilityReport } from './PackageCompatibility-CIvq2MP5.js';
4
+ import { C as CompatibilityReport } from './PackageCompatibility-DbpyKYOe.js';
5
5
  import './Parselet-B-zoPrTa.js';
6
6
  import './BytecodeBuilder-DGGeByAP.js';
7
7
  import './Token-CbP_OutD.js';
@@ -10,8 +10,8 @@ import './Lexer-DKMlj7Sy.js';
10
10
  import './resolvers.js';
11
11
  import '@tanstack/query-core';
12
12
  import './TokenNormalizer-DCWdZjGz.js';
13
- import './ScopeManager-C2LDOrDx.js';
14
- import './Configuration-B6W0-T67.js';
13
+ import './ScopeManager-DkpnlKuz.js';
14
+ import './Configuration-Culg8H_o.js';
15
15
 
16
16
  /**
17
17
  * A test kit for package authors, the supported way to test a package by the
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import {n as n$1,a,b}from'./chunk-4E4YVQKK.js';import'./chunk-XNIWQHXY.js';import'./chunk-2RWAXT6O.js';import'./chunk-7GK3XEZF.js';import'./chunk-MIQBJGGR.js';import'./chunk-YJ2OPULK.js';import'./chunk-TWC7K3ZX.js';import'./chunk-J4LZD4ZY.js';import'./chunk-XEIDV5JP.js';import {y}from'./chunk-E2Q3PQ2G.js';import'./chunk-6G3PMEPA.js';import'./chunk-TN5E6JU6.js';import'./chunk-YVKHEAFT.js';import'./chunk-5FO4PDIG.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-W2JAR233.js';import'./chunk-YAYBVVG2.js';import'./chunk-E6Z4NQAS.js';import'./chunk-HFKDWQUL.js';import'./chunk-R2ENWQ76.js';import'./chunk-RSF25YSJ.js';import {m}from'./chunk-EVAOPEO4.js';import'./chunk-WGZ3FNHI.js';import {a as a$1}from'./chunk-U4AEVL5Z.js';import'./chunk-YAHGSBMC.js';import'./chunk-JPFCXLJV.js';import'./chunk-G7TBEQRQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-TRBXW6HW.js';import'./chunk-2JMFUQZH.js';import {b as b$1}from'./chunk-MPB7KUN5.js';var i=class o extends Error{constructor(t){super(t.message),this.name="ExpectationError",this.code=t.code,this.expected=t.expected,this.actual=t.actual,Object.setPrototypeOf(this,o.prototype);}};function V(o=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new n$1({locale:e,packages:r?y:[]});for(let a of o)s.registerPackage(a);return s}function v(o,t){try{let e=o.evaluateExpression(t);return e.isError()?{status:"error",code:e.errorCode??"",message:e.errorMessage??"",source:e}:e.isPending()?{status:"pending",value:e}:{status:"value",value:e}}catch(e){if(e instanceof b$1)return {status:"error",code:e.code,message:e.message,source:e};let r=e instanceof Error?e.message:String(e);return {status:"error",code:"UNKNOWN_ERROR",message:r,source:new m(13,"UNKNOWN_ERROR",r)}}}function x(o,t){if(Object.is(o,t))return true;if(!Number.isFinite(o)||!Number.isFinite(t))return false;let e=1e-9*Math.max(1,Math.abs(o),Math.abs(t));return Math.abs(o-t)<=e}function l(o){return o.type===3?JSON.stringify(o.value):o.type===6&&typeof o.unit=="string"?`${String(o.value)} ${o.unit}`:String(o.value)}function n(o){switch(o.status){case "value":return l(o.value);case "pending":return "a pending async value";case "error":return `an error (${o.code}: ${o.message})`}}var d=class{constructor(t,e){this.expression=t;this.outcome=e;}get value(){if(this.outcome.status==="error")throw new i({code:"EXPECTED_VALUE",message:`Expected "${this.expression}" to evaluate, but it failed with ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this.outcome.value}toEvaluate(){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EVALUATE",message:`Expected "${this.expression}" to evaluate to a value, but got ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this}toEqual(t,e){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but got ${n(this.outcome)}.`,expected:c(t,e),actual:n(this.outcome)});let r=this.outcome.value,s;if(typeof t=="number"?s=x(r.toNumber(),t):typeof t=="boolean"?s=r.type===10&&r.value===t:s=C(r)===t,!s)throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but it was ${l(r)}.`,expected:c(t,e),actual:l(r)});if(e!==void 0&&r.unit!==e)throw new i({code:"EXPECTED_UNIT",message:`Expected "${this.expression}" to carry the unit "${e}", but it was ${r.unit===void 0?"unitless":`"${r.unit}"`}.`,expected:`unit "${e}"`,actual:r.unit===void 0?"no unit":`unit "${r.unit}"`});return this}toBeError(){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_ERROR",message:`Expected "${this.expression}" to fail, but it produced ${n(this.outcome)}.`,expected:"an error",actual:n(this.outcome)});return this}toFailWith(t){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it produced ${n(this.outcome)}.`,expected:`error code "${t}"`,actual:n(this.outcome)});if(this.outcome.code!==t)throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it failed with "${this.outcome.code}" (${this.outcome.message}).`,expected:`error code "${t}"`,actual:`error code "${this.outcome.code}"`});return this}toBePending(){if(this.outcome.status!=="pending")throw new i({code:"EXPECTED_PENDING",message:`Expected "${this.expression}" to be pending, but got ${n(this.outcome)}.`,expected:"a pending async value",actual:n(this.outcome)});return this}};function c(o,t){let e=typeof o=="string"?JSON.stringify(o):String(o);return t===void 0?e:`${e} ${t}`}function C(o){return String(o.value)}function D(o,t){return new d(t,v(o,t))}var O=["a","an","and","or","but","if","then","the","this","that","these","those","in","on","at","to","of","for","from","with","by","as","per","into","over","is","are","was","were","be","been","being","do","does","did","have","has","had","will","would","can","could","should","may","might","must","price","cost","value","total","sum","count","rate","amount","number","time","date","day","week","month","year","hour","minute","second","add","buy","sell","hold","make","take","give","get","set","run","up","down","out","off","all","some","any","no","not","more","less","one","two","three","first","last","next","each","every","here","there"],$=["error","warning","info"];function k(o){let t=[],e=o.lexerVocabulary;if(e?.keywords)for(let[r,s]of Object.entries(e.keywords))t.push({word:r,via:"keyword",tokenType:s});if(e?.units)for(let r of e.units)t.push({word:r,via:"unit"});if(e?.operators)for(let[r,s]of Object.entries(e.operators))t.push({word:r,via:"operator",tokenType:s});if(o.phrases)for(let[r,s]of Object.entries(o.phrases))r.includes(" ")||t.push({word:r,via:"phrase",tokenType:s});return t}var p=class{constructor(t){this.pkg=t;}notToShadow(t=O){let e=new Set(t.map(s=>s.toLowerCase())),r=k(this.pkg).filter(s=>e.has(s.word.toLowerCase()));if(r.length>0){let s=r.map(a=>`"${a.word}" (${a.via})`).join(", ");throw new i({code:"PACKAGE_SHADOWS_PROSE",message:`Package "${this.pkg.name}" claims prose word(s) as syntax: ${s}. A word that is also ordinary English turns prose into arithmetic; prefer a multi-word phrase or a form that requires a parenthesis.`,expected:"no prose words claimed as syntax",actual:s})}return r}notToCollideWith(t,e="error"){let r=a(this.pkg,t),s=$.indexOf(e),a$1=r.conflicts.filter(u=>$.indexOf(u.severity)<=s);if(a$1.length>0){let u=a$1.map(g=>`[${g.severity}] ${g.detail}`).join(`
1
+ import {n as n$1,a,b}from'./chunk-NNYMXK6H.js';import'./chunk-XNIWQHXY.js';import'./chunk-2RWAXT6O.js';import'./chunk-7E7NXKQ5.js';import'./chunk-MIQBJGGR.js';import'./chunk-YJ2OPULK.js';import'./chunk-TWC7K3ZX.js';import'./chunk-J4LZD4ZY.js';import'./chunk-XEIDV5JP.js';import {y}from'./chunk-AIIPKVKO.js';import'./chunk-6G3PMEPA.js';import'./chunk-TN5E6JU6.js';import'./chunk-YVKHEAFT.js';import'./chunk-5FO4PDIG.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-W2JAR233.js';import'./chunk-YAYBVVG2.js';import'./chunk-E6Z4NQAS.js';import'./chunk-HFKDWQUL.js';import'./chunk-R2ENWQ76.js';import'./chunk-RSF25YSJ.js';import {m}from'./chunk-EVAOPEO4.js';import'./chunk-WGZ3FNHI.js';import {a as a$1}from'./chunk-ESXQDRP7.js';import'./chunk-YAHGSBMC.js';import'./chunk-JPFCXLJV.js';import'./chunk-G7TBEQRQ.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-TRBXW6HW.js';import'./chunk-2JMFUQZH.js';import {b as b$1}from'./chunk-MPB7KUN5.js';var i=class o extends Error{constructor(t){super(t.message),this.name="ExpectationError",this.code=t.code,this.expected=t.expected,this.actual=t.actual,Object.setPrototypeOf(this,o.prototype);}};function V(o=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new n$1({locale:e,packages:r?y:[]});for(let a of o)s.registerPackage(a);return s}function v(o,t){try{let e=o.evaluateExpression(t);return e.isError()?{status:"error",code:e.errorCode??"",message:e.errorMessage??"",source:e}:e.isPending()?{status:"pending",value:e}:{status:"value",value:e}}catch(e){if(e instanceof b$1)return {status:"error",code:e.code,message:e.message,source:e};let r=e instanceof Error?e.message:String(e);return {status:"error",code:"UNKNOWN_ERROR",message:r,source:new m(13,"UNKNOWN_ERROR",r)}}}function x(o,t){if(Object.is(o,t))return true;if(!Number.isFinite(o)||!Number.isFinite(t))return false;let e=1e-9*Math.max(1,Math.abs(o),Math.abs(t));return Math.abs(o-t)<=e}function l(o){return o.type===3?JSON.stringify(o.value):o.type===6&&typeof o.unit=="string"?`${String(o.value)} ${o.unit}`:String(o.value)}function n(o){switch(o.status){case "value":return l(o.value);case "pending":return "a pending async value";case "error":return `an error (${o.code}: ${o.message})`}}var d=class{constructor(t,e){this.expression=t;this.outcome=e;}get value(){if(this.outcome.status==="error")throw new i({code:"EXPECTED_VALUE",message:`Expected "${this.expression}" to evaluate, but it failed with ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this.outcome.value}toEvaluate(){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EVALUATE",message:`Expected "${this.expression}" to evaluate to a value, but got ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this}toEqual(t,e){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but got ${n(this.outcome)}.`,expected:c(t,e),actual:n(this.outcome)});let r=this.outcome.value,s;if(typeof t=="number"?s=x(r.toNumber(),t):typeof t=="boolean"?s=r.type===10&&r.value===t:s=C(r)===t,!s)throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but it was ${l(r)}.`,expected:c(t,e),actual:l(r)});if(e!==void 0&&r.unit!==e)throw new i({code:"EXPECTED_UNIT",message:`Expected "${this.expression}" to carry the unit "${e}", but it was ${r.unit===void 0?"unitless":`"${r.unit}"`}.`,expected:`unit "${e}"`,actual:r.unit===void 0?"no unit":`unit "${r.unit}"`});return this}toBeError(){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_ERROR",message:`Expected "${this.expression}" to fail, but it produced ${n(this.outcome)}.`,expected:"an error",actual:n(this.outcome)});return this}toFailWith(t){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it produced ${n(this.outcome)}.`,expected:`error code "${t}"`,actual:n(this.outcome)});if(this.outcome.code!==t)throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it failed with "${this.outcome.code}" (${this.outcome.message}).`,expected:`error code "${t}"`,actual:`error code "${this.outcome.code}"`});return this}toBePending(){if(this.outcome.status!=="pending")throw new i({code:"EXPECTED_PENDING",message:`Expected "${this.expression}" to be pending, but got ${n(this.outcome)}.`,expected:"a pending async value",actual:n(this.outcome)});return this}};function c(o,t){let e=typeof o=="string"?JSON.stringify(o):String(o);return t===void 0?e:`${e} ${t}`}function C(o){return String(o.value)}function D(o,t){return new d(t,v(o,t))}var O=["a","an","and","or","but","if","then","the","this","that","these","those","in","on","at","to","of","for","from","with","by","as","per","into","over","is","are","was","were","be","been","being","do","does","did","have","has","had","will","would","can","could","should","may","might","must","price","cost","value","total","sum","count","rate","amount","number","time","date","day","week","month","year","hour","minute","second","add","buy","sell","hold","make","take","give","get","set","run","up","down","out","off","all","some","any","no","not","more","less","one","two","three","first","last","next","each","every","here","there"],$=["error","warning","info"];function k(o){let t=[],e=o.lexerVocabulary;if(e?.keywords)for(let[r,s]of Object.entries(e.keywords))t.push({word:r,via:"keyword",tokenType:s});if(e?.units)for(let r of e.units)t.push({word:r,via:"unit"});if(e?.operators)for(let[r,s]of Object.entries(e.operators))t.push({word:r,via:"operator",tokenType:s});if(o.phrases)for(let[r,s]of Object.entries(o.phrases))r.includes(" ")||t.push({word:r,via:"phrase",tokenType:s});return t}var p=class{constructor(t){this.pkg=t;}notToShadow(t=O){let e=new Set(t.map(s=>s.toLowerCase())),r=k(this.pkg).filter(s=>e.has(s.word.toLowerCase()));if(r.length>0){let s=r.map(a=>`"${a.word}" (${a.via})`).join(", ");throw new i({code:"PACKAGE_SHADOWS_PROSE",message:`Package "${this.pkg.name}" claims prose word(s) as syntax: ${s}. A word that is also ordinary English turns prose into arithmetic; prefer a multi-word phrase or a form that requires a parenthesis.`,expected:"no prose words claimed as syntax",actual:s})}return r}notToCollideWith(t,e="error"){let r=a(this.pkg,t),s=$.indexOf(e),a$1=r.conflicts.filter(u=>$.indexOf(u.severity)<=s);if(a$1.length>0){let u=a$1.map(g=>`[${g.severity}] ${g.detail}`).join(`
2
2
  `);throw new i({code:"PACKAGE_VOCABULARY_COLLISION",message:`Package "${this.pkg.name}" collides with another package:
3
3
  ${u}`,expected:`no conflicts at or above "${e}" severity`,actual:`${a$1.length} conflict(s)`})}return r}toDeclareCompatibleEngineVersion(t=a$1){let e=b(this.pkg,t);if(!e.compatible){let r=e.reason==="invalid-range"?`its range "${e.declaredRange}" is not valid semver`:`its range "${e.declaredRange}" is not satisfied by engine version "${e.engineVersion}"`;throw new i({code:"PACKAGE_ENGINE_VERSION_INCOMPATIBLE",message:`Package "${this.pkg.name}" declares an engineVersion that will be rejected at registration: ${r}.`,expected:`an engineVersion satisfied by "${t}"`,actual:`"${e.declaredRange}"`})}return this}};function L(o){return new p(o)}export{O as COMMON_PROSE_WORDS,i as ExpectationError,d as ExpressionAssertion,p as PackageAssertion,V as createTestEngine,D as expectExpression,L as expectPackage};//# sourceMappingURL=testing.js.map
4
4
  //# sourceMappingURL=testing.js.map
package/dist/vm.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { P as PluginFunctionHandler } from './ScopeManager-D7uMXbhS.cjs';
2
- export { B as Bytecode, a as DependencyGraph, E as ExpressionRecord, O as OpRegistry, S as ScopeManager, V as VM, c as createVM, e as executeBytecode, s as sharedOpRegistry } from './ScopeManager-D7uMXbhS.cjs';
1
+ import { P as PluginFunctionHandler } from './ScopeManager-t6SnP6Ce.cjs';
2
+ export { B as Bytecode, D as DependencyGraph, E as ExpressionRecord, O as OpRegistry, S as ScopeManager, V as VM, c as createVM, e as executeBytecode, s as sharedOpRegistry } from './ScopeManager-t6SnP6Ce.cjs';
3
3
  import { V as Value } from './Value-CCi_Eecs.cjs';
4
4
  export { M as MatrixData, a as MatrixEntry, R as RangeData, b as ValueType, c as bigIntValue, d as colVectorValue, h as hexValue, m as matrixValue, n as numberValue, r as rangeValue, e as rowVectorValue, s as stringValue, u as uomValue } from './Value-CCi_Eecs.cjs';
5
- export { a as VMCheckpoint, V as VMCheckpointer } from './VMCheckpoints-I9jg3jWR.cjs';
5
+ export { V as VMCheckpoint, a as VMCheckpointer } from './VMCheckpoints-C_jQvABf.cjs';
6
6
  import './BytecodeBuilder-DGGeByAP.cjs';
7
7
  import './EngineError-Ce1lPkjZ.cjs';
8
8
  import './pipeline-DCQicwWX.cjs';
package/dist/vm.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { P as PluginFunctionHandler } from './ScopeManager-C2LDOrDx.js';
2
- export { B as Bytecode, a as DependencyGraph, E as ExpressionRecord, O as OpRegistry, S as ScopeManager, V as VM, c as createVM, e as executeBytecode, s as sharedOpRegistry } from './ScopeManager-C2LDOrDx.js';
1
+ import { P as PluginFunctionHandler } from './ScopeManager-DkpnlKuz.js';
2
+ export { B as Bytecode, D as DependencyGraph, E as ExpressionRecord, O as OpRegistry, S as ScopeManager, V as VM, c as createVM, e as executeBytecode, s as sharedOpRegistry } from './ScopeManager-DkpnlKuz.js';
3
3
  import { V as Value } from './Value-CCi_Eecs.js';
4
4
  export { M as MatrixData, a as MatrixEntry, R as RangeData, b as ValueType, c as bigIntValue, d as colVectorValue, h as hexValue, m as matrixValue, n as numberValue, r as rangeValue, e as rowVectorValue, s as stringValue, u as uomValue } from './Value-CCi_Eecs.js';
5
- export { a as VMCheckpoint, V as VMCheckpointer } from './VMCheckpoints-CGyFhivM.js';
5
+ export { V as VMCheckpoint, a as VMCheckpointer } from './VMCheckpoints-CsHmQVaD.js';
6
6
  import './BytecodeBuilder-DGGeByAP.js';
7
7
  import './EngineError-Ce1lPkjZ.js';
8
8
  import './pipeline-72QmQlGx.js';