@linkurious/ogma-linkurious-parser 4.1.7 → 4.1.8

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 (46) hide show
  1. package/dist/index.cjs +4 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.ts +5 -5
  4. package/dist/index.mjs +4082 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/ogma/features/nodeGrouping.d.ts +15 -1
  7. package/dist/tools/ogmaTool.d.ts +3 -1
  8. package/package.json +23 -21
  9. package/dist/captions/captions.js +0 -115
  10. package/dist/captions/captions.js.map +0 -1
  11. package/dist/filters/filters.js +0 -167
  12. package/dist/filters/filters.js.map +0 -1
  13. package/dist/index.js +0 -56
  14. package/dist/index.js.map +0 -1
  15. package/dist/ogma/features/OgmaStore.js +0 -37
  16. package/dist/ogma/features/OgmaStore.js.map +0 -1
  17. package/dist/ogma/features/captions.js +0 -117
  18. package/dist/ogma/features/captions.js.map +0 -1
  19. package/dist/ogma/features/nodeGrouping.js +0 -283
  20. package/dist/ogma/features/nodeGrouping.js.map +0 -1
  21. package/dist/ogma/features/reactive.js +0 -132
  22. package/dist/ogma/features/reactive.js.map +0 -1
  23. package/dist/ogma/features/selectors.js +0 -97
  24. package/dist/ogma/features/selectors.js.map +0 -1
  25. package/dist/ogma/features/styles.js +0 -689
  26. package/dist/ogma/features/styles.js.map +0 -1
  27. package/dist/ogma/features/transformations.js +0 -86
  28. package/dist/ogma/features/transformations.js.map +0 -1
  29. package/dist/ogma/index.js +0 -326
  30. package/dist/ogma/index.js.map +0 -1
  31. package/dist/styles/edgeAttributes.js +0 -115
  32. package/dist/styles/edgeAttributes.js.map +0 -1
  33. package/dist/styles/itemAttributes.js +0 -133
  34. package/dist/styles/itemAttributes.js.map +0 -1
  35. package/dist/styles/nodeAttributes.js +0 -228
  36. package/dist/styles/nodeAttributes.js.map +0 -1
  37. package/dist/styles/styleRule.js +0 -194
  38. package/dist/styles/styleRule.js.map +0 -1
  39. package/dist/styles/styleRules.js +0 -292
  40. package/dist/styles/styleRules.js.map +0 -1
  41. package/dist/tools/colorPalette.js +0 -145
  42. package/dist/tools/colorPalette.js.map +0 -1
  43. package/dist/tools/ogmaTool.js +0 -86
  44. package/dist/tools/ogmaTool.js.map +0 -1
  45. package/dist/tools/tools.js +0 -409
  46. package/dist/tools/tools.js.map +0 -1
