@almadar/evaluator 2.12.1 → 2.13.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.
@@ -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 { evalSetDynamic 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, evalMap as J, evalMatches as K, evalMax as L, evalMin as M, evalModulo as N, evalMultiply as O, evalNavigate as P, evalNot as Q, evalNotEqual as R, evalNotify as S, evalNth as T, type UserContext as U, evalOr as V, evalPersist as W, evalRef as X, evalRenderUI as Y, evalRound as Z, evalSet as _, createEffectContext as a, evalSpawn as a0, evalSubtract as a1, evalSum as a2, evalSwap as a3, evalWatch as a4, evalWhen as a5, resolveBinding as a6, 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 };
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-BNm52R6a.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 evalMap, K as evalMatches, L as evalMax, M as evalMin, N as evalModulo, O as evalMultiply, P as evalNavigate, Q as evalNot, R as evalNotEqual, S as evalNotify, T as evalNth, V as evalOr, W as evalPersist, X as evalRef, Y as evalRenderUI, Z as evalRound, _ as evalSet, $ as evalSetDynamic, a0 as evalSpawn, a1 as evalSubtract, a2 as evalSum, a3 as evalSwap, a4 as evalWatch, a5 as evalWhen, a6 as resolveBinding } from './index-BNm52R6a.js';
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 [];
@@ -730,6 +733,50 @@ function evalMathDefault(args, evaluate2, ctx) {
730
733
  }
731
734
  return n;
732
735
  }
736
+ function evalMathSin(args, evaluate2, ctx) {
737
+ return Math.sin(evaluate2(args[0], ctx));
738
+ }
739
+ function evalMathCos(args, evaluate2, ctx) {
740
+ return Math.cos(evaluate2(args[0], ctx));
741
+ }
742
+ function evalMathTan(args, evaluate2, ctx) {
743
+ return Math.tan(evaluate2(args[0], ctx));
744
+ }
745
+ function evalMathAtan2(args, evaluate2, ctx) {
746
+ const y = evaluate2(args[0], ctx);
747
+ const x = evaluate2(args[1], ctx);
748
+ return Math.atan2(y, x);
749
+ }
750
+ function evalMathHypot(args, evaluate2, ctx) {
751
+ const a = evaluate2(args[0], ctx);
752
+ const b = evaluate2(args[1], ctx);
753
+ return Math.hypot(a, b);
754
+ }
755
+ function evalMathDegRad(args, evaluate2, ctx) {
756
+ return evaluate2(args[0], ctx) * (Math.PI / 180);
757
+ }
758
+ function evalMathRadDeg(args, evaluate2, ctx) {
759
+ return evaluate2(args[0], ctx) * (180 / Math.PI);
760
+ }
761
+ function evalMathWrap(args, evaluate2, ctx) {
762
+ const v = evaluate2(args[0], ctx);
763
+ const min = evaluate2(args[1], ctx);
764
+ const max = evaluate2(args[2], ctx);
765
+ const r = max - min;
766
+ if (r <= 0) {
767
+ return min;
768
+ }
769
+ return min + ((v - min) % r + r) % r;
770
+ }
771
+ function evalMathApproach(args, evaluate2, ctx) {
772
+ const cur = evaluate2(args[0], ctx);
773
+ const target = evaluate2(args[1], ctx);
774
+ const maxD = evaluate2(args[2], ctx);
775
+ if (Math.abs(target - cur) <= maxD) {
776
+ return target;
777
+ }
778
+ return cur + Math.sign(target - cur) * maxD;
779
+ }
733
780
 
734
781
  // std/str.ts
