full suport for models and hotloading Plugins
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user