@kubb/renderer-jsx 5.0.0-beta.5 → 5.0.0-beta.7

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/README.md ADDED
@@ -0,0 +1,124 @@
1
+ <div align="center">
2
+ <h1>@kubb/renderer-jsx</h1>
3
+ <a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
4
+ <img width="180" src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/logo.png" alt="Kubb logo">
5
+ </a>
6
+
7
+ [![npm version][npm-version-src]][npm-version-href]
8
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
9
+ [![Coverage][coverage-src]][coverage-href]
10
+ [![License][license-src]][license-href]
11
+ [![Sponsors][sponsors-src]][sponsors-href]
12
+
13
+ <h4>
14
+ <a href="https://kubb.dev/" target="_blank">Documentation</a>
15
+ <span> · </span>
16
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
17
+ <span> · </span>
18
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
19
+ </h4>
20
+ </div>
21
+
22
+ JSX-based renderer for Kubb. Provides a custom React runtime, reconciler, and built-in components (`File`, `Function`, `Type`, `Const`) for component-based, type-safe code generation inside Kubb plugins.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ bun add @kubb/renderer-jsx
28
+ # or
29
+ pnpm add @kubb/renderer-jsx
30
+ # or
31
+ npm install @kubb/renderer-jsx
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Use the built-in components inside a Kubb plugin to emit generated files:
37
+
38
+ ```tsx
39
+ import { createRenderer } from '@kubb/renderer-jsx'
40
+ import { File, Function, Type } from '@kubb/renderer-jsx'
41
+
42
+ const renderer = createRenderer()
43
+
44
+ await renderer.render(
45
+ <File baseName="petStore.ts" path="src/gen/petStore.ts">
46
+ <File.Source>
47
+ <Type name="Pet">{'{ id: number; name: string }'}</Type>
48
+ <Function name="getPet" async>
49
+ {"return fetch('/pets')"}
50
+ </Function>
51
+ </File.Source>
52
+ </File>,
53
+ )
54
+
55
+ const files = renderer.files
56
+ renderer.unmount()
57
+ ```
58
+
59
+ ## Built-in Components
60
+
61
+ | Component | Description |
62
+ | --------------- | --------------------------------------------------------------------------- |
63
+ | `<File>` | Declares a generated output file with its path and optional imports/exports |
64
+ | `<File.Source>` | The source content block inside a `<File>` |
65
+ | `<Function>` | Generates a TypeScript function declaration |
66
+ | `<Type>` | Generates a TypeScript type alias |
67
+ | `<Const>` | Generates a `const` variable declaration |
68
+ | `<Jsx>` | Renders JSX expressions inside generated output |
69
+ | `<Root>` | Root container for the renderer tree |
70
+
71
+ ## API
72
+
73
+ ### `createRenderer(options?)`
74
+
75
+ Creates a new renderer instance.
76
+
77
+ ```typescript
78
+ const renderer = createRenderer({ debug: false })
79
+ await renderer.render(<MyComponent />)
80
+ const files = renderer.files // FileNode[]
81
+ renderer.unmount()
82
+ ```
83
+
84
+ ### `jsxRenderer`
85
+
86
+ Pre-built renderer instance for use directly in Kubb plugins as the `jsxRenderer` plugin option.
87
+
88
+ ## JSX Runtime
89
+
90
+ `@kubb/renderer-jsx` ships its own JSX runtime (`jsx-runtime` and `jsx-dev-runtime`). Configure your `tsconfig.json` to use it:
91
+
92
+ ```json
93
+ {
94
+ "compilerOptions": {
95
+ "jsx": "react-jsx",
96
+ "jsxImportSource": "@kubb/renderer-jsx"
97
+ }
98
+ }
99
+ ```
100
+
101
+ ## Supporting Kubb
102
+
103
+ Kubb is an open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
104
+
105
+ - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
106
+
107
+ <p align="center">
108
+ <a href="https://github.com/sponsors/stijnvanhulle">
109
+ <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
110
+ </a>
111
+ </p>
112
+
113
+ <!-- Badges -->
114
+
115
+ [npm-version-src]: https://img.shields.io/npm/v/@kubb/renderer-jsx?flat&colorA=18181B&colorB=f58517
116
+ [npm-version-href]: https://npmjs.com/package/@kubb/renderer-jsx
117
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/renderer-jsx?flat&colorA=18181B&colorB=f58517
118
+ [npm-downloads-href]: https://npmjs.com/package/@kubb/renderer-jsx
119
+ [license-src]: https://img.shields.io/github/license/kubb-labs/kubb.svg?flat&colorA=18181B&colorB=f58517
120
+ [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
121
+ [coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
122
+ [coverage-href]: https://www.npmjs.com/package/@kubb/renderer-jsx
123
+ [sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517
124
+ [sponsors-href]: https://github.com/sponsors/stijnvanhulle/
package/dist/index.cjs CHANGED
@@ -18149,13 +18149,6 @@ var Runtime = class {
18149
18149
  }
18150
18150
  this.resolveExitPromise();
18151
18151
  }
18152
- async waitUntilExit() {
18153
- if (!this.exitPromise) this.exitPromise = new Promise((resolve, reject) => {
18154
- this.resolveExitPromise = resolve;
18155
- this.rejectExitPromise = reject;
18156
- });
18157
- return this.exitPromise;
18158
- }
18159
18152
  };
18160
18153
  //#endregion
18161
18154
  //#region src/createRenderer.tsx
package/dist/index.js CHANGED
@@ -18146,13 +18146,6 @@ var Runtime = class {
18146
18146
  }
18147
18147
  this.resolveExitPromise();
18148
18148
  }
