bireactive 0.3.1 → 0.3.3
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 +24 -11
- package/dist/automerge/doc-cell.js +19 -13
- package/dist/automerge/index.d.ts +3 -2
- package/dist/automerge/index.js +6 -5
- package/dist/automerge/reconcile.d.ts +5 -2
- package/dist/automerge/reconcile.js +73 -15
- package/dist/core/_counts.js +5 -12
- package/dist/core/cell.d.ts +3 -3
- package/dist/core/cell.js +6 -7
- package/dist/core/derived-geometry.js +4 -7
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.js +3 -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 +5 -6
- package/dist/core/lenses/index.js +5 -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} +218 -81
- package/dist/core/lenses/snap.d.ts +1 -1
- package/dist/core/lenses/snap.js +3 -10
- 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.js +10 -15
- package/dist/core/optics.js +4 -8
- package/dist/core/store.d.ts +1 -2
- package/dist/core/store.js +7 -15
- 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 +7 -23
- 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 +17 -48
- 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/index.d.ts +0 -11
- package/dist/index.js +1 -11
- package/package.json +17 -10
- 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
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
// transform.ts — reactive 2D transform.
|
|
2
|
-
//
|
|
3
|
-
// Invertibles (`add`, `sub`) return `: this` and ride on
|
|
4
|
-
// `Cell#lens(fwd, bwd)`; chained calls compose into a lens chain.
|
|
5
|
-
// Field-lens getters use `fieldLens()`, so writability propagates through
|
|
6
|
-
// nested chains
|
|
7
|
-
// (`Transform.translate.x.value = 5` works on writable receivers).
|
|
8
1
|
import { tween } from "../../animation/index.js";
|
|
9
2
|
import { Cell, fieldLens, reader, readNow } from "../cell.js";
|
|
10
3
|
import { Num } from "./num.js";
|
|
@@ -58,8 +51,6 @@ export const metric = (a, b) => vMetric(a.translate, b.translate) +
|
|
|
58
51
|
const linearImpl = { add, sub, scale };
|
|
59
52
|
export class Transform extends Cell {
|
|
60
53
|
static traits = { linear: linearImpl, lerp, metric, equals };
|
|
61
|
-
/** Scalar `scale` is the `.scale` Vec field lens, not an eager method;
|
|
62
|
-
* scalar-multiply via `Transform.lens(...)` or field writes. */
|
|
63
54
|
constructor(v = DEFAULT) {
|
|
64
55
|
super(v, { equals });
|
|
65
56
|
}
|
|
@@ -89,13 +80,13 @@ export class Transform extends Cell {
|
|
|
89
80
|
get opacity() {
|
|
90
81
|
return fieldLens(this, "opacity", Num);
|
|
91
82
|
}
|
|
92
|
-
/** Tween-builder
|
|
83
|
+
/** Tween-builder. */
|
|
93
84
|
to(target, dur, ease) {
|
|
94
85
|
return tween(this, target, dur, ease);
|
|
95
86
|
}
|
|
96
87
|
}
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
88
|
+
/** Writable `Transform` from literal fields. For reactive sources use
|
|
89
|
+
* `Transform.lens` or field writes. */
|
|
99
90
|
export function transform(init) {
|
|
100
91
|
const tr = new Transform();
|
|
101
92
|
if (init) {
|
|
@@ -15,19 +15,18 @@ export declare class Tri extends Cell<V> {
|
|
|
15
15
|
};
|
|
16
16
|
readonly _t: typeof Tri.traits;
|
|
17
17
|
constructor(v?: V);
|
|
18
|
-
/** Kleene negation.
|
|
18
|
+
/** Kleene negation. */
|
|
19
19
|
not(): this;
|
|
20
|
-
/**
|
|
21
|
-
* `
|
|
22
|
-
*
|
|
23
|
-
* child, recursing through nested aggregates; `"mixed"` is a no-op. */
|
|
20
|
+
/** AND-aggregate over writable `Bool`/`Tri` children: `true` if all are true,
|
|
21
|
+
* `false` if all false, else `"mixed"`. A `true`/`false` write broadcasts to
|
|
22
|
+
* every child (recursing into nested aggregates); `"mixed"` is a no-op. */
|
|
24
23
|
static allOf(parents: readonly (Bool | Tri)[]): Writable<Tri>;
|
|
25
|
-
/**
|
|
26
|
-
* `
|
|
27
|
-
* `"mixed"
|
|
24
|
+
/** OR-aggregate over writable `Bool`/`Tri` children: `true` if any is true,
|
|
25
|
+
* `false` if all false, else `"mixed"`. A `true`/`false` write broadcasts to
|
|
26
|
+
* every child; `"mixed"` is a no-op. */
|
|
28
27
|
static anyOf(parents: readonly (Bool | Tri)[]): Writable<Tri>;
|
|
29
28
|
}
|
|
30
|
-
/** Writable `Tri
|
|
31
|
-
*
|
|
29
|
+
/** Writable `Tri` from a literal (new cell) or existing writable (passed
|
|
30
|
+
* through). Defaults to `"mixed"`. */
|
|
32
31
|
export declare function tri(v?: Init<Tri>): Writable<Tri>;
|
|
33
32
|
export {};
|
package/dist/core/values/tri.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// tri.ts — three-valued logical type (Kleene logic).
|
|
2
|
-
//
|
|
3
|
-
// `Tri.value ∈ { true, false, "mixed" }` — Bool plus an unknown state
|
|
4
|
-
// fixed under negation. Strong-Kleene AND/OR follow the partial-info
|
|
5
|
-
// reading (`mixed AND false` → `false`, `mixed AND true` → `mixed`).
|
|
6
1
|
import { Cell, SKIP } from "../cell.js";
|
|
7
2
|
const equals = (a, b) => a === b;
|
|
8
3
|
/** Kleene negation: `true` / `false` swap, `"mixed"` is fixed. */
|
|
@@ -30,14 +25,13 @@ export class Tri extends Cell {
|
|
|
30
25
|
constructor(v = "mixed") {
|
|
31
26
|
super(v, { equals });
|
|
32
27
|
}
|
|
33
|
-
/** Kleene negation.
|
|
28
|
+
/** Kleene negation. */
|
|
34
29
|
not() {
|
|
35
30
|
return this.lens(not, not);
|
|
36
31
|
}
|
|
37
|
-
/**
|
|
38
|
-
* `
|
|
39
|
-
*
|
|
40
|
-
* child, recursing through nested aggregates; `"mixed"` is a no-op. */
|
|
32
|
+
/** AND-aggregate over writable `Bool`/`Tri` children: `true` if all are true,
|
|
33
|
+
* `false` if all false, else `"mixed"`. A `true`/`false` write broadcasts to
|
|
34
|
+
* every child (recursing into nested aggregates); `"mixed"` is a no-op. */
|
|
41
35
|
static allOf(parents) {
|
|
42
36
|
return Tri.lens(parents, (vs) => {
|
|
43
37
|
let anyT = false;
|
|
@@ -59,9 +53,9 @@ export class Tri extends Cell {
|
|
|
59
53
|
return parents.map(() => target);
|
|
60
54
|
});
|
|
61
55
|
}
|
|
62
|
-
/**
|
|
63
|
-
* `
|
|
64
|
-
* `"mixed"
|
|
56
|
+
/** OR-aggregate over writable `Bool`/`Tri` children: `true` if any is true,
|
|
57
|
+
* `false` if all false, else `"mixed"`. A `true`/`false` write broadcasts to
|
|
58
|
+
* every child; `"mixed"` is a no-op. */
|
|
65
59
|
static anyOf(parents) {
|
|
66
60
|
return Tri.lens(parents, (vs) => {
|
|
67
61
|
let anyT = false;
|
|
@@ -86,8 +80,8 @@ export class Tri extends Cell {
|
|
|
86
80
|
});
|
|
87
81
|
}
|
|
88
82
|
}
|
|
89
|
-
/** Writable `Tri
|
|
90
|
-
*
|
|
83
|
+
/** Writable `Tri` from a literal (new cell) or existing writable (passed
|
|
84
|
+
* through). Defaults to `"mixed"`. */
|
|
91
85
|
export function tri(v = "mixed") {
|
|
92
86
|
if (v instanceof Tri)
|
|
93
87
|
return v;
|
|
@@ -21,6 +21,9 @@ export declare const scaleAbout: (v: V, p: V, k: number) => V;
|
|
|
21
21
|
* (y-down screen coords flip the visual sense). Returns `c` if `p` is
|
|
22
22
|
* inside or on the circle. */
|
|
23
23
|
export declare function tangentPoint(p: V, c: V, r: number, side?: 1 | -1): V;
|
|
24
|
+
/** Representative of cyclic angle `target` closest to `current`
|
|
25
|
+
* (shortest-arc inverse). */
|
|
26
|
+
export declare const nearestAngle: (target: number, current: number) => number;
|
|
24
27
|
export declare class Vec extends Cell<V> {
|
|
25
28
|
static traits: {
|
|
26
29
|
linear: Linear<V>;
|
|
@@ -34,11 +37,9 @@ export declare class Vec extends Cell<V> {
|
|
|
34
37
|
constructor(v?: V);
|
|
35
38
|
add(b: Val<V>): this;
|
|
36
39
|
sub(b: Val<V>): this;
|
|
37
|
-
/** Uniform scale by `k` about `pivot` (default origin).
|
|
38
|
-
* by `1/k`; exact bijection for `k ≠ 0`. */
|
|
40
|
+
/** Uniform scale by `k` about `pivot` (default origin). Invertible when k ≠ 0. */
|
|
39
41
|
scale(k: Val<number>, pivot?: Val<V>): this;
|
|
40
|
-
/** Rotate by `angle` (radians) about `pivot` (default origin).
|
|
41
|
-
* rotates by `−angle`; exact bijection. */
|
|
42
|
+
/** Rotate by `angle` (radians) about `pivot` (default origin). */
|
|
42
43
|
rotate(angle: Val<number>, pivot?: Val<V>): this;
|
|
43
44
|
offset(dx: Val<number>, dy: Val<number>): this;
|
|
44
45
|
up(n: Val<number>): this;
|
|
@@ -52,27 +53,11 @@ export declare class Vec extends Cell<V> {
|
|
|
52
53
|
get x(): this extends import("../index.js").WritableBrand ? Writable<Num> : Num;
|
|
53
54
|
get y(): this extends import("../index.js").WritableBrand ? Writable<Num> : Num;
|
|
54
55
|
get magnitude(): Num;
|
|
55
|
-
/** Tween-builder
|
|
56
|
-
* receivers. */
|
|
56
|
+
/** Tween-builder. */
|
|
57
57
|
to(this: Writable<Vec>, target: V, dur: Val<number>, ease?: Easing): Tween<V>;
|
|
58
58
|
}
|
|
59
|
-
/** Writable `Vec` at `(x, y)`. Each axis is a literal
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* reactive RO tracking, or `cell.value` to snapshot. Lock an axis with
|
|
63
|
-
* `Num.pin(c)`: `vec(slider, Num.pin(100))`. */
|
|
59
|
+
/** Writable `Vec` at `(x, y)`. Each axis is a literal (new cell) or existing
|
|
60
|
+
* writable (passed through); for read-only sources use `Vec.derive`. Lock an
|
|
61
|
+
* axis with `Num.pin`: `vec(slider, Num.pin(100))`. */
|
|
64
62
|
export declare function vec(x?: Init<Num>, y?: Init<Num>): Writable<Vec>;
|
|
65
|
-
/** Policy for `polar`'s inverse — which inputs absorb a write:
|
|
66
|
-
*
|
|
67
|
-
* - `rotate` — c fixed; write r and a to land on target.
|
|
68
|
-
* - `translate` — r and a fixed; shift c by Δ.
|
|
69
|
-
* - `radial` — c and a fixed; project the drag onto the ray.
|
|
70
|
-
* - `circular` — c and r fixed; project the drag onto the circle. */
|
|
71
|
-
export type PolarPolicy = "rotate" | "translate" | "radial" | "circular";
|
|
72
|
-
/** Vec at polar offset from `center`: `center + (r·cos a, r·sin a)`.
|
|
73
|
-
* Bidirectional; each input is a literal (lifted to a fresh seed) or an
|
|
74
|
-
* existing writable cell. RO inputs are rejected at the type level.
|
|
75
|
-
* `policy` selects which inputs absorb writes; lock one with
|
|
76
|
-
* `Num.pin(c)`: `polar(c, Num.pin(100), a)`. */
|
|
77
|
-
export declare function polar(center: Init<Vec>, r: Init<Num>, a: Init<Num>, policy?: PolarPolicy): Writable<Vec>;
|
|
78
63
|
export {};
|
package/dist/core/values/vec.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
// vec.ts — reactive 2D point.
|
|
2
|
-
//
|
|
3
|
-
// Invertibles return `: this` and ride on `Cell#lens(fwd, bwd)`;
|
|
4
|
-
// chained calls compose into a lens chain. Field-lens getters use
|
|
5
|
-
// `fieldLens()` (propagates writability); `cachedDerive()` wraps RO views.
|
|
6
1
|
import { tween } from "../../animation/index.js";
|
|
7
|
-
import { Cell, cachedDerive, fieldLens, reader, readNow,
|
|
2
|
+
import { Cell, cachedDerive, fieldLens, reader, readNow, } from "../cell.js";
|
|
8
3
|
import { Num, num } from "./num.js";
|
|
9
4
|
export const add = (a, b) => ({ x: a.x + b.x, y: a.y + b.y });
|
|
10
5
|
export const sub = (a, b) => ({ x: a.x - b.x, y: a.y - b.y });
|
|
@@ -51,7 +46,7 @@ export function tangentPoint(p, c, r, side = -1) {
|
|
|
51
46
|
const wrapToPi = (x) => x - 2 * Math.PI * Math.round(x / (2 * Math.PI));
|
|
52
47
|
/** Representative of cyclic angle `target` closest to `current`
|
|
53
48
|
* (shortest-arc inverse). */
|
|
54
|
-
const nearestAngle = (target, current) => current + wrapToPi(target - current);
|
|
49
|
+
export const nearestAngle = (target, current) => current + wrapToPi(target - current);
|
|
55
50
|
const linearImpl = { add, sub, scale };
|
|
56
51
|
const packImpl = {
|
|
57
52
|
dim: 2,
|
|
@@ -94,8 +89,7 @@ export class Vec extends Cell {
|
|
|
94
89
|
return { x: n.x + o.x, y: n.y + o.y };
|
|
95
90
|
});
|
|
96
91
|
}
|
|
97
|
-
/** Uniform scale by `k` about `pivot` (default origin).
|
|
98
|
-
* by `1/k`; exact bijection for `k ≠ 0`. */
|
|
92
|
+
/** Uniform scale by `k` about `pivot` (default origin). Invertible when k ≠ 0. */
|
|
99
93
|
scale(k, pivot) {
|
|
100
94
|
const kf = reader(k);
|
|
101
95
|
const pf = pivot === undefined ? undefined : reader(pivot);
|
|
@@ -107,8 +101,7 @@ export class Vec extends Cell {
|
|
|
107
101
|
return pf ? scaleAbout(n, pf(), 1 / k) : { x: n.x / k, y: n.y / k };
|
|
108
102
|
});
|
|
109
103
|
}
|
|
110
|
-
/** Rotate by `angle` (radians) about `pivot` (default origin).
|
|
111
|
-
* rotates by `−angle`; exact bijection. */
|
|
104
|
+
/** Rotate by `angle` (radians) about `pivot` (default origin). */
|
|
112
105
|
rotate(angle, pivot = ORIGIN) {
|
|
113
106
|
const af = reader(angle);
|
|
114
107
|
const pf = reader(pivot);
|
|
@@ -119,7 +112,6 @@ export class Vec extends Cell {
|
|
|
119
112
|
const yf = reader(dy);
|
|
120
113
|
return this.lens(v => ({ x: v.x + xf(), y: v.y + yf() }), n => ({ x: n.x - xf(), y: n.y - yf() }));
|
|
121
114
|
}
|
|
122
|
-
// Axis-aligned offset sugar — same fwd/bwd shape as offset.
|
|
123
115
|
up(n) {
|
|
124
116
|
const f = reader(n);
|
|
125
117
|
return this.lens(v => ({ x: v.x, y: v.y - f() }), o => ({ x: o.x, y: o.y + f() }));
|
|
@@ -157,68 +149,21 @@ export class Vec extends Cell {
|
|
|
157
149
|
get magnitude() {
|
|
158
150
|
return cachedDerive(this, "magnitude", Num, v => Math.hypot(v.x, v.y));
|
|
159
151
|
}
|
|
160
|
-
/** Tween-builder
|
|
161
|
-
* receivers. */
|
|
152
|
+
/** Tween-builder. */
|
|
162
153
|
to(target, dur, ease) {
|
|
163
154
|
return tween(this, target, dur, ease);
|
|
164
155
|
}
|
|
165
156
|
}
|
|
166
|
-
/**
|
|
167
|
-
* here after lifting literals. */
|
|
157
|
+
/** Lens combining two writable `Num`s into a `Vec`. */
|
|
168
158
|
function axes(x, y) {
|
|
169
|
-
// The view fully reconstructs both axes (1-arg bwd ⇒ no source read).
|
|
170
159
|
return Vec.lens([x, y], ([xv, yv]) => ({ x: xv, y: yv }), v => [v.x, v.y]);
|
|
171
160
|
}
|
|
172
|
-
/** Writable `Vec` at `(x, y)`. Each axis is a literal
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* reactive RO tracking, or `cell.value` to snapshot. Lock an axis with
|
|
176
|
-
* `Num.pin(c)`: `vec(slider, Num.pin(100))`. */
|
|
161
|
+
/** Writable `Vec` at `(x, y)`. Each axis is a literal (new cell) or existing
|
|
162
|
+
* writable (passed through); for read-only sources use `Vec.derive`. Lock an
|
|
163
|
+
* axis with `Num.pin`: `vec(slider, Num.pin(100))`. */
|
|
177
164
|
export function vec(x = 0, y = 0) {
|
|
178
165
|
if (typeof x === "number" && typeof y === "number") {
|
|
179
166
|
return new Vec({ x, y });
|
|
180
167
|
}
|
|
181
168
|
return axes(num(x), num(y));
|
|
182
169
|
}
|
|
183
|
-
/** Vec at polar offset from `center`: `center + (r·cos a, r·sin a)`.
|
|
184
|
-
* Bidirectional; each input is a literal (lifted to a fresh seed) or an
|
|
185
|
-
* existing writable cell. RO inputs are rejected at the type level.
|
|
186
|
-
* `policy` selects which inputs absorb writes; lock one with
|
|
187
|
-
* `Num.pin(c)`: `polar(c, Num.pin(100), a)`. */
|
|
188
|
-
export function polar(center, r, a, policy = "rotate") {
|
|
189
|
-
// Lift literals; already-writable inputs pass through by identity.
|
|
190
|
-
const cSig = center instanceof Vec ? center : vec(center.x, center.y);
|
|
191
|
-
const rSig = num(r);
|
|
192
|
-
const aSig = num(a);
|
|
193
|
-
const project = (c, rv, av) => ({
|
|
194
|
-
x: c.x + rv * Math.cos(av),
|
|
195
|
-
y: c.y + rv * Math.sin(av),
|
|
196
|
-
});
|
|
197
|
-
let bwd;
|
|
198
|
-
switch (policy) {
|
|
199
|
-
case "rotate":
|
|
200
|
-
bwd = (p, [cv, , av]) => {
|
|
201
|
-
const dx = p.x - cv.x;
|
|
202
|
-
const dy = p.y - cv.y;
|
|
203
|
-
return [SKIP, Math.hypot(dx, dy), nearestAngle(Math.atan2(dy, dx), av)];
|
|
204
|
-
};
|
|
205
|
-
break;
|
|
206
|
-
case "translate":
|
|
207
|
-
bwd = (p, [cv, rv, av]) => {
|
|
208
|
-
const f = project(cv, rv, av);
|
|
209
|
-
return [{ x: cv.x + (p.x - f.x), y: cv.y + (p.y - f.y) }, SKIP, SKIP];
|
|
210
|
-
};
|
|
211
|
-
break;
|
|
212
|
-
case "radial":
|
|
213
|
-
bwd = (p, [cv, , av]) => {
|
|
214
|
-
const dx = p.x - cv.x;
|
|
215
|
-
const dy = p.y - cv.y;
|
|
216
|
-
return [SKIP, dx * Math.cos(av) + dy * Math.sin(av), SKIP];
|
|
217
|
-
};
|
|
218
|
-
break;
|
|
219
|
-
case "circular":
|
|
220
|
-
bwd = (p, [cv, , av]) => [SKIP, SKIP, nearestAngle(Math.atan2(p.y - cv.y, p.x - cv.x), av)];
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
return Vec.lens([cSig, rSig, aSig], ([c, rv, av]) => project(c, rv, av), bwd);
|
|
224
|
-
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
/** @group Reactivity */
|
|
2
|
-
/** @group Animation */
|
|
3
1
|
export * from "./animation/index.js";
|
|
4
|
-
/** @group Utilities */
|
|
5
2
|
export * from "./assert/index.js";
|
|
6
|
-
/** @group Rendering */
|
|
7
3
|
export { type CodeOpts, CodeShape, code, codeStyles, type Token, tokenize } from "./code/index.js";
|
|
8
|
-
/** @group Utilities */
|
|
9
|
-
export * from "./coll.js";
|
|
10
4
|
export * from "./core/index.js";
|
|
11
|
-
/** @group Utilities */
|
|
12
5
|
export * from "./ext/index.js";
|
|
13
|
-
/** @group Shapes */
|
|
14
6
|
export * from "./shapes/index.js";
|
|
15
|
-
/** @group Rendering */
|
|
16
7
|
export * from "./tex/index.js";
|
|
17
|
-
/** @group Utilities */
|
|
18
8
|
export { allNodes, atPath, isLeaf, leavesOf, node as treeNode, nodeCount, type TreeNode, walkTree, } from "./tree.js";
|
|
19
|
-
/** @group Web */
|
|
20
9
|
export * from "./web/index.js";
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
/** @group Animation */
|
|
1
|
+
// API-reference groups are assigned by source folder in theme/group-by-source.mjs.
|
|
3
2
|
export * from "./animation/index.js";
|
|
4
|
-
/** @group Utilities */
|
|
5
3
|
export * from "./assert/index.js";
|
|
6
4
|
// `code` and `tex` both export `Part`; re-export `code`'s other symbols
|
|
7
5
|
// explicitly so the wildcard below lets `tex`'s `Part` win.
|
|
8
|
-
/** @group Rendering */
|
|
9
6
|
export { CodeShape, code, codeStyles, tokenize } from "./code/index.js";
|
|
10
|
-
/** @group Utilities */
|
|
11
|
-
export * from "./coll.js";
|
|
12
7
|
export * from "./core/index.js";
|
|
13
|
-
/** @group Utilities */
|
|
14
8
|
export * from "./ext/index.js";
|
|
15
|
-
/** @group Shapes */
|
|
16
9
|
export * from "./shapes/index.js";
|
|
17
|
-
/** @group Rendering */
|
|
18
10
|
export * from "./tex/index.js";
|
|
19
|
-
/** @group Utilities */
|
|
20
11
|
export { allNodes, atPath, isLeaf, leavesOf, node as treeNode, nodeCount, walkTree, } from "./tree.js";
|
|
21
|
-
/** @group Web */
|
|
22
12
|
export * from "./web/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bireactive",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Bi-directional reactive programming.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
35
|
"dev": "vite --host",
|
|
36
|
-
"site": "vite build && typedoc
|
|
37
|
-
"docs": "typedoc
|
|
38
|
-
"docs:dev": "typedoc
|
|
36
|
+
"site": "vite build && typedoc",
|
|
37
|
+
"docs": "typedoc",
|
|
38
|
+
"docs:dev": "typedoc --watch",
|
|
39
|
+
"docs:preview": "python3 -m http.server 5556 --directory dist-web/api",
|
|
39
40
|
"preview": "vite preview",
|
|
40
41
|
"prebuild": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
41
42
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths",
|
|
@@ -52,16 +53,25 @@
|
|
|
52
53
|
"postversion": "npm publish && git push --follow-tags"
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
55
|
-
"@automerge/automerge-repo": "^2.6.0-subduction.34",
|
|
56
|
-
"@automerge/automerge-repo-network-broadcastchannel": "^2.6.0-subduction.34",
|
|
57
|
-
"@automerge/automerge-repo-storage-indexeddb": "^2.6.0-subduction.34",
|
|
58
56
|
"prism-esm": "^1.29.0-fix.6",
|
|
59
57
|
"temml": "^0.13.3"
|
|
60
58
|
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@automerge/automerge-repo": "^2.6.0-subduction.34"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@automerge/automerge-repo": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
61
67
|
"devDependencies": {
|
|
68
|
+
"@automerge/automerge-repo": "^2.6.0-subduction.34",
|
|
69
|
+
"@automerge/automerge-repo-network-broadcastchannel": "^2.6.0-subduction.34",
|
|
70
|
+
"@automerge/automerge-repo-storage-indexeddb": "^2.6.0-subduction.34",
|
|
62
71
|
"@biomejs/biome": "2.4.15",
|
|
63
72
|
"@preact/signals-core": "^1.14.2",
|
|
64
73
|
"@types/node": "^22.0.0",
|
|
74
|
+
"@typhonjs-typedoc/typedoc-theme-dmt": "^0.4.0",
|
|
65
75
|
"alien-signals": "^3.2.1",
|
|
66
76
|
"fast-check": "^4.8.0",
|
|
67
77
|
"gray-matter": "^4.0.3",
|
|
@@ -71,14 +81,11 @@
|
|
|
71
81
|
"reactive-framework-test-suite": "^0.0.2",
|
|
72
82
|
"tsc-alias": "^1.8.17",
|
|
73
83
|
"typedoc": "^0.28.19",
|
|
74
|
-
"typedoc-plugin-markdown": "^4.12.0",
|
|
75
|
-
"typedoc-vitepress-theme": "^1.1.3",
|
|
76
84
|
"typescript": "^6.0.3",
|
|
77
85
|
"vite": "^7.3.3",
|
|
78
86
|
"vite-node": "^5.3.0",
|
|
79
87
|
"vite-plugin-top-level-await": "^1.6.0",
|
|
80
88
|
"vite-plugin-wasm": "^3.6.0",
|
|
81
|
-
"vitepress": "^1.6.4",
|
|
82
89
|
"vitest": "^4.1.7"
|
|
83
90
|
},
|
|
84
91
|
"keywords": [
|
package/dist/coll.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { type Cell, type Read, type Writable } from "./core/index.js";
|
|
2
|
-
/** Accessor for an element's writable field cell. Forward reads `.value`;
|
|
3
|
-
* the backward pass writes it. */
|
|
4
|
-
export type Accessor<E, V> = (e: E) => Writable<Cell<V>>;
|
|
5
|
-
/** A forward test over an element's fields, optionally assertable —
|
|
6
|
-
* `assert(e)` makes the test pass by writing fields. */
|
|
7
|
-
export interface FieldPred<E> {
|
|
8
|
-
(e: E): boolean;
|
|
9
|
-
assert?: (e: E) => void;
|
|
10
|
-
}
|
|
11
|
-
export interface Group<K, E> {
|
|
12
|
-
key: K;
|
|
13
|
-
items: readonly E[];
|
|
14
|
-
}
|
|
15
|
-
export interface GroupOpts<E, K> {
|
|
16
|
-
/** Fixed key order; seeds empty buckets and pins column order. */
|
|
17
|
-
order?: readonly K[];
|
|
18
|
-
/** Order field within each group; enables `move(e, key, index)`. */
|
|
19
|
-
sort?: Accessor<E, number>;
|
|
20
|
-
}
|
|
21
|
-
/** `field === value`, assertable by writing the field. */
|
|
22
|
-
export declare function is<E, V>(field: Accessor<E, V>, value: V): FieldPred<E>;
|
|
23
|
-
/** Conjunction; asserts every clause. */
|
|
24
|
-
export declare function allPass<E>(...preds: readonly FieldPred<E>[]): FieldPred<E>;
|
|
25
|
-
/** Read-only projection with chainable structural lenses. */
|
|
26
|
-
export declare class View<E> {
|
|
27
|
-
protected readonly list: Read<readonly E[]>;
|
|
28
|
-
readonly key: (e: E) => unknown;
|
|
29
|
-
protected readonly parent: View<E> | null;
|
|
30
|
-
protected constructor(list: Read<readonly E[]>, key: (e: E) => unknown, parent: View<E> | null);
|
|
31
|
-
/** Current members; tracked when read in an effect/derive. */
|
|
32
|
-
get items(): readonly E[];
|
|
33
|
-
/** The source collection at the head of the chain. */
|
|
34
|
-
get root(): Coll<E>;
|
|
35
|
-
/** Make `e` appear in this view: satisfy own constraint, recursively up. */
|
|
36
|
-
assertContains(e: E): void;
|
|
37
|
-
protected assertSelf(_e: E): void;
|
|
38
|
-
filter(pred: FieldPred<E>): View<E>;
|
|
39
|
-
sortBy(field: Accessor<E, number>): SortView<E>;
|
|
40
|
-
groupBy<K>(field: Accessor<E, K>, opts?: GroupOpts<E, K>): GroupView<K, E>;
|
|
41
|
-
map<F>(f: (e: E) => F): Read<readonly F[]>;
|
|
42
|
-
/** Remove `e` from the source. */
|
|
43
|
-
remove(e: E): void;
|
|
44
|
-
}
|
|
45
|
-
/** A writable source collection. */
|
|
46
|
-
export declare class Coll<E> extends View<E> {
|
|
47
|
-
#private;
|
|
48
|
-
constructor(items: readonly E[], key: (e: E) => unknown);
|
|
49
|
-
assertContains(e: E): void;
|
|
50
|
-
insert(e: E, at?: number): void;
|
|
51
|
-
removeFromSource(e: E): void;
|
|
52
|
-
}
|
|
53
|
-
/** Sorted view. `move` writes the order field between the drop neighbours. */
|
|
54
|
-
export declare class SortView<E> extends View<E> {
|
|
55
|
-
#private;
|
|
56
|
-
constructor(parent: View<E>, field: Accessor<E, number>);
|
|
57
|
-
move(e: E, to: number): void;
|
|
58
|
-
}
|
|
59
|
-
/** Grouped view. `move`/`insert` write the group field (and, with a `sort`
|
|
60
|
-
* field, the order field). Backward composition runs the parent chain. */
|
|
61
|
-
export declare class GroupView<K, E> {
|
|
62
|
-
#private;
|
|
63
|
-
readonly groups: Read<readonly Group<K, E>[]>;
|
|
64
|
-
constructor(parent: View<E>, field: Accessor<E, K>, opts?: GroupOpts<E, K>);
|
|
65
|
-
get value(): readonly Group<K, E>[];
|
|
66
|
-
map<F>(f: (g: Group<K, E>) => F): Read<readonly F[]>;
|
|
67
|
-
/** Place `e` in group `toKey` at `index`. Inserts it into the source if
|
|
68
|
-
* it isn't there yet, asserts every upstream filter, then writes the
|
|
69
|
-
* group key and order field — all in one batch. */
|
|
70
|
-
move(e: E, toKey: K, index?: number): void;
|
|
71
|
-
insert(e: E, toKey: K, index?: number): void;
|
|
72
|
-
remove(e: E): void;
|
|
73
|
-
}
|
|
74
|
-
export declare function coll<E>(items: readonly E[], key: (e: E) => unknown): Coll<E>;
|