@elicdavis/node-flow 0.1.20 → 0.2.1
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/index.d.mts +393 -226
- package/dist/index.d.ts +393 -226
- package/dist/index.js +1905 -1058
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1888 -1057
- package/dist/index.mjs.map +1 -1
- package/index.html +1134 -329
- package/package.json +1 -1
- package/src/connection.ts +30 -5
- package/src/contextMenu.ts +66 -34
- package/src/graph.ts +19 -14
- package/src/index.ts +26 -12
- package/src/markdown/entry.ts +11 -15
- package/src/markdown/syntaxParser.ts +2 -1
- package/src/node.ts +160 -101
- package/src/nodes/subsystem.ts +113 -29
- package/src/notes/note.ts +9 -1
- package/src/organize.ts +540 -111
- package/src/popup.ts +4 -2
- package/src/port.ts +83 -6
- package/src/styles/bevel.ts +31 -0
- package/src/styles/cursor.ts +1 -0
- package/src/styles/text.ts +4 -4
- package/src/theme.ts +179 -92
- package/src/types/text.ts +5 -1
- package/src/utils/color.ts +1 -1
- package/src/widgets/button.ts +52 -107
- package/src/widgets/color.ts +91 -150
- package/src/widgets/factory.ts +89 -46
- package/src/widgets/field.ts +99 -0
- package/src/widgets/image.ts +107 -165
- package/src/widgets/inplace.ts +136 -0
- package/src/widgets/number.ts +115 -154
- package/src/widgets/row.ts +138 -0
- package/src/widgets/slider.ts +101 -216
- package/src/widgets/string.ts +32 -130
- package/src/widgets/text.ts +81 -92
- package/src/widgets/toggle.ts +62 -207
- package/src/widgets/value.ts +127 -0
- package/src/widgets/widget.ts +173 -6
- package/test/context_menu.test.ts +82 -0
- package/test/cursor.test.ts +17 -0
- package/test/hidden_port.test.ts +125 -0
- package/test/markdown.test.ts +2 -2
- package/test/markdown_code_block.test.ts +58 -0
- package/test/multi_input.test.ts +124 -0
- package/test/organize.test.ts +117 -1
- package/test/support.ts +188 -0
- package/test/theme.test.ts +86 -0
- package/test/widget_click.test.ts +111 -97
- package/test/widget_construction.test.ts +5 -4
- package/test/widgets.test.ts +386 -0
- package/test/wire_follows_camera.test.ts +57 -0
package/dist/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ declare class Connection {
|
|
|
81
81
|
outNode(): FlowNode | null;
|
|
82
82
|
clearPort(mousePosition: Vector2): void;
|
|
83
83
|
clearPorts(): void;
|
|
84
|
-
setInput(node: FlowNode, portIndex: number, replace?: boolean): void;
|
|
84
|
+
setInput(node: FlowNode, portIndex: number, replace?: boolean, insertAt?: number): void;
|
|
85
85
|
setOutput(node: FlowNode, portIndex: number): void;
|
|
86
86
|
clearInput(): void;
|
|
87
87
|
clearOutput(): void;
|
|
@@ -106,7 +106,8 @@ declare enum CursorStyle {
|
|
|
106
106
|
ZoomIn = "zoom-in",
|
|
107
107
|
ZoomOut = "zoom-out",
|
|
108
108
|
None = "none",
|
|
109
|
-
ContextMenu = "context-menu"
|
|
109
|
+
ContextMenu = "context-menu",
|
|
110
|
+
EWResize = "ew-resize"
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
interface RenderResults {
|
|
@@ -152,7 +153,8 @@ declare class PassSubsystem {
|
|
|
152
153
|
interface Box {
|
|
153
154
|
Position: Vector2;
|
|
154
155
|
Size: Vector2;
|
|
155
|
-
}
|
|
156
|
+
}
|
|
157
|
+
declare function InBox(box: Box, position: Vector2): boolean;
|
|
156
158
|
|
|
157
159
|
declare enum PortType {
|
|
158
160
|
Input = "INPUT",
|
|
@@ -187,6 +189,10 @@ interface PortConfig {
|
|
|
187
189
|
* unless `anyType` says otherwise.
|
|
188
190
|
*/
|
|
189
191
|
acceptedTypes?: Array<string>;
|
|
192
|
+
/**
|
|
193
|
+
* Leaves the port off the node until something is connected to it.
|
|
194
|
+
*/
|
|
195
|
+
hidden?: boolean;
|
|
190
196
|
emptyStyle?: PortStyle;
|
|
191
197
|
filledStyle?: PortStyle;
|
|
192
198
|
onConnectionAdded?: ConnectionChangeCallback;
|
|
@@ -210,10 +216,20 @@ declare class Port {
|
|
|
210
216
|
* Scope accepted types to singular type
|
|
211
217
|
*/
|
|
212
218
|
settleOn(type: string): void;
|
|
213
|
-
addConnection(connection: Connection): void;
|
|
219
|
+
addConnection(connection: Connection, index?: number): void;
|
|
214
220
|
replaceConnection(connection: Connection, index: number): void;
|
|
215
221
|
addConnectionAddedListener(callback: ConnectionChangeCallback): void;
|
|
216
222
|
connections(): Array<Connection>;
|
|
223
|
+
/**
|
|
224
|
+
* How many wires the port has room for: one per connection on an array
|
|
225
|
+
* input, so each can be told apart and picked up on its own.
|
|
226
|
+
*/
|
|
227
|
+
slots(): number;
|
|
228
|
+
setHidden(hidden: boolean): void;
|
|
229
|
+
/**
|
|
230
|
+
* A port asked to hide still shows while anything is connected to it.
|
|
231
|
+
*/
|
|
232
|
+
hidden(): boolean;
|
|
217
233
|
addConnectionRemovedListener(callback: ConnectionChangeCallback): void;
|
|
218
234
|
clearConnection(connection: Connection): void;
|
|
219
235
|
getDataType(): string;
|
|
@@ -229,11 +245,58 @@ declare class Port {
|
|
|
229
245
|
render(ctx: CanvasRenderingContext2D, position: Vector2, camera: Camera, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): Box;
|
|
230
246
|
}
|
|
231
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Where the pointer is, in canvas pixels, and whether it is over the widget.
|
|
250
|
+
* A press that starts on a widget keeps reporting to it until it is let go,
|
|
251
|
+
* wherever the pointer wanders.
|
|
252
|
+
*/
|
|
253
|
+
interface WidgetPointer {
|
|
254
|
+
position: Vector2;
|
|
255
|
+
inside: boolean;
|
|
256
|
+
}
|
|
232
257
|
interface Widget {
|
|
258
|
+
/**
|
|
259
|
+
* The smallest room the widget needs, in graph units. The node may hand
|
|
260
|
+
* it a wider box.
|
|
261
|
+
*/
|
|
233
262
|
Size(): Vector2;
|
|
234
|
-
Draw(ctx: CanvasRenderingContext2D,
|
|
235
|
-
|
|
236
|
-
|
|
263
|
+
Draw(ctx: CanvasRenderingContext2D, box: Box, scale: number, mousePosition: Vector2 | undefined): void;
|
|
264
|
+
PointerDown?(pointer: WidgetPointer): void;
|
|
265
|
+
PointerMove?(pointer: WidgetPointer): void;
|
|
266
|
+
PointerUp?(pointer: WidgetPointer): void;
|
|
267
|
+
Cursor?(): CursorStyle;
|
|
268
|
+
Hidden?(): boolean;
|
|
269
|
+
Disabled?(): boolean;
|
|
270
|
+
}
|
|
271
|
+
declare abstract class WidgetBase implements Widget {
|
|
272
|
+
#private;
|
|
273
|
+
abstract Size(): Vector2;
|
|
274
|
+
protected abstract render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
275
|
+
Draw(ctx: CanvasRenderingContext2D, box: Box, scale: number, mousePosition: Vector2 | undefined): void;
|
|
276
|
+
PointerDown(pointer: WidgetPointer): void;
|
|
277
|
+
PointerMove(pointer: WidgetPointer): void;
|
|
278
|
+
PointerUp(pointer: WidgetPointer): void;
|
|
279
|
+
Cursor(): CursorStyle;
|
|
280
|
+
Hidden(): boolean;
|
|
281
|
+
setHidden(hidden: boolean): void;
|
|
282
|
+
Disabled(): boolean;
|
|
283
|
+
setDisabled(disabled: boolean): void;
|
|
284
|
+
protected hovered(): boolean;
|
|
285
|
+
protected pressed(): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Where the widget was last drawn, in canvas pixels.
|
|
288
|
+
*/
|
|
289
|
+
protected box(): Box;
|
|
290
|
+
protected canvas(): HTMLCanvasElement | null;
|
|
291
|
+
protected scale(): number;
|
|
292
|
+
protected editText(value: string, onCommit: (text: string) => void): void;
|
|
293
|
+
protected onPointerDown(pointer: WidgetPointer): void;
|
|
294
|
+
protected onPointerMove(pointer: WidgetPointer): void;
|
|
295
|
+
protected onPointerUp(pointer: WidgetPointer): void;
|
|
296
|
+
/**
|
|
297
|
+
* A press and release that both landed on the widget.
|
|
298
|
+
*/
|
|
299
|
+
protected onClick(pointer: WidgetPointer): void;
|
|
237
300
|
}
|
|
238
301
|
|
|
239
302
|
interface StrokeStyleConfig {
|
|
@@ -247,18 +310,238 @@ interface BoxStyleConfig {
|
|
|
247
310
|
radius?: number;
|
|
248
311
|
}
|
|
249
312
|
|
|
313
|
+
interface ValueWidgetConfig<T> {
|
|
314
|
+
/**
|
|
315
|
+
* A node property the widget shows and edits. Setting the property from
|
|
316
|
+
* code updates the widget without counting as an edit.
|
|
317
|
+
*/
|
|
318
|
+
property?: string;
|
|
319
|
+
value?: T;
|
|
320
|
+
label?: string;
|
|
321
|
+
/**
|
|
322
|
+
* The narrowest the widget gets, in graph units.
|
|
323
|
+
*/
|
|
324
|
+
width?: number;
|
|
325
|
+
/**
|
|
326
|
+
* A person finished changing the value.
|
|
327
|
+
*/
|
|
328
|
+
callback?: (value: T) => void;
|
|
329
|
+
/**
|
|
330
|
+
* The value moved while a person is still changing it.
|
|
331
|
+
*/
|
|
332
|
+
onInput?: (value: T) => void;
|
|
333
|
+
}
|
|
334
|
+
declare abstract class ValueWidget<T> extends WidgetBase {
|
|
335
|
+
#private;
|
|
336
|
+
constructor(node: FlowNode, config: ValueWidgetConfig<T> | undefined, fallback: T);
|
|
337
|
+
Size(): Vector2;
|
|
338
|
+
value(): T;
|
|
339
|
+
/**
|
|
340
|
+
* Shows a new value without treating it as a person's edit: no callback
|
|
341
|
+
* and no edit event.
|
|
342
|
+
*/
|
|
343
|
+
setValue(value: T): void;
|
|
344
|
+
label(): string;
|
|
345
|
+
setLabel(label: string): void;
|
|
346
|
+
protected node(): FlowNode;
|
|
347
|
+
protected input(value: T): void;
|
|
348
|
+
/**
|
|
349
|
+
* Ends a person's edit. Nothing is reported when they ended where they
|
|
350
|
+
* started.
|
|
351
|
+
*/
|
|
352
|
+
protected commit(value: T, startedAt: T): void;
|
|
353
|
+
protected valueChanged(): void;
|
|
354
|
+
protected equal(a: T, b: T): boolean;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
interface NumberWidgetConfig extends ValueWidgetConfig<number> {
|
|
358
|
+
/**
|
|
359
|
+
* How much the value moves per pixel dragged. Left out, it scales with
|
|
360
|
+
* the value's size.
|
|
361
|
+
*/
|
|
362
|
+
step?: number;
|
|
363
|
+
integer?: boolean;
|
|
364
|
+
min?: number;
|
|
365
|
+
max?: number;
|
|
366
|
+
}
|
|
367
|
+
declare class NumberWidget extends ValueWidget<number> {
|
|
368
|
+
#private;
|
|
369
|
+
constructor(node: FlowNode, config?: NumberWidgetConfig);
|
|
370
|
+
Cursor(): CursorStyle;
|
|
371
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
372
|
+
protected onPointerDown(pointer: WidgetPointer): void;
|
|
373
|
+
protected onPointerMove(pointer: WidgetPointer): void;
|
|
374
|
+
protected onPointerUp(): void;
|
|
375
|
+
protected onClick(): void;
|
|
376
|
+
}
|
|
377
|
+
declare function formatNumber(value: number): string;
|
|
378
|
+
|
|
379
|
+
interface ButtonWidgetConfig {
|
|
380
|
+
text?: string;
|
|
381
|
+
callback?: () => void;
|
|
382
|
+
width?: number;
|
|
383
|
+
}
|
|
384
|
+
declare class ButtonWidget extends WidgetBase {
|
|
385
|
+
#private;
|
|
386
|
+
constructor(config?: ButtonWidgetConfig);
|
|
387
|
+
Size(): Vector2;
|
|
388
|
+
text(): string;
|
|
389
|
+
setText(text: string): void;
|
|
390
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
391
|
+
protected onClick(): void;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
interface ColorWidgetConfig extends ValueWidgetConfig<string> {
|
|
395
|
+
}
|
|
396
|
+
declare class ColorWidget extends ValueWidget<string> {
|
|
397
|
+
#private;
|
|
398
|
+
constructor(node: FlowNode, config?: ColorWidgetConfig);
|
|
399
|
+
protected valueChanged(): void;
|
|
400
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
401
|
+
protected onClick(): void;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
interface SliderWidgetConfig extends ValueWidgetConfig<number> {
|
|
405
|
+
min?: number;
|
|
406
|
+
max?: number;
|
|
407
|
+
snapIncrement?: number;
|
|
408
|
+
fillColor?: string;
|
|
409
|
+
}
|
|
410
|
+
declare class SliderWidget extends ValueWidget<number> {
|
|
411
|
+
#private;
|
|
412
|
+
constructor(node: FlowNode, config?: SliderWidgetConfig);
|
|
413
|
+
Cursor(): CursorStyle;
|
|
414
|
+
setValue(value: number): void;
|
|
415
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
416
|
+
protected onPointerDown(pointer: WidgetPointer): void;
|
|
417
|
+
protected onPointerMove(pointer: WidgetPointer): void;
|
|
418
|
+
protected onPointerUp(): void;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
interface StringWidgetConfig extends ValueWidgetConfig<string> {
|
|
422
|
+
}
|
|
423
|
+
declare class StringWidget extends ValueWidget<string> {
|
|
424
|
+
constructor(node: FlowNode, config?: StringWidgetConfig);
|
|
425
|
+
Cursor(): CursorStyle;
|
|
426
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
427
|
+
protected onClick(): void;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
interface ToggleWidgetConfig extends ValueWidgetConfig<boolean> {
|
|
431
|
+
onColor?: string;
|
|
432
|
+
offColor?: string;
|
|
433
|
+
}
|
|
434
|
+
declare class ToggleWidget extends ValueWidget<boolean> {
|
|
435
|
+
#private;
|
|
436
|
+
constructor(node: FlowNode, config?: ToggleWidgetConfig);
|
|
437
|
+
Toggle(): void;
|
|
438
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
439
|
+
protected onClick(): void;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
interface ImageWidgetConfig {
|
|
443
|
+
image?: string;
|
|
444
|
+
maxWidth?: number;
|
|
445
|
+
maxHeight?: number;
|
|
446
|
+
blob?: Blob;
|
|
447
|
+
}
|
|
448
|
+
declare class ImageWidget extends WidgetBase {
|
|
449
|
+
#private;
|
|
450
|
+
constructor(config?: ImageWidgetConfig);
|
|
451
|
+
SetBlob(blob: Blob): void;
|
|
452
|
+
SetUrl(url: string): void;
|
|
453
|
+
Cursor(): CursorStyle;
|
|
454
|
+
Size(): Vector2;
|
|
455
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
interface TextWidgetConfig {
|
|
459
|
+
property?: string;
|
|
460
|
+
value?: string;
|
|
461
|
+
textBoxStyle?: TextStyleConfig;
|
|
462
|
+
}
|
|
463
|
+
declare class TextWidget extends WidgetBase {
|
|
464
|
+
#private;
|
|
465
|
+
constructor(node: FlowNode, config?: TextWidgetConfig);
|
|
466
|
+
Cursor(): CursorStyle;
|
|
467
|
+
Size(): Vector2;
|
|
468
|
+
text(): string;
|
|
469
|
+
setText(value: string): void;
|
|
470
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
interface RowWidgetConfig {
|
|
474
|
+
/**
|
|
475
|
+
* How the room beyond each child's own width is shared out. Left out,
|
|
476
|
+
* every child grows the same; 0 keeps a child at its own width.
|
|
477
|
+
*/
|
|
478
|
+
grow?: Array<number>;
|
|
479
|
+
gap?: number;
|
|
480
|
+
}
|
|
481
|
+
declare class RowWidget extends WidgetBase {
|
|
482
|
+
#private;
|
|
483
|
+
constructor(children: Array<Widget>, config?: RowWidgetConfig);
|
|
484
|
+
children(): ReadonlyArray<Widget>;
|
|
485
|
+
Size(): Vector2;
|
|
486
|
+
Cursor(): CursorStyle;
|
|
487
|
+
Draw(ctx: CanvasRenderingContext2D, box: Box, scale: number, mousePosition: Vector2 | undefined): void;
|
|
488
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
489
|
+
protected onPointerDown(pointer: WidgetPointer): void;
|
|
490
|
+
protected onPointerMove(pointer: WidgetPointer): void;
|
|
491
|
+
protected onPointerUp(pointer: WidgetPointer): void;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
interface RowWidgetFactoryConfig extends RowWidgetConfig {
|
|
495
|
+
widgets: Array<WidgetConfig>;
|
|
496
|
+
}
|
|
497
|
+
interface WidgetConfigs {
|
|
498
|
+
button: ButtonWidgetConfig;
|
|
499
|
+
number: NumberWidgetConfig;
|
|
500
|
+
color: ColorWidgetConfig;
|
|
501
|
+
slider: SliderWidgetConfig;
|
|
502
|
+
string: StringWidgetConfig;
|
|
503
|
+
toggle: ToggleWidgetConfig;
|
|
504
|
+
image: ImageWidgetConfig;
|
|
505
|
+
text: TextWidgetConfig;
|
|
506
|
+
row: RowWidgetFactoryConfig;
|
|
507
|
+
}
|
|
508
|
+
interface WidgetTypes {
|
|
509
|
+
button: ButtonWidget;
|
|
510
|
+
number: NumberWidget;
|
|
511
|
+
color: ColorWidget;
|
|
512
|
+
slider: SliderWidget;
|
|
513
|
+
string: StringWidget;
|
|
514
|
+
toggle: ToggleWidget;
|
|
515
|
+
image: ImageWidget;
|
|
516
|
+
text: TextWidget;
|
|
517
|
+
row: RowWidget;
|
|
518
|
+
}
|
|
519
|
+
type WidgetConfig = {
|
|
520
|
+
[K in keyof WidgetConfigs]: {
|
|
521
|
+
type: K;
|
|
522
|
+
config?: WidgetConfigs[K];
|
|
523
|
+
};
|
|
524
|
+
}[keyof WidgetConfigs];
|
|
525
|
+
type WidgetBuilder = (node: FlowNode, config?: any) => Widget;
|
|
526
|
+
declare class WidgetFactory {
|
|
527
|
+
#private;
|
|
528
|
+
constructor();
|
|
529
|
+
register(widgetType: string, builder: WidgetBuilder): void;
|
|
530
|
+
create<K extends keyof WidgetConfigs>(node: FlowNode, widgetType: K, config?: WidgetConfigs[K]): WidgetTypes[K];
|
|
531
|
+
create(node: FlowNode, widgetType: string, config?: unknown): Widget;
|
|
532
|
+
createFromConfig(node: FlowNode, config: WidgetConfig): Widget;
|
|
533
|
+
}
|
|
534
|
+
declare const GlobalWidgetFactory: WidgetFactory;
|
|
535
|
+
|
|
250
536
|
interface Metadata {
|
|
251
537
|
[name: string]: any;
|
|
252
538
|
}
|
|
253
539
|
|
|
254
540
|
type AnyPropertyChangeCallback = (propertyName: string, oldValue: any, newValue: any) => void;
|
|
255
541
|
type PropertyChangeCallback = (oldValue: any, newValue: any) => void;
|
|
542
|
+
type PropertyEditCallback = (newValue: any) => void;
|
|
256
543
|
type TitleChangeCallback = (node: FlowNode, oldTitle: string, newTitle: string) => void;
|
|
257
544
|
type InfoChangeCallback = (node: FlowNode, oldInfo: string, newInfo: string) => void;
|
|
258
|
-
interface WidgetConfig {
|
|
259
|
-
type?: string;
|
|
260
|
-
config?: any;
|
|
261
|
-
}
|
|
262
545
|
interface FlowNodeTitleConfig {
|
|
263
546
|
textStyle?: TextStyleConfig;
|
|
264
547
|
color?: string;
|
|
@@ -321,6 +604,7 @@ interface NodeIntersection {
|
|
|
321
604
|
PortIsInput?: boolean;
|
|
322
605
|
Widget?: Widget;
|
|
323
606
|
WidgetIndex?: number;
|
|
607
|
+
WidgetBox?: Box;
|
|
324
608
|
}
|
|
325
609
|
declare class FlowNode {
|
|
326
610
|
#private;
|
|
@@ -335,6 +619,16 @@ declare class FlowNode {
|
|
|
335
619
|
addAnyPropertyChangeListener(callback: AnyPropertyChangeCallback): void;
|
|
336
620
|
addPropertyChangeListener(name: string, callback: PropertyChangeCallback): void;
|
|
337
621
|
setProperty(name: string, value: any): void;
|
|
622
|
+
/**
|
|
623
|
+
* Listens for a person changing the property through a widget, but not
|
|
624
|
+
* for the property being set from code.
|
|
625
|
+
*/
|
|
626
|
+
addPropertyEditListener(name: string, callback: PropertyEditCallback): void;
|
|
627
|
+
/**
|
|
628
|
+
* Sets the property as a person's finished edit, so edit listeners hear
|
|
629
|
+
* it even when the value was already showing.
|
|
630
|
+
*/
|
|
631
|
+
editProperty(name: string, value: any): void;
|
|
338
632
|
getProperty(name: string): any;
|
|
339
633
|
contextMenu(): ContextMenuConfig;
|
|
340
634
|
unselect(): void;
|
|
@@ -368,6 +662,7 @@ declare class FlowNode {
|
|
|
368
662
|
setTitle(newTitle: string): void;
|
|
369
663
|
setInfo(newInfo: string): void;
|
|
370
664
|
inputPortPosition(index: number): Box;
|
|
665
|
+
widgetPosition(index: number): Box | undefined;
|
|
371
666
|
inputPort(index: number): Port;
|
|
372
667
|
inputs(): number;
|
|
373
668
|
outputPortPosition(index: number): Box;
|
|
@@ -376,8 +671,14 @@ declare class FlowNode {
|
|
|
376
671
|
addMessage(message: NodeMessageConfig): void;
|
|
377
672
|
clearMessages(): void;
|
|
378
673
|
hasBeenLaidOut(): boolean;
|
|
674
|
+
/**
|
|
675
|
+
* Throws away where the ports were last placed, so wires wait for the
|
|
676
|
+
* next draw instead of pointing at the old spots.
|
|
677
|
+
*/
|
|
678
|
+
invalidateLayout(): void;
|
|
379
679
|
render(ctx: CanvasRenderingContext2D, camera: Camera, state: NodeState, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): void;
|
|
380
680
|
layoutPortsWithoutDrawing(bounds: Box, zoom: number): boolean;
|
|
681
|
+
placePorts(bounds: Box, zoom: number): boolean;
|
|
381
682
|
}
|
|
382
683
|
|
|
383
684
|
type NodeAddedCallback = (node: FlowNode) => void;
|
|
@@ -668,10 +969,15 @@ declare class NodeFlowGraph {
|
|
|
668
969
|
dispose(): void;
|
|
669
970
|
}
|
|
670
971
|
|
|
671
|
-
|
|
972
|
+
interface BevelColors {
|
|
973
|
+
Light: string;
|
|
974
|
+
Dark: string;
|
|
975
|
+
}
|
|
976
|
+
declare const defaults: {
|
|
672
977
|
FontFamily: string;
|
|
673
978
|
Graph: {
|
|
674
979
|
BackgroundColor: string;
|
|
980
|
+
DotColor: string;
|
|
675
981
|
};
|
|
676
982
|
Node: {
|
|
677
983
|
FontColor: string;
|
|
@@ -688,6 +994,7 @@ declare const Theme: {
|
|
|
688
994
|
Grabbed: string;
|
|
689
995
|
Selected: string;
|
|
690
996
|
};
|
|
997
|
+
Bevel: BevelColors | null;
|
|
691
998
|
Port: {
|
|
692
999
|
FontColor: string;
|
|
693
1000
|
};
|
|
@@ -705,15 +1012,25 @@ declare const Theme: {
|
|
|
705
1012
|
};
|
|
706
1013
|
Widget: {
|
|
707
1014
|
FontColor: string;
|
|
1015
|
+
LabelColor: string;
|
|
1016
|
+
FontSize: number;
|
|
1017
|
+
Padding: number;
|
|
1018
|
+
Gap: number;
|
|
708
1019
|
BackgroundColor: string;
|
|
709
1020
|
Border: {
|
|
710
1021
|
Color: string;
|
|
711
1022
|
Size: number;
|
|
712
1023
|
Radius: number;
|
|
713
1024
|
};
|
|
1025
|
+
Bevel: BevelColors | null;
|
|
714
1026
|
Hover: {
|
|
715
1027
|
BackgroundColor: string;
|
|
716
1028
|
};
|
|
1029
|
+
Input: {
|
|
1030
|
+
BackgroundColor: string;
|
|
1031
|
+
HoverBackgroundColor: string;
|
|
1032
|
+
FontColor: string;
|
|
1033
|
+
};
|
|
717
1034
|
Slider: {
|
|
718
1035
|
FillColor: string;
|
|
719
1036
|
};
|
|
@@ -726,8 +1043,10 @@ declare const Theme: {
|
|
|
726
1043
|
ContextMenu: {
|
|
727
1044
|
BackgroundColor: string;
|
|
728
1045
|
HighlightColor: string;
|
|
1046
|
+
HighlightFontColor: string;
|
|
729
1047
|
FontColor: string;
|
|
730
1048
|
DisabledFontColor: string;
|
|
1049
|
+
BorderRadius: number;
|
|
731
1050
|
};
|
|
732
1051
|
Minimap: {
|
|
733
1052
|
BackgroundColor: string;
|
|
@@ -737,6 +1056,13 @@ declare const Theme: {
|
|
|
737
1056
|
NodeColor: string;
|
|
738
1057
|
ViewportColor: string;
|
|
739
1058
|
};
|
|
1059
|
+
Popup: {
|
|
1060
|
+
BackgroundColor: string;
|
|
1061
|
+
FontColor: string;
|
|
1062
|
+
FontFamily: string;
|
|
1063
|
+
BorderRadius: number;
|
|
1064
|
+
Backdrop: string;
|
|
1065
|
+
};
|
|
740
1066
|
Note: {
|
|
741
1067
|
FontColor: string;
|
|
742
1068
|
FontSize: number;
|
|
@@ -755,232 +1081,73 @@ declare const Theme: {
|
|
|
755
1081
|
};
|
|
756
1082
|
CodeBlock: {
|
|
757
1083
|
BackgroundColor: string;
|
|
1084
|
+
FontColor: string;
|
|
758
1085
|
Padding: number;
|
|
759
1086
|
BorderRadius: number;
|
|
760
1087
|
};
|
|
761
1088
|
};
|
|
762
|
-
};
|
|
1089
|
+
};
|
|
1090
|
+
type ThemeValues = typeof defaults;
|
|
1091
|
+
type DeepPartial<T> = {
|
|
1092
|
+
[K in keyof T]?: T[K] extends object | null ? (null extends T[K] ? T[K] : DeepPartial<T[K]>) : T[K];
|
|
1093
|
+
};
|
|
1094
|
+
type ThemeConfig = DeepPartial<ThemeValues>;
|
|
1095
|
+
declare const DefaultTheme: Readonly<ThemeValues>;
|
|
1096
|
+
declare const Theme: ThemeValues;
|
|
1097
|
+
/**
|
|
1098
|
+
* Replaces the theme: the defaults, with anything in config laid over them.
|
|
1099
|
+
* Everything already on screen picks the change up on its next draw.
|
|
1100
|
+
*/
|
|
1101
|
+
declare function setTheme(config?: ThemeConfig): void;
|
|
1102
|
+
declare function themeVersion(): number;
|
|
1103
|
+
declare function onThemeChange(listener: () => void): () => void;
|
|
763
1104
|
|
|
764
1105
|
declare function requestRender(): void;
|
|
765
1106
|
declare function renderContinuously(): () => void;
|
|
766
1107
|
|
|
767
|
-
interface
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
value
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
callback?: (newNumber: number) => void;
|
|
780
|
-
}
|
|
781
|
-
declare class NumberWidget {
|
|
782
|
-
#private;
|
|
783
|
-
constructor(node: FlowNode, config?: NumberWidgetConfig);
|
|
784
|
-
Size(): Vector2;
|
|
785
|
-
Set(newNumber: number): void;
|
|
786
|
-
ClickStart(): void;
|
|
787
|
-
ClickEnd(): void;
|
|
788
|
-
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
interface ColorWidgetConfig {
|
|
792
|
-
value?: string;
|
|
793
|
-
property?: string;
|
|
794
|
-
textStyle?: TextStyleConfig;
|
|
795
|
-
callback?: (newColor: string) => void;
|
|
796
|
-
}
|
|
797
|
-
declare class ColorWidget {
|
|
798
|
-
#private;
|
|
799
|
-
constructor(node: FlowNode, config?: ColorWidgetConfig);
|
|
800
|
-
Size(): Vector2;
|
|
801
|
-
Set(value: string): void;
|
|
802
|
-
ClickStart(): void;
|
|
803
|
-
ClickEnd(): void;
|
|
804
|
-
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
interface StringWidgetConfig {
|
|
808
|
-
property?: string;
|
|
809
|
-
value?: string;
|
|
810
|
-
textBoxStyle?: TextBoxStyleConfig;
|
|
811
|
-
callback?: (newString: string) => void;
|
|
812
|
-
}
|
|
813
|
-
declare class StringWidget {
|
|
814
|
-
#private;
|
|
815
|
-
constructor(node: FlowNode, config?: StringWidgetConfig);
|
|
816
|
-
Size(): Vector2;
|
|
817
|
-
Set(value: string): void;
|
|
818
|
-
ClickStart(): void;
|
|
819
|
-
ClickEnd(): void;
|
|
820
|
-
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
interface TextWidgetConfig {
|
|
824
|
-
property?: string;
|
|
825
|
-
value?: string;
|
|
826
|
-
textBoxStyle?: TextStyleConfig;
|
|
827
|
-
callback?: (newString: string) => void;
|
|
828
|
-
}
|
|
829
|
-
declare class TextWidget {
|
|
830
|
-
#private;
|
|
831
|
-
constructor(node: FlowNode, config?: TextWidgetConfig);
|
|
832
|
-
Size(): Vector2;
|
|
833
|
-
Set(value: string): void;
|
|
834
|
-
ClickStart(): void;
|
|
835
|
-
ClickEnd(): void;
|
|
836
|
-
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
interface ButtonWidgetConfig {
|
|
840
|
-
text?: string;
|
|
841
|
-
callback?: () => void;
|
|
842
|
-
idleStyle?: TextBoxStyleConfig;
|
|
843
|
-
hoverStyle?: TextBoxStyleConfig;
|
|
844
|
-
clickStyle?: TextBoxStyleConfig;
|
|
845
|
-
}
|
|
846
|
-
declare class ButtonWidget {
|
|
847
|
-
#private;
|
|
848
|
-
constructor(config?: ButtonWidgetConfig);
|
|
849
|
-
Size(): Vector2;
|
|
850
|
-
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
851
|
-
ClickStart(): void;
|
|
852
|
-
ClickEnd(): void;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
interface ToggleStyleConfig {
|
|
856
|
-
idle?: TextBoxStyleConfig;
|
|
857
|
-
hover?: TextBoxStyleConfig;
|
|
858
|
-
lightColor?: string;
|
|
859
|
-
lightBorderColor?: string;
|
|
860
|
-
lightBlur?: number;
|
|
861
|
-
}
|
|
862
|
-
interface ToggleWidgetConfig {
|
|
863
|
-
property?: string;
|
|
864
|
-
value?: boolean;
|
|
865
|
-
text?: string;
|
|
866
|
-
callback?: () => void;
|
|
867
|
-
enabledStyle?: ToggleStyleConfig;
|
|
868
|
-
disabledStyle?: ToggleStyleConfig;
|
|
1108
|
+
interface FieldLook {
|
|
1109
|
+
hovered: boolean;
|
|
1110
|
+
pressed?: boolean;
|
|
1111
|
+
/**
|
|
1112
|
+
* Something typed or dragged into, as opposed to something pressed.
|
|
1113
|
+
*/
|
|
1114
|
+
input?: boolean;
|
|
1115
|
+
label?: string;
|
|
1116
|
+
value: string;
|
|
1117
|
+
background?: string;
|
|
1118
|
+
border?: string;
|
|
1119
|
+
textColor?: string;
|
|
869
1120
|
}
|
|
870
|
-
declare
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
ClickEnd(): void;
|
|
879
|
-
}
|
|
1121
|
+
declare function widgetFont(scale: number): string;
|
|
1122
|
+
declare function drawFieldBox(ctx: CanvasRenderingContext2D, box: Box, scale: number, look: FieldLook): void;
|
|
1123
|
+
/**
|
|
1124
|
+
* A boxed value with an optional label: the label on the left and the value
|
|
1125
|
+
* on the right, or the value alone in the middle.
|
|
1126
|
+
*/
|
|
1127
|
+
declare function drawField(ctx: CanvasRenderingContext2D, box: Box, scale: number, look: FieldLook): void;
|
|
1128
|
+
declare function drawFieldText(ctx: CanvasRenderingContext2D, box: Box, scale: number, look: FieldLook): void;
|
|
880
1129
|
|
|
881
|
-
interface
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
change?: (newValue: number) => void;
|
|
891
|
-
release?: (newValue: number) => void;
|
|
892
|
-
snapIncrement?: number;
|
|
1130
|
+
interface InPlaceEditConfig {
|
|
1131
|
+
canvas: HTMLCanvasElement | null;
|
|
1132
|
+
/**
|
|
1133
|
+
* Where to sit, in canvas pixels.
|
|
1134
|
+
*/
|
|
1135
|
+
box: Box;
|
|
1136
|
+
scale: number;
|
|
1137
|
+
value: string;
|
|
1138
|
+
onCommit: (text: string) => void;
|
|
893
1139
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
ClickEnd(): void;
|
|
901
|
-
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
interface ImageWidgetConfig {
|
|
905
|
-
image?: string;
|
|
906
|
-
maxWidth?: number;
|
|
907
|
-
maxHeight?: number;
|
|
908
|
-
blob?: Blob;
|
|
1140
|
+
interface InPlaceEdit {
|
|
1141
|
+
input: HTMLInputElement;
|
|
1142
|
+
/**
|
|
1143
|
+
* Moves the input over where the widget was just drawn, in canvas pixels.
|
|
1144
|
+
*/
|
|
1145
|
+
place(box: Box, scale: number): void;
|
|
909
1146
|
}
|
|
910
1147
|
/**
|
|
911
|
-
*
|
|
912
|
-
|
|
913
|
-
this.id = id;
|
|
914
|
-
this.app = app;
|
|
915
|
-
this.lightNode.title = parameterData.name;
|
|
916
|
-
|
|
917
|
-
this.lightNode.onDropFile = (file) => {
|
|
918
|
-
// console.log(file)
|
|
919
|
-
var reader = new FileReader();
|
|
920
|
-
reader.onload = (evt) => {
|
|
921
|
-
console.log(evt.target.result)
|
|
922
|
-
nodeManager.nodeParameterChanged({
|
|
923
|
-
id: id,
|
|
924
|
-
data: evt.target.result,
|
|
925
|
-
binary: true
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
reader.readAsArrayBuffer(file);
|
|
929
|
-
|
|
930
|
-
const url = URL.createObjectURL(file);
|
|
931
|
-
// this.loadImage(this._url, function (img) {
|
|
932
|
-
// that.size[1] = (img.height / img.width) * that.size[0];
|
|
933
|
-
// });
|
|
934
|
-
this.loadImgFromURL(url);
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
loadImgFromURL(url) {
|
|
939
|
-
const img = document.createElement("img");
|
|
940
|
-
img.src = url;
|
|
941
|
-
img.onload = () => {
|
|
942
|
-
// if (callback) {
|
|
943
|
-
// callback(this);
|
|
944
|
-
// }
|
|
945
|
-
// console.log("Image loaded, size: " + img.width + "x" + img.height);
|
|
946
|
-
// this.dirty = true;
|
|
947
|
-
// that.boxcolor = "#9F9";f
|
|
948
|
-
// that.setDirtyCanvas(true);
|
|
949
|
-
this.lightNode.widgets[0].image = img
|
|
950
|
-
this.lightNode.setSize(this.lightNode.computeSize());
|
|
951
|
-
};
|
|
952
|
-
img.onerror = () => {
|
|
953
|
-
console.log("error loading the image:" + url);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
update(parameterData) {
|
|
958
|
-
console.log("image parameter", parameterData)
|
|
959
|
-
const curVal = parameterData.currentValue;
|
|
960
|
-
this.app.RequestManager.getParameterValue(this.id, (response) => {
|
|
961
|
-
const url = URL.createObjectURL(response);
|
|
962
|
-
this.loadImgFromURL(url)
|
|
963
|
-
})
|
|
964
|
-
}
|
|
1148
|
+
* Lays a text input over a widget. Enter or clicking away keeps what was
|
|
1149
|
+
* typed; Escape throws it away.
|
|
965
1150
|
*/
|
|
966
|
-
declare
|
|
967
|
-
#private;
|
|
968
|
-
constructor(config?: ImageWidgetConfig);
|
|
969
|
-
SetBlob(blob: Blob): void;
|
|
970
|
-
SetUrl(url: string): void;
|
|
971
|
-
Size(): Vector2;
|
|
972
|
-
ClickStart(): void;
|
|
973
|
-
ClickEnd(): void;
|
|
974
|
-
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
type WidgetBuilder = (node: FlowNode, confg?: any) => Widget;
|
|
978
|
-
declare class WidgetFactory {
|
|
979
|
-
#private;
|
|
980
|
-
constructor();
|
|
981
|
-
register(widgetType: string, builder: WidgetBuilder): void;
|
|
982
|
-
create(node: FlowNode, widgetType: string, config: any): Widget;
|
|
983
|
-
}
|
|
984
|
-
declare const GlobalWidgetFactory: WidgetFactory;
|
|
1151
|
+
declare function editInPlace(config: InPlaceEditConfig): InPlaceEdit | null;
|
|
985
1152
|
|
|
986
|
-
export { type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, type CopyCallback, type DanglingConnection, DefaultConnectionRenderer, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, ImageWidget, type ImageWidgetConfig, type InternalConnection, MessageType, Minimap, type MinimapConfig, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeIntersection, type NodeMenuFilter, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, type PasteCallback, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type
|
|
1153
|
+
export { type BevelColors, type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, type CopyCallback, CursorStyle, type DanglingConnection, DefaultConnectionRenderer, DefaultTheme, type FieldLook, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, GraphView, ImageWidget, type ImageWidgetConfig, InBox, type InPlaceEdit, type InPlaceEditConfig, type InternalConnection, MessageType, Minimap, type MinimapConfig, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeIntersection, type NodeMenuFilter, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, type PasteCallback, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, RowWidget, type RowWidgetConfig, type RowWidgetFactoryConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type ThemeConfig, type ThemeValues, ToggleWidget, type ToggleWidgetConfig, ValueWidget, type ValueWidgetConfig, type Vector2, type Widget, WidgetBase, type WidgetBuilder, type WidgetConfig, type WidgetConfigs, WidgetFactory, type WidgetPointer, type WidgetTypes, drawField, drawFieldBox, drawFieldText, editInPlace, formatNumber, onThemeChange, portConfigTypes, portsCompatible, renderContinuously, requestRender, setTheme, themeVersion, typeSetsCompatible, widgetFont };
|