@dou-ui/flow 0.1.0-alpha.12 → 0.1.0-alpha.14

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.
Files changed (33) hide show
  1. package/dist/collaboration/index.js +39 -2
  2. package/dist/collaboration/index.js.map +1 -1
  3. package/dist/components/default-node.js.map +1 -1
  4. package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js +4 -4
  5. package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
  6. package/dist/components/flow-port.js.map +1 -1
  7. package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js +7 -42
  8. package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js.map +1 -1
  9. package/dist/components/node-view.js.map +1 -1
  10. package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js +2 -2
  11. package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/components/port-view.js +6 -0
  13. package/dist/components/port-view.js.map +1 -0
  14. package/dist/components/port-view.vue_vue_type_script_setup_true_lang.js +60 -0
  15. package/dist/components/port-view.vue_vue_type_script_setup_true_lang.js.map +1 -0
  16. package/dist/core/model.js.map +1 -1
  17. package/dist/core/node-types.js +6 -2
  18. package/dist/core/node-types.js.map +1 -1
  19. package/dist/flow-editor.js.map +1 -1
  20. package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js +24 -0
  21. package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/style.css +1 -1
  24. package/dist/types/components/flow-port.vue.d.ts +8 -2
  25. package/dist/types/components/port-view.vue.d.ts +10 -0
  26. package/dist/types/components/port.d.ts +2 -2
  27. package/dist/types/core/model.d.ts +9 -0
  28. package/dist/types/core/node-types.d.ts +2 -0
  29. package/dist/types/index.d.ts +1 -1
  30. package/dist/whiteboard/board-node.js.map +1 -1
  31. package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js +27 -11
  32. package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
  33. package/package.json +3 -3
@@ -6,7 +6,18 @@ import * as Y from "yjs";
6
6
  // src/collaboration/index.ts
7
7
  /** Whether a group is folded is each person's own view: it stays out of the shared document. */
8
8
  var LOCAL_DATA = "collapsed";
9
- var same = (a, b) => a === b || typeof a === "object" && JSON.stringify(a) === JSON.stringify(b);
9
+ /** The keys JSON keeps: those whose value isn't `undefined`. */
10
+ var jsonKeys = (value) => Object.keys(value).filter((key) => value[key] !== void 0);
11
+ /** Whether two JSON values are the same, whatever the order of their keys. */
12
+ function same(a, b) {
13
+ if (a === b) return true;
14
+ if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
15
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
16
+ if (Array.isArray(a)) return a.length === b.length && a.every((item, i) => same(item, b[i]));
17
+ const keys = jsonKeys(a);
18
+ if (keys.length !== jsonKeys(b).length) return false;
19
+ return keys.every((key) => same(a[key], b[key]));
20
+ }
10
21
  /** `data` as it is shared: without the local fields. */
11
22
  function sharedData(data) {
12
23
  if (!data || typeof data !== "object" || !(LOCAL_DATA in data)) return data;
@@ -117,9 +128,16 @@ function fillMaps(maps, doc, options = {}) {
117
128
  };
118
129
  transact(maps, fill, options.origin);
119
130
  }
131
+ /**
132
+ * While developing: each node and edge `readMaps` gave, as it was then, to
133
+ * tell one of `base` changed in place from one others changed meanwhile.
134
+ */
135
+ var asRead = /* @__PURE__ */ new WeakMap();
120
136
  /** Every node or edge a map holds. */
121
137
  function readAll(map) {
122
- return Array.from(map.keys(), (id) => read(map, id)).filter((item) => !!item);
138
+ const items = Array.from(map.keys(), (id) => read(map, id)).filter((item) => !!item);
139
+ if (process.env.NODE_ENV !== "production") for (const item of items) asRead.set(item, structuredClone(item));
140
+ return items;
123
141
  }
124
142
  /**
125
143
  * The flow the maps hold, read without an editor, e.g. to save a version
@@ -167,6 +185,24 @@ function syncItems(map, items, base, fits = () => true) {
167
185
  if (keys.size) write(map, item, keys);
168
186
  }
169
187
  }
188
+ /** Warns about the first of `items` that is one of `kept` (from base) changed in place since it was read. */
189
+ function warnChangedItem(items, kept) {
190
+ for (const item of items) {
191
+ const snapshot = kept.has(item) ? asRead.get(item) : void 0;
192
+ if (!snapshot || !changedKeys(snapshot, item).size) continue;
193
+ console.warn(`[@dou-ui/flow] updateMaps got "${item.id}" of \`base\` itself in \`doc\`, changed in place: the change isn't written. Change a copy of \`base\`, e.g. structuredClone(base).`);
194
+ return true;
195
+ }
196
+ return false;
197
+ }
198
+ /** Warns when `doc` holds `base` itself, or nodes or edges of it changed in place. */
199
+ function warnChangedInPlace(doc, base) {
200
+ if (doc === base || doc.nodes === base.nodes) {
201
+ console.warn("[@dou-ui/flow] updateMaps got the same object as `doc` and `base`, so nothing is written: change a copy of `base`, e.g. structuredClone(base).");
202
+ return;
203
+ }
204
+ if (!warnChangedItem(doc.nodes, new Set(base.nodes))) warnChangedItem(doc.edges, new Set(base.edges));
205
+ }
170
206
  /**
171
207
  * Change the maps from `options.base` to `doc`, without an editor, e.g. on
172
208
  * the server when a program wrote a new version while people edit the
@@ -174,6 +210,7 @@ function syncItems(map, items, base, fits = () => true) {
174
210
  */
