@graphty/graph-io 0.3.39 → 0.3.41

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 (213) hide show
  1. package/dist/chunks/{choose-CS3fvGT1.js → choose-CwFQamH9.js} +2 -2
  2. package/dist/chunks/{choose-CS3fvGT1.js.map → choose-CwFQamH9.js.map} +1 -1
  3. package/dist/chunks/{constants-DqKZT6cH.js → constants-Cf4Nn6tw.js} +2 -2
  4. package/dist/chunks/{constants-DqKZT6cH.js.map → constants-Cf4Nn6tw.js.map} +1 -1
  5. package/dist/chunks/{escape-BpYMQZVa.js → escape-DBb8zuNE.js} +4 -3
  6. package/dist/chunks/escape-DBb8zuNE.js.map +1 -0
  7. package/dist/chunks/{export-B-aVCwyG.js → export-DD3Lvw-F.js} +173 -116
  8. package/dist/chunks/export-DD3Lvw-F.js.map +1 -0
  9. package/dist/chunks/{exporter-CNJZF_BN.js → exporter-BqtmlxNr.js} +545 -459
  10. package/dist/chunks/exporter-BqtmlxNr.js.map +1 -0
  11. package/dist/chunks/{exporter-BqKs1Q12.js → exporter-CS35R6Fg.js} +6 -5
  12. package/dist/chunks/exporter-CS35R6Fg.js.map +1 -0
  13. package/dist/chunks/{exporter-DXqCPNrI.js → exporter-D8r1N2dU.js} +67 -42
  14. package/dist/chunks/exporter-D8r1N2dU.js.map +1 -0
  15. package/dist/chunks/{exporter-SFYkDzD0.js → exporter-NMplSnYn.js} +23 -20
  16. package/dist/chunks/{exporter-SFYkDzD0.js.map → exporter-NMplSnYn.js.map} +1 -1
  17. package/dist/chunks/{importer-CSt-gaYE.js → importer-BKC7AmCA.js} +42 -29
  18. package/dist/chunks/importer-BKC7AmCA.js.map +1 -0
  19. package/dist/chunks/{importer-DvFznt5-.js → importer-BdWHmlmG.js} +112 -62
  20. package/dist/chunks/importer-BdWHmlmG.js.map +1 -0
  21. package/dist/chunks/{importer-CqgYq4Ld.js → importer-BfbzWk6k.js} +202 -181
  22. package/dist/chunks/importer-BfbzWk6k.js.map +1 -0
  23. package/dist/chunks/{importer-PVXkeoaS.js → importer-BmaZcskq.js} +79 -66
  24. package/dist/chunks/importer-BmaZcskq.js.map +1 -0
  25. package/dist/chunks/{importer-B7Ir269L.js → importer-DviEsHy4.js} +118 -72
  26. package/dist/chunks/importer-DviEsHy4.js.map +1 -0
  27. package/dist/chunks/{importer--tQQsY4W.js → importer-S-abxJHn.js} +5 -5
  28. package/dist/chunks/{importer--tQQsY4W.js.map → importer-S-abxJHn.js.map} +1 -1
  29. package/dist/chunks/{importer-BfJ1jnNr.js → importer-r29cWnEf.js} +28 -13
  30. package/dist/chunks/importer-r29cWnEf.js.map +1 -0
  31. package/dist/chunks/{json-elements-CXs4z1iL.js → json-elements-DdF-etPT.js} +7 -5
  32. package/dist/chunks/{json-elements-CXs4z1iL.js.map → json-elements-DdF-etPT.js.map} +1 -1
  33. package/dist/chunks/{ontology-export-50L9DOV4.js → ontology-export-BC0zyPhj.js} +2 -2
  34. package/dist/chunks/{ontology-export-50L9DOV4.js.map → ontology-export-BC0zyPhj.js.map} +1 -1
  35. package/dist/chunks/{records-C9jd7yLD.js → records-Uc3LkABx.js} +150 -106
  36. package/dist/chunks/records-Uc3LkABx.js.map +1 -0
  37. package/dist/chunks/{text-Bjfa1xYL.js → text-Bh9SaAob.js} +20 -11
  38. package/dist/chunks/text-Bh9SaAob.js.map +1 -0
  39. package/dist/csv.js +67 -49
  40. package/dist/csv.js.map +1 -1
  41. package/dist/cx.js +1 -1
  42. package/dist/cx2.js +2 -2
  43. package/dist/cys.js +1 -1
  44. package/dist/dot.js +1 -1
  45. package/dist/gexf.js +199 -99
  46. package/dist/gexf.js.map +1 -1
  47. package/dist/gml.js +170 -149
  48. package/dist/gml.js.map +1 -1
  49. package/dist/graph-io.js +26 -26
  50. package/dist/graphml.js +2 -2
  51. package/dist/json.js +1 -1
  52. package/dist/neo4j.js +103 -65
  53. package/dist/neo4j.js.map +1 -1
  54. package/dist/obo.js +1 -1
  55. package/dist/pajek.js +1 -1
  56. package/dist/src/common/attributes.d.ts.map +1 -1
  57. package/dist/src/common/attributes.js +34 -9
  58. package/dist/src/common/attributes.js.map +1 -1
  59. package/dist/src/common/input.d.ts.map +1 -1
  60. package/dist/src/common/input.js +180 -102
  61. package/dist/src/common/input.js.map +1 -1
  62. package/dist/src/common/json-elements.d.ts.map +1 -1
  63. package/dist/src/common/json-elements.js +4 -2
  64. package/dist/src/common/json-elements.js.map +1 -1
  65. package/dist/src/common/text.d.ts +7 -0
  66. package/dist/src/common/text.d.ts.map +1 -1
  67. package/dist/src/common/text.js +15 -7
  68. package/dist/src/common/text.js.map +1 -1
  69. package/dist/src/common/xml.d.ts.map +1 -1
  70. package/dist/src/common/xml.js +2 -1
  71. package/dist/src/common/xml.js.map +1 -1
  72. package/dist/src/common/zip.d.ts.map +1 -1
  73. package/dist/src/common/zip.js +36 -19
  74. package/dist/src/common/zip.js.map +1 -1
  75. package/dist/src/formats/csv/exporter.d.ts.map +1 -1
  76. package/dist/src/formats/csv/exporter.js +77 -25
  77. package/dist/src/formats/csv/exporter.js.map +1 -1
  78. package/dist/src/formats/csv/importer.d.ts.map +1 -1
  79. package/dist/src/formats/csv/importer.js +16 -6
  80. package/dist/src/formats/csv/importer.js.map +1 -1
  81. package/dist/src/formats/csv/records.d.ts.map +1 -1
  82. package/dist/src/formats/csv/records.js +156 -110
  83. package/dist/src/formats/csv/records.js.map +1 -1
  84. package/dist/src/formats/cx/importer.d.ts.map +1 -1
  85. package/dist/src/formats/cx/importer.js +108 -53
  86. package/dist/src/formats/cx/importer.js.map +1 -1
  87. package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
  88. package/dist/src/formats/cx2/exporter.js +2 -1
  89. package/dist/src/formats/cx2/exporter.js.map +1 -1
  90. package/dist/src/formats/cx2/importer.d.ts.map +1 -1
  91. package/dist/src/formats/cx2/importer.js +28 -6
  92. package/dist/src/formats/cx2/importer.js.map +1 -1
  93. package/dist/src/formats/cys/tables.d.ts.map +1 -1
  94. package/dist/src/formats/cys/tables.js +11 -8
  95. package/dist/src/formats/cys/tables.js.map +1 -1
  96. package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
  97. package/dist/src/formats/gexf/exporter.js +69 -39
  98. package/dist/src/formats/gexf/exporter.js.map +1 -1
  99. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  100. package/dist/src/formats/gexf/importer.js +138 -50
  101. package/dist/src/formats/gexf/importer.js.map +1 -1
  102. package/dist/src/formats/gml/exporter.d.ts.map +1 -1
  103. package/dist/src/formats/gml/exporter.js +51 -35
  104. package/dist/src/formats/gml/exporter.js.map +1 -1
  105. package/dist/src/formats/gml/importer.d.ts.map +1 -1
  106. package/dist/src/formats/gml/importer.js +103 -58
  107. package/dist/src/formats/gml/importer.js.map +1 -1
  108. package/dist/src/formats/gml/syntax.d.ts.map +1 -1
  109. package/dist/src/formats/gml/syntax.js +17 -8
  110. package/dist/src/formats/gml/syntax.js.map +1 -1
  111. package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
  112. package/dist/src/formats/graphml/exporter.js +36 -25
  113. package/dist/src/formats/graphml/exporter.js.map +1 -1
  114. package/dist/src/formats/graphml/importer.d.ts.map +1 -1
  115. package/dist/src/formats/graphml/importer.js +20 -15
  116. package/dist/src/formats/graphml/importer.js.map +1 -1
  117. package/dist/src/formats/graphml/tree.js +23 -14
  118. package/dist/src/formats/graphml/tree.js.map +1 -1
  119. package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
  120. package/dist/src/formats/graphml/yfiles.js +22 -10
  121. package/dist/src/formats/graphml/yfiles.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 +13 -0
  152. package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
  153. package/dist/src/formats/xgmml/emit.js +112 -50
  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 +92 -34
  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/common/attributes.ts +59 -19
  166. package/src/common/input.ts +216 -102
  167. package/src/common/json-elements.ts +4 -2
  168. package/src/common/text.ts +24 -15
  169. package/src/common/xml.ts +2 -1
  170. package/src/common/zip.ts +47 -18
  171. package/src/formats/csv/exporter.ts +103 -39
  172. package/src/formats/csv/importer.ts +17 -6
  173. package/src/formats/csv/records.ts +162 -109
  174. package/src/formats/cx/importer.ts +140 -58
  175. package/src/formats/cx2/exporter.ts +2 -1
  176. package/src/formats/cx2/importer.ts +34 -10
  177. package/src/formats/cys/tables.ts +11 -10
  178. package/src/formats/gexf/exporter.ts +71 -38
  179. package/src/formats/gexf/importer.ts +173 -63
  180. package/src/formats/gml/exporter.ts +78 -82
  181. package/src/formats/gml/importer.ts +119 -68
  182. package/src/formats/gml/syntax.ts +18 -8
  183. package/src/formats/graphml/exporter.ts +46 -27
  184. package/src/formats/graphml/importer.ts +21 -13
  185. package/src/formats/graphml/tree.ts +22 -12
  186. package/src/formats/graphml/yfiles.ts +23 -10
  187. package/src/formats/json/exporter.ts +40 -21
  188. package/src/formats/json/importer.ts +701 -385
  189. package/src/formats/json/obographs.ts +35 -15
  190. package/src/formats/neo4j/exporter.ts +79 -41
  191. package/src/formats/neo4j/header.ts +50 -16
  192. package/src/formats/neo4j/importer.ts +21 -10
  193. package/src/formats/obo/exporter.ts +34 -17
  194. package/src/formats/pajek/exporter.ts +180 -117
  195. package/src/formats/pajek/importer.ts +27 -15
  196. package/src/formats/pajek/syntax.ts +99 -58
  197. package/src/formats/xgmml/emit.ts +122 -50
  198. package/src/formats/xgmml/exporter.ts +103 -35
  199. package/src/formats/xgmml/importer.ts +45 -23
  200. package/src/sniff.ts +115 -59
  201. package/dist/chunks/escape-BpYMQZVa.js.map +0 -1
  202. package/dist/chunks/export-B-aVCwyG.js.map +0 -1
  203. package/dist/chunks/exporter-BqKs1Q12.js.map +0 -1
  204. package/dist/chunks/exporter-CNJZF_BN.js.map +0 -1
  205. package/dist/chunks/exporter-DXqCPNrI.js.map +0 -1
  206. package/dist/chunks/importer-B7Ir269L.js.map +0 -1
  207. package/dist/chunks/importer-BfJ1jnNr.js.map +0 -1
  208. package/dist/chunks/importer-CSt-gaYE.js.map +0 -1
  209. package/dist/chunks/importer-CqgYq4Ld.js.map +0 -1
  210. package/dist/chunks/importer-DvFznt5-.js.map +0 -1
  211. package/dist/chunks/importer-PVXkeoaS.js.map +0 -1
  212. package/dist/chunks/records-C9jd7yLD.js.map +0 -1
  213. package/dist/chunks/text-Bjfa1xYL.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { INVALID_INDEX, GraphFormatError } from "@graphty/graph-format";
