@graphty/cytoscape-extensions 0.0.28 → 0.0.29

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 (72) hide show
  1. package/dist/algorithm-options.d.ts +5 -0
  2. package/dist/algorithm-options.d.ts.map +1 -0
  3. package/dist/algorithm-options.js +285 -0
  4. package/dist/algorithm-options.js.map +1 -0
  5. package/dist/algorithms.d.ts +489 -0
  6. package/dist/algorithms.d.ts.map +1 -0
  7. package/dist/algorithms.js +1184 -0
  8. package/dist/algorithms.js.map +1 -0
  9. package/dist/cdn/chunks/elements-DkrLtNP8.js +1 -0
  10. package/dist/cdn/chunks/gpu-platform-browser-VBah74fl.js +2825 -0
  11. package/dist/cdn/chunks/index-C4RZkds_.js +10 -0
  12. package/dist/cdn/chunks/index-CAhmhhmb.js +1 -0
  13. package/dist/cdn/chunks/io-Da5POp5D.js +268 -0
  14. package/dist/cdn/chunks/preload-helper-DEpZAvig.js +1 -0
  15. package/dist/cdn/chunks/samples-BkLzaDJ3.js +1 -0
  16. package/dist/cdn/chunks/sigv4-EokFic1V-CWJiFeEe.js +3 -0
  17. package/dist/cdn/chunks/sources-cypher-BGGD4kJ9.js +5 -0
  18. package/dist/cdn/chunks/sources-ndex-CxnPOYff.js +1 -0
  19. package/dist/cdn/chunks/sources-rest-BPNV8mX-.js +1 -0
  20. package/dist/cdn/chunks/sources-sparql-BiqRQuHD.js +5 -0
  21. package/dist/cdn/cytoscape-extensions.js +1 -0
  22. package/dist/cdn/io.js +1 -0
  23. package/dist/cytoscape-extensions.bundle.js +2825 -0
  24. package/dist/elements.d.ts +69 -0
  25. package/dist/elements.d.ts.map +1 -0
  26. package/dist/elements.js +343 -0
  27. package/dist/elements.js.map +1 -0
  28. package/dist/gpu-platform-browser.d.ts +11 -0
  29. package/dist/gpu-platform-browser.d.ts.map +1 -0
  30. package/dist/gpu-platform-browser.js +22 -0
  31. package/dist/gpu-platform-browser.js.map +1 -0
  32. package/dist/gpu-platform-node.d.ts +15 -0
  33. package/dist/gpu-platform-node.d.ts.map +1 -0
  34. package/dist/gpu-platform-node.js +27 -0
  35. package/dist/gpu-platform-node.js.map +1 -0
  36. package/dist/gpu.d.ts +149 -0
  37. package/dist/gpu.d.ts.map +1 -0
  38. package/dist/gpu.js +312 -0
  39. package/dist/gpu.js.map +1 -0
  40. package/dist/graph-data.d.ts +101 -0
  41. package/dist/graph-data.d.ts.map +1 -0
  42. package/dist/graph-data.js +147 -0
  43. package/dist/graph-data.js.map +1 -0
  44. package/dist/index.d.ts +36 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +48 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/io.d.ts +111 -0
  49. package/dist/io.d.ts.map +1 -0
  50. package/dist/io.js +258 -0
  51. package/dist/io.js.map +1 -0
  52. package/dist/layouts.d.ts +207 -0
  53. package/dist/layouts.d.ts.map +1 -0
  54. package/dist/layouts.js +615 -0
  55. package/dist/layouts.js.map +1 -0
  56. package/dist/lazy.d.ts +21 -0
  57. package/dist/lazy.d.ts.map +1 -0
  58. package/dist/lazy.js +32 -0
  59. package/dist/lazy.js.map +1 -0
  60. package/dist/samples.d.ts +115 -0
  61. package/dist/samples.d.ts.map +1 -0
  62. package/dist/samples.js +237 -0
  63. package/dist/samples.js.map +1 -0
  64. package/dist/snapshot.d.ts +81 -0
  65. package/dist/snapshot.d.ts.map +1 -0
  66. package/dist/snapshot.js +225 -0
  67. package/dist/snapshot.js.map +1 -0
  68. package/dist/webgpu-provider.d.ts +25 -0
  69. package/dist/webgpu-provider.d.ts.map +1 -0
  70. package/dist/webgpu-provider.js +53 -0
  71. package/dist/webgpu-provider.js.map +1 -0
  72. package/package.json +13 -9
