Files
breadcrumb-the-shire/web/js/app-boot.js
fs c7b8fd516a feat: extend module platform with UI slots, runtime components, CLI tooling and {{userId}} search support
Completes the generic module platform that enables modules to contribute
UI elements, runtime JS components, and search resources without any
core hardcoding.

New generic UI slot types:
- topbar.right_item: module-contributed topbar buttons
- layout.body_end_template: module-contributed dialog/overlay templates
- layout.head_style: module-contributed global CSS
- runtime.component: declarative JS component registration with phase ordering

New infrastructure:
- ModuleAutoloader: PSR-4 autoloading for module-local PHP classes
- ModuleRuntimePageBuilder: symlinks module pages into runtime directory
- ModuleRuntimeAssetPublisher: publishes module CSS/JS to web/modules/
- ModulePermissionSynchronizer: syncs module permissions to DB
- CLI scripts: module-runtime-sync, module-build, module-migrate,
  module-permissions-sync, module-assets-sync
- {{userId}} placeholder in SearchDataService for user-scoped search queries
- Component runtime with phased initialization (early/default/late)
- AppContainer.protectExistingBindings() to prevent module→core overwrites
- Architecture tests: ModuleStructureContractTest, CoreTemplateIsolationTest,
  FrontendComponentRuntimeContractTest, AppContainerIsolationContractTest

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 22:19:56 +01:00

54 lines
1.9 KiB
JavaScript

/**
* Render-blocking boot script — runs synchronously before first paint.
*
* Intentionally a classic IIFE (not an ES module) so the browser executes it
* immediately while parsing <head>. This prevents layout flicker by applying
* persisted UI state (sidebar collapsed, contrast mode) before any content
* is rendered. Uses `var` for broadest compatibility in the sync path.
*/
(function () {
var root = document.documentElement;
root.classList.remove('no-js');
root.classList.add('js');
root.classList.add('aside-pending');
var normalizeToken = function (value) {
return String(value == null ? '' : value)
.trim()
.toLowerCase()
.replace(/[^a-z0-9._-]+/g, '-')
.replace(/^-+|-+$/g, '');
};
var buildStorageKey = function (scope, key) {
var namespace = normalizeToken('app-ui') || 'app-ui';
var version = normalizeToken('v1') || 'v1';
var normalizedScope = normalizeToken(scope || '') || 'global';
var normalizedKey = normalizeToken(key || '');
if (!normalizedKey) {
return '';
}
return namespace + ':' + version + ':' + normalizedScope + ':state:' + normalizedKey;
};
try {
var sidebarCollapsedKey = buildStorageKey('sidebar', 'sidebar-collapsed');
var sidebarHiddenKey = buildStorageKey('sidebar', 'sidebar-hidden');
var contrastKey = buildStorageKey('contrast', 'contrast-mode');
if (sidebarCollapsedKey && window.localStorage.getItem(sidebarCollapsedKey) === '1') {
root.classList.add('sidebar-collapsed');
}
if (sidebarHiddenKey && window.localStorage.getItem(sidebarHiddenKey) === '1') {
root.classList.add('sidebar-hidden');
}
var contrastValue = contrastKey ? window.localStorage.getItem(contrastKey) : null;
if (contrastValue === 'high') {
root.dataset.contrast = 'high';
} else {
root.dataset.contrast = 'normal';
}
} catch (e) {
// ignore storage errors
}
})();