@kubb/react-fabric 0.0.0 → 0.1.0
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/devtools.cjs +154 -85
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.js +154 -85
- package/dist/devtools.js.map +1 -1
- package/dist/{globals-C6rGETh5.d.ts → globals-BQ_tJj2b.d.ts} +3 -3
- package/dist/{globals-CnATk-Sl.d.cts → globals-C-9ezLk9.d.cts} +3 -3
- package/dist/globals.d.cts +2 -2
- package/dist/globals.d.ts +2 -2
- package/dist/index.cjs +47 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -52
- package/dist/index.d.ts +63 -52
- package/dist/index.js +47 -72
- package/dist/index.js.map +1 -1
- package/dist/jsx-runtime.cjs +15 -7
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/{jsx-dev-runtime.d.ts → jsx-runtime.d.cts} +3 -3
- package/dist/{jsx-dev-runtime.d.cts → jsx-runtime.d.ts} +3 -3
- package/dist/jsx-runtime.js +12 -4
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/{types-C3p0Ljxf.d.cts → types-CUKR3KZn.d.cts} +1 -1
- package/dist/{types-DEroxUW0.d.ts → types-D9OfSq91.d.ts} +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +9 -7
- package/src/ReactTemplate.tsx +22 -24
- package/src/components/Const.tsx +4 -17
- package/src/components/File.tsx +1 -1
- package/src/components/Function.tsx +6 -38
- package/src/components/Root.tsx +5 -9
- package/src/components/Type.tsx +1 -7
- package/src/{hooks → composables}/useApp.ts +2 -2
- package/src/createApp.ts +4 -9
- package/src/dom.ts +5 -3
- package/src/globals.ts +1 -1
- package/src/index.ts +3 -4
- package/src/utils/processFiles.ts +1 -1
- package/src/utils/squashExportNodes.ts +1 -1
- package/src/utils/squashImportNodes.ts +1 -1
- package/src/utils/squashSourceNodes.ts +1 -1
- package/dist/jsx-dev-runtime.cjs +0 -9
- package/dist/jsx-dev-runtime.js +0 -6
- package/dist/jsx-runtime-DmD5u6a-.js +0 -13
- package/dist/jsx-runtime-DmD5u6a-.js.map +0 -1
- package/dist/jsx-runtime-zKfRQHQD.cjs +0 -36
- package/dist/jsx-runtime-zKfRQHQD.cjs.map +0 -1
- package/src/components/Text.tsx +0 -31
- package/src/utils/throttle.ts +0 -30
- /package/src/{hooks → composables}/useFile.ts +0 -0
- /package/src/{hooks → composables}/useLifecycle.tsx +0 -0
package/dist/jsx-runtime.cjs
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
require('./react-Bq0UOw6S.cjs');
|
|
1
|
+
const require_react = require('./react-Bq0UOw6S.cjs');
|
|
2
2
|
require('./globals-8sJ940pg.cjs');
|
|
3
|
-
require('./jsx-runtime-B3MMb3PL.cjs');
|
|
4
|
-
const require_jsx_runtime$1 = require('./jsx-runtime-zKfRQHQD.cjs');
|
|
3
|
+
const require_jsx_runtime$1 = require('./jsx-runtime-B3MMb3PL.cjs');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
//#region src/jsx-runtime.ts
|
|
6
|
+
var import_jsx_runtime = /* @__PURE__ */ require_react.__toESM(require_jsx_runtime$1.require_jsx_runtime(), 1);
|
|
7
|
+
const Fragment = import_jsx_runtime.Fragment;
|
|
8
|
+
const jsx = import_jsx_runtime.jsx;
|
|
9
|
+
const jsxs = import_jsx_runtime.jsxs;
|
|
10
|
+
const jsxDEV = import_jsx_runtime.jsx;
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.Fragment = Fragment;
|
|
14
|
+
exports.jsx = jsx;
|
|
15
|
+
exports.jsxDEV = jsxDEV;
|
|
16
|
+
exports.jsxs = jsxs;
|
|
17
|
+
//# sourceMappingURL=jsx-runtime.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.cjs","names":[],"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import './globals.ts'\n\nimport ReactJSXRuntime from 'react/jsx-runtime'\n\nexport const Fragment = ReactJSXRuntime.Fragment\nexport const jsx = ReactJSXRuntime.jsx\nexport const jsxs = ReactJSXRuntime.jsxs\nexport const jsxDEV = ReactJSXRuntime.jsx\n"],"mappings":";;;;;;AAIA,MAAa,8BAA2B;AACxC,MAAa,yBAAsB;AACnC,MAAa,0BAAuB;AACpC,MAAa,4BAAyB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./globals-
|
|
2
|
-
import "./types-
|
|
1
|
+
import "./globals-C-9ezLk9.cjs";
|
|
2
|
+
import "./types-CUKR3KZn.cjs";
|
|
3
3
|
import * as react0 from "react";
|
|
4
4
|
import ReactJSXRuntime from "react/jsx-runtime";
|
|
5
5
|
|
|
@@ -10,4 +10,4 @@ declare const jsxs: typeof ReactJSXRuntime.jsxs;
|
|
|
10
10
|
declare const jsxDEV: typeof ReactJSXRuntime.jsx;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { Fragment, jsx, jsxDEV, jsxs };
|
|
13
|
-
//# sourceMappingURL=jsx-
|
|
13
|
+
//# sourceMappingURL=jsx-runtime.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./globals-
|
|
2
|
-
import "./types-
|
|
1
|
+
import "./globals-BQ_tJj2b.js";
|
|
2
|
+
import "./types-D9OfSq91.js";
|
|
3
3
|
import * as react0 from "react";
|
|
4
4
|
import ReactJSXRuntime from "react/jsx-runtime";
|
|
5
5
|
|
|
@@ -10,4 +10,4 @@ declare const jsxs: typeof ReactJSXRuntime.jsxs;
|
|
|
10
10
|
declare const jsxDEV: typeof ReactJSXRuntime.jsx;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { Fragment, jsx, jsxDEV, jsxs };
|
|
13
|
-
//# sourceMappingURL=jsx-
|
|
13
|
+
//# sourceMappingURL=jsx-runtime.d.ts.map
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import "./react-BBkwFtZV.js";
|
|
1
|
+
import { r as __toESM } from "./react-BBkwFtZV.js";
|
|
2
2
|
import "./globals-Df5klKjG.js";
|
|
3
|
-
import "./jsx-runtime-BPQkRAg2.js";
|
|
4
|
-
import { i as jsxs, n as jsx, r as jsxDEV, t as Fragment } from "./jsx-runtime-DmD5u6a-.js";
|
|
3
|
+
import { t as require_jsx_runtime } from "./jsx-runtime-BPQkRAg2.js";
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
//#region src/jsx-runtime.ts
|
|
6
|
+
var import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime(), 1);
|
|
7
|
+
const Fragment = import_jsx_runtime.Fragment;
|
|
8
|
+
const jsx = import_jsx_runtime.jsx;
|
|
9
|
+
const jsxs = import_jsx_runtime.jsxs;
|
|
10
|
+
const jsxDEV = import_jsx_runtime.jsx;
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Fragment, jsx, jsxDEV, jsxs };
|
|
14
|
+
//# sourceMappingURL=jsx-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import './globals.ts'\n\nimport ReactJSXRuntime from 'react/jsx-runtime'\n\nexport const Fragment = ReactJSXRuntime.Fragment\nexport const jsx = ReactJSXRuntime.jsx\nexport const jsxs = ReactJSXRuntime.jsxs\nexport const jsxDEV = ReactJSXRuntime.jsx\n"],"mappings":";;;;;;AAIA,MAAa,8BAA2B;AACxC,MAAa,yBAAsB;AACnC,MAAa,0BAAuB;AACpC,MAAa,4BAAyB"}
|
|
@@ -82,4 +82,4 @@ type JSDoc = {
|
|
|
82
82
|
};
|
|
83
83
|
//#endregion
|
|
84
84
|
export { JSDoc as a, TextNode as c, Params as d, createFunctionParams as f, ElementNames as i, FunctionParams as l, DOMNode as n, Key as o, DOMNodeAttribute as r, KubbNode as s, DOMElement as t, Param as u };
|
|
85
|
-
//# sourceMappingURL=types-
|
|
85
|
+
//# sourceMappingURL=types-CUKR3KZn.d.cts.map
|
|
@@ -82,4 +82,4 @@ type JSDoc = {
|
|
|
82
82
|
};
|
|
83
83
|
//#endregion
|
|
84
84
|
export { JSDoc as a, TextNode as c, Params as d, createFunctionParams as f, ElementNames as i, FunctionParams as l, DOMNode as n, Key as o, DOMNodeAttribute as r, KubbNode as s, DOMElement as t, Param as u };
|
|
85
|
-
//# sourceMappingURL=types-
|
|
85
|
+
//# sourceMappingURL=types-D9OfSq91.d.ts.map
|
package/dist/types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JSDoc, c as TextNode, d as Params, i as ElementNames, n as DOMNode, o as Key, r as DOMNodeAttribute, s as KubbNode, t as DOMElement, u as Param } from "./types-
|
|
1
|
+
import { a as JSDoc, c as TextNode, d as Params, i as ElementNames, n as DOMNode, o as Key, r as DOMNodeAttribute, s as KubbNode, t as DOMElement, u as Param } from "./types-CUKR3KZn.cjs";
|
|
2
2
|
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, JSDoc, Key, KubbNode, Param, Params, TextNode };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as JSDoc, c as TextNode, d as Params, i as ElementNames, n as DOMNode, o as Key, r as DOMNodeAttribute, s as KubbNode, t as DOMElement, u as Param } from "./types-
|
|
1
|
+
import { a as JSDoc, c as TextNode, d as Params, i as ElementNames, n as DOMNode, o as Key, r as DOMNodeAttribute, s as KubbNode, t as DOMElement, u as Param } from "./types-D9OfSq91.js";
|
|
2
2
|
export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, JSDoc, Key, KubbNode, Param, Params, TextNode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/react-fabric",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
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",
|
|
@@ -37,10 +37,6 @@
|
|
|
37
37
|
"import": "./dist/globals.js",
|
|
38
38
|
"require": "./dist/globals.cjs"
|
|
39
39
|
},
|
|
40
|
-
"./jsx-dev-runtime": {
|
|
41
|
-
"import": "./dist/jsx-dev-runtime.js",
|
|
42
|
-
"require": "./dist/jsx-dev-runtime.cjs"
|
|
43
|
-
},
|
|
44
40
|
"./jsx-runtime": {
|
|
45
41
|
"import": "./dist/jsx-runtime.js",
|
|
46
42
|
"require": "./dist/jsx-runtime.cjs"
|
|
@@ -59,6 +55,12 @@
|
|
|
59
55
|
"devtools": [
|
|
60
56
|
"./dist/devtools.d.ts"
|
|
61
57
|
],
|
|
58
|
+
"jsx-dev-runtime": [
|
|
59
|
+
"./dist/jsx-runtime.d.ts"
|
|
60
|
+
],
|
|
61
|
+
"jsx-runtime": [
|
|
62
|
+
"./dist/jsx-runtime.d.ts"
|
|
63
|
+
],
|
|
62
64
|
"types": [
|
|
63
65
|
"./dist/types.d.ts"
|
|
64
66
|
]
|
|
@@ -79,11 +81,11 @@
|
|
|
79
81
|
"indent-string": "^5.0.0",
|
|
80
82
|
"natural-orderby": "^5.0.0",
|
|
81
83
|
"react": "^19.2.0",
|
|
82
|
-
"react-devtools-inline": "^7.0.
|
|
84
|
+
"react-devtools-inline": "^7.0.1",
|
|
83
85
|
"react-reconciler": "0.32.0",
|
|
84
86
|
"signal-exit": "^4.1.0",
|
|
85
87
|
"ws": "^8.18.3",
|
|
86
|
-
"@kubb/fabric-core": "0.
|
|
88
|
+
"@kubb/fabric-core": "0.1.0"
|
|
87
89
|
},
|
|
88
90
|
"devDependencies": {
|
|
89
91
|
"@types/react": "^19.2.2",
|
package/src/ReactTemplate.tsx
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import type { AppContext } from '@kubb/fabric-core'
|
|
2
|
+
import type { AppContext } from '@kubb/fabric-core/types'
|
|
3
3
|
import type { ReactNode } from 'react'
|
|
4
4
|
import { ConcurrentRoot } from 'react-reconciler/constants'
|
|
5
5
|
import { onExit } from 'signal-exit'
|
|
6
|
-
import type { RootContextProps } from './components/Root.tsx'
|
|
7
6
|
import { Root } from './components/Root.tsx'
|
|
8
7
|
import { createNode } from './dom.ts'
|
|
9
8
|
import type { FiberRoot } from './kubbRenderer.ts'
|
|
@@ -12,8 +11,7 @@ import type { DOMElement } from './types.ts'
|
|
|
12
11
|
import { squashTextNodes } from './utils/squashTextNodes.ts'
|
|
13
12
|
import { processFiles } from './utils/processFiles.ts'
|
|
14
13
|
|
|
15
|
-
export type
|
|
16
|
-
context: AppContext
|
|
14
|
+
export type ReactAppContext = AppContext<{
|
|
17
15
|
stdout?: NodeJS.WriteStream
|
|
18
16
|
stdin?: NodeJS.ReadStream
|
|
19
17
|
stderr?: NodeJS.WriteStream
|
|
@@ -21,10 +19,10 @@ export type ReactTemplateOptions = {
|
|
|
21
19
|
* Set this to true to always see the result of the render in the console(line per render)
|
|
22
20
|
*/
|
|
23
21
|
debug?: boolean
|
|
24
|
-
}
|
|
22
|
+
}>
|
|
25
23
|
|
|
26
24
|
export class ReactTemplate {
|
|
27
|
-
readonly #
|
|
25
|
+
readonly #context: ReactAppContext
|
|
28
26
|
// Ignore last render after unmounting a tree to prevent empty output before exit
|
|
29
27
|
#isUnmounted: boolean
|
|
30
28
|
|
|
@@ -32,8 +30,8 @@ export class ReactTemplate {
|
|
|
32
30
|
readonly #container: FiberRoot
|
|
33
31
|
readonly #rootNode: DOMElement
|
|
34
32
|
|
|
35
|
-
constructor(
|
|
36
|
-
this.#
|
|
33
|
+
constructor(context: ReactAppContext) {
|
|
34
|
+
this.#context = context
|
|
37
35
|
|
|
38
36
|
this.#rootNode = createNode('kubb-root')
|
|
39
37
|
this.#rootNode.onRender = this.onRender
|
|
@@ -122,25 +120,25 @@ export class ReactTemplate {
|
|
|
122
120
|
return
|
|
123
121
|
}
|
|
124
122
|
|
|
125
|
-
this.#
|
|
123
|
+
this.#context.clear()
|
|
126
124
|
|
|
127
|
-
processFiles(this.#rootNode, this.#
|
|
125
|
+
processFiles(this.#rootNode, this.#context)
|
|
128
126
|
|
|
129
|
-
if (!this.#options
|
|
127
|
+
if (!this.#context.options?.debug && !this.#context.options?.stdout) {
|
|
130
128
|
return
|
|
131
129
|
}
|
|
132
130
|
|
|
133
|
-
const output = await this.#getOutput(this.#rootNode, this.#
|
|
131
|
+
const output = await this.#getOutput(this.#rootNode, this.#context)
|
|
134
132
|
|
|
135
|
-
if (this.#options
|
|
133
|
+
if (this.#context.options?.debug) {
|
|
136
134
|
console.log('Rendering: \n')
|
|
137
135
|
console.log(output)
|
|
138
136
|
}
|
|
139
137
|
|
|
140
|
-
if (this.#options.
|
|
141
|
-
this.#options.stdout.clearLine(0)
|
|
142
|
-
this.#options.stdout.cursorTo(0)
|
|
143
|
-
this.#options.stdout.write(output)
|
|
138
|
+
if (this.#context.options?.stdout && process.env.NODE_ENV !== 'test') {
|
|
139
|
+
this.#context.options.stdout.clearLine(0)
|
|
140
|
+
this.#context.options.stdout.cursorTo(0)
|
|
141
|
+
this.#context.options.stdout.write(output)
|
|
144
142
|
}
|
|
145
143
|
}
|
|
146
144
|
onError(error: Error): void {
|
|
@@ -166,9 +164,9 @@ export class ReactTemplate {
|
|
|
166
164
|
: text
|
|
167
165
|
}
|
|
168
166
|
|
|
169
|
-
render(node: ReactNode
|
|
167
|
+
render(node: ReactNode): void {
|
|
170
168
|
const element = (
|
|
171
|
-
<Root
|
|
169
|
+
<Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>
|
|
172
170
|
{node}
|
|
173
171
|
</Root>
|
|
174
172
|
)
|
|
@@ -177,9 +175,9 @@ export class ReactTemplate {
|
|
|
177
175
|
KubbRenderer.flushSyncWork()
|
|
178
176
|
}
|
|
179
177
|
|
|
180
|
-
async renderToString(node: ReactNode
|
|
178
|
+
async renderToString(node: ReactNode): Promise<string> {
|
|
181
179
|
const element = (
|
|
182
|
-
<Root
|
|
180
|
+
<Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>
|
|
183
181
|
{node}
|
|
184
182
|
</Root>
|
|
185
183
|
)
|
|
@@ -187,9 +185,9 @@ export class ReactTemplate {
|
|
|
187
185
|
KubbRenderer.updateContainerSync(element, this.#container, null, null)
|
|
188
186
|
KubbRenderer.flushSyncWork()
|
|
189
187
|
|
|
190
|
-
this.#
|
|
188
|
+
this.#context.clear()
|
|
191
189
|
|
|
192
|
-
return this.#getOutput(this.#rootNode, this.#
|
|
190
|
+
return this.#getOutput(this.#rootNode, this.#context)
|
|
193
191
|
}
|
|
194
192
|
|
|
195
193
|
unmount(error?: Error | number | null): void {
|
|
@@ -197,7 +195,7 @@ export class ReactTemplate {
|
|
|
197
195
|
return
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
if (this.#options
|
|
198
|
+
if (this.#context.options?.debug) {
|
|
201
199
|
console.log('Unmount', error)
|
|
202
200
|
}
|
|
203
201
|
|
package/src/components/Const.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { JSDoc, Key, KubbNode } from '../types.ts'
|
|
2
2
|
|
|
3
|
-
import { Space } from './Text.tsx'
|
|
4
3
|
import { createJSDoc } from '../utils/createJSDoc.ts'
|
|
5
4
|
|
|
6
5
|
type Props = {
|
|
@@ -37,28 +36,16 @@ export function Const({ name, export: canExport, type, JSDoc, asConst, children
|
|
|
37
36
|
<br />
|
|
38
37
|
</>
|
|
39
38
|
)}
|
|
40
|
-
{canExport &&
|
|
41
|
-
|
|
42
|
-
export
|
|
43
|
-
<Space />
|
|
44
|
-
</>
|
|
45
|
-
)}
|
|
46
|
-
const {name}
|
|
47
|
-
<Space />
|
|
39
|
+
{canExport && <>export </>}
|
|
40
|
+
const {name}{' '}
|
|
48
41
|
{type && (
|
|
49
42
|
<>
|
|
50
43
|
{':'}
|
|
51
|
-
{type}
|
|
52
|
-
<Space />
|
|
44
|
+
{type}{' '}
|
|
53
45
|
</>
|
|
54
46
|
)}
|
|
55
47
|
= {children}
|
|
56
|
-
{asConst &&
|
|
57
|
-
<>
|
|
58
|
-
<Space />
|
|
59
|
-
as const
|
|
60
|
-
</>
|
|
61
|
-
)}
|
|
48
|
+
{asConst && <> as const</>}
|
|
62
49
|
</>
|
|
63
50
|
)
|
|
64
51
|
}
|
package/src/components/File.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext } from 'react'
|
|
2
2
|
|
|
3
|
-
import type { KubbFile } from '@kubb/fabric-core'
|
|
3
|
+
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
4
4
|
import type { Key, KubbNode } from '../types.ts'
|
|
5
5
|
|
|
6
6
|
export type FileContextProps<TMeta extends object = object> = {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { JSDoc, Key, KubbNode } from '../types.ts'
|
|
2
2
|
import { Indent } from './Indent.tsx'
|
|
3
|
-
import { Space } from './Text.tsx'
|
|
4
3
|
import { createJSDoc } from '../utils/createJSDoc.ts'
|
|
5
4
|
|
|
6
5
|
type Props = {
|
|
@@ -51,24 +50,9 @@ export function Function({ name, default: isDefault, export: canExport, async, g
|
|
|
51
50
|
<br />
|
|
52
51
|
</>
|
|
53
52
|
)}
|
|
54
|
-
{canExport &&
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<Space />
|
|
58
|
-
</>
|
|
59
|
-
)}
|
|
60
|
-
{isDefault && (
|
|
61
|
-
<>
|
|
62
|
-
default
|
|
63
|
-
<Space />
|
|
64
|
-
</>
|
|
65
|
-
)}
|
|
66
|
-
{async && (
|
|
67
|
-
<>
|
|
68
|
-
async
|
|
69
|
-
<Space />
|
|
70
|
-
</>
|
|
71
|
-
)}
|
|
53
|
+
{canExport && <>export </>}
|
|
54
|
+
{isDefault && <>default </>}
|
|
55
|
+
{async && <>async </>}
|
|
72
56
|
function {name}
|
|
73
57
|
{generics && (
|
|
74
58
|
<>
|
|
@@ -112,25 +96,9 @@ function ArrowFunction({ name, default: isDefault, export: canExport, async, gen
|
|
|
112
96
|
<br />
|
|
113
97
|
</>
|
|
114
98
|
)}
|
|
115
|
-
{canExport &&
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<Space />
|
|
119
|
-
</>
|
|
120
|
-
)}
|
|
121
|
-
{isDefault && (
|
|
122
|
-
<>
|
|
123
|
-
default
|
|
124
|
-
<Space />
|
|
125
|
-
</>
|
|
126
|
-
)}
|
|
127
|
-
const {name} =<Space />
|
|
128
|
-
{async && (
|
|
129
|
-
<>
|
|
130
|
-
async
|
|
131
|
-
<Space />
|
|
132
|
-
</>
|
|
133
|
-
)}
|
|
99
|
+
{canExport && <>export </>}
|
|
100
|
+
{isDefault && <>default </>}
|
|
101
|
+
const {name} = {async && <>async </>}
|
|
134
102
|
{generics && (
|
|
135
103
|
<>
|
|
136
104
|
{'<'}
|
package/src/components/Root.tsx
CHANGED
|
@@ -2,9 +2,8 @@ import { Component, createContext } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import type { KubbNode } from '../types.ts'
|
|
4
4
|
|
|
5
|
-
type ErrorBoundaryProps
|
|
5
|
+
type ErrorBoundaryProps = {
|
|
6
6
|
onError: (error: Error) => void
|
|
7
|
-
meta: Meta
|
|
8
7
|
children?: KubbNode
|
|
9
8
|
}
|
|
10
9
|
|
|
@@ -33,20 +32,18 @@ class ErrorBoundary extends Component<{
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
export type RootContextProps
|
|
35
|
+
export type RootContextProps = {
|
|
37
36
|
/**
|
|
38
37
|
* Exit (unmount) the whole Ink app.
|
|
39
38
|
*/
|
|
40
39
|
readonly exit: (error?: Error) => void
|
|
41
|
-
readonly meta: Meta
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
export const RootContext = createContext<RootContextProps>({
|
|
45
43
|
exit: () => {},
|
|
46
|
-
meta: {},
|
|
47
44
|
})
|
|
48
45
|
|
|
49
|
-
type RootProps
|
|
46
|
+
type RootProps = {
|
|
50
47
|
/**
|
|
51
48
|
* Exit (unmount) hook
|
|
52
49
|
*/
|
|
@@ -55,11 +52,10 @@ type RootProps<Meta extends Record<string, unknown> = Record<string, unknown>> =
|
|
|
55
52
|
* Error hook
|
|
56
53
|
*/
|
|
57
54
|
readonly onError: (error: Error) => void
|
|
58
|
-
readonly meta: Meta
|
|
59
55
|
readonly children?: KubbNode
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
export function Root
|
|
58
|
+
export function Root({ onError, onExit, children }: RootProps) {
|
|
63
59
|
try {
|
|
64
60
|
return (
|
|
65
61
|
<ErrorBoundary
|
|
@@ -67,7 +63,7 @@ export function Root<Meta extends Record<string, unknown> = Record<string, unkno
|
|
|
67
63
|
onError(error)
|
|
68
64
|
}}
|
|
69
65
|
>
|
|
70
|
-
<RootContext.Provider value={{
|
|
66
|
+
<RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>
|
|
71
67
|
</ErrorBoundary>
|
|
72
68
|
)
|
|
73
69
|
} catch (_e) {
|
package/src/components/Type.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { JSDoc, Key, KubbNode } from '../types.ts'
|
|
2
|
-
import { Space } from './Text.tsx'
|
|
3
2
|
import { createJSDoc } from '../utils/createJSDoc.ts'
|
|
4
3
|
|
|
5
4
|
type Props = {
|
|
@@ -32,12 +31,7 @@ export function Type({ name, export: canExport, JSDoc, children }: Props) {
|
|
|
32
31
|
<br />
|
|
33
32
|
</>
|
|
34
33
|
)}
|
|
35
|
-
{canExport &&
|
|
36
|
-
<>
|
|
37
|
-
export
|
|
38
|
-
<Space />
|
|
39
|
-
</>
|
|
40
|
-
)}
|
|
34
|
+
{canExport && <>export </>}
|
|
41
35
|
type {name} = {children}
|
|
42
36
|
</>
|
|
43
37
|
)
|
|
@@ -4,12 +4,12 @@ import { App, type AppContextProps } from '../components/App.tsx'
|
|
|
4
4
|
/**
|
|
5
5
|
* `useApp` will return the current App with plugin, pluginManager, fileManager and mode.
|
|
6
6
|
*/
|
|
7
|
-
export function useApp(): AppContextProps {
|
|
7
|
+
export function useApp<TMeta = unknown>(): AppContextProps<TMeta> {
|
|
8
8
|
const app = useContext(App.Context)
|
|
9
9
|
|
|
10
10
|
if (!app) {
|
|
11
11
|
throw new Error('<App /> should be set')
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
return app
|
|
14
|
+
return app as AppContextProps<TMeta>
|
|
15
15
|
}
|
package/src/createApp.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import process from 'node:process'
|
|
2
1
|
import { defineApp } from '@kubb/fabric-core'
|
|
3
|
-
import type
|
|
4
|
-
import {
|
|
5
|
-
import { ReactTemplate } from './ReactTemplate.tsx'
|
|
2
|
+
import { type ElementType, createElement } from 'react'
|
|
3
|
+
import { type ReactAppContext, ReactTemplate } from './ReactTemplate.tsx'
|
|
6
4
|
|
|
7
|
-
export const createApp = defineApp<ElementType>((app, context) => {
|
|
8
|
-
const template =
|
|
9
|
-
process.env.NODE_ENV === 'test'
|
|
10
|
-
? new ReactTemplate({ context })
|
|
11
|
-
: new ReactTemplate({ context, stdout: process.stdout, stderr: process.stderr, stdin: process.stdin })
|
|
5
|
+
export const createApp = defineApp<ElementType, ReactAppContext>((app, context) => {
|
|
6
|
+
const template = new ReactTemplate(context)
|
|
12
7
|
|
|
13
8
|
return {
|
|
14
9
|
render() {
|
package/src/dom.ts
CHANGED
|
@@ -11,13 +11,15 @@ export const createNode = (nodeName: string): DOMElement => {
|
|
|
11
11
|
return node
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const appendChildNode = (node:
|
|
14
|
+
export const appendChildNode = (node: DOMNode, childNode: DOMElement | DOMNode): void => {
|
|
15
15
|
if (childNode.parentNode) {
|
|
16
16
|
removeChildNode(childNode.parentNode, childNode)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (node.nodeName !== '#text') {
|
|
20
|
+
childNode.parentNode = node
|
|
21
|
+
node.childNodes.push(childNode)
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode): void => {
|
package/src/globals.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,12 +7,11 @@ export { Const } from './components/Const.tsx'
|
|
|
7
7
|
export { File } from './components/File.tsx'
|
|
8
8
|
export { Function } from './components/Function.tsx'
|
|
9
9
|
export { Indent } from './components/Indent.tsx'
|
|
10
|
-
export { Text } from './components/Text.tsx'
|
|
11
10
|
export { Type } from './components/Type.tsx'
|
|
12
11
|
export { createApp } from './createApp.ts'
|
|
13
|
-
export { useApp } from './
|
|
14
|
-
export { useFile } from './
|
|
15
|
-
export { useLifecycle } from './
|
|
12
|
+
export { useApp } from './composables/useApp.ts'
|
|
13
|
+
export { useFile } from './composables/useFile.ts'
|
|
14
|
+
export { useLifecycle } from './composables/useLifecycle.tsx'
|
|
16
15
|
export { createFunctionParams, FunctionParams } from './utils/getFunctionParams.ts'
|
|
17
16
|
|
|
18
17
|
export const createContext = React.createContext
|
|
@@ -3,7 +3,7 @@ import { squashExportNodes } from './squashExportNodes.ts'
|
|
|
3
3
|
import { squashImportNodes } from './squashImportNodes.ts'
|
|
4
4
|
import { squashSourceNodes } from './squashSourceNodes.ts'
|
|
5
5
|
|
|
6
|
-
import type { AppContext, KubbFile } from '@kubb/fabric-core'
|
|
6
|
+
import type { AppContext, KubbFile } from '@kubb/fabric-core/types'
|
|
7
7
|
import type React from 'react'
|
|
8
8
|
import type { File } from '../components/File.tsx'
|
|
9
9
|
import type { DOMElement } from '../types.ts'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nodeNames } from '../dom.ts'
|
|
2
2
|
|
|
3
|
-
import type { KubbFile } from '@kubb/fabric-core'
|
|
3
|
+
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
4
4
|
import type React from 'react'
|
|
5
5
|
import type { File } from '../components/File.tsx'
|
|
6
6
|
import type { DOMElement } from '../types.ts'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nodeNames } from '../dom.ts'
|
|
2
2
|
|
|
3
|
-
import type { KubbFile } from '@kubb/fabric-core'
|
|
3
|
+
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
4
4
|
import type React from 'react'
|
|
5
5
|
import type { File } from '../components/File.tsx'
|
|
6
6
|
import type { DOMElement } from '../types.ts'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nodeNames } from '../dom.ts'
|
|
2
2
|
|
|
3
|
-
import type { KubbFile } from '@kubb/fabric-core'
|
|
3
|
+
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
4
4
|
import type React from 'react'
|
|
5
5
|
import type { File } from '../components/File.tsx'
|
|
6
6
|
import type { DOMElement, ElementNames } from '../types.ts'
|
package/dist/jsx-dev-runtime.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
require('./react-Bq0UOw6S.cjs');
|
|
2
|
-
require('./globals-8sJ940pg.cjs');
|
|
3
|
-
require('./jsx-runtime-B3MMb3PL.cjs');
|
|
4
|
-
const require_jsx_runtime$1 = require('./jsx-runtime-zKfRQHQD.cjs');
|
|
5
|
-
|
|
6
|
-
exports.Fragment = require_jsx_runtime$1.Fragment;
|
|
7
|
-
exports.jsx = require_jsx_runtime$1.jsx;
|
|
8
|
-
exports.jsxDEV = require_jsx_runtime$1.jsxDEV;
|
|
9
|
-
exports.jsxs = require_jsx_runtime$1.jsxs;
|
package/dist/jsx-dev-runtime.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { r as __toESM } from "./react-BBkwFtZV.js";
|
|
2
|
-
import { t as require_jsx_runtime } from "./jsx-runtime-BPQkRAg2.js";
|
|
3
|
-
|
|
4
|
-
//#region src/jsx-runtime.ts
|
|
5
|
-
var import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime(), 1);
|
|
6
|
-
const Fragment = import_jsx_runtime.Fragment;
|
|
7
|
-
const jsx = import_jsx_runtime.jsx;
|
|
8
|
-
const jsxs = import_jsx_runtime.jsxs;
|
|
9
|
-
const jsxDEV = import_jsx_runtime.jsx;
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
export { jsxs as i, jsx as n, jsxDEV as r, Fragment as t };
|
|
13
|
-
//# sourceMappingURL=jsx-runtime-DmD5u6a-.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime-DmD5u6a-.js","names":[],"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import './globals.ts'\n\nimport ReactJSXRuntime from 'react/jsx-runtime'\n\nexport const Fragment = ReactJSXRuntime.Fragment\nexport const jsx = ReactJSXRuntime.jsx\nexport const jsxs = ReactJSXRuntime.jsxs\nexport const jsxDEV = ReactJSXRuntime.jsx\n"],"mappings":";;;;;AAIA,MAAa,8BAA2B;AACxC,MAAa,yBAAsB;AACnC,MAAa,0BAAuB;AACpC,MAAa,4BAAyB"}
|