solve-engine 2.38.26 → 2.38.28

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 (126) hide show
  1. package/dist/{PackageCompatibility-C7ILySsH.d.ts → PackageCompatibility-BfRpqwmD.d.ts} +1 -1
  2. package/dist/{PackageCompatibility-CzDzOIg9.d.cts → PackageCompatibility-CcfNMlWN.d.cts} +1 -1
  3. package/dist/{PackageRegistry-D7_B0mxv.d.ts → PackageRegistry-ClAKDDOP.d.ts} +25 -4
  4. package/dist/{PackageRegistry-Bd8ErpwZ.d.cts → PackageRegistry-DLLVZW0S.d.cts} +25 -4
  5. package/dist/{Parselet-DmMY2s9Y.d.cts → Parselet-ClR3Blwp.d.cts} +1 -1
  6. package/dist/{Parselet-Br1tHash.d.ts → Parselet-DkAFnfU2.d.ts} +1 -1
  7. package/dist/{VMBuiltins-BqkoJtHt.d.ts → VMBuiltins-Bk8TQNF1.d.ts} +2 -2
  8. package/dist/{VMBuiltins-Baa90D2v.d.cts → VMBuiltins-ClXnXk9K.d.cts} +2 -2
  9. package/dist/{Value-B55Hvn3e.d.cts → Value-wMuCzPn0.d.cts} +18 -2
  10. package/dist/{Value-B55Hvn3e.d.ts → Value-wMuCzPn0.d.ts} +18 -2
  11. package/dist/{chunk-L2JQQ5EO.js → chunk-34RTVUU3.js} +3 -3
  12. package/dist/{chunk-L2JQQ5EO.js.map → chunk-34RTVUU3.js.map} +1 -1
  13. package/dist/{chunk-QP4VIEXZ.js → chunk-36JGHDZR.js} +2 -2
  14. package/dist/chunk-36JGHDZR.js.map +1 -0
  15. package/dist/chunk-3ZFJLH4W.cjs +2 -0
  16. package/dist/chunk-3ZFJLH4W.cjs.map +1 -0
  17. package/dist/{chunk-EZ7R3ZHM.cjs → chunk-4AX7GIZY.cjs} +3 -3
  18. package/dist/{chunk-EZ7R3ZHM.cjs.map → chunk-4AX7GIZY.cjs.map} +1 -1
  19. package/dist/chunk-4H27GUVY.js +2 -0
  20. package/dist/chunk-4H27GUVY.js.map +1 -0
  21. package/dist/{chunk-ZWDLC4MR.cjs → chunk-5BRJQREI.cjs} +4 -4
  22. package/dist/{chunk-ZWDLC4MR.cjs.map → chunk-5BRJQREI.cjs.map} +1 -1
  23. package/dist/{chunk-AWGSR2GZ.js → chunk-BNVE6I22.js} +2 -2
  24. package/dist/{chunk-AWGSR2GZ.js.map → chunk-BNVE6I22.js.map} +1 -1
  25. package/dist/chunk-CAJKB4WQ.js +2 -0
  26. package/dist/chunk-CAJKB4WQ.js.map +1 -0
  27. package/dist/{chunk-ZSFOIBIH.js → chunk-CUH3FEWI.js} +2 -2
  28. package/dist/chunk-CUH3FEWI.js.map +1 -0
  29. package/dist/{chunk-NMZRAJLJ.cjs → chunk-FZTGWNVU.cjs} +2 -2
  30. package/dist/{chunk-NMZRAJLJ.cjs.map → chunk-FZTGWNVU.cjs.map} +1 -1
  31. package/dist/{chunk-RMBUP4XA.js → chunk-GMHYWVOG.js} +2 -2
  32. package/dist/{chunk-RMBUP4XA.js.map → chunk-GMHYWVOG.js.map} +1 -1
  33. package/dist/chunk-HPJ5SQEL.js +3 -0
  34. package/dist/chunk-HPJ5SQEL.js.map +1 -0
  35. package/dist/chunk-HTB3D3FU.cjs +3 -0
  36. package/dist/chunk-HTB3D3FU.cjs.map +1 -0
  37. package/dist/chunk-KVHLLR67.cjs +3 -0
  38. package/dist/chunk-KVHLLR67.cjs.map +1 -0
  39. package/dist/{chunk-Z4MIX43O.cjs → chunk-NIDVZMKV.cjs} +2 -2
  40. package/dist/chunk-NIDVZMKV.cjs.map +1 -0
  41. package/dist/chunk-NW5MM3Q6.js +3 -0
  42. package/dist/chunk-NW5MM3Q6.js.map +1 -0
  43. package/dist/{chunk-TCDB45AW.js → chunk-QXZVDT54.js} +2 -2
  44. package/dist/{chunk-TCDB45AW.js.map → chunk-QXZVDT54.js.map} +1 -1
  45. package/dist/chunk-SXLHFK7M.cjs +2 -0
  46. package/dist/{chunk-NH74IT7B.cjs.map → chunk-SXLHFK7M.cjs.map} +1 -1
  47. package/dist/{chunk-OBQC7KDY.cjs → chunk-TIWNKFSD.cjs} +2 -2
  48. package/dist/{chunk-OBQC7KDY.cjs.map → chunk-TIWNKFSD.cjs.map} +1 -1
  49. package/dist/chunk-TSVKHY5E.js +2 -0
  50. package/dist/{chunk-A34R65WT.js.map → chunk-TSVKHY5E.js.map} +1 -1
  51. package/dist/chunk-U5PPRJ3B.cjs +2 -0
  52. package/dist/chunk-U5PPRJ3B.cjs.map +1 -0
  53. package/dist/chunk-VOWMVLVV.cjs +2 -0
  54. package/dist/chunk-VOWMVLVV.cjs.map +1 -0
  55. package/dist/{chunk-R6NGKIBC.cjs → chunk-VZ4FEVWA.cjs} +2 -2
  56. package/dist/{chunk-R6NGKIBC.cjs.map → chunk-VZ4FEVWA.cjs.map} +1 -1
  57. package/dist/{chunk-TFZNEEJR.js → chunk-XAKFFIMQ.js} +3 -3
  58. package/dist/{chunk-TFZNEEJR.js.map → chunk-XAKFFIMQ.js.map} +1 -1
  59. package/dist/constants.cjs +1 -1
  60. package/dist/constants.js +1 -1
  61. package/dist/engine.cjs +1 -1
  62. package/dist/engine.d.cts +7 -7
  63. package/dist/engine.d.ts +7 -7
  64. package/dist/engine.js +1 -1
  65. package/dist/engine.worker.cjs +1 -1
  66. package/dist/engine.worker.js +1 -1
  67. package/dist/format.cjs +1 -1
  68. package/dist/format.d.cts +1 -1
  69. package/dist/format.d.ts +1 -1
  70. package/dist/format.js +1 -1
  71. package/dist/index.cjs +1 -1
  72. package/dist/index.d.cts +7 -7
  73. package/dist/index.d.ts +7 -7
  74. package/dist/index.js +1 -1
  75. package/dist/language.d.cts +6 -6
  76. package/dist/language.d.ts +6 -6
  77. package/dist/packages.cjs +1 -1
  78. package/dist/packages.d.cts +5 -5
  79. package/dist/packages.d.ts +5 -5
  80. package/dist/packages.js +1 -1
  81. package/dist/parser.d.cts +3 -3
  82. package/dist/parser.d.ts +3 -3
  83. package/dist/{pipeline-CADMN2D1.d.ts → pipeline-CLegjVrf.d.ts} +1 -1
  84. package/dist/{pipeline-C1-CJnFJ.d.cts → pipeline-DKNPr6s8.d.cts} +1 -1
  85. package/dist/resolvers.d.cts +1 -1
  86. package/dist/resolvers.d.ts +1 -1
  87. package/dist/testing.cjs +2 -2
  88. package/dist/testing.d.cts +6 -6
  89. package/dist/testing.d.ts +6 -6
  90. package/dist/testing.js +1 -1
  91. package/dist/uom.cjs +1 -1
  92. package/dist/uom.d.cts +1 -1
  93. package/dist/uom.d.ts +1 -1
  94. package/dist/uom.js +1 -1
  95. package/dist/vm.cjs +1 -1
  96. package/dist/vm.d.cts +4 -4
  97. package/dist/vm.d.ts +4 -4
  98. package/dist/vm.js +1 -1
  99. package/dist/worker.cjs +2 -2
  100. package/dist/worker.d.cts +5 -5
  101. package/dist/worker.d.ts +5 -5
  102. package/dist/worker.js +1 -1
  103. package/package.json +1 -1
  104. package/dist/chunk-44E7U4O5.js +0 -3
  105. package/dist/chunk-44E7U4O5.js.map +0 -1
  106. package/dist/chunk-54QMY2VL.cjs +0 -2
  107. package/dist/chunk-54QMY2VL.cjs.map +0 -1
  108. package/dist/chunk-5TCSFTZD.js +0 -2
  109. package/dist/chunk-5TCSFTZD.js.map +0 -1
  110. package/dist/chunk-5TVI2UPZ.cjs +0 -2
  111. package/dist/chunk-5TVI2UPZ.cjs.map +0 -1
  112. package/dist/chunk-6FBXJYWO.cjs +0 -3
  113. package/dist/chunk-6FBXJYWO.cjs.map +0 -1
  114. package/dist/chunk-A34R65WT.js +0 -2
  115. package/dist/chunk-KSOB5FCI.js +0 -3
  116. package/dist/chunk-KSOB5FCI.js.map +0 -1
  117. package/dist/chunk-NH74IT7B.cjs +0 -2
  118. package/dist/chunk-QP4VIEXZ.js.map +0 -1
  119. package/dist/chunk-QT4IQADG.cjs +0 -3
  120. package/dist/chunk-QT4IQADG.cjs.map +0 -1
  121. package/dist/chunk-Y5ZY6DPX.cjs +0 -2
  122. package/dist/chunk-Y5ZY6DPX.cjs.map +0 -1
  123. package/dist/chunk-Z4MIX43O.cjs.map +0 -1
  124. package/dist/chunk-ZISAN7NW.js +0 -2
  125. package/dist/chunk-ZISAN7NW.js.map +0 -1
  126. package/dist/chunk-ZSFOIBIH.js.map +0 -1
package/dist/testing.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-D7_B0mxv.js';
2
- import { V as Value } from './Value-B55Hvn3e.js';
1
+ import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-ClAKDDOP.js';
2
+ import { V as Value } from './Value-wMuCzPn0.js';
3
3
  import { E as EngineError } from './EngineError-Bm4OYmw8.js';
4
- import { C as CompatibilityReport } from './PackageCompatibility-C7ILySsH.js';
5
- import './Parselet-Br1tHash.js';
4
+ import { C as CompatibilityReport } from './PackageCompatibility-BfRpqwmD.js';
5
+ import './Parselet-DkAFnfU2.js';
6
6
  import './BytecodeBuilder-DSWKZi4f.js';
7
7
  import './Token-D8f7yaz1.js';
8
- import './pipeline-CADMN2D1.js';
8
+ import './pipeline-CLegjVrf.js';
9
9
  import './CalendarBackend-MdS3Bb4P.js';
10
10
  import './Lexer-DPn5dfCH.js';
11
11
  import './resolvers.js';
12
12
  import '@tanstack/query-core';
13
13
  import './TokenNormalizer-DAzPp-j1.js';
14
- import './VMBuiltins-BqkoJtHt.js';
14
+ import './VMBuiltins-Bk8TQNF1.js';
15
15
  import './Configuration-BxriK9Kw.js';
16
16
 
