@clarify-labs/cli 0.9.4 → 0.10.0

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.
Files changed (56) hide show
  1. package/output/cli/spawn.d.ts +1 -1
  2. package/output/cli.cjs +59 -54
  3. package/output/cli.cjs.map +1 -1
  4. package/output/cli.js +55 -50
  5. package/output/cli.js.map +1 -1
  6. package/output/core/adapters.d.ts +11 -0
  7. package/output/core/{config-schema.d.ts → config/config-schema.d.ts} +1 -10
  8. package/output/core/{config.d.ts → config/config.d.ts} +1 -1
  9. package/output/core/{options.d.ts → config/options.d.ts} +1 -1
  10. package/output/core/{user-config.d.ts → config/user-config.d.ts} +1 -1
  11. package/output/core/engine/context.d.ts +51 -0
  12. package/output/core/engine/engine.d.ts +68 -0
  13. package/output/core/engine/phases.d.ts +10 -0
  14. package/output/core/engine/types.d.ts +26 -0
  15. package/output/core/{builtin.d.ts → plugin/builtin.d.ts} +1 -1
  16. package/output/core/{hooks.d.ts → plugin/hooks.d.ts} +2 -1
  17. package/output/core/plugin/manager.d.ts +9 -0
  18. package/output/core/{project-context.d.ts → project/project-context.d.ts} +7 -7
  19. package/output/core/{project-info.d.ts → project/project-info.d.ts} +1 -1
  20. package/output/core/{env-types.d.ts → runtime/env-types.d.ts} +1 -1
  21. package/output/core/runtime/html-template.d.ts +13 -0
  22. package/output/core/{ssg.d.ts → runtime/ssg.d.ts} +2 -2
  23. package/output/core/{virtual-modules.d.ts → runtime/virtual-modules.d.ts} +12 -11
  24. package/output/core/{vite-config.d.ts → runtime/vite-config.d.ts} +2 -1
  25. package/output/{plugin-Z3fYTMcb.js → engine-3f5Tpa-6.js} +2494 -2098
  26. package/output/engine-3f5Tpa-6.js.map +1 -0
  27. package/output/{plugin-Etn8ZfYN.cjs → engine-I04EZzjg.cjs} +2504 -2109
  28. package/output/engine-I04EZzjg.cjs.map +1 -0
  29. package/output/index.cjs +5 -3
  30. package/output/index.d.ts +6 -4
  31. package/output/index.js +2 -2
  32. package/output/parsers/content/content.d.ts +20 -0
  33. package/output/parsers/markdown/mdx.d.ts +37 -0
  34. package/output/{core → parsers/router}/dev-routes.d.ts +1 -1
  35. package/output/parsers/{routes.d.ts → routes/routes.d.ts} +2 -2
  36. package/output/parsers/{routes.test-utils.d.ts → routes/routes.test-utils.d.ts} +1 -1
  37. package/output/plugins/openapi/parser.d.ts +1 -1
  38. package/output/plugins/variables/index.d.ts +2 -1
  39. package/output/types.d.ts +32 -3
  40. package/package.json +11 -11
  41. package/output/core/content.d.ts +0 -5
  42. package/output/core/plugin.d.ts +0 -3
  43. package/output/core/site.d.ts +0 -17
  44. package/output/parsers/content.d.ts +0 -11
  45. package/output/parsers/mdx.d.ts +0 -20
  46. package/output/parsers/variables.d.ts +0 -2
  47. package/output/plugin-Etn8ZfYN.cjs.map +0 -1
  48. package/output/plugin-Z3fYTMcb.js.map +0 -1
  49. /package/output/core/{temp-dir.d.ts → project/temp-dir.d.ts} +0 -0
  50. /package/output/core/{log.d.ts → runtime/log.d.ts} +0 -0
  51. /package/output/core/{runtime-deps.d.ts → runtime/runtime-deps.d.ts} +0 -0
  52. /package/output/core/{startup.d.ts → runtime/startup.d.ts} +0 -0
  53. /package/output/parsers/{frontmatter.d.ts → markdown/frontmatter.d.ts} +0 -0
  54. /package/output/{core → parsers/markdown}/utils.d.ts +0 -0
  55. /package/output/{core → parsers}/theme.d.ts +0 -0
  56. /package/output/{core → plugins/search-index}/search-language.d.ts +0 -0
package/output/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- export { clarifyPlugin } from './core/plugin.js';
2
- export { defineConfig } from './core/user-config.js';
3
- export type { Plugin } from 'vite';
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';
7
+ export type { ClarifyConfig } from './core/config/user-config.js';
6
8
  export type { UISlotName, SlotContext, UISlotRegistration } from '@clarify-labs/renderer';
package/output/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as defineConfig, t as clarifyPlugin } from "./plugin-Z3fYTMcb.js";
2
- export { clarifyPlugin, defineConfig };
1
+ import { c as defineConfig, n as createClarifyEngine, s as createViteAdapter, t as ClarifyEngine } from "./engine-3f5Tpa-6.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 '../types.js';
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 '../types.js';
2
- import { ContentProcessor } from './content.js';
1
+ import { ContentRoute, ContentSection, ClarifyNavigationNode, ClarifyPagesConfig, ClarifyPagesGroup, 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
  };
@@ -1,3 +1,3 @@
1
- import { ContentRoute, ResolvedClarifyI18nConfig } from '../types.js';
1
+ import { ContentRoute, ResolvedClarifyI18nConfig } from '../../types.js';
2
2
  export declare function mdxRoute(route: Omit<ContentRoute, 'kind'>): ContentRoute;
