@elicdavis/node-flow 0.1.19 → 0.2.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/dist/index.d.mts +386 -227
- package/dist/index.d.ts +386 -227
- package/dist/index.js +1884 -1076
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1867 -1075
- 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 +12 -10
- package/src/index.ts +26 -12
- package/src/markdown/entry.ts +11 -15
- package/src/markdown/syntaxParser.ts +2 -1
- package/src/node.ts +162 -111
- package/src/nodes/subsystem.ts +123 -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 +84 -0
- package/src/widgets/number.ts +122 -154
- package/src/widgets/row.ts +138 -0
- package/src/widgets/slider.ts +101 -216
- package/src/widgets/string.ts +39 -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 +180 -34
- 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/hover_after_removal.test.ts +72 -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/property_binding.test.ts +49 -0
- package/test/support.ts +175 -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 +333 -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,57 @@ 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 onPointerDown(pointer: WidgetPointer): void;
|
|
293
|
+
protected onPointerMove(pointer: WidgetPointer): void;
|
|
294
|
+
protected onPointerUp(pointer: WidgetPointer): void;
|
|
295
|
+
/**
|
|
296
|
+
* A press and release that both landed on the widget.
|
|
297
|
+
*/
|
|
298
|
+
protected onClick(pointer: WidgetPointer): void;
|
|
237
299
|
}
|
|
238
300
|
|
|
239
301
|
interface StrokeStyleConfig {
|
|
@@ -247,18 +309,238 @@ interface BoxStyleConfig {
|
|
|
247
309
|
radius?: number;
|
|
248
310
|
}
|
|
249
311
|
|
|
312
|
+
interface ValueWidgetConfig<T> {
|
|
313
|
+
/**
|
|
314
|
+
* A node property the widget shows and edits. Setting the property from
|
|
315
|
+
* code updates the widget without counting as an edit.
|
|
316
|
+
*/
|
|
317
|
+
property?: string;
|
|
318
|
+
value?: T;
|
|
319
|
+
label?: string;
|
|
320
|
+
/**
|
|
321
|
+
* The narrowest the widget gets, in graph units.
|
|
322
|
+
*/
|
|
323
|
+
width?: number;
|
|
324
|
+
/**
|
|
325
|
+
* A person finished changing the value.
|
|
326
|
+
*/
|
|
327
|
+
callback?: (value: T) => void;
|
|
328
|
+
/**
|
|
329
|
+
* The value moved while a person is still changing it.
|
|
330
|
+
*/
|
|
331
|
+
onInput?: (value: T) => void;
|
|
332
|
+
}
|
|
333
|
+
declare abstract class ValueWidget<T> extends WidgetBase {
|
|
334
|
+
#private;
|
|
335
|
+
constructor(node: FlowNode, config: ValueWidgetConfig<T> | undefined, fallback: T);
|
|
336
|
+
Size(): Vector2;
|
|
337
|
+
value(): T;
|
|
338
|
+
/**
|
|
339
|
+
* Shows a new value without treating it as a person's edit: no callback
|
|
340
|
+
* and no edit event.
|
|
341
|
+
*/
|
|
342
|
+
setValue(value: T): void;
|
|
343
|
+
label(): string;
|
|
344
|
+
setLabel(label: string): void;
|
|
345
|
+
protected node(): FlowNode;
|
|
346
|
+
protected input(value: T): void;
|
|
347
|
+
/**
|
|
348
|
+
* Ends a person's edit. Nothing is reported when they ended where they
|
|
349
|
+
* started.
|
|
350
|
+
*/
|
|
351
|
+
protected commit(value: T, startedAt: T): void;
|
|
352
|
+
protected valueChanged(): void;
|
|
353
|
+
protected equal(a: T, b: T): boolean;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
interface NumberWidgetConfig extends ValueWidgetConfig<number> {
|
|
357
|
+
/**
|
|
358
|
+
* How much the value moves per pixel dragged. Left out, it scales with
|
|
359
|
+
* the value's size.
|
|
360
|
+
*/
|
|
361
|
+
step?: number;
|
|
362
|
+
integer?: boolean;
|
|
363
|
+
min?: number;
|
|
364
|
+
max?: number;
|
|
365
|
+
}
|
|
366
|
+
declare class NumberWidget extends ValueWidget<number> {
|
|
367
|
+
#private;
|
|
368
|
+
constructor(node: FlowNode, config?: NumberWidgetConfig);
|
|
369
|
+
Cursor(): CursorStyle;
|
|
370
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
371
|
+
protected onPointerDown(pointer: WidgetPointer): void;
|
|
372
|
+
protected onPointerMove(pointer: WidgetPointer): void;
|
|
373
|
+
protected onPointerUp(): void;
|
|
374
|
+
protected onClick(): void;
|
|
375
|
+
}
|
|
376
|
+
declare function formatNumber(value: number): string;
|
|
377
|
+
|
|
378
|
+
interface ButtonWidgetConfig {
|
|
379
|
+
text?: string;
|
|
380
|
+
callback?: () => void;
|
|
381
|
+
width?: number;
|
|
382
|
+
}
|
|
383
|
+
declare class ButtonWidget extends WidgetBase {
|
|
384
|
+
#private;
|
|
385
|
+
constructor(config?: ButtonWidgetConfig);
|
|
386
|
+
Size(): Vector2;
|
|
387
|
+
text(): string;
|
|
388
|
+
setText(text: string): void;
|
|
389
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
390
|
+
protected onClick(): void;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
interface ColorWidgetConfig extends ValueWidgetConfig<string> {
|
|
394
|
+
}
|
|
395
|
+
declare class ColorWidget extends ValueWidget<string> {
|
|
396
|
+
#private;
|
|
397
|
+
constructor(node: FlowNode, config?: ColorWidgetConfig);
|
|
398
|
+
protected valueChanged(): void;
|
|
399
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
400
|
+
protected onClick(): void;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
interface SliderWidgetConfig extends ValueWidgetConfig<number> {
|
|
404
|
+
min?: number;
|
|
405
|
+
max?: number;
|
|
406
|
+
snapIncrement?: number;
|
|
407
|
+
fillColor?: string;
|
|
408
|
+
}
|
|
409
|
+
declare class SliderWidget extends ValueWidget<number> {
|
|
410
|
+
#private;
|
|
411
|
+
constructor(node: FlowNode, config?: SliderWidgetConfig);
|
|
412
|
+
Cursor(): CursorStyle;
|
|
413
|
+
setValue(value: number): void;
|
|
414
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
415
|
+
protected onPointerDown(pointer: WidgetPointer): void;
|
|
416
|
+
protected onPointerMove(pointer: WidgetPointer): void;
|
|
417
|
+
protected onPointerUp(): void;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
interface StringWidgetConfig extends ValueWidgetConfig<string> {
|
|
421
|
+
}
|
|
422
|
+
declare class StringWidget extends ValueWidget<string> {
|
|
423
|
+
constructor(node: FlowNode, config?: StringWidgetConfig);
|
|
424
|
+
Cursor(): CursorStyle;
|
|
425
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
426
|
+
protected onClick(): void;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
interface ToggleWidgetConfig extends ValueWidgetConfig<boolean> {
|
|
430
|
+
onColor?: string;
|
|
431
|
+
offColor?: string;
|
|
432
|
+
}
|
|
433
|
+
declare class ToggleWidget extends ValueWidget<boolean> {
|
|
434
|
+
#private;
|
|
435
|
+
constructor(node: FlowNode, config?: ToggleWidgetConfig);
|
|
436
|
+
Toggle(): void;
|
|
437
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
438
|
+
protected onClick(): void;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
interface ImageWidgetConfig {
|
|
442
|
+
image?: string;
|
|
443
|
+
maxWidth?: number;
|
|
444
|
+
maxHeight?: number;
|
|
445
|
+
blob?: Blob;
|
|
446
|
+
}
|
|
447
|
+
declare class ImageWidget extends WidgetBase {
|
|
448
|
+
#private;
|
|
449
|
+
constructor(config?: ImageWidgetConfig);
|
|
450
|
+
SetBlob(blob: Blob): void;
|
|
451
|
+
SetUrl(url: string): void;
|
|
452
|
+
Cursor(): CursorStyle;
|
|
453
|
+
Size(): Vector2;
|
|
454
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
interface TextWidgetConfig {
|
|
458
|
+
property?: string;
|
|
459
|
+
value?: string;
|
|
460
|
+
textBoxStyle?: TextStyleConfig;
|
|
461
|
+
}
|
|
462
|
+
declare class TextWidget extends WidgetBase {
|
|
463
|
+
#private;
|
|
464
|
+
constructor(node: FlowNode, config?: TextWidgetConfig);
|
|
465
|
+
Cursor(): CursorStyle;
|
|
466
|
+
Size(): Vector2;
|
|
467
|
+
text(): string;
|
|
468
|
+
setText(value: string): void;
|
|
469
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
interface RowWidgetConfig {
|
|
473
|
+
/**
|
|
474
|
+
* How the room beyond each child's own width is shared out. Left out,
|
|
475
|
+
* every child grows the same; 0 keeps a child at its own width.
|
|
476
|
+
*/
|
|
477
|
+
grow?: Array<number>;
|
|
478
|
+
gap?: number;
|
|
479
|
+
}
|
|
480
|
+
declare class RowWidget extends WidgetBase {
|
|
481
|
+
#private;
|
|
482
|
+
constructor(children: Array<Widget>, config?: RowWidgetConfig);
|
|
483
|
+
children(): ReadonlyArray<Widget>;
|
|
484
|
+
Size(): Vector2;
|
|
485
|
+
Cursor(): CursorStyle;
|
|
486
|
+
Draw(ctx: CanvasRenderingContext2D, box: Box, scale: number, mousePosition: Vector2 | undefined): void;
|
|
487
|
+
protected render(ctx: CanvasRenderingContext2D, box: Box, scale: number): void;
|
|
488
|
+
protected onPointerDown(pointer: WidgetPointer): void;
|
|
489
|
+
protected onPointerMove(pointer: WidgetPointer): void;
|
|
490
|
+
protected onPointerUp(pointer: WidgetPointer): void;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
interface RowWidgetFactoryConfig extends RowWidgetConfig {
|
|
494
|
+
widgets: Array<WidgetConfig>;
|
|
495
|
+
}
|
|
496
|
+
interface WidgetConfigs {
|
|
497
|
+
button: ButtonWidgetConfig;
|
|
498
|
+
number: NumberWidgetConfig;
|
|
499
|
+
color: ColorWidgetConfig;
|
|
500
|
+
slider: SliderWidgetConfig;
|
|
501
|
+
string: StringWidgetConfig;
|
|
502
|
+
toggle: ToggleWidgetConfig;
|
|
503
|
+
image: ImageWidgetConfig;
|
|
504
|
+
text: TextWidgetConfig;
|
|
505
|
+
row: RowWidgetFactoryConfig;
|
|
506
|
+
}
|
|
507
|
+
interface WidgetTypes {
|
|
508
|
+
button: ButtonWidget;
|
|
509
|
+
number: NumberWidget;
|
|
510
|
+
color: ColorWidget;
|
|
511
|
+
slider: SliderWidget;
|
|
512
|
+
string: StringWidget;
|
|
513
|
+
toggle: ToggleWidget;
|
|
514
|
+
image: ImageWidget;
|
|
515
|
+
text: TextWidget;
|
|
516
|
+
row: RowWidget;
|
|
517
|
+
}
|
|
518
|
+
type WidgetConfig = {
|
|
519
|
+
[K in keyof WidgetConfigs]: {
|
|
520
|
+
type: K;
|
|
521
|
+
config?: WidgetConfigs[K];
|
|
522
|
+
};
|
|
523
|
+
}[keyof WidgetConfigs];
|
|
524
|
+
type WidgetBuilder = (node: FlowNode, config?: any) => Widget;
|
|
525
|
+
declare class WidgetFactory {
|
|
526
|
+
#private;
|
|
527
|
+
constructor();
|
|
528
|
+
register(widgetType: string, builder: WidgetBuilder): void;
|
|
529
|
+
create<K extends keyof WidgetConfigs>(node: FlowNode, widgetType: K, config?: WidgetConfigs[K]): WidgetTypes[K];
|
|
530
|
+
create(node: FlowNode, widgetType: string, config?: unknown): Widget;
|
|
531
|
+
createFromConfig(node: FlowNode, config: WidgetConfig): Widget;
|
|
532
|
+
}
|
|
533
|
+
declare const GlobalWidgetFactory: WidgetFactory;
|
|
534
|
+
|
|
250
535
|
interface Metadata {
|
|
251
536
|
[name: string]: any;
|
|
252
537
|
}
|
|
253
538
|
|
|
254
539
|
type AnyPropertyChangeCallback = (propertyName: string, oldValue: any, newValue: any) => void;
|
|
255
540
|
type PropertyChangeCallback = (oldValue: any, newValue: any) => void;
|
|
541
|
+
type PropertyEditCallback = (newValue: any) => void;
|
|
256
542
|
type TitleChangeCallback = (node: FlowNode, oldTitle: string, newTitle: string) => void;
|
|
257
543
|
type InfoChangeCallback = (node: FlowNode, oldInfo: string, newInfo: string) => void;
|
|
258
|
-
interface WidgetConfig {
|
|
259
|
-
type?: string;
|
|
260
|
-
config?: any;
|
|
261
|
-
}
|
|
262
544
|
interface FlowNodeTitleConfig {
|
|
263
545
|
textStyle?: TextStyleConfig;
|
|
264
546
|
color?: string;
|
|
@@ -321,6 +603,7 @@ interface NodeIntersection {
|
|
|
321
603
|
PortIsInput?: boolean;
|
|
322
604
|
Widget?: Widget;
|
|
323
605
|
WidgetIndex?: number;
|
|
606
|
+
WidgetBox?: Box;
|
|
324
607
|
}
|
|
325
608
|
declare class FlowNode {
|
|
326
609
|
#private;
|
|
@@ -335,6 +618,16 @@ declare class FlowNode {
|
|
|
335
618
|
addAnyPropertyChangeListener(callback: AnyPropertyChangeCallback): void;
|
|
336
619
|
addPropertyChangeListener(name: string, callback: PropertyChangeCallback): void;
|
|
337
620
|
setProperty(name: string, value: any): void;
|
|
621
|
+
/**
|
|
622
|
+
* Listens for a person changing the property through a widget, but not
|
|
623
|
+
* for the property being set from code.
|
|
624
|
+
*/
|
|
625
|
+
addPropertyEditListener(name: string, callback: PropertyEditCallback): void;
|
|
626
|
+
/**
|
|
627
|
+
* Sets the property as a person's finished edit, so edit listeners hear
|
|
628
|
+
* it even when the value was already showing.
|
|
629
|
+
*/
|
|
630
|
+
editProperty(name: string, value: any): void;
|
|
338
631
|
getProperty(name: string): any;
|
|
339
632
|
contextMenu(): ContextMenuConfig;
|
|
340
633
|
unselect(): void;
|
|
@@ -368,6 +661,7 @@ declare class FlowNode {
|
|
|
368
661
|
setTitle(newTitle: string): void;
|
|
369
662
|
setInfo(newInfo: string): void;
|
|
370
663
|
inputPortPosition(index: number): Box;
|
|
664
|
+
widgetPosition(index: number): Box | undefined;
|
|
371
665
|
inputPort(index: number): Port;
|
|
372
666
|
inputs(): number;
|
|
373
667
|
outputPortPosition(index: number): Box;
|
|
@@ -376,8 +670,14 @@ declare class FlowNode {
|
|
|
376
670
|
addMessage(message: NodeMessageConfig): void;
|
|
377
671
|
clearMessages(): void;
|
|
378
672
|
hasBeenLaidOut(): boolean;
|
|
673
|
+
/**
|
|
674
|
+
* Throws away where the ports were last placed, so wires wait for the
|
|
675
|
+
* next draw instead of pointing at the old spots.
|
|
676
|
+
*/
|
|
677
|
+
invalidateLayout(): void;
|
|
379
678
|
render(ctx: CanvasRenderingContext2D, camera: Camera, state: NodeState, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): void;
|
|
380
679
|
layoutPortsWithoutDrawing(bounds: Box, zoom: number): boolean;
|
|
680
|
+
placePorts(bounds: Box, zoom: number): boolean;
|
|
381
681
|
}
|
|
382
682
|
|
|
383
683
|
type NodeAddedCallback = (node: FlowNode) => void;
|
|
@@ -668,10 +968,15 @@ declare class NodeFlowGraph {
|
|
|
668
968
|
dispose(): void;
|
|
669
969
|
}
|
|
670
970
|
|
|
671
|
-
|
|
971
|
+
interface BevelColors {
|
|
972
|
+
Light: string;
|
|
973
|
+
Dark: string;
|
|
974
|
+
}
|
|
975
|
+
declare const defaults: {
|
|
672
976
|
FontFamily: string;
|
|
673
977
|
Graph: {
|
|
674
978
|
BackgroundColor: string;
|
|
979
|
+
DotColor: string;
|
|
675
980
|
};
|
|
676
981
|
Node: {
|
|
677
982
|
FontColor: string;
|
|
@@ -688,6 +993,7 @@ declare const Theme: {
|
|
|
688
993
|
Grabbed: string;
|
|
689
994
|
Selected: string;
|
|
690
995
|
};
|
|
996
|
+
Bevel: BevelColors | null;
|
|
691
997
|
Port: {
|
|
692
998
|
FontColor: string;
|
|
693
999
|
};
|
|
@@ -705,15 +1011,25 @@ declare const Theme: {
|
|
|
705
1011
|
};
|
|
706
1012
|
Widget: {
|
|
707
1013
|
FontColor: string;
|
|
1014
|
+
LabelColor: string;
|
|
1015
|
+
FontSize: number;
|
|
1016
|
+
Padding: number;
|
|
1017
|
+
Gap: number;
|
|
708
1018
|
BackgroundColor: string;
|
|
709
1019
|
Border: {
|
|
710
1020
|
Color: string;
|
|
711
1021
|
Size: number;
|
|
712
1022
|
Radius: number;
|
|
713
1023
|
};
|
|
1024
|
+
Bevel: BevelColors | null;
|
|
714
1025
|
Hover: {
|
|
715
1026
|
BackgroundColor: string;
|
|
716
1027
|
};
|
|
1028
|
+
Input: {
|
|
1029
|
+
BackgroundColor: string;
|
|
1030
|
+
HoverBackgroundColor: string;
|
|
1031
|
+
FontColor: string;
|
|
1032
|
+
};
|
|
717
1033
|
Slider: {
|
|
718
1034
|
FillColor: string;
|
|
719
1035
|
};
|
|
@@ -726,8 +1042,10 @@ declare const Theme: {
|
|
|
726
1042
|
ContextMenu: {
|
|
727
1043
|
BackgroundColor: string;
|
|
728
1044
|
HighlightColor: string;
|
|
1045
|
+
HighlightFontColor: string;
|
|
729
1046
|
FontColor: string;
|
|
730
1047
|
DisabledFontColor: string;
|
|
1048
|
+
BorderRadius: number;
|
|
731
1049
|
};
|
|
732
1050
|
Minimap: {
|
|
733
1051
|
BackgroundColor: string;
|
|
@@ -737,6 +1055,13 @@ declare const Theme: {
|
|
|
737
1055
|
NodeColor: string;
|
|
738
1056
|
ViewportColor: string;
|
|
739
1057
|
};
|
|
1058
|
+
Popup: {
|
|
1059
|
+
BackgroundColor: string;
|
|
1060
|
+
FontColor: string;
|
|
1061
|
+
FontFamily: string;
|
|
1062
|
+
BorderRadius: number;
|
|
1063
|
+
Backdrop: string;
|
|
1064
|
+
};
|
|
740
1065
|
Note: {
|
|
741
1066
|
FontColor: string;
|
|
742
1067
|
FontSize: number;
|
|
@@ -755,232 +1080,66 @@ declare const Theme: {
|
|
|
755
1080
|
};
|
|
756
1081
|
CodeBlock: {
|
|
757
1082
|
BackgroundColor: string;
|
|
1083
|
+
FontColor: string;
|
|
758
1084
|
Padding: number;
|
|
759
1085
|
BorderRadius: number;
|
|
760
1086
|
};
|
|
761
1087
|
};
|
|
762
|
-
};
|
|
1088
|
+
};
|
|
1089
|
+
type ThemeValues = typeof defaults;
|
|
1090
|
+
type DeepPartial<T> = {
|
|
1091
|
+
[K in keyof T]?: T[K] extends object | null ? (null extends T[K] ? T[K] : DeepPartial<T[K]>) : T[K];
|
|
1092
|
+
};
|
|
1093
|
+
type ThemeConfig = DeepPartial<ThemeValues>;
|
|
1094
|
+
declare const DefaultTheme: Readonly<ThemeValues>;
|
|
1095
|
+
declare const Theme: ThemeValues;
|
|
1096
|
+
/**
|
|
1097
|
+
* Replaces the theme: the defaults, with anything in config laid over them.
|
|
1098
|
+
* Everything already on screen picks the change up on its next draw.
|
|
1099
|
+
*/
|
|
1100
|
+
declare function setTheme(config?: ThemeConfig): void;
|
|
1101
|
+
declare function themeVersion(): number;
|
|
1102
|
+
declare function onThemeChange(listener: () => void): () => void;
|
|
763
1103
|
|
|
764
1104
|
declare function requestRender(): void;
|
|
765
1105
|
declare function renderContinuously(): () => void;
|
|
766
1106
|
|
|
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;
|
|
869
|
-
}
|
|
870
|
-
declare class ToggleWidget {
|
|
871
|
-
#private;
|
|
872
|
-
constructor(node: FlowNode, config?: ToggleWidgetConfig);
|
|
873
|
-
Size(): Vector2;
|
|
874
|
-
Draw(ctx: CanvasRenderingContext2D, position: Vector2, scale: number, mousePosition: Vector2 | undefined): Box;
|
|
875
|
-
Toggle(): void;
|
|
876
|
-
Set(value: boolean): void;
|
|
877
|
-
ClickStart(): void;
|
|
878
|
-
ClickEnd(): void;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
interface SliderWidgetConfig {
|
|
882
|
-
property?: string;
|
|
883
|
-
min?: number;
|
|
884
|
-
max?: number;
|
|
885
|
-
value?: number;
|
|
886
|
-
backgroundColor?: string;
|
|
887
|
-
borderColor?: string;
|
|
888
|
-
fillColor?: string;
|
|
889
|
-
textStyle?: TextStyleConfig;
|
|
890
|
-
change?: (newValue: number) => void;
|
|
891
|
-
release?: (newValue: number) => void;
|
|
892
|
-
snapIncrement?: number;
|
|
893
|
-
}
|
|
894
|
-
declare class SliderWidget {
|
|
895
|
-
#private;
|
|
896
|
-
constructor(node: FlowNode, config?: SliderWidgetConfig);
|
|
897
|
-
SetValue(newValue: number): void;
|
|
898
|
-
Size(): Vector2;
|
|
899
|
-
ClickStart(): void;
|
|
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;
|
|
1107
|
+
interface FieldLook {
|
|
1108
|
+
hovered: boolean;
|
|
1109
|
+
pressed?: boolean;
|
|
1110
|
+
/**
|
|
1111
|
+
* Something typed or dragged into, as opposed to something pressed.
|
|
1112
|
+
*/
|
|
1113
|
+
input?: boolean;
|
|
1114
|
+
label?: string;
|
|
1115
|
+
value: string;
|
|
1116
|
+
background?: string;
|
|
1117
|
+
border?: string;
|
|
1118
|
+
textColor?: string;
|
|
909
1119
|
}
|
|
1120
|
+
declare function widgetFont(scale: number): string;
|
|
1121
|
+
declare function drawFieldBox(ctx: CanvasRenderingContext2D, box: Box, scale: number, look: FieldLook): void;
|
|
910
1122
|
/**
|
|
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
|
-
}
|
|
1123
|
+
* A boxed value with an optional label: the label on the left and the value
|
|
1124
|
+
* on the right, or the value alone in the middle.
|
|
965
1125
|
*/
|
|
966
|
-
declare
|
|
967
|
-
|
|
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
|
-
}
|
|
1126
|
+
declare function drawField(ctx: CanvasRenderingContext2D, box: Box, scale: number, look: FieldLook): void;
|
|
1127
|
+
declare function drawFieldText(ctx: CanvasRenderingContext2D, box: Box, scale: number, look: FieldLook): void;
|
|
976
1128
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1129
|
+
interface InPlaceEditConfig {
|
|
1130
|
+
canvas: HTMLCanvasElement | null;
|
|
1131
|
+
/**
|
|
1132
|
+
* Where to sit, in canvas pixels.
|
|
1133
|
+
*/
|
|
1134
|
+
box: Box;
|
|
1135
|
+
scale: number;
|
|
1136
|
+
value: string;
|
|
1137
|
+
onCommit: (text: string) => void;
|
|
983
1138
|
}
|
|
984
|
-
|
|
1139
|
+
/**
|
|
1140
|
+
* Lays a text input over a widget. Enter or clicking away keeps what was
|
|
1141
|
+
* typed; Escape throws it away.
|
|
1142
|
+
*/
|
|
1143
|
+
declare function editInPlace(config: InPlaceEditConfig): HTMLInputElement | null;
|
|
985
1144
|
|
|
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
|
|
1145
|
+
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 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 };
|