add runtime script and mount

feat/devtool
dominikg 4 months ago
parent a5b70142ae
commit a294bbc53e

@ -1,2 +1,3 @@
export {default as DevTool} from './DevTool.svelte'
export * from './configure.js'
export {mountUI as default} from './runtime.js'

@ -0,0 +1,21 @@
import DevTool from './DevTool.svelte';
import { mount } from 'svelte';
function create_devtool_host() {
const id = 'svelte-devtool-host';
if (document.getElementById(id) != null) {
console.debug('svelte-devtool-host already exists, skipping');
return;
}
const el = document.createElement('div');
el.setAttribute('id', id);
// appending to documentElement adds it outside of body
document.documentElement.appendChild(el);
return el;
}
export function mountUI(){
if(typeof window !== 'undefined') {
mount(DevTool, { target: create_devtool_host() });
}
}
Loading…
Cancel
Save