@kubb/renderer-jsx 5.0.0-beta.6 → 5.0.0-beta.60
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 +17 -10
- package/README.md +134 -0
- package/dist/chunk-C0LytTxp.js +8 -0
- package/dist/index.cjs +386 -17922
- package/dist/index.d.ts +232 -147
- package/dist/index.js +370 -17903
- package/dist/jsx-dev-runtime.cjs +3 -10
- package/dist/jsx-dev-runtime.d.ts +4 -8
- package/dist/jsx-dev-runtime.js +1 -9
- package/dist/jsx-runtime-3ncySO6L.cjs +89 -0
- package/dist/jsx-runtime.cjs +5 -14
- package/dist/jsx-runtime.d.ts +60 -10
- package/dist/jsx-runtime.js +24 -7
- package/dist/types-UI1cZVah.d.ts +115 -0
- package/dist/types.d.ts +2 -2
- package/package.json +6 -29
- package/src/SyncRuntime.tsx +298 -0
- package/src/components/Callout.tsx +59 -0
- package/src/components/Const.tsx +4 -4
- package/src/components/File.tsx +7 -5
- package/src/components/Frontmatter.tsx +38 -0
- package/src/components/Function.tsx +8 -8
- package/src/components/Heading.tsx +34 -0
- package/src/components/Jsx.tsx +1 -1
- package/src/components/List.tsx +40 -0
- package/src/components/Paragraph.tsx +28 -0
- package/src/components/Type.tsx +3 -3
- package/src/constants.ts +9 -28
- package/src/createRenderer.tsx +38 -75
- package/src/globals.ts +14 -6
- package/src/index.ts +6 -3
- package/src/jsx-dev-runtime.ts +1 -3
- package/src/jsx-namespace.d.ts +21 -13
- package/src/jsx-runtime.ts +22 -6
- package/src/types.ts +16 -100
- package/dist/chunk-Bb7HlUDG.js +0 -28
- package/dist/jsx-namespace-CNp0arTN.d.ts +0 -39
- package/dist/jsx-runtime-Cvu_ZYgL.js +0 -1448
- package/dist/jsx-runtime-DdmO3p0U.cjs +0 -1503
- package/dist/types-nAFMiWFw.d.ts +0 -168
- package/src/Renderer.ts +0 -184
- package/src/Runtime.tsx +0 -170
- package/src/components/Root.tsx +0 -70
- package/src/dom.ts +0 -105
- package/src/utils.ts +0 -267
package/LICENSE
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
This repository contains software under two licenses:
|
|
1
|
+
MIT License
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
MIT License — see licenses/LICENSE-MIT for the full license text.
|
|
3
|
+
Copyright (c) 2026 Stijn Van Hulle
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
11
|
|
|
12
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
13
14
|
|
|
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,134 @@
|
|
|
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 React-free JSX runtime and built-in components (`File`, `Function`, `Type`, `Const`) for component-based, type-safe code generation inside Kubb plugins.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bun add @kubb/renderer-jsx
|
|
33
|
+
# or
|
|
34
|
+
pnpm add @kubb/renderer-jsx
|
|
35
|
+
# or
|
|
36
|
+
npm install @kubb/renderer-jsx
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Use the built-in components inside a Kubb plugin to emit generated files:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
45
|
+
import { File, Function, Type } from '@kubb/renderer-jsx'
|
|
46
|
+
|
|
47
|
+
const renderer = jsxRenderer()
|
|
48
|
+
|
|
49
|
+
await renderer.render(
|
|
50
|
+
<File baseName="petStore.ts" path="src/gen/petStore.ts">
|
|
51
|
+
<File.Source>
|
|
52
|
+
<Type name="Pet">{'{ id: number; name: string }'}</Type>
|
|
53
|
+
<Function name="getPet" async>
|
|
54
|
+
{"return fetch('/pets')"}
|
|
55
|
+
</Function>
|
|
56
|
+
</File.Source>
|
|
57
|
+
</File>,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
const files = renderer.files
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Built-in Components
|
|
64
|
+
|
|
65
|
+
| Component | Description |
|
|
66
|
+
| --------------- | --------------------------------------------------------------------------- |
|
|
67
|
+
| `<File>` | Declares a generated output file with its path and optional imports/exports |
|
|
68
|
+
| `<File.Source>` | The source content block inside a `<File>` |
|
|
69
|
+
| `<Function>` | Generates a TypeScript function declaration |
|
|
70
|
+
| `<Type>` | Generates a TypeScript type alias |
|
|
71
|
+
| `<Const>` | Generates a `const` variable declaration |
|
|
72
|
+
| `<Jsx>` | Renders JSX expressions inside generated output |
|
|
73
|
+
| `<Callout>` | Generates a callout block in markdown output |
|
|
74
|
+
| `<Frontmatter>` | Generates a frontmatter block in markdown output |
|
|
75
|
+
| `<Heading>` | Generates a heading in markdown output |
|
|
76
|
+
| `<List>` | Generates a list in markdown output |
|
|
77
|
+
| `<Paragraph>` | Generates a paragraph in markdown output |
|
|
78
|
+
|
|
79
|
+
## API
|
|
80
|
+
|
|
81
|
+
### `jsxRenderer()`
|
|
82
|
+
|
|
83
|
+
Creates a renderer instance with `render`, `files`, and `stream`:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const renderer = jsxRenderer()
|
|
87
|
+
await renderer.render(<MyComponent />)
|
|
88
|
+
const files = renderer.files // FileNode[]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Use `stream(element)` instead of `render` to consume files one at a time as they are produced.
|
|
92
|
+
|
|
93
|
+
## JSX Runtime
|
|
94
|
+
|
|
95
|
+
`@kubb/renderer-jsx` ships its own JSX runtime (`jsx-runtime` and `jsx-dev-runtime`). Configure your `tsconfig.json` to use it:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"compilerOptions": {
|
|
100
|
+
"jsx": "react-jsx",
|
|
101
|
+
"jsxImportSource": "@kubb/renderer-jsx"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Supporting Kubb
|
|
107
|
+
|
|
108
|
+
Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
|
|
109
|
+
|
|
110
|
+
- [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
|
|
111
|
+
- [See sponsorship tiers and our sponsors](https://kubb.dev/sponsors)
|
|
112
|
+
|
|
113
|
+
<p align="center">
|
|
114
|
+
<a href="https://github.com/sponsors/stijnvanhulle">
|
|
115
|
+
<img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
|
|
116
|
+
</a>
|
|
117
|
+
</p>
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
[MIT](https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT)
|
|
122
|
+
|
|
123
|
+
<!-- Badges -->
|
|
124
|
+
|
|
125
|
+
[npm-version-src]: https://shieldcn.dev/npm/v/@kubb/renderer-jsx.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
126
|
+
[npm-version-href]: https://npmx.dev/package/@kubb/renderer-jsx
|
|
127
|
+
[npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/renderer-jsx.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
128
|
+
[npm-downloads-href]: https://npmx.dev/package/@kubb/renderer-jsx
|
|
129
|
+
[stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
130
|
+
[stars-href]: https://github.com/kubb-labs/kubb
|
|
131
|
+
[license-src]: https://shieldcn.dev/npm/license/@kubb/renderer-jsx.svg?variant=secondary&size=xs&theme=zinc
|
|
132
|
+
[license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
|
|
133
|
+
[node-src]: https://shieldcn.dev/npm/node/@kubb/renderer-jsx.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
134
|
+
[node-href]: https://npmx.dev/package/@kubb/renderer-jsx
|