@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.
Files changed (60) hide show
  1. package/output/cli/spawn.d.ts +1 -1
  2. package/output/cli.cjs +72 -62
  3. package/output/cli.cjs.map +1 -1
  4. package/output/cli.js +68 -58
  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/plugin/hooks.d.ts +7 -0
  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} +3 -3
  23. package/output/core/{virtual-modules.d.ts → runtime/virtual-modules.d.ts} +13 -11
  24. package/output/core/{vite-config.d.ts → runtime/vite-config.d.ts} +2 -1
  25. package/output/{plugin-Etn8ZfYN.cjs → engine-5bdNX2Oo.cjs} +2755 -2158
  26. package/output/engine-5bdNX2Oo.cjs.map +1 -0
  27. package/output/{plugin-Z3fYTMcb.js → engine-Ca_2MCj9.js} +2750 -2152
  28. package/output/engine-Ca_2MCj9.js.map +1 -0
  29. package/output/index.cjs +5 -3
  30. package/output/index.d.ts +7 -5
  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} +3 -2
  36. package/output/parsers/routes/routes.test-utils.d.ts +20 -0
  37. package/output/plugins/openapi/parser.d.ts +2 -1
  38. package/output/plugins/openapi/virtual-modules.d.ts +4 -3
  39. package/output/plugins/source-links/source-links.d.ts +2 -2
  40. package/output/plugins/variables/index.d.ts +2 -1
  41. package/output/types.d.ts +138 -45
  42. package/package.json +11 -11
  43. package/output/core/content.d.ts +0 -5
  44. package/output/core/hooks.d.ts +0 -6
  45. package/output/core/plugin.d.ts +0 -3
  46. package/output/core/site.d.ts +0 -17
  47. package/output/parsers/content.d.ts +0 -11
  48. package/output/parsers/mdx.d.ts +0 -20
  49. package/output/parsers/routes.test-utils.d.ts +0 -3
  50. package/output/parsers/variables.d.ts +0 -2
  51. package/output/plugin-Etn8ZfYN.cjs.map +0 -1
  52. package/output/plugin-Z3fYTMcb.js.map +0 -1
  53. /package/output/core/{temp-dir.d.ts → project/temp-dir.d.ts} +0 -0
  54. /package/output/core/{log.d.ts → runtime/log.d.ts} +0 -0
  55. /package/output/core/{runtime-deps.d.ts → runtime/runtime-deps.d.ts} +0 -0
  56. /package/output/core/{startup.d.ts → runtime/startup.d.ts} +0 -0
  57. /package/output/parsers/{frontmatter.d.ts → markdown/frontmatter.d.ts} +0 -0
  58. /package/output/{core → parsers/markdown}/utils.d.ts +0 -0
  59. /package/output/{core → parsers}/theme.d.ts +0 -0
  60. /package/output/{core → plugins/search-index}/search-language.d.ts +0 -0
