@visuallyjs/browser-ui-angular 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +0 -0
  2. package/css/visuallyjs-angular.css +39 -0
  3. package/esm2022/index.mjs +34 -0
  4. package/esm2022/lib/base.group.component.mjs +43 -0
  5. package/esm2022/lib/base.node.component.mjs +41 -0
  6. package/esm2022/lib/base.port.component.mjs +71 -0
  7. package/esm2022/lib/base.vertex.component.mjs +75 -0
  8. package/esm2022/lib/browser-ui-angular.module.mjs +133 -0
  9. package/esm2022/lib/charts/area.chart.component.mjs +55 -0
  10. package/esm2022/lib/charts/bar.chart.component.mjs +55 -0
  11. package/esm2022/lib/charts/bubble.chart.component.mjs +55 -0
  12. package/esm2022/lib/charts/column.chart.component.mjs +55 -0
  13. package/esm2022/lib/charts/line.chart.component.mjs +55 -0
  14. package/esm2022/lib/charts/pie.chart.component.mjs +55 -0
  15. package/esm2022/lib/charts/sankey.chart.component.mjs +74 -0
  16. package/esm2022/lib/charts/scatter.chart.component.mjs +55 -0
  17. package/esm2022/lib/charts/xy.chart.component.mjs +39 -0
  18. package/esm2022/lib/color.tag.component.mjs +86 -0
  19. package/esm2022/lib/common.mjs +2 -0
  20. package/esm2022/lib/controls-component.mjs +164 -0
  21. package/esm2022/lib/decorator-component.mjs +52 -0
  22. package/esm2022/lib/default-group-component.mjs +18 -0
  23. package/esm2022/lib/default-node-component.mjs +18 -0
  24. package/esm2022/lib/diagram-component.mjs +53 -0
  25. package/esm2022/lib/diagram-palette-component.mjs +82 -0
  26. package/esm2022/lib/edge.type.picker.component.mjs +46 -0
  27. package/esm2022/lib/export-controls-component.mjs +75 -0
  28. package/esm2022/lib/inspector.component.mjs +77 -0
  29. package/esm2022/lib/miniview-component.mjs +63 -0
  30. package/esm2022/lib/model.mjs +8 -0
  31. package/esm2022/lib/overlay-component.mjs +18 -0
  32. package/esm2022/lib/palette.component.mjs +86 -0
  33. package/esm2022/lib/shape.component.mjs +85 -0
  34. package/esm2022/lib/shape.palette.component.mjs +78 -0
  35. package/esm2022/lib/surface-component.mjs +286 -0
  36. package/esm2022/lib/vjs-service.mjs +176 -0
  37. package/esm2022/visuallyjs-browser-ui-angular.mjs +2 -0
  38. package/fesm2022/visuallyjs-browser-ui-angular.mjs +2235 -0
  39. package/fesm2022/visuallyjs-browser-ui-angular.mjs.map +1 -0
  40. package/index.d.ts +40 -0
  41. package/lib/base.group.component.d.ts +60 -0
  42. package/lib/base.node.component.d.ts +55 -0
  43. package/lib/base.port.component.d.ts +74 -0
  44. package/lib/base.vertex.component.d.ts +111 -0
  45. package/lib/browser-ui-angular.module.d.ts +35 -0
  46. package/lib/charts/area.chart.component.d.ts +43 -0
  47. package/lib/charts/bar.chart.component.d.ts +40 -0
  48. package/lib/charts/bubble.chart.component.d.ts +40 -0
  49. package/lib/charts/column.chart.component.d.ts +40 -0
  50. package/lib/charts/line.chart.component.d.ts +39 -0
  51. package/lib/charts/pie.chart.component.d.ts +40 -0
  52. package/lib/charts/sankey.chart.component.d.ts +59 -0
  53. package/lib/charts/scatter.chart.component.d.ts +40 -0
  54. package/lib/charts/xy.chart.component.d.ts +32 -0
  55. package/lib/color.tag.component.d.ts +35 -0
  56. package/lib/common.d.ts +68 -0
  57. package/lib/controls-component.d.ts +71 -0
  58. package/lib/decorator-component.d.ts +25 -0
  59. package/lib/default-group-component.d.ts +11 -0
  60. package/lib/default-node-component.d.ts +11 -0
  61. package/lib/diagram-component.d.ts +52 -0
  62. package/lib/diagram-palette-component.d.ts +92 -0
  63. package/lib/edge.type.picker.component.d.ts +35 -0
  64. package/lib/export-controls-component.d.ts +59 -0
  65. package/lib/inspector.component.d.ts +96 -0
  66. package/lib/miniview-component.d.ts +45 -0
  67. package/lib/model.d.ts +8 -0
  68. package/lib/overlay-component.d.ts +59 -0
  69. package/lib/palette.component.d.ts +94 -0
  70. package/lib/shape.component.d.ts +70 -0
  71. package/lib/shape.palette.component.d.ts +73 -0
  72. package/lib/surface-component.d.ts +149 -0
  73. package/lib/vjs-service.d.ts +71 -0
  74. package/package.json +29 -0
  75. package/visuallyjs-browser-ui-angular.tgz +0 -0
