@johnoscott/isometric-engine 0.14.1 → 0.16.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.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/iso-editor.js +249 -203
  3. package/iso-render.js +200 -154
  4. package/iso-systems.js +210 -162
  5. package/isometric-diagram.js +389 -0
  6. package/js/iso-core/index.js +5 -0
  7. package/js/iso-core/mono.js +242 -0
  8. package/js/iso-editor/ui/canvas.js +23 -1
  9. package/js/iso-objects/ants.js +36 -0
  10. package/js/iso-objects/index.js +55 -1
  11. package/js/iso-objects/looks.js +25 -0
  12. package/js/iso-objects/mono-paint.js +96 -0
  13. package/js/iso-objects/motion-builder.js +130 -0
  14. package/js/iso-objects/motion-doc.js +421 -0
  15. package/js/iso-objects/motion-entry.js +34 -0
  16. package/js/iso-objects/motion-schema.js +83 -0
  17. package/js/iso-objects/motion.js +640 -0
  18. package/js/iso-objects/resolve.js +238 -0
  19. package/js/iso-objects/scene.js +15 -13
  20. package/js/iso-objects/timeline.js +593 -0
  21. package/js/iso-systems/compile.js +83 -1
  22. package/js/iso-systems/index.js +4 -1
  23. package/js/iso-systems/render.js +20 -0
  24. package/js/iso-systems/schema.json +40 -0
  25. package/js/iso-viewer/index.js +6 -0
  26. package/js/iso-viewer/page.js +40 -16
  27. package/js/iso-viewer/play.js +340 -0
  28. package/js/iso-viewer/player.js +149 -175
  29. package/js/iso-viewer/transport.js +289 -0
  30. package/package.json +84 -2
  31. package/src/iso-core/index.ts +1 -0
  32. package/src/iso-core/mono.ts +306 -0
  33. package/src/iso-core/theme.ts +2 -1
  34. package/src/iso-editor/ui/canvas.ts +14 -1
  35. package/src/iso-objects/ants.ts +53 -0
  36. package/src/iso-objects/compile.ts +4 -1
  37. package/src/iso-objects/index.ts +16 -1
  38. package/src/iso-objects/looks.ts +21 -0
  39. package/src/iso-objects/mono-paint.ts +97 -0
  40. package/src/iso-objects/motion-builder.ts +79 -0
  41. package/src/iso-objects/motion-doc.ts +309 -0
  42. package/src/iso-objects/motion-entry.ts +13 -0
  43. package/src/iso-objects/motion-schema.ts +55 -0
  44. package/src/iso-objects/motion.ts +617 -0
  45. package/src/iso-objects/resolve.ts +196 -0
  46. package/src/iso-objects/scene.ts +32 -13
  47. package/src/iso-objects/timeline.ts +493 -0
  48. package/src/iso-objects/types.ts +22 -2
  49. package/src/iso-systems/compile.ts +86 -4
  50. package/src/iso-systems/index.ts +4 -1
  51. package/src/iso-systems/render.ts +45 -0
  52. package/src/iso-systems/schema.json +40 -0
  53. package/src/iso-viewer/index.ts +4 -0
  54. package/src/iso-viewer/page.ts +28 -11
  55. package/src/iso-viewer/play.ts +280 -0
  56. package/src/iso-viewer/player.ts +132 -150
  57. package/src/iso-viewer/transport.ts +272 -0
  58. package/types/iso-core/index.d.ts +1 -0
  59. package/types/iso-core/mono.d.ts +61 -0
  60. package/types/iso-core/theme.d.ts +2 -0
  61. package/types/iso-objects/ants.d.ts +34 -0
  62. package/types/iso-objects/compile.d.ts +3 -0
  63. package/types/iso-objects/index.d.ts +16 -1
  64. package/types/iso-objects/looks.d.ts +4 -0
  65. package/types/iso-objects/mono-paint.d.ts +20 -0
  66. package/types/iso-objects/motion-builder.d.ts +105 -0
  67. package/types/iso-objects/motion-doc.d.ts +193 -0
  68. package/types/iso-objects/motion-entry.d.ts +11 -0
  69. package/types/iso-objects/motion-schema.d.ts +594 -0
  70. package/types/iso-objects/motion.d.ts +202 -0
  71. package/types/iso-objects/resolve.d.ts +20 -0
  72. package/types/iso-objects/scene.d.ts +14 -0
  73. package/types/iso-objects/timeline.d.ts +66 -0
  74. package/types/iso-objects/types.d.ts +34 -0
  75. package/types/iso-systems/compile.d.ts +25 -3
  76. package/types/iso-systems/index.d.ts +4 -1
  77. package/types/iso-systems/render.d.ts +25 -0
  78. package/types/iso-viewer/index.d.ts +4 -0
  79. package/types/iso-viewer/play.d.ts +37 -0
  80. package/types/iso-viewer/transport.d.ts +73 -0
  81. package/types/player/isometric-diagram.d.ts +24 -0
