1
0
Fork 0
mirror of https://github.com/codedread/bitjs synced 2025-10-03 17:49:16 +02:00

Update Typescript types for 1.1.0

This commit is contained in:
Jeff Schiller 2023-05-28 10:50:31 -07:00
parent 63e84dadb0
commit 3120bba0df
12 changed files with 388 additions and 242 deletions

39
types/archive/decompress.d.ts vendored Normal file
View file

@ -0,0 +1,39 @@
/**
* Factory method that creates an unarchiver based on the byte signature found
* in the arrayBuffer.
* @param {ArrayBuffer} ab The ArrayBuffer to unarchive. Note that this ArrayBuffer
* must not be referenced after calling this method, as the ArrayBuffer is marked
* as Transferable and sent to a Worker thread once start() is called.
* @param {Object|string} options An optional object of options, or a string
* representing where the path to the unarchiver script files.
* @returns {Unarchiver}
*/
export function getUnarchiver(ab: ArrayBuffer, options?: any | string): Unarchiver;
export class Unzipper extends UnzipperInternal {
constructor(ab: any, options: any);
}
export class Unrarrer extends UnrarrerInternal {
constructor(ab: any, options: any);
}
export class Untarrer extends UntarrerInternal {
constructor(ab: any, options: any);
}
export type UnarchivedFile = {
filename: string;
fileData: Uint8Array;
};
import { Unarchiver } from "./decompress-internal.js";
import { UnarchiveAppendEvent } from "./decompress-internal.js";
import { UnarchiveErrorEvent } from "./decompress-internal.js";
import { UnarchiveEvent } from "./decompress-internal.js";
import { UnarchiveEventType } from "./decompress-internal.js";
import { UnarchiveExtractEvent } from "./decompress-internal.js";
import { UnarchiveFinishEvent } from "./decompress-internal.js";
import { UnarchiveInfoEvent } from "./decompress-internal.js";
import { UnarchiveProgressEvent } from "./decompress-internal.js";
import { UnarchiveStartEvent } from "./decompress-internal.js";
import { UnzipperInternal } from "./decompress-internal.js";
import { UnrarrerInternal } from "./decompress-internal.js";
import { UntarrerInternal } from "./decompress-internal.js";
export { UnarchiveAppendEvent, UnarchiveErrorEvent, UnarchiveEvent, UnarchiveEventType, UnarchiveExtractEvent, UnarchiveFinishEvent, UnarchiveInfoEvent, UnarchiveProgressEvent, UnarchiveStartEvent, Unarchiver };
//# sourceMappingURL=decompress.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../../archive/decompress.js"],"names":[],"mappings":"AAuEA;;;;;;;;;EASE;AACF,kCAPU,WAAW,YAGX,MAAO,MAAM,GAEX,UAAU,CAIrB;AAxBD;IACE,mCAAgE;CACjE;AAED;IACE,mCAAgE;CACjE;AAED;IACE,mCAAgE;CACjE;;cAjCa,MAAM;cACN,UAAU"}

3
types/index.d.ts vendored
View file

