xshell 1.2.30 → 1.2.31

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/fflate.d.ts ADDED
@@ -0,0 +1,359 @@
1
+ /** Codes for errors generated within this library */
2
+ export declare const FlateErrorCode: {
3
+ readonly UnexpectedEOF: 0;
4
+ readonly InvalidBlockType: 1;
5
+ readonly InvalidLengthLiteral: 2;
6
+ readonly InvalidDistance: 3;
7
+ readonly StreamFinished: 4;
8
+ readonly NoStreamHandler: 5;
9
+ readonly InvalidHeader: 6;
10
+ readonly NoCallback: 7;
11
+ readonly InvalidUTF8: 8;
12
+ readonly ExtraFieldTooLong: 9;
13
+ readonly InvalidDate: 10;
14
+ readonly FilenameTooLong: 11;
15
+ readonly StreamFinishing: 12;
16
+ readonly InvalidZipData: 13;
17
+ readonly UnknownCompressionMethod: 14;
18
+ };
19
+ /** An error generated within this library */
20
+ export interface FlateError extends Error {
21
+ /** The code associated with this error */
22
+ code: number;
23
+ }
24
+ /** Options for compressing data into a DEFLATE format */
25
+ export interface DeflateOptions {
26
+ /**
27
+ The level of compression to use, ranging from 0-9.
28
+
29
+ 0 will store the data without compression.
30
+ 1 is fastest but compresses the worst, 9 is slowest but compresses the best.
31
+ The default level is 6.
32
+
33
+ Typically, binary data benefits much more from higher values than text data.
34
+ In both cases, higher values usually take disproportionately longer than the reduction in final size that results.
35
+
36
+ For example, a 1 MB text file could:
37
+ - become 1.01 MB with level 0 in 1ms
38
+ - become 400 kB with level 1 in 10ms
39
+ - become 320 kB with level 9 in 100ms
40
+ */
41
+ level?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
42
+ /**
43
+ The memory level to use, ranging from 0-12. Increasing this increases speed and compression ratio at the cost of memory.
44
+
45
+ Note that this is exponential: while level 0 uses 4 kB, level 4 uses 64 kB, level 8 uses 1 MB, and level 12 uses 16 MB.
46
+ It is recommended not to lower the value below 4, since that tends to hurt performance.
47
+ In addition, values above 8 tend to help very little on most data and can even hurt performance.
48
+
49
+ The default value is automatically determined based on the size of the input data.
50
+ */
51
+ mem?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
52
+ }
53
+ /** Options for compressing data into a GZIP format */
54
+ export interface GzipOptions extends DeflateOptions {
55
+ /**
56
+ When the file was last modified. Defaults to the current time.
57
+ Set this to 0 to avoid revealing a modification date entirely.
58
+ */
59
+ mtime?: Date | string | number;
60
+ /**
61
+ The filename of the data. If the `gunzip` command is used to decompress the data, it will output a file
62
+ with this name instead of the name of the compressed file.
63
+ */
64
+ filename?: string;
65
+ }
66
+ /** Options for compressing data into a Zlib format */
67
+ export interface ZlibOptions extends DeflateOptions {
68
+ }
69
+ /**
70
+ Handler for data (de)compression streams
71
+ @param data The data output from the stream processor
72
+ @param final Whether this is the final block
73
+ */
74
+ export type FlateStreamHandler = (data: Uint8Array, final: boolean) => void;
75
+ /**
76
+ Callback for asynchronous (de)compression methods
77
+ @param err Any error that occurred
78
+ @param data The resulting data. Only present if `err` is null
79
+ */
80
+ export type FlateCallback = (err: FlateError | null, data: Uint8Array) => void;
81
+ /** Streaming DEFLATE compression */
82
+ export declare class Deflate {
83
+ /**
84
+ Creates a DEFLATE stream
85
+ @param opts The compression options
86
+ @param cb The callback to call whenever data is deflated
87
+ */
88
+ constructor(opts: DeflateOptions, cb?: FlateStreamHandler);
89
+ constructor(cb?: FlateStreamHandler);
90
+ private o;
91
+ private d;
92
+ /** The handler to call whenever data is available */
93
+ ondata: FlateStreamHandler;
94
+ private p;
95
+ /**
96
+ Pushes a chunk to be deflated
97
+ @param chunk The chunk to push
98
+ @param final Whether this is the last chunk
99
+ */
100
+ push(chunk: Uint8Array, final?: boolean): void;
101
+ }
102
+ /**
103
+ Expands DEFLATE data with no wrapper
104
+ @param data The data to decompress
105
+ @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
106
+ @returns The decompressed version of the data
107
+ */
108
+ export declare function inflateSync(data: Uint8Array, out?: Uint8Array): Uint8Array<ArrayBufferLike>;
109
+ /** Streaming GZIP compression */
110
+ export declare class Gzip {
111
+ private c;
112
+ private l;
113
+ private v;
114
+ private o;
115
+ /** The handler to call whenever data is available */
116
+ ondata: FlateStreamHandler;
117
+ /**
118
+ Creates a GZIP stream
119
+ @param opts The compression options
120
+ @param cb The callback to call whenever data is deflated
121
+ */
122
+ constructor(opts: GzipOptions, cb?: FlateStreamHandler);
123
+ /**
124
+ Creates a GZIP stream
125
+ @param cb The callback to call whenever data is deflated
126
+ */
127
+ constructor(cb?: FlateStreamHandler);
128
+ /**
129
+ Pushes a chunk to be GZIPped
130
+ @param chunk The chunk to push
131
+ @param final Whether this is the last chunk
132
+ */
133
+ push(chunk: Uint8Array, final?: boolean): void;
134
+ private p;
135
+ }
136
+ /**
137
+ Compresses data with GZIP
138
+ @param data The data to compress
139
+ @param opts The compression options
140
+ @returns The gzipped version of the data
141
+ */
142
+ export declare function gzipSync(data: Uint8Array, opts?: GzipOptions): Buffer<ArrayBuffer>;
143
+ /**
144
+ Expands GZIP data
145
+ @param data The data to decompress
146
+ @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
147
+ @returns The decompressed version of the data
148
+ */
149
+ export declare function gunzipSync(data: Uint8Array, out?: Uint8Array): Uint8Array<ArrayBufferLike>;
150
+ /** Streaming Zlib compression */
151
+ export declare class Zlib {
152
+ private c;
153
+ private v;
154
+ private o;
155
+ /** The handler to call whenever data is available */
156
+ ondata: FlateStreamHandler;
157
+ /**
158
+ Creates a Zlib stream
159
+ @param opts The compression options
160
+ @param cb The callback to call whenever data is deflated
161
+ */
162
+ constructor(opts: ZlibOptions, cb?: FlateStreamHandler);
163
+ /**
164
+ Creates a Zlib stream
165
+ @param cb The callback to call whenever data is deflated
166
+ */
167
+ constructor(cb?: FlateStreamHandler);
168
+ /**
169
+ Pushes a chunk to be zlibbed
170
+ @param chunk The chunk to push
171
+ @param final Whether this is the last chunk
172
+ */
173
+ push(chunk: Uint8Array, final?: boolean): void;
174
+ private p;
175
+ }
176
+ /**
177
+ Compress data with Zlib
178
+ @param data The data to compress
179
+ @param opts The compression options
180
+ @returns The zlib-compressed version of the data
181
+ */
182
+ export declare function zlibSync(data: Uint8Array, opts?: ZlibOptions): Buffer<ArrayBuffer>;
183
+ /**
184
+ Expands Zlib data
185
+ @param data The data to decompress
186
+ @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
187
+ @returns The decompressed version of the data
188
+ */
189
+ export declare function unzlibSync(data: Uint8Array, out?: Uint8Array): Uint8Array<ArrayBufferLike>;
190
+ /**
191
+ Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
192
+ @param data The data to decompress
193
+ @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
194
+ @returns The decompressed version of the data
195
+ */
196
+ export declare function decompressSync(data: Uint8Array, out?: Uint8Array): Uint8Array<ArrayBufferLike>;
197
+ /** Attributes for files added to a ZIP archive object */
198
+ export interface ZipAttributes {
199
+ /**
200
+ The operating system of origin for this file. The value is defined
201
+ by PKZIP's APPNOTE.txt, section 4.4.2.2. For example, 0 (the default)
202
+ is MS/DOS, 3 is Unix, 19 is macOS.
203
+ */
204
+ os?: number;
205
+ /**
206
+ The file's attributes. These are traditionally somewhat complicated
207
+ and platform-dependent, so using them is scarcely necessary. However,
208
+ here is a representation of what this is, bit by bit:
209
+
210
+ `TTTTugtrwxrwxrwx0000000000ADVSHR`
211
+
212
+ TTTT = file type (rarely useful)
213
+
214
+ u = setuid, g = setgid, t = sticky
215
+
216
+ rwx = user permissions, rwx = group permissions, rwx = other permissions
217
+
218
+ 0000000000 = unused
219
+
220
+ A = archive, D = directory, V = volume label, S = system file, H = hidden, R = read-only
221
+
222
+ If you want to set the Unix permissions, for instance, just bit shift by 16, e.g. 0o644 << 16.
223
+ Note that attributes usually only work in conjunction with the `os` setting: you must use
224
+ `os` = 3 (Unix) if you want to set Unix permissions
225
+ */
226
+ attrs?: number;
227
+ /**
228
+ Extra metadata to add to the file. This field is defined by PKZIP's APPNOTE.txt,
229
+ section 4.4.28. At most 65,535 bytes may be used in each ID. The ID must be an
230
+ integer between 0 and 65,535, inclusive.
231
+
232
+ This field is incredibly rare and almost never needed except for compliance with
233
+ proprietary standards and software.
234
+ */
235
+ extra?: Record<number, Uint8Array>;
236
+ /**
237
+ The comment to attach to the file. This field is defined by PKZIP's APPNOTE.txt,
238
+ section 4.4.26. The comment must be at most 65,535 bytes long UTF-8 encoded. This
239
+ field is not read by consumer software.
240
+ */
241
+ comment?: string;
242
+ /** When the file was last modified. Defaults to the current time. */
243
+ mtime?: GzipOptions['mtime'];
244
+ }
245
+ /** Options for creating a ZIP archive */
246
+ export interface ZipOptions extends DeflateOptions, ZipAttributes {
247
+ }
248
+ /** Options for expanding a ZIP archive */
249
+ export interface UnzipOptions {
250
+ /** A filter function to extract only certain files from a ZIP archive */
251
+ filter?: UnzipFileFilter;
252
+ decoder(buf: Uint8Array): string;
253
+ }
254
+ /** A file that can be used to create a ZIP archive */
255
+ export type ZippableFile = Uint8Array | Zippable | [Uint8Array | Zippable, ZipOptions];
256
+ /** The complete directory structure of a ZIPpable archive */
257
+ export interface Zippable {
258
+ [path: string]: ZippableFile;
259
+ }
260
+ /**
261
+ An unzipped archive. The full path of each file is used as the key,
262
+ and the file is the value
263
+ */
264
+ export interface Unzipped {
265
+ [path: string]: Uint8Array;
266
+ }
267
+ /**
268
+ Handler for string generation streams
269
+ @param data The string output from the stream processor
270
+ @param final Whether this is the final block
271
+ */
272
+ export type StringStreamHandler = (data: string, final: boolean) => void;
273
+ /**
274
+ Callback for asynchronous ZIP decompression
275
+ @param err Any error that occurred
276
+ @param data The decompressed ZIP archive
277
+ */
278
+ export type UnzipCallback = (err: FlateError | null, data: Unzipped) => void;
279
+ /** Streaming UTF-8 decoding */
280
+ export declare class DecodeUTF8 {
281
+ private p;
282
+ private t;
283
+ /**
284
+ Creates a UTF-8 decoding stream
285
+ @param cb The callback to call whenever data is decoded
286
+ */
287
+ constructor(cb?: StringStreamHandler);
288
+ /**
289
+ Pushes a chunk to be decoded from UTF-8 binary
290
+ @param chunk The chunk to push
291
+ @param final Whether this is the last chunk
292
+ */
293
+ push(chunk: Uint8Array, final?: boolean): void;
294
+ /** The handler to call whenever data is available */
295
+ ondata: StringStreamHandler;
296
+ }
297
+ /** Streaming UTF-8 encoding */
298
+ export declare class EncodeUTF8 {
299
+ private d;
300
+ /**
301
+ Creates a UTF-8 decoding stream
302
+ @param cb The callback to call whenever data is encoded
303
+ */
304
+ constructor(cb?: FlateStreamHandler);
305
+ /**
306
+ Pushes a chunk to be encoded to UTF-8
307
+ @param chunk The string data to push
308
+ @param final Whether this is the last chunk
309
+ */
310
+ push(chunk: string, final?: boolean): void;
311
+ /** The handler to call whenever data is available */
312
+ ondata: FlateStreamHandler;
313
+ }
314
+ /**
315
+ Converts a string into a Uint8Array for use with compression/decompression methods
316
+ @param str The string to encode
317
+ @param latin1 Whether or not to interpret the data as Latin-1. This should
318
+ not need to be true unless decoding a binary string.
319
+ @returns The string encoded in UTF-8/Latin-1 binary
320
+ */
321
+ export declare function strToU8(str: string, latin1?: boolean): Uint8Array;
322
+ /**
323
+ Converts a Uint8Array to a string
324
+ @param dat The data to decode to string
325
+ @param latin1 Whether or not to interpret the data as Latin-1. This should
326
+ not need to be true unless encoding to binary string.
327
+ @returns The original UTF-8/Latin-1 string
328
+ */
329
+ export declare function strFromU8(dat: Uint8Array, decoder: UnzipOptions['decoder']): string;
330
+ /** Information about a file to be extracted from a ZIP archive */
331
+ export interface UnzipFileInfo {
332
+ /** The name of the file */
333
+ name: string;
334
+ /** The compressed size of the file */
335
+ size: number;
336
+ /** The original size of the file */
337
+ originalSize: number;
338
+ /**
339
+ The compression format for the data stream. This number is determined by
340
+ the spec in PKZIP's APPNOTE.txt, section 4.4.5. For example, 0 = no
341
+ compression, 8 = deflate, 14 = LZMA. If the filter function returns true
342
+ but this value is not 8, the unzip function will throw.
343
+ */
344
+ compression: number;
345
+ }
346
+ /**
347
+ A filter for files to be extracted during the unzipping process
348
+ @param file The info for the current file being processed
349
+ @returns Whether or not to extract the current file
350
+ */
351
+ export type UnzipFileFilter = (file: UnzipFileInfo) => boolean;
352
+ /**
353
+ Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
354
+ performance with more than one file.
355
+ @param data The raw compressed ZIP file
356
+ @param opts The ZIP extraction options
357
+ @returns The decompressed files
358
+ */
359
+ export declare function unzipSync(data: Uint8Array, opts: UnzipOptions): Unzipped;