@@ -0,0 +1,272 @@
1
+ // A Timeline's transport (docs/design/MOTION.md, 6.3): play, pause, seek, rate, loop, the ambient switch, beats, and rebinding to a
2
+ // changed document. Headless: no DOM. It is the only place in the motion code that owns a clock, and the clock can be given (tests,
3
+ // and hosts with a clock of their own). A Timeline stays a pure function; this says which two times to ask it for.
4
+ //
5
+ // Two clocks (3.4): T, the timeline's, and A, the ambient one. Playing moves both; paused with the ambient on, A goes on alone (so ants
6
+ // march while the story waits); a seek moves both by the same; a restart, or a loop coming round, makes A equal T again. With the
7
+ // ambient off A stands through all of it, and on again it carries on from where it stood.
8
+
9
+ import type { BeatInfo, Cue, Timeline } from '../iso-objects/timeline.ts';
10
+ import type { SceneState } from '../iso-objects/motion.ts';
11
+
12
+ export interface TransportClock {
13
+ /** ms, going only forward */
14
+ now(): number;
15
+ /** call f soon, once: the next frame; returns what cancel takes */
16
+ next(f: () => void): unknown;
17
+ cancel(id: unknown): void;
18
+ }
19
+ export interface TransportOptions {
20
+ /** start again at the end (default false) */
21
+ loop?: boolean;
22
+ /** how fast (default 1) */
23
+ rate?: number;
24
+ /** default: the document's own */
25
+ ambient?: 'on' | 'off';
26
+ clock?: TransportClock;
27
+ }
28
+ export interface TransportEvents {
29
+ /** the drawing is to be painted again: T (ms), and why */
30
+ time: (ms: number, why: 'play' | 'ambient' | 'seek' | 'rebind') => void;
31
+ play: () => void;
32
+ pause: () => void;
33
+ /** it came to its end and stopped (not at each turn of a loop: that is 'loop') */
34
+ end: () => void;
35
+ loop: () => void;
36
+ /** a beat begins: each one passed, in order, while playing; the one landed in, after a seek or a rebind. `at`: where in the timeline it starts, ms */
37
+ beat: (beat: BeatInfo, how: 'play' | 'seek' | 'rebind') => void;
38
+ ambient: (on: boolean) => void;
39
+ rate: (rate: number) => void;
40
+ }
41
+ export interface Transport {
42
+ readonly timeline: Timeline;
43
+ readonly duration: number;
44
+ /** T, ms */
45
+ readonly time: number;
46
+ /** A, ms, or 'off' when it never ran: what at()'s `ambient` takes */
47
+ readonly ambientTime: number | 'off';
48
+ readonly playing: boolean;
49
+ readonly beat: BeatInfo | undefined;
50
+ readonly cue: Cue | undefined;
51
+ rate: number;
52
+ loop: boolean;
53
+ ambient: boolean;
54
+ /** whether the host shows it now (default true): while false neither clock moves, playing or not */
55
+ active: boolean;
56
+ /** what the drawing looks like now */
57
+ state(): SceneState;
58
+ /** until: pause there (a time still ahead) */
59
+ play(o?: { until?: number }): void;
60
+ pause(): void;
61
+ toggle(): void;
62
+ /** join: the ambient clock at that time too (a step taken: what loops starts with it), where the ambient is on */
63
+ seek(ms: number, o?: { join?: boolean }): void;
64
+ /** to a beat's start, by its name or its index; whether there is one */
65
+ seekBeat(beat: string | number): boolean;
66
+ /** to the next beat's start, or the end; to this beat's start, or the one before when nearly there */
67
+ next(): void;
68
+ prev(): void;
69
+ restart(): void;
70
+ /** the document or the drawing changed: the place is kept by beat and how far in it. A Timeline with faults (ok: false) is refused, and the last good one goes on */
71
+ rebind(tl: Timeline): boolean;
72
+ /** returns how to stop listening */
73
+ on<K extends keyof TransportEvents>(event: K, f: TransportEvents[K]): () => void;
74
+ dispose(): void;
75
+ }
76
+
77
+ /** the page's clock: frames, and a timer behind them, so it also goes on where no frames are drawn (a page not shown) */
78
+ export function pageClock(): TransportClock {
79
+ const g = globalThis as unknown as { requestAnimationFrame?: (f: () => void) => number; cancelAnimationFrame?: (id: number) => void };
80
+ return {
81
+ now: () => performance.now(),
82
+ next(f) {
83
+ const id: { raf?: number; timer?: ReturnType<typeof setTimeout> } = {};
84
+ const once = () => { if (id.raf !== undefined) g.cancelAnimationFrame?.(id.raf); clearTimeout(id.timer); f(); };
85
+ id.raf = g.requestAnimationFrame?.(once);
86
+ id.timer = setTimeout(once, id.raf === undefined ? 16 : 100);
87
+ return id;
88
+ },
89
+ cancel(id) { const x = id as { raf?: number; timer?: ReturnType<typeof setTimeout> }; if (x.raf !== undefined) g.cancelAnimationFrame?.(x.raf); clearTimeout(x.timer); },
90
+ };
91
+ }
92
+
93
+ /** pressing back this soon after a beat began goes to the one before, ms */
94
+ const BACK_WITHIN = 400;
95
+
96
+ export function transport(tl0: Timeline, o: TransportOptions = {}): Transport {
97
+ const clock = o.clock ?? pageClock();
98
+ let tl = tl0, T = 0, rate = good(o.rate ?? 1), loop = o.loop ?? false, playing = false, active = true, gone = false;
99
+ let on = (o.ambient ?? tl.ambient) === 'on';
100
+ /** A; 'off': never ran */
101
+ let A: number | 'off' = on ? 0 : 'off';
102
+ // turn: counts what a listener may do inside an event (seek, pause, rebind, …), after which that tick's own news is old
103
+ let pending: unknown, last = 0, beat = tl.beatAt(0), told = false, turn = 0, until: number | undefined;
104
+ const subs: { [K in keyof TransportEvents]?: Set<TransportEvents[K]> } = {};
105
+
106
+ function good(r: number) { if (!(Number.isFinite(r) && r > 0)) throw new Error('rate is a number over 0'); return r; }
107
+ const clamp = (ms: number) => Math.max(0, Math.min(tl.duration, ms));
108
+ function emit<K extends keyof TransportEvents>(k: K, ...a: Parameters<TransportEvents[K]>) {
109
+ for (const f of [...(subs[k] ?? [])]) (f as (...x: Parameters<TransportEvents[K]>) => void)(...a);
110
+ }
111
+ const moves = () => active && !gone && (playing || (on && tl.loops));
112
+ /** ask for a frame while something moves */
113
+ function arm() {
114
+ if (moves()) { if (pending === undefined) { last = clock.now(); pending = clock.next(tick); } }
115
+ else if (pending !== undefined) { clock.cancel(pending); pending = undefined; }
116
+ }
117
+ /** the beats that begin after `from`, up to `to`: each said once */
118
+ function passed(from: number, to: number) {
119
+ const mine = turn;
120
+ for (const b of tl.beats) {
121
+ if (b.start <= from || b.start > to || b.index === beat?.index) continue;
122
+ beat = b; told = true; emit('beat', b, 'play');
123
+ if (turn !== mine) return false;
124
+ }
125
+ return true;
126
+ }
127
+ function play1(dt: number) {
128
+ if (!playing) { emit('time', T, 'ambient'); return; }
129
+ const was = T, to = T + dt, mine = turn;
130
+ if (until !== undefined && to >= until) {
131
+ T = until;
132
+ if (!passed(was, T)) return;
133
+ until = undefined; playing = false;
134
+ emit('time', T, 'play');
135
+ if (turn === mine) emit('pause');
136
+ return;
137
+ }
138
+ if (to < tl.duration) {
139
+ T = to;
140
+ if (passed(was, T)) emit('time', T, 'play');
141
+ return;
142
+ }
143
+ if (loop) {
144
+ // (the beats left in this turn; whole turns missed while no frames came are not played one by one)
145
+ if (!passed(was, tl.duration)) return;
146
+ T = to % tl.duration;
147
+ if (on) A = T;
148
+ beat = undefined;
149
+ emit('loop');
150
+ if (turn !== mine) return;
151
+ const first = tl.beatAt(0);
152
+ if (first) { beat = first; emit('beat', first, 'play'); if (turn !== mine || !passed(first.start, T)) return; }
153
+ emit('time', T, 'play');
154
+ return;
155
+ }
156
+ T = tl.duration;
157
+ if (!passed(was, T)) return;
158
+ playing = false;
159
+ emit('time', T, 'play');
160
+ if (turn !== mine) return;
161
+ emit('pause');
162
+ if (turn !== mine) return;
163
+ emit('end');
164
+ }
165
+ function tick() {
166
+ pending = undefined;
167
+ const now = clock.now(), dt = Math.max(0, now - last) * rate;
168
+ last = now;
169
+ if (on && A !== 'off') A += dt;
170
+ play1(dt);
171
+ if (pending === undefined) { if (moves()) pending = clock.next(tick); }
172
+ }
173
+ function land(how: 'seek' | 'rebind', again = false) {
174
+ const b = tl.beatAt(T);
175
+ turn++;
176
+ const mine = turn, other = b?.name !== beat?.name || b?.index !== beat?.index;
177
+ beat = b;
178
+ if (b && (other || again)) { told = true; emit('beat', b, how); if (turn !== mine) return; }
179
+ emit('time', T, how);
180
+ }
181
+ function seek(ms: number, o: { join?: boolean } = {}) {
182
+ if (gone || !Number.isFinite(ms)) return;
183
+ const to = clamp(ms);
184
+ if (on && A !== 'off') A = o.join ? to : A + to - T;
185
+ T = to; last = clock.now();
186
+ if (until !== undefined && T >= until) until = undefined;
187
+ land('seek');
188
+ arm();
189
+ }
190
+ function restart() {
191
+ if (gone) return;
192
+ T = 0; if (on) A = 0;
193
+ until = undefined;
194
+ last = clock.now();
195
+ land('seek', true);
196
+ arm();
197
+ }
198
+ const api: Transport = {
199
+ get timeline() { return tl; },
200
+ get duration() { return tl.duration; },
201
+ get time() { return T; },
202
+ get ambientTime() { return A; },
203
+ get playing() { return playing; },
204
+ get beat() { return beat; },
205
+ get cue() { return tl.cues(T); },
206
+ get rate() { return rate; },
207
+ set rate(r) { const v = good(r); if (v === rate) return; rate = v; emit('rate', v); },
208
+ get loop() { return loop; },
209
+ set loop(v) { loop = v; },
210
+ get ambient() { return on; },
211
+ set ambient(v) {
212
+ if (gone || v === on) return;
213
+ on = v;
214
+ // never ran: it starts where this beat's loops stand, at their start
215
+ if (on && A === 'off') A = beat?.start ?? 0;
216
+ arm();
217
+ emit('ambient', on);
218
+ emit('time', T, 'ambient');
219
+ },
220
+ get active() { return active; },
221
+ set active(v) { if (v === active) return; active = v; arm(); },
222
+ state: () => tl.at(T, { ambient: A }),
223
+ play(p = {}) {
224
+ if (gone || playing || tl.duration <= 0) return;
225
+ if (T >= tl.duration && p.until === undefined) restart();
226
+ until = p.until !== undefined && p.until > T && p.until <= tl.duration ? p.until : undefined;
227
+ if (p.until !== undefined && until === undefined) return;
228
+ playing = true; last = clock.now();
229
+ arm();
230
+ emit('play');
231
+ // the beat it starts in, if nobody has been told of it
232
+ if (playing && !told && beat) { told = true; emit('beat', beat, 'play'); }
233
+ },
234
+ pause() { if (!playing) return; playing = false; until = undefined; turn++; arm(); emit('pause'); },
235
+ toggle() { if (playing) api.pause(); else api.play(); },
236
+ seek,
237
+ seekBeat(b) {
238
+ const ms = typeof b === 'number' ? tl.beats[b]?.start : tl.beats.find(x => x.name === b)?.start;
239
+ if (ms === undefined) return false;
240
+ seek(ms);
241
+ return true;
242
+ },
243
+ next() { const n = tl.beats.find(b => b.start > T); seek(n ? n.start : tl.duration); },
244
+ prev() { const back = [...tl.beats].reverse().find(b => b.start < T - BACK_WITHIN); seek(back ? back.start : 0); },
245
+ restart,
246
+ rebind(next) {
247
+ if (gone || !next.ok) return false;
248
+ until = undefined;
249
+ const was = tl.beatAt(T), frac = was ? (T - was.start) / Math.max(1, was.end - was.start) : 0, d = A === 'off' ? 0 : A - T, before = tl;
250
+ tl = next;
251
+ if (was) {
252
+ const same = next.beats.find(b => b.name === was.name);
253
+ if (same) T = same.start + frac * (same.end - same.start);
254
+ else {
255
+ // it went away: the nearest before it that is still there, at its end
256
+ const near = before.beats.filter(b => b.index < was.index).reverse().map(b => next.beats.find(x => x.name === b.name)).find(Boolean);
257
+ T = near ? near.start : 0;
258
+ }
259
+ }
260
+ T = clamp(T);
261
+ if (on && A !== 'off') A = T + d;
262
+ last = clock.now();
263
+ land('rebind');
264
+ arm();
265
+ return true;
266
+ },
267
+ on(k, f) { const set = (subs[k] ??= new Set() as never) as Set<typeof f>; set.add(f); return () => { set.delete(f); }; },
268
+ dispose() { gone = true; turn++; playing = false; if (pending !== undefined) clock.cancel(pending); pending = undefined; for (const k of Object.keys(subs) as (keyof TransportEvents)[]) subs[k]!.clear(); },
269
+ };
270
+ arm();
271
+ return api;
272
+ }
@@ -15,3 +15,4 @@ export type { SvgNode } from './svg-dom.js';
15
15
  export { VEl, vdoc, serialize } from './vdom.js';
