@graphty/graph-io 0.3.25 → 0.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (581) hide show
  1. package/README.md +49 -414
  2. package/dist/chunks/children-CL3Cy0ez.js.map +1 -1
  3. package/dist/chunks/choose-BbJI55dx.js +56 -0
  4. package/dist/chunks/choose-BbJI55dx.js.map +1 -0
  5. package/dist/chunks/constants-BCsFsMj4.js +231 -0
  6. package/dist/chunks/constants-BCsFsMj4.js.map +1 -0
  7. package/dist/chunks/{escape-B-tkk_Cl.js → escape-D0g6NNUy.js} +382 -92
  8. package/dist/chunks/escape-D0g6NNUy.js.map +1 -0
  9. package/dist/chunks/export-BTI4yQgy.js +4333 -0
  10. package/dist/chunks/export-BTI4yQgy.js.map +1 -0
  11. package/dist/chunks/exporter-BMqk5oxW.js +3465 -0
  12. package/dist/chunks/exporter-BMqk5oxW.js.map +1 -0
  13. package/dist/chunks/{importer-eUREhBGj.js → exporter-Cra2GYcN.js} +4969 -3201
  14. package/dist/chunks/exporter-Cra2GYcN.js.map +1 -0
  15. package/dist/chunks/{exporter-BGrsWamJ.js → exporter-Dxh231ZF.js} +38 -229
  16. package/dist/chunks/exporter-Dxh231ZF.js.map +1 -0
  17. package/dist/chunks/{exporter-DIeGJXAZ.js → exporter-tne475KK.js} +22 -20
  18. package/dist/chunks/exporter-tne475KK.js.map +1 -0
  19. package/dist/chunks/importer-90YWhJoF.js +2811 -0
  20. package/dist/chunks/importer-90YWhJoF.js.map +1 -0
  21. package/dist/chunks/{importer-D_e7e7LX.js → importer-Bcl1d4xH.js} +398 -145
  22. package/dist/chunks/importer-Bcl1d4xH.js.map +1 -0
  23. package/dist/chunks/{importer-BWY2FFc5.js → importer-BfIsp1f9.js} +255 -77
  24. package/dist/chunks/importer-BfIsp1f9.js.map +1 -0
  25. package/dist/chunks/{importer-zGLo8Dg_.js → importer-C_TEA1zJ.js} +484 -157
  26. package/dist/chunks/importer-C_TEA1zJ.js.map +1 -0
  27. package/dist/chunks/{importer-DET1tg6s.js → importer-DCjOvO7U.js} +1687 -310
  28. package/dist/chunks/importer-DCjOvO7U.js.map +1 -0
  29. package/dist/chunks/{importer-vi3bSdtw.js → importer-DfVu6j59.js} +509 -76
  30. package/dist/chunks/importer-DfVu6j59.js.map +1 -0
  31. package/dist/chunks/{importer-DIrbbnAf.js → importer-Dku_VAIY.js} +585 -226
  32. package/dist/chunks/importer-Dku_VAIY.js.map +1 -0
  33. package/dist/chunks/json-elements-3tnyt5uZ.js +1225 -0
  34. package/dist/chunks/json-elements-3tnyt5uZ.js.map +1 -0
  35. package/dist/chunks/ontology-export-B9Tcf37D.js +357 -0
  36. package/dist/chunks/ontology-export-B9Tcf37D.js.map +1 -0
  37. package/dist/chunks/{records-dbRkxwaq.js → records-CQXT__mY.js} +298 -114
  38. package/dist/chunks/records-CQXT__mY.js.map +1 -0
  39. package/dist/chunks/{text-Dr0Ifpag.js → text-DmcUs5_Q.js} +29 -11
  40. package/dist/chunks/text-DmcUs5_Q.js.map +1 -0
  41. package/dist/chunks/{writer-C7flM-Ih.js → writer-DxjgHwSe.js} +19 -1
  42. package/dist/chunks/writer-DxjgHwSe.js.map +1 -0
  43. package/dist/csv.js +951 -261
  44. package/dist/csv.js.map +1 -1
  45. package/dist/cx.js +6 -3
  46. package/dist/cx2.js +2 -2
  47. package/dist/cys.js +6 -3
  48. package/dist/dot.js +1 -1
  49. package/dist/gexf.js +554 -122
  50. package/dist/gexf.js.map +1 -1
  51. package/dist/gml.js +342 -85
  52. package/dist/gml.js.map +1 -1
  53. package/dist/graph-io.js +1105 -213
  54. package/dist/graph-io.js.map +1 -1
  55. package/dist/graphml.js +3 -2
  56. package/dist/graphml.js.map +1 -1
  57. package/dist/json.js +3 -2
  58. package/dist/neo4j.js +564 -157
  59. package/dist/neo4j.js.map +1 -1
  60. package/dist/obo.js +6 -3
  61. package/dist/pajek.js +1 -1
  62. package/dist/src/children.d.ts +18 -6
  63. package/dist/src/children.d.ts.map +1 -1
  64. package/dist/src/children.js +6 -3
  65. package/dist/src/children.js.map +1 -1
  66. package/dist/src/common/attributes.d.ts +29 -11
  67. package/dist/src/common/attributes.d.ts.map +1 -1
  68. package/dist/src/common/attributes.js +25 -7
  69. package/dist/src/common/attributes.js.map +1 -1
  70. package/dist/src/common/cell-budget.d.ts +9 -2
  71. package/dist/src/common/cell-budget.d.ts.map +1 -1
  72. package/dist/src/common/cell-budget.js +11 -3
  73. package/dist/src/common/cell-budget.js.map +1 -1
  74. package/dist/src/common/choose.d.ts +19 -0
  75. package/dist/src/common/choose.d.ts.map +1 -0
  76. package/dist/src/common/choose.js +72 -0
  77. package/dist/src/common/choose.js.map +1 -0
  78. package/dist/src/common/codes.d.ts +456 -66
  79. package/dist/src/common/codes.d.ts.map +1 -1
  80. package/dist/src/common/codes.js +458 -66
  81. package/dist/src/common/codes.js.map +1 -1
  82. package/dist/src/common/compare.d.ts +81 -0
  83. package/dist/src/common/compare.d.ts.map +1 -0
  84. package/dist/src/common/compare.js +394 -0
  85. package/dist/src/common/compare.js.map +1 -0
  86. package/dist/src/common/cx-export.d.ts +123 -0
  87. package/dist/src/common/cx-export.d.ts.map +1 -0
  88. package/dist/src/common/cx-export.js +334 -0
  89. package/dist/src/common/cx-export.js.map +1 -0
  90. package/dist/src/common/declared-types.d.ts +22 -2
  91. package/dist/src/common/declared-types.d.ts.map +1 -1
  92. package/dist/src/common/declared-types.js +19 -1
  93. package/dist/src/common/declared-types.js.map +1 -1
  94. package/dist/src/common/direction.d.ts +74 -50
  95. package/dist/src/common/direction.d.ts.map +1 -1
  96. package/dist/src/common/direction.js +47 -27
  97. package/dist/src/common/direction.js.map +1 -1
  98. package/dist/src/common/escape.d.ts +21 -9
  99. package/dist/src/common/escape.d.ts.map +1 -1
  100. package/dist/src/common/escape.js +33 -17
  101. package/dist/src/common/escape.js.map +1 -1
  102. package/dist/src/common/export.d.ts +144 -32
  103. package/dist/src/common/export.d.ts.map +1 -1
  104. package/dist/src/common/export.js +216 -42
  105. package/dist/src/common/export.js.map +1 -1
  106. package/dist/src/common/format.d.ts +23 -1
  107. package/dist/src/common/format.d.ts.map +1 -1
  108. package/dist/src/common/format.js +26 -1
  109. package/dist/src/common/format.js.map +1 -1
  110. package/dist/src/common/ids.d.ts +9 -2
  111. package/dist/src/common/ids.d.ts.map +1 -1
  112. package/dist/src/common/ids.js +6 -2
  113. package/dist/src/common/ids.js.map +1 -1
  114. package/dist/src/common/input.d.ts +122 -28
  115. package/dist/src/common/input.d.ts.map +1 -1
  116. package/dist/src/common/input.js +890 -124
  117. package/dist/src/common/input.js.map +1 -1
  118. package/dist/src/common/json-elements.d.ts +144 -20
  119. package/dist/src/common/json-elements.d.ts.map +1 -1
  120. package/dist/src/common/json-elements.js +868 -188
  121. package/dist/src/common/json-elements.js.map +1 -1
  122. package/dist/src/common/line-format.d.ts +90 -0
  123. package/dist/src/common/line-format.d.ts.map +1 -0
  124. package/dist/src/common/line-format.js +185 -0
  125. package/dist/src/common/line-format.js.map +1 -0
  126. package/dist/src/common/lists.d.ts +6 -1
  127. package/dist/src/common/lists.d.ts.map +1 -1
  128. package/dist/src/common/lists.js +2 -0
  129. package/dist/src/common/lists.js.map +1 -1
  130. package/dist/src/common/ontology-export.d.ts +167 -0
  131. package/dist/src/common/ontology-export.d.ts.map +1 -0
  132. package/dist/src/common/ontology-export.js +359 -0
  133. package/dist/src/common/ontology-export.js.map +1 -0
  134. package/dist/src/common/ontology.d.ts +25 -3
  135. package/dist/src/common/ontology.d.ts.map +1 -1
  136. package/dist/src/common/ontology.js +30 -9
  137. package/dist/src/common/ontology.js.map +1 -1
  138. package/dist/src/common/options.d.ts +62 -12
  139. package/dist/src/common/options.d.ts.map +1 -1
  140. package/dist/src/common/options.js +89 -11
  141. package/dist/src/common/options.js.map +1 -1
  142. package/dist/src/common/plural.d.ts +31 -0
  143. package/dist/src/common/plural.d.ts.map +1 -0
  144. package/dist/src/common/plural.js +46 -0
  145. package/dist/src/common/plural.js.map +1 -0
  146. package/dist/src/common/report.d.ts +72 -14
  147. package/dist/src/common/report.d.ts.map +1 -1
  148. package/dist/src/common/report.js +146 -22
  149. package/dist/src/common/report.js.map +1 -1
  150. package/dist/src/common/temporal.d.ts +22 -5
  151. package/dist/src/common/temporal.d.ts.map +1 -1
  152. package/dist/src/common/temporal.js +13 -2
  153. package/dist/src/common/temporal.js.map +1 -1
  154. package/dist/src/common/text.d.ts +39 -23
  155. package/dist/src/common/text.d.ts.map +1 -1
  156. package/dist/src/common/text.js +51 -21
  157. package/dist/src/common/text.js.map +1 -1
  158. package/dist/src/common/weights.d.ts +37 -4
  159. package/dist/src/common/weights.d.ts.map +1 -1
  160. package/dist/src/common/weights.js +61 -2
  161. package/dist/src/common/weights.js.map +1 -1
  162. package/dist/src/common/writer.d.ts +19 -3
  163. package/dist/src/common/writer.d.ts.map +1 -1
  164. package/dist/src/common/writer.js +30 -2
  165. package/dist/src/common/writer.js.map +1 -1
  166. package/dist/src/common/xml.d.ts +125 -9
  167. package/dist/src/common/xml.d.ts.map +1 -1
  168. package/dist/src/common/xml.js +400 -83
  169. package/dist/src/common/xml.js.map +1 -1
  170. package/dist/src/common/zip.d.ts +44 -4
  171. package/dist/src/common/zip.d.ts.map +1 -1
  172. package/dist/src/common/zip.js +134 -5
  173. package/dist/src/common/zip.js.map +1 -1
  174. package/dist/src/formats/csv/exporter.d.ts +80 -24
  175. package/dist/src/formats/csv/exporter.d.ts.map +1 -1
  176. package/dist/src/formats/csv/exporter.js +145 -32
  177. package/dist/src/formats/csv/exporter.js.map +1 -1
  178. package/dist/src/formats/csv/header.d.ts +38 -9
  179. package/dist/src/formats/csv/header.d.ts.map +1 -1
  180. package/dist/src/formats/csv/header.js +46 -10
  181. package/dist/src/formats/csv/header.js.map +1 -1
  182. package/dist/src/formats/csv/importer.d.ts +187 -37
  183. package/dist/src/formats/csv/importer.d.ts.map +1 -1
  184. package/dist/src/formats/csv/importer.js +835 -204
  185. package/dist/src/formats/csv/importer.js.map +1 -1
  186. package/dist/src/formats/csv/index.d.ts +100 -19
  187. package/dist/src/formats/csv/index.d.ts.map +1 -1
  188. package/dist/src/formats/csv/index.js +94 -21
  189. package/dist/src/formats/csv/index.js.map +1 -1
  190. package/dist/src/formats/csv/records.d.ts +95 -10
  191. package/dist/src/formats/csv/records.d.ts.map +1 -1
  192. package/dist/src/formats/csv/records.js +333 -122
  193. package/dist/src/formats/csv/records.js.map +1 -1
  194. package/dist/src/formats/csv/values.d.ts +1 -0
  195. package/dist/src/formats/csv/values.d.ts.map +1 -1
  196. package/dist/src/formats/csv/values.js +1 -0
  197. package/dist/src/formats/csv/values.js.map +1 -1
  198. package/dist/src/formats/cx/exporter.d.ts +102 -0
  199. package/dist/src/formats/cx/exporter.d.ts.map +1 -0
  200. package/dist/src/formats/cx/exporter.js +1217 -0
  201. package/dist/src/formats/cx/exporter.js.map +1 -0
  202. package/dist/src/formats/cx/importer.d.ts +79 -32
  203. package/dist/src/formats/cx/importer.d.ts.map +1 -1
  204. package/dist/src/formats/cx/importer.js +680 -285
  205. package/dist/src/formats/cx/importer.js.map +1 -1
  206. package/dist/src/formats/cx/index.d.ts +4 -3
  207. package/dist/src/formats/cx/index.d.ts.map +1 -1
  208. package/dist/src/formats/cx/index.js +4 -3
  209. package/dist/src/formats/cx/index.js.map +1 -1
  210. package/dist/src/formats/cx2/exporter.d.ts +29 -11
  211. package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
  212. package/dist/src/formats/cx2/exporter.js +39 -268
  213. package/dist/src/formats/cx2/exporter.js.map +1 -1
  214. package/dist/src/formats/cx2/importer.d.ts +78 -28
  215. package/dist/src/formats/cx2/importer.d.ts.map +1 -1
  216. package/dist/src/formats/cx2/importer.js +226 -79
  217. package/dist/src/formats/cx2/importer.js.map +1 -1
  218. package/dist/src/formats/cx2/index.d.ts +2 -1
  219. package/dist/src/formats/cx2/index.d.ts.map +1 -1
  220. package/dist/src/formats/cx2/index.js +2 -1
  221. package/dist/src/formats/cx2/index.js.map +1 -1
  222. package/dist/src/formats/cys/constants.d.ts +66 -17
  223. package/dist/src/formats/cys/constants.d.ts.map +1 -1
  224. package/dist/src/formats/cys/constants.js +59 -18
  225. package/dist/src/formats/cys/constants.js.map +1 -1
  226. package/dist/src/formats/cys/exporter.d.ts +118 -0
  227. package/dist/src/formats/cys/exporter.d.ts.map +1 -0
  228. package/dist/src/formats/cys/exporter.js +1072 -0
  229. package/dist/src/formats/cys/exporter.js.map +1 -0
  230. package/dist/src/formats/cys/importer.d.ts +22 -8
  231. package/dist/src/formats/cys/importer.d.ts.map +1 -1
  232. package/dist/src/formats/cys/importer.js +510 -149
  233. package/dist/src/formats/cys/importer.js.map +1 -1
  234. package/dist/src/formats/cys/index.d.ts +4 -2
  235. package/dist/src/formats/cys/index.d.ts.map +1 -1
  236. package/dist/src/formats/cys/index.js +4 -2
  237. package/dist/src/formats/cys/index.js.map +1 -1
  238. package/dist/src/formats/cys/session.d.ts +46 -7
  239. package/dist/src/formats/cys/session.d.ts.map +1 -1
  240. package/dist/src/formats/cys/session.js +98 -24
  241. package/dist/src/formats/cys/session.js.map +1 -1
  242. package/dist/src/formats/cys/tables.d.ts +9 -2
  243. package/dist/src/formats/cys/tables.d.ts.map +1 -1
  244. package/dist/src/formats/cys/tables.js +29 -7
  245. package/dist/src/formats/cys/tables.js.map +1 -1
  246. package/dist/src/formats/dot/exporter.d.ts +42 -14
  247. package/dist/src/formats/dot/exporter.d.ts.map +1 -1
  248. package/dist/src/formats/dot/exporter.js +56 -29
  249. package/dist/src/formats/dot/exporter.js.map +1 -1
  250. package/dist/src/formats/dot/importer.d.ts +91 -29
  251. package/dist/src/formats/dot/importer.d.ts.map +1 -1
  252. package/dist/src/formats/dot/importer.js +190 -39
  253. package/dist/src/formats/dot/importer.js.map +1 -1
  254. package/dist/src/formats/dot/index.d.ts +2 -1
  255. package/dist/src/formats/dot/index.d.ts.map +1 -1
  256. package/dist/src/formats/dot/index.js +2 -1
  257. package/dist/src/formats/dot/index.js.map +1 -1
  258. package/dist/src/formats/dot/names.d.ts +44 -11
  259. package/dist/src/formats/dot/names.d.ts.map +1 -1
  260. package/dist/src/formats/dot/names.js +44 -11
  261. package/dist/src/formats/dot/names.js.map +1 -1
  262. package/dist/src/formats/dot/tokenizer.d.ts +9 -2
  263. package/dist/src/formats/dot/tokenizer.d.ts.map +1 -1
  264. package/dist/src/formats/dot/tokenizer.js +20 -5
  265. package/dist/src/formats/dot/tokenizer.js.map +1 -1
  266. package/dist/src/formats/gexf/exporter.d.ts +46 -15
  267. package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
  268. package/dist/src/formats/gexf/exporter.js +45 -15
  269. package/dist/src/formats/gexf/exporter.js.map +1 -1
  270. package/dist/src/formats/gexf/importer.d.ts +87 -23
  271. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  272. package/dist/src/formats/gexf/importer.js +471 -90
  273. package/dist/src/formats/gexf/importer.js.map +1 -1
  274. package/dist/src/formats/gexf/index.d.ts +84 -21
  275. package/dist/src/formats/gexf/index.d.ts.map +1 -1
  276. package/dist/src/formats/gexf/index.js +80 -23
  277. package/dist/src/formats/gexf/index.js.map +1 -1
  278. package/dist/src/formats/gexf/schema.d.ts +67 -15
  279. package/dist/src/formats/gexf/schema.d.ts.map +1 -1
  280. package/dist/src/formats/gexf/schema.js +59 -13
  281. package/dist/src/formats/gexf/schema.js.map +1 -1
  282. package/dist/src/formats/gml/exporter.d.ts +69 -21
  283. package/dist/src/formats/gml/exporter.d.ts.map +1 -1
  284. package/dist/src/formats/gml/exporter.js +74 -29
  285. package/dist/src/formats/gml/exporter.js.map +1 -1
  286. package/dist/src/formats/gml/importer.d.ts +116 -25
  287. package/dist/src/formats/gml/importer.d.ts.map +1 -1
  288. package/dist/src/formats/gml/importer.js +290 -61
  289. package/dist/src/formats/gml/importer.js.map +1 -1
  290. package/dist/src/formats/gml/index.d.ts +87 -24
  291. package/dist/src/formats/gml/index.d.ts.map +1 -1
  292. package/dist/src/formats/gml/index.js +79 -26
  293. package/dist/src/formats/gml/index.js.map +1 -1
  294. package/dist/src/formats/gml/syntax.d.ts +67 -18
  295. package/dist/src/formats/gml/syntax.d.ts.map +1 -1
  296. package/dist/src/formats/gml/syntax.js +108 -26
  297. package/dist/src/formats/gml/syntax.js.map +1 -1
  298. package/dist/src/formats/graphml/constants.d.ts +174 -44
  299. package/dist/src/formats/graphml/constants.d.ts.map +1 -1
  300. package/dist/src/formats/graphml/constants.js +165 -44
  301. package/dist/src/formats/graphml/constants.js.map +1 -1
  302. package/dist/src/formats/graphml/exporter.d.ts +17 -9
  303. package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
  304. package/dist/src/formats/graphml/exporter.js +33 -12
  305. package/dist/src/formats/graphml/exporter.js.map +1 -1
  306. package/dist/src/formats/graphml/importer.d.ts +19 -7
  307. package/dist/src/formats/graphml/importer.d.ts.map +1 -1
  308. package/dist/src/formats/graphml/importer.js +466 -39
  309. package/dist/src/formats/graphml/importer.js.map +1 -1
  310. package/dist/src/formats/graphml/index.d.ts +2 -1
  311. package/dist/src/formats/graphml/index.d.ts.map +1 -1
  312. package/dist/src/formats/graphml/index.js +2 -1
  313. package/dist/src/formats/graphml/index.js.map +1 -1
  314. package/dist/src/formats/graphml/tree.d.ts +6 -2
  315. package/dist/src/formats/graphml/tree.d.ts.map +1 -1
  316. package/dist/src/formats/graphml/tree.js +6 -2
  317. package/dist/src/formats/graphml/tree.js.map +1 -1
  318. package/dist/src/formats/graphml/yfiles.d.ts +8 -3
  319. package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
  320. package/dist/src/formats/graphml/yfiles.js +36 -15
  321. package/dist/src/formats/graphml/yfiles.js.map +1 -1
  322. package/dist/src/formats/json/dialect.d.ts +88 -24
  323. package/dist/src/formats/json/dialect.d.ts.map +1 -1
  324. package/dist/src/formats/json/dialect.js +109 -19
  325. package/dist/src/formats/json/dialect.js.map +1 -1
  326. package/dist/src/formats/json/exporter.d.ts +134 -22
  327. package/dist/src/formats/json/exporter.d.ts.map +1 -1
  328. package/dist/src/formats/json/exporter.js +135 -54
  329. package/dist/src/formats/json/exporter.js.map +1 -1
  330. package/dist/src/formats/json/importer.d.ts +173 -52
  331. package/dist/src/formats/json/importer.d.ts.map +1 -1
  332. package/dist/src/formats/json/importer.js +899 -220
  333. package/dist/src/formats/json/importer.js.map +1 -1
  334. package/dist/src/formats/json/index.d.ts +3 -2
  335. package/dist/src/formats/json/index.d.ts.map +1 -1
  336. package/dist/src/formats/json/index.js +3 -2
  337. package/dist/src/formats/json/index.js.map +1 -1
  338. package/dist/src/formats/json/obographs-export.d.ts +68 -0
  339. package/dist/src/formats/json/obographs-export.d.ts.map +1 -0
  340. package/dist/src/formats/json/obographs-export.js +941 -0
  341. package/dist/src/formats/json/obographs-export.js.map +1 -0
  342. package/dist/src/formats/json/obographs.d.ts +26 -0
  343. package/dist/src/formats/json/obographs.d.ts.map +1 -1
  344. package/dist/src/formats/json/obographs.js +297 -80
  345. package/dist/src/formats/json/obographs.js.map +1 -1
  346. package/dist/src/formats/neo4j/exporter.d.ts +109 -21
  347. package/dist/src/formats/neo4j/exporter.d.ts.map +1 -1
  348. package/dist/src/formats/neo4j/exporter.js +238 -85
  349. package/dist/src/formats/neo4j/exporter.js.map +1 -1
  350. package/dist/src/formats/neo4j/header.d.ts +17 -4
  351. package/dist/src/formats/neo4j/header.d.ts.map +1 -1
  352. package/dist/src/formats/neo4j/header.js +36 -4
  353. package/dist/src/formats/neo4j/header.js.map +1 -1
  354. package/dist/src/formats/neo4j/importer.d.ts +107 -27
  355. package/dist/src/formats/neo4j/importer.d.ts.map +1 -1
  356. package/dist/src/formats/neo4j/importer.js +415 -63
  357. package/dist/src/formats/neo4j/importer.js.map +1 -1
  358. package/dist/src/formats/neo4j/index.d.ts +73 -23
  359. package/dist/src/formats/neo4j/index.d.ts.map +1 -1
  360. package/dist/src/formats/neo4j/index.js +65 -25
  361. package/dist/src/formats/neo4j/index.js.map +1 -1
  362. package/dist/src/formats/obo/exporter.d.ts +150 -0
  363. package/dist/src/formats/obo/exporter.d.ts.map +1 -0
  364. package/dist/src/formats/obo/exporter.js +1736 -0
  365. package/dist/src/formats/obo/exporter.js.map +1 -0
  366. package/dist/src/formats/obo/importer.d.ts +95 -19
  367. package/dist/src/formats/obo/importer.d.ts.map +1 -1
  368. package/dist/src/formats/obo/importer.js +475 -104
  369. package/dist/src/formats/obo/importer.js.map +1 -1
  370. package/dist/src/formats/obo/index.d.ts +6 -3
  371. package/dist/src/formats/obo/index.d.ts.map +1 -1
  372. package/dist/src/formats/obo/index.js +6 -3
  373. package/dist/src/formats/obo/index.js.map +1 -1
  374. package/dist/src/formats/obo/syntax.d.ts +108 -4
  375. package/dist/src/formats/obo/syntax.d.ts.map +1 -1
  376. package/dist/src/formats/obo/syntax.js +211 -34
  377. package/dist/src/formats/obo/syntax.js.map +1 -1
  378. package/dist/src/formats/pajek/exporter.d.ts +54 -16
  379. package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
  380. package/dist/src/formats/pajek/exporter.js +66 -34
  381. package/dist/src/formats/pajek/exporter.js.map +1 -1
  382. package/dist/src/formats/pajek/importer.d.ts +84 -22
  383. package/dist/src/formats/pajek/importer.d.ts.map +1 -1
  384. package/dist/src/formats/pajek/importer.js +303 -83
  385. package/dist/src/formats/pajek/importer.js.map +1 -1
  386. package/dist/src/formats/pajek/index.d.ts +2 -1
  387. package/dist/src/formats/pajek/index.d.ts.map +1 -1
  388. package/dist/src/formats/pajek/index.js +2 -1
  389. package/dist/src/formats/pajek/index.js.map +1 -1
  390. package/dist/src/formats/pajek/syntax.d.ts +77 -14
  391. package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
  392. package/dist/src/formats/pajek/syntax.js +183 -51
  393. package/dist/src/formats/pajek/syntax.js.map +1 -1
  394. package/dist/src/formats/xgmml/columns.d.ts +1 -0
  395. package/dist/src/formats/xgmml/columns.d.ts.map +1 -1
  396. package/dist/src/formats/xgmml/columns.js +4 -0
  397. package/dist/src/formats/xgmml/columns.js.map +1 -1
  398. package/dist/src/formats/xgmml/constants.d.ts +186 -56
  399. package/dist/src/formats/xgmml/constants.d.ts.map +1 -1
  400. package/dist/src/formats/xgmml/constants.js +181 -57
  401. package/dist/src/formats/xgmml/constants.js.map +1 -1
  402. package/dist/src/formats/xgmml/document.d.ts +65 -11
  403. package/dist/src/formats/xgmml/document.d.ts.map +1 -1
  404. package/dist/src/formats/xgmml/document.js +157 -28
  405. package/dist/src/formats/xgmml/document.js.map +1 -1
  406. package/dist/src/formats/xgmml/emit.d.ts +61 -3
  407. package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
  408. package/dist/src/formats/xgmml/emit.js +129 -26
  409. package/dist/src/formats/xgmml/emit.js.map +1 -1
  410. package/dist/src/formats/xgmml/exporter.d.ts +13 -6
  411. package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
  412. package/dist/src/formats/xgmml/exporter.js +20 -21
  413. package/dist/src/formats/xgmml/exporter.js.map +1 -1
  414. package/dist/src/formats/xgmml/importer.d.ts +33 -12
  415. package/dist/src/formats/xgmml/importer.d.ts.map +1 -1
  416. package/dist/src/formats/xgmml/importer.js +35 -72
  417. package/dist/src/formats/xgmml/importer.js.map +1 -1
  418. package/dist/src/formats/xgmml/index.d.ts +1 -0
  419. package/dist/src/formats/xgmml/index.d.ts.map +1 -1
  420. package/dist/src/formats/xgmml/index.js +1 -0
  421. package/dist/src/formats/xgmml/index.js.map +1 -1
  422. package/dist/src/formats/xgmml/values.d.ts +8 -1
  423. package/dist/src/formats/xgmml/values.d.ts.map +1 -1
  424. package/dist/src/formats/xgmml/values.js +7 -2
  425. package/dist/src/formats/xgmml/values.js.map +1 -1
  426. package/dist/src/index.d.ts +23 -18
  427. package/dist/src/index.d.ts.map +1 -1
  428. package/dist/src/index.js +28 -16
  429. package/dist/src/index.js.map +1 -1
  430. package/dist/src/registry.d.ts +478 -92
  431. package/dist/src/registry.d.ts.map +1 -1
  432. package/dist/src/registry.js +807 -88
  433. package/dist/src/registry.js.map +1 -1
  434. package/dist/src/sniff.d.ts +61 -19
  435. package/dist/src/sniff.d.ts.map +1 -1
  436. package/dist/src/sniff.js +121 -29
  437. package/dist/src/sniff.js.map +1 -1
  438. package/dist/src/types.d.ts +362 -112
  439. package/dist/src/types.d.ts.map +1 -1
  440. package/dist/src/types.js +28 -7
  441. package/dist/src/types.js.map +1 -1
  442. package/dist/xgmml.js +2 -2
  443. package/docs/samples/README.md +25 -0
  444. package/docs/samples/got-edges.csv +353 -0
  445. package/docs/samples/got-network.graphml +1384 -0
  446. package/docs/samples/got-nodes.csv +108 -0
  447. package/docs/samples/got.cx +930 -0
  448. package/docs/samples/got.cx2 +465 -0
  449. package/docs/samples/got.gexf +471 -0
  450. package/docs/samples/got.gml +2650 -0
  451. package/docs/samples/got.json +2546 -0
  452. package/docs/samples/got.net +461 -0
  453. package/docs/samples/movies-nodes.csv +9 -0
  454. package/docs/samples/movies-rels.csv +8 -0
  455. package/docs/samples/networks.cys +0 -0
  456. package/docs/samples/proteins.xgmml +9 -0
  457. package/docs/samples/teams.gv +24 -0
  458. package/docs/samples/vehicles.obo +25 -0
  459. package/package.json +9 -4
  460. package/src/children.ts +18 -6
  461. package/src/common/attributes.ts +29 -11
  462. package/src/common/cell-budget.ts +11 -3
  463. package/src/common/choose.ts +89 -0
  464. package/src/common/codes.ts +490 -66
  465. package/src/common/compare.ts +472 -0
  466. package/src/common/cx-export.ts +432 -0
  467. package/src/common/declared-types.ts +38 -4
  468. package/src/common/direction.ts +78 -51
  469. package/src/common/escape.ts +33 -17
  470. package/src/common/export.ts +284 -47
  471. package/src/common/format.ts +30 -1
  472. package/src/common/ids.ts +14 -3
  473. package/src/common/input.ts +1057 -134
  474. package/src/common/json-elements.ts +1034 -198
  475. package/src/common/line-format.ts +249 -0
  476. package/src/common/lists.ts +6 -1
  477. package/src/common/ontology-export.ts +461 -0
  478. package/src/common/ontology.ts +31 -9
  479. package/src/common/options.ts +110 -15
  480. package/src/common/plural.ts +49 -0
  481. package/src/common/report.ts +168 -25
  482. package/src/common/temporal.ts +22 -5
  483. package/src/common/text.ts +62 -23
  484. package/src/common/weights.ts +74 -4
  485. package/src/common/writer.ts +37 -3
  486. package/src/common/xml.ts +477 -88
  487. package/src/common/zip.ts +169 -7
  488. package/src/formats/csv/exporter.ts +201 -46
  489. package/src/formats/csv/header.ts +50 -11
  490. package/src/formats/csv/importer.ts +1133 -245
  491. package/src/formats/csv/index.ts +106 -19
  492. package/src/formats/csv/records.ts +396 -122
  493. package/src/formats/csv/values.ts +1 -0
  494. package/src/formats/cx/exporter.ts +1483 -0
  495. package/src/formats/cx/importer.ts +888 -300
  496. package/src/formats/cx/index.ts +4 -3
  497. package/src/formats/cx2/exporter.ts +61 -338
  498. package/src/formats/cx2/importer.ts +317 -86
  499. package/src/formats/cx2/index.ts +2 -1
  500. package/src/formats/cys/constants.ts +62 -17
  501. package/src/formats/cys/exporter.ts +1368 -0
  502. package/src/formats/cys/importer.ts +659 -157
  503. package/src/formats/cys/index.ts +4 -2
  504. package/src/formats/cys/session.ts +139 -31
  505. package/src/formats/cys/tables.ts +47 -9
  506. package/src/formats/dot/exporter.ts +83 -37
  507. package/src/formats/dot/importer.ts +248 -54
  508. package/src/formats/dot/index.ts +2 -1
  509. package/src/formats/dot/names.ts +44 -11
  510. package/src/formats/dot/tokenizer.ts +25 -6
  511. package/src/formats/gexf/exporter.ts +57 -18
  512. package/src/formats/gexf/importer.ts +636 -105
  513. package/src/formats/gexf/index.ts +90 -21
  514. package/src/formats/gexf/schema.ts +67 -15
  515. package/src/formats/gml/exporter.ts +90 -36
  516. package/src/formats/gml/importer.ts +388 -67
  517. package/src/formats/gml/index.ts +85 -24
  518. package/src/formats/gml/syntax.ts +111 -26
  519. package/src/formats/graphml/constants.ts +178 -44
  520. package/src/formats/graphml/exporter.ts +52 -18
  521. package/src/formats/graphml/importer.ts +640 -60
  522. package/src/formats/graphml/index.ts +2 -1
  523. package/src/formats/graphml/tree.ts +6 -2
  524. package/src/formats/graphml/yfiles.ts +37 -15
  525. package/src/formats/json/dialect.ts +128 -29
  526. package/src/formats/json/exporter.ts +205 -68
  527. package/src/formats/json/importer.ts +1163 -253
  528. package/src/formats/json/index.ts +3 -1
  529. package/src/formats/json/obographs-export.ts +1197 -0
  530. package/src/formats/json/obographs.ts +353 -92
  531. package/src/formats/neo4j/exporter.ts +320 -101
  532. package/src/formats/neo4j/header.ts +44 -6
  533. package/src/formats/neo4j/importer.ts +512 -73
  534. package/src/formats/neo4j/index.ts +75 -23
  535. package/src/formats/obo/exporter.ts +2210 -0
  536. package/src/formats/obo/importer.ts +622 -109
  537. package/src/formats/obo/index.ts +6 -3
  538. package/src/formats/obo/syntax.ts +232 -37
  539. package/src/formats/pajek/exporter.ts +89 -41
  540. package/src/formats/pajek/importer.ts +407 -93
  541. package/src/formats/pajek/index.ts +2 -1
  542. package/src/formats/pajek/syntax.ts +213 -52
  543. package/src/formats/xgmml/columns.ts +10 -0
  544. package/src/formats/xgmml/constants.ts +183 -56
  545. package/src/formats/xgmml/document.ts +212 -34
  546. package/src/formats/xgmml/emit.ts +175 -34
  547. package/src/formats/xgmml/exporter.ts +35 -27
  548. package/src/formats/xgmml/importer.ts +64 -86
  549. package/src/formats/xgmml/index.ts +1 -0
  550. package/src/formats/xgmml/values.ts +11 -3
  551. package/src/index.ts +81 -11
  552. package/src/registry.ts +1121 -135
  553. package/src/sniff.ts +163 -32
  554. package/src/types.ts +385 -114
  555. package/dist/chunks/escape-B-tkk_Cl.js.map +0 -1
  556. package/dist/chunks/export-Bh60Dv-n.js +0 -582
  557. package/dist/chunks/export-Bh60Dv-n.js.map +0 -1
  558. package/dist/chunks/exporter-BGrsWamJ.js.map +0 -1
  559. package/dist/chunks/exporter-DIeGJXAZ.js.map +0 -1
  560. package/dist/chunks/importer-BWY2FFc5.js.map +0 -1
  561. package/dist/chunks/importer-DD-xv9_Y.js +0 -1471
  562. package/dist/chunks/importer-DD-xv9_Y.js.map +0 -1
  563. package/dist/chunks/importer-DET1tg6s.js.map +0 -1
  564. package/dist/chunks/importer-DEcKhsmQ.js +0 -1614
  565. package/dist/chunks/importer-DEcKhsmQ.js.map +0 -1
  566. package/dist/chunks/importer-DIrbbnAf.js.map +0 -1
  567. package/dist/chunks/importer-D_e7e7LX.js.map +0 -1
  568. package/dist/chunks/importer-eUREhBGj.js.map +0 -1
  569. package/dist/chunks/importer-vi3bSdtw.js.map +0 -1
  570. package/dist/chunks/importer-zGLo8Dg_.js.map +0 -1
  571. package/dist/chunks/json-elements-DDS8N2Dd.js +0 -779
  572. package/dist/chunks/json-elements-DDS8N2Dd.js.map +0 -1
  573. package/dist/chunks/ontology-BnrJ4I98.js +0 -113
  574. package/dist/chunks/ontology-BnrJ4I98.js.map +0 -1
  575. package/dist/chunks/records-dbRkxwaq.js.map +0 -1
  576. package/dist/chunks/report-B1z4WT9e.js +0 -2372
  577. package/dist/chunks/report-B1z4WT9e.js.map +0 -1
  578. package/dist/chunks/text-Dr0Ifpag.js.map +0 -1
  579. package/dist/chunks/weights-Dzba96G3.js +0 -176
  580. package/dist/chunks/weights-Dzba96G3.js.map +0 -1
  581. package/dist/chunks/writer-C7flM-Ih.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The importer / exporter registry (design sections 8.2 and 8.4): the eight built-in formats