@ -1,11 +1,12 @@
export { findMimeType } from "./file/sniffer.js"; export { findMimeType } from "./file/sniffer.js";
export { BitBuffer } from "./io/bitbuffer.js";
export { BitStream } from "./io/bitstream.js"; export { BitStream } from "./io/bitstream.js";
export { ByteBuffer } from "./io/bytebuffer.js"; export { ByteBuffer } from "./io/bytebuffer.js";
export { ByteStream } from "./io/bytestream.js"; export { ByteStream } from "./io/bytestream.js";
export type ProbeStream = import('./codecs/codecs.js').ProbeStream; export type ProbeStream = import('./codecs/codecs.js').ProbeStream;
export type ProbeFormat = import('./codecs/codecs.js').ProbeFormat; export type ProbeFormat = import('./codecs/codecs.js').ProbeFormat;
export type ProbeInfo = import('./codecs/codecs.js').ProbeInfo; export type ProbeInfo = import('./codecs/codecs.js').ProbeInfo;
export { UnarchiveEvent, UnarchiveEventType, UnarchiveInfoEvent, UnarchiveErrorEvent, UnarchiveStartEvent, UnarchiveFinishEvent, UnarchiveProgressEvent, UnarchiveExtractEvent, Unarchiver, Unzipper, Unrarrer, Untarrer, getUnarchiver } from "./archive/archive.js"; export { UnarchiveEvent, UnarchiveEventType, UnarchiveInfoEvent, UnarchiveErrorEvent, UnarchiveStartEvent, UnarchiveFinishEvent, UnarchiveProgressEvent, UnarchiveExtractEvent, Unarchiver, Unzipper, Unrarrer, Untarrer, getUnarchiver } from "./archive/decompress.js";
export { getFullMIMEString, getShortMIMEString } from "./codecs/codecs.js"; export { getFullMIMEString, getShortMIMEString } from "./codecs/codecs.js";
export { convertWebPtoPNG, convertWebPtoJPG } from "./image/webp-shim/webp-shim.js"; export { convertWebPtoPNG, convertWebPtoJPG } from "./image/webp-shim/webp-shim.js";
//# sourceMappingURL=index.d.ts.map //# sourceMappingURL=index.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";;;;0BASa,OAAO,oBAAoB,EAAE,WAAW;0BAGxC,OAAO,oBAAoB,EAAE,WAAW;wBAGxC,OAAO,oBAAoB,EAAE,SAAS"} {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";;;;;0BASa,OAAO,oBAAoB,EAAE,WAAW;0BAGxC,OAAO,oBAAoB,EAAE,WAAW;wBAGxC,OAAO,oBAAoB,EAAE,SAAS"}

55
types/io/bitbuffer.d.ts vendored Normal file
View file

@ -0,0 +1,55 @@
/**
* A write-only Bit buffer which uses a Uint8Array as a backing store.
*/
export class BitBuffer {
/**
* @param {number} numBytes The number of bytes to allocate.
* @param {boolean} mtl The bit-packing mode. True means pack bits from most-significant (7) to
* least-significant (0). Defaults false: least-significant (0) to most-significant (8).
*/
constructor(numBytes: number, mtl?: boolean);
/**
* @type {Uint8Array}
* @public
*/
public data: Uint8Array;
/**
* Whether we pack bits from most-significant-bit to least. Defaults false (least-to-most
* significant bit packing).
* @type {boolean}
* @private
*/
private mtl;
/**
* The current byte we are filling with bits.
* @type {number}
* @public
*/
public bytePtr: number;
/**
* Points at the bit within the current byte where the next bit will go. This number ranges
* from 0 to 7 and the direction of packing is indicated by the mtl property.
* @type {number}
* @public
*/
public bitPtr: number;
/** @returns {boolean} */
getPackingDirection(): boolean;
/**
* Sets the bit-packing direction. Default (false) is least-significant-bit (0) to
* most-significant (7). Changing the bit-packing direction when the bit pointer is in the
* middle of a byte will fill the rest of that byte with 0s using the current bit-packing
* direction and then set the bit pointer to the appropriate bit of the next byte. If there
* are no more bytes left in this buffer, it will throw an error.
*/
setPackingDirection(mtl?: boolean): void;
/**
* writeBits(3, 6) is the same as writeBits(0b000011, 6).
* Will throw an error (without writing) if this would over-flow the buffer.
* @param {number} val The bits to pack into the buffer. Negative values are not allowed.
* @param {number} numBits Must be positive, non-zero and less or equal to than 53, since
* JavaScript can only support 53-bit integers.
*/
writeBits(val: number, numBits: number): void;
}
//# sourceMappingURL=bitbuffer.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"bitbuffer.d.ts","sourceRoot":"","sources":["../../io/bitbuffer.js"],"names":[],"mappings":"AAuBA;;GAEG;AACH;IACE;;;;OAIG;IACH,sBAJW,MAAM,QACN,OAAO,EAoCjB;IA5BC;;;OAGG;IACH,aAHU,UAAU,CAGgB;IAEpC;;;;;OAKG;IACH,YAAc;IAEd;;;;OAIG;IACH,gBAHU,MAAM,CAGA;IAEhB;;;;;OAKG;IACH,eAHU,MAAM,CAGc;IAGhC,yBAAyB;IACzB,uBADc,OAAO,CAGpB;IAED;;;;;;OAMG;IACH,yCAkBC;IAED;;;;;;OAMG;IACH,eAJW,MAAM,WACN,MAAM,QA4FhB;CACF"}

