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

Correct some typos, expose codecs in the main module (woops), and provide Typescript types (d.ts files)

This commit is contained in:
Jeff Schiller 2022-10-30 16:54:53 -07:00
parent 28e8a8e449
commit d5971c0fdb
23 changed files with 701 additions and 5 deletions

39
types/archive/archive.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=archive.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../archive/archive.js"],"names":[],"mappings":"AA0EA;;;;;;;;;GASG;AACH,kCAPW,WAAW,YAGX,MAAO,MAAM,GAEX,UAAU,CAItB;AAxBD;IACE,mCAAgE;CACjE;AAED;IACE,mCAAgE;CACjE;AAED;IACE,mCAAgE;CACjE;;cAjCa,MAAM;cACN,UAAU"}

245
types/archive/decompress-internal.d.ts vendored Normal file
View file

@ -0,0 +1,245 @@
/**
* Factory method that creates an unarchiver based on the byte signature found
* in the arrayBuffer.
* @param {ArrayBuffer} ab
* @param {Function(string):Worker} createWorkerFn A function that creates a Worker from a script file.
* @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 getUnarchiverInternal(ab: ArrayBuffer, createWorkerFn: any, options?: any | string): Unarchiver;
export namespace UnarchiveEventType {
const START: string;
const APPEND: string;
const PROGRESS: string;
const EXTRACT: string;
const FINISH: string;
const INFO: string;
const ERROR: string;
}
/**
* An unarchive event.
*/
export class UnarchiveEvent {
/**
* @param {string} type The event type.
*/
constructor(type: string);
/**
* The event type.
* @type {string}
*/
type: string;
}
/**
* Updates all Archiver listeners that an append has occurred.
*/
export class UnarchiveAppendEvent extends UnarchiveEvent {
/**
* @param {number} numBytes The number of bytes appended.
*/
constructor(numBytes: number);
/**
* The number of appended bytes.
* @type {number}
*/
numBytes: number;
}
/**
* Useful for passing info up to the client (for debugging).
*/
export class UnarchiveInfoEvent extends UnarchiveEvent {
/**
* The information message.
* @type {string}
*/
msg: string;
}
/**
* An unrecoverable error has occured.
*/
export class UnarchiveErrorEvent extends UnarchiveEvent {
/**
* The information message.
* @type {string}
*/
msg: string;
}
/**
* Start event.
*/
export class UnarchiveStartEvent extends UnarchiveEvent {
constructor();
}
/**
* Finish event.
*/
export class UnarchiveFinishEvent extends UnarchiveEvent {
/**
* @param {Object} metadata A collection fo metadata about the archive file.
*/
constructor(metadata?: any);
metadata: any;
}
/**
* Progress event.
*/
export class UnarchiveProgressEvent extends UnarchiveEvent {
/**
* @param {string} currentFilename
* @param {number} currentFileNumber
* @param {number} currentBytesUnarchivedInFile
* @param {number} currentBytesUnarchived
* @param {number} totalUncompressedBytesInArchive
* @param {number} totalFilesInArchive
* @param {number} totalCompressedBytesRead
*/
constructor(currentFilename: string, currentFileNumber: number, currentBytesUnarchivedInFile: number, currentBytesUnarchived: number, totalUncompressedBytesInArchive: number, totalFilesInArchive: number, totalCompressedBytesRead: number);
currentFilename: string;
currentFileNumber: number;
currentBytesUnarchivedInFile: number;
totalFilesInArchive: number;
currentBytesUnarchived: number;
totalUncompressedBytesInArchive: number;
totalCompressedBytesRead: number;
}
/**
* Extract event.
*/
export class UnarchiveExtractEvent extends UnarchiveEvent {
/**
* @param {UnarchivedFile} unarchivedFile
*/
constructor(unarchivedFile: UnarchivedFile);
/**
* @type {UnarchivedFile}
*/
unarchivedFile: UnarchivedFile;
}
/**
* Base class for all Unarchivers.
* TODO: When EventTarget constructors are broadly supported, make this extend
* EventTarget and remove event listener code.
* https://caniuse.com/#feat=mdn-api_eventtarget_eventtarget
*/
export class Unarchiver {
/**
* @param {ArrayBuffer} arrayBuffer The Array Buffer. Note that this ArrayBuffer must not be
* referenced once it is sent to the Unarchiver, since it is marked as Transferable and sent
* to the Worker.
* @param {Function(string):Worker} createWorkerFn A function that creates a Worker from a script file.
* @param {Object|string} options An optional object of options, or a string representing where
* the BitJS files are located. The string version of this argument is deprecated.
* Available options:
* 'pathToBitJS': A string indicating where the BitJS files are located.
* 'debug': A boolean where true indicates that the archivers should log debug output.
*/
constructor(arrayBuffer: ArrayBuffer, createWorkerFn: any, options?: any | string);
/**
* The ArrayBuffer object.
* @type {ArrayBuffer}
* @protected
*/
protected ab: ArrayBuffer;
/**
* A factory method that creates a Worker that does the unarchive work.
* @type {Function(string): Worker}
* @private
*/
private createWorkerFn_;
/**
* The path to the BitJS files.
* @type {string}
* @private
*/
private pathToBitJS_;
/**
* @orivate
* @type {boolean}
*/
debugMode_: boolean;
/**
* A map from event type to an array of listeners.
* @private
* @type {Map.<string, Array>}
*/
private listeners_;
/**
* Private web worker initialized during start().
* @private
* @type {Worker}
*/
private worker_;
/**
* This method must be overridden by the subclass to return the script filename.
* @returns {string} The MIME type of the archive.
* @protected.
*/
protected getMIMEType(): string;
/**
* This method must be overridden by the subclass to return the script filename.
* @returns {string} The script filename.
* @protected.
*/
protected getScriptFileName(): string;
/**
* Adds an event listener for UnarchiveEvents.
*
* @param {string} Event type.
* @param {function} An event handler function.
*/
addEventListener(type: any, listener: any): void;
/**
* Removes an event listener.
*
* @param {string} Event type.
* @param {EventListener|function} An event listener or handler function.
*/
removeEventListener(type: any, listener: any): void;
/**
* Create an UnarchiveEvent out of the object sent back from the Worker.
* @param {Object} obj
* @returns {UnarchiveEvent}
* @private
*/
private createUnarchiveEvent_;
/**
* Receive an event and pass it to the listener functions.
*
* @param {Object} obj
* @private
*/
private handleWorkerEvent_;
/**
* Starts the unarchive in a separate Web Worker thread and returns immediately.
*/
start(): void;
/**
* Adds more bytes to the unarchiver's Worker thread.
* @param {ArrayBuffer} ab The ArrayBuffer with more bytes in it. If opt_transferable is
* set to true, this ArrayBuffer must not be referenced after calling update(), since it
* is marked as Transferable and sent to the Worker.
* @param {boolean=} opt_transferable Optional boolean whether to mark this ArrayBuffer
* as a Tranferable object, which means it can no longer be referenced outside of
* the Worker thread.
*/
update(ab: ArrayBuffer, opt_transferable?: boolean | undefined): void;
/**
* Terminates the Web Worker for this Unarchiver and returns immediately.
*/
stop(): void;
}
export class UnzipperInternal extends Unarchiver {
constructor(arrayBuffer: any, createWorkerFn: any, options: any);
}
export class UnrarrerInternal extends Unarchiver {
constructor(arrayBuffer: any, createWorkerFn: any, options: any);
}
export class UntarrerInternal extends Unarchiver {
constructor(arrayBuffer: any, createWorkerFn: any, options: any);
}
export type UnarchivedFile = {
filename: string;
fileData: Uint8Array;
};
//# sourceMappingURL=decompress-internal.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"decompress-internal.d.ts","sourceRoot":"","sources":["../../archive/decompress-internal.js"],"names":[],"mappings":"AAgbA;;;;;;;;GAQG;AACF,0CANU,WAAW,iCAEX,MAAO,MAAM,GAEX,UAAU,CAkBtB;;;;;;;;;;AAzaD;;GAEG;AACF;IACC;;OAEG;IACH,kBAFW,MAAM,EAQhB;IALC;;;OAGG;IACH,MAFU,MAAM,CAEA;CAEnB;AAED;;GAEG;AACF;IACC;;OAEG;IACH,sBAFW,MAAM,EAUhB;IALC;;;OAGG;IACH,UAFU,MAAM,CAEQ;CAE3B;AAED;;GAEG;AACH;IAOI;;;OAGG;IACH,KAFU,MAAM,CAEF;CAEjB;AAED;;GAEG;AACH;IAOI;;;OAGG;IACH,KAFU,MAAM,CAEF;CAEjB;AAED;;GAEG;AACH;IACE,cAEC;CACF;AAED;;GAEG;AACH;IACE;;OAEG;IACH,4BAGC;IADC,cAAwB;CAE3B;AAED;;GAEG;AACH;IACE;;;;;;;;OAQG;IACH,6BARW,MAAM,qBACN,MAAM,gCACN,MAAM,0BACN,MAAM,mCACN,MAAM,uBACN,MAAM,4BACN,MAAM,EAchB;IAPC,wBAAsC;IACtC,0BAA0C;IAC1C,qCAAgE;IAChE,4BAA8C;IAC9C,+BAAoD;IACpD,wCAAsE;IACtE,iCAAwD;CAE3D;AAED;;GAEG;AACH;IACE;;OAEG;IACH,4BAFW,cAAc,EASxB;IAJC;;OAEG;IACH,gBAFU,cAAc,CAEY;CAEvC;AAED;;;;;GAKG;AACF;IACC;;;;;;;;;;OAUG;IACH,yBAVW,WAAW,iCAIX,MAAO,MAAM,EAwDvB;IA3CC;;;;OAIG;IACH,cAHU,WAAW,CAGA;IAErB;;;;OAIG;IACH,wBAAqC;IAErC;;;;OAIG;IACH,qBAA8C;IAE9C;;;OAGG;IACH,YAFU,OAAO,CAEkB;IAEnC;;;;OAIG;IACH,mBAAoB;IAKpB;;;;OAIG;IACH,gBAAmB;IAGrB;;;;OAIG;IACH,yBAHa,MAAM,CAKlB;IAED;;;;OAIG;IACH,+BAHa,MAAM,CAKlB;IAED;;;;;OAKG;IACH,iDAMC;IAED;;;;;OAKG;IACH,oDAOC;IAED;;;;;OAKG;IACH,8BAsBC;IAED;;;;;OAKG;IACH,2BAYC;IAED;;OAEG;IACH,cA2BC;IAID;;;;;;;;OAQG;IACH,WAPW,WAAW,qBAGX,OAAO,oBAkBjB;IAED;;OAEG;IACH,aAIC;CACF;AAED;IACE,iEAEC;CAIF;AAED;IACE,iEAEC;CAIF;AAED;IACE,iEAEC;CAIF;;cA/Za,MAAM;cACN,UAAU"}

