@graphty/graph-io 0.3.25 → 0.3.26

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 (581) hide show
  1. package/README.md +49 -414
  2. package/dist/chunks/children-CL3Cy0ez.js.map +1 -1
  3. package/dist/chunks/choose-BbJI55dx.js +56 -0
  4. package/dist/chunks/choose-BbJI55dx.js.map +1 -0
  5. package/dist/chunks/constants-BCsFsMj4.js +231 -0
  6. package/dist/chunks/constants-BCsFsMj4.js.map +1 -0
  7. package/dist/chunks/{escape-B-tkk_Cl.js → escape-D0g6NNUy.js} +382 -92
  8. package/dist/chunks/escape-D0g6NNUy.js.map +1 -0
  9. package/dist/chunks/export-BTI4yQgy.js +4333 -0
  10. package/dist/chunks/export-BTI4yQgy.js.map +1 -0
  11. package/dist/chunks/exporter-BMqk5oxW.js +3465 -0
  12. package/dist/chunks/exporter-BMqk5oxW.js.map +1 -0
  13. package/dist/chunks/{importer-eUREhBGj.js → exporter-Cra2GYcN.js} +4969 -3201
  14. package/dist/chunks/exporter-Cra2GYcN.js.map +1 -0
  15. package/dist/chunks/{exporter-BGrsWamJ.js → exporter-Dxh231ZF.js} +38 -229
  16. package/dist/chunks/exporter-Dxh231ZF.js.map +1 -0
  17. package/dist/chunks/{exporter-DIeGJXAZ.js → exporter-tne475KK.js} +22 -20
  18. package/dist/chunks/exporter-tne475KK.js.map +1 -0
  19. package/dist/chunks/importer-90YWhJoF.js +2811 -0
  20. package/dist/chunks/importer-90YWhJoF.js.map +1 -0
  21. package/dist/chunks/{importer-D_e7e7LX.js → importer-Bcl1d4xH.js} +398 -145
  22. package/dist/chunks/importer-Bcl1d4xH.js.map +1 -0
  23. package/dist/chunks/{importer-BWY2FFc5.js → importer-BfIsp1f9.js} +255 -77
  24. package/dist/chunks/importer-BfIsp1f9.js.map +1 -0
  25. package/dist/chunks/{importer-zGLo8Dg_.js → importer-C_TEA1zJ.js} +484 -157
  26. package/dist/chunks/importer-C_TEA1zJ.js.map +1 -0
  27. package/dist/chunks/{importer-DET1tg6s.js → importer-DCjOvO7U.js} +1687 -310
  28. package/dist/chunks/importer-DCjOvO7U.js.map +1 -0
  29. package/dist/chunks/{importer-vi3bSdtw.js → importer-DfVu6j59.js} +509 -76
  30. package/dist/chunks/importer-DfVu6j59.js.map +1 -0
  31. package/dist/chunks/{importer-DIrbbnAf.js → importer-Dku_VAIY.js} +585 -226
  32. package/dist/chunks/importer-Dku_VAIY.js.map +1 -0
  33. package/dist/chunks/json-elements-3tnyt5uZ.js +1225 -0
  34. package/dist/chunks/json-elements-3tnyt5uZ.js.map +1 -0
  35. package/dist/chunks/ontology-export-B9Tcf37D.js +357 -0
  36. package/dist/chunks/ontology-export-B9Tcf37D.js.map +1 -0
  37. package/dist/chunks/{records-dbRkxwaq.js → records-CQXT__mY.js} +298 -114
  38. package/dist/chunks/records-CQXT__mY.js.map +1 -0
  39. package/dist/chunks/{text-Dr0Ifpag.js → text-DmcUs5_Q.js} +29 -11
  40. package/dist/chunks/text-DmcUs5_Q.js.map +1 -0
  41. package/dist/chunks/{writer-C7flM-Ih.js → writer-DxjgHwSe.js} +19 -1
  42. package/dist/chunks/writer-DxjgHwSe.js.map +1 -0
  43. package/dist/csv.js +951 -261
  44. package/dist/csv.js.map +1 -1
  45. package/dist/cx.js +6 -3
  46. package/dist/cx2.js +2 -2
  47. package/dist/cys.js +6 -3
  48. package/dist/dot.js +1 -1
  49. package/dist/gexf.js +554 -122
  50. package/dist/gexf.js.map +1 -1
  51. package/dist/gml.js +342 -85
  52. package/dist/gml.js.map +1 -1
  53. package/dist/graph-io.js +1105 -213
  54. package/dist/graph-io.js.map +1 -1
  55. package/dist/graphml.js +3 -2
  56. package/dist/graphml.js.map +1 -1
  57. package/dist/json.js +3 -2
  58. package/dist/neo4j.js +564 -157
  59. package/dist/neo4j.js.map +1 -1
  60. package/dist/obo.js +6 -3
  61. package/dist/pajek.js +1 -1
  62. package/dist/src/children.d.ts +18 -6
  63. package/dist/src/children.d.ts.map +1 -1
  64. package/dist/src/children.js +6 -3
  65. package/dist/src/children.js.map +1 -1
  66. package/dist/src/common/attributes.d.ts +29 -11
  67. package/dist/src/common/attributes.d.ts.map +1 -1
  68. package/dist/src/common/attributes.js +25 -7
  69. package/dist/src/common/attributes.js.map +1 -1
  70. package/dist/src/common/cell-budget.d.ts +9 -2
  71. package/dist/src/common/cell-budget.d.ts.map +1 -1
  72. package/dist/src/common/cell-budget.js +11 -3
  73. package/dist/src/common/cell-budget.js.map +1 -1
  74. package/dist/src/common/choose.d.ts +19 -0
  75. package/dist/src/common/choose.d.ts.map +1 -0
  76. package/dist/src/common/choose.js +72 -0
  77. package/dist/src/common/choose.js.map +1 -0
  78. package/dist/src/common/codes.d.ts +456 -66
  79. package/dist/src/common/codes.d.ts.map +1 -1
  80. package/dist/src/common/codes.js +458 -66
  81. package/dist/src/common/codes.js.map +1 -1
  82. package/dist/src/common/compare.d.ts +81 -0
  83. package/dist/src/common/compare.d.ts.map +1 -0
  84. package/dist/src/common/compare.js +394 -0
  85. package/dist/src/common/compare.js.map +1 -0
  86. package/dist/src/common/cx-export.d.ts +123 -0
  87. package/dist/src/common/cx-export.d.ts.map +1 -0
  88. package/dist/src/common/cx-export.js +334 -0
  89. package/dist/src/common/cx-export.js.map +1 -0
  90. package/dist/src/common/declared-types.d.ts +22 -2
  91. package/dist/src/common/declared-types.d.ts.map +1 -1
  92. package/dist/src/common/declared-types.js +19 -1
  93. package/dist/src/common/declared-types.js.map +1 -1
  94. package/dist/src/common/direction.d.ts +74 -50
  95. package/dist/src/common/direction.d.ts.map +1 -1
  96. package/dist/src/common/direction.js +47 -27
  97. package/dist/src/common/direction.js.map +1 -1
  98. package/dist/src/common/escape.d.ts +21 -9
  99. package/dist/src/common/escape.d.ts.map +1 -1
  100. package/dist/src/common/escape.js +33 -17
  101. package/dist/src/common/escape.js.map +1 -1
  102. package/dist/src/common/export.d.ts +144 -32
  103. package/dist/src/common/export.d.ts.map +1 -1
  104. package/dist/src/common/export.js +216 -42
  105. package/dist/src/common/export.js.map +1 -1
  106. package/dist/src/common/format.d.ts +23 -1
  107. package/dist/src/common/format.d.ts.map +1 -1
  108. package/dist/src/common/format.js +26 -1
  109. package/dist/src/common/format.js.map +1 -1
  110. package/dist/src/common/ids.d.ts +9 -2
  111. package/dist/src/common/ids.d.ts.map +1 -1
  112. package/dist/src/common/ids.js +6 -2
  113. package/dist/src/common/ids.js.map +1 -1
  114. package/dist/src/common/input.d.ts +122 -28
  115. package/dist/src/common/input.d.ts.map +1 -1
  116. package/dist/src/common/input.js +890 -124
  117. package/dist/src/common/input.js.map +1 -1
  118. package/dist/src/common/json-elements.d.ts +144 -20
  119. package/dist/src/common/json-elements.d.ts.map +1 -1
  120. package/dist/src/common/json-elements.js +868 -188
  121. package/dist/src/common/json-elements.js.map +1 -1
  122. package/dist/src/common/line-format.d.ts +90 -0
  123. package/dist/src/common/line-format.d.ts.map +1 -0
  124. package/dist/src/common/line-format.js +185 -0
  125. package/dist/src/common/line-format.js.map +1 -0
  126. package/dist/src/common/lists.d.ts +6 -1
  127. package/dist/src/common/lists.d.ts.map +1 -1
  128. package/dist/src/common/lists.js +2 -0
  129. package/dist/src/common/lists.js.map +1 -1
  130. package/dist/src/common/ontology-export.d.ts +167 -0
  131. package/dist/src/common/ontology-export.d.ts.map +1 -0
  132. package/dist/src/common/ontology-export.js +359 -0
  133. package/dist/src/common/ontology-export.js.map +1 -0
  134. package/dist/src/common/ontology.d.ts +25 -3
  135. package/dist/src/common/ontology.d.ts.map +1 -1
  136. package/dist/src/common/ontology.js +30 -9
  137. package/dist/src/common/ontology.js.map +1 -1
  138. package/dist/src/common/options.d.ts +62 -12
  139. package/dist/src/common/options.d.ts.map +1 -1
  140. package/dist/src/common/options.js +89 -11
  141. package/dist/src/common/options.js.map +1 -1
  142. package/dist/src/common/plural.d.ts +31 -0
  143. package/dist/src/common/plural.d.ts.map +1 -0
  144. package/dist/src/common/plural.js +46 -0
  145. package/dist/src/common/plural.js.map +1 -0
  146. package/dist/src/common/report.d.ts +72 -14
  147. package/dist/src/common/report.d.ts.map +1 -1
  148. package/dist/src/common/report.js +146 -22
  149. package/dist/src/common/report.js.map +1 -1
  150. package/dist/src/common/temporal.d.ts +22 -5
  151. package/dist/src/common/temporal.d.ts.map +1 -1
  152. package/dist/src/common/temporal.js +13 -2
  153. package/dist/src/common/temporal.js.map +1 -1
  154. package/dist/src/common/text.d.ts +39 -23
  155. package/dist/src/common/text.d.ts.map +1 -1
  156. package/dist/src/common/text.js +51 -21
  157. package/dist/src/common/text.js.map +1 -1
  158. package/dist/src/common/weights.d.ts +37 -4
  159. package/dist/src/common/weights.d.ts.map +1 -1
  160. package/dist/src/common/weights.js +61 -2
  161. package/dist/src/common/weights.js.map +1 -1
  162. package/dist/src/common/writer.d.ts +19 -3
  163. package/dist/src/common/writer.d.ts.map +1 -1
  164. package/dist/src/common/writer.js +30 -2
  165. package/dist/src/common/writer.js.map +1 -1
  166. package/dist/src/common/xml.d.ts +125 -9
  167. package/dist/src/common/xml.d.ts.map +1 -1
  168. package/dist/src/common/xml.js +400 -83
  169. package/dist/src/common/xml.js.map +1 -1
  170. package/dist/src/common/zip.d.ts +44 -4
  171. package/dist/src/common/zip.d.ts.map +1 -1
  172. package/dist/src/common/zip.js +134 -5
  173. package/dist/src/common/zip.js.map +1 -1
  174. package/dist/src/formats/csv/exporter.d.ts +80 -24
  175. package/dist/src/formats/csv/exporter.d.ts.map +1 -1
  176. package/dist/src/formats/csv/exporter.js +145 -32
  177. package/dist/src/formats/csv/exporter.js.map +1 -1
  178. package/dist/src/formats/csv/header.d.ts +38 -9
  179. package/dist/src/formats/csv/header.d.ts.map +1 -1
  180. package/dist/src/formats/csv/header.js +46 -10
  181. package/dist/src/formats/csv/header.js.map +1 -1
  182. package/dist/src/formats/csv/importer.d.ts +187 -37
  183. package/dist/src/formats/csv/importer.d.ts.map +1 -1
  184. package/dist/src/formats/csv/importer.js +835 -204
  185. package/dist/src/formats/csv/importer.js.map +1 -1
  186. package/dist/src/formats/csv/index.d.ts +100 -19
  187. package/dist/src/formats/csv/index.d.ts.map +1 -1
  188. package/dist/src/formats/csv/index.js +94 -21
  189. package/dist/src/formats/csv/index.js.map +1 -1
  190. package/dist/src/formats/csv/records.d.ts +95 -10
  191. package/dist/src/formats/csv/records.d.ts.map +1 -1
  192. package/dist/src/formats/csv/records.js +333 -122
  193. package/dist/src/formats/csv/records.js.map +1 -1
  194. package/dist/src/formats/csv/values.d.ts +1 -0
  195. package/dist/src/formats/csv/values.d.ts.map +1 -1
  196. package/dist/src/formats/csv/values.js +1 -0
  197. package/dist/src/formats/csv/values.js.map +1 -1
  198. package/dist/src/formats/cx/exporter.d.ts +102 -0
  199. package/dist/src/formats/cx/exporter.d.ts.map +1 -0
  200. package/dist/src/formats/cx/exporter.js +1217 -0
  201. package/dist/src/formats/cx/exporter.js.map +1 -0
  202. package/dist/src/formats/cx/importer.d.ts +79 -32
  203. package/dist/src/formats/cx/importer.d.ts.map +1 -1
  204. package/dist/src/formats/cx/importer.js +680 -285
  205. package/dist/src/formats/cx/importer.js.map +1 -1
  206. package/dist/src/formats/cx/index.d.ts +4 -3
  207. package/dist/src/formats/cx/index.d.ts.map +1 -1
  208. package/dist/src/formats/cx/index.js +4 -3
  209. package/dist/src/formats/cx/index.js.map +1 -1
  210. package/dist/src/formats/cx2/exporter.d.ts +29 -11
  211. package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
  212. package/dist/src/formats/cx2/exporter.js +39 -268
  213. package/dist/src/formats/cx2/exporter.js.map +1 -1
  214. package/dist/src/formats/cx2/importer.d.ts +78 -28
  215. package/dist/src/formats/cx2/importer.d.ts.map +1 -1
  216. package/dist/src/formats/cx2/importer.js +226 -79
  217. package/dist/src/formats/cx2/importer.js.map +1 -1
  218. package/dist/src/formats/cx2/index.d.ts +2 -1
  219. package/dist/src/formats/cx2/index.d.ts.map +1 -1
  220. package/dist/src/formats/cx2/index.js +2 -1
  221. package/dist/src/formats/cx2/index.js.map +1 -1
  222. package/dist/src/formats/cys/constants.d.ts +66 -17
  223. package/dist/src/formats/cys/constants.d.ts.map +1 -1
  224. package/dist/src/formats/cys/constants.js +59 -18
  225. package/dist/src/formats/cys/constants.js.map +1 -1
  226. package/dist/src/formats/cys/exporter.d.ts +118 -0
  227. package/dist/src/formats/cys/exporter.d.ts.map +1 -0
  228. package/dist/src/formats/cys/exporter.js +1072 -0
  229. package/dist/src/formats/cys/exporter.js.map +1 -0
  230. package/dist/src/formats/cys/importer.d.ts +22 -8
  231. package/dist/src/formats/cys/importer.d.ts.map +1 -1
  232. package/dist/src/formats/cys/importer.js +510 -149
  233. package/dist/src/formats/cys/importer.js.map +1 -1
  234. package/dist/src/formats/cys/index.d.ts +4 -2
  235. package/dist/src/formats/cys/index.d.ts.map +1 -1
  236. package/dist/src/formats/cys/index.js +4 -2
  237. package/dist/src/formats/cys/index.js.map +1 -1
  238. package/dist/src/formats/cys/session.d.ts +46 -7
  239. package/dist/src/formats/cys/session.d.ts.map +1 -1
  240. package/dist/src/formats/cys/session.js +98 -24
  241. package/dist/src/formats/cys/session.js.map +1 -1
  242. package/dist/src/formats/cys/tables.d.ts +9 -2
  243. package/dist/src/formats/cys/tables.d.ts.map +1 -1
  244. package/dist/src/formats/cys/tables.js +29 -7
  245. package/dist/src/formats/cys/tables.js.map +1 -1
  246. package/dist/src/formats/dot/exporter.d.ts +42 -14
  247. package/dist/src/formats/dot/exporter.d.ts.map +1 -1
  248. package/dist/src/formats/dot/exporter.js +56 -29
  249. package/dist/src/formats/dot/exporter.js.map +1 -1
  250. package/dist/src/formats/dot/importer.d.ts +91 -29
  251. package/dist/src/formats/dot/importer.d.ts.map +1 -1
  252. package/dist/src/formats/dot/importer.js +190 -39
  253. package/dist/src/formats/dot/importer.js.map +1 -1
  254. package/dist/src/formats/dot/index.d.ts +2 -1
  255. package/dist/src/formats/dot/index.d.ts.map +1 -1
  256. package/dist/src/formats/dot/index.js +2 -1
  257. package/dist/src/formats/dot/index.js.map +1 -1
  258. package/dist/src/formats/dot/names.d.ts +44 -11
  259. package/dist/src/formats/dot/names.d.ts.map +1 -1
  260. package/dist/src/formats/dot/names.js +44 -11
  261. package/dist/src/formats/dot/names.js.map +1 -1
  262. package/dist/src/formats/dot/tokenizer.d.ts +9 -2
  263. package/dist/src/formats/dot/tokenizer.d.ts.map +1 -1
  264. package/dist/src/formats/dot/tokenizer.js +20 -5
  265. package/dist/src/formats/dot/tokenizer.js.map +1 -1
  266. package/dist/src/formats/gexf/exporter.d.ts +46 -15
  267. package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
  268. package/dist/src/formats/gexf/exporter.js +45 -15
  269. package/dist/src/formats/gexf/exporter.js.map +1 -1
  270. package/dist/src/formats/gexf/importer.d.ts +87 -23
  271. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  272. package/dist/src/formats/gexf/importer.js +471 -90
  273. package/dist/src/formats/gexf/importer.js.map +1 -1
  274. package/dist/src/formats/gexf/index.d.ts +84 -21
  275. package/dist/src/formats/gexf/index.d.ts.map +1 -1
  276. package/dist/src/formats/gexf/index.js +80 -23
  277. package/dist/src/formats/gexf/index.js.map +1 -1
  278. package/dist/src/formats/gexf/schema.d.ts +67 -15
  279. package/dist/src/formats/gexf/schema.d.ts.map +1 -1
  280. package/dist/src/formats/gexf/schema.js +59 -13
  281. package/dist/src/formats/gexf/schema.js.map +1 -1
  282. package/dist/src/formats/gml/exporter.d.ts +69 -21
  283. package/dist/src/formats/gml/exporter.d.ts.map +1 -1
  284. package/dist/src/formats/gml/exporter.js +74 -29
  285. package/dist/src/formats/gml/exporter.js.map +1 -1
  286. package/dist/src/formats/gml/importer.d.ts +116 -25
  287. package/dist/src/formats/gml/importer.d.ts.map +1 -1
  288. package/dist/src/formats/gml/importer.js +290 -61
  289. package/dist/src/formats/gml/importer.js.map +1 -1
  290. package/dist/src/formats/gml/index.d.ts +87 -24
  291. package/dist/src/formats/gml/index.d.ts.map +1 -1
  292. package/dist/src/formats/gml/index.js +79 -26
  293. package/dist/src/formats/gml/index.js.map +1 -1
  294. package/dist/src/formats/gml/syntax.d.ts +67 -18
  295. package/dist/src/formats/gml/syntax.d.ts.map +1 -1
  296. package/dist/src/formats/gml/syntax.js +108 -26
  297. package/dist/src/formats/gml/syntax.js.map +1 -1
  298. package/dist/src/formats/graphml/constants.d.ts +174 -44
  299. package/dist/src/formats/graphml/constants.d.ts.map +1 -1
  300. package/dist/src/formats/graphml/constants.js +165 -44
  301. package/dist/src/formats/graphml/constants.js.map +1 -1
  302. package/dist/src/formats/graphml/exporter.d.ts +17 -9
  303. package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
  304. package/dist/src/formats/graphml/exporter.js +33 -12
  305. package/dist/src/formats/graphml/exporter.js.map +1 -1
  306. package/dist/src/formats/graphml/importer.d.ts +19 -7
  307. package/dist/src/formats/graphml/importer.d.ts.map +1 -1
  308. package/dist/src/formats/graphml/importer.js +466 -39
  309. package/dist/src/formats/graphml/importer.js.map +1 -1
  310. package/dist/src/formats/graphml/index.d.ts +2 -1
  311. package/dist/src/formats/graphml/index.d.ts.map +1 -1
  312. package/dist/src/formats/graphml/index.js +2 -1
  313. package/dist/src/formats/graphml/index.js.map +1 -1
  314. package/dist/src/formats/graphml/tree.d.ts +6 -2
  315. package/dist/src/formats/graphml/tree.d.ts.map +1 -1
  316. package/dist/src/formats/graphml/tree.js +6 -2
  317. package/dist/src/formats/graphml/tree.js.map +1 -1
  318. package/dist/src/formats/graphml/yfiles.d.ts +8 -3
  319. package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
  320. package/dist/src/formats/graphml/yfiles.js +36 -15
  321. package/dist/src/formats/graphml/yfiles.js.map +1 -1
  322. package/dist/src/formats/json/dialect.d.ts +88 -24
  323. package/dist/src/formats/json/dialect.d.ts.map +1 -1
  324. package/dist/src/formats/json/dialect.js +109 -19
  325. package/dist/src/formats/json/dialect.js.map +1 -1
  326. package/dist/src/formats/json/exporter.d.ts +134 -22
  327. package/dist/src/formats/json/exporter.d.ts.map +1 -1
  328. package/dist/src/formats/json/exporter.js +135 -54
  329. package/dist/src/formats/json/exporter.js.map +1 -1
  330. package/dist/src/formats/json/importer.d.ts +173 -52
  331. package/dist/src/formats/json/importer.d.ts.map +1 -1
  332. package/dist/src/formats/json/importer.js +899 -220
  333. package/dist/src/formats/json/importer.js.map +1 -1
  334. package/dist/src/formats/json/index.d.ts +3 -2
  335. package/dist/src/formats/json/index.d.ts.map +1 -1
  336. package/dist/src/formats/json/index.js +3 -2
  337. package/dist/src/formats/json/index.js.map +1 -1
  338. package/dist/src/formats/json/obographs-export.d.ts +68 -0
  339. package/dist/src/formats/json/obographs-export.d.ts.map +1 -0
  340. package/dist/src/formats/json/obographs-export.js +941 -0
  341. package/dist/src/formats/json/obographs-export.js.map +1 -0
  342. package/dist/src/formats/json/obographs.d.ts +26 -0
  343. package/dist/src/formats/json/obographs.d.ts.map +1 -1
  344. package/dist/src/formats/json/obographs.js +297 -80
  345. package/dist/src/formats/json/obographs.js.map +1 -1
  346. package/dist/src/formats/neo4j/exporter.d.ts +109 -21
  347. package/dist/src/formats/neo4j/exporter.d.ts.map +1 -1
  348. package/dist/src/formats/neo4j/exporter.js +238 -85
  349. package/dist/src/formats/neo4j/exporter.js.map +1 -1
  350. package/dist/src/formats/neo4j/header.d.ts +17 -4
  351. package/dist/src/formats/neo4j/header.d.ts.map +1 -1
  352. package/dist/src/formats/neo4j/header.js +36 -4
  353. package/dist/src/formats/neo4j/header.js.map +1 -1
  354. package/dist/src/formats/neo4j/importer.d.ts +107 -27
  355. package/dist/src/formats/neo4j/importer.d.ts.map +1 -1
  356. package/dist/src/formats/neo4j/importer.js +415 -63
  357. package/dist/src/formats/neo4j/importer.js.map +1 -1
  358. package/dist/src/formats/neo4j/index.d.ts +73 -23
  359. package/dist/src/formats/neo4j/index.d.ts.map +1 -1
  360. package/dist/src/formats/neo4j/index.js +65 -25
  361. package/dist/src/formats/neo4j/index.js.map +1 -1
  362. package/dist/src/formats/obo/exporter.d.ts +150 -0
  363. package/dist/src/formats/obo/exporter.d.ts.map +1 -0
  364. package/dist/src/formats/obo/exporter.js +1736 -0
  365. package/dist/src/formats/obo/exporter.js.map +1 -0
  366. package/dist/src/formats/obo/importer.d.ts +95 -19
  367. package/dist/src/formats/obo/importer.d.ts.map +1 -1
  368. package/dist/src/formats/obo/importer.js +475 -104
  369. package/dist/src/formats/obo/importer.js.map +1 -1
  370. package/dist/src/formats/obo/index.d.ts +6 -3
  371. package/dist/src/formats/obo/index.d.ts.map +1 -1
  372. package/dist/src/formats/obo/index.js +6 -3
  373. package/dist/src/formats/obo/index.js.map +1 -1
  374. package/dist/src/formats/obo/syntax.d.ts +108 -4
  375. package/dist/src/formats/obo/syntax.d.ts.map +1 -1
  376. package/dist/src/formats/obo/syntax.js +211 -34
  377. package/dist/src/formats/obo/syntax.js.map +1 -1
  378. package/dist/src/formats/pajek/exporter.d.ts +54 -16
  379. package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
  380. package/dist/src/formats/pajek/exporter.js +66 -34
  381. package/dist/src/formats/pajek/exporter.js.map +1 -1
  382. package/dist/src/formats/pajek/importer.d.ts +84 -22
  383. package/dist/src/formats/pajek/importer.d.ts.map +1 -1
  384. package/dist/src/formats/pajek/importer.js +303 -83
  385. package/dist/src/formats/pajek/importer.js.map +1 -1
  386. package/dist/src/formats/pajek/index.d.ts +2 -1
  387. package/dist/src/formats/pajek/index.d.ts.map +1 -1
  388. package/dist/src/formats/pajek/index.js +2 -1
  389. package/dist/src/formats/pajek/index.js.map +1 -1
  390. package/dist/src/formats/pajek/syntax.d.ts +77 -14
  391. package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
  392. package/dist/src/formats/pajek/syntax.js +183 -51
  393. package/dist/src/formats/pajek/syntax.js.map +1 -1
  394. package/dist/src/formats/xgmml/columns.d.ts +1 -0
  395. package/dist/src/formats/xgmml/columns.d.ts.map +1 -1
  396. package/dist/src/formats/xgmml/columns.js +4 -0
  397. package/dist/src/formats/xgmml/columns.js.map +1 -1
  398. package/dist/src/formats/xgmml/constants.d.ts +186 -56
  399. package/dist/src/formats/xgmml/constants.d.ts.map +1 -1
  400. package/dist/src/formats/xgmml/constants.js +181 -57
  401. package/dist/src/formats/xgmml/constants.js.map +1 -1
  402. package/dist/src/formats/xgmml/document.d.ts +65 -11
  403. package/dist/src/formats/xgmml/document.d.ts.map +1 -1
  404. package/dist/src/formats/xgmml/document.js +157 -28
  405. package/dist/src/formats/xgmml/document.js.map +1 -1
  406. package/dist/src/formats/xgmml/emit.d.ts +61 -3
  407. package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
  408. package/dist/src/formats/xgmml/emit.js +129 -26
  409. package/dist/src/formats/xgmml/emit.js.map +1 -1
  410. package/dist/src/formats/xgmml/exporter.d.ts +13 -6
  411. package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
  412. package/dist/src/formats/xgmml/exporter.js +20 -21
  413. package/dist/src/formats/xgmml/exporter.js.map +1 -1
  414. package/dist/src/formats/xgmml/importer.d.ts +33 -12
  415. package/dist/src/formats/xgmml/importer.d.ts.map +1 -1
  416. package/dist/src/formats/xgmml/importer.js +35 -72
  417. package/dist/src/formats/xgmml/importer.js.map +1 -1
  418. package/dist/src/formats/xgmml/index.d.ts +1 -0
  419. package/dist/src/formats/xgmml/index.d.ts.map +1 -1
  420. package/dist/src/formats/xgmml/index.js +1 -0
  421. package/dist/src/formats/xgmml/index.js.map +1 -1
  422. package/dist/src/formats/xgmml/values.d.ts +8 -1
  423. package/dist/src/formats/xgmml/values.d.ts.map +1 -1
  424. package/dist/src/formats/xgmml/values.js +7 -2
  425. package/dist/src/formats/xgmml/values.js.map +1 -1
  426. package/dist/src/index.d.ts +23 -18
  427. package/dist/src/index.d.ts.map +1 -1
  428. package/dist/src/index.js +28 -16
  429. package/dist/src/index.js.map +1 -1
  430. package/dist/src/registry.d.ts +478 -92
  431. package/dist/src/registry.d.ts.map +1 -1
  432. package/dist/src/registry.js +807 -88
  433. package/dist/src/registry.js.map +1 -1
  434. package/dist/src/sniff.d.ts +61 -19
  435. package/dist/src/sniff.d.ts.map +1 -1
  436. package/dist/src/sniff.js +121 -29
  437. package/dist/src/sniff.js.map +1 -1
  438. package/dist/src/types.d.ts +362 -112
  439. package/dist/src/types.d.ts.map +1 -1
  440. package/dist/src/types.js +28 -7
  441. package/dist/src/types.js.map +1 -1
  442. package/dist/xgmml.js +2 -2
  443. package/docs/samples/README.md +25 -0
  444. package/docs/samples/got-edges.csv +353 -0
  445. package/docs/samples/got-network.graphml +1384 -0
  446. package/docs/samples/got-nodes.csv +108 -0
  447. package/docs/samples/got.cx +930 -0
  448. package/docs/samples/got.cx2 +465 -0
  449. package/docs/samples/got.gexf +471 -0
  450. package/docs/samples/got.gml +2650 -0
  451. package/docs/samples/got.json +2546 -0
  452. package/docs/samples/got.net +461 -0
  453. package/docs/samples/movies-nodes.csv +9 -0
  454. package/docs/samples/movies-rels.csv +8 -0
  455. package/docs/samples/networks.cys +0 -0
  456. package/docs/samples/proteins.xgmml +9 -0
  457. package/docs/samples/teams.gv +24 -0
  458. package/docs/samples/vehicles.obo +25 -0
  459. package/package.json +9 -4
  460. package/src/children.ts +18 -6
  461. package/src/common/attributes.ts +29 -11
  462. package/src/common/cell-budget.ts +11 -3
  463. package/src/common/choose.ts +89 -0
  464. package/src/common/codes.ts +490 -66
  465. package/src/common/compare.ts +472 -0
  466. package/src/common/cx-export.ts +432 -0
  467. package/src/common/declared-types.ts +38 -4
  468. package/src/common/direction.ts +78 -51
  469. package/src/common/escape.ts +33 -17
  470. package/src/common/export.ts +284 -47
  471. package/src/common/format.ts +30 -1
  472. package/src/common/ids.ts +14 -3
  473. package/src/common/input.ts +1057 -134
  474. package/src/common/json-elements.ts +1034 -198
  475. package/src/common/line-format.ts +249 -0
  476. package/src/common/lists.ts +6 -1
  477. package/src/common/ontology-export.ts +461 -0
  478. package/src/common/ontology.ts +31 -9
  479. package/src/common/options.ts +110 -15
  480. package/src/common/plural.ts +49 -0
  481. package/src/common/report.ts +168 -25
  482. package/src/common/temporal.ts +22 -5
  483. package/src/common/text.ts +62 -23
  484. package/src/common/weights.ts +74 -4
  485. package/src/common/writer.ts +37 -3
  486. package/src/common/xml.ts +477 -88
  487. package/src/common/zip.ts +169 -7
  488. package/src/formats/csv/exporter.ts +201 -46
  489. package/src/formats/csv/header.ts +50 -11
  490. package/src/formats/csv/importer.ts +1133 -245
  491. package/src/formats/csv/index.ts +106 -19
  492. package/src/formats/csv/records.ts +396 -122
  493. package/src/formats/csv/values.ts +1 -0
  494. package/src/formats/cx/exporter.ts +1483 -0
  495. package/src/formats/cx/importer.ts +888 -300
  496. package/src/formats/cx/index.ts +4 -3
  497. package/src/formats/cx2/exporter.ts +61 -338
  498. package/src/formats/cx2/importer.ts +317 -86
  499. package/src/formats/cx2/index.ts +2 -1
  500. package/src/formats/cys/constants.ts +62 -17
  501. package/src/formats/cys/exporter.ts +1368 -0
  502. package/src/formats/cys/importer.ts +659 -157
  503. package/src/formats/cys/index.ts +4 -2
  504. package/src/formats/cys/session.ts +139 -31
  505. package/src/formats/cys/tables.ts +47 -9
  506. package/src/formats/dot/exporter.ts +83 -37
  507. package/src/formats/dot/importer.ts +248 -54
  508. package/src/formats/dot/index.ts +2 -1
  509. package/src/formats/dot/names.ts +44 -11
  510. package/src/formats/dot/tokenizer.ts +25 -6
  511. package/src/formats/gexf/exporter.ts +57 -18
  512. package/src/formats/gexf/importer.ts +636 -105
  513. package/src/formats/gexf/index.ts +90 -21
  514. package/src/formats/gexf/schema.ts +67 -15
  515. package/src/formats/gml/exporter.ts +90 -36
  516. package/src/formats/gml/importer.ts +388 -67
  517. package/src/formats/gml/index.ts +85 -24
  518. package/src/formats/gml/syntax.ts +111 -26
  519. package/src/formats/graphml/constants.ts +178 -44
  520. package/src/formats/graphml/exporter.ts +52 -18
  521. package/src/formats/graphml/importer.ts +640 -60
  522. package/src/formats/graphml/index.ts +2 -1
  523. package/src/formats/graphml/tree.ts +6 -2
  524. package/src/formats/graphml/yfiles.ts +37 -15
  525. package/src/formats/json/dialect.ts +128 -29
  526. package/src/formats/json/exporter.ts +205 -68
  527. package/src/formats/json/importer.ts +1163 -253
  528. package/src/formats/json/index.ts +3 -1
  529. package/src/formats/json/obographs-export.ts +1197 -0
  530. package/src/formats/json/obographs.ts +353 -92
  531. package/src/formats/neo4j/exporter.ts +320 -101
  532. package/src/formats/neo4j/header.ts +44 -6
  533. package/src/formats/neo4j/importer.ts +512 -73
  534. package/src/formats/neo4j/index.ts +75 -23
  535. package/src/formats/obo/exporter.ts +2210 -0
  536. package/src/formats/obo/importer.ts +622 -109
  537. package/src/formats/obo/index.ts +6 -3
  538. package/src/formats/obo/syntax.ts +232 -37
  539. package/src/formats/pajek/exporter.ts +89 -41
  540. package/src/formats/pajek/importer.ts +407 -93
  541. package/src/formats/pajek/index.ts +2 -1
  542. package/src/formats/pajek/syntax.ts +213 -52
  543. package/src/formats/xgmml/columns.ts +10 -0
  544. package/src/formats/xgmml/constants.ts +183 -56
  545. package/src/formats/xgmml/document.ts +212 -34
  546. package/src/formats/xgmml/emit.ts +175 -34
  547. package/src/formats/xgmml/exporter.ts +35 -27
  548. package/src/formats/xgmml/importer.ts +64 -86
  549. package/src/formats/xgmml/index.ts +1 -0
  550. package/src/formats/xgmml/values.ts +11 -3
  551. package/src/index.ts +81 -11
  552. package/src/registry.ts +1121 -135
  553. package/src/sniff.ts +163 -32
  554. package/src/types.ts +385 -114
  555. package/dist/chunks/escape-B-tkk_Cl.js.map +0 -1
  556. package/dist/chunks/export-Bh60Dv-n.js +0 -582
  557. package/dist/chunks/export-Bh60Dv-n.js.map +0 -1
  558. package/dist/chunks/exporter-BGrsWamJ.js.map +0 -1
  559. package/dist/chunks/exporter-DIeGJXAZ.js.map +0 -1
  560. package/dist/chunks/importer-BWY2FFc5.js.map +0 -1
  561. package/dist/chunks/importer-DD-xv9_Y.js +0 -1471
  562. package/dist/chunks/importer-DD-xv9_Y.js.map +0 -1
  563. package/dist/chunks/importer-DET1tg6s.js.map +0 -1
  564. package/dist/chunks/importer-DEcKhsmQ.js +0 -1614
  565. package/dist/chunks/importer-DEcKhsmQ.js.map +0 -1
  566. package/dist/chunks/importer-DIrbbnAf.js.map +0 -1
  567. package/dist/chunks/importer-D_e7e7LX.js.map +0 -1
  568. package/dist/chunks/importer-eUREhBGj.js.map +0 -1
  569. package/dist/chunks/importer-vi3bSdtw.js.map +0 -1
  570. package/dist/chunks/importer-zGLo8Dg_.js.map +0 -1
  571. package/dist/chunks/json-elements-DDS8N2Dd.js +0 -779
  572. package/dist/chunks/json-elements-DDS8N2Dd.js.map +0 -1
  573. package/dist/chunks/ontology-BnrJ4I98.js +0 -113
  574. package/dist/chunks/ontology-BnrJ4I98.js.map +0 -1
  575. package/dist/chunks/records-dbRkxwaq.js.map +0 -1
  576. package/dist/chunks/report-B1z4WT9e.js +0 -2372
  577. package/dist/chunks/report-B1z4WT9e.js.map +0 -1
  578. package/dist/chunks/text-Dr0Ifpag.js.map +0 -1
  579. package/dist/chunks/weights-Dzba96G3.js +0 -176
  580. package/dist/chunks/weights-Dzba96G3.js.map +0 -1
  581. package/dist/chunks/writer-C7flM-Ih.js.map +0 -1
