@phin-tech/dottie 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PARITY.md +3 -0
- package/dist/compile.js +103 -8
- package/dist/dottie-compile.mjs +104 -9
- package/dist/dottie-player.js +339 -71
- package/dist/dottie-player.min.js +55 -55
- package/dist/dottie-sim.min.js +4 -4
- package/dist/dottie.js +337 -71
- package/dist/types/elbow.d.ts +18 -0
- package/dist/types/flows.d.ts +2 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/measure.d.ts +11 -0
- package/dist/types/model.d.ts +32 -0
- package/dist/types/theme.d.ts +13 -1
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Element } from "./model.ts";
|
|
2
|
+
import type { Point, Rect } from "./path.ts";
|
|
3
|
+
/** How far a route keeps from the shapes it goes round. */
|
|
4
|
+
export declare const MARGIN = 16;
|
|
5
|
+
/** What a bend costs, in points of length. */
|
|
6
|
+
export declare const BEND = 24;
|
|
7
|
+
/** Shapes smaller than this either way (packets, dots, small icons) aren't in the way. */
|
|
8
|
+
export declare const SMALLEST = 24;
|
|
9
|
+
/** More shapes in the way than this, and the plain route is kept. */
|
|
10
|
+
export declare const MOST = 48;
|
|
11
|
+
/** The box of `e` if a route goes round it: not a connector, text, freehand line or plain path, not invisible, and
|
|
12
|
+
* not small. */
|
|
13
|
+
export declare function obstacle(e: Element): Rect | null;
|
|
14
|
+
/** Whether the right-angled line through `points` passes through the inside of `r` (not just along its edge). */
|
|
15
|
+
export declare function crosses(points: Point[], r: Rect): boolean;
|
|
16
|
+
/** `plain` (the Z or L from `a` to `b`), or a way round the shapes among `elements` it crosses, leaving out `except`
|
|
17
|
+
* (the connector's own ends). */
|
|
18
|
+
export declare function avoiding(plain: Point[], a: Point, b: Point, startVertical: boolean, endVertical: boolean, elements: Iterable<Element>, except: Set<string>): Point[];
|
package/dist/types/flows.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export declare const DEFAULT_COLOR: RGBA;
|
|
|
4
4
|
export declare const clamp: (v: number | null, fallback: number, lo: number, hi: number) => number;
|
|
5
5
|
/** The id of a flow's packet `k`: the flow's id with its last twelve digits standing for `k` (Flow.packetID). */
|
|
6
6
|
export declare function packetID(flow: string, k: number): string;
|
|
7
|
+
/** `cost` as routing uses it: 1 for null, kept within 0...1,000,000 (ConnectorData.routeCost). */
|
|
8
|
+
export declare const routeCost: (cost: number | null) => number;
|
|
7
9
|
/** Every shape traffic from `from` can reach in `frame`, with the cheapest way to each:
|
|
8
10
|
* by the connectors' cost (1 each unless set), ties to the shape reached first, earlier connectors first.
|
|
9
11
|
* With `until`, the search stops once that shape is settled: its way is final then, and it is the first goal of any
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { BUNDLED_FONTS } from "./text.ts";
|
|
|
5
5
|
export { inspect, inspectFrame, inspectPage, sampleTimes } from "./inspect.ts";
|
|
6
6
|
export { DottiePlayer, Playback, definePlayer, pageIndex, withRoughness } from "./player.ts";
|
|
7
7
|
export { bounds, plan, svg, svgParts, type Plan, type Part } from "./svg.ts";
|
|
8
|
-
export { themeNamed, themes, type Theme } from "./theme.ts";
|
|
8
|
+
export { pageTheme, paletteColor, themeNamed, themes, type Theme } from "./theme.ts";
|
|
9
9
|
export { cameraView, frameTimes, posterTime, resolved, sceneAt, still, transientElements } from "./timeline.ts";
|
|
10
10
|
export interface RenderOptions {
|
|
11
11
|
/** Page name or 1-based number; the first page by default. */
|
|
@@ -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.10.0";
|
package/dist/types/measure.d.ts
CHANGED
|
@@ -28,6 +28,16 @@ export declare const emptyMetrics: () => FrameMetrics;
|
|
|
28
28
|
export declare function metricValue(m: FrameMetrics, metric: string, id: string): number | null;
|
|
29
29
|
/** A shape's delay as traffic feels it: 0...3600 seconds. */
|
|
30
30
|
export declare function delayOf(e: Element): number;
|
|
31
|
+
/** One way a flow's traffic takes in a frame (`flowFrame`'s routes): to `goal` over the connectors `hops`
|
|
32
|
+
* ([connector, backwards]), carrying `amount` of its volume at a cost of `cost`; `waits` when it goes only as far as
|
|
33
|
+
* the queue it waits in. */
|
|
34
|
+
export interface FlowRoute {
|
|
35
|
+
goal: string;
|
|
36
|
+
hops: [string, boolean][];
|
|
37
|
+
amount: number;
|
|
38
|
+
waits: boolean;
|
|
39
|
+
cost: number;
|
|
40
|
+
}
|
|
31
41
|
/** The key of a flow's queue at a shape in `FrameMetrics.carry` and `carried` (DottieDocument.queueKey). */
|
|
32
42
|
export declare const queueKey: (shape: string, flow: string) => string;
|
|
33
43
|
/** The packets the page's flows draw in `frame` (the page posed at `t`), with these values (null: every flow runs),
|
|
@@ -37,6 +47,7 @@ export declare const queueKey: (shape: string, flow: string) => string;
|
|
|
37
47
|
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
48
|
packets: Element[];
|
|
39
49
|
metrics: FrameMetrics;
|
|
50
|
+
routes: Map<string, FlowRoute[]>;
|
|
40
51
|
};
|
|
41
52
|
/** The frame's metric for a condition's comparison: its target an element's anchor, or an element's or flow's id. */
|
|
42
53
|
export declare function metricLookup(m: FrameMetrics, frame: Page): (t: MetricTerm, own: string | null) => number | null;
|
package/dist/types/model.d.ts
CHANGED
|
@@ -29,6 +29,27 @@ export interface Style {
|
|
|
29
29
|
dashOffset: number | null;
|
|
30
30
|
/** The color of a shape's or connector's label; null follows `stroke`. Text boxes and notes ignore it. */
|
|
31
31
|
textColor: RGBA | null;
|
|
32
|
+
/** Which colors are palette colors, by name (ADR 0005); set from the page's palette when it is read. */
|
|
33
|
+
named?: ColorNames | null;
|
|
34
|
+
}
|
|
35
|
+
/** Palette names for an element's colors (Theme.swift's ColorNames). */
|
|
36
|
+
export interface ColorNames {
|
|
37
|
+
fill: string | null;
|
|
38
|
+
stroke: string | null;
|
|
39
|
+
textColor: string | null;
|
|
40
|
+
}
|
|
41
|
+
/** A named color in a theme's palette. */
|
|
42
|
+
export interface PaletteColor {
|
|
43
|
+
name: string;
|
|
44
|
+
color: RGBA;
|
|
45
|
+
}
|
|
46
|
+
/** A theme made in the drawing (CustomTheme): it takes the place of the page's `theme`. */
|
|
47
|
+
export interface CustomTheme {
|
|
48
|
+
name: string;
|
|
49
|
+
background: RGBA;
|
|
50
|
+
ink: RGBA;
|
|
51
|
+
palette: PaletteColor[];
|
|
52
|
+
base: string | null;
|
|
32
53
|
}
|
|
33
54
|
/** `portIndex` pins the end to one of the bound element's `ports`, and wins over `port`. */
|
|
34
55
|
export interface Endpoint {
|
|
@@ -55,6 +76,8 @@ export interface ConnectorData {
|
|
|
55
76
|
waypoints: StrokePoint[] | null;
|
|
56
77
|
/** Hops where the line crosses a connector drawn beneath it. */
|
|
57
78
|
hops: boolean | null;
|
|
79
|
+
/** An elbow line goes round the shapes in its way instead of through them (elbow.ts). */
|
|
80
|
+
avoid?: boolean | null;
|
|
58
81
|
/** What a flow's traffic pays to take this connector (ADR 0002); null is 1. */
|
|
59
82
|
cost: number | null;
|
|
60
83
|
}
|
|
@@ -163,6 +186,13 @@ export interface Element {
|
|
|
163
186
|
delay?: number | null;
|
|
164
187
|
/** A shape that is a queue: backlog waits at the nearest one before whatever is full. */
|
|
165
188
|
queue?: boolean | null;
|
|
189
|
+
/** The container this element is in (ADR 0006). */
|
|
190
|
+
containerID?: string | null;
|
|
191
|
+
/** On a rectangle: it's a container. Its title band is its `labelRect`, kept by the app, so drawing needs nothing more. */
|
|
192
|
+
container?: {
|
|
193
|
+
fixed: boolean | null;
|
|
194
|
+
lanes: "rows" | "columns" | null;
|
|
195
|
+
} | null;
|
|
166
196
|
/** Shows a metric; drawn as plain paths and a label when the page is posed (metrics.ts). */
|
|
167
197
|
gauge?: Gauge | null;
|
|
168
198
|
}
|
|
@@ -250,6 +280,8 @@ export interface Page {
|
|
|
250
280
|
layers: Layer[];
|
|
251
281
|
elements: Element[];
|
|
252
282
|
theme: string | null;
|
|
283
|
+
/** A theme of the page's own (ADR 0005), in place of `theme`. */
|
|
284
|
+
customTheme?: CustomTheme | null;
|
|
253
285
|
timeline: Timeline | null;
|
|
254
286
|
symbols: Symbol[] | null;
|
|
255
287
|
/** The page's variables and their starting values (DottieDocument.variables). */
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import type { RGBA } from "./model.ts";
|
|
1
|
+
import type { Page, PaletteColor, RGBA } from "./model.ts";
|
|
2
2
|
export interface Theme {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
5
|
background: RGBA;
|
|
6
6
|
ink: RGBA;
|
|
7
|
+
palette: PaletteColor[];
|
|
7
8
|
}
|
|
9
|
+
/** The palette names every built-in theme has, in order. */
|
|
10
|
+
export declare const PALETTE_NAMES: string[];
|
|
11
|
+
/** Light pages. */
|
|
12
|
+
export declare const LIGHT_PALETTE: PaletteColor[];
|
|
8
13
|
export declare const themes: Theme[];
|
|
9
14
|
/** The theme a page names, or null (white page, black ink) for none or one this version doesn't know. */
|
|
10
15
|
export declare function themeNamed(id: string | null | undefined): Theme | null;
|
|
16
|
+
/** The theme `page` is drawn in: its own, else the built-in it names, else null. */
|
|
17
|
+
export declare function pageTheme(page: Pick<Page, "theme" | "customTheme">): Theme | null;
|
|
18
|
+
/** The palette color `name` names on `page`, ignoring case. */
|
|
19
|
+
export declare function paletteColor(page: Pick<Page, "theme" | "customTheme">, name: string): RGBA | null;
|
|
20
|
+
/** `page` with every named color set from its palette (DottieDocument.resolvingPalette); a name the palette doesn't
|
|
21
|
+
* have keeps the color it had. */
|
|
22
|
+
export declare function resolvingPalette(page: Page): Page;
|