create-volt 0.38.0 → 0.39.1

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,26 @@ 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.1] - 2026-06-30
8
+
9
+ ### Fixed
10
+ - **Scaffolding was broken in 0.37.0–0.39.0.** The bundled `themes/` dir is
11
+ copied into new apps, but it was never added to the package `files`, so it was
12
+ missing from the npm tarball and `npm create volt` crashed with
13
+ `ENOENT … create-volt/themes`. Added `themes` to `files`, and guarded the
14
+ bundled-dir copy (`addons`/`themes`) so a missing dir is skipped, never fatal.
15
+ Verified by scaffolding from the packed tarball.
16
+
17
+ ## [0.39.0] - 2026-06-29
18
+
19
+ ### Fixed
20
+ - **Hot reload now reaches content pages.** Pages/posts are server-rendered HTML
21
+ that dont load `volt.js`, so the 0.38 morph client never ran on them. In dev,
22
+ the `pages`/`posts` add-ons now inject the hot-reload client (socket.io +
23
+ `volt.js`) into every served page. Verified with Chromium: editing a post
24
+ morphs the DOM in place — scroll position and page state preserved, no full
25
+ reload. Nothing is injected in production.
26
+
7
27
  ## [0.38.0] - 2026-06-29
8
28
 
9
29
  ### Added
@@ -508,6 +528,8 @@ All notable changes to `create-volt` are documented here. The format follows
508
528
  watching and full-page hot reload. Supports `--skip-install` and `--force`,
509
529
  and auto-detects npm / pnpm / yarn / bun for the install step.
510
530
 
531
+ [0.39.1]: https://github.com/MIR-2025/volt/releases/tag/v0.39.1
532
+ [0.39.0]: https://github.com/MIR-2025/volt/releases/tag/v0.39.0
511
533
  [0.38.0]: https://github.com/MIR-2025/volt/releases/tag/v0.38.0
512
534
  [0.37.0]: https://github.com/MIR-2025/volt/releases/tag/v0.37.0
