@docubook/core 2.0.0-beta.0 → 2.0.0-beta.2

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.
@@ -0,0 +1,9 @@
1
+ import { serialize } from "./mdx-compiler/serialize.js";
2
+ import type { Node } from "unist";
3
+ import type { Pluggable } from "unified";
4
+ export { serialize };
5
+ export { MDXRemote } from "./mdx-compiler/index.js";
6
+ export declare const preProcess: () => (tree: Node) => Node;
7
+ export declare const postProcess: () => (tree: Node) => Node;
8
+ export declare function createDefaultRehypePlugins(): Pluggable[];
9
+ export declare function createDefaultRemarkPlugins(): Pluggable[];
@@ -0,0 +1,22 @@
1
+ import type { ZodType } from "zod";
2
+ import type { TocItem } from "./types";
3
+ export declare function sluggify(text: string): string;
4
+ export declare function extractTocsFromRawMdx(rawMdx: string): TocItem[];
5
+ export declare function extractFrontmatter<Frontmatter>(content: string): Frontmatter;
6
+ /**
7
+ * Extract frontmatter and return both the parsed data and the content
8
+ * with the frontmatter block stripped. Avoids a second parse during
9
+ * compilation.
10
+ *
11
+ * Optionally validates the parsed frontmatter with a Zod schema.
12
+ * YAML coerces unquoted values (e.g. `date: 2026-06-10` → Date, `3.5` → number),
13
+ * so use `z.coerce.*` for fields that must remain strings.
14
+ */
15
+ export declare function extractFrontmatterWithContent<Frontmatter>(content: string): {
16
+ frontmatter: Frontmatter;
17
+ strippedContent: string;
18
+ };
19
+ export declare function extractFrontmatterWithContent<Frontmatter>(content: string, schema: ZodType<Frontmatter>): {
20
+ frontmatter: Frontmatter;
21
+ strippedContent: string;
22
+ };
package/dist/index.d.ts CHANGED
@@ -1,122 +1,10 @@
1
- export { cn, formatDate, formatDate2, parseDate, stringToDate, toIsoDateOnly } from './utils.js';
2
- import { Pluggable } from 'unified';
3
- import { Node } from 'unist';
4
- import { ZodType } from 'zod';
5
- import { MDXComponents } from 'mdx/types.js';
6
- import React from 'react';
7
- import { MDXRemoteSerializeResult } from './mdx-compiler/serialize.js';
8
- export { SerializeOptions, SerializeResult, serialize } from './mdx-compiler/serialize.js';
9
- import 'clsx';
10
-
11
- type TocItem = {
12
- level: number;
13
- text: string;
14
- href: string;
15
- };
16
-
17
- /**
18
- * Custom merge function.
19
- */
20
- type MergeComponents = (currentComponents: Readonly<MDXComponents>) => MDXComponents;
21
- /**
22
- * Configuration for `MDXProvider`.
23
- */
24
- type Props = {
25
- /**
26
- * Children (optional).
27
- */
28
- children?: React.ReactNode | null | undefined;
29
- /**
30
- * Additional components to use or a function that creates them (optional).
31
- */
32
- components?: Readonly<MDXComponents> | MergeComponents | null | undefined;
33
- /**
34
- * Turn off outer component context (default: `false`).
35
- */
36
- disableParentContext?: boolean | null | undefined;
37
- };
38
-
39
- /** Props for the client-side `<MDXRemote>` (accepts pre-serialized result). */
40
- type MDXRemoteProps = MDXRemoteSerializeResult & {
41
- components?: Record<string, React.ComponentType<any>>;
42
- /** Defer hydration to an idle callback */
43
- lazy?: boolean;
44
- };
45
- /**
46
- * Client-side MDX renderer.
47
- *
48
- * Accepts a pre-compiled result from `serialize()` and renders it via
49
- * `MDXProvider` for custom component injection.
50
- */
51
- declare function MDXRemote({ compiledSource, frontmatter, scope, components, lazy, }: MDXRemoteProps): React.DetailedReactHTMLElement<{
52
- dangerouslySetInnerHTML: {
53
- __html: string;
54
- };
55
- suppressHydrationWarning: true;
56
- }, HTMLElement> | React.FunctionComponentElement<Readonly<Props>> | React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
57
-
58
- declare const preProcess: () => (tree: Node) => Node;
59
- declare const postProcess: () => (tree: Node) => Node;
60
- declare function createDefaultRehypePlugins(): Pluggable[];
61
- declare function createDefaultRemarkPlugins(): Pluggable[];
62
-
63
- declare const handleCodeTitles: () => (tree: Node) => void;
64
-
65
- declare const handleCodeExpandableRemark: () => (tree: Node) => void;
66
- declare const handleCodeExpandable: () => (tree: Node) => void;
67
-
68
- /**
69
- * Rehype plugin that transforms `<pre><code class="language-mermaid">` fenced
70
- * blocks into `<Mermaid chart="...">` elements.
71
- *
72
- * This allows Mermaid diagram definitions to be authored via standard fenced
73
- * code blocks (````mermaid) which avoids JSX parsing collisions with
74
- * Mermaid's `{...}` (decision nodes) and `[...]` (label nodes) syntax.
75
- */
76
- declare const rehypeMermaid: () => (tree: Node) => void;
77
-
78
- /**
79
- * Remark plugin: convert markdown directives into MDX component elements.
80
- *
81
- * Contract (docubook):
82
- * - `:::name{attrs} … :::` — container: EVERY component that holds content
83
- * (tabs, tab, accordions, accordion, steps, step, cards, card, files,
84
- * folder, note + variants). Children are the block between the opening
85
- * `:::` and closing `:::` — bounded by micromark's container grammar, so
86
- * a component can never trap siblings that follow it.
87
- * - `::name{attrs}` — self-closing leaf (no children): file, youtube,
88
- * mermaid.
89
- * - `:tooltip[label]{tip="…"}` — the ONE inline (single-colon) directive.
90
- * Every other text directive is rebuilt as literal text
91
- * (`localhost:3000` stays intact). `::tooltip` (block leaf) is removed
92
- * in v2 — tooltips are inline only.
93
- *
94
- * Names are PascalCased to match the components map (`file-tree` → `FileTree`).
95
- * Bare attributes (`{horizontal}`) become boolean props (JSX bare attribute).
96
- * Callout variants (`:::tip`, `:::info`, …) map to their own registry entries
97
- * (`Tip`/`Info`/…) which wrap the `Callout` component with the type set.
98
- */
99
- declare function remarkDirectiveToMdx(): (tree: Node) => Node;
100
-
101
- declare function sluggify(text: string): string;
102
- declare function extractTocsFromRawMdx(rawMdx: string): TocItem[];
103
- declare function extractFrontmatter<Frontmatter>(content: string): Frontmatter;
104
- /**
105
- * Extract frontmatter and return both the parsed data and the content
106
- * with the frontmatter block stripped. Avoids a second parse during
107
- * compilation.
108
- *
109
- * Optionally validates the parsed frontmatter with a Zod schema.
110
- * YAML coerces unquoted values (e.g. `date: 2026-06-10` → Date, `3.5` → number),
111
- * so use `z.coerce.*` for fields that must remain strings.
112
- */
113
- declare function extractFrontmatterWithContent<Frontmatter>(content: string): {
114
- frontmatter: Frontmatter;
115
- strippedContent: string;
116
- };
117
- declare function extractFrontmatterWithContent<Frontmatter>(content: string, schema: ZodType<Frontmatter>): {
118
- frontmatter: Frontmatter;
119
- strippedContent: string;
120
- };
121
-
122
- export { MDXRemote, type MDXRemoteProps, MDXRemoteSerializeResult, type TocItem, createDefaultRehypePlugins, createDefaultRemarkPlugins, extractFrontmatter, extractFrontmatterWithContent, extractTocsFromRawMdx, handleCodeExpandable, handleCodeExpandableRemark, handleCodeTitles, postProcess, preProcess, rehypeMermaid, remarkDirectiveToMdx, sluggify };
1
+ export type { TocItem } from "./types";
2
+ export { cn, parseDate, stringToDate, formatDate, formatDate2, toIsoDateOnly } from "./utils";
3
+ export { serialize, MDXRemote, preProcess, postProcess, createDefaultRehypePlugins, createDefaultRemarkPlugins, } from "./compile";
4
+ export { handleCodeTitles } from "./plugins/handleCodeTitles";
5
+ export { handleCodeExpandableRemark, handleCodeExpandable } from "./plugins/handleCodeExpandable";
6
+ export { rehypeMermaid } from "./plugins/rehypeMermaid";
7
+ export { remarkDirectiveToMdx } from "./plugins/remarkDirectiveToMdx";
8
+ export { extractFrontmatter, extractFrontmatterWithContent, extractTocsFromRawMdx, sluggify, } from "./extract";
9
+ export type { MDXRemoteProps } from "./mdx-compiler/index";
10
+ export type { MDXRemoteSerializeResult, SerializeOptions, SerializeResult, } from "./mdx-compiler/serialize";