react-router 5.3.2 → 5.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  (global = global || self, factory(global.ReactRouter = {}, global.React));
5
5
  }(this, function (exports, React) { 'use strict';
6
6
 
7
- var React__default = 'default' in React ? React['default'] : React;
7
+ React = React && React.hasOwnProperty('default') ? React['default'] : React;
8
8
 
9
9
  function _setPrototypeOf(o, p) {
10
10
  _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
@@ -1581,17 +1581,24 @@
1581
1581
  }
1582
1582
 
1583
1583
  var MAX_SIGNED_31_BIT_INT = 1073741823;
1584
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
1584
+ var commonjsGlobal = typeof globalThis !== "undefined" // 'global proper'
1585
+ ? // eslint-disable-next-line no-undef
1586
+ globalThis : typeof window !== "undefined" ? window // Browser
1587
+ : typeof global !== "undefined" ? global // node.js
1588
+ : {};
1585
1589
 
1586
1590
  function getUniqueId() {
1587
- var key = '__global_unique_id__';
1591
+ var key = "__global_unique_id__";
1588
1592
  return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
1589
- }
1593
+ } // Inlined Object.is polyfill.
1594
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1595
+
1590
1596
 
1591
1597
  function objectIs(x, y) {
1592
1598
  if (x === y) {
1593
1599
  return x !== 0 || 1 / x === 1 / y;
1594
1600
  } else {
1601
+ // eslint-disable-next-line no-self-compare
1595
1602
  return x !== x && y !== y;
1596
1603
  }
1597
1604
  }
@@ -1626,15 +1633,19 @@
1626
1633
  function createReactContext(defaultValue, calculateChangedBits) {
1627
1634
  var _Provider$childContex, _Consumer$contextType;
1628
1635
 
1629
- var contextProp = '__create-react-context-' + getUniqueId() + '__';
1636
+ var contextProp = "__create-react-context-" + getUniqueId() + "__";
1630
1637
 
1631
- var Provider = /*#__PURE__*/function (_Component) {
1632
- _inheritsLoose(Provider, _Component);
1638
+ var Provider = /*#__PURE__*/function (_React$Component) {
1639
+ _inheritsLoose(Provider, _React$Component);
1633
1640
 
1634
1641
  function Provider() {
1635
1642
  var _this;
1636
1643
 
1637
- _this = _Component.apply(this, arguments) || this;
1644
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1645
+ args[_key] = arguments[_key];
1646
+ }
1647
+
1648
+ _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
1638
1649
  _this.emitter = createEventEmitter(_this.props.value);
1639
1650
  return _this;
1640
1651
  }
@@ -1654,12 +1665,12 @@
1654
1665
  var changedBits;
1655
1666
 
1656
1667
  if (objectIs(oldValue, newValue)) {
1657
- changedBits = 0;
1668
+ changedBits = 0; // No change
1658
1669
  } else {
1659
- changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
1670
+ changedBits = typeof calculateChangedBits === "function" ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
1660
1671
 
1661
1672
  {
1662
- warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: ' + changedBits);
1673
+ warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, "calculateChangedBits: Expected the return value to be a " + "31-bit integer. Instead received: " + changedBits) ;
1663
1674
  }
1664
1675
 
1665
1676
  changedBits |= 0;
@@ -1680,13 +1691,18 @@
1680
1691
 
1681
1692
  Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = propTypes.object.isRequired, _Provider$childContex);
1682
1693
 
1683
- var Consumer = /*#__PURE__*/function (_Component2) {
1684
- _inheritsLoose(Consumer, _Component2);
1694
+ var Consumer = /*#__PURE__*/function (_React$Component2) {
1695
+ _inheritsLoose(Consumer, _React$Component2);
1685
1696
 
1686
1697
  function Consumer() {
1687
1698
  var _this2;
1688
1699
 
1689
- _this2 = _Component2.apply(this, arguments) || this;
1700
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1701
+ args[_key2] = arguments[_key2];
1702
+ }
1703
+
1704
+ _this2 = _React$Component2.call.apply(_React$Component2, [this].concat(args)) || this;
1705
+ _this2.observedBits = void 0;
1690
1706
  _this2.state = {
1691
1707
  value: _this2.getValue()
1692
1708
  };
@@ -1708,7 +1724,8 @@
1708
1724
 
1709
1725
  _proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
1710
1726
  var observedBits = nextProps.observedBits;
1711
- this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
1727
+ this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default
1728
+ : observedBits;
1712
1729
  };
1713
1730
 
1714
1731
  _proto2.componentDidMount = function componentDidMount() {
@@ -1717,7 +1734,8 @@
1717
1734
  }
1718
1735
 
1719
1736
  var observedBits = this.props.observedBits;
1720
- this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
1737
+ this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default
1738
+ : observedBits;
1721
1739
  };
1722
1740
 
1723
1741
  _proto2.componentWillUnmount = function componentWillUnmount() {
@@ -1748,12 +1766,13 @@
1748
1766
  };
1749
1767
  }
1750
1768
 
1751
- var index = React__default.createContext || createReactContext;
1769
+ // MIT License
1770
+ var createContext = React.createContext || createReactContext;
1752
1771
 
1753
1772
  // TODO: Replace with React.createContext once we can assume React 16+
1754
1773
 
1755
1774
  var createNamedContext = function createNamedContext(name) {
1756
- var context = index();
1775
+ var context = createContext();
1757
1776
  context.displayName = name;
1758
1777
  return context;
1759
1778
  };
@@ -1841,21 +1860,21 @@
1841
1860
  };