2
+ * The importer / exporter registry: the built-in formats
3
3
  * registered by name, `sniff()` over them, and the two conveniences for callers who do not own a
4
4
  * sink: `importGraph()` sniffs the format, creates a builder seeded from the common options
5
5
  * (`directed: true` as a placeholder; the importer sets the real value), imports and freezes;
@@ -7,62 +7,183 @@
7
7
  * objects directly (the subpath exports) and this module never touches their sink.
8
8
  */
9
9
  import { type FreezeOptions, type FreezeReport, type GraphBuilderOptions, type GraphSnapshot } from "@graphty/graph-format";
10
- import { type SniffHints, type SniffResult } from "./sniff.js";
11
- import { type CommonExportOptions, type CommonImportOptions, type GraphChoiceOptions, type GraphExporter, type GraphImporter, type GraphListing, type ImportInput, type ImportReport, type LossNote } from "./types.js";
12
- /** The issue code of an input whose format no registered importer recognises. */
10
+ import { type FormatName, type SniffHints, type SniffResult } from "./sniff.js";
11
+ import { type CommonExportOptions, type CommonImportOptions, type ExportCapabilities, type GraphChoiceOptions, type GraphExporter, type GraphImporter, type GraphListing, type ImportInput, type ImportReport, type LossNote } from "./types.js";
12
+ /**
13
+ * The input is in no format graph-io can read (or none of the formats you registered, for your own FormatRegistry).
14
+ * Pass `format` when you know what the file is.
15
+ * @category Issue and loss codes
16
+ */
13
17
  export declare const UNKNOWN_FORMAT_CODE = "E_UNKNOWN_FORMAT";
