@kubb/react-fabric 0.11.0 → 0.11.2

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.
@@ -0,0 +1,31 @@
1
+ import { o as Plugin } from "./Fabric-BELBf-bX.cjs";
2
+ import { ElementType } from "react";
3
+
4
+ //#region src/plugins/reactPlugin.d.ts
5
+ type Options = {
6
+ stdout?: NodeJS.WriteStream;
7
+ stdin?: NodeJS.ReadStream;
8
+ stderr?: NodeJS.WriteStream;
9
+ /**
10
+ * Set this to true to always see the result of the render in the console(line per render)
11
+ */
12
+ debug?: boolean;
13
+ };
14
+ type ExtendOptions = {
15
+ render(App: ElementType): Promise<void>;
16
+ renderToString(App: ElementType): Promise<string>;
17
+ waitUntilExit(): Promise<void>;
18
+ };
19
+ declare global {
20
+ namespace Kubb {
21
+ interface Fabric {
22
+ render(App: ElementType): Promise<void>;
23
+ renderToString(App: ElementType): Promise<string>;
24
+ waitUntilExit(): Promise<void>;
25
+ }
26
+ }
27
+ }
28
+ declare const reactPlugin: Plugin<Options, ExtendOptions>;
29
+ //#endregion
30
+ export { reactPlugin as n, Options as t };
31
+ //# sourceMappingURL=reactPlugin-yhmHKdUw.d.cts.map
@@ -0,0 +1,129 @@
1
+ import { b as Source, c as FileManager, g as Import, h as File, p as Export } from "./Fabric-BELBf-bX.cjs";
2
+ import { t as TreeNode } from "./TreeNode-Dqmg64Vf.cjs";
3
+ import React, { JSX, Key, ReactNode } from "react";
4
+
5
+ //#region ../fabric-core/src/composables/useNodeTree.d.ts
6
+ type ComponentNode = {
7
+ type: string;
8
+ props: Record<string, unknown>;
9
+ };
10
+ //#endregion
11
+ //#region ../fabric-core/src/contexts/RootContext.d.ts
12
+ type RootContextProps = {
13
+ /**
14
+ * Exit (unmount) the whole app.
15
+ */
16
+ exit: (error?: Error) => void;
17
+ /**
18
+ * TreeNode representing the tree structure of the app.
19
+ */
20
+ treeNode: TreeNode<ComponentNode>;
21
+ /**
22
+ * FileManager instance for managing files within the app.
23
+ */
24
+ fileManager: FileManager;
25
+ };
26
+ //#endregion
27
+ //#region ../fabric-core/src/types.d.ts
28
+ type JSDoc = {
29
+ comments: string[];
30
+ };
31
+ //#endregion
32
+ //#region src/utils/getFunctionParams.d.ts
33
+ type Param = {
34
+ /**
35
+ * `object` will return the pathParams as an object.
36
+ *
37
+ * `inline` will return the pathParams as comma separated params.
38
+ * @default `'inline'`
39
+ * @private
40
+ */
41
+ mode?: 'object' | 'inline' | 'inlineSpread';
42
+ type?: 'string' | 'number' | (string & {});
43
+ optional?: boolean;
44
+ /**
45
+ * @example test = "default"
46
+ */
47
+ default?: string;
48
+ /**
49
+ * Used for no TypeScript(with mode object)
50
+ * @example test: "default"
51
+ */
52
+ value?: string;
53
+ children?: Params;
54
+ };
55
+ type Params = Record<string, Param | undefined>;
56
+ type Options = {
57
+ type: 'constructor' | 'call' | 'object' | 'objectValue';
58
+ transformName?: (name: string) => string;
59
+ transformType?: (type: string) => string;
60
+ };
61
+ declare function createFunctionParams(params: Params): Params;
62
+ declare class FunctionParams {
63
+ #private;
64
+ static factory(params: Params): FunctionParams;
65
+ constructor(params: Params);
66
+ get params(): Params;
67
+ get flatParams(): Params;
68
+ toCall({
69
+ transformName,
70
+ transformType
71
+ }?: Pick<Options, 'transformName' | 'transformType'>): string;
72
+ toObject(): string;
73
+ toObjectValue(): string;
74
+ toConstructor(): string;
75
+ }
76
+ //#endregion
77
+ //#region src/types.d.ts
78
+ type ReactElementNames = 'br' | 'div';
79
+ type ElementNames = ReactElementNames | 'kubb-text' | 'kubb-file' | 'kubb-source' | 'kubb-import' | 'kubb-export' | 'kubb-root' | 'kubb-app';
80
+ type Node = {
81
+ parentNode: DOMElement | undefined;
82
+ internal_static?: boolean;
83
+ };
84
+ type DOMNodeAttribute = boolean | string | number;
85
+ type TextName = '#text';
86
+ type TextNode = {
87
+ nodeName: TextName;
88
+ nodeValue: string;
89
+ } & Node;
90
+ type DOMNode<T = {
91
+ nodeName: NodeNames;
92
+ }> = T extends {
93
+ nodeName: infer U;
94
+ } ? U extends '#text' ? TextNode : DOMElement : never;
95
+ type OutputTransformer = (s: string, index: number) => string;
96
+ type DOMElement = {
97
+ nodeName: ElementNames;
98
+ attributes: Map<string, DOMNodeAttribute>;
99
+ childNodes: DOMNode[];
100
+ internal_transform?: OutputTransformer;
101
+ isStaticDirty?: boolean;
102
+ staticNode?: DOMElement;
103
+ onComputeLayout?: () => void;
104
+ onRender?: () => void;
105
+ onImmediateRender?: () => void;
106
+ } & Node;
107
+ type NodeNames = ElementNames | TextName;
108
+ type KubbNode = ReactNode;
109
+ type KubbElement = JSX.Element;
110
+ type KubbTextProps = {
111
+ children?: KubbNode;
112
+ };
113
+ type KubbFileProps = {
114
+ id?: string;
115
+ children?: KubbNode;
116
+ baseName: string;
117
+ path: string;
118
+ override?: boolean;
119
+ meta?: File['meta'];
120
+ };
121
+ type KubbSourceProps = Source & {
122
+ children?: KubbNode;
123
+ };
124
+ type KubbImportProps = Import;
125
+ type KubbExportProps = Export;
126
+ type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
127
+ //#endregion
128
+ export { Params as _, Key as a, RootContextProps as b, KubbFileProps as c, KubbSourceProps as d, KubbTextProps as f, Param as g, FunctionParams as h, ElementNames as i, KubbImportProps as l, TextNode as m, DOMNode as n, KubbElement as o, LineBreakProps as p, DOMNodeAttribute as r, KubbExportProps as s, DOMElement as t, KubbNode as u, createFunctionParams as v, ComponentNode as x, JSDoc as y };
129
+ //# sourceMappingURL=types-BKNiqRcq.d.cts.map
@@ -0,0 +1,129 @@
1
+ import { b as Source, c as FileManager, g as Import, h as File, p as Export } from "./Fabric-DbJhvsCq.js";
2
+ import { t as TreeNode } from "./TreeNode-tc-jO4rk.js";
3
+ import React, { JSX, Key, ReactNode } from "react";
4
+
5
+ //#region ../fabric-core/src/composables/useNodeTree.d.ts
6
+ type ComponentNode = {
7
+ type: string;
8
+ props: Record<string, unknown>;
9
+ };
10
+ //#endregion
11
+ //#region ../fabric-core/src/contexts/RootContext.d.ts
12
+ type RootContextProps = {
13
+ /**
14
+ * Exit (unmount) the whole app.
15
+ */
16
+ exit: (error?: Error) => void;
17
+ /**
18
+ * TreeNode representing the tree structure of the app.
19
+ */
20
+ treeNode: TreeNode<ComponentNode>;
21
+ /**
22
+ * FileManager instance for managing files within the app.
23
+ */
24
+ fileManager: FileManager;
25
+ };
26
+ //#endregion
27
+ //#region ../fabric-core/src/types.d.ts
28
+ type JSDoc = {
29
+ comments: string[];
30
+ };
31
+ //#endregion
32
+ //#region src/utils/getFunctionParams.d.ts
33
+ type Param = {
34
+ /**
35
+ * `object` will return the pathParams as an object.
36
+ *
37
+ * `inline` will return the pathParams as comma separated params.
38
+ * @default `'inline'`
39
+ * @private
40
+ */
41
+ mode?: 'object' | 'inline' | 'inlineSpread';
42
+ type?: 'string' | 'number' | (string & {});
43
+ optional?: boolean;
44
+ /**
45
+ * @example test = "default"
46
+ */
47
+ default?: string;
48
+ /**
49
+ * Used for no TypeScript(with mode object)
50
+ * @example test: "default"
51
+ */
52
+ value?: string;
53
+ children?: Params;
54
+ };
55
+ type Params = Record<string, Param | undefined>;
56
+ type Options = {
57
+ type: 'constructor' | 'call' | 'object' | 'objectValue';
58
+ transformName?: (name: string) => string;
59
+ transformType?: (type: string) => string;
60
+ };
61
+ declare function createFunctionParams(params: Params): Params;
62
+ declare class FunctionParams {
63
+ #private;
64
+ static factory(params: Params): FunctionParams;
65
+ constructor(params: Params);
66
+ get params(): Params;
67
+ get flatParams(): Params;
68
+ toCall({
69
+ transformName,
70
+ transformType
71
+ }?: Pick<Options, 'transformName' | 'transformType'>): string;
72
+ toObject(): string;
73
+ toObjectValue(): string;
74
+ toConstructor(): string;
75
+ }
76
+ //#endregion
77
+ //#region src/types.d.ts
78
+ type ReactElementNames = 'br' | 'div';
79
+ type ElementNames = ReactElementNames | 'kubb-text' | 'kubb-file' | 'kubb-source' | 'kubb-import' | 'kubb-export' | 'kubb-root' | 'kubb-app';
80
+ type Node = {
81
+ parentNode: DOMElement | undefined;
82
+ internal_static?: boolean;
83
+ };
84
+ type DOMNodeAttribute = boolean | string | number;
85
+ type TextName = '#text';
86
+ type TextNode = {
87
+ nodeName: TextName;
88
+ nodeValue: string;
89
+ } & Node;
90
+ type DOMNode<T = {
91
+ nodeName: NodeNames;
92
+ }> = T extends {
93
+ nodeName: infer U;
94
+ } ? U extends '#text' ? TextNode : DOMElement : never;
95
+ type OutputTransformer = (s: string, index: number) => string;
96
+ type DOMElement = {
97
+ nodeName: ElementNames;
98
+ attributes: Map<string, DOMNodeAttribute>;
99
+ childNodes: DOMNode[];
100
+ internal_transform?: OutputTransformer;
101
+ isStaticDirty?: boolean;
102
+ staticNode?: DOMElement;
103
+ onComputeLayout?: () => void;
104
+ onRender?: () => void;
105
+ onImmediateRender?: () => void;
106
+ } & Node;
107
+ type NodeNames = ElementNames | TextName;
108
+ type KubbNode = ReactNode;
109
+ type KubbElement = JSX.Element;
110
+ type KubbTextProps = {
111
+ children?: KubbNode;
112
+ };
113
+ type KubbFileProps = {
114
+ id?: string;
115
+ children?: KubbNode;
116
+ baseName: string;
117
+ path: string;
118
+ override?: boolean;
119
+ meta?: File['meta'];
120
+ };
121
+ type KubbSourceProps = Source & {
122
+ children?: KubbNode;
123
+ };
124
+ type KubbImportProps = Import;
125
+ type KubbExportProps = Export;
126
+ type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
127
+ //#endregion
128
+ export { Params as _, Key as a, RootContextProps as b, KubbFileProps as c, KubbSourceProps as d, KubbTextProps as f, Param as g, FunctionParams as h, ElementNames as i, KubbImportProps as l, TextNode as m, DOMNode as n, KubbElement as o, LineBreakProps as p, DOMNodeAttribute as r, KubbExportProps as s, DOMElement as t, KubbNode as u, createFunctionParams as v, ComponentNode as x, JSDoc as y };
129
+ //# sourceMappingURL=types-BKXB0ewg.d.ts.map
package/dist/types.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-BELBf-bX.cjs";
2
- import { O as Param, _ as RootContextProps, a as Key, c as KubbFileProps, d as KubbSourceProps, f as KubbTextProps, h as JSDoc, i as ElementNames, k as Params, l as KubbImportProps, m as TextNode, n as DOMNode, o as KubbElement, p as LineBreakProps, r as DOMNodeAttribute, rt as ComponentNode, s as KubbExportProps, t as DOMElement, u as KubbNode } from "./types-C3ODUOKN.cjs";
2
+ import { _ as Params, a as Key, b as RootContextProps, c as KubbFileProps, d as KubbSourceProps, f as KubbTextProps, g as Param, i as ElementNames, l as KubbImportProps, m as TextNode, n as DOMNode, o as KubbElement, p as LineBreakProps, r as DOMNodeAttribute, s as KubbExportProps, t as DOMElement, u as KubbNode, x as ComponentNode, y as JSDoc } from "./types-BKNiqRcq.cjs";
3
3
  export { ComponentNode, DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, RootContextProps, TextNode };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-DbJhvsCq.js";