16
16
  export type { VNode } from './vdom.js';
17
17
  export { createHash, sha256Hex } from './shims/crypto.js';
18
+ export { MONO, greyOf, contrast, monoOf, type MonoLook, type MonoTable, type MonoPattern } from './mono.js';
@@ -0,0 +1,61 @@
1
+ import type { Theme } from './theme.js';
2
+ export type MonoPattern = 'none' | 'hatch' | 'hatch-wide' | 'dots';
3
+ export type MonoStep = 0 | 1 | 2 | 3;
4
+ export interface MonoFace {
5
+ top: string;
6
+ left: string;
7
+ right: string;
8
+ edge: string;
9
+ }
10
+ export interface MonoRhythm {
11
+ dash: number[];
12
+ width: number;
13
+ }
14
+ export interface MonoRoleLook extends MonoFace {
15
+ step: MonoStep;
16
+ pattern: MonoPattern;
17
+ }
18
+ export interface MonoLook {
19
+ mode: 'light' | 'dark';
20
+ paper: string;
21
+ ink: string;
22
+ roles: Record<string, MonoRoleLook>;
23
+ kinds: Record<string, MonoRhythm>;
24
+ warnings: string[];
25
+ }
26
+ export interface MonoTable {
27
+ roles?: Record<string, {
28
+ step?: MonoStep;
29
+ pattern?: MonoPattern;
30
+ }>;
31
+ kinds?: Record<string, {
32
+ dash?: number[];
33
+ width?: number;
34
+ }>;
35
+ }
36
+ export declare const MONO: {
37
+ light: {
38
+ paper: string;
39
+ ink: string;
40
+ steps: readonly [MonoFace, MonoFace, MonoFace, MonoFace];
41
+ };
42
+ dark: {
43
+ paper: string;
44
+ ink: string;
45
+ steps: readonly [MonoFace, MonoFace, MonoFace, MonoFace];
46
+ };
47
+ patterns: readonly MonoPattern[];
48
+ rhythms: readonly MonoRhythm[];
49
+ kindOrder: readonly ["send", "reply", "token", "blocked", "user", "event", "control", "planned"];
50
+ thresholds: readonly [86, 81, 76];
51
+ darkWidthAdd: number;
52
+ };
53
+ /** CIE lightness L* (0 to 100) of a #rgb, #rrggbb or hsl(h s% l%) colour. */
54
+ export declare function greyOf(color: string): number;
55
+ /** WCAG 2.1 contrast ratio between two colours (1 to 21). */
56
+ export declare function contrast(a: string, b: string): number;
57
+ /** Map a theme's roles and kinds into deterministic monochrome steps, patterns and line rhythms. */
58
+ export declare function monoOf(theme: Theme, mode: 'light' | 'dark', use?: {
59
+ roles?: string[];
60
+ kinds?: string[];
61
+ }, own?: MonoTable): MonoLook;
@@ -17,10 +17,12 @@ export interface Theme {
17
17
  name: string;
18
18
  light: Record<string, string>;
19
19
  dark: Record<string, string>;
20
+ /** ants: the dash its connectors march with, where it isn't its dash's own */
20
21
  kinds: Record<string, {
21
22
  color: string;
22
23
  dash: 'solid' | 'dashed' | 'dotted';
23
24
  legend: string;
25
+ ants?: [number, number];
24
26
  }>;
25
27
  roles: Record<string, RawRole>;
26
28
  }