14
- /** The builder options importGraph() accepts beyond the ones the common import options seed. */
18
+ /**
19
+ * Registered importer whose sniff() threw while the format was being chosen; that importer was treated as not
20
+ * recognizing the input (a defect in that importer).
21
+ * @category Issue and loss codes
22
+ */
23
+ export declare const SNIFF_FAILED_CODE = "W_SNIFF_FAILED";
24
+ /**
25
+ * The `builder` option of importGraph(): settings for building the graph that the common import
26
+ * options do not cover. `weighted`: "auto" (the default) gives the graph weights when any edge has
27
+ * one, true always does (every weight 1 when the file has none), false never does. `expectedNodes`
28
+ * and `expectedEdges`: how many nodes and edges to make room for up front, which saves time on a
29
+ * large file whose size you know.
30
+ * @category Loading
31
+ */
15
32
  export type BuilderSeed = Omit<GraphBuilderOptions, "directed" | "addMissingNodes" | "duplicateEdges" | "selfLoops" | "weightDtype">;
16
33
  /**
17
- * The options of importGraph(): the common import options (which also seed the registry's
18
- * builder, design section 8.4), the format choice and the hints sniffing uses, the builder and
19
- * freeze options, and any format-specific option (`delimiter`, `dialect`, ...) passed through to
20
- * the importer unchanged. `graphIndex` / `graphName` choose one graph of an input that holds
21
- * several, for the formats that list their graphs.
34
+ * The options of importGraph(), importAllGraphs(), listGraphs() and loadFromFile(): the common
35
+ * import options, the format and the hints used to detect it, the graph to read from a file that
36
+ * holds several, and any format-specific option (`delimiter`, `dialect`, ...), which reaches the
37
+ * importer unchanged.
38
+ * @category Loading
22
39
  */
