Files
jsonPrism/public/theme-init.js
T
poli0981andClaude Opus 5.5 532b5cfd82 JSONPrism 2.0.0: Cloudflare Workers, TypeScript 7 and a full audit (#151)
- Web app moves to https://jsonprism.poli0981.dev on Cloudflare Workers
  (static assets + /api/turnstile/verify + /api/health), with security
  headers, redirects for the old /jsonPrism paths, previews for
  non-production branches and a production smoke workflow. GitHub Pages
  only redirects now.
- Web-only Turnstile human check (server-verified, 7-day pass) and
  cookieless Web Analytics (after consent, opt-out, off under GPC);
  Privacy Policy and Terms 2.0, consent version 2.
- Node 26, TypeScript 7 with the TS 6 API alias for typescript-eslint,
  dependencies on current majors (ends the ERESOLVE that kept main red).
- Converter fixes: CSV columns, binary ZIP entries, MySQL backslash
  escaping, RESX/XML validity, BSON size, YAML quoting and alias limits,
  TOML nulls and big integers, JSON error positions, JSONL/BOM linting.
- Web Worker conversion, faster editor, technical UI refresh with an
  Appearance menu and custom scrollbars, accessibility and i18n gaps.
- Tauri least-privilege capabilities, hardened CSP, Tauri 2.12.
- CI: SHA-pinned least-privilege workflows, SonarQube Cloud, Rust job,
  verifiable releases (SHA256SUMS + provenance); Dependabot grouping.
- 864 tests (97% line coverage), SonarCloud quality gate passing; docs,
  legal and CLAUDE.md refreshed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 23:05:14 +07:00

30 lines
1.4 KiB
JavaScript

// Applies the saved theme and display preferences before the first paint so
// the page never flashes the wrong theme. Loaded as a blocking external script
// (not inline) so the Content-Security-Policy can stay free of 'unsafe-inline'.
// Mirrors src/lib/theme.tsx and src/stores/preferencesStore.ts — keep the
// storage keys and colors in sync with those files.
(function () {
var root = document.documentElement;
var theme = 'system';
var hideScrollbars = false;
try {
var stored = window.localStorage.getItem('jsonprism.theme');
if (stored === 'light' || stored === 'dark' || stored === 'system') theme = stored;
var prefs = JSON.parse(window.localStorage.getItem('jsonprism.prefs') || 'null');
hideScrollbars = !!(prefs && prefs.hideScrollbars === true);
} catch (e) {
// Blocked storage: fall back to the system theme.
}
// Same default as systemTheme() in src/lib/theme-dom.ts: dark when the
// browser cannot report a preference.
var dark =
theme === 'dark' ||
(theme === 'system' &&
(!window.matchMedia || window.matchMedia('(prefers-color-scheme: dark)').matches));
root.classList.toggle('dark', dark);
root.style.colorScheme = dark ? 'dark' : 'light';
if (hideScrollbars) root.setAttribute('data-scrollbars', 'hidden');
var meta = document.querySelector('meta[name="theme-color"]');
if (meta) meta.setAttribute('content', dark ? '#0b0c14' : '#fbfbfe');
})();