View file

@ -1,29 +1,65 @@
export const BitStream: { /**
new (ab: ArrayBuffer, mtl: boolean, opt_offset: number, opt_length: number): { * This object allows you to peek and consume bits and bytes out of a stream.
* Note that this stream is optimized, and thus, will *NOT* throw an error if
* the end of the stream is reached. Only use this in scenarios where you
* already have all the bits you need.
*
* Bit reading always proceeds from the first byte in the buffer, to the
* second byte, and so on. The MTL flag controls which bit is considered
* first *inside* the byte.
*
* An Example for how Most-To-Least vs Least-to-Most mode works:
*
* If you have an ArrayBuffer with the following two Uint8s:
* 185 (0b10111001) and 66 (0b01000010)
* and you perform a series of readBits: 2 bits, then 3, then 5, then 6.
*
* A BitStream in "mtl" mode will yield the following:
* - readBits(2) => 2 ('10')
* - readBits(3) => 7 ('111')
* - readBits(5) => 5 ('00101')
* - readBits(6) => 2 ('000010')
*
* A BitStream in "ltm" mode will yield the following:
* - readBits(2) => 1 ('01')
* - readBits(3) => 6 ('110')
* - readBits(5) => 21 ('10101')
* - readBits(6) => 16 ('010000')
*/
export class BitStream {
/**
* @param {ArrayBuffer} ab An ArrayBuffer object or a Uint8Array.
* @param {boolean} mtl Whether the stream reads bits from the byte starting with the
* most-significant-bit (bit 7) to least-significant (bit 0). False means the direction is
* from least-significant-bit (bit 0) to most-significant (bit 7).
* @param {Number} opt_offset The offset into the ArrayBuffer
* @param {Number} opt_length The length of this BitStream
*/
constructor(ab: ArrayBuffer, mtl: boolean, opt_offset: number, opt_length: number);
/** /**
* The bytes in the stream. * The bytes in the stream.
* @type {Uint8Array} * @type {Uint8Array}
* @private * @private
*/ */
bytes: Uint8Array; private bytes;
/** /**
* The byte in the stream that we are currently on. * The byte in the stream that we are currently on.
* @type {Number} * @type {Number}
* @private * @private
*/ */
bytePtr: number; private bytePtr;
/** /**
* The bit in the current byte that we will read next (can have values 0 through 7). * The bit in the current byte that we will read next (can have values 0 through 7).
* @type {Number} * @type {Number}
* @private * @private
*/ */
bitPtr: number; private bitPtr;
/** /**
* An ever-increasing number. * An ever-increasing number.
* @type {Number} * @type {Number}
* @private * @private
*/ */
bitsRead_: number; private bitsRead_;
peekBits: (n: number, opt_movePointers: any) => number; peekBits: (n: number, opt_movePointers: any) => number;
/** /**
* Returns how many bites have been read in the stream since the beginning of time. * Returns how many bites have been read in the stream since the beginning of time.
@ -85,6 +121,5 @@ export const BitStream: {
* @returns {Uint8Array} The subarray. * @returns {Uint8Array} The subarray.
*/ */
readBytes(n: number): Uint8Array; readBytes(n: number): Uint8Array;
}; }
};
//# sourceMappingURL=bitstream.d.ts.map //# sourceMappingURL=bitstream.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"bitstream.d.ts","sourceRoot":"","sources":["../../io/bitstream.js"],"names":[],"mappings":"AACA;aA8Ce,WAAW,OACX,OAAO;QAchB;;;;WAIG;eAFO,UAAU;QAKpB;;;;WAIG;;QAGH;;;;WAIG;;QAGH;;;;WAIG;;sBAuFM,MAAM,4BAEJ,MAAM;QAnFnB;;;WAGG;0BADU,MAAM;QAMnB;;;WAGG;0BADU,MAAM;QAOnB;;;;;;;;;WASG;wBAHQ,MAAM,0BAEJ,MAAM;QAkDnB;;;;;;;;;WASG;wBAHQ,MAAM,0BAEJ,MAAM;QAgDnB;;;;;;WAMG;mBADU,MAAM;QAQnB;;;;WAIG;oBAFQ,MAAM,GACJ,MAAM;QAMnB;;;;;;;WAOG;qBAHQ,MAAM,0BAEJ,UAAU;QAmDvB;;;WAGG;qBAFQ,MAAM,GACJ,UAAU;;EAQtB"} {"version":3,"file":"bitstream.d.ts","sourceRoot":"","sources":["../../io/bitstream.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IACE;;;;;;;OAOG;IACH,gBAPW,WAAW,OACX,OAAO,0CA2CjB;IA7BC;;;;OAIG;IACH,cAA+C;IAE/C;;;;OAIG;IACH,gBAAgB;IAEhB;;;;OAIG;IACH,eAAe;IAEf;;;;OAIG;IACH,kBAAkB;IAElB,cAoFS,MAAM,4BAEJ,MAAM,CAtF0C;IAG7D;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAKlB;IAED;;;;;;;;;OASG;IACH,gBAJW,MAAM,0BAEJ,MAAM,CAgDlB;IAED;;;;;;;;;OASG;IACH,gBAJW,MAAM,0BAEJ,MAAM,CA8ClB;IAED;;;;;;OAMG;IACH,WAFa,MAAM,CAMlB;IAED;;;;OAIG;IACH,YAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,aAJW,MAAM,0BAEJ,UAAU,CAiDtB;IAED;;;OAGG;IACH,aAHW,MAAM,GACJ,UAAU,CAItB;CACF"}