23
40
  export interface ImportGraphOptions extends CommonImportOptions, GraphChoiceOptions {
24
- /** The format name, or "auto" (default) to sniff it from the filename, MIME type and content. */
25
- readonly format?: string | undefined;
26
- /** The file name or path the input came from, a hint for sniffing. */
41
+ /**
42
+ * The format to read the input as ("graphml", "csv", ...; `listFormats()` names them all), or
43
+ * "auto" to work it out from `filename`, `mimeType` and the first bytes of the input. Name it to
44
+ * be strict: detection reads a file graph-io cannot place as the closest format it recognizes.
45
+ * @defaultValue "auto"
46
+ */
47
+ readonly format?: FormatName | "auto" | undefined;
48
+ /**
49
+ * The file name or full path the input came from; only its extension is used, as a format hint.
50
+ * loadFromUrl() takes it from the URL and loadFromFile() from a File's name when you do not pass
51
+ * it.
52
+ */
27
53
  readonly filename?: string | null | undefined;
28
- /** The MIME type the input was served as, a hint for sniffing. */
54
+ /**
55
+ * The MIME type the input was served as, a format hint. loadFromUrl() takes it from the
56
+ * response's Content-Type and loadFromFile() from the Blob's `type` when you do not pass it.
57
+ */
29
58
  readonly mimeType?: string | null | undefined;
30
- /** Builder options the common options do not cover (`weighted`, `expectedNodes`, ...). */
59
+ /**
60
+ * Settings for building the graph: `weighted` ("auto", true or false: whether the graph gets
61
+ * weights), `expectedNodes` and `expectedEdges` (room to make up front for a large file). Most
62
+ * programs never set it.
63
+ */
31
64
  readonly builder?: BuilderSeed | undefined;
32
- /** Options of the freeze that follows the import. */
65
+ /**
66
+ * Settings for the last step of an import, which turns what was read into the snapshot:
67
+ * `label` (a name for debugging, read back as `snapshot.label`), `prepare` (views of the graph
68
+ * to compute up front, such as `["reverse"]`), `checksum` (record checksums, which
69
+ * `snapshot.validate({ checksum: true })` compares later to catch changed memory) and `profile` (record how long each step took, in `result.freeze.timings`). Most
70
+ * programs never set it.
71
+ */
33
72
  readonly freeze?: FreezeOptions | undefined;
34
73
  /**
35
- * The most attribute slots that hold no value the import may allocate before it stops with
36
- * E_TOO_MANY_EMPTY_CELLS. Every attribute is a column with one slot per node (or edge), so a file
74
+ * The most attribute slots that hold no value the import may allocate before it stops with an
75
+ * ImportError whose `issue.code` is E_TOO_MANY_EMPTY_CELLS. Every attribute is a column with one slot per node (or edge), so a file
37
76
  * whose nodes each have a differently named attribute would otherwise need nodes x attributes
38
- * memory. Default 2^24 (16,777,216); Infinity turns the check off. Dense files are never stopped.
77
+ * memory. Infinity turns the check off. Files whose elements mostly share their attributes are
78
+ * never stopped.
79
+ * @defaultValue 16777216
39
80
  */
40
81
  readonly maxEmptyCells?: number | undefined;
41
82
  /** Format-specific options, passed to the importer as they are. */
42
83
  readonly [formatOption: string]: unknown;
43
84
  }