175
211
  function updateMaps(maps, doc, options = {}) {
176
212
  const { base } = options;
213
+ if (process.env.NODE_ENV !== "production" && base) warnChangedInPlace(doc, base);
177
214
  const update = () => {
178
215
  syncItems(maps.nodes, doc.nodes, base?.nodes);
179
216
  const there = (end) => maps.nodes.get(end.node) instanceof Y.Map;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/collaboration/index.ts"],"sourcesContent":["import { collaborationColors } from 'dou-ui'\nimport { toRaw, watch } from 'vue'\nimport * as Y from 'yjs'\nimport type { FlowEditorContext } from '../context'\nimport { defineFlowExtension, type FlowExtension } from '../core/extension'\nimport type { FlowDocument, FlowEdge, FlowNode } from '../core/model'\nimport type { FlowStep, FlowTransaction } from '../core/transaction'\nimport { createPeers, type AwarenessLike, type FlowPresence } from './peers'\n\n/** How the people editing together see each other. */\nexport interface CollaborationUser {\n name: string\n /** The color of this user's outlines, any CSS color. Picked from the client id when left out. */\n color?: string\n}\n\nexport interface CollaborationOptions {\n /** Where the nodes live, e.g. `ydoc.getMap('nodes')`. */\n nodes: Y.Map<unknown>\n /** Where the edges live, e.g. `ydoc.getMap('edges')`; in the same `Y.Doc` as `nodes`. */\n edges: Y.Map<unknown>\n /** Shares what each person selects, drags and connects (`y-protocols/awareness`). */\n awareness?: AwarenessLike\n /** This user, shown to the others. Needs `awareness`. */\n user?: CollaborationUser\n}\n\nexport { collaborationColors }\n\ntype Shared = Y.Map<unknown>\ntype Item = Record<string, unknown>\n/** The fields of one node or edge a change touched; `true` for all of them. */\ntype Touched = Map<string, Set<string> | true>\n\n/** Whether a group is folded is each person's own view: it stays out of the shared document. */\nconst LOCAL_DATA = 'collapsed'\n\nconst same = (a: unknown, b: unknown) =>\n a === b || (typeof a === 'object' && JSON.stringify(a) === JSON.stringify(b))\n\n/** `data` as it is shared: without the local fields. */\nfunction sharedData(data: unknown) {\n if (!data || typeof data !== 'object' || !(LOCAL_DATA in data)) return data\n const { [LOCAL_DATA]: _, ...rest } = data as Item\n return rest\n}\n\n/** A node or edge as the map holds it, or `null` when it holds none. */\nfunction read<T>(map: Shared, id: string): T | null {\n const fields = map.get(id)\n if (!(fields instanceof Y.Map)) return null\n return { ...(fields.toJSON() as Item), id } as T\n}\n\n/** Where in `value` something JSON can't carry sits, e.g. a component or a function. */\nfunction unshareable(value: unknown, path: string): string | null {\n if (value === null || ['string', 'number', 'boolean', 'undefined'].includes(typeof value))\n return null\n if (typeof value !== 'object') return path\n const proto = Object.getPrototypeOf(value)\n if (Array.isArray(value)) {\n for (const [i, item] of value.entries()) {\n const found = unshareable(item, `${path}[${i}]`)\n if (found) return found\n }\n return null\n }\n if (proto !== Object.prototype && proto !== null) return path\n for (const [key, item] of Object.entries(value)) {\n const found = unshareable(item, `${path}.${key}`)\n if (found) return found\n }\n return null\n}\n\nconst warned = new Set<string>()\n/** Others would get a broken copy of such a value while this editor shows it fine. */\nfunction warnUnshareable(id: string, key: string, value: unknown) {\n // the app's bundler replaces this, as for Vue's own warnings\n if (process.env.NODE_ENV === 'production') return\n const path = unshareable(value, key)\n if (!path || warned.has(`${id}:${path}`)) return\n warned.add(`${id}:${path}`)\n console.warn(\n `[@dou-ui/flow] \"${id}\" has ${path}, which can't be shared: only JSON values reach the others. Store a name and look the component or function up where it is drawn.`,\n )\n}\n\nlet warnedDataUrl = false\n/** A data URL goes into the shared document whole, to everyone, every time it loads. */\nfunction warnDataUrl(data: unknown) {\n if (process.env.NODE_ENV === 'production' || warnedDataUrl || !data || typeof data !== 'object')\n return\n for (const value of Object.values(data))\n if (typeof value === 'string' && value.length > 100_000 && value.startsWith('data:')) {\n warnedDataUrl = true\n console.warn(\n `[@dou-ui/flow] a node keeps a data URL of ${Math.round(value.length / 1024)} KB, which every collaborator downloads with the document. Upload such files and keep their address instead, e.g. whiteboardKit({ upload }).`,\n )\n return\n }\n}\n\n/** Writes a node's or edge's fields, only those that changed; `keys` limits which. */\nfunction write(map: Shared, value: FlowNode | FlowEdge, keys?: Set<string>) {\n const item = value as unknown as Item\n const existing = map.get(value.id)\n const fields: Shared = existing instanceof Y.Map ? existing : new Y.Map<unknown>()\n const fresh = existing !== fields\n for (const [key, raw] of Object.entries(item)) {\n if (key === 'id' || raw === undefined || (keys && !fresh && !keys.has(key))) continue\n const field = key === 'data' ? sharedData(raw) : raw\n warnUnshareable(value.id, key, field)\n if (key === 'data') warnDataUrl(field)\n // a new map can't be read before it is in the document\n if (fresh || !same(fields.get(key), field)) fields.set(key, field)\n }\n if (fresh) return void map.set(value.id, fields)\n for (const key of Array.from(fields.keys()))\n if (item[key] === undefined && (!keys || keys.has(key))) fields.delete(key)\n}\n\n/** The change that makes `local` match `shared`, leaving out `skip` and the local fields. */\nfunction patchFor<T extends object>(local: T, shared: T, skip?: Set<string>) {\n const a = local as Item\n const b = shared as Item\n const patch: Item = {}\n for (const key of new Set([...Object.keys(a), ...Object.keys(b)])) {\n if (key === 'id' || skip?.has(key)) continue\n if (key === 'data') {\n if (same(sharedData(a.data), b.data)) continue\n // keep this person's folding\n const mine = (a.data as Item | undefined)?.[LOCAL_DATA]\n patch.data = mine === undefined ? b.data : { ...(b.data as Item), [LOCAL_DATA]: mine }\n } else if (!same(a[key], b[key])) patch[key] = b[key]\n }\n return Object.keys(patch).length ? (patch as Partial<T>) : null\n}\n\ntype Maps = { nodes: Y.Map<unknown>; edges: Y.Map<unknown> }\n\n/** Runs `run` as one transaction of the maps' document, from `origin`. */\nfunction transact(maps: Maps, run: () => void, origin: unknown) {\n const ydoc = maps.nodes.doc\n if (ydoc) ydoc.transact(run, origin ?? null)\n else run()\n}\n\nexport interface FillMapsOptions {\n /** The origin of the Yjs transaction, so the others can tell who wrote it. */\n origin?: unknown\n}\n\n/**\n * Writes nodes and edges into empty maps, e.g. when a flow that so far was\n * saved as JSON starts being edited together. Do it once, where the shared\n * document is created.\n */\nexport function fillMaps(maps: Maps, doc: FlowDocument, options: FillMapsOptions = {}) {\n const fill = () => {\n for (const node of doc.nodes) write(maps.nodes, node)\n for (const edge of doc.edges) write(maps.edges, edge)\n }\n transact(maps, fill, options.origin)\n}\n\n/** Every node or edge a map holds. */\nfunction readAll<T>(map: Shared): T[] {\n return Array.from(map.keys(), (id) => read<T>(map, id)).filter((item): item is T => !!item)\n}\n\n/**\n * The flow the maps hold, read without an editor, e.g. to save a version\n * on the server. The order of the nodes and edges is not fixed: it may\n * differ between two reads, and from one client to another.\n */\nexport function readMaps(maps: Maps): FlowDocument {\n return { version: 1, nodes: readAll<FlowNode>(maps.nodes), edges: readAll<FlowEdge>(maps.edges) }\n}\n\n/** The fields that differ between two versions of a node or edge. */\nfunction changedKeys(before: Item, after: Item) {\n const keys = new Set<string>()\n for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {\n if (key === 'id') continue\n const a = key === 'data' ? sharedData(before[key]) : before[key]\n const b = key === 'data' ? sharedData(after[key]) : after[key]\n if (!same(a, b)) keys.add(key)\n }\n return keys\n}\n\n/**\n * Brings the map from `base` to `items`: their changed fields written, those\n * left out removed. Without `base`, from what the map holds now.\n */\nfunction syncItems(\n map: Shared,\n items: readonly (FlowNode | FlowEdge)[],\n base?: readonly (FlowNode | FlowEdge)[],\n /** Whether a new item can be added, e.g. an edge whose two nodes are there. */\n fits: (item: FlowNode | FlowEdge) => boolean = () => true,\n) {\n if (!base) {\n const ids = new Set(items.map((item) => item.id))\n for (const id of Array.from(map.keys())) if (!ids.has(id)) map.delete(id)\n for (const item of items) write(map, item)\n return\n }\n const before = new Map(base.map((item) => [item.id, item]))\n const ids = new Set(items.map((item) => item.id))\n for (const id of before.keys()) if (!ids.has(id)) map.delete(id)\n for (const item of items) {\n const old = before.get(item.id)\n if (!old) {\n if (fits(item)) write(map, item)\n continue\n }\n // removed meanwhile by someone else: it stays removed\n if (!(map.get(item.id) instanceof Y.Map)) continue\n const keys = changedKeys(old as unknown as Item, item as unknown as Item)\n if (keys.size) write(map, item, keys)\n }\n}\n\nexport interface UpdateMapsOptions extends FillMapsOptions {\n /**\n * The version `doc` was made from, e.g. the one read with `readMaps` and\n * given to a program that took a while to write `doc`. Only the fields\n * that differ between `base` and `doc` are written, and only the nodes\n * and edges `base` has and `doc` hasn't are removed, so what others\n * changed meanwhile stays. Left out, the maps as they are now: then\n * every node and edge not in `doc` is removed.\n */\n base?: FlowDocument\n}\n\n/**\n * Change the maps from `options.base` to `doc`, without an editor, e.g. on\n * the server when a program wrote a new version while people edit the\n * flow. Only the fields that differ are written.\n */\nexport function updateMaps(maps: Maps, doc: FlowDocument, options: UpdateMapsOptions = {}) {\n const { base } = options\n const update = () => {\n syncItems(maps.nodes, doc.nodes, base?.nodes)\n // a new edge to a node someone removed meanwhile would lead nowhere\n const there = (end: { node: string }) => maps.nodes.get(end.node) instanceof Y.Map\n syncItems(maps.edges, doc.edges, base?.edges, (item) => {\n const edge = item as FlowEdge\n return there(edge.source) && there(edge.target)\n })\n }\n transact(maps, update, options.origin)\n}\n\n/** The fields `touched` holds for an item, when it holds only some. */\nfunction heldKeys(touched: Touched, id: string) {\n const keys = touched.get(id)\n return keys === true ? undefined : keys\n}\n\nfunction mark(into: Touched, id: string, keys: string[] | true) {\n const current = into.get(id)\n if (current === true) return\n if (keys === true) return void into.set(id, true)\n const set = current ?? new Set<string>()\n for (const key of keys) set.add(key)\n into.set(id, set)\n}\n\n/** The nodes and edges a transaction added, removed or changed, with the fields it changed. */\nfunction touch(steps: readonly FlowStep[], into: { nodes: Touched; edges: Touched }) {\n for (const step of steps) {\n if (step.type === 'addNode') mark(into.nodes, step.node.id, true)\n else if (step.type === 'removeNode') mark(into.nodes, step.id, true)\n else if (step.type === 'updateNode') mark(into.nodes, step.id, Object.keys(step.patch))\n else if (step.type === 'addEdge') mark(into.edges, step.edge.id, true)\n else if (step.type === 'removeEdge') mark(into.edges, step.id, true)\n else mark(into.edges, step.id, Object.keys(step.patch))\n }\n}\n\n/**\n * Edit a flow together through a Yjs document. Nodes and edges live in two\n * `Y.Map`s, each field on its own, so two people changing different fields\n * of one node both keep their change. The editor's `v-model` only mirrors\n * them: changes made to `v-model` from outside are not written back. While\n * someone drags, the others see an outline; the document changes once they\n * let go. Undo only takes back this user's own changes. Folding a group\n * stays local.\n */\nexport function collaboration(options: CollaborationOptions): FlowExtension {\n const { nodes, edges } = options\n const ydoc = nodes.doc\n if (!ydoc || edges.doc !== ydoc)\n throw new Error('[@dou-ui/flow] nodes and edges must be maps of the same Y.Doc')\n const { awareness, user } = options\n if (awareness && user) {\n const color = user.color ?? collaborationColors[ydoc.clientID % collaborationColors.length]\n awareness.setLocalStateField('user', { name: user.name, color })\n }\n\n /** This editor's own changes, which undo can take back. */\n const tracked = { flow: 'tracked' }\n /** Changes that undo leaves alone, e.g. filling the maps or clearing dangling edges. */\n const untracked = { flow: 'untracked' }\n const undoManager = new Y.UndoManager([nodes, edges], {\n trackedOrigins: new Set([tracked]),\n captureTimeout: 500,\n })\n /** Set while shared changes are applied to the editor, so they aren't written back. */\n let applying = false\n /** What undo or redo is running, to name the change. */\n let travelling: 'undo' | 'redo' | null = null\n let lastGroup: string | undefined\n /** What changed during the current drag, written once it ends. */\n const held = { nodes: new Map() as Touched, edges: new Map() as Touched, tracking: false }\n\n function writeChanges(\n doc: FlowDocument,\n changed: { nodes: Touched; edges: Touched },\n tracking: boolean,\n ) {\n const nodeById = new Map(doc.nodes.map((node) => [node.id, node]))\n const edgeById = new Map(doc.edges.map((edge) => [edge.id, edge]))\n ydoc!.transact(\n () => {\n for (const [id, keys] of changed.nodes) {\n const node = nodeById.get(id)\n if (node) write(nodes, node, keys === true ? undefined : keys)\n else nodes.delete(id)\n }\n for (const [id, keys] of changed.edges) {\n const edge = edgeById.get(id)\n if (edge) write(edges, edge, keys === true ? undefined : keys)\n else edges.delete(id)\n }\n },\n tracking ? tracked : untracked,\n )\n }\n\n /** Writes what a drag changed, as one undo step. */\n function release(context: FlowEditorContext) {\n if (!held.nodes.size && !held.edges.size) return\n if (held.tracking) undoManager.stopCapturing()\n writeChanges(toRaw(context.doc.value), held, held.tracking)\n if (held.tracking) undoManager.stopCapturing()\n lastGroup = undefined\n held.nodes.clear()\n held.edges.clear()\n held.tracking = false\n }\n\n /**\n * Adds steps to `tr` that bring the given nodes and edges in line with the\n * maps; returns edges left without a node, to clear from the maps.\n */\n function pull(tr: FlowTransaction, nodeIds: Iterable<string>, edgeIds: Iterable<string>) {\n for (const id of nodeIds) {\n const shared = read<FlowNode>(nodes, id)\n const local = tr.getNode(id)\n // a node being dragged here keeps the fields the drag changes\n if (held.nodes.get(id) === true) continue\n if (!shared) {\n if (local) tr.removeNode(id)\n } else if (!local) tr.addNode(shared)\n else {\n const patch = patchFor(local, shared, heldKeys(held.nodes, id))\n if (patch) tr.updateNode(id, patch)\n }\n }\n for (const id of edgeIds) {\n const shared = read<FlowEdge>(edges, id)\n const local = tr.getEdge(id)\n if (held.edges.get(id) === true) continue\n if (!shared) {\n if (local) tr.removeEdge(id)\n } else if (!local) tr.addEdge(shared)\n else {\n const patch = patchFor(local, shared, heldKeys(held.edges, id))\n if (patch) tr.updateEdge(id, patch)\n }\n }\n // One person deleted a node while another connected to it: the edge goes too.\n const dangling: string[] = []\n for (const edge of tr.doc.edges)\n if (!tr.getNode(edge.source.node) || !tr.getNode(edge.target.node)) dangling.push(edge.id)\n for (const id of dangling) tr.removeEdge(id)\n return dangling\n }\n\n return defineFlowExtension({\n name: 'collaboration',\n // after the other extensions, so it writes what they added\n priority: 0,\n transaction(tr, context) {\n if (applying) return\n const tracking = tr.meta.history !== false\n if (context.gesturing.value) {\n touch(tr.steps, held)\n held.tracking ||= tracking\n return\n }\n const changed = { nodes: new Map() as Touched, edges: new Map() as Touched }\n touch(tr.steps, changed)\n // like the editor's own history: only changes in one group undo together\n if (tracking && (!tr.meta.group || tr.meta.group !== lastGroup)) undoManager.stopCapturing()\n if (tracking) lastGroup = tr.meta.group\n writeChanges(tr.doc, changed, tracking)\n },\n history: () => ({\n undo: () => run('undo'),\n redo: () => run('redo'),\n canUndo: () => undoManager.undoStack.length > 0,\n canRedo: () => undoManager.redoStack.length > 0,\n }),\n layers: awareness ? { above: [createPeers(awareness)] } : undefined,\n setup(context) {\n const apply = (fn: (tr: FlowTransaction) => string[], origin: string) => {\n let dangling: string[] = []\n applying = true\n try {\n context.transact((tr) => (dangling = fn(tr)), { history: false, origin })\n } finally {\n applying = false\n }\n if (dangling.length)\n queueMicrotask(() =>\n ydoc.transact(() => {\n for (const id of dangling) edges.delete(id)\n }, untracked),\n )\n }\n const current = () => toRaw(context.doc.value)\n\n // the first one to open the flow brings its nodes; everyone else reads the maps\n if (!nodes.size && !edges.size)\n ydoc.transact(() => fillMaps({ nodes, edges }, current()), untracked)\n const doc = current()\n apply(\n (tr) =>\n pull(\n tr,\n new Set([...doc.nodes.map((node) => node.id), ...nodes.keys()]),\n new Set([...doc.edges.map((edge) => edge.id), ...edges.keys()]),\n ),\n 'remote',\n )\n\n // changes from others, and from undo: gathered per Yjs transaction\n const pending = { nodes: new Set<string>(), edges: new Set<string>() }\n const gather =\n (map: Shared, into: Set<string>) =>\n (events: Y.YEvent<Y.Map<unknown>>[], transaction: Y.Transaction) => {\n if (transaction.origin === tracked || transaction.origin === untracked) return\n for (const event of events) {\n if (event.target === map) for (const key of event.changes.keys.keys()) into.add(key)\n else if (event.path.length) into.add(String(event.path[0]))\n }\n }\n const onNodes = gather(nodes, pending.nodes)\n const onEdges = gather(edges, pending.edges)\n const flush = () => {\n if (!pending.nodes.size && !pending.edges.size) return\n const nodeIds = [...pending.nodes]\n const edgeIds = [...pending.edges]\n pending.nodes.clear()\n pending.edges.clear()\n apply((tr) => pull(tr, nodeIds, edgeIds), travelling ?? 'remote')\n }\n nodes.observeDeep(onNodes)\n edges.observeDeep(onEdges)\n ydoc.on('afterTransaction', flush)\n\n // a drag is written once it ends, cancelled or not\n const stopRelease = watch(context.gesturing, (on) => !on && release(context), {\n flush: 'sync',\n })\n\n let stopPresence: (() => void) | undefined\n if (awareness) {\n // what this user is dragging, connecting and has selected, for the others to see\n stopPresence = watch(\n [context.gesturing, context.doc, context.selection, context.connectingPath],\n ([on, , selection, path]) => {\n const moving: FlowPresence['moving'] = []\n if (on)\n for (const id of held.nodes.keys()) {\n if (moving.length >= 100) break\n const rect = context.getNodeRect(id)\n if (rect) moving.push({ id, ...rect })\n }\n awareness.setLocalStateField('flow', {\n moving,\n selection: {\n nodes: selection.nodes.slice(0, 100),\n edges: selection.edges.slice(0, 100),\n },\n path,\n } satisfies FlowPresence)\n },\n { immediate: true },\n )\n }\n\n return () => {\n nodes.unobserveDeep(onNodes)\n edges.unobserveDeep(onEdges)\n ydoc.off('afterTransaction', flush)\n stopRelease()\n stopPresence?.()\n awareness?.setLocalStateField('flow', null)\n }\n },\n })\n\n function run(action: 'undo' | 'redo') {\n const stack = action === 'undo' ? undoManager.undoStack : undoManager.redoStack\n if (!stack.length) return false\n travelling = action\n try {\n undoManager[action]()\n } finally {\n travelling = null\n }\n return true\n }\n}\n\nexport type { AwarenessLike, FlowPresence }\n"],"mappings":";;;;;;;AAmCA,IAAM,aAAa;AAEnB,IAAM,QAAQ,GAAY,MACxB,MAAM,KAAM,OAAO,MAAM,YAAY,KAAK,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC;;AAG7E,SAAS,WAAW,MAAe;CACjC,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,EAAE,cAAc,OAAO,OAAO;CACvE,MAAM,GAAG,aAAa,GAAG,GAAG,SAAS;CACrC,OAAO;AACT;;AAGA,SAAS,KAAQ,KAAa,IAAsB;CAClD,MAAM,SAAS,IAAI,IAAI,EAAE;CACzB,IAAI,EAAE,kBAAkB,EAAE,MAAM,OAAO;CACvC,OAAO;EAAE,GAAI,OAAO,OAAO;EAAY;CAAG;AAC5C;;AAGA,SAAS,YAAY,OAAgB,MAA6B;CAChE,IAAI,UAAU,QAAQ;EAAC;EAAU;EAAU;EAAW;CAAW,CAAC,CAAC,SAAS,OAAO,KAAK,GACtF,OAAO;CACT,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,MAAM,QAAQ,OAAO,eAAe,KAAK;CACzC,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,KAAK,MAAM,CAAC,GAAG,SAAS,MAAM,QAAQ,GAAG;GACvC,MAAM,QAAQ,YAAY,MAAM,GAAG,KAAK,GAAG,EAAE,EAAE;GAC/C,IAAI,OAAO,OAAO;EACpB;EACA,OAAO;CACT;CACA,IAAI,UAAU,OAAO,aAAa,UAAU,MAAM,OAAO;CACzD,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,KAAK,GAAG;EAC/C,MAAM,QAAQ,YAAY,MAAM,GAAG,KAAK,GAAG,KAAK;EAChD,IAAI,OAAO,OAAO;CACpB;CACA,OAAO;AACT;AAEA,IAAM,yBAAS,IAAI,IAAY;;AAE/B,SAAS,gBAAgB,IAAY,KA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,OAAO;EAC1B,aAAa;EACb,IAAI;GACF,YAAY,OAAO,CAAC;EACtB,UAAU;GACR,aAAa;EACf;EACA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/collaboration/index.ts"],"sourcesContent":["import { collaborationColors } from 'dou-ui'\nimport { toRaw, watch } from 'vue'\nimport * as Y from 'yjs'\nimport type { FlowEditorContext } from '../context'\nimport { defineFlowExtension, type FlowExtension } from '../core/extension'\nimport type { FlowDocument, FlowEdge, FlowNode } from '../core/model'\nimport type { FlowStep, FlowTransaction } from '../core/transaction'\nimport { createPeers, type AwarenessLike, type FlowPresence } from './peers'\n\n/** How the people editing together see each other. */\nexport interface CollaborationUser {\n name: string\n /** The color of this user's outlines, any CSS color. Picked from the client id when left out. */\n color?: string\n}\n\nexport interface CollaborationOptions {\n /** Where the nodes live, e.g. `ydoc.getMap('nodes')`. */\n nodes: Y.Map<unknown>\n /** Where the edges live, e.g. `ydoc.getMap('edges')`; in the same `Y.Doc` as `nodes`. */\n edges: Y.Map<unknown>\n /** Shares what each person selects, drags and connects (`y-protocols/awareness`). */\n awareness?: AwarenessLike\n /** This user, shown to the others. Needs `awareness`. */\n user?: CollaborationUser\n}\n\nexport { collaborationColors }\n\ntype Shared = Y.Map<unknown>\ntype Item = Record<string, unknown>\n/** The fields of one node or edge a change touched; `true` for all of them. */\ntype Touched = Map<string, Set<string> | true>\n\n/** Whether a group is folded is each person's own view: it stays out of the shared document. */\nconst LOCAL_DATA = 'collapsed'\n\n/** The keys JSON keeps: those whose value isn't `undefined`. */\nconst jsonKeys = (value: object) =>\n Object.keys(value).filter((key) => (value as Item)[key] !== undefined)\n\n/** Whether two JSON values are the same, whatever the order of their keys. */\nfunction same(a: unknown, b: unknown): boolean {\n if (a === b) return true\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') return false\n if (Array.isArray(a) !== Array.isArray(b)) return false\n if (Array.isArray(a))\n return (\n a.length === (b as unknown[]).length && a.every((item, i) => same(item, (b as unknown[])[i]))\n )\n const keys = jsonKeys(a)\n if (keys.length !== jsonKeys(b).length) return false\n return keys.every((key) => same((a as Item)[key], (b as Item)[key]))\n}\n\n/** `data` as it is shared: without the local fields. */\nfunction sharedData(data: unknown) {\n if (!data || typeof data !== 'object' || !(LOCAL_DATA in data)) return data\n const { [LOCAL_DATA]: _, ...rest } = data as Item\n return rest\n}\n\n/** A node or edge as the map holds it, or `null` when it holds none. */\nfunction read<T>(map: Shared, id: string): T | null {\n const fields = map.get(id)\n if (!(fields instanceof Y.Map)) return null\n return { ...(fields.toJSON() as Item), id } as T\n}\n\n/** Where in `value` something JSON can't carry sits, e.g. a component or a function. */\nfunction unshareable(value: unknown, path: string): string | null {\n if (value === null || ['string', 'number', 'boolean', 'undefined'].includes(typeof value))\n return null\n if (typeof value !== 'object') return path\n const proto = Object.getPrototypeOf(value)\n if (Array.isArray(value)) {\n for (const [i, item] of value.entries()) {\n const found = unshareable(item, `${path}[${i}]`)\n if (found) return found\n }\n return null\n }\n if (proto !== Object.prototype && proto !== null) return path\n for (const [key, item] of Object.entries(value)) {\n const found = unshareable(item, `${path}.${key}`)\n if (found) return found\n }\n return null\n}\n\nconst warned = new Set<string>()\n/** Others would get a broken copy of such a value while this editor shows it fine. */\nfunction warnUnshareable(id: string, key: string, value: unknown) {\n // the app's bundler replaces this, as for Vue's own warnings\n if (process.env.NODE_ENV === 'production') return\n const path = unshareable(value, key)\n if (!path || warned.has(`${id}:${path}`)) return\n warned.add(`${id}:${path}`)\n console.warn(\n `[@dou-ui/flow] \"${id}\" has ${path}, which can't be shared: only JSON values reach the others. Store a name and look the component or function up where it is drawn.`,\n )\n}\n\nlet warnedDataUrl = false\n/** A data URL goes into the shared document whole, to everyone, every time it loads. */\nfunction warnDataUrl(data: unknown) {\n if (process.env.NODE_ENV === 'production' || warnedDataUrl || !data || typeof data !== 'object')\n return\n for (const value of Object.values(data))\n if (typeof value === 'string' && value.length > 100_000 && value.startsWith('data:')) {\n warnedDataUrl = true\n console.warn(\n `[@dou-ui/flow] a node keeps a data URL of ${Math.round(value.length / 1024)} KB, which every collaborator downloads with the document. Upload such files and keep their address instead, e.g. whiteboardKit({ upload }).`,\n )\n return\n }\n}\n\n/** Writes a node's or edge's fields, only those that changed; `keys` limits which. */\nfunction write(map: Shared, value: FlowNode | FlowEdge, keys?: Set<string>) {\n const item = value as unknown as Item\n const existing = map.get(value.id)\n const fields: Shared = existing instanceof Y.Map ? existing : new Y.Map<unknown>()\n const fresh = existing !== fields\n for (const [key, raw] of Object.entries(item)) {\n if (key === 'id' || raw === undefined || (keys && !fresh && !keys.has(key))) continue\n const field = key === 'data' ? sharedData(raw) : raw\n warnUnshareable(value.id, key, field)\n if (key === 'data') warnDataUrl(field)\n // a new map can't be read before it is in the document\n if (fresh || !same(fields.get(key), field)) fields.set(key, field)\n }\n if (fresh) return void map.set(value.id, fields)\n for (const key of Array.from(fields.keys()))\n if (item[key] === undefined && (!keys || keys.has(key))) fields.delete(key)\n}\n\n/** The change that makes `local` match `shared`, leaving out `skip` and the local fields. */\nfunction patchFor<T extends object>(local: T, shared: T, skip?: Set<string>) {\n const a = local as Item\n const b = shared as Item\n const patch: Item = {}\n for (const key of new Set([...Object.keys(a), ...Object.keys(b)])) {\n if (key === 'id' || skip?.has(key)) continue\n if (key === 'data') {\n if (same(sharedData(a.data), b.data)) continue\n // keep this person's folding\n const mine = (a.data as Item | undefined)?.[LOCAL_DATA]\n patch.data = mine === undefined ? b.data : { ...(b.data as Item), [LOCAL_DATA]: mine }\n } else if (!same(a[key], b[key])) patch[key] = b[key]\n }\n return Object.keys(patch).length ? (patch as Partial<T>) : null\n}\n\ntype Maps = { nodes: Y.Map<unknown>; edges: Y.Map<unknown> }\n\n/** Runs `run` as one transaction of the maps' document, from `origin`. */\nfunction transact(maps: Maps, run: () => void, origin: unknown) {\n const ydoc = maps.nodes.doc\n if (ydoc) ydoc.transact(run, origin ?? null)\n else run()\n}\n\nexport interface FillMapsOptions {\n /** The origin of the Yjs transaction, so the others can tell who wrote it. */\n origin?: unknown\n}\n\n/**\n * Writes nodes and edges into empty maps, e.g. when a flow that so far was\n * saved as JSON starts being edited together. Do it once, where the shared\n * document is created.\n */\nexport function fillMaps(maps: Maps, doc: FlowDocument, options: FillMapsOptions = {}) {\n const fill = () => {\n for (const node of doc.nodes) write(maps.nodes, node)\n for (const edge of doc.edges) write(maps.edges, edge)\n }\n transact(maps, fill, options.origin)\n}\n\n/**\n * While developing: each node and edge `readMaps` gave, as it was then, to\n * tell one of `base` changed in place from one others changed meanwhile.\n */\nconst asRead = new WeakMap<object, Item>()\n\n/** Every node or edge a map holds. */\nfunction readAll<T extends object>(map: Shared): T[] {\n const items = Array.from(map.keys(), (id) => read<T>(map, id)).filter((item): item is T => !!item)\n if (process.env.NODE_ENV !== 'production')\n for (const item of items) asRead.set(item, structuredClone(item) as Item)\n return items\n}\n\n/**\n * The flow the maps hold, read without an editor, e.g. to save a version\n * on the server. The order of the nodes and edges is not fixed: it may\n * differ between two reads, and from one client to another.\n */\nexport function readMaps(maps: Maps): FlowDocument {\n return { version: 1, nodes: readAll<FlowNode>(maps.nodes), edges: readAll<FlowEdge>(maps.edges) }\n}\n\n/** The fields that differ between two versions of a node or edge. */\nfunction changedKeys(before: Item, after: Item) {\n const keys = new Set<string>()\n for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {\n if (key === 'id') continue\n const a = key === 'data' ? sharedData(before[key]) : before[key]\n const b = key === 'data' ? sharedData(after[key]) : after[key]\n if (!same(a, b)) keys.add(key)\n }\n return keys\n}\n\n/**\n * Brings the map from `base` to `items`: their changed fields written, those\n * left out removed. Without `base`, from what the map holds now.\n */\nfunction syncItems(\n map: Shared,\n items: readonly (FlowNode | FlowEdge)[],\n base?: readonly (FlowNode | FlowEdge)[],\n /** Whether a new item can be added, e.g. an edge whose two nodes are there. */\n fits: (item: FlowNode | FlowEdge) => boolean = () => true,\n) {\n if (!base) {\n const ids = new Set(items.map((item) => item.id))\n for (const id of Array.from(map.keys())) if (!ids.has(id)) map.delete(id)\n for (const item of items) write(map, item)\n return\n }\n const before = new Map(base.map((item) => [item.id, item]))\n const ids = new Set(items.map((item) => item.id))\n for (const id of before.keys()) if (!ids.has(id)) map.delete(id)\n for (const item of items) {\n const old = before.get(item.id)\n if (!old) {\n if (fits(item)) write(map, item)\n continue\n }\n // removed meanwhile by someone else: it stays removed\n if (!(map.get(item.id) instanceof Y.Map)) continue\n const keys = changedKeys(old as unknown as Item, item as unknown as Item)\n if (keys.size) write(map, item, keys)\n }\n}\n\n/** Warns about the first of `items` that is one of `kept` (from base) changed in place since it was read. */\nfunction warnChangedItem(items: readonly (FlowNode | FlowEdge)[], kept: Set<object>) {\n for (const item of items) {\n const snapshot = kept.has(item) ? asRead.get(item) : undefined\n if (!snapshot || !changedKeys(snapshot, item as unknown as Item).size) continue\n console.warn(\n `[@dou-ui/flow] updateMaps got \"${item.id}\" of \\`base\\` itself in \\`doc\\`, changed in place: the change isn't written. Change a copy of \\`base\\`, e.g. structuredClone(base).`,\n )\n return true\n }\n return false\n}\n\n/** Warns when `doc` holds `base` itself, or nodes or edges of it changed in place. */\nfunction warnChangedInPlace(doc: FlowDocument, base: FlowDocument) {\n if (doc === base || doc.nodes === base.nodes) {\n console.warn(\n '[@dou-ui/flow] updateMaps got the same object as `doc` and `base`, so nothing is written: change a copy of `base`, e.g. structuredClone(base).',\n )\n return\n }\n if (!warnChangedItem(doc.nodes, new Set(base.nodes)))\n warnChangedItem(doc.edges, new Set(base.edges))\n}\n\nexport interface UpdateMapsOptions extends FillMapsOptions {\n /**\n * The version `doc` was made from, e.g. the one read with `readMaps` and\n * given to a program that took a while to write `doc`. Only the fields\n * that differ between `base` and `doc` are written, and only the nodes\n * and edges `base` has and `doc` hasn't are removed, so what others\n * changed meanwhile stays. Left out, the maps as they are now: then\n * every node and edge not in `doc` is removed.\n */\n base?: FlowDocument\n}\n\n/**\n * Change the maps from `options.base` to `doc`, without an editor, e.g. on\n * the server when a program wrote a new version while people edit the\n * flow. Only the fields that differ are written.\n */\nexport function updateMaps(maps: Maps, doc: FlowDocument, options: UpdateMapsOptions = {}) {\n const { base } = options\n if (process.env.NODE_ENV !== 'production' && base) warnChangedInPlace(doc, base)\n const update = () => {\n syncItems(maps.nodes, doc.nodes, base?.nodes)\n // a new edge to a node someone removed meanwhile would lead nowhere\n const there = (end: { node: string }) => maps.nodes.get(end.node) instanceof Y.Map\n syncItems(maps.edges, doc.edges, base?.edges, (item) => {\n const edge = item as FlowEdge\n return there(edge.source) && there(edge.target)\n })\n }\n transact(maps, update, options.origin)\n}\n\n/** The fields `touched` holds for an item, when it holds only some. */\nfunction heldKeys(touched: Touched, id: string) {\n const keys = touched.get(id)\n return keys === true ? undefined : keys\n}\n\nfunction mark(into: Touched, id: string, keys: string[] | true) {\n const current = into.get(id)\n if (current === true) return\n if (keys === true) return void into.set(id, true)\n const set = current ?? new Set<string>()\n for (const key of keys) set.add(key)\n into.set(id, set)\n}\n\n/** The nodes and edges a transaction added, removed or changed, with the fields it changed. */\nfunction touch(steps: readonly FlowStep[], into: { nodes: Touched; edges: Touched }) {\n for (const step of steps) {\n if (step.type === 'addNode') mark(into.nodes, step.node.id, true)\n else if (step.type === 'removeNode') mark(into.nodes, step.id, true)\n else if (step.type === 'updateNode') mark(into.nodes, step.id, Object.keys(step.patch))\n else if (step.type === 'addEdge') mark(into.edges, step.edge.id, true)\n else if (step.type === 'removeEdge') mark(into.edges, step.id, true)\n else mark(into.edges, step.id, Object.keys(step.patch))\n }\n}\n\n/**\n * Edit a flow together through a Yjs document. Nodes and edges live in two\n * `Y.Map`s, each field on its own, so two people changing different fields\n * of one node both keep their change. The editor's `v-model` only mirrors\n * them: changes made to `v-model` from outside are not written back. While\n * someone drags, the others see an outline; the document changes once they\n * let go. Undo only takes back this user's own changes. Folding a group\n * stays local.\n */\nexport function collaboration(options: CollaborationOptions): FlowExtension {\n const { nodes, edges } = options\n const ydoc = nodes.doc\n if (!ydoc || edges.doc !== ydoc)\n throw new Error('[@dou-ui/flow] nodes and edges must be maps of the same Y.Doc')\n const { awareness, user } = options\n if (awareness && user) {\n const color = user.color ?? collaborationColors[ydoc.clientID % collaborationColors.length]\n awareness.setLocalStateField('user', { name: user.name, color })\n }\n\n /** This editor's own changes, which undo can take back. */\n const tracked = { flow: 'tracked' }\n /** Changes that undo leaves alone, e.g. filling the maps or clearing dangling edges. */\n const untracked = { flow: 'untracked' }\n const undoManager = new Y.UndoManager([nodes, edges], {\n trackedOrigins: new Set([tracked]),\n captureTimeout: 500,\n })\n /** Set while shared changes are applied to the editor, so they aren't written back. */\n let applying = false\n /** What undo or redo is running, to name the change. */\n let travelling: 'undo' | 'redo' | null = null\n let lastGroup: string | undefined\n /** What changed during the current drag, written once it ends. */\n const held = { nodes: new Map() as Touched, edges: new Map() as Touched, tracking: false }\n\n function writeChanges(\n doc: FlowDocument,\n changed: { nodes: Touched; edges: Touched },\n tracking: boolean,\n ) {\n const nodeById = new Map(doc.nodes.map((node) => [node.id, node]))\n const edgeById = new Map(doc.edges.map((edge) => [edge.id, edge]))\n ydoc!.transact(\n () => {\n for (const [id, keys] of changed.nodes) {\n const node = nodeById.get(id)\n if (node) write(nodes, node, keys === true ? undefined : keys)\n else nodes.delete(id)\n }\n for (const [id, keys] of changed.edges) {\n const edge = edgeById.get(id)\n if (edge) write(edges, edge, keys === true ? undefined : keys)\n else edges.delete(id)\n }\n },\n tracking ? tracked : untracked,\n )\n }\n\n /** Writes what a drag changed, as one undo step. */\n function release(context: FlowEditorContext) {\n if (!held.nodes.size && !held.edges.size) return\n if (held.tracking) undoManager.stopCapturing()\n writeChanges(toRaw(context.doc.value), held, held.tracking)\n if (held.tracking) undoManager.stopCapturing()\n lastGroup = undefined\n held.nodes.clear()\n held.edges.clear()\n held.tracking = false\n }\n\n /**\n * Adds steps to `tr` that bring the given nodes and edges in line with the\n * maps; returns edges left without a node, to clear from the maps.\n */\n function pull(tr: FlowTransaction, nodeIds: Iterable<string>, edgeIds: Iterable<string>) {\n for (const id of nodeIds) {\n const shared = read<FlowNode>(nodes, id)\n const local = tr.getNode(id)\n // a node being dragged here keeps the fields the drag changes\n if (held.nodes.get(id) === true) continue\n if (!shared) {\n if (local) tr.removeNode(id)\n } else if (!local) tr.addNode(shared)\n else {\n const patch = patchFor(local, shared, heldKeys(held.nodes, id))\n if (patch) tr.updateNode(id, patch)\n }\n }\n for (const id of edgeIds) {\n const shared = read<FlowEdge>(edges, id)\n const local = tr.getEdge(id)\n if (held.edges.get(id) === true) continue\n if (!shared) {\n if (local) tr.removeEdge(id)\n } else if (!local) tr.addEdge(shared)\n else {\n const patch = patchFor(local, shared, heldKeys(held.edges, id))\n if (patch) tr.updateEdge(id, patch)\n }\n }\n // One person deleted a node while another connected to it: the edge goes too.\n const dangling: string[] = []\n for (const edge of tr.doc.edges)\n if (!tr.getNode(edge.source.node) || !tr.getNode(edge.target.node)) dangling.push(edge.id)\n for (const id of dangling) tr.removeEdge(id)\n return dangling\n }\n\n return defineFlowExtension({\n name: 'collaboration',\n // after the other extensions, so it writes what they added\n priority: 0,\n transaction(tr, context) {\n if (applying) return\n const tracking = tr.meta.history !== false\n if (context.gesturing.value) {\n touch(tr.steps, held)\n held.tracking ||= tracking\n return\n }\n const changed = { nodes: new Map() as Touched, edges: new Map() as Touched }\n touch(tr.steps, changed)\n // like the editor's own history: only changes in one group undo together\n if (tracking && (!tr.meta.group || tr.meta.group !== lastGroup)) undoManager.stopCapturing()\n if (tracking) lastGroup = tr.meta.group\n writeChanges(tr.doc, changed, tracking)\n },\n history: () => ({\n undo: () => run('undo'),\n redo: () => run('redo'),\n canUndo: () => undoManager.undoStack.length > 0,\n canRedo: () => undoManager.redoStack.length > 0,\n }),\n layers: awareness ? { above: [createPeers(awareness)] } : undefined,\n setup(context) {\n const apply = (fn: (tr: FlowTransaction) => string[], origin: string) => {\n let dangling: string[] = []\n applying = true\n try {\n context.transact((tr) => (dangling = fn(tr)), { history: false, origin })\n } finally {\n applying = false\n }\n if (dangling.length)\n queueMicrotask(() =>\n ydoc.transact(() => {\n for (const id of dangling) edges.delete(id)\n }, untracked),\n )\n }\n const current = () => toRaw(context.doc.value)\n\n // the first one to open the flow brings its nodes; everyone else reads the maps\n if (!nodes.size && !edges.size)\n ydoc.transact(() => fillMaps({ nodes, edges }, current()), untracked)\n const doc = current()\n apply(\n (tr) =>\n pull(\n tr,\n new Set([...doc.nodes.map((node) => node.id), ...nodes.keys()]),\n new Set([...doc.edges.map((edge) => edge.id), ...edges.keys()]),\n ),\n 'remote',\n )\n\n // changes from others, and from undo: gathered per Yjs transaction\n const pending = { nodes: new Set<string>(), edges: new Set<string>() }\n const gather =\n (map: Shared, into: Set<string>) =>\n (events: Y.YEvent<Y.Map<unknown>>[], transaction: Y.Transaction) => {\n if (transaction.origin === tracked || transaction.origin === untracked) return\n for (const event of events) {\n if (event.target === map) for (const key of event.changes.keys.keys()) into.add(key)\n else if (event.path.length) into.add(String(event.path[0]))\n }\n }\n const onNodes = gather(nodes, pending.nodes)\n const onEdges = gather(edges, pending.edges)\n const flush = () => {\n if (!pending.nodes.size && !pending.edges.size) return\n const nodeIds = [...pending.nodes]\n const edgeIds = [...pending.edges]\n pending.nodes.clear()\n pending.edges.clear()\n apply((tr) => pull(tr, nodeIds, edgeIds), travelling ?? 'remote')\n }\n nodes.observeDeep(onNodes)\n edges.observeDeep(onEdges)\n ydoc.on('afterTransaction', flush)\n\n // a drag is written once it ends, cancelled or not\n const stopRelease = watch(context.gesturing, (on) => !on && release(context), {\n flush: 'sync',\n })\n\n let stopPresence: (() => void) | undefined\n if (awareness) {\n // what this user is dragging, connecting and has selected, for the others to see\n stopPresence = watch(\n [context.gesturing, context.doc, context.selection, context.connectingPath],\n ([on, , selection, path]) => {\n const moving: FlowPresence['moving'] = []\n if (on)\n for (const id of held.nodes.keys()) {\n if (moving.length >= 100) break\n const rect = context.getNodeRect(id)\n if (rect) moving.push({ id, ...rect })\n }\n awareness.setLocalStateField('flow', {\n moving,\n selection: {\n nodes: selection.nodes.slice(0, 100),\n edges: selection.edges.slice(0, 100),\n },\n path,\n } satisfies FlowPresence)\n },\n { immediate: true },\n )\n }\n\n return () => {\n nodes.unobserveDeep(onNodes)\n edges.unobserveDeep(onEdges)\n ydoc.off('afterTransaction', flush)\n stopRelease()\n stopPresence?.()\n awareness?.setLocalStateField('flow', null)\n }\n },\n })\n\n function run(action: 'undo' | 'redo') {\n const stack = action === 'undo' ? undoManager.undoStack : undoManager.redoStack\n if (!stack.length) return false\n travelling = action\n try {\n undoManager[action]()\n } finally {\n travelling = null\n }\n return true\n }\n}\n\nexport type { AwarenessLike, FlowPresence }\n"],"mappings":";;;;;;;AAmCA,IAAM,aAAa;;AAGnB,IAAM,YAAY,UAChB,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,QAAS,MAAe,SAAS,KAAA,CAAS;;AAGvE,SAAS,KAAK,GAAY,GAAqB;CAC7C,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,KAAK,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU,OAAO;CACvE,IAAI,MAAM,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GAAG,OAAO;CAClD,IAAI,MAAM,QAAQ,CAAC,GACjB,OACE,EAAE,WAAY,EAAgB,UAAU,EAAE,OAAO,MAAM,MAAM,KAAK,MAAO,EAAgB,EAAE,CAAC;CAEhG,MAAM,OAAO,SAAS,CAAC;CACvB,IAAI,KAAK,WAAW,SAAS,CAAC,CAAC,CAAC,QAAQ,OAAO;CAC/C,OAAO,KAAK,OAAO,QAAQ,KAAM,EAAW,MAAO,EAAW,IAAI,CAAC;AACrE;;AAGA,SAAS,WAAW,MAAe;CACjC,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,EAAE,cAAc,OAAO,OAAO;CACvE,MAAM,GAAG,aAAa,GAAG,GAAG,SAAS;CACrC,OAAO;AACT;;AAGA,SAAS,KAAQ,KAAa,IAAsB;CAClD,MAAM,SAAS,IAAI,IAAI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ACA;IACF,CAAwB;GAC1B,GACA,EAAE,WAAW,KAAK,CACpB;GAGF,aAAa;IACX,MAAM,cAAc,OAAO;IAC3B,MAAM,cAAc,OAAO;IAC3B,KAAK,IAAI,oBAAoB,KAAK;IAClC,YAAY;IACZ,eAAe;IACf,WAAW,mBAAmB,QAAQ,IAAI;GAC5C;EACF;CACF,CAAC;CAED,SAAS,IAAI,QAAyB;EAEpC,IAAI,EADU,WAAW,SAAS,YAAY,YAAY,YAAY,UAAA,CAC3D,QAAQ,OAAO;EAC1B,aAAa;EACb,IAAI;GACF,YAAY,OAAO,CAAC;EACtB,UAAU;GACR,aAAa;EACf;EACA,OAAO;CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"default-node.js","names":["_sfc_main"],"sources":["../../src/components/default-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { portSide, type NodeViewProps } from '../core/node-types'\nimport { useFlowEditor } from '../context'\nimport type { DefaultNodeData } from './default-node'\nimport FlowPortView from './flow-port.vue'\n\nconst props = defineProps<NodeViewProps<DefaultNodeData>>()\nconst { messages } = useFlowEditor()\n\n// Ports on the top or bottom are placed by the editor.\nconst inputs = computed(() =>\n props.ports.filter((p) => p.kind === 'input' && portSide(p) === 'left'),\n)\nconst outputs = computed(() =>\n props.ports.filter((p) => p.kind === 'output' && portSide(p) === 'right'),\n)\n// A single unnamed input and output sit on the title row.\nconst inline = computed(\n () =>\n inputs.value.length <= 1 &&\n outputs.value.length <= 1 &&\n [...inputs.value, ...outputs.value].every((p) => !p.label),\n)\nconst rows = computed(() => {\n if (inline.value) return []\n const count = Math.max(inputs.value.length, outputs.value.length)\n return Array.from({ length: count }, (_, i) => ({\n input: inputs.value[i],\n output: outputs.value[i],\n }))\n})\n</script>\n\n<template>\n <div class=\"dou-flow-default-node\">\n <div class=\"dou-flow-default-node__head\">\n <FlowPortView v-if=\"inline && inputs[0]\" :id=\"inputs[0].id\" />\n <span v-if=\"data.icon\" class=\"dou-flow-default-node__icon\">\n <component :is=\"data.icon\" />\n </span>\n <span class=\"dou-flow-default-node__title\">{{ data.label }}</span>\n <span\n v-if=\"data.status\"\n class=\"dou-flow-default-node__status\"\n :class=\"`is-${data.status}`\"\n role=\"img\"\n :aria-label=\"messages.status[data.status]\"\n />\n <FlowPortView v-if=\"inline && outputs[0]\" :id=\"outputs[0].id\" />\n </div>\n <p v-if=\"data.description\" class=\"dou-flow-default-node__description\">\n {{ data.description }}\n </p>\n <div v-if=\"rows.length\" class=\"dou-flow-default-node__ports\">\n <div v-for=\"(row, i) in rows\" :key=\"i\" class=\"dou-flow-default-node__row\">\n <span v-if=\"row.input\" class=\"dou-flow-default-node__port is-input\">\n <FlowPortView :id=\"row.input.id\" />\n {{ row.input.label ?? messages.input }}\n </span>\n <span v-if=\"row.output\" class=\"dou-flow-default-node__port is-output\">\n {{ row.output.label ?? messages.output }}\n <FlowPortView :id=\"row.output.id\" />\n </span>\n </div>\n </div>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"default-node.js","names":["_sfc_main"],"sources":["../../src/components/default-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { portSide, type NodeViewProps } from '../core/node-types'\nimport { useFlowEditor } from '../context'\nimport type { DefaultNodeData } from './default-node'\nimport FlowPortView from './port-view.vue'\n\nconst props = defineProps<NodeViewProps<DefaultNodeData>>()\nconst { messages } = useFlowEditor()\n\n// Ports on the top or bottom are placed by the editor.\nconst inputs = computed(() =>\n props.ports.filter((p) => p.kind === 'input' && portSide(p) === 'left'),\n)\nconst outputs = computed(() =>\n props.ports.filter((p) => p.kind === 'output' && portSide(p) === 'right'),\n)\n// A single unnamed input and output sit on the title row.\nconst inline = computed(\n () =>\n inputs.value.length <= 1 &&\n outputs.value.length <= 1 &&\n [...inputs.value, ...outputs.value].every((p) => !p.label),\n)\nconst rows = computed(() => {\n if (inline.value) return []\n const count = Math.max(inputs.value.length, outputs.value.length)\n return Array.from({ length: count }, (_, i) => ({\n input: inputs.value[i],\n output: outputs.value[i],\n }))\n})\n</script>\n\n<template>\n <div class=\"dou-flow-default-node\">\n <div class=\"dou-flow-default-node__head\">\n <FlowPortView v-if=\"inline && inputs[0]\" :id=\"inputs[0].id\" />\n <span v-if=\"data.icon\" class=\"dou-flow-default-node__icon\">\n <component :is=\"data.icon\" />\n </span>\n <span class=\"dou-flow-default-node__title\">{{ data.label }}</span>\n <span\n v-if=\"data.status\"\n class=\"dou-flow-default-node__status\"\n :class=\"`is-${data.status}`\"\n role=\"img\"\n :aria-label=\"messages.status[data.status]\"\n />\n <FlowPortView v-if=\"inline && outputs[0]\" :id=\"outputs[0].id\" />\n </div>\n <p v-if=\"data.description\" class=\"dou-flow-default-node__description\">\n {{ data.description }}\n </p>\n <div v-if=\"rows.length\" class=\"dou-flow-default-node__ports\">\n <div v-for=\"(row, i) in rows\" :key=\"i\" class=\"dou-flow-default-node__row\">\n <span v-if=\"row.input\" class=\"dou-flow-default-node__port is-input\">\n <FlowPortView :id=\"row.input.id\" />\n {{ row.input.label ?? messages.input }}\n </span>\n <span v-if=\"row.output\" class=\"dou-flow-default-node__port is-output\">\n {{ row.output.label ?? messages.output }}\n <FlowPortView :id=\"row.output.id\" />\n </span>\n </div>\n </div>\n </div>\n</template>\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import { useFlowEditor } from "../context.js";
2
2
  import { portSide } from "../core/node-types.js";
3
- import flow_port_default from "./flow-port.js";
3
+ import port_view_default from "./port-view.js";
4
4
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref } from "vue";
5
5
  // src/components/default-node.vue?vue&type=script&setup=true&lang.ts
6
6
  var _hoisted_1 = { class: "dou-flow-default-node" };
@@ -54,7 +54,7 @@ var default_node_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
54
54
  return (_ctx, _cache) => {
55
55
  return openBlock(), createElementBlock("div", _hoisted_1, [
56
56
  createElementVNode("div", _hoisted_2, [
57
- inline.value && inputs.value[0] ? (openBlock(), createBlock(flow_port_default, {
57
+ inline.value && inputs.value[0] ? (openBlock(), createBlock(port_view_default, {
58
58
  key: 0,
59
59
  id: inputs.value[0].id
60
60
  }, null, 8, ["id"])) : createCommentVNode("", true),
@@ -66,7 +66,7 @@ var default_node_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
66
66
  role: "img",
67
67
  "aria-label": unref(messages).status[__props.data.status]
68
68
  }, null, 10, _hoisted_5)) : createCommentVNode("", true),
69
- inline.value && outputs.value[0] ? (openBlock(), createBlock(flow_port_default, {
69
+ inline.value && outputs.value[0] ? (openBlock(), createBlock(port_view_default, {
70
70
  key: 3,
71
71
  id: outputs.value[0].id
72
72
  }, null, 8, ["id"])) : createCommentVNode("", true)
@@ -76,7 +76,7 @@ var default_node_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
76
76
  return openBlock(), createElementBlock("div", {
77
77
  key: i,
78
78
  class: "dou-flow-default-node__row"
79
- }, [row.input ? (openBlock(), createElementBlock("span", _hoisted_8, [createVNode(flow_port_default, { id: row.input.id }, null, 8, ["id"]), createTextVNode(" " + toDisplayString(row.input.label ?? unref(messages).input), 1)])) : createCommentVNode("", true), row.output ? (openBlock(), createElementBlock("span", _hoisted_9, [createTextVNode(toDisplayString(row.output.label ?? unref(messages).output) + " ", 1), createVNode(flow_port_default, { id: row.output.id }, null, 8, ["id"])])) : createCommentVNode("", true)]);
79
+ }, [row.input ? (openBlock(), createElementBlock("span", _hoisted_8, [createVNode(port_view_default, { id: row.input.id }, null, 8, ["id"]), createTextVNode(" " + toDisplayString(row.input.label ?? unref(messages).input), 1)])) : createCommentVNode("", true), row.output ? (openBlock(), createElementBlock("span", _hoisted_9, [createTextVNode(toDisplayString(row.output.label ?? unref(messages).output) + " ", 1), createVNode(port_view_default, { id: row.output.id }, null, 8, ["id"])])) : createCommentVNode("", true)]);
80
80
  }), 128))])) : createCommentVNode("", true)
81
81
  ]);
