@graphty/graph-io 0.3.47 → 0.3.48

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 (460) hide show
  1. package/dist/chunks/{approximations-wWjCRzKj.js → approximations-C2riR4NT.js} +2 -2
  2. package/dist/chunks/{approximations-wWjCRzKj.js.map → approximations-C2riR4NT.js.map} +1 -1
  3. package/dist/chunks/{block-DiGq58c3.js → block-Cu22ewuS.js} +92 -21
  4. package/dist/chunks/block-Cu22ewuS.js.map +1 -0
  5. package/dist/chunks/{choose--jM0yYCo.js → choose-Cdx6Enl2.js} +3 -3
  6. package/dist/chunks/{choose--jM0yYCo.js.map → choose-Cdx6Enl2.js.map} +1 -1
  7. package/dist/chunks/codes-CV_Bhcyi.js +153 -0
  8. package/dist/chunks/codes-CV_Bhcyi.js.map +1 -0
  9. package/dist/chunks/{constants-BKwqelYD.js → constants-D0LqcsLJ.js} +2 -2
  10. package/dist/chunks/{constants-BKwqelYD.js.map → constants-D0LqcsLJ.js.map} +1 -1
  11. package/dist/chunks/context-cgmmOxZ2.js +663 -0
  12. package/dist/chunks/context-cgmmOxZ2.js.map +1 -0
  13. package/dist/chunks/credentials-BiQsnMTb.js +347 -0
  14. package/dist/chunks/credentials-BiQsnMTb.js.map +1 -0
  15. package/dist/chunks/cx-export-BEeF6ymo.js +259 -0
  16. package/dist/chunks/cx-export-BEeF6ymo.js.map +1 -0
  17. package/dist/chunks/descriptor-BJ-W0Jd-.js +137 -0
  18. package/dist/chunks/descriptor-BJ-W0Jd-.js.map +1 -0
  19. package/dist/chunks/descriptor-C-YDhtsn.js +48 -0
  20. package/dist/chunks/descriptor-C-YDhtsn.js.map +1 -0
  21. package/dist/chunks/{emit-CwU8cUmG.js → emit-CD8xnY8s.js} +70 -10
  22. package/dist/chunks/emit-CD8xnY8s.js.map +1 -0
  23. package/dist/chunks/{escape-CgzxiYPg.js → escape-DH2Egt-l.js} +12 -12
  24. package/dist/chunks/{escape-CgzxiYPg.js.map → escape-DH2Egt-l.js.map} +1 -1
  25. package/dist/chunks/{export-BvqAXCKh.js → export-CZ7VRm4I.js} +53 -1443
  26. package/dist/chunks/export-CZ7VRm4I.js.map +1 -0
  27. package/dist/chunks/{exporter-DndFlGSa.js → exporter-BIdaoIgh.js} +7 -6
  28. package/dist/chunks/{exporter-DndFlGSa.js.map → exporter-BIdaoIgh.js.map} +1 -1
  29. package/dist/chunks/{exporter-CJgfhF-l.js → exporter-ChjL5fmP.js} +8 -7
  30. package/dist/chunks/{exporter-CJgfhF-l.js.map → exporter-ChjL5fmP.js.map} +1 -1
  31. package/dist/chunks/{exporter--Mk9gXCJ.js → exporter-Dcw7Ldtq.js} +6 -4
  32. package/dist/chunks/{exporter--Mk9gXCJ.js.map → exporter-Dcw7Ldtq.js.map} +1 -1
  33. package/dist/chunks/exporter-DtVU80Fa.js +1008 -0
  34. package/dist/chunks/exporter-DtVU80Fa.js.map +1 -0
  35. package/dist/chunks/{exporter-CrDWIyiq.js → exporter-bxxjOrDZ.js} +11 -9
  36. package/dist/chunks/{exporter-CrDWIyiq.js.map → exporter-bxxjOrDZ.js.map} +1 -1
  37. package/dist/chunks/format-BMS-1Nxb.js +64 -0
  38. package/dist/chunks/format-BMS-1Nxb.js.map +1 -0
  39. package/dist/chunks/{generic-Dq1ntt9q.js → generic-CP6YD34u.js} +4 -4
  40. package/dist/chunks/{generic-Dq1ntt9q.js.map → generic-CP6YD34u.js.map} +1 -1
  41. package/dist/chunks/{importer-DiZRmOQG.js → importer-B87_fmVx.js} +13 -17
  42. package/dist/chunks/importer-B87_fmVx.js.map +1 -0
  43. package/dist/chunks/{importer-BSvfrX_h.js → importer-Bji2MeWr.js} +18 -1014
  44. package/dist/chunks/importer-Bji2MeWr.js.map +1 -0
  45. package/dist/chunks/{importer-COTK9Tsl.js → importer-CB_zV5_L.js} +14 -11
  46. package/dist/chunks/importer-CB_zV5_L.js.map +1 -0
  47. package/dist/chunks/{importer-e6LGpqHB.js → importer-CVT-JyDE.js} +12 -9
  48. package/dist/chunks/importer-CVT-JyDE.js.map +1 -0
  49. package/dist/chunks/{importer-yh_aBCU6.js → importer-Cyy6UseH.js} +7 -6
  50. package/dist/chunks/{importer-yh_aBCU6.js.map → importer-Cyy6UseH.js.map} +1 -1
  51. package/dist/chunks/{importer-iFYPEKaJ.js → importer-DPZDN40-.js} +14 -10
  52. package/dist/chunks/{importer-iFYPEKaJ.js.map → importer-DPZDN40-.js.map} +1 -1
  53. package/dist/chunks/{importer-CMmeMWlC.js → importer-e3huMZbm.js} +8 -260
  54. package/dist/chunks/importer-e3huMZbm.js.map +1 -0
  55. package/dist/chunks/input-Ccg9I22A.js +1397 -0
  56. package/dist/chunks/input-Ccg9I22A.js.map +1 -0
  57. package/dist/chunks/{json-elements-DJZRZ6jd.js → json-elements-By172SVq.js} +4 -4
  58. package/dist/chunks/{json-elements-DJZRZ6jd.js.map → json-elements-By172SVq.js.map} +1 -1
  59. package/dist/chunks/{lexicon-CT69Kd87.js → lexicon-u2SI5xcx.js} +19 -5
  60. package/dist/chunks/lexicon-u2SI5xcx.js.map +1 -0
  61. package/dist/chunks/{ontology-export-G4MqRdux.js → ontology-export-BwgMyuF0.js} +4 -3
  62. package/dist/chunks/{ontology-export-G4MqRdux.js.map → ontology-export-BwgMyuF0.js.map} +1 -1
  63. package/dist/chunks/{records-CiaWZrFH.js → records-Cgvxz-Vx.js} +2 -2
  64. package/dist/chunks/{records-CiaWZrFH.js.map → records-Cgvxz-Vx.js.map} +1 -1
  65. package/dist/chunks/{format-BpQBx8MZ.js → report-CgdsL9Hb.js} +72 -129
  66. package/dist/chunks/report-CgdsL9Hb.js.map +1 -0
  67. package/dist/chunks/sigv4-LkAzsLAu.js +247 -0
  68. package/dist/chunks/sigv4-LkAzsLAu.js.map +1 -0
  69. package/dist/chunks/{styles-BQnsga7p.js → styles-CaABMoO1.js} +76 -43
  70. package/dist/chunks/styles-CaABMoO1.js.map +1 -0
  71. package/dist/chunks/{styles-D3fRphrO.js → styles-P_gmFAOi.js} +101 -21
  72. package/dist/chunks/styles-P_gmFAOi.js.map +1 -0
  73. package/dist/chunks/{styles-yed-BF5x3_Y5.js → styles-yed-Cs1nmrjn.js} +60 -20
  74. package/dist/chunks/styles-yed-Cs1nmrjn.js.map +1 -0
  75. package/dist/chunks/{text-CzJNFOS9.js → text-BuKQVMz2.js} +2 -2
  76. package/dist/chunks/{text-CzJNFOS9.js.map → text-BuKQVMz2.js.map} +1 -1
  77. package/dist/chunks/{writer-DMKvthQE.js → writer-DvHTl36J.js} +5 -4
  78. package/dist/chunks/writer-DvHTl36J.js.map +1 -0
  79. package/dist/csv.js +7 -5
  80. package/dist/csv.js.map +1 -1
  81. package/dist/cx.js +5 -4
  82. package/dist/cx.js.map +1 -1
  83. package/dist/cx2.js +2 -2
  84. package/dist/cys.js +1 -1
  85. package/dist/dot.js +2 -2
  86. package/dist/gexf.js +7 -5
  87. package/dist/gexf.js.map +1 -1
  88. package/dist/gml.js +16 -13
  89. package/dist/gml.js.map +1 -1
  90. package/dist/graph-io.js +1181 -224
  91. package/dist/graph-io.js.map +1 -1
  92. package/dist/graphml.js +3 -3
  93. package/dist/json.js +1 -1
  94. package/dist/neo4j.js +6 -4
  95. package/dist/neo4j.js.map +1 -1
  96. package/dist/obo.js +1 -1
  97. package/dist/pajek.js +1 -1
  98. package/dist/sources-cypher.d.ts +1 -0
  99. package/dist/sources-cypher.js +1236 -0
  100. package/dist/sources-cypher.js.map +1 -0
  101. package/dist/sources-ndex.d.ts +1 -0
  102. package/dist/sources-ndex.js +278 -0
  103. package/dist/sources-ndex.js.map +1 -0
  104. package/dist/sources-rest.d.ts +1 -0
  105. package/dist/sources-rest.js +1367 -0
  106. package/dist/sources-rest.js.map +1 -0
  107. package/dist/src/common/report.d.ts +6 -3
  108. package/dist/src/common/report.d.ts.map +1 -1
  109. package/dist/src/common/report.js +15 -9
  110. package/dist/src/common/report.js.map +1 -1
  111. package/dist/src/formats/cx/styles.d.ts.map +1 -1
  112. package/dist/src/formats/cx/styles.js +1 -0
  113. package/dist/src/formats/cx/styles.js.map +1 -1
  114. package/dist/src/formats/dot/styles.d.ts.map +1 -1
  115. package/dist/src/formats/dot/styles.js +3 -1
  116. package/dist/src/formats/dot/styles.js.map +1 -1
  117. package/dist/src/formats/gexf/styles.d.ts +29 -12
  118. package/dist/src/formats/gexf/styles.d.ts.map +1 -1
  119. package/dist/src/formats/gexf/styles.js +160 -31
  120. package/dist/src/formats/gexf/styles.js.map +1 -1
  121. package/dist/src/formats/gml/styles.d.ts.map +1 -1
  122. package/dist/src/formats/gml/styles.js +5 -4
  123. package/dist/src/formats/gml/styles.js.map +1 -1
  124. package/dist/src/formats/graphml/styles-plain.d.ts.map +1 -1
  125. package/dist/src/formats/graphml/styles-plain.js +3 -3
  126. package/dist/src/formats/graphml/styles-plain.js.map +1 -1
  127. package/dist/src/formats/graphml/styles-yed.d.ts.map +1 -1
  128. package/dist/src/formats/graphml/styles-yed.js +89 -19
  129. package/dist/src/formats/graphml/styles-yed.js.map +1 -1
  130. package/dist/src/formats/pajek/styles.d.ts.map +1 -1
  131. package/dist/src/formats/pajek/styles.js +1 -0
  132. package/dist/src/formats/pajek/styles.js.map +1 -1
  133. package/dist/src/formats/xgmml/styles.d.ts.map +1 -1
  134. package/dist/src/formats/xgmml/styles.js +1 -0
  135. package/dist/src/formats/xgmml/styles.js.map +1 -1
  136. package/dist/src/index.d.ts +8 -1
  137. package/dist/src/index.d.ts.map +1 -1
  138. package/dist/src/index.js +9 -1
  139. package/dist/src/index.js.map +1 -1
  140. package/dist/src/registry.d.ts +173 -1
  141. package/dist/src/registry.d.ts.map +1 -1
  142. package/dist/src/registry.js +196 -1
  143. package/dist/src/registry.js.map +1 -1
  144. package/dist/src/sources/builtins.d.ts +11 -0
  145. package/dist/src/sources/builtins.d.ts.map +1 -0
  146. package/dist/src/sources/builtins.js +47 -0
  147. package/dist/src/sources/builtins.js.map +1 -0
  148. package/dist/src/sources/codes.d.ts +230 -0
  149. package/dist/src/sources/codes.d.ts.map +1 -0
  150. package/dist/src/sources/codes.js +58 -0
  151. package/dist/src/sources/codes.js.map +1 -0
  152. package/dist/src/sources/context.d.ts +112 -0
  153. package/dist/src/sources/context.d.ts.map +1 -0
  154. package/dist/src/sources/context.js +739 -0
  155. package/dist/src/sources/context.js.map +1 -0
  156. package/dist/src/sources/credentials.d.ts +179 -0
  157. package/dist/src/sources/credentials.d.ts.map +1 -0
  158. package/dist/src/sources/credentials.js +301 -0
  159. package/dist/src/sources/credentials.js.map +1 -0
  160. package/dist/src/sources/cypher/descriptor.d.ts +21 -0
  161. package/dist/src/sources/cypher/descriptor.d.ts.map +1 -0
  162. package/dist/src/sources/cypher/descriptor.js +119 -0
  163. package/dist/src/sources/cypher/descriptor.js.map +1 -0
  164. package/dist/src/sources/cypher/flatten.d.ts +72 -0
  165. package/dist/src/sources/cypher/flatten.d.ts.map +1 -0
  166. package/dist/src/sources/cypher/flatten.js +279 -0
  167. package/dist/src/sources/cypher/flatten.js.map +1 -0
  168. package/dist/src/sources/cypher/index.d.ts +33 -0
  169. package/dist/src/sources/cypher/index.d.ts.map +1 -0
  170. package/dist/src/sources/cypher/index.js +405 -0
  171. package/dist/src/sources/cypher/index.js.map +1 -0
  172. package/dist/src/sources/cypher/params.d.ts +40 -0
  173. package/dist/src/sources/cypher/params.d.ts.map +1 -0
  174. package/dist/src/sources/cypher/params.js +6 -0
  175. package/dist/src/sources/cypher/params.js.map +1 -0
  176. package/dist/src/sources/cypher/profiles.d.ts +44 -0
  177. package/dist/src/sources/cypher/profiles.d.ts.map +1 -0
  178. package/dist/src/sources/cypher/profiles.js +61 -0
  179. package/dist/src/sources/cypher/profiles.js.map +1 -0
  180. package/dist/src/sources/cypher/query-builder.d.ts +106 -0
  181. package/dist/src/sources/cypher/query-builder.d.ts.map +1 -0
  182. package/dist/src/sources/cypher/query-builder.js +236 -0
  183. package/dist/src/sources/cypher/query-builder.js.map +1 -0
  184. package/dist/src/sources/cypher/transports/bolt.d.ts +21 -0
  185. package/dist/src/sources/cypher/transports/bolt.d.ts.map +1 -0
  186. package/dist/src/sources/cypher/transports/bolt.js +185 -0
  187. package/dist/src/sources/cypher/transports/bolt.js.map +1 -0
  188. package/dist/src/sources/cypher/transports/neptune-analytics.d.ts +15 -0
  189. package/dist/src/sources/cypher/transports/neptune-analytics.d.ts.map +1 -0
  190. package/dist/src/sources/cypher/transports/neptune-analytics.js +38 -0
  191. package/dist/src/sources/cypher/transports/neptune-analytics.js.map +1 -0
  192. package/dist/src/sources/cypher/transports/neptune-https.d.ts +31 -0
  193. package/dist/src/sources/cypher/transports/neptune-https.d.ts.map +1 -0
  194. package/dist/src/sources/cypher/transports/neptune-https.js +104 -0
  195. package/dist/src/sources/cypher/transports/neptune-https.js.map +1 -0
  196. package/dist/src/sources/cypher/transports/query-api.d.ts +14 -0
  197. package/dist/src/sources/cypher/transports/query-api.d.ts.map +1 -0
  198. package/dist/src/sources/cypher/transports/query-api.js +80 -0
  199. package/dist/src/sources/cypher/transports/query-api.js.map +1 -0
  200. package/dist/src/sources/cypher/transports/transport.d.ts +78 -0
  201. package/dist/src/sources/cypher/transports/transport.d.ts.map +1 -0
  202. package/dist/src/sources/cypher/transports/transport.js +77 -0
  203. package/dist/src/sources/cypher/transports/transport.js.map +1 -0
  204. package/dist/src/sources/cypher/types-map.d.ts +91 -0
  205. package/dist/src/sources/cypher/types-map.d.ts.map +1 -0
  206. package/dist/src/sources/cypher/types-map.js +306 -0
  207. package/dist/src/sources/cypher/types-map.js.map +1 -0
  208. package/dist/src/sources/define.d.ts +47 -0
  209. package/dist/src/sources/define.d.ts.map +1 -0
  210. package/dist/src/sources/define.js +173 -0
  211. package/dist/src/sources/define.js.map +1 -0
  212. package/dist/src/sources/fail.d.ts +33 -0
  213. package/dist/src/sources/fail.d.ts.map +1 -0
  214. package/dist/src/sources/fail.js +49 -0
  215. package/dist/src/sources/fail.js.map +1 -0
  216. package/dist/src/sources/ids.d.ts +64 -0
  217. package/dist/src/sources/ids.d.ts.map +1 -0
  218. package/dist/src/sources/ids.js +64 -0
  219. package/dist/src/sources/ids.js.map +1 -0
  220. package/dist/src/sources/ndex/client.d.ts +31 -0
  221. package/dist/src/sources/ndex/client.d.ts.map +1 -0
  222. package/dist/src/sources/ndex/client.js +90 -0
  223. package/dist/src/sources/ndex/client.js.map +1 -0
  224. package/dist/src/sources/ndex/descriptor.d.ts +10 -0
  225. package/dist/src/sources/ndex/descriptor.d.ts.map +1 -0
  226. package/dist/src/sources/ndex/descriptor.js +55 -0
  227. package/dist/src/sources/ndex/descriptor.js.map +1 -0
  228. package/dist/src/sources/ndex/expand.d.ts +20 -0
  229. package/dist/src/sources/ndex/expand.d.ts.map +1 -0
  230. package/dist/src/sources/ndex/expand.js +87 -0
  231. package/dist/src/sources/ndex/expand.js.map +1 -0
  232. package/dist/src/sources/ndex/index.d.ts +25 -0
  233. package/dist/src/sources/ndex/index.d.ts.map +1 -0
  234. package/dist/src/sources/ndex/index.js +191 -0
  235. package/dist/src/sources/ndex/index.js.map +1 -0
  236. package/dist/src/sources/ndex/params.d.ts +17 -0
  237. package/dist/src/sources/ndex/params.d.ts.map +1 -0
  238. package/dist/src/sources/ndex/params.js +6 -0
  239. package/dist/src/sources/ndex/params.js.map +1 -0
  240. package/dist/src/sources/ndex/share-url.d.ts +40 -0
  241. package/dist/src/sources/ndex/share-url.d.ts.map +1 -0
  242. package/dist/src/sources/ndex/share-url.js +64 -0
  243. package/dist/src/sources/ndex/share-url.js.map +1 -0
  244. package/dist/src/sources/params.d.ts +28 -0
  245. package/dist/src/sources/params.d.ts.map +1 -0
  246. package/dist/src/sources/params.js +6 -0
  247. package/dist/src/sources/params.js.map +1 -0
  248. package/dist/src/sources/registry.d.ts +118 -0
  249. package/dist/src/sources/registry.d.ts.map +1 -0
  250. package/dist/src/sources/registry.js +193 -0
  251. package/dist/src/sources/registry.js.map +1 -0
  252. package/dist/src/sources/rest/descriptor.d.ts +16 -0
  253. package/dist/src/sources/rest/descriptor.d.ts.map +1 -0
  254. package/dist/src/sources/rest/descriptor.js +71 -0
  255. package/dist/src/sources/rest/descriptor.js.map +1 -0
  256. package/dist/src/sources/rest/index.d.ts +14 -0
  257. package/dist/src/sources/rest/index.d.ts.map +1 -0
  258. package/dist/src/sources/rest/index.js +13 -0
  259. package/dist/src/sources/rest/index.js.map +1 -0
  260. package/dist/src/sources/rest/mapping.d.ts +30 -0
  261. package/dist/src/sources/rest/mapping.d.ts.map +1 -0
  262. package/dist/src/sources/rest/mapping.js +362 -0
  263. package/dist/src/sources/rest/mapping.js.map +1 -0
  264. package/dist/src/sources/rest/openalex.d.ts +27 -0
  265. package/dist/src/sources/rest/openalex.d.ts.map +1 -0
  266. package/dist/src/sources/rest/openalex.js +269 -0
  267. package/dist/src/sources/rest/openalex.js.map +1 -0
  268. package/dist/src/sources/rest/paging.d.ts +53 -0
  269. package/dist/src/sources/rest/paging.d.ts.map +1 -0
  270. package/dist/src/sources/rest/paging.js +138 -0
  271. package/dist/src/sources/rest/paging.js.map +1 -0
  272. package/dist/src/sources/rest/params.d.ts +216 -0
  273. package/dist/src/sources/rest/params.d.ts.map +1 -0
  274. package/dist/src/sources/rest/params.js +7 -0
  275. package/dist/src/sources/rest/params.js.map +1 -0
  276. package/dist/src/sources/rest/records.d.ts +41 -0
  277. package/dist/src/sources/rest/records.d.ts.map +1 -0
  278. package/dist/src/sources/rest/records.js +240 -0
  279. package/dist/src/sources/rest/records.js.map +1 -0
  280. package/dist/src/sources/rest/samples/deps-dev.d.ts +10 -0
  281. package/dist/src/sources/rest/samples/deps-dev.d.ts.map +1 -0
  282. package/dist/src/sources/rest/samples/deps-dev.js +47 -0
  283. package/dist/src/sources/rest/samples/deps-dev.js.map +1 -0
  284. package/dist/src/sources/rest/samples/string.d.ts +9 -0
  285. package/dist/src/sources/rest/samples/string.d.ts.map +1 -0
  286. package/dist/src/sources/rest/samples/string.js +42 -0
  287. package/dist/src/sources/rest/samples/string.js.map +1 -0
  288. package/dist/src/sources/rest/selectors.d.ts +41 -0
  289. package/dist/src/sources/rest/selectors.d.ts.map +1 -0
  290. package/dist/src/sources/rest/selectors.js +81 -0
  291. package/dist/src/sources/rest/selectors.js.map +1 -0
  292. package/dist/src/sources/rest/source.d.ts +67 -0
  293. package/dist/src/sources/rest/source.d.ts.map +1 -0
  294. package/dist/src/sources/rest/source.js +635 -0
  295. package/dist/src/sources/rest/source.js.map +1 -0
  296. package/dist/src/sources/rest/templates.d.ts +38 -0
  297. package/dist/src/sources/rest/templates.d.ts.map +1 -0
  298. package/dist/src/sources/rest/templates.js +125 -0
  299. package/dist/src/sources/rest/templates.js.map +1 -0
  300. package/dist/src/sources/run.d.ts +93 -0
  301. package/dist/src/sources/run.d.ts.map +1 -0
  302. package/dist/src/sources/run.js +673 -0
  303. package/dist/src/sources/run.js.map +1 -0
  304. package/dist/src/sources/sha256.d.ts +12 -0
  305. package/dist/src/sources/sha256.d.ts.map +1 -0
  306. package/dist/src/sources/sha256.js +95 -0
  307. package/dist/src/sources/sha256.js.map +1 -0
  308. package/dist/src/sources/sigv4.d.ts +24 -0
  309. package/dist/src/sources/sigv4.d.ts.map +1 -0
  310. package/dist/src/sources/sigv4.js +182 -0
  311. package/dist/src/sources/sigv4.js.map +1 -0
  312. package/dist/src/sources/testing.d.ts +96 -0
  313. package/dist/src/sources/testing.d.ts.map +1 -0
  314. package/dist/src/sources/testing.js +138 -0
  315. package/dist/src/sources/testing.js.map +1 -0
  316. package/dist/src/sources/types.d.ts +665 -0
  317. package/dist/src/sources/types.d.ts.map +1 -0
  318. package/dist/src/sources/types.js +10 -0
  319. package/dist/src/sources/types.js.map +1 -0
  320. package/dist/src/styles/canon/enums.d.ts.map +1 -1
  321. package/dist/src/styles/canon/enums.js +1 -0
  322. package/dist/src/styles/canon/enums.js.map +1 -1
  323. package/dist/src/styles/cyjs/cascade.d.ts.map +1 -1
  324. package/dist/src/styles/cyjs/cascade.js +68 -2
  325. package/dist/src/styles/cyjs/cascade.js.map +1 -1
  326. package/dist/src/styles/cyjs/defaults-table.d.ts.map +1 -1
  327. package/dist/src/styles/cyjs/defaults-table.js +2 -0
  328. package/dist/src/styles/cyjs/defaults-table.js.map +1 -1
  329. package/dist/src/styles/cyjs/emit.d.ts.map +1 -1
  330. package/dist/src/styles/cyjs/emit.js +18 -7
  331. package/dist/src/styles/cyjs/emit.js.map +1 -1
  332. package/dist/src/styles/cyjs/mappers.d.ts +4 -1
  333. package/dist/src/styles/cyjs/mappers.d.ts.map +1 -1
  334. package/dist/src/styles/cyjs/mappers.js +2 -0
  335. package/dist/src/styles/cyjs/mappers.js.map +1 -1
  336. package/dist/src/styles/cytoscape/emit.d.ts.map +1 -1
  337. package/dist/src/styles/cytoscape/emit.js +59 -7
  338. package/dist/src/styles/cytoscape/emit.js.map +1 -1
  339. package/dist/src/styles/cytoscape/lexicon.d.ts +6 -0
  340. package/dist/src/styles/cytoscape/lexicon.d.ts.map +1 -1
  341. package/dist/src/styles/cytoscape/lexicon.js +26 -2
  342. package/dist/src/styles/cytoscape/lexicon.js.map +1 -1
  343. package/dist/src/styles/cytoscape/resolve.d.ts +4 -1
  344. package/dist/src/styles/cytoscape/resolve.d.ts.map +1 -1
  345. package/dist/src/styles/cytoscape/resolve.js +10 -6
  346. package/dist/src/styles/cytoscape/resolve.js.map +1 -1
  347. package/dist/src/styles/cytoscape/translate.d.ts.map +1 -1
  348. package/dist/src/styles/cytoscape/translate.js +10 -10
  349. package/dist/src/styles/cytoscape/translate.js.map +1 -1
  350. package/dist/src/styles/defaults.d.ts +30 -0
  351. package/dist/src/styles/defaults.d.ts.map +1 -1
  352. package/dist/src/styles/defaults.js +45 -4
  353. package/dist/src/styles/defaults.js.map +1 -1
  354. package/dist/src/styles/io/block.d.ts.map +1 -1
  355. package/dist/src/styles/io/block.js +9 -0
  356. package/dist/src/styles/io/block.js.map +1 -1
  357. package/dist/src/styles/io/writer.d.ts.map +1 -1
  358. package/dist/src/styles/io/writer.js +7 -3
  359. package/dist/src/styles/io/writer.js.map +1 -1
  360. package/dist/src/styles/plan/resolve.d.ts +2 -1
  361. package/dist/src/styles/plan/resolve.d.ts.map +1 -1
  362. package/dist/src/styles/plan/resolve.js +13 -2
  363. package/dist/src/styles/plan/resolve.js.map +1 -1
  364. package/dist/src/styles/types.d.ts +19 -2
  365. package/dist/src/styles/types.d.ts.map +1 -1
  366. package/dist/src/styles/vocabulary.d.ts.map +1 -1
  367. package/dist/src/styles/vocabulary.js +15 -1
  368. package/dist/src/styles/vocabulary.js.map +1 -1
  369. package/dist/src/types.d.ts +19 -5
  370. package/dist/src/types.d.ts.map +1 -1
  371. package/dist/src/types.js.map +1 -1
  372. package/dist/styles.js +11 -11
  373. package/dist/xgmml.js +3 -3
  374. package/docs/samples/people.json +6 -0
  375. package/package.json +29 -4
  376. package/src/common/report.ts +27 -7
  377. package/src/formats/cx/styles.ts +1 -0
  378. package/src/formats/dot/styles.ts +3 -1
  379. package/src/formats/gexf/styles.ts +185 -37
  380. package/src/formats/gml/styles.ts +5 -4
  381. package/src/formats/graphml/styles-plain.ts +3 -9
  382. package/src/formats/graphml/styles-yed.ts +93 -20
  383. package/src/formats/pajek/styles.ts +1 -0
  384. package/src/formats/xgmml/styles.ts +1 -0
  385. package/src/index.ts +90 -0
  386. package/src/registry.ts +326 -1
  387. package/src/sources/builtins.ts +56 -0
  388. package/src/sources/codes.ts +235 -0
  389. package/src/sources/context.ts +893 -0
  390. package/src/sources/credentials.ts +409 -0
  391. package/src/sources/cypher/descriptor.ts +125 -0
  392. package/src/sources/cypher/flatten.ts +323 -0
  393. package/src/sources/cypher/index.ts +498 -0
  394. package/src/sources/cypher/params.ts +41 -0
  395. package/src/sources/cypher/profiles.ts +78 -0
  396. package/src/sources/cypher/query-builder.ts +294 -0
  397. package/src/sources/cypher/transports/bolt.ts +228 -0
  398. package/src/sources/cypher/transports/neptune-analytics.ts +41 -0
  399. package/src/sources/cypher/transports/neptune-https.ts +122 -0
  400. package/src/sources/cypher/transports/query-api.ts +100 -0
  401. package/src/sources/cypher/transports/transport.ts +139 -0
  402. package/src/sources/cypher/types-map.ts +418 -0
  403. package/src/sources/define.ts +195 -0
  404. package/src/sources/fail.ts +70 -0
  405. package/src/sources/ids.ts +74 -0
  406. package/src/sources/ndex/client.ts +102 -0
  407. package/src/sources/ndex/descriptor.ts +64 -0
  408. package/src/sources/ndex/expand.ts +100 -0
  409. package/src/sources/ndex/index.ts +235 -0
  410. package/src/sources/ndex/params.ts +17 -0
  411. package/src/sources/ndex/share-url.ts +84 -0
  412. package/src/sources/params.ts +29 -0
  413. package/src/sources/registry.ts +325 -0
  414. package/src/sources/rest/descriptor.ts +74 -0
  415. package/src/sources/rest/index.ts +22 -0
  416. package/src/sources/rest/mapping.ts +401 -0
  417. package/src/sources/rest/openalex.ts +288 -0
  418. package/src/sources/rest/paging.ts +180 -0
  419. package/src/sources/rest/params.ts +243 -0
  420. package/src/sources/rest/records.ts +289 -0
  421. package/src/sources/rest/samples/deps-dev.ts +49 -0
  422. package/src/sources/rest/samples/string.ts +44 -0
  423. package/src/sources/rest/selectors.ts +91 -0
  424. package/src/sources/rest/source.ts +760 -0
  425. package/src/sources/rest/templates.ts +151 -0
  426. package/src/sources/run.ts +793 -0
  427. package/src/sources/sha256.ts +99 -0
  428. package/src/sources/sigv4.ts +207 -0
  429. package/src/sources/testing.ts +210 -0
  430. package/src/sources/types.ts +741 -0
  431. package/src/styles/canon/enums.ts +1 -0
  432. package/src/styles/cyjs/cascade.ts +81 -2
  433. package/src/styles/cyjs/defaults-table.ts +2 -0
  434. package/src/styles/cyjs/emit.ts +18 -7
  435. package/src/styles/cyjs/mappers.ts +6 -1
  436. package/src/styles/cytoscape/emit.ts +61 -7
  437. package/src/styles/cytoscape/lexicon.ts +28 -2
  438. package/src/styles/cytoscape/resolve.ts +22 -6
  439. package/src/styles/cytoscape/translate.ts +11 -11
  440. package/src/styles/defaults.ts +93 -4
  441. package/src/styles/io/block.ts +10 -0
  442. package/src/styles/io/writer.ts +8 -3
  443. package/src/styles/plan/resolve.ts +14 -2
  444. package/src/styles/types.ts +28 -2
  445. package/src/styles/vocabulary.ts +15 -1
  446. package/src/types.ts +19 -5
  447. package/dist/chunks/block-DiGq58c3.js.map +0 -1
  448. package/dist/chunks/emit-CwU8cUmG.js.map +0 -1
  449. package/dist/chunks/export-BvqAXCKh.js.map +0 -1
  450. package/dist/chunks/format-BpQBx8MZ.js.map +0 -1
  451. package/dist/chunks/importer-BSvfrX_h.js.map +0 -1
  452. package/dist/chunks/importer-CMmeMWlC.js.map +0 -1
  453. package/dist/chunks/importer-COTK9Tsl.js.map +0 -1
  454. package/dist/chunks/importer-DiZRmOQG.js.map +0 -1
  455. package/dist/chunks/importer-e6LGpqHB.js.map +0 -1
  456. package/dist/chunks/lexicon-CT69Kd87.js.map +0 -1
  457. package/dist/chunks/styles-BQnsga7p.js.map +0 -1
  458. package/dist/chunks/styles-D3fRphrO.js.map +0 -1
  459. package/dist/chunks/styles-yed-BF5x3_Y5.js.map +0 -1
  460. package/dist/chunks/writer-DMKvthQE.js.map +0 -1
