( input: ArrayBuffer | Uint8Array, )
| 602 | } |
| 603 | |
| 604 | export function tryPcSogsZip( |
| 605 | input: ArrayBuffer | Uint8Array, |
| 606 | ): { name: string; json: PcSogsJson | PcSogsV2Json } | undefined { |
| 607 | try { |
| 608 | const fileBytes = |
| 609 | input instanceof ArrayBuffer ? new Uint8Array(input) : input; |
| 610 | let metaFilename: string | null = null; |
| 611 | |
| 612 | const unzipped = unzipSync(fileBytes, { |
| 613 | filter: ({ name }) => { |
| 614 | const filename = name.split(/[\\/]/).pop() as string; |
| 615 | if (filename === "meta.json") { |
| 616 | metaFilename = name; |
| 617 | return true; |
| 618 | } |
| 619 | return false; |
| 620 | }, |
| 621 | }); |
| 622 | if (!metaFilename) { |
| 623 | return undefined; |
| 624 | } |
| 625 | |
| 626 | // Check for PC SOGS V1 and V2 (aka SOG) |
| 627 | const json = tryPcSogs(unzipped[metaFilename]); |
| 628 | if (!json) { |
| 629 | return undefined; |
| 630 | } |
| 631 | return { name: metaFilename, json }; |
| 632 | } catch { |
| 633 | return undefined; |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | export async function unpackSplats({ |
| 638 | input, |
no test coverage detected