@linkurious/ogma-linkurious-parser 4.1.0 → 4.1.2

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.
@@ -1,4 +1,4 @@
1
- import { Transformation, NodeList } from '@linkurious/ogma';
1
+ import { Transformation, NodeList, StyleRule } from '@linkurious/ogma';
2
2
  import { LkEdgeData, LkNodeData, NodeGroupingRule } from '@linkurious/rest-client';
3
3
  import { LKOgma } from '../index';
4
4
  export declare const LKE_NODE_GROUPING_EDGE = "LKE_NODE_GROUPING_EDGE";
@@ -6,6 +6,7 @@ export declare const LKE_NODE_GROUPING_NODE = "LKE_NODE_GROUPING_NODE";
6
6
  export declare class NodeGroupingTransformation {
7
7
  transformation?: Transformation<LkNodeData, LkEdgeData>;
8
8
  groupRule?: NodeGroupingRule;
9
+ nodeGroupingStyleRule?: StyleRule<LkNodeData, LkEdgeData>;
9
10
  private _ogma;
10
11
  constructor(ogma: LKOgma);
11
12
  /**
@@ -28,6 +29,7 @@ export declare class NodeGroupingTransformation {
28
29
  * init node grouping style
29
30
  */
30
31
  initNodeGroupingStyle(): void;
32
+ refreshNodeGroupingStyle(): Promise<void>;
31
33
  /**
32
34
  * run layout on all subnodes of virtual nodes
33
35
  */
@@ -47,7 +47,7 @@ class NodeGroupingTransformation {
47
47
  const propertyValue = this._findGroupingPropertyValue(node);
48
48
  // groupRule is defined if not we returned undefined
49
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.itemType}-${propertyValue}`
50
+ return `${(_a = this.groupRule) === null || _a === void 0 ? void 0 : _a.groupingOptions.itemTypes.join('-')}-${propertyValue}`
51
51
  .toLowerCase()
52
52
  .trim();
53
53
  }
@@ -69,13 +69,8 @@ class NodeGroupingTransformation {
69
69
  };
70
70
  },
71
71
  showContents: true,
72
- duration: 300,
73
72
  padding: 10
74
73
  });
75
- // TODO remove setTimeout when LKE-10453 is fixed
76
- setTimeout(() => {
77
- this.transformation.refresh();
78
- }, 200);
79
74
  }
80
75
  else {
81
76
  yield this.refreshTransformation();
@@ -101,7 +96,7 @@ class NodeGroupingTransformation {
101
96
  * init node grouping style
102
97
  */
103
98
  initNodeGroupingStyle() {
104
- this._ogma.styles.addRule({
99
+ this.nodeGroupingStyleRule = this._ogma.styles.addRule({
105
100
  nodeAttributes: {
106
101
  // Any default style will go here
107
102
  text: {
@@ -126,6 +121,12 @@ class NodeGroupingTransformation {
126
121
  nodeDependencies: { self: { data: true } }
127
122
  });
128
123
  }
124
+ refreshNodeGroupingStyle() {
125
+ var _a;
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ yield ((_a = this.nodeGroupingStyleRule) === null || _a === void 0 ? void 0 : _a.refresh());
128
+ });
129
+ }
129
130
  /**
130
131
  * run layout on all subnodes of virtual nodes
131
132
  */
@@ -148,7 +149,7 @@ class NodeGroupingTransformation {
148
149
  */
149
150
  runSubNodesLayout(subNodes) {
150
151
  return __awaiter(this, void 0, void 0, function* () {
151
- if (subNodes.size === 0) {
152
+ if (subNodes.size === 0 || subNodes.size === 1) {
152
153
  return;
153
154
  }
154
155
  const noEdges = subNodes.getAdjacentEdges({ bothExtremities: true }).size === 0;
@@ -166,7 +167,7 @@ class NodeGroupingTransformation {
166
167
  */
167
168
  getVirtualNodesOfTransformation() {
168
169
  // @ts-ignore getContext exists on the transformation but hidden by the types
169
- return this.transformation.getContext().virtualNodes;
170
+ return this.transformation.getContext().metaNodes;
170
171
  }
171
172
  /**
172
173
  * Return the caption of a virtual node
@@ -212,7 +213,7 @@ class NodeGroupingTransformation {
212
213
  // if the group rule is not defined
213
214
  this.groupRule === undefined ||
214
215
  // if rule is applied to a different category
215
- !node.getData('categories').includes(this.groupRule.groupingOptions.itemType) ||
216
+ this.groupRule.groupingOptions.itemTypes.every((itemType) => !node.getData('categories').includes(itemType)) ||
216
217
  // if the property value is not defined
217
218
  !tools_1.Tools.isDefined(propertyValue) ||
218
219
  // if the property value is missing
@@ -254,7 +255,7 @@ class NodeGroupingTransformation {
254
255
  _findNodeGroupId(nodes) {
255
256
  var _a, _b;
256
257
  const propertyValue = this._findGroupingPropertyValue(nodes.get(0));
257
- 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.itemType}-${propertyValue}`);
258
+ 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}`);
258
259
  }
259
260
  }
260
261
  exports.NodeGroupingTransformation = NodeGroupingTransformation;
@@ -1 +1 @@
1
- {"version":3,"file":"nodeGrouping.js","sourceRoot":"","sources":["../../../src/ogma/features/nodeGrouping.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,gDAAwB;AAExB,oCAAqD;AACrD,6CAAwC;AAE3B,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,MAAa,0BAA0B;IAKrC,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;gBACrC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC;oBAC/D,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;;wBACxB,IAAI,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE;4BACzC,OAAO,SAAS,CAAC;yBAClB;6BAAM;4BACL,MAAM,aAAa,GAAG,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAA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A,IAAI,CAAC,SAAS,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,QAAQ,IAAI,aAAa,EAAE,CACvF,CAAC;IACJ,CAAC;CACF;AApPD,gEAoPC","sourcesContent":["import {Transformation, Node, NodeList} from '@linkurious/ogma';\nimport {LkEdgeData, LkNodeData, MissingValue, NodeGroupingRule} 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 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.itemType}-${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 duration: 300,\n padding: 10\n });\n // TODO remove setTimeout when LKE-10453 is fixed\n setTimeout(() => {\n this.transformation!.refresh();\n }, 200);\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._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 /**\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) {\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().virtualNodes;\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 if (node !== undefined && node.isVirtual()) {\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 !node.getData('categories').includes(this.groupRule.groupingOptions.itemType) ||\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.itemType}-${propertyValue}`\n );\n }\n}\n"]}
1
+ {"version":3,"file":"nodeGrouping.js","sourceRoot":"","sources":["../../../src/ogma/features/nodeGrouping.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,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,IA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C,QAAQ,EAAE,EAAE;gBACrB,IAAI,QAAQ,KAAK,IAAI,EAAE;oBACrB,OAAO,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;iBAClD;YACH,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KAAA;IAED;;;OAGG;IACK,6BAA6B;QACnC,MAAM,YAAY,GAAG,IAAI,CAAC,+BAA+B,EAAE,CAAC;QAC5D,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC;IAEO,0BAA0B,CAAC,IAAsB;;QACvD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC;YACjC,YAAY;YACZ,MAAA,MAAA,IAAI,CAAC,SAAS,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;AAxPD,gEAwPC","sourcesContent":["import {Transformation, Node, NodeList, StyleRule} from '@linkurious/ogma';\nimport {LkEdgeData, LkNodeData, MissingValue, NodeGroupingRule} 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 * 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 if (node !== undefined && node.isVirtual()) {\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"]}
@@ -13,6 +13,9 @@ export interface OgmaState {
13
13
  input: string | string[] | null;
14
14
  value: any;
15
15
  } | undefined;
16
+ /**
17
+ * Indicates whether the positions of nodes or edges are currently transitioning.
18
+ */
16
19
  animation: boolean;
17
20
  }
