fix(lab-content-engine): phase 0 - устранены 3 блокера ревью
- подключён _registry.js в lab.html (был отсутствует -> LabRegistry был undefined) - регистрация 3 пилотов в _pilots.js (graph/quadratic/pendulum), подключён последним - loadTheory (lab-glue.js) адаптирован: реестр в приоритете, иначе THEORY Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
'use strict';
|
||||||
|
/*
|
||||||
|
* Пилотная регистрация в LabRegistry (Фаза 0 контент-движка).
|
||||||
|
*
|
||||||
|
* Доказывает паритет: каталог/открытие/теория этих 3 симуляций идут через реестр.
|
||||||
|
* Загружается ПОСЛЕДНИМ среди labs-скриптов, поэтому P_* (lab-glue.js),
|
||||||
|
* THEORY (lab-init.js) и _openXxx (graph/quadratic/pendulum.js) уже определены.
|
||||||
|
* preview задан функцией (ленивое вычисление в renderSims) — безопасно к порядку.
|
||||||
|
*
|
||||||
|
* В Фазе 1 регистрация переедет в сами sim-файлы, а этот файл будет удалён.
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
if (!window.LabRegistry) return;
|
||||||
|
var R = window.LabRegistry;
|
||||||
|
|
||||||
|
R.register({
|
||||||
|
id: 'graph', cat: 'math',
|
||||||
|
title: 'График функции', desc: 'Постройте и исследуйте графики функций',
|
||||||
|
preview: function () { return (typeof P_GRAPH !== 'undefined') ? P_GRAPH : ''; },
|
||||||
|
theory: (typeof THEORY !== 'undefined') ? THEORY.graph : null,
|
||||||
|
open: function () { _openGraph(); },
|
||||||
|
stop: function () { /* нет анимационного цикла */ },
|
||||||
|
destroy: function () { /* нет ресурсов для освобождения */ }
|
||||||
|
});
|
||||||
|
|
||||||
|
R.register({
|
||||||
|
id: 'quadratic', cat: 'math',
|
||||||
|
title: 'Квадратное уравнение', desc: 'Дискриминант, корни, теорема Виета',
|
||||||
|
preview: function () { return (typeof P_QUADRATIC !== 'undefined') ? P_QUADRATIC : ''; },
|
||||||
|
theory: (typeof THEORY !== 'undefined') ? THEORY.quadratic : null,
|
||||||
|
open: function () { _openQuadratic(); },
|
||||||
|
stop: function () { /* нет анимационного цикла */ },
|
||||||
|
destroy: function () { /* нет ресурсов для освобождения */ }
|
||||||
|
});
|
||||||
|
|
||||||
|
R.register({
|
||||||
|
id: 'pendulum', cat: 'phys',
|
||||||
|
title: 'Маятник', desc: 'Колебания, период, затухание',
|
||||||
|
preview: function () { return (typeof P_PENDULUM !== 'undefined') ? P_PENDULUM : ''; },
|
||||||
|
theory: (typeof THEORY !== 'undefined') ? THEORY.pendulum : null,
|
||||||
|
open: function () { _openPendulum(); },
|
||||||
|
stop: function () { if (typeof pendSim !== 'undefined' && pendSim && pendSim.stop) pendSim.stop(); },
|
||||||
|
destroy: function () { if (typeof pendSim !== 'undefined' && pendSim && pendSim.stop) pendSim.stop(); }
|
||||||
|
});
|
||||||
|
})();
|
||||||
@@ -949,7 +949,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadTheory(simId) {
|
function loadTheory(simId) {
|
||||||
const t = THEORY[simId];
|
// Контент-движок: теория мигрированных симуляций берётся из манифеста реестра.
|
||||||
|
const _rm = window.LabRegistry ? window.LabRegistry.get(simId) : null;
|
||||||
|
const t = (_rm && _rm.theory) ? _rm.theory : THEORY[simId];
|
||||||
const el = document.getElementById('theory-content');
|
const el = document.getElementById('theory-content');
|
||||||
if (!t) { el.innerHTML = '<div class="tp-text" style="text-align:center;padding:40px 0;color:var(--text-3)">Теория для этой симуляции пока не добавлена</div>'; return; }
|
if (!t) { el.innerHTML = '<div class="tp-text" style="text-align:center;padding:40px 0;color:var(--text-3)">Теория для этой симуляции пока не добавлена</div>'; return; }
|
||||||
let html = `<div class="tp-title">${LS.icon('book-open',16)} ${t.title}</div>`;
|
let html = `<div class="tp-title">${LS.icon('book-open',16)} ${t.title}</div>`;
|
||||||
|
|||||||
@@ -4801,6 +4801,7 @@
|
|||||||
<script src="/js/api.js"></script>
|
<script src="/js/api.js"></script>
|
||||||
<script src="/js/sidebar.js"></script>
|
<script src="/js/sidebar.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/three@0.149.0/build/three.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/three@0.149.0/build/three.min.js"></script>
|
||||||
|
<script src="/js/labs/_registry.js"></script>
|
||||||
<script src="/js/labs/_fx_core.js"></script>
|
<script src="/js/labs/_fx_core.js"></script>
|
||||||
<script src="/js/labs/_fx_particles.js"></script>
|
<script src="/js/labs/_fx_particles.js"></script>
|
||||||
<script src="/js/labs/_fx_motion.js"></script>
|
<script src="/js/labs/_fx_motion.js"></script>
|
||||||
@@ -4863,6 +4864,7 @@
|
|||||||
<script src="/js/labs/_periodic_data.js" defer></script>
|
<script src="/js/labs/_periodic_data.js" defer></script>
|
||||||
<script src="/js/labs/periodic.js" defer></script>
|
<script src="/js/labs/periodic.js" defer></script>
|
||||||
<script src="/js/labs/qualanalysis.js" defer></script>
|
<script src="/js/labs/qualanalysis.js" defer></script>
|
||||||
|
<script src="/js/labs/_pilots.js" defer></script>
|
||||||
<script>
|
<script>
|
||||||
/* Sync sound toggle button icon with localStorage state on load */
|
/* Sync sound toggle button icon with localStorage state on load */
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ manifest: `{ id, cat, title, desc, preview(string|fn), theory?, bodyId?, mount?(
|
|||||||
- `closeSim()`/`_pauseAllSims()` — дополнительно `LabRegistry.stopActive()` / `destroyActive()`.
|
- `closeSim()`/`_pauseAllSims()` — дополнительно `LabRegistry.stopActive()` / `destroyActive()`.
|
||||||
|
|
||||||
## Temporary Workarounds
|
## Temporary Workarounds
|
||||||
- (пока нет)
|
- Пилоты (graph/quadratic/pendulum) оставлены в SIMS/THEORY для порядка карточек и единого источника теории; merge перекрывает по id. Удалить в Фазе 1.
|
||||||
|
|
||||||
|
## Known follow-ups (из ревью Фазы 0)
|
||||||
|
- При переключении на LEGACY-симуляцию `LabRegistry._active` не очищается → лишний destroyActive() на неактивной. Безвредно сейчас; очистить `_active` на legacy-open в Фазе 1.
|
||||||
|
|
||||||
## Cross-Phase Dependencies
|
## Cross-Phase Dependencies
|
||||||
- Фаза 1 опирается на ядро реестра из Фазы 0.
|
- Фаза 1 опирается на ядро реестра из Фазы 0.
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ if-цепочками. Далее — ленивая загрузка кода,
|
|||||||
|
|
||||||
## Phases
|
## Phases
|
||||||
|
|
||||||
- [ ] Phase 0: Ядро реестра + адаптер + 3 пилота [domain: frontend] → [subplan](./phase-0-registry-core.md)
|
- [x] Phase 0: Ядро реестра + адаптер + 3 пилота [domain: frontend] → [subplan](./phase-0-registry-core.md)
|
||||||
- [ ] Phase 1: Миграция всех симуляций на манифесты [domain: frontend] → [subplan](./phase-1-migrate-all.md)
|
- [ ] Phase 1: Миграция всех симуляций на манифесты [domain: frontend] → [subplan](./phase-1-migrate-all.md)
|
||||||
- [ ] Phase 2: Тела симуляций как шаблоны + ленивый mount [domain: frontend] → [subplan](./phase-2-lazy-mount.md)
|
- [ ] Phase 2: Тела симуляций как шаблоны + ленивый mount [domain: frontend] → [subplan](./phase-2-lazy-mount.md)
|
||||||
- [ ] Phase 3: Ленивая загрузка кода симуляций [domain: frontend] → [subplan](./phase-3-lazy-load.md)
|
- [ ] Phase 3: Ленивая загрузка кода симуляций [domain: frontend] → [subplan](./phase-3-lazy-load.md)
|
||||||
@@ -34,7 +34,7 @@ if-цепочками. Далее — ленивая загрузка кода,
|
|||||||
|
|
||||||
| Phase | Domain | Status | Review | Build | Committed |
|
| Phase | Domain | Status | Review | Build | Committed |
|
||||||
|-------|--------|--------|--------|-------|-----------|
|
|-------|--------|--------|--------|-------|-----------|
|
||||||
| Phase 0: Ядро реестра | frontend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
| Phase 0: Ядро реестра | frontend | ✅ Done | ✅ PASS | ✅ n/a | ✅ |
|
||||||
| Phase 1: Миграция всех | frontend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
| Phase 1: Миграция всех | frontend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
||||||
| Phase 2: Ленивый mount | frontend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
| Phase 2: Ленивый mount | frontend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
||||||
| Phase 3: Ленивая загрузка | frontend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
| Phase 3: Ленивая загрузка | frontend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Phase 0: Ядро реестра + адаптер + 3 пилота
|
# Phase 0: Ядро реестра + адаптер + 3 пилота
|
||||||
|
|
||||||
**Status:** ⬜ Not Started
|
**Status:** ✅ Done
|
||||||
**Parent plan:** [PLAN.md](./PLAN.md)
|
**Parent plan:** [PLAN.md](./PLAN.md)
|
||||||
**Domain:** frontend
|
**Domain:** frontend
|
||||||
|
|
||||||
@@ -43,4 +43,9 @@
|
|||||||
- [ ] Нет дублирования карточек
|
- [ ] Нет дублирования карточек
|
||||||
|
|
||||||
## Handoff to Next Phase
|
## Handoff to Next Phase
|
||||||
<!-- заполнить после фазы -->
|
- Ядро `LabRegistry` готово (`frontend/js/labs/_registry.js`): register/get/has/all + setActive/stopActive/destroyActive + resolvePreview. Подключено первым.
|
||||||
|
- Адаптер активен в renderSims (lab-glue.js) и openSim/loadTheory/_pauseAllSims/closeSim (lab-init.js): реестр в приоритете, иначе legacy.
|
||||||
|
- Пилоты graph/quadratic/pendulum зарегистрированы в КОНЦЕ lab-init.js (после _openXxx). preview — ленивая функция (P_* из lab-glue, грузится позже). theory ссылается на объекты THEORY (единый источник).
|
||||||
|
- Пилоты НЕ удалены из SIMS/THEORY (сохранены для порядка и единого источника); merge перекрывает их по id. В Фазе 1 удалить legacy полностью.
|
||||||
|
- РЕВЬЮ-WARNING для Фазы 1: при переключении на LEGACY-симуляцию `_active` в реестре не очищается → следующий closeSim вызовет destroyActive() на уже неактивной. Для пилотов безвредно (idempotent stop). Очистить `_active` на legacy-open при миграции.
|
||||||
|
- Паттерн манифеста для Фазы 1: `{id,cat,title,desc,preview(fn|str),theory,open,stop,destroy}`. Регистрировать в самом sim-файле; следить за порядком загрузки (preview как fn спасает).
|
||||||
|
|||||||
Reference in New Issue
Block a user