probe-node-schema.mjs 825 B

1234567891011121314151617181920212223
  1. // 探查 textLayer 与 imageUrl 节点的真实字段
  2. import { readFileSync } from 'node:fs'
  3. const j = JSON.parse(readFileSync(process.argv[2], 'utf8'))
  4. let textSample = null
  5. let imgSample = null
  6. function walk(n) {
  7. if (!textSample && n.type === 'textLayer') textSample = n
  8. if (!imgSample && JSON.stringify(n).includes('imageUrl')) imgSample = n
  9. for (const c of n.layers || []) walk(c)
  10. }
  11. walk(j.artboard)
  12. if (textSample) {
  13. console.log('=== textLayer keys:', Object.keys(textSample).join(','))
  14. console.log(JSON.stringify(textSample, null, 1).slice(0, 1500))
  15. }
  16. if (imgSample) {
  17. console.log('\n=== node-with-imageUrl keys:', Object.keys(imgSample).join(','))
  18. const s = JSON.stringify(imgSample, null, 1)
  19. const i = s.indexOf('imageUrl')
  20. console.log(s.slice(Math.max(0, i - 600), i + 400))
  21. }