@graphty/graph-io 0.3.24 → 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
package/dist/graph-io.js CHANGED
@@ -1,41 +1,446 @@
1
- import { ag as describe, w as ImportReportBuilder, y as throwIfAborted } from "./chunks/report-B1z4WT9e.js";
2
- import { A, m, n, Z, ah, B, C, a5, ai, l, j, aj, ak, D, a, i, c, al, d, J, a4, u, E, am, G, an, I, a8, b, a2, r, s, K, ao, ap, e, f, af, M, a9, aq, aa, N, $, O, ar, ab, h, as, P, at, a6, ac, R, S, p, o, a3, au, g, t, ae, ad, a1, T, k, Y, q, U, av, a7, W, a0, aw, ax, H, ay, az, aA, L, aB, aC, aD, aE, aF, X, aG, F, z, V, v, x } from "./chunks/report-B1z4WT9e.js";
3
- import { C as C2, c as c2, a as a10 } from "./chunks/children-CL3Cy0ez.js";
4
- import { GraphFormatError, GraphBuilder } from "@graphty/graph-format";
1
+ import { INVALID_INDEX, GraphFormatError, GraphBuilder } from "@graphty/graph-format";
2
+ import { GraphBuilder as GraphBuilder2, GraphFormatError as GraphFormatError2, INVALID_INDEX as INVALID_INDEX2 } from "@graphty/graph-format";
3
+ import { al as resolveImportOptions, a8 as ImportReportBuilder, ao as reportSinkOptions, an as reportUnusedOptions, ar as IdCoercer, aq as DirectionResolver, az as LineReader, am as throwIfAborted, aL as parseWeightText, aM as isAbortError, aN as BAD_LINE_CODE, aO as messageOf, aP as describe, b as plural, aQ as UNKNOWN_OPTION_CODE, a7 as chooseGraph, aR as normalizeInput, aS as foreignKind, E as EMPTY_INPUT_CODE, aT as ImportError, aU as FETCH_CODE, $ as agree, aV as EDGES_MERGED_CODE, aW as SELF_LOOPS_DROPPED_CODE, O as OPTION_IGNORED_CODE, aX as WEIGHT_NOT_FOUND_CODE, aY as lockReader, aZ as abortable } from "./chunks/export-BTI4yQgy.js";
4
+ import { ae, Y, V, B, a_, a3, at, a$, C, b0, A, b1, k, j, i, b2, b3, b4, D, d, o, b5, m, u, n, F, b6, v, x, b7, b8, aB, af, H, I, b9, J, G, ba, y, z, bb, a2, L, s, t, M, l, W, T, bc, bd, aA, be, bf, N, bg, bh, Q, ai, bi, P, aD, ay, au, K, R, bj, ag, S, Z, _, bk, f, ah, ak, bl, bm, bn, ad, aC, U, g, w, q, bo, h, bp, bq, aj, ax, X, aH, c, a, br, aI, bs, a1, bt, bu, e, bv, aF, aa, ab, bw, aG, ap, bx, by, bz, bA, aK, bB, p, bC, bD, r, aE, a4 } from "./chunks/export-BTI4yQgy.js";
5
+ import { T as TextCellWriter } from "./chunks/text-DmcUs5_Q.js";
6
+ import { W as W2, i as i2, a as a5, p as p2 } from "./chunks/text-DmcUs5_Q.js";
7
+ import { C as C2, c as c2, a as a6 } from "./chunks/children-CL3Cy0ez.js";
8
+ import { c as collectBytes } from "./chunks/writer-DxjgHwSe.js";
9
+ import { D as D2, d as d2, e as e2, j as j2, t as t2 } from "./chunks/writer-DxjgHwSe.js";
5
10
  import { csvImporter, csvExporter } from "./csv.js";
6
11
  import { CSV_CAPABILITIES, CSV_ISSUE, CSV_LOSS } from "./csv.js";
7
- import { c as cxImporter } from "./chunks/importer-DET1tg6s.js";
8
- import { C as C3 } from "./chunks/importer-DET1tg6s.js";
9
- import { c as cx2Exporter } from "./chunks/exporter-BGrsWamJ.js";
10
- import { C as C4, a as a11 } from "./chunks/exporter-BGrsWamJ.js";
11
- import { c as cx2Importer } from "./chunks/importer-vi3bSdtw.js";
12
- import { C as C5 } from "./chunks/importer-vi3bSdtw.js";
13
- import { c as cysImporter } from "./chunks/importer-DD-xv9_Y.js";
14
- import { C as C6 } from "./chunks/importer-DD-xv9_Y.js";
15
- import { b as dotImporter, d as dotExporter } from "./chunks/importer-BWY2FFc5.js";
16
- import { D as D2, a as a12 } from "./chunks/importer-BWY2FFc5.js";
12
+ import { d as cxImporter, c as cxExporter } from "./chunks/importer-DCjOvO7U.js";
13
+ import { C as C3, a as a7, b } from "./chunks/importer-DCjOvO7U.js";
14
+ import { c as cx2Exporter } from "./chunks/exporter-Dxh231ZF.js";
15
+ import { C as C4, a as a8 } from "./chunks/exporter-Dxh231ZF.js";
16
+ import { c as cx2Importer } from "./chunks/importer-DfVu6j59.js";
17
+ import { C as C5 } from "./chunks/importer-DfVu6j59.js";
18
+ import { d as cysImporter, c as cysExporter } from "./chunks/importer-90YWhJoF.js";
19
+ import { C as C6, a as a9, b as b10 } from "./chunks/importer-90YWhJoF.js";
20
+ import { b as dotImporter, d as dotExporter } from "./chunks/importer-BfIsp1f9.js";
21
+ import { D as D3, a as a10 } from "./chunks/importer-BfIsp1f9.js";
17
22
  import { gexfImporter, gexfExporter } from "./gexf.js";
18
23
  import { GEXF_1_2_CAPABILITIES, GEXF_ISSUE, GEXF_LOSS } from "./gexf.js";
19
24
  import { gmlImporter, gmlExporter } from "./gml.js";
20
25
  import { GML_ISSUE, GML_LOSS } from "./gml.js";
21
- import { b as graphmlImporter, g as graphmlExporter } from "./chunks/importer-DIrbbnAf.js";
22
- import { G as G2, a as a13 } from "./chunks/importer-DIrbbnAf.js";
23
- import { r as rankFormats, S as SNIFF_HEAD_BYTES, e as jsonImporter, c as jsonExporter } from "./chunks/importer-eUREhBGj.js";
24
- import { G as G3, J as J2, a as a14, b as b2, d as d2, f as f2, h as h2, j as j2, n as n2, s as s2, g as g2 } from "./chunks/importer-eUREhBGj.js";
26
+ import { a as graphmlImporter, g as graphmlExporter } from "./chunks/importer-Dku_VAIY.js";
27
+ import { r as rankFormats, S as SNIFF_HEAD_BYTES, e as jsonImporter, c as jsonExporter } from "./chunks/exporter-Cra2GYcN.js";
28
+ import { G as G2, J as J2, a as a11, b as b11, d as d3, g as g2, h as h2, j as j3, f as f2, n as n2, s as s2, i as i3 } from "./chunks/exporter-Cra2GYcN.js";
25
29
  import { neo4jImporter, neo4jExporter } from "./neo4j.js";
