feat(patcher): 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:
1 parent
89aa5198c3
commit
c3914ec0d6
44 files changed
+1986
-1
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* The shared name map of a data pack: the file named "nm" inside a .vromfs.bin.
|
||||
*
|
||||
* BLK documents with format labels 3, 4 and 5 refer to these names instead of carrying
|
||||
* their own (format.ts). Layout, checked against the stock 2.61.0.37 char.vromfs.bin:
|
||||
* 8 bytes hash of the names
|
||||
* 32 bytes identifier of the pack's zstd dictionary; all zero when the pack has none
|
||||
* rest zstd frame holding a name table (binary/name-table.ts)
|
||||
*/
|
||||
import { BlkFormatError } from './errors.ts';
|
||||
import { ByteReader } from './binary/byte-reader.ts';
|
||||
import { decompress } from './binary/format.ts';
|
||||
import { readNameTable } from './binary/name-table.ts';
|
||||
|
||||
const HASH_SIZE = 8;
|
||||
const DICTIONARY_ID_SIZE = 32;
|
||||
|
||||
export interface SharedNameMap {
|
||||
readonly names: readonly string[];
|
||||
/** Hex identifier of the pack's zstd dictionary, or null when the pack has none. */
|
||||
readonly dictionaryId: string | null;
|
||||
}
|
||||
|
||||
export function parseSharedNameMap(file: Uint8Array, dictionary?: Uint8Array): SharedNameMap {
|
||||
if (file.length <= HASH_SIZE + DICTIONARY_ID_SIZE) throw new BlkFormatError('shared name map is too short');
|
||||
const idBytes = file.subarray(HASH_SIZE, HASH_SIZE + DICTIONARY_ID_SIZE);
|
||||
const dictionaryId = idBytes.some((byte) => byte !== 0) ? Buffer.from(idBytes).toString('hex') : null;
|
||||
const body = decompress(file.subarray(HASH_SIZE + DICTIONARY_ID_SIZE), dictionary);
|
||||
return { names: readNameTable(new ByteReader(body)), dictionaryId };
|
||||
}
|
||||
Reference in new issue
Block a user