clean-jsdoc-theme 5.0.0-alpha.4 → 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 +82 -3
- package/dist/publish.d.ts +82 -3
- package/dist/publish.js +131 -4
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +127 -4
- 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 ?? {} },
|
|
@@ -249,6 +251,69 @@ async function resolveCustomAssets(opts, hrefForServed) {
|
|
|
249
251
|
files: [...cssAssets.files, ...jsAssets.files]
|
|
250
252
|
};
|
|
251
253
|
}
|
|
254
|
+
async function resolveFooter(raw) {
|
|
255
|
+
if (typeof raw === "string") {
|
|
256
|
+
const trimmed = raw.trim();
|
|
257
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
258
|
+
}
|
|
259
|
+
if (raw && typeof raw === "object" && typeof raw.file === "string") {
|
|
260
|
+
const file = raw.file.trim();
|
|
261
|
+
if (!file) return void 0;
|
|
262
|
+
try {
|
|
263
|
+
const html = await readFile(resolvePath(file), "utf8");
|
|
264
|
+
return html.trim().length > 0 ? html : void 0;
|
|
265
|
+
} catch {
|
|
266
|
+
console.warn(
|
|
267
|
+
`clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`
|
|
268
|
+
);
|
|
269
|
+
return void 0;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return void 0;
|
|
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
|
+
}
|
|
290
|
+
var META_IDENTITY_ATTRS = ["name", "property", "http-equiv", "charset", "itemprop"];
|
|
291
|
+
function normalizeMeta(raw) {
|
|
292
|
+
if (!Array.isArray(raw)) return void 0;
|
|
293
|
+
const out = [];
|
|
294
|
+
for (const entry of raw) {
|
|
295
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
296
|
+
const o = entry;
|
|
297
|
+
const tag = {};
|
|
298
|
+
for (const [k, v] of Object.entries(o)) {
|
|
299
|
+
if (typeof v === "string") {
|
|
300
|
+
const t = v.trim();
|
|
301
|
+
if (t.length > 0) tag[k] = t;
|
|
302
|
+
} else if (typeof v === "number" && Number.isFinite(v)) {
|
|
303
|
+
tag[k] = String(v);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const hasIdentity = META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string");
|
|
307
|
+
if (!hasIdentity || Object.keys(tag).length === 0) {
|
|
308
|
+
console.warn(
|
|
309
|
+
`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`
|
|
310
|
+
);
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
out.push(tag);
|
|
314
|
+
}
|
|
315
|
+
return out.length > 0 ? out : void 0;
|
|
316
|
+
}
|
|
252
317
|
function isServableUrl(value) {
|
|
253
318
|
return /^(https?:)?\/\//i.test(value) || /^data:/i.test(value);
|
|
254
319
|
}
|
|
@@ -424,7 +489,47 @@ function normalizePageNav(raw) {
|
|
|
424
489
|
const enabled = raw.enabled;
|
|
425
490
|
return typeof enabled === "boolean" ? { enabled } : void 0;
|
|
426
491
|
}
|
|
427
|
-
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
|
+
];
|
|
428
533
|
function normalizeColors(raw) {
|
|
429
534
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
430
535
|
const src = raw;
|
|
@@ -772,6 +877,7 @@ async function publish(data, opts, tutorials) {
|
|
|
772
877
|
const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
|
|
773
878
|
const menu = normalizeMenu(opts.menu);
|
|
774
879
|
const clubSidebarItems = opts.clubSidebarItems === true;
|
|
880
|
+
const playground = normalizePlayground(opts.playground);
|
|
775
881
|
const siteOptions = {
|
|
776
882
|
...pkg ? { pkg } : {},
|
|
777
883
|
...readme ? { readme } : {},
|
|
@@ -783,7 +889,8 @@ async function publish(data, opts, tutorials) {
|
|
|
783
889
|
...defaultDocGroup ? { defaultDocGroup } : {},
|
|
784
890
|
...sectionOrder ? { sectionOrder } : {},
|
|
785
891
|
...menu ? { menu } : {},
|
|
786
|
-
...clubSidebarItems ? { clubSidebarItems } : {}
|
|
892
|
+
...clubSidebarItems ? { clubSidebarItems } : {},
|
|
893
|
+
...playground ? { playground: playground.site } : {}
|
|
787
894
|
};
|
|
788
895
|
const manifest = await progress.stage(
|
|
789
896
|
"Generating pages",
|
|
@@ -819,6 +926,9 @@ async function publish(data, opts, tutorials) {
|
|
|
819
926
|
fonts.locales = cleaned;
|
|
820
927
|
}
|
|
821
928
|
const customAssets = await resolveCustomAssets(opts, hrefForServed);
|
|
929
|
+
const footer = await resolveFooter(opts.footer);
|
|
930
|
+
const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed);
|
|
931
|
+
const meta = normalizeMeta(opts.meta);
|
|
822
932
|
const absoluteDestination = resolvePath(destination);
|
|
823
933
|
const islandCacheDir = resolvePath(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
|
|
824
934
|
const result = await progress.stage(
|
|
@@ -826,7 +936,10 @@ async function publish(data, opts, tutorials) {
|
|
|
826
936
|
() => render(manifest, {
|
|
827
937
|
theme: {
|
|
828
938
|
...resolveTheme(opts, siteName, fonts, basePath, buildSpec?.locale),
|
|
829
|
-
...customAssets.theme
|
|
939
|
+
...customAssets.theme,
|
|
940
|
+
...footer ? { footer } : {},
|
|
941
|
+
...favicon ? { favicon: favicon.href } : {},
|
|
942
|
+
...meta ? { meta } : {}
|
|
830
943
|
},
|
|
831
944
|
destination: absoluteDestination,
|
|
832
945
|
islandCacheDir,
|
|
@@ -844,7 +957,13 @@ async function publish(data, opts, tutorials) {
|
|
|
844
957
|
} : {}
|
|
845
958
|
})
|
|
846
959
|
);
|
|
847
|
-
const outputFiles = [
|
|
960
|
+
const outputFiles = [
|
|
961
|
+
...result.files,
|
|
962
|
+
...logoFiles,
|
|
963
|
+
...customAssets.files,
|
|
964
|
+
...docImageFiles,
|
|
965
|
+
...favicon?.files ?? []
|
|
966
|
+
];
|
|
848
967
|
await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
|
|
849
968
|
const zlib = await import("zlib");
|
|
850
969
|
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
@@ -882,12 +1001,16 @@ export {
|
|
|
882
1001
|
normalizeCopyPage,
|
|
883
1002
|
normalizeDocGroups,
|
|
884
1003
|
normalizeMenu,
|
|
1004
|
+
normalizeMeta,
|
|
885
1005
|
normalizePageNav,
|
|
1006
|
+
normalizePlayground,
|
|
886
1007
|
normalizeSectionOrder,
|
|
887
1008
|
outputSourceFilesEnabled,
|
|
888
1009
|
overlayDocs,
|
|
889
1010
|
publish,
|
|
890
1011
|
resolveDocImages,
|
|
1012
|
+
resolveFavicon,
|
|
1013
|
+
resolveFooter,
|
|
891
1014
|
sourceLinkToCommentEnabled
|
|
892
1015
|
};
|
|
893
1016
|
//# sourceMappingURL=publish.mjs.map
|