iobroker.mywebui 1.37.82 → 1.37.83

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.82",
4
+ "version": "1.37.83",
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.82",
3
+ "version": "1.37.83",
4
4
  "description": "ioBroker mywebui - Custom edited mywebui by gokturk413",
5
5
  "type": "module",
6
6
  "main": "dist/backend/main.js",
@@ -21,6 +21,7 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
21
21
  _webuiBindings;
22
22
  _styleBindings;
23
23
  _settingsChanged;
24
+ _designerScriptObject = null;
24
25
  async initialize(name, type, html, style, script, settings, properties, serviceContainer) {
25
26
  if (name[0] == '/')
26
27
  name = name.substring(1);
@@ -114,6 +115,8 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
114
115
  // Layout not ready yet — keep zoomFactor=1 so canvas stays visible
115
116
  this.documentContainer.designerView.designerCanvas.zoomFactor = 1;
116
117
  }
118
+ // Run the control's script so JS-generated content is visible in the designer
119
+ this._applyDesignerScript();
117
120
  });
118
121
  });
119
122
 
@@ -642,6 +645,13 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
642
645
  this.documentContainer.designerView.designerHeight = this._settings.height ?? defH;
643
646
  }
644
647
  dispose() {
648
+ if (this._designerScriptObject?.disconnectedCallback) {
649
+ try {
650
+ const rootEl = this.documentContainer.designerView.designerCanvas.rootDesignItem?.element;
651
+ this._designerScriptObject.disconnectedCallback(rootEl, rootEl?.shadowRoot);
652
+ } catch (err) {}
653
+ }
654
+ this._designerScriptObject = null;
645
655
  this.removeBindings();
646
656
  this.documentContainer.dispose();
647
657
  this._configChangedListener?.dispose();
@@ -651,5 +661,25 @@ export class IobrokerWebuiScreenEditor extends BaseCustomWebComponentConstructor
651
661
  window.appShell.styleEditor.model = null;
652
662
  window.appShell.javascriptEditor.model = null;
653
663
  }
664
+ async _applyDesignerScript() {
665
+ if (this._type !== 'control') return;
666
+ const scriptCode = this.scriptModel.getValue();
667
+ if (!scriptCode?.trim()) return;
668
+ const canvas = this.documentContainer.designerView.designerCanvas;
669
+ const rootEl = canvas.rootDesignItem?.element;
670
+ const shadowRoot = rootEl?.shadowRoot;
671
+ if (!rootEl || !shadowRoot) return;
672
+ try {
673
+ const url = URL.createObjectURL(new Blob([scriptCode], { type: 'application/javascript' }));
674
+ let scriptObj = await import(url);
675
+ if (scriptObj?.default && !scriptObj?.connectedCallback)
676
+ scriptObj = scriptObj.default;
677
+ this._designerScriptObject = scriptObj;
678
+ if (scriptObj?.connectedCallback)
679
+ scriptObj.connectedCallback(rootEl, shadowRoot);
680
+ } catch (err) {
681
+ console.warn('Designer script execution failed:', err);
682
+ }
683
+ }
654
684
  }
655
685
  customElements.define("iobroker-webui-screen-editor", IobrokerWebuiScreenEditor);
@@ -318,27 +318,13 @@ let ScreenViewer = class ScreenViewer extends BaseCustomWebComponentConstructorA
318
318
  else
319
319
  this._iobBindings = res;
320
320
  this._scriptObject = await window.appShell.scriptSystem.assignAllScripts('screenviewer - ' + this.screenName, script, this._rootShadow, this, iobrokerHandler);
321
-
322
- console.log('📜 [ScreenViewer] Script object for "' + this.screenName + '":', this._scriptObject);
323
- console.log('📜 [ScreenViewer] Object type:', Object.prototype.toString.call(this._scriptObject));
324
- console.log('📜 [ScreenViewer] Has default?', this._scriptObject?.default);
325
- console.log('📜 [ScreenViewer] Has connectedCallback?', typeof this._scriptObject?.connectedCallback);
326
- console.log('📜 [ScreenViewer] Has default.connectedCallback?', typeof this._scriptObject?.default?.connectedCallback);
327
-
328
- // If module with default export, use it
329
- if (this._scriptObject?.default && !this._scriptObject?.connectedCallback) {
330
- console.log('🔄 [ScreenViewer] Using default export for "' + this.screenName + '"');
321
+ if (this._scriptObject?.default && !this._scriptObject?.connectedCallback)
331
322
  this._scriptObject = this._scriptObject.default;
332
- }
333
-
334
- // Call connectedCallback after script is loaded
335
323
  if (this._scriptObject?.connectedCallback) {
336
- console.log('✅ [ScreenViewer] Calling connectedCallback after script load for "' + this.screenName + '"');
337
324
  try {
338
325
  this._scriptObject.connectedCallback(this, this._rootShadow);
339
- console.log('✅ [ScreenViewer] connectedCallback executed successfully for "' + this.screenName + '"');
340
326
  } catch (err) {
341
- console.error(' [ScreenViewer] Error in connectedCallback for "' + this.screenName + '":', err);
327
+ console.error('connectedCallback error for "' + this.screenName + '":', err);
342
328
  }
343
329
  }
344
330