@graphty/graph-io 0.3.33 → 0.3.35

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 (47) hide show
  1. package/dist/chunks/{exporter-jp43hhXk.js → exporter-CkPnJCXU.js} +34 -10
  2. package/dist/chunks/exporter-CkPnJCXU.js.map +1 -0
  3. package/dist/chunks/{exporter-BkkfMWGQ.js → exporter-LZTIAzkS.js} +14 -2
  4. package/dist/chunks/{exporter-BkkfMWGQ.js.map → exporter-LZTIAzkS.js.map} +1 -1
  5. package/dist/chunks/{importer-BESct_Xz.js → importer-C1VMuEBQ.js} +2 -2
  6. package/dist/chunks/importer-C1VMuEBQ.js.map +1 -0
  7. package/dist/chunks/{importer-DoSz--Ip.js → importer-DvPvd4Yy.js} +14 -7
  8. package/dist/chunks/importer-DvPvd4Yy.js.map +1 -0
  9. package/dist/cx.js +1 -1
  10. package/dist/graph-io.js +8 -8
  11. package/dist/json.js +1 -1
  12. package/dist/obo.js +1 -1
  13. package/dist/pajek.js +1 -1
  14. package/dist/src/formats/cx/exporter.js +1 -1
  15. package/dist/src/formats/cx/exporter.js.map +1 -1
  16. package/dist/src/formats/json/exporter.d.ts +2 -0
  17. package/dist/src/formats/json/exporter.d.ts.map +1 -1
  18. package/dist/src/formats/json/exporter.js +2 -0
  19. package/dist/src/formats/json/exporter.js.map +1 -1
  20. package/dist/src/formats/json/obographs-export.d.ts +2 -0
  21. package/dist/src/formats/json/obographs-export.d.ts.map +1 -1
  22. package/dist/src/formats/json/obographs-export.js +5 -0
  23. package/dist/src/formats/json/obographs-export.js.map +1 -1
  24. package/dist/src/formats/obo/exporter.d.ts +2 -0
  25. package/dist/src/formats/obo/exporter.d.ts.map +1 -1
  26. package/dist/src/formats/obo/exporter.js +5 -0
  27. package/dist/src/formats/obo/exporter.js.map +1 -1
  28. package/dist/src/formats/obo/syntax.d.ts.map +1 -1
  29. package/dist/src/formats/obo/syntax.js +39 -10
  30. package/dist/src/formats/obo/syntax.js.map +1 -1
  31. package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
  32. package/dist/src/formats/pajek/exporter.js +2 -4
  33. package/dist/src/formats/pajek/exporter.js.map +1 -1
  34. package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
  35. package/dist/src/formats/pajek/syntax.js +12 -2
  36. package/dist/src/formats/pajek/syntax.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/formats/cx/exporter.ts +1 -1
  39. package/src/formats/json/exporter.ts +2 -0
  40. package/src/formats/json/obographs-export.ts +10 -0
  41. package/src/formats/obo/exporter.ts +10 -0
  42. package/src/formats/obo/syntax.ts +42 -9
  43. package/src/formats/pajek/exporter.ts +2 -4
  44. package/src/formats/pajek/syntax.ts +12 -2
  45. package/dist/chunks/exporter-jp43hhXk.js.map +0 -1
  46. package/dist/chunks/importer-BESct_Xz.js.map +0 -1
  47. package/dist/chunks/importer-DoSz--Ip.js.map +0 -1
@@ -68,23 +68,36 @@ function splitTagValue(line) {
68
68
  }
69
69
  return null;
70
70
  }