@@ -0,0 +1,10 @@
1
+ import { ClarifyCollectorHook, ClarifyHookContext, ClarifyInterceptHook, ClarifyPipelineHook, ClarifyPlugin, ClarifyTapHook } from '../../types.js';
2
+ export type PhaseName = 'config:load' | 'config:resolve' | 'plugins:load' | 'site:discover' | 'content:process' | 'modules:build' | 'build' | 'ssg' | 'dev:server';
3
+ export type TapPhaseName = `before:${PhaseName}` | `after:${PhaseName}`;
4
+ export type TapHook = ClarifyTapHook;
5
+ export type InterceptHook = ClarifyInterceptHook;
6
+ export type PipelineHook<Input> = ClarifyPipelineHook<Input>;
7
+ export type CollectorHook<Result> = ClarifyCollectorHook<Result>;
8
+ export declare function runTapHooks(plugins: ClarifyPlugin[], hookName: TapPhaseName, ctx: ClarifyHookContext): Promise<void>;
9
+ export declare function runInterceptHooks(plugins: ClarifyPlugin[], hookName: 'build:shouldRun' | 'ssg:shouldRun', ctx: ClarifyHookContext): Promise<boolean>;
10
+ export declare function runPhase<T>(plugins: ClarifyPlugin[], phase: PhaseName, ctx: ClarifyHookContext, task: () => Promise<T> | T): Promise<T>;
@@ -0,0 +1,26 @@
1
+ import { Plugin } from 'vite';
2
+ export type ClarifyEngineMode = 'development' | 'production';
3
+ export type PrepareOptions = {
4
+ /** Force re-initialization even if already prepared (used by config-file hot reload). */
5
+ force?: boolean;
6
+ /** Toggle the HTML shell builtin plugin (default: true). */
7
+ htmlShell?: boolean;
8
+ /** Skip building virtual modules (used by check command). */
9
+ skipModules?: boolean;
10
+ /** Skip startup hints logging (used by check command). */
11
+ skipHints?: boolean;
12
+ };
13
+ export type BuildSSRBundleOptions = {
14
+ root: string;
15
+ ssrEntry: string;
16
+ ssrOutDir: string;
17
+ plugins: Plugin[];
18
+ };
19
+ export type ClarifyEngineRuntime = {
20
+ command: 'build' | 'serve';
21
+ mode: ClarifyEngineMode | string;
22
+ themeEditor?: boolean;
23
+ outputDirectory?: string;
24
+ ssrPlugins?: Plugin[];
25
+ buildSSRBundle?: (options: BuildSSRBundleOptions) => Promise<void>;
26
+ };
@@ -1,4 +1,4 @@
1
- import { ClarifyPlugin } from '../types.js';
1
+ import { ClarifyPlugin } from '../../types.js';
2
2
  export type BuiltinPluginOptions = {
3
3
  htmlShell?: boolean;
4
4
  };