@@ -1,5 +1,7 @@
1
1
  import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
2
- import { aR as withArticle, C as COLUMN_RENAMED_CODE, U as UNKNOWN_ATTR_TYPE_CODE, R as ROLE_TAKEN_CODE, B as BAD_DEFAULT_CODE, ae as BAD_OPTIONS_CODE, D as DIRECTION_FORCED_CODE, b as DIRECTION_REFUSED_CODE, M as MIXED_DIRECTION_CODE, O as OPTION_IGNORED_CODE, au as CONTROL_CHARACTER_CODE, E as EMPTY_INPUT_CODE, a1 as TOO_LARGE_CODE, u as INVALID_ENCODING_CODE, s as UNKNOWN_ENCODING_CODE, r as ENCODING_CONFLICT_CODE, v as INVALID_UTF8_CODE, t as ENCODING_FALLBACK_CODE, az as FOREIGN_FORMAT_CODE, N as NO_GRAPH_CODE, a2 as AMBIGUOUS_GRAPH_NAME_CODE, a3 as GRAPH_NOT_FOUND_CODE, p as plural, S as SINK_OPTION_CODE, ad as formatInteger, $ as formatF32, a0 as formatF64, P as PRECISION_CODE, aM as WEIGHTS_DROPPED_CODE, aE as NONFINITE_AS_NULL_CODE, aF as OPTIONS_GAINED_CODE, ac as XML_ILLEGAL_CHAR_CODE, aL as TEXT_INFERRED_CODE, aB as INTEGRAL_F64_CODE, aI as STORAGE_CLASS_CODE, ax as EMPTY_COLUMN_DROPPED_CODE, at as COLUMN_RENAMED_LOSS_CODE, aa as ROLE_ASSUMED_CODE, aN as WEIGHT_KEY_CLASH_CODE, aA as ID_TEXT_COLLISION_CODE, A as ID_TEXT_TYPE_CODE, J as MUTUAL_AS_UNDIRECTED_CODE, aD as MUTUAL_EXPANDED_CODE, G as PARENTS_DROPPED_CODE, F as ROLE_DROPPED_CODE, aK as TEMPORAL_TEXT_DROPPED_CODE, aJ as TEMPORAL_DROPPED_CODE, as as COLUMN_DROPPED_CODE, a as agree } from "./format-BpQBx8MZ.js";
2
+ import { ai as withArticle, C as COLUMN_RENAMED_CODE, R as ROLE_TAKEN_CODE, U as UNKNOWN_ATTR_TYPE_CODE, B as BAD_DEFAULT_CODE, ac as BAD_OPTIONS_CODE, D as DIRECTION_FORCED_CODE, b as DIRECTION_REFUSED_CODE, M as MIXED_DIRECTION_CODE, O as OPTION_IGNORED_CODE, S as SINK_OPTION_CODE, N as NO_GRAPH_CODE, W as AMBIGUOUS_GRAPH_NAME_CODE, Y as GRAPH_NOT_FOUND_CODE, p as plural, P as PRECISION_CODE, aL as WEIGHTS_DROPPED_CODE, aG as NONFINITE_AS_NULL_CODE, aH as OPTIONS_GAINED_CODE, ab as XML_ILLEGAL_CHAR_CODE, aK as TEXT_INFERRED_CODE, aE as INTEGRAL_F64_CODE, ap as STORAGE_CLASS_CODE, aD as EMPTY_COLUMN_DROPPED_CODE, aq as COLUMN_RENAMED_LOSS_CODE, a9 as ROLE_ASSUMED_CODE, ak as WEIGHT_KEY_CLASH_CODE, aj as ID_TEXT_COLLISION_CODE, A as ID_TEXT_TYPE_CODE, J as MUTUAL_AS_UNDIRECTED_CODE, al as MUTUAL_EXPANDED_CODE, G as PARENTS_DROPPED_CODE, F as ROLE_DROPPED_CODE, ar as TEMPORAL_TEXT_DROPPED_CODE, as as TEMPORAL_DROPPED_CODE, aA as COLUMN_DROPPED_CODE, a as agree } from "./report-CgdsL9Hb.js";
3
+ import { d as canonicalEncoding } from "./input-Ccg9I22A.js";
4
+ import { c as formatInteger, f as formatF32, a as formatF64 } from "./format-BMS-1Nxb.js";
3
5
  const TIME_TEXT_ROLE = "timeText";
