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.
- package/dist/BytecodeBuilder-3egMyuDi.d.cts +274 -0
- package/dist/BytecodeBuilder-3egMyuDi.d.ts +274 -0
- package/dist/Configuration-fVpd-HC-.d.cts +228 -0
- package/dist/Configuration-fVpd-HC-.d.ts +228 -0
- package/dist/EngineError-DvPSnhZi.d.cts +304 -0
- package/dist/EngineError-DvPSnhZi.d.ts +304 -0
- package/dist/Lexer-BJdhlnej.d.cts +531 -0
- package/dist/Lexer-D9l4Yrk2.d.ts +531 -0
- package/dist/NormalizerRule-BrVoVjmP.d.cts +163 -0
- package/dist/NormalizerRule-CEjf1FyD.d.ts +163 -0
- package/dist/PackageRegistry-D-Tv_7ca.d.cts +2572 -0
- package/dist/PackageRegistry-DaH4aIKP.d.ts +2572 -0
- package/dist/Parselet-CK8cQu2a.d.cts +299 -0
- package/dist/Parselet-ConOIdRO.d.ts +299 -0
- package/dist/ScopeManager-B5k0nk05.d.ts +559 -0
- package/dist/ScopeManager-CKfQtl7l.d.cts +559 -0
- package/dist/Token-0jpvUdPY.d.cts +245 -0
- package/dist/Token-0jpvUdPY.d.ts +245 -0
- package/dist/VMCheckpoints-BmDwIXgK.d.ts +171 -0
- package/dist/VMCheckpoints-CqFuLwrT.d.cts +171 -0
- package/dist/Value-KtAQNHur.d.cts +295 -0
- package/dist/Value-KtAQNHur.d.ts +295 -0
- package/dist/chunk-2RWAXT6O.js +3 -0
- package/dist/chunk-2RWAXT6O.js.map +1 -0
- package/dist/chunk-34RRD7PC.js +1492 -0
- package/dist/chunk-34RRD7PC.js.map +1 -0
- package/dist/chunk-3PPFLFH4.js +5097 -0
- package/dist/chunk-3PPFLFH4.js.map +1 -0
- package/dist/chunk-3VGDNEE3.js +84 -0
- package/dist/chunk-3VGDNEE3.js.map +1 -0
- package/dist/chunk-3YNVWKR2.cjs +370 -0
- package/dist/chunk-3YNVWKR2.cjs.map +1 -0
- package/dist/chunk-47LRVGOT.cjs +316 -0
- package/dist/chunk-47LRVGOT.cjs.map +1 -0
- package/dist/chunk-4MG4XKO2.js +1644 -0
- package/dist/chunk-4MG4XKO2.js.map +1 -0
- package/dist/chunk-4QADQTWS.js +2392 -0
- package/dist/chunk-4QADQTWS.js.map +1 -0
- package/dist/chunk-53B6KDDJ.cjs +1651 -0
- package/dist/chunk-53B6KDDJ.cjs.map +1 -0
- package/dist/chunk-5X2PTP6F.cjs +104 -0
- package/dist/chunk-5X2PTP6F.cjs.map +1 -0
- package/dist/chunk-5YEMOYSE.js +264 -0
- package/dist/chunk-5YEMOYSE.js.map +1 -0
- package/dist/chunk-64W6GLLZ.js +481 -0
- package/dist/chunk-64W6GLLZ.js.map +1 -0
- package/dist/chunk-6BKTCEUP.cjs +233 -0
- package/dist/chunk-6BKTCEUP.cjs.map +1 -0
- package/dist/chunk-6NTVRDQV.cjs +1642 -0
- package/dist/chunk-6NTVRDQV.cjs.map +1 -0
- package/dist/chunk-6RDSQURE.js +290 -0
- package/dist/chunk-6RDSQURE.js.map +1 -0
- package/dist/chunk-75JP4BZX.js +93 -0
- package/dist/chunk-75JP4BZX.js.map +1 -0
- package/dist/chunk-B7LXJ6LC.cjs +36 -0
- package/dist/chunk-B7LXJ6LC.cjs.map +1 -0
- package/dist/chunk-BVAR5J2F.js +257 -0
- package/dist/chunk-BVAR5J2F.js.map +1 -0
- package/dist/chunk-C4XZV6E7.cjs +269 -0
- package/dist/chunk-C4XZV6E7.cjs.map +1 -0
- package/dist/chunk-CCJPSHGI.cjs +40 -0
- package/dist/chunk-CCJPSHGI.cjs.map +1 -0
- package/dist/chunk-CLL7RUQV.cjs +316 -0
- package/dist/chunk-CLL7RUQV.cjs.map +1 -0
- package/dist/chunk-DM3LMRBC.js +329 -0
- package/dist/chunk-DM3LMRBC.js.map +1 -0
- package/dist/chunk-DUEZFTK2.js +38 -0
- package/dist/chunk-DUEZFTK2.js.map +1 -0
- package/dist/chunk-EBSPLUW4.cjs +489 -0
- package/dist/chunk-EBSPLUW4.cjs.map +1 -0
- package/dist/chunk-EHAHVROS.cjs +261 -0
- package/dist/chunk-EHAHVROS.cjs.map +1 -0
- package/dist/chunk-EIGTWK5N.js +167 -0
- package/dist/chunk-EIGTWK5N.js.map +1 -0
- package/dist/chunk-EPOXXJBK.js +96 -0
- package/dist/chunk-EPOXXJBK.js.map +1 -0
- package/dist/chunk-FEAIOR7N.cjs +91 -0
- package/dist/chunk-FEAIOR7N.cjs.map +1 -0
- package/dist/chunk-G535KJEG.js +312 -0
- package/dist/chunk-G535KJEG.js.map +1 -0
- package/dist/chunk-GCM5JHMX.js +88 -0
- package/dist/chunk-GCM5JHMX.js.map +1 -0
- package/dist/chunk-GOLDJNMZ.js +368 -0
- package/dist/chunk-GOLDJNMZ.js.map +1 -0
- package/dist/chunk-GW32KPCU.cjs +360 -0
- package/dist/chunk-GW32KPCU.cjs.map +1 -0
- package/dist/chunk-HTXVVJRA.cjs +1549 -0
- package/dist/chunk-HTXVVJRA.cjs.map +1 -0
- package/dist/chunk-HWSZJQCI.js +311 -0
- package/dist/chunk-HWSZJQCI.js.map +1 -0
- package/dist/chunk-IF532O7C.js +101 -0
- package/dist/chunk-IF532O7C.js.map +1 -0
- package/dist/chunk-J73SJHR3.cjs +2415 -0
- package/dist/chunk-J73SJHR3.cjs.map +1 -0
- package/dist/chunk-JBSYC7BB.cjs +7473 -0
- package/dist/chunk-JBSYC7BB.cjs.map +1 -0
- package/dist/chunk-KVILKGMS.js +228 -0
- package/dist/chunk-KVILKGMS.js.map +1 -0
- package/dist/chunk-LIPPNDBE.js +258 -0
- package/dist/chunk-LIPPNDBE.js.map +1 -0
- package/dist/chunk-LR7YASZF.cjs +172 -0
- package/dist/chunk-LR7YASZF.cjs.map +1 -0
- package/dist/chunk-M4N5GA5Z.cjs +309 -0
- package/dist/chunk-M4N5GA5Z.cjs.map +1 -0
- package/dist/chunk-M5LX5AOO.js +7459 -0
- package/dist/chunk-M5LX5AOO.js.map +1 -0
- package/dist/chunk-MZOVP3WI.cjs +96 -0
- package/dist/chunk-MZOVP3WI.cjs.map +1 -0
- package/dist/chunk-N5YFR4UP.cjs +10 -0
- package/dist/chunk-N5YFR4UP.cjs.map +1 -0
- package/dist/chunk-NGBBNL4K.cjs +4 -0
- package/dist/chunk-NGBBNL4K.cjs.map +1 -0
- package/dist/chunk-NH2O2AUR.js +146 -0
- package/dist/chunk-NH2O2AUR.js.map +1 -0
- package/dist/chunk-NLNDMWZC.js +31 -0
- package/dist/chunk-NLNDMWZC.js.map +1 -0
- package/dist/chunk-NMCRQP3Z.cjs +778 -0
- package/dist/chunk-NMCRQP3Z.cjs.map +1 -0
- package/dist/chunk-NMD5VRN4.cjs +1327 -0
- package/dist/chunk-NMD5VRN4.cjs.map +1 -0
- package/dist/chunk-OC6LTXYS.cjs +286 -0
- package/dist/chunk-OC6LTXYS.cjs.map +1 -0
- package/dist/chunk-OT6OJY7C.cjs +114 -0
- package/dist/chunk-OT6OJY7C.cjs.map +1 -0
- package/dist/chunk-PFSDGGYL.js +8 -0
- package/dist/chunk-PFSDGGYL.js.map +1 -0
- package/dist/chunk-QNJ4ACRT.cjs +155 -0
- package/dist/chunk-QNJ4ACRT.cjs.map +1 -0
- package/dist/chunk-QWY3VEZN.js +1637 -0
- package/dist/chunk-QWY3VEZN.js.map +1 -0
- package/dist/chunk-RFYD5TJE.js +111 -0
- package/dist/chunk-RFYD5TJE.js.map +1 -0
- package/dist/chunk-RIN643A3.js +354 -0
- package/dist/chunk-RIN643A3.js.map +1 -0
- package/dist/chunk-RZCWSXTA.cjs +5122 -0
- package/dist/chunk-RZCWSXTA.cjs.map +1 -0
- package/dist/chunk-SDGRK7EP.js +774 -0
- package/dist/chunk-SDGRK7EP.js.map +1 -0
- package/dist/chunk-VEKIWQ3F.cjs +39 -0
- package/dist/chunk-VEKIWQ3F.cjs.map +1 -0
- package/dist/chunk-WQTTOGXC.cjs +99 -0
- package/dist/chunk-WQTTOGXC.cjs.map +1 -0
- package/dist/chunk-X6K3HUOY.cjs +86 -0
- package/dist/chunk-X6K3HUOY.cjs.map +1 -0
- package/dist/chunk-XJCMXB2E.cjs +333 -0
- package/dist/chunk-XJCMXB2E.cjs.map +1 -0
- package/dist/chunk-XVWCOTR6.js +1324 -0
- package/dist/chunk-XVWCOTR6.js.map +1 -0
- package/dist/chunk-YLJ4XMA6.js +33 -0
- package/dist/chunk-YLJ4XMA6.js.map +1 -0
- package/dist/chunk-Z2XP767T.cjs +35 -0
- package/dist/chunk-Z2XP767T.cjs.map +1 -0
- package/dist/chunk-Z4X2RWOF.js +37 -0
- package/dist/chunk-Z4X2RWOF.js.map +1 -0
- package/dist/constants.cjs +22 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +12 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/engine.cjs +79 -0
- package/dist/engine.cjs.map +1 -0
- package/dist/engine.d.cts +587 -0
- package/dist/engine.d.ts +587 -0
- package/dist/engine.js +34 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.cjs +81 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +95 -0
- package/dist/errors.d.ts +95 -0
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -0
- package/dist/format.cjs +171 -0
- package/dist/format.cjs.map +1 -0
- package/dist/format.d.cts +51 -0
- package/dist/format.d.ts +51 -0
- package/dist/format.js +168 -0
- package/dist/format.js.map +1 -0
- package/dist/index.cjs +97 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +152 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/dist/language.cjs +308 -0
- package/dist/language.cjs.map +1 -0
- package/dist/language.d.cts +110 -0
- package/dist/language.d.ts +110 -0
- package/dist/language.js +287 -0
- package/dist/language.js.map +1 -0
- package/dist/lexer.cjs +64 -0
- package/dist/lexer.cjs.map +1 -0
- package/dist/lexer.d.cts +56 -0
- package/dist/lexer.d.ts +56 -0
- package/dist/lexer.js +11 -0
- package/dist/lexer.js.map +1 -0
- package/dist/normalizer.cjs +40 -0
- package/dist/normalizer.cjs.map +1 -0
- package/dist/normalizer.d.cts +364 -0
- package/dist/normalizer.d.ts +364 -0
- package/dist/normalizer.js +11 -0
- package/dist/normalizer.js.map +1 -0
- package/dist/packages.cjs +121 -0
- package/dist/packages.cjs.map +1 -0
- package/dist/packages.d.cts +691 -0
- package/dist/packages.d.ts +691 -0
- package/dist/packages.js +24 -0
- package/dist/packages.js.map +1 -0
- package/dist/parser.cjs +55 -0
- package/dist/parser.cjs.map +1 -0
- package/dist/parser.d.cts +46 -0
- package/dist/parser.d.ts +46 -0
- package/dist/parser.js +10 -0
- package/dist/parser.js.map +1 -0
- package/dist/pipeline-CrsRPmsv.d.ts +285 -0
- package/dist/pipeline-DPUQt7yL.d.cts +285 -0
- package/dist/resolvers.cjs +13 -0
- package/dist/resolvers.cjs.map +1 -0
- package/dist/resolvers.d.cts +111 -0
- package/dist/resolvers.d.ts +111 -0
- package/dist/resolvers.js +4 -0
- package/dist/resolvers.js.map +1 -0
- package/dist/services.cjs +21 -0
- package/dist/services.cjs.map +1 -0
- package/dist/services.d.cts +30 -0
- package/dist/services.d.ts +30 -0
- package/dist/services.js +4 -0
- package/dist/services.js.map +1 -0
- package/dist/uom.cjs +56 -0
- package/dist/uom.cjs.map +1 -0
- package/dist/uom.d.cts +224 -0
- package/dist/uom.d.ts +224 -0
- package/dist/uom.js +11 -0
- package/dist/uom.js.map +1 -0
- package/dist/utilities.cjs +32 -0
- package/dist/utilities.cjs.map +1 -0
- package/dist/utilities.d.cts +113 -0
- package/dist/utilities.d.ts +113 -0
- package/dist/utilities.js +7 -0
- package/dist/utilities.js.map +1 -0
- package/dist/variables.cjs +17 -0
- package/dist/variables.cjs.map +1 -0
- package/dist/variables.d.cts +87 -0
- package/dist/variables.d.ts +87 -0
- package/dist/variables.js +4 -0
- package/dist/variables.js.map +1 -0
- package/dist/vm.cjs +284 -0
- package/dist/vm.cjs.map +1 -0
- package/dist/vm.d.cts +68 -0
- package/dist/vm.d.ts +68 -0
- package/dist/vm.js +194 -0
- package/dist/vm.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// src/errors/EngineError.ts
|
|
2
|
+
var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => {
|
|
3
|
+
ErrorCategory2["PARSING"] = "PARSING";
|
|
4
|
+
ErrorCategory2["EXECUTION"] = "EXECUTION";
|
|
5
|
+
ErrorCategory2["VALIDATION"] = "VALIDATION";
|
|
6
|
+
ErrorCategory2["EXTERNAL"] = "EXTERNAL";
|
|
7
|
+
ErrorCategory2["INTERNAL"] = "INTERNAL";
|
|
8
|
+
ErrorCategory2["CONFIG"] = "CONFIG";
|
|
9
|
+
return ErrorCategory2;
|
|
10
|
+
})(ErrorCategory || {});
|
|
11
|
+
var EngineError = class _EngineError extends Error {
|
|
12
|
+
constructor(category, init) {
|
|
13
|
+
super(init.message);
|
|
14
|
+
this.name = "EngineError";
|
|
15
|
+
this.category = category;
|
|
16
|
+
this.code = init.code;
|
|
17
|
+
this.expected = init.expected;
|
|
18
|
+
this.found = init.found;
|
|
19
|
+
this.suggestion = init.suggestion;
|
|
20
|
+
this.recoverable = init.recoverable ?? true;
|
|
21
|
+
this.span = init.span;
|
|
22
|
+
this.context = init.context;
|
|
23
|
+
this.cause = init.cause;
|
|
24
|
+
this.timestamp = /* @__PURE__ */ new Date();
|
|
25
|
+
if (Error.captureStackTrace) {
|
|
26
|
+
Error.captureStackTrace(this, _EngineError);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** `!recoverable`. See `EngineErrorInit.recoverable`'s doc comment for what this actually gates (message framing/telemetry, not whether evaluation continues). */
|
|
30
|
+
isFatal() {
|
|
31
|
+
return !this.recoverable;
|
|
32
|
+
}
|
|
33
|
+
/** Walk `.cause` repeatedly, collecting the full chain (this error first). */
|
|
34
|
+
causeChain() {
|
|
35
|
+
const chain = [this];
|
|
36
|
+
let current = this.cause;
|
|
37
|
+
while (current !== void 0 && current !== null) {
|
|
38
|
+
chain.push(current);
|
|
39
|
+
current = current instanceof Error ? current.cause : void 0;
|
|
40
|
+
}
|
|
41
|
+
return chain;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Rust/Go-style multi-line renderer, the NEW thing a host/CLI/test
|
|
45
|
+
* reaches for when it wants the full, verbose picture, as distinct from
|
|
46
|
+
* `.message` (kept short and stable for existing assertions). Example:
|
|
47
|
+
*
|
|
48
|
+
* ```
|
|
49
|
+
* error[WEATHER_EXPECTED_CITY]: Expected a city name after "weather in"
|
|
50
|
+
* expected: a city name
|
|
51
|
+
* found: end of expression
|
|
52
|
+
* suggestion: e.g. "weather in London"
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
format() {
|
|
56
|
+
const lines = [`error[${this.code}]: ${this.message}`];
|
|
57
|
+
if (this.expected) lines.push(` expected: ${this.expected}`);
|
|
58
|
+
if (this.found) lines.push(` found: ${this.found}`);
|
|
59
|
+
if (this.suggestion) lines.push(` suggestion: ${this.suggestion}`);
|
|
60
|
+
return lines.join("\n");
|
|
61
|
+
}
|
|
62
|
+
toJSON() {
|
|
63
|
+
return {
|
|
64
|
+
name: this.name,
|
|
65
|
+
category: this.category,
|
|
66
|
+
code: this.code,
|
|
67
|
+
message: this.message,
|
|
68
|
+
expected: this.expected,
|
|
69
|
+
found: this.found,
|
|
70
|
+
suggestion: this.suggestion,
|
|
71
|
+
recoverable: this.recoverable,
|
|
72
|
+
span: this.span,
|
|
73
|
+
context: this.context,
|
|
74
|
+
timestamp: this.timestamp.toISOString()
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var ErrorFactory = class _ErrorFactory {
|
|
79
|
+
static build(category, defaultRecoverable, codeOrInit, message, context) {
|
|
80
|
+
const init = typeof codeOrInit === "string" ? { code: codeOrInit, message, context } : codeOrInit;
|
|
81
|
+
return new EngineError(category, { recoverable: defaultRecoverable, ...init });
|
|
82
|
+
}
|
|
83
|
+
static validation(codeOrInit, message, context) {
|
|
84
|
+
return _ErrorFactory.build("VALIDATION" /* VALIDATION */, true, codeOrInit, message, context);
|
|
85
|
+
}
|
|
86
|
+
static parsing(codeOrInit, message, context) {
|
|
87
|
+
return _ErrorFactory.build("PARSING" /* PARSING */, true, codeOrInit, message, context);
|
|
88
|
+
}
|
|
89
|
+
static execution(codeOrInit, message, context) {
|
|
90
|
+
return _ErrorFactory.build("EXECUTION" /* EXECUTION */, true, codeOrInit, message, context);
|
|
91
|
+
}
|
|
92
|
+
static external(codeOrInit, message, context) {
|
|
93
|
+
return _ErrorFactory.build("EXTERNAL" /* EXTERNAL */, true, codeOrInit, message, context);
|
|
94
|
+
}
|
|
95
|
+
static internal(codeOrInit, message, context) {
|
|
96
|
+
return _ErrorFactory.build("INTERNAL" /* INTERNAL */, false, codeOrInit, message, context);
|
|
97
|
+
}
|
|
98
|
+
static config(codeOrInit, message, context) {
|
|
99
|
+
return _ErrorFactory.build("CONFIG" /* CONFIG */, false, codeOrInit, message, context);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
function normalizeUnknownError(error) {
|
|
103
|
+
if (error instanceof EngineError) return error;
|
|
104
|
+
if (error instanceof Error) {
|
|
105
|
+
return ErrorFactory.internal({
|
|
106
|
+
code: "UNEXPECTED_ERROR",
|
|
107
|
+
message: error.message,
|
|
108
|
+
context: { originalErrorName: error.name },
|
|
109
|
+
cause: error
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return ErrorFactory.internal({
|
|
113
|
+
code: "UNKNOWN_ERROR",
|
|
114
|
+
message: "An unknown error occurred",
|
|
115
|
+
context: { error: String(error) }
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/errors/Result.ts
|
|
120
|
+
function ok(value) {
|
|
121
|
+
return { ok: true, value };
|
|
122
|
+
}
|
|
123
|
+
function err(error) {
|
|
124
|
+
return { ok: false, error };
|
|
125
|
+
}
|
|
126
|
+
function isOk(r) {
|
|
127
|
+
return r.ok;
|
|
128
|
+
}
|
|
129
|
+
function isErr(r) {
|
|
130
|
+
return !r.ok;
|
|
131
|
+
}
|
|
132
|
+
function map(r, fn) {
|
|
133
|
+
return r.ok ? ok(fn(r.value)) : r;
|
|
134
|
+
}
|
|
135
|
+
function mapErr(r, fn) {
|
|
136
|
+
return r.ok ? r : err(fn(r.error));
|
|
137
|
+
}
|
|
138
|
+
function andThen(r, fn) {
|
|
139
|
+
return r.ok ? fn(r.value) : r;
|
|
140
|
+
}
|
|
141
|
+
function unwrapOr(r, fallback) {
|
|
142
|
+
return r.ok ? r.value : fallback;
|
|
143
|
+
}
|
|
144
|
+
function match(r, arms) {
|
|
145
|
+
return r.ok ? arms.ok(r.value) : arms.err(r.error);
|
|
146
|
+
}
|
|
147
|
+
function combine(results) {
|
|
148
|
+
const values = [];
|
|
149
|
+
for (const r of results) {
|
|
150
|
+
if (!r.ok) return r;
|
|
151
|
+
values.push(r.value);
|
|
152
|
+
}
|
|
153
|
+
return ok(values);
|
|
154
|
+
}
|
|
155
|
+
function throwIfErr(r) {
|
|
156
|
+
if (r.ok) return r.value;
|
|
157
|
+
throw r.error;
|
|
158
|
+
}
|
|
159
|
+
function tryCatch(fn, normalize = normalizeUnknownError) {
|
|
160
|
+
try {
|
|
161
|
+
return ok(fn());
|
|
162
|
+
} catch (e) {
|
|
163
|
+
return err(normalize(e));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function tryCatchAsync(fn, normalize = normalizeUnknownError) {
|
|
167
|
+
try {
|
|
168
|
+
return ok(await fn());
|
|
169
|
+
} catch (e) {
|
|
170
|
+
return err(normalize(e));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/errors/ErrorCode.ts
|
|
175
|
+
var CoreErrorCodes = {
|
|
176
|
+
// ── Parser (parser/PrecedenceParser.ts, parser/BytecodeBuilder.ts, parser/PhrasePattern.ts) ──
|
|
177
|
+
INVALID_NUMBER_LITERAL: "INVALID_NUMBER_LITERAL",
|
|
178
|
+
NO_PREFIX_PARSELET: "NO_PREFIX_PARSELET",
|
|
179
|
+
UNEXPECTED_END_OF_INPUT: "UNEXPECTED_END_OF_INPUT",
|
|
180
|
+
UNEXPECTED_TOKEN_TYPE: "UNEXPECTED_TOKEN_TYPE",
|
|
181
|
+
NESTING_DEPTH_EXCEEDED: "NESTING_DEPTH_EXCEEDED",
|
|
182
|
+
UNEXPECTED_END: "UNEXPECTED_END",
|
|
183
|
+
UNEXPECTED_TRAILING_TOKEN: "UNEXPECTED_TRAILING_TOKEN",
|
|
184
|
+
PARSE_ERROR: "PARSE_ERROR",
|
|
185
|
+
TOO_MANY_NUMERIC_CONSTANTS: "TOO_MANY_NUMERIC_CONSTANTS",
|
|
186
|
+
TOO_MANY_STRING_CONSTANTS: "TOO_MANY_STRING_CONSTANTS",
|
|
187
|
+
NO_MATCHING_PHRASE_ALTERNATIVE: "NO_MATCHING_PHRASE_ALTERNATIVE",
|
|
188
|
+
INVALID_PHRASE_PATTERN: "INVALID_PHRASE_PATTERN",
|
|
189
|
+
PHRASE_KEYWORD_MISMATCH: "PHRASE_KEYWORD_MISMATCH",
|
|
190
|
+
/** User-defined-function definition parsing (`f(x, y) = ...`), an invalid token where a parameter name was expected. */
|
|
191
|
+
USER_FUNCTION_INVALID_PARAM_NAME: "USER_FUNCTION_INVALID_PARAM_NAME",
|
|
192
|
+
/** `f() = ...` with zero parameters, indistinguishable from a plain no-arg function call, so rejected at definition time. */
|
|
193
|
+
USER_FUNCTION_NO_PARAMS: "USER_FUNCTION_NO_PARAMS",
|
|
194
|
+
/** A user-defined function body calling an async plugin (weather/stocks/currency/...), rejected at definition time; v1 scope excludes async function bodies. */
|
|
195
|
+
FUNCTION_BODY_MUST_BE_SYNCHRONOUS: "FUNCTION_BODY_MUST_BE_SYNCHRONOUS",
|
|
196
|
+
/** `BytecodeBuilder`'s `userFunctionBodies` side-table exceeding its capacity. Same class as `TOO_MANY_NUMERIC_CONSTANTS`/`TOO_MANY_STRING_CONSTANTS` below. */
|
|
197
|
+
TOO_MANY_FUNCTION_DEFINITIONS: "TOO_MANY_FUNCTION_DEFINITIONS",
|
|
198
|
+
/** `BytecodeBuilder`'s `anonymousBodies` side-table (map/reduce inline transform bodies) exceeding its capacity. Same class as `TOO_MANY_FUNCTION_DEFINITIONS` above. */
|
|
199
|
+
TOO_MANY_ANONYMOUS_BODIES: "TOO_MANY_ANONYMOUS_BODIES",
|
|
200
|
+
// ── VM (vm/VM.ts, vm/OpRegistry.ts, vm/VMBuiltins.ts) ──
|
|
201
|
+
EVALUATION_ERROR: "EVALUATION_ERROR",
|
|
202
|
+
INSTRUCTION_LIMIT_EXCEEDED: "INSTRUCTION_LIMIT_EXCEEDED",
|
|
203
|
+
STACK_LIMIT_EXCEEDED: "STACK_LIMIT_EXCEEDED",
|
|
204
|
+
/** New this phase. See `VM.ts`'s `safePop()`: a stack-underflow (corrupted bytecode, a buggy plugin) is now a controlled EngineError instead of a raw TypeError. Always `recoverable: false` (internal invariant violation). */
|
|
205
|
+
STACK_UNDERFLOW: "STACK_UNDERFLOW",
|
|
206
|
+
UNDEFINED_VARIABLE: "UNDEFINED_VARIABLE",
|
|
207
|
+
/** New this phase, the Tier-2/`LOAD_GLOBAL_VAR` hardening: a global variable read before its async preflight resolved, surfaced as a controlled error instead of pushing `undefined`. */
|
|
208
|
+
GLOBAL_VARIABLE_NOT_RESOLVED: "GLOBAL_VARIABLE_NOT_RESOLVED",
|
|
209
|
+
UNKNOWN_FUNCTION: "UNKNOWN_FUNCTION",
|
|
210
|
+
/** `unwrapEvalResult()`'s pending-when-expecting-value case, a caller-contract violation, not user-input. */
|
|
211
|
+
UNEXPECTED_PENDING_RESULT: "UNEXPECTED_PENDING_RESULT",
|
|
212
|
+
/** User-defined-function call/definition errors (`CALL_USER_FUNCTION`/`DEFINE_USER_FUNCTION` opcodes), calling a name with no matching definition, calling with the wrong argument count, and the deliberate v1 restriction that a function body can't itself contain async work. */
|
|
213
|
+
UNDEFINED_FUNCTION: "UNDEFINED_FUNCTION",
|
|
214
|
+
FUNCTION_ARITY_MISMATCH: "FUNCTION_ARITY_MISMATCH",
|
|
215
|
+
USER_FUNCTION_ASYNC_UNSUPPORTED: "USER_FUNCTION_ASYNC_UNSUPPORTED",
|
|
216
|
+
/** A map/reduce transform body (inline expression or user-defined function) calling an async plugin. Same v1 scope restriction as `USER_FUNCTION_ASYNC_UNSUPPORTED` above, enforced both at parse time (`MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS`, packages/mapreduce/) and as a defense-in-depth runtime backstop here. */
|
|
217
|
+
MAP_REDUCE_ASYNC_UNSUPPORTED: "MAP_REDUCE_ASYNC_UNSUPPORTED",
|
|
218
|
+
/** `pushCallFrame()`'s recursion guard, a nested `CALL_USER_FUNCTION` re-enters `executeBytecode()`, so `maxInstructions` alone can't catch e.g. `f(x) = f(x)`; this is the dedicated backstop. `recoverable: true` (the default for `.execution()`), ordinary user-written infinite recursion, not an engine bug; the guard exists precisely so it surfaces as a clear error instead of overflowing the native call stack uncatchably. */
|
|
219
|
+
FUNCTION_RECURSION_LIMIT_EXCEEDED: "FUNCTION_RECURSION_LIMIT_EXCEEDED",
|
|
220
|
+
/** `DEFINE_USER_FUNCTION`'s body-index lookup failing, a compiler/VM invariant violation (the opcode stream referenced a `userFunctionBodies` slot that doesn't exist), never a user-input error. */
|
|
221
|
+
INTERNAL_MISSING_FUNCTION_BODY: "INTERNAL_MISSING_FUNCTION_BODY",
|
|
222
|
+
/** `MAP_INVOKE`/`REDUCE_INVOKE`'s anonymous-body-index lookup failing. Same class as `INTERNAL_MISSING_FUNCTION_BODY` above, for the `anonymousBodies` side-table instead of `userFunctionBodies`. */
|
|
223
|
+
INTERNAL_MISSING_ANONYMOUS_BODY: "INTERNAL_MISSING_ANONYMOUS_BODY",
|
|
224
|
+
// ── Symbolic algebra (symbolic/, vm/SymbolicOps.ts) ──
|
|
225
|
+
/** A coefficient grew past `RATIONAL_MAX_BITS`, e.g. repeated exact elimination multiplying denominators together. */
|
|
226
|
+
SYMBOLIC_RATIONAL_OVERFLOW: "SYMBOLIC_RATIONAL_OVERFLOW",
|
|
227
|
+
/** `NaN` or `±Infinity` reaching a symbolic expression, neither of which has an exact rational value. */
|
|
228
|
+
SYMBOLIC_NONFINITE_OPERAND: "SYMBOLIC_NONFINITE_OPERAND",
|
|
229
|
+
/** Division by an exactly-zero rational. Exact, unlike the double comparison it replaced, which could not distinguish a true zero from `5.551e-17`. */
|
|
230
|
+
SYMBOLIC_DIVISION_BY_ZERO: "SYMBOLIC_DIVISION_BY_ZERO",
|
|
231
|
+
/** A tree exceeding `SYMBOLIC_MAX_NODES` entering the simplifier. */
|
|
232
|
+
SYMBOLIC_NODE_LIMIT_EXCEEDED: "SYMBOLIC_NODE_LIMIT_EXCEEDED",
|
|
233
|
+
/** A builtin with no symbolic reading (`min`, `random`, the finance block, ...) applied to an expression still containing an unknown. Returned rather than computing against `toNumber()`'s placeholder zero. */
|
|
234
|
+
SYMBOLIC_UNSUPPORTED_FUNCTION: "SYMBOLIC_UNSUPPORTED_FUNCTION",
|
|
235
|
+
/** The rational-root search exceeding `FACTOR_MAX_ROOT_CANDIDATES`. The candidate set is the product of two divisor sets, so a highly-composite coefficient escapes quickly. */
|
|
236
|
+
SYMBOLIC_FACTOR_LIMIT_EXCEEDED: "SYMBOLIC_FACTOR_LIMIT_EXCEEDED",
|
|
237
|
+
/** An equation outside what the solver attempts: not a polynomial, above the degree ceiling, or non-linear in the unknown while another unknown is present. */
|
|
238
|
+
SYMBOLIC_SOLVE_UNSUPPORTED: "SYMBOLIC_SOLVE_UNSUPPORTED",
|
|
239
|
+
/** `solve`'s second argument not being a bare name. */
|
|
240
|
+
SOLVE_REQUIRES_VARIABLE_NAME: "SOLVE_REQUIRES_VARIABLE_NAME",
|
|
241
|
+
/** A derivative order outside 0..`DERIVATIVE_MAX_ORDER`. */
|
|
242
|
+
SYMBOLIC_DERIVATIVE_ORDER_LIMIT: "SYMBOLIC_DERIVATIVE_ORDER_LIMIT",
|
|
243
|
+
/** An expression with no known elementary antiderivative. Reported rather than approximated, since a wrong integral is indistinguishable from a right one at the point of use. */
|
|
244
|
+
SYMBOLIC_INTEGRAL_UNSUPPORTED: "SYMBOLIC_INTEGRAL_UNSUPPORTED",
|
|
245
|
+
/** A Taylor degree outside 0..`TAYLOR_MAX_DEGREE`. */
|
|
246
|
+
SYMBOLIC_TAYLOR_DEGREE_LIMIT: "SYMBOLIC_TAYLOR_DEGREE_LIMIT",
|
|
247
|
+
/** A Taylor coefficient that does not reduce to an exact number at the expansion point. */
|
|
248
|
+
SYMBOLIC_TAYLOR_INEXACT: "SYMBOLIC_TAYLOR_INEXACT",
|
|
249
|
+
/** An algebra verb's variable-name argument not being a bare name. */
|
|
250
|
+
SYMBOLIC_REQUIRES_VARIABLE_NAME: "SYMBOLIC_REQUIRES_VARIABLE_NAME",
|
|
251
|
+
/** `jacobian` called with expressions containing no unknown to differentiate against. */
|
|
252
|
+
SYMBOLIC_JACOBIAN_NO_VARIABLES: "SYMBOLIC_JACOBIAN_NO_VARIABLES",
|
|
253
|
+
/** A finite number whose decimal form could not be read back, which the regex covering every `Number.prototype.toString` output should make unreachable. */
|
|
254
|
+
INTERNAL_RATIONAL_PARSE: "INTERNAL_RATIONAL_PARSE",
|
|
255
|
+
// ── Engine (engine/ExpressionEngine.ts, engine/ExpressionEngineSafety.ts, engine/AsyncResolutionBatcher.ts) ──
|
|
256
|
+
EXPRESSION_TOO_LONG: "EXPRESSION_TOO_LONG",
|
|
257
|
+
EXPRESSION_TOO_COMPLEX: "EXPRESSION_TOO_COMPLEX",
|
|
258
|
+
NORMALIZED_TOKEN_LIMIT_EXCEEDED: "NORMALIZED_TOKEN_LIMIT_EXCEEDED",
|
|
259
|
+
/** `"=>"` with nothing before it, needs an expression or variable name to solve/simplify. */
|
|
260
|
+
THEREFORE_REQUIRES_EXPRESSION: "THEREFORE_REQUIRES_EXPRESSION",
|
|
261
|
+
/** A `"=>"`-triggered expression called an async plugin (weather/stocks/currency). Same v1 scope restriction as user-function/map-reduce bodies. */
|
|
262
|
+
THEREFORE_ASYNC_UNSUPPORTED: "THEREFORE_ASYNC_UNSUPPORTED",
|
|
263
|
+
// ── Config (constants/Configuration.ts) ──
|
|
264
|
+
CONFIG_PATH_NOT_FOUND: "CONFIG_PATH_NOT_FOUND",
|
|
265
|
+
INVALID_CONFIG_PATH: "INVALID_CONFIG_PATH",
|
|
266
|
+
CONFIG_SECTION_NOT_FOUND: "CONFIG_SECTION_NOT_FOUND",
|
|
267
|
+
CONFIG_PROPERTY_NOT_FOUND: "CONFIG_PROPERTY_NOT_FOUND",
|
|
268
|
+
// ── Package/lexer registration-time collisions (lexer/ExpressionLexer.ts) ──
|
|
269
|
+
PLUGIN_OPERATOR_COLLISION: "PLUGIN_OPERATOR_COLLISION",
|
|
270
|
+
PLUGIN_KEYWORD_COLLISION: "PLUGIN_KEYWORD_COLLISION",
|
|
271
|
+
PLUGIN_UNIT_COLLISION: "PLUGIN_UNIT_COLLISION",
|
|
272
|
+
/** A package's declared `IEnginePackage.engineVersion` semver range doesn't satisfy the running engine's ENGINE_VERSION. See api/EngineVersionCompatibility.ts. */
|
|
273
|
+
PACKAGE_ENGINE_VERSION_MISMATCH: "PACKAGE_ENGINE_VERSION_MISMATCH",
|
|
274
|
+
/** A package's declared `IEnginePackage.engineVersion` isn't a parseable semver range at all (a typo in the package's own descriptor). */
|
|
275
|
+
PACKAGE_ENGINE_VERSION_INVALID_RANGE: "PACKAGE_ENGINE_VERSION_INVALID_RANGE",
|
|
276
|
+
/** `OpRegistry.allocateOpcode()`'s dynamic opcode pool (started at 201) exhausted, too many packages calling it. */
|
|
277
|
+
OPCODE_POOL_EXHAUSTED: "OPCODE_POOL_EXHAUSTED",
|
|
278
|
+
/** `VMBuiltins.allocatePluginFunctionIndex()`'s 0-255 index pool (a single opcode-stream byte) exhausted. */
|
|
279
|
+
PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED: "PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED",
|
|
280
|
+
// ── vm/Value.ts caller-contract violations (check isRateUnit()/isTimecodeUnit() first) ──
|
|
281
|
+
INVALID_RATE_UNIT: "INVALID_RATE_UNIT",
|
|
282
|
+
INVALID_TIMECODE_UNIT: "INVALID_TIMECODE_UNIT",
|
|
283
|
+
// ── errors/EngineError.ts's own fallback normalization ──
|
|
284
|
+
UNEXPECTED_ERROR: "UNEXPECTED_ERROR",
|
|
285
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export { CoreErrorCodes, EngineError, ErrorCategory, ErrorFactory, andThen, combine, err, isErr, isOk, map, mapErr, match, normalizeUnknownError, ok, throwIfErr, tryCatch, tryCatchAsync, unwrapOr };
|
|
289
|
+
//# sourceMappingURL=chunk-6RDSQURE.js.map
|
|
290
|
+
//# sourceMappingURL=chunk-6RDSQURE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors/EngineError.ts","../src/errors/Result.ts","../src/errors/ErrorCode.ts"],"names":["ErrorCategory"],"mappings":";AA6BO,IAAK,aAAA,qBAAAA,cAAAA,KAAL;AAEL,EAAAA,eAAA,SAAA,CAAA,GAAU,SAAA;AAEV,EAAAA,eAAA,WAAA,CAAA,GAAY,WAAA;AAEZ,EAAAA,eAAA,YAAA,CAAA,GAAa,YAAA;AAEb,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AAEX,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AAEX,EAAAA,eAAA,QAAA,CAAA,GAAS,QAAA;AAZC,EAAA,OAAAA,cAAAA;AAAA,CAAA,EAAA,aAAA,IAAA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C,oCAAA,EAAsC,sCAAA;AAAA;AAAA,EAEtC,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAEvB,oCAAA,EAAsC,sCAAA;AAAA;AAAA,EAGtC,iBAAA,EAAmB,mBAAA;AAAA,EACnB,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAGvB,gBAAA,EAAkB,kBAAA;AAAA,EAClB,aAAA,EAAe;AACjB","file":"chunk-6RDSQURE.js","sourcesContent":["/**\n * The engine's structured error type, the \"Rust/Go-style, verbose, easy to\n * tell the issue\" half of the error-handling redesign (the other half is\n * `Result.ts`).\n *\n * Historical note: an earlier version of this class (`UnifiedErrorFramework.ts`,\n * still the import path most of the codebase uses. See that file, now a\n * pure re-export barrel) had a much larger field set (`severity`,\n * `recovery`, a 5-value enum, `ErrorRecoveryManager`) that was almost\n * entirely dead: nothing downstream ever read `.severity`/`.recovery`,\n * only `.message` reliably survived to a caller. This version is smaller\n * and deliberately keeps only fields something actually consumes.\n */\n\nimport type { ErrorCode } from \"@solve-js/errors/ErrorCode\";\n\n/** A character-offset (and optional line/col) span into the original expression text, for a future \"underline the offending token\" UI, not yet wired to one. */\nexport interface SourceSpan {\n start: number;\n end: number;\n line?: number;\n col?: number;\n}\n\n/**\n * Error classification, kept from the original framework, now actually\n * consulted: it's the `format()` header and lets host code group errors\n * by pipeline stage without string-matching `.code`.\n */\nexport enum ErrorCategory {\n /** Errors during expression parsing. */\n PARSING = \"PARSING\",\n /** Errors during bytecode execution. */\n EXECUTION = \"EXECUTION\",\n /** Errors from input validation (safety limits, config). */\n VALIDATION = \"VALIDATION\",\n /** Errors from external services/APIs (currency rates, weather, stocks). */\n EXTERNAL = \"EXTERNAL\",\n /** Internal engine invariant violations. See `recoverable`'s doc comment. */\n INTERNAL = \"INTERNAL\",\n /** Configuration errors. */\n CONFIG = \"CONFIG\",\n}\n\n/** Fields accepted when constructing an {@link EngineError}. */\nexport interface EngineErrorInit {\n /** Catalog code. See `errors/ErrorCode.ts`. Not a free string: every code used by a BUILT-IN package should be registered there so `ErrorCodeCatalog.spec.ts` can catch collisions/typos. Third-party packages may still use any string here, `EngineError.code`'s runtime type is `string`. */\n code: ErrorCode | (string & {});\n /** Short, single-line, `Error.message`-compatible. Existing `.toThrow(/pattern/)`/`.message` assertions keep working against this field, richer detail goes in `expected`/`found`/`suggestion`, not crammed into this string. */\n message: string;\n /** What the parser/validator/VM expected to see, in plain words, e.g. \"a city name\", \"a 4-digit year\", \"end of expression\". */\n expected?: string;\n /** What was actually found instead, e.g. \"end of expression\", `NUMBER \"5\"`, the offending token's literal text. */\n found?: string;\n /** An actionable, worked-example fix, e.g. `e.g. \"weather in London\"`. Mirrors this codebase's best existing messages (`WEATHER_EXPECTED_CITY`, `AS_CONVERTER_EXPECTED_NAME`). */\n suggestion?: string;\n /**\n * `true` (the default) for every EXPECTED failure mode of user input or\n * environment, bad syntax, an unknown variable/function, a safety limit\n * exceeded, an external API being down. `false` is reserved for genuine\n * ENGINE-INTERNAL invariant violations (corrupted bytecode, a stack\n * underflow from a buggy plugin, an \"impossible\" state)\n * `ErrorFactory.internal()`/`.config()` default to `false`, every other\n * factory method defaults to `true`.\n *\n * This does NOT gate \"does evaluation of the rest of the document\n * continue\", with this engine's per-line containment, it always does\n * even for a `recoverable: false` error (see `ARCHITECTURE.md`'s\n * async-batcher/Tier-2 hardening notes). It gates MESSAGE FRAMING and\n * telemetry: \"fix your syntax\" vs. \"this is an engine bug, worth\n * reporting\". See `EngineError.isFatal()`.\n */\n recoverable?: boolean;\n /** Character-offset span into the source expression, when available. Not yet threaded through every call site, populate opportunistically, don't block on retrofitting every existing throw site. */\n span?: SourceSpan;\n /** Free-form structured context. The one field the pre-existing framework's real consumer (`ThreeTierEvaluator.ts`'s DAG-preservation-on-compile-error path) actually reads, kept name- and shape-compatible on purpose. */\n context?: Record<string, unknown>;\n /** The underlying error this one wraps, if any, passed straight through to native `Error.cause` (ES2022), so Node's default printer, most loggers, and `instanceof Error` tooling understand the chain for free. */\n cause?: unknown;\n}\n\n/**\n * The engine's structured error type. Still a real `Error` subclass (so\n * `throw`/`catch`/`instanceof Error` all keep working exactly as before),\n * but now every field except the removed `severity`/`recovery` pair is\n * something real code reads.\n */\nexport class EngineError extends Error {\n readonly category: ErrorCategory;\n readonly code: string;\n readonly expected?: string;\n readonly found?: string;\n readonly suggestion?: string;\n readonly recoverable: boolean;\n readonly span?: SourceSpan;\n readonly context?: Record<string, unknown>;\n readonly timestamp: Date;\n /**\n * Set explicitly (not via `super(message, {cause})`). This repo's\n * `tsconfig.json` targets ES6/ES5-ES7 lib, which predates TypeScript's\n * ES2022 `Error` constructor `cause`-option overload. `Error.prototype.cause`\n * is still a real runtime feature in every target this engine actually\n * runs in (Node 16.9+, all evergreen browsers, Electron/Obsidian's\n * bundled Chromium) regardless of the TS lib target used to type-check\n * against it, assigning it directly gets the same Node-printer/logger\n * interop with no build-config change needed.\n */\n readonly cause?: unknown;\n\n constructor(category: ErrorCategory, init: EngineErrorInit) {\n super(init.message);\n this.name = \"EngineError\";\n this.category = category;\n this.code = init.code;\n this.expected = init.expected;\n this.found = init.found;\n this.suggestion = init.suggestion;\n this.recoverable = init.recoverable ?? true;\n this.span = init.span;\n this.context = init.context;\n this.cause = init.cause;\n this.timestamp = new Date();\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, EngineError);\n }\n }\n\n /** `!recoverable`. See `EngineErrorInit.recoverable`'s doc comment for what this actually gates (message framing/telemetry, not whether evaluation continues). */\n isFatal(): boolean {\n return !this.recoverable;\n }\n\n /** Walk `.cause` repeatedly, collecting the full chain (this error first). */\n causeChain(): unknown[] {\n const chain: unknown[] = [this];\n let current: unknown = this.cause;\n while (current !== undefined && current !== null) {\n chain.push(current);\n current = current instanceof Error ? (current as Error & { cause?: unknown }).cause : undefined;\n }\n return chain;\n }\n\n /**\n * Rust/Go-style multi-line renderer, the NEW thing a host/CLI/test\n * reaches for when it wants the full, verbose picture, as distinct from\n * `.message` (kept short and stable for existing assertions). Example:\n *\n * ```\n * error[WEATHER_EXPECTED_CITY]: Expected a city name after \"weather in\"\n * expected: a city name\n * found: end of expression\n * suggestion: e.g. \"weather in London\"\n * ```\n */\n format(): string {\n const lines = [`error[${this.code}]: ${this.message}`];\n if (this.expected) lines.push(` expected: ${this.expected}`);\n if (this.found) lines.push(` found: ${this.found}`);\n if (this.suggestion) lines.push(` suggestion: ${this.suggestion}`);\n return lines.join(\"\\n\");\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n category: this.category,\n code: this.code,\n message: this.message,\n expected: this.expected,\n found: this.found,\n suggestion: this.suggestion,\n recoverable: this.recoverable,\n span: this.span,\n context: this.context,\n timestamp: this.timestamp.toISOString(),\n };\n }\n}\n\n/**\n * Factory for creating classified `EngineError`s. Every method accepts\n * EITHER the original, minimal 3-arg shape (`code, message, context?`\n * every existing call site across the codebase keeps compiling unchanged)\n * OR the richer `EngineErrorInit` object (for `expected`/`found`/\n * `suggestion`/`recoverable`/`span`/`cause`), upgrade a call site to the\n * richer form only when you're already touching it, no separate churn\n * pass required.\n */\nexport class ErrorFactory {\n private static build(\n category: ErrorCategory,\n defaultRecoverable: boolean,\n codeOrInit: string | EngineErrorInit,\n message?: string,\n context?: Record<string, unknown>,\n ): EngineError {\n const init: EngineErrorInit =\n typeof codeOrInit === \"string\"\n ? { code: codeOrInit, message: message!, context }\n : codeOrInit;\n return new EngineError(category, { recoverable: defaultRecoverable, ...init });\n }\n\n static validation(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static validation(init: EngineErrorInit): EngineError;\n static validation(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.VALIDATION, true, codeOrInit, message, context);\n }\n\n static parsing(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static parsing(init: EngineErrorInit): EngineError;\n static parsing(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.PARSING, true, codeOrInit, message, context);\n }\n\n static execution(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static execution(init: EngineErrorInit): EngineError;\n static execution(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.EXECUTION, true, codeOrInit, message, context);\n }\n\n static external(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static external(init: EngineErrorInit): EngineError;\n static external(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.EXTERNAL, true, codeOrInit, message, context);\n }\n\n /** Defaults `recoverable: false`, reserve for genuine engine-internal invariant violations, not user-input errors. */\n static internal(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static internal(init: EngineErrorInit): EngineError;\n static internal(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.INTERNAL, false, codeOrInit, message, context);\n }\n\n /** Defaults `recoverable: false`, a bad config is an environment-setup problem, not a per-line user-input error. */\n static config(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static config(init: EngineErrorInit): EngineError;\n static config(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.CONFIG, false, codeOrInit, message, context);\n }\n}\n\n/**\n * Normalize any thrown value into an `EngineError`, an `EngineError`\n * passes through as-is; a plain `Error` gets wrapped (message preserved,\n * original attached via `cause`); anything else becomes a generic\n * \"unknown error\" wrapping the stringified value. Used at every\n * throw-space/Result-space boundary (`Result.tryCatch`'s default\n * `normalize`, the VM's outer execution try/catch, `AsyncResolutionBatcher`'s\n * per-line containment) so a raw `TypeError` from a genuine engine bug\n * still surfaces as a structured, catalogued error instead of an opaque\n * uncaught exception.\n */\nexport function normalizeUnknownError(error: unknown): EngineError {\n if (error instanceof EngineError) return error;\n if (error instanceof Error) {\n return ErrorFactory.internal({\n code: \"UNEXPECTED_ERROR\",\n message: error.message,\n context: { originalErrorName: error.name },\n cause: error,\n });\n }\n return ErrorFactory.internal({\n code: \"UNKNOWN_ERROR\",\n message: \"An unknown error occurred\",\n context: { error: String(error) },\n });\n}\n","import { type EngineError, normalizeUnknownError } from \"@solve-js/errors/EngineError\";\n\n/**\n * A Rust-style `Result<T, E>`, the value half of this engine's error-handling\n * redesign. `E` defaults to `EngineError` (this engine's structured error\n * type) but every combinator here is generic over `E`, so `Result` works\n * equally well for a domain that isn't `EngineError`-shaped.\n *\n * This exact shape used to live in `errors/UnifiedErrorFramework.ts` (kept\n * there as a barrel re-export for backward compatibility), moved here as\n * its own module because it's genuinely generic (no dependency on\n * `EngineError` beyond the default type parameter) and because the engine\n * is migrating callers to it incrementally: parsing/VM/package code that\n * expects \"a failure is a possibility, not an exception\" returns\n * `Result<T, EngineError>` instead of throwing; two explicit adapters\n * {@link throwIfErr} and {@link tryCatch}, are the sanctioned way to cross\n * the boundary between Result-based code and still-throw-based code during\n * the migration (and permanently, at the public API boundary. See\n * `ExpressionEngine.evaluateExpression()`'s documented throw contract).\n */\nexport type Result<T, E = EngineError> =\n | { ok: true; value: T }\n | { ok: false; error: E };\n\n/** Wrap a successful value. */\nexport function ok<T>(value: T): Result<T, never> {\n return { ok: true, value };\n}\n\n/** Wrap a failure. */\nexport function err<E>(error: E): Result<never, E> {\n return { ok: false, error };\n}\n\n/**\n * Narrow a {@link Result} to its success arm.\n *\n * @param r - The result to test.\n * @returns True when it succeeded, narrowing `r` so `r.value` is reachable.\n */\nexport function isOk<T, E>(r: Result<T, E>): r is { ok: true; value: T } {\n return r.ok;\n}\n\n/**\n * Narrow a {@link Result} to its failure arm.\n *\n * @param r - The result to test.\n * @returns True when it failed, narrowing `r` so `r.error` is reachable.\n */\nexport function isErr<T, E>(r: Result<T, E>): r is { ok: false; error: E } {\n return !r.ok;\n}\n\n/** Transform the success value; a failure passes through untouched. */\nexport function map<T, U, E>(r: Result<T, E>, fn: (value: T) => U): Result<U, E> {\n return r.ok ? ok(fn(r.value)) : r;\n}\n\n/** Transform the error; a success passes through untouched. */\nexport function mapErr<T, E, F>(r: Result<T, E>, fn: (error: E) => F): Result<T, F> {\n return r.ok ? r : err(fn(r.error));\n}\n\n/** Chain a Result-returning operation onto a success (a.k.a. flatMap/bind). */\nexport function andThen<T, U, E>(r: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E> {\n return r.ok ? fn(r.value) : r;\n}\n\n/** Unwrap a success, or return `fallback` for a failure. Never throws. */\nexport function unwrapOr<T, E>(r: Result<T, E>, fallback: T): T {\n return r.ok ? r.value : fallback;\n}\n\n/** Exhaustive pattern-match, the `match`/`switch` a Rust enum gets for free. */\nexport function match<T, E, R>(r: Result<T, E>, arms: { ok: (value: T) => R; err: (error: E) => R }): R {\n return r.ok ? arms.ok(r.value) : arms.err(r.error);\n}\n\n/**\n * Combine several Results into one, succeeds with a tuple of all values\n * iff every input succeeded; otherwise fails with the FIRST error\n * encountered (left-to-right), matching this codebase's existing\n * fail-fast convention elsewhere (e.g. `BytecodeBuilder`'s constant-pool\n * limit checks).\n */\nexport function combine<T extends readonly unknown[], E>(\n results: { [K in keyof T]: Result<T[K], E> },\n): Result<T, E> {\n const values: unknown[] = [];\n for (const r of results as readonly Result<unknown, E>[]) {\n if (!r.ok) return r;\n values.push(r.value);\n }\n return ok(values as unknown as T);\n}\n\n/**\n * Cross from Result-space back to throw-space, the sanctioned boundary\n * adapter for callers (public API surface, older not-yet-migrated code,\n * tests) that still want exception-based control flow. Throws `r.error`\n * as-is (an `EngineError` is already a real `Error` subclass, so this\n * needs no wrapping).\n */\nexport function throwIfErr<T, E>(r: Result<T, E>): T {\n if (r.ok) return r.value;\n throw r.error;\n}\n\n/**\n * Cross from throw-space into Result-space, runs `fn`, converting any\n * thrown value into a Result via `normalize` (defaults to\n * {@link normalizeUnknownError}). The inverse of {@link throwIfErr}; the\n * pairing that lets Result-based and throw-based code interoperate during\n * an incremental migration instead of requiring a single flag-day rewrite.\n */\nexport function tryCatch<T>(\n fn: () => T,\n normalize: (e: unknown) => EngineError = normalizeUnknownError,\n): Result<T, EngineError> {\n try {\n return ok(fn());\n } catch (e) {\n return err(normalize(e));\n }\n}\n\n/** Async sibling of {@link tryCatch}. */\nexport async function tryCatchAsync<T>(\n fn: () => Promise<T>,\n normalize: (e: unknown) => EngineError = normalizeUnknownError,\n): Promise<Result<T, EngineError>> {\n try {\n return ok(await fn());\n } catch (e) {\n return err(normalize(e));\n }\n}\n","/**\n * The built-in error-code catalog, one typed const object per domain\n * unioned together here for autocomplete/exhaustiveness in core engine\n * code. Deliberately NOT one central enum: `IEnginePackage` is documented\n * public SDK surface for third-party packages (see `api/PackageRegistry.ts`),\n * and a closed enum would block an external package author from defining\n * their own codes without editing this file. `EngineError.code`'s runtime\n * type stays `string` for exactly that reason. This catalog is for the\n * codes THIS repo owns and wants collision/typo checking on (see\n * `__tests__/errors/ErrorCodeCatalog.spec.ts`), not a hard runtime\n * whitelist.\n *\n * As each package migrates to `Result<void, EngineError>` (see this\n * session's error-handling-refactor plan, Phase 5), it should export its\n * own small `XxxErrorCodes` const object co-located with its parselets\n * exactly like `CoreErrorCodes` below, just scoped to one domain, and get\n * unioned into `ErrorCode` here. Until a package migrates, its existing\n * free-string codes keep working (ErrorFactory accepts any string); they\n * just aren't caught by the catalog's uniqueness/orphan checks yet.\n */\n\n/**\n * Codes used directly by the parser/VM/engine/errors layers themselves\n * confirmed against the current source, not aspirational. Grouped by\n * pipeline stage via the comments, not a naming prefix (these predate any\n * naming convention and renaming them is out of scope for introducing the\n * catalog, only NEW codes need to follow a scoped/prefixed style, see\n * `STACK_UNDERFLOW` etc. below).\n */\nexport const CoreErrorCodes = {\n // ── Parser (parser/PrecedenceParser.ts, parser/BytecodeBuilder.ts, parser/PhrasePattern.ts) ──\n INVALID_NUMBER_LITERAL: \"INVALID_NUMBER_LITERAL\",\n NO_PREFIX_PARSELET: \"NO_PREFIX_PARSELET\",\n UNEXPECTED_END_OF_INPUT: \"UNEXPECTED_END_OF_INPUT\",\n UNEXPECTED_TOKEN_TYPE: \"UNEXPECTED_TOKEN_TYPE\",\n NESTING_DEPTH_EXCEEDED: \"NESTING_DEPTH_EXCEEDED\",\n UNEXPECTED_END: \"UNEXPECTED_END\",\n UNEXPECTED_TRAILING_TOKEN: \"UNEXPECTED_TRAILING_TOKEN\",\n PARSE_ERROR: \"PARSE_ERROR\",\n TOO_MANY_NUMERIC_CONSTANTS: \"TOO_MANY_NUMERIC_CONSTANTS\",\n TOO_MANY_STRING_CONSTANTS: \"TOO_MANY_STRING_CONSTANTS\",\n NO_MATCHING_PHRASE_ALTERNATIVE: \"NO_MATCHING_PHRASE_ALTERNATIVE\",\n INVALID_PHRASE_PATTERN: \"INVALID_PHRASE_PATTERN\",\n PHRASE_KEYWORD_MISMATCH: \"PHRASE_KEYWORD_MISMATCH\",\n /** User-defined-function definition parsing (`f(x, y) = ...`), an invalid token where a parameter name was expected. */\n USER_FUNCTION_INVALID_PARAM_NAME: \"USER_FUNCTION_INVALID_PARAM_NAME\",\n /** `f() = ...` with zero parameters, indistinguishable from a plain no-arg function call, so rejected at definition time. */\n USER_FUNCTION_NO_PARAMS: \"USER_FUNCTION_NO_PARAMS\",\n /** A user-defined function body calling an async plugin (weather/stocks/currency/...), rejected at definition time; v1 scope excludes async function bodies. */\n FUNCTION_BODY_MUST_BE_SYNCHRONOUS: \"FUNCTION_BODY_MUST_BE_SYNCHRONOUS\",\n /** `BytecodeBuilder`'s `userFunctionBodies` side-table exceeding its capacity. Same class as `TOO_MANY_NUMERIC_CONSTANTS`/`TOO_MANY_STRING_CONSTANTS` below. */\n TOO_MANY_FUNCTION_DEFINITIONS: \"TOO_MANY_FUNCTION_DEFINITIONS\",\n /** `BytecodeBuilder`'s `anonymousBodies` side-table (map/reduce inline transform bodies) exceeding its capacity. Same class as `TOO_MANY_FUNCTION_DEFINITIONS` above. */\n TOO_MANY_ANONYMOUS_BODIES: \"TOO_MANY_ANONYMOUS_BODIES\",\n\n // ── VM (vm/VM.ts, vm/OpRegistry.ts, vm/VMBuiltins.ts) ──\n EVALUATION_ERROR: \"EVALUATION_ERROR\",\n INSTRUCTION_LIMIT_EXCEEDED: \"INSTRUCTION_LIMIT_EXCEEDED\",\n STACK_LIMIT_EXCEEDED: \"STACK_LIMIT_EXCEEDED\",\n /** New this phase. See `VM.ts`'s `safePop()`: a stack-underflow (corrupted bytecode, a buggy plugin) is now a controlled EngineError instead of a raw TypeError. Always `recoverable: false` (internal invariant violation). */\n STACK_UNDERFLOW: \"STACK_UNDERFLOW\",\n UNDEFINED_VARIABLE: \"UNDEFINED_VARIABLE\",\n /** New this phase, the Tier-2/`LOAD_GLOBAL_VAR` hardening: a global variable read before its async preflight resolved, surfaced as a controlled error instead of pushing `undefined`. */\n GLOBAL_VARIABLE_NOT_RESOLVED: \"GLOBAL_VARIABLE_NOT_RESOLVED\",\n UNKNOWN_FUNCTION: \"UNKNOWN_FUNCTION\",\n /** `unwrapEvalResult()`'s pending-when-expecting-value case, a caller-contract violation, not user-input. */\n UNEXPECTED_PENDING_RESULT: \"UNEXPECTED_PENDING_RESULT\",\n /** User-defined-function call/definition errors (`CALL_USER_FUNCTION`/`DEFINE_USER_FUNCTION` opcodes), calling a name with no matching definition, calling with the wrong argument count, and the deliberate v1 restriction that a function body can't itself contain async work. */\n UNDEFINED_FUNCTION: \"UNDEFINED_FUNCTION\",\n FUNCTION_ARITY_MISMATCH: \"FUNCTION_ARITY_MISMATCH\",\n USER_FUNCTION_ASYNC_UNSUPPORTED: \"USER_FUNCTION_ASYNC_UNSUPPORTED\",\n /** A map/reduce transform body (inline expression or user-defined function) calling an async plugin. Same v1 scope restriction as `USER_FUNCTION_ASYNC_UNSUPPORTED` above, enforced both at parse time (`MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS`, packages/mapreduce/) and as a defense-in-depth runtime backstop here. */\n MAP_REDUCE_ASYNC_UNSUPPORTED: \"MAP_REDUCE_ASYNC_UNSUPPORTED\",\n /** `pushCallFrame()`'s recursion guard, a nested `CALL_USER_FUNCTION` re-enters `executeBytecode()`, so `maxInstructions` alone can't catch e.g. `f(x) = f(x)`; this is the dedicated backstop. `recoverable: true` (the default for `.execution()`), ordinary user-written infinite recursion, not an engine bug; the guard exists precisely so it surfaces as a clear error instead of overflowing the native call stack uncatchably. */\n FUNCTION_RECURSION_LIMIT_EXCEEDED: \"FUNCTION_RECURSION_LIMIT_EXCEEDED\",\n /** `DEFINE_USER_FUNCTION`'s body-index lookup failing, a compiler/VM invariant violation (the opcode stream referenced a `userFunctionBodies` slot that doesn't exist), never a user-input error. */\n INTERNAL_MISSING_FUNCTION_BODY: \"INTERNAL_MISSING_FUNCTION_BODY\",\n /** `MAP_INVOKE`/`REDUCE_INVOKE`'s anonymous-body-index lookup failing. Same class as `INTERNAL_MISSING_FUNCTION_BODY` above, for the `anonymousBodies` side-table instead of `userFunctionBodies`. */\n INTERNAL_MISSING_ANONYMOUS_BODY: \"INTERNAL_MISSING_ANONYMOUS_BODY\",\n\n // ── Symbolic algebra (symbolic/, vm/SymbolicOps.ts) ──\n /** A coefficient grew past `RATIONAL_MAX_BITS`, e.g. repeated exact elimination multiplying denominators together. */\n SYMBOLIC_RATIONAL_OVERFLOW: \"SYMBOLIC_RATIONAL_OVERFLOW\",\n /** `NaN` or `±Infinity` reaching a symbolic expression, neither of which has an exact rational value. */\n SYMBOLIC_NONFINITE_OPERAND: \"SYMBOLIC_NONFINITE_OPERAND\",\n /** Division by an exactly-zero rational. Exact, unlike the double comparison it replaced, which could not distinguish a true zero from `5.551e-17`. */\n SYMBOLIC_DIVISION_BY_ZERO: \"SYMBOLIC_DIVISION_BY_ZERO\",\n /** A tree exceeding `SYMBOLIC_MAX_NODES` entering the simplifier. */\n SYMBOLIC_NODE_LIMIT_EXCEEDED: \"SYMBOLIC_NODE_LIMIT_EXCEEDED\",\n /** A builtin with no symbolic reading (`min`, `random`, the finance block, ...) applied to an expression still containing an unknown. Returned rather than computing against `toNumber()`'s placeholder zero. */\n SYMBOLIC_UNSUPPORTED_FUNCTION: \"SYMBOLIC_UNSUPPORTED_FUNCTION\",\n /** The rational-root search exceeding `FACTOR_MAX_ROOT_CANDIDATES`. The candidate set is the product of two divisor sets, so a highly-composite coefficient escapes quickly. */\n SYMBOLIC_FACTOR_LIMIT_EXCEEDED: \"SYMBOLIC_FACTOR_LIMIT_EXCEEDED\",\n /** An equation outside what the solver attempts: not a polynomial, above the degree ceiling, or non-linear in the unknown while another unknown is present. */\n SYMBOLIC_SOLVE_UNSUPPORTED: \"SYMBOLIC_SOLVE_UNSUPPORTED\",\n /** `solve`'s second argument not being a bare name. */\n SOLVE_REQUIRES_VARIABLE_NAME: \"SOLVE_REQUIRES_VARIABLE_NAME\",\n /** A derivative order outside 0..`DERIVATIVE_MAX_ORDER`. */\n SYMBOLIC_DERIVATIVE_ORDER_LIMIT: \"SYMBOLIC_DERIVATIVE_ORDER_LIMIT\",\n /** An expression with no known elementary antiderivative. Reported rather than approximated, since a wrong integral is indistinguishable from a right one at the point of use. */\n SYMBOLIC_INTEGRAL_UNSUPPORTED: \"SYMBOLIC_INTEGRAL_UNSUPPORTED\",\n /** A Taylor degree outside 0..`TAYLOR_MAX_DEGREE`. */\n SYMBOLIC_TAYLOR_DEGREE_LIMIT: \"SYMBOLIC_TAYLOR_DEGREE_LIMIT\",\n /** A Taylor coefficient that does not reduce to an exact number at the expansion point. */\n SYMBOLIC_TAYLOR_INEXACT: \"SYMBOLIC_TAYLOR_INEXACT\",\n /** An algebra verb's variable-name argument not being a bare name. */\n SYMBOLIC_REQUIRES_VARIABLE_NAME: \"SYMBOLIC_REQUIRES_VARIABLE_NAME\",\n /** `jacobian` called with expressions containing no unknown to differentiate against. */\n SYMBOLIC_JACOBIAN_NO_VARIABLES: \"SYMBOLIC_JACOBIAN_NO_VARIABLES\",\n /** A finite number whose decimal form could not be read back, which the regex covering every `Number.prototype.toString` output should make unreachable. */\n INTERNAL_RATIONAL_PARSE: \"INTERNAL_RATIONAL_PARSE\",\n\n // ── Engine (engine/ExpressionEngine.ts, engine/ExpressionEngineSafety.ts, engine/AsyncResolutionBatcher.ts) ──\n EXPRESSION_TOO_LONG: \"EXPRESSION_TOO_LONG\",\n EXPRESSION_TOO_COMPLEX: \"EXPRESSION_TOO_COMPLEX\",\n NORMALIZED_TOKEN_LIMIT_EXCEEDED: \"NORMALIZED_TOKEN_LIMIT_EXCEEDED\",\n /** `\"=>\"` with nothing before it, needs an expression or variable name to solve/simplify. */\n THEREFORE_REQUIRES_EXPRESSION: \"THEREFORE_REQUIRES_EXPRESSION\",\n /** A `\"=>\"`-triggered expression called an async plugin (weather/stocks/currency). Same v1 scope restriction as user-function/map-reduce bodies. */\n THEREFORE_ASYNC_UNSUPPORTED: \"THEREFORE_ASYNC_UNSUPPORTED\",\n\n // ── Config (constants/Configuration.ts) ──\n CONFIG_PATH_NOT_FOUND: \"CONFIG_PATH_NOT_FOUND\",\n INVALID_CONFIG_PATH: \"INVALID_CONFIG_PATH\",\n CONFIG_SECTION_NOT_FOUND: \"CONFIG_SECTION_NOT_FOUND\",\n CONFIG_PROPERTY_NOT_FOUND: \"CONFIG_PROPERTY_NOT_FOUND\",\n\n // ── Package/lexer registration-time collisions (lexer/ExpressionLexer.ts) ──\n PLUGIN_OPERATOR_COLLISION: \"PLUGIN_OPERATOR_COLLISION\",\n PLUGIN_KEYWORD_COLLISION: \"PLUGIN_KEYWORD_COLLISION\",\n PLUGIN_UNIT_COLLISION: \"PLUGIN_UNIT_COLLISION\",\n /** A package's declared `IEnginePackage.engineVersion` semver range doesn't satisfy the running engine's ENGINE_VERSION. See api/EngineVersionCompatibility.ts. */\n PACKAGE_ENGINE_VERSION_MISMATCH: \"PACKAGE_ENGINE_VERSION_MISMATCH\",\n /** A package's declared `IEnginePackage.engineVersion` isn't a parseable semver range at all (a typo in the package's own descriptor). */\n PACKAGE_ENGINE_VERSION_INVALID_RANGE: \"PACKAGE_ENGINE_VERSION_INVALID_RANGE\",\n /** `OpRegistry.allocateOpcode()`'s dynamic opcode pool (started at 201) exhausted, too many packages calling it. */\n OPCODE_POOL_EXHAUSTED: \"OPCODE_POOL_EXHAUSTED\",\n /** `VMBuiltins.allocatePluginFunctionIndex()`'s 0-255 index pool (a single opcode-stream byte) exhausted. */\n PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED: \"PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED\",\n\n // ── vm/Value.ts caller-contract violations (check isRateUnit()/isTimecodeUnit() first) ──\n INVALID_RATE_UNIT: \"INVALID_RATE_UNIT\",\n INVALID_TIMECODE_UNIT: \"INVALID_TIMECODE_UNIT\",\n\n // ── errors/EngineError.ts's own fallback normalization ──\n UNEXPECTED_ERROR: \"UNEXPECTED_ERROR\",\n UNKNOWN_ERROR: \"UNKNOWN_ERROR\",\n} as const;\n\n/** Every error code the engine's own layers can produce, from {@link CoreErrorCodes}. */\nexport type CoreErrorCode = (typeof CoreErrorCodes)[keyof typeof CoreErrorCodes];\n\n/**\n * The aggregated catalog type. Currently just `CoreErrorCode`, union in\n * each package's own code-object type here as Phase 5 converts it, e.g.\n * `CoreErrorCode | WeatherErrorCode | StocksErrorCode | ...`.\n */\nexport type ErrorCode = CoreErrorCode;\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/parser/OpCode.ts
|
|
2
|
+
var OpCode = /* @__PURE__ */ ((OpCode2) => {
|
|
3
|
+
OpCode2[OpCode2["NOP"] = 0] = "NOP";
|
|
4
|
+
OpCode2[OpCode2["HALT"] = 1] = "HALT";
|
|
5
|
+
OpCode2[OpCode2["SWAP"] = 2] = "SWAP";
|
|
6
|
+
OpCode2[OpCode2["DUP"] = 3] = "DUP";
|
|
7
|
+
OpCode2[OpCode2["PUSH_NUMBER"] = 10] = "PUSH_NUMBER";
|
|
8
|
+
OpCode2[OpCode2["PUSH_BIGINT"] = 11] = "PUSH_BIGINT";
|
|
9
|
+
OpCode2[OpCode2["PUSH_HEX"] = 12] = "PUSH_HEX";
|
|
10
|
+
OpCode2[OpCode2["PUSH_STRING"] = 13] = "PUSH_STRING";
|
|
11
|
+
OpCode2[OpCode2["PUSH_BOOLEAN"] = 14] = "PUSH_BOOLEAN";
|
|
12
|
+
OpCode2[OpCode2["PUSH_VARIABLE"] = 15] = "PUSH_VARIABLE";
|
|
13
|
+
OpCode2[OpCode2["ADD"] = 20] = "ADD";
|
|
14
|
+
OpCode2[OpCode2["SUB"] = 21] = "SUB";
|
|
15
|
+
OpCode2[OpCode2["MUL"] = 22] = "MUL";
|
|
16
|
+
OpCode2[OpCode2["DIV"] = 23] = "DIV";
|
|
17
|
+
OpCode2[OpCode2["MOD"] = 24] = "MOD";
|
|
18
|
+
OpCode2[OpCode2["EXP"] = 25] = "EXP";
|
|
19
|
+
OpCode2[OpCode2["NEG"] = 26] = "NEG";
|
|
20
|
+
OpCode2[OpCode2["POS"] = 27] = "POS";
|
|
21
|
+
OpCode2[OpCode2["LSHIFT"] = 30] = "LSHIFT";
|
|
22
|
+
OpCode2[OpCode2["RSHIFT"] = 31] = "RSHIFT";
|
|
23
|
+
OpCode2[OpCode2["URSHIFT"] = 32] = "URSHIFT";
|
|
24
|
+
OpCode2[OpCode2["BIT_AND"] = 33] = "BIT_AND";
|
|
25
|
+
OpCode2[OpCode2["BIT_OR"] = 34] = "BIT_OR";
|
|
26
|
+
OpCode2[OpCode2["BIT_XOR"] = 35] = "BIT_XOR";
|
|
27
|
+
OpCode2[OpCode2["BIT_NOT"] = 36] = "BIT_NOT";
|
|
28
|
+
OpCode2[OpCode2["EQ"] = 40] = "EQ";
|
|
29
|
+
OpCode2[OpCode2["NEQ"] = 41] = "NEQ";
|
|
30
|
+
OpCode2[OpCode2["LT"] = 42] = "LT";
|
|
31
|
+
OpCode2[OpCode2["LTE"] = 43] = "LTE";
|
|
32
|
+
OpCode2[OpCode2["GT"] = 44] = "GT";
|
|
33
|
+
OpCode2[OpCode2["GTE"] = 45] = "GTE";
|
|
34
|
+
OpCode2[OpCode2["CALL_PLUGIN"] = 50] = "CALL_PLUGIN";
|
|
35
|
+
OpCode2[OpCode2["CALL_BUILTIN"] = 51] = "CALL_BUILTIN";
|
|
36
|
+
OpCode2[OpCode2["RETURN"] = 52] = "RETURN";
|
|
37
|
+
OpCode2[OpCode2["LOAD_VAR"] = 60] = "LOAD_VAR";
|
|
38
|
+
OpCode2[OpCode2["STORE_VAR"] = 61] = "STORE_VAR";
|
|
39
|
+
OpCode2[OpCode2["LOAD_GLOBAL_VAR"] = 62] = "LOAD_GLOBAL_VAR";
|
|
40
|
+
OpCode2[OpCode2["STORE_GLOBAL_VAR"] = 63] = "STORE_GLOBAL_VAR";
|
|
41
|
+
OpCode2[OpCode2["TO_NUMBER"] = 70] = "TO_NUMBER";
|
|
42
|
+
OpCode2[OpCode2["TO_HEX"] = 71] = "TO_HEX";
|
|
43
|
+
OpCode2[OpCode2["TO_PERCENTAGE"] = 74] = "TO_PERCENTAGE";
|
|
44
|
+
OpCode2[OpCode2["UOM_CONVERT"] = 80] = "UOM_CONVERT";
|
|
45
|
+
OpCode2[OpCode2["UOM_CONVERT_TO"] = 81] = "UOM_CONVERT_TO";
|
|
46
|
+
OpCode2[OpCode2["UOM_GET_VALUE"] = 82] = "UOM_GET_VALUE";
|
|
47
|
+
OpCode2[OpCode2["UOM_BEST"] = 83] = "UOM_BEST";
|
|
48
|
+
OpCode2[OpCode2["UOM_CONVERT_IN"] = 84] = "UOM_CONVERT_IN";
|
|
49
|
+
OpCode2[OpCode2["UOM_POSSIBILITIES"] = 85] = "UOM_POSSIBILITIES";
|
|
50
|
+
OpCode2[OpCode2["DATE_NOW"] = 90] = "DATE_NOW";
|
|
51
|
+
OpCode2[OpCode2["DATE_ADD"] = 91] = "DATE_ADD";
|
|
52
|
+
OpCode2[OpCode2["DATE_SUB"] = 92] = "DATE_SUB";
|
|
53
|
+
OpCode2[OpCode2["DATE_NEXT_WEEKDAY"] = 93] = "DATE_NEXT_WEEKDAY";
|
|
54
|
+
OpCode2[OpCode2["DATE_LAST_WEEKDAY"] = 94] = "DATE_LAST_WEEKDAY";
|
|
55
|
+
OpCode2[OpCode2["DATE_LITERAL"] = 95] = "DATE_LITERAL";
|
|
56
|
+
OpCode2[OpCode2["RATE_DIV"] = 110] = "RATE_DIV";
|
|
57
|
+
OpCode2[OpCode2["RATE_MUL"] = 111] = "RATE_MUL";
|
|
58
|
+
OpCode2[OpCode2["RATE_CONVERT"] = 112] = "RATE_CONVERT";
|
|
59
|
+
OpCode2[OpCode2["CLOCK_TIME_TODAY"] = 120] = "CLOCK_TIME_TODAY";
|
|
60
|
+
OpCode2[OpCode2["LOGICAL_AND"] = 130] = "LOGICAL_AND";
|
|
61
|
+
OpCode2[OpCode2["LOGICAL_OR"] = 131] = "LOGICAL_OR";
|
|
62
|
+
OpCode2[OpCode2["SELECT"] = 132] = "SELECT";
|
|
63
|
+
OpCode2[OpCode2["TO_FRACTION"] = 140] = "TO_FRACTION";
|
|
64
|
+
OpCode2[OpCode2["TO_MULTIPLIER"] = 141] = "TO_MULTIPLIER";
|
|
65
|
+
OpCode2[OpCode2["TO_SCI"] = 142] = "TO_SCI";
|
|
66
|
+
OpCode2[OpCode2["TO_BINARY"] = 143] = "TO_BINARY";
|
|
67
|
+
OpCode2[OpCode2["TO_OCTAL"] = 144] = "TO_OCTAL";
|
|
68
|
+
OpCode2[OpCode2["CALL_AS_CONVERTER"] = 145] = "CALL_AS_CONVERTER";
|
|
69
|
+
OpCode2[OpCode2["DEFINE_USER_FUNCTION"] = 150] = "DEFINE_USER_FUNCTION";
|
|
70
|
+
OpCode2[OpCode2["CALL_USER_FUNCTION"] = 151] = "CALL_USER_FUNCTION";
|
|
71
|
+
OpCode2[OpCode2["MAT_NEW"] = 152] = "MAT_NEW";
|
|
72
|
+
OpCode2[OpCode2["MAT_INDEX1"] = 153] = "MAT_INDEX1";
|
|
73
|
+
OpCode2[OpCode2["MAT_INDEX2"] = 154] = "MAT_INDEX2";
|
|
74
|
+
OpCode2[OpCode2["MAT_SLICE"] = 155] = "MAT_SLICE";
|
|
75
|
+
OpCode2[OpCode2["RANGE_NEW"] = 156] = "RANGE_NEW";
|
|
76
|
+
OpCode2[OpCode2["MAP_INVOKE"] = 157] = "MAP_INVOKE";
|
|
77
|
+
OpCode2[OpCode2["REDUCE_INVOKE"] = 158] = "REDUCE_INVOKE";
|
|
78
|
+
return OpCode2;
|
|
79
|
+
})(OpCode || {});
|
|
80
|
+
var OP_CODE_NAMES = (() => {
|
|
81
|
+
const map = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const [key, value] of Object.entries(OpCode)) {
|
|
83
|
+
if (typeof value === "number") map.set(value, key);
|
|
84
|
+
}
|
|
85
|
+
return map;
|
|
86
|
+
})();
|
|
87
|
+
function getOpCodeName(op) {
|
|
88
|
+
return OP_CODE_NAMES.get(op) ?? `UNKNOWN_${op}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { OpCode, getOpCodeName };
|
|
92
|
+
//# sourceMappingURL=chunk-75JP4BZX.js.map
|
|
93
|
+
//# sourceMappingURL=chunk-75JP4BZX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parser/OpCode.ts"],"names":["OpCode"],"mappings":";AAcO,IAAK,MAAA,qBAAAA,OAAAA,KAAL;AAEN,EAAAA,OAAAA,CAAAA,OAAAA,CAAA,SAAM,CAAA,CAAA,GAAN,KAAA;AACA,EAAAA,OAAAA,CAAAA,OAAAA,CAAA,UAAO,CAAA,CAAA,GAAP,MAAA;AACA,EAAAA,OAAAA,CAAAA,OAAAA,CAAA,UAAO,CAAA,CAAA,GAAP,MAAA;AACA,EAAAA,OAAAA,CAAAA,OAAAA,CAAA,SAAM,CAAA,CAAA,GAAN,KAAA;AAGA,EAAAA,OAAAA,CAAAA,OAAAA,CAAA,iBAAc,EAAA,CAAA,GAAd,aAAA;AACA,EAAAA,OAAAA,CAAAA,OAAAA,CAAA,iBAAc,EAAA,CAAA,GAAd,aAAA;AACA,EAAAA,OAAAA,CAAAA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AAA,EAAA,MAAA,IAAA,EAAA;AAgJZ,IAAM,iBAA8C,MAAM;AACzD,EAAA,MAAM,GAAA,uBAAU,GAAA,EAAoB;AACpC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AAClD,IAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,GAAA,CAAI,GAAA,CAAI,OAAO,GAAG,CAAA;AAAA,EAClD;AACA,EAAA,OAAO,GAAA;AACR,CAAA,GAAG;AAOI,SAAS,cAAc,EAAA,EAAoB;AACjD,EAAA,OAAO,aAAA,CAAc,GAAA,CAAI,EAAE,CAAA,IAAK,WAAW,EAAE,CAAA,CAAA;AAC9C","file":"chunk-75JP4BZX.js","sourcesContent":["/**\n * The VM's bytecode instruction set.\n *\n * Emitted by parselets (via {@link BytecodeBuilder}) during parsing and\n * consumed by the VM's dispatch loop during execution. Values are grouped\n * into numeric bands by category (0-9 stack ops, 10-19 push-literal, 20-29\n * arithmetic, ...) purely for readability, the VM dispatches on the exact\n * numeric value, not the band.\n *\n * Third-party packages emit `CALL_PLUGIN` (with a plugin-function index\n * from {@link allocatePluginFunctionIndex}) to invoke their own logic\n * see `IEnginePackage.pluginFunctions`. The other opcodes are used\n * internally by the built-in packages' parselets.\n */\nexport enum OpCode {\n\t// Stack operations\n\tNOP = 0,\n\tHALT = 1,\n\tSWAP = 2,\n\tDUP = 3,\n\n\t// Push literals\n\tPUSH_NUMBER = 10,\n\tPUSH_BIGINT = 11,\n\tPUSH_HEX = 12,\n\tPUSH_STRING = 13,\n\tPUSH_BOOLEAN = 14,\n\tPUSH_VARIABLE = 15,\n\n\t// Arithmetic (BinaryOperator)\n\tADD = 20,\n\tSUB = 21,\n\tMUL = 22,\n\tDIV = 23,\n\tMOD = 24,\n\tEXP = 25,\n\tNEG = 26,\n\tPOS = 27,\n\n\t// Bitwise\n\tLSHIFT = 30,\n\tRSHIFT = 31,\n\tURSHIFT = 32,\n\tBIT_AND = 33,\n\tBIT_OR = 34,\n\tBIT_XOR = 35,\n\tBIT_NOT = 36,\n\n\t// Comparison\n\tEQ = 40,\n\tNEQ = 41,\n\tLT = 42,\n\tLTE = 43,\n\tGT = 44,\n\tGTE = 45,\n\n\t// Functions\n\tCALL_PLUGIN = 50, // Plugin-registered functions (may be async — pre-resolved by orchestrator)\n\tCALL_BUILTIN = 51, // Sync built-in functions (sqrt, sin, diceRoll, matmul)\n\tRETURN = 52, // Reserved for future user-defined functions\n\n\t// Variables\n\tLOAD_VAR = 60,\n\tSTORE_VAR = 61,\n\tLOAD_GLOBAL_VAR = 62, // Reads from the process-wide GlobalVariableStore, not the VM's local scope\n\tSTORE_GLOBAL_VAR = 63, // Writes to the process-wide GlobalVariableStore, visible to every document\n\n\t// Type conversion\n\tTO_NUMBER = 70,\n\tTO_HEX = 71,\n\tTO_PERCENTAGE = 74,\n\n\t// UoM\n\tUOM_CONVERT = 80,\n\tUOM_CONVERT_TO = 81,\n\tUOM_GET_VALUE = 82,\n\tUOM_BEST = 83,\n\tUOM_CONVERT_IN = 84,\n\tUOM_POSSIBILITIES = 85, // \"sourceUnit to ?\" — list units convertible from sourceUnit\n\n\t// Datetime\n\tDATE_NOW = 90,\n\tDATE_ADD = 91,\n\tDATE_SUB = 92,\n\tDATE_NEXT_WEEKDAY = 93, // \"next <Weekday>\" — the next occurrence strictly after now\n\tDATE_LAST_WEEKDAY = 94, // \"last <Weekday>\" — the previous occurrence strictly before now\n\tDATE_LITERAL = 95, // Push a datetime literal whose epoch-ms was already resolved at parse time (see DateLiteralParselet)\n\n\t// Rate, \"quantity per unit of something\" ($99/week, 30 fps). See\n\t// vm/Value.ts's rateValue()/isRateUnit()/splitRateUnit() for the\n\t// representation these opcodes operate on.\n\tRATE_DIV = 110, // Uom ÷ Uom (different measures) -> Rate — the construction op\n\tRATE_MUL = 111, // Rate × Uom (same measure as denominator) -> plain Uom (denominator cancels)\n\tRATE_CONVERT = 112, // Rate -> Rate with a rescaled denominator unit (keeps the same real-world rate)\n\n\t// Time, clock-time-of-day, lap times, video timecode (distinct from\n\t// the Datetime band's calendar-date arithmetic).\n\tCLOCK_TIME_TODAY = 120, // minutes-since-midnight -> Datetime anchored to today's calendar date\n\n\t// Conditionals, boolean logic and eager-evaluated ternary selection.\n\t// EQ/NEQ/LT/LTE/GT/GTE (40-45, above) already existed as dead opcodes\n\t// before this band was wired up; see vm/VM.ts for their handlers.\n\tLOGICAL_AND = 130, // Boolean && Boolean -> Boolean\n\tLOGICAL_OR = 131, // Boolean || Boolean -> Boolean\n\tSELECT = 132, // (thenVal, elseVal, condition) -> thenVal if condition else elseVal — EAGER (both\n\t // branches already evaluated by the time this runs; no real branching/short-circuit,\n\t // a deliberate simplification for a side-effect-free expression language, see\n\t // packages/conditionals/parselets/IfThenElseParselet.ts)\n\n\t// Converters, the general \"as <type>\" mechanism. TO_NUMBER/TO_HEX/\n\t// TO_PERCENTAGE (70/71/74, above) cover the simplest cases; these cover\n\t// the ones with no existing opcode. CALL_AS_CONVERTER is the SDK\n\t// extension point. See IEnginePackage.asConverters and\n\t// vm/VMBuiltins.ts's asConverterRegistry.\n\tTO_FRACTION = 140, // Number -> String, simplified fraction (\"0.5\" -> \"1/2\")\n\tTO_MULTIPLIER = 141, // Number -> String, \"1 + n\" growth multiplier (\"0.5\" -> \"1.5x\")\n\tTO_SCI = 142, // Number -> String, scientific notation (\"1500000\" -> \"1.5e+6\")\n\tTO_BINARY = 143, // Number -> String, base-2 display (\"10\" -> \"0b1010\")\n\tTO_OCTAL = 144, // Number -> String, base-8 display (\"10\" -> \"0o12\")\n\tCALL_AS_CONVERTER = 145, // (value, name) -> runtime asConverterRegistry lookup + call\n\n\t// User-defined, parameterized, reusable functions (f(x) = expr, then\n\t// f(5). See parser/PrecedenceParser.ts's IDENT_ID case\n\t// parser/BytecodeBuilder.ts's UserFunctionDef/emitUserFunctionBody, and\n\t// vm/VM.ts's VM.userFunctions/callFrames). Parameter references inside a\n\t// function body are ORDINARY LOAD_VAR opcodes, not a dedicated\n\t// parameter-load opcode, CALL_USER_FUNCTION binds arguments into a\n\t// name-keyed call frame at runtime, and LOAD_VAR checks the innermost\n\t// call frame before the flat variable store (see VM.getVar()).\n\tDEFINE_USER_FUNCTION = 150, // (operand = index into bytecode.userFunctionBodies) -> register name/params/program into vm.userFunctions. Registration happens at VM-EXECUTION time, not parse time, so a diagnostic/lookahead parse that compiles but never executes a definition line has no side effect on the shared registry.\n\tCALL_USER_FUNCTION = 151, // (N arg values already on stack) -> pop N args, bind by NAME into a new call frame, execute the named function's stored body (reentrant executeBytecode), push its result\n\n\t// Matrix (Calca-parity, replaces the old ARR_* vector-only opcodes\n\t// which were never emitted by any registered parselet; see\n\t// vm/MatrixOps.ts for the shared column-major storage helpers this band\n\t// operates on, and vm/Value.ts's MatrixData for the representation).\n\tMAT_NEW = 152, // (rows, cols operands; rows*cols values already on stack, ROW-MAJOR push order) -> pop rows*cols values, transpose to column-major, push a Matrix\n\tMAT_INDEX1 = 153, // (matrix, index already on stack) -> column-major single-index read `a[i]`\n\tMAT_INDEX2 = 154, // (matrix, row, col already on stack) -> `a[row, col]` read\n\tMAT_SLICE = 155, // (matrix, rowRange, colRange already on stack) -> sub-matrix via two Range values\n\tRANGE_NEW = 156, // (min, max already on stack) -> push a Range value `min:max`\n\tMAP_INVOKE = 157, // map(...) — see parser/BytecodeBuilder.ts's `anonymousBodies` side-table\n\tREDUCE_INVOKE = 158, // reduce(...) — same anonymousBodies mechanism as MAP_INVOKE\n\t// 159 and 160 were THEREFORE_SOLVE and STORE_EQUATION_OR_ASSIGNMENT, declared\n\t// but never emitted by any parselet nor handled in the VM switch. Both shapes\n\t// have effects (a stored equation, a direct vm.setVar()) that a cached\n\t// bytecode program cannot represent, so engine/ExpressionEngine.ts intercepts\n\t// them before compilation and always will. The numbers are free to reuse.\n}\n\n// Reverse lookup built once at module load, getOpCodeName() is called once\n// per VM instruction whenever a diagnostic collector is attached (VM.ts's\n// trace path), so a per-call linear scan of every enum entry (TS numeric\n// enums are bidirectional at runtime, so Object.entries(OpCode) yields both\n// \"NOP\" -> 0 and \"0\" -> \"NOP\" style entries) would otherwise redo the same\n// scan every single traced instruction. Only the numeric-valued entries are\n// kept, the string-valued reverse entries TS also generates aren't needed\n// here.\nconst OP_CODE_NAMES: ReadonlyMap<number, string> = (() => {\n\tconst map = new Map<number, string>();\n\tfor (const [key, value] of Object.entries(OpCode)) {\n\t\tif (typeof value === \"number\") map.set(value, key);\n\t}\n\treturn map;\n})();\n\n/**\n * Gets the name of an OpCode as a string.\n * @param op The OpCode value\n * @returns The enum name as a string, or \"UNKNOWN_<value>\" if not found\n */\nexport function getOpCodeName(op: number): string {\n\treturn OP_CODE_NAMES.get(op) ?? `UNKNOWN_${op}`;\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
try {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw mod = 0, e;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
exports.__commonJS = __commonJS;
|
|
34
|
+
exports.__toESM = __toESM;
|
|
35
|
+
//# sourceMappingURL=chunk-B7LXJ6LC.cjs.map
|
|
36
|
+
//# sourceMappingURL=chunk-B7LXJ6LC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-B7LXJ6LC.cjs"}
|