Files
ycode/scripts/audit-home-native-geometry.cjs

46 lines
2.8 KiB
JavaScript

// Inspect only YCode's already-built, isolated homepage fixture. No WorkBuddy connection.
const fs = require('node:fs')
const path = require('node:path')
const { app, BrowserWindow } = require('electron')
app.disableHardwareAcceleration()
const root = path.resolve(__dirname, '..')
const output = path.join(root, '.tmp', 'home-visual-audit-20261016')
fs.mkdirSync(output, { recursive: true })
app.setPath('userData', path.join(output, 'user-data'))
const selectors = [
'.wb-home-header', '.wb-home-header__title', '.wb-scene-tabs',
'.wb-segmented', '.wb-segmented-item', '.wb-home-composer__chips',
'.quick-actions__item', '.wb-home-composer__input-slot', '.cr-input-container',
'.composer__toolbar', '.composer__toolbar-left', '.composer__toolbar-right',
'.wb-home-route__growth-buddy', '.source-home-robot img',
'.wb-home-composer__below-input',
]
const properties = ['font-family', 'font-size', 'font-weight', 'line-height', 'letter-spacing',
'color', 'background-color', 'border-radius', 'border-top-width', 'border-top-color',
'padding-top', 'padding-right', 'padding-bottom', 'padding-left', 'gap', 'box-shadow',
'text-rendering', '-webkit-font-smoothing', 'transform', 'opacity']
app.whenReady().then(async () => {
const win = new BrowserWindow({ width: 1336, height: 901, useContentSize: true,
frame: false, show: false, webPreferences: { contextIsolation: true, nodeIntegration: false } })
const errors = []
win.webContents.on('console-message', (_event, level, message) => { if (level === 3) errors.push(message) })
const fixture = path.join(root, '.tmp', 'home-native-ui', 'index.html')
await win.loadFile(fixture)
await new Promise(resolve => setTimeout(resolve, 1350))
const nodes = await win.webContents.executeJavaScript(`(${function (selectors, properties) {
return selectors.flatMap(selector => Array.from(document.querySelectorAll(selector), (el, index) => {
const r = el.getBoundingClientRect(), style = getComputedStyle(el)
return { selector, index, text: el.textContent, bounds: [r.x, r.y, r.width, r.height],
styles: Object.fromEntries(properties.map(key => [key, style.getPropertyValue(key)])) }
}))
}.toString()})(${JSON.stringify(selectors)},${JSON.stringify(properties)})`)
fs.writeFileSync(path.join(output, 'native-layout.json'), JSON.stringify({
capturedAt: new Date().toISOString(), fixture, viewport: { width: 1336, height: 901 }, nodes, errors,
scope: 'Frozen YCode fixture bundle, not the production app and not the original WorkBuddy runtime',
}, null, 2))
fs.writeFileSync(path.join(output, 'native.png'), (await win.webContents.capturePage()).toPNG())
win.destroy()
console.log(JSON.stringify({ output, nodes: nodes.length, errors }))
app.quit()
}).catch(error => { console.error(error); app.exit(1) })