@kubb/react-fabric 0.0.0-canary-20251020201500 → 0.0.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 +46 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -20
- package/dist/index.d.ts +47 -20
- package/dist/index.js +46 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/ReactTemplate.tsx +5 -4
- package/src/components/Const.tsx +17 -4
- package/src/components/Function.tsx +38 -6
- package/src/components/Root.tsx +9 -5
- package/src/components/Text.tsx +31 -0
- package/src/components/Type.tsx +7 -1
- package/src/createApp.ts +2 -1
- package/src/dom.ts +3 -5
- package/src/hooks/useApp.ts +2 -2
- package/src/index.ts +1 -0
- package/src/utils/throttle.ts +30 -0
package/dist/index.cjs
CHANGED
|
@@ -76,15 +76,21 @@ var ErrorBoundary = class extends import_react.Component {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
_defineProperty(ErrorBoundary, "displayName", "KubbErrorBoundary");
|
|
79
|
-
const RootContext = (0, import_react.createContext)({
|
|
80
|
-
|
|
79
|
+
const RootContext = (0, import_react.createContext)({
|
|
80
|
+
exit: () => {},
|
|
81
|
+
meta: {}
|
|
82
|
+
});
|
|
83
|
+
function Root({ onError, onExit: onExit$1, meta, children }) {
|
|
81
84
|
try {
|
|
82
85
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBoundary, {
|
|
83
86
|
onError: (error) => {
|
|
84
87
|
onError(error);
|
|
85
88
|
},
|
|
86
89
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RootContext.Provider, {
|
|
87
|
-
value: {
|
|
90
|
+
value: {
|
|
91
|
+
meta,
|
|
92
|
+
exit: onExit$1
|
|
93
|
+
},
|
|
88
94
|
children
|
|
89
95
|
})
|
|
90
96
|
});
|
|
@@ -111,6 +117,21 @@ function App({ meta, children }) {
|
|
|
111
117
|
App.Context = AppContext;
|
|
112
118
|
App.displayName = "KubbApp";
|
|
113
119
|
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/components/Text.tsx
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated
|
|
124
|
+
*/
|
|
125
|
+
function Text({ children }) {
|
|
126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kubb-text", { children });
|
|
127
|
+
}
|
|
128
|
+
Text.displayName = "KubbText";
|
|
129
|
+
function Space({}) {
|
|
130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kubb-text", { children: " " });
|
|
131
|
+
}
|
|
132
|
+
Space.displayName = "KubbSpace";
|
|
133
|
+
Text.Space = Space;
|
|
134
|
+
|
|
114
135
|
//#endregion
|
|
115
136
|
//#region src/utils/createJSDoc.ts
|
|
116
137
|
function createJSDoc({ comments }) {
|
|
@@ -124,18 +145,18 @@ function createJSDoc({ comments }) {
|
|
|
124
145
|
function Const({ name, export: canExport, type, JSDoc, asConst, children }) {
|
|
125
146
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
126
147
|
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})] }),
|
|
127
|
-
canExport && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
148
|
+
canExport && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["export", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {})] }),
|
|
128
149
|
"const ",
|
|
129
150
|
name,
|
|
130
|
-
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {}),
|
|
131
152
|
type && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
132
153
|
":",
|
|
133
154
|
type,
|
|
134
|
-
|
|
155
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {})
|
|
135
156
|
] }),
|
|
136
157
|
"= ",
|
|
137
158
|
children,
|
|
138
|
-
asConst && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
159
|
+
asConst && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {}), "as const"] })
|
|
139
160
|
] });
|
|
140
161
|
}
|
|
141
162
|
Const.displayName = "KubbConst";
|
|
@@ -241,9 +262,9 @@ function Indent({ size = 2, children }) {
|
|
|
241
262
|
function Function({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, children }) {
|
|
242
263
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
243
264
|
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})] }),
|
|
244
|
-
canExport && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
245
|
-
isDefault && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
246
|
-
async && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
265
|
+
canExport && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["export", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {})] }),
|
|
266
|
+
isDefault && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["default", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {})] }),
|
|
267
|
+
async && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["async", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {})] }),
|
|
247
268
|
"function ",
|
|
248
269
|
name,
|
|
249
270
|
generics && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
@@ -275,12 +296,13 @@ Function.displayName = "KubbFunction";
|
|
|
275
296
|
function ArrowFunction({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine, children }) {
|
|
276
297
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
277
298
|
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})] }),
|
|
278
|
-
canExport && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
279
|
-
isDefault && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
299
|
+
canExport && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["export", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {})] }),
|
|
300
|
+
isDefault && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["default", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {})] }),
|
|
280
301
|
"const ",
|
|
281
302
|
name,
|
|
282
|
-
" =
|
|
283
|
-
|
|
303
|
+
" =",
|
|
304
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {}),
|
|
305
|
+
async && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["async", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {})] }),
|
|
284
306
|
generics && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
285
307
|
"<",
|
|
286
308
|
Array.isArray(generics) ? generics.join(", ").trim() : generics,
|
|
@@ -323,7 +345,7 @@ function Type({ name, export: canExport, JSDoc, children }) {
|
|
|
323
345
|
if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
|
|
324
346
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
325
347
|
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})] }),
|
|
326
|
-
canExport && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
348
|
+
canExport && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["export", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Space, {})] }),
|
|
327
349
|
"type ",
|
|
328
350
|
name,
|
|
329
351
|
" = ",
|
|
@@ -366,10 +388,8 @@ const createNode = (nodeName) => {
|
|
|
366
388
|
};
|
|
367
389
|
const appendChildNode = (node, childNode) => {
|
|
368
390
|
if (childNode.parentNode) removeChildNode(childNode.parentNode, childNode);
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
node.childNodes.push(childNode);
|
|
372
|
-
}
|
|
391
|
+
childNode.parentNode = node;
|
|
392
|
+
node.childNodes.push(childNode);
|
|
373
393
|
};
|
|
374
394
|
const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
|
|
375
395
|
if (newChildNode.parentNode) removeChildNode(newChildNode.parentNode, newChildNode);
|
|
@@ -15672,8 +15692,9 @@ var ReactTemplate = class {
|
|
|
15672
15692
|
onExit(error) {
|
|
15673
15693
|
this.unmount(error);
|
|
15674
15694
|
}
|
|
15675
|
-
render(node) {
|
|
15695
|
+
render(node, { meta = {} } = { meta: {} }) {
|
|
15676
15696
|
const element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Root, {
|
|
15697
|
+
meta,
|
|
15677
15698
|
onExit: this.onExit.bind(this),
|
|
15678
15699
|
onError: this.onError.bind(this),
|
|
15679
15700
|
children: node
|
|
@@ -15681,8 +15702,9 @@ var ReactTemplate = class {
|
|
|
15681
15702
|
KubbRenderer.updateContainerSync(element, _classPrivateFieldGet2(_container, this), null, null);
|
|
15682
15703
|
KubbRenderer.flushSyncWork();
|
|
15683
15704
|
}
|
|
15684
|
-
async renderToString(node) {
|
|
15705
|
+
async renderToString(node, { meta = {} } = { meta: {} }) {
|
|
15685
15706
|
const element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Root, {
|
|
15707
|
+
meta,
|
|
15686
15708
|
onExit: this.onExit.bind(this),
|
|
15687
15709
|
onError: this.onError.bind(this),
|
|
15688
15710
|
children: node
|
|
@@ -15730,10 +15752,10 @@ const createApp = (0, __kubb_fabric_core.defineApp)((app, context) => {
|
|
|
15730
15752
|
});
|
|
15731
15753
|
return {
|
|
15732
15754
|
render() {
|
|
15733
|
-
template.render(
|
|
15755
|
+
template.render(createElement(app));
|
|
15734
15756
|
},
|
|
15735
15757
|
async renderToString() {
|
|
15736
|
-
return template.renderToString(
|
|
15758
|
+
return template.renderToString(createElement(app));
|
|
15737
15759
|
},
|
|
15738
15760
|
waitUntilExit() {
|
|
15739
15761
|
return template.waitUntilExit();
|
|
@@ -15907,6 +15929,7 @@ exports.File = File;
|
|
|
15907
15929
|
exports.Function = Function;
|
|
15908
15930
|
exports.FunctionParams = FunctionParams;
|
|
15909
15931
|
exports.Indent = Indent;
|
|
15932
|
+
exports.Text = Text;
|
|
15910
15933
|
exports.Type = Type;
|
|
15911
15934
|
exports.createApp = createApp;
|
|
15912
15935
|
exports.createContext = createContext;
|