@doki-land/davinci 0.0.0-stage → 0.0.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/dist/chart.d.ts +583 -0
- package/dist/chart.js +6328 -0
- package/dist/diagram.d.ts +413 -0
- package/dist/diagram.js +415 -0
- package/dist/index.d.ts +1203 -0
- package/dist/index.js +7561 -0
- package/dist/motion.d.ts +214 -0
- package/dist/motion.js +72 -0
- package/dist/runtime.d.ts +129 -0
- package/dist/runtime.js +101 -0
- package/dist/scene-svg.d.ts +180 -0
- package/dist/scene-svg.js +164 -0
- package/dist/scene.d.ts +406 -0
- package/dist/scene.js +697 -0
- package/dist/types.d.ts +181 -0
- package/dist/types.js +153 -0
- package/package.json +74 -4
- package/README.md +0 -3
package/dist/diagram.js
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
// ../davinci-diagram/dist/spec.js
|
|
2
|
+
function specBounds(spec) {
|
|
3
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
4
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
5
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
6
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
7
|
+
for (const n of spec.nodes) {
|
|
8
|
+
if (n.positionHint) {
|
|
9
|
+
const w = n.sizeHint?.w ?? 100;
|
|
10
|
+
const h = n.sizeHint?.h ?? 40;
|
|
11
|
+
minX = Math.min(minX, n.positionHint.x);
|
|
12
|
+
minY = Math.min(minY, n.positionHint.y);
|
|
13
|
+
maxX = Math.max(maxX, n.positionHint.x + w);
|
|
14
|
+
maxY = Math.max(maxY, n.positionHint.y + h);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (!Number.isFinite(minX))
|
|
18
|
+
return { x: 0, y: 0, w: 0, h: 0 };
|
|
19
|
+
return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// ../davinci-diagram/dist/layout.js
|
|
23
|
+
var DEFAULT_NODE_W = 120;
|
|
24
|
+
var DEFAULT_NODE_H = 50;
|
|
25
|
+
var NODE_GAP_X = 60;
|
|
26
|
+
var NODE_GAP_Y = 40;
|
|
27
|
+
var CANVAS_MARGIN = 12;
|
|
28
|
+
function simpleLayout(spec) {
|
|
29
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
30
|
+
for (const n of spec.nodes)
|
|
31
|
+
nodes.set(n.id, n);
|
|
32
|
+
const incoming = /* @__PURE__ */ new Map();
|
|
33
|
+
for (const n of spec.nodes)
|
|
34
|
+
incoming.set(n.id, 0);
|
|
35
|
+
for (const e of spec.edges)
|
|
36
|
+
incoming.set(e.toNode, (incoming.get(e.toNode) ?? 0) + 1);
|
|
37
|
+
const layers = [];
|
|
38
|
+
const placed = /* @__PURE__ */ new Set();
|
|
39
|
+
let frontier = [];
|
|
40
|
+
for (const [id, count] of incoming) {
|
|
41
|
+
if (count === 0)
|
|
42
|
+
frontier.push(id);
|
|
43
|
+
}
|
|
44
|
+
while (frontier.length > 0) {
|
|
45
|
+
const layer = [];
|
|
46
|
+
const nextFrontier = [];
|
|
47
|
+
for (const id of frontier) {
|
|
48
|
+
if (placed.has(id))
|
|
49
|
+
continue;
|
|
50
|
+
placed.add(id);
|
|
51
|
+
layer.push(id);
|
|
52
|
+
for (const e of spec.edges) {
|
|
53
|
+
if (e.fromNode === id && !placed.has(e.toNode) && !nextFrontier.includes(e.toNode)) {
|
|
54
|
+
nextFrontier.push(e.toNode);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (layer.length > 0)
|
|
59
|
+
layers.push(layer);
|
|
60
|
+
frontier = nextFrontier;
|
|
61
|
+
}
|
|
62
|
+
const leftovers = [];
|
|
63
|
+
for (const n of spec.nodes)
|
|
64
|
+
if (!placed.has(n.id))
|
|
65
|
+
leftovers.push(n.id);
|
|
66
|
+
if (leftovers.length > 0)
|
|
67
|
+
layers.push(leftovers);
|
|
68
|
+
const layoutedNodes = [];
|
|
69
|
+
let maxRight = 0;
|
|
70
|
+
let maxBottom = 0;
|
|
71
|
+
for (let li = 0; li < layers.length; li++) {
|
|
72
|
+
const layerNodes = layers[li];
|
|
73
|
+
const x = CANVAS_MARGIN + li * (DEFAULT_NODE_W + NODE_GAP_X);
|
|
74
|
+
for (let ci = 0; ci < layerNodes.length; ci++) {
|
|
75
|
+
const nid = layerNodes[ci];
|
|
76
|
+
const node = nodes.get(nid);
|
|
77
|
+
const w = node.sizeHint?.w ?? DEFAULT_NODE_W;
|
|
78
|
+
const h = node.sizeHint?.h ?? DEFAULT_NODE_H;
|
|
79
|
+
const y = CANVAS_MARGIN + ci * (h + NODE_GAP_Y);
|
|
80
|
+
layoutedNodes.push({
|
|
81
|
+
id: nid,
|
|
82
|
+
bounds: { x, y, w, h },
|
|
83
|
+
layer: li,
|
|
84
|
+
column: ci
|
|
85
|
+
});
|
|
86
|
+
maxRight = Math.max(maxRight, x + w);
|
|
87
|
+
maxBottom = Math.max(maxBottom, y + h);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const nodeCenter = /* @__PURE__ */ new Map();
|
|
91
|
+
for (const ln of layoutedNodes) {
|
|
92
|
+
nodeCenter.set(ln.id, { x: ln.bounds.x + ln.bounds.w / 2, y: ln.bounds.y + ln.bounds.h / 2 });
|
|
93
|
+
}
|
|
94
|
+
const routedEdges = [];
|
|
95
|
+
for (const e of spec.edges) {
|
|
96
|
+
const from = nodeCenter.get(e.fromNode);
|
|
97
|
+
const to = nodeCenter.get(e.toNode);
|
|
98
|
+
if (!from || !to)
|
|
99
|
+
continue;
|
|
100
|
+
routedEdges.push({ id: e.id, from, to, route: [] });
|
|
101
|
+
}
|
|
102
|
+
const canvasBounds = { x: 0, y: 0, w: maxRight + CANVAS_MARGIN, h: maxBottom + CANVAS_MARGIN };
|
|
103
|
+
return {
|
|
104
|
+
nodes: layoutedNodes,
|
|
105
|
+
edges: routedEdges,
|
|
106
|
+
clusters: [],
|
|
107
|
+
canvasBounds,
|
|
108
|
+
diagnostics: { items: [] }
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ../davinci-scene/dist/version.js
|
|
113
|
+
var SCENE_VERSION = "/v0";
|
|
114
|
+
|
|
115
|
+
// ../davinci-types/dist/color.js
|
|
116
|
+
function rgba8(r, g, b, a = 255) {
|
|
117
|
+
return { r: clamp01(r / 255), g: clamp01(g / 255), b: clamp01(b / 255), a: clamp01(a / 255) };
|
|
118
|
+
}
|
|
119
|
+
function rgb8(r, g, b) {
|
|
120
|
+
return rgba8(r, g, b, 255);
|
|
121
|
+
}
|
|
122
|
+
function clamp01(v) {
|
|
123
|
+
if (v <= 0)
|
|
124
|
+
return 0;
|
|
125
|
+
if (v >= 1)
|
|
126
|
+
return 1;
|
|
127
|
+
return v;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ../davinci-types/dist/diagnostics.js
|
|
131
|
+
var EMPTY_DIAGNOSTICS = { items: [] };
|
|
132
|
+
|
|
133
|
+
// ../davinci-scene/dist/resolve.js
|
|
134
|
+
var TEXT_ADVANCE_RATIO = 0.6;
|
|
135
|
+
var WIDE_ADVANCE_RATIO = 1;
|
|
136
|
+
var TEXT_LINE_RATIO = 1.2;
|
|
137
|
+
var DEFAULT_TEXT_SIZE = 12;
|
|
138
|
+
var ELLIPSIS = "\u2026";
|
|
139
|
+
function estimateTextSize(text, sizePx) {
|
|
140
|
+
const size = Number.isFinite(sizePx) && sizePx > 0 ? sizePx : DEFAULT_TEXT_SIZE;
|
|
141
|
+
const lines = text.split("\n");
|
|
142
|
+
let widest = 0;
|
|
143
|
+
for (const line of lines)
|
|
144
|
+
widest = Math.max(widest, measureWidth(line, size));
|
|
145
|
+
return { width: widest, height: lines.length * size * TEXT_LINE_RATIO };
|
|
146
|
+
}
|
|
147
|
+
function truncateToWidth(text, maxWidth, sizePx) {
|
|
148
|
+
const size = Number.isFinite(sizePx) && sizePx > 0 ? sizePx : DEFAULT_TEXT_SIZE;
|
|
149
|
+
const limit = maxWidth > 0 ? maxWidth : 0;
|
|
150
|
+
if (measureWidth(text, size) <= limit)
|
|
151
|
+
return text;
|
|
152
|
+
const ellipsisWidth = measureWidth(ELLIPSIS, size);
|
|
153
|
+
if (ellipsisWidth > limit)
|
|
154
|
+
return "";
|
|
155
|
+
const chars = Array.from(text);
|
|
156
|
+
let used = ellipsisWidth;
|
|
157
|
+
let keep = 0;
|
|
158
|
+
for (const ch of chars) {
|
|
159
|
+
const advance = charAdvance(ch, size);
|
|
160
|
+
if (used + advance > limit)
|
|
161
|
+
break;
|
|
162
|
+
used += advance;
|
|
163
|
+
keep += 1;
|
|
164
|
+
}
|
|
165
|
+
return chars.slice(0, keep).join("") + ELLIPSIS;
|
|
166
|
+
}
|
|
167
|
+
function measureWidth(text, size) {
|
|
168
|
+
let width = 0;
|
|
169
|
+
for (const ch of Array.from(text))
|
|
170
|
+
width += charAdvance(ch, size);
|
|
171
|
+
return width;
|
|
172
|
+
}
|
|
173
|
+
function charAdvance(ch, size) {
|
|
174
|
+
return isWideCodepoint(ch.codePointAt(0) ?? 0) ? size * WIDE_ADVANCE_RATIO : size * TEXT_ADVANCE_RATIO;
|
|
175
|
+
}
|
|
176
|
+
function isWideCodepoint(cp) {
|
|
177
|
+
return cp >= 4352 && cp <= 4447 || // Hangul Jamo
|
|
178
|
+
cp >= 11904 && cp <= 12350 || // radicals, Kangxi, CJK symbols and punctuation
|
|
179
|
+
cp >= 12353 && cp <= 13311 || // kana, Hangul compatibility, enclosed CJK
|
|
180
|
+
cp >= 13312 && cp <= 19903 || // CJK Extension A
|
|
181
|
+
cp >= 19968 && cp <= 40959 || // CJK Unified Ideographs
|
|
182
|
+
cp >= 40960 && cp <= 42191 || // Yi
|
|
183
|
+
cp >= 44032 && cp <= 55203 || // Hangul syllables
|
|
184
|
+
cp >= 63744 && cp <= 64255 || // CJK Compatibility Ideographs
|
|
185
|
+
cp >= 65072 && cp <= 65103 || // CJK Form Variants
|
|
186
|
+
cp >= 65280 && cp <= 65376 || // Fullwidth Forms
|
|
187
|
+
cp >= 65504 && cp <= 65510;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ../davinci-diagram/dist/theme.js
|
|
191
|
+
var LABEL_FAMILY = "system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif";
|
|
192
|
+
var DEFAULT_DIAGRAM_THEME = {
|
|
193
|
+
nodeFill: rgb8(248, 250, 252),
|
|
194
|
+
nodeStroke: rgb8(100, 116, 139),
|
|
195
|
+
nodeStrokeWidth: 1.25,
|
|
196
|
+
nodeRadius: 6,
|
|
197
|
+
nodeLabelColor: rgb8(30, 41, 59),
|
|
198
|
+
nodeLabelFont: { family: LABEL_FAMILY, sizePx: 13 },
|
|
199
|
+
edgeStroke: rgb8(100, 116, 139),
|
|
200
|
+
edgeStrokeWidth: 1.5,
|
|
201
|
+
edgeLabelColor: rgb8(71, 85, 105),
|
|
202
|
+
edgeLabelFont: { family: LABEL_FAMILY, sizePx: 12 },
|
|
203
|
+
labelHalo: rgb8(255, 255, 255)
|
|
204
|
+
};
|
|
205
|
+
var DARK_DIAGRAM_THEME = {
|
|
206
|
+
nodeFill: rgb8(31, 41, 55),
|
|
207
|
+
nodeStroke: rgb8(107, 114, 128),
|
|
208
|
+
nodeStrokeWidth: 1.25,
|
|
209
|
+
nodeRadius: 6,
|
|
210
|
+
nodeLabelColor: rgb8(229, 231, 235),
|
|
211
|
+
nodeLabelFont: { family: LABEL_FAMILY, sizePx: 13 },
|
|
212
|
+
edgeStroke: rgb8(156, 163, 175),
|
|
213
|
+
edgeStrokeWidth: 1.5,
|
|
214
|
+
edgeLabelColor: rgb8(209, 213, 219),
|
|
215
|
+
edgeLabelFont: { family: LABEL_FAMILY, sizePx: 12 },
|
|
216
|
+
labelHalo: rgb8(17, 24, 39)
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// ../davinci-diagram/dist/builder.js
|
|
220
|
+
var ARROW_LENGTH = 10;
|
|
221
|
+
var ARROW_WIDTH = 8;
|
|
222
|
+
var NODE_LABEL_PADDING = 12;
|
|
223
|
+
var EDGE_LABEL_PAD_X = 4;
|
|
224
|
+
var EDGE_LABEL_PAD_Y = 2;
|
|
225
|
+
function buildScene(spec, plan, options) {
|
|
226
|
+
const theme = options?.theme ?? DEFAULT_DIAGRAM_THEME;
|
|
227
|
+
const children = [];
|
|
228
|
+
const nodeBounds = new Map(plan.nodes.map((n) => [n.id, n.bounds]));
|
|
229
|
+
for (const e of plan.edges) {
|
|
230
|
+
const specEdge = spec.edges.find((s) => s.id === e.id);
|
|
231
|
+
const fromBounds = nodeBounds.get(specEdge?.fromNode ?? "");
|
|
232
|
+
const toBounds = nodeBounds.get(specEdge?.toNode ?? "");
|
|
233
|
+
const clippedFrom = fromBounds ? clipToRect(e.from, e.to, fromBounds) : e.from;
|
|
234
|
+
const clippedTo = toBounds ? clipToRect(e.to, e.from, toBounds) : e.to;
|
|
235
|
+
const pathCmds = [
|
|
236
|
+
{ kind: "move", to: clippedFrom },
|
|
237
|
+
...e.route.map((p) => ({ kind: "line", to: p })),
|
|
238
|
+
{ kind: "line", to: clippedTo }
|
|
239
|
+
];
|
|
240
|
+
const stroke = edgeStroke(specEdge, theme);
|
|
241
|
+
children.push({
|
|
242
|
+
kind: "path",
|
|
243
|
+
id: `edge-${e.id}`,
|
|
244
|
+
role: "diagram.edge",
|
|
245
|
+
source: { domain: "diagram", path: ["edge", e.id] },
|
|
246
|
+
path: { commands: pathCmds },
|
|
247
|
+
stroke
|
|
248
|
+
});
|
|
249
|
+
const arrowKind = specEdge?.edgeKind;
|
|
250
|
+
if (arrowKind === "arrow" || arrowKind === "bidirectional") {
|
|
251
|
+
children.push(arrowhead(`edge-arrow-to-${e.id}`, e.id, clippedTo, direction(clippedFrom, clippedTo), stroke.color));
|
|
252
|
+
}
|
|
253
|
+
if (arrowKind === "bidirectional") {
|
|
254
|
+
children.push(arrowhead(`edge-arrow-from-${e.id}`, e.id, clippedFrom, direction(clippedTo, clippedFrom), stroke.color));
|
|
255
|
+
}
|
|
256
|
+
if (specEdge?.label) {
|
|
257
|
+
children.push(...edgeLabel(specEdge, clippedFrom, clippedTo, theme));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
for (const n of plan.nodes) {
|
|
261
|
+
const specNode = spec.nodes.find((s) => s.id === n.id);
|
|
262
|
+
children.push({
|
|
263
|
+
kind: "rect",
|
|
264
|
+
id: `node-${n.id}`,
|
|
265
|
+
role: "diagram.node",
|
|
266
|
+
source: { domain: "diagram", path: ["node", n.id] },
|
|
267
|
+
x: n.bounds.x,
|
|
268
|
+
y: n.bounds.y,
|
|
269
|
+
w: n.bounds.w,
|
|
270
|
+
h: n.bounds.h,
|
|
271
|
+
rx: theme.nodeRadius,
|
|
272
|
+
ry: theme.nodeRadius,
|
|
273
|
+
fill: { color: theme.nodeFill },
|
|
274
|
+
stroke: { color: theme.nodeStroke, width: theme.nodeStrokeWidth }
|
|
275
|
+
});
|
|
276
|
+
if (specNode?.label) {
|
|
277
|
+
children.push({
|
|
278
|
+
kind: "text",
|
|
279
|
+
id: `node-label-${n.id}`,
|
|
280
|
+
role: "text",
|
|
281
|
+
source: { domain: "diagram", path: ["node", n.id, "label"] },
|
|
282
|
+
text: truncateToWidth(specNode.label, Math.max(0, n.bounds.w - NODE_LABEL_PADDING), theme.nodeLabelFont.sizePx),
|
|
283
|
+
font: theme.nodeLabelFont,
|
|
284
|
+
anchor: { x: n.bounds.x + n.bounds.w / 2, y: n.bounds.y + n.bounds.h / 2 },
|
|
285
|
+
color: theme.nodeLabelColor
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
version: SCENE_VERSION,
|
|
291
|
+
root: {
|
|
292
|
+
kind: "group",
|
|
293
|
+
id: "diagram-root",
|
|
294
|
+
role: "group",
|
|
295
|
+
children
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function edgeStroke(specEdge, theme) {
|
|
300
|
+
const base = { color: theme.edgeStroke, width: theme.edgeStrokeWidth };
|
|
301
|
+
switch (specEdge?.edgeKind) {
|
|
302
|
+
case "dashed":
|
|
303
|
+
return { ...base, dash: [6, 4] };
|
|
304
|
+
case "dotted":
|
|
305
|
+
return { ...base, dash: [2, 3] };
|
|
306
|
+
case "thick":
|
|
307
|
+
return { ...base, width: theme.edgeStrokeWidth * 1.8 };
|
|
308
|
+
default:
|
|
309
|
+
return base;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function edgeLabel(specEdge, from, to, theme) {
|
|
313
|
+
const mid = { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 };
|
|
314
|
+
const size = estimateTextSize(specEdge.label, theme.edgeLabelFont.sizePx);
|
|
315
|
+
return [
|
|
316
|
+
{
|
|
317
|
+
kind: "rect",
|
|
318
|
+
id: `edge-label-halo-${specEdge.id}`,
|
|
319
|
+
role: "decorative",
|
|
320
|
+
source: { domain: "diagram", path: ["edge", specEdge.id, "label"] },
|
|
321
|
+
x: mid.x - size.width / 2 - EDGE_LABEL_PAD_X,
|
|
322
|
+
y: mid.y - size.height / 2 - EDGE_LABEL_PAD_Y,
|
|
323
|
+
w: size.width + EDGE_LABEL_PAD_X * 2,
|
|
324
|
+
h: size.height + EDGE_LABEL_PAD_Y * 2,
|
|
325
|
+
rx: 2,
|
|
326
|
+
ry: 2,
|
|
327
|
+
fill: { color: theme.labelHalo }
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
kind: "text",
|
|
331
|
+
id: `edge-label-${specEdge.id}`,
|
|
332
|
+
role: "diagram.label",
|
|
333
|
+
source: { domain: "diagram", path: ["edge", specEdge.id, "label"] },
|
|
334
|
+
text: specEdge.label,
|
|
335
|
+
font: theme.edgeLabelFont,
|
|
336
|
+
anchor: mid,
|
|
337
|
+
color: theme.edgeLabelColor
|
|
338
|
+
}
|
|
339
|
+
];
|
|
340
|
+
}
|
|
341
|
+
function arrowhead(id, edgeId, tip, dir, color) {
|
|
342
|
+
const len = Math.hypot(dir.x, dir.y) || 1;
|
|
343
|
+
const ux = dir.x / len;
|
|
344
|
+
const uy = dir.y / len;
|
|
345
|
+
const px = -uy;
|
|
346
|
+
const py = ux;
|
|
347
|
+
const baseX = tip.x - ux * ARROW_LENGTH;
|
|
348
|
+
const baseY = tip.y - uy * ARROW_LENGTH;
|
|
349
|
+
const half = ARROW_WIDTH / 2;
|
|
350
|
+
return {
|
|
351
|
+
kind: "path",
|
|
352
|
+
id,
|
|
353
|
+
role: "diagram.edge",
|
|
354
|
+
source: { domain: "diagram", path: ["edge", edgeId, "arrowhead"] },
|
|
355
|
+
path: {
|
|
356
|
+
commands: [
|
|
357
|
+
{ kind: "move", to: tip },
|
|
358
|
+
{ kind: "line", to: { x: baseX + px * half, y: baseY + py * half } },
|
|
359
|
+
{ kind: "line", to: { x: baseX - px * half, y: baseY - py * half } },
|
|
360
|
+
{ kind: "close" }
|
|
361
|
+
]
|
|
362
|
+
},
|
|
363
|
+
fill: { color },
|
|
364
|
+
stroke: { color, width: 1 }
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function direction(from, to) {
|
|
368
|
+
return { x: to.x - from.x, y: to.y - from.y };
|
|
369
|
+
}
|
|
370
|
+
function clipToRect(center, other, rect) {
|
|
371
|
+
const dx = other.x - center.x;
|
|
372
|
+
const dy = other.y - center.y;
|
|
373
|
+
if (dx === 0 && dy === 0)
|
|
374
|
+
return center;
|
|
375
|
+
const candidates = [];
|
|
376
|
+
if (dx !== 0) {
|
|
377
|
+
candidates.push((rect.x - center.x) / dx, (rect.x + rect.w - center.x) / dx);
|
|
378
|
+
}
|
|
379
|
+
if (dy !== 0) {
|
|
380
|
+
candidates.push((rect.y - center.y) / dy, (rect.y + rect.h - center.y) / dy);
|
|
381
|
+
}
|
|
382
|
+
let best = Number.POSITIVE_INFINITY;
|
|
383
|
+
for (const t of candidates) {
|
|
384
|
+
if (t <= 0)
|
|
385
|
+
continue;
|
|
386
|
+
const x = center.x + t * dx;
|
|
387
|
+
const y = center.y + t * dy;
|
|
388
|
+
const onX = Math.abs(x - rect.x) < 1e-9 || Math.abs(x - (rect.x + rect.w)) < 1e-9;
|
|
389
|
+
const onY = Math.abs(y - rect.y) < 1e-9 || Math.abs(y - (rect.y + rect.h)) < 1e-9;
|
|
390
|
+
const insideX = x >= rect.x - 1e-9 && x <= rect.x + rect.w + 1e-9;
|
|
391
|
+
const insideY = y >= rect.y - 1e-9 && y <= rect.y + rect.h + 1e-9;
|
|
392
|
+
if (onX && insideY || onY && insideX)
|
|
393
|
+
best = Math.min(best, t);
|
|
394
|
+
}
|
|
395
|
+
if (!Number.isFinite(best))
|
|
396
|
+
return center;
|
|
397
|
+
return { x: center.x + best * dx, y: center.y + best * dy };
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// ../davinci-diagram/dist/mermaid.js
|
|
401
|
+
function parseMermaid(_block) {
|
|
402
|
+
return { diagnostics: EMPTY_DIAGNOSTICS };
|
|
403
|
+
}
|
|
404
|
+
function fromSpec(spec) {
|
|
405
|
+
return spec;
|
|
406
|
+
}
|
|
407
|
+
export {
|
|
408
|
+
DARK_DIAGRAM_THEME,
|
|
409
|
+
DEFAULT_DIAGRAM_THEME,
|
|
410
|
+
buildScene,
|
|
411
|
+
fromSpec,
|
|
412
|
+
parseMermaid,
|
|
413
|
+
simpleLayout,
|
|
414
|
+
specBounds
|
|
415
|
+
};
|