@kubb/renderer-jsx 5.0.0-beta.63 → 5.0.0-beta.65

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/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'
@@ -1,8 +0,0 @@
1
- import type { KubbReactElement, KubbReactNode } from './types.ts'
2
-
3
- export { Fragment, jsxDEV } from './jsx-runtime.ts'
4
-
5
- export type * from './jsx-namespace.d.ts'
6
-
7
- export type JSXElement = KubbReactElement
8
- export type ReactNode = KubbReactNode
@@ -1,59 +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`, and supports pure function components, so
22
- * the HTML element and class-component machinery from `@types/react` is not needed.
23
- */
24
- export namespace JSX {
25
- type ElementType = string | ((props: any) => KubbReactNode)
26
- type Element = KubbReactElement
27
-
28
- interface ElementClass {
29
- render(): KubbReactNode
30
- }
31
- interface ElementAttributesProperty {
32
- props: {}
33
- }
34
- interface ElementChildrenAttribute {
35
- children: {}
36
- }
37
-
38
- interface IntrinsicAttributes {
39
- key?: Key | null
40
- }
41
- interface IntrinsicClassAttributes<T> {
42
- key?: Key | null
43
- }
44
-
45
- interface IntrinsicElements {
46
- 'kubb-jsx': KubbJsxProps
47
- 'kubb-file': KubbFileProps
48
- 'kubb-source': KubbSourceProps
49
- 'kubb-import': KubbImportProps
50
- 'kubb-export': KubbExportProps
51
- 'kubb-function': KubbFunctionProps
52
- 'kubb-arrow-function': KubbArrowFunctionProps
53
- 'kubb-const': KubbConstProps
54
- 'kubb-type': KubbTypeProps
55
- br: LineBreakProps
56
- }
57
-
58
- type LibraryManagedAttributes<C, P> = P
59
- }
@@ -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
package/src/types.ts DELETED
@@ -1,123 +0,0 @@
1
- import type { ArrowFunctionNode, ConstNode, ExportNode, FileNode, FunctionNode, ImportNode, SourceNode, TypeNode } from '@kubb/ast'
2
-
3
- /**
4
- * Unique key for a Kubb JSX element in lists or conditional renders.
5
- */
6
- export type Key = string | number | bigint
7
-
8
- /**
9
- * Element produced by a Kubb JSX component. The renderer walks these at runtime,
10
- * so the fields stay opaque to type-checking.
11
- */
12
- export type KubbReactElement = {
13
- type: unknown
14
- props: unknown
15
- key: Key | null
16
- }
17
-
18
- /**
19
- * Anything a Kubb JSX component accepts as children: an element, a primitive
20
- * rendered as text, a nullish value that is skipped, or an iterable of nodes.
21
- */
22
- export type KubbReactNode = KubbReactElement | string | number | bigint | boolean | null | undefined | Iterable<KubbReactNode>
23
-
24
- /**
25
- * Props for the `<kubb-jsx>` element.
26
- * Embeds a raw JSX string verbatim in generated output.
27
- */
28
- export type KubbJsxProps = {
29
- children?: string
30
- }
31
-
32
- /**
33
- * Props for the `<kubb-file>` element.
34
- * Represents a generated file.
35
- */
36
- export type KubbFileProps = {
37
- id?: string | null
38
- children?: KubbReactNode
39
- baseName: string
40
- path: string
41
- override?: boolean | null
42
- meta?: FileNode['meta'] | null
43
- }
44
-
45
- /**
46
- * Props for the `<kubb-source>` element.
47
- * Marks a block of source text associated with a file.
48
- */
49
- export type KubbSourceProps = Omit<SourceNode, 'kind'> & {
50
- children?: KubbReactNode
51
- }
52
-
53
- /**
54
- * Props for the `<kubb-import>` element.
55
- * Declares an import statement in the generated file.
56
- */
57
- export type KubbImportProps = Omit<ImportNode, 'kind'> & {}
58
-
59
- /**
60
- * Props for the `<kubb-export>` element.
61
- * Declares an export statement in the generated file.
62
- */
63
- export type KubbExportProps = Omit<ExportNode, 'kind'> & {}
64
-
65
- /**
66
- * Props for the `<kubb-function>` element.
67
- * Generates a function declaration.
68
- */
69
- export type KubbFunctionProps = Omit<FunctionNode, 'kind'> & {
70
- children?: KubbReactNode
71
- }
72
-
73
- /**
74
- * Props for the `<kubb-arrow-function>` element.
75
- * Generates an arrow function declaration.
76
- */
77
- export type KubbArrowFunctionProps = Omit<ArrowFunctionNode, 'kind'> & {
78
- children?: KubbReactNode
79
- }
80
-
81
- /**
82
- * Props for the `<kubb-const>` element.
83
- * Generates a constant declaration.
84
- */
85
- export type KubbConstProps = Omit<ConstNode, 'kind'> & {
86
- children?: KubbReactNode
87
- }
88
-
89
- /**
90
- * Props for the `<kubb-type>` element.
91
- * Generates a TypeScript type alias declaration.
92
- */
93
- export type KubbTypeProps = Omit<TypeNode, 'kind'> & {
94
- children?: KubbReactNode
95
- }
96
-
97
- /**
98
- * Props for the `<br>` element. It emits a single line break and takes no
99
- * attributes of its own.
100
- */
101
- export type LineBreakProps = {}
102
-
103
- /**
104
- * JSDoc comment block to attach to a generated declaration.
105
- * Each string in `comments` becomes one line inside the `/** … *\/` block.
106
- *
107
- * @example
108
- * ```ts
109
- * { comments: ['@description A pet object.', '@deprecated Use PetV2 instead.'] }
110
- * // Emits:
111
- * // /**
112
- * // * @description A pet object.
113
- * // * @deprecated Use PetV2 instead.
114
- * // *\/
115
- * ```
116
- */
117
- export type JSDoc = {
118
- /**
119
- * Lines to emit inside the JSDoc block, in source order.
120
- * Use standard JSDoc tags such as `@description`, `@deprecated`, `@see`, etc.
121
- */
122
- comments: Array<string>
123
- }