Files
ycode/scripts/rea/recover-sidebar-shell.mjs

18 lines
1.3 KiB
JavaScript

import fs from 'node:fs/promises'
import { createHash } from 'node:crypto'
import postcss from 'postcss'
const file = '.tmp/rea-css-recovered/contexts-BkjwYSZT.css'
const text = await fs.readFile(file, 'utf8')
if (createHash('sha256').update(text).digest('hex') !== '50cbd673f7f35fc7f966bdddc6c9f5677fdfe944cb904888d214619fca259380') throw new Error('REA sidebar CSS identity changed')
function select(node) {
if (node.type === 'rule') {
const selectors = node.selectors.filter(selector => /\.conversation-list(?:[ >:.#[\]-]|$)|\.conversation-list-(?:header|logo|brand|version|tabs|tab-|content|footer)|\.industry-template-switcher/.test(selector))
return selectors.length ? node.clone({ selector: selectors.join(',') }) : null
}
if (node.type === 'atrule' && node.nodes) { const nodes = node.nodes.map(select).filter(Boolean); return nodes.length ? node.clone({ nodes }) : null }
return null
}
const root = postcss.root({ nodes: postcss.parse(text).nodes.map(select).filter(Boolean) })
await fs.writeFile('src/renderer/src/components/sidebar-shell-source.css', `/* Fixed REA CSS ev_377c8790468b3c67dad8577aabb327f98d3140659f0fffdbabfcff5a40cc9e94; contexts SHA 50cbd673f7f35fc7f966bdddc6c9f5677fdfe944cb904888d214619fca259380. */\n${root.toString()}\n`)
console.log('Recovered sidebar shell including original media conditions')