Skip to content

Commit 3120bba

Browse files
committed
Update Typescript types for 1.1.0
1 parent 63e84da commit 3120bba

File tree

12 files changed

+388
-242
lines changed

12 files changed

+388
-242
lines changed

types/archive/decompress.d.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Factory method that creates an unarchiver based on the byte signature found
3+
* in the arrayBuffer.
4+
* @param {ArrayBuffer} ab The ArrayBuffer to unarchive. Note that this ArrayBuffer
5+
* must not be referenced after calling this method, as the ArrayBuffer is marked
6+
* as Transferable and sent to a Worker thread once start() is called.
7+
* @param {Object|string} options An optional object of options, or a string
8+
* representing where the path to the unarchiver script files.
9+
* @returns {Unarchiver}
10+
*/
11+
export function getUnarchiver(ab: ArrayBuffer, options?: any | string): Unarchiver;
12+
export class Unzipper extends UnzipperInternal {
13+
constructor(ab: any, options: any);
14+
}
15+
export class Unrarrer extends UnrarrerInternal {
16+
constructor(ab: any, options: any);
17+
}
18+
export class Untarrer extends UntarrerInternal {
19+
constructor(ab: any, options: any);
20+
}
21+
export type UnarchivedFile = {
22+
filename: string;
23+
fileData: Uint8Array;
24+
};
25+
import { Unarchiver } from "./decompress-internal.js";
26+
import { UnarchiveAppendEvent } from "./decompress-internal.js";
27+
import { UnarchiveErrorEvent } from "./decompress-internal.js";
28+
import { UnarchiveEvent } from "./decompress-internal.js";
29+
import { UnarchiveEventType } from "./decompress-internal.js";
30+
import { UnarchiveExtractEvent } from "./decompress-internal.js";
31+
import { UnarchiveFinishEvent } from "./decompress-internal.js";
32+
import { UnarchiveInfoEvent } from "./decompress-internal.js";
33+
import { UnarchiveProgressEvent } from "./decompress-internal.js";
34+
import { UnarchiveStartEvent } from "./decompress-internal.js";
35+
import { UnzipperInternal } from "./decompress-internal.js";
36+
import { UnrarrerInternal } from "./decompress-internal.js";
37+
import { UntarrerInternal } from "./decompress-internal.js";
38+
export { UnarchiveAppendEvent, UnarchiveErrorEvent, UnarchiveEvent, UnarchiveEventType, UnarchiveExtractEvent, UnarchiveFinishEvent, UnarchiveInfoEvent, UnarchiveProgressEvent, UnarchiveStartEvent, Unarchiver };
39+
//# sourceMappingURL=decompress.d.ts.map

types/archive/decompress.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
export { findMimeType } from "./file/sniffer.js";
2+
export { BitBuffer } from "./io/bitbuffer.js";
23
export { BitStream } from "./io/bitstream.js";
34
export { ByteBuffer } from "./io/bytebuffer.js";
45
export { ByteStream } from "./io/bytestream.js";
56
export type ProbeStream = import('./codecs/codecs.js').ProbeStream;
67
export type ProbeFormat = import('./codecs/codecs.js').ProbeFormat;
78
export type ProbeInfo = import('./codecs/codecs.js').ProbeInfo;
8-
export { UnarchiveEvent, UnarchiveEventType, UnarchiveInfoEvent, UnarchiveErrorEvent, UnarchiveStartEvent, UnarchiveFinishEvent, UnarchiveProgressEvent, UnarchiveExtractEvent, Unarchiver, Unzipper, Unrarrer, Untarrer, getUnarchiver } from "./archive/archive.js";
9+
export { UnarchiveEvent, UnarchiveEventType, UnarchiveInfoEvent, UnarchiveErrorEvent, UnarchiveStartEvent, UnarchiveFinishEvent, UnarchiveProgressEvent, UnarchiveExtractEvent, Unarchiver, Unzipper, Unrarrer, Untarrer, getUnarchiver } from "./archive/decompress.js";
910
export { getFullMIMEString, getShortMIMEString } from "./codecs/codecs.js";
1011
export { convertWebPtoPNG, convertWebPtoJPG } from "./image/webp-shim/webp-shim.js";
1112
//# sourceMappingURL=index.d.ts.map

