@fragiola/flow-vue 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/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/connection.d.ts +1 -0
- package/dist/connection.js +1 -0
- package/dist/drag.d.ts +1 -0
- package/dist/drag.js +1 -0
- package/dist/index.d.ts +893 -0
- package/dist/index.js +2184 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard.d.ts +1 -0
- package/dist/keyboard.js +1 -0
- package/dist/minimap.d.ts +80 -0
- package/dist/minimap.js +167 -0
- package/dist/minimap.js.map +1 -0
- package/dist/primitive-h9jTIEeT.js +274 -0
- package/dist/primitive-h9jTIEeT.js.map +1 -0
- package/dist/primitive-ryVigrQO.d.ts +42 -0
- package/dist/reconnection.d.ts +1 -0
- package/dist/reconnection.js +1 -0
- package/dist/resize.d.ts +80 -0
- package/dist/resize.js +195 -0
- package/dist/resize.js.map +1 -0
- package/dist/rolldown-runtime-D8jQpDG7.js +12 -0
- package/dist/selection.d.ts +1 -0
- package/dist/selection.js +1 -0
- package/dist/subflows.d.ts +1 -0
- package/dist/subflows.js +1 -0
- package/package.json +101 -3
package/dist/minimap.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { S as useFlowContext, c as toElement, d as useFlowValue, g as MiniMapKey, l as sameValue, n as definePrimitive, o as px, r as numberProp, s as renderElement, t as NUMBER_PROP } from "./primitive-h9jTIEeT.js";
|
|
2
|
+
import { partAttributes } from "@fragiola/flow";
|
|
3
|
+
import { h, inject, provide, watchEffect } from "vue";
|
|
4
|
+
export * from "@fragiola/flow/minimap";
|
|
5
|
+
// src/minimap/mini-map-context.ts
|
|
6
|
+
/** The view of the enclosing `MiniMap`, for its nodes and its mask. */
|
|
7
|
+
function useMiniMapView(part) {
|
|
8
|
+
const view = inject(MiniMapKey, null);
|
|
9
|
+
if (!view) throw new Error(`${part} must be rendered inside MiniMap`);
|
|
10
|
+
return view;
|
|
11
|
+
}
|
|
12
|
+
// src/minimap/mini-map-mask.ts
|
|
13
|
+
/**
|
|
14
|
+
* The `MiniMap`'s mask (`data-flow-part="minimap-mask"`): an SVG path covering the map but what the
|
|
15
|
+
* root shows (`fill-rule="evenodd"`). Give it its fill.
|
|
16
|
+
*/
|
|
17
|
+
const MiniMapMask = definePrimitive("MiniMapMask", ["as"], (props, { attrs, slots }) => {
|
|
18
|
+
const view = useMiniMapView("MiniMapMask");
|
|
19
|
+
return () => renderElement({
|
|
20
|
+
tag: "path",
|
|
21
|
+
as: props.as,
|
|
22
|
+
attrs,
|
|
23
|
+
render: slots.render,
|
|
24
|
+
state: { view: view.value.view },
|
|
25
|
+
props: {
|
|
26
|
+
...partAttributes("minimap-mask"),
|
|
27
|
+
d: view.value.maskPath,
|
|
28
|
+
"fill-rule": "evenodd"
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
// src/minimap/mini-map-node.ts
|
|
33
|
+
/**
|
|
34
|
+
* A node in the `MiniMap` (`data-flow-part="minimap-node"`, `data-flow-id`): an SVG rectangle of
|
|
35
|
+
* the node's box, in flow coordinates. Nothing when the node is not shown.
|
|
36
|
+
*/
|
|
37
|
+
const MiniMapNode = definePrimitive("MiniMapNode", ["nodeId", "as"], (props, { attrs, slots }) => {
|
|
38
|
+
const view = useMiniMapView("MiniMapNode");
|
|
39
|
+
const context = useFlowContext("MiniMapNode");
|
|
40
|
+
const attributes = useFlowValue(context, () => {
|
|
41
|
+
const engine = context.engine.value;
|
|
42
|
+
return engine ? engine.adapter.attributes("minimap-node", { nodeId: props.nodeId }) : partAttributes("minimap-node", props.nodeId);
|
|
43
|
+
}, sameValue, "entity");
|
|
44
|
+
return () => {
|
|
45
|
+
const box = view.value.nodes.find((node) => node.nodeId === props.nodeId);
|
|
46
|
+
if (!box) return null;
|
|
47
|
+
const own = attributes.value;
|
|
48
|
+
return renderElement({
|
|
49
|
+
tag: "rect",
|
|
50
|
+
as: props.as,
|
|
51
|
+
attrs,
|
|
52
|
+
render: slots.render,
|
|
53
|
+
state: {
|
|
54
|
+
nodeId: props.nodeId,
|
|
55
|
+
selected: own["data-selected"] !== void 0
|
|
56
|
+
},
|
|
57
|
+
props: {
|
|
58
|
+
...own,
|
|
59
|
+
x: box.x,
|
|
60
|
+
y: box.y,
|
|
61
|
+
width: box.width,
|
|
62
|
+
height: box.height
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
// src/minimap/mini-map.ts
|
|
68
|
+
const EMPTY_VIEW = Object.freeze({
|
|
69
|
+
viewBox: Object.freeze({
|
|
70
|
+
x: 0,
|
|
71
|
+
y: 0,
|
|
72
|
+
width: 0,
|
|
73
|
+
height: 0
|
|
74
|
+
}),
|
|
75
|
+
viewBoxAttribute: "0 0 0 0",
|
|
76
|
+
scale: 1,
|
|
77
|
+
nodes: Object.freeze([]),
|
|
78
|
+
view: Object.freeze({
|
|
79
|
+
x: 0,
|
|
80
|
+
y: 0,
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 0
|
|
83
|
+
}),
|
|
84
|
+
maskPath: ""
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* A small map of the flow (`data-flow-part="minimap"`, `minimap()`): an SVG of `width` × `height`
|
|
88
|
+
* pixels showing every node and what the root shows. With `minimap()`'s options, a drag on it pans
|
|
89
|
+
* and its wheel zooms the flow. Inside `Flow.Root`, outside `Flow.Viewport`; place it with your
|
|
90
|
+
* style.
|
|
91
|
+
*/
|
|
92
|
+
const MiniMap = definePrimitive("MiniMap", [
|
|
93
|
+
"width",
|
|
94
|
+
"height",
|
|
95
|
+
"inversePan",
|
|
96
|
+
"zoomStep",
|
|
97
|
+
"as"
|
|
98
|
+
], (props, { attrs, slots, emit }) => {
|
|
99
|
+
const context = useFlowContext("MiniMap");
|
|
100
|
+
watchEffect((onCleanup) => {
|
|
101
|
+
const engine = context.engine.value;
|
|
102
|
+
if (!engine) return;
|
|
103
|
+
const options = Object.fromEntries(Object.entries({
|
|
104
|
+
inversePan: props.inversePan,
|
|
105
|
+
zoomStep: numberProp(props.zoomStep)
|
|
106
|
+
}).filter(([, value]) => value !== void 0));
|
|
107
|
+
engine.adapter.setPartOptions("minimap", "", options);
|
|
108
|
+
onCleanup(() => engine.adapter.setPartOptions("minimap", "", null));
|
|
109
|
+
});
|
|
110
|
+
let own = null;
|
|
111
|
+
const ownRef = (value) => {
|
|
112
|
+
own = toElement(value);
|
|
113
|
+
};
|
|
114
|
+
watchEffect((onCleanup) => {
|
|
115
|
+
const engine = context.engine.value;
|
|
116
|
+
if (!engine) return;
|
|
117
|
+
onCleanup(engine.subscribe((event) => {
|
|
118
|
+
if (event.type === "minimap-click" && own !== null && event.element === own) emit("click", event.event, event.point);
|
|
119
|
+
}));
|
|
120
|
+
});
|
|
121
|
+
const width = () => props.width ?? 200;
|
|
122
|
+
const height = () => props.height ?? 150;
|
|
123
|
+
const view = useFlowValue(context, () => context.engine.value?.get("minimap-view", {
|
|
124
|
+
width: width(),
|
|
125
|
+
height: height()
|
|
126
|
+
}) ?? EMPTY_VIEW, (a, b) => a === b || a.viewBoxAttribute === b.viewBoxAttribute && a.maskPath === b.maskPath && a.nodes.length === b.nodes.length && a.nodes.every((node, i) => {
|
|
127
|
+
const other = b.nodes[i];
|
|
128
|
+
return other !== void 0 && node.nodeId === other.nodeId && node.x === other.x && node.y === other.y && node.width === other.width && node.height === other.height;
|
|
129
|
+
}));
|
|
130
|
+
const attributes = useFlowValue(context, () => {
|
|
131
|
+
const engine = context.engine.value;
|
|
132
|
+
return engine ? engine.adapter.attributes("minimap") : partAttributes("minimap");
|
|
133
|
+
});
|
|
134
|
+
provide(MiniMapKey, view);
|
|
135
|
+
return () => {
|
|
136
|
+
const current = view.value;
|
|
137
|
+
return renderElement({
|
|
138
|
+
tag: "svg",
|
|
139
|
+
as: props.as,
|
|
140
|
+
attrs,
|
|
141
|
+
render: slots.render,
|
|
142
|
+
state: { view: current },
|
|
143
|
+
ref: ownRef,
|
|
144
|
+
props: {
|
|
145
|
+
...attributes.value,
|
|
146
|
+
viewBox: current.viewBoxAttribute,
|
|
147
|
+
width: width(),
|
|
148
|
+
height: height()
|
|
149
|
+
},
|
|
150
|
+
style: {
|
|
151
|
+
width: px(width()),
|
|
152
|
+
height: px(height())
|
|
153
|
+
},
|
|
154
|
+
children: () => slots.default ? slots.default({ view: current }) : [...current.nodes.map((node) => h(MiniMapNode, {
|
|
155
|
+
key: node.nodeId,
|
|
156
|
+
nodeId: node.nodeId
|
|
157
|
+
})), h(MiniMapMask)]
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
}, {
|
|
161
|
+
booleans: ["inversePan"],
|
|
162
|
+
types: { zoomStep: NUMBER_PROP },
|
|
163
|
+
emits: ["click"]
|
|
164
|
+
});
|
|
165
|
+
export { MiniMap, MiniMapMask, MiniMapNode };
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=minimap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimap.js","names":[],"sources":["../src/minimap/mini-map-context.ts","../src/minimap/mini-map-mask.ts","../src/minimap/mini-map-node.ts","../src/minimap/mini-map.ts"],"sourcesContent":["import type { MinimapView } from \"@fragiola/flow\";\nimport { type ComputedRef, inject } from \"vue\";\nimport { MiniMapKey } from \"../context\";\n\n/** The view of the enclosing `MiniMap`, for its nodes and its mask. */\nexport function useMiniMapView(part: string): ComputedRef<MinimapView> {\n const view = inject(MiniMapKey, null);\n if (!view) throw new Error(`${part} must be rendered inside MiniMap`);\n return view;\n}\n","import { partAttributes } from \"@fragiola/flow\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\nimport { useMiniMapView } from \"./mini-map-context\";\n\n/** The state of `MiniMapMask`: the root's view, in flow coordinates. */\nexport interface MiniMapMaskState {\n readonly view: { x: number; y: number; width: number; height: number };\n}\n\nexport interface MiniMapMaskProps extends PrimitiveProps {}\n\nexport interface MiniMapMaskSlots extends RenderSlot<MiniMapMaskState> {}\n\n/**\n * The `MiniMap`'s mask (`data-flow-part=\"minimap-mask\"`): an SVG path covering the map but what the\n * root shows (`fill-rule=\"evenodd\"`). Give it its fill.\n */\nexport const MiniMapMask: FlowComponent<MiniMapMaskProps, MiniMapMaskSlots> =\n definePrimitive<MiniMapMaskProps, MiniMapMaskSlots>(\n \"MiniMapMask\",\n [\"as\"],\n (props, { attrs, slots }) => {\n const view = useMiniMapView(\"MiniMapMask\");\n return () =>\n renderElement({\n tag: \"path\",\n as: props.as,\n attrs,\n render: slots.render,\n state: { view: view.value.view },\n props: {\n ...partAttributes(\"minimap-mask\"),\n d: view.value.maskPath,\n \"fill-rule\": \"evenodd\",\n },\n });\n },\n );\n","import { partAttributes } from \"@fragiola/flow\";\nimport { sameValue, useFlowValue } from \"../composables/internal\";\nimport { useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\nimport { useMiniMapView } from \"./mini-map-context\";\n\nexport interface MiniMapNodeState {\n readonly nodeId: string;\n /** `data-selected` (`selection()`) */\n readonly selected: boolean;\n}\n\nexport interface MiniMapNodeProps extends PrimitiveProps {\n /** the node it stands for */\n nodeId: string;\n}\n\nexport interface MiniMapNodeSlots extends RenderSlot<MiniMapNodeState> {}\n\n/**\n * A node in the `MiniMap` (`data-flow-part=\"minimap-node\"`, `data-flow-id`): an SVG rectangle of\n * the node's box, in flow coordinates. Nothing when the node is not shown.\n */\nexport const MiniMapNode: FlowComponent<MiniMapNodeProps, MiniMapNodeSlots> =\n definePrimitive<MiniMapNodeProps, MiniMapNodeSlots>(\n \"MiniMapNode\",\n [\"nodeId\", \"as\"],\n (props, { attrs, slots }) => {\n const view = useMiniMapView(\"MiniMapNode\");\n const context = useFlowContext(\"MiniMapNode\");\n const attributes = useFlowValue(\n context,\n () => {\n const engine = context.engine.value;\n return engine\n ? engine.adapter.attributes(\"minimap-node\", {\n nodeId: props.nodeId,\n })\n : partAttributes(\"minimap-node\", props.nodeId);\n },\n sameValue,\n \"entity\",\n );\n return () => {\n const box = view.value.nodes.find(\n (node) => node.nodeId === props.nodeId,\n );\n if (!box) return null;\n const own = attributes.value;\n return renderElement({\n tag: \"rect\",\n as: props.as,\n attrs,\n render: slots.render,\n state: {\n nodeId: props.nodeId,\n selected: own[\"data-selected\"] !== undefined,\n },\n props: {\n ...own,\n x: box.x,\n y: box.y,\n width: box.width,\n height: box.height,\n },\n });\n };\n },\n );\n","import { type MinimapView, partAttributes, type XY } from \"@fragiola/flow\";\nimport { h, provide, watchEffect } from \"vue\";\nimport { useFlowValue } from \"../composables/internal\";\nimport { MiniMapKey, useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n NUMBER_PROP,\n numberProp,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { px, type RenderSlot, renderElement, toElement } from \"../utils/render\";\nimport { MiniMapMask } from \"./mini-map-mask\";\nimport { MiniMapNode } from \"./mini-map-node\";\n\nexport interface MiniMapState {\n /** what it draws: the nodes, the view and the mask, in flow coordinates */\n readonly view: MinimapView;\n}\n\nexport interface MiniMapProps extends PrimitiveProps {\n /** its width, in pixels; default 200 */\n width?: number | undefined;\n /** its height, in pixels; default 150 */\n height?: number | undefined;\n /**\n * a drag on it moves the view the other way (as grabbing the flow), and a press does not\n * centre the view; default `minimap()`'s `inversePan`\n */\n inversePan?: boolean | undefined;\n /**\n * how fast its wheel zooms: 10 is the flow's own wheel, 20 twice as fast; default\n * `minimap()`'s `zoomStep`. The attribute's text is its number (`zoom-step=\"20\"`)\n */\n zoomStep?: number | `${number}` | undefined;\n}\n\nexport type MiniMapEmits = {\n /**\n * a tap on it (`minimap-click`), with the flow point under the pointer on the minimap: center\n * the view there, add a node there (`@click`; the root captures the pointer, so a DOM click\n * never reaches the minimap)\n */\n click: (event: MouseEvent, point: XY) => void;\n};\n\nexport interface MiniMapSlots extends RenderSlot<MiniMapState> {\n /**\n * what it draws, in flow coordinates (`v-slot=\"{ view }\"`); default a `MiniMapNode` per node,\n * then the `MiniMapMask`\n */\n default?: SlotFunction<{ view: MinimapView }>;\n}\n\nconst EMPTY_VIEW: MinimapView = Object.freeze({\n viewBox: Object.freeze({ x: 0, y: 0, width: 0, height: 0 }),\n viewBoxAttribute: \"0 0 0 0\",\n scale: 1,\n nodes: Object.freeze([]),\n view: Object.freeze({ x: 0, y: 0, width: 0, height: 0 }),\n maskPath: \"\",\n});\n\n/**\n * A small map of the flow (`data-flow-part=\"minimap\"`, `minimap()`): an SVG of `width` × `height`\n * pixels showing every node and what the root shows. With `minimap()`'s options, a drag on it pans\n * and its wheel zooms the flow. Inside `Flow.Root`, outside `Flow.Viewport`; place it with your\n * style.\n */\nexport const MiniMap: FlowComponent<MiniMapProps, MiniMapSlots, MiniMapEmits> =\n definePrimitive<MiniMapProps, MiniMapSlots, MiniMapEmits>(\n \"MiniMap\",\n [\"width\", \"height\", \"inversePan\", \"zoomStep\", \"as\"],\n (props, { attrs, slots, emit }) => {\n const context = useFlowContext(\"MiniMap\");\n // its options over `minimap()`'s, one set for the root's minimaps (the engine's part\n // options), set again when one changes, cleared when it goes\n watchEffect((onCleanup) => {\n const engine = context.engine.value;\n if (!engine) return;\n const options = Object.fromEntries(\n Object.entries({\n inversePan: props.inversePan,\n zoomStep: numberProp(props.zoomStep),\n }).filter(([, value]) => value !== undefined),\n );\n engine.adapter.setPartOptions(\"minimap\", \"\", options);\n onCleanup(() =>\n engine.adapter.setPartOptions(\"minimap\", \"\", null),\n );\n });\n // its taps (`minimap-click` on its own element: the root may draw several minimaps),\n // to the listener given now\n let own: Element | null = null;\n const ownRef = (value: unknown) => {\n own = toElement(value);\n };\n watchEffect((onCleanup) => {\n const engine = context.engine.value;\n if (!engine) return;\n const stop = engine.subscribe((event) => {\n if (\n event.type === \"minimap-click\" &&\n own !== null &&\n event.element === own\n ) {\n emit(\"click\", event.event, event.point);\n }\n });\n onCleanup(stop);\n });\n const width = () => props.width ?? 200;\n const height = () => props.height ?? 150;\n const view = useFlowValue(\n context,\n () =>\n context.engine.value?.get(\"minimap-view\", {\n width: width(),\n height: height(),\n }) ?? EMPTY_VIEW,\n (a, b) =>\n a === b ||\n (a.viewBoxAttribute === b.viewBoxAttribute &&\n a.maskPath === b.maskPath &&\n a.nodes.length === b.nodes.length &&\n a.nodes.every((node, i) => {\n const other = b.nodes[i];\n return (\n other !== undefined &&\n node.nodeId === other.nodeId &&\n node.x === other.x &&\n node.y === other.y &&\n node.width === other.width &&\n node.height === other.height\n );\n })),\n );\n const attributes = useFlowValue(context, () => {\n const engine = context.engine.value;\n return engine\n ? engine.adapter.attributes(\"minimap\")\n : partAttributes(\"minimap\");\n });\n provide(MiniMapKey, view);\n return () => {\n const current = view.value;\n return renderElement({\n tag: \"svg\",\n as: props.as,\n attrs,\n render: slots.render,\n state: { view: current },\n ref: ownRef,\n props: {\n ...attributes.value,\n viewBox: current.viewBoxAttribute,\n width: width(),\n height: height(),\n },\n style: { width: px(width()), height: px(height()) },\n children: () =>\n slots.default\n ? slots.default({ view: current })\n : [\n ...current.nodes.map((node) =>\n h(MiniMapNode, {\n key: node.nodeId,\n nodeId: node.nodeId,\n }),\n ),\n h(MiniMapMask),\n ],\n });\n };\n },\n {\n booleans: [\"inversePan\"],\n types: { zoomStep: NUMBER_PROP },\n emits: [\"click\"],\n },\n );\n"],"mappings":";;;;;;AAKA,SAAgB,eAAe,MAAwC;CACnE,MAAM,OAAO,OAAO,YAAY,IAAI;CACpC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,GAAG,KAAK,iCAAiC;CACpE,OAAO;AACX;;;;;;ACaA,MAAa,cACT,gBACI,eACA,CAAC,IAAI,IACJ,OAAO,EAAE,OAAO,YAAY;CACzB,MAAM,OAAO,eAAe,aAAa;CACzC,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K,UAAU,MAAM,SACrB,KAAK,WAAW,MAAM;CAE9B,CAAC,CACb;CACA,MAAM,aAAa,aAAa,eAAe;EAC3C,MAAM,SAAS,QAAQ,OAAO;EAC9B,OAAO,SACD,OAAO,QAAQ,WAAW,SAAS,IACnC,eAAe,SAAS;CAClC,CAAC;CACD,QAAQ,YAAY,IAAI;CACxB,aAAa;EACT,MAAM,UAAU,KAAK;EACrB,OAAO,cAAc;GACjB,KAAK;GACL,IAAI,MAAM;GACV;GACA,QAAQ,MAAM;GACd,OAAO,EAAE,MAAM,QAAQ;GACvB,KAAK;GACL,OAAO;IACH,GAAG,WAAW;IACd,SAAS,QAAQ;IACjB,OAAO,MAAM;IACb,QAAQ,OAAO;GACnB;GACA,OAAO;IAAE,OAAO,GAAG,MAAM,CAAC;IAAG,QAAQ,GAAG,OAAO,CAAC;GAAE;GAClD,gBACI,MAAM,UACA,MAAM,QAAQ,EAAE,MAAM,QAAQ,CAAC,IAC/B,CACI,GAAG,QAAQ,MAAM,KAAK,SAClB,EAAE,aAAa;IACX,KAAK,KAAK;IACV,QAAQ,KAAK;GACjB,CAAC,CACL,GACA,EAAE,WAAW,CACjB;EACd,CAAC;CACL;AACJ,GACA;CACI,UAAU,CAAC,YAAY;CACvB,OAAO,EAAE,UAAU,YAAY;CAC/B,OAAO,CAAC,OAAO;AACnB,CACJ"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { camelize, computed, defineComponent, getCurrentInstance, h, inject, mergeProps, normalizeStyle, onBeforeMount, watch } from "vue";
|
|
2
|
+
// src/context.ts
|
|
3
|
+
const FlowKey = Symbol("Flow");
|
|
4
|
+
const NodeKey = Symbol("FlowNode");
|
|
5
|
+
const EdgeKey = Symbol("FlowEdge");
|
|
6
|
+
const EdgeLabelLayerKey = Symbol("FlowEdgeLabelLayer");
|
|
7
|
+
/** The view of the enclosing `MiniMap`, for its nodes and its mask. */
|
|
8
|
+
const MiniMapKey = Symbol("FlowMiniMap");
|
|
9
|
+
function useFlowContext(part) {
|
|
10
|
+
const context = inject(FlowKey, null);
|
|
11
|
+
if (!context) throw new Error(`Flow.${part} must be rendered inside Flow.Root`);
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
14
|
+
/** The node of `nodeId`, or the enclosing `Flow.Node`'s, read when called. */
|
|
15
|
+
function usePartNodeId(part, nodeId) {
|
|
16
|
+
const context = inject(NodeKey, null);
|
|
17
|
+
return () => {
|
|
18
|
+
const id = nodeId() ?? context?.nodeId();
|
|
19
|
+
if (id === void 0) throw new Error(`Flow.${part} must be rendered inside Flow.Node (or be given a nodeId)`);
|
|
20
|
+
return id;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** The edge of `edgeId`, or the enclosing `Flow.Edge`'s, read when called. */
|
|
24
|
+
function useEdgeId(part, edgeId) {
|
|
25
|
+
const context = inject(EdgeKey, null);
|
|
26
|
+
return () => {
|
|
27
|
+
const id = edgeId() ?? context?.edgeId();
|
|
28
|
+
if (id === void 0) throw new Error(`Flow.${part} must be rendered inside Flow.Edge (or be given an edgeId)`);
|
|
29
|
+
return id;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** A model of any registry and features, seen erased. */
|
|
33
|
+
function eraseModel(model) {
|
|
34
|
+
return model;
|
|
35
|
+
}
|
|
36
|
+
/** The erased model seen with the registry and features the caller declares. */
|
|
37
|
+
function typedModel(model) {
|
|
38
|
+
return model;
|
|
39
|
+
}
|
|
40
|
+
/** The erased engine seen with the registry and features the caller declares. */
|
|
41
|
+
function typedEngine(engine) {
|
|
42
|
+
return engine;
|
|
43
|
+
}
|
|
44
|
+
// src/utils/shallow-equal.ts
|
|
45
|
+
function same(a, b) {
|
|
46
|
+
if (Object.is(a, b)) return true;
|
|
47
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null || Array.isArray(a) !== Array.isArray(b)) return false;
|
|
48
|
+
const aRecord = a;
|
|
49
|
+
const bRecord = b;
|
|
50
|
+
const keys = Object.keys(aRecord);
|
|
51
|
+
return keys.length === Object.keys(bRecord).length && keys.every((key) => Object.hasOwn(bRecord, key) && Object.is(aRecord[key], bRecord[key]));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Whether two records (a part's state) hold the same values, a nested record or array compared by
|
|
55
|
+
* its own entries: what decides that a part does not re-render.
|
|
56
|
+
*/
|
|
57
|
+
function shallowEqual(a, b) {
|
|
58
|
+
if (a === b) return true;
|
|
59
|
+
if (!a || !b) return false;
|
|
60
|
+
const keys = Object.keys(a);
|
|
61
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && same(a[key], b[key]));
|
|
62
|
+
}
|
|
63
|
+
// src/composables/internal.ts
|
|
64
|
+
/** @internal two values the same for re-rendering: records compared by their entries */
|
|
65
|
+
function sameValue(a, b) {
|
|
66
|
+
if (Object.is(a, b)) return true;
|
|
67
|
+
if (typeof a === "object" && typeof b === "object" && a !== null && b !== null && !Array.isArray(a) && !Array.isArray(b)) return shallowEqual(a, b);
|
|
68
|
+
if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((value, i) => Object.is(value, b[i]));
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @internal a value read from the model and the engine (the React adapter's `useFlowValue`), as a
|
|
73
|
+
* computed ref that triggers its readers only when it changes (`isEqual`; records by their entries
|
|
74
|
+
* by default). It is read again on every change that may concern its `scope` (the root's store:
|
|
75
|
+
* `view`, every commit of the model and every view change of the engine; `entity`, a node's or an
|
|
76
|
+
* edge's own view, not read again on a viewport step, and given its node or edge (`entity`, a
|
|
77
|
+
* getter), not on a measurement that leaves it alone), when the engine is created, and when a
|
|
78
|
+
* reactive value the reader uses changes (a prop); a value equal to the last one keeps the last
|
|
79
|
+
* object, so nothing re-renders.
|
|
80
|
+
*/
|
|
81
|
+
function useFlowValue(context, read, isEqual = sameValue, scope = "view", entity) {
|
|
82
|
+
const { store } = context;
|
|
83
|
+
if (scope === "entity" && entity) watch(() => {
|
|
84
|
+
const of = entity();
|
|
85
|
+
return of ? `${of.kind}\u0000${of.id}` : void 0;
|
|
86
|
+
}, (_key, _previous, onCleanup) => {
|
|
87
|
+
const of = entity();
|
|
88
|
+
if (of) onCleanup(store.acquire(of));
|
|
89
|
+
}, { immediate: true });
|
|
90
|
+
let last;
|
|
91
|
+
return computed(() => {
|
|
92
|
+
if (scope === "view") store.view.value;
|
|
93
|
+
else {
|
|
94
|
+
store.entity.value;
|
|
95
|
+
const of = entity?.();
|
|
96
|
+
(of ? store.counterOf(of) : store.measure).value;
|
|
97
|
+
}
|
|
98
|
+
context.engine.value;
|
|
99
|
+
const value = read();
|
|
100
|
+
if (last !== void 0 && isEqual(last.value, value)) return last.value;
|
|
101
|
+
last = { value };
|
|
102
|
+
return value;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function sameLayers(a, b) {
|
|
106
|
+
return a.length === b.length && a.every((layer, i) => {
|
|
107
|
+
const other = b[i];
|
|
108
|
+
return other !== void 0 && layer.level === other.level && layer.zIndex === other.zIndex && sameValue(layer.edges, other.edges);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @internal the render levels (`render-layers`) with their edges: the engine's, or before it
|
|
113
|
+
* exists the static geometry's (a server render, the first client render; no edge with
|
|
114
|
+
* `onlyRenderVisible`)
|
|
115
|
+
*/
|
|
116
|
+
function useDrawnLayers(context) {
|
|
117
|
+
return useFlowValue(context, () => {
|
|
118
|
+
const engine = context.engine.value;
|
|
119
|
+
const layers = engine ? engine.get("render-layers") : context.geometry.value?.layers ?? [];
|
|
120
|
+
const edges = engine ? engine.get("drawn-edges") : context.onlyRenderVisible.value ? [] : context.model.get("all-edges");
|
|
121
|
+
const byId = new Map(edges.map((edge) => [edge.id, edge]));
|
|
122
|
+
return layers.map((layer) => ({
|
|
123
|
+
level: layer.level,
|
|
124
|
+
zIndex: layer.zIndex,
|
|
125
|
+
edges: layer.edgeIds.flatMap((id) => {
|
|
126
|
+
const edge = byId.get(id);
|
|
127
|
+
return edge ? [edge] : [];
|
|
128
|
+
})
|
|
129
|
+
}));
|
|
130
|
+
}, sameLayers);
|
|
131
|
+
}
|
|
132
|
+
// src/utils/render.ts
|
|
133
|
+
/** A length in pixels for an inline style (Vue, unlike React, adds no unit to a number). */
|
|
134
|
+
function px(value) {
|
|
135
|
+
return `${value}px`;
|
|
136
|
+
}
|
|
137
|
+
/** The element behind a template ref: the element itself, or a component's root element. */
|
|
138
|
+
function toElement(value) {
|
|
139
|
+
if (value === null || typeof value !== "object") return null;
|
|
140
|
+
if (value.nodeType === 1) return value;
|
|
141
|
+
const root = value.$el;
|
|
142
|
+
return root !== null && typeof root === "object" && root.nodeType === 1 ? root : null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A function template ref that calls `attach` with the element once it is mounted, and the
|
|
146
|
+
* cleanup it returns when the element goes away or `deps` change (then `attach` runs again). Vue
|
|
147
|
+
* calls a function ref on every patch; only a change reaches `attach`. A primitive whose `attach`
|
|
148
|
+
* needs the engine reads `context.engine.value` in its render, so it patches (and calls its ref
|
|
149
|
+
* again) once the engine is there.
|
|
150
|
+
*/
|
|
151
|
+
function elementRef(attach, deps = () => []) {
|
|
152
|
+
let current = null;
|
|
153
|
+
let currentDeps = [];
|
|
154
|
+
let cleanup;
|
|
155
|
+
return (value) => {
|
|
156
|
+
const element = toElement(value);
|
|
157
|
+
const next = element ? deps() : [];
|
|
158
|
+
if (element === current && next.length === currentDeps.length && next.every((dep, i) => Object.is(dep, currentDeps[i]))) return;
|
|
159
|
+
cleanup?.();
|
|
160
|
+
cleanup = void 0;
|
|
161
|
+
current = element;
|
|
162
|
+
currentDeps = next;
|
|
163
|
+
if (element) cleanup = attach(element);
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Runs `start` on the client only: before the component mounts (a server render never mounts, so
|
|
168
|
+
* it never subscribes to anything it could not unsubscribe from), or at once outside a component.
|
|
169
|
+
*/
|
|
170
|
+
function onClient(start) {
|
|
171
|
+
if (getCurrentInstance()) onBeforeMount(start);
|
|
172
|
+
else start();
|
|
173
|
+
}
|
|
174
|
+
/** Renders a primitive's content inside its `render` slot: one component type for every render. */
|
|
175
|
+
const PrimitiveChildren = (props) => props.content?.();
|
|
176
|
+
PrimitiveChildren.props = ["content"];
|
|
177
|
+
/**
|
|
178
|
+
* Renders a primitive's element: merges the consumer's attributes over the primitive's (listeners
|
|
179
|
+
* composed, internal first; classes joined; structural style keys win over the consumer's, which
|
|
180
|
+
* win over the default ones), puts the primitive's template ref on it, and applies `as` or the
|
|
181
|
+
* `render` slot.
|
|
182
|
+
*/
|
|
183
|
+
function renderElement(options) {
|
|
184
|
+
const { attrs, state, children } = options;
|
|
185
|
+
const { style: consumerStyle, ...external } = attrs;
|
|
186
|
+
const merged = mergeProps(options.props, external);
|
|
187
|
+
const style = {
|
|
188
|
+
...options.baseStyle,
|
|
189
|
+
...styleObject(consumerStyle),
|
|
190
|
+
...options.style
|
|
191
|
+
};
|
|
192
|
+
for (const [key, value] of Object.entries(style)) if (value === void 0) delete style[key];
|
|
193
|
+
if (Object.keys(style).length > 0) merged.style = style;
|
|
194
|
+
if (options.ref) merged.ref = options.ref;
|
|
195
|
+
if (options.render) return options.render({
|
|
196
|
+
props: merged,
|
|
197
|
+
state,
|
|
198
|
+
children: h(PrimitiveChildren, { content: children })
|
|
199
|
+
});
|
|
200
|
+
const as = options.as ?? options.tag;
|
|
201
|
+
if (typeof as === "string") return h(as, merged, children ? [children()] : void 0);
|
|
202
|
+
return h(as, merged, children ? { default: children } : void 0);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* A consumer's `style` (an object, an array or a CSS string) as one object with camelCase keys
|
|
206
|
+
* (custom properties kept), so the structural keys can win over it.
|
|
207
|
+
*/
|
|
208
|
+
function styleObject(style) {
|
|
209
|
+
const normalized = normalizeStyle(style);
|
|
210
|
+
const result = {};
|
|
211
|
+
if (typeof normalized === "string") for (const declaration of normalized.split(/;(?![^(]*\))/g)) {
|
|
212
|
+
const index = declaration.indexOf(":");
|
|
213
|
+
if (index > 0) {
|
|
214
|
+
const name = declaration.slice(0, index).trim();
|
|
215
|
+
result[name.startsWith("--") ? name : camelize(name)] = declaration.slice(index + 1).trim();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else if (normalized) for (const [name, value] of Object.entries(normalized)) result[name.startsWith("--") ? name : camelize(name)] = value;
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
// src/utils/primitive.ts
|
|
222
|
+
/**
|
|
223
|
+
* The Vue props options of a primitive's props. The names in `booleans` are cast the way Vue casts
|
|
224
|
+
* a boolean prop, so a bare attribute is `true` (`<Flow.Root pan-on-scroll>`, not the empty
|
|
225
|
+
* string); absent, they stay `undefined`, so the core's default applies. `types` gives a prop
|
|
226
|
+
* that takes a boolean or something else (`fitView`: true or a payload) its types.
|
|
227
|
+
*/
|
|
228
|
+
function primitiveProps(names, booleans = [], types = {}) {
|
|
229
|
+
return Object.fromEntries(names.map((name) => {
|
|
230
|
+
const type = types[name];
|
|
231
|
+
if (type !== void 0) return [name, {
|
|
232
|
+
type,
|
|
233
|
+
default: void 0
|
|
234
|
+
}];
|
|
235
|
+
return [name, booleans.includes(name) ? {
|
|
236
|
+
type: Boolean,
|
|
237
|
+
default: void 0
|
|
238
|
+
} : null];
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Defines a primitive: a component named `Flow<name>` with `inheritAttrs: false` (it merges the
|
|
243
|
+
* fallthrough attributes itself, under its structural style), the props named in `props`
|
|
244
|
+
* (`booleans`: those that take a bare attribute as `true`) and the events named in `emits`.
|
|
245
|
+
*/
|
|
246
|
+
function definePrimitive(name, props, setup, options = {}) {
|
|
247
|
+
return defineComponent({
|
|
248
|
+
name: `Flow${name}`,
|
|
249
|
+
inheritAttrs: false,
|
|
250
|
+
props: primitiveProps(props, options.booleans, options.types),
|
|
251
|
+
emits: [...options.emits ?? []],
|
|
252
|
+
setup(componentProps, { attrs, slots, emit }) {
|
|
253
|
+
return setup(componentProps, {
|
|
254
|
+
attrs,
|
|
255
|
+
slots,
|
|
256
|
+
emit
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* A number prop that also takes its attribute's text (`duration="300"`), as Angular's inputs do:
|
|
263
|
+
* a numeric string is its number, anything else is left for the engine to judge.
|
|
264
|
+
*/
|
|
265
|
+
function numberProp(value) {
|
|
266
|
+
if (typeof value !== "string" || value.trim() === "") return value;
|
|
267
|
+
const number = Number(value);
|
|
268
|
+
return Number.isNaN(number) ? value : number;
|
|
269
|
+
}
|
|
270
|
+
/** The prop type of {@link numberProp}'s props. */
|
|
271
|
+
const NUMBER_PROP = [Number, String];
|
|
272
|
+
export { usePartNodeId as C, useFlowContext as S, NodeKey as _, onClient as a, typedModel as b, toElement as c, useFlowValue as d, shallowEqual as f, MiniMapKey as g, FlowKey as h, elementRef as i, sameValue as l, EdgeLabelLayerKey as m, definePrimitive as n, px as o, EdgeKey as p, numberProp as r, renderElement as s, NUMBER_PROP as t, useDrawnLayers as u, eraseModel as v, useEdgeId as x, typedEngine as y };
|
|
273
|
+
|
|
274
|
+
//# sourceMappingURL=primitive-h9jTIEeT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive-h9jTIEeT.js","names":[],"sources":["../src/context.ts","../src/utils/shallow-equal.ts","../src/composables/internal.ts","../src/utils/render.ts","../src/utils/primitive.ts"],"sourcesContent":["// The injected contexts of the Flow primitives. The root's holds the model and the engine with the\n// registry erased (`AnyTypes`, any features): a child cannot infer the root's `T` through\n// injection, so the typed surface is each part's props, `useFlow<Types, typeof features>()` and\n// `typedFlow<Types, typeof features>()`. The model's state never becomes reactive: the parts read\n// it through the root's store (counters the root bumps on each commit and view change, by the\n// readers they concern) into computed values that keep their last object while equal.\nimport type {\n AnyTypes,\n FlowEngine,\n FlowFeatures,\n FlowModel,\n FlowTypes,\n MinimapView,\n StaticGeometry,\n} from \"@fragiola/flow\";\nimport {\n type ComputedRef,\n type InjectionKey,\n inject,\n type ShallowRef,\n type VNodeChild,\n} from \"vue\";\nimport type { FlowStore } from \"./utils/flow-store\";\n\n/** The model as the primitives see it: any registry, any features. */\nexport type AnyFlowModel = FlowModel<AnyTypes, FlowFeatures>;\n\n/** The engine as the primitives see it: any registry, every feature's keys. */\nexport type AnyFlowEngine = FlowEngine<AnyTypes, FlowFeatures>;\n\n/** The context of a `Flow.Root`. */\nexport interface FlowContextValue {\n readonly model: AnyFlowModel;\n /** the engine, once the root is mounted (null before, and on the server) */\n readonly engine: Readonly<ShallowRef<AnyFlowEngine | null>>;\n /** the engine as apps see it: always there, forwarding to the engine once it exists */\n readonly publicEngine: AnyFlowEngine;\n /** the root's element, once mounted: what renders outside the zoom teleports into it */\n readonly rootElement: Readonly<ShallowRef<HTMLElement | null>>;\n /** bumped on every commit of the model and every view change of the engine (`store.view`) */\n readonly revision: Readonly<ShallowRef<number>>;\n /** what the readers hear, by scope (`useFlowValue`): the root's counters */\n readonly store: FlowStore;\n /**\n * the root renders only what is in view (`onlyRenderVisible`): before the engine (which knows\n * the view) no node and no edge is rendered, rather than all of them for one render\n */\n readonly onlyRenderVisible: ComputedRef<boolean>;\n /**\n * the flow's geometry from its document alone (`staticGeometry`, with the root's options)\n * while there is no engine (a server render, the first client render), null once it exists:\n * the parts draw from it, so the server's HTML and the first client render are the same\n */\n readonly geometry: ComputedRef<StaticGeometry | null>;\n}\n\nexport const FlowKey: InjectionKey<FlowContextValue> = Symbol(\"Flow\");\n\n/** The node a subtree renders (`Flow.Node`): its handles, resizer and toolbar belong to it. */\nexport interface NodeContextValue {\n readonly nodeId: () => string;\n}\n\nexport const NodeKey: InjectionKey<NodeContextValue> = Symbol(\"FlowNode\");\n\n/** The edge a subtree renders (`Flow.Edge`). */\nexport interface EdgeContextValue {\n readonly edgeId: () => string;\n}\n\nexport const EdgeKey: InjectionKey<EdgeContextValue> = Symbol(\"FlowEdge\");\n\n/**\n * A label `Flow.EdgeLabel` (or a toolbar `Flow.EdgeToolbar`, which teleports from there into the\n * root) hands to the HTML layer of `Flow.Edges`, which renders it.\n */\nexport interface EdgeLabelEntry {\n /** its key among the layer's entries */\n readonly key: number | string;\n /** its edge (the outlet provides it again to the label's content) */\n readonly edgeId: () => string;\n /** renders the label's element (null: nothing yet) */\n readonly render: () => VNodeChild;\n /** bumped when the label's own attributes or slots change (they are not reactive) */\n readonly version: Readonly<ShallowRef<number>>;\n}\n\n/**\n * The HTML layer of `Flow.Edges`, where the edges' labels render: SVG holds no HTML, and a Vue\n * `Teleport` out of an SVG keeps creating SVG elements, so a label registers here instead.\n */\nexport interface EdgeLabelLayer {\n add(entry: EdgeLabelEntry): () => void;\n}\n\nexport const EdgeLabelLayerKey: InjectionKey<EdgeLabelLayer> =\n Symbol(\"FlowEdgeLabelLayer\");\n\n/** The view of the enclosing `MiniMap`, for its nodes and its mask. */\nexport const MiniMapKey: InjectionKey<ComputedRef<MinimapView>> =\n Symbol(\"FlowMiniMap\");\n\nexport function useFlowContext(part: string): FlowContextValue {\n const context = inject(FlowKey, null);\n if (!context) {\n throw new Error(`Flow.${part} must be rendered inside Flow.Root`);\n }\n return context;\n}\n\n/** The node of `nodeId`, or the enclosing `Flow.Node`'s, read when called. */\nexport function usePartNodeId(\n part: string,\n nodeId: () => string | undefined,\n): () => string {\n const context = inject(NodeKey, null);\n return () => {\n const id = nodeId() ?? context?.nodeId();\n if (id === undefined) {\n throw new Error(\n `Flow.${part} must be rendered inside Flow.Node (or be given a nodeId)`,\n );\n }\n return id;\n };\n}\n\n/** The edge of `edgeId`, or the enclosing `Flow.Edge`'s, read when called. */\nexport function useEdgeId(\n part: string,\n edgeId: () => string | undefined,\n): () => string {\n const context = inject(EdgeKey, null);\n return () => {\n const id = edgeId() ?? context?.edgeId();\n if (id === undefined) {\n throw new Error(\n `Flow.${part} must be rendered inside Flow.Edge (or be given an edgeId)`,\n );\n }\n return id;\n };\n}\n\n/** A model of any registry and features, seen erased. */\nexport function eraseModel<T extends FlowTypes, F extends FlowFeatures>(\n model: FlowModel<T, F>,\n): AnyFlowModel {\n return model as unknown as AnyFlowModel;\n}\n\n/** The erased model seen with the registry and features the caller declares. */\nexport function typedModel<T extends FlowTypes, F extends FlowFeatures>(\n model: AnyFlowModel,\n): FlowModel<T, F> {\n return model as unknown as FlowModel<T, F>;\n}\n\n/** The erased engine seen with the registry and features the caller declares. */\nexport function typedEngine<T extends FlowTypes, F extends FlowFeatures>(\n engine: AnyFlowEngine | FlowEngine,\n): FlowEngine<T, F> {\n return engine as unknown as FlowEngine<T, F>;\n}\n","// The React adapter's (packages/react/src/utils/shallow-equal.ts, itself from Splitter): nested\n// records compared one level down (a part's attributes, its rect).\n\nfunction same(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (\n typeof a !== \"object\" ||\n typeof b !== \"object\" ||\n a === null ||\n b === null ||\n Array.isArray(a) !== Array.isArray(b)\n ) {\n return false;\n }\n const aRecord = a as Readonly<Record<string, unknown>>;\n const bRecord = b as Readonly<Record<string, unknown>>;\n const keys = Object.keys(aRecord);\n return (\n keys.length === Object.keys(bRecord).length &&\n keys.every(\n (key) =>\n Object.hasOwn(bRecord, key) &&\n Object.is(aRecord[key], bRecord[key]),\n )\n );\n}\n\n/**\n * Whether two records (a part's state) hold the same values, a nested record or array compared by\n * its own entries: what decides that a part does not re-render.\n */\nexport function shallowEqual(\n a: Readonly<Record<string, unknown>> | undefined,\n b: Readonly<Record<string, unknown>> | undefined,\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n const keys = Object.keys(a);\n return (\n keys.length === Object.keys(b).length &&\n keys.every((key) => Object.hasOwn(b, key) && same(a[key], b[key]))\n );\n}\n","// The composables and helpers only the primitives call.\nimport type { FlowEdge, RenderLayer } from \"@fragiola/flow\";\nimport { type ComputedRef, computed, watch } from \"vue\";\nimport type { FlowContextValue } from \"../context\";\nimport type { FlowEntity, FlowValueScope } from \"../utils/flow-store\";\nimport { shallowEqual } from \"../utils/shallow-equal\";\n\n/** @internal two values the same for re-rendering: records compared by their entries */\nexport function sameValue<S>(a: S, b: S): boolean {\n if (Object.is(a, b)) return true;\n if (\n typeof a === \"object\" &&\n typeof b === \"object\" &&\n a !== null &&\n b !== null &&\n !Array.isArray(a) &&\n !Array.isArray(b)\n ) {\n return shallowEqual(\n a as Readonly<Record<string, unknown>>,\n b as Readonly<Record<string, unknown>>,\n );\n }\n if (Array.isArray(a) && Array.isArray(b)) {\n return (\n a.length === b.length &&\n a.every((value, i) => Object.is(value, b[i]))\n );\n }\n return false;\n}\n\n/**\n * @internal a value read from the model and the engine (the React adapter's `useFlowValue`), as a\n * computed ref that triggers its readers only when it changes (`isEqual`; records by their entries\n * by default). It is read again on every change that may concern its `scope` (the root's store:\n * `view`, every commit of the model and every view change of the engine; `entity`, a node's or an\n * edge's own view, not read again on a viewport step, and given its node or edge (`entity`, a\n * getter), not on a measurement that leaves it alone), when the engine is created, and when a\n * reactive value the reader uses changes (a prop); a value equal to the last one keeps the last\n * object, so nothing re-renders.\n */\nexport function useFlowValue<S>(\n context: FlowContextValue,\n read: () => S,\n isEqual: (a: S, b: S) => boolean = sameValue,\n scope: FlowValueScope = \"view\",\n entity?: () => FlowEntity | undefined,\n): ComputedRef<S> {\n const { store } = context;\n if (scope === \"entity\" && entity) {\n // its record is kept while it reads it (another node or edge: the other record)\n watch(\n () => {\n const of = entity();\n return of ? `${of.kind}\\u0000${of.id}` : undefined;\n },\n (_key, _previous, onCleanup) => {\n const of = entity();\n if (of) onCleanup(store.acquire(of));\n },\n { immediate: true },\n );\n }\n let last: { value: S } | undefined;\n return computed(() => {\n if (scope === \"view\") {\n store.view.value;\n } else {\n store.entity.value;\n const of = entity?.();\n (of ? store.counterOf(of) : store.measure).value;\n }\n context.engine.value;\n const value = read();\n if (last !== undefined && isEqual(last.value, value)) {\n return last.value;\n }\n last = { value };\n return value;\n });\n}\n\n/** @internal one render level as the parts draw it: its edges, in drawing order */\nexport interface DrawnLayer {\n readonly level: number;\n readonly zIndex: number | undefined;\n readonly edges: readonly FlowEdge[];\n}\n\nfunction sameLayers(\n a: readonly DrawnLayer[],\n b: readonly DrawnLayer[],\n): boolean {\n return (\n a.length === b.length &&\n a.every((layer, i) => {\n const other = b[i];\n return (\n other !== undefined &&\n layer.level === other.level &&\n layer.zIndex === other.zIndex &&\n sameValue(layer.edges, other.edges)\n );\n })\n );\n}\n\n/**\n * @internal the render levels (`render-layers`) with their edges: the engine's, or before it\n * exists the static geometry's (a server render, the first client render; no edge with\n * `onlyRenderVisible`)\n */\nexport function useDrawnLayers(\n context: FlowContextValue,\n): ComputedRef<readonly DrawnLayer[]> {\n return useFlowValue(\n context,\n () => {\n const engine = context.engine.value;\n const layers: readonly RenderLayer[] = engine\n ? engine.get(\"render-layers\")\n : (context.geometry.value?.layers ?? []);\n // before the engine, a culled flow draws no edge (its levels kept, empty): the view\n // is not known yet\n const edges = engine\n ? engine.get(\"drawn-edges\")\n : context.onlyRenderVisible.value\n ? []\n : context.model.get(\"all-edges\");\n const byId = new Map(edges.map((edge) => [edge.id, edge]));\n return layers.map((layer) => ({\n level: layer.level,\n zIndex: layer.zIndex,\n edges: layer.edgeIds.flatMap((id) => {\n const edge = byId.get(id);\n return edge ? [edge] : [];\n }),\n }));\n },\n sameLayers,\n );\n}\n","// From Tree (fragiola/tree, packages/vue/src/utils/render.ts), same author and licence. Flow adds\n// a default style the consumer's overrides (`baseStyle`: a handle's place on its node's side).\n// `class` and `style` are values only: Vue normalizes both when it creates a node (a template's\n// `:class` too), so a function of the state (the React adapter's) never reaches a primitive; the\n// state is the `render` slot's, the default slot's (`{ state }`) and the `data-*` attributes'.\nimport {\n type Component,\n type CSSProperties,\n camelize,\n type FunctionalComponent,\n getCurrentInstance,\n h,\n mergeProps,\n normalizeStyle,\n onBeforeMount,\n type Slot,\n type VNode,\n type VNodeChild,\n} from \"vue\";\n\n/** A length in pixels for an inline style (Vue, unlike React, adds no unit to a number). */\nexport function px(value: number): string {\n return `${value}px`;\n}\n\n/** The element behind a template ref: the element itself, or a component's root element. */\nexport function toElement(value: unknown): Element | null {\n if (value === null || typeof value !== \"object\") {\n return null;\n }\n // `nodeType`, not `instanceof HTMLElement`: an element may belong to another window (an iframe)\n if ((value as { nodeType?: unknown }).nodeType === 1) {\n return value as Element;\n }\n const root = (value as { $el?: unknown }).$el;\n return root !== null &&\n typeof root === \"object\" &&\n (root as { nodeType?: unknown }).nodeType === 1\n ? (root as Element)\n : null;\n}\n\n/** A function template ref, as a primitive puts it on its element. */\nexport type ElementRef = (value: unknown) => void;\n\n/**\n * A function template ref that calls `attach` with the element once it is mounted, and the\n * cleanup it returns when the element goes away or `deps` change (then `attach` runs again). Vue\n * calls a function ref on every patch; only a change reaches `attach`. A primitive whose `attach`\n * needs the engine reads `context.engine.value` in its render, so it patches (and calls its ref\n * again) once the engine is there.\n */\nexport function elementRef(\n attach: (element: Element) => (() => void) | undefined,\n deps: () => readonly unknown[] = () => [],\n): ElementRef {\n let current: Element | null = null;\n let currentDeps: readonly unknown[] = [];\n let cleanup: (() => void) | undefined;\n return (value: unknown) => {\n const element = toElement(value);\n // an element going away needs no deps: its node may be gone from the model already\n const next = element ? deps() : [];\n if (\n element === current &&\n next.length === currentDeps.length &&\n next.every((dep, i) => Object.is(dep, currentDeps[i]))\n ) {\n return;\n }\n cleanup?.();\n cleanup = undefined;\n current = element;\n currentDeps = next;\n if (element) {\n cleanup = attach(element);\n }\n };\n}\n\n/**\n * Runs `start` on the client only: before the component mounts (a server render never mounts, so\n * it never subscribes to anything it could not unsubscribe from), or at once outside a component.\n */\nexport function onClient(start: () => void): void {\n if (getCurrentInstance()) {\n onBeforeMount(start);\n } else {\n start();\n }\n}\n\n/** A component (or a tag) a primitive renders instead of its own element: the `as` prop. */\nexport type AsProp = string | Component;\n\n/** What a primitive's `render` scoped slot receives. */\nexport interface RenderSlotProps<State> {\n /**\n * what goes on your element (`v-bind=\"props\"`): the primitive's `data-*`, listeners, its\n * structural style merged over your `class`/`style`, and its template ref\n */\n props: Record<string, unknown>;\n /** the primitive's state */\n state: State;\n /**\n * the primitive's content, as a node of one stable component (`<component :is=\"children\" />`,\n * or `h(children)`): its type never changes between renders, so the content never remounts\n */\n children: VNode;\n}\n\n/** Renders a primitive's content inside its `render` slot: one component type for every render. */\nconst PrimitiveChildren: FunctionalComponent<{\n content?: (() => VNodeChild) | undefined;\n}> = (props) => props.content?.();\nPrimitiveChildren.props = [\"content\"];\n\n/** The slots every primitive accepts: `render` replaces its element. */\nexport interface RenderSlot<State> {\n /** replaces the rendered element (never `asChild`): bind `props` on your own element */\n render?: (scope: RenderSlotProps<State>) => VNode[];\n}\n\ninterface RenderOptions<State> {\n /** the element rendered by default */\n tag: string;\n /** the consumer's `as` prop */\n as?: AsProp | undefined;\n /** the consumer's fallthrough attributes: `class`, `style`, listeners, ARIA, … */\n attrs: Record<string, unknown>;\n /** the consumer's `render` slot */\n render?: Slot | undefined;\n state: State;\n /** the primitive's own props: data-*, listeners, SVG attributes */\n props: Record<string, unknown>;\n /** the primitive's template ref */\n ref?: ElementRef | undefined;\n /** structural style: always wins over the consumer's */\n style?: CSSProperties | Record<string, unknown> | undefined;\n /** a default style the consumer's overrides */\n baseStyle?: CSSProperties | Record<string, unknown> | undefined;\n /** the primitive's content */\n children?: (() => VNodeChild) | undefined;\n}\n\n/**\n * Renders a primitive's element: merges the consumer's attributes over the primitive's (listeners\n * composed, internal first; classes joined; structural style keys win over the consumer's, which\n * win over the default ones), puts the primitive's template ref on it, and applies `as` or the\n * `render` slot.\n */\nexport function renderElement<State>(\n options: RenderOptions<State>,\n): VNodeChild {\n const { attrs, state, children } = options;\n const { style: consumerStyle, ...external } = attrs;\n const merged = mergeProps(options.props, external);\n // structural keys win, an undefined one included (it removes the consumer's, as in React)\n const style: Record<string, unknown> = {\n ...options.baseStyle,\n ...styleObject(consumerStyle),\n ...options.style,\n };\n for (const [key, value] of Object.entries(style)) {\n if (value === undefined) {\n delete style[key];\n }\n }\n if (Object.keys(style).length > 0) {\n merged.style = style;\n }\n if (options.ref) {\n merged.ref = options.ref;\n }\n if (options.render) {\n return options.render({\n props: merged,\n state,\n children: h(PrimitiveChildren, { content: children }),\n } satisfies RenderSlotProps<State>);\n }\n const as = options.as ?? options.tag;\n if (typeof as === \"string\") {\n return h(as, merged, children ? [children()] : undefined);\n }\n return h(as, merged, children ? { default: children } : undefined);\n}\n\n/**\n * A consumer's `style` (an object, an array or a CSS string) as one object with camelCase keys\n * (custom properties kept), so the structural keys can win over it.\n */\nexport function styleObject(style: unknown): Record<string, unknown> {\n const normalized = normalizeStyle(style);\n const result: Record<string, unknown> = {};\n if (typeof normalized === \"string\") {\n for (const declaration of normalized.split(/;(?![^(]*\\))/g)) {\n const index = declaration.indexOf(\":\");\n if (index > 0) {\n const name = declaration.slice(0, index).trim();\n result[name.startsWith(\"--\") ? name : camelize(name)] =\n declaration.slice(index + 1).trim();\n }\n }\n } else if (normalized) {\n for (const [name, value] of Object.entries(normalized)) {\n result[name.startsWith(\"--\") ? name : camelize(name)] = value;\n }\n }\n return result;\n}\n","// From Tree (fragiola/tree, packages/vue/src/utils/primitive.ts), same author and licence.\n// How a primitive is defined in Vue: its props, its scoped slots, its events (`Flow.Root`'s\n// `update:*`, for `v-model`), `inheritAttrs: false` (it merges the fallthrough attributes itself,\n// under its structural style). Flow adds props of other types than one (`fitView`: true or a\n// payload).\nimport {\n type DefineSetupFnComponent,\n defineComponent,\n type ObjectEmitsOptions,\n type Prop,\n type PropType,\n type SlotsType,\n type VNode,\n type VNodeChild,\n} from \"vue\";\nimport type { AsProp } from \"./render\";\n\n/** A slot function: what a scoped slot of a primitive receives, and the nodes it renders. */\nexport type SlotFunction<Scope> = (scope: Scope) => VNode[];\n\n/** No events: every listener a primitive takes is a fallthrough attribute. */\nexport type NoEmits = Record<never, never>;\n\n/**\n * A primitive's public type: a component taking `Props` (plus any fallthrough attribute: `class`,\n * `style`, listeners, ARIA, `data-*`) with the scoped slots `Slots` and the events `Emits`. Typed\n * by the registry `T` through each part's props, and through `typedFlow<T, F>()` for a template.\n */\nexport type FlowComponent<\n Props extends object,\n Slots extends object,\n Emits extends ObjectEmitsOptions = NoEmits,\n> = DefineSetupFnComponent<Props, Emits, SlotsType<Slots>>;\n\n/** The props every primitive accepts on top of its own: `as` replaces its element. */\nexport interface PrimitiveProps {\n /** the tag or component rendered instead of the primitive's element (never `asChild`) */\n as?: AsProp | undefined;\n}\n\n/** What a primitive's setup receives with its props. */\nexport interface PrimitiveContext<Slots> {\n /** the fallthrough attributes: `class`, `style`, listeners, ARIA, `data-*`, … */\n attrs: Record<string, unknown>;\n slots: { readonly [K in keyof Slots]?: Slots[K] };\n /** emits one of the primitive's events */\n emit: (event: string, ...args: unknown[]) => void;\n}\n\n/**\n * The Vue props options of a primitive's props. The names in `booleans` are cast the way Vue casts\n * a boolean prop, so a bare attribute is `true` (`<Flow.Root pan-on-scroll>`, not the empty\n * string); absent, they stay `undefined`, so the core's default applies. `types` gives a prop\n * that takes a boolean or something else (`fitView`: true or a payload) its types.\n */\nexport function primitiveProps<Name extends string>(\n names: readonly Name[],\n booleans: readonly Name[] = [],\n types: Partial<Record<Name, PropType<unknown>>> = {},\n): Record<Name, Prop<unknown> | null> {\n // a type-erased record (the primitive's public type comes from `FlowComponent`)\n return Object.fromEntries(\n names.map((name) => {\n const type = types[name];\n if (type !== undefined) return [name, { type, default: undefined }];\n return [\n name,\n booleans.includes(name)\n ? { type: Boolean as PropType<unknown>, default: undefined }\n : null,\n ];\n }),\n ) as Record<Name, Prop<unknown> | null>;\n}\n\n/**\n * Defines a primitive: a component named `Flow<name>` with `inheritAttrs: false` (it merges the\n * fallthrough attributes itself, under its structural style), the props named in `props`\n * (`booleans`: those that take a bare attribute as `true`) and the events named in `emits`.\n */\nexport function definePrimitive<\n Props extends object,\n Slots extends object,\n Emits extends ObjectEmitsOptions = NoEmits,\n>(\n name: string,\n props: readonly (keyof Props & string)[],\n setup: (props: Props, context: PrimitiveContext<Slots>) => () => VNodeChild,\n options: {\n booleans?: readonly (keyof Props & string)[];\n types?: Partial<Record<keyof Props & string, PropType<unknown>>>;\n emits?: readonly (keyof Emits & string)[];\n } = {},\n): FlowComponent<Props, Slots, Emits> {\n return defineComponent({\n name: `Flow${name}`,\n inheritAttrs: false,\n props: primitiveProps(props, options.booleans, options.types),\n emits: [...(options.emits ?? [])],\n setup(componentProps, { attrs, slots, emit }) {\n return setup(componentProps as unknown as Props, {\n attrs,\n slots: slots as PrimitiveContext<Slots>[\"slots\"],\n emit: emit as PrimitiveContext<Slots>[\"emit\"],\n });\n },\n }) as unknown as FlowComponent<Props, Slots, Emits>;\n}\n\n/**\n * A number prop that also takes its attribute's text (`duration=\"300\"`), as Angular's inputs do:\n * a numeric string is its number, anything else is left for the engine to judge.\n */\nexport function numberProp(value: unknown): unknown {\n if (typeof value !== \"string\" || value.trim() === \"\") return value;\n const number = Number(value);\n return Number.isNaN(number) ? value : number;\n}\n\n/** The prop type of {@link numberProp}'s props. */\nexport const NUMBER_PROP = [Number, String] as PropType<unknown>;\n"],"mappings":";;AAwDA,MAAa,UAA0C,OAAO,MAAM;AAOpE,MAAa,UAA0C,OAAO,UAAU;AAOxE,MAAa,UAA0C,OAAO,UAAU;AAyBxE,MAAa,oBACT,OAAO,oBAAoB;;AAG/B,MAAa,aACT,OAAO,aAAa;AAExB,SAAgB,eAAe,MAAgC;CAC3D,MAAM,UAAU,OAAO,SAAS,IAAI;CACpC,IAAI,CAAC,SACD,MAAM,IAAI,MAAM,QAAQ,KAAK,mCAAmC;CAEpE,OAAO;AACX;;AAGA,SAAgB,cACZ,MACA,QACY;CACZ,MAAM,UAAU,OAAO,SAAS,IAAI;CACpC,aAAa;EACT,MAAM,KAAK,OAAO,KAAK,SAAS,OAAO;EACvC,IAAI,OAAO,KAAA,GACP,MAAM,IAAI,MACN,QA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upFnComponent, ObjectEmitsOptions, SlotsType, VNode } from "vue";
|
|
2
|
+
/** A function template ref, as a primitive puts it on its element. */
|
|
3
|
+
type ElementRef = (value: unknown) => void;
|
|
4
|
+
/** A component (or a tag) a primitive renders instead of its own element: the `as` prop. */
|
|
5
|
+
type AsProp = string | Component;
|
|
6
|
+
/** What a primitive's `render` scoped slot receives. */
|
|
7
|
+
interface RenderSlotProps<State> {
|
|
8
|
+
/**
|
|
9
|
+
* what goes on your element (`v-bind="props"`): the primitive's `data-*`, listeners, its
|
|
10
|
+
* structural style merged over your `class`/`style`, and its template ref
|
|
11
|
+
*/
|
|
12
|
+
props: Record<string, unknown>;
|
|
13
|
+
/** the primitive's state */
|
|
14
|
+
state: State;
|
|
15
|
+
/**
|
|
16
|
+
* the primitive's content, as a node of one stable component (`<component :is="children" />`,
|
|
17
|
+
* or `h(children)`): its type never changes between renders, so the content never remounts
|
|
18
|
+
*/
|
|
19
|
+
children: VNode;
|
|
20
|
+
}
|
|
21
|
+
/** The slots every primitive accepts: `render` replaces its element. */
|
|
22
|
+
interface RenderSlot<State> {
|
|
23
|
+
/** replaces the rendered element (never `asChild`): bind `props` on your own element */
|
|
24
|
+
render?: (scope: RenderSlotProps<State>) => VNode[];
|
|
25
|
+
}
|
|
26
|
+
/** A slot function: what a scoped slot of a primitive receives, and the nodes it renders. */
|
|
27
|
+
type SlotFunction<Scope> = (scope: Scope) => VNode[];
|
|
28
|
+
/** No events: every listener a primitive takes is a fallthrough attribute. */
|
|
29
|
+
type NoEmits = Record<never, never>;
|
|
30
|
+
/**
|
|
31
|
+
* A primitive's public type: a component taking `Props` (plus any fallthrough attribute: `class`,
|
|
32
|
+
* `style`, listeners, ARIA, `data-*`) with the scoped slots `Slots` and the events `Emits`. Typed
|
|
33
|
+
* by the registry `T` through each part's props, and through `typedFlow<T, F>()` for a template.
|
|
34
|
+
*/
|
|
35
|
+
type FlowComponent<Props extends object, Slots extends object, Emits extends ObjectEmitsOptions = NoEmits> = DefineSetupFnComponent<Props, Emits, SlotsType<Slots>>;
|
|
36
|
+
/** The props every primitive accepts on top of its own: `as` replaces its element. */
|
|
37
|
+
interface PrimitiveProps {
|
|
38
|
+
/** the tag or component rendered instead of the primitive's element (never `asChild`) */
|
|
39
|
+
as?: AsProp | undefined;
|
|
40
|
+
}
|
|
41
|
+
export { ElementRef as a, AsProp as i, PrimitiveProps as n, RenderSlot as o, SlotFunction as r, RenderSlotProps as s, FlowComponent as t };
|
|
42
|
+
//# sourceMappingURL=primitive-ryVigrQO.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@fragiola/flow/reconnection";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@fragiola/flow/reconnection";
|