@@ -1,152 +1,9 @@
1
1
  import { GraphFormatError, INVALID_INDEX, MAX_COUNT } from "@graphty/graph-format";
2
2
  import { c as childrenCsr } from "./children-CL3Cy0ez.js";
3
- import { af as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, a as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, P as PRECISION_CODE, Z as BAD_DEFAULT_CODE, k 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, au as STRAY_TEXT_CODE, Y as UNKNOWN_ELEMENT_CODE, an as HYPEREDGE_CODE, ai as COUNT_HINT_CODE, M as MULTIPLE_GRAPHS_CODE, c as DUPLICATE_EDGE_ID_CODE, d as DUPLICATE_NODE_CODE, e as MISSING_ENDPOINT_CODE, f as MISSING_ID_CODE, al as DUPLICATE_KEY_CODE, N as NO_GRAPH_CODE, q as UNKNOWN_ENCODING_CODE, E as ENCODING_FALLBACK_CODE, r as INVALID_ENCODING_CODE, s as INVALID_UTF8_CODE, aw as XML_SYNTAX_CODE, b as ID_TEXT_TYPE_CODE, ac as ROLE_DROPPED_CODE, ab as PARENTS_DROPPED_CODE, a9 as MUTUAL_AS_UNDIRECTED_CODE, V as resolveExportOptions, X as pairFolding, aE as isCanonicalIntegerText, v as resolveImportOptions, w as ImportReportBuilder, F as reportSinkOptions, z as reportUnusedOptions, x as textChunks, y as throwIfAborted, K as IdCoercer, J as DirectionResolver, aK as declareAttribute, Q as uniqueColumnName, L as declareResolved, aX as takenIn, aM as parseDeclaredValue, aN as losesPrecision } from "./report-B1z4WT9e.js";
4
- import { a as escapeXmlText, g as isWhitespace, n as isXmlName, e as escapeXmlAttribute, l as localName, x as xmlIllegalTextNotes, t as tokenizeXml, f as xmlDeclaredEncoding, X as XmlSyntaxError } from "./escape-B-tkk_Cl.js";
5
- import { c as capabilities, a as checkCapabilities, L as LOSS, s as sanitizeIds, i as isNmtoken, m as mangleNmtoken } from "./export-Bh60Dv-n.js";
6
- import { e as explicitWeights, d as formatInteger, a as formatF64, f as formatF32, i as isWeightField, p as parseWeightText } from "./weights-Dzba96G3.js";
7
- import { j as joinText, e as encodeChunks } from "./writer-C7flM-Ih.js";
8
- const GRAPHML_NAMESPACE = "http://graphml.graphdrawing.org/xmlns";
9
- const YFILES_NAMESPACE = "http://www.yworks.com/xml/graphml";
10
- const XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance";
11
- const SCHEMA_LOCATION = "http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd";
12
- const FORMAT = "graphml";
13
- const EXTENSIONS = Object.freeze([".graphml", ".xml"]);
14
- const MIME_TYPES = Object.freeze(["application/graphml+xml", "application/xml", "text/xml"]);
15
- const ORIGINAL_ID_ATTRIBUTE = "graphty:originalId";
16
- const ORIGINAL_ID_COLUMN = "graphty.originalId";
17
- const EDGE_ID_COLUMN = "id";
18
- const SOURCE_PORT_COLUMN = "sourceport";
19
- const TARGET_PORT_COLUMN = "targetport";
20
- const PARENT_COLUMN = "parent";
21
- const HYPEREDGE_HUB_COLUMN = "graphty.hyperedge";
22
- const LABEL_COLUMN = "label";
23
- const RESERVED_EDGE_NAMES = /* @__PURE__ */ new Set([
24
- EDGE_ID_COLUMN,
25
- SOURCE_PORT_COLUMN,
26
- TARGET_PORT_COLUMN
27
- ]);
28
- const RESERVED_NODE_NAMES = /* @__PURE__ */ new Set([PARENT_COLUMN]);
29
- const META_KEY = "graphml";
30
- const GRAPHML_ISSUE = Object.freeze({
31
- /** Fatal: the input is not well-formed XML. */
32
- XML_SYNTAX: XML_SYNTAX_CODE,
33
- /** Fatal: the input holds invalid UTF-8. */
34
- INVALID_UTF8: INVALID_UTF8_CODE,
35
- /** Invalid bytes in the encoding a BOM, a declaration or the encoding option chose (fatal). */
36
- INVALID_ENCODING: INVALID_ENCODING_CODE,
37
- /** Bytes that are not UTF-8 and declare no encoding were read as windows-1252. */
38
- ENCODING_FALLBACK: ENCODING_FALLBACK_CODE,
39
- /** A declared encoding the platform cannot decode was ignored. */
40
- UNKNOWN_ENCODING: UNKNOWN_ENCODING_CODE,
41
- /** Fatal: the root element is not `<graphml>`. */
42
- NOT_GRAPHML: "E_NOT_GRAPHML",
43
- /** Fatal: the document has no `<graph>`. */
44
- NO_GRAPH: NO_GRAPH_CODE,
45
- /** A `<key>` without an id. */
46
- KEY_MISSING_ID: "E_GRAPHML_KEY_MISSING_ID",
47
- /** Two `<key>` elements with the same id. */
48
- DUPLICATE_KEY: DUPLICATE_KEY_CODE,
49
- /** A key declared for hyperedges, ports or endpoints (never used). */
50
- KEY_DOMAIN_UNSUPPORTED: "W_GRAPHML_KEY_DOMAIN_UNSUPPORTED",
51
- /** A `<node>` without an id. */
52
- MISSING_ID: MISSING_ID_CODE,
53
- /** An `<edge>` without a source or a target. */
54
- MISSING_ENDPOINT: MISSING_ENDPOINT_CODE,
55
- /** A `<data>` whose key was never declared. */
56
- UNKNOWN_KEY: "E_GRAPHML_UNKNOWN_KEY",
57
- /** A `<data>` whose key is declared for another domain. */
58
- KEY_DOMAIN: "W_GRAPHML_KEY_DOMAIN",
59
- /** A `<data>` without a key attribute. */
60
- DATA_MISSING_KEY: "E_GRAPHML_DATA_MISSING_KEY",
61
- /** A `<key>` whose `for` is not a GraphML domain. */
62
- KEY_FOR_INVALID: "E_GRAPHML_KEY_FOR_INVALID",
63
- /** Data of a nested `<graph>`; only the top-level graph has attributes. */
64
- NESTED_GRAPH_DATA: "W_GRAPHML_NESTED_GRAPH_DATA",
65
- /** Data of a hyperedge expanded to a star or clique. */
66
- HYPEREDGE_DATA_DROPPED: "W_GRAPHML_HYPEREDGE_DATA_DROPPED",
67
- /** Nested elements in the `<data>` of a typed (non-yfiles) key. */
68
- DATA_NESTED: "E_GRAPHML_DATA_NESTED",
69
- /** A `<node>` declared twice. */
70
- DUPLICATE_NODE: DUPLICATE_NODE_CODE,
71
- /** An edge id already used by another edge. */
72
- DUPLICATE_EDGE_ID: DUPLICATE_EDGE_ID_CODE,
73
- /** A `directed` attribute that is neither true nor false. */
74
- INVALID_DIRECTED: "E_GRAPHML_INVALID_DIRECTED",
75
- /** An `edgedefault` that is neither directed nor undirected. */
76
- INVALID_EDGEDEFAULT: "E_GRAPHML_INVALID_EDGEDEFAULT",
77
- /** A `<graph>` without edgedefault; the `defaultDirected` option applies. */
78
- EDGEDEFAULT_MISSING: "W_GRAPHML_EDGEDEFAULT_MISSING",
79
- /** A second top-level `<graph>`; its nodes and edges are merged into the first. */
80
- MULTIPLE_GRAPHS: MULTIPLE_GRAPHS_CODE,
81
- /** A `parse.nodes` / `parse.edges` hint the sink cannot reserve (ignored). */
82
- COUNT_HINT: COUNT_HINT_CODE,
83
- /** A hyperedge under `hyperedges: "error"`. */
84
- HYPEREDGE: HYPEREDGE_CODE,
85
- /** Hyperedges skipped under `hyperedges: "skip"`. */
86
- HYPEREDGE_SKIPPED: "W_GRAPHML_HYPEREDGE_SKIPPED",
87
- /** An endpoint of a hyperedge without a node, or with an unknown type. */
88
- HYPEREDGE_ENDPOINT: "E_GRAPHML_HYPEREDGE_ENDPOINT",
89
- /** `<port>` declarations (and their data) are not kept; sourceport / targetport edge attributes are. */
90
- PORT_DECLARATION: "W_GRAPHML_PORT_DECLARATION",
91
- /** A GraphML `parse.*` hint on `<graph>`, `<node>` or `<edge>` the importer does not act on (parse.nodeids, parse.order, ...). */
92
- PARSE_HINT_IGNORED: "W_GRAPHML_PARSE_HINT_IGNORED",
93
- /** An XML attribute GraphML does not define on `<graph>`, `<node>` or `<edge>`; it is not kept. */
94
- UNKNOWN_XML_ATTRIBUTE: "W_GRAPHML_UNKNOWN_XML_ATTRIBUTE",
95
- /** A `<locator>` element. */
96
- LOCATOR_DROPPED: "W_GRAPHML_LOCATOR_DROPPED",
97
- /** A `<desc>` of a node, an edge or a hyperedge. */
98
- DESC_DROPPED: "W_GRAPHML_DESC_DROPPED",
99
- /** An element the GraphML schema does not define at that place. */
100
- UNKNOWN_ELEMENT: UNKNOWN_ELEMENT_CODE,
101
- /** Non-whitespace text where the schema allows only elements. */
102
- STRAY_TEXT: STRAY_TEXT_CODE,
103
- /** Two distinct id texts merged into one number under `ids: "number"`. */
104
- ID_MERGED: ID_MERGED_CODE,
105
- /** An option GraphML has no use for (`nodeIdFrom`: nodes are identified by their id attribute). */
106
- OPTION_IGNORED: OPTION_IGNORED_CODE,
107
- /** A yFiles key under `yfiles: "skip"`. */
108
- YFILES_SKIPPED: "W_GRAPHML_YFILES_SKIPPED",
109
- /** A key renamed `<name>#<id>` because the name was taken (design section 5.6). */
110
- COLUMN_RENAMED: COLUMN_RENAMED_CODE,
111
- /** A key declared without its role because the table already holds it. */
112
- ROLE_TAKEN: ROLE_TAKEN_CODE,
113
- /** A declared type the format does not define (kept as string). */
114
- UNKNOWN_ATTR_TYPE: UNKNOWN_ATTR_TYPE_CODE,
115
- /** A default that does not parse as the declared type. */
116
- BAD_DEFAULT: BAD_DEFAULT_CODE,
117
- /** A long value beyond 2^53 rounded. */
118
- PRECISION: PRECISION_CODE,
119
- /** A builder-policy option the sink does not honour. */
120
- SINK_OPTION: SINK_OPTION_CODE,
121
- /** The sink refused the file's direction. */
122
- DIRECTION_REFUSED: DIRECTION_REFUSED_CODE,
123
- /** Edges forced to the policy's direction. */
124
- DIRECTION_FORCED: DIRECTION_FORCED_CODE,
125
- /** A mixed file under onMixedDirection "error" (fatal). */
126
- MIXED_DIRECTION: MIXED_DIRECTION_CODE
127
- });
128
- const GRAPHML_LOSS = Object.freeze({
129
- /** yFiles nested XML kept as a JSON tree: structure preserved, not byte-exact. */
130
- YFILES_JSON: "W_GRAPHML_YFILES_JSON",
131
- /** A mutual pair written as one undirected edge; the mark is lost. */
132
- MUTUAL_AS_UNDIRECTED: MUTUAL_AS_UNDIRECTED_CODE,
133
- /** A `parents` (multi-parent) column cannot be written as nested graphs. */
134
- PARENTS_DROPPED: PARENTS_DROPPED_CODE,
135
- /** A role column GraphML has no slot for (kind, node ids, ...) written as a plain attribute. */
136
- ROLE_DROPPED: ROLE_DROPPED_CODE,
137
- /** Containment order differs from index order; node indices change after a round trip. */
138
- HIERARCHY_REORDERED: "W_GRAPHML_HIERARCHY_REORDERED",
139
- /** Nodes whose parent chain never reaches a root are written at the top level. */
140
- PARENT_CYCLE: "W_GRAPHML_PARENT_CYCLE",
141
- /** Node ids that change type after a round trip under the canonical rule (design section 4.1). */
142
- ID_TEXT_TYPE: ID_TEXT_TYPE_CODE,
143
- /** A numeric edge id column reads back as string. */
144
- EDGE_ID_TEXT: "W_GRAPHML_EDGE_ID_TEXT",
145
- /** A `yfiles.*` graphics column that no longer matches its yFiles tree: only the tree is written. */
146
- YFILES_GRAPHICS_STALE: "W_GRAPHML_YFILES_GRAPHICS_STALE",
147
- /** A yfiles json value that is not a serialisable tree: export() will throw E_COLUMN_TYPE. */
148
- YFILES_TREE: "E_GRAPHML_YFILES_TREE"
149
- });
3
+ import { r as resolveExportOptions, c as capabilities, a as checkCapabilities, L as LOSS, p as pairFolding, b as plural, $ as agree, aE as sanitizeIds, e as explicitWeights, bA as isNmtoken, by as isCanonicalIntegerText, bB as mangleNmtoken, aG as formatInteger, ab as formatF64, aa as formatF32, al as resolveImportOptions, a8 as ImportReportBuilder, ao as reportSinkOptions, an as reportUnusedOptions, a4 as textChunks, am as throwIfAborted, ar as IdCoercer, aq as DirectionResolver, aK as isWeightField, bI as declareAttribute, a0 as uniqueColumnName, a1 as declareResolved, bX as takenIn, aL as parseWeightText, bL as parseDeclaredValue, bM as losesPrecision, P as PRECISION_CODE, bJ as overflowsToInfinity } from "./export-BTI4yQgy.js";
4
+ import { a as escapeXmlText, j as isWhitespace, n as isXmlName, e as escapeXmlAttribute, l as localName, x as xmlIllegalTextNotes, t as tokenizeXml, f as xmlDeclaredEncoding, g as XmlEmptyInputError, X as XmlSyntaxError, s as sniffXmlText } from "./escape-D0g6NNUy.js";
5
+ import { j as joinText, e as encodeChunks } from "./writer-DxjgHwSe.js";
6
+ import { F as FORMAT, a as GRAPHML_LOSS, Y as YFILES_NAMESPACE, X as XSI_NAMESPACE, S as SCHEMA_LOCATION, b as GRAPHML_NAMESPACE, O as ORIGINAL_ID_ATTRIBUTE, M as META_KEY, L as LABEL_COLUMN, R as RESERVED_NODE_NAMES, c as RESERVED_EDGE_NAMES, P as PARENT_COLUMN, T as TARGET_PORT_COLUMN, d as SOURCE_PORT_COLUMN, E as EDGE_ID_COLUMN, e as MIME_TYPES, f as EXTENSIONS, G as GRAPHML_ISSUE, g as ORIGINAL_ID_COLUMN, H as HYPEREDGE_HUB_COLUMN } from "./constants-BCsFsMj4.js";
150
7
  const ATTRIBUTE_PREFIX = "@_";
