@kubb/react-fabric 0.2.0 → 0.2.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.
Files changed (80) hide show
  1. package/README.md +49 -78
  2. package/dist/{App-CbT7rbmH.d.cts → Fabric-DwVGMumV.d.ts} +27 -27
  3. package/dist/{App-D7ehObix.d.ts → Fabric-nxgJyzWH.d.cts} +27 -27
  4. package/dist/{KubbFile-FGXV713i.d.cts → KubbFile-DHCtBOpy.d.cts} +1 -1
  5. package/dist/{KubbFile-D4gyyfL-.d.ts → KubbFile-bFdmEsQz.d.ts} +1 -1
  6. package/dist/backend-BwCrJwGY.cjs +11364 -0
  7. package/dist/backend-BwCrJwGY.cjs.map +1 -0
  8. package/dist/backend-U2f8IEJ7.js +11361 -0
  9. package/dist/backend-U2f8IEJ7.js.map +1 -0
  10. package/dist/chunk-9mlisOrp.js +28 -0
  11. package/dist/chunk-BaqVhFee.cjs +46 -0
  12. package/dist/devtools-CYVZyenT.cjs +102 -0
  13. package/dist/devtools-CYVZyenT.cjs.map +1 -0
  14. package/dist/devtools-D7cmED8s.js +94 -0
  15. package/dist/devtools-D7cmED8s.js.map +1 -0
  16. package/dist/devtools.cjs +2 -10885
  17. package/dist/devtools.d.cts +11 -1
  18. package/dist/devtools.d.ts +11 -1
  19. package/dist/devtools.js +2 -10885
  20. package/dist/{globals-D_1Lfe9-.d.ts → globals-1MFa0Fvg.d.ts} +3 -3
  21. package/dist/{globals-BRG2DOJd.d.cts → globals-C7dPa-nz.d.cts} +3 -3
  22. package/dist/globals.d.cts +3 -3
  23. package/dist/globals.d.ts +3 -3
  24. package/dist/index.cjs +34 -23
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +16 -9
  27. package/dist/index.d.ts +16 -9
  28. package/dist/index.js +15 -5
  29. package/dist/index.js.map +1 -1
  30. package/dist/jsx-dev-runtime.cjs +8 -0
  31. package/dist/jsx-dev-runtime.js +5 -0
  32. package/dist/jsx-runtime-8_h1Kd4b.cjs +36 -0
  33. package/dist/jsx-runtime-8_h1Kd4b.cjs.map +1 -0
  34. package/dist/jsx-runtime-BJX2mL7C.js +13 -0
  35. package/dist/jsx-runtime-BJX2mL7C.js.map +1 -0
  36. package/dist/{react-Bq0UOw6S.cjs → jsx-runtime-C9xQ4GQD.js} +239 -57
  37. package/dist/jsx-runtime-C9xQ4GQD.js.map +1 -0
  38. package/dist/{react-BBkwFtZV.js → jsx-runtime-CSnwG7o6.cjs} +253 -42
  39. package/dist/jsx-runtime-CSnwG7o6.cjs.map +1 -0
  40. package/dist/jsx-runtime.cjs +6 -15
  41. package/dist/jsx-runtime.d.cts +3 -3
  42. package/dist/jsx-runtime.d.ts +3 -3
  43. package/dist/jsx-runtime.js +3 -12
  44. package/dist/parsers.d.cts +2 -2
  45. package/dist/parsers.d.ts +2 -2
  46. package/dist/{Runtime-DJ4dWT9w.cjs → plugins-BQE1GnQ7.cjs} +110 -76
  47. package/dist/plugins-BQE1GnQ7.cjs.map +1 -0
  48. package/dist/{Runtime-CatKeybQ.js → plugins-BVFjgEC2.js} +85 -58
  49. package/dist/plugins-BVFjgEC2.js.map +1 -0
  50. package/dist/plugins.cjs +4 -36
  51. package/dist/plugins.d.cts +16 -49
  52. package/dist/plugins.d.ts +16 -49
  53. package/dist/plugins.js +3 -34
  54. package/dist/reactPlugin-CLgWWifj.d.cts +38 -0
  55. package/dist/reactPlugin-DyvfLVFa.d.ts +38 -0
  56. package/dist/{types-Brnyan9B.d.ts → types-BnXxcIyv.d.ts} +1 -1
  57. package/dist/{types-C3p0Ljxf.d.cts → types-DoYRYV1C.d.cts} +1 -1
  58. package/dist/types.d.cts +1 -1
  59. package/dist/types.d.ts +1 -1
  60. package/package.json +10 -6
  61. package/src/Renderer.ts +26 -22
  62. package/src/Runtime.tsx +2 -2
  63. package/src/createReactFabric.ts +17 -0
  64. package/src/devtools.ts +107 -110
  65. package/src/index.ts +2 -1
  66. package/src/plugins/reactPlugin.ts +3 -3
  67. package/dist/Runtime-CatKeybQ.js.map +0 -1
  68. package/dist/Runtime-DJ4dWT9w.cjs.map +0 -1
  69. package/dist/devtools.cjs.map +0 -1
  70. package/dist/devtools.js.map +0 -1
  71. package/dist/jsx-runtime-Dg-pJBHd.js +0 -228
  72. package/dist/jsx-runtime-Dg-pJBHd.js.map +0 -1
  73. package/dist/jsx-runtime-d2dmYscH.cjs +0 -233
  74. package/dist/jsx-runtime-d2dmYscH.cjs.map +0 -1
  75. package/dist/jsx-runtime.cjs.map +0 -1
  76. package/dist/jsx-runtime.js.map +0 -1
  77. package/dist/plugins.cjs.map +0 -1
  78. package/dist/plugins.js.map +0 -1
  79. package/dist/react-BBkwFtZV.js.map +0 -1
  80. package/dist/react-Bq0UOw6S.cjs.map +0 -1