@@ -0,0 +1,7 @@
1
+ import { ViteDevServer } from 'vite';
2
+ import { ClarifyEmitAsset, ClarifyHookContext, ClarifyPipelineHooks, ClarifyPlugin } from '../../types.js';
3
+ export declare function runHooks<K extends keyof ClarifyPipelineHooks>(plugins: ClarifyPlugin[], hookName: K, input: Parameters<NonNullable<ClarifyPipelineHooks[K]>>[0], ctx: ClarifyHookContext): Promise<Parameters<NonNullable<ClarifyPipelineHooks[K]>>[0]>;
4
+ export declare function runDevConfigureServerHooks(plugins: ClarifyPlugin[], server: ViteDevServer, ctx: ClarifyHookContext): Promise<void>;
5
+ export declare function runCollectorHooks<T>(plugins: ClarifyPlugin[], hookName: string, ctx: ClarifyHookContext): Promise<T[]>;
6
+ export declare function runBuildAssetsHooks(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): Promise<ClarifyEmitAsset[]>;
7
+ export declare function runBuildDoneHooks(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import { ClarifyPlugin } from '../../types.js';
2
+ import { ClarifyBuildOptions } from '../config/options.js';
3
+ import { BuiltinPluginOptions } from './builtin.js';
4
+ export type LoadPluginsOptions = BuiltinPluginOptions & {
5
+ userPlugins?: ClarifyPlugin[];
6
+ };
7
+ export declare function sortPlugins(plugins: ClarifyPlugin[]): ClarifyPlugin[];
8
+ export declare function loadPlugins(options?: LoadPluginsOptions): ClarifyPlugin[];
9
+ export declare function loadBuildPlugins(options?: ClarifyBuildOptions, pluginOptions?: BuiltinPluginOptions): ClarifyPlugin[];
@@ -1,16 +1,16 @@
1
1
  import { ConfigEnv } from 'vite';
2
- import { ClarifyHookContext, ClarifyProjectContext } from '../types.js';
3
- import { resolveProjectConfig } from './config.js';
4
- import { ClarifyBuildOptions, ResolvedBuildOptions } from './options.js';
5
- import { ClarifyConfig } from './user-config.js';
2
+ import { ClarifyProjectContext } from '../../types.js';
3
+ import { resolveProjectConfig } from '../config/config.js';
4
+ import { ClarifyBuildOptions, ResolvedBuildOptions } from '../config/options.js';
5
+ import { ClarifyConfig } from '../config/user-config.js';
6
6
  export type ResolvedProjectContext = {
7
7
  projectRoot: string;
8
8
  contentRoot: string;
9
+ config: ClarifyConfig;
9
10
  configFilePath?: string;
10
- projectConfig: ReturnType<typeof resolveProjectConfig>;
11
11
  buildOptions: ResolvedBuildOptions;
12
- config: ClarifyConfig;
13
- hookContext: ClarifyHookContext;
12
+ resolvedOptions: ClarifyBuildOptions;
14
13
  projectContext: ClarifyProjectContext;
14
+ projectConfig: ReturnType<typeof resolveProjectConfig>;
15
15
  };
16
16
  export declare function resolveProjectContext(options?: ClarifyBuildOptions, env?: ConfigEnv): Promise<ResolvedProjectContext>;
@@ -1,5 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { ClarifyProjectContext } from '../types.js';
2
+ import { ClarifyProjectContext } from '../../types.js';
3
3
  /**
4
4
  * Dev-only HTTP endpoint that exposes project metadata so external tooling
5
5
  * (e.g. the VS Code extension) can discover which files Clarify recognizes
@@ -1,4 +1,4 @@
1
- import { ClarifyPlugin } from '../types.js';
1
+ import { ClarifyPlugin } from '../../types.js';
2
2
  export declare function generateClarifyEnvDts(_plugins: ClarifyPlugin[]): string;
3
3
  /**
4
4
  * Writes `clarify-env.d.ts` into the project root. Only rewrites when content
@@ -0,0 +1,13 @@
1
+ import { ClarifyProjectContext, ContentRoute, ResolvedProjectConfig } from '../../types.js';
2
+ /** Inject `lang` (and optional `dir`) onto the `<html>` tag for the route locale. */
3
+ export declare function injectHtmlLocaleAttributes(html: string, contextOrConfig: ClarifyProjectContext | ResolvedProjectConfig, route?: ContentRoute): string;
4
+ /** Set, replace, or remove a `<meta name="...">` tag in `<head>`. */
5
+ export declare function setNamedMeta(html: string, name: string, content: string | undefined): string;
6
+ /** Remove any existing canonical link and (if a URL is resolved) inject a fresh one. */
7
+ export declare function injectCanonicalUrl(html: string, contextOrConfig: ClarifyProjectContext | ResolvedProjectConfig, route?: ContentRoute): string;
8
+ /**
9
+ * Render the SSR result into the built HTML template: set `<title>`, the
10
+ * description/keywords meta, the canonical link, the `<html lang/dir>`, and
11
+ * replace the `#root` content with the rendered app HTML.
12
+ */
13
+ export declare function injectSSRIntoTemplate(template: string, appHtml: string, contextOrConfig: ClarifyProjectContext | ResolvedProjectConfig, route?: ContentRoute): string;
@@ -1,10 +1,10 @@
1
1
  import { Plugin } from 'vite';
2
- import { ClarifyProjectContext, ContentRoute, ResolvedProjectConfig } from '../types.js';
2
+ import { ClarifyProjectContext, ContentRoute, ResolvedProjectConfig } from '../../types.js';
3
+ export { injectSSRIntoTemplate } from './html-template.js';
3
4
  export declare function readIndexHtml(outputDirectory: string): string | undefined;
4
- export declare function injectSSRIntoTemplate(template: string, appHtml: string, contextOrConfig: ClarifyProjectContext | ResolvedProjectConfig, route?: ContentRoute): string;
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 { openApis } from 'virtual:clarify/openapi';\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.component()\n entry._resolved = mod.default\n }))\n return renderToHTML({ config, routes, navigation, openApis, runtimeSlots, url, themeEditor: config.theme.editor });\n}";
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: config.theme.editor });\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, failOnError?: boolean): Promise<void>;
@@ -1,12 +1,12 @@
1
- import { ClarifyPlugin, ContentDiagnostic, ContentRoute, NavigationTree, ResolvedBuildOptions, ResolvedProjectConfig } from '../types.js';
1
+ import { ClarifyPlugin, ContentDiagnostic, ContentRoute, NavigationTree, ResolvedBuildOptions, ResolvedProjectConfig } from '../../types.js';
2
2
  export declare const VIRTUAL_CONFIG = "virtual:clarify/config";
3
3
  export declare const VIRTUAL_ROUTES = "virtual:clarify/routes";
4
4
  export declare const VIRTUAL_SERVER_ROUTES = "virtual:clarify/routes/server";
