@kubb/react-fabric 0.11.7 → 0.12.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/globals.d.cts +3 -2
- package/dist/globals.d.ts +3 -2
- package/dist/index.cjs +10 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -86
- package/dist/index.d.ts +26 -86
- package/dist/index.js +11 -58
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +4 -5
- package/dist/jsx-dev-runtime.d.ts +2 -3
- package/dist/{jsx-namespace-CDB8OdrC.d.cts → jsx-namespace-BUHfo3FK.d.cts} +3 -2
- package/dist/{jsx-namespace-rawlYj_g.d.ts → jsx-namespace-Lr0pS1AG.d.ts} +3 -1
- package/dist/jsx-runtime.d.cts +4 -5
- package/dist/jsx-runtime.d.ts +2 -3
- package/dist/parsers.d.cts +1 -1
- package/dist/parsers.d.ts +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.d.cts +32 -10
- package/dist/plugins.d.ts +32 -10
- package/dist/plugins.js +1 -1
- package/dist/{reactPlugin-lOa0xpGM.js → reactPlugin-BHxx8AjV.js} +32 -15
- package/dist/{reactPlugin-lOa0xpGM.js.map → reactPlugin-BHxx8AjV.js.map} +1 -1
- package/dist/reactPlugin-CWHmkuUz.d.cts +72 -0
- package/dist/{reactPlugin-BzGD_nR7.cjs → reactPlugin-CicgALtR.cjs} +31 -14
- package/dist/{reactPlugin-BzGD_nR7.cjs.map → reactPlugin-CicgALtR.cjs.map} +1 -1
- package/dist/reactPlugin-DseDoGSU.d.ts +73 -0
- package/dist/{Fabric-4Ac6xwwR.d.ts → types-C-nm6Bqx.d.ts} +197 -20
- package/dist/{Fabric-xd8epqSF.d.cts → types-yKh-a1UP.d.cts} +199 -20
- package/dist/types.d.cts +2 -3
- package/dist/types.d.ts +2 -3
- package/package.json +2 -4
- package/src/Runtime.tsx +6 -10
- package/src/components/App.tsx +3 -3
- package/src/components/Const.tsx +2 -2
- package/src/components/File.tsx +5 -5
- package/src/components/Function.tsx +12 -5
- package/src/components/Root.tsx +2 -2
- package/src/components/Type.tsx +2 -2
- package/src/components/__snapshots__/{arrow_function_generics.ts → exported_async_arrow_function_with_generics.ts} +1 -1
- package/src/components/__snapshots__/{multiple_functions.ts → exported_async_function_with_generics.ts} +1 -1
- package/src/createReactFabric.ts +1 -2
- package/src/devtools.ts +3 -0
- package/src/dom.ts +12 -1
- package/src/globals.ts +2 -0
- package/src/index.ts +1 -2
- package/src/jsx-namespace.d.ts +2 -0
- package/src/plugins/reactPlugin.ts +9 -7
- package/src/types.ts +1 -1
- package/src/utils/squashExportNodes.ts +2 -2
- package/src/utils/squashTextNodes.ts +23 -8
- package/dist/TreeNode-CoigrXFC.d.ts +0 -35
- package/dist/TreeNode-Pwm74f2F.d.cts +0 -34
- package/dist/reactPlugin-6pWd-WfZ.d.cts +0 -30
- package/dist/reactPlugin-CpMrftCn.d.ts +0 -31
- package/dist/types-125Qu-Uh.d.ts +0 -129
- package/dist/types-BrE57KWH.d.cts +0 -128
- package/src/components/Indent.tsx +0 -56
- package/src/components/__snapshots__/arrow_function.ts +0 -3
- package/src/components/__snapshots__/arrow_function_default.ts +0 -3
- package/src/components/__snapshots__/arrow_function_single_line.ts +0 -1
- package/src/components/__snapshots__/function_generics.ts +0 -3
- package/src/components/__snapshots__/function_with_comments.ts +0 -6
- package/src/components/__snapshots__/function_with_params.ts +0 -3
- package/src/components/__snapshots__/function_with_returnType.ts +0 -3
package/dist/plugins.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as reactPlugin } from "./reactPlugin-
|
|
1
|
+
import { A as Plugin, C as TreeNode, D as FabricElement, K as __name, S as ComponentNode, j as UserPlugin, z as Extname } from "./types-yKh-a1UP.cjs";
|
|
2
|
+
import { n as reactPlugin } from "./reactPlugin-CWHmkuUz.cjs";
|
|
3
3
|
|
|
4
4
|
//#region ../fabric-core/src/plugins/barrelPlugin.d.ts
|
|
5
5
|
type Mode = 'all' | 'named' | 'propagate' | false;
|
|
6
|
-
type Options$
|
|
6
|
+
type Options$4 = {
|
|
7
7
|
root: string;
|
|
8
8
|
mode: Mode;
|
|
9
9
|
dryRun?: boolean;
|
|
@@ -12,7 +12,7 @@ type WriteEntryOptions = {
|
|
|
12
12
|
root: string;
|
|
13
13
|
mode: Mode;
|
|
14
14
|
};
|
|
15
|
-
type ExtendOptions$
|
|
15
|
+
type ExtendOptions$2 = {
|
|
16
16
|
/**
|
|
17
17
|
* `fabric.writeEntry` should be called before `fabric.write`
|
|
18
18
|
*/
|
|
@@ -28,16 +28,16 @@ declare global {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
declare const barrelPlugin: Plugin<Options$
|
|
31
|
+
declare const barrelPlugin: Plugin<Options$4, ExtendOptions$2>;
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region ../fabric-core/src/plugins/definePlugin.d.ts
|
|
34
|
-
declare function definePlugin<Options$
|
|
34
|
+
declare function definePlugin<Options$5 = unknown, TAppExtension extends Record<string, any> = {}>(plugin: UserPlugin<Options$5, TAppExtension>): Plugin<Options$5, TAppExtension>;
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region ../fabric-core/src/plugins/fsPlugin.d.ts
|
|
37
37
|
type WriteOptions = {
|
|
38
38
|
extension?: Record<Extname, Extname | ''>;
|
|
39
39
|
};
|
|
40
|
-
type Options$
|
|
40
|
+
type Options$3 = {
|
|
41
41
|
dryRun?: boolean;
|
|
42
42
|
/**
|
|
43
43
|
* Optional callback that is invoked whenever a file is written by the plugin.
|
|
@@ -48,7 +48,7 @@ type Options$2 = {
|
|
|
48
48
|
path: string;
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
-
type ExtendOptions = {
|
|
51
|
+
type ExtendOptions$1 = {
|
|
52
52
|
write(options?: WriteOptions): Promise<void>;
|
|
53
53
|
};
|
|
54
54
|
declare global {
|
|
@@ -58,7 +58,29 @@ declare global {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
declare const fsPlugin: Plugin<Options$
|
|
61
|
+
declare const fsPlugin: Plugin<Options$3, ExtendOptions$1>;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region ../fabric-core/src/plugins/fsxPlugin/fsxPlugin.d.ts
|
|
64
|
+
type Options$2 = {
|
|
65
|
+
treeNode?: TreeNode<ComponentNode>;
|
|
66
|
+
/**
|
|
67
|
+
* Set this to true to always see the result of the render in the console(line per render)
|
|
68
|
+
*/
|
|
69
|
+
debug?: boolean;
|
|
70
|
+
};
|
|
71
|
+
type ExtendOptions = {
|
|
72
|
+
render(App: FabricElement<any>): Promise<string>;
|
|
73
|
+
waitUntilExit(): Promise<void>;
|
|
74
|
+
};
|
|
75
|
+
declare global {
|
|
76
|
+
namespace Kubb {
|
|
77
|
+
interface Fabric {
|
|
78
|
+
render(App: FabricElement<any>): Promise<string>;
|
|
79
|
+
waitUntilExit(): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
declare const fsxPlugin: Plugin<Options$2, ExtendOptions>;
|
|
62
84
|
//#endregion
|
|
63
85
|
//#region ../fabric-core/src/plugins/graphPlugin.d.ts
|
|
64
86
|
type Options$1 = {
|
|
@@ -100,4 +122,4 @@ type Options = {
|
|
|
100
122
|
};
|
|
101
123
|
declare const loggerPlugin: Plugin<Options, {}>;
|
|
102
124
|
//#endregion
|
|
103
|
-
export { barrelPlugin, definePlugin, fsPlugin, graphPlugin, loggerPlugin, reactPlugin };
|
|
125
|
+
export { barrelPlugin, definePlugin, fsPlugin, fsxPlugin, graphPlugin, loggerPlugin, reactPlugin };
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { r as __name } from "./chunk-DkQCb-7t.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as reactPlugin } from "./reactPlugin-
|
|
2
|
+
import { A as Plugin, C as TreeNode, D as FabricElement, S as ComponentNode, j as UserPlugin, z as Extname } from "./types-C-nm6Bqx.js";
|
|
3
|
+
import { n as reactPlugin } from "./reactPlugin-DseDoGSU.js";
|
|
4
4
|
|
|
5
5
|
//#region ../fabric-core/src/plugins/barrelPlugin.d.ts
|
|
6
6
|
type Mode = 'all' | 'named' | 'propagate' | false;
|
|
7
|
-
type Options$
|
|
7
|
+
type Options$4 = {
|
|
8
8
|
root: string;
|
|
9
9
|
mode: Mode;
|
|
10
10
|
dryRun?: boolean;
|
|
@@ -13,7 +13,7 @@ type WriteEntryOptions = {
|
|
|
13
13
|
root: string;
|
|
14
14
|
mode: Mode;
|
|
15
15
|
};
|
|
16
|
-
type ExtendOptions$
|
|
16
|
+
type ExtendOptions$2 = {
|
|
17
17
|
/**
|
|
18
18
|
* `fabric.writeEntry` should be called before `fabric.write`
|
|
19
19
|
*/
|
|
@@ -29,16 +29,16 @@ declare global {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
declare const barrelPlugin: Plugin<Options$
|
|
32
|
+
declare const barrelPlugin: Plugin<Options$4, ExtendOptions$2>;
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region ../fabric-core/src/plugins/definePlugin.d.ts
|
|
35
|
-
declare function definePlugin<Options$
|
|
35
|
+
declare function definePlugin<Options$5 = unknown, TAppExtension extends Record<string, any> = {}>(plugin: UserPlugin<Options$5, TAppExtension>): Plugin<Options$5, TAppExtension>;
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region ../fabric-core/src/plugins/fsPlugin.d.ts
|
|
38
38
|
type WriteOptions = {
|
|
39
39
|
extension?: Record<Extname, Extname | ''>;
|
|
40
40
|
};
|
|
41
|
-
type Options$
|
|
41
|
+
type Options$3 = {
|
|
42
42
|
dryRun?: boolean;
|
|
43
43
|
/**
|
|
44
44
|
* Optional callback that is invoked whenever a file is written by the plugin.
|
|
@@ -49,7 +49,7 @@ type Options$2 = {
|
|
|
49
49
|
path: string;
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
-
type ExtendOptions = {
|
|
52
|
+
type ExtendOptions$1 = {
|
|
53
53
|
write(options?: WriteOptions): Promise<void>;
|
|
54
54
|
};
|
|
55
55
|
declare global {
|
|
@@ -59,7 +59,29 @@ declare global {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
declare const fsPlugin: Plugin<Options$
|
|
62
|
+
declare const fsPlugin: Plugin<Options$3, ExtendOptions$1>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region ../fabric-core/src/plugins/fsxPlugin/fsxPlugin.d.ts
|
|
65
|
+
type Options$2 = {
|
|
66
|
+
treeNode?: TreeNode<ComponentNode>;
|
|
67
|
+
/**
|
|
68
|
+
* Set this to true to always see the result of the render in the console(line per render)
|
|
69
|
+
*/
|
|
70
|
+
debug?: boolean;
|
|
71
|
+
};
|
|
72
|
+
type ExtendOptions = {
|
|
73
|
+
render(App: FabricElement<any>): Promise<string>;
|
|
74
|
+
waitUntilExit(): Promise<void>;
|
|
75
|
+
};
|
|
76
|
+
declare global {
|
|
77
|
+
namespace Kubb {
|
|
78
|
+
interface Fabric {
|
|
79
|
+
render(App: FabricElement<any>): Promise<string>;
|
|
80
|
+
waitUntilExit(): Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
declare const fsxPlugin: Plugin<Options$2, ExtendOptions>;
|
|
63
85
|
//#endregion
|
|
64
86
|
//#region ../fabric-core/src/plugins/graphPlugin.d.ts
|
|
65
87
|
type Options$1 = {
|
|
@@ -101,4 +123,4 @@ type Options = {
|
|
|
101
123
|
};
|
|
102
124
|
declare const loggerPlugin: Plugin<Options, {}>;
|
|
103
125
|
//#endregion
|
|
104
|
-
export { barrelPlugin, definePlugin, fsPlugin, graphPlugin, loggerPlugin, reactPlugin };
|
|
126
|
+
export { barrelPlugin, definePlugin, fsPlugin, fsxPlugin, graphPlugin, loggerPlugin, reactPlugin };
|
package/dist/plugins.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __name, t as __commonJSMin } from "./chunk-DkQCb-7t.js";
|
|
2
2
|
import { t as require_react } from "./react-CDrFaZVO.js";
|
|
3
3
|
import { n as jsx } from "./jsx-runtime-CT8FKS42.js";
|
|
4
|
-
import { NodeTreeContext, RootContext, TreeNode, provide } from "@kubb/fabric-core";
|
|
4
|
+
import { NodeTreeContext, RootContext, TreeNode, provide, renderIndent } from "@kubb/fabric-core";
|
|
5
5
|
import { onExit } from "signal-exit";
|
|
6
6
|
import { definePlugin } from "@kubb/fabric-core/plugins";
|
|
7
7
|
import process$1 from "node:process";
|
|
@@ -17314,7 +17314,9 @@ const nodeNames = new Set([
|
|
|
17314
17314
|
"kubb-text",
|
|
17315
17315
|
"kubb-root",
|
|
17316
17316
|
"kubb-app",
|
|
17317
|
-
"br"
|
|
17317
|
+
"br",
|
|
17318
|
+
"indent",
|
|
17319
|
+
"dedent"
|
|
17318
17320
|
]);
|
|
17319
17321
|
|
|
17320
17322
|
//#endregion
|
|
@@ -17575,9 +17577,14 @@ function squashImportNodes(node) {
|
|
|
17575
17577
|
|
|
17576
17578
|
//#endregion
|
|
17577
17579
|
//#region src/utils/squashTextNodes.ts
|
|
17578
|
-
function squashTextNodes(node
|
|
17580
|
+
function squashTextNodes(node, renderContext = {
|
|
17581
|
+
indentLevel: 0,
|
|
17582
|
+
indentSize: 2,
|
|
17583
|
+
currentLineLength: 0,
|
|
17584
|
+
shouldBreak: false
|
|
17585
|
+
}) {
|
|
17579
17586
|
let text = "";
|
|
17580
|
-
const walk = (current) => {
|
|
17587
|
+
const walk = (current, context) => {
|
|
17581
17588
|
let content = "";
|
|
17582
17589
|
for (const child of current.childNodes) {
|
|
17583
17590
|
if (!child) continue;
|
|
@@ -17603,25 +17610,36 @@ function squashTextNodes(node) {
|
|
|
17603
17610
|
default: return text$1;
|
|
17604
17611
|
}
|
|
17605
17612
|
};
|
|
17606
|
-
if (child.nodeName === "#text") nodeText = child.nodeValue;
|
|
17613
|
+
if (child.nodeName === "#text") nodeText = renderIndent(child.nodeValue, context);
|
|
17607
17614
|
else {
|
|
17608
|
-
if (child.nodeName === "kubb-text" || child.nodeName === "kubb-file" || child.nodeName === "kubb-source") nodeText = walk(child);
|
|
17615
|
+
if (child.nodeName === "kubb-text" || child.nodeName === "kubb-file" || child.nodeName === "kubb-source") nodeText = walk(child, context);
|
|
17609
17616
|
nodeText = getPrintText(nodeText);
|
|
17610
|
-
if (child.nodeName === "br")
|
|
17617
|
+
if (child.nodeName === "br") {
|
|
17618
|
+
nodeText = "\n";
|
|
17619
|
+
context.currentLineLength = 0;
|
|
17620
|
+
}
|
|
17621
|
+
if (child.nodeName === "indent") {
|
|
17622
|
+
context.indentLevel++;
|
|
17623
|
+
nodeText = "";
|
|
17624
|
+
}
|
|
17625
|
+
if (child.nodeName === "dedent") {
|
|
17626
|
+
context.indentLevel = Math.max(0, context.indentLevel - 1);
|
|
17627
|
+
nodeText = "";
|
|
17628
|
+
}
|
|
17611
17629
|
if (!nodeNames.has(child.nodeName)) {
|
|
17612
17630
|
const attributes = child.attributes;
|
|
17613
17631
|
let attrString = "";
|
|
17614
17632
|
const hasAttributes = attributes.size > 0;
|
|
17615
17633
|
for (const [key, value] of attributes) attrString += typeof value === "string" ? ` ${key}="${value}"` : ` ${key}={${String(value)}}`;
|
|
17616
|
-
if (hasAttributes) nodeText = `<${child.nodeName}${attrString}>${walk(child)}</${child.nodeName}>`;
|
|
17617
|
-
else nodeText = `<${child.nodeName}>${walk(child)}</${child.nodeName}>`;
|
|
17634
|
+
if (hasAttributes) nodeText = `<${child.nodeName}${attrString}>${walk(child, context)}</${child.nodeName}>`;
|
|
17635
|
+
else nodeText = `<${child.nodeName}>${walk(child, context)}</${child.nodeName}>`;
|
|
17618
17636
|
}
|
|
17619
17637
|
}
|
|
17620
17638
|
content += nodeText;
|
|
17621
17639
|
}
|
|
17622
17640
|
return content;
|
|
17623
17641
|
};
|
|
17624
|
-
text = walk(node);
|
|
17642
|
+
text = walk(node, renderContext);
|
|
17625
17643
|
return text;
|
|
17626
17644
|
}
|
|
17627
17645
|
|
|
@@ -17791,14 +17809,13 @@ var Runtime = class {
|
|
|
17791
17809
|
return _classPrivateFieldGet2(_options, this).fileManager;
|
|
17792
17810
|
}
|
|
17793
17811
|
onError(error) {
|
|
17794
|
-
if (process$1.env.NODE_ENV === "test") console.warn(error);
|
|
17795
17812
|
_classPrivateFieldSet2(_renderError, this, error);
|
|
17796
17813
|
}
|
|
17797
17814
|
onExit(error) {
|
|
17798
17815
|
this.unmount(error);
|
|
17799
17816
|
}
|
|
17800
17817
|
async render(node) {
|
|
17801
|
-
const treeNode = new TreeNode({
|
|
17818
|
+
const treeNode = _classPrivateFieldGet2(_options, this).treeNode || new TreeNode({
|
|
17802
17819
|
type: "Root",
|
|
17803
17820
|
props: {}
|
|
17804
17821
|
});
|
|
@@ -17823,7 +17840,7 @@ var Runtime = class {
|
|
|
17823
17840
|
}
|
|
17824
17841
|
}
|
|
17825
17842
|
async renderToString(node) {
|
|
17826
|
-
const treeNode = new TreeNode({
|
|
17843
|
+
const treeNode = _classPrivateFieldGet2(_options, this).treeNode || new TreeNode({
|
|
17827
17844
|
type: "Root",
|
|
17828
17845
|
props: {}
|
|
17829
17846
|
});
|
|
@@ -17893,11 +17910,11 @@ const reactPlugin = definePlugin({
|
|
|
17893
17910
|
return {
|
|
17894
17911
|
async render(App) {
|
|
17895
17912
|
await ctx.emit("lifecycle:start");
|
|
17896
|
-
await runtime.render(
|
|
17913
|
+
await runtime.render(App);
|
|
17897
17914
|
},
|
|
17898
17915
|
async renderToString(App) {
|
|
17899
17916
|
await ctx.emit("lifecycle:start");
|
|
17900
|
-
return runtime.renderToString(
|
|
17917
|
+
return runtime.renderToString(App);
|
|
17901
17918
|
},
|
|
17902
17919
|
async waitUntilExit() {
|
|
17903
17920
|
await runtime.waitUntilExit();
|