82
82
  };
@@ -1 +1 @@
1
- {"version":3,"file":"default-node.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createBlock","FlowPortView","_createCommentVNode","_resolveDynamicComponent","_toDisplayString","_normalizeClass","_unref","_Fragment","_renderList","_createVNode","_createTextVNode"],"sources":["../../src/components/default-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { portSide, type NodeViewProps } from '../core/node-types'\nimport { useFlowEditor } from '../context'\nimport type { DefaultNodeData } from './default-node'\nimport FlowPortView from './flow-port.vue'\n\nconst props = defineProps<NodeViewProps<DefaultNodeData>>()\nconst { messages } = useFlowEditor()\n\n// Ports on the top or bottom are placed by the editor.\nconst inputs = computed(() =>\n props.ports.filter((p) => p.kind === 'input' && portSide(p) === 'left'),\n)\nconst outputs = computed(() =>\n props.ports.filter((p) => p.kind === 'output' && portSide(p) === 'right'),\n)\n// A single unnamed input and output sit on the title row.\nconst inline = computed(\n () =>\n inputs.value.length <= 1 &&\n outputs.value.length <= 1 &&\n [...inputs.value, ...outputs.value].every((p) => !p.label),\n)\nconst rows = computed(() => {\n if (inline.value) return []\n const count = Math.max(inputs.value.length, outputs.value.length)\n return Array.from({ length: count }, (_, i) => ({\n input: inputs.value[i],\n output: outputs.value[i],\n }))\n})\n</script>\n\n<template>\n <div class=\"dou-flow-default-node\">\n <div class=\"dou-flow-default-node__head\">\n <FlowPortView v-if=\"inline && inputs[0]\" :id=\"inputs[0].id\" />\n <span v-if=\"data.icon\" class=\"dou-flow-default-node__icon\">\n <component :is=\"data.icon\" />\n </span>\n <span class=\"dou-flow-default-node__title\">{{ data.label }}</span>\n <span\n v-if=\"data.status\"\n class=\"dou-flow-default-node__status\"\n :class=\"`is-${data.status}`\"\n role=\"img\"\n :aria-label=\"messages.status[data.status]\"\n />\n <FlowPortView v-if=\"inline && outputs[0]\" :id=\"outputs[0].id\" />\n </div>\n <p v-if=\"data.description\" class=\"dou-flow-default-node__description\">\n {{ data.description }}\n </p>\n <div v-if=\"rows.length\" class=\"dou-flow-default-node__ports\">\n <div v-for=\"(row, i) in rows\" :key=\"i\" class=\"dou-flow-default-node__row\">\n <span v-if=\"row.input\" class=\"dou-flow-default-node__port is-input\">\n <FlowPortView :id=\"row.input.id\" />\n {{ row.input.label ?? messages.input }}\n </span>\n <span v-if=\"row.output\" class=\"dou-flow-default-node__port is-output\">\n {{ row.output.label ?? messages.output }}\n <FlowPortView :id=\"row.output.id\" />\n </span>\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,MAAM,QAAQ;EACd,MAAM,EAAE,aAAa,cAAc;EAGnC,MAAM,SAAS,eACb,MAAM,MAAM,QAAQ,MAAM,EAAE,SAAS,WAAW,SAAS,CAAC,MAAM,MAAM,CACxE;EACA,MAAM,UAAU,eACd,MAAM,MAAM,QAAQ,MAAM,EAAE,SAAS,YAAY,SAAS,CAAC,MAAM,OAAO,CAC1E;EAEA,MAAM,SAAS,eAEX,OAAO,MAAM,UAAU,KACvB,QAAQ,MAAM,UAAU,KACxB,CAAC,GAAG,OAAO,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC,OAAO,MAAM,CAAC,EAAE,KAAK,CAC7D;EACA,MAAM,OAAO,eAAe;GAC1B,IAAI,OAAO,OAAO,OAAO,CAAC;GAC1B,MAAM,QAAQ,KAAK,IAAI,OAAO,MAAM,QAAQ,QAAQ,MAAM,MAAM;GAChE,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,OAAO;IAC9C,OAAO,OAAO,MAAM;IACpB,QAAQ,QAAQ,MAAM;GACxB,EAAE;EACJ,CAAC;;GAIC,OAAAA,UAAA,GAAAC,mBA+BM,OA/BN,YA+BM;IA9BJC,mBAcM,OAdN,YAcM;KAbgB,OAAA,SAAU,OAAA,MAAM,MAApCF,UAAA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AI,OAAO,G"}
1
+ {"version":3,"file":"default-node.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createBlock","FlowPortView","_createCommentVNode","_resolveDynamicComponent","_toDisplayString","_normalizeClass","_unref","_Fragment","_renderList","_createVNode","_createTextVNode"],"sources":["../../src/components/default-node.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { portSide, type NodeViewProps } from '../core/node-types'\nimport { useFlowEditor } from '../context'\nimport type { DefaultNodeData } from './default-node'\nimport FlowPortView from './port-view.vue'\n\nconst props = defineProps<NodeViewProps<DefaultNodeData>>()\nconst { messages } = useFlowEditor()\n\n// Ports on the top or bottom are placed by the editor.\nconst inputs = computed(() =>\n props.ports.filter((p) => p.kind === 'input' && portSide(p) === 'left'),\n)\nconst outputs = computed(() =>\n props.ports.filter((p) => p.kind === 'output' && portSide(p) === 'right'),\n)\n// A single unnamed input and output sit on the title row.\nconst inline = computed(\n () =>\n inputs.value.length <= 1 &&\n outputs.value.length <= 1 &&\n [...inputs.value, ...outputs.value].every((p) => !p.label),\n)\nconst rows = computed(() => {\n if (inline.value) return []\n const count = Math.max(inputs.value.length, outputs.value.length)\n return Array.from({ length: count }, (_, i) => ({\n input: inputs.value[i],\n output: outputs.value[i],\n }))\n})\n</script>\n\n<template>\n <div class=\"dou-flow-default-node\">\n <div class=\"dou-flow-default-node__head\">\n <FlowPortView v-if=\"inline && inputs[0]\" :id=\"inputs[0].id\" />\n <span v-if=\"data.icon\" class=\"dou-flow-default-node__icon\">\n <component :is=\"data.icon\" />\n </span>\n <span class=\"dou-flow-default-node__title\">{{ data.label }}</span>\n <span\n v-if=\"data.status\"\n class=\"dou-flow-default-node__status\"\n :class=\"`is-${data.status}`\"\n role=\"img\"\n :aria-label=\"messages.status[data.status]\"\n />\n <FlowPortView v-if=\"inline && outputs[0]\" :id=\"outputs[0].id\" />\n </div>\n <p v-if=\"data.description\" class=\"dou-flow-default-node__description\">\n {{ data.description }}\n </p>\n <div v-if=\"rows.length\" class=\"dou-flow-default-node__ports\">\n <div v-for=\"(row, i) in rows\" :key=\"i\" class=\"dou-flow-default-node__row\">\n <span v-if=\"row.input\" class=\"dou-flow-default-node__port is-input\">\n <FlowPortView :id=\"row.input.id\" />\n {{ row.input.label ?? messages.input }}\n </span>\n <span v-if=\"row.output\" class=\"dou-flow-default-node__port is-output\">\n {{ row.output.label ?? messages.output }}\n <FlowPortView :id=\"row.output.id\" />\n </span>\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,MAAM,QAAQ;EACd,MAAM,EAAE,aAAa,cAAc;EAGnC,MAAM,SAAS,eACb,MAAM,MAAM,QAAQ,MAAM,EAAE,SAAS,WAAW,SAAS,CAAC,MAAM,MAAM,CACxE;EACA,MAAM,UAAU,eACd,MAAM,MAAM,QAAQ,MAAM,EAAE,SAAS,YAAY,SAAS,CAAC,MAAM,OAAO,CAC1E;EAEA,MAAM,SAAS,eAEX,OAAO,MAAM,UAAU,KACvB,QAAQ,MAAM,UAAU,KACxB,CAAC,GAAG,OAAO,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC,OAAO,MAAM,CAAC,EAAE,KAAK,CAC7D;EACA,MAAM,OAAO,eAAe;GAC1B,IAAI,OAAO,OAAO,OAAO,CAAC;GAC1B,MAAM,QAAQ,KAAK,IAAI,OAAO,MAAM,QAAQ,QAAQ,MAAM,MAAM;GAChE,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,OAAO;IAC9C,OAAO,OAAO,MAAM;IACpB,QAAQ,QAAQ,MAAM;GACxB,EAAE;EACJ,CAAC;;GAIC,OAAAA,UAAA,GAAAC,mBA+BM,OA/BN,YA+BM;IA9BJC,mBAcM,OAdN,YAcM;KAbgB,OAAA,SAAU,OAAA,MAAM,MAApCF,UAAA,GAAAG,YAA8DC,mBAAA;;MAApB,IAAI,OAAA,MAAM,EAA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names":["_sfc_main"],"sources":["../../src/components/flow-port.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, inject, onBeforeUnmount, onMounted, useTemplateRef } from 'vue'\nimport { flowEditorKey, flowNodeKey } from '../context'\nimport { portSide } from '../core/node-types'\n\ndefineOptions({ name: 'DouFlowPort' })\n\nconst props = defineProps<{\n /** The id of one of the node's ports. */\n id: string\n /** @internal placed by the editor, not by the node's component */\n auto?: boolean\n}>()\n\nconst node = inject(flowNodeKey, null)\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst port = computed(() => node?.ports.value.find((p) => p.id === props.id))\nconst side = computed(() => (port.value ? portSide(port.value) : 'left'))\nconst connected = computed(() => !!node?.connected.value.has(props.id))\nconst editor = inject(flowEditorKey, null)\nconst type = computed(() => (port.value ? editor?.portTypeOf(port.value) : undefined))\nconst shape = computed(() => type.value?.shape ?? 'circle')\nconst color = computed(() => editor?.colorOf(type.value))\nconst states = computed(() => node?.portStates.value)\nconst state = computed(() => states.value?.get(props.id))\n\nonMounted(() => {\n if (el.value) node?.registerPort(props.id, el.value, props.auto)\n})\nonBeforeUnmount(() => node?.unregisterPort(props.id, props.auto))\n</script>\n\n<template>\n <span\n ref=\"el\"\n class=\"dou-flow-port\"\n :class=\"[\n `is-${side}`,\n `is-${port?.kind ?? 'input'}`,\n `is-${shape}`,\n state && `is-${state}`,\n { 'is-connected': connected, 'is-unavailable': states && !state },\n ]\"\n :style=\"color ? { '--dou-flow-port-color': color } : undefined\"\n :data-port=\"id\"\n aria-hidden=\"true\"\n >\n <svg v-if=\"shape === 'triangle'\" viewBox=\"0 0 10 10\">\n <path d=\"M2 1.5 8 5 2 8.5Z\" />\n </svg>\n </span>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"flow-port.js","names":["_sfc_main"],"sources":["../../src/components/flow-port.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { FlowPortVisible } from '../core/model'\nimport PortView from './port-view.vue'\n\ndefineOptions({ name: 'DouFlowPort' })\n\ndefineProps<{\n /** The id of one of the node's ports. */\n id: string\n /**\n * When the port shows: `always`; `hover`, on a hovered or selected node,\n * or one with the keyboard focus in it (a field being typed in);\n * or `connecting`, only while an edge is drawn. Never shown in a\n * readonly editor. Defaults to the port's own `visible`, else `always`.\n */\n visible?: FlowPortVisible\n}>()\n</script>\n\n<template>\n <PortView :id=\"id\" :visible=\"visible\" />\n</template>\n"],"mappings":""}
@@ -1,54 +1,19 @@
1
- import { flowEditorKey, flowNodeKey } from "../context.js";
2
- import { portSide } from "../core/node-types.js";
3
- import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, inject, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, useTemplateRef } from "vue";
1
+ import port_view_default from "./port-view.js";
2
+ import { createBlock, defineComponent, openBlock } from "vue";
4
3
  // src/components/flow-port.vue?vue&type=script&setup=true&lang.ts
