@edx/frontend-platform 2.4.0 → 2.5.2

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.
Files changed (40) hide show
  1. package/auth/AxiosCsrfTokenService.js +6 -2
  2. package/auth/AxiosCsrfTokenService.js.map +1 -1
  3. package/auth/AxiosJwtAuthService.js +10 -6
  4. package/auth/AxiosJwtAuthService.js.map +1 -1
  5. package/auth/AxiosJwtTokenService.js +8 -4
  6. package/auth/AxiosJwtTokenService.js.map +1 -1
  7. package/auth/LocalForageCache.js +8 -4
  8. package/auth/LocalForageCache.js.map +1 -1
  9. package/auth/MockAuthService.js.map +1 -1
  10. package/auth/interceptors/createCsrfTokenProviderInterceptor.js +6 -2
  11. package/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -1
  12. package/auth/interceptors/createJwtTokenProviderInterceptor.js +6 -2
  13. package/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -1
  14. package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +6 -2
  15. package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -1
  16. package/auth/interceptors/createRetryInterceptor.js +9 -5
  17. package/auth/interceptors/createRetryInterceptor.js.map +1 -1
  18. package/auth/interface.js +10 -6
  19. package/auth/interface.js.map +1 -1
  20. package/config.js +5 -1
  21. package/config.js.map +1 -1
  22. package/i18n/countries.js +13 -13
  23. package/i18n/countries.js.map +1 -1
  24. package/i18n/injectIntlWithShim.js +3 -3
  25. package/i18n/languages.js +5 -5
  26. package/i18n/languages.js.map +1 -1
  27. package/initialize.js +126 -51
  28. package/initialize.js.map +1 -1
  29. package/package.json +4 -5
  30. package/react/AppProvider.js +10 -7
  31. package/react/AppProvider.js.map +1 -1
  32. package/react/ErrorBoundary.js +2 -2
  33. package/react/ErrorPage.js +49 -64
  34. package/react/ErrorPage.js.map +1 -1
  35. package/react/OptionalReduxProvider.js +1 -1
  36. package/react/OptionalReduxProvider.js.map +1 -1
  37. package/react/PageRoute.js +2 -1
  38. package/react/PageRoute.js.map +1 -1
  39. package/react/hooks.js +1 -1
  40. package/react/hooks.js.map +1 -1
@@ -1,29 +1,20 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
2
 
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
4
 
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
6
 
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
8
 
9
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
10
 
11
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
16
-
17
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
-
19
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
-
21
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
-
23
- import React, { Component } from 'react';
13
+ import React, { useState } from 'react';
24
14
  import PropTypes from 'prop-types';
25
15
  import { Button, Container, Row, Col } from '@edx/paragon';
26
- import { FormattedMessage } from '../i18n';
16
+ import { useAppEvent } from './hooks';
17
+ import { FormattedMessage, IntlProvider, getMessages, getLocale, LOCALE_CHANGED } from '../i18n';
27
18
  /**
28
19
  * An error page that displays a generic message for unexpected errors. Also contains a "Try
29
20
  * Again" button to refresh the page.
@@ -32,52 +23,46 @@ import { FormattedMessage } from '../i18n';
32
23
  * @extends {Component}
33
24
  */
34
25
 
