create-volt 0.38.0 → 0.39.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ All notable changes to `create-volt` are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/), and this project adheres to
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.39.0] - 2026-06-29
8
+
9
+ ### Fixed
10
+ - **Hot reload now reaches content pages.** Pages/posts are server-rendered HTML
11
+ that dont load `volt.js`, so the 0.38 morph client never ran on them. In dev,
12
+ the `pages`/`posts` add-ons now inject the hot-reload client (socket.io +
13
+ `volt.js`) into every served page. Verified with Chromium: editing a post
14
+ morphs the DOM in place — scroll position and page state preserved, no full
15
+ reload. Nothing is injected in production.
16
+
7
17
  ## [0.38.0] - 2026-06-29
8
18
 
9
19
  ### Added
@@ -508,6 +518,7 @@ All notable changes to `create-volt` are documented here. The format follows
508
518
  watching and full-page hot reload. Supports `--skip-install` and `--force`,
509
519
  and auto-detects npm / pnpm / yarn / bun for the install step.
510
520
 
521
+ [0.39.0]: https://github.com/MIR-2025/volt/releases/tag/v0.39.0
511
522
  [0.38.0]: https://github.com/MIR-2025/volt/releases/tag/v0.38.0
512
523
  [0.37.0]: https://github.com/MIR-2025/volt/releases/tag/v0.37.0
513
524
  [0.36.0]: https://github.com/MIR-2025/volt/releases/tag/v0.36.0
@@ -128,6 +128,13 @@ const DEV = process.env.NODE_ENV !== "production";
128
128
  // a restart (ESM caches a given URL forever); unchanged files keep the same URL.
129
129
  const freshUrl = (f) => pathToFileURL(f).href + (DEV ? "?t=" + fs.statSync(f).mtimeMs : "");
130
130
 
131
+ // In dev, inject the hot-reload client into served pages — content pages don't
132
+ // otherwise load volt.js, so they'd never receive reload/morph events. socket.io
133
+ // serves its client at /socket.io/socket.io.js; volt.js (a module) runs the
134
+ // hot-reload IIFE. Nothing is injected in production.
135
+ const HOT = DEV ? '\n<script src="/socket.io/socket.io.js"></script><script type="module" src="/volt.js"></script>\n' : "";
136
+ export const injectHot = (html) => (!HOT ? html : html.includes("</body>") ? html.replace("</body>", HOT + "</body>") : html + HOT);
137
+
131
138
  export async function loadTheme(dir, env) {
132
139
  const wrap = (m) => {
133
140
  const layout = m && (m.layout || m.default);
@@ -182,7 +189,7 @@ export async function pagesRouter({ dir }) {
182
189
  const content = meta.format === "html" ? body : marked.parse(body);
183
190
  const m = { ...meta, title: meta.title || slug };
184
191
  const { layout } = await getTheme();
185
- res.type("html").send(layout({ title: m.title, head: metaHead(m), content, meta: m }));
192
+ res.type("html").send(injectHot(layout({ title: m.title, head: metaHead(m), content, meta: m })));
186
193
  });
187
194
  return r;
188
195
  }
@@ -6,7 +6,7 @@ import fs from "node:fs";
6
6
  import path from "node:path";
7
7
  // express + marked are imported lazily in postsRouter() so the pure helpers load
8
8
  // without those deps. Theme + SEO come from the pages add-on (a dependency).
9
- import { parseFrontMatter, isSafeSlug, metaHead, themeResolver } from "../../../pages/files/lib/pages.js";
9
+ import { parseFrontMatter, isSafeSlug, metaHead, themeResolver, injectHot } from "../../../pages/files/lib/pages.js";
10
10
 
11
11
  const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
12
12
  const slugify = (s) => String(s).toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -120,7 +120,7 @@ export async function postsRouter({ dir, themeDir }) {
120
120
  const render = async ({ title, content, meta = {} }) => {
121
121
  const m = { ...meta, title };
122
122
  const { layout } = await getTheme();
123
- return layout({ title, head: metaHead(m), content, meta: m });
123
+ return injectHot(layout({ title, head: metaHead(m), content, meta: m }));
124
124
  };
125
125
  const r = express.Router();
126
126
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-volt",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "description": "Scaffold a new Volt app — no-build, signals-based UI with Socket.io hot reload.",
5
5
  "type": "module",
6
6
  "bin": {