40 lines
2.7 KiB
JavaScript
40 lines
2.7 KiB
JavaScript
// Reconstruct an inert SVG from saved REA exports; never accesses WorkBuddy.
|
|
import fs from 'node:fs/promises'
|
|
import crypto from 'node:crypto'
|
|
const exportData = JSON.parse(await fs.readFile('.tmp/rea-runtime-scripts.json', 'utf8'))
|
|
const evidenceId = 'ev_717fa5e846e64d67ac19c8925d121bff632c0d3aefb3603b10858559cabb2dcb'
|
|
if (exportData.evidence_id !== evidenceId) throw new Error('REA runtime evidence changed')
|
|
function source(file, expected) {
|
|
const item = exportData.items.find(i => i.file_path?.replaceAll('\\', '/').endsWith('/' + file))
|
|
const text = item?.source?.artifact?.text
|
|
if (!text || crypto.createHash('sha256').update(text).digest('hex') !== expected || item.source.artifact.sha256 !== expected) throw new Error(`REA source digest mismatch: ${file}`)
|
|
return text
|
|
}
|
|
const contextsHash = '5f35b7489b107e21ef452c8ee88a95265756f6fc444841eef869228bbc44768b'
|
|
const iconHash = '747e41d215375e1214c366213aea7e077d85421923029c61cbb6e9562be58de0'
|
|
const contexts = source('contexts-BMeWSUHk.js', contextsHash)
|
|
const icons = source('src-DPDj7_qD.js', iconHash)
|
|
if (!contexts.includes('pl as yo') || !contexts.includes('(yo,{className:`conversation-high-credit-approval__option-arrow`}')) throw new Error('Approval icon binding changed')
|
|
if (!icons.includes('uc as pl') || !icons.includes('uc=createIcon(lc)') || !icons.includes('yn={sm:14,md:16,lg:20,xl:24}')) throw new Error('Approval icon export or wrapper default changed')
|
|
const start = icons.indexOf('lc=(0,sc.forwardRef)')
|
|
const end = icons.indexOf(')),lc.displayName=', start) + 2
|
|
if (start < 0 || end < start) throw new Error('Approval SVG definition is missing')
|
|
const definition = icons.slice(start, end)
|
|
function literal(key) {
|
|
const match = definition.match(new RegExp(`${key}:\x60([^\x60]+)\x60`))
|
|
if (!match) throw new Error(`Approval SVG attribute missing: ${key}`)
|
|
return JSON.stringify(match[1])
|
|
}
|
|
const output = `// Generated from REA ${evidenceId}.
|
|
// contexts-BMeWSUHk.js sha256 ${contextsHash}: yo -> pl -> uc -> lc.
|
|
// src-DPDj7_qD.js sha256 ${iconHash}; UTF-16 [${start}, ${end}).
|
|
// createIcon defaults to md=16; original approval supplies only className.
|
|
export function ApprovalChevronIcon({ className }: { className?: string }) {
|
|
return <svg className={className} width="16" height="16" viewBox={${literal('viewBox')}} fill={${literal('fill')}} aria-hidden="true">
|
|
<path d={${literal('d')}} stroke={${literal('stroke')}} strokeWidth={${literal('strokeWidth')}} strokeLinecap={${literal('strokeLinecap')}} strokeLinejoin={${literal('strokeLinejoin')}} />
|
|
</svg>
|
|
}
|
|
`
|
|
await fs.writeFile('src/renderer/src/workbuddy/conversation/ApprovalSourceIcon.tsx', output)
|
|
console.log(JSON.stringify({ evidenceId, icon: 'ApprovalChevronIcon', utf16Range: [start, end], sources: [contextsHash, iconHash] }))
|