react-is.development.js 7.9 KB

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