26
- import { ID_SPACE_COLUMN, LABELS_COLUMN, NEO4J_CAPABILITIES, NEO4J_ISSUE, NEO4J_LOSS, ORIGINAL_ID_COLUMN, TYPE_COLUMN } from "./neo4j.js";
27
- import { o as oboImporter } from "./chunks/importer-DEcKhsmQ.js";
28
- import { O as O2 } from "./chunks/importer-DEcKhsmQ.js";
29
- import { b as pajekImporter, p as pajekExporter } from "./chunks/importer-zGLo8Dg_.js";
30
- import { P as P2, a as a15 } from "./chunks/importer-zGLo8Dg_.js";
31
- import { x as xgmmlExporter } from "./chunks/exporter-DIeGJXAZ.js";
32
- import { x as xgmmlImporter } from "./chunks/importer-D_e7e7LX.js";
33
- import { X as X2, a as a16 } from "./chunks/importer-D_e7e7LX.js";
34
- import { L as L2, N as N2, c as c3, a as a17, i as i2, m as m2, s as s3 } from "./chunks/export-Bh60Dv-n.js";
35
- import { e as e2, b as b3, f as f3, a as a18, c as c4, d as d3, i as i3, p as p2 } from "./chunks/weights-Dzba96G3.js";
36
- import { T as T2, W as W2, i as i4, a as a19, p as p3 } from "./chunks/text-Dr0Ifpag.js";
37
- import { D as D3, c as c5, d as d4, e as e3, j as j3, t as t2 } from "./chunks/writer-C7flM-Ih.js";
38
- import { X as X3, b as b4, h as h3, t as t3, x as x2 } from "./chunks/escape-B-tkk_Cl.js";
30
+ import { ID_SPACE_COLUMN, LABELS_COLUMN, NEO4J_CAPABILITIES, NEO4J_ISSUE, NEO4J_LOSS, ORIGINAL_ID_COLUMN, TYPE_COLUMN, exportNeo4jFiles } from "./neo4j.js";
31
+ import { c as oboImporter, o as oboExporter } from "./chunks/exporter-BMqk5oxW.js";
32
+ import { O, a as a12, b as b12 } from "./chunks/exporter-BMqk5oxW.js";
33
+ import { b as pajekImporter, p as pajekExporter } from "./chunks/importer-C_TEA1zJ.js";
34
+ import { P as P2, a as a13 } from "./chunks/importer-C_TEA1zJ.js";
35
+ import { x as xgmmlExporter } from "./chunks/exporter-tne475KK.js";
36
+ import { x as xgmmlImporter } from "./chunks/importer-Bcl1d4xH.js";
37
+ import { X as X2, a as a14 } from "./chunks/importer-Bcl1d4xH.js";
38
+ import { G as G3, a as a15 } from "./chunks/constants-BCsFsMj4.js";
39
+ import { X as X3, b as b13, h as h3, t as t3, x as x2 } from "./chunks/escape-D0g6NNUy.js";
40
+ const USED = /* @__PURE__ */ new Set(["ids", "defaultDirected", "weightFrom", "addMissingNodes"]);
41
+ function defineLineFormat(definition) {
42
+ const { format, extensions, mimeTypes = [], directed = false, comment = "#", sniff: sniff2, parseLine } = definition;
43
+ const importer = {
44
+ format,
45
+ extensions,
46
+ mimeTypes,
47
+ options: [],
48
+ import: async (input, sink, options) => {
49
+ const opts = resolveImportOptions(options, {
50
+ ids: "canonical",
51
+ defaultDirected: directed,
52
+ weightFrom: "weight"
53
+ });
54
+ const report = new ImportReportBuilder(format, opts.errorLimit);
55
+ reportSinkOptions(sink, options, report);
56
+ reportUnusedOptions(options, report, USED);
57
+ const ids = new IdCoercer(opts.ids);
58
+ const edges = new DirectionResolver(sink, report, opts.onMixedDirection);
59
+ const kind = opts.defaultDirected ? "directed" : "undirected";
60
+ edges.setHeader(opts.defaultDirected);
61
+ const attributes = new AttributeWriter(sink, report, opts.weightFrom);
62
+ const write = (domain, row, values) => {
63
+ attributes.write(domain, row, values);
64
+ };
65
+ const addNode = (id) => {
66
+ const nodeId = ids.text(id);
67
+ if (sink.indexOf(nodeId) === INVALID_INDEX) {
68
+ report.counts.nodes++;
69
+ }
70
+ return sink.addNode(nodeId);
71
+ };
72
+ let line = 0;
73
+ const graph = {
74
+ node: (id, attributes2) => {
75
+ write("node", addNode(id), attributes2);
76
+ },
77
+ edge: (source, target, attributes2) => {
78
+ const raw = opts.weightFrom === null ? void 0 : attributes2?.[opts.weightFrom];
79
+ const weight = raw === null || raw === void 0 ? void 0 : parseWeightText(String(raw), report);
80
+ const [s3, t4] = [ids.text(source), ids.text(target)];
81
+ const added = new Set([s3, t4].filter((id) => sink.indexOf(id) === INVALID_INDEX)).size;
82
+ const edge = edges.addEdge(s3, t4, kind, weight, { line });
83
+ report.counts.nodes += added;
84
+ report.counts.edges++;
85
+ write("edge", edge, attributes2);
86
+ }
87
+ };
88
+ const lines = new LineReader(input, report, opts);
89
+ for await (const text of lines) {
90
+ ({ line } = lines);
91
+ if (line % 64 === 0) {
92
+ throwIfAborted(opts.signal);
93
+ }
94
+ const trimmed = text.trim();
95
+ if (trimmed === "" || comment !== null && trimmed.startsWith(comment)) {
96
+ continue;
97
+ }
98
+ try {
99
+ parseLine(trimmed.split(/\s+/), graph, text);
100
+ } catch (err) {
101
+ recordLineError(report, err, line);
102
+ }
103
+ }
104
+ throwIfAborted(opts.signal);
105
+ return report.finish();
106
+ }
107
+ };
108
+ return Object.freeze(sniff2 === void 0 ? importer : { ...importer, sniff: sniff2 });
109
+ }
110
+ function recordLineError(report, err, line) {
111
+ if (isAbortError(err)) {
112
+ throw err;
113
+ }
114
+ if (err instanceof GraphFormatError) {
115
+ report.recordError(err, { line });
116
+ } else {
117
+ report.error("parse-error", BAD_LINE_CODE, err instanceof Error ? err.message : messageOf(err), { line });
118
+ }
119
+ }
120
+ class AttributeWriter {
121
+ /**
122
+ * Create a writer.
123
+ * @param sink - the sink
124
+ * @param report - the report
125
+ * @param weightFrom - the edge attribute read as the weight (not written as a column), or null
126
+ */
127
+ constructor(sink, report, weightFrom) {
128
+ this.sink = sink;
129
+ this.report = report;
130
+ this.weightFrom = weightFrom;
131
+ this.writers = { node: /* @__PURE__ */ new Map(), edge: /* @__PURE__ */ new Map() };
132
+ }
133
+ /**
134
+ * Write one element's attributes; null and undefined values are left unset.
135
+ * @param domain - node or edge
136
+ * @param row - the element's index
137
+ * @param attributes - the attributes, or undefined
138
+ */
139
+ write(domain, row, attributes) {
140
+ for (const [name, value] of Object.entries(attributes ?? {})) {
141
+ if (value === null || value === void 0 || domain === "edge" && name === this.weightFrom) {
142
+ continue;
143
+ }
144
+ if (name === "label") {
145
+ this.writeLabel(domain, row, String(value));
146
+ continue;
147
+ }
148
+ let writer = this.writers[domain].get(name);
149
+ if (writer === void 0) {
150
+ writer = new TextCellWriter(name, domain, this.sink, this.report);
151
+ this.writers[domain].set(name, writer);
152
+ }
153
+ writer.write(row, String(value));
154
+ }
155
+ }
156
+ /**
157
+ * Write a label: text, whatever it looks like, in the column that byRole("label") finds.
158
+ * @param domain - node or edge
159
+ * @param row - the element's index
160
+ * @param text - the label
161
+ */
162
+ writeLabel(domain, row, text) {
163
+ const decl = { name: "label", dtype: "string", role: "label" };
164
+ if (domain === "node") {
165
+ this.sink.setNodeValue(this.sink.declareNodeColumn(decl), row, text);
166
+ } else {
167
+ this.sink.setEdgeValue(this.sink.declareEdgeColumn(decl), row, text);
168
+ }
169
+ }
170
+ }
171
+ function compareSnapshots(expected, actual, options = {}) {
172
+ const diffs = [];
173
+ const limit = options.limit ?? 50;
174
+ const tolerance = options.tolerance ?? 0;
175
+ const ctx = {
176
+ options,
177
+ diff: (path, e3, a16, message) => {
178
+ diffs.push({
179
+ path,
180
+ expected: e3,
181
+ actual: a16,
182
+ message: message ?? `${path}: expected ${show(e3)}, got ${show(a16)}`
183
+ });
184
+ if (diffs.length >= limit) {
185
+ throw new LimitReached();
186
+ }
187
+ },
188
+ same: (e3, a16) => valuesEqual(e3, a16, tolerance)
189
+ };
190
+ try {
191
+ compareGraphs(expected, actual, ctx);
192
+ } catch (err) {
193
+ if (!(err instanceof LimitReached)) {
194
+ throw err;
195
+ }
196
+ }
197
+ return diffs;
198
+ }
199
+ class LimitReached extends Error {
200
+ }
201
+ function compareGraphs(expected, actual, ctx) {
202
+ const { diff } = ctx;
203
+ if (expected.directed !== actual.directed) {
204
+ diff("directed", expected.directed, actual.directed);
205
+ }
206
+ if (expected.nodeCount !== actual.nodeCount) {
207
+ diff("nodeCount", expected.nodeCount, actual.nodeCount);
208
+ }
209
+ if (expected.edgeCount !== actual.edgeCount) {
210
+ diff("edgeCount", expected.edgeCount, actual.edgeCount);
211
+ }
212
+ compareIds(expected, actual, diff);
213
+ if (expected.nodeCount !== actual.nodeCount || expected.edgeCount !== actual.edgeCount) {
214
+ return;
215
+ }
216
+ compareTopology(expected, actual, diff);
217
+ compareWeights(expected, actual, ctx);
218
+ compareTables("nodes", expected.nodes, actual.nodes, ctx);
219
+ compareTables("edges", expected.edges, actual.edges, ctx);
220
+ compareTables("graph", expected.graph, actual.graph, ctx);
221
+ if (ctx.options.extensions !== false) {
222
+ compareExtensions(expected, actual, ctx);
223
+ }
224
+ }
225
+ function compareIds(expected, actual, diff) {
226
+ const expectedIds = expected.ids.toArray();
227
+ const actualIds = actual.ids.toArray();
228
+ const n3 = Math.min(expectedIds.length, actualIds.length);
229
+ for (let i4 = 0; i4 < n3; i4++) {
230
+ if (!Object.is(expectedIds[i4], actualIds[i4])) {
231
+ diff(`ids[${i4}]`, expectedIds[i4], actualIds[i4]);
232
+ }
233
+ }
234
+ }
235
+ function compareTopology(expected, actual, diff) {
236
+ if (!typedEqual(expected.rowPtr, actual.rowPtr)) {
237
+ diff("rowPtr", expected.rowPtr, actual.rowPtr, "rowPtr differs");
238
+ }
239
+ if (!typedEqual(expected.colIdx, actual.colIdx)) {
240
+ diff("colIdx", expected.colIdx, actual.colIdx, "colIdx differs");
241
+ }
242
+ const el = expected.edgeList();
243
+ const al = actual.edgeList();
244
+ for (let e3 = 0; e3 < expected.edgeCount; e3++) {
245
+ if (el.src[e3] !== al.src[e3] || el.dst[e3] !== al.dst[e3]) {
246
+ diff(`edge[${e3}]`, `${el.src[e3]}->${el.dst[e3]}`, `${al.src[e3]}->${al.dst[e3]}`);
247
+ }
248
+ }
249
+ }
250
+ function compareWeights(expected, actual, ctx) {
251
+ if (expected.flags.weighted !== actual.flags.weighted) {
252
+ ctx.diff("flags.weighted", expected.flags.weighted, actual.flags.weighted);
253
+ return;
254
+ }
255
+ if (!expected.flags.weighted) {
256
+ return;
257
+ }
258
+ const eShadow = expected.edges.byRole("weight");
259
+ const aShadow = actual.edges.byRole("weight");
260
+ if (eShadow !== null && aShadow !== null) {
261
+ compareExactWeights(expected.edgeCount, eShadow, aShadow, ctx);
262
+ return;
263
+ }
264
+ if (ctx.options.weightExplicitness !== false && eShadow === null !== (aShadow === null)) {
265
+ ctx.diff(
266
+ "weightColumn",
267
+ eShadow !== null,
268
+ aShadow !== null,
269
+ "one snapshot has a role-weight column, the other does not"
270
+ );
271
+ }
272
+ const ew = expected.edgeList().weights;
273
+ const aw = actual.edgeList().weights;
274
+ for (let e3 = 0; e3 < expected.edgeCount; e3++) {
275
+ const ev = ew === null ? 1 : ew[e3];
276
+ const av = aw === null ? 1 : aw[e3];
277
+ if (!ctx.same(ev, av)) {
278
+ ctx.diff(`weight[${e3}]`, ev, av);
279
+ }
280
+ }
281
+ }
282
+ function compareExactWeights(edgeCount, expected, actual, ctx) {
283
+ for (let e3 = 0; e3 < edgeCount; e3++) {
284
+ const eSet = expected.isSet(e3);
285
+ const aSet = actual.isSet(e3);
286
+ if (ctx.options.weightExplicitness !== false && eSet !== aSet) {
287
+ ctx.diff(`weightExplicit[${e3}]`, eSet, aSet);
288
+ } else if (eSet && aSet && !ctx.same(expected.value(e3), actual.value(e3))) {
289
+ ctx.diff(`weight[${e3}]`, expected.value(e3), actual.value(e3));
290
+ }
291
+ }
292
+ }
293
+ function compareExtensions(expected, actual, ctx) {
294
+ for (const [name, table] of expected.extensions) {
295
+ const other = actual.extensions.get(name);
296
+ if (other === void 0) {
297
+ ctx.diff(`extensions.${name}`, "present", "absent");
298
+ } else if (table.rowCount === other.rowCount) {
299
+ compareTables(`extensions.${name}`, table, other, ctx);
300
+ } else {
301
+ ctx.diff(`extensions.${name}.rowCount`, table.rowCount, other.rowCount);
302
+ }
303
+ }
304
+ if (ctx.options.allowExtraColumns === false) {
305
+ for (const name of actual.extensions.keys()) {
306
+ if (!expected.extensions.has(name)) {
307
+ ctx.diff(`extensions.${name}`, "absent", "present");
308
+ }
309
+ }
310
+ }
311
+ }
312
+ function compareTables(label, expected, actual, ctx) {
313
+ const ignoreNames = new Set(ctx.options.ignoreColumns ?? []);
314
+ const ignoreRoles = new Set(ctx.options.ignoreRoles ?? []);
315
+ const skip = (column) => {
316
+ const { name, role } = column.meta;
317
+ return ignoreNames.has(name) || role !== null && (ignoreRoles.has(role) || label === "edges" && role === "weight");
318
+ };
319
+ for (const column of expected) {
320
+ if (skip(column)) {
321
+ continue;
322
+ }
323
+ const path = `${label}.${column.meta.name}`;
324
+ const other = actual.get(column.meta.name);
325
+ if (other === null) {
326
+ ctx.diff(path, "present", "absent", `${path}: column missing after round trip`);
327
+ } else {
328
+ compareColumn(path, column, other, ctx);
329
+ }
330
+ }
331
+ if (ctx.options.allowExtraColumns === false) {
332
+ for (const column of actual) {
333
+ if (!skip(column) && expected.get(column.meta.name) === null) {
334
+ const path = `${label}.${column.meta.name}`;
335
+ ctx.diff(path, "absent", "present", `${path}: extra column after round trip`);
336
+ }
337
+ }
338
+ }
339
+ }
340
+ function compareColumn(path, column, other, ctx) {
341
+ compareDeclaration(path, column, other, ctx);
342
+ if (column.length !== other.length) {
343
+ ctx.diff(`${path}.length`, column.length, other.length);
344
+ return;
345
+ }
346
+ for (let r2 = 0; r2 < column.length; r2++) {
347
+ const eSet = column.isSet(r2);
348
+ const aSet = other.isSet(r2);
349
+ if (eSet !== aSet) {
350
+ ctx.diff(`${path}[${r2}]`, eSet ? column.value(r2) : void 0, aSet ? other.value(r2) : void 0);
351
+ } else if (eSet) {
352
+ const ev = cellValue(column, r2);
353
+ const av = cellValue(other, r2);
354
+ if (!ctx.same(ev, av)) {
355
+ ctx.diff(`${path}[${r2}]`, ev, av);
356
+ }
357
+ }
358
+ }
359
+ }
360
+ function compareDeclaration(path, column, other, ctx) {
361
+ const { options, diff } = ctx;
362
+ const e3 = column.meta;
363
+ const a16 = other.meta;
364
+ if (options.dtypes !== false) {
365
+ for (const key of ["dtype", "itemDtype", "components"]) {
366
+ if (e3[key] !== a16[key]) {
367
+ diff(`${path}.${key}`, e3[key], a16[key]);
368
+ }
369
+ }
370
+ }
371
+ if (options.roles !== false && e3.role !== a16.role) {
372
+ diff(`${path}.role`, e3.role, a16.role);
373
+ }
374
+ const eType = e3.origin?.type ?? null;
375
+ const aType = a16.origin?.type ?? null;
376
+ if (options.originType === true && eType !== aType) {
377
+ diff(`${path}.origin.type`, eType, aType);
378
+ }
379
+ }
380
+ function cellValue(column, row) {
381
+ switch (column.dtype) {
382
+ case "list":
383
+ return [...column.sliceOf(row)];
384
+ case "json":
385
+ return column.values[row];
386
+ default: {
387
+ const value = column.value(row);
388
+ return ArrayBuffer.isView(value) ? Array.from(value) : value;
389
+ }
390
+ }
391
+ }
392
+ function valuesEqual(e3, a16, tolerance) {
393
+ if (typeof e3 === "number" && typeof a16 === "number") {
394
+ if (Object.is(e3, a16)) {
395
+ return true;
396
+ }
397
+ return Number.isFinite(e3) && Number.isFinite(a16) && Math.abs(e3 - a16) <= tolerance;
398
+ }
399
+ if (Array.isArray(e3) || ArrayBuffer.isView(e3)) {
400
+ const ea = Array.from(e3);
401
+ if (!(Array.isArray(a16) || ArrayBuffer.isView(a16))) {
402
+ return false;
403
+ }
404
+ const aa2 = Array.from(a16);
405
+ return ea.length === aa2.length && ea.every((v2, i4) => valuesEqual(v2, aa2[i4], tolerance));
406
+ }
407
+ if (typeof e3 === "object" && e3 !== null && typeof a16 === "object" && a16 !== null) {
408
+ const eo = e3;
409
+ const ao = a16;
410
+ const keys = Object.keys(eo);
411
+ if (keys.length !== Object.keys(ao).length) {
412
+ return false;
413
+ }
414
+ return keys.every((k2) => Object.hasOwn(ao, k2) && valuesEqual(eo[k2], ao[k2], tolerance));
415
+ }
416
+ return Object.is(e3, a16);
417
+ }
418
+ function typedEqual(a16, b14) {
419
+ if (a16.length !== b14.length) {
420
+ return false;
421
+ }
422
+ for (let i4 = 0; i4 < a16.length; i4++) {
423
+ if (a16[i4] !== b14[i4]) {
424
+ return false;
425
+ }
426
+ }
427
+ return true;
428
+ }
429
+ function show(v2) {
430
+ if (ArrayBuffer.isView(v2)) {
431
+ const items = Array.from(v2);
432
+ return `[${items.slice(0, 8).join(", ")}${items.length > 8 ? ", ..." : ""}]`;
433
+ }
434
+ try {
435
+ const text = JSON.stringify(v2);
436
+ return text ?? String(v2);
437
+ } catch {
438
+ return String(v2);
439
+ }
440
+ }
441
+ function describeDiffs(diffs) {
442
+ return diffs.length === 0 ? "no differences" : diffs.map((d4) => ` - ${d4.message}`).join("\n");
443
+ }
39
444
  const TOO_MANY_EMPTY_CELLS_CODE = "E_TOO_MANY_EMPTY_CELLS";
