@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.
@@ -261,80 +261,7 @@ function createContentArtifactsPlugin() {
261
261
  };
262
262
  }
263
263
  //#endregion
264
- //#region source/core/theme.ts
265
- var clarifyThemePresets = {
266
- default: {
267
- preset: "default",
268
- tokens: {
269
- colors: {
270
- primary: "#047857",
271
- accent: "#0D9488",
272
- background: "#ffffff",
273
- foreground: "#111827",
274
- surface: "#ffffff",
275
- muted: "#64748b",
276
- border: "rgb(15 23 42 / 0.12)",
277
- codeBackground: "#f6fbf8"
278
- },
279
- radius: {
280
- sm: "6px",
281
- md: "10px",
282
- lg: "14px",
283
- xl: "18px"
284
- }
285
- },
286
- layout: { maxWidth: "82rem" },
287
- editor: false
288
- },
289
- base: {
290
- preset: "base",
291
- tokens: {
292
- colors: {
293
- primary: "#18181b",
294
- accent: "#52525b",
295
- background: "#ffffff",
296
- foreground: "#18181b",
297
- surface: "#ffffff",
298
- muted: "#71717a",
299
- border: "rgb(24 24 27 / 0.12)",
300
- codeBackground: "#f4f4f5"
301
- },
302
- radius: {
303
- sm: "6px",
304
- md: "8px",
305
- lg: "12px",
306
- xl: "16px"
307
- }
308
- },
309
- layout: { maxWidth: "80rem" },
310
- editor: false
311
- }
312
- };
313
- function resolveThemeConfig(theme = {}) {
314
- const preset = theme.preset ?? "default";
315
- const presetTheme = clarifyThemePresets[preset];
316
- return {
317
- preset,
318
- tokens: {
319
- colors: {
320
- ...presetTheme.tokens.colors,
321
- ...theme.tokens?.colors
322
- },
323
- radius: {
324
- ...presetTheme.tokens.radius,
325
- ...theme.tokens?.radius
326
- }
327
- },
328
- layout: {
329
- ...presetTheme.layout,
330
- ...theme.layout
331
- },
332
- editor: theme.editor ?? presetTheme.editor
333
- };
334
- }
335
- //#endregion
336
264
  //#region source/plugins/html-shell/index.ts