@@ -0,0 +1,147 @@
1
+ /**
2
+ * The core methods that put graphs into Cytoscape and take them out: graphtyGenerate, graphtyDataset,
3
+ * graphtyImport and graphtyExport. Each loads its implementation (./samples.js or ./io.js, and with them the
4
+ * graph-samples or graph-io package) on its first call, so registering them costs a page nothing.
5
+ */
6
+ import { coreDestroyedError } from "./gpu.js";
7
+ import { loadPart } from "./lazy.js";
8
+ /**
9
+ * Rejected by graphtyGenerate, graphtyDataset and graphtyImport when a node id of the new graph is already in the
10
+ * core; nothing is added. `name` is "IdTakenError", `code` is "E_ID_TAKEN" and `id` is the first clashing id.
11
+ */
12
+ export class IdTakenError extends Error {
13
+ /**
14
+ * Creates the error.
15
+ * @param id - the clashing id
16
+ */
17
+ constructor(id) {
18
+ super(`graphty: the core already has an element with id "${id}", so the new graph would merge into it; ` +
19
+ "remove the existing elements (cy.elements().remove()) or add the graph to an empty core");
20
+ /** Always "E_ID_TAKEN". */
21
+ this.code = "E_ID_TAKEN";
22
+ this.name = "IdTakenError";
23
+ this.id = id;
24
+ }
25
+ }
26
+ /**
27
+ * Adds element definitions to a core. An edge whose id the core already holds loses it and gets one from
28
+ * Cytoscape, so a second import into the same core does not fail on edge ids the file chose. A node id the core
29
+ * already holds is refused: Cytoscape would skip that node and attach the new edges to the old one, merging the
30
+ * two graphs.
31
+ * @param cy - the core
32
+ * @param elements - the definitions; edge data may be changed
33
+ * @returns the added elements
34
+ * @throws IdTakenError naming the first node id the core already holds; nothing is added
35
+ * @throws Error coded E_CORE_DESTROYED when the core was destroyed (before the call or while it loaded); nothing
36
+ * is added
37
+ */
38
+ function addTo(cy, elements) {
39
+ if (cy.destroyed()) {
40
+ throw coreDestroyedError();
41
+ }
42
+ for (const el of elements) {
43
+ if (el.group === "nodes" && el.data.id !== undefined && cy.getElementById(el.data.id).nonempty()) {
44
+ throw new IdTakenError(el.data.id);
45
+ }
46
+ }
47
+ for (const el of elements) {
48
+ if (el.group === "edges" && el.data.id !== undefined && cy.getElementById(el.data.id).nonempty()) {
49
+ delete el.data.id;
50
+ }
51
+ }
52
+ return cy.add(elements);
53
+ }
54
+ /**
55
+ * An import id no element of the core holds yet.
56
+ * @param cy - the core
57
+ * @returns the id
58
+ */
59
+ function freeImportId(cy) {
60
+ const taken = new Set(cy.elements("[graphty_import]").map((e) => String(e.data("graphty_import"))));
61
+ let k = taken.size + 1;
62
+ while (taken.has(String(k))) {
63
+ k++;
64
+ }
65
+ return String(k);
66
+ }
67
+ /**
68
+ * Sets each added element's style bypass. Cytoscape skips a definition whose id an earlier one took, so the added
69
+ * collection is walked beside the definitions and a definition gets its bypass only when it is the next element.
70
+ * @param added - what cy.add returned, in definition order
71
+ * @param defs - the definitions, whose `data.id` cy.add filled in
72
+ * @param bypass - one bypass or null per definition
73
+ */
74
+ function applyBypass(added, defs, bypass) {
75
+ let j = 0;
76
+ defs.forEach((def, i) => {
77
+ const ele = added[j];
78
+ if (ele?.id() !== def.data.id) {
79
+ return;
80
+ }
81
+ j++;
82
+ const b = bypass[i];
83
+ if (b !== null && b !== undefined) {
84
+ ele.style(b);
85
+ }
86
+ });
87
+ }
88
+ /**
89
+ * Registers graphtyGenerate, graphtyDataset, graphtyImport and graphtyExport.
90
+ * @param cytoscape - the cytoscape function
91
+ */
92
+ export function registerGraphData(cytoscape) {
93
+ cytoscape("core", "graphtyGenerate", async function (name, options) {
94
+ const { generateElements } = await loadPart(import("./samples.js"), "graphtyGenerate");
95
+ const r = generateElements(name, options);
96
+ return { elements: addTo(this, r.elements), directed: r.directed };
97
+ });
98
+ cytoscape("core", "graphtyDataset", async function (name, options) {
99
+ const { datasetElements } = await loadPart(import("./samples.js"), "graphtyDataset");
100
+ const r = await datasetElements(name, options);
101
+ options?.signal?.throwIfAborted();
102
+ return { elements: addTo(this, r.elements), directed: r.directed };
103
+ });
104
+ cytoscape("core", "graphtyImport", async function (input, format, options) {
105
+ const { importElements } = await loadPart(import("./io.js"), "graphtyImport");
106
+ const styled = options?.styles !== undefined && options.styles !== false;
107
+ const r = await importElements(input, format, {
108
+ ...options,
109
+ ...(styled && options.importId === undefined ? { importId: freeImportId(this) } : {}),
110
+ });
111
+ const apply = options?.applyStyles === true && r.stylesheet !== undefined;
112
+ const elements = addTo(this, r.elements);
113
+ if (apply && r.bypass !== undefined) {
114
+ // Set after the add, not as the definition's `style`: Cytoscape 3.31 applies a creation-time
115
+ // bypass before the edge has its endpoints, and a `curve-style` there throws in parallelEdges().
116
+ applyBypass(elements, r.elements, r.bypass);
117
+ }
118
+ const style = this.style();
119
+ if (apply && r.stylesheet !== undefined && style !== undefined) {
120
+ // appended rule by rule: a round trip through style.json() turns the core's own function-valued
121
+ // properties into the string "fn", which Cytoscape then rejects
122
+ let s = style;
123
+ for (const rule of r.stylesheet) {
124
+ s = s.selector(rule.selector).style(rule.style);
125
+ }
126
+ s.update();
127
+ }
128
+ return {
129
+ elements,
130
+ directed: r.directed,
131
+ format: r.format,
132
+ report: r.report,
133
+ ...(r.stylesheet === undefined ? {} : { stylesheet: r.stylesheet }),
134
+ };
135
+ });
136
+ const exportFn = async (eles, format, options) => {
137
+ const { exportElements } = await loadPart(import("./io.js"), "graphtyExport");
138
+ return exportElements(eles, format, options);
139
+ };
140
+ cytoscape("core", "graphtyExport", function (format, options) {
141
+ return exportFn(this.elements(), format, options);
142
+ });
143
+ cytoscape("collection", "graphtyExport", function (format, options) {
144
+ return exportFn(this, format, options);
145
+ });
146
+ }
147
+ //# sourceMappingURL=graph-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-data.js","sourceRoot":"","sources":["../src/graph-data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAuFrC;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAMnC;;;OAGG;IACH,YAAY,EAAU;QAClB,KAAK,CACD,qDAAqD,EAAE,2CAA2C;YAC9F,yFAAyF,CAChG,CAAC;QAbN,2BAA2B;QAClB,SAAI,GAAG,YAAY,CAAC;QAazB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACjB,C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AAE,OAAO,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IACH,SAAS,CACL,YAAY,EACZ,eAAe,EACf,UAA4B,MAAoB,EAAE,OAAuB;QACrE,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC,CACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The Cytoscape.js adapter (package "@graphty/cytoscape-extensions"): graphty layouts and algorithms as Cytoscape.js extensions.
3
+ *
4
+ * ```ts
5
+ * import cytoscape from "cytoscape";
6
+ * import graphtyCytoscape from "@graphty/cytoscape-extensions";
7
+ * cytoscape.use(graphtyCytoscape);
8
+ * cy.layout({ name: "graphty-forceatlas2" }).run();
9
+ * cy.elements().graphtyPageRank().rank("#a");
10
+ *
11
+ * // the ...Async methods and the simulations use WebGPU when the runtime has it; nothing else to import
12
+ * const r = await cy.elements().graphtyPageRankAsync();
13
+ * r.backend.ran; // "gpu" or "cpu", with r.backend.reason saying why
14
+ *
15
+ * // graphs in and out; each loads its parsers or generators on first use
16
+ * await cy.graphtyGenerate("barabasi-albert", { n: 500, m: 2, seed: 1 });
17
+ * await cy.graphtyImport(graphmlText, "graphml");
18
+ * const gexf = await cy.graphtyExport("gexf");
19
+ * ```
20
+ */
21
+ export { ALGORITHM_NAMES, type AlgorithmOptions, ASYNC_ALGORITHM_NAMES, type CutResult, type ElementRef, type GraphtyAlgorithms, type NodePair, type Partition, type PathsResult, type PointPathResult, type PredictedLink, type ScoreResult, type SearchResult, } from "./algorithms.js";
22
+ export { type Backend, configureWebGpu, GPU_SIZE_FLOOR, type GpuMode, type WebGpuOptions } from "./gpu.js";
23
+ export { type AddedGraph, type GraphtyGraphData, IdTakenError, type ImportedGraph } from "./graph-data.js";
24
+ export type { CytoscapeStylesheetRule, ExportFormat, ExportOptions, ImportFormat, ImportOptions, LossNote, } from "./io.js";
25
+ export { type GraphtyLayoutName, type GraphtyLayoutOptions, type GraphtyLayoutOptionsByName, type GraphtyLayouts, LAYOUT_NAMES, } from "./layouts.js";
26
+ export type { GeneratorName, GeneratorOptions } from "./samples.js";
27
+ export { type CytoscapeSnapshot, type NodeSelection, type SnapshotOptions, toSnapshot, writeData } from "./snapshot.js";
28
+ /**
29
+ * The Cytoscape extension: `cytoscape.use(graphtyCytoscape)` registers every layout in LAYOUT_NAMES as
30
+ * "graphty-<name>", every algorithm in ALGORITHM_NAMES as a collection and core method, and the core methods
31
+ * graphtyGenerate, graphtyDataset, graphtyImport and graphtyExport. A second `use()` with the same cytoscape does
32
+ * nothing (the script-tag build has already registered itself when a page calls `use()` again).
33
+ * @param cytoscape - the cytoscape function `use()` passes in
34
+ */
35
+ export default function graphtyCytoscape(cytoscape: (type: string, name: string, registrant: unknown) => void): void;
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EACH,eAAe,EACf,KAAK,gBAAgB,EACrB,qBAAqB,EACrB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3G,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3G,YAAY,EACR,uBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,QAAQ,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EACnB,YAAY,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAKxH;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CASnH"}
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The Cytoscape.js adapter (package "@graphty/cytoscape-extensions"): graphty layouts and algorithms as Cytoscape.js extensions.
3
+ *
4
+ * ```ts
5
+ * import cytoscape from "cytoscape";
6
+ * import graphtyCytoscape from "@graphty/cytoscape-extensions";
7
+ * cytoscape.use(graphtyCytoscape);
8
+ * cy.layout({ name: "graphty-forceatlas2" }).run();
9
+ * cy.elements().graphtyPageRank().rank("#a");
10
+ *
11
+ * // the ...Async methods and the simulations use WebGPU when the runtime has it; nothing else to import
12
+ * const r = await cy.elements().graphtyPageRankAsync();
13
+ * r.backend.ran; // "gpu" or "cpu", with r.backend.reason saying why
14
+ *
15
+ * // graphs in and out; each loads its parsers or generators on first use
16
+ * await cy.graphtyGenerate("barabasi-albert", { n: 500, m: 2, seed: 1 });
17
+ * await cy.graphtyImport(graphmlText, "graphml");
18
+ * const gexf = await cy.graphtyExport("gexf");
19
+ * ```
20
+ */
21
+ import { registerAlgorithms } from "./algorithms.js";
22
+ import { registerGraphData } from "./graph-data.js";
23
+ import { registerLayouts } from "./layouts.js";
24
+ export { ALGORITHM_NAMES, ASYNC_ALGORITHM_NAMES, } from "./algorithms.js";
25
+ export { configureWebGpu, GPU_SIZE_FLOOR } from "./gpu.js";
26
+ export { IdTakenError } from "./graph-data.js";
27
+ export { LAYOUT_NAMES, } from "./layouts.js";
28
+ export { toSnapshot, writeData } from "./snapshot.js";
29
+ /** Set on a cytoscape function once the extension is registered on it. */
30
+ const REGISTERED = Symbol.for("@graphty/cytoscape-extensions");
31
+ /**
32
+ * The Cytoscape extension: `cytoscape.use(graphtyCytoscape)` registers every layout in LAYOUT_NAMES as
33
+ * "graphty-<name>", every algorithm in ALGORITHM_NAMES as a collection and core method, and the core methods
34
+ * graphtyGenerate, graphtyDataset, graphtyImport and graphtyExport. A second `use()` with the same cytoscape does
35
+ * nothing (the script-tag build has already registered itself when a page calls `use()` again).
36
+ * @param cytoscape - the cytoscape function `use()` passes in
37
+ */
38
+ export default function graphtyCytoscape(cytoscape) {
39
+ const marked = cytoscape;
40
+ if (marked[REGISTERED] === true) {
41
+ return;
42
+ }
43
+ marked[REGISTERED] = true;
44
+ registerLayouts(cytoscape);
45
+ registerAlgorithms(cytoscape);
46
+ registerGraphData(cytoscape);
47
+ }
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EACH,eAAe,EAEf,qBAAqB,GAWxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAgB,eAAe,EAAE,cAAc,EAAoC,MAAM,UAAU,CAAC;AAC3G,OAAO,EAA0C,YAAY,EAAsB,MAAM,iBAAiB,CAAC;AAS3G,OAAO,EAKH,YAAY,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAoE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAExH,0EAA0E;AAC1E,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,SAAoE;IACzG,MAAM,MAAM,GAAG,SAA2D,CAAC;IAC3E,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9B,OAAO;IACX,CAAC;IACD,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAC1B,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3B,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC9B,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC"}
package/dist/io.d.ts ADDED
@@ -0,0 +1,111 @@
1
+ /**
2
+ * `@graphty/cytoscape-extensions/io`: reading and writing Cytoscape graphs in the file formats of @graphty/graph-io.
3
+ * cy.graphtyImport() and cy.graphtyExport() load this module on their first call, so a page that never imports or
4
+ * exports a file never downloads the parsers.
5
+ */
6
+ import { type CommonExportOptions, type ImportGraphOptions, type ImportInput, type ImportReport, type LossNote } from "@graphty/graph-io";
7
+ import { type CytoscapeStylesheetRule } from "@graphty/graph-io/styles";
8
+ import type { Collection, ElementDefinition } from "cytoscape";
9
+ /** One thing graphtyExport's format cannot hold: `code`, `message`, the data field (`column`) and how many values. */
10
+ export type { LossNote } from "@graphty/graph-io";
11
+ /**
12
+ * The formats graphtyImport reads; "auto" sniffs the format from the content (and `filename` when given). "cys" is a
13
+ * Cytoscape desktop session file, which must be passed as bytes.
14
+ */
15
+ export type ImportFormat = "auto" | "gexf" | "graphml" | "gml" | "dot" | "pajek" | "csv" | "json" | "neo4j" | "xgmml" | "cx2" | "cx" | "obo" | "cys";
16
+ /** The formats graphtyExport writes. XGMML is the one Cytoscape desktop opens as a network file. */
17
+ export type ExportFormat = "gexf" | "graphml" | "gml" | "dot" | "pajek" | "csv" | "json" | "neo4j" | "xgmml" | "cx2";
18
+ /** One rule of a Cytoscape.js stylesheet: a selector and its properties. */
19
+ export type { CytoscapeStylesheetRule } from "@graphty/graph-io/styles";
20
+ /**
21
+ * Options of graphtyImport: graph-io's import options (`filename`, `graphIndex`, format-specific ones, ...).
22
+ * `styles: true` also reads the file's styles (its colors, sizes, shapes, ...) as a Cytoscape.js stylesheet,
23
+ * returned as `stylesheet`; a property the file leaves to the program that wrote it gets that program's default
24
+ * (`styles: { toolDefaults: false }` leaves them out).
25
+ */
26
+ export type ImportOptions = Omit<ImportGraphOptions, "format"> & {
27
+ /**
28
+ * With `styles`, graphtyImport also appends the file's stylesheet to the core's own and gives each element the
29
+ * per-element overrides that make it exact. Default false: the stylesheet is only returned.
30
+ */
31
+ readonly applyStyles?: boolean | undefined;
32
+ /**
33
+ * With `styles`, the value of the `graphty_import` data field every imported element gets and every rule of the
34
+ * stylesheet tests, so a second import into the same core never restyles the first one's elements. Default: a
35
+ * new one for each import.
36
+ */
37
+ readonly importId?: string | undefined;
38
+ };
39
+ /**
40
+ * Options of graphtyExport: graph-io's export options for the format, plus whether to write a directed graph.
41
+ * `sanitizeIds` defaults to "mangle" here (graph-io's default is "error"): GML and CX2 take only integer ids, so
42
+ * when a node id is not a plain non-negative integer ("a", "-1", "007") the nodes are numbered and the original
43
+ * kept in an attribute graphtyImport restores. When every id is one ("0", "17"), the ids are written as they are,
44
+ * and "error" accepts them too.
45
+ * JSON is written as Cytoscape JSON (`dialect: "cytoscape"`, the shape `cy.json()` and `cy.add()` use), which keeps
46
+ * edge ids, compound parents and positions; pass `dialect: "node-link"` for the NetworkX shape.
47
+ */
48
+ export interface ExportOptions extends CommonExportOptions {
49
+ /**
50
+ * Write the core's styles too: its stylesheet's rules, with what the core draws for each element as the truth
51
+ * (a function-valued property is written per element and reported as W_STYLE_LAYER_FLATTENED). Each format
52
+ * keeps as much of them as it can, so importing the file with `styles: true` draws the same; `onLoss` hears
53
+ * about the rest (W_STYLE_ codes). Default false: without it `onLoss` hears W_STYLES_NOT_EXPORTED when the core
54
+ * has a stylesheet of its own.
55
+ */
56
+ readonly styles?: boolean | undefined;
57
+ /** Format-specific options, passed to graph-io as they are. */
58
+ readonly [formatOption: string]: unknown;
59
+ /** Write the graph as directed. Default false. */
60
+ readonly directed?: boolean | undefined;
61
+ /**
62
+ * Called before writing with what the format cannot hold (positions in GraphML, lists and objects in DOT,
63
+ * ...), one note per column and kind of loss; not called when nothing is lost. Without it a loss is silent.
64
+ */
65
+ readonly onLoss?: ((notes: readonly LossNote[]) => void) | undefined;
66
+ }
67
+ /** A file read into Cytoscape element definitions. */
68
+ export interface ImportedElements {
69
+ /** The nodes, then the edges. */
70
+ readonly elements: ElementDefinition[];
71
+ /** Whether the file's graph is directed: pass it as `directed` to the algorithms. */
72
+ readonly directed: boolean;
73
+ /** The format the input was read as. */
74
+ readonly format: string;
75
+ /** graph-io's report: counts, warnings, and what could not be represented. */
76
+ readonly report: ImportReport;
77
+ /**
78
+ * With `styles`, the file's styles as a Cytoscape.js stylesheet scoped to this import; append it to the core's
79
+ * rule by rule (`cy.style().selector(r.selector).style(r.style)` for each, then `cy.style().update()`). Absent
80
+ * without `styles`.
81
+ */
82
+ readonly stylesheet?: CytoscapeStylesheetRule[];
83
+ /**
84
+ * With `styles`, per element (in the order of `elements`) the style overrides that make it draw exactly as the
85
+ * file says where the stylesheet alone does not, or null; give them as each definition's `style`.
86
+ */
87
+ readonly bypass?: (Readonly<Record<string, string | number>> | null)[];
88
+ }
89
+ /**
90
+ * Reads a graph file into Cytoscape element definitions.
91
+ * Without `styles`, a GEXF `viz:color`, `viz:size`, `viz:shape` and `viz:thickness` also become data fields
92
+ * (`data.color` as four numbers from 0 to 1, `data.size`, `data.shape`, `data.thickness`); these fields are
93
+ * deprecated and are removed in the next major release: import with `styles: true`, whose stylesheet draws them.
94
+ * With `styles: true` they are left out of data.
95
+ * @param input - the file as text, bytes, a stream or chunks
96
+ * @param format - the format, or "auto" to sniff it
97
+ * @param options - graph-io's import options
98
+ * @returns the elements, the direction, the format and graph-io's report
99
+ * @throws ImportError (from graph-io) when the file cannot be read, or when it yields no node and reports an error
100
+ */
101
+ export declare function importElements(input: ImportInput | ArrayBuffer, format?: ImportFormat, options?: ImportOptions): Promise<ImportedElements>;
102
+ /**
103
+ * Writes a collection as a graph file: every data field, each node's position and compound parent, and each
104
+ * edge's id, as far as the format holds them (`onLoss` hears about the rest).
105
+ * @param eles - the nodes and the edges between them
106
+ * @param format - the format
107
+ * @param options - graph-io's export options for the format, plus `directed`
108
+ * @returns the file's text; rejects (a TypeError) when `eles` is not a collection
109
+ */
110
+ export declare function exportElements(eles: Collection, format: ExportFormat, options?: ExportOptions): Promise<string>;
111
+ //# sourceMappingURL=io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAEH,KAAK,mBAAmB,EAIxB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAEhB,KAAK,YAAY,EACjB,KAAK,QAAQ,EAEhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,KAAK,uBAAuB,EAM/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAQ,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAIrE,sHAAsH;AACtH,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAClB,MAAM,GACN,MAAM,GACN,SAAS,GACT,KAAK,GACL,KAAK,GACL,OAAO,GACP,KAAK,GACL,MAAM,GACN,OAAO,GACP,OAAO,GACP,KAAK,GACL,IAAI,GACJ,KAAK,GACL,KAAK,CAAC;AAEZ,oGAAoG;AACpG,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,GAAG,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AAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;CAC1E;AAqBD;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAChC,KAAK,EAAE,WAAW,GAAG,WAAW,EAChC,MAAM,GAAE,YAAqB,EAC7B,OAAO,GAAE,aAAkB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAwE3B;AAyID;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAChC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,aAAkB,GAC5B,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
package/dist/io.js ADDED
@@ -0,0 +1,258 @@
1
+ /**
2
+ * `@graphty/cytoscape-extensions/io`: reading and writing Cytoscape graphs in the file formats of @graphty/graph-io.
3
+ * cy.graphtyImport() and cy.graphtyExport() load this module on their first call, so a page that never imports or
4
+ * exports a file never downloads the parsers.
5
+ */
6
+ import { checkExport, exportGraphToString, ImportError, importGraph, registry, } from "@graphty/graph-io";
7
+ import { extractPositions } from "@graphty/graph-io/positions";
8
+ import { readCytoscapeStyles, STYLE_ISSUE, toCytoscapeStylesheet, } from "@graphty/graph-io/styles";
9
+ import { elementsToSnapshot, exportedEdges, flipY, snapshotToElements } from "./elements.js";
10
+ /** How many imports have read styles: the default import ids. */
11
+ let imports = 0;
12
+ /**
13
+ * A style note as a report warning.
14
+ * @param n - the note
15
+ * @returns the issue
16
+ */
17
+ function styleIssue(n) {
18
+ return {
19
+ category: "unsupported",
20
+ severity: "warning",
21
+ code: n.code,
22
+ message: n.message,
23
+ line: null,
24
+ element: n.params.property,
25
+ };
26
+ }
27
+ /**
28
+ * Reads a graph file into Cytoscape element definitions.
29
+ * Without `styles`, a GEXF `viz:color`, `viz:size`, `viz:shape` and `viz:thickness` also become data fields
30
+ * (`data.color` as four numbers from 0 to 1, `data.size`, `data.shape`, `data.thickness`); these fields are
31
+ * deprecated and are removed in the next major release: import with `styles: true`, whose stylesheet draws them.
32
+ * With `styles: true` they are left out of data.
33
+ * @param input - the file as text, bytes, a stream or chunks
34
+ * @param format - the format, or "auto" to sniff it
35
+ * @param options - graph-io's import options
36
+ * @returns the elements, the direction, the format and graph-io's report
37
+ * @throws ImportError (from graph-io) when the file cannot be read, or when it yields no node and reports an error
38
+ */
39
+ export async function importElements(input, format = "auto", options = {}) {
40
+ // fetch().arrayBuffer() and File.arrayBuffer() give an ArrayBuffer, which graph-io does not take
41
+ const { applyStyles: _apply, importId, ...graphOptions } = options;
42
+ const r = await importGraph(input instanceof ArrayBuffer ? new Uint8Array(input) : input, {
43
+ ...graphOptions,
44
+ format,
45
+ });
46
+ // most text sniffs as CSV, so a file that is not a graph at all reads as an empty one with errors
47
+ if (r.snapshot.nodeCount === 0 && r.report.errorCount > 0) {
48
+ const first = r.report.issues.find((i) => i.severity === "error");
49
+ throw new ImportError(`nothing could be read from the input as ${r.format}: ${first?.code ?? "E_IMPORT"}: ${first?.message ?? ""}`, r.report, { format: r.format });
50
+ }
51
+ const warnings = [];
52
+ const elements = snapshotToElements(r.snapshot, ({ domain, from, to }) => warnings.push({
53
+ category: "coercion",
54
+ severity: "warning",
55
+ code: "W_COLUMN_RENAMED",
56
+ message: `${domain} attribute "${from}" renamed to "${to}": Cytoscape reserves the data field "${from}"`,
57
+ line: null,
58
+ element: from,
59
+ }), (id, takenBy) => warnings.push({
60
+ category: "coercion",
61
+ severity: "warning",
62
+ code: "W_EDGE_ID_DROPPED",
63
+ message: `edge id "${id}" is already the id of ${takenBy === "node" ? "a node" : "an earlier edge"}; Cytoscape gives this edge a new id`,
64
+ line: null,
65
+ element: id,
66
+ }), r.styles !== undefined && r.styles !== null);
67
+ // each format spells its coordinates its own way (yEd: a box's top-left corner, y down; Gephi: the
68
+ // center, y up); graph-io's extractPositions reads them all as the center with y up, and Cytoscape's y
69
+ // grows downward
70
+ const positions = extractPositions(registry.importer(r.format), r.snapshot, r.report);
71
+ for (let i = 0; i < r.snapshot.nodeCount; i++) {
72
+ const el = elements[i];
73
+ const x = positions?.usable === true ? positions.coords[3 * i] : Number.NaN;
74
+ if (Number.isNaN(x)) {
75
+ delete el.position;
76
+ }
77
+ else {
78
+ el.position = { x, y: flipY(positions?.coords[3 * i + 1] ?? 0) };
79
+ }
80
+ }
81
+ let styled = {};
82
+ if (r.styles !== undefined && r.styles !== null) {
83
+ imports++;
84
+ const em = toCytoscapeStylesheet(r.styles, { importId: importId ?? String(imports) });
85
+ const n = r.snapshot.nodeCount;
86
+ const at = (per, i) => i < n ? per.node[i] : per.edge[i - n];
87
+ elements.forEach((el, i) => Object.assign(el.data, at(em.elementData, i)));
88
+ styled = { stylesheet: em.stylesheet, bypass: elements.map((_el, i) => at(em.bypass, i)) };
89
+ warnings.push(...em.notes.map(styleIssue));
90
+ }
91
+ const report = warnings.length === 0
92
+ ? r.report
93
+ : {
94
+ ...r.report,
95
+ issues: [...r.report.issues, ...warnings],
96
+ warningCount: r.report.warningCount + warnings.length,
97
+ };
98
+ return { elements, directed: r.snapshot.directed, format: r.format, report, ...styled };
99
+ }
100
+ /** The loss notes about something graphtyImport always gives back (see lostForCytoscape). */
101
+ const CYTOSCAPE_KEEPS = new Set([
102
+ "W_ID_TEXT_TYPE",
103
+ "W_ID_RENUMBERED",
104
+ "W_CSV_NODE_ORDER",
105
+ "W_STORAGE_CLASS_CHANGED",
106
+ ]);
107
+ /**
108
+ * Whether a graph-io loss note is a loss for a Cytoscape graph. graph-io's notes describe its own snapshot read back
109
+ * by itself; graphtyImport restores some of what they report:
110
+ * - W_ID_TEXT_TYPE: every id is turned back into a string;
111
+ * - W_ID_RENUMBERED (Pajek) and W_CSV_NODE_ORDER: graphtyImport gives the nodes their original ids back, and a
112
+ * Cytoscape node is known by its id, not by its place in the file;
113
+ * - W_STORAGE_CLASS_CHANGED: text stored as a dictionary or as plain strings reads back as the same strings;
114
+ * - W_COLUMN_NAME_CHANGED on the edge `id`, the `parent` or the `position` (DOT reads them back as "key",
115
+ * "graphty.parent" and "pos"): they are read back by their role, as the edge id, `data.parent` and the position;
116
+ * - W_ROLE_DROPPED on `label`: the values read back as `data.label`, and Cytoscape has no label role to lose.
117
+ * @param n - the note
118
+ * @returns false for a note about something graphtyImport gives back
119
+ */
120
+ function lostForCytoscape(n) {
121
+ if (CYTOSCAPE_KEEPS.has(n.code)) {
122
+ return false;
123
+ }
124
+ if (n.code === "W_COLUMN_NAME_CHANGED" && (n.column === "id" || n.column === "parent" || n.column === "position")) {
125
+ return false;
126
+ }
127
+ return !(n.code === "W_ROLE_DROPPED" && n.column === "label");
128
+ }
129
+ /**
130
+ * The core a collection belongs to (`eles.cy()`, which Cytoscape's typings leave out).
131
+ * @param eles - the collection
132
+ * @returns the core
133
+ */
134
+ function coreOf(eles) {
135
+ return eles.cy();
136
+ }
137
+ /**
138
+ * A core's style.
139
+ * @param cy - the core
140
+ * @returns the style, or undefined when the core has styles disabled (headless without `styleEnabled`)
141
+ */
142
+ function styleOf(cy) {
143
+ return cy.style();
144
+ }
145
+ /**
146
+ * The styles of a collection as its core draws them: the core's stylesheet, with each element's `ele.style()` as
147
+ * the truth.
148
+ * @param eles - the collection
149
+ * @param snapshot - the collection as elementsToSnapshot() wrote it
150
+ * @returns the styles, or null when the core has styles disabled (a headless core without `styleEnabled`)
151
+ */
152
+ function coreStyles(eles, snapshot) {
153
+ const style = styleOf(coreOf(eles));
154
+ if (style === undefined) {
155
+ return null;
156
+ }
157
+ const nodes = eles.nodes();
158
+ const edges = exportedEdges(eles);
159
+ return readCytoscapeStyles({
160
+ elements: { nodes: nodes.jsons(), edges: edges.jsons() },
161
+ style: style.json(),
162
+ rendered: [...nodes.map((n) => n.style()), ...edges.map((e) => e.style())],
163
+ snapshot,
164
+ });
165
+ }
166
+ /**
167
+ * W_STYLE_LAYER_FLATTENED for each property written per element instead of as a rule (a function-valued one).
168
+ * @param extracted - the core's styles
169
+ * @returns the notes
170
+ */
171
+ function flattened(extracted) {
172
+ return extracted.styles.notes
173
+ .filter((n) => n.code === STYLE_ISSUE.LAYER_FLATTENED)
174
+ .map((n) => ({
175
+ code: n.code,
176
+ message: n.message,
177
+ column: null,
178
+ count: n.params.count,
179
+ ...(n.params.target === "node" || n.params.target === "edge"
180
+ ? { style: { target: n.params.target, property: n.params.property } }
181
+ : {}),
182
+ }));
183
+ }
184
+ /**
185
+ * W_STYLES_NOT_EXPORTED when the core has a stylesheet of its own (one a new core does not have), or when styles were
186
+ * asked for and the core has none to give (a headless core without `styleEnabled`).
187
+ * @param cy - the core
188
+ * @param asked - whether the export asked for the styles
189
+ * @returns the note, or none
190
+ */
191
+ function notExported(cy, asked) {
192
+ const style = styleOf(cy);
193
+ if (style === undefined) {
194
+ return asked
195
+ ? [
196
+ {
197
+ code: STYLE_ISSUE.NOT_EXPORTED,
198
+ message: "no styles are written: the core has styles disabled; create it with { styleEnabled: true }",
199
+ column: null,
200
+ count: null,
201
+ },
202
+ ]
203
+ : [];
204
+ }
205
+ const fresh = new cy.constructor({ headless: true, styleEnabled: true });
206
+ const own = JSON.stringify(style.json()) !== JSON.stringify(styleOf(fresh)?.json());
207
+ fresh.destroy();
208
+ return own
209
+ ? [
210
+ {
211
+ code: STYLE_ISSUE.NOT_EXPORTED,
212
+ message: "the core's stylesheet is not written; export with { styles: true } to write it",
213
+ column: null,
214
+ count: null,
215
+ },
216
+ ]
217
+ : [];
218
+ }
219
+ /** The formats that hold only integer node ids: a graph whose ids are all integers is written with them as they are. */
220
+ const INTEGER_ID_FORMATS = new Set(["gml", "cx2"]);
221
+ /**
222
+ * Writes a collection as a graph file: every data field, each node's position and compound parent, and each
223
+ * edge's id, as far as the format holds them (`onLoss` hears about the rest).
224
+ * @param eles - the nodes and the edges between them
225
+ * @param format - the format
226
+ * @param options - graph-io's export options for the format, plus `directed`
227
+ * @returns the file's text; rejects (a TypeError) when `eles` is not a collection
228
+ */
229
+ export async function exportElements(eles, format, options = {}) {
230
+ // importElements returns definitions, which this cannot read without a core to build them
231
+ if (typeof eles?.nodes !== "function") {
232
+ throw new TypeError("exportElements needs a Cytoscape collection; wrap element definitions with cytoscape({ headless: true, elements }).elements()");
233
+ }
234
+ const { directed, onLoss, styles, ...rest } = options;
235
+ const snapshot = elementsToSnapshot(eles, {
236
+ directed,
237
+ format,
238
+ integerIds: INTEGER_ID_FORMATS.has(format),
239
+ });
240
+ const extracted = styles === true ? coreStyles(eles, snapshot) : null;
241
+ const graphOptions = {
242
+ sanitizeIds: "mangle",
243
+ ...(format === "json" ? { dialect: "cytoscape" } : {}),
244
+ ...rest,
245
+ ...(extracted === null ? {} : { styles: extracted }),
246
+ };
247
+ if (onLoss !== undefined) {
248
+ const notes = [
249
+ ...(extracted === null ? notExported(coreOf(eles), styles === true) : flattened(extracted)),
250
+ ...checkExport(snapshot, format, graphOptions).filter(lostForCytoscape),
251
+ ];
252
+ if (notes.length > 0) {
253
+ onLoss(notes);
254
+ }
255
+ }
256
+ return exportGraphToString(snapshot, format, graphOptions);
257
+ }
258
+ //# sourceMappingURL=io.js.map
package/dist/io.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACH,WAAW,EAEX,mBAAmB,EACnB,WAAW,EACX,WAAW,EAMX,QAAQ,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAGH,mBAAmB,EACnB,WAAW,EAEX,qBAAqB,GACxB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAuG7F,iEAAiE;AACjE,IAAI,OAAO,GAAG,CAAC,CAAC;AAEhB;;;;GAIG;AACH,SAAS,UAAU,CAAC,CAAY;IAC5B,OAAO;QACH,QAAQ,EAAE,aAAa;QACvB,QAAQ,EAAE,SAAS;QACnB,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