35
- var ErrorPage = /*#__PURE__*/function (_Component) {
36
- _inherits(ErrorPage, _Component);
37
-
38
- var _super = _createSuper(ErrorPage);
39
-
40
- function ErrorPage() {
41
- _classCallCheck(this, ErrorPage);
42
-
43
- return _super.apply(this, arguments);
44
- }
45
-
46
- _createClass(ErrorPage, [{
47
- key: "reload",
48
- value:
49
- /* istanbul ignore next */
50
- function reload() {
51
- global.location.reload();
52
- }
53
- }, {
54
- key: "render",
55
- value: function render() {
56
- var message = this.props.message;
57
- return /*#__PURE__*/React.createElement(Container, {
58
- fluid: true,
59
- className: "py-5 justify-content-center align-items-start text-center"
60
- }, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/React.createElement("p", {
61
- className: "text-muted"
62
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
63
- id: "unexpected.error.message.text",
64
- defaultMessage: "An unexpected error occurred. Please click the button below to refresh the page.",
65
- description: "error message when an unexpected error occurs"
66
- })), message && /*#__PURE__*/React.createElement("div", {
67
- role: "alert",
68
- className: "my-4"
69
- }, /*#__PURE__*/React.createElement("p", null, message)), /*#__PURE__*/React.createElement(Button, {
70
- onClick: this.reload
71
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
72
- id: "unexpected.error.button.text",
73
- defaultMessage: "Try again",
74
- description: "text for button that tries to reload the app by refreshing the page"
75
- })))));
76
- }
77
- }]);
78
-
79
- return ErrorPage;
80
- }(Component);
26
+ function ErrorPage(_ref) {
27
+ var message = _ref.message;
28
+
29
+ var _useState = useState(getLocale()),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ locale = _useState2[0],
32
+ setLocale = _useState2[1];
33
+
34
+ useAppEvent(LOCALE_CHANGED, function () {
35
+ setLocale(getLocale());
36
+ });
37
+ /* istanbul ignore next */
38
+
39
+ var reload = function reload() {
40
+ global.location.reload();
41
+ };
42
+
43
+ return /*#__PURE__*/React.createElement(IntlProvider, {
44
+ locale: locale,
45
+ messages: getMessages()
46
+ }, /*#__PURE__*/React.createElement(Container, {
47
+ fluid: true,
48
+ className: "py-5 justify-content-center align-items-start text-center"
49
+ }, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/React.createElement("p", {
50
+ className: "text-muted"
51
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
52
+ id: "unexpected.error.message.text",
53
+ defaultMessage: "An unexpected error occurred. Please click the button below to refresh the page.",
54
+ description: "error message when an unexpected error occurs"
55
+ })), message && /*#__PURE__*/React.createElement("div", {
56
+ role: "alert",
57
+ className: "my-4"
58
+ }, /*#__PURE__*/React.createElement("p", null, message)), /*#__PURE__*/React.createElement(Button, {
59
+ onClick: reload
60
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
61
+ id: "unexpected.error.button.text",
62
+ defaultMessage: "Try again",
63
+ description: "text for button that tries to reload the app by refreshing the page"
64
+ }))))));
65
+ }
81
66
 
