@phin-tech/dottie 0.7.0 → 0.9.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/PARITY.md +10 -7
- package/README.md +10 -2
- package/dist/compile.js +103 -11
- package/dist/dottie-compile.mjs +104 -12
- package/dist/dottie-player.js +1316 -100
- package/dist/dottie-player.min.js +55 -52
- package/dist/dottie-sim.min.js +4 -0
- package/dist/dottie.js +1300 -100
- package/dist/types/clicks.d.ts +1 -0
- package/dist/types/compile.d.ts +1 -1
- package/dist/types/connector.d.ts +4 -0
- package/dist/types/flows.d.ts +28 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/measure.d.ts +73 -0
- package/dist/types/model.d.ts +66 -0
- package/dist/types/planner.d.ts +12 -0
- package/dist/types/player.d.ts +21 -1
- package/dist/types/sim-entry.d.ts +1 -0
- package/dist/types/state.d.ts +28 -8
- package/dist/types/svg.d.ts +9 -2
- package/dist/types/symbols.d.ts +19 -3
- package/dist/types/timeline.d.ts +14 -4
- package/package.json +1 -1
package/dist/types/clicks.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type Click = ({
|
|
|
13
13
|
}) & {
|
|
14
14
|
set?: Record<string, boolean>;
|
|
15
15
|
toggle?: string[];
|
|
16
|
+
reset?: true;
|
|
16
17
|
};
|
|
17
18
|
/** The marker called `name`: an exact match, else one that differs only in case. */
|
|
18
19
|
export declare function sceneNamed(name: string, markers: Marker[]): number;
|
package/dist/types/compile.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Face } from "./metrics.ts";
|
|
2
|
-
/** What follows the runtime; DOTTIE_DATA and
|
|
2
|
+
/** What follows the runtime; DOTTIE_DATA, DOTTIE_OPTIONS and DOTTIE_FONTS are replaced with JSON. Plain ES5, unminified. */
|
|
3
3
|
export declare const LOADER = ";(function () {\n var data = DOTTIE_DATA, options = DOTTIE_OPTIONS, fonts = DOTTIE_FONTS;\n var script = document.currentScript;\n if (window.Dottie.addFonts) window.Dottie.addFonts(Object.keys(fonts), fonts);\n function attr(el, name, value) { el.setAttribute(name.replace(/[A-Z]/g, function (c) { return \"-\" + c.toLowerCase(); }), value); }\n function mount() {\n var player = document.createElement(\"dottie-player\"), k;\n for (k in options) attr(player, k, options[k]);\n if (script) for (k in script.dataset) if (k !== \"target\") attr(player, k, script.dataset[k]);\n var target = script && script.dataset.target ? document.querySelector(script.dataset.target) : null;\n if (target) target.appendChild(player);\n else if (script && script.parentNode && script.parentNode !== document.head) script.parentNode.insertBefore(player, script);\n else document.body.appendChild(player);\n player.setFile(window.Dottie.parseDottie(data));\n }\n if (document.readyState === \"loading\" && (!script || script.parentNode === document.head || script.dataset.target)) {\n document.addEventListener(\"DOMContentLoaded\", mount);\n } else {\n mount();\n }\n})();\n";
|
|
4
4
|
export interface CompileOptions {
|
|
5
5
|
/** Page name or 1-based number; only that page goes in. The first page by default. */
|
|
@@ -24,5 +24,9 @@ export declare function arrowhead(tip: Point, from: Point, size: number): [Point
|
|
|
24
24
|
export declare function connectorBounds(e: Element, index: Index): Rect;
|
|
25
25
|
/** Point halfway along the route, where a label sits. */
|
|
26
26
|
export declare function midpoint(e: Element, index: Index): Point;
|
|
27
|
+
/** Each element by id, the first with an id winning. Kept per elements array, so every follow, trace and render of
|
|
28
|
+
* one frame shares it; checked against the array's members each time, so a page changed in place is indexed anew. */
|
|
29
|
+
/** Whether `index` is the one `indexOf` last built for this page's elements (without checking them again). */
|
|
30
|
+
export declare function isIndexOf(page: Page, index: Index): boolean;
|
|
27
31
|
export declare function indexOf(page: Page): Index;
|
|
28
32
|
export { angle };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Page, RGBA } from "./model.ts";
|
|
2
|
+
export declare const DEFAULT_EVERY = 0.5, DEFAULT_SPEED = 160, DEFAULT_SIZE = 12;
|
|
3
|
+
export declare const DEFAULT_COLOR: RGBA;
|
|
4
|
+
export declare const clamp: (v: number | null, fallback: number, lo: number, hi: number) => number;
|
|
5
|
+
/** The id of a flow's packet `k`: the flow's id with its last twelve digits standing for `k` (Flow.packetID). */
|
|
6
|
+
export declare function packetID(flow: string, k: number): string;
|
|
7
|
+
/** Every shape traffic from `from` can reach in `frame`, with the cheapest way to each:
|
|
8
|
+
* by the connectors' cost (1 each unless set), ties to the shape reached first, earlier connectors first.
|
|
9
|
+
* With `until`, the search stops once that shape is settled: its way is final then, and it is the first goal of any
|
|
10
|
+
* list it heads, but the tree holds only the shapes settled before it. */
|
|
11
|
+
export declare function flowTree(from: string, frame: Page, offline?: Set<string>, until?: string): FlowTree | null;
|
|
12
|
+
export declare class FlowTree {
|
|
13
|
+
settled: Set<string>;
|
|
14
|
+
came: Map<string, {
|
|
15
|
+
from: string;
|
|
16
|
+
via: string;
|
|
17
|
+
back: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
readonly from: string;
|
|
20
|
+
constructor(from: string);
|
|
21
|
+
/** The first of `to` that can be reached; with `spread`, when the first can't be, every other one that can. */
|
|
22
|
+
goals(to: string[], spread: boolean): string[];
|
|
23
|
+
/** The connectors to `goal`, as [connector, backwards] hops. */
|
|
24
|
+
hops(goal: string): [string, boolean][];
|
|
25
|
+
}
|
|
26
|
+
/** The connectors traffic takes from `from` to the first of `to` it reaches in `frame`, as [connector, backwards]
|
|
27
|
+
* hops; null when none can be reached. */
|
|
28
|
+
export declare function flowRoute(from: string, to: string[], frame: Page, offline?: Set<string>): [string, boolean][] | null;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -20,4 +20,4 @@ export interface RenderOptions {
|
|
|
20
20
|
/** One page of a drawing as an SVG document, as Dottie's own SVG export draws it. */
|
|
21
21
|
export declare function render(source: string | DottieFile | unknown, options?: RenderOptions): string;
|
|
22
22
|
/** The library's version. */
|
|
23
|
-
export declare const VERSION = "0.
|
|
23
|
+
export declare const VERSION = "0.9.0";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Element, Flow, Gauge, Page, RGBA } from "./model.ts";
|
|
2
|
+
import { type MetricTerm } from "./state.ts";
|
|
3
|
+
/** A connector's or shape's metrics in one frame (ElementMetrics). */
|
|
4
|
+
export interface ElementMetrics {
|
|
5
|
+
throughput: number;
|
|
6
|
+
load: number | null;
|
|
7
|
+
delay: number;
|
|
8
|
+
backlog: number;
|
|
9
|
+
inFlight: number;
|
|
10
|
+
depth: number;
|
|
11
|
+
}
|
|
12
|
+
/** A flow's metrics in one frame (FlowMetrics). */
|
|
13
|
+
export interface FlowMetrics {
|
|
14
|
+
volume: number;
|
|
15
|
+
placed: number;
|
|
16
|
+
backlog: number;
|
|
17
|
+
backup: number;
|
|
18
|
+
transit: number | null;
|
|
19
|
+
}
|
|
20
|
+
/** Every metric of one frame (FrameMetrics). */
|
|
21
|
+
export interface FrameMetrics {
|
|
22
|
+
elements: Map<string, ElementMetrics>;
|
|
23
|
+
flows: Map<string, FlowMetrics>;
|
|
24
|
+
carry: Record<string, number>;
|
|
25
|
+
}
|
|
26
|
+
export declare const emptyMetrics: () => FrameMetrics;
|
|
27
|
+
/** `metric` of the element or flow `id`, or null when it has none. */
|
|
28
|
+
export declare function metricValue(m: FrameMetrics, metric: string, id: string): number | null;
|
|
29
|
+
/** A shape's delay as traffic feels it: 0...3600 seconds. */
|
|
30
|
+
export declare function delayOf(e: Element): number;
|
|
31
|
+
/** The key of a flow's queue at a shape in `FrameMetrics.carry` and `carried` (DottieDocument.queueKey). */
|
|
32
|
+
export declare const queueKey: (shape: string, flow: string) => string;
|
|
33
|
+
/** The packets the page's flows draw in `frame` (the page posed at `t`), with these values (null: every flow runs),
|
|
34
|
+
* and the frame's metrics. `since` is the seconds since the page's state last changed
|
|
35
|
+
* (null: `t`), and `carried` how much each flow's queue held at that moment: since then a queue grows by its
|
|
36
|
+
* backlog, or drains at the room its way on has left. */
|
|
37
|
+
export declare function flowFrame(flows: Flow[] | null, frame: Page, t: number, values: Record<string, boolean> | null, offline?: Set<string>, sinceChange?: number | null, carried?: Record<string, number>): {
|
|
38
|
+
packets: Element[];
|
|
39
|
+
metrics: FrameMetrics;
|
|
40
|
+
};
|
|
41
|
+
/** The frame's metric for a condition's comparison: its target an element's anchor, or an element's or flow's id. */
|
|
42
|
+
export declare function metricLookup(m: FrameMetrics, frame: Page): (t: MetricTerm, own: string | null) => number | null;
|
|
43
|
+
/** What finishing does to one element: which of its overrides that compare metrics hold (their looks apply, in
|
|
44
|
+
* order), and, for a gauge, the reading it shows. */
|
|
45
|
+
export interface Finish {
|
|
46
|
+
applied: number[];
|
|
47
|
+
gauge: {
|
|
48
|
+
value: number | null;
|
|
49
|
+
} | null;
|
|
50
|
+
}
|
|
51
|
+
/** For each of `elements`, the overrides that compare metrics that hold and the reading a gauge shows (easing, over
|
|
52
|
+
* `GAUGE_EASE` seconds since the state changed, from its reading then, `carried`); with no values ("all", the
|
|
53
|
+
* editor), nothing. The readings come back to carry over. */
|
|
54
|
+
export declare function finishPlan(elements: Element[], metrics: FrameMetrics, values: Record<string, boolean> | null, frame: Page, since?: number, carried?: Record<string, number>): {
|
|
55
|
+
plan: Finish[];
|
|
56
|
+
readings: Record<string, number>;
|
|
57
|
+
};
|
|
58
|
+
/** `elements` with the looks of overrides that compare metrics applied, and gauges drawn as plain elements; with
|
|
59
|
+
* no values ("all", the editor), both are left as they are (`finishPlan`). */
|
|
60
|
+
export declare function finishing(elements: Element[], metrics: FrameMetrics, values: Record<string, boolean> | null, frame: Page, flows: Flow[], since?: number, carried?: Record<string, number>): {
|
|
61
|
+
elements: Element[];
|
|
62
|
+
readings: Record<string, number>;
|
|
63
|
+
};
|
|
64
|
+
/** The key of a gauge's reading in `FrameMetrics.carry` and `carried` (DottieDocument.gaugeKey). */
|
|
65
|
+
export declare const gaugeKey: (id: string) => string;
|
|
66
|
+
export declare const GAUGE_GREEN: RGBA, GAUGE_AMBER: RGBA, GAUGE_RED: RGBA;
|
|
67
|
+
export declare const GAUGE_BLUE: RGBA, GAUGE_TRACK: RGBA, GAUGE_GRAY: RGBA;
|
|
68
|
+
/** A metric's value as a gauge shows it: a percentage for load and backup, seconds for transit and delay. */
|
|
69
|
+
export declare function formatted(metric: string, v: number | null): string;
|
|
70
|
+
/** `v` to `places` decimals, halves away from zero, trailing zeros dropped (DottieDocument.number). */
|
|
71
|
+
export declare function formatNumber(v: number, places: number): string;
|
|
72
|
+
/** A gauge drawn: its frame as a `.path` carrying the label, then the bar or dial. */
|
|
73
|
+
export declare function gauge(e: Element, g: Gauge, value: number | null, frame: Page, flows: Flow[]): Element[];
|
package/dist/types/model.d.ts
CHANGED
|
@@ -55,6 +55,8 @@ export interface ConnectorData {
|
|
|
55
55
|
waypoints: StrokePoint[] | null;
|
|
56
56
|
/** Hops where the line crosses a connector drawn beneath it. */
|
|
57
57
|
hops: boolean | null;
|
|
58
|
+
/** What a flow's traffic pays to take this connector (ADR 0002); null is 1. */
|
|
59
|
+
cost: number | null;
|
|
58
60
|
}
|
|
59
61
|
export interface PathSubpath {
|
|
60
62
|
closed: boolean;
|
|
@@ -75,8 +77,31 @@ export interface ClickAction {
|
|
|
75
77
|
url: string | null;
|
|
76
78
|
set: Record<string, boolean> | null;
|
|
77
79
|
toggle: string[] | null;
|
|
80
|
+
/** Puts every page variable back to its starting value first. */
|
|
81
|
+
reset?: boolean | null;
|
|
78
82
|
}
|
|
79
83
|
/** How a clickable element looks under the pointer or with keyboard focus; null keeps its own. */
|
|
84
|
+
/** A change to an element while `when` holds (StateOverride): a field left null keeps the element's own. */
|
|
85
|
+
export interface StateOverride {
|
|
86
|
+
when: string;
|
|
87
|
+
stroke: RGBA | null;
|
|
88
|
+
fill: RGBA | null;
|
|
89
|
+
textColor: RGBA | null;
|
|
90
|
+
/** Multiplies the element's opacity. */
|
|
91
|
+
opacity: number | null;
|
|
92
|
+
strokeWidth: number | null;
|
|
93
|
+
dash: DashStyle | null;
|
|
94
|
+
text: string | null;
|
|
95
|
+
/** Connector ids (uppercase) to the connectors a following element takes instead. */
|
|
96
|
+
reroute: Record<string, string> | null;
|
|
97
|
+
/** Still drawn, but carries no flow traffic. */
|
|
98
|
+
offline: boolean | null;
|
|
99
|
+
/** A connector's cost for flow traffic meanwhile. */
|
|
100
|
+
cost: number | null;
|
|
101
|
+
/** Its capacity and delay meanwhile (ADR 0003). */
|
|
102
|
+
capacity: number | null;
|
|
103
|
+
delay: number | null;
|
|
104
|
+
}
|
|
80
105
|
export interface HoverLook {
|
|
81
106
|
stroke: RGBA | null;
|
|
82
107
|
fill: RGBA | null;
|
|
@@ -110,6 +135,8 @@ export interface Element {
|
|
|
110
135
|
hover: HoverLook | null;
|
|
111
136
|
/** A condition on the page's variables: drawn only while it holds (Element.when; see state.ts). */
|
|
112
137
|
when: string | null;
|
|
138
|
+
/** Changes to the element while a condition holds, in order (Element.overrides; see state.ts). */
|
|
139
|
+
overrides: StateOverride[] | null;
|
|
113
140
|
/** For a `symbol` element: the page's symbol it shows, how it plays it, and from how far in. */
|
|
114
141
|
symbol: string | null;
|
|
115
142
|
playback: SymbolPlayback | null;
|
|
@@ -131,6 +158,23 @@ export interface Element {
|
|
|
131
158
|
height: number;
|
|
132
159
|
} | null;
|
|
133
160
|
extension?: ExtensionRef | null;
|
|
161
|
+
/** The most flow volume it carries, and a shape's delay in seconds (ADR 0003). */
|
|
162
|
+
capacity?: number | null;
|
|
163
|
+
delay?: number | null;
|
|
164
|
+
/** A shape that is a queue: backlog waits at the nearest one before whatever is full. */
|
|
165
|
+
queue?: boolean | null;
|
|
166
|
+
/** Shows a metric; drawn as plain paths and a label when the page is posed (metrics.ts). */
|
|
167
|
+
gauge?: Gauge | null;
|
|
168
|
+
}
|
|
169
|
+
/** A metric shown in an element's frame (Gauge, ADR 0003). */
|
|
170
|
+
export interface Gauge {
|
|
171
|
+
metric: string;
|
|
172
|
+
of: string;
|
|
173
|
+
max: number | null;
|
|
174
|
+
warn: number | null;
|
|
175
|
+
alarm: number | null;
|
|
176
|
+
style: "number" | "bar" | "dial" | null;
|
|
177
|
+
label: string | null;
|
|
134
178
|
}
|
|
135
179
|
export interface Layer {
|
|
136
180
|
id: string;
|
|
@@ -210,6 +254,28 @@ export interface Page {
|
|
|
210
254
|
symbols: Symbol[] | null;
|
|
211
255
|
/** The page's variables and their starting values (DottieDocument.variables). */
|
|
212
256
|
variables: Record<string, boolean> | null;
|
|
257
|
+
/** Traffic routed over the connectors drawn in each frame (DottieDocument.flows; see flows.ts). */
|
|
258
|
+
flows: Flow[] | null;
|
|
259
|
+
}
|
|
260
|
+
/** Traffic from one shape to the first of `to` it can reach (Flow, ADR 0002). Numbers left null take defaults. */
|
|
261
|
+
export interface Flow {
|
|
262
|
+
id: string;
|
|
263
|
+
from: string;
|
|
264
|
+
to: string[];
|
|
265
|
+
every: number | null;
|
|
266
|
+
speed: number | null;
|
|
267
|
+
color: RGBA | null;
|
|
268
|
+
size: number | null;
|
|
269
|
+
when: string | null;
|
|
270
|
+
/** When the first destination can't be reached, deal packets across every other one that can. */
|
|
271
|
+
spread: boolean | null;
|
|
272
|
+
/** How much it carries (ADR 0003); null is 1. */
|
|
273
|
+
volume: number | null;
|
|
274
|
+
/** Its volume while a condition holds, the last that holds winning. */
|
|
275
|
+
overrides?: {
|
|
276
|
+
when: string;
|
|
277
|
+
volume: number | null;
|
|
278
|
+
}[] | null;
|
|
213
279
|
}
|
|
214
280
|
/** A drawing defined once on a page and placed by `symbol` elements, with its own timeline (Symbol). */
|
|
215
281
|
export interface Symbol {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Page } from "./model.ts";
|
|
2
|
+
/** Frames times elements below which planning in place is quicker than starting a worker. */
|
|
3
|
+
export declare const WORKER_WORK = 30000;
|
|
4
|
+
/** Roughly how much resolving every frame of `page` takes: none with a camera, which plans without resolving. */
|
|
5
|
+
export declare function planWork(page: Page): number;
|
|
6
|
+
/** Whether `page` is worth planning in a worker, and one can be had. */
|
|
7
|
+
export declare function plansInWorker(page: Page): boolean;
|
|
8
|
+
/** Plans `page` in the worker; when it resolves, `plan(page)` returns that plan at once. On any failure it resolves
|
|
9
|
+
* all the same, and `plan(page)` then plans in place. */
|
|
10
|
+
export declare function planInWorker(page: Page): Promise<void>;
|
|
11
|
+
/** In a worker started by `planInWorker`, answers its requests. Elsewhere it does nothing. */
|
|
12
|
+
export declare function servePlans(): void;
|
package/dist/types/player.d.ts
CHANGED
|
@@ -14,6 +14,14 @@ export declare class Playback {
|
|
|
14
14
|
readonly sceneLoops: boolean[];
|
|
15
15
|
/** The page's variables now: their starting values until clicks change them. */
|
|
16
16
|
state: Record<string, boolean>;
|
|
17
|
+
/** When the variables last changed (performance.now() milliseconds): backlog piles up from then (ADR 0003). */
|
|
18
|
+
stateSince: number;
|
|
19
|
+
/** A still (the `at` attribute): backlog is drawn for the page time, not the wall clock. */
|
|
20
|
+
still: boolean;
|
|
21
|
+
/** What each queue held when the variables last changed, which it drains from (FrameMetrics.carry). */
|
|
22
|
+
carried: Record<string, number>;
|
|
23
|
+
/** Seconds since the variables last changed, or null for a still. */
|
|
24
|
+
sinceChange(now?: number): number | null;
|
|
17
25
|
readonly background: RGBA;
|
|
18
26
|
readonly ink: RGBA;
|
|
19
27
|
/** What clicking each clickable element does, by element id. */
|
|
@@ -31,7 +39,10 @@ export declare class Playback {
|
|
|
31
39
|
private overTimes;
|
|
32
40
|
private downTimes;
|
|
33
41
|
private hitTimes;
|
|
34
|
-
|
|
42
|
+
last: {
|
|
43
|
+
t: number;
|
|
44
|
+
i: number;
|
|
45
|
+
};
|
|
35
46
|
private svg;
|
|
36
47
|
private groups;
|
|
37
48
|
private order;
|
|
@@ -90,6 +101,10 @@ export declare class DottiePlayer extends ElementBase {
|
|
|
90
101
|
private raf;
|
|
91
102
|
private replayRaf;
|
|
92
103
|
private loadToken;
|
|
104
|
+
/** Counts mounts, so a plan that comes back from a worker after a newer one is dropped. */
|
|
105
|
+
private mountToken;
|
|
106
|
+
/** The time a still shows; null while the drawing is animated. */
|
|
107
|
+
private stillTime;
|
|
93
108
|
private visible;
|
|
94
109
|
private observer;
|
|
95
110
|
constructor();
|
|
@@ -100,8 +115,13 @@ export declare class DottiePlayer extends ElementBase {
|
|
|
100
115
|
load(): Promise<void>;
|
|
101
116
|
/** Shows an already-parsed file. */
|
|
102
117
|
setFile(file: DottieFile): void;
|
|
118
|
+
private showFile;
|
|
119
|
+
/** Shows the file's page; then `mounted`. A big animation is planned in a worker first (planner.ts), and what was
|
|
120
|
+
* showing stays until it is ready; a newer mount, file or failed load in the meantime wins. */
|
|
103
121
|
private mount;
|
|
122
|
+
private mountPage;
|
|
104
123
|
get paused(): boolean;
|
|
124
|
+
/** The moment shown: a still's own time (its `at`, or the poster), else the current frame's. */
|
|
105
125
|
get currentTime(): number;
|
|
106
126
|
set currentTime(t: number);
|
|
107
127
|
get duration(): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/state.d.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ClickAction, type Element, type Page, type StateOverride } from "./model.ts";
|
|
2
2
|
/** Whether `name` can name a variable: a letter or underscore, then letters, digits and underscores. */
|
|
3
3
|
export declare function isName(name: string): boolean;
|
|
4
|
-
/** The
|
|
5
|
-
|
|
4
|
+
/** The metrics a condition can compare (ADR 0003), as `load(workers) > 0.9`. */
|
|
5
|
+
export declare const METRIC_NAMES: string[];
|
|
6
|
+
/** A comparison of a metric in a condition (PageState.MetricTerm). */
|
|
7
|
+
export interface MetricTerm {
|
|
8
|
+
metric: string;
|
|
9
|
+
target: string;
|
|
10
|
+
op: string;
|
|
11
|
+
value: number;
|
|
12
|
+
}
|
|
13
|
+
/** `term` (trimmed) read as a metric comparison, or null. */
|
|
14
|
+
export declare function metricTerm(term: string): MetricTerm | null;
|
|
15
|
+
/** Whether `condition` compares a metric anywhere. */
|
|
16
|
+
export declare function mentionsMetric(condition: string): boolean;
|
|
17
|
+
/** The variable names `condition` reads, or null when it isn't one: names, each optionally after `!`, or metric
|
|
18
|
+
* comparisons, joined by `&&` and `||` (`&&` binds tighter). */
|
|
6
19
|
export declare function conditionNames(condition: string): string[] | null;
|
|
7
|
-
/** Whether `condition` holds with these values
|
|
8
|
-
* holds. */
|
|
9
|
-
export declare function holds(condition: string, state: Record<string, boolean
|
|
20
|
+
/** Whether `condition` holds with these values, and `metric` giving the frame's metrics. A missing variable is
|
|
21
|
+
* false, and so is a comparison whose metric can't be had; a condition that can't be read never holds. */
|
|
22
|
+
export declare function holds(condition: string, state: Record<string, boolean>, metric?: ((m: MetricTerm) => number | null) | null): boolean;
|
|
10
23
|
/** Which elements a page shows as far as its variables go: their starting values ("initial"), these values (a
|
|
11
24
|
* missing one takes its starting value), or every element ("all"). */
|
|
12
25
|
export type StateChoice = "initial" | "all" | Record<string, boolean>;
|
|
@@ -14,7 +27,14 @@ export type StateChoice = "initial" | "all" | Record<string, boolean>;
|
|
|
14
27
|
export declare function stateValues(page: Page, choice: StateChoice): Record<string, boolean> | null;
|
|
15
28
|
/** The ids of the elements whose `when` doesn't hold under `choice`. */
|
|
16
29
|
export declare function stateHidden(page: Page, choice: StateChoice): Set<string>;
|
|
30
|
+
/** The overrides of `e` that hold under `values`, in order; none for null ("all", the editor). */
|
|
31
|
+
export declare function activeOverrides(e: Element, values: Record<string, boolean> | null): StateOverride[];
|
|
32
|
+
/** Only what an override comparing metrics may change: its looks (ADR 0003). */
|
|
33
|
+
export declare function looksOnly(o: StateOverride): StateOverride;
|
|
34
|
+
/** `e` with `o` applied (StateOverride.apply): opacity multiplies, the rest replaces. */
|
|
35
|
+
export declare function applyOverride(o: StateOverride, e: Element): Element;
|
|
17
36
|
/** Whether a click sets or flips a variable. */
|
|
18
37
|
export declare function changesState(c: ClickAction | null): boolean;
|
|
19
|
-
/** `state` after the click:
|
|
20
|
-
|
|
38
|
+
/** `state` after the click: the starting values (`initial`) back if it resets, then its `set` values, then each
|
|
39
|
+
* `toggle` flipped (a missing variable starts false). */
|
|
40
|
+
export declare function applyClick(c: ClickAction, state: Record<string, boolean>, initial?: Record<string, boolean>): Record<string, boolean>;
|
package/dist/types/svg.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export interface Plan {
|
|
|
17
17
|
/** What an animation shows over time (Exporter.animation): with a camera, its view at each frame, widened to
|
|
18
18
|
* the first key's shape; without, the bounds of the whole animation for every frame. */
|
|
19
19
|
export declare function plan(page: Page): Plan;
|
|
20
|
+
/** Whether `plan(page)` would return at once. */
|
|
21
|
+
export declare function hasPlan(page: Page): boolean;
|
|
22
|
+
/** Has `plan(page)` return `made`, a plan of this page made elsewhere (in a worker, planner.ts). */
|
|
23
|
+
export declare function rememberPlan(page: Page, made: Plan): void;
|
|
24
|
+
/** Whether `page` still holds exactly the fields it had when `fields` was copied from it. */
|
|
25
|
+
export declare function unchanged(page: Page, fields: Page): boolean;
|
|
20
26
|
/** The opening `<svg>` tag for `b`, with the page color behind everything when `paint`. */
|
|
21
27
|
export declare function svgOpen(b: Rect, background: RGBA | null, paint: boolean): string;
|
|
22
28
|
export interface Part {
|
|
@@ -25,8 +31,9 @@ export interface Part {
|
|
|
25
31
|
}
|
|
26
32
|
/** The SVG for each thing drawn, back to front, keyed by element id (rock hatching as "rock"). With `links`, an
|
|
27
33
|
* element whose click or `url` is a web address is wrapped in an `<a>` that opens it, the click's first (the players
|
|
28
|
-
* make their own clickable groups).
|
|
29
|
-
|
|
34
|
+
* make their own clickable groups). With `only`, just the parts whose keys it accepts, drawn as they are on the
|
|
35
|
+
* whole page (connectors still meet and hop the rest). */
|
|
36
|
+
export declare function svgParts(page: Page, background: RGBA | null, fixed?: Rect, links?: boolean, only?: (key: string) => boolean): {
|
|
30
37
|
bounds: Rect;
|
|
31
38
|
parts: Part[];
|
|
32
39
|
};
|
package/dist/types/symbols.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Page, type Symbol, type SymbolPlayback } from "./model.ts";
|
|
1
|
+
import { type Element, type Page, type Symbol, type SymbolPlayback } from "./model.ts";
|
|
2
2
|
/** The deepest instances nest, and the most elements expanding one page may make (Symbol.maxDepth, .maxElements). */
|
|
3
3
|
export declare const MAX_DEPTH = 8;
|
|
4
4
|
export declare const MAX_ELEMENTS = 20000;
|
|
@@ -15,9 +15,25 @@ export declare function filled(s: Symbol, args: Record<string, string> | null):
|
|
|
15
15
|
/** The symbol as a page of its own (Symbol.page). */
|
|
16
16
|
export declare function symbolPage(s: Symbol): Page;
|
|
17
17
|
export declare function hasInstances(page: Page): boolean;
|
|
18
|
+
/** What each instance on a page expanded into, kept so that expanding the same page again at the same moment with
|
|
19
|
+
* a few instances' times changed (a button's other states) redoes only those. */
|
|
20
|
+
export declare class Expansions {
|
|
21
|
+
readonly page: Page;
|
|
22
|
+
readonly t: number;
|
|
23
|
+
readonly posing: boolean;
|
|
24
|
+
/** For each instance: its time override, the budget it found and left, and what it made. */
|
|
25
|
+
readonly made: Map<Element, {
|
|
26
|
+
override: number | undefined;
|
|
27
|
+
before: number;
|
|
28
|
+
after: number;
|
|
29
|
+
out: Element[];
|
|
30
|
+
}>;
|
|
31
|
+
constructor(page: Page, t: number, posing: boolean);
|
|
32
|
+
}
|
|
18
33
|
/** The page with every instance replaced by what it shows at page time `t` (DottieDocument.expandingSymbols). `times`
|
|
19
|
-
* puts instances on the page at a moment of their symbol's own: a button's other states, or a clip replaying.
|
|
20
|
-
|
|
34
|
+
* puts instances on the page at a moment of their symbol's own: a button's other states, or a clip replaying.
|
|
35
|
+
* `memo` records what each instance made, or, made for this page and moment, reuses it where nothing differs. */
|
|
36
|
+
export declare function expandingSymbols(page: Page, t: number, posing?: boolean, times?: Map<string, number>, memo?: Expansions): Page;
|
|
21
37
|
export declare function symbolTable(page: Page): Map<string, Symbol>;
|
|
22
38
|
/** The id an element of a symbol has inside instance `instance` (DottieDocument.derivedID). */
|
|
23
39
|
export declare function derivedID(instance: string, inner: string): string;
|
package/dist/types/timeline.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { type Index } from "./connector.ts";
|
|
1
2
|
import { type Ease, type Element, type Follow, type Page, type Timeline, type Track } from "./model.ts";
|
|
2
3
|
import { Polyline, type Point, type Rect } from "./path.ts";
|
|
3
4
|
import { type StateChoice } from "./state.ts";
|
|
5
|
+
import { type FrameMetrics } from "./measure.ts";
|
|
4
6
|
export declare function applyEase(ease: Ease, u: number): number;
|
|
5
7
|
/** The time inside the track's own keys that `t` plays (repeats folded back). */
|
|
6
8
|
export declare function localTime(track: Track, t: number): number;
|
|
@@ -12,8 +14,9 @@ export declare function isVisible(track: Track, t: number): boolean;
|
|
|
12
14
|
export declare function applyTrack(track: Track, e: Element, t: number): Element;
|
|
13
15
|
/** The path span placing the element at `t`, unless an x or y key after it has taken the element back. */
|
|
14
16
|
export declare function followSpan(track: Track, t: number): Follow | null;
|
|
15
|
-
/** The clean route of a connector, or the clean, rotated outline of any other element.
|
|
16
|
-
|
|
17
|
+
/** The clean route of a connector, or the clean, rotated outline of any other element. `index` is the page's,
|
|
18
|
+
* passed by callers that already have it. */
|
|
19
|
+
export declare function tracing(e: Element, page: Page, index?: Index): Polyline;
|
|
17
20
|
/** `e` moved onto the path it is following at `t`, if any. `page` has every key applied. */
|
|
18
21
|
export declare function following(track: Track, e: Element, t: number, page: Page): Element;
|
|
19
22
|
/** Where the dashes of a line marching at `speed` stand at `t`, within one pattern `period` (Timeline.marchOffset):
|
|
@@ -21,10 +24,17 @@ export declare function following(track: Track, e: Element, t: number, page: Pag
|
|
|
21
24
|
export declare function marchOffset(tl: Timeline, speed: number, period: number, t: number): number;
|
|
22
25
|
/** The page as a still drawing at `t` seconds, symbol instances expanded (DottieDocument.resolved(at:)). A page with
|
|
23
26
|
* no timeline and no instances is returned as is. */
|
|
24
|
-
export declare function resolved(page: Page, t: number, state?: StateChoice): Page;
|
|
27
|
+
export declare function resolved(page: Page, t: number, state?: StateChoice, since?: number | null, carried?: Record<string, number>): Page;
|
|
25
28
|
/** The page posed at `t` seconds, instances kept, and the elements whose `when` doesn't hold under `state` left out
|
|
26
29
|
* with their connectors (DottieDocument.posed(at:state:)). */
|
|
27
|
-
export declare function posed(page: Page, t: number, state?: StateChoice): Page;
|
|
30
|
+
export declare function posed(page: Page, t: number, state?: StateChoice, since?: number | null, carried?: Record<string, number>): Page;
|
|
31
|
+
/** `posed`, and the frame's metrics (ADR 0003). `since` is the seconds since the page's state last changed, which
|
|
32
|
+
* backlog has been piling up for: the player passes the time since the last click; null is `t`, as exports draw it.
|
|
33
|
+
* `carried` is what each queue held when the state last changed (`FrameMetrics.carry` then), which it drains from. */
|
|
34
|
+
export declare function posedWithMetrics(page: Page, t: number, state?: StateChoice, since?: number | null, carried?: Record<string, number>): {
|
|
35
|
+
frame: Page;
|
|
36
|
+
metrics: FrameMetrics;
|
|
37
|
+
};
|
|
28
38
|
/** The moment a still picture of the page shows: its poster, else the end. */
|
|
29
39
|
export declare function posterTime(page: Page): number;
|
|
30
40
|
/** The page as a still picture (its poster frame when animated). */
|