18149
- async waitUntilExit() {
18150
- if (!this.exitPromise) this.exitPromise = new Promise((resolve, reject) => {
18151
- this.resolveExitPromise = resolve;
18152
- this.rejectExitPromise = reject;
18153
- });
18154
- return this.exitPromise;
18155
- }
18156
18149
  };
18157
18150
  //#endregion
18158
18151
  //#region src/createRenderer.tsx
package/package.json CHANGED
@@ -1,19 +1,13 @@
1
1
  {
2
2
  "name": "@kubb/renderer-jsx",
3
- "version": "5.0.0-beta.5",
4
- "description": "React integration for Kubb - JSX runtime and component-based code generation with React reconciler for building type-safe generators",
3
+ "version": "5.0.0-beta.7",
4
+ "description": "JSX-based renderer for Kubb. Provides a custom React runtime, reconciler, and built-in components (File, Function, Type, Const) for component-based, type-safe code generation.",
5
5
  "keywords": [
6
- "code-generator",
7
6
  "codegen",
8
- "component-generation",
9
- "file-generation",
10
7
  "jsx",
11
8
  "jsx-runtime",
12
9
  "kubb",
13
- "plugin-system",
14
- "plugins",
15
10
  "react",
16
- "react-reconciler",
17
11
  "typescript"
18
12
  ],
19
13
  "license": "MIT",
@@ -81,7 +75,7 @@
81
75
  "registry": "https://registry.npmjs.org/"
82
76
  },
83
77
  "dependencies": {
84
- "@kubb/ast": "5.0.0-beta.5"
78
+ "@kubb/ast": "5.0.0-beta.7"
85
79
  },
86
80
  "devDependencies": {
87
81
  "@types/react": "^19.2.14",
package/src/Renderer.ts CHANGED
@@ -155,9 +155,7 @@ export const Renderer = Reconciler({
155
155
  maySuspendCommit() {
156
156
  return false
157
157
  },
158
- // eslint-disable-next-line @typescript-eslint/naming-convention
159
158
  NotPendingTransition: undefined,
160
- // eslint-disable-next-line @typescript-eslint/naming-convention
161
159
  HostTransitionContext: createContext(null) as unknown as ReactContext<unknown>,
162
160
  resetFormInstance() {},
163
161
  requestPostPaintCallback() {},
package/src/Runtime.tsx CHANGED
@@ -156,15 +156,4 @@ export class Runtime {
156
156
 
157
157
  this.resolveExitPromise()
158
158
  }
159
-
160
- async waitUntilExit(): Promise<void> {
161
- if (!this.exitPromise) {
162
- this.exitPromise = new Promise((resolve, reject) => {
163
- this.resolveExitPromise = resolve
164
- this.rejectExitPromise = reject
165
- })
166
- }
167
-
168
- return this.exitPromise
169
- }
170
159
  }