solve-engine 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/README.md +12 -17
  2. package/dist/{BytecodeBuilder-Bp9xeTmX.d.cts → BytecodeBuilder-DGGeByAP.d.cts} +18 -0
  3. package/dist/{BytecodeBuilder-Bp9xeTmX.d.ts → BytecodeBuilder-DGGeByAP.d.ts} +18 -0
  4. package/dist/{Configuration-C9W8tJv_.d.cts → Configuration-B6W0-T67.d.cts} +17 -4
  5. package/dist/{Configuration-C9W8tJv_.d.ts → Configuration-B6W0-T67.d.ts} +17 -4
  6. package/dist/{EngineError-B61GS1jp.d.cts → EngineError-Ce1lPkjZ.d.cts} +8 -0
  7. package/dist/{EngineError-B61GS1jp.d.ts → EngineError-Ce1lPkjZ.d.ts} +8 -0
  8. package/dist/{Lexer-BOs7euZe.d.cts → Lexer-B4C1qHXu.d.cts} +1 -1
  9. package/dist/{Lexer-CSI_lwbW.d.ts → Lexer-DKMlj7Sy.d.ts} +1 -1
  10. package/dist/{PackageCompatibility-B-7rK1TD.d.cts → PackageCompatibility-Bn5jnBtA.d.cts} +2 -2
  11. package/dist/{PackageCompatibility-Dh59eF-X.d.ts → PackageCompatibility-CIvq2MP5.d.ts} +2 -2
  12. package/dist/{PackageRegistry-_8rDlvxI.d.ts → PackageRegistry-DzeiWcv4.d.ts} +143 -175
  13. package/dist/{PackageRegistry-BHWJP83F.d.cts → PackageRegistry-dpdurBVO.d.cts} +143 -175
  14. package/dist/{Parselet-BBT8riYh.d.ts → Parselet-B-zoPrTa.d.ts} +9 -6
  15. package/dist/{Parselet-BHcgK9S7.d.cts → Parselet-C4Wu055_.d.cts} +9 -6
  16. package/dist/{ScopeManager-CxA24W5n.d.ts → ScopeManager-C2LDOrDx.d.ts} +14 -16
  17. package/dist/{ScopeManager-8vf02dwj.d.cts → ScopeManager-D7uMXbhS.d.cts} +14 -16
  18. package/dist/{Token-B1hdkedD.d.cts → Token-CbP_OutD.d.cts} +9 -0
  19. package/dist/{Token-B1hdkedD.d.ts → Token-CbP_OutD.d.ts} +9 -0
  20. package/dist/{TokenNormalizer-C6VzZgHa.d.ts → TokenNormalizer-DCWdZjGz.d.ts} +1 -1
  21. package/dist/{TokenNormalizer-DRc1Js1V.d.cts → TokenNormalizer-DnlL7_8c.d.cts} +1 -1
  22. package/dist/{VMCheckpoints-MK--EBH2.d.ts → VMCheckpoints-CGyFhivM.d.ts} +3 -3
  23. package/dist/{VMCheckpoints-ELYqITdF.d.cts → VMCheckpoints-I9jg3jWR.d.cts} +3 -3
  24. package/dist/{Value-BUi1RA3S.d.cts → Value-CCi_Eecs.d.cts} +72 -5
  25. package/dist/{Value-BUi1RA3S.d.ts → Value-CCi_Eecs.d.ts} +72 -5
  26. package/dist/{WorkerError-gzmaopj2.d.cts → WorkerError-B4p6PNfx.d.cts} +1 -1
  27. package/dist/{WorkerError-_-RkoQ5P.d.ts → WorkerError-Dhj9BQ_A.d.ts} +1 -1
  28. package/dist/chunk-2JMFUQZH.js +2 -0
  29. package/dist/chunk-2JMFUQZH.js.map +1 -0
  30. package/dist/chunk-2RWAXT6O.js +0 -1
  31. package/dist/chunk-4BZIYU7S.cjs +3 -0
  32. package/dist/chunk-4BZIYU7S.cjs.map +1 -0
  33. package/dist/chunk-4J7XZSZJ.cjs +5 -0
  34. package/dist/chunk-4J7XZSZJ.cjs.map +1 -0
  35. package/dist/chunk-4QVBSG6B.cjs +2 -0
  36. package/dist/chunk-4QVBSG6B.cjs.map +1 -0
  37. package/dist/chunk-5IJD5L3O.cjs +2 -0
  38. package/dist/chunk-5IJD5L3O.cjs.map +1 -0
  39. package/dist/chunk-62LMTO4F.js +2 -0
  40. package/dist/chunk-62LMTO4F.js.map +1 -0
  41. package/dist/chunk-6CY44ZPG.js +2 -0
  42. package/dist/chunk-6CY44ZPG.js.map +1 -0
  43. package/dist/chunk-6G3PMEPA.js +2 -0
  44. package/dist/chunk-6G3PMEPA.js.map +1 -0
  45. package/dist/chunk-6INX773F.cjs +2 -0
  46. package/dist/chunk-6INX773F.cjs.map +1 -0
  47. package/dist/chunk-6KFVG6UY.cjs +2 -0
  48. package/dist/chunk-6KFVG6UY.cjs.map +1 -0
  49. package/dist/chunk-76F3LCIL.js +4 -0
  50. package/dist/chunk-76F3LCIL.js.map +1 -0
  51. package/dist/chunk-7GK3XEZF.js +2 -0
  52. package/dist/chunk-7GK3XEZF.js.map +1 -0
  53. package/dist/chunk-APN442VD.cjs +2 -0
  54. package/dist/chunk-APN442VD.cjs.map +1 -0
  55. package/dist/chunk-AXMQG5TS.cjs +2 -0
  56. package/dist/chunk-AXMQG5TS.cjs.map +1 -0
  57. package/dist/chunk-CIQOK7Q4.cjs +2 -0
  58. package/dist/chunk-CIQOK7Q4.cjs.map +1 -0
  59. package/dist/chunk-E6Z4NQAS.js +2 -0
  60. package/dist/chunk-E6Z4NQAS.js.map +1 -0
  61. package/dist/chunk-EFJCC6FJ.cjs +2 -0
  62. package/dist/chunk-EFJCC6FJ.cjs.map +1 -0
  63. package/dist/chunk-ESUN2THE.cjs +2 -0
  64. package/dist/chunk-ESUN2THE.cjs.map +1 -0
  65. package/dist/chunk-EVAOPEO4.js +2 -0
  66. package/dist/chunk-EVAOPEO4.js.map +1 -0
  67. package/dist/chunk-EYRBENHC.js +3 -0
  68. package/dist/chunk-EYRBENHC.js.map +1 -0
  69. package/dist/chunk-FDE5HWDI.cjs +2 -0
  70. package/dist/chunk-FDE5HWDI.cjs.map +1 -0
  71. package/dist/chunk-FWW3M36J.cjs +2 -0
  72. package/dist/chunk-FWW3M36J.cjs.map +1 -0
  73. package/dist/chunk-GOIQYUWV.js +2 -0
  74. package/dist/chunk-GOIQYUWV.js.map +1 -0
  75. package/dist/chunk-HFKDWQUL.js +2 -0
  76. package/dist/chunk-HFKDWQUL.js.map +1 -0
  77. package/dist/chunk-HLBYHXQD.cjs +3 -0
  78. package/dist/chunk-HLBYHXQD.cjs.map +1 -0
  79. package/dist/chunk-IANAMBJQ.cjs +2 -0
  80. package/dist/chunk-IANAMBJQ.cjs.map +1 -0
  81. package/dist/chunk-IJMNVBIS.js +2 -0
  82. package/dist/chunk-IJMNVBIS.js.map +1 -0
  83. package/dist/chunk-J4LZD4ZY.js +3 -0
  84. package/dist/chunk-J4LZD4ZY.js.map +1 -0
  85. package/dist/chunk-JAK3RAFA.cjs +2 -0
  86. package/dist/chunk-JAK3RAFA.cjs.map +1 -0
  87. package/dist/chunk-JFAJN3C2.cjs +2 -0
  88. package/dist/chunk-JFAJN3C2.cjs.map +1 -0
  89. package/dist/chunk-JPFCXLJV.js +2 -0
  90. package/dist/chunk-JPFCXLJV.js.map +1 -0
  91. package/dist/chunk-JSPKKNPQ.js +3 -0
  92. package/dist/chunk-JSPKKNPQ.js.map +1 -0
  93. package/dist/chunk-L3FPQSGN.js +2 -0
  94. package/dist/chunk-L3FPQSGN.js.map +1 -0
  95. package/dist/chunk-LR4E4A4W.cjs +2 -0
  96. package/dist/chunk-LR4E4A4W.cjs.map +1 -0
  97. package/dist/chunk-MIQBJGGR.js +2 -0
  98. package/dist/chunk-MIQBJGGR.js.map +1 -0
  99. package/dist/chunk-MPB7KUN5.js +3 -0
  100. package/dist/chunk-MPB7KUN5.js.map +1 -0
  101. package/dist/chunk-MSYX32PF.cjs +2 -0
  102. package/dist/chunk-MSYX32PF.cjs.map +1 -0
  103. package/dist/chunk-MVZUTETT.js +2 -0
  104. package/dist/chunk-MVZUTETT.js.map +1 -0
  105. package/dist/chunk-N7N7MPMK.cjs +2 -0
  106. package/dist/chunk-N7N7MPMK.cjs.map +1 -0
  107. package/dist/chunk-NGBBNL4K.cjs +1 -3
  108. package/dist/chunk-P6WPEUAJ.cjs +2 -0
  109. package/dist/chunk-P6WPEUAJ.cjs.map +1 -0
  110. package/dist/chunk-PS272DZJ.cjs +2 -0
  111. package/dist/chunk-PS272DZJ.cjs.map +1 -0
  112. package/dist/chunk-QXQE7X4S.js +2 -0
  113. package/dist/chunk-QXQE7X4S.js.map +1 -0
  114. package/dist/chunk-R2ENWQ76.js +2 -0
  115. package/dist/chunk-R2ENWQ76.js.map +1 -0
  116. package/dist/chunk-R2SZFJTT.cjs +2 -0
  117. package/dist/chunk-R2SZFJTT.cjs.map +1 -0
  118. package/dist/chunk-RAF57WYO.js +2 -0
  119. package/dist/chunk-RAF57WYO.js.map +1 -0
  120. package/dist/chunk-RSF25YSJ.js +2 -0
  121. package/dist/chunk-RSF25YSJ.js.map +1 -0
  122. package/dist/chunk-SOMGSIO4.cjs +3 -0
  123. package/dist/chunk-SOMGSIO4.cjs.map +1 -0
  124. package/dist/chunk-SUXRZWH2.cjs +3 -0
  125. package/dist/chunk-SUXRZWH2.cjs.map +1 -0
  126. package/dist/chunk-SYYE3QAX.cjs +2 -0
  127. package/dist/chunk-SYYE3QAX.cjs.map +1 -0
  128. package/dist/chunk-SZGK6RIP.cjs +2 -0
  129. package/dist/chunk-SZGK6RIP.cjs.map +1 -0
  130. package/dist/chunk-TCZSPH4A.js +2 -0
  131. package/dist/chunk-TCZSPH4A.js.map +1 -0
  132. package/dist/chunk-TLG7VZRX.cjs +2 -0
  133. package/dist/chunk-TLG7VZRX.cjs.map +1 -0
  134. package/dist/chunk-TRBXW6HW.js +2 -0
  135. package/dist/{chunk-AQNHHJMJ.cjs.map → chunk-TRBXW6HW.js.map} +1 -1
  136. package/dist/chunk-TTFO4YDP.cjs +2 -0
  137. package/dist/chunk-TTFO4YDP.cjs.map +1 -0
  138. package/dist/chunk-TWC7K3ZX.js +2 -0
  139. package/dist/chunk-TWC7K3ZX.js.map +1 -0
  140. package/dist/chunk-UDQ57ZRX.cjs +2 -0
  141. package/dist/chunk-UDQ57ZRX.cjs.map +1 -0
  142. package/dist/chunk-UI6IFGBT.js +2 -0
  143. package/dist/chunk-UI6IFGBT.js.map +1 -0
  144. package/dist/chunk-UURM7P3P.cjs +4 -0
  145. package/dist/chunk-UURM7P3P.cjs.map +1 -0
  146. package/dist/chunk-W2JAR233.js +2 -0
  147. package/dist/chunk-W2JAR233.js.map +1 -0
  148. package/dist/chunk-WGZ3FNHI.js +2 -0
  149. package/dist/chunk-WGZ3FNHI.js.map +1 -0
  150. package/dist/chunk-WN5CMP4T.cjs +3 -0
  151. package/dist/chunk-WN5CMP4T.cjs.map +1 -0
  152. package/dist/chunk-XEIDV5JP.js +2 -0
  153. package/dist/chunk-XEIDV5JP.js.map +1 -0
  154. package/dist/chunk-XNIWQHXY.js +2 -0
  155. package/dist/chunk-XNIWQHXY.js.map +1 -0
  156. package/dist/chunk-XR7HEC7B.js +5 -0
  157. package/dist/chunk-XR7HEC7B.js.map +1 -0
  158. package/dist/chunk-Y7O4D3BJ.cjs +2 -0
  159. package/dist/chunk-Y7O4D3BJ.cjs.map +1 -0
  160. package/dist/chunk-YAYBVVG2.js +3 -0
  161. package/dist/chunk-YAYBVVG2.js.map +1 -0
  162. package/dist/chunk-YJ2OPULK.js +2 -0
  163. package/dist/chunk-YJ2OPULK.js.map +1 -0
  164. package/dist/chunk-YVKHEAFT.js +2 -0
  165. package/dist/chunk-YVKHEAFT.js.map +1 -0
  166. package/dist/chunk-ZCNBT44X.cjs +2 -0
  167. package/dist/chunk-ZCNBT44X.cjs.map +1 -0
  168. package/dist/chunk-ZLRJ7TDP.cjs +2 -0
  169. package/dist/chunk-ZLRJ7TDP.cjs.map +1 -0
  170. package/dist/constants.cjs +1 -21
  171. package/dist/constants.d.cts +1 -1
  172. package/dist/constants.d.ts +1 -1
  173. package/dist/constants.js +1 -4
  174. package/dist/engine.cjs +1 -94
  175. package/dist/engine.d.cts +29 -14
  176. package/dist/engine.d.ts +29 -14
  177. package/dist/engine.js +1 -37
  178. package/dist/errors.cjs +1 -105
  179. package/dist/errors.d.cts +3 -3
  180. package/dist/errors.d.ts +3 -3
  181. package/dist/errors.js +1 -4
  182. package/dist/format.cjs +1 -26
  183. package/dist/format.d.cts +2 -2
  184. package/dist/format.d.ts +2 -2
  185. package/dist/format.js +1 -9
  186. package/dist/index.cjs +1 -314
  187. package/dist/index.cjs.map +1 -1
  188. package/dist/index.d.cts +55 -23
  189. package/dist/index.d.ts +55 -23
  190. package/dist/index.js +1 -278
  191. package/dist/index.js.map +1 -1
  192. package/dist/language.cjs +1 -369
  193. package/dist/language.cjs.map +1 -1
  194. package/dist/language.d.cts +12 -13
  195. package/dist/language.d.ts +12 -13
  196. package/dist/language.js +1 -348
  197. package/dist/language.js.map +1 -1
  198. package/dist/lexer.cjs +1 -63
  199. package/dist/lexer.d.cts +3 -3
  200. package/dist/lexer.d.ts +3 -3
  201. package/dist/lexer.js +1 -10
  202. package/dist/normalizer.cjs +1 -39
  203. package/dist/normalizer.d.cts +3 -3
  204. package/dist/normalizer.d.ts +3 -3
  205. package/dist/normalizer.js +1 -10
  206. package/dist/packages.cjs +1 -128
  207. package/dist/packages.d.cts +39 -14
  208. package/dist/packages.d.ts +39 -14
  209. package/dist/packages.js +1 -23
  210. package/dist/parser.cjs +1 -54
  211. package/dist/parser.d.cts +9 -9
  212. package/dist/parser.d.ts +9 -9
  213. package/dist/parser.js +1 -9
  214. package/dist/{pipeline-CtfJtPQc.d.cts → pipeline-72QmQlGx.d.ts} +3 -3
  215. package/dist/{pipeline-DCd5M6Gk.d.ts → pipeline-DCQicwWX.d.cts} +3 -3
  216. package/dist/resolvers.cjs +1 -12
  217. package/dist/resolvers.d.cts +3 -3
  218. package/dist/resolvers.d.ts +3 -3
  219. package/dist/resolvers.js +1 -3
  220. package/dist/services.cjs +1 -20
  221. package/dist/services.js +1 -3
  222. package/dist/testing.cjs +3 -477
  223. package/dist/testing.cjs.map +1 -1
  224. package/dist/testing.d.cts +12 -13
  225. package/dist/testing.d.ts +12 -13
  226. package/dist/testing.js +3 -469
  227. package/dist/testing.js.map +1 -1
  228. package/dist/uom.cjs +1 -55
  229. package/dist/uom.d.cts +3 -3
  230. package/dist/uom.d.ts +3 -3
  231. package/dist/uom.js +1 -10
  232. package/dist/utilities.cjs +1 -36
  233. package/dist/utilities.js +1 -7
  234. package/dist/vm.cjs +1 -295
  235. package/dist/vm.cjs.map +1 -1
  236. package/dist/vm.d.cts +22 -10
  237. package/dist/vm.d.ts +22 -10
  238. package/dist/vm.js +1 -193
  239. package/dist/vm.js.map +1 -1
  240. package/dist/worker.cjs +2 -492
  241. package/dist/worker.cjs.map +1 -1
  242. package/dist/worker.d.cts +19 -20
  243. package/dist/worker.d.ts +19 -20
  244. package/dist/worker.js +2 -483
  245. package/dist/worker.js.map +1 -1
  246. package/package.json +1 -13
  247. package/dist/chunk-267JPOTF.js +0 -406
  248. package/dist/chunk-267JPOTF.js.map +0 -1
  249. package/dist/chunk-2TZKENDH.cjs +0 -448
  250. package/dist/chunk-2TZKENDH.cjs.map +0 -1
  251. package/dist/chunk-3BOK2LDK.js +0 -17
  252. package/dist/chunk-3BOK2LDK.js.map +0 -1
  253. package/dist/chunk-3OWCDIPN.js +0 -215
  254. package/dist/chunk-3OWCDIPN.js.map +0 -1
  255. package/dist/chunk-3VGDNEE3.js +0 -84
  256. package/dist/chunk-3VGDNEE3.js.map +0 -1
  257. package/dist/chunk-4D6NIHE2.js +0 -451
  258. package/dist/chunk-4D6NIHE2.js.map +0 -1
  259. package/dist/chunk-4HQKTMWG.js +0 -7985
  260. package/dist/chunk-4HQKTMWG.js.map +0 -1
  261. package/dist/chunk-536WPM2V.cjs +0 -283
  262. package/dist/chunk-536WPM2V.cjs.map +0 -1
  263. package/dist/chunk-5HRB36DK.js +0 -405
  264. package/dist/chunk-5HRB36DK.js.map +0 -1
  265. package/dist/chunk-5ON7PUAZ.js +0 -12
  266. package/dist/chunk-5ON7PUAZ.js.map +0 -1
  267. package/dist/chunk-7KYSUDQO.js +0 -109
  268. package/dist/chunk-7KYSUDQO.js.map +0 -1
  269. package/dist/chunk-7ZX6B7SY.cjs +0 -3222
  270. package/dist/chunk-7ZX6B7SY.cjs.map +0 -1
  271. package/dist/chunk-ADBA3XBE.cjs +0 -20
  272. package/dist/chunk-ADBA3XBE.cjs.map +0 -1
  273. package/dist/chunk-ALYRJ72W.cjs +0 -434
  274. package/dist/chunk-ALYRJ72W.cjs.map +0 -1
  275. package/dist/chunk-AMOJYLG2.cjs +0 -1692
  276. package/dist/chunk-AMOJYLG2.cjs.map +0 -1
  277. package/dist/chunk-AQNHHJMJ.cjs +0 -261
  278. package/dist/chunk-B4HBEFTB.cjs +0 -375
  279. package/dist/chunk-B4HBEFTB.cjs.map +0 -1
  280. package/dist/chunk-B7LXJ6LC.cjs +0 -36
  281. package/dist/chunk-B7LXJ6LC.cjs.map +0 -1
  282. package/dist/chunk-B7NLZMQ3.cjs +0 -74
  283. package/dist/chunk-B7NLZMQ3.cjs.map +0 -1
  284. package/dist/chunk-BLI4NIQY.js +0 -98
  285. package/dist/chunk-BLI4NIQY.js.map +0 -1
  286. package/dist/chunk-BYJBUL7U.js +0 -499
  287. package/dist/chunk-BYJBUL7U.js.map +0 -1
  288. package/dist/chunk-CCBZZQAE.js +0 -312
  289. package/dist/chunk-CCBZZQAE.js.map +0 -1
  290. package/dist/chunk-CKQMXMHR.cjs +0 -219
  291. package/dist/chunk-CKQMXMHR.cjs.map +0 -1
  292. package/dist/chunk-CUR2WLI4.cjs +0 -507
  293. package/dist/chunk-CUR2WLI4.cjs.map +0 -1
  294. package/dist/chunk-DLEBSLF4.js +0 -336
  295. package/dist/chunk-DLEBSLF4.js.map +0 -1
  296. package/dist/chunk-E23GZEWL.cjs +0 -209
  297. package/dist/chunk-E23GZEWL.cjs.map +0 -1
  298. package/dist/chunk-EJ3ILXX6.cjs +0 -223
  299. package/dist/chunk-EJ3ILXX6.cjs.map +0 -1
  300. package/dist/chunk-ENKKJYD3.js +0 -333
  301. package/dist/chunk-ENKKJYD3.js.map +0 -1
  302. package/dist/chunk-ENRIK36Q.cjs +0 -94
  303. package/dist/chunk-ENRIK36Q.cjs.map +0 -1
  304. package/dist/chunk-ERCOHGXD.js +0 -356
  305. package/dist/chunk-ERCOHGXD.js.map +0 -1
  306. package/dist/chunk-FD5ZZHEU.js +0 -92
  307. package/dist/chunk-FD5ZZHEU.js.map +0 -1
  308. package/dist/chunk-FEAIOR7N.cjs +0 -91
  309. package/dist/chunk-FEAIOR7N.cjs.map +0 -1
  310. package/dist/chunk-GCM5JHMX.js +0 -88
  311. package/dist/chunk-GCM5JHMX.js.map +0 -1
  312. package/dist/chunk-GLA4JXBO.js +0 -204
  313. package/dist/chunk-GLA4JXBO.js.map +0 -1
  314. package/dist/chunk-HIQ5HSZL.cjs +0 -1923
  315. package/dist/chunk-HIQ5HSZL.cjs.map +0 -1
  316. package/dist/chunk-HVRVSI2Z.cjs +0 -829
  317. package/dist/chunk-HVRVSI2Z.cjs.map +0 -1
  318. package/dist/chunk-I4GAWIPW.js +0 -825
  319. package/dist/chunk-I4GAWIPW.js.map +0 -1
  320. package/dist/chunk-J45BCEZ4.cjs +0 -339
  321. package/dist/chunk-J45BCEZ4.cjs.map +0 -1
  322. package/dist/chunk-JG6ZJ2WU.js +0 -1513
  323. package/dist/chunk-JG6ZJ2WU.js.map +0 -1
  324. package/dist/chunk-L2TE7PMO.cjs +0 -14
  325. package/dist/chunk-L2TE7PMO.cjs.map +0 -1
  326. package/dist/chunk-LHZ6VOA7.js +0 -1764
  327. package/dist/chunk-LHZ6VOA7.js.map +0 -1
  328. package/dist/chunk-MN3LHRGV.cjs +0 -8012
  329. package/dist/chunk-MN3LHRGV.cjs.map +0 -1
  330. package/dist/chunk-MVTOCRV2.js +0 -213
  331. package/dist/chunk-MVTOCRV2.js.map +0 -1
  332. package/dist/chunk-N5NNW4VG.cjs +0 -341
  333. package/dist/chunk-N5NNW4VG.cjs.map +0 -1
  334. package/dist/chunk-N7FNVFXW.cjs +0 -32
  335. package/dist/chunk-N7FNVFXW.cjs.map +0 -1
  336. package/dist/chunk-NKW7LKYU.js +0 -3185
  337. package/dist/chunk-NKW7LKYU.js.map +0 -1
  338. package/dist/chunk-NLNDMWZC.js +0 -31
  339. package/dist/chunk-NLNDMWZC.js.map +0 -1
  340. package/dist/chunk-NNQ2TYDF.js +0 -1848
  341. package/dist/chunk-NNQ2TYDF.js.map +0 -1
  342. package/dist/chunk-NNZAEUDW.js +0 -6792
  343. package/dist/chunk-NNZAEUDW.js.map +0 -1
  344. package/dist/chunk-OUHT5Z36.cjs +0 -393
  345. package/dist/chunk-OUHT5Z36.cjs.map +0 -1
  346. package/dist/chunk-QFTDTX6K.cjs +0 -457
  347. package/dist/chunk-QFTDTX6K.cjs.map +0 -1
  348. package/dist/chunk-SBUFNJVE.js +0 -258
  349. package/dist/chunk-SBUFNJVE.js.map +0 -1
  350. package/dist/chunk-SRGQ72IR.cjs +0 -2800
  351. package/dist/chunk-SRGQ72IR.cjs.map +0 -1
  352. package/dist/chunk-SSV46KFA.cjs +0 -112
  353. package/dist/chunk-SSV46KFA.cjs.map +0 -1
  354. package/dist/chunk-T6ZYQJ63.cjs +0 -6807
  355. package/dist/chunk-T6ZYQJ63.cjs.map +0 -1
  356. package/dist/chunk-UKQHXPGW.js +0 -30
  357. package/dist/chunk-UKQHXPGW.js.map +0 -1
  358. package/dist/chunk-UO6BUV6K.js +0 -278
  359. package/dist/chunk-UO6BUV6K.js.map +0 -1
  360. package/dist/chunk-V4XG5QF6.js +0 -1685
  361. package/dist/chunk-V4XG5QF6.js.map +0 -1
  362. package/dist/chunk-VEKIWQ3F.cjs +0 -39
  363. package/dist/chunk-VEKIWQ3F.cjs.map +0 -1
  364. package/dist/chunk-WWQEY7BV.js +0 -67
  365. package/dist/chunk-WWQEY7BV.js.map +0 -1
  366. package/dist/chunk-WXEHD6TT.js +0 -2795
  367. package/dist/chunk-WXEHD6TT.js.map +0 -1
  368. package/dist/chunk-X6K3HUOY.cjs +0 -86
  369. package/dist/chunk-X6K3HUOY.cjs.map +0 -1
  370. package/dist/chunk-XA4CKRML.cjs +0 -316
  371. package/dist/chunk-XA4CKRML.cjs.map +0 -1
  372. package/dist/chunk-XBTEO4OB.js +0 -391
  373. package/dist/chunk-XBTEO4OB.js.map +0 -1
  374. package/dist/chunk-XIYYHA65.cjs +0 -101
  375. package/dist/chunk-XIYYHA65.cjs.map +0 -1
  376. package/dist/chunk-YLJ4XMA6.js +0 -33
  377. package/dist/chunk-YLJ4XMA6.js.map +0 -1
  378. package/dist/chunk-YRIKITGF.cjs +0 -1768
  379. package/dist/chunk-YRIKITGF.cjs.map +0 -1
  380. package/dist/chunk-Z2XP767T.cjs +0 -35
  381. package/dist/chunk-Z2XP767T.cjs.map +0 -1
  382. package/dist/chunk-Z4X2RWOF.js +0 -37
  383. package/dist/chunk-Z4X2RWOF.js.map +0 -1
  384. package/dist/chunk-Z7XGGLI2.js +0 -455
  385. package/dist/chunk-Z7XGGLI2.js.map +0 -1
  386. package/dist/chunk-ZMW6NU2K.cjs +0 -1516
  387. package/dist/chunk-ZMW6NU2K.cjs.map +0 -1
  388. package/dist/chunk-ZVTWQLK4.cjs +0 -459
  389. package/dist/chunk-ZVTWQLK4.cjs.map +0 -1
  390. package/dist/variables.cjs +0 -17
  391. package/dist/variables.cjs.map +0 -1
  392. package/dist/variables.d.cts +0 -87
  393. package/dist/variables.d.ts +0 -87
  394. package/dist/variables.js +0 -4
  395. package/dist/variables.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,20 +1,19 @@