44
- /** What importGraph() returns (design section 8.4). */
85
+ /**
86
+ * What importGraph(), loadFromUrl() and loadFromFile() return.
87
+ * @category Loading
88
+ */
45
89
  export interface ImportGraphResult {
46
- /** The format the input was read as. */
90
+ /** The format the input was read as ("graphml", ...). */
47
91
  readonly format: string;
48
- /** The sniff that chose the importer, or null when the caller named the format. */
92
+ /**
93
+ * How the format was detected (the candidate's `confidence` and what matched), or null when you
94
+ * named the format. Most callers can ignore it. For the JSON dialect that was read, call
95
+ * `jsonShapeOf(snapshot)` from `@graphty/graph-io/json`.
96
+ */
49
97
  readonly sniff: SniffResult | null;
50
- /** The frozen snapshot. */
98
+ /**
99
+ * The graph. `snapshot.nodeCount`, `snapshot.edgeCount`, attribute tables and so on come from
100
+ * the `@graphty/graph-format` package.
101
+ */
51
102
  readonly snapshot: GraphSnapshot;
52
- /** The importer's report. */
103
+ /**
104
+ * What happened during the import. `errorCount` counts skipped elements (see `errorLimit`,
105
+ * default 100); `warningCount` counts elements that were kept but changed; `issues` lists both;
106
+ * `counts.skippedNodes` / `counts.skippedEdges` say how much is missing from `snapshot`.
107
+ */
53
108
  readonly report: ImportReport;
54
- /** The freeze report (design section 6.6). */
109
+ /**
110
+ * What the last step of the import did to the graph: `mergedEdges` (parallel edges merged by
111
+ * `duplicateEdges`), `droppedSelfLoops` (removed by `selfLoops: "drop"`), and `timings` when you
112
+ * passed `freeze: { profile: true }`. Both counts are also reported as warnings, so most callers
113
+ * can ignore it. It is not enumerable, so `console.log(result)` and `{ ...result }` leave it out.
114
+ */
55
115
  readonly freeze: FreezeReport;
56
116
  }
57
- /** The options of exportGraph(): the common export options plus any format-specific option, passed through. */
117
+ /**
118
+ * Options for loadFromUrl(): everything importGraph() accepts, plus the fetch request settings.
119
+ * @example
120
+ * ```ts
121
+ * await loadFromUrl("/api/graph.csv", { request: { headers: { Authorization: token } }, delimiter: ";" });
122
+ * ```
123
+ * @category Loading
124
+ */
125
+ export interface LoadFromUrlOptions extends ImportGraphOptions {
126
+ /**
127
+ * Passed to fetch() as its second argument: headers, credentials, mode and so on. If you set
128
+ * `signal` in the import options and not here, the same signal also cancels the download.
129
+ */
130
+ readonly request?: RequestInit | undefined;
131
+ }
132
+ /**
133
+ * Options for downloadGraph(): the export options plus the name of the saved file.
134
+ * @example
135
+ * ```ts
136
+ * await downloadGraph(snapshot, "graphml", { filename: "network.graphml" });
137
+ * ```
138
+ * @category Saving
139
+ */
140
+ export interface DownloadGraphOptions extends ExportGraphOptions {
141
+ /**
142
+ * The file name the browser saves as. The default is "graph" plus the first entry of the
143
+ * format's `extensions` ("graph.graphml"), or "graph.<format>" when it lists none.
144
+ * @defaultValue "graph" plus the format's extension
145
+ */
146
+ readonly filename?: string | undefined;
147
+ }
148
+ /**
149
+ * One format the registry can read, write or both.
150
+ * @category Formats and detection
151
+ */
152
+ export interface FormatInfo {
153
+ /** The name you pass as `format`: "graphml", "gexf", "csv", "pajek", ... */
154
+ readonly format: string;
155
+ /**
156
+ * File extensions with the leading dot, most common first (".graphml", ".net"). Empty only for a
157
+ * custom format that declares none.
158
+ */
159
+ readonly extensions: readonly string[];
160
+ /** MIME types, most specific first. Empty when the format declares none. */
161
+ readonly mimeTypes: readonly string[];
162
+ /** Whether loadFromUrl(), loadFromFile() and importGraph() can read it. */
163
+ readonly canImport: boolean;
164
+ /** Whether the export functions can write it. */
165
+ readonly canExport: boolean;
166
+ /**
167
+ * What the format can store exactly, or null when it cannot be written. The fields are
168
+ * mixedDirection, multiEdges, selfLoops, edgeIds, idCharset, dtypes, components, lists, json,
169
+ * defaults, options, hierarchy, temporal, graphAttributes, positions and viz (each documented on
170
+ * ExportCapabilities). checkExport() tells you where a particular graph goes beyond this.
171
+ */
172
+ readonly capabilities: ExportCapabilities | null;
173
+ }
174
+ /**
175
+ * The options of exportGraph(): the common export options plus any format-specific option, passed through.
176
+ * @category Saving
177
+ */
58
178
  export interface ExportGraphOptions extends CommonExportOptions {
59
179
  /** Format-specific options, passed to the exporter as they are. */
60
180
  readonly [formatOption: string]: unknown;
61
181
  }
