(bytes: Uint8Array)
| 214 | } |
| 215 | |
| 216 | export function parseInternedStrings(bytes: Uint8Array): readonly string[] { |
| 217 | if (!(bytes instanceof Uint8Array) || bytes.byteLength < HEADER_SIZE) { |
| 218 | return Object.freeze([]); |
| 219 | } |
| 220 | |
| 221 | const merged: string[] = []; |
| 222 | let off = 0; |
| 223 | let parsedAny = false; |
| 224 | while (off + HEADER_SIZE <= bytes.byteLength) { |
| 225 | const magic = u32(bytes, off + 0); |
| 226 | const headerSize = u32(bytes, off + 8); |
| 227 | const totalSize = u32(bytes, off + 12); |
| 228 | if ( |
| 229 | magic !== ZRDL_MAGIC || |
| 230 | headerSize !== HEADER_SIZE || |
| 231 | totalSize < HEADER_SIZE || |
| 232 | (totalSize & 3) !== 0 || |
| 233 | off + totalSize > bytes.byteLength |
| 234 | ) { |
| 235 | break; |
| 236 | } |
| 237 | |
| 238 | parsedAny = true; |
| 239 | try { |
| 240 | const list = parseInternedStringsSingle(bytes.subarray(off, off + totalSize)); |
| 241 | merged.push(...list); |
| 242 | } catch { |
| 243 | return Object.freeze([]); |
| 244 | } |
| 245 | off += totalSize; |
| 246 | } |
| 247 | |
| 248 | if (parsedAny && off === bytes.byteLength) { |
| 249 | return Object.freeze(merged); |
| 250 | } |
| 251 | |
| 252 | try { |
| 253 | return parseInternedStringsSingle(bytes); |
| 254 | } catch { |
| 255 | return Object.freeze([]); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | export function parseBlobById(bytes: Uint8Array, blobId: number): Uint8Array | null { |
| 260 | const resources = parseResourceState(bytes); |
no test coverage detected