@coldsmirk/abacus-core 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +375 -0
- package/dist/index.cjs +762 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +495 -0
- package/dist/index.d.ts +495 -0
- package/dist/index.js +730 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/engine/errors.ts
|
|
3
|
+
/**
|
|
4
|
+
* Error raised when the ZEN engine fails to load or an expression cannot be
|
|
5
|
+
* evaluated. The original failure is preserved on {@link cause} and the
|
|
6
|
+
* offending expression (if any) on {@link expression}.
|
|
7
|
+
*/
|
|
8
|
+
var ExpressionError = class extends Error {
|
|
9
|
+
expression;
|
|
10
|
+
constructor(message, expression, cause) {
|
|
11
|
+
super(message, { cause });
|
|
12
|
+
this.name = "ExpressionError";
|
|
13
|
+
this.expression = expression;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Raised by the synchronous evaluation helpers when the engine has not finished
|
|
18
|
+
* initializing yet. Await {@link loadEngine} (or render under
|
|
19
|
+
* `<ExpressionEngineProvider>`) before evaluating synchronously.
|
|
20
|
+
*/
|
|
21
|
+
var ExpressionNotReadyError = class extends ExpressionError {
|
|
22
|
+
constructor(message = "Expression engine is not initialized. Await loadEngine() or render under <ExpressionEngineProvider>.") {
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = "ExpressionNotReadyError";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/internal/predicates.ts
|
|
29
|
+
/**
|
|
30
|
+
* Minimal internal type predicates. Inlined so the engine stays dependency-free
|
|
31
|
+
* (no shared-utility package), keeping `@coldsmirk/abacus-core` framework- and
|
|
32
|
+
* ecosystem-agnostic.
|
|
33
|
+
*/
|
|
34
|
+
function isUndefined(value) {
|
|
35
|
+
return value === void 0;
|
|
36
|
+
}
|
|
37
|
+
function isString(value) {
|
|
38
|
+
return typeof value === "string";
|
|
39
|
+
}
|
|
40
|
+
function isArray(value) {
|
|
41
|
+
return Array.isArray(value);
|
|
42
|
+
}
|
|
43
|
+
function isNullish(value) {
|
|
44
|
+
return value === null || value === void 0;
|
|
45
|
+
}
|
|
46
|
+
function isRecord(value) {
|
|
47
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/engine/loader.ts
|
|
51
|
+
let enginePromise = null;
|
|
52
|
+
let engineSync = null;
|
|
53
|
+
let engineError = null;
|
|
54
|
+
let configuredInput;
|
|
55
|
+
let typeContextCache = null;
|
|
56
|
+
function evaluateSafely(expression, run) {
|
|
57
|
+
try {
|
|
58
|
+
return run();
|
|
59
|
+
} catch (error) {
|
|
60
|
+
throw new ExpressionError(`Failed to evaluate expression: ${expression}`, expression, error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function loadFailureMessage() {
|
|
64
|
+
const base = "Failed to load the ZEN expression engine";
|
|
65
|
+
if (typeof window === "undefined") return `${base}. In a non-browser or non-DOM host (Node, SSR, Web Worker) the wasm cannot be auto-resolved; call configureEngine({ wasmInput }) with the wasm bytes or URL before loading.`;
|
|
66
|
+
return base;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Configure how the wasm binary is located, before the engine loads. Must be
|
|
70
|
+
* called before the first {@link loadEngine} (or any evaluation), so that the
|
|
71
|
+
* configured input is the one actually used — calling it after the engine has
|
|
72
|
+
* started loading throws, rather than silently taking no effect.
|
|
73
|
+
*/
|
|
74
|
+
function configureEngine(options) {
|
|
75
|
+
if (enginePromise || engineSync) throw new ExpressionError("configureEngine() must be called before the engine loads.");
|
|
76
|
+
configuredInput = options.wasmInput;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Load and initialize the ZEN expression engine exactly once. Concurrent and
|
|
80
|
+
* subsequent calls share the same in-flight promise / resolved instance. Set a
|
|
81
|
+
* custom wasm source up front with {@link configureEngine}.
|
|
82
|
+
*
|
|
83
|
+
* The GoRules wasm dependency is reached via a dynamic `import()` on purpose: it
|
|
84
|
+
* keeps this module usable from the package's CommonJS build (the dep is
|
|
85
|
+
* ESM-only, so a static `require` would throw) and defers the multi-megabyte
|
|
86
|
+
* wasm download until the engine is actually needed. Do NOT convert this to a
|
|
87
|
+
* static import.
|
|
88
|
+
*
|
|
89
|
+
* A failed load is not cached: the rejected promise is dropped (the error is
|
|
90
|
+
* latched on {@link getEngineError} for inspection), so calling `loadEngine()`
|
|
91
|
+
* again retries from scratch. This is the clear-and-reload retry primitive after
|
|
92
|
+
* a transient failure — an error boundary should call it before resetting.
|
|
93
|
+
*/
|
|
94
|
+
function loadEngine() {
|
|
95
|
+
if (enginePromise) return enginePromise;
|
|
96
|
+
engineError = null;
|
|
97
|
+
enginePromise = (async () => {
|
|
98
|
+
const zen = await import("@gorules/zen-engine-wasm");
|
|
99
|
+
await zen.default(isUndefined(configuredInput) ? void 0 : { module_or_path: configuredInput });
|
|
100
|
+
const toVariableType = (type) => zen.VariableType.fromJson(type);
|
|
101
|
+
const ensureTypeContext = (variables) => {
|
|
102
|
+
if (typeContextCache && typeContextCache.variables === variables) return typeContextCache;
|
|
103
|
+
const stale = typeContextCache;
|
|
104
|
+
typeContextCache = null;
|
|
105
|
+
stale?.handle.free();
|
|
106
|
+
const handle = toVariableType(variables);
|
|
107
|
+
try {
|
|
108
|
+
typeContextCache = {
|
|
109
|
+
variables,
|
|
110
|
+
handle,
|
|
111
|
+
rootKind: handle.toJson()
|
|
112
|
+
};
|
|
113
|
+
} catch (error) {
|
|
114
|
+
handle.free();
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
return typeContextCache;
|
|
118
|
+
};
|
|
119
|
+
const engine = Object.freeze({
|
|
120
|
+
evaluate: (expression, context = {}) => evaluateSafely(expression, () => zen.evaluateExpression(expression, context)),
|
|
121
|
+
evaluateUnary: (expression, context = {}) => evaluateSafely(expression, () => zen.evaluateUnaryExpression(expression, context)),
|
|
122
|
+
validate: (expression) => zen.validateExpression(expression),
|
|
123
|
+
validateUnary: (expression) => zen.validateUnaryExpression(expression),
|
|
124
|
+
getCompletions: () => zen.getCompletions(),
|
|
125
|
+
analyze: (variables, source, unary) => {
|
|
126
|
+
const context = ensureTypeContext(variables);
|
|
127
|
+
const rawSpans = unary ? context.handle.typeCheckUnary(source) : context.handle.typeCheck(source);
|
|
128
|
+
return {
|
|
129
|
+
rootKind: context.rootKind,
|
|
130
|
+
spans: Array.isArray(rawSpans) ? rawSpans : []
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
satisfies: (actual, expected) => {
|
|
134
|
+
const actualType = toVariableType(actual);
|
|
135
|
+
try {
|
|
136
|
+
const expectedType = toVariableType(expected);
|
|
137
|
+
try {
|
|
138
|
+
return actualType.satisfies(expectedType);
|
|
139
|
+
} finally {
|
|
140
|
+
expectedType.free();
|
|
141
|
+
}
|
|
142
|
+
} finally {
|
|
143
|
+
actualType.free();
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
isReady: () => zen.isReady()
|
|
147
|
+
});
|
|
148
|
+
engineSync = engine;
|
|
149
|
+
return engine;
|
|
150
|
+
})().catch((error) => {
|
|
151
|
+
enginePromise = null;
|
|
152
|
+
engineError = new ExpressionError(loadFailureMessage(), void 0, error);
|
|
153
|
+
throw engineError;
|
|
154
|
+
});
|
|
155
|
+
return enginePromise;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Whether the engine has finished initializing and is ready for sync use.
|
|
159
|
+
*/
|
|
160
|
+
function isEngineReady() {
|
|
161
|
+
return engineSync?.isReady() ?? false;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The error from the last failed {@link loadEngine} attempt, or `null`. Used by
|
|
165
|
+
* the React provider to surface a wasm-load failure to an error boundary rather
|
|
166
|
+
* than suspending forever, and by imperative pollers to tell "failed" apart from
|
|
167
|
+
* "still loading". Cleared when a new load starts or {@link resetEngine}.
|
|
168
|
+
*/
|
|
169
|
+
function getEngineError() {
|
|
170
|
+
return engineError;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Return the already-initialized engine synchronously, or throw
|
|
174
|
+
* {@link ExpressionNotReadyError} if {@link loadEngine} has not resolved yet.
|
|
175
|
+
*/
|
|
176
|
+
function getEngineSync() {
|
|
177
|
+
if (!engineSync) throw new ExpressionNotReadyError();
|
|
178
|
+
return engineSync;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Reset the engine singleton — drops the loaded engine, the cached type context,
|
|
182
|
+
* the latched error, and the configured wasm input. Mainly for tests, but also the
|
|
183
|
+
* way to re-run {@link configureEngine} after a load (configure throws once the
|
|
184
|
+
* engine has started loading).
|
|
185
|
+
*/
|
|
186
|
+
function resetEngine() {
|
|
187
|
+
typeContextCache?.handle.free();
|
|
188
|
+
typeContextCache = null;
|
|
189
|
+
enginePromise = null;
|
|
190
|
+
engineSync = null;
|
|
191
|
+
engineError = null;
|
|
192
|
+
configuredInput = void 0;
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/internal/env.ts
|
|
196
|
+
/**
|
|
197
|
+
* Best-effort development-mode flag for diagnostic-only code paths.
|
|
198
|
+
*
|
|
199
|
+
* Detected from `process.env.NODE_ENV` (defined by Node, test runners, webpack,
|
|
200
|
+
* and Vite's SSR/`define`). The `typeof` guard is load-bearing: in a plain
|
|
201
|
+
* browser bundle `process` is not declared at all, and any bare reference would
|
|
202
|
+
* throw a ReferenceError while this module is being imported. Hosts without a
|
|
203
|
+
* `process` default to "production" — the safe choice, since `isDev` only gates
|
|
204
|
+
* extra developer-facing warnings.
|
|
205
|
+
*/
|
|
206
|
+
const isDev = detectDev();
|
|
207
|
+
function detectDev() {
|
|
208
|
+
if (typeof process === "undefined") return false;
|
|
209
|
+
return process.env ? process.env.NODE_ENV !== "production" : false;
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/condition/compile.ts
|
|
213
|
+
/**
|
|
214
|
+
* A subject must be a plain identifier path (`amount`, `user.age`, `items[0]`).
|
|
215
|
+
* It is emitted verbatim into ZEN source, so anything else is rejected to keep
|
|
216
|
+
* the condition compiler from being an expression-injection sink.
|
|
217
|
+
*/
|
|
218
|
+
const SUBJECT_PATTERN = /^[A-Z_$][\w$]*(?:\.[A-Z_$][\w$]*|\[\d+\])*$/i;
|
|
219
|
+
const ZEN_RESERVED_WORDS = new Set([
|
|
220
|
+
"and",
|
|
221
|
+
"or",
|
|
222
|
+
"not",
|
|
223
|
+
"in",
|
|
224
|
+
"true",
|
|
225
|
+
"false",
|
|
226
|
+
"null"
|
|
227
|
+
]);
|
|
228
|
+
function isIdentifierPath(subject) {
|
|
229
|
+
return SUBJECT_PATTERN.test(subject) && (subject.match(/[A-Z_$][\w$]*/gi) ?? []).every((segment) => !ZEN_RESERVED_WORDS.has(segment));
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Serialize a JavaScript value into a ZEN literal. Nullish becomes `null`;
|
|
233
|
+
* numbers / booleans / bigints are emitted verbatim; strings are quoted via
|
|
234
|
+
* {@link encodeZenString}; arrays become `[a, b, ...]`.
|
|
235
|
+
*
|
|
236
|
+
* Throws {@link ExpressionError} for a value with no faithful ZEN
|
|
237
|
+
* representation — an object, symbol, or function, or a string containing both
|
|
238
|
+
* quote styles. Callers that need a sentinel instead of a throw go through
|
|
239
|
+
* {@link compileCondition}, which degrades such a value to a non-compiling
|
|
240
|
+
* (null) condition.
|
|
241
|
+
*/
|
|
242
|
+
function toZenLiteral(value) {
|
|
243
|
+
if (isNullish(value)) return "null";
|
|
244
|
+
if (typeof value === "number") {
|
|
245
|
+
if (!Number.isFinite(value)) throw new ExpressionError(`Number ${String(value)} has no ZEN literal representation`);
|
|
246
|
+
return String(value);
|
|
247
|
+
}
|
|
248
|
+
if (typeof value === "boolean" || typeof value === "bigint") return String(value);
|
|
249
|
+
if (isString(value)) return encodeZenString(value);
|
|
250
|
+
if (isArray(value)) return `[${value.map((item) => toZenLiteral(item)).join(", ")}]`;
|
|
251
|
+
throw new ExpressionError(`Value of type "${typeof value}" has no ZEN literal representation`);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Encode a string as a ZEN literal. ZEN string literals are **raw** between
|
|
255
|
+
* matching quotes and honor no backslash escapes (`'a\nb'` is the four
|
|
256
|
+
* characters `a \ n b`), so the encoder must not escape — it picks a delimiter
|
|
257
|
+
* the value does not contain. A value containing both quote styles cannot be
|
|
258
|
+
* represented as a raw ZEN literal and throws.
|
|
259
|
+
*/
|
|
260
|
+
function encodeZenString(value) {
|
|
261
|
+
const hasSingle = value.includes("'");
|
|
262
|
+
const hasDouble = value.includes("\"");
|
|
263
|
+
if (hasSingle && hasDouble) throw new ExpressionError("String contains both single and double quotes and has no ZEN literal representation");
|
|
264
|
+
return hasSingle ? `"${value}"` : `'${value}'`;
|
|
265
|
+
}
|
|
266
|
+
function toArrayLiteral(value) {
|
|
267
|
+
return isArray(value) ? toZenLiteral(value) : `[${toZenLiteral(value)}]`;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Emit the ZEN emptiness test matching the backend field evaluator's
|
|
271
|
+
* `isEmptyValue`: null, blank (whitespace-only) text, and empty arrays are
|
|
272
|
+
* empty; numbers and booleans never are. ZEN's `or` short-circuits, so the
|
|
273
|
+
* type-guarded branches never evaluate against a null subject. The backend
|
|
274
|
+
* additionally treats an empty map as empty for totality, but form values —
|
|
275
|
+
* the only subjects this compiler targets — are never objects, and ZEN's
|
|
276
|
+
* `len()` does not accept one.
|
|
277
|
+
*/
|
|
278
|
+
function zenIsEmpty(subject) {
|
|
279
|
+
return `(${subject} == null or (type(${subject}) == 'string' and len(trim(${subject})) == 0) or (type(${subject}) == 'array' and len(${subject}) == 0))`;
|
|
280
|
+
}
|
|
281
|
+
function compileFieldCondition(subject, operator, value) {
|
|
282
|
+
switch (operator) {
|
|
283
|
+
case "eq": return `${subject} == ${toZenLiteral(value)}`;
|
|
284
|
+
case "ne": return `${subject} != ${toZenLiteral(value)}`;
|
|
285
|
+
case "gt": return `${subject} > ${toZenLiteral(value)}`;
|
|
286
|
+
case "gte": return `${subject} >= ${toZenLiteral(value)}`;
|
|
287
|
+
case "lt": return `${subject} < ${toZenLiteral(value)}`;
|
|
288
|
+
case "lte": return `${subject} <= ${toZenLiteral(value)}`;
|
|
289
|
+
case "contains": return `contains(${subject}, ${toZenLiteral(value)})`;
|
|
290
|
+
case "not_contains": return `not contains(${subject}, ${toZenLiteral(value)})`;
|
|
291
|
+
case "starts_with": return `startsWith(${subject}, ${toZenLiteral(value)})`;
|
|
292
|
+
case "ends_with": return `endsWith(${subject}, ${toZenLiteral(value)})`;
|
|
293
|
+
case "in": return `${subject} in ${toArrayLiteral(value)}`;
|
|
294
|
+
case "not_in": return `not (${subject} in ${toArrayLiteral(value)})`;
|
|
295
|
+
case "is_empty": return zenIsEmpty(subject);
|
|
296
|
+
case "is_not_empty": return `not ${zenIsEmpty(subject)}`;
|
|
297
|
+
default: throw new ExpressionError(`Unsupported operator: ${String(operator)}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Compile a single condition into a ZEN boolean expression. Field conditions map
|
|
302
|
+
* their operator to ZEN; expression conditions are wrapped in parentheses to
|
|
303
|
+
* preserve their grouping. Returns `null` when the condition is empty, its
|
|
304
|
+
* subject is not an identifier path, or its value has no ZEN representation.
|
|
305
|
+
*/
|
|
306
|
+
function compileCondition(condition) {
|
|
307
|
+
if (condition.kind === "expression") {
|
|
308
|
+
const expression = condition.expression.trim();
|
|
309
|
+
return expression === "" ? null : `(${expression})`;
|
|
310
|
+
}
|
|
311
|
+
const subject = condition.subject.trim();
|
|
312
|
+
if (!isIdentifierPath(subject)) return null;
|
|
313
|
+
try {
|
|
314
|
+
return compileFieldCondition(subject, condition.operator, condition.value);
|
|
315
|
+
} catch {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Compile a condition group (its conditions joined with AND). Returns `null`
|
|
321
|
+
* when the group has no compilable conditions.
|
|
322
|
+
*/
|
|
323
|
+
function compileGroup(group) {
|
|
324
|
+
const parts = group.conditions.map((condition) => compileCondition(condition)).filter((part) => part !== null);
|
|
325
|
+
return parts.length === 0 ? null : parts.join(" and ");
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Compile a branch's condition groups into a single ZEN expression (groups
|
|
329
|
+
* joined with OR). Returns `null` when the branch has no compilable groups
|
|
330
|
+
* (e.g. a default branch).
|
|
331
|
+
*/
|
|
332
|
+
function compileBranch(branch) {
|
|
333
|
+
const groups = (branch.conditionGroups ?? []).map((group) => compileGroup(group)).filter((group) => group !== null);
|
|
334
|
+
return groups.length === 0 ? null : groups.map((group) => `(${group})`).join(" or ");
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Pick the matching branch for the given context using a pre-loaded engine.
|
|
338
|
+
* Non-default branches are tested in ascending `priority` order; the first whose
|
|
339
|
+
* compiled expression evaluates to `true` wins. Falls back to the default
|
|
340
|
+
* branch, or a `null` id when neither matches.
|
|
341
|
+
*
|
|
342
|
+
* A branch whose expression throws for the given context (e.g. ZEN's `>`
|
|
343
|
+
* throws when the subject is missing or non-numeric) is treated as not matching
|
|
344
|
+
* rather than propagating — so a missing field degrades to the default branch
|
|
345
|
+
* instead of crashing the caller.
|
|
346
|
+
*/
|
|
347
|
+
function selectBranchWith(branches, context, engine) {
|
|
348
|
+
const ordered = branches.toSorted((a, b) => a.priority - b.priority);
|
|
349
|
+
for (const branch of ordered) {
|
|
350
|
+
if (branch.isDefault) continue;
|
|
351
|
+
const expression = compileBranch(branch);
|
|
352
|
+
if (expression === null) {
|
|
353
|
+
if (isDev) console.warn(`[expression] branch "${branch.id}" has no compilable condition and can never match`);
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
if (evaluatesTrue(engine, expression, context)) return {
|
|
357
|
+
branchId: branch.id,
|
|
358
|
+
matched: true
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
branchId: ordered.find((branch) => branch.isDefault)?.id ?? null,
|
|
363
|
+
matched: false
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function evaluatesTrue(engine, expression, context) {
|
|
367
|
+
try {
|
|
368
|
+
return engine.evaluate(expression, context) === true;
|
|
369
|
+
} catch (error) {
|
|
370
|
+
if (isDev) reportEvaluationFailure(engine, expression, error);
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function reportEvaluationFailure(engine, expression, error) {
|
|
375
|
+
let diagnostic;
|
|
376
|
+
try {
|
|
377
|
+
diagnostic = engine.validate(expression);
|
|
378
|
+
} catch {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (!isNullish(diagnostic)) console.warn(`[expression] compiled branch expression failed to parse: ${expression}`, diagnostic, error);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Pick the matching branch for the given context, loading the ZEN engine on
|
|
385
|
+
* first use. See {@link selectBranchWith} for the selection semantics.
|
|
386
|
+
*/
|
|
387
|
+
async function selectBranch(branches, context) {
|
|
388
|
+
return selectBranchWith(branches, context, await loadEngine());
|
|
389
|
+
}
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/condition/types.ts
|
|
392
|
+
/**
|
|
393
|
+
* Structural shapes for the visual condition model compiled to ZEN. They mirror
|
|
394
|
+
* the condition types used in the form and flow editors so a host can map those
|
|
395
|
+
* definitions to {@link compileCondition} / {@link selectBranch} without this
|
|
396
|
+
* package depending on either editor. The editors keep a flat working model for
|
|
397
|
+
* form ergonomics (a row can hold both a half-typed field triple and an
|
|
398
|
+
* expression while the author toggles between them); this discriminated input is
|
|
399
|
+
* the narrowed, compiler-facing shape where each kind carries only what it uses.
|
|
400
|
+
*/
|
|
401
|
+
/**
|
|
402
|
+
* The closed operator vocabulary understood by {@link compileCondition}, as a
|
|
403
|
+
* runtime constant so validators can build allow-lists from it instead of
|
|
404
|
+
* re-declaring the set. The {@link ConditionOperator} type derives from this
|
|
405
|
+
* array — one definition site for both the type and the runtime list.
|
|
406
|
+
*/
|
|
407
|
+
const CONDITION_OPERATORS = [
|
|
408
|
+
"eq",
|
|
409
|
+
"ne",
|
|
410
|
+
"gt",
|
|
411
|
+
"gte",
|
|
412
|
+
"lt",
|
|
413
|
+
"lte",
|
|
414
|
+
"contains",
|
|
415
|
+
"not_contains",
|
|
416
|
+
"starts_with",
|
|
417
|
+
"ends_with",
|
|
418
|
+
"in",
|
|
419
|
+
"not_in",
|
|
420
|
+
"is_empty",
|
|
421
|
+
"is_not_empty"
|
|
422
|
+
];
|
|
423
|
+
//#endregion
|
|
424
|
+
//#region src/engine/evaluate.ts
|
|
425
|
+
/**
|
|
426
|
+
* Evaluate a standard ZEN expression, loading the engine on first use.
|
|
427
|
+
*
|
|
428
|
+
* `T` is an **unchecked** assertion — the value is returned as `T` with no
|
|
429
|
+
* runtime validation, and ZEN's result type depends on the expression and
|
|
430
|
+
* context. Prefer the `unknown` default and narrow at the call site.
|
|
431
|
+
*/
|
|
432
|
+
async function evaluate(expression, context) {
|
|
433
|
+
await loadEngine();
|
|
434
|
+
return evaluateSync(expression, context);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Evaluate a ZEN unary (test) expression, loading the engine on first use.
|
|
438
|
+
*/
|
|
439
|
+
async function evaluateUnary(expression, context) {
|
|
440
|
+
await loadEngine();
|
|
441
|
+
return evaluateUnarySync(expression, context);
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Evaluate a standard ZEN expression synchronously. Throws
|
|
445
|
+
* {@link ExpressionNotReadyError} when the engine has not loaded yet — use this
|
|
446
|
+
* only behind a readiness gate (e.g. under `<ExpressionEngineProvider>`).
|
|
447
|
+
*/
|
|
448
|
+
function evaluateSync(expression, context) {
|
|
449
|
+
return getEngineSync().evaluate(expression, context);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Evaluate a ZEN unary (test) expression synchronously. Throws
|
|
453
|
+
* {@link ExpressionNotReadyError} when the engine has not loaded yet.
|
|
454
|
+
*/
|
|
455
|
+
function evaluateUnarySync(expression, context) {
|
|
456
|
+
return getEngineSync().evaluateUnary(expression, context);
|
|
457
|
+
}
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region src/engine/messages.ts
|
|
460
|
+
const COMPLETION_INFO_ZH = {
|
|
461
|
+
"Returns the length of variable": "返回变量的长度",
|
|
462
|
+
"Checks if variable contains a needle": "检查变量是否包含指定元素",
|
|
463
|
+
"Flattens an array": "将数组扁平化",
|
|
464
|
+
"Merges multiple objects into one.": "将多个对象合并为一个。",
|
|
465
|
+
"Deeply merges multiple objects into one.": "将多个对象深度合并为一个。",
|
|
466
|
+
"Converts all characters in a string to uppercase": "将字符串中所有字符转换为大写",
|
|
467
|
+
"Converts all characters in a string to lowercase": "将字符串中所有字符转换为小写",
|
|
468
|
+
"Returns the string with leading and trailing whitespace removed": "返回去除首尾空白后的字符串",
|
|
469
|
+
"Returns true if the string starts with the specified prefix": "若字符串以指定前缀开头则返回 true",
|
|
470
|
+
"Returns true if the string ends with the specified suffix": "若字符串以指定后缀结尾则返回 true",
|
|
471
|
+
"Returns true if the string matches the specified pattern": "若字符串匹配指定模式则返回 true",
|
|
472
|
+
"Extracts matching substrings according to a pattern": "按模式提取匹配的子串",
|
|
473
|
+
"Performs a fuzzy search of the needle in the haystack, and returns the match score(s).": "在目标中对关键字进行模糊搜索,并返回匹配得分。",
|
|
474
|
+
"Splits a string into an array of substrings using the specified delimiter.": "使用指定分隔符将字符串拆分为子串数组。",
|
|
475
|
+
"Returns the absolute value of a number": "返回数字的绝对值",
|
|
476
|
+
"Returns the sum of all elements in the input array.": "返回输入数组中所有元素之和。",
|
|
477
|
+
"Calculates the average of all elements in the input array.": "计算输入数组中所有元素的平均值。",
|
|
478
|
+
"Returns the smallest of the elements in the input array.": "返回输入数组中的最小元素。",
|
|
479
|
+
"Returns the largest of the elements in the input array.": "返回输入数组中的最大元素。",
|
|
480
|
+
"Generates a random number between 0 (inclusive) and max (inclusive).": "生成 0 到 max(均包含)之间的随机数。",
|
|
481
|
+
"Calculates the median value of all elements in the input array.": "计算输入数组中所有元素的中位数。",
|
|
482
|
+
"Finds the mode(s) of the input array, which are the most frequent element(s).": "求输入数组的众数,即出现最频繁的元素。",
|
|
483
|
+
"Rounds a number down to the nearest integer.": "向下取整到最接近的整数。",
|
|
484
|
+
"Rounds a number up to the nearest integer.": "向上取整到最接近的整数。",
|
|
485
|
+
"Rounds a number to a specified number of decimal places.": "将数字四舍五入到指定的小数位数。",
|
|
486
|
+
"Truncates a number to a specified number of decimal places.": "将数字截断到指定的小数位数。",
|
|
487
|
+
"Checks if the given value is of a numeric type.": "检查给定值是否为数值类型。",
|
|
488
|
+
"Converts the given value to a string.": "将给定值转换为字符串。",
|
|
489
|
+
"Converts the given value to a number.": "将给定值转换为数字。",
|
|
490
|
+
"Converts the given value to a boolean.": "将给定值转换为布尔值。",
|
|
491
|
+
"Returns a string representing the data type of the value.": "返回表示该值数据类型的字符串。",
|
|
492
|
+
"Returns an array of a given object's own enumerable property names.": "返回由给定对象自身可枚举属性名组成的数组。",
|
|
493
|
+
"Returns an array of a given object's own enumerable property values.": "返回由给定对象自身可枚举属性值组成的数组。",
|
|
494
|
+
"Returns a new date time instance.": "返回一个新的日期时间实例。",
|
|
495
|
+
"Converts a numeric timestamp to a unix timestamp.": "将数值时间戳转换为 Unix 时间戳。",
|
|
496
|
+
"Extracts the time from a numeric timestamp and returns it as a seconds from beginning of day.": "从数值时间戳中提取时间,以当天起始的秒数返回。",
|
|
497
|
+
"e.g. 1h30min": "例如 1h30min",
|
|
498
|
+
"Extracts the year from a given timestamp.": "从给定时间戳中提取年份。",
|
|
499
|
+
"Gets the day of the week from a given timestamp, where Sunday might be 0.": "获取给定时间戳的星期几(周日可能为 0)。",
|
|
500
|
+
"Extracts the day of the month from a given timestamp.": "从给定时间戳中提取当月的日期。",
|
|
501
|
+
"Gets the day of the year from a given timestamp.": "获取给定时间戳在一年中的第几天。",
|
|
502
|
+
"Calculates the week of the year from a given timestamp.": "计算给定时间戳在一年中的第几周。",
|
|
503
|
+
"Extracts the month from a given timestamp, typically with January as 1.": "从给定时间戳中提取月份(通常 1 月为 1)。",
|
|
504
|
+
"Converts the month from a given timestamp into its string representation (e.g., 'Jan').": "将给定时间戳的月份转换为字符串表示(例如 'Jan')。",
|
|
505
|
+
"Converts a timestamp to a human-readable date string.": "将时间戳转换为人类可读的日期字符串。",
|
|
506
|
+
"Converts the day of the week from a given timestamp into its string representation (e.g., 'Mon').": "将给定时间戳的星期几转换为字符串表示(例如 'Mon')。",
|
|
507
|
+
"Returns the timestamp representing the start of a specified unit (e.g., day, month, year) based on a given timestamp.": "返回给定时间戳在指定单位(如日、月、年)起始处的时间戳。",
|
|
508
|
+
"Returns the timestamp representing the end of a specified unit (e.g., day, month, year) based on a given timestamp.": "返回给定时间戳在指定单位(如日、月、年)结束处的时间戳。",
|
|
509
|
+
"Checks if all elements in the array satisfy the condition defined in the callback.": "检查数组中所有元素是否都满足回调中定义的条件。",
|
|
510
|
+
"Checks if no elements in the array satisfy the condition defined in the callback.": "检查数组中是否没有任何元素满足回调中定义的条件。",
|
|
511
|
+
"Checks if at least one element in the array satisfies the condition defined in the callback.": "检查数组中是否至少有一个元素满足回调中定义的条件。",
|
|
512
|
+
"Checks if exactly one element in the array satisfies the condition defined in the callback.": "检查数组中是否恰好有一个元素满足回调中定义的条件。",
|
|
513
|
+
"Creates a new array with all elements that satisfy the condition defined in the callback.": "创建一个仅包含满足回调中定义条件的元素的新数组。",
|
|
514
|
+
"Creates a new array populated with the results of calling the provided function on every element in the calling array.": "创建一个新数组,其元素为对原数组每个元素调用所提供函数的结果。",
|
|
515
|
+
"First maps each element using a mapping function, then flattens the result into a new array.": "先用映射函数处理每个元素,再将结果扁平化为新数组。",
|
|
516
|
+
"Counts the number of elements in the array that satisfy the condition defined in the callback.": "统计数组中满足回调中定义条件的元素个数。",
|
|
517
|
+
"Adds time to a date": "为日期增加时间",
|
|
518
|
+
"Subtracts time from a date": "从日期中减去时间",
|
|
519
|
+
"Sets a specific unit of time on a date": "设置日期的某个时间单位",
|
|
520
|
+
"Formats a date into a string representation": "将日期格式化为字符串",
|
|
521
|
+
"Returns the start of a specified time unit for a date": "返回日期在指定时间单位上的起始",
|
|
522
|
+
"Returns the end of a specified time unit for a date": "返回日期在指定时间单位上的结束",
|
|
523
|
+
"Calculates the difference between two dates": "计算两个日期之间的差值",
|
|
524
|
+
"Converts a date to a different timezone": "将日期转换到不同的时区",
|
|
525
|
+
"Checks if two dates are the same": "检查两个日期是否相同",
|
|
526
|
+
"Checks if a date is before another date": "检查日期是否早于另一个日期",
|
|
527
|
+
"Checks if a date is after another date": "检查日期是否晚于另一个日期",
|
|
528
|
+
"Checks if a date is the same as or before another date": "检查日期是否等于或早于另一个日期",
|
|
529
|
+
"Checks if a date is the same as or after another date": "检查日期是否等于或晚于另一个日期",
|
|
530
|
+
"Gets the seconds of a date": "获取日期的秒",
|
|
531
|
+
"Gets the minutes of a date": "获取日期的分钟",
|
|
532
|
+
"Gets the hours of a date": "获取日期的小时",
|
|
533
|
+
"Gets the day of the month for a date": "获取日期在当月的第几天",
|
|
534
|
+
"Gets the day of the year for a date": "获取日期在当年的第几天",
|
|
535
|
+
"Gets the week of the year for a date": "获取日期在当年的第几周",
|
|
536
|
+
"Gets the day of the week for a date": "获取日期的星期几",
|
|
537
|
+
"Gets the month for a date": "获取日期的月份",
|
|
538
|
+
"Gets the quarter for a date": "获取日期所在的季度",
|
|
539
|
+
"Gets the year for a date": "获取日期的年份",
|
|
540
|
+
"Gets the Unix timestamp for a date": "获取日期的 Unix 时间戳",
|
|
541
|
+
"Gets the timezone offset name for a date": "获取日期的时区偏移名称",
|
|
542
|
+
"Checks if a date is valid": "检查日期是否有效",
|
|
543
|
+
"Checks if a date is yesterday": "检查日期是否为昨天",
|
|
544
|
+
"Checks if a date is today": "检查日期是否为今天",
|
|
545
|
+
"Checks if a date is tomorrow": "检查日期是否为明天",
|
|
546
|
+
"Checks if the year of a date is a leap year": "检查日期所在年份是否为闰年"
|
|
547
|
+
};
|
|
548
|
+
const EN_SOURCE_LABELS = {
|
|
549
|
+
lexerError: "Lexer error",
|
|
550
|
+
parserError: "Parser error",
|
|
551
|
+
compilerError: "Compiler error",
|
|
552
|
+
vmError: "VM error"
|
|
553
|
+
};
|
|
554
|
+
const ZH_SOURCE_LABELS = {
|
|
555
|
+
lexerError: "词法错误",
|
|
556
|
+
parserError: "语法错误",
|
|
557
|
+
compilerError: "编译错误",
|
|
558
|
+
vmError: "运行时错误"
|
|
559
|
+
};
|
|
560
|
+
function sourceLabelFrom(table, fallback, type) {
|
|
561
|
+
return (type === void 0 ? void 0 : table[type]) ?? fallback;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Built-in English message catalog (the default).
|
|
565
|
+
*/
|
|
566
|
+
const enMessages = {
|
|
567
|
+
sourceLabel: (type) => sourceLabelFrom(EN_SOURCE_LABELS, "Error", type),
|
|
568
|
+
completionInfo: (info) => info,
|
|
569
|
+
typeCheckSource: "Type check",
|
|
570
|
+
expectedBoolean: (actualType) => `Expected a boolean test expression, received \`${actualType}\`.`,
|
|
571
|
+
expectedType: (expectedType, actualType) => `Expected \`${expectedType}\`, received \`${actualType}\`.`
|
|
572
|
+
};
|
|
573
|
+
/**
|
|
574
|
+
* Built-in Simplified Chinese message catalog.
|
|
575
|
+
*/
|
|
576
|
+
const zhCNMessages = {
|
|
577
|
+
sourceLabel: (type) => sourceLabelFrom(ZH_SOURCE_LABELS, "错误", type),
|
|
578
|
+
completionInfo: (info) => info === "" ? "" : COMPLETION_INFO_ZH[info] ?? info,
|
|
579
|
+
typeCheckSource: "类型检查",
|
|
580
|
+
expectedBoolean: (actualType) => `期望布尔测试表达式,实际类型为 \`${actualType}\`。`,
|
|
581
|
+
expectedType: (expectedType, actualType) => `期望 \`${expectedType}\`,实际为 \`${actualType}\`。`
|
|
582
|
+
};
|
|
583
|
+
const localeRegistry = new Map([["en-US", enMessages], ["zh-CN", zhCNMessages]]);
|
|
584
|
+
let activeMessages = enMessages;
|
|
585
|
+
/**
|
|
586
|
+
* Register (or replace) the message catalog for a locale key, making it selectable
|
|
587
|
+
* via {@link configureExpressionMessages}. This is how a host adds a language the
|
|
588
|
+
* library does not ship — the built-in locales are registered the same way, so
|
|
589
|
+
* there is no privileged path.
|
|
590
|
+
*/
|
|
591
|
+
function registerExpressionLocale(locale, messages) {
|
|
592
|
+
localeRegistry.set(locale, messages);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Configure the active message catalog. Pass a `locale`, a partial `messages`
|
|
596
|
+
* override, or both (overrides win). Idempotent and module-global, so a host
|
|
597
|
+
* configures it once (e.g. through `ExpressionConfigProvider`).
|
|
598
|
+
*/
|
|
599
|
+
function configureExpressionMessages({ locale, messages }) {
|
|
600
|
+
const base = locale === void 0 ? activeMessages : localeRegistry.get(locale) ?? activeMessages;
|
|
601
|
+
activeMessages = messages === void 0 ? base : {
|
|
602
|
+
...base,
|
|
603
|
+
...messages
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* The active {@link ExpressionMessages} catalog (English by default).
|
|
608
|
+
*/
|
|
609
|
+
function getExpressionMessages() {
|
|
610
|
+
return activeMessages;
|
|
611
|
+
}
|
|
612
|
+
//#endregion
|
|
613
|
+
//#region src/engine/intellisense.ts
|
|
614
|
+
function parseOffset(text) {
|
|
615
|
+
const trimmed = text?.trim();
|
|
616
|
+
return trimmed ? Number(trimmed) : NaN;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Parse a trailing `... at (from, to)` / `... at pos` position out of a ZEN error
|
|
620
|
+
* message. Returns a `[from, to]` range — a single offset collapses to
|
|
621
|
+
* `[pos, pos]` — or `null` when no position is present.
|
|
622
|
+
*/
|
|
623
|
+
function extractPosition(message) {
|
|
624
|
+
const segments = message.split(" at ");
|
|
625
|
+
const last = segments.length <= 1 ? void 0 : segments.at(-1);
|
|
626
|
+
if (last === void 0) return null;
|
|
627
|
+
const [left, right] = last.replace("(", "").replace(")", "").split(", ");
|
|
628
|
+
const from = parseOffset(left);
|
|
629
|
+
if (Number.isNaN(from)) return null;
|
|
630
|
+
const to = parseOffset(right);
|
|
631
|
+
return [from, Number.isNaN(to) ? from : to];
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Normalize the wasm validate payload (`null` or `{ type, source }`) into a
|
|
635
|
+
* positioned {@link ExpressionDiagnostic}, or `null` when the expression is valid.
|
|
636
|
+
*/
|
|
637
|
+
function normalizeDiagnostic(raw, source) {
|
|
638
|
+
if (raw === null || raw === void 0) return null;
|
|
639
|
+
const errorType = isRecord(raw) && typeof raw.type === "string" ? raw.type : void 0;
|
|
640
|
+
const message = isRecord(raw) && typeof raw.source === "string" ? raw.source : String(raw);
|
|
641
|
+
const [from, to] = extractPosition(message) ?? [0, source.length];
|
|
642
|
+
return {
|
|
643
|
+
from,
|
|
644
|
+
to,
|
|
645
|
+
message,
|
|
646
|
+
source: getExpressionMessages().sourceLabel(errorType)
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Normalize the wasm `getCompletions` payload into a typed list, dropping
|
|
651
|
+
* malformed entries and stripping the backtick markers ZEN wraps type names in.
|
|
652
|
+
*/
|
|
653
|
+
function normalizeCompletions(raw) {
|
|
654
|
+
if (!Array.isArray(raw)) return [];
|
|
655
|
+
const messages = getExpressionMessages();
|
|
656
|
+
return raw.flatMap((entry) => {
|
|
657
|
+
if (!isRecord(entry) || typeof entry.label !== "string" || entry.label === "") return [];
|
|
658
|
+
return [{
|
|
659
|
+
type: entry.type === "method" || entry.type === "variable" ? entry.type : "function",
|
|
660
|
+
label: entry.label,
|
|
661
|
+
detail: typeof entry.detail === "string" ? entry.detail.replaceAll("`", "") : "",
|
|
662
|
+
info: messages.completionInfo(typeof entry.info === "string" ? entry.info : ""),
|
|
663
|
+
boost: typeof entry.boost === "number" ? entry.boost : null,
|
|
664
|
+
methodFor: typeof entry.methodFor === "string" ? entry.methodFor : null
|
|
665
|
+
}];
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Validate an expression, loading the engine on first use. Resolves to `null`
|
|
670
|
+
* when the expression is valid, or a positioned diagnostic otherwise.
|
|
671
|
+
*/
|
|
672
|
+
async function getDiagnostics(expression, mode) {
|
|
673
|
+
await loadEngine();
|
|
674
|
+
return getDiagnosticsSync(expression, mode);
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Synchronous {@link getDiagnostics}. Throws `ExpressionNotReadyError` if the
|
|
678
|
+
* engine has not loaded yet — use only behind a readiness gate.
|
|
679
|
+
*/
|
|
680
|
+
function getDiagnosticsSync(expression, mode) {
|
|
681
|
+
const engine = getEngineSync();
|
|
682
|
+
return normalizeDiagnostic(mode === "unary" ? engine.validateUnary(expression) : engine.validate(expression), expression);
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Return the ZEN built-in completion list, loading the engine on first use.
|
|
686
|
+
*/
|
|
687
|
+
async function getCompletionItems() {
|
|
688
|
+
await loadEngine();
|
|
689
|
+
return getCompletionItemsSync();
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Synchronous {@link getCompletionItems}. Throws `ExpressionNotReadyError` if the
|
|
693
|
+
* engine has not loaded yet.
|
|
694
|
+
*/
|
|
695
|
+
function getCompletionItemsSync() {
|
|
696
|
+
return normalizeCompletions(getEngineSync().getCompletions());
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Type-check an expression against a `variables` context, loading the engine on
|
|
700
|
+
* first use. See {@link ExpressionAnalysis}.
|
|
701
|
+
*/
|
|
702
|
+
async function analyzeTypes(variables, source, mode) {
|
|
703
|
+
await loadEngine();
|
|
704
|
+
return analyzeTypesSync(variables, source, mode);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Synchronous {@link analyzeTypes}. Throws `ExpressionNotReadyError` if the
|
|
708
|
+
* engine has not loaded yet.
|
|
709
|
+
*/
|
|
710
|
+
function analyzeTypesSync(variables, source, mode) {
|
|
711
|
+
return getEngineSync().analyze(variables, source, mode === "unary");
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Whether `actual` satisfies (is assignable to) `expected`, loading the engine on
|
|
715
|
+
* first use. Used for expected-return-type validation.
|
|
716
|
+
*/
|
|
717
|
+
async function satisfiesType(actual, expected) {
|
|
718
|
+
await loadEngine();
|
|
719
|
+
return satisfiesTypeSync(actual, expected);
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Synchronous {@link satisfiesType}. Throws `ExpressionNotReadyError` if the
|
|
723
|
+
* engine has not loaded yet.
|
|
724
|
+
*/
|
|
725
|
+
function satisfiesTypeSync(actual, expected) {
|
|
726
|
+
return getEngineSync().satisfies(actual, expected);
|
|
727
|
+
}
|
|
728
|
+
//#endregion
|
|
729
|
+
exports.CONDITION_OPERATORS = CONDITION_OPERATORS;
|
|
730
|
+
exports.ExpressionError = ExpressionError;
|
|
731
|
+
exports.ExpressionNotReadyError = ExpressionNotReadyError;
|
|
732
|
+
exports.analyzeTypes = analyzeTypes;
|
|
733
|
+
exports.analyzeTypesSync = analyzeTypesSync;
|
|
734
|
+
exports.compileBranch = compileBranch;
|
|
735
|
+
exports.compileCondition = compileCondition;
|
|
736
|
+
exports.compileGroup = compileGroup;
|
|
737
|
+
exports.configureEngine = configureEngine;
|
|
738
|
+
exports.configureExpressionMessages = configureExpressionMessages;
|
|
739
|
+
exports.enMessages = enMessages;
|
|
740
|
+
exports.evaluate = evaluate;
|
|
741
|
+
exports.evaluateSync = evaluateSync;
|
|
742
|
+
exports.evaluateUnary = evaluateUnary;
|
|
743
|
+
exports.evaluateUnarySync = evaluateUnarySync;
|
|
744
|
+
exports.getCompletionItems = getCompletionItems;
|
|
745
|
+
exports.getCompletionItemsSync = getCompletionItemsSync;
|
|
746
|
+
exports.getDiagnostics = getDiagnostics;
|
|
747
|
+
exports.getDiagnosticsSync = getDiagnosticsSync;
|
|
748
|
+
exports.getEngineError = getEngineError;
|
|
749
|
+
exports.getEngineSync = getEngineSync;
|
|
750
|
+
exports.getExpressionMessages = getExpressionMessages;
|
|
751
|
+
exports.isEngineReady = isEngineReady;
|
|
752
|
+
exports.loadEngine = loadEngine;
|
|
753
|
+
exports.registerExpressionLocale = registerExpressionLocale;
|
|
754
|
+
exports.resetEngine = resetEngine;
|
|
755
|
+
exports.satisfiesType = satisfiesType;
|
|
756
|
+
exports.satisfiesTypeSync = satisfiesTypeSync;
|
|
757
|
+
exports.selectBranch = selectBranch;
|
|
758
|
+
exports.selectBranchWith = selectBranchWith;
|
|
759
|
+
exports.toZenLiteral = toZenLiteral;
|
|
760
|
+
exports.zhCNMessages = zhCNMessages;
|
|
761
|
+
|
|
762
|
+
//# sourceMappingURL=index.cjs.map
|