@joint/core 4.2.0-alpha.0 → 4.2.0-beta.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.
Files changed (54) hide show
  1. package/README.md +3 -1
  2. package/dist/geometry.js +2 -2
  3. package/dist/geometry.min.js +3 -3
  4. package/dist/joint.d.ts +595 -198
  5. package/dist/joint.js +3895 -1304
  6. package/dist/joint.min.js +3 -3
  7. package/dist/joint.nowrap.js +3895 -1304
  8. package/dist/joint.nowrap.min.js +3 -3
  9. package/dist/vectorizer.js +21 -8
  10. package/dist/vectorizer.min.js +3 -3
  11. package/dist/version.mjs +1 -1
  12. package/package.json +13 -13
  13. package/src/V/index.mjs +20 -5
  14. package/src/alg/Deque.mjs +126 -0
  15. package/src/cellTools/Boundary.mjs +15 -13
  16. package/src/cellTools/Button.mjs +7 -5
  17. package/src/cellTools/Control.mjs +37 -14
  18. package/src/cellTools/HoverConnect.mjs +5 -1
  19. package/src/cellTools/helpers.mjs +44 -3
  20. package/src/config/index.mjs +11 -1
  21. package/src/dia/Cell.mjs +96 -83
  22. package/src/dia/CellCollection.mjs +136 -0
  23. package/src/dia/CellView.mjs +6 -0
  24. package/src/dia/Element.mjs +6 -5
  25. package/src/dia/ElementView.mjs +2 -1
  26. package/src/dia/Graph.mjs +610 -317
  27. package/src/dia/GraphLayer.mjs +53 -0
  28. package/src/dia/GraphLayerCollection.mjs +313 -0
  29. package/src/dia/GraphLayerView.mjs +128 -0
  30. package/src/dia/GraphLayersController.mjs +166 -0
  31. package/src/dia/GraphTopologyIndex.mjs +222 -0
  32. package/src/dia/{layers/GridLayer.mjs → GridLayerView.mjs} +23 -16
  33. package/src/dia/HighlighterView.mjs +22 -0
  34. package/src/dia/{PaperLayer.mjs → LayerView.mjs} +52 -17
  35. package/src/dia/LegacyGraphLayerView.mjs +14 -0
  36. package/src/dia/LinkView.mjs +118 -98
  37. package/src/dia/Paper.mjs +1441 -620
  38. package/src/dia/ToolView.mjs +4 -0
  39. package/src/dia/ToolsView.mjs +14 -5
  40. package/src/dia/attributes/text.mjs +4 -2
  41. package/src/dia/index.mjs +6 -1
  42. package/src/dia/ports.mjs +213 -84
  43. package/src/dia/symbols.mjs +24 -0
  44. package/src/elementTools/HoverConnect.mjs +14 -8
  45. package/src/env/index.mjs +6 -3
  46. package/src/layout/ports/port.mjs +30 -15
  47. package/src/layout/ports/portLabel.mjs +1 -1
  48. package/src/mvc/Collection.mjs +19 -19
  49. package/src/mvc/Model.mjs +13 -10
  50. package/src/mvc/View.mjs +4 -0
  51. package/src/mvc/ViewBase.mjs +1 -1
  52. package/types/geometry.d.ts +64 -60
  53. package/types/joint.d.ts +520 -137
  54. package/types/vectorizer.d.ts +11 -1
package/dist/joint.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- /*! JointJS v4.2.0-alpha.0 (2025-06-16) - JavaScript diagramming library
2
-
1
+ /*! JointJS v4.2.0-beta.1 (2025-11-03) - JavaScript diagramming library
3
2
 
4
3
  This Source Code Form is subject to the terms of the Mozilla Public
5
4
  License, v. 2.0. If a copy of the MPL was not distributed with this
6
5
  file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
6
  */
7
+
8
8
  // Definitions by:
9
9
  // Aidan Reel <http://github.com/areel>,
10
10
  // David Durman <http://github.com/DavidDurman>,
@@ -38,7 +38,8 @@ export declare namespace anchors {
38
38
  }
39
39
 
40
40
  export interface MidSideAnchorArguments extends RotateAnchorArguments, PaddingAnchorArguments {
41
-
41
+ mode?: 'prefer-horizontal' | 'prefer-vertical' | 'horizontal' | 'vertical' | 'auto';
42
+ preferenceThreshold?: dia.Sides;
42
43
  }
43
44
 
