iobroker.mywebui 1.37.86 → 1.37.88

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "mywebui",
4
- "version": "1.37.86",
4
+ "version": "1.37.88",
5
5
  "titleLang": {
6
6
  "en": "mywebui",
7
7
  "de": "mywebui",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.mywebui",
3
- "version": "1.37.86",
3
+ "version": "1.37.88",
4
4
  "description": "ioBroker mywebui - Custom edited mywebui by gokturk413",
5
5
  "type": "module",
6
6
  "main": "dist/backend/main.js",
@@ -674,25 +674,54 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
674
674
  const shadowRoot = rootEl?.shadowRoot;
675
675
  if (!rootEl || !shadowRoot) return;
676
676
  try {
677
- // Facade mimics the ScreenViewer instance API that control scripts expect.
678
- // Scripts call _getDomElement(), _assignEvent(), addEventListener(), etc.
679
- const facade = {
677
+ // Proxy wraps rootEl so ALL native HTMLElement methods (querySelector, closest, etc.) work.
678
+ // Custom WebUI API and attachInternals stub are injected via overrides.
679
+ // attachInternals() is intercepted because the designer rootEl is a plain HTMLDivElement
680
+ // (not a custom element), so the native call would throw NotSupportedError.
681
+ let _internalsStub = null;
682
+ const overrides = {
680
683
  shadowRoot,
681
684
  _getDomElement(id) {
682
685
  return shadowRoot.getElementById(id) ?? shadowRoot.querySelector(`[name="${id}"]`);
683
686
  },
684
687
  _assignEvent(id, evtName, handler) {
685
- const el = this._getDomElement(id);
688
+ const el = overrides._getDomElement(id);
686
689
  if (el) el.addEventListener(evtName, handler);
687
690
  },
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,
691
+ attachInternals() {
692
+ if (!_internalsStub) {
693
+ _internalsStub = {
694
+ setFormValue() {},
695
+ setValidity() {},
696
+ checkValidity() { return true; },
697
+ reportValidity() { return true; },
698
+ form: null,
699
+ validity: { valid: true, valueMissing: false, typeMismatch: false, patternMismatch: false, tooLong: false, tooShort: false, rangeUnderflow: false, rangeOverflow: false, stepMismatch: false, badInput: false, customError: false },
700
+ validationMessage: '',
701
+ willValidate: false,
702
+ labels: [],
703
+ states: { add() {}, delete() {}, has() { return false; }, clear() {}, forEach() {} },
704
+ role: null,
705
+ };
706
+ }
707
+ return _internalsStub;
708
+ },
695
709
  };
710
+ const facade = new Proxy(rootEl, {
711
+ get(target, prop, receiver) {
712
+ if (prop in overrides) {
713
+ const v = overrides[prop];
714
+ return typeof v === 'function' ? v.bind(overrides) : v;
715
+ }
716
+ const v = target[prop];
717
+ return typeof v === 'function' ? v.bind(target) : v;
718
+ },
719
+ set(target, prop, value) {
720
+ if (prop in overrides) { overrides[prop] = value; return true; }
721
+ target[prop] = value;
722
+ return true;
723
+ },
724
+ });
696
725
  this._designerFacade = facade;
697
726
  // Use scriptSystem.assignAllScripts — handles @event attrs, init(), applyBindings, etc.
698
727
  let scriptObj = await window.appShell.scriptSystem.assignAllScripts(