@graphty/graph-io 0.0.0 → 0.2.0

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 (339) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +250 -28
  3. package/dist/chunks/children-CL3Cy0ez.js +238 -0
  4. package/dist/chunks/children-CL3Cy0ez.js.map +1 -0
  5. package/dist/chunks/escape-DyI8JofU.js +938 -0
  6. package/dist/chunks/escape-DyI8JofU.js.map +1 -0
  7. package/dist/chunks/importer-CQnJuWJw.js +2987 -0
  8. package/dist/chunks/importer-CQnJuWJw.js.map +1 -0
  9. package/dist/chunks/importer-CpCpfbxr.js +2015 -0
  10. package/dist/chunks/importer-CpCpfbxr.js.map +1 -0
  11. package/dist/chunks/importer-DbnGYr3_.js +2342 -0
  12. package/dist/chunks/importer-DbnGYr3_.js.map +1 -0
  13. package/dist/chunks/importer-GozH8DkN.js +3050 -0
  14. package/dist/chunks/importer-GozH8DkN.js.map +1 -0
  15. package/dist/chunks/records-CGpxszm1.js +605 -0
  16. package/dist/chunks/records-CGpxszm1.js.map +1 -0
  17. package/dist/chunks/text-CajMdVFy.js +189 -0
  18. package/dist/chunks/text-CajMdVFy.js.map +1 -0
  19. package/dist/chunks/writer-DxSKC7TL.js +2842 -0
  20. package/dist/chunks/writer-DxSKC7TL.js.map +1 -0
  21. package/dist/csv.d.ts +1 -0
  22. package/dist/csv.js +1702 -0
  23. package/dist/csv.js.map +1 -0
  24. package/dist/dot.d.ts +1 -0
  25. package/dist/dot.js +8 -0
  26. package/dist/dot.js.map +1 -0
  27. package/dist/gexf.d.ts +1 -0
  28. package/dist/gexf.js +3466 -0
  29. package/dist/gexf.js.map +1 -0
  30. package/dist/gml.d.ts +1 -0
  31. package/dist/gml.js +2647 -0
  32. package/dist/gml.js.map +1 -0
  33. package/dist/graph-io.d.ts +1 -0
  34. package/dist/graph-io.js +790 -0
  35. package/dist/graph-io.js.map +1 -0
  36. package/dist/graphml.d.ts +1 -0
  37. package/dist/graphml.js +8 -0
  38. package/dist/graphml.js.map +1 -0
  39. package/dist/json.d.ts +1 -0
  40. package/dist/json.js +11 -0
  41. package/dist/json.js.map +1 -0
  42. package/dist/neo4j.d.ts +1 -0
  43. package/dist/neo4j.js +2046 -0
  44. package/dist/neo4j.js.map +1 -0
  45. package/dist/pajek.d.ts +1 -0
  46. package/dist/pajek.js +8 -0
  47. package/dist/pajek.js.map +1 -0
  48. package/dist/src/children.d.ts +134 -0
  49. package/dist/src/children.d.ts.map +1 -0
  50. package/dist/src/children.js +274 -0
  51. package/dist/src/children.js.map +1 -0
  52. package/dist/src/common/attributes.d.ts +229 -0
  53. package/dist/src/common/attributes.d.ts.map +1 -0
  54. package/dist/src/common/attributes.js +368 -0
  55. package/dist/src/common/attributes.js.map +1 -0
  56. package/dist/src/common/codes.d.ts +105 -0
  57. package/dist/src/common/codes.d.ts.map +1 -0
  58. package/dist/src/common/codes.js +107 -0
  59. package/dist/src/common/codes.js.map +1 -0
  60. package/dist/src/common/declared-types.d.ts +84 -0
  61. package/dist/src/common/declared-types.d.ts.map +1 -0
  62. package/dist/src/common/declared-types.js +326 -0
  63. package/dist/src/common/declared-types.js.map +1 -0
  64. package/dist/src/common/direction.d.ts +206 -0
  65. package/dist/src/common/direction.d.ts.map +1 -0
  66. package/dist/src/common/direction.js +370 -0
  67. package/dist/src/common/direction.js.map +1 -0
  68. package/dist/src/common/escape.d.ts +92 -0
  69. package/dist/src/common/escape.d.ts.map +1 -0
  70. package/dist/src/common/escape.js +212 -0
  71. package/dist/src/common/escape.js.map +1 -0
  72. package/dist/src/common/export.d.ts +249 -0
  73. package/dist/src/common/export.d.ts.map +1 -0
  74. package/dist/src/common/export.js +594 -0
  75. package/dist/src/common/export.js.map +1 -0
  76. package/dist/src/common/format.d.ts +59 -0
  77. package/dist/src/common/format.d.ts.map +1 -0
  78. package/dist/src/common/format.js +106 -0
  79. package/dist/src/common/format.js.map +1 -0
  80. package/dist/src/common/ids.d.ts +83 -0
  81. package/dist/src/common/ids.d.ts.map +1 -0
  82. package/dist/src/common/ids.js +158 -0
  83. package/dist/src/common/ids.js.map +1 -0
  84. package/dist/src/common/input.d.ts +100 -0
  85. package/dist/src/common/input.d.ts.map +1 -0
  86. package/dist/src/common/input.js +335 -0
  87. package/dist/src/common/input.js.map +1 -0
  88. package/dist/src/common/lists.d.ts +34 -0
  89. package/dist/src/common/lists.d.ts.map +1 -0
  90. package/dist/src/common/lists.js +185 -0
  91. package/dist/src/common/lists.js.map +1 -0
  92. package/dist/src/common/options.d.ts +108 -0
  93. package/dist/src/common/options.d.ts.map +1 -0
  94. package/dist/src/common/options.js +265 -0
  95. package/dist/src/common/options.js.map +1 -0
  96. package/dist/src/common/report.d.ts +187 -0
  97. package/dist/src/common/report.d.ts.map +1 -0
  98. package/dist/src/common/report.js +274 -0
  99. package/dist/src/common/report.js.map +1 -0
  100. package/dist/src/common/temporal.d.ts +71 -0
  101. package/dist/src/common/temporal.d.ts.map +1 -0
  102. package/dist/src/common/temporal.js +266 -0
  103. package/dist/src/common/temporal.js.map +1 -0
  104. package/dist/src/common/text.d.ts +104 -0
  105. package/dist/src/common/text.d.ts.map +1 -0
  106. package/dist/src/common/text.js +255 -0
  107. package/dist/src/common/text.js.map +1 -0
  108. package/dist/src/common/weights.d.ts +77 -0
  109. package/dist/src/common/weights.d.ts.map +1 -0
  110. package/dist/src/common/weights.js +156 -0
  111. package/dist/src/common/weights.js.map +1 -0
  112. package/dist/src/common/writer.d.ts +51 -0
  113. package/dist/src/common/writer.d.ts.map +1 -0
  114. package/dist/src/common/writer.js +108 -0
  115. package/dist/src/common/writer.js.map +1 -0
  116. package/dist/src/common/xml.d.ts +245 -0
  117. package/dist/src/common/xml.d.ts.map +1 -0
  118. package/dist/src/common/xml.js +942 -0
  119. package/dist/src/common/xml.js.map +1 -0
  120. package/dist/src/formats/csv/exporter.d.ts +70 -0
  121. package/dist/src/formats/csv/exporter.d.ts.map +1 -0
  122. package/dist/src/formats/csv/exporter.js +682 -0
  123. package/dist/src/formats/csv/exporter.js.map +1 -0
  124. package/dist/src/formats/csv/header.d.ts +66 -0
  125. package/dist/src/formats/csv/header.d.ts.map +1 -0
  126. package/dist/src/formats/csv/header.js +152 -0
  127. package/dist/src/formats/csv/header.js.map +1 -0
  128. package/dist/src/formats/csv/importer.d.ts +82 -0
  129. package/dist/src/formats/csv/importer.d.ts.map +1 -0
  130. package/dist/src/formats/csv/importer.js +849 -0
  131. package/dist/src/formats/csv/importer.js.map +1 -0
  132. package/dist/src/formats/csv/index.d.ts +60 -0
  133. package/dist/src/formats/csv/index.d.ts.map +1 -0
  134. package/dist/src/formats/csv/index.js +63 -0
  135. package/dist/src/formats/csv/index.js.map +1 -0
  136. package/dist/src/formats/csv/records.d.ts +188 -0
  137. package/dist/src/formats/csv/records.d.ts.map +1 -0
  138. package/dist/src/formats/csv/records.js +702 -0
  139. package/dist/src/formats/csv/records.js.map +1 -0
  140. package/dist/src/formats/csv/values.d.ts +105 -0
  141. package/dist/src/formats/csv/values.d.ts.map +1 -0
  142. package/dist/src/formats/csv/values.js +192 -0
  143. package/dist/src/formats/csv/values.js.map +1 -0
  144. package/dist/src/formats/dot/exporter.d.ts +52 -0
  145. package/dist/src/formats/dot/exporter.d.ts.map +1 -0
  146. package/dist/src/formats/dot/exporter.js +836 -0
  147. package/dist/src/formats/dot/exporter.js.map +1 -0
  148. package/dist/src/formats/dot/importer.d.ts +102 -0
  149. package/dist/src/formats/dot/importer.d.ts.map +1 -0
  150. package/dist/src/formats/dot/importer.js +1291 -0
  151. package/dist/src/formats/dot/importer.js.map +1 -0
  152. package/dist/src/formats/dot/index.d.ts +7 -0
  153. package/dist/src/formats/dot/index.d.ts.map +1 -0
  154. package/dist/src/formats/dot/index.js +7 -0
  155. package/dist/src/formats/dot/index.js.map +1 -0
  156. package/dist/src/formats/dot/names.d.ts +29 -0
  157. package/dist/src/formats/dot/names.d.ts.map +1 -0
  158. package/dist/src/formats/dot/names.js +28 -0
  159. package/dist/src/formats/dot/names.js.map +1 -0
  160. package/dist/src/formats/dot/tokenizer.d.ts +114 -0
  161. package/dist/src/formats/dot/tokenizer.d.ts.map +1 -0
  162. package/dist/src/formats/dot/tokenizer.js +341 -0
  163. package/dist/src/formats/dot/tokenizer.js.map +1 -0
  164. package/dist/src/formats/gexf/exporter.d.ts +56 -0
  165. package/dist/src/formats/gexf/exporter.d.ts.map +1 -0
  166. package/dist/src/formats/gexf/exporter.js +1395 -0
  167. package/dist/src/formats/gexf/exporter.js.map +1 -0
  168. package/dist/src/formats/gexf/importer.d.ts +73 -0
  169. package/dist/src/formats/gexf/importer.d.ts.map +1 -0
  170. package/dist/src/formats/gexf/importer.js +1880 -0
  171. package/dist/src/formats/gexf/importer.js.map +1 -0
  172. package/dist/src/formats/gexf/index.d.ts +96 -0
  173. package/dist/src/formats/gexf/index.d.ts.map +1 -0
  174. package/dist/src/formats/gexf/index.js +97 -0
  175. package/dist/src/formats/gexf/index.js.map +1 -0
  176. package/dist/src/formats/gexf/schema.d.ts +135 -0
  177. package/dist/src/formats/gexf/schema.d.ts.map +1 -0
  178. package/dist/src/formats/gexf/schema.js +323 -0
  179. package/dist/src/formats/gexf/schema.js.map +1 -0
  180. package/dist/src/formats/gml/exporter.d.ts +69 -0
  181. package/dist/src/formats/gml/exporter.d.ts.map +1 -0
  182. package/dist/src/formats/gml/exporter.js +1093 -0
  183. package/dist/src/formats/gml/exporter.js.map +1 -0
  184. package/dist/src/formats/gml/importer.d.ts +66 -0
  185. package/dist/src/formats/gml/importer.d.ts.map +1 -0
  186. package/dist/src/formats/gml/importer.js +1331 -0
  187. package/dist/src/formats/gml/importer.js.map +1 -0
  188. package/dist/src/formats/gml/index.d.ts +85 -0
  189. package/dist/src/formats/gml/index.d.ts.map +1 -0
  190. package/dist/src/formats/gml/index.js +88 -0
  191. package/dist/src/formats/gml/index.js.map +1 -0
  192. package/dist/src/formats/gml/syntax.d.ts +186 -0
  193. package/dist/src/formats/gml/syntax.d.ts.map +1 -0
  194. package/dist/src/formats/gml/syntax.js +467 -0
  195. package/dist/src/formats/gml/syntax.js.map +1 -0
  196. package/dist/src/formats/graphml/constants.d.ts +169 -0
  197. package/dist/src/formats/graphml/constants.d.ts.map +1 -0
  198. package/dist/src/formats/graphml/constants.js +165 -0
  199. package/dist/src/formats/graphml/constants.js.map +1 -0
  200. package/dist/src/formats/graphml/exporter.d.ts +34 -0
  201. package/dist/src/formats/graphml/exporter.d.ts.map +1 -0
  202. package/dist/src/formats/graphml/exporter.js +1176 -0
  203. package/dist/src/formats/graphml/exporter.js.map +1 -0
  204. package/dist/src/formats/graphml/importer.d.ts +31 -0
  205. package/dist/src/formats/graphml/importer.d.ts.map +1 -0
  206. package/dist/src/formats/graphml/importer.js +1607 -0
  207. package/dist/src/formats/graphml/importer.js.map +1 -0
  208. package/dist/src/formats/graphml/index.d.ts +8 -0
  209. package/dist/src/formats/graphml/index.d.ts.map +1 -0
  210. package/dist/src/formats/graphml/index.js +8 -0
  211. package/dist/src/formats/graphml/index.js.map +1 -0
  212. package/dist/src/formats/graphml/tree.d.ts +72 -0
  213. package/dist/src/formats/graphml/tree.d.ts.map +1 -0
  214. package/dist/src/formats/graphml/tree.js +290 -0
  215. package/dist/src/formats/graphml/tree.js.map +1 -0
  216. package/dist/src/formats/json/dialect.d.ts +125 -0
  217. package/dist/src/formats/json/dialect.d.ts.map +1 -0
  218. package/dist/src/formats/json/dialect.js +262 -0
  219. package/dist/src/formats/json/dialect.js.map +1 -0
  220. package/dist/src/formats/json/exporter.d.ts +89 -0
  221. package/dist/src/formats/json/exporter.d.ts.map +1 -0
  222. package/dist/src/formats/json/exporter.js +1358 -0
  223. package/dist/src/formats/json/exporter.js.map +1 -0
  224. package/dist/src/formats/json/importer.d.ts +108 -0
  225. package/dist/src/formats/json/importer.d.ts.map +1 -0
  226. package/dist/src/formats/json/importer.js +1838 -0
  227. package/dist/src/formats/json/importer.js.map +1 -0
  228. package/dist/src/formats/json/index.d.ts +8 -0
  229. package/dist/src/formats/json/index.d.ts.map +1 -0
  230. package/dist/src/formats/json/index.js +8 -0
  231. package/dist/src/formats/json/index.js.map +1 -0
  232. package/dist/src/formats/neo4j/exporter.d.ts +68 -0
  233. package/dist/src/formats/neo4j/exporter.d.ts.map +1 -0
  234. package/dist/src/formats/neo4j/exporter.js +1055 -0
  235. package/dist/src/formats/neo4j/exporter.js.map +1 -0
  236. package/dist/src/formats/neo4j/header.d.ts +52 -0
  237. package/dist/src/formats/neo4j/header.d.ts.map +1 -0
  238. package/dist/src/formats/neo4j/header.js +131 -0
  239. package/dist/src/formats/neo4j/header.js.map +1 -0
  240. package/dist/src/formats/neo4j/importer.d.ts +73 -0
  241. package/dist/src/formats/neo4j/importer.d.ts.map +1 -0
  242. package/dist/src/formats/neo4j/importer.js +932 -0
  243. package/dist/src/formats/neo4j/importer.js.map +1 -0
  244. package/dist/src/formats/neo4j/index.d.ts +79 -0
  245. package/dist/src/formats/neo4j/index.d.ts.map +1 -0
  246. package/dist/src/formats/neo4j/index.js +83 -0
  247. package/dist/src/formats/neo4j/index.js.map +1 -0
  248. package/dist/src/formats/pajek/exporter.d.ts +58 -0
  249. package/dist/src/formats/pajek/exporter.d.ts.map +1 -0
  250. package/dist/src/formats/pajek/exporter.js +825 -0
  251. package/dist/src/formats/pajek/exporter.js.map +1 -0
  252. package/dist/src/formats/pajek/importer.d.ts +88 -0
  253. package/dist/src/formats/pajek/importer.d.ts.map +1 -0
  254. package/dist/src/formats/pajek/importer.js +1047 -0
  255. package/dist/src/formats/pajek/importer.js.map +1 -0
  256. package/dist/src/formats/pajek/index.d.ts +7 -0
  257. package/dist/src/formats/pajek/index.d.ts.map +1 -0
  258. package/dist/src/formats/pajek/index.js +7 -0
  259. package/dist/src/formats/pajek/index.js.map +1 -0
  260. package/dist/src/formats/pajek/syntax.d.ts +112 -0
  261. package/dist/src/formats/pajek/syntax.d.ts.map +1 -0
  262. package/dist/src/formats/pajek/syntax.js +269 -0
  263. package/dist/src/formats/pajek/syntax.js.map +1 -0
  264. package/dist/src/index.d.ts +35 -0
  265. package/dist/src/index.d.ts.map +1 -0
  266. package/dist/src/index.js +39 -0
  267. package/dist/src/index.js.map +1 -0
  268. package/dist/src/registry.d.ts +207 -0
  269. package/dist/src/registry.d.ts.map +1 -0
  270. package/dist/src/registry.js +481 -0
  271. package/dist/src/registry.js.map +1 -0
  272. package/dist/src/sniff.d.ts +104 -0
  273. package/dist/src/sniff.d.ts.map +1 -0
  274. package/dist/src/sniff.js +357 -0
  275. package/dist/src/sniff.js.map +1 -0
  276. package/dist/src/types.d.ts +238 -0
  277. package/dist/src/types.d.ts.map +1 -0
  278. package/dist/src/types.js +29 -0
  279. package/dist/src/types.js.map +1 -0
  280. package/dist/tsconfig.build.tsbuildinfo +1 -0
  281. package/package.json +122 -7
  282. package/src/children.ts +335 -0
  283. package/src/common/attributes.ts +520 -0
  284. package/src/common/codes.ts +153 -0
  285. package/src/common/declared-types.ts +374 -0
  286. package/src/common/direction.ts +518 -0
  287. package/src/common/escape.ts +231 -0
  288. package/src/common/export.ts +817 -0
  289. package/src/common/format.ts +111 -0
  290. package/src/common/ids.ts +176 -0
  291. package/src/common/input.ts +378 -0
  292. package/src/common/lists.ts +196 -0
  293. package/src/common/options.ts +377 -0
  294. package/src/common/report.ts +352 -0
  295. package/src/common/temporal.ts +302 -0
  296. package/src/common/text.ts +294 -0
  297. package/src/common/weights.ts +202 -0
  298. package/src/common/writer.ts +123 -0
  299. package/src/common/xml.ts +1053 -0
  300. package/src/formats/csv/exporter.ts +894 -0
  301. package/src/formats/csv/header.ts +172 -0
  302. package/src/formats/csv/importer.ts +1104 -0
  303. package/src/formats/csv/index.ts +88 -0
  304. package/src/formats/csv/records.ts +813 -0
  305. package/src/formats/csv/values.ts +224 -0
  306. package/src/formats/dot/exporter.ts +1014 -0
  307. package/src/formats/dot/importer.ts +1549 -0
  308. package/src/formats/dot/index.ts +7 -0
  309. package/src/formats/dot/names.ts +40 -0
  310. package/src/formats/dot/tokenizer.ts +384 -0
  311. package/src/formats/gexf/exporter.ts +1696 -0
  312. package/src/formats/gexf/importer.ts +2333 -0
  313. package/src/formats/gexf/index.ts +142 -0
  314. package/src/formats/gexf/schema.ts +361 -0
  315. package/src/formats/gml/exporter.ts +1404 -0
  316. package/src/formats/gml/importer.ts +1591 -0
  317. package/src/formats/gml/index.ts +128 -0
  318. package/src/formats/gml/syntax.ts +545 -0
  319. package/src/formats/graphml/constants.ts +225 -0
  320. package/src/formats/graphml/exporter.ts +1458 -0
  321. package/src/formats/graphml/importer.ts +2027 -0
  322. package/src/formats/graphml/index.ts +8 -0
  323. package/src/formats/graphml/tree.ts +318 -0
  324. package/src/formats/json/dialect.ts +317 -0
  325. package/src/formats/json/exporter.ts +1616 -0
  326. package/src/formats/json/importer.ts +2271 -0
  327. package/src/formats/json/index.ts +8 -0
  328. package/src/formats/neo4j/exporter.ts +1287 -0
  329. package/src/formats/neo4j/header.ts +156 -0
  330. package/src/formats/neo4j/importer.ts +1220 -0
  331. package/src/formats/neo4j/index.ts +116 -0
  332. package/src/formats/pajek/exporter.ts +1000 -0
  333. package/src/formats/pajek/importer.ts +1311 -0
  334. package/src/formats/pajek/index.ts +7 -0
  335. package/src/formats/pajek/syntax.ts +307 -0
  336. package/src/index.ts +244 -0
  337. package/src/registry.ts +617 -0
  338. package/src/sniff.ts +397 -0
  339. package/src/types.ts +262 -0
