@loadmap/react 0.8.0 → 0.10.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/README.md +6 -2
- package/dist/{Loadmap-VLbQ__eh.d.ts → Loadmap-BOGYk1TH.d.ts} +114 -5
- package/dist/{Loadmap-D_Kto8cB.js → Loadmap-D_RccOOD.js} +802 -61
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/source.d.ts +1 -1
- package/dist/source.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -92,12 +92,16 @@ pans the diagram in its own box). Each compact panel opens whole over the diagra
|
|
|
92
92
|
'controls']}` keeps only those (`LOADMAP_PANELS` lists them all: `verdict`, `live`, `limits`, `controls`, `headroom`,
|
|
93
93
|
`compare`, `assumptions`). A switch beside Close, or the F key, turns full screen into **focus**: the diagram, the
|
|
94
94
|
story and, of the panels listed, the verdict and the load slider. `fullScreenMode="focus"` opens full screen there
|
|
95
|
-
(default `'panels'`). The story bar
|
|
95
|
+
(default `'panels'`). The story bar's Play tells the story on the diagram: the whole diagram, a close-up on what each
|
|
96
|
+
step changes, the change, and the whole diagram again for the step's `seconds`, a short title on the board (the step's
|
|
97
|
+
`title`, or what it changes). The component that runs out first wears a ring that breathes while the story plays and
|
|
98
|
+
once it is past the target. With reduced motion the camera cuts and the ring holds still. `ref.playStory()` plays it
|
|
99
|
+
on the engine's clock, which `step()` advances.
|
|
96
100
|
|
|
97
101
|
`useLoadmap` with `LoadmapRoot`, `Diagram`, `Verdict`, `Limits`, `Controls` and the others builds a page of your own
|
|
98
102
|
layout from the same pieces. The diagram's Full screen takes the whole root: inside a `<div className="lm-side">`
|
|
99
103
|
after the `Diagram`, your pieces become a box below it that scrolls on its own; a title, the `Scenarios` and the
|
|
100
104
|
`Story` stay above the diagram, and the rest waits outside. The controller has the state: `lm.fullScreen`,
|
|
101
|
-
`lm.toggleFullScreen()`, `lm.fullScreenMode`, `lm.storyPlaying
|
|
105
|
+
`lm.toggleFullScreen()`, `lm.fullScreenMode`, `lm.storyPlaying`, `lm.cue` (what the board says about the step played).
|
|
102
106
|
|
|
103
107
|
Docs, live examples and the editor: https://jaim3r0jas.github.io/loadmap/ · MIT
|
|
@@ -2,6 +2,22 @@ import { Evaluation, Model, Scenario, Values } from "@loadmap/core";
|
|
|
2
2
|
import { Direction, ElkEngine, Scene, View, labelsAt } from "@loadmap/layout";
|
|
3
3
|
import { ReactNode, Ref } from "react";
|
|
4
4
|
import { Particle, Sim, SimOptions } from "@loadmap/sim";
|
|
5
|
+
/** A part of the scene the board shows, in scene units. */
|
|
6
|
+
interface Rect {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
w: number;
|
|
10
|
+
h: number;
|
|
11
|
+
}
|
|
12
|
+
/** Each box's shape by id and the edges drawn, as `shapesOf` gives them: what a change of values reshapes. */
|
|
13
|
+
interface Shapes {
|
|
14
|
+
nodes: Record<string, string>;
|
|
15
|
+
edges: {
|
|
16
|
+
id: string;
|
|
17
|
+
from: string;
|
|
18
|
+
to: string;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
5
21
|
/** A dot as it is drawn now, in scene units. */
|
|
6
22
|
interface Dot {
|
|
7
23
|
x: number;
|
|
@@ -12,6 +28,46 @@ interface Dot {
|
|
|
12
28
|
/** A retry: drawn as a ring of this stroke width, inside r. */
|
|
13
29
|
ring?: number;
|
|
14
30
|
}
|
|
31
|
+
/** What the diagram says while the story plays a step: its title, and what the boxes framed show. */
|
|
32
|
+
interface Cue {
|
|
33
|
+
step: number;
|
|
34
|
+
title: string;
|
|
35
|
+
detail: string;
|
|
36
|
+
/** The step's values are shown. */
|
|
37
|
+
after: boolean;
|
|
38
|
+
/** The boxes framed are low on the board: the title sits at its top. */
|
|
39
|
+
top: boolean;
|
|
40
|
+
/** The step's length as it plays, in seconds. */
|
|
41
|
+
seconds: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The limit passing from one component to another, on the engine's clock: the old ring fades (its tag already the
|
|
45
|
+
* old box's badge), then the new ring comes in. The rings never show together, and only one wears the tag.
|
|
46
|
+
*/
|
|
47
|
+
interface Handover {
|
|
48
|
+
from: string;
|
|
49
|
+
to: string;
|
|
50
|
+
/** Seconds since the page drew the new limit. */
|
|
51
|
+
t: number;
|
|
52
|
+
/** How much of the old ring showed when it began to fade. */
|
|
53
|
+
fade: number;
|
|
54
|
+
/** Seconds the old ring takes to fade, and the new one to come in. */
|
|
55
|
+
out: number;
|
|
56
|
+
in: number;
|
|
57
|
+
/** When the new ring starts to come in, on `t`: a story sets it once the camera reaches the new limit. */
|
|
58
|
+
inAt: number;
|
|
59
|
+
/** Started by a story step: it lasts until the next step. */
|
|
60
|
+
story: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** How the story player reaches the page: it starts and stops, shows a step's values and says what it is at. */
|
|
63
|
+
interface StoryHost {
|
|
64
|
+
playing(on: boolean): void;
|
|
65
|
+
show(i: number): void;
|
|
66
|
+
cue(c: Cue | null): void;
|
|
67
|
+
/** Each box's shape and the edges drawn at these values (`shapesOf`, with the page's direction and fonts). */
|
|
68
|
+
shapes(ev: Evaluation): Shapes;
|
|
69
|
+
}
|
|
70
|
+
type Shot = 'establish' | 'in' | 'close' | 'change' | 'hand' | 'out' | 'wide' | 'back';
|
|
15
71
|
/**
|
|
16
72
|
* Everything that moves, without React: the sim, the dots on the canvas, the worker fills in the SVG, and the move from
|
|
17
73
|
* one structure to the next. React renders the structure once per scene, and once per frame while it moves; the engine
|
|
@@ -41,11 +97,20 @@ declare class Engine {
|
|
|
41
97
|
storyStep: number | null;
|
|
42
98
|
drawnFocus: string | null;
|
|
43
99
|
paused: boolean;
|
|
100
|
+
/** Flights cut and the first limit holds still. */
|
|
101
|
+
reducedMotion: boolean;
|
|
102
|
+
/** The part of the scene the board shows while the story plays; null for all of it. */
|
|
103
|
+
camera: Rect | null;
|
|
104
|
+
/** What the diagram says about the step the story plays; null when it does not play. */
|
|
105
|
+
cue: Cue | null;
|
|
106
|
+
host: StoryHost | null;
|
|
44
107
|
colors: Record<string, string>;
|
|
45
108
|
svg: SVGSVGElement | null;
|
|
46
109
|
canvas: HTMLCanvasElement | null;
|
|
47
110
|
constructor(model: Model, view: View, ev: Evaluation, o?: SimOptions);
|
|
48
111
|
setEvaluation(ev: Evaluation): void;
|
|
112
|
+
/** The limit passing to another component now, if it is: the diagram draws the old ring while it fades. */
|
|
113
|
+
get handover(): Handover | null;
|
|
49
114
|
/**
|
|
50
115
|
* Takes a new scene. A new structure moves in from what is drawn now, unless `cut`, the diagram turned (a new
|
|
51
116
|
* direction is a new screen size, not a new design), or it is paused with nothing stepping it; the first scene just
|
|
@@ -64,18 +129,48 @@ declare class Engine {
|
|
|
64
129
|
flowColor(flow: string): string;
|
|
65
130
|
outcomeColor(outcome: Particle['outcome']): string;
|
|
66
131
|
resize(): void;
|
|
67
|
-
/** Advances the sim,
|
|
132
|
+
/** Advances the sim, the move to a new structure and the story played, by `dtReal` seconds. */
|
|
68
133
|
step(dtReal: number, o?: {
|
|
69
134
|
particles?: boolean;
|
|
70
135
|
}): void;
|
|
136
|
+
/** The story plays: from the whole diagram, step `from` and the ones after it. */
|
|
137
|
+
get playing(): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Plays the story from step `from` on the engine's clock: the whole diagram, then for each step a flight in to what it
|
|
140
|
+
* changes, the change, a flight out and the whole diagram for its seconds. The host shows each step's values. False
|
|
141
|
+
* when it cannot: nothing is drawn yet, or there is no such step.
|
|
142
|
+
*/
|
|
143
|
+
playStory(from: number): boolean;
|
|
144
|
+
/** Stops the story: the camera flies back to the whole diagram (cuts with `cut`), and the step shown stays. */
|
|
145
|
+
stopStory(o?: {
|
|
146
|
+
cut?: boolean;
|
|
147
|
+
}): void;
|
|
148
|
+
/** For tests and recordings: the shot the story is at. */
|
|
149
|
+
get story(): {
|
|
150
|
+
i: number;
|
|
151
|
+
shot: Shot;
|
|
152
|
+
t: number;
|
|
153
|
+
} | null;
|
|
154
|
+
/** Points the SVG at the camera: React draws the whole scene's viewBox, the camera replaces it after each render. */
|
|
155
|
+
applyCamera(): void;
|
|
71
156
|
/** Draws the dots on the overlay canvas and the worker fills in the SVG. */
|
|
72
157
|
draw(o?: {
|
|
73
158
|
particles?: boolean;
|
|
74
159
|
}): void;
|
|
75
160
|
drawFills(): void;
|
|
161
|
+
/**
|
|
162
|
+
* The rings: the limit breathes, on the engine's clock, while the story plays and once it is past the target, a scale
|
|
163
|
+
* and a glow on its own layer, which moves nothing else; a handover fades the old ring and brings the new one in.
|
|
164
|
+
* Decided here, not by a render, so a recording never waits on one. The page calls it after each render too, so a
|
|
165
|
+
* new ring never shows a frame before the engine has placed it.
|
|
166
|
+
*/
|
|
167
|
+
drawHalos(): void;
|
|
76
168
|
/** Every dot as it is drawn now, in scene units: for the canvas, and for an SVG export. */
|
|
77
169
|
dots(): Dot[];
|
|
78
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Paints the dots onto any 2D context, scene units × `scale`: the overlay, or an export frame. Under the camera they
|
|
172
|
+
* go where the SVG shows their places (its viewBox, centred where its shape differs), so they keep matching the bars.
|
|
173
|
+
*/
|
|
79
174
|
paintParticles(ctx: CanvasRenderingContext2D, scale: number): void;
|
|
80
175
|
}
|
|
81
176
|
interface LoadmapOptions<P> extends SimOptions {
|
|
@@ -114,10 +209,18 @@ interface LoadmapController<P = any> {
|
|
|
114
209
|
setStep: (i: number | null) => void;
|
|
115
210
|
/** The component the story points at now. */
|
|
116
211
|
focus: string | null;
|
|
117
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* The story plays: the whole diagram, then for each step a close-up on what it changes, the change, and the whole
|
|
214
|
+
* diagram again for its seconds, until the last.
|
|
215
|
+
*/
|
|
118
216
|
storyPlaying: boolean;
|
|
119
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Plays the story from the step after the one shown (from the first outside the story or at its end), or pauses it.
|
|
219
|
+
* A value the reader changes, a scenario or a step they pick stops it.
|
|
220
|
+
*/
|
|
120
221
|
setStoryPlaying: (on: boolean) => void;
|
|
222
|
+
/** What the diagram says about the step the story plays; null when it does not play. */
|
|
223
|
+
cue: Cue | null;
|
|
121
224
|
/** The root is full screen: the browser's, or an overlay where the browser has none or refuses. */
|
|
122
225
|
fullScreen: boolean;
|
|
123
226
|
toggleFullScreen: () => void;
|
|
@@ -160,6 +263,12 @@ interface LoadmapHandle {
|
|
|
160
263
|
setStoryStep(i: number | null): void;
|
|
161
264
|
/** The story step shown; null outside the story. */
|
|
162
265
|
storyStep(): number | null;
|
|
266
|
+
/**
|
|
267
|
+
* Plays the story from its first step on the engine's clock, as Play does: the whole diagram, then for each step a
|
|
268
|
+
* close-up on what it changes, the change, and the whole diagram for its seconds. `step()` advances it; returns its
|
|
269
|
+
* length in seconds. Picking a step or a value stops it.
|
|
270
|
+
*/
|
|
271
|
+
playStory(): number;
|
|
163
272
|
/** The drawn board, for capturing frames: while the structure moves, `scene` is the frame drawn. */
|
|
164
273
|
board(): {
|
|
165
274
|
svg: SVGSVGElement;
|
|
@@ -203,4 +312,4 @@ interface LoadmapProps<P> extends LoadmapOptions<P> {
|
|
|
203
312
|
/** The whole page piece: scenarios, diagram, verdict, headroom, live meters, limits, controls and assumptions. */
|
|
204
313
|
declare function Loadmap<P>({ model, view, theme, title, assumptions, headroom, compare, fullScreen, onNodeClick, selected, ref, ...o }: LoadmapProps<P>): import("react").JSX.Element;
|
|
205
314
|
declare function handleOf(lm: LoadmapController): LoadmapHandle;
|
|
206
|
-
export { LoadmapProps as a, handleOf as c, LoadmapController as d, LoadmapOptions as f, Engine as h, LoadmapPanel as i, usePageTheme as l,
|
|
315
|
+
export { LoadmapProps as a, handleOf as c, LoadmapController as d, LoadmapOptions as f, Engine as g, Dot as h, LoadmapPanel as i, usePageTheme as l, Cue as m, Loadmap as n, LoadmapRoot as o, useLoadmap as p, LoadmapHandle as r, Theme as s, LOADMAP_PANELS as t, FullScreenMode as u };
|