@kubb/plugin-zod 3.0.0-alpha.9 → 3.0.0-beta.1

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.
Files changed (85) hide show
  1. package/README.md +14 -5
  2. package/dist/chunk-5PR4KKK7.js +235 -0
  3. package/dist/chunk-5PR4KKK7.js.map +1 -0
  4. package/dist/chunk-6MMPQJME.cjs +244 -0
  5. package/dist/chunk-6MMPQJME.cjs.map +1 -0
  6. package/dist/chunk-FLFW72FT.cjs +344 -0
  7. package/dist/chunk-FLFW72FT.cjs.map +1 -0
  8. package/dist/chunk-UONLSRDV.js +337 -0
  9. package/dist/chunk-UONLSRDV.js.map +1 -0
  10. package/dist/components.cjs +11 -10
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +20 -19
  13. package/dist/components.d.ts +20 -19
  14. package/dist/components.js +2 -14
  15. package/dist/components.js.map +1 -1
  16. package/dist/generators.cjs +17 -0
  17. package/dist/generators.cjs.map +1 -0
  18. package/dist/generators.d.cts +10 -0
  19. package/dist/generators.d.ts +10 -0
  20. package/dist/generators.js +4 -0
  21. package/dist/generators.js.map +1 -0
  22. package/dist/index.cjs +12 -8
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +4 -137
  25. package/dist/index.d.ts +4 -137
  26. package/dist/index.js +3 -12
  27. package/dist/index.js.map +1 -1
  28. package/dist/types-ryu2n1NA.d.cts +95 -0
  29. package/dist/types-ryu2n1NA.d.ts +95 -0
  30. package/package.json +19 -21
  31. package/src/components/Operations.tsx +12 -98
  32. package/src/components/Zod.tsx +66 -0
  33. package/src/components/index.ts +1 -2
  34. package/src/generators/__snapshots__/anyof.ts +3 -0
  35. package/src/generators/__snapshots__/createPet.ts +15 -0
  36. package/src/generators/__snapshots__/createPetWithUnknownTypeAny.ts +13 -0
  37. package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +15 -0
  38. package/src/generators/__snapshots__/deletePet.ts +3 -0
  39. package/src/generators/__snapshots__/discriminator.ts +3 -0
  40. package/src/generators/__snapshots__/enumBooleanLiteral.ts +3 -0
  41. package/src/generators/__snapshots__/enumNamesType.ts +3 -0
  42. package/src/generators/__snapshots__/enumNullable.ts +3 -0
  43. package/src/generators/__snapshots__/enumSingleLiteral.ts +3 -0
  44. package/src/generators/__snapshots__/enumVarNamesType.ts +3 -0
  45. package/src/generators/__snapshots__/example.ts +3 -0
  46. package/src/generators/__snapshots__/getPets.ts +18 -0
  47. package/src/generators/__snapshots__/mixedValueTypeConst.ts +6 -0
  48. package/src/generators/__snapshots__/nullableString.ts +3 -0
  49. package/src/generators/__snapshots__/nullableStringUuid.ts +3 -0
  50. package/src/generators/__snapshots__/nullableStringWithAnyOf.ts +3 -0
  51. package/src/generators/__snapshots__/numberValueConst.ts +6 -0
  52. package/src/generators/__snapshots__/oneof.ts +3 -0
  53. package/src/generators/__snapshots__/operations.ts +46 -0
  54. package/src/generators/__snapshots__/optionalPetInfer.ts +5 -0
  55. package/src/generators/__snapshots__/optionalPetTyped.ts +3 -0
  56. package/src/generators/__snapshots__/order.ts +3 -0
  57. package/src/generators/__snapshots__/orderDateTyeString.ts +10 -0
  58. package/src/generators/__snapshots__/orderDateTypeFalse.ts +3 -0
  59. package/src/generators/__snapshots__/orderDateTypeString.ts +3 -0
  60. package/src/generators/__snapshots__/pet.ts +3 -0
  61. package/src/generators/__snapshots__/petArray.ts +6 -0
  62. package/src/generators/__snapshots__/petCoercion.ts +3 -0
  63. package/src/generators/__snapshots__/petTupleObject.ts +6 -0
  64. package/src/generators/__snapshots__/petWithMapper.ts +3 -0
  65. package/src/generators/__snapshots__/pets.ts +3 -0
  66. package/src/generators/__snapshots__/recursive.ts +3 -0
  67. package/src/generators/__snapshots__/showPetById.ts +18 -0
  68. package/src/generators/__snapshots__/stringValueConst.ts +6 -0
  69. package/src/generators/__snapshots__/uuidSchema.ts +3 -0
  70. package/src/generators/index.ts +2 -0
  71. package/src/generators/operationsGenerator.tsx +39 -0
  72. package/src/generators/zodGenerator.tsx +121 -0
  73. package/src/parser/index.ts +24 -8
  74. package/src/plugin.ts +30 -39
  75. package/src/types.ts +42 -88
  76. package/dist/Operations-BG26e_MW.d.cts +0 -47
  77. package/dist/Operations-BG26e_MW.d.ts +0 -47
  78. package/dist/chunk-57AHBVYK.cjs +0 -3502
  79. package/dist/chunk-57AHBVYK.cjs.map +0 -1
  80. package/dist/chunk-CUPQVLRZ.js +0 -3502
  81. package/dist/chunk-CUPQVLRZ.js.map +0 -1
  82. package/src/SchemaGenerator.tsx +0 -22
  83. package/src/components/OperationSchema.tsx +0 -60
  84. package/src/components/Schema.tsx +0 -166
  85. package/src/components/__snapshots__/operations.ts +0 -53
