@brunosouzas/signwright 0.0.0-stage → 0.19.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/LICENSE +202 -0
- package/NOTICE +15 -0
- package/README.md +567 -2
- package/dist/scripts/cover.d.ts +29 -0
- package/dist/scripts/cover.js +186 -0
- package/dist/src/fonts/embed.d.ts +7 -0
- package/dist/src/fonts/embed.js +221 -0
- package/dist/src/pieces/bank-objects.d.ts +12 -0
- package/dist/src/pieces/bank-objects.js +52 -0
- package/dist/src/pieces/brand-cast.d.ts +105 -0
- package/dist/src/pieces/brand-cast.js +221 -0
- package/dist/src/pieces/brand-notation-icons.d.ts +12 -0
- package/dist/src/pieces/brand-notation-icons.js +79 -0
- package/dist/src/pieces/category-icon.d.ts +12 -0
- package/dist/src/pieces/category-icon.js +55 -0
- package/dist/src/pieces/cover.d.ts +138 -0
- package/dist/src/pieces/cover.js +635 -0
- package/dist/src/pieces/diagram.d.ts +141 -0
- package/dist/src/pieces/diagram.js +201 -0
- package/dist/src/pieces/eip-icons.d.ts +12 -0
- package/dist/src/pieces/eip-icons.js +468 -0
- package/dist/src/pieces/emote.d.ts +13 -0
- package/dist/src/pieces/emote.js +88 -0
- package/dist/src/pieces/headline.d.ts +11 -0
- package/dist/src/pieces/headline.js +37 -0
- package/dist/src/pieces/index.d.ts +17 -0
- package/dist/src/pieces/index.js +20 -0
- package/dist/src/pieces/ink.d.ts +71 -0
- package/dist/src/pieces/ink.js +57 -0
- package/dist/src/pieces/keyboard.d.ts +9 -0
- package/dist/src/pieces/keyboard.js +33 -0
- package/dist/src/pieces/library.d.ts +320 -0
- package/dist/src/pieces/library.js +355 -0
- package/dist/src/pieces/link-icons.d.ts +23 -0
- package/dist/src/pieces/link-icons.js +101 -0
- package/dist/src/pieces/metro.d.ts +137 -0
- package/dist/src/pieces/metro.js +288 -0
- package/dist/src/pieces/node.d.ts +29 -0
- package/dist/src/pieces/node.js +56 -0
- package/dist/src/pieces/paper.d.ts +31 -0
- package/dist/src/pieces/paper.js +72 -0
- package/dist/src/pieces/params.d.ts +84 -0
- package/dist/src/pieces/params.js +158 -0
- package/dist/src/pieces/piece.d.ts +9 -0
- package/dist/src/pieces/piece.js +28 -0
- package/dist/src/pieces/pose.d.ts +16 -0
- package/dist/src/pieces/pose.js +30 -0
- package/dist/src/pieces/question-token.d.ts +9 -0
- package/dist/src/pieces/question-token.js +49 -0
- package/dist/src/pieces/react.d.ts +4 -0
- package/dist/src/pieces/react.js +13 -0
- package/dist/src/pieces/render.d.ts +2 -0
- package/dist/src/pieces/render.js +22 -0
- package/dist/src/pieces/skin.d.ts +22 -0
- package/dist/src/pieces/skin.js +13 -0
- package/dist/src/pieces/stamp.d.ts +11 -0
- package/dist/src/pieces/stamp.js +29 -0
- package/dist/src/pieces/supporting-cast.d.ts +35 -0
- package/dist/src/pieces/supporting-cast.js +168 -0
- package/dist/src/pieces/symbol.d.ts +13 -0
- package/dist/src/pieces/symbol.js +27 -0
- package/dist/src/pieces/ui-icons.d.ts +21 -0
- package/dist/src/pieces/ui-icons.js +35 -0
- package/dist/tokens/generated/tokens.d.ts +299 -0
- package/dist/tokens/generated/tokens.js +299 -0
- package/fonts/OFL.txt +97 -0
- package/fonts/SourceCodePro-Bold.ttf +0 -0
- package/fonts/SourceCodePro-Regular.ttf +0 -0
- package/fonts/SourceSans3-Black.ttf +0 -0
- package/fonts/SourceSans3-Bold.ttf +0 -0
- package/fonts/SourceSans3-Regular.ttf +0 -0
- package/fonts/SourceSerif4-Bold.ttf +0 -0
- package/package.json +88 -4
- package/tokens/generated/tokens.css +215 -0
- package/tokens/generated/tokens.json +298 -0
- package/tokens/generated/tokens.ts +302 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// Metro and diagram pieces (spec illustration-pieces, change
|
|
2
|
+
// metro-and-diagram-pieces; design §3). They paint what the caller lays out:
|
|
3
|
+
// positions, text measurement and truncation stay with the consumer
|
|
4
|
+
// (stackledger's map engine). Each draws on a surface, light or dark, with the
|
|
5
|
+
// ink sticker of stackledger's map: hard shadow in the surface's shadow colour,
|
|
6
|
+
// a light rim on dark, then the face outlined in ink.
|
|
7
|
+
//
|
|
8
|
+
// What can go wrong: every parameter is checked by its schema first; the
|
|
9
|
+
// cross-parameter limits (room for the outline, width against height, arrow
|
|
10
|
+
// length) are checked here and thrown as a RangeError naming the parameter.
|
|
11
|
+
import { tokens } from "../../tokens/generated/tokens.js";
|
|
12
|
+
import { atLeast, inkOf, inkSchema, limits, roomFor, sticker, surfaceParam, words } from "./ink.js";
|
|
13
|
+
import { drawn, el, g, r2 } from "./node.js";
|
|
14
|
+
import { col, colour, label, MAX_SIZE, PATH_DATA, paint, pos, size } from "./params.js";
|
|
15
|
+
import { definePiece } from "./piece.js";
|
|
16
|
+
export { SURFACES } from "./ink.js";
|
|
17
|
+
const ink = tokens.color.ink;
|
|
18
|
+
const white = tokens.color.white;
|
|
19
|
+
const font = tokens.font.sans;
|
|
20
|
+
const bold = tokens.font.weightBold;
|
|
21
|
+
const M = tokens.map;
|
|
22
|
+
const dataColour = (required = true) => ({ kind: "dataColor", required });
|
|
23
|
+
const point = (required = true) => ({ kind: "point", required });
|
|
24
|
+
const pill = (x, y, w, h) => (dx, dy, attrs) => el("rect", { x: r2(x + dx), y: r2(y + dy), width: r2(w), height: r2(h), rx: r2(h / 2), ...attrs });
|
|
25
|
+
// Without a text, the default width is the one-character width (card 167).
|
|
26
|
+
const badgeWidth = ({ width, text }) => width ?? Math.max(30, 7.6 * (text === undefined ? 1 : Array.from(text).length) + 18);
|
|
27
|
+
/** A line's terminal badge: a pill in the line colour with its code in white, centred on (x, y); without `text`, the pill alone. */
|
|
28
|
+
export const lineBadge = definePiece("lineBadge", { x: pos(), y: pos(), text: label(false), fill: dataColour(), width: size(), height: size(), flat: { kind: "boolean" }, ...inkSchema }, (params) => {
|
|
29
|
+
const { x, y, text, fill, height = M.badgeHeight, flat = false } = params;
|
|
30
|
+
const width = badgeWidth(params);
|
|
31
|
+
const face = paint(fill);
|
|
32
|
+
const { line, outline } = inkOf(params);
|
|
33
|
+
const inset = flat ? outline / 2 : 0;
|
|
34
|
+
const shape = pill(x - width / 2 + inset, y - height / 2 + inset, width - 2 * inset, height - 2 * inset);
|
|
35
|
+
const body = flat ? [shape(0, 0, { fill: face, stroke: line, "stroke-width": r2(outline), "stroke-linejoin": "round" })] : sticker(shape, face, params);
|
|
36
|
+
return drawn(body, text === undefined ? [] : [words(x, y + 4.5, text, { fill: white, "font-size": M.badgeTextSize, "font-weight": bold, "text-anchor": "middle" })]);
|
|
37
|
+
}, (params) => {
|
|
38
|
+
const height = params.height ?? M.badgeHeight;
|
|
39
|
+
return limits(atLeast("width", badgeWidth(params), height, "the height"), roomFor("height", height, params));
|
|
40
|
+
});
|
|
41
|
+
/** Closed capsule round the segment a-b (stackledger's capsulePath). */
|
|
42
|
+
const capsule = (a, b, r, dx, dy) => {
|
|
43
|
+
// The normal comes from the segment itself; the shadow's offset moves the result, so a very short
|
|
44
|
+
// segment never collapses to zero length once moved.
|
|
45
|
+
const length = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
46
|
+
const n = [(-(b[1] - a[1]) / length) * r, ((b[0] - a[0]) / length) * r];
|
|
47
|
+
const p = (q, k) => `${r2(q[0] + dx + n[0] * k)},${r2(q[1] + dy + n[1] * k)}`;
|
|
48
|
+
const radius = r2(r);
|
|
49
|
+
return `M${p(a, 1)} L${p(b, 1)} A${radius},${radius} 0 0 0 ${p(b, -1)} L${p(a, -1)} A${radius},${radius} 0 0 0 ${p(a, 1)} Z`;
|
|
50
|
+
};
|
|
51
|
+
const markerRadius = ({ r, to }) => r ?? (to ? M.stopRadius + M.interchangeExtra : M.stopRadius);
|
|
52
|
+
/** A stop (disc), or with `to` an interchange (capsule from the centre to `to`); deprecated is muted. */
|
|
53
|
+
export const stationMarker = definePiece("stationMarker", { cx: pos(), cy: pos(), to: point(false), r: size(), state: { kind: "enum", values: ["normal", "deprecated"] }, ...inkSchema }, (params) => {
|
|
54
|
+
const { cx, cy, to, state = "normal" } = params;
|
|
55
|
+
const r = markerRadius(params);
|
|
56
|
+
const face = state === "deprecated" ? inkOf(params).s.muted : white;
|
|
57
|
+
const long = to !== undefined && Math.hypot(to[0] - cx, to[1] - cy) > 0;
|
|
58
|
+
const shape = long
|
|
59
|
+
? (dx, dy, attrs) => el("path", { d: capsule([cx, cy], to, r, dx, dy), ...attrs })
|
|
60
|
+
: (dx, dy, attrs) => el("circle", { cx: r2(cx + dx), cy: r2(cy + dy), r: r2(r), ...attrs });
|
|
61
|
+
return drawn(sticker(shape, face, params));
|
|
62
|
+
}, (params) => limits(roomFor("r", 2 * markerRadius(params), params)));
|
|
63
|
+
const PIPE_PATH = { kind: "string", required: true, nonEmpty: true, pattern: new RegExp(`^\\s*[Mm]${PATH_DATA.source.slice(1, -2)}*$`), patternName: "SVG path data starting with M (commands, numbers, commas and spaces only)" };
|
|
64
|
+
/** A line: its colour over an ink casing, round caps and joins, no shadow. */
|
|
65
|
+
export const pipe = definePiece("pipe", { d: PIPE_PATH, fill: dataColour(), width: { kind: "number", min: 0, exclusiveMin: true, max: 100 }, casing: { kind: "number", min: 0, max: 50 } }, ({ d, fill, width = M.lineWidth, casing = M.casing }) => {
|
|
66
|
+
const line = { d, fill: "none", "stroke-linecap": "round", "stroke-linejoin": "round" };
|
|
67
|
+
return drawn([
|
|
68
|
+
// Stroke widths as given: a valid hairline must not round to zero.
|
|
69
|
+
...(casing > 0 ? [el("path", { ...line, stroke: ink, "stroke-width": width + casing })] : []),
|
|
70
|
+
el("path", { ...line, stroke: paint(fill), "stroke-width": width }),
|
|
71
|
+
]);
|
|
72
|
+
});
|
|
73
|
+
// `textSize` scales the default height, the per-character width and the baseline with it (card 190);
|
|
74
|
+
// without it, k is 1 and every expression is the 0.5.0 one.
|
|
75
|
+
const countScale = ({ textSize }) => (textSize ?? M.countTextSize) / M.countTextSize;
|
|
76
|
+
const countHeight = (params) => params.height ?? (params.textSize === undefined ? M.countHeight : r2(M.countHeight * countScale(params)));
|
|
77
|
+
const countWidth = (params) => {
|
|
78
|
+
const { width, text } = params;
|
|
79
|
+
const height = countHeight(params);
|
|
80
|
+
const k = countScale(params);
|
|
81
|
+
const characters = Array.from(text).length;
|
|
82
|
+
return width ?? (characters === 1 ? height : Math.max(height, k === 1 ? 6.4 * characters + 8 : r2(k * (6.4 * characters + 8))));
|
|
83
|
+
};
|
|
84
|
+
/** A count (rules of a skill): a circle when as wide as high, a pill otherwise, in the surface's panel colour. */
|
|
85
|
+
export const countBadge = definePiece("countBadge", { cx: pos(), cy: pos(), text: label(), width: size(), height: size(), textSize: { kind: "number", min: 6, max: 48 }, ...inkSchema }, (params) => {
|
|
86
|
+
const { cx, cy, text, textSize = M.countTextSize } = params;
|
|
87
|
+
const height = countHeight(params);
|
|
88
|
+
const width = countWidth(params);
|
|
89
|
+
const { s } = inkOf(params);
|
|
90
|
+
const shape = width === height ? (dx, dy, attrs) => el("circle", { cx: r2(cx + dx), cy: r2(cy + dy), r: r2(height / 2), ...attrs }) : pill(cx - width / 2, cy - height / 2, width, height);
|
|
91
|
+
return drawn(sticker(shape, s.panel, params), [words(cx, cy + 4 * countScale(params), text, { fill: s.text, "font-size": textSize, "font-weight": bold, "text-anchor": "middle" })]);
|
|
92
|
+
}, (params) => {
|
|
93
|
+
const height = countHeight(params);
|
|
94
|
+
// A height derived from textSize is reported at textSize, the parameter the caller passed (card 190).
|
|
95
|
+
const name = params.height === undefined && params.textSize !== undefined ? "textSize" : "height";
|
|
96
|
+
return limits(atLeast("width", countWidth(params), height, "the height"), roomFor(name, height, params));
|
|
97
|
+
});
|
|
98
|
+
const nodeSchema = {
|
|
99
|
+
x: pos(),
|
|
100
|
+
y: pos(),
|
|
101
|
+
width: size(true),
|
|
102
|
+
height: size(),
|
|
103
|
+
title: label(),
|
|
104
|
+
subtitle: label(false),
|
|
105
|
+
state: { kind: "enum", values: ["normal", "focus", "placeholder"] },
|
|
106
|
+
...inkSchema,
|
|
107
|
+
};
|
|
108
|
+
const nodeLimits = (kind) => (params) => {
|
|
109
|
+
const { width, height = M.nodeHeight, subtitle, state = "normal" } = params;
|
|
110
|
+
const radius = params.radius ?? M.nodeRadius;
|
|
111
|
+
return limits(atLeast("width", width, 2 * height, "twice the height"), kind === "box" && radius > height / 2 && { path: "radius", message: `must be at most half the height (${r2(height / 2)}), found ${r2(radius)}` }, state !== "placeholder" && roomFor("height", height, params));
|
|
112
|
+
};
|
|
113
|
+
const drawNode = (kind, params) => {
|
|
114
|
+
const { x, y, width, height = M.nodeHeight, title, subtitle, state = "normal" } = params;
|
|
115
|
+
const inset = kind === "box" ? 12 : height / 2;
|
|
116
|
+
const radius = kind === "pill" ? height / 2 : (params.radius ?? M.nodeRadius);
|
|
117
|
+
const shape = kind === "hex"
|
|
118
|
+
? (dx, dy, attrs) => {
|
|
119
|
+
const [l, t, c] = [x + dx, y + dy, height / 2];
|
|
120
|
+
const points = [[l + c, t], [l + width - c, t], [l + width, t + c], [l + width - c, t + height], [l + c, t + height], [l, t + c]];
|
|
121
|
+
return el("polygon", { points: points.map(([px, py]) => `${r2(px)},${r2(py)}`).join(" "), ...attrs });
|
|
122
|
+
}
|
|
123
|
+
: (dx, dy, attrs) => el("rect", { x: r2(x + dx), y: r2(y + dy), width: r2(width), height: r2(height), rx: r2(radius), ...attrs });
|
|
124
|
+
const { s } = inkOf(params);
|
|
125
|
+
const middle = y + height / 2;
|
|
126
|
+
if (state === "placeholder") {
|
|
127
|
+
const dashed = [shape(0, 0, { fill: "none", stroke: s.muted, "stroke-width": 1.5, "stroke-dasharray": "5 4", "stroke-linejoin": "round" })];
|
|
128
|
+
// With a subtitle, a normal node's text layout, every word muted (stackledger's unlinked box; card 167).
|
|
129
|
+
return drawn(dashed, subtitle === undefined
|
|
130
|
+
? [words(x + width / 2, middle + 4.5, title, { fill: s.muted, "font-size": M.labelSize, "font-weight": 400, "text-anchor": "middle" })]
|
|
131
|
+
: [
|
|
132
|
+
words(x + inset, middle - 3, title, { fill: s.muted, "font-size": M.labelSize, "font-weight": bold, "text-anchor": "start" }),
|
|
133
|
+
words(x + inset, middle + 14, subtitle, { fill: s.muted, "font-size": 11, "font-weight": 400, "text-anchor": "start" }),
|
|
134
|
+
]);
|
|
135
|
+
}
|
|
136
|
+
const focus = state === "focus";
|
|
137
|
+
const titleFill = focus ? ink : s.text;
|
|
138
|
+
const text = subtitle === undefined
|
|
139
|
+
? [words(x + inset, middle + 4.5, title, { fill: titleFill, "font-size": M.labelSize, "font-weight": bold, "text-anchor": "start" })]
|
|
140
|
+
: [
|
|
141
|
+
words(x + inset, middle - 3, title, { fill: titleFill, "font-size": M.labelSize, "font-weight": bold, "text-anchor": "start" }),
|
|
142
|
+
words(x + inset, middle + 14, subtitle, { fill: focus ? ink : s.muted, "font-size": 11, "font-weight": 400, "text-anchor": "start" }),
|
|
143
|
+
];
|
|
144
|
+
return drawn(sticker(shape, focus ? tokens.color.state.caller : s.panel, params), text);
|
|
145
|
+
};
|
|
146
|
+
/** A diagram box (a skill, a software item): rounded rect with a title and an optional subtitle. */
|
|
147
|
+
export const nodeBlock = definePiece("nodeBlock", { ...nodeSchema, radius: { kind: "number", min: 0, max: MAX_SIZE } }, (p) => drawNode("box", p), nodeLimits("box"));
|
|
148
|
+
/** A diagram pill (a playbook). */
|
|
149
|
+
export const pillNode = definePiece("pillNode", nodeSchema, (p) => drawNode("pill", p), nodeLimits("pill"));
|
|
150
|
+
/** A diagram hexagon (an agent). */
|
|
151
|
+
export const hexNode = definePiece("hexNode", nodeSchema, (p) => drawNode("hex", p), nodeLimits("hex"));
|
|
152
|
+
/** An edge with a head at `to`: curved (leaves and enters horizontally), straight, or through the caller's two
|
|
153
|
+
* control points, with an optional label. `kind` paints a reply, a failure or a fail-fast path (card 141). */
|
|
154
|
+
export const messageArrow = definePiece("messageArrow", {
|
|
155
|
+
from: point(),
|
|
156
|
+
to: point(),
|
|
157
|
+
curve: { kind: "enum", values: ["bezier", "straight"] },
|
|
158
|
+
controls: { kind: "array", minItems: 2, maxItems: 2, of: point() },
|
|
159
|
+
head: { kind: "boolean" },
|
|
160
|
+
heads: { kind: "enum", values: ["end", "start", "both"] },
|
|
161
|
+
dashed: { kind: "boolean" },
|
|
162
|
+
label: label(false),
|
|
163
|
+
width: { kind: "number", min: 1, max: 12 },
|
|
164
|
+
kind: { kind: "enum", values: ["message", "reply", "failure", "failFast"] },
|
|
165
|
+
surface: surfaceParam,
|
|
166
|
+
}, ({ from, to, curve = "bezier", controls, head = true, heads = "end", dashed, label: text, width = M.edgeWidth, kind = "message", surface = "light" }) => {
|
|
167
|
+
const s = tokens.surface[surface];
|
|
168
|
+
const paint_ = kind === "failure" ? tokens.color.state.failure : kind === "failFast" ? tokens.color.state.failFast : s.text;
|
|
169
|
+
const length = 5 * width;
|
|
170
|
+
const distance = Math.hypot(to[0] - from[0], to[1] - from[1]);
|
|
171
|
+
const dx = to[0] - from[0];
|
|
172
|
+
// A curve whose ends are almost above each other has no horizontal entry: draw it straight.
|
|
173
|
+
const bent = controls === undefined && curve === "bezier" && Math.abs(dx) > 2 * length;
|
|
174
|
+
// With controls, the head points from the last of c2, c1, from that differs from `to` (design §5).
|
|
175
|
+
const towards = (q) => {
|
|
176
|
+
const l = Math.hypot(to[0] - q[0], to[1] - q[1]);
|
|
177
|
+
return [(to[0] - q[0]) / l, (to[1] - q[1]) / l];
|
|
178
|
+
};
|
|
179
|
+
const tail = controls && [controls[1], controls[0], from].find((q) => q[0] !== to[0] || q[1] !== to[1]);
|
|
180
|
+
const direction = tail !== undefined ? towards(tail) : bent ? [Math.sign(dx), 0] : [dx / distance, (to[1] - from[1]) / distance];
|
|
181
|
+
const atEnd = head && heads !== "start";
|
|
182
|
+
const atStart = head && heads !== "end";
|
|
183
|
+
const end = atEnd ? [to[0] - direction[0] * length, to[1] - direction[1] * length] : to;
|
|
184
|
+
// A head at `from` points back at it, from the first of c1, c2, to that differs from `from` (card 190).
|
|
185
|
+
const away = (q) => {
|
|
186
|
+
const l = Math.hypot(from[0] - q[0], from[1] - q[1]);
|
|
187
|
+
return [(from[0] - q[0]) / l, (from[1] - q[1]) / l];
|
|
188
|
+
};
|
|
189
|
+
const lead = controls && [controls[0], controls[1], to].find((q) => q[0] !== from[0] || q[1] !== from[1]);
|
|
190
|
+
const back = lead !== undefined ? away(lead) : bent ? [-Math.sign(dx), 0] : [-direction[0], -direction[1]];
|
|
191
|
+
const start = atStart ? [from[0] - back[0] * length, from[1] - back[1] * length] : from;
|
|
192
|
+
const mx = (from[0] + to[0]) / 2;
|
|
193
|
+
const at = (p) => `${r2(p[0])},${r2(p[1])}`;
|
|
194
|
+
const d = controls
|
|
195
|
+
? `M${at(start)} C${at(controls[0])} ${at(controls[1])} ${at(end)}`
|
|
196
|
+
: bent
|
|
197
|
+
? `M${at(start)} C${r2(mx)},${r2(from[1])} ${r2(mx)},${r2(to[1])} ${at(end)}`
|
|
198
|
+
: `M${at(start)} L${at(end)}`;
|
|
199
|
+
const dash = !(dashed ?? kind !== "message") ? {} : { "stroke-dasharray": `${r2(2.4 * width)} ${r2(3.2 * width)}` };
|
|
200
|
+
const body = [el("path", { d, fill: "none", stroke: paint_, "stroke-width": r2(width), "stroke-linecap": "round", ...dash })];
|
|
201
|
+
const arrowhead = (tip, base, along) => {
|
|
202
|
+
const normal = [-along[1] * 2 * width, along[0] * 2 * width];
|
|
203
|
+
const points = [tip, [base[0] + normal[0], base[1] + normal[1]], [base[0] - normal[0], base[1] - normal[1]]];
|
|
204
|
+
body.push(el("polygon", { points: points.map(at).join(" "), fill: paint_, stroke: paint_, "stroke-width": 1, "stroke-linejoin": "round" }));
|
|
205
|
+
};
|
|
206
|
+
if (atEnd)
|
|
207
|
+
arrowhead(to, end, direction);
|
|
208
|
+
if (atStart)
|
|
209
|
+
arrowhead(from, start, back);
|
|
210
|
+
const words_ = [];
|
|
211
|
+
if (text !== undefined) {
|
|
212
|
+
const middle = [mx, (from[1] + to[1]) / 2];
|
|
213
|
+
const w = 6.4 * Array.from(text).length + 16;
|
|
214
|
+
body.push(el("rect", { x: r2(middle[0] - w / 2), y: r2(middle[1] - 9), width: r2(w), height: 18, rx: 9, fill: s.background, stroke: s.text, "stroke-width": 1.5 }));
|
|
215
|
+
words_.push(words(middle[0], middle[1] + 4, text, { fill: s.text, "font-size": 11, "font-weight": 400, "text-anchor": "middle" }));
|
|
216
|
+
}
|
|
217
|
+
return drawn(body, words_);
|
|
218
|
+
}, ({ from, to, head = true, heads, width = M.edgeWidth, controls, curve }) => {
|
|
219
|
+
const distance = Math.hypot(to[0] - from[0], to[1] - from[1]);
|
|
220
|
+
const need = (heads === "both" ? 20 : 10) * width;
|
|
221
|
+
return limits(head === false && heads !== undefined && { path: "heads", message: "cannot be combined with head: false" }, distance === 0 && { path: "to", message: "must differ from from" }, distance > 0 && head && distance < need && { path: "to", message: `is too close to from for the ${heads === "both" ? "heads" : "head"}: needs at least ${r2(need)}, found ${r2(distance)}` }, controls !== undefined && curve !== undefined && { path: "controls", message: "cannot be combined with curve" });
|
|
222
|
+
});
|
|
223
|
+
/** stackledger's mark (favicon, header), the "Folha" of card 303: a white page with one outline, a bent line and
|
|
224
|
+
* two stations, 32 units scaled to `size`. The outline is ink on the light surface and surface.dark.muted on the dark
|
|
225
|
+
* one, so the page keeps one outline that reads on either background (ADR 0009); the stations sit on the white page
|
|
226
|
+
* and stay ink. */
|
|
227
|
+
export const ledgerMark = definePiece("ledgerMark", { x: pos(), y: pos(), size: { kind: "number", min: 12, max: 512 }, line: col(), surface: surfaceParam }, ({ x, y, size: side = 32, line = "illustration.accent", surface = "light" }) => {
|
|
228
|
+
// The stroke is centred on the rect's edge: inset by half the outline, the page stays inside the 32 box.
|
|
229
|
+
const outline = 1.25;
|
|
230
|
+
const inset = outline / 2;
|
|
231
|
+
const page = el("rect", {
|
|
232
|
+
x: inset,
|
|
233
|
+
y: inset,
|
|
234
|
+
width: 32 - outline,
|
|
235
|
+
height: 32 - outline,
|
|
236
|
+
rx: 6.6,
|
|
237
|
+
fill: white,
|
|
238
|
+
stroke: surface === "dark" ? tokens.surface.dark.muted : ink,
|
|
239
|
+
"stroke-width": outline,
|
|
240
|
+
});
|
|
241
|
+
return drawn([
|
|
242
|
+
g({ transform: `translate(${r2(x)} ${r2(y)}) scale(${side / 32})` }, page, el("path", { d: "M7 23 L14 16 L25 16", fill: "none", stroke: colour(line, "line"), "stroke-width": 4.5, "stroke-linecap": "round", "stroke-linejoin": "round" }), el("circle", { cx: 14, cy: 16, r: 4, fill: white, stroke: ink, "stroke-width": 2 }), el("circle", { cx: 25, cy: 16, r: 2.6, fill: white, stroke: ink, "stroke-width": 1.6 })),
|
|
243
|
+
]);
|
|
244
|
+
});
|
|
245
|
+
/** The renewal ring: bands like a bent pipe round a station (a rim when the surface has one, the ink line, then
|
|
246
|
+
* color.state.blocked), no shadow. */
|
|
247
|
+
export const renewalRing = definePiece("renewalRing", { cx: pos(), cy: pos(), r: size(true), width: { kind: "number", min: 0, exclusiveMin: true, max: 50 }, ...inkSchema }, (params) => {
|
|
248
|
+
const { cx, cy, r, width = M.ringWidth } = params;
|
|
249
|
+
const { s, line, outline, rim } = inkOf(params);
|
|
250
|
+
// Radius and band widths as given, like pipe's widths: a valid hairline must not round to zero.
|
|
251
|
+
const band = (stroke, strokeWidth) => el("circle", { cx: r2(cx), cy: r2(cy), r, fill: "none", stroke, "stroke-width": strokeWidth });
|
|
252
|
+
return drawn([...(s.rimWidth > 0 ? [band(s.rim, width + outline + 2 * rim)] : []), band(line, width + outline), band(tokens.color.state.blocked, width)]);
|
|
253
|
+
}, (params) => {
|
|
254
|
+
const { outline, rim } = inkOf(params);
|
|
255
|
+
const need = ((params.width ?? M.ringWidth) + outline + 2 * rim) / 2;
|
|
256
|
+
return limits(params.r < need && { path: "r", message: `leaves no room for the ring's bands: needs at least ${r2(need)}` });
|
|
257
|
+
});
|
|
258
|
+
/** The suggested-position halo: a dashed muted circle, no ink. */
|
|
259
|
+
export const suggestedHalo = definePiece("suggestedHalo", { cx: pos(), cy: pos(), r: size(true), surface: surfaceParam }, ({ cx, cy, r, surface = "light" }) => drawn([el("circle", { cx: r2(cx), cy: r2(cy), r, fill: "none", stroke: tokens.surface[surface].muted, "stroke-width": M.haloWidth, "stroke-dasharray": "4 3" })]));
|
|
260
|
+
/** A licence: a small disc sticker, green when held, white to buy. Its own room rule: size ≥ 3 × outline. */
|
|
261
|
+
export const licenceMark = definePiece("licenceMark", { cx: pos(), cy: pos(), state: { kind: "enum", values: ["owned", "toBuy"] }, size: size(), ...inkSchema }, (params) => {
|
|
262
|
+
const { cx, cy, state = "owned", size: side = M.licenceSize } = params;
|
|
263
|
+
const shape = (dx, dy, attrs) => el("circle", { cx: r2(cx + dx), cy: r2(cy + dy), r: r2(side / 2), ...attrs });
|
|
264
|
+
return drawn(sticker(shape, state === "owned" ? tokens.color.state.healthy : white, params));
|
|
265
|
+
}, (params) => {
|
|
266
|
+
const need = 3 * inkOf(params).outline;
|
|
267
|
+
const side = params.size ?? M.licenceSize;
|
|
268
|
+
return limits(side < need && { path: "size", message: `leaves no room for the licence's face: needs at least ${r2(need)} at this ink scale` });
|
|
269
|
+
});
|
|
270
|
+
/** Mixes a #RRGGBB colour with white by `amount` (stackledger's zone title tint). */
|
|
271
|
+
const tint = (hex, amount) => "#" + [1, 3, 5].map((i) => Math.round(parseInt(hex.slice(i, i + 2), 16) * (1 - amount) + 255 * amount).toString(16).padStart(2, "0").toUpperCase()).join("");
|
|
272
|
+
/** A zone: the outline the caller gives (stackledger's hull), widened by a round stroke, at the surface's zone opacity; an optional title. */
|
|
273
|
+
export const zone = definePiece("zone", { points: { kind: "array", required: true, minItems: 1, maxItems: 10000, of: point() }, fill: dataColour(), title: label(false), titleAt: point(false), surface: surfaceParam }, ({ points, fill, title, titleAt, surface = "light" }) => {
|
|
274
|
+
const colourOf = paint(fill);
|
|
275
|
+
const pad = M.zonePadding;
|
|
276
|
+
const at = (p) => `${r2(p[0])},${r2(p[1])}`;
|
|
277
|
+
const shape = points.length === 1
|
|
278
|
+
? el("circle", { cx: r2(points[0][0]), cy: r2(points[0][1]), r: pad, fill: colourOf })
|
|
279
|
+
: points.length === 2
|
|
280
|
+
? el("line", { x1: r2(points[0][0]), y1: r2(points[0][1]), x2: r2(points[1][0]), y2: r2(points[1][1]), stroke: colourOf, "stroke-width": 2 * pad, "stroke-linecap": "round" })
|
|
281
|
+
: el("polygon", { points: points.map(at).join(" "), fill: colourOf, stroke: colourOf, "stroke-width": 2 * pad, "stroke-linejoin": "round" });
|
|
282
|
+
const titleFill = surface === "dark" ? tint(colourOf, M.zoneTitleTint) : colourOf;
|
|
283
|
+
const text = title !== undefined && titleAt !== undefined
|
|
284
|
+
? [words(titleAt[0], titleAt[1] + 13, title, { fill: titleFill, "font-size": M.labelSize, "font-weight": bold, "text-anchor": "start" })]
|
|
285
|
+
: [];
|
|
286
|
+
return drawn([g({ opacity: tokens.surface[surface].zoneOpacity, stroke: "none" }, shape)], text);
|
|
287
|
+
}, ({ title, titleAt }) => limits(title !== undefined && titleAt === undefined && { path: "titleAt", message: "is required with a title" }, titleAt !== undefined && title === undefined && { path: "title", message: "is required with titleAt" }));
|
|
288
|
+
export const METRO_PIECES = { lineBadge, stationMarker, pipe, countBadge, nodeBlock, pillNode, hexNode, messageArrow, ledgerMark, renewalRing, suggestedHalo, licenceMark, zone };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const SVG_TAGS: readonly ["svg", "g", "title", "desc", "defs", "clipPath", "style", "rect", "circle", "ellipse", "line", "polyline", "polygon", "path", "text", "tspan"];
|
|
2
|
+
export type SvgTag = (typeof SVG_TAGS)[number];
|
|
3
|
+
export type AttrValue = string | number;
|
|
4
|
+
export type Attrs = Readonly<Record<string, AttrValue>>;
|
|
5
|
+
export type SvgNode = {
|
|
6
|
+
readonly tag: SvgTag;
|
|
7
|
+
readonly attrs: Attrs;
|
|
8
|
+
readonly children: readonly (SvgNode | string)[];
|
|
9
|
+
};
|
|
10
|
+
/** What a piece draws: shapes go in the outlined group, words and glyphs after every shape. */
|
|
11
|
+
export type Drawn = {
|
|
12
|
+
readonly body: readonly SvgNode[];
|
|
13
|
+
readonly text: readonly SvgNode[];
|
|
14
|
+
};
|
|
15
|
+
type Child = SvgNode | string | null | false | undefined;
|
|
16
|
+
export declare const el: (tag: SvgTag, attrs?: Attrs, ...children: Child[]) => SvgNode;
|
|
17
|
+
export declare const g: (attrs: Attrs, ...children: Child[]) => SvgNode;
|
|
18
|
+
export declare const drawn: (body: readonly SvgNode[], text?: readonly SvgNode[]) => Drawn;
|
|
19
|
+
/**
|
|
20
|
+
* Hard offset shadow: the pieces draw none since 0.7.0 (ADR 0009, `shadow.block`
|
|
21
|
+
* is 0), so with offset 0 this returns the shape alone and the output carries no
|
|
22
|
+
* hidden node. With an offset above 0, for a caller that still wants one: an ink
|
|
23
|
+
* copy of the shape translated by `offset`, then the shape. Inside the outlined
|
|
24
|
+
* group the copy keeps the outline too.
|
|
25
|
+
*/
|
|
26
|
+
export declare const shadowed: (shape: SvgNode, offset?: number) => SvgNode[];
|
|
27
|
+
/** Rounds to two decimals so computed geometry stays short and stable in the output. */
|
|
28
|
+
export declare const r2: (value: number) => number;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// SVG node contract of the illustration pieces (spec illustration-pieces;
|
|
2
|
+
// design §3 of the illustration-pieces change).
|
|
3
|
+
//
|
|
4
|
+
// Why: a piece returns plain data, not markup or React, so the same drawing
|
|
5
|
+
// becomes an SVG string for covers and diagrams and React elements for
|
|
6
|
+
// Remotion scenes, and tests can inspect it without a browser.
|
|
7
|
+
//
|
|
8
|
+
// What can go wrong: nothing here reads files or the clock; helpers only build
|
|
9
|
+
// objects. Colour and number guards live in params.ts.
|
|
10
|
+
import { tokens } from "../../tokens/generated/tokens.js";
|
|
11
|
+
export const SVG_TAGS = [
|
|
12
|
+
"svg",
|
|
13
|
+
"g",
|
|
14
|
+
"title",
|
|
15
|
+
"desc",
|
|
16
|
+
"defs",
|
|
17
|
+
"clipPath",
|
|
18
|
+
"style",
|
|
19
|
+
"rect",
|
|
20
|
+
"circle",
|
|
21
|
+
"ellipse",
|
|
22
|
+
"line",
|
|
23
|
+
"polyline",
|
|
24
|
+
"polygon",
|
|
25
|
+
"path",
|
|
26
|
+
"text",
|
|
27
|
+
"tspan",
|
|
28
|
+
];
|
|
29
|
+
export const el = (tag, attrs = {}, ...children) => ({
|
|
30
|
+
tag,
|
|
31
|
+
attrs,
|
|
32
|
+
children: children.filter((child) => child !== null && child !== false && child !== undefined),
|
|
33
|
+
});
|
|
34
|
+
export const g = (attrs, ...children) => el("g", attrs, ...children);
|
|
35
|
+
export const drawn = (body, text = []) => ({ body, text });
|
|
36
|
+
/**
|
|
37
|
+
* Hard offset shadow: the pieces draw none since 0.7.0 (ADR 0009, `shadow.block`
|
|
38
|
+
* is 0), so with offset 0 this returns the shape alone and the output carries no
|
|
39
|
+
* hidden node. With an offset above 0, for a caller that still wants one: an ink
|
|
40
|
+
* copy of the shape translated by `offset`, then the shape. Inside the outlined
|
|
41
|
+
* group the copy keeps the outline too.
|
|
42
|
+
*/
|
|
43
|
+
export const shadowed = (shape, offset = tokens.shadow.block) => offset === 0 ? [shape] : [
|
|
44
|
+
{
|
|
45
|
+
...shape,
|
|
46
|
+
attrs: {
|
|
47
|
+
...shape.attrs,
|
|
48
|
+
fill: tokens.color.ink,
|
|
49
|
+
// The offset applies after the shape's own transform, so a turned shape casts a turned shadow.
|
|
50
|
+
transform: shape.attrs.transform === undefined ? `translate(${offset} ${offset})` : `translate(${offset} ${offset}) ${shape.attrs.transform}`,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
shape,
|
|
54
|
+
];
|
|
55
|
+
/** Rounds to two decimals so computed geometry stays short and stable in the output. */
|
|
56
|
+
export const r2 = (value) => (Math.abs(value) < 1e12 ? Math.round(value * 100) / 100 : value);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Schema } from "./params.ts";
|
|
2
|
+
export type PillParams = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
text: string;
|
|
6
|
+
fill?: string;
|
|
7
|
+
width?: number;
|
|
8
|
+
};
|
|
9
|
+
/** Pill label centred on (x, y), usually overlapping the top edge of what it names. Backticks mark code (card 190). */
|
|
10
|
+
export declare const pill: import("./piece.ts").Piece<PillParams>;
|
|
11
|
+
export type SheetRow = {
|
|
12
|
+
lead?: "none" | "checkbox" | "checked" | "question";
|
|
13
|
+
bar: number;
|
|
14
|
+
tail?: "none" | "check";
|
|
15
|
+
};
|
|
16
|
+
export type SheetParams = {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
rows: SheetRow[];
|
|
22
|
+
top?: number;
|
|
23
|
+
step?: number;
|
|
24
|
+
fill?: string;
|
|
25
|
+
leadFill?: string;
|
|
26
|
+
tick?: string;
|
|
27
|
+
};
|
|
28
|
+
/** The shape of one sheet row; Visor's held sheet takes the same rows (brand-cast.ts). */
|
|
29
|
+
export declare const sheetRowSchema: Schema;
|
|
30
|
+
/** A sheet of paper with rows of text bars, an optional lead mark and an optional tick at the end. */
|
|
31
|
+
export declare const sheet: import("./piece.ts").Piece<SheetParams>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// The paper pieces, `pill` and `sheet` (spec illustration-pieces, "Piece
|
|
2
|
+
// catalogue"), moved unchanged from library.ts by change sdd-scene-pieces
|
|
3
|
+
// (card 333): Visor draws them in its hand (`holdsSheet`, brand-cast.ts), and
|
|
4
|
+
// brand-cast.ts cannot import library.ts, which imports it. library.ts
|
|
5
|
+
// re-exports both, so the catalogue and its order are the same.
|
|
6
|
+
//
|
|
7
|
+
// What can go wrong: the schemas reject an empty label, a sheet narrower than
|
|
8
|
+
// 80 and an unknown row lead or tail, naming the parameter.
|
|
9
|
+
import { tokens } from "../../tokens/generated/tokens.js";
|
|
10
|
+
import { drawn, el, g, shadowed } from "./node.js";
|
|
11
|
+
import { col, colour, label, pos, size } from "./params.js";
|
|
12
|
+
import { definePiece } from "./piece.js";
|
|
13
|
+
import { codeLength, spans } from "./ink.js";
|
|
14
|
+
const ink = tokens.color.ink;
|
|
15
|
+
/** Pill label centred on (x, y), usually overlapping the top edge of what it names. Backticks mark code (card 190). */
|
|
16
|
+
export const pill = definePiece("pill", { x: pos(), y: pos(), text: label(), fill: col(), width: size() }, ({ x, y, text, fill = "color.white", width }) => {
|
|
17
|
+
const h = tokens.cover.pillHeight;
|
|
18
|
+
const w = width ?? Math.max(68, Math.round(codeLength(text) * 10.5 + 34));
|
|
19
|
+
return drawn([el("rect", { x: x - w / 2, y: y - h / 2, width: w, height: h, rx: h / 2, fill: colour(fill, "fill") })], [el("text", { x, y: y + 7 }, ...spans(text))]);
|
|
20
|
+
});
|
|
21
|
+
/** The shape of one sheet row; Visor's held sheet takes the same rows (brand-cast.ts). */
|
|
22
|
+
export const sheetRowSchema = {
|
|
23
|
+
lead: { kind: "enum", values: ["none", "checkbox", "checked", "question"] },
|
|
24
|
+
bar: size(true),
|
|
25
|
+
tail: { kind: "enum", values: ["none", "check"] },
|
|
26
|
+
};
|
|
27
|
+
/** A sheet of paper with rows of text bars, an optional lead mark and an optional tick at the end. */
|
|
28
|
+
export const sheet = definePiece("sheet", {
|
|
29
|
+
x: pos(),
|
|
30
|
+
y: pos(),
|
|
31
|
+
width: size(true, 80),
|
|
32
|
+
height: size(true),
|
|
33
|
+
rows: { kind: "array", required: true, of: { kind: "object", fields: sheetRowSchema } },
|
|
34
|
+
top: size(),
|
|
35
|
+
step: size(),
|
|
36
|
+
fill: col(),
|
|
37
|
+
leadFill: col(),
|
|
38
|
+
tick: col(),
|
|
39
|
+
}, ({ x, y, width, height, rows, top = 46, step = 38, fill = "color.white", leadFill = "color.ink", tick = "color.white" }) => {
|
|
40
|
+
const marks = [];
|
|
41
|
+
const bars = [];
|
|
42
|
+
const ticks = [];
|
|
43
|
+
const glyphs = [];
|
|
44
|
+
rows.forEach((row, i) => {
|
|
45
|
+
const cy = y + top + i * step + 11;
|
|
46
|
+
let barX = x + 22;
|
|
47
|
+
if (row.lead === "checkbox" || row.lead === "checked") {
|
|
48
|
+
const checked = row.lead === "checked";
|
|
49
|
+
marks.push(el("rect", { x: x + 22, y: cy - 11, width: 22, height: 22, rx: 5, fill: checked ? colour(leadFill, "leadFill") : tokens.color.white }));
|
|
50
|
+
if (checked)
|
|
51
|
+
ticks.push(el("path", { d: `M${x + 27},${cy} L${x + 32},${cy + 6} L${x + 40},${cy - 6}`, stroke: colour(tick, "tick") }));
|
|
52
|
+
barX = x + 56;
|
|
53
|
+
}
|
|
54
|
+
else if (row.lead === "question") {
|
|
55
|
+
marks.push(el("circle", { cx: x + 30, cy, r: 13, fill: tokens.color.white }));
|
|
56
|
+
glyphs.push(el("text", { x: x + 30, y: cy + 7, "font-size": 19, "font-weight": tokens.font.weightHeavy }, "?"));
|
|
57
|
+
barX = x + 52;
|
|
58
|
+
}
|
|
59
|
+
bars.push(el("rect", { x: barX, y: cy - 5, width: row.bar, height: 10, rx: 5 }));
|
|
60
|
+
if (row.tail === "check") {
|
|
61
|
+
const tx = x + width - 40;
|
|
62
|
+
marks.push(el("rect", { x: tx, y: cy - 11, width: 22, height: 22, rx: 5, fill: tokens.color.state.healthy }));
|
|
63
|
+
ticks.push(el("path", { d: `M${tx + 5},${cy} L${tx + 10},${cy + 6} L${tx + 18},${cy - 6}`, stroke: ink }));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return drawn([
|
|
67
|
+
...shadowed(el("rect", { x, y, width, height, rx: 14, fill: colour(fill, "fill") })),
|
|
68
|
+
g({ "stroke-width": tokens.outline.small }, ...marks),
|
|
69
|
+
g({ fill: "none", "stroke-width": 3.5, "stroke-linecap": "round" }, ...ticks),
|
|
70
|
+
g({ stroke: "none", fill: tokens.illustration.textBar }, ...bars),
|
|
71
|
+
], glyphs);
|
|
72
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export type ParamSpec = {
|
|
2
|
+
kind: "number";
|
|
3
|
+
required?: boolean;
|
|
4
|
+
min?: number;
|
|
5
|
+
exclusiveMin?: boolean;
|
|
6
|
+
max?: number;
|
|
7
|
+
integer?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** A token path; with `currentColor`, also that exact keyword (uiIcon.colour only, card 170). */
|
|
10
|
+
| {
|
|
11
|
+
kind: "color";
|
|
12
|
+
required?: boolean;
|
|
13
|
+
currentColor?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** A token path, or a colour from the consumer's data (#RRGGBB): pipe and lineBadge fills only. */
|
|
16
|
+
| {
|
|
17
|
+
kind: "dataColor";
|
|
18
|
+
required?: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "string";
|
|
21
|
+
required?: boolean;
|
|
22
|
+
nonEmpty?: boolean;
|
|
23
|
+
pattern?: RegExp;
|
|
24
|
+
patternName?: string;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "enum";
|
|
27
|
+
required?: boolean;
|
|
28
|
+
values: readonly string[];
|
|
29
|
+
} | {
|
|
30
|
+
kind: "boolean";
|
|
31
|
+
required?: boolean;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "point";
|
|
34
|
+
required?: boolean;
|
|
35
|
+
} | {
|
|
36
|
+
kind: "array";
|
|
37
|
+
required?: boolean;
|
|
38
|
+
minItems?: number;
|
|
39
|
+
maxItems?: number;
|
|
40
|
+
of: ParamSpec;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "object";
|
|
43
|
+
required?: boolean;
|
|
44
|
+
fields: Schema;
|
|
45
|
+
};
|
|
46
|
+
export type Schema = Readonly<Record<string, ParamSpec>>;
|
|
47
|
+
export type Problem = {
|
|
48
|
+
path: string;
|
|
49
|
+
message: string;
|
|
50
|
+
};
|
|
51
|
+
/** A data colour: exactly six hex digits after the sign, nothing else. */
|
|
52
|
+
export declare const DATA_COLOUR: RegExp;
|
|
53
|
+
/** The hex value of a data colour parameter: a token path resolved, a data colour as given. */
|
|
54
|
+
export declare const paint: (value: string, name?: string) => string;
|
|
55
|
+
/** Every colour token, by its dotted path: any token whose value is #RRGGBB. */
|
|
56
|
+
export declare const COLOUR_TOKENS: ReadonlyMap<string, string>;
|
|
57
|
+
export declare const isColourLiteral: (value: string) => boolean;
|
|
58
|
+
/** The hex value of a colour token path; throws a RangeError for anything else. */
|
|
59
|
+
export declare const colour: (path: string, name?: string) => string;
|
|
60
|
+
/** Every problem of `params` against `schema`; paths are `prefix.name`. */
|
|
61
|
+
export declare const checkParams: (schema: Schema, params: Record<string, unknown>, prefix?: string) => Problem[];
|
|
62
|
+
/** Validates params for a call from code; the first problem becomes a RangeError. */
|
|
63
|
+
export declare const assertParams: (piece: string, schema: Schema, params: Record<string, unknown>) => void;
|
|
64
|
+
export declare const num: (extra?: Omit<Extract<ParamSpec, {
|
|
65
|
+
kind: "number";
|
|
66
|
+
}>, "kind">) => ParamSpec;
|
|
67
|
+
/** Largest size a piece accepts, far above any banner. Positions and points have no bound. */
|
|
68
|
+
export declare const MAX_SIZE = 10000;
|
|
69
|
+
/** Most items in any list parameter (rows, lines, nodes, tiles). */
|
|
70
|
+
export declare const MAX_ITEMS = 50;
|
|
71
|
+
/** A count of repeated parts (units, steps, teeth): an integer from `min` to `max`. */
|
|
72
|
+
export declare const count: (min: number, max: number) => ParamSpec;
|
|
73
|
+
/** A size: greater than 0 (or at least `min`, where fixed insets need room), at most MAX_SIZE. */
|
|
74
|
+
export declare const size: (required?: boolean, min?: number) => ParamSpec;
|
|
75
|
+
/** A position: any finite number, because a map position has no maximum. */
|
|
76
|
+
export declare const pos: () => ParamSpec;
|
|
77
|
+
export declare const col: () => ParamSpec;
|
|
78
|
+
/** The paint keyword that follows the text colour of an inline SVG's element. */
|
|
79
|
+
export declare const CURRENT_COLOUR = "currentColor";
|
|
80
|
+
/** A token path or `currentColor`: for icons written inline in a page. */
|
|
81
|
+
export declare const colOrCurrent: () => ParamSpec;
|
|
82
|
+
/** SVG path data: commands, digits, signs, dots, commas and spaces only. */
|
|
83
|
+
export declare const PATH_DATA: RegExp;
|
|
84
|
+
export declare const label: (required?: boolean) => ParamSpec;
|