Files
pinnacle/bin/build-inline-script.js
neonoverlord 898abb3ee4
build / build (push) Successful in 3m10s
fork: remove Pinafore's theme system — bawnet is baked into the inline CSS
Operator's decision after two days of the theme machinery failing inside
the Nextcloud wrap: Pinnacle is a hard fork and has exactly one theme.

- src/scss/themes/_default.scss IS the bawnet palette now (the inline
  critical CSS renders dark from the first byte, no JS involved); all 17
  standalone theme scss files deleted, no theme-*.css is built or shipped
- themeEngine.js reduced to constants + a no-op switchToTheme so upstream
  call sites (addInstance, switchToInstance, grayscale observer) compile;
  isDarkTheme() is constant true
- inline-script: no __themeColors, no theme resolution, no migration —
  nothing stored in the browser can affect the palette anymore
- theme picker deleted from Settings > General and the per-instance page;
  ThemeSettings component and _static/themes.js removed
- template meta theme-color: #00E0FF
- wellness grayscale mode still works (CSS filter via its observer) — the
  one deliberate appearance toggle left, and it is user-visible in Wellness

NC-colors live wiring (ops/features#35) lands on the app side: the
ClientController injects Nextcloud's configured theming colors over the
baked shell at serve time.
2026-08-06 12:23:04 -07:00

54 lines
2.0 KiB
JavaScript

import crypto from 'crypto'
import fs from 'fs'
import { promisify } from 'util'
import path from 'path'
import { rollup } from 'rollup'
import { terser } from 'rollup-plugin-terser'
import replace from '@rollup/plugin-replace'
import terserOptions from './terserOptions.js'
const __dirname = path.dirname(new URL(import.meta.url).pathname)
const writeFile = promisify(fs.writeFile)
export async function buildInlineScript () {
const inlineScriptPath = path.join(__dirname, '../src/inline-script/inline-script.js')
const bundle = await rollup({
input: inlineScriptPath,
plugins: [
replace({
values: {
'process.browser': true,
// the inline script imports basepath.js (via themeEngine); this
// rollup pass knows nothing of webpack's DefinePlugin, so without
// this entry a live `process.env.BASEPATH` reaches the browser and
// the WHOLE inline script dies on line 1 with "process is not
// defined" — no boot theme, no __themeColors, every later
// switchToTheme() throws (the dead-themes bug, ops/features#30)
'process.env.BASEPATH': JSON.stringify(process.env.BASEPATH || '')
},
preventAssignment: true
}),
// TODO: can't disable terser at all, it causes the CSP checksum to stop working
// because the HTML gets minified as some point so the checksums don't match.
terser({ ...terserOptions, mangle: !process.env.DEBUG })
]
})
const { output } = await bundle.generate({
format: 'iife',
sourcemap: true
})
const { code, map } = output[0]
const fullCode = `${code}//# sourceMappingURL=/inline-script.js.map`
const checksum = crypto.createHash('sha256').update(fullCode, 'utf8').digest('base64')
await writeFile(path.resolve(__dirname, '../src/inline-script/checksum.js'),
`export default ${JSON.stringify(checksum)}`, 'utf8')
await writeFile(path.resolve(__dirname, '../static/inline-script.js.map'),
map.toString(), 'utf8')
return '<script>' + fullCode + '</script>'
}