@kubb/react-fabric 0.12.4 → 0.12.6

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 (52) hide show
  1. package/dist/globals.d.cts +8 -8
  2. package/dist/globals.d.ts +8 -8
  3. package/dist/index.cjs +37 -39
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +59 -37
  6. package/dist/index.d.ts +59 -37
  7. package/dist/index.js +43 -64
  8. package/dist/index.js.map +1 -1
  9. package/dist/jsx-dev-runtime.cjs.map +1 -1
  10. package/dist/jsx-dev-runtime.d.cts +4 -4
  11. package/dist/jsx-dev-runtime.d.ts +4 -4
  12. package/dist/jsx-dev-runtime.js.map +1 -1
  13. package/dist/{jsx-namespace-fB1bxOIg.d.ts → jsx-namespace-BMpcDF6T.d.ts} +8 -8
  14. package/dist/{jsx-namespace-r-JXq_rp.d.cts → jsx-namespace-BdDNwAgO.d.cts} +8 -8
  15. package/dist/jsx-runtime-6sQc68DD.cjs.map +1 -1
  16. package/dist/jsx-runtime-CpElaHq6.js.map +1 -1
  17. package/dist/jsx-runtime.d.cts +4 -4
  18. package/dist/jsx-runtime.d.ts +4 -4
  19. package/dist/plugins.cjs +1 -1
  20. package/dist/plugins.d.cts +1 -1
  21. package/dist/plugins.d.ts +2 -2
  22. package/dist/plugins.js +1 -1
  23. package/dist/{reactPlugin-CwuxUcyY.js → reactPlugin-C7_IY8_K.js} +85 -83
  24. package/dist/reactPlugin-C7_IY8_K.js.map +1 -0
  25. package/dist/{reactPlugin-BzHuVlbO.cjs → reactPlugin-DbTz9RKJ.cjs} +90 -82
  26. package/dist/reactPlugin-DbTz9RKJ.cjs.map +1 -0
  27. package/dist/{reactPlugin-CVS9VJ5P.d.ts → reactPlugin-Dl5F1rQk.d.ts} +37 -11
  28. package/dist/{reactPlugin-EQOIOEA2.d.cts → reactPlugin-fdJaWnpd.d.cts} +37 -11
  29. package/dist/{types-XiObCuPy.d.ts → types-BKnc-nPE.d.ts} +15 -15
  30. package/dist/{types-J_S-h-Ae.d.cts → types-K0AHi-aU.d.cts} +15 -15
  31. package/dist/types.d.cts +2 -2
  32. package/dist/types.d.ts +2 -2
  33. package/package.json +3 -3
  34. package/src/Renderer.ts +2 -2
  35. package/src/Runtime.tsx +6 -4
  36. package/src/components/App.tsx +4 -4
  37. package/src/components/Const.tsx +4 -4
  38. package/src/components/File.tsx +11 -11
  39. package/src/components/Function.tsx +6 -6
  40. package/src/components/Root.tsx +7 -7
  41. package/src/components/Type.tsx +4 -4
  42. package/src/composables/useLifecycle.tsx +1 -19
  43. package/src/devtools.ts +3 -3
  44. package/src/globals.ts +17 -8
  45. package/src/index.ts +4 -7
  46. package/src/jsx-dev-runtime.ts +3 -3
  47. package/src/jsx-namespace.d.ts +8 -8
  48. package/src/jsx-runtime.ts +3 -3
  49. package/src/plugins/reactPlugin.ts +5 -5
  50. package/src/types.ts +24 -15
  51. package/dist/reactPlugin-BzHuVlbO.cjs.map +0 -1
  52. package/dist/reactPlugin-CwuxUcyY.js.map +0 -1
@@ -1,20 +1,20 @@
1
1
  import { type FileManager, NodeTreeContext, provide, RootContext, type TreeNode } from '@kubb/fabric-core'
2
2
  import { Component } from 'react'
3
3
 
4
- import type { ComponentNode, KubbElement, KubbNode } from '../types.ts'
4
+ import type { ComponentNode, FabricReactElement, FabricReactNode } from '../types.ts'
5
5
 
6
6
  type ErrorBoundaryProps = {
7
7
  onError: (error: Error) => void
8
- children?: KubbNode
8
+ children?: FabricReactNode
9
9
  }
10
10
 
