@getartisanflow/alpineflow 0.1.0-alpha
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 +88 -0
- package/dist/alpineflow-collab.esm.js +465 -0
- package/dist/alpineflow-collab.esm.js.map +1 -0
- package/dist/alpineflow-collab.js +247 -0
- package/dist/alpineflow-collab.js.map +1 -0
- package/dist/alpineflow-dagre.esm.js +1661 -0
- package/dist/alpineflow-dagre.esm.js.map +1 -0
- package/dist/alpineflow-dagre.js +1655 -0
- package/dist/alpineflow-dagre.js.map +1 -0
- package/dist/alpineflow-elk.esm.js +47378 -0
- package/dist/alpineflow-elk.esm.js.map +1 -0
- package/dist/alpineflow-elk.js +47373 -0
- package/dist/alpineflow-elk.js.map +1 -0
- package/dist/alpineflow-force.esm.js +599 -0
- package/dist/alpineflow-force.esm.js.map +1 -0
- package/dist/alpineflow-force.js +477 -0
- package/dist/alpineflow-force.js.map +1 -0
- package/dist/alpineflow-hierarchy.esm.js +398 -0
- package/dist/alpineflow-hierarchy.esm.js.map +1 -0
- package/dist/alpineflow-hierarchy.js +393 -0
- package/dist/alpineflow-hierarchy.js.map +1 -0
- package/dist/alpineflow-theme.css +473 -0
- package/dist/alpineflow-whiteboard.esm.js +922 -0
- package/dist/alpineflow-whiteboard.esm.js.map +1 -0
- package/dist/alpineflow-whiteboard.js +922 -0
- package/dist/alpineflow-whiteboard.js.map +1 -0
- package/dist/alpineflow.bundle.esm.js +12604 -0
- package/dist/alpineflow.bundle.esm.js.map +1 -0
- package/dist/alpineflow.css +1415 -0
- package/dist/alpineflow.esm.js +158 -0
- package/dist/alpineflow.esm.js.map +1 -0
- package/dist/alpineflow.js +5 -0
- package/dist/alpineflow.js.map +1 -0
- package/dist/export-DjmXOnKD.js +76 -0
- package/dist/export-DjmXOnKD.js.map +1 -0
- package/dist/geometry-DZSZoYHE.js +82 -0
- package/dist/geometry-DZSZoYHE.js.map +1 -0
- package/dist/index-C0N1DL3G.js +11728 -0
- package/dist/index-C0N1DL3G.js.map +1 -0
- package/dist/index-L3Zm-CoX.js +513 -0
- package/dist/index-L3Zm-CoX.js.map +1 -0
- package/dist/registry-CChkuoVJ.js +15 -0
- package/dist/registry-CChkuoVJ.js.map +1 -0
- package/dist/store-CaFAFEdD.js +9 -0
- package/dist/store-CaFAFEdD.js.map +1 -0
- package/dist/timer-B39XOBYL.js +124 -0
- package/dist/timer-B39XOBYL.js.map +1 -0
- package/dist/types/lib/collab.cdn.d.ts +1 -0
- package/dist/types/lib/collab.d.ts +2 -0
- package/dist/types/lib/core.cdn.d.ts +1 -0
- package/dist/types/lib/core.d.ts +2 -0
- package/dist/types/lib/dagre.cdn.d.ts +1 -0
- package/dist/types/lib/dagre.d.ts +1 -0
- package/dist/types/lib/elk.cdn.d.ts +1 -0
- package/dist/types/lib/elk.d.ts +1 -0
- package/dist/types/lib/force.cdn.d.ts +1 -0
- package/dist/types/lib/force.d.ts +1 -0
- package/dist/types/lib/hierarchy.cdn.d.ts +1 -0
- package/dist/types/lib/hierarchy.d.ts +1 -0
- package/dist/types/lib/whiteboard.cdn.d.ts +1 -0
- package/dist/types/lib/whiteboard.d.ts +1 -0
- package/dist/types/src/animate/animator.d.ts +57 -0
- package/dist/types/src/animate/easing.d.ts +4 -0
- package/dist/types/src/animate/edge-transitions.d.ts +22 -0
- package/dist/types/src/animate/engine.d.ts +37 -0
- package/dist/types/src/animate/index.d.ts +10 -0
- package/dist/types/src/animate/interpolators.d.ts +14 -0
- package/dist/types/src/animate/paths.d.ts +64 -0
- package/dist/types/src/animate/timeline.d.ts +149 -0
- package/dist/types/src/collab/awareness.d.ts +40 -0
- package/dist/types/src/collab/bridge.d.ts +36 -0
- package/dist/types/src/collab/directives/flow-cursors.d.ts +16 -0
- package/dist/types/src/collab/index.d.ts +19 -0
- package/dist/types/src/collab/providers/in-memory.d.ts +41 -0
- package/dist/types/src/collab/providers/reverb.d.ts +59 -0
- package/dist/types/src/collab/providers/websocket.d.ts +33 -0
- package/dist/types/src/collab/store.d.ts +22 -0
- package/dist/types/src/collab/types.d.ts +55 -0
- package/dist/types/src/core/__fixtures__/nodes.d.ts +42 -0
- package/dist/types/src/core/announcer.d.ts +21 -0
- package/dist/types/src/core/auto-pan.d.ts +37 -0
- package/dist/types/src/core/child-layout.d.ts +18 -0
- package/dist/types/src/core/child-validation.d.ts +23 -0
- package/dist/types/src/core/clipboard.d.ts +29 -0
- package/dist/types/src/core/collapse.d.ts +54 -0
- package/dist/types/src/core/color-mode.d.ts +11 -0
- package/dist/types/src/core/compute.d.ts +33 -0
- package/dist/types/src/core/connections.d.ts +32 -0
- package/dist/types/src/core/constants.d.ts +18 -0
- package/dist/types/src/core/controls-panel.d.ts +23 -0
- package/dist/types/src/core/debug.d.ts +10 -0
- package/dist/types/src/core/deep-merge.d.ts +10 -0
- package/dist/types/src/core/drag.d.ts +63 -0
- package/dist/types/src/core/edge-paths/avoidant.d.ts +25 -0
- package/dist/types/src/core/edge-paths/bezier.d.ts +26 -0
- package/dist/types/src/core/edge-paths/editable.d.ts +22 -0
- package/dist/types/src/core/edge-paths/index.d.ts +7 -0
- package/dist/types/src/core/edge-paths/orthogonal.d.ts +27 -0
- package/dist/types/src/core/edge-paths/smoothstep.d.ts +22 -0
- package/dist/types/src/core/edge-paths/straight.d.ts +12 -0
- package/dist/types/src/core/edge-paths/utils.d.ts +30 -0
- package/dist/types/src/core/edge-utils.d.ts +57 -0
- package/dist/types/src/core/export.d.ts +12 -0
- package/dist/types/src/core/floating-edge.d.ts +33 -0
- package/dist/types/src/core/geometry.d.ts +79 -0
- package/dist/types/src/core/gradients.d.ts +30 -0
- package/dist/types/src/core/graph.d.ts +38 -0
- package/dist/types/src/core/helper-lines.d.ts +32 -0
- package/dist/types/src/core/history.d.ts +19 -0
- package/dist/types/src/core/index.d.ts +17 -0
- package/dist/types/src/core/intersection.d.ts +30 -0
- package/dist/types/src/core/keyboard-shortcuts.d.ts +45 -0
- package/dist/types/src/core/lasso-hit-test.d.ts +25 -0
- package/dist/types/src/core/lasso.d.ts +10 -0
- package/dist/types/src/core/layout/dagre.d.ts +11 -0
- package/dist/types/src/core/layout/elk.d.ts +13 -0
- package/dist/types/src/core/layout/force.d.ts +15 -0
- package/dist/types/src/core/layout/hierarchy.d.ts +13 -0
- package/dist/types/src/core/long-press.d.ts +11 -0
- package/dist/types/src/core/markers.d.ts +49 -0
- package/dist/types/src/core/minimap.d.ts +18 -0
- package/dist/types/src/core/node-flags.d.ts +19 -0
- package/dist/types/src/core/pan-zoom.d.ts +62 -0
- package/dist/types/src/core/proximity-connect.d.ts +25 -0
- package/dist/types/src/core/registry.d.ts +16 -0
- package/dist/types/src/core/render-plan.d.ts +52 -0
- package/dist/types/src/core/resize.d.ts +31 -0
- package/dist/types/src/core/rotation.d.ts +8 -0
- package/dist/types/src/core/selection-box.d.ts +14 -0
- package/dist/types/src/core/shapes.d.ts +10 -0
- package/dist/types/src/core/sub-flow.d.ts +61 -0
- package/dist/types/src/core/svg-path.d.ts +5 -0
- package/dist/types/src/core/types.d.ts +1238 -0
- package/dist/types/src/core/wire-bridge.d.ts +36 -0
- package/dist/types/src/index.d.ts +43 -0
- package/dist/types/src/layout/dagre.d.ts +2 -0
- package/dist/types/src/layout/elk.d.ts +2 -0
- package/dist/types/src/layout/force.d.ts +2 -0
- package/dist/types/src/layout/hierarchy.d.ts +2 -0
- package/dist/types/src/plugin/connection-utils.d.ts +54 -0
- package/dist/types/src/plugin/data/__test-utils.d.ts +9 -0
- package/dist/types/src/plugin/data/canvas-animation.d.ts +62 -0
- package/dist/types/src/plugin/data/canvas-collapse.d.ts +35 -0
- package/dist/types/src/plugin/data/canvas-compute.d.ts +6 -0
- package/dist/types/src/plugin/data/canvas-condense.d.ts +19 -0
- package/dist/types/src/plugin/data/canvas-config.d.ts +4 -0
- package/dist/types/src/plugin/data/canvas-context.d.ts +570 -0
- package/dist/types/src/plugin/data/canvas-dom.d.ts +13 -0
- package/dist/types/src/plugin/data/canvas-edges.d.ts +37 -0
- package/dist/types/src/plugin/data/canvas-history.d.ts +53 -0
- package/dist/types/src/plugin/data/canvas-layout.d.ts +151 -0
- package/dist/types/src/plugin/data/canvas-nodes.d.ts +73 -0
- package/dist/types/src/plugin/data/canvas-rows.d.ts +13 -0
- package/dist/types/src/plugin/data/canvas-selection.d.ts +45 -0
- package/dist/types/src/plugin/data/canvas-validation.d.ts +21 -0
- package/dist/types/src/plugin/data/canvas-viewport.d.ts +111 -0
- package/dist/types/src/plugin/data/flow-canvas.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-action.d.ts +12 -0
- package/dist/types/src/plugin/directives/flow-animate.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-arrow-draw.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-circle-draw.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-collapse.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-condense.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-context-menu.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-detail.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-devtools.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-drag-handle.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-draggable.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-edge-toolbar.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-edge.d.ts +7 -0
- package/dist/types/src/plugin/directives/flow-eraser.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-filter.d.ts +9 -0
- package/dist/types/src/plugin/directives/flow-follow.d.ts +9 -0
- package/dist/types/src/plugin/directives/flow-freehand.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-handle-connectable.d.ts +12 -0
- package/dist/types/src/plugin/directives/flow-handle-limit.d.ts +9 -0
- package/dist/types/src/plugin/directives/flow-handle-validate.d.ts +10 -0
- package/dist/types/src/plugin/directives/flow-handle.d.ts +29 -0
- package/dist/types/src/plugin/directives/flow-highlighter.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-loading.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-node-toolbar.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-node.d.ts +10 -0
- package/dist/types/src/plugin/directives/flow-panel.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-rectangle-draw.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-resizer.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-rotate.d.ts +11 -0
- package/dist/types/src/plugin/directives/flow-row-select.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-snapshot.d.ts +14 -0
- package/dist/types/src/plugin/directives/flow-text-tool.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-timeline.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-viewport.d.ts +2 -0
- package/dist/types/src/plugin/magics/flow.d.ts +2 -0
- package/dist/types/src/plugin/store.d.ts +2 -0
- package/dist/types/src/whiteboard/index.d.ts +2 -0
- package/package.json +153 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { g as F, n as w, a as E, b as N } from "./index-C0N1DL3G.js";
|
|
2
|
+
import { C as $, F as j, S as V, c as X, d as Y, e as W, f as G, h as K, i as Z, j as q, A as J, k as Q, l as ee, m as te, o as se, p as oe, q as ae, r as ie, s as ne, t as re, u as de, v as le, w as ge, x as ce, y as he, z as me, B as pe, D as ue, E as fe, G as ye, H as be, I as Pe, J as we, K as Ee, L as Ne, M as xe, N as ve, O as De, P as Ie, Q as Se, R as ke, T as Ce, U as Ae, V as Te, W as Fe, X as Me, Y as Re, Z as Be, _ as ze, $ as He, a0 as Oe } from "./index-C0N1DL3G.js";
|
|
3
|
+
import { D as M, a as R, g as B } from "./geometry-DZSZoYHE.js";
|
|
4
|
+
import { b as Le, c as Ue, d as $e } from "./geometry-DZSZoYHE.js";
|
|
5
|
+
function _(x, v, r) {
|
|
6
|
+
const D = r?.defaultDimensions?.width ?? M, I = r?.defaultDimensions?.height ?? R, d = r?.padding ?? 20, y = r?.flowId ?? "ssr", l = x.filter((e) => !e.hidden).map((e) => ({
|
|
7
|
+
...e,
|
|
8
|
+
dimensions: {
|
|
9
|
+
width: e.dimensions?.width ?? D,
|
|
10
|
+
height: e.dimensions?.height ?? I
|
|
11
|
+
}
|
|
12
|
+
})), m = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const e of l)
|
|
14
|
+
m.set(e.id, e);
|
|
15
|
+
const S = l.map((e) => ({
|
|
16
|
+
id: e.id,
|
|
17
|
+
x: e.position.x,
|
|
18
|
+
y: e.position.y,
|
|
19
|
+
width: e.dimensions.width,
|
|
20
|
+
height: e.dimensions.height,
|
|
21
|
+
...e.class ? { class: e.class } : {},
|
|
22
|
+
...e.style ? {
|
|
23
|
+
style: typeof e.style == "string" ? e.style : Object.entries(e.style).map(([o, a]) => `${o}:${a}`).join(";")
|
|
24
|
+
} : {},
|
|
25
|
+
data: e.data ?? {}
|
|
26
|
+
})), k = v.filter((e) => !e.hidden), b = [], i = /* @__PURE__ */ new Map();
|
|
27
|
+
for (const e of k) {
|
|
28
|
+
const o = m.get(e.source), a = m.get(e.target);
|
|
29
|
+
if (!o || !a)
|
|
30
|
+
continue;
|
|
31
|
+
let P, g;
|
|
32
|
+
try {
|
|
33
|
+
const s = F(
|
|
34
|
+
e,
|
|
35
|
+
o,
|
|
36
|
+
a,
|
|
37
|
+
o.sourcePosition ?? "bottom",
|
|
38
|
+
a.targetPosition ?? "top"
|
|
39
|
+
);
|
|
40
|
+
P = s.path, g = s.labelPosition;
|
|
41
|
+
} catch {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
let u, f;
|
|
45
|
+
if (e.markerStart) {
|
|
46
|
+
const s = w(e.markerStart), t = E(s, y);
|
|
47
|
+
i.has(t) || i.set(t, N(s, t)), u = `url(#${t})`;
|
|
48
|
+
}
|
|
49
|
+
if (e.markerEnd) {
|
|
50
|
+
const s = w(e.markerEnd), t = E(s, y);
|
|
51
|
+
i.has(t) || i.set(t, N(s, t)), f = `url(#${t})`;
|
|
52
|
+
}
|
|
53
|
+
let c, h;
|
|
54
|
+
if (e.label)
|
|
55
|
+
if (g)
|
|
56
|
+
c = g.x, h = g.y;
|
|
57
|
+
else {
|
|
58
|
+
const s = o.position.x + o.dimensions.width / 2, t = o.position.y + o.dimensions.height / 2, A = a.position.x + a.dimensions.width / 2, T = a.position.y + a.dimensions.height / 2;
|
|
59
|
+
c = (s + A) / 2, h = (t + T) / 2;
|
|
60
|
+
}
|
|
61
|
+
b.push({
|
|
62
|
+
id: e.id,
|
|
63
|
+
source: e.source,
|
|
64
|
+
target: e.target,
|
|
65
|
+
pathD: P,
|
|
66
|
+
...u ? { markerStart: u } : {},
|
|
67
|
+
...f ? { markerEnd: f } : {},
|
|
68
|
+
...e.class ? { class: e.class } : {},
|
|
69
|
+
...e.label ? { label: e.label } : {},
|
|
70
|
+
...c !== void 0 ? { labelX: c } : {},
|
|
71
|
+
...h !== void 0 ? { labelY: h } : {}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const C = Array.from(i.values()).join(`
|
|
75
|
+
`);
|
|
76
|
+
let n, p;
|
|
77
|
+
if (l.length === 0)
|
|
78
|
+
n = { x: 0, y: 0, width: 0, height: 0 }, p = { x: 0, y: 0, zoom: 1 };
|
|
79
|
+
else {
|
|
80
|
+
const e = B(l);
|
|
81
|
+
n = {
|
|
82
|
+
x: e.x - d,
|
|
83
|
+
y: e.y - d,
|
|
84
|
+
width: e.width + d * 2,
|
|
85
|
+
height: e.height + d * 2
|
|
86
|
+
}, p = {
|
|
87
|
+
x: -n.x,
|
|
88
|
+
y: -n.y,
|
|
89
|
+
zoom: 1
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
nodes: S,
|
|
94
|
+
edges: b,
|
|
95
|
+
markers: C,
|
|
96
|
+
viewBox: n,
|
|
97
|
+
viewport: p
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
$ as ComputeEngine,
|
|
102
|
+
j as FlowHistory,
|
|
103
|
+
V as SHORTCUT_DEFAULTS,
|
|
104
|
+
X as along,
|
|
105
|
+
Y as areNodesConnected,
|
|
106
|
+
W as buildNodeMap,
|
|
107
|
+
G as clampToExtent,
|
|
108
|
+
K as clampToParent,
|
|
109
|
+
_ as computeRenderPlan,
|
|
110
|
+
Z as computeValidationErrors,
|
|
111
|
+
q as computeZIndex,
|
|
112
|
+
J as default,
|
|
113
|
+
Q as drift,
|
|
114
|
+
ee as expandParentToFitChild,
|
|
115
|
+
te as getAbsolutePosition,
|
|
116
|
+
se as getAutoPanDelta,
|
|
117
|
+
oe as getBezierPath,
|
|
118
|
+
ae as getConnectedEdges,
|
|
119
|
+
ie as getDescendantIds,
|
|
120
|
+
ne as getEdgePosition,
|
|
121
|
+
re as getFloatingEdgeParams,
|
|
122
|
+
de as getIncomers,
|
|
123
|
+
le as getNodeIntersection,
|
|
124
|
+
B as getNodesBounds,
|
|
125
|
+
ge as getNodesFullyInPolygon,
|
|
126
|
+
Le as getNodesFullyInRect,
|
|
127
|
+
ce as getNodesInPolygon,
|
|
128
|
+
Ue as getNodesInRect,
|
|
129
|
+
he as getOutgoers,
|
|
130
|
+
me as getSimpleBezierPath,
|
|
131
|
+
pe as getSimpleFloatingPosition,
|
|
132
|
+
ue as getSmoothStepPath,
|
|
133
|
+
fe as getStepPath,
|
|
134
|
+
ye as getStraightPath,
|
|
135
|
+
$e as getViewportForBounds,
|
|
136
|
+
be as isConnectable,
|
|
137
|
+
Pe as isDeletable,
|
|
138
|
+
we as isDraggable,
|
|
139
|
+
Ee as isResizable,
|
|
140
|
+
Ne as isSelectable,
|
|
141
|
+
xe as matchesKey,
|
|
142
|
+
ve as matchesModifier,
|
|
143
|
+
De as orbit,
|
|
144
|
+
Ie as pendulum,
|
|
145
|
+
Se as pointInPolygon,
|
|
146
|
+
ke as polygonIntersectsAABB,
|
|
147
|
+
Ce as registerMarker,
|
|
148
|
+
Ae as resolveChildValidation,
|
|
149
|
+
Te as resolveShortcuts,
|
|
150
|
+
Fe as sortNodesTopological,
|
|
151
|
+
Me as stagger,
|
|
152
|
+
Re as toAbsoluteNode,
|
|
153
|
+
Be as toAbsoluteNodes,
|
|
154
|
+
ze as validateChildAdd,
|
|
155
|
+
He as validateChildRemove,
|
|
156
|
+
Oe as wave
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=alpineflow.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpineflow.esm.js","sources":["../src/core/render-plan.ts"],"sourcesContent":["// ============================================================================\n// Render Plan — SSR/SSG Pre-computation\n//\n// Pure function that computes all layout, edge paths, markers, and viewport\n// data needed to render a flow diagram without JavaScript. No DOM dependencies.\n// ============================================================================\n\nimport type { FlowNode, FlowEdge, Rect, Viewport } from './types';\nimport { getEdgePath } from './edge-utils';\nimport { normalizeMarker, getMarkerId, getMarkerSvg } from './markers';\nimport { getNodesBounds, DEFAULT_NODE_WIDTH, DEFAULT_NODE_HEIGHT } from './geometry';\n\n// ─── Public Types ────────────────────────────────────────────────────────────\n\n/** A single node in the render plan output. */\nexport interface RenderPlanNode {\n id: string;\n x: number;\n y: number;\n width: number;\n height: number;\n class?: string;\n style?: string;\n data: Record<string, any>;\n}\n\n/** A single edge in the render plan output. */\nexport interface RenderPlanEdge {\n id: string;\n source: string;\n target: string;\n pathD: string;\n markerStart?: string;\n markerEnd?: string;\n class?: string;\n label?: string;\n labelX?: number;\n labelY?: number;\n}\n\n/** Full render plan returned by computeRenderPlan(). */\nexport interface RenderPlan {\n nodes: RenderPlanNode[];\n edges: RenderPlanEdge[];\n markers: string;\n viewBox: Rect;\n viewport: Viewport;\n}\n\n/** Optional configuration for computeRenderPlan(). */\nexport interface RenderPlanConfig {\n /** Default dimensions for nodes without explicit dimensions. Default: { width: 150, height: 50 } */\n defaultDimensions?: { width: number; height: number };\n /** Padding around the viewBox in flow-space pixels. Default: 20 */\n padding?: number;\n /** Flow ID used for marker ID generation. Default: 'ssr' */\n flowId?: string;\n}\n\n// ─── Core Function ───────────────────────────────────────────────────────────\n\n/**\n * Compute a complete render plan from nodes and edges.\n *\n * Pre-computes edge SVG paths, marker defs, and viewport so a flow diagram\n * can be rendered server-side without any DOM or JavaScript.\n */\nexport function computeRenderPlan(\n nodes: FlowNode[],\n edges: FlowEdge[],\n config?: RenderPlanConfig,\n): RenderPlan {\n const defaultWidth = config?.defaultDimensions?.width ?? DEFAULT_NODE_WIDTH;\n const defaultHeight = config?.defaultDimensions?.height ?? DEFAULT_NODE_HEIGHT;\n const padding = config?.padding ?? 20;\n const flowId = config?.flowId ?? 'ssr';\n\n // ── 1. Filter hidden nodes, ensure dimensions ──────────────────────────\n\n const visibleNodes = nodes.filter((n) => !n.hidden);\n\n // Build prepared nodes with guaranteed dimensions for path computation\n const preparedNodes: FlowNode[] = visibleNodes.map((n) => ({\n ...n,\n dimensions: {\n width: n.dimensions?.width ?? defaultWidth,\n height: n.dimensions?.height ?? defaultHeight,\n },\n }));\n\n // Build node lookup map\n const nodeMap = new Map<string, FlowNode>();\n for (const n of preparedNodes) {\n nodeMap.set(n.id, n);\n }\n\n // ── 2. Build output nodes ──────────────────────────────────────────────\n\n const outputNodes: RenderPlanNode[] = preparedNodes.map((n) => ({\n id: n.id,\n x: n.position.x,\n y: n.position.y,\n width: n.dimensions!.width,\n height: n.dimensions!.height,\n ...(n.class ? { class: n.class } : {}),\n ...(n.style\n ? {\n style: typeof n.style === 'string'\n ? n.style\n : Object.entries(n.style).map(([k, v]) => `${k}:${v}`).join(';'),\n }\n : {}),\n data: n.data ?? {},\n }));\n\n // ── 3. Process edges ───────────────────────────────────────────────────\n\n const visibleEdges = edges.filter((e) => !e.hidden);\n const outputEdges: RenderPlanEdge[] = [];\n const markerDefs = new Map<string, string>(); // id → SVG markup\n\n for (const edge of visibleEdges) {\n const sourceNode = nodeMap.get(edge.source);\n const targetNode = nodeMap.get(edge.target);\n\n // Skip edges with missing endpoints\n if (!sourceNode || !targetNode) {\n continue;\n }\n\n // Compute edge path — getEdgePath returns an EdgePathResult object\n let pathD: string;\n let pathLabelPosition: { x: number; y: number } | undefined;\n try {\n const result = getEdgePath(\n edge,\n sourceNode,\n targetNode,\n sourceNode.sourcePosition ?? 'bottom',\n targetNode.targetPosition ?? 'top',\n );\n pathD = result.path;\n pathLabelPosition = result.labelPosition;\n } catch {\n // Skip edges whose path computation fails (e.g. unrecognized type)\n continue;\n }\n\n // Collect markers\n let markerStartRef: string | undefined;\n let markerEndRef: string | undefined;\n\n if (edge.markerStart) {\n const cfg = normalizeMarker(edge.markerStart);\n const id = getMarkerId(cfg, flowId);\n if (!markerDefs.has(id)) {\n markerDefs.set(id, getMarkerSvg(cfg, id));\n }\n markerStartRef = `url(#${id})`;\n }\n\n if (edge.markerEnd) {\n const cfg = normalizeMarker(edge.markerEnd);\n const id = getMarkerId(cfg, flowId);\n if (!markerDefs.has(id)) {\n markerDefs.set(id, getMarkerSvg(cfg, id));\n }\n markerEndRef = `url(#${id})`;\n }\n\n // Compute label position — prefer the path's computed midpoint, fall back to node-center midpoint\n let labelX: number | undefined;\n let labelY: number | undefined;\n if (edge.label) {\n if (pathLabelPosition) {\n labelX = pathLabelPosition.x;\n labelY = pathLabelPosition.y;\n } else {\n const srcCenterX = sourceNode.position.x + sourceNode.dimensions!.width / 2;\n const srcCenterY = sourceNode.position.y + sourceNode.dimensions!.height / 2;\n const tgtCenterX = targetNode.position.x + targetNode.dimensions!.width / 2;\n const tgtCenterY = targetNode.position.y + targetNode.dimensions!.height / 2;\n labelX = (srcCenterX + tgtCenterX) / 2;\n labelY = (srcCenterY + tgtCenterY) / 2;\n }\n }\n\n outputEdges.push({\n id: edge.id,\n source: edge.source,\n target: edge.target,\n pathD,\n ...(markerStartRef ? { markerStart: markerStartRef } : {}),\n ...(markerEndRef ? { markerEnd: markerEndRef } : {}),\n ...(edge.class ? { class: edge.class } : {}),\n ...(edge.label ? { label: edge.label } : {}),\n ...(labelX !== undefined ? { labelX } : {}),\n ...(labelY !== undefined ? { labelY } : {}),\n });\n }\n\n // ── 4. Build markers string ────────────────────────────────────────────\n\n const markers = Array.from(markerDefs.values()).join('\\n');\n\n // ── 5. Compute viewBox and viewport ────────────────────────────────────\n\n let viewBox: Rect;\n let viewport: Viewport;\n\n if (preparedNodes.length === 0) {\n viewBox = { x: 0, y: 0, width: 0, height: 0 };\n viewport = { x: 0, y: 0, zoom: 1 };\n } else {\n const bounds = getNodesBounds(preparedNodes);\n viewBox = {\n x: bounds.x - padding,\n y: bounds.y - padding,\n width: bounds.width + padding * 2,\n height: bounds.height + padding * 2,\n };\n viewport = {\n x: -viewBox.x,\n y: -viewBox.y,\n zoom: 1,\n };\n }\n\n return {\n nodes: outputNodes,\n edges: outputEdges,\n markers,\n viewBox,\n viewport,\n };\n}\n"],"names":["computeRenderPlan","nodes","edges","config","defaultWidth","DEFAULT_NODE_WIDTH","defaultHeight","DEFAULT_NODE_HEIGHT","padding","flowId","preparedNodes","n","nodeMap","outputNodes","k","v","visibleEdges","outputEdges","markerDefs","edge","sourceNode","targetNode","pathD","pathLabelPosition","result","getEdgePath","markerStartRef","markerEndRef","cfg","normalizeMarker","id","getMarkerId","getMarkerSvg","labelX","labelY","srcCenterX","srcCenterY","tgtCenterX","tgtCenterY","markers","viewBox","viewport","bounds","getNodesBounds"],"mappings":";;;;AAmEO,SAASA,EACdC,GACAC,GACAC,GACY;AACZ,QAAMC,IAAeD,GAAQ,mBAAmB,SAASE,GACnDC,IAAgBH,GAAQ,mBAAmB,UAAUI,GACrDC,IAAUL,GAAQ,WAAW,IAC7BM,IAASN,GAAQ,UAAU,OAO3BO,IAHeT,EAAM,OAAO,CAACU,MAAM,CAACA,EAAE,MAAM,EAGH,IAAI,CAACA,OAAO;AAAA,IACzD,GAAGA;AAAA,IACH,YAAY;AAAA,MACV,OAAOA,EAAE,YAAY,SAASP;AAAA,MAC9B,QAAQO,EAAE,YAAY,U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EAAA,IAAW,CAAA;AAAA,MACxC,GAAIC,MAAW,SAAY,EAAE,QAAAA,MAAW,CAAA;AAAA,IAAC,CAC1C;AAAA,EACH;AAIA,QAAMK,IAAU,MAAM,KAAKrB,EAAW,QAAQ,EAAE,KAAK;AAAA,CAAI;AAIzD,MAAIsB,GACAC;AAEJ,MAAI/B,EAAc,WAAW;AAC3B,IAAA8B,IAAU,EAAE,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,QAAQ,EAAA,GAC1CC,IAAW,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,EAAA;AAAA,OAC1B;AACL,UAAMC,IAASC,EAAejC,CAAa;AAC3C,IAAA8B,IAAU;AAAA,MACR,GAAGE,EAAO,IAAIlC;AAAA,MACd,GAAGkC,EAAO,IAAIlC;AAAA,MACd,OAAOkC,EAAO,QAAQlC,IAAU;AAAA,MAChC,QAAQkC,EAAO,SAASlC,IAAU;AAAA,IAAA,GAEpCiC,IAAW;AAAA,MACT,GAAG,CAACD,EAAQ;AAAA,MACZ,GAAG,CAACA,EAAQ;AAAA,MACZ,MAAM;AAAA,IAAA;AAAA,EAEV;AAEA,SAAO;AAAA,IACL,OAAO3B;AAAA,IACP,OAAOI;AAAA,IACP,SAAAsB;AAAA,IACA,SAAAC;AAAA,IACA,UAAAC;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpineflow.js","sources":["../lib/core.cdn.ts"],"sourcesContent":["import AlpineFlow from './core';\n\ndocument.addEventListener('alpine:init', () => {\n (window as any).Alpine.plugin(AlpineFlow);\n});\n"],"names":["AlpineFlow"],"mappings":";AAEA,SAAS,iBAAiB,eAAe,MAAM;AAC5C,SAAe,OAAO,OAAOA,CAAU;AAC1C,CAAC;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { g as P, d as V } from "./geometry-DZSZoYHE.js";
|
|
2
|
+
function A(e) {
|
|
3
|
+
return e.replace(/\s+(?:@|:|x-)[\w.:-]*="[^"]*"/g, "").replace(/\s+externalResourcesRequired="[^"]*"/g, "");
|
|
4
|
+
}
|
|
5
|
+
function B(e, t, c, w) {
|
|
6
|
+
return new Promise((s, g) => {
|
|
7
|
+
const n = new Image();
|
|
8
|
+
n.onload = () => {
|
|
9
|
+
const a = document.createElement("canvas");
|
|
10
|
+
a.width = t, a.height = c;
|
|
11
|
+
const l = a.getContext("2d");
|
|
12
|
+
l.fillStyle = w, l.fillRect(0, 0, t, c), l.drawImage(n, 0, 0), s(a.toDataURL("image/png"));
|
|
13
|
+
}, n.onerror = () => {
|
|
14
|
+
g(new Error("Failed to render SVG to image"));
|
|
15
|
+
}, n.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(e);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async function N(e, t, c, w, s = {}) {
|
|
19
|
+
let g;
|
|
20
|
+
try {
|
|
21
|
+
({ toSvg: g } = await import("./index-L3Zm-CoX.js"));
|
|
22
|
+
} catch {
|
|
23
|
+
throw new Error("toImage() requires html-to-image. Install it with: npm install html-to-image");
|
|
24
|
+
}
|
|
25
|
+
const n = s.scope ?? "all", a = e.getBoundingClientRect(), l = n === "viewport" ? a.width : s.width ?? 1920, r = n === "viewport" ? a.height : s.height ?? 1080, v = s.background ?? (getComputedStyle(e).getPropertyValue("--flow-bg-color").trim() || "#ffffff"), b = t.style.transform, C = t.style.width, R = t.style.height, I = e.style.width, S = e.style.height, $ = e.style.overflow, p = [];
|
|
26
|
+
try {
|
|
27
|
+
if (n === "all") {
|
|
28
|
+
const o = e.querySelectorAll("[data-flow-culled]");
|
|
29
|
+
for (const h of o)
|
|
30
|
+
h.style.display = "", p.push(h);
|
|
31
|
+
const m = c.filter((h) => !h.hidden), y = P(m), q = s.padding ?? 0.1, u = V(
|
|
32
|
+
y,
|
|
33
|
+
l,
|
|
34
|
+
r,
|
|
35
|
+
0.1,
|
|
36
|
+
// minZoom
|
|
37
|
+
2,
|
|
38
|
+
// maxZoom
|
|
39
|
+
q
|
|
40
|
+
);
|
|
41
|
+
t.style.transform = `translate(${u.x}px, ${u.y}px) scale(${u.zoom})`, t.style.width = `${l}px`, t.style.height = `${r}px`;
|
|
42
|
+
}
|
|
43
|
+
e.style.width = `${l}px`, e.style.height = `${r}px`, e.style.overflow = "hidden", await new Promise((o) => requestAnimationFrame(o));
|
|
44
|
+
const i = s.includeOverlays, d = i === !0, f = typeof i == "object" ? i : {}, k = [
|
|
45
|
+
["canvas-overlay", d || (f.toolbar ?? !1)],
|
|
46
|
+
["flow-minimap", d || (f.minimap ?? !1)],
|
|
47
|
+
["flow-controls", d || (f.controls ?? !1)],
|
|
48
|
+
["flow-panel", d || (f.panels ?? !1)],
|
|
49
|
+
["flow-selection-box", !1]
|
|
50
|
+
], F = await g(e, {
|
|
51
|
+
width: l,
|
|
52
|
+
height: r,
|
|
53
|
+
skipFonts: !0,
|
|
54
|
+
filter: (o) => {
|
|
55
|
+
if (o.classList) {
|
|
56
|
+
for (const [m, y] of k)
|
|
57
|
+
if (o.classList.contains(m) && !y) return !1;
|
|
58
|
+
}
|
|
59
|
+
return !0;
|
|
60
|
+
}
|
|
61
|
+
}), U = A(decodeURIComponent(F.substring("data:image/svg+xml;charset=utf-8,".length))), x = await B(U, l, r, v);
|
|
62
|
+
if (s.filename) {
|
|
63
|
+
const o = document.createElement("a");
|
|
64
|
+
o.download = s.filename, o.href = x, o.click();
|
|
65
|
+
}
|
|
66
|
+
return x;
|
|
67
|
+
} finally {
|
|
68
|
+
t.style.transform = b, t.style.width = C, t.style.height = R, e.style.width = I, e.style.height = S, e.style.overflow = $;
|
|
69
|
+
for (const i of p)
|
|
70
|
+
i.style.display = "none";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
N as captureFlowImage
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=export-DjmXOnKD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-DjmXOnKD.js","sources":["../src/core/export.ts"],"sourcesContent":["// ============================================================================\n// Export Utilities\n//\n// Captures the flow canvas as a PNG image via html-to-image (dynamically\n// imported). Supports full-graph and viewport-only capture modes.\n//\n// Uses toSvg() + manual canvas rendering instead of toPng() directly,\n// because Alpine.js directives (@click, x-data, :class) produce attribute\n// names with @ and : that are invalid XML — breaking the SVG foreignObject\n// when loaded as an <img>.\n// ============================================================================\n\nimport { getNodesBounds, getViewportForBounds } from './geometry';\nimport type { FlowNode, Viewport, ToImageOptions } from './types';\n\n/**\n * Strip attributes whose names are invalid in XML (e.g. Alpine's @click, :class).\n * Also removes externalResourcesRequired which can cause image load failures.\n */\nfunction sanitizeSvg(svg: string): string {\n return svg\n // Remove Alpine-style attributes that are invalid XML:\n // @click=\"...\" :class=\"...\" x-data=\"...\" x-flow-handle:target=\"...\"\n .replace(/\\s+(?:@|:|x-)[\\w.:-]*=\"[^\"]*\"/g, '')\n // Remove externalResourcesRequired (can cause image load failures)\n .replace(/\\s+externalResourcesRequired=\"[^\"]*\"/g, '');\n}\n\n/**\n * Render a sanitized SVG string to a PNG data URL via canvas.\n */\nfunction svgToPng(svgString: string, width: number, height: number, background: string): Promise<string> {\n return new Promise((resolve, reject) => {\n const img = new Image();\n\n img.onload = () => {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n const ctx = canvas.getContext('2d')!;\n ctx.fillStyle = background;\n ctx.fillRect(0, 0, width, height);\n ctx.drawImage(img, 0, 0);\n resolve(canvas.toDataURL('image/png'));\n };\n\n img.onerror = () => {\n reject(new Error('Failed to render SVG to image'));\n };\n\n // Use data URL (not Blob URL) — Blob URLs taint the canvas\n // when the SVG contains foreignObject\n img.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svgString);\n });\n}\n\n/**\n * Capture the flow canvas as a PNG data URL.\n *\n * @param container The .flow-container element\n * @param viewportEl The .flow-viewport element\n * @param nodes All non-hidden nodes (for bounds calculation)\n * @param viewport Current viewport state\n * @param options Export options\n * @returns data:image/png;base64,... string\n */\nexport async function captureFlowImage(\n container: HTMLElement,\n viewportEl: HTMLElement,\n nodes: FlowNode[],\n viewport: Viewport,\n options: ToImageOptions = {},\n): Promise<string> {\n let toSvg: (node: HTMLElement, options?: any) => Promise<string>;\n try {\n ({ toSvg } = await import('html-to-image'));\n } catch {\n throw new Error('toImage() requires html-to-image. Install it with: npm install html-to-image');\n }\n\n const scope = options.scope ?? 'all';\n const containerRect = container.getBoundingClientRect();\n\n // Determine image dimensions\n const imageWidth = scope === 'viewport'\n ? containerRect.width\n : (options.width ?? 1920);\n const imageHeight = scope === 'viewport'\n ? containerRect.height\n : (options.height ?? 1080);\n\n // Resolve background color\n const background = options.background\n ?? (getComputedStyle(container).getPropertyValue('--flow-bg-color').trim()\n || '#ffffff');\n\n // Save original state\n const origTransform = viewportEl.style.transform;\n const origWidth = viewportEl.style.width;\n const origHeight = viewportEl.style.height;\n const origContainerWidth = container.style.width;\n const origContainerHeight = container.style.height;\n const origContainerOverflow = container.style.overflow;\n\n // Track culled nodes to temporarily reveal them\n const revealedNodes: HTMLElement[] = [];\n\n try {\n if (scope === 'all') {\n // Temporarily reveal all culled nodes\n const nodeEls = container.querySelectorAll<HTMLElement>('[data-flow-culled]');\n for (const el of nodeEls) {\n el.style.display = '';\n revealedNodes.push(el);\n }\n\n // Calculate viewport to fit all nodes\n const visibleNodes = nodes.filter(n => !n.hidden);\n const bounds = getNodesBounds(visibleNodes);\n const padding = options.padding ?? 0.1;\n const exportViewport = getViewportForBounds(\n bounds,\n imageWidth,\n imageHeight,\n 0.1, // minZoom\n 2, // maxZoom\n padding,\n );\n\n // Apply export transform\n viewportEl.style.transform = `translate(${exportViewport.x}px, ${exportViewport.y}px) scale(${exportViewport.zoom})`;\n viewportEl.style.width = `${imageWidth}px`;\n viewportEl.style.height = `${imageHeight}px`;\n }\n\n // Force container size for capture\n container.style.width = `${imageWidth}px`;\n container.style.height = `${imageHeight}px`;\n container.style.overflow = 'hidden';\n\n // Wait one frame for the DOM to settle\n await new Promise(resolve => requestAnimationFrame(resolve));\n\n // Generate SVG via html-to-image, then sanitize and render manually.\n // We use toSvg + manual canvas instead of toPng because Alpine.js\n // attributes (@click, :class, x-data) are invalid XML attribute names\n // that break the SVG foreignObject when loaded as an <img>.\n // By default, exclude UI overlays (toolbar, minimap, controls, panels)\n const overlayConfig = options.includeOverlays;\n const includeAll = overlayConfig === true;\n const perOverlay = typeof overlayConfig === 'object' ? overlayConfig : {};\n\n // Map CSS classes to their include/exclude state.\n // Selection box is always excluded (ephemeral UI state).\n const overlayRules: [string, boolean][] = [\n ['canvas-overlay', includeAll || (perOverlay.toolbar ?? false)],\n ['flow-minimap', includeAll || (perOverlay.minimap ?? false)],\n ['flow-controls', includeAll || (perOverlay.controls ?? false)],\n ['flow-panel', includeAll || (perOverlay.panels ?? false)],\n ['flow-selection-box', false],\n ];\n\n const svgDataUrl = await toSvg(container, {\n width: imageWidth,\n height: imageHeight,\n skipFonts: true,\n filter: (node: Element) => {\n if (node.classList) {\n for (const [cls, include] of overlayRules) {\n if (node.classList.contains(cls) && !include) return false;\n }\n }\n return true;\n },\n });\n\n // Decode the SVG, sanitize invalid XML, render to PNG\n const prefix = 'data:image/svg+xml;charset=utf-8,';\n const svgString = sanitizeSvg(decodeURIComponent(svgDataUrl.substring(prefix.length)));\n const dataUrl = await svgToPng(svgString, imageWidth, imageHeight, background);\n\n // Auto-download if filename provided\n if (options.filename) {\n const link = document.createElement('a');\n link.download = options.filename;\n link.href = dataUrl;\n link.click();\n }\n\n return dataUrl;\n } finally {\n // Restore original state\n viewportEl.style.transform = origTransform;\n viewportEl.style.width = origWidth;\n viewportEl.style.height = origHeight;\n container.style.width = origContainerWidth;\n container.style.height = origContainerHeight;\n container.style.overflow = origContainerOverflow;\n\n // Re-hide culled nodes\n for (const el of revealedNodes) {\n el.style.display = 'none';\n }\n }\n}\n"],"names":["sanitizeSvg","svg","svgToPng","svgString","width","height","background","resolve","reject","img","canvas","ctx","captureFlowImage","container","viewportEl","nodes","viewport","options","toSvg","scope","containerRect","imageWidth","imageHeight","origTransform","origWidth","origHeight","origContainerWidth","origContainerHeight","origContainerOverflow","revealedNodes","nodeEls","el","visibleNodes","n","bounds","getNodesBounds","padding","exportViewport","getViewportForBounds","overlayConfig","includeAll","perOverlay","overlayRules","svgDataUrl","node","cls","include","dataUrl","link"],"mappings":";AAmBA,SAASA,EAAYC,GAAqB;AACxC,SAAOA,EAGJ,QAAQ,kCAAkC,EAAE,EAE5C,QAAQ,yCAAyC,EAAE;AACxD;AAKA,SAASC,EAASC,GAAmBC,GAAeC,GAAgBC,GAAqC;AACvG,SAAO,IAAI,QAAQ,CAACC,GAASC,MAAW;AACtC,UAAMC,IAAM,IAAI,MAAA;AAEhB,IAAAA,EAAI,SAAS,MAAM;AACjB,YAAMC,IAAS,SAAS,cAAc,QAAQ;AAC9C,MAAAA,EAAO,QAAQN,GACfM,EAAO,SAASL;AAChB,YAAMM,IAAMD,EAAO,WAAW,IAAI;AAClC,MAAAC,EAAI,YAAYL,GAChBK,EAAI,SAAS,GAAG,GAAGP,GAAOC,CAAM,GAChCM,EAAI,UAAUF,GAAK,GAAG,CAAC,GACvBF,EAAQG,EAAO,UAAU,WAAW,CAAC;AAAA,IACvC,GAEAD,EAAI,UAAU,MAAM;AAClB,MAAAD,EAAO,IAAI,MAAM,+BAA+B,CAAC;AAAA,IACnD,GAIAC,EAAI,MAAM,sCAAsC,mBAAmBN,CAAS;AAAA,EAC9E,CAAC;AACH;AAYA,eAAsBS,EACpBC,GACAC,GACAC,GACAC,GACAC,IAA0B,IACT;AACjB,MAAIC;AACJ,MAAI;AACF,KAAC,EAAE,OAAAA,EAAA,IAAU,MAAM,OAAO,qBAAe;AAAA,EAC3C,QAAQ;AACN,UAAM,IAAI,MAAM,8EAA8E;AAAA,EAChG;AAEA,QAAMC,IAAQF,EAAQ,SAAS,OACzBG,IAAgBP,EAAU,sBAAA,GAG1BQ,IAAaF,MAAU,aACzBC,EAAc,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n.zoom
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
function z(t, o, n, i) {
|
|
8
|
+
return {
|
|
9
|
+
x: t * n.zoom + n.x + i.left,
|
|
10
|
+
y: o * n.zoom + n.y + i.top
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const d = 150, g = 50;
|
|
14
|
+
function f(t, o, n, i, c) {
|
|
15
|
+
if (c % 360 === 0) return { x: t, y: o, width: n, height: i };
|
|
16
|
+
const h = c * Math.PI / 180, e = Math.abs(Math.cos(h)), a = Math.abs(Math.sin(h)), x = n * e + i * a, s = n * a + i * e, y = t + n / 2, m = o + i / 2;
|
|
17
|
+
return { x: y - x / 2, y: m - s / 2, width: x, height: s };
|
|
18
|
+
}
|
|
19
|
+
function B(t, o) {
|
|
20
|
+
if (t.length === 0)
|
|
21
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
|
22
|
+
let n = 1 / 0, i = 1 / 0, c = -1 / 0, h = -1 / 0;
|
|
23
|
+
for (const e of t) {
|
|
24
|
+
const a = e.dimensions?.width ?? d, x = e.dimensions?.height ?? g, s = r(e, o), y = e.rotation ? f(s.x, s.y, a, x, e.rotation) : { x: s.x, y: s.y, width: a, height: x };
|
|
25
|
+
n = Math.min(n, y.x), i = Math.min(i, y.y), c = Math.max(c, y.x + y.width), h = Math.max(h, y.y + y.height);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
x: n,
|
|
29
|
+
y: i,
|
|
30
|
+
width: c - n,
|
|
31
|
+
height: h - i
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function D(t, o, n) {
|
|
35
|
+
const i = o.x + o.width, c = o.y + o.height;
|
|
36
|
+
return t.filter((h) => {
|
|
37
|
+
const e = h.dimensions?.width ?? d, a = h.dimensions?.height ?? g, x = r(h, n), s = h.rotation ? f(x.x, x.y, e, a, h.rotation) : { x: x.x, y: x.y, width: e, height: a }, y = s.x + s.width, m = s.y + s.height;
|
|
38
|
+
return !(y < o.x || s.x > i || m < o.y || s.y > c);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function N(t, o, n) {
|
|
42
|
+
const i = o.x + o.width, c = o.y + o.height;
|
|
43
|
+
return t.filter((h) => {
|
|
44
|
+
const e = h.dimensions?.width ?? d, a = h.dimensions?.height ?? g, x = r(h, n), s = h.rotation ? f(x.x, x.y, e, a, h.rotation) : { x: x.x, y: x.y, width: e, height: a };
|
|
45
|
+
return s.x >= o.x && s.y >= o.y && s.x + s.width <= i && s.y + s.height <= c;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function T(t, o, n, i, c, h = 0.1) {
|
|
49
|
+
const e = Math.max(t.width, 1), a = Math.max(t.height, 1), x = e * (1 + h), s = a * (1 + h), y = o / x, m = n / s, u = Math.min(Math.max(Math.min(y, m), i), c), l = { x: t.x + e / 2, y: t.y + a / 2 }, M = o / 2 - l.x * u, w = n / 2 - l.y * u;
|
|
50
|
+
return { x: M, y: w, zoom: u };
|
|
51
|
+
}
|
|
52
|
+
function E(t, o, n, i) {
|
|
53
|
+
const c = 1 / t.zoom;
|
|
54
|
+
return {
|
|
55
|
+
minX: (0 - t.x) * c - i,
|
|
56
|
+
minY: (0 - t.y) * c - i,
|
|
57
|
+
maxX: (o - t.x) * c + i,
|
|
58
|
+
maxY: (n - t.y) * c + i
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function r(t, o) {
|
|
62
|
+
if (!t.position) return { x: 0, y: 0 };
|
|
63
|
+
const n = t.nodeOrigin ?? o ?? [0, 0], i = t.dimensions?.width ?? d, c = t.dimensions?.height ?? g;
|
|
64
|
+
return {
|
|
65
|
+
x: t.position.x - i * n[0],
|
|
66
|
+
y: t.position.y - c * n[1]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
d as D,
|
|
71
|
+
g as a,
|
|
72
|
+
N as b,
|
|
73
|
+
D as c,
|
|
74
|
+
T as d,
|
|
75
|
+
f as e,
|
|
76
|
+
r as f,
|
|
77
|
+
B as g,
|
|
78
|
+
z as h,
|
|
79
|
+
E as i,
|
|
80
|
+
I as s
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=geometry-DZSZoYHE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry-DZSZoYHE.js","sources":["../src/core/geometry.ts"],"sourcesContent":["// ============================================================================\n// Geometry Utilities\n//\n// Coordinate transforms between screen space and flow space, bounding box\n// calculations for fitView, and DOM measurement helpers.\n// ============================================================================\n\nimport type { XYPosition, Viewport, Rect, Dimensions, FlowNode } from './types';\n\n/**\n * Convert screen (client) coordinates to flow coordinates.\n */\nexport function screenToFlowPosition(\n screenX: number,\n screenY: number,\n viewport: Viewport,\n containerRect: DOMRect,\n): XYPosition {\n return {\n x: (screenX - containerRect.left - viewport.x) / viewport.zoom,\n y: (screenY - containerRect.top - viewport.y) / viewport.zoom,\n };\n}\n\n/**\n * Convert flow coordinates to screen (client) coordinates.\n */\nexport function flowToScreenPosition(\n flowX: number,\n flowY: number,\n viewport: Viewport,\n containerRect: DOMRect,\n): XYPosition {\n return {\n x: flowX * viewport.zoom + viewport.x + containerRect.left,\n y: flowY * viewport.zoom + viewport.y + containerRect.top,\n };\n}\n\n/**\n * Calculate the bounding box that contains all given nodes.\n */\nexport const DEFAULT_NODE_WIDTH = 150;\nexport const DEFAULT_NODE_HEIGHT = 50;\n\n/**\n * Compute the axis-aligned bounding box of a rectangle rotated around its center.\n * Returns the expanded AABB in the same coordinate space as the input.\n */\nexport function getRotatedBounds(\n x: number,\n y: number,\n w: number,\n h: number,\n rotation: number,\n): Rect {\n if (rotation % 360 === 0) return { x, y, width: w, height: h };\n\n const rad = (rotation * Math.PI) / 180;\n const cos = Math.abs(Math.cos(rad));\n const sin = Math.abs(Math.sin(rad));\n const newW = w * cos + h * sin;\n const newH = w * sin + h * cos;\n const cx = x + w / 2;\n const cy = y + h / 2;\n\n return { x: cx - newW / 2, y: cy - newH / 2, width: newW, height: newH };\n}\n\nexport function getNodesBounds(\n nodes: FlowNode[],\n globalOrigin?: [number, number],\n): Rect {\n if (nodes.length === 0) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const node of nodes) {\n const w = node.dimensions?.width ?? DEFAULT_NODE_WIDTH;\n const h = node.dimensions?.height ?? DEFAULT_NODE_HEIGHT;\n\n const vp = getNodeVisualPosition(node, globalOrigin);\n const bounds = node.rotation\n ? getRotatedBounds(vp.x, vp.y, w, h, node.rotation)\n : { x: vp.x, y: vp.y, width: w, height: h };\n\n minX = Math.min(minX, bounds.x);\n minY = Math.min(minY, bounds.y);\n maxX = Math.max(maxX, bounds.x + bounds.width);\n maxY = Math.max(maxY, bounds.y + bounds.height);\n }\n\n return {\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n };\n}\n\n/**\n * Return all nodes whose bounding box intersects the given rectangle.\n * Uses AABB intersection with DEFAULT_NODE_WIDTH/HEIGHT fallback.\n */\nexport function getNodesInRect(\n nodes: FlowNode[],\n rect: Rect,\n globalOrigin?: [number, number],\n): FlowNode[] {\n const rectRight = rect.x + rect.width;\n const rectBottom = rect.y + rect.height;\n\n return nodes.filter((node) => {\n const w = node.dimensions?.width ?? DEFAULT_NODE_WIDTH;\n const h = node.dimensions?.height ?? DEFAULT_NODE_HEIGHT;\n\n const vp = getNodeVisualPosition(node, globalOrigin);\n const bounds = node.rotation\n ? getRotatedBounds(vp.x, vp.y, w, h, node.rotation)\n : { x: vp.x, y: vp.y, width: w, height: h };\n\n const nodeRight = bounds.x + bounds.width;\n const nodeBottom = bounds.y + bounds.height;\n\n return !(\n nodeRight < rect.x ||\n bounds.x > rectRight ||\n nodeBottom < rect.y ||\n bounds.y > rectBottom\n );\n });\n}\n\n/**\n * Return all nodes whose bounding box is fully contained within the given rectangle.\n * Uses DEFAULT_NODE_WIDTH/HEIGHT fallback for nodes without measured dimensions.\n */\nexport function getNodesFullyInRect(\n nodes: FlowNode[],\n rect: Rect,\n globalOrigin?: [number, number],\n): FlowNode[] {\n const rectRight = rect.x + rect.width;\n const rectBottom = rect.y + rect.height;\n\n return nodes.filter((node) => {\n const w = node.dimensions?.width ?? DEFAULT_NODE_WIDTH;\n const h = node.dimensions?.height ?? DEFAULT_NODE_HEIGHT;\n\n const vp = getNodeVisualPosition(node, globalOrigin);\n const bounds = node.rotation\n ? getRotatedBounds(vp.x, vp.y, w, h, node.rotation)\n : { x: vp.x, y: vp.y, width: w, height: h };\n\n return (\n bounds.x >= rect.x &&\n bounds.y >= rect.y &&\n bounds.x + bounds.width <= rectRight &&\n bounds.y + bounds.height <= rectBottom\n );\n });\n}\n\n/**\n * Calculate the viewport transform needed to fit a rect into a container.\n */\nexport function getViewportForBounds(\n bounds: Rect,\n containerWidth: number,\n containerHeight: number,\n minZoom: number,\n maxZoom: number,\n padding: number = 0.1,\n): Viewport {\n const effectiveWidth = Math.max(bounds.width, 1);\n const effectiveHeight = Math.max(bounds.height, 1);\n\n const paddedWidth = effectiveWidth * (1 + padding);\n const paddedHeight = effectiveHeight * (1 + padding);\n\n const zoomX = containerWidth / paddedWidth;\n const zoomY = containerHeight / paddedHeight;\n const zoom = Math.min(Math.max(Math.min(zoomX, zoomY), minZoom), maxZoom);\n\n const boundsCenter = { x: bounds.x + effectiveWidth / 2, y: bounds.y + effectiveHeight / 2 };\n const x = containerWidth / 2 - boundsCenter.x * zoom;\n const y = containerHeight / 2 - boundsCenter.y * zoom;\n\n return { x, y, zoom };\n}\n\n// ─── Viewport Culling Utilities ─────────────────────────────────────────────\n\n/** Axis-aligned bounds (min/max form, not x/y/width/height) */\nexport interface Bounds {\n minX: number;\n minY: number;\n maxX: number;\n maxY: number;\n}\n\n/**\n * Compute the visible bounds in flow coordinates given viewport state,\n * container dimensions, and a buffer margin.\n */\nexport function getVisibleBounds(\n viewport: Viewport,\n containerWidth: number,\n containerHeight: number,\n buffer: number,\n): Bounds {\n const invZoom = 1 / viewport.zoom;\n\n return {\n minX: (0 - viewport.x) * invZoom - buffer,\n minY: (0 - viewport.y) * invZoom - buffer,\n maxX: (containerWidth - viewport.x) * invZoom + buffer,\n maxY: (containerHeight - viewport.y) * invZoom + buffer,\n };\n}\n\n/**\n * Grid-based spatial index for fast viewport queries.\n *\n * Flow space is divided into cells of `cellSize` pixels.\n * Each cell holds a Set of node IDs whose bounding boxes overlap that cell.\n * Viewport queries find all cells overlapping the query bounds, then\n * union their node sets — O(cells) instead of O(nodes).\n */\nexport class SpatialGrid {\n private _cellSize: number;\n private _cells = new Map<string, Set<string>>();\n private _nodeCells = new Map<string, string[]>();\n\n constructor(cellSize: number = 300) {\n this._cellSize = cellSize;\n }\n\n private _cellKey(cx: number, cy: number): string {\n return `${cx},${cy}`;\n }\n\n private _getCellRange(\n x: number,\n y: number,\n w: number,\n h: number,\n ): { minCX: number; minCY: number; maxCX: number; maxCY: number } {\n return {\n minCX: Math.floor(x / this._cellSize),\n minCY: Math.floor(y / this._cellSize),\n maxCX: Math.floor((x + w) / this._cellSize),\n maxCY: Math.floor((y + h) / this._cellSize),\n };\n }\n\n insert(id: string, x: number, y: number, w: number, h: number): void {\n this.remove(id);\n const { minCX, minCY, maxCX, maxCY } = this._getCellRange(x, y, w, h);\n const keys: string[] = [];\n for (let cx = minCX; cx <= maxCX; cx++) {\n for (let cy = minCY; cy <= maxCY; cy++) {\n const key = this._cellKey(cx, cy);\n keys.push(key);\n let cell = this._cells.get(key);\n if (!cell) {\n cell = new Set();\n this._cells.set(key, cell);\n }\n cell.add(id);\n }\n }\n this._nodeCells.set(id, keys);\n }\n\n remove(id: string): void {\n const keys = this._nodeCells.get(id);\n if (!keys) {\n return;\n }\n for (const key of keys) {\n const cell = this._cells.get(key);\n if (cell) {\n cell.delete(id);\n if (cell.size === 0) {\n this._cells.delete(key);\n }\n }\n }\n this._nodeCells.delete(id);\n }\n\n update(id: string, x: number, y: number, w: number, h: number): void {\n this.insert(id, x, y, w, h);\n }\n\n query(bounds: Bounds): Set<string> {\n const { minCX, minCY, maxCX, maxCY } = this._getCellRange(\n bounds.minX,\n bounds.minY,\n bounds.maxX - bounds.minX,\n bounds.maxY - bounds.minY,\n );\n const result = new Set<string>();\n for (let cx = minCX; cx <= maxCX; cx++) {\n for (let cy = minCY; cy <= maxCY; cy++) {\n const cell = this._cells.get(this._cellKey(cx, cy));\n if (cell) {\n for (const id of cell) {\n result.add(id);\n }\n }\n }\n }\n return result;\n }\n\n clear(): void {\n this._cells.clear();\n this._nodeCells.clear();\n }\n\n get size(): number {\n return this._nodeCells.size;\n }\n}\n\n// ─── Node Origin Utilities ──────────────────────────────────────────────────\n\n/**\n * Compute the pixel offset from a node's anchor point to its visual top-left corner.\n * Returns {x: 0, y: 0} for the default [0, 0] origin.\n */\nexport function getOriginOffset(\n origin: [number, number] | undefined,\n width: number,\n height: number,\n): XYPosition {\n if (!origin || (origin[0] === 0 && origin[1] === 0)) return { x: 0, y: 0 };\n return { x: -width * origin[0], y: -height * origin[1] };\n}\n\n/**\n * Get the visual top-left position of a node, accounting for nodeOrigin.\n * The node's `position` is its anchor point; this returns where the DOM\n * element's top-left corner should be placed.\n */\nexport function getNodeVisualPosition(\n node: FlowNode,\n globalOrigin?: [number, number],\n): XYPosition {\n if (!node.position) return { x: 0, y: 0 };\n const origin = node.nodeOrigin ?? globalOrigin ?? [0, 0];\n const w = node.dimensions?.width ?? DEFAULT_NODE_WIDTH;\n const h = node.dimensions?.height ?? DEFAULT_NODE_HEIGHT;\n return {\n x: node.position.x - w * origin[0],\n y: node.position.y - h * origin[1],\n };\n}\n"],"names":["screenToFlowPosition","screenX","screenY","viewport","containerRect","flowToScreenPosition","flowX","flowY","DEFAULT_NODE_WIDTH","DEFAULT_NODE_HEIGHT","getRotatedBounds","x","y","w","h","rotation","rad","cos","sin","newW","newH","cx","cy","getNodesBounds","nodes","globalOrigin","minX","minY","maxX","maxY","node","vp","getNodeVisualPosition","bounds","getNodesInRect","rect","rectRight","rectBottom","nodeRight","nodeBottom","getNodesFullyInRect","getViewportForBounds","containerWidth","containerHeight","minZoom","maxZoom","padding","effectiveWidth","effectiveHeight","paddedWidth","paddedHeight","zoomX","zoomY","zoom","boundsCenter","getVisibleBounds","buffer","invZoom","origin"],"mappings":"AAYO,SAASA,EACdC,GACAC,GACAC,GACAC,GACY;AACZ,SAAO;AAAA,IACL,IAAIH,IAAUG,EAAc,OAAOD,EAAS,KAAKA,EAAS;AAAA,IAC1D,IAAID,IAAUE,EAAc,MAAMD,EAAS,KAAKA,EAAS;AAAA,EAAA;AAE7D;AAKO,SAASE,EACdC,GACAC,GACAJ,GACAC,GACY;AACZ,SAAO;AAAA,IACL,GAAGE,IAAQH,EAAS,OAAOA,EAAS,IAAIC,EAAc;AAAA,IACtD,GAAGG,IAAQJ,EAAS,OAAOA,EAAS,IAAIC,EAAc;AAAA,EAAA;AAE1D;AAKO,MAAMI,IAAqB,KACrBC,IAAsB;AAM5B,SAASC,EACdC,GACAC,GACAC,GACAC,GACAC,GACM;AACN,MAAIA,IAAW,QAAQ,EAAG,QAAO,EAAE,GAAAJ,GAAG,GAAAC,GAAG,OAAOC,GAAG,QAAQC,EAAA;AAE3D,QAAME,IAAOD,IAAW,KAAK,KAAM,KAC7BE,IAAM,KAAK,IAAI,KAAK,IAAID,CAAG,CAAC,GAC5BE,IAAM,KAAK,IAAI,KAAK,IAAIF,CAAG,CAAC,GAC5BG,IAAON,IAAII,IAAMH,IAAII,GACrBE,IAAOP,IAAIK,IAAMJ,IAAIG,GACrBI,IAAKV,IAAIE,IAAI,GACbS,IAAKV,IAAIE,IAAI;AAEnB,SAAO,EAAE,GAAGO,IAAKF,IAAO,GAAG,GAAGG,IAAKF,IAAO,GAAG,OAAOD,GAAM,QAAQC,EAAA;AACpE;AAEO,SAASG,EACdC,GACAC,GACM;AACN,MAAID,EAAM,WAAW;AACnB,WAAO,EAAE,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,QAAQ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