@graphty/graph-io 0.3.19 → 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.
Files changed (188) hide show
  1. package/README.md +43 -0
  2. package/dist/chunks/{escape-CWExcecC.js → escape-B-tkk_Cl.js} +74 -16
  3. package/dist/chunks/escape-B-tkk_Cl.js.map +1 -0
  4. package/dist/chunks/{writer-DQiKgQJc.js → export-Bh60Dv-n.js} +5 -79
  5. package/dist/chunks/export-Bh60Dv-n.js.map +1 -0
  6. package/dist/chunks/{exporter-CbMZyVt-.js → exporter-BGrsWamJ.js} +7 -6
  7. package/dist/chunks/{exporter-CbMZyVt-.js.map → exporter-BGrsWamJ.js.map} +1 -1
  8. package/dist/chunks/exporter-DIeGJXAZ.js +834 -0
  9. package/dist/chunks/exporter-DIeGJXAZ.js.map +1 -0
  10. package/dist/chunks/{importer-BNFuV1-K.js → importer-BWY2FFc5.js} +28 -7
  11. package/dist/chunks/importer-BWY2FFc5.js.map +1 -0
  12. package/dist/chunks/{importer-BAP4PrxR.js → importer-BaQpCEcJ.js} +5 -5
  13. package/dist/chunks/{importer-BAP4PrxR.js.map → importer-BaQpCEcJ.js.map} +1 -1
  14. package/dist/chunks/importer-DD-xv9_Y.js +1471 -0
  15. package/dist/chunks/importer-DD-xv9_Y.js.map +1 -0
  16. package/dist/chunks/{importer-ByPGO-09.js → importer-DEcKhsmQ.js} +2 -2
  17. package/dist/chunks/{importer-ByPGO-09.js.map → importer-DEcKhsmQ.js.map} +1 -1
  18. package/dist/chunks/{importer-BW-Ft2ps.js → importer-DIrbbnAf.js} +6 -5
  19. package/dist/chunks/{importer-BW-Ft2ps.js.map → importer-DIrbbnAf.js.map} +1 -1
  20. package/dist/chunks/importer-D_e7e7LX.js +3055 -0
  21. package/dist/chunks/importer-D_e7e7LX.js.map +1 -0
  22. package/dist/chunks/{importer-Bm1_5vPS.js → importer-Wv4C4gaF.js} +9 -6
  23. package/dist/chunks/importer-Wv4C4gaF.js.map +1 -0
  24. package/dist/chunks/{importer-DOepkgnG.js → importer-vi3bSdtw.js} +4 -4
  25. package/dist/chunks/{importer-DOepkgnG.js.map → importer-vi3bSdtw.js.map} +1 -1
  26. package/dist/chunks/{importer-BVGtU1NA.js → importer-zGLo8Dg_.js} +6 -5
  27. package/dist/chunks/{importer-BVGtU1NA.js.map → importer-zGLo8Dg_.js.map} +1 -1
  28. package/dist/chunks/{json-elements-CZY1wiZh.js → json-elements-DDS8N2Dd.js} +2 -2
  29. package/dist/chunks/{json-elements-CZY1wiZh.js.map → json-elements-DDS8N2Dd.js.map} +1 -1
  30. package/dist/chunks/{records-BzNicMsf.js → records-dbRkxwaq.js} +2 -2
  31. package/dist/chunks/{records-BzNicMsf.js.map → records-dbRkxwaq.js.map} +1 -1
  32. package/dist/chunks/{report-BcWboivV.js → report-B1z4WT9e.js} +143 -111
  33. package/dist/chunks/{report-BcWboivV.js.map → report-B1z4WT9e.js.map} +1 -1
  34. package/dist/chunks/{weights-CwISIpCP.js → weights-Dzba96G3.js} +5 -5
  35. package/dist/chunks/{weights-CwISIpCP.js.map → weights-Dzba96G3.js.map} +1 -1
  36. package/dist/chunks/writer-C7flM-Ih.js +77 -0
  37. package/dist/chunks/writer-C7flM-Ih.js.map +1 -0
  38. package/dist/csv.js +6 -5
  39. package/dist/csv.js.map +1 -1
  40. package/dist/cx.js +1 -1
  41. package/dist/cx2.js +2 -2
  42. package/dist/cys.d.ts +1 -0
  43. package/dist/cys.js +6 -0
  44. package/dist/cys.js.map +1 -0
  45. package/dist/dot.js +1 -1
  46. package/dist/gexf.js +5 -4
  47. package/dist/gexf.js.map +1 -1
  48. package/dist/gml.js +12 -14
  49. package/dist/gml.js.map +1 -1
  50. package/dist/graph-io.js +288 -141
  51. package/dist/graph-io.js.map +1 -1
  52. package/dist/graphml.js +1 -1
  53. package/dist/json.js +1 -1
  54. package/dist/neo4j.js +6 -5
  55. package/dist/neo4j.js.map +1 -1
  56. package/dist/obo.js +1 -1
  57. package/dist/pajek.js +1 -1
  58. package/dist/src/common/cell-budget.d.ts +84 -0
  59. package/dist/src/common/cell-budget.d.ts.map +1 -0
  60. package/dist/src/common/cell-budget.js +138 -0
  61. package/dist/src/common/cell-budget.js.map +1 -0
  62. package/dist/src/common/input.d.ts +10 -0
  63. package/dist/src/common/input.d.ts.map +1 -1
  64. package/dist/src/common/input.js +39 -0
  65. package/dist/src/common/input.js.map +1 -1
  66. package/dist/src/common/options.d.ts +6 -0
  67. package/dist/src/common/options.d.ts.map +1 -1
  68. package/dist/src/common/options.js +1 -1
  69. package/dist/src/common/options.js.map +1 -1
  70. package/dist/src/common/xml.d.ts +37 -3
  71. package/dist/src/common/xml.d.ts.map +1 -1
  72. package/dist/src/common/xml.js +86 -6
  73. package/dist/src/common/xml.js.map +1 -1
  74. package/dist/src/common/zip.d.ts +92 -0
  75. package/dist/src/common/zip.d.ts.map +1 -0
  76. package/dist/src/common/zip.js +399 -0
  77. package/dist/src/common/zip.js.map +1 -0
  78. package/dist/src/formats/cys/constants.d.ts +68 -0
  79. package/dist/src/formats/cys/constants.d.ts.map +1 -0
  80. package/dist/src/formats/cys/constants.js +76 -0
  81. package/dist/src/formats/cys/constants.js.map +1 -0
  82. package/dist/src/formats/cys/importer.d.ts +38 -0
  83. package/dist/src/formats/cys/importer.d.ts.map +1 -0
  84. package/dist/src/formats/cys/importer.js +830 -0
  85. package/dist/src/formats/cys/importer.js.map +1 -0
  86. package/dist/src/formats/cys/index.d.ts +7 -0
  87. package/dist/src/formats/cys/index.d.ts.map +1 -0
  88. package/dist/src/formats/cys/index.js +7 -0
  89. package/dist/src/formats/cys/index.js.map +1 -0
  90. package/dist/src/formats/cys/session.d.ts +132 -0
  91. package/dist/src/formats/cys/session.d.ts.map +1 -0
  92. package/dist/src/formats/cys/session.js +315 -0
  93. package/dist/src/formats/cys/session.js.map +1 -0
  94. package/dist/src/formats/cys/tables.d.ts +90 -0
  95. package/dist/src/formats/cys/tables.d.ts.map +1 -0
  96. package/dist/src/formats/cys/tables.js +293 -0
  97. package/dist/src/formats/cys/tables.js.map +1 -0
  98. package/dist/src/formats/dot/exporter.d.ts +2 -0
  99. package/dist/src/formats/dot/exporter.d.ts.map +1 -1
  100. package/dist/src/formats/dot/exporter.js +12 -0
  101. package/dist/src/formats/dot/exporter.js.map +1 -1
  102. package/dist/src/formats/dot/importer.js +6 -2
  103. package/dist/src/formats/dot/importer.js.map +1 -1
  104. package/dist/src/formats/gexf/importer.d.ts +2 -2
  105. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  106. package/dist/src/formats/gexf/importer.js +1 -1
  107. package/dist/src/formats/gexf/importer.js.map +1 -1
  108. package/dist/src/formats/gml/exporter.d.ts +0 -8
  109. package/dist/src/formats/gml/exporter.d.ts.map +1 -1
  110. package/dist/src/formats/gml/exporter.js +7 -17
  111. package/dist/src/formats/gml/exporter.js.map +1 -1
  112. package/dist/src/formats/xgmml/columns.d.ts +152 -0
  113. package/dist/src/formats/xgmml/columns.d.ts.map +1 -0
  114. package/dist/src/formats/xgmml/columns.js +593 -0
  115. package/dist/src/formats/xgmml/columns.js.map +1 -0
  116. package/dist/src/formats/xgmml/constants.d.ts +196 -0
  117. package/dist/src/formats/xgmml/constants.d.ts.map +1 -0
  118. package/dist/src/formats/xgmml/constants.js +197 -0
  119. package/dist/src/formats/xgmml/constants.js.map +1 -0
  120. package/dist/src/formats/xgmml/document.d.ts +361 -0
  121. package/dist/src/formats/xgmml/document.d.ts.map +1 -0
  122. package/dist/src/formats/xgmml/document.js +695 -0
  123. package/dist/src/formats/xgmml/document.js.map +1 -0
  124. package/dist/src/formats/xgmml/emit.d.ts +341 -0
  125. package/dist/src/formats/xgmml/emit.d.ts.map +1 -0
  126. package/dist/src/formats/xgmml/emit.js +1275 -0
  127. package/dist/src/formats/xgmml/emit.js.map +1 -0
  128. package/dist/src/formats/xgmml/exporter.d.ts +24 -0
  129. package/dist/src/formats/xgmml/exporter.d.ts.map +1 -0
  130. package/dist/src/formats/xgmml/exporter.js +999 -0
  131. package/dist/src/formats/xgmml/exporter.js.map +1 -0
  132. package/dist/src/formats/xgmml/importer.d.ts +58 -0
  133. package/dist/src/formats/xgmml/importer.d.ts.map +1 -0
  134. package/dist/src/formats/xgmml/importer.js +360 -0
  135. package/dist/src/formats/xgmml/importer.js.map +1 -0
  136. package/dist/src/formats/xgmml/index.d.ts +8 -0
  137. package/dist/src/formats/xgmml/index.d.ts.map +1 -0
  138. package/dist/src/formats/xgmml/index.js +8 -0
  139. package/dist/src/formats/xgmml/index.js.map +1 -0
  140. package/dist/src/formats/xgmml/values.d.ts +60 -0
  141. package/dist/src/formats/xgmml/values.d.ts.map +1 -0
  142. package/dist/src/formats/xgmml/values.js +148 -0
  143. package/dist/src/formats/xgmml/values.js.map +1 -0
  144. package/dist/src/index.d.ts +2 -0
  145. package/dist/src/index.d.ts.map +1 -1
  146. package/dist/src/index.js +2 -0
  147. package/dist/src/index.js.map +1 -1
  148. package/dist/src/registry.d.ts +7 -0
  149. package/dist/src/registry.d.ts.map +1 -1
  150. package/dist/src/registry.js +25 -10
  151. package/dist/src/registry.js.map +1 -1
  152. package/dist/src/sniff.d.ts +1 -1
  153. package/dist/src/sniff.d.ts.map +1 -1
  154. package/dist/src/sniff.js +2 -0
  155. package/dist/src/sniff.js.map +1 -1
  156. package/dist/xgmml.d.ts +1 -0
  157. package/dist/xgmml.js +9 -0
  158. package/dist/xgmml.js.map +1 -0
  159. package/package.json +15 -2
  160. package/src/common/cell-budget.ts +170 -0
  161. package/src/common/input.ts +40 -0
  162. package/src/common/options.ts +1 -1
  163. package/src/common/xml.ts +127 -6
  164. package/src/common/zip.ts +472 -0
  165. package/src/formats/cys/constants.ts +99 -0
  166. package/src/formats/cys/importer.ts +1100 -0
  167. package/src/formats/cys/index.ts +7 -0
  168. package/src/formats/cys/session.ts +428 -0
  169. package/src/formats/cys/tables.ts +400 -0
  170. package/src/formats/dot/exporter.ts +17 -0
  171. package/src/formats/dot/importer.ts +6 -2
  172. package/src/formats/gexf/importer.ts +0 -1
  173. package/src/formats/gml/exporter.ts +7 -18
  174. package/src/formats/xgmml/columns.ts +747 -0
  175. package/src/formats/xgmml/constants.ts +265 -0
  176. package/src/formats/xgmml/document.ts +975 -0
  177. package/src/formats/xgmml/emit.ts +1563 -0
  178. package/src/formats/xgmml/exporter.ts +1215 -0
  179. package/src/formats/xgmml/importer.ts +491 -0
  180. package/src/formats/xgmml/index.ts +8 -0
  181. package/src/formats/xgmml/values.ts +183 -0
  182. package/src/index.ts +9 -0
  183. package/src/registry.ts +41 -15
  184. package/src/sniff.ts +5 -1
  185. package/dist/chunks/escape-CWExcecC.js.map +0 -1
  186. package/dist/chunks/importer-BNFuV1-K.js.map +0 -1
  187. package/dist/chunks/importer-Bm1_5vPS.js.map +0 -1
  188. package/dist/chunks/writer-DQiKgQJc.js.map +0 -1
