react-dom.react-server.development.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. /**
  2. * @license React
  3. * react-dom.react-server.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. "use strict";
  11. "production" !== process.env.NODE_ENV &&
  12. (function () {
  13. function noop() {}
  14. function getCrossOriginStringAs(as, input) {
  15. if ("font" === as) return "";
  16. if ("string" === typeof input)
  17. return "use-credentials" === input ? input : "";
  18. }
  19. function getValueDescriptorExpectingObjectForWarning(thing) {
  20. return null === thing
  21. ? "`null`"
  22. : void 0 === thing
  23. ? "`undefined`"
  24. : "" === thing
  25. ? "an empty string"
  26. : 'something with type "' + typeof thing + '"';
  27. }
  28. function getValueDescriptorExpectingEnumForWarning(thing) {
  29. return null === thing
  30. ? "`null`"
  31. : void 0 === thing
  32. ? "`undefined`"
  33. : "" === thing
  34. ? "an empty string"
  35. : "string" === typeof thing
  36. ? JSON.stringify(thing)
  37. : "number" === typeof thing
  38. ? "`" + thing + "`"
  39. : 'something with type "' + typeof thing + '"';
  40. }
  41. var React = require("react"),
  42. Internals = {
  43. d: {
  44. f: noop,
  45. r: function () {
  46. throw Error(
  47. "Invalid form element. requestFormReset must be passed a form that was rendered by React."
  48. );
  49. },
  50. D: noop,
  51. C: noop,
  52. L: noop,
  53. m: noop,
  54. X: noop,
  55. S: noop,
  56. M: noop
  57. },
  58. p: 0,
  59. findDOMNode: null
  60. };
  61. if (!React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE)
  62. throw Error(
  63. 'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.'
  64. );
  65. ("function" === typeof Map &&
  66. null != Map.prototype &&
  67. "function" === typeof Map.prototype.forEach &&
  68. "function" === typeof Set &&
  69. null != Set.prototype &&
  70. "function" === typeof Set.prototype.clear &&
  71. "function" === typeof Set.prototype.forEach) ||
  72. console.error(
  73. "React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"
  74. );
  75. exports.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
  76. Internals;
  77. exports.preconnect = function (href, options) {
  78. "string" === typeof href && href
  79. ? null != options && "object" !== typeof options
  80. ? console.error(
  81. "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.",
  82. getValueDescriptorExpectingEnumForWarning(options)
  83. )
  84. : null != options &&
  85. "string" !== typeof options.crossOrigin &&
  86. console.error(
  87. "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.",
  88. getValueDescriptorExpectingObjectForWarning(options.crossOrigin)
  89. )
  90. : console.error(
  91. "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
  92. getValueDescriptorExpectingObjectForWarning(href)
  93. );
  94. "string" === typeof href &&
  95. (options
  96. ? ((options = options.crossOrigin),
  97. (options =
  98. "string" === typeof options
  99. ? "use-credentials" === options
  100. ? options
  101. : ""
  102. : void 0))
  103. : (options = null),
  104. Internals.d.C(href, options));
  105. };
  106. exports.prefetchDNS = function (href) {
  107. if ("string" !== typeof href || !href)
  108. console.error(
  109. "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
  110. getValueDescriptorExpectingObjectForWarning(href)
  111. );
  112. else if (1 < arguments.length) {
  113. var options = arguments[1];
  114. "object" === typeof options && options.hasOwnProperty("crossOrigin")
  115. ? console.error(
  116. "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
  117. getValueDescriptorExpectingEnumForWarning(options)
  118. )
  119. : console.error(
  120. "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
  121. getValueDescriptorExpectingEnumForWarning(options)
  122. );
  123. }
  124. "string" === typeof href && Internals.d.D(href);
  125. };
  126. exports.preinit = function (href, options) {
  127. "string" === typeof href && href
  128. ? null == options || "object" !== typeof options
  129. ? console.error(
  130. "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.",
  131. getValueDescriptorExpectingEnumForWarning(options)
  132. )
  133. : "style" !== options.as &&
  134. "script" !== options.as &&
  135. console.error(
  136. 'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".',
  137. getValueDescriptorExpectingEnumForWarning(options.as)
  138. )
  139. : console.error(
  140. "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
  141. getValueDescriptorExpectingObjectForWarning(href)
  142. );
  143. if (
  144. "string" === typeof href &&
  145. options &&
  146. "string" === typeof options.as
  147. ) {
  148. var as = options.as,
  149. crossOrigin = getCrossOriginStringAs(as, options.crossOrigin),
  150. integrity =
  151. "string" === typeof options.integrity ? options.integrity : void 0,
  152. fetchPriority =
  153. "string" === typeof options.fetchPriority
  154. ? options.fetchPriority
  155. : void 0;
  156. "style" === as
  157. ? Internals.d.S(
  158. href,
  159. "string" === typeof options.precedence
  160. ? options.precedence
  161. : void 0,
  162. {
  163. crossOrigin: crossOrigin,
  164. integrity: integrity,
  165. fetchPriority: fetchPriority
  166. }
  167. )
  168. : "script" === as &&
  169. Internals.d.X(href, {
  170. crossOrigin: crossOrigin,
  171. integrity: integrity,
  172. fetchPriority: fetchPriority,
  173. nonce: "string" === typeof options.nonce ? options.nonce : void 0
  174. });
  175. }
  176. };
  177. exports.preinitModule = function (href, options) {
  178. var encountered = "";
  179. ("string" === typeof href && href) ||
  180. (encountered +=
  181. " The `href` argument encountered was " +
  182. getValueDescriptorExpectingObjectForWarning(href) +
  183. ".");
  184. void 0 !== options && "object" !== typeof options
  185. ? (encountered +=
  186. " The `options` argument encountered was " +
  187. getValueDescriptorExpectingObjectForWarning(options) +
  188. ".")
  189. : options &&
  190. "as" in options &&
  191. "script" !== options.as &&
  192. (encountered +=
  193. " The `as` option encountered was " +
  194. getValueDescriptorExpectingEnumForWarning(options.as) +
  195. ".");
  196. if (encountered)
  197. console.error(
  198. "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s",
  199. encountered
  200. );
  201. else
  202. switch (
  203. ((encountered =
  204. options && "string" === typeof options.as ? options.as : "script"),
  205. encountered)
  206. ) {
  207. case "script":
  208. break;
  209. default:
  210. (encountered =
  211. getValueDescriptorExpectingEnumForWarning(encountered)),
  212. console.error(
  213. 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script" but received "%s" instead. This warning was generated for `href` "%s". In the future other module types will be supported, aligning with the import-attributes proposal. Learn more here: (https://github.com/tc39/proposal-import-attributes)',
  214. encountered,
  215. href
  216. );
  217. }
  218. if ("string" === typeof href)
  219. if ("object" === typeof options && null !== options) {
  220. if (null == options.as || "script" === options.as)
  221. (encountered = getCrossOriginStringAs(
  222. options.as,
  223. options.crossOrigin
  224. )),
  225. Internals.d.M(href, {
  226. crossOrigin: encountered,
  227. integrity:
  228. "string" === typeof options.integrity
  229. ? options.integrity
  230. : void 0,
  231. nonce:
  232. "string" === typeof options.nonce ? options.nonce : void 0
  233. });
  234. } else null == options && Internals.d.M(href);
  235. };
  236. exports.preload = function (href, options) {
  237. var encountered = "";
  238. ("string" === typeof href && href) ||
  239. (encountered +=
  240. " The `href` argument encountered was " +
  241. getValueDescriptorExpectingObjectForWarning(href) +
  242. ".");
  243. null == options || "object" !== typeof options
  244. ? (encountered +=
  245. " The `options` argument encountered was " +
  246. getValueDescriptorExpectingObjectForWarning(options) +
  247. ".")
  248. : ("string" === typeof options.as && options.as) ||
  249. (encountered +=
  250. " The `as` option encountered was " +
  251. getValueDescriptorExpectingObjectForWarning(options.as) +
  252. ".");
  253. encountered &&
  254. console.error(
  255. 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `<link rel="preload" as="..." />` tag.%s',
  256. encountered
  257. );
  258. if (
  259. "string" === typeof href &&
  260. "object" === typeof options &&
  261. null !== options &&
  262. "string" === typeof options.as
  263. ) {
  264. encountered = options.as;
  265. var crossOrigin = getCrossOriginStringAs(
  266. encountered,
  267. options.crossOrigin
  268. );
  269. Internals.d.L(href, encountered, {
  270. crossOrigin: crossOrigin,
  271. integrity:
  272. "string" === typeof options.integrity ? options.integrity : void 0,
  273. nonce: "string" === typeof options.nonce ? options.nonce : void 0,
  274. type: "string" === typeof options.type ? options.type : void 0,
  275. fetchPriority:
  276. "string" === typeof options.fetchPriority
  277. ? options.fetchPriority
  278. : void 0,
  279. referrerPolicy:
  280. "string" === typeof options.referrerPolicy
  281. ? options.referrerPolicy
  282. : void 0,
  283. imageSrcSet:
  284. "string" === typeof options.imageSrcSet
  285. ? options.imageSrcSet
  286. : void 0,
  287. imageSizes:
  288. "string" === typeof options.imageSizes
  289. ? options.imageSizes
  290. : void 0,
  291. media: "string" === typeof options.media ? options.media : void 0
  292. });
  293. }
  294. };
  295. exports.preloadModule = function (href, options) {
  296. var encountered = "";
  297. ("string" === typeof href && href) ||
  298. (encountered +=
  299. " The `href` argument encountered was " +
  300. getValueDescriptorExpectingObjectForWarning(href) +
  301. ".");
  302. void 0 !== options && "object" !== typeof options
  303. ? (encountered +=
  304. " The `options` argument encountered was " +
  305. getValueDescriptorExpectingObjectForWarning(options) +
  306. ".")
  307. : options &&
  308. "as" in options &&
  309. "string" !== typeof options.as &&
  310. (encountered +=
  311. " The `as` option encountered was " +
  312. getValueDescriptorExpectingObjectForWarning(options.as) +
  313. ".");
  314. encountered &&
  315. console.error(
  316. 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `<link rel="modulepreload" as="..." />` tag.%s',
  317. encountered
  318. );
  319. "string" === typeof href &&
  320. (options
  321. ? ((encountered = getCrossOriginStringAs(
  322. options.as,
  323. options.crossOrigin
  324. )),
  325. Internals.d.m(href, {
  326. as:
  327. "string" === typeof options.as && "script" !== options.as
  328. ? options.as
  329. : void 0,
  330. crossOrigin: encountered,
  331. integrity:
  332. "string" === typeof options.integrity
  333. ? options.integrity
  334. : void 0
  335. }))
  336. : Internals.d.m(href));
  337. };
  338. exports.version = "19.2.4";
  339. })();