@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,202 @@
1
+ import type { CompiledScene } from './compile.js';
2
+ import type { RawMotion } from './types.js';
3
+ import { type Assembly } from './assemble.js';
4
+ import { type Rect } from './labels.js';
5
+ export declare const ASSEMBLE_STYLES: readonly ['edge', 'drop', 'rise', 'fly', 'pop', 'scatter', 'build', 'fade'];
6
+ export declare const DISASSEMBLE_STYLES: readonly ['explode', 'lift-off', 'sink', 'scatter', 'fly-out', 'collapse', 'fade', 'reverse'];
7
+ export declare const MOTION_ORDERS: readonly ['by-depth', 'by-layer', 'by-region', 'by-flow', 'as-listed', 'random'];
8
+ export declare const MOTION_EASINGS: readonly ['linear', 'ease', 'ease-in', 'ease-out', 'settle', 'spring', 'bounce'];
9
+ export type AssembleStyle = typeof ASSEMBLE_STYLES[number];
10
+ export type DisassembleStyle = typeof DISASSEMBLE_STYLES[number];
11
+ export type MotionOrder = typeof MOTION_ORDERS[number];
12
+ export type MotionEasing = typeof MOTION_EASINGS[number];
13
+ export type Direction = 'left' | 'right' | 'top' | 'bottom';
14
+ /** what one piece's (or a region's contents') `motion:` in the file may say */
15
+ export type PieceMotion = RawMotion;
16
+ interface CommonOptions {
17
+ order?: MotionOrder;
18
+ /** where by-flow starts: a piece's id (default: the first piece no connector ends at) */
19
+ source?: string;
20
+ connectors?: 'draw' | 'grow' | 'fade';
21
+ /** after the connectors are in (before they go): a token runs along each, once */
22
+ pulses?: boolean;
23
+ labels?: 'fade' | 'type' | 'with-piece';
24
+ /** the whole plan's length, ms: everything is scaled to it (default: as long as it comes to) */
25
+ duration?: number;
26
+ /** ms between one piece's start and the next's */
27
+ stagger?: number;
28
+ /** ms one piece's move takes */
29
+ piece?: number;
30
+ /** how much of the next part (pieces, connectors, labels) runs over the end of the one before, 0 to 1 */
31
+ overlap?: number;
32
+ easing?: MotionEasing;
33
+ /** fly, fly-out: the side it comes from or goes to */
34
+ from?: Direction;
35
+ seed?: number;
36
+ }
37
+ export interface AssembleOptions extends CommonOptions {
38
+ style?: AssembleStyle;
39
+ }
40
+ export interface DisassembleOptions extends CommonOptions {
41
+ style?: DisassembleStyle;
42
+ /** explode, collapse: the point (in the drawing's units), or a piece's id (default: the drawing's middle; collapse
43
+ * into the region that holds each piece: 'region') */
44
+ point?: [number, number] | string;
45
+ /** reverse: the assemble style it plays backwards */
46
+ of?: AssembleStyle;
47
+ }
48
+ export interface MotionPiece {
49
+ id: string;
50
+ kind: 'region' | 'node';
51
+ parent?: string;
52
+ depth: number;
53
+ layer: number;
54
+ key: number;
55
+ bbox: Rect;
56
+ /** the middle of its footprint, and its bottom outline (left, front, right corner), in the drawing's units */
57
+ foot: [number, number];
58
+ base: [number, number][];
59
+ motion?: PieceMotion;
60
+ }
61
+ export interface MotionModel {
62
+ viewBox: [number, number, number, number];
63
+ pieces: MotionPiece[];
64
+ routes: {
65
+ id: string;
66
+ path: string;
67
+ from?: string;
68
+ to?: string;
69
+ }[];
70
+ /** notes' ids and what they are on (a piece or a route) */
71
+ notes: Record<string, string | undefined>;
72
+ /** the build-time intro's own timing (`edge` with no other timing given plays exactly it) */
73
+ intro: Assembly;
74
+ }
75
+ export declare function motionModel(s: CompiledScene): MotionModel;
76
+ /** a thing's block, walls, gate and name: what is not given is as in the still */
77
+ export interface ItemState {
78
+ opacity?: number;
79
+ /** in the drawing's units */
80
+ dx?: number;
81
+ dy?: number;
82
+ /** about `about` (default: the drawing's origin) */
83
+ scale?: number;
84
+ about?: [number, number];
85
+ /** only what is inside this shows (a polygon, before the offset) */
86
+ clip?: [number, number][];
87
+ }
88
+ /** a label or a note: faded, or typed so far (0 to 1) */
89
+ export interface LabelState {
90
+ opacity?: number;
91
+ typed?: number;
92
+ dx?: number;
93
+ dy?: number;
94
+ }
95
+ /** a connector: how much of it is drawn (0 to 1: its arrowhead shows at 1), stroked in, or growing from its source */
96
+ export interface RouteState {
97
+ opacity?: number;
98
+ drawn?: number;
99
+ by?: 'stroke' | 'grow';
100
+ /** (a timeline's) marching dashes: on and off, and how far they have marched, in the drawing's units along it */
101
+ ants?: {
102
+ dash: [number, number];
103
+ offset: number;
104
+ };
105
+ }
106
+ /** Plain JSON. Empty: the still render. What isn't named is as in the still. */
107
+ export interface SceneState {
108
+ items?: Record<string, ItemState>;
109
+ /** by the id of a thing, a connector or a note */
110
+ labels?: Record<string, LabelState>;
111
+ routes?: Record<string, RouteState>;
112
+ /** by the id of a thing: how much of each of its looks is there (the rest is its own), 0 to 1 */
113
+ variants?: Record<string, Record<string, number>>;
114
+ /** the step marks' and badges' layers */
115
+ marks?: {
116
+ opacity: number;
117
+ };
118
+ /** a token on a connector, a fraction (0 to 1) of the way along it */
119
+ tokens?: {
120
+ route: string;
121
+ at: number;
122
+ color?: string;
123
+ kind?: string;
124
+ }[];
125
+ /** a ring round a point */
126
+ pulses?: {
127
+ x: number;
128
+ y: number;
129
+ rx: number;
130
+ ry: number;
131
+ opacity?: number;
132
+ color?: string;
133
+ }[];
134
+ /** (a timeline's) an outline round a thing: its silhouette */
135
+ outlines?: {
136
+ id: string;
137
+ points: [number, number][];
138
+ opacity?: number;
139
+ color?: string;
140
+ }[];
141
+ /** the view, in the drawing's units */
142
+ camera?: [number, number, number, number];
143
+ /** how far toward the 2D view (0 to 1): a morph's, for a host that draws one; svgAt and paint draw the 3D view */
144
+ morph?: number;
145
+ }
146
+ export interface MotionPlan {
147
+ kind: 'assemble' | 'disassemble';
148
+ /** ms */
149
+ duration: number;
150
+ /** when each piece moves, in the order it does */
151
+ pieces: {
152
+ id: string;
153
+ delay: number;
154
+ dur: number;
155
+ style: string;
156
+ }[];
157
+ routes: {
158
+ id: string;
159
+ delay: number;
160
+ dur: number;
161
+ }[];
162
+ labels: {
163
+ delay: number;
164
+ dur: number;
165
+ };
166
+ /** what the scene looks like at t ms: plain JSON, the same for the same t */
167
+ at(t: number): SceneState;
168
+ }
169
+ export interface ScenePlan extends MotionPlan {
170
+ /** the scene's SVG at t ms, as text: svgAt(scene, at(t)) */
171
+ frame(t: number): string;
172
+ }
173
+ /** the order the pieces move in: what they stand on, or are in, never after them (but as-listed and random) */
174
+ export declare function motionOrder(m: MotionModel, order: MotionOrder, o?: {
175
+ seed?: number;
176
+ source?: string;
177
+ }): MotionPiece[];
178
+ /** either's options: the style is the plan's own kind's */
179
+ export type PlanOptions = Omit<AssembleOptions & DisassembleOptions, 'style'> & {
180
+ style?: AssembleStyle | DisassembleStyle;
181
+ };
182
+ type AnyOptions = PlanOptions;
183
+ export declare function planOf(m: MotionModel, kind: 'assemble' | 'disassemble', opts?: AnyOptions): MotionPlan;
184
+ /** a point a fraction of the way along an SVG polyline path ("M x,y L x,y …") */
185
+ export declare function alongPath(d: string, f: number): [number, number];
186
+ /** the start of a text run: an entity counts as one character */
187
+ export declare function typed(s: string, f: number): string;
188
+ type Looks = Pick<CompiledScene['rendered'], 'svg' | 'variants' | 'looks' | 'inks'>;
189
+ /** A scene as it looks in a state, as SVG text. An empty state is the still render itself, byte for byte. */
190
+ export declare function svgAt(scene: Pick<CompiledScene, 'rendered' | 'id'>, S: SceneState): string;
191
+ /** The same on a live drawing (a scene's own <svg>). Idempotent, in any order: what the last state changed is put back
192
+ * first, so the same state gives the same DOM; an empty state gives the still back. */
193
+ export declare function paint(svg: SVGSVGElement, S: SceneState, rendered?: Looks, o?: {
194
+ styles?: 'attribute' | 'cssom';
195
+ }): void;
196
+ /** the drawing arrives: frame(0) is empty, frame(duration) is the still render */
197
+ export declare const assemble: (s: CompiledScene, o?: AssembleOptions) => ScenePlan;
198
+ /** the drawing leaves: frame(0) is the still render, frame(duration) is empty */
199
+ export declare const disassemble: (s: CompiledScene, o?: DisassembleOptions) => ScenePlan;
200
+ /** A frame of the page's intro (the default assemble) at t ms, as SVG text. */
201
+ export declare const introSvg: (s: CompiledScene, t: number) => string;
202
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { Theme } from './types.js';
2
+ export type ThemeMode = 'light' | 'dark';
3
+ export interface ResolveOptions {
4
+ mode: ThemeMode;
5
+ theme: Theme;
6
+ /** the drawing's stylesheets, in order, after the theme's */
7
+ css: string;
8
+ /** the fonts the texts ask for (a stack each) */
9
+ fonts?: {
10
+ sans: string;
11
+ mono: string;
12
+ };
13
+ }
14
+ export declare const FONT_STACKS: {
15
+ sans: string;
16
+ mono: string;
17
+ };
18
+ /** The drawing, self-contained, in one of its theme's modes. What its stylesheets hide is left out of the paint (display
19
+ * none); ids, classes and data- attributes stay. */
20
+ export declare function resolveSvg(svg: string, o: ResolveOptions): string;
@@ -1,3 +1,4 @@
1
+ import type { MonoLook } from '../iso-core/mono.js';
1
2
  import { type Box } from '../iso-core/kernel.js';
