react-is.development.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /** @license React v17.0.2
  2. * react-is.development.js
  3. *
  4. * Copyright (c) Facebook, Inc. and its affiliates.
  5. *
  6. * This source code is licensed under the MIT license found in the
  7. * LICENSE file in the root directory of this source tree.
  8. */
  9. 'use strict';
  10. if (process.env.NODE_ENV !== "production") {
  11. (function() {
  12. 'use strict';
  13. // ATTENTION
  14. // When adding new symbols to this file,
  15. // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
  16. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  17. // nor polyfill, then a plain number is used for performance.
  18. var REACT_ELEMENT_TYPE = 0xeac7;
  19. var REACT_PORTAL_TYPE = 0xeaca;
  20. var REACT_FRAGMENT_TYPE = 0xeacb;
  21. var REACT_STRICT_MODE_TYPE = 0xeacc;
  22. var REACT_PROFILER_TYPE = 0xead2;
  23. var REACT_PROVIDER_TYPE = 0xeacd;
  24. var REACT_CONTEXT_TYPE = 0xeace;
  25. var REACT_FORWARD_REF_TYPE = 0xead0;
  26. var REACT_SUSPENSE_TYPE = 0xead1;
  27. var REACT_SUSPENSE_LIST_TYPE = 0xead8;
  28. var REACT_MEMO_TYPE = 0xead3;
  29. var REACT_LAZY_TYPE = 0xead4;
  30. var REACT_BLOCK_TYPE = 0xead9;
  31. var REACT_SERVER_BLOCK_TYPE = 0xeada;
  32. var REACT_FUNDAMENTAL_TYPE = 0xead5;
  33. var REACT_SCOPE_TYPE = 0xead7;
  34. var REACT_OPAQUE_ID_TYPE = 0xeae0;
  35. var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
  36. var REACT_OFFSCREEN_TYPE = 0xeae2;
  37. var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
  38. if (typeof Symbol === 'function' && Symbol.for) {
  39. var symbolFor = Symbol.for;
  40. REACT_ELEMENT_TYPE = symbolFor('react.element');
  41. REACT_PORTAL_TYPE = symbolFor('react.portal');
  42. REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
  43. REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
  44. REACT_PROFILER_TYPE = symbolFor('react.profiler');
  45. REACT_PROVIDER_TYPE = symbolFor('react.provider');
  46. REACT_CONTEXT_TYPE = symbolFor('react.context');
  47. REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
  48. REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
  49. REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
  50. REACT_MEMO_TYPE = symbolFor('react.memo');
  51. REACT_LAZY_TYPE = symbolFor('react.lazy');
  52. REACT_BLOCK_TYPE = symbolFor('react.block');
  53. REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
  54. REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
  55. REACT_SCOPE_TYPE = symbolFor('react.scope');
  56. REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
  57. REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
  58. REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
  59. REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
  60. }
  61. // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
  62. var enableScopeAPI = false; // Experimental Create Event Handle API.
  63. function isValidElementType(type) {
  64. if (typeof type === 'string' || typeof type === 'function') {
  65. return true;
  66. } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
  67. if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
  68. return true;
  69. }
  70. if (typeof type === 'object' && type !== null) {
  71. 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 || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. function typeOf(object) {
  78. if (typeof object === 'object' && object !== null) {
  79. var $$typeof = object.$$typeof;
  80. switch ($$typeof) {
  81. case REACT_ELEMENT_TYPE:
  82. var type = object.type;
  83. switch (type) {
  84. case REACT_FRAGMENT_TYPE:
  85. case REACT_PROFILER_TYPE:
  86. case REACT_STRICT_MODE_TYPE:
  87. case REACT_SUSPENSE_TYPE:
  88. case REACT_SUSPENSE_LIST_TYPE:
  89. return type;
  90. default:
  91. var $$typeofType = type && type.$$typeof;
  92. switch ($$typeofType) {
  93. case REACT_CONTEXT_TYPE:
  94. case REACT_FORWARD_REF_TYPE:
  95. case REACT_LAZY_TYPE:
  96. case REACT_MEMO_TYPE:
  97. case REACT_PROVIDER_TYPE:
  98. return $$typeofType;
  99. default:
  100. return $$typeof;
  101. }
  102. }
  103. case REACT_PORTAL_TYPE:
  104. return $$typeof;
  105. }
  106. }
  107. return undefined;
  108. }
  109. var ContextConsumer = REACT_CONTEXT_TYPE;
  110. var ContextProvider = REACT_PROVIDER_TYPE;
  111. var Element = REACT_ELEMENT_TYPE;
  112. var ForwardRef = REACT_FORWARD_REF_TYPE;
  113. var Fragment = REACT_FRAGMENT_TYPE;
  114. var Lazy = REACT_LAZY_TYPE;
  115. var Memo = REACT_MEMO_TYPE;
  116. var Portal = REACT_PORTAL_TYPE;
  117. var Profiler = REACT_PROFILER_TYPE;
  118. var StrictMode = REACT_STRICT_MODE_TYPE;
  119. var Suspense = REACT_SUSPENSE_TYPE;
  120. var hasWarnedAboutDeprecatedIsAsyncMode = false;
  121. var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
  122. function isAsyncMode(object) {
  123. {
  124. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  125. hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
  126. console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
  127. }
  128. }
  129. return false;
  130. }
  131. function isConcurrentMode(object) {
  132. {
  133. if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
  134. hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
  135. console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
  136. }
  137. }
  138. return false;
  139. }
  140. function isContextConsumer(object) {
  141. return typeOf(object) === REACT_CONTEXT_TYPE;
  142. }
  143. function isContextProvider(object) {
  144. return typeOf(object) === REACT_PROVIDER_TYPE;
  145. }
  146. function isElement(object) {
  147. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  148. }
  149. function isForwardRef(object) {
  150. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  151. }
  152. function isFragment(object) {
  153. return typeOf(object) === REACT_FRAGMENT_TYPE;
  154. }
  155. function isLazy(object) {
  156. return typeOf(object) === REACT_LAZY_TYPE;
  157. }
  158. function isMemo(object) {
  159. return typeOf(object) === REACT_MEMO_TYPE;
  160. }
  161. function isPortal(object) {
  162. return typeOf(object) === REACT_PORTAL_TYPE;
  163. }
  164. function isProfiler(object) {
  165. return typeOf(object) === REACT_PROFILER_TYPE;
  166. }
  167. function isStrictMode(object) {
  168. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  169. }
  170. function isSuspense(object) {
  171. return typeOf(object) === REACT_SUSPENSE_TYPE;
  172. }
  173. exports.ContextConsumer = ContextConsumer;
  174. exports.ContextProvider = ContextProvider;
  175. exports.Element = Element;
  176. exports.ForwardRef = ForwardRef;
  177. exports.Fragment = Fragment;
  178. exports.Lazy = Lazy;
  179. exports.Memo = Memo;
  180. exports.Portal = Portal;
  181. exports.Profiler = Profiler;
  182. exports.StrictMode = StrictMode;
  183. exports.Suspense = Suspense;
  184. exports.isAsyncMode = isAsyncMode;
  185. exports.isConcurrentMode = isConcurrentMode;
  186. exports.isContextConsumer = isContextConsumer;
  187. exports.isContextProvider = isContextProvider;
  188. exports.isElement = isElement;
  189. exports.isForwardRef = isForwardRef;
  190. exports.isFragment = isFragment;
  191. exports.isLazy = isLazy;
  192. exports.isMemo = isMemo;
  193. exports.isPortal = isPortal;
  194. exports.isProfiler = isProfiler;
  195. exports.isStrictMode = isStrictMode;
  196. exports.isSuspense = isSuspense;
  197. exports.isValidElementType = isValidElementType;
  198. exports.typeOf = typeOf;
  199. })();
  200. }