@kubb/react-fabric 0.1.8 → 0.2.1
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/README.md +273 -26
- package/dist/{App-D7ehObix.d.ts → Fabric-nxgJyzWH.d.cts} +27 -27
- package/dist/{App-CbT7rbmH.d.cts → Fabric-tVWTpMR5.d.ts} +27 -27
- package/dist/{KubbFile-D4gyyfL-.d.ts → KubbFile-DFnA3mmn.d.ts} +1 -1
- package/dist/{KubbFile-FGXV713i.d.cts → KubbFile-DHCtBOpy.d.cts} +1 -1
- package/dist/chunk-CVmoYqME.js +27 -0
- package/dist/chunk-DWy1uDak.cjs +39 -0
- package/dist/devtools-DPye8o33.js +11448 -0
- package/dist/devtools-DPye8o33.js.map +1 -0
- package/dist/devtools-DnQsy6Us.cjs +11456 -0
- package/dist/devtools-DnQsy6Us.cjs.map +1 -0
- package/dist/devtools.cjs +2 -10885
- package/dist/devtools.d.cts +11 -1
- package/dist/devtools.d.ts +11 -1
- package/dist/devtools.js +2 -10885
- package/dist/{globals-BRG2DOJd.d.cts → globals-C7dPa-nz.d.cts} +3 -3
- package/dist/{globals-D_1Lfe9-.d.ts → globals-CxZEi_Pn.d.ts} +3 -3
- package/dist/globals.d.cts +3 -3
- package/dist/globals.d.ts +3 -3
- package/dist/index.cjs +34 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -9
- package/dist/index.d.ts +16 -9
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.cjs +8 -0
- package/dist/jsx-dev-runtime.js +5 -0
- package/dist/jsx-runtime-9ohe6OS2.cjs +36 -0
- package/dist/jsx-runtime-9ohe6OS2.cjs.map +1 -0
- package/dist/{react-BBkwFtZV.js → jsx-runtime-BOrVcbIT.cjs} +253 -42
- package/dist/jsx-runtime-BOrVcbIT.cjs.map +1 -0
- package/dist/{react-Bq0UOw6S.cjs → jsx-runtime-CFd_ktZn.js} +239 -57
- package/dist/jsx-runtime-CFd_ktZn.js.map +1 -0
- package/dist/jsx-runtime-CvGZkcTo.js +13 -0
- package/dist/jsx-runtime-CvGZkcTo.js.map +1 -0
- package/dist/jsx-runtime.cjs +6 -15
- package/dist/jsx-runtime.d.cts +3 -3
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.js +3 -12
- package/dist/parsers.d.cts +2 -2
- package/dist/parsers.d.ts +2 -2
- package/dist/{Runtime-JI640uK4.cjs → plugins-CEGJdkpj.cjs} +115 -81
- package/dist/plugins-CEGJdkpj.cjs.map +1 -0
- package/dist/{Runtime-DWlDUeLZ.js → plugins-aZCNhIC8.js} +90 -63
- package/dist/plugins-aZCNhIC8.js.map +1 -0
- package/dist/plugins.cjs +4 -35
- package/dist/plugins.d.cts +16 -49
- package/dist/plugins.d.ts +16 -49
- package/dist/plugins.js +3 -33
- package/dist/reactPlugin-B47Guoya.d.ts +38 -0
- package/dist/reactPlugin-CLgWWifj.d.cts +38 -0
- package/dist/{types-C3p0Ljxf.d.cts → types-DoYRYV1C.d.cts} +1 -1
- package/dist/{types-Brnyan9B.d.ts → types-u_NEi07i.d.ts} +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +11 -7
- package/src/Renderer.ts +26 -22
- package/src/Runtime.tsx +8 -7
- package/src/createReactFabric.ts +17 -0
- package/src/devtools.ts +106 -111
- package/src/index.ts +2 -1
- package/src/plugins/reactPlugin.ts +4 -3
- package/dist/Runtime-DWlDUeLZ.js.map +0 -1
- package/dist/Runtime-JI640uK4.cjs.map +0 -1
- package/dist/devtools.cjs.map +0 -1
- package/dist/devtools.js.map +0 -1
- package/dist/jsx-runtime-Dg-pJBHd.js +0 -228
- package/dist/jsx-runtime-Dg-pJBHd.js.map +0 -1
- package/dist/jsx-runtime-d2dmYscH.cjs +0 -233
- package/dist/jsx-runtime-d2dmYscH.cjs.map +0 -1
- package/dist/jsx-runtime.cjs.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
- package/dist/plugins.cjs.map +0 -1
- package/dist/plugins.js.map +0 -1
- package/dist/react-BBkwFtZV.js.map +0 -1
- package/dist/react-Bq0UOw6S.cjs.map +0 -1
package/src/devtools.ts
CHANGED
|
@@ -1,118 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
import
|
|
1
|
+
import { onExit } from 'signal-exit'
|
|
2
|
+
// biome-ignore lint/suspicious/noTsIgnore: cannot find types
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import devtools from 'react-devtools-core'
|
|
5
|
+
import ws from 'ws'
|
|
6
|
+
import { execa } from 'execa'
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Filter out Kubbs's internal components from devtools for a cleaner view.
|
|
14
|
-
// See https://github.com/facebook/react/blob/edf6eac8a181860fd8a2d076a43806f1237495a1/packages/react-devtools-shared/src/types.js#L24
|
|
8
|
+
declare global {
|
|
9
|
+
var WebSocket: typeof WebSocket
|
|
10
|
+
var self: any
|
|
11
|
+
var window: any
|
|
12
|
+
var isDevtoolsEnabled: any
|
|
13
|
+
}
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
15
|
+
export function open() {
|
|
16
|
+
// Filter out Kubbs's internal components from devtools for a cleaner view.
|
|
17
|
+
// See https://github.com/facebook/react/blob/edf6eac8a181860fd8a2d076a43806f1237495a1/packages/react-devtools-shared/src/types.js#L24
|
|
18
|
+
const customGlobal = global as any
|
|
19
|
+
customGlobal.WebSocket ||= ws
|
|
20
|
+
customGlobal.window ||= global
|
|
21
|
+
customGlobal.self ||= global
|
|
22
|
+
customGlobal.isDevtoolsEnabled = true
|
|
23
|
+
customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
|
|
24
|
+
{
|
|
25
|
+
// ComponentFilterDisplayName
|
|
26
|
+
type: 2,
|
|
27
|
+
value: 'Context.Provider',
|
|
28
|
+
isEnabled: true,
|
|
29
|
+
isValid: true,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
// ComponentFilterDisplayName
|
|
33
|
+
type: 2,
|
|
34
|
+
value: 'KubbRoot',
|
|
35
|
+
isEnabled: true,
|
|
36
|
+
isValid: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
// ComponentFilterDisplayName
|
|
40
|
+
type: 2,
|
|
41
|
+
value: 'KubbErrorBoundary',
|
|
42
|
+
isEnabled: true,
|
|
43
|
+
isValid: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
// ComponentFilterDisplayName
|
|
47
|
+
type: 2,
|
|
48
|
+
value: 'kubb-file',
|
|
49
|
+
isEnabled: true,
|
|
50
|
+
isValid: true,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
// ComponentFilterDisplayName
|
|
54
|
+
type: 2,
|
|
55
|
+
value: 'kubb-text',
|
|
56
|
+
isEnabled: true,
|
|
57
|
+
isValid: true,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
// ComponentFilterDisplayName
|
|
61
|
+
type: 2,
|
|
62
|
+
value: 'kubb-import',
|
|
63
|
+
isEnabled: true,
|
|
64
|
+
isValid: true,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
// ComponentFilterDisplayName
|
|
68
|
+
type: 2,
|
|
69
|
+
value: 'kubb-export',
|
|
70
|
+
isEnabled: true,
|
|
71
|
+
isValid: true,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
// ComponentFilterDisplayName
|
|
75
|
+
type: 2,
|
|
76
|
+
value: 'kubb-source',
|
|
77
|
+
isEnabled: true,
|
|
78
|
+
isValid: true,
|
|
79
|
+
},
|
|
80
|
+
]
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
console.info('Opening devtools')
|
|
83
|
+
const controller = new AbortController()
|
|
84
|
+
execa({
|
|
85
|
+
stdio: 'pipe',
|
|
86
|
+
preferLocal: true,
|
|
87
|
+
cancelSignal: controller.signal,
|
|
88
|
+
gracefulCancel: true,
|
|
89
|
+
})`npx react-devtools`
|
|
82
90
|
|
|
83
|
-
|
|
91
|
+
;(devtools as any).initialize()
|
|
92
|
+
console.info('Connecting devtools')
|
|
84
93
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
try {
|
|
95
|
+
;(devtools as any).connectToDevTools({
|
|
96
|
+
host: 'localhost',
|
|
97
|
+
port: 8097,
|
|
98
|
+
useHttps: false,
|
|
99
|
+
isAppActive: () => true,
|
|
100
|
+
})
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error(e)
|
|
103
|
+
console.info('Error when connecting the devtools')
|
|
104
|
+
}
|
|
88
105
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
// // @ts-expect-error
|
|
97
|
-
// return import('react-devtools-inline/backend')
|
|
98
|
-
// })
|
|
99
|
-
// .then((devtools) => {
|
|
100
|
-
// console.log('Connecting devtools')
|
|
101
|
-
// console.log(window.__REACT_DEVTOOLS_GLOBAL_HOOK__, customGlobal.window.__REACT_DEVTOOLS_GLOBAL_HOOK__)
|
|
102
|
-
// devtools.initialize()
|
|
103
|
-
// devtools.connectToDevTools()
|
|
104
|
-
// })
|
|
105
|
-
// .catch((err) => {
|
|
106
|
-
// console.log('Error connecting devtools\n', err)
|
|
107
|
-
// })
|
|
108
|
-
//
|
|
109
|
-
// onExit(
|
|
110
|
-
// () => {
|
|
111
|
-
// console.log('Disconnecting devtools')
|
|
112
|
-
// subprocess?.kill()
|
|
113
|
-
// },
|
|
114
|
-
// { alwaysLast: false },
|
|
115
|
-
// )
|
|
106
|
+
onExit(
|
|
107
|
+
() => {
|
|
108
|
+
console.info('Disconnecting devtools')
|
|
109
|
+
controller.abort()
|
|
110
|
+
},
|
|
111
|
+
{ alwaysLast: false },
|
|
112
|
+
)
|
|
116
113
|
}
|
|
117
|
-
|
|
118
|
-
openDevtools()
|
package/src/index.ts
CHANGED
|
@@ -15,7 +15,8 @@ export { useFile } from './composables/useFile.ts'
|
|
|
15
15
|
export { useLifecycle } from './composables/useLifecycle.tsx'
|
|
16
16
|
|
|
17
17
|
// expose fabric core helpers
|
|
18
|
-
export {
|
|
18
|
+
export { createFabric } from '@kubb/fabric-core'
|
|
19
|
+
export { createReactFabric } from './createReactFabric.ts'
|
|
19
20
|
|
|
20
21
|
// utils
|
|
21
22
|
export { createFunctionParams, FunctionParams } from './utils/getFunctionParams.ts'
|
|
@@ -2,7 +2,7 @@ import { createPlugin } from '@kubb/fabric-core/plugins'
|
|
|
2
2
|
import { Runtime } from '../Runtime.tsx'
|
|
3
3
|
import { createElement, type ElementType } from 'react'
|
|
4
4
|
|
|
5
|
-
type Options = {
|
|
5
|
+
export type Options = {
|
|
6
6
|
stdout?: NodeJS.WriteStream
|
|
7
7
|
stdin?: NodeJS.ReadStream
|
|
8
8
|
stderr?: NodeJS.WriteStream
|
|
@@ -21,7 +21,7 @@ type ExtendOptions = {
|
|
|
21
21
|
// biome-ignore lint/suspicious/noTsIgnore: production ready
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
declare module '@kubb/fabric-core' {
|
|
24
|
-
interface
|
|
24
|
+
interface Fabric {
|
|
25
25
|
render(App: ElementType): Promise<void> | void
|
|
26
26
|
renderToString(App: ElementType): Promise<string> | string
|
|
27
27
|
waitUntilExit(): Promise<void>
|
|
@@ -30,7 +30,7 @@ declare module '@kubb/fabric-core' {
|
|
|
30
30
|
|
|
31
31
|
declare global {
|
|
32
32
|
namespace Kubb {
|
|
33
|
-
interface
|
|
33
|
+
interface Fabric {
|
|
34
34
|
render(App: ElementType): Promise<void> | void
|
|
35
35
|
renderToString(App: ElementType): Promise<string> | string
|
|
36
36
|
waitUntilExit(): Promise<void>
|
|
@@ -50,6 +50,7 @@ export const reactPlugin = createPlugin<Options, ExtendOptions>({
|
|
|
50
50
|
await app.context.events.emit('start')
|
|
51
51
|
},
|
|
52
52
|
async renderToString(App) {
|
|
53
|
+
await app.context.events.emit('start')
|
|
53
54
|
return runtime.renderToString(createElement(App))
|
|
54
55
|
},
|
|
55
56
|
async waitUntilExit() {
|