solve-engine 1.0.0-beta.0 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/dist/BytecodeBuilder-3egMyuDi.d.cts +274 -0
  2. package/dist/BytecodeBuilder-3egMyuDi.d.ts +274 -0
  3. package/dist/Configuration-fVpd-HC-.d.cts +228 -0
  4. package/dist/Configuration-fVpd-HC-.d.ts +228 -0
  5. package/dist/EngineError-DvPSnhZi.d.cts +304 -0
  6. package/dist/EngineError-DvPSnhZi.d.ts +304 -0
  7. package/dist/Lexer-BJdhlnej.d.cts +531 -0
  8. package/dist/Lexer-D9l4Yrk2.d.ts +531 -0
  9. package/dist/NormalizerRule-BrVoVjmP.d.cts +163 -0
  10. package/dist/NormalizerRule-CEjf1FyD.d.ts +163 -0
  11. package/dist/PackageRegistry-D-Tv_7ca.d.cts +2572 -0
  12. package/dist/PackageRegistry-DaH4aIKP.d.ts +2572 -0
  13. package/dist/Parselet-CK8cQu2a.d.cts +299 -0
  14. package/dist/Parselet-ConOIdRO.d.ts +299 -0
  15. package/dist/ScopeManager-B5k0nk05.d.ts +559 -0
  16. package/dist/ScopeManager-CKfQtl7l.d.cts +559 -0
  17. package/dist/Token-0jpvUdPY.d.cts +245 -0
  18. package/dist/Token-0jpvUdPY.d.ts +245 -0
  19. package/dist/VMCheckpoints-BmDwIXgK.d.ts +171 -0
  20. package/dist/VMCheckpoints-CqFuLwrT.d.cts +171 -0
  21. package/dist/Value-KtAQNHur.d.cts +295 -0
  22. package/dist/Value-KtAQNHur.d.ts +295 -0
  23. package/dist/chunk-2RWAXT6O.js +3 -0
  24. package/dist/chunk-2RWAXT6O.js.map +1 -0
  25. package/dist/chunk-34RRD7PC.js +1492 -0
  26. package/dist/chunk-34RRD7PC.js.map +1 -0
  27. package/dist/chunk-3PPFLFH4.js +5097 -0
  28. package/dist/chunk-3PPFLFH4.js.map +1 -0
  29. package/dist/chunk-3VGDNEE3.js +84 -0
  30. package/dist/chunk-3VGDNEE3.js.map +1 -0
  31. package/dist/chunk-3YNVWKR2.cjs +370 -0
  32. package/dist/chunk-3YNVWKR2.cjs.map +1 -0
  33. package/dist/chunk-47LRVGOT.cjs +316 -0
  34. package/dist/chunk-47LRVGOT.cjs.map +1 -0
  35. package/dist/chunk-4MG4XKO2.js +1644 -0
  36. package/dist/chunk-4MG4XKO2.js.map +1 -0
  37. package/dist/chunk-4QADQTWS.js +2392 -0
  38. package/dist/chunk-4QADQTWS.js.map +1 -0
  39. package/dist/chunk-53B6KDDJ.cjs +1651 -0
  40. package/dist/chunk-53B6KDDJ.cjs.map +1 -0
  41. package/dist/chunk-5X2PTP6F.cjs +104 -0
  42. package/dist/chunk-5X2PTP6F.cjs.map +1 -0
  43. package/dist/chunk-5YEMOYSE.js +264 -0
  44. package/dist/chunk-5YEMOYSE.js.map +1 -0
  45. package/dist/chunk-64W6GLLZ.js +481 -0
  46. package/dist/chunk-64W6GLLZ.js.map +1 -0
  47. package/dist/chunk-6BKTCEUP.cjs +233 -0
  48. package/dist/chunk-6BKTCEUP.cjs.map +1 -0
  49. package/dist/chunk-6NTVRDQV.cjs +1642 -0
  50. package/dist/chunk-6NTVRDQV.cjs.map +1 -0
  51. package/dist/chunk-6RDSQURE.js +290 -0
  52. package/dist/chunk-6RDSQURE.js.map +1 -0
  53. package/dist/chunk-75JP4BZX.js +93 -0
  54. package/dist/chunk-75JP4BZX.js.map +1 -0
  55. package/dist/chunk-B7LXJ6LC.cjs +36 -0
  56. package/dist/chunk-B7LXJ6LC.cjs.map +1 -0
  57. package/dist/chunk-BVAR5J2F.js +257 -0
  58. package/dist/chunk-BVAR5J2F.js.map +1 -0
  59. package/dist/chunk-C4XZV6E7.cjs +269 -0
  60. package/dist/chunk-C4XZV6E7.cjs.map +1 -0
  61. package/dist/chunk-CCJPSHGI.cjs +40 -0
  62. package/dist/chunk-CCJPSHGI.cjs.map +1 -0
  63. package/dist/chunk-CLL7RUQV.cjs +316 -0
  64. package/dist/chunk-CLL7RUQV.cjs.map +1 -0
  65. package/dist/chunk-DM3LMRBC.js +329 -0
  66. package/dist/chunk-DM3LMRBC.js.map +1 -0
  67. package/dist/chunk-DUEZFTK2.js +38 -0
  68. package/dist/chunk-DUEZFTK2.js.map +1 -0
  69. package/dist/chunk-EBSPLUW4.cjs +489 -0
  70. package/dist/chunk-EBSPLUW4.cjs.map +1 -0
  71. package/dist/chunk-EHAHVROS.cjs +261 -0
  72. package/dist/chunk-EHAHVROS.cjs.map +1 -0
  73. package/dist/chunk-EIGTWK5N.js +167 -0
  74. package/dist/chunk-EIGTWK5N.js.map +1 -0
  75. package/dist/chunk-EPOXXJBK.js +96 -0
  76. package/dist/chunk-EPOXXJBK.js.map +1 -0
  77. package/dist/chunk-FEAIOR7N.cjs +91 -0
  78. package/dist/chunk-FEAIOR7N.cjs.map +1 -0
  79. package/dist/chunk-G535KJEG.js +312 -0
  80. package/dist/chunk-G535KJEG.js.map +1 -0
  81. package/dist/chunk-GCM5JHMX.js +88 -0
  82. package/dist/chunk-GCM5JHMX.js.map +1 -0
  83. package/dist/chunk-GOLDJNMZ.js +368 -0
  84. package/dist/chunk-GOLDJNMZ.js.map +1 -0
  85. package/dist/chunk-GW32KPCU.cjs +360 -0
  86. package/dist/chunk-GW32KPCU.cjs.map +1 -0
  87. package/dist/chunk-HTXVVJRA.cjs +1549 -0
  88. package/dist/chunk-HTXVVJRA.cjs.map +1 -0
  89. package/dist/chunk-HWSZJQCI.js +311 -0
  90. package/dist/chunk-HWSZJQCI.js.map +1 -0
  91. package/dist/chunk-IF532O7C.js +101 -0
  92. package/dist/chunk-IF532O7C.js.map +1 -0
  93. package/dist/chunk-J73SJHR3.cjs +2415 -0
  94. package/dist/chunk-J73SJHR3.cjs.map +1 -0
  95. package/dist/chunk-JBSYC7BB.cjs +7473 -0
  96. package/dist/chunk-JBSYC7BB.cjs.map +1 -0
  97. package/dist/chunk-KVILKGMS.js +228 -0
  98. package/dist/chunk-KVILKGMS.js.map +1 -0
  99. package/dist/chunk-LIPPNDBE.js +258 -0
  100. package/dist/chunk-LIPPNDBE.js.map +1 -0
  101. package/dist/chunk-LR7YASZF.cjs +172 -0
  102. package/dist/chunk-LR7YASZF.cjs.map +1 -0
  103. package/dist/chunk-M4N5GA5Z.cjs +309 -0
  104. package/dist/chunk-M4N5GA5Z.cjs.map +1 -0
  105. package/dist/chunk-M5LX5AOO.js +7459 -0
  106. package/dist/chunk-M5LX5AOO.js.map +1 -0
  107. package/dist/chunk-MZOVP3WI.cjs +96 -0
  108. package/dist/chunk-MZOVP3WI.cjs.map +1 -0
  109. package/dist/chunk-N5YFR4UP.cjs +10 -0
  110. package/dist/chunk-N5YFR4UP.cjs.map +1 -0
  111. package/dist/chunk-NGBBNL4K.cjs +4 -0
  112. package/dist/chunk-NGBBNL4K.cjs.map +1 -0
  113. package/dist/chunk-NH2O2AUR.js +146 -0
  114. package/dist/chunk-NH2O2AUR.js.map +1 -0
  115. package/dist/chunk-NLNDMWZC.js +31 -0
  116. package/dist/chunk-NLNDMWZC.js.map +1 -0
  117. package/dist/chunk-NMCRQP3Z.cjs +778 -0
  118. package/dist/chunk-NMCRQP3Z.cjs.map +1 -0
  119. package/dist/chunk-NMD5VRN4.cjs +1327 -0
  120. package/dist/chunk-NMD5VRN4.cjs.map +1 -0
  121. package/dist/chunk-OC6LTXYS.cjs +286 -0
  122. package/dist/chunk-OC6LTXYS.cjs.map +1 -0
  123. package/dist/chunk-OT6OJY7C.cjs +114 -0
  124. package/dist/chunk-OT6OJY7C.cjs.map +1 -0
  125. package/dist/chunk-PFSDGGYL.js +8 -0
  126. package/dist/chunk-PFSDGGYL.js.map +1 -0
  127. package/dist/chunk-QNJ4ACRT.cjs +155 -0
  128. package/dist/chunk-QNJ4ACRT.cjs.map +1 -0
  129. package/dist/chunk-QWY3VEZN.js +1637 -0
  130. package/dist/chunk-QWY3VEZN.js.map +1 -0
  131. package/dist/chunk-RFYD5TJE.js +111 -0
  132. package/dist/chunk-RFYD5TJE.js.map +1 -0
  133. package/dist/chunk-RIN643A3.js +354 -0
  134. package/dist/chunk-RIN643A3.js.map +1 -0
  135. package/dist/chunk-RZCWSXTA.cjs +5122 -0
  136. package/dist/chunk-RZCWSXTA.cjs.map +1 -0
  137. package/dist/chunk-SDGRK7EP.js +774 -0
  138. package/dist/chunk-SDGRK7EP.js.map +1 -0
  139. package/dist/chunk-VEKIWQ3F.cjs +39 -0
  140. package/dist/chunk-VEKIWQ3F.cjs.map +1 -0
  141. package/dist/chunk-WQTTOGXC.cjs +99 -0
  142. package/dist/chunk-WQTTOGXC.cjs.map +1 -0
  143. package/dist/chunk-X6K3HUOY.cjs +86 -0
  144. package/dist/chunk-X6K3HUOY.cjs.map +1 -0
  145. package/dist/chunk-XJCMXB2E.cjs +333 -0
  146. package/dist/chunk-XJCMXB2E.cjs.map +1 -0
  147. package/dist/chunk-XVWCOTR6.js +1324 -0
  148. package/dist/chunk-XVWCOTR6.js.map +1 -0
  149. package/dist/chunk-YLJ4XMA6.js +33 -0
  150. package/dist/chunk-YLJ4XMA6.js.map +1 -0
  151. package/dist/chunk-Z2XP767T.cjs +35 -0
  152. package/dist/chunk-Z2XP767T.cjs.map +1 -0
  153. package/dist/chunk-Z4X2RWOF.js +37 -0
  154. package/dist/chunk-Z4X2RWOF.js.map +1 -0
  155. package/dist/constants.cjs +22 -0
  156. package/dist/constants.cjs.map +1 -0
  157. package/dist/constants.d.cts +12 -0
  158. package/dist/constants.d.ts +12 -0
  159. package/dist/constants.js +5 -0
  160. package/dist/constants.js.map +1 -0
  161. package/dist/engine.cjs +79 -0
  162. package/dist/engine.cjs.map +1 -0
  163. package/dist/engine.d.cts +587 -0
  164. package/dist/engine.d.ts +587 -0
  165. package/dist/engine.js +34 -0
  166. package/dist/engine.js.map +1 -0
  167. package/dist/errors.cjs +81 -0
  168. package/dist/errors.cjs.map +1 -0
  169. package/dist/errors.d.cts +95 -0
  170. package/dist/errors.d.ts +95 -0
  171. package/dist/errors.js +4 -0
  172. package/dist/errors.js.map +1 -0
  173. package/dist/format.cjs +171 -0
  174. package/dist/format.cjs.map +1 -0
  175. package/dist/format.d.cts +51 -0
  176. package/dist/format.d.ts +51 -0
  177. package/dist/format.js +168 -0
  178. package/dist/format.js.map +1 -0
  179. package/dist/index.cjs +97 -0
  180. package/dist/index.cjs.map +1 -0
  181. package/dist/index.d.cts +152 -0
  182. package/dist/index.d.ts +152 -0
  183. package/dist/index.js +75 -0
  184. package/dist/index.js.map +1 -0
  185. package/dist/language.cjs +308 -0
  186. package/dist/language.cjs.map +1 -0
  187. package/dist/language.d.cts +110 -0
  188. package/dist/language.d.ts +110 -0
  189. package/dist/language.js +287 -0
  190. package/dist/language.js.map +1 -0
  191. package/dist/lexer.cjs +64 -0
  192. package/dist/lexer.cjs.map +1 -0
  193. package/dist/lexer.d.cts +56 -0
  194. package/dist/lexer.d.ts +56 -0
  195. package/dist/lexer.js +11 -0
  196. package/dist/lexer.js.map +1 -0
  197. package/dist/normalizer.cjs +40 -0
  198. package/dist/normalizer.cjs.map +1 -0
  199. package/dist/normalizer.d.cts +364 -0
  200. package/dist/normalizer.d.ts +364 -0
  201. package/dist/normalizer.js +11 -0
  202. package/dist/normalizer.js.map +1 -0
  203. package/dist/packages.cjs +121 -0
  204. package/dist/packages.cjs.map +1 -0
  205. package/dist/packages.d.cts +691 -0
  206. package/dist/packages.d.ts +691 -0
  207. package/dist/packages.js +24 -0
  208. package/dist/packages.js.map +1 -0
  209. package/dist/parser.cjs +55 -0
  210. package/dist/parser.cjs.map +1 -0
  211. package/dist/parser.d.cts +46 -0
  212. package/dist/parser.d.ts +46 -0
  213. package/dist/parser.js +10 -0
  214. package/dist/parser.js.map +1 -0
  215. package/dist/pipeline-CrsRPmsv.d.ts +285 -0
  216. package/dist/pipeline-DPUQt7yL.d.cts +285 -0
  217. package/dist/resolvers.cjs +13 -0
  218. package/dist/resolvers.cjs.map +1 -0
  219. package/dist/resolvers.d.cts +111 -0
  220. package/dist/resolvers.d.ts +111 -0
  221. package/dist/resolvers.js +4 -0
  222. package/dist/resolvers.js.map +1 -0
  223. package/dist/services.cjs +21 -0
  224. package/dist/services.cjs.map +1 -0
  225. package/dist/services.d.cts +30 -0
  226. package/dist/services.d.ts +30 -0
  227. package/dist/services.js +4 -0
  228. package/dist/services.js.map +1 -0
  229. package/dist/uom.cjs +56 -0
  230. package/dist/uom.cjs.map +1 -0
  231. package/dist/uom.d.cts +224 -0
  232. package/dist/uom.d.ts +224 -0
  233. package/dist/uom.js +11 -0
  234. package/dist/uom.js.map +1 -0
  235. package/dist/utilities.cjs +32 -0
  236. package/dist/utilities.cjs.map +1 -0
  237. package/dist/utilities.d.cts +113 -0
  238. package/dist/utilities.d.ts +113 -0
  239. package/dist/utilities.js +7 -0
  240. package/dist/utilities.js.map +1 -0
  241. package/dist/variables.cjs +17 -0
  242. package/dist/variables.cjs.map +1 -0
  243. package/dist/variables.d.cts +87 -0
  244. package/dist/variables.d.ts +87 -0
  245. package/dist/variables.js +4 -0
  246. package/dist/variables.js.map +1 -0
  247. package/dist/vm.cjs +284 -0
  248. package/dist/vm.cjs.map +1 -0
  249. package/dist/vm.d.cts +68 -0
  250. package/dist/vm.d.ts +68 -0
  251. package/dist/vm.js +194 -0
  252. package/dist/vm.js.map +1 -0
  253. package/package.json +4 -4
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ var chunkM4N5GA5Z_cjs = require('./chunk-M4N5GA5Z.cjs');
4
+ require('./chunk-B7LXJ6LC.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "CoreErrorCodes", {
9
+ enumerable: true,
10
+ get: function () { return chunkM4N5GA5Z_cjs.CoreErrorCodes; }
11
+ });
12
+ Object.defineProperty(exports, "EngineError", {
13
+ enumerable: true,
14
+ get: function () { return chunkM4N5GA5Z_cjs.EngineError; }
15
+ });
16
+ Object.defineProperty(exports, "ErrorCategory", {
17
+ enumerable: true,
18
+ get: function () { return chunkM4N5GA5Z_cjs.ErrorCategory; }
19
+ });
20
+ Object.defineProperty(exports, "ErrorFactory", {
21
+ enumerable: true,
22
+ get: function () { return chunkM4N5GA5Z_cjs.ErrorFactory; }
23
+ });
24
+ Object.defineProperty(exports, "andThen", {
25
+ enumerable: true,
26
+ get: function () { return chunkM4N5GA5Z_cjs.andThen; }
27
+ });
28
+ Object.defineProperty(exports, "combine", {
29
+ enumerable: true,
30
+ get: function () { return chunkM4N5GA5Z_cjs.combine; }
31
+ });
32
+ Object.defineProperty(exports, "err", {
33
+ enumerable: true,
34
+ get: function () { return chunkM4N5GA5Z_cjs.err; }
35
+ });
36
+ Object.defineProperty(exports, "isErr", {
37
+ enumerable: true,
38
+ get: function () { return chunkM4N5GA5Z_cjs.isErr; }
39
+ });
40
+ Object.defineProperty(exports, "isOk", {
41
+ enumerable: true,
42
+ get: function () { return chunkM4N5GA5Z_cjs.isOk; }
43
+ });
44
+ Object.defineProperty(exports, "map", {
45
+ enumerable: true,
46
+ get: function () { return chunkM4N5GA5Z_cjs.map; }
47
+ });
48
+ Object.defineProperty(exports, "mapErr", {
49
+ enumerable: true,
50
+ get: function () { return chunkM4N5GA5Z_cjs.mapErr; }
51
+ });
52
+ Object.defineProperty(exports, "match", {
53
+ enumerable: true,
54
+ get: function () { return chunkM4N5GA5Z_cjs.match; }
55
+ });
56
+ Object.defineProperty(exports, "normalizeUnknownError", {
57
+ enumerable: true,
58
+ get: function () { return chunkM4N5GA5Z_cjs.normalizeUnknownError; }
59
+ });
60
+ Object.defineProperty(exports, "ok", {
61
+ enumerable: true,
62
+ get: function () { return chunkM4N5GA5Z_cjs.ok; }
63
+ });
64
+ Object.defineProperty(exports, "throwIfErr", {
65
+ enumerable: true,
66
+ get: function () { return chunkM4N5GA5Z_cjs.throwIfErr; }
67
+ });
68
+ Object.defineProperty(exports, "tryCatch", {
69
+ enumerable: true,
70
+ get: function () { return chunkM4N5GA5Z_cjs.tryCatch; }
71
+ });
72
+ Object.defineProperty(exports, "tryCatchAsync", {
73
+ enumerable: true,
74
+ get: function () { return chunkM4N5GA5Z_cjs.tryCatchAsync; }
75
+ });
76
+ Object.defineProperty(exports, "unwrapOr", {
77
+ enumerable: true,
78
+ get: function () { return chunkM4N5GA5Z_cjs.unwrapOr; }
79
+ });
80
+ //# sourceMappingURL=errors.cjs.map
81
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"errors.cjs"}
@@ -0,0 +1,95 @@
1
+ import { E as EngineError } from './EngineError-DvPSnhZi.cjs';
2
+ export { C as CoreErrorCode, a as CoreErrorCodes, b as EngineErrorInit, c as ErrorCategory, d as ErrorCode, e as ErrorFactory, S as SourceSpan, n as normalizeUnknownError } from './EngineError-DvPSnhZi.cjs';
3
+
4
+ /**
5
+ * A Rust-style `Result<T, E>`, the value half of this engine's error-handling
6
+ * redesign. `E` defaults to `EngineError` (this engine's structured error
7
+ * type) but every combinator here is generic over `E`, so `Result` works
8
+ * equally well for a domain that isn't `EngineError`-shaped.
9
+ *
10
+ * This exact shape used to live in `errors/UnifiedErrorFramework.ts` (kept
11
+ * there as a barrel re-export for backward compatibility), moved here as
12
+ * its own module because it's genuinely generic (no dependency on
13
+ * `EngineError` beyond the default type parameter) and because the engine
14
+ * is migrating callers to it incrementally: parsing/VM/package code that
15
+ * expects "a failure is a possibility, not an exception" returns
16
+ * `Result<T, EngineError>` instead of throwing; two explicit adapters
17
+ * {@link throwIfErr} and {@link tryCatch}, are the sanctioned way to cross
18
+ * the boundary between Result-based code and still-throw-based code during
19
+ * the migration (and permanently, at the public API boundary. See
20
+ * `ExpressionEngine.evaluateExpression()`'s documented throw contract).
21
+ */
22
+ type Result<T, E = EngineError> = {
23
+ ok: true;
24
+ value: T;
25
+ } | {
26
+ ok: false;
27
+ error: E;
28
+ };
29
+ /** Wrap a successful value. */
30
+ declare function ok<T>(value: T): Result<T, never>;
31
+ /** Wrap a failure. */
32
+ declare function err<E>(error: E): Result<never, E>;
33
+ /**
34
+ * Narrow a {@link Result} to its success arm.
35
+ *
36
+ * @param r - The result to test.
37
+ * @returns True when it succeeded, narrowing `r` so `r.value` is reachable.
38
+ */
39
+ declare function isOk<T, E>(r: Result<T, E>): r is {
40
+ ok: true;
41
+ value: T;
42
+ };
43
+ /**
44
+ * Narrow a {@link Result} to its failure arm.
45
+ *
46
+ * @param r - The result to test.
47
+ * @returns True when it failed, narrowing `r` so `r.error` is reachable.
48
+ */
49
+ declare function isErr<T, E>(r: Result<T, E>): r is {
50
+ ok: false;
51
+ error: E;
52
+ };
53
+ /** Transform the success value; a failure passes through untouched. */
54
+ declare function map<T, U, E>(r: Result<T, E>, fn: (value: T) => U): Result<U, E>;
55
+ /** Transform the error; a success passes through untouched. */
56
+ declare function mapErr<T, E, F>(r: Result<T, E>, fn: (error: E) => F): Result<T, F>;
57
+ /** Chain a Result-returning operation onto a success (a.k.a. flatMap/bind). */
58
+ declare function andThen<T, U, E>(r: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
59
+ /** Unwrap a success, or return `fallback` for a failure. Never throws. */
60
+ declare function unwrapOr<T, E>(r: Result<T, E>, fallback: T): T;
61
+ /** Exhaustive pattern-match, the `match`/`switch` a Rust enum gets for free. */
62
+ declare function match<T, E, R>(r: Result<T, E>, arms: {
63
+ ok: (value: T) => R;
64
+ err: (error: E) => R;
65
+ }): R;
66
+ /**
67
+ * Combine several Results into one, succeeds with a tuple of all values
68
+ * iff every input succeeded; otherwise fails with the FIRST error
69
+ * encountered (left-to-right), matching this codebase's existing
70
+ * fail-fast convention elsewhere (e.g. `BytecodeBuilder`'s constant-pool
71
+ * limit checks).
72
+ */
73
+ declare function combine<T extends readonly unknown[], E>(results: {
74
+ [K in keyof T]: Result<T[K], E>;
75
+ }): Result<T, E>;
76
+ /**
77
+ * Cross from Result-space back to throw-space, the sanctioned boundary
78
+ * adapter for callers (public API surface, older not-yet-migrated code,
79
+ * tests) that still want exception-based control flow. Throws `r.error`
80
+ * as-is (an `EngineError` is already a real `Error` subclass, so this
81
+ * needs no wrapping).
82
+ */
83
+ declare function throwIfErr<T, E>(r: Result<T, E>): T;
84
+ /**
85
+ * Cross from throw-space into Result-space, runs `fn`, converting any
86
+ * thrown value into a Result via `normalize` (defaults to
87
+ * {@link normalizeUnknownError}). The inverse of {@link throwIfErr}; the
88
+ * pairing that lets Result-based and throw-based code interoperate during
89
+ * an incremental migration instead of requiring a single flag-day rewrite.
90
+ */
91
+ declare function tryCatch<T>(fn: () => T, normalize?: (e: unknown) => EngineError): Result<T, EngineError>;
92
+ /** Async sibling of {@link tryCatch}. */
93
+ declare function tryCatchAsync<T>(fn: () => Promise<T>, normalize?: (e: unknown) => EngineError): Promise<Result<T, EngineError>>;
94
+
95
+ export { EngineError, type Result, andThen, combine, err, isErr, isOk, map, mapErr, match, ok, throwIfErr, tryCatch, tryCatchAsync, unwrapOr };
@@ -0,0 +1,95 @@
1
+ import { E as EngineError } from './EngineError-DvPSnhZi.js';
2
+ export { C as CoreErrorCode, a as CoreErrorCodes, b as EngineErrorInit, c as ErrorCategory, d as ErrorCode, e as ErrorFactory, S as SourceSpan, n as normalizeUnknownError } from './EngineError-DvPSnhZi.js';
3
+
4
+ /**
5
+ * A Rust-style `Result<T, E>`, the value half of this engine's error-handling
6
+ * redesign. `E` defaults to `EngineError` (this engine's structured error
7
+ * type) but every combinator here is generic over `E`, so `Result` works
8
+ * equally well for a domain that isn't `EngineError`-shaped.
9
+ *
10
+ * This exact shape used to live in `errors/UnifiedErrorFramework.ts` (kept
11
+ * there as a barrel re-export for backward compatibility), moved here as
12
+ * its own module because it's genuinely generic (no dependency on
13
+ * `EngineError` beyond the default type parameter) and because the engine
14
+ * is migrating callers to it incrementally: parsing/VM/package code that
15
+ * expects "a failure is a possibility, not an exception" returns
16
+ * `Result<T, EngineError>` instead of throwing; two explicit adapters
17
+ * {@link throwIfErr} and {@link tryCatch}, are the sanctioned way to cross
18
+ * the boundary between Result-based code and still-throw-based code during
19
+ * the migration (and permanently, at the public API boundary. See
20
+ * `ExpressionEngine.evaluateExpression()`'s documented throw contract).
21
+ */
22
+ type Result<T, E = EngineError> = {
23
+ ok: true;
24
+ value: T;
25
+ } | {
26
+ ok: false;
27
+ error: E;
28
+ };
29
+ /** Wrap a successful value. */
30
+ declare function ok<T>(value: T): Result<T, never>;
31
+ /** Wrap a failure. */
32
+ declare function err<E>(error: E): Result<never, E>;
33
+ /**
34
+ * Narrow a {@link Result} to its success arm.
35
+ *
36
+ * @param r - The result to test.
37
+ * @returns True when it succeeded, narrowing `r` so `r.value` is reachable.
38
+ */
39
+ declare function isOk<T, E>(r: Result<T, E>): r is {
40
+ ok: true;
41
+ value: T;
42
+ };
43
+ /**
44
+ * Narrow a {@link Result} to its failure arm.
45
+ *
46
+ * @param r - The result to test.
47
+ * @returns True when it failed, narrowing `r` so `r.error` is reachable.
48
+ */
49
+ declare function isErr<T, E>(r: Result<T, E>): r is {
50
+ ok: false;
51
+ error: E;
52
+ };
53
+ /** Transform the success value; a failure passes through untouched. */
54
+ declare function map<T, U, E>(r: Result<T, E>, fn: (value: T) => U): Result<U, E>;
55
+ /** Transform the error; a success passes through untouched. */
56
+ declare function mapErr<T, E, F>(r: Result<T, E>, fn: (error: E) => F): Result<T, F>;
57
+ /** Chain a Result-returning operation onto a success (a.k.a. flatMap/bind). */
58
+ declare function andThen<T, U, E>(r: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
59
+ /** Unwrap a success, or return `fallback` for a failure. Never throws. */
60
+ declare function unwrapOr<T, E>(r: Result<T, E>, fallback: T): T;
61
+ /** Exhaustive pattern-match, the `match`/`switch` a Rust enum gets for free. */
62
+ declare function match<T, E, R>(r: Result<T, E>, arms: {
63
+ ok: (value: T) => R;
64
+ err: (error: E) => R;
65
+ }): R;
66
+ /**
67
+ * Combine several Results into one, succeeds with a tuple of all values
68
+ * iff every input succeeded; otherwise fails with the FIRST error
69
+ * encountered (left-to-right), matching this codebase's existing
70
+ * fail-fast convention elsewhere (e.g. `BytecodeBuilder`'s constant-pool
71
+ * limit checks).
72
+ */
73
+ declare function combine<T extends readonly unknown[], E>(results: {
74
+ [K in keyof T]: Result<T[K], E>;
75
+ }): Result<T, E>;
76
+ /**
77
+ * Cross from Result-space back to throw-space, the sanctioned boundary
78
+ * adapter for callers (public API surface, older not-yet-migrated code,
79
+ * tests) that still want exception-based control flow. Throws `r.error`
80
+ * as-is (an `EngineError` is already a real `Error` subclass, so this
81
+ * needs no wrapping).
82
+ */
83
+ declare function throwIfErr<T, E>(r: Result<T, E>): T;
84
+ /**
85
+ * Cross from throw-space into Result-space, runs `fn`, converting any
86
+ * thrown value into a Result via `normalize` (defaults to
87
+ * {@link normalizeUnknownError}). The inverse of {@link throwIfErr}; the
88
+ * pairing that lets Result-based and throw-based code interoperate during
89
+ * an incremental migration instead of requiring a single flag-day rewrite.
90
+ */
91
+ declare function tryCatch<T>(fn: () => T, normalize?: (e: unknown) => EngineError): Result<T, EngineError>;
92
+ /** Async sibling of {@link tryCatch}. */
93
+ declare function tryCatchAsync<T>(fn: () => Promise<T>, normalize?: (e: unknown) => EngineError): Promise<Result<T, EngineError>>;
94
+
95
+ export { EngineError, type Result, andThen, combine, err, isErr, isOk, map, mapErr, match, ok, throwIfErr, tryCatch, tryCatchAsync, unwrapOr };
package/dist/errors.js ADDED
@@ -0,0 +1,4 @@
1
+ export { CoreErrorCodes, EngineError, ErrorCategory, ErrorFactory, andThen, combine, err, isErr, isOk, map, mapErr, match, normalizeUnknownError, ok, throwIfErr, tryCatch, tryCatchAsync, unwrapOr } from './chunk-6RDSQURE.js';
2
+ import './chunk-YLJ4XMA6.js';
3
+ //# sourceMappingURL=errors.js.map
4
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"errors.js"}
@@ -0,0 +1,171 @@
1
+ 'use strict';
2
+
3
+ var chunkCCJPSHGI_cjs = require('./chunk-CCJPSHGI.cjs');
4
+ var chunkOT6OJY7C_cjs = require('./chunk-OT6OJY7C.cjs');
5
+ var chunkHTXVVJRA_cjs = require('./chunk-HTXVVJRA.cjs');
6
+ require('./chunk-OC6LTXYS.cjs');
7
+ var chunk3YNVWKR2_cjs = require('./chunk-3YNVWKR2.cjs');
8
+ require('./chunk-M4N5GA5Z.cjs');
9
+ require('./chunk-B7LXJ6LC.cjs');
10
+
11
+ // src/format/FormattingSettings.ts
12
+ var DEFAULT_FORMATTING_SETTINGS = {
13
+ floatResult: {
14
+ decimalPlaces: 2,
15
+ enableSeperator: true
16
+ },
17
+ numberResult: {
18
+ decimalSeparatorLocale: "en-US"
19
+ },
20
+ hexResult: {
21
+ enablePadding: false,
22
+ paddingZeros: 0
23
+ },
24
+ unitOfMeasurementResult: {
25
+ decimalPlaces: 2,
26
+ unitNames: true
27
+ },
28
+ percentageResult: {
29
+ decimalPlaces: 2
30
+ }
31
+ };
32
+
33
+ // src/format/FormatEngine.ts
34
+ function formatNumber(value, locale, settings) {
35
+ const dp = settings.floatResult.decimalPlaces;
36
+ const sep = settings.floatResult.enableSeperator;
37
+ const loc = settings.numberResult.decimalSeparatorLocale;
38
+ const formatted = chunkCCJPSHGI_cjs.autoFormatIntegerOrFloat(value, dp, sep, loc);
39
+ return `${locale.display.resultPrefix}${formatted}`;
40
+ }
41
+ function formatHex(value, settings, base) {
42
+ const truncated = Math.trunc(value);
43
+ const sign = truncated < 0 ? "-" : "";
44
+ const magnitude = Math.abs(truncated);
45
+ if (base === "bin") return `= ${sign}0b${magnitude.toString(2)}`;
46
+ if (base === "oct") return `= ${sign}0o${magnitude.toString(8)}`;
47
+ const padding = settings.hexResult.enablePadding ? settings.hexResult.paddingZeros : 0;
48
+ const hex = magnitude.toString(16).toUpperCase().padStart(padding, "0");
49
+ return `= ${sign}0x${hex}`;
50
+ }
51
+ function formatBigInt(value) {
52
+ return `= ${value}`;
53
+ }
54
+ function formatString(value) {
55
+ return `= ${value}`;
56
+ }
57
+ function formatBoolean(value) {
58
+ return `= ${value}`;
59
+ }
60
+ function formatDatetime(value, locale) {
61
+ const d = new Date(value);
62
+ const dateStr = d.toLocaleDateString(locale.code, { weekday: "long", year: "numeric", month: "long", day: "numeric" });
63
+ const isMidnight = d.getHours() === 0 && d.getMinutes() === 0 && d.getSeconds() === 0 && d.getMilliseconds() === 0;
64
+ if (isMidnight) return `= ${dateStr}`;
65
+ return `= ${dateStr}, ${d.toLocaleTimeString(locale.code)}`;
66
+ }
67
+ function formatMsDuration(ms) {
68
+ const sign = ms < 0 ? "-" : "";
69
+ const totalSeconds = Math.round(Math.abs(ms) / 1e3);
70
+ const hours = Math.floor(totalSeconds / 3600);
71
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
72
+ const seconds = totalSeconds % 60;
73
+ const mm = String(minutes).padStart(2, "0");
74
+ if (seconds === 0) return `${sign}${hours}:${mm}`;
75
+ const ss = String(seconds).padStart(2, "0");
76
+ return `${sign}${hours}:${mm}:${ss}`;
77
+ }
78
+ function formatUom(value, unit, locale, settings) {
79
+ if (unit === "ms") return `= ${formatMsDuration(value)}`;
80
+ const dp = settings.unitOfMeasurementResult.decimalPlaces;
81
+ const useUnitNames = settings.unitOfMeasurementResult.unitNames;
82
+ const timeSpanUnits = ["days", "weeks", "hours", "minutes", "seconds", "day", "week", "hour", "minute", "second"];
83
+ const isTimeSpan = unit && timeSpanUnits.includes(unit);
84
+ let formatted;
85
+ if (isTimeSpan && value === Math.floor(value)) {
86
+ formatted = value.toString();
87
+ } else {
88
+ formatted = value.toFixed(dp);
89
+ }
90
+ const currencyDisplay = unit ? chunkOT6OJY7C_cjs.CURRENCY_DISPLAY[unit.toUpperCase()] : void 0;
91
+ if (currencyDisplay) {
92
+ const sep = currencyDisplay.spaced ? " " : "";
93
+ const withSymbol = currencyDisplay.position === "prefix" ? `${currencyDisplay.symbol}${sep}${formatted}` : `${formatted}${sep}${currencyDisplay.symbol}`;
94
+ return `= ${withSymbol}`;
95
+ }
96
+ const unitLabel = useUnitNames ? unit || "" : unit || "";
97
+ return `= ${formatted} ${unitLabel}`.trim();
98
+ }
99
+ function formatMatrixEntry(entry, settings) {
100
+ if (typeof entry === "boolean") return entry ? "true" : "false";
101
+ if (typeof entry === "object" && entry !== null) return chunkHTXVVJRA_cjs.formatSymbolic(entry);
102
+ const dp = settings.floatResult.decimalPlaces;
103
+ const sep = settings.floatResult.enableSeperator;
104
+ const loc = settings.numberResult.decimalSeparatorLocale;
105
+ return chunkCCJPSHGI_cjs.autoFormatIntegerOrFloat(entry, dp, sep, loc);
106
+ }
107
+ function formatMatrix(m, locale, settings) {
108
+ const rowMajor = chunkHTXVVJRA_cjs.columnMajorToRowMajor(m);
109
+ const rows = [];
110
+ for (let r = 0; r < m.rows; r++) {
111
+ const cells = [];
112
+ for (let c = 0; c < m.cols; c++) {
113
+ cells.push(formatMatrixEntry(rowMajor[r * m.cols + c], settings));
114
+ }
115
+ rows.push(cells.join(", "));
116
+ }
117
+ return `${locale.display.resultPrefix}[${rows.join("; ")}]`;
118
+ }
119
+ function formatRange(min, max, locale) {
120
+ return `${locale.display.resultPrefix}${min}:${max}`;
121
+ }
122
+ function formatPercentage(value, locale, settings) {
123
+ const dp = settings.percentageResult.decimalPlaces;
124
+ const formatted = (value * 100).toFixed(dp);
125
+ return `= ${formatted}${locale.display.percentageSuffix}`;
126
+ }
127
+ function formatUnit(value, unit) {
128
+ return `= ${value} ${unit || ""}`.trim();
129
+ }
130
+ function formatValue(value, settings) {
131
+ const us = settings || DEFAULT_FORMATTING_SETTINGS;
132
+ const localeCode = us.numberResult.decimalSeparatorLocale || "en";
133
+ const locale = chunk3YNVWKR2_cjs.getLocale(localeCode);
134
+ switch (value.type) {
135
+ case 0 /* Number */:
136
+ return formatNumber(value.value, locale, us);
137
+ case 1 /* Hex */:
138
+ return formatHex(value.value, us, value.unit);
139
+ case 2 /* BigInt */:
140
+ return formatBigInt(value.value);
141
+ case 3 /* String */:
142
+ return formatString(value.value);
143
+ case 10 /* Boolean */:
144
+ return formatBoolean(value.value);
145
+ case 4 /* Datetime */:
146
+ return formatDatetime(value.value, locale);
147
+ case 6 /* Uom */:
148
+ return formatUom(value.value, value.unit, locale, us);
149
+ case 7 /* Matrix */:
150
+ return formatMatrix(value.value, locale, us);
151
+ case 8 /* Range */: {
152
+ const r = value.value;
153
+ return formatRange(r.min, r.max, locale);
154
+ }
155
+ case 9 /* Symbolic */:
156
+ return chunkHTXVVJRA_cjs.formatSymbolic(value.value);
157
+ case 5 /* Percentage */:
158
+ return formatPercentage(value.value, locale, us);
159
+ case 11 /* Unit */:
160
+ return formatUnit(value.value, value.unit);
161
+ case 13 /* Error */:
162
+ return value.unit ?? String(value.value);
163
+ default:
164
+ return `= ${String(value.value)}`;
165
+ }
166
+ }
167
+
168
+ exports.DEFAULT_FORMATTING_SETTINGS = DEFAULT_FORMATTING_SETTINGS;
169
+ exports.formatValue = formatValue;
170
+ //# sourceMappingURL=format.cjs.map
171
+ //# sourceMappingURL=format.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/format/FormattingSettings.ts","../src/format/FormatEngine.ts"],"names":["autoFormatIntegerOrFloat","CURRENCY_DISPLAY","formatSymbolic","columnMajorToRowMajor","getLocale"],"mappings":";;;;;;;;;;;AA0BO,IAAM,2BAAA,GAAkD;AAAA,EAC7D,WAAA,EAAa;AAAA,IACX,aAAA,EAAe,CAAA;AAAA,IACf,eAAA,EAAiB;AAAA,GACnB;AAAA,EACA,YAAA,EAAc;AAAA,IACZ,sBAAA,EAAwB;AAAA,GAC1B;AAAA,EACA,SAAA,EAAW;AAAA,IACT,aAAA,EAAe,KAAA;AAAA,IACf,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,uBAAA,EAAyB;AAAA,IACvB,aAAA,EAAe,CAAA;AAAA,IACf,SAAA,EAAW;AAAA,GACb;AAAA,EACA,gBAAA,EAAkB;AAAA,IAChB,aAAA,EAAe;AAAA;AAEnB;;;ACrCA,SAAS,YAAA,CAAa,KAAA,EAAe,MAAA,EAAi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,MAAA,EAAQ,EAAE,CAAA;AAAA,IAC3D,KAAA,EAAA;AACE,MAAA,OAAO,UAAA,CAAW,KAAA,CAAM,KAAA,EAAiB,KAAA,CAAM,IAAI,CAAA;AAAA,IACrD,KAAA,EAAA;AAKE,MAAA,OAAO,KAAA,CAAM,IAAA,IAAQ,MAAA,CAAO,KAAA,CAAM,KAAK,CAAA;AAAA,IACzC;AACE,MAAA,OAAO,CAAA,EAAA,EAAK,MAAA,CAAO,KAAA,CAAM,KAAK,CAAC,CAAA,CAAA;AAAA;AAErC","file":"format.cjs","sourcesContent":["/**\n * Minimal formatting settings interface for the engine\n * This allows the engine to format values without depending on app-specific settings\n */\nexport interface FormattingSettings {\n floatResult: {\n decimalPlaces: number;\n enableSeperator: boolean;\n };\n numberResult: {\n decimalSeparatorLocale: string;\n };\n hexResult: {\n enablePadding: boolean;\n paddingZeros: number;\n };\n unitOfMeasurementResult: {\n decimalPlaces: number;\n unitNames: boolean;\n };\n percentageResult: {\n decimalPlaces: number;\n };\n}\n\n/** Formatting used when a host supplies none. */\nexport const DEFAULT_FORMATTING_SETTINGS: FormattingSettings = {\n floatResult: {\n decimalPlaces: 2,\n enableSeperator: true,\n },\n numberResult: {\n decimalSeparatorLocale: \"en-US\",\n },\n hexResult: {\n enablePadding: false,\n paddingZeros: 0,\n },\n unitOfMeasurementResult: {\n decimalPlaces: 2,\n unitNames: true,\n },\n percentageResult: {\n decimalPlaces: 2,\n },\n};\n","import { Value, ValueType, type MatrixData, type MatrixEntry, type RangeData } from \"@solve-js/vm/Value\";\nimport { getLocale, type ILocale } from \"@solve-js/constants/locales\";\nimport { autoFormatIntegerOrFloat } from \"@solve-js/utilities/Number\";\nimport { FormattingSettings, DEFAULT_FORMATTING_SETTINGS } from \"./FormattingSettings\";\nimport { CURRENCY_DISPLAY } from \"@solve-js/uom/CurrencyAliases\";\nimport { columnMajorToRowMajor } from \"@solve-js/vm/MatrixOps\";\nimport { formatSymbolic, type SymbolicNode } from \"@solve-js/symbolic\";\n\nfunction formatNumber(value: number, locale: ILocale, settings: FormattingSettings): string {\n const dp = settings.floatResult.decimalPlaces;\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n const formatted = autoFormatIntegerOrFloat(value, dp, sep, loc);\n return `${locale.display.resultPrefix}${formatted}`;\n}\n\n/**\n * Renders a number in whichever base it is tagged with.\n *\n * The zero padding is a hexadecimal setting and stays one. Applying it to a\n * binary rendering would pad `0b101` out to the same digit count as a hex\n * value, which is a different quantity of zeros and not what the setting asks\n * for.\n */\nfunction formatHex(value: number, settings: FormattingSettings, base?: string): string {\n // Truncate and take the sign off before converting. `Number.toString(radix)`\n // does neither: it renders -255 as \"-ff\", which lands the minus inside the\n // literal as `0x-FF`, and it renders 255.7 as \"ff.b3333333333\", inventing\n // fractional hex digits for a notation that has no use for them. Both were\n // visible on `as hex` until the builtins started sharing this path.\n const truncated = Math.trunc(value);\n const sign = truncated < 0 ? \"-\" : \"\";\n const magnitude = Math.abs(truncated);\n\n if (base === \"bin\") return `= ${sign}0b${magnitude.toString(2)}`;\n if (base === \"oct\") return `= ${sign}0o${magnitude.toString(8)}`;\n const padding = settings.hexResult.enablePadding ? settings.hexResult.paddingZeros : 0;\n const hex = magnitude.toString(16).toUpperCase().padStart(padding, \"0\");\n return `= ${sign}0x${hex}`;\n}\n\nfunction formatBigInt(value: bigint): string {\n return `= ${value}`;\n}\n\nfunction formatString(value: string): string {\n return `= ${value}`;\n}\n\nfunction formatBoolean(value: boolean): string {\n return `= ${value}`;\n}\n\n/**\n * Renders a Datetime value locale-aware, the previous implementation\n * called `d.toLocaleString()` with no arguments, which always uses the JS\n * runtime's own default locale and never actually consulted `locale.code`\n * despite receiving it as a parameter (both branches of its old\n * `dateFormat === \"default\"` check were byte-for-byte identical, dead\n * groundwork for a distinction that was never implemented). Concretely,\n * this meant every configured locale (including the shipped German one)\n * always displayed weekday/month names in English. See GitHub issue #77.\n *\n * Uses `weekday`/`month`: \"long\" for a spelled-out date (\"Monday,\n * November 17, 2025\" / \"lundi 17 novembre 2025\") since that's what a\n * literal weekday name is for; a bare numeric date doesn't need\n * localizing beyond the decimal/thousands separators `formatNumber()`\n * already handles. The time-of-day portion is only appended when it's\n * not exactly local midnight, bare date literals (\"today\", \"17/11/2025\")\n * always anchor to local midnight, and showing \"00:00:00\" on every one of\n * those would be noise, not information.\n */\nfunction formatDatetime(value: number, locale: ILocale): string {\n const d = new Date(value);\n const dateStr = d.toLocaleDateString(locale.code, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" });\n const isMidnight = d.getHours() === 0 && d.getMinutes() === 0 && d.getSeconds() === 0 && d.getMilliseconds() === 0;\n if (isMidnight) return `= ${dateStr}`;\n return `= ${dateStr}, ${d.toLocaleTimeString(locale.code)}`;\n}\n\n/**\n * Renders a millisecond duration as clock-style `H:MM` (or `H:MM:SS` when\n * there's a non-zero seconds component). `ms` is never a user-typeable\n * unit (confirmed: it appears nowhere in `lexer/units.ts`), it's only\n * ever produced by subtracting two clock times/datetimes (`9:30 - 8:30`,\n * `VM.ts`'s Datetime SUB case), so this is a safe, narrow special case,\n * not a general change to how durations display.\n */\nfunction formatMsDuration(ms: number): string {\n const sign = ms < 0 ? \"-\" : \"\";\n const totalSeconds = Math.round(Math.abs(ms) / 1000);\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n const mm = String(minutes).padStart(2, \"0\");\n if (seconds === 0) return `${sign}${hours}:${mm}`;\n const ss = String(seconds).padStart(2, \"0\");\n return `${sign}${hours}:${mm}:${ss}`;\n}\n\nfunction formatUom(value: number, unit: string | undefined, locale: ILocale, settings: FormattingSettings): string {\n if (unit === \"ms\") return `= ${formatMsDuration(value)}`;\n\n const dp = settings.unitOfMeasurementResult.decimalPlaces;\n const useUnitNames = settings.unitOfMeasurementResult.unitNames;\n\n // For TimeSpan values (days, weeks, hours, etc.), format as integer if the value is a whole number\n const timeSpanUnits = [\"days\", \"weeks\", \"hours\", \"minutes\", \"seconds\", \"day\", \"week\", \"hour\", \"minute\", \"second\"];\n const isTimeSpan = unit && timeSpanUnits.includes(unit);\n\n let formatted: string;\n if (isTimeSpan && value === Math.floor(value)) {\n // For whole number TimeSpan values, format as integer\n formatted = value.toString();\n } else {\n // For other values, use the configured decimal places\n formatted = value.toFixed(dp);\n }\n\n // Currency display: symbol + culturally-conventional placement (e.g.\n // \"$100.00\" prefix vs \"100.00 kr\" suffix) instead of the generic\n // \"amount CODE\" fallback below. See uom/CurrencyAliases.ts's\n // CURRENCY_DISPLAY table for the exact set covered and the reasoning\n // behind each placement choice. Any currency code NOT in that table\n // (most of the ~150 `CurrencyExchange.isCurrency()` recognizes) falls\n // through to the unchanged \"amount CODE\" format below.\n const currencyDisplay = unit ? CURRENCY_DISPLAY[unit.toUpperCase()] : undefined;\n if (currencyDisplay) {\n const sep = currencyDisplay.spaced ? \" \" : \"\";\n const withSymbol = currencyDisplay.position === \"prefix\"\n ? `${currencyDisplay.symbol}${sep}${formatted}`\n : `${formatted}${sep}${currencyDisplay.symbol}`;\n return `= ${withSymbol}`;\n }\n\n const unitLabel = useUnitNames ? (unit || \"\") : (unit || \"\");\n return `= ${formatted} ${unitLabel}`.trim();\n}\n\nfunction formatMatrixEntry(entry: MatrixEntry, settings: FormattingSettings): string {\n if (typeof entry === \"boolean\") return entry ? \"true\" : \"false\";\n if (typeof entry === \"object\" && entry !== null) return formatSymbolic(entry);\n const dp = settings.floatResult.decimalPlaces;\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n return autoFormatIntegerOrFloat(entry, dp, sep, loc);\n}\n\n/**\n * Renders a Matrix matching its own literal syntax: a single row (1xN,\n * including plain vectors) as `[a, b, c]`, a single column (Nx1) as\n * `[a; b; c]`, and a general shape as `[r0c0, r0c1; r1c0, r1c1]`, row-major\n * textual output read back out of the column-major storage\n * (`columnMajorToRowMajor()`), matching how `[1,2;3,4]` is written.\n */\nfunction formatMatrix(m: MatrixData, locale: ILocale, settings: FormattingSettings): string {\n const rowMajor = columnMajorToRowMajor(m);\n const rows: string[] = [];\n for (let r = 0; r < m.rows; r++) {\n const cells: string[] = [];\n for (let c = 0; c < m.cols; c++) {\n cells.push(formatMatrixEntry(rowMajor[r * m.cols + c], settings));\n }\n rows.push(cells.join(\", \"));\n }\n return `${locale.display.resultPrefix}[${rows.join(\"; \")}]`;\n}\n\nfunction formatRange(min: number, max: number, locale: ILocale): string {\n return `${locale.display.resultPrefix}${min}:${max}`;\n}\n\nfunction formatPercentage(value: number, locale: ILocale, settings: FormattingSettings): string {\n // ValueType.Percentage stores a fraction (0.25 for 25%). See Value.ts's\n // documented contract and the sole producer, VM.ts's TO_PERCENTAGE opcode\n // (`right/left - 1`, e.g. 0.25 for \"800 to 1000\"). Multiply by 100 before\n // formatting; without this every percentage-change result displayed as\n // e.g. \"0.25%\" instead of \"25.00%\".\n const dp = settings.percentageResult.decimalPlaces;\n const formatted = (value * 100).toFixed(dp);\n return `= ${formatted}${locale.display.percentageSuffix}`;\n}\n\nfunction formatUnit(value: number, unit: string | undefined): string {\n return `= ${value} ${unit || \"\"}`.trim();\n}\n\n/**\n * Render an evaluated {@link Value} as a display string, dispatching on\n * `value.type` to the type-specific formatter (number, hex, datetime, unit\n * of measurement, matrix, range, percentage, ...).\n *\n * Most branches produce a `\"= \"`-prefixed result string (matching the\n * plugin's inline-result convention); `ValueType.Error` is the one\n * exception, it returns the human-readable error message directly\n * (stored in `value.unit`), not an `\"= \"`-prefixed string.\n *\n * @param value - The evaluated value to format.\n * @param settings - Locale/precision/separator options; defaults to\n * {@link DEFAULT_FORMATTING_SETTINGS} when omitted.\n * @example\n * ```typescript\n * const [value] = engine.evaluateExpression(\"10 USD to GBP\");\n * formatValue(value); // \"= £7.85\" (exact output depends on live exchange rates)\n * ```\n */\nexport function formatValue(value: Value, settings?: FormattingSettings): string {\n const us = settings || DEFAULT_FORMATTING_SETTINGS;\n const localeCode = us.numberResult.decimalSeparatorLocale || \"en\";\n const locale = getLocale(localeCode);\n\n switch (value.type) {\n case ValueType.Number:\n return formatNumber(value.value as number, locale, us);\n case ValueType.Hex:\n return formatHex(value.value as number, us, value.unit);\n case ValueType.BigInt:\n return formatBigInt(value.value as bigint);\n case ValueType.String:\n return formatString(value.value as string);\n case ValueType.Boolean:\n return formatBoolean(value.value as boolean);\n case ValueType.Datetime:\n return formatDatetime(value.value as number, locale);\n case ValueType.Uom:\n return formatUom(value.value as number, value.unit, locale, us);\n case ValueType.Matrix:\n return formatMatrix(value.value as MatrixData, locale, us);\n case ValueType.Range: {\n const r = value.value as RangeData;\n return formatRange(r.min, r.max, locale);\n }\n case ValueType.Symbolic:\n return formatSymbolic(value.value as SymbolicNode);\n case ValueType.Percentage:\n return formatPercentage(value.value as number, locale, us);\n case ValueType.Unit:\n return formatUnit(value.value as number, value.unit);\n case ValueType.Error:\n // errorValue(code, message) stores the human-readable message in\n // `.unit` (code goes in `.value`), falling through to the default\n // case here previously displayed the raw code (e.g.\n // \"CURRENCY_RATE_UNAVAILABLE\") instead of the actual message.\n return value.unit ?? String(value.value);\n default:\n return `= ${String(value.value)}`;\n }\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import { V as Value } from './Value-KtAQNHur.cjs';
2
+
3
+ /**
4
+ * Minimal formatting settings interface for the engine
5
+ * This allows the engine to format values without depending on app-specific settings
6
+ */
7
+ interface FormattingSettings {
8
+ floatResult: {
9
+ decimalPlaces: number;
10
+ enableSeperator: boolean;
11
+ };
12
+ numberResult: {
13
+ decimalSeparatorLocale: string;
14
+ };
15
+ hexResult: {
16
+ enablePadding: boolean;
17
+ paddingZeros: number;
18
+ };
19
+ unitOfMeasurementResult: {
20
+ decimalPlaces: number;
21
+ unitNames: boolean;
22
+ };
23
+ percentageResult: {
24
+ decimalPlaces: number;
25
+ };
26
+ }
27
+ /** Formatting used when a host supplies none. */
28
+ declare const DEFAULT_FORMATTING_SETTINGS: FormattingSettings;
29
+
30
+ /**
31
+ * Render an evaluated {@link Value} as a display string, dispatching on
32
+ * `value.type` to the type-specific formatter (number, hex, datetime, unit
33
+ * of measurement, matrix, range, percentage, ...).
34
+ *
35
+ * Most branches produce a `"= "`-prefixed result string (matching the
36
+ * plugin's inline-result convention); `ValueType.Error` is the one
37
+ * exception, it returns the human-readable error message directly
38
+ * (stored in `value.unit`), not an `"= "`-prefixed string.
39
+ *
40
+ * @param value - The evaluated value to format.
41
+ * @param settings - Locale/precision/separator options; defaults to
42
+ * {@link DEFAULT_FORMATTING_SETTINGS} when omitted.
43
+ * @example
44
+ * ```typescript
45
+ * const [value] = engine.evaluateExpression("10 USD to GBP");
46
+ * formatValue(value); // "= £7.85" (exact output depends on live exchange rates)
47
+ * ```
48
+ */
49
+ declare function formatValue(value: Value, settings?: FormattingSettings): string;
50
+
51
+ export { DEFAULT_FORMATTING_SETTINGS, type FormattingSettings, formatValue };
@@ -0,0 +1,51 @@
1
+ import { V as Value } from './Value-KtAQNHur.js';
2
+
3
+ /**
4
+ * Minimal formatting settings interface for the engine
5
+ * This allows the engine to format values without depending on app-specific settings
6
+ */
7
+ interface FormattingSettings {
8
+ floatResult: {
9
+ decimalPlaces: number;
10
+ enableSeperator: boolean;
11
+ };
12
+ numberResult: {
13
+ decimalSeparatorLocale: string;
14
+ };
15
+ hexResult: {
16
+ enablePadding: boolean;
17
+ paddingZeros: number;
18
+ };
19
+ unitOfMeasurementResult: {
20
+ decimalPlaces: number;
21
+ unitNames: boolean;
22
+ };
23
+ percentageResult: {
24
+ decimalPlaces: number;
25
+ };
26
+ }
27
+ /** Formatting used when a host supplies none. */
28
+ declare const DEFAULT_FORMATTING_SETTINGS: FormattingSettings;
29
+
30
+ /**
31
+ * Render an evaluated {@link Value} as a display string, dispatching on
32
+ * `value.type` to the type-specific formatter (number, hex, datetime, unit
33
+ * of measurement, matrix, range, percentage, ...).
34
+ *
35
+ * Most branches produce a `"= "`-prefixed result string (matching the
36
+ * plugin's inline-result convention); `ValueType.Error` is the one
37
+ * exception, it returns the human-readable error message directly
38
+ * (stored in `value.unit`), not an `"= "`-prefixed string.
39
+ *
40
+ * @param value - The evaluated value to format.
41
+ * @param settings - Locale/precision/separator options; defaults to
42
+ * {@link DEFAULT_FORMATTING_SETTINGS} when omitted.
43
+ * @example
44
+ * ```typescript
45
+ * const [value] = engine.evaluateExpression("10 USD to GBP");
46
+ * formatValue(value); // "= £7.85" (exact output depends on live exchange rates)
47
+ * ```
48
+ */
49
+ declare function formatValue(value: Value, settings?: FormattingSettings): string;
50
+
51
+ export { DEFAULT_FORMATTING_SETTINGS, type FormattingSettings, formatValue };