735
782
  function evalStrLen(args, evaluate2, ctx) {
@@ -2572,6 +2619,454 @@ function evalAgentSearchCode(args, evaluate2, ctx) {
2572
2619
  return ctx.agent.searchCode(query, language);
2573
2620
  }
2574
2621
 
2622
+ // std/vector.ts
2623
+ function asVec(v) {
2624
+ const o = v ?? {};
2625
+ const x = typeof o.x === "number" ? o.x : 0;
2626
+ const y = typeof o.y === "number" ? o.y : 0;
2627
+ const z2 = typeof o.z === "number" ? o.z : void 0;
2628
+ return z2 === void 0 ? { x, y } : { x, y, z: z2 };
2629
+ }
2630
+ function has3(v) {
2631
+ return v.z !== void 0;
2632
+ }
2633
+ function z(v) {
2634
+ return v.z ?? 0;
2635
+ }
2636
+ function make(x, y, zVal, is3d) {
2637
+ return is3d ? { x, y, z: zVal } : { x, y };
2638
+ }
2639
+ function evalVecAdd(args, evaluate2, ctx) {
2640
+ const a = asVec(evaluate2(args[0], ctx));
2641
+ const b = asVec(evaluate2(args[1], ctx));
2642
+ return make(a.x + b.x, a.y + b.y, z(a) + z(b), has3(a));
2643
+ }
2644
+ function evalVecSub(args, evaluate2, ctx) {
2645
+ const a = asVec(evaluate2(args[0], ctx));
2646
+ const b = asVec(evaluate2(args[1], ctx));
2647
+ return make(a.x - b.x, a.y - b.y, z(a) - z(b), has3(a));
2648
+ }
2649
+ function evalVecScale(args, evaluate2, ctx) {
2650
+ const a = asVec(evaluate2(args[0], ctx));
2651
+ const k = evaluate2(args[1], ctx);
2652
+ return make(a.x * k, a.y * k, z(a) * k, has3(a));
2653
+ }
2654
+ function evalVecDot(args, evaluate2, ctx) {
2655
+ const a = asVec(evaluate2(args[0], ctx));
2656
+ const b = asVec(evaluate2(args[1], ctx));
2657
+ return a.x * b.x + a.y * b.y + z(a) * z(b);
2658
+ }
2659
+ function evalVecCross(args, evaluate2, ctx) {
2660
+ const a = asVec(evaluate2(args[0], ctx));
2661
+ const b = asVec(evaluate2(args[1], ctx));
2662
+ if (has3(a)) {
2663
+ const ax = a.x, ay = a.y, az = z(a);
2664
+ const bx = b.x, by = b.y, bz = z(b);
2665
+ return { x: ay * bz - az * by, y: az * bx - ax * bz, z: ax * by - ay * bx };
2666
+ }
2667
+ return a.x * b.y - a.y * b.x;
2668
+ }
2669
+ function evalVecLength(args, evaluate2, ctx) {
2670
+ const a = asVec(evaluate2(args[0], ctx));
2671
+ return Math.sqrt(a.x * a.x + a.y * a.y + z(a) * z(a));
2672
+ }
2673
+ function evalVecLengthSq(args, evaluate2, ctx) {
2674
+ const a = asVec(evaluate2(args[0], ctx));
2675
+ return a.x * a.x + a.y * a.y + z(a) * z(a);
2676
+ }
2677
+ function evalVecNormalize(args, evaluate2, ctx) {
2678
+ const a = asVec(evaluate2(args[0], ctx));
2679
+ const len = Math.sqrt(a.x * a.x + a.y * a.y + z(a) * z(a));
2680
+ if (len === 0) {
2681
+ return make(0, 0, 0, has3(a));
2682
+ }
2683
+ return make(a.x / len, a.y / len, z(a) / len, has3(a));
2684
+ }
2685
+ function evalVecDistance(args, evaluate2, ctx) {
2686
+ const a = asVec(evaluate2(args[0], ctx));
2687
+ const b = asVec(evaluate2(args[1], ctx));
2688
+ const dx = a.x - b.x, dy = a.y - b.y, dz = z(a) - z(b);
2689
+ return Math.sqrt(dx * dx + dy * dy + dz * dz);
2690
+ }
2691
+ function evalVecDistanceSq(args, evaluate2, ctx) {
2692
+ const a = asVec(evaluate2(args[0], ctx));
2693
+ const b = asVec(evaluate2(args[1], ctx));
2694
+ const dx = a.x - b.x, dy = a.y - b.y, dz = z(a) - z(b);
2695
+ return dx * dx + dy * dy + dz * dz;
2696
+ }
2697
+ function evalVecLerp(args, evaluate2, ctx) {
2698
+ const a = asVec(evaluate2(args[0], ctx));
2699
+ const b = asVec(evaluate2(args[1], ctx));
2700
+ const t = evaluate2(args[2], ctx);
2701
+ return make(
2702
+ a.x + (b.x - a.x) * t,
2703
+ a.y + (b.y - a.y) * t,
2704
+ z(a) + (z(b) - z(a)) * t,
2705
+ has3(a)
2706
+ );
2707
+ }
2708
+ function evalVecAngle(args, evaluate2, ctx) {
2709
+ const a = asVec(evaluate2(args[0], ctx));
2710
+ if (args.length < 2) {
2711
+ return Math.atan2(a.y, a.x);
2712
+ }
2713
+ const b = asVec(evaluate2(args[1], ctx));
2714
+ const la = Math.sqrt(a.x * a.x + a.y * a.y + z(a) * z(a));
2715
+ const lb = Math.sqrt(b.x * b.x + b.y * b.y + z(b) * z(b));
2716
+ if (la === 0 || lb === 0) {
2717
+ return 0;
2718
+ }
2719
+ const d = (a.x * b.x + a.y * b.y + z(a) * z(b)) / (la * lb);
2720
+ const clamped = Math.min(Math.max(d, -1), 1);
2721
+ return Math.acos(clamped);
2722
+ }
2723
+ function evalVecRotate(args, evaluate2, ctx) {
2724
+ const a = asVec(evaluate2(args[0], ctx));
2725
+ const rad = evaluate2(args[1], ctx);
2726
+ const c = Math.cos(rad), s = Math.sin(rad);
2727
+ return make(a.x * c - a.y * s, a.x * s + a.y * c, z(a), has3(a));
2728
+ }
2729
+ function evalVecClampLength(args, evaluate2, ctx) {
2730
+ const a = asVec(evaluate2(args[0], ctx));
2731
+ const max = evaluate2(args[1], ctx);
2732
+ const len = Math.sqrt(a.x * a.x + a.y * a.y + z(a) * z(a));
2733
+ if (len > max) {
2734
+ if (len === 0) {
2735
+ return make(0, 0, 0, has3(a));
2736
+ }
2737
+ const k = max / len;
2738
+ return make(a.x * k, a.y * k, z(a) * k, has3(a));
2739
+ }
2740
+ return make(a.x, a.y, z(a), has3(a));
2741
+ }
2742
+
2743
+ // std/geo.ts
2744
+ function num(o, k) {
2745
+ return typeof o[k] === "number" ? o[k] : 0;
2746
+ }
2747
+ function asVec2(v) {
2748
+ const o = v ?? {};
2749
+ const z2 = typeof o.z === "number" ? o.z : void 0;
2750
+ return z2 === void 0 ? { x: num(o, "x"), y: num(o, "y") } : { x: num(o, "x"), y: num(o, "y"), z: z2 };
2751
+ }
2752
+ function asRect(v) {
2753
+ const o = v ?? {};
2754
+ return { x: num(o, "x"), y: num(o, "y"), w: num(o, "w"), h: num(o, "h") };
2755
+ }
2756
+ function asCircle(v) {
2757
+ const o = v ?? {};
2758
+ return { x: num(o, "x"), y: num(o, "y"), r: num(o, "r") };
2759
+ }
2760
+ function asSegment(v) {
2761
+ const o = v ?? {};
2762
+ return { x1: num(o, "x1"), y1: num(o, "y1"), x2: num(o, "x2"), y2: num(o, "y2") };
2763
+ }
2764
+ function clamp(n, lo, hi) {
2765
+ return Math.min(Math.max(n, lo), hi);
2766
+ }
2767
+ function evalGeoAabbOverlap(args, evaluate2, ctx) {
2768
+ const a = asRect(evaluate2(args[0], ctx));
2769
+ const b = asRect(evaluate2(args[1], ctx));
2770
+ return a.x < b.x + b.w && a.x + a.w > b.x && a.y < b.y + b.h && a.y + a.h > b.y;
2771
+ }
2772
+ function evalGeoCircleOverlap(args, evaluate2, ctx) {
2773
+ const a = asCircle(evaluate2(args[0], ctx));
2774
+ const b = asCircle(evaluate2(args[1], ctx));
2775
+ const dx = a.x - b.x, dy = a.y - b.y;
2776
+ return Math.sqrt(dx * dx + dy * dy) <= a.r + b.r;
2777
+ }
2778
+ function evalGeoRectCircleOverlap(args, evaluate2, ctx) {
2779
+ const r = asRect(evaluate2(args[0], ctx));
2780
+ const c = asCircle(evaluate2(args[1], ctx));
2781
+ const cx = clamp(c.x, r.x, r.x + r.w);
2782
+ const cy = clamp(c.y, r.y, r.y + r.h);
2783
+ const dx = c.x - cx, dy = c.y - cy;
2784
+ return dx * dx + dy * dy <= c.r * c.r;
2785
+ }
2786
+ function evalGeoPointInRect(args, evaluate2, ctx) {
2787
+ const p = asVec2(evaluate2(args[0], ctx));
2788
+ const r = asRect(evaluate2(args[1], ctx));
2789
+ return p.x >= r.x && p.x <= r.x + r.w && p.y >= r.y && p.y <= r.y + r.h;
2790
+ }
2791
+ function evalGeoPointInCircle(args, evaluate2, ctx) {
2792
+ const p = asVec2(evaluate2(args[0], ctx));
2793
+ const c = asCircle(evaluate2(args[1], ctx));
2794
+ const dx = p.x - c.x, dy = p.y - c.y;
2795
+ return dx * dx + dy * dy <= c.r * c.r;
2796
+ }
2797
+ function evalGeoReflect(args, evaluate2, ctx) {
2798
+ const v = asVec2(evaluate2(args[0], ctx));
2799
+ const n = asVec2(evaluate2(args[1], ctx));
2800
+ const is3d = v.z !== void 0;
2801
+ const vz = v.z ?? 0, nz = n.z ?? 0;
2802
+ const d = v.x * n.x + v.y * n.y + vz * nz;
2803
+ const rx = v.x - n.x * 2 * d;
2804
+ const ry = v.y - n.y * 2 * d;
2805
+ const rz = vz - nz * 2 * d;
2806
+ return is3d ? { x: rx, y: ry, z: rz } : { x: rx, y: ry };
2807
+ }
2808
+ function evalGeoSegmentIntersect(args, evaluate2, ctx) {
2809
+ const s1 = asSegment(evaluate2(args[0], ctx));
2810
+ const s2 = asSegment(evaluate2(args[1], ctx));
2811
+ const r_x = s1.x2 - s1.x1, r_y = s1.y2 - s1.y1;
2812
+ const s_x = s2.x2 - s2.x1, s_y = s2.y2 - s2.y1;
2813
+ const denom = r_x * s_y - r_y * s_x;
2814
+ if (denom === 0) {
2815
+ return null;
2816
+ }
2817
+ const qpx = s2.x1 - s1.x1, qpy = s2.y1 - s1.y1;
2818
+ const t = (qpx * s_y - qpy * s_x) / denom;
2819
+ const u = (qpx * r_y - qpy * r_x) / denom;
2820
+ if (t < 0 || t > 1 || u < 0 || u > 1) {
2821
+ return null;
2822
+ }
2823
+ return { x: s1.x1 + t * r_x, y: s1.y1 + t * r_y };
2824
+ }
2825
+
2826
+ // std/grid.ts
2827
+ function num2(o, k) {
2828
+ return typeof o[k] === "number" ? o[k] : 0;
2829
+ }
2830
+ function asCell(v) {
2831
+ const o = v ?? {};
2832
+ return { x: num2(o, "x"), y: num2(o, "y") };
2833
+ }
2834
+ function evalGridToWorld(args, evaluate2, ctx) {
2835
+ const cell = asCell(evaluate2(args[0], ctx));
2836
+ const cellSize = evaluate2(args[1], ctx);
2837
+ return { x: (cell.x + 0.5) * cellSize, y: (cell.y + 0.5) * cellSize };
2838
+ }
2839
+ function evalGridFromWorld(args, evaluate2, ctx) {
2840
+ const point = asCell(evaluate2(args[0], ctx));
2841
+ const cellSize = evaluate2(args[1], ctx);
2842
+ return { x: Math.floor(point.x / cellSize), y: Math.floor(point.y / cellSize) };
2843
+ }
2844
+ function evalGridIsoToScreen(args, evaluate2, ctx) {
2845
+ const cell = asCell(evaluate2(args[0], ctx));
2846
+ const tileW = evaluate2(args[1], ctx);
2847
+ const tileH = evaluate2(args[2], ctx);
2848
+ return { x: (cell.x - cell.y) * tileW / 2, y: (cell.x + cell.y) * tileH / 2 };
2849
+ }
2850
+ function evalGridScreenToIso(args, evaluate2, ctx) {
2851
+ const point = asCell(evaluate2(args[0], ctx));
2852
+ const tileW = evaluate2(args[1], ctx);
2853
+ const tileH = evaluate2(args[2], ctx);
2854
+ const halfW = tileW / 2;
2855
+ const halfH = tileH / 2;
2856
+ return {
2857
+ x: (point.x / halfW + point.y / halfH) / 2,
2858
+ y: (point.y / halfH - point.x / halfW) / 2
2859
+ };
2860
+ }
2861
+ function evalGridDistance(args, evaluate2, ctx) {
2862
+ const a = asCell(evaluate2(args[0], ctx));
2863
+ const b = asCell(evaluate2(args[1], ctx));
2864
+ return Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y));
2865
+ }
2866
+ function evalGridManhattanDistance(args, evaluate2, ctx) {
2867
+ const a = asCell(evaluate2(args[0], ctx));
2868
+ const b = asCell(evaluate2(args[1], ctx));
2869
+ return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
2870
+ }
2871
+ function evalGridNeighbors(args, evaluate2, ctx) {
2872
+ const cell = asCell(evaluate2(args[0], ctx));
2873
+ const diagonal = args.length > 1 ? Boolean(evaluate2(args[1], ctx)) : false;
2874
+ const result = [
2875
+ { x: cell.x, y: cell.y - 1 },
2876
+ // N
2877
+ { x: cell.x + 1, y: cell.y },
2878
+ // E
2879
+ { x: cell.x, y: cell.y + 1 },
2880
+ // S
2881
+ { x: cell.x - 1, y: cell.y }
2882
+ // W
2883
+ ];
2884
+ if (diagonal) {
2885
+ result.push(
2886
+ { x: cell.x + 1, y: cell.y - 1 },
2887
+ // NE
2888
+ { x: cell.x + 1, y: cell.y + 1 },
2889
+ // SE
2890
+ { x: cell.x - 1, y: cell.y + 1 },
2891
+ // SW
2892
+ { x: cell.x - 1, y: cell.y - 1 }
2893
+ // NW
2894
+ );
2895
+ }
2896
+ return result;
2897
+ }
2898
+ function evalGridCellsInRadius(args, evaluate2, ctx) {
2899
+ const cell = asCell(evaluate2(args[0], ctx));
2900
+ const r = evaluate2(args[1], ctx);
2901
+ const rf = Math.floor(r);
2902
+ const r2 = r * r;
2903
+ const result = [];
2904
+ for (let dy = -rf; dy <= rf; dy++) {
2905
+ for (let dx = -rf; dx <= rf; dx++) {
2906
+ if (dx * dx + dy * dy <= r2) {
2907
+ result.push({ x: cell.x + dx, y: cell.y + dy });
2908
+ }
2909
+ }
2910
+ }
2911
+ return result;
2912
+ }
2913
+ function evalGridLine(args, evaluate2, ctx) {
2914
+ const a = asCell(evaluate2(args[0], ctx));
2915
+ const b = asCell(evaluate2(args[1], ctx));
2916
+ let x0 = a.x, y0 = a.y;
2917
+ const x1 = b.x, y1 = b.y;
2918
+ const dx = Math.abs(x1 - x0);
2919
+ const dy = Math.abs(y1 - y0);
2920
+ const sx = x0 < x1 ? 1 : -1;
2921
+ const sy = y0 < y1 ? 1 : -1;
2922
+ let err = dx - dy;
2923
+ const result = [];
2924
+ for (; ; ) {
2925
+ result.push({ x: x0, y: y0 });
2926
+ if (x0 === x1 && y0 === y1) {
2927
+ break;
2928
+ }
2929
+ const e2 = 2 * err;
2930
+ if (e2 > -dy) {
2931
+ err -= dy;
2932
+ x0 += sx;
2933
+ }
2934
+ if (e2 < dx) {
2935
+ err += dx;
2936
+ y0 += sy;
2937
+ }
2938
+ }
2939
+ return result;
2940
+ }
2941
+ function evalGridInBounds(args, evaluate2, ctx) {
2942
+ const cell = asCell(evaluate2(args[0], ctx));
2943
+ const w = evaluate2(args[1], ctx);
2944
+ const h = evaluate2(args[2], ctx);
2945
+ return cell.x >= 0 && cell.x < w && cell.y >= 0 && cell.y < h;
2946
+ }
2947
+
2948
+ // std/anim.ts
2949
+ function evalAnimFrameAt(args, evaluate2, ctx) {
2950
+ const elapsed = evaluate2(args[0], ctx);
2951
+ const frameDur = evaluate2(args[1], ctx);
2952
+ const frameCount = evaluate2(args[2], ctx);
2953
+ const loop = args.length > 3 ? Boolean(evaluate2(args[3], ctx)) : true;
2954
+ if (frameCount <= 0) {
2955
+ return 0;
2956
+ }
2957
+ const i = Math.floor(elapsed / frameDur);
2958
+ if (loop) {
2959
+ return (i % frameCount + frameCount) % frameCount;
2960
+ }
2961
+ return Math.min(i, frameCount - 1);
2962
+ }
2963
+ function evalAnimSheetRect(args, evaluate2, ctx) {
2964
+ const frameIndex = evaluate2(args[0], ctx);
2965
+ const cols = evaluate2(args[1], ctx);
2966
+ const frameW = evaluate2(args[2], ctx);
2967
+ const frameH = evaluate2(args[3], ctx);
2968
+ return {
2969
+ sx: frameIndex % cols * frameW,
2970
+ sy: Math.floor(frameIndex / cols) * frameH,
2971
+ sw: frameW,
2972
+ sh: frameH
2973
+ };
2974
+ }
2975
+ function evalAnimDirectionFromDelta(args, evaluate2, ctx) {
2976
+ const dx = evaluate2(args[0], ctx);
2977
+ const dy = evaluate2(args[1], ctx);
2978
+ const ways = args.length > 2 ? evaluate2(args[2], ctx) : 4;
2979
+ const angle = Math.atan2(dy, dx);
2980
+ if (ways === 8) {
2981
+ const sector2 = Math.round(angle / (Math.PI / 4));
2982
+ const idx2 = (sector2 % 8 + 8) % 8;
2983
+ const dirs8 = [
2984
+ "right",
2985
+ "down-right",
2986
+ "down",
2987
+ "down-left",
2988
+ "left",
2989
+ "up-left",
2990
+ "up",
2991
+ "up-right"
2992
+ ];
2993
+ return dirs8[idx2];
2994
+ }
2995
+ const sector = Math.round(angle / (Math.PI / 2));
2996
+ const idx = (sector % 4 + 4) % 4;
2997
+ const dirs4 = ["right", "down", "left", "up"];
2998
+ return dirs4[idx];
2999
+ }
3000
+
3001
+ // std/ease.ts
3002
+ function clamp01(t) {
3003
+ return Math.min(Math.max(t, 0), 1);
3004
+ }
3005
+ function applyCurve(curve, tRaw) {
3006
+ const t = clamp01(tRaw);
3007
+ switch (curve) {
3008
+ case "in-quad":
3009
+ return t * t;
3010
+ case "out-quad":
3011
+ return t * (2 - t);
3012
+ case "in-out-quad":
3013
+ return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
3014
+ case "in-cubic":
3015
+ return t * t * t;
3016
+ case "out-cubic": {
3017
+ const u = t - 1;
3018
+ return u * u * u + 1;
3019
+ }
3020
+ case "in-out-cubic":
3021
+ return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
3022
+ case "elastic-out": {
3023
+ if (t === 0) {
3024
+ return 0;
3025
+ }
3026
+ if (t === 1) {
3027
+ return 1;
3028
+ }
3029
+ const c4 = 2 * Math.PI / 3;
3030
+ return Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1;
3031
+ }
3032
+ case "bounce-out": {
3033
+ const n1 = 7.5625;
3034
+ const d1 = 2.75;
3035
+ let u = t;
3036
+ if (u < 1 / d1) {
3037
+ return n1 * u * u;
3038
+ } else if (u < 2 / d1) {
3039
+ u -= 1.5 / d1;
3040
+ return n1 * u * u + 0.75;
3041
+ } else if (u < 2.5 / d1) {
3042
+ u -= 2.25 / d1;
3043
+ return n1 * u * u + 0.9375;
3044
+ } else {
3045
+ u -= 2.625 / d1;
3046
+ return n1 * u * u + 0.984375;
3047
+ }
3048
+ }
3049
+ case "linear":
3050
+ default:
3051
+ return t;
3052
+ }
3053
+ }
3054
+ function evalEaseApply(args, evaluate2, ctx) {
3055
+ const curve = evaluate2(args[0], ctx);
3056
+ const t = evaluate2(args[1], ctx);
3057
+ return applyCurve(curve, t);
3058
+ }
3059
+ function evalEaseSmoothstep(args, evaluate2, ctx) {
3060
+ const edge0 = evaluate2(args[0], ctx);
3061
+ const edge1 = evaluate2(args[1], ctx);
3062
+ const x = evaluate2(args[2], ctx);
3063
+ if (edge0 === edge1) {
3064
+ return 0;
3065
+ }
3066
+ const t = clamp01((x - edge0) / (edge1 - edge0));
3067
+ return t * t * (3 - 2 * t);
3068
+ }
3069
+
2575
3070
  // SExpressionEvaluator.ts