package/src/devtools.ts CHANGED
@@ -1,118 +1,115 @@
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'
5
2
 
6
- // declare global {
7
- // var WebSocket: typeof WebSocket
8
- // var self: any
9
- // var window: any
10
- // var isDevtoolsEnabled: any
11
- // }
3
+ import ws from 'ws'
4
+ import { execa } from 'execa'
12
5
 
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
6
+ declare global {
7
+ var WebSocket: typeof WebSocket
8
+ var self: any
9
+ var window: any
10
+ var isDevtoolsEnabled: any
11
+ }
15
12
 
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
- // ]
13
+ export function open() {
14
+ // biome-ignore lint/suspicious/noTsIgnore: cannot find types
15
+ // @ts-ignore
16
+ import('react-devtools-core').then((devtools) => {
17
+ // Filter out Kubbs's internal components from devtools for a cleaner view.
18
+ // See https://github.com/facebook/react/blob/edf6eac8a181860fd8a2d076a43806f1237495a1/packages/react-devtools-shared/src/types.js#L24
19
+ const customGlobal = global as any
20
+ customGlobal.WebSocket ||= ws
21
+ customGlobal.window ||= global
22
+ customGlobal.self ||= global
23
+ customGlobal.isDevtoolsEnabled = true
24
+ customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
25
+ {
26
+ // ComponentFilterDisplayName
27
+ type: 2,
28
+ value: 'Context.Provider',
29
+ isEnabled: true,
30
+ isValid: true,
31
+ },
32
+ {
33
+ // ComponentFilterDisplayName
34
+ type: 2,
35
+ value: 'KubbRoot',
36
+ isEnabled: true,
37
+ isValid: true,
38
+ },
39
+ {
40
+ // ComponentFilterDisplayName
41
+ type: 2,
42
+ value: 'KubbErrorBoundary',
43
+ isEnabled: true,
44
+ isValid: true,
45
+ },
46
+ {
47
+ // ComponentFilterDisplayName
48
+ type: 2,
49
+ value: 'kubb-file',
50
+ isEnabled: true,
51
+ isValid: true,
52
+ },
53
+ {
54
+ // ComponentFilterDisplayName
55
+ type: 2,
56
+ value: 'kubb-text',
57
+ isEnabled: true,
58
+ isValid: true,
59
+ },
60
+ {
61
+ // ComponentFilterDisplayName
62
+ type: 2,
63
+ value: 'kubb-import',
64
+ isEnabled: true,
65
+ isValid: true,
66
+ },
67
+ {
68
+ // ComponentFilterDisplayName
69
+ type: 2,
70
+ value: 'kubb-export',
71
+ isEnabled: true,
72
+ isValid: true,
73
+ },
74
+ {
75
+ // ComponentFilterDisplayName
76
+ type: 2,
77
+ value: 'kubb-source',
78
+ isEnabled: true,
79
+ isValid: true,
80
+ },
81
+ ]
79
82
 
80
- function openDevtools() {
81
- // let subprocess: { kill: () => void }
83
+ console.info('Opening devtools')
84
+ const controller = new AbortController()
85
+ execa({
86
+ stdio: 'pipe',
87
+ preferLocal: true,
88
+ cancelSignal: controller.signal,
89
+ gracefulCancel: true,
90
+ })`npx react-devtools`
82
91
 
83
- const wss = new WebSocketServer({ port: 8097 })
92
+ ;(devtools as any).initialize()
93
+ console.info('Connecting devtools')
84
94
 
85
- connectToDevTools({
86
- websocket: wss,
87
- })
95
+ try {
96
+ ;(devtools as any).connectToDevTools({
97
+ host: 'localhost',
98
+ port: 8097,
99
+ useHttps: false,
100
+ isAppActive: () => true,
101
+ })
102
+ } catch (e) {
103
+ console.error(e)
104
+ console.info('Error when connecting the devtools')
105
+ }
88
106
 
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
- // )
107
+ onExit(
108
+ () => {
109
+ console.info('Disconnecting devtools')
110
+ controller.abort()
111
+ },
112
+ { alwaysLast: false },
113
+ )
114
+ })
116
115
  }
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>