1
- import { I as IEnginePackage } from './PackageRegistry-BHWJP83F.cjs';
2
- export { a as EngineRestoreOptions, b as EngineSnapshot, c as EvalResults, d as Explanation, e as ExplanationStep, E as ExpressionEngine, f as IPackageRegistry, L as LineEvaluation, P as PackageRegistry, S as SNAPSHOT_FORMAT, g as SNAPSHOT_VERSION, h as SerializedAnonymousBody, i as SerializedBytecode, j as SerializedDecimal, k as SerializedLineCacheEntry, l as SerializedNumber, m as SerializedRational, n as SerializedUserFunction, o as SerializedValue, p as SnapshotErrorCodes, q as packageRegistry } from './PackageRegistry-BHWJP83F.cjs';
3
- export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-B-7rK1TD.cjs';
1
+ import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-dpdurBVO.cjs';
2
+ export { b as EngineRestoreOptions, c as EngineSnapshot, d as Explanation, e as ExplanationStep, S as SNAPSHOT_FORMAT, f as SNAPSHOT_VERSION, g as SerializedAnonymousBody, h as SerializedBytecode, i as SerializedDecimal, j as SerializedLineCacheEntry, k as SerializedNumber, l as SerializedRational, m as SerializedUserFunction, n as SerializedValue, o as SnapshotErrorCodes } from './PackageRegistry-dpdurBVO.cjs';
3
+ export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-Bn5jnBtA.cjs';
4
+ export { E as EngineConfigOverride } from './Configuration-B6W0-T67.cjs';
4
5
  export { ENGINE_VERSION } from './constants.cjs';