1842
1861
 
1843
1862
  _proto.render = function render() {
1844
- return /*#__PURE__*/React__default.createElement(context.Provider, {
1863
+ return /*#__PURE__*/React.createElement(context.Provider, {
1845
1864
  value: {
1846
1865
  history: this.props.history,
1847
1866
  location: this.state.location,
1848
1867
  match: Router.computeRootMatch(this.state.location.pathname),
1849
1868
  staticContext: this.props.staticContext
1850
1869
  }
1851
- }, /*#__PURE__*/React__default.createElement(historyContext.Provider, {
1870
+ }, /*#__PURE__*/React.createElement(historyContext.Provider, {
1852
1871
  children: this.props.children || null,
1853
1872
  value: this.props.history
1854
1873
  }));
1855
1874
  };
1856
1875
 
1857
1876
  return Router;
1858
- }(React__default.Component);
1877
+ }(React.Component);
1859
1878
 
1860
1879
  {
1861
1880
  Router.propTypes = {
@@ -1891,14 +1910,14 @@
1891
1910
  var _proto = MemoryRouter.prototype;
1892
1911
 
1893
1912
  _proto.render = function render() {
1894
- return /*#__PURE__*/React__default.createElement(Router, {
1913
+ return /*#__PURE__*/React.createElement(Router, {
1895
1914
  history: this.history,
1896
1915
  children: this.props.children
1897
1916
  });
1898
1917
  };
1899
1918
 
1900
1919
  return MemoryRouter;
1901
- }(React__default.Component);
1920
+ }(React.Component);
1902
1921
 
1903
1922
  {
1904
1923
  MemoryRouter.propTypes = {
@@ -1940,7 +1959,7 @@
1940
1959
  };
1941
1960
 
1942
1961
  return Lifecycle;
1943
- }(React__default.Component);
1962
+ }(React.Component);
1944
1963
 
1945
1964
  /**
1946
1965
  * The public API for prompting the user before navigating away from a screen.
@@ -1950,11 +1969,11 @@
1950
1969
  var message = _ref.message,
1951
1970
  _ref$when = _ref.when,
1952
1971
  when = _ref$when === void 0 ? true : _ref$when;
1953
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
1972
+ return /*#__PURE__*/React.createElement(context.Consumer, null, function (context) {
1954
1973
  !context ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
1955
1974
  if (!when || context.staticContext) return null;
1956
1975
  var method = context.history.block;
1957
- return /*#__PURE__*/React__default.createElement(Lifecycle, {
1976
+ return /*#__PURE__*/React.createElement(Lifecycle, {
1958
1977
  onMount: function onMount(self) {
1959
1978
  self.release = method(message);
1960
1979
  },
@@ -2456,7 +2475,7 @@
2456
2475
  to = _ref.to,
2457
2476
  _ref$push = _ref.push,
2458
2477
  push = _ref$push === void 0 ? false : _ref$push;
2459
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
2478
+ return /*#__PURE__*/React.createElement(context.Consumer, null, function (context) {
2460
2479
  !context ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
2461
2480
  var history = context.history,
2462
2481
  staticContext = context.staticContext;
@@ -2471,7 +2490,7 @@
2471
2490
  return null;
2472
2491
  }
2473
2492
 
2474
- return /*#__PURE__*/React__default.createElement(Lifecycle, {
2493
+ return /*#__PURE__*/React.createElement(Lifecycle, {
2475
2494
  onMount: function onMount() {
2476
2495
  method(location);
2477
2496
  },
@@ -2578,7 +2597,7 @@
2578
2597
  }
2579
2598
 
2580
2599
  function isEmptyChildren(children) {
2581
- return React__default.Children.count(children) === 0;
2600
+ return React.Children.count(children) === 0;
2582
2601
  }
2583
2602
 
2584
2603
  function evalChildrenDev(children, props, path) {
@@ -2603,7 +2622,7 @@
2603
2622
  _proto.render = function render() {
2604
2623
  var _this = this;
2605
2624
 
2606
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context$1) {
2625
+ return /*#__PURE__*/React.createElement(context.Consumer, null, function (context$1) {
2607
2626
  !context$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
2608
2627
  var location = _this.props.location || context$1.location;
2609
2628
  var match = _this.props.computedMatch ? _this.props.computedMatch // <Switch> already computed the match for us
@@ -2624,14 +2643,14 @@
2624
2643
  children = null;
2625
2644
  }
2626
2645
 
2627
- return /*#__PURE__*/React__default.createElement(context.Provider, {
2646
+ return /*#__PURE__*/React.createElement(context.Provider, {
2628
2647
  value: props
2629
- }, props.match ? children ? typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : children : component ? /*#__PURE__*/React__default.createElement(component, props) : render ? render(props) : null : typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : null);
2648
+ }, props.match ? children ? typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : children : component ? /*#__PURE__*/React.createElement(component, props) : render ? render(props) : null : typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : null);
2630
2649
  });
2631
2650
  };
2632
2651
 
2633
2652
  return Route;
2634
- }(React__default.Component);
2653
+ }(React.Component);
2635
2654
 
2636
2655
  {
2637
2656
  Route.propTypes = {
@@ -2783,14 +2802,14 @@
2783
2802
  listen: this.handleListen,
2784
2803
  block: this.handleBlock
2785
2804
  };
2786
- return /*#__PURE__*/React__default.createElement(Router, _extends({}, rest, {
2805
+ return /*#__PURE__*/React.createElement(Router, _extends({}, rest, {
2787
2806
  history: history,
2788
2807
  staticContext: context
2789
2808
  }));
2790
2809
  };
2791
2810
 
2792
2811
  return StaticRouter;
2793
- }(React__default.Component);
2812
+ }(React.Component);
2794
2813
 
2795
2814
  {
2796
2815
  StaticRouter.propTypes = {
@@ -2820,7 +2839,7 @@
2820
2839
  _proto.render = function render() {
2821
2840
  var _this = this;
2822
2841
 
2823
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
2842
+ return /*#__PURE__*/React.createElement(context.Consumer, null, function (context) {
2824
2843
  !context ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
2825
2844
  var location = _this.props.location || context.location;
2826
2845
  var element, match; // We use React.Children.forEach instead of React.Children.toArray().find()
@@ -2828,8 +2847,8 @@
2828
2847
  // to trigger an unmount/remount for two <Route>s that render the same
2829
2848
  // component at different URLs.
2830
2849
 
2831
- React__default.Children.forEach(_this.props.children, function (child) {
2832
- if (match == null && /*#__PURE__*/React__default.isValidElement(child)) {
2850
+ React.Children.forEach(_this.props.children, function (child) {
2851
+ if (match == null && /*#__PURE__*/React.isValidElement(child)) {
2833
2852
  element = child;
2834
2853
  var path = child.props.path || child.props.from;
2835
2854
  match = path ? matchPath(location.pathname, _extends({}, child.props, {
@@ -2837,7 +2856,7 @@
2837
2856
  })) : context.match;
2838
2857
  }
2839
2858
  });
2840
- return match ? /*#__PURE__*/React__default.cloneElement(element, {
2859
+ return match ? /*#__PURE__*/React.cloneElement(element, {
2841
2860
  location: location,
2842
2861
  computedMatch: match
2843
2862
  }) : null;
@@ -2845,7 +2864,7 @@
2845
2864
  };
2846
2865
 
2847
2866
  return Switch;
2848
- }(React__default.Component);
2867
+ }(React.Component);
2849
2868
 
2850
2869
  {
2851
2870
  Switch.propTypes = {
@@ -2972,9 +2991,9 @@
2972
2991
  var wrappedComponentRef = props.wrappedComponentRef,
2973
2992
  remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
2974
2993
 
2975
- return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
2994
+ return /*#__PURE__*/React.createElement(context.Consumer, null, function (context) {
2976
2995
  !context ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
2977
- return /*#__PURE__*/React__default.createElement(Component, _extends({}, remainingProps, context, {
2996
+ return /*#__PURE__*/React.createElement(Component, _extends({}, remainingProps, context, {
2978
2997
  ref: wrappedComponentRef
2979
2998
  }));
2980
2999
  });
@@ -2992,7 +3011,7 @@
2992
3011
  return hoistNonReactStatics_cjs(C, Component);
2993
3012
  }
2994
3013
 
2995
- var useContext = React__default.useContext;
3014
+ var useContext = React.useContext;
2996
3015
  function useHistory() {
2997
3016
  {
2998
3017
  !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;