elit 3.4.1 → 3.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elit",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "Optimized lightweight library for creating DOM elements with reactive state",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/hmr.ts CHANGED
@@ -40,6 +40,11 @@ class ElitHMR implements HMRClient {
40
40
  return;
41
41
  }
42
42
 
43
+ // Skip HMR in preview mode (no WebSocket server is running)
44
+ if ((window as any).__ELIT_MODE__ === 'preview') {
45
+ return;
46
+ }
47
+
43
48
  this.connect();
44
49
  }
45
50
 
package/src/server.ts CHANGED
@@ -1678,7 +1678,8 @@ export default css;
1678
1678
 
1679
1679
  // Inject import map and SSR styles into <head>
1680
1680
  const elitImportMap = await createElitImportMap(client.root, basePath, client.mode);
1681
- const headInjection = ssrStyles ? `${ssrStyles}\n${elitImportMap}` : elitImportMap;
1681
+ const modeScript = config.mode === 'preview' ? '<script>window.__ELIT_MODE__=\'preview\';</script>' : '';
1682
+ const headInjection = `${modeScript}${ssrStyles ? '\n' + ssrStyles : ''}\n${elitImportMap}`;
1682
1683
  html = html.includes('</head>') ? html.replace('</head>', `${headInjection}</head>`) : html;
1683
1684
  html = html.includes('</body>') ? html.replace('</body>', `${hmrScript}</body>`) : html + hmrScript;
1684
1685
  content = Buffer.from(html);
@@ -1756,7 +1757,8 @@ export default css;
1756
1757
 
1757
1758
  // Inject import map in head, HMR script in body
1758
1759
  const elitImportMap = await createElitImportMap(client.root, basePath, client.mode);
1759
- html = html.includes('</head>') ? html.replace('</head>', `${elitImportMap}</head>`) : html;
1760
+ const modeScript = config.mode === 'preview' ? '<script>window.__ELIT_MODE__=\'preview\';</script>\n' : '';
1761
+ html = html.includes('</head>') ? html.replace('</head>', `${modeScript}${elitImportMap}</head>`) : html;
1760
1762
  html = html.includes('</body>') ? html.replace('</body>', `${hmrScript}</body>`) : html + hmrScript;
1761
1763
 
1762
1764
  res.writeHead(200, {