@@ -0,0 +1,34 @@
1
+ import type { CompiledScene } from './compile.js';
2
+ export declare const ANT_SPEED: number;
3
+ export declare const ANT_DASH: Record<string, [number, number]>;
4
+ export declare const ANT_STILL: string[];
5
+ export interface AntsOptions {
6
+ /** how it moves (default: smil); 'none': the dashes, standing still */
7
+ by?: 'css' | 'smil' | 'none';
8
+ /** the connectors that march (default: every one that may) */
9
+ ids?: string[];
10
+ /** units a second, in the drawing's units (default: 32 in 1.1 s) */
11
+ speed?: number;
12
+ dash?: [number, number];
13
+ /** the connectors' dashes, by kind: the theme's `kinds` (a dashed kind marches with its own dash) */
14
+ kinds?: Record<string, {
15
+ dash?: 'solid' | 'dashed' | 'dotted';
16
+ ants?: [number, number];
17
+ }>;
18
+ /** kinds whose connectors stand still (default: blocked, planned) */
19
+ still?: string[];
20
+ }
21
+ /** for 'css': one rule and its keyframes. A page stops them, where they are, with --ants: paused. */
22
+ export declare const ANTS_CSS = "\n.flow.iso-ants{stroke-dasharray:var(--ant-on) var(--ant-off);animation:iso-ants var(--ant-turn) linear infinite;animation-play-state:var(--ants,running)}\n@keyframes iso-ants{to{stroke-dashoffset:var(--ant-to)}}\n";
23
+ /** the dash a connector marches with, or undefined when it stands still */
24
+ export declare function antDash(kind: string, o?: Pick<AntsOptions, 'dash' | 'kinds' | 'still'>): [number, number] | undefined;
25
+ /** what a scene's `ants:` in the file asks for, as options; undefined: none */
26
+ export declare function antsOf(raw: {
27
+ ants?: boolean | string[] | {
28
+ ids?: string[];
29
+ speed?: number;
30
+ dash?: [number, number];
31
+ };
32
+ } | undefined): Pick<AntsOptions, 'ids' | 'speed' | 'dash'> | undefined;
33
+ /** The scene's still, as SVG text, with its connectors marching. */
34
+ export declare function withAnts(scene: Pick<CompiledScene, 'rendered' | 'routes'>, o?: AntsOptions): string;
@@ -5,6 +5,7 @@ import { type RenderedScene } from './scene.js';
5
5
  import { type Routed } from './route.js';
