@graphty/graph-io 0.3.40 → 0.3.42

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 (210) hide show
  1. package/README.md +2 -0
  2. package/dist/chunks/{children-CL3Cy0ez.js → children-CA4coBi0.js} +36 -27
  3. package/dist/chunks/children-CA4coBi0.js.map +1 -0
  4. package/dist/chunks/{choose-CS3fvGT1.js → choose-DvpbdRuz.js} +2 -2
  5. package/dist/chunks/{choose-CS3fvGT1.js.map → choose-DvpbdRuz.js.map} +1 -1
  6. package/dist/chunks/{constants-DqKZT6cH.js → constants-fT3E8JYY.js} +2 -2
  7. package/dist/chunks/{constants-DqKZT6cH.js.map → constants-fT3E8JYY.js.map} +1 -1
  8. package/dist/chunks/{escape-BJRLd3vJ.js → escape-B62ZGM_a.js} +2 -2
  9. package/dist/chunks/{escape-BJRLd3vJ.js.map → escape-B62ZGM_a.js.map} +1 -1
  10. package/dist/chunks/{export-B-aVCwyG.js → export-rKLeGQMo.js} +404 -243
  11. package/dist/chunks/export-rKLeGQMo.js.map +1 -0
  12. package/dist/chunks/{exporter-6ocL_9x_.js → exporter-8hLNemFk.js} +4 -4
  13. package/dist/chunks/{exporter-6ocL_9x_.js.map → exporter-8hLNemFk.js.map} +1 -1
  14. package/dist/chunks/{exporter-BVXnV9-9.js → exporter-BWwEuOPT.js} +29 -17
  15. package/dist/chunks/exporter-BWwEuOPT.js.map +1 -0
  16. package/dist/chunks/{exporter-Bcp-l4Bo.js → exporter-CpRyHZ3H.js} +574 -475
  17. package/dist/chunks/exporter-CpRyHZ3H.js.map +1 -0
  18. package/dist/chunks/{exporter-SFYkDzD0.js → exporter-yLxKBvLE.js} +23 -20
  19. package/dist/chunks/{exporter-SFYkDzD0.js.map → exporter-yLxKBvLE.js.map} +1 -1
  20. package/dist/chunks/{importer-DcKB97kW.js → importer-BbNb7eNg.js} +111 -71
  21. package/dist/chunks/importer-BbNb7eNg.js.map +1 -0
  22. package/dist/chunks/{importer-D_srHyj6.js → importer-C98dpSH4.js} +5 -5
  23. package/dist/chunks/{importer-D_srHyj6.js.map → importer-C98dpSH4.js.map} +1 -1
  24. package/dist/chunks/{importer-BJlGAOht.js → importer-D794XUTe.js} +3 -3
  25. package/dist/chunks/{importer-BJlGAOht.js.map → importer-D794XUTe.js.map} +1 -1
  26. package/dist/chunks/{importer-AjwOJrn2.js → importer-Dz7tI8Sa.js} +202 -181
  27. package/dist/chunks/importer-Dz7tI8Sa.js.map +1 -0
  28. package/dist/chunks/{importer-DEp_fYjf.js → importer-Ht7LNg8L.js} +92 -64
  29. package/dist/chunks/importer-Ht7LNg8L.js.map +1 -0
  30. package/dist/chunks/{importer-CPqnIY8m.js → importer-WrGRZb0N.js} +42 -29
  31. package/dist/chunks/importer-WrGRZb0N.js.map +1 -0
  32. package/dist/chunks/{importer-BpuS3J8C.js → importer-xZ-3suY1.js} +74 -61
  33. package/dist/chunks/importer-xZ-3suY1.js.map +1 -0
  34. package/dist/chunks/{json-elements-DpO6AXIc.js → json-elements-DKSqpNW1.js} +3 -3
  35. package/dist/chunks/{json-elements-DpO6AXIc.js.map → json-elements-DKSqpNW1.js.map} +1 -1
  36. package/dist/chunks/{ontology-export-50L9DOV4.js → ontology-export-CtRXjg_i.js} +2 -2
  37. package/dist/chunks/{ontology-export-50L9DOV4.js.map → ontology-export-CtRXjg_i.js.map} +1 -1
  38. package/dist/chunks/{records-r3SFHz11.js → records-Cu4bxYOm.js} +69 -36
  39. package/dist/chunks/records-Cu4bxYOm.js.map +1 -0
  40. package/dist/chunks/{text-Bjfa1xYL.js → text-DHOJXnED.js} +20 -11
  41. package/dist/chunks/text-DHOJXnED.js.map +1 -0
  42. package/dist/csv.js +323 -241
  43. package/dist/csv.js.map +1 -1
  44. package/dist/cx.js +1 -1
  45. package/dist/cx2.js +2 -2
  46. package/dist/cys.js +1 -1
  47. package/dist/dot.js +1 -1
  48. package/dist/gexf.js +195 -97
  49. package/dist/gexf.js.map +1 -1
  50. package/dist/gml.js +170 -149
  51. package/dist/gml.js.map +1 -1
  52. package/dist/graph-io.js +27 -27
  53. package/dist/graphml.js +2 -2
  54. package/dist/json.js +1 -1
  55. package/dist/neo4j.js +103 -65
  56. package/dist/neo4j.js.map +1 -1
  57. package/dist/obo.js +1 -1
  58. package/dist/pajek.js +1 -1
  59. package/dist/src/children.d.ts.map +1 -1
  60. package/dist/src/children.js +50 -27
  61. package/dist/src/children.js.map +1 -1
  62. package/dist/src/common/attributes.d.ts.map +1 -1
  63. package/dist/src/common/attributes.js +86 -42
  64. package/dist/src/common/attributes.js.map +1 -1
  65. package/dist/src/common/input.d.ts.map +1 -1
  66. package/dist/src/common/input.js +358 -184
  67. package/dist/src/common/input.js.map +1 -1
  68. package/dist/src/common/lists.js +30 -15
  69. package/dist/src/common/lists.js.map +1 -1
  70. package/dist/src/common/text.d.ts +7 -0
  71. package/dist/src/common/text.d.ts.map +1 -1
  72. package/dist/src/common/text.js +15 -7
  73. package/dist/src/common/text.js.map +1 -1
  74. package/dist/src/common/zip.d.ts.map +1 -1
  75. package/dist/src/common/zip.js +36 -19
  76. package/dist/src/common/zip.js.map +1 -1
  77. package/dist/src/formats/csv/exporter.d.ts.map +1 -1
  78. package/dist/src/formats/csv/exporter.js +288 -146
  79. package/dist/src/formats/csv/exporter.js.map +1 -1
  80. package/dist/src/formats/csv/importer.d.ts.map +1 -1
  81. package/dist/src/formats/csv/importer.js +129 -80
  82. package/dist/src/formats/csv/importer.js.map +1 -1
  83. package/dist/src/formats/csv/records.d.ts.map +1 -1
  84. package/dist/src/formats/csv/records.js +78 -36
  85. package/dist/src/formats/csv/records.js.map +1 -1
  86. package/dist/src/formats/cys/tables.d.ts.map +1 -1
  87. package/dist/src/formats/cys/tables.js +11 -8
  88. package/dist/src/formats/cys/tables.js.map +1 -1
  89. package/dist/src/formats/dot/tokenizer.d.ts +39 -0
  90. package/dist/src/formats/dot/tokenizer.d.ts.map +1 -1
  91. package/dist/src/formats/dot/tokenizer.js +112 -66
  92. package/dist/src/formats/dot/tokenizer.js.map +1 -1
  93. package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
  94. package/dist/src/formats/gexf/exporter.js +65 -37
  95. package/dist/src/formats/gexf/exporter.js.map +1 -1
  96. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  97. package/dist/src/formats/gexf/importer.js +138 -50
  98. package/dist/src/formats/gexf/importer.js.map +1 -1
  99. package/dist/src/formats/gml/exporter.d.ts.map +1 -1
  100. package/dist/src/formats/gml/exporter.js +51 -35
  101. package/dist/src/formats/gml/exporter.js.map +1 -1
  102. package/dist/src/formats/gml/importer.d.ts.map +1 -1
  103. package/dist/src/formats/gml/importer.js +103 -58
  104. package/dist/src/formats/gml/importer.js.map +1 -1
  105. package/dist/src/formats/gml/syntax.d.ts.map +1 -1
  106. package/dist/src/formats/gml/syntax.js +17 -8
  107. package/dist/src/formats/gml/syntax.js.map +1 -1
  108. package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
  109. package/dist/src/formats/graphml/exporter.js +34 -24
  110. package/dist/src/formats/graphml/exporter.js.map +1 -1
  111. package/dist/src/formats/graphml/importer.d.ts.map +1 -1
  112. package/dist/src/formats/graphml/importer.js +17 -13
  113. package/dist/src/formats/graphml/importer.js.map +1 -1
  114. package/dist/src/formats/graphml/tree.js +23 -14
  115. package/dist/src/formats/graphml/tree.js.map +1 -1
  116. package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
  117. package/dist/src/formats/graphml/yfiles.js +22 -10
  118. package/dist/src/formats/graphml/yfiles.js.map +1 -1
  119. package/dist/src/formats/json/dialect.d.ts.map +1 -1
  120. package/dist/src/formats/json/dialect.js +54 -20
  121. package/dist/src/formats/json/dialect.js.map +1 -1
  122. package/dist/src/formats/json/exporter.d.ts.map +1 -1
  123. package/dist/src/formats/json/exporter.js +38 -21
  124. package/dist/src/formats/json/exporter.js.map +1 -1
  125. package/dist/src/formats/json/importer.d.ts.map +1 -1
  126. package/dist/src/formats/json/importer.js +536 -343
  127. package/dist/src/formats/json/importer.js.map +1 -1
  128. package/dist/src/formats/json/obographs.js +29 -17
  129. package/dist/src/formats/json/obographs.js.map +1 -1
  130. package/dist/src/formats/neo4j/exporter.d.ts.map +1 -1
  131. package/dist/src/formats/neo4j/exporter.js +73 -43
  132. package/dist/src/formats/neo4j/exporter.js.map +1 -1
  133. package/dist/src/formats/neo4j/header.d.ts.map +1 -1
  134. package/dist/src/formats/neo4j/header.js +37 -16
  135. package/dist/src/formats/neo4j/header.js.map +1 -1
  136. package/dist/src/formats/neo4j/importer.d.ts.map +1 -1
  137. package/dist/src/formats/neo4j/importer.js +21 -11
  138. package/dist/src/formats/neo4j/importer.js.map +1 -1
  139. package/dist/src/formats/obo/exporter.d.ts.map +1 -1
  140. package/dist/src/formats/obo/exporter.js +18 -7
  141. package/dist/src/formats/obo/exporter.js.map +1 -1
  142. package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
  143. package/dist/src/formats/pajek/exporter.js +142 -73
  144. package/dist/src/formats/pajek/exporter.js.map +1 -1
  145. package/dist/src/formats/pajek/importer.d.ts.map +1 -1
  146. package/dist/src/formats/pajek/importer.js +26 -15
  147. package/dist/src/formats/pajek/importer.js.map +1 -1
  148. package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
  149. package/dist/src/formats/pajek/syntax.js +85 -58
  150. package/dist/src/formats/pajek/syntax.js.map +1 -1
  151. package/dist/src/formats/xgmml/emit.d.ts +7 -0
  152. package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
  153. package/dist/src/formats/xgmml/emit.js +79 -40
  154. package/dist/src/formats/xgmml/emit.js.map +1 -1
  155. package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
  156. package/dist/src/formats/xgmml/exporter.js +38 -12
  157. package/dist/src/formats/xgmml/exporter.js.map +1 -1
  158. package/dist/src/formats/xgmml/importer.d.ts.map +1 -1
  159. package/dist/src/formats/xgmml/importer.js +38 -18
  160. package/dist/src/formats/xgmml/importer.js.map +1 -1
  161. package/dist/src/sniff.js +109 -57
  162. package/dist/src/sniff.js.map +1 -1
  163. package/dist/xgmml.js +2 -2
  164. package/package.json +2 -2
  165. package/src/children.ts +54 -27
  166. package/src/common/attributes.ts +118 -49
  167. package/src/common/input.ts +439 -197
  168. package/src/common/lists.ts +29 -15
  169. package/src/common/text.ts +24 -15
  170. package/src/common/zip.ts +47 -18
  171. package/src/formats/csv/exporter.ts +377 -175
  172. package/src/formats/csv/importer.ts +155 -84
  173. package/src/formats/csv/records.ts +90 -35
  174. package/src/formats/cys/tables.ts +11 -10
  175. package/src/formats/dot/tokenizer.ts +118 -68
  176. package/src/formats/gexf/exporter.ts +67 -36
  177. package/src/formats/gexf/importer.ts +173 -63
  178. package/src/formats/gml/exporter.ts +78 -82
  179. package/src/formats/gml/importer.ts +119 -68
  180. package/src/formats/gml/syntax.ts +18 -8
  181. package/src/formats/graphml/exporter.ts +44 -24
  182. package/src/formats/graphml/importer.ts +18 -11
  183. package/src/formats/graphml/tree.ts +22 -12
  184. package/src/formats/graphml/yfiles.ts +23 -10
  185. package/src/formats/json/dialect.ts +61 -22
  186. package/src/formats/json/exporter.ts +40 -21
  187. package/src/formats/json/importer.ts +701 -385
  188. package/src/formats/json/obographs.ts +35 -15
  189. package/src/formats/neo4j/exporter.ts +79 -41
  190. package/src/formats/neo4j/header.ts +50 -16
  191. package/src/formats/neo4j/importer.ts +21 -10
  192. package/src/formats/obo/exporter.ts +34 -17
  193. package/src/formats/pajek/exporter.ts +180 -117
  194. package/src/formats/pajek/importer.ts +27 -15
  195. package/src/formats/pajek/syntax.ts +99 -58
  196. package/src/formats/xgmml/emit.ts +88 -40
  197. package/src/formats/xgmml/exporter.ts +40 -12
  198. package/src/formats/xgmml/importer.ts +45 -23
  199. package/src/sniff.ts +115 -59
  200. package/dist/chunks/children-CL3Cy0ez.js.map +0 -1
  201. package/dist/chunks/export-B-aVCwyG.js.map +0 -1
  202. package/dist/chunks/exporter-BVXnV9-9.js.map +0 -1
  203. package/dist/chunks/exporter-Bcp-l4Bo.js.map +0 -1
  204. package/dist/chunks/importer-AjwOJrn2.js.map +0 -1
  205. package/dist/chunks/importer-BpuS3J8C.js.map +0 -1
  206. package/dist/chunks/importer-CPqnIY8m.js.map +0 -1
  207. package/dist/chunks/importer-DEp_fYjf.js.map +0 -1
  208. package/dist/chunks/importer-DcKB97kW.js.map +0 -1
  209. package/dist/chunks/records-r3SFHz11.js.map +0 -1
  210. package/dist/chunks/text-Bjfa1xYL.js.map +0 -1
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ <img src="https://raw.githubusercontent.com/graphty-org/brand/main/guide/on-white/png/graphty-graph-io-lockup-color-on-light-800w.png" alt="graphty graph-io" width="352">
2
+
1
3
  # @graphty/graph-io
