solve-engine 2.34.0 → 2.34.2

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 (114) hide show
  1. package/dist/{PackageCompatibility-E_5GtcQW.d.cts → PackageCompatibility-CuUVgjBW.d.cts} +1 -1
  2. package/dist/{PackageCompatibility-CkzZfoJ3.d.ts → PackageCompatibility-DscVGabN.d.ts} +1 -1
  3. package/dist/{PackageRegistry-DSqic8kz.d.ts → PackageRegistry-DJekaRdM.d.ts} +4 -4
  4. package/dist/{PackageRegistry-js47hr28.d.cts → PackageRegistry-G6qyHROU.d.cts} +4 -4
  5. package/dist/{Parselet-CQjcHOKw.d.ts → Parselet-Br1tHash.d.ts} +1 -1
  6. package/dist/{Parselet-s1sRRn8H.d.cts → Parselet-DmMY2s9Y.d.cts} +1 -1
  7. package/dist/{VMBuiltins-qgzA6qGi.d.ts → VMBuiltins-BnE1KdV5.d.ts} +2 -2
  8. package/dist/{VMBuiltins-JCavlQUj.d.cts → VMBuiltins-RpmR0yHh.d.cts} +2 -2
  9. package/dist/{VMCheckpoints-BxPzmdu0.d.cts → VMCheckpoints-D0_5-IIa.d.cts} +2 -2
  10. package/dist/{VMCheckpoints-DjjE92mf.d.ts → VMCheckpoints-DpHlGjJ3.d.ts} +2 -2
  11. package/dist/{Value-2TIKi-YL.d.cts → Value-B55Hvn3e.d.cts} +19 -0
  12. package/dist/{Value-2TIKi-YL.d.ts → Value-B55Hvn3e.d.ts} +19 -0
  13. package/dist/{chunk-WFT3XUSH.cjs → chunk-5N4XDULO.cjs} +2 -2
  14. package/dist/{chunk-WFT3XUSH.cjs.map → chunk-5N4XDULO.cjs.map} +1 -1
  15. package/dist/chunk-A34R65WT.js +2 -0
  16. package/dist/chunk-A34R65WT.js.map +1 -0
  17. package/dist/{chunk-2XOLAHW6.cjs → chunk-ASO4V4WR.cjs} +2 -2
  18. package/dist/{chunk-2XOLAHW6.cjs.map → chunk-ASO4V4WR.cjs.map} +1 -1
  19. package/dist/{chunk-G5TZ6TDA.js → chunk-AWGSR2GZ.js} +2 -2
  20. package/dist/{chunk-G5TZ6TDA.js.map → chunk-AWGSR2GZ.js.map} +1 -1
  21. package/dist/{chunk-4ASM522I.js → chunk-EQ37UQGY.js} +2 -2
  22. package/dist/chunk-EQ37UQGY.js.map +1 -0
  23. package/dist/chunk-ETQBU454.js +2 -0
  24. package/dist/chunk-ETQBU454.js.map +1 -0
  25. package/dist/{chunk-WCVPXBCW.cjs → chunk-F33PW6UP.cjs} +4 -4
  26. package/dist/{chunk-WCVPXBCW.cjs.map → chunk-F33PW6UP.cjs.map} +1 -1
  27. package/dist/{chunk-DGDVY6XI.js → chunk-F6FRMZWE.js} +3 -3
  28. package/dist/chunk-F6FRMZWE.js.map +1 -0
  29. package/dist/chunk-FAA47IKC.cjs +2 -0
  30. package/dist/chunk-FAA47IKC.cjs.map +1 -0
  31. package/dist/{chunk-24OW3AAU.js → chunk-GVFLZTIE.js} +3 -3
  32. package/dist/{chunk-24OW3AAU.js.map → chunk-GVFLZTIE.js.map} +1 -1
  33. package/dist/{chunk-ITH2RLRG.js → chunk-H57IABQ2.js} +3 -3
  34. package/dist/{chunk-ITH2RLRG.js.map → chunk-H57IABQ2.js.map} +1 -1
  35. package/dist/chunk-IAXRJ5II.cjs +3 -0
  36. package/dist/chunk-IAXRJ5II.cjs.map +1 -0
  37. package/dist/{chunk-4MD5L23F.js → chunk-IHPYXJIY.js} +2 -2
  38. package/dist/{chunk-4MD5L23F.js.map → chunk-IHPYXJIY.js.map} +1 -1
  39. package/dist/{chunk-AENL3Z66.js → chunk-INKOUIXV.js} +2 -2
  40. package/dist/{chunk-AENL3Z66.js.map → chunk-INKOUIXV.js.map} +1 -1
  41. package/dist/chunk-NH74IT7B.cjs +2 -0
  42. package/dist/chunk-NH74IT7B.cjs.map +1 -0
  43. package/dist/{chunk-ZSXQP7PD.cjs → chunk-NMZRAJLJ.cjs} +2 -2
  44. package/dist/{chunk-ZSXQP7PD.cjs.map → chunk-NMZRAJLJ.cjs.map} +1 -1
  45. package/dist/chunk-SDB2A3UL.cjs +2 -0
  46. package/dist/chunk-SDB2A3UL.cjs.map +1 -0
  47. package/dist/chunk-TZ3Q6GOC.js +3 -0
  48. package/dist/chunk-TZ3Q6GOC.js.map +1 -0
  49. package/dist/{chunk-D7URPV5Z.cjs → chunk-YX37ZCK3.cjs} +3 -3
  50. package/dist/{chunk-D7URPV5Z.cjs.map → chunk-YX37ZCK3.cjs.map} +1 -1
  51. package/dist/{chunk-G2LCDR52.cjs → chunk-ZTEZBVBC.cjs} +3 -3
  52. package/dist/chunk-ZTEZBVBC.cjs.map +1 -0
  53. package/dist/constants.cjs +1 -1
  54. package/dist/constants.js +1 -1
  55. package/dist/engine.cjs +1 -1
  56. package/dist/engine.d.cts +7 -7
  57. package/dist/engine.d.ts +7 -7
  58. package/dist/engine.js +1 -1
  59. package/dist/engine.worker.cjs +1 -1
  60. package/dist/engine.worker.js +1 -1
  61. package/dist/format.cjs +1 -1
  62. package/dist/format.d.cts +1 -1
  63. package/dist/format.d.ts +1 -1
  64. package/dist/format.js +1 -1
  65. package/dist/index.cjs +1 -1
  66. package/dist/index.d.cts +7 -7
  67. package/dist/index.d.ts +7 -7
  68. package/dist/index.js +1 -1
  69. package/dist/language.d.cts +6 -6
  70. package/dist/language.d.ts +6 -6
  71. package/dist/packages.cjs +1 -1
  72. package/dist/packages.d.cts +5 -5
  73. package/dist/packages.d.ts +5 -5
  74. package/dist/packages.js +1 -1
  75. package/dist/parser.d.cts +3 -3
  76. package/dist/parser.d.ts +3 -3
  77. package/dist/{pipeline-Bum6y1B9.d.cts → pipeline-C1-CJnFJ.d.cts} +1 -1
  78. package/dist/{pipeline-DOo3KHaq.d.ts → pipeline-CADMN2D1.d.ts} +1 -1
  79. package/dist/resolvers.d.cts +1 -1
  80. package/dist/resolvers.d.ts +1 -1
  81. package/dist/testing.cjs +2 -2
  82. package/dist/testing.d.cts +6 -6
  83. package/dist/testing.d.ts +6 -6
  84. package/dist/testing.js +1 -1
  85. package/dist/uom.cjs +1 -1
  86. package/dist/uom.d.cts +1 -1
  87. package/dist/uom.d.ts +1 -1
  88. package/dist/uom.js +1 -1
  89. package/dist/vm.cjs +1 -1
  90. package/dist/vm.d.cts +5 -5
  91. package/dist/vm.d.ts +5 -5
  92. package/dist/vm.js +1 -1
  93. package/dist/worker.cjs +2 -2
  94. package/dist/worker.d.cts +5 -5
  95. package/dist/worker.d.ts +5 -5
  96. package/dist/worker.js +1 -1
  97. package/package.json +1 -1
  98. package/dist/chunk-4ASM522I.js.map +0 -1
  99. package/dist/chunk-4XWZXP6I.js +0 -3
  100. package/dist/chunk-4XWZXP6I.js.map +0 -1
  101. package/dist/chunk-DGDVY6XI.js.map +0 -1
  102. package/dist/chunk-FESR6PZI.cjs +0 -2
  103. package/dist/chunk-FESR6PZI.cjs.map +0 -1
  104. package/dist/chunk-G2LCDR52.cjs.map +0 -1
  105. package/dist/chunk-INMJ7ZXL.js +0 -2
  106. package/dist/chunk-INMJ7ZXL.js.map +0 -1
  107. package/dist/chunk-LI6LYJDA.cjs +0 -2
  108. package/dist/chunk-LI6LYJDA.cjs.map +0 -1
  109. package/dist/chunk-O7HF345B.js +0 -2
  110. package/dist/chunk-O7HF345B.js.map +0 -1
  111. package/dist/chunk-QOOTRUY7.cjs +0 -3
  112. package/dist/chunk-QOOTRUY7.cjs.map +0 -1
  113. package/dist/chunk-S3SPDK6N.cjs +0 -2
  114. package/dist/chunk-S3SPDK6N.cjs.map +0 -1