3
3
  export declare const testI18n: ResolvedClarifyI18nConfig;
@@ -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;
@@ -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;
@@ -289,6 +289,11 @@ export type ClarifyProjectContext = {
289
289
  export type ClarifyHookContext = ClarifyProjectContext & {
290
290
  routes: ContentRoute[];
291
291
  navigation: NavigationTree;
292
+ plugins: ClarifyPlugin[];
293
+ get<T>(key: string): T | undefined;
294
+ set<T>(key: string, value: T): void;
295
+ has(key: string): boolean;
296
+ delete(key: string): boolean;
292
297
  };
293
298
  export type ClarifyRouteDiscoveryInput = {
294
299
  contentRoot: string;
@@ -315,10 +320,11 @@ export type ClarifyEmitAsset = {
315
320
  /** Asset content as a UTF-8 string or raw bytes. */
316
321
  source: string | Uint8Array;
317
322
  };
323
+ export type ClarifyTapHook = (ctx: ClarifyHookContext) => Promise<void> | void;
324
+ export type ClarifyInterceptHook = (ctx: ClarifyHookContext) => Promise<boolean> | boolean;
318
325
  export type ClarifyHooks = {
319
326
  'content:transform'?: (input: ClarifyContentTransformInput, ctx: ClarifyHookContext) => Promise<ClarifyContentTransformInput> | ClarifyContentTransformInput;
320
327
  'pages:resolved'?: (pages: ClarifyPage[], ctx: ClarifyHookContext) => Promise<ClarifyPage[]> | ClarifyPage[];
321
- 'page:transform'?: (page: ClarifyPage, ctx: ClarifyHookContext) => Promise<ClarifyPage> | ClarifyPage;
322
328
  'routes:discover'?: (input: ClarifyRouteDiscoveryInput, ctx: ClarifyHookContext) => Promise<ClarifyRouteDiscoveryInput> | ClarifyRouteDiscoveryInput;
323
329
  'routes:discovered'?: (routes: ContentRoute[], ctx: ClarifyHookContext) => Promise<ContentRoute[]> | ContentRoute[];
324
330
  'routes:resolved'?: (input: {
@@ -336,9 +342,32 @@ export type ClarifyHooks = {
336
342
  'dev:configureServer'?: (server: ViteDevServer, ctx: ClarifyHookContext) => Promise<void> | void;
337
343
  'build:assets'?: (ctx: ClarifyHookContext) => Promise<ClarifyEmitAsset[]> | ClarifyEmitAsset[];
338
344
  'build:done'?: (ctx: ClarifyHookContext) => Promise<void> | void;
345
+ 'before:config:load'?: ClarifyTapHook;
346
+ 'after:config:load'?: ClarifyTapHook;
347
+ 'before:config:resolve'?: ClarifyTapHook;
348
+ 'after:config:resolve'?: ClarifyTapHook;
349
+ 'before:plugins:load'?: ClarifyTapHook;
350
+ 'after:plugins:load'?: ClarifyTapHook;
351
+ 'before:site:discover'?: ClarifyTapHook;
352
+ 'after:site:discover'?: ClarifyTapHook;
353
+ 'before:content:process'?: ClarifyTapHook;
354
+ 'after:content:process'?: ClarifyTapHook;
355
+ 'before:modules:build'?: ClarifyTapHook;
356
+ 'after:modules:build'?: ClarifyTapHook;
357
+ 'before:build'?: ClarifyTapHook;
358
+ 'after:build'?: ClarifyTapHook;
359
+ 'before:ssg'?: ClarifyTapHook;
360
+ 'after:ssg'?: ClarifyTapHook;
361
+ 'before:dev:server'?: ClarifyTapHook;
362
+ 'after:dev:server'?: ClarifyTapHook;
363
+ 'build:shouldRun'?: ClarifyInterceptHook;
364
+ 'ssg:shouldRun'?: ClarifyInterceptHook;
339
365
  };
340
366
  export type ClarifyPlugin = {
341
367
  name: string;
368
+ enforce?: 'pre' | 'post';
369
+ priority?: number;
370
+ dependsOn?: string[];
342
371
  hooks?: Partial<ClarifyHooks>;
343
372
  slots?: UISlotRegistration[];
344
373
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clarify-labs/cli",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
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.9.4",
43
- "@clarify-labs/templates": "0.9.4",
42
+ "@clarify-labs/renderer": "0.10.0",
43
+ "@clarify-labs/templates": "0.10.0",
44
44
  "@mdx-js/mdx": "^3.1.1",
45
45
  "@mdx-js/rollup": "^3.1.1",
46
- "@tailwindcss/vite": "^4.1.11",
47
- "@vitejs/plugin-react": "^6.0.2",
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": "0.14.7",
62
+ "shiki": "4.3.0",
63
63
  "unist-util-visit": "^5.1.0",
64
- "vite": "^8.0.15",
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.1.8",
70
- "typescript": "^5.8.3",
71
- "vite-plugin-dts": "^4.5.4",
72
- "vitest": "^4.1.9"
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
  }
@@ -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;
@@ -1,3 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { ClarifyBuildOptions } from './options.js';
3
- export declare function clarifyPlugin(options?: ClarifyBuildOptions): Plugin[];
@@ -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;
@@ -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 {};
@@ -1,2 +0,0 @@
1
- import { ClarifyVariablesConfig } from '../types.js';
2
- export declare function applyVariables(content: string, variables?: ClarifyVariablesConfig): string;