fix(lab-content-engine): phase 3 - устранён блокер ревью (loader не был подключён)
Два edit'а Фазы 3 не применились в fc1139f (упали по отступу), запушив
сломанное состояние: lab.html убрал eager sim-скрипты, но open остался
синхронным -> ReferenceError при клике на любую симуляцию кроме graph.
ИСПРАВЛЕНО:
- _register-all.js: open-обёртка LabLoader.ensure(id).then(rawOpen) + sync-фолбэк
- lab-init.js openSim: обработка Promise от open() (.then -> lucide, .catch -> log)
E2E vm-harness: click->ensure->load->rawOpen после загрузки; pendulum/stereo:cube/
molphys(4 файла)/alias magnetic — ALL PASS; node --check OK.
Независимое ревью поймало этот блокер.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -82,7 +82,17 @@
|
|||||||
desc: s.desc,
|
desc: s.desc,
|
||||||
preview: s.preview, // уже готовая SVG-строка (P_* вычислены в SIMS)
|
preview: s.preview, // уже готовая SVG-строка (P_* вычислены в SIMS)
|
||||||
theory: T[s.id] || null,
|
theory: T[s.id] || null,
|
||||||
open: open
|
// Фаза 3: ленивая загрузка кода. LabLoader.ensure(id) подгружает файлы
|
||||||
|
// симуляции (+ three.js при необходимости), затем выполняется raw-open.
|
||||||
|
// Если LabLoader недоступен — открываем синхронно как раньше (фолбэк).
|
||||||
|
open: (function (rawOpen, simId) {
|
||||||
|
return function (c) {
|
||||||
|
if (window.LabLoader && window.LabLoader.ensure) {
|
||||||
|
return window.LabLoader.ensure(simId).then(function () { rawOpen(c); });
|
||||||
|
}
|
||||||
|
rawOpen(c);
|
||||||
|
};
|
||||||
|
})(open, s.id)
|
||||||
// stop/destroy: глобальный «дробовик» _pauseAllSims()/closeSim() — паритет
|
// stop/destroy: глобальный «дробовик» _pauseAllSims()/closeSim() — паритет
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -116,9 +116,18 @@
|
|||||||
const _m = window.LabRegistry.get(_cid);
|
const _m = window.LabRegistry.get(_cid);
|
||||||
const _arg = _cid.includes(':') ? _cid.split(':')[1] : undefined;
|
const _arg = _cid.includes(':') ? _cid.split(':')[1] : undefined;
|
||||||
window.LabRegistry.setActive(_m);
|
window.LabRegistry.setActive(_m);
|
||||||
try { _m.open({ id: _cid, arg: _arg }); }
|
// Фаза 3: open() может вернуть Promise (ленивая загрузка кода). Иконки
|
||||||
catch (e) { console.error('[LabRegistry] open failed:', _cid, e); }
|
// перерисовываем после фактической инициализации тела симуляции; ошибку
|
||||||
if (window.lucide) lucide.createIcons();
|
// асинхронной загрузки ловим через .catch (sync try/catch её не поймает).
|
||||||
|
try {
|
||||||
|
const _r = _m.open({ id: _cid, arg: _arg });
|
||||||
|
if (_r && typeof _r.then === 'function') {
|
||||||
|
_r.then(function () { if (window.lucide) lucide.createIcons(); })
|
||||||
|
.catch(function (e) { console.error('[LabRegistry] open failed:', _cid, e); });
|
||||||
|
} else if (window.lucide) {
|
||||||
|
lucide.createIcons();
|
||||||
|
}
|
||||||
|
} catch (e) { console.error('[LabRegistry] open failed:', _cid, e); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.console) console.warn('[LabRegistry] неизвестная симуляция:', id);
|
if (window.console) console.warn('[LabRegistry] неизвестная симуляция:', id);
|
||||||
|
|||||||
Reference in New Issue
Block a user