@graphty/graph-io 0.2.4 → 0.3.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.
- package/README.md +29 -7
- package/dist/chunks/{escape-DyI8JofU.js → escape-CKied3Ri.js} +16 -10
- package/dist/chunks/escape-CKied3Ri.js.map +1 -0
- package/dist/chunks/{importer-DbnGYr3_.js → importer-C6QcIRIb.js} +129 -39
- package/dist/chunks/importer-C6QcIRIb.js.map +1 -0
- package/dist/chunks/{importer-CpCpfbxr.js → importer-D5pAsweZ.js} +136 -31
- package/dist/chunks/importer-D5pAsweZ.js.map +1 -0
- package/dist/chunks/{importer-GozH8DkN.js → importer-DbMrAR_w.js} +10 -4
- package/dist/chunks/importer-DbMrAR_w.js.map +1 -0
- package/dist/chunks/{importer-CQnJuWJw.js → importer-DkzjTvHc.js} +82 -40
- package/dist/chunks/importer-DkzjTvHc.js.map +1 -0
- package/dist/chunks/{records-CGpxszm1.js → records-BKSMowhR.js} +3 -3
- package/dist/chunks/{records-CGpxszm1.js.map → records-BKSMowhR.js.map} +1 -1
- package/dist/chunks/{text-CajMdVFy.js → text-Dr0Ifpag.js} +2 -2
- package/dist/chunks/{text-CajMdVFy.js.map → text-Dr0Ifpag.js.map} +1 -1
- package/dist/chunks/{writer-DxSKC7TL.js → writer-BdMak4_J.js} +341 -112
- package/dist/chunks/writer-BdMak4_J.js.map +1 -0
- package/dist/csv.js +24 -6
- package/dist/csv.js.map +1 -1
- package/dist/dot.js +1 -1
- package/dist/gexf.js +42 -10
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +69 -25
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +186 -129
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +1 -1
- package/dist/json.js +1 -1
- package/dist/neo4j.js +10 -4
- package/dist/neo4j.js.map +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/common/codes.d.ts +6 -0
- package/dist/src/common/codes.d.ts.map +1 -1
- package/dist/src/common/codes.js +6 -0
- package/dist/src/common/codes.js.map +1 -1
- package/dist/src/common/escape.d.ts +5 -4
- package/dist/src/common/escape.d.ts.map +1 -1
- package/dist/src/common/escape.js +6 -5
- package/dist/src/common/escape.js.map +1 -1
- package/dist/src/common/format.d.ts +3 -3
- package/dist/src/common/format.js +5 -5
- package/dist/src/common/format.js.map +1 -1
- package/dist/src/common/input.d.ts +24 -6
- package/dist/src/common/input.d.ts.map +1 -1
- package/dist/src/common/input.js +259 -23
- package/dist/src/common/input.js.map +1 -1
- package/dist/src/common/options.d.ts +2 -0
- package/dist/src/common/options.d.ts.map +1 -1
- package/dist/src/common/options.js +17 -0
- package/dist/src/common/options.js.map +1 -1
- package/dist/src/common/text.js +4 -4
- package/dist/src/common/text.js.map +1 -1
- package/dist/src/common/weights.d.ts.map +1 -1
- package/dist/src/common/weights.js +8 -0
- package/dist/src/common/weights.js.map +1 -1
- package/dist/src/common/xml.d.ts +7 -0
- package/dist/src/common/xml.d.ts.map +1 -1
- package/dist/src/common/xml.js +12 -0
- package/dist/src/common/xml.js.map +1 -1
- package/dist/src/formats/csv/exporter.d.ts +5 -1
- package/dist/src/formats/csv/exporter.d.ts.map +1 -1
- package/dist/src/formats/csv/exporter.js +8 -1
- 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 +1 -0
- package/dist/src/formats/csv/importer.js.map +1 -1
- package/dist/src/formats/csv/index.d.ts +6 -0
- package/dist/src/formats/csv/index.d.ts.map +1 -1
- package/dist/src/formats/csv/index.js +7 -1
- package/dist/src/formats/csv/index.js.map +1 -1
- package/dist/src/formats/csv/records.js +1 -1
- package/dist/src/formats/csv/records.js.map +1 -1
- package/dist/src/formats/dot/exporter.d.ts +1 -1
- package/dist/src/formats/dot/exporter.d.ts.map +1 -1
- package/dist/src/formats/dot/exporter.js +3 -3
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/dot/importer.d.ts +6 -0
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +151 -24
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +32 -7
- 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 +2 -2
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gexf/index.d.ts +6 -0
- package/dist/src/formats/gexf/index.d.ts.map +1 -1
- package/dist/src/formats/gexf/index.js +7 -1
- package/dist/src/formats/gexf/index.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts +2 -2
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +66 -25
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/gml/index.d.ts +7 -1
- package/dist/src/formats/gml/index.d.ts.map +1 -1
- package/dist/src/formats/gml/index.js +8 -2
- package/dist/src/formats/gml/index.js.map +1 -1
- package/dist/src/formats/graphml/constants.d.ts +6 -0
- package/dist/src/formats/graphml/constants.d.ts.map +1 -1
- package/dist/src/formats/graphml/constants.js +7 -1
- package/dist/src/formats/graphml/constants.js.map +1 -1
- package/dist/src/formats/graphml/importer.d.ts.map +1 -1
- package/dist/src/formats/graphml/importer.js +2 -2
- package/dist/src/formats/graphml/importer.js.map +1 -1
- package/dist/src/formats/json/exporter.d.ts.map +1 -1
- package/dist/src/formats/json/exporter.js +14 -5
- package/dist/src/formats/json/exporter.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts +8 -0
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +84 -37
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/neo4j/importer.js +1 -1
- package/dist/src/formats/neo4j/importer.js.map +1 -1
- package/dist/src/formats/neo4j/index.d.ts +6 -0
- package/dist/src/formats/neo4j/index.d.ts.map +1 -1
- package/dist/src/formats/neo4j/index.js +7 -1
- package/dist/src/formats/neo4j/index.js.map +1 -1
- package/dist/src/formats/pajek/exporter.d.ts +2 -0
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +13 -2
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/pajek/importer.d.ts +8 -2
- package/dist/src/formats/pajek/importer.d.ts.map +1 -1
- package/dist/src/formats/pajek/importer.js +122 -26
- package/dist/src/formats/pajek/importer.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/registry.d.ts +26 -0
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +101 -35
- 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 +6 -1
- package/dist/src/sniff.js.map +1 -1
- package/dist/src/types.d.ts +22 -3
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +4 -3
- package/src/common/codes.ts +9 -0
- package/src/common/escape.ts +6 -5
- package/src/common/format.ts +5 -5
- package/src/common/input.ts +293 -22
- package/src/common/options.ts +24 -0
- package/src/common/text.ts +4 -4
- package/src/common/weights.ts +9 -0
- package/src/common/xml.ts +14 -0
- package/src/formats/csv/exporter.ts +12 -1
- package/src/formats/csv/importer.ts +1 -0
- package/src/formats/csv/index.ts +9 -0
- package/src/formats/csv/records.ts +1 -1
- package/src/formats/dot/exporter.ts +3 -3
- package/src/formats/dot/importer.ts +172 -32
- package/src/formats/gexf/exporter.ts +38 -7
- package/src/formats/gexf/importer.ts +12 -2
- package/src/formats/gexf/index.ts +9 -0
- package/src/formats/gml/importer.ts +75 -22
- package/src/formats/gml/index.ts +10 -1
- package/src/formats/graphml/constants.ts +9 -0
- package/src/formats/graphml/importer.ts +9 -2
- package/src/formats/json/exporter.ts +14 -5
- package/src/formats/json/importer.ts +104 -36
- package/src/formats/neo4j/importer.ts +1 -1
- package/src/formats/neo4j/index.ts +9 -0
- package/src/formats/pajek/exporter.ts +19 -2
- package/src/formats/pajek/importer.ts +145 -28
- package/src/index.ts +1 -0
- package/src/registry.ts +131 -40
- package/src/sniff.ts +6 -1
- package/src/types.ts +26 -3
- package/dist/chunks/escape-DyI8JofU.js.map +0 -1
- package/dist/chunks/importer-CQnJuWJw.js.map +0 -1
- package/dist/chunks/importer-CpCpfbxr.js.map +0 -1
- package/dist/chunks/importer-DbnGYr3_.js.map +0 -1
- package/dist/chunks/importer-GozH8DkN.js.map +0 -1
- package/dist/chunks/writer-DxSKC7TL.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
package/dist/dot.js
CHANGED
package/dist/gexf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aM as TIME_TEXT_ROLE, aN as TIME_TEXT_SUFFIX, aF as resolveImportOptions, I as ImportReportBuilder, aC as reportSinkOptions, aD as reportUnusedOptions, t as textChunks, aa as XML_SYNTAX_CODE, a as throwIfAborted, v as IdCoercer, l as DirectionResolver, _ as STRAY_TEXT_CODE, K as NO_GRAPH_CODE, d as COUNT_HINT_CODE, aw as isWeightField, aO as declareAttribute, ai as declareResolved, y as MISSING_ID_CODE, k as DUPLICATE_NODE_CODE, a6 as UNKNOWN_PARENT_CODE, M as MISSING_ENDPOINT_CODE, i as DUPLICATE_EDGE_ID_CODE, aA as parseWeightText, aP as parseDeclaredTemporal, ah as declareCompanion, aQ as parseDeclaredValue, aR as losesPrecision, T as PRECISION_CODE, aS as parseTimeText, aT as splitListText, a4 as UNKNOWN_ELEMENT_CODE, o as ID_MERGED_CODE, aU as timeTextCompanion, aV as parseDecimalText, ac as capabilities, L as LOSS, ax as joinText, ak as encodeChunks, aG as sanitizeIds, az as pairFolding, al as explicitWeights, aE as resolveExportOptions, ad as checkCapabilities, aW as formatTimeValue, an as formatF32, ao as formatF64, aX as mapDeclaredType, aY as joinListText, aZ as formatTemporal, aq as formatInteger, at as isCanonicalIntegerText, z as MIXED_DIRECTION_CODE, g as DIRECTION_FORCED_CODE, h as DIRECTION_REFUSED_CODE, Y as SINK_OPTION_CODE, P as OPTION_IGNORED_CODE, X as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, b as BAD_OPTIONS_CODE, B as BAD_DEFAULT_CODE, a3 as UNKNOWN_ATTR_TYPE_CODE, a5 as UNKNOWN_ENCODING_CODE, n as ENCODING_FALLBACK_CODE, s as INVALID_ENCODING_CODE, u as INVALID_UTF8_CODE } from "./chunks/writer-BdMak4_J.js";
|
|
2
2
|
import { GraphFormatError, INVALID_INDEX, MAX_COUNT } from "@graphty/graph-format";
|
|
3
|
-
import { t as tokenizeXml, X as XmlSyntaxError, l as localName,
|
|
3
|
+
import { t as tokenizeXml, d as xmlDeclaredEncoding, X as XmlSyntaxError, l as localName, e as isWhitespace, x as xmlIllegalTextNotes, f as escapeXmlText, g as escapeXmlAttribute } from "./chunks/escape-CKied3Ri.js";
|
|
4
4
|
const GEXF_FORMAT = "gexf";
|
|
5
5
|
const GEXF_NAMESPACES = {
|
|
6
6
|
"1.2": { gexf: "http://www.gexf.net/1.2draft", viz: "http://www.gexf.net/1.2draft/viz" },
|
|
@@ -2155,7 +2155,10 @@ const gexfImporter = Object.freeze({
|
|
|
2155
2155
|
reportUnusedOptions(options, report, USED_OPTIONS);
|
|
2156
2156
|
const reader = new GexfReader(sink, report, resolved, viz);
|
|
2157
2157
|
try {
|
|
2158
|
-
await tokenizeXml(
|
|
2158
|
+
await tokenizeXml(
|
|
2159
|
+
textChunks(input, report, { ...resolved, declaredEncoding: xmlDeclaredEncoding }),
|
|
2160
|
+
reader
|
|
2161
|
+
);
|
|
2159
2162
|
} catch (err) {
|
|
2160
2163
|
if (err instanceof XmlSyntaxError) {
|
|
2161
2164
|
report.fail(XML_SYNTAX_CODE, err.message, { line: err.line });
|
|
@@ -2290,6 +2293,14 @@ function planExport(snapshot, options) {
|
|
|
2290
2293
|
);
|
|
2291
2294
|
}
|
|
2292
2295
|
}
|
|
2296
|
+
if (graphExtraText(snapshot, "timestamp") !== null) {
|
|
2297
|
+
note(
|
|
2298
|
+
GEXF_LOSS.TIMESTAMP_AS_INTERVAL,
|
|
2299
|
+
"the graph timestamp is written as a closed interval (start = end); GEXF 1.2 has no timestamp representation",
|
|
2300
|
+
null,
|
|
2301
|
+
null
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2293
2304
|
if (edgeRoles.kind !== null) {
|
|
2294
2305
|
note(
|
|
2295
2306
|
GEXF_LOSS.KIND_DROPPED,
|
|
@@ -3330,18 +3341,33 @@ function graphStart(snapshot, plan) {
|
|
|
3330
3341
|
if (plan.version === "1.3" && plan.timeRepresentation !== null) {
|
|
3331
3342
|
attrs += ` timerepresentation="${plan.timeRepresentation}"`;
|
|
3332
3343
|
}
|
|
3333
|
-
const
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3344
|
+
const timestamp = graphExtraText(snapshot, "timestamp");
|
|
3345
|
+
const header = {
|
|
3346
|
+
start: graphExtraText(snapshot, "start"),
|
|
3347
|
+
end: graphExtraText(snapshot, "end"),
|
|
3348
|
+
timestamp
|
|
3349
|
+
};
|
|
3350
|
+
if (plan.version === "1.2" && timestamp !== null) {
|
|
3351
|
+
header.start ??= timestamp;
|
|
3352
|
+
header.end ??= timestamp;
|
|
3353
|
+
header.timestamp = null;
|
|
3354
|
+
}
|
|
3355
|
+
for (const [key, value] of Object.entries(header)) {
|
|
3356
|
+
if (value !== null) {
|
|
3357
|
+
attrs += ` ${key}="${escapeXmlAttribute(value)}"`;
|
|
3340
3358
|
}
|
|
3341
3359
|
}
|
|
3342
3360
|
return ` <graph${attrs}>
|
|
3343
3361
|
`;
|
|
3344
3362
|
}
|
|
3363
|
+
function graphExtraText(snapshot, key) {
|
|
3364
|
+
const gexfExtra = snapshot.meta.extra.gexf;
|
|
3365
|
+
if (typeof gexfExtra !== "object" || gexfExtra === null) {
|
|
3366
|
+
return null;
|
|
3367
|
+
}
|
|
3368
|
+
const value = gexfExtra[key];
|
|
3369
|
+
return typeof value === "string" ? value : null;
|
|
3370
|
+
}
|
|
3345
3371
|
const gexfExporter = Object.freeze({
|
|
3346
3372
|
format: GEXF_FORMAT,
|
|
3347
3373
|
capabilities: CAPABILITIES_1_3,
|
|
@@ -3379,6 +3405,12 @@ const GEXF_ISSUE = Object.freeze({
|
|
|
3379
3405
|
XML_SYNTAX: XML_SYNTAX_CODE,
|
|
3380
3406
|
/** The input holds invalid UTF-8 (fatal). */
|
|
3381
3407
|
INVALID_UTF8: INVALID_UTF8_CODE,
|
|
3408
|
+
/** Invalid bytes in the encoding a BOM, a declaration or the encoding option chose (fatal). */
|
|
3409
|
+
INVALID_ENCODING: INVALID_ENCODING_CODE,
|
|
3410
|
+
/** Bytes that are not UTF-8 and declare no encoding were read as windows-1252. */
|
|
3411
|
+
ENCODING_FALLBACK: ENCODING_FALLBACK_CODE,
|
|
3412
|
+
/** A declared encoding the platform cannot decode was ignored. */
|
|
3413
|
+
UNKNOWN_ENCODING: UNKNOWN_ENCODING_CODE,
|
|
3382
3414
|
/** The root element is not `<gexf>` (fatal). */
|
|
3383
3415
|
NOT_GEXF: NOT_GEXF_CODE,
|
|
3384
3416
|
/** The document has no `<graph>` (fatal). */
|