@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/engine/errors.ts","../src/internal/predicates.ts","../src/engine/loader.ts","../src/internal/env.ts","../src/condition/compile.ts","../src/condition/types.ts","../src/engine/evaluate.ts","../src/engine/messages.ts","../src/engine/intellisense.ts"],"sourcesContent":["/**\n * Error raised when the ZEN engine fails to load or an expression cannot be\n * evaluated. The original failure is preserved on {@link cause} and the\n * offending expression (if any) on {@link expression}.\n */\nexport class ExpressionError extends Error {\n readonly expression?: string;\n\n constructor(message: string, expression?: string, cause?: unknown) {\n super(message, { cause });\n this.name = \"ExpressionError\";\n this.expression = expression;\n }\n}\n\n/**\n * Raised by the synchronous evaluation helpers when the engine has not finished\n * initializing yet. Await {@link loadEngine} (or render under\n * `<ExpressionEngineProvider>`) before evaluating synchronously.\n */\nexport class ExpressionNotReadyError extends ExpressionError {\n constructor(\n message = \"Expression engine is not initialized. Await loadEngine() or render under <ExpressionEngineProvider>.\"\n ) {\n super(message);\n this.name = \"ExpressionNotReadyError\";\n }\n}\n","/**\n * Minimal internal type predicates. Inlined so the engine stays dependency-free\n * (no shared-utility package), keeping `@coldsmirk/abacus-core` framework- and\n * ecosystem-agnostic.\n */\n\nexport function isUndefined(value: unknown): value is undefined {\n return value === undefined;\n}\n\nexport function isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\nexport function isNullish(value: unknown): value is null | undefined {\n return value === null || value === undefined;\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","import type { InitInput, VariableType, VariableTypeJson } from \"@gorules/zen-engine-wasm\";\n\nimport type { ExpressionAnalysis, ExpressionType, ExpressionTypeSpan } from \"./intellisense\";\n\nimport { isUndefined } from \"../internal/predicates\";\nimport { ExpressionError, ExpressionNotReadyError } from \"./errors\";\n\n/**\n * The data an expression reads from. Property paths in the expression (e.g.\n * `customer.name`) resolve against this object.\n */\nexport type ExpressionContext = Record<string, unknown>;\n\nexport interface LoadEngineOptions {\n /**\n * Override how the wasm binary is located. By default the engine resolves the\n * co-located `.wasm` through the GoRules package's own `import.meta.url`,\n * which the host bundler (Vite / webpack) rewrites to a served asset URL — no\n * option is needed in normal browser app setups. Supply a URL / Response /\n * bytes for exotic hosting (CDN, embedded buffer) or for a non-browser host\n * (Node / SSR), where `import.meta.url` asset resolution does not work and the\n * input must be provided explicitly. Aliased to the wasm initializer's own\n * `InitInput` so it never drifts from the dependency.\n */\n wasmInput?: InitInput;\n}\n\n/**\n * The initialized ZEN expression engine. Every method is synchronous — obtain\n * an instance via {@link loadEngine} (async, loads the wasm) before calling.\n */\nexport interface ExpressionEngine {\n /**\n * Evaluate a standard ZEN expression, returning its computed value.\n */\n evaluate: <T = unknown>(expression: string, context?: ExpressionContext) => T;\n /**\n * Evaluate a ZEN unary (test) expression, returning a boolean.\n */\n evaluateUnary: (expression: string, context?: ExpressionContext) => boolean;\n /**\n * Validate a standard expression; returns ZEN's diagnostic payload (`null`\n * when the expression parses, an error object otherwise).\n */\n validate: (expression: string) => unknown;\n /**\n * Validate a unary expression; returns ZEN's diagnostic payload.\n */\n validateUnary: (expression: string) => unknown;\n /**\n * Return ZEN's completion metadata, for building an expression editor.\n */\n getCompletions: () => unknown;\n /**\n * Type-check `source` against a `variables` context, returning the root context\n * type and the inferred type of every span (`unary` selects test-expression\n * checking). Powers an editor's type-aware completion / hover / diagnostics.\n */\n analyze: (variables: ExpressionType, source: string, unary: boolean) => ExpressionAnalysis;\n /**\n * Whether `actual` satisfies (is assignable to) `expected`. Powers\n * expected-return-type validation in an editor.\n */\n satisfies: (actual: ExpressionType, expected: ExpressionType) => boolean;\n /**\n * Whether the underlying wasm module reports itself ready.\n */\n isReady: () => boolean;\n}\n\ninterface TypeContext {\n variables: ExpressionType;\n handle: VariableType;\n rootKind: ExpressionType;\n}\n\nlet enginePromise: Promise<ExpressionEngine> | null = null;\nlet engineSync: ExpressionEngine | null = null;\nlet engineError: ExpressionError | null = null;\nlet configuredInput: InitInput | undefined;\n// The compiled variable context, cached by `variables` reference (see analyze).\nlet typeContextCache: TypeContext | null = null;\n\nfunction evaluateSafely<T>(expression: string, run: () => T): T {\n try {\n return run();\n } catch (error) {\n throw new ExpressionError(`Failed to evaluate expression: ${expression}`, expression, error);\n }\n}\n\nfunction loadFailureMessage(): string {\n const base = \"Failed to load the ZEN expression engine\";\n\n // typeof, not a property read: the standard environment probe that survives\n // both hosts without a DOM and lint rewrites of global-object aliases.\n if (typeof window === \"undefined\") {\n 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.`;\n }\n\n return base;\n}\n\n/**\n * Configure how the wasm binary is located, before the engine loads. Must be\n * called before the first {@link loadEngine} (or any evaluation), so that the\n * configured input is the one actually used — calling it after the engine has\n * started loading throws, rather than silently taking no effect.\n */\nexport function configureEngine(options: LoadEngineOptions): void {\n if (enginePromise || engineSync) {\n throw new ExpressionError(\"configureEngine() must be called before the engine loads.\");\n }\n\n configuredInput = options.wasmInput;\n}\n\n/**\n * Load and initialize the ZEN expression engine exactly once. Concurrent and\n * subsequent calls share the same in-flight promise / resolved instance. Set a\n * custom wasm source up front with {@link configureEngine}.\n *\n * The GoRules wasm dependency is reached via a dynamic `import()` on purpose: it\n * keeps this module usable from the package's CommonJS build (the dep is\n * ESM-only, so a static `require` would throw) and defers the multi-megabyte\n * wasm download until the engine is actually needed. Do NOT convert this to a\n * static import.\n *\n * A failed load is not cached: the rejected promise is dropped (the error is\n * latched on {@link getEngineError} for inspection), so calling `loadEngine()`\n * again retries from scratch. This is the clear-and-reload retry primitive after\n * a transient failure — an error boundary should call it before resetting.\n */\nexport function loadEngine(): Promise<ExpressionEngine> {\n if (enginePromise) {\n return enginePromise;\n }\n\n engineError = null;\n enginePromise = (async () => {\n const zen = await import(\"@gorules/zen-engine-wasm\");\n\n await zen.default(isUndefined(configuredInput) ? undefined : { module_or_path: configuredInput });\n\n // The wasm `VariableTypeJson` omits \"Date\" — a kind the ZEN engine itself\n // emits and accepts — so ExpressionType is a deliberate superset. This is the\n // single wasm-boundary cast that bridges the two.\n const toVariableType = (type: ExpressionType): VariableType => zen.VariableType.fromJson(type as VariableTypeJson);\n\n // Cache the compiled VariableType and its rootKind by `variables` reference:\n // both are document-independent, so per-keystroke type-checking reuses them\n // instead of rebuilding the wasm handle on every edit (the editor targets 100s\n // of fields). A changed reference frees the previous handle before rebuilding;\n // `typeContextCache` is nulled first so a throw never leaves a freed handle\n // cached, and a `toJson()` throw frees the freshly built handle it would\n // otherwise strand (built but neither cached nor freed).\n const ensureTypeContext = (variables: ExpressionType): TypeContext => {\n if (typeContextCache && typeContextCache.variables === variables) {\n return typeContextCache;\n }\n\n const stale = typeContextCache;\n typeContextCache = null;\n stale?.handle.free();\n const handle = toVariableType(variables);\n\n try {\n typeContextCache = {\n variables,\n handle,\n rootKind: handle.toJson()\n };\n } catch (error) {\n handle.free();\n throw error;\n }\n\n return typeContextCache;\n };\n\n const engine: ExpressionEngine = Object.freeze({\n evaluate: <T = unknown>(expression: string, context: ExpressionContext = {}): T => evaluateSafely(expression, () => zen.evaluateExpression(expression, context) as T),\n evaluateUnary: (expression: string, context: ExpressionContext = {}): boolean => evaluateSafely(expression, () => zen.evaluateUnaryExpression(expression, context)),\n validate: (expression: string): unknown => zen.validateExpression(expression),\n validateUnary: (expression: string): unknown => zen.validateUnaryExpression(expression),\n getCompletions: (): unknown => zen.getCompletions(),\n analyze: (variables: ExpressionType, source: string, unary: boolean): ExpressionAnalysis => {\n const context = ensureTypeContext(variables);\n // `typeCheck` is typed `any` by the wasm bindings; gate it to `unknown`, then\n // assert the element shape only once confirmed an array. The shape is fixed by\n // the pinned zen-engine-wasm version, so one boundary assertion is sound.\n const rawSpans: unknown = unary ? context.handle.typeCheckUnary(source) : context.handle.typeCheck(source);\n\n return {\n rootKind: context.rootKind,\n spans: Array.isArray(rawSpans) ? rawSpans as ExpressionTypeSpan[] : []\n };\n },\n // Acquire both handles leak-safely: the second acquisition lives inside the\n // first's try so a throw from it still frees the first (wasm handles are not\n // GC-managed). A portable equivalent of `using` without relying on Node 22's\n // explicit-resource-management runtime support.\n satisfies: (actual: ExpressionType, expected: ExpressionType): boolean => {\n const actualType = toVariableType(actual);\n\n try {\n const expectedType = toVariableType(expected);\n\n try {\n return actualType.satisfies(expectedType);\n } finally {\n expectedType.free();\n }\n } finally {\n actualType.free();\n }\n },\n isReady: (): boolean => zen.isReady()\n });\n\n engineSync = engine;\n return engine;\n })().catch((error: unknown) => {\n // Drop the rejected promise so a later imperative call can retry the load,\n // but remember the failure so the React provider can surface it to an error\n // boundary instead of re-suspending on a fresh load forever.\n enginePromise = null;\n engineError = new ExpressionError(loadFailureMessage(), undefined, error);\n throw engineError;\n });\n\n return enginePromise;\n}\n\n/**\n * Whether the engine has finished initializing and is ready for sync use.\n */\nexport function isEngineReady(): boolean {\n return engineSync?.isReady() ?? false;\n}\n\n/**\n * The error from the last failed {@link loadEngine} attempt, or `null`. Used by\n * the React provider to surface a wasm-load failure to an error boundary rather\n * than suspending forever, and by imperative pollers to tell \"failed\" apart from\n * \"still loading\". Cleared when a new load starts or {@link resetEngine}.\n */\nexport function getEngineError(): ExpressionError | null {\n return engineError;\n}\n\n/**\n * Return the already-initialized engine synchronously, or throw\n * {@link ExpressionNotReadyError} if {@link loadEngine} has not resolved yet.\n */\nexport function getEngineSync(): ExpressionEngine {\n if (!engineSync) {\n throw new ExpressionNotReadyError();\n }\n\n return engineSync;\n}\n\n/**\n * Reset the engine singleton — drops the loaded engine, the cached type context,\n * the latched error, and the configured wasm input. Mainly for tests, but also the\n * way to re-run {@link configureEngine} after a load (configure throws once the\n * engine has started loading).\n */\nexport function resetEngine(): void {\n typeContextCache?.handle.free();\n typeContextCache = null;\n enginePromise = null;\n engineSync = null;\n engineError = null;\n configuredInput = undefined;\n}\n","/**\n * Best-effort development-mode flag for diagnostic-only code paths.\n *\n * Detected from `process.env.NODE_ENV` (defined by Node, test runners, webpack,\n * and Vite's SSR/`define`). The `typeof` guard is load-bearing: in a plain\n * browser bundle `process` is not declared at all, and any bare reference would\n * throw a ReferenceError while this module is being imported. Hosts without a\n * `process` default to \"production\" — the safe choice, since `isDev` only gates\n * extra developer-facing warnings.\n */\nexport const isDev: boolean = detectDev();\n\nfunction detectDev(): boolean {\n if (typeof process === \"undefined\") {\n return false;\n }\n\n return process.env ? process.env.NODE_ENV !== \"production\" : false;\n}\n","import type { ExpressionContext, ExpressionEngine } from \"../engine/loader\";\nimport type {\n BranchSelection,\n ConditionBranchInput,\n ConditionGroupInput,\n ConditionInput,\n ConditionOperator\n} from \"./types\";\n\nimport { ExpressionError } from \"../engine/errors\";\nimport { loadEngine } from \"../engine/loader\";\nimport { isDev } from \"../internal/env\";\nimport { isArray, isNullish, isString } from \"../internal/predicates\";\n\n/**\n * A subject must be a plain identifier path (`amount`, `user.age`, `items[0]`).\n * It is emitted verbatim into ZEN source, so anything else is rejected to keep\n * the condition compiler from being an expression-injection sink.\n */\nconst SUBJECT_PATTERN = /^[A-Z_$][\\w$]*(?:\\.[A-Z_$][\\w$]*|\\[\\d+\\])*$/i;\n\n// ZEN's operator and literal keywords. The path pattern alone would accept them\n// as identifiers, compiling well-formed nonsense like `true == 5` or `not > 1`\n// that evaluates without error and silently never (or always) matches; a path\n// segment hitting one degrades the condition to null like any invalid subject.\nconst ZEN_RESERVED_WORDS = new Set([\"and\", \"or\", \"not\", \"in\", \"true\", \"false\", \"null\"]);\n\nfunction isIdentifierPath(subject: string): boolean {\n return SUBJECT_PATTERN.test(subject)\n && (subject.match(/[A-Z_$][\\w$]*/gi) ?? []).every(segment => !ZEN_RESERVED_WORDS.has(segment));\n}\n\n/**\n * Serialize a JavaScript value into a ZEN literal. Nullish becomes `null`;\n * numbers / booleans / bigints are emitted verbatim; strings are quoted via\n * {@link encodeZenString}; arrays become `[a, b, ...]`.\n *\n * Throws {@link ExpressionError} for a value with no faithful ZEN\n * representation — an object, symbol, or function, or a string containing both\n * quote styles. Callers that need a sentinel instead of a throw go through\n * {@link compileCondition}, which degrades such a value to a non-compiling\n * (null) condition.\n */\nexport function toZenLiteral(value: unknown): string {\n if (isNullish(value)) {\n return \"null\";\n }\n\n if (typeof value === \"number\") {\n // NaN / Infinity stringify to bare identifiers (\"NaN\", \"Infinity\") that ZEN\n // resolves to null, silently corrupting comparisons — reject them so the value\n // degrades to a null (non-compiling) condition like other unrepresentable ones.\n if (!Number.isFinite(value)) {\n throw new ExpressionError(`Number ${String(value)} has no ZEN literal representation`);\n }\n\n return String(value);\n }\n\n if (typeof value === \"boolean\" || typeof value === \"bigint\") {\n return String(value);\n }\n\n if (isString(value)) {\n return encodeZenString(value);\n }\n\n if (isArray(value)) {\n return `[${value.map(item => toZenLiteral(item)).join(\", \")}]`;\n }\n\n throw new ExpressionError(`Value of type \"${typeof value}\" has no ZEN literal representation`);\n}\n\n/**\n * Encode a string as a ZEN literal. ZEN string literals are **raw** between\n * matching quotes and honor no backslash escapes (`'a\\nb'` is the four\n * characters `a \\ n b`), so the encoder must not escape — it picks a delimiter\n * the value does not contain. A value containing both quote styles cannot be\n * represented as a raw ZEN literal and throws.\n */\nfunction encodeZenString(value: string): string {\n const hasSingle = value.includes(\"'\");\n const hasDouble = value.includes(\"\\\"\");\n\n if (hasSingle && hasDouble) {\n throw new ExpressionError(\"String contains both single and double quotes and has no ZEN literal representation\");\n }\n\n return hasSingle ? `\"${value}\"` : `'${value}'`;\n}\n\nfunction toArrayLiteral(value: unknown): string {\n return isArray(value) ? toZenLiteral(value) : `[${toZenLiteral(value)}]`;\n}\n\n/**\n * Emit the ZEN emptiness test matching the backend field evaluator's\n * `isEmptyValue`: null, blank (whitespace-only) text, and empty arrays are\n * empty; numbers and booleans never are. ZEN's `or` short-circuits, so the\n * type-guarded branches never evaluate against a null subject. The backend\n * additionally treats an empty map as empty for totality, but form values —\n * the only subjects this compiler targets — are never objects, and ZEN's\n * `len()` does not accept one.\n */\nfunction zenIsEmpty(subject: string): string {\n return `(${subject} == null`\n + ` or (type(${subject}) == 'string' and len(trim(${subject})) == 0)`\n + ` or (type(${subject}) == 'array' and len(${subject}) == 0))`;\n}\n\nfunction compileFieldCondition(subject: string, operator: ConditionOperator, value: unknown): string {\n switch (operator) {\n case \"eq\": {\n return `${subject} == ${toZenLiteral(value)}`;\n }\n\n case \"ne\": {\n return `${subject} != ${toZenLiteral(value)}`;\n }\n\n case \"gt\": {\n return `${subject} > ${toZenLiteral(value)}`;\n }\n\n case \"gte\": {\n return `${subject} >= ${toZenLiteral(value)}`;\n }\n\n case \"lt\": {\n return `${subject} < ${toZenLiteral(value)}`;\n }\n\n case \"lte\": {\n return `${subject} <= ${toZenLiteral(value)}`;\n }\n\n case \"contains\": {\n return `contains(${subject}, ${toZenLiteral(value)})`;\n }\n\n case \"not_contains\": {\n return `not contains(${subject}, ${toZenLiteral(value)})`;\n }\n\n case \"starts_with\": {\n return `startsWith(${subject}, ${toZenLiteral(value)})`;\n }\n\n case \"ends_with\": {\n return `endsWith(${subject}, ${toZenLiteral(value)})`;\n }\n\n case \"in\": {\n return `${subject} in ${toArrayLiteral(value)}`;\n }\n\n case \"not_in\": {\n return `not (${subject} in ${toArrayLiteral(value)})`;\n }\n\n case \"is_empty\": {\n return zenIsEmpty(subject);\n }\n\n case \"is_not_empty\": {\n return `not ${zenIsEmpty(subject)}`;\n }\n\n default: {\n // Exhaustiveness guard: adding a ConditionOperator without a case here is a\n // compile error. The throw only covers runtime-invalid data forced past the\n // type with a cast, and is caught by compileCondition.\n operator satisfies never;\n throw new ExpressionError(`Unsupported operator: ${String(operator)}`);\n }\n }\n}\n\n/**\n * Compile a single condition into a ZEN boolean expression. Field conditions map\n * their operator to ZEN; expression conditions are wrapped in parentheses to\n * preserve their grouping. Returns `null` when the condition is empty, its\n * subject is not an identifier path, or its value has no ZEN representation.\n */\nexport function compileCondition(condition: ConditionInput): string | null {\n if (condition.kind === \"expression\") {\n const expression = condition.expression.trim();\n // Parenthesize: a raw expression with a top-level `or` / ternary would be\n // regrouped by ZEN precedence once a group joins parts with ` and ` (which\n // binds tighter than `or`), silently selecting the wrong branch.\n return expression === \"\" ? null : `(${expression})`;\n }\n\n const subject = condition.subject.trim();\n\n if (!isIdentifierPath(subject)) {\n return null;\n }\n\n try {\n return compileFieldCondition(subject, condition.operator, condition.value);\n } catch {\n // A value with no ZEN representation (object value, both-quote string) or a\n // cast-in invalid operator makes the condition uncompilable; degrade it to\n // null like an invalid subject so the group simply drops it.\n return null;\n }\n}\n\n/**\n * Compile a condition group (its conditions joined with AND). Returns `null`\n * when the group has no compilable conditions.\n */\nexport function compileGroup(group: ConditionGroupInput): string | null {\n const parts = group.conditions\n .map(condition => compileCondition(condition))\n .filter(part => part !== null);\n\n return parts.length === 0 ? null : parts.join(\" and \");\n}\n\n/**\n * Compile a branch's condition groups into a single ZEN expression (groups\n * joined with OR). Returns `null` when the branch has no compilable groups\n * (e.g. a default branch).\n */\nexport function compileBranch(branch: ConditionBranchInput): string | null {\n const groups = (branch.conditionGroups ?? [])\n .map(group => compileGroup(group))\n .filter(group => group !== null);\n\n return groups.length === 0 ? null : groups.map(group => `(${group})`).join(\" or \");\n}\n\n/**\n * Pick the matching branch for the given context using a pre-loaded engine.\n * Non-default branches are tested in ascending `priority` order; the first whose\n * compiled expression evaluates to `true` wins. Falls back to the default\n * branch, or a `null` id when neither matches.\n *\n * A branch whose expression throws for the given context (e.g. ZEN's `>`\n * throws when the subject is missing or non-numeric) is treated as not matching\n * rather than propagating — so a missing field degrades to the default branch\n * instead of crashing the caller.\n */\nexport function selectBranchWith(\n branches: readonly ConditionBranchInput[],\n context: ExpressionContext,\n engine: Pick<ExpressionEngine, \"evaluate\" | \"validate\">\n): BranchSelection {\n const ordered = branches.toSorted((a, b) => a.priority - b.priority);\n\n for (const branch of ordered) {\n if (branch.isDefault) {\n continue;\n }\n\n const expression = compileBranch(branch);\n\n if (expression === null) {\n // A non-default branch that compiles to nothing can never match — almost\n // always a configuration bug (mistyped subject, unrepresentable value)\n // that would otherwise surface only as \"always falls through to default\".\n if (isDev) {\n console.warn(`[expression] branch \"${branch.id}\" has no compilable condition and can never match`);\n }\n\n continue;\n }\n\n if (evaluatesTrue(engine, expression, context)) {\n return { branchId: branch.id, matched: true };\n }\n }\n\n const fallback = ordered.find(branch => branch.isDefault);\n return { branchId: fallback?.id ?? null, matched: false };\n}\n\nfunction evaluatesTrue(\n engine: Pick<ExpressionEngine, \"evaluate\" | \"validate\">,\n expression: string,\n context: ExpressionContext\n): boolean {\n try {\n return engine.evaluate(expression, context) === true;\n } catch (error) {\n if (isDev) {\n reportEvaluationFailure(engine, expression, error);\n }\n\n return false;\n }\n}\n\nfunction reportEvaluationFailure(\n engine: Pick<ExpressionEngine, \"validate\">,\n expression: string,\n error: unknown\n): void {\n // A compiled branch expression that fails to PARSE signals a bug in this\n // package's own emitter, not a runtime type mismatch (ZEN's `>` on a missing\n // field, the intended degrade-to-default path). validate() returns null for a\n // parsable expression and a diagnostic object otherwise, so surface only the\n // former — a real authoring/emitter bug should not hide behind the fallback.\n let diagnostic: unknown;\n\n try {\n diagnostic = engine.validate(expression);\n } catch {\n return;\n }\n\n if (!isNullish(diagnostic)) {\n console.warn(`[expression] compiled branch expression failed to parse: ${expression}`, diagnostic, error);\n }\n}\n\n/**\n * Pick the matching branch for the given context, loading the ZEN engine on\n * first use. See {@link selectBranchWith} for the selection semantics.\n */\nexport async function selectBranch(\n branches: readonly ConditionBranchInput[],\n context: ExpressionContext\n): Promise<BranchSelection> {\n const engine = await loadEngine();\n return selectBranchWith(branches, context, engine);\n}\n","/**\n * Structural shapes for the visual condition model compiled to ZEN. They mirror\n * the condition types used in the form and flow editors so a host can map those\n * definitions to {@link compileCondition} / {@link selectBranch} without this\n * package depending on either editor. The editors keep a flat working model for\n * form ergonomics (a row can hold both a half-typed field triple and an\n * expression while the author toggles between them); this discriminated input is\n * the narrowed, compiler-facing shape where each kind carries only what it uses.\n */\n\n/**\n * The closed operator vocabulary understood by {@link compileCondition}, as a\n * runtime constant so validators can build allow-lists from it instead of\n * re-declaring the set. The {@link ConditionOperator} type derives from this\n * array — one definition site for both the type and the runtime list.\n */\nexport const CONDITION_OPERATORS = [\n \"eq\",\n \"ne\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"contains\",\n \"not_contains\",\n \"starts_with\",\n \"ends_with\",\n \"in\",\n \"not_in\",\n \"is_empty\",\n \"is_not_empty\"\n] as const;\n\n/**\n * Operators understood by {@link compileCondition}. The compiler maps each to a\n * ZEN expression; this closed set is the single source of truth for the operator\n * vocabulary (the flow editor shares it instead of re-declaring its own).\n */\nexport type ConditionOperator = typeof CONDITION_OPERATORS[number];\n\n/**\n * A field/operator/value condition.\n */\nexport interface FieldConditionInput {\n kind: \"field\";\n /**\n * The field path the operator tests. Emitted **verbatim** into the compiled\n * ZEN source as a path expression (guarded by an identifier-path pattern that\n * also rejects ZEN reserved words such as `true` or `not` as segments), unlike\n * `value`, which is serialized to a ZEN literal — so callers must supply a\n * valid identifier path, not arbitrary user text.\n */\n subject: string;\n operator: ConditionOperator;\n value: unknown;\n}\n\n/**\n * A raw ZEN expression condition, passed through to the engine verbatim.\n */\nexport interface ExpressionConditionInput {\n kind: \"expression\";\n expression: string;\n}\n\n/**\n * A single condition: either a field/operator/value triple or a raw expression.\n */\nexport type ConditionInput = FieldConditionInput | ExpressionConditionInput;\n\n/**\n * A group of conditions, combined with AND.\n */\nexport interface ConditionGroupInput {\n conditions: readonly ConditionInput[];\n}\n\n/**\n * A branch guarded by one or more condition groups (combined with OR).\n */\nexport interface ConditionBranchInput {\n id: string;\n priority: number;\n isDefault?: boolean;\n conditionGroups?: readonly ConditionGroupInput[];\n}\n\n/**\n * The branch chosen by {@link selectBranch}. `matched` is true only when a\n * non-default branch's expression evaluated true (then `branchId` is that\n * branch's id). On the default-branch fallback `matched` is false while\n * `branchId` is the default's id; `branchId` is null only when nothing matched\n * and there is no default branch.\n */\nexport type BranchSelection\n = | { matched: true; branchId: string }\n | { matched: false; branchId: string | null };\n","import type { ExpressionContext } from \"./loader\";\n\nimport { getEngineSync, loadEngine } from \"./loader\";\n\n/**\n * Evaluate a standard ZEN expression, loading the engine on first use.\n *\n * `T` is an **unchecked** assertion — the value is returned as `T` with no\n * runtime validation, and ZEN's result type depends on the expression and\n * context. Prefer the `unknown` default and narrow at the call site.\n */\nexport async function evaluate<T = unknown>(expression: string, context?: ExpressionContext): Promise<T> {\n await loadEngine();\n return evaluateSync<T>(expression, context);\n}\n\n/**\n * Evaluate a ZEN unary (test) expression, loading the engine on first use.\n */\nexport async function evaluateUnary(expression: string, context?: ExpressionContext): Promise<boolean> {\n await loadEngine();\n return evaluateUnarySync(expression, context);\n}\n\n/**\n * Evaluate a standard ZEN expression synchronously. Throws\n * {@link ExpressionNotReadyError} when the engine has not loaded yet — use this\n * only behind a readiness gate (e.g. under `<ExpressionEngineProvider>`).\n */\nexport function evaluateSync<T = unknown>(expression: string, context?: ExpressionContext): T {\n return getEngineSync().evaluate<T>(expression, context);\n}\n\n/**\n * Evaluate a ZEN unary (test) expression synchronously. Throws\n * {@link ExpressionNotReadyError} when the engine has not loaded yet.\n */\nexport function evaluateUnarySync(expression: string, context?: ExpressionContext): boolean {\n return getEngineSync().evaluateUnary(expression, context);\n}\n","/**\n * The locales the library ships with out of the box.\n */\nexport type BuiltInExpressionLocale = \"en-US\" | \"zh-CN\";\n\n/**\n * A locale key for editor-produced text (built-in descriptions, type-check prose,\n * and diagnostic origin labels — the wasm engine's own error bodies, identifiers,\n * and type signatures are never translated). The built-in locales surface in\n * autocomplete, while any string is accepted so a host can select a locale\n * registered through {@link registerExpressionLocale}.\n */\nexport type ExpressionLocale = BuiltInExpressionLocale | (string & {});\n\n/**\n * The catalog of editor-produced messages for one locale. All localized text the\n * editor surfaces flows through this interface, so a host can switch language or\n * override individual strings in one typed place — and add a language the library\n * does not ship by passing a full `messages` object to\n * {@link configureExpressionMessages}.\n */\nexport interface ExpressionMessages {\n /**\n * The diagnostic origin label for a wasm error `type` (`\"parserError\"` →\n * `\"Parser error\"`), falling back to a generic label for an unknown type.\n */\n sourceLabel: (type?: string) => string;\n /**\n * Translate a built-in's English `info` description to this locale. Returns the\n * input unchanged for English or when no translation exists.\n */\n completionInfo: (englishInfo: string) => string;\n /**\n * The `source` label shown on type-check (as opposed to syntax) diagnostics.\n */\n typeCheckSource: string;\n /**\n * Warning shown when a unary (test) expression does not evaluate to a boolean.\n */\n expectedBoolean: (actualType: string) => string;\n /**\n * Warning shown when a standard expression's result type does not satisfy the\n * configured expected type.\n */\n expectedType: (expectedType: string, actualType: string) => string;\n}\n\n// Built-in descriptions, keyed by the engine's English `info` text rather than by\n// label. The builtin catalog is finite and the descriptions are stable, while\n// labels collide (the function `year` and the Date method `year` share a name but\n// carry different descriptions) — keying on the description sidesteps that and\n// degrades gracefully (an unmapped/renamed builtin falls through to English).\nconst COMPLETION_INFO_ZH: Record<string, string> = {\n // String / array / object functions\n \"Returns the length of variable\": \"返回变量的长度\",\n \"Checks if variable contains a needle\": \"检查变量是否包含指定元素\",\n \"Flattens an array\": \"将数组扁平化\",\n \"Merges multiple objects into one.\": \"将多个对象合并为一个。\",\n \"Deeply merges multiple objects into one.\": \"将多个对象深度合并为一个。\",\n \"Converts all characters in a string to uppercase\": \"将字符串中所有字符转换为大写\",\n \"Converts all characters in a string to lowercase\": \"将字符串中所有字符转换为小写\",\n \"Returns the string with leading and trailing whitespace removed\": \"返回去除首尾空白后的字符串\",\n \"Returns true if the string starts with the specified prefix\": \"若字符串以指定前缀开头则返回 true\",\n \"Returns true if the string ends with the specified suffix\": \"若字符串以指定后缀结尾则返回 true\",\n \"Returns true if the string matches the specified pattern\": \"若字符串匹配指定模式则返回 true\",\n \"Extracts matching substrings according to a pattern\": \"按模式提取匹配的子串\",\n \"Performs a fuzzy search of the needle in the haystack, and returns the match score(s).\": \"在目标中对关键字进行模糊搜索,并返回匹配得分。\",\n \"Splits a string into an array of substrings using the specified delimiter.\": \"使用指定分隔符将字符串拆分为子串数组。\",\n\n // Math / aggregation functions\n \"Returns the absolute value of a number\": \"返回数字的绝对值\",\n \"Returns the sum of all elements in the input array.\": \"返回输入数组中所有元素之和。\",\n \"Calculates the average of all elements in the input array.\": \"计算输入数组中所有元素的平均值。\",\n \"Returns the smallest of the elements in the input array.\": \"返回输入数组中的最小元素。\",\n \"Returns the largest of the elements in the input array.\": \"返回输入数组中的最大元素。\",\n \"Generates a random number between 0 (inclusive) and max (inclusive).\": \"生成 0 到 max(均包含)之间的随机数。\",\n \"Calculates the median value of all elements in the input array.\": \"计算输入数组中所有元素的中位数。\",\n \"Finds the mode(s) of the input array, which are the most frequent element(s).\": \"求输入数组的众数,即出现最频繁的元素。\",\n \"Rounds a number down to the nearest integer.\": \"向下取整到最接近的整数。\",\n \"Rounds a number up to the nearest integer.\": \"向上取整到最接近的整数。\",\n \"Rounds a number to a specified number of decimal places.\": \"将数字四舍五入到指定的小数位数。\",\n \"Truncates a number to a specified number of decimal places.\": \"将数字截断到指定的小数位数。\",\n\n // Type / conversion functions\n \"Checks if the given value is of a numeric type.\": \"检查给定值是否为数值类型。\",\n \"Converts the given value to a string.\": \"将给定值转换为字符串。\",\n \"Converts the given value to a number.\": \"将给定值转换为数字。\",\n \"Converts the given value to a boolean.\": \"将给定值转换为布尔值。\",\n \"Returns a string representing the data type of the value.\": \"返回表示该值数据类型的字符串。\",\n \"Returns an array of a given object's own enumerable property names.\": \"返回由给定对象自身可枚举属性名组成的数组。\",\n \"Returns an array of a given object's own enumerable property values.\": \"返回由给定对象自身可枚举属性值组成的数组。\",\n\n // Date / time functions\n \"Returns a new date time instance.\": \"返回一个新的日期时间实例。\",\n \"Converts a numeric timestamp to a unix timestamp.\": \"将数值时间戳转换为 Unix 时间戳。\",\n \"Extracts the time from a numeric timestamp and returns it as a seconds from beginning of day.\": \"从数值时间戳中提取时间,以当天起始的秒数返回。\",\n \"e.g. 1h30min\": \"例如 1h30min\",\n \"Extracts the year from a given timestamp.\": \"从给定时间戳中提取年份。\",\n \"Gets the day of the week from a given timestamp, where Sunday might be 0.\": \"获取给定时间戳的星期几(周日可能为 0)。\",\n \"Extracts the day of the month from a given timestamp.\": \"从给定时间戳中提取当月的日期。\",\n \"Gets the day of the year from a given timestamp.\": \"获取给定时间戳在一年中的第几天。\",\n \"Calculates the week of the year from a given timestamp.\": \"计算给定时间戳在一年中的第几周。\",\n \"Extracts the month from a given timestamp, typically with January as 1.\": \"从给定时间戳中提取月份(通常 1 月为 1)。\",\n \"Converts the month from a given timestamp into its string representation (e.g., 'Jan').\": \"将给定时间戳的月份转换为字符串表示(例如 'Jan')。\",\n \"Converts a timestamp to a human-readable date string.\": \"将时间戳转换为人类可读的日期字符串。\",\n \"Converts the day of the week from a given timestamp into its string representation (e.g., 'Mon').\": \"将给定时间戳的星期几转换为字符串表示(例如 'Mon')。\",\n \"Returns the timestamp representing the start of a specified unit (e.g., day, month, year) based on a given timestamp.\": \"返回给定时间戳在指定单位(如日、月、年)起始处的时间戳。\",\n \"Returns the timestamp representing the end of a specified unit (e.g., day, month, year) based on a given timestamp.\": \"返回给定时间戳在指定单位(如日、月、年)结束处的时间戳。\",\n\n // Higher-order array functions\n \"Checks if all elements in the array satisfy the condition defined in the callback.\": \"检查数组中所有元素是否都满足回调中定义的条件。\",\n \"Checks if no elements in the array satisfy the condition defined in the callback.\": \"检查数组中是否没有任何元素满足回调中定义的条件。\",\n \"Checks if at least one element in the array satisfies the condition defined in the callback.\": \"检查数组中是否至少有一个元素满足回调中定义的条件。\",\n \"Checks if exactly one element in the array satisfies the condition defined in the callback.\": \"检查数组中是否恰好有一个元素满足回调中定义的条件。\",\n \"Creates a new array with all elements that satisfy the condition defined in the callback.\": \"创建一个仅包含满足回调中定义条件的元素的新数组。\",\n \"Creates a new array populated with the results of calling the provided function on every element in the calling array.\": \"创建一个新数组,其元素为对原数组每个元素调用所提供函数的结果。\",\n \"First maps each element using a mapping function, then flattens the result into a new array.\": \"先用映射函数处理每个元素,再将结果扁平化为新数组。\",\n \"Counts the number of elements in the array that satisfy the condition defined in the callback.\": \"统计数组中满足回调中定义条件的元素个数。\",\n\n // Date methods\n \"Adds time to a date\": \"为日期增加时间\",\n \"Subtracts time from a date\": \"从日期中减去时间\",\n \"Sets a specific unit of time on a date\": \"设置日期的某个时间单位\",\n \"Formats a date into a string representation\": \"将日期格式化为字符串\",\n \"Returns the start of a specified time unit for a date\": \"返回日期在指定时间单位上的起始\",\n \"Returns the end of a specified time unit for a date\": \"返回日期在指定时间单位上的结束\",\n \"Calculates the difference between two dates\": \"计算两个日期之间的差值\",\n \"Converts a date to a different timezone\": \"将日期转换到不同的时区\",\n \"Checks if two dates are the same\": \"检查两个日期是否相同\",\n \"Checks if a date is before another date\": \"检查日期是否早于另一个日期\",\n \"Checks if a date is after another date\": \"检查日期是否晚于另一个日期\",\n \"Checks if a date is the same as or before another date\": \"检查日期是否等于或早于另一个日期\",\n \"Checks if a date is the same as or after another date\": \"检查日期是否等于或晚于另一个日期\",\n \"Gets the seconds of a date\": \"获取日期的秒\",\n \"Gets the minutes of a date\": \"获取日期的分钟\",\n \"Gets the hours of a date\": \"获取日期的小时\",\n \"Gets the day of the month for a date\": \"获取日期在当月的第几天\",\n \"Gets the day of the year for a date\": \"获取日期在当年的第几天\",\n \"Gets the week of the year for a date\": \"获取日期在当年的第几周\",\n \"Gets the day of the week for a date\": \"获取日期的星期几\",\n \"Gets the month for a date\": \"获取日期的月份\",\n \"Gets the quarter for a date\": \"获取日期所在的季度\",\n \"Gets the year for a date\": \"获取日期的年份\",\n \"Gets the Unix timestamp for a date\": \"获取日期的 Unix 时间戳\",\n \"Gets the timezone offset name for a date\": \"获取日期的时区偏移名称\",\n \"Checks if a date is valid\": \"检查日期是否有效\",\n \"Checks if a date is yesterday\": \"检查日期是否为昨天\",\n \"Checks if a date is today\": \"检查日期是否为今天\",\n \"Checks if a date is tomorrow\": \"检查日期是否为明天\",\n \"Checks if the year of a date is a leap year\": \"检查日期所在年份是否为闰年\"\n};\n\nconst EN_SOURCE_LABELS: Record<string, string> = {\n lexerError: \"Lexer error\",\n parserError: \"Parser error\",\n compilerError: \"Compiler error\",\n vmError: \"VM error\"\n};\n\nconst ZH_SOURCE_LABELS: Record<string, string> = {\n lexerError: \"词法错误\",\n parserError: \"语法错误\",\n compilerError: \"编译错误\",\n vmError: \"运行时错误\"\n};\n\nfunction sourceLabelFrom(table: Record<string, string>, fallback: string, type: string | undefined): string {\n return (type === undefined ? undefined : table[type]) ?? fallback;\n}\n\n/**\n * Built-in English message catalog (the default).\n */\nexport const enMessages: ExpressionMessages = {\n sourceLabel: type => sourceLabelFrom(EN_SOURCE_LABELS, \"Error\", type),\n completionInfo: info => info,\n typeCheckSource: \"Type check\",\n expectedBoolean: actualType => `Expected a boolean test expression, received \\`${actualType}\\`.`,\n expectedType: (expectedType, actualType) => `Expected \\`${expectedType}\\`, received \\`${actualType}\\`.`\n};\n\n/**\n * Built-in Simplified Chinese message catalog.\n */\nexport const zhCNMessages: ExpressionMessages = {\n sourceLabel: type => sourceLabelFrom(ZH_SOURCE_LABELS, \"错误\", type),\n completionInfo: info => info === \"\" ? \"\" : COMPLETION_INFO_ZH[info] ?? info,\n typeCheckSource: \"类型检查\",\n expectedBoolean: actualType => `期望布尔测试表达式,实际类型为 \\`${actualType}\\`。`,\n expectedType: (expectedType, actualType) => `期望 \\`${expectedType}\\`,实际为 \\`${actualType}\\`。`\n};\n\n// The locale registry. Built-ins are pre-registered; a host adds its own through\n// registerExpressionLocale, so a new language is a first-class, selectable locale\n// rather than a special case — the design stays open as more languages are added.\nconst localeRegistry = new Map<string, ExpressionMessages>([\n [\"en-US\", enMessages],\n [\"zh-CN\", zhCNMessages]\n]);\n\n// Module-global active catalog. The sync editor accessors (completion / lint) read\n// it without a React context, mirroring the engine singleton itself.\nlet activeMessages: ExpressionMessages = enMessages;\n\n/**\n * Register (or replace) the message catalog for a locale key, making it selectable\n * via {@link configureExpressionMessages}. This is how a host adds a language the\n * library does not ship — the built-in locales are registered the same way, so\n * there is no privileged path.\n */\nexport function registerExpressionLocale(locale: string, messages: ExpressionMessages): void {\n localeRegistry.set(locale, messages);\n}\n\nexport interface ConfigureMessagesOptions {\n /**\n * A registered locale to use as the base — built-in or registered through\n * {@link registerExpressionLocale}. An unknown key keeps the current base; omit\n * to keep the current base.\n */\n locale?: ExpressionLocale;\n /**\n * Per-message overrides merged over the base — a quick way to tweak a few strings\n * without registering a whole locale.\n */\n messages?: Partial<ExpressionMessages>;\n}\n\n/**\n * Configure the active message catalog. Pass a `locale`, a partial `messages`\n * override, or both (overrides win). Idempotent and module-global, so a host\n * configures it once (e.g. through `ExpressionConfigProvider`).\n */\nexport function configureExpressionMessages({ locale, messages }: ConfigureMessagesOptions): void {\n const base = locale === undefined ? activeMessages : localeRegistry.get(locale) ?? activeMessages;\n activeMessages = messages === undefined ? base : { ...base, ...messages };\n}\n\n/**\n * The active {@link ExpressionMessages} catalog (English by default).\n */\nexport function getExpressionMessages(): ExpressionMessages {\n return activeMessages;\n}\n","import { isRecord } from \"../internal/predicates\";\nimport { getEngineSync, loadEngine } from \"./loader\";\nimport { getExpressionMessages } from \"./messages\";\n\n/**\n * Whether an expression is a standard value expression or a unary (test) expression.\n */\nexport type ExpressionMode = \"standard\" | \"unary\";\n\n/**\n * A ZEN type descriptor — the shape the engine understands for type-aware\n * completion and validation: a primitive kind name or one of the structural\n * variants `{ Const }`, `{ Enum }`, `{ Array }`, `{ Object }`.\n *\n * Defined here rather than aliasing the wasm `VariableTypeJson` because the\n * engine also emits and accepts `\"Date\"` — its sole method-receiver kind — which\n * that type omits. Aliasing it would make a Date-typed variable unrepresentable\n * and break `kind === \"Date\"` narrowing; the structural variants mirror the wasm\n * shape exactly so a value crosses the boundary unchanged.\n */\nexport type ExpressionType\n = | \"Any\"\n | \"Null\"\n | \"Bool\"\n | \"String\"\n | \"Number\"\n | \"Date\"\n | { Const: string }\n | { Enum: [string | undefined, string[]] }\n | { Array: ExpressionType }\n | { Object: Record<string, ExpressionType> };\n\n/**\n * A single syntax / type diagnostic, positioned by character offset.\n */\nexport interface ExpressionDiagnostic {\n /**\n * Start offset in the source.\n */\n from: number;\n /**\n * End offset in the source.\n */\n to: number;\n /**\n * Human-readable error message.\n */\n message: string;\n /**\n * Diagnostic origin label (e.g. `\"Parser error\"`).\n */\n source: string;\n}\n\n/**\n * An autocomplete suggestion for a ZEN built-in (function / method / variable).\n */\nexport interface ExpressionCompletion {\n type: \"function\" | \"method\" | \"variable\";\n label: string;\n detail: string;\n info: string;\n boost: number | null;\n /**\n * For methods, the type-kind they attach to (e.g. `\"Date\"`); otherwise `null`.\n */\n methodFor: string | null;\n}\n\n/**\n * The inferred type of one span of the source, produced by type-checking.\n */\nexport interface ExpressionTypeSpan {\n error: string | null;\n kind: ExpressionType;\n nodeKind: string;\n span: [number, number];\n}\n\n/**\n * The result of type-checking an expression against a variable context.\n */\nexport interface ExpressionAnalysis {\n /**\n * The root context type (the variables object).\n */\n rootKind: ExpressionType;\n /**\n * Per-span inferred types; `spans[0]` is the whole-expression result type.\n */\n spans: ExpressionTypeSpan[];\n}\n\n// Strict offset parsing: Number() rejects partial-numeric text (\"12:30\") that\n// parseInt would silently truncate to 12, and the empty-string guard covers\n// Number(\"\") being 0 rather than NaN.\nfunction parseOffset(text: string | undefined): number {\n const trimmed = text?.trim();\n return trimmed ? Number(trimmed) : NaN;\n}\n\n/**\n * Parse a trailing `... at (from, to)` / `... at pos` position out of a ZEN error\n * message. Returns a `[from, to]` range — a single offset collapses to\n * `[pos, pos]` — or `null` when no position is present.\n */\nexport function extractPosition(message: string): [number, number] | null {\n const segments = message.split(\" at \");\n const last = segments.length <= 1 ? undefined : segments.at(-1);\n\n if (last === undefined) {\n return null;\n }\n\n const [left, right] = last.replace(\"(\", \"\").replace(\")\", \"\").split(\", \");\n const from = parseOffset(left);\n\n if (Number.isNaN(from)) {\n return null;\n }\n\n const to = parseOffset(right);\n return [from, Number.isNaN(to) ? from : to];\n}\n\n/**\n * Normalize the wasm validate payload (`null` or `{ type, source }`) into a\n * positioned {@link ExpressionDiagnostic}, or `null` when the expression is valid.\n */\nexport function normalizeDiagnostic(raw: unknown, source: string): ExpressionDiagnostic | null {\n if (raw === null || raw === undefined) {\n return null;\n }\n\n const errorType = isRecord(raw) && typeof raw.type === \"string\" ? raw.type : undefined;\n const message = isRecord(raw) && typeof raw.source === \"string\" ? raw.source : String(raw);\n const [from, to] = extractPosition(message) ?? [0, source.length];\n\n return {\n from,\n to,\n message,\n source: getExpressionMessages().sourceLabel(errorType)\n };\n}\n\n/**\n * Normalize the wasm `getCompletions` payload into a typed list, dropping\n * malformed entries and stripping the backtick markers ZEN wraps type names in.\n */\nexport function normalizeCompletions(raw: unknown): ExpressionCompletion[] {\n if (!Array.isArray(raw)) {\n return [];\n }\n\n const messages = getExpressionMessages();\n\n return raw.flatMap((entry): ExpressionCompletion[] => {\n if (!isRecord(entry) || typeof entry.label !== \"string\" || entry.label === \"\") {\n return [];\n }\n\n return [\n {\n type: entry.type === \"method\" || entry.type === \"variable\" ? entry.type : \"function\",\n label: entry.label,\n detail: typeof entry.detail === \"string\" ? entry.detail.replaceAll(\"`\", \"\") : \"\",\n info: messages.completionInfo(typeof entry.info === \"string\" ? entry.info : \"\"),\n boost: typeof entry.boost === \"number\" ? entry.boost : null,\n methodFor: typeof entry.methodFor === \"string\" ? entry.methodFor : null\n }\n ];\n });\n}\n\n/**\n * Validate an expression, loading the engine on first use. Resolves to `null`\n * when the expression is valid, or a positioned diagnostic otherwise.\n */\nexport async function getDiagnostics(expression: string, mode: ExpressionMode): Promise<ExpressionDiagnostic | null> {\n await loadEngine();\n return getDiagnosticsSync(expression, mode);\n}\n\n/**\n * Synchronous {@link getDiagnostics}. Throws `ExpressionNotReadyError` if the\n * engine has not loaded yet — use only behind a readiness gate.\n */\nexport function getDiagnosticsSync(expression: string, mode: ExpressionMode): ExpressionDiagnostic | null {\n const engine = getEngineSync();\n return normalizeDiagnostic(mode === \"unary\" ? engine.validateUnary(expression) : engine.validate(expression), expression);\n}\n\n/**\n * Return the ZEN built-in completion list, loading the engine on first use.\n */\nexport async function getCompletionItems(): Promise<ExpressionCompletion[]> {\n await loadEngine();\n return getCompletionItemsSync();\n}\n\n/**\n * Synchronous {@link getCompletionItems}. Throws `ExpressionNotReadyError` if the\n * engine has not loaded yet.\n */\nexport function getCompletionItemsSync(): ExpressionCompletion[] {\n return normalizeCompletions(getEngineSync().getCompletions());\n}\n\n/**\n * Type-check an expression against a `variables` context, loading the engine on\n * first use. See {@link ExpressionAnalysis}.\n */\nexport async function analyzeTypes(\n variables: ExpressionType,\n source: string,\n mode: ExpressionMode\n): Promise<ExpressionAnalysis> {\n await loadEngine();\n return analyzeTypesSync(variables, source, mode);\n}\n\n/**\n * Synchronous {@link analyzeTypes}. Throws `ExpressionNotReadyError` if the\n * engine has not loaded yet.\n */\nexport function analyzeTypesSync(variables: ExpressionType, source: string, mode: ExpressionMode): ExpressionAnalysis {\n return getEngineSync().analyze(variables, source, mode === \"unary\");\n}\n\n/**\n * Whether `actual` satisfies (is assignable to) `expected`, loading the engine on\n * first use. Used for expected-return-type validation.\n */\nexport async function satisfiesType(actual: ExpressionType, expected: ExpressionType): Promise<boolean> {\n await loadEngine();\n return satisfiesTypeSync(actual, expected);\n}\n\n/**\n * Synchronous {@link satisfiesType}. Throws `ExpressionNotReadyError` if the\n * engine has not loaded yet.\n */\nexport function satisfiesTypeSync(actual: ExpressionType, expected: Expression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QAAQ,QAAQ;AAC3C;;;;;AAMA,SAAgB,kBAAkB,QAAwB,UAAmC;CAC3F,OAAO,cAAc,CAAC,CAAC,UAAU,QAAQ,QAAQ;AACnD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@coldsmirk/abacus-core",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Framework-agnostic ZEN expression engine: compile, evaluate, and type-analyze expressions over the GoRules ZEN WASM engine.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"zen",
|
|
7
|
+
"expression",
|
|
8
|
+
"gorules",
|
|
9
|
+
"wasm",
|
|
10
|
+
"rules",
|
|
11
|
+
"expression-engine"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/coldsmirk/abacus/tree/main/packages/core#readme",
|
|
14
|
+
"bugs": "https://github.com/coldsmirk/abacus/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/coldsmirk/abacus.git",
|
|
18
|
+
"directory": "packages/core"
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"author": {
|
|
22
|
+
"name": "Venus"
|
|
23
|
+
},
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
34
|
+
"default": "./dist/index.cjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"main": "./dist/index.cjs",
|
|
40
|
+
"module": "./dist/index.js",
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@gorules/zen-engine-wasm": "^0.23.1"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=22"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsdown",
|
|
56
|
+
"clean": "rimraf dist",
|
|
57
|
+
"typecheck": "tsc --noEmit"
|
|
58
|
+
}
|
|
59
|
+
}
|