@@ -1,117 +0,0 @@
1
- 'use strict';
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CaptionsViz = void 0;
13
- const __1 = require("../..");
14
- const tools_1 = require("../../tools/tools");
15
- class CaptionsViz {
16
- constructor(ogma, _nodeMaxTextLength, _edgeMaxTextLength) {
17
- this._nodeMaxTextLength = _nodeMaxTextLength;
18
- this._edgeMaxTextLength = _edgeMaxTextLength;
19
- this._captionSchema = { node: {}, edge: {} };
20
- this._graphSchema = { node: [], edge: [] };
21
- this._ogma = ogma;
22
- }
23
- set graphSchema(graphSchema) {
24
- this._graphSchema = graphSchema;
25
- }
26
- /**
27
- * Refresh the schema
28
- */
29
- refreshSchema(schema) {
30
- this._captionSchema = schema;
31
- }
32
- /**
33
- * Refresh visualization captions rules
34
- */
35
- initVizCaptions(schema) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- if (this._ogma.LKCaptions.nodesCaptionsRule) {
38
- this._ogma.LKCaptions.refreshSchema(schema);
39
- yield this._ogma.LKCaptions.updateNodeCaptions();
40
- }
41
- else {
42
- this._ogma.LKCaptions.updateNodeCaptions(schema.node);
43
- }
44
- if (this._ogma.LKCaptions.edgesCaptionsRule) {
45
- this._ogma.LKCaptions.refreshSchema(schema);
46
- yield this._ogma.LKCaptions.updateEdgeCaptions();
47
- }
48
- else {
49
- this._ogma.LKCaptions.updateEdgeCaptions(schema.edge);
50
- }
51
- });
52
- }
53
- /**
54
- * Create or update nodeCaptionRule
55
- */
56
- updateNodeCaptions(schema) {
57
- if (schema) {
58
- this._captionSchema.node = schema;
59
- }
60
- if (!tools_1.Tools.isDefined(this.nodesCaptionsRule)) {
61
- this.nodesCaptionsRule = this._ogma.styles.addRule({
62
- nodeAttributes: {
63
- text: {
64
- content: (node) => {
65
- if (node === undefined) {
66
- return ``;
67
- }
68
- const value = __1.Captions.getText(node.getData(), this._captionSchema.node, this._graphSchema.node);
69
- return tools_1.Tools.isDefined(this._nodeMaxTextLength)
70
- ? tools_1.Tools.truncate(value, 'middle', this._nodeMaxTextLength)
71
- : value;
72
- }
73
- }
74
- },
75
- // We ignore virtual nodes as they have their proper caption
76
- nodeSelector: (node) => !node.isVirtual(),
77
- nodeDependencies: { self: { data: true } }
78
- });
79
- }
80
- else {
81
- return this.nodesCaptionsRule.refresh();
82
- }
83
- }
84
- /**
85
- * Create or update edgeCaptionRule
86
- */
87
- updateEdgeCaptions(schema) {
88
- if (schema) {
89
- this._captionSchema.edge = schema;
90
- }
91
- if (!tools_1.Tools.isDefined(this.edgesCaptionsRule)) {
92
- this.edgesCaptionsRule = this._ogma.styles.addRule({
93
- edgeAttributes: {
94
- text: {
95
- content: (edge) => {
96
- if (edge === undefined || edge.getData() === undefined) {
97
- return ``;
98
- }
99
- const value = __1.Captions.getText(edge.getData(), this._captionSchema.edge, this._graphSchema.edge);
100
- return tools_1.Tools.isDefined(this._edgeMaxTextLength)
101
- ? tools_1.Tools.truncate(value, 'middle', this._edgeMaxTextLength)
102
- : value;
103
- }
104
- }
105
- },
106
- edgeSelector: (edge) => !edge.isVirtual(),
107
- // ogma will trigger the rendering if data change or the shape change (to trigger the rendering when edges are grouped)
108
- edgeDependencies: { self: { data: true, attributes: ['shape.style'] } }
109
- });
110
- }
111
- else {
112
- return this.edgesCaptionsRule.refresh();
113
- }
114
- }
115
- }
116
- exports.CaptionsViz = CaptionsViz;
117
- //# sourceMappingURL=captions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captions.js","sourceRoot":"","sources":["../../../src/ogma/features/captions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;AAKb,6BAAuC;AACvC,6CAAwC;AAOxC,MAAa,WAAW;IAUtB,YACE,IAAY,EACJ,kBAAsC,EACtC,kBAAsC;QADtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QATxC,mBAAc,GAAiB,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CAAC;QACpD,iBAAY,GAGhB,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CAAC;QAOvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,IAAW,WAAW,CAAC,WAGtB;QACC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,aAAa,CAAC,MAAoB;QACvC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IAC/B,CAAC;IAED;;OAEG;IACU,eAAe,CAAC,MAAoB;;YAC/C,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;gBAC5C,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;gBAC5C,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC;YACnD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,MAAM,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AAE;gBACzC,uHAAuH;gBACvH,gBAAgB,EAAE,EAAC,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,aAAa,CAAC,EAAC,EAAC;aACpE,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;QAC1C,CAAC;IACH,CAAC;CACF;AAvHD,kCAuHC","sourcesContent":["'use strict';\n\nimport * as Ogma from '@linkurious/ogma';\nimport {GraphSchemaTypeWithAccess, ItemFieldsCaptions} from '@linkurious/rest-client';\n\nimport {Captions, LKOgma} from '../..';\nimport {Tools} from '../../tools/tools';\n\nexport interface CaptionState {\n node: ItemFieldsCaptions;\n edge: ItemFieldsCaptions;\n}\n\nexport class CaptionsViz {\n public nodesCaptionsRule!: Ogma.StyleRule;\n public edgesCaptionsRule!: Ogma.StyleRule;\n private _ogma: LKOgma;\n private _captionSchema: CaptionState = {node: {}, edge: {}};\n private _graphSchema: {\n node: Array<GraphSchemaTypeWithAccess>;\n edge: Array<GraphSchemaTypeWithAccess>;\n } = {node: [], edge: []};\n\n constructor(\n ogma: LKOgma,\n private _nodeMaxTextLength: number | undefined,\n private _edgeMaxTextLength: number | undefined\n ) {\n this._ogma = ogma;\n }\n\n public set graphSchema(graphSchema: {\n node: Array<GraphSchemaTypeWithAccess>;\n edge: Array<GraphSchemaTypeWithAccess>;\n }) {\n this._graphSchema = graphSchema;\n }\n\n /**\n * Refresh the schema\n */\n public refreshSchema(schema: CaptionState): void {\n this._captionSchema = schema;\n }\n\n /**\n * Refresh visualization captions rules\n */\n public async initVizCaptions(schema: CaptionState): Promise<void> {\n if (this._ogma.LKCaptions.nodesCaptionsRule) {\n this._ogma.LKCaptions.refreshSchema(schema);\n await this._ogma.LKCaptions.updateNodeCaptions();\n } else {\n this._ogma.LKCaptions.updateNodeCaptions(schema.node);\n }\n if (this._ogma.LKCaptions.edgesCaptionsRule) {\n this._ogma.LKCaptions.refreshSchema(schema);\n await this._ogma.LKCaptions.updateEdgeCaptions();\n } else {\n this._ogma.LKCaptions.updateEdgeCaptions(schema.edge);\n }\n }\n\n /**\n * Create or update nodeCaptionRule\n */\n public updateNodeCaptions(schema?: ItemFieldsCaptions): Promise<void> | void {\n if (schema) {\n this._captionSchema.node = schema;\n }\n if (!Tools.isDefined(this.nodesCaptionsRule)) {\n this.nodesCaptionsRule = this._ogma.styles.addRule({\n nodeAttributes: {\n text: {\n content: (node: Ogma.Node | undefined) => {\n if (node === undefined) {\n return ``;\n }\n const value = Captions.getText(\n node.getData(),\n this._captionSchema.node,\n this._graphSchema.node\n );\n return Tools.isDefined(this._nodeMaxTextLength)\n ? Tools.truncate(value, 'middle', this._nodeMaxTextLength)\n : value;\n }\n }\n },\n // We ignore virtual nodes as they have their proper caption\n nodeSelector: (node) => !node.isVirtual(),\n nodeDependencies: {self: {data: true}}\n });\n } else {\n return this.nodesCaptionsRule.refresh();\n }\n }\n\n /**\n * Create or update edgeCaptionRule\n */\n public updateEdgeCaptions(schema?: ItemFieldsCaptions): Promise<void> | void {\n if (schema) {\n this._captionSchema.edge = schema;\n }\n if (!Tools.isDefined(this.edgesCaptionsRule)) {\n this.edgesCaptionsRule = this._ogma.styles.addRule({\n edgeAttributes: {\n text: {\n content: (edge: Ogma.Edge | undefined) => {\n if (edge === undefined || edge.getData() === undefined) {\n return ``;\n }\n const value = Captions.getText(\n edge.getData(),\n this._captionSchema.edge,\n this._graphSchema.edge\n );\n return Tools.isDefined(this._edgeMaxTextLength)\n ? Tools.truncate(value, 'middle', this._edgeMaxTextLength)\n : value;\n }\n }\n },\n edgeSelector: (edge) => !edge.isVirtual(),\n // ogma will trigger the rendering if data change or the shape change (to trigger the rendering when edges are grouped)\n edgeDependencies: {self: {data: true, attributes: ['shape.style']}}\n });\n } else {\n return this.edgesCaptionsRule.refresh();\n }\n }\n}\n"]}
@@ -1,283 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.NodeGroupingTransformation = exports.LKE_NODE_GROUPING_NODE = exports.LKE_NODE_GROUPING_EDGE = void 0;
16
- const sha1_1 = __importDefault(require("sha1"));
17
- const index_1 = require("../index");
18
- const tools_1 = require("../../tools/tools");
19
- exports.LKE_NODE_GROUPING_EDGE = 'LKE_NODE_GROUPING_EDGE';
20
- exports.LKE_NODE_GROUPING_NODE = 'LKE_NODE_GROUPING_NODE';
21
- class NodeGroupingTransformation {
22
- constructor(ogma) {
23
- this._ogma = ogma;
24
- }
25
- /**
26
- * Set the grouping rule
27
- * @param rule of grouping
28
- */
29
- setGroupingRule(rule) {
30
- this.groupRule = rule;
31
- }
32
- /**
33
- * create a node grouping transformation
34
- * It uses groupRule to define the rule
35
- * Group the nodes based on a category type and a property value
36
- */
37
- initTransformation() {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- if (this.transformation === undefined) {
40
- this.transformation = this._ogma.transformations.addNodeGrouping({
41
- groupIdFunction: (node) => {
42
- var _a;
43
- if (this._isRuleNotApplicableToNode(node)) {
44
- return undefined;
45
- }
46
- else {
47
- const propertyValue = this._findGroupingPropertyValue(node);
48
- // groupRule is defined if not we returned undefined
49
- // node with same value will be part of the same group
50
- return `${(_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.groupingOptions.itemTypes.join('-')}-${propertyValue}`
51
- .toLowerCase()
52
- .trim();
53
- }
54
- },
55
- nodeGenerator: (nodes) => {
56
- return {
57
- data: {
58
- categories: [exports.LKE_NODE_GROUPING_NODE],
59
- properties: {},
60
- nodeGroupId: this._findNodeGroupId(nodes)
61
- }
62
- };
63
- },
64
- edgeGenerator: () => {
65
- return {
66
- data: {
67
- type: exports.LKE_NODE_GROUPING_EDGE
68
- }
69
- };
70
- },
71
- showContents: true,
72
- padding: 10
73
- });
74
- }
75
- else {
76
- yield this.refreshTransformation();
77
- }
78
- });
79
- }
80
- /**
81
- * refresh the transformation
82
- * Called when there is a change in the rule
83
- */
84
- refreshTransformation() {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- if (this.transformation !== undefined) {
87
- yield this.transformation.refresh();
88
- yield this._unpinNodes(this._getAllTransformationRawNodes());
89
- }
90
- else {
91
- yield this.initTransformation();
92
- }
93
- });
94
- }
95
- /**
96
- * init node grouping style
97
- */
98
- initNodeGroupingStyle() {
99
- this.nodeGroupingStyleRule = this._ogma.styles.addRule({
100
- nodeAttributes: {
101
- // Any default style will go here
102
- text: {
103
- content: (node) => {
104
- return this._getNodeGroupingCaption(node);
105
- },
106
- style: 'bold'
107
- },
108
- layer: -1,
109
- color: 'rgba(240, 240, 240)',
110
- innerStroke: {
111
- color: '#7f7f7f',
112
- width: 2
113
- }
114
- },
115
- nodeSelector: (node) => {
116
- // TODO: Tools.isDefined(node.getSubNodes()) is a work around for an ogma issue visible when using image export plugin with Node grouping
117
- // remove when updating to Ogma v5.1.x
118
- return node.isVirtual() && tools_1.Tools.isDefined(node.getSubNodes());
119
- },
120
- // the style will be updated when data object is updated
121
- nodeDependencies: { self: { data: true } }
122
- });
123
- }
124
- refreshNodeGroupingStyle() {
125
- return __awaiter(this, void 0, void 0, function* () {
126
- var _a;
127
- yield ((_a = this.nodeGroupingStyleRule) === null || _a === void 0 ? void 0 : _a.refresh());
128
- });
129
- }
130
- /**
131
- * run layout on all subnodes of virtual nodes
132
- */
133
- runLayoutOnAllSubNodes() {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- yield this._ogma.transformations.afterNextUpdate();
136
- const rawNodesList = this._getAllTransformationRawNodes();
137
- const promisesList = [];
138
- for (let i = 0; i < rawNodesList.length; i++) {
139
- // rawNodesList[i] is not null because each group has at least one node
140
- const subNodes = rawNodesList[i];
141
- promisesList.push(this.runSubNodesLayout(subNodes));
142
- }
143
- yield Promise.all(promisesList);
144
- });
145
- }
146
- /**
147
- * Run the layout on the subnodes of the virtual node
148
- * @param subNodes nodes part of a virtual node
149
- */
150
- runSubNodesLayout(subNodes) {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- if (subNodes.size === 0 || subNodes.size === 1) {
153
- return;
154
- }
155
- const noEdges = subNodes.getAdjacentEdges({ bothExtremities: true }).size === 0;
156
- if (noEdges) {
157
- yield this._runCirclePack(subNodes);
158
- }
159
- else {
160
- yield this._runForceLayout(subNodes);
161
- }
162
- });
163
- }
164
- /**
165
- * Get the virtual nodes of the transformation
166
- * @private
167
- */
168
- getVirtualNodesOfTransformation() {
169
- // @ts-ignore getContext exists on the transformation but hidden by the types
170
- return this.transformation.getContext().metaNodes;
171
- }
172
- /**
173
- * Set the node group pin
174
- * @param nodeGroups object containing the node group id and the layoutable attribute
175
- */
176
- setNodeGroupPin(nodeGroups) {
177
- return __awaiter(this, void 0, void 0, function* () {
178
- this._ogma
179
- .getNodes()
180
- .filter((node) => node.isVirtual())
181
- .forEach((node) => {
182
- var _a;
183
- const nodeGroupInfo = nodeGroups.find((nodeGroup) => nodeGroup.id === node.getData('nodeGroupId'));
184
- if (nodeGroupInfo !== undefined) {
185
- void node.setAttribute('layoutable', (_a = nodeGroupInfo.attributes.layoutable) !== null && _a !== void 0 ? _a : false);
186
- }
187
- });
188
- });
189
- }
190
- /**
191
- * Return the caption of a virtual node
192
- * @param node reference to the virtual node
193
- */
194
- _getNodeGroupingCaption(node) {
195
- var _a;
196
- // TODO: Normally there is no need to check if getSubNodes return a value, Ogma issue
197
- //https://github.com/Linkurious/ogma/issues/3876
198
- if (node !== undefined && node.isVirtual() && ((_a = node.getSubNodes()) === null || _a === void 0 ? void 0 : _a.get(0)) !== undefined) {
199
- // get the property value of the first node of the group (all nodes share the same property value)
200
- const lkPropertyValue = node
201
- .getSubNodes()
202
- .get(0)
203
- .getData(['properties', this.groupRule.groupingOptions.propertyKey]);
204
- const propertyValue = tools_1.Tools.getValueFromLkProperty(lkPropertyValue);
205
- const size = node.getSubNodes().filter((e) => !e.hasClass('filtered')).size;
206
- return `${propertyValue} (${size})`;
207
- }
208
- }
209
- /**
210
- * Run the circle pack layout on the subnodes
211
- * @param subNodes
212
- */
213
- _runCirclePack(subNodes) {
214
- return __awaiter(this, void 0, void 0, function* () {
215
- yield this._ogma.algorithms.circlePack({
216
- nodes: subNodes,
217
- margin: 10,
218
- sort: 'asc'
219
- });
220
- });
221
- }
222
- _runForceLayout(subNodes) {
223
- return __awaiter(this, void 0, void 0, function* () {
224
- yield this._ogma.layouts.force(Object.assign({ nodes: subNodes }, index_1.FORCE_LAYOUT_CONFIG));
225
- });
226
- }
227
- _isRuleNotApplicableToNode(node) {
228
- var _a, _b;
229
- const propertyValue = node.getData([
230
- 'properties',
231
- (_b = (_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.groupingOptions.propertyKey) !== null && _b !== void 0 ? _b : ''
232
- ]);
233
- return (
234
- // if the group rule is not defined
235
- this.groupRule === undefined ||
236
- // if rule is applied to a different category
237
- this.groupRule.groupingOptions.itemTypes.every((itemType) => !node.getData('categories').includes(itemType)) ||
238
- // if the property value is not defined
239
- !tools_1.Tools.isDefined(propertyValue) ||
240
- // if the property value is missing
241
- (typeof propertyValue === 'object' && propertyValue.status === 'missing'));
242
- }
243
- /**
244
- * Unpin list of nodes
245
- * @param nodes
246
- * @private
247
- */
248
- _unpinNodes(nodes) {
249
- return __awaiter(this, void 0, void 0, function* () {
250
- yield Promise.all(nodes.map((nodeList) => {
251
- if (nodeList !== null) {
252
- return nodeList.setAttribute('layoutable', true);
253
- }
254
- }));
255
- });
256
- }
257
- /**
258
- * Get all the raw nodes part of the transformation
259
- * @private
260
- */
261
- _getAllTransformationRawNodes() {
262
- const virtualNodes = this.getVirtualNodesOfTransformation();
263
- return virtualNodes.getSubNodes();
264
- }
265
- _findGroupingPropertyValue(node) {
266
- var _a, _b;
267
- const propertyValue = node.getData([
268
- 'properties',
269
- (_b = (_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.groupingOptions.propertyKey) !== null && _b !== void 0 ? _b : ''
270
- ]);
271
- return `${tools_1.Tools.getValueFromLkProperty(propertyValue)}`;
272
- }
273
- /**
274
- * Return a hashed string that represents the group id
275
- */
276
- _findNodeGroupId(nodes) {
277
- var _a, _b;
278
- const propertyValue = this._findGroupingPropertyValue(nodes.get(0));
279
- return (0, sha1_1.default)(`${(_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.name}-${(_b = this.groupRule) === null || _b === void 0 ? void 0 : _b.groupingOptions.itemTypes.join('-')}-${propertyValue}`);
280
- }
281
- }
282
- exports.NodeGroupingTransformation = NodeGroupingTransformation;
283
- //# sourceMappingURL=nodeGrouping.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodeGrouping.js","sourceRoot":"","sources":["../../../src/ogma/features/nodeGrouping.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQA,gDAAwB;AAExB,oCAAqD;AACrD,6CAAwC;AAE3B,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,MAAa,0BAA0B;IAMrC,YAAY,IAAY;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,IAAkC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACU,kBAAkB;;YAC7B,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;gBACtC,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S,0CAAE,eAAe,CAAC,WAAW,mCAAI,EAAE;SAClD,CAAC,CAAC;QACH,OAAO,GAAG,aAAK,CAAC,sBAAsB,CAAC,aAAa,CAAC,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,KAAuC;;QAC9D,MAAM,aAAa,GAAG,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,OAAO,IAAA,cAAI,EACT,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,IAAI,IAAI,MAAA,IAAI,CAAC,SAAS,0CAAE,eAAe,CAAC,SAAS,CAAC,IAAI,CACvE,GAAG,CACJ,IAAI,aAAa,EAAE,CACrB,CAAC;IACJ,CAAC;CACF;AA5QD,gEA4QC","sourcesContent":["import {Transformation, Node, NodeList, StyleRule} from '@linkurious/ogma';\nimport {\n IVizNodeGroupInfo,\n LkEdgeData,\n LkNodeData,\n MissingValue,\n NodeGroupingRule\n} from '@linkurious/rest-client';\nimport sha1 from 'sha1';\n\nimport {FORCE_LAYOUT_CONFIG, LKOgma} from '../index';\nimport {Tools} from '../../tools/tools';\n\nexport const LKE_NODE_GROUPING_EDGE = 'LKE_NODE_GROUPING_EDGE';\nexport const LKE_NODE_GROUPING_NODE = 'LKE_NODE_GROUPING_NODE';\n\nexport class NodeGroupingTransformation {\n public transformation?: Transformation<LkNodeData, LkEdgeData>;\n public groupRule?: NodeGroupingRule;\n public nodeGroupingStyleRule?: StyleRule<LkNodeData, LkEdgeData>;\n private _ogma: LKOgma;\n\n constructor(ogma: LKOgma) {\n this._ogma = ogma;\n }\n\n /**\n * Set the grouping rule\n * @param rule of grouping\n */\n public setGroupingRule(rule: NodeGroupingRule | undefined): void {\n this.groupRule = rule;\n }\n\n /**\n * create a node grouping transformation\n * It uses groupRule to define the rule\n * Group the nodes based on a category type and a property value\n */\n public async initTransformation(): Promise<void> {\n if (this.transformation === undefined) {\n this.transformation = this._ogma.transformations.addNodeGrouping({\n groupIdFunction: (node) => {\n if (this._isRuleNotApplicableToNode(node)) {\n return undefined;\n } else {\n const propertyValue = this._findGroupingPropertyValue(node);\n // groupRule is defined if not we returned undefined\n // node with same value will be part of the same group\n return `${this.groupRule?.groupingOptions.itemTypes.join('-')}-${propertyValue}`\n .toLowerCase()\n .trim();\n }\n },\n nodeGenerator: (nodes) => {\n return {\n data: {\n categories: [LKE_NODE_GROUPING_NODE],\n properties: {},\n nodeGroupId: this._findNodeGroupId(nodes)\n }\n };\n },\n edgeGenerator: () => {\n return {\n data: {\n type: LKE_NODE_GROUPING_EDGE\n }\n };\n },\n showContents: true,\n padding: 10\n });\n } else {\n await this.refreshTransformation();\n }\n }\n\n /**\n * refresh the transformation\n * Called when there is a change in the rule\n */\n public async refreshTransformation(): Promise<void> {\n if (this.transformation !== undefined) {\n await this.transformation.refresh();\n await this._unpinNodes(this._getAllTransformationRawNodes());\n } else {\n await this.initTransformation();\n }\n }\n\n /**\n * init node grouping style\n */\n public initNodeGroupingStyle(): void {\n this.nodeGroupingStyleRule = this._ogma.styles.addRule({\n nodeAttributes: {\n // Any default style will go here\n text: {\n content: (node: Node<LkNodeData> | undefined): string | undefined => {\n return this._getNodeGroupingCaption(node);\n },\n style: 'bold'\n },\n layer: -1,\n color: 'rgba(240, 240, 240)',\n innerStroke: {\n color: '#7f7f7f',\n width: 2\n }\n },\n nodeSelector: (node) => {\n // TODO: Tools.isDefined(node.getSubNodes()) is a work around for an ogma issue visible when using image export plugin with Node grouping\n // remove when updating to Ogma v5.1.x\n return node.isVirtual() && Tools.isDefined(node.getSubNodes());\n },\n // the style will be updated when data object is updated\n nodeDependencies: {self: {data: true}}\n });\n }\n\n public async refreshNodeGroupingStyle(): Promise<void> {\n await this.nodeGroupingStyleRule?.refresh();\n }\n\n /**\n * run layout on all subnodes of virtual nodes\n */\n public async runLayoutOnAllSubNodes(): Promise<void> {\n await this._ogma.transformations.afterNextUpdate();\n const rawNodesList = this._getAllTransformationRawNodes();\n const promisesList: Promise<void>[] = [];\n for (let i = 0; i < rawNodesList.length; i++) {\n // rawNodesList[i] is not null because each group has at least one node\n const subNodes = rawNodesList[i]!;\n promisesList.push(this.runSubNodesLayout(subNodes));\n }\n await Promise.all(promisesList);\n }\n\n /**\n * Run the layout on the subnodes of the virtual node\n * @param subNodes nodes part of a virtual node\n */\n public async runSubNodesLayout(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n if (subNodes.size === 0 || subNodes.size === 1) {\n return;\n }\n\n const noEdges = subNodes.getAdjacentEdges({bothExtremities: true}).size === 0;\n if (noEdges) {\n await this._runCirclePack(subNodes);\n } else {\n await this._runForceLayout(subNodes);\n }\n }\n\n /**\n * Get the virtual nodes of the transformation\n * @private\n */\n public getVirtualNodesOfTransformation(): NodeList<LkNodeData, LkEdgeData> {\n // @ts-ignore getContext exists on the transformation but hidden by the types\n return this.transformation.getContext().metaNodes;\n }\n\n /**\n * Set the node group pin\n * @param nodeGroups object containing the node group id and the layoutable attribute\n */\n public async setNodeGroupPin(nodeGroups: IVizNodeGroupInfo[]): Promise<void> {\n this._ogma\n .getNodes()\n .filter((node) => node.isVirtual())\n .forEach((node) => {\n const nodeGroupInfo = nodeGroups.find(\n (nodeGroup) => nodeGroup.id === node.getData('nodeGroupId')\n );\n if (nodeGroupInfo !== undefined) {\n void node.setAttribute('layoutable', nodeGroupInfo.attributes.layoutable ?? false);\n }\n });\n }\n\n /**\n * Return the caption of a virtual node\n * @param node reference to the virtual node\n */\n private _getNodeGroupingCaption(node: Node<LkNodeData> | undefined): string | undefined {\n // TODO: Normally there is no need to check if getSubNodes return a value, Ogma issue\n //https://github.com/Linkurious/ogma/issues/3876\n if (node !== undefined && node.isVirtual() && node.getSubNodes()?.get(0) !== undefined) {\n // get the property value of the first node of the group (all nodes share the same property value)\n const lkPropertyValue = node\n .getSubNodes()!\n .get(0)\n .getData(['properties', this.groupRule!.groupingOptions.propertyKey]);\n const propertyValue = Tools.getValueFromLkProperty(lkPropertyValue);\n const size = node.getSubNodes()!.filter((e) => !e.hasClass('filtered')).size;\n return `${propertyValue} (${size})`;\n }\n }\n\n /**\n * Run the circle pack layout on the subnodes\n * @param subNodes\n */\n private async _runCirclePack(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n await this._ogma.algorithms.circlePack({\n nodes: subNodes,\n margin: 10,\n sort: 'asc'\n });\n }\n\n private async _runForceLayout(subNodes: NodeList<LkNodeData, LkEdgeData>): Promise<void> {\n await this._ogma.layouts.force({\n nodes: subNodes,\n ...FORCE_LAYOUT_CONFIG\n });\n }\n\n private _isRuleNotApplicableToNode(node: Node<LkNodeData>): boolean {\n const propertyValue = node.getData([\n 'properties',\n this.groupRule?.groupingOptions.propertyKey ?? ''\n ]);\n return (\n // if the group rule is not defined\n this.groupRule === undefined ||\n // if rule is applied to a different category\n this.groupRule.groupingOptions.itemTypes.every(\n (itemType) => !node.getData('categories').includes(itemType)\n ) ||\n // if the property value is not defined\n !Tools.isDefined(propertyValue) ||\n // if the property value is missing\n (typeof propertyValue === 'object' && (propertyValue as MissingValue).status === 'missing')\n );\n }\n\n /**\n * Unpin list of nodes\n * @param nodes\n * @private\n */\n private async _unpinNodes(nodes: Array<NodeList | null>): Promise<void> {\n await Promise.all(\n nodes.map((nodeList) => {\n if (nodeList !== null) {\n return nodeList.setAttribute('layoutable', true);\n }\n })\n );\n }\n\n /**\n * Get all the raw nodes part of the transformation\n * @private\n */\n private _getAllTransformationRawNodes(): Array<NodeList | null> {\n const virtualNodes = this.getVirtualNodesOfTransformation();\n return virtualNodes.getSubNodes();\n }\n\n private _findGroupingPropertyValue(node: Node<LkNodeData>): string {\n const propertyValue = node.getData([\n 'properties',\n this.groupRule?.groupingOptions.propertyKey ?? ''\n ]);\n return `${Tools.getValueFromLkProperty(propertyValue)}`;\n }\n\n /**\n * Return a hashed string that represents the group id\n */\n private _findNodeGroupId(nodes: NodeList<LkNodeData, LkEdgeData>): string {\n const propertyValue = this._findGroupingPropertyValue(nodes.get(0));\n return sha1(\n `${this.groupRule?.name}-${this.groupRule?.groupingOptions.itemTypes.join(\n '-'\n )}-${propertyValue}`\n );\n }\n}\n"]}
@@ -1,132 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DummyNodeList = exports.RxViz = void 0;
4
- const OgmaStore_1 = require("./OgmaStore");
5
- class RxViz {
6
- constructor(ogma) {
7
- this._store = new OgmaStore_1.OgmaStore({
8
- selection: new DummyNodeList(),
9
- items: { node: [], edge: [] },
10
- changes: undefined,
11
- animation: false
12
- });
13
- this._ogma = ogma;
14
- this.listenToSelectionEvents();
15
- }
16
- get store() {
17
- return this._store;
18
- }
19
- /**
20
- * Listen to ogma events and update the state
21
- */
22
- listenToSelectionEvents() {
23
- let currentAnimationEnd = Date.now();
24
- let isCurrentlyAnimating = false;
25
- this._ogma.events.on('animate', (e) => {
26
- if (e.updatesPositions === false) {
27
- // ignore animations that don't change the node/edge positions, e.g: Hover
28
- return;
29
- }
30
- if (!isCurrentlyAnimating) {
31
- isCurrentlyAnimating = true;
32
- this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: true })));
33
- }
34
- const nextAnimationEnd = Math.max(currentAnimationEnd, Date.now() + e.duration);
35
- if (nextAnimationEnd === currentAnimationEnd) {
36
- // Say animation 2 fires after animation 1 but has a much shorter duration
37
- // In such a way that animation 1 will still complete after animation 2
38
- // In that case we can safely ignore animation 2
39
- return;
40
- }
41
- currentAnimationEnd = nextAnimationEnd;
42
- const safeAnimationTimeoutMs = currentAnimationEnd - Date.now() + 16; // animation duration + duration of a single frame at 60 fps = 16ms
43
- clearTimeout(this._animationThrottle);
44
- this._animationThrottle = setTimeout(() => {
45
- isCurrentlyAnimating = false;
46
- this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: false })));
47
- }, safeAnimationTimeoutMs);
48
- });
49
- this._ogma.events.on('dragStart', () => {
50
- this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: true })));
51
- });
52
- this._ogma.events.on('dragEnd', () => {
53
- this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: false })));
54
- });
55
- this._ogma.events.on('addNodes', () => {
56
- this._store.dispatch(this.storeItems.bind(this));
57
- });
58
- this._ogma.events.on('removeNodes', () => {
59
- this._store.dispatch(this.storeItems.bind(this));
60
- });
61
- this._ogma.events.on('addEdges', () => {
62
- this._store.dispatch(this.storeItems.bind(this));
63
- });
64
- this._ogma.events.on('removeEdges', () => {
65
- this._store.dispatch(this.storeItems.bind(this));
66
- });
67
- this._ogma.events.on('nodesSelected', () => {
68
- this._store.dispatch(this.storeNodeSelection.bind(this));
69
- });
70
- this._ogma.events.on('edgesSelected', () => {
71
- this._store.dispatch(this.storeEdgeSelection.bind(this));
72
- });
73
- this._ogma.events.on('nodesUnselected', () => {
74
- this._store.dispatch(this.storeNodeSelection.bind(this));
75
- });
76
- this._ogma.events.on('edgesUnselected', () => {
77
- this._store.dispatch(this.storeEdgeSelection.bind(this));
78
- });
79
- this._ogma.events.on('updateNodeData', (evt) => {
80
- if (evt !== undefined) {
81
- evt.changes.forEach((change) => {
82
- this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { changes: {
83
- entityType: 'node',
84
- input: change.property,
85
- value: change.newValues[0]
86
- } })));
87
- });
88
- }
89
- });
90
- this._ogma.events.on('updateEdgeData', (evt) => {
91
- if (evt !== undefined) {
92
- evt.changes.forEach((change) => {
93
- this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { changes: {
94
- entityType: 'edge',
95
- input: change.property,
96
- value: change.newValues[0]
97
- } })));
98
- });
99
- }
100
- });
101
- }
102
- /**
103
- * Store new items in state
104
- */
105
- storeItems(state) {
106
- return Object.assign(Object.assign({}, state), { items: {
107
- node: this._ogma.getNodes().getId(),
108
- edge: this._ogma.getEdges().getId()
109
- } });
110
- }
111
- /**
112
- * Store new node selection in state
113
- */
114
- storeNodeSelection(state) {
115
- return Object.assign(Object.assign({}, state), { selection: this._ogma.getSelectedNodes() });
116
- }
117
- /**
118
- * store new edge selection in state
119
- */
120
- storeEdgeSelection(state) {
121
- return Object.assign(Object.assign({}, state), { selection: this._ogma.getSelectedEdges() });
122
- }
123
- }
124
- exports.RxViz = RxViz;
125
- class DummyNodeList {
126
- constructor() {
127
- this.size = 0;
128
- this.isNode = true;
129
- }
130
- }
131
- exports.DummyNodeList = DummyNodeList;
132
- //# sourceMappingURL=reactive.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../../src/ogma/features/reactive.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAOb,2CAAsC;AAYtC,MAAa,KAAK;IAUhB,YAAY,IAAY;QARhB,WAAM,GAAc,IAAI,qBAAS,CAAC;YACxC,SAAS,EAAE,IAAI,aAAa,EAAS;YACrC,KAAK,EAAE,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC;YAC3B,OAAO,EAAE,SAAS;YAClB,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;QAID,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,uBAAuB;QAC5B,IAAI,mBAAmB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACrC,IAAI,oBAAoB,GAAG,KAAK,CAAC;QACjC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAgD,EAAE,EAAE;YACnF,IAAI,CAAC,CAAC,gBAAgB,KAAK,KAAK,EAAE,CAAC;gBACjC,0EAA0E;gBAC1E,OAAO;YACT,CAAC;YACD,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC1B,oBAAoB,GAAG,IAAI,CAAC;gBAC5B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,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CAAC,KAAK,EAAE,EAAE,CAAC,iCAC3B,KAAK,KACR,OAAO,EAAE;4BACP,UAAU,EAAE,MAAM;4BAClB,KAAK,EAAE,MAAM,CAAC,QAAQ;4BACtB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;yBAC3B,IACD,CAAC,CAAC;gBACN,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,KAAgB;QACjC,uCACK,KAAK,KACR,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;gBACnC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;aACpC,IACD;IACJ,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,KAAgB;QACzC,uCACK,KAAK,KACR,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IACxC;IACJ,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,KAAgB;QACzC,uCACK,KAAK,KACR,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,IACxC;IACJ,CAAC;CACF;AAtJD,sBAsJC;AAED,MAAa,aAAa;IAA1B;QACS,SAAI,GAAG,CAAC,CAAC;QACT,WAAM,GAAG,IAAI,CAAC;IACvB,CAAC;CAAA;AAHD,sCAGC","sourcesContent":["'use strict';\n\nimport Ogma, {NodeList, EdgeList} from '@linkurious/ogma';\nimport {LkEdgeData, LkNodeData} from '@linkurious/rest-client';\n\nimport {LKOgma} from '../index';\n\nimport {OgmaStore} from './OgmaStore';\n\nexport interface OgmaState {\n selection: NodeList<LkNodeData, LkEdgeData> | EdgeList<LkEdgeData, LkNodeData>;\n items: {node: Array<string | number>; edge: Array<string | number>};\n changes: {entityType: 'node' | 'edge'; input: string | string[] | null; value: any} | undefined;\n /**\n * Indicates whether the positions of nodes or edges are currently transitioning.\n */\n animation: boolean;\n}\n\nexport class RxViz {\n private _ogma: Ogma;\n private _store: OgmaStore = new OgmaStore({\n selection: new DummyNodeList() as any,\n items: {node: [], edge: []},\n changes: undefined,\n animation: false\n });\n private _animationThrottle: any;\n\n constructor(ogma: LKOgma) {\n this._ogma = ogma;\n this.listenToSelectionEvents();\n }\n\n public get store(): OgmaStore {\n return this._store;\n }\n\n /**\n * Listen to ogma events and update the state\n */\n public listenToSelectionEvents(): void {\n let currentAnimationEnd = Date.now();\n let isCurrentlyAnimating = false;\n this._ogma.events.on('animate', (e: {duration: number; updatesPositions: boolean}) => {\n if (e.updatesPositions === false) {\n // ignore animations that don't change the node/edge positions, e.g: Hover\n return;\n }\n if (!isCurrentlyAnimating) {\n isCurrentlyAnimating = true;\n this._store.dispatch((state) => ({...state, animation: true}));\n }\n const nextAnimationEnd = Math.max(currentAnimationEnd, Date.now() + e.duration);\n if (nextAnimationEnd === currentAnimationEnd) {\n // Say animation 2 fires after animation 1 but has a much shorter duration\n // In such a way that animation 1 will still complete after animation 2\n // In that case we can safely ignore animation 2\n return;\n }\n currentAnimationEnd = nextAnimationEnd;\n const safeAnimationTimeoutMs = currentAnimationEnd - Date.now() + 16; // animation duration + duration of a single frame at 60 fps = 16ms\n clearTimeout(this._animationThrottle);\n this._animationThrottle = setTimeout(() => {\n isCurrentlyAnimating = false;\n this._store.dispatch((state) => ({...state, animation: false}));\n }, safeAnimationTimeoutMs);\n });\n\n this._ogma.events.on('dragStart', () => {\n this._store.dispatch((state) => ({...state, animation: true}));\n });\n\n this._ogma.events.on('dragEnd', () => {\n this._store.dispatch((state) => ({...state, animation: false}));\n });\n\n this._ogma.events.on('addNodes', () => {\n this._store.dispatch(this.storeItems.bind(this));\n });\n this._ogma.events.on('removeNodes', () => {\n this._store.dispatch(this.storeItems.bind(this));\n });\n this._ogma.events.on('addEdges', () => {\n this._store.dispatch(this.storeItems.bind(this));\n });\n this._ogma.events.on('removeEdges', () => {\n this._store.dispatch(this.storeItems.bind(this));\n });\n\n this._ogma.events.on('nodesSelected', () => {\n this._store.dispatch(this.storeNodeSelection.bind(this));\n });\n\n this._ogma.events.on('edgesSelected', () => {\n this._store.dispatch(this.storeEdgeSelection.bind(this));\n });\n\n this._ogma.events.on('nodesUnselected', () => {\n this._store.dispatch(this.storeNodeSelection.bind(this));\n });\n\n this._ogma.events.on('edgesUnselected', () => {\n this._store.dispatch(this.storeEdgeSelection.bind(this));\n });\n\n this._ogma.events.on('updateNodeData', (evt) => {\n if (evt !== undefined) {\n evt.changes.forEach((change) => {\n this._store.dispatch((state) => ({\n ...state,\n changes: {\n entityType: 'node',\n input: change.property,\n value: change.newValues[0]\n }\n }));\n });\n }\n });\n\n this._ogma.events.on('updateEdgeData', (evt) => {\n if (evt !== undefined) {\n evt.changes.forEach((change) => {\n this._store.dispatch((state) => ({\n ...state,\n changes: {\n entityType: 'edge',\n input: change.property,\n value: change.newValues[0]\n }\n }));\n });\n }\n });\n }\n\n /**\n * Store new items in state\n */\n private storeItems(state: OgmaState): OgmaState {\n return {\n ...state,\n items: {\n node: this._ogma.getNodes().getId(),\n edge: this._ogma.getEdges().getId()\n }\n };\n }\n\n /**\n * Store new node selection in state\n */\n private storeNodeSelection(state: OgmaState): OgmaState {\n return {\n ...state,\n selection: this._ogma.getSelectedNodes()\n };\n }\n\n /**\n * store new edge selection in state\n */\n private storeEdgeSelection(state: OgmaState): OgmaState {\n return {\n ...state,\n selection: this._ogma.getSelectedEdges()\n };\n }\n}\n\nexport class DummyNodeList {\n public size = 0;\n public isNode = true;\n}\n"]}