bireactive 0.3.0 → 0.3.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.
Files changed (117) hide show
  1. package/README.md +14 -7
  2. package/dist/automerge/doc-cell.d.ts +20 -0
  3. package/dist/automerge/doc-cell.js +80 -0
  4. package/dist/automerge/index.d.ts +3 -0
  5. package/dist/automerge/index.js +12 -0
  6. package/dist/automerge/reconcile.d.ts +5 -0
  7. package/dist/automerge/reconcile.js +63 -0
  8. package/dist/core/_counts.d.ts +48 -0
  9. package/dist/core/_counts.js +51 -0
  10. package/dist/core/cell.d.ts +148 -112
  11. package/dist/core/cell.js +945 -768
  12. package/dist/core/debug.d.ts +25 -0
  13. package/dist/core/debug.js +121 -0
  14. package/dist/core/derived-geometry.js +4 -7
  15. package/dist/core/index.d.ts +9 -2
  16. package/dist/core/index.js +8 -1
  17. package/dist/core/lenses/aggregates.d.ts +42 -52
  18. package/dist/core/lenses/aggregates.js +225 -116
  19. package/dist/core/lenses/geometry.d.ts +22 -4
  20. package/dist/core/lenses/geometry.js +59 -27
  21. package/dist/core/lenses/index.d.ts +6 -6
  22. package/dist/core/lenses/index.js +6 -6
  23. package/dist/core/lenses/memory.js +4 -17
  24. package/dist/core/lenses/numerical.d.ts +100 -0
  25. package/dist/core/lenses/{typed-factor.js → numerical.js} +136 -34
  26. package/dist/core/lenses/point-cloud.d.ts +67 -0
  27. package/dist/core/lenses/{closed-form-policies.js → point-cloud.js} +226 -84
  28. package/dist/core/lenses/snap.d.ts +18 -0
  29. package/dist/core/lenses/snap.js +138 -0
  30. package/dist/core/lenses/text.d.ts +40 -0
  31. package/dist/core/lenses/text.js +202 -0
  32. package/dist/core/lifecycle.js +3 -6
  33. package/dist/core/linalg.js +5 -11
  34. package/dist/core/optic.d.ts +13 -0
  35. package/dist/core/optic.js +39 -0
  36. package/dist/core/optics.d.ts +10 -0
  37. package/dist/core/optics.js +26 -0
  38. package/dist/core/store.d.ts +9 -0
  39. package/dist/core/store.js +77 -0
  40. package/dist/core/traits.d.ts +4 -7
  41. package/dist/core/traits.js +8 -12
  42. package/dist/core/values/anchor.js +0 -4
  43. package/dist/core/values/arr.d.ts +110 -0
  44. package/dist/core/values/arr.js +336 -0
  45. package/dist/core/values/audio.d.ts +8 -9
  46. package/dist/core/values/audio.js +11 -28
  47. package/dist/core/values/bool.d.ts +11 -11
  48. package/dist/core/values/bool.js +12 -22
  49. package/dist/core/values/box.d.ts +15 -20
  50. package/dist/core/values/box.js +20 -33
  51. package/dist/core/values/canvas.d.ts +18 -25
  52. package/dist/core/values/canvas.js +32 -66
  53. package/dist/core/values/color.d.ts +5 -7
  54. package/dist/core/values/color.js +5 -11
  55. package/dist/core/values/field.d.ts +6 -7
  56. package/dist/core/values/field.js +10 -35
  57. package/dist/core/values/flags.d.ts +1 -2
  58. package/dist/core/values/flags.js +1 -17
  59. package/dist/core/values/gpu.d.ts +6 -10
  60. package/dist/core/values/gpu.js +8 -22
  61. package/dist/core/values/matrix.d.ts +2 -4
  62. package/dist/core/values/matrix.js +2 -12
  63. package/dist/core/values/num.d.ts +19 -28
  64. package/dist/core/values/num.js +23 -41
  65. package/dist/core/values/pose.d.ts +2 -4
  66. package/dist/core/values/pose.js +3 -12
  67. package/dist/core/values/range.d.ts +18 -26
  68. package/dist/core/values/range.js +22 -39
  69. package/dist/core/values/reg/ambiguity.d.ts +8 -0
  70. package/dist/core/values/reg/ambiguity.js +131 -0
  71. package/dist/core/values/reg/engine.d.ts +91 -0
  72. package/dist/core/values/reg/engine.js +373 -0
  73. package/dist/core/values/reg/nfa.d.ts +42 -0
  74. package/dist/core/values/reg/nfa.js +391 -0
  75. package/dist/core/values/reg/regex.d.ts +7 -0
  76. package/dist/core/values/reg/regex.js +318 -0
  77. package/dist/core/values/reg/types.d.ts +60 -0
  78. package/dist/core/values/reg/types.js +3 -0
  79. package/dist/core/values/reg.d.ts +250 -0
  80. package/dist/core/values/reg.js +649 -0
  81. package/dist/core/values/str.d.ts +16 -60
  82. package/dist/core/values/str.js +133 -315
  83. package/dist/core/values/template.js +1 -24
  84. package/dist/core/values/transform.d.ts +3 -5
  85. package/dist/core/values/transform.js +3 -12
  86. package/dist/core/values/tri.d.ts +9 -10
  87. package/dist/core/values/tri.js +9 -15
  88. package/dist/core/values/vec.d.ts +9 -24
  89. package/dist/core/values/vec.js +9 -64
  90. package/dist/formats/lens.js +6 -9
  91. package/dist/index.d.ts +0 -11
  92. package/dist/index.js +1 -11
  93. package/dist/jsx-dev-runtime.d.ts +2 -0
  94. package/dist/jsx-dev-runtime.js +5 -0
  95. package/dist/jsx-runtime.d.ts +54 -0
  96. package/dist/jsx-runtime.js +219 -0
  97. package/dist/schema/lens.js +5 -5
  98. package/dist/shapes/drag-behaviors.d.ts +56 -0
  99. package/dist/shapes/drag-behaviors.js +102 -0
  100. package/dist/shapes/drag-spec.d.ts +52 -0
  101. package/dist/shapes/drag-spec.js +112 -0
  102. package/dist/shapes/index.d.ts +3 -1
  103. package/dist/shapes/index.js +3 -1
  104. package/dist/shapes/interaction.d.ts +2 -3
  105. package/dist/shapes/interaction.js +77 -56
  106. package/dist/shapes/label.js +6 -0
  107. package/dist/shapes/layout.d.ts +47 -1
  108. package/dist/shapes/layout.js +59 -1
  109. package/package.json +22 -1
  110. package/dist/coll.d.ts +0 -74
  111. package/dist/coll.js +0 -210
  112. package/dist/core/lenses/closed-form-policies.d.ts +0 -57
  113. package/dist/core/lenses/decompositions.d.ts +0 -14
  114. package/dist/core/lenses/decompositions.js +0 -224
  115. package/dist/core/lenses/domain-aggregates.d.ts +0 -42
  116. package/dist/core/lenses/domain-aggregates.js +0 -245
  117. package/dist/core/lenses/typed-factor.d.ts +0 -40