@@ -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,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it adds, and its issue code table (design `design/graph-io/cytoscape-and-obo/design.md`
4
+ * sections 1.4 and 3).
5
+ */
6
+ /** The format name. */
7
+ export declare const FORMAT = "cys";
8
+ /** File extensions. */
9
+ export declare const EXTENSIONS: readonly string[];
10
+ /** MIME types: Cytoscape declares none, so the generic zip type. */
11
+ export declare const MIME_TYPES: readonly string[];
12
+ /** The `meta.extra` key of the session facts. */
13
+ export declare const META_KEY = "cytoscape";
14
+ /** The origin namespace of the columns the session importer adds (selection, hidden state). */
15
+ export declare const CYTOSCAPE_NAMESPACE = "cytoscape";
16
+ /** The 2.x selected state (bool node and edge column). */
17
+ export declare const SELECTED_COLUMN = "cytoscape.selected";
18
+ /** The 2.x hidden state (bool node and edge column). */
19
+ export declare const HIDDEN_COLUMN = "cytoscape.hidden";
20
+ /** The prefix of the node columns of a second and further view's positions (`position@2`). */
21
+ export declare const VIEW_POSITION_PREFIX = "position@";
22
+ /** The default total of uncompressed bytes one import may inflate (2 GiB). */
23
+ export declare const DEFAULT_MAX_UNCOMPRESSED: number;
24
+ /** The largest uncompressed-to-compressed ratio an entry may have (real sessions reach 30:1). */
25
+ export declare const MAX_RATIO = 1000;
26
+ /**
27
+ * Issue codes of the Cytoscape session importer: its own, the shared ones it records and the
28
+ * XGMML codes it relays from the files inside (with the entry name in the message).
29
+ */
30
+ export declare const CYS_ISSUE: Readonly<{
31
+ /** The input is not a zip archive (or is text). */
32
+ NOT_ZIP: "E_CYS_NOT_ZIP";
33
+ /** The archive is damaged: no end record, offsets outside the file, a bad CRC, truncated data. */
34
+ CORRUPT: "E_CYS_CORRUPT";
35
+ /** A zip without a session marker (`<x.y.z>.version` or `cysession.xml`). */
36
+ NOT_SESSION: "E_CYS_NOT_SESSION";
37
+ /** A zip feature the reader does not support: encryption, a compression method, split archives. */
38
+ UNSUPPORTED: "E_CYS_UNSUPPORTED";
39
+ /** A session version graph-io cannot read: a major above 3, or the 2011 3.0 pre-release layout. */
40
+ VERSION: "E_CYS_VERSION";
41
+ /** A table or a virtual column that cannot be read at all; it is skipped. */
42
+ TABLE: "E_CYS_TABLE";
43
+ /** Table rows with too few or too many cells, a repeated key, or a key matching no element. */
44
+ TABLE_ROW: "W_CYS_TABLE_ROW";
45
+ /** A collapsed group's members are not in the network; they are recorded in meta.extra. */
46
+ COLLAPSED_GROUP: "W_CYS_COLLAPSED_GROUP";
47
+ /** Entries the importer does not read (apps, global tables, properties, images, thumbnails). */
48
+ ENTRY_SKIPPED: "W_CYS_ENTRY_SKIPPED";
49
+ /** Two entries with one name; the first is read. */
50
+ DUPLICATE_ENTRY: "W_CYS_DUPLICATE_ENTRY";
51
+ /** The archive inflates beyond maxUncompressedBytes, or an entry beyond the ratio limit. */
52
+ TOO_LARGE: "E_TOO_LARGE";
53
+ /** The session's styles are not applied (issue #706). */
54
+ STYLES_NOT_IMPORTED: "W_STYLES_NOT_IMPORTED";
55
+ /** A view, table or network the session names but does not hold. */
56
+ DANGLING_REFERENCE: "W_DANGLING_REFERENCE";
57
+ /** The input is empty. */
58
+ EMPTY_INPUT: "E_EMPTY_INPUT";
59
+ /** The session holds no network. */
60
+ NO_GRAPH: "E_NO_GRAPH";
61
+ /** The session holds several networks; one was read. */
62
+ MULTIPLE_GRAPHS: "W_MULTIPLE_GRAPHS";
63
+ /** graphIndex / graphName names no network (fatal). */
64
+ GRAPH_NOT_FOUND: "E_GRAPH_NOT_FOUND";
65
+ /** graphName names several networks (fatal). */
66
+ AMBIGUOUS_GRAPH_NAME: "E_AMBIGUOUS_GRAPH_NAME";
67
+ }>;
68
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/formats/cys/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,uBAAuB;AACvB,eAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,uBAAuB;AACvB,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAA4B,CAAC;AAErE,oEAAoE;AACpE,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAAuC,CAAC;AAEhF,iDAAiD;AACjD,eAAO,MAAM,QAAQ,cAAc,CAAC;AAEpC,+FAA+F;AAC/F,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,eAAe,uBAAuB,CAAC;AAEpD,wDAAwD;AACxD,eAAO,MAAM,aAAa,qBAAqB,CAAC;AAEhD,8FAA8F;AAC9F,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,QAAyB,CAAC;AAE/D,iGAAiG;AACjG,eAAO,MAAM,SAAS,OAAO,CAAC;AAU9B;;;GAGG;AACH,eAAO,MAAM,SAAS;IAElB,mDAAmD;;IAEnD,kGAAkG;;IAElG,6EAA6E;;IAE7E,mGAAmG;;IAEnG,mGAAmG;;IAEnG,6EAA6E;;IAE7E,+FAA+F;;IAE/F,2FAA2F;;IAE3F,gGAAgG;;IAEhG,oDAAoD;;IAEpD,4FAA4F;;IAE5F,yDAAyD;;IAEzD,oEAAoE;;IAEpE,0BAA0B;;IAE1B,oCAAoC;;IAEpC,wDAAwD;;IAExD,uDAAuD;;IAEvD,gDAAgD;;EAElD,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * What the Cytoscape session importer's modules share: the format facts, the column and metadata
3
+ * names it adds, and its issue code table (design `design/graph-io/cytoscape-and-obo/design.md`
4
+ * sections 1.4 and 3).
5
+ */
6
+ import { AMBIGUOUS_GRAPH_NAME_CODE, DANGLING_REFERENCE_CODE, EMPTY_INPUT_CODE, GRAPH_NOT_FOUND_CODE, MULTIPLE_GRAPHS_CODE, NO_GRAPH_CODE, STYLES_NOT_IMPORTED_CODE, TOO_LARGE_CODE, } from "../../common/codes.js";
7
+ import { XGMML_ISSUE } from "../xgmml/constants.js";
8
+ /** The format name. */
9
+ export const FORMAT = "cys";
10
+ /** File extensions. */
11
+ export const EXTENSIONS = Object.freeze([".cys"]);
12
+ /** MIME types: Cytoscape declares none, so the generic zip type. */
13
+ export const MIME_TYPES = Object.freeze(["application/zip"]);
14
+ /** The `meta.extra` key of the session facts. */
15
+ export const META_KEY = "cytoscape";
16
+ /** The origin namespace of the columns the session importer adds (selection, hidden state). */
17
+ export const CYTOSCAPE_NAMESPACE = "cytoscape";
18
+ /** The 2.x selected state (bool node and edge column). */
19
+ export const SELECTED_COLUMN = "cytoscape.selected";
20
+ /** The 2.x hidden state (bool node and edge column). */
21
+ export const HIDDEN_COLUMN = "cytoscape.hidden";
22
+ /** The prefix of the node columns of a second and further view's positions (`position@2`). */
23
+ export const VIEW_POSITION_PREFIX = "position@";
24
+ /** The default total of uncompressed bytes one import may inflate (2 GiB). */
25
+ export const DEFAULT_MAX_UNCOMPRESSED = 2 * 1024 * 1024 * 1024;
26
+ /** The largest uncompressed-to-compressed ratio an entry may have (real sessions reach 30:1). */
27
+ export const MAX_RATIO = 1000;
28
+ /**
29
+ * The XGMML codes the session importer relays from the network and view files inside, keyed as
30
+ * every table is (the code without its `E_` / `W_` prefix).
31
+ */
32
+ const RELAYED = Object.fromEntries(Object.values(XGMML_ISSUE).map((code) => [code.replace(/^[EW]_/, ""), code]));
33
+ /**
34
+ * Issue codes of the Cytoscape session importer: its own, the shared ones it records and the
35
+ * XGMML codes it relays from the files inside (with the entry name in the message).
36
+ */
37
+ export const CYS_ISSUE = Object.freeze({
38
+ ...RELAYED,
39
+ /** The input is not a zip archive (or is text). */
40
+ NOT_ZIP: "E_CYS_NOT_ZIP",
41
+ /** The archive is damaged: no end record, offsets outside the file, a bad CRC, truncated data. */
42
+ CORRUPT: "E_CYS_CORRUPT",
43
+ /** A zip without a session marker (`<x.y.z>.version` or `cysession.xml`). */
44
+ NOT_SESSION: "E_CYS_NOT_SESSION",
45
+ /** A zip feature the reader does not support: encryption, a compression method, split archives. */
46
+ UNSUPPORTED: "E_CYS_UNSUPPORTED",
47
+ /** A session version graph-io cannot read: a major above 3, or the 2011 3.0 pre-release layout. */
48
+ VERSION: "E_CYS_VERSION",
49
+ /** A table or a virtual column that cannot be read at all; it is skipped. */
50
+ TABLE: "E_CYS_TABLE",
51
+ /** Table rows with too few or too many cells, a repeated key, or a key matching no element. */
52
+ TABLE_ROW: "W_CYS_TABLE_ROW",
53
+ /** A collapsed group's members are not in the network; they are recorded in meta.extra. */
54
+ COLLAPSED_GROUP: "W_CYS_COLLAPSED_GROUP",
55
+ /** Entries the importer does not read (apps, global tables, properties, images, thumbnails). */
56
+ ENTRY_SKIPPED: "W_CYS_ENTRY_SKIPPED",
57
+ /** Two entries with one name; the first is read. */
58
+ DUPLICATE_ENTRY: "W_CYS_DUPLICATE_ENTRY",
59
+ /** The archive inflates beyond maxUncompressedBytes, or an entry beyond the ratio limit. */
60
+ TOO_LARGE: TOO_LARGE_CODE,
61
+ /** The session's styles are not applied (issue #706). */
62
+ STYLES_NOT_IMPORTED: STYLES_NOT_IMPORTED_CODE,
63
+ /** A view, table or network the session names but does not hold. */
64
+ DANGLING_REFERENCE: DANGLING_REFERENCE_CODE,
65
+ /** The input is empty. */
66
+ EMPTY_INPUT: EMPTY_INPUT_CODE,
67
+ /** The session holds no network. */
68
+ NO_GRAPH: NO_GRAPH_CODE,
69
+ /** The session holds several networks; one was read. */
70
+ MULTIPLE_GRAPHS: MULTIPLE_GRAPHS_CODE,
71
+ /** graphIndex / graphName names no network (fatal). */
72
+ GRAPH_NOT_FOUND: GRAPH_NOT_FOUND_CODE,
73
+ /** graphName names several networks (fatal). */
74
+ AMBIGUOUS_GRAPH_NAME: AMBIGUOUS_GRAPH_NAME_CODE,
75
+ });
76
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/formats/cys/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,a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;IACnD,OAAO,EAAE,eAAe;IACxB,kGAAkG;IAClG,OAAO,EAAE,eAAe;IACxB,6EAA6E;IAC7E,WAAW,EAAE,mBAAmB;IAChC,mGAAmG;IACnG,WAAW,EAAE,mBAAmB;IAChC,mGAAmG;IACnG,OAAO,EAAE,eAAe;IACxB,6EAA6E;IAC7E,KAAK,EAAE,aAAa;IACpB,+FAA+F;IAC/F,SAAS,EAAE,iBAAiB;IAC5B,2FAA2F;IAC3F,eAAe,EAAE,uBAAuB;IACxC,gGAAgG;IAChG,aAAa,EAAE,qBAAqB;IACpC,oDAAoD;IACpD,eAAe,EAAE,uBAAuB;IACxC,4FAA4F;IAC5F,SAAS,EAAE,cAAc;IACzB,yDAAyD;IACzD,mBAAmB,EAAE,wBAAwB;IAC7C,oEAAoE;IACpE,kBAAkB,EAAE,uBAAuB;IAC3C,0BAA0B;IAC1B,WAAW,EAAE,gBAAgB;IAC7B,oCAAoC;IACpC,QAAQ,EAAE,aAAa;IACvB,wDAAwD;IACxD,eAAe,EAAE,oBAAoB;IACrC,uDAAuD;IACvD,eAAe,EAAE,oBAAoB;IACrC,gDAAgD;IAChD,oBAAoB,EAAE,yBAAyB;CAClD,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The Cytoscape session importer (design `design/graph-io/cytoscape-and-obo/design.md` sections
3
+ * 1.4 and 3; `research-session-and-style.md`). A session is a zip of every network of a Cytoscape
4
+ * desktop; the unit of import is the registered subnetwork (3.x) or the network (2.x), one
5
+ * snapshot each: `import()` reads the one `graphIndex` / `graphName` picks (the first by default),
6
+ * `importAll()` every one, and `listGraphs()` lists them from the network files alone.
7
+ *
8
+ * 3.x: the network file gives the topology (shared nodes through `xlink:href`, per-edge direction,
9
+ * groups, nested-network pointers); the subnetwork's CyCSV tables give its columns (LOCAL_ATTRS as
10
+ * they are, the SHARED_ATTRS columns `cytables.xml` joins in, HIDDEN and app tables as hidden
11
+ * columns under their namespace); its first view gives positions (y flipped) and the `graphics`
12
+ * column, further views `position@<n>` columns. 2.x: one full XGMML file per network, with
13
+ * selection and hidden state from `cysession.xml`. Everything is resolved by the XGMML emitter, so
14
+ * both readers share every column rule. Styles are not read (issue #706): W_STYLES_NOT_IMPORTED.
15
+ */
16
+ import { type GraphChoiceOptions, type GraphImporter } from "../../types.js";
17
+ /** The format-specific options of the session importer. */
18
+ export interface CysImportOptions extends GraphChoiceOptions {
19
+ /** Where Cytoscape's z (a stacking order) goes: the `z` column (default) or the position. */
20
+ zAs?: "column" | "position" | undefined;
21
+ /**
22
+ * The most bytes one import may inflate, in total (default 2 GiB); an entry beyond it, or one
23
+ * whose compression ratio is above 1000:1, is E_TOO_LARGE.
24
+ */
25
+ maxUncompressedBytes?: number | undefined;
26
+ }
27
+ /**
28
+ * Confidence that a head of bytes is a Cytoscape session: 0.95 for a zip whose head names the
29
+ * session folder, its version marker or cysession.xml; 0 for any other zip, so an `.xlsx`, a
30
+ * `.docx` or a zipped GraphML ranks as no format rather than as a broken session. The zip may
31
+ * start after a short stub (a self-extracting archive) within the head.
32
+ * @param head - the first bytes
33
+ * @returns the confidence
34
+ */
35
+ export declare function sniffCys(head: Uint8Array): number;
36
+ /** The Cytoscape session importer. */
37
+ export declare const cysImporter: GraphImporter<CysImportOptions>;
38
+ //# sourceMappingURL=importer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../../../../src/formats/cys/importer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH,OAAO,EAEH,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAKrB,MAAM,gBAAgB,CAAC;AA6CxB,2DAA2D;AAC3D,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;IACxD,6FAA6F;IAC7F,GAAG,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IACxC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C;AAo9BD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAOjD;AAED,sCAAsC;AACtC,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,gBAAgB,CAQtD,CAAC"}