@kubb/react-fabric 0.2.3 → 0.2.4
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/{Fabric-PGwn47Lb.d.cts → Fabric-BF1akKIl.d.cts} +2 -2
- package/dist/{Fabric-CoGYXq1o.d.ts → Fabric-E6DCwBtT.d.ts} +2 -2
- package/dist/{KubbFile-bFdmEsQz.d.ts → KubbFile-D4gyyfL-.d.ts} +1 -1
- package/dist/{KubbFile-DHCtBOpy.d.cts → KubbFile-FGXV713i.d.cts} +1 -1
- package/dist/{chunk-9mlisOrp.js → chunk-BEV-X5tz.js} +4 -5
- package/dist/{chunk-BaqVhFee.cjs → chunk-CUT6urMc.cjs} +0 -16
- package/dist/{devtools-D7cmED8s.js → devtools-Cb1pMQYm.js} +2 -3
- package/dist/{devtools-D7cmED8s.js.map → devtools-Cb1pMQYm.js.map} +1 -1
- package/dist/{devtools-CYVZyenT.cjs → devtools-D4p2T_2t.cjs} +3 -3
- package/dist/{devtools-CYVZyenT.cjs.map → devtools-D4p2T_2t.cjs.map} +1 -1
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.js +1 -1
- package/dist/globals-C_mBzXoD.d.ts +26 -0
- package/dist/globals-DHvLS0j3.d.cts +26 -0
- package/dist/globals.d.cts +3 -3
- package/dist/globals.d.ts +3 -3
- package/dist/index.cjs +107 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -19
- package/dist/index.d.ts +9 -19
- package/dist/index.js +56 -69
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.cjs +15 -7
- package/dist/jsx-dev-runtime.d.cts +5 -0
- package/dist/jsx-dev-runtime.d.ts +5 -0
- package/dist/jsx-dev-runtime.js +2 -4
- package/dist/jsx-namespace-Cu6WTmTt.d.cts +27 -0
- package/dist/jsx-namespace-ghArQSma.d.ts +27 -0
- package/dist/jsx-runtime.cjs +21 -7
- package/dist/jsx-runtime.d.cts +5 -14
- package/dist/jsx-runtime.d.ts +5 -14
- package/dist/jsx-runtime.js +2 -4
- package/dist/parsers.d.cts +2 -2
- package/dist/parsers.d.ts +2 -2
- package/dist/plugins-9oisj5ko.cjs +640 -0
- package/dist/plugins-9oisj5ko.cjs.map +1 -0
- package/dist/plugins-DYBs1Uhp.js +590 -0
- package/dist/plugins-DYBs1Uhp.js.map +1 -0
- package/dist/plugins.cjs +1 -2
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +1 -2
- package/dist/{reactPlugin-CCty1XGl.d.ts → reactPlugin-B3xiMbv8.d.ts} +2 -2
- package/dist/{reactPlugin-SuzV8fwK.d.cts → reactPlugin-DpMLHD7t.d.cts} +2 -2
- package/dist/{types-DoYRYV1C.d.cts → types-C9HPr_ft.d.cts} +21 -3
- package/dist/{types-BnXxcIyv.d.ts → types-P2Lm1k_W.d.ts} +21 -3
- package/dist/types.d.cts +3 -2
- package/dist/types.d.ts +3 -2
- package/package.json +7 -4
- package/src/globals.ts +17 -43
- package/src/index.ts +1 -10
- package/src/jsx-dev-runtime.ts +3 -0
- package/src/jsx-namespace.d.ts +27 -0
- package/src/jsx-runtime.ts +2 -7
- package/src/types.ts +24 -0
- package/dist/backend-BwCrJwGY.cjs +0 -11364
- package/dist/backend-BwCrJwGY.cjs.map +0 -1
- package/dist/backend-U2f8IEJ7.js +0 -11361
- package/dist/backend-U2f8IEJ7.js.map +0 -1
- package/dist/globals-1MFa0Fvg.d.ts +0 -52
- package/dist/globals-C7dPa-nz.d.cts +0 -52
- package/dist/jsx-runtime-8_h1Kd4b.cjs +0 -36
- package/dist/jsx-runtime-8_h1Kd4b.cjs.map +0 -1
- package/dist/jsx-runtime-BJX2mL7C.js +0 -13
- package/dist/jsx-runtime-BJX2mL7C.js.map +0 -1
- package/dist/jsx-runtime-C9xQ4GQD.js +0 -1338
- package/dist/jsx-runtime-C9xQ4GQD.js.map +0 -1
- package/dist/jsx-runtime-CSnwG7o6.cjs +0 -1349
- package/dist/jsx-runtime-CSnwG7o6.cjs.map +0 -1
- package/dist/plugins-BQE1GnQ7.cjs +0 -15554
- package/dist/plugins-BQE1GnQ7.cjs.map +0 -1
- package/dist/plugins-BVFjgEC2.js +0 -15509
- package/dist/plugins-BVFjgEC2.js.map +0 -1
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
react = require_chunk.__toESM(react);
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
react_jsx_runtime = require_chunk.__toESM(react_jsx_runtime);
|
|
6
|
+
let __kubb_fabric_core_plugins = require("@kubb/fabric-core/plugins");
|
|
7
|
+
__kubb_fabric_core_plugins = require_chunk.__toESM(__kubb_fabric_core_plugins);
|
|
8
|
+
let node_process = require("node:process");
|
|
9
|
+
node_process = require_chunk.__toESM(node_process);
|
|
10
|
+
let react_reconciler_constants = require("react-reconciler/constants");
|
|
11
|
+
react_reconciler_constants = require_chunk.__toESM(react_reconciler_constants);
|
|
12
|
+
let signal_exit = require("signal-exit");
|
|
13
|
+
signal_exit = require_chunk.__toESM(signal_exit);
|
|
14
|
+
let react_reconciler = require("react-reconciler");
|
|
15
|
+
react_reconciler = require_chunk.__toESM(react_reconciler);
|
|
16
|
+
let __kubb_fabric_core_parsers_typescript = require("@kubb/fabric-core/parsers/typescript");
|
|
17
|
+
__kubb_fabric_core_parsers_typescript = require_chunk.__toESM(__kubb_fabric_core_parsers_typescript);
|
|
18
|
+
|
|
19
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/typeof.js
|
|
20
|
+
function _typeof(o) {
|
|
21
|
+
"@babel/helpers - typeof";
|
|
22
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
23
|
+
return typeof o$1;
|
|
24
|
+
} : function(o$1) {
|
|
25
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
26
|
+
}, _typeof(o);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/toPrimitive.js
|
|
31
|
+
function toPrimitive(t, r) {
|
|
32
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
33
|
+
var e = t[Symbol.toPrimitive];
|
|
34
|
+
if (void 0 !== e) {
|
|
35
|
+
var i = e.call(t, r || "default");
|
|
36
|
+
if ("object" != _typeof(i)) return i;
|
|
37
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
38
|
+
}
|
|
39
|
+
return ("string" === r ? String : Number)(t);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/toPropertyKey.js
|
|
44
|
+
function toPropertyKey(t) {
|
|
45
|
+
var i = toPrimitive(t, "string");
|
|
46
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/defineProperty.js
|
|
51
|
+
function _defineProperty(e, r, t) {
|
|
52
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
53
|
+
value: t,
|
|
54
|
+
enumerable: !0,
|
|
55
|
+
configurable: !0,
|
|
56
|
+
writable: !0
|
|
57
|
+
}) : e[r] = t, e;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/components/Root.tsx
|
|
62
|
+
var ErrorBoundary = class extends react.Component {
|
|
63
|
+
constructor(..._args) {
|
|
64
|
+
super(..._args);
|
|
65
|
+
_defineProperty(this, "state", { hasError: false });
|
|
66
|
+
}
|
|
67
|
+
static getDerivedStateFromError(_error) {
|
|
68
|
+
return { hasError: true };
|
|
69
|
+
}
|
|
70
|
+
componentDidCatch(error) {
|
|
71
|
+
if (error) this.props.onError(error);
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
if (this.state.hasError) return null;
|
|
75
|
+
return this.props.children;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
_defineProperty(ErrorBoundary, "displayName", "KubbErrorBoundary");
|
|
79
|
+
const RootContext = (0, react.createContext)({ exit: () => {} });
|
|
80
|
+
function Root({ onError, onExit: onExit$1, children }) {
|
|
81
|
+
try {
|
|
82
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorBoundary, {
|
|
83
|
+
onError: (error) => {
|
|
84
|
+
onError(error);
|
|
85
|
+
},
|
|
86
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RootContext.Provider, {
|
|
87
|
+
value: { exit: onExit$1 },
|
|
88
|
+
children
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
} catch (_e) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
Root.Context = RootContext;
|
|
96
|
+
Root.displayName = "KubbRoot";
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/dom.ts
|
|
100
|
+
const createNode = (nodeName) => {
|
|
101
|
+
return {
|
|
102
|
+
nodeName,
|
|
103
|
+
attributes: {},
|
|
104
|
+
childNodes: [],
|
|
105
|
+
parentNode: void 0
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
const appendChildNode = (node, childNode) => {
|
|
109
|
+
if (childNode.parentNode) removeChildNode(childNode.parentNode, childNode);
|
|
110
|
+
if (node.nodeName !== "#text") {
|
|
111
|
+
childNode.parentNode = node;
|
|
112
|
+
node.childNodes.push(childNode);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
|
|
116
|
+
if (newChildNode.parentNode) removeChildNode(newChildNode.parentNode, newChildNode);
|
|
117
|
+
newChildNode.parentNode = node;
|
|
118
|
+
const index = node.childNodes.indexOf(beforeChildNode);
|
|
119
|
+
if (index >= 0) {
|
|
120
|
+
node.childNodes.splice(index, 0, newChildNode);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
node.childNodes.push(newChildNode);
|
|
124
|
+
};
|
|
125
|
+
const removeChildNode = (node, removeNode) => {
|
|
126
|
+
removeNode.parentNode = void 0;
|
|
127
|
+
const index = node.childNodes.indexOf(removeNode);
|
|
128
|
+
if (index >= 0) node.childNodes.splice(index, 1);
|
|
129
|
+
};
|
|
130
|
+
const setAttribute = (node, key, value) => {
|
|
131
|
+
node.attributes[key] = value;
|
|
132
|
+
};
|
|
133
|
+
const createTextNode = (text) => {
|
|
134
|
+
const node = {
|
|
135
|
+
nodeName: "#text",
|
|
136
|
+
nodeValue: text,
|
|
137
|
+
parentNode: void 0
|
|
138
|
+
};
|
|
139
|
+
setTextNodeValue(node, text);
|
|
140
|
+
return node;
|
|
141
|
+
};
|
|
142
|
+
const setTextNodeValue = (node, text) => {
|
|
143
|
+
if (typeof text !== "string") text = String(text);
|
|
144
|
+
node.nodeValue = text;
|
|
145
|
+
};
|
|
146
|
+
const nodeNames = [
|
|
147
|
+
"kubb-export",
|
|
148
|
+
"kubb-file",
|
|
149
|
+
"kubb-source",
|
|
150
|
+
"kubb-import",
|
|
151
|
+
"kubb-text"
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/Renderer.ts
|
|
156
|
+
let currentUpdatePriority = react_reconciler_constants.NoEventPriority;
|
|
157
|
+
/**
|
|
158
|
+
* @link https://www.npmjs.com/package/react-devtools-inline
|
|
159
|
+
* @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md
|
|
160
|
+
* @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples
|
|
161
|
+
* @link https://github.com/vadimdemedes/ink
|
|
162
|
+
* @link https://github.com/pixijs/pixi-react/tree/main/packages
|
|
163
|
+
* @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts
|
|
164
|
+
*/
|
|
165
|
+
const Renderer = (0, react_reconciler.default)({
|
|
166
|
+
getRootHostContext: () => ({
|
|
167
|
+
type: "kubb-root",
|
|
168
|
+
isFile: false,
|
|
169
|
+
isSource: false
|
|
170
|
+
}),
|
|
171
|
+
prepareForCommit: () => {
|
|
172
|
+
return null;
|
|
173
|
+
},
|
|
174
|
+
preparePortalMount: () => null,
|
|
175
|
+
clearContainer: () => false,
|
|
176
|
+
resetAfterCommit(rootNode) {
|
|
177
|
+
if (typeof rootNode.onRender === "function") rootNode.onRender();
|
|
178
|
+
},
|
|
179
|
+
getChildHostContext(parentHostContext, type) {
|
|
180
|
+
return {
|
|
181
|
+
isInsideText: type === "kubb-text",
|
|
182
|
+
isFile: type === "kubb-file" || parentHostContext.isFile,
|
|
183
|
+
isSource: type === "kubb-source" || parentHostContext.isSource,
|
|
184
|
+
type
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
shouldSetTextContent: () => false,
|
|
188
|
+
createInstance(originalType, newProps, _root) {
|
|
189
|
+
const node = createNode(originalType);
|
|
190
|
+
for (const [key, value] of Object.entries(newProps)) {
|
|
191
|
+
if (key === "children") continue;
|
|
192
|
+
setAttribute(node, key, value);
|
|
193
|
+
}
|
|
194
|
+
return node;
|
|
195
|
+
},
|
|
196
|
+
createTextInstance(text, _root, hostContext) {
|
|
197
|
+
if (hostContext.isFile && !hostContext.isSource) throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`);
|
|
198
|
+
return createTextNode(text);
|
|
199
|
+
},
|
|
200
|
+
resetTextContent() {},
|
|
201
|
+
hideTextInstance(node) {
|
|
202
|
+
setTextNodeValue(node, "");
|
|
203
|
+
},
|
|
204
|
+
unhideTextInstance(node, text) {
|
|
205
|
+
setTextNodeValue(node, text);
|
|
206
|
+
},
|
|
207
|
+
getPublicInstance: (instance) => instance,
|
|
208
|
+
appendInitialChild: appendChildNode,
|
|
209
|
+
appendChild: appendChildNode,
|
|
210
|
+
insertBefore: insertBeforeNode,
|
|
211
|
+
finalizeInitialChildren(_node, _type, _props, _rootNode$1) {
|
|
212
|
+
return false;
|
|
213
|
+
},
|
|
214
|
+
supportsMutation: true,
|
|
215
|
+
isPrimaryRenderer: true,
|
|
216
|
+
supportsPersistence: false,
|
|
217
|
+
supportsHydration: false,
|
|
218
|
+
scheduleTimeout: setTimeout,
|
|
219
|
+
cancelTimeout: clearTimeout,
|
|
220
|
+
noTimeout: -1,
|
|
221
|
+
beforeActiveInstanceBlur() {},
|
|
222
|
+
afterActiveInstanceBlur() {},
|
|
223
|
+
detachDeletedInstance() {},
|
|
224
|
+
getInstanceFromNode: () => null,
|
|
225
|
+
prepareScopeUpdate() {},
|
|
226
|
+
getInstanceFromScope: () => null,
|
|
227
|
+
appendChildToContainer: appendChildNode,
|
|
228
|
+
insertInContainerBefore: insertBeforeNode,
|
|
229
|
+
removeChildFromContainer(node, removeNode) {
|
|
230
|
+
removeChildNode(node, removeNode);
|
|
231
|
+
},
|
|
232
|
+
commitMount() {},
|
|
233
|
+
commitUpdate(node, _payload, _type, _oldProps, newProps) {
|
|
234
|
+
const { props } = newProps;
|
|
235
|
+
if (props) for (const [key, value] of Object.entries(props)) setAttribute(node, key, value);
|
|
236
|
+
},
|
|
237
|
+
commitTextUpdate(node, _oldText, newText) {
|
|
238
|
+
setTextNodeValue(node, newText);
|
|
239
|
+
},
|
|
240
|
+
removeChild(node, removeNode) {
|
|
241
|
+
removeChildNode(node, removeNode);
|
|
242
|
+
},
|
|
243
|
+
setCurrentUpdatePriority: (newPriority) => {
|
|
244
|
+
currentUpdatePriority = newPriority;
|
|
245
|
+
},
|
|
246
|
+
getCurrentUpdatePriority: () => currentUpdatePriority,
|
|
247
|
+
resolveUpdatePriority() {
|
|
248
|
+
if (currentUpdatePriority !== react_reconciler_constants.NoEventPriority) return currentUpdatePriority;
|
|
249
|
+
return react_reconciler_constants.DefaultEventPriority;
|
|
250
|
+
},
|
|
251
|
+
maySuspendCommit() {
|
|
252
|
+
return false;
|
|
253
|
+
},
|
|
254
|
+
NotPendingTransition: void 0,
|
|
255
|
+
HostTransitionContext: (0, react.createContext)(null),
|
|
256
|
+
resetFormInstance() {},
|
|
257
|
+
requestPostPaintCallback() {},
|
|
258
|
+
shouldAttemptEagerTransition() {
|
|
259
|
+
return false;
|
|
260
|
+
},
|
|
261
|
+
trackSchedulerEvent() {},
|
|
262
|
+
resolveEventType() {
|
|
263
|
+
return null;
|
|
264
|
+
},
|
|
265
|
+
resolveEventTimeStamp() {
|
|
266
|
+
return -1.1;
|
|
267
|
+
},
|
|
268
|
+
preloadInstance() {
|
|
269
|
+
return true;
|
|
270
|
+
},
|
|
271
|
+
startSuspendingCommit() {},
|
|
272
|
+
suspendInstance() {},
|
|
273
|
+
waitForCommitToBeReady() {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/utils/squashTextNodes.ts
|
|
280
|
+
function squashTextNodes(node) {
|
|
281
|
+
let text = "";
|
|
282
|
+
for (const childNode of node.childNodes) {
|
|
283
|
+
if (!childNode) continue;
|
|
284
|
+
let nodeText = "";
|
|
285
|
+
const getPrintText = (text$1) => {
|
|
286
|
+
if (childNode.nodeName === "kubb-import") {
|
|
287
|
+
const attributes = childNode.attributes;
|
|
288
|
+
return (0, __kubb_fabric_core_parsers_typescript.print)([(0, __kubb_fabric_core_parsers_typescript.createImport)({
|
|
289
|
+
name: attributes.name,
|
|
290
|
+
path: attributes.path,
|
|
291
|
+
root: attributes.root,
|
|
292
|
+
isTypeOnly: attributes.isTypeOnly
|
|
293
|
+
})]);
|
|
294
|
+
}
|
|
295
|
+
if (childNode.nodeName === "kubb-export") {
|
|
296
|
+
const attributes = childNode.attributes;
|
|
297
|
+
if (attributes.path) return (0, __kubb_fabric_core_parsers_typescript.print)([(0, __kubb_fabric_core_parsers_typescript.createExport)({
|
|
298
|
+
name: attributes.name,
|
|
299
|
+
path: attributes.path,
|
|
300
|
+
isTypeOnly: attributes.isTypeOnly,
|
|
301
|
+
asAlias: attributes.asAlias
|
|
302
|
+
})]);
|
|
303
|
+
}
|
|
304
|
+
if (childNode.nodeName === "kubb-source") return text$1;
|
|
305
|
+
return text$1;
|
|
306
|
+
};
|
|
307
|
+
if (childNode.nodeName === "#text") nodeText = childNode.nodeValue;
|
|
308
|
+
else {
|
|
309
|
+
if ([
|
|
310
|
+
"kubb-text",
|
|
311
|
+
"kubb-file",
|
|
312
|
+
"kubb-source"
|
|
313
|
+
].includes(childNode.nodeName)) nodeText = squashTextNodes(childNode);
|
|
314
|
+
nodeText = getPrintText(nodeText);
|
|
315
|
+
if (childNode.nodeName === "br") nodeText = "\n";
|
|
316
|
+
if (![...nodeNames, "br"].includes(childNode.nodeName)) {
|
|
317
|
+
const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {
|
|
318
|
+
if (typeof value === "string") return `${acc} ${key}="${value}"`;
|
|
319
|
+
return `${acc} ${key}={${value}}`;
|
|
320
|
+
}, "");
|
|
321
|
+
nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
text += nodeText;
|
|
325
|
+
}
|
|
326
|
+
return text;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
//#endregion
|
|
330
|
+
//#region src/utils/squashExportNodes.ts
|
|
331
|
+
function squashExportNodes(node) {
|
|
332
|
+
let exports$1 = /* @__PURE__ */ new Set();
|
|
333
|
+
node.childNodes.filter(Boolean).forEach((childNode) => {
|
|
334
|
+
if (childNode.nodeName !== "#text" && nodeNames.includes(childNode.nodeName)) exports$1 = new Set([...exports$1, ...squashExportNodes(childNode)]);
|
|
335
|
+
if (childNode.nodeName === "kubb-export") {
|
|
336
|
+
const attributes = childNode.attributes;
|
|
337
|
+
exports$1.add(attributes);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
return exports$1;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/utils/squashImportNodes.ts
|
|
345
|
+
function squashImportNodes(node) {
|
|
346
|
+
let imports = /* @__PURE__ */ new Set();
|
|
347
|
+
node.childNodes.filter(Boolean).forEach((childNode) => {
|
|
348
|
+
if (childNode.nodeName !== "#text" && nodeNames.includes(childNode.nodeName)) imports = new Set([...imports, ...squashImportNodes(childNode)]);
|
|
349
|
+
if (childNode.nodeName === "kubb-import") {
|
|
350
|
+
const attributes = childNode.attributes;
|
|
351
|
+
imports.add(attributes);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
return imports;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/utils/squashSourceNodes.ts
|
|
359
|
+
function squashSourceNodes(node, ignores) {
|
|
360
|
+
let sources = /* @__PURE__ */ new Set();
|
|
361
|
+
for (const childNode of node.childNodes) {
|
|
362
|
+
if (!childNode) continue;
|
|
363
|
+
if (childNode.nodeName !== "#text" && ignores.includes(childNode.nodeName)) continue;
|
|
364
|
+
if (childNode.nodeName === "kubb-source") {
|
|
365
|
+
const attributes = childNode.attributes;
|
|
366
|
+
const value = squashTextNodes(childNode);
|
|
367
|
+
sources.add({
|
|
368
|
+
...attributes,
|
|
369
|
+
value: value.trim().replace(/^\s+|\s+$/g, "")
|
|
370
|
+
});
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (childNode.nodeName !== "#text" && nodeNames.includes(childNode.nodeName)) sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)]);
|
|
374
|
+
}
|
|
375
|
+
return sources;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
//#endregion
|
|
379
|
+
//#region src/utils/processFiles.ts
|
|
380
|
+
function processFiles(node, fileManager) {
|
|
381
|
+
for (let index = 0; index < node.childNodes.length; index++) {
|
|
382
|
+
const childNode = node.childNodes[index];
|
|
383
|
+
if (!childNode) continue;
|
|
384
|
+
if (childNode.nodeName !== "#text" && childNode.nodeName !== "kubb-file" && nodeNames.includes(childNode.nodeName)) processFiles(childNode, fileManager);
|
|
385
|
+
if (childNode.nodeName === "kubb-file") {
|
|
386
|
+
const attributes = childNode.attributes;
|
|
387
|
+
if (attributes.baseName && attributes.path) {
|
|
388
|
+
const sources = squashSourceNodes(childNode, ["kubb-export", "kubb-import"]);
|
|
389
|
+
const file = {
|
|
390
|
+
baseName: attributes.baseName,
|
|
391
|
+
path: attributes.path,
|
|
392
|
+
sources: [...sources],
|
|
393
|
+
exports: [...squashExportNodes(childNode)],
|
|
394
|
+
imports: [...squashImportNodes(childNode)],
|
|
395
|
+
meta: attributes.meta || {},
|
|
396
|
+
footer: attributes.footer,
|
|
397
|
+
banner: attributes.banner
|
|
398
|
+
};
|
|
399
|
+
fileManager.add(file);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/checkPrivateRedeclaration.js
|
|
407
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
408
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateMethodInitSpec.js
|
|
413
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
414
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateFieldInitSpec.js
|
|
419
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
420
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
//#endregion
|
|
424
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/assertClassBrand.js
|
|
425
|
+
function _assertClassBrand(e, t, n) {
|
|
426
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
427
|
+
throw new TypeError("Private element is not present on this object");
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateFieldGet2.js
|
|
432
|
+
function _classPrivateFieldGet2(s, a) {
|
|
433
|
+
return s.get(_assertClassBrand(s, a));
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateFieldSet2.js
|
|
438
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
439
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/Runtime.tsx
|
|
444
|
+
var _options = /* @__PURE__ */ new WeakMap();
|
|
445
|
+
var _isUnmounted = /* @__PURE__ */ new WeakMap();
|
|
446
|
+
var _container = /* @__PURE__ */ new WeakMap();
|
|
447
|
+
var _rootNode = /* @__PURE__ */ new WeakMap();
|
|
448
|
+
var _Runtime_brand = /* @__PURE__ */ new WeakSet();
|
|
449
|
+
var Runtime = class {
|
|
450
|
+
constructor(options) {
|
|
451
|
+
_classPrivateMethodInitSpec(this, _Runtime_brand);
|
|
452
|
+
_classPrivateFieldInitSpec(this, _options, void 0);
|
|
453
|
+
_classPrivateFieldInitSpec(this, _isUnmounted, void 0);
|
|
454
|
+
_defineProperty(this, "exitPromise", void 0);
|
|
455
|
+
_classPrivateFieldInitSpec(this, _container, void 0);
|
|
456
|
+
_classPrivateFieldInitSpec(this, _rootNode, void 0);
|
|
457
|
+
_defineProperty(this, "resolveExitPromise", () => {});
|
|
458
|
+
_defineProperty(this, "rejectExitPromise", () => {});
|
|
459
|
+
_defineProperty(this, "unsubscribeExit", () => {});
|
|
460
|
+
_defineProperty(this, "onRender", async () => {
|
|
461
|
+
var _classPrivateFieldGet2$1, _classPrivateFieldGet3, _classPrivateFieldGet4, _classPrivateFieldGet5;
|
|
462
|
+
if (_classPrivateFieldGet2(_isUnmounted, this)) return;
|
|
463
|
+
this.fileManager.clear();
|
|
464
|
+
processFiles(_classPrivateFieldGet2(_rootNode, this), this.fileManager);
|
|
465
|
+
if (!((_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.debug) && !((_classPrivateFieldGet3 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.stdout)) return;
|
|
466
|
+
const output = await _assertClassBrand(_Runtime_brand, this, _getOutput).call(this, _classPrivateFieldGet2(_rootNode, this));
|
|
467
|
+
if ((_classPrivateFieldGet4 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.debug) {
|
|
468
|
+
console.log("Rendering: \n");
|
|
469
|
+
console.log(output);
|
|
470
|
+
}
|
|
471
|
+
if (((_classPrivateFieldGet5 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.stdout) && node_process.default.env.NODE_ENV !== "test") {
|
|
472
|
+
_classPrivateFieldGet2(_options, this).stdout.clearLine(0);
|
|
473
|
+
_classPrivateFieldGet2(_options, this).stdout.cursorTo(0);
|
|
474
|
+
_classPrivateFieldGet2(_options, this).stdout.write(output);
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
_classPrivateFieldSet2(_options, this, options);
|
|
478
|
+
_classPrivateFieldSet2(_rootNode, this, createNode("kubb-root"));
|
|
479
|
+
_classPrivateFieldGet2(_rootNode, this).onRender = this.onRender;
|
|
480
|
+
_classPrivateFieldGet2(_rootNode, this).onImmediateRender = this.onRender;
|
|
481
|
+
_classPrivateFieldSet2(_isUnmounted, this, false);
|
|
482
|
+
this.unmount.bind(this);
|
|
483
|
+
const originalError = console.error;
|
|
484
|
+
console.error = (data) => {
|
|
485
|
+
const message = typeof data === "string" ? data : data === null || data === void 0 ? void 0 : data.message;
|
|
486
|
+
if (message === null || message === void 0 ? void 0 : message.match(/Encountered two children with the same key/gi)) return;
|
|
487
|
+
if (message === null || message === void 0 ? void 0 : message.match(/React will try to recreat/gi)) return;
|
|
488
|
+
if (message === null || message === void 0 ? void 0 : message.match(/Each child in a list should have a unique/gi)) return;
|
|
489
|
+
if (message === null || message === void 0 ? void 0 : message.match(/The above error occurred in the <KubbErrorBoundary/gi)) return;
|
|
490
|
+
if (message === null || message === void 0 ? void 0 : message.match(/A React Element from an older version of React was render/gi)) return;
|
|
491
|
+
originalError(data);
|
|
492
|
+
};
|
|
493
|
+
const logRecoverableError = typeof reportError === "function" ? reportError : console.error;
|
|
494
|
+
const rootTag = react_reconciler_constants.ConcurrentRoot;
|
|
495
|
+
const hydrationCallbacks = null;
|
|
496
|
+
const isStrictMode = false;
|
|
497
|
+
const concurrentUpdatesByDefaultOverride = false;
|
|
498
|
+
const identifierPrefix = "id";
|
|
499
|
+
const onUncaughtError = logRecoverableError;
|
|
500
|
+
const onCaughtError = logRecoverableError;
|
|
501
|
+
const onRecoverableError = logRecoverableError;
|
|
502
|
+
_classPrivateFieldSet2(_container, this, Renderer.createContainer(_classPrivateFieldGet2(_rootNode, this), rootTag, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, null));
|
|
503
|
+
this.unsubscribeExit = (0, signal_exit.onExit)((code) => {
|
|
504
|
+
this.unmount(code);
|
|
505
|
+
}, { alwaysLast: false }).bind(this);
|
|
506
|
+
Renderer.injectIntoDevTools({
|
|
507
|
+
bundleType: 1,
|
|
508
|
+
version: "19.1.0",
|
|
509
|
+
rendererPackageName: "kubb"
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
get fileManager() {
|
|
513
|
+
return _classPrivateFieldGet2(_options, this).fileManager;
|
|
514
|
+
}
|
|
515
|
+
onError(error) {
|
|
516
|
+
if (node_process.default.env.NODE_ENV === "test") console.warn(error);
|
|
517
|
+
throw error;
|
|
518
|
+
}
|
|
519
|
+
onExit(error) {
|
|
520
|
+
this.unmount(error);
|
|
521
|
+
}
|
|
522
|
+
render(node) {
|
|
523
|
+
const element = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Root, {
|
|
524
|
+
onExit: this.onExit.bind(this),
|
|
525
|
+
onError: this.onError.bind(this),
|
|
526
|
+
children: node
|
|
527
|
+
});
|
|
528
|
+
Renderer.updateContainerSync(element, _classPrivateFieldGet2(_container, this), null, null);
|
|
529
|
+
Renderer.flushSyncWork();
|
|
530
|
+
}
|
|
531
|
+
async renderToString(node) {
|
|
532
|
+
const element = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Root, {
|
|
533
|
+
onExit: this.onExit.bind(this),
|
|
534
|
+
onError: this.onError.bind(this),
|
|
535
|
+
children: node
|
|
536
|
+
});
|
|
537
|
+
Renderer.updateContainerSync(element, _classPrivateFieldGet2(_container, this), null, null);
|
|
538
|
+
Renderer.flushSyncWork();
|
|
539
|
+
this.fileManager.clear();
|
|
540
|
+
return _assertClassBrand(_Runtime_brand, this, _getOutput).call(this, _classPrivateFieldGet2(_rootNode, this));
|
|
541
|
+
}
|
|
542
|
+
unmount(error) {
|
|
543
|
+
var _classPrivateFieldGet6;
|
|
544
|
+
if (_classPrivateFieldGet2(_isUnmounted, this)) return;
|
|
545
|
+
if ((_classPrivateFieldGet6 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.debug) console.log("Unmount", error);
|
|
546
|
+
this.onRender();
|
|
547
|
+
this.unsubscribeExit();
|
|
548
|
+
_classPrivateFieldSet2(_isUnmounted, this, true);
|
|
549
|
+
Renderer.updateContainerSync(null, _classPrivateFieldGet2(_container, this), null, null);
|
|
550
|
+
if (error instanceof Error) {
|
|
551
|
+
this.rejectExitPromise(error);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
this.resolveExitPromise();
|
|
555
|
+
}
|
|
556
|
+
async waitUntilExit() {
|
|
557
|
+
if (!this.exitPromise) this.exitPromise = new Promise((resolve, reject) => {
|
|
558
|
+
this.resolveExitPromise = resolve;
|
|
559
|
+
this.rejectExitPromise = reject;
|
|
560
|
+
});
|
|
561
|
+
return this.exitPromise;
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
async function _getOutput(node) {
|
|
565
|
+
const text = squashTextNodes(node);
|
|
566
|
+
const files = this.fileManager.files;
|
|
567
|
+
return files.length ? [...files].flatMap((file) => [...file.sources].map((item) => item.value)).filter(Boolean).join("\n\n") : text;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region src/plugins/reactPlugin.ts
|
|
572
|
+
const reactPlugin = (0, __kubb_fabric_core_plugins.createPlugin)({
|
|
573
|
+
name: "react",
|
|
574
|
+
install() {},
|
|
575
|
+
inject(app, options = {}) {
|
|
576
|
+
const runtime = new Runtime({
|
|
577
|
+
fileManager: app.context.fileManager,
|
|
578
|
+
...options
|
|
579
|
+
});
|
|
580
|
+
return {
|
|
581
|
+
async render(App) {
|
|
582
|
+
runtime.render((0, react.createElement)(App));
|
|
583
|
+
await app.context.events.emit("start");
|
|
584
|
+
},
|
|
585
|
+
async renderToString(App) {
|
|
586
|
+
await app.context.events.emit("start");
|
|
587
|
+
return runtime.renderToString((0, react.createElement)(App));
|
|
588
|
+
},
|
|
589
|
+
async waitUntilExit() {
|
|
590
|
+
await runtime.waitUntilExit();
|
|
591
|
+
await app.context.events.emit("end");
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
//#endregion
|
|
598
|
+
Object.defineProperty(exports, 'Root', {
|
|
599
|
+
enumerable: true,
|
|
600
|
+
get: function () {
|
|
601
|
+
return Root;
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
Object.defineProperty(exports, 'RootContext', {
|
|
605
|
+
enumerable: true,
|
|
606
|
+
get: function () {
|
|
607
|
+
return RootContext;
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
Object.defineProperty(exports, 'Runtime', {
|
|
611
|
+
enumerable: true,
|
|
612
|
+
get: function () {
|
|
613
|
+
return Runtime;
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
Object.defineProperty(exports, '_classPrivateFieldGet2', {
|
|
617
|
+
enumerable: true,
|
|
618
|
+
get: function () {
|
|
619
|
+
return _classPrivateFieldGet2;
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
Object.defineProperty(exports, '_classPrivateFieldInitSpec', {
|
|
623
|
+
enumerable: true,
|
|
624
|
+
get: function () {
|
|
625
|
+
return _classPrivateFieldInitSpec;
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
Object.defineProperty(exports, '_classPrivateFieldSet2', {
|
|
629
|
+
enumerable: true,
|
|
630
|
+
get: function () {
|
|
631
|
+
return _classPrivateFieldSet2;
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
Object.defineProperty(exports, 'reactPlugin', {
|
|
635
|
+
enumerable: true,
|
|
636
|
+
get: function () {
|
|
637
|
+
return reactPlugin;
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
//# sourceMappingURL=plugins-9oisj5ko.cjs.map
|