@@ -1,17 +1,17 @@
1
- import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-js47hr28.cjs';
2
- import { V as Value } from './Value-2TIKi-YL.cjs';
1
+ import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-G6qyHROU.cjs';
2
+ import { V as Value } from './Value-B55Hvn3e.cjs';
3
3
  import { E as EngineError } from './EngineError-Bm4OYmw8.cjs';
4
- import { C as CompatibilityReport } from './PackageCompatibility-E_5GtcQW.cjs';
5
- import './Parselet-s1sRRn8H.cjs';
4
+ import { C as CompatibilityReport } from './PackageCompatibility-CuUVgjBW.cjs';
5
+ import './Parselet-DmMY2s9Y.cjs';
6
6
  import './BytecodeBuilder-DSWKZi4f.cjs';
7
7
  import './Token-D8f7yaz1.cjs';
8
- import './pipeline-Bum6y1B9.cjs';
8
+ import './pipeline-C1-CJnFJ.cjs';
9
9
  import './CalendarBackend-MdS3Bb4P.cjs';
10
10
  import './Lexer-DaWkCu84.cjs';
11
11
  import './resolvers.cjs';
12
12
  import '@tanstack/query-core';
13
13
  import './TokenNormalizer-D382VSYh.cjs';
14
- import './VMBuiltins-JCavlQUj.cjs';
14
+ import './VMBuiltins-RpmR0yHh.cjs';
15
15
  import './Configuration-BxriK9Kw.cjs';
