@dogsbay/ssg-cli 0.2.0-beta.167.1 → 0.2.0-beta.169

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.
@@ -45,7 +45,7 @@ import {
45
45
  uniqueSort,
46
46
  unitOfPath,
47
47
  versionsOf
48
- } from "./chunk-XYPTZFVB.mjs";
48
+ } from "./chunk-MAAAXB4P.mjs";
49
49
  import {
50
50
  __commonJS,
51
51
  __export,
@@ -6072,11 +6072,19 @@ db-nav-tree [data-part="toggle"] {
6072
6072
  /* A section without a page: the toggle carries the label and fills the row. */
6073
6073
  db-nav-tree [data-part="toggle"]:has([data-part="label"]) { @apply h-full min-w-0 flex-1 text-left; }
6074
6074
  db-nav-tree [data-part="toggle"] [data-part="label"] { @apply min-w-0 flex-1 truncate; }
6075
- db-nav-tree [data-part="chevron"] {
6075
+ /* The chevron, drawn here (chevron="css" on the tree, @dogsbay/elements' db-nav-tree): no <svg> in every section. */
6076
+ db-nav-tree[chevron="css"] [data-part="toggle"]::before {
6077
+ content: "";
6076
6078
  @apply size-4 shrink-0 transition-transform duration-200;
6077
6079
  order: -1;
6080
+ background: currentColor;
6081
+ -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat; /* Chromium before 120 */
6082
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
6083
+ }
6084
+ db-nav-tree[chevron="css"] [data-part="toggle"][aria-expanded="true"]::before { transform: rotate(90deg); }
6085
+ @media (forced-colors: active) {
6086
+ db-nav-tree[chevron="css"] [data-part="toggle"]::before { forced-color-adjust: none; background: ButtonText; }
6078
6087
  }
6079
- db-nav-tree [data-part="toggle"][aria-expanded="true"] [data-part="chevron"] { transform: rotate(90deg); }
6080
6088
 
6081
6089
  /* \u2500\u2500\u2500 Version and language switchers (VersionSwitcher look, db-select parts) \u2500 */
6082
6090
  db-select [data-part="trigger"] {
@@ -35,7 +35,7 @@ import {
35
35
  translationTables,
36
36
  versionsOf,
37
37
  writeTranslationStubs
38
- } from "./chunk-XYPTZFVB.mjs";
38
+ } from "./chunk-MAAAXB4P.mjs";
39
39
  import "./chunk-F6VRYHSY.mjs";
40
40
  import "./chunk-YVSP26OS.mjs";
41
41
  import "./chunk-Z7WUDBZV.mjs";
@@ -4,7 +4,7 @@ import {
4
4
  copiedPath,
5
5
  parseConfig,
6
6
  readBuildFiles
7
- } from "./chunk-XYPTZFVB.mjs";
7
+ } from "./chunk-MAAAXB4P.mjs";
8
8
  import "./chunk-F6VRYHSY.mjs";
9
9
  import {
10
10
  UsageError,
@@ -9,13 +9,13 @@ import {
9
9
  releaseDiff,
10
10
  releaseExitCode,
11
11
  releaseRedirects
12
- } from "./chunk-JXFQPMYJ.mjs";
12
+ } from "./chunk-UWS3P7LM.mjs";
13
13
  import {
14
14
  buildUnits,
15
15
  parseConfig,
16
16
  readBuildFiles,
17
17
  versionsOf
18
- } from "./chunk-XYPTZFVB.mjs";
18
+ } from "./chunk-MAAAXB4P.mjs";
19
19
  import "./chunk-F6VRYHSY.mjs";
20
20
  import "./chunk-YVSP26OS.mjs";
21
21
  import "./chunk-Z7WUDBZV.mjs";
@@ -9,25 +9,42 @@ import "./chunk-STRHO6SY.mjs";
9
9
  import { createServer } from "node:http";
10
10
  import { readFile, stat } from "node:fs/promises";
11
11
  import { join, normalize, dirname, resolve, sep } from "node:path";
12
- async function isFile(p) {
12
+
13
+ // src/core/etag.ts
14
+ function etagMatches(header, etag) {
15
+ if (!header) return false;
16
+ if (header.trim() === "*") return true;
17
+ const bare = (t) => t.trim().replace(/^W\//, "");
18
+ return header.split(",").some((t) => bare(t) === bare(etag));
19
+ }
20
+
21
+ // src/node/serve.ts
22
+ async function fileTag(p) {
13
23
  try {
14
- return (await stat(p)).isFile();
24
+ const s = await stat(p, { bigint: true });
25
+ return s.isFile() ? `W/"${s.size.toString(16)}-${s.mtimeNs.toString(16)}-${s.ino.toString(16)}"` : void 0;
15
26
  } catch {
16
- return false;
27
+ return void 0;
17
28
  }
18
29
  }
19
- async function handle(root, reqUrl, res) {
30
+ var isFile = async (p) => await fileTag(p) !== void 0;
31
+ async function handle(root, reqUrl, res, ifNoneMatch) {
20
32
  const url = new URL(`http://x${reqUrl.startsWith("/") ? "" : "/"}${reqUrl}`);
21
33
  const path = normalize(decodeURIComponent(url.pathname)).replace(/^(\.\.[/\\])+/, "");
22
34
  const base = join(root, path);
23
35
  const candidates = path.endsWith("/") ? [join(base, "index.html")] : [base, `${base}.html`, join(base, "index.html")];
24
36
  for (const c of candidates) {
25
- if (inside(root, c) && await isFile(c)) {
37
+ const tag = inside(root, c) ? await fileTag(c) : void 0;
38
+ if (tag) {
26
39
  if (c === join(base, "index.html") && !path.endsWith("/")) {
27
40
  res.writeHead(301, { location: url.pathname.replace(/^\/+/, "/") + "/" + url.search });
28
41
  return res.end();
29
42
  }
30
- res.writeHead(200, { "content-type": contentType(c), "cache-control": "no-cache", "x-content-type-options": "nosniff" });
43
+ if (etagMatches(ifNoneMatch, tag)) {
44
+ res.writeHead(304, { etag: tag, "cache-control": "no-cache" });
45
+ return res.end();
46
+ }
47
+ res.writeHead(200, { "content-type": contentType(c), etag: tag, "cache-control": "no-cache", "x-content-type-options": "nosniff" });
31
48
  return res.end(await readFile(c));
32
49
  }
33
50
  }
@@ -51,7 +68,7 @@ function serve(dir, port, host = "127.0.0.1") {
51
68
  const root = resolve(dir);
52
69
  const server = createServer(async (req, res) => {
53
70
  try {
54
- await handle(root, req.url ?? "/", res);
71
+ await handle(root, req.url ?? "/", res, req.headers["if-none-match"]);
55
72
  } catch (e) {
56
73
  if (res.headersSent) return res.destroy();
57
74
  const bad = e instanceof URIError;
package/cli.mjs CHANGED
@@ -37,16 +37,16 @@ async function main() {
37
37
  usage(1);
38
38
  }
39
39
  if (wantsHelp(args)) usage(0, cmd);
40
- if (cmd === "build") return (await import("./chunks/build-command-WQJANVGR.mjs")).runBuild(args, HIGHLIGHT_WORKER);
41
- if (cmd === "assemble") return (await import("./chunks/build-command-WQJANVGR.mjs")).runBuild(args, HIGHLIGHT_WORKER, { assemble: true });
42
- if (cmd === "check") return (await import("./chunks/check-command-QTJ6BUNL.mjs")).runCheck(args);
43
- if (cmd === "publish") return (await import("./chunks/publish-command-J7KGJTLD.mjs")).runPublish(args);
40
+ if (cmd === "build") return (await import("./chunks/build-command-OGFXZNYF.mjs")).runBuild(args, HIGHLIGHT_WORKER);
41
+ if (cmd === "assemble") return (await import("./chunks/build-command-OGFXZNYF.mjs")).runBuild(args, HIGHLIGHT_WORKER, { assemble: true });
42
+ if (cmd === "check") return (await import("./chunks/check-command-KNONWTEX.mjs")).runCheck(args);
43
+ if (cmd === "publish") return (await import("./chunks/publish-command-WLAWDIEL.mjs")).runPublish(args);
44
44
  if (cmd === "release-diff") {
45
45
  const from = option(args, "--from")[0];
46
46
  const gitFrom = option(args, "--git-from")[0];
47
47
  const o = { from, gitFrom, json: flag(args, "--json"), write: flag(args, "--write"), candidates: flag(args, "--candidates"), strict: flag(args, "--strict") };
48
48
  const project = resolve(positional(args, "."));
49
- const { runReleaseDiff } = await import("./chunks/release-diff-JMNCG2T7.mjs");
49
+ const { runReleaseDiff } = await import("./chunks/release-diff-G5GFYRQD.mjs");
50
50
  process.exitCode = await runReleaseDiff(project, o);
51
51
  return;
52
52
  }
@@ -58,7 +58,7 @@ async function main() {
58
58
  const llms = flag(args, "--llms");
59
59
  const project = resolve(positional(args, "."));
60
60
  const t0 = performance.now();
61
- const { dev, readyLine, serverUrl } = await import("./chunks/dev-X3Y5P4KI.mjs");
61
+ const { dev, readyLine, serverUrl } = await import("./chunks/dev-M3RP4ECB.mjs");
62
62
  const { server } = await dev(project, port, { diagrams: !noDiagrams, lazy, search: noSearchDev ? false : void 0, llms, token: process.env.DOGSBAY_DEV_TOKEN || void 0, listening: (s) => console.log(readyLine(s)) });
63
63
  console.log(`dev server for ${project} at ${serverUrl(server)} (ready in ${Math.round(performance.now() - t0)} ms); watching for changes`);
64
64
  return;
@@ -66,7 +66,7 @@ async function main() {
66
66
  if (cmd === "serve") {
67
67
  const port = Number(option(args, "-p", "--port")[0] ?? 4400);
68
68
  const dir = resolve(positional(args, "out"));
69
- const { serve } = await import("./chunks/serve-CUWABTUV.mjs");
69
+ const { serve } = await import("./chunks/serve-5DMYGIGN.mjs");
70
70
  await serve(dir, port);
71
71
  console.log(`serving ${dir} at http://127.0.0.1:${port}/`);
72
72
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/ssg-cli",
3
- "version": "0.2.0-beta.167.1",
3
+ "version": "0.2.0-beta.169",
4
4
  "type": "module",
5
5
  "description": "The dogsbay-ssg command: build, check, preview and publish Dogsbay-MD documentation sites that work offline",
6
6
  "license": "Apache-2.0",
@@ -18,7 +18,7 @@
18
18
  "NOTICE"
19
19
  ],
20
20
  "dependencies": {
21
- "@dogsbay/icons": "0.2.0-beta.167",
21
+ "@dogsbay/icons": "0.2.0-beta.169",
22
22
  "@mermanjs/web-render": "0.9.3"
23
23
  },
24
24
  "publishConfig": {