@graphty/graph-io 0.3.10 → 0.3.12

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 (32) hide show
  1. package/README.md +7 -2
  2. package/dist/chunks/{importer-9PxhqH4v.js → importer-CXEiicAN.js} +4 -1
  3. package/dist/chunks/{importer-9PxhqH4v.js.map → importer-CXEiicAN.js.map} +1 -1
  4. package/dist/chunks/{importer-C3HcYWAn.js → importer-D7ZcGCeb.js} +16 -6
  5. package/dist/chunks/importer-D7ZcGCeb.js.map +1 -0
  6. package/dist/dot.js +1 -1
  7. package/dist/gexf.js +4 -0
  8. package/dist/gexf.js.map +1 -1
  9. package/dist/gml.js +15 -3
  10. package/dist/gml.js.map +1 -1
  11. package/dist/graph-io.js +4 -4
  12. package/dist/graphml.js +1 -1
  13. package/dist/src/formats/dot/importer.d.ts +5 -0
  14. package/dist/src/formats/dot/importer.d.ts.map +1 -1
  15. package/dist/src/formats/dot/importer.js +11 -5
  16. package/dist/src/formats/dot/importer.js.map +1 -1
  17. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  18. package/dist/src/formats/gexf/importer.js +8 -1
  19. package/dist/src/formats/gexf/importer.js.map +1 -1
  20. package/dist/src/formats/gml/importer.d.ts +1 -1
  21. package/dist/src/formats/gml/importer.d.ts.map +1 -1
  22. package/dist/src/formats/gml/importer.js +13 -3
  23. package/dist/src/formats/gml/importer.js.map +1 -1
  24. package/dist/src/formats/graphml/importer.d.ts.map +1 -1
  25. package/dist/src/formats/graphml/importer.js +5 -0
  26. package/dist/src/formats/graphml/importer.js.map +1 -1
  27. package/package.json +2 -2
  28. package/src/formats/dot/importer.ts +25 -4
  29. package/src/formats/gexf/importer.ts +9 -1
  30. package/src/formats/gml/importer.ts +18 -3
  31. package/src/formats/graphml/importer.ts +5 -0
  32. package/dist/chunks/importer-C3HcYWAn.js.map +0 -1
package/dist/gml.js CHANGED
@@ -1356,6 +1356,7 @@ const REPEATED_KEY_CODE = "E_GML_REPEATED_KEY";
1356
1356
  const ELEMENT_TYPE_CODE = "E_GML_ELEMENT_TYPE";
1357
1357
  const FLAG_TYPE_CODE = "E_GML_FLAG_TYPE";
1358
1358
  const FLAG_VALUE_CODE = "W_GML_FLAG_VALUE";
1359
+ const QUOTED_INT = /^\s*[+-]?[0-9]+\s*$/;
1359
1360
  const UNKNOWN_ENTITY_CODE = "W_GML_UNKNOWN_ENTITY";
1360
1361
  const PRECISION_CODE = PRECISION_CODE$1;
1361
1362
  const ROLE_TAKEN_CODE = ROLE_TAKEN_CODE$1;
@@ -1784,7 +1785,10 @@ class GmlImport {
1784
1785
  title: null,
1785
1786
  type: this.weightKinds === KIND_INT ? "int" : "real",
1786
1787
  namespace: null
1787
- } : void 0
1788
+ } : void 0,
1789
+ // The header as written, so a reader can say which words set the direction and tell
1790
+ // `directed 0` from a file that relies on the specification's default.
1791
+ extra: this.directedToken >= 0 ? { gml: { directed: textOf(this.directedToken) } } : void 0
1788
1792
  });
1789
1793
  }
1790
1794
  /**
@@ -1798,7 +1802,15 @@ class GmlImport {
1798
1802
  return null;
1799
1803
  }
1800
1804
  const t = this.requireTokens();
1801
- if (t.kind[v] !== TOKEN_INT) {
1805
+ const quoted = t.kind[v] === TOKEN_STRING && QUOTED_INT.test(t.stringOf(v));
1806
+ if (quoted) {
1807
+ this.report.warning(
1808
+ "validation-error",
1809
+ FLAG_VALUE_CODE,
1810
+ `flag "${name}" is written as the string ${describeValue(t, v)}; read as an integer`,
1811
+ { line: t.line[v], element: name }
1812
+ );
1813
+ } else if (t.kind[v] !== TOKEN_INT) {
1802
1814
  this.report.error(
1803
1815
  "validation-error",
1804
1816
  FLAG_TYPE_CODE,
@@ -1807,7 +1819,7 @@ class GmlImport {
1807
1819
  );
1808
1820
  return null;
1809
1821
  }
1810
- const n = Number(t.textOf(v));
1822
+ const n = Number(quoted ? t.stringOf(v) : t.textOf(v));
1811
1823
  if (n !== 0 && n !== 1) {
1812
1824
  this.report.warning(
1813
1825
  "validation-error",