UNPKG

13.3 kBJavaScriptView Raw
1/**
2 * @license React
3 * react.react-server.production.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";
12var ReactSharedInternals = { H: null, A: null };
13function formatProdErrorMessage(code) {
14 var url = "https://react.dev/errors/" + code;
15 if (1 < arguments.length) {
16 url += "?args[]=" + encodeURIComponent(arguments[1]);
17 for (var i = 2; i < arguments.length; i++)
18 url += "&args[]=" + encodeURIComponent(arguments[i]);
19 }
20 return (
21 "Minified React error #" +
22 code +
23 "; visit " +
24 url +
25 " for the full message or use the non-minified dev environment for full errors and additional helpful warnings."
26 );
27}
28var isArrayImpl = Array.isArray;
29function noop() {}
30var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
31 REACT_PORTAL_TYPE = Symbol.for("react.portal"),
32 REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
33 REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
34 REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
35 REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
36 REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
37 REACT_MEMO_TYPE = Symbol.for("react.memo"),
38 REACT_LAZY_TYPE = Symbol.for("react.lazy"),
39 MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
40function getIteratorFn(maybeIterable) {
41 if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
42 maybeIterable =
43 (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
44 maybeIterable["@@iterator"];
45 return "function" === typeof maybeIterable ? maybeIterable : null;
46}
47var hasOwnProperty = Object.prototype.hasOwnProperty,
48 assign = Object.assign;
49function ReactElement(type, key, props) {
50 var refProp = props.ref;
51 return {
52 $$typeof: REACT_ELEMENT_TYPE,
53 type: type,
54 key: key,
55 ref: void 0 !== refProp ? refProp : null,
56 props: props
57 };
58}
59function cloneAndReplaceKey(oldElement, newKey) {
60 return ReactElement(oldElement.type, newKey, oldElement.props);
61}
62function isValidElement(object) {
63 return (
64 "object" === typeof object &&
65 null !== object &&
66 object.$$typeof === REACT_ELEMENT_TYPE
67 );
68}
69function escape(key) {
70 var escaperLookup = { "=": "=0", ":": "=2" };
71 return (
72 "$" +
73 key.replace(/[=:]/g, function (match) {
74 return escaperLookup[match];
75 })
76 );
77}
78var userProvidedKeyEscapeRegex = /\/+/g;
79function getElementKey(element, index) {
80 return "object" === typeof element && null !== element && null != element.key
81 ? escape("" + element.key)
82 : index.toString(36);
83}
84function resolveThenable(thenable) {
85 switch (thenable.status) {
86 case "fulfilled":
87 return thenable.value;
88 case "rejected":
89 throw thenable.reason;
90 default:
91 switch (
92 ("string" === typeof thenable.status
93 ? thenable.then(noop, noop)
94 : ((thenable.status = "pending"),
95 thenable.then(
96 function (fulfilledValue) {
97 "pending" === thenable.status &&
98 ((thenable.status = "fulfilled"),
99 (thenable.value = fulfilledValue));
100 },
101 function (error) {
102 "pending" === thenable.status &&
103 ((thenable.status = "rejected"), (thenable.reason = error));
104 }
105 )),
106 thenable.status)
107 ) {
108 case "fulfilled":
109 return thenable.value;
110 case "rejected":
111 throw thenable.reason;
112 }
113 }
114 throw thenable;
115}
116function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
117 var type = typeof children;
118 if ("undefined" === type || "boolean" === type) children = null;
119 var invokeCallback = !1;
120 if (null === children) invokeCallback = !0;
121 else
122 switch (type) {
123 case "bigint":
124 case "string":
125 case "number":
126 invokeCallback = !0;
127 break;
128 case "object":
129 switch (children.$$typeof) {
130 case REACT_ELEMENT_TYPE:
131 case REACT_PORTAL_TYPE:
132 invokeCallback = !0;
133 break;
134 case REACT_LAZY_TYPE:
135 return (
136 (invokeCallback = children._init),
137 mapIntoArray(
138 invokeCallback(children._payload),
139 array,
140 escapedPrefix,
141 nameSoFar,
142 callback
143 )
144 );
145 }
146 }
147 if (invokeCallback)
148 return (
149 (callback = callback(children)),
150 (invokeCallback =
151 "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar),
152 isArrayImpl(callback)
153 ? ((escapedPrefix = ""),
154 null != invokeCallback &&
155 (escapedPrefix =
156 invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
157 mapIntoArray(callback, array, escapedPrefix, "", function (c) {
158 return c;
159 }))
160 : null != callback &&
161 (isValidElement(callback) &&
162 (callback = cloneAndReplaceKey(
163 callback,
164 escapedPrefix +
165 (null == callback.key ||
166 (children && children.key === callback.key)
167 ? ""
168 : ("" + callback.key).replace(
169 userProvidedKeyEscapeRegex,
170 "$&/"
171 ) + "/") +
172 invokeCallback
173 )),
174 array.push(callback)),
175 1
176 );
177 invokeCallback = 0;
178 var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
179 if (isArrayImpl(children))
180 for (var i = 0; i < children.length; i++)
181 (nameSoFar = children[i]),
182 (type = nextNamePrefix + getElementKey(nameSoFar, i)),
183 (invokeCallback += mapIntoArray(
184 nameSoFar,
185 array,
186 escapedPrefix,
187 type,
188 callback
189 ));
190 else if (((i = getIteratorFn(children)), "function" === typeof i))
191 for (
192 children = i.call(children), i = 0;
193 !(nameSoFar = children.next()).done;
194
195 )
196 (nameSoFar = nameSoFar.value),
197 (type = nextNamePrefix + getElementKey(nameSoFar, i++)),
198 (invokeCallback += mapIntoArray(
199 nameSoFar,
200 array,
201 escapedPrefix,
202 type,
203 callback
204 ));
205 else if ("object" === type) {
206 if ("function" === typeof children.then)
207 return mapIntoArray(
208 resolveThenable(children),
209 array,
210 escapedPrefix,
211 nameSoFar,
212 callback
213 );
214 array = String(children);
215 throw Error(
216 formatProdErrorMessage(
217 31,
218 "[object Object]" === array
219 ? "object with keys {" + Object.keys(children).join(", ") + "}"
220 : array
221 )
222 );
223 }
224 return invokeCallback;
225}
226function mapChildren(children, func, context) {
227 if (null == children) return children;
228 var result = [],
229 count = 0;
230 mapIntoArray(children, result, "", "", function (child) {
231 return func.call(context, child, count++);
232 });
233 return result;
234}
235function lazyInitializer(payload) {
236 if (-1 === payload._status) {
237 var ctor = payload._result;
238 ctor = ctor();
239 ctor.then(
240 function (moduleObject) {
241 if (0 === payload._status || -1 === payload._status)
242 (payload._status = 1), (payload._result = moduleObject);
243 },
244 function (error) {
245 if (0 === payload._status || -1 === payload._status)
246 (payload._status = 2), (payload._result = error);
247 }
248 );
249 -1 === payload._status && ((payload._status = 0), (payload._result = ctor));
250 }
251 if (1 === payload._status) return payload._result.default;
252 throw payload._result;
253}
254function createCacheRoot() {
255 return new WeakMap();
256}
257function createCacheNode() {
258 return { s: 0, v: void 0, o: null, p: null };
259}
260exports.Children = {
261 map: mapChildren,
262 forEach: function (children, forEachFunc, forEachContext) {
263 mapChildren(
264 children,
265 function () {
266 forEachFunc.apply(this, arguments);
267 },
268 forEachContext
269 );
270 },
271 count: function (children) {
272 var n = 0;
273 mapChildren(children, function () {
274 n++;
275 });
276 return n;
277 },
278 toArray: function (children) {
279 return (
280 mapChildren(children, function (child) {
281 return child;
282 }) || []
283 );
284 },
285 only: function (children) {
286 if (!isValidElement(children)) throw Error(formatProdErrorMessage(143));
287 return children;
288 }
289};
290exports.Fragment = REACT_FRAGMENT_TYPE;
291exports.Profiler = REACT_PROFILER_TYPE;
292exports.StrictMode = REACT_STRICT_MODE_TYPE;
293exports.Suspense = REACT_SUSPENSE_TYPE;
294exports.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
295 ReactSharedInternals;
296exports.cache = function (fn) {
297 return function () {
298 var dispatcher = ReactSharedInternals.A;
299 if (!dispatcher) return fn.apply(null, arguments);
300 var fnMap = dispatcher.getCacheForType(createCacheRoot);
301 dispatcher = fnMap.get(fn);
302 void 0 === dispatcher &&
303 ((dispatcher = createCacheNode()), fnMap.set(fn, dispatcher));
304 fnMap = 0;
305 for (var l = arguments.length; fnMap < l; fnMap++) {
306 var arg = arguments[fnMap];
307 if (
308 "function" === typeof arg ||
309 ("object" === typeof arg && null !== arg)
310 ) {
311 var objectCache = dispatcher.o;
312 null === objectCache && (dispatcher.o = objectCache = new WeakMap());
313 dispatcher = objectCache.get(arg);
314 void 0 === dispatcher &&
315 ((dispatcher = createCacheNode()), objectCache.set(arg, dispatcher));
316 } else
317 (objectCache = dispatcher.p),
318 null === objectCache && (dispatcher.p = objectCache = new Map()),
319 (dispatcher = objectCache.get(arg)),
320 void 0 === dispatcher &&
321 ((dispatcher = createCacheNode()),
322 objectCache.set(arg, dispatcher));
323 }
324 if (1 === dispatcher.s) return dispatcher.v;
325 if (2 === dispatcher.s) throw dispatcher.v;
326 try {
327 var result = fn.apply(null, arguments);
328 fnMap = dispatcher;
329 fnMap.s = 1;
330 return (fnMap.v = result);
331 } catch (error) {
332 throw ((result = dispatcher), (result.s = 2), (result.v = error), error);
333 }
334 };
335};
336exports.cacheSignal = function () {
337 var dispatcher = ReactSharedInternals.A;
338 return dispatcher ? dispatcher.cacheSignal() : null;
339};
340exports.captureOwnerStack = function () {
341 return null;
342};
343exports.cloneElement = function (element, config, children) {
344 if (null === element || void 0 === element)
345 throw Error(formatProdErrorMessage(267, element));
346 var props = assign({}, element.props),
347 key = element.key;
348 if (null != config)
349 for (propName in (void 0 !== config.key && (key = "" + config.key), config))
350 !hasOwnProperty.call(config, propName) ||
351 "key" === propName ||
352 "__self" === propName ||
353 "__source" === propName ||
354 ("ref" === propName && void 0 === config.ref) ||
355 (props[propName] = config[propName]);
356 var propName = arguments.length - 2;
357 if (1 === propName) props.children = children;
358 else if (1 < propName) {
359 for (var childArray = Array(propName), i = 0; i < propName; i++)
360 childArray[i] = arguments[i + 2];
361 props.children = childArray;
362 }
363 return ReactElement(element.type, key, props);
364};
365exports.createElement = function (type, config, children) {
366 var propName,
367 props = {},
368 key = null;
369 if (null != config)
370 for (propName in (void 0 !== config.key && (key = "" + config.key), config))
371 hasOwnProperty.call(config, propName) &&
372 "key" !== propName &&
373 "__self" !== propName &&
374 "__source" !== propName &&
375 (props[propName] = config[propName]);
376 var childrenLength = arguments.length - 2;
377 if (1 === childrenLength) props.children = children;
378 else if (1 < childrenLength) {
379 for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
380 childArray[i] = arguments[i + 2];
381 props.children = childArray;
382 }
383 if (type && type.defaultProps)
384 for (propName in ((childrenLength = type.defaultProps), childrenLength))
385 void 0 === props[propName] &&
386 (props[propName] = childrenLength[propName]);
387 return ReactElement(type, key, props);
388};
389exports.createRef = function () {
390 return { current: null };
391};
392exports.forwardRef = function (render) {
393 return { $$typeof: REACT_FORWARD_REF_TYPE, render: render };
394};
395exports.isValidElement = isValidElement;
396exports.lazy = function (ctor) {
397 return {
398 $$typeof: REACT_LAZY_TYPE,
399 _payload: { _status: -1, _result: ctor },
400 _init: lazyInitializer
401 };
402};
403exports.memo = function (type, compare) {
404 return {
405 $$typeof: REACT_MEMO_TYPE,
406 type: type,
407 compare: void 0 === compare ? null : compare
408 };
409};
410exports.use = function (usable) {
411 return ReactSharedInternals.H.use(usable);
412};
413exports.useCallback = function (callback, deps) {
414 return ReactSharedInternals.H.useCallback(callback, deps);
415};
416exports.useDebugValue = function () {};
417exports.useId = function () {
418 return ReactSharedInternals.H.useId();
419};
420exports.useMemo = function (create, deps) {
421 return ReactSharedInternals.H.useMemo(create, deps);
422};
423exports.version = "19.2.3";