rendered.js not found
Run: cd tools && go run . preview all
'; + showMessage('rendered.js not found — runcd tools && go run . preview all to generate', 'error');
}
render();
})();
+// ── Message helpers ──
+function showMessage(ht, type) {
+ const container = document.getElementById('messages');
+ const el = document.createElement('div');
+ el.className = 'message message-' + (type || 'warn');
+ el.innerHTML = ht;
+ container.appendChild(el);
+ return el;
+}
+function clearMessages() {
+ document.getElementById('messages').innerHTML = '';
+}
+
+// ── Static-mode notice ──
+showMessage('Gmail / Outlook simulation is approximate. For accurate rendering with CSS inlining, use cd tools && go run . dev', 'warn');
+
// ── Dev-server live-reload (WebSocket) ──
(function(){
- const notice = document.getElementById('static-notice');
let ws;
try {
const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
ws = new WebSocket(proto + '//' + location.host + '/ws');
} catch(e) {
- // static mode (file://) — WebSocket constructor throws
- if (notice) notice.style.display = 'block';
return;
}
ws.onmessage = function(e) {
@@ -323,21 +340,21 @@ document.addEventListener('keydown',e=>{
render();
};
document.head.appendChild(script);
+ } else if (msg.type === 'error') {
+ showMessage(msg.message, 'error');
}
} catch(_) {}
};
ws.onopen = function() {
- if (notice) notice.style.display = 'none';
+ clearMessages();
console.log('[dev] live-reload connected');
};
ws.onclose = function() {
- if (notice) notice.style.display = 'block';
+ showMessage('Dev server disconnected', 'error');
console.log('[dev] live-reload disconnected');
};
ws.onerror = function() {
- if (notice) notice.style.display = 'block';
+ showMessage('Dev server connection failed', 'error');
};
})();
-
-