clean-jsdoc-theme 5.0.3 → 5.0.5

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.mjs CHANGED
@@ -5,12 +5,18 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
5
5
  throw Error('Dynamic require of "' + x + '" is not supported');
6
6
  });
7
7
 
8
+ // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.10_tsx@4.22.3_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js
9
+ import path from "path";
10
+ import { fileURLToPath } from "url";
11
+ var getFilename = () => fileURLToPath(import.meta.url);
12
+ var __filename = /* @__PURE__ */ getFilename();
13
+
8
14
  // src/publish.ts
9
- import { mkdir as mkdir2, readFile, readdir, writeFile as writeFile2 } from "fs/promises";
15
+ import { mkdir as mkdir2, readFile, readdir, rm, stat, writeFile as writeFile2 } from "fs/promises";
10
16
  import { readFileSync } from "fs";
11
17
  import { createHash } from "crypto";
12
18
  import { basename, dirname as dirname2, extname, join as joinPath, resolve as resolvePath } from "path";
13
- import { pathToFileURL, fileURLToPath } from "url";
19
+ import { pathToFileURL } from "url";
14
20
 
15
21
  // src/write-output-files.ts
16
22
  import { mkdir, writeFile } from "fs/promises";
@@ -28,18 +34,8 @@ async function writeOutputFiles(destination, files) {
28
34
  var JSDOC_TUTORIAL_TYPE_MARKDOWN = 2;
29
35
  function anchorPath() {
30
36
  if (typeof __filename === "string") return __filename;
31
- try {
32
- const getEsmUrl = new Function(
33
- "try { return import.meta && import.meta.url; } catch { return undefined; }"
34
- );
35
- const url = getEsmUrl();
36
- if (typeof url === "string" && url.startsWith("file://")) {
37
- return fileURLToPath(url);
38
- }
39
- } catch {
40
- }
41
37
  throw new Error(
42
- "clean-jsdoc-theme: could not determine the running module path (neither __filename nor import.meta.url resolved)."
38
+ "clean-jsdoc-theme: could not determine the running module path (__filename is unavailable)."
43
39
  );
44
40
  }
45
41
  function resolvePackageDir(name) {
@@ -416,6 +412,15 @@ function sourceLinkToCommentEnabled(opts) {
416
412
  if (opts?.templates?.default?.sourceLinkToComment === true) return true;
417
413
  return false;
418
414
  }
415
+ function cleanOutputDirEnabled(opts) {
416
+ try {
417
+ const env = __require("jsdoc/env");
418
+ if (env?.conf?.templates?.default?.cleanOutputDir === false) return false;
419
+ } catch {
420
+ }
421
+ if (opts?.templates?.default?.cleanOutputDir === false) return false;
422
+ return true;
423
+ }
419
424
  function hasMarkdownPlugin(plugins) {
420
425
  if (!Array.isArray(plugins)) return false;
421
426
  return plugins.some((p) => typeof p === "string" && /(^|[\\/])markdown(\.js)?$/i.test(p.trim()));
@@ -652,62 +657,295 @@ async function collectDocs(dir) {
652
657
  return docs;
653
658
  }
654
659
  var DOC_IMAGE_RE = /(!\[[^\]]*\]\()([^)\s]+)((?:\s+"[^"]*")?\))/g;
655
- async function resolveDocImages(docs, docsDir) {
656
- if (docs.length === 0) return { docs, files: [], inlineSvgs: {} };
657
- const root = resolvePath(docsDir);
660
+ var HTML_IMAGE_RE = /(<img\b[^>]*?\bsrc\s*=\s*(["']))([^"']*)(\2)/gi;
661
+ function createImageCollector(staticDirs = []) {
658
662
  const files = [];
659
- const seenServed = /* @__PURE__ */ new Set();
660
663
  const inlineSvgs = {};
664
+ const consumed = /* @__PURE__ */ new Set();
665
+ const seenServed = /* @__PURE__ */ new Set();
661
666
  const cache = /* @__PURE__ */ new Map();
662
- const resolveOne = async (rawSrc, docDir) => {
667
+ const warnedMisses = /* @__PURE__ */ new Set();
668
+ const resolve = async (rawSrc, baseDir) => {
663
669
  const src = rawSrc.trim();
664
670
  if (!src || isServableUrl(src) || src.startsWith("#") || src.startsWith("data:")) return null;
665
- const abs = src.startsWith("/") ? resolvePath(src.slice(1)) : resolvePath(docDir, src);
666
- if (cache.has(abs)) return cache.get(abs) ?? null;
667
- let bytes;
668
- try {
669
- bytes = await readFile(abs);
670
- } catch {
671
+ const primary = src.startsWith("/") ? resolvePath(src.slice(1)) : resolvePath(baseDir, src);
672
+ const candidates = [primary];
673
+ if (staticDirs.length > 0) {
674
+ const outName = src.replace(/^\/+/, "");
675
+ if (outName) for (const dir of staticDirs) candidates.push(resolvePath(dir, outName));
676
+ }
677
+ for (const abs of candidates) {
678
+ const cached = cache.get(abs);
679
+ if (cached !== void 0) {
680
+ if (cached) return cached;
681
+ continue;
682
+ }
683
+ let bytes;
684
+ try {
685
+ bytes = await readFile(abs);
686
+ } catch {
687
+ cache.set(abs, null);
688
+ continue;
689
+ }
690
+ const ext = extname(abs);
691
+ const served = `_assets/${basename(abs, ext) || "asset"}.${contentHash(bytes)}${ext}`;
692
+ if (!seenServed.has(served)) {
693
+ seenServed.add(served);
694
+ files.push({ path: served, contents: bytes });
695
+ }
696
+ const href = "/" + served;
697
+ if (ext.toLowerCase() === ".svg") {
698
+ inlineSvgs[href] = bytes.toString("utf8").replace(/<svg\b/, '<svg style="max-width:100%;height:auto;display:block"');
699
+ }
700
+ cache.set(abs, href);
701
+ consumed.add(abs);
702
+ return href;
703
+ }
704
+ if (!warnedMisses.has(src)) {
705
+ warnedMisses.add(src);
671
706
  console.warn(
672
- `clean-jsdoc-theme: could not read doc image '${src}' (resolved '${abs}'); leaving it as-is.`
707
+ `clean-jsdoc-theme: could not read image '${src}' (looked in: ${candidates.join(", ")}); leaving it as-is.`
673
708
  );
674
- cache.set(abs, null);
675
- return null;
676
- }
677
- const ext = extname(abs);
678
- const served = `_assets/${basename(abs, ext) || "asset"}.${contentHash(bytes)}${ext}`;
679
- if (!seenServed.has(served)) {
680
- seenServed.add(served);
681
- files.push({ path: served, contents: bytes });
682
709
  }
683
- const href = "/" + served;
684
- if (ext.toLowerCase() === ".svg") {
685
- inlineSvgs[href] = bytes.toString("utf8").replace(/<svg\b/, '<svg style="max-width:100%;height:auto;display:block"');
710
+ return null;
711
+ };
712
+ return { resolve, files, inlineSvgs, consumed };
713
+ }
714
+ var CODE_REGION_RE = /```[\s\S]*?```|~~~[\s\S]*?~~~|<pre[\s\S]*?<\/pre>|<code[^>]*>[\s\S]*?<\/code>|`[^`\n]+`/gi;
715
+ function codeRanges(content) {
716
+ const ranges = [];
717
+ for (const m of content.matchAll(CODE_REGION_RE)) {
718
+ if (m.index !== void 0) ranges.push([m.index, m.index + m[0].length]);
719
+ }
720
+ return ranges;
721
+ }
722
+ function indexInCode(idx, ranges) {
723
+ for (const [s, e] of ranges) if (idx >= s && idx < e) return true;
724
+ return false;
725
+ }
726
+ async function rewriteImageRefs(content, baseDir, collector) {
727
+ if (!content) return content;
728
+ const ranges = codeRanges(content);
729
+ const map = /* @__PURE__ */ new Map();
730
+ const collect = async (re, srcGroup) => {
731
+ for (const m of content.matchAll(re)) {
732
+ if (m.index !== void 0 && indexInCode(m.index, ranges)) continue;
733
+ const src = m[srcGroup];
734
+ if (map.has(src)) continue;
735
+ const href = await collector.resolve(src, baseDir);
736
+ if (href) map.set(src, href);
686
737
  }
687
- cache.set(abs, href);
688
- return href;
689
738
  };
739
+ await collect(DOC_IMAGE_RE, 2);
740
+ await collect(HTML_IMAGE_RE, 3);
741
+ if (map.size === 0) return content;
742
+ return content.replace(
743
+ DOC_IMAGE_RE,
744
+ (full, pre, src, post, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${post}` : full
745
+ ).replace(
746
+ HTML_IMAGE_RE,
747
+ (full, pre, _quote, src, close, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${close}` : full
748
+ );
749
+ }
750
+ async function resolveDocImages(docs, docsDir, collector = createImageCollector()) {
751
+ if (docs.length === 0) return { docs, files: collector.files, inlineSvgs: collector.inlineSvgs };
752
+ const root = resolvePath(docsDir);
690
753
  const out = [];
691
754
  for (const doc of docs) {
692
755
  const docDir = dirname2(resolvePath(root, doc.path));
693
- const map = /* @__PURE__ */ new Map();
694
- for (const m of doc.content.matchAll(DOC_IMAGE_RE)) {
695
- const src = m[2];
696
- if (map.has(src)) continue;
697
- const href = await resolveOne(src, docDir);
698
- if (href) map.set(src, href);
756
+ const content = await rewriteImageRefs(doc.content, docDir, collector);
757
+ out.push(content === doc.content ? doc : { ...doc, content });
758
+ }
759
+ return { docs: out, files: collector.files, inlineSvgs: collector.inlineSvgs };
760
+ }
761
+ async function resolveTutorialImages(tree, tutorialsDir, collector) {
762
+ const base = resolvePath(tutorialsDir);
763
+ const walk = async (node) => {
764
+ const content = await rewriteImageRefs(node.content, base, collector);
765
+ const children = [];
766
+ for (const child of node.children ?? []) children.push(await walk(child));
767
+ return { ...node, content, children };
768
+ };
769
+ const out = [];
770
+ for (const node of tree) out.push(await walk(node));
771
+ return out;
772
+ }
773
+ var DOCLET_IMAGE_SKIP_KEYS = /* @__PURE__ */ new Set([
774
+ "meta",
775
+ "comment",
776
+ "examples",
777
+ "tags",
778
+ "___id",
779
+ "___s"
780
+ ]);
781
+ async function rewriteDocletStrings(node, baseDir, collector) {
782
+ for (const [key, value] of Object.entries(node)) {
783
+ if (DOCLET_IMAGE_SKIP_KEYS.has(key)) continue;
784
+ if (typeof value === "string") {
785
+ if (value.includes("<img") || value.includes("![")) {
786
+ const rewritten = await rewriteImageRefs(value, baseDir, collector);
787
+ if (rewritten !== value) node[key] = rewritten;
788
+ }
789
+ } else if (Array.isArray(value)) {
790
+ for (let i = 0; i < value.length; i++) {
791
+ const item = value[i];
792
+ if (typeof item === "string") {
793
+ if (item.includes("<img") || item.includes("![")) {
794
+ const rewritten = await rewriteImageRefs(item, baseDir, collector);
795
+ if (rewritten !== item) value[i] = rewritten;
796
+ }
797
+ } else if (item && typeof item === "object") {
798
+ await rewriteDocletStrings(item, baseDir, collector);
799
+ }
800
+ }
801
+ } else if (value && typeof value === "object") {
802
+ await rewriteDocletStrings(value, baseDir, collector);
803
+ }
804
+ }
805
+ }
806
+ async function resolveDocletImages(data, collector) {
807
+ if (typeof data !== "function") return;
808
+ let doclets = [];
809
+ try {
810
+ doclets = data({}).get();
811
+ } catch {
812
+ try {
813
+ doclets = data().get();
814
+ } catch {
815
+ return;
699
816
  }
700
- if (map.size === 0) {
701
- out.push(doc);
817
+ }
818
+ if (!Array.isArray(doclets)) return;
819
+ for (const d of doclets) {
820
+ if (!d || typeof d !== "object") continue;
821
+ const meta = d.meta;
822
+ if (!meta || typeof meta.path !== "string" || meta.path.length === 0) continue;
823
+ await rewriteDocletStrings(d, meta.path, collector);
824
+ }
825
+ }
826
+ function normalizeStaticFilesConfig(raw) {
827
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
828
+ const o = raw;
829
+ const toStrArr = (v) => (Array.isArray(v) ? v : typeof v === "string" ? [v] : []).filter((s) => typeof s === "string" && s.trim().length > 0).map((s) => s.trim());
830
+ const include = toStrArr(o.include);
831
+ if (include.length === 0) return void 0;
832
+ const includePattern = typeof o.includePattern === "string" && o.includePattern.trim().length > 0 ? o.includePattern : void 0;
833
+ const excludePattern = typeof o.excludePattern === "string" && o.excludePattern.trim().length > 0 ? o.excludePattern : void 0;
834
+ return {
835
+ include,
836
+ exclude: toStrArr(o.exclude),
837
+ ...includePattern ? { includePattern } : {},
838
+ ...excludePattern ? { excludePattern } : {}
839
+ };
840
+ }
841
+ function readStaticFilesConfig(opts) {
842
+ try {
843
+ const env = __require("jsdoc/env");
844
+ const fromEnv = normalizeStaticFilesConfig(env?.conf?.templates?.default?.staticFiles);
845
+ if (fromEnv) return fromEnv;
846
+ } catch {
847
+ }
848
+ return normalizeStaticFilesConfig(opts?.templates?.default?.staticFiles);
849
+ }
850
+ function staticFileOutputName(absFile, includeRootAbs) {
851
+ const norm = (p) => p.replace(/\\/g, "/").replace(/\/+$/, "");
852
+ const f = norm(absFile);
853
+ const root = norm(includeRootAbs);
854
+ const baseOf = (p) => p.slice(p.lastIndexOf("/") + 1);
855
+ if (f === root) return baseOf(f);
856
+ const prefix = root + "/";
857
+ return f.toLowerCase().startsWith(prefix.toLowerCase()) ? f.slice(prefix.length) : baseOf(f);
858
+ }
859
+ function staticFileIncluded(absFile, config) {
860
+ const norm = (p) => resolvePath(p).replace(/\\/g, "/");
861
+ const fn = norm(absFile);
862
+ if (config.includePattern) {
863
+ try {
864
+ if (!new RegExp(config.includePattern).test(fn)) return false;
865
+ } catch {
866
+ }
867
+ }
868
+ if (config.excludePattern) {
869
+ try {
870
+ if (new RegExp(config.excludePattern).test(fn)) return false;
871
+ } catch {
872
+ }
873
+ }
874
+ for (const ex of config.exclude) {
875
+ const exAbs = norm(ex);
876
+ if (fn === exAbs || fn.toLowerCase().startsWith(exAbs.toLowerCase() + "/")) return false;
877
+ }
878
+ return true;
879
+ }
880
+ var STATIC_DIR_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".svn", ".hg"]);
881
+ async function collectStaticFiles(config, warn = (m) => console.warn(m)) {
882
+ const files = [];
883
+ const searchDirs = /* @__PURE__ */ new Set();
884
+ const seenOutput = /* @__PURE__ */ new Set();
885
+ for (const inc of config.include) {
886
+ const root = resolvePath(inc);
887
+ let st;
888
+ try {
889
+ st = await stat(root);
890
+ } catch {
891
+ warn(
892
+ `clean-jsdoc-theme: staticFiles include '${inc}' (resolved '${root}') was not found; skipping it.`
893
+ );
702
894
  continue;
703
895
  }
704
- const content = doc.content.replace(
705
- DOC_IMAGE_RE,
706
- (full, pre, src, post) => map.has(src) ? `${pre}${map.get(src)}${post}` : full
707
- );
708
- out.push({ ...doc, content });
896
+ if (st.isDirectory()) {
897
+ searchDirs.add(root);
898
+ const walk = async (absDir) => {
899
+ let entries;
900
+ try {
901
+ entries = await readdir(absDir, { withFileTypes: true });
902
+ } catch {
903
+ return;
904
+ }
905
+ for (const entry of entries) {
906
+ if (entry.name.startsWith(".")) continue;
907
+ const abs = joinPath(absDir, entry.name);
908
+ if (entry.isDirectory()) {
909
+ if (!STATIC_DIR_SKIP.has(entry.name)) await walk(abs);
910
+ continue;
911
+ }
912
+ if (!entry.isFile()) continue;
913
+ if (!staticFileIncluded(abs, config)) continue;
914
+ const outputPath = staticFileOutputName(abs, root);
915
+ if (seenOutput.has(outputPath)) continue;
916
+ let contents;
917
+ try {
918
+ contents = await readFile(abs);
919
+ } catch (err) {
920
+ warn(
921
+ `clean-jsdoc-theme: could not read static file '${abs}' \u2014 ${err.message}; skipping.`
922
+ );
923
+ continue;
924
+ }
925
+ seenOutput.add(outputPath);
926
+ files.push({ outputPath, absSource: resolvePath(abs), contents });
927
+ }
928
+ };
929
+ await walk(root);
930
+ } else if (st.isFile()) {
931
+ searchDirs.add(dirname2(root));
932
+ if (!staticFileIncluded(root, config)) continue;
933
+ const outputPath = staticFileOutputName(root, root);
934
+ if (!seenOutput.has(outputPath)) {
935
+ try {
936
+ const contents = await readFile(root);
937
+ seenOutput.add(outputPath);
938
+ files.push({ outputPath, absSource: resolvePath(root), contents });
939
+ } catch (err) {
940
+ warn(
941
+ `clean-jsdoc-theme: could not read static file '${root}' \u2014 ${err.message}; skipping.`
942
+ );
943
+ }
944
+ }
945
+ }
709
946
  }
710
- return { docs: out, files, inlineSvgs };
947
+ files.sort((a, b) => a.outputPath.localeCompare(b.outputPath));
948
+ return { files, searchDirs: [...searchDirs] };
711
949
  }
712
950
  function overlayDocs(base, locale) {
713
951
  const byPath = new Map(base.docs.map((d) => [d.path, d]));
@@ -760,16 +998,16 @@ function createBuildProgress(ora) {
760
998
  return { stage };
761
999
  }
762
1000
  function readBuildSpec() {
763
- const path = process.env.CLEAN_JSDOC_THEME_BUILD?.trim();
764
- if (!path) return null;
765
- const spec = JSON.parse(readFileSync(path, "utf8"));
1001
+ const path2 = process.env.CLEAN_JSDOC_THEME_BUILD?.trim();
1002
+ if (!path2) return null;
1003
+ const spec = JSON.parse(readFileSync(path2, "utf8"));
766
1004
  if (typeof spec.version === "number" && spec.version !== 1) {
767
1005
  throw new Error(
768
1006
  `clean-jsdoc-theme: build spec version ${spec.version} unsupported (expected 1) \u2014 update clean-jsdoc-theme and aadesh together.`
769
1007
  );
770
1008
  }
771
1009
  if (typeof spec.destination !== "string" || typeof spec.basePath !== "string") {
772
- throw new Error(`clean-jsdoc-theme: malformed build spec at "${path}".`);
1010
+ throw new Error(`clean-jsdoc-theme: malformed build spec at "${path2}".`);
773
1011
  }
774
1012
  return {
775
1013
  locale: typeof spec.locale === "string" ? spec.locale : "",
@@ -794,6 +1032,8 @@ async function publish(data, opts, tutorials) {
794
1032
  assertMarkdownPlugin();
795
1033
  const color = Boolean(process.stdout.isTTY) && opts.nocolor !== true;
796
1034
  const docsDir = typeof opts.docs === "string" && opts.docs.trim().length > 0 ? opts.docs.trim() : void 0;
1035
+ const tutorialsDir = typeof opts.tutorials === "string" && opts.tutorials.trim().length > 0 ? opts.tutorials.trim() : void 0;
1036
+ const staticCfg = readStaticFilesConfig(opts);
797
1037
  const pkgPromise = resolvePkg(data, opts);
798
1038
  const sourcesPromise = outputSourceFilesEnabled(opts) ? collectSourceFiles(data) : Promise.resolve([]);
799
1039
  const docsPromise = docsDir ? collectDocs(docsDir) : Promise.resolve([]);
@@ -852,30 +1092,34 @@ async function publish(data, opts, tutorials) {
852
1092
  const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
853
1093
  const tutorialTree = normalizeTutorials(tutorials);
854
1094
  const sourceLinkToComment = sourceLinkToCommentEnabled(opts);
855
- const { sources, docs, docImageFiles, inlineSvgs } = await progress.stage(
856
- "Reading sources & docs",
1095
+ const staticFiles = staticCfg ? await progress.stage(
1096
+ "Reading static files",
1097
+ () => collectStaticFiles(staticCfg, (m) => console.warn(m))
1098
+ ) : void 0;
1099
+ const images = createImageCollector(staticFiles?.searchDirs ?? []);
1100
+ const { sources, docs } = await progress.stage("Reading sources & docs", async () => {
1101
+ const [srcs, rawDocs] = await Promise.all([sourcesPromise, docsPromise]);
1102
+ const base = docsDir ? await resolveDocImages(rawDocs, docsDir, images) : { docs: rawDocs };
1103
+ if (!buildSpec?.docsDir) return { sources: srcs, docs: base.docs };
1104
+ const localeRaw = await collectDocs(buildSpec.docsDir);
1105
+ const locale = await resolveDocImages(localeRaw, buildSpec.docsDir, images);
1106
+ const merged = overlayDocs(
1107
+ { docs: base.docs, files: [], inlineSvgs: {} },
1108
+ { docs: locale.docs, files: [], inlineSvgs: {} }
1109
+ );
1110
+ return { sources: srcs, docs: merged.docs };
1111
+ });
1112
+ const { tutorialTree: resolvedTutorials, readme: resolvedReadme } = await progress.stage(
1113
+ "Resolving prose images",
857
1114
  async () => {
858
- const [srcs, rawDocs] = await Promise.all([sourcesPromise, docsPromise]);
859
- const base = docsDir ? await resolveDocImages(rawDocs, docsDir) : { docs: rawDocs, files: [], inlineSvgs: {} };
860
- if (!buildSpec?.docsDir) {
861
- return {
862
- sources: srcs,
863
- docs: base.docs,
864
- docImageFiles: base.files,
865
- inlineSvgs: base.inlineSvgs
866
- };
867
- }
868
- const localeRaw = await collectDocs(buildSpec.docsDir);
869
- const locale = await resolveDocImages(localeRaw, buildSpec.docsDir);
870
- const merged = overlayDocs(base, locale);
871
- return {
872
- sources: srcs,
873
- docs: merged.docs,
874
- docImageFiles: merged.files,
875
- inlineSvgs: merged.inlineSvgs
876
- };
1115
+ const tree = tutorialsDir && tutorialTree.length > 0 ? await resolveTutorialImages(tutorialTree, tutorialsDir, images) : tutorialTree;
1116
+ const md = readme ? await rewriteImageRefs(readme, process.cwd(), images) : readme;
1117
+ await resolveDocletImages(data, images);
1118
+ return { tutorialTree: tree, readme: md };
877
1119
  }
878
1120
  );
1121
+ const imageFiles = images.files;
1122
+ const allInlineSvgs = images.inlineSvgs;
879
1123
  const docGroups = normalizeDocGroups(opts.docGroups);
880
1124
  const defaultDocGroup = typeof opts.defaultDocGroup === "string" && opts.defaultDocGroup.trim().length > 0 ? opts.defaultDocGroup.trim() : void 0;
881
1125
  const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
@@ -884,8 +1128,8 @@ async function publish(data, opts, tutorials) {
884
1128
  const playground = normalizePlayground(opts.playground);
885
1129
  const siteOptions = {
886
1130
  ...pkg ? { pkg } : {},
887
- ...readme ? { readme } : {},
888
- ...tutorialTree.length > 0 ? { tutorials: tutorialTree } : {},
1131
+ ...resolvedReadme ? { readme: resolvedReadme } : {},
1132
+ ...resolvedTutorials.length > 0 ? { tutorials: resolvedTutorials } : {},
889
1133
  ...sources.length > 0 ? { sources } : {},
890
1134
  ...sources.length > 0 && sourceLinkToComment ? { sourceLinkToComment } : {},
891
1135
  ...docs.length > 0 ? { docs } : {},
@@ -947,7 +1191,11 @@ async function publish(data, opts, tutorials) {
947
1191
  },
948
1192
  destination: absoluteDestination,
949
1193
  islandCacheDir,
950
- inlineSvgs,
1194
+ inlineSvgs: allInlineSvgs,
1195
+ // Emit sitemap.xml when a public site URL is configured (the protocol needs
1196
+ // absolute URLs). In a localized build each locale's basePath yields that
1197
+ // locale's URLs, so each locale dir gets its own sitemap.
1198
+ ...nonEmptyString(opts.siteUrl) ? { siteUrl: opts.siteUrl.trim() } : {},
951
1199
  // Build mode: render chrome in the locale (SSR provider + island seeding)
952
1200
  // and, with >1 locale, mount the language switcher.
953
1201
  ...buildSpec ? {
@@ -961,13 +1209,44 @@ async function publish(data, opts, tutorials) {
961
1209
  } : {}
962
1210
  })
963
1211
  );
964
- const outputFiles = [
1212
+ const generatedFiles = [
965
1213
  ...result.files,
966
1214
  ...logoFiles,
967
1215
  ...customAssets.files,
968
- ...docImageFiles,
1216
+ ...imageFiles,
969
1217
  ...favicon?.files ?? []
970
1218
  ];
1219
+ const staticOutputFiles = [];
1220
+ if (staticFiles) {
1221
+ const generatedPaths = new Set(generatedFiles.map((f) => f.path));
1222
+ const RESERVED_PREFIXES = ["_assets/", "_islands/", "pagefind/"];
1223
+ let skippedConsumed = 0;
1224
+ for (const f of staticFiles.files) {
1225
+ if (images.consumed.has(f.absSource)) {
1226
+ skippedConsumed++;
1227
+ continue;
1228
+ }
1229
+ if (generatedPaths.has(f.outputPath) || RESERVED_PREFIXES.some((p) => f.outputPath.startsWith(p))) {
1230
+ console.warn(
1231
+ `clean-jsdoc-theme: static file '${f.outputPath}' would clobber generated output; skipping it.`
1232
+ );
1233
+ continue;
1234
+ }
1235
+ staticOutputFiles.push({ path: f.outputPath, contents: f.contents });
1236
+ }
1237
+ if (staticFiles.files.length > 0) {
1238
+ console.log(
1239
+ `clean-jsdoc-theme: staticFiles \u2014 copied ${staticOutputFiles.length} file(s) verbatim` + (skippedConsumed > 0 ? ` (${skippedConsumed} served hashed via _assets/)` : "") + "."
1240
+ );
1241
+ }
1242
+ }
1243
+ const outputFiles = [...generatedFiles, ...staticOutputFiles];
1244
+ if (!buildSpec && cleanOutputDirEnabled(opts)) {
1245
+ await progress.stage(
1246
+ "Cleaning output",
1247
+ () => rm(absoluteDestination, { recursive: true, force: true })
1248
+ );
1249
+ }
971
1250
  await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
972
1251
  const zlib = await import("zlib");
973
1252
  const gzipSizer = (b) => zlib.gzipSync(b).length;
@@ -1006,8 +1285,11 @@ async function publish(data, opts, tutorials) {
1006
1285
  }
1007
1286
  }
1008
1287
  export {
1288
+ cleanOutputDirEnabled,
1009
1289
  collectDocs,
1290
+ collectStaticFiles,
1010
1291
  computeRelPaths,
1292
+ createImageCollector,
1011
1293
  hasMarkdownPlugin,
1012
1294
  normalizeColors,
1013
1295
  normalizeCopyPage,
@@ -1017,12 +1299,18 @@ export {
1017
1299
  normalizePageNav,
1018
1300
  normalizePlayground,
1019
1301
  normalizeSectionOrder,
1302
+ normalizeStaticFilesConfig,
1020
1303
  outputSourceFilesEnabled,
1021
1304
  overlayDocs,
1022
1305
  publish,
1306
+ readStaticFilesConfig,
1023
1307
  resolveDocImages,
1308
+ resolveDocletImages,
1024
1309
  resolveFavicon,
1025
1310
  resolveFooter,
1026
- sourceLinkToCommentEnabled
1311
+ resolveTutorialImages,
1312
+ sourceLinkToCommentEnabled,
1313
+ staticFileIncluded,
1314
+ staticFileOutputName
1027
1315
  };
1028
1316
  //# sourceMappingURL=publish.mjs.map