full suport for models and hotloading Plugins

This commit is contained in:
2026-08-04 22:28:39 -05:00
parent be8c1a9ea8
commit 552f570efb
9 changed files with 236 additions and 7 deletions
@@ -103,9 +103,27 @@
}
}
await new Promise((r) => setTimeout(r, 400));
await hotloadPackPlugins(msg.plugins);
notify('model-open', { name: name });
}
// Hotload plugins bundled with the pack (served via pack_asset). A failing
// plugin is reported but never blocks the model preview.
async function hotloadPackPlugins(plugins) {
for (const p of (plugins || [])) {
if (!p || !p.url || !p.member) continue;
try {
const code = await (await fetch(p.url, { headers: { 'Accept': 'text/javascript' } })).text();
if (!code || code.length < 20) continue;
await new Plugin().loadFromFile({ path: p.member, content: code }, true);
notify('plugin-hotloaded', { name: p.member });
} catch (e) {
console.error('packs pack plugin hotload failed', p.member, e);
notify('plugin-error', { error: 'Failed to load plugin ' + p.member });
}
}
}
window.addEventListener('message', (e) => {
if (!e.data || e.data.type !== 'packs-open-model') return;
openModel(e.data).then(