@graphty/cytoscape-extensions 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/graph-data.ts +31 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphty/cytoscape-extensions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "Graphty layouts, algorithms, graph generators, sample datasets and file import/export as Cytoscape.js extensions",
|
|
5
5
|
"author": "Adam Powers <apowers@ato.ms>",
|
|
6
6
|
"type": "module",
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
},
|
|
72
72
|
"homepage": "https://graphty.app/docs/cytoscape-extensions/",
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@graphty/graph-io": "^0.3.
|
|
75
|
-
"@graphty/graph-
|
|
76
|
-
"@graphty/
|
|
74
|
+
"@graphty/graph-io": "^0.3.48",
|
|
75
|
+
"@graphty/webgpu-graph-algorithms": "^0.6.61",
|
|
76
|
+
"@graphty/graph-samples": "^0.1.39"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@graphty/algorithms": "^3.0.0",
|
|
@@ -103,9 +103,9 @@
|
|
|
103
103
|
"typescript": "^5.9.3",
|
|
104
104
|
"vite": "^7.0.5",
|
|
105
105
|
"vitest": "4.1.11",
|
|
106
|
-
"@graphty/graph-format": "^1.4.
|
|
107
|
-
"@graphty/algorithms": "^3.4.
|
|
108
|
-
"@graphty/layout": "^2.5.
|
|
106
|
+
"@graphty/graph-format": "^1.4.7",
|
|
107
|
+
"@graphty/algorithms": "^3.4.14",
|
|
108
|
+
"@graphty/layout": "^2.5.10"
|
|
109
109
|
},
|
|
110
110
|
"scripts": {
|
|
111
111
|
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json && vite build --config vite.bundle.config.ts --mode cdn --logLevel warn && vite build --config vite.bundle.config.ts --logLevel warn",
|
package/src/graph-data.ts
CHANGED
|
@@ -164,6 +164,32 @@ function freeImportId(cy: Core): string {
|
|
|
164
164
|
return String(k);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Sets each added element's style bypass. Cytoscape skips a definition whose id an earlier one took, so the added
|
|
169
|
+
* collection is walked beside the definitions and a definition gets its bypass only when it is the next element.
|
|
170
|
+
* @param added - what cy.add returned, in definition order
|
|
171
|
+
* @param defs - the definitions, whose `data.id` cy.add filled in
|
|
172
|
+
* @param bypass - one bypass or null per definition
|
|
173
|
+
*/
|
|
174
|
+
function applyBypass(
|
|
175
|
+
added: CollectionReturnValue,
|
|
176
|
+
defs: ElementDefinition[],
|
|
177
|
+
bypass: readonly (Readonly<Record<string, string | number>> | null)[],
|
|
178
|
+
): void {
|
|
179
|
+
let j = 0;
|
|
180
|
+
defs.forEach((def, i) => {
|
|
181
|
+
const ele = added[j];
|
|
182
|
+
if (ele?.id() !== def.data.id) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
j++;
|
|
186
|
+
const b = bypass[i];
|
|
187
|
+
if (b !== null && b !== undefined) {
|
|
188
|
+
ele.style(b as never);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
167
193
|
/**
|
|
168
194
|
* Registers graphtyGenerate, graphtyDataset, graphtyImport and graphtyExport.
|
|
169
195
|
* @param cytoscape - the cytoscape function
|
|
@@ -191,14 +217,12 @@ export function registerGraphData(cytoscape: Register): void {
|
|
|
191
217
|
...(styled && options.importId === undefined ? { importId: freeImportId(this) } : {}),
|
|
192
218
|
});
|
|
193
219
|
const apply = options?.applyStyles === true && r.stylesheet !== undefined;
|
|
194
|
-
if (apply) {
|
|
195
|
-
r.bypass?.forEach((b, i) => {
|
|
196
|
-
if (b !== null) {
|
|
197
|
-
r.elements[i].style = b;
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
220
|
const elements = addTo(this, r.elements);
|
|
221
|
+
if (apply && r.bypass !== undefined) {
|
|
222
|
+
// Set after the add, not as the definition's `style`: Cytoscape 3.31 applies a creation-time
|
|
223
|
+
// bypass before the edge has its endpoints, and a `curve-style` there throws in parallelEdges().
|
|
224
|
+
applyBypass(elements, r.elements, r.bypass);
|
|
225
|
+
}
|
|
202
226
|
const style = this.style() as unknown as AppendableStyle | undefined;
|
|
203
227
|
if (apply && r.stylesheet !== undefined && style !== undefined) {
|
|
204
228
|
// appended rule by rule: a round trip through style.json() turns the core's own function-valued
|