@clarify-labs/cli 0.11.7 → 0.11.9

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.
@@ -983,6 +983,22 @@ var clarifyVariableValueSchema = z.lazy(() => z.union([
983
983
  z.record(z.string(), clarifyVariableValueSchema)
984
984
  ]));
985
985
  var clarifyVariablesConfigSchema = z.record(z.string(), clarifyVariableValueSchema);
986
+ var clarifySiteUrlSchema = z.string().superRefine((value, ctx) => {
987
+ let url;
988
+ try {
989
+ url = new URL(value);
990
+ } catch {
991
+ ctx.addIssue({
992
+ code: z.ZodIssueCode.custom,
993
+ message: "must be an absolute HTTP(S) origin"
994
+ });
995
+ return;
996
+ }
997
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.pathname !== "/" || url.search || url.hash) ctx.addIssue({
998
+ code: z.ZodIssueCode.custom,
999
+ message: "must be an HTTP(S) origin without a path, query, or hash; configure deployment subpaths with routePrefix"
1000
+ });
1001
+ });
986
1002
  var clarifyRepositoryConfigSchema = z.object({
987
1003
  url: z.string().optional(),
988
1004
  branch: z.string().optional(),
@@ -1050,6 +1066,7 @@ var clarifyThemeConfigSchema = z.object({
1050
1066
  tokens: clarifyThemeTokensConfigSchema.optional(),
1051
1067
  layout: clarifyThemeLayoutConfigSchema.optional()
1052
1068
  }).strict();
1069
+ var clarifyLayoutConfigSchema = z.object({ tabs: z.enum(["subnav", "navbar"]).optional() }).strict();
1053
1070
  function featureSchema(shape, defaults, enabledByDefault = true) {
1054
1071
  const resolvedDefaults = {
1055
1072
  enabled: enabledByDefault,
@@ -1073,13 +1090,14 @@ var clarifyFeaturesConfigSchema = z.object({
1073
1090
  var clarifyProjectConfigSchema = z.object({
1074
1091
  title: z.string().optional(),
1075
1092
  description: z.string().optional(),
1076
- siteUrl: z.string().optional(),
1093
+ siteUrl: clarifySiteUrlSchema.optional(),
1077
1094
  routePrefix: z.string().default("/"),
1078
1095
  assetPrefix: z.string().optional(),
1079
1096
  logo: clarifyLogoConfigSchema.optional(),
1080
1097
  homeUrl: z.string().optional(),
1081
1098
  favicon: clarifyFaviconConfigSchema.optional(),
1082
1099
  theme: clarifyThemeConfigSchema.optional(),
1100
+ layout: clarifyLayoutConfigSchema.optional(),
1083
1101
  navigation: z.object({
1084
1102
  links: z.array(clarifyNavbarLinkSchema).optional(),
1085
1103
  tabs: clarifyTabsConfigSchema.optional()
@@ -1151,6 +1169,7 @@ function resolveProjectConfig(config = {}) {
1151
1169
  homeUrl: config.homeUrl,
1152
1170
  favicon: config.favicon,
1153
1171
  theme: resolveThemeConfig(config.theme),
1172
+ layout: { tabs: config.layout?.tabs ?? "subnav" },
1154
1173
  navigation: config.navigation,
1155
1174
  banner: config.banner,
1156
1175
  footer: config.footer,
@@ -1295,7 +1314,7 @@ function resolveVirtualModuleId(id, modules, routes) {
1295
1314
  if (route) return resolveVirtualId(route.module.pageVirtualModuleId);
1296
1315
  return null;
1297
1316
  }
1298
- function generateConfigModule(projectConfig, version) {
1317
+ function generateConfigModule(projectConfig, version, themeEditor = false) {
1299
1318
  const runtimeConfig = {
1300
1319
  title: projectConfig.title,
1301
1320
  description: projectConfig.description,
@@ -1306,6 +1325,7 @@ function generateConfigModule(projectConfig, version) {
1306
1325
  homeUrl: projectConfig.homeUrl,
1307
1326
  favicon: projectConfig.favicon,
1308
1327
  theme: projectConfig.theme,
1328
+ layout: projectConfig.layout,
1309
1329
  navigation: projectConfig.navigation,
1310
1330
  banner: projectConfig.banner,
1311
1331
  footer: projectConfig.footer,
@@ -1314,7 +1334,7 @@ function generateConfigModule(projectConfig, version) {
1314
1334
  features: projectConfig.features
1315
1335
  };
1316
1336
  if (version) runtimeConfig.version = version;
1317
- return `export const config = ${JSON.stringify(runtimeConfig)};`;
1337
+ return `export const config = ${JSON.stringify(runtimeConfig)};\nexport const runtime = ${JSON.stringify({ themeEditor })};`;
1318
1338
  }
1319
1339
  function moduleSpecifier(value) {
1320
1340
  return JSON.stringify(value);
@@ -1353,15 +1373,15 @@ function generateRoutesModule(routes, navigation, mode = "client") {
1353
1373
  return ` ${JSON.stringify(manifestEntry, null, 0).replace(`"${placeholder}"`, component).replace(/"([A-Za-z_$][\w$]*)":/g, "$1: ")}`;
1354
1374
  }).join(",\n")}\n];\n\nexport const navigation = ${JSON.stringify(navigation, null, 2)};\n`;
1355
1375
  }
1356
- function createClientEntryModule(options = {}) {
1376
+ function createClientEntryModule() {
1357
1377
  return `
1358
1378
  import '@clarify-labs/renderer/style.css';
1359
1379
  import { render } from '@clarify-labs/renderer/client';
1360
1380
  import { routes, navigation } from '${VIRTUAL_ROUTES}';
1361
- import { config } from '${VIRTUAL_CONFIG}';
1381
+ import { config, runtime } from '${VIRTUAL_CONFIG}';
1362
1382
  import { openApiSpecs } from '${VIRTUAL_OPENAPI}';
1363
1383
  import { runtimeSlots } from '${VIRTUAL_SLOTS}';
1364
- const renderOptions = { config, routes, navigation, openApiSpecs, runtimeSlots, themeEditor: ${JSON.stringify(options.themeEditor ?? false)} };
1384
+ const renderOptions = { config, routes, navigation, openApiSpecs, runtimeSlots, themeEditor: runtime.themeEditor };
1365
1385
  render(renderOptions);
1366
1386
  if (import.meta.hot) {
1367
1387
  import.meta.hot.accept('${VIRTUAL_ROUTES}', (mod) => {
@@ -1413,9 +1433,9 @@ export default createContentDiagnosticComponent(contentDiagnostic);
1413
1433
  }
1414
1434
  function buildVirtualModules(args) {
1415
1435
  const modules = /* @__PURE__ */ new Map();
1416
- const clientEntryModule = createClientEntryModule({ themeEditor: args.themeEditor });
1436
+ const clientEntryModule = createClientEntryModule();
1417
1437
  const allPlugins = [...args.plugins ?? []];
1418
- modules.set(VIRTUAL_CONFIG, generateConfigModule(args.projectConfig, args.version));
1438
+ modules.set(VIRTUAL_CONFIG, generateConfigModule(args.projectConfig, args.version, args.themeEditor));
1419
1439
  modules.set(VIRTUAL_ROUTES, generateRoutesModule(args.routes, args.navigation, "client"));
1420
1440
  modules.set(VIRTUAL_SERVER_ROUTES, generateRoutesModule(args.routes, args.navigation, "server"));
1421
1441
  modules.set(VIRTUAL_SLOTS, createRuntimeSlotsModule(allPlugins, args.generateOptions.projectRoot));
@@ -1660,7 +1680,7 @@ function createViteAdapter(engine) {
1660
1680
  }
1661
1681
  var cliPackageVersion = {
1662
1682
  name: "@clarify-labs/cli",
1663
- version: "0.11.7",
1683
+ version: "0.11.9",
1664
1684
  license: "AGPL-3.0-only",
1665
1685
  type: "module",
1666
1686
  repository: {
@@ -1868,7 +1888,8 @@ function normalizeRoutePrefix$1(routePrefix) {
1868
1888
  function resolveContentArtifactPath(url, projectConfig) {
1869
1889
  const requestPath = url?.split("?")[0] ?? "";
1870
1890
  const basePath = normalizeRoutePrefix$1(projectConfig.routePrefix);
1871
- return basePath && requestPath.startsWith(basePath) ? requestPath.slice(basePath.length) || "/" : requestPath;
1891
+ const hasBasePath = requestPath === basePath || requestPath.startsWith(`${basePath}/`);
1892
+ return basePath && hasBasePath ? requestPath.slice(basePath.length) || "/" : requestPath;
1872
1893
  }
1873
1894
  function resolveContentArtifactType(route) {
1874
1895
  return route.kind === "openapi" ? "application/json; charset=utf-8" : "text/markdown; charset=utf-8";
@@ -2768,15 +2789,16 @@ function createOpenAPIPlugin() {
2768
2789
  return {
2769
2790
  name: "clarify:openapi",
2770
2791
  hooks: {
2771
- "routes:discover": (input, ctx) => ({
2792
+ "routes:discover": (input, ctx) => ctx.projectConfig.features.openapi.enabled ? {
2772
2793
  ...input,
2773
2794
  routes: [...input.routes, ...discoverOpenAPIRoutes(input.contentRoot, ctx.projectConfig.locales)]
2774
- }),
2795
+ } : input,
2775
2796
  "routes:discovered": async (routes, ctx) => {
2797
+ if (!ctx.projectConfig.features.openapi.enabled) return state.enrichRoutes(routes.filter((route) => route.kind !== "openapi"), ctx);
2776
2798
  const expandedRoutes = expandConfiguredOpenAPIRoutes(routes, ctx.projectConfig);
2777
2799
  return state.enrichRoutes(expandedRoutes, ctx);
2778
2800
  },
2779
- "modules:before": (modules, ctx) => state.contributeModules(modules, ctx.routes)
2801
+ "modules:before": (modules, ctx) => state.contributeModules(modules, ctx.projectConfig.features.openapi.enabled ? ctx.routes : ctx.routes.filter((route) => route.kind !== "openapi"))
2780
2802
  }
2781
2803
  };
2782
2804
  }
@@ -3538,7 +3560,7 @@ function routeOutputFiles(outputDirectory, route) {
3538
3560
  }
3539
3561
  var SSR_ENTRY_CODE = `import { renderToHTML } from '@clarify-labs/renderer/server';
3540
3562
  import { routes, navigation } from 'virtual:clarify/routes/server';
3541
- import { config } from 'virtual:clarify/config';
3563
+ import { config, runtime } from 'virtual:clarify/config';
3542
3564
  import { openApiSpecs } from 'virtual:clarify/openapi/server';
3543
3565
  import { runtimeSlots } from 'virtual:clarify/slots';
3544
3566
 
@@ -3550,7 +3572,7 @@ export async function render(url) {
3550
3572
  const mod = await entry.loadComponent()
3551
3573
  entry._resolved = mod.default
3552
3574
  }))
3553
- return renderToHTML({ config, routes, navigation, openApiSpecs, runtimeSlots, url, themeEditor: config.theme.editor });
3575
+ return renderToHTML({ config, routes, navigation, openApiSpecs, runtimeSlots, url, themeEditor: runtime.themeEditor });
3554
3576
  }`;
3555
3577
  function createTempEntryFile(content) {
3556
3578
  const entryPath = join(createClarifyTempDir("ssr"), "entry-server.ts");
@@ -3999,4 +4021,4 @@ function createClarifyEngine(options = {}) {
3999
4021
  //#endregion
4000
4022
  export { createClarifyTempDir as a, cliPackageVersion as c, defineConfig as d, findRouteConflicts as i, cliPackageVersionWithCaret as l, createClarifyEngine as n, deserializeSearchIndex as o, createClarifyRuntimeAliases as r, searchMcpIndex as s, ClarifyEngine as t, createViteAdapter as u };
4001
4023
 
4002
- //# sourceMappingURL=engine-Cc7Ve6o-.js.map
4024
+ //# sourceMappingURL=engine-CdH3JL_y.js.map