2
3
  import { type KindCatalog } from './kinds.js';
3
4
  import { type Layout } from './place.js';
@@ -26,6 +27,19 @@ export interface RenderedScene {
26
27
  paths: Record<string, string>;
27
28
  /** things drawn worse than asked, e.g. a route label shortened or dropped */
28
29
  warnings: RenderWarning[];
30
+ /** (0.15.0) a self-contained drawing's own colours, for what a state adds to it (a token's rim and fill) */
31
+ inks?: {
32
+ surface: string;
33
+ control: string;
34
+ kinds?: Record<string, string>;
35
+ };
36
+ /** (0.16.0) its black and white table, when it is in that treatment */
37
+ mono?: MonoLook;
38
+ /** the drawing with every thing that has a look of this name in it, as SVG text (what a switch takes the thing's parts from);
39
+ * none when nothing declares one */
40
+ variants?: Record<string, string>;
41
+ /** the looks each thing declares */
42
+ looks?: Record<string, string[]>;
29
43
  /** the assemble intro's timeline */
30
44
  assembly: Assembly;
31
45
  /** callout pills in screen px, per step, for layout tests */
@@ -0,0 +1,66 @@
1
+ import type { CompiledScene } from './compile.js';
2
+ import { antsOf } from './ants.js';
3
+ import { type MotionModel, type SceneState } from './motion.js';
4
+ import { type MotionDiag, type MotionDoc, type Say } from './motion-doc.js';
5
+ export interface BeatInfo {
6
+ name: string;
7
+ index: number;
8
+ start: number;
9
+ end: number;
10
+ say?: Say;
11
+ }
12
+ export interface Cue {
13
+ beat: string;
14
+ chapter?: string;
15
+ index: number;
16
+ of: number;
17
+ progress: number;
18
+ say?: Say;
19
+ color?: string;
20
+ }
21
+ export interface Timeline {
22
+ readonly ok: boolean;
23
+ readonly diags: MotionDiag[];
24
+ /** ms */
25
+ readonly duration: number;
26
+ readonly beats: BeatInfo[];
27
+ readonly markers: Record<string, number>;
28
+ /** the document's own `ambient`: what at(ms) does with none given */
29
+ readonly ambient: 'on' | 'off';
30
+ /** whether anything in it runs on the ambient clock (ants, looping tokens and pulses): a host with none needs no frames while paused */
31
+ readonly loops: boolean;
32
+ /** what the drawing looks like at ms. `ambient`: the ambient clock's time (default: the same; a host that stopped it passes the time it
33
+ * stopped at, and what loops stands where it was), or 'off': it never ran, and each loop stands at its start */
34
+ at(ms: number, o?: {
35
+ ambient?: number | 'off';
36
+ }): SceneState;
37
+ cues(ms: number): Cue | undefined;
38
+ beatAt(ms: number): BeatInfo | undefined;
39
+ startOf(name: string): number | undefined;
40
+ }
41
+ export interface BindOptions {
42
+ /** the connectors' dashes, by kind: the theme's `kinds` (a dashed kind marches with its own dash) */
43
+ kinds?: Record<string, {
44
+ dash?: 'solid' | 'dashed' | 'dotted';
45
+ ants?: [number, number];
46
+ }>;
47
+ /** kinds whose connectors stand still (default: blocked, planned) */
48
+ still?: string[];
49
+ }
50
+ /** What binding needs to know of a drawing, as plain JSON: for a page that has the drawing and no compiler. */
51
+ export interface MotionSource {
52
+ model: MotionModel;
53
+ /** each connector's kind */
54
+ kinds: Record<string, string>;
55
+ /** each thing's outline */
56
+ outlines: Record<string, [number, number][]>;
57
+ /** the looks each thing declares */
58
+ looks?: Record<string, string[]>;
59
+ ants?: ReturnType<typeof antsOf>;
60
+ /** the notes on nothing (JSON keeps no undefined) */
61
+ free?: string[];
62
+ }
63
+ export declare function motionSource(scene: CompiledScene): MotionSource;
64
+ export declare function bindMotion(drawing: CompiledScene | MotionSource, doc: MotionDoc, opts?: BindOptions): Timeline;
65
+ /** A drawing's own steps as a motion document, so that every drawing with steps has a timeline. */
66
+ export declare function motionOfSteps(scene: CompiledScene): MotionDoc;
@@ -3,6 +3,16 @@ import type { RawRole, RawKind, Theme } from '../iso-core/theme.js';
3
3
  export type { RawRole, RawKind, Theme };
4
4
  export type Side = 'n' | 'e' | 's' | 'w';
5
5
  export type StepRef = string | number;
6
+ /** how one piece (and, a region's, its contents) moves when a drawing assembles or disassembles (motion.ts) */
7
+ export interface RawMotion {
8
+ style?: 'edge' | 'drop' | 'rise' | 'fly' | 'pop' | 'scatter' | 'build' | 'fade';
9
+ out?: 'explode' | 'lift-off' | 'sink' | 'scatter' | 'fly-out' | 'collapse' | 'fade' | 'reverse';
10
+ easing?: 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'settle' | 'spring' | 'bounce';
11
+ from?: 'left' | 'right' | 'top' | 'bottom';
12
+ /** ms after its turn, and ms its own move takes */
13
+ delay?: number;
14
+ duration?: number;
15
+ }
6
16
  export interface RawPlacement {
7
17
  in?: string;
8
18
  at?: [number, number];
@@ -39,6 +49,18 @@ export interface RawNode extends RawPlacement {
39
49
  dy?: number;
40
50
  };
41
51
  nodes?: RawNode[];
52
+ motion?: RawMotion;
53
+ /** other looks of it, by name, for a motion to switch to: its own keys, over what it is */
54
+ variants?: Record<string, RawVariant>;
55
+ }
56
+ /** what a look may change: never the thing's box, so nothing else moves */
57
+ export interface RawVariant {
58
+ role?: string;
59
+ ghost?: boolean;
60
+ label?: string;
61
+ sub?: string;
62
+ face?: string;
63
+ deco?: RawDeco[];
42
64
  }
43
65
  export interface RawGate {
44
66
  side: Side;
@@ -63,6 +85,8 @@ export interface RawRegion extends RawPlacement {
63
85
  around?: string[];
64
86
  regions?: RawRegion[];
65
87
  nodes?: RawNode[];
88
+ motion?: RawMotion;
89
+ variants?: Record<string, RawVariant>;
66
90
  }
67
91
  export interface RawNote {
68
92
  floor?: string;
@@ -98,6 +122,14 @@ export interface RawScene {
98
122
  grid?: GridDef;
99
123
  assemble?: boolean;
100
124
  dim?: 'flows' | 'all';
125
+ /** the scene's motion document (its `isomotion: 1` may be left out) */
126
+ motion?: Record<string, unknown>;
127
+ /** its connectors march: all that may, these, or these with a speed and a dash (ants.ts) */
128
+ ants?: boolean | string[] | {
129
+ ids?: string[];
130
+ speed?: number;
131
+ dash?: [number, number];
132
+ };
101
133
  }
102
134
  export interface GridDef {
103
135
  snap?: number;
@@ -116,6 +148,8 @@ export interface RawDiagram {
116
148
  footer?: string;
117
149
  grid?: GridDef;
118
150
  assemble?: boolean;
151
+ /** how a self-contained drawing of it is painted, where the host doesn't say */
152
+ treatment?: 'mono';
119
153
  scenes: RawScene[];
120
154
  }
121
155
  /** a region kind's name in the catalogue the drawing is laid out with (src/iso-objects/kinds.ts) */
@@ -1,6 +1,28 @@
1
+ import type { Diag } from '../iso-core/errors.js';
1
2
  import { type Compiled } from '../iso-objects/compile.js';
3
+ import { type ThemeMode } from '../iso-objects/resolve.js';
4
+ import type { MonoTable } from '../iso-core/mono.js';
2
5
  export type { Compiled, CompiledScene } from '../iso-objects/compile.js';
3
- /** opts.snap overrides every scene's grid snap (the editor's snap control). */
4
- export declare function compile(source: string, themeText: string, opts?: {
6
+ export interface CompileOptions {
7
+ /** overrides every scene's grid snap (the editor's snap control) */
5
8
  snap?: number;
6
- }): Compiled;
9
+ /** which of the theme's modes a self-contained drawing is in (default: light) */
10
+ mode?: ThemeMode;
11
+ /** (0.15.0) self-contained drawings: each scene's SVG has its colours and text styles on its elements, in `mode`: no
12
+ * stylesheet, no custom properties, no hsl() or color-mix() (svgAt's frames too) */
13
+ resolveVars?: boolean;
14
+ /** (0.16.0) a self-contained drawing in black and white, in either mode: greys, patterns and line rhythms, and no hue */
15
+ treatment?: 'mono' | 'none';
16
+ /** a host's own table, over the treatment's */
17
+ mono?: MonoTable;
18
+ /** a file with an error draws nothing: `scenes` is empty (true), or it throws ('throw'). Default: what could be laid
19
+ * out is in `scenes` all the same, with `ok` false */
20
+ strict?: boolean | 'throw';
21
+ /** ms each step lasts, for a video (default: by the length of its words) */
22
+ stepMs?: number;
23
+ }
24
+ export declare class CompileError extends Error {
25
+ diags: Diag[];
26
+ constructor(diags: Diag[]);
27
+ }
28
+ export declare function compile(source: string, themeText: string, opts?: CompileOptions): Compiled;
@@ -1,5 +1,8 @@
1
1
  export { NODE_ASSETS, getAsset } from './nodes.js';
2
2
  export { REGION_KINDS, systems } from './catalog.js';
3
3
  export { DRAWING_CSS, BASE_CSS } from './css.js';
4
- export { compile } from './compile.js';
4
+ export { compile, CompileError } from './compile.js';
5
+ export type { CompileOptions } from './compile.js';
6
+ export { renderSvg } from './render.js';
7
+ export type { RenderSvgOptions } from './render.js';
5
8
  export type { Compiled, CompiledScene } from './compile.js';
@@ -0,0 +1,25 @@
1
+ import { type AntsOptions } from '../iso-objects/ants.js';
2
+ import type { MotionDoc } from '../iso-objects/motion-doc.js';
3
+ import type { MonoTable } from '../iso-core/mono.js';
4
+ import type { ThemeMode } from '../iso-objects/resolve.js';
5
+ export interface RenderSvgOptions {
6
+ /** the theme's text */
7
+ theme: string;
8
+ mode?: ThemeMode;
9
+ /** black and white, in either mode, and a host's own table for it */
10
+ treatment?: 'mono' | 'none';
11
+ mono?: MonoTable;
12
+ /** which scene: its id or its place (default: the first) */
13
+ scene?: string | number;
14
+ /** a moment of its motion, ms: the still without it */
15
+ t?: number;
16
+ /** the motion (default: the scene's own in the file) */
17
+ motion?: MotionDoc;
18
+ /** the ambient clock at that moment (default: t), or 'off': what loops stands at its start (a still's ants too) */
19
+ ambient?: number | 'off';
20
+ /** the still's connectors march, by an animation in the SVG itself (default: as the scene's `ants:` in the file says; a
21
+ * frame's are its motion's, and where that says nothing, the file's) */
22
+ ants?: boolean | Omit<AntsOptions, 'by' | 'kinds'>;
23
+ }
24
+ /** Throws, with every fault and its line, when the file or its motion has one. */
25
+ export declare function renderSvg(source: string, o: RenderSvgOptions): string;
@@ -8,6 +8,10 @@ export { n, node, rewrite, prune, cls, attr, extent, unite, fitWithOverlay } fro
8
8
  export { isoVars, scopeSelector, scope } from './view-css.js';
9
9
  export { md, stepData, legend, renderPage } from './page.js';
10
10
  export type { PageOpts } from './page.js';
11
+ export { transport, pageClock } from './transport.js';
12
+ export type { Transport, TransportClock, TransportEvents, TransportOptions } from './transport.js';
13
+ export { mountPlayer, PLAY_CSS } from './play.js';
14
+ export type { Player, PlayerOptions } from './play.js';
11
15
  export { h } from './dom.js';
12
16
  export { TIMELINE_VERSION, SEGMENT_NAME, SEVERITIES, BINS, BIN_MS, scopePattern } from './timeline-contract.js';
13
17
  export type { TimelineTypes, AnyTimeline, Scope, Severity, AttrValue, TimelineEvent, Bin, MetricPoint, MetricRollup, EventBin, Match, AstTerm, SearchAst, Days, Retention, SeriesInfo, KindInfo, SourceInfo, EffectiveRetention, ScopeName, Catalog, Filters, Query, Row, Result, Batch, View as TimelineView, Recording, TimelineSource, TimelineCatalog } from './timeline-contract.js';
@@ -0,0 +1,37 @@
1
+ import type { CompiledScene } from '../iso-objects/compile.js';
2
+ import type { Timeline } from '../iso-objects/timeline.js';
3
+ import { type Transport, type TransportClock } from './transport.js';
4
+ export interface PlayerOptions {
5
+ scene: Pick<CompiledScene, 'rendered' | 'id'>;
6
+ /** none: the drawing alone, with nothing to play */
7
+ timeline?: Timeline;
8
+ /** what a screen reader calls it */
9
+ label?: string;
10
+ /** the controls and the commentary (default true): without them, the drawing alone */
11
+ controls?: boolean;
12
+ /** start at once, or each time most of it is in view (default: neither) */
13
+ autoplay?: boolean | 'visible';
14
+ loop?: boolean;
15
+ rate?: number;
16
+ ambient?: 'on' | 'off';
17
+ /** a reader who asked for less motion (default 'ignore': motion plays). 'respect': the last state, everything lit, the ambient off, until they press Play */
18
+ reducedMotion?: 'ignore' | 'respect';
19
+ mode?: 'light' | 'dark';
20
+ /** the timeline is the drawing's own steps (motionOfSteps): its callouts and marks show at their step, and the other steps' numbers dim */
21
+ steps?: boolean;
22
+ clock?: TransportClock;
23
+ }
24
+ export interface Player {
25
+ readonly root: HTMLElement;
26
+ readonly transport: Transport;
27
+ /** another drawing, or another document: the place is kept (transport's rebind). Faults are refused, and what plays goes on */
28
+ set(scene: Pick<CompiledScene, 'rendered' | 'id'>, timeline?: Timeline, mode?: 'light' | 'dark'): boolean;
29
+ /** show one moment, still: no clock, no controls (a screenshot, a link) */
30
+ freeze(ms: number): void;
31
+ /** to a beat and through it, stopping before the next */
32
+ step(beat: number): void;
33
+ dispose(): void;
34
+ }
35
+ export declare function mountPlayer(host: HTMLElement | ShadowRoot, o: PlayerOptions): Player;
36
+ /** The player's stylesheet: its own, under one class; the colours are custom properties a host may set. */
37
+ export declare const PLAY_CSS = "\n.iso-play{--ip-ink:#1c2026;--ip-muted:#68707c;--ip-line:#dfe3e8;--ip-bg:#fff;--ip-code:#f2f4f7;--ip-focus:#2a64d6;container:iso-play/inline-size;display:block;color:var(--ip-ink);background:var(--ip-bg);font:14px/1.5 system-ui,-apple-system,\"Segoe UI\",sans-serif;border-radius:10px}\n.iso-play[data-mode=\"dark\"]{--ip-ink:#e6e9ee;--ip-muted:#98a1ae;--ip-line:#333a44;--ip-bg:#15181d;--ip-code:#1f242b;--ip-focus:#7aa7ff;color-scheme:dark}\n.iso-play:focus-visible,.iso-play button:focus-visible,.iso-play input:focus-visible,.iso-play summary:focus-visible{outline:2px solid var(--ip-focus);outline-offset:2px}\n.iso-play [hidden]{display:none}\n.iso-play-stage svg{display:block;width:100%;height:auto}\n.iso-play-stage [data-go]{cursor:pointer}\n.iso-play-row{display:flex;align-items:center;gap:6px;padding:8px 12px 4px}\n.iso-play-btn{font:inherit;min-width:32px;height:32px;padding:0 8px;border:1px solid var(--ip-line);border-radius:8px;background:none;color:inherit;cursor:pointer}\n.iso-play-btn:hover{border-color:var(--ip-muted)}\n.iso-play-btn.play{background:var(--ip-ink);color:var(--ip-bg);border-color:var(--ip-ink);min-width:44px}\n.iso-play-btn.ambient[aria-pressed=\"false\"]{color:var(--ip-muted);text-decoration:line-through}\n.iso-play-bar{flex:1 1 60px;min-width:0;accent-color:var(--ip-ink)}\n.iso-play-time{color:var(--ip-muted);font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}\n.iso-play-dots{display:flex;flex-wrap:wrap;gap:4px 12px;padding:2px 12px}\n.iso-play-group{display:inline-flex;gap:0}\n.iso-play-dot{width:24px;height:24px;padding:0;border:0;background:none;cursor:pointer;display:grid;place-items:center}\n.iso-play-dot::before{content:\"\";width:9px;height:9px;border-radius:50%;background:var(--ip-line)}\n.iso-play-dot.done::before{background:var(--ip-muted)}\n.iso-play-dot.on::before{background:var(--ip-ink);width:11px;height:11px}\n.iso-play-say{padding:4px 12px 10px;min-height:5.2em}\n.iso-play-head{display:flex;align-items:baseline;gap:8px;font-weight:700}\n.iso-play-num{flex:none;display:inline-grid;place-items:center;min-width:22px;height:22px;border-radius:11px;background:var(--ip-ink);color:var(--ip-bg);font-size:11px;align-self:center}\n.iso-play-chapter,.iso-play-count{color:var(--ip-muted);font-size:12px;font-weight:500}\n.iso-play-count{margin-left:auto;white-space:nowrap}\n.iso-play-text{max-width:80ch}\n.iso-play-text a{color:inherit}\n.iso-play-code{margin:6px 0 0;padding:6px 10px;border-radius:8px;background:var(--ip-code);font:12px/1.5 ui-monospace,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere}\n.iso-play-facts{display:flex;flex-wrap:wrap;gap:2px 16px;margin:6px 0 0;font-size:12px}\n.iso-play-facts dt{color:var(--ip-muted)}\n.iso-play-facts dd{margin:0 8px 0 -10px;font-weight:600}\n.iso-play-list{padding:0 12px 10px;font-size:13px}\n.iso-play-list summary{color:var(--ip-muted);cursor:pointer}\n.iso-play.frozen>:not(.iso-play-stage){display:none}\n@container iso-play (max-width:420px){.iso-play-time{display:none}.iso-play-row{flex-wrap:wrap}.iso-play-bar{flex-basis:100%;order:9}}\n";
@@ -0,0 +1,73 @@
1
+ import type { BeatInfo, Cue, Timeline } from '../iso-objects/timeline.js';
2
+ import type { SceneState } from '../iso-objects/motion.js';
3
+ export interface TransportClock {
4
+ /** ms, going only forward */
5
+ now(): number;
6
+ /** call f soon, once: the next frame; returns what cancel takes */
7
+ next(f: () => void): unknown;
8
+ cancel(id: unknown): void;
9
+ }
10
+ export interface TransportOptions {
11
+ /** start again at the end (default false) */
12
+ loop?: boolean;
13
+ /** how fast (default 1) */
14
+ rate?: number;
15
+ /** default: the document's own */
16
+ ambient?: 'on' | 'off';
17
+ clock?: TransportClock;
18
+ }
19
+ export interface TransportEvents {
20
+ /** the drawing is to be painted again: T (ms), and why */
21
+ time: (ms: number, why: 'play' | 'ambient' | 'seek' | 'rebind') => void;
22
+ play: () => void;
23
+ pause: () => void;
24
+ /** it came to its end and stopped (not at each turn of a loop: that is 'loop') */
25
+ end: () => void;
26
+ loop: () => void;
27
+ /** 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 */
28
+ beat: (beat: BeatInfo, how: 'play' | 'seek' | 'rebind') => void;
29
+ ambient: (on: boolean) => void;
30
+ rate: (rate: number) => void;
31
+ }
32
+ export interface Transport {
33
+ readonly timeline: Timeline;
34
+ readonly duration: number;
35
+ /** T, ms */
36
+ readonly time: number;
37
+ /** A, ms, or 'off' when it never ran: what at()'s `ambient` takes */
38
+ readonly ambientTime: number | 'off';
39
+ readonly playing: boolean;
40
+ readonly beat: BeatInfo | undefined;
41
+ readonly cue: Cue | undefined;
42
+ rate: number;
43
+ loop: boolean;
44
+ ambient: boolean;
45
+ /** whether the host shows it now (default true): while false neither clock moves, playing or not */
46
+ active: boolean;
47
+ /** what the drawing looks like now */
48
+ state(): SceneState;
49
+ /** until: pause there (a time still ahead) */
50
+ play(o?: {
51
+ until?: number;
52
+ }): void;
53
+ pause(): void;
54
+ toggle(): void;
55
+ /** join: the ambient clock at that time too (a step taken: what loops starts with it), where the ambient is on */
56
+ seek(ms: number, o?: {
57
+ join?: boolean;
58
+ }): void;
59
+ /** to a beat's start, by its name or its index; whether there is one */
60
+ seekBeat(beat: string | number): boolean;
61
+ /** to the next beat's start, or the end; to this beat's start, or the one before when nearly there */
62
+ next(): void;
63
+ prev(): void;
64
+ restart(): void;
65
+ /** 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 */
66
+ rebind(tl: Timeline): boolean;
67
+ /** returns how to stop listening */
68
+ on<K extends keyof TransportEvents>(event: K, f: TransportEvents[K]): () => void;
69
+ dispose(): void;
70
+ }
71
+ /** the page's clock: frames, and a timer behind them, so it also goes on where no frames are drawn (a page not shown) */
72
+ export declare function pageClock(): TransportClock;
73
+ export declare function transport(tl0: Timeline, o?: TransportOptions): Transport;
@@ -0,0 +1,24 @@
1
+ import type { MotionDoc } from '../iso-objects/motion-doc.js';
2
+ import type { Transport } from '../iso-viewer/transport.js';
3
+ /** a page with no DOM (a server that imports this) has no elements: the class is there, and does nothing */
4
+ declare const Base: typeof HTMLElement;
5
+ export declare class IsometricDiagram extends Base {
6
+ #private;
7
+ static readonly observedAttributes: string[];
8
+ /** the drawing's text: the property when set, else what is written in the element */
9
+ get source(): string;
10
+ set source(v: string);
11
+ /** the theme's text (default: the engine's) */
12
+ get theme(): string;
13
+ set theme(v: string | undefined);
14
+ /** the motion (default: the scene's own in the file, or its steps) */
15
+ get motion(): MotionDoc | undefined;
16
+ set motion(v: MotionDoc | undefined);
17
+ /** once drawn: play, pause, seek, beats, the ambient switch */
18
+ get transport(): Transport | undefined;
19
+ connectedCallback(): void;
20
+ disconnectedCallback(): void;
21
+ attributeChangedCallback(name: string, was: string | null, now: string | null): void;
22
+ }
23
+ export { mountPlayer, PLAY_CSS } from '../iso-viewer/play.js';
24
+ export type { Player, PlayerOptions } from '../iso-viewer/play.js';