ssqch 0.7.0 → 0.8.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.
Files changed (153) hide show
  1. package/README.md +6 -4
  2. package/bin/ssqch.js +14 -48
  3. package/bundled/README.md +1247 -0
  4. package/bundled/completions/bash +840 -0
  5. package/bundled/completions/elvish +286 -0
  6. package/bundled/completions/fish +182 -0
  7. package/bundled/completions/powershell +318 -0
  8. package/bundled/completions/zsh +510 -0
  9. package/bundled/ssqch.d.ts +532 -0
  10. package/bundled/starter/engines/index.edge +11 -0
  11. package/bundled/starter/engines/index.ejs +11 -0
  12. package/bundled/starter/engines/index.hbs +11 -0
  13. package/bundled/starter/engines/index.liquid +11 -0
  14. package/bundled/starter/engines/layout.edge +35 -0
  15. package/bundled/starter/engines/layout.ejs +35 -0
  16. package/bundled/starter/engines/layout.hbs +35 -0
  17. package/bundled/starter/engines/layout.liquid +35 -0
  18. package/bundled/starter/gitignore +3 -0
  19. package/bundled/starter/jsconfig.json +11 -0
  20. package/bundled/starter/src/404.md +8 -0
  21. package/bundled/starter/src/_blueprints/posts.md +5 -0
  22. package/bundled/starter/src/_data/site.json +4 -0
  23. package/bundled/starter/src/_includes/layout.jinja +35 -0
  24. package/bundled/starter/src/index.jinja +11 -0
  25. package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
  26. package/bundled/starter/src/posts/posts.json +4 -0
  27. package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
  28. package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
  29. package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
  30. package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
  31. package/bundled/starter/ssqch.config.js +29 -0
  32. package/bundled/starter-docs/engines/edge/base.edge +41 -0
  33. package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
  34. package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
  35. package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
  36. package/bundled/starter-docs/engines/edge/doc.edge +59 -0
  37. package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
  38. package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
  39. package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
  40. package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
  41. package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
  42. package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
  43. package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
  44. package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
  45. package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
  46. package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
  47. package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
  48. package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
  49. package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
  50. package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
  51. package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
  52. package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
  53. package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
  54. package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
  55. package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
  56. package/bundled/starter-docs/gitignore +4 -0
  57. package/bundled/starter-docs/src/404.md +12 -0
  58. package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
  59. package/bundled/starter-docs/src/_data/nav.yml +10 -0
  60. package/bundled/starter-docs/src/_data/site.json +5 -0
  61. package/bundled/starter-docs/src/_includes/base.jinja +41 -0
  62. package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
  63. package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
  64. package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
  65. package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
  66. package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
  67. package/bundled/starter-docs/src/assets/docs.css +257 -0
  68. package/bundled/starter-docs/src/assets/docs.js +67 -0
  69. package/bundled/starter-docs/src/docs/docs.json +1 -0
  70. package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
  71. package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
  72. package/bundled/starter-docs/src/docs/index.md +29 -0
  73. package/bundled/starter-docs/src/docs/install.md +42 -0
  74. package/bundled/starter-docs/src/index.md +13 -0
  75. package/bundled/starter-docs/ssqch.config.js +40 -0
  76. package/bundled/trailheads/from-component-frameworks.md +116 -0
  77. package/bundled/trailheads/from-docusaurus.md +55 -0
  78. package/bundled/trailheads/from-eleventy.md +140 -0
  79. package/bundled/trailheads/from-hexo.md +92 -0
  80. package/bundled/trailheads/from-mkdocs.md +45 -0
  81. package/bundled/trailheads/from-zola.md +71 -0
  82. package/lib/assets.js +235 -3
  83. package/lib/chunk-37KSIVNY.js +29 -0
  84. package/lib/chunk-3GYLOC6Y.js +1017 -0
  85. package/lib/chunk-3NYSSA2C.js +22 -0
  86. package/lib/chunk-3PHCFZEU.js +209 -0
  87. package/lib/chunk-4Q6WMTER.js +32 -0
  88. package/lib/chunk-6XYSFG6V.js +4423 -0
  89. package/lib/chunk-6XYSFG6V.js.LEGAL.txt +41 -0
  90. package/lib/chunk-AD3HAW3W.js +10 -0
  91. package/lib/chunk-AMBFWPZ4.js +118 -0
  92. package/lib/chunk-BOBPVAX2.js +37088 -0
  93. package/lib/chunk-BOBPVAX2.js.LEGAL.txt +27 -0
  94. package/lib/chunk-BRK4MXXO.js +565 -0
  95. package/lib/chunk-C35KIPAR.js +247 -0
  96. package/lib/chunk-CDEPYU7W.js +25 -0
  97. package/lib/chunk-CMUWRPSQ.js +113 -0
  98. package/lib/chunk-DDV6JEC2.js +46 -0
  99. package/lib/chunk-DHHQKW4F.js +71 -0
  100. package/lib/chunk-EIT4ZDT4.js +1485 -0
  101. package/lib/chunk-EZZUUPI4.js +20 -0
  102. package/lib/chunk-F65YUXZ7.js +334 -0
  103. package/lib/chunk-FVZ5JBRI.js +115 -0
  104. package/lib/chunk-FYGE634X.js +44 -0
  105. package/lib/chunk-GOE4ZSAB.js +75 -0
  106. package/lib/chunk-GSKVRAHF.js +44 -0
  107. package/lib/chunk-HR2RU2LY.js +999 -0
  108. package/lib/chunk-HXCLCXRT.js +20 -0
  109. package/lib/chunk-I3PS26CI.js +48 -0
  110. package/lib/chunk-IAFM5ITE.js +11 -0
  111. package/lib/chunk-IRHRK7XB.js +54 -0
  112. package/lib/chunk-JRT7TQQP.js +57 -0
  113. package/lib/chunk-JSPSMIJ2.js +217 -0
  114. package/lib/chunk-KBGE5MCY.js +175 -0
  115. package/lib/chunk-N5QTGQ5N.js +207 -0
  116. package/lib/chunk-NKXEPHRZ.js +136 -0
  117. package/lib/chunk-NUKCUDC4.js +146 -0
  118. package/lib/chunk-RI2L3VGO.js +376 -0
  119. package/lib/chunk-TDGBQNGW.js +251 -0
  120. package/lib/chunk-TN6EEDX2.js +3935 -0
  121. package/lib/chunk-TWCVHOKO.js +1229 -0
  122. package/lib/chunk-UGEGUUBT.js +29 -0
  123. package/lib/chunk-UU43WIZG.js +29 -0
  124. package/lib/chunk-VJWQSYEG.js +119 -0
  125. package/lib/chunk-VVPZ5PDP.js +160 -0
  126. package/lib/chunk-WMOVCQO6.js +1287 -0
  127. package/lib/chunk-WP3RPVUM.js +211 -0
  128. package/lib/chunk-YSH2NMIE.js +502 -0
  129. package/lib/cli.js +540 -0
  130. package/lib/elements.js +180 -3
  131. package/lib/image.js +27 -3
  132. package/lib/links.js +464 -3
  133. package/lib/minify.js +69 -3
  134. package/lib/redirects.js +152 -3
  135. package/lib/rss.js +139 -3
  136. package/lib/sass.js +221 -3
  137. package/lib/sitemap.js +88 -3
  138. package/lib/ssqch.js +28 -0
  139. package/package.json +83 -80
  140. package/src/serve/live.js +174 -0
  141. package/src/serve/not-found.html +31 -0
  142. package/types/globals.d.ts +3 -2
  143. package/types/image.d.ts +7 -3
  144. package/types/index.d.ts +18 -5
  145. package/types/links.d.ts +1 -1
  146. package/types/minify.d.ts +1 -1
  147. package/types/rss.d.ts +1 -1
  148. package/types/sass.d.ts +1 -1
  149. package/wasm/markdown.wasm +0 -0
  150. package/wasm/minify.wasm +0 -0
  151. package/wasm/sass.wasm +0 -0
  152. package/lib/index.js +0 -3
  153. package/platforms.json +0 -6