types/index.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/io/bitbuffer.d.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* A write-only Bit buffer which uses a Uint8Array as a backing store.
3+
*/
4+
export class BitBuffer {
5+
/**
6+
* @param {number} numBytes The number of bytes to allocate.
7+
* @param {boolean} mtl The bit-packing mode. True means pack bits from most-significant (7) to
8+
* least-significant (0). Defaults false: least-significant (0) to most-significant (8).
9+
*/
10+
constructor(numBytes: number, mtl?: boolean);
11+
/**
12+
* @type {Uint8Array}
13+
* @public
14+
*/
15+
public data: Uint8Array;
16+
/**
17+
* Whether we pack bits from most-significant-bit to least. Defaults false (least-to-most
18+
* significant bit packing).
19+
* @type {boolean}
20+
* @private
21+
*/
22+
private mtl;
23+
/**
24+
* The current byte we are filling with bits.
25+
* @type {number}
26+
* @public
27+
*/
28+
public bytePtr: number;
29+
/**
30+
* Points at the bit within the current byte where the next bit will go. This number ranges
31+
* from 0 to 7 and the direction of packing is indicated by the mtl property.
32+
* @type {number}
33+
* @public
34+
*/
35+
public bitPtr: number;
36+
/** @returns {boolean} */
37+
getPackingDirection(): boolean;
38+
/**
39+
* Sets the bit-packing direction. Default (false) is least-significant-bit (0) to
40+
* most-significant (7). Changing the bit-packing direction when the bit pointer is in the
41+
* middle of a byte will fill the rest of that byte with 0s using the current bit-packing
42+
* direction and then set the bit pointer to the appropriate bit of the next byte. If there
43+
* are no more bytes left in this buffer, it will throw an error.
44+
*/
45+
setPackingDirection(mtl?: boolean): void;
46+
/**
47+
* writeBits(3, 6) is the same as writeBits(0b000011, 6).
48+
* Will throw an error (without writing) if this would over-flow the buffer.
49+
* @param {number} val The bits to pack into the buffer. Negative values are not allowed.
50+
* @param {number} numBits Must be positive, non-zero and less or equal to than 53, since
51+
* JavaScript can only support 53-bit integers.
52+
*/
53+
writeBits(val: number, numBits: number): void;
54+
}
55+
//# sourceMappingURL=bitbuffer.d.ts.map

types/io/bitbuffer.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/io/bitstream.d.ts

