@kubb/renderer-jsx 5.0.0-beta.20 → 5.0.0-beta.22
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 +14 -4
- package/dist/index.d.ts +9 -3
- package/dist/index.js +14 -4
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/{jsx-namespace-BLGeMDcR.d.ts → jsx-namespace-C7dcxEyT.d.ts} +2 -2
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/{types-Dk7A1Y5U.d.ts → types-D3-ni438.d.ts} +2 -2
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/File.tsx +4 -2
- package/src/createRenderer.tsx +10 -0
- package/src/dom.ts +3 -3
- package/src/types.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -486,7 +486,7 @@ const createNode = (nodeName) => {
|
|
|
486
486
|
nodeName,
|
|
487
487
|
attributes: Object.create(null),
|
|
488
488
|
childNodes: [],
|
|
489
|
-
parentNode:
|
|
489
|
+
parentNode: null
|
|
490
490
|
};
|
|
491
491
|
};
|
|
492
492
|
/**
|
|
@@ -524,7 +524,7 @@ const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
|
|
|
524
524
|
* Does nothing if `removeNode` is not a direct child of `node`.
|
|
525
525
|
*/
|
|
526
526
|
const removeChildNode = (node, removeNode) => {
|
|
527
|
-
removeNode.parentNode =
|
|
527
|
+
removeNode.parentNode = null;
|
|
528
528
|
const index = node.childNodes.indexOf(removeNode);
|
|
529
529
|
if (index >= 0) node.childNodes.splice(index, 1);
|
|
530
530
|
};
|
|
@@ -541,7 +541,7 @@ const createTextNode = (text) => {
|
|
|
541
541
|
return {
|
|
542
542
|
nodeName: TEXT_NODE_NAME,
|
|
543
543
|
nodeValue: text,
|
|
544
|
-
parentNode:
|
|
544
|
+
parentNode: null
|
|
545
545
|
};
|
|
546
546
|
};
|
|
547
547
|
/**
|
|
@@ -18408,8 +18408,14 @@ const jsxRenderer = () => {
|
|
|
18408
18408
|
get files() {
|
|
18409
18409
|
return runtime.nodes;
|
|
18410
18410
|
},
|
|
18411
|
+
dispose() {
|
|
18412
|
+
runtime.unmount();
|
|
18413
|
+
},
|
|
18411
18414
|
unmount(error) {
|
|
18412
18415
|
runtime.unmount(error);
|
|
18416
|
+
},
|
|
18417
|
+
[Symbol.dispose]() {
|
|
18418
|
+
this.dispose();
|
|
18413
18419
|
}
|
|
18414
18420
|
};
|
|
18415
18421
|
};
|
|
@@ -18451,7 +18457,11 @@ const jsxRendererSync = () => {
|
|
|
18451
18457
|
stream(element) {
|
|
18452
18458
|
return runtime.stream(element);
|
|
18453
18459
|
},
|
|
18454
|
-
|
|
18460
|
+
dispose() {},
|
|
18461
|
+
unmount(_error) {},
|
|
18462
|
+
[Symbol.dispose]() {
|
|
18463
|
+
this.dispose();
|
|
18464
|
+
}
|
|
18455
18465
|
};
|
|
18456
18466
|
};
|
|
18457
18467
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __name } from "./chunk-Bb7HlUDG.js";
|
|
2
|
-
import { a as JSDoc, h as KubbReactNode, m as KubbReactElement, o as Key } from "./types-
|
|
2
|
+
import { a as JSDoc, h as KubbReactNode, m as KubbReactElement, o as Key } from "./types-D3-ni438.js";
|
|
3
3
|
import { ExportNode, FileNode, ImportNode, SourceNode } from "@kubb/ast";
|
|
4
4
|
import * as _$react from "react";
|
|
5
5
|
|
|
@@ -152,12 +152,14 @@ type Props$2<TMeta> = BaseProps & {
|
|
|
152
152
|
meta?: TMeta;
|
|
153
153
|
/**
|
|
154
154
|
* Text prepended to the generated file content before any source blocks.
|
|
155
|
+
* Accepts `null` so `resolver.resolveBanner()` results can be passed directly.
|
|
155
156
|
*/
|
|
156
|
-
banner?: string;
|
|
157
|
+
banner?: string | null;
|
|
157
158
|
/**
|
|
158
159
|
* Text appended to the generated file content after all source blocks.
|
|
160
|
+
* Accepts `null` so `resolver.resolveFooter()` results can be passed directly.
|
|
159
161
|
*/
|
|
160
|
-
footer?: string;
|
|
162
|
+
footer?: string | null;
|
|
161
163
|
/**
|
|
162
164
|
* Child nodes rendered as the content of this file (source blocks, imports, exports).
|
|
163
165
|
*/
|
|
@@ -540,7 +542,9 @@ declare namespace Type {
|
|
|
540
542
|
declare const jsxRenderer: () => {
|
|
541
543
|
render(element: KubbReactElement): Promise<void>;
|
|
542
544
|
readonly files: FileNode[];
|
|
545
|
+
dispose(): void;
|
|
543
546
|
unmount(error?: Error | number | null): void;
|
|
547
|
+
[Symbol.dispose](): void;
|
|
544
548
|
};
|
|
545
549
|
/**
|
|
546
550
|
* Lightweight renderer factory with no React fiber, scheduler, or work loop.
|
|
@@ -572,7 +576,9 @@ declare const jsxRendererSync: () => {
|
|
|
572
576
|
render(element: KubbReactElement): Promise<void>;
|
|
573
577
|
readonly files: FileNode[];
|
|
574
578
|
stream(element: KubbReactElement): Generator<FileNode>;
|
|
579
|
+
dispose(): void;
|
|
575
580
|
unmount(_error?: Error | number | null): void;
|
|
581
|
+
[Symbol.dispose](): void;
|
|
576
582
|
};
|
|
577
583
|
//#endregion
|
|
578
584
|
export { Const, File, Function, Jsx, Root, Type, createContext, inject, jsxRenderer, jsxRendererSync, provide, unprovide };
|
package/dist/index.js
CHANGED
|
@@ -486,7 +486,7 @@ const createNode = (nodeName) => {
|
|
|
486
486
|
nodeName,
|
|
487
487
|
attributes: Object.create(null),
|
|
488
488
|
childNodes: [],
|
|
489
|
-
parentNode:
|
|
489
|
+
parentNode: null
|
|
490
490
|
};
|
|
491
491
|
};
|
|
492
492
|
/**
|
|
@@ -524,7 +524,7 @@ const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
|
|
|
524
524
|
* Does nothing if `removeNode` is not a direct child of `node`.
|
|
525
525
|
*/
|
|
526
526
|
const removeChildNode = (node, removeNode) => {
|
|
527
|
-
removeNode.parentNode =
|
|
527
|
+
removeNode.parentNode = null;
|
|
528
528
|
const index = node.childNodes.indexOf(removeNode);
|
|
529
529
|
if (index >= 0) node.childNodes.splice(index, 1);
|
|
530
530
|
};
|
|
@@ -541,7 +541,7 @@ const createTextNode = (text) => {
|
|
|
541
541
|
return {
|
|
542
542
|
nodeName: TEXT_NODE_NAME,
|
|
543
543
|
nodeValue: text,
|
|
544
|
-
parentNode:
|
|
544
|
+
parentNode: null
|
|
545
545
|
};
|
|
546
546
|
};
|
|
547
547
|
/**
|
|
@@ -18405,8 +18405,14 @@ const jsxRenderer = () => {
|
|
|
18405
18405
|
get files() {
|
|
18406
18406
|
return runtime.nodes;
|
|
18407
18407
|
},
|
|
18408
|
+
dispose() {
|
|
18409
|
+
runtime.unmount();
|
|
18410
|
+
},
|
|
18408
18411
|
unmount(error) {
|
|
18409
18412
|
runtime.unmount(error);
|
|
18413
|
+
},
|
|
18414
|
+
[Symbol.dispose]() {
|
|
18415
|
+
this.dispose();
|
|
18410
18416
|
}
|
|
18411
18417
|
};
|
|
18412
18418
|
};
|
|
@@ -18448,7 +18454,11 @@ const jsxRendererSync = () => {
|
|
|
18448
18454
|
stream(element) {
|
|
18449
18455
|
return runtime.stream(element);
|
|
18450
18456
|
},
|
|
18451
|
-
|
|
18457
|
+
dispose() {},
|
|
18458
|
+
unmount(_error) {},
|
|
18459
|
+
[Symbol.dispose]() {
|
|
18460
|
+
this.dispose();
|
|
18461
|
+
}
|
|
18452
18462
|
};
|
|
18453
18463
|
};
|
|
18454
18464
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as __name } from "./chunk-Bb7HlUDG.js";
|
|
2
|
-
import { h as KubbReactNode, m as KubbReactElement } from "./types-
|
|
3
|
-
import { t as JSX } from "./jsx-namespace-
|
|
2
|
+
import { h as KubbReactNode, m as KubbReactElement } from "./types-D3-ni438.js";
|
|
3
|
+
import { t as JSX } from "./jsx-namespace-C7dcxEyT.js";
|
|
4
4
|
import * as _$react from "react";
|
|
5
5
|
import * as React$1 from "react/jsx-runtime";
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __name } from "./chunk-Bb7HlUDG.js";
|
|
2
|
-
import { _ as KubbTextProps, c as KubbConstProps, d as KubbFunctionProps, f as KubbImportProps, g as KubbSourceProps, h as KubbReactNode, l as KubbExportProps, m as KubbReactElement, p as KubbJsxProps, s as KubbArrowFunctionProps, u as KubbFileProps, v as KubbTypeProps, y as LineBreakProps } from "./types-
|
|
2
|
+
import { _ as KubbTextProps, c as KubbConstProps, d as KubbFunctionProps, f as KubbImportProps, g as KubbSourceProps, h as KubbReactNode, l as KubbExportProps, m as KubbReactElement, p as KubbJsxProps, s as KubbArrowFunctionProps, u as KubbFileProps, v as KubbTypeProps, y as LineBreakProps } from "./types-D3-ni438.js";
|
|
3
3
|
import React from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/jsx-namespace.d.ts
|
|
@@ -36,4 +36,4 @@ declare namespace JSX$1 {
|
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
38
|
export { JSX$1 as t };
|
|
39
|
-
//# sourceMappingURL=jsx-namespace-
|
|
39
|
+
//# sourceMappingURL=jsx-namespace-C7dcxEyT.d.ts.map
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as __name } from "./chunk-Bb7HlUDG.js";
|
|
2
|
-
import { h as KubbReactNode, m as KubbReactElement } from "./types-
|
|
3
|
-
import { t as JSX } from "./jsx-namespace-
|
|
2
|
+
import { h as KubbReactNode, m as KubbReactElement } from "./types-D3-ni438.js";
|
|
3
|
+
import { t as JSX } from "./jsx-namespace-C7dcxEyT.js";
|
|
4
4
|
import * as _$react from "react";
|
|
5
5
|
import * as React$1 from "react/jsx-runtime";
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ type Key = string | number | bigint;
|
|
|
13
13
|
*/
|
|
14
14
|
type ElementNames = 'br' | 'div' | 'indent' | 'dedent' | 'kubb-jsx' | 'kubb-text' | 'kubb-file' | 'kubb-source' | 'kubb-import' | 'kubb-export' | 'kubb-function' | 'kubb-arrow-function' | 'kubb-const' | 'kubb-type' | 'kubb-root' | 'kubb-app';
|
|
15
15
|
type Node = {
|
|
16
|
-
parentNode: DOMElement |
|
|
16
|
+
parentNode: DOMElement | null;
|
|
17
17
|
internal_static?: boolean;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
@@ -165,4 +165,4 @@ type JSDoc = {
|
|
|
165
165
|
};
|
|
166
166
|
//#endregion
|
|
167
167
|
export { KubbTextProps as _, JSDoc as a, TextNode as b, KubbConstProps as c, KubbFunctionProps as d, KubbImportProps as f, KubbSourceProps as g, KubbReactNode as h, ElementNames as i, KubbExportProps as l, KubbReactElement as m, DOMNode as n, Key as o, KubbJsxProps as p, DOMNodeAttribute as r, KubbArrowFunctionProps as s, DOMElement as t, KubbFileProps as u, KubbTypeProps as v, LineBreakProps as y };
|
|
168
|
-
//# sourceMappingURL=types-
|
|
168
|
+
//# sourceMappingURL=types-D3-ni438.d.ts.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as KubbTextProps, a as JSDoc, b as TextNode, c as KubbConstProps, d as KubbFunctionProps, f as KubbImportProps, g as KubbSourceProps, h as KubbReactNode, i as ElementNames, l as KubbExportProps, m as KubbReactElement, n as DOMNode, o as Key, p as KubbJsxProps, r as DOMNodeAttribute, s as KubbArrowFunctionProps, t as DOMElement, u as KubbFileProps, v as KubbTypeProps, y as LineBreakProps } from "./types-
|
|
1
|
+
import { _ as KubbTextProps, a as JSDoc, b as TextNode, c as KubbConstProps, d as KubbFunctionProps, f as KubbImportProps, g as KubbSourceProps, h as KubbReactNode, i as ElementNames, l as KubbExportProps, m as KubbReactElement, n as DOMNode, o as Key, p as KubbJsxProps, r as DOMNodeAttribute, s as KubbArrowFunctionProps, t as DOMElement, u as KubbFileProps, v as KubbTypeProps, y as LineBreakProps } from "./types-D3-ni438.js";
|
|
2
2
|
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, JSDoc, Key, KubbArrowFunctionProps, KubbConstProps, KubbExportProps, KubbFileProps, KubbFunctionProps, KubbImportProps, KubbJsxProps, KubbReactElement, KubbReactNode, KubbSourceProps, KubbTextProps, KubbTypeProps, LineBreakProps, TextNode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/renderer-jsx",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.22",
|
|
4
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
6
|
"codegen",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"registry": "https://registry.npmjs.org/"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@kubb/ast": "5.0.0-beta.
|
|
78
|
+
"@kubb/ast": "5.0.0-beta.22"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@types/react": "^19.2.14",
|
package/src/components/File.tsx
CHANGED
|
@@ -41,12 +41,14 @@ type Props<TMeta> = BaseProps & {
|
|
|
41
41
|
meta?: TMeta
|
|
42
42
|
/**
|
|
43
43
|
* Text prepended to the generated file content before any source blocks.
|
|
44
|
+
* Accepts `null` so `resolver.resolveBanner()` results can be passed directly.
|
|
44
45
|
*/
|
|
45
|
-
banner?: string
|
|
46
|
+
banner?: string | null
|
|
46
47
|
/**
|
|
47
48
|
* Text appended to the generated file content after all source blocks.
|
|
49
|
+
* Accepts `null` so `resolver.resolveFooter()` results can be passed directly.
|
|
48
50
|
*/
|
|
49
|
-
footer?: string
|
|
51
|
+
footer?: string | null
|
|
50
52
|
/**
|
|
51
53
|
* Child nodes rendered as the content of this file (source blocks, imports, exports).
|
|
52
54
|
*/
|
package/src/createRenderer.tsx
CHANGED
|
@@ -30,9 +30,15 @@ export const jsxRenderer = () => {
|
|
|
30
30
|
get files() {
|
|
31
31
|
return runtime.nodes
|
|
32
32
|
},
|
|
33
|
+
dispose() {
|
|
34
|
+
runtime.unmount()
|
|
35
|
+
},
|
|
33
36
|
unmount(error?: Error | number | null) {
|
|
34
37
|
runtime.unmount(error)
|
|
35
38
|
},
|
|
39
|
+
[Symbol.dispose]() {
|
|
40
|
+
this.dispose()
|
|
41
|
+
},
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
|
|
@@ -75,6 +81,10 @@ export const jsxRendererSync = () => {
|
|
|
75
81
|
stream(element: KubbReactElement): Generator<FileNode> {
|
|
76
82
|
return runtime.stream(element)
|
|
77
83
|
},
|
|
84
|
+
dispose() {},
|
|
78
85
|
unmount(_error?: Error | number | null) {},
|
|
86
|
+
[Symbol.dispose]() {
|
|
87
|
+
this.dispose()
|
|
88
|
+
},
|
|
79
89
|
}
|
|
80
90
|
}
|
package/src/dom.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const createNode = (nodeName: string): DOMElement => {
|
|
|
10
10
|
nodeName: nodeName as DOMElement['nodeName'],
|
|
11
11
|
attributes: Object.create(null) as Record<string, DOMNodeAttribute>,
|
|
12
12
|
childNodes: [],
|
|
13
|
-
parentNode:
|
|
13
|
+
parentNode: null,
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -59,7 +59,7 @@ export const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, before
|
|
|
59
59
|
* Does nothing if `removeNode` is not a direct child of `node`.
|
|
60
60
|
*/
|
|
61
61
|
export const removeChildNode = (node: DOMElement, removeNode: DOMNode): void => {
|
|
62
|
-
removeNode.parentNode =
|
|
62
|
+
removeNode.parentNode = null
|
|
63
63
|
|
|
64
64
|
const index = node.childNodes.indexOf(removeNode)
|
|
65
65
|
if (index >= 0) {
|
|
@@ -81,7 +81,7 @@ export const createTextNode = (text: string): TextNode => {
|
|
|
81
81
|
return {
|
|
82
82
|
nodeName: TEXT_NODE_NAME,
|
|
83
83
|
nodeValue: text,
|
|
84
|
-
parentNode:
|
|
84
|
+
parentNode: null,
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|