clean-jsdoc-theme 5.1.1 → 5.2.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/dist/publish.js CHANGED
@@ -1,1387 +1,1632 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/publish.ts
31
- var publish_exports = {};
32
- __export(publish_exports, {
33
- cleanOutputDirEnabled: () => cleanOutputDirEnabled,
34
- collectDocs: () => collectDocs,
35
- collectStaticFiles: () => collectStaticFiles,
36
- computeRelPaths: () => computeRelPaths,
37
- createImageCollector: () => createImageCollector,
38
- hasMarkdownPlugin: () => hasMarkdownPlugin,
39
- normalizeColors: () => normalizeColors,
40
- normalizeCopyPage: () => normalizeCopyPage,
41
- normalizeDocGroups: () => normalizeDocGroups,
42
- normalizeMenu: () => normalizeMenu,
43
- normalizeMeta: () => normalizeMeta,
44
- normalizePageNav: () => normalizePageNav,
45
- normalizePlayground: () => normalizePlayground,
46
- normalizeSectionOrder: () => normalizeSectionOrder,
47
- normalizeStaticFilesConfig: () => normalizeStaticFilesConfig,
48
- outputSourceFilesEnabled: () => outputSourceFilesEnabled,
49
- overlayDocs: () => overlayDocs,
50
- publish: () => publish,
51
- readStaticFilesConfig: () => readStaticFilesConfig,
52
- resolveDocImages: () => resolveDocImages,
53
- resolveDocletImages: () => resolveDocletImages,
54
- resolveFavicon: () => resolveFavicon,
55
- resolveFooter: () => resolveFooter,
56
- resolveTutorialImages: () => resolveTutorialImages,
57
- sourceLinkToCommentEnabled: () => sourceLinkToCommentEnabled,
58
- staticFileIncluded: () => staticFileIncluded,
59
- staticFileOutputName: () => staticFileOutputName
60
- });
61
- module.exports = __toCommonJS(publish_exports);
62
- var import_promises2 = require("fs/promises");
63
- var import_node_fs = require("fs");
64
- var import_node_crypto = require("crypto");
65
- var import_node_path2 = require("path");
66
- var import_node_url = require("url");
67
-
68
- // src/write-output-files.ts
69
- var import_promises = require("fs/promises");
70
- var import_node_path = require("path");
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ let node_fs_promises = require("node:fs/promises");
4
+ let node_fs = require("node:fs");
5
+ let node_crypto = require("node:crypto");
6
+ let node_path = require("node:path");
7
+ let node_url = require("node:url");
8
+ //#region src/write-output-files.ts
71
9
  async function writeOutputFiles(destination, files) {
72
- for (const file of files) {
73
- const target = (0, import_node_path.join)(destination, file.path);
74
- await (0, import_promises.mkdir)((0, import_node_path.dirname)(target), { recursive: true });
75
- const contents = typeof file.contents === "string" ? file.contents : Buffer.from(file.contents);
76
- await (0, import_promises.writeFile)(target, contents);
77
- }
10
+ for (const file of files) {
11
+ const target = (0, node_path.join)(destination, file.path);
12
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(target), { recursive: true });
13
+ const contents = typeof file.contents === "string" ? file.contents : Buffer.from(file.contents);
14
+ await (0, node_fs_promises.writeFile)(target, contents);
15
+ }
78
16
  }
79
-
80
- // src/publish.ts
81
- var JSDOC_TUTORIAL_TYPE_MARKDOWN = 2;
17
+ //#endregion
18
+ //#region src/publish.ts
19
+ const JSDOC_TUTORIAL_TYPE_MARKDOWN = 2;
82
20
  function anchorPath() {
83
- if (typeof __filename === "string") return __filename;
84
- throw new Error(
85
- "clean-jsdoc-theme: could not determine the running module path (__filename is unavailable)."
86
- );
21
+ if (typeof __filename === "string") return __filename;
22
+ throw new Error("clean-jsdoc-theme: could not determine the running module path (__filename is unavailable).");
87
23
  }
88
24
  function resolvePackageDir(name) {
89
- const start = anchorPath();
90
- let dir = (0, import_node_path2.dirname)(start);
91
- let prev = "";
92
- while (dir !== prev) {
93
- const candidate = (0, import_node_path2.resolve)(dir, "node_modules", name);
94
- try {
95
- (0, import_node_fs.readFileSync)((0, import_node_path2.resolve)(candidate, "package.json"), "utf8");
96
- return candidate;
97
- } catch {
98
- }
99
- prev = dir;
100
- dir = (0, import_node_path2.dirname)(dir);
101
- }
102
- throw new Error(`clean-jsdoc-theme: could not locate '${name}' on disk starting from ${start}.`);
25
+ const start = anchorPath();
26
+ let dir = (0, node_path.dirname)(start);
27
+ let prev = "";
28
+ while (dir !== prev) {
29
+ const candidate = (0, node_path.resolve)(dir, "node_modules", name);
30
+ try {
31
+ (0, node_fs.readFileSync)((0, node_path.resolve)(candidate, "package.json"), "utf8");
32
+ return candidate;
33
+ } catch {}
34
+ prev = dir;
35
+ dir = (0, node_path.dirname)(dir);
36
+ }
37
+ throw new Error(`clean-jsdoc-theme: could not locate '${name}' on disk starting from ${start}.`);
103
38
  }
39
+ /**
40
+ * Resolve an `exports` condition subtree (a string target, or a conditions
41
+ * object like `{ import, require, default, types }`) to an absolute path,
42
+ * preferring the ESM condition (`import`, then a bare `default`). Recurses for
43
+ * nested conditions (`import: { default: "…" }`). Returns `undefined` when no
44
+ * usable target is present.
45
+ */
104
46
  function resolveExportTarget(node, pkgRoot) {
105
- if (typeof node === "string") return (0, import_node_path2.resolve)(pkgRoot, node);
106
- if (!node || typeof node !== "object") return void 0;
107
- const o = node;
108
- const imp = resolveExportTarget(o.import, pkgRoot);
109
- if (imp) return imp;
110
- if (typeof o.default === "string") return (0, import_node_path2.resolve)(pkgRoot, o.default);
111
- return void 0;
47
+ if (typeof node === "string") return (0, node_path.resolve)(pkgRoot, node);
48
+ if (!node || typeof node !== "object") return void 0;
49
+ const o = node;
50
+ const imp = resolveExportTarget(o.import, pkgRoot);
51
+ if (imp) return imp;
52
+ if (typeof o.default === "string") return (0, node_path.resolve)(pkgRoot, o.default);
112
53
  }
113
54
  function resolveEsmEntry(name) {
114
- const pkgRoot = resolvePackageDir(name);
115
- const pkg = JSON.parse(
116
- (0, import_node_fs.readFileSync)((0, import_node_path2.resolve)(pkgRoot, "package.json"), "utf8")
117
- );
118
- const exp = pkg.exports;
119
- if (typeof exp === "string") return (0, import_node_path2.resolve)(pkgRoot, exp);
120
- if (exp && typeof exp === "object") {
121
- const dot = exp["."];
122
- const target = resolveExportTarget(dot !== void 0 ? dot : exp, pkgRoot);
123
- if (target) return target;
124
- }
125
- if (typeof pkg.module === "string") return (0, import_node_path2.resolve)(pkgRoot, pkg.module);
126
- if (typeof pkg.main === "string") return (0, import_node_path2.resolve)(pkgRoot, pkg.main);
127
- throw new Error(
128
- `clean-jsdoc-theme: could not determine ESM entry file for '${name}' (no exports/module/main).`
129
- );
55
+ const pkgRoot = resolvePackageDir(name);
56
+ const pkg = JSON.parse((0, node_fs.readFileSync)((0, node_path.resolve)(pkgRoot, "package.json"), "utf8"));
57
+ const exp = pkg.exports;
58
+ if (typeof exp === "string") return (0, node_path.resolve)(pkgRoot, exp);
59
+ if (exp && typeof exp === "object") {
60
+ const dot = exp["."];
61
+ const target = resolveExportTarget(dot !== void 0 ? dot : exp, pkgRoot);
62
+ if (target) return target;
63
+ }
64
+ if (typeof pkg.module === "string") return (0, node_path.resolve)(pkgRoot, pkg.module);
65
+ if (typeof pkg.main === "string") return (0, node_path.resolve)(pkgRoot, pkg.main);
66
+ throw new Error(`clean-jsdoc-theme: could not determine ESM entry file for '${name}' (no exports/module/main).`);
130
67
  }
131
68
  async function loadDep(name, requiredExports) {
132
- const entry = resolveEsmEntry(name);
133
- const id = (0, import_node_url.pathToFileURL)(entry).href;
134
- const mod = await import(id);
135
- for (const key of requiredExports) {
136
- if (typeof mod[key] !== "function") {
137
- throw new Error(
138
- `clean-jsdoc-theme: '${name}' did not export a '${key}' function (resolved from ${entry}; got keys: ${Object.keys(mod).join(", ") || "(none)"}).`
139
- );
140
- }
141
- }
142
- return mod;
69
+ const entry = resolveEsmEntry(name);
70
+ const mod = await import((0, node_url.pathToFileURL)(entry).href);
71
+ for (const key of requiredExports) if (typeof mod[key] !== "function") throw new Error(`clean-jsdoc-theme: '${name}' did not export a '${key}' function (resolved from ${entry}; got keys: ${Object.keys(mod).join(", ") || "(none)"}).`);
72
+ return mod;
143
73
  }
144
- var loadSetu = () => loadDep("@clean-jsdoc-theme/setu", ["generateSite", "stampSite"]);
145
- var loadDwar = () => loadDep("@clean-jsdoc-theme/dwar", ["render", "runPagefindAgainstDir"]);
146
- var loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
147
- "validateThemeOpts",
148
- "createGoogleFontResolver",
149
- "formatDiagnostics",
150
- "formatBuildReport",
151
- "formatRenderError",
152
- "normalizeBasePath",
153
- "withBase",
154
- "toExtractManifest",
155
- "normalizeCollapsibleSidebarSections",
156
- "unmatchedCollapsibleSections",
157
- "topLevelSectionLabels",
158
- "normalizeScrollbar"
74
+ const loadSetu = () => loadDep("@clean-jsdoc-theme/setu", ["generateSite", "stampSite"]);
75
+ const loadDwar = () => loadDep("@clean-jsdoc-theme/dwar", ["render"]);
76
+ const loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
77
+ "validateThemeOpts",
78
+ "createGoogleFontResolver",
79
+ "formatDiagnostics",
80
+ "warningsOnly",
81
+ "formatBuildReport",
82
+ "formatRenderError",
83
+ "normalizeBasePath",
84
+ "withBase",
85
+ "toExtractManifest",
86
+ "normalizeCollapsibleSidebarSections",
87
+ "unmatchedCollapsibleSections",
88
+ "topLevelSectionLabels",
89
+ "normalizeScrollbar"
159
90
  ]);
