@kubb/renderer-jsx 5.0.0-beta.42 → 5.0.0-beta.43
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/chunk-C0LytTxp.js +8 -0
- package/dist/index.cjs +167 -18132
- package/dist/index.d.ts +15 -166
- package/dist/index.js +152 -18107
- package/dist/jsx-dev-runtime.cjs +3 -10
- package/dist/jsx-dev-runtime.d.ts +3 -6
- package/dist/jsx-dev-runtime.js +1 -9
- package/dist/jsx-runtime-CzH00oSR.cjs +64 -0
- package/dist/jsx-runtime.cjs +5 -14
- package/dist/jsx-runtime.d.ts +59 -8
- package/dist/jsx-runtime.js +24 -7
- package/dist/types-DBdp_5qR.d.ts +116 -0
- package/dist/types.d.ts +2 -2
- package/package.json +4 -23
- package/src/SyncRuntime.tsx +5 -5
- package/src/constants.ts +0 -29
- package/src/createRenderer.tsx +10 -66
- package/src/globals.ts +14 -6
- package/src/index.ts +1 -4
- 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 +14 -98
- package/dist/chunk-DoukXa0m.js +0 -28
- package/dist/jsx-namespace-dmStM1a2.d.ts +0 -39
- package/dist/jsx-runtime-4M1bV6ub.cjs +0 -1503
- package/dist/jsx-runtime-CQ6-_gue.js +0 -1448
- package/dist/types-B5VGpHs0.d.ts +0 -169
- package/src/Renderer.ts +0 -180
- package/src/Runtime.tsx +0 -159
- package/src/components/CodeBlock.tsx +0 -37
- package/src/components/Root.tsx +0 -70
- package/src/dom.ts +0 -93
- package/src/utils.ts +0 -246
package/src/jsx-dev-runtime.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import * as React from 'react/jsx-runtime'
|
|
2
1
|
import type { KubbReactElement, KubbReactNode } from './types.ts'
|
|
3
2
|
|
|
4
|
-
export
|
|
5
|
-
export const jsxDEV = React.jsx
|
|
3
|
+
export { Fragment, jsxDEV } from './jsx-runtime.ts'
|
|
6
4
|
|
|
7
5
|
export type * from './jsx-namespace.d.ts'
|
|
8
6
|
|
package/src/jsx-namespace.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type React from 'react'
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
KubbArrowFunctionProps,
|
|
5
3
|
KubbConstProps,
|
|
@@ -11,29 +9,42 @@ import type {
|
|
|
11
9
|
KubbReactElement,
|
|
12
10
|
KubbReactNode,
|
|
13
11
|
KubbSourceProps,
|
|
14
|
-
KubbTextProps,
|
|
15
12
|
KubbTypeProps,
|
|
13
|
+
Key,
|
|
16
14
|
LineBreakProps,
|
|
17
15
|
} from './types'
|
|
18
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`, `indent`, and `dedent`, and supports
|
|
22
|
+
* pure function components, so the HTML element and class-component machinery
|
|
23
|
+
* from `@types/react` is not needed.
|
|
24
|
+
*/
|
|
19
25
|
export namespace JSX {
|
|
20
|
-
type ElementType =
|
|
26
|
+
type ElementType = string | ((props: any) => KubbReactNode)
|
|
21
27
|
type Element = KubbReactElement
|
|
22
28
|
|
|
23
|
-
interface ElementClass
|
|
29
|
+
interface ElementClass {
|
|
24
30
|
render(): KubbReactNode
|
|
25
31
|
}
|
|
26
32
|
interface ElementAttributesProperty {
|
|
27
33
|
props: {}
|
|
28
34
|
}
|
|
29
|
-
|
|
30
35
|
interface ElementChildrenAttribute {
|
|
31
36
|
children: {}
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
interface
|
|
39
|
+
interface IntrinsicAttributes {
|
|
40
|
+
key?: Key | null
|
|
41
|
+
}
|
|
42
|
+
interface IntrinsicClassAttributes<T> {
|
|
43
|
+
key?: Key | null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface IntrinsicElements {
|
|
35
47
|
'kubb-jsx': KubbJsxProps
|
|
36
|
-
'kubb-text': KubbTextProps
|
|
37
48
|
'kubb-file': KubbFileProps
|
|
38
49
|
'kubb-source': KubbSourceProps
|
|
39
50
|
'kubb-import': KubbImportProps
|
|
@@ -43,10 +54,7 @@ export namespace JSX {
|
|
|
43
54
|
'kubb-const': KubbConstProps
|
|
44
55
|
'kubb-type': KubbTypeProps
|
|
45
56
|
br: LineBreakProps
|
|
46
|
-
indent: {}
|
|
47
|
-
dedent: {}
|
|
48
57
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
|
|
58
|
+
|
|
59
|
+
type LibraryManagedAttributes<C, P> = P
|
|
52
60
|
}
|
package/src/jsx-runtime.ts
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { KubbReactElement, KubbReactNode } from './types.ts'
|
|
1
|
+
import type { Key, KubbReactElement, KubbReactNode } from './types.ts'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 element carries a
|
|
14
|
+
* `$$typeof` marker, its `type` (a host string, a function component, or
|
|
15
|
+
* `Fragment`), and its `props`, with children included.
|
|
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
|
|
8
24
|
|
|
9
25
|
export type * from './jsx-namespace.d.ts'
|
|
10
26
|
|
package/src/types.ts
CHANGED
|
@@ -1,103 +1,26 @@
|
|
|
1
1
|
import type { ArrowFunctionNode, ConstNode, ExportNode, FileNode, FunctionNode, ImportNode, SourceNode, TypeNode } from '@kubb/ast'
|
|
2
|
-
import type React from 'react'
|
|
3
|
-
import type { JSX, ReactNode } from 'react'
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
|
-
* Unique
|
|
4
|
+
* Unique key for a Kubb JSX element in lists or conditional renders.
|
|
7
5
|
*/
|
|
8
6
|
export type Key = string | number | bigint
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Element produced by a Kubb JSX component. It carries the host or component
|
|
10
|
+
* `type`, its `props`, and an optional list `key`. The renderer walks these at
|
|
11
|
+
* runtime, so the fields stay opaque to type-checking.
|
|
13
12
|
*/
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
|
18
|
-
| 'dedent'
|
|
19
|
-
| 'kubb-jsx'
|
|
20
|
-
| 'kubb-text'
|
|
21
|
-
| 'kubb-file'
|
|
22
|
-
| 'kubb-source'
|
|
23
|
-
| 'kubb-import'
|
|
24
|
-
| 'kubb-export'
|
|
25
|
-
| 'kubb-function'
|
|
26
|
-
| 'kubb-arrow-function'
|
|
27
|
-
| 'kubb-const'
|
|
28
|
-
| 'kubb-type'
|
|
29
|
-
| 'kubb-root'
|
|
30
|
-
| 'kubb-app'
|
|
31
|
-
|
|
32
|
-
type Node = {
|
|
33
|
-
parentNode: DOMElement | null
|
|
34
|
-
internal_static?: boolean
|
|
13
|
+
export type KubbReactElement = {
|
|
14
|
+
type: unknown
|
|
15
|
+
props: unknown
|
|
16
|
+
key: Key | null
|
|
35
17
|
}
|
|
36
18
|
|
|
37
19
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
export type DOMNodeAttribute = boolean | string | number | null | Record<string, unknown> | Array<unknown>
|
|
42
|
-
|
|
43
|
-
type TextName = '#text'
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Leaf DOM node containing raw text.
|
|
47
|
-
*/
|
|
48
|
-
export type TextNode = {
|
|
49
|
-
nodeName: TextName
|
|
50
|
-
nodeValue: string
|
|
51
|
-
} & Node
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Virtual DOM node, either a text node or a named element.
|
|
55
|
-
*/
|
|
56
|
-
export type DOMNode<T = { nodeName: NodeNames }> = T extends {
|
|
57
|
-
nodeName: infer U
|
|
58
|
-
}
|
|
59
|
-
? U extends '#text'
|
|
60
|
-
? TextNode
|
|
61
|
-
: DOMElement
|
|
62
|
-
: never
|
|
63
|
-
|
|
64
|
-
type OutputTransformer = (s: string, index: number) => string
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Named element in the Kubb virtual DOM tree.
|
|
68
|
-
* Stores attributes, child nodes, and lifecycle callbacks for rendering.
|
|
69
|
-
*/
|
|
70
|
-
export type DOMElement = {
|
|
71
|
-
nodeName: ElementNames
|
|
72
|
-
/**
|
|
73
|
-
* Key/value attributes passed as JSX props to this element.
|
|
74
|
-
*/
|
|
75
|
-
attributes: Record<string, DOMNodeAttribute>
|
|
76
|
-
/**
|
|
77
|
-
* Ordered list of child nodes attached to this element.
|
|
78
|
-
*/
|
|
79
|
-
childNodes: Array<DOMNode>
|
|
80
|
-
internal_transform?: OutputTransformer
|
|
81
|
-
|
|
82
|
-
// Internal properties
|
|
83
|
-
isStaticDirty?: boolean
|
|
84
|
-
staticNode?: DOMElement
|
|
85
|
-
onComputeLayout?: () => void
|
|
86
|
-
onRender?: () => void
|
|
87
|
-
onImmediateRender?: () => void
|
|
88
|
-
} & Node
|
|
89
|
-
|
|
90
|
-
type NodeNames = ElementNames | TextName
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* React node type for Kubb JSX components.
|
|
20
|
+
* Anything a Kubb JSX component accepts as children: an element, a primitive
|
|
21
|
+
* rendered as text, a nullish value that is skipped, or an iterable of nodes.
|
|
94
22
|
*/
|
|
95
|
-
export type KubbReactNode =
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* React element type returned by Kubb JSX components.
|
|
99
|
-
*/
|
|
100
|
-
export type KubbReactElement = JSX.Element
|
|
23
|
+
export type KubbReactNode = KubbReactElement | string | number | bigint | boolean | null | undefined | Iterable<KubbReactNode>
|
|
101
24
|
|
|
102
25
|
/**
|
|
103
26
|
* Props for the `<kubb-jsx>` element.
|
|
@@ -107,14 +30,6 @@ export type KubbJsxProps = {
|
|
|
107
30
|
children?: string
|
|
108
31
|
}
|
|
109
32
|
|
|
110
|
-
/**
|
|
111
|
-
* Props for the `<kubb-text>` element.
|
|
112
|
-
* Wraps React children as plain text in the output.
|
|
113
|
-
*/
|
|
114
|
-
export type KubbTextProps = {
|
|
115
|
-
children?: KubbReactNode
|
|
116
|
-
}
|
|
117
|
-
|
|
118
33
|
/**
|
|
119
34
|
* Props for the `<kubb-file>` element.
|
|
120
35
|
* Represents a generated file.
|
|
@@ -181,9 +96,10 @@ export type KubbTypeProps = Omit<TypeNode, 'kind'> & {
|
|
|
181
96
|
}
|
|
182
97
|
|
|
183
98
|
/**
|
|
184
|
-
* Props for the
|
|
99
|
+
* Props for the `<br>` element. It emits a single line break and takes no
|
|
100
|
+
* attributes of its own.
|
|
185
101
|
*/
|
|
186
|
-
export type LineBreakProps =
|
|
102
|
+
export type LineBreakProps = {}
|
|
187
103
|
|
|
188
104
|
/**
|
|
189
105
|
* JSDoc comment block to attach to a generated declaration.
|
package/dist/chunk-DoukXa0m.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
5
|
-
value,
|
|
6
|
-
configurable: true
|
|
7
|
-
});
|
|
8
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
-
key = keys[i];
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
-
get: ((k) => from[k]).bind(null, key),
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
-
value: mod,
|
|
25
|
-
enumerable: true
|
|
26
|
-
}) : target, mod));
|
|
27
|
-
//#endregion
|
|
28
|
-
export { __name as n, __toESM as r, __commonJSMin as t };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { n as __name } from "./chunk-DoukXa0m.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-B5VGpHs0.js";
|
|
3
|
-
import React from "react";
|
|
4
|
-
|
|
5
|
-
//#region src/jsx-namespace.d.ts
|
|
6
|
-
declare namespace JSX$1 {
|
|
7
|
-
type ElementType = React.JSX.ElementType;
|
|
8
|
-
type Element = KubbReactElement;
|
|
9
|
-
interface ElementClass extends React.JSX.ElementClass {
|
|
10
|
-
render(): KubbReactNode;
|
|
11
|
-
}
|
|
12
|
-
interface ElementAttributesProperty {
|
|
13
|
-
props: {};
|
|
14
|
-
}
|
|
15
|
-
interface ElementChildrenAttribute {
|
|
16
|
-
children: {};
|
|
17
|
-
}
|
|
18
|
-
interface IntrinsicElements extends React.JSX.IntrinsicElements {
|
|
19
|
-
'kubb-jsx': KubbJsxProps;
|
|
20
|
-
'kubb-text': KubbTextProps;
|
|
21
|
-
'kubb-file': KubbFileProps;
|
|
22
|
-
'kubb-source': KubbSourceProps;
|
|
23
|
-
'kubb-import': KubbImportProps;
|
|
24
|
-
'kubb-export': KubbExportProps;
|
|
25
|
-
'kubb-function': KubbFunctionProps;
|
|
26
|
-
'kubb-arrow-function': KubbArrowFunctionProps;
|
|
27
|
-
'kubb-const': KubbConstProps;
|
|
28
|
-
'kubb-type': KubbTypeProps;
|
|
29
|
-
br: LineBreakProps;
|
|
30
|
-
indent: {};
|
|
31
|
-
dedent: {};
|
|
32
|
-
}
|
|
33
|
-
type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>;
|
|
34
|
-
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
|
|
35
|
-
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
export { JSX$1 as t };
|
|
39
|
-
//# sourceMappingURL=jsx-namespace-dmStM1a2.d.ts.map
|