5
5
  export declare const VIRTUAL_OPENAPI = "virtual:clarify/openapi";
6
+ export declare const VIRTUAL_OPENAPI_SERVER = "virtual:clarify/openapi/server";
6
7
  export declare const VIRTUAL_SLOTS = "virtual:clarify/slots";
7
8
  export declare const VIRTUAL_SLOT = "virtual:clarify/slot";
8
9
  export declare const VIRTUAL_CLIENT_ENTRY = "virtual:clarify/entry-client";
9
- export declare const RESOLVED_CLIENT_ENTRY: string;
10
10
  export type VirtualModules = Map<string, string>;
11
11
  type BuildVirtualModulesArgs = {
12
12
  generateOptions: ResolvedBuildOptions;
@@ -14,7 +14,7 @@ type BuildVirtualModulesArgs = {
14
14
  routes: ContentRoute[];
15
15
  version?: string;
16
16
  plugins?: ClarifyPlugin[];
17
- navigation?: NavigationTree;
17
+ navigation: NavigationTree;
18
18
  themeEditor?: boolean;
19
19
  };
20
20
  type CreateClientEntryModuleOptions = {
@@ -22,8 +22,17 @@ type CreateClientEntryModuleOptions = {
22
22
  };
23
23
  export declare function resolveVirtualId(id: string): string;
24
24
  export declare function stripVirtualPrefix(id: string): string;
25
+ /**
26
+ * Shared `resolveId` logic for all Clarify virtual modules. Used by both the
27
+ * Vite core plugin (dev + build) and the SSG virtual plugin so the ID-to-
28
+ * resolved-ID mapping has a single source of truth.
29
+ *
30
+ * Returns the resolved ID (with `\0` prefix per Vite convention) or `null`
31
+ * if the ID is not a Clarify virtual module.
32
+ */
33
+ export declare function resolveVirtualModuleId(id: string, modules: VirtualModules, routes: readonly ContentRoute[]): string | null;
25
34
  export declare function generateConfigModule(projectConfig: ResolvedProjectConfig, buildOptions: ResolvedBuildOptions, version?: string): string;
26
- export declare function generateRoutesModule(routes: ContentRoute[], resolvedNavigation?: NavigationTree, projectConfig?: ResolvedProjectConfig, mode?: 'client' | 'server'): string;
35
+ export declare function generateRoutesModule(routes: ContentRoute[], navigation: NavigationTree, mode?: 'client' | 'server'): string;
27
36
  export declare function createClientEntryModule(options?: CreateClientEntryModuleOptions): string;
28
37
  /**
29
38
  * Collect every plugin's `slots` declarations into a single runtime registry
@@ -38,13 +47,6 @@ export declare function createClientEntryModule(options?: CreateClientEntryModul
38
47
  * type — no runtime validation is needed.
39
48
  */
40
49
  export declare function createRuntimeSlotsModule(plugins?: ClarifyPlugin[], root?: string): string;
41
- /**
42
- * Re-exports the slot context hook from the renderer so plugin components can
43
- * `import { useSlot } from 'virtual:clarify/slot'` without depending on
44
- * renderer internals directly.
45
- */
46
- export declare function createSlotModule(): string;
47
50
  export declare function generateMdxErrorModule(diagnostic: ContentDiagnostic): string;
48
51
  export declare function buildVirtualModules(args: BuildVirtualModulesArgs): VirtualModules;
49
- export declare function generateOpenApiModule(): string;
50
52
  export {};
@@ -1,4 +1,5 @@
1
1
  import { ConfigEnv, InlineConfig } from 'vite';
2
+ import { ClarifyEngine } from '../engine/engine.js';
2
3
  export type ClarifyViteConfigOptions = {
3
4
  root: string;
4
5
  content: string;
@@ -7,4 +8,4 @@ export type ClarifyViteConfigOptions = {
7
8
  port?: number;
8
9
  open?: boolean | string;
9
10
  };
10
- export declare function createViteConfig(options: ClarifyViteConfigOptions, env: ConfigEnv): Promise<InlineConfig>;
11
+ export declare function createViteConfig(options: ClarifyViteConfigOptions, env: ConfigEnv, engine: ClarifyEngine): Promise<InlineConfig>;