62
182
  /**
63
183
  * A registry of importers and exporters by format name. Registration order is the tie-break
64
- * order of sniffing (design section 8.2); the default registry lists the built-in formats in the
184
+ * order of sniffing; the default registry lists the built-in formats in the
65
185
  * order of GRAPH_FORMATS.
186
+ * @category Formats and detection
66
187
  */
67
188
  export declare class FormatRegistry {
68
189
  private readonly importerMap;
@@ -85,25 +206,25 @@ export declare class FormatRegistry {
85
206
  * @param format - the format name
86
207
  * @returns the importer; E_UNSUPPORTED when none is registered
87
208
  */
88
- importer(format: string): GraphImporter;
209
+ importer(format: FormatName): GraphImporter;
89
210
  /**
90
211
  * The exporter of a format.
91
212
  * @param format - the format name
92
213
  * @returns the exporter; E_UNSUPPORTED when none is registered
93
214
  */
94
- exporter(format: string): GraphExporter;
215
+ exporter(format: FormatName): GraphExporter;
95
216
  /**
96
217
  * Whether an importer is registered for a format.
97
218
  * @param format - the format name
98
219
  * @returns true when importer(format) would succeed
99
220
  */
100
- hasImporter(format: string): boolean;
221
+ hasImporter(format: FormatName): boolean;
101
222
  /**
102
223
  * Whether an exporter is registered for a format.
103
224
  * @param format - the format name
104
225
  * @returns true when exporter(format) would succeed
105
226
  */
106
- hasExporter(format: string): boolean;
227
+ hasExporter(format: FormatName): boolean;
107
228
  /**
108
229
  * Every registered importer, in registration order.
109
230
  * @returns the importers
@@ -120,10 +241,10 @@ export declare class FormatRegistry {
120
241
  */
121
242
  formats(): readonly string[];
122
243
  /**
123
- * Rank the registered importers for an input (design section 8.2; the successor of
124
- * graphty-element's detectFormat()).
125
- * @param hints - the filename, MIME type and / or head of the input
126
- * @returns the candidates, best first; empty when nothing matches
244
+ * Every format that could be the input, best first, from the same hints as sniff(): use it to
245
+ * offer the user a choice when the best guess is not certain.
246
+ * @param hints - `{ filename, mimeType, head }`, any of them
247
+ * @returns the candidates, best first; empty when no format claims the input
127
248
  */
128
249
  sniffAll(hints: SniffHints): readonly SniffResult[];
129
250
  /**
@@ -133,27 +254,46 @@ export declare class FormatRegistry {
133
254
  */
134
255
  sniff(hints: SniffHints): SniffResult | null;
135
256
  /**
136
- * Read an input into a fresh builder and freeze it (design section 8.4: for callers who do not
137
- * own a sink). The format is the one named in the options, else sniffed from the filename,
138
- * the MIME type and the first bytes of the content; the builder is seeded from the common
139
- * options with `directed: true` as a placeholder that the importer overrides from the file.
140
- * An input holding several graphs yields the first, with a warning naming how many were
141
- * skipped; importAllGraphs() returns every one.
257
+ * Read a graph from a string, bytes or a stream. The format is the one you name in `format`,
258
+ * else it is detected from `filename`, `mimeType` and the first bytes of the content. From an
259
+ * input that holds several graphs, it reads the one `graphIndex` or `graphName` chooses, else
260
+ * the first, with a W_MULTIPLE_GRAPHS warning; importAllGraphs() returns every one.
142
261
  * @param input - the text, bytes, stream or chunks to read
143
262
  * @param options - the format, hints, common and format-specific import options
144
- * @returns the snapshot, the import report and the freeze report
263
+ * @returns the graph (`snapshot`), the format it was read as, and the import report
145
264
  */
146
- importGraph(input: ImportInput, options?: ImportGraphOptions): Promise<ImportGraphResult>;
265
+ importGraph(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult>;
266
+ /**
267
+ * Fetch a graph file from a URL and load it; see the top-level loadFromUrl() for the full
268
+ * description.
269
+ * @param url - an absolute URL, or in a browser one relative to the page
270
+ * @param options - import options, plus `request` for fetch
271
+ * @returns the graph, the format it was read as, and the import report
272
+ */
273
+ loadFromUrl(url: string | URL, options?: LoadFromUrlOptions | CommonImportOptions): Promise<ImportGraphResult>;
274
+ /**
275
+ * Load a graph from a File or Blob; see the top-level loadFromFile() for the full description.
276
+ * @param file - the File or Blob to read
277
+ * @param options - the same options as importGraph()
278
+ * @returns the graph, the format it was read as, and the import report
279
+ */
280
+ loadFromFile(file: Blob, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult>;
147
281
  /**
148
282
  * Read every graph of an input (a DOT file with several graphs, a Pajek project with several
149
- * networks, a JGF document with a `graphs` array), each into its own fresh builder, frozen.
150
- * A format whose importer has no importAll() holds one graph per input, so the result has one
151
- * entry. Options, sniffing and the builder seed are those of importGraph().
283
+ * networks, a JGF document with a `graphs` array), each as its own snapshot. A format that holds
284
+ * one graph per file gives one result. Options and detection are those of importGraph().
152
285
  * @param input - the text, bytes, stream or chunks to read
153
286
  * @param options - the format, hints, common and format-specific import options
154
287
  * @returns one result per graph, in document order
155
288
  */
156
- importAllGraphs(input: ImportInput, options?: ImportGraphOptions): Promise<ImportGraphResult[]>;
289
+ importAllGraphs(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult[]>;
290
+ /**
291
+ * Read every graph of an input with the chosen importer.
292
+ * @param chosen - the importer and the input to hand it
293
+ * @param options - the importGraph options
294
+ * @returns one result per graph, in document order
295
+ */
296
+ private readAll;
157
297
  /**
158
298
  * The graphs of an input that can hold several, without importing them (a Cytoscape session's
159
299
  * networks, a JGF `graphs` array), so a caller can offer a choice and then pass `graphIndex`
@@ -163,22 +303,31 @@ export declare class FormatRegistry {
163
303
  * @returns one listing per graph, in document order; null when the format's importer does not
164
304
  * list its graphs (importGraph() then reads the first)
165
305
  */
166
- listGraphs(input: ImportInput, options?: ImportGraphOptions): Promise<readonly GraphListing[] | null>;
306
+ listGraphs(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<readonly GraphListing[] | null>;
167
307
  /**
168
308
  * The importer for an input: the named format, or the sniffed one.
169
- * @param input - the input
309
+ * @param rawInput - the input as the caller passed it
170
310
  * @param options - the importGraph options
171
311
  * @returns the importer, the sniff, and the input to read (replayed for a stream)
172
312
  */
173
313
  private choose;
174
314
  /**
175
- * Write a snapshot in a format, as UTF-8 chunks (design section 8.5).
315
+ * Refuse an input no importer recognizes: empty, or not in a known graph format.
316
+ * @param failures - the report the error is recorded in
317
+ * @param head - the head, as sniffed
318
+ * @param foreign - what known non-graph file the head is, or null
319
+ * @param options - the importGraph options
320
+ * @returns never: always throws
321
+ */
322
+ private refuseUndetected;
323
+ /**
324
+ * Write a snapshot in a format, as UTF-8 chunks.
176
325
  * @param snapshot - the snapshot
177
326
  * @param format - the format name
178
327
  * @param options - the exporter's common and format-specific options
179
328
  * @returns the encoded chunks
180
329
  */
181
- exportGraph(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): AsyncIterable<Uint8Array>;
330
+ exportGraph(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): AsyncIterable<Uint8Array>;
182
331
  /**
183
332
  * Write a snapshot in a format, as one string.
184
333
  * @param snapshot - the snapshot
@@ -186,7 +335,25 @@ export declare class FormatRegistry {
186
335
  * @param options - the exporter's common and format-specific options
187
336
  * @returns the whole document
188
337
  */
189
- exportGraphToString(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): Promise<string>;
338
+ exportGraphToString(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<string>;
339
+ /**
340
+ * Write a snapshot in a format as one buffer of UTF-8 bytes; see the top-level
341
+ * exportGraphToBytes().
342
+ * @param snapshot - the graph to write
343
+ * @param format - a format name where `canExport` is true
344
+ * @param options - sanitizeIds, onMixedDirection and the format's own options
345
+ * @returns the encoded file
346
+ */
347
+ exportGraphToBytes(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<Uint8Array>;
348
+ /**
349
+ * Write a snapshot in a format as a Blob typed with the format's first MIME type; see the
350
+ * top-level exportGraphToBlob().
351
+ * @param snapshot - the graph to write
352
+ * @param format - a format name where `canExport` is true
353
+ * @param options - sanitizeIds, onMixedDirection and the format's own options
354
+ * @returns the file as a Blob
355
+ */
356
+ exportGraphToBlob(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<Blob>;
190
357
  /**
191
358
  * What exporting a snapshot in a format would lose, without writing anything.
192
359
  * @param snapshot - the snapshot
@@ -194,65 +361,284 @@ export declare class FormatRegistry {
194
361
  * @param options - the exporter's common and format-specific options
195
362
  * @returns the loss notes, empty when the export is exact
196
363
  */
197
- checkExport(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): readonly LossNote[];
364
+ checkExport(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): readonly LossNote[];
365
+ /**
366
+ * The option names no registered format and no load or save function takes (misspellings), or none while a
367
+ * registered format does not list its options.
368
+ * @param options - the caller's options
369
+ * @returns the unknown names
370
+ */
371
+ private unknownOptions;
372
+ /**
373
+ * Browser only: write a graph in a format and have the browser save it as a file; see the
374
+ * top-level downloadGraph(). Use this method on a registry from createRegistry() to download
375
+ * without bundling every built-in format.
376
+ * @param snapshot - the graph to write
377
+ * @param format - a format name from listFormats() where `canExport` is true
378
+ * @param options - the export options, plus `filename`
379
+ * @returns resolves once the download has been handed to the browser
380
+ */
381
+ downloadGraph(snapshot: GraphSnapshot, format: FormatName, options?: DownloadGraphOptions | CommonExportOptions): Promise<void>;
382
+ /**
383
+ * Every format this registry can read or write, in registration order; see the top-level
384
+ * listFormats().
385
+ * @returns one entry per format
386
+ */
387
+ listFormats(): readonly FormatInfo[];
198
388
  }
199
389
  /**
200
- * A registry holding the eight built-in importers and exporters in the order of GRAPH_FORMATS.
390
+ * A new registry holding every built-in importer and exporter, in the order of GRAPH_FORMATS.
201
391
  * @returns a new registry
392
+ * @category Formats and detection
202
393
  */
203
394
  export declare function createRegistry(): FormatRegistry;
204
- /** The default registry: every built-in format. */
395
+ /**
396
+ * The default registry: every built-in format.
397
+ * @category Formats and detection
398
+ */
205
399
  export declare const registry: FormatRegistry;
206
400
  /**
207
- * Read an input into a fresh builder and freeze it, through the default registry (design section
208
- * 8.4: `importGraph(input, { format?, ...options })`).
209
- * @param input - the text, bytes, stream or chunks to read
210
- * @param options - the format, hints, common and format-specific import options
211
- * @returns the snapshot, the import report and the freeze report
401
+ * Read a graph from a string, bytes or a stream. The format is the one you name in `format`, else
402
+ * it is detected from `filename`, `mimeType` and the first bytes; an input that matches no format
403
+ * fails with E_UNKNOWN_FORMAT. From a file that holds several graphs it reads the one `graphIndex`
404
+ * or `graphName` chooses, else the first, with a W_MULTIPLE_GRAPHS warning. For a File or Blob use
405
+ * loadFromFile(), for a URL loadFromUrl().
406
+ * @param input - the whole text, the bytes (a Uint8Array or a Node Buffer), a ReadableStream of
407
+ * bytes, or an async iterable of text or byte chunks (a Node read stream)
408
+ * @param options - the format, format hints, the options every importer takes and the format's own
409
+ * options
410
+ * @returns the graph (`snapshot`), the format it was read as, and the import report
411
+ * @throws ImportError when the input could not be read; `err.issue?.code` says why
412
+ * @throws GraphFormatError with code E_UNSUPPORTED for a `format` no importer is registered for, or
413
+ * an option value that is not allowed (`err.details.option` names it)
414
+ * @throws the signal's reason when `signal` aborts
415
+ * @category Loading
416
+ */
417
+ export declare function importGraph(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult>;
418
+ /**
419
+ * Read every graph of a file that can hold several (DOT, GML, a Pajek project, a JSON Graph Format
420
+ * or OBO Graphs document, CX, XGMML, a Cytoscape session). A format that holds one graph per file
421
+ * gives one result. Options and errors are the same as importGraph()'s.
422
+ * @param input - the text, bytes or stream to read
423
+ * @param options - the same options as importGraph()
424
+ * @returns one result per graph, in file order
425
+ * @category Loading
426
+ */
427
+ export declare function importAllGraphs(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult[]>;
428
+ /**
429
+ * List the graphs of a file without reading them: each one's `index`, `name`, and node and edge
430
+ * counts when the file states them. Pass the index or name to importGraph() as `graphIndex` or
431
+ * `graphName`. The counts come from the file and can differ from what an import reads, for example
432
+ * when the import adds edges the listing does not count. JSON, CX, XGMML and Cytoscape sessions can
433
+ * list their graphs; for DOT, GML and Pajek it returns null, and importAllGraphs() is the way to see
434
+ * them.
435
+ * @param input - the text, bytes or stream to read
436
+ * @param options - the same options as importGraph()
437
+ * @returns one listing per graph, in file order; null when the format cannot list its graphs
438
+ * @category Loading
439
+ */
440
+ export declare function listGraphs(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<readonly GraphListing[] | null>;
441
+ /**
442
+ * Write a graph in a format as a stream of UTF-8 byte chunks, for a graph too large to hold as one
443
+ * file in memory. In Node, pipe it to a file with `pipeline(exportGraph(...), createWriteStream(path))`.
444
+ * Options and errors are the same as exportGraphToBytes()'s.
445
+ * @param snapshot - the graph to write
446
+ * @param format - a format name from listFormats() where `canExport` is true
447
+ * @param options - sanitizeIds, onMixedDirection and the format's own options
448
+ * @returns the file's bytes, chunk by chunk
449
+ * @category Saving
450
+ */
451
+ export declare function exportGraph(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): AsyncIterable<Uint8Array>;
452
+ /**
453
+ * Write a graph in a format and return the file as one string. A binary format (a Cytoscape
454
+ * session) cannot be a string and fails with E_UNSUPPORTED; use exportGraphToBytes() for it. Options
455
+ * and errors are the same as exportGraphToBytes()'s.
456
+ * @param snapshot - the graph to write
457
+ * @param format - a format name from listFormats() where `canExport` is true
458
+ * @param options - sanitizeIds, onMixedDirection and the format's own options
459
+ * @returns the whole file
460
+ * @category Saving
461
+ */
462
+ export declare function exportGraphToString(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<string>;
463
+ /**
464
+ * What saving a graph in a format would lose, without writing anything. Pass the same options you
465
+ * will pass to the save. Each note has a stable `code`: "E_" means the save would throw, "W_" means
466
+ * the file is written but that part does not read back the same. An empty array means the file
467
+ * reads back as the same graph. Runs synchronously.
468
+ * @param snapshot - the graph to check
469
+ * @param format - a format name from listFormats() where `canExport` is true
470
+ * @param options - the options you will save with
471
+ * @returns the loss notes, empty when the save is exact
472
+ * @throws GraphFormatError with code E_UNSUPPORTED when no exporter is registered for `format`, or
473
+ * when an option value is not allowed (`err.details.option` names it)
474
+ * @category Saving
475
+ */
476
+ export declare function checkExport(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): readonly LossNote[];
477
+ /**
478
+ * Fetch a graph file from a URL and load it. The file is streamed into the importer as it
479
+ * downloads, so a large file is not held in memory twice. When you do not name a `format`, it is
480
+ * worked out from the URL's file name, the response's Content-Type and the first bytes of the
481
+ * file. Your own `filename` or `mimeType` option takes the place of the hint from the URL or the
482
+ * response. Every other option goes to importGraph() unchanged, including format-specific ones
483
+ * such as `delimiter` or `dialect`, and `graphIndex` / `graphName` for files that hold several
484
+ * graphs. The result is the same as importGraph()'s. A successful load can still have skipped
485
+ * elements; check `report.errorCount` and `report.warningCount`, or pass `errorLimit: 0` to make
486
+ * the first error fatal. Works wherever fetch exists: browsers, Node 18 and later, Deno, Bun and
487
+ * workers.
488
+ * @param url - an absolute URL, or in a browser one relative to the page
489
+ * @param options - import options, plus `request` for fetch
490
+ * @returns the graph, the format it was read as, and the import report
491
+ * @throws ImportError when the file could not be loaded; `err.issue?.code` is "E_FETCH" for a
492
+ * network failure, a CORS refusal or a status outside 200-299 (`err.details.url`,
493
+ * `err.details.status` -- null for a network failure -- and `err.details.cause`, fetch's own
494
+ * error), "E_UNKNOWN_FORMAT" when no format recognizes the file (pass `format`), or the code of
495
+ * the parse error
496
+ * @throws GraphFormatError with code E_UNSUPPORTED when `format` names no registered importer
497
+ * @throws the signal's reason when `signal` aborts
498
+ * @example
499
+ * ```ts
500
+ * import { GraphFormatError, loadFromUrl } from "@graphty/graph-io";
501
+ *
502
+ * try {
503
+ * const { snapshot, format } = await loadFromUrl("https://example.com/data/karate.gml");
504
+ * console.log(`${format}: ${snapshot.nodeCount} nodes, ${snapshot.edgeCount} edges`);
505
+ * } catch (err) {
506
+ * if (err instanceof GraphFormatError) {
507
+ * console.error(err.message);
508
+ * } else {
509
+ * throw err;
510
+ * }
511
+ * }
512
+ * ```
513
+ * @category Loading
212
514
  */
213
- export declare function importGraph(input: ImportInput, options?: ImportGraphOptions): Promise<ImportGraphResult>;
515
+ export declare function loadFromUrl(url: string | URL, options?: LoadFromUrlOptions | CommonImportOptions): Promise<ImportGraphResult>;
214
516
  /**
215
- * Read every graph of an input, each into its own frozen snapshot, through the default registry.
216
- * @param input - the text, bytes, stream or chunks to read
217
- * @param options - the format, hints, common and format-specific import options
218
- * @returns one result per graph, in document order
517
+ * Load a graph from a File or Blob: a file the user picked in an `<input type="file">`, a file
518
+ * dropped on the page, a Blob you built, or in Node a Blob from `fs.openAsBlob(path)`. The content
519
+ * is streamed into the importer. A File's `name` and the Blob's `type` are used as format hints
520
+ * unless you pass `filename` or `mimeType` yourself. Options, result and errors are the same as
521
+ * loadFromUrl()'s, without E_FETCH.
522
+ * @param file - the File or Blob to read
523
+ * @param options - the same options as importGraph()
524
+ * @returns the graph, the format it was read as, and the import report
525
+ * @throws ImportError when the file could not be loaded (`err.issue?.code` E_UNKNOWN_FORMAT or a parse error)
526
+ * @throws GraphFormatError with code E_UNSUPPORTED when `format` names no registered importer
527
+ * @throws the signal's reason when `signal` aborts
528
+ * @example
529
+ * ```ts
530
+ * input.addEventListener("change", async () => {
531
+ * const file = input.files?.[0];
532
+ * if (file) {
533
+ * const { snapshot, report } = await loadFromFile(file);
534
+ * console.log(`${snapshot.nodeCount} nodes, ${report.errorCount} skipped`);
535
+ * }
536
+ * });
537
+ * ```
538
+ * @category Loading
219
539
  */
220
- export declare function importAllGraphs(input: ImportInput, options?: ImportGraphOptions): Promise<ImportGraphResult[]>;
540
+ export declare function loadFromFile(file: Blob, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult>;
221
541
  /**
222
- * The graphs of an input that can hold several, through the default registry.
223
- * @param input - the text, bytes, stream or chunks to read
224
- * @param options - the format, hints, common and format-specific import options
225
- * @returns one listing per graph, in document order; null when the format does not list its graphs
542
+ * Write a graph in a format and return the whole file as UTF-8 bytes, ready for fs.writeFile, a
543
+ * fetch body or a zip entry. Prefer this over exportGraphToString() when the result goes to a file
544
+ * or the network. To stream a very large graph, use exportGraph(). To find out beforehand what the
545
+ * file will not keep, call checkExport() with the same format and the same options object: every
546
+ * "E_" note it returns makes this call throw, and every "W_" note describes a loss this call
547
+ * accepts. Most "E_" notes go away with `sanitizeIds: "mangle"` (rewrite ids the format cannot
548
+ * hold) or `onMixedDirection: "directed"` / `"undirected"`. The format's own options (the CSV
549
+ * `table` and `dialect`, the GEXF `version`, ...) go in the same object.
550
+ * @param snapshot - the graph to write
551
+ * @param format - a format name from listFormats() where `canExport` is true
552
+ * @param options - sanitizeIds, onMixedDirection and the format's own options
553
+ * @returns the encoded file
554
+ * @throws GraphFormatError with code E_UNSUPPORTED when no exporter is registered for `format`
555
+ * @throws GraphFormatError when the graph cannot be written in this format under these options
556
+ * (checkExport() returns an "E_" note for the same call). The thrown code names the kind of
557
+ * failure rather than the note: E_INVALID_ID for ids (the E_ID_CHARSET and E_ID_TEXT_COLLISION
558
+ * notes), E_DIRECTED for direction (E_MIXED_DIRECTION), and E_COLUMN_TYPE or E_UNSUPPORTED for a
559
+ * value the format cannot write; each note's entry on the codes page says which
560
+ * @throws GraphFormatError with code E_UNSUPPORTED for an option value that is not allowed
561
+ * (`err.details.option` names it)
562
+ * @example
563
+ * ```ts
564
+ * import { writeFile } from "node:fs/promises";
565
+ *
566
+ * await writeFile("out.gexf", await exportGraphToBytes(snapshot, "gexf"));
567
+ * ```
568
+ * @category Saving
226
569
  */
227
- export declare function listGraphs(input: ImportInput, options?: ImportGraphOptions): Promise<readonly GraphListing[] | null>;
570
+ export declare function exportGraphToBytes(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<Uint8Array>;
228
571
  /**
229
- * Write a snapshot in a format through the default registry, as UTF-8 chunks.
230
- * @param snapshot - the snapshot
231
- * @param format - the format name
232
- * @param options - the exporter's common and format-specific options
233
- * @returns the encoded chunks
572
+ * Write a graph in a format and return it as a Blob, for uploading with fetch or FormData or for
573
+ * offering as a download. The Blob's `type` is the first entry of the format's `mimeTypes` in
574
+ * listFormats(), or application/octet-stream when the format lists none. The exporter's chunks
575
+ * are kept as they are and never joined into one string. Options and errors are the same as
576
+ * exportGraphToBytes().
577
+ * @param snapshot - the graph to write
578
+ * @param format - a format name from listFormats() where `canExport` is true
579
+ * @param options - sanitizeIds, onMixedDirection and the format's own options
580
+ * @returns the file as a Blob
581
+ * @throws the same errors as exportGraphToBytes()
582
+ * @example
583
+ * ```ts
584
+ * const body = new FormData();
585
+ * body.append("file", await exportGraphToBlob(snapshot, "graphml"), "graph.graphml");
586
+ * await fetch("/api/graphs", { method: "POST", body });
587
+ * ```
588
+ * @category Saving
234
589
  */
235
- export declare function exportGraph(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): AsyncIterable<Uint8Array>;
590
+ export declare function exportGraphToBlob(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<Blob>;
236
591
  /**
237
- * Write a snapshot in a format through the default registry, as one string.
238
- * @param snapshot - the snapshot
239
- * @param format - the format name
240
- * @param options - the exporter's common and format-specific options
241
- * @returns the whole document
592
+ * Browser only: write a graph in a format and have the browser save it as a file, the same as
593
+ * clicking a download link. Call it from a click handler; awaiting other work first is fine. The
594
+ * promise resolves once the file has been handed to the browser. There is no way to learn
595
+ * whether the user then canceled the save. Calling it where there is no `document` (Node, a
596
+ * worker) throws instead of silently doing nothing; importing it is safe everywhere. Formats you
597
+ * registered with `registry.registerExporter()` can be downloaded too.
598
+ * @param snapshot - the graph to write
599
+ * @param format - a format name from listFormats() where `canExport` is true
600
+ * @param options - the export options, plus `filename`
601
+ * @returns resolves once the download has been handed to the browser
602
+ * @throws GraphFormatError with code E_UNSUPPORTED when called without a DOM `document`
603
+ * @throws the same errors as exportGraphToBytes()
604
+ * @example
605
+ * ```ts
606
+ * saveButton.addEventListener("click", () => {
607
+ * void downloadGraph(snapshot, "graphml", { filename: "network.graphml" });
608
+ * });
609
+ * ```
610
+ * @category Saving
242
611
  */
243
- export declare function exportGraphToString(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): Promise<string>;
612
+ export declare function downloadGraph(snapshot: GraphSnapshot, format: FormatName, options?: DownloadGraphOptions | CommonExportOptions): Promise<void>;
244
613
  /**
245
- * What exporting a snapshot in a format would lose, through the default registry.
246
- * @param snapshot - the snapshot
247
- * @param format - the format name
248
- * @param options - the exporter's common and format-specific options
249
- * @returns the loss notes, empty when the export is exact
614
+ * Every format the default registry can read or write, including any you registered yourself:
615
+ * the built-in formats in the order of GRAPH_FORMATS (the order format detection prefers them),
616
+ * then yours in registration order. Use it to fill a "Save as" menu (the entries with
617
+ * `canExport`), a file input's `accept` attribute (the `extensions` of the entries with
618
+ * `canImport`), or to pick the output format from a file name.
619
+ * @returns one entry per format
620
+ * @example
621
+ * ```ts
622
+ * input.accept = listFormats().filter((f) => f.canImport).flatMap((f) => f.extensions).join(",");
623
+ * const target = listFormats().find((f) => f.canExport && f.extensions.includes(extensionOf(path) ?? ""));
624
+ * ```
625
+ * @category Formats and detection
250
626
  */
251
- export declare function checkExport(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): readonly LossNote[];
627
+ export declare function listFormats(): readonly FormatInfo[];
252
628
  /**
253
- * Sniff an input's format through the default registry.
254
- * @param hints - the filename, MIME type and / or head of the input
255
- * @returns the best candidate, or null when no built-in importer claims it
629
+ * Detect a file's format without reading it, from what you know about it: a `filename` (only the
630
+ * extension counts), a `mimeType`, and `head`, the file's first bytes or characters (up to
631
+ * SNIFF_HEAD_BYTES; pass `bytes.subarray(0, SNIFF_HEAD_BYTES)`). It uses every format of the default
632
+ * registry, including the ones you registered. For every candidate, best first, call
633
+ * `registry.sniffAll(hints)`.
634
+ * @param hints - `{ filename, mimeType, head }`, any of them
635
+ * @returns the best candidate (`format`, `confidence` and what matched), or null when no format
636
+ * claims the input
637
+ * @example
638
+ * ```ts
639
+ * sniff({ filename: "graph.xml", head: "<?xml version=\"1.0\"?><gexf" })?.format; // "gexf"
640
+ * ```
641
+ * @category Formats and detection
256
642
  */
257
643
  export declare function sniff(hints: SniffHints): SniffResult | null;
258
644
  //# sourceMappingURL=registry.d.ts.map