@beyond-js/kernel
Advanced tools
Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "@beyond-js/kernel", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"keywords": [], | ||
@@ -5,0 +5,0 @@ "uimport": true, |
@@ -24,3 +24,3 @@ define(["exports", "@beyond-js/kernel/core/ts", "@beyond-js/kernel/routing/ts"], function (_exports2, dependency_0, dependency_1) { | ||
modules.set('./controller', { | ||
hash: 3004323736, | ||
hash: 3478298819, | ||
creator: function (require, exports) { | ||
@@ -39,29 +39,8 @@ "use strict"; | ||
class SvelteWidgetController extends _ts.BeyondWidgetController { | ||
#styles; | ||
#hmrStylesChanged = styles => { | ||
const { | ||
shadowRoot | ||
} = this.component; | ||
const previous = shadowRoot.querySelectorAll(`:scope > [bundle="${styles.id}"]`)[0]; | ||
previous && shadowRoot.removeChild(previous); | ||
styles.css && shadowRoot.appendChild(styles.css); | ||
}; | ||
#body; | ||
render() { | ||
this.#body?.remove(); | ||
this.#body = document.createElement('span'); | ||
this.component.shadowRoot.appendChild(this.#body); | ||
const { | ||
Widget | ||
} = this.bundle.package().exports.values; | ||
if (!Widget) { | ||
const message = `Widget "${this.element}" does not export a Widget class`; | ||
console.error(message); | ||
return; | ||
} | ||
new Widget({ | ||
target: this.#body | ||
_mount(props) { | ||
const hydrate = this.hydratable; | ||
new this.Widget({ | ||
target: this.body, | ||
hydrate, | ||
props | ||
}); | ||
@@ -71,25 +50,10 @@ } | ||
mount() { | ||
this.render(); | ||
this.bundle.dependencies.forEach(resource => { | ||
if (!_ts.beyond.bundles.has(resource)) return; | ||
this._mount({ | ||
component: this.component, | ||
store: this.store | ||
}); | ||
} | ||
const dependency = _ts.beyond.bundles.get(resource); | ||
unmount() {} | ||
const { | ||
styles | ||
} = dependency; | ||
if (styles.appended || !styles.css) return; | ||
const css = styles.css; | ||
this.component.shadowRoot.appendChild(css); | ||
styles.on('change', this.#hmrStylesChanged); | ||
}); // Append styles and setup styles HMR | ||
this.#styles = this.bundle.styles; | ||
const { | ||
css | ||
} = this.#styles; | ||
css && this.component.shadowRoot.appendChild(css); | ||
this.#styles.on('change', this.#hmrStylesChanged); | ||
} | ||
} | ||
@@ -96,0 +60,0 @@ |
29
15019
523404