feat(extension): redesign welcome page with Prism.js syntax highlighting

This commit is contained in:
Tommy D. Rossi
2026-01-27 18:36:14 +01:00
parent 1de0f6d1a4
commit 653f00c3a3
5 changed files with 109 additions and 33 deletions
+42
View File
@@ -0,0 +1,42 @@
// Downloads Prism.js assets into dist/src/ for the welcome page.
// Chrome extension CSP blocks external scripts, so we bundle them locally.
import https from 'node:https'
import fs from 'node:fs'
import path from 'node:path'
const BASE = 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/'
const DEST = path.join('dist', 'src')
const files: [string, string][] = [
['prism.min.js', 'prism.min.js'],
['components/prism-bash.min.js', 'prism-bash.min.js'],
]
function download(url: string, dest: string): Promise<void> {
return new Promise((resolve, reject) => {
https.get(url, (res) => {
if (res.statusCode !== 200) {
reject(new Error(`Failed to download ${url}: ${res.statusCode}`))
return
}
const chunks: Buffer[] = []
res.on('data', (chunk: Buffer) => { chunks.push(chunk) })
res.on('end', () => {
fs.writeFileSync(dest, Buffer.concat(chunks))
resolve()
})
res.on('error', reject)
}).on('error', reject)
})
}
async function main() {
await Promise.all(
files.map(([src, dest]) => {
return download(BASE + src, path.join(DEST, dest))
})
)
console.log(`Downloaded ${files.length} Prism.js files to ${DEST}`)
}
main()