17
17
  /**
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import {o,a,b}from'./chunk-L2JQQ5EO.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-RMBUP4XA.js';import'./chunk-JP4JMQOG.js';import'./chunk-TFZNEEJR.js';import'./chunk-HLZRNZEU.js';import {z}from'./chunk-KSOB5FCI.js';import'./chunk-AWGSR2GZ.js';import'./chunk-ZISAN7NW.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-QP4VIEXZ.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-ZSFOIBIH.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import {m}from'./chunk-A34R65WT.js';import'./chunk-BWTVJD5L.js';import {a as a$1}from'./chunk-TCDB45AW.js';import'./chunk-6NL7RBAG.js';import'./chunk-JPFCXLJV.js';import'./chunk-APYRNAU2.js';import'./chunk-FAO6DQ74.js';import'./chunk-LHLW7JLS.js';import'./chunk-CHVGFTO3.js';import'./chunk-PRSXXDTA.js';import {b as b$1}from'./chunk-6G2NES2I.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$1=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new o({locale:e,packages:r?z:[]});for(let a of o$1)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 {o,a,b}from'./chunk-34RTVUU3.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-GMHYWVOG.js';import'./chunk-JP4JMQOG.js';import'./chunk-XAKFFIMQ.js';import'./chunk-HLZRNZEU.js';import {z}from'./chunk-NW5MM3Q6.js';import'./chunk-BNVE6I22.js';import'./chunk-4H27GUVY.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-36JGHDZR.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-CAJKB4WQ.js';import'./chunk-CUH3FEWI.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import {m}from'./chunk-TSVKHY5E.js';import'./chunk-BWTVJD5L.js';import {a as a$1}from'./chunk-QXZVDT54.js';import'./chunk-6NL7RBAG.js';import'./chunk-JPFCXLJV.js';import'./chunk-APYRNAU2.js';import'./chunk-FAO6DQ74.js';import'./chunk-LHLW7JLS.js';import'./chunk-CHVGFTO3.js';import'./chunk-PRSXXDTA.js';import {b as b$1}from'./chunk-6G2NES2I.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$1=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new o({locale:e,packages:r?z:[]});for(let a of o$1)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/uom.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkNMZRAJLJ_cjs=require('./chunk-NMZRAJLJ.cjs');require('./chunk-GDLYXRMA.cjs');var chunkSF5QVUEI_cjs=require('./chunk-SF5QVUEI.cjs');require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-NH74IT7B.cjs');var chunkPHWIO4P3_cjs=require('./chunk-PHWIO4P3.cjs');require('./chunk-EZKR44MA.cjs'),require('./chunk-6SYU4MH7.cjs');Object.defineProperty(exports,"CurrencyAsyncResolver",{enumerable:true,get:function(){return chunkNMZRAJLJ_cjs.a}});Object.defineProperty(exports,"CurrencyExchangeService",{enumerable:true,get:function(){return chunkSF5QVUEI_cjs.a}});Object.defineProperty(exports,"currencyExchangeService",{enumerable:true,get:function(){return chunkSF5QVUEI_cjs.b}});Object.defineProperty(exports,"sharedCurrencyExchange",{enumerable:true,get:function(){return chunkSF5QVUEI_cjs.c}});Object.defineProperty(exports,"canConvert",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.d}});Object.defineProperty(exports,"convertUnit",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.e}});Object.defineProperty(exports,"getBestUnit",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.h}});Object.defineProperty(exports,"getMeasure",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.c}});Object.defineProperty(exports,"isConvertibleUnit",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.g}});Object.defineProperty(exports,"resolveUnit",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.b}});//# sourceMappingURL=uom.cjs.map
1
+ 'use strict';var chunkFZTGWNVU_cjs=require('./chunk-FZTGWNVU.cjs');require('./chunk-GDLYXRMA.cjs');var chunkSF5QVUEI_cjs=require('./chunk-SF5QVUEI.cjs');require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-SXLHFK7M.cjs');var chunkPHWIO4P3_cjs=require('./chunk-PHWIO4P3.cjs');require('./chunk-EZKR44MA.cjs'),require('./chunk-6SYU4MH7.cjs');Object.defineProperty(exports,"CurrencyAsyncResolver",{enumerable:true,get:function(){return chunkFZTGWNVU_cjs.a}});Object.defineProperty(exports,"CurrencyExchangeService",{enumerable:true,get:function(){return chunkSF5QVUEI_cjs.a}});Object.defineProperty(exports,"currencyExchangeService",{enumerable:true,get:function(){return chunkSF5QVUEI_cjs.b}});Object.defineProperty(exports,"sharedCurrencyExchange",{enumerable:true,get:function(){return chunkSF5QVUEI_cjs.c}});Object.defineProperty(exports,"canConvert",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.d}});Object.defineProperty(exports,"convertUnit",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.e}});Object.defineProperty(exports,"getBestUnit",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.h}});Object.defineProperty(exports,"getMeasure",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.c}});Object.defineProperty(exports,"isConvertibleUnit",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.g}});Object.defineProperty(exports,"resolveUnit",{enumerable:true,get:function(){return chunkPHWIO4P3_cjs.b}});//# sourceMappingURL=uom.cjs.map
2
2
  //# sourceMappingURL=uom.cjs.map
package/dist/uom.d.cts CHANGED
@@ -2,7 +2,7 @@ import { QueryClient } from '@tanstack/query-core';
2
2
  import { T as Token } from './Token-D8f7yaz1.cjs';
3
3
  import { O as OpCode, a as BytecodeProgram } from './BytecodeBuilder-DSWKZi4f.cjs';
4
4
  import { IAsyncResolver, AsyncCheckResult } from './resolvers.cjs';
5
- import './Value-B55Hvn3e.cjs';
5
+ import './Value-wMuCzPn0.cjs';
6
6
 
7
7
  /**
8
8
  * Caches exchange rates fetched from an external source.
package/dist/uom.d.ts CHANGED
@@ -2,7 +2,7 @@ import { QueryClient } from '@tanstack/query-core';
2
2
  import { T as Token } from './Token-D8f7yaz1.js';
3
3
  import { O as OpCode, a as BytecodeProgram } from './BytecodeBuilder-DSWKZi4f.js';
4
4
  import { IAsyncResolver, AsyncCheckResult } from './resolvers.js';
5
- import './Value-B55Hvn3e.js';
5
+ import './Value-wMuCzPn0.js';
6
6
 
7
7
  /**
8
8
  * Caches exchange rates fetched from an external source.
package/dist/uom.js CHANGED
@@ -1,2 +1,2 @@
1
- export{a as CurrencyAsyncResolver}from'./chunk-AWGSR2GZ.js';import'./chunk-EOKHRS2T.js';export{a as CurrencyExchangeService,b as currencyExchangeService,c as sharedCurrencyExchange}from'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-A34R65WT.js';export{d as canConvert,e as convertUnit,h as getBestUnit,c as getMeasure,g as isConvertibleUnit,b as resolveUnit}from'./chunk-BWTVJD5L.js';import'./chunk-PRSXXDTA.js';import'./chunk-6G2NES2I.js';//# sourceMappingURL=uom.js.map
1
+ export{a as CurrencyAsyncResolver}from'./chunk-BNVE6I22.js';import'./chunk-EOKHRS2T.js';export{a as CurrencyExchangeService,b as currencyExchangeService,c as sharedCurrencyExchange}from'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-TSVKHY5E.js';export{d as canConvert,e as convertUnit,h as getBestUnit,c as getMeasure,g as isConvertibleUnit,b as resolveUnit}from'./chunk-BWTVJD5L.js';import'./chunk-PRSXXDTA.js';import'./chunk-6G2NES2I.js';//# sourceMappingURL=uom.js.map
2
2
  //# sourceMappingURL=uom.js.map
package/dist/vm.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkCR7IHPA2_cjs=require('./chunk-CR7IHPA2.cjs'),chunkOBQC7KDY_cjs=require('./chunk-OBQC7KDY.cjs');require('./chunk-HG4NPDN5.cjs');var chunk54QMY2VL_cjs=require('./chunk-54QMY2VL.cjs');require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-Z4MIX43O.cjs'),require('./chunk-EQNKDTMX.cjs'),require('./chunk-E4HAKNBQ.cjs');var chunkNH74IT7B_cjs=require('./chunk-NH74IT7B.cjs');require('./chunk-PHWIO4P3.cjs'),require('./chunk-EZKR44MA.cjs'),require('./chunk-6SYU4MH7.cjs');Object.defineProperty(exports,"VMCheckpointer",{enumerable:true,get:function(){return chunkCR7IHPA2_cjs.a}});Object.defineProperty(exports,"ScopeManager",{enumerable:true,get:function(){return chunkOBQC7KDY_cjs.a}});Object.defineProperty(exports,"createVM",{enumerable:true,get:function(){return chunkOBQC7KDY_cjs.b}});Object.defineProperty(exports,"executeBytecode",{enumerable:true,get:function(){return chunkOBQC7KDY_cjs.c}});Object.defineProperty(exports,"DependencyGraph",{enumerable:true,get:function(){return chunk54QMY2VL_cjs.c}});Object.defineProperty(exports,"OpRegistry",{enumerable:true,get:function(){return chunk54QMY2VL_cjs.z}});Object.defineProperty(exports,"allocatePluginFunctionIndex",{enumerable:true,get:function(){return chunk54QMY2VL_cjs.I}});Object.defineProperty(exports,"binaryOp",{enumerable:true,get:function(){return chunk54QMY2VL_cjs.y}});Object.defineProperty(exports,"builtinFunctions",{enumerable:true,get:function(){return chunk54QMY2VL_cjs.G}});Object.defineProperty(exports,"pluginFunctionIndexFor",{enumerable:true,get:function(){return chunk54QMY2VL_cjs.J}});Object.defineProperty(exports,"pluginFunctionRegistry",{enumerable:true,get:function(){return chunk54QMY2VL_cjs.H}});Object.defineProperty(exports,"sharedOpRegistry",{enumerable:true,get:function(){return chunk54QMY2VL_cjs.A}});Object.defineProperty(exports,"unifyUom",{enumerable:true,get:function(){return chunk54QMY2VL_cjs.m}});Object.defineProperty(exports,"Value",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.m}});Object.defineProperty(exports,"ValueType",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.g}});Object.defineProperty(exports,"bigIntValue",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.s}});Object.defineProperty(exports,"chargeAllocation",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.c}});Object.defineProperty(exports,"checkAllocation",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.d}});Object.defineProperty(exports,"checkedArray",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.e}});Object.defineProperty(exports,"colVectorValue",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.E}});Object.defineProperty(exports,"hexValue",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.r}});Object.defineProperty(exports,"matrixValue",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.C}});Object.defineProperty(exports,"numberValue",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.n}});Object.defineProperty(exports,"rangeValue",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.F}});Object.defineProperty(exports,"rowVectorValue",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.D}});Object.defineProperty(exports,"stringValue",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.t}});Object.defineProperty(exports,"uomValue",{enumerable:true,get:function(){return chunkNH74IT7B_cjs.u}});//# sourceMappingURL=vm.cjs.map
1
+ 'use strict';var chunkCR7IHPA2_cjs=require('./chunk-CR7IHPA2.cjs'),chunkTIWNKFSD_cjs=require('./chunk-TIWNKFSD.cjs');require('./chunk-HG4NPDN5.cjs');var chunkVOWMVLVV_cjs=require('./chunk-VOWMVLVV.cjs');require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-NIDVZMKV.cjs'),require('./chunk-EQNKDTMX.cjs'),require('./chunk-E4HAKNBQ.cjs');var chunkSXLHFK7M_cjs=require('./chunk-SXLHFK7M.cjs');require('./chunk-PHWIO4P3.cjs'),require('./chunk-EZKR44MA.cjs'),require('./chunk-6SYU4MH7.cjs');Object.defineProperty(exports,"VMCheckpointer",{enumerable:true,get:function(){return chunkCR7IHPA2_cjs.a}});Object.defineProperty(exports,"ScopeManager",{enumerable:true,get:function(){return chunkTIWNKFSD_cjs.a}});Object.defineProperty(exports,"createVM",{enumerable:true,get:function(){return chunkTIWNKFSD_cjs.b}});Object.defineProperty(exports,"executeBytecode",{enumerable:true,get:function(){return chunkTIWNKFSD_cjs.c}});Object.defineProperty(exports,"DependencyGraph",{enumerable:true,get:function(){return chunkVOWMVLVV_cjs.c}});Object.defineProperty(exports,"OpRegistry",{enumerable:true,get:function(){return chunkVOWMVLVV_cjs.z}});Object.defineProperty(exports,"allocatePluginFunctionIndex",{enumerable:true,get:function(){return chunkVOWMVLVV_cjs.I}});Object.defineProperty(exports,"binaryOp",{enumerable:true,get:function(){return chunkVOWMVLVV_cjs.y}});Object.defineProperty(exports,"builtinFunctions",{enumerable:true,get:function(){return chunkVOWMVLVV_cjs.G}});Object.defineProperty(exports,"pluginFunctionIndexFor",{enumerable:true,get:function(){return chunkVOWMVLVV_cjs.J}});Object.defineProperty(exports,"pluginFunctionRegistry",{enumerable:true,get:function(){return chunkVOWMVLVV_cjs.H}});Object.defineProperty(exports,"sharedOpRegistry",{enumerable:true,get:function(){return chunkVOWMVLVV_cjs.A}});Object.defineProperty(exports,"unifyUom",{enumerable:true,get:function(){return chunkVOWMVLVV_cjs.m}});Object.defineProperty(exports,"Value",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.m}});Object.defineProperty(exports,"ValueType",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.g}});Object.defineProperty(exports,"bigIntValue",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.s}});Object.defineProperty(exports,"chargeAllocation",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.c}});Object.defineProperty(exports,"checkAllocation",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.d}});Object.defineProperty(exports,"checkedArray",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.e}});Object.defineProperty(exports,"colVectorValue",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.E}});Object.defineProperty(exports,"hexValue",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.r}});Object.defineProperty(exports,"matrixValue",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.C}});Object.defineProperty(exports,"numberValue",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.n}});Object.defineProperty(exports,"rangeValue",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.F}});Object.defineProperty(exports,"rowVectorValue",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.D}});Object.defineProperty(exports,"stringValue",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.t}});Object.defineProperty(exports,"uomValue",{enumerable:true,get:function(){return chunkSXLHFK7M_cjs.u}});//# sourceMappingURL=vm.cjs.map
2
2
  //# sourceMappingURL=vm.cjs.map
package/dist/vm.d.cts CHANGED
@@ -1,10 +1,10 @@
1
- export { B as Bytecode, D as DependencyGraph, E as ExpressionRecord, L as LineExecutionContext, O as OpRegistry, S as ScopeManager, V as VM, a as VMCheckpoint, b as VMCheckpointer, c as allocatePluginFunctionIndex, d as builtinFunctions, e as createVM, f as executeBytecode, p as pluginFunctionIndexFor, g as pluginFunctionRegistry, s as sharedOpRegistry } from './VMBuiltins-Baa90D2v.cjs';
2
- import { V as Value } from './Value-B55Hvn3e.cjs';
3
- 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-B55Hvn3e.cjs';
1
+ export { B as Bytecode, D as DependencyGraph, E as ExpressionRecord, L as LineExecutionContext, O as OpRegistry, S as ScopeManager, V as VM, a as VMCheckpoint, b as VMCheckpointer, c as allocatePluginFunctionIndex, d as builtinFunctions, e as createVM, f as executeBytecode, p as pluginFunctionIndexFor, g as pluginFunctionRegistry, s as sharedOpRegistry } from './VMBuiltins-ClXnXk9K.cjs';
2
+ import { V as Value } from './Value-wMuCzPn0.cjs';
3
+ 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-wMuCzPn0.cjs';
4
4
  import './BytecodeBuilder-DSWKZi4f.cjs';
5
5
  import './CalendarBackend-MdS3Bb4P.cjs';
6
6
  import './EngineError-Bm4OYmw8.cjs';
7
- import './pipeline-C1-CJnFJ.cjs';
7
+ import './pipeline-DKNPr6s8.cjs';
8
8
 
9
9
  /**
10
10
  * The ceiling on how much memory one evaluation is allowed to ask for.
package/dist/vm.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { B as Bytecode, D as DependencyGraph, E as ExpressionRecord, L as LineExecutionContext, O as OpRegistry, S as ScopeManager, V as VM, a as VMCheckpoint, b as VMCheckpointer, c as allocatePluginFunctionIndex, d as builtinFunctions, e as createVM, f as executeBytecode, p as pluginFunctionIndexFor, g as pluginFunctionRegistry, s as sharedOpRegistry } from './VMBuiltins-BqkoJtHt.js';
2
- import { V as Value } from './Value-B55Hvn3e.js';
3
- 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-B55Hvn3e.js';
1
+ export { B as Bytecode, D as DependencyGraph, E as ExpressionRecord, L as LineExecutionContext, O as OpRegistry, S as ScopeManager, V as VM, a as VMCheckpoint, b as VMCheckpointer, c as allocatePluginFunctionIndex, d as builtinFunctions, e as createVM, f as executeBytecode, p as pluginFunctionIndexFor, g as pluginFunctionRegistry, s as sharedOpRegistry } from './VMBuiltins-Bk8TQNF1.js';
2
+ import { V as Value } from './Value-wMuCzPn0.js';
3
+ 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-wMuCzPn0.js';
4
4
  import './BytecodeBuilder-DSWKZi4f.js';
5
5
  import './CalendarBackend-MdS3Bb4P.js';
6
6
  import './EngineError-Bm4OYmw8.js';
7
- import './pipeline-CADMN2D1.js';
7
+ import './pipeline-CLegjVrf.js';
8
8
 
9
9
  /**
10
10
  * The ceiling on how much memory one evaluation is allowed to ask for.
package/dist/vm.js CHANGED
@@ -1,2 +1,2 @@
1
- export{a as VMCheckpointer}from'./chunk-X2QJE3SV.js';export{a as ScopeManager,b as createVM,c as executeBytecode}from'./chunk-RMBUP4XA.js';import'./chunk-JP4JMQOG.js';export{c as DependencyGraph,z as OpRegistry,I as allocatePluginFunctionIndex,y as binaryOp,G as builtinFunctions,J as pluginFunctionIndexFor,H as pluginFunctionRegistry,A as sharedOpRegistry,m as unifyUom}from'./chunk-QP4VIEXZ.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-ZSFOIBIH.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';export{m as Value,g as ValueType,s as bigIntValue,c as chargeAllocation,d as checkAllocation,e as checkedArray,E as colVectorValue,r as hexValue,C as matrixValue,n as numberValue,F as rangeValue,D as rowVectorValue,t as stringValue,u as uomValue}from'./chunk-A34R65WT.js';import'./chunk-BWTVJD5L.js';import'./chunk-PRSXXDTA.js';import'./chunk-6G2NES2I.js';//# sourceMappingURL=vm.js.map
1
+ export{a as VMCheckpointer}from'./chunk-X2QJE3SV.js';export{a as ScopeManager,b as createVM,c as executeBytecode}from'./chunk-GMHYWVOG.js';import'./chunk-JP4JMQOG.js';export{c as DependencyGraph,z as OpRegistry,I as allocatePluginFunctionIndex,y as binaryOp,G as builtinFunctions,J as pluginFunctionIndexFor,H as pluginFunctionRegistry,A as sharedOpRegistry,m as unifyUom}from'./chunk-36JGHDZR.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-CUH3FEWI.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';export{m as Value,g as ValueType,s as bigIntValue,c as chargeAllocation,d as checkAllocation,e as checkedArray,E as colVectorValue,r as hexValue,C as matrixValue,n as numberValue,F as rangeValue,D as rowVectorValue,t as stringValue,u as uomValue}from'./chunk-TSVKHY5E.js';import'./chunk-BWTVJD5L.js';import'./chunk-PRSXXDTA.js';import'./chunk-6G2NES2I.js';//# sourceMappingURL=vm.js.map
2
2
  //# sourceMappingURL=vm.js.map
package/dist/worker.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var chunkHSTGWWU2_cjs=require('./chunk-HSTGWWU2.cjs'),chunkZWDLC4MR_cjs=require('./chunk-ZWDLC4MR.cjs');require('./chunk-P5YWBIIU.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-R3W53ZMP.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-OBQC7KDY.cjs'),require('./chunk-HG4NPDN5.cjs');var chunkEZ7R3ZHM_cjs=require('./chunk-EZ7R3ZHM.cjs');require('./chunk-W4XLVZ6R.cjs');var chunk6FBXJYWO_cjs=require('./chunk-6FBXJYWO.cjs');require('./chunk-NMZRAJLJ.cjs');var chunkY5ZY6DPX_cjs=require('./chunk-Y5ZY6DPX.cjs');require('./chunk-K3PZ66XR.cjs'),require('./chunk-YV4GDW5A.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-GDLYXRMA.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-54QMY2VL.cjs'),require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs');var chunk5TVI2UPZ_cjs=require('./chunk-5TVI2UPZ.cjs'),chunkZ4MIX43O_cjs=require('./chunk-Z4MIX43O.cjs');require('./chunk-EQNKDTMX.cjs'),require('./chunk-E4HAKNBQ.cjs'),require('./chunk-NH74IT7B.cjs'),require('./chunk-PHWIO4P3.cjs');var chunkR6NGKIBC_cjs=require('./chunk-R6NGKIBC.cjs');require('./chunk-3MG7VIPL.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-72J5V7SN.cjs'),require('./chunk-YBQOQTVL.cjs'),require('./chunk-S3DFU33X.cjs'),require('./chunk-J4LSAHCY.cjs'),require('./chunk-EZKR44MA.cjs');var chunk6SYU4MH7_cjs=require('./chunk-6SYU4MH7.cjs');function B(e){if(e?.date?.inputOrder!=="locale")return e;let r={...e.date,inputOrder:chunkY5ZY6DPX_cjs.k({...chunkR6NGKIBC_cjs.b.date,...e.date}).order};return delete r.inputLocale,{...e,date:r}}var x=class{constructor(r){this.nextId=1;this.pending=new Map;this.resolvedListeners=new Set;this.asyncErrorListeners=new Set;this.terminated=false;this.transport=r,this.transport.onMessage(n=>this.onMessage(n));}init(r){let n=this.nextId++;return new Promise((t,s)=>{this.pending.set(n,{resolve:()=>t(),reject:s}),this.transport.postMessage({kind:"init",id:n,localeCode:r.localeCode,diagnostics:r.diagnostics,config:B(r.config),packages:r.packages,formatting:r.formatting});})}parseDocument(r,n){let{signal:t,...s}=n??{},i=Object.keys(s).length>0?s:void 0;return this.call("parseDocument",[r,i],t)}evaluateLines(r,n){return this.call("evaluateLines",[r],n?.signal)}evaluateExpression(r,n){return this.call("evaluateExpression",[r],n?.signal)}onResolved(r){return this.resolvedListeners.add(r),()=>this.resolvedListeners.delete(r)}onAsyncError(r){return this.asyncErrorListeners.add(r),()=>this.asyncErrorListeners.delete(r)}terminate(){if(this.terminated)return;this.terminated=true;let r=chunkHSTGWWU2_cjs.e();for(let n of this.pending.values())this.unhook(n),n.reject(r);this.pending.clear(),this.resolvedListeners.clear(),this.asyncErrorListeners.clear(),this.transport.terminate();}call(r,n,t){if(this.terminated)return Promise.reject(chunkHSTGWWU2_cjs.e());if(t?.aborted)return Promise.reject(chunkHSTGWWU2_cjs.d(r));let s=this.nextId++;return new Promise((i,l)=>{let c={resolve:i,reject:l};if(t){let p=()=>{this.pending.has(s)&&(this.pending.delete(s),this.transport.postMessage({kind:"cancel",id:s}),l(chunkHSTGWWU2_cjs.d(r)));};c.signal=t,c.onAbort=p,t.addEventListener("abort",p,{once:true});}this.pending.set(s,c),this.transport.postMessage({kind:"request",id:s,method:r,args:n});})}onMessage(r){let n=r;switch(n.kind){case "ready":case "result":{let t=n.kind==="result"?n.value:void 0;this.settle(n.id,s=>s.resolve(t));break}case "error":this.settle(n.id,t=>t.reject(chunkHSTGWWU2_cjs.c(n.error)));break;case "async-update":for(let t of [...this.resolvedListeners])t(n.lines);break;case "async-error":for(let t of [...this.asyncErrorListeners])t({queryKey:n.queryKey,packageId:n.packageId,error:chunkHSTGWWU2_cjs.c(n.error)});break}}settle(r,n){let t=this.pending.get(r);t&&(this.pending.delete(r),this.unhook(t),n(t));}unhook(r){r.signal&&r.onAbort&&r.signal.removeEventListener("abort",r.onAbort);}};async function G(e){let r=new x(e.transport);return await r.init(e),r}function F(e){return e>0?"Infinity":e<0?"-Infinity":"NaN"}function H(e){let r=e.data.map(n=>typeof n=="object"&&n!==null?chunkZ4MIX43O_cjs.R(n):typeof n=="number"&&!Number.isFinite(n)?F(n):n);return {rows:e.rows,cols:e.cols,cells:r,hasSymbolic:e.hasSymbolic}}function m(e,r){let n=e.toNumber(),t={type:e.type,text:chunkEZ7R3ZHM_cjs.c(e,r),number:Number.isFinite(n)?n:0};Number.isFinite(n)||(t.nonFinite=F(n)),e.unit!==void 0&&(t.unit=e.unit),e.timedOut!==void 0&&(t.timedOut=e.timedOut),e.grain!==void 0&&(t.grain=e.grain),e.zone!==void 0&&(t.zone=e.zone);let s=e.value;if(typeof s=="bigint")t.bigint=s.toString();else if(e.type===7)t.matrix=H(s);else if(e.type===8){let i=s;t.range={min:i.min,max:i.max};}else if(e.type===14){let i=s;t.colour={hex:chunk5TVI2UPZ_cjs.f(i),r:i.r,g:i.g,b:i.b,a:i.a,format:i.format,css:chunk5TVI2UPZ_cjs.g(i)};}else if(e.type===16){let i=s;t.chart={kind:i.kind,points:i.points.map(l=>[l[0],l[1]]),label:i.label,domain:[i.domain[0],i.domain[1]],range:[i.range[0],i.range[1]],...i.expr!==void 0?{expr:i.expr}:{}};}else if(e.type===17){let i=s;t.ipCidr={...i.addr!==void 0?{addr:i.addr}:{},...i.prefix!==void 0?{prefix:i.prefix}:{},text:chunkEZ7R3ZHM_cjs.c(e).replace(/^=\s*/,"")};}return t}function q(e,r){return e?m(e,r):null}function J(e,r){return {start:e.start,end:e.end,expression:e.expression,lineNumber:e.lineNumber,columnNumber:e.columnNumber,result:q(e.result,r),error:e.error??null}}function y(e,r){return {lineNumber:e.lineNumber,text:e.text,startPosition:e.startPosition,endPosition:e.endPosition,isEmpty:e.isEmpty,hasInlineSolves:e.hasInlineSolves,inlineSolves:e.inlineSolves.map(n=>J(n,r)),expression:e.expression,result:q(e.result,r),error:e.error}}function R(e,r){let n={lines:e.lines.map(t=>y(t,r)),totalLines:e.totalLines,errors:[...e.errors]};return e.diagnostics!==void 0&&(n.diagnostics=e.diagnostics),n}function $(e,r){if(r===void 0)return e;let n=new Map(e.map(s=>[s.name,s])),t=[];for(let s of r){let i=n.get(s);if(!i)throw chunk6SYU4MH7_cjs.c.config(chunkHSTGWWU2_cjs.a.WORKER_UNKNOWN_PACKAGE,`No package named "${s}" is available in this worker runtime`,{name:s,available:[...n.keys()]});t.push(i);}return t}function Q(e,r={}){let n=r.packages??chunk6FBXJYWO_cjs.z,t=null,s,i=new Map,l=new Map,c=null,p=null,g=o=>e.postMessage(o),E=(o,a)=>{g({kind:"error",id:o,error:chunkHSTGWWU2_cjs.b(chunk6SYU4MH7_cjs.d(a))});},D=o=>{let a=new Map;return o.method==="parseDocument"?o.args[0].split(`
2
- `).forEach((u,d)=>a.set(d+1,u)):o.method==="evaluateLines"?o.args[0].forEach((u,d)=>a.set(d+1,u)):a.set(-1,o.args[0]),a},V=(o,a)=>{if(a.type==="error"){g({kind:"async-error",queryKey:a.queryKey,packageId:a.packageId,error:chunkHSTGWWU2_cjs.b(chunk6SYU4MH7_cjs.d(a.error))});return}let u=[];for(let d of a.lineNumbers){let f=l.get(d);if(f!==void 0)try{let T=o.evaluateLine(d,f);T&&u.push({lineNumber:d,value:m(T,s)});}catch{}}u.length>0&&g({kind:"async-update",lines:u});},U=o=>{p?.();let a=o.getEventStream().getReader();p=()=>{a.cancel();},(async()=>{try{for(;;){let{done:u,value:d}=await a.read();if(u)return;V(o,d);}}catch{}})();},j=o=>{try{let a=$(n,o.packages);t=new chunkZWDLC4MR_cjs.o({locale:o.localeCode??"en",diagnostics:o.diagnostics??!1,config:o.config,packages:a,calendar:r.calendar}),s=r.calendar?{...o.formatting??chunkEZ7R3ZHM_cjs.a,calendar:r.calendar}:o.formatting,U(t),g({kind:"ready",id:o.id});}catch(a){E(o.id,a);}},K=(o,a)=>{let{method:u,args:d}=a;switch(u){case "parseDocument":return R(o.parseDocument(d[0],d[1]),s);case "evaluateLines":return o.evaluateLines(d[0]).map(f=>y(f,s));case "evaluateExpression":return m(o.evaluateExpression(d[0]),s);default:throw chunk6SYU4MH7_cjs.c.execution(chunkHSTGWWU2_cjs.a.WORKER_UNKNOWN_METHOD,`The worker runtime has no method named "${String(u)}"`,{method:u})}},_=o=>{let a=t;if(!a){E(o.id,chunk6SYU4MH7_cjs.c.execution(chunkHSTGWWU2_cjs.a.WORKER_NOT_INITIALISED,"The worker received a request before its engine finished initialising"));return}c?.abort();let u=new AbortController;c=u,l=D(o),i.set(o.id,u),a.setKeystrokeSignal(u.signal);try{let d=K(a,o);g({kind:"result",id:o.id,value:d});}catch(d){E(o.id,d);}finally{i.delete(o.id),a.setKeystrokeSignal(null);}};return e.onMessage(o=>{let a=o;switch(a.kind){case "init":j(a);break;case "request":_(a);break;case "cancel":i.get(a.id)?.abort();break}}),()=>{p?.(),p=null,c?.abort(),c=null,l=new Map;for(let o of i.values())o.abort();i.clear(),t?.clear(),t=null,e.terminate();}}function X(e){return typeof globalThis.structuredClone=="function"?globalThis.structuredClone(e):JSON.parse(JSON.stringify(e))}function Y(){let e=null,r=null,n=true,t=(l,c)=>{let p=X(c);queueMicrotask(()=>{n&&l()?.(p);});};return {client:{postMessage:l=>t(()=>r,l),onMessage:l=>{e=l;},terminate:()=>{n=false;}},host:{postMessage:l=>t(()=>e,l),onMessage:l=>{r=l;},terminate:()=>{n=false;}}}}function Z(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{let n=t=>r(t.data);typeof e.addEventListener=="function"?e.addEventListener("message",n):e.onmessage=n,e.start?.();},terminate:()=>{e.terminate?.(),e.close?.();}}}function ee(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{e.on("message",n=>r(n));},terminate:()=>{e.terminate?.(),e.close?.();}}}exports.createLinkedTransports=Y;exports.createWorkerEngine=G;exports.eventTargetTransport=Z;exports.messagePortTransport=ee;exports.serializeParsedLine=y;exports.serializeParsingResult=R;exports.serializeValue=m;exports.startWorkerRuntime=Q;//# sourceMappingURL=worker.cjs.map
1
+ 'use strict';var chunkHSTGWWU2_cjs=require('./chunk-HSTGWWU2.cjs'),chunk5BRJQREI_cjs=require('./chunk-5BRJQREI.cjs');require('./chunk-P5YWBIIU.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-R3W53ZMP.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-TIWNKFSD.cjs'),require('./chunk-HG4NPDN5.cjs');var chunk4AX7GIZY_cjs=require('./chunk-4AX7GIZY.cjs');require('./chunk-W4XLVZ6R.cjs');var chunkKVHLLR67_cjs=require('./chunk-KVHLLR67.cjs');require('./chunk-FZTGWNVU.cjs');var chunkU5PPRJ3B_cjs=require('./chunk-U5PPRJ3B.cjs');require('./chunk-K3PZ66XR.cjs'),require('./chunk-YV4GDW5A.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-GDLYXRMA.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-VOWMVLVV.cjs'),require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs');var chunk3ZFJLH4W_cjs=require('./chunk-3ZFJLH4W.cjs'),chunkNIDVZMKV_cjs=require('./chunk-NIDVZMKV.cjs');require('./chunk-EQNKDTMX.cjs'),require('./chunk-E4HAKNBQ.cjs'),require('./chunk-SXLHFK7M.cjs'),require('./chunk-PHWIO4P3.cjs');var chunkVZ4FEVWA_cjs=require('./chunk-VZ4FEVWA.cjs');require('./chunk-3MG7VIPL.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-72J5V7SN.cjs'),require('./chunk-YBQOQTVL.cjs'),require('./chunk-S3DFU33X.cjs'),require('./chunk-J4LSAHCY.cjs'),require('./chunk-EZKR44MA.cjs');var chunk6SYU4MH7_cjs=require('./chunk-6SYU4MH7.cjs');function B(e){if(e?.date?.inputOrder!=="locale")return e;let r={...e.date,inputOrder:chunkU5PPRJ3B_cjs.k({...chunkVZ4FEVWA_cjs.b.date,...e.date}).order};return delete r.inputLocale,{...e,date:r}}var x=class{constructor(r){this.nextId=1;this.pending=new Map;this.resolvedListeners=new Set;this.asyncErrorListeners=new Set;this.terminated=false;this.transport=r,this.transport.onMessage(n=>this.onMessage(n));}init(r){let n=this.nextId++;return new Promise((t,s)=>{this.pending.set(n,{resolve:()=>t(),reject:s}),this.transport.postMessage({kind:"init",id:n,localeCode:r.localeCode,diagnostics:r.diagnostics,config:B(r.config),packages:r.packages,formatting:r.formatting});})}parseDocument(r,n){let{signal:t,...s}=n??{},i=Object.keys(s).length>0?s:void 0;return this.call("parseDocument",[r,i],t)}evaluateLines(r,n){return this.call("evaluateLines",[r],n?.signal)}evaluateExpression(r,n){return this.call("evaluateExpression",[r],n?.signal)}onResolved(r){return this.resolvedListeners.add(r),()=>this.resolvedListeners.delete(r)}onAsyncError(r){return this.asyncErrorListeners.add(r),()=>this.asyncErrorListeners.delete(r)}terminate(){if(this.terminated)return;this.terminated=true;let r=chunkHSTGWWU2_cjs.e();for(let n of this.pending.values())this.unhook(n),n.reject(r);this.pending.clear(),this.resolvedListeners.clear(),this.asyncErrorListeners.clear(),this.transport.terminate();}call(r,n,t){if(this.terminated)return Promise.reject(chunkHSTGWWU2_cjs.e());if(t?.aborted)return Promise.reject(chunkHSTGWWU2_cjs.d(r));let s=this.nextId++;return new Promise((i,l)=>{let c={resolve:i,reject:l};if(t){let p=()=>{this.pending.has(s)&&(this.pending.delete(s),this.transport.postMessage({kind:"cancel",id:s}),l(chunkHSTGWWU2_cjs.d(r)));};c.signal=t,c.onAbort=p,t.addEventListener("abort",p,{once:true});}this.pending.set(s,c),this.transport.postMessage({kind:"request",id:s,method:r,args:n});})}onMessage(r){let n=r;switch(n.kind){case "ready":case "result":{let t=n.kind==="result"?n.value:void 0;this.settle(n.id,s=>s.resolve(t));break}case "error":this.settle(n.id,t=>t.reject(chunkHSTGWWU2_cjs.c(n.error)));break;case "async-update":for(let t of [...this.resolvedListeners])t(n.lines);break;case "async-error":for(let t of [...this.asyncErrorListeners])t({queryKey:n.queryKey,packageId:n.packageId,error:chunkHSTGWWU2_cjs.c(n.error)});break}}settle(r,n){let t=this.pending.get(r);t&&(this.pending.delete(r),this.unhook(t),n(t));}unhook(r){r.signal&&r.onAbort&&r.signal.removeEventListener("abort",r.onAbort);}};async function G(e){let r=new x(e.transport);return await r.init(e),r}function F(e){return e>0?"Infinity":e<0?"-Infinity":"NaN"}function H(e){let r=e.data.map(n=>typeof n=="object"&&n!==null?chunkNIDVZMKV_cjs.R(n):typeof n=="number"&&!Number.isFinite(n)?F(n):n);return {rows:e.rows,cols:e.cols,cells:r,hasSymbolic:e.hasSymbolic}}function m(e,r){let n=e.toNumber(),t={type:e.type,text:chunk4AX7GIZY_cjs.c(e,r),number:Number.isFinite(n)?n:0};Number.isFinite(n)||(t.nonFinite=F(n)),e.unit!==void 0&&(t.unit=e.unit),e.timedOut!==void 0&&(t.timedOut=e.timedOut),e.grain!==void 0&&(t.grain=e.grain),e.zone!==void 0&&(t.zone=e.zone);let s=e.value;if(typeof s=="bigint")t.bigint=s.toString();else if(e.type===7)t.matrix=H(s);else if(e.type===8){let i=s;t.range={min:i.min,max:i.max};}else if(e.type===14){let i=s;t.colour={hex:chunk3ZFJLH4W_cjs.f(i),r:i.r,g:i.g,b:i.b,a:i.a,format:i.format,css:chunk3ZFJLH4W_cjs.g(i)};}else if(e.type===16){let i=s;t.chart={kind:i.kind,points:i.points.map(l=>[l[0],l[1]]),label:i.label,domain:[i.domain[0],i.domain[1]],range:[i.range[0],i.range[1]],...i.expr!==void 0?{expr:i.expr}:{}};}else if(e.type===17){let i=s;t.ipCidr={...i.addr!==void 0?{addr:i.addr}:{},...i.prefix!==void 0?{prefix:i.prefix}:{},text:chunk4AX7GIZY_cjs.c(e).replace(/^=\s*/,"")};}return t}function q(e,r){return e?m(e,r):null}function J(e,r){return {start:e.start,end:e.end,expression:e.expression,lineNumber:e.lineNumber,columnNumber:e.columnNumber,result:q(e.result,r),error:e.error??null}}function y(e,r){return {lineNumber:e.lineNumber,text:e.text,startPosition:e.startPosition,endPosition:e.endPosition,isEmpty:e.isEmpty,hasInlineSolves:e.hasInlineSolves,inlineSolves:e.inlineSolves.map(n=>J(n,r)),expression:e.expression,result:q(e.result,r),error:e.error}}function R(e,r){let n={lines:e.lines.map(t=>y(t,r)),totalLines:e.totalLines,errors:[...e.errors]};return e.diagnostics!==void 0&&(n.diagnostics=e.diagnostics),n}function $(e,r){if(r===void 0)return e;let n=new Map(e.map(s=>[s.name,s])),t=[];for(let s of r){let i=n.get(s);if(!i)throw chunk6SYU4MH7_cjs.c.config(chunkHSTGWWU2_cjs.a.WORKER_UNKNOWN_PACKAGE,`No package named "${s}" is available in this worker runtime`,{name:s,available:[...n.keys()]});t.push(i);}return t}function Q(e,r={}){let n=r.packages??chunkKVHLLR67_cjs.z,t=null,s,i=new Map,l=new Map,c=null,p=null,g=o=>e.postMessage(o),E=(o,a)=>{g({kind:"error",id:o,error:chunkHSTGWWU2_cjs.b(chunk6SYU4MH7_cjs.d(a))});},D=o=>{let a=new Map;return o.method==="parseDocument"?o.args[0].split(`
2
+ `).forEach((u,d)=>a.set(d+1,u)):o.method==="evaluateLines"?o.args[0].forEach((u,d)=>a.set(d+1,u)):a.set(-1,o.args[0]),a},V=(o,a)=>{if(a.type==="error"){g({kind:"async-error",queryKey:a.queryKey,packageId:a.packageId,error:chunkHSTGWWU2_cjs.b(chunk6SYU4MH7_cjs.d(a.error))});return}let u=[];for(let d of a.lineNumbers){let f=l.get(d);if(f!==void 0)try{let T=o.evaluateLine(d,f);T&&u.push({lineNumber:d,value:m(T,s)});}catch{}}u.length>0&&g({kind:"async-update",lines:u});},U=o=>{p?.();let a=o.getEventStream().getReader();p=()=>{a.cancel();},(async()=>{try{for(;;){let{done:u,value:d}=await a.read();if(u)return;V(o,d);}}catch{}})();},j=o=>{try{let a=$(n,o.packages);t=new chunk5BRJQREI_cjs.o({locale:o.localeCode??"en",diagnostics:o.diagnostics??!1,config:o.config,packages:a,calendar:r.calendar}),s=r.calendar?{...o.formatting??chunk4AX7GIZY_cjs.a,calendar:r.calendar}:o.formatting,U(t),g({kind:"ready",id:o.id});}catch(a){E(o.id,a);}},K=(o,a)=>{let{method:u,args:d}=a;switch(u){case "parseDocument":return R(o.parseDocument(d[0],d[1]),s);case "evaluateLines":return o.evaluateLines(d[0]).map(f=>y(f,s));case "evaluateExpression":return m(o.evaluateExpression(d[0]),s);default:throw chunk6SYU4MH7_cjs.c.execution(chunkHSTGWWU2_cjs.a.WORKER_UNKNOWN_METHOD,`The worker runtime has no method named "${String(u)}"`,{method:u})}},_=o=>{let a=t;if(!a){E(o.id,chunk6SYU4MH7_cjs.c.execution(chunkHSTGWWU2_cjs.a.WORKER_NOT_INITIALISED,"The worker received a request before its engine finished initialising"));return}c?.abort();let u=new AbortController;c=u,l=D(o),i.set(o.id,u),a.setKeystrokeSignal(u.signal);try{let d=K(a,o);g({kind:"result",id:o.id,value:d});}catch(d){E(o.id,d);}finally{i.delete(o.id),a.setKeystrokeSignal(null);}};return e.onMessage(o=>{let a=o;switch(a.kind){case "init":j(a);break;case "request":_(a);break;case "cancel":i.get(a.id)?.abort();break}}),()=>{p?.(),p=null,c?.abort(),c=null,l=new Map;for(let o of i.values())o.abort();i.clear(),t?.clear(),t=null,e.terminate();}}function X(e){return typeof globalThis.structuredClone=="function"?globalThis.structuredClone(e):JSON.parse(JSON.stringify(e))}function Y(){let e=null,r=null,n=true,t=(l,c)=>{let p=X(c);queueMicrotask(()=>{n&&l()?.(p);});};return {client:{postMessage:l=>t(()=>r,l),onMessage:l=>{e=l;},terminate:()=>{n=false;}},host:{postMessage:l=>t(()=>e,l),onMessage:l=>{r=l;},terminate:()=>{n=false;}}}}function Z(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{let n=t=>r(t.data);typeof e.addEventListener=="function"?e.addEventListener("message",n):e.onmessage=n,e.start?.();},terminate:()=>{e.terminate?.(),e.close?.();}}}function ee(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{e.on("message",n=>r(n));},terminate:()=>{e.terminate?.(),e.close?.();}}}exports.createLinkedTransports=Y;exports.createWorkerEngine=G;exports.eventTargetTransport=Z;exports.messagePortTransport=ee;exports.serializeParsedLine=y;exports.serializeParsingResult=R;exports.serializeValue=m;exports.startWorkerRuntime=Q;//# sourceMappingURL=worker.cjs.map
3
3
  //# sourceMappingURL=worker.cjs.map
package/dist/worker.d.cts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { E as EngineConfigOverride } from './Configuration-BxriK9Kw.cjs';
2
- import { U as UnifiedParsingOptions, I as IEnginePackage, N as ParsedLine, P as ParsingResult } from './PackageRegistry-Bd8ErpwZ.cjs';
2
+ import { U as UnifiedParsingOptions, I as IEnginePackage, N as ParsedLine, P as ParsingResult } from './PackageRegistry-DLLVZW0S.cjs';
3
3
  import { F as FormattingSettings } from './FormattingSettings-ByO-4wiM.cjs';
4
4
  import { E as EngineError } from './EngineError-Bm4OYmw8.cjs';
5
- import { b as ValueType, i as ColourFormat, D as DatetimeGrain, V as Value } from './Value-B55Hvn3e.cjs';
6
- import { a as DiagnosticReportJSON } from './pipeline-C1-CJnFJ.cjs';
5
+ import { b as ValueType, i as ColourFormat, D as DatetimeGrain, V as Value } from './Value-wMuCzPn0.cjs';
6
+ import { a as DiagnosticReportJSON } from './pipeline-DKNPr6s8.cjs';
7
7
  import { C as CalendarBackend } from './CalendarBackend-MdS3Bb4P.cjs';
8
8
  import { S as SerializedEngineError } from './WorkerError-CexHHmbb.cjs';
9
- import './Parselet-DmMY2s9Y.cjs';
9
+ import './Parselet-ClR3Blwp.cjs';
10
10
  import './BytecodeBuilder-DSWKZi4f.cjs';
11
11
  import './Token-D8f7yaz1.cjs';
12
12
  import './Lexer-DaWkCu84.cjs';
13
13
  import './resolvers.cjs';
14
14
  import '@tanstack/query-core';
15
15
  import './TokenNormalizer-D382VSYh.cjs';
16
- import './VMBuiltins-Baa90D2v.cjs';
16
+ import './VMBuiltins-ClXnXk9K.cjs';
17
17
 
18
18
  /**
19
19
  * The seam between the harness and whatever actually carries messages.
package/dist/worker.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { E as EngineConfigOverride } from './Configuration-BxriK9Kw.js';
2
- import { U as UnifiedParsingOptions, I as IEnginePackage, N as ParsedLine, P as ParsingResult } from './PackageRegistry-D7_B0mxv.js';
2
+ import { U as UnifiedParsingOptions, I as IEnginePackage, N as ParsedLine, P as ParsingResult } from './PackageRegistry-ClAKDDOP.js';
3
3
  import { F as FormattingSettings } from './FormattingSettings-CvCzAfsz.js';
4
4
  import { E as EngineError } from './EngineError-Bm4OYmw8.js';
5
- import { b as ValueType, i as ColourFormat, D as DatetimeGrain, V as Value } from './Value-B55Hvn3e.js';
6
- import { a as DiagnosticReportJSON } from './pipeline-CADMN2D1.js';
5
+ import { b as ValueType, i as ColourFormat, D as DatetimeGrain, V as Value } from './Value-wMuCzPn0.js';
6
+ import { a as DiagnosticReportJSON } from './pipeline-CLegjVrf.js';
7
7
  import { C as CalendarBackend } from './CalendarBackend-MdS3Bb4P.js';
8
8
  import { S as SerializedEngineError } from './WorkerError-BaN8_eok.js';
9
- import './Parselet-Br1tHash.js';
9
+ import './Parselet-DkAFnfU2.js';
10
10
  import './BytecodeBuilder-DSWKZi4f.js';
11
11
  import './Token-D8f7yaz1.js';
12
12
  import './Lexer-DPn5dfCH.js';
13
13
  import './resolvers.js';
14
14
  import '@tanstack/query-core';
15
15
  import './TokenNormalizer-DAzPp-j1.js';
16
- import './VMBuiltins-BqkoJtHt.js';
16
+ import './VMBuiltins-Bk8TQNF1.js';
17
17
 
18
18
  /**
19
19
  * The seam between the harness and whatever actually carries messages.
package/dist/worker.js CHANGED
@@ -1,3 +1,3 @@
1
- import {a as a$1,e,d,c as c$2,b}from'./chunk-YID47OPR.js';import {o}from'./chunk-L2JQQ5EO.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-RMBUP4XA.js';import'./chunk-JP4JMQOG.js';import {c,a}from'./chunk-TFZNEEJR.js';import'./chunk-HLZRNZEU.js';import {z}from'./chunk-KSOB5FCI.js';import'./chunk-AWGSR2GZ.js';import {k}from'./chunk-ZISAN7NW.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-QP4VIEXZ.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import {g,f}from'./chunk-5TCSFTZD.js';import {R as R$1}from'./chunk-ZSFOIBIH.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import'./chunk-A34R65WT.js';import'./chunk-BWTVJD5L.js';import {b as b$1}from'./chunk-TCDB45AW.js';import'./chunk-6NL7RBAG.js';import'./chunk-JPFCXLJV.js';import'./chunk-APYRNAU2.js';import'./chunk-FAO6DQ74.js';import'./chunk-LHLW7JLS.js';import'./chunk-CHVGFTO3.js';import'./chunk-PRSXXDTA.js';import {c as c$1,d as d$1}from'./chunk-6G2NES2I.js';function B(e){if(e?.date?.inputOrder!=="locale")return e;let r={...e.date,inputOrder:k({...b$1.date,...e.date}).order};return delete r.inputLocale,{...e,date:r}}var x=class{constructor(r){this.nextId=1;this.pending=new Map;this.resolvedListeners=new Set;this.asyncErrorListeners=new Set;this.terminated=false;this.transport=r,this.transport.onMessage(n=>this.onMessage(n));}init(r){let n=this.nextId++;return new Promise((t,s)=>{this.pending.set(n,{resolve:()=>t(),reject:s}),this.transport.postMessage({kind:"init",id:n,localeCode:r.localeCode,diagnostics:r.diagnostics,config:B(r.config),packages:r.packages,formatting:r.formatting});})}parseDocument(r,n){let{signal:t,...s}=n??{},i=Object.keys(s).length>0?s:void 0;return this.call("parseDocument",[r,i],t)}evaluateLines(r,n){return this.call("evaluateLines",[r],n?.signal)}evaluateExpression(r,n){return this.call("evaluateExpression",[r],n?.signal)}onResolved(r){return this.resolvedListeners.add(r),()=>this.resolvedListeners.delete(r)}onAsyncError(r){return this.asyncErrorListeners.add(r),()=>this.asyncErrorListeners.delete(r)}terminate(){if(this.terminated)return;this.terminated=true;let r=e();for(let n of this.pending.values())this.unhook(n),n.reject(r);this.pending.clear(),this.resolvedListeners.clear(),this.asyncErrorListeners.clear(),this.transport.terminate();}call(r,n,t){if(this.terminated)return Promise.reject(e());if(t?.aborted)return Promise.reject(d(r));let s=this.nextId++;return new Promise((i,l)=>{let c={resolve:i,reject:l};if(t){let p=()=>{this.pending.has(s)&&(this.pending.delete(s),this.transport.postMessage({kind:"cancel",id:s}),l(d(r)));};c.signal=t,c.onAbort=p,t.addEventListener("abort",p,{once:true});}this.pending.set(s,c),this.transport.postMessage({kind:"request",id:s,method:r,args:n});})}onMessage(r){let n=r;switch(n.kind){case "ready":case "result":{let t=n.kind==="result"?n.value:void 0;this.settle(n.id,s=>s.resolve(t));break}case "error":this.settle(n.id,t=>t.reject(c$2(n.error)));break;case "async-update":for(let t of [...this.resolvedListeners])t(n.lines);break;case "async-error":for(let t of [...this.asyncErrorListeners])t({queryKey:n.queryKey,packageId:n.packageId,error:c$2(n.error)});break}}settle(r,n){let t=this.pending.get(r);t&&(this.pending.delete(r),this.unhook(t),n(t));}unhook(r){r.signal&&r.onAbort&&r.signal.removeEventListener("abort",r.onAbort);}};async function G(e){let r=new x(e.transport);return await r.init(e),r}function F(e){return e>0?"Infinity":e<0?"-Infinity":"NaN"}function H(e){let r=e.data.map(n=>typeof n=="object"&&n!==null?R$1(n):typeof n=="number"&&!Number.isFinite(n)?F(n):n);return {rows:e.rows,cols:e.cols,cells:r,hasSymbolic:e.hasSymbolic}}function m(e,r){let n=e.toNumber(),t={type:e.type,text:c(e,r),number:Number.isFinite(n)?n:0};Number.isFinite(n)||(t.nonFinite=F(n)),e.unit!==void 0&&(t.unit=e.unit),e.timedOut!==void 0&&(t.timedOut=e.timedOut),e.grain!==void 0&&(t.grain=e.grain),e.zone!==void 0&&(t.zone=e.zone);let s=e.value;if(typeof s=="bigint")t.bigint=s.toString();else if(e.type===7)t.matrix=H(s);else if(e.type===8){let i=s;t.range={min:i.min,max:i.max};}else if(e.type===14){let i=s;t.colour={hex:f(i),r:i.r,g:i.g,b:i.b,a:i.a,format:i.format,css:g(i)};}else if(e.type===16){let i=s;t.chart={kind:i.kind,points:i.points.map(l=>[l[0],l[1]]),label:i.label,domain:[i.domain[0],i.domain[1]],range:[i.range[0],i.range[1]],...i.expr!==void 0?{expr:i.expr}:{}};}else if(e.type===17){let i=s;t.ipCidr={...i.addr!==void 0?{addr:i.addr}:{},...i.prefix!==void 0?{prefix:i.prefix}:{},text:c(e).replace(/^=\s*/,"")};}return t}function q(e,r){return e?m(e,r):null}function J(e,r){return {start:e.start,end:e.end,expression:e.expression,lineNumber:e.lineNumber,columnNumber:e.columnNumber,result:q(e.result,r),error:e.error??null}}function y(e,r){return {lineNumber:e.lineNumber,text:e.text,startPosition:e.startPosition,endPosition:e.endPosition,isEmpty:e.isEmpty,hasInlineSolves:e.hasInlineSolves,inlineSolves:e.inlineSolves.map(n=>J(n,r)),expression:e.expression,result:q(e.result,r),error:e.error}}function R(e,r){let n={lines:e.lines.map(t=>y(t,r)),totalLines:e.totalLines,errors:[...e.errors]};return e.diagnostics!==void 0&&(n.diagnostics=e.diagnostics),n}function $(e,r){if(r===void 0)return e;let n=new Map(e.map(s=>[s.name,s])),t=[];for(let s of r){let i=n.get(s);if(!i)throw c$1.config(a$1.WORKER_UNKNOWN_PACKAGE,`No package named "${s}" is available in this worker runtime`,{name:s,available:[...n.keys()]});t.push(i);}return t}function Q(e,r={}){let n=r.packages??z,t=null,s,i=new Map,l=new Map,c=null,p=null,g=o=>e.postMessage(o),E=(o,a)=>{g({kind:"error",id:o,error:b(d$1(a))});},D=o=>{let a=new Map;return o.method==="parseDocument"?o.args[0].split(`
1
+ import {a as a$1,e,d,c as c$2,b}from'./chunk-YID47OPR.js';import {o}from'./chunk-34RTVUU3.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-GMHYWVOG.js';import'./chunk-JP4JMQOG.js';import {c,a}from'./chunk-XAKFFIMQ.js';import'./chunk-HLZRNZEU.js';import {z}from'./chunk-NW5MM3Q6.js';import'./chunk-BNVE6I22.js';import {k}from'./chunk-4H27GUVY.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-36JGHDZR.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import {g,f}from'./chunk-CAJKB4WQ.js';import {R as R$1}from'./chunk-CUH3FEWI.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import'./chunk-TSVKHY5E.js';import'./chunk-BWTVJD5L.js';import {b as b$1}from'./chunk-QXZVDT54.js';import'./chunk-6NL7RBAG.js';import'./chunk-JPFCXLJV.js';import'./chunk-APYRNAU2.js';import'./chunk-FAO6DQ74.js';import'./chunk-LHLW7JLS.js';import'./chunk-CHVGFTO3.js';import'./chunk-PRSXXDTA.js';import {c as c$1,d as d$1}from'./chunk-6G2NES2I.js';function B(e){if(e?.date?.inputOrder!=="locale")return e;let r={...e.date,inputOrder:k({...b$1.date,...e.date}).order};return delete r.inputLocale,{...e,date:r}}var x=class{constructor(r){this.nextId=1;this.pending=new Map;this.resolvedListeners=new Set;this.asyncErrorListeners=new Set;this.terminated=false;this.transport=r,this.transport.onMessage(n=>this.onMessage(n));}init(r){let n=this.nextId++;return new Promise((t,s)=>{this.pending.set(n,{resolve:()=>t(),reject:s}),this.transport.postMessage({kind:"init",id:n,localeCode:r.localeCode,diagnostics:r.diagnostics,config:B(r.config),packages:r.packages,formatting:r.formatting});})}parseDocument(r,n){let{signal:t,...s}=n??{},i=Object.keys(s).length>0?s:void 0;return this.call("parseDocument",[r,i],t)}evaluateLines(r,n){return this.call("evaluateLines",[r],n?.signal)}evaluateExpression(r,n){return this.call("evaluateExpression",[r],n?.signal)}onResolved(r){return this.resolvedListeners.add(r),()=>this.resolvedListeners.delete(r)}onAsyncError(r){return this.asyncErrorListeners.add(r),()=>this.asyncErrorListeners.delete(r)}terminate(){if(this.terminated)return;this.terminated=true;let r=e();for(let n of this.pending.values())this.unhook(n),n.reject(r);this.pending.clear(),this.resolvedListeners.clear(),this.asyncErrorListeners.clear(),this.transport.terminate();}call(r,n,t){if(this.terminated)return Promise.reject(e());if(t?.aborted)return Promise.reject(d(r));let s=this.nextId++;return new Promise((i,l)=>{let c={resolve:i,reject:l};if(t){let p=()=>{this.pending.has(s)&&(this.pending.delete(s),this.transport.postMessage({kind:"cancel",id:s}),l(d(r)));};c.signal=t,c.onAbort=p,t.addEventListener("abort",p,{once:true});}this.pending.set(s,c),this.transport.postMessage({kind:"request",id:s,method:r,args:n});})}onMessage(r){let n=r;switch(n.kind){case "ready":case "result":{let t=n.kind==="result"?n.value:void 0;this.settle(n.id,s=>s.resolve(t));break}case "error":this.settle(n.id,t=>t.reject(c$2(n.error)));break;case "async-update":for(let t of [...this.resolvedListeners])t(n.lines);break;case "async-error":for(let t of [...this.asyncErrorListeners])t({queryKey:n.queryKey,packageId:n.packageId,error:c$2(n.error)});break}}settle(r,n){let t=this.pending.get(r);t&&(this.pending.delete(r),this.unhook(t),n(t));}unhook(r){r.signal&&r.onAbort&&r.signal.removeEventListener("abort",r.onAbort);}};async function G(e){let r=new x(e.transport);return await r.init(e),r}function F(e){return e>0?"Infinity":e<0?"-Infinity":"NaN"}function H(e){let r=e.data.map(n=>typeof n=="object"&&n!==null?R$1(n):typeof n=="number"&&!Number.isFinite(n)?F(n):n);return {rows:e.rows,cols:e.cols,cells:r,hasSymbolic:e.hasSymbolic}}function m(e,r){let n=e.toNumber(),t={type:e.type,text:c(e,r),number:Number.isFinite(n)?n:0};Number.isFinite(n)||(t.nonFinite=F(n)),e.unit!==void 0&&(t.unit=e.unit),e.timedOut!==void 0&&(t.timedOut=e.timedOut),e.grain!==void 0&&(t.grain=e.grain),e.zone!==void 0&&(t.zone=e.zone);let s=e.value;if(typeof s=="bigint")t.bigint=s.toString();else if(e.type===7)t.matrix=H(s);else if(e.type===8){let i=s;t.range={min:i.min,max:i.max};}else if(e.type===14){let i=s;t.colour={hex:f(i),r:i.r,g:i.g,b:i.b,a:i.a,format:i.format,css:g(i)};}else if(e.type===16){let i=s;t.chart={kind:i.kind,points:i.points.map(l=>[l[0],l[1]]),label:i.label,domain:[i.domain[0],i.domain[1]],range:[i.range[0],i.range[1]],...i.expr!==void 0?{expr:i.expr}:{}};}else if(e.type===17){let i=s;t.ipCidr={...i.addr!==void 0?{addr:i.addr}:{},...i.prefix!==void 0?{prefix:i.prefix}:{},text:c(e).replace(/^=\s*/,"")};}return t}function q(e,r){return e?m(e,r):null}function J(e,r){return {start:e.start,end:e.end,expression:e.expression,lineNumber:e.lineNumber,columnNumber:e.columnNumber,result:q(e.result,r),error:e.error??null}}function y(e,r){return {lineNumber:e.lineNumber,text:e.text,startPosition:e.startPosition,endPosition:e.endPosition,isEmpty:e.isEmpty,hasInlineSolves:e.hasInlineSolves,inlineSolves:e.inlineSolves.map(n=>J(n,r)),expression:e.expression,result:q(e.result,r),error:e.error}}function R(e,r){let n={lines:e.lines.map(t=>y(t,r)),totalLines:e.totalLines,errors:[...e.errors]};return e.diagnostics!==void 0&&(n.diagnostics=e.diagnostics),n}function $(e,r){if(r===void 0)return e;let n=new Map(e.map(s=>[s.name,s])),t=[];for(let s of r){let i=n.get(s);if(!i)throw c$1.config(a$1.WORKER_UNKNOWN_PACKAGE,`No package named "${s}" is available in this worker runtime`,{name:s,available:[...n.keys()]});t.push(i);}return t}function Q(e,r={}){let n=r.packages??z,t=null,s,i=new Map,l=new Map,c=null,p=null,g=o=>e.postMessage(o),E=(o,a)=>{g({kind:"error",id:o,error:b(d$1(a))});},D=o=>{let a=new Map;return o.method==="parseDocument"?o.args[0].split(`
2
2
  `).forEach((u,d)=>a.set(d+1,u)):o.method==="evaluateLines"?o.args[0].forEach((u,d)=>a.set(d+1,u)):a.set(-1,o.args[0]),a},V=(o,a)=>{if(a.type==="error"){g({kind:"async-error",queryKey:a.queryKey,packageId:a.packageId,error:b(d$1(a.error))});return}let u=[];for(let d of a.lineNumbers){let f=l.get(d);if(f!==void 0)try{let T=o.evaluateLine(d,f);T&&u.push({lineNumber:d,value:m(T,s)});}catch{}}u.length>0&&g({kind:"async-update",lines:u});},U=o=>{p?.();let a=o.getEventStream().getReader();p=()=>{a.cancel();},(async()=>{try{for(;;){let{done:u,value:d}=await a.read();if(u)return;V(o,d);}}catch{}})();},j=o$1=>{try{let a$1=$(n,o$1.packages);t=new o({locale:o$1.localeCode??"en",diagnostics:o$1.diagnostics??!1,config:o$1.config,packages:a$1,calendar:r.calendar}),s=r.calendar?{...o$1.formatting??a,calendar:r.calendar}:o$1.formatting,U(t),g({kind:"ready",id:o$1.id});}catch(a){E(o$1.id,a);}},K=(o,a)=>{let{method:u,args:d}=a;switch(u){case "parseDocument":return R(o.parseDocument(d[0],d[1]),s);case "evaluateLines":return o.evaluateLines(d[0]).map(f=>y(f,s));case "evaluateExpression":return m(o.evaluateExpression(d[0]),s);default:throw c$1.execution(a$1.WORKER_UNKNOWN_METHOD,`The worker runtime has no method named "${String(u)}"`,{method:u})}},_=o=>{let a=t;if(!a){E(o.id,c$1.execution(a$1.WORKER_NOT_INITIALISED,"The worker received a request before its engine finished initialising"));return}c?.abort();let u=new AbortController;c=u,l=D(o),i.set(o.id,u),a.setKeystrokeSignal(u.signal);try{let d=K(a,o);g({kind:"result",id:o.id,value:d});}catch(d){E(o.id,d);}finally{i.delete(o.id),a.setKeystrokeSignal(null);}};return e.onMessage(o=>{let a=o;switch(a.kind){case "init":j(a);break;case "request":_(a);break;case "cancel":i.get(a.id)?.abort();break}}),()=>{p?.(),p=null,c?.abort(),c=null,l=new Map;for(let o of i.values())o.abort();i.clear(),t?.clear(),t=null,e.terminate();}}function X(e){return typeof globalThis.structuredClone=="function"?globalThis.structuredClone(e):JSON.parse(JSON.stringify(e))}function Y(){let e=null,r=null,n=true,t=(l,c)=>{let p=X(c);queueMicrotask(()=>{n&&l()?.(p);});};return {client:{postMessage:l=>t(()=>r,l),onMessage:l=>{e=l;},terminate:()=>{n=false;}},host:{postMessage:l=>t(()=>e,l),onMessage:l=>{r=l;},terminate:()=>{n=false;}}}}function Z(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{let n=t=>r(t.data);typeof e.addEventListener=="function"?e.addEventListener("message",n):e.onmessage=n,e.start?.();},terminate:()=>{e.terminate?.(),e.close?.();}}}function ee(e){return {postMessage:r=>e.postMessage(r),onMessage:r=>{e.on("message",n=>r(n));},terminate:()=>{e.terminate?.(),e.close?.();}}}export{Y as createLinkedTransports,G as createWorkerEngine,Z as eventTargetTransport,ee as messagePortTransport,y as serializeParsedLine,R as serializeParsingResult,m as serializeValue,Q as startWorkerRuntime};//# sourceMappingURL=worker.js.map
