@kubb/react-fabric 0.2.0 → 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.
Files changed (76) hide show
  1. package/README.md +49 -78
  2. package/dist/{App-D7ehObix.d.ts → Fabric-nxgJyzWH.d.cts} +27 -27
  3. package/dist/{App-CbT7rbmH.d.cts → Fabric-tVWTpMR5.d.ts} +27 -27
  4. package/dist/{KubbFile-D4gyyfL-.d.ts → KubbFile-DFnA3mmn.d.ts} +1 -1
  5. package/dist/{KubbFile-FGXV713i.d.cts → KubbFile-DHCtBOpy.d.cts} +1 -1
  6. package/dist/chunk-CVmoYqME.js +27 -0
  7. package/dist/chunk-DWy1uDak.cjs +39 -0
  8. package/dist/devtools-DPye8o33.js +11448 -0
  9. package/dist/devtools-DPye8o33.js.map +1 -0
  10. package/dist/devtools-DnQsy6Us.cjs +11456 -0
  11. package/dist/devtools-DnQsy6Us.cjs.map +1 -0
  12. package/dist/devtools.cjs +2 -10885
  13. package/dist/devtools.d.cts +11 -1
  14. package/dist/devtools.d.ts +11 -1
  15. package/dist/devtools.js +2 -10885
  16. package/dist/{globals-BRG2DOJd.d.cts → globals-C7dPa-nz.d.cts} +3 -3
  17. package/dist/{globals-D_1Lfe9-.d.ts → globals-CxZEi_Pn.d.ts} +3 -3
  18. package/dist/globals.d.cts +3 -3
  19. package/dist/globals.d.ts +3 -3
  20. package/dist/index.cjs +34 -23
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +16 -9
  23. package/dist/index.d.ts +16 -9
  24. package/dist/index.js +15 -5
  25. package/dist/index.js.map +1 -1
  26. package/dist/jsx-dev-runtime.cjs +8 -0
  27. package/dist/jsx-dev-runtime.js +5 -0
  28. package/dist/jsx-runtime-9ohe6OS2.cjs +36 -0
  29. package/dist/jsx-runtime-9ohe6OS2.cjs.map +1 -0
  30. package/dist/{react-BBkwFtZV.js → jsx-runtime-BOrVcbIT.cjs} +253 -42
  31. package/dist/jsx-runtime-BOrVcbIT.cjs.map +1 -0
  32. package/dist/{react-Bq0UOw6S.cjs → jsx-runtime-CFd_ktZn.js} +239 -57
  33. package/dist/jsx-runtime-CFd_ktZn.js.map +1 -0
  34. package/dist/jsx-runtime-CvGZkcTo.js +13 -0
  35. package/dist/jsx-runtime-CvGZkcTo.js.map +1 -0
  36. package/dist/jsx-runtime.cjs +6 -15
  37. package/dist/jsx-runtime.d.cts +3 -3
  38. package/dist/jsx-runtime.d.ts +3 -3
  39. package/dist/jsx-runtime.js +3 -12
  40. package/dist/parsers.d.cts +2 -2
  41. package/dist/parsers.d.ts +2 -2
  42. package/dist/{Runtime-DJ4dWT9w.cjs → plugins-CEGJdkpj.cjs} +110 -76
  43. package/dist/plugins-CEGJdkpj.cjs.map +1 -0
  44. package/dist/{Runtime-CatKeybQ.js → plugins-aZCNhIC8.js} +85 -58
  45. package/dist/plugins-aZCNhIC8.js.map +1 -0
  46. package/dist/plugins.cjs +4 -36
  47. package/dist/plugins.d.cts +16 -49
  48. package/dist/plugins.d.ts +16 -49
  49. package/dist/plugins.js +3 -34
  50. package/dist/reactPlugin-B47Guoya.d.ts +38 -0
  51. package/dist/reactPlugin-CLgWWifj.d.cts +38 -0
  52. package/dist/{types-C3p0Ljxf.d.cts → types-DoYRYV1C.d.cts} +1 -1
  53. package/dist/{types-Brnyan9B.d.ts → types-u_NEi07i.d.ts} +1 -1
  54. package/dist/types.d.cts +1 -1
  55. package/dist/types.d.ts +1 -1
  56. package/package.json +10 -6
  57. package/src/Renderer.ts +26 -22
  58. package/src/Runtime.tsx +2 -2
  59. package/src/createReactFabric.ts +17 -0
  60. package/src/devtools.ts +106 -111
  61. package/src/index.ts +2 -1
  62. package/src/plugins/reactPlugin.ts +3 -3
  63. package/dist/Runtime-CatKeybQ.js.map +0 -1
  64. package/dist/Runtime-DJ4dWT9w.cjs.map +0 -1
  65. package/dist/devtools.cjs.map +0 -1
  66. package/dist/devtools.js.map +0 -1
  67. package/dist/jsx-runtime-Dg-pJBHd.js +0 -228
  68. package/dist/jsx-runtime-Dg-pJBHd.js.map +0 -1
  69. package/dist/jsx-runtime-d2dmYscH.cjs +0 -233
  70. package/dist/jsx-runtime-d2dmYscH.cjs.map +0 -1
  71. package/dist/jsx-runtime.cjs.map +0 -1
  72. package/dist/jsx-runtime.js.map +0 -1
  73. package/dist/plugins.cjs.map +0 -1
  74. package/dist/plugins.js.map +0 -1
  75. package/dist/react-BBkwFtZV.js.map +0 -1
  76. package/dist/react-Bq0UOw6S.cjs.map +0 -1
