probe-v2-structure.mjs 1.2 KB

123456789101112131415161718192021222324
  1. // 列出新版 Desktop-2 的顶层结构,并定位 nav / chip / 中央一张图
  2. import { readFileSync } from 'node:fs'
  3. const j = JSON.parse(readFileSync('.scratch/lanhu-cockpit-asset-replacement/research/raw-v2/desktop-02.json', 'utf8'))
  4. const ab = j.artboard
  5. console.log('top-level layers:')
  6. for (const l of ab.layers || []) {
  7. console.log(` ${l.type}:${l.name} ${Math.round(l.frame?.width ?? 0)}x${Math.round(l.frame?.height ?? 0)} children=${(l.layers || []).length}`)
  8. }
  9. // 全树找 name 含 Chip / nav / Layer 的节点
  10. const hits = []
  11. ;(function walk(node, path = '') {
  12. const p = path ? `${path}/${node.name}` : node.name
  13. if (/(^|\/)(nav|Chip|Chip:|Layer)(:|$|\/)/.test(node.name)) hits.push({ node, path: p })
  14. for (const ch of node.layers || []) walk(ch, p)
  15. })(ab, '')
  16. console.log(`\nmatched nodes: ${hits.length}`)
  17. for (const h of hits.slice(0, 12)) {
  18. const kids = (h.node.layers || []).map((c) => `${c.type}:${c.name}`).slice(0, 8)
  19. console.log(` ${h.node.type}:${h.node.name} ${Math.round(h.node.frame?.width ?? 0)}x${Math.round(h.node.frame?.height ?? 0)} | ${h.path}`)
  20. if (kids.length) console.log(` children: ${kids.join(', ')}`)
  21. }