2
- import { M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, O as OPTION_IGNORED_CODE, I as ID_MERGED_CODE, R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, ae as AMBIGUOUS_GRAPH_NAME_CODE, af as GRAPH_NOT_FOUND_CODE, l as MULTIPLE_GRAPHS_CODE, f as STRAY_TEXT_CODE, g as UNKNOWN_ELEMENT_CODE, U as UNKNOWN_ATTR_TYPE_CODE, b6 as EQUATION_AS_TEXT_CODE, ai as PARENT_CYCLE_CODE, q as UNKNOWN_PARENT_CODE, o as DUPLICATE_ATTRIBUTE_CODE, i as DANGLING_REFERENCE_CODE, P as PRECISION_CODE, aj as WIDENED_CODE, a3 as BAD_VALUE_CODE, m as DUPLICATE_EDGE_ID_CODE, n as DUPLICATE_NODE_CODE, s as MISSING_ENDPOINT_CODE, t as MISSING_ID_CODE, N as NO_GRAPH_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, E as EMPTY_INPUT_CODE, X as XML_SYNTAX_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, bj as STORAGE_CLASS_CODE, bp as WEIGHT_KEY_CLASH_CODE, au as ROLE_ASSUMED_CODE, a$ as COLUMN_RENAMED_LOSS_CODE, J as ID_TEXT_TYPE_CODE, bc as MUTUAL_EXPANDED_CODE, Q as PARENTS_DROPPED_CODE, K as ROLE_DROPPED_CODE, bl as TEMPORAL_TEXT_DROPPED_CODE, bk as TEMPORAL_DROPPED_CODE, ax as XML_ILLEGAL_CHAR_CODE, a0 as uniqueColumnName, a1 as declareResolved, ac as DictHeuristic, ar as IdCoercer, aq as DirectionResolver, b as plural, $ as agree, am as throwIfAborted, aK as parseWeightText, ao as reportSinkOptions, an as reportUnusedOptions, a7 as chooseGraph, ap as graphChosen, al as resolveImportOptions, a8 as ImportReportBuilder, a4 as textChunks, c0 as elementCount } from "./export-B-aVCwyG.js";
3
- import { l as localName, a as escapeXmlText, j as isWhitespace, e as escapeXmlAttribute, t as tokenizeXml, f as xmlDeclaredEncoding, X as XmlSyntaxError } from "./escape-BpYMQZVa.js";
4
- import { p as parseTextCell, i as inferTextDtype } from "./text-Bjfa1xYL.js";
2
+ import { M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, O as OPTION_IGNORED_CODE, I as ID_MERGED_CODE, R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, ae as AMBIGUOUS_GRAPH_NAME_CODE, af as GRAPH_NOT_FOUND_CODE, l as MULTIPLE_GRAPHS_CODE, f as STRAY_TEXT_CODE, g as UNKNOWN_ELEMENT_CODE, U as UNKNOWN_ATTR_TYPE_CODE, b6 as EQUATION_AS_TEXT_CODE, ai as PARENT_CYCLE_CODE, q as UNKNOWN_PARENT_CODE, o as DUPLICATE_ATTRIBUTE_CODE, i as DANGLING_REFERENCE_CODE, P as PRECISION_CODE, aj as WIDENED_CODE, a3 as BAD_VALUE_CODE, m as DUPLICATE_EDGE_ID_CODE, n as DUPLICATE_NODE_CODE, s as MISSING_ENDPOINT_CODE, t as MISSING_ID_CODE, N as NO_GRAPH_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, E as EMPTY_INPUT_CODE, X as XML_SYNTAX_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, bj as STORAGE_CLASS_CODE, bp as WEIGHT_KEY_CLASH_CODE, au as ROLE_ASSUMED_CODE, a$ as COLUMN_RENAMED_LOSS_CODE, J as ID_TEXT_TYPE_CODE, bc as MUTUAL_EXPANDED_CODE, Q as PARENTS_DROPPED_CODE, K as ROLE_DROPPED_CODE, bl as TEMPORAL_TEXT_DROPPED_CODE, bk as TEMPORAL_DROPPED_CODE, ax as XML_ILLEGAL_CHAR_CODE, a0 as uniqueColumnName, a1 as declareResolved, ac as DictHeuristic, ar as IdCoercer, aq as DirectionResolver, b as plural, $ as agree, am as throwIfAborted, aK as parseWeightText, ao as reportSinkOptions, an as reportUnusedOptions, a7 as chooseGraph, ap as graphChosen, al as resolveImportOptions, a8 as ImportReportBuilder, a4 as textChunks, c0 as elementCount } from "./export-DD3Lvw-F.js";
3
+ import { l as localName, a as escapeXmlText, j as isWhitespace, e as escapeXmlAttribute, t as tokenizeXml, f as xmlDeclaredEncoding, X as XmlSyntaxError } from "./escape-DBb8zuNE.js";
4
+ import { p as parseTextCell, i as inferTextDtype } from "./text-Bh9SaAob.js";
5
5
  const FORMAT = "xgmml";