82
67
  ErrorPage.propTypes = {
83
68
  message: PropTypes.string
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorPage.js","names":["React","Component","PropTypes","Button","Container","Row","Col","FormattedMessage","ErrorPage","global","location","reload","message","props","propTypes","string","defaultProps"],"sources":["../../src/react/ErrorPage.jsx"],"sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport {\n Button, Container, Row, Col,\n} from '@edx/paragon';\n\nimport { FormattedMessage } from '../i18n';\n\n/**\n * An error page that displays a generic message for unexpected errors. Also contains a \"Try\n * Again\" button to refresh the page.\n *\n * @memberof module:React\n * @extends {Component}\n */\nclass ErrorPage extends Component {\n /* istanbul ignore next */\n reload() {\n global.location.reload();\n }\n\n render() {\n const { message } = this.props;\n return (\n <Container fluid className=\"py-5 justify-content-center align-items-start text-center\">\n <Row>\n <Col>\n <p className=\"text-muted\">\n <FormattedMessage\n id=\"unexpected.error.message.text\"\n defaultMessage=\"An unexpected error occurred. Please click the button below to refresh the page.\"\n description=\"error message when an unexpected error occurs\"\n />\n </p>\n {message && (\n <div role=\"alert\" className=\"my-4\">\n <p>{message}</p>\n </div>\n )}\n <Button onClick={this.reload}>\n <FormattedMessage\n id=\"unexpected.error.button.text\"\n defaultMessage=\"Try again\"\n description=\"text for button that tries to reload the app by refreshing the page\"\n />\n </Button>\n </Col>\n </Row>\n </Container>\n );\n }\n}\n\nErrorPage.propTypes = {\n message: PropTypes.string,\n};\n\nErrorPage.defaultProps = {\n message: null,\n};\n\nexport default ErrorPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SACEC,MADF,EACUC,SADV,EACqBC,GADrB,EAC0BC,GAD1B,QAEO,cAFP;AAIA,SAASC,gBAAT,QAAiC,SAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;IACMC,S;;;;;;;;;;;;;;IACJ;IACA,kBAAS;MACPC,MAAM,CAACC,QAAP,CAAgBC,MAAhB;IACD;;;WAED,kBAAS;MACP,IAAQC,OAAR,GAAoB,KAAKC,KAAzB,CAAQD,OAAR;MACA,oBACE,oBAAC,SAAD;QAAW,KAAK,MAAhB;QAAiB,SAAS,EAAC;MAA3B,gBACE,oBAAC,GAAD,qBACE,oBAAC,GAAD,qBACE;QAAG,SAAS,EAAC;MAAb,gBACE,oBAAC,gBAAD;QACE,EAAE,EAAC,+BADL;QAEE,cAAc,EAAC,kFAFjB;QAGE,WAAW,EAAC;MAHd,EADF,CADF,EAQGA,OAAO,iBACN;QAAK,IAAI,EAAC,OAAV;QAAkB,SAAS,EAAC;MAA5B,gBACE,+BAAIA,OAAJ,CADF,CATJ,eAaE,oBAAC,MAAD;QAAQ,OAAO,EAAE,KAAKD;MAAtB,gBACE,oBAAC,gBAAD;QACE,EAAE,EAAC,8BADL;QAEE,cAAc,EAAC,WAFjB;QAGE,WAAW,EAAC;MAHd,EADF,CAbF,CADF,CADF,CADF;IA2BD;;;;EAnCqBV,S;;AAsCxBO,SAAS,CAACM,SAAV,GAAsB;EACpBF,OAAO,EAAEV,SAAS,CAACa;AADC,CAAtB;AAIAP,SAAS,CAACQ,YAAV,GAAyB;EACvBJ,OAAO,EAAE;AADc,CAAzB;AAIA,eAAeJ,SAAf"}
1
+ {"version":3,"file":"ErrorPage.js","names":["React","useState","PropTypes","Button","Container","Row","Col","useAppEvent","FormattedMessage","IntlProvider","getMessages","getLocale","LOCALE_CHANGED","ErrorPage","message","locale","setLocale","reload","global","location","propTypes","string","defaultProps"],"sources":["../../src/react/ErrorPage.jsx"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport {\n Button, Container, Row, Col,\n} from '@edx/paragon';\n\nimport { useAppEvent } from './hooks';\nimport {\n FormattedMessage,\n IntlProvider,\n getMessages,\n getLocale,\n LOCALE_CHANGED,\n} from '../i18n';\n\n/**\n * An error page that displays a generic message for unexpected errors. Also contains a \"Try\n * Again\" button to refresh the page.\n *\n * @memberof module:React\n * @extends {Component}\n */\nfunction ErrorPage({\n message,\n}) {\n const [locale, setLocale] = useState(getLocale());\n\n useAppEvent(LOCALE_CHANGED, () => {\n setLocale(getLocale());\n });\n\n /* istanbul ignore next */\n const reload = () => {\n global.location.reload();\n };\n\n return (\n <IntlProvider locale={locale} messages={getMessages()}>\n <Container fluid className=\"py-5 justify-content-center align-items-start text-center\">\n <Row>\n <Col>\n <p className=\"text-muted\">\n <FormattedMessage\n id=\"unexpected.error.message.text\"\n defaultMessage=\"An unexpected error occurred. Please click the button below to refresh the page.\"\n description=\"error message when an unexpected error occurs\"\n />\n </p>\n {message && (\n <div role=\"alert\" className=\"my-4\">\n <p>{message}</p>\n </div>\n )}\n <Button onClick={reload}>\n <FormattedMessage\n id=\"unexpected.error.button.text\"\n defaultMessage=\"Try again\"\n description=\"text for button that tries to reload the app by refreshing the page\"\n />\n </Button>\n </Col>\n </Row>\n </Container>\n </IntlProvider>\n );\n}\n\nErrorPage.propTypes = {\n message: PropTypes.string,\n};\n\nErrorPage.defaultProps = {\n message: null,\n};\n\nexport default ErrorPage;\n"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SACEC,MADF,EACUC,SADV,EACqBC,GADrB,EAC0BC,GAD1B,QAEO,cAFP;AAIA,SAASC,WAAT,QAA4B,SAA5B;AACA,SACEC,gBADF,EAEEC,YAFF,EAGEC,WAHF,EAIEC,SAJF,EAKEC,cALF,QAMO,SANP;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,SAAT,OAEG;EAAA,IADDC,OACC,QADDA,OACC;;EACD,gBAA4Bb,QAAQ,CAACU,SAAS,EAAV,CAApC;EAAA;EAAA,IAAOI,MAAP;EAAA,IAAeC,SAAf;;EAEAT,WAAW,CAACK,cAAD,EAAiB,YAAM;IAChCI,SAAS,CAACL,SAAS,EAAV,CAAT;EACD,CAFU,CAAX;EAIA;;EACA,IAAMM,MAAM,GAAG,SAATA,MAAS,GAAM;IACnBC,MAAM,CAACC,QAAP,CAAgBF,MAAhB;EACD,CAFD;;EAIA,oBACE,oBAAC,YAAD;IAAc,MAAM,EAAEF,MAAtB;IAA8B,QAAQ,EAAEL,WAAW;EAAnD,gBACE,oBAAC,SAAD;IAAW,KAAK,MAAhB;IAAiB,SAAS,EAAC;EAA3B,gBACE,oBAAC,GAAD,qBACE,oBAAC,GAAD,qBACE;IAAG,SAAS,EAAC;EAAb,gBACE,oBAAC,gBAAD;IACE,EAAE,EAAC,+BADL;IAEE,cAAc,EAAC,kFAFjB;IAGE,WAAW,EAAC;EAHd,EADF,CADF,EAQGI,OAAO,iBACN;IAAK,IAAI,EAAC,OAAV;IAAkB,SAAS,EAAC;EAA5B,gBACE,+BAAIA,OAAJ,CADF,CATJ,eAaE,oBAAC,MAAD;IAAQ,OAAO,EAAEG;EAAjB,gBACE,oBAAC,gBAAD;IACE,EAAE,EAAC,8BADL;IAEE,cAAc,EAAC,WAFjB;IAGE,WAAW,EAAC;EAHd,EADF,CAbF,CADF,CADF,CADF,CADF;AA6BD;;AAEDJ,SAAS,CAACO,SAAV,GAAsB;EACpBN,OAAO,EAAEZ,SAAS,CAACmB;AADC,CAAtB;AAIAR,SAAS,CAACS,YAAV,GAAyB;EACvBR,OAAO,EAAE;AADc,CAAzB;AAIA,eAAeD,SAAf"}
@@ -11,7 +11,7 @@ export default function OptionalReduxProvider(_ref) {
11
11
  children = _ref.children;
12
12
 
13
13
  if (store === null) {
14
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
14
+ return children;
15
15
  }
16
16
 
17
17
  return /*#__PURE__*/React.createElement(Provider, {
@@ -1 +1 @@
1
- {"version":3,"file":"OptionalReduxProvider.js","names":["React","PropTypes","Provider","OptionalReduxProvider","store","children","propTypes","object","node","isRequired","defaultProps"],"sources":["../../src/react/OptionalReduxProvider.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Provider } from 'react-redux';\n\n/**\n * @memberof module:React\n * @param {Object} props\n */\nexport default function OptionalReduxProvider({ store, children }) {\n if (store === null) {\n return (\n <>{children}</>\n );\n }\n\n return (\n <Provider store={store}>\n {children}\n </Provider>\n );\n}\n\nOptionalReduxProvider.propTypes = {\n store: PropTypes.object, // eslint-disable-line\n children: PropTypes.node.isRequired,\n};\n\nOptionalReduxProvider.defaultProps = {\n store: null,\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,QAAT,QAAyB,aAAzB;AAEA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,OAAoD;EAAA,IAAnBC,KAAmB,QAAnBA,KAAmB;EAAA,IAAZC,QAAY,QAAZA,QAAY;;EACjE,IAAID,KAAK,KAAK,IAAd,EAAoB;IAClB,oBACE,0CAAGC,QAAH,CADF;EAGD;;EAED,oBACE,oBAAC,QAAD;IAAU,KAAK,EAAED;EAAjB,GACGC,QADH,CADF;AAKD;AAEDF,qBAAqB,CAACG,SAAtB,GAAkC;EAChCF,KAAK,EAAEH,SAAS,CAACM,MADe;EACP;EACzBF,QAAQ,EAAEJ,SAAS,CAACO,IAAV,CAAeC;AAFO,CAAlC;AAKAN,qBAAqB,CAACO,YAAtB,GAAqC;EACnCN,KAAK,EAAE;AAD4B,CAArC"}
1
+ {"version":3,"file":"OptionalReduxProvider.js","names":["React","PropTypes","Provider","OptionalReduxProvider","store","children","propTypes","object","node","isRequired","defaultProps"],"sources":["../../src/react/OptionalReduxProvider.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Provider } from 'react-redux';\n\n/**\n * @memberof module:React\n * @param {Object} props\n */\nexport default function OptionalReduxProvider({ store, children }) {\n if (store === null) {\n return children;\n }\n\n return (\n <Provider store={store}>\n {children}\n </Provider>\n );\n}\n\nOptionalReduxProvider.propTypes = {\n store: PropTypes.object, // eslint-disable-line\n children: PropTypes.node.isRequired,\n};\n\nOptionalReduxProvider.defaultProps = {\n store: null,\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,QAAT,QAAyB,aAAzB;AAEA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,OAAoD;EAAA,IAAnBC,KAAmB,QAAnBA,KAAmB;EAAA,IAAZC,QAAY,QAAZA,QAAY;;EACjE,IAAID,KAAK,KAAK,IAAd,EAAoB;IAClB,OAAOC,QAAP;EACD;;EAED,oBACE,oBAAC,QAAD;IAAU,KAAK,EAAED;EAAjB,GACGC,QADH,CADF;AAKD;AAEDF,qBAAqB,CAACG,SAAtB,GAAkC;EAChCF,KAAK,EAAEH,SAAS,CAACM,MADe;EACP;EACzBF,QAAQ,EAAEJ,SAAS,CAACO,IAAV,CAAeC;AAFO,CAAlC;AAKAN,qBAAqB,CAACO,YAAtB,GAAqC;EACnCN,KAAK,EAAE;AAD4B,CAArC"}
@@ -20,7 +20,8 @@ export default function PageRoute(props) {
20
20
  useEffect(function () {
21
21
  if (match) {
22
22
  sendPageEvent();
23
- }
23
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
24
+
24
25
  }, [JSON.stringify(match)]);
25
26
  return /*#__PURE__*/React.createElement(Route, props);
26
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PageRoute.js","names":["React","useEffect","Route","useRouteMatch","sendPageEvent","PageRoute","props","match","path","exact","strict","sensitive","JSON","stringify"],"sources":["../../src/react/PageRoute.jsx"],"sourcesContent":["/* eslint-disable react/prop-types */\nimport React, { useEffect } from 'react';\nimport { Route, useRouteMatch } from 'react-router-dom';\nimport { sendPageEvent } from '../analytics';\n\n/**\n * A react-router Route component that calls `sendPageEvent` when it becomes active.\n *\n * @see {@link module:frontend-platform/analytics~sendPageEvent}\n * @memberof module:React\n * @param {Object} props\n */\nexport default function PageRoute(props) {\n const match = useRouteMatch({\n path: props.path,\n exact: props.exact,\n strict: props.strict,\n sensitive: props.sensitive,\n });\n\n useEffect(() => {\n if (match) {\n sendPageEvent();\n }\n }, [JSON.stringify(match)]);\n\n return (\n <Route {...props} />\n );\n}\n"],"mappings":"AAAA;AACA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,KAAT,EAAgBC,aAAhB,QAAqC,kBAArC;AACA,SAASC,aAAT,QAA8B,cAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,SAAT,CAAmBC,KAAnB,EAA0B;EACvC,IAAMC,KAAK,GAAGJ,aAAa,CAAC;IAC1BK,IAAI,EAAEF,KAAK,CAACE,IADc;IAE1BC,KAAK,EAAEH,KAAK,CAACG,KAFa;IAG1BC,MAAM,EAAEJ,KAAK,CAACI,MAHY;IAI1BC,SAAS,EAAEL,KAAK,CAACK;EAJS,CAAD,CAA3B;EAOAV,SAAS,CAAC,YAAM;IACd,IAAIM,KAAJ,EAAW;MACTH,aAAa;IACd;EACF,CAJQ,EAIN,CAACQ,IAAI,CAACC,SAAL,CAAeN,KAAf,CAAD,CAJM,CAAT;EAMA,oBACE,oBAAC,KAAD,EAAWD,KAAX,CADF;AAGD"}
1
+ {"version":3,"file":"PageRoute.js","names":["React","useEffect","Route","useRouteMatch","sendPageEvent","PageRoute","props","match","path","exact","strict","sensitive","JSON","stringify"],"sources":["../../src/react/PageRoute.jsx"],"sourcesContent":["/* eslint-disable react/prop-types */\nimport React, { useEffect } from 'react';\nimport { Route, useRouteMatch } from 'react-router-dom';\nimport { sendPageEvent } from '../analytics';\n\n/**\n * A react-router Route component that calls `sendPageEvent` when it becomes active.\n *\n * @see {@link module:frontend-platform/analytics~sendPageEvent}\n * @memberof module:React\n * @param {Object} props\n */\nexport default function PageRoute(props) {\n const match = useRouteMatch({\n path: props.path,\n exact: props.exact,\n strict: props.strict,\n sensitive: props.sensitive,\n });\n\n useEffect(() => {\n if (match) {\n sendPageEvent();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(match)]);\n\n return (\n <Route {...props} />\n );\n}\n"],"mappings":"AAAA;AACA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,KAAT,EAAgBC,aAAhB,QAAqC,kBAArC;AACA,SAASC,aAAT,QAA8B,cAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,SAAT,CAAmBC,KAAnB,EAA0B;EACvC,IAAMC,KAAK,GAAGJ,aAAa,CAAC;IAC1BK,IAAI,EAAEF,KAAK,CAACE,IADc;IAE1BC,KAAK,EAAEH,KAAK,CAACG,KAFa;IAG1BC,MAAM,EAAEJ,KAAK,CAACI,MAHY;IAI1BC,SAAS,EAAEL,KAAK,CAACK;EAJS,CAAD,CAA3B;EAOAV,SAAS,CAAC,YAAM;IACd,IAAIM,KAAJ,EAAW;MACTH,aAAa;IACd,CAHa,CAIhB;;EACC,CALQ,EAKN,CAACQ,IAAI,CAACC,SAAL,CAAeN,KAAf,CAAD,CALM,CAAT;EAOA,oBACE,oBAAC,KAAD,EAAWD,KAAX,CADF;AAGD"}
package/react/hooks.js CHANGED
@@ -18,6 +18,6 @@ export var useAppEvent = function useAppEvent(type, callback) {
18
18
  return function cleanup() {
19
19
  unsubscribe(subscriptionToken);
20
20
  };
21
- }, []);
21
+ }, [callback, type]);
22
22
  };
23
23
  //# sourceMappingURL=hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","names":["useEffect","subscribe","unsubscribe","useAppEvent","type","callback","subscriptionToken","cleanup"],"sources":["../../src/react/hooks.js"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { useEffect } from 'react';\nimport { subscribe, unsubscribe } from '../pubSub';\n\n/**\n * A React hook that allows functional components to subscribe to application events. This should\n * be used sparingly - for the most part, Context should be used higher-up in the application to\n * provide necessary data to a given component, rather than utilizing a non-React-like Pub/Sub\n * mechanism.\n *\n * @memberof module:React\n * @param {string} type\n * @param {function} callback\n */\nexport const useAppEvent = (type, callback) => {\n useEffect(() => {\n const subscriptionToken = subscribe(type, callback);\n\n return function cleanup() {\n unsubscribe(subscriptionToken);\n };\n }, []);\n};\n"],"mappings":"AAAA;AACA,SAASA,SAAT,QAA0B,OAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,WAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,IAAD,EAAOC,QAAP,EAAoB;EAC7CL,SAAS,CAAC,YAAM;IACd,IAAMM,iBAAiB,GAAGL,SAAS,CAACG,IAAD,EAAOC,QAAP,CAAnC;IAEA,OAAO,SAASE,OAAT,GAAmB;MACxBL,WAAW,CAACI,iBAAD,CAAX;IACD,CAFD;EAGD,CANQ,EAMN,EANM,CAAT;AAOD,CARM"}
1
+ {"version":3,"file":"hooks.js","names":["useEffect","subscribe","unsubscribe","useAppEvent","type","callback","subscriptionToken","cleanup"],"sources":["../../src/react/hooks.js"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { useEffect } from 'react';\nimport { subscribe, unsubscribe } from '../pubSub';\n\n/**\n * A React hook that allows functional components to subscribe to application events. This should\n * be used sparingly - for the most part, Context should be used higher-up in the application to\n * provide necessary data to a given component, rather than utilizing a non-React-like Pub/Sub\n * mechanism.\n *\n * @memberof module:React\n * @param {string} type\n * @param {function} callback\n */\nexport const useAppEvent = (type, callback) => {\n useEffect(() => {\n const subscriptionToken = subscribe(type, callback);\n\n return function cleanup() {\n unsubscribe(subscriptionToken);\n };\n }, [callback, type]);\n};\n"],"mappings":"AAAA;AACA,SAASA,SAAT,QAA0B,OAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,WAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,IAAD,EAAOC,QAAP,EAAoB;EAC7CL,SAAS,CAAC,YAAM;IACd,IAAMM,iBAAiB,GAAGL,SAAS,CAACG,IAAD,EAAOC,QAAP,CAAnC;IAEA,OAAO,SAASE,OAAT,GAAmB;MACxBL,WAAW,CAACI,iBAAD,CAAX;IACD,CAFD;EAGD,CANQ,EAMN,CAACD,QAAD,EAAWD,IAAX,CANM,CAAT;AAOD,CARM"}