clean-jsdoc-theme 5.0.0 → 5.0.2
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 +48 -3
- package/dist/publish.d.ts +48 -3
- package/dist/publish.js +77 -3
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +75 -3
- package/dist/publish.mjs.map +1 -1
- package/package.json +6 -6
package/dist/publish.mjs
CHANGED
|
@@ -182,6 +182,7 @@ function resolveTheme(opts, siteName, fonts, basePath, locale) {
|
|
|
182
182
|
const aiPrompt = typeof opts.aiPrompt === "string" && opts.aiPrompt.trim() ? opts.aiPrompt.trim() : void 0;
|
|
183
183
|
const copyPage = normalizeCopyPage(opts.copyPage);
|
|
184
184
|
const pageNav = normalizePageNav(opts.pageNav);
|
|
185
|
+
const playground = normalizePlayground(opts.playground);
|
|
185
186
|
const colors = normalizeColors(opts.colors);
|
|
186
187
|
const darkColors = normalizeColors(opts.darkColors);
|
|
187
188
|
return {
|
|
@@ -190,6 +191,7 @@ function resolveTheme(opts, siteName, fonts, basePath, locale) {
|
|
|
190
191
|
...aiPrompt ? { aiPrompt } : {},
|
|
191
192
|
...copyPage ? { copyPage } : {},
|
|
192
193
|
...pageNav ? { pageNav } : {},
|
|
194
|
+
...playground ? { playground: playground.theme } : {},
|
|
193
195
|
tokens: {
|
|
194
196
|
...defaultTheme.tokens,
|
|
195
197
|
colors: { ...defaultTheme.tokens.colors, ...colors ?? {} },
|
|
@@ -269,6 +271,22 @@ async function resolveFooter(raw) {
|
|
|
269
271
|
}
|
|
270
272
|
return void 0;
|
|
271
273
|
}
|
|
274
|
+
async function resolveFavicon(raw, hash, hrefForServed) {
|
|
275
|
+
if (typeof raw !== "string" || raw.trim().length === 0) return void 0;
|
|
276
|
+
const trimmed = raw.trim();
|
|
277
|
+
let bytes;
|
|
278
|
+
try {
|
|
279
|
+
bytes = await readFile(resolvePath(trimmed));
|
|
280
|
+
} catch {
|
|
281
|
+
console.warn(`clean-jsdoc-theme: could not read favicon ('${trimmed}'); omitting it.`);
|
|
282
|
+
return void 0;
|
|
283
|
+
}
|
|
284
|
+
const ext = extname(trimmed) || ".ico";
|
|
285
|
+
const base = basename(trimmed, extname(trimmed)) || "favicon";
|
|
286
|
+
const name = hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`;
|
|
287
|
+
const servedPath = `_assets/${name}`;
|
|
288
|
+
return { href: hrefForServed(servedPath), files: [{ path: servedPath, contents: bytes }] };
|
|
289
|
+
}
|
|
272
290
|
var META_IDENTITY_ATTRS = ["name", "property", "http-equiv", "charset", "itemprop"];
|
|
273
291
|
function normalizeMeta(raw) {
|
|
274
292
|
if (!Array.isArray(raw)) return void 0;
|
|
@@ -435,6 +453,8 @@ function normalizeMenu(raw) {
|
|
|
435
453
|
const link = typeof o.link === "string" && o.link.trim() ? o.link.trim() : typeof o.href === "string" && o.href.trim() ? o.href.trim() : void 0;
|
|
436
454
|
if (link) item.link = link;
|
|
437
455
|
if (typeof o.icon === "string" && o.icon.trim()) item.icon = o.icon.trim();
|
|
456
|
+
if (typeof o.target === "string" && o.target.trim()) item.target = o.target.trim();
|
|
457
|
+
if (typeof o.class === "string" && o.class.trim()) item.class = o.class.trim();
|
|
438
458
|
if (item.id || item.link) out.push(item);
|
|
439
459
|
}
|
|
440
460
|
return out.length > 0 ? out : void 0;
|
|
@@ -471,7 +491,47 @@ function normalizePageNav(raw) {
|
|
|
471
491
|
const enabled = raw.enabled;
|
|
472
492
|
return typeof enabled === "boolean" ? { enabled } : void 0;
|
|
473
493
|
}
|
|
474
|
-
var
|
|
494
|
+
var PLAYGROUND_PROVIDERS = ["codepen", "jsfiddle", "codesandbox"];
|
|
495
|
+
function playgroundOptionRecord(raw) {
|
|
496
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
|
|
497
|
+
}
|
|
498
|
+
function normalizePlayground(raw) {
|
|
499
|
+
if (raw == null || raw === false) return void 0;
|
|
500
|
+
const o = raw === true ? {} : raw;
|
|
501
|
+
if (typeof o !== "object" || Array.isArray(o)) return void 0;
|
|
502
|
+
const obj = o;
|
|
503
|
+
const site = {};
|
|
504
|
+
if (obj.enableForAllExamples === true) site.enableForAllExamples = true;
|
|
505
|
+
if (Array.isArray(obj.providers)) {
|
|
506
|
+
const providers = [];
|
|
507
|
+
for (const p of obj.providers) {
|
|
508
|
+
if (typeof p === "string" && PLAYGROUND_PROVIDERS.includes(p) && !providers.includes(p)) {
|
|
509
|
+
providers.push(p);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (providers.length > 0) site.providers = providers;
|
|
513
|
+
}
|
|
514
|
+
const theme = { enabled: true };
|
|
515
|
+
const codepen = playgroundOptionRecord(obj.codepen);
|
|
516
|
+
const jsfiddle = playgroundOptionRecord(obj.jsfiddle);
|
|
517
|
+
const codesandbox = playgroundOptionRecord(obj.codesandbox);
|
|
518
|
+
if (codepen) theme.codepen = codepen;
|
|
519
|
+
if (jsfiddle) theme.jsfiddle = jsfiddle;
|
|
520
|
+
if (codesandbox) theme.codesandbox = codesandbox;
|
|
521
|
+
return { site, theme };
|
|
522
|
+
}
|
|
523
|
+
var COLOR_KEYS = [
|
|
524
|
+
"bg",
|
|
525
|
+
"bgMuted",
|
|
526
|
+
"fg",
|
|
527
|
+
"fgMuted",
|
|
528
|
+
"accent",
|
|
529
|
+
"accentFg",
|
|
530
|
+
"border",
|
|
531
|
+
"codeHeaderBg",
|
|
532
|
+
"codeHeaderFg",
|
|
533
|
+
"codeHighlightBg"
|
|
534
|
+
];
|
|
475
535
|
function normalizeColors(raw) {
|
|
476
536
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
477
537
|
const src = raw;
|
|
@@ -819,6 +879,7 @@ async function publish(data, opts, tutorials) {
|
|
|
819
879
|
const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
|
|
820
880
|
const menu = normalizeMenu(opts.menu);
|
|
821
881
|
const clubSidebarItems = opts.clubSidebarItems === true;
|
|
882
|
+
const playground = normalizePlayground(opts.playground);
|
|
822
883
|
const siteOptions = {
|
|
823
884
|
...pkg ? { pkg } : {},
|
|
824
885
|
...readme ? { readme } : {},
|
|
@@ -830,7 +891,8 @@ async function publish(data, opts, tutorials) {
|
|
|
830
891
|
...defaultDocGroup ? { defaultDocGroup } : {},
|
|
831
892
|
...sectionOrder ? { sectionOrder } : {},
|
|
832
893
|
...menu ? { menu } : {},
|
|
833
|
-
...clubSidebarItems ? { clubSidebarItems } : {}
|
|
894
|
+
...clubSidebarItems ? { clubSidebarItems } : {},
|
|
895
|
+
...playground ? { playground: playground.site } : {}
|
|
834
896
|
};
|
|
835
897
|
const manifest = await progress.stage(
|
|
836
898
|
"Generating pages",
|
|
@@ -867,6 +929,7 @@ async function publish(data, opts, tutorials) {
|
|
|
867
929
|
}
|
|
868
930
|
const customAssets = await resolveCustomAssets(opts, hrefForServed);
|
|
869
931
|
const footer = await resolveFooter(opts.footer);
|
|
932
|
+
const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed);
|
|
870
933
|
const meta = normalizeMeta(opts.meta);
|
|
871
934
|
const absoluteDestination = resolvePath(destination);
|
|
872
935
|
const islandCacheDir = resolvePath(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
|
|
@@ -877,6 +940,7 @@ async function publish(data, opts, tutorials) {
|
|
|
877
940
|
...resolveTheme(opts, siteName, fonts, basePath, buildSpec?.locale),
|
|
878
941
|
...customAssets.theme,
|
|
879
942
|
...footer ? { footer } : {},
|
|
943
|
+
...favicon ? { favicon: favicon.href } : {},
|
|
880
944
|
...meta ? { meta } : {}
|
|
881
945
|
},
|
|
882
946
|
destination: absoluteDestination,
|
|
@@ -895,7 +959,13 @@ async function publish(data, opts, tutorials) {
|
|
|
895
959
|
} : {}
|
|
896
960
|
})
|
|
897
961
|
);
|
|
898
|
-
const outputFiles = [
|
|
962
|
+
const outputFiles = [
|
|
963
|
+
...result.files,
|
|
964
|
+
...logoFiles,
|
|
965
|
+
...customAssets.files,
|
|
966
|
+
...docImageFiles,
|
|
967
|
+
...favicon?.files ?? []
|
|
968
|
+
];
|
|
899
969
|
await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
|
|
900
970
|
const zlib = await import("zlib");
|
|
901
971
|
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
@@ -935,11 +1005,13 @@ export {
|
|
|
935
1005
|
normalizeMenu,
|
|
936
1006
|
normalizeMeta,
|
|
937
1007
|
normalizePageNav,
|
|
1008
|
+
normalizePlayground,
|
|
938
1009
|
normalizeSectionOrder,
|
|
939
1010
|
outputSourceFilesEnabled,
|
|
940
1011
|
overlayDocs,
|
|
941
1012
|
publish,
|
|
942
1013
|
resolveDocImages,
|
|
1014
|
+
resolveFavicon,
|
|
943
1015
|
resolveFooter,
|
|
944
1016
|
sourceLinkToCommentEnabled
|
|
945
1017
|
};
|