@@ -0,0 +1,25 @@
1
+ import { Cell } from "./cell.js";
2
+ type SomeCell = Cell<any>;
3
+ /** Short, stable display name: the cell's `name`, else `Ctor#n`. */
4
+ export declare function label(c: SomeCell): string;
5
+ /** `source` (no getter), `lens` (writable derived), or `computed` (read-only derived). */
6
+ export declare function kind(c: SomeCell): "source" | "lens" | "computed";
7
+ /** Upstream cells: eager lens parents unioned with dynamic forward deps. */
8
+ export declare function upstream(c: SomeCell): Cell<unknown>[];
9
+ /** One-line summary: `name = value [kind]` plus upstream labels, if any. */
10
+ export declare function explain(c: SomeCell): string;
11
+ export interface DumpOpts {
12
+ /** Max upstream depth to descend. Default `Infinity`. */
13
+ depth?: number;
14
+ /** Include `= value` in each line. Default `true`. */
15
+ values?: boolean;
16
+ }
17
+ /** Render the upstream graph of `root` as an indented tree (cycle-safe). */
18
+ export declare function dumpGraph(root: SomeCell, opts?: DumpOpts): string;
19
+ /** Run `fn` and collect the source cells written during it (back-writes included,
20
+ * since a view write commits through its sources' `_writeSource`). */
21
+ export declare function traceWrites<T>(fn: () => T): {
22
+ result: T;
23
+ writes: Cell<unknown>[];
24
+ };
25
+ export {};
@@ -0,0 +1,121 @@
1
+ // debug.ts — read-only inspection of the cell graph (dev-time, no hot-path cost).
2
+ //
3
+ // Three small tools: `explain` (one line about a cell), `dumpGraph` (the upstream
4
+ // dependency tree), and `traceWrites` (which sources a block of work actually
5
+ // wrote). All walk the same edges the engine maintains — lens parents
6
+ // (`parentEdges`, eager) unioned with dynamic forward deps (`deps`, post-read) —
7
+ // and label cells by their optional `name` (falling back to `Ctor#n`). Nothing
8
+ // here mutates graph state; reads go through `peek` so they don't track.
9
+ import { Cell, isLens, isReadonly, setCellWriteHook } from "./cell.js";
10
+ const edges = (c) => c;
11
+ const erase = (c) => c;
12
+ const ids = new WeakMap();
13
+ let nextId = 1;
14
+ function idOf(c) {
15
+ let i = ids.get(c);
16
+ if (i === undefined) {
17
+ i = nextId++;
18
+ ids.set(c, i);
19
+ }
20
+ return i;
21
+ }
22
+ /** Short, stable display name: the cell's `name`, else `Ctor#n`. */
23
+ export function label(c) {
24
+ return c.name ?? `${c.constructor.name}#${idOf(erase(c))}`;
25
+ }
26
+ /** `source` (no getter), `lens` (writable derived), or `computed` (read-only derived). */
27
+ export function kind(c) {
28
+ return isLens(c) ? "lens" : isReadonly(c) ? "computed" : "source";
29
+ }
30
+ function short(v) {
31
+ try {
32
+ if (typeof v === "string")
33
+ return JSON.stringify(v);
34
+ if (v === null || v === undefined || typeof v !== "object")
35
+ return String(v);
36
+ const s = JSON.stringify(v);
37
+ if (s === undefined)
38
+ return Object.prototype.toString.call(v);
39
+ return s.length > 48 ? `${s.slice(0, 47)}…` : s;
40
+ }
41
+ catch {
42
+ return "?";
43
+ }
44
+ }
45
+ /** Upstream cells: eager lens parents unioned with dynamic forward deps. */
46
+ export function upstream(c) {
47
+ const out = [];
48
+ const seen = new Set();
49
+ const push = (n) => {
50
+ if (n instanceof Cell && !seen.has(n)) {
51
+ seen.add(n);
52
+ out.push(n);
53
+ }
54
+ };
55
+ for (let e = edges(erase(c)).parentEdges; e !== undefined; e = e.nextParent)
56
+ push(e.parent);
57
+ for (let l = edges(erase(c)).deps; l !== undefined; l = l.nextDep)
58
+ push(l.dep);
59
+ return out;
60
+ }
61
+ /** One-line summary: `name = value [kind]` plus upstream labels, if any. */
62
+ export function explain(c) {
63
+ let v;
64
+ try {
65
+ v = c.peek();
66
+ }
67
+ catch {
68
+ v = "?";
69
+ }
70
+ const ups = upstream(c);
71
+ const tail = ups.length > 0 ? ` ← ${ups.map(label).join(", ")}` : "";
72
+ return `${label(c)} = ${short(v)} [${kind(c)}]${tail}`;
73
+ }
74
+ /** Render the upstream graph of `root` as an indented tree (cycle-safe). */
75
+ export function dumpGraph(root, opts = {}) {
76
+ const maxDepth = opts.depth ?? Number.POSITIVE_INFINITY;
77
+ const withValues = opts.values ?? true;
78
+ const lines = [];
79
+ const path = new Set();
80
+ const line = (c, indent) => {
81
+ if (!withValues)
82
+ return `${indent}${label(c)} [${kind(c)}]`;
83
+ let v;
84
+ try {
85
+ v = c.peek();
86
+ }
87
+ catch {
88
+ v = "?";
89
+ }
90
+ return `${indent}${label(c)} = ${short(v)} [${kind(c)}]`;
91
+ };
92
+ const walk = (c, indent, depth) => {
93
+ if (path.has(c)) {
94
+ lines.push(`${indent}${label(c)} ↺`); // back-edge into the current path
95
+ return;
96
+ }
97
+ lines.push(line(c, indent));
98
+ if (depth >= maxDepth)
99
+ return;
100
+ path.add(c);
101
+ for (const u of upstream(c))
102
+ walk(u, `${indent} `, depth + 1);
103
+ path.delete(c);
104
+ };
105
+ walk(root, "", 0);
106
+ return lines.join("\n");
107
+ }
108
+ /** Run `fn` and collect the source cells written during it (back-writes included,
109
+ * since a view write commits through its sources' `_writeSource`). */
110
+ export function traceWrites(fn) {
111
+ const writes = [];
112
+ const restore = setCellWriteHook(c => {
113
+ writes.push(c);
114
+ });
115
+ try {
116
+ return { result: fn(), writes };
117
+ }
118
+ finally {
119
+ restore();
120
+ }
121
+ }
@@ -1,10 +1,7 @@
1
- // derived-geometry.ts — read-only geometric readouts over `Cls.derive`.
2
- //
3
- // One-way derives whose inverse is genuinely under-determined (a point
4
- // sampled at parameter `t` constrains the curve at one point, but the
5
- // control points have many DOF). They live here, off the lens surface,
6
- // to keep `lenses/` exclusively bidirectional. For the writable bezier
7
- // shape decomposition see `bezierGestalt` in `lenses/domain-aggregates`.
1
+ // Read-only geometric readouts over `Cls.derive`: one-way derives whose inverse
2
+ // is under-determined (a point at parameter `t` pins the curve at one point, but
3
+ // the control points keep many DOF). For the writable bezier decomposition see
4
+ // `bezierGestalt` in `lenses/geometry`.
8
5
  import { Vec } from "./values/vec.js";
