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.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OutputFile, ThemeColors, CopyPageConfig, PageNavConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
2
|
-
import { DocInput, MenuItem } from '@clean-jsdoc-theme/setu';
|
|
1
|
+
import { OutputFile, ThemeColors, CopyPageConfig, MetaTag, PageNavConfig, ThemeConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
2
|
+
import { DocInput, MenuItem, PlaygroundSiteConfig } from '@clean-jsdoc-theme/setu';
|
|
3
3
|
|
|
4
4
|
interface JSDocOpts {
|
|
5
5
|
destination?: string;
|
|
@@ -106,6 +106,40 @@ interface JSDocOpts {
|
|
|
106
106
|
* Defaults to enabled.
|
|
107
107
|
*/
|
|
108
108
|
pageNav?: unknown;
|
|
109
|
+
/**
|
|
110
|
+
* Code-playground config (`jsdoc.json` `"opts": { "playground": … }`). Either
|
|
111
|
+
* a boolean (`true` turns it on with defaults; absent/`false` = off) or an
|
|
112
|
+
* object `{ enableForAllExamples?, providers?, codepen?, jsfiddle?,
|
|
113
|
+
* codesandbox? }`. `providers` picks which of CodePen/JSFiddle/CodeSandbox an
|
|
114
|
+
* `@example` (or prose code block) can be opened in; the per-provider records
|
|
115
|
+
* hold their site-wide runtime options. When set, `@playground` tags are
|
|
116
|
+
* honored; when off, they're ignored (byte-identical output).
|
|
117
|
+
*/
|
|
118
|
+
playground?: unknown;
|
|
119
|
+
/**
|
|
120
|
+
* Custom site footer (`jsdoc.json` `"opts": { "footer": … }`). Either an
|
|
121
|
+
* inline HTML string (v4 parity) or `{ "file": "./footer.html" }` (read from
|
|
122
|
+
* disk by the bridge). Rendered into rang's footer slot in place of the
|
|
123
|
+
* default footer on every page; style it with `customCss`/`customCssFile`.
|
|
124
|
+
* Omit for the default footer.
|
|
125
|
+
*/
|
|
126
|
+
footer?: unknown;
|
|
127
|
+
/**
|
|
128
|
+
* Favicon (`jsdoc.json` `"opts": { "favicon": "./icon.svg" }`). A path to an
|
|
129
|
+
* image file (`.svg`/`.png`/`.ico`/…), relative to the working dir. The bridge
|
|
130
|
+
* copies it to a content-hashed `_assets/` asset and emits a `<link rel="icon">`
|
|
131
|
+
* in every page's `<head>`. Needed for an SVG favicon (browsers only
|
|
132
|
+
* auto-discover a root `favicon.ico`). Omit for none.
|
|
133
|
+
*/
|
|
134
|
+
favicon?: unknown;
|
|
135
|
+
/**
|
|
136
|
+
* Site-wide custom `<meta>` tags (`jsdoc.json` `"opts": { "meta": [...] }`). An
|
|
137
|
+
* array of attribute maps — each object's key/value pairs become one `<meta>`
|
|
138
|
+
* tag in `<head>` (`{ name, content }`, `{ property, content }`, …). dwar
|
|
139
|
+
* escapes values, drops invalid attribute names, and de-dupes against its own
|
|
140
|
+
* head defaults (an author `name: "description"` replaces the auto one).
|
|
141
|
+
*/
|
|
142
|
+
meta?: unknown;
|
|
109
143
|
/**
|
|
110
144
|
* Inline custom CSS (`jsdoc.json` `"opts": { "customCss": "…" }`), injected as
|
|
111
145
|
* a `<style>` after the theme stylesheet so it can override.
|
|
@@ -163,6 +197,36 @@ interface JSDocOpts {
|
|
|
163
197
|
};
|
|
164
198
|
[key: string]: unknown;
|
|
165
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Resolve `opts.footer` (inline HTML `string` | `{ file }`) into the single
|
|
202
|
+
* `ThemeConfig.footer` string. The `{ file }` form is read from disk HERE — the
|
|
203
|
+
* bridge is the I/O layer, so dwar's `render()` only ever sees the resolved
|
|
204
|
+
* string. A missing/unreadable file is warned about and dropped (resilient,
|
|
205
|
+
* like the logo/custom-asset paths), and an empty value yields `undefined` so
|
|
206
|
+
* the default footer renders. Exported for testing.
|
|
207
|
+
*/
|
|
208
|
+
declare function resolveFooter(raw: unknown): Promise<string | undefined>;
|
|
209
|
+
/**
|
|
210
|
+
* Resolve `opts.favicon` (a file path) into a served `_assets/` href + the file
|
|
211
|
+
* to write — the bridge is the I/O layer, so dwar only sees the final URL and
|
|
212
|
+
* `render()` stays pure. The asset name is content-hashed (cache-busted) unless
|
|
213
|
+
* `hash` is off, and the source extension is preserved so dwar can derive the
|
|
214
|
+
* `<link>` `type`. A missing/unreadable file is warned about and dropped
|
|
215
|
+
* (resilient, like the logo/custom-asset paths). Exported for testing.
|
|
216
|
+
*/
|
|
217
|
+
declare function resolveFavicon(raw: unknown, hash: boolean, hrefForServed: (servedPath: string) => string): Promise<{
|
|
218
|
+
href: string;
|
|
219
|
+
files: OutputFile[];
|
|
220
|
+
} | undefined>;
|
|
221
|
+
/**
|
|
222
|
+
* Validate `opts.meta` into a clean `MetaTag[]` (attribute maps), or `undefined`
|
|
223
|
+
* when there's nothing usable. Accepts only an array of objects; within each,
|
|
224
|
+
* keeps string→string pairs (trimming the value, coercing finite numbers to
|
|
225
|
+
* strings for convenience) and drops the rest. An entry with no recognized
|
|
226
|
+
* identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
|
|
227
|
+
* dropped with a warning — dwar does the final escaping + key validation.
|
|
228
|
+
*/
|
|
229
|
+
declare function normalizeMeta(raw: unknown): MetaTag[] | undefined;
|
|
166
230
|
/**
|
|
167
231
|
* Resolve JSDoc's `templates.default.outputSourceFiles` flag. The `opts` arg
|
|
168
232
|
* `publish` receives is `env.opts` — the `opts` block — which does NOT carry the
|
|
@@ -220,6 +284,21 @@ declare function normalizeCopyPage(raw: unknown): CopyPageConfig | undefined;
|
|
|
220
284
|
* object whose `enabled` is read when boolean.
|
|
221
285
|
*/
|
|
222
286
|
declare function normalizePageNav(raw: unknown): PageNavConfig | undefined;
|
|
287
|
+
/**
|
|
288
|
+
* Validate `opts.playground` into its two consumer slices, or `undefined` when
|
|
289
|
+
* the feature is off (absent or `false`). `playground: true` / `{}` turns it on
|
|
290
|
+
* with defaults — every provider available, opt-in per `@playground`. The
|
|
291
|
+
* **`site`** slice feeds setu's `@playground` resolver (enablement + provider
|
|
292
|
+
* selection); the **`theme`** slice becomes `ThemeConfig.playground` (the
|
|
293
|
+
* site-wide per-provider runtime options dwar hands the browser island). Unknown
|
|
294
|
+
* providers/keys are dropped (lenient, like {@link normalizeCopyPage}). setu
|
|
295
|
+
* gates on the `site` slice's presence, so returning `undefined` keeps output
|
|
296
|
+
* byte-identical.
|
|
297
|
+
*/
|
|
298
|
+
declare function normalizePlayground(raw: unknown): {
|
|
299
|
+
site: PlaygroundSiteConfig;
|
|
300
|
+
theme: NonNullable<ThemeConfig['playground']>;
|
|
301
|
+
} | undefined;
|
|
223
302
|
/**
|
|
224
303
|
* Validate a user `colors`/`darkColors` object from `jsdoc.json` into a clean
|
|
225
304
|
* `Partial<ThemeColors>`: keeps only the known palette keys whose value is a
|
|
@@ -300,4 +379,4 @@ declare function overlayDocs(base: ResolvedDocs, locale: ResolvedDocs): Resolved
|
|
|
300
379
|
declare function normalizeDocGroups(raw: unknown): string[] | undefined;
|
|
301
380
|
declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
|
|
302
381
|
|
|
303
|
-
export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, sourceLinkToCommentEnabled };
|
|
382
|
+
export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizePlayground, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, resolveFavicon, resolveFooter, sourceLinkToCommentEnabled };
|
package/dist/publish.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OutputFile, ThemeColors, CopyPageConfig, PageNavConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
2
|
-
import { DocInput, MenuItem } from '@clean-jsdoc-theme/setu';
|
|
1
|
+
import { OutputFile, ThemeColors, CopyPageConfig, MetaTag, PageNavConfig, ThemeConfig, SiteLogo } from '@clean-jsdoc-theme/dwar';
|
|
2
|
+
import { DocInput, MenuItem, PlaygroundSiteConfig } from '@clean-jsdoc-theme/setu';
|
|
3
3
|
|
|
4
4
|
interface JSDocOpts {
|
|
5
5
|
destination?: string;
|
|
@@ -106,6 +106,40 @@ interface JSDocOpts {
|
|
|
106
106
|
* Defaults to enabled.
|
|
107
107
|
*/
|
|
108
108
|
pageNav?: unknown;
|
|
109
|
+
/**
|
|
110
|
+
* Code-playground config (`jsdoc.json` `"opts": { "playground": … }`). Either
|
|
111
|
+
* a boolean (`true` turns it on with defaults; absent/`false` = off) or an
|
|
112
|
+
* object `{ enableForAllExamples?, providers?, codepen?, jsfiddle?,
|
|
113
|
+
* codesandbox? }`. `providers` picks which of CodePen/JSFiddle/CodeSandbox an
|
|
114
|
+
* `@example` (or prose code block) can be opened in; the per-provider records
|
|
115
|
+
* hold their site-wide runtime options. When set, `@playground` tags are
|
|
116
|
+
* honored; when off, they're ignored (byte-identical output).
|
|
117
|
+
*/
|
|
118
|
+
playground?: unknown;
|
|
119
|
+
/**
|
|
120
|
+
* Custom site footer (`jsdoc.json` `"opts": { "footer": … }`). Either an
|
|
121
|
+
* inline HTML string (v4 parity) or `{ "file": "./footer.html" }` (read from
|
|
122
|
+
* disk by the bridge). Rendered into rang's footer slot in place of the
|
|
123
|
+
* default footer on every page; style it with `customCss`/`customCssFile`.
|
|
124
|
+
* Omit for the default footer.
|
|
125
|
+
*/
|
|
126
|
+
footer?: unknown;
|
|
127
|
+
/**
|
|
128
|
+
* Favicon (`jsdoc.json` `"opts": { "favicon": "./icon.svg" }`). A path to an
|
|
129
|
+
* image file (`.svg`/`.png`/`.ico`/…), relative to the working dir. The bridge
|
|
130
|
+
* copies it to a content-hashed `_assets/` asset and emits a `<link rel="icon">`
|
|
131
|
+
* in every page's `<head>`. Needed for an SVG favicon (browsers only
|
|
132
|
+
* auto-discover a root `favicon.ico`). Omit for none.
|
|
133
|
+
*/
|
|
134
|
+
favicon?: unknown;
|
|
135
|
+
/**
|
|
136
|
+
* Site-wide custom `<meta>` tags (`jsdoc.json` `"opts": { "meta": [...] }`). An
|
|
137
|
+
* array of attribute maps — each object's key/value pairs become one `<meta>`
|
|
138
|
+
* tag in `<head>` (`{ name, content }`, `{ property, content }`, …). dwar
|
|
139
|
+
* escapes values, drops invalid attribute names, and de-dupes against its own
|
|
140
|
+
* head defaults (an author `name: "description"` replaces the auto one).
|
|
141
|
+
*/
|
|
142
|
+
meta?: unknown;
|
|
109
143
|
/**
|
|
110
144
|
* Inline custom CSS (`jsdoc.json` `"opts": { "customCss": "…" }`), injected as
|
|
111
145
|
* a `<style>` after the theme stylesheet so it can override.
|
|
@@ -163,6 +197,36 @@ interface JSDocOpts {
|
|
|
163
197
|
};
|
|
164
198
|
[key: string]: unknown;
|
|
165
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Resolve `opts.footer` (inline HTML `string` | `{ file }`) into the single
|
|
202
|
+
* `ThemeConfig.footer` string. The `{ file }` form is read from disk HERE — the
|
|
203
|
+
* bridge is the I/O layer, so dwar's `render()` only ever sees the resolved
|
|
204
|
+
* string. A missing/unreadable file is warned about and dropped (resilient,
|
|
205
|
+
* like the logo/custom-asset paths), and an empty value yields `undefined` so
|
|
206
|
+
* the default footer renders. Exported for testing.
|
|
207
|
+
*/
|
|
208
|
+
declare function resolveFooter(raw: unknown): Promise<string | undefined>;
|
|
209
|
+
/**
|
|
210
|
+
* Resolve `opts.favicon` (a file path) into a served `_assets/` href + the file
|
|
211
|
+
* to write — the bridge is the I/O layer, so dwar only sees the final URL and
|
|
212
|
+
* `render()` stays pure. The asset name is content-hashed (cache-busted) unless
|
|
213
|
+
* `hash` is off, and the source extension is preserved so dwar can derive the
|
|
214
|
+
* `<link>` `type`. A missing/unreadable file is warned about and dropped
|
|
215
|
+
* (resilient, like the logo/custom-asset paths). Exported for testing.
|
|
216
|
+
*/
|
|
217
|
+
declare function resolveFavicon(raw: unknown, hash: boolean, hrefForServed: (servedPath: string) => string): Promise<{
|
|
218
|
+
href: string;
|
|
219
|
+
files: OutputFile[];
|
|
220
|
+
} | undefined>;
|
|
221
|
+
/**
|
|
222
|
+
* Validate `opts.meta` into a clean `MetaTag[]` (attribute maps), or `undefined`
|
|
223
|
+
* when there's nothing usable. Accepts only an array of objects; within each,
|
|
224
|
+
* keeps string→string pairs (trimming the value, coercing finite numbers to
|
|
225
|
+
* strings for convenience) and drops the rest. An entry with no recognized
|
|
226
|
+
* identifying attribute (`name`/`property`/`http-equiv`/`charset`/`itemprop`) is
|
|
227
|
+
* dropped with a warning — dwar does the final escaping + key validation.
|
|
228
|
+
*/
|
|
229
|
+
declare function normalizeMeta(raw: unknown): MetaTag[] | undefined;
|
|
166
230
|
/**
|
|
167
231
|
* Resolve JSDoc's `templates.default.outputSourceFiles` flag. The `opts` arg
|
|
168
232
|
* `publish` receives is `env.opts` — the `opts` block — which does NOT carry the
|
|
@@ -220,6 +284,21 @@ declare function normalizeCopyPage(raw: unknown): CopyPageConfig | undefined;
|
|
|
220
284
|
* object whose `enabled` is read when boolean.
|
|
221
285
|
*/
|
|
222
286
|
declare function normalizePageNav(raw: unknown): PageNavConfig | undefined;
|
|
287
|
+
/**
|
|
288
|
+
* Validate `opts.playground` into its two consumer slices, or `undefined` when
|
|
289
|
+
* the feature is off (absent or `false`). `playground: true` / `{}` turns it on
|
|
290
|
+
* with defaults — every provider available, opt-in per `@playground`. The
|
|
291
|
+
* **`site`** slice feeds setu's `@playground` resolver (enablement + provider
|
|
292
|
+
* selection); the **`theme`** slice becomes `ThemeConfig.playground` (the
|
|
293
|
+
* site-wide per-provider runtime options dwar hands the browser island). Unknown
|
|
294
|
+
* providers/keys are dropped (lenient, like {@link normalizeCopyPage}). setu
|
|
295
|
+
* gates on the `site` slice's presence, so returning `undefined` keeps output
|
|
296
|
+
* byte-identical.
|
|
297
|
+
*/
|
|
298
|
+
declare function normalizePlayground(raw: unknown): {
|
|
299
|
+
site: PlaygroundSiteConfig;
|
|
300
|
+
theme: NonNullable<ThemeConfig['playground']>;
|
|
301
|
+
} | undefined;
|
|
223
302
|
/**
|
|
224
303
|
* Validate a user `colors`/`darkColors` object from `jsdoc.json` into a clean
|
|
225
304
|
* `Partial<ThemeColors>`: keeps only the known palette keys whose value is a
|
|
@@ -300,4 +379,4 @@ declare function overlayDocs(base: ResolvedDocs, locale: ResolvedDocs): Resolved
|
|
|
300
379
|
declare function normalizeDocGroups(raw: unknown): string[] | undefined;
|
|
301
380
|
declare function publish(data: unknown, opts: JSDocOpts, tutorials?: unknown): Promise<void>;
|
|
302
381
|
|
|
303
|
-
export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizePageNav, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, sourceLinkToCommentEnabled };
|
|
382
|
+
export { type ResolvedDocs, collectDocs, computeRelPaths, hasMarkdownPlugin, normalizeColors, normalizeCopyPage, normalizeDocGroups, normalizeMenu, normalizeMeta, normalizePageNav, normalizePlayground, normalizeSectionOrder, outputSourceFilesEnabled, overlayDocs, publish, resolveDocImages, resolveFavicon, resolveFooter, sourceLinkToCommentEnabled };
|
package/dist/publish.js
CHANGED
|
@@ -37,12 +37,16 @@ __export(publish_exports, {
|
|
|
37
37
|
normalizeCopyPage: () => normalizeCopyPage,
|
|
38
38
|
normalizeDocGroups: () => normalizeDocGroups,
|
|
39
39
|
normalizeMenu: () => normalizeMenu,
|
|
40
|
+
normalizeMeta: () => normalizeMeta,
|
|
40
41
|
normalizePageNav: () => normalizePageNav,
|
|
42
|
+
normalizePlayground: () => normalizePlayground,
|
|
41
43
|
normalizeSectionOrder: () => normalizeSectionOrder,
|
|
42
44
|
outputSourceFilesEnabled: () => outputSourceFilesEnabled,
|
|
43
45
|
overlayDocs: () => overlayDocs,
|
|
44
46
|
publish: () => publish,
|
|
45
47
|
resolveDocImages: () => resolveDocImages,
|
|
48
|
+
resolveFavicon: () => resolveFavicon,
|
|
49
|
+
resolveFooter: () => resolveFooter,
|
|
46
50
|
sourceLinkToCommentEnabled: () => sourceLinkToCommentEnabled
|
|
47
51
|
});
|
|
48
52
|
module.exports = __toCommonJS(publish_exports);
|
|
@@ -222,6 +226,7 @@ function resolveTheme(opts, siteName, fonts, basePath, locale) {
|
|
|
222
226
|
const aiPrompt = typeof opts.aiPrompt === "string" && opts.aiPrompt.trim() ? opts.aiPrompt.trim() : void 0;
|
|
223
227
|
const copyPage = normalizeCopyPage(opts.copyPage);
|
|
224
228
|
const pageNav = normalizePageNav(opts.pageNav);
|
|
229
|
+
const playground = normalizePlayground(opts.playground);
|
|
225
230
|
const colors = normalizeColors(opts.colors);
|
|
226
231
|
const darkColors = normalizeColors(opts.darkColors);
|
|
227
232
|
return {
|
|
@@ -230,6 +235,7 @@ function resolveTheme(opts, siteName, fonts, basePath, locale) {
|
|
|
230
235
|
...aiPrompt ? { aiPrompt } : {},
|
|
231
236
|
...copyPage ? { copyPage } : {},
|
|
232
237
|
...pageNav ? { pageNav } : {},
|
|
238
|
+
...playground ? { playground: playground.theme } : {},
|
|
233
239
|
tokens: {
|
|
234
240
|
...defaultTheme.tokens,
|
|
235
241
|
colors: { ...defaultTheme.tokens.colors, ...colors ?? {} },
|
|
@@ -289,6 +295,69 @@ async function resolveCustomAssets(opts, hrefForServed) {
|
|
|
289
295
|
files: [...cssAssets.files, ...jsAssets.files]
|
|
290
296
|
};
|
|
291
297
|
}
|
|
298
|
+
async function resolveFooter(raw) {
|
|
299
|
+
if (typeof raw === "string") {
|
|
300
|
+
const trimmed = raw.trim();
|
|
301
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
302
|
+
}
|
|
303
|
+
if (raw && typeof raw === "object" && typeof raw.file === "string") {
|
|
304
|
+
const file = raw.file.trim();
|
|
305
|
+
if (!file) return void 0;
|
|
306
|
+
try {
|
|
307
|
+
const html = await (0, import_promises2.readFile)((0, import_node_path2.resolve)(file), "utf8");
|
|
308
|
+
return html.trim().length > 0 ? html : void 0;
|
|
309
|
+
} catch {
|
|
310
|
+
console.warn(
|
|
311
|
+
`clean-jsdoc-theme: could not read footer file ('${file}'); omitting the custom footer.`
|
|
312
|
+
);
|
|
313
|
+
return void 0;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return void 0;
|
|
317
|
+
}
|
|
318
|
+
async function resolveFavicon(raw, hash, hrefForServed) {
|
|
319
|
+
if (typeof raw !== "string" || raw.trim().length === 0) return void 0;
|
|
320
|
+
const trimmed = raw.trim();
|
|
321
|
+
let bytes;
|
|
322
|
+
try {
|
|
323
|
+
bytes = await (0, import_promises2.readFile)((0, import_node_path2.resolve)(trimmed));
|
|
324
|
+
} catch {
|
|
325
|
+
console.warn(`clean-jsdoc-theme: could not read favicon ('${trimmed}'); omitting it.`);
|
|
326
|
+
return void 0;
|
|
327
|
+
}
|
|
328
|
+
const ext = (0, import_node_path2.extname)(trimmed) || ".ico";
|
|
329
|
+
const base = (0, import_node_path2.basename)(trimmed, (0, import_node_path2.extname)(trimmed)) || "favicon";
|
|
330
|
+
const name = hash ? `${base}.${contentHash(bytes)}${ext}` : `${base}${ext}`;
|
|
331
|
+
const servedPath = `_assets/${name}`;
|
|
332
|
+
return { href: hrefForServed(servedPath), files: [{ path: servedPath, contents: bytes }] };
|
|
333
|
+
}
|
|
334
|
+
var META_IDENTITY_ATTRS = ["name", "property", "http-equiv", "charset", "itemprop"];
|
|
335
|
+
function normalizeMeta(raw) {
|
|
336
|
+
if (!Array.isArray(raw)) return void 0;
|
|
337
|
+
const out = [];
|
|
338
|
+
for (const entry of raw) {
|
|
339
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
340
|
+
const o = entry;
|
|
341
|
+
const tag = {};
|
|
342
|
+
for (const [k, v] of Object.entries(o)) {
|
|
343
|
+
if (typeof v === "string") {
|
|
344
|
+
const t = v.trim();
|
|
345
|
+
if (t.length > 0) tag[k] = t;
|
|
346
|
+
} else if (typeof v === "number" && Number.isFinite(v)) {
|
|
347
|
+
tag[k] = String(v);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const hasIdentity = META_IDENTITY_ATTRS.some((a) => typeof tag[a] === "string");
|
|
351
|
+
if (!hasIdentity || Object.keys(tag).length === 0) {
|
|
352
|
+
console.warn(
|
|
353
|
+
`clean-jsdoc-theme: skipping a meta entry with no usable name/property/http-equiv/charset attribute (${JSON.stringify(entry)}).`
|
|
354
|
+
);
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
out.push(tag);
|
|
358
|
+
}
|
|
359
|
+
return out.length > 0 ? out : void 0;
|
|
360
|
+
}
|
|
292
361
|
function isServableUrl(value) {
|
|
293
362
|
return /^(https?:)?\/\//i.test(value) || /^data:/i.test(value);
|
|
294
363
|
}
|
|
@@ -464,7 +533,47 @@ function normalizePageNav(raw) {
|
|
|
464
533
|
const enabled = raw.enabled;
|
|
465
534
|
return typeof enabled === "boolean" ? { enabled } : void 0;
|
|
466
535
|
}
|
|
467
|
-
var
|
|
536
|
+
var PLAYGROUND_PROVIDERS = ["codepen", "jsfiddle", "codesandbox"];
|
|
537
|
+
function playgroundOptionRecord(raw) {
|
|
538
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
|
|
539
|
+
}
|
|
540
|
+
function normalizePlayground(raw) {
|
|
541
|
+
if (raw == null || raw === false) return void 0;
|
|
542
|
+
const o = raw === true ? {} : raw;
|
|
543
|
+
if (typeof o !== "object" || Array.isArray(o)) return void 0;
|
|
544
|
+
const obj = o;
|
|
545
|
+
const site = {};
|
|
546
|
+
if (obj.enableForAllExamples === true) site.enableForAllExamples = true;
|
|
547
|
+
if (Array.isArray(obj.providers)) {
|
|
548
|
+
const providers = [];
|
|
549
|
+
for (const p of obj.providers) {
|
|
550
|
+
if (typeof p === "string" && PLAYGROUND_PROVIDERS.includes(p) && !providers.includes(p)) {
|
|
551
|
+
providers.push(p);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (providers.length > 0) site.providers = providers;
|
|
555
|
+
}
|
|
556
|
+
const theme = { enabled: true };
|
|
557
|
+
const codepen = playgroundOptionRecord(obj.codepen);
|
|
558
|
+
const jsfiddle = playgroundOptionRecord(obj.jsfiddle);
|
|
559
|
+
const codesandbox = playgroundOptionRecord(obj.codesandbox);
|
|
560
|
+
if (codepen) theme.codepen = codepen;
|
|
561
|
+
if (jsfiddle) theme.jsfiddle = jsfiddle;
|
|
562
|
+
if (codesandbox) theme.codesandbox = codesandbox;
|
|
563
|
+
return { site, theme };
|
|
564
|
+
}
|
|
565
|
+
var COLOR_KEYS = [
|
|
566
|
+
"bg",
|
|
567
|
+
"bgMuted",
|
|
568
|
+
"fg",
|
|
569
|
+
"fgMuted",
|
|
570
|
+
"accent",
|
|
571
|
+
"accentFg",
|
|
572
|
+
"border",
|
|
573
|
+
"codeHeaderBg",
|
|
574
|
+
"codeHeaderFg",
|
|
575
|
+
"codeHighlightBg"
|
|
576
|
+
];
|
|
468
577
|
function normalizeColors(raw) {
|
|
469
578
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
470
579
|
const src = raw;
|
|
@@ -812,6 +921,7 @@ async function publish(data, opts, tutorials) {
|
|
|
812
921
|
const sectionOrder = normalizeSectionOrder(opts.sectionOrder);
|
|
813
922
|
const menu = normalizeMenu(opts.menu);
|
|
814
923
|
const clubSidebarItems = opts.clubSidebarItems === true;
|
|
924
|
+
const playground = normalizePlayground(opts.playground);
|
|
815
925
|
const siteOptions = {
|
|
816
926
|
...pkg ? { pkg } : {},
|
|
817
927
|
...readme ? { readme } : {},
|
|
@@ -823,7 +933,8 @@ async function publish(data, opts, tutorials) {
|
|
|
823
933
|
...defaultDocGroup ? { defaultDocGroup } : {},
|
|
824
934
|
...sectionOrder ? { sectionOrder } : {},
|
|
825
935
|
...menu ? { menu } : {},
|
|
826
|
-
...clubSidebarItems ? { clubSidebarItems } : {}
|
|
936
|
+
...clubSidebarItems ? { clubSidebarItems } : {},
|
|
937
|
+
...playground ? { playground: playground.site } : {}
|
|
827
938
|
};
|
|
828
939
|
const manifest = await progress.stage(
|
|
829
940
|
"Generating pages",
|
|
@@ -859,6 +970,9 @@ async function publish(data, opts, tutorials) {
|
|
|
859
970
|
fonts.locales = cleaned;
|
|
860
971
|
}
|
|
861
972
|
const customAssets = await resolveCustomAssets(opts, hrefForServed);
|
|
973
|
+
const footer = await resolveFooter(opts.footer);
|
|
974
|
+
const favicon = await resolveFavicon(opts.favicon, opts.hashCustomAssets !== false, hrefForServed);
|
|
975
|
+
const meta = normalizeMeta(opts.meta);
|
|
862
976
|
const absoluteDestination = (0, import_node_path2.resolve)(destination);
|
|
863
977
|
const islandCacheDir = (0, import_node_path2.resolve)(process.cwd(), "node_modules", ".cache", "clean-jsdoc-theme");
|
|
864
978
|
const result = await progress.stage(
|
|
@@ -866,7 +980,10 @@ async function publish(data, opts, tutorials) {
|
|
|
866
980
|
() => render(manifest, {
|
|
867
981
|
theme: {
|
|
868
982
|
...resolveTheme(opts, siteName, fonts, basePath, buildSpec?.locale),
|
|
869
|
-
...customAssets.theme
|
|
983
|
+
...customAssets.theme,
|
|
984
|
+
...footer ? { footer } : {},
|
|
985
|
+
...favicon ? { favicon: favicon.href } : {},
|
|
986
|
+
...meta ? { meta } : {}
|
|
870
987
|
},
|
|
871
988
|
destination: absoluteDestination,
|
|
872
989
|
islandCacheDir,
|
|
@@ -884,7 +1001,13 @@ async function publish(data, opts, tutorials) {
|
|
|
884
1001
|
} : {}
|
|
885
1002
|
})
|
|
886
1003
|
);
|
|
887
|
-
const outputFiles = [
|
|
1004
|
+
const outputFiles = [
|
|
1005
|
+
...result.files,
|
|
1006
|
+
...logoFiles,
|
|
1007
|
+
...customAssets.files,
|
|
1008
|
+
...docImageFiles,
|
|
1009
|
+
...favicon?.files ?? []
|
|
1010
|
+
];
|
|
888
1011
|
await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
|
|
889
1012
|
const zlib = await import("zlib");
|
|
890
1013
|
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
@@ -923,12 +1046,16 @@ async function publish(data, opts, tutorials) {
|
|
|
923
1046
|
normalizeCopyPage,
|
|
924
1047
|
normalizeDocGroups,
|
|
925
1048
|
normalizeMenu,
|
|
1049
|
+
normalizeMeta,
|
|
926
1050
|
normalizePageNav,
|
|
1051
|
+
normalizePlayground,
|
|
927
1052
|
normalizeSectionOrder,
|
|
928
1053
|
outputSourceFilesEnabled,
|
|
929
1054
|
overlayDocs,
|
|
930
1055
|
publish,
|
|
931
1056
|
resolveDocImages,
|
|
1057
|
+
resolveFavicon,
|
|
1058
|
+
resolveFooter,
|
|
932
1059
|
sourceLinkToCommentEnabled
|
|
933
1060
|
});
|
|
934
1061
|
//# sourceMappingURL=publish.js.map
|