40
445
  const DEFAULT_MAX_EMPTY_CELLS = 2 ** 24;
41
446
  function maxEmptyCellsOption(value) {
@@ -152,7 +557,7 @@ class CellBudgetBuilder extends GraphBuilder {
152
557
  if (empty > this.maxEmptyCells) {
153
558
  new ImportReportBuilder(this.format, Infinity).fail(
154
559
  TOO_MANY_EMPTY_CELLS_CODE,
155
- `the attributes are too sparse: ${this.nodeColumns.size} node and ${this.edgeColumns.size} edge attribute column(s) over ${this.nodeBound} node(s) and ${this.edgeBound} edge(s) would allocate more than ${this.maxEmptyCells} slots that hold no value; pass a larger maxEmptyCells (or Infinity) to read the file anyway`,
560
+ `the attributes are too sparse: ${this.nodeColumns.size} node and ${this.edgeColumns.size} edge attribute columns over ${this.nodeBound} node${plural(this.nodeBound)} and ${this.edgeBound} edge${plural(this.edgeBound)} would allocate more than ${this.maxEmptyCells} slots that hold no value; pass a larger maxEmptyCells (or Infinity) to read the file anyway`,
156
561
  void 0,
157
562
  { emptyCells: empty, maxEmptyCells: this.maxEmptyCells }
158
563
  );
@@ -160,6 +565,35 @@ class CellBudgetBuilder extends GraphBuilder {
160
565
  }
161
566
  }
162
567
  const UNKNOWN_FORMAT_CODE = "E_UNKNOWN_FORMAT";
568
+ const SNIFF_FAILED_CODE = "W_SNIFF_FAILED";
569
+ const FUNCTION_OPTIONS = /* @__PURE__ */ new Set([
570
+ "addMissingNodes",
571
+ "builder",
572
+ "defaultDirected",
573
+ "duplicateEdges",
574
+ "encoding",
575
+ "errorLimit",
576
+ "filename",
577
+ "format",
578
+ "freeze",
579
+ "graphIndex",
580
+ "graphName",
581
+ "hyperedges",
582
+ "ids",
583
+ "long",
584
+ "maxEmptyCells",
585
+ "mimeType",
586
+ "nodeIdFrom",
587
+ "onMixedDirection",
588
+ "onProgress",
589
+ "request",
590
+ "restoreMangledIds",
591
+ "sanitizeIds",
592
+ "selfLoops",
593
+ "signal",
594
+ "weightDtype",
595
+ "weightFrom"
596
+ ]);
163
597
  const REGISTRY_KEYS = /* @__PURE__ */ new Set([
164
598
  "format",
165
599
  "filename",
@@ -254,10 +688,10 @@ class FormatRegistry {
254
688
  return [.../* @__PURE__ */ new Set([...this.importerMap.keys(), ...this.exporterMap.keys()])];
255
689
  }
256
690
  /**
257
- * Rank the registered importers for an input (design section 8.2; the successor of
258
- * graphty-element's detectFormat()).
259
- * @param hints - the filename, MIME type and / or head of the input
260
- * @returns the candidates, best first; empty when nothing matches
691
+ * Every format that could be the input, best first, from the same hints as sniff(): use it to
692
+ * offer the user a choice when the best guess is not certain.
693
+ * @param hints - `{ filename, mimeType, head }`, any of them
694
+ * @returns the candidates, best first; empty when no format claims the input
261
695
  */
262
696
  sniffAll(hints) {
263
697
  return rankFormats(hints, this.importerMap.values());
@@ -272,39 +706,112 @@ class FormatRegistry {
272
706
  return ranked.length > 0 ? ranked[0] : null;
273
707
  }
274
708
  /**
275
- * Read an input into a fresh builder and freeze it (design section 8.4: for callers who do not
276
- * own a sink). The format is the one named in the options, else sniffed from the filename,
277
- * the MIME type and the first bytes of the content; the builder is seeded from the common
278
- * options with `directed: true` as a placeholder that the importer overrides from the file.
279
- * An input holding several graphs yields the first, with a warning naming how many were
280
- * skipped; importAllGraphs() returns every one.
709
+ * Read a graph from a string, bytes or a stream. The format is the one you name in `format`,
710
+ * else it is detected from `filename`, `mimeType` and the first bytes of the content. From an
711
+ * input that holds several graphs, it reads the one `graphIndex` or `graphName` chooses, else
712
+ * the first, with a W_MULTIPLE_GRAPHS warning; importAllGraphs() returns every one.
281
713
  * @param input - the text, bytes, stream or chunks to read
282
714
  * @param options - the format, hints, common and format-specific import options
283
- * @returns the snapshot, the import report and the freeze report
715
+ * @returns the graph (`snapshot`), the format it was read as, and the import report
284
716
  */
285
717
  async importGraph(input, options = {}) {
286
- const chosen = await this.choose(input, options);
287
- const builder = seededBuilder(options, chosen.importer.format);
718
+ const opts = options;
719
+ const picked = await this.choose(input, opts);
720
+ const unknown = this.unknownOptions(opts).map(
721
+ (name) => Object.freeze({
722
+ category: "unsupported",
723
+ severity: "warning",
724
+ code: UNKNOWN_OPTION_CODE,
725
+ message: unknownOptionText(name),
726
+ line: null,
727
+ element: name
728
+ })
729
+ );
730
+ const chosen = unknown.length === 0 ? picked : { ...picked, warnings: [...picked.warnings, ...unknown] };
731
+ const { importer } = chosen;
732
+ if ((opts.graphIndex !== void 0 || opts.graphName !== void 0) && importer.importAll !== void 0 && importer.listGraphs === void 0) {
733
+ const all = await this.readAll(chosen, opts);
734
+ const names = all.map((r2) => r2.snapshot.meta.name);
735
+ return all[chooseGraph(names, opts, new ImportReportBuilder(importer.format, 0))];
736
+ }
737
+ let builder;
288
738
  let report;
289
739
  try {
290
- report = await chosen.importer.import(chosen.source, builder, importerOptions(options));
740
+ builder = seededBuilder(opts, chosen.importer.format);
741
+ report = await chosen.importer.import(chosen.source, builder, importerOptions(opts));
291
742
  } catch (err) {
292
743
  await chosen.peeked?.close();
293
- throw err;
744
+ throw chosen.sniff === null ? notReadableAs(err, importer.format, opts.filename) : err;
745
+ }
746
+ return result(chosen, builder, report, opts);
747
+ }
748
+ /**
749
+ * Fetch a graph file from a URL and load it; see the top-level loadFromUrl() for the full
750
+ * description.
751
+ * @param url - an absolute URL, or in a browser one relative to the page
752
+ * @param options - import options, plus `request` for fetch
753
+ * @returns the graph, the format it was read as, and the import report
754
+ */
755
+ async loadFromUrl(url, options = {}) {
756
+ const opts = options;
757
+ const { request, ...rest } = opts;
758
+ const signal = request?.signal ?? rest.signal ?? null;
759
+ const method = request?.method ?? "GET";
760
+ const where = `${method} ${String(url)}`;
761
+ let response;
762
+ try {
763
+ response = await fetch(url, { signal: rest.signal, ...request });
764
+ } catch (err) {
765
+ if (signal?.aborted === true || isAbortError(err)) {
766
+ throw err;
767
+ }
768
+ return fetchFailed(rest, url, `${where} failed: ${fetchErrorText(url, err)}`, null, err);
769
+ }
770
+ if (!response.ok) {
771
+ await response.body?.cancel().catch(() => void 0);
772
+ const status = `${String(response.status)} ${response.statusText}`.trim();
773
+ return fetchFailed(rest, url, `${where} failed: ${status}`, response.status, null);
294
774
  }
295
- return result(chosen, builder, report, options);
775
+ return this.importGraph(response.body ?? new Uint8Array(0), {
776
+ ...rest,
777
+ filename: rest.filename ?? urlFilename(url),
778
+ mimeType: rest.mimeType ?? response.headers.get("content-type")
779
+ });
780
+ }
781
+ /**
782
+ * Load a graph from a File or Blob; see the top-level loadFromFile() for the full description.
783
+ * @param file - the File or Blob to read
784
+ * @param options - the same options as importGraph()
785
+ * @returns the graph, the format it was read as, and the import report
786
+ */
787
+ loadFromFile(file, options = {}) {
788
+ const opts = options;
789
+ const { name } = file;
790
+ return this.importGraph(file.stream(), {
791
+ ...opts,
792
+ filename: opts.filename ?? (typeof name === "string" ? name : null),
793
+ mimeType: opts.mimeType ?? (file.type === "" ? null : file.type)
794
+ });
296
795
  }
297
796
  /**
298
797
  * Read every graph of an input (a DOT file with several graphs, a Pajek project with several
299
- * networks, a JGF document with a `graphs` array), each into its own fresh builder, frozen.
300
- * A format whose importer has no importAll() holds one graph per input, so the result has one
301
- * entry. Options, sniffing and the builder seed are those of importGraph().
798
+ * networks, a JGF document with a `graphs` array), each as its own snapshot. A format that holds
799
+ * one graph per file gives one result. Options and detection are those of importGraph().
302
800
  * @param input - the text, bytes, stream or chunks to read
303
801
  * @param options - the format, hints, common and format-specific import options
304
802
  * @returns one result per graph, in document order
305
803
  */
306
804
  async importAllGraphs(input, options = {}) {
307
- const chosen = await this.choose(input, options);
805
+ const opts = options;
806
+ return this.readAll(await this.choose(input, opts), opts);
807
+ }
808
+ /**
809
+ * Read every graph of an input with the chosen importer.
810
+ * @param chosen - the importer and the input to hand it
811
+ * @param options - the importGraph options
812
+ * @returns one result per graph, in document order
813
+ */
814
+ async readAll(chosen, options) {
308
815
  const { importer } = chosen;
309
816
  const builders = [];
310
817
  let reports;
@@ -325,9 +832,18 @@ class FormatRegistry {
325
832
  }
326
833
  } catch (err) {
327
834
  await chosen.peeked?.close();
328
- throw err;
835
+ throw inGraph(
836
+ chosen.sniff === null ? notReadableAs(err, importer.format, options.filename) : err,
837
+ builders.length - 1
838
+ );
329
839
  }
330
- return reports.map((report, i5) => result(chosen, builders[i5], report, options));
840
+ return reports.map((report, i4) => {
841
+ try {
842
+ return result(chosen, builders[i4], report, options);
843
+ } catch (err) {
844
+ throw inGraph(err, i4);
845
+ }
846
+ });
331
847
  }
332
848
  /**
333
849
  * The graphs of an input that can hold several, without importing them (a Cytoscape session's
@@ -339,39 +855,84 @@ class FormatRegistry {
339
855
  * list its graphs (importGraph() then reads the first)
340
856
  */
341
857
  async listGraphs(input, options = {}) {
342
- const chosen = await this.choose(input, options);
858
+ const opts = options;
859
+ const chosen = await this.choose(input, opts);
343
860
  try {
344
- return chosen.importer.listGraphs === void 0 ? null : await chosen.importer.listGraphs(chosen.source, importerOptions(options));
861
+ return chosen.importer.listGraphs === void 0 ? null : await chosen.importer.listGraphs(chosen.source, importerOptions(opts));
345
862
  } finally {
346
863
  await chosen.peeked?.close();
347
864
  }
348
865
  }
349
866
  /**
350
867
  * The importer for an input: the named format, or the sniffed one.
351
- * @param input - the input
868
+ * @param rawInput - the input as the caller passed it
352
869
  * @param options - the importGraph options
353
870
  * @returns the importer, the sniff, and the input to read (replayed for a stream)
354
871
  */
355
- async choose(input, options) {
872
+ async choose(rawInput, options) {
873
+ const input = normalizeInput(rawInput);
356
874
  const requested = options.format ?? "auto";
357
875
  if (requested !== "auto") {
358
- return { importer: this.importer(requested), sniff: null, source: input, peeked: null };
359
- }
360
- const peeked = await peekHead(input, SNIFF_HEAD_BYTES, options.signal ?? null);
361
- const sniff2 = this.sniff({ filename: options.filename, mimeType: options.mimeType, head: peeked.head });
362
- if (sniff2 === null) {
363
- const report = new ImportReportBuilder("unknown", 0);
364
- return report.fail(
365
- UNKNOWN_FORMAT_CODE,
366
- `no registered importer recognises the input${describeHints(options)}; pass the format explicitly`,
367
- void 0,
368
- { formats: this.formats() }
876
+ return { importer: this.importer(requested), sniff: null, source: input, peeked: null, warnings: [] };
877
+ }
878
+ const common = resolveImportOptions(options, { ids: "keep", defaultDirected: true, weightFrom: null });
879
+ maxEmptyCellsOption(options.maxEmptyCells);
880
+ const peeked = await peekHead(input, SNIFF_HEAD_BYTES, common.signal);
881
+ const head = common.encoding !== null && peeked.head instanceof Uint8Array ? new TextDecoder(common.encoding).decode(peeked.head, { stream: true }) : peeked.head;
882
+ let sniff2;
883
+ const failures = new ImportReportBuilder("unknown", 0);
884
+ const warnings = [];
885
+ try {
886
+ const hints = { filename: options.filename, mimeType: options.mimeType, head };
887
+ const ranked = rankFormats(hints, this.importerMap.values(), (format, err) => {
888
+ warnings.push(
889
+ failures.warning(
890
+ "unsupported",
891
+ SNIFF_FAILED_CODE,
892
+ `the ${format} importer's sniff() threw (${messageOf(err)}); it was treated as not recognizing the input`,
893
+ { element: format }
894
+ )
895
+ );
896
+ });
897
+ sniff2 = ranked.length > 0 ? ranked[0] : null;
898
+ } catch (err) {
899
+ await peeked.close();
900
+ throw err;
901
+ }
902
+ const foreign = foreignKind(peeked.head);
903
+ const claimed = sniff2 !== null && sniff2.content > 0 && !(foreign?.startsWith("an HTML") ?? false);
904
+ if (sniff2 === null || foreign !== null && !claimed) {
905
+ await peeked.close();
906
+ return this.refuseUndetected(failures, head, foreign, options);
907
+ }
908
+ return { importer: this.importer(sniff2.format), sniff: sniff2, source: peeked.input, peeked, warnings };
909
+ }
910
+ /**
911
+ * Refuse an input no importer recognizes: empty, or not in a known graph format.
912
+ * @param failures - the report the error is recorded in
913
+ * @param head - the head, as sniffed
914
+ * @param foreign - what known non-graph file the head is, or null
915
+ * @param options - the importGraph options
916
+ * @returns never: always throws
917
+ */
918
+ refuseUndetected(failures, head, foreign, options) {
919
+ const text = typeof head === "string" ? head : new TextDecoder().decode(head ?? new Uint8Array(0));
920
+ if (text.trim() === "" && text.length < SNIFF_HEAD_BYTES) {
921
+ return failures.fail(
922
+ EMPTY_INPUT_CODE,
923
+ text === "" ? "the input is empty" : "the input holds only whitespace"
369
924
  );
370
925
  }
371
- return { importer: this.importer(sniff2.format), sniff: sniff2, source: peeked.input, peeked };
926
+ const what = foreign === null ? "" : `: it is ${foreign}`;
927
+ return failures.fail(
928
+ UNKNOWN_FORMAT_CODE,
929
+ `the input is not in a graph format graph-io recognizes${describeHints(options)}${what}; if you know its format, pass it as the format option`,
930
+ void 0,
931
+ { formats: this.formats() }
932
+ );
372
933
  }
373
934
  /**
374
- * Write a snapshot in a format, as UTF-8 chunks (design section 8.5).
935
+ * Write a snapshot in a format, as UTF-8 chunks.
375
936
  * @param snapshot - the snapshot
376
937
  * @param format - the format name
377
938
  * @param options - the exporter's common and format-specific options
@@ -390,6 +951,33 @@ class FormatRegistry {
390
951
  async exportGraphToString(snapshot, format, options) {
391
952
  return this.exporter(format).exportToString(snapshot, options);
392
953
  }
954
+ /**
955
+ * Write a snapshot in a format as one buffer of UTF-8 bytes; see the top-level
956
+ * exportGraphToBytes().
957
+ * @param snapshot - the graph to write
958
+ * @param format - a format name where `canExport` is true
959
+ * @param options - sanitizeIds, onMixedDirection and the format's own options
960
+ * @returns the encoded file
961
+ */
962
+ exportGraphToBytes(snapshot, format, options) {
963
+ return collectBytes(this.exportGraph(snapshot, format, options));
964
+ }
965
+ /**
966
+ * Write a snapshot in a format as a Blob typed with the format's first MIME type; see the
967
+ * top-level exportGraphToBlob().
968
+ * @param snapshot - the graph to write
969
+ * @param format - a format name where `canExport` is true
970
+ * @param options - sanitizeIds, onMixedDirection and the format's own options
971
+ * @returns the file as a Blob
972
+ */
973
+ async exportGraphToBlob(snapshot, format, options) {
974
+ const parts = [];
975
+ for await (const chunk of this.exportGraph(snapshot, format, options)) {
976
+ parts.push(chunk);
977
+ }
978
+ const info = this.listFormats().find((f3) => f3.format === format);
979
+ return new Blob(parts, { type: info?.mimeTypes[0] ?? "application/octet-stream" });
980
+ }
393
981
  /**
394
982
  * What exporting a snapshot in a format would lose, without writing anything.
395
983
  * @param snapshot - the snapshot
@@ -398,13 +986,96 @@ class FormatRegistry {
398
986
  * @returns the loss notes, empty when the export is exact
399
987
  */
400
988
  checkExport(snapshot, format, options) {
401
- return this.exporter(format).check(snapshot, options);
989
+ const notes = this.exporter(format).check(snapshot, options);
990
+ const unknown = this.unknownOptions(options);
991
+ if (unknown.length === 0) {
992
+ return notes;
993
+ }
994
+ return Object.freeze([
995
+ ...notes,
996
+ ...unknown.map(
997
+ (name) => Object.freeze({
998
+ code: UNKNOWN_OPTION_CODE,
999
+ message: unknownOptionText(name),
1000
+ column: null,
1001
+ count: null
1002
+ })
1003
+ )
1004
+ ]);
1005
+ }
1006
+ /**
1007
+ * The option names no registered format and no load or save function takes (misspellings), or none while a
1008
+ * registered format does not list its options.
1009
+ * @param options - the caller's options
1010
+ * @returns the unknown names
1011
+ */
1012
+ unknownOptions(options) {
1013
+ if (options === null || options === void 0) {
1014
+ return [];
1015
+ }
1016
+ const known = new Set(FUNCTION_OPTIONS);
1017
+ for (const plugin of [...this.importerMap.values(), ...this.exporterMap.values()]) {
1018
+ if (plugin.options === void 0) {
1019
+ return [];
1020
+ }
1021
+ for (const name of plugin.options) {
1022
+ known.add(name);
1023
+ }
1024
+ }
1025
+ return Object.entries(options).filter(([name, value]) => value !== void 0 && !known.has(name)).map(([name]) => name);
1026
+ }
1027
+ /**
1028
+ * Browser only: write a graph in a format and have the browser save it as a file; see the
1029
+ * top-level downloadGraph(). Use this method on a registry from createRegistry() to download
1030
+ * without bundling every built-in format.
1031
+ * @param snapshot - the graph to write
1032
+ * @param format - a format name from listFormats() where `canExport` is true
1033
+ * @param options - the export options, plus `filename`
1034
+ * @returns resolves once the download has been handed to the browser
1035
+ */
1036
+ async downloadGraph(snapshot, format, options = {}) {
1037
+ if (typeof document === "undefined") {
1038
+ throw new GraphFormatError(
1039
+ "E_UNSUPPORTED",
1040
+ "downloadGraph() needs a browser document; use exportGraphToBytes() and write the bytes yourself"
1041
+ );
1042
+ }
1043
+ const { filename, ...rest } = options;
1044
+ const blob = await this.exportGraphToBlob(snapshot, format, rest);
1045
+ const extension = this.listFormats().find((f3) => f3.format === format)?.extensions[0] ?? `.${format}`;
1046
+ const href = URL.createObjectURL(blob);
1047
+ const anchor = document.createElement("a");
1048
+ anchor.href = href;
1049
+ anchor.download = filename ?? `graph${extension}`;
1050
+ anchor.click();
1051
+ setTimeout(() => {
1052
+ URL.revokeObjectURL(href);
1053
+ }, 0);
1054
+ }
1055
+ /**
1056
+ * Every format this registry can read or write, in registration order; see the top-level
1057
+ * listFormats().
1058
+ * @returns one entry per format
1059
+ */
1060
+ listFormats() {
1061
+ return this.formats().map((format) => {
1062
+ const importer = this.importerMap.get(format);
1063
+ const exporter = this.exporterMap.get(format);
1064
+ return Object.freeze({
1065
+ format,
1066
+ extensions: importer?.extensions ?? exporter?.extensions ?? [],
1067
+ mimeTypes: importer?.mimeTypes ?? exporter?.mimeTypes ?? [],
1068
+ canImport: importer !== void 0,
1069
+ canExport: exporter !== void 0,
1070
+ capabilities: exporter?.capabilities ?? null
1071
+ });
1072
+ });
402
1073
  }
403
1074
  }
404
1075
  function createRegistry() {
405
- return new FormatRegistry().registerImporter(jsonImporter).registerExporter(jsonExporter).registerImporter(graphmlImporter).registerExporter(graphmlExporter).registerImporter(gexfImporter).registerExporter(gexfExporter).registerImporter(csvImporter).registerExporter(csvExporter).registerImporter(gmlImporter).registerExporter(gmlExporter).registerImporter(dotImporter).registerExporter(dotExporter).registerImporter(pajekImporter).registerExporter(pajekExporter).registerImporter(neo4jImporter).registerExporter(neo4jExporter).registerImporter(xgmmlImporter).registerExporter(xgmmlExporter).registerImporter(cx2Importer).registerExporter(cx2Exporter).registerImporter(cxImporter).registerImporter(oboImporter).registerImporter(cysImporter);
1076
+ return new FormatRegistry().registerImporter(jsonImporter).registerExporter(jsonExporter).registerImporter(graphmlImporter).registerExporter(graphmlExporter).registerImporter(gexfImporter).registerExporter(gexfExporter).registerImporter(csvImporter).registerExporter(csvExporter).registerImporter(gmlImporter).registerExporter(gmlExporter).registerImporter(dotImporter).registerExporter(dotExporter).registerImporter(pajekImporter).registerExporter(pajekExporter).registerImporter(neo4jImporter).registerExporter(neo4jExporter).registerImporter(xgmmlImporter).registerExporter(xgmmlExporter).registerImporter(cx2Importer).registerExporter(cx2Exporter).registerImporter(cxImporter).registerExporter(cxExporter).registerImporter(oboImporter).registerExporter(oboExporter).registerImporter(cysImporter).registerExporter(cysExporter);
406
1077
  }
407
- const registry = createRegistry();
1078
+ const registry = /* @__PURE__ */ createRegistry();
408
1079
  function importGraph(input, options) {
409
1080
  return registry.importGraph(input, options);
410
1081
  }
@@ -423,9 +1094,59 @@ async function exportGraphToString(snapshot, format, options) {
423
1094
  function checkExport(snapshot, format, options) {
424
1095
  return registry.checkExport(snapshot, format, options);
425
1096
  }
1097
+ function loadFromUrl(url, options) {
1098
+ return registry.loadFromUrl(url, options);
1099
+ }
1100
+ function loadFromFile(file, options) {
1101
+ return registry.loadFromFile(file, options);
1102
+ }
1103
+ function exportGraphToBytes(snapshot, format, options) {
1104
+ return registry.exportGraphToBytes(snapshot, format, options);
1105
+ }
1106
+ function exportGraphToBlob(snapshot, format, options) {
1107
+ return registry.exportGraphToBlob(snapshot, format, options);
1108
+ }
1109
+ async function downloadGraph(snapshot, format, options = {}) {
1110
+ return registry.downloadGraph(snapshot, format, options);
1111
+ }
1112
+ function listFormats() {
1113
+ return registry.listFormats();
1114
+ }
426
1115
  function sniff(hints) {
427
1116
  return registry.sniff(hints);
428
1117
  }
1118
+ function fetchFailed(options, url, message, status, cause) {
1119
+ const format = options.format === void 0 || options.format === "auto" ? "unknown" : options.format;
1120
+ return new ImportReportBuilder(format, 0).fail(FETCH_CODE, message, void 0, { url: String(url), status, cause });
1121
+ }
1122
+ function notReadableAs(err, format, filename) {
1123
+ if (!(err instanceof ImportError) || err.issue?.category !== "parse-error" || err.report.errorCount > 1 || err.report.counts.nodes + err.report.counts.edges > 0) {
1124
+ return err;
1125
+ }
1126
+ const what = filename === void 0 || filename === null ? "the input" : JSON.stringify(filename);
1127
+ return new ImportError(`${what} could not be read as ${format}: ${err.message}`, err.report, err.details);
1128
+ }
1129
+ function fetchErrorText(url, err) {
1130
+ let absolute = null;
1131
+ try {
1132
+ absolute = new URL(url);
1133
+ } catch {
1134
+ }
1135
+ if (absolute === null && globalThis.location === void 0) {
1136
+ return "a relative URL needs a web page to resolve against; outside a browser pass an absolute http(s) URL, or read a local file with loadFromFile() or importGraph()";
1137
+ }
1138
+ if (absolute?.protocol === "file:") {
1139
+ return "fetch() cannot read file: URLs here; read a local file with loadFromFile() or importGraph()";
1140
+ }
1141
+ const cause = err?.cause?.message;
1142
+ const detail = typeof cause === "string" && cause !== "" ? ` (${cause})` : "";
1143
+ return `the server could not be reached, or (in a browser) it does not allow this page to read the file (CORS)${detail}`;
1144
+ }
1145
+ function urlFilename(url) {
1146
+ const path = new URL(url, "http://localhost/").pathname;
1147
+ const name = path.slice(path.lastIndexOf("/") + 1);
1148
+ return name === "" ? null : name;
1149
+ }
429
1150
  function importerOptions(options) {
430
1151
  const out = {};
431
1152
  for (const [key, value] of Object.entries(options)) {
@@ -437,6 +1158,21 @@ function importerOptions(options) {
437
1158
  }
438
1159
  function seededBuilder(options, format) {
439
1160
  const maxEmptyCells = maxEmptyCellsOption(options.maxEmptyCells);
1161
+ try {
1162
+ return newBuilder(options, format, maxEmptyCells);
1163
+ } catch (err) {
1164
+ if (err instanceof GraphFormatError && err.code === "E_UNSUPPORTED" && typeof err.details.field === "string") {
1165
+ const option = err.details.field;
1166
+ throw new GraphFormatError(
1167
+ "E_UNSUPPORTED",
1168
+ `option ${option}: ${JSON.stringify(err.details.found)} is not one of the values it takes`,
1169
+ { option, found: err.details.found }
1170
+ );
1171
+ }
1172
+ throw err;
1173
+ }
1174
+ }
1175
+ function newBuilder(options, format, maxEmptyCells) {
440
1176
  return new CellBudgetBuilder(
441
1177
  {
442
1178
  weightDtype: options.weightDtype ?? "f64",
@@ -450,16 +1186,108 @@ function seededBuilder(options, format) {
450
1186
  maxEmptyCells
451
1187
  );
452
1188
  }
1189
+ function inGraph(err, index) {
1190
+ if (!(err instanceof ImportError) || index < 0) {
1191
+ return err;
1192
+ }
1193
+ return new ImportError(`graph ${index}: ${err.message}`, err.report, { ...err.details, graphIndex: index });
1194
+ }
453
1195
  function result(chosen, builder, report, options) {
454
- const frozen = builder.freezeWithReport(options.freeze);
455
- return Object.freeze({
1196
+ let frozen;
1197
+ try {
1198
+ frozen = builder.freezeWithReport(options.freeze);
1199
+ } catch (err) {
1200
+ throw freezeFailure(err, report);
1201
+ }
1202
+ const { warnings } = chosen;
1203
+ const result2 = {
456
1204
  format: chosen.importer.format,
457
1205
  sniff: chosen.sniff,
458
1206
  snapshot: frozen.snapshot,
459
- report,
460
- freeze: frozen.report
1207
+ report: withFreezeWarnings(
1208
+ weightNotFound(
1209
+ warnings.length === 0 ? report : Object.freeze({
1210
+ ...report,
1211
+ issues: Object.freeze([...warnings, ...report.issues]),
1212
+ warningCount: report.warningCount + warnings.length
1213
+ }),
1214
+ frozen.snapshot,
1215
+ options.weightFrom
1216
+ ),
1217
+ frozen.report
1218
+ )
1219
+ };
1220
+ Object.defineProperty(result2, "freeze", { value: frozen.report, enumerable: false });
1221
+ return Object.freeze(result2);
1222
+ }
1223
+ function unknownOptionText(name) {
1224
+ return `option ${JSON.stringify(name)} is not an option of any format or of the load and save functions, so it has no effect; check its spelling`;
1225
+ }
1226
+ function weightNotFound(report, snapshot, weightFrom) {
1227
+ if (typeof weightFrom !== "string" || snapshot.edgeCount === 0 || snapshot.edgeList().weights !== null || report.issues.some((i4) => i4.code === OPTION_IGNORED_CODE && i4.element === "weightFrom")) {
1228
+ return report;
1229
+ }
1230
+ const issue = Object.freeze({
1231
+ category: "missing-value",
1232
+ severity: "warning",
1233
+ code: WEIGHT_NOT_FOUND_CODE,
1234
+ message: `weightFrom: ${JSON.stringify(weightFrom)} names no attribute an edge has a value for, so the graph has no weights`,
1235
+ line: null,
1236
+ element: "weightFrom"
1237
+ });
1238
+ return Object.freeze({
1239
+ ...report,
1240
+ issues: Object.freeze([...report.issues, issue]),
1241
+ warningCount: report.warningCount + 1
461
1242
  });
462
1243
  }
1244
+ function withFreezeWarnings(report, freeze) {
1245
+ const added = [];
1246
+ const warn = (category, code, message) => {
1247
+ added.push(Object.freeze({ category, severity: "warning", code, message, line: null, element: null }));
1248
+ };
1249
+ if (freeze.mergedEdges > 0) {
1250
+ warn(
1251
+ "merged",
1252
+ EDGES_MERGED_CODE,
1253
+ `${freeze.mergedEdges} parallel edge${plural(freeze.mergedEdges)} ${agree(freeze.mergedEdges, "was", "were")} merged into one edge per pair by the duplicateEdges policy; whatever told them apart (a relation, a label) is lost`
1254
+ );
1255
+ }
1256
+ if (freeze.droppedSelfLoops > 0) {
1257
+ warn(
1258
+ "validation-error",
1259
+ SELF_LOOPS_DROPPED_CODE,
1260
+ `${freeze.droppedSelfLoops} self-loop${plural(freeze.droppedSelfLoops)} ${agree(freeze.droppedSelfLoops, "was", "were")} removed by selfLoops: "drop"`
1261
+ );
1262
+ }
1263
+ if (added.length === 0) {
1264
+ return report;
1265
+ }
1266
+ return Object.freeze({
1267
+ ...report,
1268
+ issues: Object.freeze([...report.issues, ...added]),
1269
+ warningCount: report.warningCount + added.length
1270
+ });
1271
+ }
1272
+ function freezeFailure(err, report) {
1273
+ if (!(err instanceof GraphFormatError) || err instanceof ImportError) {
1274
+ return err;
1275
+ }
1276
+ const issue = Object.freeze({
1277
+ category: "validation-error",
1278
+ severity: "error",
1279
+ code: err.code,
1280
+ message: err.message,
1281
+ line: null,
1282
+ element: null
1283
+ });
1284
+ const failed = Object.freeze({
1285
+ ...report,
1286
+ issues: Object.freeze([...report.issues, issue]),
1287
+ errorCount: report.errorCount + 1
1288
+ });
1289
+ return new ImportError(`the graph cannot be frozen: ${err.message}`, failed, { code: err.code, ...err.details });
1290
+ }
463
1291
  function unknownFormat(kind, format, known) {
464
1292
  const supported = [...known];
465
1293
  return new GraphFormatError(
@@ -486,7 +1314,7 @@ async function peekHead(input, bytes, signal) {
486
1314
  return { head: input.subarray(0, bytes), input, close: () => Promise.resolve() };
487
1315
  }
488
1316
  throwIfAborted(signal);
489
- const source = typeof input.getReader === "function" ? readerIterator(input) : input[Symbol.asyncIterator]();
1317
+ const source = typeof input.getReader === "function" ? readerIterator(input, signal) : input[Symbol.asyncIterator]();
490
1318
  const buffered = [];
491
1319
  let size = 0;
492
1320
  let finished = false;
@@ -511,10 +1339,10 @@ async function peekHead(input, bytes, signal) {
511
1339
  return { head: joinHead(buffered, bytes), input: replayed, close: () => replayed.close() };
512
1340
  }
513
1341
  function joinHead(chunks, bytes) {
514
- if (chunks.every((c6) => c6 instanceof Uint8Array)) {
1342
+ if (chunks.every((c3) => c3 instanceof Uint8Array)) {
515
1343
  const total = Math.min(
516
1344
  bytes,
517
- chunks.reduce((sum, c6) => sum + c6.byteLength, 0)
1345
+ chunks.reduce((sum, c3) => sum + c3.byteLength, 0)
518
1346
  );
519
1347
  const head = new Uint8Array(total);
520
1348
  let offset = 0;
@@ -573,15 +1401,23 @@ function replay(buffered, source, finished) {
573
1401
  }
574
1402
  };
575
1403
  }
576
- function readerIterator(stream) {
577
- const reader = stream.getReader();
1404
+ function readerIterator(stream, signal) {
1405
+ const reader = lockReader(stream);
578
1406
  let done = false;
579
1407
  return {
580
1408
  async next() {
581
1409
  if (done) {
582
1410
  return { done: true, value: void 0 };
583
1411
  }
584
- const result2 = await reader.read();
1412
+ let result2;
1413
+ try {
1414
+ result2 = await abortable(reader.read(), signal);
1415
+ } catch (err) {
1416
+ done = true;
1417
+ await reader.cancel(signal?.reason).catch(() => void 0);
1418
+ reader.releaseLock();
1419
+ throw err;
1420
+ }
585
1421
  if (result2.done) {
586
1422
  done = true;
587
1423
  reader.releaseLock();
@@ -592,7 +1428,7 @@ function readerIterator(stream) {
592
1428
  async return() {
593
1429
  if (!done) {
594
1430
  done = true;
595
- await reader.cancel().catch(() => void 0);
1431
+ await reader.cancel(signal?.reason).catch(() => void 0);
596
1432
  reader.releaseLock();
597
1433
  }
598
1434
  return { done: true, value: void 0 };
@@ -600,204 +1436,260 @@ function readerIterator(stream) {
600
1436
  };
601
1437
  }
602
1438
  export {
603
- A as AMBIGUOUS_GRAPH_NAME_CODE,
604
- m as ASPECT_ORDER_CODE,
605
- n as BAD_ASPECT_BLOCK_CODE,
606
- Z as BAD_DEFAULT_CODE,
607
- ah as BAD_OPTIONS_CODE,
608
- B as BAD_VALUE_CODE,
1439
+ ae as AMBIGUOUS_GRAPH_NAME_CODE,
1440
+ Y as ASPECT_ORDER_CODE,
1441
+ V as BAD_ASPECT_BLOCK_CODE,
1442
+ B as BAD_DEFAULT_CODE,
1443
+ BAD_LINE_CODE,
1444
+ a_ as BAD_OPTIONS_CODE,
1445
+ a3 as BAD_VALUE_CODE,
1446
+ at as COLUMN_AS_PROPERTY_VALUE_CODE,
1447
+ a$ as COLUMN_DROPPED_CODE,
609
1448
  C as COLUMN_RENAMED_CODE,
610
- a5 as COLUMN_RENAMED_LOSS_CODE,
611
- ai as COUNT_HINT_CODE,
612
- l as COUNT_MISMATCH_CODE,
1449
+ b0 as COLUMN_RENAMED_LOSS_CODE,
1450
+ A as COLUMN_TYPE_CODE,
1451
+ b1 as CONTROL_CHARACTER_CODE,
1452
+ k as COUNT_HINT_CODE,
1453
+ j as COUNT_MISMATCH_CODE,
613
1454
  CSV_CAPABILITIES,
614
1455
  CSV_ISSUE,
615
1456
  CSV_LOSS,
616
1457
  C4 as CX2_CAPABILITIES,
617
1458
  C5 as CX2_ISSUE,
618
- a11 as CX2_LOSS,
619
- C3 as CX_ISSUE,
620
- C6 as CYS_ISSUE,
1459
+ a8 as CX2_LOSS,
1460
+ C3 as CX_CAPABILITIES,
1461
+ a7 as CX_ISSUE,
1462
+ b as CX_LOSS,
1463
+ C6 as CYS_CAPABILITIES,
1464
+ a9 as CYS_ISSUE,
1465
+ b10 as CYS_LOSS,
621
1466
  C2 as ChildrenCsr,
622
- j as DANGLING_REFERENCE_CODE,
623
- D3 as DEFAULT_CHUNK_BYTES,
624
- aj as DEFAULT_ERROR_LIMIT,
625
- ak as DIRECTED_COLUMN,
1467
+ i as DANGLING_REFERENCE_CODE,
1468
+ D2 as DEFAULT_CHUNK_BYTES,
1469
+ b2 as DEFAULT_ERROR_LIMIT,
1470
+ b3 as DIRECTED_COLUMN,
1471
+ b4 as DIRECTION_DROPPED_CODE,
626
1472
  D as DIRECTION_FORCED_CODE,
627
- a as DIRECTION_REFUSED_CODE,
628
- D2 as DOT_ISSUE,
629
- a12 as DOT_LOSS,
630
- i as DUPLICATE_ATTRIBUTE_CODE,
631
- c as DUPLICATE_EDGE_ID_CODE,
632
- al as DUPLICATE_KEY_CODE,
633
- d as DUPLICATE_NODE_CODE,
634
- J as DirectionResolver,
635
- a4 as EMPTY_COLUMN_DROPPED_CODE,
636
- u as EMPTY_INPUT_CODE,
637
- E as ENCODING_FALLBACK_CODE,
638
- am as EQUATION_AS_TEXT_CODE,
1473
+ d as DIRECTION_REFUSED_CODE,
1474
+ D3 as DOT_ISSUE,
1475
+ a10 as DOT_LOSS,
1476
+ o as DUPLICATE_ATTRIBUTE_CODE,
1477
+ b5 as DUPLICATE_EDGE_CODE,
1478
+ m as DUPLICATE_EDGE_ID_CODE,
1479
+ u as DUPLICATE_KEY_CODE,
1480
+ n as DUPLICATE_NODE_CODE,
1481
+ DirectionResolver,
1482
+ EDGES_MERGED_CODE,
1483
+ F as ELEMENT_ISSUE,
1484
+ b6 as EMPTY_COLUMN_DROPPED_CODE,
1485
+ EMPTY_INPUT_CODE,
1486
+ v as ENCODING_CONFLICT_CODE,
1487
+ x as ENCODING_FALLBACK_CODE,
1488
+ b7 as EQUATION_AS_TEXT_CODE,
1489
+ FETCH_CODE,
1490
+ b8 as FOREIGN_FORMAT_CODE,
639
1491
  FormatRegistry,
640
1492
  GEXF_1_2_CAPABILITIES,
641
1493
  GEXF_ISSUE,
642
1494
  GEXF_LOSS,
643
1495
  GML_ISSUE,
644
1496
  GML_LOSS,
645
- G2 as GRAPHML_ISSUE,
646
- a13 as GRAPHML_LOSS,
647
- G3 as GRAPH_FORMATS,
648
- G as GRAPH_NOT_FOUND_CODE,
649
- an as HYPEREDGE_CODE,
1497
+ G3 as GRAPHML_ISSUE,
1498
+ a15 as GRAPHML_LOSS,
1499
+ aB as GRAPH_COLUMN_AS_METADATA_CODE,
1500
+ G2 as GRAPH_FORMATS,
1501
+ af as GRAPH_NOT_FOUND_CODE,
1502
+ GraphBuilder2 as GraphBuilder,
1503
+ GraphFormatError2 as GraphFormatError,
1504
+ H as HYPEREDGE_CODE,
650
1505
  I as ID_MERGED_CODE,
651
1506
  ID_SPACE_COLUMN,
652
- a8 as ID_TEXT_COLLISION_CODE,
653
- b as ID_TEXT_TYPE_CODE,
654
- a2 as INTEGRAL_F64_CODE,
655
- r as INVALID_ENCODING_CODE,
656
- s as INVALID_UTF8_CODE,
657
- K as IdCoercer,
658
- ao as ImportError,
1507
+ b9 as ID_TEXT_COLLISION_CODE,
1508
+ J as ID_TEXT_TYPE_CODE,
1509
+ G as INPUT_ISSUE,
1510
+ ba as INTEGRAL_F64_CODE,
1511
+ y as INVALID_ENCODING_CODE,
1512
+ INVALID_INDEX2 as INVALID_INDEX,
1513
+ z as INVALID_UTF8_CODE,
1514
+ bb as ISSUES_SUPPRESSED_CODE,
1515
+ IdCoercer,
1516
+ ImportError,
659
1517
  ImportReportBuilder,
660
1518
  J2 as JSON_DIALECTS,
661
- a14 as JSON_ISSUE,
662
- b2 as JSON_LOSS,
1519
+ a11 as JSON_ISSUE,
1520
+ b11 as JSON_LOSS,
1521
+ a2 as JSON_NONSTANDARD_NUMBER_CODE,
663
1522
  LABELS_COLUMN,
664
- L2 as LOSS,
665
- ap as LineReader,
666
- e as MISSING_ENDPOINT_CODE,
667
- f as MISSING_ID_CODE,
668
- af as MIXED_DIRECTION_CODE,
669
- M as MULTIPLE_GRAPHS_CODE,
670
- a9 as MUTUAL_AS_UNDIRECTED_CODE,
671
- aq as MUTUAL_COLUMN,
672
- aa as MUTUAL_EXPANDED_CODE,
1523
+ L as LOSS,
1524
+ LineReader,
1525
+ s as MISSING_ENDPOINT_CODE,
1526
+ t as MISSING_ID_CODE,
1527
+ M as MIXED_DIRECTION_CODE,
1528
+ l as MULTIPLE_GRAPHS_CODE,
1529
+ W as MULTI_ASPECT_FRAGMENT_CODE,
1530
+ T as MUTUAL_AS_UNDIRECTED_CODE,
1531
+ bc as MUTUAL_COLUMN,
1532
+ bd as MUTUAL_EXPANDED_CODE,
673
1533
  NEO4J_CAPABILITIES,
674
1534
  NEO4J_ISSUE,
675
1535
  NEO4J_LOSS,
676
- N2 as NO_CAPABILITIES,
1536
+ aA as NODE_ORDER_CODE,
1537
+ be as NONFINITE_AS_NULL_CODE,
1538
+ bf as NO_CAPABILITIES,
677
1539
  N as NO_GRAPH_CODE,
678
- O2 as OBO_ISSUE,
679
- $ as OPTIONS_GAINED_CODE,
680
- O as OPTION_IGNORED_CODE,
1540
+ O as OBO_CAPABILITIES,
1541
+ a12 as OBO_ISSUE,
1542
+ b12 as OBO_LOSS,
1543
+ bg as OPTIONS_GAINED_CODE,
1544
+ OPTION_IGNORED_CODE,
681
1545
  ORIGINAL_ID_COLUMN,
682
- ar as PAIR_COLUMN,
1546
+ bh as PAIR_COLUMN,
683
1547
  P2 as PAJEK_ISSUE,
684
- a15 as PAJEK_LOSS,
685
- ab as PARENTS_DROPPED_CODE,
686
- h as PARENT_CYCLE_CODE,
687
- as as PARSE_ERROR_CODE,
1548
+ a13 as PAJEK_LOSS,
1549
+ Q as PARENTS_DROPPED_CODE,
1550
+ ai as PARENT_CYCLE_CODE,
1551
+ bi as PARSE_ERROR_CODE,
688
1552
  P as PRECISION_CODE,
689
- at as RENAMED_CODE,
690
- a6 as ROLE_ASSUMED_CODE,
691
- ac as ROLE_DROPPED_CODE,
1553
+ aD as RELATION_ASSUMED_CODE,
1554
+ ay as RENAMED_CODE,
1555
+ au as ROLE_ASSUMED_CODE,
1556
+ K as ROLE_DROPPED_CODE,
692
1557
  R as ROLE_TAKEN_CODE,
1558
+ SELF_LOOPS_DROPPED_CODE,
1559
+ bj as SELF_LOOP_CODE,
1560
+ ag as SINGLE_OBJECT_ASPECT_CODE,
693
1561
  S as SINK_OPTION_CODE,
1562
+ SNIFF_FAILED_CODE,
694
1563
  SNIFF_HEAD_BYTES,
695
- p as STATUS_FAILED_CODE,
696
- o as STATUS_WARNING_CODE,
697
- a3 as STORAGE_CLASS_CODE,
698
- au as STRAY_TEXT_CODE,
699
- g as STYLES_NOT_IMPORTED_CODE,
700
- t as SYNTAX_CODE,
701
- ae as TEMPORAL_DROPPED_CODE,
702
- ad as TEMPORAL_TEXT_DROPPED_CODE,
703
- a1 as TEXT_INFERRED_CODE,
704
- T as TOO_LARGE_CODE,
1564
+ Z as STATUS_FAILED_CODE,
1565
+ _ as STATUS_WARNING_CODE,
1566
+ bk as STORAGE_CLASS_CODE,
1567
+ f as STRAY_TEXT_CODE,
1568
+ ah as STYLES_NOT_IMPORTED_CODE,
1569
+ ak as SYNTAX_CODE,
1570
+ bl as TEMPORAL_DROPPED_CODE,
1571
+ bm as TEMPORAL_TEXT_DROPPED_CODE,
1572
+ bn as TEXT_INFERRED_CODE,
1573
+ ad as TOO_LARGE_CODE,
1574
+ aC as TYPEDEF_NODES_CODE,
705
1575
  TYPE_COLUMN,
706
- T2 as TextCellWriter,
707
- k as UNKNOWN_ATTR_TYPE_CODE,
708
- Y as UNKNOWN_ELEMENT_CODE,
709
- q as UNKNOWN_ENCODING_CODE,
1576
+ TextCellWriter,
1577
+ U as UNKNOWN_ATTR_TYPE_CODE,
1578
+ g as UNKNOWN_ELEMENT_CODE,
1579
+ w as UNKNOWN_ENCODING_CODE,
710
1580
  UNKNOWN_FORMAT_CODE,
711
- U as UNKNOWN_PARENT_CODE,
712
- av as UNKNOWN_TYPE_CODE,
713
- a7 as WEIGHT_KEY_CLASH_CODE,
714
- W as WIDENED_CODE,
1581
+ UNKNOWN_OPTION_CODE,
1582
+ q as UNKNOWN_PARENT_CODE,
1583
+ bo as UNKNOWN_TYPE_CODE,
1584
+ h as UNKNOWN_XML_ATTRIBUTE_CODE,
1585
+ bp as WEIGHTS_DROPPED_CODE,
1586
+ bq as WEIGHT_KEY_CLASH_CODE,
1587
+ WEIGHT_NOT_FOUND_CODE,
1588
+ aj as WIDENED_CODE,
715
1589
  W2 as WIDENING_UNSUPPORTED_CODE,
716
1590
  X2 as XGMML_ISSUE,
717
- a16 as XGMML_LOSS,
718
- a0 as XML_ILLEGAL_CHAR_CODE,
719
- aw as XML_SYNTAX_CODE,
1591
+ a14 as XGMML_LOSS,
1592
+ ax as XML_ILLEGAL_CHAR_CODE,
1593
+ X as XML_SYNTAX_CODE,
720
1594
  X3 as XmlSyntaxError,
721
- b4 as XmlTokenizer,
722
- ax as canonicalId,
723
- c3 as capabilities,
724
- a17 as checkCapabilities,
1595
+ b13 as XmlTokenizer,
1596
+ aH as canonicalId,
1597
+ c as capabilities,
1598
+ a as checkCapabilities,
725
1599
  checkExport,
726
1600
  c2 as childrenCsr,
727
- a10 as childrenFromColumn,
728
- H as chooseGraph,
729
- ay as coerceId,
730
- az as coerceIdText,
731
- c5 as collectBytes,
1601
+ a6 as childrenFromColumn,
1602
+ chooseGraph,
1603
+ br as coerceId,
1604
+ aI as coerceIdText,
1605
+ collectBytes,
1606
+ compareSnapshots,
732
1607
  createRegistry,
733
1608
  csvExporter,
734
1609
  csvImporter,
735
1610
  cx2Exporter,
736
1611
  cx2Importer,
1612
+ cxExporter,
737
1613
  cxImporter,
1614
+ cysExporter,
738
1615
  cysImporter,
739
- aA as declareCompanion,
740
- L as declareResolved,
741
- d4 as decodeChunks,
742
- aB as decodeEntryName,
743
- d2 as dialectCapabilities,
1616
+ bs as declareCompanion,
1617
+ a1 as declareResolved,
1618
+ d2 as decodeChunks,
1619
+ bt as decodeEntryName,
1620
+ defineLineFormat,
1621
+ describeDiffs,
1622
+ d3 as dialectCapabilities,
744
1623
  dotExporter,
745
1624
  dotImporter,
746
- e3 as encodeChunks,
747
- e2 as explicitWeights,
1625
+ downloadGraph,
1626
+ bu as edgeWeights,
1627
+ e2 as encodeChunks,
1628
+ e as explicitWeights,
748
1629
  exportGraph,
1630
+ exportGraphToBlob,
1631
+ exportGraphToBytes,
749
1632
  exportGraphToString,
750
- f2 as extensionOf,
751
- b3 as formatDecimal,
752
- f3 as formatF32,
753
- a18 as formatF64,
754
- c4 as formatGmlReal,
755
- d3 as formatInteger,
1633
+ exportNeo4jFiles,
1634
+ g2 as extensionOf,
1635
+ bv as forDecodedText,
1636
+ aF as formatDecimal,
1637
+ aa as formatF32,
1638
+ ab as formatF64,
1639
+ bw as formatGmlReal,
1640
+ aG as formatInteger,
756
1641
  gexfExporter,
757
1642
  gexfImporter,
758
1643
  gmlExporter,
759
1644
  gmlImporter,
1645
+ ap as graphChosen,
760
1646
  graphmlExporter,
761
1647
  graphmlImporter,
762
1648
  h3 as hasIllegalXmlChar,
763
1649
  h2 as headBytes,
764
1650
  importAllGraphs,
765
1651
  importGraph,
766
- i4 as inferTextDtype,
767
- aC as inputLength,
768
- aD as isAbortError,
769
- aE as isCanonicalIntegerText,
770
- aF as isImportInput,
771
- i2 as isNmtoken,
772
- a19 as isNumericText,
773
- i3 as isWeightField,
774
- j3 as joinText,
775
- j2 as jsonCapabilities,
1652
+ i2 as inferTextDtype,
1653
+ bx as inputLength,
1654
+ isAbortError,
1655
+ by as isCanonicalIntegerText,
1656
+ bz as isImportInput,
1657
+ bA as isNmtoken,
1658
+ a5 as isNumericText,
1659
+ aK as isWeightField,
1660
+ j2 as joinText,
1661
+ j3 as jsonCapabilities,
776
1662
  jsonExporter,
777
1663
  jsonImporter,
1664
+ f2 as jsonShapeOf,
1665
+ listFormats,
778
1666
  listGraphs,
779
- m2 as mangleNmtoken,
1667
+ loadFromFile,
1668
+ loadFromUrl,
1669
+ bB as mangleNmtoken,
780
1670
  neo4jExporter,
781
1671
  neo4jImporter,
782
1672
  n2 as normalizeMimeType,
1673
+ oboExporter,
783
1674
  oboImporter,
784
- X as pairFolding,
1675
+ p as pairFolding,
785
1676
  pajekExporter,
786
1677
  pajekImporter,
787
- p3 as parseTextCell,
788
- p2 as parseWeightText,
1678
+ p2 as parseTextCell,
1679
+ parseWeightText,
789
1680
  rankFormats,
790
- aG as readText,
1681
+ bC as readText,
1682
+ bD as refusedSave,
791
1683
  registry,
792
- F as reportSinkOptions,
793
- z as reportUnusedOptions,
794
- V as resolveExportOptions,
795
- v as resolveImportOptions,
796
- s3 as sanitizeIds,
1684
+ reportSinkOptions,
1685
+ reportUnusedOptions,
1686
+ r as resolveExportOptions,
1687
+ resolveImportOptions,
1688
+ aE as sanitizeIds,
797
1689
  sniff,
798
1690
  s2 as sniffFormat,
799
- g2 as sniffJsonDialectHead,
800
- x as textChunks,
1691
+ i3 as sniffJsonDialectHead,
1692
+ a4 as textChunks,
801
1693
  throwIfAborted,
802
1694
  t2 as toReadableStream,
803
1695
  t3 as tokenizeXml,