@graphty/graph-io 0.3.38 → 0.3.40
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-CsO24U-5.js → choose-CS3fvGT1.js} +2 -2
- package/dist/chunks/{choose-CsO24U-5.js.map → choose-CS3fvGT1.js.map} +1 -1
- package/dist/chunks/{constants-BPRiVyBu.js → constants-DqKZT6cH.js} +2 -2
- package/dist/chunks/{constants-BPRiVyBu.js.map → constants-DqKZT6cH.js.map} +1 -1
- package/dist/chunks/{escape-BRcyzD77.js → escape-BJRLd3vJ.js} +4 -3
- package/dist/chunks/escape-BJRLd3vJ.js.map +1 -0
- package/dist/chunks/{export-CTUlibzr.js → export-B-aVCwyG.js} +103 -92
- package/dist/chunks/export-B-aVCwyG.js.map +1 -0
- package/dist/chunks/{exporter-Bf5tZA0X.js → exporter-6ocL_9x_.js} +6 -5
- package/dist/chunks/exporter-6ocL_9x_.js.map +1 -0
- package/dist/chunks/{exporter-Bn4jdYfd.js → exporter-BVXnV9-9.js} +43 -30
- package/dist/chunks/exporter-BVXnV9-9.js.map +1 -0
- package/dist/chunks/{exporter-D-qQuRcG.js → exporter-Bcp-l4Bo.js} +6 -6
- package/dist/chunks/exporter-Bcp-l4Bo.js.map +1 -0
- package/dist/chunks/{exporter-F0vT919P.js → exporter-SFYkDzD0.js} +5 -4
- package/dist/chunks/exporter-SFYkDzD0.js.map +1 -0
- package/dist/chunks/{importer-Bgb9sgZZ.js → importer-AjwOJrn2.js} +6 -8
- package/dist/chunks/importer-AjwOJrn2.js.map +1 -0
- package/dist/chunks/{importer-BuzbaFFY.js → importer-BJlGAOht.js} +28 -13
- package/dist/chunks/importer-BJlGAOht.js.map +1 -0
- package/dist/chunks/{importer-DqMtyYLX.js → importer-BpuS3J8C.js} +12 -14
- package/dist/chunks/importer-BpuS3J8C.js.map +1 -0
- package/dist/chunks/{importer-CEuUmyPe.js → importer-CPqnIY8m.js} +6 -6
- package/dist/chunks/{importer-CEuUmyPe.js.map → importer-CPqnIY8m.js.map} +1 -1
- package/dist/chunks/{importer-yWUPR_nU.js → importer-DEp_fYjf.js} +30 -12
- package/dist/chunks/importer-DEp_fYjf.js.map +1 -0
- package/dist/chunks/{importer-CNMQnHDd.js → importer-D_srHyj6.js} +112 -62
- package/dist/chunks/importer-D_srHyj6.js.map +1 -0
- package/dist/chunks/{importer-oIUx9u_g.js → importer-DcKB97kW.js} +40 -18
- package/dist/chunks/importer-DcKB97kW.js.map +1 -0
- package/dist/chunks/{json-elements-AkglPS3m.js → json-elements-DpO6AXIc.js} +7 -5
- package/dist/chunks/{json-elements-AkglPS3m.js.map → json-elements-DpO6AXIc.js.map} +1 -1
- package/dist/chunks/{ontology-export-DDoG3egY.js → ontology-export-50L9DOV4.js} +2 -2
- package/dist/chunks/{ontology-export-DDoG3egY.js.map → ontology-export-50L9DOV4.js.map} +1 -1
- package/dist/chunks/{records-ChmWZGuz.js → records-r3SFHz11.js} +137 -96
- package/dist/chunks/records-r3SFHz11.js.map +1 -0
- package/dist/chunks/{text-Btw3sBe_.js → text-Bjfa1xYL.js} +2 -2
- package/dist/chunks/{text-Btw3sBe_.js.map → text-Bjfa1xYL.js.map} +1 -1
- package/dist/csv.js +4 -4
- 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 +6 -4
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +8 -6
- 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 +3 -3
- package/dist/obo.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/common/direction.js +1 -1
- package/dist/src/common/direction.js.map +1 -1
- package/dist/src/common/export.d.ts.map +1 -1
- package/dist/src/common/export.js +136 -71
- package/dist/src/common/export.js.map +1 -1
- package/dist/src/common/input.js +1 -1
- 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/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/formats/csv/records.d.ts.map +1 -1
- package/dist/src/formats/csv/records.js +138 -100
- 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/dot/importer.d.ts +6 -0
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +11 -6
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/dot/names.d.ts +5 -0
- package/dist/src/formats/dot/names.d.ts.map +1 -1
- package/dist/src/formats/dot/names.js +5 -0
- package/dist/src/formats/dot/names.js.map +1 -1
- package/dist/src/formats/dot/tokenizer.js +9 -9
- package/dist/src/formats/dot/tokenizer.js.map +1 -1
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +4 -2
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts +6 -0
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +6 -3
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
- package/dist/src/formats/graphml/exporter.js +2 -1
- 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 +5 -6
- package/dist/src/formats/graphml/importer.js.map +1 -1
- package/dist/src/formats/obo/importer.d.ts.map +1 -1
- package/dist/src/formats/obo/importer.js +2 -1
- package/dist/src/formats/obo/importer.js.map +1 -1
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +4 -5
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/xgmml/emit.d.ts +6 -0
- package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
- package/dist/src/formats/xgmml/emit.js +33 -10
- 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 +54 -22
- package/dist/src/formats/xgmml/exporter.js.map +1 -1
- package/dist/src/sniff.js +1 -1
- package/dist/src/sniff.js.map +1 -1
- package/dist/xgmml.js +2 -2
- package/package.json +2 -2
- package/src/common/direction.ts +1 -1
- package/src/common/export.ts +190 -97
- package/src/common/input.ts +1 -1
- package/src/common/json-elements.ts +4 -2
- package/src/common/xml.ts +2 -1
- package/src/formats/csv/records.ts +143 -99
- 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/dot/importer.ts +35 -4
- package/src/formats/dot/names.ts +6 -0
- package/src/formats/dot/tokenizer.ts +9 -9
- package/src/formats/gexf/exporter.ts +4 -2
- package/src/formats/gml/importer.ts +14 -3
- package/src/formats/graphml/exporter.ts +2 -3
- package/src/formats/graphml/importer.ts +5 -6
- package/src/formats/obo/importer.ts +2 -1
- package/src/formats/pajek/exporter.ts +6 -4
- package/src/formats/xgmml/emit.ts +34 -10
- package/src/formats/xgmml/exporter.ts +63 -23
- package/src/sniff.ts +1 -1
- package/dist/chunks/escape-BRcyzD77.js.map +0 -1
- package/dist/chunks/export-CTUlibzr.js.map +0 -1
- package/dist/chunks/exporter-Bf5tZA0X.js.map +0 -1
- package/dist/chunks/exporter-Bn4jdYfd.js.map +0 -1
- package/dist/chunks/exporter-D-qQuRcG.js.map +0 -1
- package/dist/chunks/exporter-F0vT919P.js.map +0 -1
- package/dist/chunks/importer-Bgb9sgZZ.js.map +0 -1
- package/dist/chunks/importer-BuzbaFFY.js.map +0 -1
- package/dist/chunks/importer-CNMQnHDd.js.map +0 -1
- package/dist/chunks/importer-DqMtyYLX.js.map +0 -1
- package/dist/chunks/importer-oIUx9u_g.js.map +0 -1
- package/dist/chunks/importer-yWUPR_nU.js.map +0 -1
- package/dist/chunks/records-ChmWZGuz.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphBuilder } from "@graphty/graph-format";
|
|
2
|
-
import { a7 as chooseGraph, a8 as ImportReportBuilder } from "./export-
|
|
2
|
+
import { a7 as chooseGraph, a8 as ImportReportBuilder } from "./export-B-aVCwyG.js";
|
|
3
3
|
async function importChosenGraph(importer, input, sink, options) {
|
|
4
4
|
const importAll = importer.importAll?.bind(importer);
|
|
5
5
|
if (importAll === void 0) {
|
|
@@ -53,4 +53,4 @@ async function replayable(input) {
|
|
|
53
53
|
export {
|
|
54
54
|
importChosenGraph as i
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=choose-
|
|
56
|
+
//# sourceMappingURL=choose-CS3fvGT1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose-
|
|
1
|
+
{"version":3,"file":"choose-CS3fvGT1.js","sources":["../../src/common/choose.ts"],"sourcesContent":["/**\n * The graph choice of an importer that can read every graph of a file (importAll) but has no cheap\n * listing: `graphIndex` / `graphName` passed to its import() directly, as the registry would honor\n * them, so a caller with its own builder is not silently given the first graph.\n */\n\nimport { GraphBuilder, type GraphSink } from \"@graphty/graph-format\";\n\nimport {\n type CommonImportOptions,\n type GraphChoiceOptions,\n type GraphImporter,\n type ImportInput,\n type ImportReport,\n} from \"../types.js\";\nimport { chooseGraph } from \"./options.js\";\nimport { ImportReportBuilder } from \"./report.js\";\n\n/**\n * Read the graph `graphIndex` or `graphName` chooses into the sink: every graph is read once into a\n * scratch builder to learn the names (E_GRAPH_NOT_FOUND lists them), then the input again with the\n * chosen graph going to the sink.\n * @param importer - the importer, which has importAll()\n * @param input - the input\n * @param sink - the caller's sink\n * @param options - the import options, with the choice\n * @returns the chosen graph's report\n */\nexport async function importChosenGraph<O>(\n importer: GraphImporter<O>,\n input: ImportInput,\n sink: GraphSink,\n options: (O & CommonImportOptions & GraphChoiceOptions) | undefined,\n): Promise<ImportReport> {\n const importAll = importer.importAll?.bind(importer);\n if (importAll === undefined) {\n return importer.import(input, sink, options);\n }\n const replay = await replayable(input);\n const scratch: GraphBuilder[] = [];\n await importAll(replay, (i) => (scratch[i] = new GraphBuilder({ directed: false })), {\n ...options,\n onProgress: undefined,\n } as O & CommonImportOptions);\n const names = scratch.map((b) => {\n try {\n return b.freeze().meta.name;\n } catch {\n return null;\n }\n });\n const chosen = chooseGraph(names, options, new ImportReportBuilder(importer.format, 0));\n const reports = await importAll(\n replay,\n (i) => (i === chosen ? sink : new GraphBuilder({ directed: false })),\n options,\n );\n return reports[chosen];\n}\n\n/**\n * The input as a string or bytes that can be read twice.\n * @param input - the input\n * @returns the same text or bytes, or the stream's bytes\n */\nasync function replayable(input: ImportInput): Promise<string | Uint8Array> {\n if (typeof input === \"string\" || input instanceof Uint8Array) {\n return input;\n }\n const parts: Uint8Array[] = [];\n const encoder = new TextEncoder();\n if (typeof (input as ReadableStream<Uint8Array>).getReader === \"function\") {\n const reader = (input as ReadableStream<Uint8Array>).getReader();\n for (let r = await reader.read(); !r.done; r = await reader.read()) {\n parts.push(r.value);\n }\n } else {\n for await (const chunk of input as AsyncIterable<string | Uint8Array>) {\n parts.push(typeof chunk === \"string\" ? encoder.encode(chunk) : chunk);\n }\n }\n const out = new Uint8Array(parts.reduce((n, p) => n + p.byteLength, 0));\n let offset = 0;\n for (const part of parts) {\n out.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K,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK,IAAI,KAAK;AAAA,IACxE;AAAA,EACJ;AACA,QAAM,MAAM,IAAI,WAAW,MAAM,OAAO,CAAC,GAAG,MAAM,IAAI,EAAE,YAAY,CAAC,CAAC;AACtE,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACtB,QAAI,IAAI,MAAM,MAAM;AACpB,cAAU,KAAK;AAAA,EACnB;AACA,SAAO;AACX;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, P as PRECISION_CODE, B as BAD_DEFAULT_CODE, U as UNKNOWN_ATTR_TYPE_CODE, R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, O as OPTION_IGNORED_CODE, I as ID_MERGED_CODE, f as STRAY_TEXT_CODE, g as UNKNOWN_ELEMENT_CODE, h as UNKNOWN_XML_ATTRIBUTE_CODE, i as DANGLING_REFERENCE_CODE, H as HYPEREDGE_CODE, j as COUNT_MISMATCH_CODE, k as COUNT_HINT_CODE, l as MULTIPLE_GRAPHS_CODE, m as DUPLICATE_EDGE_ID_CODE, n as DUPLICATE_NODE_CODE, o as DUPLICATE_ATTRIBUTE_CODE, q as UNKNOWN_PARENT_CODE, s as MISSING_ENDPOINT_CODE, t as MISSING_ID_CODE, u as DUPLICATE_KEY_CODE, N as NO_GRAPH_CODE, E as EMPTY_INPUT_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, X as XML_SYNTAX_CODE, A as COLUMN_TYPE_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, J as ID_TEXT_TYPE_CODE, K as ROLE_DROPPED_CODE, Q as PARENTS_DROPPED_CODE, T as MUTUAL_AS_UNDIRECTED_CODE } from "./export-
|
|
1
|
+
import { M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, P as PRECISION_CODE, B as BAD_DEFAULT_CODE, U as UNKNOWN_ATTR_TYPE_CODE, R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, O as OPTION_IGNORED_CODE, I as ID_MERGED_CODE, f as STRAY_TEXT_CODE, g as UNKNOWN_ELEMENT_CODE, h as UNKNOWN_XML_ATTRIBUTE_CODE, i as DANGLING_REFERENCE_CODE, H as HYPEREDGE_CODE, j as COUNT_MISMATCH_CODE, k as COUNT_HINT_CODE, l as MULTIPLE_GRAPHS_CODE, m as DUPLICATE_EDGE_ID_CODE, n as DUPLICATE_NODE_CODE, o as DUPLICATE_ATTRIBUTE_CODE, q as UNKNOWN_PARENT_CODE, s as MISSING_ENDPOINT_CODE, t as MISSING_ID_CODE, u as DUPLICATE_KEY_CODE, N as NO_GRAPH_CODE, E as EMPTY_INPUT_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, X as XML_SYNTAX_CODE, A as COLUMN_TYPE_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, J as ID_TEXT_TYPE_CODE, K as ROLE_DROPPED_CODE, Q as PARENTS_DROPPED_CODE, T as MUTUAL_AS_UNDIRECTED_CODE } from "./export-B-aVCwyG.js";
|
|
2
2
|
const GRAPHML_NAMESPACE = "http://graphml.graphdrawing.org/xmlns";
|
|
3
3
|
const YFILES_NAMESPACE = "http://www.yworks.com/xml/graphml";
|
|
4
4
|
const XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance";
|
|
@@ -228,4 +228,4 @@ export {
|
|
|
228
228
|
EXTENSIONS as f,
|
|
229
229
|
ORIGINAL_ID_COLUMN as g
|
|
230
230
|
};
|
|
231
|
-
//# sourceMappingURL=constants-
|
|
231
|
+
//# sourceMappingURL=constants-DqKZT6cH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants-BPRiVyBu.js","sources":["../../src/formats/graphml/constants.ts"],"sourcesContent":["/**\n * What the GraphML importer and exporter share: the namespace, the format facts, the reserved\n * column names of the XML-attribute-derived columns, the `meta.extra`\n * keys the importer records for the exporter, and the issue and loss codes.\n */\n\nimport {\n BAD_DEFAULT_CODE,\n COLUMN_RENAMED_CODE,\n COLUMN_TYPE_CODE,\n COUNT_HINT_CODE,\n COUNT_MISMATCH_CODE,\n DANGLING_REFERENCE_CODE,\n DIRECTION_FORCED_CODE,\n DIRECTION_REFUSED_CODE,\n DUPLICATE_ATTRIBUTE_CODE,\n DUPLICATE_EDGE_ID_CODE,\n DUPLICATE_KEY_CODE,\n DUPLICATE_NODE_CODE,\n ELEMENT_ISSUE,\n EMPTY_INPUT_CODE,\n ENCODING_CONFLICT_CODE,\n ENCODING_FALLBACK_CODE,\n HYPEREDGE_CODE,\n ID_MERGED_CODE,\n ID_TEXT_TYPE_CODE,\n INPUT_ISSUE,\n INVALID_ENCODING_CODE,\n INVALID_UTF8_CODE,\n MISSING_ENDPOINT_CODE,\n MISSING_ID_CODE,\n MIXED_DIRECTION_CODE,\n MULTIPLE_GRAPHS_CODE,\n MUTUAL_AS_UNDIRECTED_CODE,\n NO_GRAPH_CODE,\n OPTION_IGNORED_CODE,\n PARENTS_DROPPED_CODE,\n PRECISION_CODE,\n ROLE_DROPPED_CODE,\n ROLE_TAKEN_CODE,\n SINK_OPTION_CODE,\n STRAY_TEXT_CODE,\n UNKNOWN_ATTR_TYPE_CODE,\n UNKNOWN_ELEMENT_CODE,\n UNKNOWN_ENCODING_CODE,\n UNKNOWN_PARENT_CODE,\n UNKNOWN_XML_ATTRIBUTE_CODE,\n XML_SYNTAX_CODE,\n} from \"../../common/codes.js\";\n\n/**\n * The GraphML namespace.\n * @category Plugin helpers\n */\nexport const GRAPHML_NAMESPACE = \"http://graphml.graphdrawing.org/xmlns\";\n\n/**\n * The yFiles extension namespace, declared as `xmlns:y` when a yfiles column is written.\n * @category Plugin helpers\n */\nexport const YFILES_NAMESPACE = \"http://www.yworks.com/xml/graphml\";\n\n/**\n * The XML Schema instance namespace and the schema location the exporter writes.\n * @category Plugin helpers\n */\nexport const XSI_NAMESPACE = \"http://www.w3.org/2001/XMLSchema-instance\";\n\n/**\n * The GraphML schema location written by the exporter.\n * @category Plugin helpers\n */\nexport const SCHEMA_LOCATION =\n \"http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\";\n\n/**\n * The format name.\n * @category Plugin helpers\n */\nexport const FORMAT = \"graphml\";\n\n/**\n * File extensions.\n * @category Plugin helpers\n */\nexport const EXTENSIONS: readonly string[] = Object.freeze([\".graphml\", \".xml\"]);\n\n/**\n * MIME types.\n * @category Plugin helpers\n */\nexport const MIME_TYPES: readonly string[] = Object.freeze([\"application/graphml+xml\", \"application/xml\", \"text/xml\"]);\n\n/**\n * The `attr.name` of the node key that carries ids rewritten by `sanitizeIds: \"mangle\"`.\n * @category Plugin helpers\n */\nexport const ORIGINAL_ID_ATTRIBUTE = \"graphty:originalId\";\n\n/**\n * The node column that keeps original ids when `restoreMangledIds` is off.\n * @category Plugin helpers\n */\nexport const ORIGINAL_ID_COLUMN = \"graphty.originalId\";\n\n/**\n * The edge column of the `id` XML attribute (role id, unique).\n * @category Plugin helpers\n */\nexport const EDGE_ID_COLUMN = \"id\";\n\n/**\n * The edge columns of the `sourceport` / `targetport` XML attributes (roles sourcePort / targetPort).\n * @category Plugin helpers\n */\nexport const SOURCE_PORT_COLUMN = \"sourceport\";\n\n/**\n * The edge column of the `targetport` XML attribute.\n * @category Plugin helpers\n */\nexport const TARGET_PORT_COLUMN = \"targetport\";\n\n/**\n * The node column of the containing node of a nested graph (u32, role parent, refersTo node).\n * @category Plugin helpers\n */\nexport const PARENT_COLUMN = \"parent\";\n\n/**\n * The bool node column marking the hub nodes synthesized for hyperedges under `hyperedges: \"star\"`.\n * @category Plugin helpers\n */\nexport const HYPEREDGE_HUB_COLUMN = \"graphty.hyperedge\";\n\n/**\n * The column name a node key titled `label` receives the `label` role under.\n * @category Plugin helpers\n */\nexport const LABEL_COLUMN = \"label\";\n\n/**\n * Edge column names reserved for the XML-attribute-derived columns; a key titled like one is renamed `<name>#<id>`.\n * @category Plugin helpers\n */\nexport const RESERVED_EDGE_NAMES: ReadonlySet<string> = new Set([\n EDGE_ID_COLUMN,\n SOURCE_PORT_COLUMN,\n TARGET_PORT_COLUMN,\n]);\n\n/**\n * Node column names reserved for the XML-derived columns.\n * @category Plugin helpers\n */\nexport const RESERVED_NODE_NAMES: ReadonlySet<string> = new Set([PARENT_COLUMN]);\n\n/**\n * The `meta.extra` key under which the importer records what the exporter needs.\n * @category Plugin helpers\n */\nexport const META_KEY = \"graphml\";\n\n/**\n * What the importer stores under `meta.extra.graphml`.\n * @category Plugin helpers\n */\nexport interface GraphmlMeta {\n /** The top-level `<graph id>`, or null. */\n readonly graphId: string | null;\n /** The top-level `edgedefault` as written, so a mixed file re-exports with the same layout. */\n readonly edgedefault: \"directed\" | \"undirected\" | null;\n /** The `xmlns:<prefix>` declarations of the root element (yFiles and the like). */\n readonly namespaces: Readonly<Record<string, string>>;\n}\n\n/**\n * The issue codes the GraphML importer records, by name: the codes shared\n * with the other importers and the GraphML-specific ones. A key is the code\n * without its severity and format prefixes.\n * @category Built-in formats\n */\nexport const GRAPHML_ISSUE = Object.freeze({\n ...INPUT_ISSUE,\n ...ELEMENT_ISSUE,\n /**\n * A value that does not parse as the type its attribute declares (\"x\" in an integer attribute). The value is\n * left unset; the node or edge is kept.\n */\n COLUMN_TYPE: COLUMN_TYPE_CODE,\n /** The input is not well-formed XML. The import stops. */\n XML_SYNTAX: XML_SYNTAX_CODE,\n /** The input is not valid UTF-8. The import stops. */\n INVALID_UTF8: INVALID_UTF8_CODE,\n /**\n * Some bytes are not valid in the encoding that was chosen (by a byte order mark, the file's declaration or the\n * `encoding` option). The import stops.\n */\n INVALID_ENCODING: INVALID_ENCODING_CODE,\n /** Bytes that are not UTF-8 and declare no encoding were read as windows-1252. */\n ENCODING_FALLBACK: ENCODING_FALLBACK_CODE,\n /** A declared encoding the platform cannot decode was ignored. */\n UNKNOWN_ENCODING: UNKNOWN_ENCODING_CODE,\n /** A declared encoding the byte order mark contradicts (the mark wins). */\n ENCODING_CONFLICT: ENCODING_CONFLICT_CODE,\n /** The input holds no XML at all: it is empty, whitespace or a byte order mark only. The import stops. */\n EMPTY_INPUT: EMPTY_INPUT_CODE,\n /** The root element is not `<graphml>`. The import stops. */\n NOT_GRAPHML: \"E_NOT_GRAPHML\",\n /** The `<graphml>` root is in a namespace other than GraphML's; it is read as GraphML. */\n NAMESPACE: \"W_GRAPHML_NAMESPACE\",\n /** The document has no `<graph>`. The import stops. */\n NO_GRAPH: NO_GRAPH_CODE,\n /** A `<key>` without an id. */\n KEY_MISSING_ID: \"E_GRAPHML_KEY_MISSING_ID\",\n /** Two `<key>` elements with the same id. */\n DUPLICATE_KEY: DUPLICATE_KEY_CODE,\n /** A key declared for hyperedges, ports or endpoints (never used). */\n KEY_DOMAIN_UNSUPPORTED: \"W_GRAPHML_KEY_DOMAIN_UNSUPPORTED\",\n /** A `<node>` without an id. */\n MISSING_ID: MISSING_ID_CODE,\n /** An `<edge>` without a source or a target. */\n MISSING_ENDPOINT: MISSING_ENDPOINT_CODE,\n /** An edge endpoint that names no declared node under `addMissingNodes: false`; the edge is skipped. */\n UNKNOWN_NODE: \"E_UNKNOWN_NODE\",\n /** An edge endpoint that names a nested `<graph>`, not a node; a node of that id is created. */\n GRAPH_ENDPOINT: \"W_GRAPHML_GRAPH_ENDPOINT\",\n /** The nodes of a nested graph whose container node was skipped lose their parent. */\n UNKNOWN_PARENT: UNKNOWN_PARENT_CODE,\n /** Two `<data>` of one key on one element, two `<default>` in one key, or two weight keys; one is kept. */\n DUPLICATE_ATTRIBUTE: DUPLICATE_ATTRIBUTE_CODE,\n /** A `<data>` whose key was never declared. */\n UNKNOWN_KEY: \"E_GRAPHML_UNKNOWN_KEY\",\n /** A `<key>` declared after `<data>` that used it; those values were already reported and dropped. */\n KEY_DECLARED_LATE: \"W_GRAPHML_KEY_DECLARED_LATE\",\n /** A `<data>` whose key is declared for another domain. */\n KEY_DOMAIN: \"W_GRAPHML_KEY_DOMAIN\",\n /** A `<data>` without a key attribute. */\n DATA_MISSING_KEY: \"E_GRAPHML_DATA_MISSING_KEY\",\n /** A `<key>` whose `for` is not a GraphML domain. */\n KEY_FOR_INVALID: \"E_GRAPHML_KEY_FOR_INVALID\",\n /** Data of a nested `<graph>`; only the top-level graph has attributes. */\n NESTED_GRAPH_DATA: \"W_GRAPHML_NESTED_GRAPH_DATA\",\n /** Data of a hyperedge expanded to a star or clique. */\n HYPEREDGE_DATA_DROPPED: \"W_GRAPHML_HYPEREDGE_DATA_DROPPED\",\n /** Nested elements in the `<data>` of a typed (non-yfiles) key. */\n DATA_NESTED: \"E_GRAPHML_DATA_NESTED\",\n /** A `<node>` declared twice. */\n DUPLICATE_NODE: DUPLICATE_NODE_CODE,\n /** An edge id already used by another edge. */\n DUPLICATE_EDGE_ID: DUPLICATE_EDGE_ID_CODE,\n /** A `directed` attribute that is neither true nor false. */\n INVALID_DIRECTED: \"E_GRAPHML_INVALID_DIRECTED\",\n /** An `edgedefault` that is neither directed nor undirected. */\n INVALID_EDGEDEFAULT: \"E_GRAPHML_INVALID_EDGEDEFAULT\",\n /** A `<graph>` without edgedefault; the `defaultDirected` option applies. */\n EDGEDEFAULT_MISSING: \"W_GRAPHML_EDGEDEFAULT_MISSING\",\n /**\n * The file holds more than one top-level `<graph>`; their nodes and edges are merged into one graph.\n * `importAllGraphs()` reads every one.\n */\n MULTIPLE_GRAPHS: MULTIPLE_GRAPHS_CODE,\n /**\n * A node or edge count the file announces is too large to reserve room for; it is ignored and the elements are\n * read as they come.\n */\n COUNT_HINT: COUNT_HINT_CODE,\n /**\n * A `parse.nodes` or `parse.edges` count disagrees with what the graph holds. The elements are read as they are.\n */\n COUNT_MISMATCH: COUNT_MISMATCH_CODE,\n /** A hyperedge under `hyperedges: \"error\"`. */\n HYPEREDGE: HYPEREDGE_CODE,\n /** Hyperedges skipped under `hyperedges: \"skip\"`. */\n HYPEREDGE_SKIPPED: \"W_GRAPHML_HYPEREDGE_SKIPPED\",\n /** An endpoint of a hyperedge without a node, or with an unknown type. */\n HYPEREDGE_ENDPOINT: \"E_GRAPHML_HYPEREDGE_ENDPOINT\",\n /** `<port>` declarations (and their data) are not kept; sourceport / targetport edge attributes are. */\n PORT_DECLARATION: \"W_GRAPHML_PORT_DECLARATION\",\n /** A `sourceport` / `targetport` naming a port its node does not declare (once, with the count). */\n DANGLING_REFERENCE: DANGLING_REFERENCE_CODE,\n /** A `<graph>` inside an `<edge>` (legal GraphML): it and the nodes and edges it holds are dropped. */\n EDGE_GRAPH_DROPPED: \"W_GRAPHML_EDGE_GRAPH_DROPPED\",\n /** A `<node>` whose id is that of a hub `hyperedges: \"star\"` created; the node is merged into the hub. */\n HUB_ID_CLASH: \"W_GRAPHML_HUB_ID_CLASH\",\n /** A `graphty:originalId` value that is not text, or arrives after the node was added (after its nested graph). */\n ORIGINAL_ID_IGNORED: \"W_GRAPHML_ORIGINAL_ID_IGNORED\",\n /** A yFiles graphics value (a geometry coordinate, a width) that is not a number; it is not mapped. */\n YFILES_VALUE: \"W_GRAPHML_YFILES_VALUE\",\n /**\n * A GraphML `parse.*` attribute (`parse.nodeids`, `parse.order`, ...) that graph-io does not act on; the file is\n * read normally.\n */\n PARSE_HINT_IGNORED: \"W_GRAPHML_PARSE_HINT_IGNORED\",\n /** An XML attribute GraphML does not define (or the importer does not keep) on an element; it is not kept. */\n UNKNOWN_XML_ATTRIBUTE: UNKNOWN_XML_ATTRIBUTE_CODE,\n /** A `<locator>` element. */\n LOCATOR_DROPPED: \"W_GRAPHML_LOCATOR_DROPPED\",\n /** A `<desc>` of a node, an edge or a hyperedge. */\n DESC_DROPPED: \"W_GRAPHML_DESC_DROPPED\",\n /** An element the GraphML schema does not define at that place. */\n UNKNOWN_ELEMENT: UNKNOWN_ELEMENT_CODE,\n /** Non-whitespace text where the schema allows only elements. */\n STRAY_TEXT: STRAY_TEXT_CODE,\n /** Two distinct id texts merged into one number under `ids: \"number\"`. */\n ID_MERGED: ID_MERGED_CODE,\n /** You set an option this format does not use; it had no effect. The message names the option. */\n OPTION_IGNORED: OPTION_IGNORED_CODE,\n /** A yFiles key under `yfiles: \"skip\"`. */\n YFILES_SKIPPED: \"W_GRAPHML_YFILES_SKIPPED\",\n /**\n * An attribute was renamed `<name>#<suffix>` because another attribute already has its name, for example\n * two attributes declared with the same name.\n */\n COLUMN_RENAMED: COLUMN_RENAMED_CODE,\n /**\n * You read into a graph builder that already has an id, label or position attribute, so this file's one is kept as\n * a plain attribute.\n */\n ROLE_TAKEN: ROLE_TAKEN_CODE,\n /** A declared type the format does not define (kept as string). */\n UNKNOWN_ATTR_TYPE: UNKNOWN_ATTR_TYPE_CODE,\n /** A default that does not parse as the declared type. */\n BAD_DEFAULT: BAD_DEFAULT_CODE,\n /** An integer beyond 2^53 was stored as the nearest 64-bit float; pass `long: \"string\"` to keep every digit. */\n PRECISION: PRECISION_CODE,\n /**\n * You read into your own graph builder, which was created with a different `addMissingNodes`, `duplicateEdges`,\n * `selfLoops` or `weightDtype` than the option you passed; the builder's setting applies.\n */\n SINK_OPTION: SINK_OPTION_CODE,\n /**\n * You read into a graph builder whose direction is already set, or which already holds edges, so the file is read\n * with the builder's direction instead of its own.\n */\n DIRECTION_REFUSED: DIRECTION_REFUSED_CODE,\n /** Edges of the other direction were read with the direction `onMixedDirection` chose. */\n DIRECTION_FORCED: DIRECTION_FORCED_CODE,\n /**\n * The graph has both directed and undirected edges and `onMixedDirection` is \"error\". An import stops; a save to a\n * format that holds one direction per file fails with E_DIRECTED. Pass \"directed\" or \"undirected\" to read or write\n * it anyway.\n */\n MIXED_DIRECTION: MIXED_DIRECTION_CODE,\n});\n\n/**\n * Loss note codes of the GraphML importer (report.lossy) and exporter (check()): the GraphML\n * ones; the generic ones (dtypes, lists, json text, positions, visual and temporal roles,\n * extension tables, id charsets, the weight key clash, name changes) are those of `LOSS`.\n * @category Built-in formats\n */\nexport const GRAPHML_LOSS = Object.freeze({\n /** YFiles nested XML kept as a JSON tree: structure preserved, not byte-exact. */\n YFILES_JSON: \"W_GRAPHML_YFILES_JSON\",\n /** A mutual pair written as one undirected edge; the mark is lost. */\n MUTUAL_AS_UNDIRECTED: MUTUAL_AS_UNDIRECTED_CODE,\n /** A `parents` (multi-parent) column cannot be written as nested graphs. */\n PARENTS_DROPPED: PARENTS_DROPPED_CODE,\n /** An attribute with a role the format has no place for is written as a plain attribute; the role is lost. */\n ROLE_DROPPED: ROLE_DROPPED_CODE,\n /** Containment order differs from index order; node indices change after a round trip. */\n HIERARCHY_REORDERED: \"W_GRAPHML_HIERARCHY_REORDERED\",\n /** Nodes whose parent chain never reaches a root are written at the top level. */\n PARENT_CYCLE: \"W_GRAPHML_PARENT_CYCLE\",\n /** Node ids that read back as a different type, such as the text \"7\" as the number 7. */\n ID_TEXT_TYPE: ID_TEXT_TYPE_CODE,\n /** A numeric edge id column reads back as string. */\n EDGE_ID_TEXT: \"W_GRAPHML_EDGE_ID_TEXT\",\n /** A `yfiles.*` graphics column that no longer matches its yFiles tree: only the tree is written. */\n YFILES_GRAPHICS_STALE: \"W_GRAPHML_YFILES_GRAPHICS_STALE\",\n /** A yEd graphics value that is not valid XML; the save fails with E_COLUMN_TYPE. */\n YFILES_TREE: \"E_GRAPHML_YFILES_TREE\",\n});\n"],"names":[],"mappings":";AAsDO,MAAM,oBAAoB;AAM1B,MAAM,mBAAmB;AAMzB,MAAM,gBAAgB;AAMtB,MAAM,kBACT;AAMG,MAAM,SAAS;AAMf,MAAM,aAAgC,OAAO,OAAO,CAAC,YAAY,MAAM,CAAC;AAMxE,MAAM,aAAgC,OAAO,OAAO,CAAC,2BAA2B,mBAAmB,U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c;AAAA;AAAA,EAEd,cAAc;AAAA;AAAA,EAEd,uBAAuB;AAAA;AAAA,EAEvB,aAAa;AACjB,CAAC;"}
|
|
1
|
+
{"version":3,"file":"constants-DqKZT6cH.js","sources":["../../src/formats/graphml/constants.ts"],"sourcesContent":["/**\n * What the GraphML importer and exporter share: the namespace, the format facts, the reserved\n * column names of the XML-attribute-derived columns, the `meta.extra`\n * keys the importer records for the exporter, and the issue and loss codes.\n */\n\nimport {\n BAD_DEFAULT_CODE,\n COLUMN_RENAMED_CODE,\n COLUMN_TYPE_CODE,\n COUNT_HINT_CODE,\n COUNT_MISMATCH_CODE,\n DANGLING_REFERENCE_CODE,\n DIRECTION_FORCED_CODE,\n DIRECTION_REFUSED_CODE,\n DUPLICATE_ATTRIBUTE_CODE,\n DUPLICATE_EDGE_ID_CODE,\n DUPLICATE_KEY_CODE,\n DUPLICATE_NODE_CODE,\n ELEMENT_ISSUE,\n EMPTY_INPUT_CODE,\n ENCODING_CONFLICT_CODE,\n ENCODING_FALLBACK_CODE,\n HYPEREDGE_CODE,\n ID_MERGED_CODE,\n ID_TEXT_TYPE_CODE,\n INPUT_ISSUE,\n INVALID_ENCODING_CODE,\n INVALID_UTF8_CODE,\n MISSING_ENDPOINT_CODE,\n MISSING_ID_CODE,\n MIXED_DIRECTION_CODE,\n MULTIPLE_GRAPHS_CODE,\n MUTUAL_AS_UNDIRECTED_CODE,\n NO_GRAPH_CODE,\n OPTION_IGNORED_CODE,\n PARENTS_DROPPED_CODE,\n PRECISION_CODE,\n ROLE_DROPPED_CODE,\n ROLE_TAKEN_CODE,\n SINK_OPTION_CODE,\n STRAY_TEXT_CODE,\n UNKNOWN_ATTR_TYPE_CODE,\n UNKNOWN_ELEMENT_CODE,\n UNKNOWN_ENCODING_CODE,\n UNKNOWN_PARENT_CODE,\n UNKNOWN_XML_ATTRIBUTE_CODE,\n XML_SYNTAX_CODE,\n} from \"../../common/codes.js\";\n\n/**\n * The GraphML namespace.\n * @category Plugin helpers\n */\nexport const GRAPHML_NAMESPACE = \"http://graphml.graphdrawing.org/xmlns\";\n\n/**\n * The yFiles extension namespace, declared as `xmlns:y` when a yfiles column is written.\n * @category Plugin helpers\n */\nexport const YFILES_NAMESPACE = \"http://www.yworks.com/xml/graphml\";\n\n/**\n * The XML Schema instance namespace and the schema location the exporter writes.\n * @category Plugin helpers\n */\nexport const XSI_NAMESPACE = \"http://www.w3.org/2001/XMLSchema-instance\";\n\n/**\n * The GraphML schema location written by the exporter.\n * @category Plugin helpers\n */\nexport const SCHEMA_LOCATION =\n \"http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\";\n\n/**\n * The format name.\n * @category Plugin helpers\n */\nexport const FORMAT = \"graphml\";\n\n/**\n * File extensions.\n * @category Plugin helpers\n */\nexport const EXTENSIONS: readonly string[] = Object.freeze([\".graphml\", \".xml\"]);\n\n/**\n * MIME types.\n * @category Plugin helpers\n */\nexport const MIME_TYPES: readonly string[] = Object.freeze([\"application/graphml+xml\", \"application/xml\", \"text/xml\"]);\n\n/**\n * The `attr.name` of the node key that carries ids rewritten by `sanitizeIds: \"mangle\"`.\n * @category Plugin helpers\n */\nexport const ORIGINAL_ID_ATTRIBUTE = \"graphty:originalId\";\n\n/**\n * The node column that keeps original ids when `restoreMangledIds` is off.\n * @category Plugin helpers\n */\nexport const ORIGINAL_ID_COLUMN = \"graphty.originalId\";\n\n/**\n * The edge column of the `id` XML attribute (role id, unique).\n * @category Plugin helpers\n */\nexport const EDGE_ID_COLUMN = \"id\";\n\n/**\n * The edge columns of the `sourceport` / `targetport` XML attributes (roles sourcePort / targetPort).\n * @category Plugin helpers\n */\nexport const SOURCE_PORT_COLUMN = \"sourceport\";\n\n/**\n * The edge column of the `targetport` XML attribute.\n * @category Plugin helpers\n */\nexport const TARGET_PORT_COLUMN = \"targetport\";\n\n/**\n * The node column of the containing node of a nested graph (u32, role parent, refersTo node).\n * @category Plugin helpers\n */\nexport const PARENT_COLUMN = \"parent\";\n\n/**\n * The bool node column marking the hub nodes synthesized for hyperedges under `hyperedges: \"star\"`.\n * @category Plugin helpers\n */\nexport const HYPEREDGE_HUB_COLUMN = \"graphty.hyperedge\";\n\n/**\n * The column name a node key titled `label` receives the `label` role under.\n * @category Plugin helpers\n */\nexport const LABEL_COLUMN = \"label\";\n\n/**\n * Edge column names reserved for the XML-attribute-derived columns; a key titled like one is renamed `<name>#<id>`.\n * @category Plugin helpers\n */\nexport const RESERVED_EDGE_NAMES: ReadonlySet<string> = new Set([\n EDGE_ID_COLUMN,\n SOURCE_PORT_COLUMN,\n TARGET_PORT_COLUMN,\n]);\n\n/**\n * Node column names reserved for the XML-derived columns.\n * @category Plugin helpers\n */\nexport const RESERVED_NODE_NAMES: ReadonlySet<string> = new Set([PARENT_COLUMN]);\n\n/**\n * The `meta.extra` key under which the importer records what the exporter needs.\n * @category Plugin helpers\n */\nexport const META_KEY = \"graphml\";\n\n/**\n * What the importer stores under `meta.extra.graphml`.\n * @category Plugin helpers\n */\nexport interface GraphmlMeta {\n /** The top-level `<graph id>`, or null. */\n readonly graphId: string | null;\n /** The top-level `edgedefault` as written, so a mixed file re-exports with the same layout. */\n readonly edgedefault: \"directed\" | \"undirected\" | null;\n /** The `xmlns:<prefix>` declarations of the root element (yFiles and the like). */\n readonly namespaces: Readonly<Record<string, string>>;\n}\n\n/**\n * The issue codes the GraphML importer records, by name: the codes shared\n * with the other importers and the GraphML-specific ones. A key is the code\n * without its severity and format prefixes.\n * @category Built-in formats\n */\nexport const GRAPHML_ISSUE = Object.freeze({\n ...INPUT_ISSUE,\n ...ELEMENT_ISSUE,\n /**\n * A value that does not parse as the type its attribute declares (\"x\" in an integer attribute). The value is\n * left unset; the node or edge is kept.\n */\n COLUMN_TYPE: COLUMN_TYPE_CODE,\n /** The input is not well-formed XML. The import stops. */\n XML_SYNTAX: XML_SYNTAX_CODE,\n /** The input is not valid UTF-8. The import stops. */\n INVALID_UTF8: INVALID_UTF8_CODE,\n /**\n * Some bytes are not valid in the encoding that was chosen (by a byte order mark, the file's declaration or the\n * `encoding` option). The import stops.\n */\n INVALID_ENCODING: INVALID_ENCODING_CODE,\n /** Bytes that are not UTF-8 and declare no encoding were read as windows-1252. */\n ENCODING_FALLBACK: ENCODING_FALLBACK_CODE,\n /** A declared encoding the platform cannot decode was ignored. */\n UNKNOWN_ENCODING: UNKNOWN_ENCODING_CODE,\n /** A declared encoding the byte order mark contradicts (the mark wins). */\n ENCODING_CONFLICT: ENCODING_CONFLICT_CODE,\n /** The input holds no XML at all: it is empty, whitespace or a byte order mark only. The import stops. */\n EMPTY_INPUT: EMPTY_INPUT_CODE,\n /** The root element is not `<graphml>`. The import stops. */\n NOT_GRAPHML: \"E_NOT_GRAPHML\",\n /** The `<graphml>` root is in a namespace other than GraphML's; it is read as GraphML. */\n NAMESPACE: \"W_GRAPHML_NAMESPACE\",\n /** The document has no `<graph>`. The import stops. */\n NO_GRAPH: NO_GRAPH_CODE,\n /** A `<key>` without an id. */\n KEY_MISSING_ID: \"E_GRAPHML_KEY_MISSING_ID\",\n /** Two `<key>` elements with the same id. */\n DUPLICATE_KEY: DUPLICATE_KEY_CODE,\n /** A key declared for hyperedges, ports or endpoints (never used). */\n KEY_DOMAIN_UNSUPPORTED: \"W_GRAPHML_KEY_DOMAIN_UNSUPPORTED\",\n /** A `<node>` without an id. */\n MISSING_ID: MISSING_ID_CODE,\n /** An `<edge>` without a source or a target. */\n MISSING_ENDPOINT: MISSING_ENDPOINT_CODE,\n /** An edge endpoint that names no declared node under `addMissingNodes: false`; the edge is skipped. */\n UNKNOWN_NODE: \"E_UNKNOWN_NODE\",\n /** An edge endpoint that names a nested `<graph>`, not a node; a node of that id is created. */\n GRAPH_ENDPOINT: \"W_GRAPHML_GRAPH_ENDPOINT\",\n /** The nodes of a nested graph whose container node was skipped lose their parent. */\n UNKNOWN_PARENT: UNKNOWN_PARENT_CODE,\n /** Two `<data>` of one key on one element, two `<default>` in one key, or two weight keys; one is kept. */\n DUPLICATE_ATTRIBUTE: DUPLICATE_ATTRIBUTE_CODE,\n /** A `<data>` whose key was never declared. */\n UNKNOWN_KEY: \"E_GRAPHML_UNKNOWN_KEY\",\n /** A `<key>` declared after `<data>` that used it; those values were already reported and dropped. */\n KEY_DECLARED_LATE: \"W_GRAPHML_KEY_DECLARED_LATE\",\n /** A `<data>` whose key is declared for another domain. */\n KEY_DOMAIN: \"W_GRAPHML_KEY_DOMAIN\",\n /** A `<data>` without a key attribute. */\n DATA_MISSING_KEY: \"E_GRAPHML_DATA_MISSING_KEY\",\n /** A `<key>` whose `for` is not a GraphML domain. */\n KEY_FOR_INVALID: \"E_GRAPHML_KEY_FOR_INVALID\",\n /** Data of a nested `<graph>`; only the top-level graph has attributes. */\n NESTED_GRAPH_DATA: \"W_GRAPHML_NESTED_GRAPH_DATA\",\n /** Data of a hyperedge expanded to a star or clique. */\n HYPEREDGE_DATA_DROPPED: \"W_GRAPHML_HYPEREDGE_DATA_DROPPED\",\n /** Nested elements in the `<data>` of a typed (non-yfiles) key. */\n DATA_NESTED: \"E_GRAPHML_DATA_NESTED\",\n /** A `<node>` declared twice. */\n DUPLICATE_NODE: DUPLICATE_NODE_CODE,\n /** An edge id already used by another edge. */\n DUPLICATE_EDGE_ID: DUPLICATE_EDGE_ID_CODE,\n /** A `directed` attribute that is neither true nor false. */\n INVALID_DIRECTED: \"E_GRAPHML_INVALID_DIRECTED\",\n /** An `edgedefault` that is neither directed nor undirected. */\n INVALID_EDGEDEFAULT: \"E_GRAPHML_INVALID_EDGEDEFAULT\",\n /** A `<graph>` without edgedefault; the `defaultDirected` option applies. */\n EDGEDEFAULT_MISSING: \"W_GRAPHML_EDGEDEFAULT_MISSING\",\n /**\n * The file holds more than one top-level `<graph>`; their nodes and edges are merged into one graph.\n * `importAllGraphs()` reads every one.\n */\n MULTIPLE_GRAPHS: MULTIPLE_GRAPHS_CODE,\n /**\n * A node or edge count the file announces is too large to reserve room for; it is ignored and the elements are\n * read as they come.\n */\n COUNT_HINT: COUNT_HINT_CODE,\n /**\n * A `parse.nodes` or `parse.edges` count disagrees with what the graph holds. The elements are read as they are.\n */\n COUNT_MISMATCH: COUNT_MISMATCH_CODE,\n /** A hyperedge under `hyperedges: \"error\"`. */\n HYPEREDGE: HYPEREDGE_CODE,\n /** Hyperedges skipped under `hyperedges: \"skip\"`. */\n HYPEREDGE_SKIPPED: \"W_GRAPHML_HYPEREDGE_SKIPPED\",\n /** An endpoint of a hyperedge without a node, or with an unknown type. */\n HYPEREDGE_ENDPOINT: \"E_GRAPHML_HYPEREDGE_ENDPOINT\",\n /** `<port>` declarations (and their data) are not kept; sourceport / targetport edge attributes are. */\n PORT_DECLARATION: \"W_GRAPHML_PORT_DECLARATION\",\n /** A `sourceport` / `targetport` naming a port its node does not declare (once, with the count). */\n DANGLING_REFERENCE: DANGLING_REFERENCE_CODE,\n /** A `<graph>` inside an `<edge>` (legal GraphML): it and the nodes and edges it holds are dropped. */\n EDGE_GRAPH_DROPPED: \"W_GRAPHML_EDGE_GRAPH_DROPPED\",\n /** A `<node>` whose id is that of a hub `hyperedges: \"star\"` created; the node is merged into the hub. */\n HUB_ID_CLASH: \"W_GRAPHML_HUB_ID_CLASH\",\n /** A `graphty:originalId` value that is not text, or arrives after the node was added (after its nested graph). */\n ORIGINAL_ID_IGNORED: \"W_GRAPHML_ORIGINAL_ID_IGNORED\",\n /** A yFiles graphics value (a geometry coordinate, a width) that is not a number; it is not mapped. */\n YFILES_VALUE: \"W_GRAPHML_YFILES_VALUE\",\n /**\n * A GraphML `parse.*` attribute (`parse.nodeids`, `parse.order`, ...) that graph-io does not act on; the file is\n * read normally.\n */\n PARSE_HINT_IGNORED: \"W_GRAPHML_PARSE_HINT_IGNORED\",\n /** An XML attribute GraphML does not define (or the importer does not keep) on an element; it is not kept. */\n UNKNOWN_XML_ATTRIBUTE: UNKNOWN_XML_ATTRIBUTE_CODE,\n /** A `<locator>` element. */\n LOCATOR_DROPPED: \"W_GRAPHML_LOCATOR_DROPPED\",\n /** A `<desc>` of a node, an edge or a hyperedge. */\n DESC_DROPPED: \"W_GRAPHML_DESC_DROPPED\",\n /** An element the GraphML schema does not define at that place. */\n UNKNOWN_ELEMENT: UNKNOWN_ELEMENT_CODE,\n /** Non-whitespace text where the schema allows only elements. */\n STRAY_TEXT: STRAY_TEXT_CODE,\n /** Two distinct id texts merged into one number under `ids: \"number\"`. */\n ID_MERGED: ID_MERGED_CODE,\n /** You set an option this format does not use; it had no effect. The message names the option. */\n OPTION_IGNORED: OPTION_IGNORED_CODE,\n /** A yFiles key under `yfiles: \"skip\"`. */\n YFILES_SKIPPED: \"W_GRAPHML_YFILES_SKIPPED\",\n /**\n * An attribute was renamed `<name>#<suffix>` because another attribute already has its name, for example\n * two attributes declared with the same name.\n */\n COLUMN_RENAMED: COLUMN_RENAMED_CODE,\n /**\n * You read into a graph builder that already has an id, label or position attribute, so this file's one is kept as\n * a plain attribute.\n */\n ROLE_TAKEN: ROLE_TAKEN_CODE,\n /** A declared type the format does not define (kept as string). */\n UNKNOWN_ATTR_TYPE: UNKNOWN_ATTR_TYPE_CODE,\n /** A default that does not parse as the declared type. */\n BAD_DEFAULT: BAD_DEFAULT_CODE,\n /** An integer beyond 2^53 was stored as the nearest 64-bit float; pass `long: \"string\"` to keep every digit. */\n PRECISION: PRECISION_CODE,\n /**\n * You read into your own graph builder, which was created with a different `addMissingNodes`, `duplicateEdges`,\n * `selfLoops` or `weightDtype` than the option you passed; the builder's setting applies.\n */\n SINK_OPTION: SINK_OPTION_CODE,\n /**\n * You read into a graph builder whose direction is already set, or which already holds edges, so the file is read\n * with the builder's direction instead of its own.\n */\n DIRECTION_REFUSED: DIRECTION_REFUSED_CODE,\n /** Edges of the other direction were read with the direction `onMixedDirection` chose. */\n DIRECTION_FORCED: DIRECTION_FORCED_CODE,\n /**\n * The graph has both directed and undirected edges and `onMixedDirection` is \"error\". An import stops; a save to a\n * format that holds one direction per file fails with E_DIRECTED. Pass \"directed\" or \"undirected\" to read or write\n * it anyway.\n */\n MIXED_DIRECTION: MIXED_DIRECTION_CODE,\n});\n\n/**\n * Loss note codes of the GraphML importer (report.lossy) and exporter (check()): the GraphML\n * ones; the generic ones (dtypes, lists, json text, positions, visual and temporal roles,\n * extension tables, id charsets, the weight key clash, name changes) are those of `LOSS`.\n * @category Built-in formats\n */\nexport const GRAPHML_LOSS = Object.freeze({\n /** YFiles nested XML kept as a JSON tree: structure preserved, not byte-exact. */\n YFILES_JSON: \"W_GRAPHML_YFILES_JSON\",\n /** A mutual pair written as one undirected edge; the mark is lost. */\n MUTUAL_AS_UNDIRECTED: MUTUAL_AS_UNDIRECTED_CODE,\n /** A `parents` (multi-parent) column cannot be written as nested graphs. */\n PARENTS_DROPPED: PARENTS_DROPPED_CODE,\n /** An attribute with a role the format has no place for is written as a plain attribute; the role is lost. */\n ROLE_DROPPED: ROLE_DROPPED_CODE,\n /** Containment order differs from index order; node indices change after a round trip. */\n HIERARCHY_REORDERED: \"W_GRAPHML_HIERARCHY_REORDERED\",\n /** Nodes whose parent chain never reaches a root are written at the top level. */\n PARENT_CYCLE: \"W_GRAPHML_PARENT_CYCLE\",\n /** Node ids that read back as a different type, such as the text \"7\" as the number 7. */\n ID_TEXT_TYPE: ID_TEXT_TYPE_CODE,\n /** A numeric edge id column reads back as string. */\n EDGE_ID_TEXT: \"W_GRAPHML_EDGE_ID_TEXT\",\n /** A `yfiles.*` graphics column that no longer matches its yFiles tree: only the tree is written. */\n YFILES_GRAPHICS_STALE: \"W_GRAPHML_YFILES_GRAPHICS_STALE\",\n /** A yEd graphics value that is not valid XML; the save fails with E_COLUMN_TYPE. */\n YFILES_TREE: \"E_GRAPHML_YFILES_TREE\",\n});\n"],"names":[],"mappings":";AAsDO,MAAM,oBAAoB;AAM1B,MAAM,mBAAmB;AAMzB,MAAM,gBAAgB;AAMtB,MAAM,kBACT;AAMG,MAAM,SAAS;AAMf,MAAM,aAAgC,OAAO,OAAO,CAAC,YAAY,MAAM,CAAC;AAMxE,MAAM,a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A;AAAA,EAErB,cAAc;AAAA;AAAA,EAEd,cAAc;AAAA;AAAA,EAEd,cAAc;AAAA;AAAA,EAEd,uBAAuB;AAAA;AAAA,EAEvB,aAAa;AACjB,CAAC;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphFormatError } from "@graphty/graph-format";
|
|
2
|
-
import { aw as isNameChar, ax as XML_ILLEGAL_CHAR_CODE, b as plural, $ as agree } from "./export-
|
|
2
|
+
import { aw as isNameChar, ax as XML_ILLEGAL_CHAR_CODE, b as plural, $ as agree } from "./export-B-aVCwyG.js";
|
|
3
3
|
class XmlSyntaxError extends Error {
|
|
4
4
|
/**
|
|
5
5
|
* Create the error.
|
|
@@ -188,7 +188,8 @@ function decodeEntities(raw, line, repairs) {
|
|
|
188
188
|
const hex = name.startsWith("#x") || name.startsWith("#X");
|
|
189
189
|
const digits = name.slice(hex ? 2 : 1);
|
|
190
190
|
const ok = hex ? /^0*[\da-fA-F]{1,6}$/.test(digits) : /^0*\d{1,7}$/.test(digits);
|
|
191
|
-
const
|
|
191
|
+
const radix = hex ? 16 : 10;
|
|
192
|
+
const cp = ok ? Number.parseInt(digits, radix) : -1;
|
|
192
193
|
const low = cp >= 55296 && cp <= 56319 ? lowSurrogateAfter(raw, semi + 1, repairs) : null;
|
|
193
194
|
if (low !== null) {
|
|
194
195
|
repairs?.surrogatePair?.(lineAt(raw, amp, line));
|
|
@@ -1309,4 +1310,4 @@ export {
|
|
|
1309
1310
|
tokenizeXml as t,
|
|
1310
1311
|
xmlIllegalTextNotes as x
|
|
1311
1312
|
};
|
|
1312
|
-
//# sourceMappingURL=escape-
|
|
1313
|
+
//# sourceMappingURL=escape-BJRLd3vJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escape-BJRLd3vJ.js","sources":["../../src/common/xml.ts","../../src/common/escape.ts"],"sourcesContent":["/**\n * The streaming XML tokenizer shared by the GEXF and GraphML importers (design sections 8.2 and\n * 8.4): SAX-style start / end / text events over the text chunks of the common reader, so both\n * importers run in one pass with bounded memory and every issue carries a line number.\n *\n * Cost model: every character of the input is scanned once. A token that spans many chunks (a\n * long attribute value, comment, CDATA section or name) resumes where the previous chunk left off\n * instead of re-reading the token from its `<`, and line numbers are counted from a cached next\n * line-break position, so a document without line breaks costs the same as one with them.\n *\n * What it handles: the XML declaration and processing instructions (skipped), comments (skipped;\n * a `--` inside one, which XML 1.0 forbids, is accepted: a comment carries no data and banner\n * comments such as `<!-- ----- -->` are common in hand-written files),\n * CDATA sections (text), a DOCTYPE with an internal subset (skipped; entity declarations are not\n * expanded, so an unknown entity reference is a syntax error), the five predefined entities and\n * numeric character references (decimal and hexadecimal) in text and attribute values, attribute\n * value whitespace normalization, end-of-line normalization (CR LF and lone CR become LF), and\n * well-formedness: matching end tags, one root element, no text outside it, no duplicate\n * attributes, no unterminated markup at the end of the input. Namespaces are not resolved; element\n * and attribute names are reported as written (with their prefix).\n *\n * Why not fast-xml-parser: its XMLParser accepts mismatched and unclosed tags without error, does\n * not decode numeric character references unless the deprecated `htmlEntities` option is set, and\n * its validator (`XMLValidator`, the `parse(xml, true)` overload) and `XMLBuilder` are deprecated in\n * 5.x, which the root lint's `no-deprecated` rule forbids using; so the malformed corpus could not\n * be rejected and attribute values written by the common `escapeXmlAttribute` (` `) could not\n * be read back.\n */\n\nimport { type Column, type GraphSnapshot } from \"@graphty/graph-format\";\n\nimport { type LossNote } from \"../types.js\";\nimport { XML_ILLEGAL_CHAR_CODE } from \"./codes.js\";\nimport { isNameChar } from \"./export.js\";\nimport { agree, plural } from \"./plural.js\";\n\n/**\n * The events of the tokenizer; every callback is synchronous.\n * @category Plugin helpers\n */\nexport interface XmlHandler {\n /**\n * An element starts (a self-closing element produces start then end).\n * @param name - the element name as written, prefix included\n * @param attrs - the attributes, entities decoded, in document order\n * @param line - the 1-based line of the `<`\n * @param ns - the namespace URI the element's prefix (or the default namespace) is bound to:\n * \"\" when the element is in no namespace, null when its prefix is undeclared or the name is not\n * namespace-well-formed (a leading or trailing colon, two colons)\n */\n start(name: string, attrs: ReadonlyMap<string, string>, line: number, ns: string | null): void;\n /**\n * An element ends.\n * @param name - the element name\n * @param line - the 1-based line of the end tag (or of the self-closing start tag)\n */\n end(name: string, line: number): void;\n /**\n * Character data between two tags (entities decoded, CDATA included), one call per run;\n * whitespace-only runs are delivered too.\n * @param text - the text\n * @param line - the 1-based line where the run starts\n */\n text(text: string, line: number): void;\n /**\n * A DOCTYPE declaration (optional; its internal subset is never expanded).\n * @param text - the declaration as written, from `<!DOCTYPE` to its `>`\n * @param line - the 1-based line of the `<`\n */\n doctype?(text: string, line: number): void;\n}\n\n/**\n * A well-formedness or syntax error, with the line it was found on.\n * @category Plugin helpers\n */\nexport class XmlSyntaxError extends Error {\n /** The 1-based line. */\n readonly line: number;\n\n /**\n * Create the error.\n * @param message - a plain-ASCII message\n * @param line - the 1-based line\n */\n constructor(message: string, line: number) {\n super(message);\n this.name = \"XmlSyntaxError\";\n this.line = line;\n }\n}\n\n/**\n * The input holds no markup at all (empty, whitespace only, a byte order mark only): an importer\n * reports it as E_EMPTY_INPUT rather than as a syntax error.\n * @category Plugin helpers\n */\nexport class XmlEmptyInputError extends XmlSyntaxError {\n /**\n * Create the error.\n * @param line - the 1-based line where the input ended\n */\n constructor(line: number) {\n super(\"the input is empty: no root element\", line);\n this.name = \"XmlEmptyInputError\";\n }\n}\n\n/**\n * Opt-in repairs of two defects the Cytoscape XGMML writer is known to produce. Each is off unless its callback is given; GEXF and GraphML never\n * pass them, so their documents stay strictly well-formed. The callback is told the line of each\n * repair, so the importer can warn per occurrence.\n * @category Plugin helpers\n */\nexport interface XmlRepairs {\n /**\n * Read an `&` that is not followed by a `;` within the next 7 characters as `&` (Cytoscape's\n * `cytoscape.xgmml.repair.bare.ampersands` lookahead); an `&name;` that does end in time is\n * still decoded, and still fatal when the entity is unknown. A complete numeric character\n * reference is decoded whatever its length (`😀`), where Cytoscape's byte lookahead\n * would turn it into text.\n */\n readonly bareAmpersand?: ((line: number) => void) | undefined;\n /**\n * Join a high-surrogate character reference immediately followed by a low-surrogate one\n * (`��`, which XML 1.0 forbids but Cytoscape writes for astral characters) into\n * the one character they encode; a lone surrogate stays fatal.\n */\n readonly surrogatePair?: ((line: number) => void) | undefined;\n}\n\n/** How far Cytoscape's bare-ampersand repair looks for the `;` that ends an entity reference. */\nconst BARE_AMPERSAND_LOOKAHEAD = 7;\n\n/** A numeric character reference at the start of a text: `{` or ``. */\nconst CHAR_REFERENCE = /^&#(?:[xX]([0-9a-fA-F]{1,6})|(\\d{1,7}));/;\n\n/** A numeric character reference at the end of a text. */\nconst TRAILING_CHAR_REFERENCE = /&#(?:[xX]([0-9a-fA-F]{1,6})|(\\d{1,7}));$/;\n\nconst NAMED_ENTITIES: Readonly<Record<string, string>> = {\n lt: \"<\",\n gt: \">\",\n amp: \"&\",\n quot: '\"',\n apos: \"'\",\n};\n\nconst LT = 60;\nconst GT = 62;\nconst SLASH = 47;\nconst EQUALS = 61;\nconst QUOTE = 34;\nconst APOS = 39;\nconst OPEN_BRACKET = 91;\nconst CLOSE_BRACKET = 93;\nconst BANG = 33;\nconst DASH = 45;\nconst QUESTION = 63;\n\n/** The longest entity reference held back at a chunk boundary (`` is 10 characters). */\nconst MAX_ENTITY_LENGTH = 16;\n\n/** Markup shorter than this (`<![CDATA[` is 9 characters) cannot be classified yet. */\nconst MIN_DECIDABLE_MARKUP = 9;\n\n/**\n * Whether a char code is XML whitespace (space, tab, LF, CR).\n * @param c - the char code\n * @returns true for whitespace\n */\nfunction isSpace(c: number): boolean {\n return c === 32 || c === 9 || c === 10 || c === 13;\n}\n\n/**\n * Whether a code point may start an XML Name: a NameChar that is not a digit, `-`, `.`, U+00B7,\n * a combining character (U+0300..U+036F) or U+203F / U+2040.\n * @param cp - the code point\n * @returns true for a NameStartChar\n */\nfunction isNameStart(cp: number): boolean {\n if (!isNameChar(cp)) {\n return false;\n }\n if ((cp >= 0x30 && cp <= 0x39) || cp === 0x2d || cp === 0x2e || cp === 0xb7) {\n return false;\n }\n return !(cp >= 0x300 && cp <= 0x36f) && cp !== 0x203f && cp !== 0x2040;\n}\n\n/** ASCII code -> whether it is a NameStartChar / NameChar, for the fast path of readName(). */\nconst ASCII_NAME_START = new Uint8Array(128);\nconst ASCII_NAME_CHAR = new Uint8Array(128);\nfor (let c = 0; c < 128; c++) {\n ASCII_NAME_START[c] = isNameStart(c) ? 1 : 0;\n ASCII_NAME_CHAR[c] = isNameChar(c) ? 1 : 0;\n}\n\n/**\n * Characters XML 1.0 forbids in a document (the Char production): C0 controls other than tab, LF\n * and CR, U+FFFE / U+FFFF, and lone surrogates (the `u` flag makes the surrogate class match only\n * an unpaired one). Built from char codes so no control character appears in the source.\n */\nconst ILLEGAL_CHAR = new RegExp(\n `[${String.fromCharCode(0)}-${String.fromCharCode(8)}${String.fromCharCode(11)}${String.fromCharCode(12)}` +\n `${String.fromCharCode(14)}-${String.fromCharCode(31)}\\\\uFFFE\\\\uFFFF\\\\uD800-\\\\uDFFF]`,\n \"u\",\n);\n\n/**\n * Whether a text holds a character XML 1.0 forbids (see ILLEGAL_CHAR); such a character cannot be\n * written even as a character reference, so a conforming parser rejects the whole document.\n * @param text - the text\n * @returns true when the text cannot appear in an XML 1.0 document\n * @category Plugin helpers\n */\nexport function hasIllegalXmlChar(text: string): boolean {\n return ILLEGAL_CHAR.test(text);\n}\n\n/**\n * Where the first character XML 1.0 forbids is in a text.\n * @param text - the text\n * @returns its index, or -1\n */\nfunction illegalCharIndex(text: string): number {\n const match = ILLEGAL_CHAR.exec(text);\n return match === null ? -1 : match.index;\n}\n\n/**\n * The loss notes of the texts a snapshot holds that no XML 1.0 document can carry (see\n * hasIllegalXmlChar): one E_XML_ILLEGAL_CHAR note per column (node, edge and graph string / dict /\n * list-of-text columns) and one for the ids, each counting the affected rows; export() throws on\n * the first such text. Shared by the GEXF and GraphML exporters' check().\n * @param snapshot - the snapshot\n * @returns the notes, empty when every text is writable\n * @category Plugin helpers\n */\nexport function xmlIllegalTextNotes(snapshot: GraphSnapshot): LossNote[] {\n const notes: LossNote[] = [];\n let ids = 0;\n for (let i = 0; i < snapshot.nodeCount; i++) {\n const id = snapshot.ids.idOf(i);\n if (typeof id === \"string\" && hasIllegalXmlChar(id)) {\n ids++;\n }\n }\n if (ids > 0) {\n notes.push(\n Object.freeze({\n code: XML_ILLEGAL_CHAR_CODE,\n message: `${ids} node id${plural(ids)} ${agree(ids, \"holds\", \"hold\")} a character XML 1.0 cannot carry; the save fails`,\n column: null,\n count: ids,\n }),\n );\n }\n for (const [domain, table] of [\n [\"node\", snapshot.nodes],\n [\"edge\", snapshot.edges],\n [\"graph\", snapshot.graph],\n ] as const) {\n for (const column of table) {\n const bad = countIllegalRows(column);\n if (bad > 0) {\n notes.push(\n Object.freeze({\n code: XML_ILLEGAL_CHAR_CODE,\n message: `${domain} column \"${column.meta.name}\": ${bad} value${plural(bad)} ${agree(bad, \"holds\", \"hold\")} a character XML 1.0 cannot carry; the save fails`,\n column: column.meta.name,\n count: bad,\n }),\n );\n }\n }\n }\n return notes;\n}\n\n/**\n * How many set rows of a text column hold an XML-illegal character.\n * @param column - the column\n * @returns the count; 0 for a non-text column\n */\nfunction countIllegalRows(column: Column): number {\n let bad = 0;\n if (column.dtype === \"string\" || column.dtype === \"dict\") {\n for (let r = 0; r < column.length; r++) {\n if (column.isSet(r) && hasIllegalXmlChar(column.value(r) as string)) {\n bad++;\n }\n }\n } else if (column.dtype === \"list\" && (column.meta.itemDtype === \"string\" || column.meta.itemDtype === \"dict\")) {\n for (let r = 0; r < column.length; r++) {\n if (\n column.isSet(r) &&\n column.sliceOf(r).some((item) => typeof item === \"string\" && hasIllegalXmlChar(item))\n ) {\n bad++;\n }\n }\n }\n return bad;\n}\n\n/**\n * The encoding pseudo-attribute of an XML declaration at the very start of a document (one\n * anywhere else is a syntax error of the tokenizer).\n */\nconst XML_DECLARED_ENCODING = /^<\\?xml\\s[^>]*?\\bencoding\\s*=\\s*[\"']([A-Za-z][A-Za-z0-9._-]*)[\"']/;\n\n/**\n * The encoding an XML document declares in its prolog (`<?xml version=\"1.0\" encoding=\"...\"?>`),\n * for the shared byte decoder (common/input.ts).\n * @param head - the start of the document, decoded as windows-1252\n * @returns the declared label, or null when there is no declaration or it names no encoding\n * @category Plugin helpers\n */\nexport function xmlDeclaredEncoding(head: string): string | null {\n const match = XML_DECLARED_ENCODING.exec(head);\n return match === null ? null : match[1];\n}\n\n/**\n * The head of a document as text for an XML format's sniff(): UTF-16 when a byte order mark (or\n * BOM-less UTF-16 `<?`, XML 1.0 Appendix F) says so, else UTF-8, never failing.\n * @param head - the first bytes\n * @returns the text, a leading byte order mark removed\n * @category Plugin helpers\n */\nexport function sniffXmlText(head: Uint8Array): string {\n let label = \"utf-8\";\n if ((head[0] === 0xff && head[1] === 0xfe) || (head[0] === 0x3c && head[1] === 0x00 && head[2] === 0x3f)) {\n label = \"utf-16le\";\n } else if ((head[0] === 0xfe && head[1] === 0xff) || (head[0] === 0x00 && head[1] === 0x3c && head[3] === 0x3f)) {\n label = \"utf-16be\";\n }\n return new TextDecoder(label, { fatal: false }).decode(head);\n}\n\n/**\n * Whether a text is an XML Name.\n * @param text - the text\n * @returns true for a well-formed name\n * @category Plugin helpers\n */\nexport function isXmlName(text: string): boolean {\n if (text.length === 0) {\n return false;\n }\n let first = true;\n for (const ch of text) {\n const cp = ch.codePointAt(0);\n if (cp === undefined || (first ? !isNameStart(cp) : !isNameChar(cp))) {\n return false;\n }\n first = false;\n }\n return true;\n}\n\n/**\n * Whether a code point is a legal XML 1.0 character.\n * @param cp - the code point\n * @returns true when a character reference may produce it\n */\nfunction isXmlChar(cp: number): boolean {\n return (\n cp === 0x9 ||\n cp === 0xa ||\n cp === 0xd ||\n (cp >= 0x20 && cp <= 0xd7ff) ||\n (cp >= 0xe000 && cp <= 0xfffd) ||\n (cp >= 0x10000 && cp <= 0x10ffff)\n );\n}\n\n/**\n * Decode the predefined entities and character references of a text.\n * @param raw - the text as written\n * @param line - the line, for errors\n * @param repairs - the opt-in repairs (XGMML only); none by default\n * @returns the decoded text\n * @category Plugin helpers\n */\nexport function decodeEntities(raw: string, line: number, repairs?: XmlRepairs): string {\n let amp = raw.indexOf(\"&\");\n if (amp < 0) {\n return raw;\n }\n let out = \"\";\n let start = 0;\n while (amp >= 0) {\n out += raw.slice(start, amp);\n const semi = raw.indexOf(\";\", amp + 1);\n if (\n repairs?.bareAmpersand !== undefined &&\n (semi < 0 || semi - amp > BARE_AMPERSAND_LOOKAHEAD) &&\n // a well-formed character reference longer than the lookahead (😀) is not bare\n !CHAR_REFERENCE.test(raw.slice(amp, amp + 12))\n ) {\n repairs.bareAmpersand(lineAt(raw, amp, line));\n out += \"&\";\n start = amp + 1;\n amp = raw.indexOf(\"&\", start);\n continue;\n }\n if (semi < 0) {\n throw new XmlSyntaxError(\"unterminated entity reference\", lineAt(raw, amp, line));\n }\n const name = raw.slice(amp + 1, semi);\n if (name.startsWith(\"#\")) {\n const hex = name.startsWith(\"#x\") || name.startsWith(\"#X\");\n const digits = name.slice(hex ? 2 : 1);\n // XML 1.0 puts no limit on leading zeros (A is \"A\")\n const ok = hex ? /^0*[\\da-fA-F]{1,6}$/.test(digits) : /^0*\\d{1,7}$/.test(digits);\n const radix = hex ? 16 : 10;\n const cp = ok ? Number.parseInt(digits, radix) : -1;\n const low = cp >= 0xd800 && cp <= 0xdbff ? lowSurrogateAfter(raw, semi + 1, repairs) : null;\n if (low !== null) {\n repairs?.surrogatePair?.(lineAt(raw, amp, line));\n out += String.fromCharCode(cp, low.unit);\n start = low.end;\n amp = raw.indexOf(\"&\", start);\n continue;\n }\n if (cp < 0 || !isXmlChar(cp)) {\n throw new XmlSyntaxError(`invalid character reference &${name};`, lineAt(raw, amp, line));\n }\n out += String.fromCodePoint(cp);\n } else {\n const value = NAMED_ENTITIES[name];\n if (value === undefined) {\n throw new XmlSyntaxError(`unknown entity &${name};`, lineAt(raw, amp, line));\n }\n out += value;\n }\n start = semi + 1;\n amp = raw.indexOf(\"&\", start);\n }\n return out + raw.slice(start);\n}\n\n/**\n * The line of a position inside a text that starts on a known line.\n * @param raw - the text\n * @param at - the position\n * @param line - the line the text starts on\n * @returns the line of the position\n */\nfunction lineAt(raw: string, at: number, line: number): number {\n let n = line;\n for (let i = raw.indexOf(\"\\n\"); i >= 0 && i < at; i = raw.indexOf(\"\\n\", i + 1)) {\n n++;\n }\n return n;\n}\n\n/**\n * The low-surrogate character reference that may follow a high-surrogate one, when the\n * surrogate-pair repair is on.\n * @param raw - the text\n * @param at - where the next reference would start\n * @param repairs - the repairs in force\n * @returns the low surrogate code unit and the index after its reference, or null\n */\nfunction lowSurrogateAfter(\n raw: string,\n at: number,\n repairs: XmlRepairs | undefined,\n): { readonly unit: number; readonly end: number } | null {\n if (repairs?.surrogatePair === undefined || raw.charCodeAt(at) !== 38) {\n return null;\n }\n const match = CHAR_REFERENCE.exec(raw.slice(at, at + 12));\n if (match === null) {\n return null;\n }\n const unit = match[1] === undefined ? Number.parseInt(match[2], 10) : Number.parseInt(match[1], 16);\n return unit >= 0xdc00 && unit <= 0xdfff ? { unit, end: at + match[0].length } : null;\n}\n\n/**\n * Whether a text is whitespace only.\n * @param text - the text\n * @returns true when every character is XML whitespace (also for an empty text)\n * @category Plugin helpers\n */\nexport function isWhitespace(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n if (!isSpace(text.charCodeAt(i))) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * The local part of a possibly prefixed XML name.\n * @param name - the name as written\n * @returns the text after the last colon, or the name itself\n * @category Plugin helpers\n */\nexport function localName(name: string): string {\n const colon = name.lastIndexOf(\":\");\n return colon < 0 ? name : name.slice(colon + 1);\n}\n\n/**\n * Tokenize XML text arriving in chunks and deliver events to a handler. Throws XmlSyntaxError on\n * malformed input; any error the handler throws propagates unchanged.\n * @param chunks - the text (already UTF-8 decoded, BOM removed)\n * @param handler - the event sink\n * @param repairs - the opt-in repairs (XGMML only); none by default\n * @category Plugin helpers\n */\nexport async function tokenizeXml(\n chunks: AsyncIterable<string>,\n handler: XmlHandler,\n repairs?: XmlRepairs,\n): Promise<void> {\n const tokenizer = new XmlTokenizer(handler, repairs);\n // XML 1.0 section 2.8: nothing may precede the XML declaration, not even whitespace (template\n // output often adds a line break, and the declared encoding would then go unread)\n let skipped = 0;\n let lines = 1;\n let leading = true;\n try {\n for await (const chunk of chunks) {\n if (leading) {\n const start = chunk.search(/\\S/);\n const blank = start < 0 ? chunk : chunk.slice(0, start);\n skipped += blank.length;\n lines += blank.split(\"\\n\").length - 1;\n if (start >= 0) {\n leading = false;\n if (skipped > 0 && /^<\\?xml\\s/.test(chunk.slice(start, start + 6))) {\n throw new XmlSyntaxError(\n \"the XML declaration must be at the very start of the document; whitespace precedes it\",\n lines,\n );\n }\n }\n }\n tokenizer.push(chunk);\n }\n tokenizer.finish();\n } catch (err) {\n if (err instanceof XmlSyntaxError && tokenizer.declaresXml11 && !err.message.includes(\"XML 1.1\")) {\n throw new XmlSyntaxError(\n `${err.message}; the document declares XML 1.1, which graph-io does not read (it reads XML 1.0)`,\n err.line,\n );\n }\n throw err;\n }\n}\n\n/** The result of parsing one start tag out of the buffer. */\ninterface StartTag {\n /** The element name. */\n readonly name: string;\n /** The attributes. */\n readonly attrs: Map<string, string>;\n /** Whether the tag ends with `/>`. */\n readonly selfClosing: boolean;\n /** Whether an attribute name starts with `xmlns` (a namespace declaration may be among them). */\n readonly declaresNamespace: boolean;\n /** The buffer index one past the `>`. */\n readonly end: number;\n}\n\n/** The kinds of markup whose end may lie in a later chunk. */\ntype PendingKind = \"decl\" | \"comment\" | \"cdata\" | \"pi\" | \"endtag\" | \"doctype\" | \"starttag\";\n\n/** The terminator of each fixed-terminator markup kind. */\nconst TERMINATORS: Readonly<Partial<Record<PendingKind, string>>> = {\n comment: \"-->\",\n cdata: \"]]>\",\n pi: \"?>\",\n endtag: \">\",\n};\n\n/**\n * An incomplete piece of markup at the end of the input so far: its text pieces (never joined\n * until the end is found, so a token spanning many chunks costs its length once) and the state\n * the terminator scan is in. `tail` holds the last characters of the pieces a fixed terminator\n * could straddle; `quote` is the open quote character (0 outside a value) of a start tag or a\n * DOCTYPE; `depth`, `comment`, `pi` and `run` track a DOCTYPE's internal subset.\n */\ninterface Pending {\n kind: PendingKind;\n readonly pieces: string[];\n tail: string;\n quote: number;\n depth: number;\n comment: boolean;\n pi: boolean;\n run: number;\n}\n\n/** One `xmlns` / `xmlns:prefix` declaration in scope. */\ninterface NamespaceBinding {\n /** The prefix; \"\" for the default namespace. */\n readonly prefix: string;\n /** The namespace URI; \"\" undeclares the default namespace. */\n readonly uri: string;\n /** The element depth that declared it (the stack length before the element was pushed). */\n readonly depth: number;\n}\n\n/** The namespace the `xml` prefix is bound to by definition. */\nconst XML_NAMESPACE = \"http://www.w3.org/XML/1998/namespace\";\n\n/** The markup declarations a truncated `<!...` at the end of the input may have been cut from. */\nconst DECLARATION_OPENERS: readonly string[] = [\"<!--\", \"<![CDATA[\", \"<!DOCTYPE\"];\n\n/**\n * The tokenizer state: the unconsumed tail of the input, the current line, the open element\n * stack and the text run being accumulated. `push()` chunks, then `finish()`.\n * @category Plugin helpers\n */\nexport class XmlTokenizer {\n private readonly handler: XmlHandler;\n\n /** Unconsumed input that is not part of a pending token: at most a held-back entity or the last chunk. */\n private buffer = \"\";\n\n /** The markup whose end has not arrived yet, or null. */\n private pending: Pending | null = null;\n\n /** The line number at the start of `buffer` (or of the pending markup). */\n private line = 1;\n\n /**\n * The index of the next line break in `buffer` at or after the last counted position: -2\n * when not yet searched for the current buffer, -1 when the buffer holds no further break.\n */\n private nextBreak = -2;\n\n /** A CR held back from the end of the previous chunk (it may be the first half of CR LF). */\n private pendingCr = false;\n\n /** Whether the input has ended (an incomplete token is then an error, not a wait). */\n private final = false;\n\n /** The text run being accumulated (entities decoded), and the line it started on. */\n private text = \"\";\n\n private textLine = 1;\n\n private readonly stack: string[] = [];\n\n private rootSeen = false;\n\n private rootClosed = false;\n\n /** Whether any markup was consumed (an input with none is empty, not malformed). */\n private markupSeen = false;\n\n /** Whether nothing has been consumed yet: the XML declaration may only appear here. */\n private atStart = true;\n\n /** Whether a DOCTYPE declaration was read (one is allowed, in the prolog). */\n private doctypeSeen = false;\n\n /** The version of the XML declaration, or null. */\n private version: string | null = null;\n\n /** The last two characters of the character data since the last markup, for the `]]>` check. */\n private textTail = \"\";\n\n /** A high surrogate held back from the end of the previous chunk (its low half may start the next). */\n private pendingHigh = \"\";\n\n /** The namespace declarations in scope, innermost last. */\n private readonly bindings: NamespaceBinding[] = [];\n\n private readonly repairs: XmlRepairs | undefined;\n\n /**\n * Create a tokenizer.\n * @param handler - the event sink\n * @param repairs - the opt-in repairs (XGMML only); none by default\n */\n constructor(handler: XmlHandler, repairs?: XmlRepairs) {\n this.handler = handler;\n this.repairs = repairs;\n }\n\n /**\n * Whether the document's XML declaration says version 1.1 (read by the XML 1.0 rules all the\n * same; the syntax error of a 1.1-only construct then says why).\n * @returns true after a `<?xml version=\"1.1\"?>` declaration\n */\n get declaresXml11(): boolean {\n return this.version === \"1.1\";\n }\n\n /**\n * Feed one chunk and emit every complete token in it.\n * @param chunk - the text\n */\n push(chunk: string): void {\n let text = chunk;\n if (this.pendingHigh.length > 0) {\n text = this.pendingHigh + text;\n this.pendingHigh = \"\";\n }\n const last = text.charCodeAt(text.length - 1); // NOSONAR(S7758): reads UTF-16 code units on purpose\n if (last >= 0xd800 && last <= 0xdbff) {\n // a text chunk may end between the two halves of an astral character\n this.pendingHigh = text.slice(-1);\n text = text.slice(0, -1);\n }\n if (this.pendingCr) {\n text = `\\r${text}`;\n this.pendingCr = false;\n }\n if (text.endsWith(\"\\r\")) {\n this.pendingCr = true;\n text = text.slice(0, -1);\n }\n if (text.includes(\"\\r\")) {\n text = text.replaceAll(/\\r\\n?/g, \"\\n\");\n }\n this.feed(text);\n }\n\n /** Signal the end of the input: flush the last text run and check well-formedness. */\n finish(): void {\n this.final = true;\n const held = this.pendingHigh;\n this.pendingHigh = \"\";\n if (this.pendingCr) {\n this.pendingCr = false;\n this.feed(`\\n${held}`);\n } else {\n this.feed(held);\n }\n if (this.pending !== null || this.buffer.length > 0) {\n throw new XmlSyntaxError(\"unexpected end of input inside markup\", this.line);\n }\n this.flushText();\n if (this.stack.length > 0) {\n throw new XmlSyntaxError(`unclosed element <${this.stack[this.stack.length - 1]}>`, this.line);\n }\n if (!this.rootSeen) {\n if (!this.markupSeen) {\n throw new XmlEmptyInputError(this.line);\n }\n throw new XmlSyntaxError(\"no root element\", this.line);\n }\n }\n\n /**\n * Append normalized text: continue a pending token's terminator scan over the new text alone,\n * and once the token is complete (or when none is pending) scan the buffer for tokens.\n * @param text - the text, line breaks normalized\n */\n private feed(text: string): void {\n const { pending } = this;\n if (pending === null) {\n this.buffer = this.buffer.length === 0 ? text : this.buffer + text;\n this.nextBreak = -2;\n this.scan();\n return;\n }\n if (pending.kind === \"decl\") {\n // fewer than MIN_DECIDABLE_MARKUP characters of markup: the kind is decided once enough arrived\n this.pending = null;\n this.buffer = pending.pieces.join(\"\") + text;\n this.nextBreak = -2;\n this.scan();\n return;\n }\n const end = this.scanPending(pending, text);\n if (end < 0) {\n if (text.length > 0) {\n pending.pieces.push(text);\n }\n if (this.final) {\n throw new XmlSyntaxError(\"unexpected end of input inside markup\", this.line);\n }\n return;\n }\n this.pending = null;\n pending.pieces.push(text.slice(0, end));\n this.buffer = pending.pieces.join(\"\") + text.slice(end);\n this.nextBreak = -2;\n this.scan();\n }\n\n /**\n * Continue the terminator scan of a pending token over new text.\n * @param pending - the pending token\n * @param text - the new text\n * @returns the index in `text` one past the token's end, or -1 when it does not end there\n */\n private scanPending(pending: Pending, text: string): number {\n switch (pending.kind) {\n case \"starttag\":\n return this.scanStartTag(pending, text, 0);\n case \"doctype\":\n return this.scanDoctype(pending, text, 0);\n case \"decl\":\n return -1;\n default: {\n const terminator = TERMINATORS[pending.kind] ?? \">\";\n const probe = pending.tail + text;\n const at = probe.indexOf(terminator);\n if (at < 0) {\n pending.tail = probe.slice(Math.max(0, probe.length - (terminator.length - 1)));\n return -1;\n }\n return at + terminator.length - pending.tail.length;\n }\n }\n }\n\n /**\n * Scan text for the `>` that ends a start tag, skipping quoted attribute values (the quote\n * state survives between calls).\n * @param pending - the pending token\n * @param text - the text\n * @param from - where to start\n * @returns the index one past the `>`, or -1\n */\n private scanStartTag(pending: Pending, text: string, from: number): number {\n let { quote } = pending;\n const n = text.length;\n let i = from;\n while (i < n) {\n if (quote !== 0) {\n // inside an attribute value: jump to its closing quote\n const close = text.indexOf(String.fromCharCode(quote), i);\n if (close < 0) {\n break;\n }\n quote = 0;\n i = close + 1;\n continue;\n }\n const c = text.charCodeAt(i);\n if (c === QUOTE || c === APOS) {\n quote = c;\n } else if (c === GT) {\n pending.quote = 0;\n return i + 1;\n }\n i++;\n }\n pending.quote = quote;\n return -1;\n }\n\n /**\n * Scan text for the `>` that ends a DOCTYPE declaration, skipping a bracketed internal subset,\n * quoted literals and comments inside the subset. A character state machine, so the state\n * (`depth`, `quote`, `comment`, and `run`, the progress through a `<!--` or the dashes before\n * a `-->`) survives between calls and nothing is re-read.\n * @param pending - the pending token\n * @param text - the text\n * @param from - where to start\n * @returns the index one past the `>`, or -1\n */\n private scanDoctype(pending: Pending, text: string, from: number): number {\n let { quote, depth, comment, pi, run } = pending;\n for (let i = from; i < text.length; i++) {\n const c = text.charCodeAt(i);\n if (pi) {\n // a processing instruction in the subset ends at `?>`; quotes inside it are text\n if (c === GT && run === 1) {\n pi = false;\n run = 0;\n } else {\n run = c === QUESTION ? 1 : 0;\n }\n continue;\n }\n if (comment) {\n if (c === DASH) {\n run++;\n } else if (c === GT && run >= 2) {\n comment = false;\n run = 0;\n } else {\n run = 0;\n }\n continue;\n }\n if (quote !== 0) {\n if (c === quote) {\n quote = 0;\n }\n continue;\n }\n if (depth > 0) {\n if (run === 1 && c === BANG) {\n run = 2;\n continue;\n }\n if (run === 2 && c === DASH) {\n run = 3;\n continue;\n }\n if (run === 3 && c === DASH) {\n comment = true;\n run = 0;\n continue;\n }\n if (run === 1 && c === QUESTION) {\n pi = true;\n run = 0;\n continue;\n }\n run = 0;\n if (c === LT) {\n run = 1;\n continue;\n }\n }\n if (c === QUOTE || c === APOS) {\n quote = c;\n } else if (c === OPEN_BRACKET) {\n depth++;\n } else if (c === CLOSE_BRACKET) {\n depth--;\n } else if (c === GT && depth <= 0) {\n pending.quote = 0;\n pending.depth = 0;\n pending.comment = false;\n pending.pi = false;\n pending.run = 0;\n return i + 1;\n }\n }\n pending.quote = quote;\n pending.depth = depth;\n pending.comment = comment;\n pending.pi = pi;\n pending.run = run;\n return -1;\n }\n\n /**\n * Consume every complete token at the front of the buffer; an incomplete token at its end\n * becomes the pending token (its text moved out of the buffer), a possibly split entity\n * reference is held back in the buffer.\n */\n private scan(): void {\n const { buffer } = this;\n const { length } = buffer;\n let pos = 0;\n let incomplete = false;\n for (;;) {\n const lt = buffer.indexOf(\"<\", pos);\n if (lt < 0) {\n let end = length;\n if (!this.final) {\n // an entity reference may be split across chunks: hold back from its \"&\"\n const amp = buffer.lastIndexOf(\"&\");\n if (\n amp >= pos &&\n !buffer.includes(\";\", amp) &&\n // ponytail: a zero-padded reference longer than MAX_ENTITY_LENGTH is held back\n // whole, so an absurdly long run of zeros is re-scanned once per chunk\n (amp >= length - MAX_ENTITY_LENGTH || /^&#[xX]?0[\\da-fA-F]*$/.test(buffer.slice(amp)))\n ) {\n end = amp;\n }\n if (this.repairs?.surrogatePair !== undefined) {\n end = this.holdHighSurrogate(pos, end);\n }\n }\n this.takeText(pos, end);\n pos = end;\n break;\n }\n if (lt > pos) {\n this.takeText(pos, lt);\n pos = lt;\n }\n const next = this.consumeMarkup(pos);\n if (next < 0) {\n incomplete = true;\n break;\n }\n pos = next;\n }\n if (incomplete) {\n this.pending = this.startPending(buffer, pos);\n this.buffer = \"\";\n } else {\n this.buffer = pos === 0 ? buffer : buffer.slice(pos);\n }\n this.nextBreak = -2;\n }\n\n /**\n * Turn the incomplete markup at `pos` into a pending token, running the terminator scan over\n * the part already in the buffer so later chunks are scanned alone.\n * @param buffer - the buffer\n * @param pos - the index of the `<`\n * @returns the pending token\n */\n private startPending(buffer: string, pos: number): Pending {\n const piece = pos === 0 ? buffer : buffer.slice(pos);\n const pending: Pending = {\n kind: \"starttag\",\n pieces: [piece],\n tail: \"\",\n quote: 0,\n depth: 0,\n comment: false,\n pi: false,\n run: 0,\n };\n if (piece.length < MIN_DECIDABLE_MARKUP) {\n // too short to tell a comment from a start tag: wait for more before choosing a scan\n pending.kind = \"decl\";\n return pending;\n }\n if (piece.startsWith(\"<!--\")) {\n pending.kind = \"comment\";\n } else if (piece.startsWith(\"<![CDATA[\")) {\n pending.kind = \"cdata\";\n } else if (piece.startsWith(\"<!DOCTYPE\")) {\n pending.kind = \"doctype\";\n } else if (piece.startsWith(\"<!\")) {\n pending.kind = \"decl\";\n return pending;\n } else if (piece.startsWith(\"<?\")) {\n pending.kind = \"pi\";\n } else if (piece.startsWith(\"</\")) {\n pending.kind = \"endtag\";\n }\n // the part in the buffer holds no terminator (consumeMarkup said so); record the scan state\n switch (pending.kind) {\n case \"starttag\":\n this.scanStartTag(pending, piece, 1);\n break;\n case \"doctype\":\n this.scanDoctype(pending, piece, 9);\n break;\n default: {\n const terminator = TERMINATORS[pending.kind] ?? \">\";\n pending.tail = piece.slice(Math.max(0, piece.length - (terminator.length - 1)));\n break;\n }\n }\n return pending;\n }\n\n /**\n * Consume the markup starting at `pos` (a `<`).\n * @param pos - the index of the `<`\n * @returns the index after the markup, or -1 when the buffer ends before the markup does\n */\n private consumeMarkup(pos: number): number {\n const end = this.markupEnd(pos);\n if (end >= 0) {\n this.markupSeen = true;\n this.atStart = false;\n // markup ends a run of character data: a `]]>` cannot straddle it\n this.textTail = \"\";\n }\n return end;\n }\n\n /**\n * Read the markup starting at `pos` (a `<`) and deliver what it means.\n * @param pos - the index of the `<`\n * @returns the index after the markup, or -1 when the buffer ends before the markup does\n */\n private markupEnd(pos: number): number {\n const { buffer } = this;\n if (buffer.startsWith(\"<!\", pos)) {\n return this.declarationEnd(pos);\n }\n if (buffer.startsWith(\"<?\", pos)) {\n const end = buffer.indexOf(\"?>\", pos + 2);\n if (end < 0) {\n return -1;\n }\n this.processingInstruction(pos, end);\n this.advanceLine(pos, end + 2);\n return end + 2;\n }\n if (buffer.startsWith(\"</\", pos)) {\n const end = buffer.indexOf(\">\", pos + 2);\n if (end < 0) {\n return -1;\n }\n // whitespace may follow the name, never precede it\n const name = buffer.slice(pos + 2, end).trimEnd();\n if (!isXmlName(name)) {\n throw new XmlSyntaxError(`malformed end tag </${name}>`, this.line);\n }\n this.flushText();\n this.endElement(name);\n this.advanceLine(pos, end + 1);\n return end + 1;\n }\n const tag = this.parseStartTag(pos);\n if (tag === null) {\n return -1;\n }\n this.flushText();\n this.startElement(tag.name, tag.attrs, tag.declaresNamespace);\n if (tag.selfClosing) {\n this.endElement(tag.name);\n }\n this.advanceLine(pos, tag.end);\n return tag.end;\n }\n\n /**\n * Read the CDATA section at `pos` into the text.\n * @param pos - the index of the `<`\n * @returns the index after the section, or -1 when the buffer ends before the section does\n */\n private cdataEnd(pos: number): number {\n const end = this.buffer.indexOf(\"]]>\", pos + 9);\n if (end < 0) {\n return -1;\n }\n if (this.text.length === 0) {\n this.textLine = this.line;\n }\n const cdata = this.buffer.slice(pos + 9, end);\n const bad = illegalCharIndex(cdata);\n if (bad >= 0) {\n throw new XmlSyntaxError(\n \"a character XML 1.0 forbids appears in a CDATA section\",\n this.lineIn(pos, pos + 9 + bad),\n );\n }\n this.text += cdata;\n this.advanceLine(pos, end + 3);\n return end + 3;\n }\n\n /**\n * Read the `<!...>` markup at `pos`: a comment, a CDATA section or the DOCTYPE.\n * @param pos - the index of the `<`\n * @returns the index after the markup, or -1 when the buffer ends before the markup does\n */\n private declarationEnd(pos: number): number {\n const { buffer } = this;\n if (buffer.length - pos < MIN_DECIDABLE_MARKUP) {\n // \"<![CDATA[\" is 9 characters; wait until the kind of declaration is decidable, and at\n // the end of the input read the start of one cut short as a truncation\n const head = buffer.slice(pos);\n if (!this.final || DECLARATION_OPENERS.some((opener) => opener.startsWith(head))) {\n return -1;\n }\n }\n if (buffer.startsWith(\"<!--\", pos)) {\n const end = buffer.indexOf(\"-->\", pos + 4);\n if (end < 0) {\n return -1;\n }\n // a \"--\" inside, which XML 1.0 forbids, is accepted: the comment carries no data\n this.advanceLine(pos, end + 3);\n return end + 3;\n }\n if (buffer.startsWith(\"<![CDATA[\", pos)) {\n return this.cdataEnd(pos);\n }\n if (!buffer.startsWith(\"<!DOCTYPE\", pos)) {\n if (buffer.slice(pos + 2, pos + 9).toUpperCase() === \"DOCTYPE\") {\n throw new XmlSyntaxError(\n `<!${buffer.slice(pos + 2, pos + 9)}> is not XML (it must be written <!DOCTYPE>); the input looks like an HTML document`,\n this.line,\n );\n }\n throw new XmlSyntaxError(\"unexpected markup declaration\", this.line);\n }\n if (this.rootSeen || this.doctypeSeen) {\n throw new XmlSyntaxError(\"a DOCTYPE declaration is allowed once, before the root element\", this.line);\n }\n const state: Pending = {\n kind: \"doctype\",\n pieces: [],\n tail: \"\",\n quote: 0,\n depth: 0,\n comment: false,\n pi: false,\n run: 0,\n };\n const end = this.scanDoctype(state, buffer, pos + 9);\n if (end < 0) {\n return -1;\n }\n this.doctypeSeen = true;\n this.handler.doctype?.(buffer.slice(pos, end), this.line);\n this.advanceLine(pos, end);\n return end;\n }\n\n /**\n * Check a processing instruction `<?target ...?>` (skipped otherwise): its target must be a\n * name, and the reserved target `xml` is the XML declaration, allowed only at the very start\n * of the document with a 1.x version.\n * @param pos - the index of the `<`\n * @param end - the index of the `?>`\n */\n private processingInstruction(pos: number, end: number): void {\n const body = this.buffer.slice(pos + 2, end);\n const target = /^[^\\s]*/.exec(body)?.[0] ?? \"\";\n if (!isXmlName(target)) {\n throw new XmlSyntaxError(`a processing instruction needs a target name, not \"${target}\"`, this.line);\n }\n if (target.toLowerCase() !== \"xml\") {\n return;\n }\n if (target !== \"xml\") {\n throw new XmlSyntaxError(\n `<?${target} is not an XML declaration (which is written <?xml in lower case); the target is reserved`,\n this.line,\n );\n }\n if (!this.atStart || pos !== 0) {\n throw new XmlSyntaxError(\n \"an XML declaration (<?xml ...?>) may appear only at the very start of the document; the target xml is reserved\",\n this.line,\n );\n }\n const version = /\\bversion\\s*=\\s*([\"'])([^\"']*)\\1/.exec(body)?.[2];\n if (version === undefined) {\n throw new XmlSyntaxError(\"the XML declaration has no version\", this.line);\n }\n if (!/^1\\.\\d+$/.test(version)) {\n throw new XmlSyntaxError(`XML version ${version} is not supported (only 1.x)`, this.line);\n }\n this.version = version;\n }\n\n /**\n * The line of a buffer position after `start`, the position the current line count refers to.\n * Used on the error path only.\n * @param start - a position on line `this.line`\n * @param at - the position\n * @returns its line\n */\n private lineIn(start: number, at: number): number {\n return lineAt(this.buffer.slice(start, at), at - start, this.line);\n }\n\n /**\n * Decode the entities of a text, naming XML 1.1 when a character reference XML 1.0 forbids\n * appears in a document that declares version 1.1.\n * @param raw - the text as written\n * @param line - the line the text starts on\n * @returns the decoded text\n */\n private decode(raw: string, line: number): string {\n try {\n return decodeEntities(raw, line, this.repairs);\n } catch (err) {\n if (err instanceof XmlSyntaxError && this.version !== null && this.version !== \"1.0\") {\n throw new XmlSyntaxError(\n `${err.message} (the document declares XML ${this.version}, whose character rules are not supported; it is read as XML 1.0)`,\n err.line,\n );\n }\n throw err;\n }\n }\n\n /**\n * Parse a start tag at `pos`.\n * @param pos - the index of the `<`\n * @returns the tag, or null when the buffer ends inside it\n */\n private parseStartTag(pos: number): StartTag | null {\n const { buffer } = this;\n const { length } = buffer;\n let i = pos + 1;\n const nameEnd = this.readName(i);\n if (nameEnd < 0) {\n return null;\n }\n if (nameEnd === i) {\n throw new XmlSyntaxError(\"expected an element name after <\", this.line);\n }\n const name = buffer.slice(i, nameEnd);\n i = nameEnd;\n const attrs = new Map<string, string>();\n let declaresNamespace = false;\n for (;;) {\n const before = i;\n while (i < length && isSpace(buffer.charCodeAt(i))) {\n i++;\n }\n if (i >= length) {\n return null;\n }\n const c = buffer.charCodeAt(i);\n if (c === GT) {\n return { name, attrs, selfClosing: false, declaresNamespace, end: i + 1 };\n }\n if (c === SLASH) {\n if (i + 1 >= length) {\n return null;\n }\n if (buffer.charCodeAt(i + 1) !== GT) {\n throw new XmlSyntaxError(`unexpected \"/\" in <${name}>`, this.lineIn(pos, i));\n }\n return { name, attrs, selfClosing: true, declaresNamespace, end: i + 2 };\n }\n if (i === before) {\n // the name, or the previous value's closing quote, runs into the next attribute\n throw new XmlSyntaxError(\n `the attributes of <${name}> must be separated by whitespace`,\n this.lineIn(pos, i),\n );\n }\n const attrEnd = this.readName(i);\n if (attrEnd < 0) {\n return null;\n }\n if (attrEnd === i) {\n throw new XmlSyntaxError(`malformed attribute in <${name}>`, this.lineIn(pos, i));\n }\n const attrName = buffer.slice(i, attrEnd);\n i = attrEnd;\n while (i < length && isSpace(buffer.charCodeAt(i))) {\n i++;\n }\n if (i >= length) {\n return null;\n }\n if (buffer.charCodeAt(i) !== EQUALS) {\n throw new XmlSyntaxError(`attribute ${attrName} of <${name}> has no value`, this.lineIn(pos, i));\n }\n i++;\n while (i < length && isSpace(buffer.charCodeAt(i))) {\n i++;\n }\n if (i >= length) {\n return null;\n }\n const quote = buffer.charCodeAt(i);\n if (quote !== QUOTE && quote !== APOS) {\n throw new XmlSyntaxError(`attribute ${attrName} of <${name}> is not quoted`, this.lineIn(pos, i));\n }\n const close = buffer.indexOf(quote === QUOTE ? '\"' : \"'\", i + 1);\n if (close < 0) {\n return null;\n }\n const line = this.lineIn(pos, i);\n if (attrs.has(attrName)) {\n throw new XmlSyntaxError(`duplicate attribute ${attrName} in <${name}>`, line);\n }\n const raw = buffer.slice(i + 1, close);\n if (hasIllegalXmlChar(raw)) {\n throw new XmlSyntaxError(\n `a character XML 1.0 forbids appears in attribute ${attrName} of <${name}>`,\n line,\n );\n }\n if (raw.includes(\"<\")) {\n throw new XmlSyntaxError(`a \"<\" in the value of attribute ${attrName} of <${name}> (write <)`, line);\n }\n if (attrName.startsWith(\"xmlns\")) {\n declaresNamespace = true;\n }\n attrs.set(attrName, this.decode(normalizeAttributeValue(raw), line));\n i = close + 1;\n }\n }\n\n /**\n * The end of the XML Name starting at `i` (an ASCII table for the common case, the code point\n * classes beyond it).\n * @param i - the start index\n * @returns the index after the name; `i` when no name starts there; -1 when the name may\n * continue past the end of the buffer\n */\n private readName(i: number): number {\n const { buffer } = this;\n const { length } = buffer;\n let j = i;\n while (j < length) {\n const c = buffer.charCodeAt(j);\n if (c < 0x80) {\n if ((j === i ? ASCII_NAME_START[c] : ASCII_NAME_CHAR[c]) === 0) {\n break;\n }\n j++;\n continue;\n }\n const cp = buffer.codePointAt(j);\n if (cp === undefined || (j === i ? !isNameStart(cp) : !isNameChar(cp))) {\n break;\n }\n j += cp > 0xffff ? 2 : 1;\n }\n return j >= length && !this.final ? -1 : j;\n }\n\n /**\n * Under the surrogate-pair repair, hold back a high-surrogate character reference that ends\n * the text taken so far, so it is decoded together with the low one the next chunk may start with.\n * @param pos - the start of the text\n * @param end - the end of the text that would be taken\n * @returns the end to take up to\n */\n private holdHighSurrogate(pos: number, end: number): number {\n const tail = this.buffer.slice(Math.max(pos, end - 12), end);\n const match = TRAILING_CHAR_REFERENCE.exec(tail);\n if (match === null) {\n return end;\n }\n const unit = match[1] === undefined ? Number.parseInt(match[2], 10) : Number.parseInt(match[1], 16);\n return unit >= 0xd800 && unit <= 0xdbff ? end - match[0].length : end;\n }\n\n /**\n * Move text from the buffer into the current run.\n * @param start - the start index\n * @param end - the end index (exclusive)\n */\n private takeText(start: number, end: number): void {\n if (end <= start) {\n return;\n }\n if (this.text.length === 0) {\n this.textLine = this.line;\n }\n const raw = this.buffer.slice(start, end);\n const bad = illegalCharIndex(raw);\n if (bad >= 0) {\n throw new XmlSyntaxError(\n \"a character XML 1.0 forbids appears in character data\",\n lineAt(raw, bad, this.line),\n );\n }\n if (raw.includes(\">\")) {\n const probe = this.textTail + raw;\n const close = probe.indexOf(\"]]>\");\n if (close >= 0) {\n throw new XmlSyntaxError(\n '\"]]>\" is not allowed in character data (write ]]>)',\n lineAt(raw, Math.max(0, close - this.textTail.length), this.line),\n );\n }\n }\n this.textTail = raw.length >= 2 ? raw.slice(-2) : (this.textTail + raw).slice(-2);\n this.atStart = false;\n this.text += this.decode(raw, this.line);\n this.advanceLine(start, end);\n }\n\n /**\n * Count the newlines of a consumed range. Ranges are consumed in order, so the next line break\n * is searched for once per buffer and re-searched only after it was passed; a buffer without\n * a further break is searched once and remembered as such.\n * @param start - the start index\n * @param end - the end index (exclusive)\n */\n private advanceLine(start: number, end: number): void {\n let i = this.nextBreak;\n if (i === -1) {\n return;\n }\n if (i === -2 || i < start) {\n i = this.buffer.indexOf(\"\\n\", start);\n }\n while (i >= 0 && i < end) {\n this.line++;\n i = this.buffer.indexOf(\"\\n\", i + 1);\n }\n this.nextBreak = i;\n }\n\n /** Deliver the accumulated text run, if any. */\n private flushText(): void {\n if (this.text.length === 0) {\n return;\n }\n const { text } = this;\n this.text = \"\";\n if (this.stack.length === 0) {\n if (!isWhitespace(text)) {\n throw new XmlSyntaxError(\"text outside the root element\", this.textLine);\n }\n return;\n }\n this.handler.text(text, this.textLine);\n }\n\n /**\n * Open an element.\n * @param name - the element name\n * @param attrs - its attributes\n * @param declaresNamespace - whether an attribute name starts with `xmlns`\n */\n private startElement(name: string, attrs: Map<string, string>, declaresNamespace: boolean): void {\n if (this.stack.length === 0) {\n if (this.rootClosed) {\n throw new XmlSyntaxError(`a second root element <${name}> follows the document element`, this.line);\n }\n this.rootSeen = true;\n }\n if (declaresNamespace) {\n for (const [key, uri] of attrs) {\n if (key === \"xmlns\") {\n this.bindings.push({ prefix: \"\", uri, depth: this.stack.length });\n } else if (key.startsWith(\"xmlns:\")) {\n this.bindings.push({ prefix: key.slice(6), uri, depth: this.stack.length });\n }\n }\n }\n this.stack.push(name);\n this.handler.start(name, attrs, this.line, this.namespaceOf(name));\n }\n\n /**\n * The namespace an element name is in (Namespaces in XML 1.0 section 6).\n * @param name - the element name as written\n * @returns the URI; \"\" for no namespace; null for an undeclared prefix or a name that is not\n * namespace-well-formed\n */\n private namespaceOf(name: string): string | null {\n const colon = name.indexOf(\":\");\n if (colon >= 0 && (colon === 0 || colon === name.length - 1 || name.includes(\":\", colon + 1))) {\n return null;\n }\n const prefix = colon < 0 ? \"\" : name.slice(0, colon);\n for (let i = this.bindings.length - 1; i >= 0; i--) {\n if (this.bindings[i].prefix === prefix) {\n return this.bindings[i].uri;\n }\n }\n if (prefix === \"xml\") {\n return XML_NAMESPACE;\n }\n return prefix === \"\" ? \"\" : null;\n }\n\n /**\n * Close an element, checking that it matches the innermost open one.\n * @param name - the element name\n */\n private endElement(name: string): void {\n const open = this.stack.at(-1) ?? null;\n if (open === null) {\n throw new XmlSyntaxError(`unexpected end tag </${name}>`, this.line);\n }\n if (open !== name) {\n throw new XmlSyntaxError(`end tag </${name}> does not match <${open}>`, this.line);\n }\n this.stack.pop();\n while ((this.bindings.at(-1)?.depth ?? -1) >= this.stack.length) {\n this.bindings.pop();\n }\n if (this.stack.length === 0) {\n this.rootClosed = true;\n }\n this.handler.end(name, this.line);\n }\n}\n\n/**\n * Attribute value normalization (XML 1.0 section 3.3.3): a literal tab or line break becomes a\n * space; a character reference to one is kept, which is why this runs before entity decoding.\n * @param raw - the value between the quotes\n * @returns the normalized value\n */\nfunction normalizeAttributeValue(raw: string): string {\n return raw.includes(\"\\n\") || raw.includes(\"\\t\") ? raw.replaceAll(/[\\n\\t]/g, \" \") : raw;\n}\n","/**\n * Id, label and value escaping for the text formats (design section 8.5), one function per\n * syntax, with the inverse where the importer needs it: XML attribute and element text (GEXF,\n * GraphML), GML quoted strings (`\"` and `&` and non-ASCII as `&#NN;` character entities, the\n * NetworkX convention), DOT ids (bare when the grammar allows, quoted with `\\\"` otherwise), RFC\n * 4180 CSV cells and Pajek labels.\n */\n\nimport { GraphFormatError } from \"@graphty/graph-format\";\n\nimport { hasIllegalXmlChar } from \"./xml.js\";\n\nconst XML_TEXT_SPECIAL = /[&<>\\r]/g;\nconst XML_ATTR_SPECIAL = /[&<>\"\\t\\n\\r]/g;\nconst XML_REPLACEMENTS: Readonly<Record<string, string>> = {\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n '\"': \""\",\n \"\\t\": \"	\",\n \"\\n\": \" \",\n \"\\r\": \" \",\n};\n\n/**\n * Escape text for an XML element body: `&`, `<`, `>` and a carriage return (which XML\n * end-of-line handling would turn into a line feed on every read) as character references. A\n * character XML 1.0 forbids (a C0 control other than tab / LF / CR, U+FFFE, U+FFFF, a lone\n * surrogate) has no XML spelling at all and is E_COLUMN_TYPE; the exporters' check() counts them.\n * @param text - the text\n * @returns the escaped text\n * @category Plugin helpers\n */\nexport function escapeXmlText(text: string): string {\n if (hasIllegalXmlChar(text)) {\n throw illegalXml(text);\n }\n return text.replaceAll(XML_TEXT_SPECIAL, (c) => XML_REPLACEMENTS[c]);\n}\n\n/**\n * Escape text for a double-quoted XML attribute value: `&`, `<`, `>`, `\"` and the whitespace\n * characters attribute normalization would fold; a character XML 1.0 forbids is E_COLUMN_TYPE.\n * @param text - the text\n * @returns the escaped text\n * @category Plugin helpers\n */\nexport function escapeXmlAttribute(text: string): string {\n if (hasIllegalXmlChar(text)) {\n throw illegalXml(text);\n }\n return text.replaceAll(XML_ATTR_SPECIAL, (c) => XML_REPLACEMENTS[c]);\n}\n\n/**\n * The error of a text no XML 1.0 document can carry.\n * @param text - the text\n * @returns the error\n */\nfunction illegalXml(text: string): GraphFormatError {\n return new GraphFormatError(\"E_COLUMN_TYPE\", \"the text holds a character XML 1.0 cannot carry\", {\n reason: \"xml illegal char\",\n length: text.length,\n });\n}\n\nconst GML_SPECIAL = /[\"&]|[^ -~]/gu;\n\n/**\n * Quote a GML string value: double quotes around the text with `\"`, `&` and every character\n * outside printable ASCII written as `&#NN;` (NetworkX's writer convention, which its reader and\n * Gephi's decode).\n * A lone surrogate cannot be written and is E_COLUMN_TYPE.\n * @param text - the text\n * @returns the quoted GML string\n * @category Plugin helpers\n */\nexport function quoteGmlString(text: string): string {\n const escaped = text.replaceAll(GML_SPECIAL, (c) => {\n const code = c.codePointAt(0);\n if (code === undefined) {\n return c;\n }\n if (code >= 0xd800 && code <= 0xdfff) {\n throw new GraphFormatError(\"E_COLUMN_TYPE\", \"a lone surrogate cannot be written as a GML string\", {\n reason: \"lone surrogate\",\n });\n }\n return `&#${code};`;\n });\n return `\"${escaped}\"`;\n}\n\nconst GML_ENTITY = /&(#\\d+|#x[0-9a-fA-F]+|[A-Za-z][A-Za-z0-9]*);/g;\n\n/** The XML entities and the ISO-8859-1 HTML entities (U+00A0..U+00FF), which GML uses for characters above 127. */\nconst GML_NAMED: ReadonlyMap<string, string> = (() => {\n const table = new Map<string, string>([\n [\"amp\", \"&\"],\n [\"quot\", '\"'],\n [\"lt\", \"<\"],\n [\"gt\", \">\"],\n [\"apos\", \"'\"],\n ]);\n const latin1 = (\n \"nbsp iexcl cent pound curren yen brvbar sect uml copy ordf laquo not shy reg macr deg plusmn sup2 \" +\n \"sup3 acute micro para middot cedil sup1 ordm raquo frac14 frac12 frac34 iquest Agrave Aacute Acirc \" +\n \"Atilde Auml Aring AElig Ccedil Egrave Eacute Ecirc Euml Igrave Iacute Icirc Iuml ETH Ntilde Ograve \" +\n \"Oacute Ocirc Otilde Ouml times Oslash Ugrave Uacute Ucirc Uuml Yacute THORN szlig agrave aacute \" +\n \"acirc atilde auml aring aelig ccedil egrave eacute ecirc euml igrave iacute icirc iuml eth ntilde \" +\n \"ograve oacute ocirc otilde ouml divide oslash ugrave uacute ucirc uuml yacute thorn yuml\"\n ).split(\" \");\n latin1.forEach((name, i) => {\n table.set(name, String.fromCharCode(0xa0 + i));\n });\n return table;\n})();\n\n/**\n * Decode the character entities of a GML string body (the inverse of quoteGmlString on the text\n * between the quotes): numeric references, the XML entities and the ISO-8859-1 HTML entities. An\n * unknown named entity, or a numeric reference beyond U+10FFFF, is left as written and handed to\n * `onUnknown`.\n * @param body - the text between the quotes\n * @param onUnknown - called with each entity left as written (`&name;`, `�`), when given\n * @returns the decoded text\n * @category Plugin helpers\n */\nexport function decodeGmlString(body: string, onUnknown?: (entity: string) => void): string {\n return body.replaceAll(GML_ENTITY, (whole, entity: string) => {\n if (entity.startsWith(\"#\")) {\n const code = entity.startsWith(\"#x\") ? Number.parseInt(entity.slice(2), 16) : Number(entity.slice(1));\n if (code <= 0x10ffff) {\n return String.fromCodePoint(code);\n }\n // beyond Unicode: no character to decode to, kept as written like an unknown name\n onUnknown?.(whole);\n return whole;\n }\n const known = GML_NAMED.get(entity);\n if (known === undefined) {\n onUnknown?.(whole);\n return whole;\n }\n return known;\n });\n}\n\nconst DOT_NUMERAL = /^-?(\\.\\d+|\\d+(\\.\\d*)?)$/;\nconst DOT_KEYWORDS: ReadonlySet<string> = new Set([\"node\", \"edge\", \"graph\", \"digraph\", \"subgraph\", \"strict\"]);\n\n/**\n * Whether a text is a DOT ID that needs no quotes: an alphanumeric identifier not starting with\n * a digit, or a numeral, and not a keyword (case-insensitive).\n * @param text - the text\n * @returns true when the text can be written bare\n * @category Plugin helpers\n */\nexport function isBareDotId(text: string): boolean {\n if (DOT_KEYWORDS.has(text.toLowerCase())) {\n return false;\n }\n return isDotIdentifier(text) || DOT_NUMERAL.test(text);\n}\n\n/**\n * Whether a text is a DOT identifier: a letter, underscore or any character of code 128 and\n * above, followed by letters, digits, underscores or such characters.\n * @param text - the text\n * @returns true for a bare identifier\n */\nfunction isDotIdentifier(text: string): boolean {\n if (text.length === 0) {\n return false;\n }\n for (let i = 0; i < text.length; i++) {\n const c = text.charCodeAt(i);\n const letter = (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c === 95 || c >= 128;\n const digit = c >= 48 && c <= 57;\n if (!letter && (i === 0 || !digit)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Whether a text can be written as a DOT ID at all. Graphviz's scanner consumes a backslash pair\n * `\\\\` as one unit, `\\\"` as an escaped quote and a backslash before a line break as a line\n * continuation (both removed), left to right, so a backslash that precedes a double quote or a\n * line break, or ends the text, cannot be written: the written `\\\\\"` reads as a pair and a closing\n * quote, a backslash before a line break vanishes with the break, and a trailing backslash escapes\n * the closing quote. Every other text is writable; quoteDotId() writes it.\n * @param text - the id, name or value text\n * @returns true when quoteDotId(text) reads back as `text`\n * @category Plugin helpers\n */\nexport function isWritableDotText(text: string): boolean {\n return !text.endsWith(\"\\\\\") && !text.includes(String.raw`\\\"`) && !/\\\\[\\r\\n]/.test(text);\n}\n\n/**\n * Write a DOT ID: bare when the grammar allows, otherwise double-quoted with `\"` escaped as `\\\"`.\n * In DOT quoted strings the dyad `\\\"` is the only escape; every other character, a backslash and\n * a raw line break included, is kept as written, so nothing else is rewritten. A text ending in a\n * backslash has no DOT spelling (isWritableDotText); the caller refuses it before writing.\n * @param text - the id or label text\n * @returns the DOT ID\n * @category Plugin helpers\n */\nexport function quoteDotId(text: string): string {\n if (isBareDotId(text)) {\n return text;\n }\n const escaped = text.replaceAll('\"', String.raw`\\\"`);\n return `\"${escaped}\"`;\n}\n\n/**\n * Write a set CSV cell per RFC 4180: quoted, with the quote character doubled, when the text\n * contains the delimiter, the quote character, a CR or LF, or leading / trailing whitespace; bare\n * otherwise. The empty string is written as an empty quoted cell (`\"\"`), so the importers can tell a\n * set empty string (and an empty-string node id) from an unset cell, which every exporter writes as\n * nothing between the delimiters.\n * @param text - the cell text of a set cell\n * @param delimiter - the field delimiter (default \",\")\n * @param quote - the quote character (default `\"`)\n * @returns the cell as written\n * @category Plugin helpers\n */\nexport function quoteCsvCell(text: string, delimiter = \",\", quote = '\"'): string {\n if (text.length === 0) {\n return quote + quote;\n }\n if (\n !text.includes(delimiter) &&\n !text.includes(quote) &&\n !text.includes(\"\\n\") &&\n !text.includes(\"\\r\") &&\n text === text.trim()\n ) {\n return text;\n }\n return `${quote}${text.split(quote).join(quote + quote)}${quote}`;\n}\n\n/**\n * Whether a text can be a Pajek label: Pajek has no escape mechanism inside its double-quoted\n * labels, so a text containing a double quote, a CR or an LF cannot be written.\n * @param text - the label text\n * @returns true when quotePajekLabel() can write it\n * @category Plugin helpers\n */\nexport function isPajekLabel(text: string): boolean {\n return !text.includes('\"') && !text.includes(\"\\n\") && !text.includes(\"\\r\");\n}\n\n/**\n * Write a Pajek label: bare when it is a single run of non-space, non-quote characters that does\n * not start with `[` (a bare `[` opens a time set, which the reader groups up to its `]`),\n * otherwise double-quoted. E_UNSUPPORTED (reason \"pajek label\") for a text isPajekLabel() rejects;\n * the exporter's check() counts those.\n * @param text - the label text\n * @returns the label as written\n * @category Plugin helpers\n */\nexport function quotePajekLabel(text: string): string {\n if (!isPajekLabel(text)) {\n throw new GraphFormatError(\"E_UNSUPPORTED\", \"a Pajek label cannot contain a double quote or a line break\", {\n reason: \"pajek label\",\n value: text,\n });\n }\n // a bare `%` token starts a comment for the importer, so such a text is quoted too\n if (text.length > 0 && !/[\\s\"]/.test(text) && !text.startsWith(\"[\") && !text.startsWith(\"%\")) {\n return text;\n }\n return `\"${text}\"`;\n}\n"],"names":["end"],"mappings":";;AA4EO,MAAM,uBAAuB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAStC,YAAY,SAAiB,MAAc;AACvC,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EAChB;AACJ;AAOO,MAAM,2BAA2B,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnD,YAAY,MAAc;AACtB,UAAM,uCAAuC,IAAI;AACjD,SAAK,OAAO;AAAA,EAChB;AACJ;AA0BA,MAAM,2BAA2B;AAGjC,MAAM,iBAAiB;AAGvB,MAAM,0BAA0B;AAEhC,MAAM,iBAAmD;AAAA,EACrD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AACV;AAEA,MAAM,KAAK;AACX,MAAM,KAAK;AACX,MAAM,QAAQ;AACd,MAAM,SA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