97
types/codecs/codecs.d.ts vendored Normal file
View file

@ -0,0 +1,97 @@
/**
* This module helps interpret ffprobe -print_format json output.
* Its coverage is pretty sparse right now, so send me pull requests!
*/
/**
* @typedef ProbeStream ffprobe -show_streams -print_format json. Only the fields we care about.
* @property {number} index
* @property {string} codec_name
* @property {string} codec_long_name
* @property {string} profile
* @property {string} codec_type Either 'audio' or 'video'.
* @property {string} codec_tag_string
* @property {string} id
* @property {number?} level
* @property {number?} width
* @property {number?} height
* @property {string} r_frame_rate Like "60000/1001"
*/
/**
* @typedef ProbeFormat ffprobe -show_format -print_format json. Only the fields we care about.
* @property {string} filename
* @property {string} format_name
* @property {string} duration Number of seconds, as a string like "473.506367".
* @property {string} size Number of bytes, as a string.
* @property {string} bit_rate Bit rate, as a string.
*/
/**
* @typedef ProbeInfo ffprobe -show_format -show_streams -print_format json
* @property {ProbeStream[]} streams
* @property {ProbeFormat} format
*/
/**
* TODO: Reconcile this with file/sniffer.js findMimeType() which does signature matching.
* @param {ProbeInfo} info
* @returns {string}
*/
export function getShortMIMEString(info: ProbeInfo): string;
/**
* Accepts the ffprobe JSON output and returns an ISO MIME string with parameters (RFC6381), such
* as 'video/mp4; codecs="avc1.4D4028, mp4a.40.2"'. This string should be suitable to be used on
* the server as the Content-Type header of a media stream which can subsequently be used on the
* client as the type value of a SourceBuffer object `mediaSource.addSourceBuffer(contentType)`.
* NOTE: For now, this method fails hard (throws an error) when it encounters a format/codec it
* does not recognize. Please file a bug or send a PR.
* @param {ProbeInfo} info
* @returns {string}
*/
export function getFullMIMEString(info: ProbeInfo): string;
/**
* ffprobe -show_streams -print_format json. Only the fields we care about.
*/
export type ProbeStream = {
index: number;
codec_name: string;
codec_long_name: string;
profile: string;
/**
* Either 'audio' or 'video'.
*/
codec_type: string;
codec_tag_string: string;
id: string;
level: number | null;
width: number | null;
height: number | null;
/**
* Like "60000/1001"
*/
r_frame_rate: string;
};
/**
* ffprobe -show_format -print_format json. Only the fields we care about.
*/
export type ProbeFormat = {
filename: string;
format_name: string;
/**
* Number of seconds, as a string like "473.506367".
*/
duration: string;
/**
* Number of bytes, as a string.
*/
size: string;
/**
* Bit rate, as a string.
*/
bit_rate: string;
};
/**
* ffprobe -show_format -show_streams -print_format json
*/
export type ProbeInfo = {
streams: ProbeStream[];
format: ProbeFormat;
};
//# sourceMappingURL=codecs.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../codecs/codecs.js"],"names":[],"mappings":"AAQA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;;;GAOG;AAEH;;;;GAIG;AAEH;;;;GAIG;AACH,yCAHW,SAAS,GACP,MAAM,CAuClB;AAED;;;;;;;;;GASG;AACH,wCAHW,SAAS,GACP,MAAM,CAyBlB;;;;;WAzGa,MAAM;gBACN,MAAM;qBACN,MAAM;aACN,MAAM;;;;gBACN,MAAM;sBACN,MAAM;QACN,MAAM;WACN,MAAM;WACN,MAAM;YACN,MAAM;;;;kBACN,MAAM;;;;;;cAKN,MAAM;iBACN,MAAM;;;;cACN,MAAM;;;;UACN,MAAM;;;;cACN,MAAM;;;;;;aAKN,WAAW,EAAE;YACb,WAAW"}

