iobroker.vis-snapmaker-u1 0.0.0-stage → 0.0.8

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Negalein <negalein@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README-de.md ADDED
@@ -0,0 +1,51 @@
1
+ # Snapmaker-U1-Widgets für VIS 1
2
+
3
+ [English](README.md)
4
+
5
+ Beta 0.0.8 für VIS 1. Druckerübersicht, Kameras und Spoolman sind enthalten; Kamerastreams und Einstellungen bitte auf dem eigenen Testsystem prüfen.
6
+
7
+ [Snapmaker U1 – Herstellerinformationen](https://www.snapmaker.com/en/snapmaker-u1)
8
+
9
+ ## Voraussetzungen
10
+
11
+ VIS 1.6.1, js-controller 7.2.5 und Snapmaker-U1-Adapter 0.0.14; Spoolman muss im Hauptadapter eingerichtet sein. Das Widget liest nur native Zustände und schreibt keine Daten. Ein Browser mit ES-Modulen und Web Components ist erforderlich; die VIS-1-Cordova-App wird vom Host nicht unterstützt.
12
+
13
+ ## Testinstallation
14
+
15
+ Sobald der Adapter im ioBroker-Latest-Repository verfügbar ist, kann er über den ioBroker Admin installiert werden. Eine Instanz dieses Widget-Adapters anlegen, falls sie nicht automatisch angelegt wird; VIS und VIS 2 neu starten. Im VIS-1-Editor das Widget im Set „snapmaker-u1“ hinzufügen und die Snapmaker-U1-Instanz wählen. Auf einer Testansicht zunächst mit mehreren Widget-Instanzen, Ansichtswechsel und Neustart prüfen. Nach dem Update muss die Browserseite gegebenenfalls neu geladen oder der Cache geleert werden.
16
+
17
+ Das Instanzfeld schlägt gefundene Snapmaker-U1-Instanzen vor und erlaubt alternativ die manuelle Eingabe, zum Beispiel `snapmaker-u1.0`. Nach dem Herstellen der Verbindung das Widget erneut auswählen, um die Vorschläge zu aktualisieren.
18
+
19
+ Beim Aktualisieren eines bereits vorhandenen VIS-1-Widget-Sets zuerst die VIS-1-Instanz neu starten und warten, bis sie läuft. Anschließend auf dem ioBroker-Host `iobroker upload vis widgets` ausführen und den Editor im Browser vollständig neu laden. VIS 1.6.1 kopiert installierte Widget-Dateien beim Start, lädt geänderte Widget-Dateien aber möglicherweise nicht hoch, wenn sich die Widget-Set-Konfiguration nicht geändert hat. Der Befehl lädt die synchronisierten VIS-Widget-Dateien hoch; er installiert nicht die neue Adapterversion, deshalb den Adapter vorher aktualisieren.
20
+
21
+ Für vorhandene VIS-1-Views mit dem früheren Web-Component-Widget gibt es eine Kompatibilitätsvorlage, die die Einstellungen erhalten soll; dieser Weg muss auf dem echten Server geprüft werden. Vor dem Update die VIS-Projekte exportieren. Falls in einer VIS-2-View das Web-Component-Widget des VIS-1-Adapters verwendet wurde, muss es durch das Widget des VIS-2-Adapters ersetzt werden; die gespeicherten Widget-Typen sind unterschiedlich. Die Web-Komponente des VIS-2-Adapters kann in VIS 1 weiterhin unter „Web components“ erscheinen.
22
+
23
+ Das Widget zeigt bei nicht verfügbarer Verbindung einen Hinweis auf möglicherweise veraltete Werte. Bei fehlender Nennkapazität wird kein Füllstand erfunden. Schwellen: unter 300 g gelb, unter 100 g rot. Die optionale Rotation zeigt Druckstatus und gewählte AFC-Lane an, sie misst keinen tatsächlichen Filamentvorschub. Die Lane-Zuordnung ist am echten Drucker noch zu bestätigen. Radius und 3D-Ansicht sind Näherungen mit einheitlicher Spulengeometrie.
24
+
25
+ Filamentfarben werden als sechsstelliger RGB- oder achtstelliger RGBA-Hexcode mit oder ohne `#` akzeptiert. Das Widget zeigt den RGB-Anteil deckend und passend zur AFC-Farbe; die Transparenz des Filaments wird nicht dargestellt.
26
+
27
+ ## Druckerübersicht und Kameras
28
+
29
+ Die Übersicht zeigt Druckauftrag, Fortschritt (der Adapter liefert bereits Prozentwerte), Layer, Z-Position, vier Extrudertemperaturen, Bett- und Kammertemperatur, geschätzte Restzeit und Verbindungsstatus. Optional kann der Datenpunkt eines Akkus über die Datenpunktauswahl gewählt werden. Fehlende Schätzungen werden als unbekannt angezeigt. Das Widget ist schreibgeschützt.
30
+
31
+ Das Medien-Widget zeigt die native Druckvorschau und bis zu zwei Kamerastreams. Snapmaker-Instanz wählen und den Stream-Datenpunkt jeder Kamera über die Datenpunktauswahl auswählen, beispielsweise `snapmaker-u1.0.cameras.<kamera-id>.streamUrl`. Für jede Kamera **WebRTC / HTML** oder **MJPEG** auswählen. Nicht benötigte Kamerafelder leer lassen. Vollbild hängt vom Browser ab. Kamera- und Vorschauladressen müssen vom Anzeigegerät erreichbar sein; HTTPS-Mixed-Content oder iframe-Regeln des Streamservers können die Anzeige verhindern. Die Kompatibilität der Kameradienste und echte Streams müssen getestet werden. Die automatische Auflösungsumschaltung ist noch nicht implementiert.
32
+
33
+ Kamera-Stream-Datenpunkte können aus beliebigen Adaptern stammen; der gewählte Datenpunkt muss eine HTTP(S)-URL enthalten.
34
+
35
+ ## Darstellung
36
+
37
+ Jedes Widget besitzt eigene Einstellungen: automatisches, helles oder dunkles Grunddesign; Farben für Panel, Karten, Text, Nebentext, Warnung und Alarm; Schriftauswahl oder eigene Schriftart, Schriftgröße, Schriftstärke, Kursiv und Unterstreichung. Leere Farbfelder verwenden das Grunddesign. Eine eigene Schriftart hat Vorrang vor der Auswahl; die Schrift muss auf dem Anzeigegerät installiert oder anderweitig verfügbar sein. Die Filamentfarben stammen weiterhin aus Spoolman. Bei eigenen Farben auf ausreichenden Kontrast achten. Die Editor-Einstellungen müssen noch in VIS 1.6.1 praktisch geprüft werden.
38
+
39
+ ## Entwicklung
40
+
41
+ `npm ci` und `npm test` im Repository. Das Paket ist eigenständig; die VIS-2-Version ist nicht erforderlich. Quellcode MIT, siehe LICENSE.
42
+
43
+ ## Änderungen
44
+
45
+ ### 0.0.8
46
+
47
+ - Erste öffentliche Beta mit Druckerübersicht, Kamera- und Spoolman-Widgets vorbereitet.
48
+
49
+ ## Lizenz
50
+
51
+ MIT; siehe [LICENSE](LICENSE).
package/README.md CHANGED
@@ -1,3 +1,51 @@
1
- # Temporary Holding Version
1
+ # Snapmaker U1 widgets for VIS 1
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Deutsch](README-de.md)
4
+
5
+ Beta 0.0.8 for VIS 1. Printer overview, cameras and Spoolman are included; verify camera streams and settings on your own test system.
6
+
7
+ [Snapmaker U1 product information](https://www.snapmaker.com/en/snapmaker-u1)
8
+
9
+ ## Requirements
10
+
11
+ VIS 1.6.1, js-controller 7.2.5 and Snapmaker U1 adapter 0.0.14; Spoolman must be configured in the main adapter. The widget reads native states and does not write data. A browser with ES modules and Web Components is required; the VIS 1 Cordova app is not supported by its host.
12
+
13
+ ## Test installation
14
+
15
+ When the adapter is available in the ioBroker latest repository, install it through ioBroker Admin. Create an instance of this widget adapter if one is not created automatically, then restart both VIS and VIS 2. In the VIS 1 editor, add the widget from the **snapmaker-u1** set and select the Snapmaker U1 instance. Start with a test view and check multiple widget instances, view changes and restarts. A browser refresh or cache clear may be needed after updating.
16
+
17
+ The instance field suggests discovered Snapmaker U1 instances and also accepts manual input, such as `snapmaker-u1.0`, if the list is unavailable. Re-select the widget after the connection is established to refresh its suggestions.
18
+
19
+ When updating an existing VIS 1 widget set, restart the VIS 1 instance and wait until it is running; then run `iobroker upload vis widgets` on the ioBroker host and hard-refresh the editor. VIS 1.6.1 copies installed widget files on startup but may not upload changed widget files when its widget-set configuration has not changed. This command uploads the synchronized VIS widget files; it does not install the new adapter version, so update the adapter first.
20
+
21
+ Existing VIS 1 views that use the former VIS 1 web-component widget have a compatibility template intended to preserve their settings; this path must be tested on the actual server. Export the VIS projects before updating. A VIS 2 view that used the VIS 1 adapter's web-component widget must be changed to use the VIS 2 adapter's widget; the two widgets have different saved types. The VIS 2 adapter's web component may still be listed under Web components in VIS 1.
22
+
23
+ The widget warns that displayed values may be stale when the connection is unavailable. If nominal capacity is missing, it does not invent a fill level. The warning thresholds are below 300 g (yellow) and below 100 g (red). Optional rotation indicates a print in progress and the selected AFC lane; it does not measure actual filament movement. Lane selection still needs confirmation on the printer. The radius and 3D view are approximations using uniform spool geometry.
24
+
25
+ Filament colors accept six-digit RGB and eight-digit RGBA hex codes, with or without `#`. The widget displays the RGB part opaquely to match the AFC color; it does not visualize filament transparency.
26
+
27
+ ## Printer overview and cameras
28
+
29
+ The overview shows the print job, progress (already supplied as percent), layers, Z position, four tool temperatures, bed and chamber temperatures, estimated remaining time and connectivity. Optionally select a battery state with the object picker. Missing estimates are shown as unknown. The widget is read-only.
30
+
31
+ The media widget shows the native print preview and up to two camera streams. Select the Snapmaker instance, then select each camera stream state with the object picker, for example `snapmaker-u1.0.cameras.<camera-id>.streamUrl`, and choose **WebRTC / HTML** or **MJPEG** for that camera. Leave a camera field blank if unused. Fullscreen depends on browser support. Cameras and preview URLs must be reachable by the display device; HTTPS mixed-content restrictions or stream server iframe policies may prevent display. Camera service compatibility and actual streams require testing. Automatic resolution switching is not implemented.
32
+
33
+ Camera stream states may come from any adapter; the selected state must contain an HTTP(S) URL.
34
+
35
+ ## Appearance
36
+
37
+ Each widget has its own appearance settings: automatic, light or dark base theme; panel, card, text, secondary text, warning and alarm colors; font selection or a custom font family, size, weight, italic and underline. Empty color fields use the base theme. A custom font family overrides the selection; the font must be installed or otherwise available on the display device. Filament colors continue to come from Spoolman. Check contrast when choosing custom colors. These editor settings still require testing in VIS 1.6.1.
38
+
39
+ ## Development
40
+
41
+ Run `npm ci` and `npm test` in this repository. This package is independent and does not require the VIS 2 version. The source code is MIT licensed; see [LICENSE](LICENSE).
42
+
43
+ ## Changelog
44
+
45
+ ### 0.0.8
46
+
47
+ - Prepare the first public beta with printer overview, camera and Spoolman widgets.
48
+
49
+ ## License
50
+
51
+ Copyright (c) 2026 Negalein <negalein@gmail.com>. MIT; see [LICENSE](LICENSE).
package/admin/icon.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><circle cx="32" cy="32" r="29" fill="#273847"/><circle cx="32" cy="32" r="22" fill="#42b7a3"/><circle cx="32" cy="32" r="13" fill="#273847"/><circle cx="32" cy="32" r="5" fill="#b9ccd4"/></svg>
@@ -0,0 +1,11 @@
1
+ import { SpoolElement } from './spool-element.js';
2
+ class Vis1SpoolElement extends SpoolElement {}
3
+ if (!customElements.get('snapmaker-u1-vis1-spools')) customElements.define('snapmaker-u1-vis1-spools', Vis1SpoolElement);
4
+
5
+ import { OverviewElement } from './overview-element.js';
6
+ class Vis1OverviewElement extends OverviewElement {}
7
+ if (!customElements.get('snapmaker-u1-vis1-overview')) customElements.define('snapmaker-u1-vis1-overview', Vis1OverviewElement);
8
+
9
+ import { MediaElement } from './media-element.js';
10
+ class Vis1MediaElement extends MediaElement {}
11
+ if (!customElements.get('snapmaker-u1-vis1-media')) customElements.define('snapmaker-u1-vis1-media', Vis1MediaElement);
@@ -0,0 +1,64 @@
1
+ import { SpoolElement } from './spool-element.js';
2
+
3
+ const messages={de:{title:'Druckvorschau & Kameras',thumbnail:'Druckvorschau',camera:'Kamera',missing:'Keine Quelle ausgewählt',noPreview:'Keine Druckvorschau',fullscreen:'Vollbild',failed:'Vollbild nicht verfügbar'},en:{title:'Print preview & cameras',thumbnail:'Print preview',camera:'Camera',missing:'No source selected',noPreview:'No print preview',fullscreen:'Fullscreen',failed:'Fullscreen unavailable'}};
4
+ const make=(tag,cls,text)=>{const n=document.createElement(tag);if(cls)n.className=cls;if(text!==undefined)n.textContent=text;return n;};
5
+ export function cameraState(_instance,id){
6
+ if(typeof id!=='string')return '';
7
+ const value=id.trim();
8
+ // The editor chooses any ioBroker state; never subscribe to a wildcard pattern.
9
+ return value && value !== 'nothing_selected' && value.length <= 512 && !/[\x00-\x1f*?]/.test(value) ? value : '';
10
+ }
11
+ export function mediaUrl(raw){
12
+ if(typeof raw!=='string' || !raw.trim())return '';
13
+ try {const u=new URL(raw.trim(),document.baseURI);return ['http:','https:'].includes(u.protocol) ? u.href : '';} catch {return '';}
14
+ }
15
+ /** State updates only change matching media sources; other feeds keep playing. */
16
+ export class MediaElement extends SpoolElement {
17
+ _sync(){
18
+ const instance=this._settings.instance;
19
+ if(!this.isConnected || !this._socket || !/^snapmaker-u1\.\d+$/.test(instance||'')){this.render();return;}
20
+ const a=cameraState(instance,this._settings.camera1State),b=cameraState(instance,this._settings.camera2State);
21
+ const ids=[`${instance}.printer.job.previewUrl`,...new Set([a,b].filter(Boolean))];
22
+ const key=JSON.stringify(ids);
23
+ if(this._subscription && this._subscription.key===key){this.render();return;}
24
+ if(this._subscription)this._stop();
25
+ const sub={socket:this._socket,instance,ids,key,seen:new Set()};
26
+ sub.handler=(id,state)=>{if(this._subscription!==sub||!ids.includes(id))return;sub.seen.add(id);this._values.set(id,state?.val??null);this._draw();};
27
+ this._subscription=sub;
28
+ try{
29
+ Promise.resolve(sub.socket.subscribeState(ids,sub.handler)).catch(()=>{});
30
+ for(const id of ids)Promise.resolve(sub.socket.getState(id)).then(state=>{if(this._subscription===sub&&!sub.seen.has(id)){this._values.set(id,state?.val??null);this._draw();}}).catch(()=>{});
31
+ }catch{this._stop();}
32
+ this.render();
33
+ }
34
+ _draw(){this.render();}
35
+ render(){
36
+ if(!this.shadowRoot||!this.isConnected)return;
37
+ const t=messages[String(this._socket?.systemLang||'en').toLowerCase().startsWith('de')?'de':'en'];
38
+ if(!this._mediaNodes){
39
+ const style=make('style');style.textContent=`:host{display:block;width:100%;height:100%;font-family:var(--u1-font-family,Arial,sans-serif);font-size:var(--u1-font-size,14px);font-weight:var(--u1-font-weight,400);font-style:var(--u1-font-style,normal);text-decoration:var(--u1-text-decoration,none);color:var(--u1-text-color,#eaf0f5);--panel:var(--u1-panel-color,#17202a);--card:var(--u1-card-color,#202b36);--muted:var(--u1-muted-color,#aab8c5)}:host([theme=light]){color:var(--u1-text-color,#182432);--panel:var(--u1-panel-color,#edf2f6);--card:var(--u1-card-color,#fff);--muted:var(--u1-muted-color,#586878)}*{box-sizing:border-box}.panel{height:100%;overflow:auto;background:var(--panel);border-radius:12px;padding:12px}.title{margin:0 0 10px;font-size:1.07em;font-weight:inherit}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:8px}.card{background:var(--card);border-radius:10px;padding:8px;min-width:0}.heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;gap:4px}.frame{position:relative;aspect-ratio:16/9;background:#10151c;border-radius:6px;overflow:hidden}.frame img,.frame iframe{display:block;width:100%;height:100%;object-fit:contain;border:0}.placeholder{position:absolute;inset:0;display:grid;place-items:center;color:#ddd;padding:8px;text-align:center}.button{color:inherit;background:var(--panel);border:0;border-radius:5px;padding:5px 8px;cursor:pointer}.frame:fullscreen{background:#000}.frame:fullscreen img,.frame:fullscreen iframe{height:100%;width:100%}`;
40
+ const panel=make('section','panel'),title=make('h2','title'),grid=make('div','grid');panel.append(title,grid);const cards=[];
41
+ for(let i=0;i<3;i++){
42
+ const card=make('article','card'),heading=make('div','heading'),label=make('span'),button=make('button','button');button.type='button';heading.append(label);
43
+ const frame=make('div','frame'),placeholder=make('div','placeholder');frame.append(placeholder,button);card.append(heading,frame);grid.append(card);
44
+ button.addEventListener('click',()=>{if(this.shadowRoot.fullscreenElement===frame || document.fullscreenElement===frame){document.exitFullscreen?.();return;}const request=frame.requestFullscreen?.();if(request?.catch)request.catch(()=>{placeholder.textContent=t.failed;placeholder.hidden=false;});});
45
+ cards.push({label,button,frame,placeholder,media:null,mode:'',url:''});
46
+ }
47
+ style.textContent += '.placeholder[hidden]{display:none}.frame .button{position:absolute;z-index:2;right:6px;top:6px}';
48
+ this.shadowRoot.replaceChildren(style,panel);this._mediaNodes={title,cards};
49
+ }
50
+ this._mediaNodes.title.textContent=t.title;
51
+ const prefix=this._subscription?.instance;const keys=[prefix?`${prefix}.printer.job.previewUrl`:'',cameraState(prefix||'',this._settings.camera1State),cameraState(prefix||'',this._settings.camera2State)];
52
+ const modes=['image',this._settings.camera1Mode==='mjpeg'?'image':'iframe',this._settings.camera2Mode==='iframe'?'iframe':'image'];
53
+ this._mediaNodes.cards.forEach((card,i)=>{
54
+ card.label.textContent=i===0?t.thumbnail:`${t.camera} ${i}`;card.button.textContent='⛶';card.button.title=t.fullscreen;card.button.setAttribute('aria-label',`${t.fullscreen}: ${card.label.textContent}`);
55
+ const url=mediaUrl(keys[i]?this._values.get(keys[i]):'');const mode=modes[i];
56
+ if(mode!==card.mode || url!==card.url){
57
+ if(card.media)card.media.remove();card.media=null;card.mode=mode;card.url=url;
58
+ if(url){const media=make(mode==='iframe'?'iframe':'img');media.setAttribute('title',card.label.textContent);if(mode==='iframe'){media.setAttribute('allow','autoplay; fullscreen');media.setAttribute('allowfullscreen','');}else media.alt=card.label.textContent;media.addEventListener('error',()=>{card.placeholder.hidden=false;});media.src=url;card.frame.prepend(media);card.media=media;}
59
+ }
60
+ card.placeholder.textContent=i===0?t.noPreview:t.missing;card.placeholder.hidden=!!url;card.button.disabled=!url;
61
+ });
62
+ }
63
+ disconnectedCallback(){super.disconnectedCallback();if(this._mediaNodes){for(const card of this._mediaNodes.cards){card.media?.remove();card.media=null;card.url='';}}}
64
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 120"><rect width="320" height="120" rx="12" fill="#17202a"/><text x="14" y="23" fill="#eaf0f5" font-family="Arial" font-size="13">Print preview &amp; cameras</text><g fill="#273847"><rect x="12" y="34" width="94" height="74" rx="7"/><rect x="113" y="34" width="94" height="74" rx="7"/><rect x="214" y="34" width="94" height="74" rx="7"/></g><g fill="#d5e0e9" font-family="Arial" font-size="9"><text x="22" y="51">Preview</text><text x="123" y="51">Camera 1</text><text x="224" y="51">Camera 2</text></g><g stroke="#6da5c4" stroke-width="3" fill="none"><rect x="32" y="64" width="54" height="30" rx="2"/><rect x="133" y="64" width="54" height="30" rx="2"/><circle cx="160" cy="79" r="8"/><rect x="234" y="64" width="54" height="30" rx="2"/><circle cx="261" cy="79" r="8"/></g></svg>
@@ -0,0 +1,302 @@
1
+ {
2
+ "manifestVersion": 1,
3
+ "tag": "snapmaker-u1-vis1-media",
4
+ "module": "./entry.js",
5
+ "name": {
6
+ "en": "Snapmaker U1 Preview & cameras",
7
+ "de": "Snapmaker U1 Druckvorschau & Kameras"
8
+ },
9
+ "description": {
10
+ "en": "Print preview and two camera streams",
11
+ "de": "Druckvorschau und zwei Kamerastreams"
12
+ },
13
+ "size": {
14
+ "width": 900,
15
+ "height": 300
16
+ },
17
+ "settings": {
18
+ "type": "panel",
19
+ "items": {
20
+ "instance": {
21
+ "type": "instance",
22
+ "adapter": "snapmaker-u1",
23
+ "label": {
24
+ "en": "Snapmaker U1 instance",
25
+ "de": "Snapmaker-U1-Instanz"
26
+ }
27
+ },
28
+ "camera1State": {
29
+ "type": "objectId",
30
+ "label": {
31
+ "en": "Camera 1 stream state ID",
32
+ "de": "Kamera 1 Stream-Datenpunkt"
33
+ },
34
+ "help": {
35
+ "en": "Choose a state containing a camera stream URL",
36
+ "de": "Datenpunkt mit einer Kamera-Stream-URL auswählen"
37
+ }
38
+ },
39
+ "camera1Mode": {
40
+ "type": "select",
41
+ "default": "iframe",
42
+ "label": {
43
+ "en": "Camera 1 format",
44
+ "de": "Kamera 1 Format"
45
+ },
46
+ "options": [
47
+ {
48
+ "value": "iframe",
49
+ "label": "WebRTC / HTML"
50
+ },
51
+ {
52
+ "value": "mjpeg",
53
+ "label": "MJPEG"
54
+ }
55
+ ]
56
+ },
57
+ "camera2State": {
58
+ "type": "objectId",
59
+ "label": {
60
+ "en": "Camera 2 stream state ID",
61
+ "de": "Kamera 2 Stream-Datenpunkt"
62
+ },
63
+ "help": {
64
+ "en": "Choose a state containing a camera stream URL",
65
+ "de": "Datenpunkt mit einer Kamera-Stream-URL auswählen"
66
+ }
67
+ },
68
+ "camera2Mode": {
69
+ "type": "select",
70
+ "default": "mjpeg",
71
+ "label": {
72
+ "en": "Camera 2 format",
73
+ "de": "Kamera 2 Format"
74
+ },
75
+ "options": [
76
+ {
77
+ "value": "iframe",
78
+ "label": "WebRTC / HTML"
79
+ },
80
+ {
81
+ "value": "mjpeg",
82
+ "label": "MJPEG"
83
+ }
84
+ ]
85
+ },
86
+ "appearance": {
87
+ "type": "header",
88
+ "text": {
89
+ "en": "Appearance",
90
+ "de": "Darstellung"
91
+ }
92
+ },
93
+ "appearanceTheme": {
94
+ "type": "select",
95
+ "default": "auto",
96
+ "label": {
97
+ "en": "Base theme",
98
+ "de": "Grunddesign"
99
+ },
100
+ "options": [
101
+ {
102
+ "value": "auto",
103
+ "label": {
104
+ "en": "Automatic",
105
+ "de": "Automatisch"
106
+ }
107
+ },
108
+ {
109
+ "value": "light",
110
+ "label": {
111
+ "en": "Light",
112
+ "de": "Hell"
113
+ }
114
+ },
115
+ {
116
+ "value": "dark",
117
+ "label": {
118
+ "en": "Dark",
119
+ "de": "Dunkel"
120
+ }
121
+ }
122
+ ]
123
+ },
124
+ "panelColor": {
125
+ "type": "color",
126
+ "label": {
127
+ "en": "Panel background",
128
+ "de": "Panel-Hintergrund"
129
+ },
130
+ "help": {
131
+ "en": "Empty uses the base theme",
132
+ "de": "Leer verwendet das Grunddesign"
133
+ }
134
+ },
135
+ "cardColor": {
136
+ "type": "color",
137
+ "label": {
138
+ "en": "Spool card background",
139
+ "de": "Spulenkarten-Hintergrund"
140
+ },
141
+ "help": {
142
+ "en": "Empty uses the base theme",
143
+ "de": "Leer verwendet das Grunddesign"
144
+ }
145
+ },
146
+ "textColor": {
147
+ "type": "color",
148
+ "label": {
149
+ "en": "Text color",
150
+ "de": "Textfarbe"
151
+ },
152
+ "help": {
153
+ "en": "Empty uses the base theme",
154
+ "de": "Leer verwendet das Grunddesign"
155
+ }
156
+ },
157
+ "mutedColor": {
158
+ "type": "color",
159
+ "label": {
160
+ "en": "Secondary text color",
161
+ "de": "Farbe für Nebentexte"
162
+ },
163
+ "help": {
164
+ "en": "Empty uses the base theme",
165
+ "de": "Leer verwendet das Grunddesign"
166
+ }
167
+ },
168
+ "fontPreset": {
169
+ "type": "select",
170
+ "default": "default",
171
+ "label": {
172
+ "en": "Font",
173
+ "de": "Schriftart"
174
+ },
175
+ "options": [
176
+ {
177
+ "value": "default",
178
+ "label": {
179
+ "en": "Default (Arial)",
180
+ "de": "Standard (Arial)"
181
+ }
182
+ },
183
+ {
184
+ "value": "arial",
185
+ "label": "Arial"
186
+ },
187
+ {
188
+ "value": "verdana",
189
+ "label": "Verdana"
190
+ },
191
+ {
192
+ "value": "trebuchet",
193
+ "label": "Trebuchet MS"
194
+ },
195
+ {
196
+ "value": "georgia",
197
+ "label": "Georgia"
198
+ },
199
+ {
200
+ "value": "times",
201
+ "label": "Times New Roman"
202
+ },
203
+ {
204
+ "value": "courier",
205
+ "label": "Courier New"
206
+ },
207
+ {
208
+ "value": "system",
209
+ "label": {
210
+ "en": "System font",
211
+ "de": "Systemschrift"
212
+ }
213
+ }
214
+ ]
215
+ },
216
+ "fontFamily": {
217
+ "type": "text",
218
+ "label": {
219
+ "en": "Custom font family",
220
+ "de": "Eigene Schriftart"
221
+ },
222
+ "help": {
223
+ "en": "Optional font name or CSS font-family list; overrides the font selection. The font must be available on the display device.",
224
+ "de": "Optionaler Schriftname oder CSS-Schriftliste; hat Vorrang vor der Schriftauswahl. Die Schrift muss auf dem Anzeigegerät verfügbar sein."
225
+ }
226
+ },
227
+ "fontSize": {
228
+ "type": "number",
229
+ "min": 8,
230
+ "max": 60,
231
+ "step": 1,
232
+ "default": 14,
233
+ "label": {
234
+ "en": "Font size (px)",
235
+ "de": "Schriftgröße (px)"
236
+ }
237
+ },
238
+ "fontWeight": {
239
+ "type": "select",
240
+ "default": "400",
241
+ "label": {
242
+ "en": "Font weight",
243
+ "de": "Schriftstärke"
244
+ },
245
+ "options": [
246
+ {
247
+ "value": "400",
248
+ "label": {
249
+ "en": "Normal",
250
+ "de": "Normal"
251
+ }
252
+ },
253
+ {
254
+ "value": "500",
255
+ "label": {
256
+ "en": "Medium",
257
+ "de": "Mittel"
258
+ }
259
+ },
260
+ {
261
+ "value": "600",
262
+ "label": {
263
+ "en": "Semi-bold",
264
+ "de": "Halbfett"
265
+ }
266
+ },
267
+ {
268
+ "value": "700",
269
+ "label": {
270
+ "en": "Bold",
271
+ "de": "Fett"
272
+ }
273
+ },
274
+ {
275
+ "value": "800",
276
+ "label": {
277
+ "en": "Extra bold",
278
+ "de": "Extrafett"
279
+ }
280
+ }
281
+ ]
282
+ },
283
+ "fontItalic": {
284
+ "type": "checkbox",
285
+ "default": false,
286
+ "label": {
287
+ "en": "Italic",
288
+ "de": "Kursiv"
289
+ }
290
+ },
291
+ "fontUnderline": {
292
+ "type": "checkbox",
293
+ "default": false,
294
+ "label": {
295
+ "en": "Underline",
296
+ "de": "Unterstrichen"
297
+ }
298
+ }
299
+ }
300
+ },
301
+ "icon": "media-preview.svg"
302
+ }
@@ -0,0 +1,56 @@
1
+ import { SpoolElement } from './spool-element.js';
2
+
3
+ const paths = ['info.connection','printer.info.ready','spoolman.apiConnected','printer.job.state','printer.job.filename','printer.job.progress','printer.job.remaining','printer.job.estimatedEnd','printer.job.estimateAvailable','printer.job.layer.current','printer.job.layer.total','printer.motion.position.z','printer.bed.temperature','printer.bed.target','printer.chamber.temperature',...Array.from({length:4},(_,i)=>[`printer.tools.tool${i}.temperature`,`printer.tools.tool${i}.target`]).flat()];
4
+ const labels = {
5
+ de:{title:'Snapmaker U1',job:'Druckauftrag',none:'Kein Druckauftrag',unknown:'Unbekannt',temps:'Temperaturen',information:'Informationen',layer:'Layer',height:'Höhe',remaining:'Restzeit',end:'Endzeit',bed:'Bett',chamber:'Kammer',connection:'Verbindung',online:'Verbunden',offline:'Offline',spoolman:'Spoolman',battery:'Batterie',printing:'Druckt',paused:'Pausiert',complete:'Abgeschlossen',standby:'Bereit',error:'Fehler'},
6
+ en:{title:'Snapmaker U1',job:'Print job',none:'No print job',unknown:'Unknown',temps:'Temperatures',information:'Information',layer:'Layer',height:'Height',remaining:'Remaining',end:'Estimated end',bed:'Bed',chamber:'Chamber',connection:'Connection',online:'Connected',offline:'Offline',spoolman:'Spoolman',battery:'Battery',printing:'Printing',paused:'Paused',complete:'Complete',standby:'Ready',error:'Error'}
7
+ };
8
+ const finite = value => typeof value === 'number' && Number.isFinite(value);
9
+ export const percent = value => finite(value) && value >= 0 && value <= 100 ? value : null;
10
+ export function duration(value) {
11
+ if (!finite(value) || value < 0) return '–';
12
+ const minutes = Math.floor(value / 60);
13
+ return `${Math.floor(minutes / 60)}h ${String(minutes % 60).padStart(2,'0')}m`;
14
+ }
15
+ function node(tag, name, value) { const result=document.createElement(tag); if (name) result.className=name; if (value !== undefined) result.textContent=value; return result; }
16
+ function value(value, suffix='', digits=0) { return finite(value) ? `${value.toFixed(digits)}${suffix}` : '–'; }
17
+
18
+ /** Read-only overview: independent subscriptions and isolated styles per widget. */
19
+ export class OverviewElement extends SpoolElement {
20
+ _sync() {
21
+ const instance = this._settings.instance;
22
+ const battery = typeof this._settings.batteryOid === 'string' ? this._settings.batteryOid.trim() : '';
23
+ if (!this.isConnected || !this._socket || !/^snapmaker-u1\.\d+$/.test(instance || '')) { this.render(); return; }
24
+ if (this._subscription && this._subscription.battery === battery) { this.render(); return; }
25
+ if (this._subscription) this._stop();
26
+ const ids = paths.map(p=>`${instance}.${p}`);
27
+ if (battery && !ids.includes(battery)) ids.push(battery);
28
+ const sub = {socket:this._socket, instance, battery, ids, seen:new Set()};
29
+ sub.handler = (id,state) => { if (this._subscription !== sub || !ids.includes(id)) return; sub.seen.add(id); this._values.set(id,state?.val ?? null); this.render(); };
30
+ this._subscription = sub;
31
+ try {
32
+ Promise.resolve(sub.socket.subscribeState(ids,sub.handler)).catch(()=>{});
33
+ for (const id of ids) Promise.resolve(sub.socket.getState(id)).then(state=>{if(this._subscription===sub && !sub.seen.has(id)){this._values.set(id,state?.val ?? null);this.render();}}).catch(()=>{});
34
+ } catch { this._stop(); }
35
+ this.render();
36
+ }
37
+ _draw() { this.render(); }
38
+ render() {
39
+ if (!this.shadowRoot || !this.isConnected) return;
40
+ const t = labels[String(this._socket?.systemLang || 'en').toLowerCase().startsWith('de') ? 'de' : 'en'];
41
+ const base=this._subscription?.instance; const get=path=>base ? this._values.get(`${base}.${path}`) : undefined;
42
+ const style=node('style'); style.textContent=`:host{display:block;width:100%;height:100%;font-family:var(--u1-font-family,Arial,sans-serif);font-size:var(--u1-font-size,14px);font-weight:var(--u1-font-weight,400);font-style:var(--u1-font-style,normal);text-decoration:var(--u1-text-decoration,none);color:var(--u1-text-color,#eaf0f5);--panel:var(--u1-panel-color,#17202a);--card:var(--u1-card-color,#202b36);--muted:var(--u1-muted-color,#aab8c5)}:host([theme=light]){color:var(--u1-text-color,#182432);--panel:var(--u1-panel-color,#edf2f6);--card:var(--u1-card-color,#fff);--muted:var(--u1-muted-color,#586878)}*{box-sizing:border-box}.panel{height:100%;overflow:auto;background:var(--panel);border-radius:12px;padding:12px}.header,.row{display:flex;align-items:center;justify-content:space-between;gap:8px}.header{margin-bottom:10px}.header strong{font-size:1.15em}.muted{color:var(--muted);font-size:.85em}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:8px}.card{background:var(--card);border-radius:10px;padding:10px;min-width:0}.card h2{font-size:1em;font-weight:inherit;margin:0 0 8px}.job{font-weight:bold;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.progress{height:8px;border-radius:8px;background:var(--panel);overflow:hidden;margin:8px 0}.bar{height:100%;background:#42a5f5}.numbers{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:8px}.metric{background:var(--panel);border-radius:7px;padding:6px;min-width:0}.metric strong{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.status{border-radius:12px;padding:4px 8px;background:var(--card)}.online{color:#4caf70}.offline{color:#e67171}`;
43
+ const panel=node('section','panel'); const head=node('header','header'); head.append(node('strong','',t.title));
44
+ const state=String(get('printer.job.state') || '').toLowerCase(); const states={printing:t.printing,paused:t.paused,complete:t.complete,standby:t.standby,error:t.error}; head.append(node('span','status',states[state] || state || t.unknown)); panel.append(head);
45
+ const grid=node('div','grid'); panel.append(grid);
46
+ const card=(title)=>{const a=node('article','card');a.append(node('h2','',title));grid.append(a);return a;};
47
+ const metric=(container,label,text)=>{const a=node('div','metric');a.append(node('span','muted',label),node('strong','',text));container.append(a);};
48
+ const job=card(t.job); job.append(node('div','job',String(get('printer.job.filename') || t.none)));
49
+ const p=percent(get('printer.job.progress')); const track=node('div','progress');const bar=node('div','bar');bar.style.width=`${p ?? 0}%`;track.append(bar);job.append(track,node('div','muted',p===null?'–':`${p.toFixed(1)} %`));
50
+ const jobNums=node('div','numbers');metric(jobNums,t.layer,`${value(get('printer.job.layer.current'))} / ${value(get('printer.job.layer.total'))}`);metric(jobNums,t.height,value(get('printer.motion.position.z'),' mm',2));job.append(jobNums);
51
+ const temp=card(t.temps);const tempNums=node('div','numbers');for(let i=0;i<4;i++){const actual=get(`printer.tools.tool${i}.temperature`),target=get(`printer.tools.tool${i}.target`);metric(tempNums,`Extruder ${i+1}`,`${value(actual,' °C',1)}${finite(target) ? ` / ${value(target,' °C',0)}` : ''}`);}temp.append(tempNums);
52
+ const info=card(t.information);const infoNums=node('div','numbers');const available=get('printer.job.estimateAvailable')===true;const end=get('printer.job.estimatedEnd');metric(infoNums,t.remaining,available?duration(get('printer.job.remaining')):'–');metric(infoNums,t.end,available && finite(end) && end>0 ? new Date(end).toLocaleTimeString(undefined,{hour:'2-digit',minute:'2-digit'}) : '–');metric(infoNums,t.bed,value(get('printer.bed.temperature'),' °C',1));metric(infoNums,t.chamber,value(get('printer.chamber.temperature'),' °C',1));if(this._subscription?.battery)metric(infoNums,t.battery,value(this._values.get(this._subscription.battery),' %'));info.append(infoNums);
53
+ for(const [label,connected] of [[t.connection,get('info.connection')],['Klipper',get('printer.info.ready')],[t.spoolman,get('spoolman.apiConnected')]]){const row=node('div','row muted');const status=connected===true?t.online:connected===false?t.offline:t.unknown;row.append(node('span','',label),node('span',connected===true?'online':connected===false?'offline':'',status));info.append(row);}
54
+ this.shadowRoot.replaceChildren(style,panel);
55
+ }
56
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 120"><rect width="320" height="120" rx="12" fill="#17202a"/><text x="14" y="23" fill="#eaf0f5" font-family="Arial" font-size="13">Snapmaker U1</text><g fill="#273847"><rect x="12" y="34" width="94" height="74" rx="7"/><rect x="113" y="34" width="94" height="74" rx="7"/><rect x="214" y="34" width="94" height="74" rx="7"/></g><g fill="#eaf0f5" font-family="Arial" font-size="9"><text x="20" y="50">Print job</text><text x="121" y="50">Temperatures</text><text x="222" y="50">Information</text><text x="20" y="76">68 %</text><text x="121" y="76">215 °C</text><text x="222" y="76">1h 24m</text></g><rect x="20" y="86" width="76" height="5" rx="2" fill="#17202a"/><rect x="20" y="86" width="52" height="5" rx="2" fill="#42a5f5"/></svg>