2576
3071
  var jitCache = /* @__PURE__ */ new Map();
2577
3072
  var MAX_JIT_CACHE_SIZE = 1e3;
@@ -2752,6 +3247,8 @@ var SExpressionEvaluator = class {
2752
3247
  return evalIncludes(args, evaluate2, ctx);
2753
3248
  case "empty":
2754
3249
  return evalEmpty(args, evaluate2, ctx);
3250
+ case "list":
3251
+ return evalList(args, evaluate2, ctx);
2755
3252
  // Effects
2756
3253
  case "set":
2757
3254
  evalSet(args, evaluate2, ctx);
@@ -2836,6 +3333,111 @@ var SExpressionEvaluator = class {
2836
3333
  return evalMathRandomInt(args, evaluate2, ctx);
2837
3334
  case "math/default":
2838
3335
  return evalMathDefault(args, evaluate2, ctx);
3336
+ case "math/sin":
3337
+ return evalMathSin(args, evaluate2, ctx);
3338
+ case "math/cos":
3339
+ return evalMathCos(args, evaluate2, ctx);
3340
+ case "math/tan":
3341
+ return evalMathTan(args, evaluate2, ctx);
3342
+ case "math/atan2":
3343
+ return evalMathAtan2(args, evaluate2, ctx);
3344
+ case "math/hypot":
3345
+ return evalMathHypot(args, evaluate2, ctx);
3346
+ case "math/deg-rad":
3347
+ return evalMathDegRad(args, evaluate2, ctx);
3348
+ case "math/rad-deg":
3349
+ return evalMathRadDeg(args, evaluate2, ctx);
3350
+ case "math/wrap":
3351
+ return evalMathWrap(args, evaluate2, ctx);
3352
+ case "math/approach":
3353
+ return evalMathApproach(args, evaluate2, ctx);
3354
+ // ===============================
3355
+ // Standard Library: vec/*
3356
+ // ===============================
3357
+ case "vec/add":
3358
+ return evalVecAdd(args, evaluate2, ctx);
3359
+ case "vec/sub":
3360
+ return evalVecSub(args, evaluate2, ctx);
3361
+ case "vec/scale":
3362
+ return evalVecScale(args, evaluate2, ctx);
3363
+ case "vec/dot":
3364
+ return evalVecDot(args, evaluate2, ctx);
3365
+ case "vec/cross":
3366
+ return evalVecCross(args, evaluate2, ctx);
3367
+ case "vec/length":
3368
+ return evalVecLength(args, evaluate2, ctx);
3369
+ case "vec/length-sq":
3370
+ return evalVecLengthSq(args, evaluate2, ctx);
3371
+ case "vec/normalize":
3372
+ return evalVecNormalize(args, evaluate2, ctx);
3373
+ case "vec/distance":
3374
+ return evalVecDistance(args, evaluate2, ctx);
3375
+ case "vec/distance-sq":
3376
+ return evalVecDistanceSq(args, evaluate2, ctx);
3377
+ case "vec/lerp":
3378
+ return evalVecLerp(args, evaluate2, ctx);
3379
+ case "vec/angle":
3380
+ return evalVecAngle(args, evaluate2, ctx);
3381
+ case "vec/rotate":
3382
+ return evalVecRotate(args, evaluate2, ctx);
3383
+ case "vec/clamp-length":
3384
+ return evalVecClampLength(args, evaluate2, ctx);
3385
+ // ===============================
3386
+ // Standard Library: geo/*
3387
+ // ===============================
3388
+ case "geo/aabb-overlap":
3389
+ return evalGeoAabbOverlap(args, evaluate2, ctx);
3390
+ case "geo/circle-overlap":
3391
+ return evalGeoCircleOverlap(args, evaluate2, ctx);
3392
+ case "geo/rect-circle-overlap":
3393
+ return evalGeoRectCircleOverlap(args, evaluate2, ctx);
3394
+ case "geo/point-in-rect":
3395
+ return evalGeoPointInRect(args, evaluate2, ctx);
3396
+ case "geo/point-in-circle":
3397
+ return evalGeoPointInCircle(args, evaluate2, ctx);
3398
+ case "geo/reflect":
3399
+ return evalGeoReflect(args, evaluate2, ctx);
3400
+ case "geo/segment-intersect":
3401
+ return evalGeoSegmentIntersect(args, evaluate2, ctx);
3402
+ // ===============================
3403
+ // Standard Library: grid/*
3404
+ // ===============================
3405
+ case "grid/to-world":
3406
+ return evalGridToWorld(args, evaluate2, ctx);
3407
+ case "grid/from-world":
3408
+ return evalGridFromWorld(args, evaluate2, ctx);
3409
+ case "grid/iso-to-screen":
3410
+ return evalGridIsoToScreen(args, evaluate2, ctx);
3411
+ case "grid/screen-to-iso":
3412
+ return evalGridScreenToIso(args, evaluate2, ctx);
3413
+ case "grid/distance":
3414
+ return evalGridDistance(args, evaluate2, ctx);
3415
+ case "grid/manhattan-distance":
3416
+ return evalGridManhattanDistance(args, evaluate2, ctx);
3417
+ case "grid/neighbors":
3418
+ return evalGridNeighbors(args, evaluate2, ctx);
3419
+ case "grid/cells-in-radius":
3420
+ return evalGridCellsInRadius(args, evaluate2, ctx);
3421
+ case "grid/line":
3422
+ return evalGridLine(args, evaluate2, ctx);
3423
+ case "grid/in-bounds":
3424
+ return evalGridInBounds(args, evaluate2, ctx);
3425
+ // ===============================
3426
+ // Standard Library: anim/*
3427
+ // ===============================
3428
+ case "anim/frame-at":
3429
+ return evalAnimFrameAt(args, evaluate2, ctx);
3430
+ case "anim/sheet-rect":
3431
+ return evalAnimSheetRect(args, evaluate2, ctx);
3432
+ case "anim/direction-from-delta":
3433
+ return evalAnimDirectionFromDelta(args, evaluate2, ctx);
3434
+ // ===============================
3435
+ // Standard Library: ease/*
3436
+ // ===============================
3437
+ case "ease/apply":
3438
+ return evalEaseApply(args, evaluate2, ctx);
3439
+ case "ease/smoothstep":
3440
+ return evalEaseSmoothstep(args, evaluate2, ctx);
2839
3441
  // ===============================
2840
3442
  // Standard Library: str/*
2841
3443
  // ===============================
@@ -3306,6 +3908,6 @@ function executeEffects(effects, ctx) {
3306
3908
  evaluator.executeEffects(effects, ctx);
3307
3909
  }
3308
3910
 
3309
- 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 };
3911
+ 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 };
3310
3912
  //# sourceMappingURL=index.js.map
3311
3913
  //# sourceMappingURL=index.js.map