(outBase, uuid, className, wasCcon, packRef)
| 631 | if (r) return r; |
| 632 | } |
| 633 | return null; |
| 634 | } |
| 635 | for (const k of Object.keys(obj)) { |
| 636 | const r = visit(obj[k], depth + 1); |
| 637 | if (r) return r; |
| 638 | } |
| 639 | return null; |
| 640 | }; |
| 641 | return visit(doc, 0); |
| 642 | } |
| 643 | |
| 644 | async function decodeCconToDoc(buf, outBase) { |
| 645 | const decoded = decodeCcon(buf); |
| 646 | // Both v1 (JSON) and v2 (notepack) yield a `document` when decodable. |
| 647 | if (decoded.document) { |
| 648 | // Persist chunks alongside the JSON so mesh/animation payloads are not lost. |
| 649 | for (let i = 0; i < decoded.chunks.length; i += 1) { |
| 650 | await writeFile(`${outBase}.chunk${i}.bin`, decoded.chunks[i]); |
| 651 | } |
| 652 | return decoded.document; |
| 653 | } |
no test coverage detected