@dou-ui/flow 0.1.0-alpha.2 → 0.1.0-alpha.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","names":[],"sources":["../../src/core/transaction.ts"],"sourcesContent":["import type { FlowDocument, FlowEdge, FlowNode } from './model'\n\n/*\n * Every change to a document is a list of steps. Applying a step also\n * gives the step that undoes it, so history, collaboration and the\n * `transaction` event all work on the same small vocabulary.\n */\n\ntype Patch<T> = { [K in keyof T]?: T[K] | undefined }\n\nexport type FlowStep =\n | { type: 'addNode'; node: FlowNode; index?: number }\n | { type: 'removeNode'; id: string }\n | { type: 'updateNode'; id: string; patch: Patch<FlowNode> }\n | { type: 'addEdge'; edge: FlowEdge; index?: number }\n | { type: 'removeEdge'; id: string }\n | { type: 'updateEdge'; id: string; patch: Patch<FlowEdge> }\n\nexport interface FlowTransactionMeta {\n /** Keep out of the undo history, e.g. changes from another client. */\n history?: boolean\n /**\n * Consecutive transactions in the same group within a second undo as\n * one, e.g. the frames of a drag or repeated arrow key nudges.\n */\n group?: string\n /** Who made the change, passed on to the `transaction` event. */\n origin?: string\n}\n\nfunction patched<T extends object>(item: T, patch: Patch<T>): T {\n const next = { ...item } as Record<string, unknown>\n for (const key of Object.keys(patch)) {\n const value = (patch as Record<string, unknown>)[key]\n if (value === undefined) delete next[key]\n else next[key] = value\n }\n return next as T\n}\n\n/** The values `patch` would replace, so applying them restores `item`. */\nfunction previous<T extends object>(item: T, patch: Patch<T>): Patch<T> {\n const old: Record<string, unknown> = {}\n for (const key of Object.keys(patch)) old[key] = (item as Record<string, unknown>)[key]\n return old as Patch<T>\n}\n\nconst sameValue = (a: unknown, b: unknown) => a === b\n\n/**\n * A batch of changes to a document. Steps apply as they are added, so\n * later calls see earlier ones; `doc` is the result.\n */\nexport class FlowTransaction {\n readonly steps: FlowStep[] = []\n /** The steps that undo this transaction, in the order to apply them. */\n readonly inverse: FlowStep[] = []\n meta: FlowTransactionMeta = {}\n private nodes: FlowNode[]\n private edges: FlowEdge[]\n private copied = { nodes: false, edges: false }\n\n constructor(readonly before: FlowDocument) {\n this.nodes = before.nodes\n this.edges = before.edges\n }\n\n get doc(): FlowDocument {\n if (!this.steps.length) return this.before\n return { ...this.before, nodes: this.nodes, edges: this.edges }\n }\n\n /** Whether the change makes any change: it has steps and wasn't cancelled. */\n get changed() {\n return this.steps.length > 0 && !this.stopped\n }\n\n private stopped: { reason?: string } | null = null\n\n /**\n * Stops the change: none of it is applied or kept for undo, and the\n * editor fires `transactionCancel` and says why. For an extension's `transaction`\n * hook, e.g. to keep people from changing what they may not; hooks after\n * it don't run. A change kept out of the history (`meta.history: false`),\n * such as undo, redo or another person's, can't be cancelled and goes ahead.\n */\n cancel(reason?: string) {\n if (this.meta.history !== false) this.stopped = { reason }\n else warnUncancellable()\n return this\n }\n\n /** Whether `cancel` stopped it. */\n get cancelled() {\n return this.stopped !== null\n }\n\n /** What `cancel` was given, to tell people why. */\n get cancelReason() {\n return this.stopped?.reason\n }\n\n getNode(id: string) {\n return this.nodes.find((node) => node.id === id)\n }\n\n getEdge(id: string) {\n return this.edges.find((edge) => edge.id === id)\n }\n\n /** Edges that start or end at a node. */\n edgesOf(id: string) {\n return this.edges.filter((edge) => edge.source.node === id || edge.target.node === id)\n }\n\n setMeta(meta: FlowTransactionMeta) {\n Object.assign(this.meta, meta)\n return this\n }\n\n step(step: FlowStep) {\n const inverse = this.apply(step)\n if (inverse) {\n this.steps.push(step)\n this.inverse.unshift(inverse)\n }\n return this\n }\n\n addNode(node: FlowNode, index?: number) {\n return this.step({ type: 'addNode', node, index })\n }\n\n /** Removes a node and every edge attached to it. */\n removeNode(id: string) {\n for (const edge of this.edgesOf(id)) this.removeEdge(edge.id)\n return this.step({ type: 'removeNode', id })\n }\n\n updateNode(id: string, patch: Patch<FlowNode>) {\n return this.step({ type: 'updateNode', id, patch })\n }\n\n moveNode(id: string, x: number, y: number) {\n return this.updateNode(id, { x, y })\n }\n\n /** Merges `patch` into the node's `data`. */\n updateData(id: string, patch: Record<string, unknown>) {\n const node = this.getNode(id)\n if (!node) return this\n return this.updateNode(id, { data: { ...node.data, ...patch } })\n }\n\n addEdge(edge: FlowEdge, index?: number) {\n return this.step({ type: 'addEdge', edge, index })\n }\n\n removeEdge(id: string) {\n return this.step({ type: 'removeEdge', id })\n }\n\n updateEdge(id: string, patch: Patch<FlowEdge>) {\n return this.step({ type: 'updateEdge', id, patch })\n }\n\n private writable(kind: 'nodes' | 'edges') {\n if (!this.copied[kind]) {\n this.copied[kind] = true\n if (kind === 'nodes') this.nodes = this.nodes.slice()\n else this.edges = this.edges.slice()\n }\n return kind === 'nodes' ? this.nodes : this.edges\n }\n\n /** Applies a step and returns its inverse, or `null` when it changes nothing. */\n private apply(step: FlowStep): FlowStep | null {\n switch (step.type) {\n case 'addNode': {\n if (this.getNode(step.node.id)) return null\n const list = this.writable('nodes') as FlowNode[]\n const index = clampIndex(step.index, list.length)\n list.splice(index, 0, step.node)\n return { type: 'removeNode', id: step.node.id }\n }\n case 'removeNode': {\n const index = this.nodes.findIndex((node) => node.id === step.id)\n if (index < 0) return null\n const list = this.writable('nodes') as FlowNode[]\n const [node] = list.splice(index, 1)\n return { type: 'addNode', node: node!, index }\n }\n case 'updateNode': {\n const index = this.nodes.findIndex((node) => node.id === step.id)\n if (index < 0) return null\n const node = this.nodes[index]!\n const keys = Object.keys(step.patch) as (keyof FlowNode)[]\n if (keys.every((key) => sameValue(node[key], step.patch[key]))) return null\n const list = this.writable('nodes') as FlowNode[]\n list[index] = patched(node, step.patch)\n return { type: 'updateNode', id: step.id, patch: previous(node, step.patch) }\n }\n case 'addEdge': {\n if (this.getEdge(step.edge.id)) return null\n const list = this.writable('edges') as FlowEdge[]\n list.splice(clampIndex(step.index, list.length), 0, step.edge)\n return { type: 'removeEdge', id: step.edge.id }\n }\n case 'removeEdge': {\n const index = this.edges.findIndex((edge) => edge.id === step.id)\n if (index < 0) return null\n const list = this.writable('edges') as FlowEdge[]\n const [edge] = list.splice(index, 1)\n return { type: 'addEdge', edge: edge!, index }\n }\n case 'updateEdge': {\n const index = this.edges.findIndex((edge) => edge.id === step.id)\n if (index < 0) return null\n const edge = this.edges[index]!\n const keys = Object.keys(step.patch) as (keyof FlowEdge)[]\n if (keys.every((key) => sameValue(edge[key], step.patch[key]))) return null\n const list = this.writable('edges') as FlowEdge[]\n list[index] = patched(edge, step.patch)\n return { type: 'updateEdge', id: step.id, patch: previous(edge, step.patch) }\n }\n }\n }\n}\n\nfunction clampIndex(index: number | undefined, length: number) {\n if (index == null) return length\n return Math.max(0, Math.min(length, index))\n}\n\n/** Applies steps to a document; steps that no longer apply are skipped. */\nexport function applyFlowSteps(doc: FlowDocument, steps: readonly FlowStep[]) {\n const tr = new FlowTransaction(doc)\n for (const step of steps) tr.step(step)\n return tr\n}\n\nconst targetOf = (step: FlowStep) => {\n switch (step.type) {\n case 'addNode':\n return `n:${step.node.id}`\n case 'addEdge':\n return `e:${step.edge.id}`\n case 'removeNode':\n case 'updateNode':\n return `n:${step.id}`\n case 'removeEdge':\n case 'updateEdge':\n return `e:${step.id}`\n }\n}\n\n/**\n * Folds updates of the same node or edge into one, as long as nothing\n * adds or removes it in between. Updates of different targets commute, so\n * the result applies the same as the original list.\n */\nexport function compactFlowSteps(steps: readonly FlowStep[]): FlowStep[] {\n const out: (FlowStep | null)[] = []\n const lastUpdate = new Map<string, number>()\n for (const step of steps) {\n const target = targetOf(step)\n if (step.type === 'updateNode' || step.type === 'updateEdge') {\n const at = lastUpdate.get(target)\n if (at != null) {\n const prev = out[at] as typeof step\n out[at] = { ...prev, patch: { ...prev.patch, ...step.patch } } as FlowStep\n continue\n }\n lastUpdate.set(target, out.length)\n } else {\n lastUpdate.delete(target)\n }\n out.push(step)\n }\n return out.filter((step): step is FlowStep => step != null)\n}\n\nlet warnedUncancellable = false\n/** Says once that cancelling a change kept out of the history does nothing. */\nfunction warnUncancellable() {\n // the app's bundler replaces this, as for Vue's own warnings\n if (process.env.NODE_ENV === 'production' || warnedUncancellable) return\n warnedUncancellable = true\n console.warn(\n \"[@dou-ui/flow] a change kept out of the history (undo, redo or another person's) can't be cancelled; it goes ahead\",\n )\n}\n"],"mappings":";AA8BA,SAAS,QAA0B,MAAS,OAAoB;CAC9D,MAAM,OAAO,EAAE,GAAG,KAAK;CACvB,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EACpC,MAAM,QAAS,MAAkC;EACjD,IAAI,UAAU,KAAA,GAAW,OAAO,KAAK;OAChC,KAAK,OAAO;CACnB;CACA,OAAO;AACT;;AAGA,SAAS,SAA2B,MAAS,OAA2B;CACtE,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG,IAAI,OAAQ,KAAiC;CACnF,OAAO;AACT;AAEA,IAAM,aAAa,GAAY,MAAe,MAAM;;;;;AAMpD,IAAa,kBAAb,MAA6B;CASN;CARrB,QAA6B,CAAC;;CAE9B,UAA+B,CAAC;CAChC,OAA4B,CAAC;CAC7B;CACA;CACA,SAAiB;EAAE,OAAO;EAAO,OAAO;CAAM;CAE9C,YAAY,QAA+B;EAAtB,KAAA,SAAA;EACnB,KAAK,QAAQ,OAAO;EACpB,KAAK,QAAQ,OAAO;CACtB;CAEA,IAAI,MAAoB;EACtB,IAAI,CAAC,KAAK,MAAM,QAAQ,OAAO,KAAK;EACpC,OAAO;GAAE,GAAG,KAAK;GAAQ,OAAO,KAAK;GAAO,OAAO,KAAK;EAAM;CAChE;;CAGA,IAAI,UAAU;EACZ,OAAO,KAAK,MAAM,SAAS,KAAK,CAAC,KAAK;CACxC;CAEA,UAA8C;;;;;;;;CAS9C,OAAO,QAAiB;EACtB,IAAI,KAAK,KAAK,YAAY,OAAO,KAAK,UAAU,EAAE,OAAO;OACpD,kBAAkB;EACvB,OAAO;CACT;;CAGA,IAAI,YAAY;EACd,OAAO,KAAK,YAAY;CAC1B;;CAGA,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AAC5C;;AAGA,SAAgB,eAAe,KAAmB,OAA4B;CAC5E,MAAM,KAAK,IAAI,gBAAgB,GAAG;CAClC,KAAK,MAAM,QAAQ,OAAO,GAAG,KAAK,IAAI;CACtC,OAAO;AACT;AAEA,IAAM,YAAY,SAAmB;CACnC,QAAQ,KAAK,MAAb;EACE,KAAK,WACH,OAAO,KAAK,KAAK,KAAK;EACxB,KAAK,WACH,OAAO,KAAK,KAAK,KAAK;EACxB,KAAK;EACL,KAAK,cACH,OAAO,KAAK,KAAK;EACnB,KAAK;EACL,KAAK,cACH,OAAO,KAAK,KAAK;CACrB;AACF;;;;;;AAOA,SAAgB,iBAAiB,OAAwC;CACvE,MAAM,MAA2B,CAAC;CAClC,MAAM,6BAAa,IAAI,IAAoB;CAC3C,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,SAAS,SAAS,IAAI;EAC5B,IAAI,KAAK,SAAS,gBAAgB,KAAK,SAAS,cAAc;GAC5D,MAAM,KAAK,WAAW,IAAI,MAAM;GAChC,IAAI,MAAM,MAAM;IACd,MAAM,OAAO,IAAI;IACjB,IAAI,MAAM;KAAE,GAAG;KAAM,OAAO;MAAE,GAAG,KAAK;MAAO,GAAG,KAAK;KAAM;IAAE;IAC7D;GACF;GACA,WAAW,IAAI,QAAQ,IAAI,MAAM;EACnC,OACE,WAAW,OAAO,MAAM;EAE1B,IAAI,KAAK,IAAI;CACf;CACA,OAAO,IAAI,QAAQ,SAA2B,QAAQ,IAAI;AAC5D;AAEA,IAAI,sBAAsB;;AAE1B,SAAS,oBAAoB;CAE3B,IAAA,QAAA,IAAA,aAA6B,gBAAgB,qBAAqB;CAClE,sBAAsB;CACtB,QAAQ,KACN,oHACF;AACF"}
1
+ {"version":3,"file":"transaction.js","names":[],"sources":["../../src/core/transaction.ts"],"sourcesContent":["import type { FlowDocument, FlowEdge, FlowNode } from './model'\n\n/*\n * Every change to a document is a list of steps. Applying a step also\n * gives the step that undoes it, so history, collaboration and the\n * `transaction` event all work on the same small vocabulary.\n */\n\ntype Patch<T> = { [K in keyof T]?: T[K] | undefined }\n\nexport type FlowStep =\n | { type: 'addNode'; node: FlowNode; index?: number }\n | { type: 'removeNode'; id: string }\n | { type: 'updateNode'; id: string; patch: Patch<FlowNode> }\n | { type: 'addEdge'; edge: FlowEdge; index?: number }\n | { type: 'removeEdge'; id: string }\n | { type: 'updateEdge'; id: string; patch: Patch<FlowEdge> }\n\nexport interface FlowTransactionMeta {\n /** Keep out of the undo history, e.g. changes from another client. */\n history?: boolean\n /**\n * Consecutive transactions in the same group within a second undo as\n * one, e.g. the frames of a drag or repeated arrow key nudges.\n */\n group?: string\n /** Who made the change, passed on to the `transaction` event. */\n origin?: string\n}\n\nfunction patched<T extends object>(item: T, patch: Patch<T>): T {\n const next = { ...item } as Record<string, unknown>\n for (const key of Object.keys(patch)) {\n const value = (patch as Record<string, unknown>)[key]\n if (value === undefined) delete next[key]\n else next[key] = value\n }\n return next as T\n}\n\n/** The values `patch` would replace, so applying them restores `item`. */\nfunction previous<T extends object>(item: T, patch: Patch<T>): Patch<T> {\n const old: Record<string, unknown> = {}\n for (const key of Object.keys(patch)) old[key] = (item as Record<string, unknown>)[key]\n return old as Patch<T>\n}\n\nconst sameValue = (a: unknown, b: unknown) => a === b\n\n/**\n * A batch of changes to a document. Steps apply as they are added, so\n * later calls see earlier ones; `doc` is the result.\n */\nexport class FlowTransaction {\n readonly steps: FlowStep[] = []\n /** The steps that undo this transaction, in the order to apply them. */\n readonly inverse: FlowStep[] = []\n meta: FlowTransactionMeta = {}\n private nodes: FlowNode[]\n private edges: FlowEdge[]\n private copied = { nodes: false, edges: false }\n\n constructor(readonly before: FlowDocument) {\n this.nodes = before.nodes\n this.edges = before.edges\n }\n\n get doc(): FlowDocument {\n if (!this.steps.length) return this.before\n return { ...this.before, nodes: this.nodes, edges: this.edges }\n }\n\n /** Whether the change makes any change: it has steps and wasn't cancelled. */\n get changed() {\n return this.steps.length > 0 && !this.stopped\n }\n\n private stopped: { reason?: string } | null = null\n\n /**\n * Stops the change: none of it is applied or kept for undo, and the\n * editor fires `transactionCancel` and says why. For an extension's `transaction`\n * hook, e.g. to keep people from changing what they may not; hooks after\n * it don't run. A change kept out of the history (`meta.history: false`),\n * such as undo, redo or another person's, can't be cancelled and goes ahead.\n */\n cancel(reason?: string) {\n if (this.meta.history !== false) this.stopped = { reason }\n else warnUncancellable()\n return this\n }\n\n /** Whether `cancel` stopped it. */\n get cancelled() {\n return this.stopped !== null\n }\n\n /** What `cancel` was given, to tell people why. */\n get cancelReason() {\n return this.stopped?.reason\n }\n\n // Indexes built when first needed and kept up to date after, so moving\n // or removing many nodes of a large document doesn't search it each time.\n private index: { nodes?: Map<string, number>; edges?: Map<string, number> } = {}\n private incident?: Map<string, string[]>\n private was?: { nodes: Map<string, FlowNode>; edges: Map<string, FlowEdge> }\n\n private nodeIndex(id: string) {\n this.index.nodes ??= new Map(this.nodes.map((node, i) => [node.id, i]))\n return this.index.nodes.get(id) ?? -1\n }\n\n private edgeIndex(id: string) {\n this.index.edges ??= new Map(this.edges.map((edge, i) => [edge.id, i]))\n return this.index.edges.get(id) ?? -1\n }\n\n /** The document as it was before this transaction. */\n private get original() {\n this.was ??= {\n nodes: new Map(this.before.nodes.map((node) => [node.id, node])),\n edges: new Map(this.before.edges.map((edge) => [edge.id, edge])),\n }\n return this.was\n }\n\n getNode(id: string) {\n return this.nodes[this.nodeIndex(id)]\n }\n\n getEdge(id: string) {\n return this.edges[this.edgeIndex(id)]\n }\n\n /** Edges that start or end at a node. */\n edgesOf(id: string) {\n if (!this.incident) {\n this.incident = new Map()\n for (const edge of this.edges) this.attach(edge)\n }\n return (this.incident.get(id) ?? []).flatMap((e) => this.getEdge(e) ?? [])\n }\n\n private attach(edge: FlowEdge) {\n if (!this.incident) return\n for (const end of new Set([edge.source.node, edge.target.node])) {\n const list = this.incident.get(end)\n if (list) list.push(edge.id)\n else this.incident.set(end, [edge.id])\n }\n }\n\n private detach(edge: FlowEdge) {\n if (!this.incident) return\n for (const end of new Set([edge.source.node, edge.target.node])) {\n const list = this.incident.get(end)\n const at = list?.indexOf(edge.id) ?? -1\n if (at >= 0) list!.splice(at, 1)\n }\n }\n\n /** Renumbers an index from `from` on, after an insert or removal there. */\n private reindex(map: Map<string, number> | undefined, list: { id: string }[], from: number) {\n if (!map) return\n for (let i = from; i < list.length; i++) map.set(list[i]!.id, i)\n }\n\n setMeta(meta: FlowTransactionMeta) {\n Object.assign(this.meta, meta)\n return this\n }\n\n step(step: FlowStep) {\n const inverse = this.apply(step)\n if (inverse) {\n this.steps.push(step)\n this.inverse.unshift(inverse)\n }\n return this\n }\n\n addNode(node: FlowNode, index?: number) {\n return this.step({ type: 'addNode', node, index })\n }\n\n /** Removes a node and every edge attached to it. */\n removeNode(id: string) {\n for (const edge of this.edgesOf(id)) this.removeEdge(edge.id)\n return this.step({ type: 'removeNode', id })\n }\n\n /**\n * Changes a node. Moving it moves the points of an edge at it along when\n * the edge's other end has moved just as far in this transaction, and\n * drops them otherwise, as they no longer fit; so does resizing it, as\n * its ports move.\n */\n updateNode(id: string, patch: Patch<FlowNode>) {\n const node = this.getNode(id)\n const changed = (key: 'x' | 'y' | 'width' | 'height') =>\n node !== undefined && key in patch && patch[key] !== node[key]\n const moved = changed('x') || changed('y')\n const resized = changed('width') || changed('height')\n this.step({ type: 'updateNode', id, patch })\n if (moved || resized) this.carryPoints(id, resized)\n return this\n }\n\n moveNode(id: string, x: number, y: number) {\n const node = this.getNode(id)\n if (node && node.x === x && node.y === y) return this\n return this.updateNode(id, { x, y })\n }\n\n /** Moves the points of the edges at a moved node along, or drops them. */\n private carryPoints(id: string, drop: boolean) {\n const shift = this.shiftOf(id)\n for (const edge of this.edgesOf(id)) {\n const before = this.original.edges.get(edge.id)\n const other = this.shiftOf(edge.source.node === id ? edge.target.node : edge.source.node)\n const together = !drop && shift && other && other.x === shift.x && other.y === shift.y\n if (before?.points && together)\n this.updateEdge(edge.id, {\n points: before.points.map((p) => ({ x: p.x + shift!.x, y: p.y + shift!.y })),\n })\n else if (edge.points) this.updateEdge(edge.id, { points: undefined })\n }\n }\n\n /** How far a node has moved in this transaction so far. */\n private shiftOf(id: string) {\n const now = this.getNode(id)\n const was = this.original.nodes.get(id)\n return now && was ? { x: now.x - was.x, y: now.y - was.y } : undefined\n }\n\n /** Merges `patch` into the node's `data`. */\n updateData(id: string, patch: Record<string, unknown>) {\n const node = this.getNode(id)\n if (!node) return this\n return this.updateNode(id, { data: { ...node.data, ...patch } })\n }\n\n addEdge(edge: FlowEdge, index?: number) {\n return this.step({ type: 'addEdge', edge, index })\n }\n\n removeEdge(id: string) {\n return this.step({ type: 'removeEdge', id })\n }\n\n updateEdge(id: string, patch: Patch<FlowEdge>) {\n return this.step({ type: 'updateEdge', id, patch })\n }\n\n private writable(kind: 'nodes' | 'edges') {\n if (!this.copied[kind]) {\n this.copied[kind] = true\n if (kind === 'nodes') this.nodes = this.nodes.slice()\n else this.edges = this.edges.slice()\n }\n return kind === 'nodes' ? this.nodes : this.edges\n }\n\n /** Applies a step and returns its inverse, or `null` when it changes nothing. */\n private apply(step: FlowStep): FlowStep | null {\n switch (step.type) {\n case 'addNode': {\n if (this.getNode(step.node.id)) return null\n const list = this.writable('nodes') as FlowNode[]\n const index = clampIndex(step.index, list.length)\n list.splice(index, 0, step.node)\n this.reindex(this.index.nodes, list, index)\n return { type: 'removeNode', id: step.node.id }\n }\n case 'removeNode': {\n const index = this.nodeIndex(step.id)\n if (index < 0) return null\n const list = this.writable('nodes') as FlowNode[]\n const [node] = list.splice(index, 1)\n this.index.nodes?.delete(step.id)\n this.reindex(this.index.nodes, list, index)\n return { type: 'addNode', node: node!, index }\n }\n case 'updateNode': {\n const index = this.nodeIndex(step.id)\n if (index < 0) return null\n const node = this.nodes[index]!\n const keys = Object.keys(step.patch) as (keyof FlowNode)[]\n if (keys.every((key) => sameValue(node[key], step.patch[key]))) return null\n const list = this.writable('nodes') as FlowNode[]\n list[index] = patched(node, step.patch)\n return { type: 'updateNode', id: step.id, patch: previous(node, step.patch) }\n }\n case 'addEdge': {\n if (this.getEdge(step.edge.id)) return null\n const list = this.writable('edges') as FlowEdge[]\n const index = clampIndex(step.index, list.length)\n list.splice(index, 0, step.edge)\n this.reindex(this.index.edges, list, index)\n this.attach(step.edge)\n return { type: 'removeEdge', id: step.edge.id }\n }\n case 'removeEdge': {\n const index = this.edgeIndex(step.id)\n if (index < 0) return null\n const list = this.writable('edges') as FlowEdge[]\n const [edge] = list.splice(index, 1)\n this.index.edges?.delete(step.id)\n this.reindex(this.index.edges, list, index)\n this.detach(edge!)\n return { type: 'addEdge', edge: edge!, index }\n }\n case 'updateEdge': {\n const index = this.edgeIndex(step.id)\n if (index < 0) return null\n const edge = this.edges[index]!\n const keys = Object.keys(step.patch) as (keyof FlowEdge)[]\n if (keys.every((key) => sameValue(edge[key], step.patch[key]))) return null\n const list = this.writable('edges') as FlowEdge[]\n list[index] = patched(edge, step.patch)\n if ('source' in step.patch || 'target' in step.patch) {\n this.detach(edge)\n this.attach(list[index]!)\n }\n return { type: 'updateEdge', id: step.id, patch: previous(edge, step.patch) }\n }\n }\n }\n}\n\nfunction clampIndex(index: number | undefined, length: number) {\n if (index == null) return length\n return Math.max(0, Math.min(length, index))\n}\n\n/** Applies steps to a document; steps that no longer apply are skipped. */\nexport function applyFlowSteps(doc: FlowDocument, steps: readonly FlowStep[]) {\n const tr = new FlowTransaction(doc)\n for (const step of steps) tr.step(step)\n return tr\n}\n\nconst targetOf = (step: FlowStep) => {\n switch (step.type) {\n case 'addNode':\n return `n:${step.node.id}`\n case 'addEdge':\n return `e:${step.edge.id}`\n case 'removeNode':\n case 'updateNode':\n return `n:${step.id}`\n case 'removeEdge':\n case 'updateEdge':\n return `e:${step.id}`\n }\n}\n\n/**\n * Folds updates of the same node or edge into one, as long as nothing\n * adds or removes it in between. Updates of different targets commute, so\n * the result applies the same as the original list.\n */\nexport function compactFlowSteps(steps: readonly FlowStep[]): FlowStep[] {\n const out: (FlowStep | null)[] = []\n const lastUpdate = new Map<string, number>()\n for (const step of steps) {\n const target = targetOf(step)\n if (step.type === 'updateNode' || step.type === 'updateEdge') {\n const at = lastUpdate.get(target)\n if (at != null) {\n const prev = out[at] as typeof step\n out[at] = { ...prev, patch: { ...prev.patch, ...step.patch } } as FlowStep\n continue\n }\n lastUpdate.set(target, out.length)\n } else {\n lastUpdate.delete(target)\n }\n out.push(step)\n }\n return out.filter((step): step is FlowStep => step != null)\n}\n\nlet warnedUncancellable = false\n/** Says once that cancelling a change kept out of the history does nothing. */\nfunction warnUncancellable() {\n // the app's bundler replaces this, as for Vue's own warnings\n if (process.env.NODE_ENV === 'production' || warnedUncancellable) return\n warnedUncancellable = true\n console.warn(\n \"[@dou-ui/flow] a change kept out of the history (undo, redo or another person's) can't be cancelled; it goes ahead\",\n )\n}\n"],"mappings":";AA8BA,SAAS,QAA0B,MAAS,OAAoB;CAC9D,MAAM,OAAO,EAAE,GAAG,KAAK;CACvB,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EACpC,MAAM,QAAS,MAAkC;EACjD,IAAI,UAAU,KAAA,GAAW,OAAO,KAAK;OAChC,KAAK,OAAO;CACnB;CACA,OAAO;AACT;;AAGA,SAAS,SAA2B,MAAS,OAA2B;CACtE,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG,IAAI,OAAQ,KAAiC;CACnF,OAAO;AACT;AAEA,IAAM,aAAa,GAAY,MAAe,MAAM;;;;;AAMpD,IAAa,kBAAb,MAA6B;CASN;CARrB,QAA6B,CAAC;;CAE9B,UAA+B,CAAC;CAChC,OAA4B,CAAC;CAC7B;CACA;CACA,SAAiB;EAAE,OAAO;EAAO,OAAO;CAAM;CAE9C,YAAY,QAA+B;EAAtB,KAAA,SAAA;EACnB,KAAK,QAAQ,OAAO;EACpB,KAAK,QAAQ,OAAO;CACtB;CAEA,IAAI,MAAoB;EACtB,IAAI,CAAC,KAAK,MAAM,QAAQ,OA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