9
6
  /** Quadratic Bézier point at parameter `t`. RO. */
10
7
  export function bezier2(p0, p1, p2, t) {
@@ -1,9 +1,15 @@
1
- export { batch, Cell, type CellOptions, cachedDerive, cell, derive, effect, fieldLens, fieldOf, type Init, type Inner, isCell, isLens, isReadonly, lazy, lens, type Network, network, type Read, reader, readNow, SKIP, type Skip, type StatefulBwd, type StatefulLensSpec, setCellWriteHook, settle, transitiveDeps, untracked, type Val, type Writable, type WritableBrand, } from "./cell.js";
1
+ export { type Counts, counts, resetCounts, snapshotCounts, withCounts } from "./_counts.js";
2
+ export { batch, Cell, type CellOptions, cachedDerive, cell, derive, effect, fieldLens, fieldOf, type Init, type Inner, isCell, isLens, isReadonly, lazy, lens, type Network, network, type Optic, type Read, reader, readNow, SKIP, type Skip, type StatefulBwd, type StatefulBwd1, type StatefulLensSpec, type StatefulLensSpec1, setCellWriteHook, settle, transitiveDeps, untracked, type Val, type Writable, type WritableBrand, } from "./cell.js";
3
+ export { type DumpOpts, dumpGraph, explain, kind as cellKind, label as cellLabel, traceWrites, upstream, } from "./debug.js";
2
4
  export { bezier2, bezier3 } from "./derived-geometry.js";
3
5
  export * from "./lenses/index.js";
4
6
  export { each, type Lifecycle } from "./lifecycle.js";
7
+ export { atKey, compose, iso, optic } from "./optic.js";
8
+ export { at, fields } from "./optics.js";
9
+ export { type Store, store } from "./store.js";
5
10
  export { type Equals, type Lerp, type Linear, type Metric, type Pack, type Pivotal, requireEquals, requireLerp, requireLinear, requireMetric, requirePack, requirePivotal, type TraitDict, type Traits, } from "./traits.js";
6
11
  export { Anchor, Dir } from "./values/anchor.js";
12
+ export { Arr, allPass, arr, type CellPred, type Group, GroupArr, is, } from "./values/arr.js";
7
13
  export { Audio, type AudioClip, audio, stamp as audioStamp } from "./values/audio.js";
8
14
  export { Bool, bool } from "./values/bool.js";
9
15
  export { Box, box, edgeFrom as boxEdgeFrom, expand as boxExpand, union as boxUnion, } from "./values/box.js";
@@ -16,8 +22,9 @@ export { compose as matrixCompose, Matrix, matrix, toMatrixString, transformBox,
16
22
  export { Num, num } from "./values/num.js";
17
23
  export { Pose, pose } from "./values/pose.js";
18
24
  export { Range, range, span } from "./values/range.js";
25
+ export { type AltVal, type BindOpts, type Handle, type HandleKind, type HandleOf, Reg, type RegVal, type Silent, type StarVal, } from "./values/reg.js";
19
26
  export { Str, str } from "./values/str.js";
20
27
  export { type Codec, enumCodec, numCodec, route, type Slot, slot, strCodec, template, tpl, } from "./values/template.js";
21
28
  export { Transform, type TransformInit, transform } from "./values/transform.js";
22
29
  export { Tri, tri } from "./values/tri.js";
23
- export { type PolarPolicy, polar, tangentPoint, Vec, vec } from "./values/vec.js";
30
+ export { tangentPoint, Vec, vec } from "./values/vec.js";
@@ -1,9 +1,15 @@
1
+ export { counts, resetCounts, snapshotCounts, withCounts } from "./_counts.js";
1
2
  export { batch, Cell, cachedDerive, cell, derive, effect, fieldLens, fieldOf, isCell, isLens, isReadonly, lazy, lens, network, reader, readNow, SKIP, setCellWriteHook, settle, transitiveDeps, untracked, } from "./cell.js";
3
+ export { dumpGraph, explain, kind as cellKind, label as cellLabel, traceWrites, upstream, } from "./debug.js";
2
4
  export { bezier2, bezier3 } from "./derived-geometry.js";
3
5
  export * from "./lenses/index.js";
4
6
  export { each } from "./lifecycle.js";
7
+ export { atKey, compose, iso, optic } from "./optic.js";
8
+ export { at, fields } from "./optics.js";
9
+ export { store } from "./store.js";
5
10
  export { requireEquals, requireLerp, requireLinear, requireMetric, requirePack, requirePivotal, } from "./traits.js";
6
11
  export { Anchor, Dir } from "./values/anchor.js";
12
+ export { Arr, allPass, arr, GroupArr, is, } from "./values/arr.js";
7
13
  export { Audio, audio, stamp as audioStamp } from "./values/audio.js";
8
14
  export { Bool, bool } from "./values/bool.js";
9
15
  export { Box, box, edgeFrom as boxEdgeFrom, expand as boxExpand, union as boxUnion, } from "./values/box.js";
@@ -16,8 +22,9 @@ export { compose as matrixCompose, Matrix, matrix, toMatrixString, transformBox,
16
22
  export { Num, num } from "./values/num.js";
17
23
  export { Pose, pose } from "./values/pose.js";
18
24
  export { Range, range, span } from "./values/range.js";
25
+ export { Reg, } from "./values/reg.js";
19
26
  export { Str, str } from "./values/str.js";
20
27
  export { enumCodec, numCodec, route, slot, strCodec, template, tpl, } from "./values/template.js";
21
28
  export { Transform, transform } from "./values/transform.js";
22
29
  export { Tri, tri } from "./values/tri.js";
23
- export { polar, tangentPoint, Vec, vec } from "./values/vec.js";
30
+ export { tangentPoint, Vec, vec } from "./values/vec.js";
@@ -1,53 +1,43 @@
1
- import { type Writable } from "../cell.js";
2
- import { Num } from "../values/num.js";
3
- import { Vec } from "../values/vec.js";
4
- export interface ArgminOpts {
5
- /** Finite-difference epsilon for the Jacobian. Default 1e-4. */
6
- eps?: number;
7
- /** Levenberg-Marquardt damping. Default `1e-6` for `argminNum`
8
- * (Jacobian is always well-conditioned for linear constraints) and
9
- * `1e-3` for `argminVec` (IK chains hit rank-deficient regimes at
10
- * full extension). Larger smaller, more stable updates; smaller
11
- * closer to pure pseudoinverse. */
12
- damping?: number;
13
- }
14
- /** Target-shaping for `argminVec`: project a write into the reachable
15
- * workspace before the Jacobian step, sidestepping the rank-deficient
16
- * swings at the boundary. For an N-link chain rooted at `R` with reach
17
- * `L`, pass `clampToDisc(R, L)`. */
18
- export interface ArgminVecOpts extends ArgminOpts {
19
- /** Pre-write hook: transform the requested target into one that's
20
- * guaranteed solvable. Most useful as a workspace clamp. */
21
- clampTarget?: (target: {
22
- x: number;
23
- y: number;
24
- }, currentInputs: readonly number[]) => {
25
- x: number;
26
- y: number;
27
- };
28
- }
29
- /** Project `p` into the closed disc of radius `r` centred on `c` (points
30
- * inside pass through). Use as `argminVec`'s `clampTarget` to fix IK
31
- * explosion at maximum reach. */
32
- export declare function clampToDisc(c: {
33
- x: number;
34
- y: number;
35
- }, r: number): (p: {
36
- x: number;
37
- y: number;
38
- }) => {
39
- x: number;
40
- y: number;
1
+ import { type Cell, Num, type Read, type Traits, type Val, type Writable } from "../index.js";
2
+ /** Equal-weight mean (writable of `inputs[0]`'s class); writes distribute
3
+ * the delta evenly. Class inferred from the first input; needs `linear`. */
4
+ export declare function mean<S extends Traits<any, "linear">>(inputs: readonly Writable<S>[]): Writable<S>;
5
+ /** Weighted blend of K branches over any `Linear` type: reads the normalized
6
+ * weighted sum `Σ wᵢ·aᵢ`, writes the minimum-norm delta back into the
7
+ * branches (zero-weight branches untouched). Weights are read-only reactive
8
+ * controls a one-hot is `select`, a `(1−t, t)` edge is `crossfade`. */
9
+ export declare function mix<S extends Traits<any, "linear">>(weights: readonly Val<number>[], branches: readonly Writable<S>[]): Writable<S>;
10
+ /** Two-branch router (mix simplex *vertex*): reads the live branch, writes
11
+ * flow entirely to it, the other is left put. Flipping `cond` snaps the
12
+ * output to the other branch's stored value. */
13
+ export declare function select<S extends Traits<any, "linear">>(cond: Read<boolean>, whenFalse: Writable<S>, whenTrue: Writable<S>): Writable<S>;
14
+ /** Two-branch crossfade (mix simplex *edge*): `lerp(a, b, t)`. Writing
15
+ * keeps `t` fixed and splits the delta by influence. */
16
+ export declare function crossfade<S extends Traits<any, "linear">>(t: Read<number>, a: Writable<S>, b: Writable<S>): Writable<S>;
17
+ /** Mean distance from the centroid (needs `Linear` + `Metric`); write scales
18
+ * the cluster's deviations so the new mean matches. The complement carries
19
+ * normalized deviations, so a collapse (spread 0) reinflates the shape. */
20
+ export declare function spread<T extends NonNullable<unknown>, S extends Cell<T> & Traits<T, "linear" | "metric">>(inputs: readonly Writable<S>[]): Writable<Num>;
21
+ /** Mean/spread decomposition: K values → {mean, spread}, i.e. centroid +
22
+ * uniform scale about it. `mean` ∘ `spread`; works for any
23
+ * Linear + Metric class (palettes, point clouds, poses, …). */
24
+ export declare function meanSpread<T extends NonNullable<unknown>, S extends Cell<T> & Traits<T, "linear" | "metric">>(colors: readonly Writable<S>[]): {
25
+ mean: Writable<S>;
26
+ spread: Writable<Num>;
27
+ };
28
+ /** (a, b) → {mean: (a+b)/2, diff: a−b}. Square linear iso; each write is the
29
+ * inverse change of basis, so mean and diff are cross-channel invariant. */
30
+ export declare function meanDiff(a: Num, b: Num): {
31
+ mean: Writable<Num>;
32
+ diff: Writable<Num>;
33
+ };
34
+ /** Mean of N nums, clamped to `[lo, hi]` on read and write (writes are
35
+ * clamped before the delta is distributed). */
36
+ export declare function clampedMean(parents: readonly Num[], lo: number, hi: number): Writable<Num>;
37
+ /** Num values as (i, valueᵢ) samples → {mean, slope}. Writing `mean` shifts
38
+ * all values; writing `slope` (least-squares) tilts them about the mean.
39
+ * Each preserves the other's reading. */
40
+ export declare function timeSeries(values: readonly Writable<Num>[]): {
41
+ mean: Writable<Num>;
42
+ slope: Writable<Num>;
41
43
  };
42
- /** Scalar-output argmin lens: write does one Newton step against the FD
43
- * Jacobian, distributing the residual by `weights`. For typed/multi-
44
- * output cases use `factor()`; this M=1 path is kept for its hand-rolled
45
- * inner loop. */
46
- export declare function argminNum(inputs: readonly Num[], forward: (xs: readonly number[]) => number, weights: readonly number[], opts?: ArgminOpts): Writable<Num>;
47
- /** 2D-output argmin lens (scalar Num inputs, `{x, y}` forward). For IK
48
- * arms, draggable points, handle projection. Kept for its hand-rolled
49
- * 2×2 inverse + `clampTarget` hook; see `factor()` for other M. */
50
- export declare function argminVec(inputs: readonly Num[], forward: (xs: readonly number[]) => {
51
- x: number;
52
- y: number;
53
- }, weights: readonly number[], opts?: ArgminVecOpts): Writable<Vec>;