160
- var loadOra = async () => {
161
- try {
162
- const mod = await loadDep("ora", ["default"]);
163
- return mod.default;
164
- } catch {
165
- return null;
166
- }
91
+ /**
92
+ * Load `ora` (ESM-only) the same way as the other deps — via a resolved
93
+ * `file://` URL so the CJS bundle doesn't `require()` it. Returns `null` if
94
+ * `ora` can't be loaded, so progress degrades to silent rather than failing
95
+ * the build.
96
+ */
97
+ const loadOra = async () => {
98
+ try {
99
+ return (await loadDep("ora", ["default"])).default;
100
+ } catch {
101
+ return null;
102
+ }
167
103
  };
168
- var JSDOC_OWN_OPTS = /* @__PURE__ */ new Set([
169
- "destination",
170
- "template",
171
- "encoding",
172
- "recurse",
173
- "readme",
174
- "package",
175
- "tutorials",
176
- "query",
177
- "private",
178
- "access",
179
- "explain",
180
- "debug",
181
- "verbose",
182
- "pedantic",
183
- "match",
184
- "nocolor",
185
- "templates"
104
+ /**
105
+ * JSDoc's own standard `opts` keys (`jsdoc/lib/jsdoc/opts/argparser.js` +
106
+ * `conf` schema). These share the flat `opts` namespace with the theme's
107
+ * options, so they must never be flagged as unknown theme keys — even by a
108
+ * near-miss typo distance. Theme keys (`docs`, `docGroups`, …) live in
109
+ * `THEME_OPT_KEYS`, NOT here.
110
+ */
111
+ const JSDOC_OWN_OPTS = /* @__PURE__ */ new Set([
112
+ "destination",
113
+ "template",
114
+ "encoding",
115
+ "recurse",
116
+ "readme",
117
+ "package",
118
+ "tutorials",
119
+ "query",
120
+ "private",
121
+ "access",
122
+ "explain",
123
+ "debug",
124
+ "verbose",
125
+ "pedantic",
126
+ "match",
127
+ "nocolor",
128
+ "templates"
186
129
  ]);
187
- var defaultTheme = {
188
- tokens: {
189
- // Light palette (oklch). bg #fdfdf7 · fg #3e3e3e · border #eeeeee;
190
- // muted/accent derived to harmonize.
191
- colors: {
192
- bg: "oklch(0.9924 0.0079 106.54)",
193
- bgMuted: "oklch(0.9595 0.0079 106.55)",
194
- fg: "oklch(0.3639 0 0)",
195
- fgMuted: "oklch(0.5278 0 0)",
196
- accent: "oklch(0 0 0)",
197
- accentFg: "oklch(1 0 0)",
198
- border: "oklch(0.9561 0 0)"
199
- },
200
- // Dark palette (oklch). bg #09090b · fg #9e9e9e · border #141416;
201
- // muted/accent derived to harmonize.
202
- darkColors: {
203
- bg: "oklch(0.1408 0.0044 285.82)",
204
- bgMuted: "oklch(0.2103 0.0059 285.89)",
205
- fg: "oklch(0.6993 0 0)",
206
- fgMuted: "oklch(0.5382 0 0)",
207
- accent: "oklch(1 0 0)",
208
- accentFg: "oklch(0 0 0)",
209
- border: "oklch(0.2321 0.004 286.02)"
210
- },
211
- fonts: {
212
- heading: "Source Serif 4",
213
- body: "Roboto",
214
- mono: "ui-monospace, SFMono-Regular, Menlo, monospace"
215
- },
216
- shiki: { light: "github-light", dark: "github-dark" }
217
- },
218
- basePath: "/"
130
+ const defaultTheme = {
131
+ tokens: {
132
+ colors: {
133
+ bg: "oklch(0.9924 0.0079 106.54)",
134
+ bgMuted: "oklch(0.9595 0.0079 106.55)",
135
+ fg: "oklch(0.3639 0 0)",
136
+ fgMuted: "oklch(0.5278 0 0)",
137
+ accent: "oklch(0 0 0)",
138
+ accentFg: "oklch(1 0 0)",
139
+ border: "oklch(0.9561 0 0)"
140
+ },
141
+ darkColors: {
142
+ bg: "oklch(0.1408 0.0044 285.82)",
143
+ bgMuted: "oklch(0.2103 0.0059 285.89)",
144
+ fg: "oklch(0.6993 0 0)",
145
+ fgMuted: "oklch(0.5382 0 0)",
146
+ accent: "oklch(1 0 0)",
147
+ accentFg: "oklch(0 0 0)",
148
+ border: "oklch(0.2321 0.004 286.02)"
149
+ },
150
+ fonts: {
151
+ heading: "Source Serif 4",
152
+ body: "Roboto",
153
+ mono: "ui-monospace, SFMono-Regular, Menlo, monospace"
154
+ },
155
+ shiki: {
156
+ light: "github-light",
157
+ dark: "github-dark"
158
+ }
159
+ },
160
+ basePath: "/"
219
161
  };
162
+ /**
163
+ * Resolve the font triple for the active `locale`: a per-locale override wins,
164
+ * then the base font, then the theme default — per slot. With no locale (a
165
+ * normal, non-localized build) only the base + default apply, so the result is
166
+ * byte-identical to before per-locale fonts existed.
167
+ */
220
168
  function resolveFontSet(fonts, locale) {
221
- const base = defaultTheme.tokens.fonts;
222
- const override = locale && fonts.locales?.[locale] || {};
223
- return {
224
- heading: override.heading ?? fonts.heading ?? base.heading,
225
- body: override.body ?? fonts.body ?? base.body,
226
- mono: override.mono ?? fonts.mono ?? base.mono
227
- };
169
+ const base = defaultTheme.tokens.fonts;
170
+ const override = locale && fonts.locales?.[locale] || {};
171
+ return {
172
+ heading: override.heading ?? fonts.heading ?? base.heading,
173
+ body: override.body ?? fonts.body ?? base.body,
174
+ mono: override.mono ?? fonts.mono ?? base.mono
175
+ };
228
176
  }
177
+ /**
178
+ * Merge validated user overrides from `jsdoc.json` (`siteName`, `fonts`) over
179
+ * the defaults. Only the keys the user supplies are overridden; everything else
180
+ * keeps the default theme. `siteName` is pre-resolved/validated and its local
181
+ * logos copied by `prepareSiteName`; `fonts` is the validated subset (any
182
+ * family flagged `fonts/not-google` is dropped upstream so the default applies).
183
+ * `locale` (set in build mode) selects per-locale font overrides.
184
+ */
229
185
  function resolveTheme(opts, siteName, fonts, basePath, locale) {
230
- const aiPrompt = typeof opts.aiPrompt === "string" && opts.aiPrompt.trim() ? opts.aiPrompt.trim() : void 0;
231
- const copyPage = normalizeCopyPage(opts.copyPage);
232
- const pageNav = normalizePageNav(opts.pageNav);
233
- const playground = normalizePlayground(opts.playground);
234
- const colors = normalizeColors(opts.colors);
235
- const darkColors = normalizeColors(opts.darkColors);
236
- return {
237
- ...defaultTheme,
238
- basePath,
239
- ...aiPrompt ? { aiPrompt } : {},
240
- ...copyPage ? { copyPage } : {},
241
- ...pageNav ? { pageNav } : {},
242
- ...playground ? { playground: playground.theme } : {},
243
- tokens: {
244
- ...defaultTheme.tokens,
245
- colors: { ...defaultTheme.tokens.colors, ...colors ?? {} },
246
- darkColors: { ...defaultTheme.tokens.darkColors, ...darkColors ?? {} },
247
- fonts: resolveFontSet(fonts, locale),
248
- ...siteName ? { siteName } : {}
249
- }
250
- };
186
+ const aiPrompt = typeof opts.aiPrompt === "string" && opts.aiPrompt.trim() ? opts.aiPrompt.trim() : void 0;
187
+ const copyPage = normalizeCopyPage(opts.copyPage);
188
+ const pageNav = normalizePageNav(opts.pageNav);
189
+ const playground = normalizePlayground(opts.playground);
190
+ const colors = normalizeColors(opts.colors);
191
+ const darkColors = normalizeColors(opts.darkColors);
192
+ return {
193
+ ...defaultTheme,
194
+ basePath,
195
+ ...aiPrompt ? { aiPrompt } : {},
196
+ ...copyPage ? { copyPage } : {},
197
+ ...pageNav ? { pageNav } : {},
198
+ ...playground ? { playground: playground.theme } : {},
199
+ tokens: {
200
+ ...defaultTheme.tokens,
201
+ colors: {
202
+ ...defaultTheme.tokens.colors,
203
+ ...colors ?? {}
204
+ },
205
+ darkColors: {
206
+ ...defaultTheme.tokens.darkColors,
207
+ ...darkColors ?? {}
208
+ },
209
+ fonts: resolveFontSet(fonts, locale),
210
+ ...siteName ? { siteName } : {}
211
+ }
212
+ };
251
213
  }
214
+ /** Trim a value to a non-empty string, or `undefined`. */
252
215
  function nonEmptyString(value) {
253
- return typeof value === "string" && value.trim().length > 0 ? value : void 0;
216
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
254
217
  }
218
+ /**
219
+ * Short, deterministic content hash for cache-stable custom-asset filenames.
220
+ * Derived from the file's bytes (NOT random), so an unchanged file produces the
221
+ * same name across builds (browser cache hit) and a changed file cache-busts.
222
+ */
255
223
  function contentHash(bytes) {
256
- return (0, import_node_crypto.createHash)("sha256").update(bytes).digest("hex").slice(0, 8);
224
+ return (0, node_crypto.createHash)("sha256").update(bytes).digest("hex").slice(0, 8);
257
225
  }
226
+ /**
227
+ * Copy custom CSS/JS file(s) (a path or array, relative to the working dir) to
228
+ * served `_assets` files and return their hrefs. Each file is copied AS-IS (its
229
+ * own bytes — never concatenated). The asset name is `<base>.<hash>.<ext>` when
230
+ * `hash` is on (the hash is content-derived → stable URL for unchanged files),
231
+ * else the bare `<base><ext>`. A file that can't be read is skipped with a
232
+ * warning (resilient, like `prepareSiteName`); an identical served name is
233
+ * emitted once.
234
+ */
258
235
  async function copyCustomFiles(raw, ext, hash, label, hrefForServed) {
259
- const paths = (Array.isArray(raw) ? raw : [raw]).filter(
260
- (p) => typeof p === "string" && p.trim().length > 0
261
- );
262
- const links = [];
263
- const files = [];
264
- const seen = /* @__PURE__ */ new Set();
265
- for (const p of paths) {
266
- const trimmed = p.trim();
267
- let bytes;
268
- try {
269
- bytes = await (0, import_promises2.readFile)((0, import_node_path2.resolve)(trimmed));
270
- } catch {
271
- console.warn(`clean-jsdoc-theme: could not read ${label} ('${trimmed}'); skipping it.`);
272
- continue;
273
- }
274
- const base = (0, import_node_path2.basename)(trimmed, (0, import_node_path2.extname)(trimmed)) || "custom";
275
- const name = hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`;
276
- const servedPath = `_assets/${name}`;
277
- if (seen.has(servedPath)) continue;
278
- seen.add(servedPath);
279
- files.push({ path: servedPath, contents: bytes });
280
- links.push(hrefForServed(servedPath));
281
- }
282
- return { links, files };
236
+ const paths = (Array.isArray(raw) ? raw : [raw]).filter((p) => typeof p === "string" && p.trim().length > 0);
237
+ const links = [];
238
+ const files = [];
239
+ const seen = /* @__PURE__ */ new Set();
240
+ for (const p of paths) {
241
+ const trimmed = p.trim();
242
+ let bytes;
243
+ try {
244
+ bytes = await (0, node_fs_promises.readFile)((0, node_path.resolve)(trimmed));
245
+ } catch {
246
+ console.warn(`clean-jsdoc-theme: could not read ${label} ('${trimmed}'); skipping it.`);
247
+ continue;
248
+ }
249
+ const base = (0, node_path.basename)(trimmed, (0, node_path.extname)(trimmed)) || "custom";
250
+ const servedPath = `_assets/${hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`}`;
251
+ if (seen.has(servedPath)) continue;
252
+ seen.add(servedPath);
253
+ files.push({
254
+ path: servedPath,
255
+ contents: bytes
256
+ });
257
+ links.push(hrefForServed(servedPath));
258
+ }
259
+ return {
260
+ links,
261
+ files
262
+ };
283
263
  }
264
+ /**
265
+ * Resolve the custom CSS/JS injection options into render-ready `ThemeConfig`
266
+ * fields plus the asset files to write. Inline strings (`customCss`/`customJs`)
267
+ * pass through; file options (`customCssFile`/`customJsFile`) are read + copied
268
+ * to content-hashed assets here — the bridge is the I/O layer, so dwar's
269
+ * `render()` stays pure and just links the resulting hrefs. `hashCustomAssets`
270
+ * (default `true`) toggles the content-hash suffix.
271
+ */
284
272
  async function resolveCustomAssets(opts, hrefForServed) {
285
- const hash = opts.hashCustomAssets !== false;
286
- const [cssAssets, jsAssets] = await Promise.all([
287
- copyCustomFiles(opts.customCssFile, ".css", hash, "customCssFile", hrefForServed),
288
- copyCustomFiles(opts.customJsFile, ".js", hash, "customJsFile", hrefForServed)
289
- ]);
290
- const customCss = nonEmptyString(opts.customCss)?.trim();
291
- const customJs = nonEmptyString(opts.customJs)?.trim();
292
- return {
293
- theme: {
294
- ...customCss ? { customCss } : {},
295
- ...cssAssets.links.length > 0 ? { customCssLinks: cssAssets.links } : {},
296
- ...customJs ? { customJs } : {},
297
- ...jsAssets.links.length > 0 ? { customJsLinks: jsAssets.links } : {}
298
- },
299
- files: [...cssAssets.files, ...jsAssets.files]
300
- };
273
+ const hash = opts.hashCustomAssets !== false;
274
+ const [cssAssets, jsAssets] = await Promise.all([copyCustomFiles(opts.customCssFile, ".css", hash, "customCssFile", hrefForServed), copyCustomFiles(opts.customJsFile, ".js", hash, "customJsFile", hrefForServed)]);
275
+ const customCss = nonEmptyString(opts.customCss)?.trim();
276
+ const customJs = nonEmptyString(opts.customJs)?.trim();
277
+ return {
278
+ theme: {
279
+ ...customCss ? { customCss } : {},
280
+ ...cssAssets.links.length > 0 ? { customCssLinks: cssAssets.links } : {},
281
+ ...customJs ? { customJs } : {},
282
+ ...jsAssets.links.length > 0 ? { customJsLinks: jsAssets.links } : {}
283
+ },
284
+ files: [...cssAssets.files, ...jsAssets.files]
285
+ };
301
286
  }
287
+ /**
288
+ * Resolve `opts.footer` (inline HTML `string` | `{ file }`) into the single
289
+ * `ThemeConfig.footer` string. The `{ file }` form is read from disk HERE — the
290
+ * bridge is the I/O layer, so dwar's `render()` only ever sees the resolved
291
+ * string. A missing/unreadable file is warned about and dropped (resilient,
292
+ * like the logo/custom-asset paths), and an empty value yields `undefined` so
293
+ * the default footer renders. Exported for testing.
294
+ */
302
295
  async function resolveFooter(raw) {
303
- if (typeof raw === "string") {
304
- const trimmed = raw.trim();
305
- return trimmed.length > 0 ? trimmed : void 0;
306
- }
307
- if (raw && typeof raw === "object" && typeof raw.file === "string") {
308
- const file = raw.file.trim();
309
- if (!file) return void 0;
310
- try {
311
- const html = await (0, import_promises2.readFile)((0, import_node_path2.resolve)(file), "utf8");
312
- return html.trim().length > 0 ? html : void 0;
313
- } catch {
314
- console.warn(
315
- `clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`
316
- );
317
- return void 0;
318
- }
319
- }
320
- return void 0;
296
+ if (typeof raw === "string") {
297
+ const trimmed = raw.trim();
298
+ return trimmed.length > 0 ? trimmed : void 0;
299
+ }
300
+ if (raw && typeof raw === "object" && typeof raw.file === "string") {
301
+ const file = raw.file.trim();
302
+ if (!file) return void 0;
303
+ try {
304
+ const html = await (0, node_fs_promises.readFile)((0, node_path.resolve)(file), "utf8");
305
+ return html.trim().length > 0 ? html : void 0;
306
+ } catch {
307
+ console.warn(`clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`);
308
+ return;
309
+ }
310
+ }
321
311
  }
312
+ /**
313
+ * Resolve `opts.favicon` (a file path) into a served `_assets/` href + the file
314
+ * to write — the bridge is the I/O layer, so dwar only sees the final URL and
315
+ * `render()` stays pure. The asset name is content-hashed (cache-busted) unless
316
+ * `hash` is off, and the source extension is preserved so dwar can derive the
317
+ * `<link>` `type`. A missing/unreadable file is warned about and dropped
318
+ * (resilient, like the logo/custom-asset paths). Exported for testing.
319
+ */
322
320
  async function resolveFavicon(raw, hash, hrefForServed) {
323
- if (typeof raw !== "string" || raw.trim().length === 0) return void 0;
324
- const trimmed = raw.trim();
325
- let bytes;
326
- try {
327
- bytes = await (0, import_promises2.readFile)((0, import_node_path2.resolve)(trimmed));
328
- } catch {
329
- console.warn(`clean-jsdoc-theme: could not read favicon ('${trimmed}'); omitting it.`);
330
- return void 0;
331
- }
332
- const ext = (0, import_node_path2.extname)(trimmed) || ".ico";
333
- const base = (0, import_node_path2.basename)(trimmed, (0, import_node_path2.extname)(trimmed)) || "favicon";
334
- const name = hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`;
335
- const servedPath = `_assets/${name}`;
336
- return { href: hrefForServed(servedPath), files: [{ path: servedPath, contents: bytes }] };
321
+ if (typeof raw !== "string" || raw.trim().length === 0) return void 0;
322
+ const trimmed = raw.trim();
323
+ let bytes;
324
+ try {
325
+ bytes = await (0, node_fs_promises.readFile)((0, node_path.resolve)(trimmed));
326
+ } catch {
327
+ console.warn(`clean-jsdoc-theme: could not read favicon ('${trimmed}'); omitting it.`);
328
+ return;
329
+ }
330
+ const ext = (0, node_path.extname)(trimmed) || ".ico";
331
+ const base = (0, node_path.basename)(trimmed, (0, node_path.extname)(trimmed)) || "favicon";
332
+ const servedPath = `_assets/${hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`}`;
333
+ return {
334
+ href: hrefForServed(servedPath),
335
+ files: [{
336
+ path: servedPath,
337
+ contents: bytes
338
+ }]
339
+ };
337
340
  }
338
- var META_IDENTITY_ATTRS = ["name", "property", "http-equiv", "charset", "itemprop"];
341
+ /** Attributes that identify a `<meta>` tag (so an entry must carry at least one). */
342
+ const META_IDENTITY_ATTRS = [
343
+ "name",
344
+ "property",
345
+ "http-equiv",
346
+ "charset",
347
+ "itemprop"
348
+ ];
349
+ /**
350
+ * Validate `opts.meta` into a clean `MetaTag[]` (attribute maps), or `undefined`
351
+ * when there's nothing usable. Accepts only an array of objects; within each,
352
+ * keeps string→string pairs (trimming the value, coercing finite numbers to
353
+ * strings for convenience) and drops the rest. An entry with no recognized
354
+ * identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
355
+ * dropped with a warning — dwar does the final escaping + key validation.
356
+ */
339
357
  function normalizeMeta(raw) {
340
- if (!Array.isArray(raw)) return void 0;
341
- const out = [];
342
- for (const entry of raw) {
343
- if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
344
- const o = entry;
345
- const tag = {};
346
- for (const [k, v] of Object.entries(o)) {
347
- if (typeof v === "string") {
348
- const t = v.trim();
349
- if (t.length > 0) tag[k] = t;
350
- } else if (typeof v === "number" && Number.isFinite(v)) {
351
- tag[k] = String(v);
352
- }
353
- }
354
- const hasIdentity = META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string");
355
- if (!hasIdentity || Object.keys(tag).length === 0) {
356
- console.warn(
357
- `clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`
358
- );
359
- continue;
360
- }
361
- out.push(tag);
362
- }
363
- return out.length > 0 ? out : void 0;
358
+ if (!Array.isArray(raw)) return void 0;
359
+ const out = [];
360
+ for (const entry of raw) {
361
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
362
+ const o = entry;
363
+ const tag = {};
364
+ for (const [k, v] of Object.entries(o)) if (typeof v === "string") {
365
+ const t = v.trim();
366
+ if (t.length > 0) tag[k] = t;
367
+ } else if (typeof v === "number" && Number.isFinite(v)) tag[k] = String(v);
368
+ if (!META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string") || Object.keys(tag).length === 0) {
369
+ console.warn(`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`);
370
+ continue;
371
+ }
372
+ out.push(tag);
373
+ }
374
+ return out.length > 0 ? out : void 0;
364
375
  }
376
+ /** A logo value that's already a servable URL/URI needs no copying. */
365
377
  function isServableUrl(value) {
366
- return /^(https?:)?\/\//i.test(value) || /^data:/i.test(value);
378
+ return /^(https?:)?\/\//i.test(value) || /^data:/i.test(value);
367
379
  }
380
+ /**
381
+ * Resolve `opts.siteName` into a render-ready value plus any image files to
382
+ * write. A string passes through (trimmed). For a logo set, each local image
383
+ * path is read and emitted as a content-hashed output asset
384
+ * (`_assets/logo-<key>.<hash><ext>`, cache-busted like the custom assets) with
385
+ * its value rewritten to the served path; `http(s)://` / `data:` values pass
386
+ * through untouched, and the `alt` label is preserved. A path that can't be
387
+ * read is left verbatim with a warning rather than aborting the build.
388
+ */
368
389
  async function prepareSiteName(raw, hrefForServed) {
369
- if (typeof raw === "string") {
370
- const trimmed = raw.trim();
371
- return { siteName: trimmed.length > 0 ? trimmed : void 0, files: [] };
372
- }
373
- if (!raw || typeof raw !== "object") return { siteName: void 0, files: [] };
374
- const files = [];
375
- const out = {};
376
- if (typeof raw.alt === "string" && raw.alt.trim().length > 0) out.alt = raw.alt.trim();
377
- for (const key of ["default", "dark", "light"]) {
378
- const value = raw[key];
379
- if (typeof value !== "string" || value.trim().length === 0) continue;
380
- const v = value.trim();
381
- if (isServableUrl(v)) {
382
- out[key] = v;
383
- continue;
384
- }
385
- try {
386
- const abs = (0, import_node_path2.resolve)(v);
387
- const buf = await (0, import_promises2.readFile)(abs);
388
- const served = `_assets/logo-${key}.${contentHash(buf)}${(0, import_node_path2.extname)(abs)}`;
389
- files.push({ path: served, contents: buf });
390
- out[key] = hrefForServed(served);
391
- } catch {
392
- console.warn(
393
- `clean-jsdoc-theme: could not read logo image for siteName.${key} ('${v}'); using it verbatim.`
394
- );
395
- out[key] = v;
396
- }
397
- }
398
- const hasContent = out.default || out.dark || out.light || out.alt;
399
- return { siteName: hasContent ? out : void 0, files };
390
+ if (typeof raw === "string") {
391
+ const trimmed = raw.trim();
392
+ return {
393
+ siteName: trimmed.length > 0 ? trimmed : void 0,
394
+ files: []
395
+ };
396
+ }
397
+ if (!raw || typeof raw !== "object") return {
398
+ siteName: void 0,
399
+ files: []
400
+ };
401
+ const files = [];
402
+ const out = {};
403
+ if (typeof raw.alt === "string" && raw.alt.trim().length > 0) out.alt = raw.alt.trim();
404
+ for (const key of [
405
+ "default",
406
+ "dark",
407
+ "light"
408
+ ]) {
409
+ const value = raw[key];
410
+ if (typeof value !== "string" || value.trim().length === 0) continue;
411
+ const v = value.trim();
412
+ if (isServableUrl(v)) {
413
+ out[key] = v;
414
+ continue;
415
+ }
416
+ try {
417
+ const abs = (0, node_path.resolve)(v);
418
+ const buf = await (0, node_fs_promises.readFile)(abs);
419
+ const served = `_assets/logo-${key}.${contentHash(buf)}${(0, node_path.extname)(abs)}`;
420
+ files.push({
421
+ path: served,
422
+ contents: buf
423
+ });
424
+ out[key] = hrefForServed(served);
425
+ } catch {
426
+ console.warn(`clean-jsdoc-theme: could not read logo image for siteName.${key} ('${v}'); using it verbatim.`);
427
+ out[key] = v;
428
+ }
429
+ }
430
+ return {
431
+ siteName: out.default || out.dark || out.light || out.alt ? out : void 0,
432
+ files
433
+ };
400
434
  }
401
435
  async function resolvePkg(data, opts) {
402
- if (typeof opts.package === "string" && opts.package.length > 0) {
403
- try {
404
- const json = await (0, import_promises2.readFile)(opts.package, "utf8");
405
- const parsed = JSON.parse(json);
406
- return pickPkgFields(parsed);
407
- } catch {
408
- }
409
- }
410
- if (typeof data === "function") {
411
- try {
412
- const pkgDoclets = data({ kind: "package" }).get();
413
- if (Array.isArray(pkgDoclets) && pkgDoclets.length > 0) {
414
- return pickPkgFields(pkgDoclets[0]);
415
- }
416
- } catch {
417
- }
418
- }
419
- return void 0;
436
+ if (typeof opts.package === "string" && opts.package.length > 0) try {
437
+ const json = await (0, node_fs_promises.readFile)(opts.package, "utf8");
438
+ return pickPkgFields(JSON.parse(json));
439
+ } catch {}
440
+ if (typeof data === "function") try {
441
+ const pkgDoclets = data({ kind: "package" }).get();
442
+ if (Array.isArray(pkgDoclets) && pkgDoclets.length > 0) return pickPkgFields(pkgDoclets[0]);
443
+ } catch {}
420
444
  }
421
445
  function pickPkgFields(raw) {
422
- const pkg = {};
423
- if (typeof raw.name === "string") pkg.name = raw.name;
424
- if (typeof raw.version === "string") pkg.version = raw.version;
425
- if (typeof raw.description === "string") pkg.description = raw.description;
426
- if (typeof raw.homepage === "string") pkg.homepage = raw.homepage;
427
- if (typeof raw.repository === "string") {
428
- pkg.repository = raw.repository;
429
- } else if (raw.repository && typeof raw.repository === "object" && typeof raw.repository.url === "string") {
430
- pkg.repository = raw.repository.url;
431
- }
432
- return pkg;
446
+ const pkg = {};
447
+ if (typeof raw.name === "string") pkg.name = raw.name;
448
+ if (typeof raw.version === "string") pkg.version = raw.version;
449
+ if (typeof raw.description === "string") pkg.description = raw.description;
450
+ if (typeof raw.homepage === "string") pkg.homepage = raw.homepage;
451
+ if (typeof raw.repository === "string") pkg.repository = raw.repository;
452
+ else if (raw.repository && typeof raw.repository === "object" && typeof raw.repository.url === "string") pkg.repository = raw.repository.url;
453
+ return pkg;
433
454
  }
455
+ /**
456
+ * Normalize JSDoc's tutorial resolver tree (the `tutorials` arg to `publish`)
457
+ * into setu's plain {@link TutorialInput} shape. The root's `children` are the
458
+ * top-level tutorials; each child carries its own `children`, so a depth-first
459
+ * walk preserves the resolved hierarchy. Content is taken raw (`.content`);
460
+ * `.type === 2` (MARKDOWN) is markdown, everything else is treated as HTML.
461
+ */
434
462
  function normalizeTutorials(root) {
435
- const walk = (node) => {
436
- const name = typeof node.name === "string" ? node.name : "";
437
- if (!name) return null;
438
- const title = typeof node.title === "string" && node.title.length > 0 ? node.title : name;
439
- const content = typeof node.content === "string" ? node.content : "";
440
- const type = node.type === JSDOC_TUTORIAL_TYPE_MARKDOWN ? "markdown" : "html";
441
- const children2 = Array.isArray(node.children) ? node.children.map(walk).filter((t) => t !== null) : [];
442
- return { name, title, content, type, children: children2 };
443
- };
444
- const children = root?.children;
445
- if (!Array.isArray(children)) return [];
446
- return children.map(walk).filter((t) => t !== null);
463
+ const walk = (node) => {
464
+ const name = typeof node.name === "string" ? node.name : "";
465
+ if (!name) return null;
466
+ return {
467
+ name,
468
+ title: typeof node.title === "string" && node.title.length > 0 ? node.title : name,
469
+ content: typeof node.content === "string" ? node.content : "",
470
+ type: node.type === JSDOC_TUTORIAL_TYPE_MARKDOWN ? "markdown" : "html",
471
+ children: Array.isArray(node.children) ? node.children.map(walk).filter((t) => t !== null) : []
472
+ };
473
+ };
474
+ const children = root?.children;
475
+ if (!Array.isArray(children)) return [];
476
+ return children.map(walk).filter((t) => t !== null);
447
477
  }
478
+ /**
479
+ * Resolve JSDoc's `templates.default.outputSourceFiles` flag. The `opts` arg
480
+ * `publish` receives is `env.opts` — the `opts` block — which does NOT carry the
481
+ * root-level `templates` block, so we probe in priority order and default ON:
482
+ * 1. `require('jsdoc/env').conf.templates.default.outputSourceFiles` (the
483
+ * canonical location at runtime; wrapped in try/catch so a missing
484
+ * `jsdoc/env` — e.g. in unit tests — never throws the build).
485
+ * 2. `opts.templates.default.outputSourceFiles` (in case a user nests it
486
+ * under `opts`).
487
+ * Resolves to `false` ONLY when one of those is exactly `=== false`; otherwise
488
+ * `true` (matching JSDoc's default-template default).
489
+ */
448
490
  function outputSourceFilesEnabled(opts) {
449
- try {
450
- const env = require("jsdoc/env");
451
- if (env?.conf?.templates?.default?.outputSourceFiles === false) return false;
452
- } catch {
453
- }
454
- if (opts?.templates?.default?.outputSourceFiles === false) return false;
455
- return true;
491
+ try {
492
+ if (require("jsdoc/env")?.conf?.templates?.default?.outputSourceFiles === false) return false;
493
+ } catch {}
494
+ if (opts?.templates?.default?.outputSourceFiles === false) return false;
495
+ return true;
456
496
  }
497
+ /**
498
+ * Resolve `templates.default.sourceLinkToComment`. Probed in the same priority
499
+ * order as {@link outputSourceFilesEnabled} (canonical `jsdoc/env` conf, then a
500
+ * nested `opts.templates` fallback). Resolves to `true` ONLY when one of those
501
+ * is exactly `=== true`; otherwise `false` (the default: links jump to code).
502
+ */
457
503
  function sourceLinkToCommentEnabled(opts) {
458
- try {
459
- const env = require("jsdoc/env");
460
- if (env?.conf?.templates?.default?.sourceLinkToComment === true) return true;
461
- } catch {
462
- }
463
- if (opts?.templates?.default?.sourceLinkToComment === true) return true;
464
- return false;
504
+ try {
505
+ if (require("jsdoc/env")?.conf?.templates?.default?.sourceLinkToComment === true) return true;
506
+ } catch {}
507
+ if (opts?.templates?.default?.sourceLinkToComment === true) return true;
508
+ return false;
465
509
  }
510
+ /**
511
+ * Resolve `templates.default.cleanOutputDir`. Probed in the same priority order
512
+ * as {@link outputSourceFilesEnabled} (canonical `jsdoc/env` conf, then a nested
513
+ * `opts.templates` fallback). Defaults to `true` — the build empties its
514
+ * destination first so a page removed or renamed between runs (e.g. a deleted
515
+ * class, or a stale content-hashed `styles.<hash>.css`) doesn't linger in the
516
+ * served site. Resolves to `false` ONLY when one is exactly `=== false`.
517
+ */
466
518
  function cleanOutputDirEnabled(opts) {
467
- try {
468
- const env = require("jsdoc/env");
469
- if (env?.conf?.templates?.default?.cleanOutputDir === false) return false;
470
- } catch {
471
- }
472
- if (opts?.templates?.default?.cleanOutputDir === false) return false;
473
- return true;
519
+ try {
520
+ if (require("jsdoc/env")?.conf?.templates?.default?.cleanOutputDir === false) return false;
521
+ } catch {}
522
+ if (opts?.templates?.default?.cleanOutputDir === false) return false;
523
+ return true;
474
524
  }
525
+ /**
526
+ * Whether a JSDoc `conf.plugins` list enables the bundled `plugins/markdown`
527
+ * plugin. The theme relies on it: JSDoc runs `plugins/markdown` to convert the
528
+ * Markdown in doclet descriptions/tags to HTML *before* `publish` ever sees the
529
+ * doclets, so without it descriptions arrive as raw Markdown and render wrong.
530
+ * Pure + exported for testing — accepts the `plugins` array (module specifiers,
531
+ * e.g. `"plugins/markdown"`; tolerant of a `.js` suffix or path separators).
532
+ */
475
533
  function hasMarkdownPlugin(plugins) {
476
- if (!Array.isArray(plugins)) return false;
477
- return plugins.some((p) => typeof p === "string" && /(^|[\\/])markdown(\.js)?$/i.test(p.trim()));
534
+ if (!Array.isArray(plugins)) return false;
535
+ return plugins.some((p) => typeof p === "string" && /(^|[\\/])markdown(\.js)?$/i.test(p.trim()));
478
536
  }
537
+ /**
538
+ * Hard-require JSDoc's `plugins/markdown` plugin (see {@link hasMarkdownPlugin}).
539
+ * Reads the merged config from `require('jsdoc/env').conf.plugins` — the
540
+ * canonical location at runtime — and throws if the plugin is absent so the
541
+ * build stops early with an actionable message. When `jsdoc/env` can't be
542
+ * resolved (e.g. unit tests, or a non-JSDoc caller) the check is skipped: the
543
+ * plugin list is unknowable there, so it can't be enforced.
544
+ */
479
545
  function assertMarkdownPlugin() {
480
- let conf;
481
- try {
482
- conf = require("jsdoc/env").conf;
483
- } catch {
484
- return;
485
- }
486
- if (!conf) return;
487
- if (!hasMarkdownPlugin(conf.plugins)) {
488
- throw new Error(
489
- `clean-jsdoc-theme requires JSDoc's "plugins/markdown" plugin, which renders Markdown in doclet descriptions to HTML. Add it to your jsdoc.json:
490
-
491
- "plugins": ["plugins/markdown"]
492
- `
493
- );
494
- }
546
+ let conf;
547
+ try {
548
+ conf = require("jsdoc/env").conf;
549
+ } catch {
550
+ return;
551
+ }
552
+ if (!conf) return;
553
+ if (!hasMarkdownPlugin(conf.plugins)) throw new Error("clean-jsdoc-theme requires JSDoc's \"plugins/markdown\" plugin, which renders Markdown in doclet descriptions to HTML. Add it to your jsdoc.json:\n\n \"plugins\": [\"plugins/markdown\"]\n");
495
554
  }
555
+ /**
556
+ * Validate `opts.sectionOrder` into a clean `string[]`, or `undefined` to fall
557
+ * back to setu's default order. Accepts only an array; trims string entries and
558
+ * drops non-strings/empties. An array that yields no usable labels → `undefined`.
559
+ */
496
560
  function normalizeSectionOrder(raw) {
497
- if (!Array.isArray(raw)) return void 0;
498
- const out = raw.filter((s) => typeof s === "string").map((s) => s.trim()).filter((s) => s.length > 0);
499
- return out.length > 0 ? out : void 0;
561
+ if (!Array.isArray(raw)) return void 0;
562
+ const out = raw.filter((s) => typeof s === "string").map((s) => s.trim()).filter((s) => s.length > 0);
563
+ return out.length > 0 ? out : void 0;
500
564
  }
565
+ /**
566
+ * Validate `opts.menu` into a clean `MenuItem[]`, or `undefined` when there's no
567
+ * usable menu. Accepts only an array of objects; trims string fields. The link
568
+ * URL is read from `link` (preferred) or `href`. Keeps only actionable entries —
569
+ * a built-in (`id`) or an external link (`link`/`href`).
570
+ */
501
571
  function normalizeMenu(raw) {
502
- if (!Array.isArray(raw)) return void 0;
503
- const out = [];
504
- for (const entry of raw) {
505
- if (!entry || typeof entry !== "object") continue;
506
- const o = entry;
507
- const item = {};
508
- if (typeof o.id === "string" && o.id.trim()) item.id = o.id.trim();
509
- if (typeof o.title === "string" && o.title.trim()) item.title = o.title.trim();
510
- const link = typeof o.link === "string" && o.link.trim() ? o.link.trim() : typeof o.href === "string" && o.href.trim() ? o.href.trim() : void 0;
511
- if (link) item.link = link;
512
- if (typeof o.icon === "string" && o.icon.trim()) item.icon = o.icon.trim();
513
- if (typeof o.target === "string" && o.target.trim()) item.target = o.target.trim();
514
- if (typeof o.class === "string" && o.class.trim()) item.class = o.class.trim();
515
- if (item.id || item.link) out.push(item);
516
- }
517
- return out.length > 0 ? out : void 0;
572
+ if (!Array.isArray(raw)) return void 0;
573
+ const out = [];
574
+ for (const entry of raw) {
575
+ if (!entry || typeof entry !== "object") continue;
576
+ const o = entry;
577
+ const item = {};
578
+ if (typeof o.id === "string" && o.id.trim()) item.id = o.id.trim();
579
+ if (typeof o.title === "string" && o.title.trim()) item.title = o.title.trim();
580
+ const link = typeof o.link === "string" && o.link.trim() ? o.link.trim() : typeof o.href === "string" && o.href.trim() ? o.href.trim() : void 0;
581
+ if (link) item.link = link;
582
+ if (typeof o.icon === "string" && o.icon.trim()) item.icon = o.icon.trim();
583
+ if (typeof o.target === "string" && o.target.trim()) item.target = o.target.trim();
584
+ if (typeof o.class === "string" && o.class.trim()) item.class = o.class.trim();
585
+ if (item.id || item.link) out.push(item);
586
+ }
587
+ return out.length > 0 ? out : void 0;
518
588
  }
519
- var COPY_PAGE_ACTIONS = [
520
- "copy",
521
- "view",
522
- "claude",
523
- "chatgpt",
524
- "perplexity"
589
+ /** Valid copy-page dropdown actions (mirrors setu/dwar's `CopyPageAction`). */
590
+ const COPY_PAGE_ACTIONS = [
591
+ "copy",
592
+ "view",
593
+ "claude",
594
+ "chatgpt",
595
+ "perplexity"
525
596
  ];
597
+ /**
598
+ * Validate `opts.copyPage` into a {@link CopyPageConfig}, or `undefined` to use
599
+ * the defaults (enabled, all actions). Accepts a boolean shorthand (`false`
600
+ * hides the button) or an object: `enabled` is read if boolean; `actions`, if an
601
+ * array, is filtered to the known action ids (preserving order, dropping
602
+ * unknowns/dupes) — an empty/all-invalid array still yields `[]` (primary button
603
+ * only), which is meaningful and kept.
604
+ */
526
605
  function normalizeCopyPage(raw) {
527
- if (raw === false) return { enabled: false };
528
- if (raw === true || raw == null) return void 0;
529
- if (typeof raw !== "object") return void 0;
530
- const o = raw;
531
- const config = {};
532
- if (typeof o.enabled === "boolean") config.enabled = o.enabled;
533
- if (Array.isArray(o.actions)) {
534
- const seen = /* @__PURE__ */ new Set();
535
- for (const a of o.actions) {
536
- if (typeof a === "string" && COPY_PAGE_ACTIONS.includes(a)) {
537
- seen.add(a);
538
- }
539
- }
540
- config.actions = COPY_PAGE_ACTIONS.filter((a) => seen.has(a));
541
- }
542
- return Object.keys(config).length > 0 ? config : void 0;
606
+ if (raw === false) return { enabled: false };
607
+ if (raw === true || raw == null) return void 0;
608
+ if (typeof raw !== "object") return void 0;
609
+ const o = raw;
610
+ const config = {};
611
+ if (typeof o.enabled === "boolean") config.enabled = o.enabled;
612
+ if (Array.isArray(o.actions)) {
613
+ const seen = /* @__PURE__ */ new Set();
614
+ for (const a of o.actions) if (typeof a === "string" && COPY_PAGE_ACTIONS.includes(a)) seen.add(a);
615
+ config.actions = COPY_PAGE_ACTIONS.filter((a) => seen.has(a));
616
+ }
617
+ return Object.keys(config).length > 0 ? config : void 0;
543
618
  }
619
+ /**
620
+ * Validate `opts.pageNav` into a {@link PageNavConfig}, or `undefined` to use the
621
+ * default (enabled). Accepts a boolean shorthand (`false` hides the pager) or an
622
+ * object whose `enabled` is read when boolean.
623
+ */
544
624
  function normalizePageNav(raw) {
545
- if (raw === false) return { enabled: false };
546
- if (raw === true || raw == null) return void 0;
547
- if (typeof raw !== "object") return void 0;
548
- const enabled = raw.enabled;
549
- return typeof enabled === "boolean" ? { enabled } : void 0;
625
+ if (raw === false) return { enabled: false };
626
+ if (raw === true || raw == null) return void 0;
627
+ if (typeof raw !== "object") return void 0;
628
+ const enabled = raw.enabled;
629
+ return typeof enabled === "boolean" ? { enabled } : void 0;
550
630
  }
551
- var PLAYGROUND_PROVIDERS = ["codepen", "jsfiddle", "codesandbox"];
631
+ /** Valid code-playground providers (mirrors utils' `PlaygroundProvider`). */
632
+ const PLAYGROUND_PROVIDERS = [
633
+ "codepen",
634
+ "jsfiddle",
635
+ "codesandbox"
636
+ ];
637
+ /** A site-wide per-provider options record, or `undefined` for a non-object. */
552
638
  function playgroundOptionRecord(raw) {
553
- return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
639
+ return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
554
640
  }
641
+ /**
642
+ * Validate `opts.playground` into its two consumer slices, or `undefined` when
643
+ * the feature is off (absent or `false`). `playground: true` / `{}` turns it on
644
+ * with defaults — every provider available, opt-in per `@playground`. The
645
+ * **`site`** slice feeds setu's `@playground` resolver (enablement + provider
646
+ * selection); the **`theme`** slice becomes `ThemeConfig.playground` (the
647
+ * site-wide per-provider runtime options dwar hands the browser island). Unknown
648
+ * providers/keys are dropped (lenient, like {@link normalizeCopyPage}). setu
649
+ * gates on the `site` slice's presence, so returning `undefined` keeps output
650
+ * byte-identical.
651
+ */
555
652
  function normalizePlayground(raw) {
556
- if (raw == null || raw === false) return void 0;
557
- const o = raw === true ? {} : raw;
558
- if (typeof o !== "object" || Array.isArray(o)) return void 0;
559
- const obj = o;
560
- const site = {};
561
- if (obj.enableForAllExamples === true) site.enableForAllExamples = true;
562
- if (Array.isArray(obj.providers)) {
563
- const providers = [];
564
- for (const p of obj.providers) {
565
- if (typeof p === "string" && PLAYGROUND_PROVIDERS.includes(p) && !providers.includes(p)) {
566
- providers.push(p);
567
- }
568
- }
569
- if (providers.length > 0) site.providers = providers;
570
- }
571
- const theme = { enabled: true };
572
- const codepen = playgroundOptionRecord(obj.codepen);
573
- const jsfiddle = playgroundOptionRecord(obj.jsfiddle);
574
- const codesandbox = playgroundOptionRecord(obj.codesandbox);
575
- if (codepen) theme.codepen = codepen;
576
- if (jsfiddle) theme.jsfiddle = jsfiddle;
577
- if (codesandbox) theme.codesandbox = codesandbox;
578
- return { site, theme };
653
+ if (raw == null || raw === false) return void 0;
654
+ const o = raw === true ? {} : raw;
655
+ if (typeof o !== "object" || Array.isArray(o)) return void 0;
656
+ const obj = o;
657
+ const site = {};
658
+ if (obj.enableForAllExamples === true) site.enableForAllExamples = true;
659
+ if (Array.isArray(obj.providers)) {
660
+ const providers = [];
661
+ for (const p of obj.providers) if (typeof p === "string" && PLAYGROUND_PROVIDERS.includes(p) && !providers.includes(p)) providers.push(p);
662
+ if (providers.length > 0) site.providers = providers;
663
+ }
664
+ const theme = { enabled: true };
665
+ const codepen = playgroundOptionRecord(obj.codepen);
666
+ const jsfiddle = playgroundOptionRecord(obj.jsfiddle);
667
+ const codesandbox = playgroundOptionRecord(obj.codesandbox);
668
+ if (codepen) theme.codepen = codepen;
669
+ if (jsfiddle) theme.jsfiddle = jsfiddle;
670
+ if (codesandbox) theme.codesandbox = codesandbox;
671
+ return {
672
+ site,
673
+ theme
674
+ };
579
675
  }
580
- var COLOR_KEYS = [
581
- "bg",
582
- "bgMuted",
583
- "fg",
584
- "fgMuted",
585
- "accent",
586
- "accentFg",
587
- "border",
588
- "codeHeaderBg",
589
- "codeHeaderFg",
590
- "codeHighlightBg"
676
+ /** The palette keys a user may override under `opts.colors` / `opts.darkColors`. */
677
+ const COLOR_KEYS = [
678
+ "bg",
679
+ "bgMuted",
680
+ "fg",
681
+ "fgMuted",
682
+ "accent",
683
+ "accentFg",
684
+ "border",
685
+ "codeHeaderBg",
686
+ "codeHeaderFg",
687
+ "codeHighlightBg"
591
688
  ];
689
+ /**
690
+ * Validate a user `colors`/`darkColors` object from `jsdoc.json` into a clean
691
+ * `Partial<ThemeColors>`: keeps only the known palette keys whose value is a
692
+ * non-empty string, dropping everything else. Returns `undefined` when the input
693
+ * is not an object or yields no usable keys, so callers can fall back cleanly.
694
+ * Values are passed through verbatim (any CSS color is valid).
695
+ */
592
696
  function normalizeColors(raw) {
593
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
594
- const src = raw;
595
- const out = {};
596
- for (const key of COLOR_KEYS) {
597
- const v = src[key];
598
- if (typeof v === "string" && v.trim().length > 0) out[key] = v.trim();
599
- }
600
- return Object.keys(out).length > 0 ? out : void 0;
697
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
698
+ const src = raw;
699
+ const out = {};
700
+ for (const key of COLOR_KEYS) {
701
+ const v = src[key];
702
+ if (typeof v === "string" && v.trim().length > 0) out[key] = v.trim();
703
+ }
704
+ return Object.keys(out).length > 0 ? out : void 0;
601
705
  }
602
- var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".jsx", ".ts", ".mts", ".cts", ".tsx"]);
706
+ /** Extensions we treat as "source" worth emitting a viewer page for. */
707
+ const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
708
+ ".js",
709
+ ".mjs",
710
+ ".cjs",
711
+ ".jsx",
712
+ ".ts",
713
+ ".mts",
714
+ ".cts",
715
+ ".tsx"
716
+ ]);
717
+ /**
718
+ * Compute project-relative paths for a set of absolute source paths by stripping
719
+ * their longest common directory prefix. Returns a `Map<absPath, relPath>` with
720
+ * `relPath` normalized to forward slashes. Pure + exported for testing.
721
+ *
722
+ * Windows-aware: paths are split on both `/` and `\\`, and segment comparison is
723
+ * case-insensitive (NTFS is case-insensitive, and JSDoc's `meta.path` casing can
724
+ * differ from disk). The single-file case yields just its basename. If the paths
725
+ * share no common leading segment (e.g. different drives / UNC vs. drive), each
726
+ * file falls back to its basename so the index stays sane.
727
+ */
603
728
  function computeRelPaths(absPaths) {
604
- const out = /* @__PURE__ */ new Map();
605
- if (absPaths.length === 0) return out;
606
- const split = (p) => p.split(/[\\/]+/).filter((s) => s.length > 0);
607
- const segLists = absPaths.map(split);
608
- let common = segLists[0].slice(0, -1);
609
- for (let i = 1; i < segLists.length && common.length > 0; i++) {
610
- const segs = segLists[i];
611
- let j = 0;
612
- const max = Math.min(common.length, segs.length - 1);
613
- while (j < max && common[j].toLowerCase() === segs[j].toLowerCase()) j++;
614
- common = common.slice(0, j);
615
- }
616
- for (let i = 0; i < absPaths.length; i++) {
617
- const segs = segLists[i];
618
- const rel = common.length > 0 && segs.length > common.length ? segs.slice(common.length).join("/") : segs[segs.length - 1] ?? absPaths[i];
619
- out.set(absPaths[i], rel);
620
- }
621
- return out;
729
+ const out = /* @__PURE__ */ new Map();
730
+ if (absPaths.length === 0) return out;
731
+ const split = (p) => p.split(/[\\/]+/).filter((s) => s.length > 0);
732
+ const segLists = absPaths.map(split);
733
+ let common = segLists[0].slice(0, -1);
734
+ for (let i = 1; i < segLists.length && common.length > 0; i++) {
735
+ const segs = segLists[i];
736
+ let j = 0;
737
+ const max = Math.min(common.length, segs.length - 1);
738
+ while (j < max && common[j].toLowerCase() === segs[j].toLowerCase()) j++;
739
+ common = common.slice(0, j);
740
+ }
741
+ for (let i = 0; i < absPaths.length; i++) {
742
+ const segs = segLists[i];
743
+ const rel = common.length > 0 && segs.length > common.length ? segs.slice(common.length).join("/") : segs[segs.length - 1] ?? absPaths[i];
744
+ out.set(absPaths[i], rel);
745
+ }
746
+ return out;
622
747
  }
748
+ /**
749
+ * Collect every source file referenced by a doclet's `meta` and read its
750
+ * contents, ready to hand to setu as {@link SourceFileInput}s. `absPath` is the
751
+ * exact `resolve(meta.path, meta.filename)` so setu's `Source: file:line`
752
+ * matching (which joins the same fields) lines up. Files that can't be read are
753
+ * warned about and skipped — never fatal. Returns sorted-by-`relPath` for
754
+ * stable output.
755
+ */
623
756
  async function collectSourceFiles(data) {
624
- let doclets = [];
625
- if (typeof data === "function") {
626
- try {
627
- doclets = data({}).get();
628
- } catch {
629
- try {
630
- doclets = data().get();
631
- } catch {
632
- doclets = [];
633
- }
634
- }
635
- }
636
- if (!Array.isArray(doclets) || doclets.length === 0) return [];
637
- const absSet = /* @__PURE__ */ new Set();
638
- for (const d of doclets) {
639
- const meta = d?.meta;
640
- if (!meta || typeof meta.path !== "string" || typeof meta.filename !== "string") continue;
641
- const filename = meta.filename;
642
- const ext = (0, import_node_path2.extname)(filename).toLowerCase();
643
- if (ext.length > 0 && !SOURCE_EXTENSIONS.has(ext)) continue;
644
- absSet.add((0, import_node_path2.resolve)(meta.path, filename));
645
- }
646
- if (absSet.size === 0) return [];
647
- const absPaths = [...absSet];
648
- const relPaths = computeRelPaths(absPaths);
649
- const inputs = [];
650
- for (const abs of absPaths) {
651
- try {
652
- const content = await (0, import_promises2.readFile)(abs, "utf8");
653
- inputs.push({ absPath: abs, relPath: relPaths.get(abs) ?? abs, content });
654
- } catch (err) {
655
- console.warn(
656
- `clean-jsdoc-theme: could not read source file '${abs}' \u2014 ${err.message}; skipping.`
657
- );
658
- }
659
- }
660
- inputs.sort((a, b) => a.relPath.localeCompare(b.relPath));
661
- return inputs;
757
+ let doclets = [];
758
+ if (typeof data === "function") try {
759
+ doclets = data({}).get();
760
+ } catch {
761
+ try {
762
+ doclets = data().get();
763
+ } catch {
764
+ doclets = [];
765
+ }
766
+ }
767
+ if (!Array.isArray(doclets) || doclets.length === 0) return [];
768
+ const absSet = /* @__PURE__ */ new Set();
769
+ for (const d of doclets) {
770
+ const meta = d?.meta;
771
+ if (!meta || typeof meta.path !== "string" || typeof meta.filename !== "string") continue;
772
+ const filename = meta.filename;
773
+ const ext = (0, node_path.extname)(filename).toLowerCase();
774
+ if (ext.length > 0 && !SOURCE_EXTENSIONS.has(ext)) continue;
775
+ absSet.add((0, node_path.resolve)(meta.path, filename));
776
+ }
777
+ if (absSet.size === 0) return [];
778
+ const absPaths = [...absSet];
779
+ const relPaths = computeRelPaths(absPaths);
780
+ const inputs = [];
781
+ for (const abs of absPaths) try {
782
+ const content = await (0, node_fs_promises.readFile)(abs, "utf8");
783
+ inputs.push({
784
+ absPath: abs,
785
+ relPath: relPaths.get(abs) ?? abs,
786
+ content
787
+ });
788
+ } catch (err) {
789
+ console.warn(`clean-jsdoc-theme: could not read source file '${abs}' — ${err.message}; skipping.`);
790
+ }
791
+ inputs.sort((a, b) => a.relPath.localeCompare(b.relPath));
792
+ return inputs;
662
793
  }
663
- var DOC_EXTENSIONS = /* @__PURE__ */ new Map([
664
- [".md", "markdown"],
665
- [".markdown", "markdown"],
666
- [".html", "html"],
667
- [".htm", "html"]
794
+ /** Doc-file extensions → `DocInput.type`. Markdown is the priority; html maps to 'html'. */
795
+ const DOC_EXTENSIONS = /* @__PURE__ */ new Map([
796
+ [".md", "markdown"],
797
+ [".markdown", "markdown"],
798
+ [".html", "html"],
799
+ [".htm", "html"]
668
800
  ]);
669
- var DOC_DIR_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".svn", ".hg"]);
801
+ /** Directory names skipped while walking a docs tree (build/vcs noise). */
802
+ const DOC_DIR_SKIP = /* @__PURE__ */ new Set([
803
+ "node_modules",
804
+ ".git",
805
+ ".svn",
806
+ ".hg"
807
+ ]);
808
+ /**
809
+ * Recursively walk a docs directory and read each Markdown/HTML file into a
810
+ * {@link DocInput} for setu's docs front-end. Mirrors {@link collectSourceFiles}'s
811
+ * safe-probe style:
812
+ *
813
+ * - `path` is the file path relative to `dir`, POSIX-normalized (forward slashes)
814
+ * with the extension stripped (`<dir>/guides/advanced.md` → `'guides/advanced'`,
815
+ * `<dir>/index.md` → `'index'`).
816
+ * - `content` is the raw UTF-8 text (frontmatter stays embedded — setu parses it).
817
+ * - `type` is `'markdown'` for `.md`/`.markdown`, `'html'` for `.html`/`.htm`.
818
+ *
819
+ * Resilient by design: a missing/unreadable directory yields `[]` (never throws);
820
+ * dotfiles/dot-dirs and `node_modules`-like noise are skipped; a single
821
+ * unreadable file is warned about and skipped. Results are sorted by `path` so
822
+ * the output is stable build-to-build. Setu does no I/O — this is the only place
823
+ * the docs tree is read.
824
+ */
670
825
  async function collectDocs(dir) {
671
- if (typeof dir !== "string" || dir.trim().length === 0) return [];
672
- const root = (0, import_node_path2.resolve)(dir);
673
- const docs = [];
674
- const walk = async (absDir, relPrefix) => {
675
- let entries;
676
- try {
677
- entries = await (0, import_promises2.readdir)(absDir, { withFileTypes: true });
678
- } catch {
679
- return;
680
- }
681
- for (const entry of entries) {
682
- const name = entry.name;
683
- if (name.startsWith(".")) continue;
684
- if (entry.isDirectory()) {
685
- if (DOC_DIR_SKIP.has(name)) continue;
686
- await walk((0, import_node_path2.join)(absDir, name), relPrefix ? `${relPrefix}/${name}` : name);
687
- continue;
688
- }
689
- if (!entry.isFile()) continue;
690
- const ext = (0, import_node_path2.extname)(name).toLowerCase();
691
- const type = DOC_EXTENSIONS.get(ext);
692
- if (!type) continue;
693
- const abs = (0, import_node_path2.join)(absDir, name);
694
- const stem = name.slice(0, name.length - ext.length);
695
- const relPath = relPrefix ? `${relPrefix}/${stem}` : stem;
696
- try {
697
- const content = await (0, import_promises2.readFile)(abs, "utf8");
698
- docs.push({ path: relPath, content, type });
699
- } catch (err) {
700
- console.warn(
701
- `clean-jsdoc-theme: could not read doc file '${abs}' \u2014 ${err.message}; skipping.`
702
- );
703
- }
704
- }
705
- };
706
- await walk(root, "");
707
- docs.sort((a, b) => a.path.localeCompare(b.path));
708
- return docs;
826
+ if (typeof dir !== "string" || dir.trim().length === 0) return [];
827
+ const root = (0, node_path.resolve)(dir);
828
+ const docs = [];
829
+ const walk = async (absDir, relPrefix) => {
830
+ let entries;
831
+ try {
832
+ entries = await (0, node_fs_promises.readdir)(absDir, { withFileTypes: true });
833
+ } catch {
834
+ return;
835
+ }
836
+ for (const entry of entries) {
837
+ const name = entry.name;
838
+ if (name.startsWith(".")) continue;
839
+ if (entry.isDirectory()) {
840
+ if (DOC_DIR_SKIP.has(name)) continue;
841
+ await walk((0, node_path.join)(absDir, name), relPrefix ? `${relPrefix}/${name}` : name);
842
+ continue;
843
+ }
844
+ if (!entry.isFile()) continue;
845
+ const ext = (0, node_path.extname)(name).toLowerCase();
846
+ const type = DOC_EXTENSIONS.get(ext);
847
+ if (!type) continue;
848
+ const abs = (0, node_path.join)(absDir, name);
849
+ const stem = name.slice(0, name.length - ext.length);
850
+ const relPath = relPrefix ? `${relPrefix}/${stem}` : stem;
851
+ try {
852
+ const content = await (0, node_fs_promises.readFile)(abs, "utf8");
853
+ docs.push({
854
+ path: relPath,
855
+ content,
856
+ type
857
+ });
858
+ } catch (err) {
859
+ console.warn(`clean-jsdoc-theme: could not read doc file '${abs}' — ${err.message}; skipping.`);
860
+ }
861
+ }
862
+ };
863
+ await walk(root, "");
864
+ docs.sort((a, b) => a.path.localeCompare(b.path));
865
+ return docs;
709
866
  }
710
- var DOC_IMAGE_RE = /(!\[[^\]]*\]\()([^)\s]+)((?:\s+"[^"]*")?\))/g;
711
- var HTML_IMAGE_RE = /(<img\b[^>]*?\bsrc\s*=\s*(["']))([^"']*)(\2)/gi;
867
+ /** Markdown image: captures `![alt](`, the src, an optional `"title"`, and `)`. */
868
+ const DOC_IMAGE_RE = /(!\[[^\]]*\]\()([^)\s]+)((?:\s+"[^"]*")?\))/g;
869
+ /**
870
+ * HTML image: captures the `<img …src=` prefix (through the opening quote), the
871
+ * quote char, the src value, and the closing quote (a backreference to the
872
+ * opener). JSDoc's `plugins/markdown` renders a comment's `![alt](src)` to
873
+ * `<img src="…" alt="…">`, and prose can embed raw `<img>`; this matches both
874
+ * quote styles wherever `src` sits in the tag.
875
+ */
876
+ const HTML_IMAGE_RE = /(<img\b[^>]*?\bsrc\s*=\s*(["']))([^"']*)(\2)/gi;
712
877
  function createImageCollector(staticDirs = []) {
713
- const files = [];
714
- const inlineSvgs = {};
715
- const consumed = /* @__PURE__ */ new Set();
716
- const seenServed = /* @__PURE__ */ new Set();
717
- const cache = /* @__PURE__ */ new Map();
718
- const warnedMisses = /* @__PURE__ */ new Set();
719
- const resolve = async (rawSrc, baseDir) => {
720
- const src = rawSrc.trim();
721
- if (!src || isServableUrl(src) || src.startsWith("#") || src.startsWith("data:")) return null;
722
- const primary = src.startsWith("/") ? (0, import_node_path2.resolve)(src.slice(1)) : (0, import_node_path2.resolve)(baseDir, src);
723
- const candidates = [primary];
724
- if (staticDirs.length > 0) {
725
- const outName = src.replace(/^\/+/, "");
726
- if (outName) for (const dir of staticDirs) candidates.push((0, import_node_path2.resolve)(dir, outName));
727
- }
728
- for (const abs of candidates) {
729
- const cached = cache.get(abs);
730
- if (cached !== void 0) {
731
- if (cached) return cached;
732
- continue;
733
- }
734
- let bytes;
735
- try {
736
- bytes = await (0, import_promises2.readFile)(abs);
737
- } catch {
738
- cache.set(abs, null);
739
- continue;
740
- }
741
- const ext = (0, import_node_path2.extname)(abs);
742
- const served = `_assets/${(0, import_node_path2.basename)(abs, ext) || "asset"}.${contentHash(bytes)}${ext}`;
743
- if (!seenServed.has(served)) {
744
- seenServed.add(served);
745
- files.push({ path: served, contents: bytes });
746
- }
747
- const href = "/" + served;
748
- if (ext.toLowerCase() === ".svg") {
749
- inlineSvgs[href] = bytes.toString("utf8").replace(/<svg\b/, '<svg style="max-width:100%;height:auto;display:block"');
750
- }
751
- cache.set(abs, href);
752
- consumed.add(abs);
753
- return href;
754
- }
755
- if (!warnedMisses.has(src)) {
756
- warnedMisses.add(src);
757
- console.warn(
758
- `clean-jsdoc-theme: could not read image '${src}' (looked in: ${candidates.join(", ")}); leaving it as-is.`
759
- );
760
- }
761
- return null;
762
- };
763
- return { resolve, files, inlineSvgs, consumed };
878
+ const files = [];
879
+ const inlineSvgs = {};
880
+ const consumed = /* @__PURE__ */ new Set();
881
+ const seenServed = /* @__PURE__ */ new Set();
882
+ const cache = /* @__PURE__ */ new Map();
883
+ const warnedMisses = /* @__PURE__ */ new Set();
884
+ const resolve = async (rawSrc, baseDir) => {
885
+ const src = rawSrc.trim();
886
+ if (!src || isServableUrl(src) || src.startsWith("#") || src.startsWith("data:")) return null;
887
+ const candidates = [src.startsWith("/") ? (0, node_path.resolve)(src.slice(1)) : (0, node_path.resolve)(baseDir, src)];
888
+ if (staticDirs.length > 0) {
889
+ const outName = src.replace(/^\/+/, "");
890
+ if (outName) for (const dir of staticDirs) candidates.push((0, node_path.resolve)(dir, outName));
891
+ }
892
+ for (const abs of candidates) {
893
+ const cached = cache.get(abs);
894
+ if (cached !== void 0) {
895
+ if (cached) return cached;
896
+ continue;
897
+ }
898
+ let bytes;
899
+ try {
900
+ bytes = await (0, node_fs_promises.readFile)(abs);
901
+ } catch {
902
+ cache.set(abs, null);
903
+ continue;
904
+ }
905
+ const ext = (0, node_path.extname)(abs);
906
+ const served = `_assets/${(0, node_path.basename)(abs, ext) || "asset"}.${contentHash(bytes)}${ext}`;
907
+ if (!seenServed.has(served)) {
908
+ seenServed.add(served);
909
+ files.push({
910
+ path: served,
911
+ contents: bytes
912
+ });
913
+ }
914
+ const href = "/" + served;
915
+ if (ext.toLowerCase() === ".svg") inlineSvgs[href] = bytes.toString("utf8").replace(/<svg\b/, "<svg style=\"max-width:100%;height:auto;display:block\"");
916
+ cache.set(abs, href);
917
+ consumed.add(abs);
918
+ return href;
919
+ }
920
+ if (!warnedMisses.has(src)) {
921
+ warnedMisses.add(src);
922
+ console.warn(`clean-jsdoc-theme: could not read image '${src}' (looked in: ${candidates.join(", ")}); leaving it as-is.`);
923
+ }
924
+ return null;
925
+ };
926
+ return {
927
+ resolve,
928
+ files,
929
+ inlineSvgs,
930
+ consumed
931
+ };
764
932
  }
765
- var CODE_REGION_RE = /```[\s\S]*?```|~~~[\s\S]*?~~~|<pre[\s\S]*?<\/pre>|<code[^>]*>[\s\S]*?<\/code>|`[^`\n]+`/gi;
933
+ /**
934
+ * Rewrite the local image references in `content` to their content-hashed
935
+ * `/_assets/…` paths, routing each through `collector`. Handles BOTH Markdown
936
+ * `![alt](src)` and raw HTML `<img src="…">` (JSDoc renders comment/tutorial
937
+ * images to the latter), so prose in either form is covered. Relative srcs
938
+ * resolve against `baseDir`, `/`-rooted srcs against the project root, and
939
+ * external/`data:`/anchor srcs are left untouched. Returns the original string
940
+ * unchanged when nothing was rewritten.
941
+ */
942
+ /**
943
+ * Char ranges of Markdown/HTML **code** regions — fenced blocks (` ``` `/`~~~`),
944
+ * HTML `<pre>`/`<code>`, and inline backtick spans. Image references inside these
945
+ * are literal example syntax an author is *documenting*, not real images, so the
946
+ * rewriter skips them (no spurious copy/rewrite, no "could not read" warning).
947
+ * Order matters: the multi-line block forms come before the inline span so a
948
+ * fence isn't chopped at its first inner backtick.
949
+ */
950
+ const CODE_REGION_RE = /```[\s\S]*?```|~~~[\s\S]*?~~~|<pre[\s\S]*?<\/pre>|<code[^>]*>[\s\S]*?<\/code>|`[^`\n]+`/gi;
951
+ /** Collect the [start, end) char ranges of code regions in `content`. */
766
952
  function codeRanges(content) {
767
- const ranges = [];
768
- for (const m of content.matchAll(CODE_REGION_RE)) {
769
- if (m.index !== void 0) ranges.push([m.index, m.index + m[0].length]);
770
- }
771
- return ranges;
953
+ const ranges = [];
954
+ for (const m of content.matchAll(CODE_REGION_RE)) if (m.index !== void 0) ranges.push([m.index, m.index + m[0].length]);
955
+ return ranges;
772
956
  }
957
+ /** Whether char offset `idx` falls inside any of the (sorted-ish) code ranges. */
773
958
  function indexInCode(idx, ranges) {
774
- for (const [s, e] of ranges) if (idx >= s && idx < e) return true;
775
- return false;
959
+ for (const [s, e] of ranges) if (idx >= s && idx < e) return true;
960
+ return false;
776
961
  }
777
962
  async function rewriteImageRefs(content, baseDir, collector) {
778
- if (!content) return content;
779
- const ranges = codeRanges(content);
780
- const map = /* @__PURE__ */ new Map();
781
- const collect = async (re, srcGroup) => {
782
- for (const m of content.matchAll(re)) {
783
- if (m.index !== void 0 && indexInCode(m.index, ranges)) continue;
784
- const src = m[srcGroup];
785
- if (map.has(src)) continue;
786
- const href = await collector.resolve(src, baseDir);
787
- if (href) map.set(src, href);
788
- }
789
- };
790
- await collect(DOC_IMAGE_RE, 2);
791
- await collect(HTML_IMAGE_RE, 3);
792
- if (map.size === 0) return content;
793
- return content.replace(
794
- DOC_IMAGE_RE,
795
- (full, pre, src, post, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${post}` : full
796
- ).replace(
797
- HTML_IMAGE_RE,
798
- (full, pre, _quote, src, close, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${close}` : full
799
- );
963
+ if (!content) return content;
964
+ const ranges = codeRanges(content);
965
+ const map = /* @__PURE__ */ new Map();
966
+ const collect = async (re, srcGroup) => {
967
+ for (const m of content.matchAll(re)) {
968
+ if (m.index !== void 0 && indexInCode(m.index, ranges)) continue;
969
+ const src = m[srcGroup];
970
+ if (map.has(src)) continue;
971
+ const href = await collector.resolve(src, baseDir);
972
+ if (href) map.set(src, href);
973
+ }
974
+ };
975
+ await collect(DOC_IMAGE_RE, 2);
976
+ await collect(HTML_IMAGE_RE, 3);
977
+ if (map.size === 0) return content;
978
+ return content.replace(DOC_IMAGE_RE, (full, pre, src, post, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${post}` : full).replace(HTML_IMAGE_RE, (full, pre, _quote, src, close, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${close}` : full);
800
979
  }
980
+ /**
981
+ * Resolve the local images a doc references and route them through the shared
982
+ * content-hashed `_assets/` pipeline (see {@link createImageCollector}). Each
983
+ * `![alt](src)` / `<img src>` whose `src` points to a file on disk is copied and
984
+ * its `src` rewritten to the root-relative `/_assets/<base>.<hash><ext>` (rang's
985
+ * `MdxImg` adds the base path, like it does for links), resolved relative to the
986
+ * project root when it starts with `/`, else relative to the doc's own directory.
987
+ * Returns the docs with rewritten content plus the asset files to write. The
988
+ * bridge is the I/O layer here, so setu/dwar only ever see the final `_assets/`
989
+ * paths.
990
+ */
801
991
  async function resolveDocImages(docs, docsDir, collector = createImageCollector()) {
802
- if (docs.length === 0) return { docs, files: collector.files, inlineSvgs: collector.inlineSvgs };
803
- const root = (0, import_node_path2.resolve)(docsDir);
804
- const out = [];
805
- for (const doc of docs) {
806
- const docDir = (0, import_node_path2.dirname)((0, import_node_path2.resolve)(root, doc.path));
807
- const content = await rewriteImageRefs(doc.content, docDir, collector);
808
- out.push(content === doc.content ? doc : { ...doc, content });
809
- }
810
- return { docs: out, files: collector.files, inlineSvgs: collector.inlineSvgs };
992
+ if (docs.length === 0) return {
993
+ docs,
994
+ files: collector.files,
995
+ inlineSvgs: collector.inlineSvgs
996
+ };
997
+ const root = (0, node_path.resolve)(docsDir);
998
+ const out = [];
999
+ for (const doc of docs) {
1000
+ const docDir = (0, node_path.dirname)((0, node_path.resolve)(root, doc.path));
1001
+ const content = await rewriteImageRefs(doc.content, docDir, collector);
1002
+ out.push(content === doc.content ? doc : {
1003
+ ...doc,
1004
+ content
1005
+ });
1006
+ }
1007
+ return {
1008
+ docs: out,
1009
+ files: collector.files,
1010
+ inlineSvgs: collector.inlineSvgs
1011
+ };
811
1012
  }
1013
+ /**
1014
+ * Resolve the local images referenced by tutorial content, routing them through
1015
+ * the shared `collector` (the same content-hashed `_assets/` pipeline as docs).
1016
+ * JSDoc reads every tutorial from a single directory, so each tutorial's relative
1017
+ * srcs (`![x](../img/x.png)`, `<img src>`) resolve against `tutorialsDir`. Walks
1018
+ * the resolved tree (sub-tutorials included), rewriting each node's content —
1019
+ * Markdown or HTML; the tree shape is preserved. Returns a new tree (the input is
1020
+ * left untouched). Exported for testing.
1021
+ */
812
1022
  async function resolveTutorialImages(tree, tutorialsDir, collector) {
813
- const base = (0, import_node_path2.resolve)(tutorialsDir);
814
- const walk = async (node) => {
815
- const content = await rewriteImageRefs(node.content, base, collector);
816
- const children = [];
817
- for (const child of node.children ?? []) children.push(await walk(child));
818
- return { ...node, content, children };
819
- };
820
- const out = [];
821
- for (const node of tree) out.push(await walk(node));
822
- return out;
1023
+ const base = (0, node_path.resolve)(tutorialsDir);
1024
+ const walk = async (node) => {
1025
+ const content = await rewriteImageRefs(node.content, base, collector);
1026
+ const children = [];
1027
+ for (const child of node.children ?? []) children.push(await walk(child));
1028
+ return {
1029
+ ...node,
1030
+ content,
1031
+ children
1032
+ };
1033
+ };
1034
+ const out = [];
1035
+ for (const node of tree) out.push(await walk(node));
1036
+ return out;
823
1037
  }
824
- var DOCLET_IMAGE_SKIP_KEYS = /* @__PURE__ */ new Set([
825
- "meta",
826
- "comment",
827
- "examples",
828
- "tags",
829
- "___id",
830
- "___s"
1038
+ /**
1039
+ * Doclet keys whose string values are raw source/code/meta, NOT rendered prose —
1040
+ * never scanned for images (a stray `<img`/`![` there must not be rewritten).
1041
+ */
1042
+ const DOCLET_IMAGE_SKIP_KEYS = /* @__PURE__ */ new Set([
1043
+ "meta",
1044
+ "comment",
1045
+ "examples",
1046
+ "tags",
1047
+ "___id",
1048
+ "___s"
831
1049
  ]);
1050
+ /**
1051
+ * Recursively rewrite the `<img>`/`![]()` image srcs in every prose string
1052
+ * reachable from a doclet object, resolving against `baseDir`. Only strings that
1053
+ * actually carry an image marker (`<img` or `![`) are touched — a cheap guard so
1054
+ * names/identifiers/code are never scanned — and raw/code keys
1055
+ * ({@link DOCLET_IMAGE_SKIP_KEYS}) are skipped entirely. Recurses into nested
1056
+ * objects/arrays (e.g. `params[].description`). Mutates `node` in place.
1057
+ */
832
1058
  async function rewriteDocletStrings(node, baseDir, collector) {
833
- for (const [key, value] of Object.entries(node)) {
834
- if (DOCLET_IMAGE_SKIP_KEYS.has(key)) continue;
835
- if (typeof value === "string") {
836
- if (value.includes("<img") || value.includes("![")) {
837
- const rewritten = await rewriteImageRefs(value, baseDir, collector);
838
- if (rewritten !== value) node[key] = rewritten;
839
- }
840
- } else if (Array.isArray(value)) {
841
- for (let i = 0; i < value.length; i++) {
842
- const item = value[i];
843
- if (typeof item === "string") {
844
- if (item.includes("<img") || item.includes("![")) {
845
- const rewritten = await rewriteImageRefs(item, baseDir, collector);
846
- if (rewritten !== item) value[i] = rewritten;
847
- }
848
- } else if (item && typeof item === "object") {
849
- await rewriteDocletStrings(item, baseDir, collector);
850
- }
851
- }
852
- } else if (value && typeof value === "object") {
853
- await rewriteDocletStrings(value, baseDir, collector);
854
- }
855
- }
1059
+ for (const [key, value] of Object.entries(node)) {
1060
+ if (DOCLET_IMAGE_SKIP_KEYS.has(key)) continue;
1061
+ if (typeof value === "string") {
1062
+ if (value.includes("<img") || value.includes("![")) {
1063
+ const rewritten = await rewriteImageRefs(value, baseDir, collector);
1064
+ if (rewritten !== value) node[key] = rewritten;
1065
+ }
1066
+ } else if (Array.isArray(value)) for (let i = 0; i < value.length; i++) {
1067
+ const item = value[i];
1068
+ if (typeof item === "string") {
1069
+ if (item.includes("<img") || item.includes("![")) {
1070
+ const rewritten = await rewriteImageRefs(item, baseDir, collector);
1071
+ if (rewritten !== item) value[i] = rewritten;
1072
+ }
1073
+ } else if (item && typeof item === "object") await rewriteDocletStrings(item, baseDir, collector);
1074
+ }
1075
+ else if (value && typeof value === "object") await rewriteDocletStrings(value, baseDir, collector);
1076
+ }
856
1077
  }
1078
+ /**
1079
+ * Resolve the local images referenced inside JSDoc-comment prose (doclet
1080
+ * descriptions, `@classdesc`, nested `@param`/`@property`/`@returns`
1081
+ * descriptions, …) and route them through the shared `collector`. JSDoc's
1082
+ * `plugins/markdown` has already turned a comment's `![alt](../img/x.png)` into
1083
+ * an HTML `<img src="../img/x.png">` by the time `publish` runs, so each src is
1084
+ * resolved **relative to that doclet's own source file** (`meta.path` — the
1085
+ * directory of the file the comment lives in). Doclets are mutated IN PLACE:
1086
+ * salty's `get()` hands out live object references, so the rewrite is visible
1087
+ * when setu later reads the same collection. Resilient — a non-collection `data`
1088
+ * or unreadable image is skipped (the latter warned), never fatal.
1089
+ */
857
1090
  async function resolveDocletImages(data, collector) {
858
- if (typeof data !== "function") return;
859
- let doclets = [];
860
- try {
861
- doclets = data({}).get();
862
- } catch {
863
- try {
864
- doclets = data().get();
865
- } catch {
866
- return;
867
- }
868
- }
869
- if (!Array.isArray(doclets)) return;
870
- for (const d of doclets) {
871
- if (!d || typeof d !== "object") continue;
872
- const meta = d.meta;
873
- if (!meta || typeof meta.path !== "string" || meta.path.length === 0) continue;
874
- await rewriteDocletStrings(d, meta.path, collector);
875
- }
1091
+ if (typeof data !== "function") return;
1092
+ let doclets = [];
1093
+ try {
1094
+ doclets = data({}).get();
1095
+ } catch {
1096
+ try {
1097
+ doclets = data().get();
1098
+ } catch {
1099
+ return;
1100
+ }
1101
+ }
1102
+ if (!Array.isArray(doclets)) return;
1103
+ for (const d of doclets) {
1104
+ if (!d || typeof d !== "object") continue;
1105
+ const meta = d.meta;
1106
+ if (!meta || typeof meta.path !== "string" || meta.path.length === 0) continue;
1107
+ await rewriteDocletStrings(d, meta.path, collector);
1108
+ }
876
1109
  }
1110
+ /**
1111
+ * Normalize a raw `staticFiles` block into a {@link StaticFilesConfig}, or
1112
+ * `undefined` when there's nothing to include. `include`/`exclude` accept a
1113
+ * string or string[]; patterns are kept as source strings (compiled later, so a
1114
+ * bad pattern fails open rather than throwing). Pure + exported for testing.
1115
+ */
877
1116
  function normalizeStaticFilesConfig(raw) {
878
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
879
- const o = raw;
880
- const toStrArr = (v) => (Array.isArray(v) ? v : typeof v === "string" ? [v] : []).filter((s) => typeof s === "string" && s.trim().length > 0).map((s) => s.trim());
881
- const include = toStrArr(o.include);
882
- if (include.length === 0) return void 0;
883
- const includePattern = typeof o.includePattern === "string" && o.includePattern.trim().length > 0 ? o.includePattern : void 0;
884
- const excludePattern = typeof o.excludePattern === "string" && o.excludePattern.trim().length > 0 ? o.excludePattern : void 0;
885
- return {
886
- include,
887
- exclude: toStrArr(o.exclude),
888
- ...includePattern ? { includePattern } : {},
889
- ...excludePattern ? { excludePattern } : {}
890
- };
1117
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
1118
+ const o = raw;
1119
+ const toStrArr = (v) => (Array.isArray(v) ? v : typeof v === "string" ? [v] : []).filter((s) => typeof s === "string" && s.trim().length > 0).map((s) => s.trim());
1120
+ const include = toStrArr(o.include);
1121
+ if (include.length === 0) return void 0;
1122
+ const includePattern = typeof o.includePattern === "string" && o.includePattern.trim().length > 0 ? o.includePattern : void 0;
1123
+ const excludePattern = typeof o.excludePattern === "string" && o.excludePattern.trim().length > 0 ? o.excludePattern : void 0;
1124
+ return {
1125
+ include,
1126
+ exclude: toStrArr(o.exclude),
1127
+ ...includePattern ? { includePattern } : {},
1128
+ ...excludePattern ? { excludePattern } : {}
1129
+ };
891
1130
  }
1131
+ /**
1132
+ * Read `templates.default.staticFiles` from JSDoc's canonical `jsdoc/env` conf
1133
+ * (the only place the root-level `templates` block lives at runtime), falling
1134
+ * back to a nested `opts.templates.default.staticFiles`. Mirrors the probe order
1135
+ * of {@link outputSourceFilesEnabled}. Returns `undefined` when unset/unusable.
1136
+ */
892
1137
  function readStaticFilesConfig(opts) {
893
- try {
894
- const env = require("jsdoc/env");
895
- const fromEnv = normalizeStaticFilesConfig(env?.conf?.templates?.default?.staticFiles);
896
- if (fromEnv) return fromEnv;
897
- } catch {
898
- }
899
- return normalizeStaticFilesConfig(opts?.templates?.default?.staticFiles);
1138
+ try {
1139
+ const fromEnv = normalizeStaticFilesConfig(require("jsdoc/env")?.conf?.templates?.default?.staticFiles);
1140
+ if (fromEnv) return fromEnv;
1141
+ } catch {}
1142
+ return normalizeStaticFilesConfig(opts?.templates?.default?.staticFiles);
900
1143
  }
1144
+ /**
1145
+ * Output-relative path (POSIX) for a static file under an include root: strip the
1146
+ * resolved-root prefix so `<root>/img/sub/x.png` under root `<root>/img` →
1147
+ * `sub/x.png` (JSDoc maps an include dir's contents to the output ROOT). When the
1148
+ * include was a single FILE (`absFile === includeRootAbs`), the output name is its
1149
+ * basename. Windows-aware: separators are normalized and the prefix match is
1150
+ * case-insensitive (NTFS). Pure + exported for testing.
1151
+ */
901
1152
  function staticFileOutputName(absFile, includeRootAbs) {
902
- const norm = (p) => p.replace(/\\/g, "/").replace(/\/+$/, "");
903
- const f = norm(absFile);
904
- const root = norm(includeRootAbs);
905
- const baseOf = (p) => p.slice(p.lastIndexOf("/") + 1);
906
- if (f === root) return baseOf(f);
907
- const prefix = root + "/";
908
- return f.toLowerCase().startsWith(prefix.toLowerCase()) ? f.slice(prefix.length) : baseOf(f);
1153
+ const norm = (p) => p.replace(/\\/g, "/").replace(/\/+$/, "");
1154
+ const f = norm(absFile);
1155
+ const root = norm(includeRootAbs);
1156
+ const baseOf = (p) => p.slice(p.lastIndexOf("/") + 1);
1157
+ if (f === root) return baseOf(f);
1158
+ const prefix = root + "/";
1159
+ return f.toLowerCase().startsWith(prefix.toLowerCase()) ? f.slice(prefix.length) : baseOf(f);
909
1160
  }
1161
+ /**
1162
+ * Whether a static file passes a config's filter — `includePattern` (must match),
1163
+ * `excludePattern` (must not match), and `exclude` (file equal to, or nested
1164
+ * under, an excluded path is dropped). Patterns are tested against the file's
1165
+ * POSIX-normalized absolute path; a malformed pattern fails open (ignored). Pure
1166
+ * + exported for testing.
1167
+ */
910
1168
  function staticFileIncluded(absFile, config) {
911
- const norm = (p) => (0, import_node_path2.resolve)(p).replace(/\\/g, "/");
912
- const fn = norm(absFile);
913
- if (config.includePattern) {
914
- try {
915
- if (!new RegExp(config.includePattern).test(fn)) return false;
916
- } catch {
917
- }
918
- }
919
- if (config.excludePattern) {
920
- try {
921
- if (new RegExp(config.excludePattern).test(fn)) return false;
922
- } catch {
923
- }
924
- }
925
- for (const ex of config.exclude) {
926
- const exAbs = norm(ex);
927
- if (fn === exAbs || fn.toLowerCase().startsWith(exAbs.toLowerCase() + "/")) return false;
928
- }
929
- return true;
1169
+ const norm = (p) => (0, node_path.resolve)(p).replace(/\\/g, "/");
1170
+ const fn = norm(absFile);
1171
+ if (config.includePattern) try {
1172
+ if (!new RegExp(config.includePattern).test(fn)) return false;
1173
+ } catch {}
1174
+ if (config.excludePattern) try {
1175
+ if (new RegExp(config.excludePattern).test(fn)) return false;
1176
+ } catch {}
1177
+ for (const ex of config.exclude) {
1178
+ const exAbs = norm(ex);
1179
+ if (fn === exAbs || fn.toLowerCase().startsWith(exAbs.toLowerCase() + "/")) return false;
1180
+ }
1181
+ return true;
930
1182
  }
931
- var STATIC_DIR_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".svn", ".hg"]);
1183
+ /** Directory names skipped while walking a staticFiles tree (build/vcs noise). */
1184
+ const STATIC_DIR_SKIP = /* @__PURE__ */ new Set([
1185
+ "node_modules",
1186
+ ".git",
1187
+ ".svn",
1188
+ ".hg"
1189
+ ]);
1190
+ /**
1191
+ * Collect the files matched by a {@link StaticFilesConfig}: walk each include
1192
+ * path (a directory recursively, or a single file), apply
1193
+ * {@link staticFileIncluded}, and read each match. Returns the verbatim copy
1194
+ * entries (output path = include-root-stripped, JSDoc's "contents → output root"
1195
+ * mapping) plus the resolved `searchDirs` the image resolver uses as fallback
1196
+ * roots (an include dir as-is; a file include's parent dir). Resilient: a missing
1197
+ * include path / unreadable file is warned + skipped, never fatal. Exported for
1198
+ * testing.
1199
+ */
932
1200
  async function collectStaticFiles(config, warn = (m) => console.warn(m)) {
933
- const files = [];
934
- const searchDirs = /* @__PURE__ */ new Set();
935
- const seenOutput = /* @__PURE__ */ new Set();
936
- for (const inc of config.include) {
937
- const root = (0, import_node_path2.resolve)(inc);
938
- let st;
939
- try {
940
- st = await (0, import_promises2.stat)(root);
941
- } catch {
942
- warn(
943
- `clean-jsdoc-theme: staticFiles include '${inc}' (resolved '${root}') was not found; skipping it.`
944
- );
945
- continue;
946
- }
947
- if (st.isDirectory()) {
948
- searchDirs.add(root);
949
- const walk = async (absDir) => {
950
- let entries;
951
- try {
952
- entries = await (0, import_promises2.readdir)(absDir, { withFileTypes: true });
953
- } catch {
954
- return;
955
- }
956
- for (const entry of entries) {
957
- if (entry.name.startsWith(".")) continue;
958
- const abs = (0, import_node_path2.join)(absDir, entry.name);
959
- if (entry.isDirectory()) {
960
- if (!STATIC_DIR_SKIP.has(entry.name)) await walk(abs);
961
- continue;
962
- }
963
- if (!entry.isFile()) continue;
964
- if (!staticFileIncluded(abs, config)) continue;
965
- const outputPath = staticFileOutputName(abs, root);
966
- if (seenOutput.has(outputPath)) continue;
967
- let contents;
968
- try {
969
- contents = await (0, import_promises2.readFile)(abs);
970
- } catch (err) {
971
- warn(
972
- `clean-jsdoc-theme: could not read static file '${abs}' \u2014 ${err.message}; skipping.`
973
- );
974
- continue;
975
- }
976
- seenOutput.add(outputPath);
977
- files.push({ outputPath, absSource: (0, import_node_path2.resolve)(abs), contents });
978
- }
979
- };
980
- await walk(root);
981
- } else if (st.isFile()) {
982
- searchDirs.add((0, import_node_path2.dirname)(root));
983
- if (!staticFileIncluded(root, config)) continue;
984
- const outputPath = staticFileOutputName(root, root);
985
- if (!seenOutput.has(outputPath)) {
986
- try {
987
- const contents = await (0, import_promises2.readFile)(root);
988
- seenOutput.add(outputPath);
989
- files.push({ outputPath, absSource: (0, import_node_path2.resolve)(root), contents });
990
- } catch (err) {
991
- warn(
992
- `clean-jsdoc-theme: could not read static file '${root}' \u2014 ${err.message}; skipping.`
993
- );
994
- }
995
- }
996
- }
997
- }
998
- files.sort((a, b) => a.outputPath.localeCompare(b.outputPath));
999
- return { files, searchDirs: [...searchDirs] };
1201
+ const files = [];
1202
+ const searchDirs = /* @__PURE__ */ new Set();
1203
+ const seenOutput = /* @__PURE__ */ new Set();
1204
+ for (const inc of config.include) {
1205
+ const root = (0, node_path.resolve)(inc);
1206
+ let st;
1207
+ try {
1208
+ st = await (0, node_fs_promises.stat)(root);
1209
+ } catch {
1210
+ warn(`clean-jsdoc-theme: staticFiles include '${inc}' (resolved '${root}') was not found; skipping it.`);
1211
+ continue;
1212
+ }
1213
+ if (st.isDirectory()) {
1214
+ searchDirs.add(root);
1215
+ const walk = async (absDir) => {
1216
+ let entries;
1217
+ try {
1218
+ entries = await (0, node_fs_promises.readdir)(absDir, { withFileTypes: true });
1219
+ } catch {
1220
+ return;
1221
+ }
1222
+ for (const entry of entries) {
1223
+ if (entry.name.startsWith(".")) continue;
1224
+ const abs = (0, node_path.join)(absDir, entry.name);
1225
+ if (entry.isDirectory()) {
1226
+ if (!STATIC_DIR_SKIP.has(entry.name)) await walk(abs);
1227
+ continue;
1228
+ }
1229
+ if (!entry.isFile()) continue;
1230
+ if (!staticFileIncluded(abs, config)) continue;
1231
+ const outputPath = staticFileOutputName(abs, root);
1232
+ if (seenOutput.has(outputPath)) continue;
1233
+ let contents;
1234
+ try {
1235
+ contents = await (0, node_fs_promises.readFile)(abs);
1236
+ } catch (err) {
1237
+ warn(`clean-jsdoc-theme: could not read static file '${abs}' — ${err.message}; skipping.`);
1238
+ continue;
1239
+ }
1240
+ seenOutput.add(outputPath);
1241
+ files.push({
1242
+ outputPath,
1243
+ absSource: (0, node_path.resolve)(abs),
1244
+ contents
1245
+ });
1246
+ }
1247
+ };
1248
+ await walk(root);
1249
+ } else if (st.isFile()) {
1250
+ searchDirs.add((0, node_path.dirname)(root));
1251
+ if (!staticFileIncluded(root, config)) continue;
1252
+ const outputPath = staticFileOutputName(root, root);
1253
+ if (!seenOutput.has(outputPath)) try {
1254
+ const contents = await (0, node_fs_promises.readFile)(root);
1255
+ seenOutput.add(outputPath);
1256
+ files.push({
1257
+ outputPath,
1258
+ absSource: (0, node_path.resolve)(root),
1259
+ contents
1260
+ });
1261
+ } catch (err) {
1262
+ warn(`clean-jsdoc-theme: could not read static file '${root}' — ${err.message}; skipping.`);
1263
+ }
1264
+ }
1265
+ }
1266
+ files.sort((a, b) => a.outputPath.localeCompare(b.outputPath));
1267
+ return {
1268
+ files,
1269
+ searchDirs: [...searchDirs]
1270
+ };
1000
1271
  }
1272
+ /**
1273
+ * Overlay a locale's resolved docs over the default set (the per-locale docs
1274
+ * track). A locale page WINS over the default page with the same `path`; a
1275
+ * default page absent from the locale falls back (stays). Image asset files are
1276
+ * deduped by served path (same content-hashed name → one copy), and inline SVGs
1277
+ * merge locale-over-default. Output docs are re-sorted by `path` so the manifest
1278
+ * stays stable regardless of merge order. Pure — the I/O already happened in the
1279
+ * two {@link resolveDocImages} calls that produced `base`/`locale`.
1280
+ */
1001
1281
  function overlayDocs(base, locale) {
1002
- const byPath = new Map(base.docs.map((d) => [d.path, d]));
1003
- for (const d of locale.docs) byPath.set(d.path, d);
1004
- const filesByPath = /* @__PURE__ */ new Map();
1005
- for (const f of [...base.files, ...locale.files]) filesByPath.set(f.path, f);
1006
- return {
1007
- docs: [...byPath.values()].sort((a, b) => a.path.localeCompare(b.path)),
1008
- files: [...filesByPath.values()],
1009
- inlineSvgs: { ...base.inlineSvgs, ...locale.inlineSvgs }
1010
- };
1282
+ const byPath = new Map(base.docs.map((d) => [d.path, d]));
1283
+ for (const d of locale.docs) byPath.set(d.path, d);
1284
+ const filesByPath = /* @__PURE__ */ new Map();
1285
+ for (const f of [...base.files, ...locale.files]) filesByPath.set(f.path, f);
1286
+ return {
1287
+ docs: [...byPath.values()].sort((a, b) => a.path.localeCompare(b.path)),
1288
+ files: [...filesByPath.values()],
1289
+ inlineSvgs: {
1290
+ ...base.inlineSvgs,
1291
+ ...locale.inlineSvgs
1292
+ }
1293
+ };
1011
1294
  }
1295
+ /**
1296
+ * Validate `opts.docGroups` into a clean `string[]`, or `undefined` to fall back
1297
+ * to setu's default doc-group order. Mirrors {@link normalizeSectionOrder}:
1298
+ * accepts only an array; trims string entries and drops non-strings/empties.
1299
+ */
1012
1300
  function normalizeDocGroups(raw) {
1013
- return normalizeSectionOrder(raw);
1301
+ return normalizeSectionOrder(raw);
1014
1302
  }
1303
+ /** Format an elapsed-ms span compactly: `840ms` under a second, else `5.2s`. */
1015
1304
  function formatElapsed(ms) {
1016
- return ms < 1e3 ? `${ms}ms` : `${(ms / 1e3).toFixed(1)}s`;
1305
+ return ms < 1e3 ? `${ms}ms` : `${(ms / 1e3).toFixed(1)}s`;
1017
1306
  }
1307
+ /**
1308
+ * Build-stage narrator backed by `ora`. The setu→dwar pipeline does much more
1309
+ * than a bare jsdoc run (per-page MDX compile, per-island esbuild bundling), so
1310
+ * a 7–8s build can otherwise look hung. `stage(label, fn)`
1311
+ * starts an ora spinner, runs `fn`, then resolves it to `✔ <label> (<elapsed>)`
1312
+ * on success or `✖ <label>` on failure. ora handles the spinner animation, TTY
1313
+ * detection (no animation when piped/CI), and the success/fail symbols.
1314
+ *
1315
+ * The catch: ora animates its frame on a `setInterval`, but each stage does
1316
+ * heavy *synchronous* work (module evaluation during the dynamic `import()`,
1317
+ * per-page MDX compile/SSR) that blocks the event loop — so the interval can't
1318
+ * fire and the spinner freezes on one frame, looking hung. Two things keep it
1319
+ * visibly alive: an elapsed-seconds **heartbeat** appended to the label (so it
1320
+ * advances whenever the loop breathes — module-graph I/O gaps, esbuild
1321
+ * subprocess waits), and the `setText` handle, which long stages use to report
1322
+ * their current sub-step (e.g. the renderer load steps setu → dwar → utils).
1323
+ *
1324
+ * `ora` is `null` when progress is disabled (`opts.progress === false`) or the
1325
+ * package couldn't be loaded — then `stage` just runs `fn` with no output.
1326
+ */
1018
1327
  function createBuildProgress(ora) {
1019
- async function stage(label, fn) {
1020
- const noop = { setText: () => {
1021
- } };
1022
- if (!ora) return await fn(noop);
1023
- const spinner = ora(label).start();
1024
- const begin = Date.now();
1025
- let current = label;
1026
- const refresh = () => {
1027
- const secs = Math.floor((Date.now() - begin) / 1e3);
1028
- spinner.text = secs > 0 ? `${current} (${secs}s)` : current;
1029
- };
1030
- const heartbeat = setInterval(refresh, 1e3);
1031
- if (typeof heartbeat.unref === "function") heartbeat.unref();
1032
- const handle = {
1033
- setText(text) {
1034
- current = text;
1035
- refresh();
1036
- }
1037
- };
1038
- try {
1039
- const result = await fn(handle);
1040
- clearInterval(heartbeat);
1041
- spinner.succeed(`${label} (${formatElapsed(Date.now() - begin)})`);
1042
- return result;
1043
- } catch (err) {
1044
- clearInterval(heartbeat);
1045
- spinner.fail(label);
1046
- throw err;
1047
- }
1048
- }
1049
- return { stage };
1328
+ async function stage(label, fn) {
1329
+ const noop = { setText: () => {} };
1330
+ if (!ora) return await fn(noop);
1331
+ const spinner = ora(label).start();
1332
+ const begin = Date.now();
1333
+ let current = label;
1334
+ const refresh = () => {
1335
+ const secs = Math.floor((Date.now() - begin) / 1e3);
1336
+ spinner.text = secs > 0 ? `${current} (${secs}s)` : current;
1337
+ };
1338
+ const heartbeat = setInterval(refresh, 1e3);
1339
+ if (typeof heartbeat.unref === "function") heartbeat.unref();
1340
+ const handle = { setText(text) {
1341
+ current = text;
1342
+ refresh();
1343
+ } };
1344
+ try {
1345
+ const result = await fn(handle);
1346
+ clearInterval(heartbeat);
1347
+ spinner.succeed(`${label} (${formatElapsed(Date.now() - begin)})`);
1348
+ return result;
1349
+ } catch (err) {
1350
+ clearInterval(heartbeat);
1351
+ spinner.fail(label);
1352
+ throw err;
1353
+ }
1354
+ }
1355
+ return { stage };
1050
1356
  }
1357
+ /**
1358
+ * Read the localization build spec when `CLEAN_JSDOC_THEME_BUILD` points at one
1359
+ * (set by `aadesh build` per locale). When present, the theme stamps the API
1360
+ * translations and renders to the spec's `destination`/`basePath` instead of the
1361
+ * jsdoc.json values. Returns `null` for a normal (single-locale) build.
1362
+ */
1051
1363
  function readBuildSpec() {
1052
- const path = process.env.CLEAN_JSDOC_THEME_BUILD?.trim();
1053
- if (!path) return null;
1054
- const spec = JSON.parse((0, import_node_fs.readFileSync)(path, "utf8"));
1055
- if (typeof spec.version === "number" && spec.version !== 1) {
1056
- throw new Error(
1057
- `clean-jsdoc-theme: build spec version ${spec.version} unsupported (expected 1) \u2014 update clean-jsdoc-theme and aadesh together.`
1058
- );
1059
- }
1060
- if (typeof spec.destination !== "string" || typeof spec.basePath !== "string") {
1061
- throw new Error(`clean-jsdoc-theme: malformed build spec at "${path}".`);
1062
- }
1063
- return {
1064
- locale: typeof spec.locale === "string" ? spec.locale : "",
1065
- defaultLocale: typeof spec.defaultLocale === "string" ? spec.defaultLocale : "en",
1066
- apiMessages: spec.apiMessages ?? {},
1067
- chromeMessages: spec.chromeMessages ?? {},
1068
- destination: spec.destination,
1069
- basePath: spec.basePath,
1070
- siteBasePath: typeof spec.siteBasePath === "string" ? spec.siteBasePath : "/",
1071
- locales: Array.isArray(spec.locales) ? spec.locales : [],
1072
- ...typeof spec.docsDir === "string" && spec.docsDir ? { docsDir: spec.docsDir } : {}
1073
- };
1364
+ const path = process.env.CLEAN_JSDOC_THEME_BUILD?.trim();
1365
+ if (!path) return null;
1366
+ const spec = JSON.parse((0, node_fs.readFileSync)(path, "utf8"));
1367
+ if (typeof spec.version === "number" && spec.version !== 1) throw new Error(`clean-jsdoc-theme: build spec version ${spec.version} unsupported (expected 1) — update clean-jsdoc-theme and aadesh together.`);
1368
+ if (typeof spec.destination !== "string" || typeof spec.basePath !== "string") throw new Error(`clean-jsdoc-theme: malformed build spec at "${path}".`);
1369
+ return {
1370
+ locale: typeof spec.locale === "string" ? spec.locale : "",
1371
+ defaultLocale: typeof spec.defaultLocale === "string" ? spec.defaultLocale : "en",
1372
+ apiMessages: spec.apiMessages ?? {},
1373
+ chromeMessages: spec.chromeMessages ?? {},
1374
+ destination: spec.destination,
1375
+ basePath: spec.basePath,
1376
+ siteBasePath: typeof spec.siteBasePath === "string" ? spec.siteBasePath : "/",
1377
+ locales: Array.isArray(spec.locales) ? spec.locales : [],
1378
+ ...typeof spec.docsDir === "string" && spec.docsDir ? { docsDir: spec.docsDir } : {}
1379
+ };
1074
1380
  }
1075
1381
  async function publish(data, opts, tutorials) {
1076
- const buildSpec = readBuildSpec();
1077
- const destination = buildSpec?.destination ?? opts.destination;
1078
- if (!destination || typeof destination !== "string") {
1079
- throw new Error(
1080
- 'clean-jsdoc-theme publish: opts.destination is required (set "opts.destination" in your jsdoc.json).'
1081
- );
1082
- }
1083
- assertMarkdownPlugin();
1084
- const color = Boolean(process.stdout.isTTY) && opts.nocolor !== true;
1085
- const docsDir = typeof opts.docs === "string" && opts.docs.trim().length > 0 ? opts.docs.trim() : void 0;
1086
- const tutorialsDir = typeof opts.tutorials === "string" && opts.tutorials.trim().length > 0 ? opts.tutorials.trim() : void 0;
1087
- const staticCfg = readStaticFilesConfig(opts);
1088
- const pkgPromise = resolvePkg(data, opts);
1089
- const sourcesPromise = outputSourceFilesEnabled(opts) ? collectSourceFiles(data) : Promise.resolve([]);
1090
- const docsPromise = docsDir ? collectDocs(docsDir) : Promise.resolve([]);
1091
- const ora = opts.progress === false ? null : await loadOra();
1092
- const progress = createBuildProgress(ora);
1093
- const [
1094
- { generateSite, stampSite },
1095
- { render, runPagefindAgainstDir },
1096
- {
1097
- validateThemeOpts,
1098
- createGoogleFontResolver,
1099
- formatDiagnostics,
1100
- formatBuildReport,
1101
- formatRenderError,
1102
- normalizeBasePath,
1103
- withBase,
1104
- toExtractManifest,
1105
- normalizeCollapsibleSidebarSections,
1106
- unmatchedCollapsibleSections,
1107
- topLevelSectionLabels,
1108
- normalizeScrollbar
1109
- }
1110
- // Loaded sequentially (not Promise.all) so the spinner can step its label
1111
- // through each module — the evaluation of these large ESM bundles is the
1112
- // single longest, most event-loop-blocking stage, so visibly naming the
1113
- // module in flight is what stops it from reading as a hang.
1114
- ] = await progress.stage("Loading renderer", async ({ setText }) => {
1115
- setText("Loading renderer (setu)");
1116
- const setu = await loadSetu();
1117
- setText("Loading renderer (dwar)");
1118
- const dwar = await loadDwar();
1119
- setText("Loading renderer (utils)");
1120
- const utils = await loadUtils();
1121
- return [setu, dwar, utils];
1122
- });
1123
- const basePath = normalizeBasePath(buildSpec?.basePath ?? opts.basePath);
1124
- const hrefForServed = (servedPath) => withBase(basePath, "/" + servedPath);
1125
- const fontResolver = createGoogleFontResolver();
1126
- const { value, diagnostics } = await progress.stage(
1127
- "Validating options",
1128
- () => validateThemeOpts({
1129
- opts,
1130
- fontResolver,
1131
- unknownKeyPolicy: "suggest-typos",
1132
- knownNonThemeKeys: JSDOC_OWN_OPTS
1133
- })
1134
- );
1135
- const strict = opts.strict === true || opts.templates?.default?.strict === true;
1136
- if (diagnostics.list.length > 0) {
1137
- const formatted = formatDiagnostics(diagnostics, { color });
1138
- if (strict && diagnostics.hasErrors()) {
1139
- console.error(formatted);
1140
- throw new Error(
1141
- "clean-jsdoc-theme: opts validation failed in strict mode (see the diagnostics above). Fix the errors or unset `strict`."
1142
- );
1143
- }
1144
- console.log(formatted);
1145
- }
1146
- const pkg = await pkgPromise;
1147
- const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
1148
- const tutorialTree = normalizeTutorials(tutorials);
1149
- const sourceLinkToComment = sourceLinkToCommentEnabled(opts);
1150
- const staticFiles = staticCfg ? await progress.stage(
1151
- "Reading static files",
1152
- () => collectStaticFiles(staticCfg, (m) => console.warn(m))
1153
- ) : void 0;
1154
- const images = createImageCollector(staticFiles?.searchDirs ?? []);
1155
- const { sources, docs } = await progress.stage("Reading sources & docs", async () => {
1156
- const [srcs, rawDocs] = await Promise.all([sourcesPromise, docsPromise]);
1157
- const base = docsDir ? await resolveDocImages(rawDocs, docsDir, images) : { docs: rawDocs };
1158
- if (!buildSpec?.docsDir) return { sources: srcs, docs: base.docs };
1159
- const localeRaw = await collectDocs(buildSpec.docsDir);
1160
- const locale = await resolveDocImages(localeRaw, buildSpec.docsDir, images);
1161
- const merged = overlayDocs(
1162
- { docs: base.docs, files: [], inlineSvgs: {} },
1163
- { docs: locale.docs, files: [], inlineSvgs: {} }
1164
- );
1165
- return { sources: srcs, docs: merged.docs };
1166
- });
1167
- const { tutorialTree: resolvedTutorials, readme: resolvedReadme } = await progress.stage(
1168
- "Resolving prose images",
1169
- async () => {
1170
- const tree = tutorialsDir && tutorialTree.length > 0 ? await resolveTutorialImages(tutorialTree, tutorialsDir, images) : tutorialTree;
1171
- const md = readme ? await rewriteImageRefs(readme, process.cwd(), images) : readme;
1172
- await resolveDocletImages(data, images);
1173
- return { tutorialTree: tree, readme: md };
1174
- }
1175
- );
1176
- const imageFiles = images.files;
1177
- const allInlineSvgs = images.inlineSvgs;
1178
- const docGroups = normalizeDocGroups(opts.docGroups);
1179
- const defaultDocGroup = typeof opts.defaultDocGroup === "string" && opts.defaultDocGroup.trim().length > 0 ? opts.defaultDocGroup.trim() : void 0;
1180
- const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
1181
- const menu = normalizeMenu(opts.menu);
1182
- const clubSidebarItems = opts.clubSidebarItems === true;
1183
- const { value: collapsibleSidebarSections, warnings: collapsibleWarnings } = normalizeCollapsibleSidebarSections(opts.collapsibleSidebarSections);
1184
- collapsibleWarnings.forEach((w) => console.warn(`clean-jsdoc-theme: ${w}`));
1185
- const { value: scrollbar, warnings: scrollbarWarnings } = normalizeScrollbar(opts.scrollbar);
1186
- scrollbarWarnings.forEach((w) => console.warn(`clean-jsdoc-theme: ${w}`));
1187
- const playground = normalizePlayground(opts.playground);
1188
- const siteOptions = {
1189
- ...pkg ? { pkg } : {},
1190
- ...resolvedReadme ? { readme: resolvedReadme } : {},
1191
- ...resolvedTutorials.length > 0 ? { tutorials: resolvedTutorials } : {},
1192
- ...sources.length > 0 ? { sources } : {},
1193
- ...sources.length > 0 && sourceLinkToComment ? { sourceLinkToComment } : {},
1194
- ...docs.length > 0 ? { docs } : {},
1195
- ...docGroups ? { docGroups } : {},
1196
- ...defaultDocGroup ? { defaultDocGroup } : {},
1197
- ...sectionOrder ? { sectionOrder } : {},
1198
- ...menu ? { menu } : {},
1199
- ...clubSidebarItems ? { clubSidebarItems } : {},
1200
- ...collapsibleSidebarSections !== void 0 ? { collapsibleSidebarSections } : {},
1201
- ...playground ? { playground: playground.site } : {}
1202
- };
1203
- const manifest = await progress.stage(
1204
- "Generating pages",
1205
- () => buildSpec ? stampSite(data, buildSpec.apiMessages, siteOptions) : generateSite(data, siteOptions)
1206
- );
1207
- if (Array.isArray(collapsibleSidebarSections)) {
1208
- const present = topLevelSectionLabels(manifest.nav);
1209
- const unmatched = unmatchedCollapsibleSections(collapsibleSidebarSections, present);
1210
- if (unmatched.length > 0) {
1211
- console.warn(
1212
- `clean-jsdoc-theme: collapsibleSidebarSections \u2014 no sidebar section matches ${unmatched.map((l) => `'${l}'`).join(", ")}. Available sections: ${present.join(", ")}.`
1213
- );
1214
- }
1215
- }
1216
- const extractPath = process.env.CLEAN_JSDOC_THEME_EXTRACT?.trim();
1217
- if (extractPath) {
1218
- const target = (0, import_node_path2.resolve)(extractPath);
1219
- await progress.stage("Writing extract manifest", async () => {
1220
- await (0, import_promises2.mkdir)((0, import_node_path2.dirname)(target), { recursive: true });
1221
- await (0, import_promises2.writeFile)(target, JSON.stringify(toExtractManifest(manifest), null, 2) + "\n", "utf8");
1222
- });
1223
- console.log(
1224
- `clean-jsdoc-theme: extract mode \u2014 wrote ${manifest.slots?.length ?? 0} slot(s) to ${target}`
1225
- );
1226
- return;
1227
- }
1228
- const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed);
1229
- const notGoogle = new Set(
1230
- diagnostics.list.filter((d) => d.code === "fonts/not-google" && d.path).map((d) => d.path)
1231
- );
1232
- const fonts = { ...value.fonts };
1233
- if (notGoogle.has("fonts.heading")) delete fonts.heading;
1234
- if (notGoogle.has("fonts.body")) delete fonts.body;
1235
- if (fonts.locales) {
1236
- const cleaned = {};
1237
- for (const [loc, set] of Object.entries(fonts.locales)) {
1238
- const s = { ...set };
1239
- if (notGoogle.has(`fonts.${loc}:heading`)) delete s.heading;
1240
- if (notGoogle.has(`fonts.${loc}:body`)) delete s.body;
1241
- cleaned[loc] = s;
1242
- }
1243
- fonts.locales = cleaned;
1244
- }
1245
- const customAssets = await resolveCustomAssets(opts, hrefForServed);
1246
- const footer = await resolveFooter(opts.footer);
1247
- const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed);
1248
- const meta = normalizeMeta(opts.meta);
1249
- const absoluteDestination = (0, import_node_path2.resolve)(destination);
1250
- const islandCacheDir = (0, import_node_path2.resolve)(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
1251
- const result = await progress.stage(
1252
- "Rendering site",
1253
- () => render(manifest, {
1254
- theme: {
1255
- ...resolveTheme(opts, siteName, fonts, basePath, buildSpec?.locale),
1256
- ...customAssets.theme,
1257
- ...footer ? { footer } : {},
1258
- ...favicon ? { favicon: favicon.href } : {},
1259
- ...meta ? { meta } : {},
1260
- ...scrollbar ? { scrollbar } : {}
1261
- },
1262
- destination: absoluteDestination,
1263
- islandCacheDir,
1264
- inlineSvgs: allInlineSvgs,
1265
- // Emit sitemap.xml when a public site URL is configured (the protocol needs
1266
- // absolute URLs). In a localized build each locale's basePath yields that
1267
- // locale's URLs, so each locale dir gets its own sitemap.
1268
- ...nonEmptyString(opts.siteUrl) ? { siteUrl: opts.siteUrl.trim() } : {},
1269
- // Build mode: render chrome in the locale (SSR provider + island seeding)
1270
- // and, with >1 locale, mount the language switcher.
1271
- ...buildSpec ? {
1272
- locale: {
1273
- code: buildSpec.locale,
1274
- defaultLocale: buildSpec.defaultLocale,
1275
- messages: buildSpec.chromeMessages,
1276
- siteBasePath: buildSpec.siteBasePath,
1277
- locales: buildSpec.locales.map((l) => ({ code: l.code, label: l.name ?? l.code }))
1278
- }
1279
- } : {}
1280
- })
1281
- );
1282
- const generatedFiles = [
1283
- ...result.files,
1284
- ...logoFiles,
1285
- ...customAssets.files,
1286
- ...imageFiles,
1287
- ...favicon?.files ?? []
1288
- ];
1289
- const staticOutputFiles = [];
1290
- if (staticFiles) {
1291
- const generatedPaths = new Set(generatedFiles.map((f) => f.path));
1292
- const RESERVED_PREFIXES = ["_assets/", "_islands/", "pagefind/"];
1293
- let skippedConsumed = 0;
1294
- for (const f of staticFiles.files) {
1295
- if (images.consumed.has(f.absSource)) {
1296
- skippedConsumed++;
1297
- continue;
1298
- }
1299
- if (generatedPaths.has(f.outputPath) || RESERVED_PREFIXES.some((p) => f.outputPath.startsWith(p))) {
1300
- console.warn(
1301
- `clean-jsdoc-theme: static file '${f.outputPath}' would clobber generated output; skipping it.`
1302
- );
1303
- continue;
1304
- }
1305
- staticOutputFiles.push({ path: f.outputPath, contents: f.contents });
1306
- }
1307
- if (staticFiles.files.length > 0) {
1308
- console.log(
1309
- `clean-jsdoc-theme: staticFiles \u2014 copied ${staticOutputFiles.length} file(s) verbatim` + (skippedConsumed > 0 ? ` (${skippedConsumed} served hashed via _assets/)` : "") + "."
1310
- );
1311
- }
1312
- }
1313
- const outputFiles = [...generatedFiles, ...staticOutputFiles];
1314
- if (!buildSpec && cleanOutputDirEnabled(opts)) {
1315
- await progress.stage(
1316
- "Cleaning output",
1317
- () => (0, import_promises2.rm)(absoluteDestination, { recursive: true, force: true })
1318
- );
1319
- }
1320
- await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
1321
- const zlib = await import("zlib");
1322
- const gzipSizer = (b) => zlib.gzipSync(b).length;
1323
- console.log(
1324
- formatBuildReport({
1325
- files: outputFiles,
1326
- stats: result.stats,
1327
- destination,
1328
- gzipSizer,
1329
- color
1330
- })
1331
- );
1332
- if (result.errors && result.errors.length > 0) {
1333
- console.warn(
1334
- `clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`
1335
- );
1336
- for (const e of result.errors) {
1337
- console.warn(formatRenderError(e));
1338
- }
1339
- }
1340
- if (result.warnings && result.warnings.length > 0) {
1341
- console.warn(
1342
- `clean-jsdoc-theme: ${result.warnings.length} content warning(s) (non-fatal):`
1343
- );
1344
- for (const w of result.warnings) {
1345
- console.warn(formatRenderError(w));
1346
- }
1347
- }
1348
- try {
1349
- await progress.stage(
1350
- "Indexing search (pagefind)",
1351
- () => runPagefindAgainstDir(absoluteDestination)
1352
- );
1353
- } catch (err) {
1354
- console.warn(`clean-jsdoc-theme: pagefind step skipped (optional) \u2014 ${err.message}`);
1355
- }
1382
+ const buildSpec = readBuildSpec();
1383
+ const destination = buildSpec?.destination ?? opts.destination;
1384
+ if (!destination || typeof destination !== "string") throw new Error("clean-jsdoc-theme publish: opts.destination is required (set \"opts.destination\" in your jsdoc.json).");
1385
+ assertMarkdownPlugin();
1386
+ const color = Boolean(process.stdout.isTTY) && opts.nocolor !== true;
1387
+ const docsDir = typeof opts.docs === "string" && opts.docs.trim().length > 0 ? opts.docs.trim() : void 0;
1388
+ const tutorialsDir = typeof opts.tutorials === "string" && opts.tutorials.trim().length > 0 ? opts.tutorials.trim() : void 0;
1389
+ const staticCfg = readStaticFilesConfig(opts);
1390
+ const pkgPromise = resolvePkg(data, opts);
1391
+ const sourcesPromise = outputSourceFilesEnabled(opts) ? collectSourceFiles(data) : Promise.resolve([]);
1392
+ const docsPromise = docsDir ? collectDocs(docsDir) : Promise.resolve([]);
1393
+ const progress = createBuildProgress(opts.progress === false ? null : await loadOra());
1394
+ const [{ generateSite, stampSite }, { render }, { validateThemeOpts, createGoogleFontResolver, formatDiagnostics, warningsOnly, formatBuildReport, formatRenderError, normalizeBasePath, withBase, toExtractManifest, normalizeCollapsibleSidebarSections, unmatchedCollapsibleSections, topLevelSectionLabels, normalizeScrollbar }] = await progress.stage("Loading renderer", async ({ setText }) => {
1395
+ setText("Loading renderer (setu)");
1396
+ const setu = await loadSetu();
1397
+ setText("Loading renderer (dwar)");
1398
+ const dwar = await loadDwar();
1399
+ setText("Loading renderer (utils)");
1400
+ return [
1401
+ setu,
1402
+ dwar,
1403
+ await loadUtils()
1404
+ ];
1405
+ });
1406
+ const basePath = normalizeBasePath(buildSpec?.basePath ?? opts.basePath);
1407
+ const hrefForServed = (servedPath) => withBase(basePath, "/" + servedPath);
1408
+ const fontResolver = createGoogleFontResolver();
1409
+ const { value, diagnostics } = await progress.stage("Validating options", () => validateThemeOpts({
1410
+ opts,
1411
+ fontResolver,
1412
+ unknownKeyPolicy: "suggest-typos",
1413
+ knownNonThemeKeys: JSDOC_OWN_OPTS
1414
+ }));
1415
+ const strict = opts.strict === true || opts.templates?.default?.strict === true;
1416
+ if (diagnostics.list.length > 0) {
1417
+ const formatted = formatDiagnostics(diagnostics, { color });
1418
+ if (strict && diagnostics.hasErrors()) {
1419
+ console.error(formatted);
1420
+ throw new Error("clean-jsdoc-theme: opts validation failed in strict mode (see the diagnostics above). Fix the errors or unset `strict`.");
1421
+ }
1422
+ console.log(formatted);
1423
+ }
1424
+ const pkg = await pkgPromise;
1425
+ const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
1426
+ const tutorialTree = normalizeTutorials(tutorials);
1427
+ const sourceLinkToComment = sourceLinkToCommentEnabled(opts);
1428
+ const staticFiles = staticCfg ? await progress.stage("Reading static files", () => collectStaticFiles(staticCfg, (m) => console.warn(m))) : void 0;
1429
+ const images = createImageCollector(staticFiles?.searchDirs ?? []);
1430
+ const { sources, docs } = await progress.stage("Reading sources & docs", async () => {
1431
+ const [srcs, rawDocs] = await Promise.all([sourcesPromise, docsPromise]);
1432
+ const base = docsDir ? await resolveDocImages(rawDocs, docsDir, images) : { docs: rawDocs };
1433
+ if (!buildSpec?.docsDir) return {
1434
+ sources: srcs,
1435
+ docs: base.docs
1436
+ };
1437
+ const locale = await resolveDocImages(await collectDocs(buildSpec.docsDir), buildSpec.docsDir, images);
1438
+ return {
1439
+ sources: srcs,
1440
+ docs: overlayDocs({
1441
+ docs: base.docs,
1442
+ files: [],
1443
+ inlineSvgs: {}
1444
+ }, {
1445
+ docs: locale.docs,
1446
+ files: [],
1447
+ inlineSvgs: {}
1448
+ }).docs
1449
+ };
1450
+ });
1451
+ const { tutorialTree: resolvedTutorials, readme: resolvedReadme } = await progress.stage("Resolving prose images", async () => {
1452
+ const tree = tutorialsDir && tutorialTree.length > 0 ? await resolveTutorialImages(tutorialTree, tutorialsDir, images) : tutorialTree;
1453
+ const md = readme ? await rewriteImageRefs(readme, process.cwd(), images) : readme;
1454
+ await resolveDocletImages(data, images);
1455
+ return {
1456
+ tutorialTree: tree,
1457
+ readme: md
1458
+ };
1459
+ });
1460
+ const imageFiles = images.files;
1461
+ const allInlineSvgs = images.inlineSvgs;
1462
+ const docGroups = normalizeDocGroups(opts.docGroups);
1463
+ const defaultDocGroup = typeof opts.defaultDocGroup === "string" && opts.defaultDocGroup.trim().length > 0 ? opts.defaultDocGroup.trim() : void 0;
1464
+ const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
1465
+ const menu = normalizeMenu(opts.menu);
1466
+ const clubSidebarItems = opts.clubSidebarItems === true;
1467
+ const { value: collapsibleSidebarSections, warnings: collapsibleWarnings } = normalizeCollapsibleSidebarSections(opts.collapsibleSidebarSections);
1468
+ collapsibleWarnings.forEach((w) => console.warn(`clean-jsdoc-theme: ${w}`));
1469
+ const { value: scrollbar, warnings: scrollbarWarnings } = normalizeScrollbar(opts.scrollbar);
1470
+ scrollbarWarnings.forEach((w) => console.warn(`clean-jsdoc-theme: ${w}`));
1471
+ const playground = normalizePlayground(opts.playground);
1472
+ const siteOptions = {
1473
+ ...pkg ? { pkg } : {},
1474
+ ...resolvedReadme ? { readme: resolvedReadme } : {},
1475
+ ...resolvedTutorials.length > 0 ? { tutorials: resolvedTutorials } : {},
1476
+ ...sources.length > 0 ? { sources } : {},
1477
+ ...sources.length > 0 && sourceLinkToComment ? { sourceLinkToComment } : {},
1478
+ ...docs.length > 0 ? { docs } : {},
1479
+ ...docGroups ? { docGroups } : {},
1480
+ ...defaultDocGroup ? { defaultDocGroup } : {},
1481
+ ...sectionOrder ? { sectionOrder } : {},
1482
+ ...menu ? { menu } : {},
1483
+ ...clubSidebarItems ? { clubSidebarItems } : {},
1484
+ ...collapsibleSidebarSections !== void 0 ? { collapsibleSidebarSections } : {},
1485
+ ...playground ? { playground: playground.site } : {}
1486
+ };
1487
+ const manifest = await progress.stage("Generating pages", () => buildSpec ? stampSite(data, buildSpec.apiMessages, siteOptions) : generateSite(data, siteOptions));
1488
+ if (Array.isArray(collapsibleSidebarSections)) {
1489
+ const present = topLevelSectionLabels(manifest.nav);
1490
+ const unmatched = unmatchedCollapsibleSections(collapsibleSidebarSections, present);
1491
+ if (unmatched.length > 0) console.warn(`clean-jsdoc-theme: collapsibleSidebarSections — no sidebar section matches ${unmatched.map((l) => `'${l}'`).join(", ")}. Available sections: ${present.join(", ")}.`);
1492
+ }
1493
+ const extractPath = process.env.CLEAN_JSDOC_THEME_EXTRACT?.trim();
1494
+ if (extractPath) {
1495
+ const target = (0, node_path.resolve)(extractPath);
1496
+ await progress.stage("Writing extract manifest", async () => {
1497
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(target), { recursive: true });
1498
+ await (0, node_fs_promises.writeFile)(target, JSON.stringify(toExtractManifest(manifest), null, 2) + "\n", "utf8");
1499
+ });
1500
+ console.log(`clean-jsdoc-theme: extract mode — wrote ${manifest.slots?.length ?? 0} slot(s) to ${target}`);
1501
+ return;
1502
+ }
1503
+ const { siteName, files: logoFiles } = await prepareSiteName(value.siteName, hrefForServed);
1504
+ const notGoogle = new Set(diagnostics.list.filter((d) => d.code === "fonts/not-google" && d.path).map((d) => d.path));
1505
+ const fonts = { ...value.fonts };
1506
+ if (notGoogle.has("fonts.heading")) delete fonts.heading;
1507
+ if (notGoogle.has("fonts.body")) delete fonts.body;
1508
+ if (fonts.locales) {
1509
+ const cleaned = {};
1510
+ for (const [loc, set] of Object.entries(fonts.locales)) {
1511
+ const s = { ...set };
1512
+ if (notGoogle.has(`fonts.${loc}:heading`)) delete s.heading;
1513
+ if (notGoogle.has(`fonts.${loc}:body`)) delete s.body;
1514
+ cleaned[loc] = s;
1515
+ }
1516
+ fonts.locales = cleaned;
1517
+ }
1518
+ const customAssets = await resolveCustomAssets(opts, hrefForServed);
1519
+ const footer = await resolveFooter(opts.footer);
1520
+ const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed);
1521
+ const meta = normalizeMeta(opts.meta);
1522
+ const absoluteDestination = (0, node_path.resolve)(destination);
1523
+ const islandCacheDir = (0, node_path.resolve)(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
1524
+ const result = await progress.stage("Rendering site", () => render(manifest, {
1525
+ theme: {
1526
+ ...resolveTheme(opts, siteName, fonts, basePath, buildSpec?.locale),
1527
+ ...customAssets.theme,
1528
+ ...footer ? { footer } : {},
1529
+ ...favicon ? { favicon: favicon.href } : {},
1530
+ ...meta ? { meta } : {},
1531
+ ...scrollbar ? { scrollbar } : {}
1532
+ },
1533
+ destination: absoluteDestination,
1534
+ islandCacheDir,
1535
+ inlineSvgs: allInlineSvgs,
1536
+ ...value.siteUrl ? { siteUrl: value.siteUrl } : {},
1537
+ ...value.llmsTxt ? { llmsTxt: value.llmsTxt } : {},
1538
+ ...buildSpec ? { locale: {
1539
+ code: buildSpec.locale,
1540
+ defaultLocale: buildSpec.defaultLocale,
1541
+ messages: buildSpec.chromeMessages,
1542
+ siteBasePath: buildSpec.siteBasePath,
1543
+ locales: buildSpec.locales.map((l) => ({
1544
+ code: l.code,
1545
+ label: l.name ?? l.code
1546
+ }))
1547
+ } } : {}
1548
+ }));
1549
+ const generatedFiles = [
1550
+ ...result.files,
1551
+ ...logoFiles,
1552
+ ...customAssets.files,
1553
+ ...imageFiles,
1554
+ ...favicon?.files ?? []
1555
+ ];
1556
+ const staticOutputFiles = [];
1557
+ if (staticFiles) {
1558
+ const generatedPaths = new Set(generatedFiles.map((f) => f.path));
1559
+ const RESERVED_PREFIXES = ["_assets/", "_islands/"];
1560
+ let skippedConsumed = 0;
1561
+ for (const f of staticFiles.files) {
1562
+ if (images.consumed.has(f.absSource)) {
1563
+ skippedConsumed++;
1564
+ continue;
1565
+ }
1566
+ if (generatedPaths.has(f.outputPath) || RESERVED_PREFIXES.some((p) => f.outputPath.startsWith(p))) {
1567
+ console.warn(`clean-jsdoc-theme: static file '${f.outputPath}' would clobber generated output; skipping it.`);
1568
+ continue;
1569
+ }
1570
+ staticOutputFiles.push({
1571
+ path: f.outputPath,
1572
+ contents: f.contents
1573
+ });
1574
+ }
1575
+ if (staticFiles.files.length > 0) console.log(`clean-jsdoc-theme: staticFiles — copied ${staticOutputFiles.length} file(s) verbatim` + (skippedConsumed > 0 ? ` (${skippedConsumed} served hashed via _assets/)` : "") + ".");
1576
+ }
1577
+ const outputFiles = [...generatedFiles, ...staticOutputFiles];
1578
+ if (!buildSpec && cleanOutputDirEnabled(opts)) await progress.stage("Cleaning output", () => (0, node_fs_promises.rm)(absoluteDestination, {
1579
+ recursive: true,
1580
+ force: true
1581
+ }));
1582
+ await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
1583
+ const zlib = await import("node:zlib");
1584
+ const gzipSizer = (b) => zlib.gzipSync(b).length;
1585
+ console.log(formatBuildReport({
1586
+ files: outputFiles,
1587
+ stats: result.stats,
1588
+ destination,
1589
+ gzipSizer,
1590
+ color
1591
+ }));
1592
+ const optsWarnings = warningsOnly(diagnostics);
1593
+ if (optsWarnings.list.length > 0) console.warn(formatDiagnostics(optsWarnings, { color }));
1594
+ if (result.errors && result.errors.length > 0) {
1595
+ console.warn(`clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`);
1596
+ for (const e of result.errors) console.warn(formatRenderError(e));
1597
+ }
1598
+ if (result.warnings && result.warnings.length > 0) {
1599
+ console.warn(`clean-jsdoc-theme: ${result.warnings.length} content warning(s) (non-fatal):`);
1600
+ for (const w of result.warnings) console.warn(formatRenderError(w));
1601
+ }
1356
1602
  }
1357
- // Annotate the CommonJS export names for ESM import in node:
1358
- 0 && (module.exports = {
1359
- cleanOutputDirEnabled,
1360
- collectDocs,
1361
- collectStaticFiles,
1362
- computeRelPaths,
1363
- createImageCollector,
1364
- hasMarkdownPlugin,
1365
- normalizeColors,
1366
- normalizeCopyPage,
1367
- normalizeDocGroups,
1368
- normalizeMenu,
1369
- normalizeMeta,
1370
- normalizePageNav,
1371
- normalizePlayground,
1372
- normalizeSectionOrder,
1373
- normalizeStaticFilesConfig,
1374
- outputSourceFilesEnabled,
1375
- overlayDocs,
1376
- publish,
1377
- readStaticFilesConfig,
1378
- resolveDocImages,
1379
- resolveDocletImages,
1380
- resolveFavicon,
1381
- resolveFooter,
1382
- resolveTutorialImages,
1383
- sourceLinkToCommentEnabled,
1384
- staticFileIncluded,
1385
- staticFileOutputName
1386
- });
1603
+ //#endregion
1604
+ exports.cleanOutputDirEnabled = cleanOutputDirEnabled;
1605
+ exports.collectDocs = collectDocs;
1606
+ exports.collectStaticFiles = collectStaticFiles;
1607
+ exports.computeRelPaths = computeRelPaths;
1608
+ exports.createImageCollector = createImageCollector;
1609
+ exports.hasMarkdownPlugin = hasMarkdownPlugin;
1610
+ exports.normalizeColors = normalizeColors;
1611
+ exports.normalizeCopyPage = normalizeCopyPage;
1612
+ exports.normalizeDocGroups = normalizeDocGroups;
1613
+ exports.normalizeMenu = normalizeMenu;
1614
+ exports.normalizeMeta = normalizeMeta;
1615
+ exports.normalizePageNav = normalizePageNav;
1616
+ exports.normalizePlayground = normalizePlayground;
1617
+ exports.normalizeSectionOrder = normalizeSectionOrder;
1618
+ exports.normalizeStaticFilesConfig = normalizeStaticFilesConfig;
1619
+ exports.outputSourceFilesEnabled = outputSourceFilesEnabled;
1620
+ exports.overlayDocs = overlayDocs;
1621
+ exports.publish = publish;
1622
+ exports.readStaticFilesConfig = readStaticFilesConfig;
1623
+ exports.resolveDocImages = resolveDocImages;
1624
+ exports.resolveDocletImages = resolveDocletImages;
1625
+ exports.resolveFavicon = resolveFavicon;
1626
+ exports.resolveFooter = resolveFooter;
1627
+ exports.resolveTutorialImages = resolveTutorialImages;
1628
+ exports.sourceLinkToCommentEnabled = sourceLinkToCommentEnabled;
1629
+ exports.staticFileIncluded = staticFileIncluded;
1630
+ exports.staticFileOutputName = staticFileOutputName;
1631
+
1387
1632
  //# sourceMappingURL=publish.js.map