@kubb/renderer-jsx 5.5.6 → 5.6.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/index.cjs +103 -211
- package/dist/index.d.ts +9 -549
- package/dist/index.js +104 -212
- package/dist/jsx-runtime.cjs +7 -0
- package/dist/jsx-runtime.d.ts +9 -13
- package/dist/jsx-runtime.js +7 -1
- package/dist/{types-seYG0czS.d.ts → types-BbP7RtaT.d.ts} +9 -15
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-
|
|
2
|
+
import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-BbP7RtaT.js";
|
|
3
3
|
import { ast } from "@kubb/kit";
|
|
4
4
|
//#region src/components/md/Callout.d.ts
|
|
5
5
|
declare const CALLOUT_LABEL: {
|
|
@@ -44,9 +44,6 @@ type Props$7 = {
|
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
export declare function Callout({ type, title, children }: Props$7): KubbReactElement;
|
|
47
|
-
export declare namespace Callout {
|
|
48
|
-
var displayName: string;
|
|
49
|
-
}
|
|
50
47
|
//#endregion
|
|
51
48
|
//#region src/components/js/Const.d.ts
|
|
52
49
|
type ConstProps = {
|
|
@@ -105,10 +102,7 @@ type ConstProps = {
|
|
|
105
102
|
* </Const>
|
|
106
103
|
* ```
|
|
107
104
|
*/
|
|
108
|
-
export declare function Const({ children,
|
|
109
|
-
export declare namespace Const {
|
|
110
|
-
var displayName: string;
|
|
111
|
-
}
|
|
105
|
+
export declare function Const({ children, name, export: canExport, type, JSDoc, asConst }: ConstProps): KubbReactElement;
|
|
112
106
|
//#endregion
|
|
113
107
|
//#region src/components/File.d.ts
|
|
114
108
|
type BasePropsWithBaseName = {
|
|
@@ -184,7 +178,6 @@ type Props$6<TMeta> = BaseProps & {
|
|
|
184
178
|
*/
|
|
185
179
|
export declare function File<TMeta extends object = object>({ children, ...props }: Props$6<TMeta>): KubbReactElement;
|
|
186
180
|
export declare namespace File {
|
|
187
|
-
var displayName: string;
|
|
188
181
|
var Export: typeof FileExport;
|
|
189
182
|
var Import: typeof FileImport;
|
|
190
183
|
var Source: typeof FileSource;
|
|
@@ -217,9 +210,6 @@ type FileSourceProps = Omit<ast.SourceNode, 'kind' | 'value'> & {
|
|
|
217
210
|
* ```
|
|
218
211
|
*/
|
|
219
212
|
declare function FileSource({ children, ...props }: FileSourceProps): KubbReactElement;
|
|
220
|
-
declare namespace FileSource {
|
|
221
|
-
var displayName: string;
|
|
222
|
-
}
|
|
223
213
|
type FileExportProps = Omit<ast.ExportNode, 'kind'> & {
|
|
224
214
|
key?: Key;
|
|
225
215
|
};
|
|
@@ -241,9 +231,6 @@ type FileExportProps = Omit<ast.ExportNode, 'kind'> & {
|
|
|
241
231
|
* ```
|
|
242
232
|
*/
|
|
243
233
|
declare function FileExport(props: FileExportProps): KubbReactElement;
|
|
244
|
-
declare namespace FileExport {
|
|
245
|
-
var displayName: string;
|
|
246
|
-
}
|
|
247
234
|
type FileImportProps = Omit<ast.ImportNode, 'kind'> & {
|
|
248
235
|
key?: Key;
|
|
249
236
|
};
|
|
@@ -271,9 +258,6 @@ type FileImportProps = Omit<ast.ImportNode, 'kind'> & {
|
|
|
271
258
|
* ```
|
|
272
259
|
*/
|
|
273
260
|
declare function FileImport(props: FileImportProps): KubbReactElement;
|
|
274
|
-
declare namespace FileImport {
|
|
275
|
-
var displayName: string;
|
|
276
|
-
}
|
|
277
261
|
//#endregion
|
|
278
262
|
//#region src/components/md/Frontmatter.d.ts
|
|
279
263
|
type Props$5 = {
|
|
@@ -304,9 +288,6 @@ type Props$5 = {
|
|
|
304
288
|
* ```
|
|
305
289
|
*/
|
|
306
290
|
export declare function Frontmatter({ data }: Props$5): KubbReactElement;
|
|
307
|
-
export declare namespace Frontmatter {
|
|
308
|
-
var displayName: string;
|
|
309
|
-
}
|
|
310
291
|
//#endregion
|
|
311
292
|
//#region src/components/js/Function.d.ts
|
|
312
293
|
type Props$4 = {
|
|
@@ -384,9 +365,8 @@ type Props$4 = {
|
|
|
384
365
|
* // }
|
|
385
366
|
* ```
|
|
386
367
|
*/
|
|
387
|
-
export declare function Function({ children,
|
|
368
|
+
export declare function Function({ children, name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc }: Props$4): KubbReactElement;
|
|
388
369
|
export declare namespace Function {
|
|
389
|
-
var displayName: string;
|
|
390
370
|
var Arrow: typeof ArrowFunction;
|
|
391
371
|
}
|
|
392
372
|
type ArrowFunctionProps = Props$4 & {
|
|
@@ -410,10 +390,7 @@ type ArrowFunctionProps = Props$4 & {
|
|
|
410
390
|
* // export const double = (n: number): number => n * 2
|
|
411
391
|
* ```
|
|
412
392
|
*/
|
|
413
|
-
declare function ArrowFunction({ children,
|
|
414
|
-
declare namespace ArrowFunction {
|
|
415
|
-
var displayName: string;
|
|
416
|
-
}
|
|
393
|
+
declare function ArrowFunction({ children, name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine }: ArrowFunctionProps): any;
|
|
417
394
|
//#endregion
|
|
418
395
|
//#region src/components/md/Heading.d.ts
|
|
419
396
|
type Level = 1 | 2 | 3 | 4 | 5 | 6;
|
|
@@ -442,12 +419,10 @@ type Props$3 = {
|
|
|
442
419
|
* ```
|
|
443
420
|
*/
|
|
444
421
|
export declare function Heading({ level, children }: Props$3): KubbReactElement;
|
|
445
|
-
export declare namespace Heading {
|
|
446
|
-
var displayName: string;
|
|
447
|
-
}
|
|
448
422
|
//#endregion
|
|
449
423
|
//#region src/components/jsx/Jsx.d.ts
|
|
450
424
|
type Props$2 = {
|
|
425
|
+
key?: Key;
|
|
451
426
|
/**
|
|
452
427
|
* Raw JSX string embedded verbatim in the generated code, including
|
|
453
428
|
* fragments (`<>…</>`).
|
|
@@ -475,9 +450,6 @@ type Props$2 = {
|
|
|
475
450
|
* ```
|
|
476
451
|
*/
|
|
477
452
|
export declare function Jsx({ children }: Props$2): KubbReactElement;
|
|
478
|
-
export declare namespace Jsx {
|
|
479
|
-
var displayName: string;
|
|
480
|
-
}
|
|
481
453
|
//#endregion
|
|
482
454
|
//#region src/components/md/List.d.ts
|
|
483
455
|
type Props$1 = {
|
|
@@ -512,9 +484,6 @@ type Props$1 = {
|
|
|
512
484
|
* ```
|
|
513
485
|
*/
|
|
514
486
|
export declare function List({ ordered, items }: Props$1): KubbReactElement;
|
|
515
|
-
export declare namespace List {
|
|
516
|
-
var displayName: string;
|
|
517
|
-
}
|
|
518
487
|
//#endregion
|
|
519
488
|
//#region src/components/md/Paragraph.d.ts
|
|
520
489
|
type Props = {
|
|
@@ -538,9 +507,6 @@ type Props = {
|
|
|
538
507
|
* ```
|
|
539
508
|
*/
|
|
540
509
|
export declare function Paragraph({ children }: Props): KubbReactElement;
|
|
541
|
-
export declare namespace Paragraph {
|
|
542
|
-
var displayName: string;
|
|
543
|
-
}
|
|
544
510
|
//#endregion
|
|
545
511
|
//#region src/components/js/Type.d.ts
|
|
546
512
|
type TypeProps = {
|
|
@@ -590,521 +556,15 @@ type TypeProps = {
|
|
|
590
556
|
* </Type>
|
|
591
557
|
* ```
|
|
592
558
|
*/
|
|
593
|
-
export declare function Type({ children,
|
|
594
|
-
export declare namespace Type {
|
|
595
|
-
var displayName: string;
|
|
596
|
-
}
|
|
597
|
-
//#endregion
|
|
598
|
-
//#region ../ast/src/nodes/base.d.ts
|
|
599
|
-
/**
|
|
600
|
-
* `kind` values used by AST nodes.
|
|
601
|
-
*
|
|
602
|
-
* @example
|
|
603
|
-
* ```ts
|
|
604
|
-
* const kind: NodeKind = 'Schema'
|
|
605
|
-
* ```
|
|
606
|
-
*/
|
|
607
|
-
type NodeKind = 'Input' | 'Output' | 'Operation' | 'Schema' | 'Property' | 'Parameter' | 'Response' | 'RequestBody' | 'Content' | 'Type' | 'File' | 'Import' | 'Export' | 'Source' | 'Const' | 'Function' | 'ArrowFunction' | 'Text' | 'Break' | 'Jsx';
|
|
608
|
-
/**
|
|
609
|
-
* Base shape shared by all AST nodes.
|
|
610
|
-
*
|
|
611
|
-
* @example
|
|
612
|
-
* ```ts
|
|
613
|
-
* const base: BaseNode = { kind: 'Input' }
|
|
614
|
-
* ```
|
|
615
|
-
*/
|
|
616
|
-
type BaseNode = {
|
|
617
|
-
/**
|
|
618
|
-
* Node discriminator.
|
|
619
|
-
*/
|
|
620
|
-
kind: NodeKind;
|
|
621
|
-
};
|
|
622
|
-
//#endregion
|
|
623
|
-
//#region ../ast/src/nodes/code.d.ts
|
|
624
|
-
/**
|
|
625
|
-
* JSDoc documentation metadata attached to code declarations.
|
|
626
|
-
*/
|
|
627
|
-
type JSDocNode = {
|
|
628
|
-
/**
|
|
629
|
-
* JSDoc comment lines. `undefined` entries are filtered out during rendering.
|
|
630
|
-
*
|
|
631
|
-
* @example
|
|
632
|
-
* ```ts
|
|
633
|
-
* ['@description A pet resource', '@deprecated']
|
|
634
|
-
* ```
|
|
635
|
-
*/
|
|
636
|
-
comments?: Array<string | undefined>;
|
|
637
|
-
};
|
|
638
|
-
/**
|
|
639
|
-
* AST node representing a TypeScript `const` declaration.
|
|
640
|
-
*
|
|
641
|
-
* Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.
|
|
642
|
-
* The `children` prop of the component is represented as `nodes`.
|
|
643
|
-
*
|
|
644
|
-
* @example
|
|
645
|
-
* ```ts
|
|
646
|
-
* createConst({ name: 'pet', export: true, asConst: true })
|
|
647
|
-
* // export const pet = ... as const
|
|
648
|
-
* ```
|
|
649
|
-
*/
|
|
650
|
-
type ConstNode = BaseNode & {
|
|
651
|
-
kind: 'Const';
|
|
652
|
-
/**
|
|
653
|
-
* Name of the constant declaration.
|
|
654
|
-
*/
|
|
655
|
-
name: string;
|
|
656
|
-
/**
|
|
657
|
-
* Whether the declaration should be exported.
|
|
658
|
-
*/
|
|
659
|
-
export?: boolean | null;
|
|
660
|
-
/**
|
|
661
|
-
* Explicit type annotation.
|
|
662
|
-
*
|
|
663
|
-
* @example Type reference
|
|
664
|
-
* `'Pet'`
|
|
665
|
-
*/
|
|
666
|
-
type?: string | null;
|
|
667
|
-
/**
|
|
668
|
-
* JSDoc documentation metadata.
|
|
669
|
-
*/
|
|
670
|
-
JSDoc?: JSDocNode | null;
|
|
671
|
-
/**
|
|
672
|
-
* Whether to append `as const` to the declaration.
|
|
673
|
-
*/
|
|
674
|
-
asConst?: boolean | null;
|
|
675
|
-
/**
|
|
676
|
-
* Child nodes representing the value of the constant (children of the `Const` component).
|
|
677
|
-
* Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
|
|
678
|
-
*/
|
|
679
|
-
nodes?: Array<CodeNode>;
|
|
680
|
-
};
|
|
681
|
-
/**
|
|
682
|
-
* AST node representing a TypeScript `type` alias declaration.
|
|
683
|
-
*
|
|
684
|
-
* Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.
|
|
685
|
-
* The `children` prop of the component is represented as `nodes`.
|
|
686
|
-
*
|
|
687
|
-
* @example
|
|
688
|
-
* ```ts
|
|
689
|
-
* createType({ name: 'Pet', export: true })
|
|
690
|
-
* // export type Pet = ...
|
|
691
|
-
* ```
|
|
692
|
-
*/
|
|
693
|
-
type TypeNode = BaseNode & {
|
|
694
|
-
kind: 'Type';
|
|
695
|
-
/**
|
|
696
|
-
* Name of the type alias.
|
|
697
|
-
*/
|
|
698
|
-
name: string;
|
|
699
|
-
/**
|
|
700
|
-
* Whether the declaration should be exported.
|
|
701
|
-
*/
|
|
702
|
-
export?: boolean | null;
|
|
703
|
-
/**
|
|
704
|
-
* JSDoc documentation metadata.
|
|
705
|
-
*/
|
|
706
|
-
JSDoc?: JSDocNode | null;
|
|
707
|
-
/**
|
|
708
|
-
* Child nodes representing the type body (children of the `Type` component).
|
|
709
|
-
* Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
|
|
710
|
-
*/
|
|
711
|
-
nodes?: Array<CodeNode>;
|
|
712
|
-
};
|
|
713
|
-
/**
|
|
714
|
-
* AST node representing a TypeScript `function` declaration.
|
|
715
|
-
*
|
|
716
|
-
* Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.
|
|
717
|
-
* The `children` prop of the component is represented as `nodes`.
|
|
718
|
-
*
|
|
719
|
-
* @example
|
|
720
|
-
* ```ts
|
|
721
|
-
* createFunction({ name: 'getPet', export: true, async: true, returnType: 'Pet' })
|
|
722
|
-
* // export async function getPet(): Promise<Pet> { ... }
|
|
723
|
-
* ```
|
|
724
|
-
*/
|
|
725
|
-
type FunctionNode = BaseNode & {
|
|
726
|
-
kind: 'Function';
|
|
727
|
-
/**
|
|
728
|
-
* Name of the function.
|
|
729
|
-
*/
|
|
730
|
-
name: string;
|
|
731
|
-
/**
|
|
732
|
-
* Whether the function is a default export.
|
|
733
|
-
*/
|
|
734
|
-
default?: boolean | null;
|
|
735
|
-
/**
|
|
736
|
-
* Function parameter list as a pre-rendered string, written verbatim between the parentheses.
|
|
737
|
-
*
|
|
738
|
-
* @example
|
|
739
|
-
* `'id: string, config: Config = {}'`
|
|
740
|
-
*/
|
|
741
|
-
params?: string | null;
|
|
742
|
-
/**
|
|
743
|
-
* Whether the function should be exported.
|
|
744
|
-
*/
|
|
745
|
-
export?: boolean | null;
|
|
746
|
-
/**
|
|
747
|
-
* Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.
|
|
748
|
-
*/
|
|
749
|
-
async?: boolean | null;
|
|
750
|
-
/**
|
|
751
|
-
* TypeScript generic type parameters.
|
|
752
|
-
*
|
|
753
|
-
* @example Constrained generics
|
|
754
|
-
* `['T', 'U extends string']`
|
|
755
|
-
*/
|
|
756
|
-
generics?: string | Array<string> | null;
|
|
757
|
-
/**
|
|
758
|
-
* Return type annotation.
|
|
759
|
-
*
|
|
760
|
-
* @example Type reference
|
|
761
|
-
* `'Pet'`
|
|
762
|
-
*/
|
|
763
|
-
returnType?: string | null;
|
|
764
|
-
/**
|
|
765
|
-
* JSDoc documentation metadata.
|
|
766
|
-
*/
|
|
767
|
-
JSDoc?: JSDocNode | null;
|
|
768
|
-
/**
|
|
769
|
-
* Child nodes representing the function body (children of the `Function` component).
|
|
770
|
-
* Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
|
|
771
|
-
*/
|
|
772
|
-
nodes?: Array<CodeNode>;
|
|
773
|
-
};
|
|
774
|
-
/**
|
|
775
|
-
* AST node representing a TypeScript arrow function (`const name = () => { ... }`).
|
|
776
|
-
*
|
|
777
|
-
* Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.
|
|
778
|
-
* The `children` prop of the component is represented as `nodes`.
|
|
779
|
-
*
|
|
780
|
-
* @example
|
|
781
|
-
* ```ts
|
|
782
|
-
* createArrowFunction({ name: 'getPet', export: true, singleLine: true })
|
|
783
|
-
* // export const getPet = () => ...
|
|
784
|
-
* ```
|
|
785
|
-
*/
|
|
786
|
-
type ArrowFunctionNode = Omit<FunctionNode, 'kind'> & {
|
|
787
|
-
kind: 'ArrowFunction';
|
|
788
|
-
/**
|
|
789
|
-
* Render the arrow function body as a single-line expression.
|
|
790
|
-
*/
|
|
791
|
-
singleLine?: boolean | null;
|
|
792
|
-
};
|
|
793
|
-
/**
|
|
794
|
-
* AST node representing a raw text/string fragment in the source output.
|
|
795
|
-
*
|
|
796
|
-
* Used instead of bare `string` values so that all entries in `nodes` arrays
|
|
797
|
-
* are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.
|
|
798
|
-
*
|
|
799
|
-
* @example
|
|
800
|
-
* ```ts
|
|
801
|
-
* createText('return fetch(id)')
|
|
802
|
-
* // { kind: 'Text', value: 'return fetch(id)' }
|
|
803
|
-
* ```
|
|
804
|
-
*/
|
|
805
|
-
type TextNode = BaseNode & {
|
|
806
|
-
kind: 'Text';
|
|
807
|
-
/**
|
|
808
|
-
* The raw string content.
|
|
809
|
-
*/
|
|
810
|
-
value: string;
|
|
811
|
-
};
|
|
812
|
-
/**
|
|
813
|
-
* AST node representing a blank line in the source output.
|
|
814
|
-
*
|
|
815
|
-
* Corresponds to `<br/>` in JSX components. `printNodes` turns a `Break` between two
|
|
816
|
-
* statements into one blank line. Consecutive breaks, and breaks at the start or end of
|
|
817
|
-
* the list, are folded away, so a `Break` never produces more than one blank line.
|
|
818
|
-
*
|
|
819
|
-
* @example
|
|
820
|
-
* ```ts
|
|
821
|
-
* createBreak()
|
|
822
|
-
* // { kind: 'Break' }
|
|
823
|
-
* ```
|
|
824
|
-
*/
|
|
825
|
-
type BreakNode = BaseNode & {
|
|
826
|
-
kind: 'Break';
|
|
827
|
-
};
|
|
828
|
-
/**
|
|
829
|
-
* AST node representing a raw JSX fragment in the source output.
|
|
830
|
-
*
|
|
831
|
-
* Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup
|
|
832
|
-
* (including fragments `<>…</>`) directly in generated code.
|
|
833
|
-
*
|
|
834
|
-
* @example
|
|
835
|
-
* ```ts
|
|
836
|
-
* createJsx('<>\n <a href={href}>Open</a>\n</>')
|
|
837
|
-
* // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
|
|
838
|
-
* ```
|
|
839
|
-
*/
|
|
840
|
-
type JsxNode = BaseNode & {
|
|
841
|
-
kind: 'Jsx';
|
|
842
|
-
/**
|
|
843
|
-
* The raw JSX string content.
|
|
844
|
-
*/
|
|
845
|
-
value: string;
|
|
846
|
-
};
|
|
847
|
-
/**
|
|
848
|
-
* Union of all code-generation AST nodes.
|
|
849
|
-
*
|
|
850
|
-
* These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as
|
|
851
|
-
* structured children in {@link SourceNode.nodes}.
|
|
852
|
-
*/
|
|
853
|
-
type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
|
|
854
|
-
//#endregion
|
|
855
|
-
//#region ../ast/src/nodes/file.d.ts
|
|
856
|
-
/**
|
|
857
|
-
* Supported file extensions.
|
|
858
|
-
*/
|
|
859
|
-
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
860
|
-
type ImportName = string | Array<string | {
|
|
861
|
-
propertyName: string;
|
|
862
|
-
name?: string;
|
|
863
|
-
}>;
|
|
864
|
-
/**
|
|
865
|
-
* Represents a language-agnostic import/dependency declaration.
|
|
866
|
-
*
|
|
867
|
-
* @example Named import (TypeScript: `import { useState } from 'react'`)
|
|
868
|
-
* ```ts
|
|
869
|
-
* createImport({ name: ['useState'], path: 'react' })
|
|
870
|
-
* ```
|
|
871
|
-
*
|
|
872
|
-
* @example Default import (TypeScript: `import React from 'react'`)
|
|
873
|
-
* ```ts
|
|
874
|
-
* createImport({ name: 'React', path: 'react' })
|
|
875
|
-
* ```
|
|
876
|
-
*
|
|
877
|
-
* @example Type-only import (TypeScript: `import type { FC } from 'react'`)
|
|
878
|
-
* ```ts
|
|
879
|
-
* createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
|
|
880
|
-
* ```
|
|
881
|
-
*
|
|
882
|
-
* @example Namespace import (TypeScript: `import * as React from 'react'`)
|
|
883
|
-
* ```ts
|
|
884
|
-
* createImport({ name: 'React', path: 'react', isNameSpace: true })
|
|
885
|
-
* ```
|
|
886
|
-
*/
|
|
887
|
-
type ImportNode = BaseNode & {
|
|
888
|
-
kind: 'Import';
|
|
889
|
-
/**
|
|
890
|
-
* Import name(s) to be used.
|
|
891
|
-
*
|
|
892
|
-
* @example Named imports
|
|
893
|
-
* `['useState']`
|
|
894
|
-
*
|
|
895
|
-
* @example Default import
|
|
896
|
-
* `'React'`
|
|
897
|
-
*/
|
|
898
|
-
name: ImportName;
|
|
899
|
-
/**
|
|
900
|
-
* Path for the import.
|
|
901
|
-
*
|
|
902
|
-
* @example
|
|
903
|
-
* `'@kubb/core'`
|
|
904
|
-
*/
|
|
905
|
-
path: string;
|
|
906
|
-
/**
|
|
907
|
-
* Add a type-only import prefix.
|
|
908
|
-
* - `true` generates `import type { Type } from './path'`
|
|
909
|
-
* - `false` generates `import { Type } from './path'`
|
|
910
|
-
*/
|
|
911
|
-
isTypeOnly?: boolean | null;
|
|
912
|
-
/**
|
|
913
|
-
* Import the entire module as a namespace.
|
|
914
|
-
* - `true` generates `import * as Name from './path'`
|
|
915
|
-
* - `false` generates a standard import
|
|
916
|
-
*/
|
|
917
|
-
isNameSpace?: boolean | null;
|
|
918
|
-
/**
|
|
919
|
-
* When set, the import path is resolved relative to this root.
|
|
920
|
-
*/
|
|
921
|
-
root?: string | null;
|
|
922
|
-
};
|
|
923
|
-
/**
|
|
924
|
-
* Represents a language-agnostic export/public API declaration.
|
|
925
|
-
*
|
|
926
|
-
* @example Named export (TypeScript: `export { Pets } from './Pets'`)
|
|
927
|
-
* ```ts
|
|
928
|
-
* createExport({ name: ['Pets'], path: './Pets' })
|
|
929
|
-
* ```
|
|
930
|
-
*
|
|
931
|
-
* @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)
|
|
932
|
-
* ```ts
|
|
933
|
-
* createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })
|
|
934
|
-
* ```
|
|
935
|
-
*
|
|
936
|
-
* @example Wildcard export (TypeScript: `export * from './utils'`)
|
|
937
|
-
* ```ts
|
|
938
|
-
* createExport({ path: './utils' })
|
|
939
|
-
* ```
|
|
940
|
-
*
|
|
941
|
-
* @example Namespace alias (TypeScript: `export * as utils from './utils'`)
|
|
942
|
-
* ```ts
|
|
943
|
-
* createExport({ name: 'utils', path: './utils', asAlias: true })
|
|
944
|
-
* ```
|
|
945
|
-
*/
|
|
946
|
-
type ExportNode = BaseNode & {
|
|
947
|
-
kind: 'Export';
|
|
948
|
-
/**
|
|
949
|
-
* Export name(s) to be used. When omitted, generates a wildcard export.
|
|
950
|
-
*
|
|
951
|
-
* @example Named exports
|
|
952
|
-
* `['useState']`
|
|
953
|
-
*
|
|
954
|
-
* @example Single export
|
|
955
|
-
* `'React'`
|
|
956
|
-
*/
|
|
957
|
-
name?: string | Array<string> | null;
|
|
958
|
-
/**
|
|
959
|
-
* Path for the export.
|
|
960
|
-
*
|
|
961
|
-
* @example
|
|
962
|
-
* `'@kubb/core'`
|
|
963
|
-
*/
|
|
964
|
-
path: string;
|
|
965
|
-
/**
|
|
966
|
-
* Add a type-only export prefix.
|
|
967
|
-
* - `true` generates `export type { Type } from './path'`
|
|
968
|
-
* - `false` generates `export { Type } from './path'`
|
|
969
|
-
*/
|
|
970
|
-
isTypeOnly?: boolean | null;
|
|
971
|
-
/**
|
|
972
|
-
* Export as an aliased namespace.
|
|
973
|
-
* - `true` generates `export * as aliasName from './path'`
|
|
974
|
-
* - `false` generates a standard export
|
|
975
|
-
*/
|
|
976
|
-
asAlias?: boolean | null;
|
|
977
|
-
};
|
|
978
|
-
/**
|
|
979
|
-
* Represents a fragment of source code within a file.
|
|
980
|
-
*
|
|
981
|
-
* @example Named exportable source
|
|
982
|
-
* ```ts
|
|
983
|
-
* createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })
|
|
984
|
-
* ```
|
|
985
|
-
*
|
|
986
|
-
* @example Inline unnamed code block
|
|
987
|
-
* ```ts
|
|
988
|
-
* createSource({ nodes: [createText('const x = 1')] })
|
|
989
|
-
* ```
|
|
990
|
-
*/
|
|
991
|
-
type SourceNode = BaseNode & {
|
|
992
|
-
kind: 'Source';
|
|
993
|
-
/**
|
|
994
|
-
* Optional name identifying this source (used for deduplication and barrel generation).
|
|
995
|
-
*/
|
|
996
|
-
name?: string | null;
|
|
997
|
-
/**
|
|
998
|
-
* Mark this source as a type-only export.
|
|
999
|
-
*/
|
|
1000
|
-
isTypeOnly?: boolean | null;
|
|
1001
|
-
/**
|
|
1002
|
-
* Include the `export` keyword in the generated source.
|
|
1003
|
-
*/
|
|
1004
|
-
isExportable?: boolean | null;
|
|
1005
|
-
/**
|
|
1006
|
-
* Include this source in barrel/index file generation.
|
|
1007
|
-
*/
|
|
1008
|
-
isIndexable?: boolean | null;
|
|
1009
|
-
/**
|
|
1010
|
-
* Child nodes that make up this source fragment, in DOM order.
|
|
1011
|
-
* Use a {@link TextNode} for raw string content.
|
|
1012
|
-
*/
|
|
1013
|
-
nodes?: Array<CodeNode>;
|
|
1014
|
-
};
|
|
1015
|
-
/**
|
|
1016
|
-
* Represents a fully resolved file in the AST.
|
|
1017
|
-
*
|
|
1018
|
-
* Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input
|
|
1019
|
-
* and deduplicates `imports`, `exports`, and `sources`.
|
|
1020
|
-
*
|
|
1021
|
-
* @example
|
|
1022
|
-
* ```ts
|
|
1023
|
-
* const file = createFile({
|
|
1024
|
-
* baseName: 'petStore.ts',
|
|
1025
|
-
* path: 'src/models/petStore.ts',
|
|
1026
|
-
* sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],
|
|
1027
|
-
* imports: [createImport({ name: ['z'], path: 'zod' })],
|
|
1028
|
-
* exports: [createExport({ name: ['Pet'], path: './petStore' })],
|
|
1029
|
-
* })
|
|
1030
|
-
* // file.id = SHA256 hash of the path
|
|
1031
|
-
* // file.name = 'petStore'
|
|
1032
|
-
* // file.extname = '.ts'
|
|
1033
|
-
* ```
|
|
1034
|
-
*/
|
|
1035
|
-
type FileNode<TMeta extends object = object> = BaseNode & {
|
|
1036
|
-
kind: 'File';
|
|
1037
|
-
/**
|
|
1038
|
-
* Unique identifier derived from a SHA256 hash of the file path. `createFile`
|
|
1039
|
-
* computes it, so callers do not need to provide it.
|
|
1040
|
-
*/
|
|
1041
|
-
id: string;
|
|
1042
|
-
/**
|
|
1043
|
-
* File name without extension, derived from `baseName`.
|
|
1044
|
-
*
|
|
1045
|
-
* @see https://nodejs.org/api/path.html#pathformatpathobject
|
|
1046
|
-
*/
|
|
1047
|
-
name: string;
|
|
1048
|
-
/**
|
|
1049
|
-
* File base name, including extension, shaped like `${name}${extname}`.
|
|
1050
|
-
*
|
|
1051
|
-
* @see https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
1052
|
-
*/
|
|
1053
|
-
baseName: `${string}.${string}`;
|
|
1054
|
-
/**
|
|
1055
|
-
* Full qualified path to the file.
|
|
1056
|
-
*/
|
|
1057
|
-
path: string;
|
|
1058
|
-
/**
|
|
1059
|
-
* File extension extracted from `baseName`.
|
|
1060
|
-
*/
|
|
1061
|
-
extname: Extname;
|
|
1062
|
-
/**
|
|
1063
|
-
* Deduplicated list of source code fragments.
|
|
1064
|
-
*/
|
|
1065
|
-
sources: Array<SourceNode>;
|
|
1066
|
-
/**
|
|
1067
|
-
* Deduplicated list of import declarations.
|
|
1068
|
-
*/
|
|
1069
|
-
imports: Array<ImportNode>;
|
|
1070
|
-
/**
|
|
1071
|
-
* Deduplicated list of export declarations.
|
|
1072
|
-
*/
|
|
1073
|
-
exports: Array<ExportNode>;
|
|
1074
|
-
/**
|
|
1075
|
-
* Optional metadata attached to this file, read by plugins during barrel generation.
|
|
1076
|
-
*/
|
|
1077
|
-
meta?: TMeta;
|
|
1078
|
-
/**
|
|
1079
|
-
* Optional banner prepended to the generated file content.
|
|
1080
|
-
* Accepts `null` so `resolver.default.banner()` results can be passed directly.
|
|
1081
|
-
*/
|
|
1082
|
-
banner?: string | null;
|
|
1083
|
-
/**
|
|
1084
|
-
* Optional footer appended to the generated file content.
|
|
1085
|
-
* Accepts `null` so `resolver.default.footer()` results can be passed directly.
|
|
1086
|
-
*/
|
|
1087
|
-
footer?: string | null;
|
|
1088
|
-
/**
|
|
1089
|
-
* Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has one.
|
|
1090
|
-
*
|
|
1091
|
-
* Use to emit a real source file shipped inside a package (a template) into the generated
|
|
1092
|
-
* folder. When set, `copy` provides the file content and any `sources` nodes are ignored for
|
|
1093
|
-
* output; `sources` may still carry `name`/`isExportable`/`isIndexable` so barrel generation
|
|
1094
|
-
* treats the file the same as a rendered one.
|
|
1095
|
-
*/
|
|
1096
|
-
copy?: string | null;
|
|
1097
|
-
};
|
|
559
|
+
export declare function Type({ children, name, export: canExport, JSDoc }: TypeProps): KubbReactElement;
|
|
1098
560
|
//#endregion
|
|
1099
561
|
//#region src/jsxRenderer.d.ts
|
|
1100
562
|
/**
|
|
1101
563
|
* Factory for a renderer that walks the JSX tree in a single recursive pass,
|
|
1102
564
|
* with no React reconciler or scheduler. Pass it as the `renderer` property on
|
|
1103
565
|
* `defineGenerator`. Kubb core calls the factory once per render cycle and stays
|
|
1104
|
-
* generic, with no hard dependency on `@kubb/renderer-jsx`.
|
|
1105
|
-
*
|
|
1106
|
-
* Every component must be a pure function. Hooks, suspense, and class
|
|
1107
|
-
* components are not supported.
|
|
566
|
+
* generic, with no hard dependency on `@kubb/renderer-jsx`. Every component must be a pure
|
|
567
|
+
* function. Hooks, suspense and class components are not supported.
|
|
1108
568
|
*
|
|
1109
569
|
* @example Wire up a JSX generator
|
|
1110
570
|
* ```tsx
|
|
@@ -1126,7 +586,7 @@ type FileNode<TMeta extends object = object> = BaseNode & {
|
|
|
1126
586
|
*/
|
|
1127
587
|
export declare const jsxRenderer: () => {
|
|
1128
588
|
render(element: KubbReactElement): Promise<void>;
|
|
1129
|
-
readonly files: FileNode[];
|
|
589
|
+
readonly files: ast.FileNode[];
|
|
1130
590
|
[Symbol.dispose](): void;
|
|
1131
591
|
};
|
|
1132
592
|
//#endregion
|