44
45
  export interface ModelCenterAnchorArguments {
@@ -428,6 +429,9 @@ export declare namespace config {
428
429
  var classNamePrefix: string;
429
430
  var defaultTheme: string;
430
431
  var doubleTapInterval: number;
432
+ var cellMergeStrategy: util.MergeCustomizer | null;
433
+ var cellDefaultsMergeStrategy: util.MergeCustomizer | null;
434
+ var layerAttribute: string;
431
435
  }
432
436
 
433
437
  export declare namespace connectionPoints {
@@ -758,6 +762,89 @@ export declare namespace dia {
758
762
  util.filter.FilterJSON<'brightness'> |
759
763
  util.filter.FilterJSON<'contrast'>;
760
764
 
765
+ export class CellCollection<C extends Cell = Cell> extends mvc.Collection<C> {
766
+
767
+ cellNamespace: any;
768
+ layer: GraphLayer;
769
+
770
+ minZIndex(): number;
771
+
772
+ maxZIndex(): number;
773
+ }
774
+
775
+ export class GraphLayerCollection<L extends GraphLayer = GraphLayer> extends mvc.Collection<L> {
776
+
777
+ cellNamespace: any;
778
+ layerNamespace: any;
779
+ graph: Graph;
780
+
781
+ insert(layer: Graph.LayerInit, beforeId: GraphLayer.ID | null, opt?: ObjectHash): void;
782
+
783
+ getCell(cellRef: Graph.CellRef): Cell | undefined;
784
+
785
+ getCells(): Cell[];
786
+
787
+ removeCell(cell: Cell, opt?: ObjectHash): void;
788
+
789
+ moveCellBetweenLayers(cell: Cell, targetLayerId: GraphLayer.ID, opt?: ObjectHash): void;
790
+
791
+ addCellToLayer(cell: Cell, layerId: GraphLayer.ID, opt?: ObjectHash): void;
792
+ }
793
+
794
+ export class GraphLayersController extends mvc.Listener<[]> {
795
+
796
+ graph: Graph;
797
+
798
+ layerCollection: GraphLayerCollection;
799
+
800
+ startListening(): void;
801
+
802
+ protected onCellChange(cell: Cell, opt: ObjectHash): void;
803
+
804
+ protected onCellRemove(cell: Cell, opt: ObjectHash): void;
805
+
806
+ protected onLayerCollectionEvent(eventName: string, ...args: any[]): void;
807
+
808
+ protected forwardLayerEvent(...args: any[]): void;
809
+
810
+ protected forwardCellEvent(...args: any[]): void;
811
+
812
+ protected forwardCellCollectionEvent(...args: any[]): void;
813
+
814
+ protected forwardLayerCollectionEvent(...args: any[]): void;
815
+ }
816
+
817
+ export class GraphTopologyIndex extends mvc.Listener<[]> {
818
+
819
+ layerCollection: GraphLayerCollection;
820
+
821
+ startListening(): void;
822
+
823
+ getOutboundEdges(id: Cell.ID): { [edgeId: string]: true };
824
+
825
+ getInboundEdges(id: Cell.ID): { [edgeId: string]: true };
826
+
827
+ getSinkNodes(): string[];
828
+
829
+ getSourceNodes(): string[];
830
+
831
+ isSinkNode(id: Cell.ID): boolean;
832
+
833
+ isSourceNode(id: Cell.ID): boolean;
834
+
835
+ protected initializeIndex(): void;
836
+
837
+ protected _restructureOnReset(): void;
838
+
839
+ protected _restructureOnAdd(cell: Cell): void;
840
+
841
+ protected _restructureOnRemove(cell: Cell): void;
842
+
843
+ protected _restructureOnChangeSource(cell: Cell): void;
844
+
845
+ protected _restructureOnChangeTarget(cell: Cell): void;
846
+ }
847
+
761
848
  export namespace Graph {
762
849
 
763
850
  export interface Options {
@@ -781,35 +868,100 @@ export declare namespace dia {
781
868
  strict?: boolean;
782
869
  }
783
870
 
871
+ export interface SyncCellOptions extends Options {
872
+ remove?: boolean;
873
+ }
874
+
875
+ export interface RemoveCellOptions extends Options {
876
+ disconnectLinks?: boolean;
877
+ replace?: boolean;
878
+ clear?: boolean;
879
+ }
880
+
784
881
  export type SearchByKey = 'bbox' | PositionName;
785
882
 
786
883
  export interface FindUnderElementOptions extends FindInAreaOptions, FindAtPointOptions {
787
884
  searchBy?: SearchByKey;
788
885
  }
789
886
 
790
- export class Cells extends mvc.Collection<Cell> {
791
- graph: Graph;
792
- cellNamespace: any;
793
- }
887
+ export type Cells = CellCollection;
888
+
889
+ export type CellInit = Cell | Cell.JSON;
890
+
891
+ export type CellRef = Cell | Cell.ID;
892
+
893
+ export type LayerInit = GraphLayer | GraphLayer.Attributes;
894
+
895
+ export type LayerRef = GraphLayer | GraphLayer.ID;
794
896
 
795
897
  export interface Attributes {
796
- cells?: Cells;
898
+ /** @deprecated use cellsCollection property **/
899
+ cells?: CellCollection;
797
900
  [key: string]: any;
798
901
  }
902
+
903
+ export interface JSON {
904
+ cells: Array<Cell.JSON>;
905
+ layers?: Array<GraphLayer.Attributes>;
906
+ defaultLayer?: string;
907
+ [key: string]: any;
908
+ }
909
+
910
+ export interface InsertLayerOptions extends Options {
911
+ before?: GraphLayer.ID | null;
912
+ index?: number;
913
+ }
799
914
  }
800
915
 
801
916
  export class Graph<A extends ObjectHash = Graph.Attributes, S = dia.ModelSetOptions> extends mvc.Model<A, S> {
802
917
 
803
- constructor(attributes?: Graph.Attributes, opt?: { cellNamespace?: any, cellModel?: typeof Cell });
918
+ layerCollection: GraphLayerCollection;
919
+
920
+ defaultLayerId: GraphLayer.ID;
921
+
922
+ layersController: GraphLayersController;
923
+
924
+ topologyIndex: GraphTopologyIndex;
925
+
926
+ constructor(attributes?: Graph.Attributes, opt?: {
927
+ cellNamespace?: any,
928
+ layerNamespace?: any,
929
+ /** @deprecated use cellNamespace instead */
930
+ cellModel?: typeof Cell
931
+ });
932
+
933
+ addCell(cell: Graph.CellInit, opt?: CollectionAddOptions): this;
934
+ addCell(cell: Array<Graph.CellInit>, opt?: CollectionAddOptions): this;
935
+
936
+ addCells(cells: Array<Graph.CellInit>, opt?: CollectionAddOptions): this;
937
+
938
+ removeCell(cell: Graph.CellRef, opt?: Graph.RemoveCellOptions): void;
939
+
940
+ removeCells(cells: Array<Graph.CellRef>, opt?: Graph.RemoveCellOptions): this;
804
941
 
805
- addCell(cell: Cell.JSON | Cell, opt?: CollectionAddOptions): this;
806
- addCell(cell: Array<Cell | Cell.JSON>, opt?: CollectionAddOptions): this;
942
+ resetCells(cells: Array<Graph.CellInit>, opt?: Graph.Options): this;
807
943
 
808
- addCells(cells: Array<Cell | Cell.JSON>, opt?: CollectionAddOptions): this;
944
+ syncCells(cells: Array<Graph.CellInit>, opt?: Graph.SyncCellOptions): void;
809
945
 
810
- resetCells(cells: Array<Cell | Cell.JSON>, opt?: Graph.Options): this;
946
+ addLayer(layerInit: Graph.LayerInit, opt?: Graph.InsertLayerOptions): void;
811
947
 
812
- getCell(id: Cell.ID | Cell): Cell;
948
+ moveLayer(layerRef: Graph.LayerRef, opt?: Graph.InsertLayerOptions): void;
949
+
950
+ removeLayer(layerRef: Graph.LayerRef, opt?: Graph.Options): void;
951
+
952
+ getDefaultLayer(): GraphLayer;
953
+
954
+ setDefaultLayer(id: string, opt?: Graph.Options): void;
955
+
956
+ getLayer(id: string): GraphLayer;
957
+
958
+ hasLayer(id: string): boolean;
959
+
960
+ getLayers(): GraphLayer[];
961
+
962
+ getCellLayerId(cell: Graph.CellRef): GraphLayer.ID;
963
+
964
+ getCell(id: Graph.CellRef): Cell;
813
965
 
814
966
  getElements(): Element[];
815
967
 
@@ -817,15 +969,15 @@ export declare namespace dia {
817
969
 
818
970
  getCells(): Cell[];
819
971
 
820
- getFirstCell(): Cell | undefined;
972
+ getFirstCell(layerId?: string): Cell | undefined;
821
973
 
822
- getLastCell(): Cell | undefined;
974
+ getLastCell(layerId?: string): Cell | undefined;
823
975
 
824
976
  getConnectedLinks(cell: Cell, opt?: Graph.ConnectionOptions): Link[];
825
977
 
826
978
  disconnectLinks(cell: Cell, opt?: S): void;
827
979
 
828
- removeLinks(cell: Cell, opt?: Cell.DisconnectableOptions): void;
980
+ removeLinks(cell: Graph.CellRef, opt?: Graph.RemoveCellOptions): void;
829
981
 
830
982
  translate(tx: number, ty?: number, opt?: Element.TranslateOptions): this;
831
983
 
@@ -897,6 +1049,12 @@ export declare namespace dia {
897
1049
 
898
1050
  protected _filterCellsUnderElement(cells: Cell[], element: Element, opt: Graph.FindUnderElementOptions): Cell[];
899
1051
 
1052
+ protected _syncCell(cellInit: Graph.CellInit, opt?: Graph.Options): void;
1053
+
1054
+ protected _replaceCell(currentCell: Cell, newCellInit: Graph.CellInit, opt?: Graph.Options): void;
1055
+
1056
+ protected _resetLayers(layers: Array<Graph.LayerInit>, defaultLayerId: GraphLayer.ID | null, opt?: Graph.Options): this;
1057
+
900
1058
  /** @deprecated use `findElementsAtPoint` instead */
901
1059
  findModelsFromPoint(p: Point): Element[];
902
1060
 
@@ -912,11 +1070,9 @@ export declare namespace dia {
912
1070
 
913
1071
  hasActiveBatch(name?: string | string[]): boolean;
914
1072
 
915
- maxZIndex(): number;
916
-
917
- minZIndex(): number;
1073
+ maxZIndex(layerId?: GraphLayer.ID): number;
918
1074
 
919
- removeCells(cells: Cell[], opt?: Cell.DisconnectableOptions): this;
1075
+ minZIndex(layerId?: GraphLayer.ID): number;
920
1076
 
921
1077
  transferCellEmbeds(sourceCell: Cell, targetCell: Cell, opt?: S): void;
922
1078
 
@@ -975,9 +1131,7 @@ export declare namespace dia {
975
1131
  deep?: T;
976
1132
  }
977
1133
 
978
- export interface DisconnectableOptions extends Options {
979
- disconnectLinks?: boolean;
980
- }
1134
+ export type DisconnectableOptions = Graph.RemoveCellOptions;
981
1135
 
982
1136
  export interface GetEmbeddedCellsOptions extends EmbeddableOptions {
983
1137
  breadthFirst?: boolean;
@@ -1057,9 +1211,9 @@ export declare namespace dia {
1057
1211
 
1058
1212
  protected generateId(): string | number;
1059
1213
 
1060
- protected stopPendingTransitions(path?: string, delim?: string): void;
1214
+ protected stopPendingTransitions(path?: Path, delim?: string): void;
1061
1215
 
1062
- protected stopScheduledTransitions(path?: string, delim?: string): void;
1216
+ protected stopScheduledTransitions(path?: Path, delim?: string): void;
1063
1217
 
1064
1218
  toJSON(opt?: dia.Cell.ExportOptions): Cell.JSON<any, A>;
1065
1219
 
@@ -1097,11 +1251,11 @@ export declare namespace dia {
1097
1251
 
1098
1252
  removeAttr(path: Path, opt?: Cell.Options): this;
1099
1253
 
1100
- transition(path: string, value?: any, opt?: Cell.TransitionOptions, delim?: string): number;
1254
+ transition(path: Path, value?: any, opt?: Cell.TransitionOptions, delim?: string): number;
1101
1255
 
1102
1256
  getTransitions(): string[];
1103
1257
 
1104
- stopTransitions(path?: string, delim?: string): this;
1258
+ stopTransitions(path?: Path, delim?: string): this;
1105
1259
 
1106
1260
  embed(cell: Cell | Cell[], opt?: Cell.EmbedOptions): this;
1107
1261
 
@@ -1125,6 +1279,9 @@ export declare namespace dia {
1125
1279
 
1126
1280
  z(): number;
1127
1281
 
1282
+ layer(): string | null;
1283
+ layer(id: string | null, opt?: Graph.Options): this;
1284
+
1128
1285
  angle(): number;
1129
1286
 
1130
1287
  getBBox(): g.Rect;
@@ -1146,6 +1303,8 @@ export declare namespace dia {
1146
1303
 
1147
1304
  static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor<Cell>;
1148
1305
 
1306
+ static getAttributeDefinition(attrName: string): Cell.PresentationAttributeDefinition<CellView> | null;
1307
+
1149
1308
  /**
1150
1309
  * @deprecated
1151
1310
  */
@@ -1170,24 +1329,40 @@ export declare namespace dia {
1170
1329
  export interface Attributes extends GenericAttributes<Cell.Selectors> {
1171
1330
  }
1172
1331
 
1173
- export type PortPositionCallback = (ports: Port[], bbox: g.Rect) => dia.Point[];
1332
+ export interface ConstructorOptions extends Cell.ConstructorOptions {
1333
+ portLayoutNamespace?: { [key: string]: layout.Port.LayoutFunction };
1334
+ portLabelLayoutNamespace?: { [key: string]: layout.PortLabel.LayoutFunction };
1335
+ }
1336
+
1337
+ export type PortPositionCallback = layout.Port.LayoutFunction;
1338
+
1339
+ export type PortLabelPositionCallback = layout.PortLabel.LayoutFunction;
1174
1340
 
1175
1341
  export interface PortPositionJSON {
1176
1342
  name?: string;
1177
- args?: { [key: string]: any };
1343
+ args?: layout.Port.Options;
1344
+ }
1345
+
1346
+ export interface PortLabelPositionJSON {
1347
+ name?: string;
1348
+ args?: layout.PortLabel.Options;
1178
1349
  }
1179
1350
 
1180
1351
  export type PositionType = string | PortPositionCallback | PortPositionJSON;
1181
1352
 
1353
+ export type PortLabelPositionType = PortLabelPositionCallback | PortPositionJSON;
1354
+
1182
1355
  export interface PortGroup {
1183
1356
  position?: PositionType;
1184
1357
  markup?: string | MarkupJSON;
1185
1358
  attrs?: Cell.Selectors;
1186
1359
  size?: Size;
1187
- label?: {
1188
- markup?: string | MarkupJSON;
1189
- position?: PositionType;
1190
- };
1360
+ label?: PortLabel;
1361
+ }
1362
+
1363
+ export interface PortLabel {
1364
+ markup?: string | MarkupJSON;
1365
+ position?: PortLabelPositionType;
1191
1366
  }
1192
1367
 
1193
1368
  export interface Port {
@@ -1196,14 +1371,12 @@ export declare namespace dia {
1196
1371
  group?: string;
1197
1372
  attrs?: Cell.Selectors;
1198
1373
  position?: {
1199
- args?: { [key: string]: any };
1374
+ args?: layout.Port.Options;
1200
1375
  };
1201
- args?: { [key: string]: any };
1376
+ /** @deprecated use `position.args` instead */
1377
+ args?: layout.Port.Options;
1202
1378
  size?: Size;
1203
- label?: {
1204
- markup?: string | MarkupJSON;
1205
- position?: PositionType;
1206
- };
1379
+ label?: PortLabel;
1207
1380
  z?: number | 'auto';
1208
1381
  }
1209
1382
 
@@ -1233,13 +1406,13 @@ export declare namespace dia {
1233
1406
  filter?: (cell: Cell) => boolean;
1234
1407
  deep?: boolean;
1235
1408
  padding?: Padding;
1236
- minRect?: g.Rect;
1409
+ minRect?: Partial<BBox>;
1237
1410
  expandOnly?: boolean;
1238
1411
  shrinkOnly?: boolean;
1239
1412
  }
1240
1413
 
1241
1414
  export interface FitParentOptions extends FitToChildrenOptions {
1242
- terminator?: Cell | Cell.ID;
1415
+ terminator?: Graph.CellRef;
1243
1416
  }
1244
1417
 
1245
1418
  export interface RotateOptions {
@@ -1253,6 +1426,8 @@ export declare namespace dia {
1253
1426
 
1254
1427
  export class Element<A extends ObjectHash = Element.Attributes, S extends mvc.ModelSetOptions = dia.ModelSetOptions> extends Cell<A, S> {
1255
1428
 
1429
+ constructor(attributes?: DeepPartial<A>, opt?: Element.ConstructorOptions);
1430
+
1256
1431
  translate(tx: number, ty?: number, opt?: Element.TranslateOptions): this;
1257
1432
 
1258
1433
  position(opt?: Element.PositionOptions): g.Point;
@@ -1964,44 +2139,105 @@ export declare namespace dia {
1964
2139
  }
1965
2140
 
1966
2141
  export enum Layers {
1967
- CELLS = 'cells',
1968
2142
  LABELS = 'labels',
1969
2143
  BACK = 'back',
1970
2144
  FRONT = 'front',
2145
+ /** @deprecated */
2146
+ CELLS = 'cells',
1971
2147
  TOOLS = 'tools',
1972
2148
  GRID = 'grid',
1973
2149
  }
1974
2150
 
1975
- export type UpdateStats = {
2151
+ export type LayerRef = Layers | string | dia.LayerView | dia.GraphLayer;
2152
+
2153
+ export interface RenderStats {
1976
2154
  priority: number;
1977
2155
  updated: number;
1978
- empty?: boolean;
1979
- postponed?: number;
1980
- unmounted?: number;
1981
- mounted?: number;
2156
+ }
2157
+
2158
+ export interface UpdateVisibilityStats {
2159
+ mounted: number;
2160
+ unmounted: number;
2161
+ }
2162
+
2163
+ export interface RenderBatchStats extends RenderStats, UpdateVisibilityStats {
2164
+ postponed: number;
2165
+ empty: boolean;
2166
+ }
2167
+
2168
+ export type UpdateStats = RenderStats & Partial<RenderBatchStats> & {
1982
2169
  batches?: number;
1983
2170
  };
1984
2171
 
1985
2172
  export type ViewportCallback = (view: mvc.View<any, any>, isMounted: boolean, paper: Paper) => boolean;
2173
+ export type CellVisibilityCallback = (cell: Cell, isMounted: boolean, paper: Paper) => boolean;
1986
2174
  export type ProgressCallback = (done: boolean, processed: number, total: number, stats: UpdateStats, paper: Paper) => void;
1987
2175
  export type BeforeRenderCallback = (opt: { [key: string]: any }, paper: Paper) => void;
1988
2176
  export type AfterRenderCallback = (stats: UpdateStats, opt: { [key: string]: any }, paper: Paper) => void;
1989
2177
 
1990
- export interface FreezeOptions {
1991
- key?: string;
2178
+ export interface CellVisibilityOptions {
2179
+ cellVisibility?: CellVisibilityCallback | null;
2180
+
2181
+ /** @deprecated disable `legacyMode` and use `cellVisibility` instead */
2182
+ viewport?: ViewportCallback | null;
1992
2183
  }
1993
2184
 
1994
- export interface UnfreezeOptions {
1995
- key?: string;
2185
+ export interface MountOptions {
1996
2186
  mountBatchSize?: number;
2187
+ }
2188
+
2189
+ export interface UnmountOptions {
1997
2190
  unmountBatchSize?: number;
2191
+ }
2192
+
2193
+ export interface BatchSizeOptions {
1998
2194
  batchSize?: number;
1999
- viewport?: ViewportCallback;
2000
- progress?: ProgressCallback;
2195
+ }
2196
+
2197
+ export interface BeforeRenderOptions {
2001
2198
  beforeRender?: BeforeRenderCallback;
2199
+ }
2200
+
2201
+ export interface AfterRenderOptions {
2002
2202
  afterRender?: AfterRenderCallback;
2003
2203
  }
2004
2204
 
2205
+ export interface RenderCallbackOptions extends BeforeRenderOptions, AfterRenderOptions, mvc.Silenceable {
2206
+
2207
+ }
2208
+
2209
+ export interface KeyOptions {
2210
+ key?: string;
2211
+ }
2212
+
2213
+ export interface UpdateViewOptions {
2214
+ [key: string]: any;
2215
+ }
2216
+
2217
+ export interface UpdateViewsBatchOptions extends UpdateViewOptions, BatchSizeOptions, CellVisibilityOptions {
2218
+
2219
+ }
2220
+
2221
+ export interface UpdateViewsOptions extends UpdateViewsBatchOptions, RenderCallbackOptions {
2222
+
2223
+ }
2224
+
2225
+ export interface UpdateViewsAsyncOptions extends UpdateViewsBatchOptions, ScheduleCellsVisibilityUpdateOptions, RenderCallbackOptions {
2226
+ progress?: ProgressCallback;
2227
+ }
2228
+
2229
+ export interface ScheduleCellsVisibilityUpdateOptions extends CellVisibilityOptions, MountOptions, UnmountOptions {
2230
+
2231
+ }
2232
+
2233
+ export interface FreezeOptions extends KeyOptions {
2234
+
2235
+ }
2236
+
2237
+ export interface UnfreezeOptions extends KeyOptions, UpdateViewsAsyncOptions, UpdateViewsOptions {
2238
+
2239
+ }
2240
+
2005
2241
  export interface SnapLinksOptions {
2006
2242
  radius?: number;
2007
2243
  findInAreaOptions?: FindInAreaOptions;
@@ -2013,7 +2249,7 @@ export declare namespace dia {
2013
2249
  export type FindParentByCallback = ((this: dia.Graph, elementView: ElementView, evt: dia.Event, x: number, y: number) => Cell[]);
2014
2250
  export type MeasureNodeCallback = (node: SVGGraphicsElement, cellView: dia.CellView) => g.Rect;
2015
2251
 
2016
- export interface Options extends mvc.ViewOptions<Graph> {
2252
+ export interface Options extends mvc.ViewOptions<Graph>, CellVisibilityOptions, BeforeRenderOptions, AfterRenderOptions {
2017
2253
  // appearance
2018
2254
  width?: Dimension;
2019
2255
  height?: Dimension;
@@ -2056,6 +2292,7 @@ export declare namespace dia {
2056
2292
  validateUnembedding?: (this: Paper, childView: ElementView) => boolean;
2057
2293
  // default views, models & attributes
2058
2294
  cellViewNamespace?: any;
2295
+ layerViewNamespace?: any;
2059
2296
  routerNamespace?: any;
2060
2297
  connectorNamespace?: any;
2061
2298
  highlighterNamespace?: any;
@@ -2075,14 +2312,17 @@ export declare namespace dia {
2075
2312
  sorting?: sorting;
2076
2313
  frozen?: boolean;
2077
2314
  autoFreeze?: boolean;
2078
- viewport?: ViewportCallback | null;
2315
+ viewManagement?: ViewManagementOptions | boolean;
2079
2316
  onViewUpdate?: (view: mvc.View<any, any>, flag: number, priority: number, opt: { [key: string]: any }, paper: Paper) => void;
2080
2317
  onViewPostponed?: (view: mvc.View<any, any>, flag: number, paper: Paper) => boolean;
2081
- beforeRender?: Paper.BeforeRenderCallback;
2082
- afterRender?: Paper.AfterRenderCallback;
2083
2318
  overflow?: boolean;
2084
2319
  }
2085
2320
 
2321
+ export interface ViewManagementOptions {
2322
+ lazyInitialize?: boolean;
2323
+ disposeHidden?: boolean;
2324
+ }
2325
+
2086
2326
  export interface TransformToFitContentOptions {
2087
2327
  padding?: Padding;
2088
2328
  preserveAspectRatio?: boolean;
@@ -2215,6 +2455,22 @@ export declare namespace dia {
2215
2455
 
2216
2456
  export interface FindInAreaOptions extends Graph.FindInAreaOptions, BufferOptions {
2217
2457
  }
2458
+
2459
+ export interface FindClosestMagnetToPointOptions {
2460
+ radius?: number;
2461
+ findInAreaOptions?: FindInAreaOptions;
2462
+ filter?: (view: CellView, magnet: SVGElement) => boolean;
2463
+ }
2464
+
2465
+ export interface ClosestMagnet {
2466
+ view: CellView;
2467
+ magnet: SVGElement;
2468
+ }
2469
+
2470
+ export interface InsertLayerViewOptions {
2471
+ before?: LayerRef | null;
2472
+ index?: number;
2473
+ }
2218
2474
  }
2219
2475
 
2220
2476
  export class Paper extends mvc.View<Graph> {
@@ -2227,10 +2483,14 @@ export declare namespace dia {
2227
2483
 
2228
2484
  svg: SVGSVGElement;
2229
2485
  defs: SVGDefsElement;
2486
+
2487
+ /** @deprecated use getLayerViewNode()*/
2230
2488
  cells: SVGGElement;
2489
+ /** @deprecated use layers property*/
2490
+ viewport: SVGGElement;
2491
+
2231
2492
  tools: SVGGElement;
2232
2493
  layers: SVGGElement;
2233
- viewport: SVGGElement;
2234
2494
 
2235
2495
  GUARDED_TAG_NAMES: string[];
2236
2496
  FORM_CONTROLS_TAG_NAMES: string[];
@@ -2306,7 +2566,7 @@ export declare namespace dia {
2306
2566
 
2307
2567
  findView<T extends ElementView | LinkView>(element: mvc.$SVGElement): T;
2308
2568
 
2309
- findViewByModel<T extends ElementView | LinkView>(model: Cell | Cell.ID): T;
2569
+ findViewByModel<T extends ElementView | LinkView>(model: Graph.CellRef): T;
2310
2570
 
2311
2571
  /**
2312
2572
  * Finds all the element views at the specified point
@@ -2350,6 +2610,13 @@ export declare namespace dia {
2350
2610
  */
2351
2611
  findCellViewsInArea(area: BBox, opt?: Paper.FindInAreaOptions): CellView[];
2352
2612
 
2613
+ /**
2614
+ * Finds the closest magnet to the specified point
2615
+ * @param point a point in local paper coordinates
2616
+ * @param opt options for the search
2617
+ */
2618
+ findClosestMagnetToPoint(point: Point, opt?: Paper.FindClosestMagnetToPointOptions): Paper.ClosestMagnet | null;
2619
+
2353
2620
  fitToContent(opt?: Paper.FitToContentOptions): g.Rect;
2354
2621
  fitToContent(gridWidth?: number, gridHeight?: number, padding?: number, opt?: any): g.Rect;
2355
2622
 
@@ -2361,7 +2628,7 @@ export declare namespace dia {
2361
2628
 
2362
2629
  getDefaultLink(cellView: CellView, magnet: SVGElement): Link;
2363
2630
 
2364
- getModelById(id: Cell.ID | Cell): Cell;
2631
+ getModelById(id: Graph.CellRef): Cell;
2365
2632
 
2366
2633
  setDimensions(width: Paper.Dimension, height: Paper.Dimension, data?: any): void;
2367
2634
 
@@ -2397,29 +2664,38 @@ export declare namespace dia {
2397
2664
 
2398
2665
  // layers
2399
2666
 
2400
- getLayerNode(layerName: Paper.Layers | string): SVGGElement;
2667
+ getLayerView(layerRef: Paper.LayerRef): LayerView;
2668
+ getLayerView(layer: GraphLayer): GraphLayerView;
2669
+
2670
+ hasLayerView(layerRef: Paper.LayerRef): boolean;
2671
+
2672
+ getLayerViews(): Array<LayerView>;
2673
+
2674
+ getGraphLayerViews(): Array<GraphLayerView>;
2675
+
2676
+ addLayerView(layerView: LayerView, options?: Paper.InsertLayerViewOptions): void;
2401
2677
 
2402
- getLayerView(layerName: Paper.Layers | string): PaperLayer;
2678
+ moveLayerView(layerRef: Paper.LayerRef, options?: Paper.InsertLayerViewOptions): void;
2403
2679
 
2404
- hasLayerView(layerName: Paper.Layers | string): boolean;
2680
+ removeLayerView(layerRef: Paper.LayerRef): void;
2405
2681
 
2406
- renderLayers(layers: Array<{ name: string }>): void;
2682
+ protected insertLayerView(layerView: LayerView, before?: Paper.LayerRef): void;
2407
2683
 
2408
- protected removeLayers(): void;
2684
+ protected requestLayerViewRemoval(layerRef: Paper.LayerRef): void;
2409
2685
 
2410
- protected resetLayers(): void;
2686
+ protected createLayerView(options: Omit<LayerView.Options, 'paper'>): LayerView;
2411
2687
 
2412
- addLayer(layerName: string, layerView: PaperLayer, options?: { insertBefore?: string }): void;
2688
+ protected getLayerViewOrder(): string[];
2413
2689
 
2414
- removeLayer(layer: string | PaperLayer): void;
2690
+ protected renderLayerViews(): void;
2415
2691
 
2416
- moveLayer(layer: string | PaperLayer, insertBefore: string | PaperLayer | null): void;
2692
+ protected renderImplicitLayerViews(): void;
2417
2693
 
2418
- hasLayer(layer: string | PaperLayer): boolean;
2694
+ protected renderGraphLayerViews(): void;
2419
2695
 
2420
- getLayerNames(): string[];
2696
+ protected removeLayerViews(): void;
2421
2697
 
2422
- getLayers(): Array<PaperLayer>;
2698
+ protected resetLayerViews(): void;
2423
2699
 
2424
2700
  // rendering
2425
2701
 
@@ -2427,39 +2703,33 @@ export declare namespace dia {
2427
2703
 
2428
2704
  unfreeze(opt?: Paper.UnfreezeOptions): void;
2429
2705
 
2706
+ wakeUp(): void;
2707
+
2430
2708
  isFrozen(): boolean;
2431
2709
 
2432
2710
  requestViewUpdate(view: mvc.View<any, any>, flag: number, priority: number, opt?: { [key: string]: any }): void;
2433
2711
 
2434
- requireView<T extends ElementView | LinkView>(model: Cell | Cell.ID, opt?: dia.Cell.Options): T;
2435
-
2436
- dumpViews(opt?: {
2437
- batchSize?: number;
2438
- mountBatchSize?: number;
2439
- unmountBatchSize?: number;
2440
- viewport?: Paper.ViewportCallback;
2441
- }): void;
2712
+ requestCellViewInsertion(cell: Graph.CellRef, opt?: { [key: string]: any }): void;
2442
2713
 
2443
- checkViewport(opt?: {
2444
- mountBatchSize?: number;
2445
- unmountBatchSize?: number;
2446
- viewport?: Paper.ViewportCallback;
2447
- }): {
2448
- mounted: number;
2449
- unmounted: number;
2450
- };
2714
+ requireView<T extends ElementView | LinkView>(cellOrId: Graph.CellRef, opt?: Paper.UpdateViewOptions & Paper.RenderCallbackOptions): T;
2451
2715
 
2452
- updateViews(opt?: {
2453
- batchSize?: number;
2454
- viewport?: Paper.ViewportCallback;
2455
- }): {
2456
- updated: number;
2457
- batches: number;
2458
- priority: number;
2459
- };
2716
+ updateViews(opt?: Paper.UpdateViewsOptions): Paper.RenderStats & { batches: number };
2460
2717
 
2461
2718
  hasScheduledUpdates(): boolean;
2462
2719
 
2720
+ disposeHiddenCellViews(): void;
2721
+
2722
+ isCellVisible(cellOrId: Graph.CellRef): boolean;
2723
+
2724
+ updateCellVisibility(
2725
+ cell: Graph.CellRef,
2726
+ opt?: Paper.CellVisibilityOptions & Paper.UpdateViewOptions & Paper.RenderCallbackOptions
2727
+ ): void;
2728
+
2729
+ updateCellsVisibility(
2730
+ opt?: Paper.ScheduleCellsVisibilityUpdateOptions & Paper.UpdateViewsOptions
2731
+ ): void;
2732
+
2463
2733
  // events
2464
2734
 
2465
2735
  on<T extends keyof Paper.EventMap = keyof Paper.EventMap>(eventName: T, callback: Paper.EventMap[T], context?: any): this;
@@ -2469,52 +2739,51 @@ export declare namespace dia {
2469
2739
  // protected
2470
2740
 
2471
2741
  /**
2472
- * For the specified view, calls the visibility viewport function specified by the paper.options.viewport function.
2742
+ * For the specified view, calls the cell visibility function specified by the `paper.options.cellVisibility` function.
2473
2743
  * If the function returns true, the view is attached to the DOM; in other case it is detached.
2474
- * While async papers do this automatically, synchronous papers require an explicit call to this method for this functionality to be applied. To show the view again, use paper.requestView().
2475
- * If you are using autoFreeze option you should call this function if you are calling paper.requestView() if you want paper.options.viewport function to be applied.
2744
+ * While async papers do this automatically, synchronous papers require an explicit call to this method for this functionality to be applied. To show the view again, use `paper.requestView()`.
2745
+ * If you are using `autoFreeze` option you should call this function if you are calling `paper.requestView()` if you want `paper.options.cellVisibility` function to be applied.
2476
2746
  * @param cellView cellView for which the visibility check is performed
2477
- * @param opt if opt.viewport is provided, it is used as the callback function instead of paper.options.viewport.
2747
+ * @param opt if opt.cellVisibility is provided, it is used as the callback function instead of paper.options.cellVisibility.
2478
2748
  */
2479
- protected checkViewVisibility(cellView: dia.CellView, opt?: {
2480
- viewport?: Paper.ViewportCallback;
2481
- }): {
2482
- mounted: number;
2483
- unmounted: number;
2484
- };
2749
+ protected checkViewVisibility(
2750
+ cellView: dia.CellView,
2751
+ opt?: Paper.CellVisibilityOptions
2752
+ ): Paper.UpdateVisibilityStats;
2753
+
2754
+
2755
+ protected scheduleCellsVisibilityUpdate(opt?: Paper.ScheduleCellsVisibilityUpdateOptions): Paper.UpdateVisibilityStats;
2485
2756
 
2486
2757
  protected scheduleViewUpdate(view: mvc.View<any, any>, flag: number, priority: number, opt?: { [key: string]: any }): void;
2487
2758
 
2488
2759
  protected dumpViewUpdate(view: mvc.View<any, any>): number;
2489
2760
 
2490
- protected dumpView(view: mvc.View<any, any>, opt?: { [key: string]: any }): number;
2761
+ protected dumpView(view: mvc.View<any, any>, opt?: Paper.UpdateViewOptions & Paper.RenderCallbackOptions): number;
2491
2762
 
2492
- protected updateView(view: mvc.View<any, any>, flag: number, opt?: { [key: string]: any }): number;
2763
+ protected updateView(view: mvc.View<any, any>, flag: number, opt?: Paper.UpdateViewOptions): number;
2493
2764
 
2494
2765
  protected registerUnmountedView(view: mvc.View<any, any>): number;
2495
2766
 
2496
2767
  protected registerMountedView(view: mvc.View<any, any>): number;
2497
2768
 
2498
- protected updateViewsAsync(opt?: {
2499
- batchSize?: number;
2500
- mountBatchSize?: number;
2501
- unmountBatchSize?: number;
2502
- viewport?: Paper.ViewportCallback;
2503
- progress?: Paper.ProgressCallback;
2504
- before?: Paper.BeforeRenderCallback;
2505
- }): void;
2769
+ protected updateViewsAsync(opt?: Paper.UpdateViewsAsyncOptions): void;
2506
2770
 
2507
- protected updateViewsBatch(opt?: {
2508
- batchSize?: number;
2509
- viewport?: Paper.ViewportCallback;
2510
- }): Paper.UpdateStats;
2771
+ protected updateViewsBatch(opt?: Paper.UpdateViewsBatchOptions): Paper.RenderBatchStats;
2772
+
2773
+ protected checkMountedViews(viewport: Paper.ViewportCallback, opt?: Paper.UnmountOptions): number;
2774
+
2775
+ protected checkUnmountedViews(viewport: Paper.ViewportCallback, opt?: Paper.MountOptions): number;
2511
2776
 
2512
- protected checkMountedViews(viewport: Paper.ViewportCallback, opt?: { unmountBatchSize?: number }): number;
2777
+ protected prioritizeCellViewMount(cellOrId: Graph.CellRef): boolean;
2513
2778
 
2514
- protected checkUnmountedViews(viewport: Paper.ViewportCallback, opt?: { mountBatchSize?: number }): number;
2779
+ protected prioritizeCellViewUnmount(cellOrId: Graph.CellRef): boolean;
2780
+
2781
+ protected isViewMounted(viewOrCid: dia.CellView | string): boolean;
2515
2782
 
2516
2783
  protected isAsync(): boolean;
2517
2784
 
2785
+ protected isIdle(): boolean;
2786
+
2518
2787
  protected isExactSorting(): boolean;
2519
2788
 
2520
2789
  protected sortViews(): void;
@@ -2568,6 +2837,14 @@ export declare namespace dia {
2568
2837
  protected onCellChanged(cell: Cell, opt: dia.Cell.Options): void;
2569
2838
  protected onCellChanged(cell: mvc.Collection<Cell>, opt: dia.Graph.Options): void;
2570
2839
 
2840
+ protected onGraphLayerAdd(layer: GraphLayer, collection: mvc.Collection<GraphLayer>, opt: dia.Graph.Options): void;
2841
+
2842
+ protected onGraphLayerRemove(layer: GraphLayer, collection: mvc.Collection<GraphLayer>, opt: dia.Graph.Options): void;
2843
+
2844
+ protected onGraphLayerCollectionReset(layer: mvc.Collection<GraphLayer>, opt: dia.Graph.Options): void;
2845
+
2846
+ protected onGraphLayerCollectionSort(layer: GraphLayer[]): void;
2847
+
2571
2848
  protected onGraphReset(cells: mvc.Collection<Cell>, opt: dia.Graph.Options): void;
2572
2849
 
2573
2850
  protected onGraphSort(): void;
@@ -2590,12 +2867,19 @@ export declare namespace dia {
2590
2867
 
2591
2868
  protected insertView(cellView: CellView, isInitialInsert: boolean): void;
2592
2869
 
2593
- protected detachView(cellView: CellView): void;
2870
+ protected _hideCellView(cellView: CellView): void;
2871
+
2872
+ protected _detachCellView(cellView: CellView): void;
2594
2873
 
2595
2874
  protected customEventTrigger(event: dia.Event, view: CellView, rootNode?: SVGElement): dia.Event | null;
2596
2875
 
2597
2876
  protected addStylesheet(stylesheet: string): void;
2598
2877
 
2878
+ /**
2879
+ * @deprecated use `getLayerView(id).el` instead
2880
+ * **/
2881
+ getLayerNode(id: Paper.Layers | string): SVGElement;
2882
+
2599
2883
  /**
2600
2884
  * @deprecated use `findElementViewsAtPoint()
2601
2885
  */
@@ -2610,19 +2894,32 @@ export declare namespace dia {
2610
2894
  * @deprecated use transformToFitContent
2611
2895
  */
2612
2896
  scaleContentToFit(opt?: Paper.ScaleContentOptions): void;
2897
+
2898
+ /**
2899
+ * @deprecated Use `updateCellsVisibility()`
2900
+ */
2901
+ checkViewport(opt?: Paper.ScheduleCellsVisibilityUpdateOptions): Paper.UpdateVisibilityStats;
2902
+
2903
+ /**
2904
+ * @deprecated Use `updateCellsVisibility()`
2905
+ */
2906
+ dumpViews(opt?: Paper.ScheduleCellsVisibilityUpdateOptions & Paper.UpdateViewsOptions): void;
2613
2907
  }
2614
2908
 
2615
- export namespace PaperLayer {
2909
+ export namespace LayerView {
2616
2910
 
2617
- export interface Options extends mvc.ViewOptions<undefined, SVGElement> {
2618
- name: string;
2911
+ export interface Options<T extends mvc.Model | undefined = undefined> extends mvc.ViewOptions<T, SVGElement> {
2912
+ id: string;
2913
+ paper: Paper;
2914
+ type?: string;
2619
2915
  }
2620
2916
  }
2621
- export class PaperLayer extends mvc.View<undefined, SVGElement> {
2622
2917
 
2623
- constructor(opt?: PaperLayer.Options);
2918
+ export class LayerView<T extends mvc.Model | undefined = undefined> extends mvc.View<T, SVGElement> {
2624
2919
 
2625
- options: PaperLayer.Options;
2920
+ constructor(opt?: LayerView.Options);
2921
+
2922
+ options: LayerView.Options;
2626
2923
 
2627
2924
  pivotNodes: { [z: number]: Comment };
2628
2925
 
@@ -2632,7 +2929,78 @@ export declare namespace dia {
2632
2929
 
2633
2930
  insertPivot(z: number): Comment;
2634
2931
 
2635
- removePivots(): void;
2932
+ isEmpty(): boolean;
2933
+
2934
+ reset(): void;
2935
+
2936
+ setPaperReference(paper: Paper): void;
2937
+
2938
+ unsetPaperReference(): void;
2939
+
2940
+ protected removePivots(): void;
2941
+
2942
+ protected afterPaperReferenceSet(paper: Paper): void;
2943
+
2944
+ protected beforePaperReferenceUnset(paper: Paper): void;
2945
+
2946
+ protected assertPaperReferenceSet(): void;
2947
+ }
2948
+
2949
+ export namespace GraphLayer {
2950
+
2951
+ export type ID = string;
2952
+
2953
+ export interface Attributes extends mvc.ObjectHash {
2954
+ id: ID;
2955
+ type?: string;
2956
+ }
2957
+ }
2958
+
2959
+ export class GraphLayer<C extends CellCollection = CellCollection, A extends GraphLayer.Attributes = GraphLayer.Attributes, S extends mvc.ModelSetOptions = dia.ModelSetOptions> extends mvc.Model<A, S> {
2960
+
2961
+ id: string;
2962
+
2963
+ cellCollection: C;
2964
+ graph: Graph | null;
2965
+
2966
+ constructor(attributes?: DeepPartial<A>, options?: mvc.ModelConstructorOptions<GraphLayer>);
2967
+
2968
+ getCells(): Cell[];
2969
+ }
2970
+
2971
+ export class GraphLayerView<T extends GraphLayer = GraphLayer> extends LayerView<T> {
2972
+
2973
+ sort(): void;
2974
+
2975
+ sortExact(): void;
2976
+
2977
+ insertCellView(cellView: CellView): void;
2978
+
2979
+ protected onCellMove(cell: Cell, opt: Graph.Options): void;
2980
+
2981
+ protected onCellChange(cell: Cell, opt: Cell.Options): void;
2982
+
2983
+ protected onCellCollectionSort(collection: CellCollection, opt: Graph.Options): void;
2984
+
2985
+ protected onGraphBatchStop(data: any): void;
2986
+ }
2987
+
2988
+ export namespace GridLayerView {
2989
+
2990
+ export interface Options extends LayerView.Options {
2991
+ patterns?: Record<string, Paper.GridOptions[]>;
2992
+ }
2993
+ }
2994
+
2995
+ export class GridLayerView extends LayerView {
2996
+
2997
+ setGrid(opt?: null | boolean | string | Paper.GridOptions | Paper.GridOptions[]): void;
2998
+
2999
+ renderGrid(): void;
3000
+
3001
+ updateGrid(): void;
3002
+
3003
+ removeGrid(): void;
2636
3004
  }
2637
3005
 
2638
3006
  export namespace ToolsView {
@@ -2668,6 +3036,10 @@ export declare namespace dia {
2668
3036
  hide(): this;
2669
3037
 
2670
3038
  mount(): this;
3039
+
3040
+ getLayer(): string | null;
3041
+
3042
+ hasLayer(): boolean;
2671
3043
  }
2672
3044
 
2673
3045
  export namespace ToolView {
@@ -2711,6 +3083,8 @@ export declare namespace dia {
2711
3083
 
2712
3084
  update(): void;
2713
3085
 
3086
+ isOverlay(): boolean;
3087
+
2714
3088
  protected guard(evt: dia.Event): boolean;
2715
3089
  }
2716
3090
 
@@ -2802,6 +3176,8 @@ export declare namespace dia {
2802
3176
  id?: string
2803
3177
  ): T[];
2804
3178
 
3179
+ static has(cellView: dia.CellView, id?: string): boolean;
3180
+
2805
3181
  static update(cellView: dia.CellView, id?: string): void;
2806
3182
 
2807
3183
  static transform(cellView: dia.CellView, id?: string): void;
@@ -2879,7 +3255,7 @@ export declare namespace elementTools {
2879
3255
 
2880
3256
  export namespace Boundary {
2881
3257
  export interface Options extends dia.ToolView.Options<dia.ElementView> {
2882
- padding?: number | dia.Sides;
3258
+ padding?: dia.Sides;
2883
3259
  useModelGeometry?: boolean;
2884
3260
  rotate?: boolean;
2885
3261
  }
@@ -2957,12 +3333,16 @@ export declare namespace g {
2957
3333
  }
2958
3334
 
2959
3335
  export type Shape = Path | Point | Line | Polyline | Polygon | Rect | Ellipse;
3336
+
2960
3337
  export interface PlainPoint {
2961
3338
 
2962
3339
  x: number;
2963
3340
  y: number;
2964
3341
  }
2965
3342
 
3343
+ /** Can be understood by `g.Point` constructor */
3344
+ export type PointInit = Partial<PlainPoint> | string;
3345
+
2966
3346
  export interface PlainRect {
2967
3347
 
2968
3348
  x: number;
@@ -3022,15 +3402,15 @@ export declare namespace g {
3022
3402
 
3023
3403
  clone(): Segment;
3024
3404
 
3025
- closestPoint(p: Point, opt?: SubdivisionsOpt): Point;
3405
+ closestPoint(p: PlainPoint, opt?: SubdivisionsOpt): Point;
3026
3406
 
3027
- closestPointLength(p: Point, opt?: SubdivisionsOpt): number;
3407
+ closestPointLength(p: PlainPoint, opt?: SubdivisionsOpt): number;
3028
3408
 
3029
- closestPointNormalizedLength(p: Point, opt?: SubdivisionsOpt): number;
3409
+ closestPointNormalizedLength(p: PlainPoint, opt?: SubdivisionsOpt): number;
3030
3410
 
3031
- closestPointT(p: Point): number;
3411
+ closestPointT(p: PlainPoint): number;
3032
3412
 
3033
- closestPointTangent(p: Point): Line | null;
3413
+ closestPointTangent(p: PlainPoint): Line | null;
3034
3414
 
3035
3415
  divideAt(ratio: number, opt?: SubdivisionsOpt): [Segment, Segment];
3036
3416
 
@@ -3056,7 +3436,7 @@ export declare namespace g {
3056
3436
 
3057
3437
  round(precision?: number): this;
3058
3438
 
3059
- scale(sx: number, sy: number, origin?: PlainPoint): this;
3439
+ scale(sx: number, sy: number, origin?: PointInit): this;
3060
3440
 
3061
3441
  tangentAt(ratio: number): Line | null;
3062
3442
 
@@ -3113,7 +3493,7 @@ export declare namespace g {
3113
3493
  end: Point;
3114
3494
  type: types.Curve;
3115
3495
 
3116
- constructor(p1: PlainPoint | string, p2: PlainPoint | string, p3: PlainPoint | string, p4: PlainPoint | string);
3496
+ constructor(p1: PointInit, p2: PointInit, p3: PointInit, p4: PointInit);
3117
3497
  constructor(curve: Curve);
3118
3498
 
3119
3499
  bbox(): Rect;
@@ -3161,7 +3541,7 @@ export declare namespace g {
3161
3541
 
3162
3542
  round(precision?: number): this;
3163
3543
 
3164
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
3544
+ scale(sx: number, sy: number, origin?: PointInit): this;
3165
3545
 
3166
3546
  tangentAt(ratio: number, opt?: SubdivisionsOpt): Line | null;
3167
3547
 
@@ -3193,7 +3573,7 @@ export declare namespace g {
3193
3573
  b: number;
3194
3574
  type: types.Ellipse;
3195
3575
 
3196
- constructor(center: PlainPoint | string, a: number, b: number);
3576
+ constructor(center: PointInit, a: number, b: number);
3197
3577
  constructor(ellipse: Ellipse);
3198
3578
 
3199
3579
  bbox(): Rect;
@@ -3210,7 +3590,7 @@ export declare namespace g {
3210
3590
 
3211
3591
  intersectionWithLine(l: Line): Point[] | null;
3212
3592
 
3213
- intersectionWithLineFromCenterToPoint(p: PlainPoint, angle?: number): Point;
3593
+ intersectionWithLineFromCenterToPoint(p: PointInit, angle?: number): Point;
3214
3594
 
3215
3595
  normalizedDistance(point: PlainPoint): number;
3216
3596
 
@@ -3229,7 +3609,7 @@ export declare namespace g {
3229
3609
  end: Point;
3230
3610
  type: types.Line;
3231
3611
 
3232
- constructor(p1: PlainPoint | string, p2: PlainPoint | string);
3612
+ constructor(p1: PointInit, p2: PointInit);
3233
3613
  constructor(line: Line);
3234
3614
  constructor();
3235
3615
 
@@ -3243,13 +3623,13 @@ export declare namespace g {
3243
3623
 
3244
3624
  parallel(distance: number): Line;
3245
3625
 
3246
- closestPoint(p: PlainPoint | string): Point;
3626
+ closestPoint(p: PointInit): Point;
3247
3627
 
3248
- closestPointLength(p: PlainPoint | string): number;
3628
+ closestPointLength(p: PointInit): number;
3249
3629
 
3250
- closestPointNormalizedLength(p: PlainPoint | string): number;
3630
+ closestPointNormalizedLength(p: PointInit): number;
3251
3631
 
3252
- closestPointTangent(p: PlainPoint | string): Line | null;
3632
+ closestPointTangent(p: PointInit): Line | null;
3253
3633
 
3254
3634
  containsPoint(p: PlainPoint): boolean;
3255
3635
 
@@ -3277,13 +3657,13 @@ export declare namespace g {
3277
3657
 
3278
3658
  pointAtLength(length: number): Point;
3279
3659
 
3280
- pointOffset(p: PlainPoint | string): number;
3660
+ pointOffset(p: PointInit): number;
3281
3661
 
3282
3662
  rotate(origin: PlainPoint, angle: number): this;
3283
3663
 
3284
3664
  round(precision?: number): this;
3285
3665
 
3286
- scale(sx: number, sy: number, origin?: PlainPoint): this;
3666
+ scale(sx: number, sy: number, origin?: PointInit): this;
3287
3667
 
3288
3668
  setLength(length: number): this;
3289
3669
 
@@ -3322,13 +3702,13 @@ export declare namespace g {
3322
3702
 
3323
3703
  clone(): Path;
3324
3704
 
3325
- closestPoint(p: Point, opt?: SegmentSubdivisionsOpt): Point | null;
3705
+ closestPoint(p: PlainPoint, opt?: SegmentSubdivisionsOpt): Point | null;
3326
3706
 
3327
- closestPointLength(p: Point, opt?: SegmentSubdivisionsOpt): number;
3707
+ closestPointLength(p: PlainPoint, opt?: SegmentSubdivisionsOpt): number;
3328
3708
 
3329
- closestPointNormalizedLength(p: Point, opt?: SegmentSubdivisionsOpt): number;
3709
+ closestPointNormalizedLength(p: PlainPoint, opt?: SegmentSubdivisionsOpt): number;
3330
3710
 
3331
- closestPointTangent(p: Point, opt?: SegmentSubdivisionsOpt): Line | null;
3711
+ closestPointTangent(p: PlainPoint, opt?: SegmentSubdivisionsOpt): Line | null;
3332
3712
 
3333
3713
  containsPoint(p: PlainPoint, opt?: SegmentSubdivisionsOpt): boolean;
3334
3714
 
@@ -3364,7 +3744,7 @@ export declare namespace g {
3364
3744
 
3365
3745
  round(precision?: number): this;
3366
3746
 
3367
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
3747
+ scale(sx: number, sy: number, origin?: PointInit): this;
3368
3748
 
3369
3749
  segmentAt(ratio: number, opt?: SegmentSubdivisionsOpt): Segment | null;
3370
3750
 
@@ -3391,7 +3771,7 @@ export declare namespace g {
3391
3771
 
3392
3772
  validate(): this;
3393
3773
 
3394
- private closestPointT(p: Point, opt?: SegmentSubdivisionsOpt): PathT | null;
3774
+ private closestPointT(p: PlainPoint, opt?: SegmentSubdivisionsOpt): PathT | null;
3395
3775
 
3396
3776
  private lengthAtT(t: PathT, opt?: SegmentSubdivisionsOpt): number;
3397
3777
 
@@ -3419,17 +3799,17 @@ export declare namespace g {
3419
3799
  type: types.Point;
3420
3800
 
3421
3801
  constructor(x?: number, y?: number);
3422
- constructor(p: PlainPoint | string);
3802
+ constructor(p: PointInit);
3423
3803
 
3424
- chooseClosest(points: PlainPoint[]): Point | null;
3804
+ chooseClosest(points: PointInit[]): Point | null;
3425
3805
 
3426
3806
  adhereToRect(r: Rect): this;
3427
3807
 
3428
3808
  angleBetween(p1: PlainPoint, p2: PlainPoint): number;
3429
3809
 
3430
- bearing(p: Point): CardinalDirection;
3810
+ bearing(p: PlainPoint): CardinalDirection;
3431
3811
 
3432
- changeInAngle(dx: number, dy: number, ref: PlainPoint | string): number;
3812
+ changeInAngle(dx: number, dy: number, ref: PointInit): number;
3433
3813
 
3434
3814
  clone(): Point;
3435
3815
 
@@ -3438,42 +3818,42 @@ export declare namespace g {
3438
3818
  difference(dx?: number, dy?: number): Point;
3439
3819
  difference(p: PlainPoint): Point;
3440
3820
 
3441
- distance(p: PlainPoint | string): number;
3821
+ distance(p: PlainPoint): number;
3442
3822
 
3443
3823
  dot(p: PlainPoint): number;
3444
3824
 
3445
- equals(p: Point): boolean;
3825
+ equals(p: PlainPoint): boolean;
3446
3826
 
3447
- lerp(p: Point, t: number): Point;
3827
+ lerp(p: PlainPoint, t: number): Point;
3448
3828
 
3449
3829
  magnitude(): number;
3450
3830
 
3451
3831
  manhattanDistance(p: PlainPoint): number;
3452
3832
 
3453
- move(ref: PlainPoint | string, distance: number): this;
3833
+ move(ref: PointInit, distance: number): this;
3454
3834
 
3455
3835
  normalize(length: number): this;
3456
3836
 
3457
3837
  offset(dx?: number, dy?: number): this;
3458
3838
  offset(p: PlainPoint): this;
3459
3839
 
3460
- reflection(ref: PlainPoint | string): Point;
3840
+ reflection(ref: PointInit): Point;
3461
3841
 
3462
- rotate(origin: PlainPoint | string, angle: number): this;
3842
+ rotate(origin: PlainPoint, angle: number): this;
3463
3843
 
3464
3844
  round(precision?: number): this;
3465
3845
 
3466
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
3846
+ scale(sx: number, sy: number, origin?: PointInit): this;
3467
3847
 
3468
3848
  snapToGrid(gx: number, gy?: number): this;
3469
3849
 
3470
- squaredDistance(p: PlainPoint | string): number;
3850
+ squaredDistance(p: PlainPoint): number;
3471
3851
 
3472
- theta(p: PlainPoint | string): number;
3852
+ theta(p: PointInit): number;
3473
3853
 
3474
3854
  toJSON(): PlainPoint;
3475
3855
 
3476
- toPolar(origin?: PlainPoint | string): this;
3856
+ toPolar(origin?: PointInit): this;
3477
3857
 
3478
3858
  toString(): string;
3479
3859
 
@@ -3487,7 +3867,7 @@ export declare namespace g {
3487
3867
 
3488
3868
  vectorAngle(p: PlainPoint): number;
3489
3869
 
3490
- static fromPolar(distance: number, angle: number, origin?: PlainPoint | string): Point;
3870
+ static fromPolar(distance: number, angle: number, origin?: PointInit): Point;
3491
3871
 
3492
3872
  static random(x1: number, x2: number, y1: number, y2: number): Point;
3493
3873
  }
@@ -3499,17 +3879,17 @@ export declare namespace g {
3499
3879
 
3500
3880
  constructor();
3501
3881
  constructor(svgString: string);
3502
- constructor(points: PlainPoint[]);
3882
+ constructor(points: PointInit[]);
3503
3883
 
3504
3884
  bbox(): Rect | null;
3505
3885
 
3506
- closestPoint(p: PlainPoint | string): Point | null;
3886
+ closestPoint(p: PlainPoint): Point | null;
3507
3887
 
3508
- closestPointLength(p: PlainPoint | string): number;
3888
+ closestPointLength(p: PlainPoint): number;
3509
3889
 
3510
- closestPointNormalizedLength(p: PlainPoint | string): number;
3890
+ closestPointNormalizedLength(p: PlainPoint): number;
3511
3891
 
3512
- closestPointTangent(p: PlainPoint | string): Line | null;
3892
+ closestPointTangent(p: PlainPoint): Line | null;
3513
3893
 
3514
3894
  containsPoint(p: PlainPoint): boolean;
3515
3895
 
@@ -3529,7 +3909,7 @@ export declare namespace g {
3529
3909
 
3530
3910
  round(precision?: number): this;
3531
3911
 
3532
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
3912
+ scale(sx: number, sy: number, origin?: PointInit): this;
3533
3913
 
3534
3914
  simplify(opt?: { threshold?: number }): this;
3535
3915
 
@@ -3594,7 +3974,7 @@ export declare namespace g {
3594
3974
 
3595
3975
  clone(): Rect;
3596
3976
 
3597
- containsPoint(p: PlainPoint | string, opt?: StrictOpt): boolean;
3977
+ containsPoint(p: PointInit, opt?: StrictOpt): boolean;
3598
3978
 
3599
3979
  containsRect(r: PlainRect): boolean;
3600
3980
 
@@ -3608,7 +3988,7 @@ export declare namespace g {
3608
3988
 
3609
3989
  intersectionWithLine(l: Line): Point[] | null;
3610
3990
 
3611
- intersectionWithLineFromCenterToPoint(p: PlainPoint | string, angle?: number): Point;
3991
+ intersectionWithLineFromCenterToPoint(p: PointInit, angle?: number): Point;
3612
3992
 
3613
3993
  leftLine(): Line;
3614
3994
 
@@ -3620,7 +4000,7 @@ export declare namespace g {
3620
4000
 
3621
4001
  moveAndExpand(r: PlainRect): this;
3622
4002
 
3623
- moveAroundPoint(origin: PlainPoint | string, angle: number): this;
4003
+ moveAroundPoint(origin: PlainPoint, angle: number): this;
3624
4004
 
3625
4005
  normalize(): this;
3626
4006
 
@@ -3629,7 +4009,7 @@ export declare namespace g {
3629
4009
 
3630
4010
  origin(): Point;
3631
4011
 
3632
- pointNearestToPoint(point: PlainPoint | string): Point;
4012
+ pointNearestToPoint(point: PointInit): Point;
3633
4013
 
3634
4014
  rightLine(): Line;
3635
4015
 
@@ -3637,9 +4017,9 @@ export declare namespace g {
3637
4017
 
3638
4018
  round(precision?: number): this;
3639
4019
 
3640
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
4020
+ scale(sx: number, sy: number, origin?: PointInit): this;
3641
4021
 
3642
- sideNearestToPoint(point: PlainPoint | string): RectangleSide;
4022
+ sideNearestToPoint(point: PointInit): RectangleSide;
3643
4023
 
3644
4024
  snapToGrid(gx: number, gy?: number): this;
3645
4025
 
@@ -3679,24 +4059,24 @@ export declare namespace g {
3679
4059
  p3: Point;
3680
4060
  }
3681
4061
 
3682
- export function curveThroughPoints(points: PlainPoint[] | Point[]): string[];
4062
+ export function curveThroughPoints(points: PlainPoint[]): string[];
3683
4063
 
3684
- export function getCurveControlPoints(points: PlainPoint[] | Point[]): [Point[], Point[]];
4064
+ export function getCurveControlPoints(points: PlainPoint[]): [Point[], Point[]];
3685
4065
 
3686
4066
  export function getCurveDivider(
3687
- p0: string | PlainPoint,
3688
- p1: string | PlainPoint,
3689
- p2: string | PlainPoint,
3690
- p3: string | PlainPoint
4067
+ p0: PointInit,
4068
+ p1: PointInit,
4069
+ p2: PointInit,
4070
+ p3: PointInit
3691
4071
  ): (t: number) => [IBezierCurve, IBezierCurve];
3692
4072
 
3693
4073
  export function getFirstControlPoints(rhs: number[]): number[];
3694
4074
 
3695
4075
  export function getInversionSolver(
3696
- p0: PlainPoint,
3697
- p1: PlainPoint,
3698
- p2: PlainPoint,
3699
- p3: PlainPoint
4076
+ p0: PointInit,
4077
+ p1: PointInit,
4078
+ p2: PointInit,
4079
+ p3: PointInit
3700
4080
  ): (p: PlainPoint) => number;
3701
4081
  }
3702
4082
 
@@ -3882,7 +4262,7 @@ export declare namespace highlighters {
3882
4262
  position?: Positions | dia.PositionName;
3883
4263
  size?: number | dia.Size;
3884
4264
  gap?: number;
3885
- margin?: number | dia.Sides;
4265
+ margin?: dia.Sides;
3886
4266
  }
3887
4267
  }
3888
4268
 
@@ -3931,7 +4311,7 @@ export declare namespace layout {
3931
4311
  angle: number;
3932
4312
  };
3933
4313
 
3934
- export type LayoutFunction = (ports: Array<Object>, elBBox: g.Rect, opt: Options) => Array<Transformation>;
4314
+ export type LayoutFunction = (ports: Array<dia.Element.Port>, elBBox: g.Rect, opt: Options) => Array<Transformation>;
3935
4315
 
3936
4316
  export interface Options {
3937
4317
  x?: number | string;
@@ -3944,9 +4324,11 @@ export declare namespace layout {
3944
4324
  startAngle?: number;
3945
4325
  step?: number;
3946
4326
  compensateRotation?: boolean;
4327
+ [key: string]: any;
3947
4328
  }
3948
4329
 
3949
4330
  var absolute: LayoutFunction;
4331
+ /** @deprecated */
3950
4332
  var fn: LayoutFunction;
3951
4333
  var line: LayoutFunction;
3952
4334
  var left: LayoutFunction;
@@ -3965,6 +4347,7 @@ export declare namespace layout {
3965
4347
  angle?: number;
3966
4348
  offset?: number;
3967
4349
  attrs?: dia.Cell.Selectors;
4350
+ [key: string]: any;
3968
4351
  }
3969
4352
 
3970
4353
  export interface LabelAttributes {
@@ -4201,7 +4584,7 @@ export declare namespace linkTools {
4201
4584
 
4202
4585
  export namespace Boundary {
4203
4586
  export interface Options extends dia.ToolView.Options<dia.LinkView> {
4204
- padding?: number | dia.Sides;
4587
+ padding?: dia.Sides;
4205
4588
  useModelGeometry?: boolean;
4206
4589
  }
4207
4590
  }
@@ -4411,6 +4794,7 @@ export declare namespace mvc {
4411
4794
 
4412
4795
  export interface ModelConstructorOptions<TModel extends Model = Model> extends ModelSetOptions, Parseable {
4413
4796
  collection?: Collection<TModel> | undefined;
4797
+ eventPrefix?: string | undefined;
4414
4798
  }
4415
4799
 
4416
4800
  export type CombinedModelConstructorOptions<E, M extends Model<any, any, E> = Model> = ModelConstructorOptions<M> & E;
@@ -4699,6 +5083,7 @@ export declare namespace mvc {
4699
5083
  collection?: Collection<any> | undefined; // was: Collection<TModel>;
4700
5084
  el?: $Element<TElement> | string | undefined;
4701
5085
  id?: string | undefined;
5086
+ cid?: string | undefined;
4702
5087
  attributes?: Record<string, any> | undefined;
4703
5088
  className?: string | undefined;
4704
5089
  tagName?: string | undefined;
@@ -4741,9 +5126,9 @@ export declare namespace mvc {
4741
5126
 
4742
5127
  el: TElement;
4743
5128
  attributes: Record<string, any>;
4744
- /* @deprecated use `el` instead */
5129
+ /** @deprecated use `el` instead */
4745
5130
  $el: Dom;
4746
- /* @deprecated use `el.querySelector()` instead */
5131
+ /** @deprecated use `el.querySelector()` instead */
4747
5132
  $(selector: string): Dom;
4748
5133
  render(): this;
4749
5134
  remove(): this;
@@ -5555,6 +5940,8 @@ export declare namespace util {
5555
5940
 
5556
5941
  export function merge(destinationObject: object, ...args: any[]): object;
5557
5942
 
5943
+ export type MergeCustomizer = (value: any, srcValue: any, key: string, object: any, source: any, stack: any) => any;
5944
+
5558
5945
  // ADDITIONAL SIMPLE UTIL FUNCTIONS:
5559
5946
 
5560
5947
  export function isBoolean(value: any): boolean;
@@ -5606,6 +5993,7 @@ export declare namespace Vectorizer {
5606
5993
  annotations?: TextAnnotation[];
5607
5994
  includeAnnotationIndices?: boolean;
5608
5995
  displayEmpty?: boolean;
5996
+ useNoBreakSpace?: boolean;
5609
5997
  }
5610
5998
 
5611
5999
  export interface GetBBoxOptions {
@@ -5627,6 +6015,10 @@ export declare namespace Vectorizer {
5627
6015
  attrs: { [key: string]: any };
5628
6016
  }
5629
6017
 
6018
+ export interface TransformToElementOptions {
6019
+ safe?: boolean;
6020
+ }
6021
+
5630
6022
  // modifiable Matrix. SVGMatrix doesn't allow set on properties or a constructor.
5631
6023
  export interface Matrix {
5632
6024
  a: number;
@@ -5696,7 +6088,7 @@ export declare class VElement {
5696
6088
  id: string;
5697
6089
  node: SVGElement;
5698
6090
 
5699
- getTransformToElement(toElem: SVGGElement | VElement): SVGMatrix;
6091
+ getTransformToElement(target: SVGElement | VElement, opt?: Vectorizer.TransformToElementOptions): SVGMatrix;
5700
6092
 
5701
6093
  transform(): SVGMatrix;
5702
6094
  transform(matrix: SVGMatrix | Vectorizer.Matrix, opt?: Vectorizer.TransformOptions): this;
@@ -5805,6 +6197,9 @@ declare interface VStatic {
5805
6197
 
5806
6198
  ensureId(node: SVGElement | VElement): string;
5807
6199
 
6200
+ /**
6201
+ * @deprecated Use regular spaces and rely on xml:space="preserve" instead.
6202
+ */
5808
6203
  sanitizeText(text: string): string;
5809
6204
 
5810
6205
  isUndefined(value: any): boolean;
@@ -5819,6 +6214,8 @@ declare interface VStatic {
5819
6214
 
5820
6215
  qualifyAttr(name: string): Vectorizer.QualifiedAttribute;
5821
6216
 
6217
+ getCommonAncestor(node1: SVGElement | VElement, node2: SVGElement | VElement): SVGElement | null;
6218
+
5822
6219
  transformStringToMatrix(transform: string): SVGMatrix;
5823
6220
 
5824
6221
  matrixToTransformString(matrix: SVGMatrix | Vectorizer.Matrix): string;