clean-jsdoc-theme 5.0.4 → 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.d.mts +142 -14
- package/dist/publish.d.ts +142 -14
- package/dist/publish.js +351 -67
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +343 -67
- package/dist/publish.mjs.map +1 -1
- package/package.json +10 -6
package/dist/publish.js
CHANGED
|
@@ -32,7 +32,9 @@ var publish_exports = {};
|
|
|
32
32
|
__export(publish_exports, {
|
|
33
33
|
cleanOutputDirEnabled: () => cleanOutputDirEnabled,
|
|
34
34
|
collectDocs: () => collectDocs,
|
|
35
|
+
collectStaticFiles: () => collectStaticFiles,
|
|
35
36
|
computeRelPaths: () => computeRelPaths,
|
|
37
|
+
createImageCollector: () => createImageCollector,
|
|
36
38
|
hasMarkdownPlugin: () => hasMarkdownPlugin,
|
|
37
39
|
normalizeColors: () => normalizeColors,
|
|
38
40
|
normalizeCopyPage: () => normalizeCopyPage,
|
|
@@ -42,13 +44,19 @@ __export(publish_exports, {
|
|
|
42
44
|
normalizePageNav: () => normalizePageNav,
|
|
43
45
|
normalizePlayground: () => normalizePlayground,
|
|
44
46
|
normalizeSectionOrder: () => normalizeSectionOrder,
|
|
47
|
+
normalizeStaticFilesConfig: () => normalizeStaticFilesConfig,
|
|
45
48
|
outputSourceFilesEnabled: () => outputSourceFilesEnabled,
|
|
46
49
|
overlayDocs: () => overlayDocs,
|
|
47
50
|
publish: () => publish,
|
|
51
|
+
readStaticFilesConfig: () => readStaticFilesConfig,
|
|
48
52
|
resolveDocImages: () => resolveDocImages,
|
|
53
|
+
resolveDocletImages: () => resolveDocletImages,
|
|
49
54
|
resolveFavicon: () => resolveFavicon,
|
|
50
55
|
resolveFooter: () => resolveFooter,
|
|
51
|
-
|
|
56
|
+
resolveTutorialImages: () => resolveTutorialImages,
|
|
57
|
+
sourceLinkToCommentEnabled: () => sourceLinkToCommentEnabled,
|
|
58
|
+
staticFileIncluded: () => staticFileIncluded,
|
|
59
|
+
staticFileOutputName: () => staticFileOutputName
|
|
52
60
|
});
|
|
53
61
|
module.exports = __toCommonJS(publish_exports);
|
|
54
62
|
var import_promises2 = require("fs/promises");
|
|
@@ -696,62 +704,295 @@ async function collectDocs(dir) {
|
|
|
696
704
|
return docs;
|
|
697
705
|
}
|
|
698
706
|
var DOC_IMAGE_RE = /(!\[[^\]]*\]\()([^)\s]+)((?:\s+"[^"]*")?\))/g;
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
const root = (0, import_node_path2.resolve)(docsDir);
|
|
707
|
+
var HTML_IMAGE_RE = /(<img\b[^>]*?\bsrc\s*=\s*(["']))([^"']*)(\2)/gi;
|
|
708
|
+
function createImageCollector(staticDirs = []) {
|
|
702
709
|
const files = [];
|
|
703
|
-
const seenServed = /* @__PURE__ */ new Set();
|
|
704
710
|
const inlineSvgs = {};
|
|
711
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
712
|
+
const seenServed = /* @__PURE__ */ new Set();
|
|
705
713
|
const cache = /* @__PURE__ */ new Map();
|
|
706
|
-
const
|
|
714
|
+
const warnedMisses = /* @__PURE__ */ new Set();
|
|
715
|
+
const resolve = async (rawSrc, baseDir) => {
|
|
707
716
|
const src = rawSrc.trim();
|
|
708
717
|
if (!src || isServableUrl(src) || src.startsWith("#") || src.startsWith("data:")) return null;
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}
|
|
718
|
+
const primary = src.startsWith("/") ? (0, import_node_path2.resolve)(src.slice(1)) : (0, import_node_path2.resolve)(baseDir, src);
|
|
719
|
+
const candidates = [primary];
|
|
720
|
+
if (staticDirs.length > 0) {
|
|
721
|
+
const outName = src.replace(/^\/+/, "");
|
|
722
|
+
if (outName) for (const dir of staticDirs) candidates.push((0, import_node_path2.resolve)(dir, outName));
|
|
723
|
+
}
|
|
724
|
+
for (const abs of candidates) {
|
|
725
|
+
const cached = cache.get(abs);
|
|
726
|
+
if (cached !== void 0) {
|
|
727
|
+
if (cached) return cached;
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
let bytes;
|
|
731
|
+
try {
|
|
732
|
+
bytes = await (0, import_promises2.readFile)(abs);
|
|
733
|
+
} catch {
|
|
734
|
+
cache.set(abs, null);
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
const ext = (0, import_node_path2.extname)(abs);
|
|
738
|
+
const served = `_assets/${(0, import_node_path2.basename)(abs, ext) || "asset"}.${contentHash(bytes)}${ext}`;
|
|
739
|
+
if (!seenServed.has(served)) {
|
|
740
|
+
seenServed.add(served);
|
|
741
|
+
files.push({ path: served, contents: bytes });
|
|
742
|
+
}
|
|
743
|
+
const href = "/" + served;
|
|
744
|
+
if (ext.toLowerCase() === ".svg") {
|
|
745
|
+
inlineSvgs[href] = bytes.toString("utf8").replace(/<svg\b/, '<svg style="max-width:100%;height:auto;display:block"');
|
|
746
|
+
}
|
|
747
|
+
cache.set(abs, href);
|
|
748
|
+
consumed.add(abs);
|
|
749
|
+
return href;
|
|
750
|
+
}
|
|
751
|
+
if (!warnedMisses.has(src)) {
|
|
752
|
+
warnedMisses.add(src);
|
|
715
753
|
console.warn(
|
|
716
|
-
`clean-jsdoc-theme: could not read
|
|
754
|
+
`clean-jsdoc-theme: could not read image '${src}' (looked in: ${candidates.join(", ")}); leaving it as-is.`
|
|
717
755
|
);
|
|
718
|
-
cache.set(abs, null);
|
|
719
|
-
return null;
|
|
720
|
-
}
|
|
721
|
-
const ext = (0, import_node_path2.extname)(abs);
|
|
722
|
-
const served = `_assets/${(0, import_node_path2.basename)(abs, ext) || "asset"}.${contentHash(bytes)}${ext}`;
|
|
723
|
-
if (!seenServed.has(served)) {
|
|
724
|
-
seenServed.add(served);
|
|
725
|
-
files.push({ path: served, contents: bytes });
|
|
726
756
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
757
|
+
return null;
|
|
758
|
+
};
|
|
759
|
+
return { resolve, files, inlineSvgs, consumed };
|
|
760
|
+
}
|
|
761
|
+
var CODE_REGION_RE = /```[\s\S]*?```|~~~[\s\S]*?~~~|<pre[\s\S]*?<\/pre>|<code[^>]*>[\s\S]*?<\/code>|`[^`\n]+`/gi;
|
|
762
|
+
function codeRanges(content) {
|
|
763
|
+
const ranges = [];
|
|
764
|
+
for (const m of content.matchAll(CODE_REGION_RE)) {
|
|
765
|
+
if (m.index !== void 0) ranges.push([m.index, m.index + m[0].length]);
|
|
766
|
+
}
|
|
767
|
+
return ranges;
|
|
768
|
+
}
|
|
769
|
+
function indexInCode(idx, ranges) {
|
|
770
|
+
for (const [s, e] of ranges) if (idx >= s && idx < e) return true;
|
|
771
|
+
return false;
|
|
772
|
+
}
|
|
773
|
+
async function rewriteImageRefs(content, baseDir, collector) {
|
|
774
|
+
if (!content) return content;
|
|
775
|
+
const ranges = codeRanges(content);
|
|
776
|
+
const map = /* @__PURE__ */ new Map();
|
|
777
|
+
const collect = async (re, srcGroup) => {
|
|
778
|
+
for (const m of content.matchAll(re)) {
|
|
779
|
+
if (m.index !== void 0 && indexInCode(m.index, ranges)) continue;
|
|
780
|
+
const src = m[srcGroup];
|
|
781
|
+
if (map.has(src)) continue;
|
|
782
|
+
const href = await collector.resolve(src, baseDir);
|
|
783
|
+
if (href) map.set(src, href);
|
|
730
784
|
}
|
|
731
|
-
cache.set(abs, href);
|
|
732
|
-
return href;
|
|
733
785
|
};
|
|
786
|
+
await collect(DOC_IMAGE_RE, 2);
|
|
787
|
+
await collect(HTML_IMAGE_RE, 3);
|
|
788
|
+
if (map.size === 0) return content;
|
|
789
|
+
return content.replace(
|
|
790
|
+
DOC_IMAGE_RE,
|
|
791
|
+
(full, pre, src, post, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${post}` : full
|
|
792
|
+
).replace(
|
|
793
|
+
HTML_IMAGE_RE,
|
|
794
|
+
(full, pre, _quote, src, close, offset) => !indexInCode(offset, ranges) && map.has(src) ? `${pre}${map.get(src)}${close}` : full
|
|
795
|
+
);
|
|
796
|
+
}
|
|
797
|
+
async function resolveDocImages(docs, docsDir, collector = createImageCollector()) {
|
|
798
|
+
if (docs.length === 0) return { docs, files: collector.files, inlineSvgs: collector.inlineSvgs };
|
|
799
|
+
const root = (0, import_node_path2.resolve)(docsDir);
|
|
734
800
|
const out = [];
|
|
735
801
|
for (const doc of docs) {
|
|
736
802
|
const docDir = (0, import_node_path2.dirname)((0, import_node_path2.resolve)(root, doc.path));
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
803
|
+
const content = await rewriteImageRefs(doc.content, docDir, collector);
|
|
804
|
+
out.push(content === doc.content ? doc : { ...doc, content });
|
|
805
|
+
}
|
|
806
|
+
return { docs: out, files: collector.files, inlineSvgs: collector.inlineSvgs };
|
|
807
|
+
}
|
|
808
|
+
async function resolveTutorialImages(tree, tutorialsDir, collector) {
|
|
809
|
+
const base = (0, import_node_path2.resolve)(tutorialsDir);
|
|
810
|
+
const walk = async (node) => {
|
|
811
|
+
const content = await rewriteImageRefs(node.content, base, collector);
|
|
812
|
+
const children = [];
|
|
813
|
+
for (const child of node.children ?? []) children.push(await walk(child));
|
|
814
|
+
return { ...node, content, children };
|
|
815
|
+
};
|
|
816
|
+
const out = [];
|
|
817
|
+
for (const node of tree) out.push(await walk(node));
|
|
818
|
+
return out;
|
|
819
|
+
}
|
|
820
|
+
var DOCLET_IMAGE_SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
821
|
+
"meta",
|
|
822
|
+
"comment",
|
|
823
|
+
"examples",
|
|
824
|
+
"tags",
|
|
825
|
+
"___id",
|
|
826
|
+
"___s"
|
|
827
|
+
]);
|
|
828
|
+
async function rewriteDocletStrings(node, baseDir, collector) {
|
|
829
|
+
for (const [key, value] of Object.entries(node)) {
|
|
830
|
+
if (DOCLET_IMAGE_SKIP_KEYS.has(key)) continue;
|
|
831
|
+
if (typeof value === "string") {
|
|
832
|
+
if (value.includes("<img") || value.includes("![")) {
|
|
833
|
+
const rewritten = await rewriteImageRefs(value, baseDir, collector);
|
|
834
|
+
if (rewritten !== value) node[key] = rewritten;
|
|
835
|
+
}
|
|
836
|
+
} else if (Array.isArray(value)) {
|
|
837
|
+
for (let i = 0; i < value.length; i++) {
|
|
838
|
+
const item = value[i];
|
|
839
|
+
if (typeof item === "string") {
|
|
840
|
+
if (item.includes("<img") || item.includes("![")) {
|
|
841
|
+
const rewritten = await rewriteImageRefs(item, baseDir, collector);
|
|
842
|
+
if (rewritten !== item) value[i] = rewritten;
|
|
843
|
+
}
|
|
844
|
+
} else if (item && typeof item === "object") {
|
|
845
|
+
await rewriteDocletStrings(item, baseDir, collector);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
} else if (value && typeof value === "object") {
|
|
849
|
+
await rewriteDocletStrings(value, baseDir, collector);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
async function resolveDocletImages(data, collector) {
|
|
854
|
+
if (typeof data !== "function") return;
|
|
855
|
+
let doclets = [];
|
|
856
|
+
try {
|
|
857
|
+
doclets = data({}).get();
|
|
858
|
+
} catch {
|
|
859
|
+
try {
|
|
860
|
+
doclets = data().get();
|
|
861
|
+
} catch {
|
|
862
|
+
return;
|
|
743
863
|
}
|
|
744
|
-
|
|
745
|
-
|
|
864
|
+
}
|
|
865
|
+
if (!Array.isArray(doclets)) return;
|
|
866
|
+
for (const d of doclets) {
|
|
867
|
+
if (!d || typeof d !== "object") continue;
|
|
868
|
+
const meta = d.meta;
|
|
869
|
+
if (!meta || typeof meta.path !== "string" || meta.path.length === 0) continue;
|
|
870
|
+
await rewriteDocletStrings(d, meta.path, collector);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
function normalizeStaticFilesConfig(raw) {
|
|
874
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
875
|
+
const o = raw;
|
|
876
|
+
const toStrArr = (v) => (Array.isArray(v) ? v : typeof v === "string" ? [v] : []).filter((s) => typeof s === "string" && s.trim().length > 0).map((s) => s.trim());
|
|
877
|
+
const include = toStrArr(o.include);
|
|
878
|
+
if (include.length === 0) return void 0;
|
|
879
|
+
const includePattern = typeof o.includePattern === "string" && o.includePattern.trim().length > 0 ? o.includePattern : void 0;
|
|
880
|
+
const excludePattern = typeof o.excludePattern === "string" && o.excludePattern.trim().length > 0 ? o.excludePattern : void 0;
|
|
881
|
+
return {
|
|
882
|
+
include,
|
|
883
|
+
exclude: toStrArr(o.exclude),
|
|
884
|
+
...includePattern ? { includePattern } : {},
|
|
885
|
+
...excludePattern ? { excludePattern } : {}
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
function readStaticFilesConfig(opts) {
|
|
889
|
+
try {
|
|
890
|
+
const env = require("jsdoc/env");
|
|
891
|
+
const fromEnv = normalizeStaticFilesConfig(env?.conf?.templates?.default?.staticFiles);
|
|
892
|
+
if (fromEnv) return fromEnv;
|
|
893
|
+
} catch {
|
|
894
|
+
}
|
|
895
|
+
return normalizeStaticFilesConfig(opts?.templates?.default?.staticFiles);
|
|
896
|
+
}
|
|
897
|
+
function staticFileOutputName(absFile, includeRootAbs) {
|
|
898
|
+
const norm = (p) => p.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
899
|
+
const f = norm(absFile);
|
|
900
|
+
const root = norm(includeRootAbs);
|
|
901
|
+
const baseOf = (p) => p.slice(p.lastIndexOf("/") + 1);
|
|
902
|
+
if (f === root) return baseOf(f);
|
|
903
|
+
const prefix = root + "/";
|
|
904
|
+
return f.toLowerCase().startsWith(prefix.toLowerCase()) ? f.slice(prefix.length) : baseOf(f);
|
|
905
|
+
}
|
|
906
|
+
function staticFileIncluded(absFile, config) {
|
|
907
|
+
const norm = (p) => (0, import_node_path2.resolve)(p).replace(/\\/g, "/");
|
|
908
|
+
const fn = norm(absFile);
|
|
909
|
+
if (config.includePattern) {
|
|
910
|
+
try {
|
|
911
|
+
if (!new RegExp(config.includePattern).test(fn)) return false;
|
|
912
|
+
} catch {
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
if (config.excludePattern) {
|
|
916
|
+
try {
|
|
917
|
+
if (new RegExp(config.excludePattern).test(fn)) return false;
|
|
918
|
+
} catch {
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
for (const ex of config.exclude) {
|
|
922
|
+
const exAbs = norm(ex);
|
|
923
|
+
if (fn === exAbs || fn.toLowerCase().startsWith(exAbs.toLowerCase() + "/")) return false;
|
|
924
|
+
}
|
|
925
|
+
return true;
|
|
926
|
+
}
|
|
927
|
+
var STATIC_DIR_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".svn", ".hg"]);
|
|
928
|
+
async function collectStaticFiles(config, warn = (m) => console.warn(m)) {
|
|
929
|
+
const files = [];
|
|
930
|
+
const searchDirs = /* @__PURE__ */ new Set();
|
|
931
|
+
const seenOutput = /* @__PURE__ */ new Set();
|
|
932
|
+
for (const inc of config.include) {
|
|
933
|
+
const root = (0, import_node_path2.resolve)(inc);
|
|
934
|
+
let st;
|
|
935
|
+
try {
|
|
936
|
+
st = await (0, import_promises2.stat)(root);
|
|
937
|
+
} catch {
|
|
938
|
+
warn(
|
|
939
|
+
`clean-jsdoc-theme: staticFiles include '${inc}' (resolved '${root}') was not found; skipping it.`
|
|
940
|
+
);
|
|
746
941
|
continue;
|
|
747
942
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
943
|
+
if (st.isDirectory()) {
|
|
944
|
+
searchDirs.add(root);
|
|
945
|
+
const walk = async (absDir) => {
|
|
946
|
+
let entries;
|
|
947
|
+
try {
|
|
948
|
+
entries = await (0, import_promises2.readdir)(absDir, { withFileTypes: true });
|
|
949
|
+
} catch {
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
for (const entry of entries) {
|
|
953
|
+
if (entry.name.startsWith(".")) continue;
|
|
954
|
+
const abs = (0, import_node_path2.join)(absDir, entry.name);
|
|
955
|
+
if (entry.isDirectory()) {
|
|
956
|
+
if (!STATIC_DIR_SKIP.has(entry.name)) await walk(abs);
|
|
957
|
+
continue;
|
|
958
|
+
}
|
|
959
|
+
if (!entry.isFile()) continue;
|
|
960
|
+
if (!staticFileIncluded(abs, config)) continue;
|
|
961
|
+
const outputPath = staticFileOutputName(abs, root);
|
|
962
|
+
if (seenOutput.has(outputPath)) continue;
|
|
963
|
+
let contents;
|
|
964
|
+
try {
|
|
965
|
+
contents = await (0, import_promises2.readFile)(abs);
|
|
966
|
+
} catch (err) {
|
|
967
|
+
warn(
|
|
968
|
+
`clean-jsdoc-theme: could not read static file '${abs}' \u2014 ${err.message}; skipping.`
|
|
969
|
+
);
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
seenOutput.add(outputPath);
|
|
973
|
+
files.push({ outputPath, absSource: (0, import_node_path2.resolve)(abs), contents });
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
await walk(root);
|
|
977
|
+
} else if (st.isFile()) {
|
|
978
|
+
searchDirs.add((0, import_node_path2.dirname)(root));
|
|
979
|
+
if (!staticFileIncluded(root, config)) continue;
|
|
980
|
+
const outputPath = staticFileOutputName(root, root);
|
|
981
|
+
if (!seenOutput.has(outputPath)) {
|
|
982
|
+
try {
|
|
983
|
+
const contents = await (0, import_promises2.readFile)(root);
|
|
984
|
+
seenOutput.add(outputPath);
|
|
985
|
+
files.push({ outputPath, absSource: (0, import_node_path2.resolve)(root), contents });
|
|
986
|
+
} catch (err) {
|
|
987
|
+
warn(
|
|
988
|
+
`clean-jsdoc-theme: could not read static file '${root}' \u2014 ${err.message}; skipping.`
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
753
993
|
}
|
|
754
|
-
|
|
994
|
+
files.sort((a, b) => a.outputPath.localeCompare(b.outputPath));
|
|
995
|
+
return { files, searchDirs: [...searchDirs] };
|
|
755
996
|
}
|
|
756
997
|
function overlayDocs(base, locale) {
|
|
757
998
|
const byPath = new Map(base.docs.map((d) => [d.path, d]));
|
|
@@ -838,6 +1079,8 @@ async function publish(data, opts, tutorials) {
|
|
|
838
1079
|
assertMarkdownPlugin();
|
|
839
1080
|
const color = Boolean(process.stdout.isTTY) && opts.nocolor !== true;
|
|
840
1081
|
const docsDir = typeof opts.docs === "string" && opts.docs.trim().length > 0 ? opts.docs.trim() : void 0;
|
|
1082
|
+
const tutorialsDir = typeof opts.tutorials === "string" && opts.tutorials.trim().length > 0 ? opts.tutorials.trim() : void 0;
|
|
1083
|
+
const staticCfg = readStaticFilesConfig(opts);
|
|
841
1084
|
const pkgPromise = resolvePkg(data, opts);
|
|
842
1085
|
const sourcesPromise = outputSourceFilesEnabled(opts) ? collectSourceFiles(data) : Promise.resolve([]);
|
|
843
1086
|
const docsPromise = docsDir ? collectDocs(docsDir) : Promise.resolve([]);
|
|
@@ -896,30 +1139,34 @@ async function publish(data, opts, tutorials) {
|
|
|
896
1139
|
const readme = typeof opts.readme === "string" && opts.readme.length > 0 ? opts.readme : void 0;
|
|
897
1140
|
const tutorialTree = normalizeTutorials(tutorials);
|
|
898
1141
|
const sourceLinkToComment = sourceLinkToCommentEnabled(opts);
|
|
899
|
-
const
|
|
900
|
-
"Reading
|
|
1142
|
+
const staticFiles = staticCfg ? await progress.stage(
|
|
1143
|
+
"Reading static files",
|
|
1144
|
+
() => collectStaticFiles(staticCfg, (m) => console.warn(m))
|
|
1145
|
+
) : void 0;
|
|
1146
|
+
const images = createImageCollector(staticFiles?.searchDirs ?? []);
|
|
1147
|
+
const { sources, docs } = await progress.stage("Reading sources & docs", async () => {
|
|
1148
|
+
const [srcs, rawDocs] = await Promise.all([sourcesPromise, docsPromise]);
|
|
1149
|
+
const base = docsDir ? await resolveDocImages(rawDocs, docsDir, images) : { docs: rawDocs };
|
|
1150
|
+
if (!buildSpec?.docsDir) return { sources: srcs, docs: base.docs };
|
|
1151
|
+
const localeRaw = await collectDocs(buildSpec.docsDir);
|
|
1152
|
+
const locale = await resolveDocImages(localeRaw, buildSpec.docsDir, images);
|
|
1153
|
+
const merged = overlayDocs(
|
|
1154
|
+
{ docs: base.docs, files: [], inlineSvgs: {} },
|
|
1155
|
+
{ docs: locale.docs, files: [], inlineSvgs: {} }
|
|
1156
|
+
);
|
|
1157
|
+
return { sources: srcs, docs: merged.docs };
|
|
1158
|
+
});
|
|
1159
|
+
const { tutorialTree: resolvedTutorials, readme: resolvedReadme } = await progress.stage(
|
|
1160
|
+
"Resolving prose images",
|
|
901
1161
|
async () => {
|
|
902
|
-
const
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
sources: srcs,
|
|
907
|
-
docs: base.docs,
|
|
908
|
-
docImageFiles: base.files,
|
|
909
|
-
inlineSvgs: base.inlineSvgs
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
const localeRaw = await collectDocs(buildSpec.docsDir);
|
|
913
|
-
const locale = await resolveDocImages(localeRaw, buildSpec.docsDir);
|
|
914
|
-
const merged = overlayDocs(base, locale);
|
|
915
|
-
return {
|
|
916
|
-
sources: srcs,
|
|
917
|
-
docs: merged.docs,
|
|
918
|
-
docImageFiles: merged.files,
|
|
919
|
-
inlineSvgs: merged.inlineSvgs
|
|
920
|
-
};
|
|
1162
|
+
const tree = tutorialsDir && tutorialTree.length > 0 ? await resolveTutorialImages(tutorialTree, tutorialsDir, images) : tutorialTree;
|
|
1163
|
+
const md = readme ? await rewriteImageRefs(readme, process.cwd(), images) : readme;
|
|
1164
|
+
await resolveDocletImages(data, images);
|
|
1165
|
+
return { tutorialTree: tree, readme: md };
|
|
921
1166
|
}
|
|
922
1167
|
);
|
|
1168
|
+
const imageFiles = images.files;
|
|
1169
|
+
const allInlineSvgs = images.inlineSvgs;
|
|
923
1170
|
const docGroups = normalizeDocGroups(opts.docGroups);
|
|
924
1171
|
const defaultDocGroup = typeof opts.defaultDocGroup === "string" && opts.defaultDocGroup.trim().length > 0 ? opts.defaultDocGroup.trim() : void 0;
|
|
925
1172
|
const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
|
|
@@ -928,8 +1175,8 @@ async function publish(data, opts, tutorials) {
|
|
|
928
1175
|
const playground = normalizePlayground(opts.playground);
|
|
929
1176
|
const siteOptions = {
|
|
930
1177
|
...pkg ? { pkg } : {},
|
|
931
|
-
...
|
|
932
|
-
...
|
|
1178
|
+
...resolvedReadme ? { readme: resolvedReadme } : {},
|
|
1179
|
+
...resolvedTutorials.length > 0 ? { tutorials: resolvedTutorials } : {},
|
|
933
1180
|
...sources.length > 0 ? { sources } : {},
|
|
934
1181
|
...sources.length > 0 && sourceLinkToComment ? { sourceLinkToComment } : {},
|
|
935
1182
|
...docs.length > 0 ? { docs } : {},
|
|
@@ -991,7 +1238,11 @@ async function publish(data, opts, tutorials) {
|
|
|
991
1238
|
},
|
|
992
1239
|
destination: absoluteDestination,
|
|
993
1240
|
islandCacheDir,
|
|
994
|
-
inlineSvgs,
|
|
1241
|
+
inlineSvgs: allInlineSvgs,
|
|
1242
|
+
// Emit sitemap.xml when a public site URL is configured (the protocol needs
|
|
1243
|
+
// absolute URLs). In a localized build each locale's basePath yields that
|
|
1244
|
+
// locale's URLs, so each locale dir gets its own sitemap.
|
|
1245
|
+
...nonEmptyString(opts.siteUrl) ? { siteUrl: opts.siteUrl.trim() } : {},
|
|
995
1246
|
// Build mode: render chrome in the locale (SSR provider + island seeding)
|
|
996
1247
|
// and, with >1 locale, mount the language switcher.
|
|
997
1248
|
...buildSpec ? {
|
|
@@ -1005,13 +1256,38 @@ async function publish(data, opts, tutorials) {
|
|
|
1005
1256
|
} : {}
|
|
1006
1257
|
})
|
|
1007
1258
|
);
|
|
1008
|
-
const
|
|
1259
|
+
const generatedFiles = [
|
|
1009
1260
|
...result.files,
|
|
1010
1261
|
...logoFiles,
|
|
1011
1262
|
...customAssets.files,
|
|
1012
|
-
...
|
|
1263
|
+
...imageFiles,
|
|
1013
1264
|
...favicon?.files ?? []
|
|
1014
1265
|
];
|
|
1266
|
+
const staticOutputFiles = [];
|
|
1267
|
+
if (staticFiles) {
|
|
1268
|
+
const generatedPaths = new Set(generatedFiles.map((f) => f.path));
|
|
1269
|
+
const RESERVED_PREFIXES = ["_assets/", "_islands/", "pagefind/"];
|
|
1270
|
+
let skippedConsumed = 0;
|
|
1271
|
+
for (const f of staticFiles.files) {
|
|
1272
|
+
if (images.consumed.has(f.absSource)) {
|
|
1273
|
+
skippedConsumed++;
|
|
1274
|
+
continue;
|
|
1275
|
+
}
|
|
1276
|
+
if (generatedPaths.has(f.outputPath) || RESERVED_PREFIXES.some((p) => f.outputPath.startsWith(p))) {
|
|
1277
|
+
console.warn(
|
|
1278
|
+
`clean-jsdoc-theme: static file '${f.outputPath}' would clobber generated output; skipping it.`
|
|
1279
|
+
);
|
|
1280
|
+
continue;
|
|
1281
|
+
}
|
|
1282
|
+
staticOutputFiles.push({ path: f.outputPath, contents: f.contents });
|
|
1283
|
+
}
|
|
1284
|
+
if (staticFiles.files.length > 0) {
|
|
1285
|
+
console.log(
|
|
1286
|
+
`clean-jsdoc-theme: staticFiles \u2014 copied ${staticOutputFiles.length} file(s) verbatim` + (skippedConsumed > 0 ? ` (${skippedConsumed} served hashed via _assets/)` : "") + "."
|
|
1287
|
+
);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
const outputFiles = [...generatedFiles, ...staticOutputFiles];
|
|
1015
1291
|
if (!buildSpec && cleanOutputDirEnabled(opts)) {
|
|
1016
1292
|
await progress.stage(
|
|
1017
1293
|
"Cleaning output",
|
|
@@ -1059,7 +1335,9 @@ async function publish(data, opts, tutorials) {
|
|
|
1059
1335
|
0 && (module.exports = {
|
|
1060
1336
|
cleanOutputDirEnabled,
|
|
1061
1337
|
collectDocs,
|
|
1338
|
+
collectStaticFiles,
|
|
1062
1339
|
computeRelPaths,
|
|
1340
|
+
createImageCollector,
|
|
1063
1341
|
hasMarkdownPlugin,
|
|
1064
1342
|
normalizeColors,
|
|
1065
1343
|
normalizeCopyPage,
|
|
@@ -1069,12 +1347,18 @@ async function publish(data, opts, tutorials) {
|
|
|
1069
1347
|
normalizePageNav,
|
|
1070
1348
|
normalizePlayground,
|
|
1071
1349
|
normalizeSectionOrder,
|
|
1350
|
+
normalizeStaticFilesConfig,
|
|
1072
1351
|
outputSourceFilesEnabled,
|
|
1073
1352
|
overlayDocs,
|
|
1074
1353
|
publish,
|
|
1354
|
+
readStaticFilesConfig,
|
|
1075
1355
|
resolveDocImages,
|
|
1356
|
+
resolveDocletImages,
|
|
1076
1357
|
resolveFavicon,
|
|
1077
1358
|
resolveFooter,
|
|
1078
|
-
|
|
1359
|
+
resolveTutorialImages,
|
|
1360
|
+
sourceLinkToCommentEnabled,
|
|
1361
|
+
staticFileIncluded,
|
|
1362
|
+
staticFileOutputName
|
|
1079
1363
|
});
|
|
1080
1364
|
//# sourceMappingURL=publish.js.map
|