@dou-ui/flow 0.1.0-alpha.3 → 0.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collaboration/index.js +114 -6
- package/dist/collaboration/index.js.map +1 -1
- package/dist/comments.js +257 -0
- package/dist/comments.js.map +1 -0
- package/dist/components/default-node.js.map +1 -1
- package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/flow-comments.js +6 -0
- package/dist/components/flow-comments.js.map +1 -0
- package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js +218 -0
- package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-port.js.map +1 -1
- package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js +7 -42
- package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/flow-toolbar.js.map +1 -1
- package/dist/components/flow-toolbar.vue_vue_type_script_setup_true_lang.js +300 -9
- package/dist/components/flow-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/node-view.js.map +1 -1
- package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/port-view.js +6 -0
- package/dist/components/port-view.js.map +1 -0
- package/dist/components/port-view.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/components/port-view.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/context.js.map +1 -1
- package/dist/core/extension.js.map +1 -1
- package/dist/core/history.js +26 -0
- package/dist/core/history.js.map +1 -1
- package/dist/core/model.js.map +1 -1
- package/dist/core/node-types.js +39 -1
- package/dist/core/node-types.js.map +1 -1
- package/dist/core/transaction.js +5 -4
- package/dist/core/transaction.js.map +1 -1
- package/dist/document.js +1 -1
- package/dist/export/color.js +49 -6
- package/dist/export/color.js.map +1 -1
- package/dist/export/context.js +16 -9
- package/dist/export/context.js.map +1 -1
- package/dist/export/draw.js +6 -5
- package/dist/export/draw.js.map +1 -1
- package/dist/export/render.js +78 -0
- package/dist/export/render.js.map +1 -0
- package/dist/flow-editor.js.map +1 -1
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js +757 -129
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/kit.js +1 -1
- package/dist/locale.js +102 -3
- package/dist/locale.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/style.js +2 -1
- package/dist/types/collaboration/index.d.ts +32 -4
- package/dist/types/comments.d.ts +73 -0
- package/dist/types/components/flow-comments.vue.d.ts +35 -0
- package/dist/types/components/flow-port.vue.d.ts +8 -2
- package/dist/types/components/port-view.vue.d.ts +10 -0
- package/dist/types/components/port.d.ts +2 -2
- package/dist/types/context.d.ts +48 -1
- package/dist/types/core/extension.d.ts +9 -1
- package/dist/types/core/history.d.ts +10 -0
- package/dist/types/core/menu.d.ts +60 -0
- package/dist/types/core/model.d.ts +22 -0
- package/dist/types/core/node-types.d.ts +18 -2
- package/dist/types/core/transaction.d.ts +2 -1
- package/dist/types/export/color.d.ts +6 -1
- package/dist/types/export/render.d.ts +27 -0
- package/dist/types/flow-editor.vue.d.ts +11 -1
- package/dist/types/index.d.ts +36 -7
- package/dist/types/locale.d.ts +27 -1
- package/dist/types/whiteboard/board-node.vue.d.ts +5 -0
- package/dist/types/whiteboard/colors.d.ts +36 -0
- package/dist/types/whiteboard/index.d.ts +2 -2
- package/dist/types/whiteboard/model.d.ts +24 -14
- package/dist/types/whiteboard/state.d.ts +2 -0
- package/dist/types/whiteboard/toolbar.d.ts +46 -0
- package/dist/whiteboard/board-node.js.map +1 -1
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js +76 -20
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/whiteboard/colors.js +84 -0
- package/dist/whiteboard/colors.js.map +1 -0
- package/dist/whiteboard/connector.js +47 -13
- package/dist/whiteboard/connector.js.map +1 -1
- package/dist/whiteboard/draw.js +26 -9
- package/dist/whiteboard/draw.js.map +1 -1
- package/dist/whiteboard/index.js +2 -1
- package/dist/whiteboard/kit.js +65 -8
- package/dist/whiteboard/kit.js.map +1 -1
- package/dist/whiteboard/model.js +5 -31
- package/dist/whiteboard/model.js.map +1 -1
- package/dist/whiteboard/state.js +6 -1
- package/dist/whiteboard/state.js.map +1 -1
- package/dist/whiteboard/toolbar.js +296 -0
- package/dist/whiteboard/toolbar.js.map +1 -0
- package/dist/whiteboard/whiteboard-toolbar.js.map +1 -1
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js +14 -7
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- 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
|
-
|
|
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;
|
|
@@ -99,19 +110,116 @@ function patchFor(local, shared, skip) {
|
|
|
99
110
|
}
|
|
100
111
|
return Object.keys(patch).length ? patch : null;
|
|
101
112
|
}
|
|
113
|
+
/** Runs `run` as one transaction of the maps' document, from `origin`. */
|
|
114
|
+
function transact(maps, run, origin) {
|
|
115
|
+
const ydoc = maps.nodes.doc;
|
|
116
|
+
if (ydoc) ydoc.transact(run, origin ?? null);
|
|
117
|
+
else run();
|
|
118
|
+
}
|
|
102
119
|
/**
|
|
103
120
|
* Writes nodes and edges into empty maps, e.g. when a flow that so far was
|
|
104
121
|
* saved as JSON starts being edited together. Do it once, where the shared
|
|
105
122
|
* document is created.
|
|
106
123
|
*/
|
|
107
|
-
function fillMaps(maps, doc) {
|
|
124
|
+
function fillMaps(maps, doc, options = {}) {
|
|
108
125
|
const fill = () => {
|
|
109
126
|
for (const node of doc.nodes) write(maps.nodes, node);
|
|
110
127
|
for (const edge of doc.edges) write(maps.edges, edge);
|
|
111
128
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
129
|
+
transact(maps, fill, options.origin);
|
|
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();
|
|
136
|
+
/** Every node or edge a map holds. */
|
|
137
|
+
function readAll(map) {
|
|
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;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The flow the maps hold, read without an editor, e.g. to save a version
|
|
144
|
+
* on the server. The order of the nodes and edges is not fixed: it may
|
|
145
|
+
* differ between two reads, and from one client to another.
|
|
146
|
+
*/
|
|
147
|
+
function readMaps(maps) {
|
|
148
|
+
return {
|
|
149
|
+
version: 1,
|
|
150
|
+
nodes: readAll(maps.nodes),
|
|
151
|
+
edges: readAll(maps.edges)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** The fields that differ between two versions of a node or edge. */
|
|
155
|
+
function changedKeys(before, after) {
|
|
156
|
+
const keys = /* @__PURE__ */ new Set();
|
|
157
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
158
|
+
if (key === "id") continue;
|
|
159
|
+
if (!same(key === "data" ? sharedData(before[key]) : before[key], key === "data" ? sharedData(after[key]) : after[key])) keys.add(key);
|
|
160
|
+
}
|
|
161
|
+
return keys;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Brings the map from `base` to `items`: their changed fields written, those
|
|
165
|
+
* left out removed. Without `base`, from what the map holds now.
|
|
166
|
+
*/
|
|
167
|
+
function syncItems(map, items, base, fits = () => true) {
|
|
168
|
+
if (!base) {
|
|
169
|
+
const ids = new Set(items.map((item) => item.id));
|
|
170
|
+
for (const id of Array.from(map.keys())) if (!ids.has(id)) map.delete(id);
|
|
171
|
+
for (const item of items) write(map, item);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const before = new Map(base.map((item) => [item.id, item]));
|
|
175
|
+
const ids = new Set(items.map((item) => item.id));
|
|
176
|
+
for (const id of before.keys()) if (!ids.has(id)) map.delete(id);
|
|
177
|
+
for (const item of items) {
|
|
178
|
+
const old = before.get(item.id);
|
|
179
|
+
if (!old) {
|
|
180
|
+
if (fits(item)) write(map, item);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (!(map.get(item.id) instanceof Y.Map)) continue;
|
|
184
|
+
const keys = changedKeys(old, item);
|
|
185
|
+
if (keys.size) write(map, item, keys);
|
|
186
|
+
}
|
|
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
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Change the maps from `options.base` to `doc`, without an editor, e.g. on
|
|
208
|
+
* the server when a program wrote a new version while people edit the
|
|
209
|
+
* flow. Only the fields that differ are written.
|
|
210
|
+
*/
|
|
211
|
+
function updateMaps(maps, doc, options = {}) {
|
|
212
|
+
const { base } = options;
|
|
213
|
+
if (process.env.NODE_ENV !== "production" && base) warnChangedInPlace(doc, base);
|
|
214
|
+
const update = () => {
|
|
215
|
+
syncItems(maps.nodes, doc.nodes, base?.nodes);
|
|
216
|
+
const there = (end) => maps.nodes.get(end.node) instanceof Y.Map;
|
|
217
|
+
syncItems(maps.edges, doc.edges, base?.edges, (item) => {
|
|
218
|
+
const edge = item;
|
|
219
|
+
return there(edge.source) && there(edge.target);
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
transact(maps, update, options.origin);
|
|
115
223
|
}
|
|
116
224
|
/** The fields `touched` holds for an item, when it holds only some. */
|
|
117
225
|
function heldKeys(touched, id) {
|
|
@@ -355,6 +463,6 @@ function collaboration(options) {
|
|
|
355
463
|
return true;
|
|
356
464
|
}
|
|
357
465
|
}
|
|
358
|
-
export { collaboration, collaborationColors, fillMaps };
|
|
466
|
+
export { collaboration, collaborationColors, fillMaps, readMaps, updateMaps };
|
|
359
467
|
|
|
360
468
|
//# sourceMappingURL=index.js.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\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(\n maps: { nodes: Y.Map<unknown>; edges: Y.Map<unknown> },\n doc: FlowDocument,\n) {\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 const ydoc = maps.nodes.doc\n if (ydoc) ydoc.transact(fill)\n else fill()\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 { Aw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G;KACrC;KACA;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
|
+
{"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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CAAC;IACxC,IAAI,IACF,KAAK,MAAM,MAAM,KAAK,MAAM,KAAK,GAAG;KAClC,IAAI,OAAO,UAAU,KAAK;KAC1B,MAAM,OAAO,QAAQ,YAAY,EAAE;KACnC,IAAI,MAAM,OAAO,KAAK;MAAE;MAAI,GAAG;KAAK,CAAC;IACvC;IACF,UAAU,mBAAmB,QAAQ;KACnC;KACA,WAAW;MACT,OAAO,UAAU,MAAM,MAAM,GAAG,GAAG;MACnC,OAAO,UAAU,MAAM,MAAM,GAAG,GAAG;KACrC;KACA;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"}
|
package/dist/comments.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { defineFlowExtension } from "./core/extension.js";
|
|
2
|
+
import { applyCommentAction } from "dou-ui";
|
|
3
|
+
import { computed, nextTick, shallowRef, watch } from "vue";
|
|
4
|
+
import { MessagePlusIcon } from "@dou-ui/icons";
|
|
5
|
+
// src/comments.ts
|
|
6
|
+
var KEY = "mod+alt+m";
|
|
7
|
+
var fraction = (value) => typeof value === "number" && Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : null;
|
|
8
|
+
/** A point within a node, kept between 0 and 1; `null` when it isn't one. */
|
|
9
|
+
function pinPoint(at) {
|
|
10
|
+
if (!at || typeof at !== "object") return null;
|
|
11
|
+
const x = fraction(at.x);
|
|
12
|
+
const y = fraction(at.y);
|
|
13
|
+
return x === null || y === null ? null : {
|
|
14
|
+
x,
|
|
15
|
+
y
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Where the thread `id` is pinned on a node, if it is. */
|
|
19
|
+
var pinOf = (node, id) => {
|
|
20
|
+
const pins = node.commentPins;
|
|
21
|
+
return pins && typeof pins === "object" && Object.hasOwn(pins, id) ? pinPoint(pins[id]) : null;
|
|
22
|
+
};
|
|
23
|
+
/** The thread ids on a node or edge; nothing when a hand-written document has something else there. */
|
|
24
|
+
var idsOf = (item) => Array.isArray(item.comments) ? item.comments.filter((id) => typeof id === "string") : [];
|
|
25
|
+
function useFlowComments(options) {
|
|
26
|
+
const { props, emit, doc, selection, messages, transact, carry, shownOn } = options;
|
|
27
|
+
const threads = computed(() => props.comments ?? []);
|
|
28
|
+
let latestThreads = null;
|
|
29
|
+
watch(() => props.comments, () => {
|
|
30
|
+
latestThreads = null;
|
|
31
|
+
}, { flush: "sync" });
|
|
32
|
+
const currentThreads = () => {
|
|
33
|
+
const value = threads.value;
|
|
34
|
+
return latestThreads ?? value;
|
|
35
|
+
};
|
|
36
|
+
const enabled = computed(() => props.comments !== void 0);
|
|
37
|
+
const writable = computed(() => enabled.value && !!props.author && props.commentable !== false);
|
|
38
|
+
const innerActive = shallowRef(null);
|
|
39
|
+
const active = computed(() => props.activeComment === void 0 ? innerActive.value : props.activeComment);
|
|
40
|
+
/** The last thread this editor opened, so a `v-model:activeComment` echoing it isn't taken for one from outside. */
|
|
41
|
+
let ownOpen = null;
|
|
42
|
+
function open(id) {
|
|
43
|
+
if (id === active.value) return;
|
|
44
|
+
innerActive.value = id;
|
|
45
|
+
ownOpen = id;
|
|
46
|
+
emit("update:activeComment", id);
|
|
47
|
+
}
|
|
48
|
+
const openedHere = (id) => id === ownOpen;
|
|
49
|
+
const pending = shallowRef(null);
|
|
50
|
+
const pendingFocus = shallowRef(true);
|
|
51
|
+
const focusRequest = shallowRef(0);
|
|
52
|
+
const openOn = computed(() => {
|
|
53
|
+
const live = new Set(threads.value.filter((t) => !t.resolved).map((t) => t.id));
|
|
54
|
+
const known = new Set(threads.value.map((t) => t.id));
|
|
55
|
+
const pins = [];
|
|
56
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const node of doc.value.nodes) {
|
|
58
|
+
const ids = [];
|
|
59
|
+
let number = 0;
|
|
60
|
+
for (const id of idsOf(node)) {
|
|
61
|
+
const at = pinOf(node, id);
|
|
62
|
+
if (at && known.has(id)) number++;
|
|
63
|
+
if (!live.has(id)) continue;
|
|
64
|
+
if (at) pins.push({
|
|
65
|
+
thread: id,
|
|
66
|
+
node: node.id,
|
|
67
|
+
at,
|
|
68
|
+
number
|
|
69
|
+
});
|
|
70
|
+
else ids.push(id);
|
|
71
|
+
}
|
|
72
|
+
if (ids.length) nodes.set(node.id, ids);
|
|
73
|
+
}
|
|
74
|
+
const edges = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const edge of doc.value.edges) {
|
|
76
|
+
const ids = idsOf(edge).filter((id) => live.has(id));
|
|
77
|
+
if (ids.length) edges.set(edge.id, ids);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
nodes,
|
|
81
|
+
edges,
|
|
82
|
+
pins
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
const threadsOf = (anchor) => ("node" in anchor ? openOn.value.nodes.get(anchor.node) : openOn.value.edges.get(anchor.edge)) ?? [];
|
|
86
|
+
/** The open threads on a node or edge, with those its marker shows for what it hides. */
|
|
87
|
+
const openThere = (anchor) => shownOn(anchor) ?? threadsOf(anchor);
|
|
88
|
+
/** The one node or edge selected. */
|
|
89
|
+
function selected() {
|
|
90
|
+
const { nodes, edges } = selection.value;
|
|
91
|
+
if (nodes.length === 1 && !edges.length) return { node: nodes[0] };
|
|
92
|
+
if (edges.length === 1 && !nodes.length) return { edge: edges[0] };
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function show(id, focus) {
|
|
96
|
+
pending.value = null;
|
|
97
|
+
open(id);
|
|
98
|
+
if (focus) focusRequest.value++;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Opens the threads on a node or edge, the selected one by default, or
|
|
102
|
+
* the box to start one there; with `at`, always the box for a new pin.
|
|
103
|
+
* `focus` puts the focus in the reply box: from the keyboard, not from a
|
|
104
|
+
* tap, which would bring up the keyboard on a phone.
|
|
105
|
+
*/
|
|
106
|
+
function start(anchor = selected(), focus = true) {
|
|
107
|
+
if (!enabled.value || !anchor) return false;
|
|
108
|
+
if ("node" in anchor && anchor.at !== void 0) {
|
|
109
|
+
const { node } = anchor;
|
|
110
|
+
const at = pinPoint(anchor.at);
|
|
111
|
+
if (!at || !writable.value || !doc.value.nodes.some((n) => n.id === node)) return false;
|
|
112
|
+
open(null);
|
|
113
|
+
pending.value = {
|
|
114
|
+
node,
|
|
115
|
+
at
|
|
116
|
+
};
|
|
117
|
+
pendingFocus.value = focus;
|
|
118
|
+
if (focus) focusRequest.value++;
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
anchor = "node" in anchor ? { node: anchor.node } : { edge: anchor.edge };
|
|
122
|
+
if (!("node" in anchor ? doc.value.nodes.some((n) => n.id === anchor.node) : doc.value.edges.some((e) => e.id === anchor.edge))) return false;
|
|
123
|
+
const [first] = openThere(anchor);
|
|
124
|
+
if (first) {
|
|
125
|
+
show(first, focus);
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
if (!writable.value) return false;
|
|
129
|
+
open(null);
|
|
130
|
+
pending.value = anchor;
|
|
131
|
+
pendingFocus.value = focus;
|
|
132
|
+
if (focus) focusRequest.value++;
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
function close() {
|
|
136
|
+
pending.value = null;
|
|
137
|
+
open(null);
|
|
138
|
+
}
|
|
139
|
+
/** Adds or takes away a thread's id on what it is about; not an undo step. */
|
|
140
|
+
function mark(anchor, id, add) {
|
|
141
|
+
let patch = null;
|
|
142
|
+
transact((tr) => {
|
|
143
|
+
const item = "node" in anchor ? tr.getNode(anchor.node) : tr.getEdge(anchor.edge);
|
|
144
|
+
if (!item) return;
|
|
145
|
+
const had = idsOf(item);
|
|
146
|
+
const next = add ? [...had.filter((x) => x !== id), id] : had.filter((x) => x !== id);
|
|
147
|
+
patch = { comments: next.length ? next : void 0 };
|
|
148
|
+
if ("node" in anchor) {
|
|
149
|
+
const node = item;
|
|
150
|
+
const at = add && anchor.at ? pinPoint(anchor.at) : null;
|
|
151
|
+
const pins = { ...node.commentPins };
|
|
152
|
+
delete pins[id];
|
|
153
|
+
if (at) pins[id] = at;
|
|
154
|
+
if (at || node.commentPins) patch.commentPins = Object.keys(pins).length ? pins : void 0;
|
|
155
|
+
tr.updateNode(anchor.node, patch);
|
|
156
|
+
} else tr.updateEdge(anchor.edge, patch);
|
|
157
|
+
}, {
|
|
158
|
+
history: false,
|
|
159
|
+
origin: "comment"
|
|
160
|
+
});
|
|
161
|
+
if (patch) carry(anchor, patch);
|
|
162
|
+
}
|
|
163
|
+
function anchorOf(id) {
|
|
164
|
+
const current = doc.value;
|
|
165
|
+
const node = current.nodes.find((n) => idsOf(n).includes(id));
|
|
166
|
+
if (node) {
|
|
167
|
+
const at = pinOf(node, id);
|
|
168
|
+
if (!at) return { node: node.id };
|
|
169
|
+
const known = new Set(currentThreads().map((t) => t.id));
|
|
170
|
+
const pinned = idsOf(node).filter((other) => known.has(other) && pinOf(node, other));
|
|
171
|
+
return {
|
|
172
|
+
node: node.id,
|
|
173
|
+
at,
|
|
174
|
+
number: pinned.indexOf(id) + 1
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const edge = current.edges.find((e) => idsOf(e).includes(id));
|
|
178
|
+
return edge ? { edge: edge.id } : null;
|
|
179
|
+
}
|
|
180
|
+
function apply(action) {
|
|
181
|
+
if (action.type === "create") {
|
|
182
|
+
const anchor = pending.value;
|
|
183
|
+
if (!anchor) return;
|
|
184
|
+
mark(anchor, action.thread.id, true);
|
|
185
|
+
pending.value = null;
|
|
186
|
+
} else if (action.type === "remove") {
|
|
187
|
+
const anchor = anchorOf(action.threadId);
|
|
188
|
+
if (anchor) mark(anchor, action.threadId, false);
|
|
189
|
+
}
|
|
190
|
+
const next = applyCommentAction(currentThreads(), action);
|
|
191
|
+
if (!latestThreads) nextTick(() => latestThreads = null);
|
|
192
|
+
latestThreads = next;
|
|
193
|
+
emit("update:comments", next);
|
|
194
|
+
emit("commentAction", action);
|
|
195
|
+
if (action.type === "create") {
|
|
196
|
+
open(action.thread.id);
|
|
197
|
+
focusRequest.value++;
|
|
198
|
+
} else if (action.type === "remove" || action.type === "resolve") open(null);
|
|
199
|
+
}
|
|
200
|
+
function anchors() {
|
|
201
|
+
return Object.fromEntries(currentThreads().map((thread) => [thread.id, anchorOf(thread.id)]));
|
|
202
|
+
}
|
|
203
|
+
/** Whether `anchor` has something to offer: a thread to open, or one to start. */
|
|
204
|
+
const offered = (anchor) => enabled.value && (writable.value || openThere(anchor).length > 0);
|
|
205
|
+
const item = (anchor) => ({
|
|
206
|
+
key: "comment",
|
|
207
|
+
label: messages.value.comment,
|
|
208
|
+
icon: MessagePlusIcon,
|
|
209
|
+
shortcut: KEY,
|
|
210
|
+
showWhenReadonly: true,
|
|
211
|
+
run: () => void start(anchor)
|
|
212
|
+
});
|
|
213
|
+
const extension = defineFlowExtension({
|
|
214
|
+
name: "comments",
|
|
215
|
+
keymap: () => ({ [KEY]: () => start() }),
|
|
216
|
+
contextMenu(_, target) {
|
|
217
|
+
if (target.kind === "canvas") return [];
|
|
218
|
+
const anchor = target.kind === "node" ? { node: target.node.id } : { edge: target.edge.id };
|
|
219
|
+
return offered(anchor) ? [item(anchor)] : [];
|
|
220
|
+
},
|
|
221
|
+
toolbarItems(_, nodes) {
|
|
222
|
+
if (nodes.length !== 1) return [];
|
|
223
|
+
const anchor = { node: nodes[0].id };
|
|
224
|
+
return offered(anchor) ? [item(anchor)] : [];
|
|
225
|
+
},
|
|
226
|
+
edgeToolbarItems(_, edges) {
|
|
227
|
+
if (edges.length !== 1) return [];
|
|
228
|
+
const anchor = { edge: edges[0].id };
|
|
229
|
+
return offered(anchor) ? [item(anchor)] : [];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
return {
|
|
233
|
+
comments: {
|
|
234
|
+
enabled,
|
|
235
|
+
writable,
|
|
236
|
+
threads,
|
|
237
|
+
author: computed(() => props.author),
|
|
238
|
+
active,
|
|
239
|
+
pending,
|
|
240
|
+
pendingFocus,
|
|
241
|
+
focusRequest,
|
|
242
|
+
openOn,
|
|
243
|
+
start,
|
|
244
|
+
show,
|
|
245
|
+
apply,
|
|
246
|
+
open,
|
|
247
|
+
close,
|
|
248
|
+
openedHere
|
|
249
|
+
},
|
|
250
|
+
extension,
|
|
251
|
+
anchors,
|
|
252
|
+
anchorOf
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
export { pinPoint, useFlowComments };
|
|
256
|
+
|
|
257
|
+
//# sourceMappingURL=comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.js","names":[],"sources":["../src/comments.ts"],"sourcesContent":["import { MessagePlusIcon } from '@dou-ui/icons'\nimport {\n applyCommentAction,\n type CommentAction,\n type CommentAuthor,\n type CommentThread,\n type ContextMenuItem,\n} from 'dou-ui'\nimport {\n computed,\n nextTick,\n shallowRef,\n watch,\n type ComputedRef,\n type Ref,\n type ShallowRef,\n} from 'vue'\nimport type { FlowCommentAnchor, FlowEditorEmits, FlowEditorProps } from './context'\nimport { defineFlowExtension, type FlowExtension } from './core/extension'\nimport type { FlowToolbarItem } from './core/menu'\nimport type { FlowDocument, FlowNode, FlowSelection, Point } from './core/model'\nimport type { FlowTransaction, FlowTransactionMeta } from './core/transaction'\nimport type { FlowMessages } from './locale'\n\ntype Emit = <K extends keyof FlowEditorEmits>(event: K, ...args: FlowEditorEmits[K]) => void\n\n/** The comments, as the editor's parts see them. */\nexport interface FlowComments {\n enabled: ComputedRef<boolean>\n /** Threads can be started and replied to. */\n writable: ComputedRef<boolean>\n threads: ComputedRef<readonly CommentThread[]>\n author: ComputedRef<CommentAuthor | undefined>\n /** The thread open now. */\n active: ComputedRef<string | null>\n /** What a thread being started is about, until its first comment is sent. */\n pending: ShallowRef<FlowCommentAnchor | null>\n /** Whether the reply box of the thread being started takes the focus. */\n pendingFocus: ShallowRef<boolean>\n /** Goes up when the open thread should take the focus, ready for a reply. */\n focusRequest: ShallowRef<number>\n /**\n * The open threads on each node and edge, oldest first; a node's leave\n * out those pinned to a point on it, which are in `pins`.\n */\n openOn: ComputedRef<{\n nodes: Map<string, string[]>\n edges: Map<string, string[]>\n pins: FlowCommentPin[]\n }>\n start: (anchor?: FlowCommentAnchor | null, focus?: boolean) => boolean\n /** Opens a thread, with the focus in its reply box when `focus`. */\n show: (id: string, focus: boolean) => void\n apply: (action: CommentAction) => void\n open: (id: string | null) => void\n close: () => void\n /** Whether this editor opened the thread `id`, rather than the app. */\n openedHere: (id: string | null) => boolean\n}\n\n/** An open thread pinned to a point on a node. */\nexport interface FlowCommentPin {\n thread: string\n node: string\n at: Point\n /** Its number on the node: its place among the node's pins, from 1, oldest first, resolved ones counted. */\n number: number\n}\n\ntype MarkPatch = { comments: string[] | undefined; commentPins?: Record<string, Point> | undefined }\n\nconst KEY = 'mod+alt+m'\n\nconst fraction = (value: unknown) =>\n typeof value === 'number' && Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : null\n\n/** A point within a node, kept between 0 and 1; `null` when it isn't one. */\nexport function pinPoint(at: unknown): Point | null {\n if (!at || typeof at !== 'object') return null\n const x = fraction((at as Point).x)\n const y = fraction((at as Point).y)\n return x === null || y === null ? null : { x, y }\n}\n\n/** Where the thread `id` is pinned on a node, if it is. */\nconst pinOf = (node: FlowNode, id: string): Point | null => {\n const pins = node.commentPins\n return pins && typeof pins === 'object' && Object.hasOwn(pins, id) ? pinPoint(pins[id]) : null\n}\n\n/** The thread ids on a node or edge; nothing when a hand-written document has something else there. */\nconst idsOf = (item: { comments?: unknown }): string[] =>\n Array.isArray(item.comments) ? item.comments.filter((id) => typeof id === 'string') : []\n\nexport function useFlowComments(options: {\n props: FlowEditorProps\n emit: Emit\n doc: Ref<FlowDocument>\n selection: Ref<FlowSelection>\n messages: ComputedRef<FlowMessages>\n transact: (fn: (tr: FlowTransaction) => void, meta?: FlowTransactionMeta) => FlowTransaction\n /** Keeps a change kept out of undo on a node or edge as undo and redo bring it back. */\n carry: (anchor: FlowCommentAnchor, patch: MarkPatch) => void\n /** The open threads a node's marker counts: a collapsed container's take in those inside it. */\n shownOn: (anchor: FlowCommentAnchor) => string[] | undefined\n}) {\n const { props, emit, doc, selection, messages, transact, carry, shownOn } = options\n\n const threads = computed<readonly CommentThread[]>(() => props.comments ?? [])\n /*\n * `v-model:comments` catches up after the parent renders, so reads in the\n * same tick (such as `getCommentAnchors()` inside `@comment-action`) see\n * the latest applied list immediately.\n */\n let latestThreads: readonly CommentThread[] | null = null\n watch(\n () => props.comments,\n () => {\n latestThreads = null\n },\n { flush: 'sync' },\n )\n const currentThreads = (): readonly CommentThread[] => {\n const value = threads.value\n return latestThreads ?? value\n }\n const enabled = computed(() => props.comments !== undefined)\n const writable = computed(() => enabled.value && !!props.author && props.commentable !== false)\n\n const innerActive = shallowRef<string | null>(null)\n const active = computed(() =>\n props.activeComment === undefined ? innerActive.value : props.activeComment,\n )\n /** The last thread this editor opened, so a `v-model:activeComment` echoing it isn't taken for one from outside. */\n let ownOpen: string | null = null\n function open(id: string | null) {\n if (id === active.value) return\n innerActive.value = id\n ownOpen = id\n emit('update:activeComment', id)\n }\n const openedHere = (id: string | null) => id === ownOpen\n\n const pending = shallowRef<FlowCommentAnchor | null>(null)\n const pendingFocus = shallowRef(true)\n const focusRequest = shallowRef(0)\n\n const openOn = computed(() => {\n const live = new Set(threads.value.filter((t) => !t.resolved).map((t) => t.id))\n const known = new Set(threads.value.map((t) => t.id))\n const pins: FlowCommentPin[] = []\n const nodes = new Map<string, string[]>()\n for (const node of doc.value.nodes) {\n const ids: string[] = []\n let number = 0\n for (const id of idsOf(node)) {\n const at = pinOf(node, id)\n // numbered among every pin there, so resolving one renumbers none\n if (at && known.has(id)) number++\n if (!live.has(id)) continue\n if (at) pins.push({ thread: id, node: node.id, at, number })\n else ids.push(id)\n }\n if (ids.length) nodes.set(node.id, ids)\n }\n const edges = new Map<string, string[]>()\n for (const edge of doc.value.edges) {\n const ids = idsOf(edge).filter((id) => live.has(id))\n if (ids.length) edges.set(edge.id, ids)\n }\n return { nodes, edges, pins }\n })\n\n const threadsOf = (anchor: FlowCommentAnchor) =>\n ('node' in anchor\n ? openOn.value.nodes.get(anchor.node)\n : openOn.value.edges.get(anchor.edge)) ?? []\n\n /** The open threads on a node or edge, with those its marker shows for what it hides. */\n const openThere = (anchor: FlowCommentAnchor) => shownOn(anchor) ?? threadsOf(anchor)\n\n /** The one node or edge selected. */\n function selected(): FlowCommentAnchor | null {\n const { nodes, edges } = selection.value\n if (nodes.length === 1 && !edges.length) return { node: nodes[0]! }\n if (edges.length === 1 && !nodes.length) return { edge: edges[0]! }\n return null\n }\n\n function show(id: string, focus: boolean) {\n pending.value = null\n open(id)\n if (focus) focusRequest.value++\n }\n\n /**\n * Opens the threads on a node or edge, the selected one by default, or\n * the box to start one there; with `at`, always the box for a new pin.\n * `focus` puts the focus in the reply box: from the keyboard, not from a\n * tap, which would bring up the keyboard on a phone.\n */\n function start(anchor: FlowCommentAnchor | null = selected(), focus = true): boolean {\n if (!enabled.value || !anchor) return false\n if ('node' in anchor && anchor.at !== undefined) {\n const { node } = anchor\n const at = pinPoint(anchor.at)\n if (!at || !writable.value || !doc.value.nodes.some((n) => n.id === node)) return false\n open(null)\n pending.value = { node, at }\n pendingFocus.value = focus\n if (focus) focusRequest.value++\n return true\n }\n anchor = 'node' in anchor ? { node: anchor.node } : { edge: anchor.edge }\n const there =\n 'node' in anchor\n ? doc.value.nodes.some((n) => n.id === anchor.node)\n : doc.value.edges.some((e) => e.id === anchor.edge)\n if (!there) return false\n // one already there, or shown there: open it\n const [first] = openThere(anchor)\n if (first) {\n show(first, focus)\n return true\n }\n if (!writable.value) return false\n open(null)\n pending.value = anchor\n pendingFocus.value = focus\n if (focus) focusRequest.value++\n return true\n }\n\n function close() {\n pending.value = null\n open(null)\n }\n\n /** Adds or takes away a thread's id on what it is about; not an undo step. */\n function mark(anchor: FlowCommentAnchor, id: string, add: boolean) {\n let patch: MarkPatch | null = null\n transact(\n (tr) => {\n const item = 'node' in anchor ? tr.getNode(anchor.node) : tr.getEdge(anchor.edge)\n if (!item) return\n const had = idsOf(item)\n const next = add ? [...had.filter((x) => x !== id), id] : had.filter((x) => x !== id)\n patch = { comments: next.length ? next : undefined }\n if ('node' in anchor) {\n const node = item as FlowNode\n const at = add && anchor.at ? pinPoint(anchor.at) : null\n const pins = { ...node.commentPins }\n delete pins[id]\n if (at) pins[id] = at\n // only touched when there are pins, so a plain thread keeps the node as it was\n if (at || node.commentPins)\n patch.commentPins = Object.keys(pins).length ? pins : undefined\n tr.updateNode(anchor.node, patch)\n } else tr.updateEdge(anchor.edge, patch)\n },\n { history: false, origin: 'comment' },\n )\n if (patch) carry(anchor, patch)\n }\n\n function anchorOf(id: string): FlowCommentAnchor | null {\n const current = doc.value\n const node = current.nodes.find((n) => idsOf(n).includes(id))\n if (node) {\n const at = pinOf(node, id)\n if (!at) return { node: node.id }\n const known = new Set(currentThreads().map((t) => t.id))\n const pinned = idsOf(node).filter((other) => known.has(other) && pinOf(node, other))\n return { node: node.id, at, number: pinned.indexOf(id) + 1 }\n }\n const edge = current.edges.find((e) => idsOf(e).includes(id))\n return edge ? { edge: edge.id } : null\n }\n\n function apply(action: CommentAction) {\n if (action.type === 'create') {\n const anchor = pending.value\n if (!anchor) return\n mark(anchor, action.thread.id, true)\n pending.value = null\n } else if (action.type === 'remove') {\n const anchor = anchorOf(action.threadId)\n if (anchor) mark(anchor, action.threadId, false)\n }\n const next = applyCommentAction(currentThreads(), action)\n if (!latestThreads) void nextTick(() => (latestThreads = null))\n latestThreads = next\n emit('update:comments', next)\n emit('commentAction', action)\n if (action.type === 'create') {\n open(action.thread.id)\n focusRequest.value++\n } else if (action.type === 'remove' || action.type === 'resolve') open(null)\n }\n\n function anchors(): Record<string, FlowCommentAnchor | null> {\n return Object.fromEntries(currentThreads().map((thread) => [thread.id, anchorOf(thread.id)]))\n }\n\n /** Whether `anchor` has something to offer: a thread to open, or one to start. */\n const offered = (anchor: FlowCommentAnchor) =>\n enabled.value && (writable.value || openThere(anchor).length > 0)\n\n const item = (anchor: FlowCommentAnchor): FlowToolbarItem & ContextMenuItem => ({\n key: 'comment',\n label: messages.value.comment,\n icon: MessagePlusIcon,\n shortcut: KEY,\n showWhenReadonly: true,\n run: () => void start(anchor),\n })\n\n const extension: FlowExtension = defineFlowExtension({\n name: 'comments',\n keymap: () => ({ [KEY]: () => start() }),\n contextMenu(_, target) {\n if (target.kind === 'canvas') return []\n const anchor = target.kind === 'node' ? { node: target.node.id } : { edge: target.edge.id }\n return offered(anchor) ? [item(anchor)] : []\n },\n toolbarItems(_, nodes) {\n if (nodes.length !== 1) return []\n const anchor = { node: nodes[0]!.id }\n return offered(anchor) ? [item(anchor)] : []\n },\n edgeToolbarItems(_, edges) {\n if (edges.length !== 1) return []\n const anchor = { edge: edges[0]!.id }\n return offered(anchor) ? [item(anchor)] : []\n },\n })\n\n const comments: FlowComments = {\n enabled,\n writable,\n threads,\n author: computed(() => props.author),\n active,\n pending,\n pendingFocus,\n focusRequest,\n openOn,\n start,\n show,\n apply,\n open,\n close,\n openedHere,\n }\n\n return { comments, extension, anchors, anchorOf }\n}\n"],"mappings":";;;;;AAuEA,IAAM,MAAM;AAEZ,IAAM,YAAY,UAChB,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,IAAI;;AAG1F,SAAgB,SAAS,IAA2B;CAClD,IAAI,CAAC,MAAM,OAAO,O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AA2B,oBAAoB;EACnD,MAAM;EACN,eAAe,GAAG,YAAY,MAAM,EAAE;EACtC,YAAY,GAAG,QAAQ;GACrB,IAAI,OAAO,SAAS,UAAU,OAAO,CAAC;GACtC,MAAM,SAAS,OAAO,SAAS,SAAS,EAAE,MAAM,OAAO,KAAK,GAAG,IAAI,EAAE,MAAM,OAAO,KAAK,GAAG;GAC1F,OAAO,QAAQ,MAAM,IAAI,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC;EAC7C;EACA,aAAa,GAAG,OAAO;GACrB,IAAI,MAAM,WAAW,GAAG,OAAO,CAAC;GAChC,MAAM,SAAS,EAAE,MAAM,MAAM,EAAE,CAAE,GAAG;GACpC,OAAO,QAAQ,MAAM,IAAI,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC;EAC7C;EACA,iBAAiB,GAAG,OAAO;GACzB,IAAI,MAAM,WAAW,GAAG,OAAO,CAAC;GAChC,MAAM,SAAS,EAAE,MAAM,MAAM,EAAE,CAAE,GAAG;GACpC,OAAO,QAAQ,MAAM,IAAI,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC;EAC7C;CACF,CAAC;CAoBD,OAAO;EAAE,UAAA;GAjBP;GACA;GACA;GACA,QAAQ,eAAe,MAAM,MAAM;GACnC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EAGO;EAAU;EAAW;EAAS;CAAS;AAClD"}
|
|
@@ -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 './
|
|
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":""}
|