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:
Maxim Dolgolyov
2026-05-30 13:04:39 +03:00
parent dfce94fbf7
commit 0888a707cc
6 changed files with 63 additions and 6 deletions
+45
View File
@@ -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(); }
});
})();
+3 -1
View File
@@ -949,7 +949,9 @@
}
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');
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>`;