12
types/file/sniffer.d.ts vendored Normal file
View file

@ -0,0 +1,12 @@
/**
* This function initializes the byte tree. It is lazily called upon findMimeType(), but if you care
* about when the tree initializes (like in startup, etc), you can call it yourself here.
*/
export function initialize(): void;
/**
* Finds the likely MIME type represented by the ArrayBuffer.
* @param {ArrayBuffer} ab
* @returns {string} The MIME type of the buffer, or undefined.
*/
export function findMimeType(ab: ArrayBuffer): string;
//# sourceMappingURL=sniffer.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"sniffer.d.ts","sourceRoot":"","sources":["../../file/sniffer.js"],"names":[],"mappings":"AA+DA;;;GAGG;AACH,mCAiCC;AAED;;;;GAIG;AACH,iCAHW,WAAW,GACT,MAAM,CAqBlB"}

11
types/image/webp-shim/webp-shim.d.ts vendored Normal file
View file

@ -0,0 +1,11 @@
/**
* @param {ArrayBuffer|Uint8Array} webpBuffer The byte array containing the WebP image bytes.
* @returns {Promise<ArrayBuffer>} A Promise resolving to a byte array containing the PNG bytes.
*/
export function convertWebPtoPNG(webpBuffer: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>;
/**
* @param {ArrayBuffer|Uint8Array} webpBuffer The byte array containing the WebP image bytes.
* @returns {Promise<ArrayBuffer>} A Promise resolving to a byte array containing the JPG bytes.
*/
export function convertWebPtoJPG(webpBuffer: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>;
//# sourceMappingURL=webp-shim.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"webp-shim.d.ts","sourceRoot":"","sources":["../../../image/webp-shim/webp-shim.js"],"names":[],"mappings":"AAgDA;;;GAGG;AACH,6CAHW,WAAW,GAAC,UAAU,GACpB,QAAQ,WAAW,CAAC,CAyBhC;AAED;;;GAGG;AACH,6CAHW,WAAW,GAAC,UAAU,GACpB,QAAQ,WAAW,CAAC,CAyBhC"}

11
types/index.d.ts vendored Normal file
View file

@ -0,0 +1,11 @@
export { findMimeType } from "./file/sniffer.js";
export { BitStream } from "./io/bitstream.js";
export { ByteBuffer } from "./io/bytebuffer.js";
export { ByteStream } from "./io/bytestream.js";
export type ProbeStream = import('./codecs/codecs.js').ProbeStream;
export type ProbeFormat = import('./codecs/codecs.js').ProbeFormat;
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 { getFullMIMEString, getShortMIMEString } from "./codecs/codecs.js";
export { convertWebPtoPNG, convertWebPtoJPG } from "./image/webp-shim/webp-shim.js";
//# sourceMappingURL=index.d.ts.map

1
types/index.d.ts.map Normal file
View file

@ -0,0 +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"}

87
types/io/bitstream.d.ts vendored Normal file
View file

@ -0,0 +1,87 @@
export const BitStream: {
new (ab: ArrayBuffer, mtl: boolean, opt_offset: number, opt_length: number): {
/**
* The bytes in the stream.
* @type {Uint8Array}
* @private
*/
bytes: Uint8Array;
/**
* The byte in the stream that we are currently on.
* @type {Number}
* @private
*/
bytePtr: number;
/**
* The bit in the current byte that we will read next (can have values 0 through 7).
* @type {Number}
* @private
*/
bitPtr: number;
/**
* An ever-increasing number.
* @type {Number}
* @private
*/
bitsRead_: number;
peekBits: (n: number, opt_movePointers: any) => number;
/**
* Returns how many bites have been read in the stream since the beginning of time.
*/
getNumBitsRead(): number;
/**
* Returns how many bits are currently in the stream left to be read.
*/
getNumBitsLeft(): number;
/**
* byte0 byte1 byte2 byte3
* 7......0 | 7......0 | 7......0 | 7......0
*
* The bit pointer starts at least-significant bit (0) of byte0 and moves left until it reaches
* bit7 of byte0, then jumps to bit0 of byte1, etc.
* @param {number} n The number of bits to peek, must be a positive integer.
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
* @returns {number} The peeked bits, as an unsigned number.
*/
peekBits_ltm(n: number, opt_movePointers: any): number;
/**
* byte0 byte1 byte2 byte3
* 7......0 | 7......0 | 7......0 | 7......0
*
* The bit pointer starts at bit7 of byte0 and moves right until it reaches
* bit0 of byte0, then goes to bit7 of byte1, etc.
* @param {number} n The number of bits to peek. Must be a positive integer.
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
* @returns {number} The peeked bits, as an unsigned number.
*/
peekBits_mtl(n: number, opt_movePointers: any): number;
/**
* Peek at 16 bits from current position in the buffer.
* Bit at (bytePtr,bitPtr) has the highest position in returning data.
* Taken from getbits.hpp in unrar.
* TODO: Move this out of BitStream and into unrar.
*/
getBits(): number;
/**
* Reads n bits out of the stream, consuming them (moving the bit pointer).
* @param {number} n The number of bits to read. Must be a positive integer.
* @returns {number} The read bits, as an unsigned number.
*/
readBits(n: number): number;
/**
* This returns n bytes as a sub-array, advancing the pointer if movePointers
* is true. Only use this for uncompressed blocks as this throws away remaining
* bits in the current byte.
* @param {number} n The number of bytes to peek. Must be a positive integer.
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
* @returns {Uint8Array} The subarray.
*/
peekBytes(n: number, opt_movePointers: any): Uint8Array;
/**
* @param {number} n The number of bytes to read.
* @returns {Uint8Array} The subarray.
*/
readBytes(n: number): Uint8Array;
};
};
//# sourceMappingURL=bitstream.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"bitstream.d.ts","sourceRoot":"","sources":["../../io/bitstream.js"],"names":[],"mappings":"AACA;aAwBe,WAAW,OACX,OAAO;QAchB;;;;WAIG;eAFO,UAAU;QAKpB;;;;WAIG;;QAGH;;;;WAIG;;QAGH;;;;WAIG;;sBAqFM,MAAM,4BAEJ,MAAM;QAjFnB;;WAEG;;QAKH;;WAEG;;QAMH;;;;;;;;;WASG;wBAHQ,MAAM,0BAEJ,MAAM;QAkDnB;;;;;;;;;WASG;wBAHQ,MAAM,0BAEJ,MAAM;QAgDnB;;;;;WAKG;;QAOH;;;;WAIG;oBAFQ,MAAM,GACJ,MAAM;QAMnB;;;;;;;WAOG;qBAHQ,MAAM,0BAEJ,UAAU;QAmDvB;;;WAGG;qBAFQ,MAAM,GACJ,UAAU;;EAQtB"}

41
types/io/bytebuffer.d.ts vendored Normal file
View file

@ -0,0 +1,41 @@
export const ByteBuffer: {
new (numBytes: number): {
/**
* @type {Uint8Array}
* @public
*/
data: Uint8Array;
/**
* @type {number}
* @public
*/
ptr: number;
/**
* @param {number} b The byte to insert.
*/
insertByte(b: number): void;
/**
* @param {Array.<number>|Uint8Array|Int8Array} bytes The bytes to insert.
*/
insertBytes(bytes: Array<number> | Uint8Array | Int8Array): void;
/**
* Writes an unsigned number into the next n bytes. If the number is too large
* to fit into n bytes or is negative, an error is thrown.
* @param {number} num The unsigned number to write.
* @param {number} numBytes The number of bytes to write the number into.
*/
writeNumber(num: number, numBytes: number): void;
/**
* Writes a signed number into the next n bytes. If the number is too large
* to fit into n bytes, an error is thrown.
* @param {number} num The signed number to write.
* @param {number} numBytes The number of bytes to write the number into.
*/
writeSignedNumber(num: number, numBytes: number): void;
/**
* @param {string} str The ASCII string to write.
*/
writeASCIIString(str: string): void;
};
};
//# sourceMappingURL=bytebuffer.d.ts.map

View file

@ -0,0 +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"}

109
types/io/bytestream.d.ts vendored Normal file
View file

@ -0,0 +1,109 @@
export const ByteStream: {
new (ab: ArrayBuffer, opt_offset?: number | undefined, opt_length?: number | undefined): {
/**
* The current page of bytes in the stream.
* @type {Uint8Array}
* @private
*/
bytes: Uint8Array;
/**
* The next pages of bytes in the stream.
* @type {Array<Uint8Array>}
* @private
*/
pages_: Array<Uint8Array>;
/**
* The byte in the current page that we will read next.
* @type {Number}
* @private
*/
ptr: number;
/**
* An ever-increasing number.
* @type {Number}
* @private
*/
bytesRead_: number;
/**
* Returns how many bytes have been read in the stream since the beginning of time.
*/
getNumBytesRead(): number;
/**
* Returns how many bytes are currently in the stream left to be read.
*/
getNumBytesLeft(): number;
/**
* Move the pointer ahead n bytes. If the pointer is at the end of the current array
* of bytes and we have another page of bytes, point at the new page. This is a private
* method, no validation is done.
* @param {number} n Number of bytes to increment.
* @private
*/
movePointer_(n: number): void;
/**
* Peeks at the next n bytes as an unsigned number but does not advance the
* pointer.
* @param {number} n The number of bytes to peek at. Must be a positive integer.
* @returns {number} The n bytes interpreted as an unsigned number.
*/
peekNumber(n: number): number;
/**
* Returns the next n bytes as an unsigned number (or -1 on error)
* and advances the stream pointer n bytes.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {number} The n bytes interpreted as an unsigned number.
*/
readNumber(n: number): number;
/**
* Returns the next n bytes as a signed number but does not advance the
* pointer.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {number} The bytes interpreted as a signed number.
*/
peekSignedNumber(n: number): number;
/**
* Returns the next n bytes as a signed number and advances the stream pointer.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {number} The bytes interpreted as a signed number.
*/
readSignedNumber(n: number): number;
/**
* This returns n bytes as a sub-array, advancing the pointer if movePointers
* is true.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @param {boolean} movePointers Whether to move the pointers.
* @returns {Uint8Array} The subarray.
*/
peekBytes(n: number, movePointers: boolean): Uint8Array;
/**
* Reads the next n bytes as a sub-array.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {Uint8Array} The subarray.
*/
readBytes(n: number): Uint8Array;
/**
* Peeks at the next n bytes as an ASCII string but does not advance the pointer.
* @param {number} n The number of bytes to peek at. Must be a positive integer.
* @returns {string} The next n bytes as a string.
*/
peekString(n: number): string;
/**
* Returns the next n bytes as an ASCII string and advances the stream pointer
* n bytes.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {string} The next n bytes as a string.
*/
readString(n: number): string;
/**
* Feeds more bytes into the back of the stream.
* @param {ArrayBuffer} ab
*/
push(ab: ArrayBuffer): void;
/**
* Creates a new ByteStream from this ByteStream that can be read / peeked.
* @returns {ByteStream} A clone of this ByteStream.
*/
tee(): any;
};
};
//# sourceMappingURL=bytestream.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"bytestream.d.ts","sourceRoot":"","sources":["../../io/bytestream.js"],"names":[],"mappings":"AACA;aAoBe,WAAW,eACX,MAAM,2BACN,MAAM;QAUf;;;;WAIG;eAFO,UAAU;QAKpB;;;;WAIG;gBAFO,MAAM,UAAU,CAAC;QAK3B;;;;WAIG;;QAGH;;;;WAIG;;QAIL;;WAEG;;QAKH;;WAEG;;QAMH;;;;;;WAMG;wBAFQ,MAAM;QAYjB;;;;;WAKG;sBAFQ,MAAM,GACJ,MAAM;QAqCnB;;;;;WAKG;sBAFQ,MAAM,GACJ,MAAM;QASnB;;;;;WAKG;4BAFQ,MAAM,GACJ,MAAM;QAanB;;;;WAIG;4BAFQ,MAAM,GACJ,MAAM;QASnB;;;;;;WAMG;qBAHQ,MAAM,gBACN,OAAO,GACL,UAAU;QA2CvB;;;;WAIG;qBAFQ,MAAM,GACJ,UAAU;QAMvB;;;;WAIG;sBAFQ,MAAM,GACJ,MAAM;QA+BnB;;;;;WAKG;sBAFQ,MAAM,GACJ,MAAM;QAQnB;;;WAGG;iBADQ,WAAW;QAatB;;;WAGG;;;EAYF"}