Build a loopback client copy with TypeScript

Add the shared BLK, VROMFS, executable patch, and build packages. Preserve
typed fields and shared name tables when reading BLK data. Rewrite the
service endpoints in place so the original environment names remain
available to the client, then build the client copy.
This commit is contained in:
N0VAN0M4LY committed 2026-11-24 00:35:13 +08:00
1 parent 0117c02677
commit 5421268fbf
44 files changed
+1986 -1

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
/** Sequential little-endian reader over a byte array, with the format's variable-length integers. */
import { BlkFormatError } from '../errors.ts';
export class ByteReader {
readonly bytes: Uint8Array;
offset = 0;
constructor(bytes: Uint8Array) {
this.bytes = bytes;
}
get remaining(): number {
return this.bytes.length - this.offset;
}
u8(): number {
this.require(1);
return this.bytes[this.offset++]!;
}
take(length: number): Uint8Array {
this.require(length);
const slice = this.bytes.subarray(this.offset, this.offset + length);
this.offset += length;
return slice;
}
/** Unsigned LEB128: 7 bits per byte, least significant group first, high bit = more bytes follow. */
varUint(): number {
let value = 0;
for (let shift = 0; shift < 35; shift += 7) {
const byte = this.u8();
value += (byte & 0x7f) * 2 ** shift;
if ((byte & 0x80) === 0) return value;
}
throw new BlkFormatError(`variable-length integer at offset ${this.offset} is too long`);
}
private require(length: number): void {
if (length > this.remaining) {
throw new BlkFormatError(`unexpected end of data: need ${length} bytes at offset ${this.offset}, have ${this.remaining}`);
}
}
}