@graphty/graph-io 0.3.39 → 0.3.41
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.
- package/dist/chunks/{choose-CS3fvGT1.js → choose-CwFQamH9.js} +2 -2
- package/dist/chunks/{choose-CS3fvGT1.js.map → choose-CwFQamH9.js.map} +1 -1
- package/dist/chunks/{constants-DqKZT6cH.js → constants-Cf4Nn6tw.js} +2 -2
- package/dist/chunks/{constants-DqKZT6cH.js.map → constants-Cf4Nn6tw.js.map} +1 -1
- package/dist/chunks/{escape-BpYMQZVa.js → escape-DBb8zuNE.js} +4 -3
- package/dist/chunks/escape-DBb8zuNE.js.map +1 -0
- package/dist/chunks/{export-B-aVCwyG.js → export-DD3Lvw-F.js} +173 -116
- package/dist/chunks/export-DD3Lvw-F.js.map +1 -0
- package/dist/chunks/{exporter-CNJZF_BN.js → exporter-BqtmlxNr.js} +545 -459
- package/dist/chunks/exporter-BqtmlxNr.js.map +1 -0
- package/dist/chunks/{exporter-BqKs1Q12.js → exporter-CS35R6Fg.js} +6 -5
- package/dist/chunks/exporter-CS35R6Fg.js.map +1 -0
- package/dist/chunks/{exporter-DXqCPNrI.js → exporter-D8r1N2dU.js} +67 -42
- package/dist/chunks/exporter-D8r1N2dU.js.map +1 -0
- package/dist/chunks/{exporter-SFYkDzD0.js → exporter-NMplSnYn.js} +23 -20
- package/dist/chunks/{exporter-SFYkDzD0.js.map → exporter-NMplSnYn.js.map} +1 -1
- package/dist/chunks/{importer-CSt-gaYE.js → importer-BKC7AmCA.js} +42 -29
- package/dist/chunks/importer-BKC7AmCA.js.map +1 -0
- package/dist/chunks/{importer-DvFznt5-.js → importer-BdWHmlmG.js} +112 -62
- package/dist/chunks/importer-BdWHmlmG.js.map +1 -0
- package/dist/chunks/{importer-CqgYq4Ld.js → importer-BfbzWk6k.js} +202 -181
- package/dist/chunks/importer-BfbzWk6k.js.map +1 -0
- package/dist/chunks/{importer-PVXkeoaS.js → importer-BmaZcskq.js} +79 -66
- package/dist/chunks/importer-BmaZcskq.js.map +1 -0
- package/dist/chunks/{importer-B7Ir269L.js → importer-DviEsHy4.js} +118 -72
- package/dist/chunks/importer-DviEsHy4.js.map +1 -0
- package/dist/chunks/{importer--tQQsY4W.js → importer-S-abxJHn.js} +5 -5
- package/dist/chunks/{importer--tQQsY4W.js.map → importer-S-abxJHn.js.map} +1 -1
- package/dist/chunks/{importer-BfJ1jnNr.js → importer-r29cWnEf.js} +28 -13
- package/dist/chunks/importer-r29cWnEf.js.map +1 -0
- package/dist/chunks/{json-elements-CXs4z1iL.js → json-elements-DdF-etPT.js} +7 -5
- package/dist/chunks/{json-elements-CXs4z1iL.js.map → json-elements-DdF-etPT.js.map} +1 -1
- package/dist/chunks/{ontology-export-50L9DOV4.js → ontology-export-BC0zyPhj.js} +2 -2
- package/dist/chunks/{ontology-export-50L9DOV4.js.map → ontology-export-BC0zyPhj.js.map} +1 -1
- package/dist/chunks/{records-C9jd7yLD.js → records-Uc3LkABx.js} +150 -106
- package/dist/chunks/records-Uc3LkABx.js.map +1 -0
- package/dist/chunks/{text-Bjfa1xYL.js → text-Bh9SaAob.js} +20 -11
- package/dist/chunks/text-Bh9SaAob.js.map +1 -0
- package/dist/csv.js +67 -49
- package/dist/csv.js.map +1 -1
- package/dist/cx.js +1 -1
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +1 -1
- package/dist/gexf.js +199 -99
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +170 -149
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +26 -26
- package/dist/graphml.js +2 -2
- package/dist/json.js +1 -1
- package/dist/neo4j.js +103 -65
- package/dist/neo4j.js.map +1 -1
- package/dist/obo.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/common/attributes.d.ts.map +1 -1
- package/dist/src/common/attributes.js +34 -9
- package/dist/src/common/attributes.js.map +1 -1
- package/dist/src/common/input.d.ts.map +1 -1
- package/dist/src/common/input.js +180 -102
- package/dist/src/common/input.js.map +1 -1
- package/dist/src/common/json-elements.d.ts.map +1 -1
- package/dist/src/common/json-elements.js +4 -2
- package/dist/src/common/json-elements.js.map +1 -1
- package/dist/src/common/text.d.ts +7 -0
- package/dist/src/common/text.d.ts.map +1 -1
- package/dist/src/common/text.js +15 -7
- package/dist/src/common/text.js.map +1 -1
- package/dist/src/common/xml.d.ts.map +1 -1
- package/dist/src/common/xml.js +2 -1
- package/dist/src/common/xml.js.map +1 -1
- package/dist/src/common/zip.d.ts.map +1 -1
- package/dist/src/common/zip.js +36 -19
- package/dist/src/common/zip.js.map +1 -1
- package/dist/src/formats/csv/exporter.d.ts.map +1 -1
- package/dist/src/formats/csv/exporter.js +77 -25
- package/dist/src/formats/csv/exporter.js.map +1 -1
- package/dist/src/formats/csv/importer.d.ts.map +1 -1
- package/dist/src/formats/csv/importer.js +16 -6
- package/dist/src/formats/csv/importer.js.map +1 -1
- package/dist/src/formats/csv/records.d.ts.map +1 -1
- package/dist/src/formats/csv/records.js +156 -110
- package/dist/src/formats/csv/records.js.map +1 -1
- package/dist/src/formats/cx/importer.d.ts.map +1 -1
- package/dist/src/formats/cx/importer.js +108 -53
- package/dist/src/formats/cx/importer.js.map +1 -1
- package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
- package/dist/src/formats/cx2/exporter.js +2 -1
- package/dist/src/formats/cx2/exporter.js.map +1 -1
- package/dist/src/formats/cx2/importer.d.ts.map +1 -1
- package/dist/src/formats/cx2/importer.js +28 -6
- package/dist/src/formats/cx2/importer.js.map +1 -1
- package/dist/src/formats/cys/tables.d.ts.map +1 -1
- package/dist/src/formats/cys/tables.js +11 -8
- package/dist/src/formats/cys/tables.js.map +1 -1
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +69 -39
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gexf/importer.d.ts.map +1 -1
- package/dist/src/formats/gexf/importer.js +138 -50
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gml/exporter.d.ts.map +1 -1
- package/dist/src/formats/gml/exporter.js +51 -35
- package/dist/src/formats/gml/exporter.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +103 -58
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/gml/syntax.d.ts.map +1 -1
- package/dist/src/formats/gml/syntax.js +17 -8
- package/dist/src/formats/gml/syntax.js.map +1 -1
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
- package/dist/src/formats/graphml/exporter.js +36 -25
- package/dist/src/formats/graphml/exporter.js.map +1 -1
- package/dist/src/formats/graphml/importer.d.ts.map +1 -1
- package/dist/src/formats/graphml/importer.js +20 -15
- package/dist/src/formats/graphml/importer.js.map +1 -1
- package/dist/src/formats/graphml/tree.js +23 -14
- package/dist/src/formats/graphml/tree.js.map +1 -1
- package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
- package/dist/src/formats/graphml/yfiles.js +22 -10
- package/dist/src/formats/graphml/yfiles.js.map +1 -1
- package/dist/src/formats/json/exporter.d.ts.map +1 -1
- package/dist/src/formats/json/exporter.js +38 -21
- package/dist/src/formats/json/exporter.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +536 -343
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/json/obographs.js +29 -17
- package/dist/src/formats/json/obographs.js.map +1 -1
- package/dist/src/formats/neo4j/exporter.d.ts.map +1 -1
- package/dist/src/formats/neo4j/exporter.js +73 -43
- package/dist/src/formats/neo4j/exporter.js.map +1 -1
- package/dist/src/formats/neo4j/header.d.ts.map +1 -1
- package/dist/src/formats/neo4j/header.js +37 -16
- package/dist/src/formats/neo4j/header.js.map +1 -1
- package/dist/src/formats/neo4j/importer.d.ts.map +1 -1
- package/dist/src/formats/neo4j/importer.js +21 -11
- package/dist/src/formats/neo4j/importer.js.map +1 -1
- package/dist/src/formats/obo/exporter.d.ts.map +1 -1
- package/dist/src/formats/obo/exporter.js +18 -7
- package/dist/src/formats/obo/exporter.js.map +1 -1
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +142 -73
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/pajek/importer.d.ts.map +1 -1
- package/dist/src/formats/pajek/importer.js +26 -15
- package/dist/src/formats/pajek/importer.js.map +1 -1
- package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
- package/dist/src/formats/pajek/syntax.js +85 -58
- package/dist/src/formats/pajek/syntax.js.map +1 -1
- package/dist/src/formats/xgmml/emit.d.ts +13 -0
- package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
- package/dist/src/formats/xgmml/emit.js +112 -50
- package/dist/src/formats/xgmml/emit.js.map +1 -1
- package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
- package/dist/src/formats/xgmml/exporter.js +92 -34
- package/dist/src/formats/xgmml/exporter.js.map +1 -1
- package/dist/src/formats/xgmml/importer.d.ts.map +1 -1
- package/dist/src/formats/xgmml/importer.js +38 -18
- package/dist/src/formats/xgmml/importer.js.map +1 -1
- package/dist/src/sniff.js +109 -57
- package/dist/src/sniff.js.map +1 -1
- package/dist/xgmml.js +2 -2
- package/package.json +2 -2
- package/src/common/attributes.ts +59 -19
- package/src/common/input.ts +216 -102
- package/src/common/json-elements.ts +4 -2
- package/src/common/text.ts +24 -15
- package/src/common/xml.ts +2 -1
- package/src/common/zip.ts +47 -18
- package/src/formats/csv/exporter.ts +103 -39
- package/src/formats/csv/importer.ts +17 -6
- package/src/formats/csv/records.ts +162 -109
- package/src/formats/cx/importer.ts +140 -58
- package/src/formats/cx2/exporter.ts +2 -1
- package/src/formats/cx2/importer.ts +34 -10
- package/src/formats/cys/tables.ts +11 -10
- package/src/formats/gexf/exporter.ts +71 -38
- package/src/formats/gexf/importer.ts +173 -63
- package/src/formats/gml/exporter.ts +78 -82
- package/src/formats/gml/importer.ts +119 -68
- package/src/formats/gml/syntax.ts +18 -8
- package/src/formats/graphml/exporter.ts +46 -27
- package/src/formats/graphml/importer.ts +21 -13
- package/src/formats/graphml/tree.ts +22 -12
- package/src/formats/graphml/yfiles.ts +23 -10
- package/src/formats/json/exporter.ts +40 -21
- package/src/formats/json/importer.ts +701 -385
- package/src/formats/json/obographs.ts +35 -15
- package/src/formats/neo4j/exporter.ts +79 -41
- package/src/formats/neo4j/header.ts +50 -16
- package/src/formats/neo4j/importer.ts +21 -10
- package/src/formats/obo/exporter.ts +34 -17
- package/src/formats/pajek/exporter.ts +180 -117
- package/src/formats/pajek/importer.ts +27 -15
- package/src/formats/pajek/syntax.ts +99 -58
- package/src/formats/xgmml/emit.ts +122 -50
- package/src/formats/xgmml/exporter.ts +103 -35
- package/src/formats/xgmml/importer.ts +45 -23
- package/src/sniff.ts +115 -59
- package/dist/chunks/escape-BpYMQZVa.js.map +0 -1
- package/dist/chunks/export-B-aVCwyG.js.map +0 -1
- package/dist/chunks/exporter-BqKs1Q12.js.map +0 -1
- package/dist/chunks/exporter-CNJZF_BN.js.map +0 -1
- package/dist/chunks/exporter-DXqCPNrI.js.map +0 -1
- package/dist/chunks/importer-B7Ir269L.js.map +0 -1
- package/dist/chunks/importer-BfJ1jnNr.js.map +0 -1
- package/dist/chunks/importer-CSt-gaYE.js.map +0 -1
- package/dist/chunks/importer-CqgYq4Ld.js.map +0 -1
- package/dist/chunks/importer-DvFznt5-.js.map +0 -1
- package/dist/chunks/importer-PVXkeoaS.js.map +0 -1
- package/dist/chunks/records-C9jd7yLD.js.map +0 -1
- package/dist/chunks/text-Bjfa1xYL.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { INVALID_INDEX, GraphFormatError } from "@graphty/graph-format";
|
|
2
|
-
import { M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, O as OPTION_IGNORED_CODE, I as ID_MERGED_CODE, R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, ae as AMBIGUOUS_GRAPH_NAME_CODE, af as GRAPH_NOT_FOUND_CODE, l as MULTIPLE_GRAPHS_CODE, f as STRAY_TEXT_CODE, g as UNKNOWN_ELEMENT_CODE, U as UNKNOWN_ATTR_TYPE_CODE, b6 as EQUATION_AS_TEXT_CODE, ai as PARENT_CYCLE_CODE, q as UNKNOWN_PARENT_CODE, o as DUPLICATE_ATTRIBUTE_CODE, i as DANGLING_REFERENCE_CODE, P as PRECISION_CODE, aj as WIDENED_CODE, a3 as BAD_VALUE_CODE, m as DUPLICATE_EDGE_ID_CODE, n as DUPLICATE_NODE_CODE, s as MISSING_ENDPOINT_CODE, t as MISSING_ID_CODE, N as NO_GRAPH_CODE, v as ENCODING_CONFLICT_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, E as EMPTY_INPUT_CODE, X as XML_SYNTAX_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, bj as STORAGE_CLASS_CODE, bp as WEIGHT_KEY_CLASH_CODE, au as ROLE_ASSUMED_CODE, a$ as COLUMN_RENAMED_LOSS_CODE, J as ID_TEXT_TYPE_CODE, bc as MUTUAL_EXPANDED_CODE, Q as PARENTS_DROPPED_CODE, K as ROLE_DROPPED_CODE, bl as TEMPORAL_TEXT_DROPPED_CODE, bk as TEMPORAL_DROPPED_CODE, ax as XML_ILLEGAL_CHAR_CODE, a0 as uniqueColumnName, a1 as declareResolved, ac as DictHeuristic, ar as IdCoercer, aq as DirectionResolver, b as plural, $ as agree, am as throwIfAborted, aK as parseWeightText, ao as reportSinkOptions, an as reportUnusedOptions, a7 as chooseGraph, ap as graphChosen, al as resolveImportOptions, a8 as ImportReportBuilder, a4 as textChunks, c0 as elementCount } from "./export-
|
|
3
|
-
import { l as localName, a as escapeXmlText, j as isWhitespace, e as escapeXmlAttribute, t as tokenizeXml, f as xmlDeclaredEncoding, X as XmlSyntaxError } from "./escape-
|
|
4
|
-
import { p as parseTextCell, i as inferTextDtype } from "./text-
|
|
2
|
+
import { M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, O as OPTION_IGNORED_CODE, I as ID_MERGED_CODE, R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, ae as AMBIGUOUS_GRAPH_NAME_CODE, af as GRAPH_NOT_FOUND_CODE, l as MULTIPLE_GRAPHS_CODE, f as STRAY_TEXT_CODE, g as UNKNOWN_ELEMENT_CODE, U as UNKNOWN_ATTR_TYPE_CODE, b6 as EQUATION_AS_TEXT_CODE, ai as PARENT_CYCLE_CODE, q as UNKNOWN_PARENT_CODE, o as DUPLICATE_ATTRIBUTE_CODE, i as DANGLING_REFERENCE_CODE, P as PRECISION_CODE, aj as WIDENED_CODE, a3 as BAD_VALUE_CODE, m as DUPLICATE_EDGE_ID_CODE, n as DUPLICATE_NODE_CODE, s as MISSING_ENDPOINT_CODE, t as MISSING_ID_CODE, N as NO_GRAPH_CODE, v as ENCODING_CONFLICT_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, E as EMPTY_INPUT_CODE, X as XML_SYNTAX_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, bj as STORAGE_CLASS_CODE, bp as WEIGHT_KEY_CLASH_CODE, au as ROLE_ASSUMED_CODE, a$ as COLUMN_RENAMED_LOSS_CODE, J as ID_TEXT_TYPE_CODE, bc as MUTUAL_EXPANDED_CODE, Q as PARENTS_DROPPED_CODE, K as ROLE_DROPPED_CODE, bl as TEMPORAL_TEXT_DROPPED_CODE, bk as TEMPORAL_DROPPED_CODE, ax as XML_ILLEGAL_CHAR_CODE, a0 as uniqueColumnName, a1 as declareResolved, ac as DictHeuristic, ar as IdCoercer, aq as DirectionResolver, b as plural, $ as agree, am as throwIfAborted, aK as parseWeightText, ao as reportSinkOptions, an as reportUnusedOptions, a7 as chooseGraph, ap as graphChosen, al as resolveImportOptions, a8 as ImportReportBuilder, a4 as textChunks, c0 as elementCount } from "./export-DD3Lvw-F.js";
|
|
3
|
+
import { l as localName, a as escapeXmlText, j as isWhitespace, e as escapeXmlAttribute, t as tokenizeXml, f as xmlDeclaredEncoding, X as XmlSyntaxError } from "./escape-DBb8zuNE.js";
|
|
4
|
+
import { p as parseTextCell, i as inferTextDtype } from "./text-Bh9SaAob.js";
|
|
5
5
|
const FORMAT = "xgmml";
|
|
6
6
|
const EXTENSIONS = Object.freeze([".xgmml", ".xml"]);
|
|
7
7
|
const MIME_TYPES = Object.freeze(["application/xgmml", "text/xgmml", "text/xgmml+xml"]);
|
|
@@ -1747,6 +1747,9 @@ function parseCoordinate(text) {
|
|
|
1747
1747
|
function localRef(href) {
|
|
1748
1748
|
return href.startsWith("#") ? href.slice(1) : null;
|
|
1749
1749
|
}
|
|
1750
|
+
function memberRef(id, href) {
|
|
1751
|
+
return id ?? (href === null ? null : localRef(href));
|
|
1752
|
+
}
|
|
1750
1753
|
function membersOf(doc, graph) {
|
|
1751
1754
|
if (graph === null) {
|
|
1752
1755
|
return { nodes: doc.nodes, edges: doc.edges, dangling: 0 };
|
|
@@ -1757,19 +1760,7 @@ function membersOf(doc, graph) {
|
|
|
1757
1760
|
const edges = [];
|
|
1758
1761
|
let dangling = 0;
|
|
1759
1762
|
for (const member of graph.members) {
|
|
1760
|
-
|
|
1761
|
-
if (member.kind === "node") {
|
|
1762
|
-
nodes.push(member);
|
|
1763
|
-
} else {
|
|
1764
|
-
edges.push(member);
|
|
1765
|
-
}
|
|
1766
|
-
continue;
|
|
1767
|
-
}
|
|
1768
|
-
const id = localRef(member.href);
|
|
1769
|
-
let target;
|
|
1770
|
-
if (id !== null) {
|
|
1771
|
-
target = member.kind === "node" ? nodeById.get(id) : edgeById.get(id);
|
|
1772
|
-
}
|
|
1763
|
+
const target = resolveMember(member, nodeById, edgeById);
|
|
1773
1764
|
if (target === void 0) {
|
|
1774
1765
|
dangling++;
|
|
1775
1766
|
} else if (target.kind === "node") {
|
|
@@ -1780,6 +1771,16 @@ function membersOf(doc, graph) {
|
|
|
1780
1771
|
}
|
|
1781
1772
|
return { nodes, edges, dangling };
|
|
1782
1773
|
}
|
|
1774
|
+
function resolveMember(member, nodeById, edgeById) {
|
|
1775
|
+
if (member.href === null) {
|
|
1776
|
+
return member;
|
|
1777
|
+
}
|
|
1778
|
+
const id = localRef(member.href);
|
|
1779
|
+
if (id === null) {
|
|
1780
|
+
return void 0;
|
|
1781
|
+
}
|
|
1782
|
+
return member.kind === "node" ? nodeById.get(id) : edgeById.get(id);
|
|
1783
|
+
}
|
|
1783
1784
|
function indexById(records) {
|
|
1784
1785
|
const out = /* @__PURE__ */ new Map();
|
|
1785
1786
|
for (const record of records) {
|
|
@@ -1789,6 +1790,26 @@ function indexById(records) {
|
|
|
1789
1790
|
}
|
|
1790
1791
|
return out;
|
|
1791
1792
|
}
|
|
1793
|
+
function isRepeat(seen, record) {
|
|
1794
|
+
if (seen === null) {
|
|
1795
|
+
return false;
|
|
1796
|
+
}
|
|
1797
|
+
const key2 = record.id ?? (record.label === null ? null : JSON.stringify([record.label, record.source, record.target]));
|
|
1798
|
+
if (key2 === null) {
|
|
1799
|
+
return false;
|
|
1800
|
+
}
|
|
1801
|
+
if (seen.has(key2)) {
|
|
1802
|
+
return true;
|
|
1803
|
+
}
|
|
1804
|
+
seen.add(key2);
|
|
1805
|
+
return false;
|
|
1806
|
+
}
|
|
1807
|
+
function isGraphValueAtt(att) {
|
|
1808
|
+
if (att.name !== null && META_ATTS.has(att.name)) {
|
|
1809
|
+
return false;
|
|
1810
|
+
}
|
|
1811
|
+
return !(att.hasGraph && att.name === null);
|
|
1812
|
+
}
|
|
1792
1813
|
class XgmmlEmitter {
|
|
1793
1814
|
/**
|
|
1794
1815
|
* Create an emitter for one graph.
|
|
@@ -2036,10 +2057,16 @@ class XgmmlEmitter {
|
|
|
2036
2057
|
}
|
|
2037
2058
|
const lower = t.toLowerCase();
|
|
2038
2059
|
const readable = lower === "true" || lower === "yes" || lower === "false" || lower === "no";
|
|
2060
|
+
let readAs;
|
|
2061
|
+
if (readable) {
|
|
2062
|
+
readAs = lower === "true" || lower === "yes" ? "1" : "0";
|
|
2063
|
+
} else {
|
|
2064
|
+
readAs = fallback ? "directed" : "undirected";
|
|
2065
|
+
}
|
|
2039
2066
|
this.report.warnOnce(
|
|
2040
2067
|
"validation-error",
|
|
2041
2068
|
XGMML_ISSUE.BAD_DIRECTED,
|
|
2042
|
-
|
|
2069
|
+
`${this.prefix()}directed="${text}" is not 0 or 1; read as ${readAs}`,
|
|
2043
2070
|
where,
|
|
2044
2071
|
`${XGMML_ISSUE.BAD_DIRECTED}:${text}`
|
|
2045
2072
|
);
|
|
@@ -2156,16 +2183,7 @@ class XgmmlEmitter {
|
|
|
2156
2183
|
if (graph.owner !== null && isGroup(graph.owner)) {
|
|
2157
2184
|
continue;
|
|
2158
2185
|
}
|
|
2159
|
-
|
|
2160
|
-
if (member.href === null) {
|
|
2161
|
-
continue;
|
|
2162
|
-
}
|
|
2163
|
-
const id = localRef(member.href);
|
|
2164
|
-
const known = id !== null && (member.kind === "node" ? this.rows.has(id) : edgeIds.has(id));
|
|
2165
|
-
if (!known) {
|
|
2166
|
-
dangling++;
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2186
|
+
dangling += this.danglingReferences(graph, edgeIds);
|
|
2169
2187
|
}
|
|
2170
2188
|
if (dangling > 0) {
|
|
2171
2189
|
this.report.warning(
|
|
@@ -2175,6 +2193,26 @@ class XgmmlEmitter {
|
|
|
2175
2193
|
);
|
|
2176
2194
|
}
|
|
2177
2195
|
}
|
|
2196
|
+
/**
|
|
2197
|
+
* How many `xlink:href` members of a graph name no node or edge of the document.
|
|
2198
|
+
* @param graph - the graph
|
|
2199
|
+
* @param edgeIds - the id of every edge
|
|
2200
|
+
* @returns the count
|
|
2201
|
+
*/
|
|
2202
|
+
danglingReferences(graph, edgeIds) {
|
|
2203
|
+
let dangling = 0;
|
|
2204
|
+
for (const member of graph.members) {
|
|
2205
|
+
if (member.href === null) {
|
|
2206
|
+
continue;
|
|
2207
|
+
}
|
|
2208
|
+
const id = localRef(member.href);
|
|
2209
|
+
const known = id !== null && (member.kind === "node" ? this.rows.has(id) : edgeIds.has(id));
|
|
2210
|
+
if (!known) {
|
|
2211
|
+
dangling++;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
return dangling;
|
|
2215
|
+
}
|
|
2178
2216
|
/**
|
|
2179
2217
|
* Write the per-node values: label, attributes, XML attributes, graphics, positions, nested
|
|
2180
2218
|
* network pointers and subgraph memberships.
|
|
@@ -2305,17 +2343,17 @@ class XgmmlEmitter {
|
|
|
2305
2343
|
}
|
|
2306
2344
|
});
|
|
2307
2345
|
}
|
|
2308
|
-
/**
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2346
|
+
/**
|
|
2347
|
+
* The names of the subgraphs each node row is a member of.
|
|
2348
|
+
* @param subgraphs - the root-level subgraphs
|
|
2349
|
+
* @returns the subgraph names by node row index
|
|
2350
|
+
*/
|
|
2351
|
+
networkMembership(subgraphs) {
|
|
2314
2352
|
const member = /* @__PURE__ */ new Map();
|
|
2315
2353
|
for (const graph of subgraphs) {
|
|
2316
2354
|
const name = graph.id ?? graph.label ?? "";
|
|
2317
2355
|
for (const m of graph.members) {
|
|
2318
|
-
const id = m.kind === "node" ? m.id
|
|
2356
|
+
const id = m.kind === "node" ? memberRef(m.id, m.href) : null;
|
|
2319
2357
|
const row = id === null ? void 0 : this.rows.get(id);
|
|
2320
2358
|
if (row !== void 0 && row.index >= 0) {
|
|
2321
2359
|
const list = member.get(row.index) ?? [];
|
|
@@ -2324,6 +2362,15 @@ class XgmmlEmitter {
|
|
|
2324
2362
|
}
|
|
2325
2363
|
}
|
|
2326
2364
|
}
|
|
2365
|
+
return member;
|
|
2366
|
+
}
|
|
2367
|
+
/** The `xgmml.networks` membership of nodes in root-level subgraphs of a generic document. */
|
|
2368
|
+
writeNetworks() {
|
|
2369
|
+
const { subgraphs } = this.doc.root;
|
|
2370
|
+
if (subgraphs.length === 0) {
|
|
2371
|
+
return;
|
|
2372
|
+
}
|
|
2373
|
+
const member = this.networkMembership(subgraphs);
|
|
2327
2374
|
if (member.size === 0) {
|
|
2328
2375
|
return;
|
|
2329
2376
|
}
|
|
@@ -2358,14 +2405,10 @@ class XgmmlEmitter {
|
|
|
2358
2405
|
this.decideNameLabel("edge", records);
|
|
2359
2406
|
for (const record of records) {
|
|
2360
2407
|
const where = { line: record.line, element: record.id ?? record.label };
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
firstRepeat ??= where;
|
|
2366
|
-
continue;
|
|
2367
|
-
}
|
|
2368
|
-
dedupe.add(key2);
|
|
2408
|
+
if (isRepeat(dedupe, record)) {
|
|
2409
|
+
repeats++;
|
|
2410
|
+
firstRepeat ??= where;
|
|
2411
|
+
continue;
|
|
2369
2412
|
}
|
|
2370
2413
|
const index = this.addEdge(record, header, ids, where);
|
|
2371
2414
|
this.checkAbort();
|
|
@@ -2614,13 +2657,9 @@ class XgmmlEmitter {
|
|
|
2614
2657
|
}
|
|
2615
2658
|
}
|
|
2616
2659
|
for (const att of g.atts) {
|
|
2617
|
-
if (
|
|
2618
|
-
|
|
2619
|
-
}
|
|
2620
|
-
if (att.hasGraph && att.name === null) {
|
|
2621
|
-
continue;
|
|
2660
|
+
if (isGraphValueAtt(att)) {
|
|
2661
|
+
this.graphColumns.addAtt(0, att, where);
|
|
2622
2662
|
}
|
|
2623
|
-
this.graphColumns.addAtt(0, att, where);
|
|
2624
2663
|
}
|
|
2625
2664
|
this.graphColumns.write(this.sink, () => 0);
|
|
2626
2665
|
const json = { ...this.extras.graphJson };
|
|
@@ -3089,19 +3128,7 @@ function booleanOption(name, value, fallback) {
|
|
|
3089
3128
|
return value;
|
|
3090
3129
|
}
|
|
3091
3130
|
async function parseXgmml(input, report, common, options) {
|
|
3092
|
-
const repairs =
|
|
3093
|
-
bareAmpersand: booleanOption("repairBareAmpersands", options?.repairBareAmpersands, false) ? (line) => {
|
|
3094
|
-
report.warning("parse-error", XGMML_ISSUE.AMPERSAND_REPAIRED, "a bare & was read as &", { line });
|
|
3095
|
-
} : void 0,
|
|
3096
|
-
surrogatePair: booleanOption("pairSurrogateReferences", options?.pairSurrogateReferences, false) ? (line) => {
|
|
3097
|
-
report.warning(
|
|
3098
|
-
"parse-error",
|
|
3099
|
-
XGMML_ISSUE.SURROGATE_PAIRED,
|
|
3100
|
-
"two surrogate character references were joined into one character",
|
|
3101
|
-
{ line }
|
|
3102
|
-
);
|
|
3103
|
-
} : void 0
|
|
3104
|
-
};
|
|
3131
|
+
const repairs = repairsOf(options, report);
|
|
3105
3132
|
const parser = new XgmmlParser(report);
|
|
3106
3133
|
const seen = { content: false };
|
|
3107
3134
|
try {
|
|
@@ -3111,12 +3138,7 @@ async function parseXgmml(input, report, common, options) {
|
|
|
3111
3138
|
repairs
|
|
3112
3139
|
);
|
|
3113
3140
|
} catch (err) {
|
|
3114
|
-
|
|
3115
|
-
if (!seen.content) {
|
|
3116
|
-
report.fail(XGMML_ISSUE.EMPTY_INPUT, "the input is empty");
|
|
3117
|
-
}
|
|
3118
|
-
report.fail(XGMML_ISSUE.XML_SYNTAX, err.message, { line: err.line });
|
|
3119
|
-
}
|
|
3141
|
+
failOnSyntax(err, seen.content, report);
|
|
3120
3142
|
throw err;
|
|
3121
3143
|
}
|
|
3122
3144
|
const doc = parser.document();
|
|
@@ -3130,6 +3152,30 @@ async function parseXgmml(input, report, common, options) {
|
|
|
3130
3152
|
}
|
|
3131
3153
|
return doc;
|
|
3132
3154
|
}
|
|
3155
|
+
function repairsOf(options, report) {
|
|
3156
|
+
return {
|
|
3157
|
+
bareAmpersand: booleanOption("repairBareAmpersands", options?.repairBareAmpersands, false) ? (line) => {
|
|
3158
|
+
report.warning("parse-error", XGMML_ISSUE.AMPERSAND_REPAIRED, "a bare & was read as &", { line });
|
|
3159
|
+
} : void 0,
|
|
3160
|
+
surrogatePair: booleanOption("pairSurrogateReferences", options?.pairSurrogateReferences, false) ? (line) => {
|
|
3161
|
+
report.warning(
|
|
3162
|
+
"parse-error",
|
|
3163
|
+
XGMML_ISSUE.SURROGATE_PAIRED,
|
|
3164
|
+
"two surrogate character references were joined into one character",
|
|
3165
|
+
{ line }
|
|
3166
|
+
);
|
|
3167
|
+
} : void 0
|
|
3168
|
+
};
|
|
3169
|
+
}
|
|
3170
|
+
function failOnSyntax(err, content, report) {
|
|
3171
|
+
if (!(err instanceof XmlSyntaxError)) {
|
|
3172
|
+
return;
|
|
3173
|
+
}
|
|
3174
|
+
if (!content) {
|
|
3175
|
+
report.fail(XGMML_ISSUE.EMPTY_INPUT, "the input is empty");
|
|
3176
|
+
}
|
|
3177
|
+
report.fail(XGMML_ISSUE.XML_SYNTAX, err.message, { line: err.line });
|
|
3178
|
+
}
|
|
3133
3179
|
async function* watch(chunks, seen) {
|
|
3134
3180
|
for await (const chunk of chunks) {
|
|
3135
3181
|
seen.content ||= !isWhitespace(chunk);
|
|
@@ -3290,10 +3336,10 @@ export {
|
|
|
3290
3336
|
XLINK_NAMESPACE as b,
|
|
3291
3337
|
XGMML_NAMESPACE as c,
|
|
3292
3338
|
aliasesOf as d,
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3339
|
+
PARENT_COLUMN as e,
|
|
3340
|
+
PARENTS_COLUMN as f,
|
|
3341
|
+
NETWORK_POINTER_COLUMN as g,
|
|
3342
|
+
NETWORKS_COLUMN as h,
|
|
3297
3343
|
XGMML_ORIGIN_NAMESPACE as i,
|
|
3298
3344
|
CYTOSCAPE_ORIGIN_NAMESPACE as j,
|
|
3299
3345
|
XgmmlEmitter as k,
|
|
@@ -3305,4 +3351,4 @@ export {
|
|
|
3305
3351
|
resolveSettings as r,
|
|
3306
3352
|
xgmmlImporter as x
|
|
3307
3353
|
};
|
|
3308
|
-
//# sourceMappingURL=importer-
|
|
3354
|
+
//# sourceMappingURL=importer-DviEsHy4.js.map
|