18
21
  export declare class RxViz {
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DummyNodeList = exports.RxViz = void 0;
4
- const index_1 = require("../index");
5
4
  const OgmaStore_1 = require("./OgmaStore");
6
5
  class RxViz {
7
6
  constructor(ogma) {
@@ -21,16 +20,31 @@ class RxViz {
21
20
  * Listen to ogma events and update the state
22
21
  */
23
22
  listenToSelectionEvents() {
24
- let count = 0;
23
+ let currentAnimationEnd = Date.now();
24
+ let isCurrentlyAnimating = false;
25
25
  this._ogma.events.on('animate', (e) => {
26
- const animationEnd = ++count;
27
- this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: true })));
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
28
43
  clearTimeout(this._animationThrottle);
29
44
  this._animationThrottle = setTimeout(() => {
30
- if (count === animationEnd) {
31
- this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: false })));
32
- }
33
- }, e.duration + index_1.ANIMATION_DURATION + 100);
45
+ isCurrentlyAnimating = false;
46
+ this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: false })));
47
+ }, safeAnimationTimeoutMs);
34
48
  });
35
49
  this._ogma.events.on('dragStart', () => {
36
50
  this._store.dispatch((state) => (Object.assign(Object.assign({}, state), { animation: true })));
@@ -1 +1 @@
1
- {"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../../src/ogma/features/reactive.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAKb,oCAAoD;AAEpD,2CAAsC;AAStC,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,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAqB,EAAE,EAAE;YACxD,MAAM,YAAY,GAAG,EAAE,KAAK,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCAAK,KAAK,KAAE,SAAS,EAAE,IAAI,IAAE,CAAC,CAAC;YAC/D,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACtC,IAA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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;AAvID,sBAuIC;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 {ANIMATION_DURATION, 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 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 count = 0;\n this._ogma.events.on('animate', (e: {duration: number}) => {\n const animationEnd = ++count;\n this._store.dispatch((state) => ({...state, animation: true}));\n clearTimeout(this._animationThrottle);\n this._animationThrottle = setTimeout(() => {\n if (count === animationEnd) {\n this._store.dispatch((state) => ({...state, animation: false}));\n }\n }, e.duration + ANIMATION_DURATION + 100);\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"]}
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;gBAChC,0EAA0E;gBAC1E,OAAO;aACR;YACD,IAAI,CAAC,oBAAoB,EAAE;gBACzB,oBAAoB,GAAG,IAAI,CAAC;gBAC5B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCAAK,KAAK,KAAE,SAAS,EAAE,IAAI,IAAE,CAAC,CAAC;aAChE;YACD,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;YAChF,IAAI,gBAAgB,KAAK,mBAAmB,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AAU,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"]}
@@ -251,10 +251,7 @@ class LKOgma extends ogma_1.default {
251
251
  * Adding edges to the graph after filtering disconnected ones
252
252
  */
253
253
  addEdges(edges, options) {
254
- const filteredEdges = edges.filter((edge) => {
255
- return this.getNode(edge.source) !== undefined && this.getNode(edge.target) !== undefined;
256
- });
257
- return super.addEdges(filteredEdges, options);
254
+ return super.addEdges(edges, Object.assign(Object.assign({}, options), { ignoreInvalid: true }));
258
255
  }
259
256
  /**
260
257
  * Return the list of non filtered nodes
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ogma/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yDAUiC;AACjC,4DAW0B;AAE1B,0BAA8B;AAC9B,0CAAqC;AAErC,8CAA4C;AAC5C,gEAA8D;AAC9D,kDAAgD;AAChD,kDAA0C;AAE1C,0DAAmE;AAEnE,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AAC,cAAc,CAAC,CAAC;IACxC,CAAC;CACF;AA3UD,wBA2UC","sourcesContent":["import {\n EntityType,\n ForceLayoutMode,\n HierarchicalLayoutMode,\n IOgmaConfig,\n LkEdgeData,\n LkNodeData,\n PopulatedVisualization,\n VizEdge,\n VizNode\n} from '@linkurious/rest-client';\nimport Ogma, {\n EdgeList,\n ForceLayoutOptions,\n HierarchicalLayoutOptions,\n NodeId,\n NodeList,\n NonObjectPropertyWatcher,\n RadialLayoutOptions,\n RawEdge,\n RawGraph,\n RawNode\n} from '@linkurious/ogma';\n\nimport {StyleRules} from '..';\nimport {Tools} from '../tools/tools';\n\nimport {StylesViz} from './features/styles';\nimport {TransformationsViz} from './features/transformations';\nimport {CaptionsViz} from './features/captions';\nimport {RxViz} from './features/reactive';\nimport {OgmaStore} from './features/OgmaStore';\nimport {NodeGroupingTransformation} from './features/nodeGrouping';\n\nexport {default as Ogma} from '@linkurious/ogma';\nexport const ANIMATION_DURATION = 750;\n\ninterface AddItemOptions {\n batchSize?: number;\n virtual?: boolean;\n}\n\nexport const FORCE_LAYOUT_CONFIG = {\n steps: 40,\n alignSiblings: true,\n charge: 5,\n theta: 0.34,\n duration: ANIMATION_DURATION\n};\n\nexport class LKOgma extends Ogma<LkNodeData, LkEdgeData> {\n public LKStyles!: StylesViz;\n public LKCaptions!: CaptionsViz;\n public LKTransformation!: TransformationsViz;\n // Trigger an event with node category changes\n public nodeCategoriesWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n // Trigger an event with edge type changes\n public edgeTypeWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n public store!: OgmaStore;\n // Node Grouping transformation instance\n public LkNodeGroupingTransformation!: NodeGroupingTransformation;\n private _reactive!: RxViz;\n\n constructor(private _configuration: IOgmaConfig, _baseUrl?: string) {\n // set Ogma global configuration\n super(_configuration);\n Object.setPrototypeOf(this, new.target.prototype);\n this.initOgmaLinkuriousParser(true, _baseUrl);\n }\n\n /**\n * Initialize the Ogma instance with the configuration and the base url\n * @param init used to know if the instance is initialized for the first time (used in setConfigOgma)\n * @param baseUrl base url used for relative image urls\n * @private\n */\n private initOgmaLinkuriousParser(init?: boolean, baseUrl?: string): void {\n this.nodeCategoriesWatcher = this.schema.watchNodeNonObjectProperty({\n path: 'categories',\n unwindArrays: true,\n filter: 'all'\n });\n this.edgeTypeWatcher = this.schema.watchEdgeNonObjectProperty({\n path: 'type',\n filter: 'all'\n });\n // set ogma max zoom value and selection with mouse option (false?)\n this.setOptions({\n interactions: {\n zoom: {\n maxValue: (params: any) => {\n return 128 / params.smallestNodeSize;\n }\n },\n selection: {\n enabled: false\n }\n }\n });\n\n // only instantiate the store once when app is starting\n if (this._reactive === undefined) {\n this._reactive = new RxViz(this);\n this.store = this._reactive.store;\n } else {\n // if store already exist, but ogma was reset, create new ogma event listener\n this._reactive.listenToSelectionEvents();\n }\n this.initSelection();\n this.setConfigOgma(this._configuration, init, baseUrl);\n this.LKTransformation = new TransformationsViz(this);\n this.LkNodeGroupingTransformation = new NodeGroupingTransformation(this);\n\n this.LKStyles.setNodesDefaultHalo();\n this.LKStyles.setEdgesDefaultHalo();\n this.LKStyles.setBadgeRule();\n this.LKStyles.setFilterClass();\n }\n\n /**\n * Initialize selection behavior\n */\n public initSelection(): void {\n this.events.onClick((e) => {\n if (e !== undefined && e.button === 'left') {\n if (e.target !== null) {\n const multiSelectionKey = navigator.platform === 'MacIntel' ? 'cmd' : 'ctrl';\n if (this.keyboard.isKeyPressed(multiSelectionKey)) {\n if (e.target.isNode && this.getSelectedEdges().size > 0) {\n this.getSelectedEdges().setSelected(false);\n }\n if (!e.target.isNode && this.getSelectedNodes().size > 0) {\n this.getSelectedNodes().setSelected(false);\n }\n if (e.target.isSelected()) {\n e.target.setSelected(false);\n } else {\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n }\n }\n });\n }\n\n private setStyles(configuration: IOgmaConfig, baseUrl?: string): void {\n this.LKStyles = new StylesViz(this, {\n node: configuration?.options?.styles?.node || {},\n edge: configuration?.options?.styles?.edge || {},\n baseUrl: baseUrl\n });\n this.LKStyles.setNodesDefaultStyles();\n this.LKStyles.setEdgesDefaultStyles();\n }\n\n private setCaptions(configuration: IOgmaConfig): void {\n const nodeMaxTextLength = configuration?.options?.styles?.node?.text?.maxTextLength;\n const edgeMaxTextLength = configuration?.options?.styles?.edge?.text?.maxTextLength;\n this.LKCaptions = new CaptionsViz(this, nodeMaxTextLength, edgeMaxTextLength);\n }\n\n /**\n * Returns Ogma Layout parameters according to visualization layout settings\n * */\n public getForceLayoutParams(mode: ForceLayoutMode, duration = 0): ForceLayoutOptions {\n let dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;\n if (dynamicSteps < 40) {\n dynamicSteps = 40;\n }\n return {\n steps: mode === ForceLayoutMode.FAST ? dynamicSteps : 300,\n alignSiblings: this.getNodes().size > 3,\n duration: duration,\n charge: 20,\n gravity: 0.08,\n theta: this.getNodes().size > 100 ? 0.8 : 0.34\n };\n }\n\n public getRadialLayoutParams(\n rootNode: string,\n duration = 0\n ): RadialLayoutOptions<unknown, unknown> {\n return {\n centralNode: rootNode,\n radiusDelta: 1,\n nodeGap: 10,\n repulsion: this.getNodes().size > 80 ? 1 : 6,\n duration: duration\n };\n }\n\n public getHierarchicalLayoutParams(\n mode: HierarchicalLayoutMode,\n rootNode: string,\n duration = 0\n ): HierarchicalLayoutOptions {\n return {\n direction: mode,\n roots: [rootNode],\n duration: duration\n };\n }\n\n /**\n * Initialize graph.\n * add nodes and edges to the viz and init the selection.\n */\n public async init(visualization: {nodes: Array<VizNode>; edges: Array<VizEdge>}): Promise<void> {\n this.clearGraph();\n let selectedEntityType: EntityType | undefined = undefined;\n let selectedElements: Array<string> = [];\n // need to remove selected in every items before adding them to Ogma\n const fixedNodes = visualization.nodes.map((node) => {\n if (node.attributes.selected) {\n selectedEntityType = EntityType.NODE;\n selectedElements.push(node.id);\n }\n delete node.attributes.selected;\n return node;\n });\n const fixedEdges = visualization.edges.map((edge) => {\n if (edge.attributes !== undefined) {\n if (edge.attributes.selected) {\n if (selectedEntityType === undefined || selectedEntityType === EntityType.NODE) {\n selectedEntityType = EntityType.EDGE;\n selectedElements = [];\n }\n selectedElements.push(edge.id);\n }\n delete edge.attributes.selected;\n }\n return edge;\n });\n await this.addGraphAfterValidation({\n nodes: fixedNodes as Array<RawNode<LkNodeData>>,\n edges: fixedEdges as Array<RawEdge<LkEdgeData>>\n });\n if (selectedEntityType === EntityType.NODE) {\n this.getNodes(selectedElements).setSelected(true);\n } else if (selectedEntityType === EntityType.EDGE) {\n this.getEdges(selectedElements).setSelected(true);\n }\n }\n\n public async initVisualization(visualization: PopulatedVisualization): Promise<void> {\n await this.init(visualization);\n const styles = StyleRules.sanitizeStylesIndex(visualization.design.styles);\n this.LKStyles.initNodeColors(styles.node);\n this.LKStyles.initNodesIcons(styles.node);\n this.LKStyles.initNodesSizes(styles.node);\n this.LKStyles.initNodesShapes(styles.node);\n this.LKStyles.initEdgesWidth(styles.edge);\n this.LKStyles.initEdgesShape(styles.edge);\n this.LKStyles.initEdgesColor(styles.edge);\n await this.LKCaptions.initVizCaptions({\n node: visualization.nodeFields.captions || {},\n edge: visualization.edgeFields.captions || {}\n });\n this.LKTransformation.groupedEdges = visualization.edgeGrouping;\n await this.LKTransformation.initTransformation();\n this.LKTransformation.initEdgeGroupingStyle();\n }\n\n /**\n * Adding nodes then adding edges to the graph\n */\n public async addGraphAfterValidation(\n graph: RawGraph<LkNodeData, LkEdgeData>\n ): Promise<{\n nodes: NodeList<LkNodeData>;\n edges: EdgeList<LkEdgeData>;\n }> {\n const addedNodes = await this.addNodes(graph.nodes);\n const addedEdges = await this.addEdges(graph.edges);\n return {\n nodes: addedNodes,\n edges: addedEdges\n };\n }\n\n /**\n * Adding edges to the graph after filtering disconnected ones\n */\n public addEdges(edges: Array<RawEdge<LkEdgeData>>, options?: AddItemOptions): Promise<EdgeList> {\n const filteredEdges = edges.filter((edge) => {\n return this.getNode(edge.source) !== undefined && this.getNode(edge.target) !== undefined;\n });\n return super.addEdges(filteredEdges, options);\n }\n\n /**\n * Return the list of non filtered nodes\n */\n public getNonFilteredNodes(items?: Array<NodeId>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => !i.hasClass('filtered'))\n : // take only none virtual nodes\n this.getNodes('raw').filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered nodes\n * @param items items to check if they are filtered\n * @param filter type of nodes to check if they are filtered ( nodes that are visible, raw nodes (none virtual) or all nodes)\n */\n public getFilteredNodes(\n items?: Array<NodeId>,\n filter: 'visible' | 'raw' | 'all' = 'raw'\n ): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => i.hasClass('filtered'))\n : this.getNodes(filter).filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Return the list of non filtered edges\n */\n public getNonFilteredEdges(items?: Array<any>): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => !i.hasClass('filtered'))\n : this.getEdges('raw').filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered edges\n */\n public getFilteredEdges(\n items?: Array<any>,\n filter: 'visible' | 'raw' | 'all' = 'raw'\n ): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => i.hasClass('filtered'))\n : this.getEdges(filter).filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Do a full reset on ogma and streams of ogma\n */\n public shutDown(): void {\n this.destroy();\n if (this.store) {\n this.store.clear();\n }\n }\n\n /**\n * Reset the Ogma instance so that it can be used fresh in the next visulization\n */\n public clearOgmaState(): void {\n this.reset();\n if (this.store) {\n this.store.clear();\n }\n this.initOgmaLinkuriousParser();\n }\n\n /**\n * Updates the Ogma config when config changes in LKE. If init, options were already set by the Ogma.reset()\n */\n public setConfigOgma(configuration?: IOgmaConfig, init?: boolean, baseUrl?: string): void {\n if (configuration) {\n // here we make sure that the internal config object is updated and we have the correct one when resetting\n this._configuration = configuration;\n }\n if (!init) {\n this.setOptions({\n ...this._configuration.options,\n renderer: this._configuration.renderer\n });\n }\n this.setStyles(this._configuration, baseUrl);\n this.setCaptions(this._configuration);\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ogma/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yDAUiC;AACjC,4DAW0B;AAE1B,0BAA8B;AAC9B,0CAAqC;AAErC,8CAA4C;AAC5C,gEAA8D;AAC9D,kDAAgD;AAChD,kDAA0C;AAE1C,0DAAmE;AAEnE,yCAAiD;AAAzC,6GAAA,OAAO,OAAQ;AACV,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAOzB,QAAA,mBAAmB,GAAG;IACjC,KAAK,EAAE,EAAE;IACT,aAAa,EAAE,IAAI;IACnB,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,0BAAkB;CAC7B,CAAC;AAEF,MAAa,MAAO,SAAQ,cAA4B;IAatD,YAAoB,cAA2B,EAAE,QAAiB;QAChE,gCAAgC;QAChC,KAAK,CAAC,cAAc,CAAC,CAAC;QAFJ,mBAAc,GAAd,cAAc,CAAa;QAG7C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,wBAAwB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACK,wBAAwB,CAAC,IAAc,EAAE,OAAgB;QAC/D,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC;YAClE,IAAI,EA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ACjB,0GAA0G;YAC1G,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;SACrC;QACD,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,CAAC,UAAU,iCACV,IAAI,CAAC,cAAc,CAAC,OAAO,KAC9B,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,IACtC,CAAC;SACJ;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;CACF;AAxUD,wBAwUC","sourcesContent":["import {\n EntityType,\n ForceLayoutMode,\n HierarchicalLayoutMode,\n IOgmaConfig,\n LkEdgeData,\n LkNodeData,\n PopulatedVisualization,\n VizEdge,\n VizNode\n} from '@linkurious/rest-client';\nimport Ogma, {\n EdgeList,\n ForceLayoutOptions,\n HierarchicalLayoutOptions,\n NodeId,\n NodeList,\n NonObjectPropertyWatcher,\n RadialLayoutOptions,\n RawEdge,\n RawGraph,\n RawNode\n} from '@linkurious/ogma';\n\nimport {StyleRules} from '..';\nimport {Tools} from '../tools/tools';\n\nimport {StylesViz} from './features/styles';\nimport {TransformationsViz} from './features/transformations';\nimport {CaptionsViz} from './features/captions';\nimport {RxViz} from './features/reactive';\nimport {OgmaStore} from './features/OgmaStore';\nimport {NodeGroupingTransformation} from './features/nodeGrouping';\n\nexport {default as Ogma} from '@linkurious/ogma';\nexport const ANIMATION_DURATION = 750;\n\ninterface AddItemOptions {\n batchSize?: number;\n virtual?: boolean;\n}\n\nexport const FORCE_LAYOUT_CONFIG = {\n steps: 40,\n alignSiblings: true,\n charge: 5,\n theta: 0.34,\n duration: ANIMATION_DURATION\n};\n\nexport class LKOgma extends Ogma<LkNodeData, LkEdgeData> {\n public LKStyles!: StylesViz;\n public LKCaptions!: CaptionsViz;\n public LKTransformation!: TransformationsViz;\n // Trigger an event with node category changes\n public nodeCategoriesWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n // Trigger an event with edge type changes\n public edgeTypeWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n public store!: OgmaStore;\n // Node Grouping transformation instance\n public LkNodeGroupingTransformation!: NodeGroupingTransformation;\n private _reactive!: RxViz;\n\n constructor(private _configuration: IOgmaConfig, _baseUrl?: string) {\n // set Ogma global configuration\n super(_configuration);\n Object.setPrototypeOf(this, new.target.prototype);\n this.initOgmaLinkuriousParser(true, _baseUrl);\n }\n\n /**\n * Initialize the Ogma instance with the configuration and the base url\n * @param init used to know if the instance is initialized for the first time (used in setConfigOgma)\n * @param baseUrl base url used for relative image urls\n * @private\n */\n private initOgmaLinkuriousParser(init?: boolean, baseUrl?: string): void {\n this.nodeCategoriesWatcher = this.schema.watchNodeNonObjectProperty({\n path: 'categories',\n unwindArrays: true,\n filter: 'all'\n });\n this.edgeTypeWatcher = this.schema.watchEdgeNonObjectProperty({\n path: 'type',\n filter: 'all'\n });\n // set ogma max zoom value and selection with mouse option (false?)\n this.setOptions({\n interactions: {\n zoom: {\n maxValue: (params: any) => {\n return 128 / params.smallestNodeSize;\n }\n },\n selection: {\n enabled: false\n }\n }\n });\n\n // only instantiate the store once when app is starting\n if (this._reactive === undefined) {\n this._reactive = new RxViz(this);\n this.store = this._reactive.store;\n } else {\n // if store already exist, but ogma was reset, create new ogma event listener\n this._reactive.listenToSelectionEvents();\n }\n this.initSelection();\n this.setConfigOgma(this._configuration, init, baseUrl);\n this.LKTransformation = new TransformationsViz(this);\n this.LkNodeGroupingTransformation = new NodeGroupingTransformation(this);\n\n this.LKStyles.setNodesDefaultHalo();\n this.LKStyles.setEdgesDefaultHalo();\n this.LKStyles.setBadgeRule();\n this.LKStyles.setFilterClass();\n }\n\n /**\n * Initialize selection behavior\n */\n public initSelection(): void {\n this.events.onClick((e) => {\n if (e !== undefined && e.button === 'left') {\n if (e.target !== null) {\n const multiSelectionKey = navigator.platform === 'MacIntel' ? 'cmd' : 'ctrl';\n if (this.keyboard.isKeyPressed(multiSelectionKey)) {\n if (e.target.isNode && this.getSelectedEdges().size > 0) {\n this.getSelectedEdges().setSelected(false);\n }\n if (!e.target.isNode && this.getSelectedNodes().size > 0) {\n this.getSelectedNodes().setSelected(false);\n }\n if (e.target.isSelected()) {\n e.target.setSelected(false);\n } else {\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n }\n }\n });\n }\n\n private setStyles(configuration: IOgmaConfig, baseUrl?: string): void {\n this.LKStyles = new StylesViz(this, {\n node: configuration?.options?.styles?.node || {},\n edge: configuration?.options?.styles?.edge || {},\n baseUrl: baseUrl\n });\n this.LKStyles.setNodesDefaultStyles();\n this.LKStyles.setEdgesDefaultStyles();\n }\n\n private setCaptions(configuration: IOgmaConfig): void {\n const nodeMaxTextLength = configuration?.options?.styles?.node?.text?.maxTextLength;\n const edgeMaxTextLength = configuration?.options?.styles?.edge?.text?.maxTextLength;\n this.LKCaptions = new CaptionsViz(this, nodeMaxTextLength, edgeMaxTextLength);\n }\n\n /**\n * Returns Ogma Layout parameters according to visualization layout settings\n * */\n public getForceLayoutParams(mode: ForceLayoutMode, duration = 0): ForceLayoutOptions {\n let dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;\n if (dynamicSteps < 40) {\n dynamicSteps = 40;\n }\n return {\n steps: mode === ForceLayoutMode.FAST ? dynamicSteps : 300,\n alignSiblings: this.getNodes().size > 3,\n duration: duration,\n charge: 20,\n gravity: 0.08,\n theta: this.getNodes().size > 100 ? 0.8 : 0.34\n };\n }\n\n public getRadialLayoutParams(\n rootNode: string,\n duration = 0\n ): RadialLayoutOptions<unknown, unknown> {\n return {\n centralNode: rootNode,\n radiusDelta: 1,\n nodeGap: 10,\n repulsion: this.getNodes().size > 80 ? 1 : 6,\n duration: duration\n };\n }\n\n public getHierarchicalLayoutParams(\n mode: HierarchicalLayoutMode,\n rootNode: string,\n duration = 0\n ): HierarchicalLayoutOptions {\n return {\n direction: mode,\n roots: [rootNode],\n duration: duration\n };\n }\n\n /**\n * Initialize graph.\n * add nodes and edges to the viz and init the selection.\n */\n public async init(visualization: {nodes: Array<VizNode>; edges: Array<VizEdge>}): Promise<void> {\n this.clearGraph();\n let selectedEntityType: EntityType | undefined = undefined;\n let selectedElements: Array<string> = [];\n // need to remove selected in every items before adding them to Ogma\n const fixedNodes = visualization.nodes.map((node) => {\n if (node.attributes.selected) {\n selectedEntityType = EntityType.NODE;\n selectedElements.push(node.id);\n }\n delete node.attributes.selected;\n return node;\n });\n const fixedEdges = visualization.edges.map((edge) => {\n if (edge.attributes !== undefined) {\n if (edge.attributes.selected) {\n if (selectedEntityType === undefined || selectedEntityType === EntityType.NODE) {\n selectedEntityType = EntityType.EDGE;\n selectedElements = [];\n }\n selectedElements.push(edge.id);\n }\n delete edge.attributes.selected;\n }\n return edge;\n });\n await this.addGraphAfterValidation({\n nodes: fixedNodes as Array<RawNode<LkNodeData>>,\n edges: fixedEdges as Array<RawEdge<LkEdgeData>>\n });\n if (selectedEntityType === EntityType.NODE) {\n this.getNodes(selectedElements).setSelected(true);\n } else if (selectedEntityType === EntityType.EDGE) {\n this.getEdges(selectedElements).setSelected(true);\n }\n }\n\n public async initVisualization(visualization: PopulatedVisualization): Promise<void> {\n await this.init(visualization);\n const styles = StyleRules.sanitizeStylesIndex(visualization.design.styles);\n this.LKStyles.initNodeColors(styles.node);\n this.LKStyles.initNodesIcons(styles.node);\n this.LKStyles.initNodesSizes(styles.node);\n this.LKStyles.initNodesShapes(styles.node);\n this.LKStyles.initEdgesWidth(styles.edge);\n this.LKStyles.initEdgesShape(styles.edge);\n this.LKStyles.initEdgesColor(styles.edge);\n await this.LKCaptions.initVizCaptions({\n node: visualization.nodeFields.captions || {},\n edge: visualization.edgeFields.captions || {}\n });\n this.LKTransformation.groupedEdges = visualization.edgeGrouping;\n await this.LKTransformation.initTransformation();\n this.LKTransformation.initEdgeGroupingStyle();\n }\n\n /**\n * Adding nodes then adding edges to the graph\n */\n public async addGraphAfterValidation(\n graph: RawGraph<LkNodeData, LkEdgeData>\n ): Promise<{\n nodes: NodeList<LkNodeData>;\n edges: EdgeList<LkEdgeData>;\n }> {\n const addedNodes = await this.addNodes(graph.nodes);\n const addedEdges = await this.addEdges(graph.edges);\n return {\n nodes: addedNodes,\n edges: addedEdges\n };\n }\n\n /**\n * Adding edges to the graph after filtering disconnected ones\n */\n public addEdges(edges: Array<RawEdge<LkEdgeData>>, options?: AddItemOptions): Promise<EdgeList> {\n return super.addEdges(edges, {...options, ignoreInvalid: true});\n }\n\n /**\n * Return the list of non filtered nodes\n */\n public getNonFilteredNodes(items?: Array<NodeId>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => !i.hasClass('filtered'))\n : // take only none virtual nodes\n this.getNodes('raw').filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered nodes\n * @param items items to check if they are filtered\n * @param filter type of nodes to check if they are filtered ( nodes that are visible, raw nodes (none virtual) or all nodes)\n */\n public getFilteredNodes(\n items?: Array<NodeId>,\n filter: 'visible' | 'raw' | 'all' = 'raw'\n ): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => i.hasClass('filtered'))\n : this.getNodes(filter).filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Return the list of non filtered edges\n */\n public getNonFilteredEdges(items?: Array<any>): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => !i.hasClass('filtered'))\n : this.getEdges('raw').filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered edges\n */\n public getFilteredEdges(\n items?: Array<any>,\n filter: 'visible' | 'raw' | 'all' = 'raw'\n ): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => i.hasClass('filtered'))\n : this.getEdges(filter).filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Do a full reset on ogma and streams of ogma\n */\n public shutDown(): void {\n this.destroy();\n if (this.store) {\n this.store.clear();\n }\n }\n\n /**\n * Reset the Ogma instance so that it can be used fresh in the next visulization\n */\n public clearOgmaState(): void {\n this.reset();\n if (this.store) {\n this.store.clear();\n }\n this.initOgmaLinkuriousParser();\n }\n\n /**\n * Updates the Ogma config when config changes in LKE. If init, options were already set by the Ogma.reset()\n */\n public setConfigOgma(configuration?: IOgmaConfig, init?: boolean, baseUrl?: string): void {\n if (configuration) {\n // here we make sure that the internal config object is updated and we have the correct one when resetting\n this._configuration = configuration;\n }\n if (!init) {\n this.setOptions({\n ...this._configuration.options,\n renderer: this._configuration.renderer\n });\n }\n this.setStyles(this._configuration, baseUrl);\n this.setCaptions(this._configuration);\n }\n}\n"]}
@@ -66,9 +66,8 @@ class OgmaTools {
66
66
  else {
67
67
  return true;
68
68
  }
69
- const [r, g, b] = rgb
70
- .replace(/\s/g, '')
71
- .match(/rgba?\((\d{1,3}),(\d{1,3}),(\d{1,3})(,\d{1,3})?\)/)
69
+ const [r, g, b] = /rgba?\((\d{1,3}),(\d{1,3}),(\d{1,3})(,\d{1,3})?\)/
70
+ .exec(rgb.replace(/\s/g, ''))
72
71
  .slice(1, 4);
73
72
  if (!tools_1.Tools.isDefined(r) || !tools_1.Tools.isDefined(g) || !tools_1.Tools.isDefined(b)) {
74
73
  console.warn('The given color is not a valid rgb formatted color');
@@ -1 +1 @@
1
- {"version":3,"file":"ogmaTool.js","sourceRoot":"","sources":["../../src/tools/ogmaTool.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,mCAA8B;AAC9B,iDAA2C;AAE3C,MAAa,SAAS;IACpB;;;;OAIG;IACI,MAAM,CAAC,kBAAkB,CAAC,KAAuC;QACtE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,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AK,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;YACrE,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;YACnE,OAAO,IAAI,CAAC;SACb;QACD,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC;IAC7D,CAAC;IAEM,MAAM,CAAC,MAAM,CAClB,IAAiE;QAEjE,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,UAAU,CACtB,KAA0E;QAE1E,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;CACF;AA3FD,8BA2FC","sourcesContent":["'use strict';\nimport {Color, NodeList, Node, EdgeList, Edge} from '@linkurious/ogma';\nimport {LkEdgeData, LkNodeData} from '@linkurious/rest-client';\n\nimport {Tools} from './tools';\nimport {HTML_COLORS} from './colorPalette';\n\nexport class OgmaTools {\n /**\n * Get the amount of hidden neighbors from a list of nodes\n *\n * @param nodes\n */\n public static getHiddenNeighbors(nodes: NodeList<LkNodeData, LkEdgeData>): number {\n return nodes.reduce((result: number, node: Node<LkNodeData, LkEdgeData>) => {\n const statistics = node.getData('statistics');\n if (statistics !== undefined) {\n const hiddenNeighbors =\n statistics.degree !== undefined && !statistics.supernode\n ? statistics.degree - Tools.getDegreeWithoutSelfConnection(node)\n : statistics.supernodeDegree;\n if (hiddenNeighbors !== undefined && hiddenNeighbors > 0) {\n return (result += hiddenNeighbors);\n }\n }\n return result;\n }, 0);\n }\n\n /**\n * Return the visible degree of a node without self connection (self edge)\n *\n * @param {Node} node\n * @return {number}\n */\n public static getDegreeWithoutSelfConnection(node: Node<LkNodeData, LkEdgeData>): number {\n return node.getAdjacentNodes({policy: 'exclude-sources', filter: 'all'}).size;\n }\n\n /**\n * Return true if the color tone is \"bright\"\n *\n * @param {string} color\n * @returns {boolean}\n */\n public static isBright(color: Color): boolean {\n if (color === null || !Tools.isStringFilled(color)) {\n return true;\n }\n const hexRegExp = /#[A-Fa-f0-9]{3,6}/;\n const rgbRegExp = /^rgb\\(\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*\\)$/i;\n const rgbaRegExp = /^rgba\\(\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|1|0?\\.\\d+)\\s*\\)$/i;\n let rgb: string;\n\n if (hexRegExp.test(color)) {\n if (color.length < 5) {\n color += color.slice(1);\n }\n color = color.replace('#', '');\n const r = parseInt(color[0].toString() + color[1].toString(), 16);\n const g = parseInt(color[2].toString() + color[3].toString(), 16);\n const b = parseInt(color[4].toString() + color[5].toString(), 16);\n rgb = `rgb(${r}, ${g}, ${b})`;\n } else if (\n rgbRegExp.test(color) ||\n rgbaRegExp.test(color) ||\n HTML_COLORS[color.toLowerCase()] !== undefined\n ) {\n rgb = Tools.isDefined(HTML_COLORS[color.toLowerCase()])\n ? HTML_COLORS[color.toLowerCase()]['rgb']\n : color;\n } else {\n return true;\n }\n\n const [r, g, b] = rgb\n .replace(/\\s/g, '')\n .match(/rgba?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3})(,\\d{1,3})?\\)/)!\n .slice(1, 4);\n\n if (!Tools.isDefined(r) || !Tools.isDefined(g) || !Tools.isDefined(b)) {\n console.warn('The given color is not a valid rgb formatted color');\n return true;\n }\n return (+r * 299 + +g * 587 + +b * 114) / 1000 > 255 * 0.7;\n }\n\n public static isNode(\n item: Node<LkNodeData, LkEdgeData> | Edge<LkEdgeData, LkNodeData>\n ): item is Node<LkNodeData, LkEdgeData> {\n return item.isNode;\n }\n\n public static isNodeList(\n items: NodeList<LkNodeData, LkEdgeData> | EdgeList<LkEdgeData, LkNodeData>\n ): items is NodeList<LkNodeData, LkEdgeData> {\n return items.isNode;\n }\n}\n"]}
1
+ {"version":3,"file":"ogmaTool.js","sourceRoot":"","sources":["../../src/tools/ogmaTool.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,mCAA8B;AAC9B,iDAA2C;AAE3C,MAAa,SAAS;IACpB;;;;OAIG;IACI,MAAM,CAAC,kBAAkB,CAAC,KAAuC;QACtE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,MAAc,EAAE,IAAkC,EAAE,EAAE;YACzE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAC9C,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC5B,MAAM,eAAe,GACnB,UAAU,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,SAAS;oBACtD,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,aAAK,CAAC,8BAA8B,CAAC,IAAI,CAAC;oBAChE,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC;gBACjC,IAAI,eAAe,KAAK,SAAS,IAAI,eAAe,GAAG,CAAC,EAAE;oBACxD,OAAO,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC;iBACpC;aACF;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,8BAA8B,CAAC,IAAkC;QAC7E,OAAO,IAAI,CAAC,gBAAgB,CAAC,EAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC,IAAI,CAAC;IAChF,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,CAAC,KAAY;QACjC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,aAAK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gBACrD,CAAC,CAAC,0BAAW,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC;gBACzC,CAAC,CAAC,KAAK,CAAC;SACX;aAAM;YACL,OAAO,IAAI,CAAC;SACb;QAED,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,mDAAmD;aAClE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAE;aAC7B,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEf,IAAI,CAAC,aAAK,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAK,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;YACrE,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;YACnE,OAAO,IAAI,CAAC;SACb;QACD,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC;IAC7D,CAAC;IAEM,MAAM,CAAC,MAAM,CAClB,IAAiE;QAEjE,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,UAAU,CACtB,KAA0E;QAE1E,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;CACF;AA1FD,8BA0FC","sourcesContent":["'use strict';\nimport {Color, NodeList, Node, EdgeList, Edge} from '@linkurious/ogma';\nimport {LkEdgeData, LkNodeData} from '@linkurious/rest-client';\n\nimport {Tools} from './tools';\nimport {HTML_COLORS} from './colorPalette';\n\nexport class OgmaTools {\n /**\n * Get the amount of hidden neighbors from a list of nodes\n *\n * @param nodes\n */\n public static getHiddenNeighbors(nodes: NodeList<LkNodeData, LkEdgeData>): number {\n return nodes.reduce((result: number, node: Node<LkNodeData, LkEdgeData>) => {\n const statistics = node.getData('statistics');\n if (statistics !== undefined) {\n const hiddenNeighbors =\n statistics.degree !== undefined && !statistics.supernode\n ? statistics.degree - Tools.getDegreeWithoutSelfConnection(node)\n : statistics.supernodeDegree;\n if (hiddenNeighbors !== undefined && hiddenNeighbors > 0) {\n return (result += hiddenNeighbors);\n }\n }\n return result;\n }, 0);\n }\n\n /**\n * Return the visible degree of a node without self connection (self edge)\n *\n * @param {Node} node\n * @return {number}\n */\n public static getDegreeWithoutSelfConnection(node: Node<LkNodeData, LkEdgeData>): number {\n return node.getAdjacentNodes({policy: 'exclude-sources', filter: 'all'}).size;\n }\n\n /**\n * Return true if the color tone is \"bright\"\n *\n * @param {string} color\n * @returns {boolean}\n */\n public static isBright(color: Color): boolean {\n if (color === null || !Tools.isStringFilled(color)) {\n return true;\n }\n const hexRegExp = /#[A-Fa-f0-9]{3,6}/;\n const rgbRegExp = /^rgb\\(\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*\\)$/i;\n const rgbaRegExp = /^rgba\\(\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|1|0?\\.\\d+)\\s*\\)$/i;\n let rgb: string;\n\n if (hexRegExp.test(color)) {\n if (color.length < 5) {\n color += color.slice(1);\n }\n color = color.replace('#', '');\n const r = parseInt(color[0].toString() + color[1].toString(), 16);\n const g = parseInt(color[2].toString() + color[3].toString(), 16);\n const b = parseInt(color[4].toString() + color[5].toString(), 16);\n rgb = `rgb(${r}, ${g}, ${b})`;\n } else if (\n rgbRegExp.test(color) ||\n rgbaRegExp.test(color) ||\n HTML_COLORS[color.toLowerCase()] !== undefined\n ) {\n rgb = Tools.isDefined(HTML_COLORS[color.toLowerCase()])\n ? HTML_COLORS[color.toLowerCase()]['rgb']\n : color;\n } else {\n return true;\n }\n\n const [r, g, b] = /rgba?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3})(,\\d{1,3})?\\)/\n .exec(rgb.replace(/\\s/g, ''))!\n .slice(1, 4);\n\n if (!Tools.isDefined(r) || !Tools.isDefined(g) || !Tools.isDefined(b)) {\n console.warn('The given color is not a valid rgb formatted color');\n return true;\n }\n return (+r * 299 + +g * 587 + +b * 114) / 1000 > 255 * 0.7;\n }\n\n public static isNode(\n item: Node<LkNodeData, LkEdgeData> | Edge<LkEdgeData, LkNodeData>\n ): item is Node<LkNodeData, LkEdgeData> {\n return item.isNode;\n }\n\n public static isNodeList(\n items: NodeList<LkNodeData, LkEdgeData> | EdgeList<LkEdgeData, LkNodeData>\n ): items is NodeList<LkNodeData, LkEdgeData> {\n return items.isNode;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linkurious/ogma-linkurious-parser",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "author": "Linkurious SAS",
5
5
  "description": "Parse and load a Linkurious visualization in Ogma with one line of code ",
6
6
  "files": [
@@ -13,7 +13,7 @@
13
13
  "main": "./dist/index.js",
14
14
  "types": "./dist/index.d.ts",
15
15
  "engines": {
16
- "node": "20.12.1"
16
+ "node": "20.14.0"
17
17
  },
18
18
  "scripts": {
19
19
  "build": "tsc -b",
@@ -50,11 +50,11 @@
50
50
  "sha1": "1.1.1"
51
51
  },
52
52
  "peerDependencies": {
53
- "@linkurious/ogma": "4.5.9"
53
+ "@linkurious/ogma": "5.1.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@linkurious/ogma": "4.5.9",
57
- "@linkurious/rest-client": "4.1.0",
56
+ "@linkurious/ogma": "5.1.1",
57
+ "@linkurious/rest-client": "4.1.2",
58
58
  "@rollup/plugin-buble": "0.21.3",
59
59
  "@rollup/plugin-commonjs": "17.0.0",
60
60
  "@rollup/plugin-json": "4.1.0",
@@ -63,12 +63,12 @@
63
63
  "@types/lodash": "4.14.182",
64
64
  "@types/mocha": "5.2.7",
65
65
  "@types/sha1": "1.1.2",
66
- "@typescript-eslint/eslint-plugin": "2.25.0",
67
- "@typescript-eslint/parser": "2.25.0",
66
+ "@typescript-eslint/eslint-plugin": "7.13.1",
67
+ "@typescript-eslint/parser": "7.13.1",
68
68
  "chai": "4.3.4",
69
- "eslint": "6.8.0",
69
+ "eslint": "8.57.0",
70
70
  "eslint-config-prettier": "6.10.1",
71
- "eslint-plugin-import": "2.22.1",
71
+ "eslint-plugin-import": "2.29.0",
72
72
  "eslint-plugin-prettier": "3.4.0",
73
73
  "mocha": "9.2.0",
74
74
  "mocha-junit-reporter": "2.0.2",