View file

@ -1,15 +1,21 @@
export const ByteBuffer: { /**
new (numBytes: number): { * A write-only Byte buffer which uses a Uint8 Typed Array as a backing store.
*/
export class ByteBuffer {
/**
* @param {number} numBytes The number of bytes to allocate.
*/
constructor(numBytes: number);
/** /**
* @type {Uint8Array} * @type {Uint8Array}
* @public * @public
*/ */
data: Uint8Array; public data: Uint8Array;
/** /**
* @type {number} * @type {number}
* @public * @public
*/ */
ptr: number; public ptr: number;
/** /**
* @param {number} b The byte to insert. * @param {number} b The byte to insert.
*/ */
@ -36,6 +42,5 @@ export const ByteBuffer: {
* @param {string} str The ASCII string to write. * @param {string} str The ASCII string to write.
*/ */
writeASCIIString(str: string): void; writeASCIIString(str: string): void;
}; }
};
//# sourceMappingURL=bytebuffer.d.ts.map //# sourceMappingURL=bytebuffer.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"bytebuffer.d.ts","sourceRoot":"","sources":["../../io/bytebuffer.js"],"names":[],"mappings":"AACA;mBAkBe,MAAM;QAOf;;;WAGG;cAFO,UAAU;QAKpB;;;WAGG;aAFO,MAAM;QAOlB;;WAEG;sBADQ,MAAM;QAOjB;;WAEG;2BADQ,MAAO,MAAM,CAAC,GAAC,UAAU,GAAC,SAAS;QAQ9C;;;;;WAKG;yBAFQ,MAAM,YACN,MAAM;QAyBjB;;;;;WAKG;+BAFQ,MAAM,YACN,MAAM;QAuBjB;;WAEG;8BADQ,MAAM;;EAchB"} {"version":3,"file":"bytebuffer.d.ts","sourceRoot":"","sources":["../../io/bytebuffer.js"],"names":[],"mappings":"AAWA;;GAEG;AACH;IACE;;OAEG;IACH,sBAFW,MAAM,EAkBhB;IAXC;;;OAGG;IACH,aAHU,UAAU,CAGgB;IAEpC;;;OAGG;IACH,YAHU,MAAM,CAGJ;IAId;;OAEG;IACH,cAFW,MAAM,QAKhB;IAED;;OAEG;IACH,mBAFW,MAAO,MAAM,CAAC,GAAC,UAAU,GAAC,SAAS,QAM7C;IAED;;;;;OAKG;IACH,iBAHW,MAAM,YACN,MAAM,QAuBhB;IAED;;;;;OAKG;IACH,uBAHW,MAAM,YACN,MAAM,QAqBhB;IAED;;OAEG;IACH,sBAFW,MAAM,QAUhB;CACF"}