513
535
  [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/index.js CHANGED
@@ -465,8 +465,12 @@ if (fs.existsSync(shippedDockerignore)) {
465
465
  // Bundle the add-on sources so the app's setup wizard can enable them later
466
466
  // (only for templates that ship the wizard, i.e. have a setup/ dir).
467
467
  if (fs.existsSync(path.join(targetDir, "setup"))) {
468
- fs.cpSync(path.join(__dirname, "addons"), path.join(targetDir, ".volt", "addons"), { recursive: true });
469
- fs.cpSync(path.join(__dirname, "themes"), path.join(targetDir, ".volt", "themes"), { recursive: true }); // bundled themes the wizard can pick
468
+ // copy each bundled dir into .volt/ guard existsSync so a missing dir (e.g.
469
+ // an incomplete install) is skipped rather than crashing the scaffold.
470
+ for (const name of ["addons", "themes"]) {
471
+ const src = path.join(__dirname, name);
472
+ if (fs.existsSync(src)) fs.cpSync(src, path.join(targetDir, ".volt", name), { recursive: true });
473
+ }
470
474
  }
471
475
 
472
476
  // --- stamp the project name into package.json ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-volt",
3
- "version": "0.38.0",
3
+ "version": "0.39.1",
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": {
@@ -11,6 +11,7 @@
11
11
  "lib",
12
12
  "templates",
13
13
  "addons",
14
+ "themes",
14
15
  "CHANGELOG.md"
15
16
  ],
16
17
  "engines": {
@@ -0,0 +1,28 @@
1
+ // volt-theme-classic — a structured site theme: top nav bar + card content.
2
+ const NAME = process.env.SITE_NAME || "Home";
3
+
4
+ export const css = `:root{--ink:#1f2329;--bg:#f4f5f7;--card:#fff;--accent:#2557d6;--muted:#5b6573;--line:#e2e5ea}
5
+ *{box-sizing:border-box}
6
+ body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.7 system-ui,sans-serif}
7
+ header.site{background:var(--card);border-bottom:1px solid var(--line)}
8
+ header.site .bar{display:flex;align-items:center;gap:1rem;max-width:840px;margin:0 auto;padding:.9rem 1.2rem}
9
+ header.site a.brand{font-weight:800;color:var(--ink);text-decoration:none;font-size:1.15rem}
10
+ header.site nav{margin-left:auto}
11
+ header.site nav a{color:var(--muted);text-decoration:none;margin-left:1rem}
12
+ header.site nav a:hover{color:var(--accent)}
13
+ main .card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:2rem;max-width:840px;margin:2rem auto}
14
+ h1,h2,h3{line-height:1.25}
15
+ a{color:var(--accent)}
16
+ pre{background:#0b0d11;color:#cfe3ff;padding:1rem;border-radius:8px;overflow:auto}
17
+ :not(pre)>code{background:#eef1f5;padding:.1em .35em;border-radius:5px}
18
+ img{max-width:100%}
19
+ footer.site{text-align:center;color:var(--muted);font-size:.9rem;padding:2rem 1rem}`;
20
+
21
+ export function layout({ title, head, content }) {
22
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
23
+ <title>${title}</title>${head}<link rel="stylesheet" href="/_theme.css" /></head><body>
24
+ <header class="site"><div class="bar"><a class="brand" href="/">${NAME}</a><nav><a href="/">Home</a></nav></div></header>
25
+ <main><div class="card">${content}</div></main>
26
+ <footer class="site">${NAME} — built with Volt</footer>
27
+ </body></html>`;
28
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "description": "Volt theme: Classic — a structured site with a top nav bar and card content."
3
+ }
@@ -0,0 +1,27 @@
1
+ // volt-theme-midnight — a dark, modern, sans-serif theme.
2
+ const NAME = process.env.SITE_NAME || "Home";
3
+
4
+ export const css = `:root{--ink:#e6e8ee;--bg:#0e1116;--accent:#7c9cff;--muted:#9aa4b2;--line:#222831}
5
+ *{box-sizing:border-box}
6
+ body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.7 system-ui,-apple-system,sans-serif}
7
+ .wrap{max-width:760px;margin:0 auto;padding:0 1.2rem}
8
+ header.site{position:sticky;top:0;background:rgba(14,17,22,.85);backdrop-filter:blur(6px);border-bottom:1px solid var(--line);padding:.9rem 0}
9
+ header.site a{color:var(--accent);font-weight:800;text-decoration:none;letter-spacing:-.02em}
10
+ main{padding:2rem 0 3rem}
11
+ h1,h2,h3{line-height:1.2;letter-spacing:-.01em}
12
+ a{color:var(--accent)}
13
+ pre{background:#0a0d12;border:1px solid var(--line);padding:1rem;border-radius:10px;overflow:auto;color:#cfe3ff}
14
+ :not(pre)>code{background:rgba(124,156,255,.15);padding:.1em .35em;border-radius:5px;color:var(--accent)}
15
+ blockquote{border-left:3px solid var(--accent);margin:1.2rem 0;padding:.2rem 1rem;color:var(--muted)}
16
+ img{max-width:100%;border-radius:10px}
17
+ table{border-collapse:collapse;width:100%}td,th{border:1px solid var(--line);padding:.5rem .7rem}
18
+ footer.site{border-top:1px solid var(--line);margin-top:3rem;padding:1.5rem 0;color:var(--muted);font-size:.9rem}`;
19
+
20
+ export function layout({ title, head, content }) {
21
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
22
+ <title>${title}</title>${head}<link rel="stylesheet" href="/_theme.css" /></head><body>
23
+ <header class="site"><div class="wrap"><a href="/">${NAME}</a></div></header>
24
+ <main><div class="wrap">${content}</div></main>
25
+ <footer class="site"><div class="wrap">${NAME} — built with Volt</div></footer>
26
+ </body></html>`;
27
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "description": "Volt theme: Midnight — dark, modern, sans-serif with a sticky header."
3
+ }
@@ -0,0 +1,26 @@
1
+ // volt-theme-paper — a light, serif, reading-focused theme.
2
+ const NAME = process.env.SITE_NAME || "Home";
3
+
4
+ export const css = `:root{--ink:#222;--bg:#fbfaf7;--accent:#9a3b2e;--muted:#6b6b6b}
5
+ *{box-sizing:border-box}
6
+ body{margin:0;background:var(--bg);color:var(--ink);font:18px/1.75 Georgia,"Times New Roman",serif}
7
+ .wrap{max-width:680px;margin:0 auto;padding:0 1.2rem}
8
+ header.site{padding:2rem 0 1rem;border-bottom:1px solid #e7e3da}
9
+ header.site a{color:var(--ink);text-decoration:none;font-weight:700;font-size:1.3rem}
10
+ main{padding:2rem 0 3rem}
11
+ h1,h2,h3{font-weight:700;line-height:1.2}
12
+ a{color:var(--accent)}
13
+ pre{background:#f1ede4;padding:1rem;border-radius:6px;overflow:auto;font:14px/1.5 ui-monospace,monospace}
14
+ :not(pre)>code{background:#f1ede4;padding:.1em .35em;border-radius:4px;font-size:.9em}
15
+ blockquote{border-left:3px solid var(--accent);margin:1.5rem 0;padding:.2rem 1.2rem;color:var(--muted);font-style:italic}
16
+ img{max-width:100%;border-radius:6px}
17
+ footer.site{border-top:1px solid #e7e3da;margin-top:3rem;padding:1.5rem 0;color:var(--muted);font-size:.9rem}`;
18
+
19
+ export function layout({ title, head, content }) {
20
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
21
+ <title>${title}</title>${head}<link rel="stylesheet" href="/_theme.css" /></head><body>
22
+ <header class="site"><div class="wrap"><a href="/">${NAME}</a></div></header>
23
+ <main><div class="wrap">${content}</div></main>
24
+ <footer class="site"><div class="wrap">${NAME} — built with Volt</div></footer>
25
+ </body></html>`;
26
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "description": "Volt theme: Paper — light, serif, reading-focused (blogs, essays, docs)."
3
+ }