aboutsummaryrefslogtreecommitdiff
path: root/src/zeroscript/component.template.js
blob: e8cb914ad7f2710b91e60ed58604a10ccbb866c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
customElements.define("{s}-{s}", class extends HTMLElement {{
	constructor() {{
		super();
		this.attachShadow({{ mode: 'open' }});
		const template = document.getElementById("@{s}");
		const node = document.importNode(template.content, true);
		this.shadowRoot.appendChild(node);
		this[ZsPtr] = null;
	}}
	connectedCallback() {{
		wasm_ready.then(() => {{
			const id = ObjectStore.generateFreeId();
			ObjectStore.registerObject(id, this);
			this[ZsPtr] = wasm.exports['export::{s}::init'](id);
		}});
	}}
	disconnectedCallback() {{
		wasm.exports['export::{s}::deinit'](this[ZsId]);
		ObjectStore.free(this);
	}}
}})