ssqch 0.12.0 → 0.13.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/bundled/completions/bash +66 -8
- package/bundled/completions/elvish +23 -4
- package/bundled/completions/fish +36 -25
- package/bundled/completions/powershell +25 -4
- package/bundled/completions/zsh +44 -10
- package/bundled/docs/agents.md +2 -2
- package/bundled/docs/build-summary.md +1 -1
- package/bundled/docs/comparing-builds.md +2 -2
- package/bundled/docs/configuring.md +3 -6
- package/bundled/docs/deploying.md +1 -1
- package/bundled/docs/field-guide.md +4 -4
- package/bundled/docs/github-pages.md +1 -0
- package/bundled/docs/index.md +1 -1
- package/bundled/docs/install.md +1 -1
- package/bundled/docs/known-gaps.md +1 -1
- package/bundled/docs/markdown.md +8 -12
- package/bundled/docs/nav.yml +5 -1
- package/bundled/docs/netlify.md +4 -2
- package/bundled/docs/patrol.md +48 -0
- package/bundled/docs/plugins.md +6 -6
- package/bundled/docs/robots.md +85 -0
- package/bundled/docs/seo.md +2 -38
- package/bundled/docs/serving-markdown.md +142 -0
- package/bundled/docs/template-languages.md +1 -1
- package/bundled/docs/templates.md +1 -1
- package/bundled/docs/trailheads/from-hugo.md +5 -3
- package/bundled/docs/trailheads/from-jekyll.md +54 -13
- package/bundled/docs/trailheads/from-mkdocs.md +15 -12
- package/bundled/docs/trailheads/from-vitepress.md +13 -11
- package/bundled/docs/trailheads.md +3 -3
- package/bundled/docs/where-values-come-from.md +5 -5
- package/bundled/docs/writing-plugins.md +69 -0
- package/bundled/ssqch.d.ts +118 -44
- package/bundled/starter/engines/index.edge +1 -0
- package/bundled/starter/engines/index.ejs +1 -0
- package/bundled/starter/engines/index.hbs +1 -0
- package/bundled/starter/engines/index.liquid +1 -0
- package/bundled/starter/engines/layout.edge +7 -0
- package/bundled/starter/engines/layout.ejs +4 -0
- package/bundled/starter/engines/layout.hbs +4 -0
- package/bundled/starter/engines/layout.liquid +4 -0
- package/bundled/starter/src/_data/site.json +1 -0
- package/bundled/starter/src/_includes/layout.jinja +4 -0
- package/bundled/starter/src/index.jinja +1 -0
- package/bundled/starter/ssqch.config.js +14 -1
- package/bundled/starter-docs/engines/edge/base.edge +7 -0
- package/bundled/starter-docs/engines/edge/doc.edge +4 -0
- package/bundled/starter-docs/engines/ejs/base.ejs +4 -0
- package/bundled/starter-docs/engines/ejs/doc.ejs +4 -0
- package/bundled/starter-docs/engines/hbs/base.hbs +4 -0
- package/bundled/starter-docs/engines/hbs/doc.hbs +3 -0
- package/bundled/starter-docs/engines/liquid/base.liquid +4 -0
- package/bundled/starter-docs/engines/liquid/doc.liquid +4 -0
- package/bundled/starter-docs/src/_data/site.json +1 -0
- package/bundled/starter-docs/src/_includes/base.jinja +4 -0
- package/bundled/starter-docs/src/_includes/doc.jinja +4 -0
- package/bundled/starter-docs/src/assets/docs.css +4 -0
- package/bundled/starter-docs/src/assets/docs.js +17 -0
- package/bundled/starter-docs/ssqch.config.js +14 -1
- package/lib/assets.js +9 -9
- package/lib/chunk-25WERNDD.js +112 -0
- package/lib/{chunk-4ZMNLWE4.js → chunk-2BJFGKOE.js} +2 -2
- package/lib/{chunk-M2BBE2C3.js → chunk-3ZTRIO6O.js} +18 -17
- package/lib/{chunk-57HLSKZS.js → chunk-4AZFCSGJ.js} +2 -2
- package/lib/{chunk-ULQHJ4TS.js → chunk-55WXDGO4.js} +3 -3
- package/lib/{chunk-JX43SJHU.js → chunk-6FY77I4M.js} +24 -22
- package/lib/{chunk-RY3KLUQ3.js → chunk-6OUCRDYI.js} +267 -202
- package/lib/{chunk-EVFNYUTR.js → chunk-6U5VIQVY.js} +5 -5
- package/lib/{chunk-N3IZ44XY.js → chunk-7U5GWTEH.js} +88 -54
- package/lib/{chunk-VTYQ3JKL.js → chunk-AIJNG6MJ.js} +2 -2
- package/lib/{chunk-IIBZPHAW.js → chunk-C2Q7JKFI.js} +8 -8
- package/lib/{chunk-6CSH757V.js → chunk-DFJFHULZ.js} +33 -8
- package/lib/{chunk-XVV7JJK7.js → chunk-ENWDM2RW.js} +40 -39
- package/lib/{chunk-JUALMFW3.js → chunk-ER72RPD6.js} +1 -1
- package/lib/{chunk-RFREB3SI.js → chunk-F3JPNFCZ.js} +7 -7
- package/lib/{chunk-LLOA3QXV.js → chunk-FENJHLNM.js} +3 -2
- package/lib/{chunk-UU43WIZG.js → chunk-FJML7INB.js} +4 -2
- package/lib/{chunk-IZCF4UH3.js → chunk-FQZDUDFK.js} +1 -1
- package/lib/chunk-GM5SHCTU.js +272 -0
- package/lib/{chunk-GVHQ37JE.js → chunk-GSNRAGKQ.js} +10 -5
- package/lib/{chunk-L2IY4P6O.js → chunk-GU7BBYWB.js} +3 -3
- package/lib/{chunk-RGYJQYW3.js → chunk-HDKU6LRI.js} +32 -5
- package/lib/{chunk-IQUGLVZY.js → chunk-K5WZ2VYK.js} +4 -4
- package/lib/{chunk-JVT5ZRRH.js → chunk-OOKBXQAY.js} +5 -5
- package/lib/{chunk-MOLTDO5A.js → chunk-SNQOHNXE.js} +1 -1
- package/lib/{chunk-Z3XH4KWX.js → chunk-SPIFZBIW.js} +1 -1
- package/lib/{chunk-FNNXRVSU.js → chunk-T5IUI7W7.js} +10 -10
- package/lib/{chunk-5HEZ3WUQ.js → chunk-TGSVSG2G.js} +2 -2
- package/lib/{chunk-3GROJ3TY.js → chunk-U2KEMVXO.js} +24 -17
- package/lib/{chunk-4B3N44SN.js → chunk-UHRBPZ4A.js} +3 -3
- package/lib/{chunk-GWWA5Y3X.js → chunk-ULCT3PAV.js} +1 -1
- package/lib/{chunk-7RGEWDLF.js → chunk-UZNUS7RP.js} +10 -8
- package/lib/{chunk-DZ5F5XSI.js → chunk-V3G2QGL3.js} +10 -105
- package/lib/{chunk-DOHOKUGB.js → chunk-VILOEVK7.js} +50 -26
- package/lib/{chunk-DXMDXHV7.js → chunk-WGAIE3DD.js} +15 -14
- package/lib/{chunk-G3RFQDKO.js → chunk-WUCRAV36.js} +8 -6
- package/lib/{chunk-52ROOMBZ.js → chunk-XYAWJTHM.js} +9 -9
- package/lib/{chunk-L3K7MMFC.js → chunk-YA23NDMW.js} +2 -2
- package/lib/{chunk-R7PBREXL.js → chunk-YNJNMQWU.js} +8 -5
- package/lib/{chunk-AK7ZKSZP.js → chunk-ZMG25MXF.js} +17 -16
- package/lib/cli.js +56 -34
- package/lib/elements.js +9 -9
- package/lib/from-hugo.js +36 -0
- package/lib/from-jekyll.js +41 -0
- package/lib/from-mkdocs.js +49 -0
- package/lib/from-vitepress.js +49 -0
- package/lib/image.js +10 -10
- package/lib/links.js +9 -9
- package/lib/llms.js +619 -54
- package/lib/minify.js +10 -10
- package/lib/redirects.js +9 -9
- package/lib/robots.js +87 -0
- package/lib/rss.js +22 -12
- package/lib/sass.js +10 -10
- package/lib/sitemap.js +22 -33
- package/lib/ssqch.js +5 -5
- package/lib/vue.js +14 -13
- package/package.json +21 -1
- package/types/from-hugo.d.ts +5 -0
- package/types/from-jekyll.d.ts +11 -0
- package/types/from-mkdocs.d.ts +11 -0
- package/types/from-vitepress.d.ts +5 -0
- package/types/index.d.ts +45 -29
- package/types/llms.d.ts +18 -8
- package/types/robots.d.ts +13 -0
- package/types/sass.d.ts +1 -1
- package/types/sitemap.d.ts +3 -5
- package/wasm/markdown.wasm +0 -0
- /package/lib/{chunk-JX43SJHU.js.LEGAL.txt → chunk-6FY77I4M.js.LEGAL.txt} +0 -0
- /package/lib/{chunk-R7PBREXL.js.LEGAL.txt → chunk-YNJNMQWU.js.LEGAL.txt} +0 -0
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
2
|
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
4
|
+
tracePages
|
|
5
|
+
} from "./chunk-6FY77I4M.js";
|
|
6
|
+
import "./chunk-YA23NDMW.js";
|
|
7
|
+
import "./chunk-V3G2QGL3.js";
|
|
8
8
|
import "./chunk-4Q6WMTER.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-UHRBPZ4A.js";
|
|
10
|
+
import "./chunk-25WERNDD.js";
|
|
11
|
+
import "./chunk-VILOEVK7.js";
|
|
12
|
+
import "./chunk-ULCT3PAV.js";
|
|
13
|
+
import "./chunk-6U5VIQVY.js";
|
|
13
14
|
import "./chunk-AD3HAW3W.js";
|
|
14
15
|
import "./chunk-YCOTX2VM.js";
|
|
15
16
|
import "./chunk-DDV6JEC2.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-6OUCRDYI.js";
|
|
18
|
+
import "./chunk-SPIFZBIW.js";
|
|
17
19
|
import "./chunk-FVZ5JBRI.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-57HLSKZS.js";
|
|
20
|
+
import "./chunk-FJML7INB.js";
|
|
21
|
+
import "./chunk-4AZFCSGJ.js";
|
|
21
22
|
import {
|
|
22
23
|
charCount,
|
|
23
24
|
firstChars,
|
|
@@ -30,7 +31,7 @@ import {
|
|
|
30
31
|
import {
|
|
31
32
|
bail,
|
|
32
33
|
getPath
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-YNJNMQWU.js";
|
|
34
35
|
import {
|
|
35
36
|
comparePaths,
|
|
36
37
|
compareText,
|
|
@@ -39,7 +40,7 @@ import {
|
|
|
39
40
|
} from "./chunk-VJWQSYEG.js";
|
|
40
41
|
import "./chunk-I3PS26CI.js";
|
|
41
42
|
|
|
42
|
-
// src/
|
|
43
|
+
// src/trace.ts
|
|
43
44
|
import fs from "node:fs";
|
|
44
45
|
import path from "node:path";
|
|
45
46
|
var has = (data, key) => data !== null && typeof data === "object" && Object.prototype.hasOwnProperty.call(data, key);
|
|
@@ -83,8 +84,8 @@ function fieldsOf(config, dirs, global, page) {
|
|
|
83
84
|
}
|
|
84
85
|
return out;
|
|
85
86
|
}
|
|
86
|
-
async function
|
|
87
|
-
const { dirs, global, pages } = await
|
|
87
|
+
async function trace(config, target) {
|
|
88
|
+
const { dirs, global, pages } = await tracePages(config);
|
|
88
89
|
const trim = (u) => {
|
|
89
90
|
const rest = u.endsWith("index.html") ? u.slice(0, -10) : void 0;
|
|
90
91
|
return (rest !== void 0 && rest.endsWith("/") ? rest : u).replace(/\/+$/, "");
|
|
@@ -151,30 +152,30 @@ function valueAt(value, key) {
|
|
|
151
152
|
if (value instanceof Date || typeof value === "function") return void 0;
|
|
152
153
|
return has(value, key) ? value[key] : void 0;
|
|
153
154
|
}
|
|
154
|
-
function field(
|
|
155
|
+
function field(traced, dotted) {
|
|
155
156
|
const at = dotted.indexOf(".");
|
|
156
157
|
const [top, rest] = at === -1 ? [dotted, ""] : [dotted.slice(0, at), dotted.slice(at + 1)];
|
|
157
|
-
const found =
|
|
158
|
+
const found = traced.fields.find((f) => f.name === top);
|
|
158
159
|
if (!found || rest === "") return found;
|
|
159
160
|
const pathIn = (v) => rest.split(".").reduce(valueAt, v);
|
|
160
161
|
const setBy = found.setBy.filter((s) => !nullish(pathIn(s.value))).map((s) => ({ from: s.from, value: pathIn(s.value) }));
|
|
161
162
|
return { name: dotted, value: pathIn(found.value), from: setBy.length ? setBy[setBy.length - 1].from : found.from, setBy };
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
-
let out = `${
|
|
164
|
+
function traceText(traced) {
|
|
165
|
+
let out = `${traced.url ?? "(no URL: permalink is false)"}
|
|
165
166
|
`;
|
|
166
167
|
const row = (label, value) => {
|
|
167
168
|
out += ` ${padEnd(label, 12)}${value}
|
|
168
169
|
`;
|
|
169
170
|
};
|
|
170
|
-
row("From", `${
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
173
|
-
row("Date", `${
|
|
174
|
-
row("Collections",
|
|
171
|
+
row("From", `${traced.inputPath} (${traced.engines.length ? traced.engines.join(", ") : "as it is"})`);
|
|
172
|
+
if (traced.outputPath !== null) row("Writes", traced.outputPath);
|
|
173
|
+
if (traced.layouts.length) row("Layouts", traced.layouts.join(" > "));
|
|
174
|
+
row("Date", `${traced.date} (from ${traced.dateFrom})`);
|
|
175
|
+
row("Collections", traced.collections.length ? traced.collections.join(", ") : "none");
|
|
175
176
|
out += "\n Data (name, value, and the level of the cascade that set it)\n";
|
|
176
|
-
const width = Math.min(24, Math.max(0, ...
|
|
177
|
-
for (const f of
|
|
177
|
+
const width = Math.min(24, Math.max(0, ...traced.fields.map((f) => charCount(f.name))));
|
|
178
|
+
for (const f of traced.fields) {
|
|
178
179
|
const overrides = f.setBy.length > 1 ? ` (over ${f.setBy.slice(0, -1).map((s) => s.from).join(", ")})` : "";
|
|
179
180
|
out += ` ${padEnd(f.name, width)} ${padEnd(brief(f.value), 52)} ${f.from}${overrides}
|
|
180
181
|
`;
|
|
@@ -195,25 +196,25 @@ function fieldText(f) {
|
|
|
195
196
|
return out;
|
|
196
197
|
}
|
|
197
198
|
var setByJson = (f) => f.setBy.map((s) => ({ from: s.from, value: toJsonValue(s.value) }));
|
|
198
|
-
function
|
|
199
|
+
function traceJson(traced, one) {
|
|
199
200
|
const out = {
|
|
200
201
|
schemaVersion: 1,
|
|
201
|
-
url:
|
|
202
|
-
inputPath:
|
|
203
|
-
outputPath:
|
|
204
|
-
engines:
|
|
205
|
-
layouts:
|
|
206
|
-
date: { value:
|
|
207
|
-
collections:
|
|
202
|
+
url: traced.url,
|
|
203
|
+
inputPath: traced.inputPath,
|
|
204
|
+
outputPath: traced.outputPath,
|
|
205
|
+
engines: traced.engines,
|
|
206
|
+
layouts: traced.layouts,
|
|
207
|
+
date: { value: traced.date, from: traced.dateFrom },
|
|
208
|
+
collections: traced.collections
|
|
208
209
|
};
|
|
209
210
|
if (one) out.field = { name: one.name, value: toJsonValue(one.value), from: one.from, setBy: setByJson(one) };
|
|
210
|
-
else out.data = Object.fromEntries(
|
|
211
|
+
else out.data = Object.fromEntries(traced.fields.map((f) => [f.name, { value: toJsonValue(f.value), from: f.from, setBy: setByJson(f) }]));
|
|
211
212
|
return out;
|
|
212
213
|
}
|
|
213
214
|
export {
|
|
214
215
|
field,
|
|
215
216
|
fieldText,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
trace,
|
|
218
|
+
traceJson,
|
|
219
|
+
traceText
|
|
219
220
|
};
|
|
@@ -2,7 +2,7 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
red
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-YNJNMQWU.js";
|
|
6
6
|
|
|
7
7
|
// src/serve/builder.ts
|
|
8
8
|
import { fork } from "node:child_process";
|
|
@@ -3,18 +3,18 @@ const require = __ssqchCreateRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
baselineTime,
|
|
5
5
|
runBaseline
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2BJFGKOE.js";
|
|
7
7
|
import "./chunk-4Q6WMTER.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-HDKU6LRI.js";
|
|
9
9
|
import "./chunk-P2WS4RM4.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-UHRBPZ4A.js";
|
|
11
|
+
import "./chunk-ULCT3PAV.js";
|
|
12
|
+
import "./chunk-6U5VIQVY.js";
|
|
13
13
|
import "./chunk-DDV6JEC2.js";
|
|
14
14
|
import "./chunk-FVZ5JBRI.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-FJML7INB.js";
|
|
16
16
|
import "./chunk-CMUWRPSQ.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-YNJNMQWU.js";
|
|
18
18
|
import "./chunk-VJWQSYEG.js";
|
|
19
19
|
import "./chunk-I3PS26CI.js";
|
|
20
20
|
export {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-YCOTX2VM.js";
|
|
7
7
|
import {
|
|
8
8
|
red
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YNJNMQWU.js";
|
|
10
10
|
import {
|
|
11
11
|
joinAsGiven,
|
|
12
12
|
parentAsGiven,
|
|
@@ -107,7 +107,8 @@ This site is built with SiteSquatch (\`ssqch\`), a static site generator. ${file
|
|
|
107
107
|
- How to use something: \`ssqch docs <name>\` (a config option, template function, command or topic) answers for the installed version, and \`ssqch docs\` lists everything.
|
|
108
108
|
- What this ssqch supports: \`ssqch capabilities --format json\`.
|
|
109
109
|
- Check a change: \`ssqch build --format json\`. \`ok\` is the result, and each problem has a \`code\`, a \`file\` and a \`line\`.
|
|
110
|
-
-
|
|
110
|
+
- What agents and crawlers find in the build (robots.txt, the sitemap, llms.txt, each page's Markdown copy): \`ssqch patrol --format json\` after \`ssqch build\`.
|
|
111
|
+
- Why a page's value is what it is: \`ssqch trace <url or file> --format json\`.
|
|
111
112
|
- Before changing layouts or the config: \`ssqch build --output ${out}-before\`, and afterwards \`ssqch build\` and \`ssqch diff ${out}-before ${out}\`.
|
|
112
113
|
- A new page: ${newPage}.
|
|
113
114
|
- \`ssqch serve\` is for a person watching the browser. Check with \`ssqch build\`.
|
|
@@ -4,12 +4,13 @@ const require = __ssqchCreateRequire(import.meta.url);
|
|
|
4
4
|
// src/voice.ts
|
|
5
5
|
var SQUATCH_WATCH = "Squatch Watch is on.";
|
|
6
6
|
var FRESH_TRACKS = "Fresh tracks in";
|
|
7
|
-
var
|
|
7
|
+
var FIRST_SIGHTING = "First confirmed sighting.";
|
|
8
8
|
var RECOVERED = "Build recovered. Back on the trail.";
|
|
9
9
|
var FIELD_NOTES = "Field notes started.";
|
|
10
10
|
var LEFT_NO_TRACE = "left no trace";
|
|
11
11
|
var CAMPSITE_DISTURBED = "Campsite disturbed:";
|
|
12
12
|
var PASSED_THIS_TREE = "we've passed this tree before";
|
|
13
|
+
var ACCOUNTS_DIFFER = "The eyewitness accounts differ:";
|
|
13
14
|
var TRAIL_GOES_COLD = "the trail goes cold";
|
|
14
15
|
var SOMETHING_LARGE = "something large walked through the build";
|
|
15
16
|
var ISSUES_URL = "https://github.com/reverentgeek/sitesquatch/issues";
|
|
@@ -17,12 +18,13 @@ var ISSUES_URL = "https://github.com/reverentgeek/sitesquatch/issues";
|
|
|
17
18
|
export {
|
|
18
19
|
SQUATCH_WATCH,
|
|
19
20
|
FRESH_TRACKS,
|
|
20
|
-
|
|
21
|
+
FIRST_SIGHTING,
|
|
21
22
|
RECOVERED,
|
|
22
23
|
FIELD_NOTES,
|
|
23
24
|
LEFT_NO_TRACE,
|
|
24
25
|
CAMPSITE_DISTURBED,
|
|
25
26
|
PASSED_THIS_TREE,
|
|
27
|
+
ACCOUNTS_DIFFER,
|
|
26
28
|
TRAIL_GOES_COLD,
|
|
27
29
|
SOMETHING_LARGE,
|
|
28
30
|
ISSUES_URL
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
htmlText
|
|
5
|
+
} from "./chunk-25WERNDD.js";
|
|
6
|
+
import {
|
|
7
|
+
count
|
|
8
|
+
} from "./chunk-6U5VIQVY.js";
|
|
9
|
+
import "./chunk-DDV6JEC2.js";
|
|
10
|
+
import {
|
|
11
|
+
markdown
|
|
12
|
+
} from "./chunk-6OUCRDYI.js";
|
|
13
|
+
import "./chunk-SPIFZBIW.js";
|
|
14
|
+
import "./chunk-FVZ5JBRI.js";
|
|
15
|
+
import "./chunk-FJML7INB.js";
|
|
16
|
+
import "./chunk-4AZFCSGJ.js";
|
|
17
|
+
import "./chunk-CMUWRPSQ.js";
|
|
18
|
+
import {
|
|
19
|
+
bail
|
|
20
|
+
} from "./chunk-YNJNMQWU.js";
|
|
21
|
+
import {
|
|
22
|
+
compareText
|
|
23
|
+
} from "./chunk-VJWQSYEG.js";
|
|
24
|
+
import "./chunk-I3PS26CI.js";
|
|
25
|
+
|
|
26
|
+
// src/patrol.ts
|
|
27
|
+
import fs from "node:fs";
|
|
28
|
+
import path from "node:path";
|
|
29
|
+
var LLMS_LIMIT = 5e4;
|
|
30
|
+
var COPY_LONG = 5e4;
|
|
31
|
+
var COPY_CUT = 1e5;
|
|
32
|
+
var walk = (dir, rel = "") => fs.readdirSync(path.join(dir, rel), { withFileTypes: true }).flatMap((e) => {
|
|
33
|
+
const r = rel ? `${rel}/${e.name}` : e.name;
|
|
34
|
+
return e.isDirectory() ? walk(dir, r) : e.isFile() ? [r] : [];
|
|
35
|
+
}).sort(compareText);
|
|
36
|
+
var urlOf = (file) => `/${file.replace(/(^|\/)index\.html?$/, "$1")}`;
|
|
37
|
+
var textOf = (html) => htmlText(html.replace(/<(script|style|svg|template|noscript)\b[\s\S]*?<\/\1\s*>/gi, " "));
|
|
38
|
+
function part(html, name) {
|
|
39
|
+
const open = new RegExp(`<${name}\\b[^>]*>`, "i").exec(html);
|
|
40
|
+
if (!open) return void 0;
|
|
41
|
+
const close = html.toLowerCase().lastIndexOf(`</${name}`);
|
|
42
|
+
return close > open.index ? { start: open.index, html: html.slice(open.index + open[0].length, close) } : void 0;
|
|
43
|
+
}
|
|
44
|
+
var words = (text) => text.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((w) => w.length > 1);
|
|
45
|
+
function covered(a, b) {
|
|
46
|
+
if (!a.length) return 1;
|
|
47
|
+
const have = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const w of b) have.set(w, (have.get(w) ?? 0) + 1);
|
|
49
|
+
let hits = 0;
|
|
50
|
+
for (const w of a) {
|
|
51
|
+
const n = have.get(w) ?? 0;
|
|
52
|
+
if (n > 0) {
|
|
53
|
+
hits++;
|
|
54
|
+
have.set(w, n - 1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return hits / a.length;
|
|
58
|
+
}
|
|
59
|
+
function linksIn(md) {
|
|
60
|
+
const out = [];
|
|
61
|
+
let fence;
|
|
62
|
+
for (const line of md.split("\n")) {
|
|
63
|
+
const marker = /^\s{0,3}(`{3,}|~{3,})/.exec(line)?.[1];
|
|
64
|
+
if (fence !== void 0) {
|
|
65
|
+
if (marker && marker[0] === fence[0] && marker.length >= fence.length && line.trim() === marker) fence = void 0;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (marker) {
|
|
69
|
+
fence = marker;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const ref = /^ {0,3}\[[^\]]+\]:\s*<?([^\s>]+)/.exec(line);
|
|
73
|
+
if (ref) out.push(ref[1]);
|
|
74
|
+
for (const m of line.replace(/`+[^`]*`+/g, "").matchAll(/\]\(\s*<?([^\s)>]+)/g)) out.push(m[1]);
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
function prose(md) {
|
|
79
|
+
let fence;
|
|
80
|
+
return md.split("\n").filter((line) => {
|
|
81
|
+
const marker = /^\s{0,3}(`{3,}|~{3,})/.exec(line)?.[1];
|
|
82
|
+
if (fence !== void 0) {
|
|
83
|
+
if (marker && marker[0] === fence[0] && marker.length >= fence.length && line.trim() === marker) fence = void 0;
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (marker) {
|
|
87
|
+
fence = marker;
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}).map((line) => line.replace(/`+[^`]*`+/g, "")).join("\n");
|
|
92
|
+
}
|
|
93
|
+
function fencesClose(md) {
|
|
94
|
+
let fence;
|
|
95
|
+
for (const line of md.split("\n")) {
|
|
96
|
+
const marker = /^\s{0,3}(`{3,}|~{3,})/.exec(line)?.[1];
|
|
97
|
+
if (fence === void 0) {
|
|
98
|
+
if (marker) fence = marker;
|
|
99
|
+
} else if (marker && marker[0] === fence[0] && marker.length >= fence.length && line.trim() === marker) fence = void 0;
|
|
100
|
+
}
|
|
101
|
+
return fence === void 0;
|
|
102
|
+
}
|
|
103
|
+
var relative = (href) => !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(href) && !href.startsWith("#") && !href.startsWith("/");
|
|
104
|
+
function patrol(dir) {
|
|
105
|
+
let stat;
|
|
106
|
+
try {
|
|
107
|
+
stat = fs.statSync(dir);
|
|
108
|
+
} catch {
|
|
109
|
+
bail(`${dir} isn't there: build the site first (\`ssqch build\`), or name a build folder`);
|
|
110
|
+
}
|
|
111
|
+
if (!stat.isDirectory()) bail(`${dir} is a file, not a build folder`);
|
|
112
|
+
const files = walk(dir);
|
|
113
|
+
const has = new Set(files);
|
|
114
|
+
const read = (file) => fs.readFileSync(path.join(dir, file), "utf8");
|
|
115
|
+
const found = /* @__PURE__ */ new Map();
|
|
116
|
+
const say = (code, message, file) => {
|
|
117
|
+
const f = found.get(code) ?? { code, message, files: [] };
|
|
118
|
+
if (file !== void 0) f.files.push(file);
|
|
119
|
+
found.set(code, f);
|
|
120
|
+
};
|
|
121
|
+
const pages = files.filter((f) => /\.html?$/i.test(f) && !/(^|\/)404\.html?$/i.test(f));
|
|
122
|
+
const robots = has.has("robots.txt") ? read("robots.txt") : void 0;
|
|
123
|
+
const sitemapFile = has.has("sitemap.xml") ? "sitemap.xml" : void 0;
|
|
124
|
+
const sitemapLine = robots && /^\s*sitemap:\s*(\S+)/im.exec(robots)?.[1];
|
|
125
|
+
const sitemap = sitemapFile ? read(sitemapFile) : void 0;
|
|
126
|
+
const locs = sitemap ? [...sitemap.matchAll(/<loc>\s*([^<\s]+)\s*<\/loc>/g)].map((m) => m[1].replace(/&/g, "&")) : [];
|
|
127
|
+
const origins = /* @__PURE__ */ new Set();
|
|
128
|
+
for (const u of [sitemapLine, ...locs.slice(0, 1)]) {
|
|
129
|
+
try {
|
|
130
|
+
if (u) origins.add(new URL(u).origin);
|
|
131
|
+
} catch {
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const fileOf = (href) => {
|
|
135
|
+
let p;
|
|
136
|
+
if (href.startsWith("/") && !href.startsWith("//")) p = href;
|
|
137
|
+
else {
|
|
138
|
+
try {
|
|
139
|
+
const u = new URL(href);
|
|
140
|
+
if (!origins.has(u.origin)) return void 0;
|
|
141
|
+
p = u.pathname;
|
|
142
|
+
} catch {
|
|
143
|
+
return void 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
p = decodeURIComponent(p.replace(/[?#].*$/, "")).replace(/^\/+/, "");
|
|
147
|
+
if (has.has(p)) return p;
|
|
148
|
+
if (has.has(`${p.replace(/\/$/, "")}/index.html`.replace(/^\//, ""))) return `${p.replace(/\/$/, "")}/index.html`.replace(/^\//, "");
|
|
149
|
+
return "";
|
|
150
|
+
};
|
|
151
|
+
if (!robots) say("no-robots", "no robots.txt: crawlers find no sitemap line and no rules for AI crawlers (robotsPlugin() writes one)");
|
|
152
|
+
if (!sitemapFile && !sitemapLine) say("no-sitemap", "no sitemap.xml, and robots.txt names none (sitemapPlugin({ url }) writes one)");
|
|
153
|
+
if (!has.has("404.html")) say("no-404", "no 404.html: a missing page gets the host's error page, or worse, a 200");
|
|
154
|
+
else if (has.has("index.html") && read("404.html") === read("index.html")) say("no-404", "404.html is the home page: a missing page should say it's missing");
|
|
155
|
+
const llms = has.has("llms.txt") ? read("llms.txt") : void 0;
|
|
156
|
+
const listed = /* @__PURE__ */ new Set();
|
|
157
|
+
if (llms === void 0) say("no-llms", "no llms.txt: an agent gets no map of the site (llmsPlugin() writes one, with a Markdown copy of each page)");
|
|
158
|
+
const maps = llms === void 0 ? [] : ["llms.txt"];
|
|
159
|
+
for (let i = 0; i < maps.length; i++) {
|
|
160
|
+
const name = maps[i];
|
|
161
|
+
const text = i === 0 ? llms : read(name);
|
|
162
|
+
if (!/^\uFEFF?# \S/.test(text)) say("llms-shape", "llms.txt doesn't start with a `# ` heading (the site's name), which llmstxt.org's format requires", name);
|
|
163
|
+
if (text.length > LLMS_LIMIT) say("llms-long", `llms.txt is ${count(text.length)} characters, over ${count(LLMS_LIMIT)}: more than an agent reads before deciding where to go (link section files from it instead)`, name);
|
|
164
|
+
for (const href of linksIn(text)) {
|
|
165
|
+
if (relative(href)) {
|
|
166
|
+
say("relative-links", "links that aren't whole addresses (or from the site's root): they break once the text is read on its own", name);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const file = fileOf(href);
|
|
170
|
+
if (file === void 0) continue;
|
|
171
|
+
if (file === "") say("llms-broken", `llms.txt links to files that aren't in the build`, href);
|
|
172
|
+
else {
|
|
173
|
+
if (!/\.(md|markdown|txt)$/i.test(file)) say("llms-html", "llms.txt links to pages, not their Markdown: an agent reads Markdown without the page's chrome", href);
|
|
174
|
+
listed.add(file);
|
|
175
|
+
if (/(^|\/)llms\.txt$/.test(file) && !maps.includes(file)) maps.push(file);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
let copies = 0;
|
|
180
|
+
const pageUrls = [];
|
|
181
|
+
for (const file of pages) {
|
|
182
|
+
const html = read(file);
|
|
183
|
+
if (/<meta\s[^>]*http-equiv=["']?refresh/i.test(html)) continue;
|
|
184
|
+
pageUrls.push(urlOf(file));
|
|
185
|
+
const h1 = (html.match(/<h1[\s>]/gi) ?? []).length;
|
|
186
|
+
if (h1 === 0) say("no-h1", "pages with no <h1>: an agent takes the first heading as what the page is about", file);
|
|
187
|
+
else if (h1 > 1) say("h1s", "pages with more than one <h1>", file);
|
|
188
|
+
if (!/<meta\s[^>]*name=["']?description["']?[^>]*content=["']?[^"'\s>]/i.test(html) && !/<meta\s[^>]*content=["']?[^"'>]+["']?[^>]*name=["']?description/i.test(html)) say("no-description", 'pages with no <meta name="description">: what search results and agents show for a link', file);
|
|
189
|
+
const body = part(html, "body")?.html ?? html;
|
|
190
|
+
const content = part(body, "main") ?? part(body, "article");
|
|
191
|
+
if (!content) say("no-main", "pages with their content in neither <main> nor <article>: an agent can't tell the page from its navigation", file);
|
|
192
|
+
else {
|
|
193
|
+
const before = words(textOf(body.slice(0, content.start))).length;
|
|
194
|
+
const all = words(textOf(body)).length;
|
|
195
|
+
if (all > 0 && before / all > 0.5) say("content-late", "pages whose <main> comes after most of their text (navigation first): an agent with a short read sees the menus", file);
|
|
196
|
+
}
|
|
197
|
+
const linked = /<link\s[^>]*rel=["']?alternate["']?[^>]*type=["']?text\/markdown["']?[^>]*>/i.exec(html)?.[0] ?? /<link\s[^>]*type=["']?text\/markdown["']?[^>]*rel=["']?alternate["']?[^>]*>/i.exec(html)?.[0];
|
|
198
|
+
const href = linked ? /href=["']?([^"'\s>]+)/i.exec(linked)?.[1] : void 0;
|
|
199
|
+
let copy;
|
|
200
|
+
if (href !== void 0) {
|
|
201
|
+
const target = fileOf(href.startsWith("/") || /^[a-z]+:/i.test(href) ? href : `/${path.posix.join(path.posix.dirname(file), href)}`);
|
|
202
|
+
if (target === "") {
|
|
203
|
+
say("copy-missing", "pages that link a Markdown copy that isn't in the build", file);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
copy = target;
|
|
207
|
+
} else {
|
|
208
|
+
const guess = file.replace(/\.html?$/i, ".md");
|
|
209
|
+
if (has.has(guess)) copy = guess;
|
|
210
|
+
}
|
|
211
|
+
if (!copy) continue;
|
|
212
|
+
copies++;
|
|
213
|
+
const md = read(copy);
|
|
214
|
+
if (md.length > COPY_CUT) say("copy-cut-off", `Markdown copies over ${count(COPY_CUT)} characters, where Claude Code's fetch stops reading`, copy);
|
|
215
|
+
else if (md.length > COPY_LONG) say("copy-long", `Markdown copies over ${count(COPY_LONG)} characters: long for one fetch`, copy);
|
|
216
|
+
if (!fencesClose(md)) say("copy-fence", "Markdown copies with a code fence that never closes: the rest reads as code", copy);
|
|
217
|
+
if (linksIn(md).some(relative)) say("relative-links", "links that aren't whole addresses (or from the site's root): they break once the text is read on its own", copy);
|
|
218
|
+
if ([...linksIn(md), ...[...prose(md).matchAll(/<(?:img|a|source)\b[^>]*\s(?:src|href)\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1])].some((href2) => !relative(href2) && fileOf(href2) === "")) say("copy-broken", "Markdown copies that link the site's own files that aren't in the build (an image's source path, say)", copy);
|
|
219
|
+
if (content) {
|
|
220
|
+
const page = words(textOf(content.html));
|
|
221
|
+
const own = words(textOf(markdown(md)));
|
|
222
|
+
if (page.length >= 20 && (covered(own, page) < 0.8 || covered(page, own) < 0.5)) say("copy-differs", "Markdown copies that don't say what their page says (under 80% of the copy's words on the page, or under half the page's in the copy)", copy);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (llms !== void 0 && locs.length && listed.size) {
|
|
226
|
+
const copyFor = (file) => file.replace(/\.html?$/i, ".md");
|
|
227
|
+
const inList = locs.filter((loc) => {
|
|
228
|
+
const file = fileOf(loc);
|
|
229
|
+
return !file || listed.has(file) || listed.has(copyFor(file));
|
|
230
|
+
}).length;
|
|
231
|
+
if (inList / locs.length < 0.95) say("llms-coverage", `llms.txt lists ${count(inList)} of the sitemap's ${count(locs.length)} pages: under 95%, so an agent misses some (llmsPlugin() lists them all)`, "llms.txt");
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
pages: pageUrls.length,
|
|
235
|
+
signs: { robots: robots !== void 0, sitemap: sitemapFile !== void 0 || Boolean(sitemapLine), llms: llms !== void 0, notFound: has.has("404.html") },
|
|
236
|
+
copies,
|
|
237
|
+
findings: [...found.values()].map((f) => ({ ...f, files: [...new Set(f.files)] }))
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function patrolText(p, shown) {
|
|
241
|
+
const sign = (name, there) => `${name} ${there ? "posted" : "missing"}`;
|
|
242
|
+
let out = `Patrol of ${shown}: ${p.pages} page${p.pages === 1 ? "" : "s"}, ${p.copies} with a Markdown copy
|
|
243
|
+
`;
|
|
244
|
+
out += ` ${[sign("robots.txt", p.signs.robots), sign("sitemap", p.signs.sitemap), sign("llms.txt", p.signs.llms), sign("404.html", p.signs.notFound)].join(", ")}
|
|
245
|
+
`;
|
|
246
|
+
if (!p.findings.length) return `${out}
|
|
247
|
+
All clear: nothing on the trail for an agent to trip on.
|
|
248
|
+
`;
|
|
249
|
+
out += "\n";
|
|
250
|
+
for (const f of p.findings) {
|
|
251
|
+
const n = f.files.length;
|
|
252
|
+
out += `warn[${f.code}]: ${f.message}${n > 1 ? ` (${n})` : ""}
|
|
253
|
+
`;
|
|
254
|
+
for (const file of f.files.slice(0, 5)) out += ` ${file}
|
|
255
|
+
`;
|
|
256
|
+
if (n > 5) out += ` and ${n - 5} more (--format json lists them all)
|
|
257
|
+
`;
|
|
258
|
+
}
|
|
259
|
+
const files = new Set(p.findings.flatMap((f) => f.files)).size;
|
|
260
|
+
out += `
|
|
261
|
+
${p.findings.length} kind${p.findings.length === 1 ? "" : "s"} of warning${files ? ` in ${files} file${files === 1 ? "" : "s"}` : ""}. \`ssqch docs "what patrol checks"\` says what each code means.
|
|
262
|
+
`;
|
|
263
|
+
return out;
|
|
264
|
+
}
|
|
265
|
+
function patrolJson(p, output) {
|
|
266
|
+
return { schemaVersion: 1, output, pages: p.pages, copies: p.copies, signs: p.signs, warnings: p.findings.map((f) => ({ code: f.code, message: f.message, files: f.files })) };
|
|
267
|
+
}
|
|
268
|
+
export {
|
|
269
|
+
patrol,
|
|
270
|
+
patrolJson,
|
|
271
|
+
patrolText
|
|
272
|
+
};
|
|
@@ -2,11 +2,11 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
starterEngines
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FENJHLNM.js";
|
|
6
6
|
import {
|
|
7
7
|
DEFAULTS,
|
|
8
8
|
configOptions
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VILOEVK7.js";
|
|
10
10
|
import {
|
|
11
11
|
VERSION
|
|
12
12
|
} from "./chunk-AD3HAW3W.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-DDV6JEC2.js";
|
|
16
16
|
import {
|
|
17
17
|
red
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-YNJNMQWU.js";
|
|
19
19
|
|
|
20
20
|
// src/commands/capabilities.ts
|
|
21
21
|
var MODULE_EXPORTS = [
|
|
@@ -30,7 +30,12 @@ var MODULE_EXPORTS = [
|
|
|
30
30
|
["ssqch/elements", ["elementsPlugin"]],
|
|
31
31
|
["ssqch/minify", ["minifyPlugin", "minify", "minifyCss"]],
|
|
32
32
|
["ssqch/llms", ["llmsPlugin"]],
|
|
33
|
-
["ssqch/
|
|
33
|
+
["ssqch/robots", ["robotsPlugin"]],
|
|
34
|
+
["ssqch/vue", ["vuePlugin"]],
|
|
35
|
+
["ssqch/from-vitepress", ["fromVitepress"]],
|
|
36
|
+
["ssqch/from-mkdocs", ["fromMkdocs"]],
|
|
37
|
+
["ssqch/from-jekyll", ["fromJekyll"]],
|
|
38
|
+
["ssqch/from-hugo", ["fromHugo"]]
|
|
34
39
|
];
|
|
35
40
|
var NODE_MODULES = ["fs", "fs/promises", "path", "path/posix", "url", "process", "buffer", "crypto", "module", "util", "events", "os", "assert", "assert/strict", "timers", "timers/promises", "string_decoder", "http", "https", "http2", "net", "tls", "dns", "child_process", "worker_threads", "cluster", "readline", "zlib", "vm", "stream", "tty", "perf_hooks"];
|
|
36
41
|
function modules() {
|
|
@@ -53,7 +58,7 @@ async function capabilities(commands) {
|
|
|
53
58
|
schemaVersion: 1,
|
|
54
59
|
version: VERSION,
|
|
55
60
|
commands,
|
|
56
|
-
json: ["build --format json", "
|
|
61
|
+
json: ["build --format json", "trace --format json", "diff --format json", "capabilities --format json", "docs --format json", "serve --ready-file"],
|
|
57
62
|
features,
|
|
58
63
|
configFiles: [...CONFIG_FILES, "sitesquatch.toml"],
|
|
59
64
|
configOptions: configOptions(),
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
fixed,
|
|
8
8
|
profileText,
|
|
9
9
|
summary
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6U5VIQVY.js";
|
|
11
11
|
import "./chunk-DDV6JEC2.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-FJML7INB.js";
|
|
13
|
+
import "./chunk-YNJNMQWU.js";
|
|
14
14
|
import "./chunk-VJWQSYEG.js";
|
|
15
15
|
import "./chunk-I3PS26CI.js";
|
|
16
16
|
export {
|
|
@@ -6,11 +6,14 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
buildFiles,
|
|
8
8
|
urlOf
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-UHRBPZ4A.js";
|
|
10
10
|
import {
|
|
11
11
|
bytes,
|
|
12
12
|
count
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-6U5VIQVY.js";
|
|
14
|
+
import {
|
|
15
|
+
ACCOUNTS_DIFFER
|
|
16
|
+
} from "./chunk-FJML7INB.js";
|
|
14
17
|
import {
|
|
15
18
|
firstChars,
|
|
16
19
|
quoted
|
|
@@ -18,7 +21,7 @@ import {
|
|
|
18
21
|
import {
|
|
19
22
|
BuildError,
|
|
20
23
|
bail
|
|
21
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-YNJNMQWU.js";
|
|
22
25
|
import {
|
|
23
26
|
compareText
|
|
24
27
|
} from "./chunk-VJWQSYEG.js";
|
|
@@ -210,6 +213,28 @@ function attributeValue(raw) {
|
|
|
210
213
|
if (!raw.includes("&")) return raw;
|
|
211
214
|
return raw.replace(ENTITY_OR_AMP, (whole, name) => name === void 0 ? whole : name === "nbsp" ? "\xA0" : entityChar(name) ?? whole);
|
|
212
215
|
}
|
|
216
|
+
var URL_ATTRS = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "poster", "cite", "data"]);
|
|
217
|
+
var UTF8 = new TextDecoder("utf-8", { fatal: true });
|
|
218
|
+
function canonicalUrl(url) {
|
|
219
|
+
if (!url.includes("%")) return url;
|
|
220
|
+
return url.replace(/(?:%[0-9A-Fa-f]{2})+/g, (run) => {
|
|
221
|
+
const bytes2 = Uint8Array.from(run.slice(1).split("%"), (h) => Number.parseInt(h, 16));
|
|
222
|
+
let text;
|
|
223
|
+
try {
|
|
224
|
+
text = UTF8.decode(bytes2);
|
|
225
|
+
} catch {
|
|
226
|
+
return run;
|
|
227
|
+
}
|
|
228
|
+
let out = "";
|
|
229
|
+
let at = 0;
|
|
230
|
+
for (const c of text) {
|
|
231
|
+
const n = Buffer.byteLength(c);
|
|
232
|
+
out += c.charCodeAt(0) > 127 || ' "<>`{}'.includes(c) ? c : run.slice(at * 3, (at + n) * 3);
|
|
233
|
+
at += n;
|
|
234
|
+
}
|
|
235
|
+
return out;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
213
238
|
var NO_ATTRIBUTES = /^<\/?[a-z][a-z0-9-]*>$/;
|
|
214
239
|
function canonicalTag(tag, foreign, xml = false) {
|
|
215
240
|
if (NO_ATTRIBUTES.test(tag)) return [tag, false];
|
|
@@ -266,6 +291,7 @@ function canonicalTag(tag, foreign, xml = false) {
|
|
|
266
291
|
if (attrs.has(attr2)) continue;
|
|
267
292
|
if (value !== void 0 && BOOLEAN.has(attr2) && !foreign && (value === "" || asciiLower(value) === attr2)) value = void 0;
|
|
268
293
|
if (value !== void 0 && SPACED.has(attr2)) value = collapse(value).replace(/ ?, ?/g, ", ");
|
|
294
|
+
if (value !== void 0 && URL_ATTRS.has(attr2)) value = canonicalUrl(value);
|
|
269
295
|
attrs.set(attr2, value);
|
|
270
296
|
}
|
|
271
297
|
if (closing) return [`</${element}>`, false];
|
|
@@ -802,7 +828,7 @@ function onlyDates(list) {
|
|
|
802
828
|
}
|
|
803
829
|
return first;
|
|
804
830
|
}
|
|
805
|
-
var IGNORING = "Ignoring asset fingerprints, image ids, integrity hashes, the generator's version, Vue's and Astro's scope ids and fragment markers, whitespace between tags, and how tags are written where browsers read them the same (attribute order, quotes, entities, `<br/>`) (--exact compares bytes).\n";
|
|
831
|
+
var IGNORING = "Ignoring asset fingerprints, image ids, integrity hashes, the generator's version, Vue's and Astro's scope ids and fragment markers, whitespace between tags, and how tags are written where browsers read them the same (attribute order, quotes, entities, percent-encoding in URLs, `<br/>`) (--exact compares bytes).\n";
|
|
806
832
|
var IMAGES_LISTED = 5;
|
|
807
833
|
function listed(urls, sign) {
|
|
808
834
|
const images = urls.filter(isHashedImage);
|
|
@@ -1081,7 +1107,7 @@ Varies (${report.varies.length})
|
|
|
1081
1107
|
out += grouped ? linesText(sample.ownHunks, sample.ownLines, limit, paint) : linesText(sample.hunks, sample.changedLines, limit, paint);
|
|
1082
1108
|
}
|
|
1083
1109
|
out += `
|
|
1084
|
-
${plural(report.varies.length, "file varies", "files vary")} between builds made the same way; ${steady} are the same in all of them. Pin what changes (the build's time, random ids) before comparing another build with these, or leave it out with --ignore.
|
|
1110
|
+
${ACCOUNTS_DIFFER} ${plural(report.varies.length, "file varies", "files vary")} between builds made the same way; ${steady} are the same in all of them. Pin what changes (the build's time, random ids) before comparing another build with these, or leave it out with --ignore.
|
|
1085
1111
|
`;
|
|
1086
1112
|
const common = report.varies.filter((v) => !v.versions[0].missing && v.versions[0].runs.includes(report.typical)).length;
|
|
1087
1113
|
if (common > 0 && report.varies.some((v) => v.versions[0].runs.length >= 2)) out += `The build most like the others: ${report.runs[report.typical]}, with the most common version of ${common} of the ${plural(report.varies.length, "file", "files")} that vary.
|
|
@@ -1122,6 +1148,7 @@ export {
|
|
|
1122
1148
|
withoutFingerprints,
|
|
1123
1149
|
keyed,
|
|
1124
1150
|
canonicalText,
|
|
1151
|
+
canonicalUrl,
|
|
1125
1152
|
canonicalTag,
|
|
1126
1153
|
tokens,
|
|
1127
1154
|
compare,
|