iobroker.mywebui 1.37.85 → 1.37.87
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,48 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
|
|
|
673
674
|
const shadowRoot = rootEl?.shadowRoot;
|
|
674
675
|
if (!rootEl || !shadowRoot) return;
|
|
675
676
|
try {
|
|
676
|
-
|
|
677
|
-
|
|
677
|
+
// Proxy wraps rootEl so ALL native HTMLElement methods (attachInternals, querySelector,
|
|
678
|
+
// closest, matches, getBoundingClientRect, etc.) work automatically.
|
|
679
|
+
// Custom WebUI API (_getDomElement, _assignEvent, shadowRoot) is injected via the handler.
|
|
680
|
+
const overrides = {
|
|
681
|
+
shadowRoot,
|
|
682
|
+
_getDomElement(id) {
|
|
683
|
+
return shadowRoot.getElementById(id) ?? shadowRoot.querySelector(`[name="${id}"]`);
|
|
684
|
+
},
|
|
685
|
+
_assignEvent(id, evtName, handler) {
|
|
686
|
+
const el = overrides._getDomElement(id);
|
|
687
|
+
if (el) el.addEventListener(evtName, handler);
|
|
688
|
+
},
|
|
689
|
+
};
|
|
690
|
+
const facade = new Proxy(rootEl, {
|
|
691
|
+
get(target, prop, receiver) {
|
|
692
|
+
if (prop in overrides) {
|
|
693
|
+
const v = overrides[prop];
|
|
694
|
+
return typeof v === 'function' ? v.bind(overrides) : v;
|
|
695
|
+
}
|
|
696
|
+
const v = target[prop];
|
|
697
|
+
return typeof v === 'function' ? v.bind(target) : v;
|
|
698
|
+
},
|
|
699
|
+
set(target, prop, value) {
|
|
700
|
+
if (prop in overrides) { overrides[prop] = value; return true; }
|
|
701
|
+
target[prop] = value;
|
|
702
|
+
return true;
|
|
703
|
+
},
|
|
704
|
+
});
|
|
705
|
+
this._designerFacade = facade;
|
|
706
|
+
// Use scriptSystem.assignAllScripts — handles @event attrs, init(), applyBindings, etc.
|
|
707
|
+
let scriptObj = await window.appShell.scriptSystem.assignAllScripts(
|
|
708
|
+
'designer-control - ' + this._name,
|
|
709
|
+
scriptCode,
|
|
710
|
+
shadowRoot,
|
|
711
|
+
facade,
|
|
712
|
+
iobrokerHandler
|
|
713
|
+
);
|
|
678
714
|
if (scriptObj?.default && !scriptObj?.connectedCallback)
|
|
679
715
|
scriptObj = scriptObj.default;
|
|
680
716
|
this._designerScriptObject = scriptObj;
|
|
681
|
-
if (scriptObj?.init)
|
|
682
|
-
scriptObj.init(rootEl, shadowRoot);
|
|
683
717
|
if (scriptObj?.connectedCallback)
|
|
684
|
-
scriptObj.connectedCallback(
|
|
718
|
+
scriptObj.connectedCallback(facade, shadowRoot);
|
|
685
719
|
} catch (err) {
|
|
686
720
|
console.warn('Designer script execution failed:', err);
|
|
687
721
|
}
|