|
1 | 1 | /**
|
| 2 | + * @typedef {import('mdx/types.js').MDXComponents} Components |
2 | 3 | * @typedef {import('../core.js').ProcessorOptions} ProcessorOptions
|
| 4 | + */ |
| 5 | + |
| 6 | +/** |
| 7 | + * @typedef {JSX.Element | string | null | undefined} Child |
| 8 | + * Child. |
| 9 | + * |
| 10 | + * @typedef {EvaluateProcessorOptions & RunnerOptions} EvaluateOptions |
| 11 | + * Configuration for evaluation. |
| 12 | + * |
| 13 | + * @typedef {Omit<ProcessorOptions, 'jsx' | 'jsxImportSource' | 'jsxRuntime' | 'pragma' | 'pragmaFrag' | 'pragmaImportSource' | 'providerImportSource' | 'outputFormat'> } EvaluateProcessorOptions |
| 14 | + * Compile configuration without JSX options for evaluation. |
| 15 | + * |
| 16 | + * @typedef {unknown} Fragment |
| 17 | + * Represent the children, typically a symbol. |
| 18 | + * |
| 19 | + * @callback Jsx |
| 20 | + * Create a production element. |
| 21 | + * @param {unknown} type |
| 22 | + * Element type: `Fragment` symbol, tag name (`string`), component. |
| 23 | + * @param {Props} props |
| 24 | + * Element props, `children`, and maybe `node`. |
| 25 | + * @param {string | undefined} [key] |
| 26 | + * Dynamicly generated key to use. |
| 27 | + * @returns {JSX.Element} |
| 28 | + * An element from your framework. |
| 29 | + * |
| 30 | + * @callback JsxDev |
| 31 | + * Create a development element. |
| 32 | + * @param {unknown} type |
| 33 | + * Element type: `Fragment` symbol, tag name (`string`), component. |
| 34 | + * @param {Props} props |
| 35 | + * Element props, `children`, and maybe `node`. |
| 36 | + * @param {string | undefined} key |
| 37 | + * Dynamicly generated key to use. |
| 38 | + * @param {boolean} isStaticChildren |
| 39 | + * Whether two or more children are passed (in an array), which is whether |
| 40 | + * `jsxs` or `jsx` would be used. |
| 41 | + * @param {Source} source |
| 42 | + * Info about source. |
| 43 | + * @param {undefined} self |
| 44 | + * Nothing (this is used by frameworks that have components, we don’t). |
| 45 | + * @returns {JSX.Element} |
| 46 | + * An element from your framework. |
| 47 | + * |
| 48 | + * @callback MergeComponents |
| 49 | + * Custom merge function. |
| 50 | + * @param {Components} currentComponents |
| 51 | + * Current components from the context. |
| 52 | + * @returns {Components} |
| 53 | + * Merged components. |
| 54 | + * |
| 55 | + * @typedef {{children?: Array<Child> | Child, node?: Element | undefined, [prop: string]: Array<Child> | Child | Element | Value | undefined}} Props |
| 56 | + * Properties and children. |
3 | 57 | *
|
4 | 58 | * @typedef RunnerOptions
|
5 | 59 | * Configuration with JSX runtime.
|
6 |
| - * @property {any} Fragment |
| 60 | + * @property {Fragment} Fragment |
7 | 61 | * Symbol to use for fragments.
|
8 |
| - * @property {any} [jsx] |
| 62 | + * @property {Jsx | null | undefined} [jsx] |
9 | 63 | * Function to generate an element with static children in production mode.
|
10 |
| - * @property {any} [jsxs] |
| 64 | + * @property {Jsx | null | undefined} [jsxs] |
11 | 65 | * Function to generate an element with dynamic children in production mode.
|
12 |
| - * @property {any} [jsxDEV] |
| 66 | + * @property {JsxDev | null | undefined} [jsxDEV] |
13 | 67 | * Function to generate an element in development mode.
|
14 |
| - * @property {any} [useMDXComponents] |
| 68 | + * @property {UseMdxComponents | null | undefined} [useMDXComponents] |
15 | 69 | * Function to get `MDXComponents` from context.
|
16 | 70 | *
|
17 |
| - * @typedef {Omit<ProcessorOptions, 'jsx' | 'jsxImportSource' | 'jsxRuntime' | 'pragma' | 'pragmaFrag' | 'pragmaImportSource' | 'providerImportSource' | 'outputFormat'> } EvaluateProcessorOptions |
18 |
| - * Compile configuration without JSX options for evaluation. |
| 71 | + * @typedef RuntimeDevelopment |
| 72 | + * Runtime fields when development is on. |
| 73 | + * @property {Fragment} Fragment |
| 74 | + * Fragment. |
| 75 | + * @property {Jsx | null | undefined} [jsx] |
| 76 | + * Dynamic JSX (optional). |
| 77 | + * @property {JsxDev} jsxDEV |
| 78 | + * Development JSX. |
| 79 | + * @property {Jsx | null | undefined} [jsxs] |
| 80 | + * Static JSX (optional). |
19 | 81 | *
|
20 |
| - * @typedef {EvaluateProcessorOptions & RunnerOptions} EvaluateOptions |
21 |
| - * Configuration for evaluation. |
| 82 | + * @typedef RuntimeProduction |
| 83 | + * Runtime fields when development is off. |
| 84 | + * @property {Fragment} Fragment |
| 85 | + * Fragment. |
| 86 | + * @property {Jsx} jsx |
| 87 | + * Dynamic JSX. |
| 88 | + * @property {JsxDev | null | undefined} [jsxDEV] |
| 89 | + * Development JSX (optional). |
| 90 | + * @property {Jsx} jsxs |
| 91 | + * Static JSX. |
| 92 | + * |
| 93 | + * @typedef Source |
| 94 | + * Info about source. |
| 95 | + * @property {number | undefined} columnNumber |
| 96 | + * Column where thing starts (0-indexed). |
| 97 | + * @property {string | undefined} fileName |
| 98 | + * Name of source file. |
| 99 | + * @property {number | undefined} lineNumber |
| 100 | + * Line where thing starts (1-indexed). |
| 101 | + * |
| 102 | + * @typedef {Record<string, string>} Style |
| 103 | + * Style map. |
| 104 | + * |
| 105 | + * @callback UseMdxComponents |
| 106 | + * Get current components from the MDX Context. |
| 107 | + * @param {Components | MergeComponents | null | undefined} [components] |
| 108 | + * Additional components to use or a function that takes the current |
| 109 | + * components and filters/merges/changes them. |
| 110 | + * @returns {Components} |
| 111 | + * Current components. |
| 112 | + * |
| 113 | + * @typedef {Style | boolean | number | string} Value |
| 114 | + * Primitive property value and `Style` map. |
22 | 115 | */
|
23 | 116 |
|
24 | 117 | /**
|
|
0 commit comments