package/lib/sitemap.js CHANGED
@@ -1,3 +1,88 @@
1
- // ssqch/sitemap is built into the ssqch binary, which runs ssqch.config.js and data files itself.
2
- // This file is here so editors and linters can find the module (its types are in ../types).
3
- throw new Error("ssqch/sitemap only works in files ssqch runs (ssqch.config.js, data files): build with ssqch, not node");
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ Options
5
+ } from "./chunk-JRT7TQQP.js";
6
+ import {
7
+ BUILTINS,
8
+ debugString,
9
+ escapeHtml,
10
+ isoDay
11
+ } from "./chunk-TN6EEDX2.js";
12
+ import "./chunk-IRHRK7XB.js";
13
+ import "./chunk-NKXEPHRZ.js";
14
+ import "./chunk-AD3HAW3W.js";
15
+ import "./chunk-DDV6JEC2.js";
16
+ import "./chunk-EIT4ZDT4.js";
17
+ import "./chunk-FVZ5JBRI.js";
18
+ import {
19
+ globSet
20
+ } from "./chunk-TDGBQNGW.js";
21
+ import "./chunk-UU43WIZG.js";
22
+ import "./chunk-C35KIPAR.js";
23
+ import "./chunk-CMUWRPSQ.js";
24
+ import {
25
+ bail,
26
+ toDate
27
+ } from "./chunk-6XYSFG6V.js";
28
+ import {
29
+ compareText
30
+ } from "./chunk-VJWQSYEG.js";
31
+ import "./chunk-I3PS26CI.js";
32
+
33
+ // src/modules/sitemap.ts
34
+ import path from "node:path";
35
+ function sitemapPlugin(options = {}) {
36
+ return { name: "ssqch/sitemap", builtin: "ssqch/sitemap", options };
37
+ }
38
+ function isLaterPage(data) {
39
+ const p = data.pagination;
40
+ const number = typeof p?.pageNumber === "number" ? p.pageNumber : 0;
41
+ const size = typeof p?.size === "number" ? p.size : 1;
42
+ return number > 0 && size > 1;
43
+ }
44
+ BUILTINS.set("ssqch/sitemap", (config, given) => {
45
+ const o = new Options(given, ["url", "exclude", "lastmod", "output", "paginated"]);
46
+ const url = o.string("url");
47
+ if (url === void 0) bail(`url is required: the site's address, like "https://example.com"`);
48
+ const exclude = o.list("exclude") ?? [];
49
+ const lastmod = o.bool("lastmod") ?? true;
50
+ const output = o.string("output") ?? "/sitemap.xml";
51
+ const paginated = o.bool("paginated") ?? false;
52
+ if (!(url.startsWith("https://") || url.startsWith("http://"))) bail(`url must be the site's address, like "https://example.com" (got ${debugString(url)})`);
53
+ if (!output.startsWith("/") || output.endsWith("/")) bail(`output must be a URL path to a file, like "/sitemap.xml" (got ${debugString(output)})`);
54
+ const matchers = exclude.map((glob) => {
55
+ if (!glob.startsWith("/")) bail(`exclude: ${debugString(glob)} must be a URL path or glob starting with /, like "/tags/**"`);
56
+ return globSet("exclude", [glob]);
57
+ });
58
+ const excluded = (url2) => matchers.some((m) => m(url2));
59
+ config.generators.push(["ssqch/sitemap", (config2, pages) => {
60
+ const trimmed = url.replace(/\/+$/, "");
61
+ const withBase = trimmed.endsWith(config2.base) ? trimmed : trimmed + config2.base;
62
+ const entries = [];
63
+ for (const p of pages) {
64
+ if (path.extname(p.outputPath) !== ".html") continue;
65
+ if (p.data.sitemap === false) continue;
66
+ if (!paginated && isLaterPage(p.data)) continue;
67
+ if (p.url === "/404.html" || p.url === "/404/") continue;
68
+ if (excluded(p.url)) continue;
69
+ entries.push([p.url, isoDay(toDate(p.data.page?.lastModified) ?? p.date)]);
70
+ }
71
+ entries.sort((a, b) => compareText(a[0], b[0]) || compareText(a[1], b[1]));
72
+ const loc = escapeHtml(withBase);
73
+ let xml = '<?xml version="1.0" encoding="utf-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n';
74
+ for (const [pageUrl, date] of entries) {
75
+ xml += ` <url>
76
+ <loc>${loc}${escapeHtml(pageUrl)}</loc>
77
+ `;
78
+ if (lastmod) xml += ` <lastmod>${date}</lastmod>
79
+ `;
80
+ xml += " </url>\n";
81
+ }
82
+ xml += "</urlset>\n";
83
+ return [{ path: output, contents: xml }];
84
+ }]);
85
+ });
86
+ export {
87
+ sitemapPlugin
88
+ };
package/lib/ssqch.js ADDED
@@ -0,0 +1,28 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ api_default,
5
+ defineConfig,
6
+ files,
7
+ markdown,
8
+ readData,
9
+ slugger,
10
+ slugify
11
+ } from "./chunk-EIT4ZDT4.js";
12
+ import "./chunk-FVZ5JBRI.js";
13
+ import "./chunk-TDGBQNGW.js";
14
+ import "./chunk-UU43WIZG.js";
15
+ import "./chunk-C35KIPAR.js";
16
+ import "./chunk-CMUWRPSQ.js";
17
+ import "./chunk-6XYSFG6V.js";
18
+ import "./chunk-VJWQSYEG.js";
19
+ import "./chunk-I3PS26CI.js";
20
+ export {
21
+ api_default as default,
22
+ defineConfig,
23
+ files,
24
+ markdown,
25
+ readData,
26
+ slugger,
27
+ slugify
28
+ };
package/package.json CHANGED
@@ -1,82 +1,85 @@
1
1
  {
2
- "name": "ssqch",
3
- "description": "SiteSquatch, a fast static site generator configured with JavaScript",
4
- "version": "0.7.0",
5
- "license": "MIT",
6
- "homepage": "https://github.com/reverentgeek/sitesquatch#readme",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/reverentgeek/sitesquatch.git"
10
- },
11
- "bugs": "https://github.com/reverentgeek/sitesquatch/issues",
12
- "keywords": [
13
- "static site generator",
14
- "ssg",
15
- "blog",
16
- "markdown",
17
- "jinja",
18
- "liquid"
19
- ],
20
- "bin": {
21
- "ssqch": "bin/ssqch.js"
22
- },
23
- "types": "./types/index.d.ts",
24
- "exports": {
25
- ".": {
26
- "types": "./types/index.d.ts",
27
- "default": "./lib/index.js"
28
- },
29
- "./image": {
30
- "types": "./types/image.d.ts",
31
- "default": "./lib/image.js"
32
- },
33
- "./rss": {
34
- "types": "./types/rss.d.ts",
35
- "default": "./lib/rss.js"
36
- },
37
- "./minify": {
38
- "types": "./types/minify.d.ts",
39
- "default": "./lib/minify.js"
40
- },
41
- "./assets": {
42
- "types": "./types/assets.d.ts",
43
- "default": "./lib/assets.js"
44
- },
45
- "./links": {
46
- "types": "./types/links.d.ts",
47
- "default": "./lib/links.js"
48
- },
49
- "./sitemap": {
50
- "types": "./types/sitemap.d.ts",
51
- "default": "./lib/sitemap.js"
52
- },
53
- "./elements": {
54
- "types": "./types/elements.d.ts",
55
- "default": "./lib/elements.js"
56
- },
57
- "./redirects": {
58
- "types": "./types/redirects.d.ts",
59
- "default": "./lib/redirects.js"
60
- },
61
- "./sass": {
62
- "types": "./types/sass.d.ts",
63
- "default": "./lib/sass.js"
64
- },
65
- "./package.json": "./package.json"
66
- },
67
- "files": [
68
- "bin",
69
- "lib",
70
- "types",
71
- "platforms.json"
72
- ],
73
- "engines": {
74
- "node": ">=18"
75
- },
76
- "optionalDependencies": {
77
- "@ssqch/darwin-arm64": "0.7.0",
78
- "@ssqch/darwin-x64": "0.7.0",
79
- "@ssqch/linux-x64": "0.7.0",
80
- "@ssqch/win32-x64": "0.7.0"
81
- }
2
+ "name": "ssqch",
3
+ "version": "0.8.0",
4
+ "description": "SiteSquatch (ssqch): a fast static site generator, configured with JavaScript",
5
+ "keywords": [
6
+ "static site generator",
7
+ "ssg",
8
+ "blog",
9
+ "markdown",
10
+ "jinja",
11
+ "nunjucks",
12
+ "liquid",
13
+ "edge"
14
+ ],
15
+ "homepage": "https://github.com/reverentgeek/sitesquatch#readme",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/reverentgeek/sitesquatch.git",
19
+ "directory": "packages/ssqch"
20
+ },
21
+ "bugs": "https://github.com/reverentgeek/sitesquatch/issues",
22
+ "license": "MIT",
23
+ "type": "module",
24
+ "bin": {
25
+ "ssqch": "bin/ssqch.js"
26
+ },
27
+ "types": "./types/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./types/index.d.ts",
31
+ "default": "./lib/ssqch.js"
32
+ },
33
+ "./image": {
34
+ "types": "./types/image.d.ts",
35
+ "default": "./lib/image.js"
36
+ },
37
+ "./rss": {
38
+ "types": "./types/rss.d.ts",
39
+ "default": "./lib/rss.js"
40
+ },
41
+ "./minify": {
42
+ "types": "./types/minify.d.ts",
43
+ "default": "./lib/minify.js"
44
+ },
45
+ "./assets": {
46
+ "types": "./types/assets.d.ts",
47
+ "default": "./lib/assets.js"
48
+ },
49
+ "./links": {
50
+ "types": "./types/links.d.ts",
51
+ "default": "./lib/links.js"
52
+ },
53
+ "./sitemap": {
54
+ "types": "./types/sitemap.d.ts",
55
+ "default": "./lib/sitemap.js"
56
+ },
57
+ "./elements": {
58
+ "types": "./types/elements.d.ts",
59
+ "default": "./lib/elements.js"
60
+ },
61
+ "./redirects": {
62
+ "types": "./types/redirects.d.ts",
63
+ "default": "./lib/redirects.js"
64
+ },
65
+ "./sass": {
66
+ "types": "./types/sass.d.ts",
67
+ "default": "./lib/sass.js"
68
+ },
69
+ "./package.json": "./package.json"
70
+ },
71
+ "files": [
72
+ "bin",
73
+ "lib",
74
+ "src",
75
+ "types",
76
+ "wasm",
77
+ "bundled"
78
+ ],
79
+ "engines": {
80
+ "node": ">=22.18"
81
+ },
82
+ "dependencies": {
83
+ "sharp": "0.35.5"
84
+ }
82
85
  }