@@ -0,0 +1,78 @@
1
+ import { Component, ElementRef, inject, Input } from "@angular/core";
2
+ import { ShapePalette, ShapeLibraryDefaults } from "@visuallyjs/browser-ui";
3
+ import { VisuallyJsService } from "./vjs-service";
4
+ import * as i0 from "@angular/core";
5
+
6
+ export class ShapePaletteComponent {
7
+ constructor() {
8
+
9
+ this.dragSize = { width: 150, height: 100 };
10
+
11
+ this.iconSize = { width: 150, height: 100 };
12
+
13
+ this.fill = ShapeLibraryDefaults.FILL;
14
+
15
+ this.outline = ShapeLibraryDefaults.STROKE;
16
+
17
+ this.showAllMessage = "Show all";
18
+
19
+ this.selectAfterDrop = true;
20
+
21
+ this.paletteStrokeWidth = 1;
22
+
23
+ this.dataGenerator = undefined;
24
+ this.$el = inject(ElementRef);
25
+ this.$vjs = inject(VisuallyJsService);
26
+ }
27
+ ngAfterViewInit() {
28
+ this.$vjs.getUI((ui) => {
29
+
30
+ new ShapePalette(ui, {
31
+ container: this.$el.nativeElement,
32
+ initialSet: this.initialSet,
33
+ dragSize: this.dragSize,
34
+ iconSize: this.iconSize,
35
+ fill: this.fill,
36
+ outline: this.outline,
37
+ shapeLibrary: ui.getShapeLibrary(),
38
+ showAllMessage: this.showAllMessage,
39
+ selectAfterDrop: this.selectAfterDrop,
40
+ paletteStrokeWidth: this.paletteStrokeWidth,
41
+ dataGenerator: this.dataGenerator,
42
+ onVertexAdded: this.onVertexAdded,
43
+ preparedShapes: this.preparedShapes
44
+ });
45
+ });
46
+ }
47
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ShapePaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
48
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ShapePaletteComponent, selector: "vjs-shape-palette", inputs: { initialSet: "initialSet", dragSize: "dragSize", iconSize: "iconSize", fill: "fill", outline: "outline", showAllMessage: "showAllMessage", selectAfterDrop: "selectAfterDrop", paletteStrokeWidth: "paletteStrokeWidth", onVertexAdded: "onVertexAdded", dataGenerator: "dataGenerator", preparedShapes: "preparedShapes" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
49
+ }
50
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ShapePaletteComponent, decorators: [{
51
+ type: Component,
52
+ args: [{
53
+ template: `<div></div>`,
54
+ selector: `vjs-shape-palette`
55
+ }]
56
+ }], propDecorators: { initialSet: [{
57
+ type: Input
58
+ }], dragSize: [{
59
+ type: Input
60
+ }], iconSize: [{
61
+ type: Input
62
+ }], fill: [{
63
+ type: Input
64
+ }], outline: [{
65
+ type: Input
66
+ }], showAllMessage: [{
67
+ type: Input
68
+ }], selectAfterDrop: [{
69
+ type: Input
70
+ }], paletteStrokeWidth: [{
71
+ type: Input
72
+ }], onVertexAdded: [{
73
+ type: Input
74
+ }], dataGenerator: [{
75
+ type: Input
76
+ }], preparedShapes: [{
77
+ type: Input
78
+ }] } });
@@ -0,0 +1,286 @@
1
+ import { Component, ElementRef, EventEmitter, Input, NgZone, Output, ViewContainerRef, inject, reflectComponentType } from "@angular/core";
2
+ import { EVENT_EDGE_UPDATED, EVENT_GROUP_UPDATED, EVENT_NODE_UPDATED, EVENT_PORT_ADDED, EVENT_PORT_UPDATED, extend, renderSurface, CustomOverlay, isGroup, EVENT_INTERNAL_CONNECTION, EVENT_DATA_LOAD_END, ELEMENT_DIV } from "@visuallyjs/browser-ui";
3
+ import { AngularComponentOverlayType, } from "./overlay-component";
4
+ import { DefaultGroupComponent } from "./default-group-component";
5
+ import { DefaultNodeComponent } from "./default-node-component";
6
+ import { BasePortComponent } from "./base.port.component";
7
+ import { VisuallyJsService } from "./vjs-service";
8
+ import { BrowserUIAngularModel } from "./model";
9
+ import * as i0 from "@angular/core";
10
+
11
+ export class SurfaceComponent {
12
+ constructor() {
13
+
14
+ this.vertexEvent = new EventEmitter();
15
+ this.$el = inject(ElementRef);
16
+ this.$viewContainerRef = inject(ViewContainerRef);
17
+ this.$ngZone = inject(NgZone);
18
+ this.$vjs = inject(VisuallyJsService);
19
+ }
20
+
21
+ getNativeElement(component) {
22
+ return component.location.nativeElement.childNodes[0];
23
+ }
24
+ _getComponent(el, tryParent) {
25
+ if (el == null) {
26
+ return null;
27
+ }
28
+ else {
29
+ let vjc = el._visuallyJsNgComponent;
30
+ if (vjc == null && tryParent && el.parentNode != null) {
31
+ vjc = el.parentNode._visuallyJsNgComponent;
32
+ }
33
+ return vjc;
34
+ }
35
+ }
36
+ _getComponentThen(el, then, tryParent) {
37
+ const c = this._getComponent(el, tryParent);
38
+ if (c != null) {
39
+ then(c);
40
+ }
41
+ }
42
+
43
+ nodeOrGroupUpdated(params) {
44
+ const info = this.surface.getObjectInfo(params.vertex, false);
45
+ this._getComponentThen(info.el, (component) => {
46
+ component.data = params.vertex.data;
47
+ component.$data?.set(component.data);
48
+ if (component.changeDetectorRef) {
49
+ component.changeDetectorRef.detectChanges();
50
+ }
51
+ }, false);
52
+ }
53
+ portUpdated(params) {
54
+ const info = this.surface.getObjectInfo(params.port, false);
55
+ this._getComponentThen(info.el, (component) => {
56
+ if (component instanceof BasePortComponent) {
57
+ component.data = params.port.data;
58
+ if (component.changeDetectorRef) {
59
+ component.changeDetectorRef.detectChanges();
60
+ }
61
+ }
62
+ }, true);
63
+ }
64
+
65
+ edgeUpdated(params) {
66
+ const connection = this.surface.getRenderedConnection(params.edge.id);
67
+ if (connection) {
68
+ for (let id in connection.overlays) {
69
+ const canvas = connection.overlays[id].contentElement;
70
+ this._getComponentThen(canvas, (component) => {
71
+ if (component.changeDetectorRef != null) {
72
+ component.changeDetectorRef.detectChanges();
73
+ }
74
+ }, false);
75
+ }
76
+ }
77
+ }
78
+
79
+ _processAngularOverlays(view) {
80
+ const self = this;
81
+ const edgeTypes = view.edges || {};
82
+ for (let edgeTypeId in edgeTypes) {
83
+ const edgeType = edgeTypes[edgeTypeId];
84
+ if (edgeType.overlays != null) {
85
+ edgeType.overlays = edgeType.overlays.map((o) => {
86
+ if (typeof o === "string") {
87
+ return o;
88
+ }
89
+ else {
90
+ const fo = o;
91
+ if (fo.type === AngularComponentOverlayType) {
92
+ const newSpec = Object.assign(fo, {
93
+ type: CustomOverlay.type,
94
+ });
95
+ newSpec.options = (newSpec.options || {});
96
+ newSpec.options.create = (connection) => {
97
+ const el = document.createElement(ELEMENT_DIV);
98
+ let createdComponent = self.$viewContainerRef.createComponent(newSpec.options.component);
99
+ let angularOverlayComponent = createdComponent.instance;
100
+ let nativeEl = createdComponent.location.nativeElement.childNodes[0];
101
+ el.appendChild(nativeEl);
102
+ el._visuallyJsNgComponent = angularOverlayComponent;
103
+
104
+ if (connection != null) {
105
+ const edge = connection.edge;
106
+ angularOverlayComponent.edge = edge;
107
+ angularOverlayComponent.data = edge.data;
108
+ }
109
+ angularOverlayComponent.model = self.model;
110
+ angularOverlayComponent.surface = self.surface;
111
+ createdComponent.changeDetectorRef.detectChanges();
112
+ return el;
113
+ };
114
+ return newSpec;
115
+ }
116
+ else {
117
+ return fo;
118
+ }
119
+ }
120
+ });
121
+ }
122
+ }
123
+ return view;
124
+ }
125
+
126
+ save(options) {
127
+ this.surface.save(options);
128
+ }
129
+
130
+ exportData(options) {
131
+ return this.surface.model.exportData(options);
132
+ }
133
+
134
+ dataLoadEnd() {
135
+ setTimeout(() => {
136
+ if (this.surface != null) {
137
+ this.surface.repaintEverything();
138
+ }
139
+ }, 0);
140
+ }
141
+ $removeNgElement(el) {
142
+ if (el._ref != null) {
143
+ el._ref.destroy();
144
+ }
145
+ if (el.parentNode != null) {
146
+ el.parentNode.removeChild(el);
147
+ }
148
+ }
149
+
150
+ ngAfterViewInit() {
151
+ this.$ngZone.runOutsideAngular(() => {
152
+ const view = this._processAngularOverlays(this.viewOptions || {});
153
+ const self = this;
154
+ this.renderOptions = this.renderOptions || {};
155
+ const render = (directiveId, data, instance, objectType, surface, def, modelObject, eventInfo) => {
156
+ let component;
157
+ if (def.component == null) {
158
+ if (isGroup(modelObject)) {
159
+ component = DefaultGroupComponent;
160
+ }
161
+ else {
162
+ component = DefaultNodeComponent;
163
+ }
164
+ }
165
+ else {
166
+ component = def.component;
167
+ }
168
+ let createdComponent = self.$viewContainerRef.createComponent(component);
169
+ let _componentRef = createdComponent.instance;
170
+ _componentRef.data = data || {};
171
+ _componentRef.model = model;
172
+ _componentRef.surface = surface;
173
+ _componentRef.modelObject = modelObject;
174
+ // get the reflection data for the component
175
+ const componentInfo = reflectComponentType(component);
176
+ // ..and populate any declared inputs from data
177
+ componentInfo.inputs.forEach((pt) => {
178
+ const pv = _componentRef.data[pt.propName];
179
+ if (pv != null) {
180
+ _componentRef[pt.propName] = pv;
181
+ }
182
+ });
183
+ // map to any outputs
184
+ componentInfo.outputs.forEach((pt) => {
185
+ _componentRef[pt.propName].subscribe((d) => self.vertexEvent.emit({
186
+ vertex: modelObject,
187
+ event: pt.propName,
188
+ payload: d,
189
+ component: createdComponent,
190
+ }));
191
+ });
192
+ // if angular def has 'inputs' set, set them on the component. this is different to the mechanism above, in which values are extracted from
193
+ // each node's backing data. here we inject values either as a string or from some arbitrary function.
194
+ if (def.inputs != null) {
195
+ for (let k in def.inputs) {
196
+ const v = def.inputs[k];
197
+ const value = typeof v === "string" ? v : v(modelObject);
198
+ _componentRef[k] = value;
199
+ }
200
+ }
201
+ createdComponent.changeDetectorRef.detectChanges();
202
+ // TODO this should not be necessary
203
+ const nativeElement = self.getNativeElement(createdComponent);
204
+ _componentRef._el = nativeElement;
205
+ _componentRef._el._visuallyJsNgComponent = _componentRef;
206
+ _componentRef._el._ref = createdComponent; // we store _ref so we can call `destroy` on it later if the node is removed.
207
+ surface.$vertexRendered(modelObject, nativeElement, def, eventInfo);
208
+ };
209
+ const templateRenderer = {
210
+ asynchronous: false,
211
+ reactive: true,
212
+ usesWrapperElement: false,
213
+ update: (el, data, v, renderer) => { },
214
+ render,
215
+ rerender: (directiveId, data, instance, objectType, surface, def, modelObject, eventInfo, originalElement) => {
216
+ this.$removeNgElement(originalElement);
217
+ render(directiveId, data, instance, objectType, surface, def, modelObject, eventInfo);
218
+ },
219
+ cleanupVertex: (objId, el) => {
220
+ this.$removeNgElement(el);
221
+ },
222
+ cleanupPort: (objId, el) => {
223
+ this.$removeNgElement(el);
224
+ },
225
+ };
226
+ const renderParams = extend(this.renderOptions || {}, {
227
+ view: view,
228
+ });
229
+ let model = new BrowserUIAngularModel(this.modelOptions);
230
+ this.model = model;
231
+ this.surface = renderSurface(model, self.$el.nativeElement, templateRenderer, renderParams);
232
+ //this.$service.addSurface(this.surfaceId, this.surface);
233
+ // new
234
+ this.$vjs.$setSurface(this.surface);
235
+ // ----------------
236
+ this.nodeUpdateFn = this.nodeOrGroupUpdated.bind(this);
237
+ model.bind(EVENT_NODE_UPDATED, this.nodeUpdateFn);
238
+ model.bind(EVENT_PORT_ADDED, this.nodeUpdateFn);
239
+ model.bind(EVENT_GROUP_UPDATED, this.nodeUpdateFn);
240
+ this.dataLoadEndFn = this.dataLoadEnd.bind(this);
241
+ model.bind(EVENT_DATA_LOAD_END, this.dataLoadEndFn);
242
+ this.portUpdateFn = this.portUpdated.bind(this);
243
+ model.bind(EVENT_PORT_UPDATED, this.portUpdateFn);
244
+ this.edgeUpdateFn = this.edgeUpdated.bind(this);
245
+ model.bind(EVENT_EDGE_UPDATED, this.edgeUpdateFn);
246
+ if (this.data) {
247
+ this.model.load({ data: this.data });
248
+ }
249
+ else if (this.url) {
250
+ this.model.load({ url: this.url });
251
+ }
252
+ });
253
+ }
254
+
255
+ ngOnDestroy() {
256
+ this.surface.destroy();
257
+ this.model.unbind(EVENT_NODE_UPDATED, this.nodeUpdateFn);
258
+ this.model.unbind(EVENT_GROUP_UPDATED, this.nodeUpdateFn);
259
+ this.model.unbind(EVENT_PORT_ADDED, this.nodeUpdateFn);
260
+ this.model.unbind(EVENT_PORT_UPDATED, this.portUpdateFn);
261
+ this.model.unbind(EVENT_EDGE_UPDATED, this.edgeUpdateFn);
262
+ this.model.unbind(EVENT_DATA_LOAD_END, this.dataLoadEndFn);
263
+ this.surface.unbind(EVENT_INTERNAL_CONNECTION, this.edgeAddFn);
264
+ }
265
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SurfaceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
266
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SurfaceComponent, selector: "vjs-surface", inputs: { viewOptions: "viewOptions", renderOptions: "renderOptions", modelOptions: "modelOptions", data: "data", url: "url" }, outputs: { vertexEvent: "vertexEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true }); }
267
+ }
268
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SurfaceComponent, decorators: [{
269
+ type: Component,
270
+ args: [{
271
+ selector: "vjs-surface",
272
+ template: `<ng-content></ng-content>`
273
+ }]
274
+ }], propDecorators: { viewOptions: [{
275
+ type: Input
276
+ }], renderOptions: [{
277
+ type: Input
278
+ }], modelOptions: [{
279
+ type: Input
280
+ }], data: [{
281
+ type: Input
282
+ }], url: [{
283
+ type: Input
284
+ }], vertexEvent: [{
285
+ type: Output
286
+ }] } });
@@ -0,0 +1,176 @@
1
+ import { log, Paper, Surface } from "@visuallyjs/browser-ui";
2
+ import { Injectable } from "@angular/core";
3
+ import * as i0 from "@angular/core";
4
+
5
+ export class VisuallyJsService {
6
+ constructor() {
7
+ this.inspectorListeners = [];
8
+ this.surfaceListeners = [];
9
+ this.paperListeners = [];
10
+ this.modelListeners = [];
11
+ this.diagramListeners = [];
12
+ this.uiListeners = [];
13
+ }
14
+ $setInspector(i) {
15
+ this.$inspector = i;
16
+ this.$notifyInspector();
17
+ }
18
+ $notifyInspector() {
19
+ this.inspectorListeners.forEach(sl => {
20
+ try {
21
+ sl(this.$inspector);
22
+ }
23
+ catch (e) {
24
+ log(`WARN: could not notify Inspector listener ${e}`);
25
+ }
26
+ });
27
+ this.inspectorListeners.length = 0;
28
+ }
29
+ $setSurface(s) {
30
+ // @ts-ignore
31
+ this.$setModel(s.model);
32
+ this.$surface = s;
33
+ this.$notifySurface();
34
+ }
35
+ $notifySurface() {
36
+ this.surfaceListeners.forEach(sl => {
37
+ try {
38
+ sl(this.$surface);
39
+ }
40
+ catch (e) {
41
+ log(`WARN: could not notify Surface listener ${e}`);
42
+ }
43
+ });
44
+ this.surfaceListeners.length = 0;
45
+ this.$notifyUI(this.$surface);
46
+ }
47
+
48
+ getSurface(cb) {
49
+ if (this.$surface != null) {
50
+ cb(this.$surface);
51
+ }
52
+ else {
53
+ this.surfaceListeners.push(cb);
54
+ }
55
+ }
56
+
57
+ getInspector(cb) {
58
+ if (this.$inspector != null) {
59
+ cb(this.$inspector);
60
+ }
61
+ else {
62
+ this.inspectorListeners.push(cb);
63
+ }
64
+ }
65
+ $setPaper(p) {
66
+ // @ts-ignore
67
+ this.$setModel(p.model);
68
+ this.$paper = p;
69
+ this.$notifyPaper();
70
+ }
71
+ $notifyPaper() {
72
+ this.paperListeners.forEach(sl => {
73
+ try {
74
+ sl(this.$paper);
75
+ }
76
+ catch (e) {
77
+ log(`WARN: could not notify Paper listener ${e}`);
78
+ }
79
+ });
80
+ this.paperListeners.length = 0;
81
+ this.$notifyUI(this.$paper);
82
+ }
83
+
84
+ getPaper(cb) {
85
+ if (this.$paper != null) {
86
+ cb(this.$paper);
87
+ }
88
+ else {
89
+ this.paperListeners.push(cb);
90
+ }
91
+ }
92
+ $setDiagram(d) {
93
+ this.$diagram = d;
94
+ if (d.$ui instanceof Surface) {
95
+ this.$setSurface(d.$ui);
96
+ }
97
+ if (d.$ui instanceof Paper) {
98
+ this.$setPaper(d.$ui);
99
+ }
100
+ this.$notifyDiagram();
101
+ }
102
+ $notifyDiagram() {
103
+ this.diagramListeners.forEach(sl => {
104
+ try {
105
+ sl(this.$diagram);
106
+ }
107
+ catch (e) {
108
+ log(`WARN: could not notify Diagram listener ${e}`);
109
+ }
110
+ });
111
+ this.diagramListeners.length = 0;
112
+ }
113
+
114
+ getDiagram(cb) {
115
+ if (this.$diagram != null) {
116
+ cb(this.$diagram);
117
+ }
118
+ else {
119
+ this.diagramListeners.push(cb);
120
+ }
121
+ }
122
+
123
+ getModel(cb) {
124
+ if (this.$model != null) {
125
+ cb(this.$model);
126
+ }
127
+ else {
128
+ this.modelListeners.push(cb);
129
+ }
130
+ }
131
+
132
+ $setModel(m) {
133
+ this.$model = m;
134
+ this.$notifyModel();
135
+ }
136
+ $notifyModel() {
137
+ this.modelListeners.forEach(sl => {
138
+ try {
139
+ sl(this.$model);
140
+ }
141
+ catch (e) {
142
+ log(`WARN: could not notify Model listener ${e}`);
143
+ }
144
+ });
145
+ this.modelListeners.length = 0;
146
+ }
147
+ $notifyUI(ui) {
148
+ this.uiListeners.forEach(sl => {
149
+ try {
150
+ sl(ui);
151
+ }
152
+ catch (e) {
153
+ log(`WARN: could not notify UI listener ${e}`);
154
+ }
155
+ });
156
+ this.uiListeners.length = 0;
157
+ }
158
+
159
+ getUI(cb) {
160
+ const ui = this.$surface || this.$paper;
161
+ if (ui != null) {
162
+ cb(ui);
163
+ }
164
+ else {
165
+ this.uiListeners.push(cb);
166
+ }
167
+ }
168
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VisuallyJsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
169
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VisuallyJsService, providedIn: 'root' }); }
170
+ }
171
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VisuallyJsService, decorators: [{
172
+ type: Injectable,
173
+ args: [{
174
+ providedIn: 'root',
175
+ }]
176
+ }] });
@@ -0,0 +1,2 @@
1
+
2
+ export * from './index';