UNPKG

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