2
- import { O as Param, _ as RootContextProps, a as Key, c as KubbFileProps, d as KubbSourceProps, f as KubbTextProps, h as JSDoc, i as ElementNames, k as Params, l as KubbImportProps, m as TextNode, n as DOMNode, o as KubbElement, p as LineBreakProps, r as DOMNodeAttribute, rt as ComponentNode, s as KubbExportProps, t as DOMElement, u as KubbNode } from "./types-DwaohVJS.js";
2
+ import { _ as Params, a as Key, b as RootContextProps, c as KubbFileProps, d as KubbSourceProps, f as KubbTextProps, g as Param, i as ElementNames, l as KubbImportProps, m as TextNode, n as DOMNode, o as KubbElement, p as LineBreakProps, r as DOMNodeAttribute, s as KubbExportProps, t as DOMElement, u as KubbNode, x as ComponentNode, y as JSDoc } from "./types-BKXB0ewg.js";
3
3
  export { ComponentNode, DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, RootContextProps, TextNode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/react-fabric",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
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",
@@ -111,7 +111,7 @@
111
111
  "react-devtools-core": "6.1.2",
112
112
  "signal-exit": "^4.1.0",
113
113
  "ws": "8.18.0",
114
- "@kubb/fabric-core": "0.11.0"
114
+ "@kubb/fabric-core": "0.11.2"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@types/react": "^19.2.8",
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as React from 'react'
3
3
 
4
4
  // expose fabric core helpers
5
- export * from '@kubb/fabric-core'
5
+ export { createFabric, createFile, type Fabric, FileManager, FileProcessor } from '@kubb/fabric-core'
6
6
 
7
7
  // react helpers
8
8
  export const useState = React.useState
@@ -1,7 +1,6 @@
1
1
  import { definePlugin } from '@kubb/fabric-core/plugins'
2
2
  import { createElement, type ElementType } from 'react'
3
3
  import { Runtime } from '../Runtime.tsx'
4
- import type { KubbElement } from '../types'
5
4
 
6
5
  export type Options = {
7
6
  stdout?: NodeJS.WriteStream
@@ -14,16 +13,16 @@ export type Options = {
14
13
  }
15
14
 
16
15
  type ExtendOptions = {
17
- render(App: KubbElement | ElementType): Promise<void>
18
- renderToString(App: KubbElement | ElementType): Promise<string>
16
+ render(App: ElementType): Promise<void>
17
+ renderToString(App: ElementType): Promise<string>
19
18
  waitUntilExit(): Promise<void>
20
19
  }
21
20
 
22
21
  declare global {
23
22
  namespace Kubb {
24
23
  interface Fabric {
25
- render(App: KubbElement | ElementType): Promise<void>
26
- renderToString(App: KubbElement | ElementType): Promise<string>
24
+ render(App: ElementType): Promise<void>
25
+ renderToString(App: ElementType): Promise<string>
27
26
  waitUntilExit(): Promise<void>
28
27
  }
29
28
  }
@@ -38,11 +37,11 @@ export const reactPlugin = definePlugin<Options, ExtendOptions>({
38
37
  return {
39
38
  async render(App) {
40
39
  await ctx.emit('lifecycle:start')
41
- await runtime.render(createElement(App as unknown as ElementType))
40
+ await runtime.render(createElement(App))
42
41
  },
43
42
  async renderToString(App) {
44
43
  await ctx.emit('lifecycle:start')
45
- return runtime.renderToString(createElement(App as unknown as ElementType))
44
+ return runtime.renderToString(createElement(App))
46
45
  },
47
46
  async waitUntilExit() {
48
47
  await runtime.waitUntilExit()