iobroker.mywebui 1.37.85 → 1.37.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/io-package.json
CHANGED
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
22
22
|
_styleBindings;
|
|
23
23
|
_settingsChanged;
|
|
24
24
|
_designerScriptObject = null;
|
|
25
|
+
_designerFacade = null;
|
|
25
26
|
async initialize(name, type, html, style, script, settings, properties, serviceContainer) {
|
|
26
27
|
if (name[0] == '/')
|
|
27
28
|
name = name.substring(1);
|
|
@@ -650,11 +651,11 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
650
651
|
dispose() {
|
|
651
652
|
if (this._designerScriptObject?.disconnectedCallback) {
|
|
652
653
|
try {
|
|
653
|
-
|
|
654
|
-
this._designerScriptObject.disconnectedCallback(rootEl, rootEl?.shadowRoot);
|
|
654
|
+
this._designerScriptObject.disconnectedCallback(this._designerFacade, this._designerFacade?.shadowRoot);
|
|
655
655
|
} catch (err) {}
|
|
656
656
|
}
|
|
657
657
|
this._designerScriptObject = null;
|
|
658
|
+
this._designerFacade = null;
|
|
658
659
|
this.removeBindings();
|
|
659
660
|
this.documentContainer.dispose();
|
|
660
661
|
this._configChangedListener?.dispose();
|
|
@@ -673,15 +674,39 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
673
674
|
const shadowRoot = rootEl?.shadowRoot;
|
|
674
675
|
if (!rootEl || !shadowRoot) return;
|
|
675
676
|
try {
|
|
676
|
-
|
|
677
|
-
|
|
677
|
+
// Facade mimics the ScreenViewer instance API that control scripts expect.
|
|
678
|
+
// Scripts call _getDomElement(), _assignEvent(), addEventListener(), etc.
|
|
679
|
+
const facade = {
|
|
680
|
+
shadowRoot,
|
|
681
|
+
_getDomElement(id) {
|
|
682
|
+
return shadowRoot.getElementById(id) ?? shadowRoot.querySelector(`[name="${id}"]`);
|
|
683
|
+
},
|
|
684
|
+
_assignEvent(id, evtName, handler) {
|
|
685
|
+
const el = this._getDomElement(id);
|
|
686
|
+
if (el) el.addEventListener(evtName, handler);
|
|
687
|
+
},
|
|
688
|
+
addEventListener: (type, handler, opts) => rootEl.addEventListener(type, handler, opts),
|
|
689
|
+
removeEventListener: (type, handler, opts) => rootEl.removeEventListener(type, handler, opts),
|
|
690
|
+
dispatchEvent: (evt) => rootEl.dispatchEvent(evt),
|
|
691
|
+
getAttribute: (name) => rootEl.getAttribute(name),
|
|
692
|
+
setAttribute: (name, val) => rootEl.setAttribute(name, val),
|
|
693
|
+
style: rootEl.style,
|
|
694
|
+
dataset: rootEl.dataset,
|
|
695
|
+
};
|
|
696
|
+
this._designerFacade = facade;
|
|
697
|
+
// Use scriptSystem.assignAllScripts — handles @event attrs, init(), applyBindings, etc.
|
|
698
|
+
let scriptObj = await window.appShell.scriptSystem.assignAllScripts(
|
|
699
|
+
'designer-control - ' + this._name,
|
|
700
|
+
scriptCode,
|
|
701
|
+
shadowRoot,
|
|
702
|
+
facade,
|
|
703
|
+
iobrokerHandler
|
|
704
|
+
);
|
|
678
705
|
if (scriptObj?.default && !scriptObj?.connectedCallback)
|
|
679
706
|
scriptObj = scriptObj.default;
|
|
680
707
|
this._designerScriptObject = scriptObj;
|
|
681
|
-
if (scriptObj?.init)
|
|
682
|
-
scriptObj.init(rootEl, shadowRoot);
|
|
683
708
|
if (scriptObj?.connectedCallback)
|
|
684
|
-
scriptObj.connectedCallback(
|
|
709
|
+
scriptObj.connectedCallback(facade, shadowRoot);
|
|
685
710
|
} catch (err) {
|
|
686
711
|
console.warn('Designer script execution failed:', err);
|
|
687
712
|
}
|