5
- import './Parselet-BHcgK9S7.cjs';
6
- import './BytecodeBuilder-Bp9xeTmX.cjs';
7
- import './Token-B1hdkedD.cjs';
8
- import './pipeline-CtfJtPQc.cjs';
9
- import './Value-BUi1RA3S.cjs';
10
- import './variables.cjs';
11
- import './Lexer-BOs7euZe.cjs';
6
+ import './Parselet-C4Wu055_.cjs';
7
+ import './BytecodeBuilder-DGGeByAP.cjs';
8
+ import './Token-CbP_OutD.cjs';
9
+ import './pipeline-DCQicwWX.cjs';
10
+ import './Value-CCi_Eecs.cjs';
11
+ import './Lexer-B4C1qHXu.cjs';
12
12
  import './resolvers.cjs';
13
13
  import '@tanstack/query-core';
14
- import './TokenNormalizer-DRc1Js1V.cjs';
15
- import './ScopeManager-8vf02dwj.cjs';
16
- import './EngineError-B61GS1jp.cjs';
17
- import './Configuration-C9W8tJv_.cjs';
14
+ import './TokenNormalizer-DnlL7_8c.cjs';
15
+ import './ScopeManager-D7uMXbhS.cjs';
16
+ import './EngineError-Ce1lPkjZ.cjs';
18
17
 