11
11
  class ErrorBoundary extends Component<{
12
12
  onError: ErrorBoundaryProps['onError']
13
- children?: KubbNode
13
+ children?: FabricReactNode
14
14
  }> {
15
15
  state = { hasError: false }
16
16
 
17
- static displayName = 'KubbErrorBoundary'
17
+ static displayName = 'ErrorBoundary'
18
18
  static getDerivedStateFromError(_error: Error) {
19
19
  return { hasError: true }
20
20
  }
@@ -53,13 +53,13 @@ export type RootProps = {
53
53
  /**
54
54
  * Children nodes.
55
55
  */
56
- children?: KubbNode
56
+ children?: FabricReactNode
57
57
  }
58
58
 
59
59
  /**
60
60
  * This component provides the root behavior for the Fabric runtime.
61
61
  */
62
- export function Root({ onError, onExit, treeNode, fileManager, children }: RootProps): KubbElement {
62
+ export function Root({ onError, onExit, treeNode, fileManager, children }: RootProps): FabricReactElement {
63
63
  provide(RootContext, { exit: onExit, treeNode, fileManager })
64
64
  provide(NodeTreeContext, treeNode)
65
65
 
@@ -74,4 +74,4 @@ export function Root({ onError, onExit, treeNode, fileManager, children }: RootP
74
74
  )
75
75
  }
76
76
 
77
- Root.displayName = 'KubbRoot'
77
+ Root.displayName = 'Root'
@@ -1,5 +1,5 @@
1
1
  import { NodeTreeContext, provide, useNodeTree } from '@kubb/fabric-core'
2
- import type { JSDoc, Key, KubbElement, KubbNode } from '../types.ts'
2
+ import type { FabricReactElement, FabricReactNode, JSDoc, Key } from '../types.ts'
3
3
  import { createJSDoc } from '../utils/createJSDoc.ts'
4
4
 
5
5
  export type TypeProps = {
@@ -19,13 +19,13 @@ export type TypeProps = {
19
19
  /**
20
20
  * Children nodes.
21
21
  */
22
- children?: KubbNode
22
+ children?: FabricReactNode
23
23
  }
24
24
 
25
25
  /**
26
26
  * Generates a TypeScript type declaration.
27
27
  */
28
- export function Type({ children, ...props }: TypeProps): KubbElement {
28
+ export function Type({ children, ...props }: TypeProps): FabricReactElement {
29
29
  const { name, export: canExport, JSDoc } = props
30
30
 
31
31
  const nodeTree = useNodeTree()
@@ -54,4 +54,4 @@ export function Type({ children, ...props }: TypeProps): KubbElement {
54
54
  )
55
55
  }
56
56
 
57
- Type.displayName = 'KubbType'
57
+ Type.displayName = 'Type'
@@ -1,19 +1 @@
1
- import { RootContext, useContext } from '@kubb/fabric-core'
2
-
3
- /**
4
- * Provides lifecycle helpers that integrate with the Fabric runtime. The
5
- * `exit` helper schedules a call to the RootContext exit function on the
6
- * next tick to allow React to complete its render cycle first.
7
- */
8
- export function useLifecycle() {
9
- const { exit } = useContext(RootContext)
10
-
11
- return {
12
- exit: () => {
13
- // need this to let React finish its current render cycle
14
- setTimeout(() => {
15
- exit()
16
- }, 0)
17
- },
18
- }
19
- }
1
+ export { useLifecycle } from '@kubb/fabric-core'
package/src/devtools.ts CHANGED
@@ -25,7 +25,7 @@ export function openDevtools() {
25
25
  customGlobal.self ||= global
26
26
  customGlobal.isDevtoolsEnabled = true
27
27
 
28
- // Filter out Kubbs's internal components from devtools for a cleaner view.
28
+ // Filter out Kubb internal components from devtools for a cleaner view.
29
29
  // See https://github.com/facebook/react/blob/edf6eac8a181860fd8a2d076a43806f1237495a1/packages/react-devtools-shared/src/types.js#L24
30
30
  customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
31
31
  {
@@ -38,14 +38,14 @@ export function openDevtools() {
38
38
  {
39
39
  // ComponentFilterDisplayName
40
40
  type: 2,
41
- value: 'KubbRoot',
41
+ value: 'Root',
42
42
  isEnabled: true,
43
43
  isValid: true,
44
44
  },
45
45
  {
46
46
  // ComponentFilterDisplayName
47
47
  type: 2,
48
- value: 'KubbErrorBoundary',
48
+ value: 'ErrorBoundary',
49
49
  isEnabled: true,
50
50
  isValid: true,
51
51
  },
package/src/globals.ts CHANGED
@@ -1,20 +1,29 @@
1
1
  import type React from 'react'
2
- import type { KubbElement, KubbExportProps, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps } from './types.ts'
2
+ import type {
3
+ FabricExportProps,
4
+ FabricFileProps,
5
+ FabricImportProps,
6
+ FabricReactElement,
7
+ FabricReactNode,
8
+ FabricSourceProps,
9
+ FabricTextProps,
10
+ LineBreakProps,
11
+ } from './types.ts'
3
12
 
4
13
  declare global {
5
14
  namespace JSX {
6
- type Element = KubbElement
15
+ type Element = FabricReactElement
7
16
 
8
17
  interface ElementClass extends React.ComponentClass<any> {
9
- render(): KubbNode
18
+ render(): FabricReactNode
10
19
  }
11
20
 
12
21
  interface IntrinsicElements {
13
- 'kubb-text': KubbTextProps
14
- 'kubb-file': KubbFileProps
15
- 'kubb-source': KubbSourceProps
16
- 'kubb-import': KubbImportProps
17
- 'kubb-export': KubbExportProps
22
+ 'kubb-text': FabricTextProps
23
+ 'kubb-file': FabricFileProps
24
+ 'kubb-source': FabricSourceProps
25
+ 'kubb-import': FabricImportProps
26
+ 'kubb-export': FabricExportProps
18
27
  br: LineBreakProps
19
28
  indent: {}
20
29
  dedent: {}
package/src/index.ts CHANGED
@@ -3,23 +3,20 @@ import * as React from 'react'
3
3
 
4
4
  export type { Fabric } from '@kubb/fabric-core'
5
5
  // expose fabric core helpers
6
- export { createFabric, createFile, FileManager, FileProcessor } from '@kubb/fabric-core'
6
+ export { createContext, createFabric, createFile, FileManager, FileProcessor, TreeNode, useContext } from '@kubb/fabric-core'
7
7
 
8
8
  // react helpers
9
9
  export const useState = React.useState
10
- export const createContext = React.createContext
11
- export const createElement = React.createElement
12
- export const Fragment = React.Fragment
13
- export const use = React.use
14
- export const useContext = React.useContext
15
10
  export const useEffect = React.useEffect
16
11
  export const useReducer = React.useReducer
17
12
  export const useRef = React.useRef
18
- // components
13
+
19
14
  export { App } from './components/App.tsx'
20
15
  export { Const } from './components/Const.tsx'
21
16
  export { File } from './components/File.tsx'
22
17
  export { Function } from './components/Function.tsx'
18
+ // components
19
+ export { Root } from './components/Root.tsx'
23
20
  export { Type } from './components/Type.tsx'
24
21
 
25
22
  // composables
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react/jsx-dev-runtime'
2
- import type { KubbElement, KubbNode } from './types.ts'
2
+ import type { FabricReactElement, FabricReactNode } from './types.ts'
3
3
 
4
4
  export const Fragment = React.Fragment
5
5
  export const jsxDEV = React.jsxDEV
6
6
 
7
7
  export type * from './jsx-namespace.d.ts'
8
8
 
9
- export type JSXElement = KubbElement
10
- export type ReactNode = KubbNode
9
+ export type JSXElement = FabricReactElement
10
+ export type ReactNode = FabricReactNode
@@ -1,13 +1,13 @@
1
1
  import type React from 'react'
2
2
 
3
- import type { KubbNode, KubbElement, KubbExportProps, KubbFileProps, KubbImportProps, KubbSourceProps, KubbTextProps, LineBreakProps } from './types'
3
+ import type { FabricReactNode, FabricReactElement, FabricExportProps, FabricFileProps, FabricImportProps, FabricSourceProps, FabricTextProps, LineBreakProps } from './types'
4
4
 
5
5
  export namespace JSX {
6
6
  type ElementType = React.JSX.ElementType
7
- type Element = KubbElement
7
+ type Element = FabricReactElement
8
8
 
9
9
  interface ElementClass extends React.JSX.ElementClass {
10
- render(): KubbNode
10
+ render(): FabricReactNode
11
11
  }
12
12
  interface ElementAttributesProperty {
13
13
  props: {}
@@ -18,11 +18,11 @@ export namespace JSX {
18
18
  }
19
19
 
20
20
  interface IntrinsicElements extends React.JSX.IntrinsicElements {
21
- 'kubb-text': KubbTextProps
22
- 'kubb-file': KubbFileProps
23
- 'kubb-source': KubbSourceProps
24
- 'kubb-import': KubbImportProps
25
- 'kubb-export': KubbExportProps
21
+ 'kubb-text': FabricTextProps
22
+ 'kubb-file': FabricFileProps
23
+ 'kubb-source': FabricSourceProps
24
+ 'kubb-import': FabricImportProps
25
+ 'kubb-export': FabricExportProps
26
26
  br: LineBreakProps
27
27
  indent: {}
28
28
  dedent: {}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react/jsx-runtime'
2
- import type { KubbElement, KubbNode } from './types.ts'
2
+ import type { FabricReactElement, FabricReactNode } from './types.ts'
3
3
 
4
4
  export const Fragment = React.Fragment
5
5
  export const jsx = React.jsx
@@ -8,5 +8,5 @@ export const jsxs = React.jsxs
8
8
 
9
9
  export type * from './jsx-namespace.d.ts'
10
10
 
11
- export type JSXElement = KubbElement
12
- export type ReactNode = KubbNode
11
+ export type JSXElement = FabricReactElement
12
+ export type ReactNode = FabricReactNode
@@ -1,7 +1,7 @@
1
1
  import type { TreeNode } from '@kubb/fabric-core'
2
2
  import { definePlugin } from '@kubb/fabric-core/plugins'
3
3
  import { Runtime } from '../Runtime.tsx'
4
- import type { ComponentNode, KubbElement } from '../types.ts'
4
+ import type { ComponentNode, FabricReactElement } from '../types.ts'
5
5
 
6
6
  export type Options = {
7
7
  stdout?: NodeJS.WriteStream
@@ -15,16 +15,16 @@ export type Options = {
15
15
  }
16
16
 
17
17
  type ExtendOptions = {
18
- render(App: KubbElement): Promise<void>
19
- renderToString(App: KubbElement): Promise<string>
18
+ render(App: FabricReactElement): Promise<void>
19
+ renderToString(App: FabricReactElement): Promise<string>
20
20
  waitUntilExit(): Promise<void>
21
21
  }
22
22
 
23
23
  declare global {
24
24
  namespace Kubb {
25
25
  interface Fabric {
26
- render(App: KubbElement): Promise<void>
27
- renderToString(App: KubbElement): Promise<string>
26
+ render(App: FabricReactElement): Promise<void>
27
+ renderToString(App: FabricReactElement): Promise<string>
28
28
  waitUntilExit(): Promise<void>
29
29
  }
30
30
  }
package/src/types.ts CHANGED
@@ -2,9 +2,20 @@ import type { KubbFile } from '@kubb/fabric-core/types'
2
2
  import type React from 'react'
3
3
  import type { JSX, ReactNode } from 'react'
4
4
 
5
- type ReactElementNames = 'br' | 'div' | 'indent' | 'dedent'
6
-
7
- export type ElementNames = ReactElementNames | 'kubb-text' | 'kubb-file' | 'kubb-source' | 'kubb-import' | 'kubb-export' | 'kubb-root' | 'kubb-app'
5
+ export type Key = string | number | bigint
6
+
7
+ export type ElementNames =
8
+ | 'br'
9
+ | 'div'
10
+ | 'indent'
11
+ | 'dedent'
12
+ | 'kubb-text'
13
+ | 'kubb-file'
14
+ | 'kubb-source'
15
+ | 'kubb-import'
16
+ | 'kubb-export'
17
+ | 'kubb-root'
18
+ | 'kubb-app'
8
19
 
9
20
  type Node = {
10
21
  parentNode: DOMElement | undefined
@@ -45,30 +56,28 @@ export type DOMElement = {
45
56
 
46
57
  type NodeNames = ElementNames | TextName
47
58
 
48
- export type KubbNode = ReactNode
49
- export type KubbElement = JSX.Element
50
-
51
- export type { Key } from 'react'
59
+ export type FabricReactNode = ReactNode
60
+ export type FabricReactElement = JSX.Element
52
61
 
53
- export type KubbTextProps = {
54
- children?: KubbNode
62
+ export type FabricTextProps = {
63
+ children?: FabricReactNode
55
64
  }
56
65
 
57
- export type KubbFileProps = {
66
+ export type FabricFileProps = {
58
67
  id?: string
59
- children?: KubbNode
68
+ children?: FabricReactNode
60
69
  baseName: string
61
70
  path: string
62
71
  override?: boolean
63
72
  meta?: KubbFile.File['meta']
64
73
  }
65
- export type KubbSourceProps = KubbFile.Source & {
66
- children?: KubbNode
74
+ export type FabricSourceProps = KubbFile.Source & {
75
+ children?: FabricReactNode
67
76
  }
68
77
 
69
- export type KubbImportProps = KubbFile.Import
78
+ export type FabricImportProps = KubbFile.Import
70
79
 
71
- export type KubbExportProps = KubbFile.Export
80
+ export type FabricExportProps = KubbFile.Export
72
81
 
73
82
  export type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>
74
83