@kubb/react-fabric 0.12.5 → 0.12.6
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/globals.d.cts +8 -8
- package/dist/globals.d.ts +8 -8
- package/dist/index.cjs +36 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -39
- package/dist/index.d.ts +24 -39
- package/dist/index.js +43 -64
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +6 -6
- package/dist/jsx-dev-runtime.d.ts +6 -6
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/{jsx-namespace-fB1bxOIg.d.ts → jsx-namespace-BMpcDF6T.d.ts} +8 -8
- package/dist/{jsx-namespace-r-JXq_rp.d.cts → jsx-namespace-BdDNwAgO.d.cts} +8 -8
- package/dist/jsx-runtime-6sQc68DD.cjs.map +1 -1
- package/dist/jsx-runtime-CpElaHq6.js.map +1 -1
- package/dist/jsx-runtime.d.cts +6 -6
- package/dist/jsx-runtime.d.ts +6 -6
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.d.cts +1 -1
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +1 -1
- package/dist/{reactPlugin-Dgs9o4KK.js → reactPlugin-C7_IY8_K.js} +5 -3
- package/dist/reactPlugin-C7_IY8_K.js.map +1 -0
- package/dist/{reactPlugin-ROpqWeoY.cjs → reactPlugin-DbTz9RKJ.cjs} +5 -3
- package/dist/reactPlugin-DbTz9RKJ.cjs.map +1 -0
- package/dist/{reactPlugin-B8VMf0BQ.d.ts → reactPlugin-Dl5F1rQk.d.ts} +6 -5
- package/dist/{reactPlugin-I53HUDXu.d.cts → reactPlugin-fdJaWnpd.d.cts} +6 -5
- package/dist/{types-XiObCuPy.d.ts → types-BKnc-nPE.d.ts} +15 -15
- package/dist/{types-J_S-h-Ae.d.cts → types-K0AHi-aU.d.cts} +15 -15
- package/dist/types.d.cts +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +3 -3
- package/src/Renderer.ts +2 -2
- package/src/Runtime.tsx +6 -4
- package/src/components/App.tsx +4 -4
- package/src/components/Const.tsx +4 -4
- package/src/components/File.tsx +11 -11
- package/src/components/Function.tsx +5 -5
- package/src/components/Root.tsx +7 -7
- package/src/components/Type.tsx +4 -4
- package/src/composables/useLifecycle.tsx +1 -19
- package/src/devtools.ts +2 -2
- package/src/globals.ts +17 -8
- package/src/index.ts +1 -6
- package/src/jsx-dev-runtime.ts +3 -3
- package/src/jsx-namespace.d.ts +8 -8
- package/src/jsx-runtime.ts +3 -3
- package/src/plugins/reactPlugin.ts +5 -5
- package/src/types.ts +24 -15
- package/dist/reactPlugin-Dgs9o4KK.js.map +0 -1
- package/dist/reactPlugin-ROpqWeoY.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as __name } from "./chunk-CrnDzoTS.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as FabricReactElement, h as types_d_exports } from "./types-BKnc-nPE.js";
|
|
3
3
|
import { TreeNode } from "@kubb/fabric-core";
|
|
4
4
|
|
|
5
5
|
//#region ../fabric-core/src/KubbFile.d.ts
|
|
@@ -250,6 +250,7 @@ interface FabricOptions {
|
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
252
252
|
* Available modes for file processing.
|
|
253
|
+
* @default 'sequential'
|
|
253
254
|
*/
|
|
254
255
|
type FabricMode = 'sequential' | 'parallel';
|
|
255
256
|
/**
|
|
@@ -442,15 +443,15 @@ type Options = {
|
|
|
442
443
|
debug?: boolean;
|
|
443
444
|
};
|
|
444
445
|
type ExtendOptions = {
|
|
445
|
-
render(App:
|
|
446
|
-
renderToString(App:
|
|
446
|
+
render(App: FabricReactElement): Promise<void>;
|
|
447
|
+
renderToString(App: FabricReactElement): Promise<string>;
|
|
447
448
|
waitUntilExit(): Promise<void>;
|
|
448
449
|
};
|
|
449
450
|
declare global {
|
|
450
451
|
namespace Kubb {
|
|
451
452
|
interface Fabric {
|
|
452
|
-
render(App:
|
|
453
|
-
renderToString(App:
|
|
453
|
+
render(App: FabricReactElement): Promise<void>;
|
|
454
|
+
renderToString(App: FabricReactElement): Promise<string>;
|
|
454
455
|
waitUntilExit(): Promise<void>;
|
|
455
456
|
}
|
|
456
457
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as __name,
|
|
1
|
+
import { b as __name, c as FabricReactElement, h as types_d_exports } from "./types-K0AHi-aU.cjs";
|
|
2
2
|
import { TreeNode } from "@kubb/fabric-core";
|
|
3
3
|
|
|
4
4
|
//#region ../fabric-core/src/KubbFile.d.ts
|
|
@@ -249,6 +249,7 @@ interface FabricOptions {
|
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
251
251
|
* Available modes for file processing.
|
|
252
|
+
* @default 'sequential'
|
|
252
253
|
*/
|
|
253
254
|
type FabricMode = 'sequential' | 'parallel';
|
|
254
255
|
/**
|
|
@@ -441,15 +442,15 @@ type Options = {
|
|
|
441
442
|
debug?: boolean;
|
|
442
443
|
};
|
|
443
444
|
type ExtendOptions = {
|
|
444
|
-
render(App:
|
|
445
|
-
renderToString(App:
|
|
445
|
+
render(App: FabricReactElement): Promise<void>;
|
|
446
|
+
renderToString(App: FabricReactElement): Promise<string>;
|
|
446
447
|
waitUntilExit(): Promise<void>;
|
|
447
448
|
};
|
|
448
449
|
declare global {
|
|
449
450
|
namespace Kubb {
|
|
450
451
|
interface Fabric {
|
|
451
|
-
render(App:
|
|
452
|
-
renderToString(App:
|
|
452
|
+
render(App: FabricReactElement): Promise<void>;
|
|
453
|
+
renderToString(App: FabricReactElement): Promise<string>;
|
|
453
454
|
waitUntilExit(): Promise<void>;
|
|
454
455
|
}
|
|
455
456
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as __reExport, n as __exportAll, r as __name } from "./chunk-CrnDzoTS.js";
|
|
2
2
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
3
|
-
import React, { JSX,
|
|
3
|
+
import React, { JSX, ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/getFunctionParams.d.ts
|
|
6
6
|
type Param = {
|
|
@@ -47,11 +47,11 @@ declare class FunctionParams {
|
|
|
47
47
|
toConstructor(): string;
|
|
48
48
|
}
|
|
49
49
|
declare namespace types_d_exports {
|
|
50
|
-
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames,
|
|
50
|
+
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricExportProps, FabricFileProps, FabricImportProps, FabricReactElement, FabricReactNode, FabricSourceProps, FabricTextProps, Key, LineBreakProps, Param, Params, TextNode };
|
|
51
51
|
}
|
|
52
52
|
import * as import__kubb_fabric_core_types from "@kubb/fabric-core/types";
|
|
53
|
-
type
|
|
54
|
-
type ElementNames =
|
|
53
|
+
type Key = string | number | bigint;
|
|
54
|
+
type ElementNames = 'br' | 'div' | 'indent' | 'dedent' | 'kubb-text' | 'kubb-file' | 'kubb-source' | 'kubb-import' | 'kubb-export' | 'kubb-root' | 'kubb-app';
|
|
55
55
|
type Node = {
|
|
56
56
|
parentNode: DOMElement | undefined;
|
|
57
57
|
internal_static?: boolean;
|
|
@@ -80,24 +80,24 @@ type DOMElement = {
|
|
|
80
80
|
onImmediateRender?: () => void;
|
|
81
81
|
} & Node;
|
|
82
82
|
type NodeNames = ElementNames | TextName;
|
|
83
|
-
type
|
|
84
|
-
type
|
|
85
|
-
type
|
|
86
|
-
children?:
|
|
83
|
+
type FabricReactNode = ReactNode;
|
|
84
|
+
type FabricReactElement = JSX.Element;
|
|
85
|
+
type FabricTextProps = {
|
|
86
|
+
children?: FabricReactNode;
|
|
87
87
|
};
|
|
88
|
-
type
|
|
88
|
+
type FabricFileProps = {
|
|
89
89
|
id?: string;
|
|
90
|
-
children?:
|
|
90
|
+
children?: FabricReactNode;
|
|
91
91
|
baseName: string;
|
|
92
92
|
path: string;
|
|
93
93
|
override?: boolean;
|
|
94
94
|
meta?: KubbFile.File['meta'];
|
|
95
95
|
};
|
|
96
|
-
type
|
|
97
|
-
children?:
|
|
96
|
+
type FabricSourceProps = KubbFile.Source & {
|
|
97
|
+
children?: FabricReactNode;
|
|
98
98
|
};
|
|
99
|
-
type
|
|
100
|
-
type
|
|
99
|
+
type FabricImportProps = KubbFile.Import;
|
|
100
|
+
type FabricExportProps = KubbFile.Export;
|
|
101
101
|
type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
|
|
102
102
|
//#endregion
|
|
103
|
-
export { Param as _,
|
|
103
|
+
export { Param as _, FabricExportProps as a, FabricReactElement as c, FabricTextProps as d, Key as f, FunctionParams as g, types_d_exports as h, ElementNames as i, FabricReactNode as l, TextNode as m, DOMNode as n, FabricFileProps as o, LineBreakProps as p, DOMNodeAttribute as r, FabricImportProps as s, DOMElement as t, FabricSourceProps as u, Params as v, createFunctionParams as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { JSX,
|
|
1
|
+
import React, { JSX, ReactNode } from "react";
|
|
2
2
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
3
3
|
|
|
4
4
|
//#region rolldown:runtime
|
|
@@ -48,11 +48,11 @@ declare class FunctionParams {
|
|
|
48
48
|
toConstructor(): string;
|
|
49
49
|
}
|
|
50
50
|
declare namespace types_d_exports {
|
|
51
|
-
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames,
|
|
51
|
+
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricExportProps, FabricFileProps, FabricImportProps, FabricReactElement, FabricReactNode, FabricSourceProps, FabricTextProps, Key, LineBreakProps, Param, Params, TextNode };
|
|
52
52
|
}
|
|
53
53
|
import * as import__kubb_fabric_core_types from "@kubb/fabric-core/types";
|
|
54
|
-
type
|
|
55
|
-
type ElementNames =
|
|
54
|
+
type Key = string | number | bigint;
|
|
55
|
+
type ElementNames = 'br' | 'div' | 'indent' | 'dedent' | 'kubb-text' | 'kubb-file' | 'kubb-source' | 'kubb-import' | 'kubb-export' | 'kubb-root' | 'kubb-app';
|
|
56
56
|
type Node = {
|
|
57
57
|
parentNode: DOMElement | undefined;
|
|
58
58
|
internal_static?: boolean;
|
|
@@ -81,24 +81,24 @@ type DOMElement = {
|
|
|
81
81
|
onImmediateRender?: () => void;
|
|
82
82
|
} & Node;
|
|
83
83
|
type NodeNames = ElementNames | TextName;
|
|
84
|
-
type
|
|
85
|
-
type
|
|
86
|
-
type
|
|
87
|
-
children?:
|
|
84
|
+
type FabricReactNode = ReactNode;
|
|
85
|
+
type FabricReactElement = JSX.Element;
|
|
86
|
+
type FabricTextProps = {
|
|
87
|
+
children?: FabricReactNode;
|
|
88
88
|
};
|
|
89
|
-
type
|
|
89
|
+
type FabricFileProps = {
|
|
90
90
|
id?: string;
|
|
91
|
-
children?:
|
|
91
|
+
children?: FabricReactNode;
|
|
92
92
|
baseName: string;
|
|
93
93
|
path: string;
|
|
94
94
|
override?: boolean;
|
|
95
95
|
meta?: KubbFile.File['meta'];
|
|
96
96
|
};
|
|
97
|
-
type
|
|
98
|
-
children?:
|
|
97
|
+
type FabricSourceProps = KubbFile.Source & {
|
|
98
|
+
children?: FabricReactNode;
|
|
99
99
|
};
|
|
100
|
-
type
|
|
101
|
-
type
|
|
100
|
+
type FabricImportProps = KubbFile.Import;
|
|
101
|
+
type FabricExportProps = KubbFile.Export;
|
|
102
102
|
type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
|
|
103
103
|
//#endregion
|
|
104
|
-
export { Param as _,
|
|
104
|
+
export { Param as _, FabricExportProps as a, __name as b, FabricReactElement as c, FabricTextProps as d, Key as f, FunctionParams as g, types_d_exports as h, ElementNames as i, FabricReactNode as l, TextNode as m, DOMNode as n, FabricFileProps as o, LineBreakProps as p, DOMNodeAttribute as r, FabricImportProps as s, DOMElement as t, FabricSourceProps as u, Params as v, createFunctionParams as y };
|
package/dist/types.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as Param, a as
|
|
1
|
+
import { _ as Param, a as FabricExportProps, c as FabricReactElement, d as FabricTextProps, f as Key, i as ElementNames, l as FabricReactNode, m as TextNode, n as DOMNode, o as FabricFileProps, p as LineBreakProps, r as DOMNodeAttribute, s as FabricImportProps, t as DOMElement, u as FabricSourceProps, v as Params } from "./types-K0AHi-aU.cjs";
|
|
2
2
|
export * from "@kubb/fabric-core/types";
|
|
3
|
-
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames,
|
|
3
|
+
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricExportProps, FabricFileProps, FabricImportProps, FabricReactElement, FabricReactNode, FabricSourceProps, FabricTextProps, Key, LineBreakProps, Param, Params, TextNode };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as Param, a as
|
|
1
|
+
import { _ as Param, a as FabricExportProps, c as FabricReactElement, d as FabricTextProps, f as Key, i as ElementNames, l as FabricReactNode, m as TextNode, n as DOMNode, o as FabricFileProps, p as LineBreakProps, r as DOMNodeAttribute, s as FabricImportProps, t as DOMElement, u as FabricSourceProps, v as Params } from "./types-BKnc-nPE.js";
|
|
2
2
|
export * from "@kubb/fabric-core/types";
|
|
3
|
-
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames,
|
|
3
|
+
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricExportProps, FabricFileProps, FabricImportProps, FabricReactElement, FabricReactNode, FabricSourceProps, FabricTextProps, Key, LineBreakProps, Param, Params, TextNode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/react-fabric",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
4
4
|
"description": "React integration for Kubb, providing JSX runtime support and React component generation capabilities for code generation plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -103,10 +103,10 @@
|
|
|
103
103
|
"remeda": "^2.33.4",
|
|
104
104
|
"signal-exit": "^4.1.0",
|
|
105
105
|
"ws": "8.18.0",
|
|
106
|
-
"@kubb/fabric-core": "0.12.
|
|
106
|
+
"@kubb/fabric-core": "0.12.6"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@types/react": "^19.2.
|
|
109
|
+
"@types/react": "^19.2.10",
|
|
110
110
|
"@types/react-reconciler": "0.32.0",
|
|
111
111
|
"@types/ws": "^8.18.1",
|
|
112
112
|
"react": "19.2.3",
|
package/src/Renderer.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { createContext } from 'react'
|
|
|
2
2
|
import Reconciler, { type ReactContext } from 'react-reconciler'
|
|
3
3
|
import { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants.js'
|
|
4
4
|
import { appendChildNode, createNode, createTextNode, insertBeforeNode, removeChildNode, setAttribute, setTextNodeValue } from './dom.ts'
|
|
5
|
-
import type {
|
|
5
|
+
import type { FabricReactNode } from './types'
|
|
6
6
|
import type { DOMElement, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'
|
|
7
7
|
|
|
8
8
|
declare module 'react-reconciler' {
|
|
9
9
|
// @ts-expect-error custom override
|
|
10
10
|
interface Reconciler {
|
|
11
|
-
updateContainerSync(element:
|
|
11
|
+
updateContainerSync(element: FabricReactNode, container: unknown, parentComponent: any, callback?: null | (() => void)): void
|
|
12
12
|
flushSyncWork(): void
|
|
13
13
|
createContainer(
|
|
14
14
|
containerInfo: unknown,
|
package/src/Runtime.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { Root } from './components/Root.tsx'
|
|
|
6
6
|
import { createNode } from './dom.ts'
|
|
7
7
|
import type { FiberRoot } from './Renderer.ts'
|
|
8
8
|
import { Renderer } from './Renderer.ts'
|
|
9
|
-
import type { ComponentNode, DOMElement,
|
|
9
|
+
import type { ComponentNode, DOMElement, FabricReactElement } from './types.ts'
|
|
10
10
|
import { processFiles } from './utils/processFiles.ts'
|
|
11
11
|
import { squashTextNodes } from './utils/squashTextNodes.ts'
|
|
12
12
|
|
|
@@ -133,7 +133,9 @@ export class Runtime {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
onExit(error?: Error): void {
|
|
136
|
-
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
this.unmount(error)
|
|
138
|
+
}, 0)
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
async #getOutput(node: DOMElement): Promise<string> {
|
|
@@ -156,7 +158,7 @@ export class Runtime {
|
|
|
156
158
|
return [...values].join('\n\n')
|
|
157
159
|
}
|
|
158
160
|
|
|
159
|
-
async render(node:
|
|
161
|
+
async render(node: FabricReactElement): Promise<void> {
|
|
160
162
|
const treeNode = this.#options.treeNode || new TreeNode<ComponentNode>({ type: 'Root', props: {} })
|
|
161
163
|
const props = {
|
|
162
164
|
fileManager: this.fileManager,
|
|
@@ -180,7 +182,7 @@ export class Runtime {
|
|
|
180
182
|
}
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
async renderToString(node:
|
|
185
|
+
async renderToString(node: FabricReactElement): Promise<string> {
|
|
184
186
|
const treeNode = this.#options.treeNode || new TreeNode<ComponentNode>({ type: 'Root', props: {} })
|
|
185
187
|
const props = {
|
|
186
188
|
fileManager: this.fileManager,
|
package/src/components/App.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppContext, NodeTreeContext, provide, RootContext, useContext, useNodeTree } from '@kubb/fabric-core'
|
|
2
|
-
import type {
|
|
2
|
+
import type { FabricReactElement, FabricReactNode } from '../types.ts'
|
|
3
3
|
|
|
4
4
|
export type AppProps<TMeta extends object = object> = {
|
|
5
5
|
/**
|
|
@@ -9,13 +9,13 @@ export type AppProps<TMeta extends object = object> = {
|
|
|
9
9
|
/**
|
|
10
10
|
* Children nodes.
|
|
11
11
|
*/
|
|
12
|
-
children?:
|
|
12
|
+
children?: FabricReactNode
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* App container containing the AppContext carrying `meta` and an `exit` hook.
|
|
17
17
|
*/
|
|
18
|
-
export function App<TMeta extends object = object>({ children, ...props }: AppProps<TMeta>):
|
|
18
|
+
export function App<TMeta extends object = object>({ children, ...props }: AppProps<TMeta>): FabricReactElement {
|
|
19
19
|
const { meta = {} } = props
|
|
20
20
|
|
|
21
21
|
const { exit } = useContext(RootContext)
|
|
@@ -33,4 +33,4 @@ export function App<TMeta extends object = object>({ children, ...props }: AppPr
|
|
|
33
33
|
return <>{children}</>
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
App.displayName = '
|
|
36
|
+
App.displayName = 'App'
|
package/src/components/Const.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeTreeContext, provide, useNodeTree } from '@kubb/fabric-core'
|
|
2
|
-
import type {
|
|
2
|
+
import type { FabricReactElement, FabricReactNode, JSDoc, Key } from '../types.ts'
|
|
3
3
|
import { createJSDoc } from '../utils/createJSDoc.ts'
|
|
4
4
|
|
|
5
5
|
export type ConstProps = {
|
|
@@ -27,13 +27,13 @@ export type ConstProps = {
|
|
|
27
27
|
/**
|
|
28
28
|
* Children nodes.
|
|
29
29
|
*/
|
|
30
|
-
children?:
|
|
30
|
+
children?: FabricReactNode
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Generates a TypeScript constant declaration.
|
|
35
35
|
*/
|
|
36
|
-
export function Const({ children, ...props }: ConstProps):
|
|
36
|
+
export function Const({ children, ...props }: ConstProps): FabricReactElement {
|
|
37
37
|
const { name, export: canExport, type, JSDoc, asConst } = props
|
|
38
38
|
|
|
39
39
|
const nodeTree = useNodeTree()
|
|
@@ -66,4 +66,4 @@ export function Const({ children, ...props }: ConstProps): KubbElement {
|
|
|
66
66
|
)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
Const.displayName = '
|
|
69
|
+
Const.displayName = 'Const'
|
package/src/components/File.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileContext, NodeTreeContext, provide, useFile, useFileManager, useNodeTree } from '@kubb/fabric-core'
|
|
2
2
|
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
3
|
-
import type {
|
|
3
|
+
import type { FabricReactElement, FabricReactNode, Key } from '../types.ts'
|
|
4
4
|
|
|
5
5
|
type BasePropsWithBaseName = {
|
|
6
6
|
/**
|
|
@@ -30,13 +30,13 @@ type Props<TMeta> = BaseProps & {
|
|
|
30
30
|
meta?: TMeta
|
|
31
31
|
banner?: string
|
|
32
32
|
footer?: string
|
|
33
|
-
children?:
|
|
33
|
+
children?: FabricReactNode
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Adds files to the FileManager
|
|
38
38
|
*/
|
|
39
|
-
export function File<TMeta extends object = object>({ children, ...props }: Props<TMeta>):
|
|
39
|
+
export function File<TMeta extends object = object>({ children, ...props }: Props<TMeta>): FabricReactElement {
|
|
40
40
|
const { baseName, path, meta = {}, footer, banner } = props
|
|
41
41
|
|
|
42
42
|
const fileManager = useFileManager()
|
|
@@ -69,11 +69,11 @@ export function File<TMeta extends object = object>({ children, ...props }: Prop
|
|
|
69
69
|
return <kubb-file {...props}>{children}</kubb-file>
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
File.displayName = '
|
|
72
|
+
File.displayName = 'File'
|
|
73
73
|
|
|
74
74
|
type FileSourceProps = Omit<KubbFile.Source, 'value'> & {
|
|
75
75
|
key?: Key
|
|
76
|
-
children?:
|
|
76
|
+
children?: FabricReactNode
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
@@ -82,7 +82,7 @@ type FileSourceProps = Omit<KubbFile.Source, 'value'> & {
|
|
|
82
82
|
* Marks a block of source text to be associated with the current file when
|
|
83
83
|
* rendering with the FileCollector. Children are treated as the source string.
|
|
84
84
|
*/
|
|
85
|
-
function FileSource({ children, ...props }: FileSourceProps):
|
|
85
|
+
function FileSource({ children, ...props }: FileSourceProps): FabricReactElement {
|
|
86
86
|
const { name, isExportable, isIndexable, isTypeOnly } = props
|
|
87
87
|
|
|
88
88
|
const nodeTree = useNodeTree()
|
|
@@ -100,7 +100,7 @@ function FileSource({ children, ...props }: FileSourceProps): KubbElement {
|
|
|
100
100
|
)
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
FileSource.displayName = '
|
|
103
|
+
FileSource.displayName = 'FileSource'
|
|
104
104
|
|
|
105
105
|
export type FileExportProps = KubbFile.Export & { key?: Key }
|
|
106
106
|
|
|
@@ -110,7 +110,7 @@ export type FileExportProps = KubbFile.Export & { key?: Key }
|
|
|
110
110
|
* Declares an export entry for the current file. This will be collected by
|
|
111
111
|
* the FileCollector for later emission.
|
|
112
112
|
*/
|
|
113
|
-
function FileExport(props: FileExportProps):
|
|
113
|
+
function FileExport(props: FileExportProps): FabricReactElement {
|
|
114
114
|
const { name, path, isTypeOnly, asAlias } = props
|
|
115
115
|
|
|
116
116
|
const nodeTree = useNodeTree()
|
|
@@ -134,7 +134,7 @@ function FileExport(props: FileExportProps): KubbElement {
|
|
|
134
134
|
return <kubb-export name={name} path={path} isTypeOnly={isTypeOnly} asAlias={asAlias} />
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
FileExport.displayName = '
|
|
137
|
+
FileExport.displayName = 'FileExport'
|
|
138
138
|
|
|
139
139
|
export type FileImportProps = KubbFile.Import & { key?: Key }
|
|
140
140
|
|
|
@@ -143,7 +143,7 @@ export type FileImportProps = KubbFile.Import & { key?: Key }
|
|
|
143
143
|
*
|
|
144
144
|
* Declares an import entry for the current file.
|
|
145
145
|
*/
|
|
146
|
-
function FileImport(props: FileImportProps):
|
|
146
|
+
function FileImport(props: FileImportProps): FabricReactElement {
|
|
147
147
|
const { name, root, path, isTypeOnly, isNameSpace } = props
|
|
148
148
|
|
|
149
149
|
const nodeTree = useNodeTree()
|
|
@@ -168,7 +168,7 @@ function FileImport(props: FileImportProps): KubbElement {
|
|
|
168
168
|
return <kubb-import name={name} root={root} path={path} isNameSpace={isNameSpace} isTypeOnly={isTypeOnly} />
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
FileImport.displayName = '
|
|
171
|
+
FileImport.displayName = 'FileImport'
|
|
172
172
|
|
|
173
173
|
File.Export = FileExport
|
|
174
174
|
File.Import = FileImport
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeTreeContext, provide, useNodeTree } from '@kubb/fabric-core'
|
|
2
|
-
import type {
|
|
2
|
+
import type { FabricReactElement, FabricReactNode, JSDoc, Key } from '../types.ts'
|
|
3
3
|
import { createJSDoc } from '../utils/createJSDoc.ts'
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
@@ -40,13 +40,13 @@ type Props = {
|
|
|
40
40
|
/**
|
|
41
41
|
* Children nodes.
|
|
42
42
|
*/
|
|
43
|
-
children?:
|
|
43
|
+
children?: FabricReactNode
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Generates a TypeScript function declaration.
|
|
48
48
|
*/
|
|
49
|
-
export function Function({ children, ...props }: Props):
|
|
49
|
+
export function Function({ children, ...props }: Props): FabricReactElement {
|
|
50
50
|
const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc } = props
|
|
51
51
|
|
|
52
52
|
const nodeTree = useNodeTree()
|
|
@@ -97,7 +97,7 @@ export function Function({ children, ...props }: Props): KubbElement {
|
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
Function.displayName = '
|
|
100
|
+
Function.displayName = 'Function'
|
|
101
101
|
|
|
102
102
|
type ArrowFunctionProps = Props & {
|
|
103
103
|
/**
|
|
@@ -173,5 +173,5 @@ function ArrowFunction({ children, ...props }: ArrowFunctionProps) {
|
|
|
173
173
|
)
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
ArrowFunction.displayName = '
|
|
176
|
+
ArrowFunction.displayName = 'ArrowFunction'
|
|
177
177
|
Function.Arrow = ArrowFunction
|
package/src/components/Root.tsx
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { type FileManager, NodeTreeContext, provide, RootContext, type TreeNode } from '@kubb/fabric-core'
|
|
2
2
|
import { Component } from 'react'
|
|
3
3
|
|
|
4
|
-
import type { ComponentNode,
|
|
4
|
+
import type { ComponentNode, FabricReactElement, FabricReactNode } from '../types.ts'
|
|
5
5
|
|
|
6
6
|
type ErrorBoundaryProps = {
|
|
7
7
|
onError: (error: Error) => void
|
|
8
|
-
children?:
|
|
8
|
+
children?: FabricReactNode
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
class ErrorBoundary extends Component<{
|
|
12
12
|
onError: ErrorBoundaryProps['onError']
|
|
13
|
-
children?:
|
|
13
|
+
children?: FabricReactNode
|
|
14
14
|
}> {
|
|
15
15
|
state = { hasError: false }
|
|
16
16
|
|
|
17
|
-
static displayName = '
|
|
17
|
+
static displayName = 'ErrorBoundary'
|
|
18
18
|
static getDerivedStateFromError(_error: Error) {
|
|
19
19
|
return { hasError: true }
|
|
20
20
|
}
|
|
@@ -53,13 +53,13 @@ export type RootProps = {
|
|
|
53
53
|
/**
|
|
54
54
|
* Children nodes.
|
|
55
55
|
*/
|
|
56
|
-
children?:
|
|
56
|
+
children?: FabricReactNode
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* This component provides the root behavior for the Fabric runtime.
|
|
61
61
|
*/
|
|
62
|
-
export function Root({ onError, onExit, treeNode, fileManager, children }: RootProps):
|
|
62
|
+
export function Root({ onError, onExit, treeNode, fileManager, children }: RootProps): FabricReactElement {
|
|
63
63
|
provide(RootContext, { exit: onExit, treeNode, fileManager })
|
|
64
64
|
provide(NodeTreeContext, treeNode)
|
|
65
65
|
|
|
@@ -74,4 +74,4 @@ export function Root({ onError, onExit, treeNode, fileManager, children }: RootP
|
|
|
74
74
|
)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
Root.displayName = '
|
|
77
|
+
Root.displayName = 'Root'
|
package/src/components/Type.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeTreeContext, provide, useNodeTree } from '@kubb/fabric-core'
|
|
2
|
-
import type {
|
|
2
|
+
import type { FabricReactElement, FabricReactNode, JSDoc, Key } from '../types.ts'
|
|
3
3
|
import { createJSDoc } from '../utils/createJSDoc.ts'
|
|
4
4
|
|
|
5
5
|
export type TypeProps = {
|
|
@@ -19,13 +19,13 @@ export type TypeProps = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Children nodes.
|
|
21
21
|
*/
|
|
22
|
-
children?:
|
|
22
|
+
children?: FabricReactNode
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Generates a TypeScript type declaration.
|
|
27
27
|
*/
|
|
28
|
-
export function Type({ children, ...props }: TypeProps):
|
|
28
|
+
export function Type({ children, ...props }: TypeProps): FabricReactElement {
|
|
29
29
|
const { name, export: canExport, JSDoc } = props
|
|
30
30
|
|
|
31
31
|
const nodeTree = useNodeTree()
|
|
@@ -54,4 +54,4 @@ export function Type({ children, ...props }: TypeProps): KubbElement {
|
|
|
54
54
|
)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
Type.displayName = '
|
|
57
|
+
Type.displayName = 'Type'
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Provides lifecycle helpers that integrate with the Fabric runtime. The
|
|
5
|
-
* `exit` helper schedules a call to the RootContext exit function on the
|
|
6
|
-
* next tick to allow React to complete its render cycle first.
|
|
7
|
-
*/
|
|
8
|
-
export function useLifecycle() {
|
|
9
|
-
const { exit } = useContext(RootContext)
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
exit: () => {
|
|
13
|
-
// need this to let React finish its current render cycle
|
|
14
|
-
setTimeout(() => {
|
|
15
|
-
exit()
|
|
16
|
-
}, 0)
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
export { useLifecycle } from '@kubb/fabric-core'
|
package/src/devtools.ts
CHANGED
|
@@ -38,14 +38,14 @@ export function openDevtools() {
|
|
|
38
38
|
{
|
|
39
39
|
// ComponentFilterDisplayName
|
|
40
40
|
type: 2,
|
|
41
|
-
value: '
|
|
41
|
+
value: 'Root',
|
|
42
42
|
isEnabled: true,
|
|
43
43
|
isValid: true,
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
// ComponentFilterDisplayName
|
|
47
47
|
type: 2,
|
|
48
|
-
value: '
|
|
48
|
+
value: 'ErrorBoundary',
|
|
49
49
|
isEnabled: true,
|
|
50
50
|
isValid: true,
|
|
51
51
|
},
|
package/src/globals.ts
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import type React from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
FabricExportProps,
|
|
4
|
+
FabricFileProps,
|
|
5
|
+
FabricImportProps,
|
|
6
|
+
FabricReactElement,
|
|
7
|
+
FabricReactNode,
|
|
8
|
+
FabricSourceProps,
|
|
9
|
+
FabricTextProps,
|
|
10
|
+
LineBreakProps,
|
|
11
|
+
} from './types.ts'
|
|
3
12
|
|
|
4
13
|
declare global {
|
|
5
14
|
namespace JSX {
|
|
6
|
-
type Element =
|
|
15
|
+
type Element = FabricReactElement
|
|
7
16
|
|
|
8
17
|
interface ElementClass extends React.ComponentClass<any> {
|
|
9
|
-
render():
|
|
18
|
+
render(): FabricReactNode
|
|
10
19
|
}
|
|
11
20
|
|
|
12
21
|
interface IntrinsicElements {
|
|
13
|
-
'kubb-text':
|
|
14
|
-
'kubb-file':
|
|
15
|
-
'kubb-source':
|
|
16
|
-
'kubb-import':
|
|
17
|
-
'kubb-export':
|
|
22
|
+
'kubb-text': FabricTextProps
|
|
23
|
+
'kubb-file': FabricFileProps
|
|
24
|
+
'kubb-source': FabricSourceProps
|
|
25
|
+
'kubb-import': FabricImportProps
|
|
26
|
+
'kubb-export': FabricExportProps
|
|
18
27
|
br: LineBreakProps
|
|
19
28
|
indent: {}
|
|
20
29
|
dedent: {}
|
package/src/index.ts
CHANGED
|
@@ -3,15 +3,10 @@ import * as React from 'react'
|
|
|
3
3
|
|
|
4
4
|
export type { Fabric } from '@kubb/fabric-core'
|
|
5
5
|
// expose fabric core helpers
|
|
6
|
-
export { createFabric, createFile, FileManager, FileProcessor } from '@kubb/fabric-core'
|
|
6
|
+
export { createContext, createFabric, createFile, FileManager, FileProcessor, TreeNode, useContext } from '@kubb/fabric-core'
|
|
7
7
|
|
|
8
8
|
// react helpers
|
|
9
9
|
export const useState = React.useState
|
|
10
|
-
export const createContext = React.createContext
|
|
11
|
-
export const createElement = React.createElement
|
|
12
|
-
export const Fragment = React.Fragment
|
|
13
|
-
export const use = React.use
|
|
14
|
-
export const useContext = React.useContext
|
|
15
10
|
export const useEffect = React.useEffect
|
|
16
11
|
export const useReducer = React.useReducer
|
|
17
12
|
export const useRef = React.useRef
|
package/src/jsx-dev-runtime.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react/jsx-dev-runtime'
|
|
2
|
-
import type {
|
|
2
|
+
import type { FabricReactElement, FabricReactNode } from './types.ts'
|
|
3
3
|
|
|
4
4
|
export const Fragment = React.Fragment
|
|
5
5
|
export const jsxDEV = React.jsxDEV
|
|
6
6
|
|
|
7
7
|
export type * from './jsx-namespace.d.ts'
|
|
8
8
|
|
|
9
|
-
export type JSXElement =
|
|
10
|
-
export type ReactNode =
|
|
9
|
+
export type JSXElement = FabricReactElement
|
|
10
|
+
export type ReactNode = FabricReactNode
|