19
18
  /**
20
19
  * A higher-level, declarative way to contribute a single `name(args)`
@@ -88,16 +87,16 @@ declare const DefineFunctionErrorCodes: {
88
87
  *
89
88
  * This is the higher-level API from issue #102. It derives, from the
90
89
  * declaration alone, everything the low-level contract asks an author to write
91
- * by hand: a plugin function index ({@link allocatePluginFunctionIndex}), a
92
- * lexer keyword so the name tokenises, a call-syntax parselet emitting
93
- * `CALL_PLUGIN`, and a handler that checks arity and argument types (yielding
90
+ * by hand: a named plugin function (the engine assigns its `CALL_PLUGIN`
91
+ * index), a lexer keyword so the name tokenises, a call-syntax parselet emitting
92
+ * that call by name, and a handler that checks arity and argument types (yielding
94
93
  * the engine's own structured errors) before invoking `call` and wrapping its
95
94
  * result. Anything needing custom parsing keeps writing a raw parselet exactly
96
95
  * as before, this sits on top of that contract and does not change it.
97
96
  *
98
97
  * @example
99
98
  * ```ts
100
- * const engine = new ExpressionEngine("en", false, undefined, undefined, [
99
+ * const engine = new ExpressionEngine({ packages: [
101
100
  * ...BUILTIN_PACKAGES,
102
101
  * defineFunction({
103
102
  * name: "vat",
@@ -105,7 +104,7 @@ declare const DefineFunctionErrorCodes: {
105
104
  * returns: "number",
106
105
  * call: (amount) => amount * 1.2,
107
106
  * }),
108
- * ]);
107
+ * ] });
109
108
  * engine.evaluateExpression("vat(100)"); // 120
110
109
  * ```
111
110
  *
@@ -148,9 +147,9 @@ declare function defineFunction<const A extends readonly FunctionArg[], R extend
148
147
  * `checkPackageCompatibility()`'s "return a result, caller decides" shape,
149
148
  * and this codebase's own testing convention of asserting against plain
150
149
  * result objects rather than `toThrow()` for a pure function).
151
- * `assertEngineVersionCompatible()` is the thin throwing wrapper both
152
- * `ExpressionEngine.registerPackage()` and the `PackageRegistry` singleton
153
- * call as the very first thing they do. See `ARCHITECTURE.md` §5.3.
150
+ * `assertEngineVersionCompatible()` is the thin throwing wrapper
151
+ * `ExpressionEngine.registerPackage()` calls as the very first thing it
152
+ * does. See `ARCHITECTURE.md` §5.3.
154
153
  */
