unicode-input-toolconverter 0.2.0 → 0.2.3

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 (143) hide show
  1. package/.nyc_output/out.json +8980 -1849
  2. package/CHANGES.md +15 -1
  3. package/README.md +6 -11
  4. package/_locales/en-US/messages.json +153 -6
  5. package/_locales/hu-HU/messages.json +153 -6
  6. package/_locales/pt-BR/messages.json +153 -6
  7. package/_locales/sv-SE/messages.json +153 -6
  8. package/babel.config.json +0 -1
  9. package/browser_action/characterSelection.js +18 -11
  10. package/browser_action/charrefConverters.js +286 -79
  11. package/browser_action/chartBuild.js +97 -27
  12. package/browser_action/encodingBehaviors.js +10 -7
  13. package/browser_action/entityBehaviors.js +42 -16
  14. package/browser_action/index-es.html +13 -1
  15. package/browser_action/index-instrumented.html +13 -1
  16. package/browser_action/index-pages.html +13 -1
  17. package/browser_action/index.html +13 -1
  18. package/browser_action/index.iife.min.js +9 -1
  19. package/browser_action/index.iife.min.js.map +1 -1
  20. package/browser_action/index.instrumented.iife.min.js +1 -1
  21. package/browser_action/index.instrumented.iife.min.js.map +1 -1
  22. package/browser_action/index.js +5 -5
  23. package/browser_action/preferences/prefDefaults.js +12 -3
  24. package/browser_action/service-worker/sw-activateCallback.js +1 -2
  25. package/browser_action/service-worker/sw-resources.json +6 -4
  26. package/browser_action/templateUtils/elements.js +12 -1
  27. package/browser_action/templateUtils/fill.js +6 -0
  28. package/browser_action/templateUtils/validation.js +4 -1
  29. package/browser_action/templates/chartBuild.js +167 -102
  30. package/browser_action/templates/index.js +227 -53
  31. package/browser_action/templatesElementCustomization/widgets.js +40 -15
  32. package/browser_action/unicode/UnicodeConverter.js +99 -73
  33. package/browser_action/unicode/charrefunicodeDb.js +100 -50
  34. package/browser_action/unicode/getScriptInfoForCodePoint.js +13 -4
  35. package/browser_action/unicode/hangul.js +27 -20
  36. package/browser_action/unicode/lastScriptNames.json +1 -1
  37. package/browser_action/unicode/parseUnihanFromTextFileStrings.js +44 -25
  38. package/browser_action/unicode/unicodeFieldInfo.js +112 -90
  39. package/browser_action/unicode/unicodeScripts.js +409 -35
  40. package/browser_action/unicode/unihan.js +4 -3
  41. package/browser_action/unicode/unihanDbPopulate.js +7 -2
  42. package/browser_action/unicode/unihanFields.js +34 -0
  43. package/browser_action/unicodecharref.js +353 -190
  44. package/browser_action/utils/DOMUtils.js +95 -34
  45. package/browser_action/utils/FetchUtils.js +7 -6
  46. package/browser_action/utils/TextUtils.js +4 -4
  47. package/browser_action/utils/TypedArrayUtils.js +9 -5
  48. package/browser_action/utils/semicolonSeparatedToArray.js +3 -3
  49. package/browser_action/utils/setupServiceWorker.js +2 -2
  50. package/eslint.config.js +11 -0
  51. package/icons/openWindow16.png +0 -0
  52. package/icons/openWindow24.png +0 -0
  53. package/lib/background.html +7 -0
  54. package/lib/background.js +2 -2
  55. package/package.json +80 -70
  56. package/pnpm-workspace.yaml +8 -0
  57. package/server.js +66 -51
  58. package/sw.js +97 -56
  59. package/tools/entities-import.js +4 -1
  60. package/tools/findEsResources.js +33 -10
  61. package/tools/fix-sw-resources-vendor-paths.js +60 -0
  62. package/tools/list-locales.js +2 -2
  63. package/tools/parseUnicodeCharts.js +126 -60
  64. package/tools/ucd-import.js +1 -10
  65. package/tools/unicode-charts.html +49 -20
  66. package/tools/unihan-import.js +45 -15
  67. package/tools/write-sw-version.js +16 -0
  68. package/tsconfig.json +23 -0
  69. package/typings/__coverage__.d.ts +5 -0
  70. package/typings/apple-system-profiler.d.ts +17 -0
  71. package/typings/commands.d.ts +19 -0
  72. package/typings/json-6.d.ts +4 -0
  73. package/typings/rollup-plugin-istanbul.d.ts +3 -0
  74. package/vendor/camelcase/index.d.ts +154 -0
  75. package/vendor/camelcase/index.js +137 -23
  76. package/vendor/fflate/esm/browser.d.ts +1539 -0
  77. package/vendor/fflate/esm/browser.js +82 -55
  78. package/vendor/intl-dom/dist/Formatter.d.ts +120 -0
  79. package/vendor/intl-dom/dist/Formatter.d.ts.map +1 -0
  80. package/vendor/intl-dom/dist/collation.d.ts +42 -0
  81. package/vendor/intl-dom/dist/collation.d.ts.map +1 -0
  82. package/vendor/intl-dom/dist/defaultAllSubstitutions.d.ts +52 -0
  83. package/vendor/intl-dom/dist/defaultAllSubstitutions.d.ts.map +1 -0
  84. package/vendor/intl-dom/dist/defaultInsertNodes.d.ts +96 -0
  85. package/vendor/intl-dom/dist/defaultInsertNodes.d.ts.map +1 -0
  86. package/vendor/intl-dom/dist/defaultKeyCheckerConverter.d.ts +17 -0
  87. package/vendor/intl-dom/dist/defaultKeyCheckerConverter.d.ts.map +1 -0
  88. package/vendor/intl-dom/dist/defaultLocaleResolver.d.ts +285 -0
  89. package/vendor/intl-dom/dist/defaultLocaleResolver.d.ts.map +1 -0
  90. package/vendor/intl-dom/dist/findLocaleStrings.d.ts +88 -0
  91. package/vendor/intl-dom/dist/findLocaleStrings.d.ts.map +1 -0
  92. package/vendor/intl-dom/dist/getDOMForLocaleString.d.ts +67 -0
  93. package/vendor/intl-dom/dist/getDOMForLocaleString.d.ts.map +1 -0
  94. package/vendor/intl-dom/dist/getMessageForKeyByStyle.d.ts +73 -0
  95. package/vendor/intl-dom/dist/getMessageForKeyByStyle.d.ts.map +1 -0
  96. package/vendor/intl-dom/dist/getStringFromMessageAndDefaults.d.ts +26 -0
  97. package/vendor/intl-dom/dist/getStringFromMessageAndDefaults.d.ts.map +1 -0
  98. package/vendor/intl-dom/dist/i18n.d.ts +113 -0
  99. package/vendor/intl-dom/dist/i18n.d.ts.map +1 -0
  100. package/vendor/intl-dom/dist/index.d.ts +92 -0
  101. package/vendor/intl-dom/dist/index.d.ts.map +1 -0
  102. package/vendor/intl-dom/dist/index.esm.d.ts +34 -0
  103. package/vendor/intl-dom/dist/index.esm.js +854 -896
  104. package/vendor/intl-dom/dist/index.esm.min.js +4 -0
  105. package/vendor/intl-dom/dist/index.esm.min.js.map +1 -0
  106. package/vendor/intl-dom/dist/index.umd.js +2953 -0
  107. package/vendor/intl-dom/dist/index.umd.min.js +4 -0
  108. package/vendor/intl-dom/dist/index.umd.min.js.map +1 -0
  109. package/vendor/intl-dom/dist/promiseChainForValues.d.ts +34 -0
  110. package/vendor/intl-dom/dist/promiseChainForValues.d.ts.map +1 -0
  111. package/vendor/intl-dom/dist/shared.d.ts +20 -0
  112. package/vendor/intl-dom/dist/shared.d.ts.map +1 -0
  113. package/vendor/intl-dom/dist/utils.d.ts +53 -0
  114. package/vendor/intl-dom/dist/utils.d.ts.map +1 -0
  115. package/vendor/jamilih/dist/jml.d.mts +468 -0
  116. package/vendor/jamilih/dist/{jml-es.js → jml.mjs} +1489 -343
  117. package/vendor/jquery/dist/jquery.js +1677 -2713
  118. package/vendor/json-6/dist/index.mjs +2 -0
  119. package/vendor/miller-columns/CHANGES.md +185 -0
  120. package/vendor/miller-columns/LICENSE-MIT.txt +21 -0
  121. package/vendor/miller-columns/README.md +249 -0
  122. package/vendor/miller-columns/demos/index.html +69 -0
  123. package/vendor/miller-columns/demos/index.js +72 -0
  124. package/vendor/miller-columns/dist/index-es.js +748 -0
  125. package/vendor/miller-columns/dist/index-es.min.d.ts +25 -0
  126. package/vendor/miller-columns/dist/index-es.min.js +7 -1
  127. package/vendor/miller-columns/dist/index-umd.js +757 -0
  128. package/vendor/miller-columns/dist/index-umd.min.js +7 -0
  129. package/vendor/miller-columns/dist/index.d.ts +25 -0
  130. package/vendor/miller-columns/dist/millerColumns.d.ts +10 -0
  131. package/vendor/miller-columns/eslint.config.js +46 -0
  132. package/vendor/miller-columns/fix-declarations.js +18 -0
  133. package/vendor/miller-columns/miller-columns.css +24 -1
  134. package/vendor/miller-columns/package.json +73 -0
  135. package/vendor/miller-columns/pnpm-workspace.yaml +2 -0
  136. package/vendor/miller-columns/src/index.js +642 -0
  137. package/vendor/miller-columns/src/millerColumns.ts +12 -0
  138. package/vendor/miller-columns/tsconfig-prod.json +23 -0
  139. package/vendor/miller-columns/tsconfig.json +21 -0
  140. package/vendor/simple-prefs/dist/index.esm.d.ts +1 -0
  141. package/vendor/simple-prefs/dist/index.esm.js +164 -216
  142. package/vendor/simple-prefs/dist/simple-prefs.d.ts +117 -0
  143. package/lgtm.yml +0 -5
