clean-jsdoc-theme 5.0.0 → 5.0.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.d.mts +48 -3
- package/dist/publish.d.ts +48 -3
- package/dist/publish.js +75 -3
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +73 -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;
|
|
@@ -471,7 +489,47 @@ function normalizePageNav(raw) {
|
|
|
471
489
|
const enabled = raw.enabled;
|
|
472
490
|
return typeof enabled === "boolean" ? { enabled } : void 0;
|
|
473
491
|
}
|
|
474
|
-
var
|
|
492
|
+
var PLAYGROUND_PROVIDERS = ["codepen", "jsfiddle", "codesandbox"];
|
|
493
|
+
function playgroundOptionRecord(raw) {
|
|
494
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
|
|
495
|
+
}
|
|
496
|
+
function normalizePlayground(raw) {
|
|
497
|
+
if (raw == null || raw === false) return void 0;
|
|
498
|
+
const o = raw === true ? {} : raw;
|
|
499
|
+
if (typeof o !== "object" || Array.isArray(o)) return void 0;
|
|
500
|
+
const obj = o;
|
|
501
|
+
const site = {};
|
|
502
|
+
if (obj.enableForAllExamples === true) site.enableForAllExamples = true;
|
|
503
|
+
if (Array.isArray(obj.providers)) {
|
|
504
|
+
const providers = [];
|
|
505
|
+
for (const p of obj.providers) {
|
|
506
|
+
if (typeof p === "string" && PLAYGROUND_PROVIDERS.includes(p) && !providers.includes(p)) {
|
|
507
|
+
providers.push(p);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (providers.length > 0) site.providers = providers;
|
|
511
|
+
}
|
|
512
|
+
const theme = { enabled: true };
|
|
513
|
+
const codepen = playgroundOptionRecord(obj.codepen);
|
|
514
|
+
const jsfiddle = playgroundOptionRecord(obj.jsfiddle);
|
|
515
|
+
const codesandbox = playgroundOptionRecord(obj.codesandbox);
|
|
516
|
+
if (codepen) theme.codepen = codepen;
|
|
517
|
+
if (jsfiddle) theme.jsfiddle = jsfiddle;
|
|
518
|
+
if (codesandbox) theme.codesandbox = codesandbox;
|
|
519
|
+
return { site, theme };
|
|
520
|
+
}
|
|
521
|
+
var COLOR_KEYS = [
|
|
522
|
+
"bg",
|
|
523
|
+
"bgMuted",
|
|
524
|
+
"fg",
|
|
525
|
+
"fgMuted",
|
|
526
|
+
"accent",
|
|
527
|
+
"accentFg",
|
|
528
|
+
"border",
|
|
529
|
+
"codeHeaderBg",
|
|
530
|
+
"codeHeaderFg",
|
|
531
|
+
"codeHighlightBg"
|
|
532
|
+
];
|
|
475
533
|
function normalizeColors(raw) {
|
|
476
534
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
477
535
|
const src = raw;
|
|
@@ -819,6 +877,7 @@ async function publish(data, opts, tutorials) {
|
|
|
819
877
|
const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
|
|
820
878
|
const menu = normalizeMenu(opts.menu);
|
|
821
879
|
const clubSidebarItems = opts.clubSidebarItems === true;
|
|
880
|
+
const playground = normalizePlayground(opts.playground);
|
|
822
881
|
const siteOptions = {
|
|
823
882
|
...pkg ? { pkg } : {},
|
|
824
883
|
...readme ? { readme } : {},
|
|
@@ -830,7 +889,8 @@ async function publish(data, opts, tutorials) {
|
|
|
830
889
|
...defaultDocGroup ? { defaultDocGroup } : {},
|
|
831
890
|
...sectionOrder ? { sectionOrder } : {},
|
|
832
891
|
...menu ? { menu } : {},
|
|
833
|
-
...clubSidebarItems ? { clubSidebarItems } : {}
|
|
892
|
+
...clubSidebarItems ? { clubSidebarItems } : {},
|
|
893
|
+
...playground ? { playground: playground.site } : {}
|
|
834
894
|
};
|
|
835
895
|
const manifest = await progress.stage(
|
|
836
896
|
"Generating pages",
|
|
@@ -867,6 +927,7 @@ async function publish(data, opts, tutorials) {
|
|
|
867
927
|
}
|
|
868
928
|
const customAssets = await resolveCustomAssets(opts, hrefForServed);
|
|
869
929
|
const footer = await resolveFooter(opts.footer);
|
|
930
|
+
const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed);
|
|
870
931
|
const meta = normalizeMeta(opts.meta);
|
|
871
932
|
const absoluteDestination = resolvePath(destination);
|
|
872
933
|
const islandCacheDir = resolvePath(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
|
|
@@ -877,6 +938,7 @@ async function publish(data, opts, tutorials) {
|
|
|
877
938
|
...resolveTheme(opts, siteName, fonts, basePath, buildSpec?.locale),
|
|
878
939
|
...customAssets.theme,
|
|
879
940
|
...footer ? { footer } : {},
|
|
941
|
+
...favicon ? { favicon: favicon.href } : {},
|
|
880
942
|
...meta ? { meta } : {}
|
|
881
943
|
},
|
|
882
944
|
destination: absoluteDestination,
|
|
@@ -895,7 +957,13 @@ async function publish(data, opts, tutorials) {
|
|
|
895
957
|
} : {}
|
|
896
958
|
})
|
|
897
959
|
);
|
|
898
|
-
const outputFiles = [
|
|
960
|
+
const outputFiles = [
|
|
961
|
+
...result.files,
|
|
962
|
+
...logoFiles,
|
|
963
|
+
...customAssets.files,
|
|
964
|
+
...docImageFiles,
|
|
965
|
+
...favicon?.files ?? []
|
|
966
|
+
];
|
|
899
967
|
await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
|
|
900
968
|
const zlib = await import("zlib");
|
|
901
969
|
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
@@ -935,11 +1003,13 @@ export {
|
|
|
935
1003
|
normalizeMenu,
|
|
936
1004
|
normalizeMeta,
|
|
937
1005
|
normalizePageNav,
|
|
1006
|
+
normalizePlayground,
|
|
938
1007
|
normalizeSectionOrder,
|
|
939
1008
|
outputSourceFilesEnabled,
|
|
940
1009
|
overlayDocs,
|
|
941
1010
|
publish,
|
|
942
1011
|
resolveDocImages,
|
|
1012
|
+
resolveFavicon,
|
|
943
1013
|
resolveFooter,
|
|
944
1014
|
sourceLinkToCommentEnabled
|
|
945
1015
|
};
|