2
4
 
3
5
  [![npm version](https://img.shields.io/npm/v/@graphty/graph-io.svg)](https://www.npmjs.com/package/@graphty/graph-io)
@@ -175,7 +175,6 @@ function childrenFromColumn(nodeCount, column) {
175
175
  let dropped = 0;
176
176
  const references = [];
177
177
  if (column !== null) {
178
- const rows = Math.min(column.length, nodeCount);
179
178
  const keep = (child, parent) => {
180
179
  if (!Number.isInteger(parent) || parent === INVALID_INDEX || parent >= nodeCount || parent === child) {
181
180
  dropped++;
@@ -185,31 +184,8 @@ function childrenFromColumn(nodeCount, column) {
185
184
  rowPtr[parent + 1]++;
186
185
  parentCount[child]++;
187
186
  };
188
- if (column.dtype === "u32") {
189
- const { data } = column;
190
- for (let i = 0; i < rows; i++) {
191
- if (column.isSet(i)) {
192
- keep(i, data[i]);
193
- }
194
- }
195
- } else if (column.dtype === "list") {
196
- for (let i = 0; i < rows; i++) {
197
- if (!column.isSet(i)) {
198
- continue;
199
- }
200
- for (const item of column.sliceOf(i)) {
201
- if (typeof item === "number") {
202
- keep(i, item);
203
- } else {
204
- dropped++;
205
- }
206
- }
207
- }
208
- } else {
209
- throw new TypeError(
210
- `a containment column must be u32 or a list of u32, found ${column.dtype} column "${column.meta.name}"`
211
- );
212
- }
187
+ const nonNumeric = readContainment(column, Math.min(column.length, nodeCount), keep);
188
+ dropped += nonNumeric;
213
189
  }
214
190
  for (let u = 0; u < nodeCount; u++) {
215
191
  rowPtr[u + 1] += rowPtr[u];
@@ -221,6 +197,39 @@ function childrenFromColumn(nodeCount, column) {
221
197
  }
222
198
  return new ChildrenCsr(nodeCount, rowPtr, children, parentCount, dropped, column);
223
199
  }
200
+ function readContainment(column, rows, keep) {
201
+ if (column.dtype === "u32") {
202
+ const { data } = column;
203
+ for (let i = 0; i < rows; i++) {
204
+ if (column.isSet(i)) {
205
+ keep(i, data[i]);
206
+ }
207
+ }
208
+ return 0;
209
+ }
210
+ if (column.dtype === "list") {
211
+ return readParentLists(column, rows, keep);
212
+ }
213
+ throw new TypeError(
214
+ `a containment column must be u32 or a list of u32, found ${column.dtype} column "${column.meta.name}"`
215
+ );
216
+ }
217
+ function readParentLists(column, rows, keep) {
218
+ let dropped = 0;
219
+ for (let i = 0; i < rows; i++) {
220
+ if (!column.isSet(i)) {
221
+ continue;
222
+ }
223
+ for (const item of column.sliceOf(i)) {
224
+ if (typeof item === "number") {
225
+ keep(i, item);
226
+ } else {
227
+ dropped++;
228
+ }
229
+ }
230
+ }
231
+ return dropped;
232
+ }
224
233
  function resolveColumn(snapshot, choice) {
225
234
  if (typeof choice !== "string") {
226
235
  return choice;
@@ -235,4 +244,4 @@ export {
235
244
  childrenFromColumn as a,
236
245
  childrenCsr as c
237
246
  };
238
- //# sourceMappingURL=children-CL3Cy0ez.js.map
247
+ //# sourceMappingURL=children-CA4coBi0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"children-CA4coBi0.js","sources":["../../src/children.ts"],"sourcesContent":["/**\n * The children CSR over a containment column: containment\n * (GEXF `pid` / `<parents>`, Cytoscape `parent`, DOT clusters, GraphML nested graphs) is a node\n * column with the `parent` role (u32, refersTo node) or the `parents` role (list of u32) and never\n * enters the CSR of the snapshot. Importers and exporters that need to walk containers top-down\n * (nested subgraphs, cluster blocks, parent lists) build this inverse index once: for every node\n * `u`, `children[rowPtr[u] .. rowPtr[u + 1])` are its children in ascending index order, `roots`\n * are the nodes with no parent, and `depthFirst()` is the pre-order the nested writers use.\n *\n * The helper is deliberately outside the core (7.1: it computes a property the arrays do not\n * already imply and only io needs it). A reference is ignored when it is unset, INVALID_INDEX, out\n * of range, or the node itself; a cycle (a parent chain that never reaches a root) is reported\n * through `unreachable` and its members are appended to the depth-first order in index order so\n * every node is written exactly once.\n */\n\nimport { type Column, type GraphSnapshot, INVALID_INDEX, type ListColumn } from \"@graphty/graph-format\";\n\n/**\n * The role of the column a children CSR is built over.\n * @category Plugin helpers\n */\nexport type ContainmentRole = \"parent\" | \"parents\";\n\n/**\n * How the CSR is built: from a role column of the snapshot (default `parent`, then `parents`) or an explicit column.\n * @category Plugin helpers\n */\nexport interface ChildrenOptions {\n /**\n * The column to read: a role name (`parent` for the u32 single-parent column, `parents` for\n * the list column) or a column object of either shape; \"auto\" (default) takes the `parent`\n * role column when the snapshot has one, else `parents`, else no containment; null builds\n * the empty CSR (every node a root) whatever the snapshot holds.\n */\n readonly column?: ContainmentRole | Column | \"auto\" | null | undefined;\n}\n\n/**\n * One depth-first traversal of the containment forest.\n * @category Plugin helpers\n */\nexport interface DepthFirstOrder {\n /** Every node index exactly once: roots in index order, each followed by its descendants, cycle members last. */\n readonly order: Uint32Array;\n /** The depth of every node in the traversal (0 for a root or a cycle member forced to the top). */\n readonly depth: Uint32Array;\n /** Whether `order` differs from `0..n-1`. */\n readonly reordered: boolean;\n}\n\n/**\n * The children CSR of a snapshot's containment column: the inverse\n * of the parent relation as a compressed sparse row structure over node indices.\n * @category Plugin helpers\n */\nexport class ChildrenCsr {\n /** The number of nodes (the row count of the CSR). */\n readonly nodeCount: number;\n /** `rowPtr[u] .. rowPtr[u + 1]` is the range of `children` holding the children of `u`; length nodeCount + 1. */\n readonly rowPtr: Uint32Array;\n /** Child node indices, ascending within each parent's range. */\n readonly children: Uint32Array;\n /** The nodes with no (valid) parent, in index order. */\n readonly roots: Uint32Array;\n /** Every (child, parent) reference kept; equal to `children.length`. */\n readonly edgeCount: number;\n /** References dropped because they were INVALID_INDEX, out of range or self-references. */\n readonly dropped: number;\n /** Nodes whose parent chain never reaches a root (members of a cycle), counted once each. */\n readonly unreachable: number;\n /** The column the CSR was built from, or null when the snapshot has no containment. */\n readonly column: Column | null;\n\n private readonly parentCount: Uint32Array;\n\n /**\n * Build the CSR; use childrenCsr() rather than the constructor.\n * @param nodeCount - the node count\n * @param rowPtr - the row pointers\n * @param children - the child list\n * @param parentCount - parents per node (0 for a root)\n * @param dropped - references ignored\n * @param column - the source column, or null\n */\n constructor(\n nodeCount: number,\n rowPtr: Uint32Array,\n children: Uint32Array,\n parentCount: Uint32Array,\n dropped: number,\n column: Column | null,\n ) {\n this.nodeCount = nodeCount;\n this.rowPtr = rowPtr;\n this.children = children;\n this.parentCount = parentCount;\n this.edgeCount = children.length;\n this.dropped = dropped;\n this.column = column;\n let rootCount = 0;\n for (let u = 0; u < nodeCount; u++) {\n if (parentCount[u] === 0) {\n rootCount++;\n }\n }\n const roots = new Uint32Array(rootCount);\n let r = 0;\n for (let u = 0; u < nodeCount; u++) {\n if (parentCount[u] === 0) {\n roots[r++] = u;\n }\n }\n this.roots = roots;\n this.unreachable = nodeCount - this.reachableCount();\n }\n\n /**\n * The children of a node, as a view into `children` (do not modify).\n * @param node - the node index\n * @returns the child indices in ascending order; empty for a leaf\n */\n childrenOf(node: number): Uint32Array {\n return this.children.subarray(this.rowPtr[node], this.rowPtr[node + 1]);\n }\n\n /**\n * How many children a node has.\n * @param node - the node index\n * @returns the count\n */\n childCount(node: number): number {\n return this.rowPtr[node + 1] - this.rowPtr[node];\n }\n\n /**\n * Whether a node is a container (has at least one child).\n * @param node - the node index\n * @returns true when it has children\n */\n hasChildren(node: number): boolean {\n return this.rowPtr[node + 1] > this.rowPtr[node];\n }\n\n /**\n * How many parents a node has: 0 for a root, 1 under a `parent` column, any number under `parents`.\n * @param node - the node index\n * @returns the parent count\n */\n parentCountOf(node: number): number {\n return this.parentCount[node];\n }\n\n /**\n * Whether a node has no parent.\n * @param node - the node index\n * @returns true for a root\n */\n isRoot(node: number): boolean {\n return this.parentCount[node] === 0;\n }\n\n /**\n * Whether the snapshot has any containment at all.\n * @returns true when at least one child reference was kept\n */\n isEmpty(): boolean {\n return this.edgeCount === 0;\n }\n\n /**\n * A pre-order depth-first traversal from the roots in index order (children in ascending\n * order), then every node not yet visited (a cycle member, or a multi-parent node reached\n * only through a cycle) in index order at depth 0. Each node appears exactly once, so nested\n * writers emit every element once even for a `parents` column that shares a child.\n * @returns the order, the depth of every node and whether the order differs from index order\n */\n depthFirst(): DepthFirstOrder {\n const n = this.nodeCount;\n const order = new Uint32Array(n);\n const depth = new Uint32Array(n);\n const visited = new Uint8Array(n);\n const stackNode: number[] = [];\n const stackCursor: number[] = [];\n let position = 0;\n let reordered = false;\n const place = (u: number, d: number): void => {\n visited[u] = 1;\n if (u !== position) {\n reordered = true;\n }\n order[position++] = u;\n depth[u] = d;\n };\n const visit = (root: number): void => {\n place(root, 0);\n stackNode.push(root);\n stackCursor.push(this.rowPtr[root]);\n while (stackNode.length > 0) {\n const top = stackNode.length - 1;\n const u = stackNode[top];\n const cursor = stackCursor[top];\n if (cursor >= this.rowPtr[u + 1]) {\n stackNode.pop();\n stackCursor.pop();\n continue;\n }\n stackCursor[top] = cursor + 1;\n const v = this.children[cursor];\n if (visited[v] === 1) {\n continue;\n }\n place(v, stackNode.length);\n stackNode.push(v);\n stackCursor.push(this.rowPtr[v]);\n }\n };\n for (const root of this.roots) {\n visit(root);\n }\n for (let u = 0; u < n; u++) {\n if (visited[u] === 0) {\n visit(u);\n }\n }\n return { order, depth, reordered };\n }\n\n /**\n * The nodes reachable from the roots by following child references.\n * @returns how many nodes a traversal from the roots reaches\n */\n private reachableCount(): number {\n const visited = new Uint8Array(this.nodeCount);\n // every node is pushed at most once, so a stack of nodeCount entries never overflows\n const stack = new Uint32Array(this.nodeCount);\n let top = 0;\n let count = 0;\n for (const root of this.roots) {\n visited[root] = 1;\n count++;\n stack[top++] = root;\n while (top > 0) {\n const u = stack[--top];\n for (let k = this.rowPtr[u]; k < this.rowPtr[u + 1]; k++) {\n const v = this.children[k];\n if (visited[v] === 0) {\n visited[v] = 1;\n count++;\n stack[top++] = v;\n }\n }\n }\n }\n return count;\n }\n}\n\n/**\n * Build the children CSR of a snapshot.\n * @param snapshot - the snapshot\n * @param options - which column to read; the `parent` role, then `parents`, by default\n * @returns the CSR; empty (every node a root) when the snapshot has no containment column\n * @category Plugin helpers\n */\nexport function childrenCsr(snapshot: GraphSnapshot, options: ChildrenOptions = {}): ChildrenCsr {\n const column = resolveColumn(snapshot, options.column === undefined ? \"auto\" : options.column);\n return childrenFromColumn(snapshot.nodeCount, column);\n}\n\n/**\n * Build the children CSR over one containment column without a snapshot (an importer that holds\n * the column before freezing, a test).\n * @param nodeCount - the node count the references index into\n * @param column - a u32 `parent`-shaped column, a list-of-u32 `parents`-shaped column, or null for none\n * @returns the CSR\n * @category Plugin helpers\n */\nexport function childrenFromColumn(nodeCount: number, column: Column | null): ChildrenCsr {\n const rowPtr = new Uint32Array(nodeCount + 1);\n const parentCount = new Uint32Array(nodeCount);\n let dropped = 0;\n const references: number[] = [];\n if (column !== null) {\n const keep = (child: number, parent: number): void => {\n if (!Number.isInteger(parent) || parent === INVALID_INDEX || parent >= nodeCount || parent === child) {\n dropped++;\n return;\n }\n references.push(child, parent);\n rowPtr[parent + 1]++;\n parentCount[child]++;\n };\n // keep() counts into `dropped` while it runs, so add the non-numeric items after the call\n const nonNumeric = readContainment(column, Math.min(column.length, nodeCount), keep);\n dropped += nonNumeric;\n }\n for (let u = 0; u < nodeCount; u++) {\n rowPtr[u + 1] += rowPtr[u];\n }\n const children = new Uint32Array(rowPtr[nodeCount]);\n const fill = rowPtr.slice(0, nodeCount);\n // references were collected in ascending child order, so each parent's range fills ascending\n for (let k = 0; k < references.length; k += 2) {\n children[fill[references[k + 1]]++] = references[k];\n }\n return new ChildrenCsr(nodeCount, rowPtr, children, parentCount, dropped, column);\n}\n\n/**\n * Hand every (child, parent) reference of the first `rows` rows of a containment column to `keep`,\n * in ascending child order.\n * @param column - a u32 `parent`-shaped column or a list-of-u32 `parents`-shaped column\n * @param rows - how many rows to read\n * @param keep - receives each reference\n * @returns how many list items were dropped for not being a number\n */\nfunction readContainment(column: Column, rows: number, keep: (child: number, parent: number) => void): number {\n if (column.dtype === \"u32\") {\n const { data } = column;\n for (let i = 0; i < rows; i++) {\n if (column.isSet(i)) {\n keep(i, data[i]);\n }\n }\n return 0;\n }\n if (column.dtype === \"list\") {\n return readParentLists(column, rows, keep);\n }\n throw new TypeError(\n `a containment column must be u32 or a list of u32, found ${column.dtype} column \"${column.meta.name}\"`,\n );\n}\n\n/**\n * Hand every numeric item of a `parents`-shaped list column to `keep`.\n * @param column - the list column\n * @param rows - how many rows to read\n * @param keep - receives each reference\n * @returns how many items were not numbers\n */\nfunction readParentLists(column: ListColumn, rows: number, keep: (child: number, parent: number) => void): number {\n let dropped = 0;\n for (let i = 0; i < rows; i++) {\n if (!column.isSet(i)) {\n continue;\n }\n for (const item of column.sliceOf(i)) {\n if (typeof item === \"number\") {\n keep(i, item);\n } else {\n dropped++;\n }\n }\n }\n return dropped;\n}\n\n/**\n * The column a ChildrenOptions selects.\n * @param snapshot - the snapshot\n * @param choice - the option value\n * @returns the column, or null when the snapshot has none of that shape\n */\nfunction resolveColumn(snapshot: GraphSnapshot, choice: ContainmentRole | Column | \"auto\" | null): Column | null {\n if (typeof choice !== \"string\") {\n return choice;\n }\n if (choice === \"parent\" || choice === \"parents\") {\n return snapshot.nodes.byRole(choice);\n }\n return snapshot.nodes.byRole(\"parent\") ?? snapshot.nodes.byRole(\"parents\");\n}\n"],"names":[],"mappings":";AAwDO,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BrB,YACI,WACA,QACA,UACA,aACA,S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,QAAiE;AAC7G,MAAI,OAAO,WAAW,UAAU;AAC5B,WAAO;AAAA,EACX;AACA,MAAI,WAAW,YAAY,WAAW,WAAW;AAC7C,WAAO,SAAS,MAAM,OAAO,MAAM;AAAA,EACvC;AACA,SAAO,SAAS,MAAM,OAAO,QAAQ,KAAK,SAAS,MAAM,OAAO,SAAS;AAC7E;"}
@@ -1,5 +1,5 @@
1
1
  import { GraphBuilder } from "@graphty/graph-format";
2
- import { a7 as chooseGraph, a8 as ImportReportBuilder } from "./export-B-aVCwyG.js";
2
+ import { a7 as chooseGraph, a8 as ImportReportBuilder } from "./export-rKLeGQMo.js";
3
3
  async function importChosenGraph(importer, input, sink, options) {
4
4
  const importAll = importer.importAll?.bind(importer);
5
5
  if (importAll === void 0) {
@@ -53,4 +53,4 @@ async function replayable(input) {
53
53
  export {
54
54
  importChosenGraph as i
55
55
  };
56
- //# sourceMappingURL=choose-CS3fvGT1.js.map
56
+ //# sourceMappingURL=choose-DvpbdRuz.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"choose-CS3fvGT1.js","sources":["../../src/common/choose.ts"],"sourcesContent":["/**\n * The graph choice of an importer that can read every graph of a file (importAll) but has no cheap\n * listing: `graphIndex` / `graphName` passed to its import() directly, as the registry would honor\n * them, so a caller with its own builder is not silently given the first graph.\n */\n\nimport { GraphBuilder, type GraphSink } from \"@graphty/graph-format\";\n\nimport {\n type CommonImportOptions,\n type GraphChoiceOptions,\n type GraphImporter,\n type ImportInput,\n type ImportReport,\n} from \"../types.js\";\nimport { chooseGraph } from \"./options.js\";\nimport { ImportReportBuilder } from \"./report.js\";\n\n/**\n * Read the graph `graphIndex` or `graphName` chooses into the sink: every graph is read once into a\n * scratch builder to learn the names (E_GRAPH_NOT_FOUND lists them), then the input again with the\n * chosen graph going to the sink.\n * @param importer - the importer, which has importAll()\n * @param input - the input\n * @param sink - the caller's sink\n * @param options - the import options, with the choice\n * @returns the chosen graph's report\n */\nexport async function importChosenGraph<O>(\n importer: GraphImporter<O>,\n input: ImportInput,\n sink: GraphSink,\n options: (O & CommonImportOptions & GraphChoiceOptions) | undefined,\n): Promise<ImportReport> {\n const importAll = importer.importAll?.bind(importer);\n if (importAll === undefined) {\n return importer.import(input, sink, options);\n }\n const replay = await replayable(input);\n const scratch: GraphBuilder[] = [];\n await importAll(replay, (i) => (scratch[i] = new GraphBuilder({ directed: false })), {\n ...options,\n onProgress: undefined,\n } as O & CommonImportOptions);\n const names = scratch.map((b) => {\n try {\n return b.freeze().meta.name;\n } catch {\n return null;\n }\n });\n const chosen = chooseGraph(names, options, new ImportReportBuilder(importer.format, 0));\n const reports = await importAll(\n replay,\n (i) => (i === chosen ? sink : new GraphBuilder({ directed: false })),\n options,\n );\n return reports[chosen];\n}\n\n/**\n * The input as a string or bytes that can be read twice.\n * @param input - the input\n * @returns the same text or bytes, or the stream's bytes\n */\nasync function replayable(input: ImportInput): Promise<string | Uint8Array> {\n if (typeof input === \"string\" || input instanceof Uint8Array) {\n return input;\n }\n const parts: Uint8Array[] = [];\n const encoder = new TextEncoder();\n if (typeof (input as ReadableStream<Uint8Array>).getReader === \"function\") {\n const reader = (input as ReadableStream<Uint8Array>).getReader();\n for (let r = await reader.read(); !r.done; r = await reader.read()) {\n parts.push(r.value);\n }\n } else {\n for await (const chunk of input as AsyncIterable<string | Uint8Array>) {\n parts.push(typeof chunk === \"string\" ? encoder.encode(chunk) : chunk);\n }\n }\n const out = new Uint8Array(parts.reduce((n, p) => n + p.byteLength, 0));\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.byteLength;\n }\n return out;\n}\n"],"names":[],"mappings":";;AA4BA,eAAsB,kBAClB,UACA,OACA,MACA,SACqB;AACrB,QAAM,YAAY,SAAS,WAAW,KAAK,QAAQ;AACnD,MAAI,cAAc,QAAW;AACzB,WAAO,SAAS,OAAO,OAAO,MAAM,OAAO;AAAA,EAC/C;AACA,QAAM,SAAS,MAAM,WAAW,KAAK;AACrC,QAAM,UAA0B,CAAA;AAChC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
1
+ {"version":3,"file":"choose-DvpbdRuz.js","sources":["../../src/common/choose.ts"],"sourcesContent":["/**\n * The graph choice of an importer that can read every graph of a file (importAll) but has no cheap\n * listing: `graphIndex` / `graphName` passed to its import() directly, as the registry would honor\n * them, so a caller with its own builder is not silently given the first graph.\n */\n\nimport { GraphBuilder, type GraphSink } from \"@graphty/graph-format\";\n\nimport {\n type CommonImportOptions,\n type GraphChoiceOptions,\n type GraphImporter,\n type ImportInput,\n type ImportReport,\n} from \"../types.js\";\nimport { chooseGraph } from \"./options.js\";\nimport { ImportReportBuilder } from \"./report.js\";\n\n/**\n * Read the graph `graphIndex` or `graphName` chooses into the sink: every graph is read once into a\n * scratch builder to learn the names (E_GRAPH_NOT_FOUND lists them), then the input again with the\n * chosen graph going to the sink.\n * @param importer - the importer, which has importAll()\n * @param input - the input\n * @param sink - the caller's sink\n * @param options - the import options, with the choice\n * @returns the chosen graph's report\n */\nexport async function importChosenGraph<O>(\n importer: GraphImporter<O>,\n input: ImportInput,\n sink: GraphSink,\n options: (O & CommonImportOptions & GraphChoiceOptions) | undefined,\n): Promise<ImportReport> {\n const importAll = importer.importAll?.bind(importer);\n if (importAll === undefined) {\n return importer.import(input, sink, options);\n }\n const replay = await replayable(input);\n const scratch: GraphBuilder[] = [];\n await importAll(replay, (i) => (scratch[i] = new GraphBuilder({ directed: false })), {\n ...options,\n onProgress: undefined,\n } as O & CommonImportOptions);\n const names = scratch.map((b) => {\n try {\n return b.freeze().meta.name;\n } catch {\n return null;\n }\n });\n const chosen = chooseGraph(names, options, new ImportReportBuilder(importer.format, 0));\n const reports = await importAll(\n replay,\n (i) => (i === chosen ? sink : new GraphBuilder({ directed: false })),\n options,\n );\n return reports[chosen];\n}\n\n/**\n * The input as a string or bytes that can be read twice.\n * @param input - the input\n * @returns the same text or bytes, or the stream's bytes\n */\nasync function replayable(input: ImportInput): Promise<string | Uint8Array> {\n if (typeof input === \"string\" || input instanceof Uint8Array) {\n return input;\n }\n const parts: Uint8Array[] = [];\n const encoder = new TextEncoder();\n if (typeof (input as ReadableStream<Uint8Array>).getReader === \"function\") {\n const reader = (input as ReadableStream<Uint8Array>).getReader();\n for (let r = await reader.read(); !r.done; r = await reader.read()) {\n parts.push(r.value);\n }\n } else {\n for await (const chunk of input as AsyncIterable<string | Uint8Array>) {\n parts.push(typeof chunk === \"string\" ? encoder.encode(chunk) : chunk);\n }\n }\n const out = new Uint8Array(parts.reduce((n, p) => n + p.byteLength, 0));\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.byteLength;\n }\n return out;\n}\n"],"names":[],"mappings":";;AA4BA,eAAsB,kBAClB,UACA,OACA,MACA,SACqB;AACrB,QAAM,YAAY,SAAS,WAAW,KAAK,QAAQ;AACnD,MAAI,cAAc,QAAW;AACzB,WAAO,SAAS,OAAO,OAAO,MAAM,OAAO;AAAA,EAC/C;AACA,QAAM,SAAS,MAAM,WAAW,KAAK;AACrC,QAAM,UAA0B,CAAA;AAChC,QAAM,UAAU,QAAQ,CAAC,MAAO,QAAQ,CAAC,IAAI,IAAI,aAAa,EAAE,UAAU,MAAA,CAAO,GAAI;AAAA,IACjF,GAAG;AAAA,IACH,YAAY;AAAA,EAAA,CACY;AAC5B,QAAM,QAAQ,QAAQ,IAAI,CAAC,MAAM;AAC7B,QAAI;AACA,aAAO,EAAE,SAAS,KAAK;AAAA,IAC3B,QAAQ;AACJ,aAAO;AAAA,IACX;AAAA,EACJ,CAAC;AACD,QAAM,SAAS,YAAY,OAAO,SAAS,IAAI,oBAAoB,SAAS,QAAQ,CAAC,CAAC;AACtF,QAAM,UAAU,MAAM;AAAA,IAClB;AAAA,IACA,CAAC,MAAO,MAAM,SAAS,OAAO,IAAI,aAAa,EAAE,UAAU,OAAO;AAAA,IAClE;AAAA,EAAA;AAEJ,SAAO,QAAQ,MAAM;AACzB;AAOA,eAAe,WAAW,OAAkD;AACxE,MAAI,OAAO,UAAU,YAAY,iBAAiB,YAAY;AAC1D,WAAO;AAAA,EACX;AACA,QAAM,QAAsB,CAAA;AAC5B,QAAM,UAAU,IAAI,YAAA;AACpB,MAAI,OAAQ,MAAqC,cAAc,YAAY;AACvE,UAAM,SAAU,MAAqC,UAAA;AACrD,aAAS,IAAI,MAAM,OAAO,KAAA,GAAQ,CAAC,EAAE,MAAM,IAAI,MAAM,OAAO,KAAA,GAAQ;AAChE,YAAM,KAAK,EAAE,KAAK;AAAA,IACtB;AAAA,EACJ,OAAO;AACH,qBAAiB,SAAS,OAA6C;AACnE,YAAM,KAAK,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK,IAAI,KAAK;AAAA,IACxE;AAAA,EACJ;AACA,QAAM,MAAM,IAAI,WAAW,MAAM,OAAO,CAAC,GAAG,MAAM,IAAI,EAAE,YAAY,CAAC,CAAC;AACtE,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACtB,QAAI,IAAI,MAAM,MAAM;AACpB,cAAU,KAAK;AAAA,EACnB;AACA,SAAO;AACX;"}
@@ -1,4 +1,4 @@
1
- import { M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, P as PRECISION_CODE, B as BAD_DEFAULT_CODE, U as UNKNOWN_ATTR_TYPE_CODE, R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, O as OPTION_IGNORED_CODE, I as ID_MERGED_CODE, f as STRAY_TEXT_CODE, g as UNKNOWN_ELEMENT_CODE, h as UNKNOWN_XML_ATTRIBUTE_CODE, i as DANGLING_REFERENCE_CODE, H as HYPEREDGE_CODE, j as COUNT_MISMATCH_CODE, k as COUNT_HINT_CODE, l as MULTIPLE_GRAPHS_CODE, m as DUPLICATE_EDGE_ID_CODE, n as DUPLICATE_NODE_CODE, o as DUPLICATE_ATTRIBUTE_CODE, q as UNKNOWN_PARENT_CODE, s as MISSING_ENDPOINT_CODE, t as MISSING_ID_CODE, u as DUPLICATE_KEY_CODE, N as NO_GRAPH_CODE, E as EMPTY_INPUT_CODE, v as ENCODING_CONFLICT_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, X as XML_SYNTAX_CODE, A as COLUMN_TYPE_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, J as ID_TEXT_TYPE_CODE, K as ROLE_DROPPED_CODE, Q as PARENTS_DROPPED_CODE, T as MUTUAL_AS_UNDIRECTED_CODE } from "./export-B-aVCwyG.js";
1
+ import { M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, P as PRECISION_CODE, B as BAD_DEFAULT_CODE, U as UNKNOWN_ATTR_TYPE_CODE, R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, O as OPTION_IGNORED_CODE, I as ID_MERGED_CODE, f as STRAY_TEXT_CODE, g as UNKNOWN_ELEMENT_CODE, h as UNKNOWN_XML_ATTRIBUTE_CODE, i as DANGLING_REFERENCE_CODE, H as HYPEREDGE_CODE, j as COUNT_MISMATCH_CODE, k as COUNT_HINT_CODE, l as MULTIPLE_GRAPHS_CODE, m as DUPLICATE_EDGE_ID_CODE, n as DUPLICATE_NODE_CODE, o as DUPLICATE_ATTRIBUTE_CODE, q as UNKNOWN_PARENT_CODE, s as MISSING_ENDPOINT_CODE, t as MISSING_ID_CODE, u as DUPLICATE_KEY_CODE, N as NO_GRAPH_CODE, E as EMPTY_INPUT_CODE, v as ENCODING_CONFLICT_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, X as XML_SYNTAX_CODE, A as COLUMN_TYPE_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, J as ID_TEXT_TYPE_CODE, K as ROLE_DROPPED_CODE, Q as PARENTS_DROPPED_CODE, T as MUTUAL_AS_UNDIRECTED_CODE } from "./export-rKLeGQMo.js";
2
2
  const GRAPHML_NAMESPACE = "http://graphml.graphdrawing.org/xmlns";
3
3
  const YFILES_NAMESPACE = "http://www.yworks.com/xml/graphml";
4
4
  const XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance";
@@ -228,4 +228,4 @@ export {
228
228
  EXTENSIONS as f,
229
229
  ORIGINAL_ID_COLUMN as g
230
230
  };
231
- //# sourceMappingURL=constants-DqKZT6cH.js.map
231
+ //# sourceMappingURL=constants-fT3E8JYY.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants-DqKZT6cH.js","sources":["../../src/formats/graphml/constants.ts"],"sourcesContent":["/**\n * What the GraphML importer and exporter share: the namespace, the format facts, the reserved\n * column names of the XML-attribute-derived columns, the `meta.extra`\n * keys the importer records for the exporter, and the issue and loss codes.\n */\n\nimport {\n BAD_DEFAULT_CODE,\n COLUMN_RENAMED_CODE,\n COLUMN_TYPE_CODE,\n COUNT_HINT_CODE,\n COUNT_MISMATCH_CODE,\n DANGLING_REFERENCE_CODE,\n DIRECTION_FORCED_CODE,\n DIRECTION_REFUSED_CODE,\n DUPLICATE_ATTRIBUTE_CODE,\n DUPLICATE_EDGE_ID_CODE,\n DUPLICATE_KEY_CODE,\n DUPLICATE_NODE_CODE,\n ELEMENT_ISSUE,\n EMPTY_INPUT_CODE,\n ENCODING_CONFLICT_CODE,\n ENCODING_FALLBACK_CODE,\n HYPEREDGE_CODE,\n ID_MERGED_CODE,\n ID_TEXT_TYPE_CODE,\n INPUT_ISSUE,\n INVALID_ENCODING_CODE,\n INVALID_UTF8_CODE,\n MISSING_ENDPOINT_CODE,\n MISSING_ID_CODE,\n MIXED_DIRECTION_CODE,\n MULTIPLE_GRAPHS_CODE,\n MUTUAL_AS_UNDIRECTED_CODE,\n NO_GRAPH_CODE,\n OPTION_IGNORED_CODE,\n PARENTS_DROPPED_CODE,\n PRECISION_CODE,\n ROLE_DROPPED_CODE,\n ROLE_TAKEN_CODE,\n SINK_OPTION_CODE,\n STRAY_TEXT_CODE,\n UNKNOWN_ATTR_TYPE_CODE,\n UNKNOWN_ELEMENT_CODE,\n UNKNOWN_ENCODING_CODE,\n UNKNOWN_PARENT_CODE,\n UNKNOWN_XML_ATTRIBUTE_CODE,\n XML_SYNTAX_CODE,\n} from \"../../common/codes.js\";\n\n/**\n * The GraphML namespace.\n * @category Plugin helpers\n */\nexport const GRAPHML_NAMESPACE = \"http://graphml.graphdrawing.org/xmlns\";\n\n/**\n * The yFiles extension namespace, declared as `xmlns:y` when a yfiles column is written.\n * @category Plugin helpers\n */\nexport const YFILES_NAMESPACE = \"http://www.yworks.com/xml/graphml\";\n\n/**\n * The XML Schema instance namespace and the schema location the exporter writes.\n * @category Plugin helpers\n */\nexport const XSI_NAMESPACE = \"http://www.w3.org/2001/XMLSchema-instance\";\n\n/**\n * The GraphML schema location written by the exporter.\n * @category Plugin helpers\n */\nexport const SCHEMA_LOCATION =\n \"http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\";\n\n/**\n * The format name.\n * @category Plugin helpers\n */\nexport const FORMAT = \"graphml\";\n\n/**\n * File extensions.\n * @category Plugin helpers\n */\nexport const EXTENSIONS: readonly string[] = Object.freeze([\".graphml\", \".xml\"]);\n\n/**\n * MIME types.\n * @category Plugin helpers\n */\nexport const MIME_TYPES: readonly string[] = Object.freeze([\"application/graphml+xml\", \"application/xml\", \"text/xml\"]);\n\n/**\n * The `attr.name` of the node key that carries ids rewritten by `sanitizeIds: \"mangle\"`.\n * @category Plugin helpers\n */\nexport const ORIGINAL_ID_ATTRIBUTE = \"graphty:originalId\";\n\n/**\n * The node column that keeps original ids when `restoreMangledIds` is off.\n * @category Plugin helpers\n */\nexport const ORIGINAL_ID_COLUMN = \"graphty.originalId\";\n\n/**\n * The edge column of the `id` XML attribute (role id, unique).\n * @category Plugin helpers\n */\nexport const EDGE_ID_COLUMN = \"id\";\n\n/**\n * The edge columns of the `sourceport` / `targetport` XML attributes (roles sourcePort / targetPort).\n * @category Plugin helpers\n */\nexport const SOURCE_PORT_COLUMN = \"sourceport\";\n\n/**\n * The edge column of the `targetport` XML attribute.\n * @category Plugin helpers\n */\nexport const TARGET_PORT_COLUMN = \"targetport\";\n\n/**\n * The node column of the containing node of a nested graph (u32, role parent, refersTo node).\n * @category Plugin helpers\n */\nexport const PARENT_COLUMN = \"parent\";\n\n/**\n * The bool node column marking the hub nodes synthesized for hyperedges under `hyperedges: \"star\"`.\n * @category Plugin helpers\n */\nexport const HYPEREDGE_HUB_COLUMN = \"graphty.hyperedge\";\n\n/**\n * The column name a node key titled `label` receives the `label` role under.\n * @category Plugin helpers\n */\nexport const LABEL_COLUMN = \"label\";\n\n/**\n * Edge column names reserved for the XML-attribute-derived columns; a key titled like one is renamed `<name>#<id>`.\n * @category Plugin helpers\n */\nexport const RESERVED_EDGE_NAMES: ReadonlySet<string> = new Set([\n EDGE_ID_COLUMN,\n SOURCE_PORT_COLUMN,\n TARGET_PORT_COLUMN,\n]);\n\n/**\n * Node column names reserved for the XML-derived columns.\n * @category Plugin helpers\n */\nexport const RESERVED_NODE_NAMES: ReadonlySet<string> = new Set([PARENT_COLUMN]);\n\n/**\n * The `meta.extra` key under which the importer records what the exporter needs.\n * @category Plugin helpers\n */\nexport const META_KEY = \"graphml\";\n\n/**\n * What the importer stores under `meta.extra.graphml`.\n * @category Plugin helpers\n */\nexport interface GraphmlMeta {\n /** The top-level `<graph id>`, or null. */\n readonly graphId: string | null;\n /** The top-level `edgedefault` as written, so a mixed file re-exports with the same layout. */\n readonly edgedefault: \"directed\" | \"undirected\" | null;\n /** The `xmlns:<prefix>` declarations of the root element (yFiles and the like). */\n readonly namespaces: Readonly<Record<string, string>>;\n}\n\n/**\n * The issue codes the GraphML importer records, by name: the codes shared\n * with the other importers and the GraphML-specific ones. A key is the code\n * without its severity and format prefixes.\n * @category Built-in formats\n */\nexport const GRAPHML_ISSUE = Object.freeze({\n ...INPUT_ISSUE,\n ...ELEMENT_ISSUE,\n /**\n * A value that does not parse as the type its attribute declares (\"x\" in an integer attribute). The value is\n * left unset; the node or edge is kept.\n */\n COLUMN_TYPE: COLUMN_TYPE_CODE,\n /** The input is not well-formed XML. The import stops. */\n XML_SYNTAX: XML_SYNTAX_CODE,\n /** The input is not valid UTF-8. The import stops. */\n INVALID_UTF8: INVALID_UTF8_CODE,\n /**\n * Some bytes are not valid in the encoding that was chosen (by a byte order mark, the file's declaration or the\n * `encoding` option). The import stops.\n */\n INVALID_ENCODING: INVALID_ENCODING_CODE,\n /** Bytes that are not UTF-8 and declare no encoding were read as windows-1252. */\n ENCODING_FALLBACK: ENCODING_FALLBACK_CODE,\n /** A declared encoding the platform cannot decode was ignored. */\n UNKNOWN_ENCODING: UNKNOWN_ENCODING_CODE,\n /** A declared encoding the byte order mark contradicts (the mark wins). */\n ENCODING_CONFLICT: ENCODING_CONFLICT_CODE,\n /** The input holds no XML at all: it is empty, whitespace or a byte order mark only. The import stops. */\n EMPTY_INPUT: EMPTY_INPUT_CODE,\n /** The root element is not `<graphml>`. The import stops. */\n NOT_GRAPHML: \"E_NOT_GRAPHML\",\n /** The `<graphml>` root is in a namespace other than GraphML's; it is read as GraphML. */\n NAMESPACE: \"W_GRAPHML_NAMESPACE\",\n /** The document has no `<graph>`. The import stops. */\n NO_GRAPH: NO_GRAPH_CODE,\n /** A `<key>` without an id. */\n KEY_MISSING_ID: \"E_GRAPHML_KEY_MISSING_ID\",\n /** Two `<key>` elements with the same id. */\n DUPLICATE_KEY: DUPLICATE_KEY_CODE,\n /** A key declared for hyperedges, ports or endpoints (never used). */\n KEY_DOMAIN_UNSUPPORTED: \"W_GRAPHML_KEY_DOMAIN_UNSUPPORTED\",\n /** A `<node>` without an id. */\n MISSING_ID: MISSING_ID_CODE,\n /** An `<edge>` without a source or a target. */\n MISSING_ENDPOINT: MISSING_ENDPOINT_CODE,\n /** An edge endpoint that names no declared node under `addMissingNodes: false`; the edge is skipped. */\n UNKNOWN_NODE: \"E_UNKNOWN_NODE\",\n /** An edge endpoint that names a nested `<graph>`, not a node; a node of that id is created. */\n GRAPH_ENDPOINT: \"W_GRAPHML_GRAPH_ENDPOINT\",\n /** The nodes of a nested graph whose container node was skipped lose their parent. */\n UNKNOWN_PARENT: UNKNOWN_PARENT_CODE,\n /** Two `<data>` of one key on one element, two `<default>` in one key, or two weight keys; one is kept. */\n DUPLICATE_ATTRIBUTE: DUPLICATE_ATTRIBUTE_CODE,\n /** A `<data>` whose key was never declared. */\n UNKNOWN_KEY: \"E_GRAPHML_UNKNOWN_KEY\",\n /** A `<key>` declared after `<data>` that used it; those values were already reported and dropped. */\n KEY_DECLARED_LATE: \"W_GRAPHML_KEY_DECLARED_LATE\",\n /** A `<data>` whose key is declared for another domain. */\n KEY_DOMAIN: \"W_GRAPHML_KEY_DOMAIN\",\n /** A `<data>` without a key attribute. */\n DATA_MISSING_KEY: \"E_GRAPHML_DATA_MISSING_KEY\",\n /** A `<key>` whose `for` is not a GraphML domain. */\n KEY_FOR_INVALID: \"E_GRAPHML_KEY_FOR_INVALID\",\n /** Data of a nested `<graph>`; only the top-level graph has attributes. */\n NESTED_GRAPH_DATA: \"W_GRAPHML_NESTED_GRAPH_DATA\",\n /** Data of a hyperedge expanded to a star or clique. */\n HYPEREDGE_DATA_DROPPED: \"W_GRAPHML_HYPEREDGE_DATA_DROPPED\",\n /** Nested elements in the `<data>` of a typed (non-yfiles) key. */\n DATA_NESTED: \"E_GRAPHML_DATA_NESTED\",\n /** A `<node>` declared twice. */\n DUPLICATE_NODE: DUPLICATE_NODE_CODE,\n /** An edge id already used by another edge. */\n DUPLICATE_EDGE_ID: DUPLICATE_EDGE_ID_CODE,\n /** A `directed` attribute that is neither true nor false. */\n INVALID_DIRECTED: \"E_GRAPHML_INVALID_DIRECTED\",\n /** An `edgedefault` that is neither directed nor undirected. */\n INVALID_EDGEDEFAULT: \"E_GRAPHML_INVALID_EDGEDEFAULT\",\n /** A `<graph>` without edgedefault; the `defaultDirected` option applies. */\n EDGEDEFAULT_MISSING: \"W_GRAPHML_EDGEDEFAULT_MISSING\",\n /**\n * The file holds more than one top-level `<graph>`; their nodes and edges are merged into one graph.\n * `importAllGraphs()` reads every one.\n */\n MULTIPLE_GRAPHS: MULTIPLE_GRAPHS_CODE,\n /**\n * A node or edge count the file announces is too large to reserve room for; it is ignored and the elements are\n * read as they come.\n */\n COUNT_HINT: COUNT_HINT_CODE,\n /**\n * A `parse.nodes` or `parse.edges` count disagrees with what the graph holds. The elements are read as they are.\n */\n COUNT_MISMATCH: COUNT_MISMATCH_CODE,\n /** A hyperedge under `hyperedges: \"error\"`. */\n HYPEREDGE: HYPEREDGE_CODE,\n /** Hyperedges skipped under `hyperedges: \"skip\"`. */\n HYPEREDGE_SKIPPED: \"W_GRAPHML_HYPEREDGE_SKIPPED\",\n /** An endpoint of a hyperedge without a node, or with an unknown type. */\n HYPEREDGE_ENDPOINT: \"E_GRAPHML_HYPEREDGE_ENDPOINT\",\n /** `<port>` declarations (and their data) are not kept; sourceport / targetport edge attributes are. */\n PORT_DECLARATION: \"W_GRAPHML_PORT_DECLARATION\",\n /** A `sourceport` / `targetport` naming a port its node does not declare (once, with the count). */\n DANGLING_REFERENCE: DANGLING_REFERENCE_CODE,\n /** A `<graph>` inside an `<edge>` (legal GraphML): it and the nodes and edges it holds are dropped. */\n EDGE_GRAPH_DROPPED: \"W_GRAPHML_EDGE_GRAPH_DROPPED\",\n /** A `<node>` whose id is that of a hub `hyperedges: \"star\"` created; the node is merged into the hub. */\n HUB_ID_CLASH: \"W_GRAPHML_HUB_ID_CLASH\",\n /** A `graphty:originalId` value that is not text, or arrives after the node was added (after its nested graph). */\n ORIGINAL_ID_IGNORED: \"W_GRAPHML_ORIGINAL_ID_IGNORED\",\n /** A yFiles graphics value (a geometry coordinate, a width) that is not a number; it is not mapped. */\n YFILES_VALUE: \"W_GRAPHML_YFILES_VALUE\",\n /**\n * A GraphML `parse.*` attribute (`parse.nodeids`, `parse.order`, ...) that graph-io does not act on; the file is\n * read normally.\n */\n PARSE_HINT_IGNORED: \"W_GRAPHML_PARSE_HINT_IGNORED\",\n /** An XML attribute GraphML does not define (or the importer does not keep) on an element; it is not kept. */\n UNKNOWN_XML_ATTRIBUTE: UNKNOWN_XML_ATTRIBUTE_CODE,\n /** A `<locator>` element. */\n LOCATOR_DROPPED: \"W_GRAPHML_LOCATOR_DROPPED\",\n /** A `<desc>` of a node, an edge or a hyperedge. */\n DESC_DROPPED: \"W_GRAPHML_DESC_DROPPED\",\n /** An element the GraphML schema does not define at that place. */\n UNKNOWN_ELEMENT: UNKNOWN_ELEMENT_CODE,\n /** Non-whitespace text where the schema allows only elements. */\n STRAY_TEXT: STRAY_TEXT_CODE,\n /** Two distinct id texts merged into one number under `ids: \"number\"`. */\n ID_MERGED: ID_MERGED_CODE,\n /** You set an option this format does not use; it had no effect. The message names the option. */\n OPTION_IGNORED: OPTION_IGNORED_CODE,\n /** A yFiles key under `yfiles: \"skip\"`. */\n YFILES_SKIPPED: \"W_GRAPHML_YFILES_SKIPPED\",\n /**\n * An attribute was renamed `<name>#<suffix>` because another attribute already has its name, for example\n * two attributes declared with the same name.\n */\n COLUMN_RENAMED: COLUMN_RENAMED_CODE,\n /**\n * You read into a graph builder that already has an id, label or position attribute, so this file's one is kept as\n * a plain attribute.\n */\n ROLE_TAKEN: ROLE_TAKEN_CODE,\n /** A declared type the format does not define (kept as string). */\n UNKNOWN_ATTR_TYPE: UNKNOWN_ATTR_TYPE_CODE,\n /** A default that does not parse as the declared type. */\n BAD_DEFAULT: BAD_DEFAULT_CODE,\n /** An integer beyond 2^53 was stored as the nearest 64-bit float; pass `long: \"string\"` to keep every digit. */\n PRECISION: PRECISION_CODE,\n /**\n * You read into your own graph builder, which was created with a different `addMissingNodes`, `duplicateEdges`,\n * `selfLoops` or `weightDtype` than the option you passed; the builder's setting applies.\n */\n SINK_OPTION: SINK_OPTION_CODE,\n /**\n * You read into a graph builder whose direction is already set, or which already holds edges, so the file is read\n * with the builder's direction instead of its own.\n */\n DIRECTION_REFUSED: DIRECTION_REFUSED_CODE,\n /** Edges of the other direction were read with the direction `onMixedDirection` chose. */\n DIRECTION_FORCED: DIRECTION_FORCED_CODE,\n /**\n * The graph has both directed and undirected edges and `onMixedDirection` is \"error\". An import stops; a save to a\n * format that holds one direction per file fails with E_DIRECTED. Pass \"directed\" or \"undirected\" to read or write\n * it anyway.\n */\n MIXED_DIRECTION: MIXED_DIRECTION_CODE,\n});\n\n/**\n * Loss note codes of the GraphML importer (report.lossy) and exporter (check()): the GraphML\n * ones; the generic ones (dtypes, lists, json text, positions, visual and temporal roles,\n * extension tables, id charsets, the weight key clash, name changes) are those of `LOSS`.\n * @category Built-in formats\n */\nexport const GRAPHML_LOSS = Object.freeze({\n /** YFiles nested XML kept as a JSON tree: structure preserved, not byte-exact. */\n YFILES_JSON: \"W_GRAPHML_YFILES_JSON\",\n /** A mutual pair written as one undirected edge; the mark is lost. */\n MUTUAL_AS_UNDIRECTED: MUTUAL_AS_UNDIRECTED_CODE,\n /** A `parents` (multi-parent) column cannot be written as nested graphs. */\n PARENTS_DROPPED: PARENTS_DROPPED_CODE,\n /** An attribute with a role the format has no place for is written as a plain attribute; the role is lost. */\n ROLE_DROPPED: ROLE_DROPPED_CODE,\n /** Containment order differs from index order; node indices change after a round trip. */\n HIERARCHY_REORDERED: \"W_GRAPHML_HIERARCHY_REORDERED\",\n /** Nodes whose parent chain never reaches a root are written at the top level. */\n PARENT_CYCLE: \"W_GRAPHML_PARENT_CYCLE\",\n /** Node ids that read back as a different type, such as the text \"7\" as the number 7. */\n ID_TEXT_TYPE: ID_TEXT_TYPE_CODE,\n /** A numeric edge id column reads back as string. */\n EDGE_ID_TEXT: \"W_GRAPHML_EDGE_ID_TEXT\",\n /** A `yfiles.*` graphics column that no longer matches its yFiles tree: only the tree is written. */\n YFILES_GRAPHICS_STALE: \"W_GRAPHML_YFILES_GRAPHICS_STALE\",\n /** A yEd graphics value that is not valid XML; the save fails with E_COLUMN_TYPE. */\n YFILES_TREE: \"E_GRAPHML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A;AAAA;AAAA,EAMlB,iBAAiB;AACrB,CAAC;AAQM,MAAM,eAAe,OAAO,OAAO;AAAA;AAAA,EAEtC,aAAa;AAAA;AAAA,EAEb,sBAAsB;AAAA;AAAA,EAEtB,iBAAiB;AAAA;AAAA,EAEjB,cAAc;AAAA;AAAA,EAEd,qBAAqB;AAAA;AAAA,EAErB,cAAc;AAAA;AAAA,EAEd,cAAc;AAAA;AAAA,EAEd,cAAc;AAAA;AAAA,EAEd,uBAAuB;AAAA;AAAA,EAEvB,aAAa;AACjB,CAAC;"}
1
+ {"version":3,"file":"constants-fT3E8JYY.js","sources":["../../src/formats/graphml/constants.ts"],"sourcesContent":["/**\n * What the GraphML importer and exporter share: the namespace, the format facts, the reserved\n * column names of the XML-attribute-derived columns, the `meta.extra`\n * keys the importer records for the exporter, and the issue and loss codes.\n */\n\nimport {\n BAD_DEFAULT_CODE,\n COLUMN_RENAMED_CODE,\n COLUMN_TYPE_CODE,\n COUNT_HINT_CODE,\n COUNT_MISMATCH_CODE,\n DANGLING_REFERENCE_CODE,\n DIRECTION_FORCED_CODE,\n DIRECTION_REFUSED_CODE,\n DUPLICATE_ATTRIBUTE_CODE,\n DUPLICATE_EDGE_ID_CODE,\n DUPLICATE_KEY_CODE,\n DUPLICATE_NODE_CODE,\n ELEMENT_ISSUE,\n EMPTY_INPUT_CODE,\n ENCODING_CONFLICT_CODE,\n ENCODING_FALLBACK_CODE,\n HYPEREDGE_CODE,\n ID_MERGED_CODE,\n ID_TEXT_TYPE_CODE,\n INPUT_ISSUE,\n INVALID_ENCODING_CODE,\n INVALID_UTF8_CODE,\n MISSING_ENDPOINT_CODE,\n MISSING_ID_CODE,\n MIXED_DIRECTION_CODE,\n MULTIPLE_GRAPHS_CODE,\n MUTUAL_AS_UNDIRECTED_CODE,\n NO_GRAPH_CODE,\n OPTION_IGNORED_CODE,\n PARENTS_DROPPED_CODE,\n PRECISION_CODE,\n ROLE_DROPPED_CODE,\n ROLE_TAKEN_CODE,\n SINK_OPTION_CODE,\n STRAY_TEXT_CODE,\n UNKNOWN_ATTR_TYPE_CODE,\n UNKNOWN_ELEMENT_CODE,\n UNKNOWN_ENCODING_CODE,\n UNKNOWN_PARENT_CODE,\n UNKNOWN_XML_ATTRIBUTE_CODE,\n XML_SYNTAX_CODE,\n} from \"../../common/codes.js\";\n\n/**\n * The GraphML namespace.\n * @category Plugin helpers\n */\nexport const GRAPHML_NAMESPACE = \"http://graphml.graphdrawing.org/xmlns\";\n\n/**\n * The yFiles extension namespace, declared as `xmlns:y` when a yfiles column is written.\n * @category Plugin helpers\n */\nexport const YFILES_NAMESPACE = \"http://www.yworks.com/xml/graphml\";\n\n/**\n * The XML Schema instance namespace and the schema location the exporter writes.\n * @category Plugin helpers\n */\nexport const XSI_NAMESPACE = \"http://www.w3.org/2001/XMLSchema-instance\";\n\n/**\n * The GraphML schema location written by the exporter.\n * @category Plugin helpers\n */\nexport const SCHEMA_LOCATION =\n \"http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\";\n\n/**\n * The format name.\n * @category Plugin helpers\n */\nexport const FORMAT = \"graphml\";\n\n/**\n * File extensions.\n * @category Plugin helpers\n */\nexport const EXTENSIONS: readonly string[] = Object.freeze([\".graphml\", \".xml\"]);\n\n/**\n * MIME types.\n * @category Plugin helpers\n */\nexport const MIME_TYPES: readonly string[] = Object.freeze([\"application/graphml+xml\", \"application/xml\", \"text/xml\"]);\n\n/**\n * The `attr.name` of the node key that carries ids rewritten by `sanitizeIds: \"mangle\"`.\n * @category Plugin helpers\n */\nexport const ORIGINAL_ID_ATTRIBUTE = \"graphty:originalId\";\n\n/**\n * The node column that keeps original ids when `restoreMangledIds` is off.\n * @category Plugin helpers\n */\nexport const ORIGINAL_ID_COLUMN = \"graphty.originalId\";\n\n/**\n * The edge column of the `id` XML attribute (role id, unique).\n * @category Plugin helpers\n */\nexport const EDGE_ID_COLUMN = \"id\";\n\n/**\n * The edge columns of the `sourceport` / `targetport` XML attributes (roles sourcePort / targetPort).\n * @category Plugin helpers\n */\nexport const SOURCE_PORT_COLUMN = \"sourceport\";\n\n/**\n * The edge column of the `targetport` XML attribute.\n * @category Plugin helpers\n */\nexport const TARGET_PORT_COLUMN = \"targetport\";\n\n/**\n * The node column of the containing node of a nested graph (u32, role parent, refersTo node).\n * @category Plugin helpers\n */\nexport const PARENT_COLUMN = \"parent\";\n\n/**\n * The bool node column marking the hub nodes synthesized for hyperedges under `hyperedges: \"star\"`.\n * @category Plugin helpers\n */\nexport const HYPEREDGE_HUB_COLUMN = \"graphty.hyperedge\";\n\n/**\n * The column name a node key titled `label` receives the `label` role under.\n * @category Plugin helpers\n */\nexport const LABEL_COLUMN = \"label\";\n\n/**\n * Edge column names reserved for the XML-attribute-derived columns; a key titled like one is renamed `<name>#<id>`.\n * @category Plugin helpers\n */\nexport const RESERVED_EDGE_NAMES: ReadonlySet<string> = new Set([\n EDGE_ID_COLUMN,\n SOURCE_PORT_COLUMN,\n TARGET_PORT_COLUMN,\n]);\n\n/**\n * Node column names reserved for the XML-derived columns.\n * @category Plugin helpers\n */\nexport const RESERVED_NODE_NAMES: ReadonlySet<string> = new Set([PARENT_COLUMN]);\n\n/**\n * The `meta.extra` key under which the importer records what the exporter needs.\n * @category Plugin helpers\n */\nexport const META_KEY = \"graphml\";\n\n/**\n * What the importer stores under `meta.extra.graphml`.\n * @category Plugin helpers\n */\nexport interface GraphmlMeta {\n /** The top-level `<graph id>`, or null. */\n readonly graphId: string | null;\n /** The top-level `edgedefault` as written, so a mixed file re-exports with the same layout. */\n readonly edgedefault: \"directed\" | \"undirected\" | null;\n /** The `xmlns:<prefix>` declarations of the root element (yFiles and the like). */\n readonly namespaces: Readonly<Record<string, string>>;\n}\n\n/**\n * The issue codes the GraphML importer records, by name: the codes shared\n * with the other importers and the GraphML-specific ones. A key is the code\n * without its severity and format prefixes.\n * @category Built-in formats\n */\nexport const GRAPHML_ISSUE = Object.freeze({\n ...INPUT_ISSUE,\n ...ELEMENT_ISSUE,\n /**\n * A value that does not parse as the type its attribute declares (\"x\" in an integer attribute). The value is\n * left unset; the node or edge is kept.\n */\n COLUMN_TYPE: COLUMN_TYPE_CODE,\n /** The input is not well-formed XML. The import stops. */\n XML_SYNTAX: XML_SYNTAX_CODE,\n /** The input is not valid UTF-8. The import stops. */\n INVALID_UTF8: INVALID_UTF8_CODE,\n /**\n * Some bytes are not valid in the encoding that was chosen (by a byte order mark, the file's declaration or the\n * `encoding` option). The import stops.\n */\n INVALID_ENCODING: INVALID_ENCODING_CODE,\n /** Bytes that are not UTF-8 and declare no encoding were read as windows-1252. */\n ENCODING_FALLBACK: ENCODING_FALLBACK_CODE,\n /** A declared encoding the platform cannot decode was ignored. */\n UNKNOWN_ENCODING: UNKNOWN_ENCODING_CODE,\n /** A declared encoding the byte order mark contradicts (the mark wins). */\n ENCODING_CONFLICT: ENCODING_CONFLICT_CODE,\n /** The input holds no XML at all: it is empty, whitespace or a byte order mark only. The import stops. */\n EMPTY_INPUT: EMPTY_INPUT_CODE,\n /** The root element is not `<graphml>`. The import stops. */\n NOT_GRAPHML: \"E_NOT_GRAPHML\",\n /** The `<graphml>` root is in a namespace other than GraphML's; it is read as GraphML. */\n NAMESPACE: \"W_GRAPHML_NAMESPACE\",\n /** The document has no `<graph>`. The import stops. */\n NO_GRAPH: NO_GRAPH_CODE,\n /** A `<key>` without an id. */\n KEY_MISSING_ID: \"E_GRAPHML_KEY_MISSING_ID\",\n /** Two `<key>` elements with the same id. */\n DUPLICATE_KEY: DUPLICATE_KEY_CODE,\n /** A key declared for hyperedges, ports or endpoints (never used). */\n KEY_DOMAIN_UNSUPPORTED: \"W_GRAPHML_KEY_DOMAIN_UNSUPPORTED\",\n /** A `<node>` without an id. */\n MISSING_ID: MISSING_ID_CODE,\n /** An `<edge>` without a source or a target. */\n MISSING_ENDPOINT: MISSING_ENDPOINT_CODE,\n /** An edge endpoint that names no declared node under `addMissingNodes: false`; the edge is skipped. */\n UNKNOWN_NODE: \"E_UNKNOWN_NODE\",\n /** An edge endpoint that names a nested `<graph>`, not a node; a node of that id is created. */\n GRAPH_ENDPOINT: \"W_GRAPHML_GRAPH_ENDPOINT\",\n /** The nodes of a nested graph whose container node was skipped lose their parent. */\n UNKNOWN_PARENT: UNKNOWN_PARENT_CODE,\n /** Two `<data>` of one key on one element, two `<default>` in one key, or two weight keys; one is kept. */\n DUPLICATE_ATTRIBUTE: DUPLICATE_ATTRIBUTE_CODE,\n /** A `<data>` whose key was never declared. */\n UNKNOWN_KEY: \"E_GRAPHML_UNKNOWN_KEY\",\n /** A `<key>` declared after `<data>` that used it; those values were already reported and dropped. */\n KEY_DECLARED_LATE: \"W_GRAPHML_KEY_DECLARED_LATE\",\n /** A `<data>` whose key is declared for another domain. */\n KEY_DOMAIN: \"W_GRAPHML_KEY_DOMAIN\",\n /** A `<data>` without a key attribute. */\n DATA_MISSING_KEY: \"E_GRAPHML_DATA_MISSING_KEY\",\n /** A `<key>` whose `for` is not a GraphML domain. */\n KEY_FOR_INVALID: \"E_GRAPHML_KEY_FOR_INVALID\",\n /** Data of a nested `<graph>`; only the top-level graph has attributes. */\n NESTED_GRAPH_DATA: \"W_GRAPHML_NESTED_GRAPH_DATA\",\n /** Data of a hyperedge expanded to a star or clique. */\n HYPEREDGE_DATA_DROPPED: \"W_GRAPHML_HYPEREDGE_DATA_DROPPED\",\n /** Nested elements in the `<data>` of a typed (non-yfiles) key. */\n DATA_NESTED: \"E_GRAPHML_DATA_NESTED\",\n /** A `<node>` declared twice. */\n DUPLICATE_NODE: DUPLICATE_NODE_CODE,\n /** An edge id already used by another edge. */\n DUPLICATE_EDGE_ID: DUPLICATE_EDGE_ID_CODE,\n /** A `directed` attribute that is neither true nor false. */\n INVALID_DIRECTED: \"E_GRAPHML_INVALID_DIRECTED\",\n /** An `edgedefault` that is neither directed nor undirected. */\n INVALID_EDGEDEFAULT: \"E_GRAPHML_INVALID_EDGEDEFAULT\",\n /** A `<graph>` without edgedefault; the `defaultDirected` option applies. */\n EDGEDEFAULT_MISSING: \"W_GRAPHML_EDGEDEFAULT_MISSING\",\n /**\n * The file holds more than one top-level `<graph>`; their nodes and edges are merged into one graph.\n * `importAllGraphs()` reads every one.\n */\n MULTIPLE_GRAPHS: MULTIPLE_GRAPHS_CODE,\n /**\n * A node or edge count the file announces is too large to reserve room for; it is ignored and the elements are\n * read as they come.\n */\n COUNT_HINT: COUNT_HINT_CODE,\n /**\n * A `parse.nodes` or `parse.edges` count disagrees with what the graph holds. The elements are read as they are.\n */\n COUNT_MISMATCH: COUNT_MISMATCH_CODE,\n /** A hyperedge under `hyperedges: \"error\"`. */\n HYPEREDGE: HYPEREDGE_CODE,\n /** Hyperedges skipped under `hyperedges: \"skip\"`. */\n HYPEREDGE_SKIPPED: \"W_GRAPHML_HYPEREDGE_SKIPPED\",\n /** An endpoint of a hyperedge without a node, or with an unknown type. */\n HYPEREDGE_ENDPOINT: \"E_GRAPHML_HYPEREDGE_ENDPOINT\",\n /** `<port>` declarations (and their data) are not kept; sourceport / targetport edge attributes are. */\n PORT_DECLARATION: \"W_GRAPHML_PORT_DECLARATION\",\n /** A `sourceport` / `targetport` naming a port its node does not declare (once, with the count). */\n DANGLING_REFERENCE: DANGLING_REFERENCE_CODE,\n /** A `<graph>` inside an `<edge>` (legal GraphML): it and the nodes and edges it holds are dropped. */\n EDGE_GRAPH_DROPPED: \"W_GRAPHML_EDGE_GRAPH_DROPPED\",\n /** A `<node>` whose id is that of a hub `hyperedges: \"star\"` created; the node is merged into the hub. */\n HUB_ID_CLASH: \"W_GRAPHML_HUB_ID_CLASH\",\n /** A `graphty:originalId` value that is not text, or arrives after the node was added (after its nested graph). */\n ORIGINAL_ID_IGNORED: \"W_GRAPHML_ORIGINAL_ID_IGNORED\",\n /** A yFiles graphics value (a geometry coordinate, a width) that is not a number; it is not mapped. */\n YFILES_VALUE: \"W_GRAPHML_YFILES_VALUE\",\n /**\n * A GraphML `parse.*` attribute (`parse.nodeids`, `parse.order`, ...) that graph-io does not act on; the file is\n * read normally.\n */\n PARSE_HINT_IGNORED: \"W_GRAPHML_PARSE_HINT_IGNORED\",\n /** An XML attribute GraphML does not define (or the importer does not keep) on an element; it is not kept. */\n UNKNOWN_XML_ATTRIBUTE: UNKNOWN_XML_ATTRIBUTE_CODE,\n /** A `<locator>` element. */\n LOCATOR_DROPPED: \"W_GRAPHML_LOCATOR_DROPPED\",\n /** A `<desc>` of a node, an edge or a hyperedge. */\n DESC_DROPPED: \"W_GRAPHML_DESC_DROPPED\",\n /** An element the GraphML schema does not define at that place. */\n UNKNOWN_ELEMENT: UNKNOWN_ELEMENT_CODE,\n /** Non-whitespace text where the schema allows only elements. */\n STRAY_TEXT: STRAY_TEXT_CODE,\n /** Two distinct id texts merged into one number under `ids: \"number\"`. */\n ID_MERGED: ID_MERGED_CODE,\n /** You set an option this format does not use; it had no effect. The message names the option. */\n OPTION_IGNORED: OPTION_IGNORED_CODE,\n /** A yFiles key under `yfiles: \"skip\"`. */\n YFILES_SKIPPED: \"W_GRAPHML_YFILES_SKIPPED\",\n /**\n * An attribute was renamed `<name>#<suffix>` because another attribute already has its name, for example\n * two attributes declared with the same name.\n */\n COLUMN_RENAMED: COLUMN_RENAMED_CODE,\n /**\n * You read into a graph builder that already has an id, label or position attribute, so this file's one is kept as\n * a plain attribute.\n */\n ROLE_TAKEN: ROLE_TAKEN_CODE,\n /** A declared type the format does not define (kept as string). */\n UNKNOWN_ATTR_TYPE: UNKNOWN_ATTR_TYPE_CODE,\n /** A default that does not parse as the declared type. */\n BAD_DEFAULT: BAD_DEFAULT_CODE,\n /** An integer beyond 2^53 was stored as the nearest 64-bit float; pass `long: \"string\"` to keep every digit. */\n PRECISION: PRECISION_CODE,\n /**\n * You read into your own graph builder, which was created with a different `addMissingNodes`, `duplicateEdges`,\n * `selfLoops` or `weightDtype` than the option you passed; the builder's setting applies.\n */\n SINK_OPTION: SINK_OPTION_CODE,\n /**\n * You read into a graph builder whose direction is already set, or which already holds edges, so the file is read\n * with the builder's direction instead of its own.\n */\n DIRECTION_REFUSED: DIRECTION_REFUSED_CODE,\n /** Edges of the other direction were read with the direction `onMixedDirection` chose. */\n DIRECTION_FORCED: DIRECTION_FORCED_CODE,\n /**\n * The graph has both directed and undirected edges and `onMixedDirection` is \"error\". An import stops; a save to a\n * format that holds one direction per file fails with E_DIRECTED. Pass \"directed\" or \"undirected\" to read or write\n * it anyway.\n */\n MIXED_DIRECTION: MIXED_DIRECTION_CODE,\n});\n\n/**\n * Loss note codes of the GraphML importer (report.lossy) and exporter (check()): the GraphML\n * ones; the generic ones (dtypes, lists, json text, positions, visual and temporal roles,\n * extension tables, id charsets, the weight key clash, name changes) are those of `LOSS`.\n * @category Built-in formats\n */\nexport const GRAPHML_LOSS = Object.freeze({\n /** YFiles nested XML kept as a JSON tree: structure preserved, not byte-exact. */\n YFILES_JSON: \"W_GRAPHML_YFILES_JSON\",\n /** A mutual pair written as one undirected edge; the mark is lost. */\n MUTUAL_AS_UNDIRECTED: MUTUAL_AS_UNDIRECTED_CODE,\n /** A `parents` (multi-parent) column cannot be written as nested graphs. */\n PARENTS_DROPPED: PARENTS_DROPPED_CODE,\n /** An attribute with a role the format has no place for is written as a plain attribute; the role is lost. */\n ROLE_DROPPED: ROLE_DROPPED_CODE,\n /** Containment order differs from index order; node indices change after a round trip. */\n HIERARCHY_REORDERED: \"W_GRAPHML_HIERARCHY_REORDERED\",\n /** Nodes whose parent chain never reaches a root are written at the top level. */\n PARENT_CYCLE: \"W_GRAPHML_PARENT_CYCLE\",\n /** Node ids that read back as a different type, such as the text \"7\" as the number 7. */\n ID_TEXT_TYPE: ID_TEXT_TYPE_CODE,\n /** A numeric edge id column reads back as string. */\n EDGE_ID_TEXT: \"W_GRAPHML_EDGE_ID_TEXT\",\n /** A `yfiles.*` graphics column that no longer matches its yFiles tree: only the tree is written. */\n YFILES_GRAPHICS_STALE: \"W_GRAPHML_YFILES_GRAPHICS_STALE\",\n /** A yEd graphics value that is not valid XML; the save fails with E_COLUM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EnB,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,iBAAiB;AACrB,CAAC;AAQM,MAAM,eAAe,OAAO,OAAO;AAAA;AAAA,EAEtC,aAAa;AAAA;AAAA,EAEb,sBAAsB;AAAA;AAAA,EAEtB,iBAAiB;AAAA;AAAA,EAEjB,cAAc;AAAA;AAAA,EAEd,qBAAqB;AAAA;AAAA,EAErB,cAAc;AAAA;AAAA,EAEd,cAAc;AAAA;AAAA,EAEd,cAAc;AAAA;AAAA,EAEd,uBAAuB;AAAA;AAAA,EAEvB,aAAa;AACjB,CAAC;"}
@@ -1,5 +1,5 @@
1
1
  import { GraphFormatError } from "@graphty/graph-format";
2
- import { aw as isNameChar, ax as XML_ILLEGAL_CHAR_CODE, b as plural, $ as agree } from "./export-B-aVCwyG.js";
2
+ import { aw as isNameChar, ax as XML_ILLEGAL_CHAR_CODE, b as plural, $ as agree } from "./export-rKLeGQMo.js";
3
3
  class XmlSyntaxError extends Error {
4
4
  /**
5
5
  * Create the error.
@@ -1310,4 +1310,4 @@ export {
1310
1310
  tokenizeXml as t,
1311
1311
  xmlIllegalTextNotes as x
1312
1312
  };
1313
- //# sourceMappingURL=escape-BJRLd3vJ.js.map
1313
+ //# sourceMappingURL=escape-B62ZGM_a.js.map