@dou-ui/flow 0.0.0-stage → 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/collaboration/index.js +360 -0
- package/dist/collaboration/index.js.map +1 -0
- package/dist/collaboration/peers.js +76 -0
- package/dist/collaboration/peers.js.map +1 -0
- package/dist/components/default-node.js +6 -0
- package/dist/components/default-node.js.map +1 -0
- package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js +87 -0
- package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/default-node2.js +116 -0
- package/dist/components/default-node2.js.map +1 -0
- package/dist/components/flow-controls.js +6 -0
- package/dist/components/flow-controls.js.map +1 -0
- package/dist/components/flow-controls.vue_vue_type_script_setup_true_lang.js +148 -0
- package/dist/components/flow-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-menu.js +6 -0
- package/dist/components/flow-menu.js.map +1 -0
- package/dist/components/flow-menu.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/components/flow-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-minimap.js +6 -0
- package/dist/components/flow-minimap.js.map +1 -0
- package/dist/components/flow-minimap.vue_vue_type_script_setup_true_lang.js +238 -0
- package/dist/components/flow-minimap.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-port.js +6 -0
- package/dist/components/flow-port.js.map +1 -0
- package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-quick-add.js +6 -0
- package/dist/components/flow-quick-add.js.map +1 -0
- package/dist/components/flow-quick-add.vue_vue_type_script_setup_true_lang.js +126 -0
- package/dist/components/flow-quick-add.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-toolbar.js +6 -0
- package/dist/components/flow-toolbar.js.map +1 -0
- package/dist/components/flow-toolbar.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/components/flow-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/group-node.js +6 -0
- package/dist/components/group-node.js.map +1 -0
- package/dist/components/group-node.vue_vue_type_script_setup_true_lang.js +84 -0
- package/dist/components/group-node.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/group-node2.js +42 -0
- package/dist/components/group-node2.js.map +1 -0
- package/dist/components/node-view.js +6 -0
- package/dist/components/node-view.js.map +1 -0
- package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js +179 -0
- package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/context.js +13 -0
- package/dist/context.js.map +1 -0
- package/dist/core/clipboard.js +37 -0
- package/dist/core/clipboard.js.map +1 -0
- package/dist/core/connect.js +74 -0
- package/dist/core/connect.js.map +1 -0
- package/dist/core/edge-types.js +240 -0
- package/dist/core/edge-types.js.map +1 -0
- package/dist/core/extension.js +63 -0
- package/dist/core/extension.js.map +1 -0
- package/dist/core/geometry.js +232 -0
- package/dist/core/geometry.js.map +1 -0
- package/dist/core/groups.js +76 -0
- package/dist/core/groups.js.map +1 -0
- package/dist/core/history.js +79 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/model.js +21 -0
- package/dist/core/model.js.map +1 -0
- package/dist/core/node-types.js +32 -0
- package/dist/core/node-types.js.map +1 -0
- package/dist/core/order.js +42 -0
- package/dist/core/order.js.map +1 -0
- package/dist/core/transaction.js +288 -0
- package/dist/core/transaction.js.map +1 -0
- package/dist/document.js +220 -0
- package/dist/document.js.map +1 -0
- package/dist/export/color.js +38 -0
- package/dist/export/color.js.map +1 -0
- package/dist/export/context.js +223 -0
- package/dist/export/context.js.map +1 -0
- package/dist/export/draw.js +249 -0
- package/dist/export/draw.js.map +1 -0
- package/dist/flow-editor.js +6 -0
- package/dist/flow-editor.js.map +1 -0
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js +3721 -0
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/kit.js +234 -0
- package/dist/kit.js.map +1 -0
- package/dist/layers.js +150 -0
- package/dist/layers.js.map +1 -0
- package/dist/locale.js +426 -0
- package/dist/locale.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/style.d.ts +1 -0
- package/dist/style.js +8 -0
- package/dist/types/collaboration/index.d.ts +42 -0
- package/dist/types/collaboration/peers.d.ts +27 -0
- package/dist/types/components/default-node.d.ts +18 -0
- package/dist/types/components/default-node.vue.d.ts +6 -0
- package/dist/types/components/flow-controls.vue.d.ts +8 -0
- package/dist/types/components/flow-menu.vue.d.ts +29 -0
- package/dist/types/components/flow-minimap.vue.d.ts +8 -0
- package/dist/types/components/flow-port.vue.d.ts +9 -0
- package/dist/types/components/flow-quick-add.vue.d.ts +31 -0
- package/dist/types/components/flow-toolbar.vue.d.ts +25 -0
- package/dist/types/components/group-node.d.ts +13 -0
- package/dist/types/components/group-node.vue.d.ts +6 -0
- package/dist/types/components/node-view.vue.d.ts +28 -0
- package/dist/types/context.d.ts +362 -0
- package/dist/types/core/clipboard.d.ts +9 -0
- package/dist/types/core/connect.d.ts +63 -0
- package/dist/types/core/edge-types.d.ts +50 -0
- package/dist/types/core/extension.d.ts +141 -0
- package/dist/types/core/geometry.d.ts +63 -0
- package/dist/types/core/groups.d.ts +23 -0
- package/dist/types/core/history.d.ts +24 -0
- package/dist/types/core/menu.d.ts +40 -0
- package/dist/types/core/model.d.ts +87 -0
- package/dist/types/core/node-types.d.ts +103 -0
- package/dist/types/core/order.d.ts +7 -0
- package/dist/types/core/transaction.d.ts +97 -0
- package/dist/types/document.d.ts +57 -0
- package/dist/types/export/color.d.ts +7 -0
- package/dist/types/export/context.d.ts +90 -0
- package/dist/types/export/draw.d.ts +72 -0
- package/dist/types/flow-editor.vue.d.ts +63 -0
- package/dist/types/index.d.ts +202 -0
- package/dist/types/kit.d.ts +22 -0
- package/dist/types/layers.d.ts +24 -0
- package/dist/types/locale.d.ts +172 -0
- package/dist/types/whiteboard/board-draft.vue.d.ts +3 -0
- package/dist/types/whiteboard/board-node.vue.d.ts +19 -0
- package/dist/types/whiteboard/connector.d.ts +12 -0
- package/dist/types/whiteboard/draw.d.ts +5 -0
- package/dist/types/whiteboard/image.d.ts +27 -0
- package/dist/types/whiteboard/index.d.ts +6 -0
- package/dist/types/whiteboard/ink.d.ts +30 -0
- package/dist/types/whiteboard/kit.d.ts +36 -0
- package/dist/types/whiteboard/model.d.ts +79 -0
- package/dist/types/whiteboard/pen.d.ts +7 -0
- package/dist/types/whiteboard/state.d.ts +37 -0
- package/dist/types/whiteboard/transform.d.ts +67 -0
- package/dist/types/whiteboard/whiteboard-toolbar.vue.d.ts +3 -0
- package/dist/whiteboard/board-draft.js +6 -0
- package/dist/whiteboard/board-draft.js.map +1 -0
- package/dist/whiteboard/board-draft.vue_vue_type_script_setup_true_lang.js +58 -0
- package/dist/whiteboard/board-draft.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/whiteboard/board-node.js +6 -0
- package/dist/whiteboard/board-node.js.map +1 -0
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js +332 -0
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/whiteboard/connector.js +180 -0
- package/dist/whiteboard/connector.js.map +1 -0
- package/dist/whiteboard/draw.js +68 -0
- package/dist/whiteboard/draw.js.map +1 -0
- package/dist/whiteboard/image.js +104 -0
- package/dist/whiteboard/image.js.map +1 -0
- package/dist/whiteboard/index.js +5 -0
- package/dist/whiteboard/ink.js +168 -0
- package/dist/whiteboard/ink.js.map +1 -0
- package/dist/whiteboard/kit.js +406 -0
- package/dist/whiteboard/kit.js.map +1 -0
- package/dist/whiteboard/model.js +52 -0
- package/dist/whiteboard/model.js.map +1 -0
- package/dist/whiteboard/pen.js +88 -0
- package/dist/whiteboard/pen.js.map +1 -0
- package/dist/whiteboard/state.js +26 -0
- package/dist/whiteboard/state.js.map +1 -0
- package/dist/whiteboard/transform.js +256 -0
- package/dist/whiteboard/transform.js.map +1 -0
- package/dist/whiteboard/whiteboard-toolbar.js +6 -0
- package/dist/whiteboard/whiteboard-toolbar.js.map +1 -0
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js +171 -0
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { ContextMenuItem } from 'dou-ui';
|
|
2
|
+
import type { Component } from 'vue';
|
|
3
|
+
import type { FlowEditorContext } from '../context';
|
|
4
|
+
import type { FlowDrawContext } from '../export/context';
|
|
5
|
+
import type { FlowConnection, PortTypes } from './connect';
|
|
6
|
+
import type { EdgeTypeSpec } from './edge-types';
|
|
7
|
+
import type { FlowMenuTarget, FlowToolbarItem } from './menu';
|
|
8
|
+
import type { FlowDocument, FlowEdge, FlowNode, Point } from './model';
|
|
9
|
+
import type { NodeTypeSpec } from './node-types';
|
|
10
|
+
import type { FlowTransaction } from './transaction';
|
|
11
|
+
/** What an extension's hooks receive; the same as `useFlowEditor()`. */
|
|
12
|
+
export type FlowExtensionContext = FlowEditorContext;
|
|
13
|
+
/**
|
|
14
|
+
* A key handler: return `false` to let the key through to the next handler
|
|
15
|
+
* and the editor's own keys; anything else means it was handled.
|
|
16
|
+
*/
|
|
17
|
+
export type FlowKeyHandler = (event: KeyboardEvent) => boolean | void;
|
|
18
|
+
/** An undo history that replaces the editor's own, e.g. one that only undoes this user's changes. */
|
|
19
|
+
export interface FlowHistoryHandler {
|
|
20
|
+
/** `false` when there is nothing to undo. */
|
|
21
|
+
undo: () => boolean;
|
|
22
|
+
redo: () => boolean;
|
|
23
|
+
canUndo: () => boolean;
|
|
24
|
+
canRedo: () => boolean;
|
|
25
|
+
}
|
|
26
|
+
/** A press on the editor that an extension may take over, e.g. a drawing tool. */
|
|
27
|
+
export interface FlowPress {
|
|
28
|
+
/** Where it was pressed, in canvas coordinates. */
|
|
29
|
+
point: Point;
|
|
30
|
+
/** The node under the pointer, if any. */
|
|
31
|
+
node: FlowNode | null;
|
|
32
|
+
event: PointerEvent;
|
|
33
|
+
}
|
|
34
|
+
/** Follows a press an extension took over, until the pointer is let go. */
|
|
35
|
+
export interface FlowPressHandler {
|
|
36
|
+
move?: (point: Point, event: PointerEvent) => void;
|
|
37
|
+
end?: (point: Point, event: PointerEvent) => void;
|
|
38
|
+
/** Escape, a second finger, or the browser took the pointer. */
|
|
39
|
+
cancel?: () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A piece of the editor: node types, port types, connection rules, keys and
|
|
43
|
+
* extra layers. The default node type comes as an extension too (see
|
|
44
|
+
* `flowKit`), so a third-party extension stands on equal footing with it.
|
|
45
|
+
*/
|
|
46
|
+
export interface FlowExtension {
|
|
47
|
+
name: string;
|
|
48
|
+
/** Higher runs first: its keys and rules are asked before others. Defaults to 100. */
|
|
49
|
+
priority?: number;
|
|
50
|
+
nodeTypes?: NodeTypeSpec<any>[];
|
|
51
|
+
/** Edge types, used by `edge.type`; `flowKit` brings `bezier`, `step` and `straight`. */
|
|
52
|
+
edgeTypes?: EdgeTypeSpec<any>[];
|
|
53
|
+
/**
|
|
54
|
+
* The edge type of edges without a `type`, unless the editor's `edge-type`
|
|
55
|
+
* prop says otherwise. The last extension that sets it wins.
|
|
56
|
+
*/
|
|
57
|
+
edgeType?: string;
|
|
58
|
+
/** Looks and connection rules of port types; see the `portTypes` prop. */
|
|
59
|
+
portTypes?: PortTypes;
|
|
60
|
+
/**
|
|
61
|
+
* A connection rule, asked after the built-in ones. Return `false` to
|
|
62
|
+
* refuse, or a sentence saying why. Called for every port while dragging.
|
|
63
|
+
*/
|
|
64
|
+
canConnect?: (connection: FlowConnection, doc: FlowDocument) => boolean | string;
|
|
65
|
+
/** Keys, written as in `useHotkey` (e.g. `mod+g`, `shift+t`), while the canvas has focus. */
|
|
66
|
+
keymap?: (context: FlowExtensionContext) => Record<string, FlowKeyHandler>;
|
|
67
|
+
/** Rewrites nodes and edges before they are pasted, e.g. to reset run state. */
|
|
68
|
+
transformPaste?: (data: FlowDocument, context: FlowExtensionContext) => FlowDocument;
|
|
69
|
+
/**
|
|
70
|
+
* Components drawn in canvas coordinates: `below` under the edges, `above`
|
|
71
|
+
* over the nodes. They move and zoom with the canvas.
|
|
72
|
+
*/
|
|
73
|
+
layers?: {
|
|
74
|
+
below?: Component[];
|
|
75
|
+
above?: Component[];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* What `layers.above` shows, for `exportSVG` and `exportPNG`: SVG markup
|
|
79
|
+
* in canvas coordinates, drawn over the nodes. `nodes` are the ones in the
|
|
80
|
+
* picture; `draw.width` and `draw.height` are the picture's size.
|
|
81
|
+
*/
|
|
82
|
+
drawLayer?: (context: FlowExtensionContext, draw: FlowDrawContext, nodes: FlowNode[]) => string;
|
|
83
|
+
/**
|
|
84
|
+
* Components drawn over the editor in screen space, e.g. a panel or a
|
|
85
|
+
* popup. They can call `useFlowEditor()`.
|
|
86
|
+
*/
|
|
87
|
+
overlays?: Component[];
|
|
88
|
+
/**
|
|
89
|
+
* Items for the menu opened by a right click, a long press on the empty
|
|
90
|
+
* canvas, or the context menu key. Extensions' items follow each other
|
|
91
|
+
* in priority order; an empty list leaves them out.
|
|
92
|
+
*/
|
|
93
|
+
contextMenu?: (context: FlowExtensionContext, target: FlowMenuTarget) => ContextMenuItem[];
|
|
94
|
+
/** Buttons for the toolbar that floats above the selected nodes. */
|
|
95
|
+
toolbarItems?: (context: FlowExtensionContext, nodes: FlowNode[]) => FlowToolbarItem[];
|
|
96
|
+
/** Buttons for the toolbar that floats above the selected edges, when no node is selected. */
|
|
97
|
+
edgeToolbarItems?: (context: FlowExtensionContext, edges: FlowEdge[]) => FlowToolbarItem[];
|
|
98
|
+
/**
|
|
99
|
+
* Asked first when the canvas or a node is pressed with the main button or
|
|
100
|
+
* one finger, in priority order. Return handlers to take the press over;
|
|
101
|
+
* the editor then doesn't select, drag or pan for it.
|
|
102
|
+
*/
|
|
103
|
+
press?: (context: FlowExtensionContext, press: FlowPress) => FlowPressHandler | void;
|
|
104
|
+
/** Runs once the editor is mounted. Return a function to run when it unmounts. */
|
|
105
|
+
setup?: (context: FlowExtensionContext) => void | (() => void);
|
|
106
|
+
/**
|
|
107
|
+
* Sees every change before it reaches the document, in priority order,
|
|
108
|
+
* and may add steps to it. Undo and redo come through here too.
|
|
109
|
+
*/
|
|
110
|
+
transaction?: (tr: FlowTransaction, context: FlowExtensionContext) => void;
|
|
111
|
+
/** Replaces the editor's undo history; the first extension that has one wins. */
|
|
112
|
+
history?: (context: FlowExtensionContext) => FlowHistoryHandler;
|
|
113
|
+
}
|
|
114
|
+
/** Declares an extension; only gives it a type. */
|
|
115
|
+
export declare function defineFlowExtension(extension: FlowExtension): FlowExtension;
|
|
116
|
+
/** Everything the extensions contribute, gathered once per list. */
|
|
117
|
+
export interface ResolvedFlowExtensions {
|
|
118
|
+
extensions: FlowExtension[];
|
|
119
|
+
nodeTypes: Map<string, NodeTypeSpec>;
|
|
120
|
+
edgeTypes: Map<string, EdgeTypeSpec>;
|
|
121
|
+
edgeType: string | undefined;
|
|
122
|
+
portTypes: PortTypes;
|
|
123
|
+
rules: NonNullable<FlowExtension['canConnect']>[];
|
|
124
|
+
keymaps: NonNullable<FlowExtension['keymap']>[];
|
|
125
|
+
pasteTransforms: NonNullable<FlowExtension['transformPaste']>[];
|
|
126
|
+
below: Component[];
|
|
127
|
+
above: Component[];
|
|
128
|
+
overlays: Component[];
|
|
129
|
+
menus: NonNullable<FlowExtension['contextMenu']>[];
|
|
130
|
+
toolbars: NonNullable<FlowExtension['toolbarItems']>[];
|
|
131
|
+
edgeToolbars: NonNullable<FlowExtension['edgeToolbarItems']>[];
|
|
132
|
+
drawLayers: NonNullable<FlowExtension['drawLayer']>[];
|
|
133
|
+
setups: NonNullable<FlowExtension['setup']>[];
|
|
134
|
+
transactions: NonNullable<FlowExtension['transaction']>[];
|
|
135
|
+
history: FlowExtension['history'];
|
|
136
|
+
presses: NonNullable<FlowExtension['press']>[];
|
|
137
|
+
}
|
|
138
|
+
type ExtensionList = readonly (FlowExtension | readonly FlowExtension[])[];
|
|
139
|
+
/** Sorts the extensions by priority and collects what they add. */
|
|
140
|
+
export declare function resolveFlowExtensions(list: ExtensionList): ResolvedFlowExtensions;
|
|
141
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { FlowViewport, Point, Rect } from './model';
|
|
2
|
+
export declare function boundsOf(rects: readonly Rect[]): Rect | null;
|
|
3
|
+
export declare function intersects(a: Rect, b: Rect): boolean;
|
|
4
|
+
/** The rectangle spanned by two corners, in any order. */
|
|
5
|
+
export declare function rectFrom(a: Point, b: Point): Rect;
|
|
6
|
+
export declare const snapTo: (value: number, step: number) => number;
|
|
7
|
+
export interface Guide {
|
|
8
|
+
axis: 'x' | 'y';
|
|
9
|
+
/** The canvas coordinate of the line. */
|
|
10
|
+
at: number;
|
|
11
|
+
/** Where the line starts and ends along the other axis. */
|
|
12
|
+
from: number;
|
|
13
|
+
to: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SnapResult {
|
|
16
|
+
/** How far to shift the moving box so it lines up. */
|
|
17
|
+
dx: number;
|
|
18
|
+
dy: number;
|
|
19
|
+
guides: Guide[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A port on a moving node and the port it is connected to. Lining them up
|
|
23
|
+
* makes the edge between them a straight line.
|
|
24
|
+
*/
|
|
25
|
+
export interface SnapLink {
|
|
26
|
+
/** Where the moving port is before the snap. */
|
|
27
|
+
from: Point;
|
|
28
|
+
to: Point;
|
|
29
|
+
/** `y` levels ports on the left or right; `x` ports on the top or bottom. */
|
|
30
|
+
axis: 'x' | 'y';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Lines the moving box up, on each axis separately, when it is within
|
|
34
|
+
* `threshold`: first a port with the port it is connected to, then the
|
|
35
|
+
* nearest edge or centre of another box. Without a match on an axis, the
|
|
36
|
+
* box's top left corner snaps to `grid` instead.
|
|
37
|
+
*/
|
|
38
|
+
export declare function snapBox(box: Rect, others: readonly Rect[], { threshold, grid, links }: {
|
|
39
|
+
threshold: number;
|
|
40
|
+
grid: number;
|
|
41
|
+
links?: readonly SnapLink[];
|
|
42
|
+
}): SnapResult;
|
|
43
|
+
/** Turns `point` by `degrees` around `centre`. */
|
|
44
|
+
export declare function turn(point: Point, centre: Point, degrees: number): Point;
|
|
45
|
+
/** The box around `rect` turned by `degrees` about its centre. */
|
|
46
|
+
export declare function turnedBox(rect: Rect, degrees: number): Rect;
|
|
47
|
+
/** Whether `box` and `rect` turned by `degrees` about its centre overlap. */
|
|
48
|
+
export declare function intersectsTurned(box: Rect, rect: Rect, degrees: number): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Keeps a pan within reach of the nodes: the view may go as far as having
|
|
51
|
+
* the nodes just leave it on the opposite side, a screen of room to draw in,
|
|
52
|
+
* and no further, so the canvas never runs off to coordinates the browser
|
|
53
|
+
* can't draw (it clamps lengths at about 3.3e7 px, and the layer and the
|
|
54
|
+
* nodes stop lining up long before). With no nodes, the origin is kept in
|
|
55
|
+
* view. A view already outside, e.g. set through `v-model:viewport` or left
|
|
56
|
+
* there when nodes were removed, isn't pulled back: it can only move closer.
|
|
57
|
+
* Zooming in is left as it is: it stays inside the view, so it never goes
|
|
58
|
+
* further out.
|
|
59
|
+
*/
|
|
60
|
+
export declare function clampPan(next: FlowViewport, current: FlowViewport, content: Rect | null, size: {
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
}): FlowViewport;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FlowNode, Point, Rect } from './model';
|
|
2
|
+
/**
|
|
3
|
+
* Parent links between nodes, worked out once per document. A `parent`
|
|
4
|
+
* naming a missing node, or one that would close a loop, is ignored.
|
|
5
|
+
*/
|
|
6
|
+
export declare class FlowTree {
|
|
7
|
+
readonly parents: Map<string, string>;
|
|
8
|
+
readonly children: Map<string, string[]>;
|
|
9
|
+
constructor(nodes: readonly FlowNode[]);
|
|
10
|
+
parentOf(id: string): string | undefined;
|
|
11
|
+
/** The node's ancestors, nearest first. */
|
|
12
|
+
ancestors(id: string): string[];
|
|
13
|
+
/** All nodes inside, at any depth. */
|
|
14
|
+
descendants(id: string): string[];
|
|
15
|
+
depth(id: string): number;
|
|
16
|
+
/** `ids` without the ones inside another of them. */
|
|
17
|
+
topmost(ids: Iterable<string>): string[];
|
|
18
|
+
}
|
|
19
|
+
/** The innermost of `containers` whose rect holds `point`. */
|
|
20
|
+
export declare function containerAt(point: Point, containers: {
|
|
21
|
+
id: string;
|
|
22
|
+
rect: Rect;
|
|
23
|
+
}[]): string | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FlowDocument, FlowSelection } from './model';
|
|
2
|
+
import { type FlowTransaction } from './transaction';
|
|
3
|
+
export declare class FlowHistory {
|
|
4
|
+
private depth;
|
|
5
|
+
private done;
|
|
6
|
+
private undone;
|
|
7
|
+
constructor(depth?: number);
|
|
8
|
+
get canUndo(): boolean;
|
|
9
|
+
get canRedo(): boolean;
|
|
10
|
+
record(tr: FlowTransaction, selectionBefore: FlowSelection, selectionAfter: FlowSelection, now?: number): void;
|
|
11
|
+
/** Ends the current group, so the next change starts a new undo step. */
|
|
12
|
+
close(): void;
|
|
13
|
+
/** Forgets the last entry if it belongs to `group`, e.g. after a cancelled drag. */
|
|
14
|
+
drop(group: string): void;
|
|
15
|
+
undo(doc: FlowDocument): {
|
|
16
|
+
tr: FlowTransaction;
|
|
17
|
+
selection: FlowSelection;
|
|
18
|
+
} | null;
|
|
19
|
+
redo(doc: FlowDocument): {
|
|
20
|
+
tr: FlowTransaction;
|
|
21
|
+
selection: FlowSelection;
|
|
22
|
+
} | null;
|
|
23
|
+
clear(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ContextMenuItem } from 'dou-ui';
|
|
2
|
+
import type { Component } from 'vue';
|
|
3
|
+
import type { FlowEdge, FlowNode, Point } from './model';
|
|
4
|
+
/** What a context menu was opened on. `point` is in canvas coordinates. */
|
|
5
|
+
export type FlowMenuTarget = {
|
|
6
|
+
kind: 'node';
|
|
7
|
+
node: FlowNode;
|
|
8
|
+
point: Point;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'edge';
|
|
11
|
+
edge: FlowEdge;
|
|
12
|
+
point: Point;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'canvas';
|
|
15
|
+
point: Point;
|
|
16
|
+
};
|
|
17
|
+
export interface FlowToolbarItem {
|
|
18
|
+
/** Unique within the toolbar. */
|
|
19
|
+
key: string;
|
|
20
|
+
/** Shown as a tooltip and read by screen readers. */
|
|
21
|
+
label: string;
|
|
22
|
+
icon: Component;
|
|
23
|
+
/** Called on click. */
|
|
24
|
+
run?: () => void;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** For a button that turns something on and off: whether it is on. */
|
|
27
|
+
pressed?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The key that does the same, as a hotkey like `mod+d`: shown in the
|
|
30
|
+
* tooltip and given to screen readers as `aria-keyshortcuts`. It is only
|
|
31
|
+
* a hint; bind the key with `keymap`.
|
|
32
|
+
*/
|
|
33
|
+
shortcut?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Choices to show under the button instead of `run`: the editor places
|
|
36
|
+
* the menu, marks the button as opening one, and closes it on a second
|
|
37
|
+
* click. Give the items `checked` to mark the one in use.
|
|
38
|
+
*/
|
|
39
|
+
children?: ContextMenuItem[];
|
|
40
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export type FlowData = Record<string, unknown>;
|
|
2
|
+
export interface FlowNode<Data extends FlowData = FlowData> {
|
|
3
|
+
id: string;
|
|
4
|
+
/** A registered node type; `'default'` when left out. */
|
|
5
|
+
type?: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
/** Only stored for nodes that can be resized; otherwise the content decides. */
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
data?: Data;
|
|
12
|
+
/** A locked node cannot be moved or deleted. */
|
|
13
|
+
locked?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The container node, e.g. a group, this node sits in. Its `x` and `y`
|
|
16
|
+
* stay canvas coordinates; moving the container moves it along.
|
|
17
|
+
*/
|
|
18
|
+
parent?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Stacking order among nodes that aren't containers: higher is drawn on
|
|
21
|
+
* top. Nodes without it count as `0`; equal ones keep the document order.
|
|
22
|
+
*/
|
|
23
|
+
z?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface FlowEndpoint {
|
|
26
|
+
node: string;
|
|
27
|
+
/** Leave out to attach to the node itself. */
|
|
28
|
+
port?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface FlowEdge<Data extends FlowData = FlowData> {
|
|
31
|
+
id: string;
|
|
32
|
+
source: FlowEndpoint;
|
|
33
|
+
target: FlowEndpoint;
|
|
34
|
+
/** The edge type: `bezier`, `step`, `straight` or one added by an extension. The editor's `edge-type` when left out. */
|
|
35
|
+
type?: string;
|
|
36
|
+
/** Text shown on the edge. */
|
|
37
|
+
label?: string;
|
|
38
|
+
/** Dashes run along the edge in its direction, e.g. while data flows through it. */
|
|
39
|
+
animated?: boolean;
|
|
40
|
+
data?: Data;
|
|
41
|
+
}
|
|
42
|
+
export interface FlowDocument {
|
|
43
|
+
/** The version of the format; see `migrateDocument`. */
|
|
44
|
+
version: 1;
|
|
45
|
+
nodes: FlowNode[];
|
|
46
|
+
edges: FlowEdge[];
|
|
47
|
+
}
|
|
48
|
+
export type PortSide = 'left' | 'right' | 'top' | 'bottom';
|
|
49
|
+
export interface FlowPortSpec {
|
|
50
|
+
id: string;
|
|
51
|
+
/** Inputs receive edges, outputs start them. */
|
|
52
|
+
kind: 'input' | 'output';
|
|
53
|
+
/** Where the port sits; inputs default to the left, outputs to the right. */
|
|
54
|
+
side?: PortSide;
|
|
55
|
+
label?: string;
|
|
56
|
+
/** What the port carries. Two ports connect when they share a type, or either is `'any'`. */
|
|
57
|
+
dataType?: string | string[];
|
|
58
|
+
/**
|
|
59
|
+
* The most edges the port takes. Inputs take one by default, outputs any
|
|
60
|
+
* number. A new edge on a full port replaces its oldest edge.
|
|
61
|
+
*/
|
|
62
|
+
max?: number;
|
|
63
|
+
}
|
|
64
|
+
/** Where the canvas is shown: `x` and `y` are the screen offset of the canvas origin. */
|
|
65
|
+
export interface FlowViewport {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
zoom: number;
|
|
69
|
+
}
|
|
70
|
+
export interface FlowSelection {
|
|
71
|
+
nodes: string[];
|
|
72
|
+
edges: string[];
|
|
73
|
+
}
|
|
74
|
+
export interface Point {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
}
|
|
78
|
+
export interface Rect {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
}
|
|
84
|
+
export declare const emptyDocument: () => FlowDocument;
|
|
85
|
+
export declare const emptySelection: () => FlowSelection;
|
|
86
|
+
/** A short id, unique within this page and very likely across clients. */
|
|
87
|
+
export declare function createId(prefix?: string): string;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { FlowDrawContext } from '../export/context';
|
|
2
|
+
import type { Component } from 'vue';
|
|
3
|
+
import type { FlowMessages } from '../locale';
|
|
4
|
+
import type { FlowData, FlowNode, FlowPortSpec, PortSide, Rect } from './model';
|
|
5
|
+
/** What a node type's component receives. */
|
|
6
|
+
export interface NodeViewProps<Data extends FlowData = FlowData> {
|
|
7
|
+
node: FlowNode<Data>;
|
|
8
|
+
data: Data;
|
|
9
|
+
ports: FlowPortSpec[];
|
|
10
|
+
selected: boolean;
|
|
11
|
+
readonly: boolean;
|
|
12
|
+
/** Merges `patch` into the node's data, as one undo step. */
|
|
13
|
+
updateData: (patch: Partial<Data>) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface NodeTypeSpec<Data extends FlowData = FlowData> {
|
|
16
|
+
type: string;
|
|
17
|
+
/**
|
|
18
|
+
* Renders the node's content. The editor draws the frame, selection and
|
|
19
|
+
* focus ring around it. Place ports with `<DouFlowPort>`; ports the
|
|
20
|
+
* component does not place are spread along their sides.
|
|
21
|
+
*/
|
|
22
|
+
component?: Component;
|
|
23
|
+
/** The node's ports, fixed or worked out from its data. */
|
|
24
|
+
ports?: FlowPortSpec[] | ((node: FlowNode<Data>) => FlowPortSpec[]);
|
|
25
|
+
/** Data for a new node of this type. */
|
|
26
|
+
defaults?: () => Data;
|
|
27
|
+
/**
|
|
28
|
+
* The node's accessible name; `data.label` by default. `messages` are the
|
|
29
|
+
* editor's current strings, for names that follow the locale.
|
|
30
|
+
*/
|
|
31
|
+
label?: (node: FlowNode<Data>, messages: FlowMessages) => string;
|
|
32
|
+
/**
|
|
33
|
+
* How the type is offered by `paletteTypes` and in the list that opens
|
|
34
|
+
* when an edge is dropped on the empty canvas. Types without it aren't offered.
|
|
35
|
+
*/
|
|
36
|
+
palette?: NodePaletteSpec;
|
|
37
|
+
/**
|
|
38
|
+
* Nodes dropped inside become its children (`parent`) and move with it;
|
|
39
|
+
* with `data.collapsed` they are hidden and their edges end on it.
|
|
40
|
+
* Containers are drawn under edges and other nodes.
|
|
41
|
+
*/
|
|
42
|
+
container?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* A handle on the selected node changes its stored `width` and `height`.
|
|
45
|
+
* A function decides per node, e.g. not while it is turned.
|
|
46
|
+
*/
|
|
47
|
+
resizable?: NodeResize | ((node: FlowNode<Data>) => NodeResize);
|
|
48
|
+
/** The `width` and `height` a new node starts with. */
|
|
49
|
+
size?: {
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* `false` leaves out the card the editor draws around the component (its
|
|
55
|
+
* border, background and shadow), for nodes that draw their own outline,
|
|
56
|
+
* e.g. a circle. Selection then shows as a thin outline around the box.
|
|
57
|
+
*/
|
|
58
|
+
frame?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* How far the node is drawn turned about its centre, in degrees clockwise;
|
|
61
|
+
* `0` by default. The component turns what it draws, and `draw` turns its
|
|
62
|
+
* export; the editor follows: the selection outline, picking with a box,
|
|
63
|
+
* what is drawn in view, the toolbar and other people's outlines. For
|
|
64
|
+
* nodes with `frame: false`. A turned node has no editor resize handle.
|
|
65
|
+
*/
|
|
66
|
+
rotation?: (node: FlowNode<Data>) => number;
|
|
67
|
+
/**
|
|
68
|
+
* The box the node covers on screen when it draws outside its own `rect`.
|
|
69
|
+
* The toolbar over the selection floats above it. By default the box
|
|
70
|
+
* around `rect` turned by `rotation`.
|
|
71
|
+
*/
|
|
72
|
+
bounds?: (node: FlowNode<Data>, rect: Rect) => Rect;
|
|
73
|
+
/**
|
|
74
|
+
* Draws the node as SVG markup for `exportSVG` and `exportPNG`, in its
|
|
75
|
+
* own coordinates. Without it the node is drawn as a card with its name.
|
|
76
|
+
*/
|
|
77
|
+
draw?: (node: FlowNode<Data>, draw: FlowDrawContext) => string;
|
|
78
|
+
}
|
|
79
|
+
export interface NodePaletteSpec {
|
|
80
|
+
label: string;
|
|
81
|
+
icon?: Component;
|
|
82
|
+
/** Types with the same group are listed together under its name. */
|
|
83
|
+
group?: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
/** Other words the search should find the type by. */
|
|
86
|
+
keywords?: string[];
|
|
87
|
+
}
|
|
88
|
+
/** Declares a node type, with the data type checked against its component. */
|
|
89
|
+
export declare function defineNodeType<Data extends FlowData = FlowData>(spec: NodeTypeSpec<Data>): NodeTypeSpec<Data>;
|
|
90
|
+
export declare const portSide: (port: FlowPortSpec) => PortSide;
|
|
91
|
+
export declare function portsOf(spec: NodeTypeSpec | undefined, node: FlowNode): FlowPortSpec[];
|
|
92
|
+
export type NodeResize = boolean | {
|
|
93
|
+
minWidth?: number;
|
|
94
|
+
minHeight?: number;
|
|
95
|
+
};
|
|
96
|
+
/** Whether a node can be resized, and its smallest size; `null` when it can't. */
|
|
97
|
+
export declare function resizeOf(spec: NodeTypeSpec | undefined, node: FlowNode): {
|
|
98
|
+
minWidth?: number;
|
|
99
|
+
minHeight?: number;
|
|
100
|
+
} | null;
|
|
101
|
+
export declare function labelOf(spec: NodeTypeSpec | undefined, node: FlowNode, messages: FlowMessages): string;
|
|
102
|
+
/** The box `node` covers on screen, drawn at `rect`. */
|
|
103
|
+
export declare function nodeBounds(spec: NodeTypeSpec, node: FlowNode, rect: Rect): Rect;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FlowDocument, FlowNode } from './model';
|
|
2
|
+
/**
|
|
3
|
+
* Nodes in the order a flow reads: every node after the ones it depends on,
|
|
4
|
+
* and among nodes that are ready, the leftmost (then topmost) first. Nodes
|
|
5
|
+
* on a cycle follow the rest, left to right.
|
|
6
|
+
*/
|
|
7
|
+
export declare function flowOrder(doc: FlowDocument): FlowNode[];
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { FlowDocument, FlowEdge, FlowNode } from './model';
|
|
2
|
+
type Patch<T> = {
|
|
3
|
+
[K in keyof T]?: T[K] | undefined;
|
|
4
|
+
};
|
|
5
|
+
export type FlowStep = {
|
|
6
|
+
type: 'addNode';
|
|
7
|
+
node: FlowNode;
|
|
8
|
+
index?: number;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'removeNode';
|
|
11
|
+
id: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'updateNode';
|
|
14
|
+
id: string;
|
|
15
|
+
patch: Patch<FlowNode>;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'addEdge';
|
|
18
|
+
edge: FlowEdge;
|
|
19
|
+
index?: number;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'removeEdge';
|
|
22
|
+
id: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'updateEdge';
|
|
25
|
+
id: string;
|
|
26
|
+
patch: Patch<FlowEdge>;
|
|
27
|
+
};
|
|
28
|
+
export interface FlowTransactionMeta {
|
|
29
|
+
/** Keep out of the undo history, e.g. changes from another client. */
|
|
30
|
+
history?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Consecutive transactions in the same group within a second undo as
|
|
33
|
+
* one, e.g. the frames of a drag or repeated arrow key nudges.
|
|
34
|
+
*/
|
|
35
|
+
group?: string;
|
|
36
|
+
/** Who made the change, passed on to the `transaction` event. */
|
|
37
|
+
origin?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A batch of changes to a document. Steps apply as they are added, so
|
|
41
|
+
* later calls see earlier ones; `doc` is the result.
|
|
42
|
+
*/
|
|
43
|
+
export declare class FlowTransaction {
|
|
44
|
+
readonly before: FlowDocument;
|
|
45
|
+
readonly steps: FlowStep[];
|
|
46
|
+
/** The steps that undo this transaction, in the order to apply them. */
|
|
47
|
+
readonly inverse: FlowStep[];
|
|
48
|
+
meta: FlowTransactionMeta;
|
|
49
|
+
private nodes;
|
|
50
|
+
private edges;
|
|
51
|
+
private copied;
|
|
52
|
+
constructor(before: FlowDocument);
|
|
53
|
+
get doc(): FlowDocument;
|
|
54
|
+
/** Whether the change makes any change: it has steps and wasn't cancelled. */
|
|
55
|
+
get changed(): boolean;
|
|
56
|
+
private stopped;
|
|
57
|
+
/**
|
|
58
|
+
* Stops the change: none of it is applied or kept for undo, and the
|
|
59
|
+
* editor fires `transactionCancel` and says why. For an extension's `transaction`
|
|
60
|
+
* hook, e.g. to keep people from changing what they may not; hooks after
|
|
61
|
+
* it don't run. A change kept out of the history (`meta.history: false`),
|
|
62
|
+
* such as undo, redo or another person's, can't be cancelled and goes ahead.
|
|
63
|
+
*/
|
|
64
|
+
cancel(reason?: string): this;
|
|
65
|
+
/** Whether `cancel` stopped it. */
|
|
66
|
+
get cancelled(): boolean;
|
|
67
|
+
/** What `cancel` was given, to tell people why. */
|
|
68
|
+
get cancelReason(): string | undefined;
|
|
69
|
+
getNode(id: string): FlowNode<import("./model").FlowData> | undefined;
|
|
70
|
+
getEdge(id: string): FlowEdge<import("./model").FlowData> | undefined;
|
|
71
|
+
/** Edges that start or end at a node. */
|
|
72
|
+
edgesOf(id: string): FlowEdge<import("./model").FlowData>[];
|
|
73
|
+
setMeta(meta: FlowTransactionMeta): this;
|
|
74
|
+
step(step: FlowStep): this;
|
|
75
|
+
addNode(node: FlowNode, index?: number): this;
|
|
76
|
+
/** Removes a node and every edge attached to it. */
|
|
77
|
+
removeNode(id: string): this;
|
|
78
|
+
updateNode(id: string, patch: Patch<FlowNode>): this;
|
|
79
|
+
moveNode(id: string, x: number, y: number): this;
|
|
80
|
+
/** Merges `patch` into the node's `data`. */
|
|
81
|
+
updateData(id: string, patch: Record<string, unknown>): this;
|
|
82
|
+
addEdge(edge: FlowEdge, index?: number): this;
|
|
83
|
+
removeEdge(id: string): this;
|
|
84
|
+
updateEdge(id: string, patch: Patch<FlowEdge>): this;
|
|
85
|
+
private writable;
|
|
86
|
+
/** Applies a step and returns its inverse, or `null` when it changes nothing. */
|
|
87
|
+
private apply;
|
|
88
|
+
}
|
|
89
|
+
/** Applies steps to a document; steps that no longer apply are skipped. */
|
|
90
|
+
export declare function applyFlowSteps(doc: FlowDocument, steps: readonly FlowStep[]): FlowTransaction;
|
|
91
|
+
/**
|
|
92
|
+
* Folds updates of the same node or edge into one, as long as nothing
|
|
93
|
+
* adds or removes it in between. Updates of different targets commute, so
|
|
94
|
+
* the result applies the same as the original list.
|
|
95
|
+
*/
|
|
96
|
+
export declare function compactFlowSteps(steps: readonly FlowStep[]): FlowStep[];
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type FlowExtension } from './core/extension';
|
|
2
|
+
import type { EdgeTypeSpec } from './core/edge-types';
|
|
3
|
+
import type { FlowDocument } from './core/model';
|
|
4
|
+
import { type NodeTypeSpec } from './core/node-types';
|
|
5
|
+
export interface DocumentProblem {
|
|
6
|
+
code: 'version' | 'shape' | 'missing-id' | 'duplicate-id' | 'bad-position' | 'unknown-type' | 'missing-node' | 'missing-port' | 'missing-parent' | 'parent-cycle';
|
|
7
|
+
/** The node at fault, or the node an edge's end points at. */
|
|
8
|
+
nodeId?: string;
|
|
9
|
+
/** The edge at fault. */
|
|
10
|
+
edgeId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Where the problem is, as a path into the document, e.g. `nodes[2]` or
|
|
13
|
+
* `edges[0].target`; `version` for the version.
|
|
14
|
+
*/
|
|
15
|
+
path: string;
|
|
16
|
+
/** The id, type or port at fault, for the editor's message. */
|
|
17
|
+
text: string;
|
|
18
|
+
/** An English description, for logs. */
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CheckDocumentOptions {
|
|
22
|
+
/**
|
|
23
|
+
* The editor's `extensions`, for the node and edge types they add. With
|
|
24
|
+
* none of `extensions`, `nodeTypes` and `edgeTypes`, types and ports are
|
|
25
|
+
* not checked; with `nodeTypes` or `edgeTypes` alone, the default
|
|
26
|
+
* `flowKit()` is assumed, as in the editor.
|
|
27
|
+
*/
|
|
28
|
+
extensions?: readonly (FlowExtension | readonly FlowExtension[])[];
|
|
29
|
+
/** The editor's `nodeTypes`. */
|
|
30
|
+
nodeTypes?: readonly NodeTypeSpec<any>[];
|
|
31
|
+
/** The editor's `edgeTypes`. */
|
|
32
|
+
edgeTypes?: readonly EdgeTypeSpec<any>[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The problems of a flow document, before it is saved or shown: an unknown
|
|
36
|
+
* version, nodes and edges without an id or sharing one, positions that are
|
|
37
|
+
* not numbers, edges whose ends are missing, `parent` pointing nowhere or
|
|
38
|
+
* in a circle, and, given the editor's types, types nobody registered and
|
|
39
|
+
* ports a node does not have.
|
|
40
|
+
*/
|
|
41
|
+
export declare function checkDocument(document: FlowDocument, options?: CheckDocumentOptions): DocumentProblem[];
|
|
42
|
+
/**
|
|
43
|
+
* Brings a saved document up to the current version, and fills what an
|
|
44
|
+
* older or hand-written one may lack (`version`, `nodes`, `edges`). Nodes
|
|
45
|
+
* and edges that are not objects are dropped; anything else is kept as it
|
|
46
|
+
* is. Throws for data that is not an object
|
|
47
|
+
* (an array, `null`, a string) and for a version it does not know.
|
|
48
|
+
*/
|
|
49
|
+
export declare function migrateDocument(input: unknown): FlowDocument;
|
|
50
|
+
/**
|
|
51
|
+
* The `v-model` as the editor reads it. A document of the wrong shape (not
|
|
52
|
+
* an object, without `nodes` or `edges`, without a known `version`) gets a
|
|
53
|
+
* warning in development and is read with what is missing left empty and
|
|
54
|
+
* the version as 1, so the editor still opens and what it writes back
|
|
55
|
+
* carries `version: 1`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readDocument(value: unknown): FlowDocument;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A computed color as `rgb(…)`, `rgba(…)` or `#rrggbb`, which every SVG reader
|
|
3
|
+
* understands. A canvas converts most colors as it parses them; colors it
|
|
4
|
+
* keeps in another space (`oklab(…)`, `color(…)`) are painted on a pixel
|
|
5
|
+
* and read back.
|
|
6
|
+
*/
|
|
7
|
+
export declare function plainColor(color: string): string;
|