4
6
  const TIME_TEXT_SUFFIX = ".text";
5
7
  const DATE_TIME$1 = /^(-?\d{4,})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?)?(Z|z|[+-]\d{2}(?::?\d{2})?)?$/;
@@ -1258,1383 +1260,6 @@ class IdCoercer {
1258
1260
  return coerceId(value, this.mode);
1259
1261
  }
1260
1262
  }
1261
- const HEAD_BYTES = 1024;
1262
- const BOM_BYTES = 4;
1263
- function canonicalEncoding(label) {
1264
- try {
1265
- return new TextDecoder(label.trim()).encoding;
1266
- } catch {
1267
- return null;
1268
- }
1269
- }
1270
- function bomEncoding(head) {
1271
- if (startsWithBytes(head, [255, 254, 0, 0])) {
1272
- return "utf-32le";
1273
- }
1274
- if (startsWithBytes(head, [0, 0, 254, 255])) {
1275
- return "utf-32be";
1276
- }
1277
- if (startsWithBytes(head, [239, 187, 191])) {
1278
- return "utf-8";
1279
- }
1280
- if (startsWithBytes(head, [255, 254])) {
1281
- return "utf-16le";
1282
- }
1283
- if (startsWithBytes(head, [254, 255])) {
1284
- return "utf-16be";
1285
- }
1286
- return null;
1287
- }
1288
- function startsWithBytes(bytes, signature) {
1289
- return bytes.byteLength >= signature.length && signature.every((b, i) => bytes[i] === b);
1290
- }
1291
- function bomlessUtf16(head) {
1292
- const pairs = Math.min(head.byteLength >> 1, 512);
1293
- if (pairs < 2) {
1294
- return null;
1295
- }
1296
- let le = 0;
1297
- let be = 0;
1298
- for (let i = 0; i < pairs; i++) {
1299
- const even = head[2 * i];
1300
- const odd = head[2 * i + 1];
1301
- if (even !== 0 && odd === 0) {
1302
- le++;
1303
- } else if (even === 0 && odd !== 0) {
1304
- be++;
1305
- }
1306
- }
1307
- if (le >= pairs * 0.9) {
1308
- return "utf-16le";
1309
- }
1310
- return be >= pairs * 0.9 ? "utf-16be" : null;
1311
- }
1312
- function xmlDeclarationUtf16(head) {
1313
- if (startsWithBytes(head, [60, 0, 63, 0])) {
1314
- return "utf-16le";
1315
- }
1316
- return startsWithBytes(head, [0, 60, 0, 63]) ? "utf-16be" : null;
1317
- }
1318
- function foreignKind(head) {
1319
- if (typeof head !== "string") {
1320
- if (startsWithBytes(head, [31, 139])) {
1321
- return "gzip-compressed data (decompress it first)";
1322
- }
1323
- if (startsWithBytes(head, [80, 75, 3, 4]) || startsWithBytes(head, [80, 75, 5, 6])) {
1324
- return "a zip archive (a Cytoscape session (.cys) is read by the cys importer; extract any other graph file from it first)";
1325
- }
1326
- if (startsWithBytes(head, [137, 80, 78, 71])) {
1327
- return "a PNG image";
1328
- }
1329
- }
1330
- const text = typeof head === "string" ? head.slice(0, 64) : String.fromCodePoint(...head.subarray(0, 64));
1331
- const utf8Bom = String.fromCodePoint(239, 187, 191);
1332
- let body = text.startsWith(utf8Bom) ? text.slice(3) : text;
1333
- body = body.startsWith(BOM) ? body.slice(1) : body;
1334
- if (body.startsWith("%PDF-")) {
1335
- return "a PDF document";
1336
- }
1337
- if (/^\s*(<!doctype\s+html[\s>]|<html[\s>])/i.test(body)) {
1338
- return "an HTML document (likely an error page saved in place of the file)";
1339
- }
1340
- return null;
1341
- }
1342
- function refuseForeign(head, report, options) {
1343
- const foreign = foreignKind(head);
1344
- if (foreign !== null && !(options.xml === true && foreign.startsWith("an HTML"))) {
1345
- report.fail(FOREIGN_FORMAT_CODE, `the input is ${foreign}, not ${report.format} text`);
1346
- }
1347
- }
1348
- function sameFamily(a, b) {
1349
- return a === b || a.startsWith("utf-16") && b.startsWith("utf-16");
1350
- }
1351
- class ByteDecoder {
1352
- /**
1353
- * Create the decoder of one import.
1354
- * @param report - where warnings and the fatal decode error go
1355
- * @param options - the encoding option and the format's declaration reader
1356
- */
1357
- constructor(report, options) {
1358
- this.report = report;
1359
- this.options = options;
1360
- this.decoder = null;
1361
- this.encoding = "utf-8";
1362
- this.mayFallBack = false;
1363
- this.asciiSoFar = true;
1364
- this.carry = new Uint8Array(0);
1365
- this.offset = 0;
1366
- this.fellBack = false;
1367
- this.control = null;
1368
- this.subAt = -1;
1369
- this.textFollows = false;
1370
- this.declaredUtf8 = false;
1371
- this.mixedPending = false;
1372
- }
1373
- /**
1374
- * Whether start() ran.
1375
- * @returns true once the encoding is chosen
1376
- */
1377
- get started() {
1378
- return this.decoder !== null;
1379
- }
1380
- /**
1381
- * Choose the encoding from the first bytes of the input: a BOM, else the option, else the
1382
- * declaration, else UTF-8 (see the module comment), warning where two of them disagree.
1383
- * @param head - the first bytes (up to the declaration size; fewer when the input is shorter)
1384
- */
1385
- start(head) {
1386
- refuseForeign(head, this.report, this.options);
1387
- const explicit = this.options.encoding ?? null;
1388
- const bom = bomEncoding(head);
1389
- if (bom === "utf-32le" || bom === "utf-32be") {
1390
- this.report.fail(
1391
- INVALID_ENCODING_CODE,
1392
- `the input starts with a ${bom.toUpperCase()} byte order mark; UTF-32 is not supported (convert the file to UTF-8)`,
1393
- void 0,
1394
- { byteOffset: 0 }
1395
- );
1396
- }
1397
- if (bom !== null) {
1398
- const option = explicit === null ? null : canonicalEncoding(explicit);
1399
- if (option !== null && option !== bom) {
1400
- this.conflict(`the encoding option says ${option} but the byte order mark says ${bom}; read as ${bom}`);
1401
- }
1402
- this.checkDeclaration(head, bom, "its byte order mark says");
1403
- this.use(bom, false);
1404
- return;
1405
- }
1406
- if (explicit !== null) {
1407
- this.use(explicit, false);
1408
- this.checkDeclaration(head, this.encoding, "the encoding option says");
1409
- return;
1410
- }
1411
- const xmlUtf16 = xmlDeclarationUtf16(head);
1412
- if (xmlUtf16 !== null) {
1413
- this.checkDeclaration(head, xmlUtf16, "its XML declaration's byte pattern says");
1414
- this.use(xmlUtf16, false);
1415
- return;
1416
- }
1417
- const utf16 = bomlessUtf16(head);
1418
- if (utf16 !== null && this.options.bomlessUtf16 === true) {
1419
- this.use(utf16, false);
1420
- return;
1421
- }
1422
- if (utf16 !== null) {
1423
- this.report.fail(
1424
- INVALID_ENCODING_CODE,
1425
- `the input looks like ${utf16} text without a byte order mark (every other byte is 0); pass the encoding option ${JSON.stringify(utf16)} to read it`,
1426
- void 0,
1427
- { byteOffset: 0 }
1428
- );
1429
- }
1430
- const declared = this.declared(head, "windows-1252");
1431
- if (declared !== null) {
1432
- const canonical = canonicalEncoding(declared);
1433
- if (canonical === null) {
1434
- this.report.warning(
1435
- "unsupported",
1436
- UNKNOWN_ENCODING_CODE,
1437
- `the input declares the encoding ${JSON.stringify(declared)}, which this platform cannot decode; reading it as UTF-8`,
1438
- { element: declared }
1439
- );
1440
- } else if (canonical.startsWith("utf-16")) {
1441
- this.conflict(
1442
- `the input declares ${JSON.stringify(declared)} but has no byte order mark and its bytes are not UTF-16; read as UTF-8`
1443
- );
1444
- } else if (canonical === "utf-8") {
1445
- this.declaredUtf8 = true;
1446
- } else {
1447
- this.use(canonical, false);
1448
- return;
1449
- }
1450
- }
1451
- this.use("utf-8", true);
1452
- }
1453
- /**
1454
- * The encoding the head declares, read through the format's declaration reader.
1455
- * @param head - the first bytes
1456
- * @param encoding - the encoding to read the head in for the reader
1457
- * @returns the declared label, or null (also for a format without declarations)
1458
- */
1459
- declared(head, encoding) {
1460
- const reader = this.options.declaredEncoding;
1461
- return reader === void 0 ? null : reader(new TextDecoder(encoding).decode(head));
1462
- }
1463
- /**
1464
- * Warn when the file declares an encoding other than the one a BOM or the option chose.
1465
- * @param head - the first bytes
1466
- * @param chosen - the encoding the input is read in
1467
- * @param why - what chose it, for the message
1468
- */
1469
- checkDeclaration(head, chosen, why) {
1470
- const declared = this.declared(head, chosen);
1471
- const canonical = declared === null ? null : canonicalEncoding(declared);
1472
- if (canonical !== null && !sameFamily(canonical, chosen)) {
1473
- this.conflict(
1474
- `the input declares the encoding ${JSON.stringify(declared)} but ${why} ${chosen}; read as ${chosen}`
1475
- );
1476
- }
1477
- }
1478
- /**
1479
- * Record a W_ENCODING_CONFLICT warning.
1480
- * @param message - which sources disagree and which applies
1481
- */
1482
- conflict(message) {
1483
- this.report.warning("coercion", ENCODING_CONFLICT_CODE, message);
1484
- }
1485
- /**
1486
- * Decode the next bytes.
1487
- * @param input - the bytes
1488
- * @param stream - whether more bytes follow
1489
- * @returns the text
1490
- */
1491
- decode(input, stream) {
1492
- const bytes = typeof SharedArrayBuffer === "function" && input.buffer instanceof SharedArrayBuffer ? input.slice() : input;
1493
- const decoder = this.decoder;
1494
- if (this.fellBack || this.mayFallBack && this.asciiSoFar) {
1495
- this.watch(bytes, !stream);
1496
- if (this.fellBack && this.control !== null) {
1497
- this.binary(this.control);
1498
- }
1499
- }
1500
- const text = this.decodeOrRecover(decoder, bytes, stream);
1501
- if (this.mixedPending) {
1502
- this.reportUtf8After(bytes, this.offset);
1503
- }
1504
- if (this.asciiSoFar && this.mayFallBack) {
1505
- this.trackAscii(bytes, text);
1506
- }
1507
- if (this.mayFallBack && this.options.nulIsBinary === true && text.includes("\0")) {
1508
- this.binary({ at: this.offset + bytes.indexOf(0), byte: 0 });
1509
- }
1510
- this.offset += bytes.byteLength;
1511
- return text;
1512
- }
1513
- /**
1514
- * Decode bytes, recovering from bytes that are not valid in the encoding.
1515
- * @param decoder - the decoder
1516
- * @param bytes - the bytes
1517
- * @param stream - whether more bytes follow
1518
- * @returns the text
1519
- */
1520
- decodeOrRecover(decoder, bytes, stream) {
1521
- try {
1522
- return decoder.decode(bytes, { stream });
1523
- } catch (err) {
1524
- if (!(err instanceof TypeError)) {
1525
- throw err;
1526
- }
1527
- return this.recover(bytes, stream);
1528
- }
1529
- }
1530
- /**
1531
- * Track whether the input is ASCII so far. While it is, every character is one byte, so the
1532
- * bytes not yet emitted are held back for a fallback.
1533
- * @param bytes - the bytes just decoded
1534
- * @param text - their text
1535
- */
1536
- trackAscii(bytes, text) {
1537
- if (/[\u0080-\uffff]/.test(text)) {
1538
- this.asciiSoFar = false;
1539
- this.carry = new Uint8Array(0);
1540
- return;
1541
- }
1542
- const all = this.carry.byteLength === 0 ? bytes : concatBytes([this.carry, bytes]);
1543
- this.carry = all.slice(text.length);
1544
- }
1545
- /**
1546
- * Flush the bytes held back because a text chunk follows (the input switches from bytes to
1547
- * strings): a multi-byte sequence cut there is invalid UTF-8, never windows-1252 text.
1548
- * @param flush - the flush to run (the decoder's own, or the head's)
1549
- * @returns the text of the held-back bytes
1550
- */
1551
- flushBeforeText(flush) {
1552
- this.textFollows = true;
1553
- try {
1554
- return flush();
1555
- } finally {
1556
- this.textFollows = false;
1557
- }
1558
- }
1559
- /**
1560
- * A decode failed: switch to windows-1252 when allowed, else fail the import with the position
1561
- * of the first byte that is not valid.
1562
- * @param bytes - the bytes that failed
1563
- * @param stream - whether more bytes follow
1564
- * @returns the bytes decoded as windows-1252
1565
- */
1566
- recover(bytes, stream) {
1567
- const all = this.carry.byteLength === 0 ? bytes : concatBytes([this.carry, bytes]);
1568
- const base = this.offset - this.carry.byteLength;
1569
- const bad = this.encoding === "utf-8" ? invalidUtf8(all) : null;
1570
- const at = base + (bad === null ? 0 : bad.index);
1571
- if (this.mayFallBack && this.asciiSoFar) {
1572
- const text = this.fallBack(all, bad, at, base, stream);
1573
- if (text !== null) {
1574
- return text;
1575
- }
1576
- }
1577
- return this.failDecode(bytes, at, base, stream);
1578
- }
1579
- /**
1580
- * Undeclared input that was ASCII so far failed to decode: fail on binary data or a cut
1581
- * sequence, else switch to windows-1252 with a warning unless the bytes start with valid
1582
- * non-ASCII UTF-8.
1583
- * @param all - the held-back bytes followed by the bytes that failed
1584
- * @param bad - the first invalid UTF-8 sequence, or null when the encoding is not UTF-8
1585
- * @param at - the byte offset of the first invalid byte
1586
- * @param base - the byte offset of `all`
1587
- * @param stream - whether more bytes follow
1588
- * @returns the bytes decoded as windows-1252, or null when they do not fall back
1589
- */
1590
- fallBack(all, bad, at, base, stream) {
1591
- if (this.control !== null) {
1592
- return this.binary(this.control);
1593
- }
1594
- if (this.textFollows && bad?.cut === true) {
1595
- return this.report.fail(
1596
- INVALID_UTF8_CODE,
1597
- `invalid UTF-8 at byte ${at}: a byte chunk ends inside a multi-byte sequence and a text chunk follows`,
1598
- void 0,
1599
- { byteOffset: at }
1600
- );
1601
- }
1602
- if (!stream && bad?.truncated === true) {
1603
- return this.report.fail(
1604
- INVALID_UTF8_CODE,
1605
- `the input ends in the middle of a UTF-8 sequence at byte ${at} (it may be truncated)`,
1606
- void 0,
1607
- { byteOffset: at }
1608
- );
1609
- }
1610
- if (startsWithUtf8(all)) {
1611
- return null;
1612
- }
1613
- const cutNote = !stream && bad?.cut === true ? ": it ends inside a multi-byte UTF-8 sequence, so it may be truncated" : "";
1614
- this.report.warning(
1615
- "coercion",
1616
- ENCODING_FALLBACK_CODE,
1617
- this.declaredUtf8 ? `the input declares UTF-8 but is not valid UTF-8 (at byte ${at}); everything before was ASCII, so it is read as windows-1252 (pass the encoding option to choose another)` : `the input is not valid UTF-8 (at byte ${at}${cutNote}) and declares no encoding; read as windows-1252 (pass the encoding option to choose another)`
1618
- );
1619
- this.use("windows-1252", false);
1620
- this.fellBack = true;
1621
- this.mixedPending = true;
1622
- this.reportUtf8After(all, base);
1623
- return this.decoder.decode(all, { stream });
1624
- }
1625
- /**
1626
- * Fail the import on bytes that are not valid in the encoding.
1627
- * @param bytes - the bytes that failed
1628
- * @param at - the byte offset of the first invalid UTF-8 byte
1629
- * @param base - the byte offset of the held-back bytes and these
1630
- * @param stream - whether more bytes follow
1631
- * @returns never: it throws
1632
- */
1633
- failDecode(bytes, at, base, stream) {
1634
- if (this.encoding === "utf-8") {
1635
- const after = this.mayFallBack ? " after valid non-ASCII UTF-8 text; pass the encoding option" : "";
1636
- return this.report.fail(INVALID_UTF8_CODE, `invalid UTF-8 at byte ${at}${after}`, void 0, {
1637
- byteOffset: at
1638
- });
1639
- }
1640
- const end = this.offset + bytes.byteLength;
1641
- const odd = !stream && this.encoding.startsWith("utf-16") && end % 2 === 1;
1642
- return this.report.fail(
1643
- INVALID_ENCODING_CODE,
1644
- odd ? `the input ends with half a ${this.encoding} code unit at byte ${end - 1} (it may be truncated)` : `the bytes near byte ${base} are not valid ${this.encoding}`,
1645
- void 0,
1646
- { byteOffset: odd ? end - 1 : base }
1647
- );
1648
- }
1649
- /**
1650
- * After the windows-1252 fallback, report once that later bytes hold a valid multi-byte UTF-8
1651
- * sequence: the input mixes encodings, and those characters are read as two or three
1652
- * windows-1252 characters each.
1653
- * @param bytes - bytes being decoded as windows-1252
1654
- * @param start - the byte offset of the first of them
1655
- */
1656
- reportUtf8After(bytes, start) {
1657
- const at = utf8SequenceIndex(bytes);
1658
- if (at < 0) {
1659
- return;
1660
- }
1661
- this.mixedPending = false;
1662
- this.report.warning(
1663
- "coercion",
1664
- ENCODING_FALLBACK_CODE,
1665
- `bytes read as windows-1252 hold valid UTF-8 (at byte ${start + at}): the input mixes encodings, and its UTF-8 characters are read as windows-1252 (pass the encoding option to choose one)`
1666
- );
1667
- }
1668
- /**
1669
- * Note the first control byte of the next bytes (see `control`).
1670
- * @param bytes - the bytes, starting at `offset`
1671
- * @param final - whether they end the input
1672
- */
1673
- watch(bytes, final) {
1674
- if (this.control !== null || bytes.byteLength === 0) {
1675
- return;
1676
- }
1677
- if (this.subAt >= 0) {
1678
- this.control = { at: this.subAt, byte: 26 };
1679
- return;
1680
- }
1681
- const index = controlByte(bytes, true);
1682
- if (index >= 0) {
1683
- this.control = { at: this.offset + index, byte: bytes[index] };
1684
- } else if (!final && bytes[bytes.byteLength - 1] === 26) {
1685
- this.subAt = this.offset + bytes.byteLength - 1;
1686
- }
1687
- }
1688
- /**
1689
- * Fail the import as binary data.
1690
- * @param control - the control byte that shows it
1691
- * @param control.at - its offset
1692
- * @param control.byte - its value
1693
- * @returns never
1694
- */
1695
- binary(control) {
1696
- const hex = control.byte.toString(16).padStart(2, "0");
1697
- return this.report.fail(
1698
- INVALID_UTF8_CODE,
1699
- `the input is binary data, not text: control byte 0x${hex} at byte ${control.at}`,
1700
- void 0,
1701
- { byteOffset: control.at }
1702
- );
1703
- }
1704
- /**
1705
- * Switch to an encoding.
1706
- * @param label - the encoding label
1707
- * @param mayFallBack - whether a UTF-8 failure may switch to windows-1252
1708
- */
1709
- use(label, mayFallBack) {
1710
- this.decoder = new TextDecoder(label, { fatal: true, ignoreBOM: true });
1711
- this.encoding = this.decoder.encoding;
1712
- this.mayFallBack = mayFallBack;
1713
- }
1714
- }
1715
- function utf8SequenceIndex(bytes) {
1716
- for (let i = 0; i < bytes.byteLength; i++) {
1717
- if (bytes[i] >= 194 && isUtf8SequenceAt(bytes, i)) {
1718
- return i;
1719
- }
1720
- }
1721
- return -1;
1722
- }
1723
- function startsWithUtf8(bytes) {
1724
- const i = bytes.findIndex((b) => b >= 128);
1725
- return i >= 0 && isUtf8SequenceAt(bytes, i);
1726
- }
1727
- const STRICT_UTF8 = new TextDecoder("utf-8", { fatal: true });
1728
- function isUtf8SequenceAt(bytes, i) {
1729
- const lead = bytes[i];
1730
- let length = 0;
1731
- if (lead >= 194 && lead <= 223) {
1732
- length = 2;
1733
- } else if (lead >= 224 && lead <= 239) {
1734
- length = 3;
1735
- } else if (lead >= 240 && lead <= 244) {
1736
- length = 4;
1737
- }
1738
- if (length === 0 || i + length > bytes.byteLength) {
1739
- return false;
1740
- }
1741
- try {
1742
- STRICT_UTF8.decode(bytes.subarray(i, i + length));
1743
- return true;
1744
- } catch {
1745
- return false;
1746
- }
1747
- }
1748
- const CP437_HIGH = [
1749
- 199,
1750
- 252,
1751
- 233,
1752
- 226,
1753
- 228,
1754
- 224,
1755
- 229,
1756
- 231,
1757
- 234,
1758
- 235,
1759
- 232,
1760
- 239,
1761
- 238,
1762
- 236,
1763
- 196,
1764
- 197,
1765
- 201,
1766
- 230,
1767
- 198,
1768
- 244,
1769
- 246,
1770
- 242,
1771
- 251,
1772
- 249,
1773
- 255,
1774
- 214,
1775
- 220,
1776
- 162,
1777
- 163,
1778
- 165,
1779
- 8359,
1780
- 402,
1781
- 225,
1782
- 237,
1783
- 243,
1784
- 250,
1785
- 241,
1786
- 209,
1787
- 170,
1788
- 186,
1789
- 191,
1790
- 8976,
1791
- 172,
1792
- 189,
1793
- 188,
1794
- 161,
1795
- 171,
1796
- 187,
1797
- 9617,
1798
- 9618,
1799
- 9619,
1800
- 9474,
1801
- 9508,
1802
- 9569,
1803
- 9570,
1804
- 9558,
1805
- 9557,
1806
- 9571,
1807
- 9553,
1808
- 9559,
1809
- 9565,
1810
- 9564,
1811
- 9563,
1812
- 9488,
1813
- 9492,
1814
- 9524,
1815
- 9516,
1816
- 9500,
1817
- 9472,
1818
- 9532,
1819
- 9566,
1820
- 9567,
1821
- 9562,
1822
- 9556,
1823
- 9577,
1824
- 9574,
1825
- 9568,
1826
- 9552,
1827
- 9580,
1828
- 9575,
1829
- 9576,
1830
- 9572,
1831
- 9573,
1832
- 9561,
1833
- 9560,
1834
- 9554,
1835
- 9555,
1836
- 9579,
1837
- 9578,
1838
- 9496,
1839
- 9484,
1840
- 9608,
1841
- 9604,
1842
- 9612,
1843
- 9616,
1844
- 9600,
1845
- 945,
1846
- 223,
1847
- 915,
1848
- 960,
1849
- 931,
1850
- 963,
1851
- 181,
1852
- 964,
1853
- 934,
1854
- 920,
1855
- 937,
1856
- 948,
1857
- 8734,
1858
- 966,
1859
- 949,
1860
- 8745,
1861
- 8801,
1862
- 177,
1863
- 8805,
1864
- 8804,
1865
- 8992,
1866
- 8993,
1867
- 247,
1868
- 8776,
1869
- 176,
1870
- 8729,
1871
- 183,
1872
- 8730,
1873
- 8319,
1874
- 178,
1875
- 9632,
1876
- 160
1877
- ];
1878
- function invalidUtf8(bytes) {
1879
- let i = 0;
1880
- while (i < bytes.byteLength) {
1881
- const lead = bytes[i];
1882
- const sequence = lead < 128 ? ASCII_SEQUENCE : utf8Sequence(lead);
1883
- if (sequence === null) {
1884
- return { index: i, truncated: false, cut: false };
1885
- }
1886
- const problem = checkContinuation(bytes, i, sequence);
1887
- if (problem !== null) {
1888
- return problem;
1889
- }
1890
- i += sequence.need + 1;
1891
- }
1892
- return { index: 0, truncated: false, cut: false };
1893
- }
1894
- const ASCII_SEQUENCE = { need: 0, low: 128, high: 191 };
1895
- function utf8Sequence(lead) {
1896
- if (lead >= 194 && lead <= 223) {
1897
- return { need: 1, low: 128, high: 191 };
1898
- }
1899
- if (lead >= 224 && lead <= 239) {
1900
- return { need: 2, low: lead === 224 ? 160 : 128, high: lead === 237 ? 159 : 191 };
1901
- }
1902
- if (lead >= 240 && lead <= 244) {
1903
- return { need: 3, low: lead === 240 ? 144 : 128, high: lead === 244 ? 143 : 191 };
1904
- }
1905
- return null;
1906
- }
1907
- function checkContinuation(bytes, i, sequence) {
1908
- for (let k = 1; k <= sequence.need; k++) {
1909
- if (i + k >= bytes.byteLength) {
1910
- return { index: i, truncated: k > 1, cut: true };
1911
- }
1912
- const next = bytes[i + k];
1913
- const low = k === 1 ? sequence.low : 128;
1914
- const high = k === 1 ? sequence.high : 191;
1915
- if (next < low || next > high) {
1916
- return { index: i, truncated: false, cut: false };
1917
- }
1918
- }
1919
- return null;
1920
- }
1921
- function controlByte(bytes, final) {
1922
- const last = bytes.byteLength - 1;
1923
- for (let i = 0; i <= last; i++) {
1924
- const b = bytes[i];
1925
- if (b < 32 && b !== 9 && b !== 10 && b !== 12 && b !== 13 && !(b === 26 && final && i === last)) {
1926
- return i;
1927
- }
1928
- }
1929
- return -1;
1930
- }
1931
- function decodeEntryName(bytes, cp437 = false) {
1932
- try {
1933
- return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
1934
- } catch {
1935
- if (!cp437) {
1936
- return new TextDecoder("windows-1252").decode(bytes);
1937
- }
1938
- let out = "";
1939
- for (const byte of bytes) {
1940
- out += String.fromCodePoint(byte < 128 ? byte : CP437_HIGH[byte - 128]);
1941
- }
1942
- return out;
1943
- }
1944
- }
1945
- function concatBytes(chunks) {
1946
- if (chunks.length === 1) {
1947
- return chunks[0];
1948
- }
1949
- const out = new Uint8Array(chunks.reduce((sum, c) => sum + c.byteLength, 0));
1950
- let offset = 0;
1951
- for (const chunk of chunks) {
1952
- out.set(chunk, offset);
1953
- offset += chunk.byteLength;
1954
- }
1955
- return out;
1956
- }
1957
- const DECODE_SLICE = 256 * 1024;
1958
- const BOM = String.fromCharCode(65279);
1959
- const SUB = String.fromCodePoint(26);
1960
- const MAX_TEXT_LENGTH = 2 ** 29 - 24;
1961
- const CONTROL_CHARACTER = new RegExp(
1962
- `[${String.fromCodePoint(0)}-${String.fromCodePoint(8, 11, 14)}-${String.fromCodePoint(31, 127)}-${String.fromCodePoint(159)}${BOM}]`
1963
- );
1964
- function isImportInput(input) {
1965
- if (typeof input === "string" || asBytes(input) !== null) {
1966
- return true;
1967
- }
1968
- if (typeof input !== "object" || input === null) {
1969
- return false;
1970
- }
1971
- return typeof input.getReader === "function" || Symbol.asyncIterator in input;
1972
- }
1973
- function asBytes(value) {
1974
- if (value instanceof Uint8Array) {
1975
- return value;
1976
- }
1977
- if (ArrayBuffer.isView(value) && Object.prototype.toString.call(value) === "[object Uint8Array]") {
1978
- return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
1979
- }
1980
- return null;
1981
- }
1982
- function normalizeInput(input) {
1983
- if (typeof input === "string") {
1984
- return input;
1985
- }
1986
- const bytes = asBytes(input);
1987
- if (bytes !== null) {
1988
- return bytes;
1989
- }
1990
- if (isImportInput(input)) {
1991
- return input;
1992
- }
1993
- const tag = Object.prototype.toString.call(input).slice(8, -1);
1994
- let found = input === null ? "null" : typeof input;
1995
- let fix = "";
1996
- if (tag === "ArrayBuffer" || tag === "SharedArrayBuffer") {
1997
- found = `an ${tag}`;
1998
- fix = "; wrap it as new Uint8Array(buffer)";
1999
- } else if (ArrayBuffer.isView(input)) {
2000
- found = `a ${tag}`;
2001
- fix = "; pass new Uint8Array(view.buffer, view.byteOffset, view.byteLength)";
2002
- } else if (typeof input === "object" && input !== null) {
2003
- const object = input;
2004
- if (typeof object.stream === "function" && typeof object.size === "number") {
2005
- found = "a Blob or File";
2006
- fix = "; pass blob.stream()";
2007
- } else if ("body" in object && typeof object.arrayBuffer === "function") {
2008
- found = "a fetch Response";
2009
- fix = "; pass response.body";
2010
- } else {
2011
- found = `an object (${tag})`;
2012
- }
2013
- }
2014
- throw new GraphFormatError(
2015
- "E_UNSUPPORTED",
2016
- `the input is ${found}; an importer reads a string, a Uint8Array, a ReadableStream or an async iterable of strings and Uint8Arrays${fix}`,
2017
- { reason: "input type", found }
2018
- );
2019
- }
2020
- function inputLength(input) {
2021
- if (typeof input === "string") {
2022
- return input.length;
2023
- }
2024
- if (input instanceof Uint8Array) {
2025
- return input.byteLength;
2026
- }
2027
- return null;
2028
- }
2029
- function utf8Length(text) {
2030
- let bytes = 0;
2031
- let i = 0;
2032
- while (i < text.length) {
2033
- const c = text.charCodeAt(i);
2034
- const pair = c >= 55296 && c <= 56319 && (text.charCodeAt(i + 1) & 64512) === 56320;
2035
- if (c < 128) {
2036
- bytes++;
2037
- } else if (c < 2048) {
2038
- bytes += 2;
2039
- } else {
2040
- bytes += pair ? 4 : 3;
2041
- }
2042
- i += pair ? 2 : 1;
2043
- }
2044
- return bytes;
2045
- }
2046
- function throwIfAborted(signal) {
2047
- if (!signal?.aborted) {
2048
- return;
2049
- }
2050
- const { reason } = signal;
2051
- if (reason === void 0) {
2052
- throw abortError();
2053
- }
2054
- throw reason;
2055
- }
2056
- function abortError() {
2057
- const message = "The import was aborted";
2058
- if (typeof DOMException === "function") {
2059
- return new DOMException(message, "AbortError");
2060
- }
2061
- const err = new Error(message);
2062
- err.name = "AbortError";
2063
- return err;
2064
- }
2065
- function abortable(promise, signal) {
2066
- if (signal === null || typeof signal.addEventListener !== "function") {
2067
- return promise;
2068
- }
2069
- return new Promise((resolve, reject) => {
2070
- const onAbort = () => {
2071
- try {
2072
- throwIfAborted(signal);
2073
- } catch (err) {
2074
- reject(err);
2075
- }
2076
- };
2077
- signal.addEventListener("abort", onAbort, { once: true });
2078
- promise.then(
2079
- (value) => {
2080
- signal.removeEventListener("abort", onAbort);
2081
- resolve(value);
2082
- },
2083
- (err) => {
2084
- signal.removeEventListener("abort", onAbort);
2085
- reject(err);
2086
- }
2087
- );
2088
- });
2089
- }
2090
- function lockReader(stream) {
2091
- if (stream.locked) {
2092
- throw new GraphFormatError(
2093
- "E_UNSUPPORTED",
2094
- "the input ReadableStream is locked: another reader holds it (release it, or pass a fresh stream)",
2095
- { reason: "stream locked" }
2096
- );
2097
- }
2098
- return stream.getReader();
2099
- }
2100
- class TextFilter {
2101
- /**
2102
- * Create the filter of one import.
2103
- * @param report - where the warnings and the fatal errors go
2104
- * @param options - whether an empty input is valid, whether the format is XML
2105
- */
2106
- constructor(report, options) {
2107
- this.report = report;
2108
- this.options = options;
2109
- this.first = true;
2110
- this.content = false;
2111
- this.heldSub = false;
2112
- this.warned = false;
2113
- this.strayBom = false;
2114
- }
2115
- /**
2116
- * Filter the next decoded text.
2117
- * @param chunk - the text
2118
- * @returns the text to hand on
2119
- */
2120
- push(chunk) {
2121
- let text = this.heldSub ? SUB + chunk : chunk;
2122
- this.heldSub = false;
2123
- if (text.length === 0) {
2124
- return text;
2125
- }
2126
- if (this.first) {
2127
- text = this.skipByteOrderMarks(text);
2128
- if (text.length === 0) {
2129
- return text;
2130
- }
2131
- this.first = false;
2132
- refuseForeign(text, this.report, this.options);
2133
- }
2134
- if (text.endsWith(SUB)) {
2135
- this.heldSub = true;
2136
- text = text.slice(0, -1);
2137
- }
2138
- if (!this.content && /\S/.test(text)) {
2139
- this.content = true;
2140
- }
2141
- if (!this.warned) {
2142
- this.warnControl(text);
2143
- }
2144
- return text;
2145
- }
2146
- /**
2147
- * Drop the byte order marks the input starts with, warning when there is more than one.
2148
- * @param text - the first text
2149
- * @returns the text without them
2150
- */
2151
- skipByteOrderMarks(text) {
2152
- let start = 0;
2153
- while (text.codePointAt(start) === 65279) {
2154
- start++;
2155
- }
2156
- if (start > 1 && !this.strayBom) {
2157
- this.strayBom = true;
2158
- this.report.warning(
2159
- "validation-error",
2160
- CONTROL_CHARACTER_CODE,
2161
- `the input starts with ${start} byte order marks (U+FEFF); the extra ones were ignored`,
2162
- { element: "U+FEFF" }
2163
- );
2164
- }
2165
- return text.slice(start);
2166
- }
2167
- /**
2168
- * Warn, once, about the first control character the text holds.
2169
- * @param text - the text
2170
- */
2171
- warnControl(text) {
2172
- const match = CONTROL_CHARACTER.exec(text);
2173
- if (match === null) {
2174
- return;
2175
- }
2176
- this.warned = true;
2177
- const code = (match[0].codePointAt(0) ?? 0).toString(16).toUpperCase().padStart(4, "0");
2178
- const around = JSON.stringify(text.slice(Math.max(0, match.index - 20), match.index + 20));
2179
- this.report.warning(
2180
- "validation-error",
2181
- CONTROL_CHARACTER_CODE,
2182
- `the input holds the control character U+${code} (in ${around}); it is kept in the id or value it is part of`,
2183
- { element: `U+${code}` }
2184
- );
2185
- }
2186
- /** The input ended: drop a held Ctrl-Z with a warning, and refuse an input without content. */
2187
- end() {
2188
- if (this.heldSub) {
2189
- this.report.warning(
2190
- "validation-error",
2191
- CONTROL_CHARACTER_CODE,
2192
- "the input ends with a Ctrl-Z (0x1A), the DOS end-of-file marker; it was ignored",
2193
- { element: "U+001A" }
2194
- );
2195
- }
2196
- if (!this.content && this.options.allowEmpty !== true) {
2197
- this.report.fail(EMPTY_INPUT_CODE, this.first ? "the input is empty" : "the input holds only whitespace");
2198
- }
2199
- }
2200
- }
2201
- function reportTextEncoding(report, encoding) {
2202
- if (encoding !== null && encoding !== void 0) {
2203
- report.warning(
2204
- "unsupported",
2205
- OPTION_IGNORED_CODE,
2206
- "option encoding has no effect on text input, which is already decoded",
2207
- { element: "encoding" }
2208
- );
2209
- }
2210
- }
2211
- async function* textChunks(rawInput, report, options = {}) {
2212
- const input = normalizeInput(rawInput);
2213
- const signal = options.signal ?? null;
2214
- const filter = new TextFilter(report, options);
2215
- throwIfAborted(signal);
2216
- if (typeof input === "string") {
2217
- reportTextEncoding(report, options.encoding);
2218
- yield* stringTextChunks(input, filter, options);
2219
- return;
2220
- }
2221
- const decoder = new ByteDecoder(report, options);
2222
- if (input instanceof Uint8Array) {
2223
- yield* byteTextChunks(input, filter, decoder, options);
2224
- return;
2225
- }
2226
- const stream = new StreamText(filter, decoder, options);
2227
- for await (const chunk of isReadableStream(input) ? streamChunks(input, signal) : input) {
2228
- throwIfAborted(signal);
2229
- const text = stream.push(chunk);
2230
- if (text.length > 0) {
2231
- yield text;
2232
- }
2233
- options.onProgress?.(stream.done);
2234
- }
2235
- const tail = stream.end();
2236
- if (tail.length > 0) {
2237
- yield tail;
2238
- }
2239
- filter.end();
2240
- options.onProgress?.(stream.done, stream.done);
2241
- }
2242
- function stringSliceEnd(input, start) {
2243
- const end = Math.min(start + DECODE_SLICE, input.length);
2244
- const highSurrogate = (input.charCodeAt(end - 1) & 64512) === 55296;
2245
- return end < input.length && highSurrogate ? end + 1 : end;
2246
- }
2247
- function* stringTextChunks(input, filter, options) {
2248
- const signal = options.signal ?? null;
2249
- const onProgress = options.onProgress ?? null;
2250
- const total = onProgress === null ? 0 : utf8Length(input);
2251
- let done = 0;
2252
- let start = 0;
2253
- while (start < input.length) {
2254
- throwIfAborted(signal);
2255
- const end = stringSliceEnd(input, start);
2256
- const piece = start === 0 && end === input.length ? input : input.slice(start, end);
2257
- start = end;
2258
- const text = filter.push(piece);
2259
- if (text.length > 0) {
2260
- yield text;
2261
- }
2262
- if (onProgress !== null) {
2263
- done += utf8Length(piece);
2264
- onProgress(done, total);
2265
- }
2266
- }
2267
- if (input.length === 0) {
2268
- onProgress?.(0, 0);
2269
- }
2270
- filter.end();
2271
- }
2272
- function* byteTextChunks(input, filter, decoder, options) {
2273
- const signal = options.signal ?? null;
2274
- const length = input.byteLength;
2275
- decoder.start(input.subarray(0, headByteCount(options)));
2276
- for (let offset = 0; offset < length; offset += DECODE_SLICE) {
2277
- throwIfAborted(signal);
2278
- if (input.byteLength !== length) {
2279
- throw new GraphFormatError(
2280
- "E_UNSUPPORTED",
2281
- "the input's buffer was detached (transferred) or resized during the import",
2282
- { reason: "detached" }
2283
- );
2284
- }
2285
- const slice = input.subarray(offset, Math.min(offset + DECODE_SLICE, length));
2286
- const text = filter.push(decoder.decode(slice, offset + DECODE_SLICE < length));
2287
- if (text.length > 0) {
2288
- yield text;
2289
- }
2290
- options.onProgress?.(Math.min(offset + DECODE_SLICE, length), length);
2291
- }
2292
- if (length === 0) {
2293
- options.onProgress?.(0, 0);
2294
- }
2295
- filter.end();
2296
- }
2297
- function headByteCount(options) {
2298
- return Math.max(options.declarationBytes ?? HEAD_BYTES, BOM_BYTES);
2299
- }
2300
- class StreamText {
2301
- /**
2302
- * Create the reader of one stream input.
2303
- * @param filter - the text checks
2304
- * @param decoder - the byte decoder
2305
- * @param options - progress, the declaration reader and its size
2306
- */
2307
- constructor(filter, decoder, options) {
2308
- this.filter = filter;
2309
- this.decoder = decoder;
2310
- this.done = 0;
2311
- this.head = [];
2312
- this.headLength = 0;
2313
- this.headBytes = headByteCount(options);
2314
- this.needed = options.declaredEncoding === void 0 ? BOM_BYTES : this.headBytes;
2315
- this.counting = (options.onProgress ?? null) !== null;
2316
- }
2317
- /**
2318
- * Read the next chunk.
2319
- * @param chunk - a string or a Uint8Array (anything else is E_UNSUPPORTED)
2320
- * @returns its filtered text; empty while bytes are held back
2321
- */
2322
- push(chunk) {
2323
- if (typeof chunk === "string") {
2324
- this.done += this.counting ? utf8Length(chunk) : 0;
2325
- return this.filter.push(this.beforeText() + chunk);
2326
- }
2327
- const bytes = asBytes(chunk);
2328
- if (bytes === null) {
2329
- throw new GraphFormatError("E_UNSUPPORTED", "an input chunk must be a string or a Uint8Array", {
2330
- reason: "chunk type",
2331
- found: typeof chunk
2332
- });
2333
- }
2334
- this.done += bytes.byteLength;
2335
- if (this.decoder.started) {
2336
- return this.filter.push(this.decoder.decode(bytes, true));
2337
- }
2338
- this.head.push(bytes);
2339
- this.headLength += bytes.byteLength;
2340
- return this.headLength >= this.needed ? this.filter.push(this.flushHead(true)) : "";
2341
- }
2342
- /**
2343
- * The input ended: the filtered text of whatever is still held or pending.
2344
- * @returns the text
2345
- */
2346
- end() {
2347
- let tail = "";
2348
- if (this.headLength > 0) {
2349
- tail = this.flushHead(false);
2350
- } else if (this.decoder.started) {
2351
- tail = this.decoder.decode(new Uint8Array(0), false);
2352
- }
2353
- return this.filter.push(tail);
2354
- }
2355
- /**
2356
- * Start the decoder on the held bytes and decode them.
2357
- * @param stream - whether more bytes follow
2358
- * @returns their text
2359
- */
2360
- flushHead(stream) {
2361
- const bytes = concatBytes(this.head);
2362
- this.head = [];
2363
- this.headLength = 0;
2364
- this.decoder.start(bytes.subarray(0, this.headBytes));
2365
- return this.decoder.decode(bytes, stream);
2366
- }
2367
- /**
2368
- * A text chunk follows: finish any byte sequence still pending in the decoder before switching
2369
- * to text. The BOM and declaration checks apply to the start of the input only, so bytes after
2370
- * text are never taken for a BOM.
2371
- * @returns the text of the pending bytes
2372
- */
2373
- beforeText() {
2374
- if (this.headLength > 0) {
2375
- return this.decoder.flushBeforeText(() => this.flushHead(false));
2376
- }
2377
- if (this.decoder.started) {
2378
- return this.decoder.flushBeforeText(() => this.decoder.decode(new Uint8Array(0), false));
2379
- }
2380
- this.decoder.start(new Uint8Array(0));
2381
- return "";
2382
- }
2383
- }
2384
- function isReadableStream(input) {
2385
- return typeof input.getReader === "function";
2386
- }
2387
- async function* streamChunks(stream, signal) {
2388
- const reader = lockReader(stream);
2389
- let finished = false;
2390
- try {
2391
- for (; ; ) {
2392
- throwIfAborted(signal);
2393
- const { done, value } = await abortable(reader.read(), signal);
2394
- if (done) {
2395
- finished = true;
2396
- return;
2397
- }
2398
- yield value;
2399
- }
2400
- } finally {
2401
- if (!finished) {
2402
- await reader.cancel(signal?.reason).catch(() => void 0);
2403
- }
2404
- reader.releaseLock();
2405
- }
2406
- }
2407
- async function readBytes(rawInput, options = {}) {
2408
- const input = normalizeInput(rawInput);
2409
- const signal = options.signal ?? null;
2410
- throwIfAborted(signal);
2411
- if (typeof input === "string") {
2412
- return null;
2413
- }
2414
- if (input instanceof Uint8Array) {
2415
- options.onProgress?.(input.byteLength, input.byteLength);
2416
- return input;
2417
- }
2418
- const parts = [];
2419
- let done = 0;
2420
- for await (const chunk of isReadableStream(input) ? streamChunks(input, signal) : input) {
2421
- throwIfAborted(signal);
2422
- if (typeof chunk === "string") {
2423
- return null;
2424
- }
2425
- const bytes = asBytes(chunk);
2426
- if (bytes === null) {
2427
- throw new GraphFormatError("E_UNSUPPORTED", "an input chunk must be a string or a Uint8Array", {
2428
- reason: "chunk type",
2429
- found: typeof chunk
2430
- });
2431
- }
2432
- parts.push(bytes);
2433
- done += bytes.byteLength;
2434
- options.onProgress?.(done);
2435
- }
2436
- options.onProgress?.(done, done);
2437
- return parts.length === 0 ? new Uint8Array(0) : concatBytes(parts);
2438
- }
2439
- function tooLarge(report, message, line) {
2440
- report.failWith("unsupported", TOO_LARGE_CODE, message, line === void 0 ? void 0 : { line });
2441
- }
2442
- async function readText(rawInput, report, options = {}) {
2443
- const input = normalizeInput(rawInput);
2444
- if (typeof input === "string") {
2445
- throwIfAborted(options.signal);
2446
- reportTextEncoding(report, options.encoding);
2447
- const filter = new TextFilter(report, options);
2448
- const text = filter.push(input);
2449
- filter.end();
2450
- if (options.onProgress !== null && options.onProgress !== void 0) {
2451
- const total = utf8Length(input);
2452
- options.onProgress(total, total);
2453
- }
2454
- return text;
2455
- }
2456
- const parts = [];
2457
- let length = 0;
2458
- for await (const chunk of textChunks(input, report, options)) {
2459
- length += chunk.length;
2460
- if (length > MAX_TEXT_LENGTH) {
2461
- tooLarge(
2462
- report,
2463
- `the document is longer than ${MAX_TEXT_LENGTH} characters, the most one JavaScript string holds`
2464
- );
2465
- }
2466
- parts.push(chunk);
2467
- }
2468
- return parts.length === 1 ? parts[0] : parts.join("");
2469
- }
2470
- class LineReader {
2471
- /**
2472
- * Create a reader over an input; nothing is read until iteration starts.
2473
- * @param input - the input
2474
- * @param report - the report decode errors are recorded in
2475
- * @param options - cancellation and progress
2476
- */
2477
- constructor(input, report, options = {}) {
2478
- this.lineNumber = 0;
2479
- this.input = input;
2480
- this.report = report;
2481
- this.options = options;
2482
- }
2483
- /**
2484
- * The 1-based number of the line most recently yielded.
2485
- * @returns the line number; 0 before the first line
2486
- */
2487
- get line() {
2488
- return this.lineNumber;
2489
- }
2490
- /**
2491
- * The E_TOO_LARGE message of a line longer than one string.
2492
- * @returns the message
2493
- */
2494
- lineTooLong() {
2495
- return `a line is longer than ${MAX_TEXT_LENGTH} characters, the most one JavaScript string holds`;
2496
- }
2497
- /**
2498
- * Iterate the lines.
2499
- * @yields one line at a time, terminator removed
2500
- * @returns nothing
2501
- */
2502
- async *[Symbol.asyncIterator]() {
2503
- const pending = new PendingLine((line) => tooLarge(this.report, this.lineTooLong(), line));
2504
- let trailingCr = false;
2505
- for await (const chunk of textChunks(this.input, this.report, this.options)) {
2506
- let start = 0;
2507
- if (trailingCr) {
2508
- trailingCr = false;
2509
- this.lineNumber++;
2510
- yield pending.take().slice(0, -1);
2511
- if (chunk.charCodeAt(0) === 10) {
2512
- start = 1;
2513
- }
2514
- }
2515
- const breaks = new LineBreaks(chunk, start);
2516
- while (breaks.advance()) {
2517
- this.lineNumber++;
2518
- yield pending.finish(chunk.slice(start, breaks.cut), this.lineNumber);
2519
- start = breaks.next;
2520
- }
2521
- if (start < chunk.length) {
2522
- pending.appendRest(chunk, start, this.lineNumber + 1);
2523
- trailingCr = chunk.codePointAt(chunk.length - 1) === 13;
2524
- }
2525
- }
2526
- if (!pending.empty) {
2527
- this.lineNumber++;
2528
- const joined = pending.take();
2529
- yield joined.endsWith("\r") ? joined.slice(0, -1) : joined;
2530
- }
2531
- }
2532
- }
2533
- class PendingLine {
2534
- /**
2535
- * Start an empty line.
2536
- * @param tooLong - fails the import when the line grows longer than one string can hold
2537
- */
2538
- constructor(tooLong) {
2539
- this.pieces = [];
2540
- this.length = 0;
2541
- this.tooLong = tooLong;
2542
- }
2543
- /**
2544
- * Whether no piece is held.
2545
- * @returns true when the line in progress is empty
2546
- */
2547
- get empty() {
2548
- return this.pieces.length === 0;
2549
- }
2550
- /**
2551
- * Hold the rest of a chunk from `start`: the line goes on in the next chunk.
2552
- * @param chunk - the chunk
2553
- * @param start - where the unfinished line starts in it
2554
- * @param line - the 1-based number of the line, for the too-long error
2555
- */
2556
- appendRest(chunk, start, line) {
2557
- this.append(start === 0 ? chunk : chunk.slice(start), line);
2558
- }
2559
- /**
2560
- * End the line with its last piece.
2561
- * @param piece - the text from the start of the chunk (or the last break) to the line break
2562
- * @param line - the 1-based number of the line, for the too-long error
2563
- * @returns the whole line
2564
- */
2565
- finish(piece, line) {
2566
- if (this.pieces.length === 0) {
2567
- return piece;
2568
- }
2569
- this.append(piece, line);
2570
- return this.take();
2571
- }
2572
- /**
2573
- * Join the held pieces and start a new line.
2574
- * @returns the joined text
2575
- */
2576
- take() {
2577
- const joined = this.pieces.join("");
2578
- this.pieces.length = 0;
2579
- this.length = 0;
2580
- return joined;
2581
- }
2582
- /**
2583
- * Hold one more piece.
2584
- * @param piece - the piece
2585
- * @param line - the 1-based number of the line, for the too-long error
2586
- */
2587
- append(piece, line) {
2588
- this.length += piece.length;
2589
- if (this.length > MAX_TEXT_LENGTH) {
2590
- this.tooLong(line);
2591
- }
2592
- this.pieces.push(piece);
2593
- }
2594
- }
2595
- class LineBreaks {
2596
- /**
2597
- * Scan a chunk from a position.
2598
- * @param chunk - the chunk
2599
- * @param start - where scanning starts
2600
- */
2601
- constructor(chunk, start) {
2602
- this.cut = 0;
2603
- this.chunk = chunk;
2604
- this.next = start;
2605
- this.nl = chunk.indexOf("\n", start);
2606
- this.cr = chunk.indexOf("\r", start);
2607
- }
2608
- /**
2609
- * Find the next line break.
2610
- * @returns false when none is left, or the only one left is a trailing `\r` (it may be the first
2611
- * half of a `\r\n` split across chunks)
2612
- */
2613
- advance() {
2614
- const { chunk, next } = this;
2615
- if (this.nl >= 0 && this.nl < next) {
2616
- this.nl = chunk.indexOf("\n", next);
2617
- }
2618
- if (this.cr >= 0 && this.cr < next) {
2619
- this.cr = chunk.indexOf("\r", next);
2620
- }
2621
- const { nl, cr } = this;
2622
- if (cr >= 0 && (nl < 0 || cr < nl)) {
2623
- if (cr === chunk.length - 1) {
2624
- return false;
2625
- }
2626
- this.cut = cr;
2627
- this.next = chunk.codePointAt(cr + 1) === 10 ? cr + 2 : cr + 1;
2628
- return true;
2629
- }
2630
- if (nl < 0) {
2631
- return false;
2632
- }
2633
- this.cut = nl;
2634
- this.next = nl + 1;
2635
- return true;
2636
- }
2637
- }
2638
1263
  const ID_COERCIONS = /* @__PURE__ */ new Set(["keep", "canonical", "string", "number"]);