@@ -0,0 +1,1539 @@
1
+ /**
2
+ * Codes for errors generated within this library
3
+ */
4
+ export declare const FlateErrorCode: {
5
+ readonly UnexpectedEOF: 0;
6
+ readonly InvalidBlockType: 1;
7
+ readonly InvalidLengthLiteral: 2;
8
+ readonly InvalidDistance: 3;
9
+ readonly StreamFinished: 4;
10
+ readonly NoStreamHandler: 5;
11
+ readonly InvalidHeader: 6;
12
+ readonly NoCallback: 7;
13
+ readonly InvalidUTF8: 8;
14
+ readonly ExtraFieldTooLong: 9;
15
+ readonly InvalidDate: 10;
16
+ readonly FilenameTooLong: 11;
17
+ readonly StreamFinishing: 12;
18
+ readonly InvalidZipData: 13;
19
+ readonly UnknownCompressionMethod: 14;
20
+ };
21
+ /**
22
+ * An error generated within this library
23
+ */
24
+ export interface FlateError extends Error {
25
+ /**
26
+ * The code associated with this error
27
+ */
28
+ code: number;
29
+ }
30
+ /**
31
+ * Options for decompressing a DEFLATE stream
32
+ */
33
+ export interface InflateStreamOptions {
34
+ /**
35
+ * The dictionary used to compress the original data. If no dictionary was used during compression, this option has no effect.
36
+ *
37
+ * Supplying the wrong dictionary during decompression usually yields corrupt output or causes an invalid distance error.
38
+ */
39
+ dictionary?: Uint8Array;
40
+ }
41
+ /**
42
+ * Options for decompressing DEFLATE data
43
+ */
44
+ export interface InflateOptions<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends InflateStreamOptions {
45
+ /**
46
+ * The buffer into which to write the decompressed data. Saves memory if you know the decompressed size in advance.
47
+ *
48
+ * Note that if the decompression result is larger than the size of this buffer, it will be truncated to fit.
49
+ */
50
+ out?: Uint8Array<TArrayBuffer>;
51
+ }
52
+ /**
53
+ * Options for decompressing a GZIP stream
54
+ */
55
+ export interface GunzipStreamOptions extends InflateStreamOptions {
56
+ }
57
+ /**
58
+ * Options for decompressing GZIP data
59
+ */
60
+ export interface GunzipOptions<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends InflateStreamOptions {
61
+ /**
62
+ * The buffer into which to write the decompressed data. GZIP already encodes the output size, so providing this doesn't save memory.
63
+ *
64
+ * Note that if the decompression result is larger than the size of this buffer, it will be truncated to fit.
65
+ */
66
+ out?: Uint8Array<TArrayBuffer>;
67
+ }
68
+ /**
69
+ * Options for decompressing a Zlib stream
70
+ */
71
+ export interface UnzlibStreamOptions extends InflateStreamOptions {
72
+ }
73
+ /**
74
+ * Options for decompressing Zlib data
75
+ */
76
+ export interface UnzlibOptions<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends InflateOptions<TArrayBuffer> {
77
+ }
78
+ /**
79
+ * Options for compressing data into a DEFLATE format
80
+ */
81
+ export interface DeflateOptions {
82
+ /**
83
+ * The level of compression to use, ranging from 0-9.
84
+ *
85
+ * 0 will store the data without compression.
86
+ * 1 is fastest but compresses the worst, 9 is slowest but compresses the best.
87
+ * The default level is 6.
88
+ *
89
+ * Typically, binary data benefits much more from higher values than text data.
90
+ * In both cases, higher values usually take disproportionately longer than the reduction in final size that results.
91
+ *
92
+ * For example, a 1 MB text file could:
93
+ * - become 1.01 MB with level 0 in 1ms
94
+ * - become 400 kB with level 1 in 10ms
95
+ * - become 320 kB with level 9 in 100ms
96
+ */
97
+ level?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
98
+ /**
99
+ * The memory level to use, ranging from 0-12. Increasing this increases speed and compression ratio at the cost of memory.
100
+ *
101
+ * Note that this is exponential: while level 0 uses 8 kB, level 4 uses 128 kB, level 8 uses 2 MB, and level 12 uses 32 MB.
102
+ * It is recommended not to lower the value below 4, since that tends to hurt performance.
103
+ * In addition, values above 8 tend to help very little on most data and can even hurt performance.
104
+ *
105
+ * The default value is automatically determined based on the size of the input data.
106
+ */
107
+ mem?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
108
+ /**
109
+ * A buffer containing common byte sequences in the input data that can be used to significantly improve compression ratios.
110
+ *
111
+ * Dictionaries should be 32kB or smaller and include strings or byte sequences likely to appear in the input.
112
+ * The decompressor must supply the same dictionary as the compressor to extract the original data.
113
+ *
114
+ * Dictionaries only improve aggregate compression ratio when reused across multiple small inputs. They should typically not be used otherwise.
115
+ *
116
+ * Avoid using dictionaries with GZIP and ZIP to maximize software compatibility.
117
+ */
118
+ dictionary?: Uint8Array;
119
+ }
120
+ /**
121
+ * Options for compressing data into a GZIP format
122
+ */
123
+ export interface GzipOptions extends DeflateOptions {
124
+ /**
125
+ * When the file was last modified. Defaults to the current time.
126
+ * Set this to 0 to avoid revealing a modification date entirely.
127
+ */
128
+ mtime?: Date | string | number;
129
+ /**
130
+ * The filename of the data. If the `gunzip` command is used to decompress the data, it will output a file
131
+ * with this name instead of the name of the compressed file.
132
+ */
133
+ filename?: string;
134
+ }
135
+ /**
136
+ * Options for compressing data into a Zlib format
137
+ */
138
+ export interface ZlibOptions extends DeflateOptions {
139
+ }
140
+ /**
141
+ * Handler for data (de)compression streams
142
+ * @param data The data output from the stream processor
143
+ * @param final Whether this is the final block
144
+ */
145
+ export type FlateStreamHandler = (data: Uint8Array<ArrayBuffer>, final: boolean) => void;
146
+ /**
147
+ * Handler for asynchronous data (de)compression streams
148
+ * @param err Any error that occurred
149
+ * @param data The data output from the stream processor
150
+ * @param final Whether this is the final block
151
+ */
152
+ export type AsyncFlateStreamHandler = (err: FlateError | null, data: Uint8Array<ArrayBuffer>, final: boolean) => void;
153
+ /**
154
+ * Handler for the asynchronous completion of (de)compression for a data chunk
155
+ * @param size The number of bytes that were processed. This is measured in terms of the input
156
+ * (i.e. compressed bytes for decompression, uncompressed bytes for compression.)
157
+ */
158
+ export type AsyncFlateDrainHandler = (size: number) => void;
159
+ /**
160
+ * Callback for asynchronous (de)compression methods
161
+ * @param err Any error that occurred
162
+ * @param data The resulting data. Only present if `err` is null
163
+ */
164
+ export type FlateCallback = (err: FlateError | null, data: Uint8Array<ArrayBuffer>) => void;
165
+ interface AsyncOptions {
166
+ /**
167
+ * Whether or not to "consume" the source data. This will make the typed array/buffer you pass in
168
+ * unusable but will increase performance and reduce memory usage.
169
+ */
170
+ consume?: boolean;
171
+ }
172
+ /**
173
+ * Options for compressing data asynchronously into a DEFLATE format
174
+ */
175
+ export interface AsyncDeflateOptions extends DeflateOptions, AsyncOptions {
176
+ }
177
+ /**
178
+ * Options for decompressing DEFLATE data asynchronously
179
+ */
180
+ export interface AsyncInflateOptions extends AsyncOptions, InflateStreamOptions {
181
+ /**
182
+ * The original size of the data. Currently, the asynchronous API disallows
183
+ * writing into a buffer you provide; the best you can do is provide the
184
+ * size in bytes and be given back a new typed array.
185
+ */
186
+ size?: number;
187
+ }
188
+ /**
189
+ * Options for compressing data asynchronously into a GZIP format
190
+ */
191
+ export interface AsyncGzipOptions extends GzipOptions, AsyncOptions {
192
+ }
193
+ /**
194
+ * Options for decompressing GZIP data asynchronously
195
+ */
196
+ export interface AsyncGunzipOptions extends AsyncOptions, InflateStreamOptions {
197
+ }
198
+ /**
199
+ * Options for compressing data asynchronously into a Zlib format
200
+ */
201
+ export interface AsyncZlibOptions extends ZlibOptions, AsyncOptions {
202
+ }
203
+ /**
204
+ * Options for decompressing Zlib data asynchronously
205
+ */
206
+ export interface AsyncUnzlibOptions extends AsyncInflateOptions {
207
+ }
208
+ /**
209
+ * A terminable compression/decompression process
210
+ */
211
+ export interface AsyncTerminable {
212
+ /**
213
+ * Terminates the worker thread immediately. The callback will not be called.
214
+ */
215
+ (): void;
216
+ }
217
+ /**
218
+ * Streaming DEFLATE compression
219
+ */
220
+ export declare class Deflate {
221
+ /**
222
+ * Creates a DEFLATE stream
223
+ * @param opts The compression options
224
+ * @param cb The callback to call whenever data is deflated
225
+ */
226
+ constructor(opts: DeflateOptions, cb?: FlateStreamHandler);
227
+ /**
228
+ * Creates a DEFLATE stream
229
+ * @param cb The callback to call whenever data is deflated
230
+ */
231
+ constructor(cb?: FlateStreamHandler);
232
+ private b;
233
+ private s;
234
+ private o;
235
+ /**
236
+ * The handler to call whenever data is available
237
+ */
238
+ ondata: FlateStreamHandler;
239
+ private p;
240
+ /**
241
+ * Pushes a chunk to be deflated
242
+ * @param chunk The chunk to push
243
+ * @param final Whether this is the last chunk
244
+ */
245
+ push(chunk: Uint8Array, final?: boolean): void;
246
+ /**
247
+ * Flushes buffered uncompressed data. Useful to immediately retrieve the
248
+ * deflated output for small inputs.
249
+ * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5
250
+ * extra bytes, but guarantees all pushed data is immediately
251
+ * decompressible. A separate DEFLATE stream may be concatenated
252
+ * with the current output after a sync flush.
253
+ */
254
+ flush(sync?: boolean): void;
255
+ }
256
+ /**
257
+ * Asynchronous streaming DEFLATE compression
258
+ */
259
+ export declare class AsyncDeflate {
260
+ /**
261
+ * The handler to call whenever data is available
262
+ */
263
+ ondata: AsyncFlateStreamHandler;
264
+ /**
265
+ * The handler to call whenever buffered source data is processed (i.e. `queuedSize` updates)
266
+ */
267
+ ondrain?: AsyncFlateDrainHandler;
268
+ /**
269
+ * The number of uncompressed bytes buffered in the stream
270
+ */
271
+ queuedSize: number;
272
+ /**
273
+ * Creates an asynchronous DEFLATE stream
274
+ * @param opts The compression options
275
+ * @param cb The callback to call whenever data is deflated
276
+ */
277
+ constructor(opts: DeflateOptions, cb?: AsyncFlateStreamHandler);
278
+ /**
279
+ * Creates an asynchronous DEFLATE stream
280
+ * @param cb The callback to call whenever data is deflated
281
+ */
282
+ constructor(cb?: AsyncFlateStreamHandler);
283
+ /**
284
+ * Pushes a chunk to be deflated
285
+ * @param chunk The chunk to push
286
+ * @param final Whether this is the last chunk
287
+ */
288
+ push(chunk: Uint8Array, final?: boolean): void;
289
+ /**
290
+ * Flushes buffered uncompressed data. Useful to immediately retrieve the
291
+ * deflated output for small inputs.
292
+ * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5
293
+ * extra bytes, but guarantees all pushed data is immediately
294
+ * decompressible. A separate DEFLATE stream may be concatenated
295
+ * with the current output after a sync flush.
296
+ */
297
+ flush(sync?: boolean): void;
298
+ /**
299
+ * A method to terminate the stream's internal worker. Subsequent calls to
300
+ * push() will silently fail.
301
+ */
302
+ terminate: AsyncTerminable;
303
+ }
304
+ /**
305
+ * Asynchronously compresses data with DEFLATE without any wrapper
306
+ * @param data The data to compress
307
+ * @param opts The compression options
308
+ * @param cb The function to be called upon compression completion
309
+ * @returns A function that can be used to immediately terminate the compression
310
+ */
311
+ export declare function deflate(data: Uint8Array, opts: AsyncDeflateOptions, cb: FlateCallback): AsyncTerminable;
312
+ /**
313
+ * Asynchronously compresses data with DEFLATE without any wrapper
314
+ * @param data The data to compress
315
+ * @param cb The function to be called upon compression completion
316
+ */
317
+ export declare function deflate(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
318
+ /**
319
+ * Compresses data with DEFLATE without any wrapper
320
+ * @param data The data to compress
321
+ * @param opts The compression options
322
+ * @returns The deflated version of the data
323
+ */
324
+ export declare function deflateSync(data: Uint8Array, opts?: DeflateOptions): Uint8Array<ArrayBuffer>;
325
+ /**
326
+ * Streaming DEFLATE decompression
327
+ */
328
+ export declare class Inflate {
329
+ private s;
330
+ private o;
331
+ private p;
332
+ private d;
333
+ /**
334
+ * The handler to call whenever data is available
335
+ */
336
+ ondata: FlateStreamHandler;
337
+ /**
338
+ * Creates a DEFLATE decompression stream
339
+ * @param opts The decompression options
340
+ * @param cb The callback to call whenever data is inflated
341
+ */
342
+ constructor(opts: InflateStreamOptions, cb?: FlateStreamHandler);
343
+ /**
344
+ * Creates a DEFLATE decompression stream
345
+ * @param cb The callback to call whenever data is inflated
346
+ */
347
+ constructor(cb?: FlateStreamHandler);
348
+ private e;
349
+ private c;
350
+ /**
351
+ * Pushes a chunk to be inflated
352
+ * @param chunk The chunk to push
353
+ * @param final Whether this is the final chunk
354
+ */
355
+ push(chunk: Uint8Array, final?: boolean): void;
356
+ }
357
+ /**
358
+ * Asynchronous streaming DEFLATE decompression
359
+ */
360
+ export declare class AsyncInflate {
361
+ /**
362
+ * The handler to call whenever data is available
363
+ */
364
+ ondata: AsyncFlateStreamHandler;
365
+ /**
366
+ * The handler to call whenever buffered source data is processed (i.e. `queuedSize` updates)
367
+ */
368
+ ondrain?: AsyncFlateDrainHandler;
369
+ /**
370
+ * The number of compressed bytes buffered in the stream
371
+ */
372
+ queuedSize: number;
373
+ /**
374
+ * Creates an asynchronous DEFLATE decompression stream
375
+ * @param opts The decompression options
376
+ * @param cb The callback to call whenever data is inflated
377
+ */
378
+ constructor(opts: InflateStreamOptions, cb?: AsyncFlateStreamHandler);
379
+ /**
380
+ * Creates an asynchronous DEFLATE decompression stream
381
+ * @param cb The callback to call whenever data is inflated
382
+ */
383
+ constructor(cb?: AsyncFlateStreamHandler);
384
+ /**
385
+ * Pushes a chunk to be inflated
386
+ * @param chunk The chunk to push
387
+ * @param final Whether this is the last chunk
388
+ */
389
+ push(chunk: Uint8Array, final?: boolean): void;
390
+ /**
391
+ * A method to terminate the stream's internal worker. Subsequent calls to
392
+ * push() will silently fail.
393
+ */
394
+ terminate: AsyncTerminable;
395
+ }
396
+ /**
397
+ * Asynchronously expands DEFLATE data with no wrapper
398
+ * @param data The data to decompress
399
+ * @param opts The decompression options
400
+ * @param cb The function to be called upon decompression completion
401
+ * @returns A function that can be used to immediately terminate the decompression
402
+ */
403
+ export declare function inflate(data: Uint8Array, opts: AsyncInflateOptions, cb: FlateCallback): AsyncTerminable;
404
+ /**
405
+ * Asynchronously expands DEFLATE data with no wrapper
406
+ * @param data The data to decompress
407
+ * @param cb The function to be called upon decompression completion
408
+ * @returns A function that can be used to immediately terminate the decompression
409
+ */
410
+ export declare function inflate(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
411
+ /**
412
+ * Expands DEFLATE data with no wrapper
413
+ * @param data The data to decompress
414
+ * @returns The decompressed version of the data
415
+ */
416
+ export declare function inflateSync(data: Uint8Array): Uint8Array<ArrayBuffer>;
417
+ /**
418
+ * Expands DEFLATE data with no wrapper
419
+ * @param data The data to decompress
420
+ * @param opts The decompression options
421
+ * @returns The decompressed version of the data
422
+ */
423
+ export declare function inflateSync<TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(data: Uint8Array, opts?: InflateOptions<TArrayBuffer>): Uint8Array<TArrayBuffer>;
424
+ /**
425
+ * Streaming GZIP compression
426
+ */
427
+ export declare class Gzip {
428
+ private c;
429
+ private l;
430
+ private v;
431
+ private o;
432
+ private s;
433
+ /**
434
+ * The handler to call whenever data is available
435
+ */
436
+ ondata: FlateStreamHandler;
437
+ /**
438
+ * Creates a GZIP stream
439
+ * @param opts The compression options
440
+ * @param cb The callback to call whenever data is deflated
441
+ */
442
+ constructor(opts: GzipOptions, cb?: FlateStreamHandler);
443
+ /**
444
+ * Creates a GZIP stream
445
+ * @param cb The callback to call whenever data is deflated
446
+ */
447
+ constructor(cb?: FlateStreamHandler);
448
+ /**
449
+ * Pushes a chunk to be GZIPped
450
+ * @param chunk The chunk to push
451
+ * @param final Whether this is the last chunk
452
+ */
453
+ push(chunk: Uint8Array, final?: boolean): void;
454
+ private p;
455
+ /**
456
+ * Flushes buffered uncompressed data. Useful to immediately retrieve the
457
+ * GZIPped output for small inputs.
458
+ * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5
459
+ * extra bytes, but guarantees all pushed data is immediately
460
+ * decompressible.
461
+ */
462
+ flush(sync?: boolean): void;
463
+ }
464
+ /**
465
+ * Asynchronous streaming GZIP compression
466
+ */
467
+ export declare class AsyncGzip {
468
+ /**
469
+ * The handler to call whenever data is available
470
+ */
471
+ ondata: AsyncFlateStreamHandler;
472
+ /**
473
+ * The handler to call whenever buffered source data is processed (i.e. `queuedSize` updates)
474
+ */
475
+ ondrain?: AsyncFlateDrainHandler;
476
+ /**
477
+ * The number of uncompressed bytes buffered in the stream
478
+ */
479
+ queuedSize: number;
480
+ /**
481
+ * Creates an asynchronous GZIP stream
482
+ * @param opts The compression options
483
+ * @param cb The callback to call whenever data is deflated
484
+ */
485
+ constructor(opts: GzipOptions, cb?: AsyncFlateStreamHandler);
486
+ /**
487
+ * Creates an asynchronous GZIP stream
488
+ * @param cb The callback to call whenever data is deflated
489
+ */
490
+ constructor(cb?: AsyncFlateStreamHandler);
491
+ /**
492
+ * Pushes a chunk to be GZIPped
493
+ * @param chunk The chunk to push
494
+ * @param final Whether this is the last chunk
495
+ */
496
+ push(chunk: Uint8Array, final?: boolean): void;
497
+ /**
498
+ * Flushes buffered uncompressed data. Useful to immediately retrieve the
499
+ * GZIPped output for small inputs.
500
+ * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5
501
+ * extra bytes, but guarantees all pushed data is immediately
502
+ * decompressible.
503
+ */
504
+ flush(sync?: boolean): void;
505
+ /**
506
+ * A method to terminate the stream's internal worker. Subsequent calls to
507
+ * push() will silently fail.
508
+ */
509
+ terminate: AsyncTerminable;
510
+ }
511
+ /**
512
+ * Asynchronously compresses data with GZIP
513
+ * @param data The data to compress
514
+ * @param opts The compression options
515
+ * @param cb The function to be called upon compression completion
516
+ * @returns A function that can be used to immediately terminate the compression
517
+ */
518
+ export declare function gzip(data: Uint8Array, opts: AsyncGzipOptions, cb: FlateCallback): AsyncTerminable;
519
+ /**
520
+ * Asynchronously compresses data with GZIP
521
+ * @param data The data to compress
522
+ * @param cb The function to be called upon compression completion
523
+ * @returns A function that can be used to immediately terminate the decompression
524
+ */
525
+ export declare function gzip(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
526
+ /**
527
+ * Compresses data with GZIP
528
+ * @param data The data to compress
529
+ * @param opts The compression options
530
+ * @returns The gzipped version of the data
531
+ */
532
+ export declare function gzipSync(data: Uint8Array, opts?: GzipOptions): Uint8Array<ArrayBuffer>;
533
+ /**
534
+ * Handler for new GZIP members in concatenated GZIP streams. Useful for building indices used to perform random-access reads on compressed files.
535
+ * @param offset The offset of the new member relative to the start of the stream
536
+ */
537
+ export type GunzipMemberHandler = (offset: number) => void;
538
+ /**
539
+ * Streaming single or multi-member GZIP decompression
540
+ */
541
+ export declare class Gunzip {
542
+ private v;
543
+ private r;
544
+ private o;
545
+ private p;
546
+ private s;
547
+ /**
548
+ * The handler to call whenever data is available
549
+ */
550
+ ondata: FlateStreamHandler;
551
+ /**
552
+ * The handler to call whenever a new GZIP member is found
553
+ */
554
+ onmember?: GunzipMemberHandler;
555
+ /**
556
+ * Creates a GUNZIP stream
557
+ * @param opts The decompression options
558
+ * @param cb The callback to call whenever data is inflated
559
+ */
560
+ constructor(opts: GunzipStreamOptions, cb?: FlateStreamHandler);
561
+ /**
562
+ * Creates a GUNZIP stream
563
+ * @param cb The callback to call whenever data is inflated
564
+ */
565
+ constructor(cb?: FlateStreamHandler);
566
+ /**
567
+ * Pushes a chunk to be GUNZIPped
568
+ * @param chunk The chunk to push
569
+ * @param final Whether this is the last chunk
570
+ */
571
+ push(chunk: Uint8Array, final?: boolean): void;
572
+ }
573
+ /**
574
+ * Asynchronous streaming single or multi-member GZIP decompression
575
+ */
576
+ export declare class AsyncGunzip {
577
+ /**
578
+ * The handler to call whenever data is available
579
+ */
580
+ ondata: AsyncFlateStreamHandler;
581
+ /**
582
+ * The handler to call whenever buffered source data is processed (i.e. `queuedSize` updates)
583
+ */
584
+ ondrain?: AsyncFlateDrainHandler;
585
+ /**
586
+ * The number of compressed bytes buffered in the stream
587
+ */
588
+ queuedSize: number;
589
+ /**
590
+ * The handler to call whenever a new GZIP member is found
591
+ */
592
+ onmember?: GunzipMemberHandler;
593
+ /**
594
+ * Creates an asynchronous GUNZIP stream
595
+ * @param opts The decompression options
596
+ * @param cb The callback to call whenever data is inflated
597
+ */
598
+ constructor(opts: GunzipStreamOptions, cb?: AsyncFlateStreamHandler);
599
+ /**
600
+ * Creates an asynchronous GUNZIP stream
601
+ * @param cb The callback to call whenever data is inflated
602
+ */
603
+ constructor(cb?: AsyncFlateStreamHandler);
604
+ /**
605
+ * Pushes a chunk to be GUNZIPped
606
+ * @param chunk The chunk to push
607
+ * @param final Whether this is the last chunk
608
+ */
609
+ push(chunk: Uint8Array, final?: boolean): void;
610
+ /**
611
+ * A method to terminate the stream's internal worker. Subsequent calls to
612
+ * push() will silently fail.
613
+ */
614
+ terminate: AsyncTerminable;
615
+ }
616
+ /**
617
+ * Asynchronously expands GZIP data
618
+ * @param data The data to decompress
619
+ * @param opts The decompression options
620
+ * @param cb The function to be called upon decompression completion
621
+ * @returns A function that can be used to immediately terminate the decompression
622
+ */
623
+ export declare function gunzip(data: Uint8Array, opts: AsyncGunzipOptions, cb: FlateCallback): AsyncTerminable;
624
+ /**
625
+ * Asynchronously expands GZIP data
626
+ * @param data The data to decompress
627
+ * @param cb The function to be called upon decompression completion
628
+ * @returns A function that can be used to immediately terminate the decompression
629
+ */
630
+ export declare function gunzip(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
631
+ /**
632
+ * Expands GZIP data
633
+ * @param data The data to decompress
634
+ * @returns The decompressed version of the data
635
+ */
636
+ export declare function gunzipSync(data: Uint8Array): Uint8Array<ArrayBuffer>;
637
+ /**
638
+ * Expands GZIP data
639
+ * @param data The data to decompress
640
+ * @param opts The decompression options
641
+ * @returns The decompressed version of the data
642
+ */
643
+ export declare function gunzipSync<TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(data: Uint8Array, opts?: GunzipOptions<TArrayBuffer>): Uint8Array<TArrayBuffer>;
644
+ /**
645
+ * Streaming Zlib compression
646
+ */
647
+ export declare class Zlib {
648
+ private c;
649
+ private v;
650
+ private o;
651
+ private s;
652
+ /**
653
+ * The handler to call whenever data is available
654
+ */
655
+ ondata: FlateStreamHandler;
656
+ /**
657
+ * Creates a Zlib stream
658
+ * @param opts The compression options
659
+ * @param cb The callback to call whenever data is deflated
660
+ */
661
+ constructor(opts: ZlibOptions, cb?: FlateStreamHandler);
662
+ /**
663
+ * Creates a Zlib stream
664
+ * @param cb The callback to call whenever data is deflated
665
+ */
666
+ constructor(cb?: FlateStreamHandler);
667
+ /**
668
+ * Pushes a chunk to be zlibbed
669
+ * @param chunk The chunk to push
670
+ * @param final Whether this is the last chunk
671
+ */
672
+ push(chunk: Uint8Array, final?: boolean): void;
673
+ private p;
674
+ /**
675
+ * Flushes buffered uncompressed data. Useful to immediately retrieve the
676
+ * zlibbed output for small inputs.
677
+ * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5
678
+ * extra bytes, but guarantees all pushed data is immediately
679
+ * decompressible.
680
+ */
681
+ flush(sync?: boolean): void;
682
+ }
683
+ /**
684
+ * Asynchronous streaming Zlib compression
685
+ */
686
+ export declare class AsyncZlib {
687
+ /**
688
+ * The handler to call whenever data is available
689
+ */
690
+ ondata: AsyncFlateStreamHandler;
691
+ /**
692
+ * The handler to call whenever buffered source data is processed (i.e. `queuedSize` updates)
693
+ */
694
+ ondrain?: AsyncFlateDrainHandler;
695
+ /**
696
+ * The number of uncompressed bytes buffered in the stream
697
+ */
698
+ queuedSize: number;
699
+ /**
700
+ * Creates an asynchronous Zlib stream
701
+ * @param opts The compression options
702
+ * @param cb The callback to call whenever data is deflated
703
+ */
704
+ constructor(opts: ZlibOptions, cb?: AsyncFlateStreamHandler);
705
+ /**
706
+ * Creates an asynchronous Zlib stream
707
+ * @param cb The callback to call whenever data is deflated
708
+ */
709
+ constructor(cb?: AsyncFlateStreamHandler);
710
+ /**
711
+ * Pushes a chunk to be deflated
712
+ * @param chunk The chunk to push
713
+ * @param final Whether this is the last chunk
714
+ */
715
+ push(chunk: Uint8Array, final?: boolean): void;
716
+ /**
717
+ * Flushes buffered uncompressed data. Useful to immediately retrieve the
718
+ * zlibbed output for small inputs.
719
+ * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5
720
+ * extra bytes, but guarantees all pushed data is immediately
721
+ * decompressible.
722
+ */
723
+ flush(sync?: boolean): void;
724
+ /**
725
+ * A method to terminate the stream's internal worker. Subsequent calls to
726
+ * push() will silently fail.
727
+ */
728
+ terminate: AsyncTerminable;
729
+ }
730
+ /**
731
+ * Asynchronously compresses data with Zlib
732
+ * @param data The data to compress
733
+ * @param opts The compression options
734
+ * @param cb The function to be called upon compression completion
735
+ */
736
+ export declare function zlib(data: Uint8Array, opts: AsyncZlibOptions, cb: FlateCallback): AsyncTerminable;
737
+ /**
738
+ * Asynchronously compresses data with Zlib
739
+ * @param data The data to compress
740
+ * @param cb The function to be called upon compression completion
741
+ * @returns A function that can be used to immediately terminate the compression
742
+ */
743
+ export declare function zlib(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
744
+ /**
745
+ * Compress data with Zlib
746
+ * @param data The data to compress
747
+ * @param opts The compression options
748
+ * @returns The zlib-compressed version of the data
749
+ */
750
+ export declare function zlibSync(data: Uint8Array, opts?: ZlibOptions): Uint8Array<ArrayBuffer>;
751
+ /**
752
+ * Streaming Zlib decompression
753
+ */
754
+ export declare class Unzlib {
755
+ private v;
756
+ private p;
757
+ /**
758
+ * The handler to call whenever data is available
759
+ */
760
+ ondata: FlateStreamHandler;
761
+ /**
762
+ * Creates a Zlib decompression stream
763
+ * @param opts The decompression options
764
+ * @param cb The callback to call whenever data is inflated
765
+ */
766
+ constructor(opts: UnzlibStreamOptions, cb?: FlateStreamHandler);
767
+ /**
768
+ * Creates a Zlib decompression stream
769
+ * @param cb The callback to call whenever data is inflated
770
+ */
771
+ constructor(cb?: FlateStreamHandler);
772
+ /**
773
+ * Pushes a chunk to be unzlibbed
774
+ * @param chunk The chunk to push
775
+ * @param final Whether this is the last chunk
776
+ */
777
+ push(chunk: Uint8Array, final?: boolean): void;
778
+ }
779
+ /**
780
+ * Asynchronous streaming Zlib decompression
781
+ */
782
+ export declare class AsyncUnzlib {
783
+ /**
784
+ * The handler to call whenever data is available
785
+ */
786
+ ondata: AsyncFlateStreamHandler;
787
+ /**
788
+ * The handler to call whenever buffered source data is processed (i.e. `queuedSize` updates)
789
+ */
790
+ ondrain?: AsyncFlateDrainHandler;
791
+ /**
792
+ * The number of compressed bytes buffered in the stream
793
+ */
794
+ queuedSize: number;
795
+ /**
796
+ * Creates an asynchronous Zlib decompression stream
797
+ * @param opts The decompression options
798
+ * @param cb The callback to call whenever data is inflated
799
+ */
800
+ constructor(opts: UnzlibStreamOptions, cb?: AsyncFlateStreamHandler);
801
+ /**
802
+ * Creates an asynchronous Zlib decompression stream
803
+ * @param cb The callback to call whenever data is inflated
804
+ */
805
+ constructor(cb?: AsyncFlateStreamHandler);
806
+ /**
807
+ * Pushes a chunk to be decompressed from Zlib
808
+ * @param chunk The chunk to push
809
+ * @param final Whether this is the last chunk
810
+ */
811
+ push(chunk: Uint8Array, final?: boolean): void;
812
+ /**
813
+ * A method to terminate the stream's internal worker. Subsequent calls to
814
+ * push() will silently fail.
815
+ */
816
+ terminate: AsyncTerminable;
817
+ }
818
+ /**
819
+ * Asynchronously expands Zlib data
820
+ * @param data The data to decompress
821
+ * @param opts The decompression options
822
+ * @param cb The function to be called upon decompression completion
823
+ * @returns A function that can be used to immediately terminate the decompression
824
+ */
825
+ export declare function unzlib(data: Uint8Array, opts: AsyncUnzlibOptions, cb: FlateCallback): AsyncTerminable;
826
+ /**
827
+ * Asynchronously expands Zlib data
828
+ * @param data The data to decompress
829
+ * @param cb The function to be called upon decompression completion
830
+ * @returns A function that can be used to immediately terminate the decompression
831
+ */
832
+ export declare function unzlib(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
833
+ /**
834
+ * Expands Zlib data
835
+ * @param data The data to decompress
836
+ * @returns The decompressed version of the data
837
+ */
838
+ export declare function unzlibSync(data: Uint8Array): Uint8Array<ArrayBuffer>;
839
+ /**
840
+ * Expands Zlib data
841
+ * @param data The data to decompress
842
+ * @param opts The decompression options
843
+ * @returns The decompressed version of the data
844
+ */
845
+ export declare function unzlibSync<TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(data: Uint8Array, opts?: UnzlibOptions<TArrayBuffer>): Uint8Array<TArrayBuffer>;
846
+ export { gzip as compress, AsyncGzip as AsyncCompress };
847
+ export { gzipSync as compressSync, Gzip as Compress };
848
+ /**
849
+ * Streaming GZIP, Zlib, or raw DEFLATE decompression
850
+ */
851
+ export declare class Decompress {
852
+ private G;
853
+ private I;
854
+ private Z;
855
+ private o;
856
+ private s;
857
+ private p;
858
+ /**
859
+ * The handler to call whenever data is available
860
+ */
861
+ ondata: FlateStreamHandler;
862
+ /**
863
+ * Creates a decompression stream
864
+ * @param opts The decompression options
865
+ * @param cb The callback to call whenever data is decompressed
866
+ */
867
+ constructor(opts: InflateStreamOptions, cb?: FlateStreamHandler);
868
+ /**
869
+ * Creates a decompression stream
870
+ * @param cb The callback to call whenever data is decompressed
871
+ */
872
+ constructor(cb?: FlateStreamHandler);
873
+ private i;
874
+ /**
875
+ * Pushes a chunk to be decompressed
876
+ * @param chunk The chunk to push
877
+ * @param final Whether this is the last chunk
878
+ */
879
+ push(chunk: Uint8Array, final?: boolean): void;
880
+ }
881
+ /**
882
+ * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression
883
+ */
884
+ export declare class AsyncDecompress {
885
+ private G;
886
+ private I;
887
+ private Z;
888
+ /**
889
+ * The handler to call whenever data is available
890
+ */
891
+ ondata: AsyncFlateStreamHandler;
892
+ /**
893
+ * The handler to call whenever buffered source data is processed (i.e. `queuedSize` updates)
894
+ */
895
+ ondrain?: AsyncFlateDrainHandler;
896
+ /**
897
+ * The number of compressed bytes buffered in the stream
898
+ */
899
+ queuedSize: number;
900
+ /**
901
+ * Creates an asynchronous decompression stream
902
+ * @param opts The decompression options
903
+ * @param cb The callback to call whenever data is decompressed
904
+ */
905
+ constructor(opts: InflateStreamOptions, cb?: AsyncFlateStreamHandler);
906
+ /**
907
+ * Creates an asynchronous decompression stream
908
+ * @param cb The callback to call whenever data is decompressed
909
+ */
910
+ constructor(cb?: AsyncFlateStreamHandler);
911
+ private i;
912
+ /**
913
+ * Pushes a chunk to be decompressed
914
+ * @param chunk The chunk to push
915
+ * @param final Whether this is the last chunk
916
+ */
917
+ push(chunk: Uint8Array, final?: boolean): void;
918
+ }
919
+ /**
920
+ * Asynchrononously expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
921
+ * @param data The data to decompress
922
+ * @param opts The decompression options
923
+ * @param cb The function to be called upon decompression completion
924
+ * @returns A function that can be used to immediately terminate the decompression
925
+ */
926
+ export declare function decompress(data: Uint8Array, opts: AsyncInflateOptions, cb: FlateCallback): AsyncTerminable;
927
+ /**
928
+ * Asynchrononously expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
929
+ * @param data The data to decompress
930
+ * @param cb The function to be called upon decompression completion
931
+ * @returns A function that can be used to immediately terminate the decompression
932
+ */
933
+ export declare function decompress(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
934
+ /**
935
+ * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
936
+ * @param data The data to decompress
937
+ * @param opts The decompression options
938
+ * @returns The decompressed version of the data
939
+ */
940
+ export declare function decompressSync(data: Uint8Array, opts?: InflateOptions): Uint8Array<ArrayBufferLike>;
941
+ /**
942
+ * Attributes for files added to a ZIP archive object
943
+ */
944
+ export interface ZipAttributes {
945
+ /**
946
+ * The operating system of origin for this file. The value is defined
947
+ * by PKZIP's APPNOTE.txt, section 4.4.2.2. For example, 0 (the default)
948
+ * is MS/DOS, 3 is Unix, 19 is macOS.
949
+ */
950
+ os?: number;
951
+ /**
952
+ * The file's attributes. These are traditionally somewhat complicated
953
+ * and platform-dependent, so using them is scarcely necessary. However,
954
+ * here is a representation of what this is, bit by bit:
955
+ *
956
+ * `TTTTugtrwxrwxrwx0000000000ADVSHR`
957
+ *
958
+ * TTTT = file type (rarely useful)
959
+ *
960
+ * u = setuid, g = setgid, t = sticky
961
+ *
962
+ * rwx = user permissions, rwx = group permissions, rwx = other permissions
963
+ *
964
+ * 0000000000 = unused
965
+ *
966
+ * A = archive, D = directory, V = volume label, S = system file, H = hidden, R = read-only
967
+ *
968
+ * If you want to set the Unix permissions, for instance, just bit shift by 16, e.g. 0o644 << 16.
969
+ * Note that attributes usually only work in conjunction with the `os` setting: you must use
970
+ * `os` = 3 (Unix) if you want to set Unix permissions
971
+ */
972
+ attrs?: number;
973
+ /**
974
+ * Extra metadata to add to the file. This field is defined by PKZIP's APPNOTE.txt,
975
+ * section 4.4.28. At most 65,535 bytes may be used in each ID. The ID must be an
976
+ * integer between 0 and 65,535, inclusive.
977
+ *
978
+ * This field is incredibly rare and almost never needed except for compliance with
979
+ * proprietary standards and software.
980
+ */
981
+ extra?: Record<number, Uint8Array>;
982
+ /**
983
+ * The comment to attach to the file. This field is defined by PKZIP's APPNOTE.txt,
984
+ * section 4.4.26. The comment must be at most 65,535 bytes long UTF-8 encoded. This
985
+ * field is not read by consumer software.
986
+ */
987
+ comment?: string;
988
+ /**
989
+ * When the file was last modified. Defaults to the current time.
990
+ */
991
+ mtime?: GzipOptions['mtime'];
992
+ }
993
+ /**
994
+ * Options for creating a ZIP archive
995
+ */
996
+ export interface ZipOptions extends DeflateOptions, ZipAttributes {
997
+ }
998
+ /**
999
+ * Options for expanding a ZIP archive
1000
+ */
1001
+ export interface UnzipOptions {
1002
+ /**
1003
+ * A filter function to extract only certain files from a ZIP archive
1004
+ */
1005
+ filter?: UnzipFileFilter;
1006
+ }
1007
+ /**
1008
+ * Options for asynchronously creating a ZIP archive
1009
+ */
1010
+ export interface AsyncZipOptions extends AsyncDeflateOptions, ZipAttributes {
1011
+ }
1012
+ /**
1013
+ * Options for asynchronously expanding a ZIP archive
1014
+ */
1015
+ export interface AsyncUnzipOptions extends UnzipOptions {
1016
+ }
1017
+ /**
1018
+ * A file that can be used to create a ZIP archive
1019
+ */
1020
+ export type ZippableFile = Uint8Array | Zippable | [Uint8Array | Zippable, ZipOptions];
1021
+ /**
1022
+ * A file that can be used to asynchronously create a ZIP archive
1023
+ */
1024
+ export type AsyncZippableFile = Uint8Array | AsyncZippable | [Uint8Array | AsyncZippable, AsyncZipOptions];
1025
+ /**
1026
+ * The complete directory structure of a ZIPpable archive
1027
+ */
1028
+ export interface Zippable {
1029
+ [path: string]: ZippableFile;
1030
+ }
1031
+ /**
1032
+ * The complete directory structure of an asynchronously ZIPpable archive
1033
+ */
1034
+ export interface AsyncZippable {
1035
+ [path: string]: AsyncZippableFile;
1036
+ }
1037
+ /**
1038
+ * An unzipped archive. The full path of each file is used as the key,
1039
+ * and the file is the value
1040
+ */
1041
+ export interface Unzipped {
1042
+ [path: string]: Uint8Array<ArrayBuffer>;
1043
+ }
1044
+ /**
1045
+ * Handler for string generation streams
1046
+ * @param data The string output from the stream processor
1047
+ * @param final Whether this is the final block
1048
+ */
1049
+ export type StringStreamHandler = (data: string, final: boolean) => void;
1050
+ /**
1051
+ * Callback for asynchronous ZIP decompression
1052
+ * @param err Any error that occurred
1053
+ * @param data The decompressed ZIP archive
1054
+ */
1055
+ export type UnzipCallback = (err: FlateError | null, data: Unzipped) => void;
1056
+ /**
1057
+ * Handler for streaming ZIP decompression
1058
+ * @param file The file that was found in the archive
1059
+ */
1060
+ export type UnzipFileHandler = (file: UnzipFile) => void;
1061
+ /**
1062
+ * Streaming UTF-8 decoding
1063
+ */
1064
+ export declare class DecodeUTF8 {
1065
+ private p;
1066
+ private t;
1067
+ /**
1068
+ * Creates a UTF-8 decoding stream
1069
+ * @param cb The callback to call whenever data is decoded
1070
+ */
1071
+ constructor(cb?: StringStreamHandler);
1072
+ /**
1073
+ * Pushes a chunk to be decoded from UTF-8 binary
1074
+ * @param chunk The chunk to push
1075
+ * @param final Whether this is the last chunk
1076
+ */
1077
+ push(chunk: Uint8Array, final?: boolean): void;
1078
+ /**
1079
+ * The handler to call whenever data is available
1080
+ */
1081
+ ondata: StringStreamHandler;
1082
+ }
1083
+ /**
1084
+ * Streaming UTF-8 encoding
1085
+ */
1086
+ export declare class EncodeUTF8 {
1087
+ private d;
1088
+ /**
1089
+ * Creates a UTF-8 decoding stream
1090
+ * @param cb The callback to call whenever data is encoded
1091
+ */
1092
+ constructor(cb?: FlateStreamHandler);
1093
+ /**
1094
+ * Pushes a chunk to be encoded to UTF-8
1095
+ * @param chunk The string data to push
1096
+ * @param final Whether this is the last chunk
1097
+ */
1098
+ push(chunk: string, final?: boolean): void;
1099
+ /**
1100
+ * The handler to call whenever data is available
1101
+ */
1102
+ ondata: FlateStreamHandler;
1103
+ }
1104
+ /**
1105
+ * Converts a string into a Uint8Array for use with compression/decompression methods
1106
+ * @param str The string to encode
1107
+ * @param latin1 Whether or not to interpret the data as Latin-1. This should
1108
+ * not need to be true unless decoding a binary string.
1109
+ * @returns The string encoded in UTF-8/Latin-1 binary
1110
+ */
1111
+ export declare function strToU8(str: string, latin1?: boolean): Uint8Array<ArrayBuffer>;
1112
+ /**
1113
+ * Converts a Uint8Array to a string
1114
+ * @param dat The data to decode to string
1115
+ * @param latin1 Whether or not to interpret the data as Latin-1. This should
1116
+ * not need to be true unless encoding to binary string.
1117
+ * @returns The original UTF-8/Latin-1 string
1118
+ */
1119
+ export declare function strFromU8(dat: Uint8Array, latin1?: boolean): string;
1120
+ /**
1121
+ * A stream that can be used to create a file in a ZIP archive
1122
+ */
1123
+ export interface ZipInputFile extends ZipAttributes {
1124
+ /**
1125
+ * The filename to associate with the data provided to this stream. If you
1126
+ * want a file in a subdirectory, use forward slashes as a separator (e.g.
1127
+ * `directory/filename.ext`). This will still work on Windows.
1128
+ */
1129
+ filename: string;
1130
+ /**
1131
+ * The size of the file in bytes. This attribute may be invalid after
1132
+ * the file is added to the ZIP archive; it must be correct only before the
1133
+ * stream completes.
1134
+ *
1135
+ * If you don't want to have to compute this yourself, consider extending the
1136
+ * ZipPassThrough class and overriding its process() method, or using one of
1137
+ * ZipDeflate or AsyncZipDeflate.
1138
+ */
1139
+ size: number;
1140
+ /**
1141
+ * A CRC of the original file contents. This attribute may be invalid after
1142
+ * the file is added to the ZIP archive; it must be correct only before the
1143
+ * stream completes.
1144
+ *
1145
+ * If you don't want to have to generate this yourself, consider extending the
1146
+ * ZipPassThrough class and overriding its process() method, or using one of
1147
+ * ZipDeflate or AsyncZipDeflate.
1148
+ */
1149
+ crc: number;
1150
+ /**
1151
+ * The compression format for the data stream. This number is determined by
1152
+ * the spec in PKZIP's APPNOTE.txt, section 4.4.5. For example, 0 = no
1153
+ * compression, 8 = deflate, 14 = LZMA
1154
+ */
1155
+ compression: number;
1156
+ /**
1157
+ * Bits 1 and 2 of the general purpose bit flag, specified in PKZIP's
1158
+ * APPNOTE.txt, section 4.4.4. Should be between 0 and 3. This is unlikely
1159
+ * to be necessary.
1160
+ */
1161
+ flag?: number;
1162
+ /**
1163
+ * The handler to be called when data is added. After passing this stream to
1164
+ * the ZIP file object, this handler will always be defined. To call it:
1165
+ *
1166
+ * `stream.ondata(error, chunk, final)`
1167
+ *
1168
+ * error = any error that occurred (null if there was no error)
1169
+ *
1170
+ * chunk = a Uint8Array of the data that was added (null if there was an
1171
+ * error)
1172
+ *
1173
+ * final = boolean, whether this is the final chunk in the stream
1174
+ */
1175
+ ondata?: AsyncFlateStreamHandler;
1176
+ /**
1177
+ * A method called when the stream is no longer needed, for clean-up
1178
+ * purposes. This will not always be called after the stream completes,
1179
+ * so you may wish to call this.terminate() after the final chunk is
1180
+ * processed if you have clean-up logic.
1181
+ */
1182
+ terminate?: AsyncTerminable;
1183
+ }
1184
+ /**
1185
+ * A pass-through stream to keep data uncompressed in a ZIP archive.
1186
+ */
1187
+ export declare class ZipPassThrough implements ZipInputFile {
1188
+ filename: string;
1189
+ crc: number;
1190
+ size: number;
1191
+ compression: number;
1192
+ os?: number;
1193
+ attrs?: number;
1194
+ comment?: string;
1195
+ extra?: Record<number, Uint8Array>;
1196
+ mtime?: GzipOptions['mtime'];
1197
+ ondata: AsyncFlateStreamHandler;
1198
+ private c;
1199
+ /**
1200
+ * Creates a pass-through stream that can be added to ZIP archives
1201
+ * @param filename The filename to associate with this data stream
1202
+ */
1203
+ constructor(filename: string);
1204
+ /**
1205
+ * Processes a chunk and pushes to the output stream. You can override this
1206
+ * method in a subclass for custom behavior, but by default this passes
1207
+ * the data through. You must call this.ondata(err, chunk, final) at some
1208
+ * point in this method.
1209
+ * @param chunk The chunk to process
1210
+ * @param final Whether this is the last chunk
1211
+ */
1212
+ protected process(chunk: Uint8Array<ArrayBuffer>, final: boolean): void;
1213
+ /**
1214
+ * Pushes a chunk to be added. If you are subclassing this with a custom
1215
+ * compression algorithm, note that you must push data from the source
1216
+ * file only, pre-compression.
1217
+ * @param chunk The chunk to push
1218
+ * @param final Whether this is the last chunk
1219
+ */
1220
+ push(chunk: Uint8Array, final?: boolean): void;
1221
+ }
1222
+ /**
1223
+ * Streaming DEFLATE compression for ZIP archives. Prefer using AsyncZipDeflate
1224
+ * for better performance
1225
+ */
1226
+ export declare class ZipDeflate implements ZipInputFile {
1227
+ filename: string;
1228
+ crc: number;
1229
+ size: number;
1230
+ compression: number;
1231
+ flag: 0 | 1 | 2 | 3;
1232
+ os?: number;
1233
+ attrs?: number;
1234
+ comment?: string;
1235
+ extra?: Record<number, Uint8Array>;
1236
+ mtime?: GzipOptions['mtime'];
1237
+ ondata: AsyncFlateStreamHandler;
1238
+ private d;
1239
+ /**
1240
+ * Creates a DEFLATE stream that can be added to ZIP archives
1241
+ * @param filename The filename to associate with this data stream
1242
+ * @param opts The compression options
1243
+ */
1244
+ constructor(filename: string, opts?: DeflateOptions);
1245
+ private process;
1246
+ /**
1247
+ * Pushes a chunk to be deflated
1248
+ * @param chunk The chunk to push
1249
+ * @param final Whether this is the last chunk
1250
+ */
1251
+ push(chunk: Uint8Array, final?: boolean): void;
1252
+ }
1253
+ /**
1254
+ * Asynchronous streaming DEFLATE compression for ZIP archives
1255
+ */
1256
+ export declare class AsyncZipDeflate implements ZipInputFile {
1257
+ filename: string;
1258
+ crc: number;
1259
+ size: number;
1260
+ compression: number;
1261
+ flag: 0 | 1 | 2 | 3;
1262
+ os?: number;
1263
+ attrs?: number;
1264
+ comment?: string;
1265
+ extra?: Record<number, Uint8Array>;
1266
+ mtime?: GzipOptions['mtime'];
1267
+ ondata: AsyncFlateStreamHandler;
1268
+ private d;
1269
+ terminate: AsyncTerminable;
1270
+ /**
1271
+ * Creates an asynchronous DEFLATE stream that can be added to ZIP archives
1272
+ * @param filename The filename to associate with this data stream
1273
+ * @param opts The compression options
1274
+ */
1275
+ constructor(filename: string, opts?: DeflateOptions);
1276
+ private process;
1277
+ /**
1278
+ * Pushes a chunk to be deflated
1279
+ * @param chunk The chunk to push
1280
+ * @param final Whether this is the last chunk
1281
+ */
1282
+ push(chunk: Uint8Array, final?: boolean): void;
1283
+ }
1284
+ /**
1285
+ * A zippable archive to which files can incrementally be added
1286
+ */
1287
+ export declare class Zip {
1288
+ private u;
1289
+ private d;
1290
+ /**
1291
+ * Creates an empty ZIP archive to which files can be added
1292
+ * @param cb The callback to call whenever data for the generated ZIP archive
1293
+ * is available
1294
+ */
1295
+ constructor(cb?: AsyncFlateStreamHandler);
1296
+ /**
1297
+ * Adds a file to the ZIP archive
1298
+ * @param file The file stream to add
1299
+ */
1300
+ add(file: ZipInputFile): void;
1301
+ /**
1302
+ * Ends the process of adding files and prepares to emit the final chunks.
1303
+ * This *must* be called after adding all desired files for the resulting
1304
+ * ZIP file to work properly.
1305
+ */
1306
+ end(): void;
1307
+ private e;
1308
+ /**
1309
+ * A method to terminate any internal workers used by the stream. Subsequent
1310
+ * calls to add() will fail.
1311
+ */
1312
+ terminate(): void;
1313
+ /**
1314
+ * The handler to call whenever data is available
1315
+ */
1316
+ ondata: AsyncFlateStreamHandler;
1317
+ }
1318
+ /**
1319
+ * Asynchronously creates a ZIP file
1320
+ * @param data The directory structure for the ZIP archive
1321
+ * @param opts The main options, merged with per-file options
1322
+ * @param cb The callback to call with the generated ZIP archive
1323
+ * @returns A function that can be used to immediately terminate the compression
1324
+ */
1325
+ export declare function zip(data: AsyncZippable, opts: AsyncZipOptions, cb: FlateCallback): AsyncTerminable;
1326
+ /**
1327
+ * Asynchronously creates a ZIP file
1328
+ * @param data The directory structure for the ZIP archive
1329
+ * @param cb The callback to call with the generated ZIP archive
1330
+ * @returns A function that can be used to immediately terminate the compression
1331
+ */
1332
+ export declare function zip(data: AsyncZippable, cb: FlateCallback): AsyncTerminable;
1333
+ /**
1334
+ * Synchronously creates a ZIP file. Prefer using `zip` for better performance
1335
+ * with more than one file.
1336
+ * @param data The directory structure for the ZIP archive
1337
+ * @param opts The main options, merged with per-file options
1338
+ * @returns The generated ZIP archive
1339
+ */
1340
+ export declare function zipSync(data: Zippable, opts?: ZipOptions): Uint8Array<ArrayBuffer>;
1341
+ /**
1342
+ * A decoder for files in ZIP streams
1343
+ */
1344
+ export interface UnzipDecoder {
1345
+ /**
1346
+ * The handler to call whenever data is available
1347
+ */
1348
+ ondata: AsyncFlateStreamHandler;
1349
+ /**
1350
+ * Pushes a chunk to be decompressed
1351
+ * @param chunk The data in this chunk. Do not consume (detach) this buffer.
1352
+ * @param final Whether this is the last chunk in the data stream
1353
+ */
1354
+ push(chunk: Uint8Array, final: boolean): void;
1355
+ /**
1356
+ * A method to terminate any internal workers used by the stream. Subsequent
1357
+ * calls to push() should silently fail.
1358
+ */
1359
+ terminate?: AsyncTerminable;
1360
+ }
1361
+ /**
1362
+ * A constructor for a decoder for unzip streams
1363
+ */
1364
+ export interface UnzipDecoderConstructor {
1365
+ /**
1366
+ * Creates an instance of the decoder
1367
+ * @param filename The name of the file
1368
+ * @param size The compressed size of the file
1369
+ * @param originalSize The original size of the file
1370
+ */
1371
+ new (filename: string, size?: number, originalSize?: number): UnzipDecoder;
1372
+ /**
1373
+ * The compression format for the data stream. This number is determined by
1374
+ * the spec in PKZIP's APPNOTE.txt, section 4.4.5. For example, 0 = no
1375
+ * compression, 8 = deflate, 14 = LZMA
1376
+ */
1377
+ compression: number;
1378
+ }
1379
+ /**
1380
+ * Information about a file to be extracted from a ZIP archive
1381
+ */
1382
+ export interface UnzipFileInfo {
1383
+ /**
1384
+ * The name of the file
1385
+ */
1386
+ name: string;
1387
+ /**
1388
+ * The compressed size of the file
1389
+ */
1390
+ size: number;
1391
+ /**
1392
+ * The original size of the file
1393
+ */
1394
+ originalSize: number;
1395
+ /**
1396
+ * The compression format for the data stream. This number is determined by
1397
+ * the spec in PKZIP's APPNOTE.txt, section 4.4.5. For example, 0 = no
1398
+ * compression, 8 = deflate, 14 = LZMA. If the filter function returns true
1399
+ * but this value is not 8, the unzip function will throw.
1400
+ */
1401
+ compression: number;
1402
+ }
1403
+ /**
1404
+ * A filter for files to be extracted during the unzipping process
1405
+ * @param file The info for the current file being processed
1406
+ * @returns Whether or not to extract the current file
1407
+ */
1408
+ export type UnzipFileFilter = (file: UnzipFileInfo) => boolean;
1409
+ /**
1410
+ * Streaming file extraction from ZIP archives
1411
+ */
1412
+ export interface UnzipFile {
1413
+ /**
1414
+ * The handler to call whenever data is available
1415
+ */
1416
+ ondata: AsyncFlateStreamHandler;
1417
+ /**
1418
+ * The name of the file
1419
+ */
1420
+ name: string;
1421
+ /**
1422
+ * The compression format for the data stream. This number is determined by
1423
+ * the spec in PKZIP's APPNOTE.txt, section 4.4.5. For example, 0 = no
1424
+ * compression, 8 = deflate, 14 = LZMA. If start() is called but there is no
1425
+ * decompression stream available for this method, start() will throw.
1426
+ */
1427
+ compression: number;
1428
+ /**
1429
+ * The compressed size of the file. Will not be present for archives created
1430
+ * in a streaming fashion.
1431
+ */
1432
+ size?: number;
1433
+ /**
1434
+ * The original size of the file. Will not be present for archives created
1435
+ * in a streaming fashion.
1436
+ */
1437
+ originalSize?: number;
1438
+ /**
1439
+ * Starts reading from the stream. Calling this function will always enable
1440
+ * this stream, but ocassionally the stream will be enabled even without
1441
+ * this being called.
1442
+ */
1443
+ start(): void;
1444
+ /**
1445
+ * A method to terminate any internal workers used by the stream. ondata
1446
+ * will not be called any further.
1447
+ */
1448
+ terminate: AsyncTerminable;
1449
+ }
1450
+ /**
1451
+ * Streaming pass-through decompression for ZIP archives
1452
+ */
1453
+ export declare class UnzipPassThrough implements UnzipDecoder {
1454
+ static compression: number;
1455
+ ondata: AsyncFlateStreamHandler;
1456
+ push(chunk: Uint8Array, final: boolean): void;
1457
+ }
1458
+ /**
1459
+ * Streaming DEFLATE decompression for ZIP archives. Prefer AsyncZipInflate for
1460
+ * better performance.
1461
+ */
1462
+ export declare class UnzipInflate implements UnzipDecoder {
1463
+ static compression: number;
1464
+ private i;
1465
+ ondata: AsyncFlateStreamHandler;
1466
+ /**
1467
+ * Creates a DEFLATE decompression that can be used in ZIP archives
1468
+ */
1469
+ constructor();
1470
+ push(chunk: Uint8Array, final: boolean): void;
1471
+ }
1472
+ /**
1473
+ * Asynchronous streaming DEFLATE decompression for ZIP archives
1474
+ */
1475
+ export declare class AsyncUnzipInflate implements UnzipDecoder {
1476
+ static compression: number;
1477
+ private i;
1478
+ ondata: AsyncFlateStreamHandler;
1479
+ terminate: AsyncTerminable;
1480
+ /**
1481
+ * Creates a DEFLATE decompression that can be used in ZIP archives
1482
+ */
1483
+ constructor(_: string, sz?: number);
1484
+ push(chunk: Uint8Array, final: boolean): void;
1485
+ }
1486
+ /**
1487
+ * A ZIP archive decompression stream that emits files as they are discovered
1488
+ */
1489
+ export declare class Unzip {
1490
+ private d;
1491
+ private c;
1492
+ private p;
1493
+ private k;
1494
+ private o;
1495
+ /**
1496
+ * Creates a ZIP decompression stream
1497
+ * @param cb The callback to call whenever a file in the ZIP archive is found
1498
+ */
1499
+ constructor(cb?: UnzipFileHandler);
1500
+ /**
1501
+ * Pushes a chunk to be unzipped
1502
+ * @param chunk The chunk to push
1503
+ * @param final Whether this is the last chunk
1504
+ */
1505
+ push(chunk: Uint8Array, final?: boolean): void;
1506
+ /**
1507
+ * Registers a decoder with the stream, allowing for files compressed with
1508
+ * the compression type provided to be expanded correctly
1509
+ * @param decoder The decoder constructor
1510
+ */
1511
+ register(decoder: UnzipDecoderConstructor): void;
1512
+ /**
1513
+ * The handler to call whenever a file is discovered
1514
+ */
1515
+ onfile: UnzipFileHandler;
1516
+ }
1517
+ /**
1518
+ * Asynchronously decompresses a ZIP archive
1519
+ * @param data The raw compressed ZIP file
1520
+ * @param opts The ZIP extraction options
1521
+ * @param cb The callback to call with the decompressed files
1522
+ * @returns A function that can be used to immediately terminate the unzipping
1523
+ */
1524
+ export declare function unzip(data: Uint8Array, opts: AsyncUnzipOptions, cb: UnzipCallback): AsyncTerminable;
1525
+ /**
1526
+ * Asynchronously decompresses a ZIP archive
1527
+ * @param data The raw compressed ZIP file
1528
+ * @param cb The callback to call with the decompressed files
1529
+ * @returns A function that can be used to immediately terminate the unzipping
1530
+ */
1531
+ export declare function unzip(data: Uint8Array, cb: UnzipCallback): AsyncTerminable;
1532
+ /**
1533
+ * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
1534
+ * performance with more than one file.
1535
+ * @param data The raw compressed ZIP file
1536
+ * @param opts The ZIP extraction options
1537
+ * @returns The decompressed files
1538
+ */
1539
+ export declare function unzipSync(data: Uint8Array, opts?: UnzipOptions): Unzipped;