@clarify-labs/cli 0.7.0 → 0.7.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/output/cli.cjs +2 -2
- package/output/cli.cjs.map +1 -1
- package/output/cli.js +2 -2
- package/output/cli.js.map +1 -1
- package/output/core/config-schema.d.ts +24 -4
- package/output/core/ssg.d.ts +1 -1
- package/output/core/theme.d.ts +2 -52
- package/output/core/virtual-modules.d.ts +2 -0
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/{plugin-dzXRzjdX.cjs → plugin-DFpkIm9j.cjs} +51 -141
- package/output/plugin-DFpkIm9j.cjs.map +1 -0
- package/output/{plugin-BNzlJ4o7.js → plugin-o1rP_gts.js} +51 -141
- package/output/plugin-o1rP_gts.js.map +1 -0
- package/output/types.d.ts +7 -1
- package/package.json +3 -3
- package/output/plugin-BNzlJ4o7.js.map +0 -1
- package/output/plugin-dzXRzjdX.cjs.map +0 -1
|
@@ -7,7 +7,7 @@ import GithubSlugger, { slug } from "github-slugger";
|
|
|
7
7
|
import { toString } from "mdast-util-to-string";
|
|
8
8
|
import shiki from "shiki";
|
|
9
9
|
import { visit } from "unist-util-visit";
|
|
10
|
-
import { markdownRemarkPlugins } from "@clarify-labs/renderer";
|
|
10
|
+
import { markdownRemarkPlugins, themeBootstrapScript, themePresets } from "@clarify-labs/renderer";
|
|
11
11
|
import { remark } from "remark";
|
|
12
12
|
import matter from "gray-matter";
|
|
13
13
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
@@ -232,80 +232,7 @@ function createContentArtifactsPlugin() {
|
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
234
|
//#endregion
|
|
235
|
-
//#region source/core/theme.ts
|
|
236
|
-
var clarifyThemePresets = {
|
|
237
|
-
default: {
|
|
238
|
-
preset: "default",
|
|
239
|
-
tokens: {
|
|
240
|
-
colors: {
|
|
241
|
-
primary: "#047857",
|
|
242
|
-
accent: "#0D9488",
|
|
243
|
-
background: "#ffffff",
|
|
244
|
-
foreground: "#111827",
|
|
245
|
-
surface: "#ffffff",
|
|
246
|
-
muted: "#64748b",
|
|
247
|
-
border: "rgb(15 23 42 / 0.12)",
|
|
248
|
-
codeBackground: "#f6fbf8"
|
|
249
|
-
},
|
|
250
|
-
radius: {
|
|
251
|
-
sm: "6px",
|
|
252
|
-
md: "10px",
|
|
253
|
-
lg: "14px",
|
|
254
|
-
xl: "18px"
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
layout: { maxWidth: "82rem" },
|
|
258
|
-
editor: false
|
|
259
|
-
},
|
|
260
|
-
base: {
|
|
261
|
-
preset: "base",
|
|
262
|
-
tokens: {
|
|
263
|
-
colors: {
|
|
264
|
-
primary: "#18181b",
|
|
265
|
-
accent: "#52525b",
|
|
266
|
-
background: "#ffffff",
|
|
267
|
-
foreground: "#18181b",
|
|
268
|
-
surface: "#ffffff",
|
|
269
|
-
muted: "#71717a",
|
|
270
|
-
border: "rgb(24 24 27 / 0.12)",
|
|
271
|
-
codeBackground: "#f4f4f5"
|
|
272
|
-
},
|
|
273
|
-
radius: {
|
|
274
|
-
sm: "6px",
|
|
275
|
-
md: "8px",
|
|
276
|
-
lg: "12px",
|
|
277
|
-
xl: "16px"
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
layout: { maxWidth: "80rem" },
|
|
281
|
-
editor: false
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
function resolveThemeConfig(theme = {}) {
|
|
285
|
-
const preset = theme.preset ?? "default";
|
|
286
|
-
const presetTheme = clarifyThemePresets[preset];
|
|
287
|
-
return {
|
|
288
|
-
preset,
|
|
289
|
-
tokens: {
|
|
290
|
-
colors: {
|
|
291
|
-
...presetTheme.tokens.colors,
|
|
292
|
-
...theme.tokens?.colors
|
|
293
|
-
},
|
|
294
|
-
radius: {
|
|
295
|
-
...presetTheme.tokens.radius,
|
|
296
|
-
...theme.tokens?.radius
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
layout: {
|
|
300
|
-
...presetTheme.layout,
|
|
301
|
-
...theme.layout
|
|
302
|
-
},
|
|
303
|
-
editor: theme.editor ?? presetTheme.editor
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
//#endregion
|
|
307
235
|
//#region source/plugins/html-shell/index.ts
|
|
308
|
-
var THEME_STORAGE_KEY = "clarify:theme";
|
|
309
236
|
var REL_ICON_RE = /<link\s+[^>]*rel=["'][^"']*\bicon\b[^"']*["'][^>]*>/i;
|
|
310
237
|
function inferIconType(href) {
|
|
311
238
|
const path = href.split(/[?#]/, 1)[0]?.toLowerCase() ?? href.toLowerCase();
|
|
@@ -335,62 +262,6 @@ function createIconTags(icon) {
|
|
|
335
262
|
if (lightIcon === darkIcon) return [createIconTag(lightIcon)];
|
|
336
263
|
return [createIconTag(lightIcon, "(prefers-color-scheme: light)"), createIconTag(darkIcon, "(prefers-color-scheme: dark)")];
|
|
337
264
|
}
|
|
338
|
-
function matchesPresetTheme(theme) {
|
|
339
|
-
const preset = clarifyThemePresets[theme.preset];
|
|
340
|
-
return JSON.stringify({
|
|
341
|
-
tokens: theme.tokens,
|
|
342
|
-
layout: theme.layout
|
|
343
|
-
}) === JSON.stringify({
|
|
344
|
-
tokens: preset.tokens,
|
|
345
|
-
layout: preset.layout
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
function effectiveTheme(theme, resolvedTheme) {
|
|
349
|
-
if (resolvedTheme !== "dark" || !matchesPresetTheme(theme)) return theme;
|
|
350
|
-
return {
|
|
351
|
-
...theme,
|
|
352
|
-
tokens: {
|
|
353
|
-
...theme.tokens,
|
|
354
|
-
colors: {
|
|
355
|
-
...theme.tokens.colors,
|
|
356
|
-
background: "#09090b",
|
|
357
|
-
foreground: "#ffffff",
|
|
358
|
-
surface: "#18181b",
|
|
359
|
-
muted: "#a1a1aa",
|
|
360
|
-
border: "rgb(255 255 255 / 0.1)",
|
|
361
|
-
codeBackground: "#18181b"
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
function resolveThemeColorValue(value, resolvedTheme) {
|
|
367
|
-
return typeof value === "string" ? value : value[resolvedTheme] ?? value.light ?? value.dark ?? "";
|
|
368
|
-
}
|
|
369
|
-
function themeToCssVariables(theme, resolvedTheme) {
|
|
370
|
-
const resolved = effectiveTheme(theme, resolvedTheme);
|
|
371
|
-
const { colors } = resolved.tokens;
|
|
372
|
-
const { radius } = resolved.tokens;
|
|
373
|
-
return {
|
|
374
|
-
"--clarify-theme-tokens-colors-primary": resolveThemeColorValue(colors.primary, resolvedTheme),
|
|
375
|
-
"--clarify-theme-tokens-colors-accent": resolveThemeColorValue(colors.accent, resolvedTheme),
|
|
376
|
-
"--clarify-theme-tokens-colors-background": resolveThemeColorValue(colors.background, resolvedTheme),
|
|
377
|
-
"--clarify-theme-tokens-colors-foreground": resolveThemeColorValue(colors.foreground, resolvedTheme),
|
|
378
|
-
"--clarify-theme-tokens-colors-surface": resolveThemeColorValue(colors.surface, resolvedTheme),
|
|
379
|
-
"--clarify-theme-tokens-colors-muted": resolveThemeColorValue(colors.muted, resolvedTheme),
|
|
380
|
-
"--clarify-theme-tokens-colors-border": resolveThemeColorValue(colors.border, resolvedTheme),
|
|
381
|
-
"--clarify-theme-tokens-colors-code-background": resolveThemeColorValue(colors.codeBackground, resolvedTheme),
|
|
382
|
-
"--clarify-theme-tokens-radius-sm": radius.sm,
|
|
383
|
-
"--clarify-theme-tokens-radius-md": radius.md,
|
|
384
|
-
"--clarify-theme-tokens-radius-lg": radius.lg,
|
|
385
|
-
"--clarify-theme-tokens-radius-xl": radius.xl,
|
|
386
|
-
"--clarify-theme-layout-max-width": resolved.layout.maxWidth
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
function themeBootstrapScript(theme) {
|
|
390
|
-
const darkVariables = themeToCssVariables(theme, "dark");
|
|
391
|
-
const lightVariables = themeToCssVariables(theme, "light");
|
|
392
|
-
return `(function(){try{var e=localStorage.getItem(${JSON.stringify(THEME_STORAGE_KEY)});var t=e==='dark'||e==='light'||e==='system'?e:'system';var r=t==='system'?window.matchMedia('(prefers-color-scheme: dark)').matches:t==='dark';var v=r?${JSON.stringify(darkVariables)}:${JSON.stringify(lightVariables)};var s=document.documentElement.style;for(var k in v)s.setProperty(k,v[k]);document.documentElement.classList.toggle('dark',r);document.documentElement.style.colorScheme=r?'dark':'light'}catch(e){}})();`;
|
|
393
|
-
}
|
|
394
265
|
function createHtmlShellPlugin() {
|
|
395
266
|
return {
|
|
396
267
|
name: "clarify:html-shell",
|
|
@@ -466,6 +337,7 @@ function navigationSections(sections) {
|
|
|
466
337
|
return sections.map((s) => ({
|
|
467
338
|
id: s.id,
|
|
468
339
|
title: s.title,
|
|
340
|
+
level: s.level,
|
|
469
341
|
badge: s.badge,
|
|
470
342
|
tags: s.tags
|
|
471
343
|
}));
|
|
@@ -860,6 +732,7 @@ function generateRoutesModule(routes, resolvedNavigation, projectConfig, mode =
|
|
|
860
732
|
const sections = r.sections && r.sections.length > 0 ? `, sections: ${JSON.stringify(r.sections.map((s) => ({
|
|
861
733
|
id: s.id,
|
|
862
734
|
title: s.title,
|
|
735
|
+
level: s.level,
|
|
863
736
|
badge: s.badge,
|
|
864
737
|
tags: s.tags
|
|
865
738
|
})))}` : "";
|
|
@@ -879,9 +752,11 @@ function generateRoutesModule(routes, resolvedNavigation, projectConfig, mode =
|
|
|
879
752
|
return `${imports}\n\nexport const routes = [\n${routesArray}\n];\n\nexport const navigation = ${JSON.stringify(navigation, null, 2)};\n`;
|
|
880
753
|
}
|
|
881
754
|
function createRuntimeModule(options = {}) {
|
|
882
|
-
|
|
883
|
-
export const openApis = {};
|
|
755
|
+
const imports = [options.bannerComponentSource === "path" && options.imports?.bannerComponent ? `import BannerComponent from ${moduleSpecifier(options.imports.bannerComponent)};` : void 0, options.footerComponentSource === "path" && options.imports?.footerComponent ? `import FooterComponent from ${moduleSpecifier(options.imports.footerComponent)};` : void 0].filter(Boolean).join("\n");
|
|
756
|
+
const exports = `export const openApis = {};
|
|
757
|
+
export const bannerComponent = ${options.bannerComponentSource === "path" ? "BannerComponent" : "undefined"};
|
|
884
758
|
export const footerComponent = ${options.footerComponentSource === "path" ? "FooterComponent" : "undefined"};`;
|
|
759
|
+
return imports ? `${imports}\n${exports}` : exports;
|
|
885
760
|
}
|
|
886
761
|
function createClientEntryModule(options = {}) {
|
|
887
762
|
return `
|
|
@@ -889,12 +764,15 @@ import '@clarify-labs/renderer/style.css';
|
|
|
889
764
|
import { render } from '@clarify-labs/renderer/client';
|
|
890
765
|
import { routes, navigation } from '${VIRTUAL_ROUTES}';
|
|
891
766
|
import { config } from '${VIRTUAL_CONFIG}';
|
|
892
|
-
import { openApis, footerComponent } from '${VIRTUAL_RUNTIME}';
|
|
893
|
-
render({ config, routes, navigation, openApis, footerComponent, themeEditor: ${JSON.stringify(options.themeEditor ?? false)} });`;
|
|
767
|
+
import { openApis, bannerComponent, footerComponent } from '${VIRTUAL_RUNTIME}';
|
|
768
|
+
render({ config, routes, navigation, openApis, bannerComponent, footerComponent, themeEditor: ${JSON.stringify(options.themeEditor ?? false)} });`;
|
|
894
769
|
}
|
|
895
770
|
function buildVirtualModules(args) {
|
|
896
771
|
const modules = /* @__PURE__ */ new Map();
|
|
897
772
|
const clientEntryModule = createClientEntryModule({ themeEditor: args.themeEditor });
|
|
773
|
+
const bannerComponent = args.projectConfig.banner;
|
|
774
|
+
const bannerComponentSource = typeof bannerComponent === "string" ? "path" : void 0;
|
|
775
|
+
const bannerComponentImport = typeof bannerComponent === "string" ? bannerComponent : void 0;
|
|
898
776
|
const footerComponent = args.projectConfig.footer;
|
|
899
777
|
const footerComponentSource = typeof footerComponent === "string" ? "path" : void 0;
|
|
900
778
|
const footerComponentImport = typeof footerComponent === "string" ? footerComponent : void 0;
|
|
@@ -902,8 +780,12 @@ function buildVirtualModules(args) {
|
|
|
902
780
|
modules.set(VIRTUAL_ROUTES, generateRoutesModule(args.routes, args.navigation, args.projectConfig, "client"));
|
|
903
781
|
modules.set(VIRTUAL_SERVER_ROUTES, generateRoutesModule(args.routes, args.navigation, args.projectConfig, "server"));
|
|
904
782
|
modules.set(VIRTUAL_RUNTIME, createRuntimeModule({
|
|
783
|
+
bannerComponentSource,
|
|
905
784
|
footerComponentSource,
|
|
906
|
-
imports: {
|
|
785
|
+
imports: {
|
|
786
|
+
bannerComponent: bannerComponentImport,
|
|
787
|
+
footerComponent: footerComponentImport
|
|
788
|
+
}
|
|
907
789
|
}));
|
|
908
790
|
modules.set(VIRTUAL_CLIENT_ENTRY, clientEntryModule);
|
|
909
791
|
modules.set(RESOLVED_CLIENT_ENTRY, clientEntryModule);
|
|
@@ -1379,10 +1261,12 @@ var clarifyNavbarLinkSchema = z.object({
|
|
|
1379
1261
|
href: z.string(),
|
|
1380
1262
|
external: z.boolean().optional()
|
|
1381
1263
|
});
|
|
1382
|
-
var
|
|
1264
|
+
var clarifyBannerConfigOptionsSchema = z.object({
|
|
1383
1265
|
content: clarifyLocalizedTextSchema,
|
|
1384
|
-
dismissible: z.boolean().optional()
|
|
1385
|
-
|
|
1266
|
+
dismissible: z.boolean().optional(),
|
|
1267
|
+
link: clarifyNavbarLinkSchema.optional()
|
|
1268
|
+
}).strict();
|
|
1269
|
+
var clarifyBannerConfigSchema = z.union([clarifyBannerConfigOptionsSchema, z.string()]);
|
|
1386
1270
|
var clarifyFooterLinksConfigSchema = z.object({
|
|
1387
1271
|
links: z.array(clarifyNavbarLinkSchema).optional(),
|
|
1388
1272
|
socials: z.record(z.string(), z.string()).optional(),
|
|
@@ -1462,6 +1346,7 @@ var clarifyProjectConfigSchema = z.object({
|
|
|
1462
1346
|
siteUrl: z.string().optional(),
|
|
1463
1347
|
source: clarifySourceConfigSchema.optional(),
|
|
1464
1348
|
logo: clarifyLogoConfigSchema.optional(),
|
|
1349
|
+
homeUrl: z.string().optional(),
|
|
1465
1350
|
favicon: clarifyFaviconConfigSchema.optional(),
|
|
1466
1351
|
theme: clarifyThemeConfigSchema.optional(),
|
|
1467
1352
|
routePrefix: z.string().optional(),
|
|
@@ -1472,6 +1357,30 @@ var clarifyProjectConfigSchema = z.object({
|
|
|
1472
1357
|
tabs: clarifyTabsConfigSchema.optional()
|
|
1473
1358
|
});
|
|
1474
1359
|
//#endregion
|
|
1360
|
+
//#region source/core/theme.ts
|
|
1361
|
+
function resolveThemeConfig(theme = {}) {
|
|
1362
|
+
const preset = theme.preset ?? "default";
|
|
1363
|
+
const presetTheme = themePresets[preset];
|
|
1364
|
+
return {
|
|
1365
|
+
preset,
|
|
1366
|
+
tokens: {
|
|
1367
|
+
colors: {
|
|
1368
|
+
...presetTheme.tokens.colors,
|
|
1369
|
+
...theme.tokens?.colors
|
|
1370
|
+
},
|
|
1371
|
+
radius: {
|
|
1372
|
+
...presetTheme.tokens.radius,
|
|
1373
|
+
...theme.tokens?.radius
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
layout: {
|
|
1377
|
+
...presetTheme.layout,
|
|
1378
|
+
...theme.layout
|
|
1379
|
+
},
|
|
1380
|
+
editor: theme.editor ?? presetTheme.editor
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
//#endregion
|
|
1475
1384
|
//#region source/core/config.ts
|
|
1476
1385
|
function formatIssuePath(path) {
|
|
1477
1386
|
return path.reduce((result, segment) => {
|
|
@@ -1510,6 +1419,7 @@ function resolveProjectConfig(config = {}) {
|
|
|
1510
1419
|
siteUrl: config.siteUrl,
|
|
1511
1420
|
source: config.source,
|
|
1512
1421
|
logo: config.logo,
|
|
1422
|
+
homeUrl: config.homeUrl,
|
|
1513
1423
|
favicon: config.favicon,
|
|
1514
1424
|
routePrefix: config.routePrefix ?? "/",
|
|
1515
1425
|
theme: resolveThemeConfig(config.theme),
|
|
@@ -1765,10 +1675,10 @@ function routeOutputFiles(outputDirectory, route) {
|
|
|
1765
1675
|
var SSR_ENTRY_CODE = `import { renderToHTML } from '@clarify-labs/renderer/server';
|
|
1766
1676
|
import { routes, navigation } from 'virtual:clarify-routes/server';
|
|
1767
1677
|
import { config } from 'virtual:clarify-config';
|
|
1768
|
-
import { openApis, footerComponent } from 'virtual:clarify-runtime';
|
|
1678
|
+
import { openApis, bannerComponent, footerComponent } from 'virtual:clarify-runtime';
|
|
1769
1679
|
|
|
1770
1680
|
export function render(url) {
|
|
1771
|
-
return renderToHTML({ config, routes, navigation, openApis, footerComponent, url, themeEditor: config.theme.editor });
|
|
1681
|
+
return renderToHTML({ config, routes, navigation, openApis, bannerComponent, footerComponent, url, themeEditor: config.theme.editor });
|
|
1772
1682
|
}`;
|
|
1773
1683
|
function createTempEntryFile(content) {
|
|
1774
1684
|
const entryPath = join(createClarifyTempDir("ssr"), "entry-server.ts");
|
|
@@ -2064,4 +1974,4 @@ function clarifyPlugin(options = {}) {
|
|
|
2064
1974
|
//#endregion
|
|
2065
1975
|
export { resolveClarifySite as a, createClarifyRuntimeAliases as i, defineConfig as n, createClarifyTempDir as o, loadClarifyConfig as r, clarifyPlugin as t };
|
|
2066
1976
|
|
|
2067
|
-
//# sourceMappingURL=plugin-
|
|
1977
|
+
//# sourceMappingURL=plugin-o1rP_gts.js.map
|