package/src/devtools.ts CHANGED
@@ -1,118 +1,113 @@
1
- // @ts-expect-error cannot find package
2
- import { connectToDevTools } from 'react-devtools-inline/backend'
3
- // import { onExit } from 'signal-exit'
4
- import { WebSocketServer } from 'ws'
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
- // declare global {
7
- // var WebSocket: typeof WebSocket
8
- // var self: any
9
- // var window: any
10
- // var isDevtoolsEnabled: any
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
- // const customGlobal: any = globalThis
17
- // customGlobal.WebSocket ||= ws
18
- // customGlobal.window ||= customGlobal
19
- // customGlobal.self ||= customGlobal
20
- // customGlobal.isDevtoolsEnabled = true
21
- // customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
22
- // {
23
- // // ComponentFilterDisplayName
24
- // type: 2,
25
- // value: 'Context.Provider',
26
- // isEnabled: true,
27
- // isValid: true,
28
- // },
29
- // {
30
- // // ComponentFilterDisplayName
31
- // type: 2,
32
- // value: 'KubbRoot',
33
- // isEnabled: true,
34
- // isValid: true,
35
- // },
36
- // {
37
- // // ComponentFilterDisplayName
38
- // type: 2,
39
- // value: 'KubbErrorBoundary',
40
- // isEnabled: true,
41
- // isValid: true,
42
- // },
43
- // {
44
- // // ComponentFilterDisplayName
45
- // type: 2,
46
- // value: 'kubb-file',
47
- // isEnabled: true,
48
- // isValid: true,
49
- // },
50
- // {
51
- // // ComponentFilterDisplayName
52
- // type: 2,
53
- // value: 'kubb-text',
54
- // isEnabled: true,
55
- // isValid: true,
56
- // },
57
- // {
58
- // // ComponentFilterDisplayName
59
- // type: 2,
60
- // value: 'kubb-import',
61
- // isEnabled: true,
62
- // isValid: true,
63
- // },
64
- // {
65
- // // ComponentFilterDisplayName
66
- // type: 2,
67
- // value: 'kubb-export',
68
- // isEnabled: true,
69
- // isValid: true,
70
- // },
71
- // {
72
- // // ComponentFilterDisplayName
73
- // type: 2,
74
- // value: 'kubb-source',
75
- // isEnabled: true,
76
- // isValid: true,
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
- function openDevtools() {
81
- // let subprocess: { kill: () => void }
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
- const wss = new WebSocketServer({ port: 8097 })
91
+ ;(devtools as any).initialize()
92
+ console.info('Connecting devtools')
84
93
 
85
- connectToDevTools({
86
- websocket: wss,
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
- // import('execa')
90
- // .then(async (execa) => {
91
- // console.log('Opening devtools')
92
- //
93
- // subprocess = execa.execa({ preferLocal: true })`npx react-devtools`
94
- // })
95
- // .then(() => {
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 { createApp } from '@kubb/fabric-core'
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 App {
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 App {
33
+ interface Fabric {
34
34
  render(App: ElementType): Promise<void> | void
35
35
  renderToString(App: ElementType): Promise<string> | string
36
36
  waitUntilExit(): Promise<void>