@@ -0,0 +1,174 @@
1
+ (() => {
2
+ // What `ssqch serve` adds to each page it sends: it asks the server what changed,
3
+ // and reloads, swaps a stylesheet or shows a build error. It's never written to the output.
4
+ let seen;
5
+ let panel;
6
+ let icon;
7
+ let hidden;
8
+ // Where the keyboard was before the overlay took it, to give it back.
9
+ let before;
10
+ const title = document.title;
11
+ const hide = () => {
12
+ hidden = panel.shadowRoot.querySelector("pre").textContent;
13
+ show(hidden);
14
+ };
15
+ const escape = event => {
16
+ if (event.key === "Escape" && panel) hide();
17
+ };
18
+ const show = error => {
19
+ if (!error || error === hidden) {
20
+ if (panel) {
21
+ const had = panel.shadowRoot.activeElement || document.activeElement === panel;
22
+ panel.remove();
23
+ icon.remove();
24
+ panel = icon = null;
25
+ document.title = title;
26
+ document.removeEventListener("keydown", escape);
27
+ if (had && before?.isConnected) before.focus();
28
+ before = null;
29
+ }
30
+ if (!error) hidden = null;
31
+ return;
32
+ }
33
+ if (!panel) {
34
+ panel = document.createElement("div");
35
+ panel.attachShadow({ mode: "open" }).innerHTML = `<style>
36
+ section { position: fixed; inset: 0; z-index: 2147483647; overflow: auto; box-sizing: border-box; padding: 2rem 1rem; background: rgba(27, 32, 29, 0.97); color: #e5e9e1; font: 16px/1.5 system-ui, sans-serif; }
37
+ div { max-width: 60rem; margin: 0 auto; }
38
+ h1 { margin: 0 0 0.25rem; font-size: 1.4rem; color: #f0a17d; }
39
+ p { margin: 0 0 1rem; color: #a2aca3; }
40
+ pre { margin: 0 0 1rem; padding: 1rem; border-left: 5px solid #e8af43; background: #252b27; color: #e5e9e1; font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
41
+ section:focus { outline: none; }
42
+ button { margin-right: 0.5rem; padding: 0.35rem 0.9rem; border: 0; border-radius: 4px; background: #a23e20; color: #fafaf7; font: inherit; cursor: pointer; }
43
+ button:focus-visible { outline: 3px solid #e8af43; outline-offset: 2px; }
44
+ small { margin-left: 0.25rem; color: #a2aca3; }
45
+ </style><section role="alert" aria-labelledby="ssqch-title" tabindex="-1"><div><h1 id="ssqch-title">Build failed</h1><p>This page is from the last build that worked. Fix the error and this goes away.</p><pre></pre><button type="button" data-copy>Copy diagnostic</button><button type="button" data-hide>Hide</button><small>Escape hides it. Squatch Watch (ssqch serve)</small></div></section>`;
46
+ const root = panel.shadowRoot;
47
+ const copy = root.querySelector("[data-copy]");
48
+ copy.addEventListener("click", async () => {
49
+ const text = root.querySelector("pre").textContent;
50
+ try {
51
+ await navigator.clipboard.writeText(text);
52
+ copy.textContent = "Copied";
53
+ } catch {
54
+ // No clipboard (a page served over plain HTTP to another device): select it to copy by hand.
55
+ const range = document.createRange();
56
+ range.selectNodeContents(root.querySelector("pre"));
57
+ getSelection().removeAllRanges();
58
+ getSelection().addRange(range);
59
+ copy.textContent = "Selected: copy it with your keyboard";
60
+ }
61
+ setTimeout(() => {
62
+ copy.textContent = "Copy diagnostic";
63
+ }, 2000);
64
+ });
65
+ root.querySelector("[data-hide]").addEventListener("click", hide);
66
+ document.addEventListener("keydown", escape);
67
+ document.body.append(panel);
68
+ // The keyboard goes to the overlay (Tab reaches its buttons), and comes back when it goes.
69
+ before = document.activeElement;
70
+ root.querySelector("section").focus({ preventScroll: true });
71
+ icon = document.createElement("link");
72
+ icon.rel = "icon";
73
+ icon.href = "/__ssqch/favicon-error.svg";
74
+ document.head.append(icon);
75
+ document.title = `[build failed] ${title}`;
76
+ }
77
+ panel.shadowRoot.querySelector("pre").textContent = error;
78
+ };
79
+ // Stylesheets and scripts the page links that aren't in the output: a note in the corner (the
80
+ // page is there, just unstyled or without its script), and the server says so in the terminal.
81
+ let note;
82
+ let missing = new Map();
83
+ const assets = () => [...document.querySelectorAll('link[rel~="stylesheet"][href], script[src]')]
84
+ .map(el => new URL(el.getAttribute("href") ?? el.getAttribute("src"), location.href))
85
+ .filter(url => url.origin === location.origin && !url.pathname.startsWith("/__ssqch/"))
86
+ .map(url => url.pathname);
87
+ const notice = () => {
88
+ if (!missing.size) {
89
+ note?.remove();
90
+ note = null;
91
+ return;
92
+ }
93
+ if (!note) {
94
+ note = document.createElement("div");
95
+ note.attachShadow({ mode: "open" }).innerHTML = `<style>
96
+ aside { position: fixed; right: 1rem; bottom: 1rem; z-index: 2147483646; max-width: 32rem; box-sizing: border-box; padding: 0.75rem 1rem; border-left: 5px solid #e8af43; background: #1b201d; color: #e5e9e1; font: 14px/1.5 system-ui, sans-serif; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); }
97
+ strong { display: block; color: #f0a17d; }
98
+ p { margin: 0.35rem 0 0; overflow-wrap: anywhere; }
99
+ button { margin-top: 0.5rem; padding: 0.2rem 0.7rem; border: 0; border-radius: 4px; background: #a23e20; color: #fafaf7; font: inherit; cursor: pointer; }
100
+ </style><aside role="status"><strong>Missing from the output</strong><div></div><button type="button">Hide</button></aside>`;
101
+ note.shadowRoot.querySelector("button").addEventListener("click", () => note.remove());
102
+ document.body.append(note);
103
+ }
104
+ const list = note.shadowRoot.querySelector("div");
105
+ list.replaceChildren(...[...missing.values()].map(message => Object.assign(document.createElement("p"), { textContent: message })));
106
+ };
107
+ const check = async paths => {
108
+ for (const path of paths) {
109
+ try {
110
+ const found = (await fetch(path, { method: "HEAD", cache: "no-store" })).ok;
111
+ if (found) {
112
+ missing.delete(path);
113
+ continue;
114
+ }
115
+ const { message } = await (await fetch(`/__ssqch/missing?path=${encodeURIComponent(path)}`)).json();
116
+ if (message) missing.set(path, message);
117
+ else missing.delete(path);
118
+ } catch {}
119
+ }
120
+ notice();
121
+ };
122
+ check(assets());
123
+ // A changed stylesheet is fetched again in place: the page keeps its scroll position and its forms.
124
+ // The new one loads next to the old, which goes once it's there, so the page is never unstyled
125
+ // in between. One that doesn't load, or comes back empty where the old one had rules (a tool
126
+ // still writing it), leaves the old one in place and is tried again.
127
+ const loading = new Map();
128
+ const rules = link => {
129
+ try {
130
+ return link.sheet?.cssRules.length ?? 0;
131
+ } catch {
132
+ return 1;
133
+ }
134
+ };
135
+ const swap = (path, id, tries = 0) => {
136
+ const replacements = new Set(loading.values());
137
+ for (const link of document.querySelectorAll('link[rel~="stylesheet"]')) {
138
+ const url = new URL(link.href, location.href);
139
+ if (replacements.has(link) || url.origin !== location.origin || url.pathname !== path) continue;
140
+ url.searchParams.set("ssqch", tries ? `${id}.${tries}` : id);
141
+ // A newer change replaces one still loading.
142
+ loading.get(link)?.remove();
143
+ const next = link.cloneNode();
144
+ next.href = url.href;
145
+ const done = ok => {
146
+ if (loading.get(link) !== next) return;
147
+ loading.delete(link);
148
+ (ok ? link : next).remove();
149
+ if (!ok && tries < 5) setTimeout(() => swap(path, id, tries + 1), 300);
150
+ };
151
+ next.addEventListener("load", () => done(rules(next) > 0 || rules(link) === 0), { once: true });
152
+ next.addEventListener("error", () => done(false), { once: true });
153
+ loading.set(link, next);
154
+ link.after(next);
155
+ }
156
+ };
157
+ setInterval(async () => {
158
+ try {
159
+ const now = await (await fetch(`/__ssqch/build?v=${seen ?? ""}&p=${encodeURIComponent(location.pathname)}`)).json();
160
+ show(now.error);
161
+ if (seen !== undefined && now.id !== seen && !now.error) {
162
+ if (now.reload) {
163
+ console.log("[ssqch] Fresh tracks. Reloading.");
164
+ location.reload();
165
+ return;
166
+ }
167
+ for (const path of now.css) swap(path, now.id);
168
+ // A file that was missing may be there now.
169
+ if (missing.size) check([...missing.keys()]);
170
+ }
171
+ seen = now.id;
172
+ } catch {}
173
+ }, 700);
174
+ })();
@@ -0,0 +1,31 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Page not found</title>
7
+ <style>
8
+ /* Ranger Station '76: soft white (or green charcoal), neutral text, pine headings, burnt orange links. */
9
+ :root { color-scheme: light dark; --ink: #29332c; --heading: #233b2b; --soft: #5e6a61; --paper: #fafaf7; --link: #a23e20; --gold: #e8af43; }
10
+ @media (prefers-color-scheme: dark) { :root { --ink: #e5e9e1; --heading: #d6e4c8; --soft: #a2aca3; --paper: #1b201d; --link: #f0a17d; } }
11
+ body { margin: 0; min-height: 100vh; display: grid; place-items: center; background: var(--paper); color: var(--ink); font: 1rem/1.6 system-ui, sans-serif; }
12
+ main { max-width: 32rem; padding: 2rem 1rem; text-align: center; }
13
+ svg { width: 9rem; height: auto; }
14
+ h1 { font-size: 1.5rem; margin: 1rem 0 0.5rem; color: var(--heading); }
15
+ code { font-size: 0.95em; overflow-wrap: anywhere; }
16
+ a { color: var(--link); text-decoration: underline; text-underline-offset: 0.18em; }
17
+ h1::after { content: ""; display: block; width: 4rem; height: 4px; margin: 0.6rem auto 0; background: var(--gold); }
18
+ small { display: block; margin-top: 2rem; color: var(--soft); }
19
+ </style>
20
+ </head>
21
+ <body>
22
+ <main>
23
+ {{patch}}
24
+ <h1>Page not found</h1>
25
+ <p>The trail goes cold at <code>{{url}}</code>. We have several eyewitness accounts of this page, but no page.</p>
26
+ {{suggestion}}
27
+ <p><a href="{{home}}">Back to the trailhead</a></p>
28
+ <small>From <code>ssqch serve</code>, because this site has no <code>404.html</code>. Add a page with <code>permalink: /404.html</code> to make your own.</small>
29
+ </main>
30
+ </body>
31
+ </html>
@@ -2,8 +2,9 @@
2
2
  // Written by `ssqch types`. Editors use them for autocomplete and checking;
3
3
  // the build doesn't read them. Regenerate after upgrading ssqch.
4
4
 
5
- // The parts of Node's `process` that ssqch provides to configs and data files. Declared
6
- // the way @types/node declares it, so a project that installs those types gets theirs too.
5
+ // A config and its data files run on Node, so `process` is Node's own. These are the parts
6
+ // they most often use, declared the way @types/node declares them, so a project that installs
7
+ // those types gets theirs too.
7
8
  declare namespace NodeJS {
8
9
  interface ProcessEnv {
9
10
  /** The build's environment (`--env`): `"production"` for `ssqch build`, `"development"` for `ssqch serve`. */
package/types/image.d.ts CHANGED
@@ -17,11 +17,15 @@ export interface ImagePluginOptions {
17
17
  outputDir?: string;
18
18
  /** URL path they're served from. Default `/img/`. */
19
19
  urlPath?: string;
20
+ /** WebP quality, sharp's: a whole number from 1 to 100. Default 75 (0.7's 75 too: WebP's numbers didn't change). */
20
21
  webpQuality?: number;
22
+ /** AVIF quality, sharp's: a whole number from 1 to 100. Default 41, which looks like 0.7's default of 50 (0.7's 60 is 48; the changelog has the table). */
21
23
  avifQuality?: number;
22
- /** 1 (slowest, smallest) to 10 (fastest). Default 8. */
23
- avifSpeed?: number;
24
+ /** sharp's AVIF effort: a whole number from 0 (fastest) to 9 (slowest, smallest files). Default 2. Replaces 0.7's `avifSpeed`: speed 8 is effort 2, speed 4 is effort 3. */
25
+ avifEffort?: number;
26
+ /** JPEG quality, sharp's (mozjpeg): a whole number from 1 to 100. Default 89, which looks like 0.7's default of 80. */
24
27
  jpegQuality?: number;
28
+ /** A width larger than the original is clamped to it only when the width before it is this many times smaller. Default 1.25. */
25
29
  minimumThreshold?: number;
26
30
  /** Delete generated images the build didn't use. Only for full builds. */
27
31
  prune?: boolean;
@@ -48,7 +52,7 @@ export interface ImageEntry {
48
52
  size: number;
49
53
  }
50
54
 
51
- /** Turns every local `<img>` in HTML output into a `<picture>`. */
55
+ /** Turns every local `<img>` in HTML output into a `<picture>`, encoded by sharp (AVIF needs no build feature). `[ssqch] Encoded ...` lines come as each image's files are done, while pages go on rendering. */
52
56
  export function imagePlugin(options?: ImagePluginOptions): BuiltinPlugin;
53
57
 
54
58
  /** Generate one image's files with the plugin's settings and cache. Keyed by format, smallest first; with `"auto"` in `formats`, its files are under `auto` too. */
package/types/index.d.ts CHANGED
@@ -141,6 +141,18 @@ export interface BuiltinPlugin {
141
141
  options?: Record<string, unknown>;
142
142
  }
143
143
 
144
+ /** A plugin written in Rust: one `.wasm` file built with the `ssqch-plugin` crate, which ssqch runs in Node's WebAssembly on every platform. An npm package's default export returns this: `export default (options) => ({ name: "hello", rust: { wasm: fileURLToPath(new URL("./hello.wasm", import.meta.url)), options } })`. Its transform, filters and engines come from the manifest inside the file, so none are listed here; a name the config already uses is an error, and so is a file built for another plugin ABI. */
145
+ export interface RustPlugin {
146
+ /** Shows up in error messages. */
147
+ name: string;
148
+ rust: {
149
+ /** The absolute path to the plugin's `.wasm` file. */
150
+ wasm: string;
151
+ /** The plugin's options, as JSON. The plugin checks them when the config loads (an unknown or misspelled option fails the build, and says which fields it has). */
152
+ options?: unknown;
153
+ };
154
+ }
155
+
144
156
  /** Everything a plugin can add. The config itself can set these too. */
145
157
  export interface ConfigParts {
146
158
  /** Shows up in error messages. */
@@ -163,14 +175,15 @@ export interface ConfigParts {
163
175
  beforeBuild?: Hook | Hook[];
164
176
  /** Run after each build, with `written` (the files the build wrote). */
165
177
  afterBuild?: Hook | Hook[];
166
- /** More config, from plugins. `false`, `null` and `undefined` are skipped. */
178
+ /** More config, from plugins. A plugin is an object with any of these keys, a function that returns one, a built-in plugin (`imagePlugin()`), and plugins written in Rust (`{ name, rust: { wasm, options } }`). `false`, `null` and `undefined` are skipped. */
167
179
  plugins?: Plugin[];
168
180
  }
169
181
 
170
182
  export type Plugin =
171
183
  | ConfigParts
172
184
  | BuiltinPlugin
173
- | ((context: ConfigContext) => MaybePromise<ConfigParts | BuiltinPlugin | false | null | undefined>)
185
+ | RustPlugin
186
+ | ((context: ConfigContext) => MaybePromise<ConfigParts | BuiltinPlugin | RustPlugin | false | null | undefined>)
174
187
  | false
175
188
  | null
176
189
  | undefined;
@@ -217,7 +230,7 @@ export interface Config extends ConfigParts {
217
230
  schemas?: Record<string, Schema>;
218
231
  /** Size budgets by kind of file, checked after each build: a file over its kind's budget is an `over-budget` warning. Sizes are bytes or strings like `"150 KB"` and `"1.5 MB"` (powers of 1,000). */
219
232
  budgets?: Partial<Record<"pages" | "images" | "css" | "javascript" | "fonts" | "media" | "documents" | "data" | "other" | "total", number | string>>;
220
- /** What `ssqch serve` runs besides the server. */
233
+ /** What `ssqch serve` runs besides the server. (The server builds in a process of its own, starts it again when the config or a module it imports changes, and listens on 127.0.0.1 only.) */
221
234
  serve?: {
222
235
  /** Programs to start with the server and stop with it, like the watchers of your CSS and JavaScript tools: `["npx postcss src/app.css -o dist/app.css --watch"]`. Their output is shown with the tool's name in front. Builds don't run them. */
223
236
  run?: string | string[];
@@ -248,9 +261,9 @@ export interface FoundFile {
248
261
  dateFrom: "name" | "modified";
249
262
  /** Bytes. */
250
263
  size: number;
251
- /** Pixels, with `{ dimensions: true }`; `null` for a file that isn't an image ssqch can read the size of. */
264
+ /** Pixels, with `{ dimensions: true }`; `null` for a file whose size ssqch can't read (it reads PNG, JPEG, GIF, TIFF, WebP, HEIF, AVIF, BMP, PSD, ICO and QOI). */
252
265
  width?: number | null;
253
- /** Pixels, with `{ dimensions: true }`; `null` for a file that isn't an image ssqch can read the size of. */
266
+ /** Pixels, with `{ dimensions: true }`; `null` for a file whose size ssqch can't read (it reads PNG, JPEG, GIF, TIFF, WebP, HEIF, AVIF, BMP, PSD, ICO and QOI). */
254
267
  height?: number | null;
255
268
  }
256
269
  /** The files a glob matches, from the project root and ignoring case, sorted by path, as data: `files("images/albums/v1/*.{jpg,png}")`. `{ dimensions: true }` reads each image's width and height from its header, once: they're kept in `.cache/ssqch/image-sizes.json` until the file changes. No match is an empty list. */
package/types/links.d.ts CHANGED
@@ -7,7 +7,7 @@ export interface LinksPluginOptions {
7
7
  anchors?: boolean;
8
8
  /** URL path prefixes to skip, like `["/downloads/"]`. */
9
9
  ignore?: string[];
10
- /** Fail the build on a broken link. Default: production builds only. */
10
+ /** Fail the build on a broken link. Default: production builds only. A build lists the first 20 broken links; `--verbose` lists them all. */
11
11
  fail?: boolean;
12
12
  /** The site's address, like `"https://example.com"`, so absolute links to it are checked too. Default: the address `sitemap.xml` uses. */
13
13
  url?: string;
package/types/minify.d.ts CHANGED
@@ -13,7 +13,7 @@ export interface MinifyOptions {
13
13
  shortenAttributes?: boolean;
14
14
  }
15
15
 
16
- /** Minifies HTML output, after the image transform. */
16
+ /** Minifies HTML output, after the image transform, with ssqch's own minifier (Rust, as WebAssembly): it doesn't write html-minifier-terser's bytes. */
17
17
  export function minifyPlugin(options?: MinifyOptions): BuiltinPlugin;
18
18
  /** Minify one string of HTML, with the plugin's options. */
19
19
  export function minify(html: string, options?: MinifyOptions): string;
package/types/rss.d.ts CHANGED
@@ -14,5 +14,5 @@ export function dateToRfc822(date: Date | string): string;
14
14
  export function absoluteUrl(url: string, base: string): string;
15
15
  /** Every link and image in some HTML made absolute, for a feed's content. */
16
16
  export function htmlToAbsoluteUrls(html: string, base: string): string;
17
- /** A post's HTML for a feed: each local image points at one generated copy (`width` 1200 and the source's format by default), page-only attributes go, and every URL is made absolute against `base`, the post's address. */
17
+ /** A post's HTML for a feed: each local image points at one generated copy (`width` 1200 and the source's format by default), page-only attributes go, and every URL is made absolute against `base`, the post's address. The images are made by the image plugin, so the config needs `imagePlugin()` too. */
18
18
  export function feedHtml(html: string, base: string, options?: { width?: number | "auto"; format?: string }): string;
package/types/sass.d.ts CHANGED
@@ -11,5 +11,5 @@ export interface SassPluginOptions {
11
11
  loadPaths?: string[];
12
12
  }
13
13
 
14
- /** Compiles Sass at the start of each build, so fingerprinting and the link checker see the CSS. */
14
+ /** Compiles Sass at the start of each build, with grass (Rust, as WebAssembly: no Dart Sass), so fingerprinting and the link checker see the CSS. */
15
15
  export function sassPlugin(options: SassPluginOptions): BuiltinPlugin;
Binary file
Binary file
package/wasm/sass.wasm ADDED
Binary file
package/lib/index.js DELETED
@@ -1,3 +0,0 @@
1
- // ssqch is built into the ssqch binary, which runs ssqch.config.js and data files itself.
2
- // This file is here so editors and linters can find the module (its types are in ../types).
3
- throw new Error("ssqch only works in files ssqch runs (ssqch.config.js, data files): build with ssqch, not node");