@visuallyjs/browser-ui 1.2.7 → 1.2.9
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/js/visuallyjs.browser-ui.cjs.js +70 -70
- package/js/visuallyjs.browser-ui.esm.js +70 -70
- package/package.json +1 -1
- package/types/browser-ui/browser-visuallyjs-instance.d.ts +4 -2
- package/types/browser-ui/components/index.d.ts +1 -0
- package/types/browser-ui/components/inspector/index.d.ts +0 -1
- package/types/browser-ui/components/shape-type-inspector/index.d.ts +1 -0
- package/types/browser-ui/components/{inspector → shape-type-inspector}/shape-type-inspector.d.ts +2 -2
- package/types/browser-ui/plugins/graph-propagation/index.d.ts +26 -0
- package/types/browser-ui/plugins/index.d.ts +1 -0
- package/types/browser-ui/shape-library/shape-library-definitions.d.ts +4 -0
- package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +87 -0
- package/types/browser-ui/surface-renderer/diagrams/diagram.d.ts +1 -0
- package/types/browser-ui/surface-renderer/shape-palette.d.ts +1 -0
- package/types/browser-ui/surface-renderer/surface.d.ts +1 -0
- package/types/browser-ui/svg-element-connector.d.ts +3 -3
- package/types/core/graph-propagation/definitions.d.ts +41 -0
- package/types/core/graph-propagation/engine.d.ts +63 -0
- package/types/core/graph-propagation/index.d.ts +2 -0
- package/types/core/index.d.ts +1 -0
- package/types/ui/common/overlay.d.ts +4 -0
- package/types/ui/core/core.d.ts +21 -2
- package/types/ui/core/defaults.d.ts +12 -0
- package/types/ui/core/overlay/overlay.d.ts +3 -0
- package/types/version.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EVENT_EDGE_CLICK, EVENT_EDGE_CONTEXTMENU, EVENT_EDGE_DBLCLICK, EVENT_EDGE_MOUSEDOWN, EVENT_EDGE_MOUSEOUT, EVENT_EDGE_MOUSEOVER, EVENT_EDGE_MOUSEUP, EVENT_VERTEX_CLICK, EVENT_VERTEX_TAP, EVENT_VERTEX_DBLTAP, EVENT_VERTEX_MOUSEOVER, EVENT_VERTEX_MOUSEOUT, EVENT_VERTEX_MOUSEMOVE, EVENT_VERTEX_MOUSEUP, EVENT_VERTEX_MOUSEDOWN, EVENT_VERTEX_CONTEXTMENU, EVENT_VERTEX_DBLCLICK, Overlay, OverlayPaintParams, LabelOverlay, Connection, ConnectorPath, UICore, TypeDescriptorBase, VertexMapping, GroupMapping, PortMapping, NodeMapping, DragHandler2, ViewportElement, OverlaySpec, Connector, PaintStyle, ZoomToFitOptions, ZoomToFitIfNecessaryOptions, ZoomToElementsOptions, PropertyMapper, EdgePropertyMappings, ViewportGroupElement, ViewportNodeElement } from '../ui';
|
|
1
|
+
import { EVENT_EDGE_CLICK, EVENT_EDGE_CONTEXTMENU, EVENT_EDGE_DBLCLICK, EVENT_EDGE_MOUSEDOWN, EVENT_EDGE_MOUSEOUT, EVENT_EDGE_MOUSEOVER, EVENT_EDGE_MOUSEUP, EVENT_VERTEX_CLICK, EVENT_VERTEX_TAP, EVENT_VERTEX_DBLTAP, EVENT_VERTEX_MOUSEOVER, EVENT_VERTEX_MOUSEOUT, EVENT_VERTEX_MOUSEMOVE, EVENT_VERTEX_MOUSEUP, EVENT_VERTEX_MOUSEDOWN, EVENT_VERTEX_CONTEXTMENU, EVENT_VERTEX_DBLCLICK, Overlay, OverlayPaintParams, LabelOverlay, Connection, ConnectorPath, UICore, TypeDescriptorBase, VertexMapping, GroupMapping, PortMapping, NodeMapping, DragHandler2, ViewportElement, OverlaySpec, Connector, PaintStyle, ZoomToFitOptions, ZoomToFitIfNecessaryOptions, ZoomToElementsOptions, PropertyMapper, EdgePropertyMappings, ViewportGroupElement, ViewportNodeElement, EdgeRenderContext } from '../ui';
|
|
2
2
|
import { VisuallyJSDOMElement } from './element-facade';
|
|
3
3
|
import { VisuallyJsModel, Base, Edge, Group, Node, ObjectData, Port, Vertex, VisuallyJsSelection, DataSource, EVENT_GROUP_MOVE, Grid, GroupRemovedParams, NodeRemovedParams, PointXY, RectangleXY, Size, CustomTagOptions, AbstractLayoutAdapter, LayoutResultSet, EVENT_EDGE_DRAG_START, EVENT_EDGE_DRAG, EVENT_EDGE_DRAG_END, EVENT_EDGE_DRAG_ABORT } from "../core";
|
|
4
4
|
import { TemplateRenderer } from "./browser-ui";
|
|
@@ -145,6 +145,8 @@ export declare abstract class BrowserUI<EVT = any> extends UICore<BrowserElement
|
|
|
145
145
|
$appendOverlayElement(e: BrowserElement, insertAtStart?: boolean): void;
|
|
146
146
|
$appendVertexElement(e: BrowserElement, insertAtStart?: boolean): void;
|
|
147
147
|
$appendEdgeElement(e: BrowserElement, insertAtStart?: boolean): void;
|
|
148
|
+
$createEdgeElementFragment(): DocumentFragment;
|
|
149
|
+
$appendEdgeElementFragment(fragment: unknown): void;
|
|
148
150
|
/**
|
|
149
151
|
*
|
|
150
152
|
* @param el
|
|
@@ -632,7 +634,7 @@ export declare abstract class BrowserUI<EVT = any> extends UICore<BrowserElement
|
|
|
632
634
|
* @param connection
|
|
633
635
|
* @param paintStyle
|
|
634
636
|
*/
|
|
635
|
-
$paintConnector(connection: Connection<BrowserElement>, paintStyle: PaintStyle): void;
|
|
637
|
+
$paintConnector(connection: Connection<BrowserElement>, paintStyle: PaintStyle, edgeRenderContext?: EdgeRenderContext): void;
|
|
636
638
|
/**
|
|
637
639
|
* @internal
|
|
638
640
|
* @param connection
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './shape-type-inspector';
|
package/types/browser-ui/components/{inspector → shape-type-inspector}/shape-type-inspector.d.ts
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ShapePropertyDefinition } from "../../shape-library";
|
|
2
|
-
import { VanillaInspector } from "
|
|
2
|
+
import { VanillaInspector } from "../inspector/vanilla-inspector";
|
|
3
3
|
import { Base } from "../../../core";
|
|
4
|
-
import { VanillaInspectorOptions } from "
|
|
4
|
+
import { VanillaInspectorOptions } from "../inspector/definitions";
|
|
5
5
|
import { BrowserUI } from "../../browser-visuallyjs-instance";
|
|
6
6
|
/**
|
|
7
7
|
* Generates an HTML string in the Recado template format for all configurable
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Calculator, GraphPropagationEngine } from "../../../core/graph-propagation";
|
|
2
|
+
import { BrowserUI } from "../../browser-visuallyjs-instance";
|
|
3
|
+
import { BaseBrowserUIPlugin, BrowserUIPlugin, BrowserUIPluginOptions } from "../browser-ui-plugin";
|
|
4
|
+
/** Plugin type for graph value propagation. */
|
|
5
|
+
export declare const PLUGIN_TYPE_GRAPH_PROPAGATION = "graphPropagation";
|
|
6
|
+
/** Options for the graph propagation plugin. */
|
|
7
|
+
export interface GraphPropagationEnginePluginOptions<ValueType, StateType = unknown> extends BrowserUIPluginOptions {
|
|
8
|
+
/** Calculator functions keyed by node or group type. */
|
|
9
|
+
calculators: Record<string, Calculator<ValueType, StateType>>;
|
|
10
|
+
/** Model property used for propagated values. Defaults to `value`. */
|
|
11
|
+
property?: string;
|
|
12
|
+
/** Model property used for calculated node state. Defaults to `computed`. */
|
|
13
|
+
stateProperty?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Browser UI plugin that runs a GraphPropagationEngine against the UI's model. */
|
|
16
|
+
export declare class GraphPropagationEnginePlugin<ValueType = unknown, StateType = unknown> extends BaseBrowserUIPlugin implements BrowserUIPlugin<GraphPropagationEnginePluginOptions<ValueType, StateType>> {
|
|
17
|
+
static type: string;
|
|
18
|
+
id: string;
|
|
19
|
+
ui: BrowserUI;
|
|
20
|
+
engine: GraphPropagationEngine<ValueType, StateType>;
|
|
21
|
+
initialise(ui: BrowserUI, options: GraphPropagationEnginePluginOptions<ValueType, StateType>): boolean;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
reset(): void;
|
|
24
|
+
}
|
|
25
|
+
/** Gets the graph propagation plugin attached to a UI, if present. */
|
|
26
|
+
export declare function getGraphPropagationPlugin(ui: BrowserUI): GraphPropagationEnginePlugin | null;
|
|
@@ -271,6 +271,10 @@ export interface ShapePropertyDefinition {
|
|
|
271
271
|
* The data type of the property, telling the inspector which UI control to render by default. For properties that include a `values` array (and also properties of type boolean) you can override the choice of UI control via the `editor` option.
|
|
272
272
|
*/
|
|
273
273
|
type: ShapePropertyType;
|
|
274
|
+
/**
|
|
275
|
+
* If true, inspectors display this property's value without an editable control.
|
|
276
|
+
*/
|
|
277
|
+
readOnly?: boolean;
|
|
274
278
|
/**
|
|
275
279
|
* The default value for this property if it hasn't been explicitly set.
|
|
276
280
|
*/
|
|
@@ -2,6 +2,7 @@ import { LabelBackgroundOptions, LabelPosition, ShapeSet } from "../../shape-lib
|
|
|
2
2
|
import { Group, ObjectData, PointXY, Size, Vertex, Node, BeforeConnectInterceptor } from "../../../core";
|
|
3
3
|
import { DiagramCell } from "./diagram-cell";
|
|
4
4
|
import { GridOptions, UIExportOptions, UICoreDefaults, EdgeEventOptions, OverlaySpec, ConnectorSpec, NodeEventOptions, GroupMapping, NodeMapping, AnchorSpec, EdgePropertyMappings, MagnetizeOptions, PaintStyle, OverlayVisibility, EdgeDeleteConfirmationFunction, LabelBackgroundStyle, FontSpec } from "../../../ui";
|
|
5
|
+
import type { BindableViewEvent } from "../../../ui";
|
|
5
6
|
import { SurfaceSaveData } from "../definitions";
|
|
6
7
|
import { BrowserElement } from "../../util";
|
|
7
8
|
import { PaletteMode, AutoEdgeConnectOptions, CanDropOnEdgeFilter } from "../../components/palette/palette-options";
|
|
@@ -11,6 +12,65 @@ import { EdgeSnapOptions, EdgeInputMethod } from "../../edge-handler-base";
|
|
|
11
12
|
import { DiagramActionMediator } from "./mediator";
|
|
12
13
|
import { OnVertexAddedCallback } from "../../definitions";
|
|
13
14
|
import { PreparedShape } from "../shape-palette-options";
|
|
15
|
+
import { GraphPropagationEnginePluginOptions } from "../../plugins";
|
|
16
|
+
import type { BrowserUIModel } from "../../browser-ui";
|
|
17
|
+
import type { BrowserUI } from "../../browser-visuallyjs-instance";
|
|
18
|
+
import type { Diagram } from "./diagram";
|
|
19
|
+
/**
|
|
20
|
+
* Payload passed to a cell template event callback.
|
|
21
|
+
* @group Diagrams
|
|
22
|
+
* @category Events
|
|
23
|
+
*/
|
|
24
|
+
export interface DiagramCellTemplateEventCallbackPayload<E extends Event = Event> {
|
|
25
|
+
/**
|
|
26
|
+
* The diagram cell whose rendered template contained the matching event target.
|
|
27
|
+
*/
|
|
28
|
+
cell: DiagramCell;
|
|
29
|
+
/**
|
|
30
|
+
* The backing vertex for the cell.
|
|
31
|
+
*/
|
|
32
|
+
vertex: Node | Group;
|
|
33
|
+
/**
|
|
34
|
+
* The original browser event.
|
|
35
|
+
*/
|
|
36
|
+
event: E;
|
|
37
|
+
/**
|
|
38
|
+
* The element inside the rendered shape template that matched the configured selector.
|
|
39
|
+
*/
|
|
40
|
+
eventTarget: BrowserElement;
|
|
41
|
+
/**
|
|
42
|
+
* The diagram that owns the cell.
|
|
43
|
+
*/
|
|
44
|
+
diagram: Diagram;
|
|
45
|
+
/**
|
|
46
|
+
* The underlying VisuallyJs model.
|
|
47
|
+
*/
|
|
48
|
+
model: BrowserUIModel;
|
|
49
|
+
/**
|
|
50
|
+
* The UI that rendered the diagram.
|
|
51
|
+
*/
|
|
52
|
+
ui: BrowserUI;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Callback invoked for an event on an element inside a rendered cell template.
|
|
56
|
+
* @group Diagrams
|
|
57
|
+
* @category Events
|
|
58
|
+
*/
|
|
59
|
+
export type DiagramCellTemplateEventCallback<E extends Event = Event> = (p: DiagramCellTemplateEventCallbackPayload<E>) => any;
|
|
60
|
+
/**
|
|
61
|
+
* A map of event names to callbacks for a single selector inside a rendered cell template.
|
|
62
|
+
* @group Diagrams
|
|
63
|
+
* @category Events
|
|
64
|
+
*/
|
|
65
|
+
export type DiagramCellTemplateEventMap = {
|
|
66
|
+
[K in BindableViewEvent]?: DiagramCellTemplateEventCallback;
|
|
67
|
+
} & Record<string, DiagramCellTemplateEventCallback | undefined>;
|
|
68
|
+
/**
|
|
69
|
+
* A map of CSS selectors to event/callback maps for elements inside rendered cell templates.
|
|
70
|
+
* @group Diagrams
|
|
71
|
+
* @category Events
|
|
72
|
+
*/
|
|
73
|
+
export type DiagramCellTemplateEvents = Record<string, DiagramCellTemplateEventMap>;
|
|
14
74
|
/**
|
|
15
75
|
* Options for the {@link Diagram.addLink method}
|
|
16
76
|
* @group Diagrams
|
|
@@ -353,6 +413,26 @@ export interface DiagramOptions {
|
|
|
353
413
|
* Optional event mappings for all cells.
|
|
354
414
|
*/
|
|
355
415
|
events?: NodeEventOptions<any>;
|
|
416
|
+
/**
|
|
417
|
+
* Optional delegated event mappings for elements inside rendered cell templates. Keys are CSS selectors
|
|
418
|
+
* that match elements inside a shape template, and values are maps of event names to callbacks.
|
|
419
|
+
*
|
|
420
|
+
* The callback receives the {@link DiagramCell} associated with the matching element, plus the backing
|
|
421
|
+
* vertex, the original browser event, the matching element, the diagram, the model and the UI.
|
|
422
|
+
*
|
|
423
|
+
* For example:
|
|
424
|
+
*
|
|
425
|
+
* ```ts
|
|
426
|
+
* cells:{
|
|
427
|
+
* templateEvents:{
|
|
428
|
+
* ".delete":{
|
|
429
|
+
* tap:({cell}) => cell.remove()
|
|
430
|
+
* }
|
|
431
|
+
* }
|
|
432
|
+
* }
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
templateEvents?: DiagramCellTemplateEvents;
|
|
356
436
|
/**
|
|
357
437
|
* Optional behaviour mapping for groups in the diagram. For many setups, you won't need to use this, as the other options in the `cells` config are quite extensive and can be used to configure many things. For some setups you may need to provide config for group behaviour, such as whether or not vertices can be dragged in/out, whether the group should be resizable, etc. You can also provide group-specific event mappings here. Any `events` you provide here will be merged with the internal event registrations made by the diagram, but if you provide a `template` it will be ignored.
|
|
358
438
|
*/
|
|
@@ -366,6 +446,9 @@ export interface DiagramOptions {
|
|
|
366
446
|
* Optional mapping for nodes in the diagram. For many setups, you won't need to use this, as the other options in the `cells` config are quite extensive and can be used to configure many things. Any `events` you provide here will be merged with the internal event registrations made by the diagram, but if you provide a `template` it will be ignored.
|
|
367
447
|
*/
|
|
368
448
|
nodes?: DiagramNodeMapping;
|
|
449
|
+
/**
|
|
450
|
+
* Options controlling how resize functions.
|
|
451
|
+
*/
|
|
369
452
|
resize?: {
|
|
370
453
|
/**
|
|
371
454
|
* Width/height to use for resize handles. Defaults to 20 pixels.
|
|
@@ -483,6 +566,10 @@ export interface DiagramOptions {
|
|
|
483
566
|
* Controls whether line crossings are shown by a visual cue. Defaults to false. You can either supply a boolean and have the panbuttons plugin initialize with its default settings, or supply your own settings.
|
|
484
567
|
*/
|
|
485
568
|
lineCrossings?: boolean | LineCrossingsPluginOptions;
|
|
569
|
+
/**
|
|
570
|
+
* If provided, a graph propagation engine will be used to propagate changes to the graph.
|
|
571
|
+
*/
|
|
572
|
+
graphPropagation?: GraphPropagationEnginePluginOptions<any>;
|
|
486
573
|
}
|
|
487
574
|
/**
|
|
488
575
|
* Options for a palette for a diagram.
|
|
@@ -15,6 +15,7 @@ export declare const ATTRIBUTE_DATA_SHAPE_ID = "data-shape-id";
|
|
|
15
15
|
*/
|
|
16
16
|
export declare class ShapePalette<T extends ObjectData> {
|
|
17
17
|
private ui;
|
|
18
|
+
_$_iconTemplateEngine: BrowserUiRecado;
|
|
18
19
|
_$_templateEngine: BrowserUiRecado;
|
|
19
20
|
_$_palette: Palette;
|
|
20
21
|
_$_userDataGenerator: DataGeneratorFunction;
|
|
@@ -168,6 +168,7 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
|
|
|
168
168
|
$appendOverlayElement(e: BrowserElement, insertAtStart?: boolean): void;
|
|
169
169
|
$appendVertexElement(e: BrowserElement, insertAtStart?: boolean): void;
|
|
170
170
|
$appendEdgeElement(e: BrowserElement, insertAtStart?: boolean): void;
|
|
171
|
+
$appendEdgeElementFragment(fragment: unknown): void;
|
|
171
172
|
/**
|
|
172
173
|
* Internal callback to register an edge path editor and ensure that the various editors are initialized.
|
|
173
174
|
* @param editor
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BrowserUI } from "./browser-visuallyjs-instance";
|
|
2
|
-
import { PaintStyle, Connector, Connection } from "../ui";
|
|
3
|
-
export declare function paintSvgConnector(instance: BrowserUI, connection: Connection<any>, paintStyle: PaintStyle): void;
|
|
2
|
+
import { PaintStyle, Connector, Connection, EdgeRenderContext } from "../ui";
|
|
3
|
+
export declare function paintSvgConnector(instance: BrowserUI, connection: Connection<any>, paintStyle: PaintStyle, edgeRenderContext?: EdgeRenderContext): void;
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
@@ -13,4 +13,4 @@ export interface SvgConnector extends Connector {
|
|
|
13
13
|
targetZone: SVGElement;
|
|
14
14
|
gradient?: SVGLinearGradientElement;
|
|
15
15
|
}
|
|
16
|
-
export declare function getConnectorElement(instance: BrowserUI, connection: Connection<any
|
|
16
|
+
export declare function getConnectorElement(instance: BrowserUI, connection: Connection<any>, edgeFragment?: DocumentFragment): SVGElement;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Node } from "../model/graph";
|
|
2
|
+
/**
|
|
3
|
+
* Terminal id used when an edge connects directly to a node or group instead of a named port.
|
|
4
|
+
* For example, junctions and probes use this as their implicit input/output terminal.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_TERMINAL = "default";
|
|
7
|
+
/**
|
|
8
|
+
* Result returned by a node calculator.
|
|
9
|
+
* @typeParam ValueType Defines the type of the node's output values.
|
|
10
|
+
* @typeParam StateType Defines the type of the node's internal state.
|
|
11
|
+
*/
|
|
12
|
+
export type NodeEvaluation<ValueType, StateType = unknown> = {
|
|
13
|
+
/**
|
|
14
|
+
* Values made available to downstream edges, keyed by terminal id. Keys are port ids such as"out"`, or `DEFAULT_TERMINAL` for direct node connections
|
|
15
|
+
*/
|
|
16
|
+
outputs?: Record<string, ValueType | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Derived node state (such as display text, validation details, or cached intermediate results) written to the node's configured state property.
|
|
19
|
+
*/
|
|
20
|
+
state?: StateType;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Helper API passed to calculators so they can read upstream values without knowing graph details.
|
|
24
|
+
* @typeParam ValueType Defines the type of the node's output values.
|
|
25
|
+
*/
|
|
26
|
+
export interface EvaluationContext<ValueType> {
|
|
27
|
+
/**
|
|
28
|
+
* Reads the value connected to one input terminal. Omit `terminalId` or pass `DEFAULT_TERMINAL` for direct node-body connections. Otherwise terminalId is assumed to map to a port ID on the node.
|
|
29
|
+
*/
|
|
30
|
+
input: (terminalId?: string) => ValueType | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Reads named input terminals in order. When omitted, reads every edge connected directly to the node body, in edge order.
|
|
33
|
+
*/
|
|
34
|
+
inputs: (terminalIds?: string[]) => Array<ValueType | undefined>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Evaluates a node from its current upstream inputs - the function has access to the `input(...)` and `inputs(..)` methods on the evaluation context that is passed in, for resolving the input values on the node.
|
|
38
|
+
* @typeParam ValueType Defines the type of the node's output values.
|
|
39
|
+
* @typeParam StateType Defines the type of the node's internal state.
|
|
40
|
+
*/
|
|
41
|
+
export type Calculator<ValueType, StateType = unknown> = (node: Node, context: EvaluationContext<ValueType>) => NodeEvaluation<ValueType, StateType> | undefined;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { VisuallyJsModel } from "../toolkit";
|
|
2
|
+
import { Calculator } from "./definitions";
|
|
3
|
+
/**
|
|
4
|
+
* Full calculation output before it is written back to the model.
|
|
5
|
+
*/
|
|
6
|
+
type CalculationResult<ValueType, StateType> = {
|
|
7
|
+
/** Propagated values keyed by concrete vertex id, for example `nodeId.out`. */
|
|
8
|
+
values: Map<string, ValueType>;
|
|
9
|
+
/** Computed node states keyed by node or group id. */
|
|
10
|
+
states: Map<string, StateType>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Propagates computed values through a VisuallyJS graph.
|
|
14
|
+
*
|
|
15
|
+
* The engine treats each node or group as the unit of computation. A calculator is registered per
|
|
16
|
+
* vertex type, reads upstream values through an `EvaluationContext`, and returns output terminal
|
|
17
|
+
* values plus optional internal state for that vertex.
|
|
18
|
+
*
|
|
19
|
+
* Output keys are terminal ids: use a port id for named ports, or `DEFAULT_TERMINAL` for edges
|
|
20
|
+
* connected directly to the node/group body. During propagation, the engine maps those terminal ids
|
|
21
|
+
* back to concrete graph vertices and writes propagated values to `property` on target vertices.
|
|
22
|
+
*
|
|
23
|
+
* Calculator `state` is not propagated across edges. It is written to the owning node/group under
|
|
24
|
+
* `stateProperty`, making it suitable for display data, validation results, summaries, or cached
|
|
25
|
+
* derived values.
|
|
26
|
+
*
|
|
27
|
+
* To integrate, define calculators keyed by node/group type, construct the engine with a
|
|
28
|
+
* `VisuallyJsModel`, and read propagated values from vertices using `property` and computed state
|
|
29
|
+
* from nodes/groups using `stateProperty`.
|
|
30
|
+
*/
|
|
31
|
+
export declare class GraphPropagationEngine<ValueType, StateType = unknown> {
|
|
32
|
+
private model;
|
|
33
|
+
private calculators;
|
|
34
|
+
private _suspended;
|
|
35
|
+
private _property;
|
|
36
|
+
private _stateProperty;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a propagation engine and binds it to model update events.
|
|
39
|
+
*
|
|
40
|
+
* Edge additions/removals and data updates on connected vertices trigger recalculation on the
|
|
41
|
+
* next animation frame. Updates produced by the engine are applied in one model transaction.
|
|
42
|
+
*
|
|
43
|
+
* @param model Model whose nodes, groups, ports, and edges should participate in propagation.
|
|
44
|
+
* @param calculators Calculator functions keyed by node/group type.
|
|
45
|
+
* @param property Data property used for propagated vertex values. Defaults to `"value"`.
|
|
46
|
+
* @param stateProperty Data property used for computed node/group state. Defaults to `"computed"`.
|
|
47
|
+
*/
|
|
48
|
+
constructor(model: VisuallyJsModel, calculators: Record<string, Calculator<ValueType, StateType>>, property?: string, stateProperty?: string);
|
|
49
|
+
/**
|
|
50
|
+
* Runs propagation immediately and writes the result back to the model.
|
|
51
|
+
*
|
|
52
|
+
* `knownValues` can seed the value cache for this run. Keys must be concrete vertex ids, such
|
|
53
|
+
* as a node id or full port id. This is useful when an edited source value is already known and
|
|
54
|
+
* should be used before the model has been fully re-read.
|
|
55
|
+
*/
|
|
56
|
+
calculate(knownValues?: Record<string, ValueType>): CalculationResult<ValueType, StateType>;
|
|
57
|
+
/**
|
|
58
|
+
* The main entry point for the calculation. Iterates through all nodes, resolves their new state, and updates the model if the state has changed.
|
|
59
|
+
*/
|
|
60
|
+
private _calculate;
|
|
61
|
+
private _apply;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
package/types/core/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './model/path';
|
|
|
8
8
|
export * from './model/anchor';
|
|
9
9
|
export * from './datamodel/data-model';
|
|
10
10
|
export * from './datamodel/vertex-definition';
|
|
11
|
+
export * from './graph-propagation';
|
|
11
12
|
export * from './layout';
|
|
12
13
|
export * from "./geom";
|
|
13
14
|
export * from './color-generator';
|
|
@@ -20,6 +20,10 @@ export interface OverlayOptions extends Record<string, any> {
|
|
|
20
20
|
* Defaults to 0.5. See docs.
|
|
21
21
|
*/
|
|
22
22
|
location?: number;
|
|
23
|
+
/** Minimum zoom at which this overlay is visible. Defaults to 0. Null or a negative value disables this bound. */
|
|
24
|
+
minZoom?: number | null;
|
|
25
|
+
/** Maximum zoom at which this overlay is visible. Defaults to Infinity. Null or a negative value disables this bound. */
|
|
26
|
+
maxZoom?: number | null;
|
|
23
27
|
/**
|
|
24
28
|
* 1 to point forwards (the default), -1 to point backwards. Only taken into consideration in some overlay types.
|
|
25
29
|
*/
|
package/types/ui/core/core.d.ts
CHANGED
|
@@ -103,6 +103,13 @@ export interface LineStyle {
|
|
|
103
103
|
*/
|
|
104
104
|
fontFamily?: string;
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Used by the bulk loader to provide a fragment to which edge elements are appended, rather than the DOM itself. At the end of a bulk load the entire fragment is appended. This provides a performance boost.
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
export interface EdgeRenderContext {
|
|
111
|
+
edgeElementFragment?: unknown;
|
|
112
|
+
}
|
|
106
113
|
/**
|
|
107
114
|
* Base UI for apps and diagrams.
|
|
108
115
|
* @internal
|
|
@@ -176,6 +183,12 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
|
|
|
176
183
|
def: any;
|
|
177
184
|
eventInfo: any;
|
|
178
185
|
}>;
|
|
186
|
+
/**
|
|
187
|
+
* Measurements that will need to be made once the bulk load completes
|
|
188
|
+
* @private
|
|
189
|
+
*/
|
|
190
|
+
private _pendingInitialSizeMeasurements;
|
|
191
|
+
private _deferredInitialVertexRenderedEvents;
|
|
179
192
|
/**
|
|
180
193
|
* Map of group member added events which have not yet been processed, due to the group in question not having yet been rendered at the time the event was fired. The contents of this map are processed whenever a new group is added. Users of the API should not modify the contents of this map.
|
|
181
194
|
* @internal
|
|
@@ -189,6 +202,8 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
|
|
|
189
202
|
$_useModelForSizes: boolean;
|
|
190
203
|
$_writeSizeToElements: boolean;
|
|
191
204
|
$_useModelForPositions: boolean;
|
|
205
|
+
$_batchInitialElementMeasurements: boolean;
|
|
206
|
+
$_batchEdgeInsertions: boolean;
|
|
192
207
|
readonly $_allowUnattachedEdges: boolean;
|
|
193
208
|
readonly $_edgesDetachable: boolean;
|
|
194
209
|
readonly $_reattachEdges: boolean;
|
|
@@ -352,6 +367,7 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
|
|
|
352
367
|
*/
|
|
353
368
|
$dataAppendStart(): void;
|
|
354
369
|
$dataAppendEnd(noDataWasAppended?: boolean): void;
|
|
370
|
+
private $measureInitialElementSizes;
|
|
355
371
|
/**
|
|
356
372
|
This method needs to be updated to work with _setDataLoading to ensure that all vertices for some batch load have been rendered before the stuff here happens. Vertices might be painted async by the underlying template engine, such as React 18 or Vue 3.
|
|
357
373
|
* @param noDataWasLoaded
|
|
@@ -546,7 +562,7 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
|
|
|
546
562
|
/**
|
|
547
563
|
* @internal
|
|
548
564
|
*/
|
|
549
|
-
$redrawEveryConnection(): void;
|
|
565
|
+
$redrawEveryConnection(timestamp?: string, edgeRenderContext?: EdgeRenderContext): void;
|
|
550
566
|
private $redrawConnectionsForViewportElement;
|
|
551
567
|
private _repaintConnections;
|
|
552
568
|
/**
|
|
@@ -963,6 +979,7 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
|
|
|
963
979
|
$paintConnection(connection: Connection<EL>, params?: {
|
|
964
980
|
timestamp?: string;
|
|
965
981
|
fireEvent?: boolean;
|
|
982
|
+
edgeRenderContext?: EdgeRenderContext;
|
|
966
983
|
}): void;
|
|
967
984
|
/**
|
|
968
985
|
* Adds an overlay to the given component, repainting the UI as necessary.
|
|
@@ -1169,6 +1186,8 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
|
|
|
1169
1186
|
* @internal
|
|
1170
1187
|
*/
|
|
1171
1188
|
abstract $appendEdgeElement(e: EL, insertAtStart?: boolean): void;
|
|
1189
|
+
abstract $createEdgeElementFragment(): unknown;
|
|
1190
|
+
abstract $appendEdgeElementFragment(fragment: unknown): void;
|
|
1172
1191
|
abstract $setElementVisible(el: EL, visible: boolean): void;
|
|
1173
1192
|
/**
|
|
1174
1193
|
* Sets the size of the element in the UI. The details of this are specific to the concrete subclass. No model edits occur as a result of this method.
|
|
@@ -1754,7 +1773,7 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
|
|
|
1754
1773
|
* @param paintStyle
|
|
1755
1774
|
* @param extents
|
|
1756
1775
|
*/
|
|
1757
|
-
abstract $paintConnector(connection: Connection<any>, paintStyle: PaintStyle): void;
|
|
1776
|
+
abstract $paintConnector(connection: Connection<any>, paintStyle: PaintStyle, edgeRenderContext?: EdgeRenderContext): void;
|
|
1758
1777
|
/**
|
|
1759
1778
|
* @internal
|
|
1760
1779
|
* @param connection
|
|
@@ -150,6 +150,12 @@ export interface UIEdgeOptions {
|
|
|
150
150
|
* The default color to paint a connector's outline path. Defaults to `"transparent"`. Can be overridden on a per-edge basis via the `outlineColor` setting.
|
|
151
151
|
*/
|
|
152
152
|
outlineColor?: string;
|
|
153
|
+
/**
|
|
154
|
+
* defaults to true, connector elements created during the final initial render pass are appended to the DOM in a single batch. only exposing this option in case a major regression is detected and the functionality needs to be switched off. and marking internal so it's a need to know.
|
|
155
|
+
* @internal
|
|
156
|
+
* @deprecated
|
|
157
|
+
*/
|
|
158
|
+
batchEdgeInsertions?: boolean;
|
|
153
159
|
}
|
|
154
160
|
/**
|
|
155
161
|
* Base options for a renderer.
|
|
@@ -205,6 +211,12 @@ export interface UICoreOptions<E, O extends UICoreDefaults> {
|
|
|
205
211
|
* Defaults to false. When true, newly created nodes are sized according to values in their backing data, using the modelWidthAttribute and modelHeightAttribute as keys. NOTE: when this flag is set, VisuallyJs will write the size onto each element as it is created. Depending on your app, you may not need it to do this - if you know your node sizes are set via css, for instance, or you know the template rendering your vertices writes out the size in an element's style or an SVG element's width/height. If that is the case, you can set {@link writeSizeToElements} to be false, and you'll get a performance boost.
|
|
206
212
|
*/
|
|
207
213
|
useModelForSizes?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Defaults to true. During initial data rendering, append vertices first and measure their DOM sizes together before layout. This preserves DOM-derived sizes while avoiding a layout read after each append. only exposing this option in case a major regression is detected and the functionality needs to be switched off. and marking internal so it's a need to know.
|
|
216
|
+
* @internal
|
|
217
|
+
* @deprecated
|
|
218
|
+
*/
|
|
219
|
+
batchInitialElementMeasurements?: boolean;
|
|
208
220
|
/**
|
|
209
221
|
* When {@link useModelForSizes} is true, VisuallyJs will write out the model size onto each element rendered. But if you know your node sizes are set via css, or you know the template rendering your vertices writes out the size in an element's style or an SVG element's width/height, you can instruct VisuallyJs not to bother writing out the size to the element itself, by setting this flag to true (the default is false). This can provide a performance boost.
|
|
210
222
|
*/
|
|
@@ -70,6 +70,8 @@ export declare abstract class Overlay<EL, O extends OverlayOptions = OverlayOpti
|
|
|
70
70
|
_visibility: OverlayVisibility;
|
|
71
71
|
visible: boolean;
|
|
72
72
|
location: number;
|
|
73
|
+
minZoom: number;
|
|
74
|
+
maxZoom: number;
|
|
73
75
|
events: Record<string, (value: any, event?: any) => any>;
|
|
74
76
|
attributes: Record<string, string>;
|
|
75
77
|
/**
|
|
@@ -83,6 +85,7 @@ export declare abstract class Overlay<EL, O extends OverlayOptions = OverlayOpti
|
|
|
83
85
|
ignoreTypes: boolean;
|
|
84
86
|
constructor(connection: Connection<EL>, p: O);
|
|
85
87
|
abstract updateFrom(opts: O, context: ObjectData): void;
|
|
88
|
+
setZoomRange(options: OverlayOptions): void;
|
|
86
89
|
abstract isSimpleShape: boolean;
|
|
87
90
|
}
|
|
88
91
|
/**
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.2.
|
|
1
|
+
export declare const VERSION = "1.2.9";
|