3
3
  //# sourceMappingURL=worker.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solve-engine",
3
- "version": "2.38.26",
3
+ "version": "2.38.28",
4
4
  "description": "An embeddable expression engine for natural-language calculations: units, currencies, percentages, dates and matrices, with the parsing and evaluation plumbing already built.",
5
5
  "keywords": [
6
6
  "expression-evaluator",
@@ -1,3 +0,0 @@
1
- import {a}from'./chunk-RAF57WYO.js';import {m,n,h as h$1}from'./chunk-L2JQQ5EO.js';import {a as a$1}from'./chunk-X2QJE3SV.js';import {b as b$2,a as a$2}from'./chunk-ZISAN7NW.js';import {b as b$1}from'./chunk-76F3LCIL.js';import {N,O,b as b$3}from'./chunk-QP4VIEXZ.js';import {h,i,P as P$1,j,k}from'./chunk-A34R65WT.js';import {b}from'./chunk-TCDB45AW.js';import {c as c$1}from'./chunk-6NL7RBAG.js';import {c,b as b$4}from'./chunk-6G2NES2I.js';var H=class{constructor(){this.root=null;}get length(){return this.root?this.root.size:0}get isEmpty(){return this.root===null}getAt(e){if(!(e<0||e>=(this.root?.size??0)))return this.nodeAt(this.root,e).lineId}insertAt(e,t){let[n,i]=A(this.root,e);this.root=R(R(n,fe(t)),i);}deleteAt(e){if(e<0||e>=(this.root?.size??0))return;let[t,n]=A(this.root,e),[i,r]=A(n,1),s=i?i.lineId:void 0;return this.root=R(t,r),s}spliceAt(e,t,n){let i=Math.max(0,e),r=Math.min(Math.max(0,t),(this.root?.size??0)-i),[s,o]=A(this.root,i),[u,a]=A(o,r),l=ge(u),c=z(n,0,n.length);return this.root=R(R(s,c),a),l}replaceAll(e){this.root=z(e,0,e.length);}getRange(e,t){let n=Math.max(0,e),i=Math.min((this.root?.size??0)-1,t);if(n>i)return [];let r=[];return this.collectRange(this.root,n,i,0,r),r}clear(){this.root=null;}*[Symbol.iterator](){yield*this.inOrder(this.root);}*inOrder(e){e&&(yield*this.inOrder(e.left),yield e.lineId,yield*this.inOrder(e.right));}nodeAt(e,t){let n=e.left?e.left.size:0;return t<n?this.nodeAt(e.left,t):t===n?e:this.nodeAt(e.right,t-n-1)}collectRange(e,t,n,i,r){if(!e)return;let s=e.left?e.left.size:0,o=i+s;o>t&&e.left&&this.collectRange(e.left,t,n,i,r),o>=t&&o<=n&&r.push(e.lineId),o<n&&e.right&&this.collectRange(e.right,t,n,o+1,r);}};function fe(d){return {lineId:d,size:1,priority:Math.random(),left:null,right:null}}function U(d){d.size=1+(d.left?d.left.size:0)+(d.right?d.right.size:0);}function R(d,e){return d?e?d.priority>e.priority?(d.right=R(d.right,e),U(d),d):(e.left=R(d,e.left),U(e),e):d:e}function A(d,e){if(!d)return [null,null];let t=d.left?d.left.size:0;if(e<=t){let[n,i]=A(d.left,e);return d.left=i,U(d),[n,d]}else {let[n,i]=A(d.right,e-t-1);return d.right=n,U(d),[d,i]}}function ge(d){let e=[];return Z(d,e),e}function Z(d,e){d&&(Z(d.left,e),e.push(d.lineId),Z(d.right,e));}function z(d,e,t){if(e>=t)return null;let n=Math.floor((e+t)/2),i=pe(d[n]);return {lineId:d[n],size:t-e,priority:i,left:z(d,e,n),right:z(d,n+1,t)}}function pe(d){let e=d+2654435769|0;return e=Math.imul(e>>>16^e,73244475),e=Math.imul(e>>>16^e,73244475),e=(e>>>16^e)>>>0,e/4294967296}var M=class{constructor(e=b.performance.maxDocumentLines){this.lines=new Map;this.orderTree=new H;this.nextLineId=1;this._positionCache=null;this.dirtyLineIds=new Set;this.tagIndex=null;this.maxLines=e;}setDocument(e){if(b$1(e,this.maxLines)>this.maxLines)throw c.execution("DOCUMENT_TOO_LARGE",`This document has more than ${this.maxLines.toLocaleString("en-US")} lines, which is the most the engine will hold at once`,{maxLines:this.maxLines});this.lines.clear(),this.orderTree.clear(),this._positionCache=null,this.dirtyLineIds.clear(),this.nextLineId=1,this.tagIndex=null;let n=e.split(`
2
- `),i=new Array(n.length);for(let r=0;r<n.length;r++){let s=this.nextLineId++;i[r]=s,this.lines.set(s,{lineId:s,textHash:a(n[r]),text:n[r],expressions:[],bytecodes:[],reads:[],writes:[],results:[],result:null,dirty:true,isVariableDef:false,isEmpty:n[r].trim().length===0,inlineSolveCount:0});}this.orderTree.replaceAll(i);for(let r of i)this.dirtyLineIds.add(r);}applyChanges(e){let t=[],n=[],i=[...e].sort((r,s)=>s.startLine-r.startLine);for(let r of i){let s=r.startLine-1,o=[];for(let a$1 of r.insertLines){let l=this.nextLineId++;o.push(l),t.push(l),this.lines.set(l,{lineId:l,textHash:a(a$1),text:a$1,expressions:[],bytecodes:[],reads:[],writes:[],results:[],result:null,dirty:true,isVariableDef:false,isEmpty:a$1.trim().length===0,inlineSolveCount:0});}for(let a of o)this.dirtyLineIds.add(a);if(this.tagIndex!==null)for(let a of o)this.indexTags(a,this.lines.get(a).text);let u=this.orderTree.spliceAt(s,r.deleteCount,o);for(let a of u)n.push(a),this.tagIndex!==null&&this.unindexTags(a,this.lines.get(a)?.text??""),this.lines.delete(a),this.dirtyLineIds.delete(a);}return this._positionCache=null,{inserted:t,removed:n}}insertLines(e,t){let n={startLine:e,deleteCount:0,insertLines:t};return this.applyChanges([n]).inserted}deleteLines(e,t){let n={startLine:e,deleteCount:t-e+1,insertLines:[]};return this.applyChanges([n]).removed}editLine(e,t){let n=this.getLineAt(e);if(!n)return false;let i=a(t);return i===n.textHash?false:(this.tagIndex!==null&&(this.unindexTags(n.lineId,n.text),this.indexTags(n.lineId,t)),n.text=t,n.textHash=i,n.expressions=[],n.bytecodes=[],n.results=[],n.result=null,n.inlineSolveCount=0,n.dirty=true,this.dirtyLineIds.add(n.lineId),n.isEmpty=t.trim().length===0,true)}linesCarryingTag(e){let t=this.ensureTagIndex().get(e.toLowerCase());if(t===void 0||t.size===0)return [];let n=[];for(let i of t){let r=this.getLinePosition(i);r>0&&n.push(r);}return n.sort((i,r)=>i-r),n}ensureTagIndex(){if(this.tagIndex!==null)return this.tagIndex;this.tagIndex=new Map;for(let e of this.lines.values())this.indexTags(e.lineId,e.text);return this.tagIndex}indexTags(e,t){if(!(t.indexOf("#")<0))for(let n of b$2(t)){let i=this.tagIndex.get(n);i===void 0?this.tagIndex.set(n,new Set([e])):i.add(e);}}unindexTags(e,t){if(!(t.indexOf("#")<0))for(let n of b$2(t)){let i=this.tagIndex.get(n);i!==void 0&&(i.delete(e),i.size===0&&this.tagIndex.delete(n));}}getLineAt(e){let t=e-1,n=this.orderTree.getAt(t);if(n!==void 0)return this.lines.get(n)}getLinePosition(e){if(this._positionCache)return this._positionCache.get(e)??-1;this._positionCache=new Map;let t=1;for(let n of this.orderTree)this._positionCache.set(n,t++);return this._positionCache.get(e)??-1}getVisibleLines(e,t){let n=this.orderTree.getRange(e-1,t-1),i=[];for(let r of n){let s=this.lines.get(r);s&&i.push(s);}return i}getLineStatesInRange(e,t){let n=this.orderTree.getRange(e-1,t-1),i=new Array(n.length);for(let r=0;r<n.length;r++)i[r]=this.lines.get(n[r]);return i}getAllLines(){return this.getVisibleLines(1,this.lineCount)}getLineById(e){return this.lines.get(e)}getDirtyLines(){let e=[];for(let t of this.lines.values())t.dirty&&e.push(t);return e}hasAnyDirtyLineBefore(e){for(let t of this.dirtyLineIds){let n=this.getLinePosition(t);if(n>=1&&n<e)return true}return false}hasAnyDirtyVariableDefLineBefore(e){for(let t of this.dirtyLineIds){let n=this.lines.get(t);if(!n||!n.isVariableDef)continue;let i=this.getLinePosition(t);if(i>=1&&i<e)return true}return false}get dirtyCount(){return this.dirtyLineIds.size}isBytecodeValid(e,t){let n=this.lines.get(e);return n!==void 0&&n.textHash===t}forgetResult(e){let t=this.lines.get(e);t&&(t.result=null,t.results=[]);}markClean(e){let t=this.lines.get(e);t&&(t.dirty=false,this.dirtyLineIds.delete(e));}markDirtyByLineNumber(e){let t=this.getLineAt(e);t&&(t.dirty=true,this.dirtyLineIds.add(t.lineId));}markDirty(e){let t=this.lines.get(e);t&&(t.dirty=true,this.dirtyLineIds.add(e));}invalidateAll(){for(let e of this.lines.values())e.dirty=true;this.dirtyLineIds=new Set(this.lines.keys());}updateLineResult(e,t,n,i,r,s,o,u=0){let a=this.lines.get(e);a&&(a.results=t,a.result=t[0]?.[0]??null,a.bytecodes=n,a.expressions=i,a.reads=r,a.writes=s,a.isVariableDef=o,a.inlineSolveCount=u,a.dirty=false,this.dirtyLineIds.delete(e));}updateLineCompiled(e,t,n,i,r,s,o=0){let u=this.lines.get(e);u&&(u.expressions=t,u.bytecodes=n,u.reads=i,u.writes=r,u.isVariableDef=s,u.inlineSolveCount=o);}get lineCount(){return this.orderTree.length}get isEmpty(){return this.orderTree.isEmpty}*[Symbol.iterator](){for(let e of this.orderTree){let t=this.lines.get(e);t&&(yield t);}}clear(){this.lines.clear(),this.orderTree.clear(),this._positionCache=null,this.nextLineId=1,this.tagIndex=null;}toJSON(){return {lineCount:this.lineCount,lines:this.getAllLines().map(e=>({lineId:e.lineId,text:e.text.substring(0,80),textHash:e.textHash,dirty:e.dirty,isVariableDef:e.isVariableDef,isEmpty:e.isEmpty,hasBytecode:e.bytecodes.length>0,hasResult:e.results.length>0,inlineSolveCount:e.inlineSolveCount,reads:e.reads,writes:e.writes}))}}};var T=class{constructor(){this.worker=null;this.nextId=1;this.pending=new Map;}ensureWorker(){if(this.worker)return this.worker;let e=h$1();if(e===null)throw new Error("no engine worker factory registered, so compilation stays on the main thread");return this.worker=e(),this.worker.onmessage=t=>{let n=t.data;if(!n||n.type!=="COMPILE_RESULT")return;let i=this.pending.get(n.id);if(!i)return;this.pending.delete(n.id);let r=[];for(let s of n.results)r.push(this.reconstructResult(s));i.resolve(r);},this.worker.onerror=t=>{for(let[n,i]of this.pending)i.reject(new Error(`Compilation worker error: ${t.message}`)),this.pending.delete(n);},this.worker}async compileBatch(e){if(e.length===0)return [];let t=this.ensureWorker(),n=this.nextId++;return new Promise((i,r)=>{this.pending.set(n,{resolve:i,reject:r}),t.postMessage({type:"COMPILE_BATCH",id:n,items:e});})}storeResults(e,t){let n=new Map;for(let s of e){if(s.error)continue;let o=t.getLineById(s.lineId);if(!o||o.textHash!==s.compiledAgainstHash)continue;let u=n.get(s.lineId);u||(u={bytecodes:[],reads:new Set,writes:new Set,isVariableDef:false,expressions:o.expressions.length>0?[...o.expressions]:[],textHash:s.compiledAgainstHash},n.set(s.lineId,u)),u.bytecodes.push(s.program);for(let a of s.reads)u.reads.add(a);for(let a of s.writes)u.writes.add(a);s.isVariableDef&&(u.isVariableDef=true);}let r=0;for(let[s,o]of n){if(o.bytecodes.length===0)continue;let a=t.getLineById(s)?.inlineSolveCount??0;t.updateLineCompiled(s,o.expressions,o.bytecodes,[...o.reads],[...o.writes],o.isVariableDef,a),r+=o.bytecodes.length;}return r}terminate(){this.worker&&(this.worker.terminate(),this.worker=null,this.pending.clear());}get isActive(){return this.worker!==null}reconstructResult(e){if(e.error)return {lineId:e.lineId,compiledAgainstHash:e.compiledAgainstHash,program:{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},reads:[],writes:[],isVariableDef:false,error:e.error};let t=e.opcodesLength>0?new Uint8Array(e.opcodesBuffer,0,e.opcodesLength):new Uint8Array(0),n=e.numbersLength>0?new Float64Array(e.numbersBuffer,0,e.numbersLength):new Float64Array(0),i={opcodes:t,numbers:n,strings:e.strings,hasAsync:false};return {lineId:e.lineId,compiledAgainstHash:e.compiledAgainstHash,program:i,reads:e.reads,writes:e.writes,isVariableDef:e.isVariableDef,error:null}}};var J=128,V=3,ae=6,ue=2,de=V,_=class d{constructor(){this.lastViewportStart=null;this.savedDirection=null;this.pageAccess=new Map;this.accessSeq=0;}static pageForLine(e){return Math.floor((e-1)/J)}static pageRange(e,t){return {startLine:e*J+1,endLine:Math.min((e+1)*J,t)}}detectDirection(e){return this.lastViewportStart===null?null:e.startLine>this.lastViewportStart?"down":e.startLine<this.lastViewportStart?"up":null}maintainAfterEval(e,t){this.savedDirection=this.detectDirection(e),this.lastViewportStart=e.startLine;let n=t.lineCount,i=d.pageForLine(e.startLine),r=d.pageForLine(e.endLine),s=d.pageForLine(n),o=Math.max(0,i-V),u=Math.min(s,r+V),a=Math.max(0,i-ae),l=Math.min(s,r+ae);for(let f=o;f<=u;f++)this.touchPage(f);for(let f=a;f<=l;f++)f>=o&&f<=u||this.evictPageResults(f,t,n);let c=a-1,h=Math.max(0,c-de+1);for(let f=h;f<=c;f++)this.evictPageBytecode(f,t,n);let m=l+1,g=Math.min(s,m+de-1);for(let f=m;f<=g;f++)this.evictPageBytecode(f,t,n);}getPreloadTargets(e,t){let n=this.savedDirection;if(!n)return [];let i=[],r=d.pageForLine(e.endLine),s=d.pageForLine(e.startLine),o=d.pageForLine(t.lineCount),u=[];if(n==="down"){let a=r+V+1,l=Math.min(a+ue-1,o);for(let c=a;c<=l&&c<=o;c++)u.push(c);}else {let a=s-V-1;for(let l=a;l>a-ue&&l>=0;l--)u.push(l);}for(let a of u){let l=d.pageRange(a,t.lineCount);for(let c=l.startLine;c<=l.endLine;c++){let h=t.getLineAt(c);if(h&&h.dirty&&!(h.bytecodes.length>0&&!h.isVariableDef)&&!h.isEmpty)if(h.expressions.length>0)for(let m of h.expressions)m.trim()&&i.push({lineId:h.lineId,expression:m,textHash:h.textHash});else {let m=c$1.findInlineSolves(h.text);if(m.length>0)for(let g of m)g.expression.trim()&&i.push({lineId:h.lineId,expression:g.expression,textHash:h.textHash});else {let g=h.text.trim();g&&i.push({lineId:h.lineId,expression:g,textHash:h.textHash});}}}}return i}clear(){this.pageAccess.clear(),this.accessSeq=0,this.lastViewportStart=null,this.savedDirection=null;}touchPage(e){this.pageAccess.set(e,++this.accessSeq);}evictPageResults(e,t,n){let i=d.pageRange(e,n);for(let r=i.startLine;r<=i.endLine;r++){let s=t.getLineAt(r);s&&!s.isVariableDef&&s.results.length>0&&(s.results=[],s.result=null);}}evictPageBytecode(e,t,n){let i=d.pageRange(e,n);for(let r=i.startLine;r<=i.endLine;r++){let s=t.getLineAt(r);!s||s.isVariableDef||(s.bytecodes.length>0||s.results.length>0)&&(s.bytecodes=[],s.results=[],s.result=null,t.markDirty(s.lineId));}}};var ce=(i=>(i[i.Tier1=1]="Tier1",i[i.Tier2=2]="Tier2",i[i.Tier3=3]="Tier3",i[i.Skipped=0]="Skipped",i))(ce||{});function Q(d){let e=new Set;for(let t of d)if(t.userFunctionBodies!==void 0)for(let n of t.userFunctionBodies)e.add(n.name);return e}function Y(d,e){let t=0;for(let n of d)if(n===e&&++t===2)return true;return false}var P=class{constructor(e,t,n){this.compilationWorker=null;this.textHashOfRecordedEdges=new Map;this.selfReadingWrites=new Map;this.cycleMemberIds=new Set;this.movedFloor=Number.MAX_SAFE_INTEGER;this.globalUnsubscribe=null;this.doc=e,this.engine=t,this.dag=t.getDag(),this.checkpointer=n??new a$1(t.getVM()),this.pageManager=new _,this.engine.getBatcher().checkpointer=this.checkpointer,this.engine.setDocumentModel(this.doc),this.globalUnsubscribe=N.subscribe(i=>{for(let r of this.dag.getAffectedLines(O(i)))this.doc.markDirtyByLineNumber(r);});}evaluate(e,t){this.engine.setKeystrokeSignal(t??null),h();try{this.reseedAccumulators();let n=this.engine.userUnitNames(),i=[],r=new Map,s={tier1:0,tier2:0,tier3:0,skipped:0},o=this.doc.lineCount,u=Math.min(e.endLine,o);this.forgetMovedBelowViewport(u);let a=this.doc.getLineStatesInRange(1,u);for(let c=1;c<=u;c++){let h=a[c-1];if(!h){s.skipped++;continue}let m=c>=e.startLine&&c<=e.endLine,g=this.evaluateSingleLine(h,c,m);i.push(g),g.tier===1?s.tier1++:g.tier===2?s.tier2++:g.tier===3?s.tier3++:s.skipped++,g.results&&m&&r.set(c,g.results.flat());}this.settleCycles(),this.pageManager.maintainAfterEval(e,this.doc),this.engine.settleOrphanedNames();let l=new Set(this.engine.userUnitNames());return n.some(c=>!l.has(c))&&this.engine.invalidateForRemovedUserUnits(),{lines:i,resultMap:r,tierCounts:s}}finally{this.engine.setKeystrokeSignal(null),i();}}backgroundCompile(e){let t=[],n=this.doc.lineCount,i=e.endLine+1;for(let r=i;r<=n;r++){let s=this.doc.getLineAt(r);if(!s||!s.dirty||s.bytecodes.length>0&&!s.isVariableDef)continue;let o=this.evaluateSingleLine(s,r,false);t.push(o);}return t}dispatchBackgroundCompiles(e){let t=this.collectInvisibleCompileTargets(e);t.length!==0&&(this.compilationWorker||(this.compilationWorker=new T),this.compilationWorker.compileBatch(t).then(n=>{this.compilationWorker.storeResults(n,this.doc);}).catch(n=>{}));}terminateWorker(){this.compilationWorker&&(this.compilationWorker.terminate(),this.compilationWorker=null),this.globalUnsubscribe&&(this.globalUnsubscribe(),this.globalUnsubscribe=null);}getDoc(){return this.doc}evaluateAll(e){let t={startLine:1,endLine:this.doc.lineCount};return this.evaluate(t,e)}setViewport(e,t){if(this.engine.setKeystrokeSignal(t??null),e.startLine>1&&this.hasDirtyLinesBefore(e.startLine))return this.evaluate(e,t);this.reseedAccumulators(),this.pageManager.maintainAfterEval(e,this.doc),this.preloadNextPages(e),this.restoreTo(e.startLine-1),h();try{return this.collectEvalResults(e.startLine,e.endLine)}finally{this.engine.setKeystrokeSignal(null),i();}}applyTransaction(e){let t=new Set;for(let o of e)for(let u=0;u<o.deleteCount;u++){let a=o.startLine+u,l=this.dag.getWrites(a);for(let c of l)t.add(c);this.undefineOrphans(this.dag.removeLine(a)),this.engine.undefineUserUnitsFrom(this.doc.getLineAt(a)?.lineId??-1)&&this.engine.invalidateForRemovedUserUnits(),this.engine.getLineCache().removeAllForLine(a);}let n=new Set,i=new Set;for(let o of this.dag.linesReadingAPosition()){let u=this.doc.getLineAt(o);u&&(n.add(u.lineId),i.add(u.lineId));}for(let o of t){let u=this.dag.getAffectedLines(o);for(let a of u){let l=this.doc.getLineAt(a);l&&n.add(l.lineId);}}let r=this.doc.applyChanges(e);this.checkpointer?.renumber(o=>this.doc.getLinePosition(o));for(let o of t)this.engine.restoreToPrefix(o,Number.MAX_SAFE_INTEGER);for(let o of n)this.doc.markDirty(o);for(let o of i)this.doc.forgetResult(o);let s=e.reduce((o,u)=>Math.min(o,u.startLine),Number.MAX_SAFE_INTEGER);this.movedFloor=Math.min(this.movedFloor,s),this.dag.clear();for(let o of r.removed)this.textHashOfRecordedEdges.delete(o),this.selfReadingWrites.delete(o),this.cycleMemberIds.delete(o);return {inserted:r.inserted,removed:r.removed}}forgetPositionsOfEditedText(e,t){let n=this.textHashOfRecordedEdges.get(e.lineId);n!==e.textHash&&(n!==void 0&&this.dag.forgetPositionReads(t),this.textHashOfRecordedEdges.set(e.lineId,e.textHash));}settleCycles(){let e=this.dag.takeReadersThatGainedAPosition(),t=this.dag.takeEdgeChanges(),n=new Set(e);for(let i of t.lines)n.add(i);for(let i of t.keys)if(!b$3(i))for(let r of this.dag.directConsumersOf(i))n.add(r);if(n.size!==0){if(this.cycleMemberIds.size>0){let i=this.doc.lineCount;for(let r=1;r<=i;r++){let s=this.doc.getLineAt(r);s!==void 0&&this.cycleMemberIds.has(s.lineId)&&n.add(r);}}this.recomputeCycleMembership(n);}}recomputeCycleMembership(e){let t=new Map,n=new Map,i=new Set,r=[],s=[],o=0,u=l=>{t.set(l,o),n.set(l,o),o++,r.push(l),i.add(l),s.push({line:l,targets:this.dependantsOf(l),next:0});},a=(l,c)=>{let h=this.doc.getLineAt(l);h!==void 0&&c!==this.cycleMemberIds.has(h.lineId)&&(c?this.cycleMemberIds.add(h.lineId):this.cycleMemberIds.delete(h.lineId),this.doc.markDirty(h.lineId));};for(let l of e)if(!t.has(l))for(u(l);s.length>0;){let c=s[s.length-1];if(c.next<c.targets.length){let g=c.targets[c.next++];t.has(g)?i.has(g)&&n.set(c.line,Math.min(n.get(c.line),t.get(g))):u(g);continue}if(s.pop(),s.length>0){let g=s[s.length-1].line;n.set(g,Math.min(n.get(g),n.get(c.line)));}if(n.get(c.line)!==t.get(c.line))continue;let h=[],m;do m=r.pop(),i.delete(m),h.push(m);while(m!==c.line);for(let g of h)a(g,h.length>1);}}dependantsOf(e){let t=[...this.dag.getAffectedLinesByPosition(e)];for(let n of this.dag.getWrites(e))if(!b$3(n)){for(let i of this.dag.directConsumersOf(n))t.push(i);if(this.engine.isAccumulatorName(n))for(let i of this.dag.getProducers(n))i>e&&t.push(i);}return t}reseedAccumulators(){let e=this.engine.resetAccumulators();if(e.size===0)return;let t=this.doc.lineCount;for(let n=1;n<=t;n++){let i=this.doc.getLineAt(n);if(!(i===void 0||i.writes.length===0)){for(let r of i.writes)if(e.has(r)){this.doc.markDirtyByLineNumber(n);break}}}}forgetMovedBelowViewport(e){if(this.movedFloor===Number.MAX_SAFE_INTEGER)return;let t=Math.max(e+1,this.movedFloor),n=this.doc.lineCount;for(let i=t;i<=n;i++){let r=this.doc.getLineAt(i);r&&this.doc.forgetResult(r.lineId);}this.movedFloor=Number.MAX_SAFE_INTEGER;}collectEvalResults(e,t){let n=[],i=new Map,r={tier1:0,tier2:0,tier3:0,skipped:0},s=this.doc.lineCount,o=Math.min(t,s);this.forgetMovedBelowViewport(o);for(let u=e;u<=o;u++){let a=this.doc.getLineAt(u);if(!a)continue;let l=this.evaluateSingleLine(a,u,true);n.push(l),l.tier===1?r.tier1++:l.tier===2?r.tier2++:l.tier===3?r.tier3++:r.skipped++,l.results&&i.set(u,l.results.flat());}return this.settleCycles(),{lines:n,resultMap:i,tierCounts:r}}hasDirtyLinesBefore(e){return this.doc.hasAnyDirtyVariableDefLineBefore(e)}evaluateSingleLine(e,t,n){e.dirty&&this.forgetPositionsOfEditedText(e,t);let i=this.cycleMemberIds.has(e.lineId);if(this.engine.setLineOnCycle(i),i)for(let s of e.reads)b$3(s)||this.engine.restoreToPrefix(s,t);let r=this.dispatchLine(e,t,n);return (r.tier===1||r.tier===2)&&this.dag.reconcilePositionReads(t),r}dispatchLine(e,t,n){let i={lineId:e.lineId,lineNumber:t};if(!e.dirty&&!n)return {...i,tier:0,result:null,error:null};if(e.isEmpty||m(e.text))return this.deregisterIfDirty(e,t),e.isEmpty=true,this.doc.markClean(e.lineId),{...i,tier:0,result:null,error:null};let{expressions:r,inlineSolveCount:s}=this.extractExpressions(e);return r.length===0?(this.deregisterIfDirty(e,t),e.isEmpty=true,this.doc.markClean(e.lineId),{...i,tier:0,result:null,error:null}):e.dirty?n?this.evaluateTier1(e,t,r,s,i):e.bytecodes.length>0&&e.bytecodes.length===r.length&&!e.isVariableDef?{...i,tier:0,result:null,error:null}:this.evaluateTier3(e,t,r,s,i):n&&e.bytecodes.length>0?this.evaluateTier2(e,t,i):{...i,tier:0,result:null,error:null}}deregisterIfDirty(e,t){if(e.dirty){for(let n of e.writes)this.engine.restoreToPrefix(n,t);e.reads=[],e.writes=[],this.registerWithTags(t,[],[]),this.engine.undefineUserUnitsFrom(e.lineId),this.checkpointer?.dropCheckpointAt(t);}}registerWithTags(e,t,n){let i=this.doc.getLineAt(e)?.text??"",r=a$2(i,t,n);this.undefineOrphans(this.dag.registerLine(e,r.reads,r.writes));}undefineOrphans(e){this.engine.forgetOrphanedNames(e);}evaluateTier1(e,t,n,i,r){this.engine.undefineUserUnitsFrom(e.lineId);let s=[],o=[],u=new Set,a=new Set,l=false,c=null,h=null,m=false,g=false;for(let w of e.writes)this.engine.restoreToPrefix(w,t);let f=new Set,x=[];for(let w of n){if(!w.trim())continue;let I=null,b;try{let p=this.engine.evaluateLine(t,w);I=[p],c=p,b=this.engine.getLineCache().get(t,w);}catch(p){let C=p instanceof Error?p.message:String(p);h||(h=C),m=true,I=null;}I&&I.some(p=>p.type===12)&&(g=true),I?s.push(I):s.push([P$1("eval_failed",h??"unknown error")]);let L=I===null;if(b){o.push(b.bytecode);for(let p of b.readVariables)u.add(p);b.writeVariable&&(a.add(b.writeVariable),l=true,Y(b.readVariables,b.writeVariable)&&x.push(b.writeVariable),L&&!f.has(b.writeVariable)?this.engine.restoreToPrefix(b.writeVariable,t):L||f.add(b.writeVariable));}else try{let{program:p,reads:C,writes:E}=this.engine.compileExpression(w);o.push(p);for(let y of C)u.add(y);for(let y of E)a.add(y);E.length>0&&(l=!0);for(let y of E)Y(C,y)&&x.push(y);for(let y of E)L&&!f.has(y)?this.engine.restoreToPrefix(y,t):L||f.add(y);}catch(p){if(o.push({opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false}),p instanceof b$4&&p.context){let C=p.context.reads,E=p.context.writes;if(Array.isArray(C))for(let y of C)u.add(y);if(Array.isArray(E))for(let y of E)a.add(y),f.has(y)||this.engine.restoreToPrefix(y,t);}}}let S=[...u],v=[...a];return m||g?(this.doc.updateLineCompiled(e.lineId,n,o,S,v,l,i),e.results=s,e.result=s[0]?.[0]??null,e.inlineSolveCount=i,e.expressions=n):this.doc.updateLineResult(e.lineId,s,o,n,S,v,l,i),x.length>0?this.selfReadingWrites.set(e.lineId,x):this.selfReadingWrites.delete(e.lineId),this.registerWithTags(t,S,v),this.checkpointer&&v.length>0&&!g?this.checkpointer.snapshot(t,e.lineId,v,Q(o)):this.checkpointer&&v.length===0&&this.checkpointer.dropCheckpointAt(t),{...r,tier:1,result:c,results:s,error:h}}evaluateTier2(e,t,n){if(e.bytecodes.length===0)return {...n,tier:0,result:null,error:null};let i=[],r=null,s=null,o=false;for(let l of this.selfReadingWrites.get(e.lineId)??[])this.engine.restoreToPrefix(l,t);let u=this.engine.getLineCache(),a=new Set;for(let l=0;l<e.bytecodes.length;l++){let c=e.bytecodes[l];if(c.opcodes.length===0)continue;let h=u.get(t,e.expressions[l]??""),m=h!==void 0?h.writeVariable===null?[]:[h.writeVariable]:e.writes,g=false;try{let f=this.engine.executeCached(c,t);r=f,i.push([f]);}catch(f){let x=f instanceof Error?f.message:String(f);s||(s=x),o=true,g=true,i.push([P$1("exec_failed",x)]);}for(let f of m)g&&!a.has(f)?this.engine.restoreToPrefix(f,t):g||a.add(f);}return this.registerWithTags(t,e.reads,e.writes),i.length>0?(e.results=i,e.result=i[0][0]??null):e.result!==null&&j()&&(e.results=e.results.map(l=>l.map(k)),e.result=e.results[0]?.[0]??k(e.result)),o&&this.doc.markDirty(e.lineId),this.checkpointer&&e.writes.length>0&&!o&&this.checkpointer.snapshot(t,e.lineId,e.writes,Q(e.bytecodes)),{...n,tier:2,result:i.length>0?r:e.result,results:i.length>0?i:e.results,error:s}}evaluateTier3(e,t,n,i,r){let s=[],o=new Set,u=new Set,a=false,l=null,c=null,h=false,m=false;for(let v of e.writes)this.engine.restoreToPrefix(v,t);let g=new Set,f=[];for(let v of n){if(!v.trim())continue;let w;try{w=this.engine.compileExpression(v);}catch(p){let C=p instanceof Error?p.message:String(p);if(c||(c=C),h=true,s.push({opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false}),p instanceof b$4&&p.context){let E=p.context.reads,y=p.context.writes;if(Array.isArray(E))for(let k of E)o.add(k);if(Array.isArray(y))for(let k of y)u.add(k),g.has(k)||this.engine.restoreToPrefix(k,t);}continue}let{program:I,reads:b,writes:L}=w;s.push(I);for(let p of b)o.add(p);for(let p of L)u.add(p);L.length>0&&(a=true);for(let p of L)Y(b,p)&&f.push(p);if(L.length>0&&I.opcodes.length>0)try{l=this.engine.executeCached(I,t),l&&l.type===12&&(m=!0);for(let p of L)g.add(p);}catch(p){let C=p instanceof Error?p.message:String(p);c||(c=C),h=true;for(let E of L)g.has(E)||this.engine.restoreToPrefix(E,t);}}let x=[...o],S=[...u];return this.doc.updateLineCompiled(e.lineId,n,s,x,S,a,i),this.registerWithTags(t,x,S),f.length>0?this.selfReadingWrites.set(e.lineId,f):this.selfReadingWrites.delete(e.lineId),a&&l&&!h&&!m&&(e.results=[[l]],e.result=l,this.doc.markClean(e.lineId)),this.checkpointer&&S.length>0&&!m?this.checkpointer.snapshot(t,e.lineId,S,Q(s)):this.checkpointer&&S.length===0&&this.checkpointer.dropCheckpointAt(t),{...r,tier:3,result:l,results:a&&l&&!h&&!m?[[l]]:void 0,error:c}}restoreTo(e){this.checkpointer&&this.checkpointer.restoreTo(e);}getCheckpointer(){return this.checkpointer}getPageManager(){return this.pageManager}preloadNextPages(e){let t=this.pageManager.getPreloadTargets(e,this.doc);t.length!==0&&(this.compilationWorker||(this.compilationWorker=new T),this.compilationWorker.compileBatch(t).then(n=>{this.compilationWorker.storeResults(n,this.doc);}).catch(n=>{}));}collectInvisibleCompileTargets(e){let t=[],n=this.doc.lineCount,i=e.endLine+1;for(let r=i;r<=n;r++){let s=this.doc.getLineAt(r);if(!s||!s.dirty||s.bytecodes.length>0&&!s.isVariableDef||s.isEmpty||m(s.text))continue;let{expressions:o}=this.extractExpressions(s);if(o.length!==0)for(let u of o)u.trim()&&t.push({lineId:s.lineId,expression:u,textHash:s.textHash});}return t}extractExpressions(e){if(e.expressions.length>0)return {expressions:e.expressions,inlineSolveCount:e.inlineSolveCount};let t=e.text.trim();if(t.length===0)return {expressions:[],inlineSolveCount:0};let n=c$1.findInlineSolves(e.text);return n.length>0?{expressions:n.map(i=>i.expression),inlineSolveCount:n.length}:{expressions:[t],inlineSolveCount:0}}};function he(d){return typeof d.unit=="string"?d.unit:String(d.value)}function me(d,e,t={inputType:"markdown"}){let n$1=d.getDocumentModel(),i=new M;i.setDocument(e);let r=new P(i,d,new a$1(d.getVM()));try{let s=i.lineCount;r.evaluate({startLine:1,endLine:s});let o=[],u=[],a=0;for(let l=1;l<=s;l++){let c=i.getLineAt(l),h=c.text,m=a,g=a+h.length;a=g+1;let f=c.inlineSolveCount>0,x=[],S=null,v=null;c.isEmpty||(f?x=n(h,l).map((w,I)=>{let b=c.results[I]?.[0]??null;if(b&&b.type===13){let L=he(b);return u.push(`Line ${l}: ${L}`),{...w,result:null,error:L}}return {...w,result:b,error:null}}):(S=c.expressions[0]??null,v=c.result??null,v&&v.type===13&&u.push(`Line ${l}: ${he(v)}`))),o.push({lineNumber:l,text:h,startPosition:m,endPosition:g,isEmpty:c.isEmpty,hasInlineSolves:f,inlineSolves:x,expression:S,error:null,result:v});}return {lines:o,totalLines:s,errors:u}}finally{r.terminateWorker(),d.setDocumentModel(n$1);}}export{M as a,ce as b,P as c,me as d};//# sourceMappingURL=chunk-44E7U4O5.js.map
3
- //# sourceMappingURL=chunk-44E7U4O5.js.map