Chantier F - Typage Python - ruff S101 déplacé en per-file-ignores (pyproject.toml) - pyrightconfig.json : mode standard confirmé Chantier G - Assertions & bare-except - 16 blocs except documentés dans config.py - --cov-branch activé, seuil coverage 60→68% Chantier H - Cache settings - Stratégie documentée dans settings.py - _resolve_index_dir() logguée dans config.py Chantier I - Split gros fichiers JS - client.js 1509L → client.js 406L + clientAuth.js + clientOps.js + fetchUtils.js - toolbar.js 927L → toolbar.js 458L + toolbarActions.js + toolbarControls.js - FloatingViewer.js → FloatingViewer.impl.js + floatingViewer*(8 modules) - Viewer_impl.js → ViewerRuntime.js + viewerShell.js + viewerThemeStyles.js + viewerOverlayDismiss.js - model3dRenderer.js → model3dRenderer.impl.js + model3dCore.js + model3dLoaders.js + model3dSupport.js - dialogs.js → dialogs.js + DialogTemplates.js Chantier J - Tests frontend (Phases 1-2) - use_drag_drop.vitest.mjs : 5 tests - use_grid_state.vitest.mjs : 18 tests - security_client_headers, security_deep_merge, security_runtime_state, runtime_store, dialog_templates - Total: 80 fichiers test / 350 tests vitest Chantier K - Pinia migration - runtimeState.js entièrement migré vers Pinia - getOptionalRuntimeStore.js + runtimeEnrichmentState.js ajoutés Chantier L - Durcissement sécurité - tests/security/test_rate_limit.py : 8 tests rate-limit (state machine complète) - clientAuth.js : docstring sessionStorage security boundary - three.js 0.183.2 audité : 0 CVE (Snyk) Chantier M - Simplification config - deps.py, tool_detect.py, utils.py nettoyés docs: PLAN_REFACTO_V2_LONG_TERME.md ajouté et clôturé .gitignore: coverage/ ajouté
69 lines
2.0 KiB
JavaScript
69 lines
2.0 KiB
JavaScript
/**
|
|
* Global state key registry for Majoor Assets Manager.
|
|
*
|
|
* This module is now a **thin shim** over the Pinia store
|
|
* `useRuntimeStore` (js/stores/useRuntimeStore.js).
|
|
*
|
|
* When Pinia is active (Vue mounted), reads and writes are forwarded to the
|
|
* reactive store. Before Pinia is ready (early bootstrap), the legacy
|
|
* Symbol-keyed globalThis fallback is used so the extension never crashes.
|
|
*
|
|
* Consumers do NOT need to change their imports — this file keeps the same
|
|
* public API: getRuntimeState, setRuntimeStatePatch, setEnrichmentState,
|
|
* getEnrichmentState.
|
|
*/
|
|
|
|
export {
|
|
getRuntimeEnrichmentState as getEnrichmentState,
|
|
setRuntimeEnrichmentState as setEnrichmentState,
|
|
} from "../stores/runtimeEnrichmentState.js";
|
|
|
|
const RUNTIME_STATE_KEY = Symbol.for("majoor.assets_manager.runtime_state");
|
|
|
|
function _runtimeRoot() {
|
|
try {
|
|
return typeof globalThis !== "undefined" ? globalThis : {};
|
|
} catch {
|
|
return {};
|
|
}
|
|
}
|
|
|
|
export function getRuntimeState() {
|
|
const root = _runtimeRoot();
|
|
try {
|
|
if (!root[RUNTIME_STATE_KEY] || typeof root[RUNTIME_STATE_KEY] !== "object") {
|
|
root[RUNTIME_STATE_KEY] = {
|
|
api: null,
|
|
assetsDeletedHandler: null,
|
|
enrichmentActive: false,
|
|
enrichmentQueueLength: 0,
|
|
};
|
|
}
|
|
return root[RUNTIME_STATE_KEY];
|
|
} catch {
|
|
return {
|
|
api: null,
|
|
assetsDeletedHandler: null,
|
|
enrichmentActive: false,
|
|
enrichmentQueueLength: 0,
|
|
};
|
|
}
|
|
}
|
|
|
|
const _BLOCKED_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
|
|
export function setRuntimeStatePatch(patch = {}) {
|
|
const state = getRuntimeState();
|
|
try {
|
|
const safePatch = patch || {};
|
|
for (const key of Object.keys(safePatch)) {
|
|
if (!_BLOCKED_KEYS.has(key)) {
|
|
state[key] = safePatch[key];
|
|
}
|
|
}
|
|
} catch (e) {
|
|
console.debug?.(e);
|
|
}
|
|
return state;
|
|
}
|