6
6
  import { type Steps } from './steps.js';
7
7
  import { type KindCatalog } from './kinds.js';
8
+ import type { MotionDoc } from './motion-doc.js';
8
9
  import type { GridDef, RawDiagram, Theme } from './types.js';
9
10
  export interface CompiledScene {
10
11
  id: string;
@@ -15,6 +16,8 @@ export interface CompiledScene {
15
16
  rendered: RenderedScene;
16
17
  grid: GridDef;
17
18
  assemble: boolean;
19
+ /** the file's `motion:` on this scene, checked against the drawing (a file with errors in it has none) */
20
+ motion?: MotionDoc;
18
21
  }
19
22
  export interface Compiled {
20
23
  ok: boolean;
@@ -1,4 +1,4 @@
1
- export type { Side, StepRef, RawPlacement, RawDeco, RawNode, RawGate, RawRegion, RawNote, RawScene, GridDef, RawDiagram, RegionKindName, Placed, RawRole, RawKind, Theme } from './types.js';
1
+ export type { Side, StepRef, RawPlacement, RawDeco, RawNode, RawGate, RawRegion, RawNote, RawScene, GridDef, RawDiagram, RegionKindName, Placed, RawRole, RawKind, Theme, RawMotion, RawVariant } from './types.js';
2
2
  export { regionKind, nodeKind, nodeKindOr, wallHeight, kindsCss } from './kinds.js';
3
3
  export type { RegionShape, RegionKind, KindCatalog } from './kinds.js';
4
4
  export { drawDecos, boxAsset, plate, cloudPath, drawCloud, defaultLabel, registerMarks, markCss, iconPainter, facePainter, placeholderIcon } from './assets.js';
@@ -11,6 +11,21 @@ export { silhouette, polyBounds, polyRectArea, rectArea, lineRectArea, Obstacles
11
11
  export type { Rect, Poly, LabelText, PlacedLabel, CalloutSpot } from './labels.js';
12
12
  export { offscreen, assembly } from './assemble.js';
13
13
  export type { Edge, Piece, Assembly } from './assemble.js';
14
+ export { ASSEMBLE_STYLES, DISASSEMBLE_STYLES, MOTION_ORDERS, MOTION_EASINGS, motionModel, motionOrder, planOf, assemble, disassemble, alongPath, svgAt, paint, introSvg } from './motion.js';
15
+ export type { AssembleStyle, DisassembleStyle, MotionOrder, MotionEasing, Direction, PieceMotion, AssembleOptions, DisassembleOptions, PlanOptions, MotionPiece, MotionModel, MotionPlan, ScenePlan, SceneState, ItemState, LabelState, RouteState } from './motion.js';
16
+ export { drawLooks } from './looks.js';
17
+ export { withAnts, antsOf, antDash, ANTS_CSS, ANT_SPEED, ANT_DASH, ANT_STILL } from './ants.js';
18
+ export type { AntsOptions } from './ants.js';
19
+ export { motion, MotionBuilder, SeriesBuilder, NodesBuilder } from './motion-builder.js';
20
+ export type { SequenceOptions, Timing, CameraVerbs, Ids as MotionIds } from './motion-builder.js';
21
+ export { bindMotion, motionOfSteps, motionSource } from './timeline.js';
22
+ export type { Timeline, BindOptions, BeatInfo, Cue, MotionSource } from './timeline.js';
23
+ export { MOTION_SCHEMA } from './motion-schema.js';
24
+ export { EASING_NAMES, EXTRAPOLATE, checkMotion, msOf, readMs, easeOf, curveAt, springAt, bezier } from './motion-doc.js';
25
+ export type { MotionDoc, MotionNode, MotionTime, MotionEase, EasingName, Extrapolate, SpringConfig, Curve, Say as MotionSay, Focus, ReadTime, Sequence, SeriesItem, Transition, MotionDiag } from './motion-doc.js';
26
+ export { resolveSvg, FONT_STACKS } from './resolve.js';
27
+ export { monoOfDrawing, monoTheme, monoCss, paintMono, usedIn } from './mono-paint.js';
28
+ export type { ResolveOptions, ThemeMode } from './resolve.js';
14
29
  export { durationFor, resolveSteps, midpoint } from './steps.js';
15
30
  export type { RawStep, Token, StepData, Say, Mark, Badge, Steps } from './steps.js';
16
31
  export { focusView } from './focus.js';
@@ -0,0 +1,4 @@
1
+ import type { CompiledScene } from './compile.js';
2
+ import type { Theme } from './types.js';
3
+ /** Draw a scene's looks into its `rendered` (none declared: nothing). */
4
+ export declare function drawLooks(s: CompiledScene, theme: Theme): void;
@@ -0,0 +1,20 @@
1
+ import { type Theme } from '../iso-core/theme.js';
2
+ import { type MonoLook, type MonoTable } from '../iso-core/mono.js';
3
+ import type { ThemeMode } from './resolve.js';
4
+ /** the roles and connector kinds a drawing uses */
5
+ export declare function usedIn(svg: string, theme: Theme, kinds: string[]): {
6
+ roles: string[];
7
+ kinds: string[];
8
+ };
9
+ /** the theme in greys, its tokens by the same names, so that everything that names one is grey too */
10
+ export declare function monoTheme(theme: Theme, look: MonoLook): Theme;
11
+ /** what is each role's and each kind's own: the faces' lightnesses, the connectors' rhythms */
12
+ export declare function monoCss(look: MonoLook): string;
13
+ /** The resolved drawing with its patterns, and no hue in it. `id`: the drawing's own (its patterns' ids begin with it). */
14
+ export declare function paintMono(svg: string, look: MonoLook, id: string): string;
15
+ /** Everything a compile needs for the treatment: the look, its theme and its rules. */
16
+ export declare function monoOfDrawing(svg: string, theme: Theme, mode: ThemeMode, kinds: string[], own?: MonoTable): {
17
+ look: MonoLook;
18
+ theme: Theme;
19
+ css: string;
20
+ };
@@ -0,0 +1,105 @@
1
+ import type { Curve, Focus, MotionDoc, MotionEase, MotionNode, MotionTime, ReadTime, Say, Sequence, SeriesItem, Transition } from './motion-doc.js';
2
+ import type { AssembleOptions, DisassembleOptions } from './motion.js';
3
+ export interface Timing {
4
+ from?: MotionTime;
5
+ over?: MotionTime;
6
+ easing?: MotionEase;
7
+ }
8
+ /** a sequence's own keys; `read`: as long as its words take (true, or how) */
9
+ export type SequenceOptions = Omit<Sequence, 'name' | 'children' | 'layers' | 'series' | 'duration'> & {
10
+ duration?: MotionTime;
11
+ read?: ReadTime['read'];
12
+ };
13
+ export type Ids = string | string[];
14
+ export interface CameraVerbs<B> {
15
+ focus(on: Ids | [number, number, number, number], o?: Timing & {
16
+ zoom?: number;
17
+ margin?: number;
18
+ }): B;
19
+ fit(o?: Timing): B;
20
+ }
21
+ /** what is in a sequence (or in a document's layers), in the order it is said */
22
+ export declare class NodesBuilder {
23
+ /** @internal */
24
+ readonly nodes: MotionNode[];
25
+ private add;
26
+ assemble(o?: Omit<AssembleOptions, 'duration'>, t?: Timing): this;
27
+ disassemble(o?: Omit<DisassembleOptions, 'duration'>, t?: Timing): this;
28
+ /** tokens along connectors, one after another; a nested list at once; "id:kind" */
29
+ travel(routes: (string | string[])[], o?: Timing & {
30
+ each?: MotionTime;
31
+ hold?: MotionTime;
32
+ loop?: boolean;
33
+ }): this;
34
+ pulse(ids: Ids, o?: Timing & {
35
+ loop?: boolean;
36
+ }): this;
37
+ ants(ids?: Ids | true, o?: Timing & {
38
+ speed?: number;
39
+ dash?: [number, number];
40
+ }): this;
41
+ draw(routes: Ids, o?: Timing & {
42
+ by?: 'stroke' | 'grow';
43
+ stagger?: MotionTime;
44
+ }): this;
45
+ type(ids: Ids, o?: Timing): this;
46
+ move(id: string, o: {
47
+ from?: MotionTime;
48
+ x?: Curve;
49
+ y?: Curve;
50
+ scale?: Curve;
51
+ opacity?: Curve;
52
+ }): this;
53
+ lift(ids: Ids, by: number, o?: Timing & {
54
+ stagger?: MotionTime;
55
+ to?: 'up' | 'down';
56
+ opacity?: Curve;
57
+ }): this;
58
+ focus(lit: Ids, o?: Timing & Omit<Focus, 'lit'> & {
59
+ fade?: MotionTime;
60
+ }): this;
61
+ highlight(ids: Ids, o?: Timing & {
62
+ fade?: MotionTime;
63
+ }): this;
64
+ /** the view: on a thing, some things or a box; or the whole drawing again */
65
+ get camera(): CameraVerbs<this>;
66
+ /** a sequence in this one: a clock of its own, from `from` */
67
+ sequence(name: string | undefined, o?: SequenceOptions, fill?: (b: NodesBuilder) => unknown): this;
68
+ /** sequences one after another */
69
+ series(fill: (s: SeriesBuilder) => unknown): this;
70
+ /** nodes over one another */
71
+ layers(fill: (b: NodesBuilder) => unknown): this;
72
+ }
73
+ export declare class SeriesBuilder {
74
+ /** @internal */
75
+ readonly items: SeriesItem[];
76
+ sequence(name: string | undefined, o?: SequenceOptions, fill?: (b: NodesBuilder) => unknown): this;
77
+ transition(t: Transition): this;
78
+ }
79
+ export declare class MotionBuilder extends SeriesBuilder {
80
+ private over;
81
+ private marks;
82
+ private head;
83
+ constructor(head?: {
84
+ fps?: number;
85
+ seed?: number;
86
+ ambient?: 'on' | 'off';
87
+ });
88
+ /** a beat: a sequence with commentary */
89
+ beat(name: string, say: Say, o?: SequenceOptions, fill?: (b: NodesBuilder) => unknown): this;
90
+ /** the whole drawing arrives (a sequence as long as that takes) */
91
+ assemble(o?: Omit<AssembleOptions, 'duration'>, t?: Timing): this;
92
+ /** the whole drawing leaves */
93
+ disassemble(o?: Omit<DisassembleOptions, 'duration'>, t?: Timing): this;
94
+ /** a name for a moment: ms, or "beat+1200" */
95
+ mark(name: string, at: MotionTime): this;
96
+ /** nodes over the whole document, on its own clock */
97
+ layers(fill: (b: NodesBuilder) => unknown): this;
98
+ toJSON(): MotionDoc;
99
+ }
100
+ /** Start a motion document. */
101
+ export declare const motion: (head?: {
102
+ fps?: number;
103
+ seed?: number;
104
+ ambient?: 'on' | 'off';
105
+ }) => MotionBuilder;