solve-engine 1.2.0 → 2.1.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.
- package/README.md +12 -17
- package/dist/{BytecodeBuilder-Bp9xeTmX.d.cts → BytecodeBuilder-DGGeByAP.d.cts} +18 -0
- package/dist/{BytecodeBuilder-Bp9xeTmX.d.ts → BytecodeBuilder-DGGeByAP.d.ts} +18 -0
- package/dist/{Configuration-C9W8tJv_.d.cts → Configuration-B6W0-T67.d.cts} +17 -4
- package/dist/{Configuration-C9W8tJv_.d.ts → Configuration-B6W0-T67.d.ts} +17 -4
- package/dist/{EngineError-CNA_rHY-.d.cts → EngineError-Ce1lPkjZ.d.cts} +2 -0
- package/dist/{EngineError-CNA_rHY-.d.ts → EngineError-Ce1lPkjZ.d.ts} +2 -0
- package/dist/{PackageCompatibility-B6NX9IaN.d.cts → PackageCompatibility-Bn5jnBtA.d.cts} +2 -2
- package/dist/{PackageCompatibility-Ceg5XdAp.d.ts → PackageCompatibility-CIvq2MP5.d.ts} +2 -2
- package/dist/{PackageRegistry-DrCPQNyy.d.ts → PackageRegistry-DzeiWcv4.d.ts} +93 -172
- package/dist/{PackageRegistry-DnJYVw9G.d.cts → PackageRegistry-dpdurBVO.d.cts} +93 -172
- package/dist/{Parselet-Bhf7d0_W.d.ts → Parselet-B-zoPrTa.d.ts} +8 -5
- package/dist/{Parselet-Cv7S7KRt.d.cts → Parselet-C4Wu055_.d.cts} +8 -5
- package/dist/{ScopeManager-Bzq87GfA.d.ts → ScopeManager-C2LDOrDx.d.ts} +7 -16
- package/dist/{ScopeManager-DRDBVfan.d.cts → ScopeManager-D7uMXbhS.d.cts} +7 -16
- package/dist/{VMCheckpoints-C6c17Hbo.d.ts → VMCheckpoints-CGyFhivM.d.ts} +3 -3
- package/dist/{VMCheckpoints-dZxSMGHG.d.cts → VMCheckpoints-I9jg3jWR.d.cts} +3 -3
- package/dist/{Value-DZNQ_PU7.d.cts → Value-CCi_Eecs.d.cts} +40 -0
- package/dist/{Value-DZNQ_PU7.d.ts → Value-CCi_Eecs.d.ts} +40 -0
- package/dist/{WorkerError-Djd7GGGa.d.cts → WorkerError-B4p6PNfx.d.cts} +1 -1
- package/dist/{WorkerError-B7t7R2-m.d.ts → WorkerError-Dhj9BQ_A.d.ts} +1 -1
- package/dist/chunk-2JMFUQZH.js +2 -0
- package/dist/chunk-2JMFUQZH.js.map +1 -0
- package/dist/chunk-2LFLR3VZ.cjs +2 -0
- package/dist/chunk-2LFLR3VZ.cjs.map +1 -0
- package/dist/chunk-2RWAXT6O.js +0 -1
- package/dist/chunk-32GC2FHC.cjs +2 -0
- package/dist/chunk-32GC2FHC.cjs.map +1 -0
- package/dist/chunk-4BZIYU7S.cjs +3 -0
- package/dist/chunk-4BZIYU7S.cjs.map +1 -0
- package/dist/chunk-4E4YVQKK.js +5 -0
- package/dist/chunk-4E4YVQKK.js.map +1 -0
- package/dist/chunk-4QVBSG6B.cjs +2 -0
- package/dist/chunk-4QVBSG6B.cjs.map +1 -0
- package/dist/chunk-5FO4PDIG.js +2 -0
- package/dist/chunk-5FO4PDIG.js.map +1 -0
- package/dist/chunk-5IJD5L3O.cjs +2 -0
- package/dist/chunk-5IJD5L3O.cjs.map +1 -0
- package/dist/chunk-62LMTO4F.js +2 -0
- package/dist/chunk-62LMTO4F.js.map +1 -0
- package/dist/chunk-6G3PMEPA.js +2 -0
- package/dist/chunk-6G3PMEPA.js.map +1 -0
- package/dist/chunk-6INX773F.cjs +2 -0
- package/dist/chunk-6INX773F.cjs.map +1 -0
- package/dist/chunk-76F3LCIL.js +4 -0
- package/dist/chunk-76F3LCIL.js.map +1 -0
- package/dist/chunk-7BXPCWKM.cjs +2 -0
- package/dist/chunk-7BXPCWKM.cjs.map +1 -0
- package/dist/chunk-7GK3XEZF.js +2 -0
- package/dist/chunk-7GK3XEZF.js.map +1 -0
- package/dist/chunk-AXMQG5TS.cjs +2 -0
- package/dist/chunk-AXMQG5TS.cjs.map +1 -0
- package/dist/chunk-CIQOK7Q4.cjs +2 -0
- package/dist/chunk-CIQOK7Q4.cjs.map +1 -0
- package/dist/chunk-E2Q3PQ2G.js +3 -0
- package/dist/chunk-E2Q3PQ2G.js.map +1 -0
- package/dist/chunk-E6Z4NQAS.js +2 -0
- package/dist/chunk-E6Z4NQAS.js.map +1 -0
- package/dist/chunk-EFJCC6FJ.cjs +2 -0
- package/dist/chunk-EFJCC6FJ.cjs.map +1 -0
- package/dist/chunk-ESUN2THE.cjs +2 -0
- package/dist/chunk-ESUN2THE.cjs.map +1 -0
- package/dist/chunk-EVAOPEO4.js +2 -0
- package/dist/chunk-EVAOPEO4.js.map +1 -0
- package/dist/chunk-EVI6OHQH.cjs +2 -0
- package/dist/chunk-EVI6OHQH.cjs.map +1 -0
- package/dist/chunk-FDE5HWDI.cjs +2 -0
- package/dist/chunk-FDE5HWDI.cjs.map +1 -0
- package/dist/chunk-FWW3M36J.cjs +2 -0
- package/dist/chunk-FWW3M36J.cjs.map +1 -0
- package/dist/chunk-G7TBEQRQ.js +2 -0
- package/dist/chunk-G7TBEQRQ.js.map +1 -0
- package/dist/chunk-GK2OHWRF.cjs +5 -0
- package/dist/chunk-GK2OHWRF.cjs.map +1 -0
- package/dist/chunk-HFKDWQUL.js +2 -0
- package/dist/chunk-HFKDWQUL.js.map +1 -0
- package/dist/chunk-HLBYHXQD.cjs +3 -0
- package/dist/chunk-HLBYHXQD.cjs.map +1 -0
- package/dist/chunk-I52MYCVI.js +3 -0
- package/dist/chunk-I52MYCVI.js.map +1 -0
- package/dist/chunk-IANAMBJQ.cjs +2 -0
- package/dist/chunk-IANAMBJQ.cjs.map +1 -0
- package/dist/chunk-IJMNVBIS.js +2 -0
- package/dist/chunk-IJMNVBIS.js.map +1 -0
- package/dist/chunk-J4LZD4ZY.js +3 -0
- package/dist/chunk-J4LZD4ZY.js.map +1 -0
- package/dist/chunk-JAK3RAFA.cjs +2 -0
- package/dist/chunk-JAK3RAFA.cjs.map +1 -0
- package/dist/chunk-JFAJN3C2.cjs +2 -0
- package/dist/chunk-JFAJN3C2.cjs.map +1 -0
- package/dist/chunk-JPFCXLJV.js +2 -0
- package/dist/chunk-JPFCXLJV.js.map +1 -0
- package/dist/chunk-JUIJ6NRD.cjs +3 -0
- package/dist/chunk-JUIJ6NRD.cjs.map +1 -0
- package/dist/chunk-MIQBJGGR.js +2 -0
- package/dist/chunk-MIQBJGGR.js.map +1 -0
- package/dist/chunk-MPB7KUN5.js +3 -0
- package/dist/chunk-MPB7KUN5.js.map +1 -0
- package/dist/chunk-MSYX32PF.cjs +2 -0
- package/dist/chunk-MSYX32PF.cjs.map +1 -0
- package/dist/chunk-MVZUTETT.js +2 -0
- package/dist/chunk-MVZUTETT.js.map +1 -0
- package/dist/chunk-N7N7MPMK.cjs +2 -0
- package/dist/chunk-N7N7MPMK.cjs.map +1 -0
- package/dist/chunk-NGBBNL4K.cjs +1 -3
- package/dist/chunk-OVKDDTXO.cjs +3 -0
- package/dist/chunk-OVKDDTXO.cjs.map +1 -0
- package/dist/chunk-P6WPEUAJ.cjs +2 -0
- package/dist/chunk-P6WPEUAJ.cjs.map +1 -0
- package/dist/chunk-PS272DZJ.cjs +2 -0
- package/dist/chunk-PS272DZJ.cjs.map +1 -0
- package/dist/chunk-R2ENWQ76.js +2 -0
- package/dist/chunk-R2ENWQ76.js.map +1 -0
- package/dist/chunk-R2SZFJTT.cjs +2 -0
- package/dist/chunk-R2SZFJTT.cjs.map +1 -0
- package/dist/chunk-RAF57WYO.js +2 -0
- package/dist/chunk-RAF57WYO.js.map +1 -0
- package/dist/chunk-RSF25YSJ.js +2 -0
- package/dist/chunk-RSF25YSJ.js.map +1 -0
- package/dist/chunk-SOMGSIO4.cjs +3 -0
- package/dist/chunk-SOMGSIO4.cjs.map +1 -0
- package/dist/chunk-SYYE3QAX.cjs +2 -0
- package/dist/chunk-SYYE3QAX.cjs.map +1 -0
- package/dist/chunk-TCZSPH4A.js +2 -0
- package/dist/chunk-TCZSPH4A.js.map +1 -0
- package/dist/chunk-TLG7VZRX.cjs +2 -0
- package/dist/chunk-TLG7VZRX.cjs.map +1 -0
- package/dist/chunk-TN5E6JU6.js +2 -0
- package/dist/chunk-TN5E6JU6.js.map +1 -0
- package/dist/chunk-TRBXW6HW.js +2 -0
- package/dist/{chunk-AQNHHJMJ.cjs.map → chunk-TRBXW6HW.js.map} +1 -1
- package/dist/chunk-TTFO4YDP.cjs +2 -0
- package/dist/chunk-TTFO4YDP.cjs.map +1 -0
- package/dist/chunk-TWC7K3ZX.js +2 -0
- package/dist/chunk-TWC7K3ZX.js.map +1 -0
- package/dist/chunk-U4AEVL5Z.js +2 -0
- package/dist/chunk-U4AEVL5Z.js.map +1 -0
- package/dist/chunk-UURM7P3P.cjs +4 -0
- package/dist/chunk-UURM7P3P.cjs.map +1 -0
- package/dist/chunk-VAGS5JS7.cjs +2 -0
- package/dist/chunk-VAGS5JS7.cjs.map +1 -0
- package/dist/chunk-W2JAR233.js +2 -0
- package/dist/chunk-W2JAR233.js.map +1 -0
- package/dist/chunk-WGZ3FNHI.js +2 -0
- package/dist/chunk-WGZ3FNHI.js.map +1 -0
- package/dist/chunk-XEIDV5JP.js +2 -0
- package/dist/chunk-XEIDV5JP.js.map +1 -0
- package/dist/chunk-XNIWQHXY.js +2 -0
- package/dist/chunk-XNIWQHXY.js.map +1 -0
- package/dist/chunk-Y7O4D3BJ.cjs +2 -0
- package/dist/chunk-Y7O4D3BJ.cjs.map +1 -0
- package/dist/chunk-YAHGSBMC.js +2 -0
- package/dist/chunk-YAHGSBMC.js.map +1 -0
- package/dist/chunk-YAYBVVG2.js +3 -0
- package/dist/chunk-YAYBVVG2.js.map +1 -0
- package/dist/chunk-YJ2OPULK.js +2 -0
- package/dist/chunk-YJ2OPULK.js.map +1 -0
- package/dist/chunk-YVKHEAFT.js +2 -0
- package/dist/chunk-YVKHEAFT.js.map +1 -0
- package/dist/chunk-ZCNBT44X.cjs +2 -0
- package/dist/chunk-ZCNBT44X.cjs.map +1 -0
- package/dist/chunk-ZLRJ7TDP.cjs +2 -0
- package/dist/chunk-ZLRJ7TDP.cjs.map +1 -0
- package/dist/constants.cjs +1 -21
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -4
- package/dist/engine.cjs +1 -94
- package/dist/engine.d.cts +10 -11
- package/dist/engine.d.ts +10 -11
- package/dist/engine.js +1 -37
- package/dist/errors.cjs +1 -105
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -4
- package/dist/format.cjs +1 -26
- package/dist/format.d.cts +2 -2
- package/dist/format.d.ts +2 -2
- package/dist/format.js +1 -9
- package/dist/index.cjs +1 -314
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -20
- package/dist/index.d.ts +52 -20
- package/dist/index.js +1 -278
- package/dist/index.js.map +1 -1
- package/dist/language.cjs +1 -369
- package/dist/language.cjs.map +1 -1
- package/dist/language.d.cts +9 -10
- package/dist/language.d.ts +9 -10
- package/dist/language.js +1 -348
- package/dist/language.js.map +1 -1
- package/dist/lexer.cjs +1 -63
- package/dist/lexer.js +1 -10
- package/dist/normalizer.cjs +1 -39
- package/dist/normalizer.js +1 -10
- package/dist/packages.cjs +1 -132
- package/dist/packages.d.cts +8 -9
- package/dist/packages.d.ts +8 -9
- package/dist/packages.js +1 -23
- package/dist/parser.cjs +1 -54
- package/dist/parser.d.cts +8 -8
- package/dist/parser.d.ts +8 -8
- package/dist/parser.js +1 -9
- package/dist/{pipeline-D-PS9gVw.d.ts → pipeline-72QmQlGx.d.ts} +1 -1
- package/dist/{pipeline-DtSBJ8TS.d.cts → pipeline-DCQicwWX.d.cts} +1 -1
- package/dist/resolvers.cjs +1 -12
- package/dist/resolvers.d.cts +2 -2
- package/dist/resolvers.d.ts +2 -2
- package/dist/resolvers.js +1 -3
- package/dist/services.cjs +1 -20
- package/dist/services.js +1 -3
- package/dist/testing.cjs +3 -477
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +9 -10
- package/dist/testing.d.ts +9 -10
- package/dist/testing.js +3 -469
- package/dist/testing.js.map +1 -1
- package/dist/uom.cjs +1 -55
- package/dist/uom.d.cts +2 -2
- package/dist/uom.d.ts +2 -2
- package/dist/uom.js +1 -10
- package/dist/utilities.cjs +1 -36
- package/dist/utilities.js +1 -7
- package/dist/vm.cjs +1 -295
- package/dist/vm.cjs.map +1 -1
- package/dist/vm.d.cts +22 -10
- package/dist/vm.d.ts +22 -10
- package/dist/vm.js +1 -193
- package/dist/vm.js.map +1 -1
- package/dist/worker.cjs +2 -492
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +16 -17
- package/dist/worker.d.ts +16 -17
- package/dist/worker.js +2 -483
- package/dist/worker.js.map +1 -1
- package/package.json +1 -13
- package/dist/chunk-3BOK2LDK.js +0 -17
- package/dist/chunk-3BOK2LDK.js.map +0 -1
- package/dist/chunk-3VGDNEE3.js +0 -84
- package/dist/chunk-3VGDNEE3.js.map +0 -1
- package/dist/chunk-4K5W7EH2.cjs +0 -112
- package/dist/chunk-4K5W7EH2.cjs.map +0 -1
- package/dist/chunk-5EFKSKMA.js +0 -413
- package/dist/chunk-5EFKSKMA.js.map +0 -1
- package/dist/chunk-5HRB36DK.js +0 -405
- package/dist/chunk-5HRB36DK.js.map +0 -1
- package/dist/chunk-5ON7PUAZ.js +0 -12
- package/dist/chunk-5ON7PUAZ.js.map +0 -1
- package/dist/chunk-7AXJNQMF.cjs +0 -297
- package/dist/chunk-7AXJNQMF.cjs.map +0 -1
- package/dist/chunk-7JM3F4KL.js +0 -1795
- package/dist/chunk-7JM3F4KL.js.map +0 -1
- package/dist/chunk-7USV76HV.cjs +0 -341
- package/dist/chunk-7USV76HV.cjs.map +0 -1
- package/dist/chunk-A2DZ5BEJ.cjs +0 -1930
- package/dist/chunk-A2DZ5BEJ.cjs.map +0 -1
- package/dist/chunk-ADBA3XBE.cjs +0 -20
- package/dist/chunk-ADBA3XBE.cjs.map +0 -1
- package/dist/chunk-AKNGX4TZ.cjs +0 -236
- package/dist/chunk-AKNGX4TZ.cjs.map +0 -1
- package/dist/chunk-ALYRJ72W.cjs +0 -434
- package/dist/chunk-ALYRJ72W.cjs.map +0 -1
- package/dist/chunk-AMOJYLG2.cjs +0 -1692
- package/dist/chunk-AMOJYLG2.cjs.map +0 -1
- package/dist/chunk-AOH6UR2L.js +0 -825
- package/dist/chunk-AOH6UR2L.js.map +0 -1
- package/dist/chunk-AQNHHJMJ.cjs +0 -261
- package/dist/chunk-B7LXJ6LC.cjs +0 -36
- package/dist/chunk-B7LXJ6LC.cjs.map +0 -1
- package/dist/chunk-BESTLPRK.cjs +0 -6919
- package/dist/chunk-BESTLPRK.cjs.map +0 -1
- package/dist/chunk-BLI4NIQY.js +0 -98
- package/dist/chunk-BLI4NIQY.js.map +0 -1
- package/dist/chunk-BSPXMGIS.js +0 -455
- package/dist/chunk-BSPXMGIS.js.map +0 -1
- package/dist/chunk-C2OMO3WN.cjs +0 -2806
- package/dist/chunk-C2OMO3WN.cjs.map +0 -1
- package/dist/chunk-CSDQMDU2.js +0 -204
- package/dist/chunk-CSDQMDU2.js.map +0 -1
- package/dist/chunk-EJ3ILXX6.cjs +0 -223
- package/dist/chunk-EJ3ILXX6.cjs.map +0 -1
- package/dist/chunk-ENRIK36Q.cjs +0 -94
- package/dist/chunk-ENRIK36Q.cjs.map +0 -1
- package/dist/chunk-F4UB4XIL.js +0 -109
- package/dist/chunk-F4UB4XIL.js.map +0 -1
- package/dist/chunk-FD5ZZHEU.js +0 -92
- package/dist/chunk-FD5ZZHEU.js.map +0 -1
- package/dist/chunk-FE4RC37D.js +0 -2801
- package/dist/chunk-FE4RC37D.js.map +0 -1
- package/dist/chunk-FEAIOR7N.cjs +0 -91
- package/dist/chunk-FEAIOR7N.cjs.map +0 -1
- package/dist/chunk-FR7RNOPT.cjs +0 -3303
- package/dist/chunk-FR7RNOPT.cjs.map +0 -1
- package/dist/chunk-G2YPPLGX.cjs +0 -484
- package/dist/chunk-G2YPPLGX.cjs.map +0 -1
- package/dist/chunk-GCM5JHMX.js +0 -88
- package/dist/chunk-GCM5JHMX.js.map +0 -1
- package/dist/chunk-GDEU72RG.cjs +0 -829
- package/dist/chunk-GDEU72RG.cjs.map +0 -1
- package/dist/chunk-HKTQCQ4Z.cjs +0 -8383
- package/dist/chunk-HKTQCQ4Z.cjs.map +0 -1
- package/dist/chunk-HWHU642X.cjs +0 -316
- package/dist/chunk-HWHU642X.cjs.map +0 -1
- package/dist/chunk-ICEKS6YC.cjs +0 -507
- package/dist/chunk-ICEKS6YC.cjs.map +0 -1
- package/dist/chunk-IJGOFP2J.js +0 -6904
- package/dist/chunk-IJGOFP2J.js.map +0 -1
- package/dist/chunk-IQJGDZOP.js +0 -333
- package/dist/chunk-IQJGDZOP.js.map +0 -1
- package/dist/chunk-IT74O4BE.cjs +0 -456
- package/dist/chunk-IT74O4BE.cjs.map +0 -1
- package/dist/chunk-KXDQKVNX.cjs +0 -459
- package/dist/chunk-KXDQKVNX.cjs.map +0 -1
- package/dist/chunk-L2TE7PMO.cjs +0 -14
- package/dist/chunk-L2TE7PMO.cjs.map +0 -1
- package/dist/chunk-L5YHV6BQ.js +0 -499
- package/dist/chunk-L5YHV6BQ.js.map +0 -1
- package/dist/chunk-LO7HU5WB.cjs +0 -209
- package/dist/chunk-LO7HU5WB.cjs.map +0 -1
- package/dist/chunk-LSALB3IN.js +0 -292
- package/dist/chunk-LSALB3IN.js.map +0 -1
- package/dist/chunk-MI7OTUHL.cjs +0 -339
- package/dist/chunk-MI7OTUHL.cjs.map +0 -1
- package/dist/chunk-MIGXCBXT.cjs +0 -381
- package/dist/chunk-MIGXCBXT.cjs.map +0 -1
- package/dist/chunk-MVTOCRV2.js +0 -213
- package/dist/chunk-MVTOCRV2.js.map +0 -1
- package/dist/chunk-N7FNVFXW.cjs +0 -32
- package/dist/chunk-N7FNVFXW.cjs.map +0 -1
- package/dist/chunk-N7OA4WPJ.js +0 -362
- package/dist/chunk-N7OA4WPJ.js.map +0 -1
- package/dist/chunk-NAWZATKT.js +0 -478
- package/dist/chunk-NAWZATKT.js.map +0 -1
- package/dist/chunk-NLNDMWZC.js +0 -31
- package/dist/chunk-NLNDMWZC.js.map +0 -1
- package/dist/chunk-ORM7CHYZ.js +0 -1531
- package/dist/chunk-ORM7CHYZ.js.map +0 -1
- package/dist/chunk-OUHT5Z36.cjs +0 -393
- package/dist/chunk-OUHT5Z36.cjs.map +0 -1
- package/dist/chunk-PCZVMMWU.cjs +0 -74
- package/dist/chunk-PCZVMMWU.cjs.map +0 -1
- package/dist/chunk-RNKDIXDV.js +0 -336
- package/dist/chunk-RNKDIXDV.js.map +0 -1
- package/dist/chunk-SBUFNJVE.js +0 -258
- package/dist/chunk-SBUFNJVE.js.map +0 -1
- package/dist/chunk-TC6BTUSU.cjs +0 -1799
- package/dist/chunk-TC6BTUSU.cjs.map +0 -1
- package/dist/chunk-TPOK3UNI.js +0 -8355
- package/dist/chunk-TPOK3UNI.js.map +0 -1
- package/dist/chunk-UF6JG5SG.js +0 -312
- package/dist/chunk-UF6JG5SG.js.map +0 -1
- package/dist/chunk-UKQHXPGW.js +0 -30
- package/dist/chunk-UKQHXPGW.js.map +0 -1
- package/dist/chunk-V4XG5QF6.js +0 -1685
- package/dist/chunk-V4XG5QF6.js.map +0 -1
- package/dist/chunk-VEKIWQ3F.cjs +0 -39
- package/dist/chunk-VEKIWQ3F.cjs.map +0 -1
- package/dist/chunk-WMQRJTAO.js +0 -3266
- package/dist/chunk-WMQRJTAO.js.map +0 -1
- package/dist/chunk-X6K3HUOY.cjs +0 -86
- package/dist/chunk-X6K3HUOY.cjs.map +0 -1
- package/dist/chunk-XBTEO4OB.js +0 -391
- package/dist/chunk-XBTEO4OB.js.map +0 -1
- package/dist/chunk-XIYYHA65.cjs +0 -101
- package/dist/chunk-XIYYHA65.cjs.map +0 -1
- package/dist/chunk-YJHY7CMN.cjs +0 -1534
- package/dist/chunk-YJHY7CMN.cjs.map +0 -1
- package/dist/chunk-YLJ4XMA6.js +0 -33
- package/dist/chunk-YLJ4XMA6.js.map +0 -1
- package/dist/chunk-YNIWOYW6.js +0 -232
- package/dist/chunk-YNIWOYW6.js.map +0 -1
- package/dist/chunk-Z2XP767T.cjs +0 -35
- package/dist/chunk-Z2XP767T.cjs.map +0 -1
- package/dist/chunk-Z4X2RWOF.js +0 -37
- package/dist/chunk-Z4X2RWOF.js.map +0 -1
- package/dist/chunk-ZN6YYPIW.js +0 -67
- package/dist/chunk-ZN6YYPIW.js.map +0 -1
- package/dist/chunk-ZNFFTYWH.js +0 -1854
- package/dist/chunk-ZNFFTYWH.js.map +0 -1
- package/dist/variables.cjs +0 -17
- package/dist/variables.cjs.map +0 -1
- package/dist/variables.d.cts +0 -87
- package/dist/variables.d.ts +0 -87
- package/dist/variables.js +0 -4
- package/dist/variables.js.map +0 -1
package/dist/chunk-IT74O4BE.cjs
DELETED
|
@@ -1,456 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkMIGXCBXT_cjs = require('./chunk-MIGXCBXT.cjs');
|
|
4
|
-
|
|
5
|
-
// src/vm/AllocationBudget.ts
|
|
6
|
-
var depth = 0;
|
|
7
|
-
var used = 0;
|
|
8
|
-
var limit = Number.POSITIVE_INFINITY;
|
|
9
|
-
var calls = 0;
|
|
10
|
-
var callLimit = Number.POSITIVE_INFINITY;
|
|
11
|
-
function exceeded(requested, what, alreadyUsed) {
|
|
12
|
-
return chunkMIGXCBXT_cjs.ErrorFactory.execution({
|
|
13
|
-
code: "ALLOCATION_LIMIT_EXCEEDED",
|
|
14
|
-
message: `Evaluating this expression would materialise ${requested.toLocaleString("en-US")} ${what}, past the limit of ${limit.toLocaleString("en-US")} elements for one evaluation`,
|
|
15
|
-
expected: `at most ${limit.toLocaleString("en-US")} elements materialised while evaluating one expression`,
|
|
16
|
-
found: `a request for ${requested.toLocaleString("en-US")} more ${what}, on top of ${alreadyUsed.toLocaleString("en-US")} already materialised`,
|
|
17
|
-
suggestion: "use a smaller collection or matrix, or raise the engine's vm.maxAllocatedElements setting",
|
|
18
|
-
context: { requested, what, used: alreadyUsed, limit }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function beginEvaluation(vm) {
|
|
22
|
-
if (depth++ === 0) {
|
|
23
|
-
used = 0;
|
|
24
|
-
limit = vm.getMaxAllocatedElements();
|
|
25
|
-
calls = 0;
|
|
26
|
-
callLimit = vm.getMaxFunctionCalls();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function endEvaluation() {
|
|
30
|
-
if (depth > 0) depth--;
|
|
31
|
-
}
|
|
32
|
-
function chargeAllocation(count, what) {
|
|
33
|
-
if (depth === 0) return;
|
|
34
|
-
if (!(count >= 0)) throw exceeded(count, what, used);
|
|
35
|
-
used += count;
|
|
36
|
-
if (used > limit) throw exceeded(count, what, used - count);
|
|
37
|
-
}
|
|
38
|
-
function checkAllocation(count, what) {
|
|
39
|
-
if (depth === 0) return;
|
|
40
|
-
if (!(count >= 0) || used + count > limit) throw exceeded(count, what, used);
|
|
41
|
-
}
|
|
42
|
-
function checkedArray(count, what) {
|
|
43
|
-
checkAllocation(count, what);
|
|
44
|
-
return new Array(count);
|
|
45
|
-
}
|
|
46
|
-
function chargeFunctionCall() {
|
|
47
|
-
if (depth === 0) return;
|
|
48
|
-
if (++calls > callLimit) {
|
|
49
|
-
throw chunkMIGXCBXT_cjs.ErrorFactory.execution({
|
|
50
|
-
code: "FUNCTION_CALL_LIMIT_EXCEEDED",
|
|
51
|
-
message: `Evaluating this expression would make more than ${callLimit.toLocaleString("en-US")} user-defined-function calls, which is the limit for one evaluation`,
|
|
52
|
-
expected: `at most ${callLimit.toLocaleString("en-US")} function calls while evaluating one expression`,
|
|
53
|
-
found: "a call past that limit, from a chain of functions that each call others more than once",
|
|
54
|
-
suggestion: "check for a function that calls itself (or a chain of them) more times than intended, or raise the engine's vm.maxFunctionCalls setting",
|
|
55
|
-
context: { calls, callLimit }
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// src/vm/Value.ts
|
|
61
|
-
var ValueType = /* @__PURE__ */ ((ValueType2) => {
|
|
62
|
-
ValueType2[ValueType2["Number"] = 0] = "Number";
|
|
63
|
-
ValueType2[ValueType2["Hex"] = 1] = "Hex";
|
|
64
|
-
ValueType2[ValueType2["BigInt"] = 2] = "BigInt";
|
|
65
|
-
ValueType2[ValueType2["String"] = 3] = "String";
|
|
66
|
-
ValueType2[ValueType2["Datetime"] = 4] = "Datetime";
|
|
67
|
-
ValueType2[ValueType2["Percentage"] = 5] = "Percentage";
|
|
68
|
-
ValueType2[ValueType2["Uom"] = 6] = "Uom";
|
|
69
|
-
ValueType2[ValueType2["Matrix"] = 7] = "Matrix";
|
|
70
|
-
ValueType2[ValueType2["Range"] = 8] = "Range";
|
|
71
|
-
ValueType2[ValueType2["Symbolic"] = 9] = "Symbolic";
|
|
72
|
-
ValueType2[ValueType2["Boolean"] = 10] = "Boolean";
|
|
73
|
-
ValueType2[ValueType2["Unit"] = 11] = "Unit";
|
|
74
|
-
ValueType2[ValueType2["Pending"] = 12] = "Pending";
|
|
75
|
-
ValueType2[ValueType2["Error"] = 13] = "Error";
|
|
76
|
-
ValueType2[ValueType2["Colour"] = 14] = "Colour";
|
|
77
|
-
ValueType2[ValueType2["Split"] = 15] = "Split";
|
|
78
|
-
return ValueType2;
|
|
79
|
-
})(ValueType || {});
|
|
80
|
-
var _ValueArena = class _ValueArena {
|
|
81
|
-
/** Pre-allocate initial block. 512 Values covers ~30-line viewport comfortably. */
|
|
82
|
-
constructor(initialSize = 512) {
|
|
83
|
-
this.arena = [];
|
|
84
|
-
this.index = 0;
|
|
85
|
-
this.initialSize = initialSize;
|
|
86
|
-
for (let i = 0; i < initialSize; i++) {
|
|
87
|
-
this.arena.push(new Value(0 /* Number */, 0));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/** Bump-allocate a recycled Value. Falls back to allocation only for overflow. */
|
|
91
|
-
acquire(type, value, unit) {
|
|
92
|
-
if (this.index < this.arena.length) {
|
|
93
|
-
const v2 = this.arena[this.index++];
|
|
94
|
-
v2.recycle(type, value, unit);
|
|
95
|
-
return v2;
|
|
96
|
-
}
|
|
97
|
-
const v = new Value(type, value, unit);
|
|
98
|
-
this.arena.push(v);
|
|
99
|
-
this.index++;
|
|
100
|
-
return v;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Reset for the next scroll frame, releasing a block the last frame turned
|
|
104
|
-
* out not to need.
|
|
105
|
-
*
|
|
106
|
-
* Still O(1) in the ordinary case: one comparison against what the cycle
|
|
107
|
-
* that just ended used, and the truncation only on the frame after an
|
|
108
|
-
* unusually expensive one. Reading the usage here rather than at
|
|
109
|
-
* `disableValueArena()` is what makes the policy "the first cycle that does
|
|
110
|
-
* not need the block gives it back", which is the first thing a host does
|
|
111
|
-
* after the line that grew it.
|
|
112
|
-
*/
|
|
113
|
-
reset() {
|
|
114
|
-
const usedLastCycle = this.index;
|
|
115
|
-
this.index = 0;
|
|
116
|
-
if (this.arena.length <= this.initialSize) return;
|
|
117
|
-
if (this.arena.length <= usedLastCycle * _ValueArena.SHRINK_WHEN_HOLDING_TIMES) return;
|
|
118
|
-
this.arena.length = Math.max(this.initialSize, usedLastCycle * _ValueArena.KEEP_TIMES);
|
|
119
|
-
}
|
|
120
|
-
/** Current arena utilization (for diagnostics). */
|
|
121
|
-
get usage() {
|
|
122
|
-
return this.index;
|
|
123
|
-
}
|
|
124
|
-
get capacity() {
|
|
125
|
-
return this.arena.length;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* How much more than the last cycle needed the arena may go on holding
|
|
130
|
-
* before it gives the difference back, and how much of it it keeps when it
|
|
131
|
-
* does.
|
|
132
|
-
*
|
|
133
|
-
* A bump allocator that grows to serve one expensive line is working as
|
|
134
|
-
* intended; one that never comes down is a leak wearing a cache's clothes.
|
|
135
|
-
* `map(x*1, 1:100000)` is an ordinary line by every limit the engine has,
|
|
136
|
-
* and it took the arena from 512 Values to 300,004, about 24MB that stayed
|
|
137
|
-
* live through two forced full collections and through every later `1 + 1`,
|
|
138
|
-
* because `acquire()` handles overflow with `push()` and `reset()` only
|
|
139
|
-
* zeroed the bump index. The instance is module-level and survives
|
|
140
|
-
* `disableValueArena()` on purpose, so that high-water mark was for the
|
|
141
|
-
* life of the process.
|
|
142
|
-
*
|
|
143
|
-
* Keeping twice what the last cycle used, and only shrinking once holding
|
|
144
|
-
* four times that, is what stops the release from becoming a different
|
|
145
|
-
* performance bug: a steady scroll uses about the same number of Values
|
|
146
|
-
* every frame, so it never meets the condition at all, and an alternating
|
|
147
|
-
* heavy/light document degrades at worst to allocating the Values it would
|
|
148
|
-
* have allocated with no arena in the first place.
|
|
149
|
-
*/
|
|
150
|
-
_ValueArena.SHRINK_WHEN_HOLDING_TIMES = 4;
|
|
151
|
-
_ValueArena.KEEP_TIMES = 2;
|
|
152
|
-
var ValueArena = _ValueArena;
|
|
153
|
-
var _arena = null;
|
|
154
|
-
var _arenaActive = false;
|
|
155
|
-
function enableValueArena(size) {
|
|
156
|
-
if (!_arena) _arena = new ValueArena(size);
|
|
157
|
-
_arena.reset();
|
|
158
|
-
_arenaActive = true;
|
|
159
|
-
return _arena;
|
|
160
|
-
}
|
|
161
|
-
function disableValueArena() {
|
|
162
|
-
_arenaActive = false;
|
|
163
|
-
}
|
|
164
|
-
function isArenaActive() {
|
|
165
|
-
return _arenaActive;
|
|
166
|
-
}
|
|
167
|
-
function persistentValue(v) {
|
|
168
|
-
const p = new Value(v.type, v.value, v.unit);
|
|
169
|
-
if (v.exact !== void 0) p.exact = v.exact;
|
|
170
|
-
if (v.rational !== void 0) p.rational = v.rational;
|
|
171
|
-
if (v.uncertainty !== void 0) p.uncertainty = v.uncertainty;
|
|
172
|
-
return p;
|
|
173
|
-
}
|
|
174
|
-
var isDevelopmentBuild = process.env.NODE_ENV === "development";
|
|
175
|
-
function freezeIfDev(value) {
|
|
176
|
-
if (isDevelopmentBuild && !isArenaActive()) {
|
|
177
|
-
value.toNumber();
|
|
178
|
-
Object.freeze(value);
|
|
179
|
-
}
|
|
180
|
-
return value;
|
|
181
|
-
}
|
|
182
|
-
var Value = class {
|
|
183
|
-
constructor(type, value, unit) {
|
|
184
|
-
this.type = type;
|
|
185
|
-
this.value = value;
|
|
186
|
-
this.unit = unit;
|
|
187
|
-
if (typeof value === "number") {
|
|
188
|
-
this._cachedNumber = value;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Phase 5.3: Reset all fields for arena reuse.
|
|
193
|
-
* Called by ValueArena.acquire(), zero allocation, just field assignment.
|
|
194
|
-
*/
|
|
195
|
-
recycle(type, value, unit) {
|
|
196
|
-
this.type = type;
|
|
197
|
-
this.value = value;
|
|
198
|
-
this.unit = unit;
|
|
199
|
-
this._cachedNumber = typeof value === "number" ? value : void 0;
|
|
200
|
-
this.timedOut = void 0;
|
|
201
|
-
this.exact = void 0;
|
|
202
|
-
this.rational = void 0;
|
|
203
|
-
this.uncertainty = void 0;
|
|
204
|
-
this.decimalPlaces = void 0;
|
|
205
|
-
}
|
|
206
|
-
isNumber() {
|
|
207
|
-
return this.type === 0 /* Number */;
|
|
208
|
-
}
|
|
209
|
-
isHex() {
|
|
210
|
-
return this.type === 1 /* Hex */;
|
|
211
|
-
}
|
|
212
|
-
isBigInt() {
|
|
213
|
-
return this.type === 2 /* BigInt */;
|
|
214
|
-
}
|
|
215
|
-
isString() {
|
|
216
|
-
return this.type === 3 /* String */;
|
|
217
|
-
}
|
|
218
|
-
isMatrix() {
|
|
219
|
-
return this.type === 7 /* Matrix */;
|
|
220
|
-
}
|
|
221
|
-
/** A Matrix shaped like a vector, 1×N (row) or N×1 (column). */
|
|
222
|
-
isVectorShape() {
|
|
223
|
-
if (this.type !== 7 /* Matrix */) return false;
|
|
224
|
-
const m = this.value;
|
|
225
|
-
return m.rows === 1 || m.cols === 1;
|
|
226
|
-
}
|
|
227
|
-
isRange() {
|
|
228
|
-
return this.type === 8 /* Range */;
|
|
229
|
-
}
|
|
230
|
-
isColour() {
|
|
231
|
-
return this.type === 14 /* Colour */;
|
|
232
|
-
}
|
|
233
|
-
isSymbolic() {
|
|
234
|
-
return this.type === 9 /* Symbolic */;
|
|
235
|
-
}
|
|
236
|
-
toNumber() {
|
|
237
|
-
if (this.type === 12 /* Pending */) return 0;
|
|
238
|
-
if (this.type === 13 /* Error */) return 0;
|
|
239
|
-
if (this.type === 7 /* Matrix */) {
|
|
240
|
-
const m = this.value;
|
|
241
|
-
if (m.rows === 1 && m.cols === 1 && typeof m.data[0] === "number") return m.data[0];
|
|
242
|
-
return 0;
|
|
243
|
-
}
|
|
244
|
-
if (this.type === 8 /* Range */) return 0;
|
|
245
|
-
if (this.type === 14 /* Colour */) return 0;
|
|
246
|
-
if (this.type === 15 /* Split */) return this.value.shares[0].value;
|
|
247
|
-
if (this.type === 9 /* Symbolic */) return 0;
|
|
248
|
-
if (this.type === 10 /* Boolean */) return this.value === true ? 1 : 0;
|
|
249
|
-
if (this._cachedNumber !== void 0) return this._cachedNumber;
|
|
250
|
-
if (typeof this.value === "bigint") {
|
|
251
|
-
this._cachedNumber = Number(this.value);
|
|
252
|
-
return this._cachedNumber;
|
|
253
|
-
}
|
|
254
|
-
const result = parseFloat(this.value);
|
|
255
|
-
this._cachedNumber = isNaN(result) ? 0 : result;
|
|
256
|
-
return this._cachedNumber;
|
|
257
|
-
}
|
|
258
|
-
isNaN() {
|
|
259
|
-
if (this.type === 12 /* Pending */) return false;
|
|
260
|
-
if (this.type === 13 /* Error */) return false;
|
|
261
|
-
if (this.type === 7 /* Matrix */) {
|
|
262
|
-
const m = this.value;
|
|
263
|
-
if (m.rows === 1 && m.cols === 1 && typeof m.data[0] === "number") return isNaN(m.data[0]);
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
-
if (this.type === 8 /* Range */) return false;
|
|
267
|
-
if (this.type === 14 /* Colour */) return false;
|
|
268
|
-
if (this.type === 15 /* Split */) return false;
|
|
269
|
-
if (this.type === 9 /* Symbolic */) return false;
|
|
270
|
-
if (this.type === 10 /* Boolean */) return false;
|
|
271
|
-
if (typeof this.value === "number") return isNaN(this.value);
|
|
272
|
-
if (typeof this.value === "bigint") return false;
|
|
273
|
-
return isNaN(parseFloat(this.value));
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
function numberValue(n) {
|
|
277
|
-
if (_arenaActive && _arena) return _arena.acquire(0 /* Number */, n);
|
|
278
|
-
return new Value(0 /* Number */, n);
|
|
279
|
-
}
|
|
280
|
-
function numberValueExact(n, exact) {
|
|
281
|
-
const v = numberValue(n);
|
|
282
|
-
v.exact = exact;
|
|
283
|
-
return v;
|
|
284
|
-
}
|
|
285
|
-
function numberValueRational(n, rational) {
|
|
286
|
-
const v = numberValue(n);
|
|
287
|
-
v.rational = rational;
|
|
288
|
-
return v;
|
|
289
|
-
}
|
|
290
|
-
function numberValueUncertain(n, uncertainty) {
|
|
291
|
-
const v = numberValue(n);
|
|
292
|
-
v.uncertainty = uncertainty;
|
|
293
|
-
return v;
|
|
294
|
-
}
|
|
295
|
-
function hexValue(n, base = "hex") {
|
|
296
|
-
const tag = base === "hex" ? void 0 : base;
|
|
297
|
-
if (_arenaActive && _arena) return _arena.acquire(1 /* Hex */, n, tag);
|
|
298
|
-
return new Value(1 /* Hex */, n, tag);
|
|
299
|
-
}
|
|
300
|
-
function bigIntValue(n) {
|
|
301
|
-
if (_arenaActive && _arena) return _arena.acquire(2 /* BigInt */, n);
|
|
302
|
-
return new Value(2 /* BigInt */, n);
|
|
303
|
-
}
|
|
304
|
-
function stringValue(s) {
|
|
305
|
-
if (_arenaActive && _arena) return _arena.acquire(3 /* String */, s);
|
|
306
|
-
return new Value(3 /* String */, s);
|
|
307
|
-
}
|
|
308
|
-
function uomValue(n, unit) {
|
|
309
|
-
if (_arenaActive && _arena) return _arena.acquire(6 /* Uom */, n, unit);
|
|
310
|
-
return new Value(6 /* Uom */, n, unit);
|
|
311
|
-
}
|
|
312
|
-
function uomValueExact(n, unit, exact) {
|
|
313
|
-
const v = uomValue(n, unit);
|
|
314
|
-
v.exact = exact;
|
|
315
|
-
return v;
|
|
316
|
-
}
|
|
317
|
-
function rateValue(magnitude, numeratorUnit, denominatorUnit) {
|
|
318
|
-
return uomValue(magnitude, `${numeratorUnit}/${denominatorUnit}`);
|
|
319
|
-
}
|
|
320
|
-
function isRateUnit(unit) {
|
|
321
|
-
return typeof unit === "string" && unit.includes("/");
|
|
322
|
-
}
|
|
323
|
-
function splitRateUnit(unit) {
|
|
324
|
-
const idx = unit.indexOf("/");
|
|
325
|
-
if (idx < 0) {
|
|
326
|
-
throw chunkMIGXCBXT_cjs.ErrorFactory.internal(
|
|
327
|
-
"INVALID_RATE_UNIT",
|
|
328
|
-
`splitRateUnit: "${unit}" is not a rate unit (expected "numerator/denominator")`,
|
|
329
|
-
{ unit }
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
return { numerator: unit.slice(0, idx), denominator: unit.slice(idx + 1) };
|
|
333
|
-
}
|
|
334
|
-
var TIMECODE_UNIT_PREFIX = "timecode@";
|
|
335
|
-
function timecodeUnit(fps) {
|
|
336
|
-
return `${TIMECODE_UNIT_PREFIX}${fps}`;
|
|
337
|
-
}
|
|
338
|
-
function isTimecodeUnit(unit) {
|
|
339
|
-
return typeof unit === "string" && unit.startsWith(TIMECODE_UNIT_PREFIX);
|
|
340
|
-
}
|
|
341
|
-
function timecodeFps(unit) {
|
|
342
|
-
if (!isTimecodeUnit(unit)) {
|
|
343
|
-
throw chunkMIGXCBXT_cjs.ErrorFactory.internal(
|
|
344
|
-
"INVALID_TIMECODE_UNIT",
|
|
345
|
-
`timecodeFps: "${unit}" is not a timecode unit (expected "timecode@<fps>")`,
|
|
346
|
-
{ unit }
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
return parseFloat(unit.slice(TIMECODE_UNIT_PREFIX.length));
|
|
350
|
-
}
|
|
351
|
-
function matrixValue(rows, cols, data) {
|
|
352
|
-
chargeAllocation(data.length, "matrix cells");
|
|
353
|
-
const hasSymbolic = data.some((cell) => typeof cell === "object" && cell !== null && "kind" in cell);
|
|
354
|
-
const m = { rows, cols, data, hasSymbolic };
|
|
355
|
-
if (_arenaActive && _arena) return _arena.acquire(7 /* Matrix */, m);
|
|
356
|
-
return new Value(7 /* Matrix */, m);
|
|
357
|
-
}
|
|
358
|
-
function rowVectorValue(data) {
|
|
359
|
-
return matrixValue(1, data.length, data);
|
|
360
|
-
}
|
|
361
|
-
function colVectorValue(data) {
|
|
362
|
-
return matrixValue(data.length, 1, data);
|
|
363
|
-
}
|
|
364
|
-
function rangeValue(min, max) {
|
|
365
|
-
const r = { min, max };
|
|
366
|
-
if (_arenaActive && _arena) return _arena.acquire(8 /* Range */, r);
|
|
367
|
-
return new Value(8 /* Range */, r);
|
|
368
|
-
}
|
|
369
|
-
function colourValue(c) {
|
|
370
|
-
if (_arenaActive && _arena) return _arena.acquire(14 /* Colour */, c);
|
|
371
|
-
return new Value(14 /* Colour */, c);
|
|
372
|
-
}
|
|
373
|
-
function splitValue(data) {
|
|
374
|
-
if (_arenaActive && _arena) return _arena.acquire(15 /* Split */, data);
|
|
375
|
-
return new Value(15 /* Split */, data);
|
|
376
|
-
}
|
|
377
|
-
function symbolicValue(node) {
|
|
378
|
-
if (_arenaActive && _arena) return _arena.acquire(9 /* Symbolic */, node);
|
|
379
|
-
return new Value(9 /* Symbolic */, node);
|
|
380
|
-
}
|
|
381
|
-
function boolValue(b) {
|
|
382
|
-
if (_arenaActive && _arena) return _arena.acquire(10 /* Boolean */, b);
|
|
383
|
-
return new Value(10 /* Boolean */, b);
|
|
384
|
-
}
|
|
385
|
-
function datetimeValue(n) {
|
|
386
|
-
if (_arenaActive && _arena) return _arena.acquire(4 /* Datetime */, n);
|
|
387
|
-
return new Value(4 /* Datetime */, n);
|
|
388
|
-
}
|
|
389
|
-
function percentageValue(n) {
|
|
390
|
-
if (_arenaActive && _arena) return _arena.acquire(5 /* Percentage */, n);
|
|
391
|
-
return new Value(5 /* Percentage */, n);
|
|
392
|
-
}
|
|
393
|
-
function pendingValue(queryKey) {
|
|
394
|
-
return new Value(12 /* Pending */, queryKey);
|
|
395
|
-
}
|
|
396
|
-
function errorValue(code, message) {
|
|
397
|
-
return new Value(13 /* Error */, code, message);
|
|
398
|
-
}
|
|
399
|
-
function faultedOperand(a, b, c) {
|
|
400
|
-
if (a.type === 13 /* Error */ || a.type === 12 /* Pending */) return a;
|
|
401
|
-
if (b !== void 0 && (b.type === 13 /* Error */ || b.type === 12 /* Pending */)) return b;
|
|
402
|
-
if (c !== void 0 && (c.type === 13 /* Error */ || c.type === 12 /* Pending */)) return c;
|
|
403
|
-
return null;
|
|
404
|
-
}
|
|
405
|
-
function faultedIn(values) {
|
|
406
|
-
for (let i = 0; i < values.length; i++) {
|
|
407
|
-
const v = values[i];
|
|
408
|
-
if (v.type === 13 /* Error */ || v.type === 12 /* Pending */) return v;
|
|
409
|
-
}
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
exports.Value = Value;
|
|
414
|
-
exports.ValueType = ValueType;
|
|
415
|
-
exports.beginEvaluation = beginEvaluation;
|
|
416
|
-
exports.bigIntValue = bigIntValue;
|
|
417
|
-
exports.boolValue = boolValue;
|
|
418
|
-
exports.chargeAllocation = chargeAllocation;
|
|
419
|
-
exports.chargeFunctionCall = chargeFunctionCall;
|
|
420
|
-
exports.checkAllocation = checkAllocation;
|
|
421
|
-
exports.checkedArray = checkedArray;
|
|
422
|
-
exports.colVectorValue = colVectorValue;
|
|
423
|
-
exports.colourValue = colourValue;
|
|
424
|
-
exports.datetimeValue = datetimeValue;
|
|
425
|
-
exports.disableValueArena = disableValueArena;
|
|
426
|
-
exports.enableValueArena = enableValueArena;
|
|
427
|
-
exports.endEvaluation = endEvaluation;
|
|
428
|
-
exports.errorValue = errorValue;
|
|
429
|
-
exports.faultedIn = faultedIn;
|
|
430
|
-
exports.faultedOperand = faultedOperand;
|
|
431
|
-
exports.freezeIfDev = freezeIfDev;
|
|
432
|
-
exports.hexValue = hexValue;
|
|
433
|
-
exports.isArenaActive = isArenaActive;
|
|
434
|
-
exports.isRateUnit = isRateUnit;
|
|
435
|
-
exports.isTimecodeUnit = isTimecodeUnit;
|
|
436
|
-
exports.matrixValue = matrixValue;
|
|
437
|
-
exports.numberValue = numberValue;
|
|
438
|
-
exports.numberValueExact = numberValueExact;
|
|
439
|
-
exports.numberValueRational = numberValueRational;
|
|
440
|
-
exports.numberValueUncertain = numberValueUncertain;
|
|
441
|
-
exports.pendingValue = pendingValue;
|
|
442
|
-
exports.percentageValue = percentageValue;
|
|
443
|
-
exports.persistentValue = persistentValue;
|
|
444
|
-
exports.rangeValue = rangeValue;
|
|
445
|
-
exports.rateValue = rateValue;
|
|
446
|
-
exports.rowVectorValue = rowVectorValue;
|
|
447
|
-
exports.splitRateUnit = splitRateUnit;
|
|
448
|
-
exports.splitValue = splitValue;
|
|
449
|
-
exports.stringValue = stringValue;
|
|
450
|
-
exports.symbolicValue = symbolicValue;
|
|
451
|
-
exports.timecodeFps = timecodeFps;
|
|
452
|
-
exports.timecodeUnit = timecodeUnit;
|
|
453
|
-
exports.uomValue = uomValue;
|
|
454
|
-
exports.uomValueExact = uomValueExact;
|
|
455
|
-
//# sourceMappingURL=chunk-IT74O4BE.cjs.map
|
|
456
|
-
//# sourceMappingURL=chunk-IT74O4BE.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vm/AllocationBudget.ts","../src/vm/Value.ts"],"names":["ErrorFactory","ValueType","v"],"mappings":";;;;;AAwDA,IAAI,KAAA,GAAQ,CAAA;AAGZ,IAAI,IAAA,GAAO,CAAA;AAGX,IAAI,QAAQ,MAAA,CAAO,iBAAA;AAGnB,IAAI,KAAA,GAAQ,CAAA;AAGZ,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AAQO,SAAS,UAAA,CAAW,MAAc,OAAA,EAAwB;AAChE,EAAA,OAAO,IAAI,KAAA,CAAM,EAAA,cAAiB,IAAA,EAAM,OAAO,CAAA;AAChD;AA2BO,SAAS,cAAA,CAAe,CAAA,EAAU,CAAA,EAAW,CAAA,EAAyB;AAC5E,EAAA,IAAI,EAAE,IAAA,KAAS,EAAA,gBAAmB,CAAA,CAAE,IAAA,KAAS,kBAAmB,OAAO,CAAA;AACvE,EAAA,IAAI,CAAA,KAAM,WAAc,CAAA,CAAE,IAAA,KAAS,kBAAmB,CAAA,CAAE,IAAA,KAAS,mBAAoB,OAAO,CAAA;AAC5F,EAAA,IAAI,CAAA,KAAM,WAAc,CAAA,CAAE,IAAA,KAAS,kBAAmB,CAAA,CAAE,IAAA,KAAS,mBAAoB,OAAO,CAAA;AAC5F,EAAA,OAAO,IAAA;AACR;AAQO,SAAS,UAAU,MAAA,EAAwC;AACjE,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,MAAA,CAAO,QAAQ,CAAA,EAAA,EAAK;AACvC,IAAA,MAAM,CAAA,GAAI,OAAO,CAAC,CAAA;AAClB,IAAA,IAAI,EAAE,IAAA,KAAS,EAAA,gBAAmB,CAAA,CAAE,IAAA,KAAS,kBAAmB,OAAO,CAAA;AAAA,EACxE;AACA,EAAA,OAAO,IAAA;AACR","file":"chunk-IT74O4BE.cjs","sourcesContent":["/**\n * The ceiling on how much memory one evaluation is allowed to ask for.\n *\n * The VM's other two counters bound how many opcodes run and how deep the value\n * stack gets, and both are checked BETWEEN opcodes. That leaves a hole the size\n * of a single opcode: whatever one opcode allocates in a loop of its own is\n * invisible to both, so twenty-four characters of input (`map(10*x,\n * 0:2000000000)`) could allocate until V8 aborted the process, which no\n * `try`/`catch` in the host can contain. Per-site caps close one hole each and\n * do not compose: two collections that are individually legal are legal\n * together, and an operation whose result is the PRODUCT of two legal inputs (a\n * matrix multiply) is bounded by neither of them.\n *\n * This is the counter that composes. Everything an evaluation materialises is\n * charged against one running tally, so the bound is on the total rather than\n * on any single step, and a new opcode inherits it by allocating through\n * {@link chargedArray} or by building a Value through a constructor that\n * already charges ({@link matrixValue}).\n *\n * The tally is module state rather than something threaded through every\n * signature. `executeBytecode()` opens an evaluation and every charge inside\n * that window lands on it, which is what lets a helper five call levels down\n * (`vm/MatrixOps.ts`'s `collectionToValues()`) charge without the four frames\n * in between passing a parameter along, and what keeps a charge down to an add\n * and a compare. This mirrors the value arena in `vm/Value.ts`, which is\n * ambient for the same reason and rests on the same fact: `executeBytecode()`\n * is synchronous, so exactly one evaluation is ever in flight in a realm.\n *\n * An \"element\" is one thing a user's input caused to exist: a `Value` in an\n * expanded collection, a cell in a matrix. They are counted rather than\n * measured in bytes, because a count is the quantity every call site already\n * has in hand before it allocates, and asking V8 how big something is costs\n * more than the allocation being guarded.\n *\n * A second tally lives here for the same structural reason and not because it\n * counts the same thing: {@link chargeFunctionCall} bounds how many\n * user-defined-function calls one evaluation may make in total. Surviving\n * reentry is the whole property both need, and this module is where reentry is\n * already tracked.\n *\n * @module AllocationBudget\n */\n\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport type { VM } from \"@solve-js/vm/OpRegistry\";\n\n/**\n * How deep the evaluation is: 0 outside one, higher inside a reentrant call.\n *\n * `executeBytecode()` re-enters itself for a user-defined function call, a map\n * or reduce transform body, and an algebra verb's bound-unknown body. Only the\n * outermost entry clears the tally, so a runaway recursion cannot refresh its\n * own allowance the way it can refresh `maxInstructions` (each reentrant call\n * gets a fresh local instruction count, which is why function recursion needed\n * a separate guard of its own).\n */\nlet depth = 0;\n\n/** Elements charged so far in the evaluation currently in flight. */\nlet used = 0;\n\n/** The in-flight evaluation's ceiling, read from its VM when the evaluation opened. */\nlet limit = Number.POSITIVE_INFINITY;\n\n/** User-defined-function calls made so far in the evaluation currently in flight. */\nlet calls = 0;\n\n/** The in-flight evaluation's call ceiling, read from its VM when the evaluation opened. */\nlet callLimit = Number.POSITIVE_INFINITY;\n\n/**\n * The refusal itself, built in one place so the wording of the engine's most\n * likely \"this is too big\" message is not reinvented per site.\n */\nfunction exceeded(requested: number, what: string, alreadyUsed: number): Error {\n\treturn ErrorFactory.execution({\n\t\tcode: \"ALLOCATION_LIMIT_EXCEEDED\",\n\t\tmessage:\n\t\t\t`Evaluating this expression would materialise ${requested.toLocaleString(\"en-US\")} ${what}, ` +\n\t\t\t`past the limit of ${limit.toLocaleString(\"en-US\")} elements for one evaluation`,\n\t\texpected: `at most ${limit.toLocaleString(\"en-US\")} elements materialised while evaluating one expression`,\n\t\tfound: `a request for ${requested.toLocaleString(\"en-US\")} more ${what}, on top of ${alreadyUsed.toLocaleString(\"en-US\")} already materialised`,\n\t\tsuggestion: \"use a smaller collection or matrix, or raise the engine's vm.maxAllocatedElements setting\",\n\t\tcontext: { requested, what, used: alreadyUsed, limit },\n\t});\n}\n\n/**\n * Open an evaluation, taking its ceiling from the VM about to run it.\n *\n * @param vm - The VM running this program. Only consulted on the outermost\n * entry, so a reentrant call costs one increment.\n */\nexport function beginEvaluation(vm: VM): void {\n\tif (depth++ === 0) {\n\t\tused = 0;\n\t\tlimit = vm.getMaxAllocatedElements();\n\t\tcalls = 0;\n\t\tcallLimit = vm.getMaxFunctionCalls();\n\t}\n}\n\n/** Close the innermost evaluation. Always call from a `finally`, so a throw cannot leave one open. */\nexport function endEvaluation(): void {\n\tif (depth > 0) depth--;\n}\n\n/**\n * Record elements materialised by the evaluation in flight.\n *\n * Each thing is charged exactly once, where it comes into existence: a matrix\n * in `matrixValue()`, an expanded collection where it is expanded. A site that\n * knows a size in advance and whose result will be charged on birth uses\n * {@link checkAllocation} instead, so that refusing early does not mean\n * counting twice.\n *\n * Outside an evaluation this is a plain no-op rather than an error:\n * `matrixValue()` and the `vm/MatrixOps.ts` helpers are exported and get called\n * by tests, by the formatter and by hosts with no evaluation in flight, and\n * none of those is user input being executed.\n *\n * @param count - How many elements now exist.\n * @param what - What they are, in the plural and in a user's words (\"matrix\n * cells\", \"collection elements\"). Quoted verbatim in the error, so it should\n * name the thing rather than the code that makes it.\n * @throws `ALLOCATION_LIMIT_EXCEEDED` when this evaluation has had enough.\n * Recoverable: it describes this expression, not the engine.\n */\nexport function chargeAllocation(count: number, what: string): void {\n\tif (depth === 0) return;\n\t// Written as a negated `>=` so that NaN takes this branch. A NaN count would\n\t// otherwise be added to the tally and make every later `used > limit`\n\t// comparison false, silently switching the guard off for the rest of the\n\t// evaluation, which is the one failure mode a safety limit must not have.\n\tif (!(count >= 0)) throw exceeded(count, what, used);\n\tused += count;\n\tif (used > limit) throw exceeded(count, what, used - count);\n}\n\n/**\n * Refuse an allocation this evaluation cannot afford, without recording it.\n *\n * For the sites that know how big a result will be BEFORE building it and whose\n * result is charged later, when it is born. A matrix product is the case that\n * matters: its size is the product of two operands that are each affordable, so\n * it has to be refused from the shapes alone, before `matrixMultiply()` takes\n * the memory. Charging here as well as at birth would bill every matrix twice\n * and halve the ceiling the host asked for.\n *\n * @param count - How many elements the result would have.\n * @param what - What they are, in the plural. See {@link chargeAllocation}.\n * @throws `ALLOCATION_LIMIT_EXCEEDED` when the evaluation could not afford them.\n */\nexport function checkAllocation(count: number, what: string): void {\n\tif (depth === 0) return;\n\tif (!(count >= 0) || used + count > limit) throw exceeded(count, what, used);\n}\n\n/**\n * Check that an array is affordable, then allocate it.\n *\n * The intended way to build any user-sized array inside the VM whose contents\n * end up inside a Value that charges on birth, so that \"ask before you take\" is\n * a property of the allocator rather than something each new opcode has to be\n * told.\n *\n * @param count - Element count, checked before a single element exists.\n * @param what - What the elements are, in the plural. See {@link chargeAllocation}.\n * @returns An empty array of that length.\n * @throws `ALLOCATION_LIMIT_EXCEEDED` before allocating anything, when the\n * evaluation cannot afford it.\n */\nexport function checkedArray<T>(count: number, what: string): T[] {\n\tcheckAllocation(count, what);\n\treturn new Array<T>(count);\n}\n\n/**\n * Record one user-defined-function call, and refuse the one past the ceiling.\n *\n * Lives in this module rather than in the VM for the single reason the element\n * tally does: it has to survive `executeBytecode()` re-entering itself. A call\n * count kept per invocation would be reset by the very calls it is counting,\n * which is exactly what happens to `maxInstructions` and exactly why counting\n * instructions could never bound this.\n *\n * The thing being bounded is BREADTH, which no existing guard could see.\n * `maxFunctionRecursionDepth` bounds nesting, and a doubling chain\n * (`f22(v) = f21(v) + f21(v)`, twenty-two lines of it) nests only twenty-two\n * deep while making 2,097,152 calls, which was a fatal heap abort in under a\n * second. Depth 22 against a limit of 50 is comfortably legal, and it was.\n *\n * @throws `FUNCTION_CALL_LIMIT_EXCEEDED` when this evaluation has made\n * enough. Recoverable: the engine is fine, this line is not.\n */\nexport function chargeFunctionCall(): void {\n\tif (depth === 0) return;\n\tif (++calls > callLimit) {\n\t\tthrow ErrorFactory.execution({\n\t\t\tcode: \"FUNCTION_CALL_LIMIT_EXCEEDED\",\n\t\t\tmessage:\n\t\t\t\t`Evaluating this expression would make more than ${callLimit.toLocaleString(\"en-US\")} ` +\n\t\t\t\t`user-defined-function calls, which is the limit for one evaluation`,\n\t\t\texpected: `at most ${callLimit.toLocaleString(\"en-US\")} function calls while evaluating one expression`,\n\t\t\tfound: \"a call past that limit, from a chain of functions that each call others more than once\",\n\t\t\tsuggestion: \"check for a function that calls itself (or a chain of them) more times than intended, or raise the engine's vm.maxFunctionCalls setting\",\n\t\t\tcontext: { calls, callLimit },\n\t\t});\n\t}\n}\n\n/**\n * Elements charged so far in the evaluation in flight, or in the one that just\n * finished. For tests and for a host reporting on a refusal.\n *\n * @returns The running tally.\n */\nexport function allocationUsed(): number {\n\treturn used;\n}\n\n/**\n * User-defined-function calls made so far in the evaluation in flight, or in\n * the one that just finished. For tests and for a host reporting on a refusal.\n *\n * @returns The running tally.\n */\nexport function functionCallsUsed(): number {\n\treturn calls;\n}\n\n/**\n * Drop all in-flight evaluation state.\n *\n * For tests that need a known starting point, and as a repair for a host that\n * somehow lost an `endEvaluation()`. Ordinary execution never needs it:\n * `executeBytecode()` pairs its own begin and end in a `finally`, and the\n * outermost begin clears the tally regardless of what came before.\n */\nexport function resetAllocationTracking(): void {\n\tdepth = 0;\n\tused = 0;\n\tlimit = Number.POSITIVE_INFINITY;\n\tcalls = 0;\n\tcallLimit = Number.POSITIVE_INFINITY;\n}\n","import { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { chargeAllocation } from \"@solve-js/vm/AllocationBudget\";\nimport type { SymbolicNode, Rational } from \"@solve-js/symbolic\";\nimport type { DecimalData } from \"@solve-js/decimal\";\n\n/**\n * A single matrix cell. `boolean` covers element-wise comparison results\n * (`[1,6;3,8] < [5,2;7,4]` produces a Matrix of booleans, not numbers). A\n * `SymbolicNode` cell is a free-variable algebraic entry, e.g. `s =\n * [sx,0,0;0,sy,0;0,0,1]` where `sx`/`sy` are never assigned, so those\n * cells store a real `SymbolicNode` (a bare `var` node initially) rather\n * than degrading to `0`. See `MatrixOps.ts`'s `entryToSymbolic()`/\n * `symbolicToEntry()` for the two-way conversion every symbolic-aware\n * matrix op (multiply, inverse, determinant) uses.\n */\nexport type MatrixEntry = number | boolean | SymbolicNode;\n\n/**\n * A general rows×cols matrix, a vector is just a 1×N (row) or N×1 (column)\n * matrix. `data` is COLUMN-MAJOR (`data[row + col*rows]`), matching the\n * spec's own `a[index]` column-major indexing semantics directly (no\n * translation needed for single-index reads). `hasSymbolic` lets every\n * numeric matrix op fast-path the all-numeric case with one boolean check,\n * mirroring `binaryOp()`'s existing Number+Number fast path, computed by\n * `matrixValue()` itself (true the moment any cell is a `SymbolicNode`\n * object rather than a plain number/boolean), not something callers set\n * by hand.\n */\nexport interface MatrixData {\n\treadonly rows: number;\n\treadonly cols: number;\n\treadonly data: readonly MatrixEntry[];\n\treadonly hasSymbolic: boolean;\n}\n\n/** A first-class integer range `min:max`, both bounds inclusive. */\nexport interface RangeData {\n\treadonly min: number;\n\treadonly max: number;\n}\n\n/**\n * How a colour was authored, and therefore how it should display. It never\n * changes the channels: a colour is always stored as canonical sRGB (`r`,`g`,`b`\n * integers 0-255, `a` in 0-1), and `format` only decides whether `formatValue`\n * renders it as `#rrggbb`, `rgb(...)`, `hsl(...)` or a named keyword.\n */\nexport type ColourFormat = \"hex\" | \"rgb\" | \"rgba\" | \"hsl\" | \"hsla\" | \"named\";\n\n/**\n * A colour value. Canonical channels are sRGB (`r`,`g`,`b` are integers 0-255,\n * `a` is 0-1); HSL is never stored, it is derived on demand for display and for\n * hue/saturation/lightness operations, then re-quantised back to RGBA. A\n * `lighten` followed by an equal `darken` returns to within one rounding step of\n * the original (integer channels re-quantise each way), and does not drift on\n * repetition, rather than storing both HSL and RGB and letting them disagree.\n * `format`\n * records the authored/display form; `name` carries the CSS keyword only when\n * `format === \"named\"` (e.g. `\"rebeccapurple\"`). Lives in a {@link Value}'s\n * `value` slot exactly as {@link MatrixData}/{@link RangeData} do.\n */\nexport interface ColourData {\n\treadonly r: number;\n\treadonly g: number;\n\treadonly b: number;\n\treadonly a: number;\n\treadonly format: ColourFormat;\n\treadonly name?: string;\n}\n\n/**\n * One tier of a bill split: an amount and how many people pay it. An even\n * split is a single share; the odd-penny case is two shares (the base amount\n * most people pay, then the base plus a cent that the remaining `count` pay),\n * so the shares always add back to the exact total. `exact` carries the\n * base-ten cents of a currency share so display rounds from the decimal rather\n * than a drifted double, exactly as money does everywhere else.\n */\nexport interface SplitShare {\n\treadonly value: number;\n\treadonly exact?: DecimalData;\n\treadonly count: number;\n}\n\n/**\n * The result of a per-person bill split (`split $180 between 4`). `unit` is the\n * currency code when the amount was money, undefined for a bare number.\n * `shares` is ordered base-first: `shares[0]` is the \"each\" amount, and a\n * second share, when present, is the slightly larger amount the odd penny falls\n * on. Lives in a {@link Value}'s `value` slot exactly as {@link ColourData} and\n * {@link RangeData} do, a display-only payload the formatter renders.\n */\nexport interface SplitData {\n\treadonly unit?: string;\n\treadonly shares: readonly SplitShare[];\n}\n\n/**\n * Discriminated union tag for {@link Value} objects.\n *\n * Determines the runtime type of a Value and how its `value` field should\n * be interpreted. Used by the VM for type-aware dispatch in arithmetic,\n * comparison, and conversion operations.\n */\nexport enum ValueType {\n\t/** Plain 64-bit floating point number (IEEE 754 double) */\n\tNumber = 0,\n\tHex = 1,\n\tBigInt = 2,\n\tString = 3,\n\tDatetime = 4,\n\tPercentage = 5,\n\tUom = 6,\n\t/** General rows×cols matrix (a vector is a 1×N or N×1 matrix). Value is {@link MatrixData}. */\n\tMatrix = 7,\n\t/** A first-class integer range `min:max`, both inclusive. Value is {@link RangeData}. */\n\tRange = 8,\n\t/** A symbolic/algebraic expression tree (free-variable formula, not a concrete number). Value is a `SymbolicNode` (`@solve-js/symbolic`). */\n\tSymbolic = 9,\n\t/** Boolean true/false. Value is `boolean`. */\n\tBoolean = 10,\n\t/** Unit of measurement token (lexer only, not a runtime value). */\n\tUnit = 11,\n\t/** Async result pending resolution. Value stores the queryKey string. */\n\tPending = 12,\n\t/** Plugin-raised error propagated through the DAG. Value stores error code, unit stores message. */\n\tError = 13,\n\t/** A colour (hex/rgb/hsl/named). Value is {@link ColourData}. */\n\tColour = 14,\n\t/** A per-person bill split (`split $180 between 4`). Value is {@link SplitData}. */\n\tSplit = 15,\n}\n\n// ── ValueArena ────────────────────────────────────────────────────────────\n// Phase 5.3: Bump-allocator arena for zero-allocation Value reuse during scroll.\n// Instead of allocating new Value objects per instruction, we pre-allocate a\n// block and bump an index. A single arena.reset() per scroll frame recycles all\n// Values, no per-value release overhead, no GC pressure during 60fps scrolling.\n\n/**\n * Bump-allocator arena for zero-allocation Value reuse during scroll.\n *\n * Instead of allocating new Value objects per instruction, pre-allocates a\n * block and bumps an index. `arena.reset()` per scroll frame recycles all\n * Values, no per-value release overhead, no GC pressure during 60fps scrolling.\n *\n * Only active during Tier 2 scroll execution (ThreeTierEvaluator).\n */\nexport class ValueArena {\n\tprivate arena: Value[] = [];\n\tprivate index: number = 0;\n\t/** The block size to come back down to. Kept so {@link reset} can. */\n\tprivate readonly initialSize: number;\n\n\t/**\n\t * How much more than the last cycle needed the arena may go on holding\n\t * before it gives the difference back, and how much of it it keeps when it\n\t * does.\n\t *\n\t * A bump allocator that grows to serve one expensive line is working as\n\t * intended; one that never comes down is a leak wearing a cache's clothes.\n\t * `map(x*1, 1:100000)` is an ordinary line by every limit the engine has,\n\t * and it took the arena from 512 Values to 300,004, about 24MB that stayed\n\t * live through two forced full collections and through every later `1 + 1`,\n\t * because `acquire()` handles overflow with `push()` and `reset()` only\n\t * zeroed the bump index. The instance is module-level and survives\n\t * `disableValueArena()` on purpose, so that high-water mark was for the\n\t * life of the process.\n\t *\n\t * Keeping twice what the last cycle used, and only shrinking once holding\n\t * four times that, is what stops the release from becoming a different\n\t * performance bug: a steady scroll uses about the same number of Values\n\t * every frame, so it never meets the condition at all, and an alternating\n\t * heavy/light document degrades at worst to allocating the Values it would\n\t * have allocated with no arena in the first place.\n\t */\n\tprivate static readonly SHRINK_WHEN_HOLDING_TIMES = 4;\n\tprivate static readonly KEEP_TIMES = 2;\n\n\t/** Pre-allocate initial block. 512 Values covers ~30-line viewport comfortably. */\n\tconstructor(initialSize: number = 512) {\n\t\tthis.initialSize = initialSize;\n\t\tfor (let i = 0; i < initialSize; i++) {\n\t\t\tthis.arena.push(new Value(ValueType.Number, 0));\n\t\t}\n\t}\n\n\t/** Bump-allocate a recycled Value. Falls back to allocation only for overflow. */\n\tacquire(type: ValueType, value: number | bigint | string | boolean | MatrixData | RangeData | ColourData | SplitData | SymbolicNode, unit?: string): Value {\n\t\tif (this.index < this.arena.length) {\n\t\t\tconst v = this.arena[this.index++];\n\t\t\tv.recycle(type, value, unit);\n\t\t\treturn v;\n\t\t}\n\t\t// Arena overflow, allocate fresh (rare, only for very complex expressions)\n\t\tconst v = new Value(type, value, unit);\n\t\tthis.arena.push(v);\n\t\tthis.index++;\n\t\treturn v;\n\t}\n\n\t/**\n\t * Reset for the next scroll frame, releasing a block the last frame turned\n\t * out not to need.\n\t *\n\t * Still O(1) in the ordinary case: one comparison against what the cycle\n\t * that just ended used, and the truncation only on the frame after an\n\t * unusually expensive one. Reading the usage here rather than at\n\t * `disableValueArena()` is what makes the policy \"the first cycle that does\n\t * not need the block gives it back\", which is the first thing a host does\n\t * after the line that grew it.\n\t */\n\treset(): void {\n\t\tconst usedLastCycle = this.index;\n\t\tthis.index = 0;\n\t\tif (this.arena.length <= this.initialSize) return;\n\t\tif (this.arena.length <= usedLastCycle * ValueArena.SHRINK_WHEN_HOLDING_TIMES) return;\n\t\t// Never below the initial block, and never above what is already held,\n\t\t// so this only ever truncates.\n\t\tthis.arena.length = Math.max(this.initialSize, usedLastCycle * ValueArena.KEEP_TIMES);\n\t}\n\n\t/** Current arena utilization (for diagnostics). */\n\tget usage(): number { return this.index; }\n\tget capacity(): number { return this.arena.length; }\n}\n\n// Module-level arena toggle. Single-threaded JS, so global state is safe.\n// The arena is ONLY active during Tier 2 scroll execution, the ThreeTierEvaluator\n// enables it before evaluating visible lines and disables it after.\n//\n// The arena INSTANCE survives disable(): constructing a ValueArena allocates\n// its whole initial block (512 Values), so dropping it on every disable would\n// pay that allocation cost again on the next enable, more garbage than the\n// arena saves. Instead, an `_arenaActive` flag gates use of the long-lived\n// instance; enable() just resets the bump index.\nlet _arena: ValueArena | null = null;\nlet _arenaActive = false;\n\n/** Enable the Value arena for zero-allocation scroll execution. */\nexport function enableValueArena(size?: number): ValueArena {\n\tif (!_arena) _arena = new ValueArena(size);\n\t_arena.reset();\n\t_arenaActive = true;\n\treturn _arena;\n}\n\n/** Disable the arena (returns to normal GC-collected allocation). */\nexport function disableValueArena(): void {\n\t_arenaActive = false;\n}\n\n/** Check if arena is active (used by STORE_VAR / HALT to decide cloning). */\nexport function isArenaActive(): boolean {\n\treturn _arenaActive;\n}\n\n/**\n * Allocate a Value that persists beyond the current arena cycle.\n * Used for values stored in variables (STORE_VAR) and final expression results\n * (HALT return), these must survive arena.reset() in the next scroll frame.\n */\nexport function persistentValue(v: Value): Value {\n\tconst p = new Value(v.type, v.value, v.unit);\n\t// The exact sidecar has to survive being stored in a variable, or a\n\t// referenced money value would silently drop back to the double: \"a = $0.10,\n\t// b = $0.20, a + b\" must still be exact across the STORE_VAR round trip.\n\tif (v.exact !== undefined) p.exact = v.exact;\n\t// The rational sidecar survives the same round trip, so \"a = 1/3, a + a + a\"\n\t// is exactly 1 rather than the drifted double a stored fraction would carry.\n\tif (v.rational !== undefined) p.rational = v.rational;\n\t// The uncertainty sidecar survives too, so \"a = 12.3 +/- 0.5, a * 4\" still\n\t// propagates the tolerance across the STORE_VAR round trip.\n\tif (v.uncertainty !== undefined) p.uncertainty = v.uncertainty;\n\treturn p;\n}\n\n// ── Dev-mode immutability guard (Part II, L5, Value model hardening) ──\n//\n// Value is documented immutable by convention, not enforcement: the arena\n// mutates objects in place via recycle() (by design, for Tier-2 scroll\n// performance), so Value can never be unconditionally frozen. This guard\n// freezes a Value ONLY when it is safe to do so, i.e. NOT while the arena\n// is active, since an arena-active Value may still be recycled later in\n// the same scroll frame. It is a no-op outside development builds (matches\n// the existing `process.env.NODE_ENV === \"development\"` convention used by\n// the app-layer logger) so there is zero runtime cost in production.\nconst isDevelopmentBuild = process.env.NODE_ENV === \"development\";\n\n/**\n * Freeze a Value in development builds, catching accidental external\n * mutation of \"immutable\" results early. Safe to call unconditionally\n * it is a no-op in production and a no-op whenever the arena is active\n * (an arena-active Value may still be recycle()'d before this scroll\n * frame ends, and freezing it would make recycle() throw).\n *\n * Intended for values leaving a public evaluation boundary\n * (ExpressionEngine.evaluateLine* / evaluateExpression), not for values\n * still moving through internal VM/arena machinery.\n */\nexport function freezeIfDev<T extends Value>(value: T): T {\n\tif (isDevelopmentBuild && !isArenaActive()) {\n\t\t// toNumber() lazily memoizes _cachedNumber for bigint/string values\n\t\t// (Number/Hex are already eagerly cached by the constructor), warm\n\t\t// it now so a later toNumber() call on the frozen object doesn't\n\t\t// try to write to a frozen field.\n\t\tvalue.toNumber();\n\t\tObject.freeze(value);\n\t}\n\treturn value;\n}\n\n/**\n * Universal runtime value for the solve-js VM.\n *\n * Carries a {@link ValueType} discriminant, a polymorphic `value` payload,\n * and an optional `unit` string (for UoM values). Treated as immutable after\n * construction, the arena reuses objects internally via `recycle()`, but\n * external code should never mutate Value fields.\n *\n * A cached `_cachedNumber` avoids repeated `toNumber()` computation on\n * hot paths (ADD/SUB/MUL in the VM dispatch loop).\n */\nexport class Value {\n\t// Cached numeric representation, computed once on first toNumber() call.\n\t// Cleared on recycle() when the arena reuses this Value for a new value.\n\tprivate _cachedNumber: number | undefined;\n\n\t// Fields are NOT readonly, the arena reuses Value objects by calling\n\t// recycle() which overwrites all fields. External code should treat Values\n\t// as immutable after construction (arena handles mutation internally).\n\tpublic type: ValueType;\n\tpublic value: number | bigint | string | boolean | MatrixData | RangeData | ColourData | SplitData | SymbolicNode;\n\tpublic unit?: string;\n\t/** Set by async resolvers when a fetch timed out, the result is a fallback (typically 0). */\n\tpublic timedOut?: boolean;\n\t/**\n\t * The exact base-ten value this Value stands for, when it has one.\n\t *\n\t * A sidecar rather than a replacement for `value`: money and decimal-point\n\t * literals set it to a {@link DecimalData} so that same-currency arithmetic\n\t * and display can be exact (\"$0.10 + $0.20\" is \"$0.30\", not\n\t * \"$0.30000000000000004\"), while `value` stays the nearest double so every\n\t * existing consumer that reads `.value` or `toNumber()` is unchanged. The\n\t * plain Number-times-Number fast paths deliberately ignore it, which is why\n\t * a bare \"0.1 + 0.2\" still answers the double it always did: exactness is\n\t * carried only where a unit-bearing operand asks for it. Cleared by\n\t * {@link recycle} so a reused arena Value never inherits a stale exact.\n\t */\n\tpublic exact?: DecimalData;\n\t/**\n\t * The exact rational value this Value stands for, when it has one.\n\t *\n\t * The second sidecar, the same shape as {@link exact} and for the same\n\t * reason: a fraction has no exact base-ten form (`1/3` is not any decimal),\n\t * so exact fraction arithmetic needs a numerator/denominator pair rather\n\t * than a coefficient and a scale. Integer division seeds it (\"1/3\" carries\n\t * the {@link Rational} 1/3), and `+`, `-`, `*`, `/` between rational-bearing\n\t * numbers keep it reduced, so \"1/49 * 49\" is exactly 1 and \"5/6 - 1/6 - 1/6\n\t * - 1/6 - 1/6 - 1/6\" is exactly 0 rather than the 1.6e-16 the doubles drift\n\t * to. `value` still holds the nearest double, recomputed from the exact\n\t * rational so accumulation error never creeps in, which is why the default\n\t * display and every `.value`/`toNumber()` reader are unchanged. Only a\n\t * fraction written with \"/\" carries it, so a decimal literal (\"0.1\") and a\n\t * transcendental result (\"sqrt(2)\") stay the plain doubles they were.\n\t * Cleared by {@link recycle} alongside {@link exact}.\n\t */\n\tpublic rational?: Rational;\n\t/**\n\t * The one-sigma uncertainty (standard error) this value carries, when it\n\t * has one.\n\t *\n\t * The third sidecar, the same shape as {@link exact} and {@link rational}\n\t * and for the same reason: a measurement written `12.3 ± 0.5` is still the\n\t * number 12.3 everywhere it is read as one, so the type stays\n\t * {@link ValueType.Number} and `value` stays the center, while this non\n\t * negative field carries the tolerance. The `±` (or ASCII `+/-`) operator\n\t * seeds it, and `+`, `-`, `*`, `/` propagate it in quadrature for\n\t * independent errors (see `vm/VMConversion.ts`'s `uncertainOp`). Everything\n\t * else (a comparison, a transcendental function, a unit conversion) reads\n\t * the center through `toNumber()` and drops the tolerance, which is why a\n\t * value with no uncertainty behaves exactly as a plain number always did.\n\t * Cleared by {@link recycle} alongside the other two sidecars.\n\t */\n\tpublic uncertainty?: number;\n\t/**\n\t * The number of decimal places this value should DISPLAY at, when it has been\n\t * given an explicit precision.\n\t *\n\t * A display sidecar, not a value one: `value` is unchanged, so every\n\t * `.value`/`toNumber()` reader and all arithmetic behave exactly as before,\n\t * and a value with no `decimalPlaces` formats the way it always did (the\n\t * global two-place default with trailing zeros trimmed). It is set only by an\n\t * explicit precision request, `<x> to N dp` and `round(x, N)`, so that\n\t * `3.14159 to 4 dp` shows `3.1416` and `1.5 to 2 dp` shows `1.50` rather than\n\t * the value being rounded but then displayed at the default two places. It is\n\t * NOT propagated through arithmetic (a later `+ 1` re-decides precision),\n\t * which is why nothing that did not ask for a precision is affected. Cleared\n\t * by {@link recycle} alongside the other sidecars.\n\t */\n\tpublic decimalPlaces?: number;\n\n\tconstructor(\n\t\ttype: ValueType,\n\t\tvalue: number | bigint | string | boolean | MatrixData | RangeData | ColourData | SplitData | SymbolicNode,\n\t\tunit?: string\n\t) {\n\t\tthis.type = type;\n\t\tthis.value = value;\n\t\tthis.unit = unit;\n\t\t// Eagerly cache for Number and Hex types (the most common case).\n\t\t// This avoids a method call + type-check on first toNumber().\n\t\tif (typeof value === 'number') {\n\t\t\tthis._cachedNumber = value;\n\t\t}\n\t}\n\n\t/**\n\t * Phase 5.3: Reset all fields for arena reuse.\n\t * Called by ValueArena.acquire(), zero allocation, just field assignment.\n\t */\n\trecycle(type: ValueType, value: number | bigint | string | boolean | MatrixData | RangeData | ColourData | SplitData | SymbolicNode, unit?: string): void {\n\t\tthis.type = type;\n\t\tthis.value = value;\n\t\tthis.unit = unit;\n\t\t// Clear cache, value changed, cached number is stale.\n\t\t// Re-eager-cache for Number type (most common).\n\t\tthis._cachedNumber = typeof value === 'number' ? value : undefined;\n\t\t// Clear timeout flag, recycled Values shouldn't inherit stale metadata.\n\t\tthis.timedOut = undefined;\n\t\t// Clear the exact sidecar for the same reason: a reused Value that once\n\t\t// held money must not carry that money's decimal into a plain number.\n\t\tthis.exact = undefined;\n\t\t// The rational sidecar clears with it: a reused Value that once held a\n\t\t// fraction must not carry that fraction into a plain number.\n\t\tthis.rational = undefined;\n\t\t// The uncertainty sidecar clears the same way: a reused Value that once\n\t\t// carried a tolerance must not lend it to a plain number.\n\t\tthis.uncertainty = undefined;\n\t\t// The display-precision sidecar clears too: a reused Value that once had\n\t\t// an explicit `to N dp` must not display a plain number at that precision.\n\t\tthis.decimalPlaces = undefined;\n\t}\n\n\tisNumber(): this is Value & { value: number } {\n\t\treturn this.type === ValueType.Number;\n\t}\n\n\tisHex(): this is Value & { value: number } {\n\t\treturn this.type === ValueType.Hex;\n\t}\n\n\tisBigInt(): this is Value & { value: bigint } {\n\t\treturn this.type === ValueType.BigInt;\n\t}\n\n\tisString(): this is Value & { value: string } {\n\t\treturn this.type === ValueType.String;\n\t}\n\n\tisMatrix(): this is Value & { value: MatrixData } {\n\t\treturn this.type === ValueType.Matrix;\n\t}\n\n\t/** A Matrix shaped like a vector, 1×N (row) or N×1 (column). */\n\tisVectorShape(): boolean {\n\t\tif (this.type !== ValueType.Matrix) return false;\n\t\tconst m = this.value as MatrixData;\n\t\treturn m.rows === 1 || m.cols === 1;\n\t}\n\n\tisRange(): this is Value & { value: RangeData } {\n\t\treturn this.type === ValueType.Range;\n\t}\n\n\tisColour(): this is Value & { value: ColourData } {\n\t\treturn this.type === ValueType.Colour;\n\t}\n\n\tisSymbolic(): this is Value & { value: SymbolicNode } {\n\t\treturn this.type === ValueType.Symbolic;\n\t}\n\n\ttoNumber(): number {\n\t\t// Pending/Error have no numeric representation at all, 0 (established\n\t\t// convention). A genuinely multi-cell Matrix has no single numeric\n\t\t// representation either (real callers branch on `.isMatrix()` BEFORE\n\t\t// reaching this fallback. See e.g. VM.ts's MUL/comparison dispatch)\n\t\t// but a 1x1 Matrix, the shape `float(x)`'s legacy sugar produces, see\n\t\t// packages/vector/parselets/FloatParselet.ts, IS a scalar in every\n\t\t// meaningful sense, so it degrades to that single cell's numeric value\n\t\t// rather than 0 (this exact case used to work \"by accident\" pre-Matrix,\n\t\t// since `parseFloat([2].toString())` happened to yield `2`).\n\t\tif (this.type === ValueType.Pending) return 0;\n\t\tif (this.type === ValueType.Error) return 0;\n\t\tif (this.type === ValueType.Matrix) {\n\t\t\tconst m = this.value as MatrixData;\n\t\t\tif (m.rows === 1 && m.cols === 1 && typeof m.data[0] === \"number\") return m.data[0];\n\t\t\treturn 0;\n\t\t}\n\t\tif (this.type === ValueType.Range) return 0;\n\t\t// A colour is a struct of channels, not a scalar; like Matrix/Range it has\n\t\t// no single numeric reading. Callers branch on `.isColour()` first.\n\t\tif (this.type === ValueType.Colour) return 0;\n\t\t// A split is a structured multi-share result; its scalar reading is the\n\t\t// \"each\" (base) share, so a numeric consumer or the worker DTO's number\n\t\t// field still gets a sensible value where a caller does not branch first.\n\t\tif (this.type === ValueType.Split) return (this.value as SplitData).shares[0].value;\n\t\t// A symbolic expression has no single concrete numeric value by\n\t\t// definition (it's a free-variable formula), 0, matching the\n\t\t// Pending/Error/Range convention. Real callers branch on\n\t\t// `.isSymbolic()` BEFORE reaching this fallback (see\n\t\t// `VMConversion.ts`'s `binaryOp()`).\n\t\tif (this.type === ValueType.Symbolic) return 0;\n\t\t// A boolean has an obvious numeric reading and no branch used to give it\n\t\t// one, so it fell through to `parseFloat(true)` -> NaN -> 0, and BOTH\n\t\t// booleans read as zero: `true == false` answered true, and every\n\t\t// arithmetic path that mixes a boolean with a number (\"true and 5\")\n\t\t// contributed nothing. 1/0 is the reading every language with a numeric\n\t\t// boolean coercion uses, and the one `if 1 then` already implies.\n\t\tif (this.type === ValueType.Boolean) return this.value === true ? 1 : 0;\n\n\t\tif (this._cachedNumber !== undefined) return this._cachedNumber;\n\n\t\tif (typeof this.value === 'bigint') {\n\t\t\tthis._cachedNumber = Number(this.value);\n\t\t\treturn this._cachedNumber;\n\t\t}\n\t\t// Prevent silent NaN propagation from non-numeric strings\n\t\tconst result = parseFloat(this.value as string);\n\t\tthis._cachedNumber = isNaN(result) ? 0 : result;\n\t\treturn this._cachedNumber;\n\t}\n\n\tisNaN(): boolean {\n\t\tif (this.type === ValueType.Pending) return false;\n\t\tif (this.type === ValueType.Error) return false;\n\t\tif (this.type === ValueType.Matrix) {\n\t\t\tconst m = this.value as MatrixData;\n\t\t\tif (m.rows === 1 && m.cols === 1 && typeof m.data[0] === \"number\") return isNaN(m.data[0]);\n\t\t\treturn false;\n\t\t}\n\t\tif (this.type === ValueType.Range) return false;\n\t\tif (this.type === ValueType.Colour) return false;\n\t\tif (this.type === ValueType.Split) return false;\n\t\tif (this.type === ValueType.Symbolic) return false;\n\t\t// Matches toNumber()'s boolean reading above. Without this a Boolean\n\t\t// reached the string branch at the bottom and `parseFloat(true)` made\n\t\t// every boolean report itself as NaN.\n\t\tif (this.type === ValueType.Boolean) return false;\n\t\tif (typeof this.value === 'number') return isNaN(this.value);\n\t\tif (typeof this.value === 'bigint') return false;\n\t\treturn isNaN(parseFloat(this.value as string));\n\t}\n}\n\n/**\n * Create a Number-typed Value. Uses the arena when active for zero-allocation.\n * This is the most common factory, over 90% of all Value creations.\n */\nexport function numberValue(n: number): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Number, n);\n\treturn new Value(ValueType.Number, n);\n}\n\n/**\n * A Number that also carries the exact decimal it was written as.\n *\n * The type stays {@link ValueType.Number} and `value` stays the nearest double,\n * so this Value behaves exactly like any other number everywhere it is read as\n * one. The `exact` sidecar only matters when it later meets a currency: that is\n * what lets \"$0.70 * 1.10\" be exact while \"0.1 + 0.2\" stays the double it was.\n * Decimal-point literals are compiled to this (see the PUSH_DECIMAL opcode).\n */\nexport function numberValueExact(n: number, exact: DecimalData): Value {\n\tconst v = numberValue(n);\n\tv.exact = exact;\n\treturn v;\n}\n\n/**\n * A Number that also carries the exact rational it evaluates to.\n *\n * The rational counterpart of {@link numberValueExact}: the type stays\n * {@link ValueType.Number} and `value` stays the nearest double (recomputed\n * from the rational, so a chain of fraction operations never accumulates\n * float error), so this reads as an ordinary number everywhere. The `rational`\n * sidecar is what keeps the next fraction operation and any `as fraction`\n * exact. Integer division produces this (see the DIV opcode).\n */\nexport function numberValueRational(n: number, rational: Rational): Value {\n\tconst v = numberValue(n);\n\tv.rational = rational;\n\treturn v;\n}\n\n/**\n * A Number that also carries a one-sigma uncertainty (standard error).\n *\n * The uncertainty counterpart of {@link numberValueExact}: the type stays\n * {@link ValueType.Number} and `value` stays the center, so this reads as an\n * ordinary number everywhere. The `uncertainty` sidecar is what lets `+`, `-`,\n * `*`, `/` propagate the tolerance in quadrature. The `±` operator produces\n * this (see the MAKE_UNCERTAIN opcode), as does any of those four ops when an\n * operand already carries one. The magnitude is stored as given, callers pass a\n * non-negative value (`Math.abs` at the seam, quadrature results are already\n * non-negative).\n */\nexport function numberValueUncertain(n: number, uncertainty: number): Value {\n\tconst v = numberValue(n);\n\tv.uncertainty = uncertainty;\n\treturn v;\n}\n\n/** Which base a {@link ValueType.Hex} value is displayed in. */\nexport type DisplayBase = \"hex\" | \"bin\" | \"oct\";\n\n/**\n * Create a Hex-typed Value: a **number** that displays in another base.\n *\n * The type is numeric on purpose, and that is the whole point of it. A base is\n * a way of writing a quantity, not a different kind of quantity, so `0xFF + 1`\n * has to be 256. Returning a string instead makes it 1, because a string reads\n * as zero in arithmetic, and nothing about that failure is visible at the point\n * of use.\n *\n * @param n - The number itself, in full precision. A `bigint` is accepted for\n * the same reason the type is numeric at all: `12345678901234567890n as hex`\n * has an exact answer, and forcing it through a double first rendered\n * 0xAB54A98CEB1F0800 for a value ending 0AD2.\n * @param base - How to display it, defaulting to hexadecimal. Carried in the\n * `unit` slot, which is free for this type.\n */\nexport function hexValue(n: number | bigint, base: DisplayBase = \"hex\"): Value {\n\tconst tag = base === \"hex\" ? undefined : base;\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Hex, n, tag);\n\treturn new Value(ValueType.Hex, n, tag);\n}\n\n/** Create a BigInt-typed Value (arbitrary-precision integer). */\nexport function bigIntValue(n: bigint): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.BigInt, n);\n\treturn new Value(ValueType.BigInt, n);\n}\n\n/** Create a String-typed Value. */\nexport function stringValue(s: string): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.String, s);\n\treturn new Value(ValueType.String, s);\n}\n\n/** Create a Unit-of-Measurement Value (typed number with unit annotation). */\nexport function uomValue(n: number, unit: string): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Uom, n, unit);\n\treturn new Value(ValueType.Uom, n, unit);\n}\n\n/**\n * A unit-of-measurement Value that also carries an exact decimal magnitude.\n *\n * This is how money keeps its precision: `value` is the nearest double (so\n * `toNumber()` and every existing Uom path are unchanged), and `exact` is the\n * decimal the amount really is. Same-currency arithmetic reads `exact` to stay\n * exact, and the formatter reads it to round a half-cent the way a ledger does\n * rather than the way `toFixed` does on a double.\n */\nexport function uomValueExact(n: number, unit: string, exact: DecimalData): Value {\n\tconst v = uomValue(n, unit);\n\tv.exact = exact;\n\treturn v;\n}\n\n// ── Rate, \"quantity per unit of something\" (SoulverCore: `$99/week`\n// `3 hours/day`, `30 fps`). Represented as a `ValueType.Uom` (no new\n// ValueType, a rate IS a unit-of-measurement, just a compound one) whose\n// `unit` string is `\"<numerator>/<denominator>\"`. The numerator is an\n// opaque label (may be a real convertible unit like \"USD\"/\"km\", or a bare\n// tag like \"frames\" that the `convert` package doesn't know about, rate\n// arithmetic never needs to convert the numerator, only compare it for\n// equality when combining two rates). The denominator MUST be a unit\n// `convertUnit()`/`getMeasure()` (uom/UomConverter.ts) recognizes, since\n// that's the part rate arithmetic actually rescales. See `vm/VM.ts`'s\n// `RATE_CONVERT`/`RATE_MUL`/`RATE_DIV` opcodes for the operations built on\n// this representation.\n\n/** Create a Rate value: `magnitude` of `numeratorUnit` per one `denominatorUnit`. */\nexport function rateValue(magnitude: number, numeratorUnit: string, denominatorUnit: string): Value {\n\treturn uomValue(magnitude, `${numeratorUnit}/${denominatorUnit}`);\n}\n\n/** Whether `unit` is a compound rate unit (`\"X/Y\"`) rather than a plain unit. */\nexport function isRateUnit(unit: string | undefined): unit is string {\n\treturn typeof unit === \"string\" && unit.includes(\"/\");\n}\n\n/**\n * Split a rate unit string into its numerator/denominator halves.\n * @throws if `unit` isn't a rate unit, check with {@link isRateUnit} first.\n */\nexport function splitRateUnit(unit: string): { numerator: string; denominator: string } {\n\tconst idx = unit.indexOf(\"/\");\n\tif (idx < 0) {\n\t\tthrow ErrorFactory.internal(\n\t\t\t\"INVALID_RATE_UNIT\",\n\t\t\t`splitRateUnit: \"${unit}\" is not a rate unit (expected \"numerator/denominator\")`,\n\t\t\t{ unit },\n\t\t);\n\t}\n\treturn { numerator: unit.slice(0, idx), denominator: unit.slice(idx + 1) };\n}\n\n/** Join a numerator/denominator pair back into a rate unit string. */\nexport function joinRateUnit(numeratorUnit: string, denominatorUnit: string): string {\n\treturn `${numeratorUnit}/${denominatorUnit}`;\n}\n\n// ── Video timecode, \"HH:MM:SS:FF at a given fps\" (SoulverCore: video\n// editing timecode literals, e.g. `01:02:03:04 at 30fps`). Represented the\n// same way Rate is above: NOT a new ValueType, just a `ValueType.Uom` whose\n// `unit` string is `\"timecode@<fps>\"` and whose numeric `value` is the\n// TOTAL FRAME COUNT since 00:00:00:00 at that fps, e.g. \"00:00:01:00 at\n// 30fps\" is `Uom(30, \"timecode@30\")`.\n//\n// Storing the total frame count (rather than four separate H/M/S/F fields)\n// means ordinary integer addition/subtraction on the numeric value is\n// ALREADY correct carry/borrow-aware arithmetic with zero extra logic\n// e.g. \"frame 29 + 2 frames\" at 30fps is just `29 + 2 = 31`, and 31 total\n// frames at 30fps IS frame 1 of the next second, with no explicit carry\n// step required. Carry/borrow only needs to be reconstructed when\n// converting a total frame count back into HH:MM:SS:FF display notation\n// see `packages/time/timecode/TimecodeMath.ts`'s `framesToTimecodeString()`.\n// See `vm/VM.ts`'s ADD/SUB dispatch for the arithmetic built on this\n// representation (timecode + frames, + duration, + timecode, - timecode).\n\nconst TIMECODE_UNIT_PREFIX = \"timecode@\";\n\n/** Build a timecode Uom unit string embedding its frame rate, e.g. `timecodeUnit(30)` -> `\"timecode@30\"`. */\nexport function timecodeUnit(fps: number): string {\n\treturn `${TIMECODE_UNIT_PREFIX}${fps}`;\n}\n\n/** Whether `unit` is a compound video-timecode unit (`\"timecode@<fps>\"`). */\nexport function isTimecodeUnit(unit: string | undefined): unit is string {\n\treturn typeof unit === \"string\" && unit.startsWith(TIMECODE_UNIT_PREFIX);\n}\n\n/**\n * Extract the fps from a timecode unit string.\n * @throws if `unit` isn't a timecode unit, check with {@link isTimecodeUnit} first.\n */\nexport function timecodeFps(unit: string): number {\n\tif (!isTimecodeUnit(unit)) {\n\t\tthrow ErrorFactory.internal(\n\t\t\t\"INVALID_TIMECODE_UNIT\",\n\t\t\t`timecodeFps: \"${unit}\" is not a timecode unit (expected \"timecode@<fps>\")`,\n\t\t\t{ unit },\n\t\t);\n\t}\n\treturn parseFloat(unit.slice(TIMECODE_UNIT_PREFIX.length));\n}\n\n/**\n * Create a Matrix value from an explicit shape + column-major data array.\n * `data.length` must equal `rows*cols`, callers building a matrix from\n * row-major source syntax (e.g. the `[1,2;3,4]` literal) must transpose\n * into column-major order before calling this; see `MatrixOps.ts`'s\n * `rowMajorToColumnMajor()`.\n */\nexport function matrixValue(rows: number, cols: number, data: readonly MatrixEntry[]): Value {\n\t// Every matrix in the engine is born here, which makes this the one place\n\t// that can charge for one without each producer having to remember to. The\n\t// charge lands after `data` exists, so it is a backstop rather than a\n\t// refusal: it cannot stop a single allocation that is already fatal (the\n\t// sites whose size is knowable in advance charge before allocating, see\n\t// `vm/VM.ts`'s matrix cases), but it does stop the second one, and it means\n\t// an opcode added later inherits the bound without being told about it.\n\t// Free in relative terms: the hasSymbolic scan just below is already O(n)\n\t// over the same cells.\n\tchargeAllocation(data.length, \"matrix cells\");\n\t// A SymbolicNode cell is the only object-typed MatrixEntry variant\n\t// (number/boolean are primitives), a cheap, always-correct way to\n\t// derive hasSymbolic without asking every caller to track it by hand.\n\t// The `\"kind\" in cell` half is a tripwire, not redundancy. MatrixEntry is\n\t// `number | boolean | SymbolicNode`, so an object cell should always be a\n\t// node; requiring the discriminant means a Rational that escaped\n\t// MatrixOps.ts's symbolicToEntry() shows up as a wrong result rather than as\n\t// a matrix that silently believes it is symbolic.\n\tconst hasSymbolic = data.some(cell => typeof cell === \"object\" && cell !== null && \"kind\" in cell);\n\tconst m: MatrixData = { rows, cols, data, hasSymbolic };\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Matrix, m);\n\treturn new Value(ValueType.Matrix, m);\n}\n\n/** A 1×N row-vector Matrix, row-major and column-major storage are identical for a single row. */\nexport function rowVectorValue(data: readonly number[]): Value {\n\treturn matrixValue(1, data.length, data);\n}\n\n/** An N×1 column-vector Matrix, row-major and column-major storage are identical for a single column. */\nexport function colVectorValue(data: readonly number[]): Value {\n\treturn matrixValue(data.length, 1, data);\n}\n\n/** Create a Range value, a first-class integer range `min:max`, both bounds inclusive. */\nexport function rangeValue(min: number, max: number): Value {\n\tconst r: RangeData = { min, max };\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Range, r);\n\treturn new Value(ValueType.Range, r);\n}\n\n/**\n * Create a Colour value from canonical sRGB channels plus a display format.\n * Arena-backed like the other synchronous factories; the `ColourData` struct in\n * the `value` slot is immutable, so arena recycle is safe with no extra clearing\n * (matching {@link matrixValue}/{@link rangeValue}).\n */\nexport function colourValue(c: ColourData): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Colour, c);\n\treturn new Value(ValueType.Colour, c);\n}\n\n/**\n * Create a Split value from its structured per-share payload. Arena-backed like\n * the other synchronous factories; the {@link SplitData} struct in the `value`\n * slot is immutable, so arena recycle is safe with no extra clearing (matching\n * {@link colourValue}/{@link rangeValue}).\n */\nexport function splitValue(data: SplitData): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Split, data);\n\treturn new Value(ValueType.Split, data);\n}\n\n/** Create a Symbolic value, a free-variable algebraic expression tree (`symbolic/SymbolicNode.ts`'s `SymbolicNode`), not a concrete number. */\nexport function symbolicValue(node: SymbolicNode): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Symbolic, node);\n\treturn new Value(ValueType.Symbolic, node);\n}\n\n\n\n/** Create a Boolean-typed Value. */\nexport function boolValue(b: boolean): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Boolean, b);\n\treturn new Value(ValueType.Boolean, b);\n}\n\n/** Create a Datetime-typed Value (Unix timestamp in milliseconds). */\nexport function datetimeValue(n: number): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Datetime, n);\n\treturn new Value(ValueType.Datetime, n);\n}\n\n/** Create a Percentage-typed Value (stored as fraction, e.g. 0.5 for 50%). */\nexport function percentageValue(n: number): Value {\n\tif (_arenaActive && _arena) return _arena.acquire(ValueType.Percentage, n);\n\treturn new Value(ValueType.Percentage, n);\n}\n\n/**\n * Create a Pending value, signals that an async result is not yet resolved.\n * The value field stores the queryKey string for deduplication and diagnostics.\n * Pending values should NEVER be stored in the arena (they persist across\n * scroll frames until resolution completes).\n */\nexport function pendingValue(queryKey: string): Value {\n\treturn new Value(ValueType.Pending, queryKey);\n}\n\n/**\n * Create an Error value, propagated through the DAG when a plugin raises an error.\n * The value field stores the EngineError code, unit stores the message.\n * Downstream consumers (lines that depend on errored data) bubble this up.\n * Should NEVER be stored in the arena.\n */\nexport function errorValue(code: string, message: string): Value {\n\treturn new Value(ValueType.Error, code, message);\n}\n\n/**\n * The first operand carrying a fault rather than a quantity, if any does.\n *\n * `Error` and `Pending` both read as the number 0 through {@link Value.toNumber},\n * by a convention that only holds up as long as nothing asks. Every opcode and\n * builtin that reaches for an operand's number without asking its type first\n * therefore computes with a zero it cannot tell apart from a real one, and\n * hands back an answer dressed in whatever type it was going to produce\n * anyway. That is how `(5 kg to m) to s` came to answer `0.00 s`: the failed\n * conversion is an Error, the second conversion read it as zero, and the unit\n * the reader asked for made the result look like a conversion that worked.\n *\n * Operands are checked left to right, matching evaluation order, and the\n * faulted Value is returned AS IT IS rather than replaced with a fresh one, so\n * the original code and message (or the pending query key) reach the caller\n * unchanged. `binaryOp` (vm/VMConversion.ts) and `OpCode.EXP` already did this\n * inline; this is the same rule for every other site, in one place so a site\n * added later can adopt it in a line.\n *\n * Three operands cover every call site in the VM (`MAT_INDEX2` and `MAT_SLICE`\n * are the widest). A variadic signature would allocate an arguments array on\n * paths that run per instruction; see {@link faultedIn} for the list case.\n *\n * @returns The faulted operand, or `null` when all of them carry a value.\n */\nexport function faultedOperand(a: Value, b?: Value, c?: Value): Value | null {\n\tif (a.type === ValueType.Error || a.type === ValueType.Pending) return a;\n\tif (b !== undefined && (b.type === ValueType.Error || b.type === ValueType.Pending)) return b;\n\tif (c !== undefined && (c.type === ValueType.Error || c.type === ValueType.Pending)) return c;\n\treturn null;\n}\n\n/**\n * {@link faultedOperand} over an already-built list, for the call sites that\n * have one (a builtin's arguments, a plugin function's).\n *\n * @returns The first faulted element, or `null` when every element carries a value.\n */\nexport function faultedIn(values: readonly Value[]): Value | null {\n\tfor (let i = 0; i < values.length; i++) {\n\t\tconst v = values[i];\n\t\tif (v.type === ValueType.Error || v.type === ValueType.Pending) return v;\n\t}\n\treturn null;\n}\n"]}
|