Lines changed: 124 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,125 @@
1-
export const BitStream: {
2-
new (ab: ArrayBuffer, mtl: boolean, opt_offset: number, opt_length: number): {
3-
/**
4-
* The bytes in the stream.
5-
* @type {Uint8Array}
6-
* @private
7-
*/
8-
bytes: Uint8Array;
9-
/**
10-
* The byte in the stream that we are currently on.
11-
* @type {Number}
12-
* @private
13-
*/
14-
bytePtr: number;
15-
/**
16-
* The bit in the current byte that we will read next (can have values 0 through 7).
17-
* @type {Number}
18-
* @private
19-
*/
20-
bitPtr: number;
21-
/**
22-
* An ever-increasing number.
23-
* @type {Number}
24-
* @private
25-
*/
26-
bitsRead_: number;
27-
peekBits: (n: number, opt_movePointers: any) => number;
28-
/**
29-
* Returns how many bites have been read in the stream since the beginning of time.
30-
* @returns {number}
31-
*/
32-
getNumBitsRead(): number;
33-
/**
34-
* Returns how many bits are currently in the stream left to be read.
35-
* @returns {number}
36-
*/
37-
getNumBitsLeft(): number;
38-
/**
39-
* byte0 byte1 byte2 byte3
40-
* 7......0 | 7......0 | 7......0 | 7......0
41-
*
42-
* The bit pointer starts at least-significant bit (0) of byte0 and moves left until it reaches
43-
* bit7 of byte0, then jumps to bit0 of byte1, etc.
44-
* @param {number} n The number of bits to peek, must be a positive integer.
45-
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
46-
* @returns {number} The peeked bits, as an unsigned number.
47-
*/
48-
peekBits_ltm(n: number, opt_movePointers: any): number;
49-
/**
50-
* byte0 byte1 byte2 byte3
51-
* 7......0 | 7......0 | 7......0 | 7......0
52-
*
53-
* The bit pointer starts at bit7 of byte0 and moves right until it reaches
54-
* bit0 of byte0, then goes to bit7 of byte1, etc.
55-
* @param {number} n The number of bits to peek. Must be a positive integer.
56-
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
57-
* @returns {number} The peeked bits, as an unsigned number.
58-
*/
59-
peekBits_mtl(n: number, opt_movePointers: any): number;
60-
/**
61-
* Peek at 16 bits from current position in the buffer.
62-
* Bit at (bytePtr,bitPtr) has the highest position in returning data.
63-
* Taken from getbits.hpp in unrar.
64-
* TODO: Move this out of BitStream and into unrar.
65-
* @returns {number}
66-
*/
67-
getBits(): number;
68-
/**
69-
* Reads n bits out of the stream, consuming them (moving the bit pointer).
70-
* @param {number} n The number of bits to read. Must be a positive integer.
71-
* @returns {number} The read bits, as an unsigned number.
72-
*/
73-
readBits(n: number): number;
74-
/**
75-
* This returns n bytes as a sub-array, advancing the pointer if movePointers
76-
* is true. Only use this for uncompressed blocks as this throws away remaining
77-
* bits in the current byte.
78-
* @param {number} n The number of bytes to peek. Must be a positive integer.
79-
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
80-
* @returns {Uint8Array} The subarray.
81-
*/
82-
peekBytes(n: number, opt_movePointers: any): Uint8Array;
83-
/**
84-
* @param {number} n The number of bytes to read.
85-
* @returns {Uint8Array} The subarray.
86-
*/
87-
readBytes(n: number): Uint8Array;
88-
};
89-
};
1+
/**
2+
* This object allows you to peek and consume bits and bytes out of a stream.
3+
* Note that this stream is optimized, and thus, will *NOT* throw an error if
4+
* the end of the stream is reached. Only use this in scenarios where you
5+
* already have all the bits you need.
6+
*
7+
* Bit reading always proceeds from the first byte in the buffer, to the
8+
* second byte, and so on. The MTL flag controls which bit is considered
9+
* first *inside* the byte.
10+
*
11+
* An Example for how Most-To-Least vs Least-to-Most mode works:
12+
*
13+
* If you have an ArrayBuffer with the following two Uint8s:
14+
* 185 (0b10111001) and 66 (0b01000010)
15+
* and you perform a series of readBits: 2 bits, then 3, then 5, then 6.
16+
*
17+
* A BitStream in "mtl" mode will yield the following:
18+
* - readBits(2) => 2 ('10')
19+
* - readBits(3) => 7 ('111')
20+
* - readBits(5) => 5 ('00101')
21+
* - readBits(6) => 2 ('000010')
22+
*
23+
* A BitStream in "ltm" mode will yield the following:
24+
* - readBits(2) => 1 ('01')
25+
* - readBits(3) => 6 ('110')
26+
* - readBits(5) => 21 ('10101')
27+
* - readBits(6) => 16 ('010000')
28+
*/
29+
export class BitStream {
30+
/**
31+
* @param {ArrayBuffer} ab An ArrayBuffer object or a Uint8Array.
32+
* @param {boolean} mtl Whether the stream reads bits from the byte starting with the
33+
* most-significant-bit (bit 7) to least-significant (bit 0). False means the direction is
34+
* from least-significant-bit (bit 0) to most-significant (bit 7).
35+
* @param {Number} opt_offset The offset into the ArrayBuffer
36+
* @param {Number} opt_length The length of this BitStream
37+
*/
38+
constructor(ab: ArrayBuffer, mtl: boolean, opt_offset: number, opt_length: number);
39+
/**
40+
* The bytes in the stream.
41+
* @type {Uint8Array}
42+
* @private
43+
*/
44+
private bytes;
45+
/**
46+
* The byte in the stream that we are currently on.
47+
* @type {Number}
48+
* @private
49+
*/
50+
private bytePtr;
51+
/**
52+
* The bit in the current byte that we will read next (can have values 0 through 7).
53+
* @type {Number}
54+
* @private
55+
*/
56+
private bitPtr;
57+
/**
58+
* An ever-increasing number.
59+
* @type {Number}
60+
* @private
61+
*/
62+
private bitsRead_;
63+
peekBits: (n: number, opt_movePointers: any) => number;
64+
/**
65+
* Returns how many bites have been read in the stream since the beginning of time.
66+
* @returns {number}
67+
*/
68+
getNumBitsRead(): number;
69+
/**
70+
* Returns how many bits are currently in the stream left to be read.
71+
* @returns {number}
72+
*/
73+
getNumBitsLeft(): number;
74+
/**
75+
* byte0 byte1 byte2 byte3
76+
* 7......0 | 7......0 | 7......0 | 7......0
77+
*
78+
* The bit pointer starts at least-significant bit (0) of byte0 and moves left until it reaches
79+
* bit7 of byte0, then jumps to bit0 of byte1, etc.
80+
* @param {number} n The number of bits to peek, must be a positive integer.
81+
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
82+
* @returns {number} The peeked bits, as an unsigned number.
83+
*/
84+
peekBits_ltm(n: number, opt_movePointers: any): number;
85+
/**
86+
* byte0 byte1 byte2 byte3
87+
* 7......0 | 7......0 | 7......0 | 7......0
88+
*
89+
* The bit pointer starts at bit7 of byte0 and moves right until it reaches
90+
* bit0 of byte0, then goes to bit7 of byte1, etc.
91+
* @param {number} n The number of bits to peek. Must be a positive integer.
92+
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
93+
* @returns {number} The peeked bits, as an unsigned number.
94+
*/
95+
peekBits_mtl(n: number, opt_movePointers: any): number;
96+
/**
97+
* Peek at 16 bits from current position in the buffer.
98+
* Bit at (bytePtr,bitPtr) has the highest position in returning data.
99+
* Taken from getbits.hpp in unrar.
100+
* TODO: Move this out of BitStream and into unrar.
101+
* @returns {number}
102+
*/
103+
getBits(): number;
104+
/**
105+
* Reads n bits out of the stream, consuming them (moving the bit pointer).
106+
* @param {number} n The number of bits to read. Must be a positive integer.
107+
* @returns {number} The read bits, as an unsigned number.
108+
*/
109+
readBits(n: number): number;
110+
/**
111+
* This returns n bytes as a sub-array, advancing the pointer if movePointers
112+
* is true. Only use this for uncompressed blocks as this throws away remaining
113+
* bits in the current byte.
114+
* @param {number} n The number of bytes to peek. Must be a positive integer.
115+
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
116+
* @returns {Uint8Array} The subarray.
117+
*/
118+
peekBytes(n: number, opt_movePointers: any): Uint8Array;
119+
/**
120+
* @param {number} n The number of bytes to read.
121+
* @returns {Uint8Array} The subarray.
122+
*/
123+
readBytes(n: number): Uint8Array;
124+
}
90125
//# sourceMappingURL=bitstream.d.ts.map

types/io/bitstream.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)