@edx/frontend-platform 2.0.0 → 2.2.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.map +1 -1
- package/analytics/SegmentAnalyticsService.js.map +1 -1
- package/analytics/index.js.map +1 -1
- package/analytics/interface.js.map +1 -1
- package/auth/AxiosCsrfTokenService.js.map +1 -1
- package/auth/AxiosJwtAuthService.js +32 -7
- package/auth/AxiosJwtAuthService.js.map +1 -1
- package/auth/AxiosJwtTokenService.js.map +1 -1
- package/auth/LocalForageCache.js.map +1 -1
- package/auth/MockAuthService.js +136 -107
- package/auth/MockAuthService.js.map +1 -1
- package/auth/index.js.map +1 -1
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -1
- package/auth/interceptors/createRetryInterceptor.js.map +1 -1
- package/auth/interface.js.map +1 -1
- package/auth/utils.js.map +1 -1
- package/config.js.map +1 -1
- package/constants.js.map +1 -1
- package/i18n/countries.js.map +1 -1
- package/i18n/index.js.map +1 -1
- package/i18n/injectIntlWithShim.js.map +1 -1
- package/i18n/languages.js.map +1 -1
- package/i18n/lib.js.map +1 -1
- package/i18n/scripts/README.md +25 -0
- package/i18n/scripts/transifex-utils.js.map +1 -1
- package/index.js.map +1 -1
- package/initialize.js +5 -3
- package/initialize.js.map +1 -1
- package/logging/MockLoggingService.js.map +1 -1
- package/logging/NewRelicLoggingService.js.map +1 -1
- package/logging/index.js.map +1 -1
- package/logging/interface.js.map +1 -1
- package/package.json +4 -5
- package/pubSub.js.map +1 -1
- package/react/AppContext.js.map +1 -1
- package/react/AppProvider.js.map +1 -1
- package/react/AuthenticatedPageRoute.js.map +1 -1
- package/react/ErrorBoundary.js.map +1 -1
- package/react/ErrorPage.js.map +1 -1
- package/react/LoginRedirect.js.map +1 -1
- package/react/OptionalReduxProvider.js.map +1 -1
- package/react/PageRoute.js.map +1 -1
- package/react/hooks.js.map +1 -1
- package/react/index.js.map +1 -1
- package/testing/index.js.map +1 -1
- package/testing/initializeMockApp.js.map +1 -1
- package/testing/mockMessages.js.map +1 -1
- package/utils.js.map +1 -1
- package/i18n/scripts/Makefile +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,aAAT,QAA8B,kBAA9B;AAEA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,SAASC,mBAAT,QAAoC,SAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,sBAAT,OAA2D;EAAA,IAAzBC,WAAyB,QAAzBA,WAAyB;EAAA,IAATC,KAAS;;EACxE,kBAA8BR,UAAU,CAACG,UAAD,CAAxC;EAAA,IAAQM,iBAAR,eAAQA,iBAAR;;EAEA,IAAMC,KAAK,GAAGR,aAAa,CAAC;IAC1B;IACAS,IAAI,EAAEH,KAAK,CAACG,IAFc;IAG1B;IACAC,KAAK,EAAEJ,KAAK,CAACI,KAJa;IAK1B;IACAC,MAAM,EAAEL,KAAK,CAACK,MANY;IAO1B;IACAC,SAAS,EAAEN,KAAK,CAACM;EARS,CAAD,CAA3B;;EAWA,IAAIL,iBAAiB,KAAK,IAA1B,EAAgC;IAC9B,IAAIC,KAAJ,EAAW;MACT,IAAMK,WAAW,GAAGR,WAAW,IAAIF,mBAAmB,CAACW,MAAM,CAACC,QAAP,CAAgBC,IAAjB,CAAtD;MACAF,MAAM,CAACC,QAAP,CAAgBE,MAAhB,CAAuBJ,WAAvB;IACD,CAJ6B,CAK9B;IACA;;;IACA,OAAO,IAAP;EACD;;EACD,oBACE,oBAAC,SAAD,EAAeP,KAAf,CADF;AAGD;AAEDF,sBAAsB,CAACc,SAAvB,GAAmC;EACjCb,WAAW,EAAEN,SAAS,CAACoB;AADU,CAAnC;AAIAf,sBAAsB,CAACgB,YAAvB,GAAsC;EACpCf,WAAW,EAAE;AADuB,CAAtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,SAASC,QAAT,QAAyB,YAAzB;AAEA,OAAOC,SAAP,MAAsB,aAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;;IACqBC,a;;;;;EACnB,uBAAYC,KAAZ,EAAmB;IAAA;;IAAA;;IACjB,0BAAMA,KAAN;IACA,MAAKC,KAAL,GAAa;MAAEC,QAAQ,EAAE;IAAZ,CAAb;IAFiB;EAGlB;;;;WAOD,2BAAkBC,KAAlB,EAAyBC,IAAzB,EAA+B;MAC7BP,QAAQ,CAACM,KAAD,EAAQ;QAAEE,KAAK,EAAED,IAAI,CAACE;MAAd,CAAR,CAAR;IACD;;;WAED,kBAAS;MACP,IAAI,KAAKL,KAAL,CAAWC,QAAf,EAAyB;QACvB,oBAAO,oBAAC,SAAD,OAAP;MACD;;MAED,OAAO,KAAKF,KAAL,CAAWO,QAAlB;IACD;;;WAfD,oCAAkC;MAChC;MACA,OAAO;QAAEL,QAAQ,EAAE;MAAZ,CAAP;IACD;;;;EATwCP,S;;SAAtBI,a;AAwBrBA,aAAa,CAACS,SAAd,GAA0B;EACxBD,QAAQ,EAAEX,SAAS,CAACa;AADI,CAA1B;AAIAV,aAAa,CAACW,YAAd,GAA6B;EAC3BH,QAAQ,EAAE;AADiB,CAA7B"}
|
package/react/ErrorPage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,SAAT,QAA0B,OAA1B;AACA,SAASC,eAAT,QAAgC,SAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,aAAT,GAAyB;EACtCF,SAAS,CAAC,YAAM;IACdC,eAAe,CAACE,MAAM,CAACC,QAAP,CAAgBC,IAAjB,CAAf;EACD,CAFQ,EAEN,EAFM,CAAT;EAGA,OAAO,IAAP;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/react/PageRoute.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/react/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,UAApB,QAAsC,cAAtC;AACA,SAASD,OAAO,IAAIE,WAApB,QAAuC,eAAvC;AACA,SAASF,OAAO,IAAIG,sBAApB,QAAkD,0BAAlD;AACA,SAASH,OAAO,IAAII,aAApB,QAAyC,iBAAzC;AACA,SAASJ,OAAO,IAAIK,SAApB,QAAqC,aAArC;AACA,SAASL,OAAO,IAAIM,aAApB,QAAyC,iBAAzC;AACA,SAASN,OAAO,IAAIO,SAApB,QAAqC,aAArC;AACA,SAASC,WAAT,QAA4B,SAA5B"}
|
package/testing/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,iBAApB,QAA6C,qBAA7C;AACA,SAASD,OAAO,IAAIE,YAApB,QAAwC,gBAAxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"initializeMockApp.js","names":["configure","configureAnalytics","MockAnalyticsService","configureI18n","configureLogging","MockLoggingService","configureAuth","MockAuthService","getConfig","mockMessages","initializeMockApp","messages","authenticatedUser","loggingService","config","authService","analyticsService","httpClient","getAuthenticatedHttpClient"],"sources":["../../src/testing/initializeMockApp.js"],"sourcesContent":["import { configure as configureAnalytics, MockAnalyticsService } from '../analytics';\nimport { configure as configureI18n } from '../i18n';\nimport { configure as configureLogging, MockLoggingService } from '../logging';\nimport { configure as configureAuth, MockAuthService } from '../auth';\nimport { getConfig } from '../config';\nimport mockMessages from './mockMessages';\n\n/**\n * Initializes a mock application for component testing. The mock application includes\n * mock analytics, auth, and logging services, and the real i18n service.\n *\n * See MockAnalyticsService, MockAuthService, and MockLoggingService for mock implementation\n * details. For the most part, the analytics and logging services just implement their functions\n * with jest.fn() and do nothing else, whereas the MockAuthService actually has some behavior\n * implemented, it just doesn't make any HTTP calls.\n *\n * Note that this mock application is not sufficient for testing the full application lifecycle or\n * initialization callbacks/custom handlers as described in the 'initialize' function's\n * documentation. It exists merely to set up the mock services that components themselves tend to\n * interact with most often. It could be extended to allow for setting up custom handlers fairly\n * easily, as this functionality would be more-or-less identical to what the real initialize\n * function does.\n *\n * Example:\n *\n * ```\n * import { initializeMockApp } from '@edx/frontend-platform/testing';\n * import { logInfo } from '@edx/frontend-platform/logging';\n *\n * describe('initializeMockApp', () => {\n * it('mocks things correctly', () => {\n * const { loggingService } = initializeMockApp();\n * logInfo('test', {});\n * expect(loggingService.logInfo).toHaveBeenCalledWith('test', {});\n * });\n * });\n * ```\n *\n * @param {Object} [options]\n * @param {*} [options.messages] A i18n-compatible messages object, or an array of such objects. If\n * an array is provided, duplicate keys are resolved with the last-one-in winning.\n * @param {UserData|null} [options.authenticatedUser] A UserData object representing the\n * authenticated user. This is passed directly to MockAuthService.\n * @memberof module:Testing\n */\nexport default function initializeMockApp({\n messages = mockMessages,\n authenticatedUser = null,\n} = {}) {\n const loggingService = configureLogging(MockLoggingService, {\n config: getConfig(),\n });\n\n const authService = configureAuth(MockAuthService, {\n config: { ...getConfig(), authenticatedUser },\n loggingService,\n });\n\n const analyticsService = configureAnalytics(MockAnalyticsService, {\n config: getConfig(),\n httpClient: authService.getAuthenticatedHttpClient(),\n loggingService,\n });\n\n // The i18n service configure function has no return value, since there isn't a service class.\n configureI18n({\n config: getConfig(),\n loggingService,\n messages,\n });\n\n return {\n analyticsService,\n authService,\n loggingService,\n };\n}\n"],"mappings":";;;;;;AAAA,SAASA,SAAS,IAAIC,kBAAtB,EAA0CC,oBAA1C,QAAsE,cAAtE;AACA,SAASF,SAAS,IAAIG,aAAtB,QAA2C,SAA3C;AACA,SAASH,SAAS,IAAII,gBAAtB,EAAwCC,kBAAxC,QAAkE,YAAlE;AACA,SAASL,SAAS,IAAIM,aAAtB,EAAqCC,eAArC,QAA4D,SAA5D;AACA,SAASC,SAAT,QAA0B,WAA1B;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,iBAAT,GAGP;EAAA,+EAAJ,EAAI;EAAA,yBAFNC,QAEM;EAAA,IAFNA,QAEM,8BAFKF,YAEL;EAAA,iCADNG,iBACM;EAAA,IADNA,iBACM,sCADc,IACd;;EACN,IAAMC,cAAc,GAAGT,gBAAgB,CAACC,kBAAD,EAAqB;IAC1DS,MAAM,EAAEN,SAAS;EADyC,CAArB,CAAvC;EAIA,IAAMO,WAAW,GAAGT,aAAa,CAACC,eAAD,EAAkB;IACjDO,MAAM,kCAAON,SAAS,EAAhB;MAAoBI,iBAAiB,EAAjBA;IAApB,EAD2C;IAEjDC,cAAc,EAAdA;EAFiD,CAAlB,CAAjC;EAKA,IAAMG,gBAAgB,GAAGf,kBAAkB,CAACC,oBAAD,EAAuB;IAChEY,MAAM,EAAEN,SAAS,EAD+C;IAEhES,UAAU,EAAEF,WAAW,CAACG,0BAAZ,EAFoD;IAGhEL,cAAc,EAAdA;EAHgE,CAAvB,CAA3C,CAVM,CAgBN;;EACAV,aAAa,CAAC;IACZW,MAAM,EAAEN,SAAS,EADL;IAEZK,cAAc,EAAdA,cAFY;IAGZF,QAAQ,EAARA;EAHY,CAAD,CAAb;EAMA,OAAO;IACLK,gBAAgB,EAAhBA,gBADK;IAELD,WAAW,EAAXA,WAFK;IAGLF,cAAc,EAAdA;EAHK,CAAP;AAKD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"mockMessages.js","names":["messages","ar","fr","ca","he","id","pl","ru","th","uk"],"sources":["../../src/testing/mockMessages.js"],"sourcesContent":["/**\n * An empty messages object suitable for fulfilling the i18n service's contract.\n * @memberof module:Testing\n */\nconst messages = {\n ar: {},\n 'es-419': {},\n fr: {},\n 'zh-cn': {},\n ca: {},\n he: {},\n id: {},\n 'ko-kr': {},\n pl: {},\n 'pt-br': {},\n ru: {},\n th: {},\n uk: {},\n};\n\nexport default messages;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,IAAMA,QAAQ,GAAG;EACfC,EAAE,EAAE,EADW;EAEf,UAAU,EAFK;EAGfC,EAAE,EAAE,EAHW;EAIf,SAAS,EAJM;EAKfC,EAAE,EAAE,EALW;EAMfC,EAAE,EAAE,EANW;EAOfC,EAAE,EAAE,EAPW;EAQf,SAAS,EARM;EASfC,EAAE,EAAE,EATW;EAUf,SAAS,EAVM;EAWfC,EAAE,EAAE,EAXW;EAYfC,EAAE,EAAE,EAZW;EAafC,EAAE,EAAE;AAbW,CAAjB;AAgBA,eAAeT,QAAf"}
|
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["camelCase","snakeCase","modifyObjectKeys","object","modify","undefined","Array","isArray","map","value","result","Object","entries","forEach","key","camelCaseObject","snakeCaseObject","convertKeyNames","nameMap","transformer","getQueryParameters","search","global","location","keyValueFragments","slice","indexOf","split","filter","hash","reduce","params","keyValueFragment","assign","decodeURIComponent","ensureDefinedConfig","requester","keys","console","warn"],"sources":["../src/utils.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform**\n *\n * @module Utilities\n */\nimport camelCase from 'lodash.camelcase';\nimport snakeCase from 'lodash.snakecase';\n\n/**\n * This is the underlying function used by camelCaseObject, snakeCaseObject, and convertKeyNames\n * above.\n *\n * Given an object (or array) and a modification function, will perform the function on each key it\n * encounters on the object and its tree of children.\n *\n * The modification function must take a string as an argument and returns a string.\n *\n * Example:\n *\n * ```\n * (key) => {\n * if (key === 'edX') {\n * return 'Open edX';\n * }\n * return key;\n * }\n * ```\n *\n * This function will turn any key that matches 'edX' into 'Open edX'. All other keys will be\n * passed through unmodified.\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Object} object\n * @param {function} modify\n * @returns {Object}\n */\nexport function modifyObjectKeys(object, modify) {\n // If the passed in object is not an Object, return it.\n if (\n object === undefined\n || object === null\n || (typeof object !== 'object' && !Array.isArray(object))\n ) {\n return object;\n }\n\n if (Array.isArray(object)) {\n return object.map(value => modifyObjectKeys(value, modify));\n }\n\n // Otherwise, process all its keys.\n const result = {};\n Object.entries(object).forEach(([key, value]) => {\n result[modify(key)] = modifyObjectKeys(value, modify);\n });\n return result;\n}\n\n/**\n * Performs a deep conversion to camelCase on all keys in the provided object and its tree of\n * children. Uses [lodash.camelcase](https://lodash.com/docs/4.17.15#camelCase) on each key. This\n * is commonly used to convert snake_case keys in models from a backend server into camelCase keys\n * for use in the JavaScript client.\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Array|Object} object\n * @returns {Array|Object}\n */\nexport function camelCaseObject(object) {\n return modifyObjectKeys(object, camelCase);\n}\n\n/**\n * Performs a deep conversion to snake_case on all keys in the provided object and its tree of\n * children. Uses [lodash.snakecase](https://lodash.com/docs/4.17.15#snakeCase) on each key. This\n * is commonly used to convert camelCase keys from the JavaScript app into snake_case keys expected\n * by backend servers.\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Array|Object} object\n * @returns {Array|Object}\n */\nexport function snakeCaseObject(object) {\n return modifyObjectKeys(object, snakeCase);\n}\n\n/**\n * Given a map of key-value pairs, performs a deep conversion key names in the specified object\n * _from_ the key _to_ the value. This is useful for updating names in an API request to the names\n * used throughout a client application if they happen to differ. It can also be used in the\n * reverse - formatting names from the client application to names expected by an API.\n *\n * ```\n * import { convertKeyNames } from '@edx/frontend-base';\n *\n * // This object can be of any shape or depth with subobjects/arrays.\n * const myObject = {\n * myKey: 'my value',\n * }\n *\n * const result = convertKeyNames(myObject, { myKey: 'their_key' });\n *\n * console.log(result) // { their_key: 'my value' }\n * ```\n *\n * Can accept arrays as well as objects, and will perform its conversion on any objects it finds in\n * the array.\n *\n * @param {Array|Object} object\n * @param {Object} nameMap\n * @returns {Array|Object}\n */\nexport function convertKeyNames(object, nameMap) {\n const transformer = key => (nameMap[key] === undefined ? key : nameMap[key]);\n\n return modifyObjectKeys(object, transformer);\n}\n\n/**\n * *Deprecated*: A method which converts the supplied query string into an object of\n * key-value pairs and returns it. Defaults to the current query string - should perform like\n * [window.searchParams](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams)\n *\n * @deprecated\n * @param {string} [search=global.location.search]\n * @returns {Object}\n */\nexport function getQueryParameters(search = global.location.search) {\n const keyValueFragments = search\n .slice(search.indexOf('?') + 1)\n .split('&')\n .filter(hash => hash !== '');\n\n return keyValueFragments.reduce((params, keyValueFragment) => {\n const split = keyValueFragment.indexOf('=');\n const key = keyValueFragment.slice(0, split);\n const value = keyValueFragment.slice(split + 1);\n return Object.assign(params, { [key]: decodeURIComponent(value) });\n }, {});\n}\n\n/**\n * This function helps catch a certain class of misconfiguration in which configuration variables\n * are not properly defined and/or supplied to a consumer that requires them. Any key that exists\n * is still set to \"undefined\" indicates a misconfiguration further up in the application, and\n * should be flagged as an error, and is logged to 'warn'.\n *\n * Keys that are intended to be falsy should be defined using null, 0, false, etc.\n *\n * @param {Object} object\n * @param {string} requester A human-readable identifier for the code which called this function.\n * Used when throwing errors to aid in debugging.\n */\nexport function ensureDefinedConfig(object, requester) {\n Object.keys(object).forEach((key) => {\n if (object[key] === undefined) {\n // eslint-disable-next-line no-console\n console.warn(`Module configuration error: ${key} is required by ${requester}.`);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,kBAAtB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AAEA;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;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,CAA0BC,MAA1B,EAAkCC,MAAlC,EAA0C;EAC/C;EACA,IACED,MAAM,KAAKE,SAAX,IACGF,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OAAO,CAACC,IAAR,uCAA4CzB,GAA5C,6BAAkEsB,SAAlE;IACD;EACF,CALD;AAMD"}
|
package/i18n/scripts/Makefile
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# For more details about the translation jobs, see https://github.com/edx/frontend-i18n/blob/master/docs/how_tos/i18n.rst
|
|
2
|
-
|
|
3
|
-
transifex_langs = "ar,fr,es_419,zh_CN"
|
|
4
|
-
transifex_utils = ./node_modules/.bin/transifex-utils.js
|
|
5
|
-
transifex_input = ./src/i18n/transifex_input.json
|
|
6
|
-
tx_url1 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/translation/en/strings/
|
|
7
|
-
tx_url2 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/source/
|
|
8
|
-
|
|
9
|
-
i18n.extract:
|
|
10
|
-
# Pulling display strings from .jsx files into .json files...
|
|
11
|
-
rm -rf $(transifex_temp)
|
|
12
|
-
npm run-script i18n_extract
|
|
13
|
-
|
|
14
|
-
i18n.concat:
|
|
15
|
-
# Gathering JSON messages into one file...
|
|
16
|
-
$(transifex_utils) $(transifex_temp) $(transifex_input)
|
|
17
|
-
|
|
18
|
-
detect_changed_source_translations:
|
|
19
|
-
# Checking for changed translations...
|
|
20
|
-
git diff --exit-code $(transifex_input)
|
|
21
|
-
|
|
22
|
-
validate-no-uncommitted-package-lock-changes:
|
|
23
|
-
# Checking for package-lock.json changes...
|
|
24
|
-
git diff --exit-code package-lock.json
|
|
25
|
-
|
|
26
|
-
# Push translations to Transifex. Run make extract_translations first.
|
|
27
|
-
push_translations:
|
|
28
|
-
# Pushing strings to Transifex...
|
|
29
|
-
tx push -s
|
|
30
|
-
# Fetching hashes from Transifex...
|
|
31
|
-
./node_modules/reactifex/bash_scripts/get_hashed_strings.sh $(tx_url1)
|
|
32
|
-
# Writing out comments to file...
|
|
33
|
-
$(transifex_utils) $(transifex_temp) --comments
|
|
34
|
-
# Pushing comments to Transifex...
|
|
35
|
-
./node_modules/reactifex/bash_scripts/put_comments.sh $(tx_url2)
|
|
36
|
-
|
|
37
|
-
# Pull translations from Transifex
|
|
38
|
-
pull_translations:
|
|
39
|
-
tx pull -f --mode reviewed --language=$(transifex_langs)
|