@clarify-labs/cli 0.9.4 → 0.10.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/spawn.d.ts +1 -1
- package/output/cli.cjs +72 -62
- package/output/cli.cjs.map +1 -1
- package/output/cli.js +68 -58
- package/output/cli.js.map +1 -1
- package/output/core/adapters.d.ts +11 -0
- package/output/core/{config-schema.d.ts → config/config-schema.d.ts} +1 -10
- package/output/core/{config.d.ts → config/config.d.ts} +1 -1
- package/output/core/{options.d.ts → config/options.d.ts} +1 -1
- package/output/core/{user-config.d.ts → config/user-config.d.ts} +1 -1
- package/output/core/engine/context.d.ts +51 -0
- package/output/core/engine/engine.d.ts +68 -0
- package/output/core/engine/phases.d.ts +10 -0
- package/output/core/engine/types.d.ts +26 -0
- package/output/core/{builtin.d.ts → plugin/builtin.d.ts} +1 -1
- package/output/core/plugin/hooks.d.ts +7 -0
- package/output/core/plugin/manager.d.ts +9 -0
- package/output/core/{project-context.d.ts → project/project-context.d.ts} +7 -7
- package/output/core/{project-info.d.ts → project/project-info.d.ts} +1 -1
- package/output/core/{env-types.d.ts → runtime/env-types.d.ts} +1 -1
- package/output/core/runtime/html-template.d.ts +13 -0
- package/output/core/{ssg.d.ts → runtime/ssg.d.ts} +3 -3
- package/output/core/{virtual-modules.d.ts → runtime/virtual-modules.d.ts} +13 -11
- package/output/core/{vite-config.d.ts → runtime/vite-config.d.ts} +2 -1
- package/output/{plugin-Etn8ZfYN.cjs → engine-5bdNX2Oo.cjs} +2755 -2158
- package/output/engine-5bdNX2Oo.cjs.map +1 -0
- package/output/{plugin-Z3fYTMcb.js → engine-Ca_2MCj9.js} +2750 -2152
- package/output/engine-Ca_2MCj9.js.map +1 -0
- package/output/index.cjs +5 -3
- package/output/index.d.ts +7 -5
- package/output/index.js +2 -2
- package/output/parsers/content/content.d.ts +20 -0
- package/output/parsers/markdown/mdx.d.ts +37 -0
- package/output/{core → parsers/router}/dev-routes.d.ts +1 -1
- package/output/parsers/{routes.d.ts → routes/routes.d.ts} +3 -2
- package/output/parsers/routes/routes.test-utils.d.ts +20 -0
- package/output/plugins/openapi/parser.d.ts +2 -1
- package/output/plugins/openapi/virtual-modules.d.ts +4 -3
- package/output/plugins/source-links/source-links.d.ts +2 -2
- package/output/plugins/variables/index.d.ts +2 -1
- package/output/types.d.ts +138 -45
- package/package.json +11 -11
- package/output/core/content.d.ts +0 -5
- package/output/core/hooks.d.ts +0 -6
- package/output/core/plugin.d.ts +0 -3
- package/output/core/site.d.ts +0 -17
- package/output/parsers/content.d.ts +0 -11
- package/output/parsers/mdx.d.ts +0 -20
- package/output/parsers/routes.test-utils.d.ts +0 -3
- package/output/parsers/variables.d.ts +0 -2
- package/output/plugin-Etn8ZfYN.cjs.map +0 -1
- package/output/plugin-Z3fYTMcb.js.map +0 -1
- /package/output/core/{temp-dir.d.ts → project/temp-dir.d.ts} +0 -0
- /package/output/core/{log.d.ts → runtime/log.d.ts} +0 -0
- /package/output/core/{runtime-deps.d.ts → runtime/runtime-deps.d.ts} +0 -0
- /package/output/core/{startup.d.ts → runtime/startup.d.ts} +0 -0
- /package/output/parsers/{frontmatter.d.ts → markdown/frontmatter.d.ts} +0 -0
- /package/output/{core → parsers/markdown}/utils.d.ts +0 -0
- /package/output/{core → parsers}/theme.d.ts +0 -0
- /package/output/{core → plugins/search-index}/search-language.d.ts +0 -0
package/output/index.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
2
|
+
const require_engine = require("./engine-5bdNX2Oo.cjs");
|
|
3
|
+
exports.ClarifyEngine = require_engine.ClarifyEngine;
|
|
4
|
+
exports.createClarifyEngine = require_engine.createClarifyEngine;
|
|
5
|
+
exports.createViteAdapter = require_engine.createViteAdapter;
|
|
6
|
+
exports.defineConfig = require_engine.defineConfig;
|
package/output/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
1
|
+
export { createViteAdapter } from './core/adapters.js';
|
|
2
|
+
export { ClarifyEngine, createClarifyEngine } from './core/engine/engine.js';
|
|
3
|
+
export { defineConfig } from './core/config/user-config.js';
|
|
4
|
+
export type { ClarifyEngineRuntime, PrepareOptions } from './core/engine/engine.js';
|
|
5
|
+
export type { PhaseName, TapPhaseName, TapHook, InterceptHook, PipelineHook, CollectorHook } from './core/engine/phases.js';
|
|
4
6
|
export * from './types.js';
|
|
5
|
-
export type { ClarifyConfig } from './core/user-config.js';
|
|
6
|
-
export type { UISlotName,
|
|
7
|
+
export type { ClarifyConfig } from './core/config/user-config.js';
|
|
8
|
+
export type { UISlotName, UISlotContext, UISlotRegistration } from '@clarify-labs/renderer';
|
package/output/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { c as defineConfig, n as createClarifyEngine, s as createViteAdapter, t as ClarifyEngine } from "./engine-Ca_2MCj9.js";
|
|
2
|
+
export { ClarifyEngine, createClarifyEngine, createViteAdapter, defineConfig };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ClarifyContentKind, ClarifyContentTransformInput, ClarifyHookContext, ClarifyPlugin } from '../../types.js';
|
|
2
|
+
export type ProcessedMdxContent = {
|
|
3
|
+
frontmatter: Record<string, unknown>;
|
|
4
|
+
content: string;
|
|
5
|
+
};
|
|
6
|
+
export type ContentTransform = (input: ClarifyContentTransformInput) => Promise<ClarifyContentTransformInput> | ClarifyContentTransformInput;
|
|
7
|
+
export type ContentProcessor = {
|
|
8
|
+
processMdx(source: string, filePath?: string): Promise<ProcessedMdxContent>;
|
|
9
|
+
processText(source: string, kind: Exclude<ClarifyContentKind, 'mdx'>, filePath?: string): Promise<string>;
|
|
10
|
+
};
|
|
11
|
+
export declare function createContentProcessor(transform?: ContentTransform): ContentProcessor;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a ContentProcessor that forwards each piece of content through the
|
|
14
|
+
* `content:transform` pipeline hook before it is parsed.
|
|
15
|
+
*
|
|
16
|
+
* Plugins that need to read content (site-discovery, openapi) call this with
|
|
17
|
+
* the plugins list from their hook context. There is no global registry -
|
|
18
|
+
* each call produces an independent processor bound to the given plugins.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createProjectContentProcessor(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): ContentProcessor;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ContentDiagnostic } from '../../types.js';
|
|
2
|
+
type HastNode = {
|
|
3
|
+
type: string;
|
|
4
|
+
tagName?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
properties?: Record<string, unknown>;
|
|
7
|
+
children?: HastNode[];
|
|
8
|
+
};
|
|
9
|
+
export declare function rehypeParseCodeBlocks(): (tree: HastNode) => void;
|
|
10
|
+
export declare function rehypeShiki(): (tree: HastNode) => Promise<void>;
|
|
11
|
+
export declare function rehypeSlugSections(): (tree: HastNode) => void;
|
|
12
|
+
export declare const remarkPlugins: unknown[];
|
|
13
|
+
export declare const rehypePlugins: (typeof rehypeSlugSections)[];
|
|
14
|
+
/**
|
|
15
|
+
* Validate MDX content for diagnostics WITHOUT running the build-time rehype
|
|
16
|
+
* pipeline (Shiki highlighting, slug injection, code-block parsing).
|
|
17
|
+
*
|
|
18
|
+
* `rehypePlugins` includes `rehypeShiki`, which loads grammar/WASM assets and
|
|
19
|
+
* is expensive. The real highlighting happens at Vite build time via the
|
|
20
|
+
* `@mdx-js/rollup` plugin (see `createMdxPlugin` in `core/adapters.ts`), which
|
|
21
|
+
* runs the full remark + rehype pipeline. Re-running it here, during route
|
|
22
|
+
* discovery (Phase 3), would compile every `.mdx` file twice and invoke Shiki
|
|
23
|
+
* once per file per `engine.refresh()` — see ARCHITECTURE.md §2.2 which states
|
|
24
|
+
* "不应在 core 中执行代码高亮".
|
|
25
|
+
*
|
|
26
|
+
* The remark pipeline still runs (shared with the Vite plugin via
|
|
27
|
+
* `remarkPlugins`), so MDX/JSX syntax errors — the only class of error this
|
|
28
|
+
* diagnostic is meant to surface ahead of the Vite build — are caught. The
|
|
29
|
+
* output is discarded; only the thrown error is used.
|
|
30
|
+
*/
|
|
31
|
+
export declare function compileMdxContent(content: string, filePath?: string, projectRoot?: string): Promise<{
|
|
32
|
+
ok: true;
|
|
33
|
+
} | {
|
|
34
|
+
ok: false;
|
|
35
|
+
diagnostic: ContentDiagnostic;
|
|
36
|
+
}>;
|
|
37
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { ClarifyProjectContext, ContentRoute } from '
|
|
2
|
+
import { ClarifyProjectContext, ContentRoute } from '../../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Dev-only HTTP endpoint that exposes the in-memory route manifest so external
|
|
5
5
|
* tools (e.g. the VS Code extension) can resolve a content file path to its
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ContentRoute, ContentSection, ClarifyNavigationNode, ClarifyPagesConfig, ClarifyPagesGroup, ClarifyLocalizedText, ClarifyTabsConfig, LocalizedNavigation, LocalizedTabbedNavigation, ResolvedClarifyI18nConfig, TabbedNavigation } from '
|
|
2
|
-
import { ContentProcessor } from '
|
|
1
|
+
import { ContentRoute, ContentSection, ClarifyNavigationNode, ClarifyPagesConfig, ClarifyPagesGroup, ClarifyPagesItem, ClarifyRouteIntent, ClarifyLocalizedText, ClarifyTabsConfig, LocalizedNavigation, LocalizedTabbedNavigation, ResolvedClarifyI18nConfig, TabbedNavigation } from '../../types.js';
|
|
2
|
+
import { ContentProcessor } from '../content/content.js';
|
|
3
3
|
export type FindContentRoutesOptions = {
|
|
4
4
|
contentProcessor?: ContentProcessor;
|
|
5
5
|
};
|
|
@@ -18,6 +18,7 @@ export declare function findContentRoutes(dir: string, base?: string, options?:
|
|
|
18
18
|
export declare function withAlternates(route: ContentRoute, routes: ContentRoute[], i18n: ResolvedClarifyI18nConfig): ContentRoute;
|
|
19
19
|
export declare function findLocalizedContentRoutes(contentRoot: string, i18n?: ResolvedClarifyI18nConfig, options?: FindContentRoutesOptions): Promise<ContentRoute[]>;
|
|
20
20
|
export declare function buildNavigation(routes: ContentRoute[]): ClarifyNavigationNode[];
|
|
21
|
+
export declare function routeIntentFromPagesItem(item: ClarifyPagesItem): ClarifyRouteIntent;
|
|
21
22
|
export declare function applyConfiguredPageRoutePaths(routes: ContentRoute[], tabs?: ClarifyTabsConfig, i18n?: ResolvedClarifyI18nConfig): ContentRoute[];
|
|
22
23
|
export declare function buildNavigationFromTabsConfig(routes: ContentRoute[], tabs: ClarifyTabsConfig): TabbedNavigation;
|
|
23
24
|
export declare function buildNavigationFromConfig(routes: ContentRoute[], config: ClarifyPagesGroup[]): ClarifyNavigationNode[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ContentRoute, ResolvedClarifyI18nConfig } from '../../types.js';
|
|
2
|
+
type ContentRouteFixture = Partial<Omit<ContentRoute, 'kind' | 'meta' | 'module' | 'source'>> & {
|
|
3
|
+
kind?: ContentRoute['kind'];
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
keywords?: ContentRoute['meta']['keywords'];
|
|
7
|
+
sections?: ContentRoute['meta']['sections'];
|
|
8
|
+
filePath?: string;
|
|
9
|
+
frontmatter?: ContentRoute['source']['frontmatter'];
|
|
10
|
+
content?: string;
|
|
11
|
+
sourceEditUrl?: string;
|
|
12
|
+
virtualModuleId?: string;
|
|
13
|
+
meta?: Partial<ContentRoute['meta']>;
|
|
14
|
+
module?: Partial<ContentRoute['module']>;
|
|
15
|
+
source?: Partial<ContentRoute['source']>;
|
|
16
|
+
};
|
|
17
|
+
export declare function contentRoute(route?: ContentRouteFixture): ContentRoute;
|
|
18
|
+
export declare function mdxRoute(route?: ContentRouteFixture): ContentRoute;
|
|
19
|
+
export declare const testI18n: ResolvedClarifyI18nConfig;
|
|
20
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentProcessor } from '../../parsers/content.js';
|
|
1
|
+
import { ContentProcessor } from '../../parsers/content/content.js';
|
|
2
2
|
import { ContentDiagnostic, ContentRoute, ContentSection, OpenAPISpec } from '../../types.js';
|
|
3
3
|
export type OpenAPIParseResult = {
|
|
4
4
|
ok: true;
|
|
@@ -8,6 +8,7 @@ export type OpenAPIParseResult = {
|
|
|
8
8
|
diagnostic: ContentDiagnostic;
|
|
9
9
|
};
|
|
10
10
|
export declare function findOpenAPIRoutes(dir: string, base?: string): ContentRoute[];
|
|
11
|
+
export declare function normalizeOpenAPISpecSectionIds(spec: OpenAPISpec): OpenAPISpec;
|
|
11
12
|
/** Filter an OpenAPI spec to only include paths that have at least one operation matching the given tags. */
|
|
12
13
|
export declare function filterSpecByTags(spec: OpenAPISpec, tags: string[]): OpenAPISpec;
|
|
13
14
|
/** Extract endpoint operations from an OpenAPI spec as page sections. */
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ContentDiagnostic, OpenAPISpec } from '../../types.js';
|
|
2
2
|
export declare const openApiRegistryModuleId = "virtual:clarify/openapi";
|
|
3
|
+
export declare const openApiServerRegistryModuleId = "virtual:clarify/openapi/server";
|
|
3
4
|
export declare const OPENAPI_SPEC_PREFIX = "virtual:clarify/openapi-spec/";
|
|
4
5
|
export declare function specVirtualModuleId(specKey: string): string;
|
|
5
|
-
export declare function generateOpenAPIRegistryModule(
|
|
6
|
+
export declare function generateOpenAPIRegistryModule(openApiSpecs: Record<string, string>): string;
|
|
7
|
+
export declare function generateOpenAPIServerRegistryModule(openApiSpecs: Record<string, OpenAPISpec>): string;
|
|
6
8
|
/** Generate a virtual module that exports a single spec as default. */
|
|
7
9
|
export declare function generateOpenAPISpecModule(spec: OpenAPISpec): string;
|
|
8
10
|
type OpenAPIPageModuleOptions = {
|
|
9
|
-
|
|
10
|
-
tagFilter?: string[];
|
|
11
|
+
specModuleId: string;
|
|
11
12
|
};
|
|
12
13
|
export declare function generateOpenAPIPageModule(opts: OpenAPIPageModuleOptions): string;
|
|
13
14
|
export declare function generateOpenAPIErrorModule(diagnostic: ContentDiagnostic): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ClarifySourceConfig, ContentRoute } from '../../types.js';
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function createSourceEditUrl(filePath: string, contentRoot: string, source: ClarifySourceConfig): string;
|
|
3
|
+
export declare function attachSourceEditUrls(routes: ContentRoute[], contentRoot: string, source?: ClarifySourceConfig): void;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { ClarifyPlugin } from '../../types.js';
|
|
1
|
+
import { ClarifyVariablesConfig, ClarifyPlugin } from '../../types.js';
|
|
2
|
+
export declare function applyVariables(content: string, variables?: ClarifyVariablesConfig): string;
|
|
2
3
|
export declare function createVariablesPlugin(): ClarifyPlugin;
|
package/output/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
2
2
|
import { HtmlTagDescriptor, ViteDevServer } from 'vite';
|
|
3
3
|
import { UISlotRegistration } from '@clarify-labs/renderer';
|
|
4
|
-
import { ResolvedBuildOptions } from './core/options.js';
|
|
5
|
-
export type { ClarifyBuildOptions, ResolvedBuildOptions, } from './core/options.js';
|
|
4
|
+
import { ResolvedBuildOptions } from './core/config/options.js';
|
|
5
|
+
export type { ClarifyBuildOptions, ResolvedBuildOptions, } from './core/config/options.js';
|
|
6
6
|
export type OpenAPISpec = OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
7
7
|
export type ClarifyLogoConfig = string | {
|
|
8
8
|
light?: string;
|
|
@@ -148,6 +148,23 @@ export type ClarifyPagesGroup = {
|
|
|
148
148
|
};
|
|
149
149
|
/** Use the string "FileTree" to auto-generate pages from the file system. */
|
|
150
150
|
export type ClarifyPagesConfig = ClarifyPagesGroup[] | 'FileTree';
|
|
151
|
+
export type ClarifyPageRouteIntent = {
|
|
152
|
+
kind: 'page';
|
|
153
|
+
ref: string;
|
|
154
|
+
path?: string;
|
|
155
|
+
redirect?: string;
|
|
156
|
+
title?: ClarifyLocalizedText;
|
|
157
|
+
icon?: string;
|
|
158
|
+
};
|
|
159
|
+
export type ClarifyOpenAPIRouteIntent = {
|
|
160
|
+
kind: 'openapi';
|
|
161
|
+
ref: string;
|
|
162
|
+
path?: string;
|
|
163
|
+
tagFilter?: string[];
|
|
164
|
+
title?: ClarifyLocalizedText;
|
|
165
|
+
icon?: string;
|
|
166
|
+
};
|
|
167
|
+
export type ClarifyRouteIntent = ClarifyPageRouteIntent | ClarifyOpenAPIRouteIntent;
|
|
151
168
|
export type ClarifyTabItem = {
|
|
152
169
|
tab: ClarifyLocalizedText;
|
|
153
170
|
/** Icon name from lucide-react, e.g. "BookOpen". */
|
|
@@ -226,6 +243,35 @@ export type ContentDiagnostic = {
|
|
|
226
243
|
details?: string;
|
|
227
244
|
filePath?: string;
|
|
228
245
|
};
|
|
246
|
+
export type ContentRouteMeta = {
|
|
247
|
+
title: string;
|
|
248
|
+
description?: string;
|
|
249
|
+
keywords?: string[];
|
|
250
|
+
sections?: ContentSection[];
|
|
251
|
+
};
|
|
252
|
+
export type ContentRouteModule = {
|
|
253
|
+
virtualModuleId: string;
|
|
254
|
+
};
|
|
255
|
+
export type OpenAPIContentRouteState = {
|
|
256
|
+
/** Operation tag filter applied to this route. Undefined means all operations. */
|
|
257
|
+
tagFilter?: string[];
|
|
258
|
+
/** Deduplicated id derived from the source OpenAPI spec file path. */
|
|
259
|
+
sourceSpecId?: string;
|
|
260
|
+
/** Spec virtual module id fragment used by this route after route-level filtering. */
|
|
261
|
+
routeSpecModuleId?: string;
|
|
262
|
+
};
|
|
263
|
+
export type ContentRouteArtifacts = {
|
|
264
|
+
/** Public URL for the machine-readable content artifact served or emitted for this route. */
|
|
265
|
+
contentArtifactUrl?: string;
|
|
266
|
+
};
|
|
267
|
+
export type ContentRouteSource = {
|
|
268
|
+
filePath: string;
|
|
269
|
+
frontmatter?: Record<string, unknown>;
|
|
270
|
+
/** Normalized source content captured during route discovery. */
|
|
271
|
+
content?: string;
|
|
272
|
+
/** Public edit URL for this route's source file. */
|
|
273
|
+
sourceEditUrl?: string;
|
|
274
|
+
};
|
|
229
275
|
export type ContentRoute = {
|
|
230
276
|
path: string;
|
|
231
277
|
basePath?: string;
|
|
@@ -234,24 +280,14 @@ export type ContentRoute = {
|
|
|
234
280
|
/** Indicates this route is a bare alias for the default locale (e.g., /path instead of /locale/path). Should not be indexed. */
|
|
235
281
|
isBareAlias?: boolean;
|
|
236
282
|
alternates?: Record<string, string>;
|
|
237
|
-
title: string;
|
|
238
|
-
description?: string;
|
|
239
|
-
keywords?: string[];
|
|
240
|
-
filePath: string;
|
|
241
|
-
virtualModuleId: string;
|
|
242
283
|
kind: string;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
frontmatter?: Record<string, unknown>;
|
|
249
|
-
/** Normalized source content captured during route discovery. */
|
|
250
|
-
content?: string;
|
|
284
|
+
meta: ContentRouteMeta;
|
|
285
|
+
module: ContentRouteModule;
|
|
286
|
+
source: ContentRouteSource;
|
|
287
|
+
/** OpenAPI-specific route state. Present only for OpenAPI routes. */
|
|
288
|
+
openapi?: OpenAPIContentRouteState;
|
|
251
289
|
diagnostic?: ContentDiagnostic;
|
|
252
|
-
|
|
253
|
-
contentArtifactUrl?: string;
|
|
254
|
-
sourceUrl?: string;
|
|
290
|
+
artifacts?: ContentRouteArtifacts;
|
|
255
291
|
};
|
|
256
292
|
export type ClarifyNavigationTab = {
|
|
257
293
|
type: 'tab';
|
|
@@ -260,36 +296,64 @@ export type ClarifyNavigationTab = {
|
|
|
260
296
|
icon?: string;
|
|
261
297
|
children: ClarifyNavigationNode[];
|
|
262
298
|
};
|
|
299
|
+
export type FlatNavigationTree = {
|
|
300
|
+
kind: 'flat';
|
|
301
|
+
nodes: ClarifyNavigationNode[];
|
|
302
|
+
};
|
|
263
303
|
export type TabbedNavigation = {
|
|
304
|
+
kind: 'tabbed';
|
|
264
305
|
tabs: ClarifyNavigationTab[];
|
|
265
306
|
};
|
|
266
|
-
export type LocalizedNavigation =
|
|
267
|
-
|
|
268
|
-
|
|
307
|
+
export type LocalizedNavigation = {
|
|
308
|
+
kind: 'localized';
|
|
309
|
+
locales: Record<string, ClarifyNavigationNode[]>;
|
|
310
|
+
};
|
|
311
|
+
export type LocalizedTabbedNavigation = {
|
|
312
|
+
kind: 'localized-tabbed';
|
|
313
|
+
locales: Record<string, Omit<TabbedNavigation, 'kind'>>;
|
|
314
|
+
};
|
|
315
|
+
export type NavigationTree = FlatNavigationTree | LocalizedNavigation | TabbedNavigation | LocalizedTabbedNavigation;
|
|
269
316
|
export type ClarifyPage = {
|
|
270
317
|
path: string;
|
|
271
318
|
filePath: string;
|
|
272
319
|
frontmatter: Record<string, unknown>;
|
|
273
320
|
content: string;
|
|
274
321
|
};
|
|
322
|
+
export type NavigationSection = {
|
|
323
|
+
id: string;
|
|
324
|
+
title: string;
|
|
325
|
+
level?: number;
|
|
326
|
+
badge?: string;
|
|
327
|
+
tags?: string[];
|
|
328
|
+
};
|
|
275
329
|
export type ClarifyNavigationNode = {
|
|
276
330
|
path: string;
|
|
277
331
|
title: string;
|
|
278
332
|
icon?: string;
|
|
279
333
|
children?: ClarifyNavigationNode[];
|
|
280
|
-
sections?:
|
|
334
|
+
sections?: NavigationSection[];
|
|
281
335
|
};
|
|
282
336
|
export type ClarifyProjectContext = {
|
|
337
|
+
version: string;
|
|
283
338
|
projectRoot: string;
|
|
284
339
|
contentRoot: string;
|
|
285
340
|
projectConfig: ResolvedProjectConfig;
|
|
286
341
|
generateOptions: ResolvedBuildOptions;
|
|
287
|
-
version: string;
|
|
288
342
|
};
|
|
289
|
-
export type
|
|
343
|
+
export type ClarifyRouteState = {
|
|
290
344
|
routes: ContentRoute[];
|
|
291
345
|
navigation: NavigationTree;
|
|
292
346
|
};
|
|
347
|
+
export type ClarifyPluginState = {
|
|
348
|
+
plugins: ClarifyPlugin[];
|
|
349
|
+
};
|
|
350
|
+
export type ClarifyPluginStore = {
|
|
351
|
+
get<T>(key: string): T | undefined;
|
|
352
|
+
set<T>(key: string, value: T): void;
|
|
353
|
+
has(key: string): boolean;
|
|
354
|
+
delete(key: string): boolean;
|
|
355
|
+
};
|
|
356
|
+
export type ClarifyHookContext = ClarifyProjectContext & ClarifyRouteState & ClarifyPluginState & ClarifyPluginStore;
|
|
293
357
|
export type ClarifyRouteDiscoveryInput = {
|
|
294
358
|
contentRoot: string;
|
|
295
359
|
locale?: string;
|
|
@@ -315,30 +379,59 @@ export type ClarifyEmitAsset = {
|
|
|
315
379
|
/** Asset content as a UTF-8 string or raw bytes. */
|
|
316
380
|
source: string | Uint8Array;
|
|
317
381
|
};
|
|
318
|
-
export type
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
navigation: NavigationTree;
|
|
327
|
-
}, ctx: ClarifyHookContext) => Promise<{
|
|
328
|
-
routes: ContentRoute[];
|
|
329
|
-
navigation: NavigationTree;
|
|
330
|
-
}> | {
|
|
331
|
-
routes: ContentRoute[];
|
|
332
|
-
navigation: NavigationTree;
|
|
333
|
-
};
|
|
334
|
-
'modules:before'?: (modules: Map<string, string>, ctx: ClarifyHookContext) => Promise<Map<string, string>> | Map<string, string>;
|
|
335
|
-
'html:transform'?: (input: ClarifyHtmlTransformInput, ctx: ClarifyHookContext) => Promise<ClarifyHtmlTransformInput> | ClarifyHtmlTransformInput;
|
|
336
|
-
'dev:configureServer'?: (server: ViteDevServer, ctx: ClarifyHookContext) => Promise<void> | void;
|
|
337
|
-
'build:assets'?: (ctx: ClarifyHookContext) => Promise<ClarifyEmitAsset[]> | ClarifyEmitAsset[];
|
|
338
|
-
'build:done'?: (ctx: ClarifyHookContext) => Promise<void> | void;
|
|
382
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
383
|
+
export type ClarifyTapHook = (ctx: ClarifyHookContext) => MaybePromise<void>;
|
|
384
|
+
export type ClarifyInterceptHook = (ctx: ClarifyHookContext) => MaybePromise<boolean>;
|
|
385
|
+
export type ClarifyPipelineHook<Input> = (input: Input, ctx: ClarifyHookContext) => MaybePromise<Input>;
|
|
386
|
+
export type ClarifyCollectorHook<Result> = (ctx: ClarifyHookContext) => MaybePromise<Result[]>;
|
|
387
|
+
export type ClarifyRoutesResolvedInput = {
|
|
388
|
+
routes: ContentRoute[];
|
|
389
|
+
navigation: NavigationTree;
|
|
339
390
|
};
|
|
391
|
+
export type ClarifyLifecycleHooks = {
|
|
392
|
+
'before:config:load'?: ClarifyTapHook;
|
|
393
|
+
'after:config:load'?: ClarifyTapHook;
|
|
394
|
+
'before:config:resolve'?: ClarifyTapHook;
|
|
395
|
+
'after:config:resolve'?: ClarifyTapHook;
|
|
396
|
+
'before:plugins:load'?: ClarifyTapHook;
|
|
397
|
+
'after:plugins:load'?: ClarifyTapHook;
|
|
398
|
+
'before:site:discover'?: ClarifyTapHook;
|
|
399
|
+
'after:site:discover'?: ClarifyTapHook;
|
|
400
|
+
'before:content:process'?: ClarifyTapHook;
|
|
401
|
+
'after:content:process'?: ClarifyTapHook;
|
|
402
|
+
'before:modules:build'?: ClarifyTapHook;
|
|
403
|
+
'after:modules:build'?: ClarifyTapHook;
|
|
404
|
+
'before:build'?: ClarifyTapHook;
|
|
405
|
+
'after:build'?: ClarifyTapHook;
|
|
406
|
+
'before:ssg'?: ClarifyTapHook;
|
|
407
|
+
'after:ssg'?: ClarifyTapHook;
|
|
408
|
+
'before:dev:server'?: ClarifyTapHook;
|
|
409
|
+
'after:dev:server'?: ClarifyTapHook;
|
|
410
|
+
};
|
|
411
|
+
export type ClarifyPipelineHooks = {
|
|
412
|
+
'content:transform'?: ClarifyPipelineHook<ClarifyContentTransformInput>;
|
|
413
|
+
'pages:resolved'?: ClarifyPipelineHook<ClarifyPage[]>;
|
|
414
|
+
'routes:discover'?: ClarifyPipelineHook<ClarifyRouteDiscoveryInput>;
|
|
415
|
+
'routes:discovered'?: ClarifyPipelineHook<ContentRoute[]>;
|
|
416
|
+
'routes:resolved'?: ClarifyPipelineHook<ClarifyRoutesResolvedInput>;
|
|
417
|
+
'modules:before'?: ClarifyPipelineHook<Map<string, string>>;
|
|
418
|
+
'html:transform'?: ClarifyPipelineHook<ClarifyHtmlTransformInput>;
|
|
419
|
+
};
|
|
420
|
+
export type ClarifyBuildHooks = {
|
|
421
|
+
'build:assets'?: ClarifyCollectorHook<ClarifyEmitAsset>;
|
|
422
|
+
'build:done'?: ClarifyTapHook;
|
|
423
|
+
'build:shouldRun'?: ClarifyInterceptHook;
|
|
424
|
+
'ssg:shouldRun'?: ClarifyInterceptHook;
|
|
425
|
+
};
|
|
426
|
+
export type ClarifyDevHooks = {
|
|
427
|
+
'dev:configureServer'?: (server: ViteDevServer, ctx: ClarifyHookContext) => MaybePromise<void>;
|
|
428
|
+
};
|
|
429
|
+
export type ClarifyHooks = ClarifyLifecycleHooks & ClarifyPipelineHooks & ClarifyBuildHooks & ClarifyDevHooks;
|
|
340
430
|
export type ClarifyPlugin = {
|
|
341
431
|
name: string;
|
|
432
|
+
enforce?: 'pre' | 'post';
|
|
433
|
+
priority?: number;
|
|
434
|
+
dependsOn?: string[];
|
|
342
435
|
hooks?: Partial<ClarifyHooks>;
|
|
343
436
|
slots?: UISlotRegistration[];
|
|
344
437
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clarify-labs/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@apidevtools/swagger-parser": "^12.1.0",
|
|
42
|
-
"@clarify-labs/renderer": "0.
|
|
43
|
-
"@clarify-labs/templates": "0.
|
|
42
|
+
"@clarify-labs/renderer": "0.10.1",
|
|
43
|
+
"@clarify-labs/templates": "0.10.1",
|
|
44
44
|
"@mdx-js/mdx": "^3.1.1",
|
|
45
45
|
"@mdx-js/rollup": "^3.1.1",
|
|
46
|
-
"@tailwindcss/vite": "^4.
|
|
47
|
-
"@vitejs/plugin-react": "^6.0.
|
|
46
|
+
"@tailwindcss/vite": "^4.3.2",
|
|
47
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
48
48
|
"cac": "^7.0.0",
|
|
49
49
|
"github-slugger": "^2.0.0",
|
|
50
50
|
"gray-matter": "^4.0.3",
|
|
@@ -59,16 +59,16 @@
|
|
|
59
59
|
"react-zoom-pan-pinch": "^4.0.3",
|
|
60
60
|
"remark": "^15.0.1",
|
|
61
61
|
"remark-gfm": "^4.0.1",
|
|
62
|
-
"shiki": "
|
|
62
|
+
"shiki": "4.3.0",
|
|
63
63
|
"unist-util-visit": "^5.1.0",
|
|
64
|
-
"vite": "^8.
|
|
64
|
+
"vite": "^8.1.4",
|
|
65
65
|
"yaml": "^2.9.0",
|
|
66
66
|
"zod": "^4.4.3"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@types/react": "^19.
|
|
70
|
-
"typescript": "^
|
|
71
|
-
"vite-plugin-dts": "^
|
|
72
|
-
"vitest": "^4.1.
|
|
69
|
+
"@types/react": "^19.2.17",
|
|
70
|
+
"typescript": "^6.0.3",
|
|
71
|
+
"vite-plugin-dts": "^5.0.3",
|
|
72
|
+
"vitest": "^4.1.10"
|
|
73
73
|
}
|
|
74
74
|
}
|
package/output/core/content.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ContentProcessor } from '../parsers/content.js';
|
|
2
|
-
import { ClarifyHookContext, ClarifyPlugin } from '../types.js';
|
|
3
|
-
export declare function createProjectContentProcessor(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): ContentProcessor;
|
|
4
|
-
export declare function setProjectContentProcessor(ctx: ClarifyHookContext, processor: ContentProcessor): void;
|
|
5
|
-
export declare function getProjectContentProcessor(ctx: ClarifyHookContext): ContentProcessor | undefined;
|
package/output/core/hooks.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ViteDevServer } from 'vite';
|
|
2
|
-
import { ClarifyEmitAsset, ClarifyHookContext, ClarifyHooks, ClarifyPlugin } from '../types.js';
|
|
3
|
-
export declare function runHooks<K extends Exclude<keyof ClarifyHooks, 'build:assets' | 'build:done' | 'dev:configureServer'>>(plugins: ClarifyPlugin[], hookName: K, input: Parameters<NonNullable<ClarifyHooks[K]>>[0], ctx: ClarifyHookContext): Promise<Parameters<NonNullable<ClarifyHooks[K]>>[0]>;
|
|
4
|
-
export declare function runDevConfigureServerHooks(plugins: ClarifyPlugin[], server: ViteDevServer, ctx: ClarifyHookContext): Promise<void>;
|
|
5
|
-
export declare function runBuildAssetsHooks(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): Promise<ClarifyEmitAsset[]>;
|
|
6
|
-
export declare function runBuildDoneHooks(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): Promise<void>;
|
package/output/core/plugin.d.ts
DELETED
package/output/core/site.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ClarifyHookContext, ClarifyPlugin, ContentRoute, NavigationTree } from '../types.js';
|
|
2
|
-
import { ClarifyBuildOptions, ResolvedBuildOptions } from './options.js';
|
|
3
|
-
import { resolveProjectContext } from './project-context.js';
|
|
4
|
-
export type ResolvedClarifySite = {
|
|
5
|
-
root: string;
|
|
6
|
-
contentRoot: string;
|
|
7
|
-
projectConfig: Awaited<ReturnType<typeof resolveProjectContext>>['projectConfig'];
|
|
8
|
-
generateOptions: ResolvedBuildOptions;
|
|
9
|
-
plugins: ClarifyPlugin[];
|
|
10
|
-
ctx: ClarifyHookContext;
|
|
11
|
-
routes: ContentRoute[];
|
|
12
|
-
navigation: NavigationTree;
|
|
13
|
-
};
|
|
14
|
-
export type ResolveClarifySiteOptions = {
|
|
15
|
-
includeHtmlShellPlugin?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export declare function resolveClarifySite(options?: ClarifyBuildOptions, resolveOptions?: ResolveClarifySiteOptions): Promise<ResolvedClarifySite>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ClarifyContentKind, ClarifyContentTransformInput } from '../types.js';
|
|
2
|
-
export type ProcessedMdxContent = {
|
|
3
|
-
frontmatter: Record<string, unknown>;
|
|
4
|
-
content: string;
|
|
5
|
-
};
|
|
6
|
-
export type ContentTransform = (input: ClarifyContentTransformInput) => Promise<ClarifyContentTransformInput> | ClarifyContentTransformInput;
|
|
7
|
-
export type ContentProcessor = {
|
|
8
|
-
processMdx(source: string, filePath?: string): Promise<ProcessedMdxContent>;
|
|
9
|
-
processText(source: string, kind: Exclude<ClarifyContentKind, 'mdx'>, filePath?: string): Promise<string>;
|
|
10
|
-
};
|
|
11
|
-
export declare function createContentProcessor(transform?: ContentTransform): ContentProcessor;
|
package/output/parsers/mdx.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ContentDiagnostic } from '../types.js';
|
|
2
|
-
type HastNode = {
|
|
3
|
-
type: string;
|
|
4
|
-
tagName?: string;
|
|
5
|
-
value?: string;
|
|
6
|
-
properties?: Record<string, unknown>;
|
|
7
|
-
children?: HastNode[];
|
|
8
|
-
};
|
|
9
|
-
export declare function rehypeParseCodeBlocks(): (tree: HastNode) => void;
|
|
10
|
-
export declare function rehypeShiki(): (tree: HastNode) => Promise<void>;
|
|
11
|
-
export declare function rehypeSlugSections(): (tree: HastNode) => void;
|
|
12
|
-
export declare const remarkPlugins: unknown[];
|
|
13
|
-
export declare const rehypePlugins: (typeof rehypeSlugSections)[];
|
|
14
|
-
export declare function compileMdxContent(content: string, filePath?: string, projectRoot?: string): Promise<{
|
|
15
|
-
ok: true;
|
|
16
|
-
} | {
|
|
17
|
-
ok: false;
|
|
18
|
-
diagnostic: ContentDiagnostic;
|
|
19
|
-
}>;
|
|
20
|
-
export {};
|