@@ -1,3502 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
-
30
- // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js
31
- var init_esm_shims = __esm({
32
- "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js"() {
33
- "use strict";
34
- }
35
- });
36
-
37
- // ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
38
- var require_react_production_min = __commonJS({
39
- "../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js"(exports) {
40
- "use strict";
41
- init_esm_shims();
42
- var l = Symbol.for("react.element");
43
- var n = Symbol.for("react.portal");
44
- var p = Symbol.for("react.fragment");
45
- var q = Symbol.for("react.strict_mode");
46
- var r = Symbol.for("react.profiler");
47
- var t = Symbol.for("react.provider");
48
- var u = Symbol.for("react.context");
49
- var v = Symbol.for("react.forward_ref");
50
- var w = Symbol.for("react.suspense");
51
- var x = Symbol.for("react.memo");
52
- var y = Symbol.for("react.lazy");
53
- var z = Symbol.iterator;
54
- function A(a) {
55
- if (null === a || "object" !== typeof a) return null;
56
- a = z && a[z] || a["@@iterator"];
57
- return "function" === typeof a ? a : null;
58
- }
59
- var B = { isMounted: function() {
60
- return false;
61
- }, enqueueForceUpdate: function() {
62
- }, enqueueReplaceState: function() {
63
- }, enqueueSetState: function() {
64
- } };
65
- var C = Object.assign;
66
- var D = {};
67
- function E(a, b, e) {
68
- this.props = a;
69
- this.context = b;
70
- this.refs = D;
71
- this.updater = e || B;
72
- }
73
- E.prototype.isReactComponent = {};
74
- E.prototype.setState = function(a, b) {
75
- if ("object" !== typeof a && "function" !== typeof a && null != a) throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
76
- this.updater.enqueueSetState(this, a, b, "setState");
77
- };
78
- E.prototype.forceUpdate = function(a) {
79
- this.updater.enqueueForceUpdate(this, a, "forceUpdate");
80
- };
81
- function F() {
82
- }
83
- F.prototype = E.prototype;
84
- function G(a, b, e) {
85
- this.props = a;
86
- this.context = b;
87
- this.refs = D;
88
- this.updater = e || B;
89
- }
90
- var H = G.prototype = new F();
91
- H.constructor = G;
92
- C(H, E.prototype);
93
- H.isPureReactComponent = true;
94
- var I = Array.isArray;
95
- var J = Object.prototype.hasOwnProperty;
96
- var K = { current: null };
97
- var L = { key: true, ref: true, __self: true, __source: true };
98
- function M(a, b, e) {
99
- var d, c = {}, k = null, h = null;
100
- if (null != b) for (d in void 0 !== b.ref && (h = b.ref), void 0 !== b.key && (k = "" + b.key), b) J.call(b, d) && !L.hasOwnProperty(d) && (c[d] = b[d]);
101
- var g = arguments.length - 2;
102
- if (1 === g) c.children = e;
103
- else if (1 < g) {
104
- for (var f = Array(g), m = 0; m < g; m++) f[m] = arguments[m + 2];
105
- c.children = f;
106
- }
107
- if (a && a.defaultProps) for (d in g = a.defaultProps, g) void 0 === c[d] && (c[d] = g[d]);
108
- return { $$typeof: l, type: a, key: k, ref: h, props: c, _owner: K.current };
109
- }
110
- function N(a, b) {
111
- return { $$typeof: l, type: a.type, key: b, ref: a.ref, props: a.props, _owner: a._owner };
112
- }
113
- function O(a) {
114
- return "object" === typeof a && null !== a && a.$$typeof === l;
115
- }
116
- function escape(a) {
117
- var b = { "=": "=0", ":": "=2" };
118
- return "$" + a.replace(/[=:]/g, function(a2) {
119
- return b[a2];
120
- });
121
- }
122
- var P = /\/+/g;
123
- function Q(a, b) {
124
- return "object" === typeof a && null !== a && null != a.key ? escape("" + a.key) : b.toString(36);
125
- }
126
- function R(a, b, e, d, c) {
127
- var k = typeof a;
128
- if ("undefined" === k || "boolean" === k) a = null;
129
- var h = false;
130
- if (null === a) h = true;
131
- else switch (k) {
132
- case "string":
133
- case "number":
134
- h = true;
135
- break;
136
- case "object":
137
- switch (a.$$typeof) {
138
- case l:
139
- case n:
140
- h = true;
141
- }
142
- }
143
- if (h) return h = a, c = c(h), a = "" === d ? "." + Q(h, 0) : d, I(c) ? (e = "", null != a && (e = a.replace(P, "$&/") + "/"), R(c, b, e, "", function(a2) {
144
- return a2;
145
- })) : null != c && (O(c) && (c = N(c, e + (!c.key || h && h.key === c.key ? "" : ("" + c.key).replace(P, "$&/") + "/") + a)), b.push(c)), 1;
146
- h = 0;
147
- d = "" === d ? "." : d + ":";
148
- if (I(a)) for (var g = 0; g < a.length; g++) {
149
- k = a[g];
150
- var f = d + Q(k, g);
151
- h += R(k, b, e, f, c);
152
- }
153
- else if (f = A(a), "function" === typeof f) for (a = f.call(a), g = 0; !(k = a.next()).done; ) k = k.value, f = d + Q(k, g++), h += R(k, b, e, f, c);
154
- else if ("object" === k) throw b = String(a), Error("Objects are not valid as a React child (found: " + ("[object Object]" === b ? "object with keys {" + Object.keys(a).join(", ") + "}" : b) + "). If you meant to render a collection of children, use an array instead.");
155
- return h;
156
- }
157
- function S(a, b, e) {
158
- if (null == a) return a;
159
- var d = [], c = 0;
160
- R(a, d, "", "", function(a2) {
161
- return b.call(e, a2, c++);
162
- });
163
- return d;
164
- }
165
- function T(a) {
166
- if (-1 === a._status) {
167
- var b = a._result;
168
- b = b();
169
- b.then(function(b2) {
170
- if (0 === a._status || -1 === a._status) a._status = 1, a._result = b2;
171
- }, function(b2) {
172
- if (0 === a._status || -1 === a._status) a._status = 2, a._result = b2;
173
- });
174
- -1 === a._status && (a._status = 0, a._result = b);
175
- }
176
- if (1 === a._status) return a._result.default;
177
- throw a._result;
178
- }
179
- var U = { current: null };
180
- var V = { transition: null };
181
- var W = { ReactCurrentDispatcher: U, ReactCurrentBatchConfig: V, ReactCurrentOwner: K };
182
- function X() {
183
- throw Error("act(...) is not supported in production builds of React.");
184
- }
185
- exports.Children = { map: S, forEach: function(a, b, e) {
186
- S(a, function() {
187
- b.apply(this, arguments);
188
- }, e);
189
- }, count: function(a) {
190
- var b = 0;
191
- S(a, function() {
192
- b++;
193
- });
194
- return b;
195
- }, toArray: function(a) {
196
- return S(a, function(a2) {
197
- return a2;
198
- }) || [];
199
- }, only: function(a) {
200
- if (!O(a)) throw Error("React.Children.only expected to receive a single React element child.");
201
- return a;
202
- } };
203
- exports.Component = E;
204
- exports.Fragment = p;
205
- exports.Profiler = r;
206
- exports.PureComponent = G;
207
- exports.StrictMode = q;
208
- exports.Suspense = w;
209
- exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = W;
210
- exports.act = X;
211
- exports.cloneElement = function(a, b, e) {
212
- if (null === a || void 0 === a) throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + a + ".");
213
- var d = C({}, a.props), c = a.key, k = a.ref, h = a._owner;
214
- if (null != b) {
215
- void 0 !== b.ref && (k = b.ref, h = K.current);
216
- void 0 !== b.key && (c = "" + b.key);
217
- if (a.type && a.type.defaultProps) var g = a.type.defaultProps;
218
- for (f in b) J.call(b, f) && !L.hasOwnProperty(f) && (d[f] = void 0 === b[f] && void 0 !== g ? g[f] : b[f]);
219
- }
220
- var f = arguments.length - 2;
221
- if (1 === f) d.children = e;
222
- else if (1 < f) {
223
- g = Array(f);
224
- for (var m = 0; m < f; m++) g[m] = arguments[m + 2];
225
- d.children = g;
226
- }
227
- return { $$typeof: l, type: a.type, key: c, ref: k, props: d, _owner: h };
228
- };
229
- exports.createContext = function(a) {
230
- a = { $$typeof: u, _currentValue: a, _currentValue2: a, _threadCount: 0, Provider: null, Consumer: null, _defaultValue: null, _globalName: null };
231
- a.Provider = { $$typeof: t, _context: a };
232
- return a.Consumer = a;
233
- };
234
- exports.createElement = M;
235
- exports.createFactory = function(a) {
236
- var b = M.bind(null, a);
237
- b.type = a;
238
- return b;
239
- };
240
- exports.createRef = function() {
241
- return { current: null };
242
- };
243
- exports.forwardRef = function(a) {
244
- return { $$typeof: v, render: a };
245
- };
246
- exports.isValidElement = O;
247
- exports.lazy = function(a) {
248
- return { $$typeof: y, _payload: { _status: -1, _result: a }, _init: T };
249
- };
250
- exports.memo = function(a, b) {
251
- return { $$typeof: x, type: a, compare: void 0 === b ? null : b };
252
- };
253
- exports.startTransition = function(a) {
254
- var b = V.transition;
255
- V.transition = {};
256
- try {
257
- a();
258
- } finally {
259
- V.transition = b;
260
- }
261
- };
262
- exports.unstable_act = X;
263
- exports.useCallback = function(a, b) {
264
- return U.current.useCallback(a, b);
265
- };
266
- exports.useContext = function(a) {
267
- return U.current.useContext(a);
268
- };
269
- exports.useDebugValue = function() {
270
- };
271
- exports.useDeferredValue = function(a) {
272
- return U.current.useDeferredValue(a);
273
- };
274
- exports.useEffect = function(a, b) {
275
- return U.current.useEffect(a, b);
276
- };
277
- exports.useId = function() {
278
- return U.current.useId();
279
- };
280
- exports.useImperativeHandle = function(a, b, e) {
281
- return U.current.useImperativeHandle(a, b, e);
282
- };
283
- exports.useInsertionEffect = function(a, b) {
284
- return U.current.useInsertionEffect(a, b);
285
- };
286
- exports.useLayoutEffect = function(a, b) {
287
- return U.current.useLayoutEffect(a, b);
288
- };
289
- exports.useMemo = function(a, b) {
290
- return U.current.useMemo(a, b);
291
- };
292
- exports.useReducer = function(a, b, e) {
293
- return U.current.useReducer(a, b, e);
294
- };
295
- exports.useRef = function(a) {
296
- return U.current.useRef(a);
297
- };
298
- exports.useState = function(a) {
299
- return U.current.useState(a);
300
- };
301
- exports.useSyncExternalStore = function(a, b, e) {
302
- return U.current.useSyncExternalStore(a, b, e);
303
- };
304
- exports.useTransition = function() {
305
- return U.current.useTransition();
306
- };
307
- exports.version = "18.3.1";
308
- }
309
- });
310
-
311
- // ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js
312
- var require_react_development = __commonJS({
313
- "../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.development.js"(exports, module) {
314
- "use strict";
315
- init_esm_shims();
316
- if (process.env.NODE_ENV !== "production") {
317
- (function() {
318
- "use strict";
319
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
320
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
321
- }
322
- var ReactVersion = "18.3.1";
323
- var REACT_ELEMENT_TYPE = Symbol.for("react.element");
324
- var REACT_PORTAL_TYPE = Symbol.for("react.portal");
325
- var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
326
- var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
327
- var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
328
- var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
329
- var REACT_CONTEXT_TYPE = Symbol.for("react.context");
330
- var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
331
- var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
332
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
333
- var REACT_MEMO_TYPE = Symbol.for("react.memo");
334
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
335
- var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
336
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
337
- var FAUX_ITERATOR_SYMBOL = "@@iterator";
338
- function getIteratorFn(maybeIterable) {
339
- if (maybeIterable === null || typeof maybeIterable !== "object") {
340
- return null;
341
- }
342
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
343
- if (typeof maybeIterator === "function") {
344
- return maybeIterator;
345
- }
346
- return null;
347
- }
348
- var ReactCurrentDispatcher = {
349
- /**
350
- * @internal
351
- * @type {ReactComponent}
352
- */
353
- current: null
354
- };
355
- var ReactCurrentBatchConfig = {
356
- transition: null
357
- };
358
- var ReactCurrentActQueue = {
359
- current: null,
360
- // Used to reproduce behavior of `batchedUpdates` in legacy mode.
361
- isBatchingLegacy: false,
362
- didScheduleLegacyUpdate: false
363
- };
364
- var ReactCurrentOwner = {
365
- /**
366
- * @internal
367
- * @type {ReactComponent}
368
- */
369
- current: null
370
- };
371
- var ReactDebugCurrentFrame = {};
372
- var currentExtraStackFrame = null;
373
- function setExtraStackFrame(stack) {
374
- {
375
- currentExtraStackFrame = stack;
376
- }
377
- }
378
- {
379
- ReactDebugCurrentFrame.setExtraStackFrame = function(stack) {
380
- {
381
- currentExtraStackFrame = stack;
382
- }
383
- };
384
- ReactDebugCurrentFrame.getCurrentStack = null;
385
- ReactDebugCurrentFrame.getStackAddendum = function() {
386
- var stack = "";
387
- if (currentExtraStackFrame) {
388
- stack += currentExtraStackFrame;
389
- }
390
- var impl = ReactDebugCurrentFrame.getCurrentStack;
391
- if (impl) {
392
- stack += impl() || "";
393
- }
394
- return stack;
395
- };
396
- }
397
- var enableScopeAPI = false;
398
- var enableCacheElement = false;
399
- var enableTransitionTracing = false;
400
- var enableLegacyHidden = false;
401
- var enableDebugTracing = false;
402
- var ReactSharedInternals = {
403
- ReactCurrentDispatcher,
404
- ReactCurrentBatchConfig,
405
- ReactCurrentOwner
406
- };
407
- {
408
- ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
409
- ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;
410
- }
411
- function warn(format) {
412
- {
413
- {
414
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
415
- args[_key - 1] = arguments[_key];
416
- }
417
- printWarning("warn", format, args);
418
- }
419
- }
420
- }
421
- function error(format) {
422
- {
423
- {
424
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
425
- args[_key2 - 1] = arguments[_key2];
426
- }
427
- printWarning("error", format, args);
428
- }
429
- }
430
- }
431
- function printWarning(level, format, args) {
432
- {
433
- var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
434
- var stack = ReactDebugCurrentFrame2.getStackAddendum();
435
- if (stack !== "") {
436
- format += "%s";
437
- args = args.concat([stack]);
438
- }
439
- var argsWithFormat = args.map(function(item) {
440
- return String(item);
441
- });
442
- argsWithFormat.unshift("Warning: " + format);
443
- Function.prototype.apply.call(console[level], console, argsWithFormat);
444
- }
445
- }
446
- var didWarnStateUpdateForUnmountedComponent = {};
447
- function warnNoop(publicInstance, callerName) {
448
- {
449
- var _constructor = publicInstance.constructor;
450
- var componentName = _constructor && (_constructor.displayName || _constructor.name) || "ReactClass";
451
- var warningKey = componentName + "." + callerName;
452
- if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
453
- return;
454
- }
455
- error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.", callerName, componentName);
456
- didWarnStateUpdateForUnmountedComponent[warningKey] = true;
457
- }
458
- }
459
- var ReactNoopUpdateQueue = {
460
- /**
461
- * Checks whether or not this composite component is mounted.
462
- * @param {ReactClass} publicInstance The instance we want to test.
463
- * @return {boolean} True if mounted, false otherwise.
464
- * @protected
465
- * @final
466
- */
467
- isMounted: function(publicInstance) {
468
- return false;
469
- },
470
- /**
471
- * Forces an update. This should only be invoked when it is known with
472
- * certainty that we are **not** in a DOM transaction.
473
- *
474
- * You may want to call this when you know that some deeper aspect of the
475
- * component's state has changed but `setState` was not called.
476
- *
477
- * This will not invoke `shouldComponentUpdate`, but it will invoke
478
- * `componentWillUpdate` and `componentDidUpdate`.
479
- *
480
- * @param {ReactClass} publicInstance The instance that should rerender.
481
- * @param {?function} callback Called after component is updated.
482
- * @param {?string} callerName name of the calling function in the public API.
483
- * @internal
484
- */
485
- enqueueForceUpdate: function(publicInstance, callback, callerName) {
486
- warnNoop(publicInstance, "forceUpdate");
487
- },
488
- /**
489
- * Replaces all of the state. Always use this or `setState` to mutate state.
490
- * You should treat `this.state` as immutable.
491
- *
492
- * There is no guarantee that `this.state` will be immediately updated, so
493
- * accessing `this.state` after calling this method may return the old value.
494
- *
495
- * @param {ReactClass} publicInstance The instance that should rerender.
496
- * @param {object} completeState Next state.
497
- * @param {?function} callback Called after component is updated.
498
- * @param {?string} callerName name of the calling function in the public API.
499
- * @internal
500
- */
501
- enqueueReplaceState: function(publicInstance, completeState, callback, callerName) {
502
- warnNoop(publicInstance, "replaceState");
503
- },
504
- /**
505
- * Sets a subset of the state. This only exists because _pendingState is
506
- * internal. This provides a merging strategy that is not available to deep
507
- * properties which is confusing. TODO: Expose pendingState or don't use it
508
- * during the merge.
509
- *
510
- * @param {ReactClass} publicInstance The instance that should rerender.
511
- * @param {object} partialState Next partial state to be merged with state.
512
- * @param {?function} callback Called after component is updated.
513
- * @param {?string} Name of the calling function in the public API.
514
- * @internal
515
- */
516
- enqueueSetState: function(publicInstance, partialState, callback, callerName) {
517
- warnNoop(publicInstance, "setState");
518
- }
519
- };
520
- var assign = Object.assign;
521
- var emptyObject = {};
522
- {
523
- Object.freeze(emptyObject);
524
- }
525
- function Component(props, context, updater) {
526
- this.props = props;
527
- this.context = context;
528
- this.refs = emptyObject;
529
- this.updater = updater || ReactNoopUpdateQueue;
530
- }
531
- Component.prototype.isReactComponent = {};
532
- Component.prototype.setState = function(partialState, callback) {
533
- if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null) {
534
- throw new Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
535
- }
536
- this.updater.enqueueSetState(this, partialState, callback, "setState");
537
- };
538
- Component.prototype.forceUpdate = function(callback) {
539
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
540
- };
541
- {
542
- var deprecatedAPIs = {
543
- isMounted: ["isMounted", "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],
544
- replaceState: ["replaceState", "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]
545
- };
546
- var defineDeprecationWarning = function(methodName, info) {
547
- Object.defineProperty(Component.prototype, methodName, {
548
- get: function() {
549
- warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
550
- return void 0;
551
- }
552
- });
553
- };
554
- for (var fnName in deprecatedAPIs) {
555
- if (deprecatedAPIs.hasOwnProperty(fnName)) {
556
- defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
557
- }
558
- }
559
- }
560
- function ComponentDummy() {
561
- }
562
- ComponentDummy.prototype = Component.prototype;
563
- function PureComponent(props, context, updater) {
564
- this.props = props;
565
- this.context = context;
566
- this.refs = emptyObject;
567
- this.updater = updater || ReactNoopUpdateQueue;
568
- }
569
- var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
570
- pureComponentPrototype.constructor = PureComponent;
571
- assign(pureComponentPrototype, Component.prototype);
572
- pureComponentPrototype.isPureReactComponent = true;
573
- function createRef() {
574
- var refObject = {
575
- current: null
576
- };
577
- {
578
- Object.seal(refObject);
579
- }
580
- return refObject;
581
- }
582
- var isArrayImpl = Array.isArray;
583
- function isArray(a) {
584
- return isArrayImpl(a);
585
- }
586
- function typeName(value) {
587
- {
588
- var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
589
- var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
590
- return type;
591
- }
592
- }
593
- function willCoercionThrow(value) {
594
- {
595
- try {
596
- testStringCoercion(value);
597
- return false;
598
- } catch (e) {
599
- return true;
600
- }
601
- }
602
- }
603
- function testStringCoercion(value) {
604
- return "" + value;
605
- }
606
- function checkKeyStringCoercion(value) {
607
- {
608
- if (willCoercionThrow(value)) {
609
- error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
610
- return testStringCoercion(value);
611
- }
612
- }
613
- }
614
- function getWrappedName(outerType, innerType, wrapperName) {
615
- var displayName = outerType.displayName;
616
- if (displayName) {
617
- return displayName;
618
- }
619
- var functionName = innerType.displayName || innerType.name || "";
620
- return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
621
- }
622
- function getContextName(type) {
623
- return type.displayName || "Context";
624
- }
625
- function getComponentNameFromType(type) {
626
- if (type == null) {
627
- return null;
628
- }
629
- {
630
- if (typeof type.tag === "number") {
631
- error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
632
- }
633
- }
634
- if (typeof type === "function") {
635
- return type.displayName || type.name || null;
636
- }
637
- if (typeof type === "string") {
638
- return type;
639
- }
640
- switch (type) {
641
- case REACT_FRAGMENT_TYPE:
642
- return "Fragment";
643
- case REACT_PORTAL_TYPE:
644
- return "Portal";
645
- case REACT_PROFILER_TYPE:
646
- return "Profiler";
647
- case REACT_STRICT_MODE_TYPE:
648
- return "StrictMode";
649
- case REACT_SUSPENSE_TYPE:
650
- return "Suspense";
651
- case REACT_SUSPENSE_LIST_TYPE:
652
- return "SuspenseList";
653
- }
654
- if (typeof type === "object") {
655
- switch (type.$$typeof) {
656
- case REACT_CONTEXT_TYPE:
657
- var context = type;
658
- return getContextName(context) + ".Consumer";
659
- case REACT_PROVIDER_TYPE:
660
- var provider = type;
661
- return getContextName(provider._context) + ".Provider";
662
- case REACT_FORWARD_REF_TYPE:
663
- return getWrappedName(type, type.render, "ForwardRef");
664
- case REACT_MEMO_TYPE:
665
- var outerName = type.displayName || null;
666
- if (outerName !== null) {
667
- return outerName;
668
- }
669
- return getComponentNameFromType(type.type) || "Memo";
670
- case REACT_LAZY_TYPE: {
671
- var lazyComponent = type;
672
- var payload = lazyComponent._payload;
673
- var init = lazyComponent._init;
674
- try {
675
- return getComponentNameFromType(init(payload));
676
- } catch (x) {
677
- return null;
678
- }
679
- }
680
- }
681
- }
682
- return null;
683
- }
684
- var hasOwnProperty = Object.prototype.hasOwnProperty;
685
- var RESERVED_PROPS = {
686
- key: true,
687
- ref: true,
688
- __self: true,
689
- __source: true
690
- };
691
- var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
692
- {
693
- didWarnAboutStringRefs = {};
694
- }
695
- function hasValidRef(config) {
696
- {
697
- if (hasOwnProperty.call(config, "ref")) {
698
- var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
699
- if (getter && getter.isReactWarning) {
700
- return false;
701
- }
702
- }
703
- }
704
- return config.ref !== void 0;
705
- }
706
- function hasValidKey(config) {
707
- {
708
- if (hasOwnProperty.call(config, "key")) {
709
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
710
- if (getter && getter.isReactWarning) {
711
- return false;
712
- }
713
- }
714
- }
715
- return config.key !== void 0;
716
- }
717
- function defineKeyPropWarningGetter(props, displayName) {
718
- var warnAboutAccessingKey = function() {
719
- {
720
- if (!specialPropKeyWarningShown) {
721
- specialPropKeyWarningShown = true;
722
- error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
723
- }
724
- }
725
- };
726
- warnAboutAccessingKey.isReactWarning = true;
727
- Object.defineProperty(props, "key", {
728
- get: warnAboutAccessingKey,
729
- configurable: true
730
- });
731
- }
732
- function defineRefPropWarningGetter(props, displayName) {
733
- var warnAboutAccessingRef = function() {
734
- {
735
- if (!specialPropRefWarningShown) {
736
- specialPropRefWarningShown = true;
737
- error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
738
- }
739
- }
740
- };
741
- warnAboutAccessingRef.isReactWarning = true;
742
- Object.defineProperty(props, "ref", {
743
- get: warnAboutAccessingRef,
744
- configurable: true
745
- });
746
- }
747
- function warnIfStringRefCannotBeAutoConverted(config) {
748
- {
749
- if (typeof config.ref === "string" && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
750
- var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
751
- if (!didWarnAboutStringRefs[componentName]) {
752
- error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);
753
- didWarnAboutStringRefs[componentName] = true;
754
- }
755
- }
756
- }
757
- }
758
- var ReactElement = function(type, key, ref, self, source, owner, props) {
759
- var element = {
760
- // This tag allows us to uniquely identify this as a React Element
761
- $$typeof: REACT_ELEMENT_TYPE,
762
- // Built-in properties that belong on the element
763
- type,
764
- key,
765
- ref,
766
- props,
767
- // Record the component responsible for creating this element.
768
- _owner: owner
769
- };
770
- {
771
- element._store = {};
772
- Object.defineProperty(element._store, "validated", {
773
- configurable: false,
774
- enumerable: false,
775
- writable: true,
776
- value: false
777
- });
778
- Object.defineProperty(element, "_self", {
779
- configurable: false,
780
- enumerable: false,
781
- writable: false,
782
- value: self
783
- });
784
- Object.defineProperty(element, "_source", {
785
- configurable: false,
786
- enumerable: false,
787
- writable: false,
788
- value: source
789
- });
790
- if (Object.freeze) {
791
- Object.freeze(element.props);
792
- Object.freeze(element);
793
- }
794
- }
795
- return element;
796
- };
797
- function createElement(type, config, children) {
798
- var propName;
799
- var props = {};
800
- var key = null;
801
- var ref = null;
802
- var self = null;
803
- var source = null;
804
- if (config != null) {
805
- if (hasValidRef(config)) {
806
- ref = config.ref;
807
- {
808
- warnIfStringRefCannotBeAutoConverted(config);
809
- }
810
- }
811
- if (hasValidKey(config)) {
812
- {
813
- checkKeyStringCoercion(config.key);
814
- }
815
- key = "" + config.key;
816
- }
817
- self = config.__self === void 0 ? null : config.__self;
818
- source = config.__source === void 0 ? null : config.__source;
819
- for (propName in config) {
820
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
821
- props[propName] = config[propName];
822
- }
823
- }
824
- }
825
- var childrenLength = arguments.length - 2;
826
- if (childrenLength === 1) {
827
- props.children = children;
828
- } else if (childrenLength > 1) {
829
- var childArray = Array(childrenLength);
830
- for (var i = 0; i < childrenLength; i++) {
831
- childArray[i] = arguments[i + 2];
832
- }
833
- {
834
- if (Object.freeze) {
835
- Object.freeze(childArray);
836
- }
837
- }
838
- props.children = childArray;
839
- }
840
- if (type && type.defaultProps) {
841
- var defaultProps = type.defaultProps;
842
- for (propName in defaultProps) {
843
- if (props[propName] === void 0) {
844
- props[propName] = defaultProps[propName];
845
- }
846
- }
847
- }
848
- {
849
- if (key || ref) {
850
- var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
851
- if (key) {
852
- defineKeyPropWarningGetter(props, displayName);
853
- }
854
- if (ref) {
855
- defineRefPropWarningGetter(props, displayName);
856
- }
857
- }
858
- }
859
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
860
- }
861
- function cloneAndReplaceKey(oldElement, newKey) {
862
- var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
863
- return newElement;
864
- }
865
- function cloneElement(element, config, children) {
866
- if (element === null || element === void 0) {
867
- throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
868
- }
869
- var propName;
870
- var props = assign({}, element.props);
871
- var key = element.key;
872
- var ref = element.ref;
873
- var self = element._self;
874
- var source = element._source;
875
- var owner = element._owner;
876
- if (config != null) {
877
- if (hasValidRef(config)) {
878
- ref = config.ref;
879
- owner = ReactCurrentOwner.current;
880
- }
881
- if (hasValidKey(config)) {
882
- {
883
- checkKeyStringCoercion(config.key);
884
- }
885
- key = "" + config.key;
886
- }
887
- var defaultProps;
888
- if (element.type && element.type.defaultProps) {
889
- defaultProps = element.type.defaultProps;
890
- }
891
- for (propName in config) {
892
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
893
- if (config[propName] === void 0 && defaultProps !== void 0) {
894
- props[propName] = defaultProps[propName];
895
- } else {
896
- props[propName] = config[propName];
897
- }
898
- }
899
- }
900
- }
901
- var childrenLength = arguments.length - 2;
902
- if (childrenLength === 1) {
903
- props.children = children;
904
- } else if (childrenLength > 1) {
905
- var childArray = Array(childrenLength);
906
- for (var i = 0; i < childrenLength; i++) {
907
- childArray[i] = arguments[i + 2];
908
- }
909
- props.children = childArray;
910
- }
911
- return ReactElement(element.type, key, ref, self, source, owner, props);
912
- }
913
- function isValidElement(object) {
914
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
915
- }
916
- var SEPARATOR = ".";
917
- var SUBSEPARATOR = ":";
918
- function escape(key) {
919
- var escapeRegex = /[=:]/g;
920
- var escaperLookup = {
921
- "=": "=0",
922
- ":": "=2"
923
- };
924
- var escapedString = key.replace(escapeRegex, function(match) {
925
- return escaperLookup[match];
926
- });
927
- return "$" + escapedString;
928
- }
929
- var didWarnAboutMaps = false;
930
- var userProvidedKeyEscapeRegex = /\/+/g;
931
- function escapeUserProvidedKey(text) {
932
- return text.replace(userProvidedKeyEscapeRegex, "$&/");
933
- }
934
- function getElementKey(element, index) {
935
- if (typeof element === "object" && element !== null && element.key != null) {
936
- {
937
- checkKeyStringCoercion(element.key);
938
- }
939
- return escape("" + element.key);
940
- }
941
- return index.toString(36);
942
- }
943
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
944
- var type = typeof children;
945
- if (type === "undefined" || type === "boolean") {
946
- children = null;
947
- }
948
- var invokeCallback = false;
949
- if (children === null) {
950
- invokeCallback = true;
951
- } else {
952
- switch (type) {
953
- case "string":
954
- case "number":
955
- invokeCallback = true;
956
- break;
957
- case "object":
958
- switch (children.$$typeof) {
959
- case REACT_ELEMENT_TYPE:
960
- case REACT_PORTAL_TYPE:
961
- invokeCallback = true;
962
- }
963
- }
964
- }
965
- if (invokeCallback) {
966
- var _child = children;
967
- var mappedChild = callback(_child);
968
- var childKey = nameSoFar === "" ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
969
- if (isArray(mappedChild)) {
970
- var escapedChildKey = "";
971
- if (childKey != null) {
972
- escapedChildKey = escapeUserProvidedKey(childKey) + "/";
973
- }
974
- mapIntoArray(mappedChild, array, escapedChildKey, "", function(c) {
975
- return c;
976
- });
977
- } else if (mappedChild != null) {
978
- if (isValidElement(mappedChild)) {
979
- {
980
- if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
981
- checkKeyStringCoercion(mappedChild.key);
982
- }
983
- }
984
- mappedChild = cloneAndReplaceKey(
985
- mappedChild,
986
- // Keep both the (mapped) and old keys if they differ, just as
987
- // traverseAllChildren used to do for objects as children
988
- escapedPrefix + // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
989
- (mappedChild.key && (!_child || _child.key !== mappedChild.key) ? (
990
- // $FlowFixMe Flow incorrectly thinks existing element's key can be a number
991
- // eslint-disable-next-line react-internal/safe-string-coercion
992
- escapeUserProvidedKey("" + mappedChild.key) + "/"
993
- ) : "") + childKey
994
- );
995
- }
996
- array.push(mappedChild);
997
- }
998
- return 1;
999
- }
1000
- var child;
1001
- var nextName;
1002
- var subtreeCount = 0;
1003
- var nextNamePrefix = nameSoFar === "" ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1004
- if (isArray(children)) {
1005
- for (var i = 0; i < children.length; i++) {
1006
- child = children[i];
1007
- nextName = nextNamePrefix + getElementKey(child, i);
1008
- subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
1009
- }
1010
- } else {
1011
- var iteratorFn = getIteratorFn(children);
1012
- if (typeof iteratorFn === "function") {
1013
- var iterableChildren = children;
1014
- {
1015
- if (iteratorFn === iterableChildren.entries) {
1016
- if (!didWarnAboutMaps) {
1017
- warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead.");
1018
- }
1019
- didWarnAboutMaps = true;
1020
- }
1021
- }
1022
- var iterator = iteratorFn.call(iterableChildren);
1023
- var step;
1024
- var ii = 0;
1025
- while (!(step = iterator.next()).done) {
1026
- child = step.value;
1027
- nextName = nextNamePrefix + getElementKey(child, ii++);
1028
- subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
1029
- }
1030
- } else if (type === "object") {
1031
- var childrenString = String(children);
1032
- throw new Error("Objects are not valid as a React child (found: " + (childrenString === "[object Object]" ? "object with keys {" + Object.keys(children).join(", ") + "}" : childrenString) + "). If you meant to render a collection of children, use an array instead.");
1033
- }
1034
- }
1035
- return subtreeCount;
1036
- }
1037
- function mapChildren(children, func, context) {
1038
- if (children == null) {
1039
- return children;
1040
- }
1041
- var result = [];
1042
- var count = 0;
1043
- mapIntoArray(children, result, "", "", function(child) {
1044
- return func.call(context, child, count++);
1045
- });
1046
- return result;
1047
- }
1048
- function countChildren(children) {
1049
- var n = 0;
1050
- mapChildren(children, function() {
1051
- n++;
1052
- });
1053
- return n;
1054
- }
1055
- function forEachChildren(children, forEachFunc, forEachContext) {
1056
- mapChildren(children, function() {
1057
- forEachFunc.apply(this, arguments);
1058
- }, forEachContext);
1059
- }
1060
- function toArray(children) {
1061
- return mapChildren(children, function(child) {
1062
- return child;
1063
- }) || [];
1064
- }
1065
- function onlyChild(children) {
1066
- if (!isValidElement(children)) {
1067
- throw new Error("React.Children.only expected to receive a single React element child.");
1068
- }
1069
- return children;
1070
- }
1071
- function createContext(defaultValue) {
1072
- var context = {
1073
- $$typeof: REACT_CONTEXT_TYPE,
1074
- // As a workaround to support multiple concurrent renderers, we categorize
1075
- // some renderers as primary and others as secondary. We only expect
1076
- // there to be two concurrent renderers at most: React Native (primary) and
1077
- // Fabric (secondary); React DOM (primary) and React ART (secondary).
1078
- // Secondary renderers store their context values on separate fields.
1079
- _currentValue: defaultValue,
1080
- _currentValue2: defaultValue,
1081
- // Used to track how many concurrent renderers this context currently
1082
- // supports within in a single renderer. Such as parallel server rendering.
1083
- _threadCount: 0,
1084
- // These are circular
1085
- Provider: null,
1086
- Consumer: null,
1087
- // Add these to use same hidden class in VM as ServerContext
1088
- _defaultValue: null,
1089
- _globalName: null
1090
- };
1091
- context.Provider = {
1092
- $$typeof: REACT_PROVIDER_TYPE,
1093
- _context: context
1094
- };
1095
- var hasWarnedAboutUsingNestedContextConsumers = false;
1096
- var hasWarnedAboutUsingConsumerProvider = false;
1097
- var hasWarnedAboutDisplayNameOnConsumer = false;
1098
- {
1099
- var Consumer = {
1100
- $$typeof: REACT_CONTEXT_TYPE,
1101
- _context: context
1102
- };
1103
- Object.defineProperties(Consumer, {
1104
- Provider: {
1105
- get: function() {
1106
- if (!hasWarnedAboutUsingConsumerProvider) {
1107
- hasWarnedAboutUsingConsumerProvider = true;
1108
- error("Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?");
1109
- }
1110
- return context.Provider;
1111
- },
1112
- set: function(_Provider) {
1113
- context.Provider = _Provider;
1114
- }
1115
- },
1116
- _currentValue: {
1117
- get: function() {
1118
- return context._currentValue;
1119
- },
1120
- set: function(_currentValue) {
1121
- context._currentValue = _currentValue;
1122
- }
1123
- },
1124
- _currentValue2: {
1125
- get: function() {
1126
- return context._currentValue2;
1127
- },
1128
- set: function(_currentValue2) {
1129
- context._currentValue2 = _currentValue2;
1130
- }
1131
- },
1132
- _threadCount: {
1133
- get: function() {
1134
- return context._threadCount;
1135
- },
1136
- set: function(_threadCount) {
1137
- context._threadCount = _threadCount;
1138
- }
1139
- },
1140
- Consumer: {
1141
- get: function() {
1142
- if (!hasWarnedAboutUsingNestedContextConsumers) {
1143
- hasWarnedAboutUsingNestedContextConsumers = true;
1144
- error("Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?");
1145
- }
1146
- return context.Consumer;
1147
- }
1148
- },
1149
- displayName: {
1150
- get: function() {
1151
- return context.displayName;
1152
- },
1153
- set: function(displayName) {
1154
- if (!hasWarnedAboutDisplayNameOnConsumer) {
1155
- warn("Setting `displayName` on Context.Consumer has no effect. You should set it directly on the context with Context.displayName = '%s'.", displayName);
1156
- hasWarnedAboutDisplayNameOnConsumer = true;
1157
- }
1158
- }
1159
- }
1160
- });
1161
- context.Consumer = Consumer;
1162
- }
1163
- {
1164
- context._currentRenderer = null;
1165
- context._currentRenderer2 = null;
1166
- }
1167
- return context;
1168
- }
1169
- var Uninitialized = -1;
1170
- var Pending = 0;
1171
- var Resolved = 1;
1172
- var Rejected = 2;
1173
- function lazyInitializer(payload) {
1174
- if (payload._status === Uninitialized) {
1175
- var ctor = payload._result;
1176
- var thenable = ctor();
1177
- thenable.then(function(moduleObject2) {
1178
- if (payload._status === Pending || payload._status === Uninitialized) {
1179
- var resolved = payload;
1180
- resolved._status = Resolved;
1181
- resolved._result = moduleObject2;
1182
- }
1183
- }, function(error2) {
1184
- if (payload._status === Pending || payload._status === Uninitialized) {
1185
- var rejected = payload;
1186
- rejected._status = Rejected;
1187
- rejected._result = error2;
1188
- }
1189
- });
1190
- if (payload._status === Uninitialized) {
1191
- var pending = payload;
1192
- pending._status = Pending;
1193
- pending._result = thenable;
1194
- }
1195
- }
1196
- if (payload._status === Resolved) {
1197
- var moduleObject = payload._result;
1198
- {
1199
- if (moduleObject === void 0) {
1200
- error("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?", moduleObject);
1201
- }
1202
- }
1203
- {
1204
- if (!("default" in moduleObject)) {
1205
- error("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
1206
- }
1207
- }
1208
- return moduleObject.default;
1209
- } else {
1210
- throw payload._result;
1211
- }
1212
- }
1213
- function lazy(ctor) {
1214
- var payload = {
1215
- // We use these fields to store the result.
1216
- _status: Uninitialized,
1217
- _result: ctor
1218
- };
1219
- var lazyType = {
1220
- $$typeof: REACT_LAZY_TYPE,
1221
- _payload: payload,
1222
- _init: lazyInitializer
1223
- };
1224
- {
1225
- var defaultProps;
1226
- var propTypes;
1227
- Object.defineProperties(lazyType, {
1228
- defaultProps: {
1229
- configurable: true,
1230
- get: function() {
1231
- return defaultProps;
1232
- },
1233
- set: function(newDefaultProps) {
1234
- error("React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.");
1235
- defaultProps = newDefaultProps;
1236
- Object.defineProperty(lazyType, "defaultProps", {
1237
- enumerable: true
1238
- });
1239
- }
1240
- },
1241
- propTypes: {
1242
- configurable: true,
1243
- get: function() {
1244
- return propTypes;
1245
- },
1246
- set: function(newPropTypes) {
1247
- error("React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.");
1248
- propTypes = newPropTypes;
1249
- Object.defineProperty(lazyType, "propTypes", {
1250
- enumerable: true
1251
- });
1252
- }
1253
- }
1254
- });
1255
- }
1256
- return lazyType;
1257
- }
1258
- function forwardRef(render) {
1259
- {
1260
- if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
1261
- error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).");
1262
- } else if (typeof render !== "function") {
1263
- error("forwardRef requires a render function but was given %s.", render === null ? "null" : typeof render);
1264
- } else {
1265
- if (render.length !== 0 && render.length !== 2) {
1266
- error("forwardRef render functions accept exactly two parameters: props and ref. %s", render.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined.");
1267
- }
1268
- }
1269
- if (render != null) {
1270
- if (render.defaultProps != null || render.propTypes != null) {
1271
- error("forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?");
1272
- }
1273
- }
1274
- }
1275
- var elementType = {
1276
- $$typeof: REACT_FORWARD_REF_TYPE,
1277
- render
1278
- };
1279
- {
1280
- var ownName;
1281
- Object.defineProperty(elementType, "displayName", {
1282
- enumerable: false,
1283
- configurable: true,
1284
- get: function() {
1285
- return ownName;
1286
- },
1287
- set: function(name) {
1288
- ownName = name;
1289
- if (!render.name && !render.displayName) {
1290
- render.displayName = name;
1291
- }
1292
- }
1293
- });
1294
- }
1295
- return elementType;
1296
- }
1297
- var REACT_MODULE_REFERENCE;
1298
- {
1299
- REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
1300
- }
1301
- function isValidElementType(type) {
1302
- if (typeof type === "string" || typeof type === "function") {
1303
- return true;
1304
- }
1305
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
1306
- return true;
1307
- }
1308
- if (typeof type === "object" && type !== null) {
1309
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
1310
- // types supported by any Flight configuration anywhere since
1311
- // we don't know which Flight build this will end up being used
1312
- // with.
1313
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
1314
- return true;
1315
- }
1316
- }
1317
- return false;
1318
- }
1319
- function memo(type, compare) {
1320
- {
1321
- if (!isValidElementType(type)) {
1322
- error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
1323
- }
1324
- }
1325
- var elementType = {
1326
- $$typeof: REACT_MEMO_TYPE,
1327
- type,
1328
- compare: compare === void 0 ? null : compare
1329
- };
1330
- {
1331
- var ownName;
1332
- Object.defineProperty(elementType, "displayName", {
1333
- enumerable: false,
1334
- configurable: true,
1335
- get: function() {
1336
- return ownName;
1337
- },
1338
- set: function(name) {
1339
- ownName = name;
1340
- if (!type.name && !type.displayName) {
1341
- type.displayName = name;
1342
- }
1343
- }
1344
- });
1345
- }
1346
- return elementType;
1347
- }
1348
- function resolveDispatcher() {
1349
- var dispatcher = ReactCurrentDispatcher.current;
1350
- {
1351
- if (dispatcher === null) {
1352
- error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
1353
- }
1354
- }
1355
- return dispatcher;
1356
- }
1357
- function useContext(Context) {
1358
- var dispatcher = resolveDispatcher();
1359
- {
1360
- if (Context._context !== void 0) {
1361
- var realContext = Context._context;
1362
- if (realContext.Consumer === Context) {
1363
- error("Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?");
1364
- } else if (realContext.Provider === Context) {
1365
- error("Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?");
1366
- }
1367
- }
1368
- }
1369
- return dispatcher.useContext(Context);
1370
- }
1371
- function useState(initialState) {
1372
- var dispatcher = resolveDispatcher();
1373
- return dispatcher.useState(initialState);
1374
- }
1375
- function useReducer(reducer, initialArg, init) {
1376
- var dispatcher = resolveDispatcher();
1377
- return dispatcher.useReducer(reducer, initialArg, init);
1378
- }
1379
- function useRef(initialValue) {
1380
- var dispatcher = resolveDispatcher();
1381
- return dispatcher.useRef(initialValue);
1382
- }
1383
- function useEffect(create, deps) {
1384
- var dispatcher = resolveDispatcher();
1385
- return dispatcher.useEffect(create, deps);
1386
- }
1387
- function useInsertionEffect(create, deps) {
1388
- var dispatcher = resolveDispatcher();
1389
- return dispatcher.useInsertionEffect(create, deps);
1390
- }
1391
- function useLayoutEffect(create, deps) {
1392
- var dispatcher = resolveDispatcher();
1393
- return dispatcher.useLayoutEffect(create, deps);
1394
- }
1395
- function useCallback(callback, deps) {
1396
- var dispatcher = resolveDispatcher();
1397
- return dispatcher.useCallback(callback, deps);
1398
- }
1399
- function useMemo(create, deps) {
1400
- var dispatcher = resolveDispatcher();
1401
- return dispatcher.useMemo(create, deps);
1402
- }
1403
- function useImperativeHandle(ref, create, deps) {
1404
- var dispatcher = resolveDispatcher();
1405
- return dispatcher.useImperativeHandle(ref, create, deps);
1406
- }
1407
- function useDebugValue(value, formatterFn) {
1408
- {
1409
- var dispatcher = resolveDispatcher();
1410
- return dispatcher.useDebugValue(value, formatterFn);
1411
- }
1412
- }
1413
- function useTransition() {
1414
- var dispatcher = resolveDispatcher();
1415
- return dispatcher.useTransition();
1416
- }
1417
- function useDeferredValue(value) {
1418
- var dispatcher = resolveDispatcher();
1419
- return dispatcher.useDeferredValue(value);
1420
- }
1421
- function useId() {
1422
- var dispatcher = resolveDispatcher();
1423
- return dispatcher.useId();
1424
- }
1425
- function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
1426
- var dispatcher = resolveDispatcher();
1427
- return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
1428
- }
1429
- var disabledDepth = 0;
1430
- var prevLog;
1431
- var prevInfo;
1432
- var prevWarn;
1433
- var prevError;
1434
- var prevGroup;
1435
- var prevGroupCollapsed;
1436
- var prevGroupEnd;
1437
- function disabledLog() {
1438
- }
1439
- disabledLog.__reactDisabledLog = true;
1440
- function disableLogs() {
1441
- {
1442
- if (disabledDepth === 0) {
1443
- prevLog = console.log;
1444
- prevInfo = console.info;
1445
- prevWarn = console.warn;
1446
- prevError = console.error;
1447
- prevGroup = console.group;
1448
- prevGroupCollapsed = console.groupCollapsed;
1449
- prevGroupEnd = console.groupEnd;
1450
- var props = {
1451
- configurable: true,
1452
- enumerable: true,
1453
- value: disabledLog,
1454
- writable: true
1455
- };
1456
- Object.defineProperties(console, {
1457
- info: props,
1458
- log: props,
1459
- warn: props,
1460
- error: props,
1461
- group: props,
1462
- groupCollapsed: props,
1463
- groupEnd: props
1464
- });
1465
- }
1466
- disabledDepth++;
1467
- }
1468
- }
1469
- function reenableLogs() {
1470
- {
1471
- disabledDepth--;
1472
- if (disabledDepth === 0) {
1473
- var props = {
1474
- configurable: true,
1475
- enumerable: true,
1476
- writable: true
1477
- };
1478
- Object.defineProperties(console, {
1479
- log: assign({}, props, {
1480
- value: prevLog
1481
- }),
1482
- info: assign({}, props, {
1483
- value: prevInfo
1484
- }),
1485
- warn: assign({}, props, {
1486
- value: prevWarn
1487
- }),
1488
- error: assign({}, props, {
1489
- value: prevError
1490
- }),
1491
- group: assign({}, props, {
1492
- value: prevGroup
1493
- }),
1494
- groupCollapsed: assign({}, props, {
1495
- value: prevGroupCollapsed
1496
- }),
1497
- groupEnd: assign({}, props, {
1498
- value: prevGroupEnd
1499
- })
1500
- });
1501
- }
1502
- if (disabledDepth < 0) {
1503
- error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
1504
- }
1505
- }
1506
- }
1507
- var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
1508
- var prefix;
1509
- function describeBuiltInComponentFrame(name, source, ownerFn) {
1510
- {
1511
- if (prefix === void 0) {
1512
- try {
1513
- throw Error();
1514
- } catch (x) {
1515
- var match = x.stack.trim().match(/\n( *(at )?)/);
1516
- prefix = match && match[1] || "";
1517
- }
1518
- }
1519
- return "\n" + prefix + name;
1520
- }
1521
- }
1522
- var reentry = false;
1523
- var componentFrameCache;
1524
- {
1525
- var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
1526
- componentFrameCache = new PossiblyWeakMap();
1527
- }
1528
- function describeNativeComponentFrame(fn, construct) {
1529
- if (!fn || reentry) {
1530
- return "";
1531
- }
1532
- {
1533
- var frame = componentFrameCache.get(fn);
1534
- if (frame !== void 0) {
1535
- return frame;
1536
- }
1537
- }
1538
- var control;
1539
- reentry = true;
1540
- var previousPrepareStackTrace = Error.prepareStackTrace;
1541
- Error.prepareStackTrace = void 0;
1542
- var previousDispatcher;
1543
- {
1544
- previousDispatcher = ReactCurrentDispatcher$1.current;
1545
- ReactCurrentDispatcher$1.current = null;
1546
- disableLogs();
1547
- }
1548
- try {
1549
- if (construct) {
1550
- var Fake = function() {
1551
- throw Error();
1552
- };
1553
- Object.defineProperty(Fake.prototype, "props", {
1554
- set: function() {
1555
- throw Error();
1556
- }
1557
- });
1558
- if (typeof Reflect === "object" && Reflect.construct) {
1559
- try {
1560
- Reflect.construct(Fake, []);
1561
- } catch (x) {
1562
- control = x;
1563
- }
1564
- Reflect.construct(fn, [], Fake);
1565
- } else {
1566
- try {
1567
- Fake.call();
1568
- } catch (x) {
1569
- control = x;
1570
- }
1571
- fn.call(Fake.prototype);
1572
- }
1573
- } else {
1574
- try {
1575
- throw Error();
1576
- } catch (x) {
1577
- control = x;
1578
- }
1579
- fn();
1580
- }
1581
- } catch (sample) {
1582
- if (sample && control && typeof sample.stack === "string") {
1583
- var sampleLines = sample.stack.split("\n");
1584
- var controlLines = control.stack.split("\n");
1585
- var s = sampleLines.length - 1;
1586
- var c = controlLines.length - 1;
1587
- while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
1588
- c--;
1589
- }
1590
- for (; s >= 1 && c >= 0; s--, c--) {
1591
- if (sampleLines[s] !== controlLines[c]) {
1592
- if (s !== 1 || c !== 1) {
1593
- do {
1594
- s--;
1595
- c--;
1596
- if (c < 0 || sampleLines[s] !== controlLines[c]) {
1597
- var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
1598
- if (fn.displayName && _frame.includes("<anonymous>")) {
1599
- _frame = _frame.replace("<anonymous>", fn.displayName);
1600
- }
1601
- {
1602
- if (typeof fn === "function") {
1603
- componentFrameCache.set(fn, _frame);
1604
- }
1605
- }
1606
- return _frame;
1607
- }
1608
- } while (s >= 1 && c >= 0);
1609
- }
1610
- break;
1611
- }
1612
- }
1613
- }
1614
- } finally {
1615
- reentry = false;
1616
- {
1617
- ReactCurrentDispatcher$1.current = previousDispatcher;
1618
- reenableLogs();
1619
- }
1620
- Error.prepareStackTrace = previousPrepareStackTrace;
1621
- }
1622
- var name = fn ? fn.displayName || fn.name : "";
1623
- var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
1624
- {
1625
- if (typeof fn === "function") {
1626
- componentFrameCache.set(fn, syntheticFrame);
1627
- }
1628
- }
1629
- return syntheticFrame;
1630
- }
1631
- function describeFunctionComponentFrame(fn, source, ownerFn) {
1632
- {
1633
- return describeNativeComponentFrame(fn, false);
1634
- }
1635
- }
1636
- function shouldConstruct(Component2) {
1637
- var prototype = Component2.prototype;
1638
- return !!(prototype && prototype.isReactComponent);
1639
- }
1640
- function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
1641
- if (type == null) {
1642
- return "";
1643
- }
1644
- if (typeof type === "function") {
1645
- {
1646
- return describeNativeComponentFrame(type, shouldConstruct(type));
1647
- }
1648
- }
1649
- if (typeof type === "string") {
1650
- return describeBuiltInComponentFrame(type);
1651
- }
1652
- switch (type) {
1653
- case REACT_SUSPENSE_TYPE:
1654
- return describeBuiltInComponentFrame("Suspense");
1655
- case REACT_SUSPENSE_LIST_TYPE:
1656
- return describeBuiltInComponentFrame("SuspenseList");
1657
- }
1658
- if (typeof type === "object") {
1659
- switch (type.$$typeof) {
1660
- case REACT_FORWARD_REF_TYPE:
1661
- return describeFunctionComponentFrame(type.render);
1662
- case REACT_MEMO_TYPE:
1663
- return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
1664
- case REACT_LAZY_TYPE: {
1665
- var lazyComponent = type;
1666
- var payload = lazyComponent._payload;
1667
- var init = lazyComponent._init;
1668
- try {
1669
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
1670
- } catch (x) {
1671
- }
1672
- }
1673
- }
1674
- }
1675
- return "";
1676
- }
1677
- var loggedTypeFailures = {};
1678
- var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
1679
- function setCurrentlyValidatingElement(element) {
1680
- {
1681
- if (element) {
1682
- var owner = element._owner;
1683
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1684
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
1685
- } else {
1686
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
1687
- }
1688
- }
1689
- }
1690
- function checkPropTypes(typeSpecs, values, location, componentName, element) {
1691
- {
1692
- var has = Function.call.bind(hasOwnProperty);
1693
- for (var typeSpecName in typeSpecs) {
1694
- if (has(typeSpecs, typeSpecName)) {
1695
- var error$1 = void 0;
1696
- try {
1697
- if (typeof typeSpecs[typeSpecName] !== "function") {
1698
- var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
1699
- err.name = "Invariant Violation";
1700
- throw err;
1701
- }
1702
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
1703
- } catch (ex) {
1704
- error$1 = ex;
1705
- }
1706
- if (error$1 && !(error$1 instanceof Error)) {
1707
- setCurrentlyValidatingElement(element);
1708
- error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
1709
- setCurrentlyValidatingElement(null);
1710
- }
1711
- if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
1712
- loggedTypeFailures[error$1.message] = true;
1713
- setCurrentlyValidatingElement(element);
1714
- error("Failed %s type: %s", location, error$1.message);
1715
- setCurrentlyValidatingElement(null);
1716
- }
1717
- }
1718
- }
1719
- }
1720
- }
1721
- function setCurrentlyValidatingElement$1(element) {
1722
- {
1723
- if (element) {
1724
- var owner = element._owner;
1725
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1726
- setExtraStackFrame(stack);
1727
- } else {
1728
- setExtraStackFrame(null);
1729
- }
1730
- }
1731
- }
1732
- var propTypesMisspellWarningShown;
1733
- {
1734
- propTypesMisspellWarningShown = false;
1735
- }
1736
- function getDeclarationErrorAddendum() {
1737
- if (ReactCurrentOwner.current) {
1738
- var name = getComponentNameFromType(ReactCurrentOwner.current.type);
1739
- if (name) {
1740
- return "\n\nCheck the render method of `" + name + "`.";
1741
- }
1742
- }
1743
- return "";
1744
- }
1745
- function getSourceInfoErrorAddendum(source) {
1746
- if (source !== void 0) {
1747
- var fileName = source.fileName.replace(/^.*[\\\/]/, "");
1748
- var lineNumber = source.lineNumber;
1749
- return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
1750
- }
1751
- return "";
1752
- }
1753
- function getSourceInfoErrorAddendumForProps(elementProps) {
1754
- if (elementProps !== null && elementProps !== void 0) {
1755
- return getSourceInfoErrorAddendum(elementProps.__source);
1756
- }
1757
- return "";
1758
- }
1759
- var ownerHasKeyUseWarning = {};
1760
- function getCurrentComponentErrorInfo(parentType) {
1761
- var info = getDeclarationErrorAddendum();
1762
- if (!info) {
1763
- var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
1764
- if (parentName) {
1765
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
1766
- }
1767
- }
1768
- return info;
1769
- }
1770
- function validateExplicitKey(element, parentType) {
1771
- if (!element._store || element._store.validated || element.key != null) {
1772
- return;
1773
- }
1774
- element._store.validated = true;
1775
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1776
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1777
- return;
1778
- }
1779
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
1780
- var childOwner = "";
1781
- if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
1782
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
1783
- }
1784
- {
1785
- setCurrentlyValidatingElement$1(element);
1786
- error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
1787
- setCurrentlyValidatingElement$1(null);
1788
- }
1789
- }
1790
- function validateChildKeys(node, parentType) {
1791
- if (typeof node !== "object") {
1792
- return;
1793
- }
1794
- if (isArray(node)) {
1795
- for (var i = 0; i < node.length; i++) {
1796
- var child = node[i];
1797
- if (isValidElement(child)) {
1798
- validateExplicitKey(child, parentType);
1799
- }
1800
- }
1801
- } else if (isValidElement(node)) {
1802
- if (node._store) {
1803
- node._store.validated = true;
1804
- }
1805
- } else if (node) {
1806
- var iteratorFn = getIteratorFn(node);
1807
- if (typeof iteratorFn === "function") {
1808
- if (iteratorFn !== node.entries) {
1809
- var iterator = iteratorFn.call(node);
1810
- var step;
1811
- while (!(step = iterator.next()).done) {
1812
- if (isValidElement(step.value)) {
1813
- validateExplicitKey(step.value, parentType);
1814
- }
1815
- }
1816
- }
1817
- }
1818
- }
1819
- }
1820
- function validatePropTypes(element) {
1821
- {
1822
- var type = element.type;
1823
- if (type === null || type === void 0 || typeof type === "string") {
1824
- return;
1825
- }
1826
- var propTypes;
1827
- if (typeof type === "function") {
1828
- propTypes = type.propTypes;
1829
- } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1830
- // Inner props are checked in the reconciler.
1831
- type.$$typeof === REACT_MEMO_TYPE)) {
1832
- propTypes = type.propTypes;
1833
- } else {
1834
- return;
1835
- }
1836
- if (propTypes) {
1837
- var name = getComponentNameFromType(type);
1838
- checkPropTypes(propTypes, element.props, "prop", name, element);
1839
- } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
1840
- propTypesMisspellWarningShown = true;
1841
- var _name = getComponentNameFromType(type);
1842
- error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
1843
- }
1844
- if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
1845
- error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
1846
- }
1847
- }
1848
- }
1849
- function validateFragmentProps(fragment) {
1850
- {
1851
- var keys = Object.keys(fragment.props);
1852
- for (var i = 0; i < keys.length; i++) {
1853
- var key = keys[i];
1854
- if (key !== "children" && key !== "key") {
1855
- setCurrentlyValidatingElement$1(fragment);
1856
- error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
1857
- setCurrentlyValidatingElement$1(null);
1858
- break;
1859
- }
1860
- }
1861
- if (fragment.ref !== null) {
1862
- setCurrentlyValidatingElement$1(fragment);
1863
- error("Invalid attribute `ref` supplied to `React.Fragment`.");
1864
- setCurrentlyValidatingElement$1(null);
1865
- }
1866
- }
1867
- }
1868
- function createElementWithValidation(type, props, children) {
1869
- var validType = isValidElementType(type);
1870
- if (!validType) {
1871
- var info = "";
1872
- if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
1873
- info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
1874
- }
1875
- var sourceInfo = getSourceInfoErrorAddendumForProps(props);
1876
- if (sourceInfo) {
1877
- info += sourceInfo;
1878
- } else {
1879
- info += getDeclarationErrorAddendum();
1880
- }
1881
- var typeString;
1882
- if (type === null) {
1883
- typeString = "null";
1884
- } else if (isArray(type)) {
1885
- typeString = "array";
1886
- } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
1887
- typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
1888
- info = " Did you accidentally export a JSX literal instead of a component?";
1889
- } else {
1890
- typeString = typeof type;
1891
- }
1892
- {
1893
- error("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
1894
- }
1895
- }
1896
- var element = createElement.apply(this, arguments);
1897
- if (element == null) {
1898
- return element;
1899
- }
1900
- if (validType) {
1901
- for (var i = 2; i < arguments.length; i++) {
1902
- validateChildKeys(arguments[i], type);
1903
- }
1904
- }
1905
- if (type === REACT_FRAGMENT_TYPE) {
1906
- validateFragmentProps(element);
1907
- } else {
1908
- validatePropTypes(element);
1909
- }
1910
- return element;
1911
- }
1912
- var didWarnAboutDeprecatedCreateFactory = false;
1913
- function createFactoryWithValidation(type) {
1914
- var validatedFactory = createElementWithValidation.bind(null, type);
1915
- validatedFactory.type = type;
1916
- {
1917
- if (!didWarnAboutDeprecatedCreateFactory) {
1918
- didWarnAboutDeprecatedCreateFactory = true;
1919
- warn("React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.");
1920
- }
1921
- Object.defineProperty(validatedFactory, "type", {
1922
- enumerable: false,
1923
- get: function() {
1924
- warn("Factory.type is deprecated. Access the class directly before passing it to createFactory.");
1925
- Object.defineProperty(this, "type", {
1926
- value: type
1927
- });
1928
- return type;
1929
- }
1930
- });
1931
- }
1932
- return validatedFactory;
1933
- }
1934
- function cloneElementWithValidation(element, props, children) {
1935
- var newElement = cloneElement.apply(this, arguments);
1936
- for (var i = 2; i < arguments.length; i++) {
1937
- validateChildKeys(arguments[i], newElement.type);
1938
- }
1939
- validatePropTypes(newElement);
1940
- return newElement;
1941
- }
1942
- function startTransition(scope, options) {
1943
- var prevTransition = ReactCurrentBatchConfig.transition;
1944
- ReactCurrentBatchConfig.transition = {};
1945
- var currentTransition = ReactCurrentBatchConfig.transition;
1946
- {
1947
- ReactCurrentBatchConfig.transition._updatedFibers = /* @__PURE__ */ new Set();
1948
- }
1949
- try {
1950
- scope();
1951
- } finally {
1952
- ReactCurrentBatchConfig.transition = prevTransition;
1953
- {
1954
- if (prevTransition === null && currentTransition._updatedFibers) {
1955
- var updatedFibersCount = currentTransition._updatedFibers.size;
1956
- if (updatedFibersCount > 10) {
1957
- warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.");
1958
- }
1959
- currentTransition._updatedFibers.clear();
1960
- }
1961
- }
1962
- }
1963
- }
1964
- var didWarnAboutMessageChannel = false;
1965
- var enqueueTaskImpl = null;
1966
- function enqueueTask(task) {
1967
- if (enqueueTaskImpl === null) {
1968
- try {
1969
- var requireString = ("require" + Math.random()).slice(0, 7);
1970
- var nodeRequire = module && module[requireString];
1971
- enqueueTaskImpl = nodeRequire.call(module, "timers").setImmediate;
1972
- } catch (_err) {
1973
- enqueueTaskImpl = function(callback) {
1974
- {
1975
- if (didWarnAboutMessageChannel === false) {
1976
- didWarnAboutMessageChannel = true;
1977
- if (typeof MessageChannel === "undefined") {
1978
- error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning.");
1979
- }
1980
- }
1981
- }
1982
- var channel = new MessageChannel();
1983
- channel.port1.onmessage = callback;
1984
- channel.port2.postMessage(void 0);
1985
- };
1986
- }
1987
- }
1988
- return enqueueTaskImpl(task);
1989
- }
1990
- var actScopeDepth = 0;
1991
- var didWarnNoAwaitAct = false;
1992
- function act(callback) {
1993
- {
1994
- var prevActScopeDepth = actScopeDepth;
1995
- actScopeDepth++;
1996
- if (ReactCurrentActQueue.current === null) {
1997
- ReactCurrentActQueue.current = [];
1998
- }
1999
- var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;
2000
- var result;
2001
- try {
2002
- ReactCurrentActQueue.isBatchingLegacy = true;
2003
- result = callback();
2004
- if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
2005
- var queue = ReactCurrentActQueue.current;
2006
- if (queue !== null) {
2007
- ReactCurrentActQueue.didScheduleLegacyUpdate = false;
2008
- flushActQueue(queue);
2009
- }
2010
- }
2011
- } catch (error2) {
2012
- popActScope(prevActScopeDepth);
2013
- throw error2;
2014
- } finally {
2015
- ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
2016
- }
2017
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
2018
- var thenableResult = result;
2019
- var wasAwaited = false;
2020
- var thenable = {
2021
- then: function(resolve, reject) {
2022
- wasAwaited = true;
2023
- thenableResult.then(function(returnValue2) {
2024
- popActScope(prevActScopeDepth);
2025
- if (actScopeDepth === 0) {
2026
- recursivelyFlushAsyncActWork(returnValue2, resolve, reject);
2027
- } else {
2028
- resolve(returnValue2);
2029
- }
2030
- }, function(error2) {
2031
- popActScope(prevActScopeDepth);
2032
- reject(error2);
2033
- });
2034
- }
2035
- };
2036
- {
2037
- if (!didWarnNoAwaitAct && typeof Promise !== "undefined") {
2038
- Promise.resolve().then(function() {
2039
- }).then(function() {
2040
- if (!wasAwaited) {
2041
- didWarnNoAwaitAct = true;
2042
- error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);");
2043
- }
2044
- });
2045
- }
2046
- }
2047
- return thenable;
2048
- } else {
2049
- var returnValue = result;
2050
- popActScope(prevActScopeDepth);
2051
- if (actScopeDepth === 0) {
2052
- var _queue = ReactCurrentActQueue.current;
2053
- if (_queue !== null) {
2054
- flushActQueue(_queue);
2055
- ReactCurrentActQueue.current = null;
2056
- }
2057
- var _thenable = {
2058
- then: function(resolve, reject) {
2059
- if (ReactCurrentActQueue.current === null) {
2060
- ReactCurrentActQueue.current = [];
2061
- recursivelyFlushAsyncActWork(returnValue, resolve, reject);
2062
- } else {
2063
- resolve(returnValue);
2064
- }
2065
- }
2066
- };
2067
- return _thenable;
2068
- } else {
2069
- var _thenable2 = {
2070
- then: function(resolve, reject) {
2071
- resolve(returnValue);
2072
- }
2073
- };
2074
- return _thenable2;
2075
- }
2076
- }
2077
- }
2078
- }
2079
- function popActScope(prevActScopeDepth) {
2080
- {
2081
- if (prevActScopeDepth !== actScopeDepth - 1) {
2082
- error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ");
2083
- }
2084
- actScopeDepth = prevActScopeDepth;
2085
- }
2086
- }
2087
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
2088
- {
2089
- var queue = ReactCurrentActQueue.current;
2090
- if (queue !== null) {
2091
- try {
2092
- flushActQueue(queue);
2093
- enqueueTask(function() {
2094
- if (queue.length === 0) {
2095
- ReactCurrentActQueue.current = null;
2096
- resolve(returnValue);
2097
- } else {
2098
- recursivelyFlushAsyncActWork(returnValue, resolve, reject);
2099
- }
2100
- });
2101
- } catch (error2) {
2102
- reject(error2);
2103
- }
2104
- } else {
2105
- resolve(returnValue);
2106
- }
2107
- }
2108
- }
2109
- var isFlushing = false;
2110
- function flushActQueue(queue) {
2111
- {
2112
- if (!isFlushing) {
2113
- isFlushing = true;
2114
- var i = 0;
2115
- try {
2116
- for (; i < queue.length; i++) {
2117
- var callback = queue[i];
2118
- do {
2119
- callback = callback(true);
2120
- } while (callback !== null);
2121
- }
2122
- queue.length = 0;
2123
- } catch (error2) {
2124
- queue = queue.slice(i + 1);
2125
- throw error2;
2126
- } finally {
2127
- isFlushing = false;
2128
- }
2129
- }
2130
- }
2131
- }
2132
- var createElement$1 = createElementWithValidation;
2133
- var cloneElement$1 = cloneElementWithValidation;
2134
- var createFactory = createFactoryWithValidation;
2135
- var Children = {
2136
- map: mapChildren,
2137
- forEach: forEachChildren,
2138
- count: countChildren,
2139
- toArray,
2140
- only: onlyChild
2141
- };
2142
- exports.Children = Children;
2143
- exports.Component = Component;
2144
- exports.Fragment = REACT_FRAGMENT_TYPE;
2145
- exports.Profiler = REACT_PROFILER_TYPE;
2146
- exports.PureComponent = PureComponent;
2147
- exports.StrictMode = REACT_STRICT_MODE_TYPE;
2148
- exports.Suspense = REACT_SUSPENSE_TYPE;
2149
- exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
2150
- exports.act = act;
2151
- exports.cloneElement = cloneElement$1;
2152
- exports.createContext = createContext;
2153
- exports.createElement = createElement$1;
2154
- exports.createFactory = createFactory;
2155
- exports.createRef = createRef;
2156
- exports.forwardRef = forwardRef;
2157
- exports.isValidElement = isValidElement;
2158
- exports.lazy = lazy;
2159
- exports.memo = memo;
2160
- exports.startTransition = startTransition;
2161
- exports.unstable_act = act;
2162
- exports.useCallback = useCallback;
2163
- exports.useContext = useContext;
2164
- exports.useDebugValue = useDebugValue;
2165
- exports.useDeferredValue = useDeferredValue;
2166
- exports.useEffect = useEffect;
2167
- exports.useId = useId;
2168
- exports.useImperativeHandle = useImperativeHandle;
2169
- exports.useInsertionEffect = useInsertionEffect;
2170
- exports.useLayoutEffect = useLayoutEffect;
2171
- exports.useMemo = useMemo;
2172
- exports.useReducer = useReducer;
2173
- exports.useRef = useRef;
2174
- exports.useState = useState;
2175
- exports.useSyncExternalStore = useSyncExternalStore;
2176
- exports.useTransition = useTransition;
2177
- exports.version = ReactVersion;
2178
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
2179
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
2180
- }
2181
- })();
2182
- }
2183
- }
2184
- });
2185
-
2186
- // ../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
2187
- var require_react = __commonJS({
2188
- "../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"(exports, module) {
2189
- "use strict";
2190
- init_esm_shims();
2191
- if (process.env.NODE_ENV === "production") {
2192
- module.exports = require_react_production_min();
2193
- } else {
2194
- module.exports = require_react_development();
2195
- }
2196
- }
2197
- });
2198
-
2199
- // src/components/Schema.tsx
2200
- init_esm_shims();
2201
- import { Oas as Oas6 } from "@kubb/plugin-oas/components";
2202
- import { Const as Const2, File as File6, Type as Type2, useApp as useApp6, useFile } from "@kubb/react";
2203
-
2204
- // ../plugin-ts/src/index.ts
2205
- init_esm_shims();
2206
-
2207
- // ../plugin-ts/src/plugin.ts
2208
- init_esm_shims();
2209
- import path from "node:path";
2210
- import { FileManager, PluginManager, createPlugin } from "@kubb/core";
2211
- import { camelCase, pascalCase } from "@kubb/core/transformers";
2212
- import { renderTemplate } from "@kubb/core/utils";
2213
- import { pluginOasName } from "@kubb/plugin-oas";
2214
-
2215
- // ../plugin-ts/src/OperationGenerator.tsx
2216
- init_esm_shims();
2217
- import { OperationGenerator as Generator2 } from "@kubb/plugin-oas";
2218
- import { Oas as Oas4 } from "@kubb/plugin-oas/components";
2219
- import { App as App2, createRoot as createRoot2 } from "@kubb/react";
2220
-
2221
- // ../plugin-ts/src/components/OasType.tsx
2222
- init_esm_shims();
2223
- import { useOas } from "@kubb/plugin-oas/hooks";
2224
- import { File, Type, useApp } from "@kubb/react";
2225
- import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
2226
- function Template({ name, typeName, api }) {
2227
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2228
- /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(api, void 0, 2)} as const` }),
2229
- /* @__PURE__ */ jsx("br", {}),
2230
- /* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `Infer<typeof ${name}>` }) })
2231
- ] });
2232
- }
2233
- var defaultTemplates = { default: Template };
2234
- function OasType({ name, typeName, Template: Template3 = defaultTemplates.default }) {
2235
- const oas = useOas();
2236
- return /* @__PURE__ */ jsx(Template3, { name, typeName, api: oas.api });
2237
- }
2238
- OasType.File = function({ name, typeName, templates = defaultTemplates }) {
2239
- const {
2240
- pluginManager,
2241
- plugin: { key: pluginKey }
2242
- } = useApp();
2243
- const file = pluginManager.getFile({ name, extName: ".ts", pluginKey });
2244
- const Template3 = templates.default;
2245
- return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
2246
- /* @__PURE__ */ jsx(File.Import, { name: ["Infer"], path: "@kubb/oas", isTypeOnly: true }),
2247
- /* @__PURE__ */ jsx(OasType, { Template: Template3, name, typeName })
2248
- ] });
2249
- };
2250
- OasType.templates = defaultTemplates;
2251
-
2252
- // ../plugin-ts/src/components/OperationSchema.tsx
2253
- init_esm_shims();
2254
- import transformers3 from "@kubb/core/transformers";
2255
- import { print as print2 } from "@kubb/parser-ts";
2256
- import * as factory3 from "@kubb/parser-ts/factory";
2257
- import { Oas as Oas3 } from "@kubb/plugin-oas/components";
2258
- import { useOas as useOas2, useOperation, useOperationManager } from "@kubb/plugin-oas/hooks";
2259
- import { File as File3, useApp as useApp3 } from "@kubb/react";
2260
-
2261
- // ../plugin-ts/src/SchemaGenerator.tsx
2262
- init_esm_shims();
2263
- import { SchemaGenerator as Generator } from "@kubb/plugin-oas";
2264
- import { Oas as Oas2 } from "@kubb/plugin-oas/components";
2265
- import { App, createRoot } from "@kubb/react";
2266
-
2267
- // ../plugin-ts/src/components/Schema.tsx
2268
- init_esm_shims();
2269
- var import_react3 = __toESM(require_react(), 1);
2270
- import { Oas } from "@kubb/plugin-oas/components";
2271
- import { File as File2, useApp as useApp2 } from "@kubb/react";
2272
- import transformers2 from "@kubb/core/transformers";
2273
- import { print } from "@kubb/parser-ts";
2274
- import * as factory2 from "@kubb/parser-ts/factory";
2275
- import { SchemaGenerator, schemaKeywords as schemaKeywords2 } from "@kubb/plugin-oas";
2276
- import { useSchema } from "@kubb/plugin-oas/hooks";
2277
-
2278
- // ../plugin-ts/src/parser/index.ts
2279
- init_esm_shims();
2280
- import transformers from "@kubb/core/transformers";
2281
- import * as factory from "@kubb/parser-ts/factory";
2282
- import { isKeyword, schemaKeywords } from "@kubb/plugin-oas";
2283
- var typeKeywordMapper = {
2284
- any: () => factory.keywordTypeNodes.any,
2285
- unknown: () => factory.keywordTypeNodes.unknown,
2286
- number: () => factory.keywordTypeNodes.number,
2287
- integer: () => factory.keywordTypeNodes.number,
2288
- object: (nodes) => {
2289
- if (!nodes || !nodes.length) {
2290
- return factory.keywordTypeNodes.object;
2291
- }
2292
- return factory.createTypeLiteralNode(nodes);
2293
- },
2294
- string: () => factory.keywordTypeNodes.string,
2295
- boolean: () => factory.keywordTypeNodes.boolean,
2296
- undefined: () => factory.keywordTypeNodes.undefined,
2297
- nullable: void 0,
2298
- null: () => factory.keywordTypeNodes.null,
2299
- nullish: void 0,
2300
- array: (nodes) => {
2301
- if (!nodes) {
2302
- return void 0;
2303
- }
2304
- return factory.createArrayDeclaration({ nodes });
2305
- },
2306
- tuple: (nodes) => {
2307
- if (!nodes) {
2308
- return void 0;
2309
- }
2310
- return factory.createTupleTypeNode(nodes);
2311
- },
2312
- enum: (name) => {
2313
- if (!name) {
2314
- return void 0;
2315
- }
2316
- return factory.createTypeReferenceNode(name, void 0);
2317
- },
2318
- union: (nodes) => {
2319
- if (!nodes) {
2320
- return void 0;
2321
- }
2322
- return factory.createUnionDeclaration({
2323
- withParentheses: true,
2324
- nodes
2325
- });
2326
- },
2327
- const: (name, format) => {
2328
- if (!name) {
2329
- return void 0;
2330
- }
2331
- if (format === "number") {
2332
- return factory.createLiteralTypeNode(factory.createNumericLiteral(name));
2333
- }
2334
- return factory.createLiteralTypeNode(factory.createStringLiteral(name.toString()));
2335
- },
2336
- datetime: () => factory.keywordTypeNodes.string,
2337
- date: (type = "string") => type === "string" ? factory.keywordTypeNodes.string : factory.createTypeReferenceNode(factory.createIdentifier("Date")),
2338
- time: (type = "string") => type === "string" ? factory.keywordTypeNodes.string : factory.createTypeReferenceNode(factory.createIdentifier("Date")),
2339
- uuid: void 0,
2340
- url: void 0,
2341
- strict: void 0,
2342
- default: void 0,
2343
- and: (nodes) => {
2344
- if (!nodes) {
2345
- return void 0;
2346
- }
2347
- return factory.createIntersectionDeclaration({
2348
- withParentheses: true,
2349
- nodes
2350
- });
2351
- },
2352
- describe: void 0,
2353
- min: void 0,
2354
- max: void 0,
2355
- optional: void 0,
2356
- matches: void 0,
2357
- email: void 0,
2358
- firstName: void 0,
2359
- lastName: void 0,
2360
- password: void 0,
2361
- phone: void 0,
2362
- readOnly: void 0,
2363
- ref: (propertyName) => {
2364
- if (!propertyName) {
2365
- return void 0;
2366
- }
2367
- return factory.createTypeReferenceNode(propertyName, void 0);
2368
- },
2369
- blob: () => factory.createTypeReferenceNode("Blob", []),
2370
- deprecated: void 0,
2371
- example: void 0,
2372
- schema: void 0,
2373
- catchall: void 0,
2374
- name: void 0
2375
- };
2376
- function parse(parent, current, options) {
2377
- const value = typeKeywordMapper[current.keyword];
2378
- if (!value) {
2379
- return void 0;
2380
- }
2381
- if (isKeyword(current, schemaKeywords.union)) {
2382
- return typeKeywordMapper.union(current.args.map((schema) => parse(current, schema, options)).filter(Boolean));
2383
- }
2384
- if (isKeyword(current, schemaKeywords.and)) {
2385
- return typeKeywordMapper.and(current.args.map((schema) => parse(current, schema, options)).filter(Boolean));
2386
- }
2387
- if (isKeyword(current, schemaKeywords.array)) {
2388
- return typeKeywordMapper.array(current.args.items.map((schema) => parse(current, schema, options)).filter(Boolean));
2389
- }
2390
- if (isKeyword(current, schemaKeywords.enum)) {
2391
- return typeKeywordMapper.enum(current.args.typeName);
2392
- }
2393
- if (isKeyword(current, schemaKeywords.ref)) {
2394
- return typeKeywordMapper.ref(current.args.name);
2395
- }
2396
- if (isKeyword(current, schemaKeywords.blob)) {
2397
- return value();
2398
- }
2399
- if (isKeyword(current, schemaKeywords.tuple)) {
2400
- return typeKeywordMapper.tuple(current.args.items.map((schema) => parse(current, schema, options)).filter(Boolean));
2401
- }
2402
- if (isKeyword(current, schemaKeywords.const)) {
2403
- return typeKeywordMapper.const(current.args.name, current.args.format);
2404
- }
2405
- if (isKeyword(current, schemaKeywords.object)) {
2406
- const properties = Object.entries(current.args?.properties || {}).filter((item) => {
2407
- const schemas = item[1];
2408
- return schemas && typeof schemas.map === "function";
2409
- }).map(([name, schemas]) => {
2410
- const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name);
2411
- const mappedName = nameSchema?.args || name;
2412
- if (options.mapper?.[mappedName]) {
2413
- return options.mapper?.[mappedName];
2414
- }
2415
- const isNullish = schemas.some((schema) => schema.keyword === schemaKeywords.nullish);
2416
- const isNullable = schemas.some((schema) => schema.keyword === schemaKeywords.nullable);
2417
- const isOptional = schemas.some((schema) => schema.keyword === schemaKeywords.optional);
2418
- const isReadonly = schemas.some((schema) => schema.keyword === schemaKeywords.readOnly);
2419
- const describeSchema = schemas.find((schema) => schema.keyword === schemaKeywords.describe);
2420
- const deprecatedSchema = schemas.find((schema) => schema.keyword === schemaKeywords.deprecated);
2421
- const defaultSchema = schemas.find((schema) => schema.keyword === schemaKeywords.default);
2422
- const exampleSchema = schemas.find((schema) => schema.keyword === schemaKeywords.example);
2423
- const schemaSchema = schemas.find((schema) => schema.keyword === schemaKeywords.schema);
2424
- let type = schemas.map((schema) => parse(current, schema, options)).filter(Boolean)[0];
2425
- if (isNullable) {
2426
- type = factory.createUnionDeclaration({
2427
- nodes: [type, factory.keywordTypeNodes.null]
2428
- });
2429
- }
2430
- if (isNullish && ["undefined", "questionTokenAndUndefined"].includes(options.optionalType)) {
2431
- type = factory.createUnionDeclaration({
2432
- nodes: [type, factory.keywordTypeNodes.undefined]
2433
- });
2434
- }
2435
- if (isOptional && ["undefined", "questionTokenAndUndefined"].includes(options.optionalType)) {
2436
- type = factory.createUnionDeclaration({
2437
- nodes: [type, factory.keywordTypeNodes.undefined]
2438
- });
2439
- }
2440
- const propertySignature = factory.createPropertySignature({
2441
- questionToken: isOptional || isNullish ? ["questionToken", "questionTokenAndUndefined"].includes(options.optionalType) : false,
2442
- name: mappedName,
2443
- type,
2444
- readOnly: isReadonly
2445
- });
2446
- return factory.appendJSDocToNode({
2447
- node: propertySignature,
2448
- comments: [
2449
- describeSchema ? `@description ${transformers.jsStringEscape(describeSchema.args)}` : void 0,
2450
- deprecatedSchema ? "@deprecated" : void 0,
2451
- defaultSchema ? `@default ${defaultSchema.args}` : void 0,
2452
- exampleSchema ? `@example ${exampleSchema.args}` : void 0,
2453
- schemaSchema?.args?.type || schemaSchema?.args?.format ? [`@type ${schemaSchema?.args?.type || "unknown"}${!isOptional ? "" : " | undefined"}`, schemaSchema?.args?.format].filter(Boolean).join(", ") : void 0
2454
- ].filter(Boolean)
2455
- });
2456
- });
2457
- const additionalProperties = current.args?.additionalProperties?.length ? factory.createIndexSignature(
2458
- current.args.additionalProperties.map((schema) => parse(current, schema, options)).filter(Boolean).at(0)
2459
- ) : void 0;
2460
- return typeKeywordMapper.object([...properties, additionalProperties].filter(Boolean));
2461
- }
2462
- if (isKeyword(current, schemaKeywords.datetime)) {
2463
- return typeKeywordMapper.datetime();
2464
- }
2465
- if (isKeyword(current, schemaKeywords.date)) {
2466
- return typeKeywordMapper.date(current.args.type);
2467
- }
2468
- if (isKeyword(current, schemaKeywords.time)) {
2469
- return typeKeywordMapper.time(current.args.type);
2470
- }
2471
- if (current.keyword in typeKeywordMapper) {
2472
- return value();
2473
- }
2474
- return void 0;
2475
- }
2476
-
2477
- // ../plugin-ts/src/components/Schema.tsx
2478
- import { jsx as jsx2, jsxs as jsxs2 } from "@kubb/react/jsx-runtime";
2479
- function Schema(props) {
2480
- const { keysToOmit, description } = props;
2481
- const { tree, name } = useSchema();
2482
- const {
2483
- pluginManager,
2484
- plugin: {
2485
- options: { mapper, enumType, optionalType }
2486
- }
2487
- } = useApp2();
2488
- if (enumType === "asPascalConst") {
2489
- pluginManager.logger.emit("warning", `enumType '${enumType}' is deprecated`);
2490
- }
2491
- const resolvedName = pluginManager.resolveName({
2492
- name,
2493
- pluginKey: [pluginTsName],
2494
- type: "function"
2495
- });
2496
- const typeName = pluginManager.resolveName({
2497
- name,
2498
- pluginKey: [pluginTsName],
2499
- type: "type"
2500
- });
2501
- const typeNodes = [];
2502
- if (!tree.length) {
2503
- return "";
2504
- }
2505
- const isNullish = tree.some((item) => item.keyword === schemaKeywords2.nullish);
2506
- const isNullable = tree.some((item) => item.keyword === schemaKeywords2.nullable);
2507
- const isOptional = tree.some((item) => item.keyword === schemaKeywords2.optional);
2508
- let type = tree.map(
2509
- (schema) => parse(void 0, schema, {
2510
- name: resolvedName,
2511
- typeName,
2512
- description,
2513
- keysToOmit,
2514
- optionalType,
2515
- enumType,
2516
- mapper
2517
- })
2518
- ).filter(Boolean).at(0) || typeKeywordMapper.undefined();
2519
- if (isNullable) {
2520
- type = factory2.createUnionDeclaration({
2521
- nodes: [type, factory2.keywordTypeNodes.null]
2522
- });
2523
- }
2524
- if (isNullish && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) {
2525
- type = factory2.createUnionDeclaration({
2526
- nodes: [type, factory2.keywordTypeNodes.undefined]
2527
- });
2528
- }
2529
- if (isOptional && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) {
2530
- type = factory2.createUnionDeclaration({
2531
- nodes: [type, factory2.keywordTypeNodes.undefined]
2532
- });
2533
- }
2534
- const node = factory2.createTypeAliasDeclaration({
2535
- modifiers: [factory2.modifiers.export],
2536
- name: resolvedName,
2537
- type: keysToOmit?.length ? factory2.createOmitDeclaration({
2538
- keys: keysToOmit,
2539
- type,
2540
- nonNullable: true
2541
- }) : type
2542
- });
2543
- const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords2.enum);
2544
- const enums = enumSchemas.map((enumSchema) => {
2545
- const name2 = enumType === "asPascalConst" ? transformers2.pascalCase(enumSchema.args.name) : transformers2.camelCase(enumSchema.args.name);
2546
- const typeName2 = enumSchema.args.typeName;
2547
- const [nameNode, typeNode] = factory2.createEnumDeclaration({
2548
- name: name2,
2549
- typeName: typeName2,
2550
- enums: enumSchema.args.items.map((item) => item.value === void 0 ? void 0 : [transformers2.trimQuotes(item.name?.toString()), item.value]).filter(Boolean),
2551
- type: enumType
2552
- });
2553
- return {
2554
- nameNode,
2555
- typeNode,
2556
- name: name2,
2557
- typeName: typeName2
2558
- };
2559
- });
2560
- typeNodes.push(
2561
- factory2.appendJSDocToNode({
2562
- node,
2563
- comments: [description ? `@description ${transformers2.jsStringEscape(description)}` : void 0].filter(Boolean)
2564
- })
2565
- );
2566
- return /* @__PURE__ */ jsxs2(import_react3.Fragment, { children: [
2567
- enums.map(({ name: name2, nameNode, typeName: typeName2, typeNode }, index) => /* @__PURE__ */ jsxs2(import_react3.Fragment, { children: [
2568
- nameNode && /* @__PURE__ */ jsx2(File2.Source, { name: name2, isExportable: true, isIndexable: true, children: print(nameNode) }),
2569
- /* @__PURE__ */ jsx2(File2.Source, { name: typeName2, isIndexable: true, isExportable: ["enum", "asConst", "constEnum", "literal", void 0].includes(enumType), isTypeOnly: true, children: print(typeNode) })
2570
- ] }, [name2, nameNode].join("-"))),
2571
- enums.every((item) => item.typeName !== resolvedName) && /* @__PURE__ */ jsx2(File2.Source, { name: typeName, isTypeOnly: true, isExportable: true, isIndexable: true, children: print(typeNodes) })
2572
- ] });
2573
- }
2574
- Schema.File = function({}) {
2575
- const { pluginManager } = useApp2();
2576
- const { schema } = useSchema();
2577
- return /* @__PURE__ */ jsx2(Oas.Schema.File, { isTypeOnly: true, output: pluginManager.config.output.path, children: /* @__PURE__ */ jsx2(Schema, { description: schema?.description }) });
2578
- };
2579
-
2580
- // ../plugin-ts/src/SchemaGenerator.tsx
2581
- import { jsx as jsx3 } from "@kubb/react/jsx-runtime";
2582
- var SchemaGenerator2 = class extends Generator {
2583
- async schema(name, schema, options) {
2584
- const { oas, pluginManager, plugin, mode, output } = this.context;
2585
- const root = createRoot({
2586
- logger: pluginManager.logger
2587
- });
2588
- const tree = this.parse({ schema, name });
2589
- root.render(
2590
- /* @__PURE__ */ jsx3(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx3(Oas2, { oas, children: /* @__PURE__ */ jsx3(Oas2.Schema, { name, value: schema, tree, children: /* @__PURE__ */ jsx3(Schema.File, {}) }) }) })
2591
- );
2592
- return root.files;
2593
- }
2594
- };
2595
-
2596
- // ../plugin-ts/src/components/OperationSchema.tsx
2597
- import { jsx as jsx4, jsxs as jsxs3 } from "@kubb/react/jsx-runtime";
2598
- function printCombinedSchema({
2599
- name,
2600
- operation,
2601
- schemas,
2602
- pluginManager
2603
- }) {
2604
- const properties = {};
2605
- if (schemas.response) {
2606
- const identifier = pluginManager.resolveName({
2607
- name: schemas.response.name,
2608
- pluginKey: [pluginTsName],
2609
- type: "function"
2610
- });
2611
- properties["response"] = factory3.createTypeReferenceNode(factory3.createIdentifier(identifier), void 0);
2612
- }
2613
- if (schemas.request) {
2614
- const identifier = pluginManager.resolveName({
2615
- name: schemas.request.name,
2616
- pluginKey: [pluginTsName],
2617
- type: "function"
2618
- });
2619
- properties["request"] = factory3.createTypeReferenceNode(factory3.createIdentifier(identifier), void 0);
2620
- }
2621
- if (schemas.pathParams) {
2622
- const identifier = pluginManager.resolveName({
2623
- name: schemas.pathParams.name,
2624
- pluginKey: [pluginTsName],
2625
- type: "function"
2626
- });
2627
- properties["pathParams"] = factory3.createTypeReferenceNode(factory3.createIdentifier(identifier), void 0);
2628
- }
2629
- if (schemas.queryParams) {
2630
- const identifier = pluginManager.resolveName({
2631
- name: schemas.queryParams.name,
2632
- pluginKey: [pluginTsName],
2633
- type: "function"
2634
- });
2635
- properties["queryParams"] = factory3.createTypeReferenceNode(factory3.createIdentifier(identifier), void 0);
2636
- }
2637
- if (schemas.headerParams) {
2638
- const identifier = pluginManager.resolveName({
2639
- name: schemas.headerParams.name,
2640
- pluginKey: [pluginTsName],
2641
- type: "function"
2642
- });
2643
- properties["headerParams"] = factory3.createTypeReferenceNode(factory3.createIdentifier(identifier), void 0);
2644
- }
2645
- if (schemas.errors) {
2646
- properties["errors"] = factory3.createUnionDeclaration({
2647
- nodes: schemas.errors.map((error) => {
2648
- const identifier = pluginManager.resolveName({
2649
- name: error.name,
2650
- pluginKey: [pluginTsName],
2651
- type: "function"
2652
- });
2653
- return factory3.createTypeReferenceNode(factory3.createIdentifier(identifier), void 0);
2654
- })
2655
- });
2656
- }
2657
- const namespaceNode = factory3.createTypeAliasDeclaration({
2658
- name,
2659
- type: factory3.createTypeLiteralNode(
2660
- Object.keys(properties).map((key) => {
2661
- const type = properties[key];
2662
- if (!type) {
2663
- return void 0;
2664
- }
2665
- return factory3.createPropertySignature({
2666
- name: transformers3.pascalCase(key),
2667
- type
2668
- });
2669
- }).filter(Boolean)
2670
- ),
2671
- modifiers: [factory3.modifiers.export]
2672
- });
2673
- return print2(namespaceNode);
2674
- }
2675
- function OperationSchema({ keysToOmit, description }) {
2676
- return /* @__PURE__ */ jsx4(Schema, { keysToOmit, description });
2677
- }
2678
- OperationSchema.File = function({}) {
2679
- const { pluginManager, plugin, mode } = useApp3();
2680
- const oas = useOas2();
2681
- const { getSchemas, getFile, getName } = useOperationManager();
2682
- const operation = useOperation();
2683
- const file = getFile(operation);
2684
- const schemas = getSchemas(operation);
2685
- const factoryName = getName(operation, { type: "type" });
2686
- const generator = new SchemaGenerator2(plugin.options, {
2687
- oas,
2688
- plugin,
2689
- pluginManager,
2690
- mode,
2691
- override: plugin.options.override
2692
- });
2693
- const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
2694
- const mapItem = ({ name, schema, description, keysToOmit, ...options }, i) => {
2695
- const tree = generator.parse({ schema, name });
2696
- return /* @__PURE__ */ jsxs3(Oas3.Schema, { name, value: schema, tree, children: [
2697
- mode === "split" && /* @__PURE__ */ jsx4(Oas3.Schema.Imports, { isTypeOnly: true }),
2698
- /* @__PURE__ */ jsx4(OperationSchema, { description, keysToOmit })
2699
- ] }, i);
2700
- };
2701
- const combinedSchemaName = operation.method === "get" ? `${factoryName}Query` : `${factoryName}Mutation`;
2702
- return /* @__PURE__ */ jsxs3(File3, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
2703
- items.map(mapItem),
2704
- /* @__PURE__ */ jsx4(File3.Source, { name: combinedSchemaName, isExportable: true, isIndexable: true, isTypeOnly: true, children: printCombinedSchema({ name: combinedSchemaName, operation, schemas, pluginManager }) })
2705
- ] });
2706
- };
2707
-
2708
- // ../plugin-ts/src/OperationGenerator.tsx
2709
- import { jsx as jsx5 } from "@kubb/react/jsx-runtime";
2710
- var OperationGenerator = class extends Generator2 {
2711
- async all(operations) {
2712
- const { oas, pluginManager, plugin, mode } = this.context;
2713
- const root = createRoot2({
2714
- logger: pluginManager.logger
2715
- });
2716
- root.render(
2717
- /* @__PURE__ */ jsx5(App2, { pluginManager, plugin, mode, children: /* @__PURE__ */ jsx5(Oas4, { oas, operations, generator: this, children: plugin.options.oasType && /* @__PURE__ */ jsx5(OasType.File, { name: "oas", typeName: "Oas" }) }) })
2718
- );
2719
- return root.files;
2720
- }
2721
- async operation(operation, options) {
2722
- const { oas, pluginManager, plugin, mode } = this.context;
2723
- const root = createRoot2({
2724
- logger: pluginManager.logger
2725
- });
2726
- root.render(
2727
- /* @__PURE__ */ jsx5(App2, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx5(Oas4, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ jsx5(Oas4.Operation, { operation, children: /* @__PURE__ */ jsx5(OperationSchema.File, {}) }) }) })
2728
- );
2729
- return root.files;
2730
- }
2731
- };
2732
-
2733
- // ../plugin-ts/src/plugin.ts
2734
- var pluginTsName = "plugin-ts";
2735
- var pluginTs = createPlugin((options) => {
2736
- const {
2737
- output = { path: "types" },
2738
- group,
2739
- exclude = [],
2740
- include,
2741
- override = [],
2742
- enumType = "asConst",
2743
- enumSuffix = "",
2744
- dateType = "string",
2745
- unknownType = "any",
2746
- optionalType = "questionToken",
2747
- transformers: transformers7 = {},
2748
- oasType = false,
2749
- mapper = {}
2750
- } = options;
2751
- const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
2752
- return {
2753
- name: pluginTsName,
2754
- output: {
2755
- exportType: "barrelNamed",
2756
- ...output
2757
- },
2758
- options: {
2759
- extName: output.extName,
2760
- transformers: transformers7,
2761
- dateType,
2762
- optionalType,
2763
- oasType,
2764
- enumType,
2765
- enumSuffix,
2766
- // keep the used enumnames between SchemaGenerator and OperationGenerator per plugin(pluginKey)
2767
- usedEnumNames: {},
2768
- unknownType,
2769
- override,
2770
- mapper
2771
- },
2772
- pre: [pluginOasName],
2773
- resolvePath(baseName, pathMode, options2) {
2774
- const root = path.resolve(this.config.root, this.config.output.path);
2775
- const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
2776
- if (mode === "single") {
2777
- return path.resolve(root, output.path);
2778
- }
2779
- if (options2?.tag && group?.type === "tag") {
2780
- const tag = camelCase(options2.tag);
2781
- return path.resolve(root, renderTemplate(template, { tag }), baseName);
2782
- }
2783
- return path.resolve(root, output.path, baseName);
2784
- },
2785
- resolveName(name, type) {
2786
- const resolvedName = pascalCase(name, { isFile: type === "file" });
2787
- if (type) {
2788
- return transformers7?.name?.(resolvedName, type) || resolvedName;
2789
- }
2790
- return resolvedName;
2791
- },
2792
- async buildStart() {
2793
- const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
2794
- const oas = await swaggerPlugin.context.getOas();
2795
- const root = path.resolve(this.config.root, this.config.output.path);
2796
- const mode = FileManager.getMode(path.resolve(root, output.path));
2797
- const schemaGenerator = new SchemaGenerator2(this.plugin.options, {
2798
- oas,
2799
- pluginManager: this.pluginManager,
2800
- plugin: this.plugin,
2801
- contentType: swaggerPlugin.context.contentType,
2802
- include: void 0,
2803
- override,
2804
- mode,
2805
- output: output.path
2806
- });
2807
- const schemaFiles = await schemaGenerator.build();
2808
- await this.addFile(...schemaFiles);
2809
- const operationGenerator = new OperationGenerator(this.plugin.options, {
2810
- oas,
2811
- pluginManager: this.pluginManager,
2812
- plugin: this.plugin,
2813
- contentType: swaggerPlugin.context.contentType,
2814
- exclude,
2815
- include,
2816
- override,
2817
- mode
2818
- });
2819
- const operationFiles = await operationGenerator.build();
2820
- await this.addFile(...operationFiles);
2821
- if (this.config.output.exportType) {
2822
- const barrelFiles = await this.fileManager.getBarrelFiles({
2823
- root,
2824
- output,
2825
- files: this.fileManager.files,
2826
- meta: {
2827
- pluginKey: this.plugin.key
2828
- },
2829
- logger: this.logger
2830
- });
2831
- await this.addFile(...barrelFiles);
2832
- }
2833
- }
2834
- };
2835
- });
2836
-
2837
- // src/components/Schema.tsx
2838
- import transformers6 from "@kubb/core/transformers";
2839
- import { isKeyword as isKeyword3, schemaKeywords as schemaKeywords5 } from "@kubb/plugin-oas";
2840
- import { useSchema as useSchema2 } from "@kubb/plugin-oas/hooks";
2841
-
2842
- // src/parser/index.ts
2843
- init_esm_shims();
2844
- import transformers4 from "@kubb/core/transformers";
2845
- import { isKeyword as isKeyword2, schemaKeywords as schemaKeywords3 } from "@kubb/plugin-oas";
2846
- var zodKeywordMapper = {
2847
- any: () => "z.any()",
2848
- unknown: () => "z.unknown()",
2849
- number: (coercion, min, max) => {
2850
- return [coercion ? "z.coerce.number()" : "z.number()", min !== void 0 ? `.min(${min})` : void 0, max !== void 0 ? `.max(${max})` : void 0].filter(Boolean).join("");
2851
- },
2852
- integer: (coercion, min, max) => {
2853
- return [
2854
- coercion ? "z.coerce.number().int()" : "z.number().int()",
2855
- min !== void 0 ? `.min(${min})` : void 0,
2856
- max !== void 0 ? `.max(${max})` : void 0
2857
- ].filter(Boolean).join("");
2858
- },
2859
- object: (value) => `z.object({${value}})`,
2860
- string: (coercion, min, max) => {
2861
- return [coercion ? "z.coerce.string()" : "z.string()", min !== void 0 ? `.min(${min})` : void 0, max !== void 0 ? `.max(${max})` : void 0].filter(Boolean).join("");
2862
- },
2863
- boolean: () => "z.boolean()",
2864
- undefined: () => "z.undefined()",
2865
- nullable: () => ".nullable()",
2866
- null: () => "z.null()",
2867
- nullish: () => ".nullish()",
2868
- array: (items = [], min, max) => {
2869
- return [`z.array(${items?.join("")})`, min !== void 0 ? `.min(${min})` : void 0, max !== void 0 ? `.max(${max})` : void 0].filter(Boolean).join("");
2870
- },
2871
- tuple: (items = []) => `z.tuple([${items?.join(", ")}])`,
2872
- enum: (items = []) => `z.enum([${items?.join(", ")}])`,
2873
- union: (items = []) => `z.union([${items?.join(", ")}])`,
2874
- const: (value) => `z.literal(${value ?? ""})`,
2875
- /**
2876
- * ISO 8601
2877
- */
2878
- datetime: (offset = false, local = false) => {
2879
- if (offset) {
2880
- return `z.string().datetime({ offset: ${offset} })`;
2881
- }
2882
- if (local) {
2883
- return `z.string().datetime({ local: ${local} })`;
2884
- }
2885
- return "z.string().datetime()";
2886
- },
2887
- /**
2888
- * Type `'date'` Date
2889
- * Type `'string'` ISO date format (YYYY-MM-DD)
2890
- * @default ISO date format (YYYY-MM-DD)
2891
- */
2892
- date: (type = "string", coercion) => {
2893
- if (type === "string") {
2894
- return "z.string().date()";
2895
- }
2896
- if (coercion) {
2897
- return "z.coerce.date()";
2898
- }
2899
- return "z.date()";
2900
- },
2901
- /**
2902
- * Type `'date'` Date
2903
- * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])
2904
- * @default ISO time format (HH:mm:ss[.SSSSSS])
2905
- */
2906
- time: (type = "string", coercion) => {
2907
- if (type === "string") {
2908
- return "z.string().time()";
2909
- }
2910
- if (coercion) {
2911
- return "z.coerce.date()";
2912
- }
2913
- return "z.date()";
2914
- },
2915
- uuid: () => ".uuid()",
2916
- url: () => ".url()",
2917
- strict: () => ".strict()",
2918
- default: (value) => `.default(${value ?? ""})`,
2919
- and: (items = []) => items?.map((item) => `.and(${item})`).join(""),
2920
- describe: (value = "") => `.describe(${value})`,
2921
- min: (value) => `.min(${value ?? ""})`,
2922
- max: (value) => `.max(${value ?? ""})`,
2923
- optional: () => ".optional()",
2924
- matches: (value = "") => `.regex(${value})`,
2925
- email: () => ".email()",
2926
- firstName: void 0,
2927
- lastName: void 0,
2928
- password: void 0,
2929
- phone: void 0,
2930
- readOnly: void 0,
2931
- ref: (value) => value ? `z.lazy(() => ${value})` : void 0,
2932
- blob: () => "z.string()",
2933
- deprecated: void 0,
2934
- example: void 0,
2935
- schema: void 0,
2936
- catchall: (value) => value ? `.catchall(${value})` : void 0,
2937
- name: void 0
2938
- };
2939
- function sort(items) {
2940
- const order = [
2941
- schemaKeywords3.string,
2942
- schemaKeywords3.datetime,
2943
- schemaKeywords3.date,
2944
- schemaKeywords3.time,
2945
- schemaKeywords3.tuple,
2946
- schemaKeywords3.number,
2947
- schemaKeywords3.object,
2948
- schemaKeywords3.enum,
2949
- schemaKeywords3.url,
2950
- schemaKeywords3.email,
2951
- schemaKeywords3.firstName,
2952
- schemaKeywords3.lastName,
2953
- schemaKeywords3.password,
2954
- schemaKeywords3.matches,
2955
- schemaKeywords3.uuid,
2956
- schemaKeywords3.min,
2957
- schemaKeywords3.max,
2958
- schemaKeywords3.default,
2959
- schemaKeywords3.describe,
2960
- schemaKeywords3.optional,
2961
- schemaKeywords3.nullable,
2962
- schemaKeywords3.nullish,
2963
- schemaKeywords3.null
2964
- ];
2965
- if (!items) {
2966
- return [];
2967
- }
2968
- return transformers4.orderBy(items, [(v) => order.indexOf(v.keyword)], ["asc"]);
2969
- }
2970
- function parse2(parent, current, options) {
2971
- const value = zodKeywordMapper[current.keyword];
2972
- if (!value) {
2973
- return void 0;
2974
- }
2975
- if (isKeyword2(current, schemaKeywords3.union)) {
2976
- if (Array.isArray(current.args) && current.args.length === 1) {
2977
- return parse2(parent, current.args[0], options);
2978
- }
2979
- if (Array.isArray(current.args) && !current.args.length) {
2980
- return "";
2981
- }
2982
- return zodKeywordMapper.union(
2983
- sort(current.args).map((schema) => parse2(current, schema, options)).filter(Boolean)
2984
- );
2985
- }
2986
- if (isKeyword2(current, schemaKeywords3.and)) {
2987
- const items = sort(current.args).filter((schema) => {
2988
- return ![schemaKeywords3.optional, schemaKeywords3.describe].includes(schema.keyword);
2989
- }).map((schema) => parse2(current, schema, options)).filter(Boolean);
2990
- return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`;
2991
- }
2992
- if (isKeyword2(current, schemaKeywords3.array)) {
2993
- return zodKeywordMapper.array(
2994
- sort(current.args.items).map((schemas) => parse2(current, schemas, options)).filter(Boolean),
2995
- current.args.min,
2996
- current.args.max
2997
- );
2998
- }
2999
- if (isKeyword2(current, schemaKeywords3.enum)) {
3000
- if (current.args.asConst) {
3001
- return zodKeywordMapper.union(
3002
- current.args.items.map((schema) => {
3003
- return parse2(
3004
- current,
3005
- {
3006
- keyword: schemaKeywords3.const,
3007
- args: schema
3008
- },
3009
- options
3010
- );
3011
- }).filter(Boolean)
3012
- );
3013
- }
3014
- return zodKeywordMapper.enum(
3015
- current.args.items.map((schema) => {
3016
- if (schema.format === "number") {
3017
- return transformers4.stringify(schema.value);
3018
- }
3019
- return transformers4.stringify(schema.value);
3020
- })
3021
- );
3022
- }
3023
- if (isKeyword2(current, schemaKeywords3.ref)) {
3024
- return zodKeywordMapper.ref(current.args?.name);
3025
- }
3026
- if (isKeyword2(current, schemaKeywords3.object)) {
3027
- const properties = Object.entries(current.args?.properties || {}).filter((item) => {
3028
- const schema = item[1];
3029
- return schema && typeof schema.map === "function";
3030
- }).map(([name, schemas]) => {
3031
- const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords3.name);
3032
- const mappedName = nameSchema?.args || name;
3033
- if (options.mapper?.[mappedName]) {
3034
- return `"${name}": ${options.mapper?.[mappedName]}`;
3035
- }
3036
- return `"${name}": ${sort(schemas).map((schema, array) => {
3037
- return parse2(current, schema, options);
3038
- }).filter(Boolean).join("")}`;
3039
- }).join(",");
3040
- const additionalProperties = current.args?.additionalProperties?.length ? current.args.additionalProperties.map((schema) => parse2(current, schema, options)).filter(Boolean).at(0) : void 0;
3041
- const text = [
3042
- zodKeywordMapper.object(properties),
3043
- current.args?.strict ? zodKeywordMapper.strict() : void 0,
3044
- additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : void 0
3045
- ].filter(Boolean);
3046
- return text.join("");
3047
- }
3048
- if (isKeyword2(current, schemaKeywords3.tuple)) {
3049
- return zodKeywordMapper.tuple(
3050
- sort(current.args.items).map((schema) => parse2(current, schema, options)).filter(Boolean)
3051
- );
3052
- }
3053
- if (isKeyword2(current, schemaKeywords3.const)) {
3054
- if (current.args.format === "number" && current.args.value !== void 0) {
3055
- return zodKeywordMapper.const(Number.parseInt(current.args.value?.toString()));
3056
- }
3057
- return zodKeywordMapper.const(transformers4.stringify(current.args.value));
3058
- }
3059
- if (isKeyword2(current, schemaKeywords3.matches)) {
3060
- if (current.args) {
3061
- return zodKeywordMapper.matches(transformers4.toRegExpString(current.args));
3062
- }
3063
- }
3064
- if (isKeyword2(current, schemaKeywords3.default)) {
3065
- if (current.args) {
3066
- return zodKeywordMapper.default(current.args);
3067
- }
3068
- }
3069
- if (isKeyword2(current, schemaKeywords3.describe)) {
3070
- if (current.args) {
3071
- return zodKeywordMapper.describe(transformers4.stringify(current.args.toString()));
3072
- }
3073
- }
3074
- if (isKeyword2(current, schemaKeywords3.string)) {
3075
- return zodKeywordMapper.string(options.coercion);
3076
- }
3077
- if (isKeyword2(current, schemaKeywords3.number)) {
3078
- return zodKeywordMapper.number(options.coercion);
3079
- }
3080
- if (isKeyword2(current, schemaKeywords3.integer)) {
3081
- return zodKeywordMapper.integer(options.coercion);
3082
- }
3083
- if (isKeyword2(current, schemaKeywords3.min)) {
3084
- return zodKeywordMapper.min(current.args);
3085
- }
3086
- if (isKeyword2(current, schemaKeywords3.max)) {
3087
- return zodKeywordMapper.max(current.args);
3088
- }
3089
- if (isKeyword2(current, schemaKeywords3.datetime)) {
3090
- return zodKeywordMapper.datetime(current.args.offset, current.args.local);
3091
- }
3092
- if (isKeyword2(current, schemaKeywords3.date)) {
3093
- return zodKeywordMapper.date(current.args.type, options.coercion);
3094
- }
3095
- if (isKeyword2(current, schemaKeywords3.time)) {
3096
- return zodKeywordMapper.time(current.args.type, options.coercion);
3097
- }
3098
- if (current.keyword in zodKeywordMapper && "args" in current) {
3099
- const value2 = zodKeywordMapper[current.keyword];
3100
- return value2(current.args);
3101
- }
3102
- if (current.keyword in zodKeywordMapper) {
3103
- return value();
3104
- }
3105
- return void 0;
3106
- }
3107
-
3108
- // src/plugin.ts
3109
- init_esm_shims();
3110
- import path2 from "node:path";
3111
- import { FileManager as FileManager2, PluginManager as PluginManager2, createPlugin as createPlugin2 } from "@kubb/core";
3112
- import { camelCase as camelCase2, pascalCase as pascalCase2 } from "@kubb/core/transformers";
3113
- import { renderTemplate as renderTemplate2 } from "@kubb/core/utils";
3114
- import { OperationGenerator as OperationGenerator2, SchemaGenerator as SchemaGenerator4, pluginOasName as pluginOasName2 } from "@kubb/plugin-oas";
3115
-
3116
- // src/SchemaGenerator.tsx
3117
- init_esm_shims();
3118
- import { createReactGenerator } from "@kubb/plugin-oas";
3119
-
3120
- // src/components/OperationSchema.tsx
3121
- init_esm_shims();
3122
- import { SchemaGenerator as SchemaGenerator3, schemaKeywords as schemaKeywords4 } from "@kubb/plugin-oas";
3123
- import { Oas as Oas5 } from "@kubb/plugin-oas/components";
3124
- import { useOas as useOas3, useOperation as useOperation2, useOperationManager as useOperationManager2 } from "@kubb/plugin-oas/hooks";
3125
- import { File as File4, useApp as useApp4 } from "@kubb/react";
3126
- import { jsx as jsx6, jsxs as jsxs4 } from "@kubb/react/jsx-runtime";
3127
- function OperationSchema2({ description, keysToOmit }) {
3128
- return /* @__PURE__ */ jsx6(Schema2, { keysToOmit, withTypeAnnotation: false, description });
3129
- }
3130
- OperationSchema2.File = function({}) {
3131
- const { pluginManager, plugin, mode } = useApp4();
3132
- const { getSchemas, getFile } = useOperationManager2();
3133
- const oas = useOas3();
3134
- const operation = useOperation2();
3135
- const file = getFile(operation);
3136
- const schemas = getSchemas(operation);
3137
- const generator = new SchemaGenerator3(plugin.options, {
3138
- oas,
3139
- plugin,
3140
- pluginManager,
3141
- mode,
3142
- override: plugin.options.override
3143
- });
3144
- const items = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
3145
- const mapItem = ({ name, schema, description, keysToOmit, ...options }, i) => {
3146
- const required = Array.isArray(schema?.required) ? !!schema.required.length : !!schema?.required;
3147
- const optional = !required && !!name.includes("Params");
3148
- const tree = generator.parse({ schema, name });
3149
- return /* @__PURE__ */ jsxs4(Oas5.Schema, { name, value: schema, tree: [...tree, optional ? { keyword: schemaKeywords4.optional } : void 0].filter(Boolean), children: [
3150
- mode === "split" && /* @__PURE__ */ jsx6(Oas5.Schema.Imports, { isTypeOnly: false }),
3151
- /* @__PURE__ */ jsx6(OperationSchema2, { description, keysToOmit })
3152
- ] }, i);
3153
- };
3154
- return /* @__PURE__ */ jsxs4(File4, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
3155
- /* @__PURE__ */ jsx6(File4.Import, { name: ["z"], path: plugin.options.importPath }),
3156
- items.map(mapItem)
3157
- ] });
3158
- };
3159
-
3160
- // src/components/Operations.tsx
3161
- init_esm_shims();
3162
- import { useOperationManager as useOperationManager3, useOperations } from "@kubb/plugin-oas/hooks";
3163
- import { Const, File as File5, useApp as useApp5 } from "@kubb/react";
3164
- import transformers5 from "@kubb/core/transformers";
3165
- import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs5 } from "@kubb/react/jsx-runtime";
3166
- function Template2({ operationsName, pathsName, operations }) {
3167
- const { groupSchemasByName } = useOperationManager3();
3168
- const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
3169
- const operationsJSON = transformedOperations.reduce(
3170
- (prev, acc) => {
3171
- prev[`"${acc.operation.getOperationId()}"`] = acc.data;
3172
- return prev;
3173
- },
3174
- {}
3175
- );
3176
- const pathsJSON = transformedOperations.reduce(
3177
- (prev, acc) => {
3178
- prev[`"${acc.operation.path}"`] = {
3179
- ...prev[`"${acc.operation.path}"`] || {},
3180
- [acc.operation.method]: `operations["${acc.operation.getOperationId()}"]`
3181
- };
3182
- return prev;
3183
- },
3184
- {}
3185
- );
3186
- return /* @__PURE__ */ jsxs5(Fragment3, { children: [
3187
- /* @__PURE__ */ jsx7(File5.Source, { name: operationsName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx7(Const, { export: true, name: operationsName, asConst: true, children: `{${transformers5.stringifyObject(operationsJSON)}}` }) }),
3188
- /* @__PURE__ */ jsx7(File5.Source, { name: pathsName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx7(Const, { export: true, name: pathsName, asConst: true, children: `{${transformers5.stringifyObject(pathsJSON)}}` }) })
3189
- ] });
3190
- }
3191
- function RootTemplate({ children }) {
3192
- const {
3193
- mode,
3194
- pluginManager,
3195
- plugin: {
3196
- key: pluginKey,
3197
- options: { extName }
3198
- }
3199
- } = useApp5();
3200
- const { getFile } = useOperationManager3();
3201
- const operations = useOperations();
3202
- const { groupSchemasByName } = useOperationManager3();
3203
- const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
3204
- const file = pluginManager.getFile({ name: "operations", extName: ".ts", pluginKey });
3205
- const imports = Object.entries(transformedOperations).map(([key, { data, operation }]) => {
3206
- const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean);
3207
- return /* @__PURE__ */ jsx7(File5.Import, { name: names, root: file.path, path: getFile(operation).path }, key);
3208
- }).filter(Boolean);
3209
- return /* @__PURE__ */ jsxs5(File5, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
3210
- mode === "split" && imports,
3211
- children
3212
- ] });
3213
- }
3214
- var defaultTemplates2 = { default: Template2, root: RootTemplate };
3215
- function Operations({ Template: Template3 = defaultTemplates2.default }) {
3216
- const operations = useOperations();
3217
- return /* @__PURE__ */ jsx7(Template3, { operationsName: "operations", pathsName: "paths", operations });
3218
- }
3219
- Operations.File = function(props) {
3220
- const templates = { ...defaultTemplates2, ...props.templates };
3221
- const Template3 = templates.default;
3222
- const RootTemplate2 = templates.root;
3223
- return /* @__PURE__ */ jsx7(RootTemplate2, { children: /* @__PURE__ */ jsx7(Operations, { Template: Template3 }) });
3224
- };
3225
- Operations.templates = defaultTemplates2;
3226
-
3227
- // src/SchemaGenerator.tsx
3228
- import { jsx as jsx8 } from "@kubb/react/jsx-runtime";
3229
- var zodParser = createReactGenerator({
3230
- name: "plugin-zod",
3231
- Operations({ options }) {
3232
- if (!options.templates.operations) {
3233
- return null;
3234
- }
3235
- return /* @__PURE__ */ jsx8(Operations.File, { templates: options.templates.operations });
3236
- },
3237
- Operation() {
3238
- return /* @__PURE__ */ jsx8(OperationSchema2.File, {});
3239
- },
3240
- Schema({ schema, name }) {
3241
- return /* @__PURE__ */ jsx8(Schema2.File, {});
3242
- }
3243
- });
3244
-
3245
- // src/plugin.ts
3246
- var pluginZodName = "plugin-zod";
3247
- var pluginZod = createPlugin2((options) => {
3248
- const {
3249
- output = { path: "zod" },
3250
- group,
3251
- exclude = [],
3252
- include,
3253
- override = [],
3254
- transformers: transformers7 = {},
3255
- dateType = "string",
3256
- unknownType = "any",
3257
- typed = false,
3258
- typedSchema = false,
3259
- mapper = {},
3260
- templates,
3261
- importPath = "zod",
3262
- coercion = false
3263
- } = options;
3264
- const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
3265
- return {
3266
- name: pluginZodName,
3267
- output: {
3268
- exportType: "barrelNamed",
3269
- ...output
3270
- },
3271
- options: {
3272
- extName: output.extName,
3273
- transformers: transformers7,
3274
- include,
3275
- exclude,
3276
- override,
3277
- typed,
3278
- typedSchema,
3279
- dateType,
3280
- unknownType,
3281
- mapper,
3282
- importPath,
3283
- coercion,
3284
- templates: {
3285
- operations: Operations.templates,
3286
- ...templates
3287
- }
3288
- },
3289
- pre: [pluginOasName2, typed ? pluginTsName : void 0].filter(Boolean),
3290
- resolvePath(baseName, pathMode, options2) {
3291
- const root = path2.resolve(this.config.root, this.config.output.path);
3292
- const mode = pathMode ?? FileManager2.getMode(path2.resolve(root, output.path));
3293
- if (mode === "single") {
3294
- return path2.resolve(root, output.path);
3295
- }
3296
- if (options2?.tag && group?.type === "tag") {
3297
- const tag = camelCase2(options2.tag);
3298
- return path2.resolve(root, renderTemplate2(template, { tag }), baseName);
3299
- }
3300
- return path2.resolve(root, output.path, baseName);
3301
- },
3302
- resolveName(name, type) {
3303
- let resolvedName = camelCase2(name, {
3304
- suffix: type ? "schema" : void 0,
3305
- isFile: type === "file"
3306
- });
3307
- if (type === "type") {
3308
- resolvedName = pascalCase2(resolvedName);
3309
- }
3310
- if (type) {
3311
- return transformers7?.name?.(resolvedName, type) || resolvedName;
3312
- }
3313
- return resolvedName;
3314
- },
3315
- async buildStart() {
3316
- const [swaggerPlugin] = PluginManager2.getDependedPlugins(this.plugins, [pluginOasName2]);
3317
- const oas = await swaggerPlugin.context.getOas();
3318
- const root = path2.resolve(this.config.root, this.config.output.path);
3319
- const mode = FileManager2.getMode(path2.resolve(root, output.path));
3320
- const schemaGenerator = new SchemaGenerator4(this.plugin.options, {
3321
- oas,
3322
- pluginManager: this.pluginManager,
3323
- plugin: this.plugin,
3324
- contentType: swaggerPlugin.context.contentType,
3325
- include: void 0,
3326
- override,
3327
- mode,
3328
- output: output.path
3329
- });
3330
- const schemaFiles = await schemaGenerator.build(zodParser);
3331
- await this.addFile(...schemaFiles);
3332
- const operationGenerator = new OperationGenerator2(this.plugin.options, {
3333
- oas,
3334
- pluginManager: this.pluginManager,
3335
- plugin: this.plugin,
3336
- contentType: swaggerPlugin.context.contentType,
3337
- exclude,
3338
- include,
3339
- override,
3340
- mode
3341
- });
3342
- const operationFiles = await operationGenerator.build(zodParser);
3343
- await this.addFile(...operationFiles);
3344
- if (this.config.output.exportType) {
3345
- const barrelFiles = await this.fileManager.getBarrelFiles({
3346
- root,
3347
- output,
3348
- files: this.fileManager.files,
3349
- meta: {
3350
- pluginKey: this.plugin.key
3351
- },
3352
- logger: this.logger
3353
- });
3354
- await this.addFile(...barrelFiles);
3355
- }
3356
- }
3357
- };
3358
- });
3359
-
3360
- // src/components/Schema.tsx
3361
- import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs6 } from "@kubb/react/jsx-runtime";
3362
- function Schema2(props) {
3363
- const { keysToOmit, withTypeAnnotation, description } = props;
3364
- const { tree, name } = useSchema2();
3365
- const {
3366
- pluginManager,
3367
- plugin: {
3368
- options: { mapper, typedSchema, coercion }
3369
- }
3370
- } = useApp6();
3371
- const resolvedName = pluginManager.resolveName({
3372
- name,
3373
- pluginKey: [pluginZodName],
3374
- type: "function"
3375
- });
3376
- const resolvedTypeName = pluginManager.resolveName({
3377
- name,
3378
- pluginKey: [pluginZodName],
3379
- type: "type"
3380
- });
3381
- const typeName = pluginManager.resolveName({
3382
- name,
3383
- pluginKey: [pluginTsName],
3384
- type: "type"
3385
- });
3386
- if (!tree.length) {
3387
- return /* @__PURE__ */ jsx9(File6.Source, { name: resolvedName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx9(
3388
- Const2,
3389
- {
3390
- name: resolvedName,
3391
- export: true,
3392
- JSDoc: {
3393
- comments: [description ? `@description ${transformers6.jsStringEscape(description)}` : void 0].filter(Boolean)
3394
- },
3395
- children: "undefined"
3396
- }
3397
- ) });
3398
- }
3399
- const hasTuple = tree.some((item) => isKeyword3(item, schemaKeywords5.tuple));
3400
- const output = sort(tree).filter((item) => {
3401
- if (hasTuple && (isKeyword3(item, schemaKeywords5.min) || isKeyword3(item, schemaKeywords5.max))) {
3402
- return false;
3403
- }
3404
- return true;
3405
- }).map((item) => parse2(void 0, item, { name, typeName, description, mapper, coercion, keysToOmit })).filter(Boolean).join("");
3406
- const suffix = output.endsWith(".nullable()") ? ".unwrap().and" : ".and";
3407
- return /* @__PURE__ */ jsxs6(Fragment4, { children: [
3408
- /* @__PURE__ */ jsx9(File6.Source, { name: resolvedName, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx9(
3409
- Const2,
3410
- {
3411
- export: true,
3412
- name: resolvedName,
3413
- JSDoc: {
3414
- comments: [description ? `@description ${transformers6.jsStringEscape(description)}` : void 0].filter(Boolean)
3415
- },
3416
- children: [
3417
- output,
3418
- keysToOmit?.length ? `${suffix}(z.object({ ${keysToOmit.map((key) => `${key}: z.never()`).join(",")} }))` : void 0,
3419
- withTypeAnnotation && typeName ? ` as z.ZodType<${typeName}>` : ""
3420
- ].filter(Boolean).join("") || ""
3421
- }
3422
- ) }),
3423
- typedSchema && /* @__PURE__ */ jsx9(File6.Source, { name: resolvedTypeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx9(Type2, { export: true, name: resolvedTypeName, children: `z.infer<typeof ${resolvedName}>` }) })
3424
- ] });
3425
- }
3426
- Schema2.File = function({}) {
3427
- const {
3428
- pluginManager,
3429
- plugin: {
3430
- options: { typed }
3431
- }
3432
- } = useApp6();
3433
- const { schema } = useSchema2();
3434
- const withTypeAnnotation = !!typed;
3435
- return /* @__PURE__ */ jsxs6(Oas6.Schema.File, { output: pluginManager.config.output.path, children: [
3436
- /* @__PURE__ */ jsx9(Schema2.Imports, {}),
3437
- /* @__PURE__ */ jsx9(Schema2, { withTypeAnnotation, description: schema?.description })
3438
- ] });
3439
- };
3440
- Schema2.Imports = () => {
3441
- const {
3442
- pluginManager,
3443
- plugin: {
3444
- options: { typed, importPath }
3445
- }
3446
- } = useApp6();
3447
- const { path: root } = useFile();
3448
- const { name, tree, schema } = useSchema2();
3449
- const typeName = pluginManager.resolveName({
3450
- name,
3451
- pluginKey: [pluginTsName],
3452
- type: "type"
3453
- });
3454
- const typeFileName = pluginManager.resolveName({
3455
- name,
3456
- pluginKey: [pluginTsName],
3457
- type: "file"
3458
- });
3459
- const typePath = pluginManager.resolvePath({
3460
- baseName: typeFileName,
3461
- pluginKey: [pluginTsName]
3462
- });
3463
- const withTypeAnnotation = !!typed;
3464
- return /* @__PURE__ */ jsxs6(Fragment4, { children: [
3465
- /* @__PURE__ */ jsx9(File6.Import, { name: ["z"], path: importPath }),
3466
- withTypeAnnotation && typeName && typePath && /* @__PURE__ */ jsx9(File6.Import, { isTypeOnly: true, root, path: typePath, name: [typeName] })
3467
- ] });
3468
- };
3469
-
3470
- export {
3471
- init_esm_shims,
3472
- Schema2 as Schema,
3473
- OperationSchema2 as OperationSchema,
3474
- Operations,
3475
- pluginZodName,
3476
- pluginZod
3477
- };
3478
- /*! Bundled license information:
3479
-
3480
- react/cjs/react.production.min.js:
3481
- (**
3482
- * @license React
3483
- * react.production.min.js
3484
- *
3485
- * Copyright (c) Facebook, Inc. and its affiliates.
3486
- *
3487
- * This source code is licensed under the MIT license found in the
3488
- * LICENSE file in the root directory of this source tree.
3489
- *)
3490
-
3491
- react/cjs/react.development.js:
3492
- (**
3493
- * @license React
3494
- * react.development.js
3495
- *
3496
- * Copyright (c) Facebook, Inc. and its affiliates.
3497
- *
3498
- * This source code is licensed under the MIT license found in the
3499
- * LICENSE file in the root directory of this source tree.
3500
- *)
3501
- */
3502
- //# sourceMappingURL=chunk-CUPQVLRZ.js.map