@dogsbay/ssg-cli 0.2.0-beta.183 → 0.2.0-beta.188
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/AGENTS.md +168 -0
- package/README.md +3 -1
- package/THIRD-PARTY-NOTICES.txt +23 -17
- package/chunks/{build-command-QLNZ5BNK.mjs → build-command-NJATVOUY.mjs} +37 -26
- package/chunks/check-command-FL5O3AXB.mjs +577 -0
- package/chunks/chunk-2EM7IEQT.mjs +95 -0
- package/chunks/{chunk-JABACD5T.mjs → chunk-5A2QPRCV.mjs} +1 -30
- package/chunks/chunk-5NQOUB5I.mjs +4534 -0
- package/chunks/chunk-CYJ6GFVM.mjs +77 -0
- package/chunks/{chunk-KE6N5RFA.mjs → chunk-FFIXBXHD.mjs} +63 -234
- package/chunks/chunk-GFG5I7WI.mjs +807 -0
- package/chunks/chunk-GZ3E45TE.mjs +2290 -0
- package/chunks/chunk-IAAKV7V2.mjs +37 -0
- package/chunks/{chunk-IERF2DNL.mjs → chunk-VJ6AESSJ.mjs} +8072 -8555
- package/chunks/chunk-X3UPCLX5.mjs +503 -0
- package/chunks/{chunk-QDXUP47M.mjs → chunk-ZDH4JRVX.mjs} +1203 -4035
- package/chunks/{chunk-LNWQN7K7.mjs → chunk-ZRGJHNES.mjs} +7 -1
- package/chunks/compare-W4DJYVHT.mjs +239 -0
- package/chunks/compare-command-U36H55IE.mjs +144 -0
- package/chunks/{css-build-VKKTSP6P.mjs → css-build-MKIHYHCX.mjs} +2 -1
- package/chunks/{dev-HXLVZ7MF.mjs → dev-X3PKN4G3.mjs} +77 -25
- package/chunks/{menu-N2AZSZKS.mjs → menu-J3CLVADF.mjs} +9 -5
- package/chunks/{publish-command-UFHG6PJN.mjs → publish-command-SAPICGGM.mjs} +15 -7
- package/chunks/{release-diff-LFDQIFEF.mjs → release-diff-Y7X63MT3.mjs} +13 -6
- package/chunks/{serve-WGWRM7JQ.mjs → serve-7DR4WSYA.mjs} +3 -1
- package/cli.mjs +17 -10
- package/package.json +4 -3
- package/chunks/check-command-5U7VSMDO.mjs +0 -218
- package/chunks/chunk-KFYMG4VB.mjs +0 -45
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CHOICES_HEAD_SCRIPT
|
|
5
|
+
} from "./chunk-VJ6AESSJ.mjs";
|
|
6
|
+
|
|
7
|
+
// node_modules/@dogsbay/elements/dist/chunk-77TPXX44.js
|
|
8
|
+
var ANNOUNCEMENT_HEAD_SCRIPT = `(function(){try{var m=document.querySelector('meta[name="db-announcement"]');if(m&&m.content&&localStorage.getItem("db-announcement-closed:"+m.content))document.documentElement.setAttribute("data-announcement-closed","")}catch(e){}})();`;
|
|
9
|
+
|
|
10
|
+
// node_modules/@dogsbay/elements/dist/chunk-BT45VDJC.js
|
|
11
|
+
var script = (fallback) => `(function(){var s=null;try{s=localStorage.getItem("theme")}catch(e){}var d=s==="dark"||(s!=="light"&&${fallback});document.documentElement.classList.toggle("dark",d)})();`;
|
|
12
|
+
var COLOR_MODE_HEAD_SCRIPTS = Object.freeze({
|
|
13
|
+
system: script('window.matchMedia("(prefers-color-scheme: dark)").matches'),
|
|
14
|
+
light: script("false"),
|
|
15
|
+
dark: script("true")
|
|
16
|
+
});
|
|
17
|
+
var COLOR_MODE_HEAD_SCRIPT_HASHES = Object.freeze({
|
|
18
|
+
system: "sha256-jRauguO5YMPSA4gk/Aoj48u6XqzpdLfrLpCJ27+53lU=",
|
|
19
|
+
light: "sha256-+ikeQCMZHj6kIiZnltLiZGw3+oy+dUNCKb+sZ3FIU/Q=",
|
|
20
|
+
dark: "sha256-rl7pDPoIM2Dkr1KlLP+OVtY1HGFLdszqURk3Let+fKI="
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// src/core/served-base.ts
|
|
24
|
+
var SERVED_BASE_SCRIPT = (
|
|
25
|
+
// No `="` in the text: the Worker's rebaseServedPage rewrites attribute values, and the CSP allows the script by its hash
|
|
26
|
+
"(function(s){var o=s.getAttribute('data-out'),p=location.pathname;if(!o||location.protocol==='file:')return;try{p=decodeURIComponent(p)}catch(e){}if(p.slice(-o.length-1)==='/'+o)return;var b=document.createElement('base');b.href=s.getAttribute('data-root');document.head.appendChild(b);document.addEventListener('DOMContentLoaded',function(){var h=location.href.split('#')[0];document.querySelectorAll('a[href^=\\'#\\']').forEach(function(a){a.href=h+a.getAttribute('href')})})})(document.currentScript)"
|
|
27
|
+
);
|
|
28
|
+
function servedBaseScript(root, out, esc) {
|
|
29
|
+
return `<script data-root="${esc(root)}" data-out="${esc(out)}">${SERVED_BASE_SCRIPT}</script>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
function relocateServedPage(html, prefix, siteRoot) {
|
|
33
|
+
const from = new URL(`https://h/${prefix.replace(/\/*$/, "/")}`);
|
|
34
|
+
return html.replace(/(\s(?:href|src|base|data-unit-root|data-site-root|data-search-page)=")([^"]*)"/g, (m, attr, raw) => {
|
|
35
|
+
const v = unescapeAttr(raw);
|
|
36
|
+
if (v.startsWith("#") || v.startsWith("/") || /^[a-z][a-z0-9+.-]*:/i.test(v)) return m;
|
|
37
|
+
const u = new URL(v, from);
|
|
38
|
+
return `${attr}${escapeAttr(u.pathname.slice(1) + u.search + u.hash || "./")}"`;
|
|
39
|
+
}).replace(/(<script data-root=")[^"]*(" data-out=")[^"]*(">)/, (_, a, b, c) => `${a}${escapeAttr(siteRoot)}${b}404.html${c}`);
|
|
40
|
+
}
|
|
41
|
+
var unescapeAttr = (v) => v.replace(/&(#x[0-9a-f]+|#\d+|amp|quot|apos|lt|gt);/gi, (m, e) => {
|
|
42
|
+
const k = e.toLowerCase();
|
|
43
|
+
if (k.startsWith("#x")) return String.fromCodePoint(parseInt(k.slice(2), 16));
|
|
44
|
+
if (k.startsWith("#")) return String.fromCodePoint(Number(k.slice(1)));
|
|
45
|
+
return { amp: "&", quot: '"', apos: "'", lt: "<", gt: ">" }[k] ?? m;
|
|
46
|
+
});
|
|
47
|
+
var escapeAttr = (v) => v.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
48
|
+
|
|
49
|
+
// src/core/csp.ts
|
|
50
|
+
var FORWARD_SCRIPT = "location.replace(document.documentElement.dataset.to+location.search+location.hash)";
|
|
51
|
+
var INLINE_SCRIPTS = [...new Set(Object.values(COLOR_MODE_HEAD_SCRIPTS)), ANNOUNCEMENT_HEAD_SCRIPT, FORWARD_SCRIPT, CHOICES_HEAD_SCRIPT, SERVED_BASE_SCRIPT];
|
|
52
|
+
var INLINE_HANDLERS = [];
|
|
53
|
+
async function sha256(text) {
|
|
54
|
+
const d = new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text)));
|
|
55
|
+
let bin = "";
|
|
56
|
+
for (const b of d) bin += String.fromCharCode(b);
|
|
57
|
+
return `'sha256-${btoa(bin)}'`;
|
|
58
|
+
}
|
|
59
|
+
var hashes;
|
|
60
|
+
function cspHashes() {
|
|
61
|
+
return hashes ??= Promise.all([Promise.all(INLINE_SCRIPTS.map(sha256)), Promise.all(INLINE_HANDLERS.map(sha256))]).then(([scripts, handlers]) => ({ scripts, handlers }));
|
|
62
|
+
}
|
|
63
|
+
async function sitePolicy(scripts) {
|
|
64
|
+
const h = await cspHashes();
|
|
65
|
+
const handlers = h.handlers.length ? ["'unsafe-hashes'", ...h.handlers] : [];
|
|
66
|
+
return [`script-src ${[scripts, ...h.scripts, ...handlers].join(" ")}`, "object-src 'none'", `base-uri ${scripts}`].join("; ");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
ANNOUNCEMENT_HEAD_SCRIPT,
|
|
71
|
+
COLOR_MODE_HEAD_SCRIPTS,
|
|
72
|
+
servedBaseScript,
|
|
73
|
+
relocateServedPage,
|
|
74
|
+
FORWARD_SCRIPT,
|
|
75
|
+
INLINE_SCRIPTS,
|
|
76
|
+
sitePolicy
|
|
77
|
+
};
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
Comment,
|
|
5
|
-
ConfigError,
|
|
6
5
|
Document,
|
|
7
6
|
Element,
|
|
8
7
|
ProcessingInstruction,
|
|
9
8
|
Text,
|
|
10
9
|
build,
|
|
11
|
-
buildUnits,
|
|
12
10
|
cloneNode,
|
|
13
11
|
esm_default,
|
|
14
12
|
esm_exports,
|
|
@@ -29,25 +27,37 @@ import {
|
|
|
29
27
|
linkBaseDir,
|
|
30
28
|
nextElementSibling,
|
|
31
29
|
pageKeyCandidates,
|
|
32
|
-
parseConfig,
|
|
33
30
|
parseDocument,
|
|
34
31
|
prevElementSibling,
|
|
35
32
|
removeElement,
|
|
36
33
|
resolveLinkPath,
|
|
37
|
-
sameProduct,
|
|
38
34
|
splitHref,
|
|
39
35
|
textContent,
|
|
40
|
-
uniqueSort
|
|
36
|
+
uniqueSort
|
|
37
|
+
} from "./chunk-ZDH4JRVX.mjs";
|
|
38
|
+
import {
|
|
39
|
+
slugFromPath
|
|
40
|
+
} from "./chunk-2EM7IEQT.mjs";
|
|
41
|
+
import {
|
|
42
|
+
ConfigError,
|
|
43
|
+
buildUnits,
|
|
44
|
+
compareRelease,
|
|
45
|
+
flat,
|
|
46
|
+
pageKey,
|
|
47
|
+
parseConfig,
|
|
48
|
+
releaseBaseline,
|
|
49
|
+
releasePage,
|
|
50
|
+
sameProduct,
|
|
51
|
+
titleOf,
|
|
41
52
|
unitOfPath,
|
|
42
53
|
versionsOf
|
|
43
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-5NQOUB5I.mjs";
|
|
44
55
|
import {
|
|
45
56
|
checkFrontmatter,
|
|
46
57
|
detectLeadingNodes,
|
|
47
58
|
extractFirstParagraph,
|
|
48
|
-
frontmatterKeyLines
|
|
49
|
-
|
|
50
|
-
} from "./chunk-IERF2DNL.mjs";
|
|
59
|
+
frontmatterKeyLines
|
|
60
|
+
} from "./chunk-VJ6AESSJ.mjs";
|
|
51
61
|
import {
|
|
52
62
|
__commonJS,
|
|
53
63
|
__export,
|
|
@@ -239,11 +249,11 @@ var require_parse = __commonJS({
|
|
|
239
249
|
function parseSelector(subselects2, selector, selectorIndex) {
|
|
240
250
|
var tokens = [];
|
|
241
251
|
function getName(offset) {
|
|
242
|
-
var
|
|
243
|
-
if (!
|
|
252
|
+
var match = selector.slice(selectorIndex + offset).match(reName);
|
|
253
|
+
if (!match) {
|
|
244
254
|
throw new Error("Expected name, found ".concat(selector.slice(selectorIndex)));
|
|
245
255
|
}
|
|
246
|
-
var name =
|
|
256
|
+
var name = match[0];
|
|
247
257
|
selectorIndex += offset + name.length;
|
|
248
258
|
return unescapeCSS(name);
|
|
249
259
|
}
|
|
@@ -17215,15 +17225,15 @@ var require_mock_utils = __commonJS({
|
|
|
17215
17225
|
}
|
|
17216
17226
|
} = __require("node:util");
|
|
17217
17227
|
var { InvalidArgumentError } = require_errors();
|
|
17218
|
-
function matchValue(
|
|
17219
|
-
if (typeof
|
|
17220
|
-
return
|
|
17228
|
+
function matchValue(match, value) {
|
|
17229
|
+
if (typeof match === "string") {
|
|
17230
|
+
return match === value;
|
|
17221
17231
|
}
|
|
17222
|
-
if (
|
|
17223
|
-
return
|
|
17232
|
+
if (match instanceof RegExp) {
|
|
17233
|
+
return match.test(value);
|
|
17224
17234
|
}
|
|
17225
|
-
if (typeof
|
|
17226
|
-
return
|
|
17235
|
+
if (typeof match === "function") {
|
|
17236
|
+
return match(value) === true;
|
|
17227
17237
|
}
|
|
17228
17238
|
return false;
|
|
17229
17239
|
}
|
|
@@ -18396,13 +18406,13 @@ var require_snapshot_recorder = __commonJS({
|
|
|
18396
18406
|
caseSensitive = false
|
|
18397
18407
|
} = matchOptions;
|
|
18398
18408
|
const filtered = {};
|
|
18399
|
-
const { ignore, exclude, match
|
|
18409
|
+
const { ignore, exclude, match } = headerFilters;
|
|
18400
18410
|
for (const [key, value] of Object.entries(headers)) {
|
|
18401
18411
|
const headerKey = caseSensitive ? key : key.toLowerCase();
|
|
18402
18412
|
if (exclude.has(headerKey)) continue;
|
|
18403
18413
|
if (ignore.has(headerKey)) continue;
|
|
18404
|
-
if (
|
|
18405
|
-
if (!
|
|
18414
|
+
if (match.size !== 0) {
|
|
18415
|
+
if (!match.has(headerKey)) continue;
|
|
18406
18416
|
}
|
|
18407
18417
|
filtered[headerKey] = value;
|
|
18408
18418
|
}
|
|
@@ -30856,26 +30866,6 @@ var titleMissing = {
|
|
|
30856
30866
|
}
|
|
30857
30867
|
};
|
|
30858
30868
|
|
|
30859
|
-
// node_modules/@dogsbay/site-check/dist/lib/page.js
|
|
30860
|
-
function titleOf(page) {
|
|
30861
|
-
const fm = page.frontmatter?.["title"];
|
|
30862
|
-
return (typeof fm === "string" && fm.trim() ? fm : page.title ?? "").trim();
|
|
30863
|
-
}
|
|
30864
|
-
function flat(s) {
|
|
30865
|
-
return JSON.parse(JSON.stringify(s));
|
|
30866
|
-
}
|
|
30867
|
-
function pageKey(pathOrUrl, urlBase = "") {
|
|
30868
|
-
let p = pathOrUrl.replace(/[?#].*$/, "");
|
|
30869
|
-
const m = /^[a-z][a-z0-9+.-]*:\/\/[^/]*(.*)$/i.exec(p) ?? /^\/\/[^/]*(.*)$/.exec(p);
|
|
30870
|
-
if (m)
|
|
30871
|
-
p = m[1];
|
|
30872
|
-
p = p.replace(/^\/+/, "");
|
|
30873
|
-
const base = urlBase.replace(/^\/+|\/+$/g, "");
|
|
30874
|
-
if (m && base && (p === base || p.startsWith(base + "/")))
|
|
30875
|
-
p = p.slice(base.length);
|
|
30876
|
-
return p.replace(/^\/+|\/+$/g, "").replace(/(^|\/)index\.html$/, "").replace(/\.html$/, "").replace(/\/+$/, "");
|
|
30877
|
-
}
|
|
30878
|
-
|
|
30879
30869
|
// node_modules/@dogsbay/site-check/dist/rules/seo/duplicate-title.js
|
|
30880
30870
|
var duplicateTitle = {
|
|
30881
30871
|
id: "seo/duplicate-title",
|
|
@@ -30981,7 +30971,7 @@ var sitemapPresent = {
|
|
|
30981
30971
|
stage: "dist",
|
|
30982
30972
|
scope: "site",
|
|
30983
30973
|
severity: "error",
|
|
30984
|
-
description: "`sitemap.xml` (or `sitemap-index.xml`) exists at the dist root and parses.",
|
|
30974
|
+
description: "`sitemap.xml` (or `sitemap-index.xml`) exists at the dist root and parses. A site with no `site.url` has no sitemap by design: reported as info.",
|
|
30985
30975
|
run(ctx) {
|
|
30986
30976
|
if (!ctx.readFile)
|
|
30987
30977
|
return [];
|
|
@@ -30990,7 +30980,14 @@ var sitemapPresent = {
|
|
|
30990
30980
|
return [];
|
|
30991
30981
|
state.emitted.add("seo/sitemap-present");
|
|
30992
30982
|
const issues = [];
|
|
30993
|
-
if (!state.sitemapPath) {
|
|
30983
|
+
if (!state.sitemapPath && !ctx.config?.siteUrl) {
|
|
30984
|
+
issues.push({
|
|
30985
|
+
ruleId: "seo/sitemap-present",
|
|
30986
|
+
severity: "info",
|
|
30987
|
+
file: "sitemap.xml",
|
|
30988
|
+
message: "No sitemap: the site has no `site.url`, and a sitemap needs absolute URLs. Set `site.url` in dogsbay.config.yml to get one."
|
|
30989
|
+
});
|
|
30990
|
+
} else if (!state.sitemapPath) {
|
|
30994
30991
|
issues.push({
|
|
30995
30992
|
ruleId: "seo/sitemap-present",
|
|
30996
30993
|
severity: "error",
|
|
@@ -31897,7 +31894,7 @@ function walkInline(nodes, visit) {
|
|
|
31897
31894
|
walkInline(node.children, visit);
|
|
31898
31895
|
} else if (node.type === "image" && typeof node.src === "string") {
|
|
31899
31896
|
visit(node.src, "image");
|
|
31900
|
-
} else if (node.type === "highlight" && node.children) {
|
|
31897
|
+
} else if ((node.type === "highlight" || node.type === "when") && node.children) {
|
|
31901
31898
|
walkInline(node.children, visit);
|
|
31902
31899
|
}
|
|
31903
31900
|
}
|
|
@@ -34275,35 +34272,35 @@ function map(fn) {
|
|
|
34275
34272
|
}
|
|
34276
34273
|
return this._make(elems);
|
|
34277
34274
|
}
|
|
34278
|
-
function getFilterFn(
|
|
34279
|
-
if (typeof
|
|
34280
|
-
return (el, i) =>
|
|
34275
|
+
function getFilterFn(match) {
|
|
34276
|
+
if (typeof match === "function") {
|
|
34277
|
+
return (el, i) => match.call(el, i, el);
|
|
34281
34278
|
}
|
|
34282
|
-
if (isCheerio(
|
|
34283
|
-
return (el) => Array.prototype.includes.call(
|
|
34279
|
+
if (isCheerio(match)) {
|
|
34280
|
+
return (el) => Array.prototype.includes.call(match, el);
|
|
34284
34281
|
}
|
|
34285
34282
|
return function(el) {
|
|
34286
|
-
return
|
|
34283
|
+
return match === el;
|
|
34287
34284
|
};
|
|
34288
34285
|
}
|
|
34289
|
-
function filter2(
|
|
34286
|
+
function filter2(match) {
|
|
34290
34287
|
var _a3;
|
|
34291
|
-
return this._make(filterArray(this.toArray(),
|
|
34288
|
+
return this._make(filterArray(this.toArray(), match, this.options.xmlMode, (_a3 = this._root) === null || _a3 === void 0 ? void 0 : _a3[0]));
|
|
34292
34289
|
}
|
|
34293
|
-
function filterArray(nodes,
|
|
34294
|
-
return typeof
|
|
34290
|
+
function filterArray(nodes, match, xmlMode, root2) {
|
|
34291
|
+
return typeof match === "string" ? filter(match, nodes, { xmlMode, root: root2 }) : nodes.filter(getFilterFn(match));
|
|
34295
34292
|
}
|
|
34296
34293
|
function is3(selector) {
|
|
34297
34294
|
const nodes = this.toArray();
|
|
34298
34295
|
return typeof selector === "string" ? some(nodes.filter(isTag), selector, this.options) : selector ? nodes.some(getFilterFn(selector)) : false;
|
|
34299
34296
|
}
|
|
34300
|
-
function not(
|
|
34297
|
+
function not(match) {
|
|
34301
34298
|
let nodes = this.toArray();
|
|
34302
|
-
if (typeof
|
|
34303
|
-
const matches = new Set(filter(
|
|
34299
|
+
if (typeof match === "string") {
|
|
34300
|
+
const matches = new Set(filter(match, nodes, this.options));
|
|
34304
34301
|
nodes = nodes.filter((el) => !matches.has(el));
|
|
34305
34302
|
} else {
|
|
34306
|
-
const filterFn = getFilterFn(
|
|
34303
|
+
const filterFn = getFilterFn(match);
|
|
34307
34304
|
nodes = nodes.filter((el, i) => !filterFn(el, i));
|
|
34308
34305
|
}
|
|
34309
34306
|
return this._make(nodes);
|
|
@@ -42872,15 +42869,15 @@ var getCodePoint = (
|
|
|
42872
42869
|
);
|
|
42873
42870
|
function getEscaper(regex, map2) {
|
|
42874
42871
|
return function escape(data2) {
|
|
42875
|
-
let
|
|
42872
|
+
let match;
|
|
42876
42873
|
let lastIndex = 0;
|
|
42877
42874
|
let result = "";
|
|
42878
|
-
while (
|
|
42879
|
-
if (lastIndex !==
|
|
42880
|
-
result += data2.substring(lastIndex,
|
|
42875
|
+
while (match = regex.exec(data2)) {
|
|
42876
|
+
if (lastIndex !== match.index) {
|
|
42877
|
+
result += data2.substring(lastIndex, match.index);
|
|
42881
42878
|
}
|
|
42882
|
-
result += map2.get(
|
|
42883
|
-
lastIndex =
|
|
42879
|
+
result += map2.get(match[0].charCodeAt(0));
|
|
42880
|
+
lastIndex = match.index + 1;
|
|
42884
42881
|
}
|
|
42885
42882
|
return result + data2.substring(lastIndex);
|
|
42886
42883
|
};
|
|
@@ -43493,7 +43490,7 @@ function collectInline(nodes, visit) {
|
|
|
43493
43490
|
collectInline(node.children, visit);
|
|
43494
43491
|
} else if (node.type === "image" && typeof node.src === "string") {
|
|
43495
43492
|
visit(node.src, "image");
|
|
43496
|
-
} else if (node.type === "highlight" && node.children) {
|
|
43493
|
+
} else if ((node.type === "highlight" || node.type === "when") && node.children) {
|
|
43497
43494
|
collectInline(node.children, visit);
|
|
43498
43495
|
}
|
|
43499
43496
|
}
|
|
@@ -43520,174 +43517,6 @@ function robotsMeta(html3) {
|
|
|
43520
43517
|
return "";
|
|
43521
43518
|
}
|
|
43522
43519
|
|
|
43523
|
-
// node_modules/@dogsbay/site-check/dist/lib/release.js
|
|
43524
|
-
var MOVED_SIMILARITY = 0.6;
|
|
43525
|
-
var MIN_SHINGLES = 8;
|
|
43526
|
-
function compareRelease(input) {
|
|
43527
|
-
const toPaths = new Set(input.to.map((p) => p.path));
|
|
43528
|
-
const fromPaths = new Set(input.from.map((p) => p.path));
|
|
43529
|
-
const removed = new Set((input.removed ?? []).map(normalizeRemoved));
|
|
43530
|
-
const fresh = input.to.filter((p) => !fromPaths.has(p.path)).sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
43531
|
-
const entries = [];
|
|
43532
|
-
for (const page of input.from) {
|
|
43533
|
-
if (toPaths.has(page.path))
|
|
43534
|
-
continue;
|
|
43535
|
-
const about = { ...page.source !== void 0 ? { source: page.source } : {}, ...page.index ? { index: true } : {} };
|
|
43536
|
-
const redirect = input.redirects?.get(page.path);
|
|
43537
|
-
if (redirect !== void 0) {
|
|
43538
|
-
entries.push({ path: page.path, status: "redirected", to: redirect, ...about });
|
|
43539
|
-
continue;
|
|
43540
|
-
}
|
|
43541
|
-
if (removed.has(page.path)) {
|
|
43542
|
-
entries.push({ path: page.path, status: "removed-ok", ...about });
|
|
43543
|
-
continue;
|
|
43544
|
-
}
|
|
43545
|
-
entries.push({ ...match(page, fresh, toPaths, input.renames), ...about });
|
|
43546
|
-
}
|
|
43547
|
-
return entries;
|
|
43548
|
-
}
|
|
43549
|
-
function normalizeRemoved(raw) {
|
|
43550
|
-
const p = raw.trim().replace(/^\/+|\/+$/g, "").replace(/\.(md|markdown|mdx)$/i, "").replace(/(^|\/)index$/, "");
|
|
43551
|
-
return p || "index";
|
|
43552
|
-
}
|
|
43553
|
-
function match(page, fresh, toPaths, renames) {
|
|
43554
|
-
const renamed = renames?.get(page.path);
|
|
43555
|
-
if (renamed !== void 0 && toPaths.has(renamed)) {
|
|
43556
|
-
return { path: page.path, status: "moved", to: renamed, evidence: ["git rename"] };
|
|
43557
|
-
}
|
|
43558
|
-
if (page.id) {
|
|
43559
|
-
const same = fresh.find((p) => p.id === page.id);
|
|
43560
|
-
if (same)
|
|
43561
|
-
return { path: page.path, status: "moved", to: same.path, evidence: ["same id"] };
|
|
43562
|
-
}
|
|
43563
|
-
let best;
|
|
43564
|
-
let bestScore = 0;
|
|
43565
|
-
for (const p of page.shingles >= MIN_SHINGLES ? fresh : []) {
|
|
43566
|
-
if (p.shingles < MIN_SHINGLES)
|
|
43567
|
-
continue;
|
|
43568
|
-
const s = similarity(page.signature, p.signature);
|
|
43569
|
-
if (s > bestScore) {
|
|
43570
|
-
best = p;
|
|
43571
|
-
bestScore = s;
|
|
43572
|
-
}
|
|
43573
|
-
}
|
|
43574
|
-
if (best && bestScore >= MOVED_SIMILARITY) {
|
|
43575
|
-
return { path: page.path, status: "moved", to: best.path, evidence: [`same text, ${Math.round(bestScore * 100)}%`] };
|
|
43576
|
-
}
|
|
43577
|
-
const title = page.title.toLowerCase();
|
|
43578
|
-
const byTitle = title ? fresh.find((p) => p.title.toLowerCase() === title) : void 0;
|
|
43579
|
-
if (byTitle)
|
|
43580
|
-
return { path: page.path, status: "candidate", to: byTitle.path, evidence: ["same title"] };
|
|
43581
|
-
const name = baseName(page.path);
|
|
43582
|
-
const byName = fresh.find((p) => baseName(p.path) === name);
|
|
43583
|
-
if (byName)
|
|
43584
|
-
return { path: page.path, status: "candidate", to: byName.path, evidence: ["same file name"] };
|
|
43585
|
-
return { path: page.path, status: "removed" };
|
|
43586
|
-
}
|
|
43587
|
-
function baseName(path) {
|
|
43588
|
-
const parts = path.split("/").filter((s) => s !== "index");
|
|
43589
|
-
return parts[parts.length - 1] ?? "index";
|
|
43590
|
-
}
|
|
43591
|
-
var HASHES = 64;
|
|
43592
|
-
var SHINGLE = 5;
|
|
43593
|
-
function releasePage(page, path, o = {}) {
|
|
43594
|
-
const id = page.frontmatter?.["id"];
|
|
43595
|
-
const text3 = treeText(page.tree);
|
|
43596
|
-
return {
|
|
43597
|
-
path: flat(path),
|
|
43598
|
-
title: flat(titleOf(page)),
|
|
43599
|
-
...typeof id === "string" && id.trim() ? { id: flat(id.trim()) } : {},
|
|
43600
|
-
...o.source !== void 0 ? { source: flat(o.source) } : {},
|
|
43601
|
-
...o.index && path !== "index" ? { index: true } : {},
|
|
43602
|
-
signature: signature(text3),
|
|
43603
|
-
shingles: shingleCount(text3)
|
|
43604
|
-
};
|
|
43605
|
-
}
|
|
43606
|
-
function shingleCount(text3) {
|
|
43607
|
-
const words = text3.match(/[\p{L}\p{N}]+/gu)?.length ?? 0;
|
|
43608
|
-
return words ? Math.max(1, words - SHINGLE + 1) : 0;
|
|
43609
|
-
}
|
|
43610
|
-
function signature(text3) {
|
|
43611
|
-
const words = text3.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
43612
|
-
const mins = new Array(HASHES).fill(4294967295);
|
|
43613
|
-
if (!words.length)
|
|
43614
|
-
return mins;
|
|
43615
|
-
const count = Math.max(1, words.length - SHINGLE + 1);
|
|
43616
|
-
for (let i = 0; i < count; i++) {
|
|
43617
|
-
const h = fnv1a(words.slice(i, i + SHINGLE).join(" "));
|
|
43618
|
-
for (let k = 0; k < HASHES; k++) {
|
|
43619
|
-
const v = mix(h, k);
|
|
43620
|
-
if (v < mins[k])
|
|
43621
|
-
mins[k] = v;
|
|
43622
|
-
}
|
|
43623
|
-
}
|
|
43624
|
-
return mins;
|
|
43625
|
-
}
|
|
43626
|
-
function similarity(a, b) {
|
|
43627
|
-
if (a.length !== b.length || !a.length || a[0] === 4294967295 || b[0] === 4294967295)
|
|
43628
|
-
return 0;
|
|
43629
|
-
let same = 0;
|
|
43630
|
-
for (let i = 0; i < a.length; i++)
|
|
43631
|
-
if (a[i] === b[i])
|
|
43632
|
-
same++;
|
|
43633
|
-
return same / a.length;
|
|
43634
|
-
}
|
|
43635
|
-
function fnv1a(s) {
|
|
43636
|
-
let h = 2166136261;
|
|
43637
|
-
for (let i = 0; i < s.length; i++) {
|
|
43638
|
-
h ^= s.charCodeAt(i);
|
|
43639
|
-
h = Math.imul(h, 16777619);
|
|
43640
|
-
}
|
|
43641
|
-
return h >>> 0;
|
|
43642
|
-
}
|
|
43643
|
-
function mix(h, k) {
|
|
43644
|
-
let x = (h ^ Math.imul(k + 1, 2654435769)) >>> 0;
|
|
43645
|
-
x ^= x >>> 16;
|
|
43646
|
-
x = Math.imul(x, 2246822507);
|
|
43647
|
-
x ^= x >>> 13;
|
|
43648
|
-
x = Math.imul(x, 3266489909);
|
|
43649
|
-
x ^= x >>> 16;
|
|
43650
|
-
return x >>> 0;
|
|
43651
|
-
}
|
|
43652
|
-
function treeText(nodes) {
|
|
43653
|
-
const out = [];
|
|
43654
|
-
const walk2 = (list2) => {
|
|
43655
|
-
for (const node of list2) {
|
|
43656
|
-
if (node.inline)
|
|
43657
|
-
out.push(inlineText2(node.inline));
|
|
43658
|
-
if (node.html)
|
|
43659
|
-
out.push(node.html.replace(/<[^>]+>/g, " "));
|
|
43660
|
-
if (typeof node.props?.code === "string")
|
|
43661
|
-
out.push(node.props.code);
|
|
43662
|
-
if (node.children)
|
|
43663
|
-
walk2(node.children);
|
|
43664
|
-
}
|
|
43665
|
-
};
|
|
43666
|
-
walk2(nodes);
|
|
43667
|
-
return out.join(" ");
|
|
43668
|
-
}
|
|
43669
|
-
function inlineText2(nodes) {
|
|
43670
|
-
let s = "";
|
|
43671
|
-
for (const n of nodes) {
|
|
43672
|
-
if (typeof n.text === "string")
|
|
43673
|
-
s += n.text;
|
|
43674
|
-
else if (typeof n.value === "string")
|
|
43675
|
-
s += n.value;
|
|
43676
|
-
if (Array.isArray(n.children))
|
|
43677
|
-
s += inlineText2(n.children);
|
|
43678
|
-
s += " ";
|
|
43679
|
-
}
|
|
43680
|
-
return s;
|
|
43681
|
-
}
|
|
43682
|
-
function releaseBaseline(versions, defaultVersion, from) {
|
|
43683
|
-
if (from !== void 0)
|
|
43684
|
-
return versions.some((v) => v.id === from) && from !== defaultVersion ? from : void 0;
|
|
43685
|
-
const i = versions.findIndex((v) => v.id === defaultVersion);
|
|
43686
|
-
if (i < 0)
|
|
43687
|
-
return void 0;
|
|
43688
|
-
return versions.slice(i + 1).find((v) => !v.prerelease && !v.hidden)?.id;
|
|
43689
|
-
}
|
|
43690
|
-
|
|
43691
43520
|
// node_modules/@dogsbay/site-check/dist/index.js
|
|
43692
43521
|
function registerSharedRules() {
|
|
43693
43522
|
registerSeoRules();
|