@graphty/graph-io 0.3.18 → 0.3.19
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/README.md +37 -2
- package/dist/chunks/{escape-D-gZWO26.js → escape-CWExcecC.js} +3 -3
- package/dist/chunks/{escape-D-gZWO26.js.map → escape-CWExcecC.js.map} +1 -1
- package/dist/chunks/exporter-CbMZyVt-.js +735 -0
- package/dist/chunks/exporter-CbMZyVt-.js.map +1 -0
- package/dist/chunks/importer-BAP4PrxR.js +2194 -0
- package/dist/chunks/importer-BAP4PrxR.js.map +1 -0
- package/dist/chunks/{importer-Br_QeAeE.js → importer-BNFuV1-K.js} +5 -4
- package/dist/chunks/{importer-Br_QeAeE.js.map → importer-BNFuV1-K.js.map} +1 -1
- package/dist/chunks/{importer-d0uQxFp6.js → importer-BVGtU1NA.js} +5 -4
- package/dist/chunks/{importer-d0uQxFp6.js.map → importer-BVGtU1NA.js.map} +1 -1
- package/dist/chunks/{importer-DHagxvDD.js → importer-BW-Ft2ps.js} +5 -4
- package/dist/chunks/{importer-DHagxvDD.js.map → importer-BW-Ft2ps.js.map} +1 -1
- package/dist/chunks/{importer-Du5crN9l.js → importer-Bm1_5vPS.js} +275 -82
- package/dist/chunks/importer-Bm1_5vPS.js.map +1 -0
- package/dist/chunks/{importer-aNJfe0qu.js → importer-ByPGO-09.js} +2 -2
- package/dist/chunks/{importer-aNJfe0qu.js.map → importer-ByPGO-09.js.map} +1 -1
- package/dist/chunks/importer-DOepkgnG.js +1713 -0
- package/dist/chunks/importer-DOepkgnG.js.map +1 -0
- package/dist/chunks/json-elements-CZY1wiZh.js +779 -0
- package/dist/chunks/json-elements-CZY1wiZh.js.map +1 -0
- package/dist/chunks/{records-Bk9jgodz.js → records-BzNicMsf.js} +2 -2
- package/dist/chunks/{records-Bk9jgodz.js.map → records-BzNicMsf.js.map} +1 -1
- package/dist/chunks/{report-BOk0p5y8.js → report-BcWboivV.js} +95 -95
- package/dist/chunks/{report-BOk0p5y8.js.map → report-BcWboivV.js.map} +1 -1
- package/dist/chunks/weights-CwISIpCP.js +176 -0
- package/dist/chunks/weights-CwISIpCP.js.map +1 -0
- package/dist/chunks/{writer-GAdltGmC.js → writer-DQiKgQJc.js} +8 -179
- package/dist/chunks/writer-DQiKgQJc.js.map +1 -0
- package/dist/csv.js +5 -4
- package/dist/csv.js.map +1 -1
- package/dist/cx.d.ts +1 -0
- package/dist/cx.js +6 -0
- package/dist/cx.js.map +1 -0
- package/dist/cx2.d.ts +1 -0
- package/dist/cx2.js +10 -0
- package/dist/cx2.js.map +1 -0
- package/dist/dot.js +1 -1
- package/dist/gexf.js +15 -4
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +5 -4
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +145 -389
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +1 -1
- package/dist/json.js +1 -1
- package/dist/neo4j.js +5 -4
- package/dist/neo4j.js.map +1 -1
- package/dist/obo.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/common/json-elements.d.ts +286 -0
- package/dist/src/common/json-elements.d.ts.map +1 -0
- package/dist/src/common/json-elements.js +926 -0
- package/dist/src/common/json-elements.js.map +1 -0
- package/dist/src/formats/cx/importer.d.ts +133 -0
- package/dist/src/formats/cx/importer.d.ts.map +1 -0
- package/dist/src/formats/cx/importer.js +2220 -0
- package/dist/src/formats/cx/importer.js.map +1 -0
- package/dist/src/formats/cx/index.d.ts +7 -0
- package/dist/src/formats/cx/index.d.ts.map +1 -0
- package/dist/src/formats/cx/index.js +7 -0
- package/dist/src/formats/cx/index.js.map +1 -0
- package/dist/src/formats/cx2/exporter.d.ts +59 -0
- package/dist/src/formats/cx2/exporter.d.ts.map +1 -0
- package/dist/src/formats/cx2/exporter.js +864 -0
- package/dist/src/formats/cx2/exporter.js.map +1 -0
- package/dist/src/formats/cx2/importer.d.ts +169 -0
- package/dist/src/formats/cx2/importer.d.ts.map +1 -0
- package/dist/src/formats/cx2/importer.js +1652 -0
- package/dist/src/formats/cx2/importer.js.map +1 -0
- package/dist/src/formats/cx2/index.d.ts +7 -0
- package/dist/src/formats/cx2/index.d.ts.map +1 -0
- package/dist/src/formats/cx2/index.js +7 -0
- package/dist/src/formats/cx2/index.js.map +1 -0
- package/dist/src/formats/gexf/exporter.d.ts +2 -0
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +6 -0
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gexf/importer.d.ts +2 -4
- package/dist/src/formats/gexf/importer.d.ts.map +1 -1
- package/dist/src/formats/gexf/importer.js +2 -4
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gexf/index.d.ts +1 -1
- package/dist/src/formats/gexf/index.js +2 -2
- package/dist/src/formats/gexf/index.js.map +1 -1
- package/dist/src/formats/gml/exporter.js +1 -1
- package/dist/src/formats/gml/exporter.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +6 -104
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +5 -0
- package/dist/src/registry.js.map +1 -1
- package/dist/src/sniff.d.ts +1 -1
- package/dist/src/sniff.d.ts.map +1 -1
- package/dist/src/sniff.js +2 -0
- package/dist/src/sniff.js.map +1 -1
- package/package.json +11 -1
- package/src/common/json-elements.ts +1147 -0
- package/src/formats/cx/importer.ts +2733 -0
- package/src/formats/cx/index.ts +7 -0
- package/src/formats/cx2/exporter.ts +1036 -0
- package/src/formats/cx2/importer.ts +2187 -0
- package/src/formats/cx2/index.ts +7 -0
- package/src/formats/gexf/exporter.ts +11 -0
- package/src/formats/gexf/importer.ts +2 -2
- package/src/formats/gexf/index.ts +1 -1
- package/src/formats/gml/exporter.ts +1 -1
- package/src/formats/json/importer.ts +6 -105
- package/src/index.ts +10 -0
- package/src/registry.ts +5 -0
- package/src/sniff.ts +14 -1
- package/dist/chunks/importer-Du5crN9l.js.map +0 -1
- package/dist/chunks/writer-GAdltGmC.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@graphty/graph-io/cx2` subpath (design/graph-io/cytoscape-and-obo/design.md section 1.3):
|
|
3
|
+
* the CX2 importer and exporter with their option types and code tables.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { CX2_CAPABILITIES, CX2_LOSS, cx2Exporter, type Cx2ExportOptions } from "./exporter.js";
|
|
7
|
+
export { CX2_ISSUE, cx2Importer, type Cx2ImportOptions } from "./importer.js";
|
|
@@ -73,6 +73,8 @@ export const GEXF_LOSS = Object.freeze({
|
|
|
73
73
|
DECLARED_TYPE: "W_DECLARED_TYPE",
|
|
74
74
|
/** A node id whose text reads back as the other type under the canonical rule (design section 4.1): a non-integer number, a string of integer text. */
|
|
75
75
|
ID_TEXT_TYPE: LOSS.ID_TEXT_TYPE,
|
|
76
|
+
/** A numeric edge id column: GEXF edge ids read back as strings. */
|
|
77
|
+
EDGE_ID_TEXT: "W_GEXF_EDGE_ID_TEXT",
|
|
76
78
|
/** A viz role column (position, color, size, thickness) that is not f32; the importer reads viz values as f32. */
|
|
77
79
|
VIZ_DTYPE: "W_GEXF_VIZ_DTYPE",
|
|
78
80
|
/** A plain `weight` edge column reads back as THE weight (the importer's weightFrom default). */
|
|
@@ -267,6 +269,15 @@ function planExport(
|
|
|
267
269
|
typeChanges,
|
|
268
270
|
);
|
|
269
271
|
}
|
|
272
|
+
const edgeIds = snapshot.edges.byRole("id");
|
|
273
|
+
if (edgeIds !== null && edgeIds.dtype !== "string" && edgeIds.dtype !== "dict") {
|
|
274
|
+
note(
|
|
275
|
+
GEXF_LOSS.EDGE_ID_TEXT,
|
|
276
|
+
`edge id column "${edgeIds.meta.name}" is ${edgeIds.dtype}; GEXF edge ids read back as strings`,
|
|
277
|
+
edgeIds.meta.name,
|
|
278
|
+
snapshot.edgeCount - edgeIds.nullCount,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
270
281
|
const tables = collectTemporalTables(snapshot, version, note);
|
|
271
282
|
const nodeRoles = collectRoles(snapshot.nodes, "node", note);
|
|
272
283
|
const edgeRoles = collectRoles(snapshot.edges, "edge", note);
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
} from "../../common/attributes.js";
|
|
52
52
|
import {
|
|
53
53
|
COUNT_HINT_CODE,
|
|
54
|
+
DUPLICATE_ATTRIBUTE_CODE,
|
|
54
55
|
DUPLICATE_EDGE_ID_CODE,
|
|
55
56
|
DUPLICATE_NODE_CODE,
|
|
56
57
|
ID_MERGED_CODE,
|
|
@@ -122,8 +123,6 @@ export const ATTRIBUTES_CLASS_CODE = "E_GEXF_ATTRIBUTES_CLASS";
|
|
|
122
123
|
export const ATTRIBUTE_ID_CODE = "E_GEXF_ATTRIBUTE_ID";
|
|
123
124
|
/** Issue code: a graph header value (`defaultedgetype`, `mode`, `timeformat`, ...) outside its set. */
|
|
124
125
|
export const HEADER_VALUE_CODE = "W_GEXF_HEADER_VALUE";
|
|
125
|
-
/** Issue code: a second `<attribute>` with the same id in the same class (the first is kept). */
|
|
126
|
-
export const DUPLICATE_ATTRIBUTE_CODE = "W_GEXF_DUPLICATE_ATTRIBUTE";
|
|
127
126
|
/** Issue code: an `<attribute>` without a type (read as string). */
|
|
128
127
|
export const ATTRIBUTE_TYPE_CODE = "W_GEXF_ATTRIBUTE_TYPE";
|
|
129
128
|
/** Issue code: an `<attvalue>` naming an attribute the document never declares (once per id). */
|
|
@@ -149,6 +148,7 @@ export const VIZ_VALUE_CODE = "W_GEXF_VIZ_VALUE";
|
|
|
149
148
|
export const OPEN_BOUND_CONFLICT_CODE = "W_GEXF_OPEN_BOUND_CONFLICT";
|
|
150
149
|
|
|
151
150
|
export {
|
|
151
|
+
DUPLICATE_ATTRIBUTE_CODE,
|
|
152
152
|
DUPLICATE_NODE_CODE,
|
|
153
153
|
ID_MERGED_CODE,
|
|
154
154
|
MISSING_ENDPOINT_CODE,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
COUNT_HINT_CODE,
|
|
12
12
|
DIRECTION_FORCED_CODE,
|
|
13
13
|
DIRECTION_REFUSED_CODE,
|
|
14
|
+
DUPLICATE_ATTRIBUTE_CODE,
|
|
14
15
|
DUPLICATE_EDGE_ID_CODE,
|
|
15
16
|
DUPLICATE_NODE_CODE,
|
|
16
17
|
ENCODING_FALLBACK_CODE,
|
|
@@ -37,7 +38,6 @@ import {
|
|
|
37
38
|
ATTRIBUTE_TYPE_CODE,
|
|
38
39
|
ATTRIBUTES_CLASS_CODE,
|
|
39
40
|
ATTVALUE_SHAPE_CODE,
|
|
40
|
-
DUPLICATE_ATTRIBUTE_CODE,
|
|
41
41
|
EDGE_TYPE_CODE,
|
|
42
42
|
HEADER_VALUE_CODE,
|
|
43
43
|
MISSING_NODES_CODE,
|
|
@@ -140,7 +140,7 @@ const SKIPPED_ROLES: ReadonlySet<string> = new Set([
|
|
|
140
140
|
]);
|
|
141
141
|
|
|
142
142
|
const NODE_RESERVED: ReadonlySet<string> = new Set(["id"]);
|
|
143
|
-
const EDGE_RESERVED: ReadonlySet<string> = new Set(["source", "target"]);
|
|
143
|
+
const EDGE_RESERVED: ReadonlySet<string> = new Set(["source", "target", "directed"]);
|
|
144
144
|
const GRAPH_RESERVED: ReadonlySet<string> = new Set(["node", "edge", "directed", "multigraph"]);
|
|
145
145
|
const TOP_RESERVED: ReadonlySet<string> = new Set(["graph"]);
|
|
146
146
|
const NUMBER_TEXT = /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
|
|
@@ -66,6 +66,7 @@ import {
|
|
|
66
66
|
import { DirectionResolver, type EdgeKind } from "../../common/direction.js";
|
|
67
67
|
import { ID_MERGED_CODE, IdCoercer } from "../../common/ids.js";
|
|
68
68
|
import { readText, textChunks, throwIfAborted } from "../../common/input.js";
|
|
69
|
+
import { MAYBE_UNSAFE_INTEGER, reviveNonstandard, rewriteNumbers } from "../../common/json-elements.js";
|
|
69
70
|
import {
|
|
70
71
|
chooseGraph,
|
|
71
72
|
type ImportFormatDefaults,
|
|
@@ -77,6 +78,7 @@ import {
|
|
|
77
78
|
} from "../../common/options.js";
|
|
78
79
|
import { ImportReportBuilder } from "../../common/report.js";
|
|
79
80
|
import { weightFromValue } from "../../common/weights.js";
|
|
81
|
+
import { sniffJsonDialectHead } from "../../sniff.js";
|
|
80
82
|
import {
|
|
81
83
|
type CommonImportOptions,
|
|
82
84
|
type GraphChoiceOptions,
|
|
@@ -1272,113 +1274,9 @@ function parseDocument(text: string, report: ImportReportBuilder): unknown {
|
|
|
1272
1274
|
return root;
|
|
1273
1275
|
}
|
|
1274
1276
|
|
|
1275
|
-
/** A run of 16 digits not inside a fraction: the shortest integer literal that can exceed 2^53 (9007199254740992). */
|
|
1276
|
-
const MAYBE_UNSAFE_INTEGER = /(?<![0-9.])[0-9]{16}/;
|
|
1277
|
-
|
|
1278
1277
|
/** How many of the integers kept as text the warning lists. */
|
|
1279
1278
|
const BIG_INTEGERS_SHOWN = 10;
|
|
1280
1279
|
|
|
1281
|
-
/**
|
|
1282
|
-
* The prefix of the string a non-standard token is rewritten to (a NUL character first, which no
|
|
1283
|
-
* sensible attribute value starts with); reviveNonstandard() turns it back into the number.
|
|
1284
|
-
*/
|
|
1285
|
-
const NONSTANDARD_SENTINEL = `${String.fromCharCode(0)}graph-io:`;
|
|
1286
|
-
|
|
1287
|
-
/** The non-standard tokens Python's json module writes, longest first so -Infinity wins over a bare minus. */
|
|
1288
|
-
const NONSTANDARD_TOKENS: readonly (readonly [string, number])[] = [
|
|
1289
|
-
["-Infinity", -Infinity],
|
|
1290
|
-
["Infinity", Infinity],
|
|
1291
|
-
["NaN", NaN],
|
|
1292
|
-
];
|
|
1293
|
-
|
|
1294
|
-
/** A JSON integer literal (no fraction, no exponent, no leading zero), as CANONICAL_INTEGER in common/ids.ts. */
|
|
1295
|
-
const INTEGER_LITERAL = /^-?(0|[1-9][0-9]*)$/;
|
|
1296
|
-
|
|
1297
|
-
/**
|
|
1298
|
-
* Rewrite the numbers JSON.parse cannot read exactly, outside strings and in value positions only:
|
|
1299
|
-
* NaN / Infinity / -Infinity become sentinel strings, an integer literal that is not a safe
|
|
1300
|
-
* integer becomes a string of its digits. A container stack tells a value position (after `:`,
|
|
1301
|
-
* `[`, or `,` inside an array) from a key position, so `{NaN: 1}` stays invalid.
|
|
1302
|
-
* @param text - the document text
|
|
1303
|
-
* @returns the rewritten text, the non-standard tokens seen and the integer literals quoted
|
|
1304
|
-
*/
|
|
1305
|
-
function rewriteNumbers(text: string): { text: string; tokens: Set<string>; bigIntegers: string[] } {
|
|
1306
|
-
const parts: string[] = [];
|
|
1307
|
-
const tokens = new Set<string>();
|
|
1308
|
-
const bigIntegers: string[] = [];
|
|
1309
|
-
const arrays: boolean[] = [];
|
|
1310
|
-
let expectValue = true;
|
|
1311
|
-
let copied = 0;
|
|
1312
|
-
let i = 0;
|
|
1313
|
-
const n = text.length;
|
|
1314
|
-
while (i < n) {
|
|
1315
|
-
const ch = text[i];
|
|
1316
|
-
if (ch === '"') {
|
|
1317
|
-
i++;
|
|
1318
|
-
while (i < n && text[i] !== '"') {
|
|
1319
|
-
i += text[i] === "\\" ? 2 : 1;
|
|
1320
|
-
}
|
|
1321
|
-
i++;
|
|
1322
|
-
expectValue = false;
|
|
1323
|
-
continue;
|
|
1324
|
-
}
|
|
1325
|
-
if (ch === "{" || ch === "[") {
|
|
1326
|
-
arrays.push(ch === "[");
|
|
1327
|
-
expectValue = ch === "[";
|
|
1328
|
-
} else if (ch === "}" || ch === "]") {
|
|
1329
|
-
arrays.pop();
|
|
1330
|
-
expectValue = false;
|
|
1331
|
-
} else if (ch === ":") {
|
|
1332
|
-
expectValue = true;
|
|
1333
|
-
} else if (ch === ",") {
|
|
1334
|
-
expectValue = arrays.length > 0 && arrays[arrays.length - 1];
|
|
1335
|
-
} else if (expectValue && ch !== " " && ch !== "\t" && ch !== "\n" && ch !== "\r") {
|
|
1336
|
-
expectValue = false;
|
|
1337
|
-
const token = NONSTANDARD_TOKENS.find(([word]) => text.startsWith(word, i));
|
|
1338
|
-
let end = i;
|
|
1339
|
-
let replacement: string | null = null;
|
|
1340
|
-
if (token !== undefined) {
|
|
1341
|
-
end = i + token[0].length;
|
|
1342
|
-
tokens.add(token[0]);
|
|
1343
|
-
replacement = JSON.stringify(`${NONSTANDARD_SENTINEL}${token[0]}`);
|
|
1344
|
-
} else if (ch === "-" || (ch >= "0" && ch <= "9")) {
|
|
1345
|
-
end = i + 1;
|
|
1346
|
-
while (end < n && "0123456789+-.eE".includes(text[end])) {
|
|
1347
|
-
end++;
|
|
1348
|
-
}
|
|
1349
|
-
const literal = text.slice(i, end);
|
|
1350
|
-
if (INTEGER_LITERAL.test(literal) && !Number.isSafeInteger(Number(literal))) {
|
|
1351
|
-
bigIntegers.push(literal);
|
|
1352
|
-
replacement = `"${literal}"`;
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
if (replacement !== null) {
|
|
1356
|
-
parts.push(text.slice(copied, i), replacement);
|
|
1357
|
-
copied = end;
|
|
1358
|
-
}
|
|
1359
|
-
i = Math.max(end, i + 1);
|
|
1360
|
-
continue;
|
|
1361
|
-
}
|
|
1362
|
-
i++;
|
|
1363
|
-
}
|
|
1364
|
-
parts.push(text.slice(copied));
|
|
1365
|
-
return { text: parts.join(""), tokens, bigIntegers };
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
/**
|
|
1369
|
-
* The JSON.parse reviver that turns the sentinel strings of rewriteNumbers() back into numbers.
|
|
1370
|
-
* @param _key - the member key (unused)
|
|
1371
|
-
* @param value - the parsed value
|
|
1372
|
-
* @returns the number for a sentinel string, the value otherwise
|
|
1373
|
-
*/
|
|
1374
|
-
function reviveNonstandard(_key: string, value: unknown): unknown {
|
|
1375
|
-
if (typeof value === "string" && value.startsWith(NONSTANDARD_SENTINEL)) {
|
|
1376
|
-
const found = NONSTANDARD_TOKENS.find(([word]) => word === value.slice(NONSTANDARD_SENTINEL.length));
|
|
1377
|
-
return found === undefined ? value : found[1];
|
|
1378
|
-
}
|
|
1379
|
-
return value;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
1280
|
/**
|
|
1383
1281
|
* The dialect to read: the forced one, else the shape rule of sniffJsonDialect(); a document
|
|
1384
1282
|
* that matches no dialect is a fatal E_JSON_DIALECT.
|
|
@@ -2979,7 +2877,10 @@ export const jsonImporter: GraphImporter<JsonImportOptions> = Object.freeze({
|
|
|
2979
2877
|
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
|
|
2980
2878
|
return 0;
|
|
2981
2879
|
}
|
|
2982
|
-
|
|
2880
|
+
const score = SNIFF_KEYS.some((key) => trimmed.includes(key)) ? 0.9 : 0.5;
|
|
2881
|
+
// a top-level array is a graph only as Cytoscape.js elements (`[{"data": ...}]`): a CX or
|
|
2882
|
+
// CX2 document (`[{"metaData": ...}]`, `[{"CXVersion": ...}]`) is another format's
|
|
2883
|
+
return trimmed.startsWith("[") && sniffJsonDialectHead(trimmed) !== "cytoscape" ? Math.min(score, 0.3) : score;
|
|
2983
2884
|
},
|
|
2984
2885
|
|
|
2985
2886
|
/**
|
package/src/index.ts
CHANGED
|
@@ -76,6 +76,16 @@ export {
|
|
|
76
76
|
csvImporter,
|
|
77
77
|
type CsvImportOptions,
|
|
78
78
|
} from "./formats/csv/index.js";
|
|
79
|
+
export { CX_ISSUE, cxImporter, type CxImportOptions } from "./formats/cx/index.js";
|
|
80
|
+
export {
|
|
81
|
+
CX2_CAPABILITIES,
|
|
82
|
+
CX2_ISSUE,
|
|
83
|
+
CX2_LOSS,
|
|
84
|
+
cx2Exporter,
|
|
85
|
+
type Cx2ExportOptions,
|
|
86
|
+
cx2Importer,
|
|
87
|
+
type Cx2ImportOptions,
|
|
88
|
+
} from "./formats/cx2/index.js";
|
|
79
89
|
export {
|
|
80
90
|
DOT_ISSUE,
|
|
81
91
|
DOT_LOSS,
|
package/src/registry.ts
CHANGED
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
import { throwIfAborted } from "./common/input.js";
|
|
20
20
|
import { ImportReportBuilder } from "./common/report.js";
|
|
21
21
|
import { csvExporter, csvImporter } from "./formats/csv/index.js";
|
|
22
|
+
import { cxImporter } from "./formats/cx/index.js";
|
|
23
|
+
import { cx2Exporter, cx2Importer } from "./formats/cx2/index.js";
|
|
22
24
|
import { dotExporter, dotImporter } from "./formats/dot/index.js";
|
|
23
25
|
import { gexfExporter, gexfImporter } from "./formats/gexf/index.js";
|
|
24
26
|
import { gmlExporter, gmlImporter } from "./formats/gml/index.js";
|
|
@@ -374,6 +376,9 @@ export function createRegistry(): FormatRegistry {
|
|
|
374
376
|
.registerExporter(pajekExporter)
|
|
375
377
|
.registerImporter(neo4jImporter)
|
|
376
378
|
.registerExporter(neo4jExporter)
|
|
379
|
+
.registerImporter(cx2Importer)
|
|
380
|
+
.registerExporter(cx2Exporter)
|
|
381
|
+
.registerImporter(cxImporter)
|
|
377
382
|
.registerImporter(oboImporter);
|
|
378
383
|
}
|
|
379
384
|
|
package/src/sniff.ts
CHANGED
|
@@ -25,7 +25,18 @@ import { type JsonImportDialect, sniffJsonDialect } from "./formats/json/dialect
|
|
|
25
25
|
import { type GraphImporter } from "./types.js";
|
|
26
26
|
|
|
27
27
|
/** The format names of the eight built-in importers and exporters. */
|
|
28
|
-
export type GraphFormatName =
|
|
28
|
+
export type GraphFormatName =
|
|
29
|
+
| "gexf"
|
|
30
|
+
| "graphml"
|
|
31
|
+
| "gml"
|
|
32
|
+
| "dot"
|
|
33
|
+
| "pajek"
|
|
34
|
+
| "csv"
|
|
35
|
+
| "json"
|
|
36
|
+
| "neo4j"
|
|
37
|
+
| "cx2"
|
|
38
|
+
| "cx"
|
|
39
|
+
| "obo";
|
|
29
40
|
|
|
30
41
|
/**
|
|
31
42
|
* The built-in format names in the default registry's order, which is also the tie-break order of
|
|
@@ -41,6 +52,8 @@ export const GRAPH_FORMATS: readonly GraphFormatName[] = Object.freeze([
|
|
|
41
52
|
"dot",
|
|
42
53
|
"pajek",
|
|
43
54
|
"neo4j",
|
|
55
|
+
"cx2",
|
|
56
|
+
"cx",
|
|
44
57
|
"obo",
|
|
45
58
|
]);
|
|
46
59
|
|