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.
- package/README.md +14 -7
- package/dist/automerge/doc-cell.d.ts +20 -0
- package/dist/automerge/doc-cell.js +80 -0
- package/dist/automerge/index.d.ts +3 -0
- package/dist/automerge/index.js +12 -0
- package/dist/automerge/reconcile.d.ts +5 -0
- package/dist/automerge/reconcile.js +63 -0
- package/dist/core/_counts.d.ts +48 -0
- package/dist/core/_counts.js +51 -0
- package/dist/core/cell.d.ts +148 -112
- package/dist/core/cell.js +945 -768
- package/dist/core/debug.d.ts +25 -0
- package/dist/core/debug.js +121 -0
- package/dist/core/derived-geometry.js +4 -7
- package/dist/core/index.d.ts +9 -2
- package/dist/core/index.js +8 -1
- package/dist/core/lenses/aggregates.d.ts +42 -52
- package/dist/core/lenses/aggregates.js +225 -116
- package/dist/core/lenses/geometry.d.ts +22 -4
- package/dist/core/lenses/geometry.js +59 -27
- package/dist/core/lenses/index.d.ts +6 -6
- package/dist/core/lenses/index.js +6 -6
- package/dist/core/lenses/memory.js +4 -17
- package/dist/core/lenses/numerical.d.ts +100 -0
- package/dist/core/lenses/{typed-factor.js → numerical.js} +136 -34
- package/dist/core/lenses/point-cloud.d.ts +67 -0
- package/dist/core/lenses/{closed-form-policies.js → point-cloud.js} +226 -84
- package/dist/core/lenses/snap.d.ts +18 -0
- package/dist/core/lenses/snap.js +138 -0
- package/dist/core/lenses/text.d.ts +40 -0
- package/dist/core/lenses/text.js +202 -0
- package/dist/core/lifecycle.js +3 -6
- package/dist/core/linalg.js +5 -11
- package/dist/core/optic.d.ts +13 -0
- package/dist/core/optic.js +39 -0
- package/dist/core/optics.d.ts +10 -0
- package/dist/core/optics.js +26 -0
- package/dist/core/store.d.ts +9 -0
- package/dist/core/store.js +77 -0
- package/dist/core/traits.d.ts +4 -7
- package/dist/core/traits.js +8 -12
- package/dist/core/values/anchor.js +0 -4
- package/dist/core/values/arr.d.ts +110 -0
- package/dist/core/values/arr.js +336 -0
- package/dist/core/values/audio.d.ts +8 -9
- package/dist/core/values/audio.js +11 -28
- package/dist/core/values/bool.d.ts +11 -11
- package/dist/core/values/bool.js +12 -22
- package/dist/core/values/box.d.ts +15 -20
- package/dist/core/values/box.js +20 -33
- package/dist/core/values/canvas.d.ts +18 -25
- package/dist/core/values/canvas.js +32 -66
- package/dist/core/values/color.d.ts +5 -7
- package/dist/core/values/color.js +5 -11
- package/dist/core/values/field.d.ts +6 -7
- package/dist/core/values/field.js +10 -35
- package/dist/core/values/flags.d.ts +1 -2
- package/dist/core/values/flags.js +1 -17
- package/dist/core/values/gpu.d.ts +6 -10
- package/dist/core/values/gpu.js +8 -22
- package/dist/core/values/matrix.d.ts +2 -4
- package/dist/core/values/matrix.js +2 -12
- package/dist/core/values/num.d.ts +19 -28
- package/dist/core/values/num.js +23 -41
- package/dist/core/values/pose.d.ts +2 -4
- package/dist/core/values/pose.js +3 -12
- package/dist/core/values/range.d.ts +18 -26
- package/dist/core/values/range.js +22 -39
- package/dist/core/values/reg/ambiguity.d.ts +8 -0
- package/dist/core/values/reg/ambiguity.js +131 -0
- package/dist/core/values/reg/engine.d.ts +91 -0
- package/dist/core/values/reg/engine.js +373 -0
- package/dist/core/values/reg/nfa.d.ts +42 -0
- package/dist/core/values/reg/nfa.js +391 -0
- package/dist/core/values/reg/regex.d.ts +7 -0
- package/dist/core/values/reg/regex.js +318 -0
- package/dist/core/values/reg/types.d.ts +60 -0
- package/dist/core/values/reg/types.js +3 -0
- package/dist/core/values/reg.d.ts +250 -0
- package/dist/core/values/reg.js +649 -0
- package/dist/core/values/str.d.ts +16 -60
- package/dist/core/values/str.js +133 -315
- package/dist/core/values/template.js +1 -24
- package/dist/core/values/transform.d.ts +3 -5
- package/dist/core/values/transform.js +3 -12
- package/dist/core/values/tri.d.ts +9 -10
- package/dist/core/values/tri.js +9 -15
- package/dist/core/values/vec.d.ts +9 -24
- package/dist/core/values/vec.js +9 -64
- package/dist/formats/lens.js +6 -9
- package/dist/index.d.ts +0 -11
- package/dist/index.js +1 -11
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +5 -0
- package/dist/jsx-runtime.d.ts +54 -0
- package/dist/jsx-runtime.js +219 -0
- package/dist/schema/lens.js +5 -5
- package/dist/shapes/drag-behaviors.d.ts +56 -0
- package/dist/shapes/drag-behaviors.js +102 -0
- package/dist/shapes/drag-spec.d.ts +52 -0
- package/dist/shapes/drag-spec.js +112 -0
- package/dist/shapes/index.d.ts +3 -1
- package/dist/shapes/index.js +3 -1
- package/dist/shapes/interaction.d.ts +2 -3
- package/dist/shapes/interaction.js +77 -56
- package/dist/shapes/label.js +6 -0
- package/dist/shapes/layout.d.ts +47 -1
- package/dist/shapes/layout.js +59 -1
- package/package.json +22 -1
- package/dist/coll.d.ts +0 -74
- package/dist/coll.js +0 -210
- package/dist/core/lenses/closed-form-policies.d.ts +0 -57
- package/dist/core/lenses/decompositions.d.ts +0 -14
- package/dist/core/lenses/decompositions.js +0 -224
- package/dist/core/lenses/domain-aggregates.d.ts +0 -42
- package/dist/core/lenses/domain-aggregates.js +0 -245
- 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
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
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) {
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
export {
|
|
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 {
|
|
30
|
+
export { tangentPoint, Vec, vec } from "./values/vec.js";
|
package/dist/core/index.js
CHANGED
|
@@ -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 {
|
|
30
|
+
export { tangentPoint, Vec, vec } from "./values/vec.js";
|
|
@@ -1,53 +1,43 @@
|
|
|
1
|
-
import { type Writable } from "../
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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>;
|