@edx/frontend-platform 2.5.0 → 2.6.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/auth/AxiosCsrfTokenService.js +6 -2
- package/auth/AxiosCsrfTokenService.js.map +1 -1
- package/auth/AxiosJwtAuthService.js +10 -6
- package/auth/AxiosJwtAuthService.js.map +1 -1
- package/auth/AxiosJwtTokenService.js +8 -4
- package/auth/AxiosJwtTokenService.js.map +1 -1
- package/auth/LocalForageCache.js +8 -4
- package/auth/LocalForageCache.js.map +1 -1
- package/auth/MockAuthService.js.map +1 -1
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js +6 -2
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createJwtTokenProviderInterceptor.js +6 -2
- package/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +6 -2
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -1
- package/auth/interceptors/createRetryInterceptor.js +9 -5
- package/auth/interceptors/createRetryInterceptor.js.map +1 -1
- package/auth/interface.js +10 -6
- package/auth/interface.js.map +1 -1
- package/config.js +3 -1
- package/config.js.map +1 -1
- package/i18n/countries.js +13 -13
- package/i18n/countries.js.map +1 -1
- package/i18n/injectIntlWithShim.js +3 -3
- package/i18n/languages.js +5 -5
- package/i18n/languages.js.map +1 -1
- package/initialize.js +16 -12
- package/initialize.js.map +1 -1
- package/package.json +4 -4
- package/react/AppProvider.js +10 -7
- package/react/AppProvider.js.map +1 -1
- package/react/ErrorBoundary.js +2 -2
- package/react/ErrorPage.js +49 -64
- package/react/ErrorPage.js.map +1 -1
- package/react/OptionalReduxProvider.js +1 -1
- package/react/OptionalReduxProvider.js.map +1 -1
- package/react/PageRoute.js +2 -1
- package/react/PageRoute.js.map +1 -1
- package/react/hooks.js +1 -1
- package/react/hooks.js.map +1 -1
package/i18n/languages.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"languages.js","names":["LANGUAGES","langs","languageLangs","getPrimaryLanguageSubtag","registerLocale","require","getLanguageMessages","locale","primaryLanguageSubtag","languageCode","includes","getNames","getLanguageList","languageMessages","Object","entries","map","code","name"],"sources":["../../src/i18n/languages.js"],"sourcesContent":["import LANGUAGES, { langs as languageLangs } from '@cospired/i18n-iso-languages';\n\nimport { getPrimaryLanguageSubtag } from './lib';\n\n/*\n * LANGUAGE LISTS\n *\n * Lists of language names localized in supported languages.\n *\n * TODO: When we start dynamically loading translations only for the current locale, change this.\n * TODO: Also note that a bunch of languages are missing here. They're present but commented out\n * for reference. That's because they're not implemented in this library. If you read this and it's\n * been a while, go check and see if that's changed!\n */\n\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/ar.json'));\nLANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/en
|
|
1
|
+
{"version":3,"file":"languages.js","names":["LANGUAGES","langs","languageLangs","getPrimaryLanguageSubtag","registerLocale","require","getLanguageMessages","locale","primaryLanguageSubtag","languageCode","includes","getNames","getLanguageList","languageMessages","Object","entries","map","code","name"],"sources":["../../src/i18n/languages.js"],"sourcesContent":["import LANGUAGES, { langs as languageLangs } from '@cospired/i18n-iso-languages';\n\nimport { getPrimaryLanguageSubtag } from './lib';\n\n/*\n * LANGUAGE LISTS\n *\n * Lists of language names localized in supported languages.\n *\n * TODO: When we start dynamically loading translations only for the current locale, change this.\n * TODO: Also note that a bunch of languages are missing here. They're present but commented out\n * for reference. That's because they're not implemented in this library. If you read this and it's\n * been a while, go check and see if that's changed!\n */\n\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/ar.json'));\nLANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/en'));\nLANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/es'));\nLANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/fr'));\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/zh.json'));\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/ca.json'));\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/he.json'));\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/id.json'));\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/ko.json'));\nLANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/pl'));\nLANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/pt'));\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/ru.json'));\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/th.json'));\n// LANGUAGES.registerLocale(require('@cospired/i18n-iso-languages/langs/uk.json'));\n\n/**\n * Provides a lookup table of language IDs to language names for the current locale.\n *\n * @memberof I18n\n */\nexport const getLanguageMessages = (locale) => {\n const primaryLanguageSubtag = getPrimaryLanguageSubtag(locale);\n const languageCode = languageLangs().includes(primaryLanguageSubtag) ? primaryLanguageSubtag : 'en';\n\n return LANGUAGES.getNames(languageCode);\n};\n\n/**\n * Provides a list of languages represented as objects of the following shape:\n *\n * {\n * key, // The ID of the language\n * name // The localized name of the language\n * }\n *\n * TODO: ARCH-878: The list should be sorted alphabetically in the current locale.\n * This is useful for populating dropdowns.\n *\n * @memberof I18n\n */\nexport const getLanguageList = (locale) => {\n const languageMessages = getLanguageMessages(locale);\n return Object.entries(languageMessages).map(([code, name]) => ({ code, name }));\n};\n"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,IAAoBC,KAAK,IAAIC,aAA7B,QAAkD,8BAAlD;AAEA,SAASC,wBAAT,QAAyC,OAAzC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AACAH,SAAS,CAACI,cAAV,CAAyBC,OAAO,CAAC,uCAAD,CAAhC;AACAL,SAAS,CAACI,cAAV,CAAyBC,OAAO,CAAC,uCAAD,CAAhC;AACAL,SAAS,CAACI,cAAV,CAAyBC,OAAO,CAAC,uCAAD,CAAhC,E,CACA;AACA;AACA;AACA;AACA;;AACAL,SAAS,CAACI,cAAV,CAAyBC,OAAO,CAAC,uCAAD,CAAhC;AACAL,SAAS,CAACI,cAAV,CAAyBC,OAAO,CAAC,uCAAD,CAAhC,E,CACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,MAAD,EAAY;EAC7C,IAAMC,qBAAqB,GAAGL,wBAAwB,CAACI,MAAD,CAAtD;EACA,IAAME,YAAY,GAAGP,aAAa,GAAGQ,QAAhB,CAAyBF,qBAAzB,IAAkDA,qBAAlD,GAA0E,IAA/F;EAEA,OAAOR,SAAS,CAACW,QAAV,CAAmBF,YAAnB,CAAP;AACD,CALM;AAOP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMG,eAAe,GAAG,SAAlBA,eAAkB,CAACL,MAAD,EAAY;EACzC,IAAMM,gBAAgB,GAAGP,mBAAmB,CAACC,MAAD,CAA5C;EACA,OAAOO,MAAM,CAACC,OAAP,CAAeF,gBAAf,EAAiCG,GAAjC,CAAqC;IAAA;IAAA,IAAEC,IAAF;IAAA,IAAQC,IAAR;;IAAA,OAAmB;MAAED,IAAI,EAAJA,IAAF;MAAQC,IAAI,EAAJA;IAAR,CAAnB;EAAA,CAArC,CAAP;AACD,CAHM"}
|
package/initialize.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
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
|
+
|
|
1
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
4
|
|
|
3
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
6
|
|
|
5
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
8
|
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
10
|
+
|
|
7
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
12
|
|
|
9
13
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -101,8 +105,8 @@ export function initError(_x) {
|
|
|
101
105
|
*/
|
|
102
106
|
|
|
103
107
|
function _initError() {
|
|
104
|
-
_initError = _asyncToGenerator( /*#__PURE__*/
|
|
105
|
-
return
|
|
108
|
+
_initError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(error) {
|
|
109
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
106
110
|
while (1) {
|
|
107
111
|
switch (_context2.prev = _context2.next) {
|
|
108
112
|
case 0:
|
|
@@ -128,8 +132,8 @@ export function auth(_x2, _x3) {
|
|
|
128
132
|
*/
|
|
129
133
|
|
|
130
134
|
function _auth() {
|
|
131
|
-
_auth = _asyncToGenerator( /*#__PURE__*/
|
|
132
|
-
return
|
|
135
|
+
_auth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(requireUser, hydrateUser) {
|
|
136
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
133
137
|
while (1) {
|
|
134
138
|
switch (_context3.prev = _context3.next) {
|
|
135
139
|
case 0:
|
|
@@ -180,10 +184,10 @@ export function runtimeConfig() {
|
|
|
180
184
|
*/
|
|
181
185
|
|
|
182
186
|
function _runtimeConfig() {
|
|
183
|
-
_runtimeConfig = _asyncToGenerator( /*#__PURE__*/
|
|
187
|
+
_runtimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
184
188
|
var _getConfig, MFE_CONFIG_API_URL, APP_ID, apiConfig, apiService, params, url, _yield$apiService$get, data;
|
|
185
189
|
|
|
186
|
-
return
|
|
190
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
187
191
|
while (1) {
|
|
188
192
|
switch (_context4.prev = _context4.next) {
|
|
189
193
|
case 0:
|
|
@@ -241,9 +245,9 @@ export function analytics() {
|
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
function _analytics() {
|
|
244
|
-
_analytics = _asyncToGenerator( /*#__PURE__*/
|
|
248
|
+
_analytics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
245
249
|
var authenticatedUser;
|
|
246
|
-
return
|
|
250
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
247
251
|
while (1) {
|
|
248
252
|
switch (_context5.prev = _context5.next) {
|
|
249
253
|
case 0:
|
|
@@ -274,8 +278,8 @@ function _analytics() {
|
|
|
274
278
|
|
|
275
279
|
function applyOverrideHandlers(overrides) {
|
|
276
280
|
var noOp = /*#__PURE__*/function () {
|
|
277
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/
|
|
278
|
-
return
|
|
281
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
282
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
279
283
|
while (1) {
|
|
280
284
|
switch (_context.prev = _context.next) {
|
|
281
285
|
case 0:
|
|
@@ -355,10 +359,10 @@ export function initialize(_x4) {
|
|
|
355
359
|
}
|
|
356
360
|
|
|
357
361
|
function _initialize() {
|
|
358
|
-
_initialize = _asyncToGenerator( /*#__PURE__*/
|
|
362
|
+
_initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref2) {
|
|
359
363
|
var _ref2$loggingService, loggingService, _ref2$analyticsServic, analyticsService, _ref2$authService, authService, _ref2$authMiddleware, authMiddleware, _ref2$requireAuthenti, requireUser, _ref2$hydrateAuthenti, hydrateUser, messages, _ref2$handlers, overrideHandlers, handlers;
|
|
360
364
|
|
|
361
|
-
return
|
|
365
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
362
366
|
while (1) {
|
|
363
367
|
switch (_context6.prev = _context6.next) {
|
|
364
368
|
case 0:
|
package/initialize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","names":["createBrowserHistory","createMemoryHistory","publish","getConfig","mergeConfig","configure","configureLogging","getLoggingService","NewRelicLoggingService","logError","configureAnalytics","SegmentAnalyticsService","identifyAnonymousUser","identifyAuthenticatedUser","getAuthenticatedHttpClient","configureAuth","ensureAuthenticatedUser","fetchAuthenticatedUser","hydrateAuthenticatedUser","getAuthenticatedUser","AxiosJwtAuthService","configureI18n","APP_PUBSUB_INITIALIZED","APP_CONFIG_INITIALIZED","APP_AUTH_INITIALIZED","APP_I18N_INITIALIZED","APP_LOGGING_INITIALIZED","APP_ANALYTICS_INITIALIZED","APP_READY","APP_INIT_ERROR","configureCache","history","window","basename","PUBLIC_PATH","initError","error","auth","requireUser","hydrateUser","global","location","href","runtimeConfig","MFE_CONFIG_API_URL","APP_ID","apiConfig","headers","accept","apiService","params","URLSearchParams","append","url","toString","get","data","console","message","analytics","authenticatedUser","userId","applyOverrideHandlers","overrides","noOp","pubSub","config","logging","i18n","ready","initialize","loggingService","analyticsService","authService","authMiddleware","requireAuthenticatedUser","messages","handlers","overrideHandlers","middleware","httpClient","isRedirecting"],"sources":["../src/initialize.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform**\n *\n * The initialization module provides a function for managing an application's initialization\n * lifecycle. It also provides constants and default handler implementations.\n *\n * ```\n * import {\n * initialize,\n * APP_INIT_ERROR,\n * APP_READY,\n * subscribe,\n * } from '@edx/frontend-platform';\n * import { AppProvider, ErrorPage, PageRoute } from '@edx/frontend-platform/react';\n * import React from 'react';\n * import ReactDOM from 'react-dom';\n * import { Switch } from 'react-router-dom';\n *\n * subscribe(APP_READY, () => {\n * ReactDOM.render(\n * <AppProvider store={configureStore()}>\n * <Header />\n * <main>\n * <Switch>\n * <PageRoute exact path=\"/\" component={PaymentPage} />\n * </Switch>\n * </main>\n * <Footer />\n * </AppProvider>,\n * document.getElementById('root'),\n * );\n * });\n *\n * subscribe(APP_INIT_ERROR, (error) => {\n * ReactDOM.render(<ErrorPage message={error.message} />, document.getElementById('root'));\n * });\n *\n * initialize({\n * messages: [appMessages],\n * requireAuthenticatedUser: true,\n * hydrateAuthenticatedUser: true,\n * });\n\n```\n * @module Initialization\n */\n\nimport { createBrowserHistory, createMemoryHistory } from 'history';\nimport {\n publish,\n} from './pubSub';\n// eslint-disable-next-line import/no-cycle\nimport {\n getConfig, mergeConfig,\n} from './config';\nimport {\n configure as configureLogging, getLoggingService, NewRelicLoggingService, logError,\n} from './logging';\nimport {\n configure as configureAnalytics, SegmentAnalyticsService, identifyAnonymousUser, identifyAuthenticatedUser,\n} from './analytics';\nimport {\n getAuthenticatedHttpClient,\n configure as configureAuth,\n ensureAuthenticatedUser,\n fetchAuthenticatedUser,\n hydrateAuthenticatedUser,\n getAuthenticatedUser,\n AxiosJwtAuthService,\n} from './auth';\nimport { configure as configureI18n } from './i18n';\nimport {\n APP_PUBSUB_INITIALIZED,\n APP_CONFIG_INITIALIZED,\n APP_AUTH_INITIALIZED,\n APP_I18N_INITIALIZED,\n APP_LOGGING_INITIALIZED,\n APP_ANALYTICS_INITIALIZED,\n APP_READY, APP_INIT_ERROR,\n} from './constants';\nimport configureCache from './auth/LocalForageCache';\n\n/**\n * A browser history or memory history object created by the [history](https://github.com/ReactTraining/history)\n * package. Applications are encouraged to use this history object, rather than creating their own,\n * as behavior may be undefined when managing history via multiple mechanisms/instances. Note that\n * in environments where browser history may be inaccessible due to `window` being undefined, this\n * falls back to memory history.\n */\nexport const history = (typeof window !== 'undefined')\n ? createBrowserHistory({\n basename: getConfig().PUBLIC_PATH,\n }) : createMemoryHistory();\n\n/**\n * The default handler for the initialization lifecycle's `initError` phase. Logs the error to the\n * LoggingService using `logError`\n *\n * @see {@link module:frontend-platform/logging~logError}\n * @param {*} error\n */\nexport async function initError(error) {\n logError(error);\n}\n\n/**\n * The default handler for the initialization lifecycle's `auth` phase.\n *\n * The handler has several responsibilities:\n * - Determining the user's authentication state (authenticated or anonymous)\n * - Optionally redirecting to login if the application requires an authenticated user.\n * - Optionally loading additional user information via the application's user account data\n * endpoint.\n *\n * @param {boolean} requireUser Whether or not we should redirect to login if a user is not\n * authenticated.\n * @param {boolean} hydrateUser Whether or not we should fetch additional user account data.\n */\nexport async function auth(requireUser, hydrateUser) {\n if (requireUser) {\n await ensureAuthenticatedUser(global.location.href);\n } else {\n await fetchAuthenticatedUser();\n }\n\n if (hydrateUser && getAuthenticatedUser() !== null) {\n // We intentionally do not await the promise returned by hydrateAuthenticatedUser. All the\n // critical data is returned as part of fetch/ensureAuthenticatedUser above, and anything else\n // is a nice-to-have for application code.\n hydrateAuthenticatedUser();\n }\n}\n/*\n * Set or overrides configuration through an API.\n * This method allows runtime configuration.\n * Set a basic configuration when an error happen and allow initError and display the ErrorPage.\n */\n\nexport async function runtimeConfig() {\n try {\n const { MFE_CONFIG_API_URL, APP_ID } = getConfig();\n\n if (MFE_CONFIG_API_URL) {\n const apiConfig = { headers: { accept: 'application/json' } };\n const apiService = await configureCache();\n\n const params = new URLSearchParams();\n params.append('mfe', APP_ID);\n const url = `${MFE_CONFIG_API_URL}?${params.toString()}`;\n\n const { data } = await apiService.get(url, apiConfig);\n mergeConfig(data);\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error with config API', error.message);\n }\n}\n\n/**\n * The default handler for the initialization lifecycle's `analytics` phase.\n *\n * The handler is responsible for identifying authenticated and anonymous users with the analytics\n * service. This is a pre-requisite for sending analytics events, thus, we do it during the\n * initialization sequence so that analytics is ready once the application's UI code starts to load.\n *\n */\nexport async function analytics() {\n const authenticatedUser = getAuthenticatedUser();\n if (authenticatedUser && authenticatedUser.userId) {\n identifyAuthenticatedUser(authenticatedUser.userId);\n } else {\n await identifyAnonymousUser();\n }\n}\n\nfunction applyOverrideHandlers(overrides) {\n const noOp = async () => { };\n return {\n pubSub: noOp,\n config: noOp,\n logging: noOp,\n auth,\n analytics,\n i18n: noOp,\n ready: noOp,\n initError,\n ...overrides, // This will override any same-keyed handlers from above.\n };\n}\n\n/**\n * Invokes the application initialization sequence.\n *\n * The sequence proceeds through a number of lifecycle phases, during which pertinent services are\n * configured.\n *\n * Using the `handlers` option, lifecycle phase handlers can be overridden to perform custom\n * functionality. Note that while these override handlers _do_ replace the default handler\n * functionality for analytics, auth, and initError (the other phases have no default\n * functionality), they do _not_ override the configuration of the actual services that those\n * handlers leverage.\n *\n * Some services can be overridden via the loggingService and analyticsService options. The other\n * services (auth and i18n) cannot currently be overridden.\n *\n * The following lifecycle phases exist:\n *\n * - pubSub: A no-op by default.\n * - config: A no-op by default.\n * - logging: A no-op by default.\n * - auth: Uses the 'auth' handler defined above.\n * - analytics: Uses the 'analytics' handler defined above.\n * - i18n: A no-op by default.\n * - ready: A no-op by default.\n * - initError: Uses the 'initError' handler defined above.\n *\n * @param {Object} [options]\n * @param {*} [options.loggingService=NewRelicLoggingService] The `LoggingService` implementation\n * to use.\n * @param {*} [options.analyticsService=SegmentAnalyticsService] The `AnalyticsService`\n * implementation to use.\n * @param {*} [options.authMiddleware=[]] An array of middleware to apply to http clients in the auth service.\n * @param {*} [options.requireAuthenticatedUser=false] If true, turns on automatic login\n * redirection for unauthenticated users. Defaults to false, meaning that by default the\n * application will allow anonymous/unauthenticated sessions.\n * @param {*} [options.hydrateAuthenticatedUser=false] If true, makes an API call to the user\n * account endpoint (`${App.config.LMS_BASE_URL}/api/user/v1/accounts/${username}`) to fetch\n * detailed account information for the authenticated user. This data is merged into the return\n * value of `getAuthenticatedUser`, overriding any duplicate keys that already exist. Defaults to\n * false, meaning that no additional account information will be loaded.\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 {*} [options.handlers={}] An optional object of handlers which can be used to replace the\n * default behavior of any part of the startup sequence. It can also be used to add additional\n * initialization behavior before or after the rest of the sequence.\n */\nexport async function initialize({\n loggingService = NewRelicLoggingService,\n analyticsService = SegmentAnalyticsService,\n authService = AxiosJwtAuthService,\n authMiddleware = [],\n requireAuthenticatedUser: requireUser = false,\n hydrateAuthenticatedUser: hydrateUser = false,\n messages,\n handlers: overrideHandlers = {},\n}) {\n const handlers = applyOverrideHandlers(overrideHandlers);\n try {\n // Pub/Sub\n await handlers.pubSub();\n publish(APP_PUBSUB_INITIALIZED);\n\n // Configuration\n await handlers.config();\n await runtimeConfig();\n publish(APP_CONFIG_INITIALIZED);\n\n // Logging\n configureLogging(loggingService, {\n config: getConfig(),\n });\n await handlers.logging();\n publish(APP_LOGGING_INITIALIZED);\n\n // Authentication\n configureAuth(authService, {\n loggingService: getLoggingService(),\n config: getConfig(),\n middleware: authMiddleware,\n });\n\n await handlers.auth(requireUser, hydrateUser);\n publish(APP_AUTH_INITIALIZED);\n\n // Analytics\n configureAnalytics(analyticsService, {\n config: getConfig(),\n loggingService: getLoggingService(),\n httpClient: getAuthenticatedHttpClient(),\n });\n await handlers.analytics();\n publish(APP_ANALYTICS_INITIALIZED);\n\n // Internationalization\n configureI18n({\n messages,\n config: getConfig(),\n loggingService: getLoggingService(),\n });\n await handlers.i18n();\n publish(APP_I18N_INITIALIZED);\n\n // Application Ready\n await handlers.ready();\n publish(APP_READY);\n } catch (error) {\n if (!error.isRedirecting) {\n // Initialization Error\n await handlers.initError(error);\n publish(APP_INIT_ERROR, error);\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAAA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,oBAAT,EAA+BC,mBAA/B,QAA0D,SAA1D;AACA,SACEC,OADF,QAEO,UAFP,C,CAGA;;AACA,SACEC,SADF,EACaC,WADb,QAEO,UAFP;AAGA,SACEC,SAAS,IAAIC,gBADf,EACiCC,iBADjC,EACoDC,sBADpD,EAC4EC,QAD5E,QAEO,WAFP;AAGA,SACEJ,SAAS,IAAIK,kBADf,EACmCC,uBADnC,EAC4DC,qBAD5D,EACmFC,yBADnF,QAEO,aAFP;AAGA,SACEC,0BADF,EAEET,SAAS,IAAIU,aAFf,EAGEC,uBAHF,EAIEC,sBAJF,EAKEC,wBALF,EAMEC,oBANF,EAOEC,mBAPF,QAQO,QARP;AASA,SAASf,SAAS,IAAIgB,aAAtB,QAA2C,QAA3C;AACA,SACEC,sBADF,EAEEC,sBAFF,EAGEC,oBAHF,EAIEC,oBAJF,EAKEC,uBALF,EAMEC,yBANF,EAOEC,SAPF,EAOaC,cAPb,QAQO,aARP;AASA,OAAOC,cAAP,MAA2B,yBAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,OAAO,GAAI,OAAOC,MAAP,KAAkB,WAAnB,GACnBhC,oBAAoB,CAAC;EACrBiC,QAAQ,EAAE9B,SAAS,GAAG+B;AADD,CAAD,CADD,GAGhBjC,mBAAmB,EAHnB;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,gBAAsBkC,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BAAkB,CAAC8D,gBAAD,EAAmB;cACnCN,MAAM,EAAE/D,SAAS,EADkB;cAEnCoE,cAAc,EAAEhE,iBAAiB,EAFE;cAGnCyE,UAAU,EAAElE,0BAA0B;YAHH,CAAnB,CAAlB;YAvCG;YAAA,OA4CG+D,QAAQ,CAAClB,SAAT,EA5CH;;UAAA;YA6CHzD,OAAO,CAACyB,yBAAD,CAAP,CA7CG,CA+CH;;YACAN,aAAa,CAAC;cACZuD,QAAQ,EAARA,QADY;cAEZV,MAAM,EAAE/D,SAAS,EAFL;cAGZoE,cAAc,EAAEhE,iBAAiB;YAHrB,CAAD,CAAb;YAhDG;YAAA,OAqDGsE,QAAQ,CAACT,IAAT,EArDH;;UAAA;YAsDHlE,OAAO,CAACuB,oBAAD,CAAP,CAtDG,CAwDH;;YAxDG;YAAA,OAyDGoD,QAAQ,CAACR,KAAT,EAzDH;;UAAA;YA0DHnE,OAAO,CAAC0B,SAAD,CAAP;YA1DG;YAAA;;UAAA;YAAA;YAAA;;YAAA,IA4DE,aAAMqD,aA5DR;cAAA;cAAA;YAAA;;YAAA;YAAA,OA8DKJ,QAAQ,CAAC1C,SAAT,cA9DL;;UAAA;YA+DDjC,OAAO,CAAC2B,cAAD,eAAP;;UA/DC;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C"}
|
|
1
|
+
{"version":3,"file":"initialize.js","names":["createBrowserHistory","createMemoryHistory","publish","getConfig","mergeConfig","configure","configureLogging","getLoggingService","NewRelicLoggingService","logError","configureAnalytics","SegmentAnalyticsService","identifyAnonymousUser","identifyAuthenticatedUser","getAuthenticatedHttpClient","configureAuth","ensureAuthenticatedUser","fetchAuthenticatedUser","hydrateAuthenticatedUser","getAuthenticatedUser","AxiosJwtAuthService","configureI18n","APP_PUBSUB_INITIALIZED","APP_CONFIG_INITIALIZED","APP_AUTH_INITIALIZED","APP_I18N_INITIALIZED","APP_LOGGING_INITIALIZED","APP_ANALYTICS_INITIALIZED","APP_READY","APP_INIT_ERROR","configureCache","history","window","basename","PUBLIC_PATH","initError","error","auth","requireUser","hydrateUser","global","location","href","runtimeConfig","MFE_CONFIG_API_URL","APP_ID","apiConfig","headers","accept","apiService","params","URLSearchParams","append","url","toString","get","data","console","message","analytics","authenticatedUser","userId","applyOverrideHandlers","overrides","noOp","pubSub","config","logging","i18n","ready","initialize","loggingService","analyticsService","authService","authMiddleware","requireAuthenticatedUser","messages","handlers","overrideHandlers","middleware","httpClient","isRedirecting"],"sources":["../src/initialize.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform**\n *\n * The initialization module provides a function for managing an application's initialization\n * lifecycle. It also provides constants and default handler implementations.\n *\n * ```\n * import {\n * initialize,\n * APP_INIT_ERROR,\n * APP_READY,\n * subscribe,\n * } from '@edx/frontend-platform';\n * import { AppProvider, ErrorPage, PageRoute } from '@edx/frontend-platform/react';\n * import React from 'react';\n * import ReactDOM from 'react-dom';\n * import { Switch } from 'react-router-dom';\n *\n * subscribe(APP_READY, () => {\n * ReactDOM.render(\n * <AppProvider store={configureStore()}>\n * <Header />\n * <main>\n * <Switch>\n * <PageRoute exact path=\"/\" component={PaymentPage} />\n * </Switch>\n * </main>\n * <Footer />\n * </AppProvider>,\n * document.getElementById('root'),\n * );\n * });\n *\n * subscribe(APP_INIT_ERROR, (error) => {\n * ReactDOM.render(<ErrorPage message={error.message} />, document.getElementById('root'));\n * });\n *\n * initialize({\n * messages: [appMessages],\n * requireAuthenticatedUser: true,\n * hydrateAuthenticatedUser: true,\n * });\n\n```\n * @module Initialization\n */\n\nimport { createBrowserHistory, createMemoryHistory } from 'history';\nimport {\n publish,\n} from './pubSub';\n// eslint-disable-next-line import/no-cycle\nimport {\n getConfig, mergeConfig,\n} from './config';\nimport {\n configure as configureLogging, getLoggingService, NewRelicLoggingService, logError,\n} from './logging';\nimport {\n configure as configureAnalytics, SegmentAnalyticsService, identifyAnonymousUser, identifyAuthenticatedUser,\n} from './analytics';\nimport {\n getAuthenticatedHttpClient,\n configure as configureAuth,\n ensureAuthenticatedUser,\n fetchAuthenticatedUser,\n hydrateAuthenticatedUser,\n getAuthenticatedUser,\n AxiosJwtAuthService,\n} from './auth';\nimport { configure as configureI18n } from './i18n';\nimport {\n APP_PUBSUB_INITIALIZED,\n APP_CONFIG_INITIALIZED,\n APP_AUTH_INITIALIZED,\n APP_I18N_INITIALIZED,\n APP_LOGGING_INITIALIZED,\n APP_ANALYTICS_INITIALIZED,\n APP_READY, APP_INIT_ERROR,\n} from './constants';\nimport configureCache from './auth/LocalForageCache';\n\n/**\n * A browser history or memory history object created by the [history](https://github.com/ReactTraining/history)\n * package. Applications are encouraged to use this history object, rather than creating their own,\n * as behavior may be undefined when managing history via multiple mechanisms/instances. Note that\n * in environments where browser history may be inaccessible due to `window` being undefined, this\n * falls back to memory history.\n */\nexport const history = (typeof window !== 'undefined')\n ? createBrowserHistory({\n basename: getConfig().PUBLIC_PATH,\n }) : createMemoryHistory();\n\n/**\n * The default handler for the initialization lifecycle's `initError` phase. Logs the error to the\n * LoggingService using `logError`\n *\n * @see {@link module:frontend-platform/logging~logError}\n * @param {*} error\n */\nexport async function initError(error) {\n logError(error);\n}\n\n/**\n * The default handler for the initialization lifecycle's `auth` phase.\n *\n * The handler has several responsibilities:\n * - Determining the user's authentication state (authenticated or anonymous)\n * - Optionally redirecting to login if the application requires an authenticated user.\n * - Optionally loading additional user information via the application's user account data\n * endpoint.\n *\n * @param {boolean} requireUser Whether or not we should redirect to login if a user is not\n * authenticated.\n * @param {boolean} hydrateUser Whether or not we should fetch additional user account data.\n */\nexport async function auth(requireUser, hydrateUser) {\n if (requireUser) {\n await ensureAuthenticatedUser(global.location.href);\n } else {\n await fetchAuthenticatedUser();\n }\n\n if (hydrateUser && getAuthenticatedUser() !== null) {\n // We intentionally do not await the promise returned by hydrateAuthenticatedUser. All the\n // critical data is returned as part of fetch/ensureAuthenticatedUser above, and anything else\n // is a nice-to-have for application code.\n hydrateAuthenticatedUser();\n }\n}\n/*\n * Set or overrides configuration through an API.\n * This method allows runtime configuration.\n * Set a basic configuration when an error happen and allow initError and display the ErrorPage.\n */\n\nexport async function runtimeConfig() {\n try {\n const { MFE_CONFIG_API_URL, APP_ID } = getConfig();\n\n if (MFE_CONFIG_API_URL) {\n const apiConfig = { headers: { accept: 'application/json' } };\n const apiService = await configureCache();\n\n const params = new URLSearchParams();\n params.append('mfe', APP_ID);\n const url = `${MFE_CONFIG_API_URL}?${params.toString()}`;\n\n const { data } = await apiService.get(url, apiConfig);\n mergeConfig(data);\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error with config API', error.message);\n }\n}\n\n/**\n * The default handler for the initialization lifecycle's `analytics` phase.\n *\n * The handler is responsible for identifying authenticated and anonymous users with the analytics\n * service. This is a pre-requisite for sending analytics events, thus, we do it during the\n * initialization sequence so that analytics is ready once the application's UI code starts to load.\n *\n */\nexport async function analytics() {\n const authenticatedUser = getAuthenticatedUser();\n if (authenticatedUser && authenticatedUser.userId) {\n identifyAuthenticatedUser(authenticatedUser.userId);\n } else {\n await identifyAnonymousUser();\n }\n}\n\nfunction applyOverrideHandlers(overrides) {\n const noOp = async () => { };\n return {\n pubSub: noOp,\n config: noOp,\n logging: noOp,\n auth,\n analytics,\n i18n: noOp,\n ready: noOp,\n initError,\n ...overrides, // This will override any same-keyed handlers from above.\n };\n}\n\n/**\n * Invokes the application initialization sequence.\n *\n * The sequence proceeds through a number of lifecycle phases, during which pertinent services are\n * configured.\n *\n * Using the `handlers` option, lifecycle phase handlers can be overridden to perform custom\n * functionality. Note that while these override handlers _do_ replace the default handler\n * functionality for analytics, auth, and initError (the other phases have no default\n * functionality), they do _not_ override the configuration of the actual services that those\n * handlers leverage.\n *\n * Some services can be overridden via the loggingService and analyticsService options. The other\n * services (auth and i18n) cannot currently be overridden.\n *\n * The following lifecycle phases exist:\n *\n * - pubSub: A no-op by default.\n * - config: A no-op by default.\n * - logging: A no-op by default.\n * - auth: Uses the 'auth' handler defined above.\n * - analytics: Uses the 'analytics' handler defined above.\n * - i18n: A no-op by default.\n * - ready: A no-op by default.\n * - initError: Uses the 'initError' handler defined above.\n *\n * @param {Object} [options]\n * @param {*} [options.loggingService=NewRelicLoggingService] The `LoggingService` implementation\n * to use.\n * @param {*} [options.analyticsService=SegmentAnalyticsService] The `AnalyticsService`\n * implementation to use.\n * @param {*} [options.authMiddleware=[]] An array of middleware to apply to http clients in the auth service.\n * @param {*} [options.requireAuthenticatedUser=false] If true, turns on automatic login\n * redirection for unauthenticated users. Defaults to false, meaning that by default the\n * application will allow anonymous/unauthenticated sessions.\n * @param {*} [options.hydrateAuthenticatedUser=false] If true, makes an API call to the user\n * account endpoint (`${App.config.LMS_BASE_URL}/api/user/v1/accounts/${username}`) to fetch\n * detailed account information for the authenticated user. This data is merged into the return\n * value of `getAuthenticatedUser`, overriding any duplicate keys that already exist. Defaults to\n * false, meaning that no additional account information will be loaded.\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 {*} [options.handlers={}] An optional object of handlers which can be used to replace the\n * default behavior of any part of the startup sequence. It can also be used to add additional\n * initialization behavior before or after the rest of the sequence.\n */\nexport async function initialize({\n loggingService = NewRelicLoggingService,\n analyticsService = SegmentAnalyticsService,\n authService = AxiosJwtAuthService,\n authMiddleware = [],\n requireAuthenticatedUser: requireUser = false,\n hydrateAuthenticatedUser: hydrateUser = false,\n messages,\n handlers: overrideHandlers = {},\n}) {\n const handlers = applyOverrideHandlers(overrideHandlers);\n try {\n // Pub/Sub\n await handlers.pubSub();\n publish(APP_PUBSUB_INITIALIZED);\n\n // Configuration\n await handlers.config();\n await runtimeConfig();\n publish(APP_CONFIG_INITIALIZED);\n\n // Logging\n configureLogging(loggingService, {\n config: getConfig(),\n });\n await handlers.logging();\n publish(APP_LOGGING_INITIALIZED);\n\n // Authentication\n configureAuth(authService, {\n loggingService: getLoggingService(),\n config: getConfig(),\n middleware: authMiddleware,\n });\n\n await handlers.auth(requireUser, hydrateUser);\n publish(APP_AUTH_INITIALIZED);\n\n // Analytics\n configureAnalytics(analyticsService, {\n config: getConfig(),\n loggingService: getLoggingService(),\n httpClient: getAuthenticatedHttpClient(),\n });\n await handlers.analytics();\n publish(APP_ANALYTICS_INITIALIZED);\n\n // Internationalization\n configureI18n({\n messages,\n config: getConfig(),\n loggingService: getLoggingService(),\n });\n await handlers.i18n();\n publish(APP_I18N_INITIALIZED);\n\n // Application Ready\n await handlers.ready();\n publish(APP_READY);\n } catch (error) {\n if (!error.isRedirecting) {\n // Initialization Error\n await handlers.initError(error);\n publish(APP_INIT_ERROR, error);\n }\n }\n}\n"],"mappings":";;;;;;;;+CACA,oJ;;;;;;AADA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,oBAAT,EAA+BC,mBAA/B,QAA0D,SAA1D;AACA,SACEC,OADF,QAEO,UAFP,C,CAGA;;AACA,SACEC,SADF,EACaC,WADb,QAEO,UAFP;AAGA,SACEC,SAAS,IAAIC,gBADf,EACiCC,iBADjC,EACoDC,sBADpD,EAC4EC,QAD5E,QAEO,WAFP;AAGA,SACEJ,SAAS,IAAIK,kBADf,EACmCC,uBADnC,EAC4DC,qBAD5D,EACmFC,yBADnF,QAEO,aAFP;AAGA,SACEC,0BADF,EAEET,SAAS,IAAIU,aAFf,EAGEC,uBAHF,EAIEC,sBAJF,EAKEC,wBALF,EAMEC,oBANF,EAOEC,mBAPF,QAQO,QARP;AASA,SAASf,SAAS,IAAIgB,aAAtB,QAA2C,QAA3C;AACA,SACEC,sBADF,EAEEC,sBAFF,EAGEC,oBAHF,EAIEC,oBAJF,EAKEC,uBALF,EAMEC,yBANF,EAOEC,SAPF,EAOaC,cAPb,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2.6.0",
|
|
4
4
|
"description": "Foundational application framework for Open edX micro-frontend applications.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"homepage": "https://github.com/edx/frontend-platform#readme",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@edx/brand": "npm:@edx/brand-openedx@1.1.0",
|
|
35
|
-
"@edx/frontend-build": "
|
|
35
|
+
"@edx/frontend-build": "^12.0.3",
|
|
36
36
|
"@edx/paragon": "20.2.0",
|
|
37
37
|
"axios-mock-adapter": "1.20.0",
|
|
38
38
|
"core-js": "3.21.1",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@cospired/i18n-iso-languages": "2.2.0",
|
|
54
|
-
"@formatjs/intl-pluralrules": "
|
|
55
|
-
"@formatjs/intl-relativetimeformat": "
|
|
54
|
+
"@formatjs/intl-pluralrules": "4.3.3",
|
|
55
|
+
"@formatjs/intl-relativetimeformat": "10.0.1",
|
|
56
56
|
"axios": "0.26.1",
|
|
57
57
|
"axios-cache-adapter": "2.7.3",
|
|
58
58
|
"form-urlencoded": "4.1.4",
|
package/react/AppProvider.js
CHANGED
|
@@ -10,7 +10,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
10
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
-
import React, { useState } from 'react';
|
|
13
|
+
import React, { useState, useMemo } from 'react';
|
|
14
14
|
import PropTypes from 'prop-types';
|
|
15
15
|
import { Router } from 'react-router-dom';
|
|
16
16
|
import OptionalReduxProvider from './OptionalReduxProvider';
|
|
@@ -77,20 +77,23 @@ export default function AppProvider(_ref) {
|
|
|
77
77
|
useAppEvent(LOCALE_CHANGED, function () {
|
|
78
78
|
setLocale(getLocale());
|
|
79
79
|
});
|
|
80
|
+
var appContextValue = useMemo(function () {
|
|
81
|
+
return {
|
|
82
|
+
authenticatedUser: authenticatedUser,
|
|
83
|
+
config: config,
|
|
84
|
+
locale: locale
|
|
85
|
+
};
|
|
86
|
+
}, [authenticatedUser, config, locale]);
|
|
80
87
|
return /*#__PURE__*/React.createElement(IntlProvider, {
|
|
81
88
|
locale: locale,
|
|
82
89
|
messages: getMessages()
|
|
83
90
|
}, /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(AppContext.Provider, {
|
|
84
|
-
value:
|
|
85
|
-
authenticatedUser: authenticatedUser,
|
|
86
|
-
config: config,
|
|
87
|
-
locale: locale
|
|
88
|
-
}
|
|
91
|
+
value: appContextValue
|
|
89
92
|
}, /*#__PURE__*/React.createElement(OptionalReduxProvider, {
|
|
90
93
|
store: store
|
|
91
94
|
}, /*#__PURE__*/React.createElement(Router, {
|
|
92
95
|
history: history
|
|
93
|
-
},
|
|
96
|
+
}, children)))));
|
|
94
97
|
}
|
|
95
98
|
AppProvider.propTypes = {
|
|
96
99
|
// eslint-disable-next-line react/forbid-prop-types
|
package/react/AppProvider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProvider.js","names":["React","useState","PropTypes","Router","OptionalReduxProvider","ErrorBoundary","AppContext","useAppEvent","getAuthenticatedUser","AUTHENTICATED_USER_CHANGED","getConfig","CONFIG_CHANGED","history","getLocale","getMessages","IntlProvider","LOCALE_CHANGED","AppProvider","store","children","config","setConfig","authenticatedUser","setAuthenticatedUser","locale","setLocale","propTypes","object","node","isRequired","defaultProps"],"sources":["../../src/react/AppProvider.jsx"],"sourcesContent":["import React, { useState } 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 } 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 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 return (\n <IntlProvider locale={locale} messages={getMessages()}>\n <ErrorBoundary>\n <AppContext.Provider\n value={
|
|
1
|
+
{"version":3,"file":"AppProvider.js","names":["React","useState","useMemo","PropTypes","Router","OptionalReduxProvider","ErrorBoundary","AppContext","useAppEvent","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 } 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 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,KAAP,IAAgBC,QAAhB,EAA0BC,OAA1B,QAAyC,OAAzC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,MAAT,QAAuB,kBAAvB;AAEA,OAAOC,qBAAP,MAAkC,yBAAlC;AAEA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,SAASC,WAAT,QAA4B,SAA5B;AACA,SAASC,oBAAT,EAA+BC,0BAA/B,QAAiE,SAAjE;AACA,SAASC,SAAT,QAA0B,WAA1B;AACA,SAASC,cAAT,QAA+B,cAA/B;AACA,SAASC,OAAT,QAAwB,eAAxB;AACA,SACEC,SADF,EAEEC,WAFF,EAGEC,YAHF,EAIEC,cAJF,QAKO,SALP;AAOA;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,WAAT,OAA0C;EAAA,IAAnBC,KAAmB,QAAnBA,KAAmB;EAAA,IAAZC,QAAY,QAAZA,QAAY;;EACvD,gBAA4BnB,QAAQ,CAACU,SAAS,EAAV,CAApC;EAAA;EAAA,IAAOU,MAAP;EAAA,IAAeC,SAAf;;EACA,iBAAkDrB,QAAQ,CAACQ,oBAAoB,EAArB,CAA1D;EAAA;EAAA,IAAOc,iBAAP;EAAA,IAA0BC,oBAA1B;;EACA,iBAA4BvB,QAAQ,CAACa,SAAS,EAAV,CAApC;EAAA;EAAA,IAAOW,MAAP;EAAA,IAAeC,SAAf;;EAEAlB,WAAW,CAACE,0BAAD,EAA6B,YAAM;IAC5Cc,oBAAoB,CAACf,oBAAoB,EAArB,CAApB;EACD,CAFU,CAAX;EAIAD,WAAW,CAACI,cAAD,EAAiB,YAAM;IAChCU,SAAS,CAACX,SAAS,EAAV,CAAT;EACD,CAFU,CAAX;EAIAH,WAAW,CAACS,cAAD,EAAiB,YAAM;IAChCS,SAAS,CAACZ,SAAS,EAAV,CAAT;EACD,CAFU,CAAX;EAIA,IAAMa,eAAe,GAAGzB,OAAO,CAAC;IAAA,OAAO;MAAEqB,iBAAiB,EAAjBA,iBAAF;MAAqBF,MAAM,EAANA,MAArB;MAA6BI,MAAM,EAANA;IAA7B,CAAP;EAAA,CAAD,EAAgD,CAACF,iBAAD,EAAoBF,MAApB,EAA4BI,MAA5B,CAAhD,CAA/B;EAEA,oBACE,oBAAC,YAAD;IAAc,MAAM,EAAEA,MAAtB;IAA8B,QAAQ,EAAEV,WAAW;EAAnD,gBACE,oBAAC,aAAD,qBACE,oBAAC,UAAD,CAAY,QAAZ;IACE,KAAK,EAAEY;EADT,gBAGE,oBAAC,qBAAD;IAAuB,KAAK,EAAER;EAA9B,gBACE,oBAAC,MAAD;IAAQ,OAAO,EAAEN;EAAjB,GACGO,QADH,CADF,CAHF,CADF,CADF,CADF;AAeD;AAEDF,WAAW,CAACU,SAAZ,GAAwB;EACtB;EACAT,KAAK,EAAEhB,SAAS,CAAC0B,MAFK;EAGtBT,QAAQ,EAAEjB,SAAS,CAAC2B,IAAV,CAAeC;AAHH,CAAxB;AAMAb,WAAW,CAACc,YAAZ,GAA2B;EACzBb,KAAK,EAAE;AADkB,CAA3B"}
|
package/react/ErrorBoundary.js
CHANGED
|
@@ -8,7 +8,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
8
8
|
|
|
9
9
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
10
|
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
12
|
|
|
13
13
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
14
|
|
|
@@ -18,7 +18,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
18
18
|
|
|
19
19
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
20
|
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
22
|
|
|
23
23
|
import React, { Component } from 'react';
|
|
24
24
|
import PropTypes from 'prop-types';
|
package/react/ErrorPage.js
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
16
|
-
|
|
17
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
|
|
19
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
|
|
23
|
-
import React, { Component } from 'react';
|
|
13
|
+
import React, { useState } from 'react';
|
|
24
14
|
import PropTypes from 'prop-types';
|
|
25
15
|
import { Button, Container, Row, Col } from '@edx/paragon';
|
|
26
|
-
import {
|
|
16
|
+
import { useAppEvent } from './hooks';
|
|
17
|
+
import { FormattedMessage, IntlProvider, getMessages, getLocale, LOCALE_CHANGED } from '../i18n';
|
|
27
18
|
/**
|
|
28
19
|
* An error page that displays a generic message for unexpected errors. Also contains a "Try
|
|
29
20
|
* Again" button to refresh the page.
|
|
@@ -32,52 +23,46 @@ import { FormattedMessage } from '../i18n';
|
|
|
32
23
|
* @extends {Component}
|
|
33
24
|
*/
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})))));
|
|
76
|
-
}
|
|
77
|
-
}]);
|
|
78
|
-
|
|
79
|
-
return ErrorPage;
|
|
80
|
-
}(Component);
|
|
26
|
+
function ErrorPage(_ref) {
|
|
27
|
+
var message = _ref.message;
|
|
28
|
+
|
|
29
|
+
var _useState = useState(getLocale()),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
locale = _useState2[0],
|
|
32
|
+
setLocale = _useState2[1];
|
|
33
|
+
|
|
34
|
+
useAppEvent(LOCALE_CHANGED, function () {
|
|
35
|
+
setLocale(getLocale());
|
|
36
|
+
});
|
|
37
|
+
/* istanbul ignore next */
|
|
38
|
+
|
|
39
|
+
var reload = function reload() {
|
|
40
|
+
global.location.reload();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/React.createElement(IntlProvider, {
|
|
44
|
+
locale: locale,
|
|
45
|
+
messages: getMessages()
|
|
46
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
47
|
+
fluid: true,
|
|
48
|
+
className: "py-5 justify-content-center align-items-start text-center"
|
|
49
|
+
}, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/React.createElement("p", {
|
|
50
|
+
className: "text-muted"
|
|
51
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
52
|
+
id: "unexpected.error.message.text",
|
|
53
|
+
defaultMessage: "An unexpected error occurred. Please click the button below to refresh the page.",
|
|
54
|
+
description: "error message when an unexpected error occurs"
|
|
55
|
+
})), message && /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
role: "alert",
|
|
57
|
+
className: "my-4"
|
|
58
|
+
}, /*#__PURE__*/React.createElement("p", null, message)), /*#__PURE__*/React.createElement(Button, {
|
|
59
|
+
onClick: reload
|
|
60
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
61
|
+
id: "unexpected.error.button.text",
|
|
62
|
+
defaultMessage: "Try again",
|
|
63
|
+
description: "text for button that tries to reload the app by refreshing the page"
|
|
64
|
+
}))))));
|
|
65
|
+
}
|
|
81
66
|
|
|
82
67
|
ErrorPage.propTypes = {
|
|
83
68
|
message: PropTypes.string
|
package/react/ErrorPage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorPage.js","names":["React","
|
|
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\nErr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AAC,WAFjB;IAGE,WAAW,EAAC;EAHd,EADF,CAbF,CADF,CADF,CADF,CADF;AA6BD;;AAEDJ,SAAS,CAACO,SAAV,GAAsB;EACpBN,OAAO,EAAEZ,SAAS,CAACmB;AADC,CAAtB;AAIAR,SAAS,CAACS,YAAV,GAAyB;EACvBR,OAAO,EAAE;AADc,CAAzB;AAIA,eAAeD,SAAf"}
|
|
@@ -11,7 +11,7 @@ export default function OptionalReduxProvider(_ref) {
|
|
|
11
11
|
children = _ref.children;
|
|
12
12
|
|
|
13
13
|
if (store === null) {
|
|
14
|
-
return
|
|
14
|
+
return children;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return /*#__PURE__*/React.createElement(Provider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionalReduxProvider.js","names":["React","PropTypes","Provider","OptionalReduxProvider","store","children","propTypes","object","node","isRequired","defaultProps"],"sources":["../../src/react/OptionalReduxProvider.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Provider } from 'react-redux';\n\n/**\n * @memberof module:React\n * @param {Object} props\n */\nexport default function OptionalReduxProvider({ store, children }) {\n if (store === null) {\n return
|
|
1
|
+
{"version":3,"file":"OptionalReduxProvider.js","names":["React","PropTypes","Provider","OptionalReduxProvider","store","children","propTypes","object","node","isRequired","defaultProps"],"sources":["../../src/react/OptionalReduxProvider.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Provider } from 'react-redux';\n\n/**\n * @memberof module:React\n * @param {Object} props\n */\nexport default function OptionalReduxProvider({ store, children }) {\n if (store === null) {\n return children;\n }\n\n return (\n <Provider store={store}>\n {children}\n </Provider>\n );\n}\n\nOptionalReduxProvider.propTypes = {\n store: PropTypes.object, // eslint-disable-line\n children: PropTypes.node.isRequired,\n};\n\nOptionalReduxProvider.defaultProps = {\n store: null,\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,QAAT,QAAyB,aAAzB;AAEA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,OAAoD;EAAA,IAAnBC,KAAmB,QAAnBA,KAAmB;EAAA,IAAZC,QAAY,QAAZA,QAAY;;EACjE,IAAID,KAAK,KAAK,IAAd,EAAoB;IAClB,OAAOC,QAAP;EACD;;EAED,oBACE,oBAAC,QAAD;IAAU,KAAK,EAAED;EAAjB,GACGC,QADH,CADF;AAKD;AAEDF,qBAAqB,CAACG,SAAtB,GAAkC;EAChCF,KAAK,EAAEH,SAAS,CAACM,MADe;EACP;EACzBF,QAAQ,EAAEJ,SAAS,CAACO,IAAV,CAAeC;AAFO,CAAlC;AAKAN,qBAAqB,CAACO,YAAtB,GAAqC;EACnCN,KAAK,EAAE;AAD4B,CAArC"}
|
package/react/PageRoute.js
CHANGED
|
@@ -20,7 +20,8 @@ export default function PageRoute(props) {
|
|
|
20
20
|
useEffect(function () {
|
|
21
21
|
if (match) {
|
|
22
22
|
sendPageEvent();
|
|
23
|
-
}
|
|
23
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
|
|
24
25
|
}, [JSON.stringify(match)]);
|
|
25
26
|
return /*#__PURE__*/React.createElement(Route, props);
|
|
26
27
|
}
|
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 }, [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
|
|
1
|
+
{"version":3,"file":"PageRoute.js","names":["React","useEffect","Route","useRouteMatch","sendPageEvent","PageRoute","props","match","path","exact","strict","sensitive","JSON","stringify"],"sources":["../../src/react/PageRoute.jsx"],"sourcesContent":["/* eslint-disable react/prop-types */\nimport React, { useEffect } from 'react';\nimport { Route, useRouteMatch } from 'react-router-dom';\nimport { sendPageEvent } from '../analytics';\n\n/**\n * A react-router Route component that calls `sendPageEvent` when it becomes active.\n *\n * @see {@link module:frontend-platform/analytics~sendPageEvent}\n * @memberof module:React\n * @param {Object} props\n */\nexport default function PageRoute(props) {\n const match = useRouteMatch({\n path: props.path,\n exact: props.exact,\n strict: props.strict,\n sensitive: props.sensitive,\n });\n\n useEffect(() => {\n if (match) {\n sendPageEvent();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(match)]);\n\n return (\n <Route {...props} />\n );\n}\n"],"mappings":"AAAA;AACA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,KAAT,EAAgBC,aAAhB,QAAqC,kBAArC;AACA,SAASC,aAAT,QAA8B,cAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,SAAT,CAAmBC,KAAnB,EAA0B;EACvC,IAAMC,KAAK,GAAGJ,aAAa,CAAC;IAC1BK,IAAI,EAAEF,KAAK,CAACE,IADc;IAE1BC,KAAK,EAAEH,KAAK,CAACG,KAFa;IAG1BC,MAAM,EAAEJ,KAAK,CAACI,MAHY;IAI1BC,SAAS,EAAEL,KAAK,CAACK;EAJS,CAAD,CAA3B;EAOAV,SAAS,CAAC,YAAM;IACd,IAAIM,KAAJ,EAAW;MACTH,aAAa;IACd,CAHa,CAIhB;;EACC,CALQ,EAKN,CAACQ,IAAI,CAACC,SAAL,CAAeN,KAAf,CAAD,CALM,CAAT;EAOA,oBACE,oBAAC,KAAD,EAAWD,KAAX,CADF;AAGD"}
|
package/react/hooks.js
CHANGED
package/react/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":["useEffect","subscribe","unsubscribe","useAppEvent","type","callback","subscriptionToken","cleanup"],"sources":["../../src/react/hooks.js"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { useEffect } from 'react';\nimport { subscribe, unsubscribe } from '../pubSub';\n\n/**\n * A React hook that allows functional components to subscribe to application events. This should\n * be used sparingly - for the most part, Context should be used higher-up in the application to\n * provide necessary data to a given component, rather than utilizing a non-React-like Pub/Sub\n * mechanism.\n *\n * @memberof module:React\n * @param {string} type\n * @param {function} callback\n */\nexport const useAppEvent = (type, callback) => {\n useEffect(() => {\n const subscriptionToken = subscribe(type, callback);\n\n return function cleanup() {\n unsubscribe(subscriptionToken);\n };\n }, []);\n};\n"],"mappings":"AAAA;AACA,SAASA,SAAT,QAA0B,OAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,WAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,IAAD,EAAOC,QAAP,EAAoB;EAC7CL,SAAS,CAAC,YAAM;IACd,IAAMM,iBAAiB,GAAGL,SAAS,CAACG,IAAD,EAAOC,QAAP,CAAnC;IAEA,OAAO,SAASE,OAAT,GAAmB;MACxBL,WAAW,CAACI,iBAAD,CAAX;IACD,CAFD;EAGD,CANQ,EAMN,
|
|
1
|
+
{"version":3,"file":"hooks.js","names":["useEffect","subscribe","unsubscribe","useAppEvent","type","callback","subscriptionToken","cleanup"],"sources":["../../src/react/hooks.js"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { useEffect } from 'react';\nimport { subscribe, unsubscribe } from '../pubSub';\n\n/**\n * A React hook that allows functional components to subscribe to application events. This should\n * be used sparingly - for the most part, Context should be used higher-up in the application to\n * provide necessary data to a given component, rather than utilizing a non-React-like Pub/Sub\n * mechanism.\n *\n * @memberof module:React\n * @param {string} type\n * @param {function} callback\n */\nexport const useAppEvent = (type, callback) => {\n useEffect(() => {\n const subscriptionToken = subscribe(type, callback);\n\n return function cleanup() {\n unsubscribe(subscriptionToken);\n };\n }, [callback, type]);\n};\n"],"mappings":"AAAA;AACA,SAASA,SAAT,QAA0B,OAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,WAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,IAAD,EAAOC,QAAP,EAAoB;EAC7CL,SAAS,CAAC,YAAM;IACd,IAAMM,iBAAiB,GAAGL,SAAS,CAACG,IAAD,EAAOC,QAAP,CAAnC;IAEA,OAAO,SAASE,OAAT,GAAmB;MACxBL,WAAW,CAACI,iBAAD,CAAX;IACD,CAFD;EAGD,CANQ,EAMN,CAACD,QAAD,EAAWD,IAAX,CANM,CAAT;AAOD,CARM"}
|