UNPKG

11.8 kBJavaScriptView Raw
1/**
2 * @license React
3 * react-jsx-dev-runtime.development.js
4 *
5 * Copyright (c) Meta Platforms, Inc. and affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */
10
11"use strict";
12"production" !== process.env.NODE_ENV &&
13 (function () {
14 function getComponentNameFromType(type) {
15 if (null == type) return null;
16 if ("function" === typeof type)
17 return type.$$typeof === REACT_CLIENT_REFERENCE
18 ? null
19 : type.displayName || type.name || null;
20 if ("string" === typeof type) return type;
21 switch (type) {
22 case REACT_FRAGMENT_TYPE:
23 return "Fragment";
24 case REACT_PROFILER_TYPE:
25 return "Profiler";
26 case REACT_STRICT_MODE_TYPE:
27 return "StrictMode";
28 case REACT_SUSPENSE_TYPE:
29 return "Suspense";
30 case REACT_SUSPENSE_LIST_TYPE:
31 return "SuspenseList";
32 case REACT_ACTIVITY_TYPE:
33 return "Activity";
34 }
35 if ("object" === typeof type)
36 switch (
37 ("number" === typeof type.tag &&
38 console.error(
39 "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
40 ),
41 type.$$typeof)
42 ) {
43 case REACT_PORTAL_TYPE:
44 return "Portal";
45 case REACT_CONTEXT_TYPE:
46 return (type.displayName || "Context") + ".Provider";
47 case REACT_CONSUMER_TYPE:
48 return (type._context.displayName || "Context") + ".Consumer";
49 case REACT_FORWARD_REF_TYPE:
50 var innerType = type.render;
51 type = type.displayName;
52 type ||
53 ((type = innerType.displayName || innerType.name || ""),
54 (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
55 return type;
56 case REACT_MEMO_TYPE:
57 return (
58 (innerType = type.displayName || null),
59 null !== innerType
60 ? innerType
61 : getComponentNameFromType(type.type) || "Memo"
62 );
63 case REACT_LAZY_TYPE:
64 innerType = type._payload;
65 type = type._init;
66 try {
67 return getComponentNameFromType(type(innerType));
68 } catch (x) {}
69 }
70 return null;
71 }
72 function testStringCoercion(value) {
73 return "" + value;
74 }
75 function checkKeyStringCoercion(value) {
76 try {
77 testStringCoercion(value);
78 var JSCompiler_inline_result = !1;
79 } catch (e) {
80 JSCompiler_inline_result = !0;
81 }
82 if (JSCompiler_inline_result) {
83 JSCompiler_inline_result = console;
84 var JSCompiler_temp_const = JSCompiler_inline_result.error;
85 var JSCompiler_inline_result$jscomp$0 =
86 ("function" === typeof Symbol &&
87 Symbol.toStringTag &&
88 value[Symbol.toStringTag]) ||
89 value.constructor.name ||
90 "Object";
91 JSCompiler_temp_const.call(
92 JSCompiler_inline_result,
93 "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
94 JSCompiler_inline_result$jscomp$0
95 );
96 return testStringCoercion(value);
97 }
98 }
99 function getTaskName(type) {
100 if (type === REACT_FRAGMENT_TYPE) return "<>";
101 if (
102 "object" === typeof type &&
103 null !== type &&
104 type.$$typeof === REACT_LAZY_TYPE
105 )
106 return "<...>";
107 try {
108 var name = getComponentNameFromType(type);
109 return name ? "<" + name + ">" : "<...>";
110 } catch (x) {
111 return "<...>";
112 }
113 }
114 function getOwner() {
115 var dispatcher = ReactSharedInternals.A;
116 return null === dispatcher ? null : dispatcher.getOwner();
117 }
118 function UnknownOwner() {
119 return Error("react-stack-top-frame");
120 }
121 function hasValidKey(config) {
122 if (hasOwnProperty.call(config, "key")) {
123 var getter = Object.getOwnPropertyDescriptor(config, "key").get;
124 if (getter && getter.isReactWarning) return !1;
125 }
126 return void 0 !== config.key;
127 }
128 function defineKeyPropWarningGetter(props, displayName) {
129 function warnAboutAccessingKey() {
130 specialPropKeyWarningShown ||
131 ((specialPropKeyWarningShown = !0),
132 console.error(
133 "%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://react.dev/link/special-props)",
134 displayName
135 ));
136 }
137 warnAboutAccessingKey.isReactWarning = !0;
138 Object.defineProperty(props, "key", {
139 get: warnAboutAccessingKey,
140 configurable: !0
141 });
142 }
143 function elementRefGetterWithDeprecationWarning() {
144 var componentName = getComponentNameFromType(this.type);
145 didWarnAboutElementRef[componentName] ||
146 ((didWarnAboutElementRef[componentName] = !0),
147 console.error(
148 "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
149 ));
150 componentName = this.props.ref;
151 return void 0 !== componentName ? componentName : null;
152 }
153 function ReactElement(
154 type,
155 key,
156 self,
157 source,
158 owner,
159 props,
160 debugStack,
161 debugTask
162 ) {
163 self = props.ref;
164 type = {
165 $$typeof: REACT_ELEMENT_TYPE,
166 type: type,
167 key: key,
168 props: props,
169 _owner: owner
170 };
171 null !== (void 0 !== self ? self : null)
172 ? Object.defineProperty(type, "ref", {
173 enumerable: !1,
174 get: elementRefGetterWithDeprecationWarning
175 })
176 : Object.defineProperty(type, "ref", { enumerable: !1, value: null });
177 type._store = {};
178 Object.defineProperty(type._store, "validated", {
179 configurable: !1,
180 enumerable: !1,
181 writable: !0,
182 value: 0
183 });
184 Object.defineProperty(type, "_debugInfo", {
185 configurable: !1,
186 enumerable: !1,
187 writable: !0,
188 value: null
189 });
190 Object.defineProperty(type, "_debugStack", {
191 configurable: !1,
192 enumerable: !1,
193 writable: !0,
194 value: debugStack
195 });
196 Object.defineProperty(type, "_debugTask", {
197 configurable: !1,
198 enumerable: !1,
199 writable: !0,
200 value: debugTask
201 });
202 Object.freeze && (Object.freeze(type.props), Object.freeze(type));
203 return type;
204 }
205 function jsxDEVImpl(
206 type,
207 config,
208 maybeKey,
209 isStaticChildren,
210 source,
211 self,
212 debugStack,
213 debugTask
214 ) {
215 var children = config.children;
216 if (void 0 !== children)
217 if (isStaticChildren)
218 if (isArrayImpl(children)) {
219 for (
220 isStaticChildren = 0;
221 isStaticChildren < children.length;
222 isStaticChildren++
223 )
224 validateChildKeys(children[isStaticChildren]);
225 Object.freeze && Object.freeze(children);
226 } else
227 console.error(
228 "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
229 );
230 else validateChildKeys(children);
231 if (hasOwnProperty.call(config, "key")) {
232 children = getComponentNameFromType(type);
233 var keys = Object.keys(config).filter(function (k) {
234 return "key" !== k;
235 });
236 isStaticChildren =
237 0 < keys.length
238 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
239 : "{key: someKey}";
240 didWarnAboutKeySpread[children + isStaticChildren] ||
241 ((keys =
242 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
243 console.error(
244 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
245 isStaticChildren,
246 children,
247 keys,
248 children
249 ),
250 (didWarnAboutKeySpread[children + isStaticChildren] = !0));
251 }
252 children = null;
253 void 0 !== maybeKey &&
254 (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
255 hasValidKey(config) &&
256 (checkKeyStringCoercion(config.key), (children = "" + config.key));
257 if ("key" in config) {
258 maybeKey = {};
259 for (var propName in config)
260 "key" !== propName && (maybeKey[propName] = config[propName]);
261 } else maybeKey = config;
262 children &&
263 defineKeyPropWarningGetter(
264 maybeKey,
265 "function" === typeof type
266 ? type.displayName || type.name || "Unknown"
267 : type
268 );
269 return ReactElement(
270 type,
271 children,
272 self,
273 source,
274 getOwner(),
275 maybeKey,
276 debugStack,
277 debugTask
278 );
279 }
280 function validateChildKeys(node) {
281 "object" === typeof node &&
282 null !== node &&
283 node.$$typeof === REACT_ELEMENT_TYPE &&
284 node._store &&
285 (node._store.validated = 1);
286 }
287 var React = require("react"),
288 REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
289 REACT_PORTAL_TYPE = Symbol.for("react.portal"),
290 REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
291 REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
292 REACT_PROFILER_TYPE = Symbol.for("react.profiler");
293 Symbol.for("react.provider");
294 var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
295 REACT_CONTEXT_TYPE = Symbol.for("react.context"),
296 REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
297 REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
298 REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
299 REACT_MEMO_TYPE = Symbol.for("react.memo"),
300 REACT_LAZY_TYPE = Symbol.for("react.lazy"),
301 REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
302 REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
303 ReactSharedInternals =
304 React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
305 hasOwnProperty = Object.prototype.hasOwnProperty,
306 isArrayImpl = Array.isArray,
307 createTask = console.createTask
308 ? console.createTask
309 : function () {
310 return null;
311 };
312 React = {
313 react_stack_bottom_frame: function (callStackForError) {
314 return callStackForError();
315 }
316 };
317 var specialPropKeyWarningShown;
318 var didWarnAboutElementRef = {};
319 var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
320 React,
321 UnknownOwner
322 )();
323 var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
324 var didWarnAboutKeySpread = {};
325 exports.Fragment = REACT_FRAGMENT_TYPE;
326 exports.jsxDEV = function (
327 type,
328 config,
329 maybeKey,
330 isStaticChildren,
331 source,
332 self
333 ) {
334 var trackActualOwner =
335 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
336 return jsxDEVImpl(
337 type,
338 config,
339 maybeKey,
340 isStaticChildren,
341 source,
342 self,
343 trackActualOwner
344 ? Error("react-stack-top-frame")
345 : unknownOwnerDebugStack,
346 trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
347 );
348 };
349 })();