@elicdavis/node-flow 0.1.0 → 0.1.2
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/README.md +19 -5
- package/dist/index.d.mts +762 -0
- package/dist/index.d.ts +762 -0
- package/dist/index.js +6509 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6471 -0
- package/dist/index.mjs.map +1 -0
- package/esbuild.ts +1 -1
- package/index.html +16 -12
- package/package.json +1 -1
- package/src/elements/base.ts +1 -0
- package/src/elements/text.ts +32 -4
- package/src/port.ts +53 -17
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
interface Vector2 {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare enum FontWeight {
|
|
7
|
+
Normal = "",
|
|
8
|
+
Bold = "bold"
|
|
9
|
+
}
|
|
10
|
+
declare enum FontStyle {
|
|
11
|
+
Normal = "",
|
|
12
|
+
Italic = "italic"
|
|
13
|
+
}
|
|
14
|
+
interface TextStyleConfig {
|
|
15
|
+
size?: number;
|
|
16
|
+
color?: string;
|
|
17
|
+
font?: string;
|
|
18
|
+
weight?: FontWeight;
|
|
19
|
+
style?: FontStyle;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ContextMenuItemConfig {
|
|
23
|
+
name?: string;
|
|
24
|
+
textStyle?: TextStyleConfig;
|
|
25
|
+
group?: string;
|
|
26
|
+
callback?: () => void;
|
|
27
|
+
}
|
|
28
|
+
interface ContextMenuConfig {
|
|
29
|
+
name?: string;
|
|
30
|
+
textStyle?: TextStyleConfig;
|
|
31
|
+
group?: string;
|
|
32
|
+
subMenus?: Array<ContextMenuConfig>;
|
|
33
|
+
items?: Array<ContextMenuItemConfig>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare class Camera {
|
|
37
|
+
zoom: number;
|
|
38
|
+
position: Vector2;
|
|
39
|
+
constructor();
|
|
40
|
+
screenSpaceToGraphSpace(screenPosition: Vector2, out: Vector2): void;
|
|
41
|
+
graphSpaceToScreenSpace(graphPosition: Vector2, out: Vector2): void;
|
|
42
|
+
reset(): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface ConnectionRendererParams {
|
|
46
|
+
ctx: CanvasRenderingContext2D;
|
|
47
|
+
start: Vector2;
|
|
48
|
+
end: Vector2;
|
|
49
|
+
graphScale: number;
|
|
50
|
+
mouseOver: boolean;
|
|
51
|
+
inNode: FlowNode | null;
|
|
52
|
+
inPort: Port | null;
|
|
53
|
+
outNode: FlowNode | null;
|
|
54
|
+
outPort: Port | null;
|
|
55
|
+
}
|
|
56
|
+
type ConnectionRenderer = (params: ConnectionRendererParams) => void;
|
|
57
|
+
declare class Connection {
|
|
58
|
+
#private;
|
|
59
|
+
constructor(inNode: FlowNode | null, inNodePortIndex: number, outNode: FlowNode | null, outNodePortIndex: number, renderer: ConnectionRenderer);
|
|
60
|
+
render(ctx: CanvasRenderingContext2D, graphScale: number, mouseOver: boolean, mousePosition: Vector2 | undefined): void;
|
|
61
|
+
inNode(): FlowNode | null;
|
|
62
|
+
outNode(): FlowNode | null;
|
|
63
|
+
clearPort(mousePosition: Vector2): void;
|
|
64
|
+
clearPorts(): void;
|
|
65
|
+
setInput(node: FlowNode, portIndex: number, replace?: boolean): void;
|
|
66
|
+
setOutput(node: FlowNode, portIndex: number): void;
|
|
67
|
+
clearInput(): void;
|
|
68
|
+
clearOutput(): void;
|
|
69
|
+
mouseOverPort(mousePosition: Vector2): Port | null;
|
|
70
|
+
outPort(): Port | null;
|
|
71
|
+
inPort(): Port | null;
|
|
72
|
+
referencesNode(node: FlowNode): boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
declare enum CursorStyle {
|
|
76
|
+
Default = "default",
|
|
77
|
+
Pointer = "pointer",
|
|
78
|
+
Grab = "grab",
|
|
79
|
+
Grabbing = "grabbing",
|
|
80
|
+
Wait = "wait",
|
|
81
|
+
Help = "help",
|
|
82
|
+
Crosshair = "crosshair",
|
|
83
|
+
Cell = "cell",
|
|
84
|
+
Text = "text",
|
|
85
|
+
Move = "move",
|
|
86
|
+
NotAllowed = "not-allowed",
|
|
87
|
+
ZoomIn = "zoom-in",
|
|
88
|
+
ZoomOut = "zoom-out",
|
|
89
|
+
None = "none",
|
|
90
|
+
ContextMenu = "context-menu"
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface RenderResults {
|
|
94
|
+
cursorStyle?: CursorStyle;
|
|
95
|
+
}
|
|
96
|
+
interface GraphSubsystem {
|
|
97
|
+
render(ctx: CanvasRenderingContext2D, camera: Camera, mousePosition: Vector2 | undefined): RenderResults | undefined;
|
|
98
|
+
openContextMenu(ctx: CanvasRenderingContext2D, position: Vector2): ContextMenuConfig | null;
|
|
99
|
+
/**
|
|
100
|
+
* Event for when the graph is clicked.
|
|
101
|
+
*
|
|
102
|
+
* Returns whether or not the subsystem had one of it's elements clicked on
|
|
103
|
+
*
|
|
104
|
+
* @param mousePosition Where the mouse is on the graph
|
|
105
|
+
* @param ctrlKey Whether or not the ctrl key is pressed
|
|
106
|
+
*/
|
|
107
|
+
clickStart(mousePosition: Vector2, camera: Camera, ctrlKey: boolean): boolean;
|
|
108
|
+
mouseDragEvent(delta: Vector2, scale: number): boolean;
|
|
109
|
+
fileDrop(file: File): boolean;
|
|
110
|
+
clickEnd(): void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
type RenderLambda = () => void;
|
|
114
|
+
/**
|
|
115
|
+
* Generic subsystem meant for other sybsystems to pass whatever to to render
|
|
116
|
+
* at a certain time.
|
|
117
|
+
*
|
|
118
|
+
* Initial inspriation is for a subsytem to submit something to render on top
|
|
119
|
+
* of all other subsystems.
|
|
120
|
+
*/
|
|
121
|
+
declare class PassSubsystem {
|
|
122
|
+
#private;
|
|
123
|
+
constructor();
|
|
124
|
+
queue(lambda: RenderLambda): void;
|
|
125
|
+
render(ctx: CanvasRenderingContext2D, camera: Camera, mousePosition: Vector2 | undefined): RenderResults | undefined;
|
|
126
|
+
openContextMenu(ctx: CanvasRenderingContext2D, position: Vector2): ContextMenuConfig | null;
|
|
127
|
+
clickStart(mousePosition: Vector2, camera: Camera, ctrlKey: boolean): boolean;
|
|
128
|
+
mouseDragEvent(delta: Vector2, scale: number): boolean;
|
|
129
|
+
fileDrop(file: File): boolean;
|
|
130
|
+
clickEnd(): void;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface Box {
|
|
134
|
+
Position: Vector2;
|
|
135
|
+
Size: Vector2;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
declare enum PortType {
|
|
139
|
+
Input = "INPUT",
|
|
140
|
+
Output = "OUTPUT",
|
|
141
|
+
InputArray = "INPUTARRAY"
|
|
142
|
+
}
|
|
143
|
+
interface PortStyle {
|
|
144
|
+
size?: number;
|
|
145
|
+
fillColor?: string;
|
|
146
|
+
borderColor?: string;
|
|
147
|
+
borderSize?: number;
|
|
148
|
+
}
|
|
149
|
+
type ConnectionChangeCallback = (connection: Connection, connectionIndex: number, port: Port, portType: PortType, node: FlowNode) => void;
|
|
150
|
+
interface PortConfig {
|
|
151
|
+
name?: string;
|
|
152
|
+
type?: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
array?: boolean;
|
|
155
|
+
emptyStyle?: PortStyle;
|
|
156
|
+
filledStyle?: PortStyle;
|
|
157
|
+
onConnectionAdded?: ConnectionChangeCallback;
|
|
158
|
+
onConnectionRemoved?: ConnectionChangeCallback;
|
|
159
|
+
}
|
|
160
|
+
declare class Port {
|
|
161
|
+
#private;
|
|
162
|
+
constructor(node: FlowNode, portType: PortType, config?: PortConfig);
|
|
163
|
+
addConnection(connection: Connection): void;
|
|
164
|
+
replaceConnection(connection: Connection, index: number): void;
|
|
165
|
+
addConnectionAddedListener(callback: ConnectionChangeCallback): void;
|
|
166
|
+
connections(): Array<Connection>;
|
|
167
|
+
addConnectionRemovedListener(callback: ConnectionChangeCallback): void;
|
|
168
|
+
clearConnection(connection: Connection): void;
|
|
169
|
+
getDataType(): string;
|
|
170
|
+
getPortType(): PortType;
|
|
171
|
+
getDisplayName(): string;
|
|
172
|
+
filledStyleColor(): string;
|
|
173
|
+
render(ctx: CanvasRenderingContext2D, position: Vector2, camera: Camera, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): Box;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface Widget {
|
|
177
|
+
Size(): Vector2;
|
|
178
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
179
|
+
ClickStart(): void;
|
|
180
|
+
ClickEnd(): void;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface StrokeStyleConfig {
|
|
184
|
+
size?: number;
|
|
185
|
+
color?: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface BoxStyleConfig {
|
|
189
|
+
border?: StrokeStyleConfig;
|
|
190
|
+
color?: string;
|
|
191
|
+
radius?: number;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
interface Metadata {
|
|
195
|
+
[name: string]: any;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
type AnyPropertyChangeCallback = (propertyName: string, oldValue: any, newValue: any) => void;
|
|
199
|
+
type PropertyChangeCallback = (oldValue: any, newValue: any) => void;
|
|
200
|
+
type TitleChangeCallback = (node: FlowNode, oldTitle: string, newTitle: string) => void;
|
|
201
|
+
type InfoChangeCallback = (node: FlowNode, oldInfo: string, newInfo: string) => void;
|
|
202
|
+
interface WidgetConfig {
|
|
203
|
+
type?: string;
|
|
204
|
+
config?: any;
|
|
205
|
+
}
|
|
206
|
+
interface FlowNodeTitleConfig {
|
|
207
|
+
textStyle?: TextStyleConfig;
|
|
208
|
+
color?: string;
|
|
209
|
+
padding?: number;
|
|
210
|
+
}
|
|
211
|
+
interface FlowNodeStyle {
|
|
212
|
+
title?: FlowNodeTitleConfig;
|
|
213
|
+
idle?: BoxStyleConfig;
|
|
214
|
+
mouseOver?: BoxStyleConfig;
|
|
215
|
+
grabbed?: BoxStyleConfig;
|
|
216
|
+
selected?: BoxStyleConfig;
|
|
217
|
+
portText?: TextStyleConfig;
|
|
218
|
+
}
|
|
219
|
+
interface FlowNodeConfig {
|
|
220
|
+
position?: Vector2;
|
|
221
|
+
title?: string;
|
|
222
|
+
subTitle?: string;
|
|
223
|
+
info?: string;
|
|
224
|
+
locked?: boolean;
|
|
225
|
+
data?: Metadata;
|
|
226
|
+
contextMenu?: ContextMenuConfig;
|
|
227
|
+
metadata?: any;
|
|
228
|
+
canEditTitle?: boolean;
|
|
229
|
+
canEditInfo?: boolean;
|
|
230
|
+
canEditPorts?: boolean;
|
|
231
|
+
inputs?: Array<PortConfig>;
|
|
232
|
+
outputs?: Array<PortConfig>;
|
|
233
|
+
onGrab?: () => void;
|
|
234
|
+
onRelease?: () => void;
|
|
235
|
+
onSelect?: () => void;
|
|
236
|
+
onUnselect?: () => void;
|
|
237
|
+
onDragStop?: (FlowNode: FlowNode) => void;
|
|
238
|
+
onFileDrop?: (file: File) => void;
|
|
239
|
+
onTitleChange?: TitleChangeCallback;
|
|
240
|
+
onInfoChange?: InfoChangeCallback;
|
|
241
|
+
widgets?: Array<WidgetConfig>;
|
|
242
|
+
style?: FlowNodeStyle;
|
|
243
|
+
}
|
|
244
|
+
declare enum NodeState {
|
|
245
|
+
Idle = 0,
|
|
246
|
+
MouseOver = 1,
|
|
247
|
+
Grabbed = 2
|
|
248
|
+
}
|
|
249
|
+
interface NodeIntersection {
|
|
250
|
+
Node?: FlowNode;
|
|
251
|
+
Port?: Port;
|
|
252
|
+
PortIndex?: number;
|
|
253
|
+
PortIsInput?: boolean;
|
|
254
|
+
Widget?: Widget;
|
|
255
|
+
WidgetIndex?: number;
|
|
256
|
+
}
|
|
257
|
+
declare class FlowNode {
|
|
258
|
+
#private;
|
|
259
|
+
constructor(config?: FlowNodeConfig);
|
|
260
|
+
metadata(): any;
|
|
261
|
+
selected(): boolean;
|
|
262
|
+
select(): void;
|
|
263
|
+
raiseDragStoppedEvent(): void;
|
|
264
|
+
addTitleChangeListener(callback: TitleChangeCallback): void;
|
|
265
|
+
addInfoChangeListener(callback: InfoChangeCallback): void;
|
|
266
|
+
addDragStoppedListener(callback: (node: FlowNode) => void): void;
|
|
267
|
+
addAnyPropertyChangeListener(callback: AnyPropertyChangeCallback): void;
|
|
268
|
+
addPropertyChangeListener(name: string, callback: PropertyChangeCallback): void;
|
|
269
|
+
setProperty(name: string, value: any): void;
|
|
270
|
+
getProperty(name: string): any;
|
|
271
|
+
contextMenu(): ContextMenuConfig;
|
|
272
|
+
unselect(): void;
|
|
273
|
+
addUnselectListener(callback: () => void): void;
|
|
274
|
+
addSelectListener(callback: () => void): void;
|
|
275
|
+
dropFile(file: File): void;
|
|
276
|
+
addFileDropListener(callback: (file: File) => void): void;
|
|
277
|
+
locked(): boolean;
|
|
278
|
+
lock(): void;
|
|
279
|
+
unlock(): void;
|
|
280
|
+
setPosition(position: Vector2): void;
|
|
281
|
+
getPosition(): Vector2;
|
|
282
|
+
calculateBounds(ctx: CanvasRenderingContext2D, camera: Camera): Box;
|
|
283
|
+
addInput(config: PortConfig): Port;
|
|
284
|
+
addOutput(config: PortConfig): Port;
|
|
285
|
+
addWidget(widget: Widget): void;
|
|
286
|
+
getWidget(index: number): Widget;
|
|
287
|
+
widgetCount(): number;
|
|
288
|
+
translate(delta: Vector2): void;
|
|
289
|
+
inBounds(ctx: CanvasRenderingContext2D, camera: Camera, position: Vector2): NodeIntersection;
|
|
290
|
+
canEditTitle(): boolean;
|
|
291
|
+
canEditPorts(): boolean;
|
|
292
|
+
title(): string;
|
|
293
|
+
setTitle(newTitle: string): void;
|
|
294
|
+
setInfo(newInfo: string): void;
|
|
295
|
+
inputPortPosition(index: number): Box;
|
|
296
|
+
inputPort(index: number): Port;
|
|
297
|
+
inputs(): number;
|
|
298
|
+
outputPortPosition(index: number): Box;
|
|
299
|
+
outputPort(index: number): Port;
|
|
300
|
+
outputs(): number;
|
|
301
|
+
render(ctx: CanvasRenderingContext2D, camera: Camera, state: NodeState, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): void;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
type NodeAddedCallback = (node: FlowNode) => void;
|
|
305
|
+
type NodeRemovedCallback = (node: FlowNode) => void;
|
|
306
|
+
interface ConnectionRendererConfiguration {
|
|
307
|
+
size?: number;
|
|
308
|
+
color?: string;
|
|
309
|
+
mouseOverSize?: number;
|
|
310
|
+
mouseOverColor?: string;
|
|
311
|
+
renderer?: ConnectionRenderer;
|
|
312
|
+
}
|
|
313
|
+
interface NodeSubsystemConfig {
|
|
314
|
+
idleConnection?: ConnectionRendererConfiguration;
|
|
315
|
+
nodes?: NodeFactoryConfig;
|
|
316
|
+
}
|
|
317
|
+
declare class NodeSubsystem {
|
|
318
|
+
#private;
|
|
319
|
+
constructor(postProcessPass: PassSubsystem, config?: NodeSubsystemConfig);
|
|
320
|
+
addPublisher(identifier: string, publisher: Publisher): void;
|
|
321
|
+
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
322
|
+
nodeFactory(): NodeFactory;
|
|
323
|
+
addOnNodeAddedListener(callback: NodeAddedCallback): void;
|
|
324
|
+
addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
|
|
325
|
+
clickStart(mousePosition: Vector2, camera: Camera, ctrlKey: boolean): boolean;
|
|
326
|
+
mouseDragEvent(delta: Vector2, scale: number): boolean;
|
|
327
|
+
clearNodeInputConnection(node: FlowNode, index: number): void;
|
|
328
|
+
clickEnd(): void;
|
|
329
|
+
connectNodes(nodeOut: FlowNode, outPort: number, nodeIn: FlowNode, inPort: number): Connection | undefined;
|
|
330
|
+
getNodes(): Array<FlowNode>;
|
|
331
|
+
/**
|
|
332
|
+
* Returns all nodes who are connected to the inputs of the
|
|
333
|
+
* node in question
|
|
334
|
+
*
|
|
335
|
+
* @param nodeIndex index of the node to examine inputs to
|
|
336
|
+
*/
|
|
337
|
+
connectedInputsNodeReferencesByIndex(nodeIndex: number): Array<FlowNode>;
|
|
338
|
+
connectedInputsNodeReferences(node: FlowNode): Array<FlowNode>;
|
|
339
|
+
connectedOutputsNodeReferences(nodeIndex: number): Array<FlowNode>;
|
|
340
|
+
addNode(node: FlowNode): void;
|
|
341
|
+
fileDrop(file: File): boolean;
|
|
342
|
+
organize(ctx: CanvasRenderingContext2D): void;
|
|
343
|
+
openContextMenu(ctx: CanvasRenderingContext2D, position: Vector2): ContextMenuConfig | null;
|
|
344
|
+
render(ctx: CanvasRenderingContext2D, camera: Camera, mousePosition: Vector2 | undefined): RenderResults | undefined;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
interface PublisherNodes {
|
|
348
|
+
[name: string]: FlowNodeConfig;
|
|
349
|
+
}
|
|
350
|
+
interface PublisherConfig {
|
|
351
|
+
name?: string;
|
|
352
|
+
description?: string;
|
|
353
|
+
version?: string;
|
|
354
|
+
nodes?: PublisherNodes;
|
|
355
|
+
}
|
|
356
|
+
declare class Publisher {
|
|
357
|
+
#private;
|
|
358
|
+
constructor(config?: PublisherConfig);
|
|
359
|
+
nodes(): Map<string, FlowNodeConfig>;
|
|
360
|
+
register(nodeType: string, config: FlowNodeConfig): void;
|
|
361
|
+
contextMenu(graph: NodeSubsystem, position: Vector2): ContextMenuConfig;
|
|
362
|
+
create(nodeType: string): FlowNode;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
type NodeCreatedCallback = (publisher: string, nodeType: string, node: FlowNode) => void;
|
|
366
|
+
interface NodeFactoryPublishers {
|
|
367
|
+
[name: string]: PublisherConfig;
|
|
368
|
+
}
|
|
369
|
+
interface NodeFactoryConfig {
|
|
370
|
+
publishers?: NodeFactoryPublishers;
|
|
371
|
+
onNodeCreated?: NodeCreatedCallback;
|
|
372
|
+
}
|
|
373
|
+
declare class NodeFactory {
|
|
374
|
+
#private;
|
|
375
|
+
constructor(config?: NodeFactoryConfig);
|
|
376
|
+
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
377
|
+
addPublisher(identifier: string, publisher: Publisher): void;
|
|
378
|
+
create(publisher: string, nodeType: string): FlowNode;
|
|
379
|
+
newNodeSubmenus(graph: NodeSubsystem, position: Vector2): Array<ContextMenuConfig>;
|
|
380
|
+
openMenu(graph: NodeSubsystem, position: Vector2): ContextMenuConfig;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
type NoteContentChangeCallback = (node: FlowNote, newContents: string) => void;
|
|
384
|
+
type NoteWidthChangeCallback = (node: FlowNote, newWidth: number) => void;
|
|
385
|
+
interface FlowNoteConfig {
|
|
386
|
+
text?: string;
|
|
387
|
+
style?: TextStyleConfig;
|
|
388
|
+
metadata?: Metadata;
|
|
389
|
+
position?: Vector2;
|
|
390
|
+
width?: number;
|
|
391
|
+
locked?: boolean;
|
|
392
|
+
onWidthChange?: NoteWidthChangeCallback;
|
|
393
|
+
onContentChange?: NoteContentChangeCallback;
|
|
394
|
+
}
|
|
395
|
+
declare enum DragHandle {
|
|
396
|
+
None = 0,
|
|
397
|
+
Left = 1,
|
|
398
|
+
Right = 2
|
|
399
|
+
}
|
|
400
|
+
declare class FlowNote {
|
|
401
|
+
#private;
|
|
402
|
+
constructor(config?: FlowNoteConfig);
|
|
403
|
+
setText(text: string): void;
|
|
404
|
+
setMetadataProperty(name: string, value: any): void;
|
|
405
|
+
getMetadataProperty(name: string): any;
|
|
406
|
+
text(): string;
|
|
407
|
+
width(): number;
|
|
408
|
+
position(): Vector2;
|
|
409
|
+
translate(delta: Vector2): void;
|
|
410
|
+
setPosition(position: Vector2): void;
|
|
411
|
+
handleSelected(): DragHandle;
|
|
412
|
+
selectHandle(handle: DragHandle): void;
|
|
413
|
+
setWidth(newWidth: number): void;
|
|
414
|
+
addWidthChangeListener(callback: NoteWidthChangeCallback): void;
|
|
415
|
+
addContentChangeListener(callback: NoteContentChangeCallback): void;
|
|
416
|
+
render(ctx: CanvasRenderingContext2D, camera: Camera, mousePosition: Vector2 | undefined): void;
|
|
417
|
+
leftResizeHandleBox(): Box;
|
|
418
|
+
rightResizeHandleBox(): Box;
|
|
419
|
+
edittingLayout(): boolean;
|
|
420
|
+
setHovering(hovering: boolean): void;
|
|
421
|
+
editContent(): void;
|
|
422
|
+
lock(): void;
|
|
423
|
+
unlock(): void;
|
|
424
|
+
bounds(): Box;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
type NoteAddedCallback = (addedNote: FlowNote) => void;
|
|
428
|
+
type NoteRemovedCallback = (noteRemoved: FlowNote) => void;
|
|
429
|
+
type NoteDragStartCallback = (nodeDragged: FlowNote) => void;
|
|
430
|
+
type NoteDragStopCallback = (nodeDragged: FlowNote) => void;
|
|
431
|
+
interface NoteSubsystemConfig {
|
|
432
|
+
onNoteAdded?: NoteAddedCallback;
|
|
433
|
+
onNoteRemoved?: NoteRemovedCallback;
|
|
434
|
+
onNoteDragStop?: NoteDragStopCallback;
|
|
435
|
+
onNoteDragStart?: NoteDragStartCallback;
|
|
436
|
+
notes?: Array<FlowNoteConfig>;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
type GraphRenderer = (canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D, position: Vector2, scale: number) => void;
|
|
440
|
+
interface FlowNodeGraphConfiguration {
|
|
441
|
+
backgroundRenderer?: GraphRenderer;
|
|
442
|
+
backgroundColor?: string;
|
|
443
|
+
idleConnection?: ConnectionRendererConfiguration;
|
|
444
|
+
contextMenu?: ContextMenuConfig;
|
|
445
|
+
nodes?: NodeFactoryConfig;
|
|
446
|
+
board?: NoteSubsystemConfig;
|
|
447
|
+
}
|
|
448
|
+
declare class GraphView {
|
|
449
|
+
#private;
|
|
450
|
+
constructor(subsystems: Array<GraphSubsystem>);
|
|
451
|
+
clickStart(mousePosition: Vector2, camera: Camera, ctrlKey: boolean): void;
|
|
452
|
+
fileDrop(file: File): boolean;
|
|
453
|
+
openContextMenu(ctx: CanvasRenderingContext2D, position: Vector2): ContextMenuConfig;
|
|
454
|
+
clickEnd(): void;
|
|
455
|
+
mouseDragEvent(delta: Vector2, scale: number): boolean;
|
|
456
|
+
render(ctx: CanvasRenderingContext2D, camera: Camera, mousePosition: Vector2 | undefined): RenderResults;
|
|
457
|
+
}
|
|
458
|
+
declare class NodeFlowGraph {
|
|
459
|
+
#private;
|
|
460
|
+
constructor(canvas: HTMLCanvasElement, config?: FlowNodeGraphConfiguration);
|
|
461
|
+
addNoteAddedListener(callback: NoteAddedCallback): void;
|
|
462
|
+
addNoteRemovedListener(callback: NoteRemovedCallback): void;
|
|
463
|
+
addNoteDragStartListener(callback: NoteDragStartCallback): void;
|
|
464
|
+
addNoteDragStopListener(callback: NoteDragStopCallback): void;
|
|
465
|
+
zoom(amount: number): void;
|
|
466
|
+
currentView(): GraphView;
|
|
467
|
+
organize(): void;
|
|
468
|
+
addPublisher(identifier: string, publisher: Publisher): void;
|
|
469
|
+
getNodes(): Array<FlowNode>;
|
|
470
|
+
connectedInputsNodeReferences(nodeIndex: number): Array<FlowNode>;
|
|
471
|
+
connectedOutputsNodeReferences(nodeIndex: number): Array<FlowNode>;
|
|
472
|
+
connectNodes(nodeOut: FlowNode, outPort: number, nodeIn: FlowNode, inPort: number): Connection | undefined;
|
|
473
|
+
addNode(node: FlowNode): void;
|
|
474
|
+
addNote(note: FlowNote): void;
|
|
475
|
+
addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
|
|
476
|
+
addOnNodeAddedListener(callback: NodeAddedCallback): void;
|
|
477
|
+
addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
declare const Theme: {
|
|
481
|
+
FontFamily: string;
|
|
482
|
+
Graph: {
|
|
483
|
+
BackgroundColor: string;
|
|
484
|
+
};
|
|
485
|
+
Node: {
|
|
486
|
+
FontColor: string;
|
|
487
|
+
BackgroundColor: string;
|
|
488
|
+
Title: {
|
|
489
|
+
Color: string;
|
|
490
|
+
FontColor: string;
|
|
491
|
+
Padding: number;
|
|
492
|
+
};
|
|
493
|
+
BorderRadius: number;
|
|
494
|
+
Border: {
|
|
495
|
+
Idle: string;
|
|
496
|
+
MouseOver: string;
|
|
497
|
+
Grabbed: string;
|
|
498
|
+
Selected: string;
|
|
499
|
+
};
|
|
500
|
+
Port: {
|
|
501
|
+
FontColor: string;
|
|
502
|
+
};
|
|
503
|
+
};
|
|
504
|
+
BoxSelect: {
|
|
505
|
+
Color: string;
|
|
506
|
+
Size: number;
|
|
507
|
+
Radius: number;
|
|
508
|
+
LineDashLength: number;
|
|
509
|
+
};
|
|
510
|
+
Widget: {
|
|
511
|
+
FontColor: string;
|
|
512
|
+
BackgroundColor: string;
|
|
513
|
+
Border: {
|
|
514
|
+
Color: string;
|
|
515
|
+
Size: number;
|
|
516
|
+
Radius: number;
|
|
517
|
+
};
|
|
518
|
+
Hover: {
|
|
519
|
+
BackgroundColor: string;
|
|
520
|
+
};
|
|
521
|
+
Slider: {
|
|
522
|
+
FillColor: string;
|
|
523
|
+
};
|
|
524
|
+
Button: {
|
|
525
|
+
Click: {
|
|
526
|
+
BackgroundColor: string;
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
ContextMenu: {
|
|
531
|
+
BackgroundColor: string;
|
|
532
|
+
HighlightColor: string;
|
|
533
|
+
FontColor: string;
|
|
534
|
+
};
|
|
535
|
+
Note: {
|
|
536
|
+
FontColor: string;
|
|
537
|
+
FontSize: number;
|
|
538
|
+
EntrySpacing: number;
|
|
539
|
+
LineSpacing: number;
|
|
540
|
+
DotSize: number;
|
|
541
|
+
HeaderLineWidth: number;
|
|
542
|
+
H1: {
|
|
543
|
+
FontSize: number;
|
|
544
|
+
};
|
|
545
|
+
H2: {
|
|
546
|
+
FontSize: number;
|
|
547
|
+
};
|
|
548
|
+
H3: {
|
|
549
|
+
FontSize: number;
|
|
550
|
+
};
|
|
551
|
+
CodeBlock: {
|
|
552
|
+
BackgroundColor: string;
|
|
553
|
+
Padding: number;
|
|
554
|
+
BorderRadius: number;
|
|
555
|
+
};
|
|
556
|
+
};
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
interface TextBoxStyleConfig {
|
|
560
|
+
box?: BoxStyleConfig;
|
|
561
|
+
text?: TextStyleConfig;
|
|
562
|
+
textAlign?: CanvasTextAlign;
|
|
563
|
+
textBaseline?: CanvasTextBaseline;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
interface NumberWidgetConfig {
|
|
567
|
+
value?: number;
|
|
568
|
+
property?: string;
|
|
569
|
+
idleBoxStyle?: TextBoxStyleConfig;
|
|
570
|
+
highlightBoxStyle?: TextBoxStyleConfig;
|
|
571
|
+
callback?: (newNumber: number) => void;
|
|
572
|
+
}
|
|
573
|
+
declare class NumberWidget {
|
|
574
|
+
#private;
|
|
575
|
+
constructor(node: FlowNode, config?: NumberWidgetConfig);
|
|
576
|
+
Size(): Vector2;
|
|
577
|
+
Set(newNumber: number): void;
|
|
578
|
+
ClickStart(): void;
|
|
579
|
+
ClickEnd(): void;
|
|
580
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
interface ColorWidgetConfig {
|
|
584
|
+
value?: string;
|
|
585
|
+
property?: string;
|
|
586
|
+
textStyle?: TextStyleConfig;
|
|
587
|
+
callback?: (newColor: string) => void;
|
|
588
|
+
}
|
|
589
|
+
declare class ColorWidget {
|
|
590
|
+
#private;
|
|
591
|
+
constructor(node: FlowNode, config?: ColorWidgetConfig);
|
|
592
|
+
Size(): Vector2;
|
|
593
|
+
Set(value: string): void;
|
|
594
|
+
ClickStart(): void;
|
|
595
|
+
ClickEnd(): void;
|
|
596
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
interface StringWidgetConfig {
|
|
600
|
+
property?: string;
|
|
601
|
+
value?: string;
|
|
602
|
+
textBoxStyle?: TextBoxStyleConfig;
|
|
603
|
+
callback?: (newString: string) => void;
|
|
604
|
+
}
|
|
605
|
+
declare class StringWidget {
|
|
606
|
+
#private;
|
|
607
|
+
constructor(node: FlowNode, config?: StringWidgetConfig);
|
|
608
|
+
Size(): Vector2;
|
|
609
|
+
Set(value: string): void;
|
|
610
|
+
ClickStart(): void;
|
|
611
|
+
ClickEnd(): void;
|
|
612
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
interface ButtonWidgetConfig {
|
|
616
|
+
text?: string;
|
|
617
|
+
callback?: () => void;
|
|
618
|
+
idleStyle?: TextBoxStyleConfig;
|
|
619
|
+
hoverStyle?: TextBoxStyleConfig;
|
|
620
|
+
clickStyle?: TextBoxStyleConfig;
|
|
621
|
+
}
|
|
622
|
+
declare class ButtonWidget {
|
|
623
|
+
#private;
|
|
624
|
+
constructor(config?: ButtonWidgetConfig);
|
|
625
|
+
Size(): Vector2;
|
|
626
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
627
|
+
ClickStart(): void;
|
|
628
|
+
ClickEnd(): void;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
interface ToggleStyleConfig {
|
|
632
|
+
idle?: TextBoxStyleConfig;
|
|
633
|
+
hover?: TextBoxStyleConfig;
|
|
634
|
+
lightColor?: string;
|
|
635
|
+
lightBorderColor?: string;
|
|
636
|
+
lightBlur?: number;
|
|
637
|
+
}
|
|
638
|
+
interface ToggleWidgetConfig {
|
|
639
|
+
property?: string;
|
|
640
|
+
value?: boolean;
|
|
641
|
+
text?: string;
|
|
642
|
+
callback?: () => void;
|
|
643
|
+
enabledStyle?: ToggleStyleConfig;
|
|
644
|
+
disabledStyle?: ToggleStyleConfig;
|
|
645
|
+
}
|
|
646
|
+
declare class ToggleWidget {
|
|
647
|
+
#private;
|
|
648
|
+
constructor(node: FlowNode, config?: ToggleWidgetConfig);
|
|
649
|
+
Size(): Vector2;
|
|
650
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
651
|
+
Toggle(): void;
|
|
652
|
+
Set(value: boolean): void;
|
|
653
|
+
ClickStart(): void;
|
|
654
|
+
ClickEnd(): void;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
interface SliderWidgetConfig {
|
|
658
|
+
property?: string;
|
|
659
|
+
min?: number;
|
|
660
|
+
max?: number;
|
|
661
|
+
value?: number;
|
|
662
|
+
backgroundColor?: string;
|
|
663
|
+
borderColor?: string;
|
|
664
|
+
fillColor?: string;
|
|
665
|
+
textStyle?: TextStyleConfig;
|
|
666
|
+
change?: (newValue: number) => void;
|
|
667
|
+
release?: (newValue: number) => void;
|
|
668
|
+
snapIncrement?: number;
|
|
669
|
+
}
|
|
670
|
+
declare class SliderWidget {
|
|
671
|
+
#private;
|
|
672
|
+
constructor(node: FlowNode, config?: SliderWidgetConfig);
|
|
673
|
+
SetValue(newValue: number): void;
|
|
674
|
+
Size(): Vector2;
|
|
675
|
+
ClickStart(): void;
|
|
676
|
+
ClickEnd(): void;
|
|
677
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
interface ImageWidgetConfig {
|
|
681
|
+
image?: string;
|
|
682
|
+
maxWidth?: number;
|
|
683
|
+
maxHeight?: number;
|
|
684
|
+
blob?: Blob;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* constructor(lightNode, nodeManager, id, parameterData, app) {
|
|
688
|
+
this.lightNode = lightNode;
|
|
689
|
+
this.id = id;
|
|
690
|
+
this.app = app;
|
|
691
|
+
this.lightNode.title = parameterData.name;
|
|
692
|
+
|
|
693
|
+
this.lightNode.onDropFile = (file) => {
|
|
694
|
+
// console.log(file)
|
|
695
|
+
var reader = new FileReader();
|
|
696
|
+
reader.onload = (evt) => {
|
|
697
|
+
console.log(evt.target.result)
|
|
698
|
+
nodeManager.nodeParameterChanged({
|
|
699
|
+
id: id,
|
|
700
|
+
data: evt.target.result,
|
|
701
|
+
binary: true
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
reader.readAsArrayBuffer(file);
|
|
705
|
+
|
|
706
|
+
const url = URL.createObjectURL(file);
|
|
707
|
+
// this.loadImage(this._url, function (img) {
|
|
708
|
+
// that.size[1] = (img.height / img.width) * that.size[0];
|
|
709
|
+
// });
|
|
710
|
+
this.loadImgFromURL(url);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
loadImgFromURL(url) {
|
|
715
|
+
const img = document.createElement("img");
|
|
716
|
+
img.src = url;
|
|
717
|
+
img.onload = () => {
|
|
718
|
+
// if (callback) {
|
|
719
|
+
// callback(this);
|
|
720
|
+
// }
|
|
721
|
+
// console.log("Image loaded, size: " + img.width + "x" + img.height);
|
|
722
|
+
// this.dirty = true;
|
|
723
|
+
// that.boxcolor = "#9F9";f
|
|
724
|
+
// that.setDirtyCanvas(true);
|
|
725
|
+
this.lightNode.widgets[0].image = img
|
|
726
|
+
this.lightNode.setSize(this.lightNode.computeSize());
|
|
727
|
+
};
|
|
728
|
+
img.onerror = () => {
|
|
729
|
+
console.log("error loading the image:" + url);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
update(parameterData) {
|
|
734
|
+
console.log("image parameter", parameterData)
|
|
735
|
+
const curVal = parameterData.currentValue;
|
|
736
|
+
this.app.RequestManager.getParameterValue(this.id, (response) => {
|
|
737
|
+
const url = URL.createObjectURL(response);
|
|
738
|
+
this.loadImgFromURL(url)
|
|
739
|
+
})
|
|
740
|
+
}
|
|
741
|
+
*/
|
|
742
|
+
declare class ImageWidget {
|
|
743
|
+
#private;
|
|
744
|
+
constructor(config?: ImageWidgetConfig);
|
|
745
|
+
SetBlob(blob: Blob): void;
|
|
746
|
+
SetUrl(url: string): void;
|
|
747
|
+
Size(): Vector2;
|
|
748
|
+
ClickStart(): void;
|
|
749
|
+
ClickEnd(): void;
|
|
750
|
+
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
type WidgetBuilder = (node: FlowNode, confg?: any) => Widget;
|
|
754
|
+
declare class WidgetFactory {
|
|
755
|
+
#private;
|
|
756
|
+
constructor();
|
|
757
|
+
register(widgetType: string, builder: WidgetBuilder): void;
|
|
758
|
+
create(node: FlowNode, widgetType: string, config: any): Widget;
|
|
759
|
+
}
|
|
760
|
+
declare const GlobalWidgetFactory: WidgetFactory;
|
|
761
|
+
|
|
762
|
+
export { ButtonWidget, ColorWidget, FlowNode, type FlowNodeConfig, FlowNote, GlobalWidgetFactory, ImageWidget, NodeFlowGraph, NumberWidget, Publisher, type PublisherConfig, SliderWidget, StringWidget, Theme, ToggleWidget };
|