155
154
  type EngineVersionCheckResult = {
156
155
  compatible: true;
@@ -185,4 +184,37 @@ declare function checkEngineVersionCompatibility(pkg: IEnginePackage, engineVers
185
184
  */
186
185
  declare function assertEngineVersionCompatible(pkg: IEnginePackage, engineVersion?: string): void;
187
186
 
188
- export { DefineFunctionErrorCodes, type EngineVersionCheckResult, type FunctionArg, type FunctionSpec, type FunctionValueType, IEnginePackage, assertEngineVersionCompatible, checkEngineVersionCompatibility, defineFunction };
187
+ /** Options for {@link createEngine}: the engine options, minus `packages` (the
188
+ * built-in set is always registered), plus `extraPackages` to add your own. */
189
+ interface CreateEngineOptions extends Omit<EngineOptions, "packages"> {
190
+ /** Packages to register ON TOP of the built-in set (e.g. an OSRS or stocks package). */
191
+ extraPackages?: IEnginePackage[];
192
+ }
193
+ /**
194
+ * A batteries-included {@link ExpressionEngine} with every built-in package
195
+ * registered.
196
+ *
197
+ * The constructor registers only the packages it is given, so a consumer's
198
+ * bundler can tree-shake away the built-ins they never use: an engine built
199
+ * with `new ExpressionEngine({ packages: [ARITHMETIC_PACKAGE] })` carries no
200
+ * finance, colour or weather code. This convenience is the opposite trade: it
201
+ * pulls the FULL built-in set (`BUILTIN_PACKAGES`) for the common "I want
202
+ * everything" case, so importing it defeats that tree-shaking. Reach for the
203
+ * constructor with an explicit package list when bundle size matters, and for
204
+ * `createEngine` when it does not.
205
+ *
206
+ * @param options - Engine options ({@link EngineOptions}) minus `packages`, plus
207
+ * an optional `extraPackages` to register alongside the built-in set.
208
+ * @returns An engine with the built-in packages (and any extras) registered.
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * import { createEngine } from "solve-engine";
213
+ * const engine = createEngine();
214
+ * const value = engine.evaluateExpression("2 + 2 * 10");
215
+ * console.log(value.toNumber()); // 22
216
+ * ```
217
+ */
218
+ declare function createEngine(options?: CreateEngineOptions): ExpressionEngine;
219
+
220
+ export { type CreateEngineOptions, DefineFunctionErrorCodes, EngineOptions, type EngineVersionCheckResult, ExpressionEngine, type FunctionArg, type FunctionSpec, type FunctionValueType, IEnginePackage, assertEngineVersionCompatible, checkEngineVersionCompatibility, createEngine, defineFunction };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,19 @@
1
- import { I as IEnginePackage } from './PackageRegistry-_8rDlvxI.js';
2
- export { a as EngineRestoreOptions, b as EngineSnapshot, c as EvalResults, d as Explanation, e as ExplanationStep, E as ExpressionEngine, f as IPackageRegistry, L as LineEvaluation, P as PackageRegistry, S as SNAPSHOT_FORMAT, g as SNAPSHOT_VERSION, h as SerializedAnonymousBody, i as SerializedBytecode, j as SerializedDecimal, k as SerializedLineCacheEntry, l as SerializedNumber, m as SerializedRational, n as SerializedUserFunction, o as SerializedValue, p as SnapshotErrorCodes, q as packageRegistry } from './PackageRegistry-_8rDlvxI.js';
3
- export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-Dh59eF-X.js';
1
+ import { I as IEnginePackage, a as EngineOptions, E as ExpressionEngine } from './PackageRegistry-DzeiWcv4.js';
2
+ export { b as EngineRestoreOptions, c as EngineSnapshot, d as Explanation, e as ExplanationStep, S as SNAPSHOT_FORMAT, f as SNAPSHOT_VERSION, g as SerializedAnonymousBody, h as SerializedBytecode, i as SerializedDecimal, j as SerializedLineCacheEntry, k as SerializedNumber, l as SerializedRational, m as SerializedUserFunction, n as SerializedValue, o as SnapshotErrorCodes } from './PackageRegistry-DzeiWcv4.js';
3
+ export { a as CompatibilityConflict, b as CompatibilityConflictKind, C as CompatibilityReport, c as CompatibilitySeverity, d as checkPackageCompatibility } from './PackageCompatibility-CIvq2MP5.js';
4
+ export { E as EngineConfigOverride } from './Configuration-B6W0-T67.js';
4
5
  export { ENGINE_VERSION } from './constants.js';
5
- import './Parselet-BBT8riYh.js';
6
- import './BytecodeBuilder-Bp9xeTmX.js';
7
- import './Token-B1hdkedD.js';
8
- import './pipeline-DCd5M6Gk.js';
9
- import './Value-BUi1RA3S.js';
10
- import './variables.js';
11
- import './Lexer-CSI_lwbW.js';
6
+ import './Parselet-B-zoPrTa.js';
7
+ import './BytecodeBuilder-DGGeByAP.js';
8
+ import './Token-CbP_OutD.js';
9
+ import './pipeline-72QmQlGx.js';
10
+ import './Value-CCi_Eecs.js';
11
+ import './Lexer-DKMlj7Sy.js';
12
12
  import './resolvers.js';
13
13
  import '@tanstack/query-core';
14
- import './TokenNormalizer-C6VzZgHa.js';
15
- import './ScopeManager-CxA24W5n.js';
16
- import './EngineError-B61GS1jp.js';
17
- import './Configuration-C9W8tJv_.js';
14
+ import './TokenNormalizer-DCWdZjGz.js';
15
+ import './ScopeManager-C2LDOrDx.js';
16
+ import './EngineError-Ce1lPkjZ.js';
18
17
 
19
18
  /**
20
19
  * A higher-level, declarative way to contribute a single `name(args)`
@@ -88,16 +87,16 @@ declare const DefineFunctionErrorCodes: {
88
87
  *
89
88
  * This is the higher-level API from issue #102. It derives, from the
90
89
  * declaration alone, everything the low-level contract asks an author to write
91
- * by hand: a plugin function index ({@link allocatePluginFunctionIndex}), a
92
- * lexer keyword so the name tokenises, a call-syntax parselet emitting
93
- * `CALL_PLUGIN`, and a handler that checks arity and argument types (yielding
90
+ * by hand: a named plugin function (the engine assigns its `CALL_PLUGIN`
91
+ * index), a lexer keyword so the name tokenises, a call-syntax parselet emitting
92
+ * that call by name, and a handler that checks arity and argument types (yielding
94
93
  * the engine's own structured errors) before invoking `call` and wrapping its
95
94
  * result. Anything needing custom parsing keeps writing a raw parselet exactly
96
95
  * as before, this sits on top of that contract and does not change it.
97
96
  *
98
97
  * @example
99
98
  * ```ts
100
- * const engine = new ExpressionEngine("en", false, undefined, undefined, [
99
+ * const engine = new ExpressionEngine({ packages: [
101
100
  * ...BUILTIN_PACKAGES,
102
101
  * defineFunction({
103
102
  * name: "vat",
@@ -105,7 +104,7 @@ declare const DefineFunctionErrorCodes: {
105
104
  * returns: "number",
106
105
  * call: (amount) => amount * 1.2,
107
106
  * }),
108
- * ]);
107
+ * ] });
109
108
  * engine.evaluateExpression("vat(100)"); // 120
110
109
  * ```
111
110
  *
@@ -148,9 +147,9 @@ declare function defineFunction<const A extends readonly FunctionArg[], R extend
148
147
  * `checkPackageCompatibility()`'s "return a result, caller decides" shape,
149
148
  * and this codebase's own testing convention of asserting against plain
150
149
  * result objects rather than `toThrow()` for a pure function).
151
- * `assertEngineVersionCompatible()` is the thin throwing wrapper both
152
- * `ExpressionEngine.registerPackage()` and the `PackageRegistry` singleton
153
- * call as the very first thing they do. See `ARCHITECTURE.md` §5.3.
150
+ * `assertEngineVersionCompatible()` is the thin throwing wrapper
151
+ * `ExpressionEngine.registerPackage()` calls as the very first thing it
152
+ * does. See `ARCHITECTURE.md` §5.3.
154
153
  */
155
154
  type EngineVersionCheckResult = {
156
155
  compatible: true;
@@ -185,4 +184,37 @@ declare function checkEngineVersionCompatibility(pkg: IEnginePackage, engineVers
185
184
  */
186
185
  declare function assertEngineVersionCompatible(pkg: IEnginePackage, engineVersion?: string): void;
187
186
 
188
- export { DefineFunctionErrorCodes, type EngineVersionCheckResult, type FunctionArg, type FunctionSpec, type FunctionValueType, IEnginePackage, assertEngineVersionCompatible, checkEngineVersionCompatibility, defineFunction };
187
+ /** Options for {@link createEngine}: the engine options, minus `packages` (the
188
+ * built-in set is always registered), plus `extraPackages` to add your own. */
189
+ interface CreateEngineOptions extends Omit<EngineOptions, "packages"> {
190
+ /** Packages to register ON TOP of the built-in set (e.g. an OSRS or stocks package). */
191
+ extraPackages?: IEnginePackage[];
192
+ }
193
+ /**
194
+ * A batteries-included {@link ExpressionEngine} with every built-in package
195
+ * registered.
196
+ *
197
+ * The constructor registers only the packages it is given, so a consumer's
198
+ * bundler can tree-shake away the built-ins they never use: an engine built
199
+ * with `new ExpressionEngine({ packages: [ARITHMETIC_PACKAGE] })` carries no
200
+ * finance, colour or weather code. This convenience is the opposite trade: it
201
+ * pulls the FULL built-in set (`BUILTIN_PACKAGES`) for the common "I want
202
+ * everything" case, so importing it defeats that tree-shaking. Reach for the
203
+ * constructor with an explicit package list when bundle size matters, and for
204
+ * `createEngine` when it does not.
205
+ *
206
+ * @param options - Engine options ({@link EngineOptions}) minus `packages`, plus
207
+ * an optional `extraPackages` to register alongside the built-in set.
208
+ * @returns An engine with the built-in packages (and any extras) registered.
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * import { createEngine } from "solve-engine";
213
+ * const engine = createEngine();
214
+ * const value = engine.evaluateExpression("2 + 2 * 10");
215
+ * console.log(value.toNumber()); // 22
216
+ * ```
217
+ */
218
+ declare function createEngine(options?: CreateEngineOptions): ExpressionEngine;
219
+
220
+ export { type CreateEngineOptions, DefineFunctionErrorCodes, EngineOptions, type EngineVersionCheckResult, ExpressionEngine, type FunctionArg, type FunctionSpec, type FunctionValueType, IEnginePackage, assertEngineVersionCompatible, checkEngineVersionCompatibility, createEngine, defineFunction };
package/dist/index.js CHANGED
@@ -1,279 +1,2 @@
1
- import './chunk-LHZ6VOA7.js';
2
- import { assertEngineVersionCompatible } from './chunk-NNZAEUDW.js';
3
- export { ExpressionEngine, SNAPSHOT_FORMAT, SNAPSHOT_VERSION, SnapshotErrorCodes, assertEngineVersionCompatible, checkEngineVersionCompatibility, checkPackageCompatibility } from './chunk-NNZAEUDW.js';
4
- import { sharedParseletRegistry } from './chunk-I4GAWIPW.js';
5
- import './chunk-2RWAXT6O.js';
6
- import './chunk-3VGDNEE3.js';
7
- import './chunk-5ON7PUAZ.js';
8
- import './chunk-FD5ZZHEU.js';
9
- import './chunk-WXEHD6TT.js';
10
- import './chunk-CCBZZQAE.js';
11
- import './chunk-3OWCDIPN.js';
12
- import './chunk-UKQHXPGW.js';
13
- import './chunk-4HQKTMWG.js';
14
- import { BindingPower } from './chunk-ENKKJYD3.js';
15
- import './chunk-BYJBUL7U.js';
16
- import './chunk-3BOK2LDK.js';
17
- import './chunk-7KYSUDQO.js';
18
- import './chunk-NLNDMWZC.js';
19
- import { allocatePluginFunctionIndex } from './chunk-NKW7LKYU.js';
20
- import { sharedVariableResolver } from './chunk-GCM5JHMX.js';
21
- import './chunk-Z7XGGLI2.js';
22
- import './chunk-BLI4NIQY.js';
23
- import './chunk-Z4X2RWOF.js';
24
- import './chunk-5HRB36DK.js';
25
- import './chunk-NNQ2TYDF.js';
26
- import { Value, boolValue, stringValue, numberValue } from './chunk-267JPOTF.js';
27
- import './chunk-MVTOCRV2.js';
28
- export { ENGINE_VERSION } from './chunk-GLA4JXBO.js';
29
- import { sharedLexer } from './chunk-DLEBSLF4.js';
30
- import './chunk-UO6BUV6K.js';
31
- import './chunk-JG6ZJ2WU.js';
32
- import './chunk-4D6NIHE2.js';
33
- import './chunk-XBTEO4OB.js';
34
- import './chunk-SBUFNJVE.js';
35
- import './chunk-V4XG5QF6.js';
36
- import { ErrorFactory } from './chunk-ERCOHGXD.js';
37
- import './chunk-YLJ4XMA6.js';
38
-
39
- // src/api/PackageRegistry.ts
40
- var PackageRegistry = class {
41
- constructor() {
42
- this.Value = Value;
43
- }
44
- registerPrefixParselet(tokenType, parselet) {
45
- sharedParseletRegistry.registerPrefix(tokenType, parselet);
46
- }
47
- registerInfixParselet(tokenType, parselet) {
48
- sharedParseletRegistry.registerInfix(tokenType, parselet);
49
- }
50
- registerVariableSource(source) {
51
- sharedVariableResolver.registerSource(source);
52
- }
53
- registerPackage(pkg) {
54
- assertEngineVersionCompatible(pkg);
55
- if (pkg.lexerVocabulary) {
56
- sharedLexer.registerVocabulary(pkg.lexerVocabulary);
57
- }
58
- if (pkg.prefixParselets) {
59
- for (const pp of pkg.prefixParselets) {
60
- this.registerPrefixParselet(pp.tokenType, pp.parselet);
61
- }
62
- }
63
- if (pkg.infixParselets) {
64
- for (const ip of pkg.infixParselets) {
65
- this.registerInfixParselet(ip.tokenType, ip.parselet);
66
- }
67
- }
68
- if (pkg.variableSources) {
69
- for (const vs of pkg.variableSources) {
70
- this.registerVariableSource(vs);
71
- }
72
- }
73
- }
74
- };
75
- var packageRegistry = new PackageRegistry();
76
-
77
- // src/api/defineFunction.ts
78
- var DefineFunctionErrorCodes = {
79
- /** The spec's `name` is not a single identifier. Thrown by `defineFunction`, before any engine sees it. */
80
- DEFINE_FUNCTION_INVALID_NAME: "DEFINE_FUNCTION_INVALID_NAME",
81
- /** The spec is otherwise malformed (bad `args`, unsupported type, missing `call`). Thrown by `defineFunction`. */
82
- DEFINE_FUNCTION_INVALID_SPEC: "DEFINE_FUNCTION_INVALID_SPEC",
83
- /** The call site passed the wrong number of arguments. Raised at evaluation time. */
84
- DEFINE_FUNCTION_ARITY_MISMATCH: "DEFINE_FUNCTION_ARITY_MISMATCH",
85
- /** An argument was the wrong value type. Raised at evaluation time. */
86
- DEFINE_FUNCTION_ARGUMENT_TYPE: "DEFINE_FUNCTION_ARGUMENT_TYPE",
87
- /** The `call` implementation returned a value that did not match `returns`. Raised at evaluation time, an authoring bug rather than a user one. */
88
- DEFINE_FUNCTION_RETURN_TYPE: "DEFINE_FUNCTION_RETURN_TYPE"
89
- };
90
- var NAME_PATTERN = /^[a-z_][a-z0-9_]*$/i;
91
- var SUPPORTED_TYPES = /* @__PURE__ */ new Set(["number", "string", "boolean"]);
92
- function plural(count) {
93
- return count === 1 ? "1 argument" : `${count} arguments`;
94
- }
95
- function describeValueType(v) {
96
- switch (v.type) {
97
- case 0 /* Number */:
98
- case 1 /* Hex */:
99
- return "a number";
100
- case 3 /* String */:
101
- return "a string";
102
- case 10 /* Boolean */:
103
- return "a boolean";
104
- case 2 /* BigInt */:
105
- return "a big integer";
106
- case 5 /* Percentage */:
107
- return "a percentage";
108
- case 6 /* Uom */:
109
- return "a value with a unit";
110
- case 4 /* Datetime */:
111
- return "a date";
112
- case 7 /* Matrix */:
113
- return "a matrix";
114
- case 8 /* Range */:
115
- return "a range";
116
- case 9 /* Symbolic */:
117
- return "a symbolic expression";
118
- default:
119
- return "an unsupported value";
120
- }
121
- }
122
- function coerceArgument(value, arg, fnName) {
123
- switch (arg.type) {
124
- case "number":
125
- if (value.type === 0 /* Number */ || value.type === 1 /* Hex */) {
126
- return value.toNumber();
127
- }
128
- break;
129
- case "string":
130
- if (value.type === 3 /* String */) return value.value;
131
- break;
132
- case "boolean":
133
- if (value.type === 10 /* Boolean */) return value.value;
134
- break;
135
- }
136
- throw ErrorFactory.execution({
137
- code: DefineFunctionErrorCodes.DEFINE_FUNCTION_ARGUMENT_TYPE,
138
- message: `${fnName}() expects "${arg.name}" to be a ${arg.type}, but was given ${describeValueType(value)}`,
139
- expected: `a ${arg.type}`,
140
- found: describeValueType(value),
141
- context: { functionName: fnName, argName: arg.name, expectedType: arg.type }
142
- });
143
- }
144
- function wrapReturn(result, returns, fnName) {
145
- switch (returns) {
146
- case "number":
147
- if (typeof result === "number") return numberValue(result);
148
- break;
149
- case "string":
150
- if (typeof result === "string") return stringValue(result);
151
- break;
152
- case "boolean":
153
- if (typeof result === "boolean") return boolValue(result);
154
- break;
155
- }
156
- throw ErrorFactory.internal({
157
- code: DefineFunctionErrorCodes.DEFINE_FUNCTION_RETURN_TYPE,
158
- message: `${fnName}() is declared to return a ${returns}, but its implementation returned ${typeof result}`,
159
- expected: `a ${returns}`,
160
- found: typeof result,
161
- context: { functionName: fnName, expectedType: returns }
162
- });
163
- }
164
- var DefinedFunctionParselet = class {
165
- constructor(fnIndex, fnName) {
166
- this.fnIndex = fnIndex;
167
- this.fnName = fnName;
168
- this.category = "Function";
169
- }
170
- parse(parser, _token, builder) {
171
- parser.consume("LPAREN");
172
- let argCount = 0;
173
- if (parser.peek()?.type !== "RPAREN") {
174
- parser.parseExpression(BindingPower.Lowest, builder);
175
- argCount++;
176
- while (parser.match("COMMA")) {
177
- parser.parseExpression(BindingPower.Lowest, builder);
178
- argCount++;
179
- }
180
- }
181
- parser.consume("RPAREN");
182
- builder.emitOpcode(50 /* CALL_PLUGIN */);
183
- builder.emitIndex(this.fnIndex);
184
- builder.emitIndex(argCount);
185
- }
186
- };
187
- function makeHandler(spec) {
188
- const arity = spec.args.length;
189
- return (args) => {
190
- if (args.length !== arity) {
191
- throw ErrorFactory.execution({
192
- code: DefineFunctionErrorCodes.DEFINE_FUNCTION_ARITY_MISMATCH,
193
- message: `${spec.name}() takes ${plural(arity)}, but was given ${args.length === 0 ? "none" : plural(args.length)}`,
194
- expected: plural(arity),
195
- found: args.length === 0 ? "none" : plural(args.length),
196
- context: { functionName: spec.name, expected: arity, actual: args.length }
197
- });
198
- }
199
- const jsArgs = new Array(arity);
200
- for (let i = 0; i < arity; i++) {
201
- jsArgs[i] = coerceArgument(args[i], spec.args[i], spec.name);
202
- }
203
- const result = spec.call(...jsArgs);
204
- return wrapReturn(result, spec.returns, spec.name);
205
- };
206
- }
207
- function validateSpec(spec) {
208
- if (typeof spec?.name !== "string" || !NAME_PATTERN.test(spec.name)) {
209
- throw ErrorFactory.config({
210
- code: DefineFunctionErrorCodes.DEFINE_FUNCTION_INVALID_NAME,
211
- message: `defineFunction: name must be a single identifier, got ${JSON.stringify(spec?.name)}`,
212
- suggestion: 'e.g. "vat" or "net_price"',
213
- context: { name: spec?.name }
214
- });
215
- }
216
- if (!Array.isArray(spec.args)) {
217
- throw ErrorFactory.config({
218
- code: DefineFunctionErrorCodes.DEFINE_FUNCTION_INVALID_SPEC,
219
- message: `defineFunction: "${spec.name}" args must be an array`,
220
- context: { name: spec.name }
221
- });
222
- }
223
- for (const arg of spec.args) {
224
- if (typeof arg?.name !== "string" || arg.name.length === 0) {
225
- throw ErrorFactory.config({
226
- code: DefineFunctionErrorCodes.DEFINE_FUNCTION_INVALID_SPEC,
227
- message: `defineFunction: "${spec.name}" has an argument with no name`,
228
- context: { name: spec.name }
229
- });
230
- }
231
- if (!SUPPORTED_TYPES.has(arg.type)) {
232
- throw ErrorFactory.config({
233
- code: DefineFunctionErrorCodes.DEFINE_FUNCTION_INVALID_SPEC,
234
- message: `defineFunction: "${spec.name}" argument "${arg.name}" has unsupported type ${JSON.stringify(arg.type)}`,
235
- suggestion: "supported argument types are number, string, boolean",
236
- context: { name: spec.name, argName: arg.name, type: arg.type }
237
- });
238
- }
239
- }
240
- if (!SUPPORTED_TYPES.has(spec.returns)) {
241
- throw ErrorFactory.config({
242
- code: DefineFunctionErrorCodes.DEFINE_FUNCTION_INVALID_SPEC,
243
- message: `defineFunction: "${spec.name}" has unsupported return type ${JSON.stringify(spec.returns)}`,
244
- suggestion: "supported return types are number, string, boolean",
245
- context: { name: spec.name, returns: spec.returns }
246
- });
247
- }
248
- if (typeof spec.call !== "function") {
249
- throw ErrorFactory.config({
250
- code: DefineFunctionErrorCodes.DEFINE_FUNCTION_INVALID_SPEC,
251
- message: `defineFunction: "${spec.name}" is missing a call implementation`,
252
- context: { name: spec.name }
253
- });
254
- }
255
- }
256
- function defineFunction(spec) {
257
- validateSpec(spec);
258
- const name = spec.name;
259
- const tokenType = `DEFINE_FN_${name.toUpperCase()}`;
260
- const index = allocatePluginFunctionIndex();
261
- return {
262
- name: `solve-fn-${name}`,
263
- lexerVocabulary: {
264
- // Lowercased because the lexer lowercases input before lookup, so the
265
- // call is matched case-insensitively.
266
- keywords: { [name.toLowerCase()]: tokenType }
267
- },
268
- prefixParselets: [
269
- { tokenType, parselet: new DefinedFunctionParselet(index, name) }
270
- ],
271
- pluginFunctions: [
272
- { index, handler: makeHandler(spec) }
273
- ]
274
- };
275
- }
276
-
277
- export { DefineFunctionErrorCodes, PackageRegistry, defineFunction, packageRegistry };
278
- //# sourceMappingURL=index.js.map
1
+ import'./chunk-JSPKKNPQ.js';import'./chunk-RAF57WYO.js';import {n}from'./chunk-XR7HEC7B.js';export{n as ExpressionEngine,d as SNAPSHOT_FORMAT,e as SNAPSHOT_VERSION,f as SnapshotErrorCodes,c as assertEngineVersionCompatible,b as checkEngineVersionCompatibility,a as checkPackageCompatibility}from'./chunk-XR7HEC7B.js';import'./chunk-XNIWQHXY.js';import'./chunk-2RWAXT6O.js';import'./chunk-7GK3XEZF.js';import'./chunk-MIQBJGGR.js';import'./chunk-YJ2OPULK.js';import'./chunk-TWC7K3ZX.js';import'./chunk-J4LZD4ZY.js';import'./chunk-XEIDV5JP.js';import {y as y$1}from'./chunk-EYRBENHC.js';import'./chunk-6G3PMEPA.js';import'./chunk-6CY44ZPG.js';import {a}from'./chunk-YVKHEAFT.js';import'./chunk-QXQE7X4S.js';import'./chunk-76F3LCIL.js';import'./chunk-TCZSPH4A.js';import'./chunk-W2JAR233.js';import'./chunk-YAYBVVG2.js';import'./chunk-E6Z4NQAS.js';import'./chunk-HFKDWQUL.js';import'./chunk-R2ENWQ76.js';import'./chunk-RSF25YSJ.js';import {J,t,n as n$1}from'./chunk-EVAOPEO4.js';import'./chunk-WGZ3FNHI.js';export{a as ENGINE_VERSION}from'./chunk-L3FPQSGN.js';import'./chunk-GOIQYUWV.js';import'./chunk-JPFCXLJV.js';import'./chunk-UI6IFGBT.js';import'./chunk-IJMNVBIS.js';import'./chunk-62LMTO4F.js';import'./chunk-TRBXW6HW.js';import'./chunk-2JMFUQZH.js';import {c}from'./chunk-MPB7KUN5.js';var r={DEFINE_FUNCTION_INVALID_NAME:"DEFINE_FUNCTION_INVALID_NAME",DEFINE_FUNCTION_INVALID_SPEC:"DEFINE_FUNCTION_INVALID_SPEC",DEFINE_FUNCTION_ARITY_MISMATCH:"DEFINE_FUNCTION_ARITY_MISMATCH",DEFINE_FUNCTION_ARGUMENT_TYPE:"DEFINE_FUNCTION_ARGUMENT_TYPE",DEFINE_FUNCTION_RETURN_TYPE:"DEFINE_FUNCTION_RETURN_TYPE"},b=/^[a-z_][a-z0-9_]*$/i,y=new Set(["number","string","boolean"]);function u(e){return e===1?"1 argument":`${e} arguments`}function f(e){switch(e.type){case 0:case 1:return "a number";case 3:return "a string";case 10:return "a boolean";case 2:return "a big integer";case 5:return "a percentage";case 6:return "a value with a unit";case 4:return "a date";case 7:return "a matrix";case 8:return "a range";case 9:return "a symbolic expression";default:return "an unsupported value"}}function A(e,n,t){switch(n.type){case "number":if(e.type===0||e.type===1)return e.toNumber();break;case "string":if(e.type===3)return e.value;break;case "boolean":if(e.type===10)return e.value;break}throw c.execution({code:r.DEFINE_FUNCTION_ARGUMENT_TYPE,message:`${t}() expects "${n.name}" to be a ${n.type}, but was given ${f(e)}`,expected:`a ${n.type}`,found:f(e),context:{functionName:t,argName:n.name,expectedType:n.type}})}function S(e,n,t$1){switch(n){case "number":if(typeof e=="number")return n$1(e);break;case "string":if(typeof e=="string")return t(e);break;case "boolean":if(typeof e=="boolean")return J(e);break}throw c.internal({code:r.DEFINE_FUNCTION_RETURN_TYPE,message:`${t$1}() is declared to return a ${n}, but its implementation returned ${typeof e}`,expected:`a ${n}`,found:typeof e,context:{functionName:t$1,expectedType:n}})}var p=class{constructor(n){this.fnName=n;this.category="Function";}parse(n,t,i){n.consume("LPAREN");let a$1=0;if(n.peek()?.type!=="RPAREN")for(n.parseExpression(a.Lowest,i),a$1++;n.match("COMMA");)n.parseExpression(a.Lowest,i),a$1++;n.consume("RPAREN"),i.emitPluginCall(this.fnName,a$1);}};function P(e){let n=e.args.length;return t=>{if(t.length!==n)throw c.execution({code:r.DEFINE_FUNCTION_ARITY_MISMATCH,message:`${e.name}() takes ${u(n)}, but was given ${t.length===0?"none":u(t.length)}`,expected:u(n),found:t.length===0?"none":u(t.length),context:{functionName:e.name,expected:n,actual:t.length}});let i=new Array(n);for(let s=0;s<n;s++)i[s]=A(t[s],e.args[s],e.name);let a=e.call(...i);return S(a,e.returns,e.name)}}function V(e){if(typeof e?.name!="string"||!b.test(e.name))throw c.config({code:r.DEFINE_FUNCTION_INVALID_NAME,message:`defineFunction: name must be a single identifier, got ${JSON.stringify(e?.name)}`,suggestion:'e.g. "vat" or "net_price"',context:{name:e?.name}});if(!Array.isArray(e.args))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" args must be an array`,context:{name:e.name}});for(let n of e.args){if(typeof n?.name!="string"||n.name.length===0)throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has an argument with no name`,context:{name:e.name}});if(!y.has(n.type))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" argument "${n.name}" has unsupported type ${JSON.stringify(n.type)}`,suggestion:"supported argument types are number, string, boolean",context:{name:e.name,argName:n.name,type:n.type}})}if(!y.has(e.returns))throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" has unsupported return type ${JSON.stringify(e.returns)}`,suggestion:"supported return types are number, string, boolean",context:{name:e.name,returns:e.returns}});if(typeof e.call!="function")throw c.config({code:r.DEFINE_FUNCTION_INVALID_SPEC,message:`defineFunction: "${e.name}" is missing a call implementation`,context:{name:e.name}})}function O(e){V(e);let n=e.name,t=`DEFINE_FN_${n.toUpperCase()}`;return {name:`solve-fn-${n}`,lexerVocabulary:{keywords:{[n.toLowerCase()]:t}},prefixParselets:{[t]:new p(n)},pluginFunctions:{[n]:P(e)}}}function h(e={}){let{extraPackages:n$1=[],...t}=e;return new n({...t,packages:n$1.length>0?[...y$1,...n$1]:y$1})}export{r as DefineFunctionErrorCodes,h as createEngine,O as defineFunction};//# sourceMappingURL=index.js.map
279
2
  //# sourceMappingURL=index.js.map