@clarify-labs/cli 0.11.7 → 0.11.8
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 +1 -1
- package/output/cli.js +1 -1
- package/output/core/config/config-schema.d.ts +6 -0
- package/output/core/runtime/ssg.d.ts +1 -1
- package/output/core/runtime/virtual-modules.d.ts +2 -5
- package/output/{engine-Cc7Ve6o-.js → engine-B_0YOc2B.js} +38 -16
- package/output/engine-B_0YOc2B.js.map +1 -0
- package/output/{engine-BbQJ97Ed.cjs → engine-pubnVIwZ.cjs} +38 -16
- package/output/engine-pubnVIwZ.cjs.map +1 -0
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/types.d.ts +7 -0
- package/package.json +3 -3
- package/output/engine-BbQJ97Ed.cjs.map +0 -1
- package/output/engine-Cc7Ve6o-.js.map +0 -1
package/output/cli.cjs
CHANGED
package/output/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as createClarifyTempDir, c as cliPackageVersion, i as findRouteConflicts, l as cliPackageVersionWithCaret, n as createClarifyEngine, o as deserializeSearchIndex, r as createClarifyRuntimeAliases, s as searchMcpIndex, u as createViteAdapter } from "./engine-
|
|
2
|
+
import { a as createClarifyTempDir, c as cliPackageVersion, i as findRouteConflicts, l as cliPackageVersionWithCaret, n as createClarifyEngine, o as deserializeSearchIndex, r as createClarifyRuntimeAliases, s as searchMcpIndex, u as createViteAdapter } from "./engine-B_0YOc2B.js";
|
|
3
3
|
import { dirname, extname, isAbsolute, join, normalize, relative, resolve } from "node:path";
|
|
4
4
|
import { lstat, mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -119,6 +119,12 @@ export declare const clarifyProjectConfigSchema: z.ZodObject<{
|
|
|
119
119
|
maxWidth: z.ZodOptional<z.ZodString>;
|
|
120
120
|
}, z.core.$strict>>;
|
|
121
121
|
}, z.core.$strict>>;
|
|
122
|
+
layout: z.ZodOptional<z.ZodObject<{
|
|
123
|
+
tabs: z.ZodOptional<z.ZodEnum<{
|
|
124
|
+
subnav: "subnav";
|
|
125
|
+
navbar: "navbar";
|
|
126
|
+
}>>;
|
|
127
|
+
}, z.core.$strict>>;
|
|
122
128
|
navigation: z.ZodOptional<z.ZodObject<{
|
|
123
129
|
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
124
130
|
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
@@ -4,7 +4,7 @@ export { injectSSRIntoTemplate } from './html-template.js';
|
|
|
4
4
|
export declare function readIndexHtml(outputDirectory: string): string | undefined;
|
|
5
5
|
export declare function isNotFoundRoute(route: ContentRoute): boolean;
|
|
6
6
|
export declare function routeOutputFiles(outputDirectory: string, route: ContentRoute): string[];
|
|
7
|
-
export declare const SSR_ENTRY_CODE = "import { renderToHTML } from '@clarify-labs/renderer/server';\nimport { routes, navigation } from 'virtual:clarify/routes/server';\nimport { config } from 'virtual:clarify/config';\nimport { openApiSpecs } from 'virtual:clarify/openapi/server';\nimport { runtimeSlots } from 'virtual:clarify/slots';\n\nexport async function render(url) {\n // Pre-resolve every slot component factory so renderToString can use\n // them synchronously (renderToString has no Suspense support).\n const entries = Object.values(runtimeSlots).flat()\n await Promise.all(entries.map(async (entry) => {\n const mod = await entry.loadComponent()\n entry._resolved = mod.default\n }))\n return renderToHTML({ config, routes, navigation, openApiSpecs, runtimeSlots, url, themeEditor:
|
|
7
|
+
export declare const SSR_ENTRY_CODE = "import { renderToHTML } from '@clarify-labs/renderer/server';\nimport { routes, navigation } from 'virtual:clarify/routes/server';\nimport { config, runtime } from 'virtual:clarify/config';\nimport { openApiSpecs } from 'virtual:clarify/openapi/server';\nimport { runtimeSlots } from 'virtual:clarify/slots';\n\nexport async function render(url) {\n // Pre-resolve every slot component factory so renderToString can use\n // them synchronously (renderToString has no Suspense support).\n const entries = Object.values(runtimeSlots).flat()\n await Promise.all(entries.map(async (entry) => {\n const mod = await entry.loadComponent()\n entry._resolved = mod.default\n }))\n return renderToHTML({ config, routes, navigation, openApiSpecs, runtimeSlots, url, themeEditor: runtime.themeEditor });\n}";
|
|
8
8
|
export declare function createTempEntryFile(content: string): string;
|
|
9
9
|
export declare function buildSSRBundle(root: string, ssrEntry: string, ssrOutDir: string, plugins: Plugin[]): Promise<void>;
|
|
10
10
|
export declare function renderSSGRoutes(routes: ContentRoute[], contextOrConfig: ClarifyProjectContext | ResolvedProjectConfig, outputDirectory: string, ssrBundlePath: string): Promise<void>;
|
|
@@ -13,9 +13,6 @@ type BuildVirtualModulesArgs = {
|
|
|
13
13
|
navigation: NavigationTree;
|
|
14
14
|
themeEditor?: boolean;
|
|
15
15
|
};
|
|
16
|
-
type CreateClientEntryModuleOptions = {
|
|
17
|
-
themeEditor?: boolean;
|
|
18
|
-
};
|
|
19
16
|
export declare function resolveVirtualId(id: string): string;
|
|
20
17
|
export declare function stripVirtualPrefix(id: string): string;
|
|
21
18
|
export declare function virtualContentModuleId(route: MarkdownContentRoute): string;
|
|
@@ -28,9 +25,9 @@ export declare function virtualContentModuleId(route: MarkdownContentRoute): str
|
|
|
28
25
|
* if the ID is not a Clarify virtual module.
|
|
29
26
|
*/
|
|
30
27
|
export declare function resolveVirtualModuleId(id: string, modules: VirtualModules, routes: readonly ContentRoute[]): string | null;
|
|
31
|
-
export declare function generateConfigModule(projectConfig: ResolvedProjectConfig, version?: string): string;
|
|
28
|
+
export declare function generateConfigModule(projectConfig: ResolvedProjectConfig, version?: string, themeEditor?: boolean): string;
|
|
32
29
|
export declare function generateRoutesModule(routes: ContentRoute[], navigation: NavigationTree, mode?: 'client' | 'server'): string;
|
|
33
|
-
export declare function createClientEntryModule(
|
|
30
|
+
export declare function createClientEntryModule(): string;
|
|
34
31
|
/**
|
|
35
32
|
* Collect every plugin's `slots` declarations into a single runtime registry
|
|
36
33
|
* module. Component modules are exported as lazy import factories so the
|
|
@@ -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:
|
|
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(
|
|
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:
|
|
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(
|
|
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.
|
|
1683
|
+
version: "0.11.8",
|
|
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
|
-
|
|
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:
|
|
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-
|
|
4024
|
+
//# sourceMappingURL=engine-B_0YOc2B.js.map
|