5
- var _hoisted_1 = ["data-port"];
6
- var _hoisted_2 = {
7
- key: 0,
8
- viewBox: "0 0 10 10"
9
- };
10
4
  var flow_port_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
11
5
  name: "DouFlowPort",
12
6
  __name: "flow-port",
13
7
  props: {
14
8
  id: {},
15
- auto: { type: Boolean }
9
+ visible: {}
16
10
  },
17
11
  setup(__props) {
18
- const props = __props;
19
- const node = inject(flowNodeKey, null);
20
- const el = useTemplateRef("el");
21
- const port = computed(() => node?.ports.value.find((p) => p.id === props.id));
22
- const side = computed(() => port.value ? portSide(port.value) : "left");
23
- const connected = computed(() => !!node?.connected.value.has(props.id));
24
- const editor = inject(flowEditorKey, null);
25
- const type = computed(() => port.value ? editor?.portTypeOf(port.value) : void 0);
26
- const shape = computed(() => type.value?.shape ?? "circle");
27
- const color = computed(() => editor?.colorOf(type.value));
28
- const states = computed(() => node?.portStates.value);
29
- const state = computed(() => states.value?.get(props.id));
30
- onMounted(() => {
31
- if (el.value) node?.registerPort(props.id, el.value, props.auto);
32
- });
33
- onBeforeUnmount(() => node?.unregisterPort(props.id, props.auto));
34
12
  return (_ctx, _cache) => {
35
- return openBlock(), createElementBlock("span", {
36
- ref_key: "el",
37
- ref: el,
38
- class: normalizeClass(["dou-flow-port", [
39
- `is-${side.value}`,
40
- `is-${port.value?.kind ?? "input"}`,
41
- `is-${shape.value}`,
42
- state.value && `is-${state.value}`,
43
- {
44
- "is-connected": connected.value,
45
- "is-unavailable": states.value && !state.value
46
- }
47
- ]]),
48
- style: normalizeStyle(color.value ? { "--dou-flow-port-color": color.value } : void 0),
49
- "data-port": __props.id,
50
- "aria-hidden": "true"
51
- }, [shape.value === "triangle" ? (openBlock(), createElementBlock("svg", _hoisted_2, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M2 1.5 8 5 2 8.5Z" }, null, -1)])])) : createCommentVNode("", true)], 14, _hoisted_1);
13
+ return openBlock(), createBlock(port_view_default, {
14
+ id: __props.id,
15
+ visible: __props.visible
16
+ }, null, 8, ["id", "visible"]);
52
17
  };
53
18
  }
54
19
  });
@@ -1 +1 @@
1
- {"version":3,"file":"flow-port.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_createElementVNode","_createCommentVNode"],"sources":["../../src/components/flow-port.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, inject, onBeforeUnmount, onMounted, useTemplateRef } from 'vue'\nimport { flowEditorKey, flowNodeKey } from '../context'\nimport { portSide } from '../core/node-types'\n\ndefineOptions({ name: 'DouFlowPort' })\n\nconst props = defineProps<{\n /** The id of one of the node's ports. */\n id: string\n /** @internal placed by the editor, not by the node's component */\n auto?: boolean\n}>()\n\nconst node = inject(flowNodeKey, null)\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst port = computed(() => node?.ports.value.find((p) => p.id === props.id))\nconst side = computed(() => (port.value ? portSide(port.value) : 'left'))\nconst connected = computed(() => !!node?.connected.value.has(props.id))\nconst editor = inject(flowEditorKey, null)\nconst type = computed(() => (port.value ? editor?.portTypeOf(port.value) : undefined))\nconst shape = computed(() => type.value?.shape ?? 'circle')\nconst color = computed(() => editor?.colorOf(type.value))\nconst states = computed(() => node?.portStates.value)\nconst state = computed(() => states.value?.get(props.id))\n\nonMounted(() => {\n if (el.value) node?.registerPort(props.id, el.value, props.auto)\n})\nonBeforeUnmount(() => node?.unregisterPort(props.id, props.auto))\n</script>\n\n<template>\n <span\n ref=\"el\"\n class=\"dou-flow-port\"\n :class=\"[\n `is-${side}`,\n `is-${port?.kind ?? 'input'}`,\n `is-${shape}`,\n state && `is-${state}`,\n { 'is-connected': connected, 'is-unavailable': states && !state },\n ]\"\n :style=\"color ? { '--dou-flow-port-color': color } : undefined\"\n :data-port=\"id\"\n aria-hidden=\"true\"\n >\n <svg v-if=\"shape === 'triangle'\" viewBox=\"0 0 10 10\">\n <path d=\"M2 1.5 8 5 2 8.5Z\" />\n </svg>\n </span>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAOA,MAAM,QAAQ;EAOd,MAAM,OAAO,OAAO,aAAa,IAAI;EAErC,MAAM,KAAK,eAA4B,IAAI;EAC3C,MAAM,OAAO,eAAe,MAAM,MAAM,MAAM,MAAM,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;EAC5E,MAAM,OAAO,eAAgB,KAAK,QAAQ,SAAS,KAAK,KAAK,IAAI,MAAO;EACxE,MAAM,YAAY,eAAe,CAAC,CAAC,MAAM,UAAU,MAAM,IAAI,MAAM,EAAE,CAAC;EACtE,MAAM,SAAS,OAAO,eAAe,IAAI;EACzC,MAAM,OAAO,eAAgB,KAAK,QAAQ,QAAQ,WAAW,KAAK,KAAK,IAAI,KAAA,CAAU;EACrF,MAAM,QAAQ,eAAe,KAAK,OAAO,SAAS,QAAQ;EAC1D,MAAM,QAAQ,eAAe,QAAQ,QAAQ,KAAK,KAAK,CAAC;EACxD,MAAM,SAAS,eAAe,MAAM,WAAW,KAAK;EACpD,MAAM,QAAQ,eAAe,OAAO,OAAO,IAAI,MAAM,EAAE,CAAC;EAExD,gBAAgB;GACd,IAAI,GAAG,OAAO,MAAM,aAAa,MAAM,IAAI,GAAG,OAAO,MAAM,IAAI;EACjE,CAAC;EACD,sBAAsB,MAAM,eAAe,MAAM,IAAI,MAAM,IAAI,CAAC;;GAI9D,OAAAA,UAAA,GAAAC,mBAiBO,QAAA;IAhBD,SAAA;IAAJ,KAAI;IACJ,OAAKC,eAAA,CAAC,iBAAe;KACC,MAAA,KAAA;KAAoB,MAAA,KAAA,OAAM,QAAI;KAA2B,MAAA,MAAA;KAAe,MAAA,SAAK,MAAU,MAAA;KAAiC;MAAA,gBAAA,UAAA;MAAS,kBAAoB,OAAA,SAAM,CAAK,MAAA;KAAK;;IAO1L,OAAKC,eAAE,MAAA,QAAK,EAAA,yBAA8B,MAAA,MAAK,IAAK,KAAA,CAAS;IAC7D,aAAW,QAAA;IACZ,eAAY;G,IAED,MAAA,UAAK,cAAhBH,UAAA,GAAAC,mBAEM,OAFN,YAEM,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CADJG,mBAA8B,QAAA,EAAxB,GAAE,oBAAmB,GAAA,MAAA,EAAA,C"}
1
+ {"version":3,"file":"flow-port.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","PortView"],"sources":["../../src/components/flow-port.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { FlowPortVisible } from '../core/model'\nimport PortView from './port-view.vue'\n\ndefineOptions({ name: 'DouFlowPort' })\n\ndefineProps<{\n /** The id of one of the node's ports. */\n id: string\n /**\n * When the port shows: `always`; `hover`, on a hovered or selected node,\n * or one with the keyboard focus in it (a field being typed in);\n * or `connecting`, only while an edge is drawn. Never shown in a\n * readonly editor. Defaults to the port's own `visible`, else `always`.\n */\n visible?: FlowPortVisible\n}>()\n</script>\n\n<template>\n <PortView :id=\"id\" :visible=\"visible\" />\n</template>\n"],"mappings":";;;;;;;;;;;;GAoBE,OAAAA,UAAA,GAAAC,YAAwCC,mBAAA;IAA7B,IAAI,QAAA;IAAK,SAAS,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"node-view.js","names":["_sfc_main"],"sources":["../../src/components/node-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { flowNodeKey, type NodeMetrics, type PortAnchor, type PortState } from '../context'\nimport type { FlowNode, FlowPortSpec, PortSide } from '../core/model'\nimport { portSide, portsOf, resizeOf, type NodeTypeSpec } from '../core/node-types'\nimport DefaultNode from './default-node.vue'\nimport FlowPortView from './flow-port.vue'\n\nconst props = defineProps<{\n node: FlowNode\n spec: NodeTypeSpec | undefined\n selected: boolean\n readonly: boolean\n dragging: boolean\n connected: Set<string>\n portStates: Map<string, PortState> | null\n roleDescription: string\n /** The node's accessible name. */\n label: string\n /** Read out after the name, e.g. the port counts. */\n description: string\n /** Where the nodes being dragged will be put. */\n dropTarget?: boolean\n}>()\nconst emit = defineEmits<{\n measure: [id: string, metrics: NodeMetrics]\n update: [id: string, patch: Record<string, unknown>]\n}>()\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst ports = computed(() => portsOf(props.spec, props.node))\n\n// Ports placed by the node's component, and the ones the editor places.\nconst placed = new Map<string, HTMLElement>()\nconst autoPlaced = new Map<string, HTMLElement>()\nconst placedIds = shallowRef(new Set<string>())\nconst mounted = shallowRef(false)\n\nprovide(flowNodeKey, {\n node: computed(() => props.node),\n ports,\n connected: computed(() => props.connected),\n portStates: computed(() => props.portStates),\n registerPort(id, portEl, auto) {\n if (auto) autoPlaced.set(id, portEl)\n else {\n placed.set(id, portEl)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n unregisterPort(id, auto) {\n if (auto) autoPlaced.delete(id)\n else {\n placed.delete(id)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n})\n\nconst autoPorts = computed(() =>\n mounted.value ? ports.value.filter((port) => !placedIds.value.has(port.id)) : [],\n)\n\n/** Spreads the editor-placed ports evenly along each side. */\nfunction autoStyle(port: FlowPortSpec): CSSProperties {\n const side = portSide(port)\n const same = autoPorts.value.filter((p) => portSide(p) === side)\n const at = `${((same.indexOf(port) + 1) / (same.length + 1)) * 100}%`\n return side === 'left' || side === 'right' ? { top: at } : { left: at }\n}\n\nfunction measure() {\n const node = el.value\n if (!node || !node.offsetWidth) return\n const box = node.getBoundingClientRect()\n // The canvas is scaled; measure in its own units.\n const scale = box.width / node.offsetWidth || 1\n const anchors = new Map<string, PortAnchor>()\n for (const port of ports.value) {\n const portEl = placed.get(port.id) ?? autoPlaced.get(port.id)\n if (!portEl) continue\n const rect = portEl.getBoundingClientRect()\n const side: PortSide = portSide(port)\n anchors.set(port.id, {\n x: (rect.left + rect.width / 2 - box.left) / scale,\n y: (rect.top + rect.height / 2 - box.top) / scale,\n side,\n })\n }\n emit('measure', props.node.id, {\n width: node.offsetWidth,\n height: node.offsetHeight,\n ports: anchors,\n })\n}\n\nlet pending = false\nfunction scheduleMeasure() {\n if (pending) return\n pending = true\n void nextTick(() => {\n pending = false\n measure()\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n mounted.value = true\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(() => measure())\n observer.observe(el.value!)\n }\n scheduleMeasure()\n})\nonBeforeUnmount(() => observer?.disconnect())\n\n// Content changes can move ports without resizing the node.\nwatch(\n () => [props.node.data, props.node.type, ports.value],\n () => scheduleMeasure(),\n { flush: 'post' },\n)\n\nconst container = computed(() => !!props.spec?.container)\n// A collapsed container is as tall as its content, its title.\nconst collapsed = computed(() => container.value && !!props.node.data?.collapsed)\nconst resizable = computed(\n () => !!resizeOf(props.spec, props.node) && !props.readonly && !collapsed.value,\n)\n\n/** How far the node is drawn turned, so its selection outline turns with it. */\nconst rotation = computed(() => props.spec?.rotation?.(props.node) ?? 0)\n\nconst style = computed<CSSProperties>(() => ({\n transform: `translate(${props.node.x}px, ${props.node.y}px)`,\n '--dou-flow-node-rotation': rotation.value ? `${rotation.value}deg` : undefined,\n width: props.node.width != null ? `${props.node.width}px` : undefined,\n height: props.node.height != null && !collapsed.value ? `${props.node.height}px` : undefined,\n}))\n\nconst viewProps = computed(() => ({\n node: props.node,\n data: props.node.data ?? {},\n ports: ports.value,\n selected: props.selected,\n readonly: props.readonly,\n updateData: (patch: Record<string, unknown>) => emit('update', props.node.id, patch),\n}))\n</script>\n\n<template>\n <div\n ref=\"el\"\n class=\"dou-flow-editor__node\"\n :class=\"{\n 'is-selected': selected,\n 'is-locked': node.locked,\n 'is-dragging': dragging,\n 'is-sized': node.width != null,\n 'is-container': container,\n 'is-bare': spec?.frame === false,\n 'is-turned': !!rotation,\n 'is-collapsed': collapsed,\n 'is-drop-target': dropTarget,\n }\"\n :style=\"style\"\n :data-node-id=\"node.id\"\n role=\"group\"\n :aria-roledescription=\"roleDescription\"\n :aria-label=\"label\"\n :aria-description=\"description || undefined\"\n tabindex=\"-1\"\n >\n <component :is=\"spec?.component ?? DefaultNode\" v-bind=\"viewProps\" />\n <FlowPortView\n v-for=\"port in autoPorts\"\n :id=\"port.id\"\n :key=\"port.id\"\n auto\n class=\"is-auto\"\n :style=\"autoStyle(port)\"\n />\n <span v-if=\"resizable && selected\" class=\"dou-flow-editor__resize\" aria-hidden=\"true\" />\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"node-view.js","names":["_sfc_main"],"sources":["../../src/components/node-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { flowNodeKey, type NodeMetrics, type PortAnchor, type PortState } from '../context'\nimport type { FlowNode, FlowPortSpec, PortSide } from '../core/model'\nimport { portSide, portsOf, resizeOf, type NodeTypeSpec } from '../core/node-types'\nimport DefaultNode from './default-node.vue'\nimport FlowPortView from './port-view.vue'\n\nconst props = defineProps<{\n node: FlowNode\n spec: NodeTypeSpec | undefined\n selected: boolean\n readonly: boolean\n dragging: boolean\n connected: Set<string>\n portStates: Map<string, PortState> | null\n roleDescription: string\n /** The node's accessible name. */\n label: string\n /** Read out after the name, e.g. the port counts. */\n description: string\n /** Where the nodes being dragged will be put. */\n dropTarget?: boolean\n}>()\nconst emit = defineEmits<{\n measure: [id: string, metrics: NodeMetrics]\n update: [id: string, patch: Record<string, unknown>]\n}>()\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst ports = computed(() => portsOf(props.spec, props.node))\n\n// Ports placed by the node's component, and the ones the editor places.\nconst placed = new Map<string, HTMLElement>()\nconst autoPlaced = new Map<string, HTMLElement>()\nconst placedIds = shallowRef(new Set<string>())\nconst mounted = shallowRef(false)\n\nprovide(flowNodeKey, {\n node: computed(() => props.node),\n ports,\n connected: computed(() => props.connected),\n portStates: computed(() => props.portStates),\n registerPort(id, portEl, auto) {\n if (auto) autoPlaced.set(id, portEl)\n else {\n placed.set(id, portEl)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n unregisterPort(id, auto) {\n if (auto) autoPlaced.delete(id)\n else {\n placed.delete(id)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n})\n\nconst autoPorts = computed(() =>\n mounted.value ? ports.value.filter((port) => !placedIds.value.has(port.id)) : [],\n)\n\n/** Spreads the editor-placed ports evenly along each side. */\nfunction autoStyle(port: FlowPortSpec): CSSProperties {\n const side = portSide(port)\n const same = autoPorts.value.filter((p) => portSide(p) === side)\n const at = `${((same.indexOf(port) + 1) / (same.length + 1)) * 100}%`\n return side === 'left' || side === 'right' ? { top: at } : { left: at }\n}\n\nfunction measure() {\n const node = el.value\n if (!node || !node.offsetWidth) return\n const box = node.getBoundingClientRect()\n // The canvas is scaled; measure in its own units.\n const scale = box.width / node.offsetWidth || 1\n const anchors = new Map<string, PortAnchor>()\n for (const port of ports.value) {\n const portEl = placed.get(port.id) ?? autoPlaced.get(port.id)\n if (!portEl) continue\n const rect = portEl.getBoundingClientRect()\n const side: PortSide = portSide(port)\n anchors.set(port.id, {\n x: (rect.left + rect.width / 2 - box.left) / scale,\n y: (rect.top + rect.height / 2 - box.top) / scale,\n side,\n })\n }\n emit('measure', props.node.id, {\n width: node.offsetWidth,\n height: node.offsetHeight,\n ports: anchors,\n })\n}\n\nlet pending = false\nfunction scheduleMeasure() {\n if (pending) return\n pending = true\n void nextTick(() => {\n pending = false\n measure()\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n mounted.value = true\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(() => measure())\n observer.observe(el.value!)\n }\n scheduleMeasure()\n})\nonBeforeUnmount(() => observer?.disconnect())\n\n// Content changes can move ports without resizing the node.\nwatch(\n () => [props.node.data, props.node.type, ports.value],\n () => scheduleMeasure(),\n { flush: 'post' },\n)\n\nconst container = computed(() => !!props.spec?.container)\n// A collapsed container is as tall as its content, its title.\nconst collapsed = computed(() => container.value && !!props.node.data?.collapsed)\nconst resizable = computed(\n () => !!resizeOf(props.spec, props.node) && !props.readonly && !collapsed.value,\n)\n\n/** How far the node is drawn turned, so its selection outline turns with it. */\nconst rotation = computed(() => props.spec?.rotation?.(props.node) ?? 0)\n\nconst style = computed<CSSProperties>(() => ({\n transform: `translate(${props.node.x}px, ${props.node.y}px)`,\n '--dou-flow-node-rotation': rotation.value ? `${rotation.value}deg` : undefined,\n width: props.node.width != null ? `${props.node.width}px` : undefined,\n height: props.node.height != null && !collapsed.value ? `${props.node.height}px` : undefined,\n}))\n\nconst viewProps = computed(() => ({\n node: props.node,\n data: props.node.data ?? {},\n ports: ports.value,\n selected: props.selected,\n readonly: props.readonly,\n updateData: (patch: Record<string, unknown>) => emit('update', props.node.id, patch),\n}))\n</script>\n\n<template>\n <div\n ref=\"el\"\n class=\"dou-flow-editor__node\"\n :class=\"{\n 'is-selected': selected,\n 'is-locked': node.locked,\n 'is-dragging': dragging,\n 'is-sized': node.width != null,\n 'is-container': container,\n 'is-bare': spec?.frame === false,\n 'is-turned': !!rotation,\n 'is-collapsed': collapsed,\n 'is-drop-target': dropTarget,\n }\"\n :style=\"style\"\n :data-node-id=\"node.id\"\n role=\"group\"\n :aria-roledescription=\"roleDescription\"\n :aria-label=\"label\"\n :aria-description=\"description || undefined\"\n tabindex=\"-1\"\n >\n <component :is=\"spec?.component ?? DefaultNode\" v-bind=\"viewProps\" />\n <FlowPortView\n v-for=\"port in autoPorts\"\n :id=\"port.id\"\n :key=\"port.id\"\n auto\n class=\"is-auto\"\n :style=\"autoStyle(port)\"\n />\n <span v-if=\"resizable && selected\" class=\"dou-flow-editor__resize\" aria-hidden=\"true\" />\n </div>\n</template>\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import { flowNodeKey } from "../context.js";
2
2
  import { portSide, portsOf, resizeOf } from "../core/node-types.js";
3
- import flow_port_default from "./flow-port.js";
3
+ import port_view_default from "./port-view.js";
4
4
  import default_node_default from "./default-node.js";
5
5
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, defineComponent, guardReactiveProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, renderList, resolveDynamicComponent, shallowRef, useTemplateRef, watch } from "vue";
6
6
  // src/components/node-view.vue?vue&type=script&setup=true&lang.ts
@@ -161,7 +161,7 @@ var node_view_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
161
161
  }, [
162
162
  (openBlock(), createBlock(resolveDynamicComponent(__props.spec?.component ?? default_node_default), normalizeProps(guardReactiveProps(viewProps.value)), null, 16)),
163
163
  (openBlock(true), createElementBlock(Fragment, null, renderList(autoPorts.value, (port) => {
164
- return openBlock(), createBlock(flow_port_default, {
164
+ return openBlock(), createBlock(port_view_default, {
165
165
  id: port.id,
166
166
  key: port.id,
167
167
  auto: "",
@@ -1 +1 @@
1
- {"version":3,"file":"node-view.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_createBlock","_resolveDynamicComponent","DefaultNode","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","FlowPortView","_createCommentVNode"],"sources":["../../src/components/node-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { flowNodeKey, type NodeMetrics, type PortAnchor, type PortState } from '../context'\nimport type { FlowNode, FlowPortSpec, PortSide } from '../core/model'\nimport { portSide, portsOf, resizeOf, type NodeTypeSpec } from '../core/node-types'\nimport DefaultNode from './default-node.vue'\nimport FlowPortView from './flow-port.vue'\n\nconst props = defineProps<{\n node: FlowNode\n spec: NodeTypeSpec | undefined\n selected: boolean\n readonly: boolean\n dragging: boolean\n connected: Set<string>\n portStates: Map<string, PortState> | null\n roleDescription: string\n /** The node's accessible name. */\n label: string\n /** Read out after the name, e.g. the port counts. */\n description: string\n /** Where the nodes being dragged will be put. */\n dropTarget?: boolean\n}>()\nconst emit = defineEmits<{\n measure: [id: string, metrics: NodeMetrics]\n update: [id: string, patch: Record<string, unknown>]\n}>()\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst ports = computed(() => portsOf(props.spec, props.node))\n\n// Ports placed by the node's component, and the ones the editor places.\nconst placed = new Map<string, HTMLElement>()\nconst autoPlaced = new Map<string, HTMLElement>()\nconst placedIds = shallowRef(new Set<string>())\nconst mounted = shallowRef(false)\n\nprovide(flowNodeKey, {\n node: computed(() => props.node),\n ports,\n connected: computed(() => props.connected),\n portStates: computed(() => props.portStates),\n registerPort(id, portEl, auto) {\n if (auto) autoPlaced.set(id, portEl)\n else {\n placed.set(id, portEl)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n unregisterPort(id, auto) {\n if (auto) autoPlaced.delete(id)\n else {\n placed.delete(id)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n})\n\nconst autoPorts = computed(() =>\n mounted.value ? ports.value.filter((port) => !placedIds.value.has(port.id)) : [],\n)\n\n/** Spreads the editor-placed ports evenly along each side. */\nfunction autoStyle(port: FlowPortSpec): CSSProperties {\n const side = portSide(port)\n const same = autoPorts.value.filter((p) => portSide(p) === side)\n const at = `${((same.indexOf(port) + 1) / (same.length + 1)) * 100}%`\n return side === 'left' || side === 'right' ? { top: at } : { left: at }\n}\n\nfunction measure() {\n const node = el.value\n if (!node || !node.offsetWidth) return\n const box = node.getBoundingClientRect()\n // The canvas is scaled; measure in its own units.\n const scale = box.width / node.offsetWidth || 1\n const anchors = new Map<string, PortAnchor>()\n for (const port of ports.value) {\n const portEl = placed.get(port.id) ?? autoPlaced.get(port.id)\n if (!portEl) continue\n const rect = portEl.getBoundingClientRect()\n const side: PortSide = portSide(port)\n anchors.set(port.id, {\n x: (rect.left + rect.width / 2 - box.left) / scale,\n y: (rect.top + rect.height / 2 - box.top) / scale,\n side,\n })\n }\n emit('measure', props.node.id, {\n width: node.offsetWidth,\n height: node.offsetHeight,\n ports: anchors,\n })\n}\n\nlet pending = false\nfunction scheduleMeasure() {\n if (pending) return\n pending = true\n void nextTick(() => {\n pending = false\n measure()\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n mounted.value = true\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(() => measure())\n observer.observe(el.value!)\n }\n scheduleMeasure()\n})\nonBeforeUnmount(() => observer?.disconnect())\n\n// Content changes can move ports without resizing the node.\nwatch(\n () => [props.node.data, props.node.type, ports.value],\n () => scheduleMeasure(),\n { flush: 'post' },\n)\n\nconst container = computed(() => !!props.spec?.container)\n// A collapsed container is as tall as its content, its title.\nconst collapsed = computed(() => container.value && !!props.node.data?.collapsed)\nconst resizable = computed(\n () => !!resizeOf(props.spec, props.node) && !props.readonly && !collapsed.value,\n)\n\n/** How far the node is drawn turned, so its selection outline turns with it. */\nconst rotation = computed(() => props.spec?.rotation?.(props.node) ?? 0)\n\nconst style = computed<CSSProperties>(() => ({\n transform: `translate(${props.node.x}px, ${props.node.y}px)`,\n '--dou-flow-node-rotation': rotation.value ? `${rotation.value}deg` : undefined,\n width: props.node.width != null ? `${props.node.width}px` : undefined,\n height: props.node.height != null && !collapsed.value ? `${props.node.height}px` : undefined,\n}))\n\nconst viewProps = computed(() => ({\n node: props.node,\n data: props.node.data ?? {},\n ports: ports.value,\n selected: props.selected,\n readonly: props.readonly,\n updateData: (patch: Record<string, unknown>) => emit('update', props.node.id, patch),\n}))\n</script>\n\n<template>\n <div\n ref=\"el\"\n class=\"dou-flow-editor__node\"\n :class=\"{\n 'is-selected': selected,\n 'is-locked': node.locked,\n 'is-dragging': dragging,\n 'is-sized': node.width != null,\n 'is-container': container,\n 'is-bare': spec?.frame === false,\n 'is-turned': !!rotation,\n 'is-collapsed': collapsed,\n 'is-drop-target': dropTarget,\n }\"\n :style=\"style\"\n :data-node-id=\"node.id\"\n role=\"group\"\n :aria-roledescription=\"roleDescription\"\n :aria-label=\"label\"\n :aria-description=\"description || undefined\"\n tabindex=\"-1\"\n >\n <component :is=\"spec?.component ?? DefaultNode\" v-bind=\"viewProps\" />\n <FlowPortView\n v-for=\"port in autoPorts\"\n :id=\"port.id\"\n :key=\"port.id\"\n auto\n class=\"is-auto\"\n :style=\"autoStyle(port)\"\n />\n <span v-if=\"resizable && selected\" class=\"dou-flow-editor__resize\" aria-hidden=\"true\" />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBA,MAAM,QAAQ;EAgBd,MAAM,OAAO;EAKb,MAAM,KAAK,eAA4B,IAAI;EAC3C,MAAM,QAAQ,eAAe,QAAQ,MAAM,MAAM,MAAM,IAAI,CAAC;EAG5D,MAAM,yBAAS,IAAI,IAAyB;EAC5C,MAAM,6BAAa,IAAI,IAAyB;EAChD,MAAM,YAAY,2BAAW,IAAI,IAAY,CAA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,UAAA,GAAAC,mBAAwF,QAAxF,UAAwF,K"}
1
+ {"version":3,"file":"node-view.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_createBlock","_resolveDynamicComponent","DefaultNode","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","FlowPortView","_createCommentVNode"],"sources":["../../src/components/node-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { flowNodeKey, type NodeMetrics, type PortAnchor, type PortState } from '../context'\nimport type { FlowNode, FlowPortSpec, PortSide } from '../core/model'\nimport { portSide, portsOf, resizeOf, type NodeTypeSpec } from '../core/node-types'\nimport DefaultNode from './default-node.vue'\nimport FlowPortView from './port-view.vue'\n\nconst props = defineProps<{\n node: FlowNode\n spec: NodeTypeSpec | undefined\n selected: boolean\n readonly: boolean\n dragging: boolean\n connected: Set<string>\n portStates: Map<string, PortState> | null\n roleDescription: string\n /** The node's accessible name. */\n label: string\n /** Read out after the name, e.g. the port counts. */\n description: string\n /** Where the nodes being dragged will be put. */\n dropTarget?: boolean\n}>()\nconst emit = defineEmits<{\n measure: [id: string, metrics: NodeMetrics]\n update: [id: string, patch: Record<string, unknown>]\n}>()\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst ports = computed(() => portsOf(props.spec, props.node))\n\n// Ports placed by the node's component, and the ones the editor places.\nconst placed = new Map<string, HTMLElement>()\nconst autoPlaced = new Map<string, HTMLElement>()\nconst placedIds = shallowRef(new Set<string>())\nconst mounted = shallowRef(false)\n\nprovide(flowNodeKey, {\n node: computed(() => props.node),\n ports,\n connected: computed(() => props.connected),\n portStates: computed(() => props.portStates),\n registerPort(id, portEl, auto) {\n if (auto) autoPlaced.set(id, portEl)\n else {\n placed.set(id, portEl)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n unregisterPort(id, auto) {\n if (auto) autoPlaced.delete(id)\n else {\n placed.delete(id)\n placedIds.value = new Set(placed.keys())\n }\n scheduleMeasure()\n },\n})\n\nconst autoPorts = computed(() =>\n mounted.value ? ports.value.filter((port) => !placedIds.value.has(port.id)) : [],\n)\n\n/** Spreads the editor-placed ports evenly along each side. */\nfunction autoStyle(port: FlowPortSpec): CSSProperties {\n const side = portSide(port)\n const same = autoPorts.value.filter((p) => portSide(p) === side)\n const at = `${((same.indexOf(port) + 1) / (same.length + 1)) * 100}%`\n return side === 'left' || side === 'right' ? { top: at } : { left: at }\n}\n\nfunction measure() {\n const node = el.value\n if (!node || !node.offsetWidth) return\n const box = node.getBoundingClientRect()\n // The canvas is scaled; measure in its own units.\n const scale = box.width / node.offsetWidth || 1\n const anchors = new Map<string, PortAnchor>()\n for (const port of ports.value) {\n const portEl = placed.get(port.id) ?? autoPlaced.get(port.id)\n if (!portEl) continue\n const rect = portEl.getBoundingClientRect()\n const side: PortSide = portSide(port)\n anchors.set(port.id, {\n x: (rect.left + rect.width / 2 - box.left) / scale,\n y: (rect.top + rect.height / 2 - box.top) / scale,\n side,\n })\n }\n emit('measure', props.node.id, {\n width: node.offsetWidth,\n height: node.offsetHeight,\n ports: anchors,\n })\n}\n\nlet pending = false\nfunction scheduleMeasure() {\n if (pending) return\n pending = true\n void nextTick(() => {\n pending = false\n measure()\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n mounted.value = true\n if (typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(() => measure())\n observer.observe(el.value!)\n }\n scheduleMeasure()\n})\nonBeforeUnmount(() => observer?.disconnect())\n\n// Content changes can move ports without resizing the node.\nwatch(\n () => [props.node.data, props.node.type, ports.value],\n () => scheduleMeasure(),\n { flush: 'post' },\n)\n\nconst container = computed(() => !!props.spec?.container)\n// A collapsed container is as tall as its content, its title.\nconst collapsed = computed(() => container.value && !!props.node.data?.collapsed)\nconst resizable = computed(\n () => !!resizeOf(props.spec, props.node) && !props.readonly && !collapsed.value,\n)\n\n/** How far the node is drawn turned, so its selection outline turns with it. */\nconst rotation = computed(() => props.spec?.rotation?.(props.node) ?? 0)\n\nconst style = computed<CSSProperties>(() => ({\n transform: `translate(${props.node.x}px, ${props.node.y}px)`,\n '--dou-flow-node-rotation': rotation.value ? `${rotation.value}deg` : undefined,\n width: props.node.width != null ? `${props.node.width}px` : undefined,\n height: props.node.height != null && !collapsed.value ? `${props.node.height}px` : undefined,\n}))\n\nconst viewProps = computed(() => ({\n node: props.node,\n data: props.node.data ?? {},\n ports: ports.value,\n selected: props.selected,\n readonly: props.readonly,\n updateData: (patch: Record<string, unknown>) => emit('update', props.node.id, patch),\n}))\n</script>\n\n<template>\n <div\n ref=\"el\"\n class=\"dou-flow-editor__node\"\n :class=\"{\n 'is-selected': selected,\n 'is-locked': node.locked,\n 'is-dragging': dragging,\n 'is-sized': node.width != null,\n 'is-container': container,\n 'is-bare': spec?.frame === false,\n 'is-turned': !!rotation,\n 'is-collapsed': collapsed,\n 'is-drop-target': dropTarget,\n }\"\n :style=\"style\"\n :data-node-id=\"node.id\"\n role=\"group\"\n :aria-roledescription=\"roleDescription\"\n :aria-label=\"label\"\n :aria-description=\"description || undefined\"\n tabindex=\"-1\"\n >\n <component :is=\"spec?.component ?? DefaultNode\" v-bind=\"viewProps\" />\n <FlowPortView\n v-for=\"port in autoPorts\"\n :id=\"port.id\"\n :key=\"port.id\"\n auto\n class=\"is-auto\"\n :style=\"autoStyle(port)\"\n />\n <span v-if=\"resizable && selected\" class=\"dou-flow-editor__resize\" aria-hidden=\"true\" />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBA,MAAM,QAAQ;EAgBd,MAAM,OAAO;EAKb,MAAM,KAAK,eAA4B,IAAI;EAC3C,MAAM,QAAQ,eAAe,QAAQ,MAAM,MAAM,MAAM,IAAI,CAAC;EAG5D,MAAM,yBAAS,IAAI,IAAyB;EA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;MACL,OAAKR,eAAE,UAAU,IAAI,CAAA;;;IAEZ,UAAA,SAAa,QAAA,YAAzBH,UAAA,GAAAC,mBAAwF,QAAxF,UAAwF,K"}
@@ -0,0 +1,6 @@
1
+ import port_view_vue_vue_type_script_setup_true_lang_default from "./port-view.vue_vue_type_script_setup_true_lang.js";
2
+ // src/components/port-view.vue
3
+ var port_view_default = port_view_vue_vue_type_script_setup_true_lang_default;
4
+ export { port_view_default as default };
5
+
6
+ //# sourceMappingURL=port-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port-view.js","names":["_sfc_main"],"sources":["../../src/components/port-view.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, inject, onBeforeUnmount, onMounted, useTemplateRef } from 'vue'\nimport { flowEditorKey, flowNodeKey } from '../context'\nimport type { FlowPortVisible } from '../core/model'\nimport { portSide } from '../core/node-types'\n\ndefineOptions({ name: 'DouFlowPortView' })\n\n// The port itself. `<DouFlowPort>` is the public face; the editor places\n// the ports a node's component leaves out with `auto`.\nconst props = defineProps<{\n id: string\n visible?: FlowPortVisible\n /** placed by the editor, not by the node's component */\n auto?: boolean\n}>()\n\nconst node = inject(flowNodeKey, null)\n\nconst el = useTemplateRef<HTMLElement>('el')\nconst port = computed(() => node?.ports.value.find((p) => p.id === props.id))\nconst side = computed(() => (port.value ? portSide(port.value) : 'left'))\nconst connected = computed(() => !!node?.connected.value.has(props.id))\nconst editor = inject(flowEditorKey, null)\nconst type = computed(() => (port.value ? editor?.portTypeOf(port.value) : undefined))\nconst shape = computed(() => type.value?.shape ?? 'circle')\nconst color = computed(() => editor?.colorOf(type.value))\nconst visible = computed(() => props.visible ?? port.value?.visible ?? 'always')\nconst states = computed(() => node?.portStates.value)\nconst state = computed(() => states.value?.get(props.id))\n\nonMounted(() => {\n if (el.value) node?.registerPort(props.id, el.value, props.auto)\n})\nonBeforeUnmount(() => node?.unregisterPort(props.id, props.auto))\n</script>\n\n<template>\n <span\n ref=\"el\"\n class=\"dou-flow-port\"\n :class=\"[\n `is-${side}`,\n `is-${port?.kind ?? 'input'}`,\n `is-${shape}`,\n state && `is-${state}`,\n { 'is-connected': connected, 'is-unavailable': states && !state },\n ]\"\n :style=\"color ? { '--dou-flow-port-color': color } : undefined\"\n :data-port=\"id\"\n :data-visible=\"visible === 'always' ? undefined : visible\"\n aria-hidden=\"true\"\n >\n <svg v-if=\"shape === 'triangle'\" viewBox=\"0 0 10 10\">\n <path d=\"M2 1.5 8 5 2 8.5Z\" />\n </svg>\n </span>\n</template>\n"],"mappings":""}
@@ -0,0 +1,60 @@
1
+ import { flowEditorKey, flowNodeKey } from "../context.js";
2
+ import { portSide } from "../core/node-types.js";
3
+ import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, inject, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, useTemplateRef } from "vue";
4
+ // src/components/port-view.vue?vue&type=script&setup=true&lang.ts
5
+ var _hoisted_1 = ["data-port", "data-visible"];
6
+ var _hoisted_2 = {
7
+ key: 0,
8
+ viewBox: "0 0 10 10"
9
+ };
10
+ var port_view_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
11
+ name: "DouFlowPortView",
12
+ __name: "port-view",
13
+ props: {
14
+ id: {},
15
+ visible: {},
16
+ auto: { type: Boolean }
17
+ },
18
+ setup(__props) {
19
+ const props = __props;
20
+ const node = inject(flowNodeKey, null);
21
+ const el = useTemplateRef("el");
22
+ const port = computed(() => node?.ports.value.find((p) => p.id === props.id));
23
+ const side = computed(() => port.value ? portSide(port.value) : "left");
24
+ const connected = computed(() => !!node?.connected.value.has(props.id));
25
+ const editor = inject(flowEditorKey, null);
26
+ const type = computed(() => port.value ? editor?.portTypeOf(port.value) : void 0);
27
+ const shape = computed(() => type.value?.shape ?? "circle");
28
+ const color = computed(() => editor?.colorOf(type.value));
29
+ const visible = computed(() => props.visible ?? port.value?.visible ?? "always");
30
+ const states = computed(() => node?.portStates.value);
31
+ const state = computed(() => states.value?.get(props.id));
32
+ onMounted(() => {
33
+ if (el.value) node?.registerPort(props.id, el.value, props.auto);
34
+ });
35
+ onBeforeUnmount(() => node?.unregisterPort(props.id, props.auto));
36
+ return (_ctx, _cache) => {
37
+ return openBlock(), createElementBlock("span", {
38
+ ref_key: "el",
39
+ ref: el,
40
+ class: normalizeClass(["dou-flow-port", [
41
+ `is-${side.value}`,
42
+ `is-${port.value?.kind ?? "input"}`,
43
+ `is-${shape.value}`,
44
+ state.value && `is-${state.value}`,
45
+ {
46
+ "is-connected": connected.value,
47
+ "is-unavailable": states.value && !state.value
48
+ }
49
+ ]]),
50
+ style: normalizeStyle(color.value ? { "--dou-flow-port-color": color.value } : void 0),
51
+ "data-port": __props.id,
52
+ "data-visible": visible.value === "always" ? void 0 : visible.value,
53
+ "aria-hidden": "true"
54
+ }, [shape.value === "triangle" ? (openBlock(), createElementBlock("svg", _hoisted_2, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M2 1.5 8 5 2 8.5Z" }, null, -1)])])) : createCommentVNode("", true)], 14, _hoisted_1);
55
+ };
56
+ }
57
+ });
58
+ export { port_view_vue_vue_type_script_setup_true_lang_default as default };
59
+
60
+ //# sourceMappingURL=port-view.vue_vue_type_script_setup_true_lang.js.map