6
6
  const EXTENSIONS = Object.freeze([".xgmml", ".xml"]);
7
7
  const MIME_TYPES = Object.freeze(["application/xgmml", "text/xgmml", "text/xgmml+xml"]);
@@ -1747,6 +1747,9 @@ function parseCoordinate(text) {
1747
1747
  function localRef(href) {
1748
1748
  return href.startsWith("#") ? href.slice(1) : null;
1749
1749
  }
1750
+ function memberRef(id, href) {
1751
+ return id ?? (href === null ? null : localRef(href));
1752
+ }
1750
1753
  function membersOf(doc, graph) {
1751
1754
  if (graph === null) {
1752
1755
  return { nodes: doc.nodes, edges: doc.edges, dangling: 0 };
@@ -1757,19 +1760,7 @@ function membersOf(doc, graph) {
1757
1760
  const edges = [];
1758
1761
  let dangling = 0;
1759
1762
  for (const member of graph.members) {
1760
- if (member.href === null) {
1761
- if (member.kind === "node") {
1762
- nodes.push(member);
1763
- } else {
1764
- edges.push(member);
1765
- }
1766
- continue;
1767
- }
1768
- const id = localRef(member.href);
1769
- let target;
1770
- if (id !== null) {
1771
- target = member.kind === "node" ? nodeById.get(id) : edgeById.get(id);
1772
- }
1763
+ const target = resolveMember(member, nodeById, edgeById);
1773
1764
  if (target === void 0) {
1774
1765
  dangling++;
1775
1766
  } else if (target.kind === "node") {
@@ -1780,6 +1771,16 @@ function membersOf(doc, graph) {
1780
1771
  }
1781
1772
  return { nodes, edges, dangling };
1782
1773
  }
1774
+ function resolveMember(member, nodeById, edgeById) {
1775
+ if (member.href === null) {
1776
+ return member;
1777
+ }
1778
+ const id = localRef(member.href);
1779
+ if (id === null) {
1780
+ return void 0;
1781
+ }
1782
+ return member.kind === "node" ? nodeById.get(id) : edgeById.get(id);
1783
+ }
1783
1784
  function indexById(records) {
1784
1785
  const out = /* @__PURE__ */ new Map();
1785
1786
  for (const record of records) {
@@ -1789,6 +1790,26 @@ function indexById(records) {
1789
1790
  }
1790
1791
  return out;
1791
1792
  }
1793
+ function isRepeat(seen, record) {
1794
+ if (seen === null) {
1795
+ return false;
1796
+ }
1797
+ const key2 = record.id ?? (record.label === null ? null : JSON.stringify([record.label, record.source, record.target]));
1798
+ if (key2 === null) {
1799
+ return false;
1800
+ }
1801
+ if (seen.has(key2)) {
1802
+ return true;
1803
+ }
1804
+ seen.add(key2);
1805
+ return false;
1806
+ }
1807
+ function isGraphValueAtt(att) {
1808
+ if (att.name !== null && META_ATTS.has(att.name)) {
1809
+ return false;
1810
+ }
1811
+ return !(att.hasGraph && att.name === null);
1812
+ }
1792
1813
  class XgmmlEmitter {
1793
1814
  /**
1794
1815
  * Create an emitter for one graph.
@@ -2036,10 +2057,16 @@ class XgmmlEmitter {
2036
2057
  }
2037
2058
  const lower = t.toLowerCase();
2038
2059
  const readable = lower === "true" || lower === "yes" || lower === "false" || lower === "no";
2060
+ let readAs;
2061
+ if (readable) {
2062
+ readAs = lower === "true" || lower === "yes" ? "1" : "0";
2063
+ } else {
2064
+ readAs = fallback ? "directed" : "undirected";
2065
+ }
2039
2066
  this.report.warnOnce(
2040
2067
  "validation-error",
2041
2068
  XGMML_ISSUE.BAD_DIRECTED,
2042
- readable ? `${this.prefix()}directed="${text}" is not 0 or 1; read as ${lower === "true" || lower === "yes" ? "1" : "0"}` : `${this.prefix()}directed="${text}" is not 0 or 1; read as ${fallback ? "directed" : "undirected"}`,
2069
+ `${this.prefix()}directed="${text}" is not 0 or 1; read as ${readAs}`,
2043
2070
  where,
2044
2071
  `${XGMML_ISSUE.BAD_DIRECTED}:${text}`
2045
2072
  );
@@ -2156,16 +2183,7 @@ class XgmmlEmitter {
2156
2183
  if (graph.owner !== null && isGroup(graph.owner)) {
2157
2184
  continue;
2158
2185
  }
2159
- for (const member of graph.members) {
2160
- if (member.href === null) {
2161
- continue;
2162
- }
2163
- const id = localRef(member.href);
2164
- const known = id !== null && (member.kind === "node" ? this.rows.has(id) : edgeIds.has(id));
2165
- if (!known) {
2166
- dangling++;
2167
- }
2168
- }
2186
+ dangling += this.danglingReferences(graph, edgeIds);
2169
2187
  }
2170
2188
  if (dangling > 0) {
2171
2189
  this.report.warning(
@@ -2175,6 +2193,26 @@ class XgmmlEmitter {
2175
2193
  );
2176
2194
  }
2177
2195
  }
2196
+ /**
2197
+ * How many `xlink:href` members of a graph name no node or edge of the document.
2198
+ * @param graph - the graph
2199
+ * @param edgeIds - the id of every edge
2200
+ * @returns the count
2201
+ */
2202
+ danglingReferences(graph, edgeIds) {
2203
+ let dangling = 0;
2204
+ for (const member of graph.members) {
2205
+ if (member.href === null) {
2206
+ continue;
2207
+ }
2208
+ const id = localRef(member.href);
2209
+ const known = id !== null && (member.kind === "node" ? this.rows.has(id) : edgeIds.has(id));
2210
+ if (!known) {
2211
+ dangling++;
2212
+ }
2213
+ }
2214
+ return dangling;
2215
+ }
2178
2216
  /**
2179
2217
  * Write the per-node values: label, attributes, XML attributes, graphics, positions, nested
2180
2218
  * network pointers and subgraph memberships.
@@ -2305,17 +2343,17 @@ class XgmmlEmitter {
2305
2343
  }
2306
2344
  });
2307
2345
  }
2308
- /** The `xgmml.networks` membership of nodes in root-level subgraphs of a generic document. */
2309
- writeNetworks() {
2310
- const { subgraphs } = this.doc.root;
2311
- if (subgraphs.length === 0) {
2312
- return;
2313
- }
2346
+ /**
2347
+ * The names of the subgraphs each node row is a member of.
2348
+ * @param subgraphs - the root-level subgraphs
2349
+ * @returns the subgraph names by node row index
2350
+ */
2351
+ networkMembership(subgraphs) {
2314
2352
  const member = /* @__PURE__ */ new Map();
2315
2353
  for (const graph of subgraphs) {
2316
2354
  const name = graph.id ?? graph.label ?? "";
2317
2355
  for (const m of graph.members) {
2318
- const id = m.kind === "node" ? m.id ?? (m.href === null ? null : localRef(m.href)) : null;
2356
+ const id = m.kind === "node" ? memberRef(m.id, m.href) : null;
2319
2357
  const row = id === null ? void 0 : this.rows.get(id);
2320
2358
  if (row !== void 0 && row.index >= 0) {
2321
2359
  const list = member.get(row.index) ?? [];
@@ -2324,6 +2362,15 @@ class XgmmlEmitter {
2324
2362
  }
2325
2363
  }
2326
2364
  }
2365
+ return member;
2366
+ }
2367
+ /** The `xgmml.networks` membership of nodes in root-level subgraphs of a generic document. */
2368
+ writeNetworks() {
2369
+ const { subgraphs } = this.doc.root;
2370
+ if (subgraphs.length === 0) {
2371
+ return;
2372
+ }
2373
+ const member = this.networkMembership(subgraphs);
2327
2374
  if (member.size === 0) {
2328
2375
  return;
2329
2376
  }
@@ -2358,14 +2405,10 @@ class XgmmlEmitter {
2358
2405
  this.decideNameLabel("edge", records);
2359
2406
  for (const record of records) {
2360
2407
  const where = { line: record.line, element: record.id ?? record.label };
2361
- const key2 = record.id ?? (record.label === null ? null : JSON.stringify([record.label, record.source, record.target]));
2362
- if (dedupe !== null && key2 !== null) {
2363
- if (dedupe.has(key2)) {
2364
- repeats++;
2365
- firstRepeat ??= where;
2366
- continue;
2367
- }
2368
- dedupe.add(key2);
2408
+ if (isRepeat(dedupe, record)) {
2409
+ repeats++;
2410
+ firstRepeat ??= where;
2411
+ continue;
2369
2412
  }
2370
2413
  const index = this.addEdge(record, header, ids, where);
2371
2414
  this.checkAbort();
@@ -2614,13 +2657,9 @@ class XgmmlEmitter {
2614
2657
  }
2615
2658
  }
2616
2659
  for (const att of g.atts) {
2617
- if (att.name !== null && META_ATTS.has(att.name)) {
2618
- continue;
2619
- }
2620
- if (att.hasGraph && att.name === null) {
2621
- continue;
2660
+ if (isGraphValueAtt(att)) {
2661
+ this.graphColumns.addAtt(0, att, where);
2622
2662
  }
2623
- this.graphColumns.addAtt(0, att, where);
2624
2663
  }
2625
2664
  this.graphColumns.write(this.sink, () => 0);
2626
2665
  const json = { ...this.extras.graphJson };
@@ -3089,19 +3128,7 @@ function booleanOption(name, value, fallback) {
3089
3128
  return value;
3090
3129
  }
3091
3130
  async function parseXgmml(input, report, common, options) {
3092
- const repairs = {
3093
- bareAmpersand: booleanOption("repairBareAmpersands", options?.repairBareAmpersands, false) ? (line) => {
3094
- report.warning("parse-error", XGMML_ISSUE.AMPERSAND_REPAIRED, "a bare & was read as &", { line });
3095
- } : void 0,
3096
- surrogatePair: booleanOption("pairSurrogateReferences", options?.pairSurrogateReferences, false) ? (line) => {
3097
- report.warning(
3098
- "parse-error",
3099
- XGMML_ISSUE.SURROGATE_PAIRED,
3100
- "two surrogate character references were joined into one character",
3101
- { line }
3102
- );
3103
- } : void 0
3104
- };
3131
+ const repairs = repairsOf(options, report);
3105
3132
  const parser = new XgmmlParser(report);
3106
3133
  const seen = { content: false };
3107
3134
  try {
@@ -3111,12 +3138,7 @@ async function parseXgmml(input, report, common, options) {
3111
3138
  repairs
3112
3139
  );
3113
3140
  } catch (err) {
3114
- if (err instanceof XmlSyntaxError) {
3115
- if (!seen.content) {
3116
- report.fail(XGMML_ISSUE.EMPTY_INPUT, "the input is empty");
3117
- }
3118
- report.fail(XGMML_ISSUE.XML_SYNTAX, err.message, { line: err.line });
3119
- }
3141
+ failOnSyntax(err, seen.content, report);
3120
3142
  throw err;
3121
3143
  }
3122
3144
  const doc = parser.document();
@@ -3130,6 +3152,30 @@ async function parseXgmml(input, report, common, options) {
3130
3152
  }
3131
3153
  return doc;
3132
3154
  }
3155
+ function repairsOf(options, report) {
3156
+ return {
3157
+ bareAmpersand: booleanOption("repairBareAmpersands", options?.repairBareAmpersands, false) ? (line) => {
3158
+ report.warning("parse-error", XGMML_ISSUE.AMPERSAND_REPAIRED, "a bare & was read as &", { line });
3159
+ } : void 0,
3160
+ surrogatePair: booleanOption("pairSurrogateReferences", options?.pairSurrogateReferences, false) ? (line) => {
3161
+ report.warning(
3162
+ "parse-error",
3163
+ XGMML_ISSUE.SURROGATE_PAIRED,
3164
+ "two surrogate character references were joined into one character",
3165
+ { line }
3166
+ );
3167
+ } : void 0
3168
+ };
3169
+ }
3170
+ function failOnSyntax(err, content, report) {
3171
+ if (!(err instanceof XmlSyntaxError)) {
3172
+ return;
3173
+ }
3174
+ if (!content) {
3175
+ report.fail(XGMML_ISSUE.EMPTY_INPUT, "the input is empty");
3176
+ }
3177
+ report.fail(XGMML_ISSUE.XML_SYNTAX, err.message, { line: err.line });
3178
+ }
3133
3179
  async function* watch(chunks, seen) {
3134
3180
  for await (const chunk of chunks) {
3135
3181
  seen.content ||= !isWhitespace(chunk);
@@ -3290,10 +3336,10 @@ export {
3290
3336
  XLINK_NAMESPACE as b,
3291
3337
  XGMML_NAMESPACE as c,
3292
3338
  aliasesOf as d,
3293
- NETWORK_POINTER_COLUMN as e,
3294
- NETWORKS_COLUMN as f,
3295
- PARENT_COLUMN as g,
3296
- PARENTS_COLUMN as h,
3339
+ PARENT_COLUMN as e,
3340
+ PARENTS_COLUMN as f,
3341
+ NETWORK_POINTER_COLUMN as g,
3342
+ NETWORKS_COLUMN as h,
3297
3343
  XGMML_ORIGIN_NAMESPACE as i,
3298
3344
  CYTOSCAPE_ORIGIN_NAMESPACE as j,
3299
3345
  XgmmlEmitter as k,
@@ -3305,4 +3351,4 @@ export {
3305
3351
  resolveSettings as r,
3306
3352
  xgmmlImporter as x
3307
3353
  };
3308
- //# sourceMappingURL=importer-B7Ir269L.js.map
3354
+ //# sourceMappingURL=importer-DviEsHy4.js.map