@kubb/renderer-jsx 5.0.0-beta.2 → 5.0.0-beta.21
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/README.md +124 -0
- package/dist/index.cjs +429 -182
- package/dist/index.d.ts +43 -56
- package/dist/index.js +429 -182
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/{jsx-namespace-CNp0arTN.d.ts → jsx-namespace-C7dcxEyT.d.ts} +2 -2
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/{types-nAFMiWFw.d.ts → types-D3-ni438.d.ts} +3 -3
- package/dist/types.d.ts +1 -1
- package/package.json +3 -9
- package/src/Renderer.ts +1 -5
- package/src/Runtime.tsx +6 -17
- package/src/SyncRuntime.tsx +309 -0
- package/src/constants.ts +19 -9
- package/src/createRenderer.tsx +57 -60
- package/src/dom.ts +7 -19
- package/src/index.ts +1 -1
- package/src/types.ts +2 -2
- package/src/utils.ts +154 -175
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jsx-dev-runtime.cjs.map +0 -1
- package/dist/jsx-dev-runtime.js.map +0 -1
- package/dist/jsx-runtime-Cvu_ZYgL.js.map +0 -1
- package/dist/jsx-runtime-DdmO3p0U.cjs.map +0 -1
- package/dist/jsx-runtime.cjs.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __name } from "./chunk-Bb7HlUDG.js";
|
|
2
|
-
import { a as JSDoc, h as KubbReactNode, m as KubbReactElement, o as Key } from "./types-
|
|
2
|
+
import { a as JSDoc, h as KubbReactNode, m as KubbReactElement, o as Key } from "./types-D3-ni438.js";
|
|
3
3
|
import { ExportNode, FileNode, ImportNode, SourceNode } from "@kubb/ast";
|
|
4
4
|
import * as _$react from "react";
|
|
5
5
|
|
|
@@ -519,78 +519,65 @@ declare namespace Type {
|
|
|
519
519
|
}
|
|
520
520
|
//#endregion
|
|
521
521
|
//#region src/createRenderer.d.ts
|
|
522
|
-
type Options = {
|
|
523
|
-
/**
|
|
524
|
-
* Print each render result to the console for debugging.
|
|
525
|
-
* Useful when diagnosing output differences between renders.
|
|
526
|
-
* @default false
|
|
527
|
-
*/
|
|
528
|
-
debug?: boolean;
|
|
529
|
-
};
|
|
530
522
|
/**
|
|
531
|
-
*
|
|
532
|
-
*/
|
|
533
|
-
type Renderer = {
|
|
534
|
-
/**
|
|
535
|
-
* Render a JSX element tree and collect the resulting {@link FileNode} entries.
|
|
536
|
-
* Resolves once all synchronous render work (including React's flush) is done.
|
|
537
|
-
*/
|
|
538
|
-
render(Element: KubbReactElement): Promise<void>;
|
|
539
|
-
/**
|
|
540
|
-
* Tear down the renderer and release all React resources.
|
|
541
|
-
* Pass an `Error` to signal an abnormal shutdown.
|
|
542
|
-
*/
|
|
543
|
-
unmount(error?: Error | number | null): void;
|
|
544
|
-
/**
|
|
545
|
-
* The {@link FileNode} entries collected from the most recent `render` call.
|
|
546
|
-
*/
|
|
547
|
-
files: Array<FileNode>;
|
|
548
|
-
};
|
|
549
|
-
/**
|
|
550
|
-
* Create a Kubb JSX renderer.
|
|
523
|
+
* Renderer factory for generators that produce JSX output.
|
|
551
524
|
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
525
|
+
* Pass as the `renderer` property of `defineGenerator`. Core drives rendering
|
|
526
|
+
* without a hard dependency on `@kubb/renderer-jsx`.
|
|
554
527
|
*
|
|
555
|
-
* @example
|
|
528
|
+
* @example
|
|
556
529
|
* ```ts
|
|
557
|
-
* import {
|
|
558
|
-
*
|
|
559
|
-
* const
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
* <File.
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
* </File>
|
|
566
|
-
* )
|
|
567
|
-
* console.log(renderer.files) // [FileNode]
|
|
568
|
-
* renderer.unmount()
|
|
530
|
+
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
531
|
+
*
|
|
532
|
+
* export const myGenerator = defineGenerator<PluginTs>({
|
|
533
|
+
* renderer: jsxRenderer,
|
|
534
|
+
* schema(node, options) {
|
|
535
|
+
* return <File baseName="output.ts" path="src/output.ts">...</File>
|
|
536
|
+
* },
|
|
537
|
+
* })
|
|
569
538
|
* ```
|
|
570
539
|
*/
|
|
571
|
-
declare
|
|
540
|
+
declare const jsxRenderer: () => {
|
|
541
|
+
render(element: KubbReactElement): Promise<void>;
|
|
542
|
+
readonly files: FileNode[];
|
|
543
|
+
dispose(): void;
|
|
544
|
+
unmount(error?: Error | number | null): void;
|
|
545
|
+
[Symbol.dispose](): void;
|
|
546
|
+
};
|
|
572
547
|
/**
|
|
573
|
-
*
|
|
548
|
+
* Lightweight renderer factory with no React fiber, scheduler, or work loop.
|
|
574
549
|
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
550
|
+
* Walks the JSX element tree in a single recursive pass. All components must be
|
|
551
|
+
* pure functions; hooks and class components are not supported. Drop-in
|
|
552
|
+
* replacement for {@link jsxRenderer} at approximately 2–4× the speed.
|
|
578
553
|
*
|
|
579
|
-
* @example
|
|
554
|
+
* @example Drop-in replacement
|
|
580
555
|
* ```ts
|
|
581
|
-
* import {
|
|
582
|
-
* import { defineGenerator } from '@kubb/core'
|
|
556
|
+
* import { jsxRendererSync } from '@kubb/renderer-jsx'
|
|
583
557
|
*
|
|
584
558
|
* export const myGenerator = defineGenerator<PluginTs>({
|
|
585
|
-
*
|
|
586
|
-
* renderer: jsxRenderer,
|
|
559
|
+
* renderer: jsxRendererSync,
|
|
587
560
|
* schema(node, options) {
|
|
588
561
|
* return <File baseName="output.ts" path="src/output.ts">...</File>
|
|
589
562
|
* },
|
|
590
563
|
* })
|
|
591
564
|
* ```
|
|
565
|
+
*
|
|
566
|
+
* @example Stream files as they are produced
|
|
567
|
+
* ```ts
|
|
568
|
+
* for await (const file of jsxRendererSync().stream(element)) {
|
|
569
|
+
* await writeFile(file)
|
|
570
|
+
* }
|
|
571
|
+
* ```
|
|
592
572
|
*/
|
|
593
|
-
declare const
|
|
573
|
+
declare const jsxRendererSync: () => {
|
|
574
|
+
render(element: KubbReactElement): Promise<void>;
|
|
575
|
+
readonly files: FileNode[];
|
|
576
|
+
stream(element: KubbReactElement): Generator<FileNode>;
|
|
577
|
+
dispose(): void;
|
|
578
|
+
unmount(_error?: Error | number | null): void;
|
|
579
|
+
[Symbol.dispose](): void;
|
|
580
|
+
};
|
|
594
581
|
//#endregion
|
|
595
|
-
export { Const, File, Function, Jsx, Root, Type, createContext,
|
|
582
|
+
export { Const, File, Function, Jsx, Root, Type, createContext, inject, jsxRenderer, jsxRendererSync, provide, unprovide };
|
|
596
583
|
//# sourceMappingURL=index.d.ts.map
|