@edx/frontend-platform 3.6.0 → 4.0.0
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.
- package/analytics/MockAnalyticsService.js +31 -19
- package/analytics/MockAnalyticsService.js.map +1 -1
- package/analytics/SegmentAnalyticsService.js +53 -57
- package/analytics/SegmentAnalyticsService.js.map +1 -1
- package/analytics/index.js.map +1 -1
- package/analytics/interface.js +9 -9
- package/analytics/interface.js.map +1 -1
- package/auth/AxiosCsrfTokenService.js +36 -58
- package/auth/AxiosCsrfTokenService.js.map +1 -1
- package/auth/AxiosJwtAuthService.js +105 -150
- package/auth/AxiosJwtAuthService.js.map +1 -1
- package/auth/AxiosJwtTokenService.js +101 -148
- package/auth/AxiosJwtTokenService.js.map +1 -1
- package/auth/LocalForageCache.js +89 -108
- package/auth/LocalForageCache.js.map +1 -1
- package/auth/MockAuthService.js +114 -43
- package/auth/MockAuthService.js.map +1 -1
- package/auth/index.js.map +1 -1
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js +35 -50
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createJwtTokenProviderInterceptor.js +33 -47
- package/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +15 -27
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -1
- package/auth/interceptors/createRetryInterceptor.js +75 -105
- package/auth/interceptors/createRetryInterceptor.js.map +1 -1
- package/auth/interface.js +41 -58
- package/auth/interface.js.map +1 -1
- package/auth/utils.js +22 -40
- package/auth/utils.js.map +1 -1
- package/config.js +6 -7
- package/config.js.map +1 -1
- package/constants.js +8 -8
- package/constants.js.map +1 -1
- package/i18n/countries.js +9 -15
- package/i18n/countries.js.map +1 -1
- package/i18n/index.js +1 -0
- package/i18n/index.js.map +1 -1
- package/i18n/injectIntlWithShim.js +4 -28
- package/i18n/injectIntlWithShim.js.map +1 -1
- package/i18n/languages.js +11 -17
- package/i18n/languages.js.map +1 -1
- package/i18n/lib.js +64 -56
- package/i18n/lib.js.map +1 -1
- package/i18n/scripts/transifex-utils.js +5 -20
- package/i18n/scripts/transifex-utils.js.map +1 -1
- package/index.js.map +1 -1
- package/initialize.js +176 -228
- package/initialize.js.map +1 -1
- package/logging/MockLoggingService.js +15 -9
- package/logging/MockLoggingService.js.map +1 -1
- package/logging/NewRelicLoggingService.js +9 -33
- package/logging/NewRelicLoggingService.js.map +1 -1
- package/logging/index.js.map +1 -1
- package/logging/interface.js +7 -6
- package/logging/interface.js.map +1 -1
- package/package.json +4 -4
- package/pubSub.js +4 -3
- package/pubSub.js.map +1 -1
- package/react/AppContext.js +1 -1
- package/react/AppContext.js.map +1 -1
- package/react/AppProvider.js +13 -23
- package/react/AppProvider.js.map +1 -1
- package/react/AuthenticatedPageRoute.js +5 -13
- package/react/AuthenticatedPageRoute.js.map +1 -1
- package/react/ErrorBoundary.js +4 -21
- package/react/ErrorBoundary.js.map +1 -1
- package/react/ErrorPage.js +7 -17
- package/react/ErrorPage.js.map +1 -1
- package/react/LoginRedirect.js +1 -1
- package/react/LoginRedirect.js.map +1 -1
- package/react/OptionalReduxProvider.js +2 -4
- package/react/OptionalReduxProvider.js.map +1 -1
- package/react/PageRoute.js +3 -3
- package/react/PageRoute.js.map +1 -1
- package/react/hooks.js +2 -6
- package/react/hooks.js.map +1 -1
- package/react/index.js +1 -0
- package/react/index.js.map +1 -1
- package/testing/index.js +1 -0
- package/testing/index.js.map +1 -1
- package/testing/initializeMockApp.js +11 -11
- package/testing/initializeMockApp.js.map +1 -1
- package/testing/mockMessages.js.map +1 -1
- package/utils.js +15 -24
- package/utils.js.map +1 -1
package/react/AppProvider.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
2
|
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
|
-
|
|
5
3
|
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
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
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
|
-
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
11
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
7
|
import React, { useState, useMemo } from 'react';
|
|
14
8
|
import PropTypes from 'prop-types';
|
|
15
9
|
import { Router } from 'react-router-dom';
|
|
@@ -22,6 +16,7 @@ import { getConfig } from '../config';
|
|
|
22
16
|
import { CONFIG_CHANGED } from '../constants';
|
|
23
17
|
import { history } from '../initialize';
|
|
24
18
|
import { getLocale, getMessages, IntlProvider, LOCALE_CHANGED } from '../i18n';
|
|
19
|
+
|
|
25
20
|
/**
|
|
26
21
|
* A wrapper component for React-based micro-frontends to initialize a number of common data/
|
|
27
22
|
* context providers.
|
|
@@ -48,26 +43,21 @@ import { getLocale, getMessages, IntlProvider, LOCALE_CHANGED } from '../i18n';
|
|
|
48
43
|
* @param {Object} [props.store] A redux store.
|
|
49
44
|
* @memberof module:React
|
|
50
45
|
*/
|
|
51
|
-
|
|
52
46
|
export default function AppProvider(_ref) {
|
|
53
47
|
var store = _ref.store,
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
children = _ref.children;
|
|
56
49
|
var _useState = useState(getConfig()),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
51
|
+
config = _useState2[0],
|
|
52
|
+
setConfig = _useState2[1];
|
|
61
53
|
var _useState3 = useState(getAuthenticatedUser()),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
55
|
+
authenticatedUser = _useState4[0],
|
|
56
|
+
setAuthenticatedUser = _useState4[1];
|
|
66
57
|
var _useState5 = useState(getLocale()),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
59
|
+
locale = _useState6[0],
|
|
60
|
+
setLocale = _useState6[1];
|
|
71
61
|
useTrackColorSchemeChoice();
|
|
72
62
|
useAppEvent(AUTHENTICATED_USER_CHANGED, function () {
|
|
73
63
|
setAuthenticatedUser(getAuthenticatedUser());
|
package/react/AppProvider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProvider.js","names":["React","useState","useMemo","PropTypes","Router","OptionalReduxProvider","ErrorBoundary","AppContext","useAppEvent","useTrackColorSchemeChoice","getAuthenticatedUser","AUTHENTICATED_USER_CHANGED","getConfig","CONFIG_CHANGED","history","getLocale","getMessages","IntlProvider","LOCALE_CHANGED","AppProvider","store","children","config","setConfig","authenticatedUser","setAuthenticatedUser","locale","setLocale","appContextValue","propTypes","object","node","isRequired","defaultProps"],"sources":["../../src/react/AppProvider.jsx"],"sourcesContent":["import React, { useState, useMemo } from 'react';\nimport PropTypes from 'prop-types';\nimport { Router } from 'react-router-dom';\n\nimport OptionalReduxProvider from './OptionalReduxProvider';\n\nimport ErrorBoundary from './ErrorBoundary';\nimport AppContext from './AppContext';\nimport { useAppEvent, useTrackColorSchemeChoice } from './hooks';\nimport { getAuthenticatedUser, AUTHENTICATED_USER_CHANGED } from '../auth';\nimport { getConfig } from '../config';\nimport { CONFIG_CHANGED } from '../constants';\nimport { history } from '../initialize';\nimport {\n getLocale,\n getMessages,\n IntlProvider,\n LOCALE_CHANGED,\n} from '../i18n';\n\n/**\n * A wrapper component for React-based micro-frontends to initialize a number of common data/\n * context providers.\n *\n * ```\n * subscribe(APP_READY, () => {\n * ReactDOM.render(\n * <AppProvider>\n * <HelloWorld />\n * </AppProvider>\n * )\n * });\n * ```\n *\n * This will provide the following to HelloWorld:\n * - An error boundary as described above.\n * - An `AppContext` provider for React context data.\n * - IntlProvider for @edx/frontend-i18n internationalization\n * - Optionally a redux `Provider`. Will only be included if a `store` property is passed to\n * `AppProvider`.\n * - A `Router` for react-router.\n *\n * @param {Object} props\n * @param {Object} [props.store] A redux store.\n * @memberof module:React\n */\nexport default function AppProvider({ store, children }) {\n const [config, setConfig] = useState(getConfig());\n const [authenticatedUser, setAuthenticatedUser] = useState(getAuthenticatedUser());\n const [locale, setLocale] = useState(getLocale());\n\n useTrackColorSchemeChoice();\n\n useAppEvent(AUTHENTICATED_USER_CHANGED, () => {\n setAuthenticatedUser(getAuthenticatedUser());\n });\n\n useAppEvent(CONFIG_CHANGED, () => {\n setConfig(getConfig());\n });\n\n useAppEvent(LOCALE_CHANGED, () => {\n setLocale(getLocale());\n });\n\n const appContextValue = useMemo(() => ({ authenticatedUser, config, locale }), [authenticatedUser, config, locale]);\n\n return (\n <IntlProvider locale={locale} messages={getMessages()}>\n <ErrorBoundary>\n <AppContext.Provider\n value={appContextValue}\n >\n <OptionalReduxProvider store={store}>\n <Router history={history}>\n {children}\n </Router>\n </OptionalReduxProvider>\n </AppContext.Provider>\n </ErrorBoundary>\n </IntlProvider>\n );\n}\n\nAppProvider.propTypes = {\n // eslint-disable-next-line react/forbid-prop-types\n store: PropTypes.object,\n children: PropTypes.node.isRequired,\n};\n\nAppProvider.defaultProps = {\n store: null,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AppProvider.js","names":["React","useState","useMemo","PropTypes","Router","OptionalReduxProvider","ErrorBoundary","AppContext","useAppEvent","useTrackColorSchemeChoice","getAuthenticatedUser","AUTHENTICATED_USER_CHANGED","getConfig","CONFIG_CHANGED","history","getLocale","getMessages","IntlProvider","LOCALE_CHANGED","AppProvider","_ref","store","children","_useState","_useState2","_slicedToArray","config","setConfig","_useState3","_useState4","authenticatedUser","setAuthenticatedUser","_useState5","_useState6","locale","setLocale","appContextValue","createElement","messages","Provider","value","propTypes","object","node","isRequired","defaultProps"],"sources":["../../src/react/AppProvider.jsx"],"sourcesContent":["import React, { useState, useMemo } from 'react';\nimport PropTypes from 'prop-types';\nimport { Router } from 'react-router-dom';\n\nimport OptionalReduxProvider from './OptionalReduxProvider';\n\nimport ErrorBoundary from './ErrorBoundary';\nimport AppContext from './AppContext';\nimport { useAppEvent, useTrackColorSchemeChoice } from './hooks';\nimport { getAuthenticatedUser, AUTHENTICATED_USER_CHANGED } from '../auth';\nimport { getConfig } from '../config';\nimport { CONFIG_CHANGED } from '../constants';\nimport { history } from '../initialize';\nimport {\n getLocale,\n getMessages,\n IntlProvider,\n LOCALE_CHANGED,\n} from '../i18n';\n\n/**\n * A wrapper component for React-based micro-frontends to initialize a number of common data/\n * context providers.\n *\n * ```\n * subscribe(APP_READY, () => {\n * ReactDOM.render(\n * <AppProvider>\n * <HelloWorld />\n * </AppProvider>\n * )\n * });\n * ```\n *\n * This will provide the following to HelloWorld:\n * - An error boundary as described above.\n * - An `AppContext` provider for React context data.\n * - IntlProvider for @edx/frontend-i18n internationalization\n * - Optionally a redux `Provider`. Will only be included if a `store` property is passed to\n * `AppProvider`.\n * - A `Router` for react-router.\n *\n * @param {Object} props\n * @param {Object} [props.store] A redux store.\n * @memberof module:React\n */\nexport default function AppProvider({ store, children }) {\n const [config, setConfig] = useState(getConfig());\n const [authenticatedUser, setAuthenticatedUser] = useState(getAuthenticatedUser());\n const [locale, setLocale] = useState(getLocale());\n\n useTrackColorSchemeChoice();\n\n useAppEvent(AUTHENTICATED_USER_CHANGED, () => {\n setAuthenticatedUser(getAuthenticatedUser());\n });\n\n useAppEvent(CONFIG_CHANGED, () => {\n setConfig(getConfig());\n });\n\n useAppEvent(LOCALE_CHANGED, () => {\n setLocale(getLocale());\n });\n\n const appContextValue = useMemo(() => ({ authenticatedUser, config, locale }), [authenticatedUser, config, locale]);\n\n return (\n <IntlProvider locale={locale} messages={getMessages()}>\n <ErrorBoundary>\n <AppContext.Provider\n value={appContextValue}\n >\n <OptionalReduxProvider store={store}>\n <Router history={history}>\n {children}\n </Router>\n </OptionalReduxProvider>\n </AppContext.Provider>\n </ErrorBoundary>\n </IntlProvider>\n );\n}\n\nAppProvider.propTypes = {\n // eslint-disable-next-line react/forbid-prop-types\n store: PropTypes.object,\n children: PropTypes.node.isRequired,\n};\n\nAppProvider.defaultProps = {\n store: null,\n};\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,MAAM,QAAQ,kBAAkB;AAEzC,OAAOC,qBAAqB,MAAM,yBAAyB;AAE3D,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,UAAU,MAAM,cAAc;AACrC,SAASC,WAAW,EAAEC,yBAAyB,QAAQ,SAAS;AAChE,SAASC,oBAAoB,EAAEC,0BAA0B,QAAQ,SAAS;AAC1E,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,cAAc,QAAQ,cAAc;AAC7C,SAASC,OAAO,QAAQ,eAAe;AACvC,SACEC,SAAS,EACTC,WAAW,EACXC,YAAY,EACZC,cAAc,QACT,SAAS;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAAAC,IAAA,EAAsB;EAAA,IAAnBC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;EACnD,IAAAC,SAAA,GAA4BtB,QAAQ,CAACW,SAAS,EAAE,CAAC;IAAAY,UAAA,GAAAC,cAAA,CAAAF,SAAA;IAA1CG,MAAM,GAAAF,UAAA;IAAEG,SAAS,GAAAH,UAAA;EACxB,IAAAI,UAAA,GAAkD3B,QAAQ,CAACS,oBAAoB,EAAE,CAAC;IAAAmB,UAAA,GAAAJ,cAAA,CAAAG,UAAA;IAA3EE,iBAAiB,GAAAD,UAAA;IAAEE,oBAAoB,GAAAF,UAAA;EAC9C,IAAAG,UAAA,GAA4B/B,QAAQ,CAACc,SAAS,EAAE,CAAC;IAAAkB,UAAA,GAAAR,cAAA,CAAAO,UAAA;IAA1CE,MAAM,GAAAD,UAAA;IAAEE,SAAS,GAAAF,UAAA;EAExBxB,yBAAyB,EAAE;EAE3BD,WAAW,CAACG,0BAA0B,EAAE,YAAM;IAC5CoB,oBAAoB,CAACrB,oBAAoB,EAAE,CAAC;EAC9C,CAAC,CAAC;EAEFF,WAAW,CAACK,cAAc,EAAE,YAAM;IAChCc,SAAS,CAACf,SAAS,EAAE,CAAC;EACxB,CAAC,CAAC;EAEFJ,WAAW,CAACU,cAAc,EAAE,YAAM;IAChCiB,SAAS,CAACpB,SAAS,EAAE,CAAC;EACxB,CAAC,CAAC;EAEF,IAAMqB,eAAe,GAAGlC,OAAO,CAAC;IAAA,OAAO;MAAE4B,iBAAiB,EAAjBA,iBAAiB;MAAEJ,MAAM,EAANA,MAAM;MAAEQ,MAAM,EAANA;IAAO,CAAC;EAAA,CAAC,EAAE,CAACJ,iBAAiB,EAAEJ,MAAM,EAAEQ,MAAM,CAAC,CAAC;EAEnH,oBACElC,KAAA,CAAAqC,aAAA,CAACpB,YAAY;IAACiB,MAAM,EAAEA,MAAO;IAACI,QAAQ,EAAEtB,WAAW;EAAG,gBACpDhB,KAAA,CAAAqC,aAAA,CAAC/B,aAAa,qBACZN,KAAA,CAAAqC,aAAA,CAAC9B,UAAU,CAACgC,QAAQ;IAClBC,KAAK,EAAEJ;EAAgB,gBAEvBpC,KAAA,CAAAqC,aAAA,CAAChC,qBAAqB;IAACgB,KAAK,EAAEA;EAAM,gBAClCrB,KAAA,CAAAqC,aAAA,CAACjC,MAAM;IAACU,OAAO,EAAEA;EAAQ,GACtBQ,QAAQ,CACF,CACa,CACJ,CACR,CACH;AAEnB;AAEAH,WAAW,CAACsB,SAAS,GAAG;EACtB;EACApB,KAAK,EAAElB,SAAS,CAACuC,MAAM;EACvBpB,QAAQ,EAAEnB,SAAS,CAACwC,IAAI,CAACC;AAC3B,CAAC;AAEDzB,WAAW,CAAC0B,YAAY,GAAG;EACzBxB,KAAK,EAAE;AACT,CAAC"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
var _excluded = ["redirectUrl"];
|
|
2
|
-
|
|
3
2
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
4
|
import React, { useContext } from 'react';
|
|
8
5
|
import PropTypes from 'prop-types';
|
|
9
6
|
import { useRouteMatch } from 'react-router-dom';
|
|
10
7
|
import AppContext from './AppContext';
|
|
11
8
|
import PageRoute from './PageRoute';
|
|
12
9
|
import { getLoginRedirectUrl } from '../auth';
|
|
10
|
+
|
|
13
11
|
/**
|
|
14
12
|
* A react-router route that redirects to the login page when the route becomes active and the user
|
|
15
13
|
* is not authenticated. If the application has been initialized with `requireAuthenticatedUser`
|
|
@@ -27,14 +25,11 @@ import { getLoginRedirectUrl } from '../auth';
|
|
|
27
25
|
* @param {string} props.redirectUrl The URL anonymous users should be redirected to, rather than
|
|
28
26
|
* viewing the route's contents.
|
|
29
27
|
*/
|
|
30
|
-
|
|
31
28
|
export default function AuthenticatedPageRoute(_ref) {
|
|
32
29
|
var redirectUrl = _ref.redirectUrl,
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
31
|
var _useContext = useContext(AppContext),
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
authenticatedUser = _useContext.authenticatedUser;
|
|
38
33
|
var match = useRouteMatch({
|
|
39
34
|
// eslint-disable-next-line react/prop-types
|
|
40
35
|
path: props.path,
|
|
@@ -45,18 +40,15 @@ export default function AuthenticatedPageRoute(_ref) {
|
|
|
45
40
|
// eslint-disable-next-line react/prop-types
|
|
46
41
|
sensitive: props.sensitive
|
|
47
42
|
});
|
|
48
|
-
|
|
49
43
|
if (authenticatedUser === null) {
|
|
50
44
|
if (match) {
|
|
51
45
|
var destination = redirectUrl || getLoginRedirectUrl(global.location.href);
|
|
52
46
|
global.location.assign(destination);
|
|
53
|
-
}
|
|
47
|
+
}
|
|
48
|
+
// This emulates a Route's way of displaying nothing if the route's path doesn't match the
|
|
54
49
|
// current URL.
|
|
55
|
-
|
|
56
|
-
|
|
57
50
|
return null;
|
|
58
51
|
}
|
|
59
|
-
|
|
60
52
|
return /*#__PURE__*/React.createElement(PageRoute, props);
|
|
61
53
|
}
|
|
62
54
|
AuthenticatedPageRoute.propTypes = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticatedPageRoute.js","names":["React","useContext","PropTypes","useRouteMatch","AppContext","PageRoute","getLoginRedirectUrl","AuthenticatedPageRoute","redirectUrl","props","authenticatedUser","match","path","exact","strict","sensitive","destination","global","location","href","assign","propTypes","string","defaultProps"],"sources":["../../src/react/AuthenticatedPageRoute.jsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport { useRouteMatch } from 'react-router-dom';\n\nimport AppContext from './AppContext';\nimport PageRoute from './PageRoute';\nimport { getLoginRedirectUrl } from '../auth';\n\n/**\n * A react-router route that redirects to the login page when the route becomes active and the user\n * is not authenticated. If the application has been initialized with `requireAuthenticatedUser`\n * false, an authenticatedPageRoute can be used to protect a subset of the application's routes,\n * rather than the entire application.\n *\n * It can optionally accept an override URL to redirect to instead of the login page.\n *\n * Like a `PageRoute`, also calls `sendPageEvent` when the route becomes active.\n *\n * @see PageRoute\n * @see {@link module:frontend-platform/analytics~sendPageEvent}\n * @memberof module:React\n * @param {Object} props\n * @param {string} props.redirectUrl The URL anonymous users should be redirected to, rather than\n * viewing the route's contents.\n */\nexport default function AuthenticatedPageRoute({ redirectUrl, ...props }) {\n const { authenticatedUser } = useContext(AppContext);\n\n const match = useRouteMatch({\n // eslint-disable-next-line react/prop-types\n path: props.path,\n // eslint-disable-next-line react/prop-types\n exact: props.exact,\n // eslint-disable-next-line react/prop-types\n strict: props.strict,\n // eslint-disable-next-line react/prop-types\n sensitive: props.sensitive,\n });\n\n if (authenticatedUser === null) {\n if (match) {\n const destination = redirectUrl || getLoginRedirectUrl(global.location.href);\n global.location.assign(destination);\n }\n // This emulates a Route's way of displaying nothing if the route's path doesn't match the\n // current URL.\n return null;\n }\n return (\n <PageRoute {...props} />\n );\n}\n\nAuthenticatedPageRoute.propTypes = {\n redirectUrl: PropTypes.string,\n};\n\nAuthenticatedPageRoute.defaultProps = {\n redirectUrl: null,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthenticatedPageRoute.js","names":["React","useContext","PropTypes","useRouteMatch","AppContext","PageRoute","getLoginRedirectUrl","AuthenticatedPageRoute","_ref","redirectUrl","props","_objectWithoutProperties","_excluded","_useContext","authenticatedUser","match","path","exact","strict","sensitive","destination","global","location","href","assign","createElement","propTypes","string","defaultProps"],"sources":["../../src/react/AuthenticatedPageRoute.jsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport { useRouteMatch } from 'react-router-dom';\n\nimport AppContext from './AppContext';\nimport PageRoute from './PageRoute';\nimport { getLoginRedirectUrl } from '../auth';\n\n/**\n * A react-router route that redirects to the login page when the route becomes active and the user\n * is not authenticated. If the application has been initialized with `requireAuthenticatedUser`\n * false, an authenticatedPageRoute can be used to protect a subset of the application's routes,\n * rather than the entire application.\n *\n * It can optionally accept an override URL to redirect to instead of the login page.\n *\n * Like a `PageRoute`, also calls `sendPageEvent` when the route becomes active.\n *\n * @see PageRoute\n * @see {@link module:frontend-platform/analytics~sendPageEvent}\n * @memberof module:React\n * @param {Object} props\n * @param {string} props.redirectUrl The URL anonymous users should be redirected to, rather than\n * viewing the route's contents.\n */\nexport default function AuthenticatedPageRoute({ redirectUrl, ...props }) {\n const { authenticatedUser } = useContext(AppContext);\n\n const match = useRouteMatch({\n // eslint-disable-next-line react/prop-types\n path: props.path,\n // eslint-disable-next-line react/prop-types\n exact: props.exact,\n // eslint-disable-next-line react/prop-types\n strict: props.strict,\n // eslint-disable-next-line react/prop-types\n sensitive: props.sensitive,\n });\n\n if (authenticatedUser === null) {\n if (match) {\n const destination = redirectUrl || getLoginRedirectUrl(global.location.href);\n global.location.assign(destination);\n }\n // This emulates a Route's way of displaying nothing if the route's path doesn't match the\n // current URL.\n return null;\n }\n return (\n <PageRoute {...props} />\n );\n}\n\nAuthenticatedPageRoute.propTypes = {\n redirectUrl: PropTypes.string,\n};\n\nAuthenticatedPageRoute.defaultProps = {\n redirectUrl: null,\n};\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,aAAa,QAAQ,kBAAkB;AAEhD,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,SAAS,MAAM,aAAa;AACnC,SAASC,mBAAmB,QAAQ,SAAS;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,sBAAsBA,CAAAC,IAAA,EAA4B;EAAA,IAAzBC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IAAKC,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EACpE,IAAAC,WAAA,GAA8BZ,UAAU,CAACG,UAAU,CAAC;IAA5CU,iBAAiB,GAAAD,WAAA,CAAjBC,iBAAiB;EAEzB,IAAMC,KAAK,GAAGZ,aAAa,CAAC;IAC1B;IACAa,IAAI,EAAEN,KAAK,CAACM,IAAI;IAChB;IACAC,KAAK,EAAEP,KAAK,CAACO,KAAK;IAClB;IACAC,MAAM,EAAER,KAAK,CAACQ,MAAM;IACpB;IACAC,SAAS,EAAET,KAAK,CAACS;EACnB,CAAC,CAAC;EAEF,IAAIL,iBAAiB,KAAK,IAAI,EAAE;IAC9B,IAAIC,KAAK,EAAE;MACT,IAAMK,WAAW,GAAGX,WAAW,IAAIH,mBAAmB,CAACe,MAAM,CAACC,QAAQ,CAACC,IAAI,CAAC;MAC5EF,MAAM,CAACC,QAAQ,CAACE,MAAM,CAACJ,WAAW,CAAC;IACrC;IACA;IACA;IACA,OAAO,IAAI;EACb;EACA,oBACEpB,KAAA,CAAAyB,aAAA,CAACpB,SAAS,EAAKK,KAAK,CAAI;AAE5B;AAEAH,sBAAsB,CAACmB,SAAS,GAAG;EACjCjB,WAAW,EAAEP,SAAS,CAACyB;AACzB,CAAC;AAEDpB,sBAAsB,CAACqB,YAAY,GAAG;EACpCnB,WAAW,EAAE;AACf,CAAC"}
|
package/react/ErrorBoundary.js
CHANGED
|
@@ -1,53 +1,39 @@
|
|
|
1
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); }
|
|
2
|
-
|
|
3
2
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
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); } }
|
|
6
|
-
|
|
3
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
4
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
-
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
7
|
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); }
|
|
10
|
-
|
|
11
8
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
|
|
13
9
|
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
10
|
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
11
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
|
|
19
12
|
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
13
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
|
|
23
14
|
import React, { Component } from 'react';
|
|
24
15
|
import PropTypes from 'prop-types';
|
|
25
16
|
import { logError } from '../logging';
|
|
26
17
|
import ErrorPage from './ErrorPage';
|
|
18
|
+
|
|
27
19
|
/**
|
|
28
20
|
* Error boundary component used to log caught errors and display the error page.
|
|
29
21
|
*
|
|
30
22
|
* @memberof module:React
|
|
31
23
|
* @extends {Component}
|
|
32
24
|
*/
|
|
33
|
-
|
|
34
25
|
var ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
35
26
|
_inherits(ErrorBoundary, _Component);
|
|
36
|
-
|
|
37
27
|
var _super = _createSuper(ErrorBoundary);
|
|
38
|
-
|
|
39
28
|
function ErrorBoundary(props) {
|
|
40
29
|
var _this;
|
|
41
|
-
|
|
42
30
|
_classCallCheck(this, ErrorBoundary);
|
|
43
|
-
|
|
44
31
|
_this = _super.call(this, props);
|
|
45
32
|
_this.state = {
|
|
46
33
|
hasError: false
|
|
47
34
|
};
|
|
48
35
|
return _this;
|
|
49
36
|
}
|
|
50
|
-
|
|
51
37
|
_createClass(ErrorBoundary, [{
|
|
52
38
|
key: "componentDidCatch",
|
|
53
39
|
value: function componentDidCatch(error, info) {
|
|
@@ -61,7 +47,6 @@ var ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
61
47
|
if (this.state.hasError) {
|
|
62
48
|
return /*#__PURE__*/React.createElement(ErrorPage, null);
|
|
63
49
|
}
|
|
64
|
-
|
|
65
50
|
return this.props.children;
|
|
66
51
|
}
|
|
67
52
|
}], [{
|
|
@@ -73,10 +58,8 @@ var ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
73
58
|
};
|
|
74
59
|
}
|
|
75
60
|
}]);
|
|
76
|
-
|
|
77
61
|
return ErrorBoundary;
|
|
78
62
|
}(Component);
|
|
79
|
-
|
|
80
63
|
export { ErrorBoundary as default };
|
|
81
64
|
ErrorBoundary.propTypes = {
|
|
82
65
|
children: PropTypes.node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","names":["React","Component","PropTypes","logError","ErrorPage","ErrorBoundary","props","state","hasError","error","info","stack","componentStack","children","propTypes","node","defaultProps"],"sources":["../../src/react/ErrorBoundary.jsx"],"sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\n\nimport { logError } from '../logging';\n\nimport ErrorPage from './ErrorPage';\n\n/**\n * Error boundary component used to log caught errors and display the error page.\n *\n * @memberof module:React\n * @extends {Component}\n */\nexport default class ErrorBoundary extends Component {\n constructor(props) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError() {\n // Update state so the next render will show the fallback UI.\n return { hasError: true };\n }\n\n componentDidCatch(error, info) {\n logError(error, { stack: info.componentStack });\n }\n\n render() {\n if (this.state.hasError) {\n return <ErrorPage />;\n }\n\n return this.props.children;\n }\n}\n\nErrorBoundary.propTypes = {\n children: PropTypes.node,\n};\n\nErrorBoundary.defaultProps = {\n children: null,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","names":["React","Component","PropTypes","logError","ErrorPage","ErrorBoundary","_Component","_inherits","_super","_createSuper","props","_this","_classCallCheck","call","state","hasError","_createClass","key","value","componentDidCatch","error","info","stack","componentStack","render","createElement","children","getDerivedStateFromError","default","propTypes","node","defaultProps"],"sources":["../../src/react/ErrorBoundary.jsx"],"sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\n\nimport { logError } from '../logging';\n\nimport ErrorPage from './ErrorPage';\n\n/**\n * Error boundary component used to log caught errors and display the error page.\n *\n * @memberof module:React\n * @extends {Component}\n */\nexport default class ErrorBoundary extends Component {\n constructor(props) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError() {\n // Update state so the next render will show the fallback UI.\n return { hasError: true };\n }\n\n componentDidCatch(error, info) {\n logError(error, { stack: info.componentStack });\n }\n\n render() {\n if (this.state.hasError) {\n return <ErrorPage />;\n }\n\n return this.props.children;\n }\n}\n\nErrorBoundary.propTypes = {\n children: PropTypes.node,\n};\n\nErrorBoundary.defaultProps = {\n children: null,\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,OAAOC,SAAS,MAAM,YAAY;AAElC,SAASC,QAAQ,QAAQ,YAAY;AAErC,OAAOC,SAAS,MAAM,aAAa;;AAEnC;AACA;AACA;AACA;AACA;AACA;AALA,IAMqBC,aAAa,0BAAAC,UAAA;EAAAC,SAAA,CAAAF,aAAA,EAAAC,UAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,aAAA;EAChC,SAAAA,cAAYK,KAAK,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAP,aAAA;IACjBM,KAAA,GAAAH,MAAA,CAAAK,IAAA,OAAMH,KAAK;IACXC,KAAA,CAAKG,KAAK,GAAG;MAAEC,QAAQ,EAAE;IAAM,CAAC;IAAC,OAAAJ,KAAA;EACnC;EAACK,YAAA,CAAAX,aAAA;IAAAY,GAAA;IAAAC,KAAA,EAOD,SAAAC,kBAAkBC,KAAK,EAAEC,IAAI,EAAE;MAC7BlB,QAAQ,CAACiB,KAAK,EAAE;QAAEE,KAAK,EAAED,IAAI,CAACE;MAAe,CAAC,CAAC;IACjD;EAAC;IAAAN,GAAA;IAAAC,KAAA,EAED,SAAAM,OAAA,EAAS;MACP,IAAI,IAAI,CAACV,KAAK,CAACC,QAAQ,EAAE;QACvB,oBAAOf,KAAA,CAAAyB,aAAA,CAACrB,SAAS,OAAG;MACtB;MAEA,OAAO,IAAI,CAACM,KAAK,CAACgB,QAAQ;IAC5B;EAAC;IAAAT,GAAA;IAAAC,KAAA,EAfD,SAAAS,yBAAA,EAAkC;MAChC;MACA,OAAO;QAAEZ,QAAQ,EAAE;MAAK,CAAC;IAC3B;EAAC;EAAA,OAAAV,aAAA;AAAA,EATwCJ,SAAS;AAAA,SAA/BI,aAAa,IAAAuB,OAAA;AAwBlCvB,aAAa,CAACwB,SAAS,GAAG;EACxBH,QAAQ,EAAExB,SAAS,CAAC4B;AACtB,CAAC;AAEDzB,aAAa,CAAC0B,YAAY,GAAG;EAC3BL,QAAQ,EAAE;AACZ,CAAC"}
|
package/react/ErrorPage.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
2
|
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
|
-
|
|
5
3
|
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
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
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
|
-
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
11
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
7
|
import React, { useState } from 'react';
|
|
14
8
|
import PropTypes from 'prop-types';
|
|
15
9
|
import { Button, Container, Row, Col } from '@edx/paragon';
|
|
16
10
|
import { useAppEvent } from './hooks';
|
|
17
11
|
import { FormattedMessage, IntlProvider, getMessages, getLocale, LOCALE_CHANGED } from '../i18n';
|
|
12
|
+
|
|
18
13
|
/**
|
|
19
14
|
* An error page that displays a generic message for unexpected errors. Also contains a "Try
|
|
20
15
|
* Again" button to refresh the page.
|
|
@@ -22,24 +17,20 @@ import { FormattedMessage, IntlProvider, getMessages, getLocale, LOCALE_CHANGED
|
|
|
22
17
|
* @memberof module:React
|
|
23
18
|
* @extends {Component}
|
|
24
19
|
*/
|
|
25
|
-
|
|
26
20
|
function ErrorPage(_ref) {
|
|
27
21
|
var message = _ref.message;
|
|
28
|
-
|
|
29
22
|
var _useState = useState(getLocale()),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
locale = _useState2[0],
|
|
25
|
+
setLocale = _useState2[1];
|
|
34
26
|
useAppEvent(LOCALE_CHANGED, function () {
|
|
35
27
|
setLocale(getLocale());
|
|
36
28
|
});
|
|
37
|
-
/* istanbul ignore next */
|
|
38
29
|
|
|
30
|
+
/* istanbul ignore next */
|
|
39
31
|
var reload = function reload() {
|
|
40
32
|
global.location.reload();
|
|
41
33
|
};
|
|
42
|
-
|
|
43
34
|
return /*#__PURE__*/React.createElement(IntlProvider, {
|
|
44
35
|
locale: locale,
|
|
45
36
|
messages: getMessages()
|
|
@@ -63,7 +54,6 @@ function ErrorPage(_ref) {
|
|
|
63
54
|
description: "text for button that tries to reload the app by refreshing the page"
|
|
64
55
|
}))))));
|
|
65
56
|
}
|
|
66
|
-
|
|
67
57
|
ErrorPage.propTypes = {
|
|
68
58
|
message: PropTypes.string
|
|
69
59
|
};
|
package/react/ErrorPage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"
|
|
1
|
+
{"version":3,"file":"ErrorPage.js","names":["React","useState","PropTypes","Button","Container","Row","Col","useAppEvent","FormattedMessage","IntlProvider","getMessages","getLocale","LOCALE_CHANGED","ErrorPage","_ref","message","_useState","_useState2","_slicedToArray","locale","setLocale","reload","global","location","createElement","messages","fluid","className","id","defaultMessage","description","role","onClick","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,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,SACEC,MAAM,EAAEC,SAAS,EAAEC,GAAG,EAAEC,GAAG,QACtB,cAAc;AAErB,SAASC,WAAW,QAAQ,SAAS;AACrC,SACEC,gBAAgB,EAChBC,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,cAAc,QACT,SAAS;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,SAASA,CAAAC,IAAA,EAEf;EAAA,IADDC,OAAO,GAAAD,IAAA,CAAPC,OAAO;EAEP,IAAAC,SAAA,GAA4Bf,QAAQ,CAACU,SAAS,EAAE,CAAC;IAAAM,UAAA,GAAAC,cAAA,CAAAF,SAAA;IAA1CG,MAAM,GAAAF,UAAA;IAAEG,SAAS,GAAAH,UAAA;EAExBV,WAAW,CAACK,cAAc,EAAE,YAAM;IAChCQ,SAAS,CAACT,SAAS,EAAE,CAAC;EACxB,CAAC,CAAC;;EAEF;EACA,IAAMU,MAAM,GAAG,SAATA,MAAMA,CAAA,EAAS;IACnBC,MAAM,CAACC,QAAQ,CAACF,MAAM,EAAE;EAC1B,CAAC;EAED,oBACErB,KAAA,CAAAwB,aAAA,CAACf,YAAY;IAACU,MAAM,EAAEA,MAAO;IAACM,QAAQ,EAAEf,WAAW;EAAG,gBACpDV,KAAA,CAAAwB,aAAA,CAACpB,SAAS;IAACsB,KAAK;IAACC,SAAS,EAAC;EAA2D,gBACpF3B,KAAA,CAAAwB,aAAA,CAACnB,GAAG,qBACFL,KAAA,CAAAwB,aAAA,CAAClB,GAAG,qBACFN,KAAA,CAAAwB,aAAA;IAAGG,SAAS,EAAC;EAAY,gBACvB3B,KAAA,CAAAwB,aAAA,CAAChB,gBAAgB;IACfoB,EAAE,EAAC,+BAA+B;IAClCC,cAAc,EAAC,kFAAkF;IACjGC,WAAW,EAAC;EAA+C,EAC3D,CACA,EACHf,OAAO,iBACNf,KAAA,CAAAwB,aAAA;IAAKO,IAAI,EAAC,OAAO;IAACJ,SAAS,EAAC;EAAM,gBAChC3B,KAAA,CAAAwB,aAAA,YAAIT,OAAO,CAAK,CAEnB,eACDf,KAAA,CAAAwB,aAAA,CAACrB,MAAM;IAAC6B,OAAO,EAAEX;EAAO,gBACtBrB,KAAA,CAAAwB,aAAA,CAAChB,gBAAgB;IACfoB,EAAE,EAAC,8BAA8B;IACjCC,cAAc,EAAC,WAAW;IAC1BC,WAAW,EAAC;EAAqE,EACjF,CACK,CACL,CACF,CACI,CACC;AAEnB;AAEAjB,SAAS,CAACoB,SAAS,GAAG;EACpBlB,OAAO,EAAEb,SAAS,CAACgC;AACrB,CAAC;AAEDrB,SAAS,CAACsB,YAAY,GAAG;EACvBpB,OAAO,EAAE;AACX,CAAC;AAED,eAAeF,SAAS"}
|
package/react/LoginRedirect.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { redirectToLogin } from '../auth';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* A React component that, when rendered, redirects to the login page as a side effect. Uses
|
|
5
6
|
* `redirectToLogin` to perform the redirect.
|
|
@@ -7,7 +8,6 @@ import { redirectToLogin } from '../auth';
|
|
|
7
8
|
* @see {@link module:frontend-platform/auth~redirectToLogin}
|
|
8
9
|
* @memberof module:React
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
11
|
export default function LoginRedirect() {
|
|
12
12
|
useEffect(function () {
|
|
13
13
|
redirectToLogin(global.location.href);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoginRedirect.js","names":["useEffect","redirectToLogin","LoginRedirect","global","location","href"],"sources":["../../src/react/LoginRedirect.jsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { redirectToLogin } from '../auth';\n\n/**\n * A React component that, when rendered, redirects to the login page as a side effect. Uses\n * `redirectToLogin` to perform the redirect.\n *\n * @see {@link module:frontend-platform/auth~redirectToLogin}\n * @memberof module:React\n */\nexport default function LoginRedirect() {\n useEffect(() => {\n redirectToLogin(global.location.href);\n }, []);\n return null;\n}\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"file":"LoginRedirect.js","names":["useEffect","redirectToLogin","LoginRedirect","global","location","href"],"sources":["../../src/react/LoginRedirect.jsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { redirectToLogin } from '../auth';\n\n/**\n * A React component that, when rendered, redirects to the login page as a side effect. Uses\n * `redirectToLogin` to perform the redirect.\n *\n * @see {@link module:frontend-platform/auth~redirectToLogin}\n * @memberof module:React\n */\nexport default function LoginRedirect() {\n useEffect(() => {\n redirectToLogin(global.location.href);\n }, []);\n return null;\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,eAAe,QAAQ,SAAS;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,aAAaA,CAAA,EAAG;EACtCF,SAAS,CAAC,YAAM;IACdC,eAAe,CAACE,MAAM,CAACC,QAAQ,CAACC,IAAI,CAAC;EACvC,CAAC,EAAE,EAAE,CAAC;EACN,OAAO,IAAI;AACb"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Provider } from 'react-redux';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* @memberof module:React
|
|
6
7
|
* @param {Object} props
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
export default function OptionalReduxProvider(_ref) {
|
|
10
10
|
var store = _ref.store,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
children = _ref.children;
|
|
13
12
|
if (store === null) {
|
|
14
13
|
return children;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
return /*#__PURE__*/React.createElement(Provider, {
|
|
18
16
|
store: store
|
|
19
17
|
}, children);
|
|
@@ -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 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,
|
|
1
|
+
{"version":3,"file":"OptionalReduxProvider.js","names":["React","PropTypes","Provider","OptionalReduxProvider","_ref","store","children","createElement","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,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,QAAQ,aAAa;;AAEtC;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAAC,IAAA,EAAsB;EAAA,IAAnBC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;EAC7D,IAAID,KAAK,KAAK,IAAI,EAAE;IAClB,OAAOC,QAAQ;EACjB;EAEA,oBACEN,KAAA,CAAAO,aAAA,CAACL,QAAQ;IAACG,KAAK,EAAEA;EAAM,GACpBC,QAAQ,CACA;AAEf;AAEAH,qBAAqB,CAACK,SAAS,GAAG;EAChCH,KAAK,EAAEJ,SAAS,CAACQ,MAAM;EAAE;EACzBH,QAAQ,EAAEL,SAAS,CAACS,IAAI,CAACC;AAC3B,CAAC;AAEDR,qBAAqB,CAACS,YAAY,GAAG;EACnCP,KAAK,EAAE;AACT,CAAC"}
|
package/react/PageRoute.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React, { useEffect } from 'react';
|
|
3
3
|
import { Route, useRouteMatch } from 'react-router-dom';
|
|
4
4
|
import { sendPageEvent } from '../analytics';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* A react-router Route component that calls `sendPageEvent` when it becomes active.
|
|
7
8
|
*
|
|
@@ -9,7 +10,6 @@ import { sendPageEvent } from '../analytics';
|
|
|
9
10
|
* @memberof module:React
|
|
10
11
|
* @param {Object} props
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
13
|
export default function PageRoute(props) {
|
|
14
14
|
var match = useRouteMatch({
|
|
15
15
|
path: props.path,
|
|
@@ -20,8 +20,8 @@ export default function PageRoute(props) {
|
|
|
20
20
|
useEffect(function () {
|
|
21
21
|
if (match) {
|
|
22
22
|
sendPageEvent();
|
|
23
|
-
}
|
|
24
|
-
|
|
23
|
+
}
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
25
|
}, [JSON.stringify(match)]);
|
|
26
26
|
return /*#__PURE__*/React.createElement(Route, props);
|
|
27
27
|
}
|
package/react/PageRoute.js.map
CHANGED
|
@@ -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 // 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,
|
|
1
|
+
{"version":3,"file":"PageRoute.js","names":["React","useEffect","Route","useRouteMatch","sendPageEvent","PageRoute","props","match","path","exact","strict","sensitive","JSON","stringify","createElement"],"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,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,KAAK,EAAEC,aAAa,QAAQ,kBAAkB;AACvD,SAASC,aAAa,QAAQ,cAAc;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,SAASA,CAACC,KAAK,EAAE;EACvC,IAAMC,KAAK,GAAGJ,aAAa,CAAC;IAC1BK,IAAI,EAAEF,KAAK,CAACE,IAAI;IAChBC,KAAK,EAAEH,KAAK,CAACG,KAAK;IAClBC,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBC,SAAS,EAAEL,KAAK,CAACK;EACnB,CAAC,CAAC;EAEFV,SAAS,CAAC,YAAM;IACd,IAAIM,KAAK,EAAE;MACTH,aAAa,EAAE;IACjB;IACF;EACA,CAAC,EAAE,CAACQ,IAAI,CAACC,SAAS,CAACN,KAAK,CAAC,CAAC,CAAC;EAE3B,oBACEP,KAAA,CAAAc,aAAA,CAACZ,KAAK,EAAKI,KAAK,CAAI;AAExB"}
|
package/react/hooks.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import { subscribe, unsubscribe } from '../pubSub';
|
|
4
4
|
import { sendTrackEvent } from '../analytics';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* A React hook that allows functional components to subscribe to application events. This should
|
|
7
8
|
* be used sparingly - for the most part, Context should be used higher-up in the application to
|
|
@@ -12,7 +13,6 @@ import { sendTrackEvent } from '../analytics';
|
|
|
12
13
|
* @param {string} type
|
|
13
14
|
* @param {function} callback
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
16
|
export var useAppEvent = function useAppEvent(type, callback) {
|
|
17
17
|
useEffect(function () {
|
|
18
18
|
var subscriptionToken = subscribe(type, callback);
|
|
@@ -21,17 +21,16 @@ export var useAppEvent = function useAppEvent(type, callback) {
|
|
|
21
21
|
};
|
|
22
22
|
}, [callback, type]);
|
|
23
23
|
};
|
|
24
|
+
|
|
24
25
|
/**
|
|
25
26
|
* A React hook that tracks user's preferred color scheme (light or dark) and sends respective
|
|
26
27
|
* event to the tracking service.
|
|
27
28
|
*
|
|
28
29
|
* @memberof module:React
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
31
|
export var useTrackColorSchemeChoice = function useTrackColorSchemeChoice() {
|
|
32
32
|
useEffect(function () {
|
|
33
33
|
var _window$matchMedia, _window;
|
|
34
|
-
|
|
35
34
|
var trackColorSchemeChoice = function trackColorSchemeChoice(_ref) {
|
|
36
35
|
var matches = _ref.matches;
|
|
37
36
|
var preferredColorScheme = matches ? 'dark' : 'light';
|
|
@@ -39,15 +38,12 @@ export var useTrackColorSchemeChoice = function useTrackColorSchemeChoice() {
|
|
|
39
38
|
preferredColorScheme: preferredColorScheme
|
|
40
39
|
});
|
|
41
40
|
};
|
|
42
|
-
|
|
43
41
|
var colorSchemeQuery = (_window$matchMedia = (_window = window).matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, '(prefers-color-scheme: dark)');
|
|
44
|
-
|
|
45
42
|
if (colorSchemeQuery) {
|
|
46
43
|
// send user's initial choice
|
|
47
44
|
trackColorSchemeChoice(colorSchemeQuery);
|
|
48
45
|
colorSchemeQuery.addEventListener('change', trackColorSchemeChoice);
|
|
49
46
|
}
|
|
50
|
-
|
|
51
47
|
return function () {
|
|
52
48
|
if (colorSchemeQuery) {
|
|
53
49
|
colorSchemeQuery.removeEventListener('change', trackColorSchemeChoice);
|
package/react/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":["useEffect","subscribe","unsubscribe","sendTrackEvent","useAppEvent","type","callback","subscriptionToken","cleanup","useTrackColorSchemeChoice","trackColorSchemeChoice","matches","preferredColorScheme","colorSchemeQuery","window","matchMedia","addEventListener","removeEventListener"],"sources":["../../src/react/hooks.js"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { useEffect } from 'react';\nimport { subscribe, unsubscribe } from '../pubSub';\nimport { sendTrackEvent } from '../analytics';\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\n/**\n * A React hook that tracks user's preferred color scheme (light or dark) and sends respective\n * event to the tracking service.\n *\n * @memberof module:React\n */\nexport const useTrackColorSchemeChoice = () => {\n useEffect(() => {\n const trackColorSchemeChoice = ({ matches }) => {\n const preferredColorScheme = matches ? 'dark' : 'light';\n sendTrackEvent('openedx.ui.frontend-platform.prefers-color-scheme.selected', { preferredColorScheme });\n };\n const colorSchemeQuery = window.matchMedia?.('(prefers-color-scheme: dark)');\n if (colorSchemeQuery) {\n // send user's initial choice\n trackColorSchemeChoice(colorSchemeQuery);\n colorSchemeQuery.addEventListener('change', trackColorSchemeChoice);\n }\n return () => {\n if (colorSchemeQuery) {\n colorSchemeQuery.removeEventListener('change', trackColorSchemeChoice);\n }\n };\n }, []);\n};\n"],"mappings":"AAAA;AACA,SAASA,
|
|
1
|
+
{"version":3,"file":"hooks.js","names":["useEffect","subscribe","unsubscribe","sendTrackEvent","useAppEvent","type","callback","subscriptionToken","cleanup","useTrackColorSchemeChoice","_window$matchMedia","_window","trackColorSchemeChoice","_ref","matches","preferredColorScheme","colorSchemeQuery","window","matchMedia","call","addEventListener","removeEventListener"],"sources":["../../src/react/hooks.js"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { useEffect } from 'react';\nimport { subscribe, unsubscribe } from '../pubSub';\nimport { sendTrackEvent } from '../analytics';\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\n/**\n * A React hook that tracks user's preferred color scheme (light or dark) and sends respective\n * event to the tracking service.\n *\n * @memberof module:React\n */\nexport const useTrackColorSchemeChoice = () => {\n useEffect(() => {\n const trackColorSchemeChoice = ({ matches }) => {\n const preferredColorScheme = matches ? 'dark' : 'light';\n sendTrackEvent('openedx.ui.frontend-platform.prefers-color-scheme.selected', { preferredColorScheme });\n };\n const colorSchemeQuery = window.matchMedia?.('(prefers-color-scheme: dark)');\n if (colorSchemeQuery) {\n // send user's initial choice\n trackColorSchemeChoice(colorSchemeQuery);\n colorSchemeQuery.addEventListener('change', trackColorSchemeChoice);\n }\n return () => {\n if (colorSchemeQuery) {\n colorSchemeQuery.removeEventListener('change', trackColorSchemeChoice);\n }\n };\n }, []);\n};\n"],"mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,SAAS,EAAEC,WAAW,QAAQ,WAAW;AAClD,SAASC,cAAc,QAAQ,cAAc;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAIC,IAAI,EAAEC,QAAQ,EAAK;EAC7CN,SAAS,CAAC,YAAM;IACd,IAAMO,iBAAiB,GAAGN,SAAS,CAACI,IAAI,EAAEC,QAAQ,CAAC;IAEnD,OAAO,SAASE,OAAOA,CAAA,EAAG;MACxBN,WAAW,CAACK,iBAAiB,CAAC;IAChC,CAAC;EACH,CAAC,EAAE,CAACD,QAAQ,EAAED,IAAI,CAAC,CAAC;AACtB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMI,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAA,EAAS;EAC7CT,SAAS,CAAC,YAAM;IAAA,IAAAU,kBAAA,EAAAC,OAAA;IACd,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAAC,IAAA,EAAoB;MAAA,IAAdC,OAAO,GAAAD,IAAA,CAAPC,OAAO;MACvC,IAAMC,oBAAoB,GAAGD,OAAO,GAAG,MAAM,GAAG,OAAO;MACvDX,cAAc,CAAC,4DAA4D,EAAE;QAAEY,oBAAoB,EAApBA;MAAqB,CAAC,CAAC;IACxG,CAAC;IACD,IAAMC,gBAAgB,IAAAN,kBAAA,GAAG,CAAAC,OAAA,GAAAM,MAAM,EAACC,UAAU,cAAAR,kBAAA,uBAAjBA,kBAAA,CAAAS,IAAA,CAAAR,OAAA,EAAoB,8BAA8B,CAAC;IAC5E,IAAIK,gBAAgB,EAAE;MACpB;MACAJ,sBAAsB,CAACI,gBAAgB,CAAC;MACxCA,gBAAgB,CAACI,gBAAgB,CAAC,QAAQ,EAAER,sBAAsB,CAAC;IACrE;IACA,OAAO,YAAM;MACX,IAAII,gBAAgB,EAAE;QACpBA,gBAAgB,CAACK,mBAAmB,CAAC,QAAQ,EAAET,sBAAsB,CAAC;MACxE;IACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;AACR,CAAC"}
|
package/react/index.js
CHANGED
package/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","AppContext","AppProvider","AuthenticatedPageRoute","ErrorBoundary","ErrorPage","LoginRedirect","PageRoute","useAppEvent"],"sources":["../../src/react/index.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform/react**\n * The React module provides a variety of React components, hooks, and contexts for use in an\n * application.\n *\n * @module React\n */\n\nexport { default as AppContext } from './AppContext';\nexport { default as AppProvider } from './AppProvider';\nexport { default as AuthenticatedPageRoute } from './AuthenticatedPageRoute';\nexport { default as ErrorBoundary } from './ErrorBoundary';\nexport { default as ErrorPage } from './ErrorPage';\nexport { default as LoginRedirect } from './LoginRedirect';\nexport { default as PageRoute } from './PageRoute';\nexport { useAppEvent } from './hooks';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","AppContext","AppProvider","AuthenticatedPageRoute","ErrorBoundary","ErrorPage","LoginRedirect","PageRoute","useAppEvent"],"sources":["../../src/react/index.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform/react**\n * The React module provides a variety of React components, hooks, and contexts for use in an\n * application.\n *\n * @module React\n */\n\nexport { default as AppContext } from './AppContext';\nexport { default as AppProvider } from './AppProvider';\nexport { default as AuthenticatedPageRoute } from './AuthenticatedPageRoute';\nexport { default as ErrorBoundary } from './ErrorBoundary';\nexport { default as ErrorPage } from './ErrorPage';\nexport { default as LoginRedirect } from './LoginRedirect';\nexport { default as PageRoute } from './PageRoute';\nexport { useAppEvent } from './hooks';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,IAAIC,UAAU,QAAQ,cAAc;AACpD,SAASD,OAAO,IAAIE,WAAW,QAAQ,eAAe;AACtD,SAASF,OAAO,IAAIG,sBAAsB,QAAQ,0BAA0B;AAC5E,SAASH,OAAO,IAAII,aAAa,QAAQ,iBAAiB;AAC1D,SAASJ,OAAO,IAAIK,SAAS,QAAQ,aAAa;AAClD,SAASL,OAAO,IAAIM,aAAa,QAAQ,iBAAiB;AAC1D,SAASN,OAAO,IAAIO,SAAS,QAAQ,aAAa;AAClD,SAASC,WAAW,QAAQ,SAAS"}
|
package/testing/index.js
CHANGED
package/testing/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","initializeMockApp","mockMessages"],"sources":["../../src/testing/index.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform/testing**\n * The testing module provides helpers for writing tests in Jest.\n *\n * @module Testing\n */\n\nexport { default as initializeMockApp } from './initializeMockApp';\nexport { default as mockMessages } from './mockMessages';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","initializeMockApp","mockMessages"],"sources":["../../src/testing/index.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform/testing**\n * The testing module provides helpers for writing tests in Jest.\n *\n * @module Testing\n */\n\nexport { default as initializeMockApp } from './initializeMockApp';\nexport { default as mockMessages } from './mockMessages';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,IAAIC,iBAAiB,QAAQ,qBAAqB;AAClE,SAASD,OAAO,IAAIE,YAAY,QAAQ,gBAAgB"}
|