ssqch 0.7.1 → 0.9.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/README.md +8 -4
- package/bin/ssqch.js +14 -48
- package/bundled/README.md +1314 -0
- package/bundled/completions/bash +840 -0
- package/bundled/completions/elvish +286 -0
- package/bundled/completions/fish +182 -0
- package/bundled/completions/powershell +318 -0
- package/bundled/completions/zsh +510 -0
- package/bundled/ssqch.d.ts +540 -0
- package/bundled/starter/engines/index.edge +11 -0
- package/bundled/starter/engines/index.ejs +11 -0
- package/bundled/starter/engines/index.hbs +11 -0
- package/bundled/starter/engines/index.liquid +11 -0
- package/bundled/starter/engines/layout.edge +35 -0
- package/bundled/starter/engines/layout.ejs +35 -0
- package/bundled/starter/engines/layout.hbs +35 -0
- package/bundled/starter/engines/layout.liquid +35 -0
- package/bundled/starter/gitignore +3 -0
- package/bundled/starter/jsconfig.json +11 -0
- package/bundled/starter/src/404.md +8 -0
- package/bundled/starter/src/_blueprints/posts.md +5 -0
- package/bundled/starter/src/_data/site.json +4 -0
- package/bundled/starter/src/_includes/layout.jinja +35 -0
- package/bundled/starter/src/index.jinja +11 -0
- package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
- package/bundled/starter/src/posts/posts.json +4 -0
- package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
- package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
- package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
- package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
- package/bundled/starter/ssqch.config.js +29 -0
- package/bundled/starter-docs/engines/edge/base.edge +41 -0
- package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
- package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
- package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
- package/bundled/starter-docs/engines/edge/doc.edge +59 -0
- package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
- package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
- package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
- package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
- package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
- package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
- package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
- package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
- package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
- package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
- package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
- package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
- package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
- package/bundled/starter-docs/gitignore +4 -0
- package/bundled/starter-docs/src/404.md +12 -0
- package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
- package/bundled/starter-docs/src/_data/nav.yml +10 -0
- package/bundled/starter-docs/src/_data/site.json +5 -0
- package/bundled/starter-docs/src/_includes/base.jinja +41 -0
- package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
- package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
- package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
- package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
- package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
- package/bundled/starter-docs/src/assets/docs.css +257 -0
- package/bundled/starter-docs/src/assets/docs.js +67 -0
- package/bundled/starter-docs/src/docs/docs.json +1 -0
- package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
- package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
- package/bundled/starter-docs/src/docs/index.md +29 -0
- package/bundled/starter-docs/src/docs/install.md +42 -0
- package/bundled/starter-docs/src/index.md +13 -0
- package/bundled/starter-docs/ssqch.config.js +40 -0
- package/bundled/trailheads/from-component-frameworks.md +116 -0
- package/bundled/trailheads/from-docusaurus.md +55 -0
- package/bundled/trailheads/from-eleventy.md +140 -0
- package/bundled/trailheads/from-hexo.md +92 -0
- package/bundled/trailheads/from-jekyll.md +79 -0
- package/bundled/trailheads/from-mkdocs.md +45 -0
- package/bundled/trailheads/from-zola.md +71 -0
- package/lib/assets.js +235 -3
- package/lib/chunk-3A647I3N.js +384 -0
- package/lib/chunk-3GYLOC6Y.js +1017 -0
- package/lib/chunk-3K3ANWZ2.js +118 -0
- package/lib/chunk-3NYSSA2C.js +22 -0
- package/lib/chunk-47P4YREZ.js +1287 -0
- package/lib/chunk-4Q6WMTER.js +32 -0
- package/lib/chunk-76NTVE34.js +338 -0
- package/lib/chunk-7PWCYHTJ.js +1350 -0
- package/lib/chunk-7RDRZHJD.js +217 -0
- package/lib/chunk-7SD7K567.js +57 -0
- package/lib/chunk-7XLK2GEG.js +54 -0
- package/lib/chunk-AD3HAW3W.js +10 -0
- package/lib/chunk-BEGC7YP6.js +502 -0
- package/lib/chunk-CMUWRPSQ.js +113 -0
- package/lib/chunk-CZ4XQC56.js +999 -0
- package/lib/chunk-D2XE2GTY.js +71 -0
- package/lib/chunk-DDV6JEC2.js +46 -0
- package/lib/chunk-DELWRJAO.js +37409 -0
- package/lib/chunk-DELWRJAO.js.LEGAL.txt +27 -0
- package/lib/chunk-F65YUXZ7.js +334 -0
- package/lib/chunk-FVZ5JBRI.js +115 -0
- package/lib/chunk-GRWMGC7D.js +4435 -0
- package/lib/chunk-GRWMGC7D.js.LEGAL.txt +41 -0
- package/lib/chunk-GUKSZ2XM.js +207 -0
- package/lib/chunk-HPXAZ2HU.js +251 -0
- package/lib/chunk-HXCLCXRT.js +20 -0
- package/lib/chunk-I3PS26CI.js +48 -0
- package/lib/chunk-IAFM5ITE.js +11 -0
- package/lib/chunk-II5DEH3Q.js +209 -0
- package/lib/chunk-IJWHOFRP.js +44 -0
- package/lib/chunk-LPHNACE4.js +29 -0
- package/lib/chunk-MI6EJWA2.js +175 -0
- package/lib/chunk-NCWFYT74.js +1541 -0
- package/lib/chunk-NKXEPHRZ.js +136 -0
- package/lib/chunk-NNUKIGOO.js +160 -0
- package/lib/chunk-R7K3D5W5.js +3957 -0
- package/lib/chunk-RNJFPFXE.js +29 -0
- package/lib/chunk-SF4I6Z7S.js +25 -0
- package/lib/chunk-SURPOAW7.js +44 -0
- package/lib/chunk-SXMJ52IK.js +572 -0
- package/lib/chunk-TICWN55Z.js +20 -0
- package/lib/chunk-TVU3OPPK.js +146 -0
- package/lib/chunk-UU43WIZG.js +29 -0
- package/lib/chunk-VJWQSYEG.js +119 -0
- package/lib/chunk-XMXBHXZR.js +75 -0
- package/lib/chunk-YTHQBMDJ.js +211 -0
- package/lib/cli.js +547 -0
- package/lib/elements.js +180 -3
- package/lib/image.js +27 -3
- package/lib/links.js +464 -3
- package/lib/minify.js +69 -3
- package/lib/redirects.js +152 -3
- package/lib/rss.js +139 -3
- package/lib/sass.js +256 -3
- package/lib/sitemap.js +113 -3
- package/lib/ssqch.js +28 -0
- package/package.json +83 -80
- package/src/serve/live.js +174 -0
- package/src/serve/not-found.html +31 -0
- package/types/globals.d.ts +3 -2
- package/types/image.d.ts +7 -3
- package/types/index.d.ts +28 -9
- package/types/links.d.ts +1 -1
- package/types/minify.d.ts +1 -1
- package/types/rss.d.ts +1 -1
- package/types/sass.d.ts +1 -1
- package/types/sitemap.d.ts +2 -0
- package/wasm/markdown.wasm +0 -0
- package/wasm/minify.wasm +0 -0
- package/wasm/sass.wasm +0 -0
- package/lib/index.js +0 -3
- package/platforms.json +0 -6
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
BUDGETS
|
|
5
|
+
} from "./chunk-7XLK2GEG.js";
|
|
6
|
+
import {
|
|
7
|
+
bytes,
|
|
8
|
+
count,
|
|
9
|
+
fixed
|
|
10
|
+
} from "./chunk-NKXEPHRZ.js";
|
|
11
|
+
import {
|
|
12
|
+
padEnd,
|
|
13
|
+
padStart
|
|
14
|
+
} from "./chunk-CMUWRPSQ.js";
|
|
15
|
+
import {
|
|
16
|
+
BuildError,
|
|
17
|
+
bail,
|
|
18
|
+
warning
|
|
19
|
+
} from "./chunk-GRWMGC7D.js";
|
|
20
|
+
import {
|
|
21
|
+
compareText,
|
|
22
|
+
realPath
|
|
23
|
+
} from "./chunk-VJWQSYEG.js";
|
|
24
|
+
|
|
25
|
+
// src/footprint.ts
|
|
26
|
+
import fs from "node:fs";
|
|
27
|
+
import path from "node:path";
|
|
28
|
+
var KINDS = [
|
|
29
|
+
["Pages", ["html", "htm"]],
|
|
30
|
+
["Images", ["avif", "webp", "jpg", "jpeg", "png", "gif", "svg", "ico", "bmp", "tif", "tiff", "jxl"]],
|
|
31
|
+
["CSS", ["css"]],
|
|
32
|
+
["JavaScript", ["js", "mjs", "cjs", "wasm"]],
|
|
33
|
+
["Fonts", ["woff2", "woff", "ttf", "otf", "eot"]],
|
|
34
|
+
["Media", ["mp4", "webm", "mov", "mp3", "ogg", "wav", "m4a", "flac"]],
|
|
35
|
+
["Documents", ["pdf", "zip", "epub"]],
|
|
36
|
+
["Data and feeds", ["xml", "json", "txt", "webmanifest", "csv", "map", "rss", "atom"]]
|
|
37
|
+
];
|
|
38
|
+
var OTHER = "Other";
|
|
39
|
+
var KIND_OF_EXTENSION = new Map(KINDS.flatMap(([name, exts]) => exts.map((ext) => [ext, name])));
|
|
40
|
+
function kindOf(file) {
|
|
41
|
+
const dot = file.lastIndexOf(".");
|
|
42
|
+
return dot === -1 ? OTHER : KIND_OF_EXTENSION.get(asciiLower(file.slice(dot + 1))) ?? OTHER;
|
|
43
|
+
}
|
|
44
|
+
var asciiLower = (text) => text.replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
45
|
+
function urlOf(file) {
|
|
46
|
+
if (file.endsWith("index.html")) {
|
|
47
|
+
const dir = file.slice(0, -10);
|
|
48
|
+
if (dir === "" || dir.endsWith("/")) return `/${dir}`;
|
|
49
|
+
}
|
|
50
|
+
return `/${file}`;
|
|
51
|
+
}
|
|
52
|
+
var AT_ONCE = 32;
|
|
53
|
+
function buildFiles(dir, sizes) {
|
|
54
|
+
const out = [];
|
|
55
|
+
const folders = [{ path: dir, rel: "", real: realPath(dir), parent: void 0 }];
|
|
56
|
+
const files = [];
|
|
57
|
+
let active = 0;
|
|
58
|
+
const failures = [];
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const fail = (at, detail) => {
|
|
61
|
+
failures.push([at, `reading ${dir}: ${detail}`]);
|
|
62
|
+
};
|
|
63
|
+
const inside = (folder, name) => folder.parent === void 0 && /[\\/]$/.test(folder.path) ? folder.path + name : folder.path + path.sep + name;
|
|
64
|
+
const done = () => {
|
|
65
|
+
active--;
|
|
66
|
+
pump();
|
|
67
|
+
};
|
|
68
|
+
const read = (folder) => {
|
|
69
|
+
fs.readdir(folder.path, { withFileTypes: true }, (e, entries) => {
|
|
70
|
+
if (e) fail(folder.path, `IO error for operation on ${folder.path}: ${e.message}`);
|
|
71
|
+
else for (const entry of entries) {
|
|
72
|
+
const file = inside(folder, entry.name);
|
|
73
|
+
const rel = folder.rel === "" ? entry.name : `${folder.rel}/${entry.name}`;
|
|
74
|
+
let isDir = entry.isDirectory(), isFile = entry.isFile();
|
|
75
|
+
if (entry.isSymbolicLink()) {
|
|
76
|
+
const stat = fs.statSync(file, { throwIfNoEntry: false });
|
|
77
|
+
if (!stat) {
|
|
78
|
+
fail(file, `IO error for operation on ${file}: No such file or directory (os error 2): No such file or directory (os error 2)`);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
[isDir, isFile] = [stat.isDirectory(), stat.isFile()];
|
|
82
|
+
if (isDir) {
|
|
83
|
+
const real = realPath(file);
|
|
84
|
+
let loop = folder;
|
|
85
|
+
while (loop && loop.real !== real) loop = loop.parent;
|
|
86
|
+
if (loop) {
|
|
87
|
+
fail(file, `File system loop found: ${file} points to an ancestor ${loop.path}`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
folders.push({ path: file, rel, real, parent: folder });
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (isDir) folders.push({ path: file, rel, real: folder.real + path.sep + entry.name, parent: folder });
|
|
95
|
+
else if (isFile && entry.name !== ".DS_Store") {
|
|
96
|
+
if (sizes) files.push([file, rel]);
|
|
97
|
+
else out.push([rel, 0]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
done();
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const size = (file, rel) => {
|
|
104
|
+
fs.stat(file, (e, stat) => {
|
|
105
|
+
if (e) fail(file, `IO error for operation on ${file}: ${e.message}`);
|
|
106
|
+
else out.push([rel, stat.size]);
|
|
107
|
+
done();
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const pump = () => {
|
|
111
|
+
while (active < AT_ONCE && (folders.length || files.length)) {
|
|
112
|
+
active++;
|
|
113
|
+
if (folders.length) read(folders.pop());
|
|
114
|
+
else size(...files.pop());
|
|
115
|
+
}
|
|
116
|
+
if (active === 0) {
|
|
117
|
+
if (failures.length) reject(new BuildError(failures.sort((a, b) => compareText(a[0], b[0]))[0][1]));
|
|
118
|
+
else resolve(out);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
pump();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async function measure(dir) {
|
|
125
|
+
if (!(fs.statSync(dir, { throwIfNoEntry: false })?.isDirectory() ?? false)) bail(`${dir} isn't a folder; build the site first, or give \`ssqch footprint\` a build folder (\`ssqch footprint dist\`)`);
|
|
126
|
+
const pages = [];
|
|
127
|
+
const others = [];
|
|
128
|
+
for (const [file, size] of await buildFiles(dir, true)) (kindOf(file) === "Pages" ? pages : others).push({ path: file, bytes: size });
|
|
129
|
+
const heaviest = (a, b) => b.bytes - a.bytes || compareText(a.path, b.path);
|
|
130
|
+
pages.sort(heaviest);
|
|
131
|
+
others.sort(heaviest);
|
|
132
|
+
const kinds = [...KINDS.map(([name]) => name), OTHER].map((name) => ({ name, files: 0, bytes: 0 }));
|
|
133
|
+
for (const file of [...pages, ...others]) {
|
|
134
|
+
const kind = kinds.find((k) => k.name === kindOf(file.path));
|
|
135
|
+
kind.files += 1;
|
|
136
|
+
kind.bytes += file.bytes;
|
|
137
|
+
}
|
|
138
|
+
const used = kinds.filter((k) => k.files > 0);
|
|
139
|
+
return { files: pages.length + others.length, bytes: used.reduce((sum, k) => sum + k.bytes, 0), kinds: used, pages, others };
|
|
140
|
+
}
|
|
141
|
+
function share(part, total) {
|
|
142
|
+
if (total === 0) return "0%";
|
|
143
|
+
const percent = part * 100 / total;
|
|
144
|
+
return percent > 0 && percent < 1 ? "<1%" : `${fixed(percent, 0)}%`;
|
|
145
|
+
}
|
|
146
|
+
function footprintText(footprint, shown, top) {
|
|
147
|
+
let out = `Footprint of ${shown}: ${count(footprint.files)} file${footprint.files === 1 ? "" : "s"}, ${bytes(footprint.bytes)}
|
|
148
|
+
`;
|
|
149
|
+
if (footprint.files === 0) return `${out}Nothing sighted: the folder is empty.
|
|
150
|
+
`;
|
|
151
|
+
const rows = footprint.kinds.map((k) => [k.name, count(k.files), k.files === 1 ? "file" : "files", bytes(k.bytes), share(k.bytes, footprint.bytes)]);
|
|
152
|
+
const width = (i) => Math.max(0, ...rows.map((r) => [...r[i]].length));
|
|
153
|
+
const [w0, w1, w2, w3] = [width(0), width(1), width(2), width(3)];
|
|
154
|
+
for (const [name, files, word, size, part] of rows) out += ` ${padEnd(name, w0)} ${padStart(files, w1)} ${padEnd(word, w2)} ${padStart(size, w3)} ${part}
|
|
155
|
+
`;
|
|
156
|
+
const list = (title, files, name) => {
|
|
157
|
+
if (!files.length || top === 0) return;
|
|
158
|
+
out += `
|
|
159
|
+
${title}
|
|
160
|
+
`;
|
|
161
|
+
const listed = files.slice(0, top).map((f) => [bytes(f.bytes), name(f)]);
|
|
162
|
+
const w = Math.max(0, ...listed.map(([size]) => [...size].length));
|
|
163
|
+
for (const [size, file] of listed) out += ` ${padStart(size, w)} ${file}
|
|
164
|
+
`;
|
|
165
|
+
};
|
|
166
|
+
list("Largest footprints: pages", footprint.pages, (f) => urlOf(f.path));
|
|
167
|
+
list("Largest footprints: other files", footprint.others, (f) => `/${f.path}`);
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
function footprintJson(footprint, output, top) {
|
|
171
|
+
const files = (list, page) => list.slice(0, top).map((f) => page ? { path: f.path, bytes: f.bytes, url: urlOf(f.path) } : { path: f.path, bytes: f.bytes, kind: kindOf(f.path) });
|
|
172
|
+
return {
|
|
173
|
+
schemaVersion: 1,
|
|
174
|
+
output,
|
|
175
|
+
files: footprint.files,
|
|
176
|
+
bytes: footprint.bytes,
|
|
177
|
+
kinds: footprint.kinds.map((k) => ({ kind: k.name, files: k.files, bytes: k.bytes })),
|
|
178
|
+
largest: { pages: files(footprint.pages, true), files: files(footprint.others, false) }
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function overBudget(footprint, budgets) {
|
|
182
|
+
const out = [];
|
|
183
|
+
for (const [name, limit] of budgets) {
|
|
184
|
+
if (name === "total") {
|
|
185
|
+
if (footprint.bytes > limit) out.push(warning("over-budget", `the build is ${bytes(footprint.bytes)}, over its total budget of ${bytes(limit)}`));
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
const kind = BUDGETS.find(([key]) => key === name)?.[1];
|
|
189
|
+
if (kind === void 0) continue;
|
|
190
|
+
const page = kind === "Pages";
|
|
191
|
+
const over = [...footprint.pages, ...footprint.others].filter((f) => kindOf(f.path) === kind && f.bytes > limit);
|
|
192
|
+
const shown = (f) => `${page ? urlOf(f.path) : `/${f.path}`} (${bytes(f.bytes)})`;
|
|
193
|
+
const what = page ? "page" : "file";
|
|
194
|
+
if (!over.length) continue;
|
|
195
|
+
const message = over.length === 1 ? `${shown(over[0])} is over the ${name} budget of ${bytes(limit)}` : `${over.length} ${what}s are over the ${name} budget of ${bytes(limit)}: ${over.slice(0, 5).map(shown).join(", ")}${over.length > 5 ? ", ..." : ""}`;
|
|
196
|
+
out.push(warning("over-budget", message));
|
|
197
|
+
}
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export {
|
|
202
|
+
kindOf,
|
|
203
|
+
urlOf,
|
|
204
|
+
buildFiles,
|
|
205
|
+
measure,
|
|
206
|
+
footprintText,
|
|
207
|
+
footprintJson,
|
|
208
|
+
overBudget
|
|
209
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
OUTPUT_LIST,
|
|
5
|
+
asTextForTest,
|
|
6
|
+
build,
|
|
7
|
+
edgeCodeMentionsForTest,
|
|
8
|
+
inEdgeCode,
|
|
9
|
+
inspectPages,
|
|
10
|
+
runCommand,
|
|
11
|
+
sameContentsForTest
|
|
12
|
+
} from "./chunk-DELWRJAO.js";
|
|
13
|
+
import {
|
|
14
|
+
commandLine,
|
|
15
|
+
toolPath
|
|
16
|
+
} from "./chunk-4Q6WMTER.js";
|
|
17
|
+
import "./chunk-3A647I3N.js";
|
|
18
|
+
import "./chunk-II5DEH3Q.js";
|
|
19
|
+
import "./chunk-R7K3D5W5.js";
|
|
20
|
+
import "./chunk-7XLK2GEG.js";
|
|
21
|
+
import "./chunk-NKXEPHRZ.js";
|
|
22
|
+
import "./chunk-AD3HAW3W.js";
|
|
23
|
+
import "./chunk-DDV6JEC2.js";
|
|
24
|
+
import "./chunk-NCWFYT74.js";
|
|
25
|
+
import "./chunk-FVZ5JBRI.js";
|
|
26
|
+
import "./chunk-HPXAZ2HU.js";
|
|
27
|
+
import "./chunk-UU43WIZG.js";
|
|
28
|
+
import "./chunk-76NTVE34.js";
|
|
29
|
+
import "./chunk-CMUWRPSQ.js";
|
|
30
|
+
import "./chunk-GRWMGC7D.js";
|
|
31
|
+
import "./chunk-VJWQSYEG.js";
|
|
32
|
+
import "./chunk-I3PS26CI.js";
|
|
33
|
+
export {
|
|
34
|
+
OUTPUT_LIST,
|
|
35
|
+
asTextForTest,
|
|
36
|
+
build,
|
|
37
|
+
commandLine,
|
|
38
|
+
edgeCodeMentionsForTest,
|
|
39
|
+
inEdgeCode,
|
|
40
|
+
inspectPages,
|
|
41
|
+
runCommand,
|
|
42
|
+
sameContentsForTest,
|
|
43
|
+
toolPath
|
|
44
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
MODULE_EXPORTS,
|
|
5
|
+
capabilities,
|
|
6
|
+
modules,
|
|
7
|
+
runCapabilities
|
|
8
|
+
} from "./chunk-3K3ANWZ2.js";
|
|
9
|
+
import "./chunk-YTHQBMDJ.js";
|
|
10
|
+
import "./chunk-R7K3D5W5.js";
|
|
11
|
+
import "./chunk-7XLK2GEG.js";
|
|
12
|
+
import "./chunk-NKXEPHRZ.js";
|
|
13
|
+
import "./chunk-AD3HAW3W.js";
|
|
14
|
+
import "./chunk-DDV6JEC2.js";
|
|
15
|
+
import "./chunk-NCWFYT74.js";
|
|
16
|
+
import "./chunk-FVZ5JBRI.js";
|
|
17
|
+
import "./chunk-HPXAZ2HU.js";
|
|
18
|
+
import "./chunk-UU43WIZG.js";
|
|
19
|
+
import "./chunk-76NTVE34.js";
|
|
20
|
+
import "./chunk-CMUWRPSQ.js";
|
|
21
|
+
import "./chunk-GRWMGC7D.js";
|
|
22
|
+
import "./chunk-VJWQSYEG.js";
|
|
23
|
+
import "./chunk-I3PS26CI.js";
|
|
24
|
+
export {
|
|
25
|
+
MODULE_EXPORTS,
|
|
26
|
+
capabilities,
|
|
27
|
+
modules,
|
|
28
|
+
runCapabilities
|
|
29
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
red
|
|
5
|
+
} from "./chunk-GRWMGC7D.js";
|
|
6
|
+
|
|
7
|
+
// src/serve/builder.ts
|
|
8
|
+
import { fork } from "node:child_process";
|
|
9
|
+
import crypto from "node:crypto";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
var BUILDER = "__serve-builder";
|
|
12
|
+
function fileHash(file) {
|
|
13
|
+
try {
|
|
14
|
+
return crypto.hash("sha1", fs.readFileSync(file), "base64");
|
|
15
|
+
} catch {
|
|
16
|
+
return "-";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
var builders = /* @__PURE__ */ new Set();
|
|
20
|
+
var stopping = false;
|
|
21
|
+
function stopBuilders() {
|
|
22
|
+
stopping = true;
|
|
23
|
+
for (const builder of [...builders]) builder.stop();
|
|
24
|
+
}
|
|
25
|
+
var never = () => new Promise(() => {
|
|
26
|
+
});
|
|
27
|
+
var Builder = class _Builder {
|
|
28
|
+
site;
|
|
29
|
+
/** The configuration's files, as of the last build. */
|
|
30
|
+
files = /* @__PURE__ */ new Set();
|
|
31
|
+
/** What the plugins read for the last build. */
|
|
32
|
+
read = /* @__PURE__ */ new Set();
|
|
33
|
+
/** Other generators' words noted so far. */
|
|
34
|
+
said = [];
|
|
35
|
+
args;
|
|
36
|
+
child;
|
|
37
|
+
waiting;
|
|
38
|
+
/** What each of the configuration's files held when it loaded (`State.loadedAs`). */
|
|
39
|
+
loadedAs = {};
|
|
40
|
+
/** A process that's starting in place of one that ended, until it has loaded (or hasn't). */
|
|
41
|
+
starting;
|
|
42
|
+
/** What the site's code threw after a build had reported, ending its process: the next build's error. */
|
|
43
|
+
crashed;
|
|
44
|
+
constructor(args) {
|
|
45
|
+
this.args = args;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Start a process that loads the configuration, with the command line's own arguments.
|
|
49
|
+
* Nothing when it doesn't load: the process has printed why.
|
|
50
|
+
*/
|
|
51
|
+
static async start(args, start) {
|
|
52
|
+
const builder = new _Builder(args);
|
|
53
|
+
builder.said = start.said;
|
|
54
|
+
return await builder.spawn(start) ? builder : void 0;
|
|
55
|
+
}
|
|
56
|
+
/** Whether a process with this configuration is there to build, or starting. */
|
|
57
|
+
get alive() {
|
|
58
|
+
return this.child !== void 0 || this.starting !== void 0;
|
|
59
|
+
}
|
|
60
|
+
async spawn(start) {
|
|
61
|
+
const child = fork(process.argv[1], [BUILDER, JSON.stringify(start), ...this.args], { stdio: ["inherit", "inherit", "inherit", "ipc"], execArgv: process.execArgv });
|
|
62
|
+
this.child = child;
|
|
63
|
+
builders.add(this);
|
|
64
|
+
const current = () => this.child === child;
|
|
65
|
+
const lost = () => {
|
|
66
|
+
this.child = void 0;
|
|
67
|
+
builders.delete(this);
|
|
68
|
+
};
|
|
69
|
+
const replace = () => {
|
|
70
|
+
if (!stopping && this.site !== void 0) this.replace();
|
|
71
|
+
};
|
|
72
|
+
child.on("message", (message2) => {
|
|
73
|
+
if (!current()) return;
|
|
74
|
+
if (message2.type !== "crashed") return this.waiting?.(message2);
|
|
75
|
+
this.crashed = message2.error;
|
|
76
|
+
lost();
|
|
77
|
+
this.waiting?.(message2);
|
|
78
|
+
replace();
|
|
79
|
+
});
|
|
80
|
+
child.once("exit", () => {
|
|
81
|
+
if (!current()) return;
|
|
82
|
+
lost();
|
|
83
|
+
this.waiting?.(void 0);
|
|
84
|
+
replace();
|
|
85
|
+
});
|
|
86
|
+
child.once("error", () => {
|
|
87
|
+
if (!current()) return;
|
|
88
|
+
lost();
|
|
89
|
+
this.waiting?.(void 0);
|
|
90
|
+
});
|
|
91
|
+
const message = await this.next();
|
|
92
|
+
if (message?.type !== "loaded") {
|
|
93
|
+
this.stop();
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
this.site = message.site;
|
|
97
|
+
this.note(message);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Start a process in place of one that ended, when it would load the same configuration: the
|
|
102
|
+
* one that loaded last, whose files hold what they held then. Otherwise (they've changed
|
|
103
|
+
* since), the server reads them again for that change, and this has nothing to build with.
|
|
104
|
+
*/
|
|
105
|
+
replace() {
|
|
106
|
+
if (this.starting || !Object.entries(this.loadedAs).every(([file, hash]) => fileHash(file) === hash)) return;
|
|
107
|
+
const starting = this.spawn({ reload: true, fallback: false, said: this.said });
|
|
108
|
+
this.starting = starting;
|
|
109
|
+
void starting.finally(() => {
|
|
110
|
+
if (this.starting === starting) this.starting = void 0;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
next() {
|
|
114
|
+
return new Promise((resolve) => {
|
|
115
|
+
this.waiting = (message) => {
|
|
116
|
+
this.waiting = void 0;
|
|
117
|
+
resolve(message);
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
note(state) {
|
|
122
|
+
this.files = new Set(state.files);
|
|
123
|
+
this.loadedAs = state.loadedAs;
|
|
124
|
+
this.read = new Set(state.read);
|
|
125
|
+
this.said = state.said;
|
|
126
|
+
}
|
|
127
|
+
/** Says a build failed, and why. */
|
|
128
|
+
failed(error) {
|
|
129
|
+
process.stderr.write(`${red("Build failed:")} ${error}
|
|
130
|
+
`);
|
|
131
|
+
return { ok: false, error, assets: [] };
|
|
132
|
+
}
|
|
133
|
+
/** Build, and print the summary or the error. `recovered`: the last build failed, which the summary of one that works says. */
|
|
134
|
+
async build(recovered) {
|
|
135
|
+
if (stopping) return never();
|
|
136
|
+
if (this.starting) await this.starting;
|
|
137
|
+
if (this.crashed !== void 0) {
|
|
138
|
+
const error = this.crashed;
|
|
139
|
+
this.crashed = void 0;
|
|
140
|
+
return this.failed(error);
|
|
141
|
+
}
|
|
142
|
+
if (!this.child) this.replace();
|
|
143
|
+
if (this.starting) await this.starting;
|
|
144
|
+
if (stopping) return never();
|
|
145
|
+
if (!this.child) return { ok: false, error: "The configuration didn't load: its error is in the terminal.", assets: [] };
|
|
146
|
+
const child = this.child;
|
|
147
|
+
const answer = this.next();
|
|
148
|
+
child.send({ type: "build", recovered });
|
|
149
|
+
const message = await answer;
|
|
150
|
+
if (stopping) return never();
|
|
151
|
+
if (message?.type === "crashed") {
|
|
152
|
+
this.crashed = void 0;
|
|
153
|
+
return this.failed(message.error);
|
|
154
|
+
}
|
|
155
|
+
if (message?.type !== "built") {
|
|
156
|
+
const how = child.exitCode !== null ? `exit code ${child.exitCode}` : child.signalCode !== null ? `stopped by ${child.signalCode}` : "it stopped answering";
|
|
157
|
+
return this.failed(`The build's process ended before the build did (${how}). What it said is in the terminal.`);
|
|
158
|
+
}
|
|
159
|
+
this.note(message);
|
|
160
|
+
return { ok: message.ok, error: message.error, assets: message.assets };
|
|
161
|
+
}
|
|
162
|
+
stop() {
|
|
163
|
+
const child = this.child;
|
|
164
|
+
this.child = void 0;
|
|
165
|
+
builders.delete(this);
|
|
166
|
+
if (child && child.exitCode === null && child.signalCode === null) child.kill("SIGKILL");
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
BUILDER,
|
|
172
|
+
fileHash,
|
|
173
|
+
stopBuilders,
|
|
174
|
+
Builder
|
|
175
|
+
};
|