71
+ const COMMENT_MARKS = String.raw`\"!`;
72
+ const BRACE_MARKS = String.raw`\"[]{}`;
71
73
  function stripComment(rest) {
72
74
  let quoted = false;
73
- for (let i = 0; i < rest.length; i++) {
75
+ const found = [-2, -2, -2];
76
+ let i = nextOf(rest, 0, COMMENT_MARKS, found);
77
+ while (i >= 0) {
74
78
  const ch = rest.charAt(i);
75
- if (ch === "\\") {
76
- i++;
77
- continue;
78
- }
79
79
  const atStart = i === 0 || rest.charAt(i - 1) === " " || rest.charAt(i - 1) === " ";
80
80
  if (ch === '"' && (quoted || atStart)) {
81
81
  quoted = !quoted;
82
82
  } else if (ch === "!" && !quoted && atStart) {
83
83
  return rest.slice(0, i).trimEnd();
84
84
  }
85
+ i = nextOf(rest, ch === "\\" ? i + 2 : i + 1, COMMENT_MARKS, found);
85
86
  }
86
87
  return rest.trimEnd();
87
88
  }
89
+ function nextOf(text, from, marks, found) {
90
+ let nearest = -1;
91
+ for (let k = 0; k < marks.length; k++) {
92
+ if (found[k] !== -1 && found[k] < from) {
93
+ found[k] = text.indexOf(marks.charAt(k), from);
94
+ }
95
+ if (found[k] !== -1 && (nearest === -1 || found[k] < nearest)) {
96
+ nearest = found[k];
97
+ }
98
+ }
99
+ return nearest;
100
+ }
88
101
  function splitQualifiers(value) {
89
102
  if (!value.endsWith("}")) {
90
103
  return { value, qualifiers: null, badBlock: null };
@@ -338,17 +351,18 @@ function parseXrefList(inner) {
338
351
  function hasStrayBrace(value) {
339
352
  let quoted = false;
340
353
  let listed = false;
341
- for (let i = 0; i < value.length; i++) {
354
+ const found = [-2, -2, -2, -2, -2, -2];
355
+ let i = nextOf(value, 0, BRACE_MARKS, found);
356
+ while (i >= 0) {
342
357
  const ch = value.charAt(i);
343
- if (ch === "\\") {
344
- i++;
345
- } else if (ch === '"') {
358
+ if (ch === '"') {
346
359
  quoted = !quoted;
347
360
  } else if (!quoted && (ch === "[" || ch === "]")) {
348
361
  listed = ch === "[";
349
362
  } else if (!quoted && !listed && (ch === "{" || ch === "}")) {
350
363
  return true;
351
364
  }
365
+ i = nextOf(value, ch === "\\" ? i + 2 : i + 1, BRACE_MARKS, found);
352
366
  }
353
367
  return false;
354
368
  }
@@ -2102,6 +2116,8 @@ const OBO_LOSS = Object.freeze({
2102
2116
  ONTOLOGY_NAME: "W_OBO_ONTOLOGY_NAME",
2103
2117
  /** `[Typedef]` frames read back as nodes only under the importer's `typedefs: "nodes"`; by default they are metadata. */
2104
2118
  TYPEDEF_NODES: TYPEDEF_NODES_CODE,
2119
+ /** A graph without a node `type` column is written as `[Term]` frames and reads back with a `type` column holding Term. */
2120
+ TYPE_GAINED: "W_OBO_TYPE_GAINED",
2105
2121
  /** Edges are written in the frame of their source node, so they read back grouped by source, in node order. */
2106
2122
  EDGE_ORDER: "W_OBO_EDGE_ORDER",
2107
2123
  /**
@@ -2691,6 +2707,14 @@ function plan(snapshot, options) {
2691
2707
  }
2692
2708
  }
2693
2709
  const { kinds, type } = planKinds(snapshot, frameless);
2710
+ if (rows.length > 0 && !snapshot.nodes.has("type")) {
2711
+ note(
2712
+ OBO_LOSS.TYPE_GAINED,
2713
+ `${rows.length} node${plural(rows.length)} ${agree(rows.length, "is", "are")} written as [Term] frames and ${agree(rows.length, "reads", "read")} back with the type Term in a new node column "type"`,
2714
+ null,
2715
+ rows.length
2716
+ );
2717
+ }
2694
2718
  const typedefNodes = rows.filter((i) => kinds[i] === "Typedef").length;
2695
2719
  if (typedefNodes > 0) {
2696
2720
  note(
@@ -3462,4 +3486,4 @@ export {
3462
3486
  oboImporter as c,
3463
3487
  oboExporter as o
3464
3488
  };
3465
- //# sourceMappingURL=exporter-jp43hhXk.js.map
3489
+ //# sourceMappingURL=exporter-CkPnJCXU.js.map