@@ -0,0 +1,467 @@
1
+ /**
2
+ * The GML lexical layer shared by the importer and the exporter (research note 07 section 2.2,
3
+ * NetworkX readwrite/gml.py as the reference reader): the token list a whole GML text lexes into,
4
+ * the structural validation that guarantees every later walk sees balanced `key value` pairs, the
5
+ * value grammar (int, real, quoted string with `&#NN;` character references, `[ ... ]` record),
6
+ * the NetworkX list conventions (`_networkx_list_start`, `"[]"`) and the key charset.
7
+ *
8
+ * Tokens are kept in typed arrays (kind, start, end, line, matching bracket) rather than objects:
9
+ * the token list is the one intermediate structure of the GML importer, and it costs 17 bytes per
10
+ * token instead of an object per node.
11
+ */
12
+ import { SYNTAX_CODE } from "../../common/codes.js";
13
+ import { decodeGmlString } from "../../common/escape.js";
14
+ /** A bare word: a key, or `INF` / `NAN` at a value position. */
15
+ export const TOKEN_WORD = 0;
16
+ /** An integer literal. */
17
+ export const TOKEN_INT = 1;
18
+ /** A real literal, including the non-finite spellings. */
19
+ export const TOKEN_REAL = 2;
20
+ /** A double-quoted string; start / end delimit the body between the quotes. */
21
+ export const TOKEN_STRING = 3;
22
+ /** `[`. */
23
+ export const TOKEN_OPEN = 4;
24
+ /** `]`. */
25
+ export const TOKEN_CLOSE = 5;
26
+ /** The NetworkX marker that starts a one-element list written as repeated keys. */
27
+ export const LIST_START_MARKER = "_networkx_list_start";
28
+ /** The string NetworkX writes for an empty list. */
29
+ export const EMPTY_LIST_TEXT = "[]";
30
+ /** The string NetworkX writes for an empty tuple, read as an empty list too. */
31
+ export const EMPTY_TUPLE_TEXT = "()";
32
+ /** The node key the exporter writes a mangled node's original id into (design section 8.5). */
33
+ export const ORIGINAL_ID_KEY = "graphty_originalId";
34
+ /**
35
+ * Issue code of every grammar violation (shared with the other text formats; the message carries
36
+ * the detail): a bare token that is neither a key nor a number, an unclosed string, an unclosed
37
+ * `[`, a `]` with no open `[`, a value without a key or a key without a value.
38
+ */
39
+ export const SYNTAX_STRUCTURE_CODE = SYNTAX_CODE;
40
+ /** The code of an untokenisable bare token (E_SYNTAX). */
41
+ export const SYNTAX_TOKEN_CODE = SYNTAX_CODE;
42
+ /** The code of an unclosed string (E_SYNTAX). */
43
+ export const SYNTAX_STRING_CODE = SYNTAX_CODE;
44
+ /** The code of an unclosed `[` (E_SYNTAX). */
45
+ export const SYNTAX_BRACKET_CODE = SYNTAX_CODE;
46
+ const KEY_TEXT = /^[A-Za-z_][0-9A-Za-z_]*$/;
47
+ const STRICT_KEY_TEXT = /^[A-Za-z][0-9A-Za-z_]*$/;
48
+ const INT_TEXT = /^[+-]?[0-9]+$/;
49
+ const REAL_TEXT = /^[+-]?(?:(?:[0-9]+\.[0-9]*|\.[0-9]+)(?:[eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)$/;
50
+ const NON_FINITE_TEXT = /^[+-]?(?:inf|infinity|nan)$/i;
51
+ const NON_FINITE_WORD = /^(?:inf|infinity|nan)$/i;
52
+ /**
53
+ * A lexical or structural error of a GML text, with the 1-based line it was found on. The importer
54
+ * turns it into a fatal parse-error issue.
55
+ */
56
+ export class GmlSyntaxError extends Error {
57
+ /**
58
+ * Create a syntax error.
59
+ * @param code - the issue code
60
+ * @param message - a plain-ASCII message
61
+ * @param line - the 1-based line
62
+ */
63
+ constructor(code, message, line) {
64
+ super(message);
65
+ this.name = "GmlSyntaxError";
66
+ this.code = code;
67
+ this.line = line;
68
+ }
69
+ }
70
+ /**
71
+ * The tokens of one GML text, structurally validated: every `[` has its matching `]` recorded and
72
+ * every key is followed by a value, so walkers need no error paths.
73
+ */
74
+ export class GmlTokens {
75
+ /**
76
+ * Create an empty token list over a text.
77
+ * @param text - the source text
78
+ * @param capacity - the initial capacity
79
+ */
80
+ constructor(text, capacity = 1024) {
81
+ /** The number of tokens. */
82
+ this.count = 0;
83
+ this.text = text;
84
+ this.kind = new Uint8Array(capacity);
85
+ this.start = new Uint32Array(capacity);
86
+ this.end = new Uint32Array(capacity);
87
+ this.line = new Uint32Array(capacity);
88
+ this.match = new Uint32Array(0);
89
+ }
90
+ /**
91
+ * Append a token.
92
+ * @param kind - the kind
93
+ * @param start - the start offset
94
+ * @param end - the end offset
95
+ * @param line - the 1-based line
96
+ */
97
+ push(kind, start, end, line) {
98
+ if (this.count === this.kind.length) {
99
+ this.grow();
100
+ }
101
+ const i = this.count++;
102
+ this.kind[i] = kind;
103
+ this.start[i] = start;
104
+ this.end[i] = end;
105
+ this.line[i] = line;
106
+ }
107
+ /**
108
+ * The raw text of a token (a string's body without the quotes, entities undecoded).
109
+ * @param i - the token index
110
+ * @returns the text
111
+ */
112
+ textOf(i) {
113
+ return this.text.slice(this.start[i], this.end[i]);
114
+ }
115
+ /**
116
+ * The decoded value of a string token.
117
+ * @param i - the token index
118
+ * @returns the body with character references decoded
119
+ */
120
+ stringOf(i) {
121
+ return decodeGmlString(this.textOf(i));
122
+ }
123
+ /**
124
+ * Whether a token is a `[` or `]`.
125
+ * @param i - the token index
126
+ * @returns true for a bracket
127
+ */
128
+ isBracket(i) {
129
+ return this.kind[i] >= TOKEN_OPEN;
130
+ }
131
+ /**
132
+ * The index of the pair following the pair whose key is at `key`.
133
+ * @param key - the index of a key token
134
+ * @returns the index after the pair's value (after the matching `]` for a record)
135
+ */
136
+ nextPair(key) {
137
+ const value = key + 1;
138
+ return this.kind[value] === TOKEN_OPEN ? this.match[value] + 1 : value + 1;
139
+ }
140
+ /** Double every array. */
141
+ grow() {
142
+ const capacity = this.kind.length * 2;
143
+ const kind = new Uint8Array(capacity);
144
+ kind.set(this.kind);
145
+ this.kind = kind;
146
+ const start = new Uint32Array(capacity);
147
+ start.set(this.start);
148
+ this.start = start;
149
+ const end = new Uint32Array(capacity);
150
+ end.set(this.end);
151
+ this.end = end;
152
+ const line = new Uint32Array(capacity);
153
+ line.set(this.line);
154
+ this.line = line;
155
+ }
156
+ }
157
+ /**
158
+ * Lex and structurally validate a whole GML text.
159
+ *
160
+ * Lexical rules (NetworkX): whitespace separates tokens; `#` outside a string starts a comment
161
+ * that runs to the end of the line; a string is delimited by double quotes and must close on its
162
+ * line (there is no escape mechanism; `&#NN;` references are decoded later); `[` and `]` are
163
+ * single-character tokens; every other run of characters is a key (`[A-Za-z_][0-9A-Za-z_]*`),
164
+ * an integer (`[+-]?[0-9]+`), a real (with a decimal point or an exponent, or `INF` / `NAN` in
165
+ * any case with an optional sign) or an error.
166
+ *
167
+ * Structural rules: the text is a sequence of `key value` pairs where a value is a number, a
168
+ * string, `INF` / `NAN`, or a bracketed sequence of pairs; every `[` has a `]`.
169
+ * @param text - the GML text
170
+ * @returns the validated tokens; GmlSyntaxError with the line of the first problem
171
+ */
172
+ export function tokenizeGml(text) {
173
+ const tokens = new GmlTokens(text, Math.max(1024, text.length >>> 3));
174
+ const n = text.length;
175
+ let i = 0;
176
+ let line = 1;
177
+ while (i < n) {
178
+ const c = text.charCodeAt(i);
179
+ if (c === 10) {
180
+ line++;
181
+ i++;
182
+ }
183
+ else if (c === 13) {
184
+ line++;
185
+ i++;
186
+ if (i < n && text.charCodeAt(i) === 10) {
187
+ i++;
188
+ }
189
+ }
190
+ else if (c === 32 || c === 9 || c === 11 || c === 12) {
191
+ i++;
192
+ }
193
+ else if (c === 35) {
194
+ i = endOfLine(text, i);
195
+ }
196
+ else if (c === 91) {
197
+ tokens.push(TOKEN_OPEN, i, i + 1, line);
198
+ i++;
199
+ }
200
+ else if (c === 93) {
201
+ tokens.push(TOKEN_CLOSE, i, i + 1, line);
202
+ i++;
203
+ }
204
+ else if (c === 34) {
205
+ const close = text.indexOf('"', i + 1);
206
+ const eol = endOfLine(text, i + 1);
207
+ if (close < 0 || close > eol) {
208
+ throw new GmlSyntaxError(SYNTAX_STRING_CODE, `unclosed string at line ${line}`, line);
209
+ }
210
+ tokens.push(TOKEN_STRING, i + 1, close, line);
211
+ i = close + 1;
212
+ }
213
+ else {
214
+ let j = i + 1;
215
+ while (j < n && !isDelimiter(text.charCodeAt(j))) {
216
+ j++;
217
+ }
218
+ tokens.push(classifyBare(text, i, j, line), i, j, line);
219
+ i = j;
220
+ }
221
+ }
222
+ validateStructure(tokens);
223
+ return tokens;
224
+ }
225
+ /**
226
+ * The offset of the line terminator at or after `from`, or the text length.
227
+ * @param text - the text
228
+ * @param from - the offset to search from
229
+ * @returns the offset of the next `\n` or `\r`
230
+ */
231
+ function endOfLine(text, from) {
232
+ const n = text.length;
233
+ for (let i = from; i < n; i++) {
234
+ const c = text.charCodeAt(i);
235
+ if (c === 10 || c === 13) {
236
+ return i;
237
+ }
238
+ }
239
+ return n;
240
+ }
241
+ /**
242
+ * Whether a character ends a bare token.
243
+ * @param c - the char code
244
+ * @returns true for whitespace, brackets, a quote or `#`
245
+ */
246
+ function isDelimiter(c) {
247
+ return (c === 32 ||
248
+ c === 9 ||
249
+ c === 10 ||
250
+ c === 13 ||
251
+ c === 11 ||
252
+ c === 12 ||
253
+ c === 91 ||
254
+ c === 93 ||
255
+ c === 34 ||
256
+ c === 35);
257
+ }
258
+ /**
259
+ * Classify a bare token.
260
+ * @param text - the text
261
+ * @param start - the token start
262
+ * @param end - the token end
263
+ * @param line - the token line, for the error
264
+ * @returns WORD, INT or REAL; GmlSyntaxError for anything else
265
+ */
266
+ function classifyBare(text, start, end, line) {
267
+ const token = text.slice(start, end);
268
+ if (KEY_TEXT.test(token)) {
269
+ return TOKEN_WORD;
270
+ }
271
+ if (INT_TEXT.test(token)) {
272
+ return TOKEN_INT;
273
+ }
274
+ if (REAL_TEXT.test(token) || NON_FINITE_TEXT.test(token)) {
275
+ return TOKEN_REAL;
276
+ }
277
+ const shown = token.length > 20 ? `${token.slice(0, 20)}...` : token;
278
+ throw new GmlSyntaxError(SYNTAX_TOKEN_CODE, `cannot tokenize "${shown}" at line ${line}`, line);
279
+ }
280
+ /**
281
+ * Check the `key value` structure and record the matching bracket of every `[`.
282
+ * @param tokens - the lexed tokens
283
+ */
284
+ function validateStructure(tokens) {
285
+ const { count, kind } = tokens;
286
+ const match = new Uint32Array(count);
287
+ const stack = [];
288
+ let i = 0;
289
+ while (i < count) {
290
+ const k = kind[i];
291
+ if (k === TOKEN_CLOSE) {
292
+ const open = stack.pop();
293
+ if (open === undefined) {
294
+ throw new GmlSyntaxError(SYNTAX_STRUCTURE_CODE, `unexpected "]" at line ${tokens.line[i]}: no open "["`, tokens.line[i]);
295
+ }
296
+ match[open] = i;
297
+ i++;
298
+ continue;
299
+ }
300
+ if (k !== TOKEN_WORD) {
301
+ throw new GmlSyntaxError(SYNTAX_STRUCTURE_CODE, `expected a key at line ${tokens.line[i]}, found ${describeToken(tokens, i)}`, tokens.line[i]);
302
+ }
303
+ const value = i + 1;
304
+ if (value >= count) {
305
+ throw new GmlSyntaxError(SYNTAX_STRUCTURE_CODE, `key "${tokens.textOf(i)}" at line ${tokens.line[i]} has no value`, tokens.line[i]);
306
+ }
307
+ const vk = kind[value];
308
+ if (vk === TOKEN_OPEN) {
309
+ stack.push(value);
310
+ }
311
+ else if (vk === TOKEN_CLOSE || (vk === TOKEN_WORD && !NON_FINITE_WORD.test(tokens.textOf(value)))) {
312
+ throw new GmlSyntaxError(SYNTAX_STRUCTURE_CODE, `expected a value for key "${tokens.textOf(i)}" at line ${tokens.line[i]}, found ${describeToken(tokens, value)}`, tokens.line[value]);
313
+ }
314
+ i = value + 1;
315
+ }
316
+ if (stack.length > 0) {
317
+ const open = stack[stack.length - 1];
318
+ throw new GmlSyntaxError(SYNTAX_BRACKET_CODE, `unexpected end of input: ${stack.length} bracket(s) still open, the last opened at line ${tokens.line[open]}`, tokens.line[open]);
319
+ }
320
+ tokens.match = match;
321
+ }
322
+ /**
323
+ * A short description of a token for messages.
324
+ * @param tokens - the tokens
325
+ * @param i - the token index
326
+ * @returns the quoted text or the bracket
327
+ */
328
+ function describeToken(tokens, i) {
329
+ switch (tokens.kind[i]) {
330
+ case TOKEN_OPEN:
331
+ return '"["';
332
+ case TOKEN_CLOSE:
333
+ return '"]"';
334
+ case TOKEN_STRING:
335
+ return `the string "${tokens.textOf(i)}"`;
336
+ default:
337
+ return `"${tokens.textOf(i)}"`;
338
+ }
339
+ }
340
+ /**
341
+ * The numeric value of an INT or REAL token (or a WORD that is `INF` / `NAN` at a value position).
342
+ * @param text - the token text
343
+ * @returns the number; Infinity / -Infinity / NaN for the non-finite spellings
344
+ */
345
+ export function numberOfText(text) {
346
+ if (NON_FINITE_TEXT.test(text)) {
347
+ const lower = text.toLowerCase();
348
+ if (lower.endsWith("nan")) {
349
+ return NaN;
350
+ }
351
+ return lower.startsWith("-") ? -Infinity : Infinity;
352
+ }
353
+ return Number(text);
354
+ }
355
+ /**
356
+ * Whether a value token is one of the non-finite bare words (`INF`, `NAN`), which lex as words.
357
+ * @param tokens - the tokens
358
+ * @param i - the value token index
359
+ * @returns true when the word is a real
360
+ */
361
+ export function isNonFiniteWord(tokens, i) {
362
+ return tokens.kind[i] === TOKEN_WORD && NON_FINITE_WORD.test(tokens.textOf(i));
363
+ }
364
+ /**
365
+ * Whether a text is a GML key the strict grammar accepts (`[A-Za-z][0-9A-Za-z_]*`, what NetworkX
366
+ * writes and reads).
367
+ * @param text - the candidate key
368
+ * @returns true when it can be written as a key
369
+ */
370
+ export function isGmlKey(text) {
371
+ return STRICT_KEY_TEXT.test(text);
372
+ }
373
+ /**
374
+ * Rewrite a text as a GML key: every character outside `[0-9A-Za-z_]` becomes `_` and a leading
375
+ * non-letter is prefixed with `x` (the exporter's `sanitizeKeys: "mangle"`).
376
+ * @param text - the text
377
+ * @returns a valid key
378
+ */
379
+ export function mangleGmlKey(text) {
380
+ const body = text.replace(/[^0-9A-Za-z_]/g, "_");
381
+ return /^[A-Za-z]/.test(body) ? body : `x${body}`;
382
+ }
383
+ /**
384
+ * Parse a bracketed record into a JSON object (design section 8.5: nested GML records map to
385
+ * `json`). Values follow the value grammar; repeated keys become arrays with the NetworkX
386
+ * conventions: the `_networkx_list_start` marker starts a list so a one-element list survives,
387
+ * `"[]"` and `"()"` are empty lists, and a key seen twice without the marker becomes a
388
+ * two-element array. Nested records are walked with an explicit stack, so the nesting depth is
389
+ * bounded by memory, not by the call stack.
390
+ * @param tokens - the validated tokens
391
+ * @param open - the index of the record's `[`
392
+ * @returns a null-prototype object
393
+ */
394
+ export function parseRecord(tokens, open) {
395
+ const root = Object.create(null);
396
+ const stack = [
397
+ { record: root, listKeys: null, close: tokens.match[open], next: open + 1, key: null },
398
+ ];
399
+ while (stack.length > 0) {
400
+ const frame = stack[stack.length - 1];
401
+ if (frame.next >= frame.close) {
402
+ stack.pop();
403
+ if (frame.key !== null) {
404
+ storeValue(stack[stack.length - 1], frame.key, frame.record);
405
+ }
406
+ continue;
407
+ }
408
+ const p = frame.next;
409
+ frame.next = tokens.nextPair(p);
410
+ const key = tokens.textOf(p);
411
+ const v = p + 1;
412
+ if (tokens.kind[v] === TOKEN_STRING) {
413
+ const text = tokens.stringOf(v);
414
+ if (text === LIST_START_MARKER) {
415
+ frame.record[key] = [];
416
+ frame.listKeys ?? (frame.listKeys = new Set());
417
+ frame.listKeys.add(key);
418
+ continue;
419
+ }
420
+ storeValue(frame, key, text === EMPTY_LIST_TEXT || text === EMPTY_TUPLE_TEXT ? [] : text);
421
+ }
422
+ else if (tokens.kind[v] === TOKEN_OPEN) {
423
+ stack.push({
424
+ record: Object.create(null),
425
+ listKeys: null,
426
+ close: tokens.match[v],
427
+ next: v + 1,
428
+ key,
429
+ });
430
+ }
431
+ else {
432
+ storeValue(frame, key, numberOfText(tokens.textOf(v)));
433
+ }
434
+ }
435
+ return root;
436
+ }
437
+ /**
438
+ * Store one value under a key: appended to the key's list when the key is a list, paired with the
439
+ * earlier value when the key repeats, set otherwise.
440
+ * @param frame - the open record
441
+ * @param key - the key
442
+ * @param value - the value
443
+ */
444
+ function storeValue(frame, key, value) {
445
+ const { record } = frame;
446
+ if (frame.listKeys !== null && frame.listKeys.has(key)) {
447
+ record[key].push(value);
448
+ }
449
+ else if (key in record) {
450
+ record[key] = [record[key], value];
451
+ frame.listKeys ?? (frame.listKeys = new Set());
452
+ frame.listKeys.add(key);
453
+ }
454
+ else {
455
+ record[key] = value;
456
+ }
457
+ }
458
+ /**
459
+ * The JSON value of a non-string value token: a number, or a record.
460
+ * @param tokens - the tokens
461
+ * @param v - the value token index (INT, REAL, non-finite WORD or OPEN)
462
+ * @returns the value
463
+ */
464
+ export function scalarOrRecord(tokens, v) {
465
+ return tokens.kind[v] === TOKEN_OPEN ? parseRecord(tokens, v) : numberOfText(tokens.textOf(v));
466
+ }
467
+ //# sourceMappingURL=syntax.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax.js","sourceRoot":"","sources":["../../../../src/formats/gml/syntax.ts"],"names":[],"mappings":"AAAA;;;;;;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C,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,KAAkB,EAAE,GAAW,EAAE,KAAc;IAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACzB,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACpD,MAAM,CAAC,GAAG,CAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;SAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QACnC,KAAK,CAAC,QAAQ,KAAd,KAAK,CAAC,QAAQ,GAAK,IAAI,GAAG,EAAE,EAAC;QAC7B,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACxB,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAiB,EAAE,CAAS;IACvD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACnG,CAAC"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * What the GraphML importer and exporter share: the namespace, the format facts, the reserved
3
+ * column names of the XML-attribute-derived columns (design section 5.6), the `meta.extra`
4
+ * keys the importer records for the exporter, and the issue and loss codes.
5
+ */
6
+ /** The GraphML namespace. */
7
+ export declare const GRAPHML_NAMESPACE = "http://graphml.graphdrawing.org/xmlns";
8
+ /** The yFiles extension namespace, declared as `xmlns:y` when a yfiles column is written. */
9
+ export declare const YFILES_NAMESPACE = "http://www.yworks.com/xml/graphml";
10
+ /** The XML Schema instance namespace and the schema location the exporter writes. */
11
+ export declare const XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance";
12
+ /** The GraphML schema location written by the exporter. */
13
+ export declare const SCHEMA_LOCATION = "http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd";
14
+ /** The format name. */
15
+ export declare const FORMAT = "graphml";
16
+ /** File extensions. */
17
+ export declare const EXTENSIONS: readonly string[];
18
+ /** MIME types. */
19
+ export declare const MIME_TYPES: readonly string[];
20
+ /** The `attr.name` of the node key that carries ids rewritten by `sanitizeIds: "mangle"` (design section 8.5). */
21
+ export declare const ORIGINAL_ID_ATTRIBUTE = "graphty:originalId";
22
+ /** The node column that keeps original ids when `restoreMangledIds` is off (design section 5.6). */
23
+ export declare const ORIGINAL_ID_COLUMN = "graphty.originalId";
24
+ /** The edge column of the `id` XML attribute (role id, unique). */
25
+ export declare const EDGE_ID_COLUMN = "id";
26
+ /** The edge columns of the `sourceport` / `targetport` XML attributes (roles sourcePort / targetPort). */
27
+ export declare const SOURCE_PORT_COLUMN = "sourceport";
28
+ /** The edge column of the `targetport` XML attribute. */
29
+ export declare const TARGET_PORT_COLUMN = "targetport";
30
+ /** The node column of the containing node of a nested graph (u32, role parent, refersTo node). */
31
+ export declare const PARENT_COLUMN = "parent";
32
+ /** The bool node column marking the hub nodes synthesised for hyperedges under `hyperedges: "star"`. */
33
+ export declare const HYPEREDGE_HUB_COLUMN = "graphty.hyperedge";
34
+ /** The column name a node key titled `label` receives the `label` role under. */
35
+ export declare const LABEL_COLUMN = "label";
36
+ /** Edge column names reserved for the XML-attribute-derived columns; a key titled like one is renamed `<name>#<id>`. */
37
+ export declare const RESERVED_EDGE_NAMES: ReadonlySet<string>;
38
+ /** Node column names reserved for the XML-derived columns. */
39
+ export declare const RESERVED_NODE_NAMES: ReadonlySet<string>;
40
+ /** The `meta.extra` key under which the importer records what the exporter needs. */
41
+ export declare const META_KEY = "graphml";
42
+ /** What the importer stores under `meta.extra.graphml`. */
43
+ export interface GraphmlMeta {
44
+ /** The top-level `<graph id>`, or null. */
45
+ readonly graphId: string | null;
46
+ /** The top-level `edgedefault` as written, so a mixed file re-exports with the same layout. */
47
+ readonly edgedefault: "directed" | "undirected" | null;
48
+ /** The `xmlns:<prefix>` declarations of the root element (yFiles and the like). */
49
+ readonly namespaces: Readonly<Record<string, string>>;
50
+ }
51
+ /**
52
+ * The issue codes the GraphML importer records (design section 8.6), by name: the codes shared
53
+ * with the other importers (src/common/codes.ts) and the GraphML-specific ones. A key is the code
54
+ * without its severity and format prefixes.
55
+ */
56
+ export declare const GRAPHML_ISSUE: Readonly<{
57
+ /** Fatal: the input is not well-formed XML. */
58
+ XML_SYNTAX: "E_XML_SYNTAX";
59
+ /** Fatal: the input holds invalid UTF-8. */
60
+ INVALID_UTF8: "E_INVALID_UTF8";
61
+ /** Fatal: the root element is not `<graphml>`. */
62
+ NOT_GRAPHML: "E_NOT_GRAPHML";
63
+ /** Fatal: the document has no `<graph>`. */
64
+ NO_GRAPH: "E_NO_GRAPH";
65
+ /** A `<key>` without an id. */
66
+ KEY_MISSING_ID: "E_GRAPHML_KEY_MISSING_ID";
67
+ /** Two `<key>` elements with the same id. */
68
+ DUPLICATE_KEY: "E_DUPLICATE_KEY";
69
+ /** A key declared for hyperedges, ports or endpoints (never used). */
70
+ KEY_DOMAIN_UNSUPPORTED: "W_GRAPHML_KEY_DOMAIN_UNSUPPORTED";
71
+ /** A `<node>` without an id. */
72
+ MISSING_ID: "E_MISSING_ID";
73
+ /** An `<edge>` without a source or a target. */
74
+ MISSING_ENDPOINT: "E_MISSING_ENDPOINT";
75
+ /** A `<data>` whose key was never declared. */
76
+ UNKNOWN_KEY: "E_GRAPHML_UNKNOWN_KEY";
77
+ /** A `<data>` whose key is declared for another domain. */
78
+ KEY_DOMAIN: "W_GRAPHML_KEY_DOMAIN";
79
+ /** A `<data>` without a key attribute. */
80
+ DATA_MISSING_KEY: "E_GRAPHML_DATA_MISSING_KEY";
81
+ /** A `<key>` whose `for` is not a GraphML domain. */
82
+ KEY_FOR_INVALID: "E_GRAPHML_KEY_FOR_INVALID";
83
+ /** Data of a nested `<graph>`; only the top-level graph has attributes. */
84
+ NESTED_GRAPH_DATA: "W_GRAPHML_NESTED_GRAPH_DATA";
85
+ /** Data of a hyperedge expanded to a star or clique. */
86
+ HYPEREDGE_DATA_DROPPED: "W_GRAPHML_HYPEREDGE_DATA_DROPPED";
87
+ /** Nested elements in the `<data>` of a typed (non-yfiles) key. */
88
+ DATA_NESTED: "E_GRAPHML_DATA_NESTED";
89
+ /** A `<node>` declared twice. */
90
+ DUPLICATE_NODE: "W_DUPLICATE_NODE";
91
+ /** An edge id already used by another edge. */
92
+ DUPLICATE_EDGE_ID: "E_DUPLICATE_EDGE_ID";
93
+ /** A `directed` attribute that is neither true nor false. */
94
+ INVALID_DIRECTED: "E_GRAPHML_INVALID_DIRECTED";
95
+ /** An `edgedefault` that is neither directed nor undirected. */
96
+ INVALID_EDGEDEFAULT: "E_GRAPHML_INVALID_EDGEDEFAULT";
97
+ /** A `<graph>` without edgedefault; the `defaultDirected` option applies. */
98
+ EDGEDEFAULT_MISSING: "W_GRAPHML_EDGEDEFAULT_MISSING";
99
+ /** A second top-level `<graph>`; its nodes and edges are merged into the first. */
100
+ MULTIPLE_GRAPHS: "W_MULTIPLE_GRAPHS";
101
+ /** A `parse.nodes` / `parse.edges` hint the sink cannot reserve (ignored). */
102
+ COUNT_HINT: "W_COUNT_HINT";
103
+ /** A hyperedge under `hyperedges: "error"`. */
104
+ HYPEREDGE: "E_HYPEREDGE";
105
+ /** Hyperedges skipped under `hyperedges: "skip"`. */
106
+ HYPEREDGE_SKIPPED: "W_GRAPHML_HYPEREDGE_SKIPPED";
107
+ /** An endpoint of a hyperedge without a node, or with an unknown type. */
108
+ HYPEREDGE_ENDPOINT: "E_GRAPHML_HYPEREDGE_ENDPOINT";
109
+ /** `<port>` declarations (and their data) are not kept; sourceport / targetport edge attributes are. */
110
+ PORT_DECLARATION: "W_GRAPHML_PORT_DECLARATION";
111
+ /** A `<locator>` element. */
112
+ LOCATOR_DROPPED: "W_GRAPHML_LOCATOR_DROPPED";
113
+ /** A `<desc>` of a node, an edge or a hyperedge. */
114
+ DESC_DROPPED: "W_GRAPHML_DESC_DROPPED";
115
+ /** An element the GraphML schema does not define at that place. */
116
+ UNKNOWN_ELEMENT: "W_UNKNOWN_ELEMENT";
117
+ /** Non-whitespace text where the schema allows only elements. */
118
+ STRAY_TEXT: "W_STRAY_TEXT";
119
+ /** Two distinct id texts merged into one number under `ids: "number"`. */
120
+ ID_MERGED: "W_ID_MERGED";
121
+ /** An option GraphML has no use for (`nodeIdFrom`: nodes are identified by their id attribute). */
122
+ OPTION_IGNORED: "W_OPTION_IGNORED";
123
+ /** A yFiles key under `yfiles: "skip"`. */
124
+ YFILES_SKIPPED: "W_GRAPHML_YFILES_SKIPPED";
125
+ /** A key renamed `<name>#<id>` because the name was taken (design section 5.6). */
126
+ COLUMN_RENAMED: "W_COLUMN_RENAMED";
127
+ /** A key declared without its role because the table already holds it. */
128
+ ROLE_TAKEN: "W_ROLE_TAKEN";
129
+ /** A declared type the format does not define (kept as string). */
130
+ UNKNOWN_ATTR_TYPE: "W_UNKNOWN_ATTR_TYPE";
131
+ /** A default that does not parse as the declared type. */
132
+ BAD_DEFAULT: "W_BAD_DEFAULT";
133
+ /** A long value beyond 2^53 rounded. */
134
+ PRECISION: "W_PRECISION";
135
+ /** A builder-policy option the sink does not honour. */
136
+ SINK_OPTION: "W_SINK_OPTION";
137
+ /** The sink refused the file's direction. */
138
+ DIRECTION_REFUSED: "W_DIRECTION_REFUSED";
139
+ /** Edges forced to the policy's direction. */
140
+ DIRECTION_FORCED: "W_DIRECTION_FORCED";
141
+ /** A mixed file under onMixedDirection "error" (fatal). */
142
+ MIXED_DIRECTION: "E_MIXED_DIRECTION";
143
+ }>;
144
+ /**
145
+ * Loss note codes of the GraphML importer (report.lossy) and exporter (check()): the GraphML
146
+ * ones; the generic ones (dtypes, lists, json text, positions, visual and temporal roles,
147
+ * extension tables, id charsets, the weight key clash, name changes) are those of `LOSS`.
148
+ */
149
+ export declare const GRAPHML_LOSS: Readonly<{
150
+ /** yFiles nested XML kept as a JSON tree: structure preserved, not byte-exact. */
151
+ YFILES_JSON: "W_GRAPHML_YFILES_JSON";
152
+ /** A mutual pair written as one undirected edge; the mark is lost. */
153
+ MUTUAL_AS_UNDIRECTED: "W_MUTUAL_AS_UNDIRECTED";
154
+ /** A `parents` (multi-parent) column cannot be written as nested graphs. */
155
+ PARENTS_DROPPED: "W_PARENTS_DROPPED";
156
+ /** A role column GraphML has no slot for (kind, node ids, ...) written as a plain attribute. */
157
+ ROLE_DROPPED: "W_ROLE_DROPPED";
158
+ /** Containment order differs from index order; node indices change after a round trip. */
159
+ HIERARCHY_REORDERED: "W_GRAPHML_HIERARCHY_REORDERED";
160
+ /** Nodes whose parent chain never reaches a root are written at the top level. */
161
+ PARENT_CYCLE: "W_GRAPHML_PARENT_CYCLE";
162
+ /** Node ids that change type after a round trip under the canonical rule (design section 4.1). */
163
+ ID_TEXT_TYPE: "W_ID_TEXT_TYPE";
164
+ /** A numeric edge id column reads back as string. */
165
+ EDGE_ID_TEXT: "W_GRAPHML_EDGE_ID_TEXT";
166
+ /** A yfiles json value that is not a serialisable tree: export() will throw E_COLUMN_TYPE. */
167
+ YFILES_TREE: "E_GRAPHML_YFILES_TREE";
168
+ }>;
169
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/formats/graphml/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiCH,6BAA6B;AAC7B,eAAO,MAA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