@kubb/renderer-jsx 0.0.0-canary-20260817183954

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stijn Van Hulle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ <div align="center">
2
+ <a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
3
+ <img src="https://kubb.dev/og.png" alt="Kubb banner">
4
+ </a>
5
+
6
+ [![npm version][npm-version-src]][npm-version-href]
7
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
8
+ [![Stars][stars-src]][stars-href]
9
+ [![License][license-src]][license-href]
10
+ [![Node][node-src]][node-href]
11
+
12
+ <h4>
13
+ <a href="https://kubb.dev" target="_blank">Documentation</a>
14
+ <span> · </span>
15
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
16
+ <span> · </span>
17
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
18
+ </h4>
19
+ </div>
20
+
21
+ <br />
22
+
23
+ # @kubb/renderer-jsx
24
+
25
+ ### JSX-based renderer for Kubb
26
+
27
+ Provides a JSX runtime and built-in components (`File`, `Function`, `Type`, `Const`) for component-based, type-safe code generation inside Kubb plugins.
28
+ An alternative for the ast.factory syntax.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ bun add @kubb/renderer-jsx
34
+ # or
35
+ pnpm add @kubb/renderer-jsx
36
+ # or
37
+ npm install @kubb/renderer-jsx
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ Use the built-in components inside a Kubb plugin to emit generated files:
43
+
44
+ ```tsx
45
+ import { jsxRenderer } from '@kubb/renderer-jsx'
46
+ import { File, Function, Type } from '@kubb/renderer-jsx'
47
+
48
+ const renderer = jsxRenderer()
49
+
50
+ await renderer.render(
51
+ <File baseName="petStore.ts" path="src/gen/petStore.ts">
52
+ <File.Source>
53
+ <Type name="Pet">{'{ id: number; name: string }'}</Type>
54
+ <Function name="getPet" async>
55
+ {"return fetch('/pets')"}
56
+ </Function>
57
+ </File.Source>
58
+ </File>,
59
+ )
60
+
61
+ const files = renderer.files
62
+ ```
63
+
64
+ ## Built-in Components
65
+
66
+ | Component | Description |
67
+ | --------------- | --------------------------------------------------------------------------- |
68
+ | `<File>` | Declares a generated output file with its path and optional imports/exports |
69
+ | `<File.Source>` | The source content block inside a `<File>` |
70
+ | `<Function>` | Generates a TypeScript function declaration |
71
+ | `<Type>` | Generates a TypeScript type alias |
72
+ | `<Const>` | Generates a `const` variable declaration |
73
+ | `<Jsx>` | Renders JSX expressions inside generated output |
74
+ | `<Callout>` | Generates a callout block in markdown output |
75
+ | `<Frontmatter>` | Generates a frontmatter block in markdown output |
76
+ | `<Heading>` | Generates a heading in markdown output |
77
+ | `<List>` | Generates a list in markdown output |
78
+ | `<Paragraph>` | Generates a paragraph in markdown output |
79
+
80
+ ## API
81
+
82
+ ### `jsxRenderer()`
83
+
84
+ Creates a renderer instance with `render`, `files`, and `stream`:
85
+
86
+ ```typescript
87
+ const renderer = jsxRenderer()
88
+ await renderer.render(<MyComponent />)
89
+ const files = renderer.files // FileNode[]
90
+ ```
91
+
92
+ Use `stream(element)` instead of `render` to consume files one at a time as they are produced.
93
+
94
+ ## JSX Runtime
95
+
96
+ `@kubb/renderer-jsx` ships its own JSX runtime (`jsx-runtime` and `jsx-dev-runtime`). Configure your `tsconfig.json` to use it:
97
+
98
+ ```json
99
+ {
100
+ "compilerOptions": {
101
+ "jsx": "react-jsx",
102
+ "jsxImportSource": "@kubb/renderer-jsx"
103
+ }
104
+ }
105
+ ```
106
+
107
+ ## Supporting Kubb
108
+
109
+ Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
110
+
111
+ - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
112
+ - [See sponsorship tiers and our sponsors](https://kubb.dev/sponsors)
113
+
114
+ <p align="center">
115
+ <a href="https://github.com/sponsors/stijnvanhulle">
116
+ <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
117
+ </a>
118
+ </p>
119
+
120
+ ## License
121
+
122
+ [MIT](https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT)
123
+
124
+ <!-- Badges -->
125
+
126
+ [npm-version-src]: https://shieldcn.dev/npm/v/@kubb/renderer-jsx.svg?variant=secondary&size=xs&theme=zinc&mode=dark
127
+ [npm-version-href]: https://npmx.dev/package/@kubb/renderer-jsx
128
+ [npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/renderer-jsx.svg?variant=secondary&size=xs&theme=zinc&mode=dark
129
+ [npm-downloads-href]: https://npmx.dev/package/@kubb/renderer-jsx
130
+ [stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
131
+ [stars-href]: https://github.com/kubb-labs/kubb
132
+ [license-src]: https://shieldcn.dev/npm/license/@kubb/renderer-jsx.svg?variant=secondary&size=xs&theme=zinc
133
+ [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
134
+ [node-src]: https://shieldcn.dev/npm/node/@kubb/renderer-jsx.svg?variant=secondary&size=xs&theme=zinc&mode=dark
135
+ [node-href]: https://npmx.dev/package/@kubb/renderer-jsx