You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 15:06:20 +00:00
TS 5.7+ ArrayBuffer drift: cast where ArrayBufferLike leaked
TypeScript 5.7 split ArrayBuffer / SharedArrayBuffer at the type level (ArrayBuffer now exposes resizable/transfer/detached etc; SharedArrayBuffer doesn't), and parametrized the typed-array constructors so plain Uint8Array became Uint8Array<ArrayBufferLike>. The renderer never uses SharedArrayBuffer, so this is type-level only — narrowing back to ArrayBuffer at the boundaries: - BinaryReader.readBytes() / .toArrayBuffer() return the underlying DataView buffer; cast to ArrayBuffer. - BinaryWriter.getBuffer() same shape. - WsSessionCrypto.randomNonce() now returns Uint8Array<ArrayBuffer> (it's always backed by a plain ArrayBuffer); aesGcmEncrypt/Decrypt nonce parameter retyped accordingly so SubtleCrypto.encrypt accepts it as BufferSource. - ArrayBufferToBase64 now accepts Uint8Array | ArrayBufferLike directly (pako/inflate hands back Uint8Array<ArrayBuffer> which the old ArrayBuffer-only signature rejected).
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
export const ArrayBufferToBase64 = (buffer: ArrayBuffer) =>
|
||||
export const ArrayBufferToBase64 = (buffer: ArrayBufferLike | Uint8Array) =>
|
||||
{
|
||||
let binary = '';
|
||||
|
||||
const bytes = new Uint8Array(buffer);
|
||||
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
||||
const len = bytes.byteLength;
|
||||
|
||||
for(let i = 0; i < len; i++) (binary += String.fromCharCode(bytes[i]));
|
||||
|
||||
@@ -13,7 +13,7 @@ export class BinaryReader implements IBinaryReader
|
||||
|
||||
public readBytes(length: number): IBinaryReader
|
||||
{
|
||||
const buffer = new BinaryReader(this._dataView.buffer.slice(this._position, this._position + length));
|
||||
const buffer = new BinaryReader(this._dataView.buffer.slice(this._position, this._position + length) as ArrayBuffer);
|
||||
|
||||
this._position += length;
|
||||
|
||||
@@ -77,6 +77,6 @@ export class BinaryReader implements IBinaryReader
|
||||
|
||||
public toArrayBuffer(): ArrayBuffer
|
||||
{
|
||||
return this._dataView.buffer;
|
||||
return this._dataView.buffer as ArrayBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ export class BinaryWriter implements IBinaryWriter
|
||||
|
||||
public getBuffer(): ArrayBuffer
|
||||
{
|
||||
return this._buffer.buffer;
|
||||
return this._buffer.buffer as ArrayBuffer;
|
||||
}
|
||||
|
||||
public get position(): number
|
||||
|
||||
Reference in New Issue
Block a user