151
8
  const TEXT_KEY = "#text";
152
9
  class XmlTreeBuilder {
@@ -431,44 +288,44 @@ function staleGraphicsRows(column, table, domain) {
431
288
  }
432
289
  return stale;
433
290
  }
434
- function graphicsValues(domain, tree) {
291
+ function graphicsValues(domain, tree, unmapped = []) {
435
292
  const out = [];
436
293
  if (domain === "node") {
437
294
  const shape = child(tree, "ShapeNode");
438
295
  if (shape !== void 0) {
439
- shapeNodeValues(shape, out);
296
+ shapeNodeValues(shape, out, unmapped);
440
297
  }
441
298
  } else {
442
299
  const edge = child(tree, "PolyLineEdge");
443
300
  if (edge !== void 0) {
444
- polyLineEdgeValues(edge, out);
301
+ polyLineEdgeValues(edge, out, unmapped);
445
302
  }
446
303
  }
447
304
  return out;
448
305
  }
449
- function shapeNodeValues(shape, out) {
306
+ function shapeNodeValues(shape, out, unmapped) {
450
307
  const geometry = child(shape, "Geometry");
451
- const x = number(attr(geometry, "x"));
452
- const y = number(attr(geometry, "y"));
308
+ const x = checked(attr(geometry, "x"), "x", unmapped);
309
+ const y = checked(attr(geometry, "y"), "y", unmapped);
453
310
  if (x !== void 0 && y !== void 0) {
454
311
  out.push(["position", [x, y, 0]]);
455
312
  }
456
- push(out, "width", number(attr(geometry, "width")));
457
- push(out, "height", number(attr(geometry, "height")));
313
+ push(out, "width", checked(attr(geometry, "width"), "width", unmapped));
314
+ push(out, "height", checked(attr(geometry, "height"), "height", unmapped));
458
315
  push(out, "color", color(attr(child(shape, "Fill"), "color")));
459
316
  const border = child(shape, "BorderStyle");
460
317
  push(out, "borderColor", color(attr(border, "color")));
461
- push(out, "borderWidth", number(attr(border, "width")));
318
+ push(out, "borderWidth", checked(attr(border, "width"), "borderWidth", unmapped));
462
319
  const label = child(shape, "NodeLabel");
463
320
  if (typeof label === "string" ? label.length > 0 : label !== void 0) {
464
321
  out.push(["label", (typeof label === "string" ? label : text(label) ?? "").trim()]);
465
322
  }
466
323
  push(out, "shape", nonEmpty(attr(child(shape, "Shape"), "type")));
467
324
  }
468
- function polyLineEdgeValues(edge, out) {
325
+ function polyLineEdgeValues(edge, out, unmapped) {
469
326
  const line = child(edge, "LineStyle");
470
327
  push(out, "color", color(attr(line, "color")));
471
- push(out, "width", number(attr(line, "width")));
328
+ push(out, "width", checked(attr(line, "width"), "width", unmapped));
472
329
  const arrows = child(edge, "Arrows");
473
330
  if (arrows !== void 0 && typeof arrows === "object") {
474
331
  const target = attr(arrows, "target");
@@ -515,6 +372,13 @@ function number(value) {
515
372
  const n = Number.parseFloat(value);
516
373
  return Number.isNaN(n) ? void 0 : n;
517
374
  }
375
+ function checked(value, field, unmapped) {
376
+ const n = number(value);
377
+ if (n === void 0 && value !== void 0 && value.length > 0) {
378
+ unmapped.push(field);
379
+ }
380
+ return n;
381
+ }
518
382
  function color(value) {
519
383
  if (value === void 0 || value.length === 0) {
520
384
  return void 0;
@@ -657,7 +521,7 @@ function planExport(snapshot, options, format) {
657
521
  if (idTypeChanges > 0) {
658
522
  note(
659
523
  GRAPHML_LOSS.ID_TEXT_TYPE,
660
- `${idTypeChanges} node id(s) change type when read back under ids: "canonical" (string ids that are integer text, non-integer numbers)`,
524
+ `${idTypeChanges} node id${plural(idTypeChanges)} ${agree(idTypeChanges, "changes", "change")} type when read back under ids: "canonical" (string ids that are integer text, non-integer numbers)`,
661
525
  null,
662
526
  idTypeChanges
663
527
  );
@@ -673,7 +537,7 @@ function planExport(snapshot, options, format) {
673
537
  if (folding.mutualCount > 0) {
674
538
  note(
675
539
  GRAPHML_LOSS.MUTUAL_AS_UNDIRECTED,
676
- `${folding.mutualCount} mutual pair(s) are written as undirected edges; the mutual mark is lost`,
540
+ `${folding.mutualCount} mutual pair${plural(folding.mutualCount)} ${agree(folding.mutualCount, "is", "are")} written as undirected edges; the mutual mark is lost`,
677
541
  null,
678
542
  folding.mutualCount
679
543
  );
@@ -690,7 +554,7 @@ function planExport(snapshot, options, format) {
690
554
  if (hierarchy.unreachable > 0) {
691
555
  note(
692
556
  GRAPHML_LOSS.PARENT_CYCLE,
693
- `${hierarchy.unreachable} node(s) whose parent chain never reaches a root are written at the top level`,
557
+ `${hierarchy.unreachable} node${plural(hierarchy.unreachable)} whose parent chain never reaches a root ${agree(hierarchy.unreachable, "is", "are")} written at the top level`,
694
558
  hierarchy.parent?.meta.name ?? null,
695
559
  hierarchy.unreachable
696
560
  );
@@ -805,7 +669,7 @@ function planWeight(snapshot, edgeColumns, keyIds, keys, note) {
805
669
  if (plan.attrName === attrName) {
806
670
  note(
807
671
  LOSS.WEIGHT_KEY_CLASH,
808
- `edge column "${plan.column.meta.name}" is written as a key titled "${attrName}", which the importer reads as THE weight (weightFrom); it reads back as the weight, not as a column`,
672
+ `edge column "${plan.column.meta.name}" is written as a key titled "${attrName}", which the importer reads as the edge weight (weightFrom); it reads back as the weight, not as a column`,
809
673
  plan.column.meta.name,
810
674
  plan.column.length - plan.column.nullCount
811
675
  );
@@ -842,11 +706,16 @@ function planEdgeIds(snapshot, column, options, note) {
842
706
  return;
843
707
  }
844
708
  if (options.sanitizeIds === "mangle") {
845
- note(LOSS.ID_MANGLED, `${bad} edge id(s) outside the nmtoken charset are rewritten`, column.meta.name, bad);
709
+ note(
710
+ LOSS.ID_MANGLED,
711
+ `${bad} edge id${plural(bad)} outside the nmtoken charset ${agree(bad, "is", "are")} rewritten`,
712
+ column.meta.name,
713
+ bad
714
+ );
846
715
  } else {
847
716
  note(
848
717
  LOSS.ID_CHARSET,
849
- `${bad} edge id(s) outside the nmtoken charset; export() will throw unless sanitizeIds is "mangle"`,
718
+ `${bad} edge id${plural(bad)} outside the nmtoken charset; the save fails unless sanitizeIds is "mangle"`,
850
719
  column.meta.name,
851
720
  bad
852
721
  );
@@ -895,7 +764,7 @@ function planTable(table, domain, notes, note) {
895
764
  if (stale > 0) {
896
765
  note(
897
766
  GRAPHML_LOSS.YFILES_GRAPHICS_STALE,
898
- `${stale} value(s) of ${domain} column "${name}" differ from the yFiles tree it was read from; only the tree is written, so they are lost`,
767
+ `${stale} value${plural(stale)} of ${domain} column "${name}" differ from the yFiles tree it was read from; only the tree is written, so they are lost`,
899
768
  name,
900
769
  stale
901
770
  );
@@ -937,7 +806,7 @@ function planTable(table, domain, notes, note) {
937
806
  if (bad > 0) {
938
807
  note(
939
808
  GRAPHML_LOSS.YFILES_TREE,
940
- `${bad} value(s) of yfiles column "${name}" are not XML trees; export() will throw E_COLUMN_TYPE`,
809
+ `${bad} value${plural(bad)} of yfiles column "${name}" ${agree(bad, "is", "are")} not XML trees; the save fails with E_COLUMN_TYPE`,
941
810
  name,
942
811
  bad
943
812
  );
@@ -1016,6 +885,9 @@ function attrTypeFor(column) {
1016
885
  case "u32":
1017
886
  return columnMax(column) <= I32_MAX ? "int" : "long";
1018
887
  case "string":
888
+ if (declared !== null && declared.trim().toLowerCase() === "long" && columnIntegerText(column)) {
889
+ return "long";
890
+ }
1019
891
  if (declared !== null && TYPE_DTYPES[declared.trim().toLowerCase()] === void 0) {
1020
892
  return declared;
1021
893
  }
@@ -1030,6 +902,14 @@ function attrTypeFor(column) {
1030
902
  }
1031
903
  }
1032
904
  }
905
+ function columnIntegerText(column) {
906
+ for (let r = 0; r < column.length; r++) {
907
+ if (column.isSet(r) && !/^[+-]?\d+$/.test(String(column.value(r)))) {
908
+ return false;
909
+ }
910
+ }
911
+ return true;
912
+ }
1033
913
  function columnIntegral(column) {
1034
914
  if (column.dtype !== "f64") {
1035
915
  return false;
@@ -1287,7 +1167,7 @@ function sanitizeEdgeIds(column, mode, edgeCount) {
1287
1167
  if (bad.length > 0 && mode === "error") {
1288
1168
  throw new GraphFormatError(
1289
1169
  "E_INVALID_ID",
1290
- `${bad.length} edge id(s) cannot be written as nmtoken (first: ${JSON.stringify(edgeIdText(column, bad[0]))} at edge ${bad[0]}); pass sanitizeIds: "mangle" to rewrite them`,
1170
+ `${bad.length} edge id${plural(bad.length)} ${agree(bad.length, "is", "are")} not XML name tokens (first: ${JSON.stringify(edgeIdText(column, bad[0]))} at edge ${bad[0]}); pass sanitizeIds: "mangle" to rewrite them`,
1291
1171
  { reason: "charset", charset: "nmtoken", count: bad.length, edge: bad[0] }
1292
1172
  );
1293
1173
  }
@@ -1490,6 +1370,7 @@ ${pad}</node>`;
1490
1370
  }
1491
1371
  const graphmlExporter = Object.freeze({
1492
1372
  format: FORMAT,
1373
+ options: Object.freeze(["edgedefault", "pretty"]),
1493
1374
  capabilities: CAPABILITIES,
1494
1375
  /**
1495
1376
  * Pre-flight: every loss the export would incur.
@@ -1524,6 +1405,22 @@ const graphmlExporter = Object.freeze({
1524
1405
  });
1525
1406
  const GRAPH_ATTRIBUTES = /* @__PURE__ */ new Set(["id", "edgedefault", "parse.nodes", "parse.edges"]);
1526
1407
  const NODE_ATTRIBUTES = /* @__PURE__ */ new Set(["id"]);
1408
+ const KEY_ATTRIBUTES = /* @__PURE__ */ new Set([
1409
+ "id",
1410
+ "for",
1411
+ "attr.name",
1412
+ "attr.type",
1413
+ "name",
1414
+ "type",
1415
+ "yfiles.type"
1416
+ ]);
1417
+ const DATA_ATTRIBUTES = /* @__PURE__ */ new Set(["key"]);
1418
+ const HYPEREDGE_ATTRIBUTES = /* @__PURE__ */ new Set(["id"]);
1419
+ const ENDPOINT_ATTRIBUTES = /* @__PURE__ */ new Set(["node", "type"]);
1420
+ const PORT_ATTRIBUTES = /* @__PURE__ */ new Set(["name"]);
1421
+ const NO_ATTRIBUTES = /* @__PURE__ */ new Set();
1422
+ const SCHEMA_ATTRIBUTES = /* @__PURE__ */ new Set(["id", "port", "parse.order", "parse.nodeids", "parse.edgeids"]);
1423
+ const MAX_UNKNOWN_ATTRIBUTE_NAMES = 16;
1527
1424
  const EDGE_ATTRIBUTES = /* @__PURE__ */ new Set([
1528
1425
  "id",
1529
1426
  "source",
@@ -1598,6 +1495,8 @@ class GraphmlReader {
1598
1495
  this.nodes = [];
1599
1496
  this.declared = new IndexFlags();
1600
1497
  this.edgeIds = /* @__PURE__ */ new Set();
1498
+ this.unknownKeyIds = /* @__PURE__ */ new Set();
1499
+ this.deferredEdgeIds = /* @__PURE__ */ new Set();
1601
1500
  this.elementsSinceCheck = 0;
1602
1501
  this.restored = /* @__PURE__ */ new Map();
1603
1502
  this.graphColumnNames = /* @__PURE__ */ new Set();
@@ -1614,6 +1513,8 @@ class GraphmlReader {
1614
1513
  };
1615
1514
  this.descTarget = null;
1616
1515
  this.descText = "";
1516
+ this.descLine = 0;
1517
+ this.graphKeys = { keys: null };
1617
1518
  this.description = null;
1618
1519
  this.graphSeen = false;
1619
1520
  this.graphId = null;
@@ -1628,6 +1529,16 @@ class GraphmlReader {
1628
1529
  this.targetPortHandle = INVALID_INDEX;
1629
1530
  this.parentHandle = INVALID_INDEX;
1630
1531
  this.hubHandle = INVALID_INDEX;
1532
+ this.hubs = new IndexFlags();
1533
+ this.deferred = [];
1534
+ this.graphIds = /* @__PURE__ */ new Set();
1535
+ this.topGraphs = 0;
1536
+ this.rootNs = GRAPHML_NAMESPACE;
1537
+ this.graphDescSeen = false;
1538
+ this.unknownNames = /* @__PURE__ */ new Map();
1539
+ this.unknownOverflow = /* @__PURE__ */ new Map();
1540
+ this.ports = /* @__PURE__ */ new Map();
1541
+ this.portRefs = [];
1631
1542
  this.sink = sink;
1632
1543
  this.report = report;
1633
1544
  this.options = options;
@@ -1641,8 +1552,9 @@ class GraphmlReader {
1641
1552
  * @param name - the element name
1642
1553
  * @param attrs - its attributes
1643
1554
  * @param line - the line
1555
+ * @param ns - the element's namespace (null: an undeclared prefix)
1644
1556
  */
1645
- start(name, attrs, line) {
1557
+ start(name, attrs, line, ns = "") {
1646
1558
  const parent = this.ctx.length === 0 ? null : this.ctx[this.ctx.length - 1];
1647
1559
  switch (parent) {
1648
1560
  case 9:
@@ -1659,8 +1571,15 @@ class GraphmlReader {
1659
1571
  case 3:
1660
1572
  this.captureStart(name, attrs);
1661
1573
  return;
1574
+ case 12:
1575
+ this.dropStart(localName(name));
1576
+ return;
1662
1577
  }
1663
1578
  const local = localName(name);
1579
+ if (parent !== null && ns !== GRAPHML_NAMESPACE && ns !== "" && ns !== this.rootNs) {
1580
+ this.unknownElement(name, line);
1581
+ return;
1582
+ }
1664
1583
  switch (parent) {
1665
1584
  case null:
1666
1585
  if (local !== "graphml") {
@@ -1668,6 +1587,16 @@ class GraphmlReader {
1668
1587
  line
1669
1588
  });
1670
1589
  }
1590
+ if (ns !== GRAPHML_NAMESPACE && ns !== "") {
1591
+ this.report.warning(
1592
+ "validation-error",
1593
+ GRAPHML_ISSUE.NAMESPACE,
1594
+ ns === null ? `the root <${name}> uses an undeclared prefix; read as GraphML` : `the root <${name}> is in the namespace ${JSON.stringify(ns)}, not ${GRAPHML_NAMESPACE}; read as GraphML`,
1595
+ { line, element: ns }
1596
+ );
1597
+ }
1598
+ this.rootNs = ns;
1599
+ this.reportUnreadAttributes("graphml", attrs, NO_ATTRIBUTES, line);
1671
1600
  this.readRoot(attrs);
1672
1601
  this.ctx.push(
1673
1602
  0
@@ -1678,7 +1607,7 @@ class GraphmlReader {
1678
1607
  this.startInGraphml(name, local, attrs, line);
1679
1608
  return;
1680
1609
  case 2:
1681
- this.startInKey(name, local, line);
1610
+ this.startInKey(name, local, attrs, line);
1682
1611
  return;
1683
1612
  case 4:
1684
1613
  this.startInGraph(name, local, attrs, line);
@@ -1692,6 +1621,9 @@ class GraphmlReader {
1692
1621
  case 7:
1693
1622
  this.startInHyperedge(name, local, attrs, line);
1694
1623
  return;
1624
+ case 11:
1625
+ this.startInPort(name, local, attrs, line);
1626
+ return;
1695
1627
  default:
1696
1628
  this.unknownElement(name, line);
1697
1629
  }
@@ -1709,6 +1641,8 @@ class GraphmlReader {
1709
1641
  return;
1710
1642
  case 10:
1711
1643
  case 0:
1644
+ case 11:
1645
+ case 12:
1712
1646
  case void 0:
1713
1647
  return;
1714
1648
  case 1:
@@ -1733,7 +1667,7 @@ class GraphmlReader {
1733
1667
  this.finishHyperedge();
1734
1668
  return;
1735
1669
  case 4:
1736
- this.graphs.pop();
1670
+ this.finishGraph();
1737
1671
  return;
1738
1672
  default: {
1739
1673
  const value = ctx;
@@ -1764,6 +1698,7 @@ class GraphmlReader {
1764
1698
  this.descText += text2;
1765
1699
  return;
1766
1700
  case 10:
1701
+ case 12:
1767
1702
  return;
1768
1703
  default:
1769
1704
  if (!isWhitespace(text2)) {
@@ -1783,6 +1718,23 @@ class GraphmlReader {
1783
1718
  if (!this.graphSeen) {
1784
1719
  this.report.fail(GRAPHML_ISSUE.NO_GRAPH, "the document has no <graph> element");
1785
1720
  }
1721
+ for (const edge of this.deferred) {
1722
+ if ("endpoints" in edge) {
1723
+ this.expandHyperedge(edge);
1724
+ } else {
1725
+ this.addEdge(edge);
1726
+ }
1727
+ }
1728
+ this.deferred.length = 0;
1729
+ this.checkPorts();
1730
+ for (const [kind, more] of this.unknownOverflow) {
1731
+ this.report.warning(
1732
+ "unsupported",
1733
+ GRAPHML_ISSUE.UNKNOWN_XML_ATTRIBUTE,
1734
+ `${more} more distinct attribute names on <${kind}> are not GraphML attributes and are not kept (not listed one by one)`,
1735
+ { element: kind }
1736
+ );
1737
+ }
1786
1738
  const meta = { graphId: this.graphId, edgedefault: this.edgedefault, namespaces: this.namespaces };
1787
1739
  this.sink.setMeta({
1788
1740
  sourceFormat: FORMAT,
@@ -1819,7 +1771,7 @@ class GraphmlReader {
1819
1771
  startInGraphml(name, local, attrs, line) {
1820
1772
  switch (local) {
1821
1773
  case "desc":
1822
- this.beginDesc("graph");
1774
+ this.beginDesc("graph", line);
1823
1775
  return;
1824
1776
  case "key":
1825
1777
  this.beginKey(attrs, line);
@@ -1838,14 +1790,24 @@ class GraphmlReader {
1838
1790
  * A child of `<key>`.
1839
1791
  * @param name - the element name
1840
1792
  * @param local - its local name
1793
+ * @param attrs - its attributes
1841
1794
  * @param line - the line
1842
1795
  */
1843
- startInKey(name, local, line) {
1796
+ startInKey(name, local, attrs, line) {
1844
1797
  switch (local) {
1845
1798
  case "desc":
1846
- this.beginDesc("key");
1799
+ this.beginDesc("key", line);
1847
1800
  return;
1848
1801
  case "default":
1802
+ this.reportUnreadAttributes("default", attrs, NO_ATTRIBUTES, line);
1803
+ if (this.pendingKey !== null && (this.pendingKey.defaultText !== null || this.pendingKey.defaultTree !== void 0)) {
1804
+ this.report.warning(
1805
+ "validation-error",
1806
+ GRAPHML_ISSUE.DUPLICATE_ATTRIBUTE,
1807
+ `key "${this.pendingKey.id ?? ""}" has a second <default>; the later one is kept`,
1808
+ { line, element: this.pendingKey.id }
1809
+ );
1810
+ }
1849
1811
  this.content.key = null;
1850
1812
  this.content.pendingKey = this.pendingKey;
1851
1813
  this.content.text = "";
@@ -1868,11 +1830,19 @@ class GraphmlReader {
1868
1830
  * @param line - the line
1869
1831
  */
1870
1832
  startInGraph(name, local, attrs, line) {
1833
+ const first = this.graphs.length === 1 && this.topGraphs === 1;
1871
1834
  switch (local) {
1872
1835
  case "desc":
1873
- if (this.graphs.length === 1) {
1874
- this.beginDesc("graph");
1836
+ if (first) {
1837
+ this.beginDesc("graph", line);
1875
1838
  } else {
1839
+ this.report.warnOnce(
1840
+ "unsupported",
1841
+ GRAPHML_ISSUE.DESC_DROPPED,
1842
+ `the <desc> of a ${this.graphs.length === 1 ? "second top-level" : "nested"} <graph> is not kept`,
1843
+ { line },
1844
+ `${GRAPHML_ISSUE.DESC_DROPPED}:graph`
1845
+ );
1876
1846
  this.ctx.push(
1877
1847
  10
1878
1848
  /* Skip */
@@ -1880,13 +1850,13 @@ class GraphmlReader {
1880
1850
  }
1881
1851
  return;
1882
1852
  case "data":
1883
- if (this.graphs.length === 1) {
1853
+ if (first) {
1884
1854
  this.beginData(attrs, line, "graph");
1885
1855
  } else {
1886
1856
  this.report.warnOnce(
1887
1857
  "unsupported",
1888
1858
  GRAPHML_ISSUE.NESTED_GRAPH_DATA,
1889
- "data of a nested <graph> cannot be kept; only the top-level graph has attributes",
1859
+ this.graphs.length === 1 ? "data of a second top-level <graph> cannot be kept; the graphs are merged and only the first one's attributes are kept" : "data of a nested <graph> cannot be kept; only the top-level graph has attributes",
1890
1860
  { line }
1891
1861
  );
1892
1862
  this.ctx.push(
@@ -1953,14 +1923,19 @@ class GraphmlReader {
1953
1923
  "<port> declarations are not kept; sourceport / targetport edge attributes are",
1954
1924
  { line }
1955
1925
  );
1956
- this.ctx.push(
1957
- 10
1958
- /* Skip */
1959
- );
1926
+ this.beginPort(attrs, line);
1960
1927
  return;
1961
1928
  case "graph": {
1962
1929
  const node = this.nodes[this.nodes.length - 1];
1963
1930
  this.materializeNode(node);
1931
+ if (node.index === INVALID_INDEX) {
1932
+ this.report.error(
1933
+ "missing-value",
1934
+ GRAPHML_ISSUE.UNKNOWN_PARENT,
1935
+ "the nodes of this nested <graph> lose their parent: the node holding it was skipped; they are read as top-level nodes",
1936
+ { line }
1937
+ );
1938
+ }
1964
1939
  this.beginGraph(attrs, line, node.index);
1965
1940
  return;
1966
1941
  }
@@ -2006,10 +1981,105 @@ class GraphmlReader {
2006
1981
  case "data":
2007
1982
  this.beginData(attrs, line, "edge");
2008
1983
  return;
1984
+ case "graph":
1985
+ this.report.warnOnce(
1986
+ "unsupported",
1987
+ GRAPHML_ISSUE.EDGE_GRAPH_DROPPED,
1988
+ "a <graph> inside an <edge> is not supported; it is dropped with the nodes and edges it holds (counted as skipped)",
1989
+ { line, element: attrs.get("id") ?? null }
1990
+ );
1991
+ this.ctx.push(
1992
+ 12
1993
+ /* Dropped */
1994
+ );
1995
+ return;
1996
+ default:
1997
+ this.unknownElement(name, line);
1998
+ }
1999
+ }
2000
+ /**
2001
+ * An element inside a dropped `<graph>` (one held by an edge): counted as skipped.
2002
+ * @param local - its local name
2003
+ */
2004
+ dropStart(local) {
2005
+ if (local === "node") {
2006
+ this.report.counts.skippedNodes++;
2007
+ } else if (local === "edge" || local === "hyperedge") {
2008
+ this.report.counts.skippedEdges++;
2009
+ }
2010
+ this.ctx.push(
2011
+ local === "data" || local === "desc" ? 10 : 12
2012
+ /* Dropped */
2013
+ );
2014
+ }
2015
+ /**
2016
+ * Open a `<port>`: its name is kept for the edge port check, its content is skipped.
2017
+ * @param attrs - its attributes
2018
+ * @param line - the line
2019
+ */
2020
+ beginPort(attrs, line) {
2021
+ this.reportUnreadAttributes("port", attrs, PORT_ATTRIBUTES, line);
2022
+ const node = this.nodes[this.nodes.length - 1];
2023
+ const name = attrs.get("name");
2024
+ if (node.id !== null && name !== void 0) {
2025
+ const id = node.restoredId ?? node.id;
2026
+ let names = this.ports.get(id);
2027
+ if (names === void 0) {
2028
+ names = /* @__PURE__ */ new Set();
2029
+ this.ports.set(id, names);
2030
+ }
2031
+ names.add(name);
2032
+ }
2033
+ this.ctx.push(
2034
+ 11
2035
+ /* Port */
2036
+ );
2037
+ }
2038
+ /**
2039
+ * A child of `<port>`: a nested port declares a name too; data and desc are skipped.
2040
+ * @param name - the element name
2041
+ * @param local - its local name
2042
+ * @param attrs - its attributes
2043
+ * @param line - the line
2044
+ */
2045
+ startInPort(name, local, attrs, line) {
2046
+ switch (local) {
2047
+ case "port":
2048
+ this.beginPort(attrs, line);
2049
+ return;
2050
+ case "data":
2051
+ case "desc":
2052
+ this.ctx.push(
2053
+ 10
2054
+ /* Skip */
2055
+ );
2056
+ return;
2009
2057
  default:
2010
2058
  this.unknownElement(name, line);
2011
2059
  }
2012
2060
  }
2061
+ /**
2062
+ * Report the `sourceport` / `targetport` values that name a port their node never declares
2063
+ * (once, with the count), now that every node has been read.
2064
+ */
2065
+ checkPorts() {
2066
+ let dangling = 0;
2067
+ let first = null;
2068
+ for (const [node, port] of this.portRefs) {
2069
+ if (this.ports.get(node)?.has(port) !== true) {
2070
+ dangling++;
2071
+ first ??= `${String(node)}:${port}`;
2072
+ }
2073
+ }
2074
+ if (dangling > 0) {
2075
+ this.report.warning(
2076
+ "missing-value",
2077
+ GRAPHML_ISSUE.DANGLING_REFERENCE,
2078
+ `${dangling} edge port reference${plural(dangling)} ${agree(dangling, "names", "name")} a port their node does not declare (first: ${first ?? ""}); the values are kept`,
2079
+ { element: first }
2080
+ );
2081
+ }
2082
+ }
2013
2083
  /**
2014
2084
  * A child of `<hyperedge>` (under the star / clique policies).
2015
2085
  * @param name - the element name
@@ -2020,6 +2090,7 @@ class GraphmlReader {
2020
2090
  startInHyperedge(name, local, attrs, line) {
2021
2091
  switch (local) {
2022
2092
  case "endpoint":
2093
+ this.reportUnreadAttributes("endpoint", attrs, ENDPOINT_ATTRIBUTES, line);
2023
2094
  this.readEndpoint(attrs, line);
2024
2095
  this.ctx.push(
2025
2096
  10
@@ -2039,6 +2110,13 @@ class GraphmlReader {
2039
2110
  );
2040
2111
  return;
2041
2112
  case "desc":
2113
+ this.report.warnOnce(
2114
+ "unsupported",
2115
+ GRAPHML_ISSUE.DESC_DROPPED,
2116
+ "the <desc> of a hyperedge is not kept by the star / clique expansions",
2117
+ { line },
2118
+ `${GRAPHML_ISSUE.DESC_DROPPED}:hyperedge`
2119
+ );
2042
2120
  this.ctx.push(
2043
2121
  10
2044
2122
  /* Skip */
@@ -2054,15 +2132,10 @@ class GraphmlReader {
2054
2132
  * @param line - the line
2055
2133
  */
2056
2134
  unknownElement(name, line) {
2057
- this.report.warnOnce(
2058
- "unsupported",
2059
- GRAPHML_ISSUE.UNKNOWN_ELEMENT,
2060
- `element <${name}> is not GraphML and was skipped`,
2061
- {
2062
- line,
2063
- element: name
2064
- }
2065
- );
2135
+ this.report.warnOnce("unsupported", GRAPHML_ISSUE.UNKNOWN_ELEMENT, unknownElementMessage(name), {
2136
+ line,
2137
+ element: name
2138
+ });
2066
2139
  this.ctx.push(
2067
2140
  10
2068
2141
  /* Skip */
@@ -2071,10 +2144,12 @@ class GraphmlReader {
2071
2144
  /**
2072
2145
  * Open a `<desc>`.
2073
2146
  * @param target - what the text describes
2147
+ * @param line - the line
2074
2148
  */
2075
- beginDesc(target) {
2149
+ beginDesc(target, line) {
2076
2150
  this.descTarget = target;
2077
2151
  this.descText = "";
2152
+ this.descLine = line;
2078
2153
  this.ctx.push(
2079
2154
  1
2080
2155
  /* Desc */
@@ -2086,6 +2161,15 @@ class GraphmlReader {
2086
2161
  if (this.descTarget === "key" && this.pendingKey !== null) {
2087
2162
  this.pendingKey.desc = text2;
2088
2163
  } else if (this.descTarget === "graph" && text2.length > 0) {
2164
+ if (this.graphDescSeen) {
2165
+ this.report.warning(
2166
+ "unsupported",
2167
+ GRAPHML_ISSUE.DESC_DROPPED,
2168
+ "a second graph-level <desc> replaces the first; the earlier text is not kept",
2169
+ { line: this.descLine }
2170
+ );
2171
+ }
2172
+ this.graphDescSeen = true;
2089
2173
  this.description = text2;
2090
2174
  }
2091
2175
  this.descTarget = null;
@@ -2094,27 +2178,49 @@ class GraphmlReader {
2094
2178
  // ------------------------------------------------------------------ graphs
2095
2179
  /**
2096
2180
  * Report, once per element kind and attribute name, an XML attribute the importer does not read:
2097
- * a GraphML `parse.*` hint as ignored, anything else as unknown. Namespace declarations and
2098
- * `xml:` / `xsi:` attributes are not data and pass silently.
2181
+ * a GraphML `parse.*` hint as ignored, anything else as not kept. Namespace declarations and
2182
+ * `xml:` / `xsi:` attributes are not data and pass silently. Beyond MAX_UNKNOWN_ATTRIBUTE_NAMES
2183
+ * distinct names per element kind the rest are counted and reported once at the end, so a file
2184
+ * with thousands of vendor attributes does not grow the report without bound.
2099
2185
  * @param kind - the element name
2100
2186
  * @param attrs - the element's attributes
2101
2187
  * @param known - the attributes the importer reads on that element
2102
2188
  * @param line - the line
2103
2189
  */
2104
2190
  reportUnreadAttributes(kind, attrs, known, line) {
2191
+ if (attrs.size === 0) {
2192
+ return;
2193
+ }
2105
2194
  for (const name of attrs.keys()) {
2106
2195
  if (known.has(name) || name === "xmlns" || /^(xmlns|xml|xsi):/.test(name)) {
2107
2196
  continue;
2108
2197
  }
2109
2198
  const hint2 = name.startsWith("parse.");
2110
2199
  const code = hint2 ? GRAPHML_ISSUE.PARSE_HINT_IGNORED : GRAPHML_ISSUE.UNKNOWN_XML_ATTRIBUTE;
2111
- this.report.warnOnce(
2112
- "unsupported",
2113
- code,
2114
- hint2 ? `the <${kind}> parse hint ${name} is ignored` : `the <${kind}> attribute ${name} is not a GraphML attribute; it is not kept`,
2115
- { line, element: name },
2116
- `${code}:${kind}:${name}`
2117
- );
2200
+ let names = this.unknownNames.get(kind);
2201
+ if (names === void 0) {
2202
+ names = /* @__PURE__ */ new Set();
2203
+ this.unknownNames.set(kind, names);
2204
+ }
2205
+ if (names.has(name)) {
2206
+ continue;
2207
+ }
2208
+ if (names.size >= MAX_UNKNOWN_ATTRIBUTE_NAMES && !hint2) {
2209
+ this.unknownOverflow.set(kind, (this.unknownOverflow.get(kind) ?? 0) + 1);
2210
+ }
2211
+ names.add(name);
2212
+ if (names.size > MAX_UNKNOWN_ATTRIBUTE_NAMES && !hint2) {
2213
+ continue;
2214
+ }
2215
+ let message;
2216
+ if (hint2) {
2217
+ message = `the <${kind}> parse hint ${name} is ignored`;
2218
+ } else if (SCHEMA_ATTRIBUTES.has(name)) {
2219
+ message = `the <${kind}> attribute ${name} is not kept`;
2220
+ } else {
2221
+ message = `the <${kind}> attribute ${name} is not a GraphML attribute; it is not kept`;
2222
+ }
2223
+ this.report.warning("unsupported", code, message, { line, element: name });
2118
2224
  }
2119
2225
  }
2120
2226
  /**
@@ -2127,17 +2233,26 @@ class GraphmlReader {
2127
2233
  beginGraph(attrs, line, parent) {
2128
2234
  this.reportUnreadAttributes("graph", attrs, GRAPH_ATTRIBUTES, line);
2129
2235
  const top = this.graphs.length === 0;
2236
+ if (top) {
2237
+ this.topGraphs++;
2238
+ }
2239
+ const graphId = attrs.get("id");
2240
+ if (graphId !== void 0 && graphId.length > 0) {
2241
+ this.graphIds.add(graphId);
2242
+ }
2130
2243
  const edgedefault = attrs.get("edgedefault");
2131
2244
  let directed;
2132
2245
  if (edgedefault === "directed" || edgedefault === "undirected") {
2133
2246
  directed = edgedefault === "directed";
2134
2247
  } else if (edgedefault === void 0) {
2135
2248
  directed = top ? this.options.defaultDirected : this.graphs[this.graphs.length - 1].directed;
2136
- this.report.warning(
2249
+ const direction = directed ? "directed" : "undirected";
2250
+ this.report.warnOnce(
2137
2251
  "validation-error",
2138
2252
  GRAPHML_ISSUE.EDGEDEFAULT_MISSING,
2139
- `<graph> has no edgedefault; read as ${directed ? "directed" : "undirected"}`,
2140
- { line }
2253
+ top ? `<graph> has no edgedefault; read as ${direction}` : `a nested <graph> has no edgedefault; it takes its container's (${direction})`,
2254
+ { line },
2255
+ `${GRAPHML_ISSUE.EDGEDEFAULT_MISSING}:${top ? "top" : "nested"}`
2141
2256
  );
2142
2257
  } else {
2143
2258
  directed = top ? this.options.defaultDirected : this.graphs[this.graphs.length - 1].directed;
@@ -2148,6 +2263,7 @@ class GraphmlReader {
2148
2263
  { line }
2149
2264
  );
2150
2265
  }
2266
+ let hints = null;
2151
2267
  if (top && this.graphSeen) {
2152
2268
  this.report.warnOnce(
2153
2269
  "unsupported",
@@ -2155,6 +2271,17 @@ class GraphmlReader {
2155
2271
  "the document holds more than one top-level <graph>; their nodes and edges are merged into one graph",
2156
2272
  { line, element: attrs.get("id") ?? null }
2157
2273
  );
2274
+ for (const name of ["parse.nodes", "parse.edges"]) {
2275
+ if (attrs.has(name)) {
2276
+ this.report.warnOnce(
2277
+ "unsupported",
2278
+ GRAPHML_ISSUE.PARSE_HINT_IGNORED,
2279
+ `the ${name} hint of a second top-level <graph> is ignored`,
2280
+ { line, element: name },
2281
+ `${GRAPHML_ISSUE.PARSE_HINT_IGNORED}:second:${name}`
2282
+ );
2283
+ }
2284
+ }
2158
2285
  } else if (top) {
2159
2286
  this.graphSeen = true;
2160
2287
  this.graphId = attrs.get("id") ?? null;
@@ -2162,6 +2289,7 @@ class GraphmlReader {
2162
2289
  this.direction.setHeader(directed, { line });
2163
2290
  const nodes = this.hint(attrs.get("parse.nodes"), "parse.nodes", line);
2164
2291
  const edges = this.hint(attrs.get("parse.edges"), "parse.edges", line);
2292
+ hints = nodes === null && edges === null ? null : { nodes, edges };
2165
2293
  if (nodes !== null || edges !== null) {
2166
2294
  try {
2167
2295
  this.sink.reserve(nodes ?? void 0, edges ?? void 0);
@@ -2180,12 +2308,32 @@ class GraphmlReader {
2180
2308
  }
2181
2309
  }
2182
2310
  }
2183
- this.graphs.push({ directed, parent });
2311
+ this.graphs.push({ directed, parent, hints, nodes: 0, edges: 0, line });
2184
2312
  this.ctx.push(
2185
2313
  4
2186
2314
  /* Graph */
2187
2315
  );
2188
2316
  }
2317
+ /** Close a `<graph>`: a top-level graph's count hints are checked against what it held. */
2318
+ finishGraph() {
2319
+ const graph = this.graphs.pop();
2320
+ if (graph?.hints === null || graph === void 0) {
2321
+ return;
2322
+ }
2323
+ for (const [name, hint2, found] of [
2324
+ ["parse.nodes", graph.hints.nodes, graph.nodes],
2325
+ ["parse.edges", graph.hints.edges, graph.edges]
2326
+ ]) {
2327
+ if (hint2 !== null && hint2 !== found) {
2328
+ this.report.warning(
2329
+ "validation-error",
2330
+ GRAPHML_ISSUE.COUNT_MISMATCH,
2331
+ `<graph ${name}="${hint2}"> but the graph holds ${found} ${name === "parse.nodes" ? "<node>" : "<edge>"} elements`,
2332
+ { line: graph.line, element: name }
2333
+ );
2334
+ }
2335
+ }
2336
+ }
2189
2337
  /**
2190
2338
  * A `parse.nodes` / `parse.edges` hint the sink can reserve; anything else is reported and ignored.
2191
2339
  * @param text - the attribute text, or undefined
@@ -2216,7 +2364,16 @@ class GraphmlReader {
2216
2364
  * @param line - the line
2217
2365
  */
2218
2366
  beginKey(attrs, line) {
2367
+ this.reportUnreadAttributes("key", attrs, KEY_ATTRIBUTES, line);
2219
2368
  const id = attrs.get("id") ?? null;
2369
+ if (id !== null && this.unknownKeyIds.delete(id)) {
2370
+ this.report.warning(
2371
+ "missing-value",
2372
+ GRAPHML_ISSUE.KEY_DECLARED_LATE,
2373
+ `key "${id}" is declared after data that uses it; those values were dropped (declare <key> before <graph>)`,
2374
+ { line, element: id }
2375
+ );
2376
+ }
2220
2377
  const forText = attrs.get("for") ?? "all";
2221
2378
  let domains;
2222
2379
  switch (forText) {
@@ -2474,8 +2631,12 @@ class GraphmlReader {
2474
2631
  * @param domain - the domain of the element holding it
2475
2632
  */
2476
2633
  beginData(attrs, line, domain) {
2634
+ this.reportUnreadAttributes("data", attrs, DATA_ATTRIBUTES, line);
2477
2635
  const keyId = attrs.get("key");
2478
2636
  const { content } = this;
2637
+ if (keyId !== void 0) {
2638
+ this.checkDuplicateData(keyId, domain, line);
2639
+ }
2479
2640
  content.key = null;
2480
2641
  content.pendingKey = null;
2481
2642
  content.domain = domain;
@@ -2490,6 +2651,7 @@ class GraphmlReader {
2490
2651
  const entries = this.keys.get(keyId);
2491
2652
  const key = entries?.find((entry) => entry.domains.includes(domain)) ?? entries?.[0];
2492
2653
  if (key === void 0) {
2654
+ this.unknownKeyIds.add(keyId);
2493
2655
  this.report.error(
2494
2656
  "validation-error",
2495
2657
  GRAPHML_ISSUE.UNKNOWN_KEY,
@@ -2512,6 +2674,35 @@ class GraphmlReader {
2512
2674
  /* Data */
2513
2675
  );
2514
2676
  }
2677
+ /**
2678
+ * Report a second `<data>` of one key on one element; the later value is kept (it overwrites).
2679
+ * @param keyId - the key
2680
+ * @param domain - the domain of the element holding it
2681
+ * @param line - the line
2682
+ */
2683
+ checkDuplicateData(keyId, domain, line) {
2684
+ let holder = null;
2685
+ if (domain === "node") {
2686
+ holder = this.nodes.at(-1) ?? null;
2687
+ } else if (domain === "edge") {
2688
+ holder = this.edge;
2689
+ } else {
2690
+ holder = this.graphKeys;
2691
+ }
2692
+ if (holder === null) {
2693
+ return;
2694
+ }
2695
+ holder.keys ??= /* @__PURE__ */ new Set();
2696
+ if (holder.keys.has(keyId)) {
2697
+ this.report.warning(
2698
+ "validation-error",
2699
+ GRAPHML_ISSUE.DUPLICATE_ATTRIBUTE,
2700
+ `a second <data key="${keyId}"> on one ${domain}; the later value is kept`,
2701
+ { line, element: keyId }
2702
+ );
2703
+ }
2704
+ holder.keys.add(keyId);
2705
+ }
2515
2706
  /**
2516
2707
  * A child element inside `<data>` / `<default>`: the content becomes a tree.
2517
2708
  * @param name - the element name
@@ -2568,9 +2759,16 @@ class GraphmlReader {
2568
2759
  case "node": {
2569
2760
  const node = this.nodes[this.nodes.length - 1];
2570
2761
  if (key.originalId) {
2571
- if (typeof value === "string") {
2572
- node.restoredId = value;
2762
+ if (typeof value !== "string" || node.index !== INVALID_INDEX) {
2763
+ this.report.warning(
2764
+ "validation-error",
2765
+ GRAPHML_ISSUE.ORIGINAL_ID_IGNORED,
2766
+ typeof value === "string" ? `the ${ORIGINAL_ID_ATTRIBUTE} value comes after the node's nested <graph>, which added the node under its written id; it is not restored` : `the ${ORIGINAL_ID_ATTRIBUTE} value holds elements, not text; it is not restored`,
2767
+ where
2768
+ );
2769
+ return;
2573
2770
  }
2771
+ node.restoredId = value;
2574
2772
  return;
2575
2773
  }
2576
2774
  if (key.yfiles) {
@@ -2602,8 +2800,18 @@ class GraphmlReader {
2602
2800
  );
2603
2801
  return;
2604
2802
  }
2803
+ if (edge.weightKey !== null && edge.weightKey !== key.id) {
2804
+ this.report.warning(
2805
+ "validation-error",
2806
+ GRAPHML_ISSUE.DUPLICATE_ATTRIBUTE,
2807
+ `the edge has values of two weight keys ("${edge.weightKey}" and "${key.id}"); the later one is kept`,
2808
+ where
2809
+ );
2810
+ }
2811
+ edge.weightKey = key.id;
2605
2812
  try {
2606
- edge.weight = parseWeightText(value);
2813
+ edge.weight = parseWeightText(value, this.report);
2814
+ this.checkOverflow(value, edge.weight, key.name, where);
2607
2815
  } catch (err) {
2608
2816
  this.skipEdge(edge);
2609
2817
  this.report.recordError(err, where);
@@ -2668,7 +2876,18 @@ class GraphmlReader {
2668
2876
  */
2669
2877
  graphics(domain, key, tree, where) {
2670
2878
  const out = [];
2671
- for (const [field, value] of graphicsValues(domain, tree)) {
2879
+ const unmapped = [];
2880
+ const values = graphicsValues(domain, tree, unmapped);
2881
+ for (const field of unmapped) {
2882
+ this.report.warnOnce(
2883
+ "validation-error",
2884
+ GRAPHML_ISSUE.YFILES_VALUE,
2885
+ `a yFiles ${domain} ${field} that is not a number is not mapped to its yfiles column (the graphics tree is kept)`,
2886
+ where,
2887
+ `${GRAPHML_ISSUE.YFILES_VALUE}:${domain}:${field}`
2888
+ );
2889
+ }
2890
+ for (const [field, value] of values) {
2672
2891
  const id = `${domain}:${field}`;
2673
2892
  let handle = this.graphicsColumns.get(id);
2674
2893
  if (handle === void 0) {
@@ -2732,12 +2951,31 @@ class GraphmlReader {
2732
2951
  { line: where.line, element: target.name }
2733
2952
  );
2734
2953
  }
2954
+ this.checkOverflow(value, parsed, target.name, where);
2735
2955
  return parsed;
2736
2956
  } catch (err) {
2737
2957
  this.report.recordError(err, where);
2738
2958
  return void 0;
2739
2959
  }
2740
2960
  }
2961
+ /**
2962
+ * Report (once per column) a finite number text too large for a double, stored as Infinity.
2963
+ * @param text - the value text
2964
+ * @param value - the parsed value
2965
+ * @param column - the column name
2966
+ * @param where - the location
2967
+ */
2968
+ checkOverflow(text2, value, column, where) {
2969
+ if (typeof value === "number" && overflowsToInfinity(text2)) {
2970
+ this.report.warnOnce(
2971
+ "precision",
2972
+ PRECISION_CODE,
2973
+ `values of "${column}" beyond the double range (${text2.trim()}) are stored as Infinity`,
2974
+ { line: where.line, element: column },
2975
+ `${PRECISION_CODE}:overflow:${column}`
2976
+ );
2977
+ }
2978
+ }
2741
2979
  // ------------------------------------------------------------------ nodes
2742
2980
  /**
2743
2981
  * Open a `<node>`; it is added to the sink when its data is complete (or a nested graph
@@ -2748,6 +2986,7 @@ class GraphmlReader {
2748
2986
  beginNode(attrs, line) {
2749
2987
  this.reportUnreadAttributes("node", attrs, NODE_ATTRIBUTES, line);
2750
2988
  const graph = this.graphs[this.graphs.length - 1];
2989
+ graph.nodes++;
2751
2990
  const state = {
2752
2991
  id: null,
2753
2992
  idText: null,
@@ -2756,7 +2995,8 @@ class GraphmlReader {
2756
2995
  pending: [],
2757
2996
  restoredId: null,
2758
2997
  failed: false,
2759
- line
2998
+ line,
2999
+ keys: null
2760
3000
  };
2761
3001
  const idText = attrs.get("id");
2762
3002
  if (idText === void 0 || idText.length === 0) {
@@ -2797,7 +3037,14 @@ class GraphmlReader {
2797
3037
  try {
2798
3038
  const existing = this.sink.indexOf(id);
2799
3039
  const index = this.sink.addNode(id);
2800
- if (existing !== INVALID_INDEX && this.declared.has(index)) {
3040
+ if (existing !== INVALID_INDEX && this.hubs.has(index)) {
3041
+ this.report.warning(
3042
+ "validation-error",
3043
+ GRAPHML_ISSUE.HUB_ID_CLASH,
3044
+ `node "${String(id)}" has the id of the hub a star-expanded hyperedge created earlier; the node is merged into the hub`,
3045
+ { line: node.line, element: String(id) }
3046
+ );
3047
+ } else if (existing !== INVALID_INDEX && this.declared.has(index)) {
2801
3048
  this.report.warning(
2802
3049
  "validation-error",
2803
3050
  GRAPHML_ISSUE.DUPLICATE_NODE,
@@ -2867,21 +3114,28 @@ class GraphmlReader {
2867
3114
  beginEdge(attrs, line) {
2868
3115
  this.reportUnreadAttributes("edge", attrs, EDGE_ATTRIBUTES, line);
2869
3116
  const graph = this.graphs[this.graphs.length - 1];
3117
+ graph.edges++;
3118
+ const idText = attrs.get("id");
3119
+ const sourceText = attrs.get("source");
3120
+ const targetText = attrs.get("target");
2870
3121
  const edge = {
2871
3122
  source: null,
2872
3123
  target: null,
2873
- id: attrs.get("id") ?? null,
3124
+ // an exporter that writes id="" for an edge without one: the same as no id
3125
+ id: idText === void 0 || idText.length === 0 ? null : idText,
2874
3126
  kind: graph.directed ? "directed" : "undirected",
2875
3127
  sourcePort: attrs.get("sourceport") ?? null,
2876
3128
  targetPort: attrs.get("targetport") ?? null,
2877
3129
  weight: void 0,
2878
3130
  pending: [],
2879
3131
  failed: false,
2880
- line
3132
+ line,
3133
+ keys: null,
3134
+ weightKey: null,
3135
+ sourceText: sourceText ?? null,
3136
+ targetText: targetText ?? null
2881
3137
  };
2882
3138
  const where = { line, element: edge.id };
2883
- const sourceText = attrs.get("source");
2884
- const targetText = attrs.get("target");
2885
3139
  if (sourceText === void 0 || sourceText.length === 0) {
2886
3140
  this.skipEdge(edge);
2887
3141
  this.report.error("missing-value", GRAPHML_ISSUE.MISSING_ENDPOINT, "<edge> without a source", where);
@@ -2901,16 +3155,16 @@ class GraphmlReader {
2901
3155
  }
2902
3156
  const directedText = attrs.get("directed");
2903
3157
  if (directedText !== void 0) {
2904
- if (directedText === "true") {
3158
+ if (directedText === "true" || directedText === "1") {
2905
3159
  edge.kind = "directed";
2906
- } else if (directedText === "false") {
3160
+ } else if (directedText === "false" || directedText === "0") {
2907
3161
  edge.kind = "undirected";
2908
3162
  } else {
2909
3163
  this.skipEdge(edge);
2910
3164
  this.report.error(
2911
3165
  "validation-error",
2912
3166
  GRAPHML_ISSUE.INVALID_DIRECTED,
2913
- `directed="${directedText}" is neither true nor false`,
3167
+ `directed="${directedText}" is neither true nor false (nor 1 or 0)`,
2914
3168
  where
2915
3169
  );
2916
3170
  }
@@ -2934,6 +3188,23 @@ class GraphmlReader {
2934
3188
  this.skipEdge(edge);
2935
3189
  return;
2936
3190
  }
3191
+ if (!this.options.addMissingNodes && (this.sink.indexOf(edge.source) === INVALID_INDEX || this.sink.indexOf(edge.target) === INVALID_INDEX) || edge.id !== null && this.deferredEdgeIds.has(edge.id)) {
3192
+ if (edge.id !== null) {
3193
+ this.deferredEdgeIds.add(edge.id);
3194
+ }
3195
+ this.deferred.push(edge);
3196
+ return;
3197
+ }
3198
+ this.addEdge(edge);
3199
+ }
3200
+ /**
3201
+ * Push an edge through the direction resolver and write its values.
3202
+ * @param edge - the edge, its endpoints known
3203
+ */
3204
+ addEdge(edge) {
3205
+ if (edge.source === null || edge.target === null) {
3206
+ return;
3207
+ }
2937
3208
  const element = edge.id ?? `${String(edge.source)} -> ${String(edge.target)}`;
2938
3209
  const where = { line: edge.line, element };
2939
3210
  try {
@@ -2941,6 +3212,8 @@ class GraphmlReader {
2941
3212
  this.requireNode(edge.source);
2942
3213
  this.requireNode(edge.target);
2943
3214
  }
3215
+ this.checkGraphEndpoint(edge.source, edge.sourceText, where);
3216
+ this.checkGraphEndpoint(edge.target, edge.targetText, where);
2944
3217
  if (edge.id !== null && this.edgeIds.has(edge.id)) {
2945
3218
  throw new GraphFormatError("E_DUPLICATE_EDGE_ID", `edge id "${edge.id}" is used twice`, {
2946
3219
  id: edge.id
@@ -2957,9 +3230,11 @@ class GraphmlReader {
2957
3230
  }
2958
3231
  if (edge.sourcePort !== null) {
2959
3232
  this.sink.setEdgeValue(this.portColumn("source"), e, edge.sourcePort);
3233
+ this.portRefs.push([edge.source, edge.sourcePort]);
2960
3234
  }
2961
3235
  if (edge.targetPort !== null) {
2962
3236
  this.sink.setEdgeValue(this.portColumn("target"), e, edge.targetPort);
3237
+ this.portRefs.push([edge.target, edge.targetPort]);
2963
3238
  }
2964
3239
  const { pending } = edge;
2965
3240
  for (let i = 0; i < pending.length; i += 2) {
@@ -2980,6 +3255,23 @@ class GraphmlReader {
2980
3255
  this.report.counts.skippedEdges++;
2981
3256
  }
2982
3257
  }
3258
+ /**
3259
+ * Report an endpoint that names a nested `<graph>` rather than a node (a node of that id is
3260
+ * then created under addMissingNodes).
3261
+ * @param id - the endpoint id
3262
+ * @param text - the endpoint as written, or null
3263
+ * @param where - the edge's location
3264
+ */
3265
+ checkGraphEndpoint(id, text2, where) {
3266
+ if (text2 !== null && this.graphIds.has(text2) && this.sink.indexOf(id) === INVALID_INDEX) {
3267
+ this.report.warning(
3268
+ "validation-error",
3269
+ GRAPHML_ISSUE.GRAPH_ENDPOINT,
3270
+ `edge endpoint "${text2}" names a <graph>, not a node; a node "${text2}" is created`,
3271
+ where
3272
+ );
3273
+ }
3274
+ }
2983
3275
  /**
2984
3276
  * E_UNKNOWN_NODE when an endpoint was never declared (addMissingNodes false enforced by the
2985
3277
  * importer, whatever the sink allows).
@@ -3045,6 +3337,7 @@ class GraphmlReader {
3045
3337
  * @param line - the line
3046
3338
  */
3047
3339
  beginHyperedge(attrs, line) {
3340
+ this.reportUnreadAttributes("hyperedge", attrs, HYPEREDGE_ATTRIBUTES, line);
3048
3341
  const id = attrs.get("id") ?? null;
3049
3342
  const where = { line, element: id };
3050
3343
  switch (this.options.hyperedges) {
@@ -3131,12 +3424,48 @@ class GraphmlReader {
3131
3424
  if (hyperedge.failed) {
3132
3425
  return;
3133
3426
  }
3427
+ if (hyperedge.endpoints.length === 0) {
3428
+ this.skipEdge(hyperedge);
3429
+ this.report.error(
3430
+ "missing-value",
3431
+ GRAPHML_ISSUE.HYPEREDGE_ENDPOINT,
3432
+ "<hyperedge> without endpoints yields no edge",
3433
+ { line: hyperedge.line, element: hyperedge.id }
3434
+ );
3435
+ return;
3436
+ }
3437
+ if (!this.options.addMissingNodes && hyperedge.endpoints.some((endpoint) => this.sink.indexOf(endpoint.node) === INVALID_INDEX)) {
3438
+ this.deferred.push(hyperedge);
3439
+ return;
3440
+ }
3441
+ this.expandHyperedge(hyperedge);
3442
+ }
3443
+ /**
3444
+ * Expand a hyperedge to a star or a clique; under addMissingNodes false every endpoint must be
3445
+ * a declared node.
3446
+ * @param hyperedge - the hyperedge, its endpoints read
3447
+ */
3448
+ expandHyperedge(hyperedge) {
3134
3449
  const where = { line: hyperedge.line, element: hyperedge.id };
3135
3450
  try {
3451
+ for (const endpoint of hyperedge.endpoints) {
3452
+ if (!this.options.addMissingNodes) {
3453
+ this.requireNode(endpoint.node);
3454
+ }
3455
+ }
3456
+ for (const node of new Set(hyperedge.endpoints.map((endpoint) => endpoint.node))) {
3457
+ this.countEndpoints(node, node);
3458
+ }
3136
3459
  if (this.options.hyperedges === "star") {
3137
3460
  this.expandStar(hyperedge, where);
3138
- } else {
3139
- this.expandClique(hyperedge, where);
3461
+ } else if (this.expandClique(hyperedge, where) === 0) {
3462
+ this.skipEdge(hyperedge);
3463
+ this.report.error(
3464
+ "validation-error",
3465
+ GRAPHML_ISSUE.HYPEREDGE_ENDPOINT,
3466
+ "no two endpoints of this hyperedge can be joined (all in, all out, or only one); it yields no edge",
3467
+ where
3468
+ );
3140
3469
  }
3141
3470
  } catch (err) {
3142
3471
  this.skipEdge(hyperedge);
@@ -3158,6 +3487,7 @@ class GraphmlReader {
3158
3487
  }
3159
3488
  const hub = this.sink.addNode(hubId);
3160
3489
  this.declared.add(hub);
3490
+ this.hubs.add(hub);
3161
3491
  this.report.counts.nodes++;
3162
3492
  if (this.hubHandle === INVALID_INDEX) {
3163
3493
  this.hubHandle = this.sink.declareNodeColumn({
@@ -3193,9 +3523,11 @@ class GraphmlReader {
3193
3523
  * joined undirected to every other endpoint; two endpoints of the same direction are not joined.
3194
3524
  * @param hyperedge - the hyperedge
3195
3525
  * @param where - the location for issues
3526
+ * @returns the number of edge elements added
3196
3527
  */
3197
3528
  expandClique(hyperedge, where) {
3198
3529
  const { endpoints } = hyperedge;
3530
+ let added = 0;
3199
3531
  for (let i = 0; i < endpoints.length; i++) {
3200
3532
  for (let j = i + 1; j < endpoints.length; j++) {
3201
3533
  const a = endpoints[i];
@@ -3210,9 +3542,11 @@ class GraphmlReader {
3210
3542
  } else {
3211
3543
  continue;
3212
3544
  }
3545
+ added++;
3213
3546
  this.report.counts.edges += this.sink.edgeCount - before;
3214
3547
  }
3215
3548
  }
3549
+ return added;
3216
3550
  }
3217
3551
  // ------------------------------------------------------------------ options and ids
3218
3552
  /**
@@ -3296,11 +3630,11 @@ function resolveYfiles(options) {
3296
3630
  return value;
3297
3631
  }
3298
3632
  function sniffGraphml(head) {
3299
- const text2 = new TextDecoder("utf-8", { fatal: false }).decode(head.subarray(0, SNIFF_BYTES));
3633
+ const text2 = sniffXmlText(head.subarray(0, SNIFF_BYTES));
3300
3634
  if (!/^\uFEFF?\s*</.test(text2)) {
3301
3635
  return 0;
3302
3636
  }
3303
- const root = text2.indexOf("<graphml");
3637
+ const root = text2.search(/<([\w.-]+:)?graphml[\s>/]/);
3304
3638
  if (root >= 0) {
3305
3639
  return text2.includes(GRAPHML_NAMESPACE, root) ? 1 : 0.9;
3306
3640
  }
@@ -3314,8 +3648,14 @@ async function importGraphml(input, sink, options) {
3314
3648
  reportUnusedOptions(options, report, USED_OPTIONS);
3315
3649
  const reader = new GraphmlReader(sink, report, common, yfilesMode);
3316
3650
  try {
3317
- await tokenizeXml(textChunks(input, report, { ...common, declaredEncoding: xmlDeclaredEncoding }), reader);
3651
+ await tokenizeXml(
3652
+ textChunks(input, report, { ...common, declaredEncoding: xmlDeclaredEncoding, xml: true }),
3653
+ reader
3654
+ );
3318
3655
  } catch (err) {
3656
+ if (err instanceof XmlEmptyInputError) {
3657
+ report.fail(GRAPHML_ISSUE.EMPTY_INPUT, "the input is empty (no markup at all)", { line: err.line });
3658
+ }
3319
3659
  if (err instanceof XmlSyntaxError) {
3320
3660
  report.fail(GRAPHML_ISSUE.XML_SYNTAX, err.message, { line: err.line });
3321
3661
  }
@@ -3327,15 +3667,34 @@ async function importGraphml(input, sink, options) {
3327
3667
  }
3328
3668
  const graphmlImporter = Object.freeze({
3329
3669
  format: FORMAT,
3670
+ options: Object.freeze(["yfiles"]),
3330
3671
  extensions: EXTENSIONS,
3331
3672
  mimeTypes: MIME_TYPES,
3332
3673
  sniff: sniffGraphml,
3333
3674
  import: importGraphml
3334
3675
  });
3676
+ const GRAPHML_ELEMENTS = /* @__PURE__ */ new Set([
3677
+ "graphml",
3678
+ "key",
3679
+ "default",
3680
+ "graph",
3681
+ "node",
3682
+ "edge",
3683
+ "hyperedge",
3684
+ "endpoint",
3685
+ "port",
3686
+ "data",
3687
+ "desc",
3688
+ "locator"
3689
+ ]);
3690
+ function unknownElementMessage(name) {
3691
+ if (name === "key") {
3692
+ return "element <key> is only allowed as a child of <graphml>, before the first <graph>; it was skipped";
3693
+ }
3694
+ return GRAPHML_ELEMENTS.has(name) ? `element <${name}> is not allowed at this place in a GraphML file and was skipped` : `element <${name}> is not GraphML and was skipped`;
3695
+ }
3335
3696
  export {
3336
- GRAPHML_ISSUE as G,
3337
- GRAPHML_LOSS as a,
3338
- graphmlImporter as b,
3697
+ graphmlImporter as a,
3339
3698
  graphmlExporter as g
3340
3699
  };
3341
- //# sourceMappingURL=importer-DIrbbnAf.js.map
3700
+ //# sourceMappingURL=importer-Dku_VAIY.js.map