From 0888a707ccea83f5f45d32da29b2067bff8cf780 Mon Sep 17 00:00:00 2001 From: Maxim Dolgolyov Date: Sat, 30 May 2026 13:04:39 +0300 Subject: [PATCH] =?UTF-8?q?fix(lab-content-engine):=20phase=200=20-=20?= =?UTF-8?q?=D1=83=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D1=8B=203=20?= =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BA=D0=B5=D1=80=D0=B0=20=D1=80=D0=B5=D0=B2?= =?UTF-8?q?=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - подключён _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) --- frontend/js/labs/_pilots.js | 45 +++++++++++++++++++ frontend/js/labs/lab-glue.js | 4 +- frontend/lab.html | 2 + plans/lab-content-engine/CONTEXT.md | 5 ++- plans/lab-content-engine/PLAN.md | 4 +- .../phase-0-registry-core.md | 9 +++- 6 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 frontend/js/labs/_pilots.js diff --git a/frontend/js/labs/_pilots.js b/frontend/js/labs/_pilots.js new file mode 100644 index 0000000..e897b8e --- /dev/null +++ b/frontend/js/labs/_pilots.js @@ -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(); } + }); +})(); diff --git a/frontend/js/labs/lab-glue.js b/frontend/js/labs/lab-glue.js index b46b90f..ef572a9 100644 --- a/frontend/js/labs/lab-glue.js +++ b/frontend/js/labs/lab-glue.js @@ -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 = '
Теория для этой симуляции пока не добавлена
'; return; } let html = `
${LS.icon('book-open',16)} ${t.title}
`; diff --git a/frontend/lab.html b/frontend/lab.html index 400a371..a047cda 100644 --- a/frontend/lab.html +++ b/frontend/lab.html @@ -4801,6 +4801,7 @@ + @@ -4863,6 +4864,7 @@ +