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>
This commit is contained in:
2026-03-18 22:19:56 +01:00
parent c364e2b46d
commit c7b8fd516a
139 changed files with 7591 additions and 2535 deletions

View File

@@ -1,9 +1,10 @@
/**
* High-contrast mode toggle with localStorage persistence.
*/
import { requireEl } from '../core/app-dom.js';
import { warnOnce, resolveHost } from '../core/app-dom.js';
import { createUiStorage } from '../core/app-ui-storage.js';
const STORAGE_KEY = 'app-contrast';
const STORAGE_KEY = 'contrast-mode';
const setContrast = (contrast) => {
const root = document.documentElement;
@@ -12,7 +13,9 @@ const setContrast = (contrast) => {
const setIcon = (button, contrast) => {
const icon = button.querySelector('i');
if (!icon) {return;}
if (!icon) {
return;
}
icon.classList.remove('bi-circle-half', 'bi-highlights');
icon.classList.add(contrast === 'high' ? 'bi-highlights' : 'bi-circle-half');
};
@@ -21,30 +24,48 @@ const setPressedState = (button, contrast) => {
button.setAttribute('aria-pressed', contrast === 'high' ? 'true' : 'false');
};
const initContrastToggle = () => {
const button = requireEl('[data-contrast-toggle]', { module: 'contrast-toggle' });
if (!button) {return;}
const root = document.documentElement;
const getCurrent = () => (root.dataset.contrast === 'high' ? 'high' : 'normal');
export function initContrastToggle(root = document, options = {}) {
const selector = String(options.selector || '[data-contrast-toggle]').trim() || '[data-contrast-toggle]';
const storage = createUiStorage({
namespace: options.storageNamespace || 'app-ui',
version: options.storageVersion || 'v1',
scope: options.storageScope || 'contrast',
});
const scopedStorageKey = storage.buildKey('state', options.storageKey || STORAGE_KEY);
const host = resolveHost(root);
const button = host.matches?.(selector) ? host : host.querySelector(selector);
if (!(button instanceof HTMLElement)) {
warnOnce('UI_EL_MISSING', `Missing contrast toggle: ${selector}`, { module: 'contrast-toggle' });
return { destroy: () => {} };
}
if (button.dataset.contrastToggleBound === '1') {
return {
destroy: () => {
delete button.dataset.contrastToggleBound;
},
};
}
button.dataset.contrastToggleBound = '1';
const getCurrent = () => (document.documentElement.dataset.contrast === 'high' ? 'high' : 'normal');
const current = getCurrent();
setIcon(button, current);
setPressedState(button, current);
button.addEventListener('click', () => {
const onClick = () => {
const next = getCurrent() === 'high' ? 'normal' : 'high';
setContrast(next);
setIcon(button, next);
setPressedState(button, next);
try {
window.localStorage.setItem(STORAGE_KEY, next);
} catch (e) {
// ignore storage errors
}
});
};
storage.setItem(scopedStorageKey, next);
};
button.addEventListener('click', onClick);
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initContrastToggle);
} else {
initContrastToggle();
const destroy = () => {
button.removeEventListener('click', onClick);
delete button.dataset.contrastToggleBound;
};
return { destroy };
}