2639
1264
  const NODE_ID_SOURCES = /* @__PURE__ */ new Set(["id", "label", "index"]);
2640
1265
  const DUPLICATE_POLICIES = /* @__PURE__ */ new Set(["keep", "error", "first", "last", "sum", "min", "max"]);
@@ -3856,81 +2481,66 @@ function mangleNmtoken(text) {
3856
2481
  return out.length === 0 ? "_" : out;
3857
2482
  }
3858
2483
  export {
3859
- PAIR_COLUMN as $,
3860
- losesPrecision as A,
3861
- parseTimeText as B,
3862
- splitListText as C,
2484
+ MUTUAL_COLUMN as $,
2485
+ timeTextCompanion as A,
2486
+ parseDecimalText as B,
2487
+ sanitizeIds as C,
3863
2488
  DictHeuristic as D,
3864
- timeTextCompanion as E,
3865
- parseDecimalText as F,
3866
- sanitizeIds as G,
3867
- formatTimeValue as H,
2489
+ formatTimeValue as E,
2490
+ mapDeclaredType as F,
2491
+ joinListText as G,
2492
+ formatTemporal as H,
3868
2493
  IdCoercer as I,
3869
- mapDeclaredType as J,
3870
- joinListText as K,
2494
+ isCanonicalIntegerText as J,
2495
+ declareOn as K,
3871
2496
  LOSS as L,
3872
- MAX_TEXT_LENGTH as M,
3873
- formatTemporal as N,
3874
- isCanonicalIntegerText as O,
3875
- LineReader as P,
3876
- describe as Q,
2497
+ takenIn as M,
2498
+ parseTemporal as N,
2499
+ canonicalId as O,
2500
+ coerceIdText as P,
2501
+ DICT_SAMPLE_ROWS as Q,
3877
2502
  RENAMED_CODE as R,
3878
- normalizeInput as S,
2503
+ otherFormatDialect as S,
3879
2504
  TIME_TEXT_ROLE as T,
3880
- foreignKind as U,
3881
- lockReader as V,
3882
- abortable as W,
3883
- DEFAULT_ERROR_LIMIT as X,
3884
- DIRECTED_COLUMN as Y,
3885
- MUTUAL_COLUMN as Z,
3886
- NO_CAPABILITIES as _,
2505
+ countMixedEdges as U,
2506
+ reportWeightPrecision as V,
2507
+ isNmtoken as W,
2508
+ mangleNmtoken as X,
2509
+ describe as Y,
2510
+ DEFAULT_ERROR_LIMIT as Z,
2511
+ DIRECTED_COLUMN as _,
3887
2512
  checkCapabilities as a,
3888
- UNKNOWN_TYPE_CODE as a0,
3889
- canonicalId as a1,
3890
- coerceId as a2,
3891
- coerceIdText as a3,
3892
- decodeEntryName as a4,
3893
- edgeWeights as a5,
3894
- forDecodedText as a6,
3895
- inputLength as a7,
3896
- isImportInput as a8,
3897
- isNmtoken as a9,
3898
- mangleNmtoken as aa,
3899
- readText as ab,
3900
- refusedSave as ac,
3901
- declareOn as ad,
3902
- takenIn as ae,
3903
- parseTemporal as af,
3904
- DICT_SAMPLE_ROWS as ag,
3905
- otherFormatDialect as ah,
3906
- countMixedEdges as ai,
3907
- canonicalEncoding as aj,
3908
- reportWeightPrecision as ak,
3909
- readBytes as al,
3910
- tooLarge as b,
2513
+ NO_CAPABILITIES as a0,
2514
+ PAIR_COLUMN as a1,
2515
+ UNKNOWN_TYPE_CODE as a2,
2516
+ coerceId as a3,
2517
+ edgeWeights as a4,
2518
+ forDecodedText as a5,
2519
+ refusedSave as a6,
2520
+ chooseGraph as b,
3911
2521
  capabilities as c,
3912
- declareResolved as d,
2522
+ resolveImportOptions as d,
3913
2523
  explicitWeights as e,
3914
- chooseGraph as f,
3915
- resolveImportOptions as g,
3916
- throwIfAborted as h,
3917
- reportUnusedOptions as i,
3918
- reportSinkOptions as j,
3919
- graphChosen as k,
3920
- DirectionResolver as l,
3921
- TIME_TEXT_SUFFIX as m,
3922
- isNameChar as n,
3923
- isWeightField as o,
2524
+ reportUnusedOptions as f,
2525
+ reportSinkOptions as g,
2526
+ graphChosen as h,
2527
+ DirectionResolver as i,
2528
+ declareResolved as j,
2529
+ TIME_TEXT_SUFFIX as k,
2530
+ isNameChar as l,
2531
+ isWeightField as m,
2532
+ declareAttribute as n,
2533
+ parseWeightText as o,
3924
2534
  pairFolding as p,
3925
- declareAttribute as q,
2535
+ overflowsToInfinity as q,
3926
2536
  resolveExportOptions as r,
3927
- parseWeightText as s,
3928
- textChunks as t,
2537
+ parseDeclaredTemporal as s,
2538
+ declareCompanion as t,
3929
2539
  uniqueColumnName as u,
3930
- overflowsToInfinity as v,
2540
+ parseDeclaredValue as v,
3931
2541
  weightFromValue as w,
3932
- parseDeclaredTemporal as x,
3933
- declareCompanion as y,
3934
- parseDeclaredValue as z
2542
+ losesPrecision as x,
2543
+ parseTimeText as y,
2544
+ splitListText as z
3935
2545
  };
3936
- //# sourceMappingURL=export-BvqAXCKh.js.map
2546
+ //# sourceMappingURL=export-CZ7VRm4I.js.map