Context.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = exports.ReactReduxContext = void 0;
  4. var React = _interopRequireWildcard(require("react"));
  5. function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
  6. function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  7. const ContextKey = Symbol.for(`react-redux-context`);
  8. const gT = typeof globalThis !== "undefined" ? globalThis :
  9. /* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
  10. {};
  11. function getContext() {
  12. var _gT$ContextKey;
  13. if (!React.createContext) return {};
  14. const contextMap = (_gT$ContextKey = gT[ContextKey]) != null ? _gT$ContextKey : gT[ContextKey] = new Map();
  15. let realContext = contextMap.get(React.createContext);
  16. if (!realContext) {
  17. realContext = React.createContext(null);
  18. if (process.env.NODE_ENV !== 'production') {
  19. realContext.displayName = 'ReactRedux';
  20. }
  21. contextMap.set(React.createContext, realContext);
  22. }
  23. return realContext;
  24. }
  25. const ReactReduxContext = /*#__PURE__*/getContext();
  26. exports.ReactReduxContext = ReactReduxContext;
  27. var _default = ReactReduxContext;
  28. exports.default = _default;