@graphty/graph-io 0.3.18 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -2
- package/dist/chunks/{escape-D-gZWO26.js → escape-B-tkk_Cl.js} +74 -16
- package/dist/chunks/escape-B-tkk_Cl.js.map +1 -0
- package/dist/chunks/{writer-GAdltGmC.js → export-Bh60Dv-n.js} +7 -252
- package/dist/chunks/export-Bh60Dv-n.js.map +1 -0
- package/dist/chunks/exporter-BGrsWamJ.js +736 -0
- package/dist/chunks/exporter-BGrsWamJ.js.map +1 -0
- package/dist/chunks/exporter-DIeGJXAZ.js +834 -0
- package/dist/chunks/exporter-DIeGJXAZ.js.map +1 -0
- package/dist/chunks/{importer-Br_QeAeE.js → importer-BWY2FFc5.js} +28 -6
- package/dist/chunks/importer-BWY2FFc5.js.map +1 -0
- package/dist/chunks/importer-BaQpCEcJ.js +2194 -0
- package/dist/chunks/importer-BaQpCEcJ.js.map +1 -0
- package/dist/chunks/importer-DD-xv9_Y.js +1471 -0
- package/dist/chunks/importer-DD-xv9_Y.js.map +1 -0
- package/dist/chunks/{importer-aNJfe0qu.js → importer-DEcKhsmQ.js} +2 -2
- package/dist/chunks/{importer-aNJfe0qu.js.map → importer-DEcKhsmQ.js.map} +1 -1
- package/dist/chunks/{importer-DHagxvDD.js → importer-DIrbbnAf.js} +6 -4
- package/dist/chunks/{importer-DHagxvDD.js.map → importer-DIrbbnAf.js.map} +1 -1
- package/dist/chunks/importer-D_e7e7LX.js +3055 -0
- package/dist/chunks/importer-D_e7e7LX.js.map +1 -0
- package/dist/chunks/{importer-Du5crN9l.js → importer-Wv4C4gaF.js} +278 -82
- package/dist/chunks/importer-Wv4C4gaF.js.map +1 -0
- package/dist/chunks/importer-vi3bSdtw.js +1713 -0
- package/dist/chunks/importer-vi3bSdtw.js.map +1 -0
- package/dist/chunks/{importer-d0uQxFp6.js → importer-zGLo8Dg_.js} +6 -4
- package/dist/chunks/{importer-d0uQxFp6.js.map → importer-zGLo8Dg_.js.map} +1 -1
- package/dist/chunks/json-elements-DDS8N2Dd.js +779 -0
- package/dist/chunks/json-elements-DDS8N2Dd.js.map +1 -0
- package/dist/chunks/{records-Bk9jgodz.js → records-dbRkxwaq.js} +2 -2
- package/dist/chunks/{records-Bk9jgodz.js.map → records-dbRkxwaq.js.map} +1 -1
- package/dist/chunks/{report-BOk0p5y8.js → report-B1z4WT9e.js} +143 -111
- package/dist/chunks/{report-BOk0p5y8.js.map → report-B1z4WT9e.js.map} +1 -1
- package/dist/chunks/weights-Dzba96G3.js +176 -0
- package/dist/chunks/weights-Dzba96G3.js.map +1 -0
- package/dist/chunks/writer-C7flM-Ih.js +77 -0
- package/dist/chunks/writer-C7flM-Ih.js.map +1 -0
- package/dist/csv.js +6 -4
- package/dist/csv.js.map +1 -1
- package/dist/cx.d.ts +1 -0
- package/dist/cx.js +6 -0
- package/dist/cx.js.map +1 -0
- package/dist/cx2.d.ts +1 -0
- package/dist/cx2.js +10 -0
- package/dist/cx2.js.map +1 -0
- package/dist/cys.d.ts +1 -0
- package/dist/cys.js +6 -0
- package/dist/cys.js.map +1 -0
- package/dist/dot.js +1 -1
- package/dist/gexf.js +16 -4
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +13 -14
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +302 -399
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +1 -1
- package/dist/json.js +1 -1
- package/dist/neo4j.js +6 -4
- package/dist/neo4j.js.map +1 -1
- package/dist/obo.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/common/cell-budget.d.ts +84 -0
- package/dist/src/common/cell-budget.d.ts.map +1 -0
- package/dist/src/common/cell-budget.js +138 -0
- package/dist/src/common/cell-budget.js.map +1 -0
- package/dist/src/common/input.d.ts +10 -0
- package/dist/src/common/input.d.ts.map +1 -1
- package/dist/src/common/input.js +39 -0
- package/dist/src/common/input.js.map +1 -1
- package/dist/src/common/json-elements.d.ts +286 -0
- package/dist/src/common/json-elements.d.ts.map +1 -0
- package/dist/src/common/json-elements.js +926 -0
- package/dist/src/common/json-elements.js.map +1 -0
- package/dist/src/common/options.d.ts +6 -0
- package/dist/src/common/options.d.ts.map +1 -1
- package/dist/src/common/options.js +1 -1
- package/dist/src/common/options.js.map +1 -1
- package/dist/src/common/xml.d.ts +37 -3
- package/dist/src/common/xml.d.ts.map +1 -1
- package/dist/src/common/xml.js +86 -6
- package/dist/src/common/xml.js.map +1 -1
- package/dist/src/common/zip.d.ts +92 -0
- package/dist/src/common/zip.d.ts.map +1 -0
- package/dist/src/common/zip.js +399 -0
- package/dist/src/common/zip.js.map +1 -0
- package/dist/src/formats/cx/importer.d.ts +133 -0
- package/dist/src/formats/cx/importer.d.ts.map +1 -0
- package/dist/src/formats/cx/importer.js +2220 -0
- package/dist/src/formats/cx/importer.js.map +1 -0
- package/dist/src/formats/cx/index.d.ts +7 -0
- package/dist/src/formats/cx/index.d.ts.map +1 -0
- package/dist/src/formats/cx/index.js +7 -0
- package/dist/src/formats/cx/index.js.map +1 -0
- package/dist/src/formats/cx2/exporter.d.ts +59 -0
- package/dist/src/formats/cx2/exporter.d.ts.map +1 -0
- package/dist/src/formats/cx2/exporter.js +864 -0
- package/dist/src/formats/cx2/exporter.js.map +1 -0
- package/dist/src/formats/cx2/importer.d.ts +169 -0
- package/dist/src/formats/cx2/importer.d.ts.map +1 -0
- package/dist/src/formats/cx2/importer.js +1652 -0
- package/dist/src/formats/cx2/importer.js.map +1 -0
- package/dist/src/formats/cx2/index.d.ts +7 -0
- package/dist/src/formats/cx2/index.d.ts.map +1 -0
- package/dist/src/formats/cx2/index.js +7 -0
- package/dist/src/formats/cx2/index.js.map +1 -0
- package/dist/src/formats/cys/constants.d.ts +68 -0
- package/dist/src/formats/cys/constants.d.ts.map +1 -0
- package/dist/src/formats/cys/constants.js +76 -0
- package/dist/src/formats/cys/constants.js.map +1 -0
- package/dist/src/formats/cys/importer.d.ts +38 -0
- package/dist/src/formats/cys/importer.d.ts.map +1 -0
- package/dist/src/formats/cys/importer.js +830 -0
- package/dist/src/formats/cys/importer.js.map +1 -0
- package/dist/src/formats/cys/index.d.ts +7 -0
- package/dist/src/formats/cys/index.d.ts.map +1 -0
- package/dist/src/formats/cys/index.js +7 -0
- package/dist/src/formats/cys/index.js.map +1 -0
- package/dist/src/formats/cys/session.d.ts +132 -0
- package/dist/src/formats/cys/session.d.ts.map +1 -0
- package/dist/src/formats/cys/session.js +315 -0
- package/dist/src/formats/cys/session.js.map +1 -0
- package/dist/src/formats/cys/tables.d.ts +90 -0
- package/dist/src/formats/cys/tables.d.ts.map +1 -0
- package/dist/src/formats/cys/tables.js +293 -0
- package/dist/src/formats/cys/tables.js.map +1 -0
- package/dist/src/formats/dot/exporter.d.ts +2 -0
- package/dist/src/formats/dot/exporter.d.ts.map +1 -1
- package/dist/src/formats/dot/exporter.js +12 -0
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/dot/importer.js +6 -2
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/gexf/exporter.d.ts +2 -0
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +6 -0
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gexf/importer.d.ts +0 -2
- package/dist/src/formats/gexf/importer.d.ts.map +1 -1
- package/dist/src/formats/gexf/importer.js +1 -3
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gexf/index.d.ts +1 -1
- package/dist/src/formats/gexf/index.js +2 -2
- package/dist/src/formats/gexf/index.js.map +1 -1
- package/dist/src/formats/gml/exporter.d.ts +0 -8
- package/dist/src/formats/gml/exporter.d.ts.map +1 -1
- package/dist/src/formats/gml/exporter.js +8 -18
- package/dist/src/formats/gml/exporter.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +6 -104
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/xgmml/columns.d.ts +152 -0
- package/dist/src/formats/xgmml/columns.d.ts.map +1 -0
- package/dist/src/formats/xgmml/columns.js +593 -0
- package/dist/src/formats/xgmml/columns.js.map +1 -0
- package/dist/src/formats/xgmml/constants.d.ts +196 -0
- package/dist/src/formats/xgmml/constants.d.ts.map +1 -0
- package/dist/src/formats/xgmml/constants.js +197 -0
- package/dist/src/formats/xgmml/constants.js.map +1 -0
- package/dist/src/formats/xgmml/document.d.ts +361 -0
- package/dist/src/formats/xgmml/document.d.ts.map +1 -0
- package/dist/src/formats/xgmml/document.js +695 -0
- package/dist/src/formats/xgmml/document.js.map +1 -0
- package/dist/src/formats/xgmml/emit.d.ts +341 -0
- package/dist/src/formats/xgmml/emit.d.ts.map +1 -0
- package/dist/src/formats/xgmml/emit.js +1275 -0
- package/dist/src/formats/xgmml/emit.js.map +1 -0
- package/dist/src/formats/xgmml/exporter.d.ts +24 -0
- package/dist/src/formats/xgmml/exporter.d.ts.map +1 -0
- package/dist/src/formats/xgmml/exporter.js +999 -0
- package/dist/src/formats/xgmml/exporter.js.map +1 -0
- package/dist/src/formats/xgmml/importer.d.ts +58 -0
- package/dist/src/formats/xgmml/importer.d.ts.map +1 -0
- package/dist/src/formats/xgmml/importer.js +360 -0
- package/dist/src/formats/xgmml/importer.js.map +1 -0
- package/dist/src/formats/xgmml/index.d.ts +8 -0
- package/dist/src/formats/xgmml/index.d.ts.map +1 -0
- package/dist/src/formats/xgmml/index.js +8 -0
- package/dist/src/formats/xgmml/index.js.map +1 -0
- package/dist/src/formats/xgmml/values.d.ts +60 -0
- package/dist/src/formats/xgmml/values.d.ts.map +1 -0
- package/dist/src/formats/xgmml/values.js +148 -0
- package/dist/src/formats/xgmml/values.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/registry.d.ts +7 -0
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +30 -10
- package/dist/src/registry.js.map +1 -1
- package/dist/src/sniff.d.ts +1 -1
- package/dist/src/sniff.d.ts.map +1 -1
- package/dist/src/sniff.js +4 -0
- package/dist/src/sniff.js.map +1 -1
- package/dist/xgmml.d.ts +1 -0
- package/dist/xgmml.js +9 -0
- package/dist/xgmml.js.map +1 -0
- package/package.json +25 -2
- package/src/common/cell-budget.ts +170 -0
- package/src/common/input.ts +40 -0
- package/src/common/json-elements.ts +1147 -0
- package/src/common/options.ts +1 -1
- package/src/common/xml.ts +127 -6
- package/src/common/zip.ts +472 -0
- package/src/formats/cx/importer.ts +2733 -0
- package/src/formats/cx/index.ts +7 -0
- package/src/formats/cx2/exporter.ts +1036 -0
- package/src/formats/cx2/importer.ts +2187 -0
- package/src/formats/cx2/index.ts +7 -0
- package/src/formats/cys/constants.ts +99 -0
- package/src/formats/cys/importer.ts +1100 -0
- package/src/formats/cys/index.ts +7 -0
- package/src/formats/cys/session.ts +428 -0
- package/src/formats/cys/tables.ts +400 -0
- package/src/formats/dot/exporter.ts +17 -0
- package/src/formats/dot/importer.ts +6 -2
- package/src/formats/gexf/exporter.ts +11 -0
- package/src/formats/gexf/importer.ts +1 -2
- package/src/formats/gexf/index.ts +1 -1
- package/src/formats/gml/exporter.ts +8 -19
- package/src/formats/json/importer.ts +6 -105
- package/src/formats/xgmml/columns.ts +747 -0
- package/src/formats/xgmml/constants.ts +265 -0
- package/src/formats/xgmml/document.ts +975 -0
- package/src/formats/xgmml/emit.ts +1563 -0
- package/src/formats/xgmml/exporter.ts +1215 -0
- package/src/formats/xgmml/importer.ts +491 -0
- package/src/formats/xgmml/index.ts +8 -0
- package/src/formats/xgmml/values.ts +183 -0
- package/src/index.ts +19 -0
- package/src/registry.ts +46 -15
- package/src/sniff.ts +18 -1
- package/dist/chunks/escape-D-gZWO26.js.map +0 -1
- package/dist/chunks/importer-Br_QeAeE.js.map +0 -1
- package/dist/chunks/importer-Du5crN9l.js.map +0 -1
- package/dist/chunks/writer-GAdltGmC.js.map +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A zip reader with no dependency (design `design/graph-io/cytoscape-and-obo/design.md` section
|
|
3
|
+
* 3.3; PKWARE APPNOTE 6.3.10, https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT), for
|
|
4
|
+
* the Cytoscape session importer.
|
|
5
|
+
*
|
|
6
|
+
* The whole archive is in memory: every Cytoscape-written entry has a data descriptor and zero
|
|
7
|
+
* sizes in its local header, so the sizes come from the central directory at the end. The end
|
|
8
|
+
* record is searched in the last 65,557 bytes (a comment can be 65,535 bytes long); the zip64
|
|
9
|
+
* locator and the `0x0001` extra field are followed; bytes prepended to the archive (a
|
|
10
|
+
* self-extracting stub) are tolerated by the shift between the directory's stated and actual
|
|
11
|
+
* offsets. Deflate (method 8) is inflated by wrapping the raw deflate bytes in a gzip member
|
|
12
|
+
* (header, data, the directory's CRC-32 and size) and passing it to `DecompressionStream("gzip")`,
|
|
13
|
+
* which every supported runtime has (Node 18, unlike `"deflate-raw"`) and which checks the CRC and
|
|
14
|
+
* the length itself; stored entries (method 0) are checked against a CRC-32 table here. Every
|
|
15
|
+
* other method, and encryption, is refused by name. Entry names are decoded by `decodeEntryName()`
|
|
16
|
+
* (the one place bytes become text) and are matching keys only, never paths.
|
|
17
|
+
*/
|
|
18
|
+
/** Why a zip could not be read; the importer maps each kind to its own issue code. */
|
|
19
|
+
type ZipErrorKind = "not-zip" | "corrupt" | "unsupported" | "too-large";
|
|
20
|
+
/** A zip that cannot be read, or an entry that cannot be inflated. */
|
|
21
|
+
export declare class ZipError extends Error {
|
|
22
|
+
/** What went wrong. */
|
|
23
|
+
readonly kind: ZipErrorKind;
|
|
24
|
+
/**
|
|
25
|
+
* Create the error.
|
|
26
|
+
* @param kind - what went wrong
|
|
27
|
+
* @param message - a plain-ASCII message
|
|
28
|
+
*/
|
|
29
|
+
constructor(kind: ZipErrorKind, message: string);
|
|
30
|
+
}
|
|
31
|
+
/** One entry of the central directory. */
|
|
32
|
+
export interface ZipEntry {
|
|
33
|
+
/** The name, decoded, as the central directory spells it. */
|
|
34
|
+
readonly name: string;
|
|
35
|
+
/** The compression method (0 stored, 8 deflate, ...). */
|
|
36
|
+
readonly method: number;
|
|
37
|
+
/** The general purpose bit flags. */
|
|
38
|
+
readonly flags: number;
|
|
39
|
+
/** The CRC-32 of the uncompressed data. */
|
|
40
|
+
readonly crc32: number;
|
|
41
|
+
/** The compressed size in bytes. */
|
|
42
|
+
readonly compressedSize: number;
|
|
43
|
+
/** The uncompressed size in bytes. */
|
|
44
|
+
readonly size: number;
|
|
45
|
+
/** The offset of the local header in the archive bytes (the prepended-data shift applied). */
|
|
46
|
+
readonly localOffset: number;
|
|
47
|
+
/** The name ends in `/`: a directory entry, which holds no data. */
|
|
48
|
+
readonly directory: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** How one entry is read. */
|
|
51
|
+
export interface ReadEntryOptions {
|
|
52
|
+
/** The cancellation signal. */
|
|
53
|
+
readonly signal?: AbortSignal | null | undefined;
|
|
54
|
+
/** Called with the bytes inflated so far by this call. */
|
|
55
|
+
readonly onBytes?: ((inflated: number) => void) | undefined;
|
|
56
|
+
/** The most uncompressed bytes this entry may have (the import's remaining budget). */
|
|
57
|
+
readonly maxBytes: number;
|
|
58
|
+
/** The largest uncompressed-to-compressed ratio allowed (above `RATIO_FLOOR` bytes). */
|
|
59
|
+
readonly maxRatio: number;
|
|
60
|
+
}
|
|
61
|
+
/** A per-entry size under which the ratio limit does not apply (tiny entries compress well). */
|
|
62
|
+
export declare const RATIO_FLOOR: number;
|
|
63
|
+
/**
|
|
64
|
+
* Whether bytes start with a local file header signature (`PK\x03\x04`).
|
|
65
|
+
* @param bytes - the bytes
|
|
66
|
+
* @returns true for the start of a zip
|
|
67
|
+
*/
|
|
68
|
+
export declare function startsLikeZip(bytes: Uint8Array): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Read the central directory.
|
|
71
|
+
* @param bytes - the whole archive
|
|
72
|
+
* @returns the entries in directory order; ZipError "not-zip" when there is no end record and the
|
|
73
|
+
* bytes do not start like a zip, "corrupt" for an end record or directory that does not fit,
|
|
74
|
+
* "unsupported" for a split archive
|
|
75
|
+
*/
|
|
76
|
+
export declare function readZipDirectory(bytes: Uint8Array): ZipEntry[];
|
|
77
|
+
/**
|
|
78
|
+
* Read one entry's data: stored entries are sliced and CRC-checked, deflated ones inflated.
|
|
79
|
+
* @param bytes - the whole archive
|
|
80
|
+
* @param entry - the entry
|
|
81
|
+
* @param options - cancellation, progress and the size limits
|
|
82
|
+
* @returns the uncompressed bytes; ZipError for a damaged, encrypted, unsupported or oversized entry
|
|
83
|
+
*/
|
|
84
|
+
export declare function readZipEntry(bytes: Uint8Array, entry: ZipEntry, options: ReadEntryOptions): Promise<Uint8Array>;
|
|
85
|
+
/**
|
|
86
|
+
* The CRC-32 of bytes.
|
|
87
|
+
* @param bytes - the bytes
|
|
88
|
+
* @returns the checksum
|
|
89
|
+
*/
|
|
90
|
+
export declare function crc32(bytes: Uint8Array): number;
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=zip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../../src/common/zip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,sFAAsF;AACtF,KAAK,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;AAExE,sEAAsE;AACtE,qBAAa,QAAS,SAAQ,KAAK;IAC/B,uBAAuB;IACvB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAE5B;;;;OAIG;gBACS,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM;CAKlD;AAED,0CAA0C;AAC1C,MAAM,WAAW,QAAQ;IACrB,6DAA6D;IAC7D,QAAQ,CAAC,I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AAK,EAAE,UAAU,GAAG,MAAM,CAE/C"}
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A zip reader with no dependency (design `design/graph-io/cytoscape-and-obo/design.md` section
|
|
3
|
+
* 3.3; PKWARE APPNOTE 6.3.10, https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT), for
|
|
4
|
+
* the Cytoscape session importer.
|
|
5
|
+
*
|
|
6
|
+
* The whole archive is in memory: every Cytoscape-written entry has a data descriptor and zero
|
|
7
|
+
* sizes in its local header, so the sizes come from the central directory at the end. The end
|
|
8
|
+
* record is searched in the last 65,557 bytes (a comment can be 65,535 bytes long); the zip64
|
|
9
|
+
* locator and the `0x0001` extra field are followed; bytes prepended to the archive (a
|
|
10
|
+
* self-extracting stub) are tolerated by the shift between the directory's stated and actual
|
|
11
|
+
* offsets. Deflate (method 8) is inflated by wrapping the raw deflate bytes in a gzip member
|
|
12
|
+
* (header, data, the directory's CRC-32 and size) and passing it to `DecompressionStream("gzip")`,
|
|
13
|
+
* which every supported runtime has (Node 18, unlike `"deflate-raw"`) and which checks the CRC and
|
|
14
|
+
* the length itself; stored entries (method 0) are checked against a CRC-32 table here. Every
|
|
15
|
+
* other method, and encryption, is refused by name. Entry names are decoded by `decodeEntryName()`
|
|
16
|
+
* (the one place bytes become text) and are matching keys only, never paths.
|
|
17
|
+
*/
|
|
18
|
+
import { decodeEntryName, throwIfAborted } from "./input.js";
|
|
19
|
+
/** A zip that cannot be read, or an entry that cannot be inflated. */
|
|
20
|
+
export class ZipError extends Error {
|
|
21
|
+
/**
|
|
22
|
+
* Create the error.
|
|
23
|
+
* @param kind - what went wrong
|
|
24
|
+
* @param message - a plain-ASCII message
|
|
25
|
+
*/
|
|
26
|
+
constructor(kind, message) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = "ZipError";
|
|
29
|
+
this.kind = kind;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** A per-entry size under which the ratio limit does not apply (tiny entries compress well). */
|
|
33
|
+
export const RATIO_FLOOR = 1024 * 1024;
|
|
34
|
+
const EOCD_SIGNATURE = 0x06054b50;
|
|
35
|
+
const ZIP64_LOCATOR_SIGNATURE = 0x07064b50;
|
|
36
|
+
const ZIP64_EOCD_SIGNATURE = 0x06064b50;
|
|
37
|
+
const CENTRAL_SIGNATURE = 0x02014b50;
|
|
38
|
+
const LOCAL_SIGNATURE = 0x04034b50;
|
|
39
|
+
const EOCD_SIZE = 22;
|
|
40
|
+
const MAX_COMMENT = 65535;
|
|
41
|
+
const CENTRAL_SIZE = 46;
|
|
42
|
+
const LOCAL_SIZE = 30;
|
|
43
|
+
const ZIP64_EOCD_SIZE = 56;
|
|
44
|
+
const ZIP64_LOCATOR_SIZE = 20;
|
|
45
|
+
const U16_MAX = 0xffff;
|
|
46
|
+
const U32_MAX = 0xffffffff;
|
|
47
|
+
/** Bytes between two cancellation checks while a stored entry's CRC is computed. */
|
|
48
|
+
const CRC_SLICE = 1024 * 1024;
|
|
49
|
+
/** The compression methods other tools write, by number, for the refusal message. */
|
|
50
|
+
const METHOD_NAMES = {
|
|
51
|
+
1: "shrink",
|
|
52
|
+
6: "implode",
|
|
53
|
+
9: "deflate64",
|
|
54
|
+
12: "bzip2",
|
|
55
|
+
14: "LZMA",
|
|
56
|
+
93: "zstd",
|
|
57
|
+
95: "xz",
|
|
58
|
+
96: "JPEG",
|
|
59
|
+
97: "WavPack",
|
|
60
|
+
98: "PPMd",
|
|
61
|
+
99: "AES encryption",
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Whether bytes start with a local file header signature (`PK\x03\x04`).
|
|
65
|
+
* @param bytes - the bytes
|
|
66
|
+
* @returns true for the start of a zip
|
|
67
|
+
*/
|
|
68
|
+
export function startsLikeZip(bytes) {
|
|
69
|
+
return bytes.byteLength >= 4 && bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 3 && bytes[3] === 4;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Read the central directory.
|
|
73
|
+
* @param bytes - the whole archive
|
|
74
|
+
* @returns the entries in directory order; ZipError "not-zip" when there is no end record and the
|
|
75
|
+
* bytes do not start like a zip, "corrupt" for an end record or directory that does not fit,
|
|
76
|
+
* "unsupported" for a split archive
|
|
77
|
+
*/
|
|
78
|
+
export function readZipDirectory(bytes) {
|
|
79
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
80
|
+
const eocd = findEndRecord(bytes, view);
|
|
81
|
+
if (eocd < 0) {
|
|
82
|
+
throw startsLikeZip(bytes)
|
|
83
|
+
? new ZipError("corrupt", "the archive has no end of central directory record (truncated?)")
|
|
84
|
+
: new ZipError("not-zip", "the input is not a zip archive");
|
|
85
|
+
}
|
|
86
|
+
let disk = view.getUint16(eocd + 4, true);
|
|
87
|
+
let directoryDisk = view.getUint16(eocd + 6, true);
|
|
88
|
+
let count = view.getUint16(eocd + 10, true);
|
|
89
|
+
let directorySize = view.getUint32(eocd + 12, true);
|
|
90
|
+
let directoryOffset = view.getUint32(eocd + 16, true);
|
|
91
|
+
let directoryEnd = eocd;
|
|
92
|
+
const locator = eocd - ZIP64_LOCATOR_SIZE;
|
|
93
|
+
if (locator >= 0 && view.getUint32(locator, true) === ZIP64_LOCATOR_SIGNATURE) {
|
|
94
|
+
const record = zip64EndRecord(view, locator);
|
|
95
|
+
disk = view.getUint32(record + 16, true);
|
|
96
|
+
directoryDisk = view.getUint32(record + 20, true);
|
|
97
|
+
count = readU64(view, record + 32);
|
|
98
|
+
directorySize = readU64(view, record + 40);
|
|
99
|
+
directoryOffset = readU64(view, record + 48);
|
|
100
|
+
directoryEnd = record;
|
|
101
|
+
}
|
|
102
|
+
else if (count === U16_MAX || directorySize === U32_MAX || directoryOffset === U32_MAX) {
|
|
103
|
+
throw new ZipError("corrupt", "the end record needs a zip64 record the archive does not have");
|
|
104
|
+
}
|
|
105
|
+
if (disk !== 0 || directoryDisk !== 0) {
|
|
106
|
+
throw new ZipError("unsupported", "a split (multi-disk) archive cannot be read");
|
|
107
|
+
}
|
|
108
|
+
const start = directoryEnd - directorySize;
|
|
109
|
+
if (start < 0 || directoryOffset > bytes.byteLength) {
|
|
110
|
+
throw new ZipError("corrupt", "the central directory lies outside the archive");
|
|
111
|
+
}
|
|
112
|
+
// data prepended to the archive moves every offset by the same amount
|
|
113
|
+
const shift = start - directoryOffset;
|
|
114
|
+
if (shift < 0) {
|
|
115
|
+
throw new ZipError("corrupt", "the central directory offset does not match its position");
|
|
116
|
+
}
|
|
117
|
+
const entries = [];
|
|
118
|
+
let at = start;
|
|
119
|
+
for (let i = 0; i < count; i++) {
|
|
120
|
+
if (at + CENTRAL_SIZE > directoryEnd || view.getUint32(at, true) !== CENTRAL_SIGNATURE) {
|
|
121
|
+
throw new ZipError("corrupt", `central directory entry ${i + 1} of ${count} is damaged`);
|
|
122
|
+
}
|
|
123
|
+
const nameLength = view.getUint16(at + 28, true);
|
|
124
|
+
const extraLength = view.getUint16(at + 30, true);
|
|
125
|
+
const commentLength = view.getUint16(at + 32, true);
|
|
126
|
+
const next = at + CENTRAL_SIZE + nameLength + extraLength + commentLength;
|
|
127
|
+
if (next > directoryEnd) {
|
|
128
|
+
throw new ZipError("corrupt", `central directory entry ${i + 1} runs past the directory`);
|
|
129
|
+
}
|
|
130
|
+
const name = decodeEntryName(bytes.subarray(at + CENTRAL_SIZE, at + CENTRAL_SIZE + nameLength));
|
|
131
|
+
let compressedSize = view.getUint32(at + 20, true);
|
|
132
|
+
let size = view.getUint32(at + 24, true);
|
|
133
|
+
let localOffset = view.getUint32(at + 42, true);
|
|
134
|
+
if (compressedSize === U32_MAX || size === U32_MAX || localOffset === U32_MAX) {
|
|
135
|
+
({ compressedSize, size, localOffset } = zip64Extra(view, at + CENTRAL_SIZE + nameLength, extraLength, {
|
|
136
|
+
compressedSize,
|
|
137
|
+
size,
|
|
138
|
+
localOffset,
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
entries.push(Object.freeze({
|
|
142
|
+
name,
|
|
143
|
+
method: view.getUint16(at + 10, true),
|
|
144
|
+
flags: view.getUint16(at + 8, true),
|
|
145
|
+
crc32: view.getUint32(at + 16, true),
|
|
146
|
+
compressedSize,
|
|
147
|
+
size,
|
|
148
|
+
localOffset: localOffset + shift,
|
|
149
|
+
directory: name.endsWith("/"),
|
|
150
|
+
}));
|
|
151
|
+
at = next;
|
|
152
|
+
}
|
|
153
|
+
return entries;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The position of the end of central directory record: the last signature whose comment length
|
|
157
|
+
* fits the archive, else the last signature at all (an archive with bytes after its comment).
|
|
158
|
+
* @param bytes - the archive
|
|
159
|
+
* @param view - a view of it
|
|
160
|
+
* @returns the offset, or -1
|
|
161
|
+
*/
|
|
162
|
+
function findEndRecord(bytes, view) {
|
|
163
|
+
const lowest = Math.max(0, bytes.byteLength - EOCD_SIZE - MAX_COMMENT);
|
|
164
|
+
let fallback = -1;
|
|
165
|
+
for (let at = bytes.byteLength - EOCD_SIZE; at >= lowest; at--) {
|
|
166
|
+
if (view.getUint32(at, true) !== EOCD_SIGNATURE) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (at + EOCD_SIZE + view.getUint16(at + 20, true) === bytes.byteLength) {
|
|
170
|
+
return at;
|
|
171
|
+
}
|
|
172
|
+
if (fallback < 0) {
|
|
173
|
+
fallback = at;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return fallback;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The zip64 end of central directory record a locator points at (or, when the archive has bytes
|
|
180
|
+
* prepended, the one right before the locator).
|
|
181
|
+
* @param view - the archive
|
|
182
|
+
* @param locator - the locator's offset
|
|
183
|
+
* @returns the record's offset
|
|
184
|
+
*/
|
|
185
|
+
function zip64EndRecord(view, locator) {
|
|
186
|
+
const stated = readU64(view, locator + 8);
|
|
187
|
+
for (const at of [stated, locator - ZIP64_EOCD_SIZE]) {
|
|
188
|
+
if (at >= 0 && at + ZIP64_EOCD_SIZE <= locator && view.getUint32(at, true) === ZIP64_EOCD_SIGNATURE) {
|
|
189
|
+
return at;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
throw new ZipError("corrupt", "the zip64 end record the locator names is missing");
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The zip64 extended information extra field (header id 0x0001) of a central entry: the 64-bit
|
|
196
|
+
* values of the fields whose 32-bit slot is 0xFFFFFFFF, in the order APPNOTE 4.5.3 gives.
|
|
197
|
+
* @param view - the archive
|
|
198
|
+
* @param at - the start of the extra field
|
|
199
|
+
* @param length - its length
|
|
200
|
+
* @param fields - the 32-bit values
|
|
201
|
+
* @param fields.compressedSize - the compressed size slot
|
|
202
|
+
* @param fields.size - the uncompressed size slot
|
|
203
|
+
* @param fields.localOffset - the local header offset slot
|
|
204
|
+
* @returns the resolved values
|
|
205
|
+
*/
|
|
206
|
+
function zip64Extra(view, at, length, fields) {
|
|
207
|
+
const out = { ...fields };
|
|
208
|
+
for (let p = at; p + 4 <= at + length;) {
|
|
209
|
+
const id = view.getUint16(p, true);
|
|
210
|
+
const dataLength = view.getUint16(p + 2, true);
|
|
211
|
+
if (id === 1) {
|
|
212
|
+
let q = p + 4;
|
|
213
|
+
const end = q + dataLength;
|
|
214
|
+
for (const key of ["size", "compressedSize", "localOffset"]) {
|
|
215
|
+
if (fields[key] === U32_MAX) {
|
|
216
|
+
if (q + 8 > end) {
|
|
217
|
+
throw new ZipError("corrupt", "a zip64 extra field is too short");
|
|
218
|
+
}
|
|
219
|
+
out[key] = readU64(view, q);
|
|
220
|
+
q += 8;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return out;
|
|
224
|
+
}
|
|
225
|
+
p += 4 + dataLength;
|
|
226
|
+
}
|
|
227
|
+
throw new ZipError("corrupt", "an entry needs a zip64 extra field it does not have");
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* An unsigned 64-bit little-endian integer as a number (exact up to 2^53).
|
|
231
|
+
* @param view - the bytes
|
|
232
|
+
* @param at - the offset
|
|
233
|
+
* @returns the value; ZipError "unsupported" beyond 2^53
|
|
234
|
+
*/
|
|
235
|
+
function readU64(view, at) {
|
|
236
|
+
const high = view.getUint32(at + 4, true);
|
|
237
|
+
if (high >= 0x200000) {
|
|
238
|
+
throw new ZipError("unsupported", "a zip64 size or offset beyond 2^53 cannot be read");
|
|
239
|
+
}
|
|
240
|
+
return high * 0x100000000 + view.getUint32(at, true);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Read one entry's data: stored entries are sliced and CRC-checked, deflated ones inflated.
|
|
244
|
+
* @param bytes - the whole archive
|
|
245
|
+
* @param entry - the entry
|
|
246
|
+
* @param options - cancellation, progress and the size limits
|
|
247
|
+
* @returns the uncompressed bytes; ZipError for a damaged, encrypted, unsupported or oversized entry
|
|
248
|
+
*/
|
|
249
|
+
export async function readZipEntry(bytes, entry, options) {
|
|
250
|
+
if ((entry.flags & 1) !== 0 || entry.method === 99) {
|
|
251
|
+
throw new ZipError("unsupported", `${entry.name}: the entry is encrypted`);
|
|
252
|
+
}
|
|
253
|
+
if (entry.method !== 0 && entry.method !== 8) {
|
|
254
|
+
const name = METHOD_NAMES[entry.method] ?? `method ${entry.method}`;
|
|
255
|
+
throw new ZipError("unsupported", `${entry.name}: compression ${name} is not supported (only stored and deflate)`);
|
|
256
|
+
}
|
|
257
|
+
if (entry.size > options.maxBytes) {
|
|
258
|
+
throw new ZipError("too-large", `${entry.name}: ${entry.size} uncompressed bytes exceed the limit of ${options.maxBytes}`);
|
|
259
|
+
}
|
|
260
|
+
if (entry.size > RATIO_FLOOR && entry.size > options.maxRatio * Math.max(entry.compressedSize, 1)) {
|
|
261
|
+
throw new ZipError("too-large", `${entry.name}: ${entry.size} bytes from ${entry.compressedSize} is a compression ratio above ${options.maxRatio}:1`);
|
|
262
|
+
}
|
|
263
|
+
const data = entryData(bytes, entry);
|
|
264
|
+
if (entry.method === 0) {
|
|
265
|
+
if (data.byteLength !== entry.size) {
|
|
266
|
+
throw new ZipError("corrupt", `${entry.name}: a stored entry's sizes disagree`);
|
|
267
|
+
}
|
|
268
|
+
let crc = 0xffffffff;
|
|
269
|
+
for (let at = 0; at < data.byteLength; at += CRC_SLICE) {
|
|
270
|
+
throwIfAborted(options.signal);
|
|
271
|
+
crc = crcUpdate(crc, data.subarray(at, Math.min(at + CRC_SLICE, data.byteLength)));
|
|
272
|
+
options.onBytes?.(Math.min(at + CRC_SLICE, data.byteLength));
|
|
273
|
+
}
|
|
274
|
+
if ((crc ^ 0xffffffff) >>> 0 !== entry.crc32) {
|
|
275
|
+
throw new ZipError("corrupt", `${entry.name}: the data does not match its CRC-32`);
|
|
276
|
+
}
|
|
277
|
+
return data;
|
|
278
|
+
}
|
|
279
|
+
return inflate(data, entry, options);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The compressed bytes of an entry, located through its local header (whose name and extra
|
|
283
|
+
* lengths can differ from the central directory's).
|
|
284
|
+
* @param bytes - the archive
|
|
285
|
+
* @param entry - the entry
|
|
286
|
+
* @returns exactly compressedSize bytes
|
|
287
|
+
*/
|
|
288
|
+
function entryData(bytes, entry) {
|
|
289
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
290
|
+
const at = entry.localOffset;
|
|
291
|
+
if (at + LOCAL_SIZE > bytes.byteLength || view.getUint32(at, true) !== LOCAL_SIGNATURE) {
|
|
292
|
+
throw new ZipError("corrupt", `${entry.name}: the local header is missing`);
|
|
293
|
+
}
|
|
294
|
+
const start = at + LOCAL_SIZE + view.getUint16(at + 26, true) + view.getUint16(at + 28, true);
|
|
295
|
+
const end = start + entry.compressedSize;
|
|
296
|
+
if (end > bytes.byteLength) {
|
|
297
|
+
throw new ZipError("corrupt", `${entry.name}: the entry's data runs past the end of the archive (truncated?)`);
|
|
298
|
+
}
|
|
299
|
+
return bytes.subarray(start, end);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Inflate a deflate stream through `DecompressionStream("gzip")`, wrapped in a gzip member that
|
|
303
|
+
* carries the directory's CRC-32 and size, so the platform checks both.
|
|
304
|
+
* @param data - the raw deflate bytes
|
|
305
|
+
* @param entry - the entry
|
|
306
|
+
* @param options - cancellation, progress and limits
|
|
307
|
+
* @returns the bytes
|
|
308
|
+
*/
|
|
309
|
+
async function inflate(data, entry, options) {
|
|
310
|
+
if (typeof DecompressionStream !== "function") {
|
|
311
|
+
throw new ZipError("unsupported", "this runtime has no DecompressionStream, so deflated entries cannot be read");
|
|
312
|
+
}
|
|
313
|
+
const member = new Uint8Array(10 + data.byteLength + 8);
|
|
314
|
+
member.set([0x1f, 0x8b, 8, 0, 0, 0, 0, 0, 0, 0xff]);
|
|
315
|
+
member.set(data, 10);
|
|
316
|
+
const trailer = new DataView(member.buffer, 10 + data.byteLength, 8);
|
|
317
|
+
trailer.setUint32(0, entry.crc32, true);
|
|
318
|
+
trailer.setUint32(4, entry.size % 0x100000000, true);
|
|
319
|
+
const source = new ReadableStream({
|
|
320
|
+
start(controller) {
|
|
321
|
+
controller.enqueue(member);
|
|
322
|
+
controller.close();
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
const reader = source.pipeThrough(new DecompressionStream("gzip")).getReader();
|
|
326
|
+
const parts = [];
|
|
327
|
+
let total = 0;
|
|
328
|
+
try {
|
|
329
|
+
for (;;) {
|
|
330
|
+
throwIfAborted(options.signal);
|
|
331
|
+
let chunk;
|
|
332
|
+
try {
|
|
333
|
+
chunk = await reader.read();
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
throw new ZipError("corrupt", `${entry.name}: the deflate data is damaged or does not match its CRC-32 and size`);
|
|
337
|
+
}
|
|
338
|
+
if (chunk.done) {
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
total += chunk.value.byteLength;
|
|
342
|
+
if (total > entry.size) {
|
|
343
|
+
throw new ZipError("corrupt", `${entry.name}: the data is longer than its directory size`);
|
|
344
|
+
}
|
|
345
|
+
parts.push(chunk.value);
|
|
346
|
+
options.onBytes?.(total);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
finally {
|
|
350
|
+
await reader.cancel().catch(() => undefined);
|
|
351
|
+
}
|
|
352
|
+
if (total !== entry.size) {
|
|
353
|
+
throw new ZipError("corrupt", `${entry.name}: the data is shorter than its directory size`);
|
|
354
|
+
}
|
|
355
|
+
if (parts.length === 1) {
|
|
356
|
+
return parts[0];
|
|
357
|
+
}
|
|
358
|
+
const out = new Uint8Array(total);
|
|
359
|
+
let at = 0;
|
|
360
|
+
for (const part of parts) {
|
|
361
|
+
out.set(part, at);
|
|
362
|
+
at += part.byteLength;
|
|
363
|
+
}
|
|
364
|
+
return out;
|
|
365
|
+
}
|
|
366
|
+
/** The CRC-32 table (polynomial 0xEDB88320). */
|
|
367
|
+
const CRC_TABLE = (() => {
|
|
368
|
+
const table = new Uint32Array(256);
|
|
369
|
+
for (let n = 0; n < 256; n++) {
|
|
370
|
+
let c = n;
|
|
371
|
+
for (let k = 0; k < 8; k++) {
|
|
372
|
+
c = (c & 1) === 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
373
|
+
}
|
|
374
|
+
table[n] = c >>> 0;
|
|
375
|
+
}
|
|
376
|
+
return table;
|
|
377
|
+
})();
|
|
378
|
+
/**
|
|
379
|
+
* Continue a CRC-32 over more bytes.
|
|
380
|
+
* @param crc - the running value (start with 0xFFFFFFFF)
|
|
381
|
+
* @param bytes - the bytes
|
|
382
|
+
* @returns the running value (XOR with 0xFFFFFFFF to finish)
|
|
383
|
+
*/
|
|
384
|
+
function crcUpdate(crc, bytes) {
|
|
385
|
+
let c = crc;
|
|
386
|
+
for (const byte of bytes) {
|
|
387
|
+
c = CRC_TABLE[(c ^ byte) & 0xff] ^ (c >>> 8);
|
|
388
|
+
}
|
|
389
|
+
return c >>> 0;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The CRC-32 of bytes.
|
|
393
|
+
* @param bytes - the bytes
|
|
394
|
+
* @returns the checksum
|
|
395
|
+
*/
|
|
396
|
+
export function crc32(bytes) {
|
|
397
|
+
return (crcUpdate(0xffffffff, bytes) ^ 0xffffffff) >>> 0;
|
|
398
|
+
}
|
|
399
|
+
//# sourceMappingURL=zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../../src/common/zip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAK7D,sEAAsE;AACtE,MAAM,OAAO,QAAS,SAAQ,KAAK;IAI/B;;;;OAIG;IACH,YAAY,IAAkB,EAAE,OAAe;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ;AAkCD,gGAAgG;AAChG,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;AAEvC,MAAM,cAAc,GAAG,UAAU,CAAC;AAClC,MAAM,uBAAuB,GAAG,UAAU,CAAC;AAC3C,MAAM,oBAAoB,GAAG,UAAU,CAAC;AACxC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AACrC,MAAM,eAAe,GAAG,UAAU,CAAC;AACnC,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,WAAW,GAAG,KAAK,CAAC;AAC1B,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,OAAO,GAAG,MAAM,CAAC;AACvB,MAAM,OAAO,GAAG,UAAU,CAAC;AAC3B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AChD,MAAM,SAAS,GAAG,CAAC,GAAgB,EAAE;IACjC,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACzB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACzD,CAAC;QACD,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC,EAAE,CAAC;AAEL;;;;;GAKG;AACH,SAAS,SAAS,CAAC,GAAW,EAAE,KAAiB;IAC7C,IAAI,CAAC,GAAG,GAAG,CAAC;IACZ,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,KAAiB;IACnC,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CX version 1 importer (design/graph-io/cytoscape-and-obo/design.md section 1.2; the feature
|
|
3
|
+
* and error inventory is research-cx.md): the JSON exchange format of NDEx and Cytoscape's CX
|
|
4
|
+
* support. A CX document is an array of aspect fragments (`nodes`, `edges`, `nodeAttributes`,
|
|
5
|
+
* `cartesianLayout`, `cySubNetworks`, `cyGroups`, `cyVisualProperties`, ...) that refer to each
|
|
6
|
+
* other by integer ids, in any order.
|
|
7
|
+
*
|
|
8
|
+
* The document is read through the streaming scanner of common/json-elements.ts, so its text is
|
|
9
|
+
* never held as one string; the parsed aspect elements are collected and each graph is built at the
|
|
10
|
+
* end, because a reference may precede what it names.
|
|
11
|
+
*
|
|
12
|
+
* Mapping: every edge is directed; ids follow the CX id rule (design section 1.0.2); `n` is the
|
|
13
|
+
* `name` column (the label), `r` is `represents`, `i` is `interaction`; attributes become columns
|
|
14
|
+
* typed by their `d` (Cytoscape's value rule: "" and "null" are unset, "NaN" is NaN in a double); a
|
|
15
|
+
* subnetwork's values are the unscoped ones and its own (`s`), its own winning. A collection (several
|
|
16
|
+
* `cySubNetworks`) holds one graph per subnetwork: `importAll()` returns them, `import()` reads the
|
|
17
|
+
* one `graphIndex` / `graphName` picks, `listGraphs()` lists them. Positions come from the
|
|
18
|
+
* subnetwork's view, y flipped to y-up, `z` into the `z` column; `cyGroups` give `parent` (or
|
|
19
|
+
* `parents`); per-element visual properties are one column per property (origin namespace
|
|
20
|
+
* "cx.bypass") and style rules are kept verbatim in `meta.extra.cx` and not applied
|
|
21
|
+
* (W_STYLES_NOT_IMPORTED, issue #706); provenance aspects become extension tables and list columns.
|
|
22
|
+
*/
|
|
23
|
+
import { type GraphChoiceOptions, type GraphImporter } from "../../types.js";
|
|
24
|
+
/** The format-specific options of the CX importer. */
|
|
25
|
+
export interface CxImportOptions extends GraphChoiceOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Where a node's `z` goes: "column" (default) keeps it in the f64 node column `z` (Cytoscape
|
|
28
|
+
* writes a stacking order there); "position" makes it the third component of the position.
|
|
29
|
+
*/
|
|
30
|
+
zAs?: "column" | "position" | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The issue codes the CX importer records (design section 1.2), by name: the codes shared with
|
|
34
|
+
* the other importers (src/common/codes.ts) and the CX-specific ones. A key is the code without
|
|
35
|
+
* its severity and format prefixes.
|
|
36
|
+
*/
|
|
37
|
+
export declare const CX_ISSUE: Readonly<{
|
|
38
|
+
/** The input is empty (fatal). */
|
|
39
|
+
EMPTY_INPUT: "E_EMPTY_INPUT";
|
|
40
|
+
/** The text is not JSON (fatal). */
|
|
41
|
+
SYNTAX: "E_SYNTAX";
|
|
42
|
+
/** Invalid UTF-8 (fatal). */
|
|
43
|
+
INVALID_UTF8: "E_INVALID_UTF8";
|
|
44
|
+
/** Invalid bytes in the encoding a BOM or the encoding option chose (fatal). */
|
|
45
|
+
INVALID_ENCODING: "E_INVALID_ENCODING";
|
|
46
|
+
/** Bytes that are not UTF-8 were read as windows-1252. */
|
|
47
|
+
ENCODING_FALLBACK: "W_ENCODING_FALLBACK";
|
|
48
|
+
/** An encoding the platform cannot decode was ignored. */
|
|
49
|
+
UNKNOWN_ENCODING: "W_UNKNOWN_ENCODING";
|
|
50
|
+
/** The document is not a CX array, or it is CX2 (fatal; the message names CX2). */
|
|
51
|
+
NOT_CX: "E_CX_NOT_CX";
|
|
52
|
+
/** numberVerification holds another value than 2^48 - 1, or comes twice. */
|
|
53
|
+
NUMBER_VERIFICATION: "W_CX_NUMBER_VERIFICATION";
|
|
54
|
+
/** An old Cytoscape aspect name (visualProperties, subNetworks, ...) read under its cy name. */
|
|
55
|
+
OLD_ASPECT_NAME: "W_CX_OLD_ASPECT_NAME";
|
|
56
|
+
/** A cyGroups group whose id is not a node: the group node is added. */
|
|
57
|
+
GROUP_NODE_ADDED: "W_CX_GROUP_NODE_ADDED";
|
|
58
|
+
/** Nodes or edges of the root network that no subnetwork holds: Cytoscape shows them in no network; not read. */
|
|
59
|
+
ROOT_ONLY: "W_CX_ROOT_ONLY";
|
|
60
|
+
/** The producer marked the document as failed (fatal). */
|
|
61
|
+
STATUS_FAILED: "E_STATUS_FAILED";
|
|
62
|
+
/** The producer marked the document as successful with an error text. */
|
|
63
|
+
STATUS_WARNING: "W_STATUS_WARNING";
|
|
64
|
+
/** A member of the array that is not a one-key aspect block, or an element that is not an object. */
|
|
65
|
+
BAD_ASPECT_BLOCK: "E_BAD_ASPECT_BLOCK";
|
|
66
|
+
/** An aspect after the post-metadata or after the status, a third metaData. */
|
|
67
|
+
ASPECT_ORDER: "W_ASPECT_ORDER";
|
|
68
|
+
/** A metaData element count disagrees with what was read. */
|
|
69
|
+
COUNT_MISMATCH: "W_COUNT_MISMATCH";
|
|
70
|
+
/** A value that does not parse as its data type; the cell is unset. */
|
|
71
|
+
BAD_VALUE: "E_BAD_VALUE";
|
|
72
|
+
/** One attribute name with several data types: the column takes the wider one. */
|
|
73
|
+
WIDENED: "W_WIDENED";
|
|
74
|
+
/** A data type CX does not define; the value is kept as text. */
|
|
75
|
+
UNKNOWN_ATTR_TYPE: "W_UNKNOWN_ATTR_TYPE";
|
|
76
|
+
/** An attribute, layout, bypass, subnetwork member, view or provenance entry naming nothing. */
|
|
77
|
+
DANGLING_REFERENCE: "W_DANGLING_REFERENCE";
|
|
78
|
+
/** The same attribute twice on one element (or n and a different name attribute); the later wins. */
|
|
79
|
+
DUPLICATE_ATTRIBUTE: "W_DUPLICATE_ATTRIBUTE";
|
|
80
|
+
/** A group member naming no node. */
|
|
81
|
+
UNKNOWN_PARENT: "E_UNKNOWN_PARENT";
|
|
82
|
+
/** A group membership that would close a parent cycle; dropped. */
|
|
83
|
+
PARENT_CYCLE: "E_PARENT_CYCLE";
|
|
84
|
+
/** The style rules of cyVisualProperties are not applied (issue #706). */
|
|
85
|
+
STYLES_NOT_IMPORTED: "W_STYLES_NOT_IMPORTED";
|
|
86
|
+
/** A node without an @id. */
|
|
87
|
+
MISSING_ID: "E_MISSING_ID";
|
|
88
|
+
/** An edge without s or t. */
|
|
89
|
+
MISSING_ENDPOINT: "E_MISSING_ENDPOINT";
|
|
90
|
+
/** A node id declared twice; the second merges into the first. */
|
|
91
|
+
DUPLICATE_NODE: "W_DUPLICATE_NODE";
|
|
92
|
+
/** An edge id declared twice; the second edge is skipped. */
|
|
93
|
+
DUPLICATE_EDGE_ID: "E_DUPLICATE_EDGE_ID";
|
|
94
|
+
/** An id that is not an integer. */
|
|
95
|
+
INVALID_ID: "E_INVALID_ID";
|
|
96
|
+
/** An edge endpoint naming no node of the graph (addMissingNodes false, the default). */
|
|
97
|
+
UNKNOWN_NODE: "E_UNKNOWN_NODE";
|
|
98
|
+
/** A weight that is not a number. */
|
|
99
|
+
INVALID_WEIGHT: "E_INVALID_WEIGHT";
|
|
100
|
+
/** An id spelled as a string or a non-integer literal; read as the integer. */
|
|
101
|
+
ID_TEXT_TYPE: "W_ID_TEXT_TYPE";
|
|
102
|
+
/** An integer beyond 2^53: an id kept as its digits, a value stored as the nearest f64. */
|
|
103
|
+
PRECISION: "W_PRECISION";
|
|
104
|
+
/** Two id texts merged under `ids: "number"`. */
|
|
105
|
+
ID_MERGED: "W_ID_MERGED";
|
|
106
|
+
/** A collection read by import(): the other subnetworks are skipped. */
|
|
107
|
+
MULTIPLE_GRAPHS: "W_MULTIPLE_GRAPHS";
|
|
108
|
+
/** graphIndex or graphName names no subnetwork (fatal). */
|
|
109
|
+
GRAPH_NOT_FOUND: "E_GRAPH_NOT_FOUND";
|
|
110
|
+
/** graphName names several subnetworks (fatal). */
|
|
111
|
+
AMBIGUOUS_GRAPH_NAME: "E_AMBIGUOUS_GRAPH_NAME";
|
|
112
|
+
/** The input holds no graph (fatal). */
|
|
113
|
+
NO_GRAPH: "E_NO_GRAPH";
|
|
114
|
+
/** A column renamed because its name was taken. */
|
|
115
|
+
COLUMN_RENAMED: "W_COLUMN_RENAMED";
|
|
116
|
+
/** A column that lost its role because another column holds it. */
|
|
117
|
+
ROLE_TAKEN: "W_ROLE_TAKEN";
|
|
118
|
+
/** The sink refused the direction. */
|
|
119
|
+
DIRECTION_REFUSED: "W_DIRECTION_REFUSED";
|
|
120
|
+
/** Edges forced to the policy's direction. */
|
|
121
|
+
DIRECTION_FORCED: "W_DIRECTION_FORCED";
|
|
122
|
+
/** A common option CX has no use for. */
|
|
123
|
+
OPTION_IGNORED: "W_OPTION_IGNORED";
|
|
124
|
+
/** A builder option the caller's sink does not honour. */
|
|
125
|
+
SINK_OPTION: "W_SINK_OPTION";
|
|
126
|
+
/** The input is beyond a size limit (fatal). */
|
|
127
|
+
TOO_LARGE: "E_TOO_LARGE";
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* The CX version 1 importer plugin (design section 1.2).
|
|
131
|
+
*/
|
|
132
|
+
export declare const cxImporter: GraphImporter<CxImportOptions>;
|
|
133
|
+
//# sourceMappingURL=importer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../../../../src/formats/cx/importer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAiFH,OAAO,EAEH,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAIrB,MAAM,gBAAgB,CAAC;AASxB,sDAAsD;AACtD,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACvD;;;OAGG;IACH,GAAG,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;CAC3C;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ;IACjB,kCAAkC;;IAElC,oCAAoC;;IAEpC,6BAA6B;;IAE7B,gFAAgF;;IAEhF,0DAA0D;;IAE1D,0DAA0D;;IAE1D,mFAAmF;;IAEnF,4EAA4E;;IAE5E,gGAAgG;;IAEhG,wEAAwE;;IAExE,iHAAiH;;IAEjH,0DAA0D;;IAE1D,yEAAyE;;IAEzE,qGAAqG;;IAErG,+EAA+E;;IAE/E,6DAA6D;;IAE7D,uEAAuE;;IAEvE,kFAAkF;;IAElF,iEAAiE;;IAEjE,gGAAgG;;IAEhG,qGAAqG;;IAErG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