16
16
 
17
17
  /**
package/dist/testing.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-DSqic8kz.js';
2
- import { V as Value } from './Value-2TIKi-YL.js';
1
+ import { I as IEnginePackage, E as ExpressionEngine } from './PackageRegistry-DJekaRdM.js';
2
+ import { V as Value } from './Value-B55Hvn3e.js';
3
3
  import { E as EngineError } from './EngineError-Bm4OYmw8.js';
4
- import { C as CompatibilityReport } from './PackageCompatibility-CkzZfoJ3.js';
5
- import './Parselet-CQjcHOKw.js';
4
+ import { C as CompatibilityReport } from './PackageCompatibility-DscVGabN.js';
5
+ import './Parselet-Br1tHash.js';
6
6
  import './BytecodeBuilder-DSWKZi4f.js';
7
7
  import './Token-D8f7yaz1.js';
8
- import './pipeline-DOo3KHaq.js';
8
+ import './pipeline-CADMN2D1.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-qgzA6qGi.js';
14
+ import './VMBuiltins-BnE1KdV5.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-ITH2RLRG.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-4ASM522I.js';import'./chunk-JP4JMQOG.js';import'./chunk-4XWZXP6I.js';import'./chunk-XEIDV5JP.js';import {z}from'./chunk-DGDVY6XI.js';import'./chunk-G5TZ6TDA.js';import'./chunk-TJKN466F.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-INMJ7ZXL.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-4MD5L23F.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import {m}from'./chunk-O7HF345B.js';import'./chunk-BWTVJD5L.js';import {a as a$1}from'./chunk-AENL3Z66.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-H57IABQ2.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-EQ37UQGY.js';import'./chunk-JP4JMQOG.js';import'./chunk-TZ3Q6GOC.js';import'./chunk-XEIDV5JP.js';import {z}from'./chunk-F6FRMZWE.js';import'./chunk-AWGSR2GZ.js';import'./chunk-TJKN466F.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-ETQBU454.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-5TCSFTZD.js';import'./chunk-IHPYXJIY.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-INKOUIXV.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 chunkZSXQP7PD_cjs=require('./chunk-ZSXQP7PD.cjs');require('./chunk-GDLYXRMA.cjs');var chunkSF5QVUEI_cjs=require('./chunk-SF5QVUEI.cjs');require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-S3SPDK6N.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 chunkZSXQP7PD_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 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
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-2TIKi-YL.cjs';
5
+ import './Value-B55Hvn3e.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-2TIKi-YL.js';
5
+ import './Value-B55Hvn3e.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-G5TZ6TDA.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-O7HF345B.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-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
2
2
  //# sourceMappingURL=uom.js.map
package/dist/vm.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkLI6LYJDA_cjs=require('./chunk-LI6LYJDA.cjs');require('./chunk-HG4NPDN5.cjs');var chunkFESR6PZI_cjs=require('./chunk-FESR6PZI.cjs');require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-WFT3XUSH.cjs'),require('./chunk-EQNKDTMX.cjs'),require('./chunk-E4HAKNBQ.cjs');var chunkS3SPDK6N_cjs=require('./chunk-S3SPDK6N.cjs');require('./chunk-PHWIO4P3.cjs'),require('./chunk-EZKR44MA.cjs'),require('./chunk-6SYU4MH7.cjs');var l=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,n,e){if(e.length===0)return null;let r=this.checkpoints.length>0?this.checkpoints[this.checkpoints.length-1]:null,o=Object.create(r?.variables??null),i=Object.create(r?.functions??null);for(let s of e){if(this.vm.hasUserFunction(s)){let p=this.vm.getUserFunction(s);p&&(i[s]=p);continue}let u=this.vm.getVar(s);u!==void 0&&(o[s]=u);}let c={lineNumber:t,lineId:n,variables:o,functions:i,parent:r};return this.checkpoints.push(c),c}restoreTo(t){let n=this.getNearestCheckpoint(t);if(!n){this.vm.reset();return}let e=[],r=n;for(;r;)e.unshift(r),r=r.parent;this.vm.reset();for(let o of e){for(let i of Object.keys(o.variables))this.vm.setVar(i,o.variables[i]);for(let i of Object.keys(o.functions)){let c=o.functions[i];this.vm.defineUserFunction(c.name,c.params,c.program);}}}getNearestCheckpoint(t){let n=null;for(let e of this.checkpoints)if(e.lineNumber<=t)n=e;else break;return n}getCheckpointAt(t){return this.checkpoints.find(n=>n.lineNumber===t)}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1].variables;for(;e;){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];e=Object.getPrototypeOf(e);}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};Object.defineProperty(exports,"DependencyGraph",{enumerable:true,get:function(){return chunkLI6LYJDA_cjs.a}});Object.defineProperty(exports,"ScopeManager",{enumerable:true,get:function(){return chunkLI6LYJDA_cjs.b}});Object.defineProperty(exports,"createVM",{enumerable:true,get:function(){return chunkLI6LYJDA_cjs.c}});Object.defineProperty(exports,"executeBytecode",{enumerable:true,get:function(){return chunkLI6LYJDA_cjs.d}});Object.defineProperty(exports,"OpRegistry",{enumerable:true,get:function(){return chunkFESR6PZI_cjs.v}});Object.defineProperty(exports,"allocatePluginFunctionIndex",{enumerable:true,get:function(){return chunkFESR6PZI_cjs.E}});Object.defineProperty(exports,"binaryOp",{enumerable:true,get:function(){return chunkFESR6PZI_cjs.u}});Object.defineProperty(exports,"builtinFunctions",{enumerable:true,get:function(){return chunkFESR6PZI_cjs.C}});Object.defineProperty(exports,"pluginFunctionIndexFor",{enumerable:true,get:function(){return chunkFESR6PZI_cjs.F}});Object.defineProperty(exports,"pluginFunctionRegistry",{enumerable:true,get:function(){return chunkFESR6PZI_cjs.D}});Object.defineProperty(exports,"sharedOpRegistry",{enumerable:true,get:function(){return chunkFESR6PZI_cjs.w}});Object.defineProperty(exports,"unifyUom",{enumerable:true,get:function(){return chunkFESR6PZI_cjs.j}});Object.defineProperty(exports,"Value",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.m}});Object.defineProperty(exports,"ValueType",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.g}});Object.defineProperty(exports,"bigIntValue",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.s}});Object.defineProperty(exports,"chargeAllocation",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.c}});Object.defineProperty(exports,"checkAllocation",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.d}});Object.defineProperty(exports,"checkedArray",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.e}});Object.defineProperty(exports,"colVectorValue",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.E}});Object.defineProperty(exports,"hexValue",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.r}});Object.defineProperty(exports,"matrixValue",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.C}});Object.defineProperty(exports,"numberValue",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.n}});Object.defineProperty(exports,"rangeValue",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.F}});Object.defineProperty(exports,"rowVectorValue",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.D}});Object.defineProperty(exports,"stringValue",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.t}});Object.defineProperty(exports,"uomValue",{enumerable:true,get:function(){return chunkS3SPDK6N_cjs.u}});exports.VMCheckpointer=l;//# sourceMappingURL=vm.cjs.map
1
+ 'use strict';var chunkSDB2A3UL_cjs=require('./chunk-SDB2A3UL.cjs');require('./chunk-HG4NPDN5.cjs');var chunkFAA47IKC_cjs=require('./chunk-FAA47IKC.cjs');require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5N4XDULO.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');var l=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,n,e){if(e.length===0)return null;let r=this.checkpoints.length>0?this.checkpoints[this.checkpoints.length-1]:null,o=Object.create(r?.variables??null),i=Object.create(r?.functions??null);for(let s of e){if(this.vm.hasUserFunction(s)){let p=this.vm.getUserFunction(s);p&&(i[s]=p);continue}let u=this.vm.getVar(s);u!==void 0&&(o[s]=u);}let c={lineNumber:t,lineId:n,variables:o,functions:i,parent:r};return this.checkpoints.push(c),c}restoreTo(t){let n=this.getNearestCheckpoint(t);if(!n){this.vm.reset();return}let e=[],r=n;for(;r;)e.unshift(r),r=r.parent;this.vm.reset();for(let o of e){for(let i of Object.keys(o.variables))this.vm.setVar(i,o.variables[i]);for(let i of Object.keys(o.functions)){let c=o.functions[i];this.vm.defineUserFunction(c.name,c.params,c.program);}}}getNearestCheckpoint(t){let n=null;for(let e of this.checkpoints)if(e.lineNumber<=t)n=e;else break;return n}getCheckpointAt(t){return this.checkpoints.find(n=>n.lineNumber===t)}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1].variables;for(;e;){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];e=Object.getPrototypeOf(e);}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};Object.defineProperty(exports,"DependencyGraph",{enumerable:true,get:function(){return chunkSDB2A3UL_cjs.a}});Object.defineProperty(exports,"ScopeManager",{enumerable:true,get:function(){return chunkSDB2A3UL_cjs.b}});Object.defineProperty(exports,"createVM",{enumerable:true,get:function(){return chunkSDB2A3UL_cjs.c}});Object.defineProperty(exports,"executeBytecode",{enumerable:true,get:function(){return chunkSDB2A3UL_cjs.d}});Object.defineProperty(exports,"OpRegistry",{enumerable:true,get:function(){return chunkFAA47IKC_cjs.v}});Object.defineProperty(exports,"allocatePluginFunctionIndex",{enumerable:true,get:function(){return chunkFAA47IKC_cjs.E}});Object.defineProperty(exports,"binaryOp",{enumerable:true,get:function(){return chunkFAA47IKC_cjs.u}});Object.defineProperty(exports,"builtinFunctions",{enumerable:true,get:function(){return chunkFAA47IKC_cjs.C}});Object.defineProperty(exports,"pluginFunctionIndexFor",{enumerable:true,get:function(){return chunkFAA47IKC_cjs.F}});Object.defineProperty(exports,"pluginFunctionRegistry",{enumerable:true,get:function(){return chunkFAA47IKC_cjs.D}});Object.defineProperty(exports,"sharedOpRegistry",{enumerable:true,get:function(){return chunkFAA47IKC_cjs.w}});Object.defineProperty(exports,"unifyUom",{enumerable:true,get:function(){return chunkFAA47IKC_cjs.j}});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}});exports.VMCheckpointer=l;//# sourceMappingURL=vm.cjs.map
2
2
  //# sourceMappingURL=vm.cjs.map
package/dist/vm.d.cts CHANGED
@@ -1,11 +1,11 @@
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 allocatePluginFunctionIndex, b as builtinFunctions, c as createVM, e as executeBytecode, p as pluginFunctionIndexFor, d as pluginFunctionRegistry, s as sharedOpRegistry } from './VMBuiltins-JCavlQUj.cjs';
2
- import { V as Value } from './Value-2TIKi-YL.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-2TIKi-YL.cjs';
4
- export { V as VMCheckpoint, a as VMCheckpointer } from './VMCheckpoints-BxPzmdu0.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 allocatePluginFunctionIndex, b as builtinFunctions, c as createVM, e as executeBytecode, p as pluginFunctionIndexFor, d as pluginFunctionRegistry, s as sharedOpRegistry } from './VMBuiltins-RpmR0yHh.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';
4
+ export { V as VMCheckpoint, a as VMCheckpointer } from './VMCheckpoints-D0_5-IIa.cjs';
5
5
  import './BytecodeBuilder-DSWKZi4f.cjs';
6
6
  import './CalendarBackend-MdS3Bb4P.cjs';
7
7
  import './EngineError-Bm4OYmw8.cjs';
8
- import './pipeline-Bum6y1B9.cjs';
8
+ import './pipeline-C1-CJnFJ.cjs';
9
9
 
10
10
  /**
11
11
  * The ceiling on how much memory one evaluation is allowed to ask for.
package/dist/vm.d.ts CHANGED
@@ -1,11 +1,11 @@
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 allocatePluginFunctionIndex, b as builtinFunctions, c as createVM, e as executeBytecode, p as pluginFunctionIndexFor, d as pluginFunctionRegistry, s as sharedOpRegistry } from './VMBuiltins-qgzA6qGi.js';
2
- import { V as Value } from './Value-2TIKi-YL.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-2TIKi-YL.js';
4
- export { V as VMCheckpoint, a as VMCheckpointer } from './VMCheckpoints-DjjE92mf.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 allocatePluginFunctionIndex, b as builtinFunctions, c as createVM, e as executeBytecode, p as pluginFunctionIndexFor, d as pluginFunctionRegistry, s as sharedOpRegistry } from './VMBuiltins-BnE1KdV5.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';
4
+ export { V as VMCheckpoint, a as VMCheckpointer } from './VMCheckpoints-DpHlGjJ3.js';
5
5
  import './BytecodeBuilder-DSWKZi4f.js';
6
6
  import './CalendarBackend-MdS3Bb4P.js';
7
7
  import './EngineError-Bm4OYmw8.js';
8
- import './pipeline-DOo3KHaq.js';
8
+ import './pipeline-CADMN2D1.js';
9
9
 
10
10
  /**
11
11
  * 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 DependencyGraph,b as ScopeManager,c as createVM,d as executeBytecode}from'./chunk-4ASM522I.js';import'./chunk-JP4JMQOG.js';export{v as OpRegistry,E as allocatePluginFunctionIndex,u as binaryOp,C as builtinFunctions,F as pluginFunctionIndexFor,D as pluginFunctionRegistry,w as sharedOpRegistry,j as unifyUom}from'./chunk-INMJ7ZXL.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-4MD5L23F.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-O7HF345B.js';import'./chunk-BWTVJD5L.js';import'./chunk-PRSXXDTA.js';import'./chunk-6G2NES2I.js';var l=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,n,e){if(e.length===0)return null;let r=this.checkpoints.length>0?this.checkpoints[this.checkpoints.length-1]:null,o=Object.create(r?.variables??null),i=Object.create(r?.functions??null);for(let s of e){if(this.vm.hasUserFunction(s)){let p=this.vm.getUserFunction(s);p&&(i[s]=p);continue}let u=this.vm.getVar(s);u!==void 0&&(o[s]=u);}let c={lineNumber:t,lineId:n,variables:o,functions:i,parent:r};return this.checkpoints.push(c),c}restoreTo(t){let n=this.getNearestCheckpoint(t);if(!n){this.vm.reset();return}let e=[],r=n;for(;r;)e.unshift(r),r=r.parent;this.vm.reset();for(let o of e){for(let i of Object.keys(o.variables))this.vm.setVar(i,o.variables[i]);for(let i of Object.keys(o.functions)){let c=o.functions[i];this.vm.defineUserFunction(c.name,c.params,c.program);}}}getNearestCheckpoint(t){let n=null;for(let e of this.checkpoints)if(e.lineNumber<=t)n=e;else break;return n}getCheckpointAt(t){return this.checkpoints.find(n=>n.lineNumber===t)}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1].variables;for(;e;){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];e=Object.getPrototypeOf(e);}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};export{l as VMCheckpointer};//# sourceMappingURL=vm.js.map
1
+ export{a as DependencyGraph,b as ScopeManager,c as createVM,d as executeBytecode}from'./chunk-EQ37UQGY.js';import'./chunk-JP4JMQOG.js';export{v as OpRegistry,E as allocatePluginFunctionIndex,u as binaryOp,C as builtinFunctions,F as pluginFunctionIndexFor,D as pluginFunctionRegistry,w as sharedOpRegistry,j as unifyUom}from'./chunk-ETQBU454.js';import'./chunk-X2GQAKL2.js';import'./chunk-PICFFFJV.js';import'./chunk-TZYMXNIB.js';import'./chunk-HFKDWQUL.js';import'./chunk-IHPYXJIY.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';var l=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,n,e){if(e.length===0)return null;let r=this.checkpoints.length>0?this.checkpoints[this.checkpoints.length-1]:null,o=Object.create(r?.variables??null),i=Object.create(r?.functions??null);for(let s of e){if(this.vm.hasUserFunction(s)){let p=this.vm.getUserFunction(s);p&&(i[s]=p);continue}let u=this.vm.getVar(s);u!==void 0&&(o[s]=u);}let c={lineNumber:t,lineId:n,variables:o,functions:i,parent:r};return this.checkpoints.push(c),c}restoreTo(t){let n=this.getNearestCheckpoint(t);if(!n){this.vm.reset();return}let e=[],r=n;for(;r;)e.unshift(r),r=r.parent;this.vm.reset();for(let o of e){for(let i of Object.keys(o.variables))this.vm.setVar(i,o.variables[i]);for(let i of Object.keys(o.functions)){let c=o.functions[i];this.vm.defineUserFunction(c.name,c.params,c.program);}}}getNearestCheckpoint(t){let n=null;for(let e of this.checkpoints)if(e.lineNumber<=t)n=e;else break;return n}getCheckpointAt(t){return this.checkpoints.find(n=>n.lineNumber===t)}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1].variables;for(;e;){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];e=Object.getPrototypeOf(e);}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};export{l as VMCheckpointer};//# 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'),chunkWCVPXBCW_cjs=require('./chunk-WCVPXBCW.cjs');require('./chunk-P5YWBIIU.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-R3W53ZMP.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-LI6LYJDA.cjs'),require('./chunk-HG4NPDN5.cjs');var chunkQOOTRUY7_cjs=require('./chunk-QOOTRUY7.cjs');require('./chunk-R2SZFJTT.cjs');var chunkG2LCDR52_cjs=require('./chunk-G2LCDR52.cjs');require('./chunk-ZSXQP7PD.cjs');var chunkM4UC2PB6_cjs=require('./chunk-M4UC2PB6.cjs');require('./chunk-K3PZ66XR.cjs'),require('./chunk-YV4GDW5A.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-GDLYXRMA.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-FESR6PZI.cjs'),require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs');var chunk5TVI2UPZ_cjs=require('./chunk-5TVI2UPZ.cjs'),chunkWFT3XUSH_cjs=require('./chunk-WFT3XUSH.cjs');require('./chunk-EQNKDTMX.cjs'),require('./chunk-E4HAKNBQ.cjs'),require('./chunk-S3SPDK6N.cjs'),require('./chunk-PHWIO4P3.cjs');var chunk2XOLAHW6_cjs=require('./chunk-2XOLAHW6.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:chunkM4UC2PB6_cjs.h({...chunk2XOLAHW6_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?chunkWFT3XUSH_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:chunkQOOTRUY7_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:chunkQOOTRUY7_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??chunkG2LCDR52_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 chunkWCVPXBCW_cjs.o({locale:o.localeCode??"en",diagnostics:o.diagnostics??!1,config:o.config,packages:a,calendar:r.calendar}),s=r.calendar?{...o.formatting??chunkQOOTRUY7_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'),chunkF33PW6UP_cjs=require('./chunk-F33PW6UP.cjs');require('./chunk-P5YWBIIU.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-R3W53ZMP.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-SDB2A3UL.cjs'),require('./chunk-HG4NPDN5.cjs');var chunkIAXRJ5II_cjs=require('./chunk-IAXRJ5II.cjs');require('./chunk-R2SZFJTT.cjs');var chunkZTEZBVBC_cjs=require('./chunk-ZTEZBVBC.cjs');require('./chunk-NMZRAJLJ.cjs');var chunkM4UC2PB6_cjs=require('./chunk-M4UC2PB6.cjs');require('./chunk-K3PZ66XR.cjs'),require('./chunk-YV4GDW5A.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-GDLYXRMA.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-FAA47IKC.cjs'),require('./chunk-OBZJKZ2F.cjs'),require('./chunk-SF5QVUEI.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs');var chunk5TVI2UPZ_cjs=require('./chunk-5TVI2UPZ.cjs'),chunk5N4XDULO_cjs=require('./chunk-5N4XDULO.cjs');require('./chunk-EQNKDTMX.cjs'),require('./chunk-E4HAKNBQ.cjs'),require('./chunk-NH74IT7B.cjs'),require('./chunk-PHWIO4P3.cjs');var chunkASO4V4WR_cjs=require('./chunk-ASO4V4WR.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:chunkM4UC2PB6_cjs.h({...chunkASO4V4WR_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?chunk5N4XDULO_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:chunkIAXRJ5II_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:chunkIAXRJ5II_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??chunkZTEZBVBC_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 chunkF33PW6UP_cjs.o({locale:o.localeCode??"en",diagnostics:o.diagnostics??!1,config:o.config,packages:a,calendar:r.calendar}),s=r.calendar?{...o.formatting??chunkIAXRJ5II_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-js47hr28.cjs';
2
+ import { U as UnifiedParsingOptions, I as IEnginePackage, N as ParsedLine, P as ParsingResult } from './PackageRegistry-G6qyHROU.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-2TIKi-YL.cjs';
6
- import { a as DiagnosticReportJSON } from './pipeline-Bum6y1B9.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';
7
7
  import { C as CalendarBackend } from './CalendarBackend-MdS3Bb4P.cjs';
8
8
  import { S as SerializedEngineError } from './WorkerError-CexHHmbb.cjs';
9
- import './Parselet-s1sRRn8H.cjs';
9
+ import './Parselet-DmMY2s9Y.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-JCavlQUj.cjs';
16
+ import './VMBuiltins-RpmR0yHh.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-DSqic8kz.js';
2
+ import { U as UnifiedParsingOptions, I as IEnginePackage, N as ParsedLine, P as ParsingResult } from './PackageRegistry-DJekaRdM.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-2TIKi-YL.js';
6
- import { a as DiagnosticReportJSON } from './pipeline-DOo3KHaq.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';
7
7
  import { C as CalendarBackend } from './CalendarBackend-MdS3Bb4P.js';
8
8
  import { S as SerializedEngineError } from './WorkerError-BaN8_eok.js';
9
- import './Parselet-CQjcHOKw.js';
9
+ import './Parselet-Br1tHash.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-qgzA6qGi.js';
16
+ import './VMBuiltins-BnE1KdV5.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-ITH2RLRG.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-4ASM522I.js';import'./chunk-JP4JMQOG.js';import {c,a}from'./chunk-4XWZXP6I.js';import'./chunk-XEIDV5JP.js';import {z}from'./chunk-DGDVY6XI.js';import'./chunk-G5TZ6TDA.js';import {h}from'./chunk-TJKN466F.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-INMJ7ZXL.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-4MD5L23F.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import'./chunk-O7HF345B.js';import'./chunk-BWTVJD5L.js';import {b as b$1}from'./chunk-AENL3Z66.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:h({...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-H57IABQ2.js';import'./chunk-RU3KGJRA.js';import'./chunk-2RWAXT6O.js';import'./chunk-RMDCGYZM.js';import'./chunk-MIQBJGGR.js';import'./chunk-EQ37UQGY.js';import'./chunk-JP4JMQOG.js';import {c,a}from'./chunk-TZ3Q6GOC.js';import'./chunk-XEIDV5JP.js';import {z}from'./chunk-F6FRMZWE.js';import'./chunk-AWGSR2GZ.js';import {h}from'./chunk-TJKN466F.js';import'./chunk-U5MESNRT.js';import'./chunk-DB5ISONG.js';import'./chunk-76F3LCIL.js';import'./chunk-EOKHRS2T.js';import'./chunk-TCZSPH4A.js';import'./chunk-ETQBU454.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-IHPYXJIY.js';import'./chunk-EOO6M65F.js';import'./chunk-J4K72CQN.js';import'./chunk-A34R65WT.js';import'./chunk-BWTVJD5L.js';import {b as b$1}from'./chunk-INKOUIXV.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:h({...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.34.0",
3
+ "version": "2.34.2",
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",