@kubb/react-fabric 0.9.5 → 0.11.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/{Fabric-DitK3IEP.d.ts → Fabric-BELBf-bX.d.cts} +5 -5
- package/dist/{Fabric-C61uYmUy.d.cts → Fabric-DbJhvsCq.d.ts} +5 -5
- package/dist/{devtools-D6dZodXp.js → devtools-8_UKWDTl.js} +1 -1
- package/dist/{devtools-D6dZodXp.js.map → devtools-8_UKWDTl.js.map} +1 -1
- package/dist/{devtools-CRkwwngz.cjs → devtools-BOpUJhc_.cjs} +1 -1
- package/dist/{devtools-CRkwwngz.cjs.map → devtools-BOpUJhc_.cjs.map} +1 -1
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.js +1 -1
- package/dist/globals.d.cts +2 -2
- package/dist/globals.d.ts +2 -2
- package/dist/index.cjs +166 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -359
- package/dist/index.d.ts +3 -359
- package/dist/index.js +151 -68
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +5 -5
- package/dist/jsx-dev-runtime.d.ts +3 -3
- package/dist/{jsx-namespace-BAkGpU6g.d.ts → jsx-namespace-CBOEkCmJ.d.ts} +2 -2
- package/dist/{jsx-namespace-CCPa1Nut.d.cts → jsx-namespace-od7sqrmY.d.cts} +2 -2
- package/dist/{jsx-runtime-BEVcoJUm.cjs → jsx-runtime-Cq39dA50.cjs} +1 -1
- package/dist/{jsx-runtime-BEVcoJUm.cjs.map → jsx-runtime-Cq39dA50.cjs.map} +1 -1
- package/dist/{jsx-runtime-DDu0mFTI.js → jsx-runtime-Isgf9orn.js} +1 -1
- package/dist/{jsx-runtime-DDu0mFTI.js.map → jsx-runtime-Isgf9orn.js.map} +1 -1
- package/dist/jsx-runtime.cjs +1 -1
- package/dist/jsx-runtime.d.cts +5 -5
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.js +1 -1
- package/dist/parsers.d.cts +1 -1
- package/dist/parsers.d.ts +1 -1
- package/dist/plugins.cjs +2 -2
- package/dist/plugins.d.cts +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +2 -2
- package/dist/{reactPlugin-CXaAO13f.cjs → reactPlugin-B8F6jVb5.cjs} +77 -64
- package/dist/reactPlugin-B8F6jVb5.cjs.map +1 -0
- package/dist/{reactPlugin-ixOr00MK.js → reactPlugin-CAtVV84d.js} +78 -53
- package/dist/reactPlugin-CAtVV84d.js.map +1 -0
- package/dist/types-C3ODUOKN.d.cts +675 -0
- package/dist/types-DwaohVJS.d.ts +675 -0
- package/dist/types.d.cts +3 -3
- package/dist/types.d.ts +3 -3
- package/package.json +3 -3
- package/src/Runtime.tsx +22 -12
- package/src/components/App.tsx +24 -15
- package/src/components/Const.tsx +19 -3
- package/src/components/File.tsx +107 -31
- package/src/components/Function.tsx +36 -5
- package/src/components/Indent.tsx +3 -0
- package/src/components/Root.tsx +26 -20
- package/src/components/Type.tsx +19 -2
- package/src/components/__snapshots__/arrow_function.ts +3 -0
- package/src/components/__snapshots__/arrow_function_default.ts +3 -0
- package/src/components/__snapshots__/arrow_function_generics.ts +3 -0
- package/src/components/__snapshots__/arrow_function_single_line.ts +1 -0
- package/src/components/__snapshots__/arrow_function_with_generics.ts +3 -0
- package/src/components/__snapshots__/async_arrow_function.ts +3 -0
- package/src/components/__snapshots__/async_function.ts +3 -0
- package/src/components/__snapshots__/async_function_with_Promise_return_type.ts +3 -0
- package/src/components/__snapshots__/basic_arrow_function.ts +3 -0
- package/src/components/__snapshots__/basic_const.ts +1 -0
- package/src/components/__snapshots__/basic_export.ts +1 -0
- package/src/components/__snapshots__/basic_function.ts +3 -0
- package/src/components/__snapshots__/basic_import.ts +1 -0
- package/src/components/__snapshots__/basic_type.ts +1 -0
- package/src/components/__snapshots__/const_with_JSDoc.ts +4 -0
- package/src/components/__snapshots__/const_with_as_const.ts +1 -0
- package/src/components/__snapshots__/const_with_type.ts +1 -0
- package/src/components/__snapshots__/default_exported_arrow_function.ts +3 -0
- package/src/components/__snapshots__/default_exported_function.ts +3 -0
- package/src/components/__snapshots__/exported_arrow_function.ts +3 -0
- package/src/components/__snapshots__/exported_const.ts +1 -0
- package/src/components/__snapshots__/exported_function.ts +3 -0
- package/src/components/__snapshots__/exported_type.ts +1 -0
- package/src/components/__snapshots__/function_generics.ts +3 -0
- package/src/components/__snapshots__/function_with_JSDoc.ts +6 -0
- package/src/components/__snapshots__/function_with_comments.ts +6 -0
- package/src/components/__snapshots__/function_with_generics.ts +3 -0
- package/src/components/__snapshots__/function_with_parameters.ts +3 -0
- package/src/components/__snapshots__/function_with_params.ts +3 -0
- package/src/components/__snapshots__/function_with_returnType.ts +3 -0
- package/src/components/__snapshots__/function_with_return_type.ts +3 -0
- package/src/components/__snapshots__/matches_with_root_import.ts +1 -0
- package/src/components/__snapshots__/multiple_functions.ts +3 -0
- package/src/components/__snapshots__/named_export.ts +1 -0
- package/src/components/__snapshots__/named_export_(object_advanced).ts +1 -0
- package/src/components/__snapshots__/named_import.ts +1 -0
- package/src/components/__snapshots__/named_import_(object).ts +1 -0
- package/src/components/__snapshots__/named_import_(object_advanced).ts +1 -0
- package/src/components/__snapshots__/named_typed_export.ts +1 -0
- package/src/components/__snapshots__/named_typed_import.ts +1 -0
- package/src/components/__snapshots__/single_line_arrow_function.ts +1 -0
- package/src/components/__snapshots__/type_with_JSDoc.ts +4 -0
- package/src/components/__snapshots__/typed_export.ts +1 -0
- package/src/components/__snapshots__/typed_import.ts +1 -0
- package/src/composables/useApp.ts +1 -15
- package/src/composables/useFile.ts +1 -12
- package/src/composables/useLifecycle.tsx +7 -8
- package/src/index.ts +5 -1
- package/src/plugins/reactPlugin.ts +7 -6
- package/src/types.ts +0 -4
- package/src/utils/createJSDoc.ts +1 -8
- package/dist/reactPlugin-4-kcMKwZ.d.ts +0 -31
- package/dist/reactPlugin-B4xarQJX.d.cts +0 -31
- package/dist/reactPlugin-CXaAO13f.cjs.map +0 -1
- package/dist/reactPlugin-ixOr00MK.js.map +0 -1
- package/dist/types-CSUzVTpn.d.ts +0 -104
- package/dist/types-DP2mgqeb.d.cts +0 -104
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import fabric from "./fabric/@kubb/react-fabric";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { createFabric } from "@kubb/react-fabric";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { App, createFrabric } from "@kubb/react-fabric";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import type { createFabric } from "@kubb/react-fabric";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { createFabric as create } from "@kubb/react-fabric";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { App, createFabric as create } from "@kubb/react-fabric";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { Fabric } from "@kubb/react-fabric";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import type { Fabric } from "@kubb/react-fabric";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const myFunc = () => true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from "@kubb/react-fabric";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import type fabric from "@kubb/react-fabric";
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { App, type AppContextProps } from '../components/App.tsx'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `useApp` will return the current App with plugin, pluginManager, fileManager and mode.
|
|
6
|
-
*/
|
|
7
|
-
export function useApp<TMeta = unknown>(): AppContextProps<TMeta> {
|
|
8
|
-
const app = useContext(App.Context)
|
|
9
|
-
|
|
10
|
-
if (!app) {
|
|
11
|
-
throw new Error('<App /> should be set')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return app as AppContextProps<TMeta>
|
|
15
|
-
}
|
|
1
|
+
export { useApp } from '@kubb/fabric-core'
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { FileContextProps } from '../components/File.tsx'
|
|
3
|
-
import { File } from '../components/File.tsx'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `useFile` will return the current file when <File/> is used.
|
|
7
|
-
*/
|
|
8
|
-
export function useFile(): FileContextProps {
|
|
9
|
-
const file = useContext(File.Context)
|
|
10
|
-
|
|
11
|
-
return file as FileContextProps
|
|
12
|
-
}
|
|
1
|
+
export { useFile } from '@kubb/fabric-core'
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { useContext } from '
|
|
2
|
-
|
|
3
|
-
import { Root } from '../components/Root.tsx'
|
|
1
|
+
import { RootContext, useContext } from '@kubb/fabric-core'
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
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
7
|
*/
|
|
8
8
|
export function useLifecycle() {
|
|
9
|
-
const { exit } = useContext(
|
|
9
|
+
const { exit } = useContext(RootContext)
|
|
10
10
|
|
|
11
11
|
return {
|
|
12
12
|
exit: () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
// need this to let React finish its current render cycle
|
|
14
|
+
setTimeout(() => {
|
|
16
15
|
exit()
|
|
17
16
|
}, 0)
|
|
18
17
|
},
|
package/src/index.ts
CHANGED
|
@@ -14,16 +14,20 @@ export const useContext = React.useContext
|
|
|
14
14
|
export const useEffect = React.useEffect
|
|
15
15
|
export const useReducer = React.useReducer
|
|
16
16
|
export const useRef = React.useRef
|
|
17
|
-
//
|
|
17
|
+
// components
|
|
18
18
|
export { App } from './components/App.tsx'
|
|
19
19
|
export { Const } from './components/Const.tsx'
|
|
20
20
|
export { File } from './components/File.tsx'
|
|
21
21
|
export { Function } from './components/Function.tsx'
|
|
22
22
|
export { Indent } from './components/Indent.tsx'
|
|
23
23
|
export { Type } from './components/Type.tsx'
|
|
24
|
+
|
|
25
|
+
// composables
|
|
24
26
|
export { useApp } from './composables/useApp.ts'
|
|
25
27
|
export { useFile } from './composables/useFile.ts'
|
|
26
28
|
export { useLifecycle } from './composables/useLifecycle.tsx'
|
|
29
|
+
|
|
30
|
+
// factories
|
|
27
31
|
export { createReactFabric } from './createReactFabric.ts'
|
|
28
32
|
export { Runtime } from './Runtime.tsx'
|
|
29
33
|
// utils
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { definePlugin } from '@kubb/fabric-core/plugins'
|
|
2
2
|
import { createElement, type ElementType } from 'react'
|
|
3
3
|
import { Runtime } from '../Runtime.tsx'
|
|
4
|
+
import type { KubbElement } from '../types'
|
|
4
5
|
|
|
5
6
|
export type Options = {
|
|
6
7
|
stdout?: NodeJS.WriteStream
|
|
@@ -13,16 +14,16 @@ export type Options = {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
type ExtendOptions = {
|
|
16
|
-
render(App: ElementType): Promise<void>
|
|
17
|
-
renderToString(App: ElementType): Promise<string>
|
|
17
|
+
render(App: KubbElement | ElementType): Promise<void>
|
|
18
|
+
renderToString(App: KubbElement | ElementType): Promise<string>
|
|
18
19
|
waitUntilExit(): Promise<void>
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
declare global {
|
|
22
23
|
namespace Kubb {
|
|
23
24
|
interface Fabric {
|
|
24
|
-
render(App: ElementType): Promise<void>
|
|
25
|
-
renderToString(App: ElementType): Promise<string>
|
|
25
|
+
render(App: KubbElement | ElementType): Promise<void>
|
|
26
|
+
renderToString(App: KubbElement | ElementType): Promise<string>
|
|
26
27
|
waitUntilExit(): Promise<void>
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -37,11 +38,11 @@ export const reactPlugin = definePlugin<Options, ExtendOptions>({
|
|
|
37
38
|
return {
|
|
38
39
|
async render(App) {
|
|
39
40
|
await ctx.emit('lifecycle:start')
|
|
40
|
-
await runtime.render(createElement(App))
|
|
41
|
+
await runtime.render(createElement(App as unknown as ElementType))
|
|
41
42
|
},
|
|
42
43
|
async renderToString(App) {
|
|
43
44
|
await ctx.emit('lifecycle:start')
|
|
44
|
-
return runtime.renderToString(createElement(App))
|
|
45
|
+
return runtime.renderToString(createElement(App as unknown as ElementType))
|
|
45
46
|
},
|
|
46
47
|
async waitUntilExit() {
|
|
47
48
|
await runtime.waitUntilExit()
|
package/src/types.ts
CHANGED
package/src/utils/createJSDoc.ts
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
const filtered = comments.filter((c) => c.trim())
|
|
3
|
-
if (!filtered.length) {
|
|
4
|
-
return ''
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
return `/**\n * ${filtered.join('\n * ')}\n */`
|
|
8
|
-
}
|
|
1
|
+
export { createJSDoc } from '@kubb/fabric-core'
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { o as Plugin } from "./Fabric-DitK3IEP.js";
|
|
2
|
-
import { ElementType } from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/plugins/reactPlugin.d.ts
|
|
5
|
-
type Options = {
|
|
6
|
-
stdout?: NodeJS.WriteStream;
|
|
7
|
-
stdin?: NodeJS.ReadStream;
|
|
8
|
-
stderr?: NodeJS.WriteStream;
|
|
9
|
-
/**
|
|
10
|
-
* Set this to true to always see the result of the render in the console(line per render)
|
|
11
|
-
*/
|
|
12
|
-
debug?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type ExtendOptions = {
|
|
15
|
-
render(App: ElementType): Promise<void>;
|
|
16
|
-
renderToString(App: ElementType): Promise<string>;
|
|
17
|
-
waitUntilExit(): Promise<void>;
|
|
18
|
-
};
|
|
19
|
-
declare global {
|
|
20
|
-
namespace Kubb {
|
|
21
|
-
interface Fabric {
|
|
22
|
-
render(App: ElementType): Promise<void>;
|
|
23
|
-
renderToString(App: ElementType): Promise<string>;
|
|
24
|
-
waitUntilExit(): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
declare const reactPlugin: Plugin<Options, ExtendOptions>;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { reactPlugin as n, Options as t };
|
|
31
|
-
//# sourceMappingURL=reactPlugin-4-kcMKwZ.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { o as Plugin } from "./Fabric-C61uYmUy.cjs";
|
|
2
|
-
import { ElementType } from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/plugins/reactPlugin.d.ts
|
|
5
|
-
type Options = {
|
|
6
|
-
stdout?: NodeJS.WriteStream;
|
|
7
|
-
stdin?: NodeJS.ReadStream;
|
|
8
|
-
stderr?: NodeJS.WriteStream;
|
|
9
|
-
/**
|
|
10
|
-
* Set this to true to always see the result of the render in the console(line per render)
|
|
11
|
-
*/
|
|
12
|
-
debug?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type ExtendOptions = {
|
|
15
|
-
render(App: ElementType): Promise<void>;
|
|
16
|
-
renderToString(App: ElementType): Promise<string>;
|
|
17
|
-
waitUntilExit(): Promise<void>;
|
|
18
|
-
};
|
|
19
|
-
declare global {
|
|
20
|
-
namespace Kubb {
|
|
21
|
-
interface Fabric {
|
|
22
|
-
render(App: ElementType): Promise<void>;
|
|
23
|
-
renderToString(App: ElementType): Promise<string>;
|
|
24
|
-
waitUntilExit(): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
declare const reactPlugin: Plugin<Options, ExtendOptions>;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { reactPlugin as n, Options as t };
|
|
31
|
-
//# sourceMappingURL=reactPlugin-B4xarQJX.d.cts.map
|