@kubb/renderer-jsx 5.0.0-beta.62 → 5.0.0-beta.64
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/dist/index.cjs +23 -25
- package/dist/index.d.ts +23 -32
- package/dist/index.js +21 -24
- package/dist/jsx-dev-runtime.cjs +1 -1
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-runtime.cjs +32 -5
- package/dist/jsx-runtime.d.ts +4 -5
- package/dist/jsx-runtime.js +1 -1
- package/dist/{jsx-runtime-3ncySO6L.cjs → rolldown-runtime-Bx3C2hgW.cjs} +0 -51
- package/dist/{types-UI1cZVah.d.ts → types-CC4v2M00.d.ts} +2 -2
- package/dist/types.d.ts +1 -1
- package/package.json +2 -3
- package/src/SyncRuntime.tsx +0 -298
- package/src/components/Callout.tsx +0 -59
- package/src/components/Const.tsx +0 -72
- package/src/components/File.tsx +0 -188
- package/src/components/Frontmatter.tsx +0 -38
- package/src/components/Function.tsx +0 -152
- package/src/components/Heading.tsx +0 -34
- package/src/components/Jsx.tsx +0 -34
- package/src/components/List.tsx +0 -40
- package/src/components/Paragraph.tsx +0 -28
- package/src/components/Type.tsx +0 -66
- package/src/constants.ts +0 -9
- package/src/createRenderer.tsx +0 -56
- package/src/globals.ts +0 -42
- package/src/index.ts +0 -11
- package/src/jsx-dev-runtime.ts +0 -8
- package/src/jsx-namespace.d.ts +0 -60
- package/src/jsx-runtime.ts +0 -28
- package/src/types.ts +0 -123
- /package/dist/{chunk-C0LytTxp.js → rolldown-runtime-C0LytTxp.js} +0 -0
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import type { JSDoc, Key, KubbReactElement, KubbReactNode } from '../types.ts'
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
key?: Key
|
|
5
|
-
/**
|
|
6
|
-
* Identifier of the generated function declaration.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* `name: 'getPet'`
|
|
10
|
-
*/
|
|
11
|
-
name: string
|
|
12
|
-
/**
|
|
13
|
-
* Emit `default` after the `export` keyword, making this the module's default export.
|
|
14
|
-
* Requires `export` to also be `true`.
|
|
15
|
-
* @default false
|
|
16
|
-
*/
|
|
17
|
-
default?: boolean | null
|
|
18
|
-
/**
|
|
19
|
-
* Parameter list written verbatim between the function's parentheses.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* `params: 'petId: string, options?: RequestOptions'`
|
|
23
|
-
*/
|
|
24
|
-
params?: string | null
|
|
25
|
-
/**
|
|
26
|
-
* Emit the `export` keyword before the function declaration.
|
|
27
|
-
* - `true` generates `export function name(…) { … }`
|
|
28
|
-
* - `false` generates `function name(…) { … }`
|
|
29
|
-
* @default false
|
|
30
|
-
*/
|
|
31
|
-
export?: boolean | null
|
|
32
|
-
/**
|
|
33
|
-
* Emit the `async` keyword, making this an async function.
|
|
34
|
-
* The return type is automatically wrapped in `Promise<returnType>` when both
|
|
35
|
-
* `async` and `returnType` are set.
|
|
36
|
-
* @default false
|
|
37
|
-
*/
|
|
38
|
-
async?: boolean | null
|
|
39
|
-
/**
|
|
40
|
-
* TypeScript generic type parameters written verbatim between `<` and `>`.
|
|
41
|
-
* Pass an array to emit multiple parameters separated by commas.
|
|
42
|
-
*
|
|
43
|
-
* @example Single generic
|
|
44
|
-
* `generics: 'TData'`
|
|
45
|
-
*
|
|
46
|
-
* @example Multiple generics
|
|
47
|
-
* `generics: ['TData', 'TError = unknown']`
|
|
48
|
-
*/
|
|
49
|
-
generics?: string | Array<string> | null
|
|
50
|
-
/**
|
|
51
|
-
* TypeScript return type annotation written verbatim after `:`.
|
|
52
|
-
* When `async` is `true`, the value is automatically wrapped in `Promise<…>`.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* `returnType: 'Pet'`
|
|
56
|
-
*/
|
|
57
|
-
returnType?: string | null
|
|
58
|
-
/**
|
|
59
|
-
* JSDoc block to prepend to the function declaration.
|
|
60
|
-
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
61
|
-
*/
|
|
62
|
-
JSDoc?: JSDoc | null
|
|
63
|
-
/**
|
|
64
|
-
* Child nodes rendered as the body of the function.
|
|
65
|
-
*/
|
|
66
|
-
children?: KubbReactNode
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Generates a TypeScript function declaration.
|
|
71
|
-
*
|
|
72
|
-
* @example Async exported function with generics
|
|
73
|
-
* ```tsx
|
|
74
|
-
* <Function export async name="getPet" generics={['TData = Pet']} params="petId: string" returnType="TData">
|
|
75
|
-
* {`return client.get(\`/pets/\${petId}\`)`}
|
|
76
|
-
* </Function>
|
|
77
|
-
* // export async function getPet<TData = Pet>(petId: string): Promise<TData> {
|
|
78
|
-
* // return client.get(`/pets/${petId}`)
|
|
79
|
-
* // }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
export function Function({ children, ...props }: Props): KubbReactElement {
|
|
83
|
-
const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc } = props
|
|
84
|
-
|
|
85
|
-
// Normalize generics array to comma-separated string for DOM attribute storage
|
|
86
|
-
const genericsString = Array.isArray(generics) ? generics.join(', ').trim() : generics
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<kubb-function
|
|
90
|
-
name={name}
|
|
91
|
-
params={params}
|
|
92
|
-
export={canExport}
|
|
93
|
-
default={isDefault}
|
|
94
|
-
async={isAsync}
|
|
95
|
-
generics={genericsString}
|
|
96
|
-
returnType={returnType}
|
|
97
|
-
JSDoc={JSDoc}
|
|
98
|
-
>
|
|
99
|
-
{children}
|
|
100
|
-
</kubb-function>
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
Function.displayName = 'Function'
|
|
105
|
-
|
|
106
|
-
type ArrowFunctionProps = Props & {
|
|
107
|
-
/**
|
|
108
|
-
* Render the arrow function as a single-line expression (no braces around the body).
|
|
109
|
-
* - `true` generates `const name = (…) => expression`
|
|
110
|
-
* - `false` generates `const name = (…) => { … }`
|
|
111
|
-
* @default false
|
|
112
|
-
*/
|
|
113
|
-
singleLine?: boolean | null
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Generates an arrow function expression assigned to a `const`.
|
|
118
|
-
* Supports the same flags as {@link Function}.
|
|
119
|
-
* Use `singleLine` to render the body as a concise expression rather than a block.
|
|
120
|
-
*
|
|
121
|
-
* @example Single-line arrow function
|
|
122
|
-
* ```tsx
|
|
123
|
-
* <Function.Arrow export name="double" params="n: number" returnType="number" singleLine>
|
|
124
|
-
* {`n * 2`}
|
|
125
|
-
* </Function.Arrow>
|
|
126
|
-
* // export const double = (n: number): number => n * 2
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
function ArrowFunction({ children, ...props }: ArrowFunctionProps) {
|
|
130
|
-
const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props
|
|
131
|
-
|
|
132
|
-
const genericsString = Array.isArray(generics) ? generics.join(', ').trim() : generics
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<kubb-arrow-function
|
|
136
|
-
name={name}
|
|
137
|
-
params={params}
|
|
138
|
-
export={canExport}
|
|
139
|
-
default={isDefault}
|
|
140
|
-
async={async}
|
|
141
|
-
generics={genericsString}
|
|
142
|
-
returnType={returnType}
|
|
143
|
-
singleLine={singleLine}
|
|
144
|
-
JSDoc={JSDoc}
|
|
145
|
-
>
|
|
146
|
-
{children}
|
|
147
|
-
</kubb-arrow-function>
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
ArrowFunction.displayName = 'ArrowFunction'
|
|
152
|
-
Function.Arrow = ArrowFunction
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Key, KubbReactElement } from '../types.ts'
|
|
2
|
-
|
|
3
|
-
type Level = 1 | 2 | 3 | 4 | 5 | 6
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
key?: Key
|
|
7
|
-
/**
|
|
8
|
-
* Heading depth, `1` through `6`. Matches the number of `#` characters
|
|
9
|
-
* prefixed to the heading text.
|
|
10
|
-
*/
|
|
11
|
-
level: Level
|
|
12
|
-
/**
|
|
13
|
-
* Heading text. Inline markdown (links, emphasis) is passed through verbatim.
|
|
14
|
-
*/
|
|
15
|
-
children: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Renders an ATX-style markdown heading.
|
|
20
|
-
*
|
|
21
|
-
* Emits a `<File.Source>` block containing `${'#'.repeat(level)} ${children}`.
|
|
22
|
-
* Use inside a `<File>` rendered by `parserMd`.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* <Heading level={2}>Installation</Heading>
|
|
27
|
-
* // ## Installation
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export function Heading({ level, children }: Props): KubbReactElement {
|
|
31
|
-
return <kubb-source name="heading">{`${'#'.repeat(level)} ${children}`}</kubb-source>
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Heading.displayName = 'Heading'
|
package/src/components/Jsx.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { KubbReactElement } from '../types.ts'
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
/**
|
|
5
|
-
* Raw JSX string to embed verbatim in the generated code.
|
|
6
|
-
* Supports JSX fragments (`<>…</>`), elements, and any valid JSX syntax.
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* <Jsx>{'<>\n <a href={href}>Open</a>\n</>'}</Jsx>
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
children?: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Embeds a raw JSX string verbatim in the generated source code.
|
|
17
|
-
*
|
|
18
|
-
* Use this component when you need to include JSX markup (including fragments
|
|
19
|
-
* `<>…</>`) in the body of a generated function or component. The `children`
|
|
20
|
-
* prop must be a plain string, expression attributes that reference runtime
|
|
21
|
-
* values should be written as template literals.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```tsx
|
|
25
|
-
* <Function name="MyComponent" export>
|
|
26
|
-
* <Jsx>{'return (\n <>\n <div>Hello</div>\n </>\n)'}</Jsx>
|
|
27
|
-
* </Function>
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export function Jsx({ children }: Props): KubbReactElement {
|
|
31
|
-
return <kubb-jsx>{children}</kubb-jsx>
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Jsx.displayName = 'Jsx'
|
package/src/components/List.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { Key, KubbReactElement } from '../types.ts'
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
key?: Key
|
|
5
|
-
/**
|
|
6
|
-
* When `true`, emits a numbered list (`1. …`). When `false` or omitted,
|
|
7
|
-
* emits a bullet list (`- …`).
|
|
8
|
-
*
|
|
9
|
-
* @default false
|
|
10
|
-
*/
|
|
11
|
-
ordered?: boolean | null
|
|
12
|
-
/**
|
|
13
|
-
* One entry per line. Inline markdown is passed through verbatim.
|
|
14
|
-
*/
|
|
15
|
-
items: ReadonlyArray<string>
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Renders a markdown list.
|
|
20
|
-
*
|
|
21
|
-
* Emits a `<File.Source>` block containing one entry per line, prefixed with
|
|
22
|
-
* `1.` / `2.` … when `ordered`, or `-` otherwise.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* <List items={['Add the parser', 'Render the page']} />
|
|
27
|
-
* // - Add the parser
|
|
28
|
-
* // - Render the page
|
|
29
|
-
*
|
|
30
|
-
* <List ordered items={['First', 'Second']} />
|
|
31
|
-
* // 1. First
|
|
32
|
-
* // 2. Second
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export function List({ ordered, items }: Props): KubbReactElement {
|
|
36
|
-
const body = items.map((item, index) => `${ordered ? `${index + 1}.` : '-'} ${item}`).join('\n')
|
|
37
|
-
return <kubb-source name="list">{body}</kubb-source>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
List.displayName = 'List'
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Key, KubbReactElement } from '../types.ts'
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
key?: Key
|
|
5
|
-
/**
|
|
6
|
-
* Paragraph text. Inline markdown (links, emphasis, code spans) is passed
|
|
7
|
-
* through verbatim.
|
|
8
|
-
*/
|
|
9
|
-
children: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Renders a markdown paragraph.
|
|
14
|
-
*
|
|
15
|
-
* Emits a `<File.Source>` block containing the text as-is. Paragraphs are
|
|
16
|
-
* separated from surrounding blocks by blank lines via the parser's source
|
|
17
|
-
* joining.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* <Paragraph>{'A pet object with `id` and `name` fields.'}</Paragraph>
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export function Paragraph({ children }: Props): KubbReactElement {
|
|
25
|
-
return <kubb-source name="paragraph">{children}</kubb-source>
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Paragraph.displayName = 'Paragraph'
|
package/src/components/Type.tsx
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { JSDoc, Key, KubbReactElement, KubbReactNode } from '../types.ts'
|
|
2
|
-
|
|
3
|
-
type TypeProps = {
|
|
4
|
-
key?: Key
|
|
5
|
-
/**
|
|
6
|
-
* Identifier of the generated type alias.
|
|
7
|
-
* Must start with an uppercase letter to follow TypeScript naming conventions.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* `name: 'Pet'`
|
|
11
|
-
*/
|
|
12
|
-
name: string
|
|
13
|
-
/**
|
|
14
|
-
* Emit the `export` keyword before the type alias declaration.
|
|
15
|
-
* - `true` generates `export type Name = …`
|
|
16
|
-
* - `false` generates `type Name = …`
|
|
17
|
-
* @default false
|
|
18
|
-
*/
|
|
19
|
-
export?: boolean | null
|
|
20
|
-
/**
|
|
21
|
-
* JSDoc block to prepend to the type alias declaration.
|
|
22
|
-
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
23
|
-
*/
|
|
24
|
-
JSDoc?: JSDoc | null
|
|
25
|
-
/**
|
|
26
|
-
* Child nodes rendered as the type expression on the right-hand side of the alias.
|
|
27
|
-
*/
|
|
28
|
-
children?: KubbReactNode
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Generates a TypeScript type alias declaration.
|
|
33
|
-
*
|
|
34
|
-
* Throws if `name` does not start with an uppercase letter. TypeScript type aliases
|
|
35
|
-
* should follow PascalCase naming conventions.
|
|
36
|
-
*
|
|
37
|
-
* @example Simple exported type alias
|
|
38
|
-
* ```tsx
|
|
39
|
-
* <Type export name="PetId">
|
|
40
|
-
* {`string | number`}
|
|
41
|
-
* </Type>
|
|
42
|
-
* // export type PetId = string | number
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @example Type alias with JSDoc
|
|
46
|
-
* ```tsx
|
|
47
|
-
* <Type export name="Pet" JSDoc={{ comments: ['@description A pet in the store.'] }}>
|
|
48
|
-
* {`{ id: number; name: string }`}
|
|
49
|
-
* </Type>
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export function Type({ children, ...props }: TypeProps): KubbReactElement {
|
|
53
|
-
const { name, export: canExport, JSDoc } = props
|
|
54
|
-
|
|
55
|
-
if (name.charAt(0).toUpperCase() !== name.charAt(0)) {
|
|
56
|
-
throw new Error('Name should start with a capital letter(see TypeScript types)')
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<kubb-type name={name} export={canExport} JSDoc={JSDoc}>
|
|
61
|
-
{children}
|
|
62
|
-
</kubb-type>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
Type.displayName = 'Type'
|
package/src/constants.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const KUBB_FILE = 'kubb-file' as const
|
|
2
|
-
export const KUBB_SOURCE = 'kubb-source' as const
|
|
3
|
-
export const KUBB_EXPORT = 'kubb-export' as const
|
|
4
|
-
export const KUBB_IMPORT = 'kubb-import' as const
|
|
5
|
-
export const KUBB_FUNCTION = 'kubb-function' as const
|
|
6
|
-
export const KUBB_ARROW_FUNCTION = 'kubb-arrow-function' as const
|
|
7
|
-
export const KUBB_CONST = 'kubb-const' as const
|
|
8
|
-
export const KUBB_TYPE = 'kubb-type' as const
|
|
9
|
-
export const KUBB_JSX = 'kubb-jsx' as const
|
package/src/createRenderer.tsx
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { FileNode } from '@kubb/ast'
|
|
2
|
-
import { SyncRuntime } from './SyncRuntime.tsx'
|
|
3
|
-
import type { KubbReactElement } from './types.ts'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Renderer that walks the JSX tree in a single recursive pass, with no React
|
|
7
|
-
* reconciler or scheduler. Pass as the `renderer` property on
|
|
8
|
-
* `defineGenerator`. Kubb core stays generic, with no hard dependency on
|
|
9
|
-
* `@kubb/renderer-jsx`.
|
|
10
|
-
*
|
|
11
|
-
* Every component must be a pure function. Hooks, suspense, and class
|
|
12
|
-
* components are not supported. It also exposes `stream()` for incremental
|
|
13
|
-
* file emission.
|
|
14
|
-
*
|
|
15
|
-
* @example Wire up a JSX generator
|
|
16
|
-
* ```tsx
|
|
17
|
-
* import { defineGenerator } from '@kubb/core'
|
|
18
|
-
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
19
|
-
*
|
|
20
|
-
* export const myGenerator = defineGenerator<PluginTs>({
|
|
21
|
-
* name: 'types',
|
|
22
|
-
* renderer: jsxRenderer,
|
|
23
|
-
* schema(node, ctx) {
|
|
24
|
-
* return (
|
|
25
|
-
* <File baseName="output.ts" path={`${ctx.root}/output.ts`}>
|
|
26
|
-
* <Type node={node} resolver={ctx.resolver} />
|
|
27
|
-
* </File>
|
|
28
|
-
* )
|
|
29
|
-
* },
|
|
30
|
-
* })
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @example Stream files as they are produced
|
|
34
|
-
* ```tsx
|
|
35
|
-
* const renderer = jsxRenderer()
|
|
36
|
-
* for (const file of renderer.stream(element)) {
|
|
37
|
-
* await writeFile(file.path, file.sources[0])
|
|
38
|
-
* }
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export const jsxRenderer = () => {
|
|
42
|
-
const runtime = new SyncRuntime()
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
async render(element: KubbReactElement): Promise<void> {
|
|
46
|
-
runtime.render(element)
|
|
47
|
-
},
|
|
48
|
-
get files() {
|
|
49
|
-
return runtime.nodes
|
|
50
|
-
},
|
|
51
|
-
stream(element: KubbReactElement): Generator<FileNode> {
|
|
52
|
-
return runtime.stream(element)
|
|
53
|
-
},
|
|
54
|
-
[Symbol.dispose]() {},
|
|
55
|
-
}
|
|
56
|
-
}
|
package/src/globals.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
KubbArrowFunctionProps,
|
|
3
|
-
KubbConstProps,
|
|
4
|
-
KubbExportProps,
|
|
5
|
-
KubbFileProps,
|
|
6
|
-
KubbFunctionProps,
|
|
7
|
-
KubbImportProps,
|
|
8
|
-
KubbJsxProps,
|
|
9
|
-
KubbReactElement,
|
|
10
|
-
KubbReactNode,
|
|
11
|
-
KubbSourceProps,
|
|
12
|
-
KubbTypeProps,
|
|
13
|
-
Key,
|
|
14
|
-
LineBreakProps,
|
|
15
|
-
} from './types.ts'
|
|
16
|
-
|
|
17
|
-
declare global {
|
|
18
|
-
namespace JSX {
|
|
19
|
-
type Element = KubbReactElement
|
|
20
|
-
|
|
21
|
-
interface ElementClass {
|
|
22
|
-
render(): KubbReactNode
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface IntrinsicAttributes {
|
|
26
|
-
key?: Key | null
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface IntrinsicElements {
|
|
30
|
-
'kubb-jsx': KubbJsxProps
|
|
31
|
-
'kubb-file': KubbFileProps
|
|
32
|
-
'kubb-source': KubbSourceProps
|
|
33
|
-
'kubb-import': KubbImportProps
|
|
34
|
-
'kubb-export': KubbExportProps
|
|
35
|
-
'kubb-function': KubbFunctionProps
|
|
36
|
-
'kubb-arrow-function': KubbArrowFunctionProps
|
|
37
|
-
'kubb-const': KubbConstProps
|
|
38
|
-
'kubb-type': KubbTypeProps
|
|
39
|
-
br: LineBreakProps
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { Callout } from './components/Callout.tsx'
|
|
2
|
-
export { Const } from './components/Const.tsx'
|
|
3
|
-
export { File } from './components/File.tsx'
|
|
4
|
-
export { Frontmatter } from './components/Frontmatter.tsx'
|
|
5
|
-
export { Function } from './components/Function.tsx'
|
|
6
|
-
export { Heading } from './components/Heading.tsx'
|
|
7
|
-
export { Jsx } from './components/Jsx.tsx'
|
|
8
|
-
export { List } from './components/List.tsx'
|
|
9
|
-
export { Paragraph } from './components/Paragraph.tsx'
|
|
10
|
-
export { Type } from './components/Type.tsx'
|
|
11
|
-
export { jsxRenderer } from './createRenderer.tsx'
|
package/src/jsx-dev-runtime.ts
DELETED
package/src/jsx-namespace.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
KubbArrowFunctionProps,
|
|
3
|
-
KubbConstProps,
|
|
4
|
-
KubbExportProps,
|
|
5
|
-
KubbFileProps,
|
|
6
|
-
KubbFunctionProps,
|
|
7
|
-
KubbImportProps,
|
|
8
|
-
KubbJsxProps,
|
|
9
|
-
KubbReactElement,
|
|
10
|
-
KubbReactNode,
|
|
11
|
-
KubbSourceProps,
|
|
12
|
-
KubbTypeProps,
|
|
13
|
-
Key,
|
|
14
|
-
LineBreakProps,
|
|
15
|
-
} from './types'
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* JSX contract for `@kubb/renderer-jsx`, resolved through `jsxImportSource`.
|
|
19
|
-
*
|
|
20
|
-
* It is self-contained and does not extend `React.JSX`. The renderer only emits
|
|
21
|
-
* the custom `kubb-*` hosts plus `br`, `indent`, and `dedent`, and supports
|
|
22
|
-
* pure function components, so the HTML element and class-component machinery
|
|
23
|
-
* from `@types/react` is not needed.
|
|
24
|
-
*/
|
|
25
|
-
export namespace JSX {
|
|
26
|
-
type ElementType = string | ((props: any) => KubbReactNode)
|
|
27
|
-
type Element = KubbReactElement
|
|
28
|
-
|
|
29
|
-
interface ElementClass {
|
|
30
|
-
render(): KubbReactNode
|
|
31
|
-
}
|
|
32
|
-
interface ElementAttributesProperty {
|
|
33
|
-
props: {}
|
|
34
|
-
}
|
|
35
|
-
interface ElementChildrenAttribute {
|
|
36
|
-
children: {}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface IntrinsicAttributes {
|
|
40
|
-
key?: Key | null
|
|
41
|
-
}
|
|
42
|
-
interface IntrinsicClassAttributes<T> {
|
|
43
|
-
key?: Key | null
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface IntrinsicElements {
|
|
47
|
-
'kubb-jsx': KubbJsxProps
|
|
48
|
-
'kubb-file': KubbFileProps
|
|
49
|
-
'kubb-source': KubbSourceProps
|
|
50
|
-
'kubb-import': KubbImportProps
|
|
51
|
-
'kubb-export': KubbExportProps
|
|
52
|
-
'kubb-function': KubbFunctionProps
|
|
53
|
-
'kubb-arrow-function': KubbArrowFunctionProps
|
|
54
|
-
'kubb-const': KubbConstProps
|
|
55
|
-
'kubb-type': KubbTypeProps
|
|
56
|
-
br: LineBreakProps
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
type LibraryManagedAttributes<C, P> = P
|
|
60
|
-
}
|
package/src/jsx-runtime.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Key, KubbReactElement, KubbReactNode } from './types.ts'
|
|
2
|
-
|
|
3
|
-
const KUBB_ELEMENT = Symbol.for('kubb.element')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Fragment marker. A `<>…</>` compiles to `jsx(Fragment, …)`, and the renderer
|
|
7
|
-
* unwraps it while walking the tree.
|
|
8
|
-
*/
|
|
9
|
-
export const Fragment = Symbol.for('kubb.fragment')
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Create a Kubb JSX element. The automatic JSX runtime calls this for every tag,
|
|
13
|
-
* so the renderer never depends on React at runtime. The `type` is a host
|
|
14
|
-
* string, a function component, or `Fragment`, and children are folded into
|
|
15
|
-
* `props`.
|
|
16
|
-
*/
|
|
17
|
-
function createElement(type: unknown, props: Record<string, unknown> | null, key?: Key | null): KubbReactElement {
|
|
18
|
-
return { $$typeof: KUBB_ELEMENT, type, key: key ?? null, props: props ?? {} } as unknown as KubbReactElement
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const jsx = createElement
|
|
22
|
-
export const jsxs = createElement
|
|
23
|
-
export const jsxDEV = createElement
|
|
24
|
-
|
|
25
|
-
export type * from './jsx-namespace.d.ts'
|
|
26
|
-
|
|
27
|
-
export type JSXElement = KubbReactElement
|
|
28
|
-
export type ReactNode = KubbReactNode
|