@almadar/evaluator 2.12.0 → 2.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-BNm52R6a.d.ts → index-DbN8OE5Y.d.ts} +10 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/operators/index.d.ts +1 -1
- package/dist/operators/index.js +4 -1
- package/dist/operators/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -325,6 +325,15 @@ declare function evalIncludes(args: SExpr[], evaluate: Evaluator$1, ctx: Evaluat
|
|
|
325
325
|
* Evaluate empty: ["empty", collection]
|
|
326
326
|
*/
|
|
327
327
|
declare function evalEmpty(args: SExpr[], evaluate: Evaluator$1, ctx: EvaluationContext): boolean;
|
|
328
|
+
/**
|
|
329
|
+
* `(list a b c …)` — literal array constructor. Evaluates each argument and
|
|
330
|
+
* returns them as a plain array. Lowering wraps a literal list bound for a
|
|
331
|
+
* literal-array slot in `list` so it is unambiguously data, never a call — the
|
|
332
|
+
* deterministic disambiguation for a list whose first element collides with an
|
|
333
|
+
* operator name (e.g. `[path method …]` would otherwise be read as the `path`
|
|
334
|
+
* operator call and collapse to a string).
|
|
335
|
+
*/
|
|
336
|
+
declare function evalList(args: SExpr[], evaluate: Evaluator$1, ctx: EvaluationContext): unknown[];
|
|
328
337
|
|
|
329
338
|
/**
|
|
330
339
|
* Effect Operator Implementations
|
|
@@ -421,4 +430,4 @@ declare function evalWatch(args: SExpr[], evaluate: Evaluator, ctx: EvaluationCo
|
|
|
421
430
|
*/
|
|
422
431
|
declare function evalAtomic(args: SExpr[], evaluate: Evaluator, ctx: EvaluationContext): unknown;
|
|
423
432
|
|
|
424
|
-
export {
|
|
433
|
+
export { evalSet as $, evalGreaterThanOrEqual as A, evalIf as B, evalIncludes as C, evalIncrement as D, type EvaluationContext as E, evalLast as F, evalLessThan as G, evalLessThanOrEqual as H, evalLet as I, evalList as J, evalMap as K, evalMatches as L, evalMax as M, evalMin as N, evalModulo as O, evalMultiply as P, evalNavigate as Q, evalNot as R, evalNotEqual as S, evalNotify as T, type UserContext as U, evalNth as V, evalOr as W, evalPersist as X, evalRef as Y, evalRenderUI as Z, evalRound as _, createEffectContext as a, evalSetDynamic as a0, evalSpawn as a1, evalSubtract as a2, evalSum as a3, evalSwap as a4, evalWatch as a5, evalWhen as a6, resolveBinding as a7, createMinimalContext as b, createChildContext as c, evalAdd as d, evalAbs as e, evalAnd as f, evalAtomic as g, evalCallService as h, evalCeil as i, evalClamp as j, evalConcat as k, evalCount as l, evalDecrement as m, evalDeref as n, evalDespawn as o, evalDivide as p, evalDo as q, evalEmit as r, evalEmpty as s, evalEqual as t, evalFilter as u, evalFind as v, evalFirst as w, evalFloor as x, evalFn as y, evalGreaterThan as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SExpr } from '@almadar/core';
|
|
2
2
|
export { CORE_BINDINGS, CoreBinding, Expression, ExpressionSchema, ParsedBinding, SExpr, SExprAtom, SExprSchema, collectBindings, getArgs, getOperator, isBinding, isSExpr, isSExprAtom, isSExprCall, isValidBinding, parseBinding, sexpr, walkSExpr } from '@almadar/core';
|
|
3
|
-
import { E as EvaluationContext } from './index-
|
|
4
|
-
export { U as UserContext, c as createChildContext, a as createEffectContext, b as createMinimalContext, e as evalAbs, d as evalAdd, f as evalAnd, g as evalAtomic, h as evalCallService, i as evalCeil, j as evalClamp, k as evalConcat, l as evalCount, m as evalDecrement, n as evalDeref, o as evalDespawn, p as evalDivide, q as evalDo, r as evalEmit, s as evalEmpty, t as evalEqual, u as evalFilter, v as evalFind, w as evalFirst, x as evalFloor, y as evalFn, z as evalGreaterThan, A as evalGreaterThanOrEqual, B as evalIf, C as evalIncludes, D as evalIncrement, F as evalLast, G as evalLessThan, H as evalLessThanOrEqual, I as evalLet, J as
|
|
3
|
+
import { E as EvaluationContext } from './index-DbN8OE5Y.js';
|
|
4
|
+
export { U as UserContext, c as createChildContext, a as createEffectContext, b as createMinimalContext, e as evalAbs, d as evalAdd, f as evalAnd, g as evalAtomic, h as evalCallService, i as evalCeil, j as evalClamp, k as evalConcat, l as evalCount, m as evalDecrement, n as evalDeref, o as evalDespawn, p as evalDivide, q as evalDo, r as evalEmit, s as evalEmpty, t as evalEqual, u as evalFilter, v as evalFind, w as evalFirst, x as evalFloor, y as evalFn, z as evalGreaterThan, A as evalGreaterThanOrEqual, B as evalIf, C as evalIncludes, D as evalIncrement, F as evalLast, G as evalLessThan, H as evalLessThanOrEqual, I as evalLet, J as evalList, K as evalMap, L as evalMatches, M as evalMax, N as evalMin, O as evalModulo, P as evalMultiply, Q as evalNavigate, R as evalNot, S as evalNotEqual, T as evalNotify, V as evalNth, W as evalOr, X as evalPersist, Y as evalRef, Z as evalRenderUI, _ as evalRound, $ as evalSet, a0 as evalSetDynamic, a1 as evalSpawn, a2 as evalSubtract, a3 as evalSum, a4 as evalSwap, a5 as evalWatch, a6 as evalWhen, a7 as resolveBinding } from './index-DbN8OE5Y.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* S-Expression Evaluator
|
package/dist/index.js
CHANGED
|
@@ -380,6 +380,9 @@ function evalEmpty(args, evaluate2, ctx) {
|
|
|
380
380
|
const collection = toArray(evaluate2(args[0], ctx));
|
|
381
381
|
return collection.length === 0;
|
|
382
382
|
}
|
|
383
|
+
function evalList(args, evaluate2, ctx) {
|
|
384
|
+
return args.map((arg) => evaluate2(arg, ctx));
|
|
385
|
+
}
|
|
383
386
|
function toArray(value) {
|
|
384
387
|
if (Array.isArray(value)) return value;
|
|
385
388
|
if (value === null || value === void 0) return [];
|
|
@@ -1210,6 +1213,7 @@ function evalArrayDropLast(args, evaluate2, ctx) {
|
|
|
1210
1213
|
}
|
|
1211
1214
|
|
|
1212
1215
|
// std/object.ts
|
|
1216
|
+
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1213
1217
|
function evalLambda(lambdaExpr, evaluate2, ctx, ...values) {
|
|
1214
1218
|
if (!isSExpr(lambdaExpr) || getOperator(lambdaExpr) !== "fn") {
|
|
1215
1219
|
return evaluate2(lambdaExpr, ctx);
|
|
@@ -1272,6 +1276,9 @@ function evalObjectSet(args, evaluate2, ctx) {
|
|
|
1272
1276
|
if (!path) return obj ?? {};
|
|
1273
1277
|
const result = structuredClone(obj ?? {});
|
|
1274
1278
|
const parts = path.split(".");
|
|
1279
|
+
if (parts.some((p) => FORBIDDEN_KEYS.has(p))) {
|
|
1280
|
+
return result;
|
|
1281
|
+
}
|
|
1275
1282
|
let current = result;
|
|
1276
1283
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
1277
1284
|
const part = parts[i];
|
|
@@ -1309,6 +1316,7 @@ function evalObjectDeepMerge(args, evaluate2, ctx) {
|
|
|
1309
1316
|
function deepMerge(target, source) {
|
|
1310
1317
|
const result = { ...target };
|
|
1311
1318
|
for (const key of Object.keys(source)) {
|
|
1319
|
+
if (FORBIDDEN_KEYS.has(key)) continue;
|
|
1312
1320
|
if (source[key] !== null && typeof source[key] === "object" && !Array.isArray(source[key]) && target[key] !== null && typeof target[key] === "object" && !Array.isArray(target[key])) {
|
|
1313
1321
|
result[key] = deepMerge(
|
|
1314
1322
|
target[key],
|
|
@@ -2747,6 +2755,8 @@ var SExpressionEvaluator = class {
|
|
|
2747
2755
|
return evalIncludes(args, evaluate2, ctx);
|
|
2748
2756
|
case "empty":
|
|
2749
2757
|
return evalEmpty(args, evaluate2, ctx);
|
|
2758
|
+
case "list":
|
|
2759
|
+
return evalList(args, evaluate2, ctx);
|
|
2750
2760
|
// Effects
|
|
2751
2761
|
case "set":
|
|
2752
2762
|
evalSet(args, evaluate2, ctx);
|
|
@@ -3301,6 +3311,6 @@ function executeEffects(effects, ctx) {
|
|
|
3301
3311
|
evaluator.executeEffects(effects, ctx);
|
|
3302
3312
|
}
|
|
3303
3313
|
|
|
3304
|
-
export { SExpressionEvaluator, createChildContext, createEffectContext, createMinimalContext, evalAbs, evalAdd, evalAnd, evalAtomic, evalCallService, evalCeil, evalClamp, evalConcat, evalCount, evalDecrement, evalDeref, evalDespawn, evalDivide, evalDo, evalEmit, evalEmpty, evalEqual, evalFilter, evalFind, evalFirst, evalFloor, evalFn, evalGreaterThan, evalGreaterThanOrEqual, evalIf, evalIncludes, evalIncrement, evalLast, evalLessThan, evalLessThanOrEqual, evalLet, evalMap, evalMatches, evalMax, evalMin, evalModulo, evalMultiply, evalNavigate, evalNot, evalNotEqual, evalNotify, evalNth, evalOr, evalPersist, evalRef, evalRenderUI, evalRound, evalSet, evalSetDynamic, evalSpawn, evalSubtract, evalSum, evalSwap, evalWatch, evalWhen, evaluate, evaluateGuard, evaluator, executeEffect, executeEffects, resolveBinding };
|
|
3314
|
+
export { SExpressionEvaluator, createChildContext, createEffectContext, createMinimalContext, evalAbs, evalAdd, evalAnd, evalAtomic, evalCallService, evalCeil, evalClamp, evalConcat, evalCount, evalDecrement, evalDeref, evalDespawn, evalDivide, evalDo, evalEmit, evalEmpty, evalEqual, evalFilter, evalFind, evalFirst, evalFloor, evalFn, evalGreaterThan, evalGreaterThanOrEqual, evalIf, evalIncludes, evalIncrement, evalLast, evalLessThan, evalLessThanOrEqual, evalLet, evalList, evalMap, evalMatches, evalMax, evalMin, evalModulo, evalMultiply, evalNavigate, evalNot, evalNotEqual, evalNotify, evalNth, evalOr, evalPersist, evalRef, evalRenderUI, evalRound, evalSet, evalSetDynamic, evalSpawn, evalSubtract, evalSum, evalSwap, evalWatch, evalWhen, evaluate, evaluateGuard, evaluator, executeEffect, executeEffects, resolveBinding };
|
|
3305
3315
|
//# sourceMappingURL=index.js.map
|
|
3306
3316
|
//# sourceMappingURL=index.js.map
|