337
- var THEME_STORAGE_KEY = "clarify:theme";
338
265
  var REL_ICON_RE = /<link\s+[^>]*rel=["'][^"']*\bicon\b[^"']*["'][^>]*>/i;
339
266
  function inferIconType(href) {
340
267
  const path = href.split(/[?#]/, 1)[0]?.toLowerCase() ?? href.toLowerCase();
@@ -364,62 +291,6 @@ function createIconTags(icon) {
364
291
  if (lightIcon === darkIcon) return [createIconTag(lightIcon)];
365
292
  return [createIconTag(lightIcon, "(prefers-color-scheme: light)"), createIconTag(darkIcon, "(prefers-color-scheme: dark)")];
366
293
  }
367
- function matchesPresetTheme(theme) {
368
- const preset = clarifyThemePresets[theme.preset];
369
- return JSON.stringify({
370
- tokens: theme.tokens,
371
- layout: theme.layout
372
- }) === JSON.stringify({
373
- tokens: preset.tokens,
374
- layout: preset.layout
375
- });
376
- }
377
- function effectiveTheme(theme, resolvedTheme) {
378
- if (resolvedTheme !== "dark" || !matchesPresetTheme(theme)) return theme;
379
- return {
380
- ...theme,
381
- tokens: {
382
- ...theme.tokens,
383
- colors: {
384
- ...theme.tokens.colors,
385
- background: "#09090b",
386
- foreground: "#ffffff",
387
- surface: "#18181b",
388
- muted: "#a1a1aa",
389
- border: "rgb(255 255 255 / 0.1)",
390
- codeBackground: "#18181b"
391
- }
392
- }
393
- };
394
- }
395
- function resolveThemeColorValue(value, resolvedTheme) {
396
- return typeof value === "string" ? value : value[resolvedTheme] ?? value.light ?? value.dark ?? "";
397
- }
398
- function themeToCssVariables(theme, resolvedTheme) {
399
- const resolved = effectiveTheme(theme, resolvedTheme);
400
- const { colors } = resolved.tokens;
401
- const { radius } = resolved.tokens;
402
- return {
403
- "--clarify-theme-tokens-colors-primary": resolveThemeColorValue(colors.primary, resolvedTheme),
404
- "--clarify-theme-tokens-colors-accent": resolveThemeColorValue(colors.accent, resolvedTheme),
405
- "--clarify-theme-tokens-colors-background": resolveThemeColorValue(colors.background, resolvedTheme),
406
- "--clarify-theme-tokens-colors-foreground": resolveThemeColorValue(colors.foreground, resolvedTheme),
407
- "--clarify-theme-tokens-colors-surface": resolveThemeColorValue(colors.surface, resolvedTheme),
408
- "--clarify-theme-tokens-colors-muted": resolveThemeColorValue(colors.muted, resolvedTheme),
409
- "--clarify-theme-tokens-colors-border": resolveThemeColorValue(colors.border, resolvedTheme),
410
- "--clarify-theme-tokens-colors-code-background": resolveThemeColorValue(colors.codeBackground, resolvedTheme),
411
- "--clarify-theme-tokens-radius-sm": radius.sm,
412
- "--clarify-theme-tokens-radius-md": radius.md,
413
- "--clarify-theme-tokens-radius-lg": radius.lg,
414
- "--clarify-theme-tokens-radius-xl": radius.xl,
415
- "--clarify-theme-layout-max-width": resolved.layout.maxWidth
416
- };
417
- }
418
- function themeBootstrapScript(theme) {
419
- const darkVariables = themeToCssVariables(theme, "dark");
420
- const lightVariables = themeToCssVariables(theme, "light");
421
- 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){}})();`;
422
- }
423
294
  function createHtmlShellPlugin() {
424
295
  return {
425
296
  name: "clarify:html-shell",
@@ -430,7 +301,7 @@ function createHtmlShellPlugin() {
430
301
  ...REL_ICON_RE.test(input.html) ? [] : createIconTags(ctx.projectConfig.favicon ?? ctx.projectConfig.logo),
431
302
  {
432
303
  tag: "script",
433
- children: themeBootstrapScript(ctx.projectConfig.theme),
304
+ children: (0, _clarify_labs_renderer.themeBootstrapScript)(ctx.projectConfig.theme),
434
305
  injectTo: "head-prepend"
435
306
  },
436
307
  {
@@ -495,6 +366,7 @@ function navigationSections(sections) {
495
366
  return sections.map((s) => ({
496
367
  id: s.id,
497
368
  title: s.title,
369
+ level: s.level,
498
370
  badge: s.badge,
499
371
  tags: s.tags
500
372
  }));
@@ -889,6 +761,7 @@ function generateRoutesModule(routes, resolvedNavigation, projectConfig, mode =
889
761
  const sections = r.sections && r.sections.length > 0 ? `, sections: ${JSON.stringify(r.sections.map((s) => ({
890
762
  id: s.id,
891
763
  title: s.title,
764
+ level: s.level,
892
765
  badge: s.badge,
893
766
  tags: s.tags
894
767
  })))}` : "";
@@ -908,9 +781,11 @@ function generateRoutesModule(routes, resolvedNavigation, projectConfig, mode =
908
781
  return `${imports}\n\nexport const routes = [\n${routesArray}\n];\n\nexport const navigation = ${JSON.stringify(navigation, null, 2)};\n`;
909
782
  }
910
783
  function createRuntimeModule(options = {}) {
911
- return `${options.footerComponentSource === "path" && options.imports?.footerComponent ? `import FooterComponent from ${moduleSpecifier(options.imports.footerComponent)};` : ""}
912
- export const openApis = {};
784
+ 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");
785
+ const exports = `export const openApis = {};
786
+ export const bannerComponent = ${options.bannerComponentSource === "path" ? "BannerComponent" : "undefined"};
913
787
  export const footerComponent = ${options.footerComponentSource === "path" ? "FooterComponent" : "undefined"};`;
788
+ return imports ? `${imports}\n${exports}` : exports;
914
789
  }
915
790
  function createClientEntryModule(options = {}) {
916
791
  return `
@@ -918,12 +793,15 @@ import '@clarify-labs/renderer/style.css';
918
793
  import { render } from '@clarify-labs/renderer/client';
919
794
  import { routes, navigation } from '${VIRTUAL_ROUTES}';
920
795
  import { config } from '${VIRTUAL_CONFIG}';
921
- import { openApis, footerComponent } from '${VIRTUAL_RUNTIME}';
922
- render({ config, routes, navigation, openApis, footerComponent, themeEditor: ${JSON.stringify(options.themeEditor ?? false)} });`;
796
+ import { openApis, bannerComponent, footerComponent } from '${VIRTUAL_RUNTIME}';
797
+ render({ config, routes, navigation, openApis, bannerComponent, footerComponent, themeEditor: ${JSON.stringify(options.themeEditor ?? false)} });`;
923
798
  }
924
799
  function buildVirtualModules(args) {
925
800
  const modules = /* @__PURE__ */ new Map();
926
801
  const clientEntryModule = createClientEntryModule({ themeEditor: args.themeEditor });
802
+ const bannerComponent = args.projectConfig.banner;
803
+ const bannerComponentSource = typeof bannerComponent === "string" ? "path" : void 0;
804
+ const bannerComponentImport = typeof bannerComponent === "string" ? bannerComponent : void 0;
927
805
  const footerComponent = args.projectConfig.footer;
928
806
  const footerComponentSource = typeof footerComponent === "string" ? "path" : void 0;
929
807
  const footerComponentImport = typeof footerComponent === "string" ? footerComponent : void 0;
@@ -931,8 +809,12 @@ function buildVirtualModules(args) {
931
809
  modules.set(VIRTUAL_ROUTES, generateRoutesModule(args.routes, args.navigation, args.projectConfig, "client"));
932
810
  modules.set(VIRTUAL_SERVER_ROUTES, generateRoutesModule(args.routes, args.navigation, args.projectConfig, "server"));
933
811
  modules.set(VIRTUAL_RUNTIME, createRuntimeModule({
812
+ bannerComponentSource,
934
813
  footerComponentSource,
935
- imports: { footerComponent: footerComponentImport }
814
+ imports: {
815
+ bannerComponent: bannerComponentImport,
816
+ footerComponent: footerComponentImport
817
+ }
936
818
  }));
937
819
  modules.set(VIRTUAL_CLIENT_ENTRY, clientEntryModule);
938
820
  modules.set(RESOLVED_CLIENT_ENTRY, clientEntryModule);
@@ -1408,10 +1290,12 @@ var clarifyNavbarLinkSchema = zod.z.object({
1408
1290
  href: zod.z.string(),
1409
1291
  external: zod.z.boolean().optional()
1410
1292
  });
1411
- var clarifyBannerConfigSchema = zod.z.object({
1293
+ var clarifyBannerConfigOptionsSchema = zod.z.object({
1412
1294
  content: clarifyLocalizedTextSchema,
1413
- dismissible: zod.z.boolean().optional()
1414
- });
1295
+ dismissible: zod.z.boolean().optional(),
1296
+ link: clarifyNavbarLinkSchema.optional()
1297
+ }).strict();
1298
+ var clarifyBannerConfigSchema = zod.z.union([clarifyBannerConfigOptionsSchema, zod.z.string()]);
1415
1299
  var clarifyFooterLinksConfigSchema = zod.z.object({
1416
1300
  links: zod.z.array(clarifyNavbarLinkSchema).optional(),
1417
1301
  socials: zod.z.record(zod.z.string(), zod.z.string()).optional(),
@@ -1491,6 +1375,7 @@ var clarifyProjectConfigSchema = zod.z.object({
1491
1375
  siteUrl: zod.z.string().optional(),
1492
1376
  source: clarifySourceConfigSchema.optional(),
1493
1377
  logo: clarifyLogoConfigSchema.optional(),
1378
+ homeUrl: zod.z.string().optional(),
1494
1379
  favicon: clarifyFaviconConfigSchema.optional(),
1495
1380
  theme: clarifyThemeConfigSchema.optional(),
1496
1381
  routePrefix: zod.z.string().optional(),
@@ -1501,6 +1386,30 @@ var clarifyProjectConfigSchema = zod.z.object({
1501
1386
  tabs: clarifyTabsConfigSchema.optional()
1502
1387
  });
1503
1388
  //#endregion
1389
+ //#region source/core/theme.ts
1390
+ function resolveThemeConfig(theme = {}) {
1391
+ const preset = theme.preset ?? "default";
1392
+ const presetTheme = _clarify_labs_renderer.themePresets[preset];
1393
+ return {
1394
+ preset,
1395
+ tokens: {
1396
+ colors: {
1397
+ ...presetTheme.tokens.colors,
1398
+ ...theme.tokens?.colors
1399
+ },
1400
+ radius: {
1401
+ ...presetTheme.tokens.radius,
1402
+ ...theme.tokens?.radius
1403
+ }
1404
+ },
1405
+ layout: {
1406
+ ...presetTheme.layout,
1407
+ ...theme.layout
1408
+ },
1409
+ editor: theme.editor ?? presetTheme.editor
1410
+ };
1411
+ }
1412
+ //#endregion
1504
1413
  //#region source/core/config.ts
1505
1414
  function formatIssuePath(path) {
1506
1415
  return path.reduce((result, segment) => {
@@ -1539,6 +1448,7 @@ function resolveProjectConfig(config = {}) {
1539
1448
  siteUrl: config.siteUrl,
1540
1449
  source: config.source,
1541
1450
  logo: config.logo,
1451
+ homeUrl: config.homeUrl,
1542
1452
  favicon: config.favicon,
1543
1453
  routePrefix: config.routePrefix ?? "/",
1544
1454
  theme: resolveThemeConfig(config.theme),
@@ -1794,10 +1704,10 @@ function routeOutputFiles(outputDirectory, route) {
1794
1704
  var SSR_ENTRY_CODE = `import { renderToHTML } from '@clarify-labs/renderer/server';
1795
1705
  import { routes, navigation } from 'virtual:clarify-routes/server';
1796
1706
  import { config } from 'virtual:clarify-config';
1797
- import { openApis, footerComponent } from 'virtual:clarify-runtime';
1707
+ import { openApis, bannerComponent, footerComponent } from 'virtual:clarify-runtime';
1798
1708
 
1799
1709
  export function render(url) {
1800
- return renderToHTML({ config, routes, navigation, openApis, footerComponent, url, themeEditor: config.theme.editor });
1710
+ return renderToHTML({ config, routes, navigation, openApis, bannerComponent, footerComponent, url, themeEditor: config.theme.editor });
1801
1711
  }`;
1802
1712
  function createTempEntryFile(content) {
1803
1713
  const entryPath = (0, node_path.join)(createClarifyTempDir("ssr"), "entry-server.ts");
@@ -2128,4 +2038,4 @@ Object.defineProperty(exports, "resolveClarifySite", {
2128
2038
  }
2129
2039
  });
2130
2040
 
2131
- //# sourceMappingURL=plugin-dzXRzjdX.cjs.map
2041
+ //# sourceMappingURL=plugin-DFpkIm9j.cjs.map