V1_commit_RGC

This commit is contained in:
2026-02-11 13:57:54 +01:00
commit ef397eedac
4901 changed files with 292881 additions and 0 deletions

22
SuiviREForamteur/node_modules/iobuffer/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Michaël Zasso
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

64
SuiviREForamteur/node_modules/iobuffer/README.md generated vendored Normal file
View File

@@ -0,0 +1,64 @@
# iobuffer
Read and write binary data in ArrayBuffers.
<h3 align="center">
<a href="https://www.zakodium.com">
<img src="https://www.zakodium.com/brand/zakodium-logo-white.svg" width="50" alt="Zakodium logo" />
</a>
<p>
Maintained by <a href="https://www.zakodium.com">Zakodium</a>
</p>
[![NPM version][npm-image]][npm-url]
[![build status][ci-image]][ci-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]
</h3>
## Installation
```console
npm i iobuffer
```
## API
Complete [API documentation](http://image-js.github.io/iobuffer/)
## Usage example
```js
const { IOBuffer } = require('iobuffer');
const io = new IOBuffer();
// Pointer offset is 0
io.writeChars('Hello world') // Write 11 chars, pointer offset now 11
.writeUint32(42) // Write 32-bit int (default is little-endian), pointer offset now 15
.setBigEndian() // Switch to big-endian mode
.writeUint32(24) // Write another 32-bit int, but big-endian, pointer offset now 19
.mark() // Bookmark current pointer offset (19)
.skip(2) // Pointer offset now 21
.writeBoolean(true) // Write 0xff, pointer offset now 22
.reset() // Go to bookmarked pointer offset, pointer offset now 19
.setLittleEndian() // Go back to little endian mode
.writeUint16(18) // Write 16-bit unsigned integer in the previously skipped 2 bytes, pointer offset now 21
.rewind() // Pointer offset back to 0
.toArray(); // Get a Uint8Array over the written part [0-21] of the internal ArrayBuffer
```
## License
[MIT](./LICENSE)
[npm-image]: https://img.shields.io/npm/v/iobuffer.svg
[npm-url]: https://www.npmjs.com/package/iobuffer
[ci-image]: https://github.com/image-js/iobuffer/workflows/Node.js%20CI/badge.svg?branch=main
[ci-url]: https://github.com/image-js/iobuffer/actions?query=workflow%3A%22Node.js+CI%22
[codecov-image]: https://img.shields.io/codecov/c/github/image-js/iobuffer.svg
[codecov-url]: https://codecov.io/gh/image-js/iobuffer
[download-image]: https://img.shields.io/npm/dm/iobuffer.svg
[download-url]: https://www.npmjs.com/package/iobuffer

View File

@@ -0,0 +1,619 @@
import { decode, encode } from './text';
const defaultByteLength = 1024 * 8;
const hostBigEndian = (() => {
const array = new Uint8Array(4);
const view = new Uint32Array(array.buffer);
return !((view[0] = 1) & array[0]);
})();
const typedArrays = {
int8: globalThis.Int8Array,
uint8: globalThis.Uint8Array,
int16: globalThis.Int16Array,
uint16: globalThis.Uint16Array,
int32: globalThis.Int32Array,
uint32: globalThis.Uint32Array,
uint64: globalThis.BigUint64Array,
int64: globalThis.BigInt64Array,
float32: globalThis.Float32Array,
float64: globalThis.Float64Array,
};
export class IOBuffer {
/**
* Reference to the internal ArrayBuffer object.
*/
buffer;
/**
* Byte length of the internal ArrayBuffer.
*/
byteLength;
/**
* Byte offset of the internal ArrayBuffer.
*/
byteOffset;
/**
* Byte length of the internal ArrayBuffer.
*/
length;
/**
* The current offset of the buffer's pointer.
*/
offset;
lastWrittenByte;
littleEndian;
_data;
_mark;
_marks;
/**
* Create a new IOBuffer.
* @param data - The data to construct the IOBuffer with.
* If data is a number, it will be the new buffer's length<br>
* If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>
* If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,
* or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.
* @param options - An object for the options.
* @returns A new IOBuffer instance.
*/
constructor(data = defaultByteLength, options = {}) {
let dataIsGiven = false;
if (typeof data === 'number') {
data = new ArrayBuffer(data);
}
else {
dataIsGiven = true;
this.lastWrittenByte = data.byteLength;
}
const offset = options.offset ? options.offset >>> 0 : 0;
const byteLength = data.byteLength - offset;
let dvOffset = offset;
if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {
if (data.byteLength !== data.buffer.byteLength) {
dvOffset = data.byteOffset + offset;
}
data = data.buffer;
}
if (dataIsGiven) {
this.lastWrittenByte = byteLength;
}
else {
this.lastWrittenByte = 0;
}
this.buffer = data;
this.length = byteLength;
this.byteLength = byteLength;
this.byteOffset = dvOffset;
this.offset = 0;
this.littleEndian = true;
this._data = new DataView(this.buffer, dvOffset, byteLength);
this._mark = 0;
this._marks = [];
}
/**
* Checks if the memory allocated to the buffer is sufficient to store more
* bytes after the offset.
* @param byteLength - The needed memory in bytes.
* @returns `true` if there is sufficient space and `false` otherwise.
*/
available(byteLength = 1) {
return this.offset + byteLength <= this.length;
}
/**
* Check if little-endian mode is used for reading and writing multi-byte
* values.
* @returns `true` if little-endian mode is used, `false` otherwise.
*/
isLittleEndian() {
return this.littleEndian;
}
/**
* Set little-endian mode for reading and writing multi-byte values.
* @returns This.
*/
setLittleEndian() {
this.littleEndian = true;
return this;
}
/**
* Check if big-endian mode is used for reading and writing multi-byte values.
* @returns `true` if big-endian mode is used, `false` otherwise.
*/
isBigEndian() {
return !this.littleEndian;
}
/**
* Switches to big-endian mode for reading and writing multi-byte values.
* @returns This.
*/
setBigEndian() {
this.littleEndian = false;
return this;
}
/**
* Move the pointer n bytes forward.
* @param n - Number of bytes to skip.
* @returns This.
*/
skip(n = 1) {
this.offset += n;
return this;
}
/**
* Move the pointer n bytes backward.
* @param n - Number of bytes to move back.
* @returns This.
*/
back(n = 1) {
this.offset -= n;
return this;
}
/**
* Move the pointer to the given offset.
* @param offset - The offset to move to.
* @returns This.
*/
seek(offset) {
this.offset = offset;
return this;
}
/**
* Store the current pointer offset.
* @see {@link IOBuffer#reset}
* @returns This.
*/
mark() {
this._mark = this.offset;
return this;
}
/**
* Move the pointer back to the last pointer offset set by mark.
* @see {@link IOBuffer#mark}
* @returns This.
*/
reset() {
this.offset = this._mark;
return this;
}
/**
* Push the current pointer offset to the mark stack.
* @see {@link IOBuffer#popMark}
* @returns This.
*/
pushMark() {
this._marks.push(this.offset);
return this;
}
/**
* Pop the last pointer offset from the mark stack, and set the current
* pointer offset to the popped value.
* @see {@link IOBuffer#pushMark}
* @returns This.
*/
popMark() {
const offset = this._marks.pop();
if (offset === undefined) {
throw new Error('Mark stack empty');
}
this.seek(offset);
return this;
}
/**
* Move the pointer offset back to 0.
* @returns This.
*/
rewind() {
this.offset = 0;
return this;
}
/**
* Make sure the buffer has sufficient memory to write a given byteLength at
* the current pointer offset.
* If the buffer's memory is insufficient, this method will create a new
* buffer (a copy) with a length that is twice (byteLength + current offset).
* @param byteLength - The needed memory in bytes.
* @returns This.
*/
ensureAvailable(byteLength = 1) {
if (!this.available(byteLength)) {
const lengthNeeded = this.offset + byteLength;
const newLength = lengthNeeded * 2;
const newArray = new Uint8Array(newLength);
newArray.set(new Uint8Array(this.buffer));
this.buffer = newArray.buffer;
this.length = newLength;
this.byteLength = newLength;
this._data = new DataView(this.buffer);
}
return this;
}
/**
* Read a byte and return false if the byte's value is 0, or true otherwise.
* Moves pointer forward by one byte.
* @returns The read boolean.
*/
readBoolean() {
return this.readUint8() !== 0;
}
/**
* Read a signed 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/
readInt8() {
return this._data.getInt8(this.offset++);
}
/**
* Read an unsigned 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/
readUint8() {
return this._data.getUint8(this.offset++);
}
/**
* Alias for {@link IOBuffer#readUint8}.
* @returns The read byte.
*/
readByte() {
return this.readUint8();
}
/**
* Read `n` bytes and move pointer forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The read bytes.
*/
readBytes(n = 1) {
return this.readArray(n, 'uint8');
}
/**
* Creates an array of corresponding to the type `type` and size `size`.
* For example type `uint8` will create a `Uint8Array`.
* @param size - size of the resulting array
* @param type - number type of elements to read
* @returns The read array.
*/
readArray(size, type) {
const bytes = typedArrays[type].BYTES_PER_ELEMENT * size;
const offset = this.byteOffset + this.offset;
const slice = this.buffer.slice(offset, offset + bytes);
if (this.littleEndian === hostBigEndian &&
type !== 'uint8' &&
type !== 'int8') {
const slice = new Uint8Array(this.buffer.slice(offset, offset + bytes));
slice.reverse();
const returnArray = new typedArrays[type](slice.buffer);
this.offset += bytes;
returnArray.reverse();
return returnArray;
}
const returnArray = new typedArrays[type](slice);
this.offset += bytes;
return returnArray;
}
/**
* Read a 16-bit signed integer and move pointer forward by 2 bytes.
* @returns The read value.
*/
readInt16() {
const value = this._data.getInt16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
/**
* Read a 16-bit unsigned integer and move pointer forward by 2 bytes.
* @returns The read value.
*/
readUint16() {
const value = this._data.getUint16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
/**
* Read a 32-bit signed integer and move pointer forward by 4 bytes.
* @returns The read value.
*/
readInt32() {
const value = this._data.getInt32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 32-bit unsigned integer and move pointer forward by 4 bytes.
* @returns The read value.
*/
readUint32() {
const value = this._data.getUint32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 32-bit floating number and move pointer forward by 4 bytes.
* @returns The read value.
*/
readFloat32() {
const value = this._data.getFloat32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 64-bit floating number and move pointer forward by 8 bytes.
* @returns The read value.
*/
readFloat64() {
const value = this._data.getFloat64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 64-bit signed integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/
readBigInt64() {
const value = this._data.getBigInt64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 64-bit unsigned integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/
readBigUint64() {
const value = this._data.getBigUint64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 1-byte ASCII character and move pointer forward by 1 byte.
* @returns The read character.
*/
readChar() {
// eslint-disable-next-line unicorn/prefer-code-point
return String.fromCharCode(this.readInt8());
}
/**
* Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.
* @param n - Number of characters to read.
* @returns The read characters.
*/
readChars(n = 1) {
let result = '';
for (let i = 0; i < n; i++) {
result += this.readChar();
}
return result;
}
/**
* Read the next `n` bytes, return a UTF-8 decoded string and move pointer
* forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The decoded string.
*/
readUtf8(n = 1) {
return decode(this.readBytes(n));
}
/**
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer
* forward by `n` bytes.
* If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8}
* @param n - Number of bytes to read.
* @param encoding - The encoding to use. Default is 'utf8'.
* @returns The decoded string.
*/
decodeText(n = 1, encoding = 'utf8') {
return decode(this.readBytes(n), encoding);
}
/**
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
* forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/
writeBoolean(value) {
this.writeUint8(value ? 0xff : 0x00);
return this;
}
/**
* Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/
writeInt8(value) {
this.ensureAvailable(1);
this._data.setInt8(this.offset++, value);
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as an 8-bit unsigned integer and move pointer forward by 1
* byte.
* @param value - The value to write.
* @returns This.
*/
writeUint8(value) {
this.ensureAvailable(1);
this._data.setUint8(this.offset++, value);
this._updateLastWrittenByte();
return this;
}
/**
* An alias for {@link IOBuffer#writeUint8}.
* @param value - The value to write.
* @returns This.
*/
writeByte(value) {
return this.writeUint8(value);
}
/**
* Write all elements of `bytes` as uint8 values and move pointer forward by
* `bytes.length` bytes.
* @param bytes - The array of bytes to write.
* @returns This.
*/
writeBytes(bytes) {
this.ensureAvailable(bytes.length);
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < bytes.length; i++) {
this._data.setUint8(this.offset++, bytes[i]);
}
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 16-bit signed integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeInt16(value) {
this.ensureAvailable(2);
this._data.setInt16(this.offset, value, this.littleEndian);
this.offset += 2;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 16-bit unsigned integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeUint16(value) {
this.ensureAvailable(2);
this._data.setUint16(this.offset, value, this.littleEndian);
this.offset += 2;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit signed integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeInt32(value) {
this.ensureAvailable(4);
this._data.setInt32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit unsigned integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeUint32(value) {
this.ensureAvailable(4);
this._data.setUint32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit floating number and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeFloat32(value) {
this.ensureAvailable(4);
this._data.setFloat32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit floating number and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeFloat64(value) {
this.ensureAvailable(8);
this._data.setFloat64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit signed bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeBigInt64(value) {
this.ensureAvailable(8);
this._data.setBigInt64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit unsigned bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeBigUint64(value) {
this.ensureAvailable(8);
this._data.setBigUint64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write the charCode of `str`'s first character as an 8-bit unsigned integer
* and move pointer forward by 1 byte.
* @param str - The character to write.
* @returns This.
*/
writeChar(str) {
// eslint-disable-next-line unicorn/prefer-code-point
return this.writeUint8(str.charCodeAt(0));
}
/**
* Write the charCodes of all `str`'s characters as 8-bit unsigned integers
* and move pointer forward by `str.length` bytes.
* @param str - The characters to write.
* @returns This.
*/
writeChars(str) {
for (let i = 0; i < str.length; i++) {
// eslint-disable-next-line unicorn/prefer-code-point
this.writeUint8(str.charCodeAt(i));
}
return this;
}
/**
* UTF-8 encode and write `str` to the current pointer offset and move pointer
* forward according to the encoded length.
* @param str - The string to write.
* @returns This.
*/
writeUtf8(str) {
return this.writeBytes(encode(str));
}
/**
* Export a Uint8Array view of the internal buffer.
* The view starts at the byte offset and its length
* is calculated to stop at the last written byte or the original length.
* @returns A new Uint8Array view.
*/
toArray() {
return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
}
/**
* Get the total number of bytes written so far, regardless of the current offset.
* @returns - Total number of bytes.
*/
getWrittenByteLength() {
return this.lastWrittenByte - this.byteOffset;
}
/**
* Update the last written byte offset
* @private
*/
_updateLastWrittenByte() {
if (this.offset > this.lastWrittenByte) {
this.lastWrittenByte = this.offset;
}
}
}
//# sourceMappingURL=IOBuffer.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
export function decode(bytes, encoding = 'utf8') {
const decoder = new TextDecoder(encoding);
return decoder.decode(bytes);
}
const encoder = new TextEncoder();
export function encode(str) {
return encoder.encode(str);
}
//# sourceMappingURL=text.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAC,KAAiB,EAAE,QAAQ,GAAG,MAAM;IACzD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC"}

View File

@@ -0,0 +1,373 @@
type InputData = number | ArrayBufferLike | ArrayBufferView | IOBuffer | Buffer;
declare const typedArrays: {
int8: Int8ArrayConstructor;
uint8: Uint8ArrayConstructor;
int16: Int16ArrayConstructor;
uint16: Uint16ArrayConstructor;
int32: Int32ArrayConstructor;
uint32: Uint32ArrayConstructor;
uint64: BigUint64ArrayConstructor;
int64: BigInt64ArrayConstructor;
float32: Float32ArrayConstructor;
float64: Float64ArrayConstructor;
};
type TypedArrays = typeof typedArrays;
interface IOBufferOptions {
/**
* Ignore the first n bytes of the ArrayBuffer.
*/
offset?: number;
}
export declare class IOBuffer {
/**
* Reference to the internal ArrayBuffer object.
*/
buffer: ArrayBufferLike;
/**
* Byte length of the internal ArrayBuffer.
*/
byteLength: number;
/**
* Byte offset of the internal ArrayBuffer.
*/
byteOffset: number;
/**
* Byte length of the internal ArrayBuffer.
*/
length: number;
/**
* The current offset of the buffer's pointer.
*/
offset: number;
private lastWrittenByte;
private littleEndian;
private _data;
private _mark;
private _marks;
/**
* Create a new IOBuffer.
* @param data - The data to construct the IOBuffer with.
* If data is a number, it will be the new buffer's length<br>
* If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>
* If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,
* or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.
* @param options - An object for the options.
* @returns A new IOBuffer instance.
*/
constructor(data?: InputData, options?: IOBufferOptions);
/**
* Checks if the memory allocated to the buffer is sufficient to store more
* bytes after the offset.
* @param byteLength - The needed memory in bytes.
* @returns `true` if there is sufficient space and `false` otherwise.
*/
available(byteLength?: number): boolean;
/**
* Check if little-endian mode is used for reading and writing multi-byte
* values.
* @returns `true` if little-endian mode is used, `false` otherwise.
*/
isLittleEndian(): boolean;
/**
* Set little-endian mode for reading and writing multi-byte values.
* @returns This.
*/
setLittleEndian(): this;
/**
* Check if big-endian mode is used for reading and writing multi-byte values.
* @returns `true` if big-endian mode is used, `false` otherwise.
*/
isBigEndian(): boolean;
/**
* Switches to big-endian mode for reading and writing multi-byte values.
* @returns This.
*/
setBigEndian(): this;
/**
* Move the pointer n bytes forward.
* @param n - Number of bytes to skip.
* @returns This.
*/
skip(n?: number): this;
/**
* Move the pointer n bytes backward.
* @param n - Number of bytes to move back.
* @returns This.
*/
back(n?: number): this;
/**
* Move the pointer to the given offset.
* @param offset - The offset to move to.
* @returns This.
*/
seek(offset: number): this;
/**
* Store the current pointer offset.
* @see {@link IOBuffer#reset}
* @returns This.
*/
mark(): this;
/**
* Move the pointer back to the last pointer offset set by mark.
* @see {@link IOBuffer#mark}
* @returns This.
*/
reset(): this;
/**
* Push the current pointer offset to the mark stack.
* @see {@link IOBuffer#popMark}
* @returns This.
*/
pushMark(): this;
/**
* Pop the last pointer offset from the mark stack, and set the current
* pointer offset to the popped value.
* @see {@link IOBuffer#pushMark}
* @returns This.
*/
popMark(): this;
/**
* Move the pointer offset back to 0.
* @returns This.
*/
rewind(): this;
/**
* Make sure the buffer has sufficient memory to write a given byteLength at
* the current pointer offset.
* If the buffer's memory is insufficient, this method will create a new
* buffer (a copy) with a length that is twice (byteLength + current offset).
* @param byteLength - The needed memory in bytes.
* @returns This.
*/
ensureAvailable(byteLength?: number): this;
/**
* Read a byte and return false if the byte's value is 0, or true otherwise.
* Moves pointer forward by one byte.
* @returns The read boolean.
*/
readBoolean(): boolean;
/**
* Read a signed 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/
readInt8(): number;
/**
* Read an unsigned 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/
readUint8(): number;
/**
* Alias for {@link IOBuffer#readUint8}.
* @returns The read byte.
*/
readByte(): number;
/**
* Read `n` bytes and move pointer forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The read bytes.
*/
readBytes(n?: number): Uint8Array;
/**
* Creates an array of corresponding to the type `type` and size `size`.
* For example type `uint8` will create a `Uint8Array`.
* @param size - size of the resulting array
* @param type - number type of elements to read
* @returns The read array.
*/
readArray<T extends keyof typeof typedArrays>(size: number, type: T): InstanceType<TypedArrays[T]>;
/**
* Read a 16-bit signed integer and move pointer forward by 2 bytes.
* @returns The read value.
*/
readInt16(): number;
/**
* Read a 16-bit unsigned integer and move pointer forward by 2 bytes.
* @returns The read value.
*/
readUint16(): number;
/**
* Read a 32-bit signed integer and move pointer forward by 4 bytes.
* @returns The read value.
*/
readInt32(): number;
/**
* Read a 32-bit unsigned integer and move pointer forward by 4 bytes.
* @returns The read value.
*/
readUint32(): number;
/**
* Read a 32-bit floating number and move pointer forward by 4 bytes.
* @returns The read value.
*/
readFloat32(): number;
/**
* Read a 64-bit floating number and move pointer forward by 8 bytes.
* @returns The read value.
*/
readFloat64(): number;
/**
* Read a 64-bit signed integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/
readBigInt64(): bigint;
/**
* Read a 64-bit unsigned integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/
readBigUint64(): bigint;
/**
* Read a 1-byte ASCII character and move pointer forward by 1 byte.
* @returns The read character.
*/
readChar(): string;
/**
* Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.
* @param n - Number of characters to read.
* @returns The read characters.
*/
readChars(n?: number): string;
/**
* Read the next `n` bytes, return a UTF-8 decoded string and move pointer
* forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The decoded string.
*/
readUtf8(n?: number): string;
/**
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer
* forward by `n` bytes.
* If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8}
* @param n - Number of bytes to read.
* @param encoding - The encoding to use. Default is 'utf8'.
* @returns The decoded string.
*/
decodeText(n?: number, encoding?: string): string;
/**
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
* forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/
writeBoolean(value: unknown): this;
/**
* Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/
writeInt8(value: number): this;
/**
* Write `value` as an 8-bit unsigned integer and move pointer forward by 1
* byte.
* @param value - The value to write.
* @returns This.
*/
writeUint8(value: number): this;
/**
* An alias for {@link IOBuffer#writeUint8}.
* @param value - The value to write.
* @returns This.
*/
writeByte(value: number): this;
/**
* Write all elements of `bytes` as uint8 values and move pointer forward by
* `bytes.length` bytes.
* @param bytes - The array of bytes to write.
* @returns This.
*/
writeBytes(bytes: ArrayLike<number>): this;
/**
* Write `value` as a 16-bit signed integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeInt16(value: number): this;
/**
* Write `value` as a 16-bit unsigned integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeUint16(value: number): this;
/**
* Write `value` as a 32-bit signed integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeInt32(value: number): this;
/**
* Write `value` as a 32-bit unsigned integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeUint32(value: number): this;
/**
* Write `value` as a 32-bit floating number and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeFloat32(value: number): this;
/**
* Write `value` as a 64-bit floating number and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeFloat64(value: number): this;
/**
* Write `value` as a 64-bit signed bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeBigInt64(value: bigint): this;
/**
* Write `value` as a 64-bit unsigned bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeBigUint64(value: bigint): this;
/**
* Write the charCode of `str`'s first character as an 8-bit unsigned integer
* and move pointer forward by 1 byte.
* @param str - The character to write.
* @returns This.
*/
writeChar(str: string): this;
/**
* Write the charCodes of all `str`'s characters as 8-bit unsigned integers
* and move pointer forward by `str.length` bytes.
* @param str - The characters to write.
* @returns This.
*/
writeChars(str: string): this;
/**
* UTF-8 encode and write `str` to the current pointer offset and move pointer
* forward according to the encoded length.
* @param str - The string to write.
* @returns This.
*/
writeUtf8(str: string): this;
/**
* Export a Uint8Array view of the internal buffer.
* The view starts at the byte offset and its length
* is calculated to stop at the last written byte or the original length.
* @returns A new Uint8Array view.
*/
toArray(): Uint8Array;
/**
* Get the total number of bytes written so far, regardless of the current offset.
* @returns - Total number of bytes.
*/
getWrittenByteLength(): number;
/**
* Update the last written byte offset
* @private
*/
private _updateLastWrittenByte;
}
export {};

623
SuiviREForamteur/node_modules/iobuffer/lib/IOBuffer.js generated vendored Normal file
View File

@@ -0,0 +1,623 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IOBuffer = void 0;
const text_1 = require("./text");
const defaultByteLength = 1024 * 8;
const hostBigEndian = (() => {
const array = new Uint8Array(4);
const view = new Uint32Array(array.buffer);
return !((view[0] = 1) & array[0]);
})();
const typedArrays = {
int8: globalThis.Int8Array,
uint8: globalThis.Uint8Array,
int16: globalThis.Int16Array,
uint16: globalThis.Uint16Array,
int32: globalThis.Int32Array,
uint32: globalThis.Uint32Array,
uint64: globalThis.BigUint64Array,
int64: globalThis.BigInt64Array,
float32: globalThis.Float32Array,
float64: globalThis.Float64Array,
};
class IOBuffer {
/**
* Reference to the internal ArrayBuffer object.
*/
buffer;
/**
* Byte length of the internal ArrayBuffer.
*/
byteLength;
/**
* Byte offset of the internal ArrayBuffer.
*/
byteOffset;
/**
* Byte length of the internal ArrayBuffer.
*/
length;
/**
* The current offset of the buffer's pointer.
*/
offset;
lastWrittenByte;
littleEndian;
_data;
_mark;
_marks;
/**
* Create a new IOBuffer.
* @param data - The data to construct the IOBuffer with.
* If data is a number, it will be the new buffer's length<br>
* If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>
* If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,
* or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.
* @param options - An object for the options.
* @returns A new IOBuffer instance.
*/
constructor(data = defaultByteLength, options = {}) {
let dataIsGiven = false;
if (typeof data === 'number') {
data = new ArrayBuffer(data);
}
else {
dataIsGiven = true;
this.lastWrittenByte = data.byteLength;
}
const offset = options.offset ? options.offset >>> 0 : 0;
const byteLength = data.byteLength - offset;
let dvOffset = offset;
if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {
if (data.byteLength !== data.buffer.byteLength) {
dvOffset = data.byteOffset + offset;
}
data = data.buffer;
}
if (dataIsGiven) {
this.lastWrittenByte = byteLength;
}
else {
this.lastWrittenByte = 0;
}
this.buffer = data;
this.length = byteLength;
this.byteLength = byteLength;
this.byteOffset = dvOffset;
this.offset = 0;
this.littleEndian = true;
this._data = new DataView(this.buffer, dvOffset, byteLength);
this._mark = 0;
this._marks = [];
}
/**
* Checks if the memory allocated to the buffer is sufficient to store more
* bytes after the offset.
* @param byteLength - The needed memory in bytes.
* @returns `true` if there is sufficient space and `false` otherwise.
*/
available(byteLength = 1) {
return this.offset + byteLength <= this.length;
}
/**
* Check if little-endian mode is used for reading and writing multi-byte
* values.
* @returns `true` if little-endian mode is used, `false` otherwise.
*/
isLittleEndian() {
return this.littleEndian;
}
/**
* Set little-endian mode for reading and writing multi-byte values.
* @returns This.
*/
setLittleEndian() {
this.littleEndian = true;
return this;
}
/**
* Check if big-endian mode is used for reading and writing multi-byte values.
* @returns `true` if big-endian mode is used, `false` otherwise.
*/
isBigEndian() {
return !this.littleEndian;
}
/**
* Switches to big-endian mode for reading and writing multi-byte values.
* @returns This.
*/
setBigEndian() {
this.littleEndian = false;
return this;
}
/**
* Move the pointer n bytes forward.
* @param n - Number of bytes to skip.
* @returns This.
*/
skip(n = 1) {
this.offset += n;
return this;
}
/**
* Move the pointer n bytes backward.
* @param n - Number of bytes to move back.
* @returns This.
*/
back(n = 1) {
this.offset -= n;
return this;
}
/**
* Move the pointer to the given offset.
* @param offset - The offset to move to.
* @returns This.
*/
seek(offset) {
this.offset = offset;
return this;
}
/**
* Store the current pointer offset.
* @see {@link IOBuffer#reset}
* @returns This.
*/
mark() {
this._mark = this.offset;
return this;
}
/**
* Move the pointer back to the last pointer offset set by mark.
* @see {@link IOBuffer#mark}
* @returns This.
*/
reset() {
this.offset = this._mark;
return this;
}
/**
* Push the current pointer offset to the mark stack.
* @see {@link IOBuffer#popMark}
* @returns This.
*/
pushMark() {
this._marks.push(this.offset);
return this;
}
/**
* Pop the last pointer offset from the mark stack, and set the current
* pointer offset to the popped value.
* @see {@link IOBuffer#pushMark}
* @returns This.
*/
popMark() {
const offset = this._marks.pop();
if (offset === undefined) {
throw new Error('Mark stack empty');
}
this.seek(offset);
return this;
}
/**
* Move the pointer offset back to 0.
* @returns This.
*/
rewind() {
this.offset = 0;
return this;
}
/**
* Make sure the buffer has sufficient memory to write a given byteLength at
* the current pointer offset.
* If the buffer's memory is insufficient, this method will create a new
* buffer (a copy) with a length that is twice (byteLength + current offset).
* @param byteLength - The needed memory in bytes.
* @returns This.
*/
ensureAvailable(byteLength = 1) {
if (!this.available(byteLength)) {
const lengthNeeded = this.offset + byteLength;
const newLength = lengthNeeded * 2;
const newArray = new Uint8Array(newLength);
newArray.set(new Uint8Array(this.buffer));
this.buffer = newArray.buffer;
this.length = newLength;
this.byteLength = newLength;
this._data = new DataView(this.buffer);
}
return this;
}
/**
* Read a byte and return false if the byte's value is 0, or true otherwise.
* Moves pointer forward by one byte.
* @returns The read boolean.
*/
readBoolean() {
return this.readUint8() !== 0;
}
/**
* Read a signed 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/
readInt8() {
return this._data.getInt8(this.offset++);
}
/**
* Read an unsigned 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/
readUint8() {
return this._data.getUint8(this.offset++);
}
/**
* Alias for {@link IOBuffer#readUint8}.
* @returns The read byte.
*/
readByte() {
return this.readUint8();
}
/**
* Read `n` bytes and move pointer forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The read bytes.
*/
readBytes(n = 1) {
return this.readArray(n, 'uint8');
}
/**
* Creates an array of corresponding to the type `type` and size `size`.
* For example type `uint8` will create a `Uint8Array`.
* @param size - size of the resulting array
* @param type - number type of elements to read
* @returns The read array.
*/
readArray(size, type) {
const bytes = typedArrays[type].BYTES_PER_ELEMENT * size;
const offset = this.byteOffset + this.offset;
const slice = this.buffer.slice(offset, offset + bytes);
if (this.littleEndian === hostBigEndian &&
type !== 'uint8' &&
type !== 'int8') {
const slice = new Uint8Array(this.buffer.slice(offset, offset + bytes));
slice.reverse();
const returnArray = new typedArrays[type](slice.buffer);
this.offset += bytes;
returnArray.reverse();
return returnArray;
}
const returnArray = new typedArrays[type](slice);
this.offset += bytes;
return returnArray;
}
/**
* Read a 16-bit signed integer and move pointer forward by 2 bytes.
* @returns The read value.
*/
readInt16() {
const value = this._data.getInt16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
/**
* Read a 16-bit unsigned integer and move pointer forward by 2 bytes.
* @returns The read value.
*/
readUint16() {
const value = this._data.getUint16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
/**
* Read a 32-bit signed integer and move pointer forward by 4 bytes.
* @returns The read value.
*/
readInt32() {
const value = this._data.getInt32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 32-bit unsigned integer and move pointer forward by 4 bytes.
* @returns The read value.
*/
readUint32() {
const value = this._data.getUint32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 32-bit floating number and move pointer forward by 4 bytes.
* @returns The read value.
*/
readFloat32() {
const value = this._data.getFloat32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 64-bit floating number and move pointer forward by 8 bytes.
* @returns The read value.
*/
readFloat64() {
const value = this._data.getFloat64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 64-bit signed integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/
readBigInt64() {
const value = this._data.getBigInt64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 64-bit unsigned integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/
readBigUint64() {
const value = this._data.getBigUint64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 1-byte ASCII character and move pointer forward by 1 byte.
* @returns The read character.
*/
readChar() {
// eslint-disable-next-line unicorn/prefer-code-point
return String.fromCharCode(this.readInt8());
}
/**
* Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.
* @param n - Number of characters to read.
* @returns The read characters.
*/
readChars(n = 1) {
let result = '';
for (let i = 0; i < n; i++) {
result += this.readChar();
}
return result;
}
/**
* Read the next `n` bytes, return a UTF-8 decoded string and move pointer
* forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The decoded string.
*/
readUtf8(n = 1) {
return (0, text_1.decode)(this.readBytes(n));
}
/**
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer
* forward by `n` bytes.
* If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8}
* @param n - Number of bytes to read.
* @param encoding - The encoding to use. Default is 'utf8'.
* @returns The decoded string.
*/
decodeText(n = 1, encoding = 'utf8') {
return (0, text_1.decode)(this.readBytes(n), encoding);
}
/**
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
* forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/
writeBoolean(value) {
this.writeUint8(value ? 0xff : 0x00);
return this;
}
/**
* Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/
writeInt8(value) {
this.ensureAvailable(1);
this._data.setInt8(this.offset++, value);
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as an 8-bit unsigned integer and move pointer forward by 1
* byte.
* @param value - The value to write.
* @returns This.
*/
writeUint8(value) {
this.ensureAvailable(1);
this._data.setUint8(this.offset++, value);
this._updateLastWrittenByte();
return this;
}
/**
* An alias for {@link IOBuffer#writeUint8}.
* @param value - The value to write.
* @returns This.
*/
writeByte(value) {
return this.writeUint8(value);
}
/**
* Write all elements of `bytes` as uint8 values and move pointer forward by
* `bytes.length` bytes.
* @param bytes - The array of bytes to write.
* @returns This.
*/
writeBytes(bytes) {
this.ensureAvailable(bytes.length);
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < bytes.length; i++) {
this._data.setUint8(this.offset++, bytes[i]);
}
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 16-bit signed integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeInt16(value) {
this.ensureAvailable(2);
this._data.setInt16(this.offset, value, this.littleEndian);
this.offset += 2;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 16-bit unsigned integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeUint16(value) {
this.ensureAvailable(2);
this._data.setUint16(this.offset, value, this.littleEndian);
this.offset += 2;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit signed integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeInt32(value) {
this.ensureAvailable(4);
this._data.setInt32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit unsigned integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeUint32(value) {
this.ensureAvailable(4);
this._data.setUint32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit floating number and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeFloat32(value) {
this.ensureAvailable(4);
this._data.setFloat32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit floating number and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeFloat64(value) {
this.ensureAvailable(8);
this._data.setFloat64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit signed bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeBigInt64(value) {
this.ensureAvailable(8);
this._data.setBigInt64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit unsigned bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
writeBigUint64(value) {
this.ensureAvailable(8);
this._data.setBigUint64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write the charCode of `str`'s first character as an 8-bit unsigned integer
* and move pointer forward by 1 byte.
* @param str - The character to write.
* @returns This.
*/
writeChar(str) {
// eslint-disable-next-line unicorn/prefer-code-point
return this.writeUint8(str.charCodeAt(0));
}
/**
* Write the charCodes of all `str`'s characters as 8-bit unsigned integers
* and move pointer forward by `str.length` bytes.
* @param str - The characters to write.
* @returns This.
*/
writeChars(str) {
for (let i = 0; i < str.length; i++) {
// eslint-disable-next-line unicorn/prefer-code-point
this.writeUint8(str.charCodeAt(i));
}
return this;
}
/**
* UTF-8 encode and write `str` to the current pointer offset and move pointer
* forward according to the encoded length.
* @param str - The string to write.
* @returns This.
*/
writeUtf8(str) {
return this.writeBytes((0, text_1.encode)(str));
}
/**
* Export a Uint8Array view of the internal buffer.
* The view starts at the byte offset and its length
* is calculated to stop at the last written byte or the original length.
* @returns A new Uint8Array view.
*/
toArray() {
return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
}
/**
* Get the total number of bytes written so far, regardless of the current offset.
* @returns - Total number of bytes.
*/
getWrittenByteLength() {
return this.lastWrittenByte - this.byteOffset;
}
/**
* Update the last written byte offset
* @private
*/
_updateLastWrittenByte() {
if (this.offset > this.lastWrittenByte) {
this.lastWrittenByte = this.offset;
}
}
}
exports.IOBuffer = IOBuffer;
//# sourceMappingURL=IOBuffer.js.map

File diff suppressed because one or more lines are too long

2
SuiviREForamteur/node_modules/iobuffer/lib/text.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare function decode(bytes: Uint8Array, encoding?: string): string;
export declare function encode(str: string): Uint8Array;

13
SuiviREForamteur/node_modules/iobuffer/lib/text.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decode = decode;
exports.encode = encode;
function decode(bytes, encoding = 'utf8') {
const decoder = new TextDecoder(encoding);
return decoder.decode(bytes);
}
const encoder = new TextEncoder();
function encode(str) {
return encoder.encode(str);
}
//# sourceMappingURL=text.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":";;AAAA,wBAGC;AAID,wBAEC;AATD,SAAgB,MAAM,CAAC,KAAiB,EAAE,QAAQ,GAAG,MAAM;IACzD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,SAAgB,MAAM,CAAC,GAAW;IAChC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC"}

47
SuiviREForamteur/node_modules/iobuffer/package.json generated vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "iobuffer",
"version": "5.4.0",
"description": "Read and write binary data on ArrayBuffers",
"main": "./lib/IOBuffer.js",
"module": "./lib-esm/IOBuffer.js",
"types": "./lib/IOBuffer.d.ts",
"files": [
"src",
"lib",
"lib-esm"
],
"scripts": {
"check-types": "tsc --noEmit",
"clean": "rimraf lib lib-esm",
"eslint": "eslint src",
"eslint-fix": "npm run eslint -- --fix",
"prepack": "npm run tsc",
"prettier": "prettier --check src",
"prettier-write": "prettier --write src",
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types",
"test-only": "vitest run --coverage",
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
"tsc-cjs": "tsc --project tsconfig.cjs.json",
"tsc-esm": "tsc --project tsconfig.esm.json"
},
"repository": {
"type": "git",
"url": "git+https://github.com/image-js/iobuffer.git"
},
"author": "Michaël Zasso",
"license": "MIT",
"bugs": {
"url": "https://github.com/image-js/iobuffer/issues"
},
"homepage": "https://github.com/image-js/iobuffer#readme",
"devDependencies": {
"@types/node": "^22.13.0",
"@vitest/coverage-v8": "^3.0.4",
"eslint": "^9.19.0",
"eslint-config-cheminfo-typescript": "^17.0.0",
"prettier": "^3.4.2",
"rimraf": "^6.0.1",
"typescript": "^5.7.3",
"vitest": "^3.0.4"
}
}

697
SuiviREForamteur/node_modules/iobuffer/src/IOBuffer.ts generated vendored Normal file
View File

@@ -0,0 +1,697 @@
import { decode, encode } from './text';
const defaultByteLength = 1024 * 8;
const hostBigEndian = (() => {
const array = new Uint8Array(4);
const view = new Uint32Array(array.buffer);
return !((view[0] = 1) & array[0]);
})();
type InputData = number | ArrayBufferLike | ArrayBufferView | IOBuffer | Buffer;
const typedArrays = {
int8: globalThis.Int8Array,
uint8: globalThis.Uint8Array,
int16: globalThis.Int16Array,
uint16: globalThis.Uint16Array,
int32: globalThis.Int32Array,
uint32: globalThis.Uint32Array,
uint64: globalThis.BigUint64Array,
int64: globalThis.BigInt64Array,
float32: globalThis.Float32Array,
float64: globalThis.Float64Array,
};
type TypedArrays = typeof typedArrays;
interface IOBufferOptions {
/**
* Ignore the first n bytes of the ArrayBuffer.
*/
offset?: number;
}
export class IOBuffer {
/**
* Reference to the internal ArrayBuffer object.
*/
public buffer: ArrayBufferLike;
/**
* Byte length of the internal ArrayBuffer.
*/
public byteLength: number;
/**
* Byte offset of the internal ArrayBuffer.
*/
public byteOffset: number;
/**
* Byte length of the internal ArrayBuffer.
*/
public length: number;
/**
* The current offset of the buffer's pointer.
*/
public offset: number;
private lastWrittenByte: number;
private littleEndian: boolean;
private _data: DataView;
private _mark: number;
private _marks: number[];
/**
* Create a new IOBuffer.
* @param data - The data to construct the IOBuffer with.
* If data is a number, it will be the new buffer's length<br>
* If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>
* If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,
* or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.
* @param options - An object for the options.
* @returns A new IOBuffer instance.
*/
public constructor(
data: InputData = defaultByteLength,
options: IOBufferOptions = {},
) {
let dataIsGiven = false;
if (typeof data === 'number') {
data = new ArrayBuffer(data);
} else {
dataIsGiven = true;
this.lastWrittenByte = data.byteLength;
}
const offset = options.offset ? options.offset >>> 0 : 0;
const byteLength = data.byteLength - offset;
let dvOffset = offset;
if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {
if (data.byteLength !== data.buffer.byteLength) {
dvOffset = data.byteOffset + offset;
}
data = data.buffer;
}
if (dataIsGiven) {
this.lastWrittenByte = byteLength;
} else {
this.lastWrittenByte = 0;
}
this.buffer = data;
this.length = byteLength;
this.byteLength = byteLength;
this.byteOffset = dvOffset;
this.offset = 0;
this.littleEndian = true;
this._data = new DataView(this.buffer, dvOffset, byteLength);
this._mark = 0;
this._marks = [];
}
/**
* Checks if the memory allocated to the buffer is sufficient to store more
* bytes after the offset.
* @param byteLength - The needed memory in bytes.
* @returns `true` if there is sufficient space and `false` otherwise.
*/
public available(byteLength = 1): boolean {
return this.offset + byteLength <= this.length;
}
/**
* Check if little-endian mode is used for reading and writing multi-byte
* values.
* @returns `true` if little-endian mode is used, `false` otherwise.
*/
public isLittleEndian(): boolean {
return this.littleEndian;
}
/**
* Set little-endian mode for reading and writing multi-byte values.
* @returns This.
*/
public setLittleEndian(): this {
this.littleEndian = true;
return this;
}
/**
* Check if big-endian mode is used for reading and writing multi-byte values.
* @returns `true` if big-endian mode is used, `false` otherwise.
*/
public isBigEndian(): boolean {
return !this.littleEndian;
}
/**
* Switches to big-endian mode for reading and writing multi-byte values.
* @returns This.
*/
public setBigEndian(): this {
this.littleEndian = false;
return this;
}
/**
* Move the pointer n bytes forward.
* @param n - Number of bytes to skip.
* @returns This.
*/
public skip(n = 1): this {
this.offset += n;
return this;
}
/**
* Move the pointer n bytes backward.
* @param n - Number of bytes to move back.
* @returns This.
*/
public back(n = 1): this {
this.offset -= n;
return this;
}
/**
* Move the pointer to the given offset.
* @param offset - The offset to move to.
* @returns This.
*/
public seek(offset: number): this {
this.offset = offset;
return this;
}
/**
* Store the current pointer offset.
* @see {@link IOBuffer#reset}
* @returns This.
*/
public mark(): this {
this._mark = this.offset;
return this;
}
/**
* Move the pointer back to the last pointer offset set by mark.
* @see {@link IOBuffer#mark}
* @returns This.
*/
public reset(): this {
this.offset = this._mark;
return this;
}
/**
* Push the current pointer offset to the mark stack.
* @see {@link IOBuffer#popMark}
* @returns This.
*/
public pushMark(): this {
this._marks.push(this.offset);
return this;
}
/**
* Pop the last pointer offset from the mark stack, and set the current
* pointer offset to the popped value.
* @see {@link IOBuffer#pushMark}
* @returns This.
*/
public popMark(): this {
const offset = this._marks.pop();
if (offset === undefined) {
throw new Error('Mark stack empty');
}
this.seek(offset);
return this;
}
/**
* Move the pointer offset back to 0.
* @returns This.
*/
public rewind(): this {
this.offset = 0;
return this;
}
/**
* Make sure the buffer has sufficient memory to write a given byteLength at
* the current pointer offset.
* If the buffer's memory is insufficient, this method will create a new
* buffer (a copy) with a length that is twice (byteLength + current offset).
* @param byteLength - The needed memory in bytes.
* @returns This.
*/
public ensureAvailable(byteLength = 1): this {
if (!this.available(byteLength)) {
const lengthNeeded = this.offset + byteLength;
const newLength = lengthNeeded * 2;
const newArray = new Uint8Array(newLength);
newArray.set(new Uint8Array(this.buffer));
this.buffer = newArray.buffer;
this.length = newLength;
this.byteLength = newLength;
this._data = new DataView(this.buffer);
}
return this;
}
/**
* Read a byte and return false if the byte's value is 0, or true otherwise.
* Moves pointer forward by one byte.
* @returns The read boolean.
*/
public readBoolean(): boolean {
return this.readUint8() !== 0;
}
/**
* Read a signed 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/
public readInt8(): number {
return this._data.getInt8(this.offset++);
}
/**
* Read an unsigned 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/
public readUint8(): number {
return this._data.getUint8(this.offset++);
}
/**
* Alias for {@link IOBuffer#readUint8}.
* @returns The read byte.
*/
public readByte(): number {
return this.readUint8();
}
/**
* Read `n` bytes and move pointer forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The read bytes.
*/
public readBytes(n = 1): Uint8Array {
return this.readArray(n, 'uint8');
}
/**
* Creates an array of corresponding to the type `type` and size `size`.
* For example type `uint8` will create a `Uint8Array`.
* @param size - size of the resulting array
* @param type - number type of elements to read
* @returns The read array.
*/
public readArray<T extends keyof typeof typedArrays>(
size: number,
type: T,
): InstanceType<TypedArrays[T]> {
const bytes = typedArrays[type].BYTES_PER_ELEMENT * size;
const offset = this.byteOffset + this.offset;
const slice = this.buffer.slice(offset, offset + bytes);
if (
this.littleEndian === hostBigEndian &&
type !== 'uint8' &&
type !== 'int8'
) {
const slice = new Uint8Array(this.buffer.slice(offset, offset + bytes));
slice.reverse();
const returnArray = new typedArrays[type](slice.buffer);
this.offset += bytes;
returnArray.reverse();
return returnArray as InstanceType<TypedArrays[T]>;
}
const returnArray = new typedArrays[type](slice);
this.offset += bytes;
return returnArray as InstanceType<TypedArrays[T]>;
}
/**
* Read a 16-bit signed integer and move pointer forward by 2 bytes.
* @returns The read value.
*/
public readInt16(): number {
const value = this._data.getInt16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
/**
* Read a 16-bit unsigned integer and move pointer forward by 2 bytes.
* @returns The read value.
*/
public readUint16(): number {
const value = this._data.getUint16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
/**
* Read a 32-bit signed integer and move pointer forward by 4 bytes.
* @returns The read value.
*/
public readInt32(): number {
const value = this._data.getInt32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 32-bit unsigned integer and move pointer forward by 4 bytes.
* @returns The read value.
*/
public readUint32(): number {
const value = this._data.getUint32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 32-bit floating number and move pointer forward by 4 bytes.
* @returns The read value.
*/
public readFloat32(): number {
const value = this._data.getFloat32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 64-bit floating number and move pointer forward by 8 bytes.
* @returns The read value.
*/
public readFloat64(): number {
const value = this._data.getFloat64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 64-bit signed integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/
public readBigInt64(): bigint {
const value = this._data.getBigInt64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 64-bit unsigned integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/
public readBigUint64(): bigint {
const value = this._data.getBigUint64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 1-byte ASCII character and move pointer forward by 1 byte.
* @returns The read character.
*/
public readChar(): string {
// eslint-disable-next-line unicorn/prefer-code-point
return String.fromCharCode(this.readInt8());
}
/**
* Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.
* @param n - Number of characters to read.
* @returns The read characters.
*/
public readChars(n = 1): string {
let result = '';
for (let i = 0; i < n; i++) {
result += this.readChar();
}
return result;
}
/**
* Read the next `n` bytes, return a UTF-8 decoded string and move pointer
* forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The decoded string.
*/
public readUtf8(n = 1): string {
return decode(this.readBytes(n));
}
/**
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer
* forward by `n` bytes.
* If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8}
* @param n - Number of bytes to read.
* @param encoding - The encoding to use. Default is 'utf8'.
* @returns The decoded string.
*/
public decodeText(n = 1, encoding = 'utf8'): string {
return decode(this.readBytes(n), encoding);
}
/**
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
* forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/
public writeBoolean(value: unknown): this {
this.writeUint8(value ? 0xff : 0x00);
return this;
}
/**
* Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/
public writeInt8(value: number): this {
this.ensureAvailable(1);
this._data.setInt8(this.offset++, value);
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as an 8-bit unsigned integer and move pointer forward by 1
* byte.
* @param value - The value to write.
* @returns This.
*/
public writeUint8(value: number): this {
this.ensureAvailable(1);
this._data.setUint8(this.offset++, value);
this._updateLastWrittenByte();
return this;
}
/**
* An alias for {@link IOBuffer#writeUint8}.
* @param value - The value to write.
* @returns This.
*/
public writeByte(value: number): this {
return this.writeUint8(value);
}
/**
* Write all elements of `bytes` as uint8 values and move pointer forward by
* `bytes.length` bytes.
* @param bytes - The array of bytes to write.
* @returns This.
*/
public writeBytes(bytes: ArrayLike<number>): this {
this.ensureAvailable(bytes.length);
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < bytes.length; i++) {
this._data.setUint8(this.offset++, bytes[i]);
}
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 16-bit signed integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/
public writeInt16(value: number): this {
this.ensureAvailable(2);
this._data.setInt16(this.offset, value, this.littleEndian);
this.offset += 2;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 16-bit unsigned integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/
public writeUint16(value: number): this {
this.ensureAvailable(2);
this._data.setUint16(this.offset, value, this.littleEndian);
this.offset += 2;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit signed integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
public writeInt32(value: number): this {
this.ensureAvailable(4);
this._data.setInt32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit unsigned integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
public writeUint32(value: number): this {
this.ensureAvailable(4);
this._data.setUint32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit floating number and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/
public writeFloat32(value: number): this {
this.ensureAvailable(4);
this._data.setFloat32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit floating number and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
public writeFloat64(value: number): this {
this.ensureAvailable(8);
this._data.setFloat64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit signed bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
public writeBigInt64(value: bigint): this {
this.ensureAvailable(8);
this._data.setBigInt64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit unsigned bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/
public writeBigUint64(value: bigint): this {
this.ensureAvailable(8);
this._data.setBigUint64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write the charCode of `str`'s first character as an 8-bit unsigned integer
* and move pointer forward by 1 byte.
* @param str - The character to write.
* @returns This.
*/
public writeChar(str: string): this {
// eslint-disable-next-line unicorn/prefer-code-point
return this.writeUint8(str.charCodeAt(0));
}
/**
* Write the charCodes of all `str`'s characters as 8-bit unsigned integers
* and move pointer forward by `str.length` bytes.
* @param str - The characters to write.
* @returns This.
*/
public writeChars(str: string): this {
for (let i = 0; i < str.length; i++) {
// eslint-disable-next-line unicorn/prefer-code-point
this.writeUint8(str.charCodeAt(i));
}
return this;
}
/**
* UTF-8 encode and write `str` to the current pointer offset and move pointer
* forward according to the encoded length.
* @param str - The string to write.
* @returns This.
*/
public writeUtf8(str: string): this {
return this.writeBytes(encode(str));
}
/**
* Export a Uint8Array view of the internal buffer.
* The view starts at the byte offset and its length
* is calculated to stop at the last written byte or the original length.
* @returns A new Uint8Array view.
*/
public toArray(): Uint8Array {
return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
}
/**
* Get the total number of bytes written so far, regardless of the current offset.
* @returns - Total number of bytes.
*/
public getWrittenByteLength() {
return this.lastWrittenByte - this.byteOffset;
}
/**
* Update the last written byte offset
* @private
*/
private _updateLastWrittenByte(): void {
if (this.offset > this.lastWrittenByte) {
this.lastWrittenByte = this.offset;
}
}
}

10
SuiviREForamteur/node_modules/iobuffer/src/text.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
export function decode(bytes: Uint8Array, encoding = 'utf8'): string {
const decoder = new TextDecoder(encoding);
return decoder.decode(bytes);
}
const encoder = new TextEncoder();
export function encode(str: string): Uint8Array {
return encoder.encode(str);
}