CMMS fork: Phase 6 polish — schema.html light theme + load-time IndexedDB wipe

- cmms-bridge.js: wipeProjectData() clears the project object stores (devices,
  boards, components, images, overlappedImages, nets, schemas, schemaComponents
  — not the KiCad symbol library) and resets studio.js's shared globals before
  the CMMS attachment ZIP is imported. The ZIP is the single source of truth for
  a CMMS board, so restoreDevice()'s merge path (which only de-dupes on a newer
  meta.lastModified, absent on CMMS-created boards) no longer accretes duplicate
  image/net rows across repeated opens. init() also stamps data-theme=light as
  well as =dark. All gated on PCBRETRACE_CONFIG — standalone untouched.
- schema.html: inline head script mirrors ?theme=light|dark (passed by studio.js
  on the iframe src) onto <html> and, for light, injects cmms-schema-light.css.
  Full no-op with no ?theme=.
- cmms-schema-light.css (new): [data-theme="light"]-gated override of
  schema.html's :root palette for the CMMS light theme. Canvas stays dark.
- studio.js: append ?theme=<active> to the schema.html iframe src.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Stuart 2026-09-09 22:08:45 +10:00
commit eeb2af1e15
4 changed files with 84 additions and 2 deletions

View file

@ -1528,7 +1528,10 @@ function switchView(v) {
// 'contentWindow.location:', frame.contentWindow?.location?.href);
frame.contentWindow.postMessage(msg, '*');
};
frame.src = 'schema.html';
// CMMS fork: hand the schema iframe the active theme so its
// light-mode override sheet can match the CMMS (no-op standalone).
const _t = document.documentElement.getAttribute('data-theme');
frame.src = 'schema.html' + (_t ? '?theme=' + encodeURIComponent(_t) : '');
// console.log('[studio] frame clientWidth:', frame.clientWidth,
// 'clientHeight:', frame.clientHeight,
// 'offsetWidth:', frame.offsetWidth,