View file

@ -1,29 +1,39 @@
export const ByteStream: { /**
new (ab: ArrayBuffer, opt_offset?: number | undefined, opt_length?: number | undefined): { * This object allows you to peek and consume bytes as numbers and strings out
* of a stream. More bytes can be pushed into the back of the stream via the
* push() method.
*/
export class ByteStream {
/**
* @param {ArrayBuffer} ab The ArrayBuffer object.
* @param {number=} opt_offset The offset into the ArrayBuffer
* @param {number=} opt_length The length of this ByteStream
*/
constructor(ab: ArrayBuffer, opt_offset?: number | undefined, opt_length?: number | undefined);
/** /**
* The current page of bytes in the stream. * The current page of bytes in the stream.
* @type {Uint8Array} * @type {Uint8Array}
* @private * @private
*/ */
bytes: Uint8Array; private bytes;
/** /**
* The next pages of bytes in the stream. * The next pages of bytes in the stream.
* @type {Array<Uint8Array>} * @type {Array<Uint8Array>}
* @private * @private
*/ */
pages_: Array<Uint8Array>; private pages_;
/** /**
* The byte in the current page that we will read next. * The byte in the current page that we will read next.
* @type {Number} * @type {Number}
* @private * @private
*/ */
ptr: number; private ptr;
/** /**
* An ever-increasing number. * An ever-increasing number.
* @type {Number} * @type {Number}
* @private * @private
*/ */
bytesRead_: number; private bytesRead_;
/** /**
* Returns how many bytes have been read in the stream since the beginning of time. * Returns how many bytes have been read in the stream since the beginning of time.
*/ */
@ -39,7 +49,7 @@ export const ByteStream: {
* @param {number} n Number of bytes to increment. * @param {number} n Number of bytes to increment.
* @private * @private
*/ */
movePointer_(n: number): void; private movePointer_;
/** /**
* Peeks at the next n bytes as an unsigned number but does not advance the * Peeks at the next n bytes as an unsigned number but does not advance the
* pointer. * pointer.
@ -103,7 +113,6 @@ export const ByteStream: {
* Creates a new ByteStream from this ByteStream that can be read / peeked. * Creates a new ByteStream from this ByteStream that can be read / peeked.
* @returns {ByteStream} A clone of this ByteStream. * @returns {ByteStream} A clone of this ByteStream.
*/ */
tee(): any; tee(): ByteStream;
}; }
};
//# sourceMappingURL=bytestream.d.ts.map //# sourceMappingURL=bytestream.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"bytestream.d.ts","sourceRoot":"","sources":["../../io/bytestream.js"],"names":[],"mappings":"AACA;aA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