@hattoriai/poney-react 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +20 -2
- package/dist/index.d.ts +829 -0
- package/dist/index.js +2295 -0
- package/dist/index.js.map +1 -0
- package/dist/poney.css +211 -0
- package/dist/poney.min.css +1 -0
- package/package.json +53 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,2295 @@
|
|
|
1
|
+
import { createContext, useMemo, useState, useContext, useCallback } from 'react';
|
|
2
|
+
import { clip, labelPoint, measure, roundedPath, ERD, trimEnd, endAngle, startAngle, wrap, union, bezier } from '@hattoriai/poney-layout';
|
|
3
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { walkthroughsShowing, marksOf, fragmentLabel, refKey, parseRef } from '@hattoriai/poney-core';
|
|
5
|
+
export { indexOf, marksOf } from '@hattoriai/poney-core';
|
|
6
|
+
import { Network, Map as Map$1, ListOrdered, Waypoints, GitBranch, Table2, CircleDot, UsersRound, Blocks, KeyRound, Link2, ChevronsDownUp, ChevronsUpDown, Zap, Users, UserRound, UserCog, Timer, Store, ShoppingCart, Server, Send, Route, Receipt, Radio, Plug, Package, Mail, Library, Landmark, Globe, FileText, Database, CreditCard, ClipboardList, Boxes, Box, BookOpen, AppWindow } from 'lucide-react';
|
|
7
|
+
|
|
8
|
+
// src/context.tsx
|
|
9
|
+
var StoryContext = createContext({
|
|
10
|
+
marks: /* @__PURE__ */ new Map(),
|
|
11
|
+
mode: "after",
|
|
12
|
+
focus: null,
|
|
13
|
+
callouts: /* @__PURE__ */ new Map(),
|
|
14
|
+
hot: null,
|
|
15
|
+
setHot: () => {
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var StoryProvider = ({ value, children }) => /* @__PURE__ */ jsx(StoryContext.Provider, { value, children });
|
|
19
|
+
var useStory = () => useContext(StoryContext);
|
|
20
|
+
function useLook(key) {
|
|
21
|
+
return lookOf(useStory(), key);
|
|
22
|
+
}
|
|
23
|
+
function useLookAny(keys) {
|
|
24
|
+
const s = useStory();
|
|
25
|
+
const looks = keys.map((k) => lookOf(s, k));
|
|
26
|
+
return {
|
|
27
|
+
state: looks.find((l) => l.state)?.state,
|
|
28
|
+
hidden: looks.every((l) => l.hidden),
|
|
29
|
+
dim: looks.every((l) => l.dim),
|
|
30
|
+
hot: looks.some((l) => l.hot),
|
|
31
|
+
focused: looks.some((l) => l.focused),
|
|
32
|
+
callout: looks.find((l) => l.callout)?.callout
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function lookOf(s, key) {
|
|
36
|
+
const mark = s.marks.get(key);
|
|
37
|
+
const hidden = s.mode === "before" && mark === "new" || s.mode === "after" && mark === "removed";
|
|
38
|
+
const focused = !s.focus || s.focus.has(key);
|
|
39
|
+
return {
|
|
40
|
+
state: s.mode === "change" ? mark : void 0,
|
|
41
|
+
hidden,
|
|
42
|
+
dim: !focused && s.hot !== key,
|
|
43
|
+
hot: s.hot === key,
|
|
44
|
+
focused,
|
|
45
|
+
callout: s.callouts.get(key)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var lookClass = (l) => `poney-story-el ${l.hidden ? "poney-story-hidden" : l.dim ? "poney-story-dim" : ""}`;
|
|
49
|
+
var stateStroke = (s, fallback = "var(--poney-story-rule)") => s ? `var(--poney-${s})` : fallback;
|
|
50
|
+
var stateFill = (s, fallback = "var(--poney-story-node)") => s ? `var(--poney-${s}-wash)` : fallback;
|
|
51
|
+
var STATE_LABEL = { new: "New", changed: "Changed", removed: "Removed" };
|
|
52
|
+
function StateTag({ state: state2, x, y, anchor = "start" }) {
|
|
53
|
+
if (!state2) return null;
|
|
54
|
+
const text = STATE_LABEL[state2];
|
|
55
|
+
const w = measure(text, 11, 650) + 14;
|
|
56
|
+
const left = anchor === "start" ? x : anchor === "end" ? x - w : x - w / 2;
|
|
57
|
+
return /* @__PURE__ */ jsxs("g", { pointerEvents: "none", children: [
|
|
58
|
+
/* @__PURE__ */ jsx("rect", { x: left, y: y - 9, width: w, height: 18, rx: 9, fill: `var(--poney-${state2}-wash)`, stroke: `var(--poney-${state2})`, strokeWidth: 1 }),
|
|
59
|
+
/* @__PURE__ */ jsx("text", { x: left + w / 2, y: y + 4, textAnchor: "middle", fontSize: 11, fontWeight: 650, fill: `var(--poney-${state2})`, children: text })
|
|
60
|
+
] });
|
|
61
|
+
}
|
|
62
|
+
function CalloutBadge({ n, x, y, hot }) {
|
|
63
|
+
return /* @__PURE__ */ jsxs("g", { pointerEvents: "none", className: "poney-story-el", children: [
|
|
64
|
+
/* @__PURE__ */ jsx("circle", { cx: x, cy: y, r: 12, fill: hot ? "var(--poney-accent)" : "var(--poney-ink)", stroke: "var(--poney-paper-raised)", strokeWidth: 2.5 }),
|
|
65
|
+
/* @__PURE__ */ jsx("text", { x, y: y + 4.2, textAnchor: "middle", fontSize: 12, fontWeight: 700, fill: "var(--poney-paper-raised)", className: "poney-numbers", children: n })
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
function Head({ x, y, angle, color, size = 7 }) {
|
|
69
|
+
const c = Math.cos(angle);
|
|
70
|
+
const s = Math.sin(angle);
|
|
71
|
+
const p = (dx, dy) => `${x + dx * c - dy * s},${y + dx * s + dy * c}`;
|
|
72
|
+
return /* @__PURE__ */ jsx("polygon", { points: `${p(0, 0)} ${p(-size * 1.35, -size * 0.62)} ${p(-size * 1.35, size * 0.62)}`, fill: color });
|
|
73
|
+
}
|
|
74
|
+
var RenderContext = createContext(null);
|
|
75
|
+
var RenderProvider = ({ value, children }) => /* @__PURE__ */ jsx(RenderContext.Provider, { value, children });
|
|
76
|
+
function useRenderIndex() {
|
|
77
|
+
const v = useContext(RenderContext);
|
|
78
|
+
if (!v) throw new Error("Poney renderers need a RenderProvider (from @hattoriai/poney-react) with the model index");
|
|
79
|
+
return v.idx;
|
|
80
|
+
}
|
|
81
|
+
var plain = (ref, label) => ({ "data-ref": refKey(ref), "aria-label": label });
|
|
82
|
+
function useRenderBind() {
|
|
83
|
+
return useContext(RenderContext)?.bind ?? plain;
|
|
84
|
+
}
|
|
85
|
+
function useRenderSubject() {
|
|
86
|
+
const v = useContext(RenderContext);
|
|
87
|
+
const selection = v?.selection ?? null;
|
|
88
|
+
const hover = v?.hover ?? null;
|
|
89
|
+
return { subject: hover ?? selection, selection, hover };
|
|
90
|
+
}
|
|
91
|
+
function useViewState(viewId) {
|
|
92
|
+
const v = useContext(RenderContext);
|
|
93
|
+
const [own, setOwn] = useState({});
|
|
94
|
+
const hosted = !!v?.setViewState;
|
|
95
|
+
const state2 = (hosted ? v.viewState?.(viewId) : own) ?? {};
|
|
96
|
+
const set = useCallback(
|
|
97
|
+
(patch) => hosted ? v.setViewState(viewId, patch) : setOwn((s) => ({ ...s, ...patch })),
|
|
98
|
+
[hosted, v, viewId]
|
|
99
|
+
);
|
|
100
|
+
return [state2, set];
|
|
101
|
+
}
|
|
102
|
+
var ZoomContext = createContext(1);
|
|
103
|
+
var ZoomProvider = ({ value, children }) => /* @__PURE__ */ jsx(ZoomContext.Provider, { value, children });
|
|
104
|
+
var useRenderZoom = () => useContext(ZoomContext);
|
|
105
|
+
var useRenderStill = () => !!useContext(RenderContext)?.still;
|
|
106
|
+
function sceneLayoutOptions(view, walkthrough, focus) {
|
|
107
|
+
const o = {};
|
|
108
|
+
if (walkthrough && view.type === "state") o.extraTransitions = walkthrough.removed.transitions.filter((t) => t.stateMachine === view.stateMachine).map((t) => t.transition);
|
|
109
|
+
if (walkthrough && view.type === "map") {
|
|
110
|
+
o.extraEntities = walkthrough.removed.entities;
|
|
111
|
+
o.extraRelationships = walkthrough.removed.relationships;
|
|
112
|
+
}
|
|
113
|
+
if (view.type === "sequence") {
|
|
114
|
+
o.compact = true;
|
|
115
|
+
const only = focus.map(parseRef).flatMap((r) => r?.kind === "message" && r.behavior === view.interaction ? [r.id] : []);
|
|
116
|
+
if (only.length) o.only = only;
|
|
117
|
+
}
|
|
118
|
+
return o;
|
|
119
|
+
}
|
|
120
|
+
var keysOf = (refs) => refs.map(parseRef).flatMap((r) => r ? [refKey(r)] : []);
|
|
121
|
+
function expandFocus(refs, idx, walkthrough) {
|
|
122
|
+
const out = new Set(keysOf(refs));
|
|
123
|
+
for (const key of [...out]) {
|
|
124
|
+
const ref = parseRef(key);
|
|
125
|
+
if (!ref) continue;
|
|
126
|
+
if (ref.kind === "relationship") {
|
|
127
|
+
const r = idx?.relationships.get(ref.id) ?? walkthrough?.removed.relationships.find((x) => x.id === ref.id);
|
|
128
|
+
if (r) for (const e of [r.source, r.target]) out.add(`entity:${e}`);
|
|
129
|
+
}
|
|
130
|
+
if (ref.kind === "transition") {
|
|
131
|
+
const t = idx?.stateMachine(ref.behavior)?.transitions.find((x) => x.id === ref.id) ?? walkthrough?.removed.transitions.find((x) => x.stateMachine === ref.behavior && x.transition.id === ref.id)?.transition;
|
|
132
|
+
if (t) for (const st of [t.from, t.to]) out.add(`state:${ref.behavior}:${st}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return [...out];
|
|
136
|
+
}
|
|
137
|
+
var BOX = /^(entity|state|dataType|activityNode|capability):/;
|
|
138
|
+
function sceneFrame(scene, view, focus, idx, walkthrough) {
|
|
139
|
+
const rects = expandFocus(focus, idx, walkthrough).map((k) => scene.anchors[k]).filter((r) => !!r);
|
|
140
|
+
if (!rects.length || view.type === "sequence") return { x: 0, y: 0, w: scene.width, h: scene.height };
|
|
141
|
+
let frame = union(rects);
|
|
142
|
+
const pad = 24;
|
|
143
|
+
for (let pass = 0; pass < 3; pass++) {
|
|
144
|
+
const f = { x: frame.x - pad, y: frame.y - pad, w: frame.w + pad * 2, h: frame.h + pad * 2 };
|
|
145
|
+
const cut = Object.entries(scene.anchors).filter(([k]) => BOX.test(k)).map(([, r]) => r).filter((r) => r.x < f.x + f.w && r.x + r.w > f.x && r.y < f.y + f.h && r.y + r.h > f.y).filter((r) => r.x < f.x || r.y < f.y || r.x + r.w > f.x + f.w || r.y + r.h > f.y + f.h);
|
|
146
|
+
if (!cut.length) break;
|
|
147
|
+
frame = union([frame, ...cut]);
|
|
148
|
+
}
|
|
149
|
+
return frame;
|
|
150
|
+
}
|
|
151
|
+
function fit(frame, W, H, pad, maxScale) {
|
|
152
|
+
const f = { x: frame.x - pad, y: frame.y - pad, w: frame.w + pad * 2, h: frame.h + pad * 2 };
|
|
153
|
+
let w = Math.max(f.w, W / maxScale);
|
|
154
|
+
let h = Math.max(f.h, H / maxScale);
|
|
155
|
+
const aspect = W / Math.max(H, 1);
|
|
156
|
+
if (w / h < aspect) w = h * aspect;
|
|
157
|
+
else h = w / aspect;
|
|
158
|
+
return { x: f.x + f.w / 2 - w / 2, y: f.y + f.h / 2 - h / 2, w, h };
|
|
159
|
+
}
|
|
160
|
+
function storyState(input) {
|
|
161
|
+
const keys = expandFocus(input.focus, input.idx, input.walkthrough);
|
|
162
|
+
const group = (items = []) => {
|
|
163
|
+
const m = /* @__PURE__ */ new Map();
|
|
164
|
+
for (const it of items) {
|
|
165
|
+
const r = parseRef(it.target);
|
|
166
|
+
if (r) m.set(refKey(r), [...m.get(refKey(r)) ?? [], it]);
|
|
167
|
+
}
|
|
168
|
+
return m;
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
marks: input.marks,
|
|
172
|
+
mode: input.mode,
|
|
173
|
+
focus: keys.length && input.view.type !== "sequence" ? new Set(keys) : null,
|
|
174
|
+
callouts: new Map(keysOf(input.callouts).map((k, i) => [k, i + 1])),
|
|
175
|
+
hot: input.hot ?? null,
|
|
176
|
+
setHot: input.setHot ?? (() => {
|
|
177
|
+
}),
|
|
178
|
+
// A tour marks nothing, so a picture with no focus names every line.
|
|
179
|
+
allLabels: input.walkthrough?.kind === "tour" && keys.length === 0,
|
|
180
|
+
effects: group(input.effects),
|
|
181
|
+
badges: group(input.badges),
|
|
182
|
+
trace: input.trace?.length ? { steps: keysOf(input.trace.map((t) => t.ref)), current: input.traceStep ?? null, animate: input.animate !== false, numbered: !!input.numberSteps } : void 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function findScene(doc, walkthroughId, sceneId) {
|
|
186
|
+
const w = walkthroughId ? doc.walkthroughs.find((x) => x.id === walkthroughId) : doc.walkthroughs[0];
|
|
187
|
+
if (!w) return void 0;
|
|
188
|
+
if (!sceneId || sceneId === "overview") {
|
|
189
|
+
if (w.overview) return { walkthrough: w, viewId: w.overview, focus: [], callouts: [], notes: [], title: `${w.title}: overview`, scene: void 0 };
|
|
190
|
+
if (sceneId === "overview") return void 0;
|
|
191
|
+
}
|
|
192
|
+
const s = sceneId ? w.scenes.find((x) => x.id === sceneId) : w.scenes.find((x) => x.view);
|
|
193
|
+
if (!s?.view) return void 0;
|
|
194
|
+
return { walkthrough: w, viewId: s.view, focus: s.focus, callouts: s.callouts.map((c) => c.target), notes: s.callouts.map((c) => c.text), title: s.title, scene: s };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/theme.ts
|
|
198
|
+
var THEMES = {
|
|
199
|
+
light: {
|
|
200
|
+
plaster: "#eef0ec",
|
|
201
|
+
paper: "#fbfbf9",
|
|
202
|
+
"paper-raised": "#ffffff",
|
|
203
|
+
sunken: "#e5e8e3",
|
|
204
|
+
ink: "#1d2230",
|
|
205
|
+
"ink-2": "#4e5566",
|
|
206
|
+
"ink-3": "#848a97",
|
|
207
|
+
"ink-4": "#b3b8c1",
|
|
208
|
+
rule: "#dcdfd8",
|
|
209
|
+
"rule-strong": "#c8ccc4",
|
|
210
|
+
accent: "#b24a32",
|
|
211
|
+
"accent-wash": "#f7ebe7",
|
|
212
|
+
"accent-ring": "#b24a3240",
|
|
213
|
+
lapis: "#3a5a9e",
|
|
214
|
+
malachite: "#2e7656",
|
|
215
|
+
ochre: "#a8761c",
|
|
216
|
+
umber: "#7d5a43",
|
|
217
|
+
tyrian: "#7a4a88",
|
|
218
|
+
slate: "#56627a",
|
|
219
|
+
verdigris: "#26807f",
|
|
220
|
+
success: "#2e7656",
|
|
221
|
+
failure: "#9c3554",
|
|
222
|
+
new: "#1d8a4e",
|
|
223
|
+
"new-wash": "#ecf8f0",
|
|
224
|
+
changed: "#b86e0b",
|
|
225
|
+
"changed-wash": "#fdf5e6",
|
|
226
|
+
removed: "#c03550",
|
|
227
|
+
"removed-wash": "#fcf0f2",
|
|
228
|
+
"story-node": "#ffffff",
|
|
229
|
+
"story-line": "#8c939e",
|
|
230
|
+
"story-rule": "#d7dade"
|
|
231
|
+
},
|
|
232
|
+
dark: {
|
|
233
|
+
plaster: "#15181e",
|
|
234
|
+
paper: "#1b1f27",
|
|
235
|
+
"paper-raised": "#212631",
|
|
236
|
+
sunken: "#12151a",
|
|
237
|
+
ink: "#e6e8ec",
|
|
238
|
+
"ink-2": "#aeb4c0",
|
|
239
|
+
"ink-3": "#7c8391",
|
|
240
|
+
"ink-4": "#535a67",
|
|
241
|
+
rule: "#2a2f39",
|
|
242
|
+
"rule-strong": "#3a404c",
|
|
243
|
+
accent: "#e2765b",
|
|
244
|
+
"accent-wash": "#3a2621",
|
|
245
|
+
"accent-ring": "#e2765b4d",
|
|
246
|
+
lapis: "#7f9ce0",
|
|
247
|
+
malachite: "#5fb68d",
|
|
248
|
+
ochre: "#d6a64c",
|
|
249
|
+
umber: "#c19a7f",
|
|
250
|
+
tyrian: "#b98ac8",
|
|
251
|
+
slate: "#98a3b9",
|
|
252
|
+
verdigris: "#58bcba",
|
|
253
|
+
success: "#5fb68d",
|
|
254
|
+
failure: "#e07a98",
|
|
255
|
+
new: "#4fc887",
|
|
256
|
+
"new-wash": "#15281f",
|
|
257
|
+
changed: "#e3a54a",
|
|
258
|
+
"changed-wash": "#2b2416",
|
|
259
|
+
removed: "#ef7f97",
|
|
260
|
+
"removed-wash": "#2e1a20",
|
|
261
|
+
"story-node": "#1f242d",
|
|
262
|
+
"story-line": "#7d8592",
|
|
263
|
+
"story-rule": "#363c48"
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
var FONTS = {
|
|
267
|
+
sans: "'Hanken Grotesk Variable', 'Hanken Grotesk', ui-sans-serif, system-ui, sans-serif",
|
|
268
|
+
mono: "'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, monospace"
|
|
269
|
+
};
|
|
270
|
+
var ICONS = {
|
|
271
|
+
"app-window": AppWindow,
|
|
272
|
+
"book-open": BookOpen,
|
|
273
|
+
box: Box,
|
|
274
|
+
boxes: Boxes,
|
|
275
|
+
"clipboard-list": ClipboardList,
|
|
276
|
+
"credit-card": CreditCard,
|
|
277
|
+
database: Database,
|
|
278
|
+
"file-text": FileText,
|
|
279
|
+
globe: Globe,
|
|
280
|
+
"key-round": KeyRound,
|
|
281
|
+
landmark: Landmark,
|
|
282
|
+
library: Library,
|
|
283
|
+
mail: Mail,
|
|
284
|
+
package: Package,
|
|
285
|
+
plug: Plug,
|
|
286
|
+
radio: Radio,
|
|
287
|
+
receipt: Receipt,
|
|
288
|
+
route: Route,
|
|
289
|
+
send: Send,
|
|
290
|
+
server: Server,
|
|
291
|
+
"shopping-cart": ShoppingCart,
|
|
292
|
+
store: Store,
|
|
293
|
+
table: Table2,
|
|
294
|
+
timer: Timer,
|
|
295
|
+
"user-cog": UserCog,
|
|
296
|
+
"user-round": UserRound,
|
|
297
|
+
users: Users,
|
|
298
|
+
waypoints: Waypoints,
|
|
299
|
+
zap: Zap
|
|
300
|
+
};
|
|
301
|
+
function iconFor(name) {
|
|
302
|
+
return ICONS[name] ?? Box;
|
|
303
|
+
}
|
|
304
|
+
function Glyph({ name, x, y, size = 16, color = "currentColor", strokeWidth = 1.75 }) {
|
|
305
|
+
const Icon = iconFor(name);
|
|
306
|
+
return /* @__PURE__ */ jsx(Icon, { x, y, width: size, height: size, color, strokeWidth, "aria-hidden": true });
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// src/tone.ts
|
|
310
|
+
var toneColor = (tone) => tone.startsWith("#") ? tone : `var(--poney-${tone === "poney" ? "accent" : tone})`;
|
|
311
|
+
var toneWash = (tone, amount = 10) => `color-mix(in srgb, ${toneColor(tone)} ${amount}%, var(--poney-paper-raised))`;
|
|
312
|
+
function MapStory({ scene, extra = [] }) {
|
|
313
|
+
const idx = useRenderIndex();
|
|
314
|
+
const extraById = new Map(extra.map((e) => [e.id, e]));
|
|
315
|
+
const entityOf = (id) => idx.entities.get(id) ?? extraById.get(id);
|
|
316
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
317
|
+
(scene.groups ?? []).map((g) => {
|
|
318
|
+
const e = entityOf(g.entityId);
|
|
319
|
+
return e ? /* @__PURE__ */ jsx(MapGroup, { group: g, entity: e }, g.entityId) : null;
|
|
320
|
+
}),
|
|
321
|
+
scene.edges.map((e) => /* @__PURE__ */ jsx(MapEdge, { edge: e }, e.id)),
|
|
322
|
+
scene.nodes.map((n) => {
|
|
323
|
+
const e = entityOf(n.entityId);
|
|
324
|
+
return e ? /* @__PURE__ */ jsx(MapNode, { node: n, entity: e }, n.entityId) : null;
|
|
325
|
+
}),
|
|
326
|
+
scene.edges.map((e) => /* @__PURE__ */ jsx(EdgeLabel, { edge: e }, `l-${e.id}`)),
|
|
327
|
+
[...scene.groups ?? [], ...scene.nodes].map((n) => /* @__PURE__ */ jsx(NodeCallout, { node: n }, `c-${n.entityId}`)),
|
|
328
|
+
scene.edges.map((e) => /* @__PURE__ */ jsx(EdgeCallout, { edge: e }, `ec-${e.id}`)),
|
|
329
|
+
scene.nodes.filter((n) => n.members?.length).map((n) => /* @__PURE__ */ jsx(GroupPeek, { node: n, names: n.members.map((m) => entityOf(m)?.name ?? m) }, `p-${n.entityId}`))
|
|
330
|
+
] });
|
|
331
|
+
}
|
|
332
|
+
function GroupPeek({ node, names }) {
|
|
333
|
+
const { hot } = useStory();
|
|
334
|
+
if (hot !== `entity:${node.entityId}`) return null;
|
|
335
|
+
const shown = names.slice(0, 6);
|
|
336
|
+
const more = names.length - shown.length;
|
|
337
|
+
const rows = [...shown, ...more > 0 ? [`and ${more} more`] : []];
|
|
338
|
+
const w = Math.max(node.w, Math.max(...rows.map((r) => measure(r, 12.5, 500))) + 40);
|
|
339
|
+
const h = rows.length * 22 + 38;
|
|
340
|
+
const x = node.x + node.w / 2 - w / 2;
|
|
341
|
+
const y = node.y + node.h + 12;
|
|
342
|
+
return /* @__PURE__ */ jsxs("g", { pointerEvents: "none", transform: `translate(${x} ${y})`, children: [
|
|
343
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, rx: 12, fill: "var(--poney-paper-raised)", stroke: "var(--poney-story-rule)" }),
|
|
344
|
+
/* @__PURE__ */ jsx("text", { x: 16, y: 22, fontSize: 11.5, fontWeight: 600, fill: "var(--poney-ink-3)", children: "Inside" }),
|
|
345
|
+
rows.map((r, i) => /* @__PURE__ */ jsx("text", { x: 16, y: 44 + i * 22, fontSize: 12.5, fontWeight: i < shown.length ? 500 : 400, fill: i < shown.length ? "var(--poney-ink)" : "var(--poney-ink-3)", children: r }, i))
|
|
346
|
+
] });
|
|
347
|
+
}
|
|
348
|
+
function MapNode({ node, entity }) {
|
|
349
|
+
const idx = useRenderIndex();
|
|
350
|
+
const bind = useRenderBind();
|
|
351
|
+
const key = `entity:${entity.id}`;
|
|
352
|
+
const members = node.members ?? [];
|
|
353
|
+
const look = useLookAny([key, ...members.map((m) => `entity:${m}`)]);
|
|
354
|
+
const style = idx.style(entity);
|
|
355
|
+
const { setHot, toggleGroup } = useStory();
|
|
356
|
+
const { x, y, w, h } = node;
|
|
357
|
+
const stroke = look.hot ? "var(--poney-accent)" : stateStroke(look.state, look.focused ? "var(--poney-story-line)" : "var(--poney-story-rule)");
|
|
358
|
+
const removed = look.state === "removed";
|
|
359
|
+
const sub = members.length ? `${members.length} inside${entity.technology ? ` \xB7 ${entity.technology}` : ""}` : entity.technology ?? style.label;
|
|
360
|
+
const props = bind({ kind: "entity", id: entity.id }, `${entity.name}. ${entity.summary}`);
|
|
361
|
+
return /* @__PURE__ */ jsxs(
|
|
362
|
+
"g",
|
|
363
|
+
{
|
|
364
|
+
transform: `translate(${x} ${y})`,
|
|
365
|
+
...props,
|
|
366
|
+
className: `poney-el ${lookClass(look)}`,
|
|
367
|
+
onMouseEnter: () => {
|
|
368
|
+
props.onMouseEnter?.();
|
|
369
|
+
setHot(key);
|
|
370
|
+
},
|
|
371
|
+
onMouseLeave: () => {
|
|
372
|
+
props.onMouseLeave?.();
|
|
373
|
+
setHot(null);
|
|
374
|
+
},
|
|
375
|
+
children: [
|
|
376
|
+
members.length > 0 && /* @__PURE__ */ jsx("rect", { x: 5, y: 5, width: w, height: h, rx: 14, fill: "var(--poney-story-node)", stroke: "var(--poney-story-rule)", strokeWidth: 1.2 }),
|
|
377
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, rx: 14, fill: stateFill(look.state), stroke, strokeWidth: look.state || look.hot ? 1.75 : 1.2, strokeDasharray: removed || entity.kind === "external" ? "6 4" : void 0 }),
|
|
378
|
+
members.length > 0 && toggleGroup && /* @__PURE__ */ jsx(GroupToggle, { open: false, name: entity.name, x: w - 22, y: h / 2, onToggle: () => toggleGroup(entity.id) }),
|
|
379
|
+
/* @__PURE__ */ jsx(Glyph, { name: style.icon, x: 18, y: h / 2 - 9, size: 18, color: look.state ? `var(--poney-${look.state})` : toneColor(style.tone) }),
|
|
380
|
+
/* @__PURE__ */ jsx("text", { x: 48, y: h / 2 - 2, fontSize: 15, fontWeight: 600, fill: "var(--poney-ink)", textDecoration: removed ? "line-through" : void 0, children: clip(entity.name, w - (members.length && toggleGroup ? 92 : 60), 15, 600) }),
|
|
381
|
+
/* @__PURE__ */ jsx("text", { x: 48, y: h / 2 + 17, fontSize: 12.5, fill: "var(--poney-ink-3)", children: clip(sub, w - (members.length && toggleGroup ? 92 : 60), 12.5) }),
|
|
382
|
+
/* @__PURE__ */ jsx(StateTag, { state: look.state, x: w - 12, y: 0, anchor: "end" }),
|
|
383
|
+
/* @__PURE__ */ jsx("rect", { className: "poney-focus", x: -5, y: -5, width: w + 10, height: h + 10, rx: 18, fill: "none", stroke: "var(--poney-accent)", strokeWidth: 2, strokeDasharray: "4 3" })
|
|
384
|
+
]
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
function MapGroup({ group, entity }) {
|
|
389
|
+
const idx = useRenderIndex();
|
|
390
|
+
const bind = useRenderBind();
|
|
391
|
+
const key = `entity:${entity.id}`;
|
|
392
|
+
const look = useLook(key);
|
|
393
|
+
const inside = useLookAny(group.members.map((m) => `entity:${m}`));
|
|
394
|
+
const { setHot, toggleGroup } = useStory();
|
|
395
|
+
const style = idx.style(entity);
|
|
396
|
+
const { x, y, w, h } = group;
|
|
397
|
+
const props = bind({ kind: "entity", id: entity.id }, `${entity.name}. ${entity.summary}`);
|
|
398
|
+
const stroke = look.hot ? "var(--poney-accent)" : stateStroke(look.state, "var(--poney-story-rule)");
|
|
399
|
+
const sub = entity.technology ?? style.label;
|
|
400
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x} ${y})`, className: `poney-el ${lookClass({ ...look, dim: look.dim && inside.dim })}`, children: [
|
|
401
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, rx: 18, fill: look.state ? `var(--poney-${look.state}-wash)` : "var(--poney-sunken)", fillOpacity: look.state ? 0.55 : 0.45, stroke, strokeWidth: look.state || look.hot ? 1.6 : 1.1 }),
|
|
402
|
+
/* @__PURE__ */ jsxs(
|
|
403
|
+
"g",
|
|
404
|
+
{
|
|
405
|
+
...props,
|
|
406
|
+
onMouseEnter: () => {
|
|
407
|
+
props.onMouseEnter?.();
|
|
408
|
+
setHot(key);
|
|
409
|
+
},
|
|
410
|
+
onMouseLeave: () => {
|
|
411
|
+
props.onMouseLeave?.();
|
|
412
|
+
setHot(null);
|
|
413
|
+
},
|
|
414
|
+
children: [
|
|
415
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: 44, rx: 18, fill: "transparent" }),
|
|
416
|
+
/* @__PURE__ */ jsx(Glyph, { name: style.icon, x: 16, y: 14, size: 16, color: look.state ? `var(--poney-${look.state})` : toneColor(style.tone) }),
|
|
417
|
+
/* @__PURE__ */ jsx("text", { x: 40, y: 27, fontSize: 14, fontWeight: 600, fill: "var(--poney-ink)", children: clip(entity.name, w - (toggleGroup ? 150 : 110), 14, 600) }),
|
|
418
|
+
/* @__PURE__ */ jsx("text", { x: 40 + Math.min(measureName(entity.name), w - (toggleGroup ? 150 : 110)) + 10, y: 27, fontSize: 12, fill: "var(--poney-ink-3)", children: clip(sub, Math.max(0, w - 40 - measureName(entity.name) - (toggleGroup ? 56 : 24)), 12) })
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
),
|
|
422
|
+
/* @__PURE__ */ jsx(StateTag, { state: look.state, x: w - (toggleGroup ? 44 : 14), y: 22, anchor: "end" }),
|
|
423
|
+
toggleGroup && /* @__PURE__ */ jsx(GroupToggle, { open: true, name: entity.name, x: w - 24, y: 22, onToggle: () => toggleGroup(entity.id) })
|
|
424
|
+
] });
|
|
425
|
+
}
|
|
426
|
+
var measureName = (name) => measure(name, 14, 600);
|
|
427
|
+
function GroupToggle({ open, name, x, y, onToggle }) {
|
|
428
|
+
return /* @__PURE__ */ jsxs(
|
|
429
|
+
"g",
|
|
430
|
+
{
|
|
431
|
+
role: "button",
|
|
432
|
+
tabIndex: 0,
|
|
433
|
+
"aria-label": `${open ? "Close" : "Open"} ${name}`,
|
|
434
|
+
className: "poney-control",
|
|
435
|
+
onClick: (e) => {
|
|
436
|
+
e.stopPropagation();
|
|
437
|
+
onToggle();
|
|
438
|
+
},
|
|
439
|
+
onKeyDown: (e) => {
|
|
440
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
441
|
+
e.preventDefault();
|
|
442
|
+
onToggle();
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ jsx("title", { children: open ? `Close ${name}` : `Open ${name}` }),
|
|
447
|
+
/* @__PURE__ */ jsx("circle", { cx: x, cy: y, r: 11, fill: "var(--poney-paper-raised)", stroke: "var(--poney-story-line)", strokeWidth: 1.1 }),
|
|
448
|
+
/* @__PURE__ */ jsx("line", { x1: x - 4.5, y1: y, x2: x + 4.5, y2: y, stroke: "var(--poney-ink-2)", strokeWidth: 1.6, strokeLinecap: "round" }),
|
|
449
|
+
!open && /* @__PURE__ */ jsx("line", { x1: x, y1: y - 4.5, x2: x, y2: y + 4.5, stroke: "var(--poney-ink-2)", strokeWidth: 1.6, strokeLinecap: "round" })
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
function MapEdge({ edge }) {
|
|
455
|
+
const idx = useRenderIndex();
|
|
456
|
+
const bind = useRenderBind();
|
|
457
|
+
const { setHot } = useStory();
|
|
458
|
+
const key = `relationship:${edge.id}`;
|
|
459
|
+
const look = useLookAny(edge.relationships.map((r) => `relationship:${r}`));
|
|
460
|
+
const rel = idx.relationships.get(edge.id);
|
|
461
|
+
const [p0, c1, c2, p3] = edge.curve;
|
|
462
|
+
const color = look.hot ? "var(--poney-accent)" : stateStroke(look.state, look.focused ? "var(--poney-story-line)" : "var(--poney-story-rule)");
|
|
463
|
+
const angle = Math.atan2(p3.y - c2.y, p3.x - c2.x);
|
|
464
|
+
const end = { x: p3.x - Math.cos(angle) * 8, y: p3.y - Math.sin(angle) * 8 };
|
|
465
|
+
const async = rel?.kind === "publishes" || rel?.kind === "subscribes";
|
|
466
|
+
const props = bind({ kind: "relationship", id: edge.id }, rel?.label ?? edge.id);
|
|
467
|
+
return /* @__PURE__ */ jsxs(
|
|
468
|
+
"g",
|
|
469
|
+
{
|
|
470
|
+
...props,
|
|
471
|
+
className: `poney-el ${lookClass(look)}`,
|
|
472
|
+
onMouseEnter: () => {
|
|
473
|
+
props.onMouseEnter?.();
|
|
474
|
+
setHot(key);
|
|
475
|
+
},
|
|
476
|
+
onMouseLeave: () => {
|
|
477
|
+
props.onMouseLeave?.();
|
|
478
|
+
setHot(null);
|
|
479
|
+
},
|
|
480
|
+
children: [
|
|
481
|
+
/* @__PURE__ */ jsx("path", { d: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${p3.x} ${p3.y}`, fill: "none", stroke: "transparent", strokeWidth: 16 }),
|
|
482
|
+
/* @__PURE__ */ jsx(
|
|
483
|
+
"path",
|
|
484
|
+
{
|
|
485
|
+
d: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${end.x} ${end.y}`,
|
|
486
|
+
fill: "none",
|
|
487
|
+
stroke: color,
|
|
488
|
+
strokeWidth: look.state || look.hot ? 2 : 1.4,
|
|
489
|
+
strokeDasharray: look.state === "removed" || async ? "6 5" : void 0,
|
|
490
|
+
strokeLinecap: "round"
|
|
491
|
+
}
|
|
492
|
+
),
|
|
493
|
+
/* @__PURE__ */ jsx(Head, { x: p3.x, y: p3.y, angle, color })
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
function EdgeLabel({ edge }) {
|
|
499
|
+
const s = useStory();
|
|
500
|
+
const look = useLookAny(edge.relationships.map((r) => `relationship:${r}`));
|
|
501
|
+
const show = !look.hidden && (look.hot || s.allLabels || !!look.callout || !!s.focus && look.focused || !s.focus && !!look.state);
|
|
502
|
+
if (!show) return null;
|
|
503
|
+
const { x, y, w, h, text, sub } = edge.label;
|
|
504
|
+
const color = look.hot ? "var(--poney-accent)" : look.state ? `var(--poney-${look.state})` : "var(--poney-ink-2)";
|
|
505
|
+
const line = look.hot ? "var(--poney-accent)" : look.state ? `var(--poney-${look.state})` : "var(--poney-story-line)";
|
|
506
|
+
const lead = edge.leader;
|
|
507
|
+
const nearest = lead ? { x: Math.max(x, Math.min(x + w, lead.x)), y: Math.max(y, Math.min(y + h, lead.y)) } : void 0;
|
|
508
|
+
return /* @__PURE__ */ jsxs("g", { pointerEvents: "none", className: `poney-story-el ${look.dim ? "poney-story-dim" : ""}`, children: [
|
|
509
|
+
lead && nearest && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
510
|
+
/* @__PURE__ */ jsx("line", { x1: nearest.x, y1: nearest.y, x2: lead.x, y2: lead.y, stroke: line, strokeWidth: 1, strokeDasharray: "2 3" }),
|
|
511
|
+
/* @__PURE__ */ jsx("circle", { cx: lead.x, cy: lead.y, r: 2.5, fill: line })
|
|
512
|
+
] }),
|
|
513
|
+
/* @__PURE__ */ jsxs("g", { transform: `translate(${x} ${y})`, children: [
|
|
514
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, rx: 11, fill: "var(--poney-paper-raised)", stroke: look.hot ? "var(--poney-accent)" : look.state ? `var(--poney-${look.state})` : "var(--poney-story-rule)" }),
|
|
515
|
+
/* @__PURE__ */ jsx("text", { x: w / 2, y: 15, textAnchor: "middle", fontSize: 12, fontWeight: 500, fill: color, children: text }),
|
|
516
|
+
sub && /* @__PURE__ */ jsx("text", { x: w / 2, y: 29, textAnchor: "middle", fontSize: 11, fill: "var(--poney-ink-3)", children: sub })
|
|
517
|
+
] })
|
|
518
|
+
] });
|
|
519
|
+
}
|
|
520
|
+
function NodeCallout({ node }) {
|
|
521
|
+
const look = useLookAny([`entity:${node.entityId}`, ...(("depth" in node ? [] : node.members) ?? []).map((m) => `entity:${m}`)]);
|
|
522
|
+
if (!look.callout || look.hidden) return null;
|
|
523
|
+
return /* @__PURE__ */ jsx(CalloutBadge, { n: look.callout, x: node.x - 2, y: node.y - 2, hot: look.hot });
|
|
524
|
+
}
|
|
525
|
+
function EdgeCallout({ edge }) {
|
|
526
|
+
const look = useLookAny(edge.relationships.map((r) => `relationship:${r}`));
|
|
527
|
+
if (!look.callout || look.hidden) return null;
|
|
528
|
+
return /* @__PURE__ */ jsx(CalloutBadge, { n: look.callout, x: edge.label.x - 14, y: edge.label.y + edge.label.h / 2, hot: look.hot });
|
|
529
|
+
}
|
|
530
|
+
function SequenceStory({ scene }) {
|
|
531
|
+
const behavior = scene.interactionId;
|
|
532
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
533
|
+
scene.fragments.slice().sort((a, b) => a.depth - b.depth).map((f) => /* @__PURE__ */ jsx(Fragment3, { f, behavior }, f.id)),
|
|
534
|
+
scene.participants.map((p) => /* @__PURE__ */ jsx(Lifeline, { p }, p.entityId)),
|
|
535
|
+
scene.activations.map((a, i) => /* @__PURE__ */ jsx("rect", { x: a.x + 1, y: a.y1, width: 8, height: a.y2 - a.y1, rx: 3, fill: "var(--poney-sunken)", stroke: "var(--poney-story-rule)" }, i)),
|
|
536
|
+
scene.fragments.map((f) => /* @__PURE__ */ jsx(FragmentLabels, { f, behavior }, `fl-${f.id}`)),
|
|
537
|
+
scene.messages.map((m) => /* @__PURE__ */ jsx(MessageRow, { m, behavior }, m.id)),
|
|
538
|
+
scene.participants.map((p) => /* @__PURE__ */ jsx(Participant, { p }, `h-${p.entityId}`))
|
|
539
|
+
] });
|
|
540
|
+
}
|
|
541
|
+
function Lifeline({ p }) {
|
|
542
|
+
const look = useLook(`entity:${p.entityId}`);
|
|
543
|
+
return /* @__PURE__ */ jsx("line", { x1: p.x, x2: p.x, y1: p.lifeline.y1, y2: p.lifeline.y2, stroke: look.hot ? "var(--poney-accent)" : "var(--poney-story-rule)", strokeWidth: look.hot ? 1.5 : 1, className: lookClass({ ...look, dim: false }) });
|
|
544
|
+
}
|
|
545
|
+
function Participant({ p }) {
|
|
546
|
+
const idx = useRenderIndex();
|
|
547
|
+
const bind = useRenderBind();
|
|
548
|
+
const { setHot } = useStory();
|
|
549
|
+
const key = `entity:${p.entityId}`;
|
|
550
|
+
const look = useLook(key);
|
|
551
|
+
const e = idx.entities.get(p.entityId);
|
|
552
|
+
if (!e) return null;
|
|
553
|
+
const s = idx.style(e);
|
|
554
|
+
const { x, y, w, h } = p.header;
|
|
555
|
+
const props = bind({ kind: "entity", id: e.id }, `${e.name}, ${s.label}`);
|
|
556
|
+
return /* @__PURE__ */ jsxs(
|
|
557
|
+
"g",
|
|
558
|
+
{
|
|
559
|
+
transform: `translate(${x} ${y})`,
|
|
560
|
+
...props,
|
|
561
|
+
className: `poney-el ${lookClass({ ...look, dim: false })}`,
|
|
562
|
+
onMouseEnter: () => {
|
|
563
|
+
props.onMouseEnter?.();
|
|
564
|
+
setHot(key);
|
|
565
|
+
},
|
|
566
|
+
onMouseLeave: () => {
|
|
567
|
+
props.onMouseLeave?.();
|
|
568
|
+
setHot(null);
|
|
569
|
+
},
|
|
570
|
+
children: [
|
|
571
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, rx: 14, fill: stateFill(look.state), stroke: look.hot ? "var(--poney-accent)" : stateStroke(look.state, "var(--poney-story-line)"), strokeWidth: look.state ? 1.75 : 1.2, strokeDasharray: e.kind === "external" ? "6 4" : void 0 }),
|
|
572
|
+
/* @__PURE__ */ jsx(Glyph, { name: s.icon, x: 16, y: h / 2 - 9, size: 18, color: look.state ? `var(--poney-${look.state})` : toneColor(s.tone) }),
|
|
573
|
+
/* @__PURE__ */ jsx("text", { x: 44, y: h / 2 - 1, fontSize: 14.5, fontWeight: 600, fill: "var(--poney-ink)", children: clip(e.name, w - 54, 14.5, 600) }),
|
|
574
|
+
/* @__PURE__ */ jsx("text", { x: 44, y: h / 2 + 16, fontSize: 12, fill: "var(--poney-ink-3)", children: clip(e.technology ?? s.label, w - 54, 12) }),
|
|
575
|
+
/* @__PURE__ */ jsx(StateTag, { state: look.state, x: w - 10, y: 0, anchor: "end" }),
|
|
576
|
+
look.callout && /* @__PURE__ */ jsx(CalloutBadge, { n: look.callout, x: -2, y: -2, hot: look.hot })
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
function messageColor(look) {
|
|
582
|
+
if (look.hot) return "var(--poney-accent)";
|
|
583
|
+
if (look.state) return `var(--poney-${look.state})`;
|
|
584
|
+
return "var(--poney-ink-2)";
|
|
585
|
+
}
|
|
586
|
+
function MessageRow({ m, behavior }) {
|
|
587
|
+
const bind = useRenderBind();
|
|
588
|
+
const { setHot } = useStory();
|
|
589
|
+
const key = `message:${behavior}:${m.id}`;
|
|
590
|
+
const look = useLook(key);
|
|
591
|
+
const color = messageColor(look);
|
|
592
|
+
const width = look.state || look.hot ? 1.9 : 1.35;
|
|
593
|
+
const num = String(m.number);
|
|
594
|
+
const numW = measure(num, 11.5, 600) + 8;
|
|
595
|
+
const textW = measure(m.label, 13, look.state ? 600 : 500);
|
|
596
|
+
const props = bind({ kind: "message", behavior, id: m.id }, `Step ${m.number}: ${m.label}`);
|
|
597
|
+
const events = {
|
|
598
|
+
...props,
|
|
599
|
+
className: `poney-el ${lookClass(look)}`,
|
|
600
|
+
onMouseEnter: () => {
|
|
601
|
+
props.onMouseEnter?.();
|
|
602
|
+
setHot(key);
|
|
603
|
+
},
|
|
604
|
+
onMouseLeave: () => {
|
|
605
|
+
props.onMouseLeave?.();
|
|
606
|
+
setHot(null);
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
const label = (lx, ly, anchor) => {
|
|
610
|
+
const total = numW + textW;
|
|
611
|
+
const start = anchor === "middle" ? lx - total / 2 : lx;
|
|
612
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
613
|
+
/* @__PURE__ */ jsx("text", { x: start, y: ly, fontSize: 11.5, fontWeight: 600, fill: "var(--poney-ink-3)", className: "poney-numbers", stroke: "var(--poney-paper-raised)", strokeWidth: 5, paintOrder: "stroke", strokeLinejoin: "round", children: num }),
|
|
614
|
+
/* @__PURE__ */ jsx("text", { x: start + numW, y: ly, stroke: "var(--poney-paper-raised)", strokeWidth: 5, paintOrder: "stroke", strokeLinejoin: "round", fontSize: 13, fontWeight: look.state ? 600 : 500, fill: look.state || look.hot ? color : m.kind === "return" ? "var(--poney-ink-2)" : "var(--poney-ink)", children: m.label }),
|
|
615
|
+
/* @__PURE__ */ jsx(StateTag, { state: look.state, x: start + total + 14, y: ly - 4.5 }),
|
|
616
|
+
look.callout && /* @__PURE__ */ jsx(CalloutBadge, { n: look.callout, x: start - 18, y: ly - 4.5, hot: look.hot })
|
|
617
|
+
] });
|
|
618
|
+
};
|
|
619
|
+
if (m.loop) {
|
|
620
|
+
const { x, y1, y2, w } = m.loop;
|
|
621
|
+
return /* @__PURE__ */ jsxs("g", { ...events, children: [
|
|
622
|
+
/* @__PURE__ */ jsx("rect", { x: x - 4, y: y1 - 14, width: w + textW + numW + 90, height: y2 - y1 + 26, fill: "transparent" }),
|
|
623
|
+
/* @__PURE__ */ jsx("path", { d: `M ${x} ${y1} H ${x + w} V ${y2} H ${x + 8}`, fill: "none", stroke: color, strokeWidth: width, strokeLinejoin: "round" }),
|
|
624
|
+
/* @__PURE__ */ jsx(Head, { x: x + 1, y: y2, angle: Math.PI, color, size: 6 }),
|
|
625
|
+
label(x + w + 14, (y1 + y2) / 2 + 4.5, "start")
|
|
626
|
+
] });
|
|
627
|
+
}
|
|
628
|
+
const right = m.x2 > m.x1;
|
|
629
|
+
return /* @__PURE__ */ jsxs("g", { ...events, children: [
|
|
630
|
+
/* @__PURE__ */ jsx("rect", { x: Math.min(m.x1, m.x2), y: m.y - 24, width: Math.abs(m.x2 - m.x1), height: 32, fill: "transparent" }),
|
|
631
|
+
/* @__PURE__ */ jsx("line", { x1: m.x1, x2: m.x2 + (right ? -8 : 8), y1: m.y, y2: m.y, stroke: color, strokeWidth: width, strokeDasharray: m.kind === "return" ? "5 4" : m.kind === "async" ? "2 4" : void 0, strokeLinecap: "round" }),
|
|
632
|
+
/* @__PURE__ */ jsx(Head, { x: m.x2, y: m.y, angle: right ? 0 : Math.PI, color, size: 6 }),
|
|
633
|
+
label((m.x1 + m.x2) / 2, m.y - 9, "middle")
|
|
634
|
+
] });
|
|
635
|
+
}
|
|
636
|
+
function Fragment3({ f, behavior }) {
|
|
637
|
+
const look = useLook(`fragment:${behavior}:${f.id}`);
|
|
638
|
+
return /* @__PURE__ */ jsxs("g", { className: lookClass(look), children: [
|
|
639
|
+
/* @__PURE__ */ jsx("rect", { x: f.x, y: f.y, width: f.w, height: f.h, rx: 14, fill: "var(--poney-paper)", fillOpacity: 0.55, stroke: "var(--poney-story-rule)" }),
|
|
640
|
+
f.branches.slice(1).map((b, i) => /* @__PURE__ */ jsx("line", { x1: f.x + 10, x2: f.x + f.w - 10, y1: b.y, y2: b.y, stroke: "var(--poney-story-rule)", strokeDasharray: "4 4" }, i))
|
|
641
|
+
] });
|
|
642
|
+
}
|
|
643
|
+
function FragmentLabels({ f, behavior }) {
|
|
644
|
+
const look = useLook(`fragment:${behavior}:${f.id}`);
|
|
645
|
+
const name = fragmentLabel(f.kind);
|
|
646
|
+
const first = f.branches[0]?.guard ?? "";
|
|
647
|
+
const nameW = measure(name, 11.5, 650);
|
|
648
|
+
const halo = { stroke: "var(--poney-paper-raised)", strokeWidth: 5, paintOrder: "stroke", strokeLinejoin: "round" };
|
|
649
|
+
return /* @__PURE__ */ jsxs("g", { className: lookClass(look), pointerEvents: "none", children: [
|
|
650
|
+
/* @__PURE__ */ jsx("text", { x: f.x + 14, y: f.y + 19, fontSize: 11.5, fontWeight: 650, fill: "var(--poney-ink-3)", ...halo, children: name }),
|
|
651
|
+
/* @__PURE__ */ jsx("text", { x: f.x + 24 + nameW, y: f.y + 19, fontSize: 12, fill: "var(--poney-ink-2)", ...halo, children: f.kind === "loop" || f.kind === "opt" ? first : `if ${first}` }),
|
|
652
|
+
f.branches.slice(1).map((b, i) => /* @__PURE__ */ jsx("text", { x: f.x + 14, y: b.y + 18, fontSize: 12, fill: "var(--poney-ink-2)", ...halo, children: f.kind === "par" ? `and ${b.guard}` : `else, if ${b.guard}` }, i))
|
|
653
|
+
] });
|
|
654
|
+
}
|
|
655
|
+
function StateStory({ scene }) {
|
|
656
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
657
|
+
scene.transitions.map((t) => /* @__PURE__ */ jsx(TransitionLine, { t, machine: scene.machineId }, t.id)),
|
|
658
|
+
scene.states.map((s) => /* @__PURE__ */ jsx(StateBox, { s, machine: scene.machineId }, s.id)),
|
|
659
|
+
scene.transitions.map((t) => /* @__PURE__ */ jsx(TransitionLabel, { t, machine: scene.machineId }, `l-${t.id}`))
|
|
660
|
+
] });
|
|
661
|
+
}
|
|
662
|
+
function useHotBind(key, ref, label, cls) {
|
|
663
|
+
const bind = useRenderBind();
|
|
664
|
+
const { setHot } = useStory();
|
|
665
|
+
const props = bind(ref, label);
|
|
666
|
+
return {
|
|
667
|
+
...props,
|
|
668
|
+
className: `poney-el ${cls}`,
|
|
669
|
+
onMouseEnter: () => {
|
|
670
|
+
props.onMouseEnter?.();
|
|
671
|
+
setHot(key);
|
|
672
|
+
},
|
|
673
|
+
onMouseLeave: () => {
|
|
674
|
+
props.onMouseLeave?.();
|
|
675
|
+
setHot(null);
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
function StateBox({ s, machine }) {
|
|
680
|
+
const key = `state:${machine}:${s.id}`;
|
|
681
|
+
const look = useLook(key);
|
|
682
|
+
const props = useHotBind(key, { kind: "state", behavior: machine, id: s.id }, `State ${s.name}`, lookClass(look));
|
|
683
|
+
const outcome = s.outcome === "success" ? "var(--poney-success)" : s.outcome === "failure" ? "var(--poney-failure)" : void 0;
|
|
684
|
+
if (s.kind === "initial")
|
|
685
|
+
return /* @__PURE__ */ jsx("g", { transform: `translate(${s.x} ${s.y})`, ...props, children: /* @__PURE__ */ jsx("circle", { cx: s.w / 2, cy: s.h / 2, r: 8, fill: "var(--poney-ink)" }) });
|
|
686
|
+
const stroke = look.hot ? "var(--poney-accent)" : stateStroke(look.state, look.focused ? "var(--poney-story-line)" : "var(--poney-story-rule)");
|
|
687
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${s.x} ${s.y})`, ...props, children: [
|
|
688
|
+
/* @__PURE__ */ jsx("rect", { width: s.w, height: s.h, rx: s.h / 2, fill: stateFill(look.state), stroke, strokeWidth: look.state || look.hot ? 1.8 : 1.25 }),
|
|
689
|
+
s.kind === "final" && /* @__PURE__ */ jsx("rect", { x: 4, y: 4, width: s.w - 8, height: s.h - 8, rx: (s.h - 8) / 2, fill: "none", stroke, strokeWidth: 1 }),
|
|
690
|
+
outcome && /* @__PURE__ */ jsx("circle", { cx: 20, cy: s.h / 2, r: 4, fill: outcome }),
|
|
691
|
+
/* @__PURE__ */ jsx("text", { x: s.w / 2, y: s.entryActions.length ? s.h / 2 - 2 : s.h / 2 + 5, textAnchor: "middle", fontSize: 14.5, fontWeight: 600, fill: "var(--poney-ink)", children: s.name }),
|
|
692
|
+
s.entryActions.length > 0 && /* @__PURE__ */ jsxs("text", { x: s.w / 2, y: s.h / 2 + 15, textAnchor: "middle", fontSize: 11.5, fill: "var(--poney-ink-3)", children: [
|
|
693
|
+
s.entryActions[0],
|
|
694
|
+
s.entryActions.length > 1 ? `, +${s.entryActions.length - 1}` : ""
|
|
695
|
+
] }),
|
|
696
|
+
/* @__PURE__ */ jsx(StateTag, { state: look.state, x: s.w - 14, y: 0, anchor: "end" }),
|
|
697
|
+
look.callout && /* @__PURE__ */ jsx(CalloutBadge, { n: look.callout, x: 0, y: 0, hot: look.hot })
|
|
698
|
+
] });
|
|
699
|
+
}
|
|
700
|
+
function TransitionLine({ t, machine }) {
|
|
701
|
+
const key = `transition:${machine}:${t.id}`;
|
|
702
|
+
const look = useLook(key);
|
|
703
|
+
const props = useHotBind(key, { kind: "transition", behavior: machine, id: t.id }, `Transition: ${t.event}`, lookClass(look));
|
|
704
|
+
const color = look.hot ? "var(--poney-accent)" : stateStroke(look.state, look.focused ? "var(--poney-story-line)" : "var(--poney-story-rule)");
|
|
705
|
+
const d = roundedPath(trimEnd(t.points, 7), 18);
|
|
706
|
+
const last = t.points[t.points.length - 1];
|
|
707
|
+
return /* @__PURE__ */ jsxs("g", { ...props, children: [
|
|
708
|
+
/* @__PURE__ */ jsx("path", { d: roundedPath(t.points, 18), fill: "none", stroke: "transparent", strokeWidth: 16 }),
|
|
709
|
+
/* @__PURE__ */ jsx("path", { d, fill: "none", stroke: color, strokeWidth: look.state || look.hot ? 2 : 1.4, strokeDasharray: look.state === "removed" ? "6 5" : void 0, strokeLinecap: "round" }),
|
|
710
|
+
/* @__PURE__ */ jsx(Head, { x: last.x, y: last.y, angle: endAngle(t.points), color, size: 6 })
|
|
711
|
+
] });
|
|
712
|
+
}
|
|
713
|
+
function TransitionLabel({ t, machine }) {
|
|
714
|
+
const key = `transition:${machine}:${t.id}`;
|
|
715
|
+
const look = useLook(key);
|
|
716
|
+
if (!t.label) return null;
|
|
717
|
+
const { x, y, w, h } = t.label;
|
|
718
|
+
const color = look.hot ? "var(--poney-accent)" : look.state ? `var(--poney-${look.state})` : "var(--poney-ink)";
|
|
719
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x} ${y})`, pointerEvents: "none", className: lookClass(look), children: [
|
|
720
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, rx: 8, fill: look.state ? `var(--poney-${look.state}-wash)` : "var(--poney-paper-raised)", stroke: look.state ? `var(--poney-${look.state})` : "var(--poney-story-rule)" }),
|
|
721
|
+
/* @__PURE__ */ jsx("text", { x: w / 2, y: 15, textAnchor: "middle", fontSize: 11.5, fontWeight: 600, fill: color, textDecoration: look.state === "removed" ? "line-through" : void 0, children: t.event }),
|
|
722
|
+
t.guard && /* @__PURE__ */ jsxs("text", { x: w / 2, y: 28, textAnchor: "middle", fontSize: 10.5, fill: "var(--poney-ink-3)", children: [
|
|
723
|
+
"[",
|
|
724
|
+
t.guard,
|
|
725
|
+
"]"
|
|
726
|
+
] }),
|
|
727
|
+
look.callout && /* @__PURE__ */ jsx(CalloutBadge, { n: look.callout, x: -4, y: h / 2, hot: look.hot })
|
|
728
|
+
] });
|
|
729
|
+
}
|
|
730
|
+
function sceneLines(scene, view) {
|
|
731
|
+
const out = /* @__PURE__ */ new Map();
|
|
732
|
+
if (view.type === "map") {
|
|
733
|
+
for (const e of scene.edges) {
|
|
734
|
+
const c = e.curve;
|
|
735
|
+
const shape = {
|
|
736
|
+
d: `M ${c[0].x} ${c[0].y} C ${c[1].x} ${c[1].y} ${c[2].x} ${c[2].y} ${c[3].x} ${c[3].y}`,
|
|
737
|
+
at: (t) => {
|
|
738
|
+
const p = bezier(c, t);
|
|
739
|
+
const q = bezier(c, Math.min(1, t + 0.01));
|
|
740
|
+
const o = bezier(c, Math.max(0, t - 0.01));
|
|
741
|
+
return { ...p, angle: Math.atan2(q.y - o.y, q.x - o.x) };
|
|
742
|
+
},
|
|
743
|
+
stepAt: 0.18,
|
|
744
|
+
badge: { x: e.label.x + e.label.w / 2, y: e.label.y + e.label.h + 13 },
|
|
745
|
+
sign: { x: e.label.x + e.label.w + 13, y: e.label.y + e.label.h / 2 }
|
|
746
|
+
};
|
|
747
|
+
for (const r of e.relationships) out.set(`relationship:${r}`, shape);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
if (view.type === "sequence") {
|
|
751
|
+
const s = scene;
|
|
752
|
+
for (const m of s.messages) {
|
|
753
|
+
const pts = m.loop ? [
|
|
754
|
+
{ x: m.loop.x, y: m.loop.y1 },
|
|
755
|
+
{ x: m.loop.x + m.loop.w, y: m.loop.y1 },
|
|
756
|
+
{ x: m.loop.x + m.loop.w, y: m.loop.y2 },
|
|
757
|
+
{ x: m.loop.x + 8, y: m.loop.y2 }
|
|
758
|
+
] : [
|
|
759
|
+
{ x: m.x1, y: m.y },
|
|
760
|
+
{ x: m.x2, y: m.y }
|
|
761
|
+
];
|
|
762
|
+
const line = polyline(pts, 0);
|
|
763
|
+
const len = Math.abs(m.x2 - m.x1) || 60;
|
|
764
|
+
const mid = line.at(0.5);
|
|
765
|
+
out.set(`message:${s.interactionId}:${m.id}`, { ...line, stepAt: Math.min(0.4, 22 / len), badge: m.loop ? { x: m.loop.x + m.loop.w + 40, y: m.loop.y2 + 14 } : { x: mid.x, y: mid.y + 15 }, sign: m.loop ? line.at(0.5) : { x: line.at(0.9).x, y: m.y + 15 } });
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
if (view.type === "state") {
|
|
769
|
+
const s = scene;
|
|
770
|
+
for (const t of s.transitions) {
|
|
771
|
+
const line = polyline(t.points, 18);
|
|
772
|
+
const mid = line.at(0.5);
|
|
773
|
+
out.set(`transition:${s.machineId}:${t.id}`, { ...line, stepAt: 0.22, badge: t.label ? { x: t.label.x + t.label.w / 2, y: t.label.y + t.label.h + 13 } : { x: mid.x, y: mid.y + 15 }, sign: t.label ? { x: t.label.x + t.label.w + 13, y: t.label.y + t.label.h / 2 } : line.at(0.3) });
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
return out;
|
|
777
|
+
}
|
|
778
|
+
function polyline(points, radius) {
|
|
779
|
+
const lengths = points.slice(1).map((p, i) => Math.hypot(p.x - points[i].x, p.y - points[i].y));
|
|
780
|
+
const total = lengths.reduce((a, b) => a + b, 0) || 1;
|
|
781
|
+
return {
|
|
782
|
+
d: radius ? roundedPath(points, radius) : `M ${points.map((p) => `${p.x} ${p.y}`).join(" L ")}`,
|
|
783
|
+
at(t) {
|
|
784
|
+
let left = Math.max(0, Math.min(1, t)) * total;
|
|
785
|
+
for (let i = 0; i < lengths.length; i++) {
|
|
786
|
+
const a = points[i];
|
|
787
|
+
const b = points[i + 1];
|
|
788
|
+
if (left <= lengths[i] || i === lengths.length - 1) {
|
|
789
|
+
const f = lengths[i] ? Math.min(1, left / lengths[i]) : 0;
|
|
790
|
+
return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f, angle: Math.atan2(b.y - a.y, b.x - a.x) };
|
|
791
|
+
}
|
|
792
|
+
left -= lengths[i];
|
|
793
|
+
}
|
|
794
|
+
return { ...points[0], angle: 0 };
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
var DEFAULT_COLOR = {
|
|
799
|
+
flow: "var(--poney-lapis)",
|
|
800
|
+
attention: "var(--poney-accent)",
|
|
801
|
+
"hot-path": "var(--poney-accent)",
|
|
802
|
+
slow: "var(--poney-ochre)",
|
|
803
|
+
failing: "var(--poney-failure)",
|
|
804
|
+
blocked: "var(--poney-failure)"
|
|
805
|
+
};
|
|
806
|
+
var colorOf = (as, tone) => tone ? toneColor(tone) : DEFAULT_COLOR[as];
|
|
807
|
+
var isBox = (k) => /^(entity|state|dataType|activityNode|capability):/.test(k);
|
|
808
|
+
function EmphasisUnder({ scene, view }) {
|
|
809
|
+
const s = useStory();
|
|
810
|
+
if (!s.effects?.size) return null;
|
|
811
|
+
const lines = sceneLines(scene, view);
|
|
812
|
+
const out = [];
|
|
813
|
+
s.effects.forEach((effects, key) => {
|
|
814
|
+
const line = lines.get(key);
|
|
815
|
+
if (!line) return;
|
|
816
|
+
for (const e of effects) {
|
|
817
|
+
if (e.as === "flow") continue;
|
|
818
|
+
const strong = e.as === "hot-path";
|
|
819
|
+
out.push(
|
|
820
|
+
/* @__PURE__ */ jsx(
|
|
821
|
+
"path",
|
|
822
|
+
{
|
|
823
|
+
d: line.d,
|
|
824
|
+
fill: "none",
|
|
825
|
+
stroke: colorOf(e.as, e.tone),
|
|
826
|
+
strokeOpacity: strong ? 0.3 : 0.2,
|
|
827
|
+
strokeWidth: strong ? 9 : 11,
|
|
828
|
+
strokeLinecap: "round",
|
|
829
|
+
strokeDasharray: e.as === "slow" ? "1 14" : void 0,
|
|
830
|
+
className: e.as === "attention" ? "poney-pulse" : void 0
|
|
831
|
+
},
|
|
832
|
+
`${key}-${e.as}`
|
|
833
|
+
)
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
return /* @__PURE__ */ jsx("g", { pointerEvents: "none", children: out });
|
|
838
|
+
}
|
|
839
|
+
function EmphasisOver({ scene, view }) {
|
|
840
|
+
const s = useStory();
|
|
841
|
+
const lines = sceneLines(scene, view);
|
|
842
|
+
const box = (key) => {
|
|
843
|
+
const rect = isBox(key) ? scene.anchors[key] : void 0;
|
|
844
|
+
return rect?.entityId && key.startsWith("entity:") && rect.entityId !== key.slice("entity:".length) ? void 0 : rect;
|
|
845
|
+
};
|
|
846
|
+
const out = [];
|
|
847
|
+
s.effects?.forEach((effects, key) => {
|
|
848
|
+
const line = lines.get(key);
|
|
849
|
+
const rect = box(key);
|
|
850
|
+
effects.forEach((e, i) => {
|
|
851
|
+
const color = colorOf(e.as, e.tone);
|
|
852
|
+
const id = `${key}-${e.as}-${i}`;
|
|
853
|
+
if (line) {
|
|
854
|
+
if (e.as === "flow") out.push(/* @__PURE__ */ jsx("path", { d: line.d, fill: "none", stroke: color, strokeWidth: 3, strokeLinecap: "round", strokeDasharray: "0.1 11", className: "poney-flow" }, id));
|
|
855
|
+
if (e.as === "slow" || e.as === "failing" || e.as === "blocked") {
|
|
856
|
+
out.push(/* @__PURE__ */ jsx(Sign, { as: e.as, x: line.sign.x, y: line.sign.y, color }, id));
|
|
857
|
+
}
|
|
858
|
+
} else if (rect) {
|
|
859
|
+
const pad = 6;
|
|
860
|
+
out.push(
|
|
861
|
+
/* @__PURE__ */ jsx(
|
|
862
|
+
"rect",
|
|
863
|
+
{
|
|
864
|
+
x: rect.x - pad,
|
|
865
|
+
y: rect.y - pad,
|
|
866
|
+
width: rect.w + pad * 2,
|
|
867
|
+
height: rect.h + pad * 2,
|
|
868
|
+
rx: Math.min(20, (rect.h + pad * 2) / 2),
|
|
869
|
+
fill: "none",
|
|
870
|
+
stroke: color,
|
|
871
|
+
strokeWidth: e.as === "hot-path" ? 2.5 : 2,
|
|
872
|
+
strokeDasharray: e.as === "blocked" ? "6 4" : e.as === "slow" ? "2 4" : void 0,
|
|
873
|
+
strokeLinecap: "round",
|
|
874
|
+
className: e.as === "attention" ? "poney-pulse" : void 0
|
|
875
|
+
},
|
|
876
|
+
id
|
|
877
|
+
)
|
|
878
|
+
);
|
|
879
|
+
if (e.as === "slow" || e.as === "failing" || e.as === "blocked") out.push(/* @__PURE__ */ jsx(Sign, { as: e.as, x: rect.x + rect.w + 2, y: rect.y + rect.h + 2, color }, `${id}-s`));
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
s.badges?.forEach((badges, key) => {
|
|
884
|
+
const line = lines.get(key);
|
|
885
|
+
const rect = box(key);
|
|
886
|
+
let x = 0;
|
|
887
|
+
let y = 0;
|
|
888
|
+
if (line) {
|
|
889
|
+
x = line.badge.x;
|
|
890
|
+
y = line.badge.y;
|
|
891
|
+
} else if (rect) {
|
|
892
|
+
x = rect.x + rect.w / 2;
|
|
893
|
+
y = rect.y + rect.h;
|
|
894
|
+
} else return;
|
|
895
|
+
const widths = badges.map((b) => measure(b.text, 11, 600) + 16);
|
|
896
|
+
let left = x - (widths.reduce((a, b) => a + b, 0) + (badges.length - 1) * 4) / 2;
|
|
897
|
+
badges.forEach((b, i) => {
|
|
898
|
+
const color = b.tone ? toneColor(b.tone) : "var(--poney-ink-2)";
|
|
899
|
+
out.push(
|
|
900
|
+
/* @__PURE__ */ jsxs("g", { transform: `translate(${left} ${y - 10})`, children: [
|
|
901
|
+
/* @__PURE__ */ jsx("rect", { width: widths[i], height: 20, rx: 10, fill: "var(--poney-paper-raised)", stroke: color, strokeWidth: 1.1 }),
|
|
902
|
+
/* @__PURE__ */ jsx("text", { x: widths[i] / 2, y: 14, textAnchor: "middle", fontSize: 11, fontWeight: 600, fill: color, className: "poney-numbers", children: b.text })
|
|
903
|
+
] }, `b-${key}-${i}`)
|
|
904
|
+
);
|
|
905
|
+
left += widths[i] + 4;
|
|
906
|
+
});
|
|
907
|
+
});
|
|
908
|
+
const trace = s.trace;
|
|
909
|
+
if (trace?.steps.length) {
|
|
910
|
+
if (trace.current === null && trace.numbered) {
|
|
911
|
+
trace.steps.forEach((k, i) => {
|
|
912
|
+
const line = lines.get(k);
|
|
913
|
+
const rect = box(k);
|
|
914
|
+
const p = line ? line.at(line.stepAt) : rect ? { x: rect.x + 14, y: rect.y + rect.h - 2 } : void 0;
|
|
915
|
+
if (p) out.push(/* @__PURE__ */ jsx(StepMark, { n: i + 1, x: p.x, y: p.y }, `t-${i}`));
|
|
916
|
+
});
|
|
917
|
+
} else if (trace.current !== null) {
|
|
918
|
+
const k = trace.steps[trace.current];
|
|
919
|
+
const line = lines.get(k);
|
|
920
|
+
const rect = box(k);
|
|
921
|
+
if (line)
|
|
922
|
+
out.push(
|
|
923
|
+
/* @__PURE__ */ jsxs("g", { children: [
|
|
924
|
+
/* @__PURE__ */ jsx("circle", { r: 7, fill: "var(--poney-accent)", stroke: "var(--poney-paper-raised)", strokeWidth: 2.5, children: trace.animate ? /* @__PURE__ */ jsx("animateMotion", { dur: "0.9s", fill: "freeze", path: line.d, keyPoints: "0;1", keyTimes: "0;1", calcMode: "spline", keySplines: "0.4 0 0.2 1" }) : null }),
|
|
925
|
+
!trace.animate && /* @__PURE__ */ jsx("circle", { cx: line.at(1).x, cy: line.at(1).y, r: 7, fill: "var(--poney-accent)", stroke: "var(--poney-paper-raised)", strokeWidth: 2.5 })
|
|
926
|
+
] }, `token-${trace.current}`)
|
|
927
|
+
);
|
|
928
|
+
else if (rect)
|
|
929
|
+
out.push(/* @__PURE__ */ jsx("rect", { x: rect.x - 7, y: rect.y - 7, width: rect.w + 14, height: rect.h + 14, rx: 20, fill: "none", stroke: "var(--poney-accent)", strokeWidth: 2.5, className: trace.animate ? "poney-pulse" : void 0 }, `token-${trace.current}`));
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
return out.length ? /* @__PURE__ */ jsx("g", { pointerEvents: "none", children: out }) : null;
|
|
933
|
+
}
|
|
934
|
+
function Sign({ as, x, y, color }) {
|
|
935
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
936
|
+
/* @__PURE__ */ jsx("circle", { cx: x, cy: y, r: 10, fill: "var(--poney-paper-raised)", stroke: color, strokeWidth: 1.6 }),
|
|
937
|
+
as === "slow" && /* @__PURE__ */ jsx(Glyph, { name: "timer", x: x - 6.5, y: y - 6.5, size: 13, color }),
|
|
938
|
+
as === "failing" && /* @__PURE__ */ jsx("path", { d: `M ${x - 3.6} ${y - 3.6} L ${x + 3.6} ${y + 3.6} M ${x + 3.6} ${y - 3.6} L ${x - 3.6} ${y + 3.6}`, stroke: color, strokeWidth: 2, strokeLinecap: "round" }),
|
|
939
|
+
as === "blocked" && /* @__PURE__ */ jsx("path", { d: `M ${x - 4.5} ${y} L ${x + 4.5} ${y}`, stroke: color, strokeWidth: 2.4, strokeLinecap: "round" })
|
|
940
|
+
] });
|
|
941
|
+
}
|
|
942
|
+
var stepLetter = (i) => i < 26 ? String.fromCharCode(65 + i) : `${String.fromCharCode(65 + Math.floor(i / 26) - 1)}${String.fromCharCode(65 + i % 26)}`;
|
|
943
|
+
function StepMark({ n, x, y }) {
|
|
944
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
945
|
+
/* @__PURE__ */ jsx("rect", { x: x - 8.5, y: y - 8.5, width: 17, height: 17, rx: 5, fill: "var(--poney-accent)", stroke: "var(--poney-paper-raised)", strokeWidth: 1.75 }),
|
|
946
|
+
/* @__PURE__ */ jsx("text", { x, y: y + 3.8, textAnchor: "middle", fontSize: 10.5, fontWeight: 700, fill: "var(--poney-paper-raised)", className: "poney-numbers", children: stepLetter(n - 1) })
|
|
947
|
+
] });
|
|
948
|
+
}
|
|
949
|
+
function SceneStory({ view, scene, extra }) {
|
|
950
|
+
const body = view.type === "map" ? /* @__PURE__ */ jsx(MapStory, { scene, extra }) : view.type === "sequence" ? /* @__PURE__ */ jsx(SequenceStory, { scene }) : view.type === "state" ? /* @__PURE__ */ jsx(StateStory, { scene }) : null;
|
|
951
|
+
if (!body) return null;
|
|
952
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
953
|
+
/* @__PURE__ */ jsx(EmphasisUnder, { scene, view }),
|
|
954
|
+
body,
|
|
955
|
+
/* @__PURE__ */ jsx(EmphasisOver, { scene, view })
|
|
956
|
+
] });
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// src/diagrams/types.ts
|
|
960
|
+
var viewKey = (view) => view.type === "extension" ? view.extension : view.type;
|
|
961
|
+
function ArrowHead({ at, angle, kind, color, size = 8 }) {
|
|
962
|
+
if (kind === "none") return null;
|
|
963
|
+
const w = kind === "triangle" ? size * 0.75 : size * 0.55;
|
|
964
|
+
const l = kind === "triangle" ? size * 1.25 : size;
|
|
965
|
+
const cos = Math.cos(angle);
|
|
966
|
+
const sin = Math.sin(angle);
|
|
967
|
+
const p = (dx, dy) => `${at.x + dx * cos - dy * sin},${at.y + dx * sin + dy * cos}`;
|
|
968
|
+
if (kind === "open-arrow")
|
|
969
|
+
return /* @__PURE__ */ jsx("polyline", { points: `${p(-l, -w)} ${p(0, 0)} ${p(-l, w)}`, fill: "none", stroke: color, strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" });
|
|
970
|
+
if (kind === "triangle") return /* @__PURE__ */ jsx("polygon", { points: `${p(0, 0)} ${p(-l, -w)} ${p(-l, w)}`, fill: "var(--poney-paper-raised)", stroke: color, strokeWidth: 1.3, strokeLinejoin: "round" });
|
|
971
|
+
return /* @__PURE__ */ jsx("polygon", { points: `${p(0, 0)} ${p(-l, -w)} ${p(-l * 0.72, 0)} ${p(-l, w)}`, fill: color });
|
|
972
|
+
}
|
|
973
|
+
function EdgeLine({ points, style, radius = 8 }) {
|
|
974
|
+
const headLen = style.head === "none" ? 0 : style.head === "triangle" ? 10 : 6;
|
|
975
|
+
const visible = trimEnd(points, headLen);
|
|
976
|
+
const d = roundedPath(visible, radius);
|
|
977
|
+
return /* @__PURE__ */ jsxs("g", { opacity: style.opacity ?? 1, children: [
|
|
978
|
+
/* @__PURE__ */ jsx("path", { d: roundedPath(points, radius), fill: "none", stroke: "transparent", strokeWidth: 14 }),
|
|
979
|
+
/* @__PURE__ */ jsx(
|
|
980
|
+
"path",
|
|
981
|
+
{
|
|
982
|
+
d,
|
|
983
|
+
className: `poney-edge ${style.flowing ? "poney-flowing" : ""}`,
|
|
984
|
+
fill: "none",
|
|
985
|
+
stroke: style.color,
|
|
986
|
+
strokeWidth: style.width,
|
|
987
|
+
strokeDasharray: style.flowing ? void 0 : style.dash,
|
|
988
|
+
strokeLinecap: "round",
|
|
989
|
+
strokeLinejoin: "round"
|
|
990
|
+
}
|
|
991
|
+
),
|
|
992
|
+
/* @__PURE__ */ jsx(ArrowHead, { at: points[points.length - 1], angle: endAngle(points), kind: style.head, color: style.color }),
|
|
993
|
+
style.tail && style.tail !== "none" && /* @__PURE__ */ jsx(ArrowHead, { at: points[0], angle: startAngle(points), kind: style.tail, color: style.color })
|
|
994
|
+
] });
|
|
995
|
+
}
|
|
996
|
+
function EdgeLabel2({
|
|
997
|
+
at,
|
|
998
|
+
text,
|
|
999
|
+
secondary,
|
|
1000
|
+
tone = "var(--poney-ink-2)",
|
|
1001
|
+
strong,
|
|
1002
|
+
size = 11.5
|
|
1003
|
+
}) {
|
|
1004
|
+
const w1 = measure(text, size, strong ? 600 : 500);
|
|
1005
|
+
const w2 = secondary ? measure(secondary, size - 1, 400) : 0;
|
|
1006
|
+
const w = Math.max(w1, w2) + size * 1.2;
|
|
1007
|
+
const h = secondary ? size * 3 : size * 1.75;
|
|
1008
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${at.x - w / 2} ${at.y - h / 2})`, pointerEvents: "none", children: [
|
|
1009
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, rx: size / 2, fill: "var(--poney-paper-raised)", stroke: strong ? tone : "var(--poney-rule)", strokeWidth: strong ? 1.2 : 1 }),
|
|
1010
|
+
/* @__PURE__ */ jsx("text", { x: w / 2, y: size * 1.22, textAnchor: "middle", fontSize: size, fontWeight: strong ? 600 : 500, fill: strong ? tone : "var(--poney-ink-2)", children: text }),
|
|
1011
|
+
secondary && /* @__PURE__ */ jsx("text", { x: w / 2, y: size * 2.4, textAnchor: "middle", fontSize: size - 1, fill: "var(--poney-ink-3)", children: secondary })
|
|
1012
|
+
] });
|
|
1013
|
+
}
|
|
1014
|
+
function useReadableSize(base, screen = 11.5, max = 30) {
|
|
1015
|
+
const k = useRenderZoom();
|
|
1016
|
+
const wanted = screen / k;
|
|
1017
|
+
return wanted <= base ? base : Math.min(max, Math.ceil(wanted / 2) * 2);
|
|
1018
|
+
}
|
|
1019
|
+
function Rings({ w, h, rx = 12, selected }) {
|
|
1020
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1021
|
+
selected && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1022
|
+
/* @__PURE__ */ jsx("rect", { x: -5, y: -5, width: w + 10, height: h + 10, rx: rx + 5, fill: "none", stroke: "var(--poney-accent-ring)", strokeWidth: 6 }),
|
|
1023
|
+
/* @__PURE__ */ jsx("rect", { x: -2.5, y: -2.5, width: w + 5, height: h + 5, rx: rx + 2.5, fill: "none", stroke: "var(--poney-accent)", strokeWidth: 1.75 })
|
|
1024
|
+
] }),
|
|
1025
|
+
/* @__PURE__ */ jsx("rect", { className: "poney-focus", x: -5, y: -5, width: w + 10, height: h + 10, rx: rx + 5, fill: "none", stroke: "var(--poney-accent)", strokeWidth: 2, strokeDasharray: "4 3" })
|
|
1026
|
+
] });
|
|
1027
|
+
}
|
|
1028
|
+
function EntityNode({ entity, style, w, h, emphasis, detail, footer }) {
|
|
1029
|
+
const tone = toneColor(style.tone);
|
|
1030
|
+
const external = entity.kind === "external";
|
|
1031
|
+
const selected = emphasis === "selected";
|
|
1032
|
+
const summary = useMemo(
|
|
1033
|
+
() => entity.summary ? wrap(entity.summary, style.shape === "person" ? w - 12 : w - 30, style.shape === "person" ? 11.5 : 12, 400, 2) : [],
|
|
1034
|
+
[entity.summary, w, style.shape]
|
|
1035
|
+
);
|
|
1036
|
+
const meta = entity.technology ?? style.label;
|
|
1037
|
+
const nameSize = useReadableSize(14, 10.5);
|
|
1038
|
+
const compact = nameSize > 14 && style.shape !== "person";
|
|
1039
|
+
const bigLines = useMemo(() => compact ? wrap(entity.name, w - 28, nameSize, 650, 2) : [], [compact, entity.name, w, nameSize]);
|
|
1040
|
+
const stroke = style.emphasis ? `color-mix(in srgb, ${tone} 55%, var(--poney-rule-strong))` : "var(--poney-rule-strong)";
|
|
1041
|
+
if (style.shape === "person") {
|
|
1042
|
+
const cx = w / 2;
|
|
1043
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1044
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, rx: 14, fill: "transparent" }),
|
|
1045
|
+
/* @__PURE__ */ jsx("circle", { cx, cy: 22, r: 15, fill: toneWash(style.tone, 16), stroke: tone, strokeWidth: 1.4 }),
|
|
1046
|
+
/* @__PURE__ */ jsx("path", { d: `M ${cx - 27} 64 Q ${cx - 27} 42 ${cx} 42 Q ${cx + 27} 42 ${cx + 27} 64 Z`, fill: toneWash(style.tone, 16), stroke: tone, strokeWidth: 1.4, strokeLinejoin: "round" }),
|
|
1047
|
+
/* @__PURE__ */ jsx("text", { x: cx, y: 70 + Math.min(nameSize, 20), textAnchor: "middle", fontSize: Math.min(nameSize, 20), fontWeight: 650, fill: "var(--poney-ink)", children: clip(entity.name, w + 40, Math.min(nameSize, 20), 650) }),
|
|
1048
|
+
detail && !compact && nameSize === 14 && summary.map((line, i) => /* @__PURE__ */ jsx("text", { x: cx, y: 101 + i * 14, textAnchor: "middle", fontSize: 11.5, fill: "var(--poney-ink-3)", children: line }, i)),
|
|
1049
|
+
/* @__PURE__ */ jsx(Rings, { w, h, rx: 14, selected })
|
|
1050
|
+
] });
|
|
1051
|
+
}
|
|
1052
|
+
const bigName = (dy = 0) => bigLines.map((line, i) => /* @__PURE__ */ jsx("text", { x: w / 2, y: dy + h / 2 + nameSize * 0.36 + (i - (bigLines.length - 1) / 2) * nameSize * 1.1, textAnchor: "middle", fontSize: nameSize, fontWeight: 650, fill: "var(--poney-ink)", children: line }, i));
|
|
1053
|
+
if (style.shape === "chip") {
|
|
1054
|
+
const dashed = entity.kind === "interface";
|
|
1055
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1056
|
+
/* @__PURE__ */ jsx("rect", { className: "poney-body", width: w, height: h, rx: 10, fill: entity.kind === "library" ? "var(--poney-paper)" : "var(--poney-paper-raised)", stroke: dashed ? tone : stroke, strokeDasharray: dashed ? "5 3" : void 0, strokeWidth: 1.1 }),
|
|
1057
|
+
compact ? bigName() : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1058
|
+
/* @__PURE__ */ jsx("rect", { x: 11, y: (h - 30) / 2, width: 30, height: 30, rx: 8, fill: toneWash(style.tone, 13) }),
|
|
1059
|
+
/* @__PURE__ */ jsx(Glyph, { name: style.icon, x: 18, y: (h - 30) / 2 + 7, size: 16, color: tone }),
|
|
1060
|
+
/* @__PURE__ */ jsx("text", { x: 52, y: h / 2 - 3, fontSize: 13.5, fontWeight: 600, fill: "var(--poney-ink)", fontFamily: entity.kind === "interface" ? "var(--poney-font-mono)" : void 0, children: clip(entity.name, w - 62, 13.5, 600, entity.kind === "interface" ? "mono" : "sans") }),
|
|
1061
|
+
/* @__PURE__ */ jsx("text", { x: 52, y: h / 2 + 13, fontSize: 11.5, fill: "var(--poney-ink-3)", children: clip(meta, w - 62, 11.5) })
|
|
1062
|
+
] }),
|
|
1063
|
+
/* @__PURE__ */ jsx(Rings, { w, h, rx: 10, selected })
|
|
1064
|
+
] });
|
|
1065
|
+
}
|
|
1066
|
+
const top = style.shape === "cylinder" ? 12 : 0;
|
|
1067
|
+
const body = style.shape === "cylinder" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1068
|
+
/* @__PURE__ */ jsx(
|
|
1069
|
+
"path",
|
|
1070
|
+
{
|
|
1071
|
+
className: "poney-body",
|
|
1072
|
+
d: `M 0 10 A ${w / 2} 10 0 0 1 ${w} 10 V ${h - 10} A ${w / 2} 10 0 0 1 0 ${h - 10} Z`,
|
|
1073
|
+
fill: "var(--poney-paper-raised)",
|
|
1074
|
+
stroke,
|
|
1075
|
+
strokeWidth: 1.1
|
|
1076
|
+
}
|
|
1077
|
+
),
|
|
1078
|
+
/* @__PURE__ */ jsx("ellipse", { cx: w / 2, cy: 10, rx: w / 2, ry: 10, fill: toneWash(style.tone, 9), stroke, strokeWidth: 1.1 })
|
|
1079
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1080
|
+
style.shape === "stack" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1081
|
+
/* @__PURE__ */ jsx("rect", { x: 8, y: -8, width: w, height: h, rx: 12, fill: "var(--poney-paper)", stroke: "var(--poney-rule-strong)", strokeWidth: 1 }),
|
|
1082
|
+
/* @__PURE__ */ jsx("rect", { x: 4, y: -4, width: w, height: h, rx: 12, fill: "var(--poney-paper)", stroke: "var(--poney-rule-strong)", strokeWidth: 1 })
|
|
1083
|
+
] }),
|
|
1084
|
+
/* @__PURE__ */ jsx(
|
|
1085
|
+
"rect",
|
|
1086
|
+
{
|
|
1087
|
+
className: "poney-body",
|
|
1088
|
+
width: w,
|
|
1089
|
+
height: h,
|
|
1090
|
+
rx: style.shape === "frame" ? 16 : 12,
|
|
1091
|
+
fill: style.shape === "frame" ? toneWash(style.tone, 6) : "var(--poney-paper-raised)",
|
|
1092
|
+
stroke: external ? tone : stroke,
|
|
1093
|
+
strokeDasharray: external ? "6 4" : void 0,
|
|
1094
|
+
strokeWidth: style.shape === "frame" ? 1.5 : 1.1
|
|
1095
|
+
}
|
|
1096
|
+
)
|
|
1097
|
+
] });
|
|
1098
|
+
const big = style.shape === "frame";
|
|
1099
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1100
|
+
body,
|
|
1101
|
+
compact && bigName(top / 2),
|
|
1102
|
+
/* @__PURE__ */ jsxs("g", { transform: `translate(0 ${top})`, display: compact ? "none" : void 0, children: [
|
|
1103
|
+
/* @__PURE__ */ jsx("rect", { x: 14, y: 14, width: big ? 38 : 32, height: big ? 38 : 32, rx: 9, fill: toneWash(style.tone, 14) }),
|
|
1104
|
+
/* @__PURE__ */ jsx(Glyph, { name: style.icon, x: big ? 23 : 21.5, y: big ? 23 : 21.5, size: big ? 20 : 17, color: tone }),
|
|
1105
|
+
/* @__PURE__ */ jsx("text", { x: big ? 64 : 56, y: big ? 31 : 29, fontSize: big ? 16 : 14, fontWeight: 650, fill: "var(--poney-ink)", children: clip(entity.name, w - (big ? 76 : 68), big ? 16 : 14, 650) }),
|
|
1106
|
+
/* @__PURE__ */ jsx("text", { x: big ? 64 : 56, y: big ? 48 : 45.5, fontSize: 11.5, fill: "var(--poney-ink-3)", children: clip(meta, w - (big ? 76 : 68), 11.5) }),
|
|
1107
|
+
detail && summary.map((line, i) => /* @__PURE__ */ jsx("text", { x: 14, y: (big ? 76 : 70) + i * 15, fontSize: 12, fill: "var(--poney-ink-2)", children: line }, i)),
|
|
1108
|
+
footer && /* @__PURE__ */ jsx("text", { x: 14, y: h - top - 16, fontSize: 12, fontWeight: 600, fill: tone, children: footer })
|
|
1109
|
+
] }),
|
|
1110
|
+
/* @__PURE__ */ jsx(Rings, { w, h, rx: big ? 16 : 12, selected })
|
|
1111
|
+
] });
|
|
1112
|
+
}
|
|
1113
|
+
function LegendShape({ shape, tone, label, dashed }) {
|
|
1114
|
+
const c = toneColor(tone);
|
|
1115
|
+
const fill = toneWash(tone, 14);
|
|
1116
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend-row", children: [
|
|
1117
|
+
/* @__PURE__ */ jsxs("svg", { width: "22", height: "16", "aria-hidden": true, className: "poney-legend-mark", children: [
|
|
1118
|
+
shape === "person" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1119
|
+
/* @__PURE__ */ jsx("circle", { cx: "11", cy: "5", r: "3.6", fill, stroke: c, strokeWidth: "1.2" }),
|
|
1120
|
+
/* @__PURE__ */ jsx("path", { d: "M4.5 15 Q4.5 9.5 11 9.5 Q17.5 9.5 17.5 15 Z", fill, stroke: c, strokeWidth: "1.2" })
|
|
1121
|
+
] }),
|
|
1122
|
+
shape === "cylinder" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1123
|
+
/* @__PURE__ */ jsx("path", { d: "M2 4 A9 2.6 0 0 1 20 4 V12 A9 2.6 0 0 1 2 12 Z", fill, stroke: c, strokeWidth: "1.2" }),
|
|
1124
|
+
/* @__PURE__ */ jsx("ellipse", { cx: "11", cy: "4", rx: "9", ry: "2.6", fill, stroke: c, strokeWidth: "1.2" })
|
|
1125
|
+
] }),
|
|
1126
|
+
shape === "stack" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1127
|
+
/* @__PURE__ */ jsx("rect", { x: "5", y: "1", width: "15", height: "10", rx: "2.5", fill: "none", stroke: c, strokeWidth: "1", opacity: "0.6" }),
|
|
1128
|
+
/* @__PURE__ */ jsx("rect", { x: "2", y: "4", width: "15", height: "10", rx: "2.5", fill, stroke: c, strokeWidth: "1.2" })
|
|
1129
|
+
] }),
|
|
1130
|
+
(shape === "card" || shape === "frame" || shape === "chip") && /* @__PURE__ */ jsx("rect", { x: "2", y: "2", width: "18", height: "12", rx: "3", fill, stroke: c, strokeWidth: "1.2", strokeDasharray: dashed ? "3 2" : void 0 }),
|
|
1131
|
+
shape === "pill" && /* @__PURE__ */ jsx("rect", { x: "1", y: "3", width: "20", height: "10", rx: "5", fill, stroke: c, strokeWidth: "1.2" }),
|
|
1132
|
+
shape === "diamond" && /* @__PURE__ */ jsx("path", { d: "M11 1 L20 8 L11 15 L2 8 Z", fill, stroke: c, strokeWidth: "1.2" }),
|
|
1133
|
+
shape === "dot" && /* @__PURE__ */ jsx("circle", { cx: "11", cy: "8", r: "5", fill: c }),
|
|
1134
|
+
shape === "bullseye" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1135
|
+
/* @__PURE__ */ jsx("circle", { cx: "11", cy: "8", r: "6", fill: "none", stroke: c, strokeWidth: "1.2" }),
|
|
1136
|
+
/* @__PURE__ */ jsx("circle", { cx: "11", cy: "8", r: "3.4", fill: c })
|
|
1137
|
+
] }),
|
|
1138
|
+
shape === "store" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1139
|
+
/* @__PURE__ */ jsx("path", { d: "M2 3 H20 M2 13 H20", stroke: c, strokeWidth: "1.2" }),
|
|
1140
|
+
/* @__PURE__ */ jsx("rect", { x: "2", y: "3", width: "18", height: "10", fill })
|
|
1141
|
+
] }),
|
|
1142
|
+
shape === "bar" && /* @__PURE__ */ jsx("rect", { x: "2", y: "6", width: "18", height: "4", rx: "2", fill: c })
|
|
1143
|
+
] }),
|
|
1144
|
+
/* @__PURE__ */ jsx("span", { children: label })
|
|
1145
|
+
] });
|
|
1146
|
+
}
|
|
1147
|
+
function LegendRow({ line, label, color = "var(--poney-ink-3)", head = true }) {
|
|
1148
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend-row", children: [
|
|
1149
|
+
/* @__PURE__ */ jsxs("svg", { width: "22", height: "16", "aria-hidden": true, className: "poney-legend-mark", children: [
|
|
1150
|
+
/* @__PURE__ */ jsx("line", { x1: "1", y1: "8", x2: head ? 15 : 21, y2: "8", stroke: color, strokeWidth: "1.4", strokeDasharray: line === "dashed" ? "4 3" : line === "dotted" ? "1.4 3" : void 0 }),
|
|
1151
|
+
head && /* @__PURE__ */ jsx("path", { d: "M14 4.5 L21 8 L14 11.5 Z", fill: color })
|
|
1152
|
+
] }),
|
|
1153
|
+
/* @__PURE__ */ jsx("span", { children: label })
|
|
1154
|
+
] });
|
|
1155
|
+
}
|
|
1156
|
+
function useCollapsed(view) {
|
|
1157
|
+
const [ui, update] = useViewState(view.id);
|
|
1158
|
+
const collapsed = ui.collapsed ?? view.collapsed;
|
|
1159
|
+
const toggle = (id) => update({ collapsed: collapsed.includes(id) ? collapsed.filter((c) => c !== id) : [...collapsed, id] });
|
|
1160
|
+
return { collapsed, toggle };
|
|
1161
|
+
}
|
|
1162
|
+
function Toggle({ x, y, open, label, onToggle }) {
|
|
1163
|
+
if (useRenderStill()) return null;
|
|
1164
|
+
return /* @__PURE__ */ jsxs(
|
|
1165
|
+
"g",
|
|
1166
|
+
{
|
|
1167
|
+
transform: `translate(${x} ${y})`,
|
|
1168
|
+
role: "button",
|
|
1169
|
+
tabIndex: 0,
|
|
1170
|
+
"aria-label": `${open ? "Close" : "Open"} ${label}`,
|
|
1171
|
+
"aria-expanded": open,
|
|
1172
|
+
className: "poney-control",
|
|
1173
|
+
"data-ref": "toggle",
|
|
1174
|
+
onClick: (e) => {
|
|
1175
|
+
e.stopPropagation();
|
|
1176
|
+
onToggle();
|
|
1177
|
+
},
|
|
1178
|
+
onDoubleClick: (e) => e.stopPropagation(),
|
|
1179
|
+
onKeyDown: (e) => {
|
|
1180
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1181
|
+
e.preventDefault();
|
|
1182
|
+
e.stopPropagation();
|
|
1183
|
+
onToggle();
|
|
1184
|
+
}
|
|
1185
|
+
},
|
|
1186
|
+
children: [
|
|
1187
|
+
/* @__PURE__ */ jsx("rect", { width: 26, height: 26, rx: 7, fill: "var(--poney-paper-raised)", stroke: "var(--poney-rule-strong)" }),
|
|
1188
|
+
/* @__PURE__ */ jsx("g", { transform: "translate(5 5)", color: "var(--poney-ink-2)", children: open ? /* @__PURE__ */ jsx(ChevronsDownUp, { width: 16, height: 16, strokeWidth: 1.8 }) : /* @__PURE__ */ jsx(ChevronsUpDown, { width: 16, height: 16, strokeWidth: 1.8 }) }),
|
|
1189
|
+
/* @__PURE__ */ jsx("rect", { className: "poney-focus", x: -3, y: -3, width: 32, height: 32, rx: 9, fill: "none", stroke: "var(--poney-accent)", strokeWidth: 2 })
|
|
1190
|
+
]
|
|
1191
|
+
}
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
function Renderer({ scene, view }) {
|
|
1195
|
+
const idx = useRenderIndex();
|
|
1196
|
+
const bind = useRenderBind();
|
|
1197
|
+
const zoom = useRenderZoom();
|
|
1198
|
+
const { subject, selection } = useRenderSubject();
|
|
1199
|
+
const { toggle } = useCollapsed(view);
|
|
1200
|
+
const relStyles = idx.doc.presentation.relationships;
|
|
1201
|
+
const groupSize = useReadableSize(12.5, 11, 26);
|
|
1202
|
+
const systemSize = useReadableSize(15, 12, 32);
|
|
1203
|
+
const labelSize = useReadableSize(11.5, 10.5, 26);
|
|
1204
|
+
const focus = useMemo(() => {
|
|
1205
|
+
if (!subject) return null;
|
|
1206
|
+
const nodes = /* @__PURE__ */ new Set();
|
|
1207
|
+
const edges = /* @__PURE__ */ new Set();
|
|
1208
|
+
const byId = new Map(scene.nodes.map((n) => [n.id, n]));
|
|
1209
|
+
const descendants = (id) => scene.nodes.filter((n) => isInside(n, id, byId)).forEach((n) => nodes.add(n.id));
|
|
1210
|
+
const nodeFor = (entityId) => scene.nodes.find((n) => n.entityId === entityId)?.id ?? repOf(entityId);
|
|
1211
|
+
const repOf = (entityId) => {
|
|
1212
|
+
const a = scene.anchors[`entity:${entityId}`];
|
|
1213
|
+
return a ? scene.nodes.find((n) => n.x === a.x && n.y === a.y && n.w === a.w && n.h === a.h)?.id : void 0;
|
|
1214
|
+
};
|
|
1215
|
+
if (subject.kind === "entity") {
|
|
1216
|
+
const id = nodeFor(subject.id);
|
|
1217
|
+
if (!id) return null;
|
|
1218
|
+
nodes.add(id);
|
|
1219
|
+
descendants(id);
|
|
1220
|
+
const own = new Set(nodes);
|
|
1221
|
+
for (const e of scene.edges)
|
|
1222
|
+
if (own.has(e.source) || own.has(e.target)) {
|
|
1223
|
+
edges.add(e.id);
|
|
1224
|
+
nodes.add(e.source);
|
|
1225
|
+
nodes.add(e.target);
|
|
1226
|
+
}
|
|
1227
|
+
} else if (subject.kind === "relationship") {
|
|
1228
|
+
const e = scene.edges.find((x) => x.relationships.includes(subject.id));
|
|
1229
|
+
if (!e) return null;
|
|
1230
|
+
edges.add(e.id);
|
|
1231
|
+
nodes.add(e.source);
|
|
1232
|
+
nodes.add(e.target);
|
|
1233
|
+
} else if (subject.kind === "group" && subject.view === view.id) {
|
|
1234
|
+
const id = `g:${subject.id}`;
|
|
1235
|
+
nodes.add(id);
|
|
1236
|
+
descendants(id);
|
|
1237
|
+
const own = new Set(nodes);
|
|
1238
|
+
for (const e of scene.edges) if (own.has(e.source) || own.has(e.target)) edges.add(e.id);
|
|
1239
|
+
} else return null;
|
|
1240
|
+
return { nodes, edges };
|
|
1241
|
+
}, [subject, scene, view.id]);
|
|
1242
|
+
const selectedNode = selection?.kind === "entity" ? scene.nodes.find((n) => n.entityId === selection.id)?.id : selection?.kind === "group" ? `g:${selection.id}` : void 0;
|
|
1243
|
+
const selectedEdge = selection?.kind === "relationship" ? scene.edges.find((e) => e.relationships.includes(selection.id))?.id : void 0;
|
|
1244
|
+
const dimNode = (n) => !!focus && !n.compound && !focus.nodes.has(n.id);
|
|
1245
|
+
const containers = scene.nodes.filter((n) => n.compound);
|
|
1246
|
+
const leaves = scene.nodes.filter((n) => !n.compound);
|
|
1247
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1248
|
+
containers.map((n) => {
|
|
1249
|
+
if (n.type === "group") {
|
|
1250
|
+
const g = view.groups.find((x) => x.id === n.groupId);
|
|
1251
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${n.x} ${n.y})`, ...bind({ kind: "group", view: view.id, id: g.id }, `Group ${g.label}`), children: [
|
|
1252
|
+
/* @__PURE__ */ jsx("rect", { width: n.w, height: n.h, rx: 14, fill: "var(--poney-plaster)", fillOpacity: 0.55, stroke: "var(--poney-rule-strong)", strokeDasharray: "5 4" }),
|
|
1253
|
+
/* @__PURE__ */ jsx("text", { x: 16, y: 12 + groupSize, fontSize: groupSize, fontWeight: 600, fill: "var(--poney-ink-2)", children: g.label }),
|
|
1254
|
+
/* @__PURE__ */ jsx(Toggle, { x: n.w - 36, y: 7, open: true, label: g.label, onToggle: () => toggle(g.id) }),
|
|
1255
|
+
/* @__PURE__ */ jsx(Rings, { w: n.w, h: n.h, rx: 14, selected: selectedNode === n.id })
|
|
1256
|
+
] }, n.id);
|
|
1257
|
+
}
|
|
1258
|
+
const e = idx.entities.get(n.entityId);
|
|
1259
|
+
const s = idx.style(e, view.id);
|
|
1260
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${n.x} ${n.y})`, ...bind({ kind: "entity", id: e.id }, `${e.name}, ${s.label}, contains ${n.hiddenCount || "several"} parts`), children: [
|
|
1261
|
+
/* @__PURE__ */ jsx("rect", { width: n.w, height: n.h, rx: 18, fill: `color-mix(in srgb, ${toneColor(s.tone)} 4%, var(--poney-paper))`, stroke: "var(--poney-rule-strong)", strokeWidth: 1.25 }),
|
|
1262
|
+
/* @__PURE__ */ jsx(Glyph, { name: s.icon, x: 20, y: 18, size: 18, color: toneColor(s.tone) }),
|
|
1263
|
+
/* @__PURE__ */ jsx("text", { x: 46, y: systemSize > 15 ? 16 + systemSize : 32, fontSize: systemSize, fontWeight: 650, fill: "var(--poney-ink)", children: e.name }),
|
|
1264
|
+
systemSize === 15 && /* @__PURE__ */ jsx("text", { x: 20, y: 48, fontSize: 12, fill: "var(--poney-ink-3)", children: clip(e.summary, n.w - 80, 12) }),
|
|
1265
|
+
/* @__PURE__ */ jsx(Toggle, { x: n.w - 40, y: 12, open: true, label: e.name, onToggle: () => toggle(e.id) }),
|
|
1266
|
+
/* @__PURE__ */ jsx(Rings, { w: n.w, h: n.h, rx: 18, selected: selectedNode === n.id })
|
|
1267
|
+
] }, n.id);
|
|
1268
|
+
}),
|
|
1269
|
+
scene.edges.map((edge) => {
|
|
1270
|
+
const rel = idx.relationships.get(edge.relationships[0]);
|
|
1271
|
+
const ls = relStyles[rel.kind] ?? { pattern: "solid", head: "arrow" };
|
|
1272
|
+
const hot = focus?.edges.has(edge.id);
|
|
1273
|
+
const selected = selectedEdge === edge.id;
|
|
1274
|
+
const color = hot || selected ? "var(--poney-accent)" : "var(--poney-ink-4)";
|
|
1275
|
+
const label = edge.relationships.length > 1 ? `${edge.relationships.length} connections` : rel.label;
|
|
1276
|
+
return /* @__PURE__ */ jsx(
|
|
1277
|
+
"g",
|
|
1278
|
+
{
|
|
1279
|
+
...bind({ kind: "relationship", id: edge.relationships[0] }, `${idx.describe({ kind: "relationship", id: rel.id }).title}: ${label}`),
|
|
1280
|
+
className: `poney-el ${focus && !hot ? "poney-dim" : ""}`,
|
|
1281
|
+
children: /* @__PURE__ */ jsx(
|
|
1282
|
+
EdgeLine,
|
|
1283
|
+
{
|
|
1284
|
+
points: edge.points,
|
|
1285
|
+
style: {
|
|
1286
|
+
color,
|
|
1287
|
+
width: hot || selected ? 1.9 : 1.3,
|
|
1288
|
+
dash: ls.pattern === "dashed" ? "6 4" : ls.pattern === "dotted" ? "1.5 4" : void 0,
|
|
1289
|
+
head: ls.head,
|
|
1290
|
+
flowing: selected && (rel.kind === "publishes" || rel.kind === "subscribes")
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
)
|
|
1294
|
+
},
|
|
1295
|
+
edge.id
|
|
1296
|
+
);
|
|
1297
|
+
}),
|
|
1298
|
+
leaves.map((n) => {
|
|
1299
|
+
if (n.type === "group") {
|
|
1300
|
+
const g = view.groups.find((x) => x.id === n.groupId);
|
|
1301
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${n.x} ${n.y})`, ...bind({ kind: "group", view: view.id, id: g.id }, `Group ${g.label}, closed`), className: `poney-el ${dimNode(n) ? "poney-dim" : ""}`, children: [
|
|
1302
|
+
/* @__PURE__ */ jsx("rect", { x: 6, y: -6, width: n.w, height: n.h, rx: 12, fill: "var(--poney-paper)", stroke: "var(--poney-rule-strong)" }),
|
|
1303
|
+
/* @__PURE__ */ jsx("rect", { width: n.w, height: n.h, rx: 12, fill: "var(--poney-paper-raised)", stroke: "var(--poney-rule-strong)", strokeDasharray: "5 4" }),
|
|
1304
|
+
/* @__PURE__ */ jsx("text", { x: 16, y: 30, fontSize: 14, fontWeight: 650, fill: "var(--poney-ink)", children: g.label }),
|
|
1305
|
+
/* @__PURE__ */ jsxs("text", { x: 16, y: 50, fontSize: 12, fill: "var(--poney-ink-3)", children: [
|
|
1306
|
+
n.hiddenCount,
|
|
1307
|
+
" parts inside"
|
|
1308
|
+
] }),
|
|
1309
|
+
g.description && zoom > 0.55 && /* @__PURE__ */ jsx("text", { x: 16, y: 74, fontSize: 12, fill: "var(--poney-ink-2)", children: clip(g.description, n.w - 32, 12) }),
|
|
1310
|
+
/* @__PURE__ */ jsx(Toggle, { x: n.w - 36, y: 10, open: false, label: g.label, onToggle: () => toggle(g.id) }),
|
|
1311
|
+
/* @__PURE__ */ jsx(Rings, { w: n.w, h: n.h, selected: selectedNode === n.id })
|
|
1312
|
+
] }, n.id);
|
|
1313
|
+
}
|
|
1314
|
+
const e = idx.entities.get(n.entityId);
|
|
1315
|
+
const s = idx.style(e, view.id);
|
|
1316
|
+
const style = n.collapsed ? { ...s, shape: "frame" } : s;
|
|
1317
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${n.x} ${n.y})`, ...bind({ kind: "entity", id: e.id }, `${e.name}, ${s.label}. ${e.summary}`), className: `poney-el ${dimNode(n) ? "poney-dim" : ""}`, children: [
|
|
1318
|
+
/* @__PURE__ */ jsx(
|
|
1319
|
+
EntityNode,
|
|
1320
|
+
{
|
|
1321
|
+
entity: e,
|
|
1322
|
+
style,
|
|
1323
|
+
w: n.w,
|
|
1324
|
+
h: n.h,
|
|
1325
|
+
emphasis: selectedNode === n.id ? "selected" : "normal",
|
|
1326
|
+
detail: zoom > 0.55,
|
|
1327
|
+
footer: n.collapsed ? `${n.hiddenCount} parts inside` : void 0
|
|
1328
|
+
}
|
|
1329
|
+
),
|
|
1330
|
+
n.collapsed && /* @__PURE__ */ jsx(Toggle, { x: n.w - 40, y: 12, open: false, label: e.name, onToggle: () => toggle(e.id) })
|
|
1331
|
+
] }, n.id);
|
|
1332
|
+
}),
|
|
1333
|
+
scene.edges.filter((e) => focus?.edges.has(e.id) || selectedEdge === e.id).map((edge) => {
|
|
1334
|
+
const rel = idx.relationships.get(edge.relationships[0]);
|
|
1335
|
+
const multiple = edge.relationships.length > 1;
|
|
1336
|
+
return /* @__PURE__ */ jsx(
|
|
1337
|
+
EdgeLabel2,
|
|
1338
|
+
{
|
|
1339
|
+
at: labelPoint(edge.points),
|
|
1340
|
+
text: multiple ? `${edge.relationships.length} connections` : rel.label,
|
|
1341
|
+
secondary: multiple ? void 0 : rel.protocol,
|
|
1342
|
+
tone: "var(--poney-accent)",
|
|
1343
|
+
strong: selectedEdge === edge.id,
|
|
1344
|
+
size: labelSize
|
|
1345
|
+
},
|
|
1346
|
+
`l-${edge.id}`
|
|
1347
|
+
);
|
|
1348
|
+
})
|
|
1349
|
+
] });
|
|
1350
|
+
}
|
|
1351
|
+
function isInside(n, ancestor, byId) {
|
|
1352
|
+
let p = n.parent;
|
|
1353
|
+
while (p) {
|
|
1354
|
+
if (p === ancestor) return true;
|
|
1355
|
+
p = byId.get(p)?.parent;
|
|
1356
|
+
}
|
|
1357
|
+
return false;
|
|
1358
|
+
}
|
|
1359
|
+
function Legend({ view }) {
|
|
1360
|
+
const idx = useRenderIndex();
|
|
1361
|
+
const kinds = [...new Set(view.entities.map((id) => idx.entities.get(id)?.kind).filter(Boolean))];
|
|
1362
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend", children: [
|
|
1363
|
+
kinds.map((k) => {
|
|
1364
|
+
const s = idx.doc.presentation.kinds[k];
|
|
1365
|
+
return s ? /* @__PURE__ */ jsx(LegendShape, { shape: s.shape, tone: s.tone, label: s.label, dashed: k === "external" }, k) : null;
|
|
1366
|
+
}),
|
|
1367
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "solid", label: "Request and response" }),
|
|
1368
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "dashed", label: "Event, sent and forgotten" })
|
|
1369
|
+
] });
|
|
1370
|
+
}
|
|
1371
|
+
var architecture = {
|
|
1372
|
+
key: "architecture",
|
|
1373
|
+
label: "Architecture",
|
|
1374
|
+
icon: Network,
|
|
1375
|
+
howToRead: "Boxes are the running parts of the system; lines show who calls whom. Select a part to see what it talks to. Open or close a group with its corner button.",
|
|
1376
|
+
Renderer,
|
|
1377
|
+
Legend
|
|
1378
|
+
};
|
|
1379
|
+
function Renderer2({ scene }) {
|
|
1380
|
+
const idx = useRenderIndex();
|
|
1381
|
+
const bind = useRenderBind();
|
|
1382
|
+
const { subject, selection } = useRenderSubject();
|
|
1383
|
+
const behavior = scene.interactionId;
|
|
1384
|
+
const flat = idx.messages(behavior);
|
|
1385
|
+
const focus = useMemo(() => {
|
|
1386
|
+
if (!subject) return null;
|
|
1387
|
+
const msgs = /* @__PURE__ */ new Set();
|
|
1388
|
+
const people = /* @__PURE__ */ new Set();
|
|
1389
|
+
const add = (id) => {
|
|
1390
|
+
const m = flat.find((f) => f.message.id === id)?.message;
|
|
1391
|
+
if (!m) return;
|
|
1392
|
+
msgs.add(id);
|
|
1393
|
+
people.add(m.from);
|
|
1394
|
+
people.add(m.to);
|
|
1395
|
+
};
|
|
1396
|
+
if (subject.kind === "entity") {
|
|
1397
|
+
if (!scene.participants.some((p) => p.entityId === subject.id)) return null;
|
|
1398
|
+
people.add(subject.id);
|
|
1399
|
+
flat.forEach((f) => (f.message.from === subject.id || f.message.to === subject.id) && msgs.add(f.message.id));
|
|
1400
|
+
} else if (subject.kind === "message" && subject.behavior === behavior) add(subject.id);
|
|
1401
|
+
else if (subject.kind === "fragment" && subject.behavior === behavior) flat.forEach((f) => f.context.some((c) => c.fragment.id === subject.id) && add(f.message.id));
|
|
1402
|
+
else if (subject.kind === "relationship") flat.forEach((f) => f.message.relationship === subject.id && add(f.message.id));
|
|
1403
|
+
else if (subject.kind === "dataType") flat.forEach((f) => f.message.data.includes(subject.id) && add(f.message.id));
|
|
1404
|
+
else return null;
|
|
1405
|
+
return msgs.size || people.size ? { msgs, people } : null;
|
|
1406
|
+
}, [subject, flat, scene.participants, behavior]);
|
|
1407
|
+
const selectedMsg = selection?.kind === "message" && selection.behavior === behavior ? selection.id : void 0;
|
|
1408
|
+
const selectedFrag = selection?.kind === "fragment" && selection.behavior === behavior ? selection.id : void 0;
|
|
1409
|
+
const selectedEntity = selection?.kind === "entity" ? selection.id : void 0;
|
|
1410
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1411
|
+
scene.fragments.map((f) => {
|
|
1412
|
+
const hot = focus?.msgs.size && flat.some((m) => focus.msgs.has(m.message.id) && m.context.some((c) => c.fragment.id === f.id));
|
|
1413
|
+
return /* @__PURE__ */ jsx("rect", { x: f.x, y: f.y, width: f.w, height: f.h, rx: 10, fill: "var(--poney-paper)", fillOpacity: 0.5, stroke: selectedFrag === f.id ? "var(--poney-accent)" : hot ? "var(--poney-ink-4)" : "var(--poney-rule-strong)", strokeWidth: selectedFrag === f.id ? 1.6 : 1 }, `bg-${f.id}`);
|
|
1414
|
+
}),
|
|
1415
|
+
scene.participants.map((p) => {
|
|
1416
|
+
const hot = focus?.people.has(p.entityId);
|
|
1417
|
+
return /* @__PURE__ */ jsx("line", { x1: p.x, x2: p.x, y1: p.lifeline.y1, y2: p.lifeline.y2, stroke: hot && subject?.kind === "entity" ? "var(--poney-accent)" : "var(--poney-ink-4)", strokeOpacity: hot ? 0.8 : 1, strokeWidth: hot && subject?.kind === "entity" ? 1.6 : 1, strokeDasharray: "4 5", className: focus && !hot ? "poney-dim" : "" }, `l-${p.entityId}`);
|
|
1418
|
+
}),
|
|
1419
|
+
scene.activations.map((a, i) => {
|
|
1420
|
+
const s = idx.style(a.entityId);
|
|
1421
|
+
return /* @__PURE__ */ jsx("rect", { x: a.x, y: a.y1, width: 10, height: a.y2 - a.y1, rx: 2, fill: toneWash(s.tone, 18), stroke: toneColor(s.tone), strokeWidth: 1, className: focus && !focus.people.has(a.entityId) ? "poney-dim" : "" }, i);
|
|
1422
|
+
}),
|
|
1423
|
+
scene.messages.map((m) => {
|
|
1424
|
+
const hot = focus?.msgs.has(m.id);
|
|
1425
|
+
const selected = selectedMsg === m.id;
|
|
1426
|
+
const color = selected || hot && subject?.kind !== "entity" ? "var(--poney-accent)" : hot ? "var(--poney-ink)" : "var(--poney-ink-2)";
|
|
1427
|
+
const dash = m.kind === "return" ? "5 4" : void 0;
|
|
1428
|
+
const head = m.kind === "call" ? "arrow" : "open-arrow";
|
|
1429
|
+
const textW = measure(m.label, 12.5, 500);
|
|
1430
|
+
const badge = (x, y) => /* @__PURE__ */ jsxs("g", { children: [
|
|
1431
|
+
/* @__PURE__ */ jsx("circle", { cx: x, cy: y, r: 9, fill: selected ? "var(--poney-accent)" : "var(--poney-paper-raised)", stroke: selected ? "var(--poney-accent)" : "var(--poney-rule-strong)" }),
|
|
1432
|
+
/* @__PURE__ */ jsx("text", { x, y: y + 3.5, textAnchor: "middle", fontSize: 10, fontWeight: 650, fill: selected ? "var(--poney-paper)" : "var(--poney-ink-2)", className: "poney-numbers", children: m.number })
|
|
1433
|
+
] });
|
|
1434
|
+
const label = `Step ${m.number}: ${idx.entities.get(m.from)?.name} to ${idx.entities.get(m.to)?.name}, ${m.label}`;
|
|
1435
|
+
if (m.loop) {
|
|
1436
|
+
const { x, y1, y2, w } = m.loop;
|
|
1437
|
+
return /* @__PURE__ */ jsxs("g", { ...bind({ kind: "message", behavior, id: m.id }, label), className: `poney-el ${focus && !hot ? "poney-dim" : ""}`, children: [
|
|
1438
|
+
/* @__PURE__ */ jsx("rect", { x: x - 4, y: y1 - 16, width: w + textW + 60, height: y2 - y1 + 24, fill: "transparent" }),
|
|
1439
|
+
/* @__PURE__ */ jsx("path", { d: `M ${x} ${y1} H ${x + w} V ${y2} H ${x + 6}`, fill: "none", stroke: color, strokeWidth: selected ? 1.8 : 1.3, strokeLinejoin: "round" }),
|
|
1440
|
+
/* @__PURE__ */ jsx(ArrowHead, { at: { x: x + 2, y: y2 }, angle: Math.PI, kind: "arrow", color }),
|
|
1441
|
+
badge(x + w + 18, (y1 + y2) / 2),
|
|
1442
|
+
/* @__PURE__ */ jsx("text", { x: x + w + 32, y: (y1 + y2) / 2 + 4.5, fontSize: 12.5, fontWeight: selected ? 650 : 500, fill: selected ? "var(--poney-accent)" : "var(--poney-ink)", children: m.label }),
|
|
1443
|
+
selected && /* @__PURE__ */ jsx("rect", { x: x - 6, y: y1 - 14, width: w + textW + 64, height: y2 - y1 + 22, rx: 8, fill: "var(--poney-accent-wash)" })
|
|
1444
|
+
] }, m.id);
|
|
1445
|
+
}
|
|
1446
|
+
const right = m.x2 > m.x1;
|
|
1447
|
+
const mid = (m.x1 + m.x2) / 2;
|
|
1448
|
+
const total = textW + 26;
|
|
1449
|
+
return /* @__PURE__ */ jsxs("g", { ...bind({ kind: "message", behavior, id: m.id }, label), className: `poney-el ${focus && !hot ? "poney-dim" : ""}`, children: [
|
|
1450
|
+
/* @__PURE__ */ jsx("rect", { x: Math.min(m.x1, m.x2), y: m.y - 22, width: Math.abs(m.x2 - m.x1), height: 30, fill: selected ? "var(--poney-accent-wash)" : "transparent", rx: 6 }),
|
|
1451
|
+
/* @__PURE__ */ jsx("line", { x1: m.x1, x2: m.x2 + (right ? -6 : 6), y1: m.y, y2: m.y, stroke: color, strokeWidth: selected ? 1.8 : 1.3, strokeDasharray: dash }),
|
|
1452
|
+
/* @__PURE__ */ jsx(ArrowHead, { at: { x: m.x2, y: m.y }, angle: right ? 0 : Math.PI, kind: head, color }),
|
|
1453
|
+
badge(mid - total / 2 + 9, m.y - 12),
|
|
1454
|
+
/* @__PURE__ */ jsx("text", { x: mid - total / 2 + 24, y: m.y - 7.5, fontSize: 12.5, fontWeight: selected ? 650 : 500, fill: selected ? "var(--poney-accent)" : m.kind === "return" ? "var(--poney-ink-2)" : "var(--poney-ink)", children: m.label })
|
|
1455
|
+
] }, m.id);
|
|
1456
|
+
}),
|
|
1457
|
+
[...scene.fragments].sort((a, b) => a.depth - b.depth).map((f) => {
|
|
1458
|
+
const name = fragmentLabel(f.kind);
|
|
1459
|
+
const tabW = measure(name, 11.5, 650) + 20;
|
|
1460
|
+
const first = f.branches[0]?.guard;
|
|
1461
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1462
|
+
/* @__PURE__ */ jsxs("g", { ...bind({ kind: "fragment", behavior, id: f.id }, `${name}: ${f.branches.map((b) => b.guard).join(", or ")}`), children: [
|
|
1463
|
+
/* @__PURE__ */ jsx("path", { d: `M ${f.x} ${f.y + 24} V ${f.y + 10} Q ${f.x} ${f.y} ${f.x + 10} ${f.y} H ${f.x + tabW} V ${f.y + 16} L ${f.x + tabW - 8} ${f.y + 24} Z`, fill: selectedFrag === f.id ? "var(--poney-accent)" : "var(--poney-ink-2)" }),
|
|
1464
|
+
/* @__PURE__ */ jsx("text", { x: f.x + 10, y: f.y + 16, fontSize: 11.5, fontWeight: 650, fill: "var(--poney-paper)", children: name }),
|
|
1465
|
+
/* @__PURE__ */ jsx("rect", { x: f.x + tabW + 4, y: f.y + 3, width: measure(f.kind === "loop" || f.kind === "opt" ? first : `If ${first}`, 12, 500) + 12, height: 18, rx: 4, fill: "var(--poney-plaster)" }),
|
|
1466
|
+
/* @__PURE__ */ jsx("text", { x: f.x + tabW + 10, y: f.y + 16, fontSize: 12, fontWeight: 500, fill: "var(--poney-ink-2)", children: f.kind === "loop" || f.kind === "opt" ? first : `If ${first}` })
|
|
1467
|
+
] }),
|
|
1468
|
+
f.branches.slice(1).map((b, i) => /* @__PURE__ */ jsxs("g", { children: [
|
|
1469
|
+
/* @__PURE__ */ jsx("line", { x1: f.x, x2: f.x + f.w, y1: b.y, y2: b.y, stroke: "var(--poney-rule-strong)", strokeDasharray: "5 4" }),
|
|
1470
|
+
/* @__PURE__ */ jsx("rect", { x: f.x + 6, y: b.y + 4, width: measure(f.kind === "par" ? `And ${b.guard}` : `Else, if ${b.guard}`, 12, 500) + 12, height: 18, rx: 4, fill: "var(--poney-plaster)" }),
|
|
1471
|
+
/* @__PURE__ */ jsx("text", { x: f.x + 12, y: b.y + 17, fontSize: 12, fontWeight: 500, fill: "var(--poney-ink-2)", children: f.kind === "par" ? `And ${b.guard}` : `Else, if ${b.guard}` })
|
|
1472
|
+
] }, i))
|
|
1473
|
+
] }, f.id);
|
|
1474
|
+
}),
|
|
1475
|
+
scene.participants.map((p) => {
|
|
1476
|
+
const e = idx.entities.get(p.entityId);
|
|
1477
|
+
const s = idx.style(e);
|
|
1478
|
+
const hot = focus?.people.has(p.entityId);
|
|
1479
|
+
const { x, y, w, h } = p.header;
|
|
1480
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x} ${y})`, ...bind({ kind: "entity", id: e.id }, `${e.name}, ${s.label}`), className: `poney-el ${focus && !hot ? "poney-dim" : ""}`, children: [
|
|
1481
|
+
/* @__PURE__ */ jsx("rect", { className: "poney-body", width: w, height: h, rx: 12, fill: "var(--poney-paper-raised)", stroke: hot ? toneColor(s.tone) : "var(--poney-rule-strong)", strokeDasharray: e.kind === "external" ? "6 4" : void 0 }),
|
|
1482
|
+
/* @__PURE__ */ jsx("rect", { x: 12, y: (h - 32) / 2, width: 32, height: 32, rx: 9, fill: toneWash(s.tone, 14) }),
|
|
1483
|
+
/* @__PURE__ */ jsx(Glyph, { name: s.icon, x: 19.5, y: (h - 32) / 2 + 7.5, size: 17, color: toneColor(s.tone) }),
|
|
1484
|
+
/* @__PURE__ */ jsx("text", { x: 54, y: h / 2 - 2, fontSize: 14, fontWeight: 650, fill: "var(--poney-ink)", children: clip(e.name, w - 64, 14, 650) }),
|
|
1485
|
+
/* @__PURE__ */ jsx("text", { x: 54, y: h / 2 + 14, fontSize: 11.5, fill: "var(--poney-ink-3)", children: clip(e.technology ?? s.label, w - 64, 11.5) }),
|
|
1486
|
+
/* @__PURE__ */ jsx(Rings, { w, h, selected: selectedEntity === e.id })
|
|
1487
|
+
] }, p.entityId);
|
|
1488
|
+
})
|
|
1489
|
+
] });
|
|
1490
|
+
}
|
|
1491
|
+
function Legend2() {
|
|
1492
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend", children: [
|
|
1493
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "solid", label: "Request: the sender waits", color: "var(--poney-ink-2)" }),
|
|
1494
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "dashed", label: "Answer to a request", color: "var(--poney-ink-2)" }),
|
|
1495
|
+
/* @__PURE__ */ jsxs("div", { className: "poney-legend-row", children: [
|
|
1496
|
+
/* @__PURE__ */ jsx("svg", { width: "22", height: "16", "aria-hidden": true, children: /* @__PURE__ */ jsx("rect", { x: "7", y: "1", width: "8", height: "14", rx: "2", fill: "var(--poney-sunken)", stroke: "var(--poney-lapis)" }) }),
|
|
1497
|
+
"Busy: handling a request"
|
|
1498
|
+
] }),
|
|
1499
|
+
/* @__PURE__ */ jsxs("div", { className: "poney-legend-row", children: [
|
|
1500
|
+
/* @__PURE__ */ jsxs("svg", { width: "22", height: "16", "aria-hidden": true, children: [
|
|
1501
|
+
/* @__PURE__ */ jsx("rect", { x: "1", y: "2", width: "20", height: "12", rx: "3", fill: "none", stroke: "var(--poney-rule-strong)" }),
|
|
1502
|
+
/* @__PURE__ */ jsx("rect", { x: "1", y: "2", width: "9", height: "5", rx: "1.5", fill: "var(--poney-ink-2)" })
|
|
1503
|
+
] }),
|
|
1504
|
+
"Condition, loop or parallel paths"
|
|
1505
|
+
] })
|
|
1506
|
+
] });
|
|
1507
|
+
}
|
|
1508
|
+
var sequence = {
|
|
1509
|
+
key: "sequence",
|
|
1510
|
+
label: "Sequence",
|
|
1511
|
+
icon: ListOrdered,
|
|
1512
|
+
howToRead: "Time runs down the page. Each column is a participant; arrows are the messages between them, numbered in order. Boxes mark steps that happen only under a condition, repeat, or run in parallel.",
|
|
1513
|
+
Renderer: Renderer2,
|
|
1514
|
+
Legend: Legend2,
|
|
1515
|
+
initialView: "start"
|
|
1516
|
+
};
|
|
1517
|
+
function Renderer3({ scene }) {
|
|
1518
|
+
const idx = useRenderIndex();
|
|
1519
|
+
const bind = useRenderBind();
|
|
1520
|
+
const { subject, selection } = useRenderSubject();
|
|
1521
|
+
const focus = useMemo(() => {
|
|
1522
|
+
if (!subject) return null;
|
|
1523
|
+
const nodes = /* @__PURE__ */ new Set();
|
|
1524
|
+
const edges = /* @__PURE__ */ new Set();
|
|
1525
|
+
const take = (e) => {
|
|
1526
|
+
edges.add(e.id);
|
|
1527
|
+
nodes.add(e.source);
|
|
1528
|
+
nodes.add(e.target);
|
|
1529
|
+
};
|
|
1530
|
+
if (subject.kind === "entity") {
|
|
1531
|
+
if (!scene.nodes.some((n) => n.entityId === subject.id)) return null;
|
|
1532
|
+
nodes.add(subject.id);
|
|
1533
|
+
scene.edges.forEach((e) => (e.source === subject.id || e.target === subject.id) && take(e));
|
|
1534
|
+
} else if (subject.kind === "dataFlow" || subject.kind === "relationship") {
|
|
1535
|
+
scene.edges.forEach((e) => (e.id === subject.id || idx.dataFlows.get(e.id)?.via === subject.id) && take(e));
|
|
1536
|
+
} else if (subject.kind === "dataType") scene.edges.forEach((e) => e.data.includes(subject.id) && take(e));
|
|
1537
|
+
else return null;
|
|
1538
|
+
return edges.size || nodes.size ? { nodes, edges } : null;
|
|
1539
|
+
}, [subject, scene, idx]);
|
|
1540
|
+
const selectedEdge = selection?.kind === "dataFlow" || selection?.kind === "relationship" ? selection.id : void 0;
|
|
1541
|
+
const selectedNode = selection?.kind === "entity" ? selection.id : void 0;
|
|
1542
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1543
|
+
scene.edges.map((e) => {
|
|
1544
|
+
const hot = focus?.edges.has(e.id);
|
|
1545
|
+
const selected = selectedEdge === e.id;
|
|
1546
|
+
const ref = e.control ? { kind: "relationship", id: e.id } : { kind: "dataFlow", id: e.id };
|
|
1547
|
+
const color = selected || hot ? "var(--poney-accent)" : e.control ? "var(--poney-ink-4)" : "var(--poney-ink-2)";
|
|
1548
|
+
return /* @__PURE__ */ jsx("g", { ...bind(ref, idx.describe(ref).title), className: `poney-el ${focus && !hot ? "poney-dim" : ""}`, children: /* @__PURE__ */ jsx(EdgeLine, { points: e.points, style: { color, width: e.control ? 1 : selected || hot ? 2 : 1.6, dash: e.control ? "1.5 4" : void 0, head: e.control ? "open-arrow" : "arrow", flowing: !e.control && (selected || hot) } }) }, e.id);
|
|
1549
|
+
}),
|
|
1550
|
+
scene.nodes.map((n) => {
|
|
1551
|
+
const e = idx.entities.get(n.entityId);
|
|
1552
|
+
const s = idx.style(e);
|
|
1553
|
+
const tone = toneColor(s.tone);
|
|
1554
|
+
const dim = focus && !focus.nodes.has(n.entityId);
|
|
1555
|
+
const { w, h } = n;
|
|
1556
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${n.x} ${n.y})`, ...bind({ kind: "entity", id: e.id }, `${e.name}, ${n.role}`), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
|
|
1557
|
+
n.role === "process" && /* @__PURE__ */ jsx("rect", { className: "poney-body", width: w, height: h, rx: h / 2, fill: "var(--poney-paper-raised)", stroke: tone, strokeWidth: 1.3 }),
|
|
1558
|
+
n.role === "terminator" && /* @__PURE__ */ jsx("rect", { className: "poney-body", width: w, height: h, rx: 4, fill: toneWash(s.tone, 10), stroke: tone, strokeWidth: 1.3 }),
|
|
1559
|
+
n.role === "store" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1560
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, fill: toneWash(s.tone, 10) }),
|
|
1561
|
+
/* @__PURE__ */ jsx("line", { x1: 0, x2: w, y1: 0.5, y2: 0.5, stroke: tone, strokeWidth: 1.5 }),
|
|
1562
|
+
/* @__PURE__ */ jsx("line", { x1: 0, x2: w, y1: h - 0.5, y2: h - 0.5, stroke: tone, strokeWidth: 1.5 }),
|
|
1563
|
+
/* @__PURE__ */ jsx("line", { x1: 34, x2: 34, y1: 0, y2: h, stroke: tone, strokeWidth: 1 })
|
|
1564
|
+
] }),
|
|
1565
|
+
/* @__PURE__ */ jsx(Glyph, { name: s.icon, x: n.role === "store" ? 9 : n.role === "process" ? 20 : 14, y: h / 2 - 8, size: 16, color: tone }),
|
|
1566
|
+
/* @__PURE__ */ jsx("text", { x: n.role === "store" ? 46 : n.role === "process" ? 44 : 38, y: h / 2 + (n.role === "store" ? 4.5 : -1), fontSize: 13.5, fontWeight: 650, fill: "var(--poney-ink)", children: clip(e.name, w - 60, 13.5, 650) }),
|
|
1567
|
+
n.role !== "store" && /* @__PURE__ */ jsx("text", { x: n.role === "process" ? 44 : 38, y: h / 2 + 15, fontSize: 11.5, fill: "var(--poney-ink-3)", children: n.role === "process" ? "Process" : s.label }),
|
|
1568
|
+
/* @__PURE__ */ jsx(Rings, { w, h, rx: n.role === "process" ? h / 2 : 4, selected: selectedNode === e.id })
|
|
1569
|
+
] }, n.id);
|
|
1570
|
+
}),
|
|
1571
|
+
scene.edges.map((e) => {
|
|
1572
|
+
if (!e.label) return null;
|
|
1573
|
+
const hot = focus?.edges.has(e.id) || selectedEdge === e.id;
|
|
1574
|
+
const { x, y, w, h } = e.label;
|
|
1575
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x} ${y})`, className: focus && !hot ? "poney-dim" : "", pointerEvents: "none", children: [
|
|
1576
|
+
/* @__PURE__ */ jsx("rect", { width: w, height: h, rx: h / 2, fill: "var(--poney-paper-raised)", stroke: hot ? "var(--poney-accent)" : "var(--poney-rule-strong)" }),
|
|
1577
|
+
/* @__PURE__ */ jsx("circle", { cx: 11, cy: h / 2, r: 3, fill: hot ? "var(--poney-accent)" : "var(--poney-malachite)" }),
|
|
1578
|
+
/* @__PURE__ */ jsx("text", { x: 19, y: h / 2 + 4, fontSize: 11.5, fontWeight: hot ? 650 : 500, fill: hot ? "var(--poney-accent)" : "var(--poney-ink-2)", children: e.label.text })
|
|
1579
|
+
] }, `l-${e.id}`);
|
|
1580
|
+
})
|
|
1581
|
+
] });
|
|
1582
|
+
}
|
|
1583
|
+
function Legend3() {
|
|
1584
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend", children: [
|
|
1585
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "card", tone: "umber", label: "Outside the system: people and providers" }),
|
|
1586
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "pill", tone: "lapis", label: "Process: code that changes data" }),
|
|
1587
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "store", tone: "malachite", label: "Store: where data rests" }),
|
|
1588
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "solid", label: "Data moving, with what it carries", color: "var(--poney-ink-2)" }),
|
|
1589
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "dotted", label: "Control only: a call with no data shown", color: "var(--poney-ink-4)" })
|
|
1590
|
+
] });
|
|
1591
|
+
}
|
|
1592
|
+
var dataflow = {
|
|
1593
|
+
key: "dataflow",
|
|
1594
|
+
label: "Data flow",
|
|
1595
|
+
icon: Waypoints,
|
|
1596
|
+
howToRead: "Arrows follow the data, not the calls: each one says what moves and in which direction. Select a flow to see its fields.",
|
|
1597
|
+
Renderer: Renderer3,
|
|
1598
|
+
Legend: Legend3
|
|
1599
|
+
};
|
|
1600
|
+
function Renderer4({ scene }) {
|
|
1601
|
+
const idx = useRenderIndex();
|
|
1602
|
+
const bind = useRenderBind();
|
|
1603
|
+
const { subject, selection } = useRenderSubject();
|
|
1604
|
+
const behavior = scene.processId;
|
|
1605
|
+
const focus = useMemo(() => {
|
|
1606
|
+
if (!subject) return null;
|
|
1607
|
+
const nodes = /* @__PURE__ */ new Set();
|
|
1608
|
+
const edges = /* @__PURE__ */ new Set();
|
|
1609
|
+
if (subject.kind === "activityNode" && subject.behavior === behavior) {
|
|
1610
|
+
nodes.add(subject.id);
|
|
1611
|
+
scene.edges.forEach((e) => {
|
|
1612
|
+
if (e.from === subject.id || e.to === subject.id) {
|
|
1613
|
+
edges.add(e.id);
|
|
1614
|
+
nodes.add(e.from);
|
|
1615
|
+
nodes.add(e.to);
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
} else if (subject.kind === "activityFlow" && subject.behavior === behavior) {
|
|
1619
|
+
const e = scene.edges.find((x) => x.id === subject.id);
|
|
1620
|
+
if (!e) return null;
|
|
1621
|
+
edges.add(e.id);
|
|
1622
|
+
nodes.add(e.from);
|
|
1623
|
+
nodes.add(e.to);
|
|
1624
|
+
} else if (subject.kind === "entity") {
|
|
1625
|
+
const lane = scene.lanes.findIndex((l) => l.entityId === subject.id);
|
|
1626
|
+
if (lane < 0) return null;
|
|
1627
|
+
scene.nodes.forEach((n) => n.lane === lane && nodes.add(n.id));
|
|
1628
|
+
scene.edges.forEach((e) => nodes.has(e.from) && nodes.has(e.to) && edges.add(e.id));
|
|
1629
|
+
} else return null;
|
|
1630
|
+
return { nodes, edges };
|
|
1631
|
+
}, [subject, scene, behavior]);
|
|
1632
|
+
const sel = (kind, id) => selection?.kind === kind && selection.behavior === behavior && selection.id === id;
|
|
1633
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1634
|
+
scene.lanes.map((l, i) => {
|
|
1635
|
+
const e = l.entityId ? idx.entities.get(l.entityId) : void 0;
|
|
1636
|
+
const s = e ? idx.style(e) : void 0;
|
|
1637
|
+
const laneHot = subject?.kind === "entity" && subject.id === l.entityId;
|
|
1638
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1639
|
+
/* @__PURE__ */ jsx("rect", { x: l.x, y: 0, width: l.w, height: scene.height, fill: i % 2 ? "var(--poney-paper)" : "transparent", fillOpacity: 0.45 }),
|
|
1640
|
+
i > 0 && /* @__PURE__ */ jsx("line", { x1: l.x, x2: l.x, y1: 0, y2: scene.height, stroke: "var(--poney-rule)" }),
|
|
1641
|
+
/* @__PURE__ */ jsxs("g", { ...e ? bind({ kind: "entity", id: e.id }, `Lane: ${e.name}`) : {}, children: [
|
|
1642
|
+
/* @__PURE__ */ jsx("rect", { x: l.x + 8, y: 8, width: l.w - 16, height: scene.laneHeader - 16, rx: 8, fill: laneHot ? "var(--poney-accent-wash)" : "var(--poney-paper-raised)", stroke: laneHot ? "var(--poney-accent)" : "var(--poney-rule)" }),
|
|
1643
|
+
s && /* @__PURE__ */ jsx(Glyph, { name: s.icon, x: l.x + l.w / 2 - measure(l.label, 13, 650) / 2 - 12, y: scene.laneHeader / 2 - 7, size: 14, color: toneColor(s.tone) }),
|
|
1644
|
+
/* @__PURE__ */ jsx("text", { x: l.x + l.w / 2 + (s ? 9 : 0), y: scene.laneHeader / 2 + 4.5, textAnchor: "middle", fontSize: 13, fontWeight: 650, fill: "var(--poney-ink)", children: l.label })
|
|
1645
|
+
] })
|
|
1646
|
+
] }, i);
|
|
1647
|
+
}),
|
|
1648
|
+
scene.edges.map((e) => {
|
|
1649
|
+
const hot = focus?.edges.has(e.id) || sel("activityFlow", e.id);
|
|
1650
|
+
const color = hot ? "var(--poney-accent)" : "var(--poney-ink-3)";
|
|
1651
|
+
return /* @__PURE__ */ jsxs("g", { ...bind({ kind: "activityFlow", behavior, id: e.id }, idx.describe({ kind: "activityFlow", behavior, id: e.id }).title), className: `poney-el ${focus && !hot ? "poney-dim" : ""}`, children: [
|
|
1652
|
+
/* @__PURE__ */ jsx(EdgeLine, { points: e.points, style: { color, width: hot ? 1.9 : 1.3, head: "arrow", dash: e.back ? "6 4" : void 0 } }),
|
|
1653
|
+
e.guard && e.guardAt && /* @__PURE__ */ jsxs("g", { pointerEvents: "none", children: [
|
|
1654
|
+
/* @__PURE__ */ jsx(
|
|
1655
|
+
"rect",
|
|
1656
|
+
{
|
|
1657
|
+
x: e.guardAt.anchor === "end" ? e.guardAt.x - measure(e.guard, 11.5, 650) - 12 : e.guardAt.x - 2,
|
|
1658
|
+
y: e.guardAt.y - 11,
|
|
1659
|
+
width: measure(e.guard, 11.5, 650) + 14,
|
|
1660
|
+
height: 19,
|
|
1661
|
+
rx: 9.5,
|
|
1662
|
+
fill: "var(--poney-plaster)",
|
|
1663
|
+
stroke: hot ? "var(--poney-accent)" : "var(--poney-rule-strong)"
|
|
1664
|
+
}
|
|
1665
|
+
),
|
|
1666
|
+
/* @__PURE__ */ jsx("text", { x: e.guardAt.anchor === "end" ? e.guardAt.x - 5 : e.guardAt.x + 5, y: e.guardAt.y + 2.5, textAnchor: e.guardAt.anchor === "end" ? "end" : "start", fontSize: 11.5, fontWeight: 650, fill: hot ? "var(--poney-accent)" : "var(--poney-ink-2)", children: e.guard })
|
|
1667
|
+
] })
|
|
1668
|
+
] }, e.id);
|
|
1669
|
+
}),
|
|
1670
|
+
scene.nodes.map((n) => {
|
|
1671
|
+
const dim = focus && !focus.nodes.has(n.id);
|
|
1672
|
+
const selected = sel("activityNode", n.id);
|
|
1673
|
+
const ref = { kind: "activityNode", behavior, id: n.id };
|
|
1674
|
+
const label = `${idx.describe(ref).kind}: ${n.label}`;
|
|
1675
|
+
const { x, y, w, h } = n;
|
|
1676
|
+
const outcome = n.outcome === "failure" ? "var(--poney-failure)" : n.outcome === "success" ? "var(--poney-success)" : "var(--poney-ink)";
|
|
1677
|
+
let body;
|
|
1678
|
+
switch (n.kind) {
|
|
1679
|
+
case "start":
|
|
1680
|
+
body = /* @__PURE__ */ jsx("circle", { cx: w / 2, cy: h / 2, r: w / 2, fill: "var(--poney-ink)" });
|
|
1681
|
+
break;
|
|
1682
|
+
case "end":
|
|
1683
|
+
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1684
|
+
/* @__PURE__ */ jsx("circle", { cx: w / 2, cy: h / 2, r: w / 2, fill: "var(--poney-paper-raised)", stroke: outcome, strokeWidth: 1.6 }),
|
|
1685
|
+
/* @__PURE__ */ jsx("circle", { cx: w / 2, cy: h / 2, r: w / 2 - 5.5, fill: outcome }),
|
|
1686
|
+
/* @__PURE__ */ jsx("text", { x: w / 2, y: h + 17, textAnchor: "middle", fontSize: 12.5, fontWeight: 650, fill: outcome, children: n.label })
|
|
1687
|
+
] });
|
|
1688
|
+
break;
|
|
1689
|
+
case "fork":
|
|
1690
|
+
case "join":
|
|
1691
|
+
body = /* @__PURE__ */ jsx("rect", { width: w, height: h, rx: 3, fill: "var(--poney-ink)" });
|
|
1692
|
+
break;
|
|
1693
|
+
case "decision":
|
|
1694
|
+
case "merge":
|
|
1695
|
+
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1696
|
+
/* @__PURE__ */ jsx("path", { className: "poney-body", d: `M ${w / 2} 0 L ${w} ${h / 2} L ${w / 2} ${h} L 0 ${h / 2} Z`, fill: "var(--poney-paper-raised)", stroke: "var(--poney-ochre)", strokeWidth: 1.4, strokeLinejoin: "round" }),
|
|
1697
|
+
/* @__PURE__ */ jsx("text", { x: w / 2, y: h / 2 + 4.5, textAnchor: "middle", fontSize: 12.5, fontWeight: 650, fill: "var(--poney-ink)", children: n.label })
|
|
1698
|
+
] });
|
|
1699
|
+
break;
|
|
1700
|
+
default:
|
|
1701
|
+
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1702
|
+
/* @__PURE__ */ jsx("rect", { className: "poney-body", width: w, height: h, rx: 10, fill: "var(--poney-paper-raised)", stroke: "var(--poney-rule-strong)", strokeWidth: 1.1 }),
|
|
1703
|
+
n.lines.map((line, i) => /* @__PURE__ */ jsx("text", { x: w / 2, y: h / 2 + 4.5 + (i - (n.lines.length - 1) / 2) * 16, textAnchor: "middle", fontSize: 13, fontWeight: 500, fill: "var(--poney-ink)", children: line }, i))
|
|
1704
|
+
] });
|
|
1705
|
+
}
|
|
1706
|
+
const pad = n.kind === "fork" || n.kind === "join" ? 6 : 0;
|
|
1707
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x} ${y})`, ...bind(ref, label), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
|
|
1708
|
+
pad > 0 && /* @__PURE__ */ jsx("rect", { x: 0, y: -pad, width: w, height: h + pad * 2, fill: "transparent" }),
|
|
1709
|
+
body,
|
|
1710
|
+
/* @__PURE__ */ jsx(Rings, { w, h, rx: n.kind === "start" || n.kind === "end" ? w / 2 : 10, selected })
|
|
1711
|
+
] }, n.id);
|
|
1712
|
+
})
|
|
1713
|
+
] });
|
|
1714
|
+
}
|
|
1715
|
+
function Legend4() {
|
|
1716
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend", children: [
|
|
1717
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "dot", tone: "ink", label: "Start" }),
|
|
1718
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "card", tone: "slate", label: "Action" }),
|
|
1719
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "diamond", tone: "ochre", label: "Decision: one way out per answer" }),
|
|
1720
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "bar", tone: "ink", label: "Split into, or join, parallel paths" }),
|
|
1721
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "bullseye", tone: "success", label: "End, in success" }),
|
|
1722
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "bullseye", tone: "failure", label: "End, in failure" })
|
|
1723
|
+
] });
|
|
1724
|
+
}
|
|
1725
|
+
var activity = {
|
|
1726
|
+
key: "activity",
|
|
1727
|
+
label: "Activity",
|
|
1728
|
+
icon: GitBranch,
|
|
1729
|
+
howToRead: "Follow the arrows from the black dot. Each column is who does the step. Diamonds ask a question; dashed arrows go back to an earlier step.",
|
|
1730
|
+
Renderer: Renderer4,
|
|
1731
|
+
Legend: Legend4
|
|
1732
|
+
};
|
|
1733
|
+
function Cardinal({ p, d, card, color }) {
|
|
1734
|
+
const perp = { x: -d.y, y: d.x };
|
|
1735
|
+
const at = (back, side = 0) => ({ x: p.x - d.x * back + perp.x * side, y: p.y - d.y * back + perp.y * side });
|
|
1736
|
+
const bar = (back) => {
|
|
1737
|
+
const a = at(back, 6);
|
|
1738
|
+
const b = at(back, -6);
|
|
1739
|
+
return /* @__PURE__ */ jsx("line", { x1: a.x, y1: a.y, x2: b.x, y2: b.y, stroke: color, strokeWidth: 1.4 });
|
|
1740
|
+
};
|
|
1741
|
+
const circle = (back) => {
|
|
1742
|
+
const c = at(back);
|
|
1743
|
+
return /* @__PURE__ */ jsx("circle", { cx: c.x, cy: c.y, r: 4, fill: "var(--poney-paper-raised)", stroke: color, strokeWidth: 1.3 });
|
|
1744
|
+
};
|
|
1745
|
+
const crow = () => {
|
|
1746
|
+
const root = at(13);
|
|
1747
|
+
return /* @__PURE__ */ jsx(Fragment, { children: [-6.5, 0, 6.5].map((s) => {
|
|
1748
|
+
const tip = at(0, s);
|
|
1749
|
+
return /* @__PURE__ */ jsx("line", { x1: root.x, y1: root.y, x2: tip.x, y2: tip.y, stroke: color, strokeWidth: 1.3 }, s);
|
|
1750
|
+
}) });
|
|
1751
|
+
};
|
|
1752
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1753
|
+
card === "one" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1754
|
+
bar(6),
|
|
1755
|
+
bar(11)
|
|
1756
|
+
] }),
|
|
1757
|
+
card === "zero-or-one" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1758
|
+
bar(6),
|
|
1759
|
+
circle(15)
|
|
1760
|
+
] }),
|
|
1761
|
+
card === "many" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1762
|
+
crow(),
|
|
1763
|
+
circle(18)
|
|
1764
|
+
] }),
|
|
1765
|
+
card === "one-or-many" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1766
|
+
crow(),
|
|
1767
|
+
bar(17)
|
|
1768
|
+
] })
|
|
1769
|
+
] });
|
|
1770
|
+
}
|
|
1771
|
+
var unit = (a, b) => {
|
|
1772
|
+
const len = Math.hypot(b.x - a.x, b.y - a.y) || 1;
|
|
1773
|
+
return { x: (b.x - a.x) / len, y: (b.y - a.y) / len };
|
|
1774
|
+
};
|
|
1775
|
+
function Renderer5({ scene, view }) {
|
|
1776
|
+
const idx = useRenderIndex();
|
|
1777
|
+
const bind = useRenderBind();
|
|
1778
|
+
const { subject, selection } = useRenderSubject();
|
|
1779
|
+
const [ui, update] = useViewState(view.id);
|
|
1780
|
+
const expanded = ui.expandedTables ?? [];
|
|
1781
|
+
const focus = useMemo(() => {
|
|
1782
|
+
if (!subject) return null;
|
|
1783
|
+
const tables = /* @__PURE__ */ new Set();
|
|
1784
|
+
const rels = /* @__PURE__ */ new Set();
|
|
1785
|
+
const rows = /* @__PURE__ */ new Set();
|
|
1786
|
+
if (subject.kind === "dataType") {
|
|
1787
|
+
if (!scene.tables.some((t) => t.dataTypeId === subject.id)) return null;
|
|
1788
|
+
tables.add(subject.id);
|
|
1789
|
+
for (const r of scene.relations) {
|
|
1790
|
+
if (r.from !== subject.id && r.to !== subject.id) continue;
|
|
1791
|
+
if (subject.field) {
|
|
1792
|
+
const t = scene.tables.find((x) => x.dataTypeId === subject.id);
|
|
1793
|
+
const field = t.rows.find((f) => f.name === subject.field);
|
|
1794
|
+
const linked = r.via === subject.field || field?.primaryKey && r.from === subject.id;
|
|
1795
|
+
if (!linked) continue;
|
|
1796
|
+
rows.add(`${r.from}#${r.from === subject.id ? subject.field : r.via}`);
|
|
1797
|
+
rows.add(`${r.to}#${r.to === subject.id ? subject.field : r.via}`);
|
|
1798
|
+
}
|
|
1799
|
+
rels.add(r.id);
|
|
1800
|
+
tables.add(r.from);
|
|
1801
|
+
tables.add(r.to);
|
|
1802
|
+
}
|
|
1803
|
+
if (subject.field) rows.add(`${subject.id}#${subject.field}`);
|
|
1804
|
+
} else if (subject.kind === "dataRelation") {
|
|
1805
|
+
const r = scene.relations.find((x) => x.id === subject.id);
|
|
1806
|
+
if (!r) return null;
|
|
1807
|
+
rels.add(r.id);
|
|
1808
|
+
tables.add(r.from);
|
|
1809
|
+
tables.add(r.to);
|
|
1810
|
+
if (r.via) {
|
|
1811
|
+
rows.add(`${r.to}#${r.via}`);
|
|
1812
|
+
rows.add(`${r.from}#${r.via}`);
|
|
1813
|
+
}
|
|
1814
|
+
} else if (subject.kind === "entity") {
|
|
1815
|
+
scene.tables.forEach((t) => t.store === subject.id && tables.add(t.dataTypeId));
|
|
1816
|
+
if (!tables.size) return null;
|
|
1817
|
+
scene.relations.forEach((r) => tables.has(r.from) && tables.has(r.to) && rels.add(r.id));
|
|
1818
|
+
} else return null;
|
|
1819
|
+
return { tables, rels, rows };
|
|
1820
|
+
}, [subject, scene]);
|
|
1821
|
+
const toggle = (id) => update({ expandedTables: expanded.includes(id) ? expanded.filter((x) => x !== id) : [...expanded, id] });
|
|
1822
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1823
|
+
scene.stores.map((s) => {
|
|
1824
|
+
const e = idx.entities.get(s.entityId);
|
|
1825
|
+
const st = idx.style(e);
|
|
1826
|
+
const selected = selection?.kind === "entity" && selection.id === e.id;
|
|
1827
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1828
|
+
/* @__PURE__ */ jsx("rect", { x: s.x, y: s.y, width: s.w, height: s.h, rx: 16, fill: toneWash(st.tone, 5), stroke: "var(--poney-rule-strong)" }),
|
|
1829
|
+
/* @__PURE__ */ jsxs("g", { transform: `translate(${s.x} ${s.y})`, ...bind({ kind: "entity", id: e.id }, `${e.name}, ${e.technology ?? "database"}`), children: [
|
|
1830
|
+
/* @__PURE__ */ jsx("rect", { x: 10, y: 8, width: Math.min(s.w - 20, 320), height: 26, rx: 7, fill: "transparent" }),
|
|
1831
|
+
/* @__PURE__ */ jsx(Glyph, { name: st.icon, x: 18, y: 13, size: 15, color: toneColor(st.tone) }),
|
|
1832
|
+
/* @__PURE__ */ jsx("text", { x: 40, y: 25, fontSize: 12.5, fontWeight: 650, fill: "var(--poney-ink)", children: e.name }),
|
|
1833
|
+
/* @__PURE__ */ jsx("text", { x: 50 + measure(e.name, 12.5, 650), y: 25, fontSize: 11.5, fill: "var(--poney-ink-3)", children: e.technology }),
|
|
1834
|
+
selected && /* @__PURE__ */ jsx("rect", { x: 6, y: 4, width: Math.min(s.w - 12, 330), height: 34, rx: 9, fill: "none", stroke: "var(--poney-accent)", strokeWidth: 1.5 })
|
|
1835
|
+
] })
|
|
1836
|
+
] }, s.entityId);
|
|
1837
|
+
}),
|
|
1838
|
+
scene.relations.map((r) => {
|
|
1839
|
+
const hot = focus?.rels.has(r.id);
|
|
1840
|
+
const selected = selection?.kind === "dataRelation" && selection.id === r.id;
|
|
1841
|
+
const color = hot || selected ? "var(--poney-accent)" : "var(--poney-ink-3)";
|
|
1842
|
+
const pts = r.points;
|
|
1843
|
+
const n = pts.length;
|
|
1844
|
+
return /* @__PURE__ */ jsxs("g", { ...bind({ kind: "dataRelation", id: r.id }, idx.describe({ kind: "dataRelation", id: r.id }).title), className: `poney-el ${focus && !hot ? "poney-dim" : ""}`, children: [
|
|
1845
|
+
/* @__PURE__ */ jsx("path", { d: roundedPath(pts, 8), fill: "none", stroke: "transparent", strokeWidth: 14 }),
|
|
1846
|
+
/* @__PURE__ */ jsx("path", { d: roundedPath(pts, 8), fill: "none", stroke: color, strokeWidth: hot || selected ? 1.8 : 1.2, strokeDasharray: r.logical ? "6 4" : void 0, className: "poney-edge" }),
|
|
1847
|
+
/* @__PURE__ */ jsx(Cardinal, { p: pts[0], d: unit(pts[1], pts[0]), card: r.fromCardinality, color }),
|
|
1848
|
+
/* @__PURE__ */ jsx(Cardinal, { p: pts[n - 1], d: unit(pts[n - 2], pts[n - 1]), card: r.toCardinality, color })
|
|
1849
|
+
] }, r.id);
|
|
1850
|
+
}),
|
|
1851
|
+
scene.tables.map((t) => {
|
|
1852
|
+
const d = idx.dataTypes.get(t.dataTypeId);
|
|
1853
|
+
const dim = focus && !focus.tables.has(t.dataTypeId);
|
|
1854
|
+
const tableSelected = selection?.kind === "dataType" && selection.id === t.dataTypeId && !selection.field;
|
|
1855
|
+
const tone = d.storedIn ? idx.style(d.storedIn).tone : "malachite";
|
|
1856
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${t.x} ${t.y})`, className: `poney-fade ${dim ? "poney-dim" : ""}`, children: [
|
|
1857
|
+
/* @__PURE__ */ jsx("rect", { width: t.w, height: t.h, rx: 10, fill: "var(--poney-paper-raised)", stroke: focus?.tables.has(t.dataTypeId) && subject?.kind === "dataType" && subject.id === t.dataTypeId ? toneColor(tone) : "var(--poney-rule-strong)" }),
|
|
1858
|
+
/* @__PURE__ */ jsxs("g", { ...bind({ kind: "dataType", id: t.dataTypeId }, `Table ${t.name}, ${d.fields.length} fields`), children: [
|
|
1859
|
+
/* @__PURE__ */ jsx("path", { d: `M 0 10 Q 0 0 10 0 H ${t.w - 10} Q ${t.w} 0 ${t.w} 10 V ${ERD.header} H 0 Z`, fill: toneWash(tone, 9) }),
|
|
1860
|
+
/* @__PURE__ */ jsx("line", { x1: 0, x2: t.w, y1: ERD.header, y2: ERD.header, stroke: "var(--poney-rule)" }),
|
|
1861
|
+
/* @__PURE__ */ jsx("g", { transform: "translate(13 12)", color: toneColor(tone), children: /* @__PURE__ */ jsx(Table2, { width: 16, height: 16, strokeWidth: 1.8 }) }),
|
|
1862
|
+
/* @__PURE__ */ jsx("text", { x: 38, y: 25, fontSize: 13.5, fontWeight: 650, fontFamily: "var(--poney-font-mono)", fill: "var(--poney-ink)", children: t.name }),
|
|
1863
|
+
/* @__PURE__ */ jsxs("text", { x: t.w - 12, y: 25, textAnchor: "end", fontSize: 11, fill: "var(--poney-ink-3)", className: "poney-numbers", children: [
|
|
1864
|
+
d.fields.length,
|
|
1865
|
+
" fields"
|
|
1866
|
+
] })
|
|
1867
|
+
] }),
|
|
1868
|
+
t.rows.map((f) => {
|
|
1869
|
+
const ry = f.y - t.y;
|
|
1870
|
+
const hot = focus?.rows.has(`${t.dataTypeId}#${f.name}`);
|
|
1871
|
+
const selected = selection?.kind === "dataType" && selection.id === t.dataTypeId && selection.field === f.name;
|
|
1872
|
+
return /* @__PURE__ */ jsxs("g", { ...bind({ kind: "dataType", id: t.dataTypeId, field: f.name }, `Field ${f.name}, ${f.type}${f.primaryKey ? ", primary key" : ""}${f.foreign ? ", foreign key" : ""}`), children: [
|
|
1873
|
+
/* @__PURE__ */ jsx("rect", { x: 1, y: ry, width: t.w - 2, height: ERD.row, fill: selected ? "var(--poney-accent-wash)" : hot ? toneWash(tone, 10) : "transparent", className: "poney-row" }),
|
|
1874
|
+
f.primaryKey && /* @__PURE__ */ jsx("g", { transform: `translate(13 ${ry + 6})`, color: "var(--poney-ochre)", children: /* @__PURE__ */ jsx(KeyRound, { width: 13, height: 13, strokeWidth: 2 }) }),
|
|
1875
|
+
!f.primaryKey && f.foreign && /* @__PURE__ */ jsx("g", { transform: `translate(13 ${ry + 6})`, color: "var(--poney-lapis)", children: /* @__PURE__ */ jsx(Link2, { width: 13, height: 13, strokeWidth: 2 }) }),
|
|
1876
|
+
/* @__PURE__ */ jsx("text", { x: 38, y: ry + 17, fontSize: 12.5, fontFamily: "var(--poney-font-mono)", fontWeight: f.primaryKey ? 600 : 450, fill: selected ? "var(--poney-accent)" : "var(--poney-ink)", children: f.name }),
|
|
1877
|
+
/* @__PURE__ */ jsxs("text", { x: t.w - 12, y: ry + 17, textAnchor: "end", fontSize: 11.5, fontFamily: "var(--poney-font-mono)", fill: "var(--poney-ink-3)", children: [
|
|
1878
|
+
clip(f.type, t.w / 2 - 20, 11.5, 400, "mono"),
|
|
1879
|
+
f.nullable ? "?" : ""
|
|
1880
|
+
] })
|
|
1881
|
+
] }, f.name);
|
|
1882
|
+
}),
|
|
1883
|
+
(t.hiddenCount > 0 || t.expanded) && /* @__PURE__ */ jsxs(
|
|
1884
|
+
"g",
|
|
1885
|
+
{
|
|
1886
|
+
role: "button",
|
|
1887
|
+
tabIndex: 0,
|
|
1888
|
+
"data-ref": "toggle",
|
|
1889
|
+
"aria-label": t.expanded ? `Show fewer fields of ${t.name}` : `Show ${t.hiddenCount} more fields of ${t.name}`,
|
|
1890
|
+
className: "poney-control",
|
|
1891
|
+
onClick: (e) => {
|
|
1892
|
+
e.stopPropagation();
|
|
1893
|
+
toggle(t.dataTypeId);
|
|
1894
|
+
},
|
|
1895
|
+
onKeyDown: (e) => {
|
|
1896
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1897
|
+
e.preventDefault();
|
|
1898
|
+
toggle(t.dataTypeId);
|
|
1899
|
+
}
|
|
1900
|
+
},
|
|
1901
|
+
children: [
|
|
1902
|
+
/* @__PURE__ */ jsx("rect", { x: 1, y: t.h - ERD.more - ERD.bottom, width: t.w - 2, height: ERD.more, fill: "transparent" }),
|
|
1903
|
+
/* @__PURE__ */ jsx("line", { x1: 0, x2: t.w, y1: t.h - ERD.more - ERD.bottom, y2: t.h - ERD.more - ERD.bottom, stroke: "var(--poney-rule)" }),
|
|
1904
|
+
/* @__PURE__ */ jsx("text", { x: t.w / 2, y: t.h - ERD.bottom - 10, textAnchor: "middle", fontSize: 11.5, fontWeight: 600, fill: "var(--poney-ink-2)", children: t.expanded ? "Show fewer fields" : `Show ${t.hiddenCount} more field${t.hiddenCount === 1 ? "" : "s"}` }),
|
|
1905
|
+
/* @__PURE__ */ jsx("rect", { className: "poney-focus", x: 4, y: t.h - ERD.more - ERD.bottom + 2, width: t.w - 8, height: ERD.more - 4, rx: 6, fill: "none", stroke: "var(--poney-accent)", strokeWidth: 2 })
|
|
1906
|
+
]
|
|
1907
|
+
}
|
|
1908
|
+
),
|
|
1909
|
+
/* @__PURE__ */ jsx(Rings, { w: t.w, h: t.h, rx: 10, selected: tableSelected })
|
|
1910
|
+
] }, t.dataTypeId);
|
|
1911
|
+
})
|
|
1912
|
+
] });
|
|
1913
|
+
}
|
|
1914
|
+
function Legend5() {
|
|
1915
|
+
const row = (card, label) => /* @__PURE__ */ jsxs("div", { className: "poney-legend-row", children: [
|
|
1916
|
+
/* @__PURE__ */ jsxs("svg", { width: "30", height: "16", "aria-hidden": true, children: [
|
|
1917
|
+
/* @__PURE__ */ jsx("line", { x1: "0", y1: "8", x2: "28", y2: "8", stroke: "var(--poney-ink-3)", strokeWidth: "1.2" }),
|
|
1918
|
+
/* @__PURE__ */ jsx(Cardinal, { p: { x: 28, y: 8 }, d: { x: 1, y: 0 }, card, color: "var(--poney-ink-2)" })
|
|
1919
|
+
] }),
|
|
1920
|
+
label
|
|
1921
|
+
] });
|
|
1922
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend", children: [
|
|
1923
|
+
row("one", "Exactly one"),
|
|
1924
|
+
row("zero-or-one", "Zero or one"),
|
|
1925
|
+
row("one-or-many", "One or more"),
|
|
1926
|
+
row("many", "Any number"),
|
|
1927
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "dashed", label: "Across databases, kept by code", head: false }),
|
|
1928
|
+
/* @__PURE__ */ jsxs("div", { className: "poney-legend-row", children: [
|
|
1929
|
+
/* @__PURE__ */ jsx(KeyRound, { size: 13, style: { margin: "0 4px", color: "var(--poney-ochre)" } }),
|
|
1930
|
+
" Primary key",
|
|
1931
|
+
/* @__PURE__ */ jsx(Link2, { size: 13, style: { marginLeft: 8, color: "var(--poney-lapis)" } }),
|
|
1932
|
+
" Reference"
|
|
1933
|
+
] })
|
|
1934
|
+
] });
|
|
1935
|
+
}
|
|
1936
|
+
var erd = {
|
|
1937
|
+
key: "erd",
|
|
1938
|
+
label: "Entity relationships",
|
|
1939
|
+
icon: Table2,
|
|
1940
|
+
howToRead: "Each box is a table; the symbols at the line ends say how many rows can be on each side. Tables show their keys first. Select a field to see what it links to.",
|
|
1941
|
+
Renderer: Renderer5,
|
|
1942
|
+
Legend: Legend5
|
|
1943
|
+
};
|
|
1944
|
+
function Renderer6({ scene }) {
|
|
1945
|
+
const idx = useRenderIndex();
|
|
1946
|
+
const bind = useRenderBind();
|
|
1947
|
+
const { subject, selection } = useRenderSubject();
|
|
1948
|
+
const behavior = scene.machineId;
|
|
1949
|
+
const sm = idx.stateMachine(behavior);
|
|
1950
|
+
const focus = useMemo(() => {
|
|
1951
|
+
if (!subject) return null;
|
|
1952
|
+
const states = /* @__PURE__ */ new Set();
|
|
1953
|
+
const trans = /* @__PURE__ */ new Set();
|
|
1954
|
+
const take = (t) => {
|
|
1955
|
+
if (!t) return;
|
|
1956
|
+
trans.add(t.id);
|
|
1957
|
+
states.add(t.from);
|
|
1958
|
+
states.add(t.to);
|
|
1959
|
+
};
|
|
1960
|
+
if (subject.kind === "state" && subject.behavior === behavior) {
|
|
1961
|
+
states.add(subject.id);
|
|
1962
|
+
scene.transitions.forEach((t) => (t.from === subject.id || t.to === subject.id) && take(t));
|
|
1963
|
+
} else if (subject.kind === "transition" && subject.behavior === behavior) take(scene.transitions.find((t) => t.id === subject.id));
|
|
1964
|
+
else if (subject.kind === "entity") sm.transitions.forEach((t) => t.triggeredBy === subject.id && take(scene.transitions.find((x) => x.id === t.id)));
|
|
1965
|
+
else return null;
|
|
1966
|
+
return trans.size || states.size ? { states, trans } : null;
|
|
1967
|
+
}, [subject, scene, behavior, sm]);
|
|
1968
|
+
const isSel = (kind, id) => selection?.kind === kind && selection.behavior === behavior && selection.id === id;
|
|
1969
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
1970
|
+
scene.transitions.map((t) => {
|
|
1971
|
+
const hot = focus?.trans.has(t.id) || isSel("transition", t.id);
|
|
1972
|
+
const color = hot ? "var(--poney-accent)" : "var(--poney-ink-3)";
|
|
1973
|
+
return /* @__PURE__ */ jsxs("g", { ...bind({ kind: "transition", behavior, id: t.id }, `Transition: ${t.event}${t.guard ? `, when ${t.guard}` : ""}`), className: `poney-el ${focus && !hot ? "poney-dim" : ""}`, children: [
|
|
1974
|
+
/* @__PURE__ */ jsx(EdgeLine, { points: t.points, style: { color, width: hot ? 1.9 : 1.3, head: "arrow" } }),
|
|
1975
|
+
t.label && /* @__PURE__ */ jsxs("g", { transform: `translate(${t.label.x} ${t.label.y})`, children: [
|
|
1976
|
+
/* @__PURE__ */ jsx("rect", { width: t.label.w, height: t.label.h, rx: 7, fill: "var(--poney-paper-raised)", stroke: hot ? "var(--poney-accent)" : "var(--poney-rule-strong)" }),
|
|
1977
|
+
/* @__PURE__ */ jsx("text", { x: t.label.w / 2, y: 15, textAnchor: "middle", fontSize: 11.5, fontWeight: 650, fill: hot ? "var(--poney-accent)" : "var(--poney-ink)", children: t.event }),
|
|
1978
|
+
t.guard && /* @__PURE__ */ jsxs("text", { x: t.label.w / 2, y: 28, textAnchor: "middle", fontSize: 10.5, fill: "var(--poney-ink-3)", children: [
|
|
1979
|
+
"[",
|
|
1980
|
+
t.guard,
|
|
1981
|
+
"]"
|
|
1982
|
+
] })
|
|
1983
|
+
] })
|
|
1984
|
+
] }, t.id);
|
|
1985
|
+
}),
|
|
1986
|
+
scene.states.map((s) => {
|
|
1987
|
+
const dim = focus && !focus.states.has(s.id);
|
|
1988
|
+
const selected = isSel("state", s.id);
|
|
1989
|
+
const ref = { kind: "state", behavior, id: s.id };
|
|
1990
|
+
const stroke = s.outcome === "success" ? "var(--poney-success)" : s.outcome === "failure" ? "var(--poney-failure)" : "var(--poney-rule-strong)";
|
|
1991
|
+
if (s.kind === "initial")
|
|
1992
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${s.x} ${s.y})`, ...bind(ref, "Start"), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
|
|
1993
|
+
/* @__PURE__ */ jsx("circle", { cx: s.w / 2, cy: s.h / 2, r: s.w / 2, fill: "var(--poney-ink)" }),
|
|
1994
|
+
/* @__PURE__ */ jsx(Rings, { w: s.w, h: s.h, rx: s.w / 2, selected })
|
|
1995
|
+
] }, s.id);
|
|
1996
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${s.x} ${s.y})`, ...bind(ref, `State ${s.name}${s.kind === "final" ? ", final" : ""}`), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
|
|
1997
|
+
/* @__PURE__ */ jsx("rect", { className: "poney-body", width: s.w, height: s.h, rx: 16, fill: "var(--poney-paper-raised)", stroke, strokeWidth: s.outcome === "neutral" ? 1.1 : 1.5 }),
|
|
1998
|
+
s.kind === "final" && /* @__PURE__ */ jsx("rect", { x: 4, y: 4, width: s.w - 8, height: s.h - 8, rx: 12, fill: "none", stroke, strokeWidth: 1.1 }),
|
|
1999
|
+
s.outcome !== "neutral" && /* @__PURE__ */ jsx("circle", { cx: 18, cy: s.entryActions.length ? 22 : s.h / 2, r: 4, fill: stroke }),
|
|
2000
|
+
/* @__PURE__ */ jsx("text", { x: s.w / 2, y: s.entryActions.length ? 27 : s.h / 2 + 5, textAnchor: "middle", fontSize: 14, fontWeight: 650, fill: "var(--poney-ink)", children: s.name }),
|
|
2001
|
+
s.entryActions.length > 0 && /* @__PURE__ */ jsxs("text", { x: s.w / 2, y: 46, textAnchor: "middle", fontSize: 11, fill: "var(--poney-ink-3)", children: [
|
|
2002
|
+
"On entry: ",
|
|
2003
|
+
s.entryActions[0],
|
|
2004
|
+
s.entryActions.length > 1 ? ` +${s.entryActions.length - 1}` : ""
|
|
2005
|
+
] }),
|
|
2006
|
+
/* @__PURE__ */ jsx(Rings, { w: s.w, h: s.h, rx: 16, selected })
|
|
2007
|
+
] }, s.id);
|
|
2008
|
+
})
|
|
2009
|
+
] });
|
|
2010
|
+
}
|
|
2011
|
+
function Legend6() {
|
|
2012
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend", children: [
|
|
2013
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "dot", tone: "ink", label: "Where it starts" }),
|
|
2014
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "pill", tone: "slate", label: "A state it can be in" }),
|
|
2015
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "pill", tone: "success", label: "A good outcome" }),
|
|
2016
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "pill", tone: "failure", label: "A failed or stopped outcome" }),
|
|
2017
|
+
/* @__PURE__ */ jsxs("div", { className: "poney-legend-row", children: [
|
|
2018
|
+
/* @__PURE__ */ jsxs("svg", { width: "22", height: "16", "aria-hidden": true, children: [
|
|
2019
|
+
/* @__PURE__ */ jsx("rect", { x: "1", y: "2", width: "20", height: "12", rx: "5", fill: "none", stroke: "var(--poney-ink-3)" }),
|
|
2020
|
+
/* @__PURE__ */ jsx("rect", { x: "3.5", y: "4.5", width: "15", height: "7", rx: "3", fill: "none", stroke: "var(--poney-ink-3)" })
|
|
2021
|
+
] }),
|
|
2022
|
+
"Final: nothing happens after it"
|
|
2023
|
+
] }),
|
|
2024
|
+
/* @__PURE__ */ jsx("p", { className: "poney-legend-note", children: "Labels on arrows are events. Text in brackets is the condition that must be true." })
|
|
2025
|
+
] });
|
|
2026
|
+
}
|
|
2027
|
+
var state = {
|
|
2028
|
+
key: "state",
|
|
2029
|
+
label: "State machine",
|
|
2030
|
+
icon: CircleDot,
|
|
2031
|
+
howToRead: "Each box is a status. Arrows are the events that move it on; select one to see what causes it and what happens next.",
|
|
2032
|
+
Renderer: Renderer6,
|
|
2033
|
+
Legend: Legend6
|
|
2034
|
+
};
|
|
2035
|
+
function Renderer7({ scene }) {
|
|
2036
|
+
const idx = useRenderIndex();
|
|
2037
|
+
const bind = useRenderBind();
|
|
2038
|
+
const zoom = useRenderZoom();
|
|
2039
|
+
const { subject, selection } = useRenderSubject();
|
|
2040
|
+
const focus = useMemo(() => {
|
|
2041
|
+
if (!subject) return null;
|
|
2042
|
+
const actors = /* @__PURE__ */ new Set();
|
|
2043
|
+
const caps = /* @__PURE__ */ new Set();
|
|
2044
|
+
if (subject.kind === "entity" && scene.actors.some((a) => a.entityId === subject.id)) {
|
|
2045
|
+
actors.add(subject.id);
|
|
2046
|
+
scene.associations.forEach((a) => a.actor === subject.id && caps.add(a.capability));
|
|
2047
|
+
} else if (subject.kind === "capability" && scene.capabilities.some((c) => c.id === subject.id)) {
|
|
2048
|
+
caps.add(subject.id);
|
|
2049
|
+
scene.associations.forEach((a) => a.capability === subject.id && actors.add(a.actor));
|
|
2050
|
+
scene.includes.forEach((i) => i.from === subject.id && caps.add(i.to));
|
|
2051
|
+
} else return null;
|
|
2052
|
+
return { actors, caps };
|
|
2053
|
+
}, [subject, scene]);
|
|
2054
|
+
const hotAssoc = (a) => !!focus && focus.caps.has(a.capability) && focus.actors.has(a.actor);
|
|
2055
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
2056
|
+
/* @__PURE__ */ jsx("rect", { x: scene.boundary.x, y: scene.boundary.y, width: scene.boundary.w, height: scene.boundary.h, rx: 22, fill: "var(--poney-paper)", fillOpacity: 0.6, stroke: "var(--poney-rule-strong)" }),
|
|
2057
|
+
/* @__PURE__ */ jsx("text", { x: scene.boundary.x + 20, y: scene.boundary.y + 30, fontSize: 13, fontWeight: 650, fill: "var(--poney-ink-2)", children: scene.boundary.title }),
|
|
2058
|
+
scene.areas.map((a, i) => /* @__PURE__ */ jsxs("g", { children: [
|
|
2059
|
+
i > 0 && /* @__PURE__ */ jsx("line", { x1: a.x, x2: a.x + a.w, y1: a.y - 7, y2: a.y - 7, stroke: "var(--poney-rule)" }),
|
|
2060
|
+
/* @__PURE__ */ jsx("text", { x: a.x + 4, y: a.y + 18, fontSize: 12, fontWeight: 650, fill: "var(--poney-ink-3)", children: a.label })
|
|
2061
|
+
] }, a.label)),
|
|
2062
|
+
scene.associations.map((a) => {
|
|
2063
|
+
const hot = hotAssoc(a);
|
|
2064
|
+
const mx = (a.from.x + a.to.x) / 2;
|
|
2065
|
+
return /* @__PURE__ */ jsx(
|
|
2066
|
+
"path",
|
|
2067
|
+
{
|
|
2068
|
+
d: `M ${a.from.x} ${a.from.y} C ${mx} ${a.from.y} ${mx} ${a.to.y} ${a.to.x} ${a.to.y}`,
|
|
2069
|
+
fill: "none",
|
|
2070
|
+
stroke: hot ? "var(--poney-accent)" : "var(--poney-ink-4)",
|
|
2071
|
+
strokeWidth: hot ? 1.8 : 1.1,
|
|
2072
|
+
strokeDasharray: a.side === "right" ? "5 4" : void 0,
|
|
2073
|
+
className: `poney-edge ${focus && !hot ? "poney-dim" : ""}`
|
|
2074
|
+
},
|
|
2075
|
+
a.id
|
|
2076
|
+
);
|
|
2077
|
+
}),
|
|
2078
|
+
scene.includes.map((i) => {
|
|
2079
|
+
const hot = focus?.caps.has(i.from) && focus.caps.has(i.to);
|
|
2080
|
+
const color = hot ? "var(--poney-accent)" : "var(--poney-ink-3)";
|
|
2081
|
+
const d = `M ${i.a.x} ${i.a.y} C ${i.a.x + 48} ${i.a.y + 6} ${i.b.x + 48} ${i.b.y - 6} ${i.b.x + 4} ${i.b.y - 1}`;
|
|
2082
|
+
return /* @__PURE__ */ jsxs("g", { className: focus && !hot ? "poney-dim" : "", children: [
|
|
2083
|
+
/* @__PURE__ */ jsx("path", { d, fill: "none", stroke: color, strokeDasharray: "4 3", strokeWidth: 1.2 }),
|
|
2084
|
+
/* @__PURE__ */ jsx(ArrowHead, { at: { x: i.b.x + 2, y: i.b.y }, angle: Math.PI * 0.62, kind: "open-arrow", color }),
|
|
2085
|
+
/* @__PURE__ */ jsx("text", { x: i.a.x + 44, y: (i.a.y + i.b.y) / 2 + 4, fontSize: 11, fontStyle: "italic", fill: color, children: "includes" })
|
|
2086
|
+
] }, i.id);
|
|
2087
|
+
}),
|
|
2088
|
+
scene.capabilities.map((c) => {
|
|
2089
|
+
const cap = idx.capabilities.get(c.id);
|
|
2090
|
+
const dim = focus && !focus.caps.has(c.id);
|
|
2091
|
+
const selected = selection?.kind === "capability" && selection.id === c.id;
|
|
2092
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${c.x} ${c.y})`, ...bind({ kind: "capability", id: c.id }, `${cap.name}. ${cap.summary}`), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
|
|
2093
|
+
/* @__PURE__ */ jsx("rect", { className: "poney-body", width: c.w, height: c.h, rx: c.h / 2, fill: "var(--poney-paper-raised)", stroke: focus?.caps.has(c.id) ? "var(--poney-tyrian)" : "var(--poney-rule-strong)", strokeWidth: 1.2 }),
|
|
2094
|
+
/* @__PURE__ */ jsx("text", { x: c.w / 2, y: c.h / 2 + 5, textAnchor: "middle", fontSize: 13.5, fontWeight: 600, fill: "var(--poney-ink)", children: clip(cap.name, c.w - 32, 13.5, 600) }),
|
|
2095
|
+
/* @__PURE__ */ jsx(Rings, { w: c.w, h: c.h, rx: c.h / 2, selected })
|
|
2096
|
+
] }, c.id);
|
|
2097
|
+
}),
|
|
2098
|
+
scene.actors.map((a) => {
|
|
2099
|
+
const e = idx.entities.get(a.entityId);
|
|
2100
|
+
const s = idx.style(e);
|
|
2101
|
+
const dim = focus && !focus.actors.has(a.entityId);
|
|
2102
|
+
const selected = selection?.kind === "entity" && selection.id === e.id;
|
|
2103
|
+
const count = scene.associations.filter((x) => x.actor === e.id).length;
|
|
2104
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${a.x} ${a.y})`, ...bind({ kind: "entity", id: e.id }, `${e.name}: ${count} things they can do`), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
|
|
2105
|
+
/* @__PURE__ */ jsx(EntityNode, { entity: e, style: s.shape === "person" ? s : { ...s, shape: "card" }, w: a.w, h: a.h, emphasis: selected ? "selected" : "normal", detail: false }),
|
|
2106
|
+
zoom > 0.5 && /* @__PURE__ */ jsx("text", { x: a.w / 2, y: a.h + 16, textAnchor: "middle", fontSize: 11.5, fill: "var(--poney-ink-3)", children: a.side === "left" ? `Can do ${count} thing${count === 1 ? "" : "s"}` : `Supports ${count}` })
|
|
2107
|
+
] }, a.entityId);
|
|
2108
|
+
})
|
|
2109
|
+
] });
|
|
2110
|
+
}
|
|
2111
|
+
function Legend7() {
|
|
2112
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend", children: [
|
|
2113
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "person", tone: "slate", label: "Person who uses the system" }),
|
|
2114
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "card", tone: "umber", label: "Outside system that helps", dashed: true }),
|
|
2115
|
+
/* @__PURE__ */ jsx(LegendShape, { shape: "pill", tone: "tyrian", label: "Something a person can do" }),
|
|
2116
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "solid", label: "Does it", head: false }),
|
|
2117
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "dashed", label: "Helps with it", head: false })
|
|
2118
|
+
] });
|
|
2119
|
+
}
|
|
2120
|
+
var usecase = {
|
|
2121
|
+
key: "usecase",
|
|
2122
|
+
label: "Use cases",
|
|
2123
|
+
icon: UsersRound,
|
|
2124
|
+
howToRead: "People on the left, the things they can do in the middle, outside services that help on the right. Select a person to see everything they can do.",
|
|
2125
|
+
Renderer: Renderer7,
|
|
2126
|
+
Legend: Legend7
|
|
2127
|
+
};
|
|
2128
|
+
var DOWN = "var(--poney-lapis)";
|
|
2129
|
+
var UP = "var(--poney-ochre)";
|
|
2130
|
+
function Renderer8({ scene, view }) {
|
|
2131
|
+
const idx = useRenderIndex();
|
|
2132
|
+
const bind = useRenderBind();
|
|
2133
|
+
const { subject, selection } = useRenderSubject();
|
|
2134
|
+
const transitive = useViewState(view.id)[0].transitive ?? false;
|
|
2135
|
+
const relStyles = idx.doc.presentation.relationships;
|
|
2136
|
+
const bandSize = useReadableSize(13, 11, 22);
|
|
2137
|
+
const focus = useMemo(() => {
|
|
2138
|
+
if (!subject) return null;
|
|
2139
|
+
const deps = /* @__PURE__ */ new Set();
|
|
2140
|
+
const users = /* @__PURE__ */ new Set();
|
|
2141
|
+
const depEdges = /* @__PURE__ */ new Set();
|
|
2142
|
+
const userEdges = /* @__PURE__ */ new Set();
|
|
2143
|
+
if (subject.kind === "entity" && scene.nodes.some((n) => n.entityId === subject.id)) {
|
|
2144
|
+
const walk = (id, forward) => {
|
|
2145
|
+
for (const e of scene.edges) {
|
|
2146
|
+
const from = forward ? e.source : e.target;
|
|
2147
|
+
const to = forward ? e.target : e.source;
|
|
2148
|
+
if (from !== id) continue;
|
|
2149
|
+
(forward ? depEdges : userEdges).add(e.id);
|
|
2150
|
+
const set = forward ? deps : users;
|
|
2151
|
+
if (set.has(to) || to === subject.id) continue;
|
|
2152
|
+
set.add(to);
|
|
2153
|
+
if (transitive) walk(to, forward);
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
2156
|
+
walk(subject.id, true);
|
|
2157
|
+
walk(subject.id, false);
|
|
2158
|
+
return { node: subject.id, deps, users, depEdges, userEdges, group: null };
|
|
2159
|
+
}
|
|
2160
|
+
if (subject.kind === "relationship") {
|
|
2161
|
+
const e = scene.edges.find((x) => x.id === subject.id);
|
|
2162
|
+
if (!e) return null;
|
|
2163
|
+
depEdges.add(e.id);
|
|
2164
|
+
deps.add(e.target);
|
|
2165
|
+
users.add(e.source);
|
|
2166
|
+
return { node: null, deps, users, depEdges, userEdges, group: null };
|
|
2167
|
+
}
|
|
2168
|
+
if (subject.kind === "group" && subject.view === view.id) {
|
|
2169
|
+
const band = scene.bands.findIndex((b) => b.id === subject.id);
|
|
2170
|
+
scene.nodes.forEach((n) => n.band === band && deps.add(n.entityId));
|
|
2171
|
+
return { node: null, deps, users, depEdges, userEdges, group: subject.id };
|
|
2172
|
+
}
|
|
2173
|
+
return null;
|
|
2174
|
+
}, [subject, scene, transitive, view.id]);
|
|
2175
|
+
const nodeColor = (id) => focus?.deps.has(id) ? DOWN : focus?.users.has(id) ? UP : void 0;
|
|
2176
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
2177
|
+
scene.bands.map((b, i) => {
|
|
2178
|
+
const selected = selection?.kind === "group" && selection.id === b.id;
|
|
2179
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
2180
|
+
/* @__PURE__ */ jsx("rect", { x: b.x, y: b.y, width: b.w, height: b.h, fill: i % 2 ? "var(--poney-paper)" : "transparent", fillOpacity: 0.55 }),
|
|
2181
|
+
i > 0 && /* @__PURE__ */ jsx("line", { x1: b.x, x2: b.x + b.w, y1: b.y, y2: b.y, stroke: "var(--poney-rule)" }),
|
|
2182
|
+
/* @__PURE__ */ jsxs("g", { ...bind({ kind: "group", view: view.id, id: b.id }, `Layer ${b.label}`), children: [
|
|
2183
|
+
/* @__PURE__ */ jsx("rect", { x: 12, y: b.y + 12, width: 148, height: b.h - 24, rx: 10, fill: selected ? "var(--poney-accent-wash)" : "transparent" }),
|
|
2184
|
+
/* @__PURE__ */ jsx("text", { x: 24, y: b.y + b.h / 2 - (b.description && bandSize === 13 ? 4 : -4), fontSize: bandSize, fontWeight: 650, fill: selected ? "var(--poney-accent)" : "var(--poney-ink-2)", children: b.label }),
|
|
2185
|
+
b.description && bandSize === 13 && /* @__PURE__ */ jsx("text", { x: 24, y: b.y + b.h / 2 + 13, fontSize: 11, fill: "var(--poney-ink-3)", children: clip(b.description, 136, 11) })
|
|
2186
|
+
] })
|
|
2187
|
+
] }, b.id);
|
|
2188
|
+
}),
|
|
2189
|
+
scene.edges.map((e) => {
|
|
2190
|
+
const ls = relStyles[e.kind] ?? { pattern: "solid", head: "arrow" };
|
|
2191
|
+
const down = focus?.depEdges.has(e.id);
|
|
2192
|
+
const up = focus?.userEdges.has(e.id);
|
|
2193
|
+
const groupHot = focus?.group && (focus.deps.has(e.source) || focus.deps.has(e.target));
|
|
2194
|
+
const color = down ? DOWN : up ? UP : groupHot ? "var(--poney-ink-2)" : "var(--poney-ink-4)";
|
|
2195
|
+
const [p0, c1, c2, p3] = e.d;
|
|
2196
|
+
const angle = Math.atan2(p3.y - c2.y, p3.x - c2.x);
|
|
2197
|
+
const back = ls.head === "triangle" ? 10 : 6;
|
|
2198
|
+
const end = { x: p3.x - Math.cos(angle) * back, y: p3.y - Math.sin(angle) * back };
|
|
2199
|
+
const dim = focus && !down && !up && !groupHot;
|
|
2200
|
+
const rel = idx.relationships.get(e.id);
|
|
2201
|
+
return /* @__PURE__ */ jsxs("g", { ...bind({ kind: "relationship", id: e.id }, `${idx.entities.get(e.source)?.name} ${rel?.kind === "implements" ? "implements" : "depends on"} ${idx.entities.get(e.target)?.name}`), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
|
|
2202
|
+
/* @__PURE__ */ jsx("path", { d: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${p3.x} ${p3.y}`, fill: "none", stroke: "transparent", strokeWidth: 12 }),
|
|
2203
|
+
/* @__PURE__ */ jsx(
|
|
2204
|
+
"path",
|
|
2205
|
+
{
|
|
2206
|
+
d: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${end.x} ${end.y}`,
|
|
2207
|
+
fill: "none",
|
|
2208
|
+
stroke: color,
|
|
2209
|
+
strokeWidth: down || up ? 1.9 : 1.2,
|
|
2210
|
+
strokeDasharray: ls.pattern === "dashed" ? "5 4" : void 0,
|
|
2211
|
+
className: "poney-edge"
|
|
2212
|
+
}
|
|
2213
|
+
),
|
|
2214
|
+
/* @__PURE__ */ jsx(ArrowHead, { at: p3, angle, kind: ls.head, color })
|
|
2215
|
+
] }, e.id);
|
|
2216
|
+
}),
|
|
2217
|
+
scene.nodes.map((n) => {
|
|
2218
|
+
const e = idx.entities.get(n.entityId);
|
|
2219
|
+
const s = idx.style(e);
|
|
2220
|
+
const isSubject = focus?.node === n.entityId;
|
|
2221
|
+
const tint = nodeColor(n.entityId);
|
|
2222
|
+
const dim = focus && !isSubject && !tint;
|
|
2223
|
+
const selected = selection?.kind === "entity" && selection.id === e.id;
|
|
2224
|
+
return /* @__PURE__ */ jsxs("g", { transform: `translate(${n.x} ${n.y})`, ...bind({ kind: "entity", id: e.id }, `${e.name}, ${s.label}`), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
|
|
2225
|
+
/* @__PURE__ */ jsx(EntityNode, { entity: e, style: { ...s, shape: "chip" }, w: n.w, h: n.h, emphasis: selected ? "selected" : "normal", detail: false }),
|
|
2226
|
+
tint && !selected && /* @__PURE__ */ jsx("rect", { x: -2, y: -2, width: n.w + 4, height: n.h + 4, rx: 12, fill: "none", stroke: tint, strokeWidth: 1.6 }),
|
|
2227
|
+
/* @__PURE__ */ jsx(Rings, { w: n.w, h: n.h, rx: 10, selected: false })
|
|
2228
|
+
] }, n.entityId);
|
|
2229
|
+
})
|
|
2230
|
+
] });
|
|
2231
|
+
}
|
|
2232
|
+
function Legend8() {
|
|
2233
|
+
return /* @__PURE__ */ jsxs("div", { className: "poney-legend", children: [
|
|
2234
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "solid", label: "Depends on", color: "var(--poney-ink-3)" }),
|
|
2235
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "dashed", label: "Implements, or sends events to", color: "var(--poney-ink-3)" }),
|
|
2236
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "solid", label: "When selected: what it needs", color: DOWN }),
|
|
2237
|
+
/* @__PURE__ */ jsx(LegendRow, { line: "solid", label: "When selected: what needs it", color: UP }),
|
|
2238
|
+
/* @__PURE__ */ jsx("p", { className: "poney-legend-note", children: "Arrows should point down. An arrow that points up is a dependency turned around on purpose, such as an adapter that implements a domain interface." })
|
|
2239
|
+
] });
|
|
2240
|
+
}
|
|
2241
|
+
var dependency = {
|
|
2242
|
+
key: "dependency",
|
|
2243
|
+
label: "Dependencies",
|
|
2244
|
+
icon: Blocks,
|
|
2245
|
+
howToRead: "Layers run from the outside in, top to bottom. Select a part: blue shows what it needs, amber shows what needs it. Turn on \u201Cfollow all the way\u201D to see the full chain.",
|
|
2246
|
+
Renderer: Renderer8,
|
|
2247
|
+
Legend: Legend8
|
|
2248
|
+
};
|
|
2249
|
+
function Renderer9({ scene, view }) {
|
|
2250
|
+
const doc = useRenderIndex().doc;
|
|
2251
|
+
const [hot, setHot] = useState(null);
|
|
2252
|
+
const w = walkthroughsShowing(doc, view.id)[0];
|
|
2253
|
+
const [ui, update] = useViewState(view.id);
|
|
2254
|
+
const collapsed = ui.collapsed;
|
|
2255
|
+
const value = useMemo(
|
|
2256
|
+
() => ({
|
|
2257
|
+
marks: w ? marksOf(w) : /* @__PURE__ */ new Map(),
|
|
2258
|
+
mode: "after",
|
|
2259
|
+
focus: null,
|
|
2260
|
+
callouts: /* @__PURE__ */ new Map(),
|
|
2261
|
+
hot,
|
|
2262
|
+
setHot,
|
|
2263
|
+
toggleGroup: (id) => {
|
|
2264
|
+
const base = collapsed ?? view.collapsed;
|
|
2265
|
+
update({ collapsed: base.includes(id) ? base.filter((x) => x !== id) : [...base, id] });
|
|
2266
|
+
}
|
|
2267
|
+
}),
|
|
2268
|
+
[w, hot, collapsed, view, update]
|
|
2269
|
+
);
|
|
2270
|
+
return /* @__PURE__ */ jsx(StoryProvider, { value, children: /* @__PURE__ */ jsx(MapStory, { scene }) });
|
|
2271
|
+
}
|
|
2272
|
+
var map = {
|
|
2273
|
+
key: "map",
|
|
2274
|
+
label: "Map",
|
|
2275
|
+
icon: Map$1,
|
|
2276
|
+
howToRead: "A picture of how parts connect. A part drawn inside another belongs to it; open or close a group with its round button. Hover a line to read what it does.",
|
|
2277
|
+
Renderer: Renderer9
|
|
2278
|
+
};
|
|
2279
|
+
|
|
2280
|
+
// src/diagrams/registry.ts
|
|
2281
|
+
var BUILT_IN_DIAGRAMS = [architecture, map, sequence, dataflow, activity, erd, state, usecase, dependency];
|
|
2282
|
+
var modules = new Map(BUILT_IN_DIAGRAMS.map((m) => [m.key, m]));
|
|
2283
|
+
function registerDiagram(module) {
|
|
2284
|
+
modules.set(module.key, module);
|
|
2285
|
+
}
|
|
2286
|
+
function diagramFor(view) {
|
|
2287
|
+
return modules.get(viewKey(view));
|
|
2288
|
+
}
|
|
2289
|
+
function diagramByKey(key) {
|
|
2290
|
+
return modules.get(key);
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
export { BUILT_IN_DIAGRAMS, CalloutBadge, EdgeLabel2 as EdgeLabel, EdgeLine, EmphasisOver, EmphasisUnder, EntityNode, FONTS, Glyph, Head, ICONS, LegendRow, LegendShape, MapStory, RenderProvider, Rings, STATE_LABEL, SceneStory, SequenceStory, StateStory, StateTag, StoryProvider, THEMES, ZoomProvider, diagramByKey, diagramFor, expandFocus, findScene, fit, iconFor, lookClass, lookOf, registerDiagram, sceneFrame, sceneLayoutOptions, sceneLines, stateFill, stateStroke, stepLetter, storyState, toneColor, toneWash, useLook, useLookAny, useReadableSize, useRenderBind, useRenderIndex, useRenderStill, useRenderSubject, useRenderZoom, useStory, useViewState, viewKey };
|
|
2294
|
+
//# sourceMappingURL=index.js.map
|
|
2295
|
+
//# sourceMappingURL=index.js.map
|