@kubb/renderer-jsx 5.0.0-beta.42 → 5.0.0-beta.43
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/chunk-C0LytTxp.js +8 -0
- package/dist/index.cjs +167 -18132
- package/dist/index.d.ts +15 -166
- package/dist/index.js +152 -18107
- package/dist/jsx-dev-runtime.cjs +3 -10
- package/dist/jsx-dev-runtime.d.ts +3 -6
- package/dist/jsx-dev-runtime.js +1 -9
- package/dist/jsx-runtime-CzH00oSR.cjs +64 -0
- package/dist/jsx-runtime.cjs +5 -14
- package/dist/jsx-runtime.d.ts +59 -8
- package/dist/jsx-runtime.js +24 -7
- package/dist/types-DBdp_5qR.d.ts +116 -0
- package/dist/types.d.ts +2 -2
- package/package.json +4 -23
- package/src/SyncRuntime.tsx +5 -5
- package/src/constants.ts +0 -29
- package/src/createRenderer.tsx +10 -66
- package/src/globals.ts +14 -6
- package/src/index.ts +1 -4
- package/src/jsx-dev-runtime.ts +1 -3
- package/src/jsx-namespace.d.ts +21 -13
- package/src/jsx-runtime.ts +22 -6
- package/src/types.ts +14 -98
- package/dist/chunk-DoukXa0m.js +0 -28
- package/dist/jsx-namespace-dmStM1a2.d.ts +0 -39
- package/dist/jsx-runtime-4M1bV6ub.cjs +0 -1503
- package/dist/jsx-runtime-CQ6-_gue.js +0 -1448
- package/dist/types-B5VGpHs0.d.ts +0 -169
- package/src/Renderer.ts +0 -180
- package/src/Runtime.tsx +0 -159
- package/src/components/CodeBlock.tsx +0 -37
- package/src/components/Root.tsx +0 -70
- package/src/dom.ts +0 -93
- package/src/utils.ts +0 -246
package/dist/index.d.ts
CHANGED
|
@@ -1,51 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as __name } from "./chunk-C0LytTxp.js";
|
|
2
|
+
import { d as KubbReactNode, n as Key, t as JSDoc, u as KubbReactElement } from "./types-DBdp_5qR.js";
|
|
3
3
|
import { ExportNode, FileNode, ImportNode, SourceNode } from "@kubb/ast";
|
|
4
4
|
|
|
5
|
-
//#region ../../internals/utils/src/context.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Context type that carries type information about its value
|
|
8
|
-
* This is a branded symbol type that enables type-safe context usage
|
|
9
|
-
*/
|
|
10
|
-
type Context<T> = symbol & {
|
|
11
|
-
readonly __type: T;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Provides a value to descendant components (Vue 3 style)
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* const ThemeKey = Symbol('theme')
|
|
19
|
-
* provide(ThemeKey, { color: 'blue' })
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
declare function provide<T>(key: symbol | Context<T>, value: T): void;
|
|
23
|
-
/**
|
|
24
|
-
* Injects a value provided by an ancestor component (Vue 3 style)
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* const theme = inject(ThemeKey, { color: 'default' })
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
declare function inject<T>(key: symbol | Context<T>, defaultValue?: T): T;
|
|
32
|
-
/**
|
|
33
|
-
* Removes a provided value from the context stack (for cleanup)
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
declare function unprovide<T>(key: symbol | Context<T>): void;
|
|
37
|
-
/**
|
|
38
|
-
* Creates a context key with a default value (React-style compatibility)
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* const ThemeContext = createContext({ color: 'blue' })
|
|
43
|
-
* // ThemeContext is now typed as Context<{ color: string }>
|
|
44
|
-
* const theme = useContext(ThemeContext) // theme is { color: string }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
declare function createContext<T>(defaultValue: T): Context<T>;
|
|
48
|
-
//#endregion
|
|
49
5
|
//#region src/components/Callout.d.ts
|
|
50
6
|
declare const CALLOUT_LABEL: {
|
|
51
7
|
readonly tip: "TIP";
|
|
@@ -55,7 +11,7 @@ declare const CALLOUT_LABEL: {
|
|
|
55
11
|
readonly caution: "CAUTION";
|
|
56
12
|
};
|
|
57
13
|
type CalloutType = keyof typeof CALLOUT_LABEL;
|
|
58
|
-
type Props$
|
|
14
|
+
type Props$7 = {
|
|
59
15
|
key?: Key;
|
|
60
16
|
/**
|
|
61
17
|
* Callout kind. Maps to the uppercase label inside the `> [!TYPE]` marker.
|
|
@@ -93,45 +49,8 @@ declare function Callout({
|
|
|
93
49
|
type,
|
|
94
50
|
title,
|
|
95
51
|
children
|
|
96
|
-
}: Props$8): KubbReactElement;
|
|
97
|
-
declare namespace Callout {
|
|
98
|
-
var displayName: string;
|
|
99
|
-
}
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/components/CodeBlock.d.ts
|
|
102
|
-
type Props$7 = {
|
|
103
|
-
key?: Key;
|
|
104
|
-
/**
|
|
105
|
-
* Language tag for syntax highlighting. Rendered after the opening fence.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* `lang: 'typescript'`
|
|
109
|
-
*/
|
|
110
|
-
lang?: string;
|
|
111
|
-
/**
|
|
112
|
-
* Code body. Wrapped in triple-backtick fences as-is.
|
|
113
|
-
*/
|
|
114
|
-
children: string;
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Renders a fenced markdown code block.
|
|
118
|
-
*
|
|
119
|
-
* Emits a `<File.Source>` block containing the children wrapped in
|
|
120
|
-
* triple-backtick fences with an optional language tag.
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```tsx
|
|
124
|
-
* <CodeBlock lang="typescript">{'const pet = { id: 1 }'}</CodeBlock>
|
|
125
|
-
* // ```typescript
|
|
126
|
-
* // const pet = { id: 1 }
|
|
127
|
-
* // ```
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
declare function CodeBlock({
|
|
131
|
-
lang,
|
|
132
|
-
children
|
|
133
52
|
}: Props$7): KubbReactElement;
|
|
134
|
-
declare namespace
|
|
53
|
+
declare namespace Callout {
|
|
135
54
|
var displayName: string;
|
|
136
55
|
}
|
|
137
56
|
//#endregion
|
|
@@ -516,7 +435,7 @@ type ArrowFunctionProps = Props$4 & {
|
|
|
516
435
|
declare function ArrowFunction({
|
|
517
436
|
children,
|
|
518
437
|
...props
|
|
519
|
-
}: ArrowFunctionProps):
|
|
438
|
+
}: ArrowFunctionProps): any;
|
|
520
439
|
declare namespace ArrowFunction {
|
|
521
440
|
var displayName: string;
|
|
522
441
|
}
|
|
@@ -657,38 +576,6 @@ declare namespace Paragraph {
|
|
|
657
576
|
var displayName: string;
|
|
658
577
|
}
|
|
659
578
|
//#endregion
|
|
660
|
-
//#region src/components/Root.d.ts
|
|
661
|
-
type RootProps = {
|
|
662
|
-
/**
|
|
663
|
-
* Callback invoked to unmount the entire renderer tree.
|
|
664
|
-
* Called with an `Error` when the exit is caused by a render error,
|
|
665
|
-
* or with `undefined` for a clean shutdown.
|
|
666
|
-
*/
|
|
667
|
-
onExit: (error?: Error) => void;
|
|
668
|
-
/**
|
|
669
|
-
* Callback invoked whenever a render error is caught by the error boundary.
|
|
670
|
-
* Use this to propagate errors up to the caller of {@link createRenderer}.
|
|
671
|
-
*/
|
|
672
|
-
onError: (error: Error) => void;
|
|
673
|
-
/**
|
|
674
|
-
* Child nodes rendered inside the error boundary.
|
|
675
|
-
*/
|
|
676
|
-
children?: KubbReactNode;
|
|
677
|
-
};
|
|
678
|
-
/**
|
|
679
|
-
* Root component for the Kubb renderer tree.
|
|
680
|
-
*
|
|
681
|
-
* Wraps all children in an `ErrorBoundary` so that render errors are caught
|
|
682
|
-
* and forwarded to `onError` rather than crashing the process.
|
|
683
|
-
*/
|
|
684
|
-
declare function Root({
|
|
685
|
-
onError,
|
|
686
|
-
children
|
|
687
|
-
}: RootProps): KubbReactElement;
|
|
688
|
-
declare namespace Root {
|
|
689
|
-
var displayName: string;
|
|
690
|
-
}
|
|
691
|
-
//#endregion
|
|
692
579
|
//#region src/components/Type.d.ts
|
|
693
580
|
type TypeProps = {
|
|
694
581
|
key?: Key;
|
|
@@ -748,14 +635,14 @@ declare namespace Type {
|
|
|
748
635
|
//#endregion
|
|
749
636
|
//#region src/createRenderer.d.ts
|
|
750
637
|
/**
|
|
751
|
-
* Renderer
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
638
|
+
* Renderer that walks the JSX tree in a single recursive pass, with no React
|
|
639
|
+
* reconciler or scheduler. Pass as the `renderer` property on
|
|
640
|
+
* `defineGenerator`. Kubb core stays generic, with no hard dependency on
|
|
641
|
+
* `@kubb/renderer-jsx`.
|
|
755
642
|
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
643
|
+
* Every component must be a pure function. Hooks, suspense, and class
|
|
644
|
+
* components are not supported. It also exposes `stream()` for incremental
|
|
645
|
+
* file emission.
|
|
759
646
|
*
|
|
760
647
|
* @example Wire up a JSX generator
|
|
761
648
|
* ```tsx
|
|
@@ -774,59 +661,21 @@ declare namespace Type {
|
|
|
774
661
|
* },
|
|
775
662
|
* })
|
|
776
663
|
* ```
|
|
777
|
-
*/
|
|
778
|
-
declare const jsxRenderer: () => {
|
|
779
|
-
render(element: KubbReactElement): Promise<void>;
|
|
780
|
-
readonly files: FileNode[];
|
|
781
|
-
dispose(): void;
|
|
782
|
-
unmount(error?: Error | number | null): void;
|
|
783
|
-
[Symbol.dispose](): void;
|
|
784
|
-
};
|
|
785
|
-
/**
|
|
786
|
-
* Lightweight renderer that walks the JSX tree in a single recursive pass, * no React reconciler, no scheduler. Drop-in replacement for
|
|
787
|
-
* {@link jsxRenderer} at roughly 2, 4× the throughput.
|
|
788
|
-
*
|
|
789
|
-
* Constraints: every component must be a pure function. Hooks, suspense, and
|
|
790
|
-
* class components are not supported.
|
|
791
|
-
*
|
|
792
|
-
* Use this for generators that produce large amounts of output and do not need
|
|
793
|
-
* React's runtime features. It also exposes `stream()` for incremental file
|
|
794
|
-
* emission.
|
|
795
|
-
*
|
|
796
|
-
* @example Drop-in faster renderer
|
|
797
|
-
* ```tsx
|
|
798
|
-
* import { defineGenerator } from '@kubb/core'
|
|
799
|
-
* import { jsxRendererSync } from '@kubb/renderer-jsx'
|
|
800
|
-
*
|
|
801
|
-
* export const myGenerator = defineGenerator<PluginTs>({
|
|
802
|
-
* name: 'types',
|
|
803
|
-
* renderer: jsxRendererSync,
|
|
804
|
-
* schema(node, ctx) {
|
|
805
|
-
* return (
|
|
806
|
-
* <File baseName="output.ts" path={`${ctx.root}/output.ts`}>
|
|
807
|
-
* <Type node={node} resolver={ctx.resolver} />
|
|
808
|
-
* </File>
|
|
809
|
-
* )
|
|
810
|
-
* },
|
|
811
|
-
* })
|
|
812
|
-
* ```
|
|
813
664
|
*
|
|
814
665
|
* @example Stream files as they are produced
|
|
815
666
|
* ```tsx
|
|
816
|
-
* const renderer =
|
|
667
|
+
* const renderer = jsxRenderer()
|
|
817
668
|
* for (const file of renderer.stream(element)) {
|
|
818
669
|
* await writeFile(file.path, file.sources[0])
|
|
819
670
|
* }
|
|
820
671
|
* ```
|
|
821
672
|
*/
|
|
822
|
-
declare const
|
|
673
|
+
declare const jsxRenderer: () => {
|
|
823
674
|
render(element: KubbReactElement): Promise<void>;
|
|
824
675
|
readonly files: FileNode[];
|
|
825
676
|
stream(element: KubbReactElement): Generator<FileNode>;
|
|
826
|
-
dispose(): void;
|
|
827
|
-
unmount(_error?: Error | number | null): void;
|
|
828
677
|
[Symbol.dispose](): void;
|
|
829
678
|
};
|
|
830
679
|
//#endregion
|
|
831
|
-
export { Callout,
|
|
680
|
+
export { Callout, Const, File, Frontmatter, Function, Heading, Jsx, List, Paragraph, Type, jsxRenderer };
|
|
832
681
|
//# sourceMappingURL=index.d.ts.map
|