@graphty/graph-io 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +250 -28
- package/dist/chunks/children-CL3Cy0ez.js +238 -0
- package/dist/chunks/children-CL3Cy0ez.js.map +1 -0
- package/dist/chunks/escape-DyI8JofU.js +938 -0
- package/dist/chunks/escape-DyI8JofU.js.map +1 -0
- package/dist/chunks/importer-CQnJuWJw.js +2987 -0
- package/dist/chunks/importer-CQnJuWJw.js.map +1 -0
- package/dist/chunks/importer-CpCpfbxr.js +2015 -0
- package/dist/chunks/importer-CpCpfbxr.js.map +1 -0
- package/dist/chunks/importer-DbnGYr3_.js +2342 -0
- package/dist/chunks/importer-DbnGYr3_.js.map +1 -0
- package/dist/chunks/importer-GozH8DkN.js +3050 -0
- package/dist/chunks/importer-GozH8DkN.js.map +1 -0
- package/dist/chunks/records-CGpxszm1.js +605 -0
- package/dist/chunks/records-CGpxszm1.js.map +1 -0
- package/dist/chunks/text-CajMdVFy.js +189 -0
- package/dist/chunks/text-CajMdVFy.js.map +1 -0
- package/dist/chunks/writer-DxSKC7TL.js +2842 -0
- package/dist/chunks/writer-DxSKC7TL.js.map +1 -0
- package/dist/csv.d.ts +1 -0
- package/dist/csv.js +1702 -0
- package/dist/csv.js.map +1 -0
- package/dist/dot.d.ts +1 -0
- package/dist/dot.js +8 -0
- package/dist/dot.js.map +1 -0
- package/dist/gexf.d.ts +1 -0
- package/dist/gexf.js +3466 -0
- package/dist/gexf.js.map +1 -0
- package/dist/gml.d.ts +1 -0
- package/dist/gml.js +2647 -0
- package/dist/gml.js.map +1 -0
- package/dist/graph-io.d.ts +1 -0
- package/dist/graph-io.js +790 -0
- package/dist/graph-io.js.map +1 -0
- package/dist/graphml.d.ts +1 -0
- package/dist/graphml.js +8 -0
- package/dist/graphml.js.map +1 -0
- package/dist/json.d.ts +1 -0
- package/dist/json.js +11 -0
- package/dist/json.js.map +1 -0
- package/dist/neo4j.d.ts +1 -0
- package/dist/neo4j.js +2046 -0
- package/dist/neo4j.js.map +1 -0
- package/dist/pajek.d.ts +1 -0
- package/dist/pajek.js +8 -0
- package/dist/pajek.js.map +1 -0
- package/dist/src/children.d.ts +134 -0
- package/dist/src/children.d.ts.map +1 -0
- package/dist/src/children.js +274 -0
- package/dist/src/children.js.map +1 -0
- package/dist/src/common/attributes.d.ts +229 -0
- package/dist/src/common/attributes.d.ts.map +1 -0
- package/dist/src/common/attributes.js +368 -0
- package/dist/src/common/attributes.js.map +1 -0
- package/dist/src/common/codes.d.ts +105 -0
- package/dist/src/common/codes.d.ts.map +1 -0
- package/dist/src/common/codes.js +107 -0
- package/dist/src/common/codes.js.map +1 -0
- package/dist/src/common/declared-types.d.ts +84 -0
- package/dist/src/common/declared-types.d.ts.map +1 -0
- package/dist/src/common/declared-types.js +326 -0
- package/dist/src/common/declared-types.js.map +1 -0
- package/dist/src/common/direction.d.ts +206 -0
- package/dist/src/common/direction.d.ts.map +1 -0
- package/dist/src/common/direction.js +370 -0
- package/dist/src/common/direction.js.map +1 -0
- package/dist/src/common/escape.d.ts +92 -0
- package/dist/src/common/escape.d.ts.map +1 -0
- package/dist/src/common/escape.js +212 -0
- package/dist/src/common/escape.js.map +1 -0
- package/dist/src/common/export.d.ts +249 -0
- package/dist/src/common/export.d.ts.map +1 -0
- package/dist/src/common/export.js +594 -0
- package/dist/src/common/export.js.map +1 -0
- package/dist/src/common/format.d.ts +59 -0
- package/dist/src/common/format.d.ts.map +1 -0
- package/dist/src/common/format.js +106 -0
- package/dist/src/common/format.js.map +1 -0
- package/dist/src/common/ids.d.ts +83 -0
- package/dist/src/common/ids.d.ts.map +1 -0
- package/dist/src/common/ids.js +158 -0
- package/dist/src/common/ids.js.map +1 -0
- package/dist/src/common/input.d.ts +100 -0
- package/dist/src/common/input.d.ts.map +1 -0
- package/dist/src/common/input.js +335 -0
- package/dist/src/common/input.js.map +1 -0
- package/dist/src/common/lists.d.ts +34 -0
- package/dist/src/common/lists.d.ts.map +1 -0
- package/dist/src/common/lists.js +185 -0
- package/dist/src/common/lists.js.map +1 -0
- package/dist/src/common/options.d.ts +108 -0
- package/dist/src/common/options.d.ts.map +1 -0
- package/dist/src/common/options.js +265 -0
- package/dist/src/common/options.js.map +1 -0
- package/dist/src/common/report.d.ts +187 -0
- package/dist/src/common/report.d.ts.map +1 -0
- package/dist/src/common/report.js +274 -0
- package/dist/src/common/report.js.map +1 -0
- package/dist/src/common/temporal.d.ts +71 -0
- package/dist/src/common/temporal.d.ts.map +1 -0
- package/dist/src/common/temporal.js +266 -0
- package/dist/src/common/temporal.js.map +1 -0
- package/dist/src/common/text.d.ts +104 -0
- package/dist/src/common/text.d.ts.map +1 -0
- package/dist/src/common/text.js +255 -0
- package/dist/src/common/text.js.map +1 -0
- package/dist/src/common/weights.d.ts +77 -0
- package/dist/src/common/weights.d.ts.map +1 -0
- package/dist/src/common/weights.js +156 -0
- package/dist/src/common/weights.js.map +1 -0
- package/dist/src/common/writer.d.ts +51 -0
- package/dist/src/common/writer.d.ts.map +1 -0
- package/dist/src/common/writer.js +108 -0
- package/dist/src/common/writer.js.map +1 -0
- package/dist/src/common/xml.d.ts +245 -0
- package/dist/src/common/xml.d.ts.map +1 -0
- package/dist/src/common/xml.js +942 -0
- package/dist/src/common/xml.js.map +1 -0
- package/dist/src/formats/csv/exporter.d.ts +70 -0
- package/dist/src/formats/csv/exporter.d.ts.map +1 -0
- package/dist/src/formats/csv/exporter.js +682 -0
- package/dist/src/formats/csv/exporter.js.map +1 -0
- package/dist/src/formats/csv/header.d.ts +66 -0
- package/dist/src/formats/csv/header.d.ts.map +1 -0
- package/dist/src/formats/csv/header.js +152 -0
- package/dist/src/formats/csv/header.js.map +1 -0
- package/dist/src/formats/csv/importer.d.ts +82 -0
- package/dist/src/formats/csv/importer.d.ts.map +1 -0
- package/dist/src/formats/csv/importer.js +849 -0
- package/dist/src/formats/csv/importer.js.map +1 -0
- package/dist/src/formats/csv/index.d.ts +60 -0
- package/dist/src/formats/csv/index.d.ts.map +1 -0
- package/dist/src/formats/csv/index.js +63 -0
- package/dist/src/formats/csv/index.js.map +1 -0
- package/dist/src/formats/csv/records.d.ts +188 -0
- package/dist/src/formats/csv/records.d.ts.map +1 -0
- package/dist/src/formats/csv/records.js +702 -0
- package/dist/src/formats/csv/records.js.map +1 -0
- package/dist/src/formats/csv/values.d.ts +105 -0
- package/dist/src/formats/csv/values.d.ts.map +1 -0
- package/dist/src/formats/csv/values.js +192 -0
- package/dist/src/formats/csv/values.js.map +1 -0
- package/dist/src/formats/dot/exporter.d.ts +52 -0
- package/dist/src/formats/dot/exporter.d.ts.map +1 -0
- package/dist/src/formats/dot/exporter.js +836 -0
- package/dist/src/formats/dot/exporter.js.map +1 -0
- package/dist/src/formats/dot/importer.d.ts +102 -0
- package/dist/src/formats/dot/importer.d.ts.map +1 -0
- package/dist/src/formats/dot/importer.js +1291 -0
- package/dist/src/formats/dot/importer.js.map +1 -0
- package/dist/src/formats/dot/index.d.ts +7 -0
- package/dist/src/formats/dot/index.d.ts.map +1 -0
- package/dist/src/formats/dot/index.js +7 -0
- package/dist/src/formats/dot/index.js.map +1 -0
- package/dist/src/formats/dot/names.d.ts +29 -0
- package/dist/src/formats/dot/names.d.ts.map +1 -0
- package/dist/src/formats/dot/names.js +28 -0
- package/dist/src/formats/dot/names.js.map +1 -0
- package/dist/src/formats/dot/tokenizer.d.ts +114 -0
- package/dist/src/formats/dot/tokenizer.d.ts.map +1 -0
- package/dist/src/formats/dot/tokenizer.js +341 -0
- package/dist/src/formats/dot/tokenizer.js.map +1 -0
- package/dist/src/formats/gexf/exporter.d.ts +56 -0
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -0
- package/dist/src/formats/gexf/exporter.js +1395 -0
- package/dist/src/formats/gexf/exporter.js.map +1 -0
- package/dist/src/formats/gexf/importer.d.ts +73 -0
- package/dist/src/formats/gexf/importer.d.ts.map +1 -0
- package/dist/src/formats/gexf/importer.js +1880 -0
- package/dist/src/formats/gexf/importer.js.map +1 -0
- package/dist/src/formats/gexf/index.d.ts +96 -0
- package/dist/src/formats/gexf/index.d.ts.map +1 -0
- package/dist/src/formats/gexf/index.js +97 -0
- package/dist/src/formats/gexf/index.js.map +1 -0
- package/dist/src/formats/gexf/schema.d.ts +135 -0
- package/dist/src/formats/gexf/schema.d.ts.map +1 -0
- package/dist/src/formats/gexf/schema.js +323 -0
- package/dist/src/formats/gexf/schema.js.map +1 -0
- package/dist/src/formats/gml/exporter.d.ts +69 -0
- package/dist/src/formats/gml/exporter.d.ts.map +1 -0
- package/dist/src/formats/gml/exporter.js +1093 -0
- package/dist/src/formats/gml/exporter.js.map +1 -0
- package/dist/src/formats/gml/importer.d.ts +66 -0
- package/dist/src/formats/gml/importer.d.ts.map +1 -0
- package/dist/src/formats/gml/importer.js +1331 -0
- package/dist/src/formats/gml/importer.js.map +1 -0
- package/dist/src/formats/gml/index.d.ts +85 -0
- package/dist/src/formats/gml/index.d.ts.map +1 -0
- package/dist/src/formats/gml/index.js +88 -0
- package/dist/src/formats/gml/index.js.map +1 -0
- package/dist/src/formats/gml/syntax.d.ts +186 -0
- package/dist/src/formats/gml/syntax.d.ts.map +1 -0
- package/dist/src/formats/gml/syntax.js +467 -0
- package/dist/src/formats/gml/syntax.js.map +1 -0
- package/dist/src/formats/graphml/constants.d.ts +169 -0
- package/dist/src/formats/graphml/constants.d.ts.map +1 -0
- package/dist/src/formats/graphml/constants.js +165 -0
- package/dist/src/formats/graphml/constants.js.map +1 -0
- package/dist/src/formats/graphml/exporter.d.ts +34 -0
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -0
- package/dist/src/formats/graphml/exporter.js +1176 -0
- package/dist/src/formats/graphml/exporter.js.map +1 -0
- package/dist/src/formats/graphml/importer.d.ts +31 -0
- package/dist/src/formats/graphml/importer.d.ts.map +1 -0
- package/dist/src/formats/graphml/importer.js +1607 -0
- package/dist/src/formats/graphml/importer.js.map +1 -0
- package/dist/src/formats/graphml/index.d.ts +8 -0
- package/dist/src/formats/graphml/index.d.ts.map +1 -0
- package/dist/src/formats/graphml/index.js +8 -0
- package/dist/src/formats/graphml/index.js.map +1 -0
- package/dist/src/formats/graphml/tree.d.ts +72 -0
- package/dist/src/formats/graphml/tree.d.ts.map +1 -0
- package/dist/src/formats/graphml/tree.js +290 -0
- package/dist/src/formats/graphml/tree.js.map +1 -0
- package/dist/src/formats/json/dialect.d.ts +125 -0
- package/dist/src/formats/json/dialect.d.ts.map +1 -0
- package/dist/src/formats/json/dialect.js +262 -0
- package/dist/src/formats/json/dialect.js.map +1 -0
- package/dist/src/formats/json/exporter.d.ts +89 -0
- package/dist/src/formats/json/exporter.d.ts.map +1 -0
- package/dist/src/formats/json/exporter.js +1358 -0
- package/dist/src/formats/json/exporter.js.map +1 -0
- package/dist/src/formats/json/importer.d.ts +108 -0
- package/dist/src/formats/json/importer.d.ts.map +1 -0
- package/dist/src/formats/json/importer.js +1838 -0
- package/dist/src/formats/json/importer.js.map +1 -0
- package/dist/src/formats/json/index.d.ts +8 -0
- package/dist/src/formats/json/index.d.ts.map +1 -0
- package/dist/src/formats/json/index.js +8 -0
- package/dist/src/formats/json/index.js.map +1 -0
- package/dist/src/formats/neo4j/exporter.d.ts +68 -0
- package/dist/src/formats/neo4j/exporter.d.ts.map +1 -0
- package/dist/src/formats/neo4j/exporter.js +1055 -0
- package/dist/src/formats/neo4j/exporter.js.map +1 -0
- package/dist/src/formats/neo4j/header.d.ts +52 -0
- package/dist/src/formats/neo4j/header.d.ts.map +1 -0
- package/dist/src/formats/neo4j/header.js +131 -0
- package/dist/src/formats/neo4j/header.js.map +1 -0
- package/dist/src/formats/neo4j/importer.d.ts +73 -0
- package/dist/src/formats/neo4j/importer.d.ts.map +1 -0
- package/dist/src/formats/neo4j/importer.js +932 -0
- package/dist/src/formats/neo4j/importer.js.map +1 -0
- package/dist/src/formats/neo4j/index.d.ts +79 -0
- package/dist/src/formats/neo4j/index.d.ts.map +1 -0
- package/dist/src/formats/neo4j/index.js +83 -0
- package/dist/src/formats/neo4j/index.js.map +1 -0
- package/dist/src/formats/pajek/exporter.d.ts +58 -0
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -0
- package/dist/src/formats/pajek/exporter.js +825 -0
- package/dist/src/formats/pajek/exporter.js.map +1 -0
- package/dist/src/formats/pajek/importer.d.ts +88 -0
- package/dist/src/formats/pajek/importer.d.ts.map +1 -0
- package/dist/src/formats/pajek/importer.js +1047 -0
- package/dist/src/formats/pajek/importer.js.map +1 -0
- package/dist/src/formats/pajek/index.d.ts +7 -0
- package/dist/src/formats/pajek/index.d.ts.map +1 -0
- package/dist/src/formats/pajek/index.js +7 -0
- package/dist/src/formats/pajek/index.js.map +1 -0
- package/dist/src/formats/pajek/syntax.d.ts +112 -0
- package/dist/src/formats/pajek/syntax.d.ts.map +1 -0
- package/dist/src/formats/pajek/syntax.js +269 -0
- package/dist/src/formats/pajek/syntax.js.map +1 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +39 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/registry.d.ts +207 -0
- package/dist/src/registry.d.ts.map +1 -0
- package/dist/src/registry.js +481 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/sniff.d.ts +104 -0
- package/dist/src/sniff.d.ts.map +1 -0
- package/dist/src/sniff.js +357 -0
- package/dist/src/sniff.js.map +1 -0
- package/dist/src/types.d.ts +238 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +29 -0
- package/dist/src/types.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +122 -7
- package/src/children.ts +335 -0
- package/src/common/attributes.ts +520 -0
- package/src/common/codes.ts +153 -0
- package/src/common/declared-types.ts +374 -0
- package/src/common/direction.ts +518 -0
- package/src/common/escape.ts +231 -0
- package/src/common/export.ts +817 -0
- package/src/common/format.ts +111 -0
- package/src/common/ids.ts +176 -0
- package/src/common/input.ts +378 -0
- package/src/common/lists.ts +196 -0
- package/src/common/options.ts +377 -0
- package/src/common/report.ts +352 -0
- package/src/common/temporal.ts +302 -0
- package/src/common/text.ts +294 -0
- package/src/common/weights.ts +202 -0
- package/src/common/writer.ts +123 -0
- package/src/common/xml.ts +1053 -0
- package/src/formats/csv/exporter.ts +894 -0
- package/src/formats/csv/header.ts +172 -0
- package/src/formats/csv/importer.ts +1104 -0
- package/src/formats/csv/index.ts +88 -0
- package/src/formats/csv/records.ts +813 -0
- package/src/formats/csv/values.ts +224 -0
- package/src/formats/dot/exporter.ts +1014 -0
- package/src/formats/dot/importer.ts +1549 -0
- package/src/formats/dot/index.ts +7 -0
- package/src/formats/dot/names.ts +40 -0
- package/src/formats/dot/tokenizer.ts +384 -0
- package/src/formats/gexf/exporter.ts +1696 -0
- package/src/formats/gexf/importer.ts +2333 -0
- package/src/formats/gexf/index.ts +142 -0
- package/src/formats/gexf/schema.ts +361 -0
- package/src/formats/gml/exporter.ts +1404 -0
- package/src/formats/gml/importer.ts +1591 -0
- package/src/formats/gml/index.ts +128 -0
- package/src/formats/gml/syntax.ts +545 -0
- package/src/formats/graphml/constants.ts +225 -0
- package/src/formats/graphml/exporter.ts +1458 -0
- package/src/formats/graphml/importer.ts +2027 -0
- package/src/formats/graphml/index.ts +8 -0
- package/src/formats/graphml/tree.ts +318 -0
- package/src/formats/json/dialect.ts +317 -0
- package/src/formats/json/exporter.ts +1616 -0
- package/src/formats/json/importer.ts +2271 -0
- package/src/formats/json/index.ts +8 -0
- package/src/formats/neo4j/exporter.ts +1287 -0
- package/src/formats/neo4j/header.ts +156 -0
- package/src/formats/neo4j/importer.ts +1220 -0
- package/src/formats/neo4j/index.ts +116 -0
- package/src/formats/pajek/exporter.ts +1000 -0
- package/src/formats/pajek/importer.ts +1311 -0
- package/src/formats/pajek/index.ts +7 -0
- package/src/formats/pajek/syntax.ts +307 -0
- package/src/index.ts +244 -0
- package/src/registry.ts +617 -0
- package/src/sniff.ts +397 -0
- package/src/types.ts +262 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The output side of the exporter contract (design sections 8.5 and 12.4): an exporter produces
|
|
3
|
+
* its document as a sequence of text parts (a sync or async generator of strings, one per line or
|
|
4
|
+
* element); these helpers turn that sequence into `export()`'s `AsyncIterable<Uint8Array>` of
|
|
5
|
+
* UTF-8 chunks of a bounded size, into `exportToString()`'s one string, or into a
|
|
6
|
+
* `ReadableStream<Uint8Array>` for a caller that wants a stream.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Text parts an exporter produces.
|
|
10
|
+
* Consumed by the per-format importers and exporters under src/formats.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export type TextParts = Iterable<string> | AsyncIterable<string>;
|
|
14
|
+
/** The target size of one encoded chunk; parts are coalesced up to it and never split. */
|
|
15
|
+
export declare const DEFAULT_CHUNK_BYTES: number;
|
|
16
|
+
/**
|
|
17
|
+
* Encode text parts as UTF-8 chunks of about `chunkBytes` each. Small parts are coalesced; a part
|
|
18
|
+
* larger than the chunk size is emitted whole. The last chunk may be short; nothing is emitted for
|
|
19
|
+
* an empty document.
|
|
20
|
+
* @param parts - the text parts
|
|
21
|
+
* @param chunkBytes - the target chunk size in bytes
|
|
22
|
+
* @yields UTF-8 chunks
|
|
23
|
+
* @returns nothing
|
|
24
|
+
*/
|
|
25
|
+
export declare function encodeChunks(parts: TextParts, chunkBytes?: number): AsyncGenerator<Uint8Array, void, undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* Join text parts into one string.
|
|
28
|
+
* @param parts - the text parts
|
|
29
|
+
* @returns the whole document
|
|
30
|
+
*/
|
|
31
|
+
export declare function joinText(parts: TextParts): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Decode UTF-8 chunks back into one string (for tests and for callers holding an export() result).
|
|
34
|
+
* @param chunks - the chunks
|
|
35
|
+
* @returns the decoded text
|
|
36
|
+
*/
|
|
37
|
+
export declare function decodeChunks(chunks: AsyncIterable<Uint8Array>): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Collect UTF-8 chunks into one Uint8Array.
|
|
40
|
+
* @param chunks - the chunks
|
|
41
|
+
* @returns the concatenated bytes
|
|
42
|
+
*/
|
|
43
|
+
export declare function collectBytes(chunks: AsyncIterable<Uint8Array>): Promise<Uint8Array>;
|
|
44
|
+
/**
|
|
45
|
+
* Wrap an async iterable of chunks as a ReadableStream, pulling one chunk per read and cancelling
|
|
46
|
+
* the iterable when the stream is cancelled.
|
|
47
|
+
* @param chunks - the chunks
|
|
48
|
+
* @returns a byte stream
|
|
49
|
+
*/
|
|
50
|
+
export declare function toReadableStream(chunks: AsyncIterable<Uint8Array>): ReadableStream<Uint8Array>;
|
|
51
|
+
//# sourceMappingURL=writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../src/common/writer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAEjE,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,QAAY,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAuB,YAAY,CAC/B,KAAK,EAAE,SAAS,EAChB,UAAU,GAAE,MAA4B,GACzC,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAoB7C;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAMhE;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAQrF;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAczF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CAe9F"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The output side of the exporter contract (design sections 8.5 and 12.4): an exporter produces
|
|
3
|
+
* its document as a sequence of text parts (a sync or async generator of strings, one per line or
|
|
4
|
+
* element); these helpers turn that sequence into `export()`'s `AsyncIterable<Uint8Array>` of
|
|
5
|
+
* UTF-8 chunks of a bounded size, into `exportToString()`'s one string, or into a
|
|
6
|
+
* `ReadableStream<Uint8Array>` for a caller that wants a stream.
|
|
7
|
+
*/
|
|
8
|
+
/** The target size of one encoded chunk; parts are coalesced up to it and never split. */
|
|
9
|
+
export const DEFAULT_CHUNK_BYTES = 64 * 1024;
|
|
10
|
+
/**
|
|
11
|
+
* Encode text parts as UTF-8 chunks of about `chunkBytes` each. Small parts are coalesced; a part
|
|
12
|
+
* larger than the chunk size is emitted whole. The last chunk may be short; nothing is emitted for
|
|
13
|
+
* an empty document.
|
|
14
|
+
* @param parts - the text parts
|
|
15
|
+
* @param chunkBytes - the target chunk size in bytes
|
|
16
|
+
* @yields UTF-8 chunks
|
|
17
|
+
* @returns nothing
|
|
18
|
+
*/
|
|
19
|
+
export async function* encodeChunks(parts, chunkBytes = DEFAULT_CHUNK_BYTES) {
|
|
20
|
+
const encoder = new TextEncoder();
|
|
21
|
+
let pending = [];
|
|
22
|
+
let pendingUnits = 0;
|
|
23
|
+
for await (const part of parts) {
|
|
24
|
+
if (part.length === 0) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
pending.push(part);
|
|
28
|
+
pendingUnits += part.length;
|
|
29
|
+
// UTF-16 code units are a lower bound on the UTF-8 byte count; flush when the lower bound reaches the target
|
|
30
|
+
if (pendingUnits >= chunkBytes) {
|
|
31
|
+
yield encoder.encode(pending.length === 1 ? pending[0] : pending.join(""));
|
|
32
|
+
pending = [];
|
|
33
|
+
pendingUnits = 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (pending.length > 0) {
|
|
37
|
+
yield encoder.encode(pending.length === 1 ? pending[0] : pending.join(""));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Join text parts into one string.
|
|
42
|
+
* @param parts - the text parts
|
|
43
|
+
* @returns the whole document
|
|
44
|
+
*/
|
|
45
|
+
export async function joinText(parts) {
|
|
46
|
+
const collected = [];
|
|
47
|
+
for await (const part of parts) {
|
|
48
|
+
collected.push(part);
|
|
49
|
+
}
|
|
50
|
+
return collected.join("");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Decode UTF-8 chunks back into one string (for tests and for callers holding an export() result).
|
|
54
|
+
* @param chunks - the chunks
|
|
55
|
+
* @returns the decoded text
|
|
56
|
+
*/
|
|
57
|
+
export async function decodeChunks(chunks) {
|
|
58
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
59
|
+
const parts = [];
|
|
60
|
+
for await (const chunk of chunks) {
|
|
61
|
+
parts.push(decoder.decode(chunk, { stream: true }));
|
|
62
|
+
}
|
|
63
|
+
parts.push(decoder.decode());
|
|
64
|
+
return parts.join("");
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Collect UTF-8 chunks into one Uint8Array.
|
|
68
|
+
* @param chunks - the chunks
|
|
69
|
+
* @returns the concatenated bytes
|
|
70
|
+
*/
|
|
71
|
+
export async function collectBytes(chunks) {
|
|
72
|
+
const parts = [];
|
|
73
|
+
let total = 0;
|
|
74
|
+
for await (const chunk of chunks) {
|
|
75
|
+
parts.push(chunk);
|
|
76
|
+
total += chunk.byteLength;
|
|
77
|
+
}
|
|
78
|
+
const out = new Uint8Array(total);
|
|
79
|
+
let offset = 0;
|
|
80
|
+
for (const part of parts) {
|
|
81
|
+
out.set(part, offset);
|
|
82
|
+
offset += part.byteLength;
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Wrap an async iterable of chunks as a ReadableStream, pulling one chunk per read and cancelling
|
|
88
|
+
* the iterable when the stream is cancelled.
|
|
89
|
+
* @param chunks - the chunks
|
|
90
|
+
* @returns a byte stream
|
|
91
|
+
*/
|
|
92
|
+
export function toReadableStream(chunks) {
|
|
93
|
+
const iterator = chunks[Symbol.asyncIterator]();
|
|
94
|
+
return new ReadableStream({
|
|
95
|
+
async pull(controller) {
|
|
96
|
+
const { done, value } = await iterator.next();
|
|
97
|
+
if (done) {
|
|
98
|
+
controller.close();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
controller.enqueue(value);
|
|
102
|
+
},
|
|
103
|
+
async cancel() {
|
|
104
|
+
await iterator.return?.(undefined);
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../../../src/common/writer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,YAAY,CAC/B,KAAgB,EAChB,aAAqB,mBAAmB;IAExC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,IAAI,OAAO,GAAa,EAAE,CAAC;IAC3B,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpB,SAAS;QACb,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,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C,MAAM;YACR,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;QACvC,CAAC;KACJ,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The streaming XML tokenizer shared by the GEXF and GraphML importers (design sections 8.2 and
|
|
3
|
+
* 8.4): SAX-style start / end / text events over the text chunks of the common reader, so both
|
|
4
|
+
* importers run in one pass with bounded memory and every issue carries a line number.
|
|
5
|
+
*
|
|
6
|
+
* Cost model: every character of the input is scanned once. A token that spans many chunks (a
|
|
7
|
+
* long attribute value, comment, CDATA section or name) resumes where the previous chunk left off
|
|
8
|
+
* instead of re-reading the token from its `<`, and line numbers are counted from a cached next
|
|
9
|
+
* line-break position, so a document without line breaks costs the same as one with them.
|
|
10
|
+
*
|
|
11
|
+
* What it handles: the XML declaration and processing instructions (skipped), comments (skipped),
|
|
12
|
+
* CDATA sections (text), a DOCTYPE with an internal subset (skipped; entity declarations are not
|
|
13
|
+
* expanded, so an unknown entity reference is a syntax error), the five predefined entities and
|
|
14
|
+
* numeric character references (decimal and hexadecimal) in text and attribute values, attribute
|
|
15
|
+
* value whitespace normalisation, end-of-line normalisation (CR LF and lone CR become LF), and
|
|
16
|
+
* well-formedness: matching end tags, one root element, no text outside it, no duplicate
|
|
17
|
+
* attributes, no unterminated markup at the end of the input. Namespaces are not resolved; element
|
|
18
|
+
* and attribute names are reported as written (with their prefix).
|
|
19
|
+
*
|
|
20
|
+
* Why not fast-xml-parser: its XMLParser accepts mismatched and unclosed tags without error, does
|
|
21
|
+
* not decode numeric character references unless the deprecated `htmlEntities` option is set, and
|
|
22
|
+
* its validator (`XMLValidator`, the `parse(xml, true)` overload) and `XMLBuilder` are deprecated in
|
|
23
|
+
* 5.x, which the root lint's `no-deprecated` rule forbids using; so the malformed corpus could not
|
|
24
|
+
* be rejected and attribute values written by the common `escapeXmlAttribute` (` `) could not
|
|
25
|
+
* be read back.
|
|
26
|
+
*/
|
|
27
|
+
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
28
|
+
import { type LossNote } from "../types.js";
|
|
29
|
+
/** The events of the tokenizer; every callback is synchronous. */
|
|
30
|
+
export interface XmlHandler {
|
|
31
|
+
/**
|
|
32
|
+
* An element starts (a self-closing element produces start then end).
|
|
33
|
+
* @param name - the element name as written, prefix included
|
|
34
|
+
* @param attrs - the attributes, entities decoded, in document order
|
|
35
|
+
* @param line - the 1-based line of the `<`
|
|
36
|
+
*/
|
|
37
|
+
start(name: string, attrs: ReadonlyMap<string, string>, line: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* An element ends.
|
|
40
|
+
* @param name - the element name
|
|
41
|
+
* @param line - the 1-based line of the end tag (or of the self-closing start tag)
|
|
42
|
+
*/
|
|
43
|
+
end(name: string, line: number): void;
|
|
44
|
+
/**
|
|
45
|
+
* Character data between two tags (entities decoded, CDATA included), one call per run;
|
|
46
|
+
* whitespace-only runs are delivered too.
|
|
47
|
+
* @param text - the text
|
|
48
|
+
* @param line - the 1-based line where the run starts
|
|
49
|
+
*/
|
|
50
|
+
text(text: string, line: number): void;
|
|
51
|
+
}
|
|
52
|
+
/** A well-formedness or syntax error, with the line it was found on. */
|
|
53
|
+
export declare class XmlSyntaxError extends Error {
|
|
54
|
+
/** The 1-based line. */
|
|
55
|
+
readonly line: number;
|
|
56
|
+
/**
|
|
57
|
+
* Create the error.
|
|
58
|
+
* @param message - a plain-ASCII message
|
|
59
|
+
* @param line - the 1-based line
|
|
60
|
+
*/
|
|
61
|
+
constructor(message: string, line: number);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Whether a text holds a character XML 1.0 forbids (see ILLEGAL_CHAR); such a character cannot be
|
|
65
|
+
* written even as a character reference, so a conforming parser rejects the whole document.
|
|
66
|
+
* @param text - the text
|
|
67
|
+
* @returns true when the text cannot appear in an XML 1.0 document
|
|
68
|
+
*/
|
|
69
|
+
export declare function hasIllegalXmlChar(text: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The loss notes of the texts a snapshot holds that no XML 1.0 document can carry (see
|
|
72
|
+
* hasIllegalXmlChar): one E_XML_ILLEGAL_CHAR note per column (node, edge and graph string / dict /
|
|
73
|
+
* list-of-text columns) and one for the ids, each counting the affected rows; export() throws on
|
|
74
|
+
* the first such text. Shared by the GEXF and GraphML exporters' check().
|
|
75
|
+
* @param snapshot - the snapshot
|
|
76
|
+
* @returns the notes, empty when every text is writable
|
|
77
|
+
*/
|
|
78
|
+
export declare function xmlIllegalTextNotes(snapshot: GraphSnapshot): LossNote[];
|
|
79
|
+
/**
|
|
80
|
+
* Whether a text is an XML Name.
|
|
81
|
+
* @param text - the text
|
|
82
|
+
* @returns true for a well-formed name
|
|
83
|
+
*/
|
|
84
|
+
export declare function isXmlName(text: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Decode the predefined entities and character references of a text.
|
|
87
|
+
* @param raw - the text as written
|
|
88
|
+
* @param line - the line, for errors
|
|
89
|
+
* @returns the decoded text
|
|
90
|
+
*/
|
|
91
|
+
export declare function decodeEntities(raw: string, line: number): string;
|
|
92
|
+
/**
|
|
93
|
+
* Whether a text is whitespace only.
|
|
94
|
+
* @param text - the text
|
|
95
|
+
* @returns true when every character is XML whitespace (also for an empty text)
|
|
96
|
+
*/
|
|
97
|
+
export declare function isWhitespace(text: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* The local part of a possibly prefixed XML name.
|
|
100
|
+
* @param name - the name as written
|
|
101
|
+
* @returns the text after the last colon, or the name itself
|
|
102
|
+
*/
|
|
103
|
+
export declare function localName(name: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Tokenize XML text arriving in chunks and deliver events to a handler. Throws XmlSyntaxError on
|
|
106
|
+
* malformed input; any error the handler throws propagates unchanged.
|
|
107
|
+
* @param chunks - the text (already UTF-8 decoded, BOM removed)
|
|
108
|
+
* @param handler - the event sink
|
|
109
|
+
*/
|
|
110
|
+
export declare function tokenizeXml(chunks: AsyncIterable<string>, handler: XmlHandler): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* The tokenizer state: the unconsumed tail of the input, the current line, the open element
|
|
113
|
+
* stack and the text run being accumulated. `push()` chunks, then `finish()`.
|
|
114
|
+
*/
|
|
115
|
+
export declare class XmlTokenizer {
|
|
116
|
+
private readonly handler;
|
|
117
|
+
/** Unconsumed input that is not part of a pending token: at most a held-back entity or the last chunk. */
|
|
118
|
+
private buffer;
|
|
119
|
+
/** The markup whose end has not arrived yet, or null. */
|
|
120
|
+
private pending;
|
|
121
|
+
/** The line number at the start of `buffer` (or of the pending markup). */
|
|
122
|
+
private line;
|
|
123
|
+
/**
|
|
124
|
+
* The index of the next line break in `buffer` at or after the last counted position: -2
|
|
125
|
+
* when not yet searched for the current buffer, -1 when the buffer holds no further break.
|
|
126
|
+
*/
|
|
127
|
+
private nextBreak;
|
|
128
|
+
/** A CR held back from the end of the previous chunk (it may be the first half of CR LF). */
|
|
129
|
+
private pendingCr;
|
|
130
|
+
/** Whether the input has ended (an incomplete token is then an error, not a wait). */
|
|
131
|
+
private final;
|
|
132
|
+
/** The text run being accumulated (entities decoded), and the line it started on. */
|
|
133
|
+
private text;
|
|
134
|
+
private textLine;
|
|
135
|
+
private readonly stack;
|
|
136
|
+
private rootSeen;
|
|
137
|
+
private rootClosed;
|
|
138
|
+
/**
|
|
139
|
+
* Create a tokenizer.
|
|
140
|
+
* @param handler - the event sink
|
|
141
|
+
*/
|
|
142
|
+
constructor(handler: XmlHandler);
|
|
143
|
+
/**
|
|
144
|
+
* Feed one chunk and emit every complete token in it.
|
|
145
|
+
* @param chunk - the text
|
|
146
|
+
*/
|
|
147
|
+
push(chunk: string): void;
|
|
148
|
+
/** Signal the end of the input: flush the last text run and check well-formedness. */
|
|
149
|
+
finish(): void;
|
|
150
|
+
/**
|
|
151
|
+
* Append normalised text: continue a pending token's terminator scan over the new text alone,
|
|
152
|
+
* and once the token is complete (or when none is pending) scan the buffer for tokens.
|
|
153
|
+
* @param text - the text, line breaks normalised
|
|
154
|
+
*/
|
|
155
|
+
private feed;
|
|
156
|
+
/**
|
|
157
|
+
* Continue the terminator scan of a pending token over new text.
|
|
158
|
+
* @param pending - the pending token
|
|
159
|
+
* @param text - the new text
|
|
160
|
+
* @returns the index in `text` one past the token's end, or -1 when it does not end there
|
|
161
|
+
*/
|
|
162
|
+
private scanPending;
|
|
163
|
+
/**
|
|
164
|
+
* Scan text for the `>` that ends a start tag, skipping quoted attribute values (the quote
|
|
165
|
+
* state survives between calls).
|
|
166
|
+
* @param pending - the pending token
|
|
167
|
+
* @param text - the text
|
|
168
|
+
* @param from - where to start
|
|
169
|
+
* @returns the index one past the `>`, or -1
|
|
170
|
+
*/
|
|
171
|
+
private scanStartTag;
|
|
172
|
+
/**
|
|
173
|
+
* Scan text for the `>` that ends a DOCTYPE declaration, skipping a bracketed internal subset,
|
|
174
|
+
* quoted literals and comments inside the subset. A character state machine, so the state
|
|
175
|
+
* (`depth`, `quote`, `comment`, and `run`, the progress through a `<!--` or the dashes before
|
|
176
|
+
* a `-->`) survives between calls and nothing is re-read.
|
|
177
|
+
* @param pending - the pending token
|
|
178
|
+
* @param text - the text
|
|
179
|
+
* @param from - where to start
|
|
180
|
+
* @returns the index one past the `>`, or -1
|
|
181
|
+
*/
|
|
182
|
+
private scanDoctype;
|
|
183
|
+
/**
|
|
184
|
+
* Consume every complete token at the front of the buffer; an incomplete token at its end
|
|
185
|
+
* becomes the pending token (its text moved out of the buffer), a possibly split entity
|
|
186
|
+
* reference is held back in the buffer.
|
|
187
|
+
*/
|
|
188
|
+
private scan;
|
|
189
|
+
/**
|
|
190
|
+
* Turn the incomplete markup at `pos` into a pending token, running the terminator scan over
|
|
191
|
+
* the part already in the buffer so later chunks are scanned alone.
|
|
192
|
+
* @param buffer - the buffer
|
|
193
|
+
* @param pos - the index of the `<`
|
|
194
|
+
* @returns the pending token
|
|
195
|
+
*/
|
|
196
|
+
private startPending;
|
|
197
|
+
/**
|
|
198
|
+
* Consume the markup starting at `pos` (a `<`).
|
|
199
|
+
* @param pos - the index of the `<`
|
|
200
|
+
* @returns the index after the markup, or -1 when the buffer ends before the markup does
|
|
201
|
+
*/
|
|
202
|
+
private consumeMarkup;
|
|
203
|
+
/**
|
|
204
|
+
* Parse a start tag at `pos`.
|
|
205
|
+
* @param pos - the index of the `<`
|
|
206
|
+
* @returns the tag, or null when the buffer ends inside it
|
|
207
|
+
*/
|
|
208
|
+
private parseStartTag;
|
|
209
|
+
/**
|
|
210
|
+
* The end of the XML Name starting at `i` (an ASCII table for the common case, the code point
|
|
211
|
+
* classes beyond it).
|
|
212
|
+
* @param i - the start index
|
|
213
|
+
* @returns the index after the name; `i` when no name starts there; -1 when the name may
|
|
214
|
+
* continue past the end of the buffer
|
|
215
|
+
*/
|
|
216
|
+
private readName;
|
|
217
|
+
/**
|
|
218
|
+
* Move text from the buffer into the current run.
|
|
219
|
+
* @param start - the start index
|
|
220
|
+
* @param end - the end index (exclusive)
|
|
221
|
+
*/
|
|
222
|
+
private takeText;
|
|
223
|
+
/**
|
|
224
|
+
* Count the newlines of a consumed range. Ranges are consumed in order, so the next line break
|
|
225
|
+
* is searched for once per buffer and re-searched only after it was passed; a buffer without
|
|
226
|
+
* a further break is searched once and remembered as such.
|
|
227
|
+
* @param start - the start index
|
|
228
|
+
* @param end - the end index (exclusive)
|
|
229
|
+
*/
|
|
230
|
+
private advanceLine;
|
|
231
|
+
/** Deliver the accumulated text run, if any. */
|
|
232
|
+
private flushText;
|
|
233
|
+
/**
|
|
234
|
+
* Open an element.
|
|
235
|
+
* @param name - the element name
|
|
236
|
+
* @param attrs - its attributes
|
|
237
|
+
*/
|
|
238
|
+
private startElement;
|
|
239
|
+
/**
|
|
240
|
+
* Close an element, checking that it matches the innermost open one.
|
|
241
|
+
* @param name - the element name
|
|
242
|
+
*/
|
|
243
|
+
private endElement;
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=xml.d.ts.map
|
|
@@ -0,0 +1 @@
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