glassbrain 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +236 -2
- package/dist/adapters/common.d.ts +51 -0
- package/dist/adapters/graphify.d.ts +51 -0
- package/dist/adapters/index.d.ts +24 -0
- package/dist/adapters/memory.d.ts +7 -0
- package/dist/adapters/obsidian.d.ts +18 -0
- package/dist/adapters/understand.d.ts +70 -0
- package/dist/adapters.js +492 -0
- package/dist/animate.d.ts +312 -0
- package/dist/chunks/chunk-37BAJC3L.js +234 -0
- package/dist/chunks/chunk-3CNKH3HB.js +5226 -0
- package/dist/chunks/chunk-EJURBBFC.js +92 -0
- package/dist/chunks/chunk-LEYJCT6O.js +0 -0
- package/dist/chunks/chunk-SA6RSWZP.js +0 -0
- package/dist/chunks/chunk-UJCALP4P.js +2283 -0
- package/dist/chunks/chunk-YGRPNAXE.js +95 -0
- package/dist/chunks/chunk-ZA47FP7C.js +7 -0
- package/dist/cli/glassbrain.js +1491 -0
- package/dist/cli/viewer.js +851 -0
- package/dist/core.d.ts +10 -0
- package/dist/core.js +148 -0
- package/dist/diff.d.ts +156 -0
- package/dist/edit.d.ts +58 -0
- package/dist/elements.d.ts +57 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +175 -0
- package/dist/internal.d.ts +7 -0
- package/dist/internal.js +287 -0
- package/dist/layout/diff-layout.d.ts +92 -0
- package/dist/layout/divide.d.ts +61 -0
- package/dist/layout/engine.d.ts +63 -0
- package/dist/layout/inline-pool.d.ts +2 -0
- package/dist/layout/inline-pool.js +7 -0
- package/dist/layout/planes.d.ts +39 -0
- package/dist/layout/presets.d.ts +5 -0
- package/dist/layout/readability.d.ts +65 -0
- package/dist/layout/relax.d.ts +19 -0
- package/dist/layout/run-job.d.ts +30 -0
- package/dist/layout/worker-pool.d.ts +2 -0
- package/dist/layout/worker-pool.js +17 -0
- package/dist/layout/worker.d.ts +1 -0
- package/dist/layout/worker.js +87 -0
- package/dist/model.d.ts +92 -0
- package/dist/paint.d.ts +94 -0
- package/dist/profile.d.ts +133 -0
- package/dist/react/DetailPanel.d.ts +29 -0
- package/dist/react/DetailPanel.js +10 -0
- package/dist/react/DiffOverlay.d.ts +59 -0
- package/dist/react/EditPanel.d.ts +30 -0
- package/dist/react/GraphCanvas.d.ts +208 -0
- package/dist/react/GraphCanvas.js +13 -0
- package/dist/react/Legend.d.ts +47 -0
- package/dist/react/Toolbar.d.ts +48 -0
- package/dist/react/camera.d.ts +29 -0
- package/dist/react/i18n.d.ts +3 -0
- package/dist/react/icons.d.ts +20 -0
- package/dist/react/markdown.d.ts +11 -0
- package/dist/strings.d.ts +84 -0
- package/dist/style.d.ts +138 -0
- package/dist/view.d.ts +69 -0
- package/package.json +110 -4
- package/schema/graph.schema.json +54 -0
- package/schema/profile.schema.json +59 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { type GraphDelta } from './diff.js';
|
|
2
|
+
import type { GraphModel } from './model.js';
|
|
3
|
+
import type { GraphProfile } from './profile.js';
|
|
4
|
+
import type { Positions } from './layout/planes.js';
|
|
5
|
+
export interface AnimateSpec {
|
|
6
|
+
/** How long **a whole scene** plays, in ms. Default 1800: the storyboard has seven beats with overlapping ends and does not fit
|
|
7
|
+
* the old 700; and this scene is for people to see "how much was removed vs added", not a transition effect, so too fast is just a
|
|
8
|
+
* blur. Set by dragging a slider.
|
|
9
|
+
*
|
|
10
|
+
* **Beats this step does not have take no time**: a reskin-only / growth-only step actually plays `duration × score.span`
|
|
11
|
+
* ≈ 648 ms, and each of its beats takes **exactly** as many ms as in the full storyboard. See `makeScore`. */
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** The curve of **the "move" beat**. Default easeInOutCubic: move does not start at frame 0
|
|
14
|
+
* (the leaves drift for a while first), and without ease-in it would shoot off from nowhere. Other beats have their own curves, see BEATS. */
|
|
15
|
+
easing?: (t: number) => number;
|
|
16
|
+
/** How far leaves drift, **as a fraction of the whole graph's span**. 0 = no drift, just fade. Default 0.08 (8% of the span).
|
|
17
|
+
*
|
|
18
|
+
* **Keep it small.** This beat should stress "the tip was cut", not "it exploded": a lock of hair falling scatters
|
|
19
|
+
* a short distance and still looks like the same lock. Drifting far hides the cut instead.
|
|
20
|
+
*
|
|
21
|
+
* The unit can only be "a fraction of the picture": the camera frames the graph, so a few percent of the span = a few percent
|
|
22
|
+
* of the screen, for any graph at any zoom. A version based on "my distance to my parent" did not work:
|
|
23
|
+
* that distance varies by two orders of magnitude in one graph (a leaf hugging its parent 140, a top level under the virtual root 2400);
|
|
24
|
+
* the near ones drifted 60 units while following their parent over a thousand, completely drowned.
|
|
25
|
+
* Each fragment varies ±30% around this value, so it is an average, not a fixed amount.
|
|
26
|
+
*
|
|
27
|
+
* The exact number can only be set with a slider: 8% is the line between "you can tell something fell off" and "it exploded". */
|
|
28
|
+
drift?: number;
|
|
29
|
+
/** Sprout overshoot (the easeOutBack coefficient). 0 = no bounce, reduces to easeOutCubic. Default 0.6:
|
|
30
|
+
* about 1.3% past the mark. **The point is "it came alive", not a spring.** */
|
|
31
|
+
bounce?: number;
|
|
32
|
+
/** Above this many union elements, land directly without playing: during motion every frame redraws the whole layer,
|
|
33
|
+
* and on large graphs it only shows a dropped-frame smear; better clean and quick. Default 3000. */
|
|
34
|
+
maxNodes?: number;
|
|
35
|
+
}
|
|
36
|
+
export declare const easeOutCubic: (t: number) => number;
|
|
37
|
+
export declare const easeInOutCubic: (t: number) => number;
|
|
38
|
+
/** Overshoot. With `s = 0` it **reduces exactly to easeOutCubic**, so "no bounce" is not a separate branch. */
|
|
39
|
+
export declare const easeOutBack: (s: number) => (t: number) => number;
|
|
40
|
+
/**
|
|
41
|
+
* Drift: **drift at a steady speed**.
|
|
42
|
+
*
|
|
43
|
+
* The impulse of "being cut" is already played by the `snap` beat on its own (spring off a short way + dim a notch), so this
|
|
44
|
+
* curve only handles the long drift after it: nearly linear, **with non-zero final speed**. That is a hard requirement:
|
|
45
|
+
* easeOutCubic finishes the motion in the first 20%, and for the rest the fragment "stops there and fades", which looks no
|
|
46
|
+
* different from fading in place.
|
|
47
|
+
*/
|
|
48
|
+
export declare const easeDrift: (t: number) => number;
|
|
49
|
+
export declare const DEFAULT_ANIMATE: Required<AnimateSpec>;
|
|
50
|
+
export declare function resolveSpec(a: boolean | AnimateSpec | undefined): Required<AnimateSpec> | null;
|
|
51
|
+
export type TrackName = 'cut' | 'snap' | 'leaf' | 'move' | 'present' | 'sprout' | 'graft' | 'open' | 'close';
|
|
52
|
+
export declare const TRACK_NAMES: TrackName[];
|
|
53
|
+
export interface Track {
|
|
54
|
+
from: number;
|
|
55
|
+
to: number;
|
|
56
|
+
/** How to move within the window. **Opacity takes no curve** (see ENVELOPES); only position and camera do. */
|
|
57
|
+
ease: (t: number) => number;
|
|
58
|
+
}
|
|
59
|
+
/** The storyboard + **how much of the timeline it actually uses**. */
|
|
60
|
+
export type Score = Record<TrackName, Track> & {
|
|
61
|
+
/** What remains after trimming the empty start (0–1). **Multiply the wall-clock duration by it.** See `makeScore`. */
|
|
62
|
+
span: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* A track's linear progress at time t (clamped to 0/1 outside the window).
|
|
66
|
+
*
|
|
67
|
+
* **Zero width = this beat does not happen**, not "finishes instantly". Zero width has one source: trimming empty beats pushed
|
|
68
|
+
* the whole window before lead (this switch has no such content). It used to divide by a 1e-6 floor, so it saturated to 1 on the first frame.
|
|
69
|
+
* Content tracks did not care (those groups were empty anyway), **but the camera eats the same number**: in a reskin-only step
|
|
70
|
+
* "open" was trimmed to zero width, so the camera teleported to the union framing on frame 1 and spent the whole scene drifting back. Frame 0
|
|
71
|
+
* was continuous, frame 1 jumped.
|
|
72
|
+
*/
|
|
73
|
+
export declare const trackLin: (tr: Track, t: number) => number;
|
|
74
|
+
/**
|
|
75
|
+
* A track's progress at time t (through its curve).
|
|
76
|
+
*
|
|
77
|
+
* **Both ends pinned.** Curves leave floating-point residue at 0/1: `easeOutBack(0.6)` at 0 is
|
|
78
|
+
* `-1.1e-16`, which times a displacement is "frame 0 moved a hair". "Frame 0 is identical to the previous frame" must hold **exactly**,
|
|
79
|
+
* not approximately; pinning it here makes it count for every curve, current and future.
|
|
80
|
+
*/
|
|
81
|
+
export declare const trackAt: (tr: Track, t: number) => number;
|
|
82
|
+
/** One envelope. The increment is "how much opacity changes once this track finishes". */
|
|
83
|
+
export interface Envelope {
|
|
84
|
+
base: number;
|
|
85
|
+
legs: {
|
|
86
|
+
track: TrackName;
|
|
87
|
+
d: number;
|
|
88
|
+
}[];
|
|
89
|
+
}
|
|
90
|
+
/** How much the cut piece dims during the "snap" beat. **The rest is left for the leaf to fade slowly.**
|
|
91
|
+
* Fading evenly to nothing from the start leaves no trace of the "break" in opacity; dropping a notch first and then fading
|
|
92
|
+
* slowly gives the cut its weight. */
|
|
93
|
+
export declare const SNAP_DIM = 0.4;
|
|
94
|
+
export type FadeName = 'cut' | 'out' | 'in' | 'graft';
|
|
95
|
+
export declare const FADE_NAMES: FadeName[];
|
|
96
|
+
export declare const ENVELOPES: Record<FadeName, Envelope>;
|
|
97
|
+
/** An element's situation in this switch. */
|
|
98
|
+
export type EndState = 'gone' | 'new' | 'stay';
|
|
99
|
+
/**
|
|
100
|
+
* **Which envelope an edge belongs to.** Only the situation at both ends and its own mark matter; it knows nothing about "containment edges".
|
|
101
|
+
*
|
|
102
|
+
* One axiom is enough: **additions grow, removals drift; and an edge is defined by its ends, change one and it is another edge.**
|
|
103
|
+
* (So "moved to another branch" is an old containment edge removed + a new one added, emitted honestly by `buildElements`,
|
|
104
|
+
* and here it is exactly like any other added or removed edge.)
|
|
105
|
+
*
|
|
106
|
+
* The rest is only computing what "follow both ends" means. **An edge has no position of its own**: it can only be drawn between its ends,
|
|
107
|
+
* so:
|
|
108
|
+
*
|
|
109
|
+
* ends share a fate → follow them: the whole piece drifts together (out) / grows along with the new branch (in), length unchanged throughout
|
|
110
|
+
* ends differ in fate → cannot follow, can only break; so it shows up during the time **when neither end moves**
|
|
111
|
+
*
|
|
112
|
+
* Start and end look asymmetric (leavers rush at the start, arrivals wait for the end), but it is one criterion: **the past side
|
|
113
|
+
* still has to move, the future side has already stopped.** A leaving edge's living end is about to go to its new position (move
|
|
114
|
+
* 22–74%); if it does not break cleanly before that it gets pulled into a thread across the whole graph. An entering edge's old end has
|
|
115
|
+
* long been in place, so it can wait, and connects once motion stops (86–100%).
|
|
116
|
+
*
|
|
117
|
+
* This is also the final answer to "should a transparent node pin the edge": **no.** The stretched length comes from **the living
|
|
118
|
+
* end**, so pinning the dying end is useless; avoiding the stretch would mean pinning both ends, which is a frozen copy of the old graph,
|
|
119
|
+
* exactly back to "interpolating between two coordinate sets", which the union exists to eliminate. Use timing, not compensation.
|
|
120
|
+
*/
|
|
121
|
+
export declare function edgeFade(from: EndState, to: EndState, flag: 'added' | 'removed' | null): FadeName | null;
|
|
122
|
+
/** Opacity at time 0: all bases, **needing neither a storyboard nor coordinates**.
|
|
123
|
+
*
|
|
124
|
+
* So the four groups can be written the moment the union mounts, without waiting for layout. This is where "frame 0 = previous frame"
|
|
125
|
+
* turns from a rule into a consequence: the bases of `in` and `graft` are 0, so new things are invisible before layout has even
|
|
126
|
+
* given them a position. */
|
|
127
|
+
export declare const FADE_BASE: Record<FadeName, number>;
|
|
128
|
+
/** An envelope's value at time t. **Takes only the window's linear progress, not the curve**: easing an opacity makes
|
|
129
|
+
* it linger and then suddenly drop. For "drop a notch, then fade slowly" add another leg instead of bending a curve. */
|
|
130
|
+
export declare const fadeAt: (name: FadeName, sc: Score, t: number) => number;
|
|
131
|
+
/**
|
|
132
|
+
* Build a storyboard.
|
|
133
|
+
*
|
|
134
|
+
* **Empty beats leave no gap, and the rest must not be stretched.** If this switch has no leaves and no motion, "present" should not
|
|
135
|
+
* wait until 64% to start: trim the empty start (shift windows forward, renormalize to [0,1]) **and multiply the wall-clock duration by
|
|
136
|
+
* `span`**. The two scalings cancel exactly, so:
|
|
137
|
+
*
|
|
138
|
+
* **How long a beat plays does not depend on how many beats this step has.**
|
|
139
|
+
*
|
|
140
|
+
* It used to only shift forward: the remainder was stretched back to [0,1] with the duration unchanged, so a "content only" step slowed
|
|
141
|
+
* the present beat by 2.78× and still played the full 1800 ms. What the audience waited for was not an empty beat but a stretched one.
|
|
142
|
+
*
|
|
143
|
+
* (The tail is not trimmed: the camera always closes there.)
|
|
144
|
+
*/
|
|
145
|
+
export declare function makeScore(spec: Required<AnimateSpec>, active?: {
|
|
146
|
+
leaf?: boolean;
|
|
147
|
+
move?: boolean;
|
|
148
|
+
present?: boolean;
|
|
149
|
+
}): Score;
|
|
150
|
+
/**
|
|
151
|
+
* How many edges enter and leave in a delta, under either vocabulary (`diffModels` or `stepUnion`).
|
|
152
|
+
*
|
|
153
|
+
* `changes` only lists nodes, so a step that only links (no node added, removed or changed) has an empty `changes` and
|
|
154
|
+
* still has everything to show. "Nothing changed" has to ask the edges too.
|
|
155
|
+
*/
|
|
156
|
+
export declare function edgeTraffic(delta: GraphDelta): {
|
|
157
|
+
in: number;
|
|
158
|
+
out: number;
|
|
159
|
+
};
|
|
160
|
+
/** One leg: how far this track has pushed this element once the track finishes. */
|
|
161
|
+
export interface Leg {
|
|
162
|
+
track: TrackName;
|
|
163
|
+
dx: number;
|
|
164
|
+
dy: number;
|
|
165
|
+
}
|
|
166
|
+
export interface TransitionItem {
|
|
167
|
+
id: string;
|
|
168
|
+
/** Base (position at time 0). **Always where it was in the previous frame**, no exceptions. */
|
|
169
|
+
x: number;
|
|
170
|
+
y: number;
|
|
171
|
+
/** Additive displacement components. Empty = no motion at all, only opacity changes. */
|
|
172
|
+
legs: Leg[];
|
|
173
|
+
}
|
|
174
|
+
/** Reskin: the same thing looks different in the two versions. */
|
|
175
|
+
export interface SkinChange {
|
|
176
|
+
id: string;
|
|
177
|
+
/** The previous version's class string. */
|
|
178
|
+
past: string;
|
|
179
|
+
/** This version's class string. */
|
|
180
|
+
now: string;
|
|
181
|
+
}
|
|
182
|
+
/** A computed style (property → value). Values are exactly what the renderer gives; nothing is assumed about them. */
|
|
183
|
+
export type StyleMap = Record<string, string | number>;
|
|
184
|
+
/** One interpolatable property. Colors interpolate per component, numbers linearly; nothing else gets in here. */
|
|
185
|
+
export interface StyleTween {
|
|
186
|
+
prop: string;
|
|
187
|
+
from: number[];
|
|
188
|
+
to: number[];
|
|
189
|
+
/** true = these four numbers are rgba and go back into `rgba(...)`; false = a single number. */
|
|
190
|
+
color: boolean;
|
|
191
|
+
}
|
|
192
|
+
/** The look properties that change node size: the canvas removes them before measuring. */
|
|
193
|
+
export declare const SKIN_SIZE_PROPS: string[];
|
|
194
|
+
/**
|
|
195
|
+
* The difference of two computed styles → one tween + a set of hard cuts.
|
|
196
|
+
*
|
|
197
|
+
* **The core knows no specific color.** It asks two questions only: is this property the same in both versions? If not,
|
|
198
|
+
* can these two values have an in-between? If yes (colors, numbers), interpolate; if not (`dashed`→`solid`, shapes and other
|
|
199
|
+
* enums with no in-between), switch at that moment. So any profile, any palette, any style property added later
|
|
200
|
+
* takes this path automatically, with nothing to register in advance.
|
|
201
|
+
*/
|
|
202
|
+
export declare function diffSkinStyle(past: StyleMap, now: StyleMap): {
|
|
203
|
+
tween: StyleTween[];
|
|
204
|
+
steps: StyleMap;
|
|
205
|
+
};
|
|
206
|
+
/** One frame of the tween. Progress is the "enter" envelope: new things appearing and the old skin becoming new are the same number. */
|
|
207
|
+
export declare function sampleSkinStyle(tween: StyleTween[], p: number): StyleMap;
|
|
208
|
+
export interface Transition {
|
|
209
|
+
items: TransitionItem[];
|
|
210
|
+
/** This switch's storyboard: which track runs when and on which curve. */
|
|
211
|
+
score: Score;
|
|
212
|
+
/** Look channel: old skin → new skin, progress is the "present" envelope. */
|
|
213
|
+
skins: SkinChange[];
|
|
214
|
+
/** Ids of elements leaving: the canvas tucks them away after the scene. */
|
|
215
|
+
leaving: Set<string>;
|
|
216
|
+
/** Whether anything is worth playing. When false the caller lands directly. */
|
|
217
|
+
worth: boolean;
|
|
218
|
+
/** Readings for logs / tests. */
|
|
219
|
+
report: TransitionReport;
|
|
220
|
+
}
|
|
221
|
+
export interface TransitionReport {
|
|
222
|
+
/** How many elements in the union take part. */
|
|
223
|
+
total: number;
|
|
224
|
+
/** Ones whose position actually changes (kept/changed moved by the union layout) */
|
|
225
|
+
moved: number;
|
|
226
|
+
/** The **median** of those moves (graph coordinates). A count alone lies: after a seeded re-solve every node settles
|
|
227
|
+
* slightly, so `moved` equals everyone while things only moved a few units. To judge "did it actually move",
|
|
228
|
+
* look at this number, not that count. */
|
|
229
|
+
movedMedian: number;
|
|
230
|
+
entering: number;
|
|
231
|
+
leaving: number;
|
|
232
|
+
/** Moved to another branch */
|
|
233
|
+
relocated: number;
|
|
234
|
+
/** Merged and converging */
|
|
235
|
+
converging: number;
|
|
236
|
+
/** Reskinned (same position, same presence, but looks different) */
|
|
237
|
+
restyled: number;
|
|
238
|
+
/** How many **pieces** the leavers form: a piece drifts as a whole, so this counts "pieces cut off", not nodes. */
|
|
239
|
+
pieces: number;
|
|
240
|
+
/** Added / removed **edges**. A step that only adds edges and moves no node is common (typically the linking beat);
|
|
241
|
+
* not counting them would judge it "nothing to play", while that step has nothing but edges to see. */
|
|
242
|
+
edgesIn: number;
|
|
243
|
+
edgesOut: number;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* **Where it grows from**: up the parent chain, the first ancestor "present in the previous frame".
|
|
247
|
+
*
|
|
248
|
+
* Mount seating (where the canvas puts new elements the moment it mounts the union) and the "sprout" base use **the same
|
|
249
|
+
* function**: both places give the same number, so "mount frame = sample 0" is a fact by construction, not a convention written twice that
|
|
250
|
+
* sooner or later diverges. When the whole parent chain is new (an entire new tree) it returns undefined, and the thing only
|
|
251
|
+
* fades in without moving.
|
|
252
|
+
*/
|
|
253
|
+
export declare function anchorOf(id: string, seen: (id: string) => boolean, parentOf: (id: string) => string | undefined): string | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* From the delta + previous frame coordinates + union coordinates, derive how each element moves in this transition.
|
|
256
|
+
*
|
|
257
|
+
* @param delta the result of diffModels(previous, new). **May be empty**: the data did not change, only the coordinates did
|
|
258
|
+
* ("Recompute" does this); then every element only "shifts a bit",
|
|
259
|
+
* with no additions, removals or fades, but it should still play.
|
|
260
|
+
* @param from previous frame's on-screen coordinates. Elements without one (new ones) start at their anchor's position.
|
|
261
|
+
* @param union coordinates from the union layout: **the only source of end points**
|
|
262
|
+
*/
|
|
263
|
+
export declare function planTransition(delta: GraphDelta | null, from: Positions, union: Positions, opts?: {
|
|
264
|
+
skins?: SkinChange[];
|
|
265
|
+
spec?: Required<AnimateSpec>;
|
|
266
|
+
/** Parent-child relations in the element table (the canvas has the authoritative one: the virtual root is in it).
|
|
267
|
+
* If omitted, derived from the union model: the parent of a top level is the virtual root, if present. */
|
|
268
|
+
parentOf?: (id: string) => string | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* Who enters and leaves on screen: what the canvas read from the marks on elements, the **same source** as the "presence" channel's
|
|
271
|
+
* fades and the curtain. The data change is only part of it: synthetic things in the element table (the virtual root) are not
|
|
272
|
+
* in the data but still enter and leave. If the two places each kept their own, one node would be fading out while being planned
|
|
273
|
+
* as "staying" and framed in. So delta handles details (what merged into what), and entering / leaving falls back to this.
|
|
274
|
+
*/
|
|
275
|
+
presence?: Map<string, 'gone' | 'new'>;
|
|
276
|
+
}): Transition;
|
|
277
|
+
/**
|
|
278
|
+
* Look channel: **the same node looks different in two versions**.
|
|
279
|
+
*
|
|
280
|
+
* The typical case is "a placeholder got filled": the `unfilled` flag drops and grey dashes become solid color. Note this is not
|
|
281
|
+
* `changed`: `changed` compares data, while the skin is computed from kind/flags/whether it is a container,
|
|
282
|
+
* and either can happen alone (that flag often depends on whether **other** nodes exist, with not one character of
|
|
283
|
+
* its own data changed). So this does not look at change categories, only at skins: **for every matched node, compute classes for the previous
|
|
284
|
+
* and this version; if they differ, it is a reskin.**
|
|
285
|
+
*
|
|
286
|
+
* @param delta the diff of the two versions; only its `resolved` is used (old id → identity in the union)
|
|
287
|
+
* @param prev the previous model
|
|
288
|
+
* @param next this model (not the union: the union carries gb-* marks, which are the diff channel, not skin)
|
|
289
|
+
*/
|
|
290
|
+
export declare function planSkins(delta: GraphDelta | null, prev: GraphModel | null, next: GraphModel, profile: GraphProfile): SkinChange[];
|
|
291
|
+
/** The half tucked away after the scene (the past). Also used to land directly on the new version when not playing. */
|
|
292
|
+
export declare function leavingOf(delta: GraphDelta | null): Set<string>;
|
|
293
|
+
/**
|
|
294
|
+
* Sample one frame.
|
|
295
|
+
*
|
|
296
|
+
* **One input only: time t (wall-clock progress, no easing).** Curves belong to the tracks:
|
|
297
|
+
* the window says "when", the curve says "how". It used to pass p through a global easing first and compare it against times,
|
|
298
|
+
* so all times collapsed to the start (with easeOutCubic, 0.4 landed at 15.7% of wall-clock). The track model fills
|
|
299
|
+
* that hole at the root: time and speed are no longer the same number.
|
|
300
|
+
*
|
|
301
|
+
* position = base + Σ(leg vector × its track's progress); opacity is isomorphic, see ENVELOPES.
|
|
302
|
+
* At `t = 0` both equal their base, so **this frame is the last frame before the switch**.
|
|
303
|
+
*/
|
|
304
|
+
export declare function sampleTransition(t: Transition, time: number): {
|
|
305
|
+
pos: Positions;
|
|
306
|
+
/** Current opacity of the four envelopes. The caller sets style once on each of the four sets (rule ④).
|
|
307
|
+
* `fade.in` is also the look channel's progress (rule ③). */
|
|
308
|
+
fade: Record<FadeName, number>;
|
|
309
|
+
/** Progress of the camera's two legs: open to the union framing first, then close to the new framing. */
|
|
310
|
+
open: number;
|
|
311
|
+
close: number;
|
|
312
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EN
|
|
3
|
+
} from "./chunk-EJURBBFC.js";
|
|
4
|
+
|
|
5
|
+
// src/react/i18n.ts
|
|
6
|
+
import { createContext, useContext } from "react";
|
|
7
|
+
var StringsContext = createContext(EN);
|
|
8
|
+
var useStrings = () => useContext(StringsContext);
|
|
9
|
+
|
|
10
|
+
// src/react/icons.tsx
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
var Icon = ({ d, size = 16 }) => /* @__PURE__ */ jsx("svg", { className: "gb-ico", viewBox: "0 0 24 24", width: size, height: size, "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d }) });
|
|
13
|
+
var I = {
|
|
14
|
+
search: "M10.5 4a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13Zm4.75 11.25L20 20",
|
|
15
|
+
x: "M6 6l12 12M18 6 6 18",
|
|
16
|
+
plus: "M12 5v14M5 12h14",
|
|
17
|
+
minus: "M5 12h14",
|
|
18
|
+
fit: "M4 9V5a1 1 0 0 1 1-1h4M15 4h4a1 1 0 0 1 1 1v4M20 15v4a1 1 0 0 1-1 1h-4M9 20H5a1 1 0 0 1-1-1v-4",
|
|
19
|
+
more: "M4 7h10M18 7h2M4 17h2M10 17h10M16 5v4M8 15v4",
|
|
20
|
+
warn: "M12 4 2.8 19.5h18.4L12 4Zm0 6v4.5m0 2.5v.5",
|
|
21
|
+
arrow: "M5 12h13M13 7l5 5-5 5",
|
|
22
|
+
stack: "M12 4 3 8.5l9 4.5 9-4.5L12 4ZM3 12.5l9 4.5 9-4.5M3 16.5l9 4.5 9-4.5",
|
|
23
|
+
edit: "M4 20h4L19 9l-4-4L4 16v4Zm9-13 4 4",
|
|
24
|
+
legend: "M5 7h.01M9 7h10M5 12h.01M9 12h10M5 17h.01M9 17h10",
|
|
25
|
+
reset: "M4 12a8 8 0 1 0 2.3-5.6M4 4v4h4",
|
|
26
|
+
collapse: "M6 15l6-6 6 6",
|
|
27
|
+
file: "M7 3h7l5 5v12a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/react/markdown.tsx
|
|
31
|
+
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
32
|
+
var ABS = /^(https?:|mailto:)/i;
|
|
33
|
+
var SCHEME = /^[a-z][a-z0-9+.-]*:/i;
|
|
34
|
+
function href(url, o) {
|
|
35
|
+
const u = url.trim();
|
|
36
|
+
if (u.startsWith("node:")) return { kind: "node", url: u.slice(5) };
|
|
37
|
+
if (ABS.test(u)) return { kind: "ext", url: u };
|
|
38
|
+
if (SCHEME.test(u) || u.startsWith("//")) return null;
|
|
39
|
+
const r = o.resolveUrl?.(u);
|
|
40
|
+
return r && ABS.test(r) ? { kind: "ext", url: r } : null;
|
|
41
|
+
}
|
|
42
|
+
var INLINE = /!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|`([^`]+)`|\*\*([^*]+)\*\*|__([^_]+)__|\*([^*\s][^*]*)\*|_([^_\s][^_]*)_/g;
|
|
43
|
+
function inline(text, o, key) {
|
|
44
|
+
const out = [];
|
|
45
|
+
let last = 0, i = 0;
|
|
46
|
+
for (const m of text.matchAll(INLINE)) {
|
|
47
|
+
if (m.index > last) out.push(text.slice(last, m.index));
|
|
48
|
+
const k = `${key}.${i++}`;
|
|
49
|
+
if (m[2] !== void 0) {
|
|
50
|
+
const h = href(m[2], o);
|
|
51
|
+
if (h?.kind === "ext") {
|
|
52
|
+
out.push(/* @__PURE__ */ jsx2(
|
|
53
|
+
"img",
|
|
54
|
+
{
|
|
55
|
+
className: "gb-md-img",
|
|
56
|
+
src: h.url,
|
|
57
|
+
alt: m[1],
|
|
58
|
+
loading: "lazy",
|
|
59
|
+
onError: (e) => {
|
|
60
|
+
e.currentTarget.style.display = "none";
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
k
|
|
64
|
+
));
|
|
65
|
+
} else if (m[1]) out.push(/* @__PURE__ */ jsx2("span", { className: "gb-md-alt", children: m[1] }, k));
|
|
66
|
+
} else if (m[4] !== void 0) {
|
|
67
|
+
const h = href(m[4], o);
|
|
68
|
+
const label = inline(m[3], o, k);
|
|
69
|
+
if (h?.kind === "ext") out.push(/* @__PURE__ */ jsx2("a", { href: h.url, target: "_blank", rel: "noreferrer noopener", children: label }, k));
|
|
70
|
+
else if (h?.kind === "node" && o.onNodeLink) {
|
|
71
|
+
const id = h.url;
|
|
72
|
+
out.push(/* @__PURE__ */ jsx2("a", { href: "#", className: "gb-md-node", onClick: (e) => {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
o.onNodeLink(id);
|
|
75
|
+
}, children: label }, k));
|
|
76
|
+
} else out.push(/* @__PURE__ */ jsx2("span", { children: label }, k));
|
|
77
|
+
} else if (m[5] !== void 0) out.push(/* @__PURE__ */ jsx2("code", { children: m[5] }, k));
|
|
78
|
+
else if (m[6] !== void 0 || m[7] !== void 0) out.push(/* @__PURE__ */ jsx2("strong", { children: inline(m[6] ?? m[7], o, k) }, k));
|
|
79
|
+
else out.push(/* @__PURE__ */ jsx2("em", { children: inline(m[8] ?? m[9], o, k) }, k));
|
|
80
|
+
last = m.index + m[0].length;
|
|
81
|
+
}
|
|
82
|
+
if (last < text.length) out.push(text.slice(last));
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
function renderMarkdown(src, o = {}) {
|
|
86
|
+
const lines = src.replace(/\r\n?/g, "\n").split("\n");
|
|
87
|
+
const blocks = [];
|
|
88
|
+
let para = [];
|
|
89
|
+
let list = null;
|
|
90
|
+
let n = 0;
|
|
91
|
+
const flushPara = () => {
|
|
92
|
+
if (para.length) blocks.push(/* @__PURE__ */ jsx2("p", { children: inline(para.join(" "), o, `p${n}`) }, n++));
|
|
93
|
+
para = [];
|
|
94
|
+
};
|
|
95
|
+
const flushList = () => {
|
|
96
|
+
if (!list) return;
|
|
97
|
+
const items = list.items.map((it, j) => /* @__PURE__ */ jsx2("li", { children: inline(it, o, `l${n}.${j}`) }, j));
|
|
98
|
+
blocks.push(list.ordered ? /* @__PURE__ */ jsx2("ol", { children: items }, n++) : /* @__PURE__ */ jsx2("ul", { children: items }, n++));
|
|
99
|
+
list = null;
|
|
100
|
+
};
|
|
101
|
+
for (let i = 0; i < lines.length; i++) {
|
|
102
|
+
const line = lines[i];
|
|
103
|
+
const t = line.trim();
|
|
104
|
+
if (t.startsWith("```")) {
|
|
105
|
+
flushPara();
|
|
106
|
+
flushList();
|
|
107
|
+
const body = [];
|
|
108
|
+
for (i++; i < lines.length && !lines[i].trim().startsWith("```"); i++) body.push(lines[i]);
|
|
109
|
+
blocks.push(/* @__PURE__ */ jsx2("pre", { children: /* @__PURE__ */ jsx2("code", { children: body.join("\n") }) }, n++));
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (!t) {
|
|
113
|
+
flushPara();
|
|
114
|
+
flushList();
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const h = /^(#{1,6})\s+(.*)$/.exec(t);
|
|
118
|
+
if (h) {
|
|
119
|
+
flushPara();
|
|
120
|
+
flushList();
|
|
121
|
+
blocks.push(/* @__PURE__ */ jsx2("div", { className: `gb-md-h gb-md-h${Math.min(h[1].length, 3)}`, children: inline(h[2], o, `h${n}`) }, n++));
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const li = /^([-*+]|\d+[.)])\s+(.*)$/.exec(t);
|
|
125
|
+
if (li) {
|
|
126
|
+
flushPara();
|
|
127
|
+
const ordered = /\d/.test(li[1]);
|
|
128
|
+
if (list && list.ordered !== ordered) flushList();
|
|
129
|
+
if (!list) list = { ordered, items: [] };
|
|
130
|
+
list.items.push(li[2]);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (t.startsWith(">")) {
|
|
134
|
+
flushPara();
|
|
135
|
+
flushList();
|
|
136
|
+
blocks.push(/* @__PURE__ */ jsx2("blockquote", { children: inline(t.replace(/^>\s?/, ""), o, `q${n}`) }, n++));
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (list && /^\s{2,}/.test(line)) {
|
|
140
|
+
list.items[list.items.length - 1] += ` ${t}`;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
flushList();
|
|
144
|
+
para.push(t);
|
|
145
|
+
}
|
|
146
|
+
flushPara();
|
|
147
|
+
flushList();
|
|
148
|
+
return /* @__PURE__ */ jsx2("div", { className: "gb-md", children: blocks });
|
|
149
|
+
}
|
|
150
|
+
function renderInline(src, o = {}) {
|
|
151
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: inline(src, o, "i") });
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/react/DetailPanel.tsx
|
|
155
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
156
|
+
var asStr = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
|
|
157
|
+
var asArr = (v) => Array.isArray(v) ? v.map(asStr).filter(Boolean) : [];
|
|
158
|
+
function DetailPanel({ node, spec, kindLabels, onClose, renderText, onEdit, color, markdown }) {
|
|
159
|
+
const t = useStrings();
|
|
160
|
+
const d = node.detail ?? {};
|
|
161
|
+
const line = spec.line ?? [];
|
|
162
|
+
const list = spec.list ?? [];
|
|
163
|
+
const text = (s) => renderText ? renderText(s) : renderMarkdown(s, markdown);
|
|
164
|
+
const item = (s) => renderText ? renderText(s) : renderInline(s, markdown);
|
|
165
|
+
const value = (field, raw) => spec.linkify ? spec.linkify(field, raw) : raw;
|
|
166
|
+
const known = /* @__PURE__ */ new Set([
|
|
167
|
+
...line.map((f) => f.key),
|
|
168
|
+
...list.map((f) => f.key),
|
|
169
|
+
...spec.skip ?? [],
|
|
170
|
+
// Structural fields (nodes carry them in the generic format) are already told by the title and the graph itself; not listed again.
|
|
171
|
+
"name",
|
|
172
|
+
"description",
|
|
173
|
+
"kind",
|
|
174
|
+
"id",
|
|
175
|
+
"label",
|
|
176
|
+
"parent",
|
|
177
|
+
"layer",
|
|
178
|
+
"flags"
|
|
179
|
+
]);
|
|
180
|
+
const extras = Object.entries(d).filter(([k, v]) => !known.has(k) && v != null && typeof v !== "object");
|
|
181
|
+
const empty = !extras.length && !asStr(d.description) && !node.flags.some((f) => spec.flagNotes?.[f]) && !line.some((f) => asStr(d[f.key])) && !list.some((f) => asArr(d[f.key]).length);
|
|
182
|
+
return /* @__PURE__ */ jsxs("div", { className: "gb-detail", children: [
|
|
183
|
+
/* @__PURE__ */ jsxs("div", { className: "gb-dh", children: [
|
|
184
|
+
/* @__PURE__ */ jsxs("span", { className: "gb-dh-title gb-kind", children: [
|
|
185
|
+
/* @__PURE__ */ jsx3("i", { className: "gb-dot", style: { background: color } }),
|
|
186
|
+
kindLabels[node.kind] ?? (node.kind || t.node)
|
|
187
|
+
] }),
|
|
188
|
+
/* @__PURE__ */ jsxs("span", { className: "gb-dh-act", children: [
|
|
189
|
+
onEdit && /* @__PURE__ */ jsxs("button", { className: "gb-ibtn gb-ibtn-text", onClick: onEdit, title: t.edit, children: [
|
|
190
|
+
/* @__PURE__ */ jsx3(Icon, { d: I.edit, size: 14 }),
|
|
191
|
+
/* @__PURE__ */ jsx3("span", { children: t.edit })
|
|
192
|
+
] }),
|
|
193
|
+
/* @__PURE__ */ jsx3("button", { className: "gb-ibtn", onClick: onClose, "aria-label": t.close, title: t.close, children: /* @__PURE__ */ jsx3(Icon, { d: I.x, size: 15 }) })
|
|
194
|
+
] })
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ jsxs("div", { className: "gb-db", children: [
|
|
197
|
+
/* @__PURE__ */ jsx3("div", { className: "gb-dt", children: node.label }),
|
|
198
|
+
node.flags.map((f) => {
|
|
199
|
+
const note = spec.flagNotes?.[f];
|
|
200
|
+
return note ? /* @__PURE__ */ jsx3("div", { className: "gb-flag", children: note }, f) : null;
|
|
201
|
+
}),
|
|
202
|
+
line.map((f) => {
|
|
203
|
+
const v = asStr(d[f.key]);
|
|
204
|
+
return v ? /* @__PURE__ */ jsxs("div", { className: "gb-line", children: [
|
|
205
|
+
/* @__PURE__ */ jsx3("span", { className: "gb-k", children: f.label }),
|
|
206
|
+
/* @__PURE__ */ jsx3("span", { children: v })
|
|
207
|
+
] }, f.key) : null;
|
|
208
|
+
}),
|
|
209
|
+
asStr(d.description) && /* @__PURE__ */ jsx3("div", { className: "gb-desc", children: text(asStr(d.description)) }),
|
|
210
|
+
list.map((f) => {
|
|
211
|
+
const items = asArr(d[f.key]);
|
|
212
|
+
return items.length ? /* @__PURE__ */ jsxs("div", { className: "gb-sect", children: [
|
|
213
|
+
/* @__PURE__ */ jsx3("span", { className: "gb-k", children: f.label }),
|
|
214
|
+
/* @__PURE__ */ jsx3("ul", { children: items.map((it, i) => /* @__PURE__ */ jsx3("li", { children: item(value(f.key, it)) }, i)) })
|
|
215
|
+
] }, f.key) : null;
|
|
216
|
+
}),
|
|
217
|
+
empty && /* @__PURE__ */ jsx3("div", { className: "gb-dempty", children: t.noDetails }),
|
|
218
|
+
extras.length > 0 && /* @__PURE__ */ jsx3("div", { className: "gb-extras", children: extras.map(([k, v]) => /* @__PURE__ */ jsxs("div", { className: "gb-line", children: [
|
|
219
|
+
/* @__PURE__ */ jsx3("span", { className: "gb-k", children: k }),
|
|
220
|
+
/* @__PURE__ */ jsx3("span", { children: asStr(v) })
|
|
221
|
+
] }, k)) })
|
|
222
|
+
] })
|
|
223
|
+
] });
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export {
|
|
227
|
+
StringsContext,
|
|
228
|
+
useStrings,
|
|
229
|
+
Icon,
|
|
230
|
+
I,
|
|
231
|
+
renderMarkdown,
|
|
232
|
+
renderInline,
|
|
233
|
+
DetailPanel
|
|
234
|
+
};
|