@edx/frontend-platform 1.15.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,13 +18,13 @@ export default function configureCache() {
18
18
  }
19
19
 
20
20
  function _configureCache() {
21
- _configureCache = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
21
+ _configureCache = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
22
22
  var forageStore;
23
- return regeneratorRuntime.wrap(function _callee$(_context) {
23
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
24
24
  while (1) {
25
- switch (_context.prev = _context.next) {
25
+ switch (_context2.prev = _context2.next) {
26
26
  case 0:
27
- _context.next = 2;
27
+ _context2.next = 2;
28
28
  return localforage.defineDriver(memoryDriver);
29
29
 
30
30
  case 2:
@@ -35,22 +35,50 @@ function _configureCache() {
35
35
  name: 'edx-cache'
36
36
  }); // Set up the cache with a default maxAge of 5 minutes and using localforage as the storage source
37
37
 
38
- return _context.abrupt("return", setup({
38
+ return _context2.abrupt("return", setup({
39
39
  cache: {
40
40
  maxAge: 5 * 60 * 1000,
41
41
  store: forageStore,
42
42
  exclude: {
43
43
  query: false
44
- }
44
+ },
45
+ invalidate: function () {
46
+ var _invalidate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(config, request) {
47
+ return regeneratorRuntime.wrap(function _callee$(_context) {
48
+ while (1) {
49
+ switch (_context.prev = _context.next) {
50
+ case 0:
51
+ if (!request.clearCacheEntry) {
52
+ _context.next = 3;
53
+ break;
54
+ }
55
+
56
+ _context.next = 3;
57
+ return config.store.removeItem(config.uuid);
58
+
59
+ case 3:
60
+ case "end":
61
+ return _context.stop();
62
+ }
63
+ }
64
+ }, _callee);
65
+ }));
66
+
67
+ function invalidate(_x, _x2) {
68
+ return _invalidate.apply(this, arguments);
69
+ }
70
+
71
+ return invalidate;
72
+ }()
45
73
  }
46
74
  }));
47
75
 
48
76
  case 4:
49
77
  case "end":
50
- return _context.stop();
78
+ return _context2.stop();
51
79
  }
52
80
  }
53
- }, _callee);
81
+ }, _callee2);
54
82
  }));
55
83
  return _configureCache.apply(this, arguments);
56
84
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/LocalForageCache.js"],"names":["localforage","memoryDriver","setup","configureCache","defineDriver","forageStore","createInstance","driver","INDEXEDDB","LOCALSTORAGE","_driver","name","cache","maxAge","store","exclude","query"],"mappings":";;;;AAAA;AACA,OAAOA,WAAP,MAAwB,aAAxB;AACA,OAAOC,YAAP,MAAyB,iCAAzB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,wBAA8BC,cAA9B;AAAA;AAAA;;;4EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAEPH,WAAW,CAACI,YAAZ,CAAyBH,YAAzB,CAFO;;AAAA;AAIb;AACMI,YAAAA,WALO,GAKOL,WAAW,CAACM,cAAZ,CAA2B;AAC7C;AACAC,cAAAA,MAAM,EAAE,CACNP,WAAW,CAACQ,SADN,EAENR,WAAW,CAACS,YAFN,EAGNR,YAAY,CAACS,OAHP,CAFqC;AAO7CC,cAAAA,IAAI,EAAE;AAPuC,aAA3B,CALP,EAeb;;AAfa,6CAgBNT,KAAK,CAAC;AACXU,cAAAA,KAAK,EAAE;AACLC,gBAAAA,MAAM,EAAE,IAAI,EAAJ,GAAS,IADZ;AAELC,gBAAAA,KAAK,EAAET,WAFF;AAGLU,gBAAAA,OAAO,EAAE;AAAEC,kBAAAA,KAAK,EAAE;AAAT;AAHJ;AADI,aAAD,CAhBC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["/* eslint-disable no-underscore-dangle */\nimport localforage from 'localforage';\nimport memoryDriver from 'localforage-memoryStorageDriver';\nimport { setup } from 'axios-cache-adapter';\n\n/**\n * Async function to configure localforage and setup the cache\n *\n * @returns {Promise} A promise that, when resolved, returns an axios instance configured to\n * use localforage as a cache.\n */\nexport default async function configureCache() {\n // Register the imported `memoryDriver` to `localforage`\n await localforage.defineDriver(memoryDriver);\n\n // Create `localforage` instance\n const forageStore = localforage.createInstance({\n // List of drivers used\n driver: [\n localforage.INDEXEDDB,\n localforage.LOCALSTORAGE,\n memoryDriver._driver,\n ],\n name: 'edx-cache',\n });\n\n // Set up the cache with a default maxAge of 5 minutes and using localforage as the storage source\n return setup({\n cache: {\n maxAge: 5 * 60 * 1000,\n store: forageStore,\n exclude: { query: false },\n },\n });\n}\n"],"file":"LocalForageCache.js"}
1
+ {"version":3,"sources":["../../src/auth/LocalForageCache.js"],"names":["localforage","memoryDriver","setup","configureCache","defineDriver","forageStore","createInstance","driver","INDEXEDDB","LOCALSTORAGE","_driver","name","cache","maxAge","store","exclude","query","invalidate","config","request","clearCacheEntry","removeItem","uuid"],"mappings":";;;;AAAA;AACA,OAAOA,WAAP,MAAwB,aAAxB;AACA,OAAOC,YAAP,MAAyB,iCAAzB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,wBAA8BC,cAA9B;AAAA;AAAA;;;4EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAEPH,WAAW,CAACI,YAAZ,CAAyBH,YAAzB,CAFO;;AAAA;AAIb;AACMI,YAAAA,WALO,GAKOL,WAAW,CAACM,cAAZ,CAA2B;AAC7C;AACAC,cAAAA,MAAM,EAAE,CACNP,WAAW,CAACQ,SADN,EAENR,WAAW,CAACS,YAFN,EAGNR,YAAY,CAACS,OAHP,CAFqC;AAO7CC,cAAAA,IAAI,EAAE;AAPuC,aAA3B,CALP,EAeb;;AAfa,8CAgBNT,KAAK,CAAC;AACXU,cAAAA,KAAK,EAAE;AACLC,gBAAAA,MAAM,EAAE,IAAI,EAAJ,GAAS,IADZ;AAELC,gBAAAA,KAAK,EAAET,WAFF;AAGLU,gBAAAA,OAAO,EAAE;AAAEC,kBAAAA,KAAK,EAAE;AAAT,iBAHJ;AAILC,gBAAAA,UAAU;AAAA,4FAAE,iBAAOC,MAAP,EAAeC,OAAf;AAAA;AAAA;AAAA;AAAA;AAAA,iCACNA,OAAO,CAACC,eADF;AAAA;AAAA;AAAA;;AAAA;AAAA,mCAEFF,MAAM,CAACJ,KAAP,CAAaO,UAAb,CAAwBH,MAAM,CAACI,IAA/B,CAFE;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAF;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAJL;AADI,aAAD,CAhBC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["/* eslint-disable no-underscore-dangle */\nimport localforage from 'localforage';\nimport memoryDriver from 'localforage-memoryStorageDriver';\nimport { setup } from 'axios-cache-adapter';\n\n/**\n * Async function to configure localforage and setup the cache\n *\n * @returns {Promise} A promise that, when resolved, returns an axios instance configured to\n * use localforage as a cache.\n */\nexport default async function configureCache() {\n // Register the imported `memoryDriver` to `localforage`\n await localforage.defineDriver(memoryDriver);\n\n // Create `localforage` instance\n const forageStore = localforage.createInstance({\n // List of drivers used\n driver: [\n localforage.INDEXEDDB,\n localforage.LOCALSTORAGE,\n memoryDriver._driver,\n ],\n name: 'edx-cache',\n });\n\n // Set up the cache with a default maxAge of 5 minutes and using localforage as the storage source\n return setup({\n cache: {\n maxAge: 5 * 60 * 1000,\n store: forageStore,\n exclude: { query: false },\n invalidate: async (config, request) => {\n if (request.clearCacheEntry) {\n await config.store.removeItem(config.uuid);\n }\n },\n },\n });\n}\n"],"file":"LocalForageCache.js"}
package/i18n/index.js CHANGED
@@ -19,65 +19,59 @@
19
19
  *
20
20
  * @module Internationalization
21
21
  * @see {@link https://github.com/edx/frontend-platform/blob/master/docs/how_tos/i18n.rst}
22
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md|React Intl} for components exported from this module.
22
+ * @see {@link https://formatjs.io/docs/react-intl/components/ Intl} for components exported from this module.
23
23
  *
24
24
  */
25
25
 
26
26
  /**
27
27
  * @name FormattedDate
28
28
  * @kind class
29
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formatteddate|React Intl}
29
+ * @see {@link https://formatjs.io/docs/react-intl/components/#formatteddate Intl}
30
30
  */
31
31
 
32
32
  /**
33
33
  * @name FormattedTime
34
34
  * @kind class
35
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formatteddate|React Intl}
35
+ * @see {@link https://formatjs.io/docs/react-intl/components/#formattedtime Intl}
36
36
  */
37
37
 
38
38
  /**
39
- * @name FormattedRelative
39
+ * @name FormattedRelativeTime
40
40
  * @kind class
41
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formattedrelative|React Intl}
41
+ * @see {@link https://formatjs.io/docs/react-intl/components/#formattedrelativetime Intl}
42
42
  */
43
43
 
44
44
  /**
45
45
  * @name FormattedNumber
46
46
  * @kind class
47
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formattednumber|React Intl}
47
+ * @see {@link https://formatjs.io/docs/react-intl/components/#formattednumber Intl}
48
48
  */
49
49
 
50
50
  /**
51
51
  * @name FormattedPlural
52
52
  * @kind class
53
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formattedplural|React Intl}
53
+ * @see {@link https://formatjs.io/docs/react-intl/components/#formattedplural Intl}
54
54
  */
55
55
 
56
56
  /**
57
57
  * @name FormattedMessage
58
58
  * @kind class
59
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formattedmessage|React Intl}
59
+ * @see {@link https://formatjs.io/docs/react-intl/components/#formattedmessage Intl}
60
60
  */
61
61
 
62
62
  /**
63
63
  * @name IntlProvider
64
64
  * @kind class
65
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#intlprovider|React Intl}
66
- */
67
-
68
- /**
69
- * @name intlShape
70
- * @kind constant
71
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/API.md#intlshape|React Intl}
65
+ * @see {@link https://formatjs.io/docs/react-intl/components/#intlprovider Intl}
72
66
  */
73
67
 
74
68
  /**
75
69
  * @name defineMessages
76
70
  * @kind function
77
- * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/API.md#definemessages|React Intl}
71
+ * @see {@link https://formatjs.io/docs/react-intl/api#definemessagesdefinemessage Intl}
78
72
  */
79
- export { intlShape, FormattedDate, FormattedTime, FormattedRelative, FormattedNumber, FormattedPlural, FormattedMessage, defineMessages, IntlProvider } from 'react-intl';
80
- export { configure, getPrimaryLanguageSubtag, getLocale, getMessages, isRtl, handleRtl, LOCALE_CHANGED, LOCALE_TOPIC } from './lib';
73
+ export { FormattedDate, FormattedTime, FormattedRelativeTime, FormattedNumber, FormattedPlural, FormattedMessage, defineMessages, IntlProvider } from 'react-intl';
74
+ export { intlShape, configure, getPrimaryLanguageSubtag, getLocale, getMessages, isRtl, handleRtl, LOCALE_CHANGED, LOCALE_TOPIC } from './lib';
81
75
  export { default as injectIntl } from './injectIntlWithShim';
82
76
  export { getCountryList, getCountryMessages } from './countries';
83
77
  export { getLanguageList, getLanguageMessages } from './languages';
package/i18n/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/i18n/index.js"],"names":["intlShape","FormattedDate","FormattedTime","FormattedRelative","FormattedNumber","FormattedPlural","FormattedMessage","defineMessages","IntlProvider","configure","getPrimaryLanguageSubtag","getLocale","getMessages","isRtl","handleRtl","LOCALE_CHANGED","LOCALE_TOPIC","default","injectIntl","getCountryList","getCountryMessages","getLanguageList","getLanguageMessages"],"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;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA,SACEA,SADF,EAEEC,aAFF,EAGEC,aAHF,EAIEC,iBAJF,EAKEC,eALF,EAMEC,eANF,EAOEC,gBAPF,EAQEC,cARF,EASEC,YATF,QAUO,YAVP;AAYA,SACEC,SADF,EAEEC,wBAFF,EAGEC,SAHF,EAIEC,WAJF,EAKEC,KALF,EAMEC,SANF,EAOEC,cAPF,EAQEC,YARF,QASO,OATP;AAWA,SACEC,OAAO,IAAIC,UADb,QAEO,sBAFP;AAIA,SACEC,cADF,EAEEC,kBAFF,QAGO,aAHP;AAKA,SACEC,eADF,EAEEC,mBAFF,QAGO,aAHP","sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform/i18n**\n * The i18n module relies on react-intl and re-exports all of that package's exports.\n *\n * For each locale we want to support, react-intl needs 1) the locale-data, which includes\n * information about how to format numbers, handle plurals, etc., and 2) the translations, as an\n * object holding message id / translated string pairs. A locale string and the messages object are\n * passed into the IntlProvider element that wraps your element hierarchy.\n *\n * Note that react-intl has no way of checking if the translations you give it actually have\n * anything to do with the locale you pass it; it will happily use whatever messages object you pass\n * in. However, if the locale data for the locale you passed into the IntlProvider was not\n * correctly installed with addLocaleData, all of your translations will fall back to the default\n * (in our case English), *even if you gave IntlProvider the correct messages object for that\n * locale*.\n *\n * Messages are provided to this module via the configure() function below.\n *\n *\n * @module Internationalization\n * @see {@link https://github.com/edx/frontend-platform/blob/master/docs/how_tos/i18n.rst}\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md|React Intl} for components exported from this module.\n *\n */\n\n/**\n * @name FormattedDate\n * @kind class\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formatteddate|React Intl}\n */\n\n/**\n * @name FormattedTime\n * @kind class\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formatteddate|React Intl}\n */\n\n/**\n * @name FormattedRelative\n * @kind class\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formattedrelative|React Intl}\n */\n\n/**\n * @name FormattedNumber\n * @kind class\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formattednumber|React Intl}\n */\n\n/**\n * @name FormattedPlural\n * @kind class\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formattedplural|React Intl}\n */\n\n/**\n * @name FormattedMessage\n * @kind class\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#formattedmessage|React Intl}\n */\n\n/**\n * @name IntlProvider\n * @kind class\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/Components.md#intlprovider|React Intl}\n */\n\n/**\n * @name intlShape\n * @kind constant\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/API.md#intlshape|React Intl}\n */\n\n/**\n * @name defineMessages\n * @kind function\n * @see {@link https://github.com/formatjs/react-intl/blob/master/docs/API.md#definemessages|React Intl}\n */\n\nexport {\n intlShape,\n FormattedDate,\n FormattedTime,\n FormattedRelative,\n FormattedNumber,\n FormattedPlural,\n FormattedMessage,\n defineMessages,\n IntlProvider,\n} from 'react-intl';\n\nexport {\n configure,\n getPrimaryLanguageSubtag,\n getLocale,\n getMessages,\n isRtl,\n handleRtl,\n LOCALE_CHANGED,\n LOCALE_TOPIC,\n} from './lib';\n\nexport {\n default as injectIntl,\n} from './injectIntlWithShim';\n\nexport {\n getCountryList,\n getCountryMessages,\n} from './countries';\n\nexport {\n getLanguageList,\n getLanguageMessages,\n} from './languages';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/i18n/index.js"],"names":["FormattedDate","FormattedTime","FormattedRelativeTime","FormattedNumber","FormattedPlural","FormattedMessage","defineMessages","IntlProvider","intlShape","configure","getPrimaryLanguageSubtag","getLocale","getMessages","isRtl","handleRtl","LOCALE_CHANGED","LOCALE_TOPIC","default","injectIntl","getCountryList","getCountryMessages","getLanguageList","getLanguageMessages"],"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;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA,SACEA,aADF,EAEEC,aAFF,EAGEC,qBAHF,EAIEC,eAJF,EAKEC,eALF,EAMEC,gBANF,EAOEC,cAPF,EAQEC,YARF,QASO,YATP;AAWA,SACEC,SADF,EAEEC,SAFF,EAGEC,wBAHF,EAIEC,SAJF,EAKEC,WALF,EAMEC,KANF,EAOEC,SAPF,EAQEC,cARF,EASEC,YATF,QAUO,OAVP;AAYA,SACEC,OAAO,IAAIC,UADb,QAEO,sBAFP;AAIA,SACEC,cADF,EAEEC,kBAFF,QAGO,aAHP;AAKA,SACEC,eADF,EAEEC,mBAFF,QAGO,aAHP","sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform/i18n**\n * The i18n module relies on react-intl and re-exports all of that package's exports.\n *\n * For each locale we want to support, react-intl needs 1) the locale-data, which includes\n * information about how to format numbers, handle plurals, etc., and 2) the translations, as an\n * object holding message id / translated string pairs. A locale string and the messages object are\n * passed into the IntlProvider element that wraps your element hierarchy.\n *\n * Note that react-intl has no way of checking if the translations you give it actually have\n * anything to do with the locale you pass it; it will happily use whatever messages object you pass\n * in. However, if the locale data for the locale you passed into the IntlProvider was not\n * correctly installed with addLocaleData, all of your translations will fall back to the default\n * (in our case English), *even if you gave IntlProvider the correct messages object for that\n * locale*.\n *\n * Messages are provided to this module via the configure() function below.\n *\n *\n * @module Internationalization\n * @see {@link https://github.com/edx/frontend-platform/blob/master/docs/how_tos/i18n.rst}\n * @see {@link https://formatjs.io/docs/react-intl/components/ Intl} for components exported from this module.\n *\n */\n\n/**\n * @name FormattedDate\n * @kind class\n * @see {@link https://formatjs.io/docs/react-intl/components/#formatteddate Intl}\n */\n\n/**\n * @name FormattedTime\n * @kind class\n * @see {@link https://formatjs.io/docs/react-intl/components/#formattedtime Intl}\n */\n\n/**\n * @name FormattedRelativeTime\n * @kind class\n * @see {@link https://formatjs.io/docs/react-intl/components/#formattedrelativetime Intl}\n */\n\n/**\n * @name FormattedNumber\n * @kind class\n * @see {@link https://formatjs.io/docs/react-intl/components/#formattednumber Intl}\n */\n\n/**\n * @name FormattedPlural\n * @kind class\n * @see {@link https://formatjs.io/docs/react-intl/components/#formattedplural Intl}\n */\n\n/**\n * @name FormattedMessage\n * @kind class\n * @see {@link https://formatjs.io/docs/react-intl/components/#formattedmessage Intl}\n */\n\n/**\n * @name IntlProvider\n * @kind class\n * @see {@link https://formatjs.io/docs/react-intl/components/#intlprovider Intl}\n */\n\n/**\n * @name defineMessages\n * @kind function\n * @see {@link https://formatjs.io/docs/react-intl/api#definemessagesdefinemessage Intl}\n */\n\nexport {\n FormattedDate,\n FormattedTime,\n FormattedRelativeTime,\n FormattedNumber,\n FormattedPlural,\n FormattedMessage,\n defineMessages,\n IntlProvider,\n} from 'react-intl';\n\nexport {\n intlShape,\n configure,\n getPrimaryLanguageSubtag,\n getLocale,\n getMessages,\n isRtl,\n handleRtl,\n LOCALE_CHANGED,\n LOCALE_TOPIC,\n} from './lib';\n\nexport {\n default as injectIntl,\n} from './injectIntlWithShim';\n\nexport {\n getCountryList,\n getCountryMessages,\n} from './countries';\n\nexport {\n getLanguageList,\n getLanguageMessages,\n} from './languages';\n"],"file":"index.js"}
@@ -23,8 +23,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
23
23
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
24
24
 
25
25
  import React from 'react';
26
- import { injectIntl, intlShape } from 'react-intl';
27
- import { getLoggingService } from './lib';
26
+ import { injectIntl } from 'react-intl';
27
+ import { getLoggingService, intlShape } from './lib';
28
28
  /**
29
29
  * This function wraps react-intl's injectIntl function in order to add error logging to the intl
30
30
  * property's formatMessage function.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/i18n/injectIntlWithShim.jsx"],"names":["React","injectIntl","intlShape","getLoggingService","injectIntlWithShim","WrappedComponent","ShimmedIntlComponent","props","shimmedIntl","Object","create","intl","formatMessage","value","definition","undefined","id","error","Error","process","env","NODE_ENV","console","logError","args","Component","propTypes","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,UAAT,EAAqBC,SAArB,QAAsC,YAAtC;AACA,SAASC,iBAAT,QAAkC,OAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,gBAAD,EAAsB;AAAA,MACzCC,oBADyC;AAAA;;AAAA;;AAE7C,kCAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,gCAAMA,KAAN;AACA,YAAKC,WAAL,GAAmBC,MAAM,CAACC,MAAP,CAAc,MAAKH,KAAL,CAAWI,IAAzB,EAA+B;AAChDC,QAAAA,aAAa,EAAE;AACbC,UAAAA,KAAK,EAAE,eAACC,UAAD,EAAyB;AAAA;;AAC9B,gBAAIA,UAAU,KAAKC,SAAf,IAA4BD,UAAU,CAACE,EAAX,KAAkBD,SAAlD,EAA6D;AAC3D,kBAAME,KAAK,GAAG,IAAIC,KAAJ,CAAU,sEAAV,CAAd;;AACA,kBAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzCC,gBAAAA,OAAO,CAACL,KAAR,CAAcA,KAAd,EADyC,CACnB;;AACtB,uBAAO,wDAAP;AACD;;AACDd,cAAAA,iBAAiB,GAAGoB,QAApB,CAA6BN,KAA7B;AACA,qBAAO,EAAP,CAP2D,CAOhD;AACZ;;AAT6B,8CAATO,IAAS;AAATA,cAAAA,IAAS;AAAA;;AAU9B,mBAAO,0BAAKjB,KAAL,CAAWI,IAAX,EAAgBC,aAAhB,0BAA8BE,UAA9B,SAA6CU,IAA7C,EAAP;AACD;AAZY;AADiC,OAA/B,CAAnB;AAFiB;AAkBlB;;AApB4C;AAAA;AAAA,aAsB7C,kBAAS;AACP,4BAAO,oBAAC,gBAAD,eAAsB,KAAKjB,KAA3B;AAAkC,UAAA,IAAI,EAAE,KAAKC;AAA7C,WAAP;AACD;AAxB4C;;AAAA;AAAA,IACZR,KAAK,CAACyB,SADM;;AA2B/CnB,EAAAA,oBAAoB,CAACoB,SAArB,GAAiC;AAC/Bf,IAAAA,IAAI,EAAET,SAAS,CAACyB;AADe,GAAjC;AAIA,SAAO1B,UAAU,CAACK,oBAAD,CAAjB;AACD,CAhCD;;AAkCA,eAAeF,kBAAf","sourcesContent":["import React from 'react';\nimport { injectIntl, intlShape } from 'react-intl';\nimport { getLoggingService } from './lib';\n\n/**\n * This function wraps react-intl's injectIntl function in order to add error logging to the intl\n * property's formatMessage function.\n *\n * @memberof I18n\n */\nconst injectIntlWithShim = (WrappedComponent) => {\n class ShimmedIntlComponent extends React.Component {\n constructor(props) {\n super(props);\n this.shimmedIntl = Object.create(this.props.intl, {\n formatMessage: {\n value: (definition, ...args) => {\n if (definition === undefined || definition.id === undefined) {\n const error = new Error('i18n error: An undefined message was supplied to intl.formatMessage.');\n if (process.env.NODE_ENV !== 'production') {\n console.error(error); // eslint-disable-line no-console\n return '!!! Missing message supplied to intl.formatMessage !!!';\n }\n getLoggingService().logError(error);\n return ''; // Fail silently in production\n }\n return this.props.intl.formatMessage(definition, ...args);\n },\n },\n });\n }\n\n render() {\n return <WrappedComponent {...this.props} intl={this.shimmedIntl} />;\n }\n }\n\n ShimmedIntlComponent.propTypes = {\n intl: intlShape.isRequired,\n };\n\n return injectIntl(ShimmedIntlComponent);\n};\n\nexport default injectIntlWithShim;\n"],"file":"injectIntlWithShim.js"}
1
+ {"version":3,"sources":["../../src/i18n/injectIntlWithShim.jsx"],"names":["React","injectIntl","getLoggingService","intlShape","injectIntlWithShim","WrappedComponent","ShimmedIntlComponent","props","shimmedIntl","Object","create","intl","formatMessage","value","definition","undefined","id","error","Error","process","env","NODE_ENV","console","logError","args","Component","propTypes","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,UAAT,QAA2B,YAA3B;AACA,SAASC,iBAAT,EAA4BC,SAA5B,QAA6C,OAA7C;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,gBAAD,EAAsB;AAAA,MACzCC,oBADyC;AAAA;;AAAA;;AAE7C,kCAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,gCAAMA,KAAN;AACA,YAAKC,WAAL,GAAmBC,MAAM,CAACC,MAAP,CAAc,MAAKH,KAAL,CAAWI,IAAzB,EAA+B;AAChDC,QAAAA,aAAa,EAAE;AACbC,UAAAA,KAAK,EAAE,eAACC,UAAD,EAAyB;AAAA;;AAC9B,gBAAIA,UAAU,KAAKC,SAAf,IAA4BD,UAAU,CAACE,EAAX,KAAkBD,SAAlD,EAA6D;AAC3D,kBAAME,KAAK,GAAG,IAAIC,KAAJ,CAAU,sEAAV,CAAd;;AACA,kBAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzCC,gBAAAA,OAAO,CAACL,KAAR,CAAcA,KAAd,EADyC,CACnB;;AACtB,uBAAO,wDAAP;AACD;;AACDf,cAAAA,iBAAiB,GAAGqB,QAApB,CAA6BN,KAA7B;AACA,qBAAO,EAAP,CAP2D,CAOhD;AACZ;;AAT6B,8CAATO,IAAS;AAATA,cAAAA,IAAS;AAAA;;AAU9B,mBAAO,0BAAKjB,KAAL,CAAWI,IAAX,EAAgBC,aAAhB,0BAA8BE,UAA9B,SAA6CU,IAA7C,EAAP;AACD;AAZY;AADiC,OAA/B,CAAnB;AAFiB;AAkBlB;;AApB4C;AAAA;AAAA,aAsB7C,kBAAS;AACP,4BAAO,oBAAC,gBAAD,eAAsB,KAAKjB,KAA3B;AAAkC,UAAA,IAAI,EAAE,KAAKC;AAA7C,WAAP;AACD;AAxB4C;;AAAA;AAAA,IACZR,KAAK,CAACyB,SADM;;AA2B/CnB,EAAAA,oBAAoB,CAACoB,SAArB,GAAiC;AAC/Bf,IAAAA,IAAI,EAAER,SAAS,CAACwB;AADe,GAAjC;AAIA,SAAO1B,UAAU,CAACK,oBAAD,CAAjB;AACD,CAhCD;;AAkCA,eAAeF,kBAAf","sourcesContent":["import React from 'react';\nimport { injectIntl } from 'react-intl';\nimport { getLoggingService, intlShape } from './lib';\n\n/**\n * This function wraps react-intl's injectIntl function in order to add error logging to the intl\n * property's formatMessage function.\n *\n * @memberof I18n\n */\nconst injectIntlWithShim = (WrappedComponent) => {\n class ShimmedIntlComponent extends React.Component {\n constructor(props) {\n super(props);\n this.shimmedIntl = Object.create(this.props.intl, {\n formatMessage: {\n value: (definition, ...args) => {\n if (definition === undefined || definition.id === undefined) {\n const error = new Error('i18n error: An undefined message was supplied to intl.formatMessage.');\n if (process.env.NODE_ENV !== 'production') {\n console.error(error); // eslint-disable-line no-console\n return '!!! Missing message supplied to intl.formatMessage !!!';\n }\n getLoggingService().logError(error);\n return ''; // Fail silently in production\n }\n return this.props.intl.formatMessage(definition, ...args);\n },\n },\n });\n }\n\n render() {\n return <WrappedComponent {...this.props} intl={this.shimmedIntl} />;\n }\n }\n\n ShimmedIntlComponent.propTypes = {\n intl: intlShape.isRequired,\n };\n\n return injectIntl(ShimmedIntlComponent);\n};\n\nexport default injectIntlWithShim;\n"],"file":"injectIntlWithShim.js"}
package/i18n/lib.js CHANGED
@@ -11,23 +11,38 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
11
11
  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; }
12
12
 
13
13
  import PropTypes from 'prop-types';
14
- import { addLocaleData } from 'react-intl';
15
- import arLocale from 'react-intl/locale-data/ar';
16
- import enLocale from 'react-intl/locale-data/en';
17
- import esLocale from 'react-intl/locale-data/es';
18
- import frLocale from 'react-intl/locale-data/fr';
19
- import zhLocale from 'react-intl/locale-data/zh';
20
- import caLocale from 'react-intl/locale-data/ca';
21
- import heLocale from 'react-intl/locale-data/he';
22
- import idLocale from 'react-intl/locale-data/id';
23
- import koLocale from 'react-intl/locale-data/ko';
24
- import plLocale from 'react-intl/locale-data/pl';
25
- import ptLocale from 'react-intl/locale-data/pt';
26
- import ruLocale from 'react-intl/locale-data/ru';
27
- import thLocale from 'react-intl/locale-data/th';
28
- import ukLocale from 'react-intl/locale-data/uk';
29
14
  import Cookies from 'universal-cookie';
30
15
  import merge from 'lodash.merge';
16
+ import '@formatjs/intl-pluralrules/polyfill';
17
+ import '@formatjs/intl-pluralrules/locale-data/ar';
18
+ import '@formatjs/intl-pluralrules/locale-data/en';
19
+ import '@formatjs/intl-pluralrules/locale-data/es';
20
+ import '@formatjs/intl-pluralrules/locale-data/fr';
21
+ import '@formatjs/intl-pluralrules/locale-data/zh';
22
+ import '@formatjs/intl-pluralrules/locale-data/ca';
23
+ import '@formatjs/intl-pluralrules/locale-data/he';
24
+ import '@formatjs/intl-pluralrules/locale-data/id';
25
+ import '@formatjs/intl-pluralrules/locale-data/ko';
26
+ import '@formatjs/intl-pluralrules/locale-data/pl';
27
+ import '@formatjs/intl-pluralrules/locale-data/pt';
28
+ import '@formatjs/intl-pluralrules/locale-data/ru';
29
+ import '@formatjs/intl-pluralrules/locale-data/th';
30
+ import '@formatjs/intl-pluralrules/locale-data/uk';
31
+ import '@formatjs/intl-relativetimeformat/polyfill';
32
+ import '@formatjs/intl-relativetimeformat/locale-data/ar';
33
+ import '@formatjs/intl-relativetimeformat/locale-data/en';
34
+ import '@formatjs/intl-relativetimeformat/locale-data/es';
35
+ import '@formatjs/intl-relativetimeformat/locale-data/fr';
36
+ import '@formatjs/intl-relativetimeformat/locale-data/zh';
37
+ import '@formatjs/intl-relativetimeformat/locale-data/ca';
38
+ import '@formatjs/intl-relativetimeformat/locale-data/he';
39
+ import '@formatjs/intl-relativetimeformat/locale-data/id';
40
+ import '@formatjs/intl-relativetimeformat/locale-data/ko';
41
+ import '@formatjs/intl-relativetimeformat/locale-data/pl';
42
+ import '@formatjs/intl-relativetimeformat/locale-data/pt';
43
+ import '@formatjs/intl-relativetimeformat/locale-data/ru';
44
+ import '@formatjs/intl-relativetimeformat/locale-data/th';
45
+ import '@formatjs/intl-relativetimeformat/locale-data/uk';
31
46
  var cookies = new Cookies();
32
47
  var supportedLocales = ['ar', // Arabic
33
48
  // NOTE: 'en' is not included in this list intentionally, since it's the fallback.
@@ -52,11 +67,22 @@ var rtlLocales = ['ar', // Arabic
52
67
  var config = null;
53
68
  var loggingService = null;
54
69
  var messages = null;
70
+ /**
71
+ * @memberof module:Internationalization
72
+ *
73
+ * Prior versions of react-intl (our primary implementation of the i18n service) included a
74
+ * PropTypes-based 'shape' for its `intl` object. This has since been removed. For legacy
75
+ * compatibility, we include an `intlShape` export that is set to PropTypes.object. Usage of this
76
+ * export is deprecated.
77
+ *
78
+ * @deprecated
79
+ */
80
+
81
+ export var intlShape = PropTypes.object;
55
82
  /**
56
83
  *
57
84
  * @ignore
58
85
  * @returns {LoggingService}
59
- *
60
86
  */
61
87
 
62
88
  export var getLoggingService = function getLoggingService() {
@@ -81,7 +107,6 @@ export var LOCALE_CHANGED = "".concat(LOCALE_TOPIC, ".CHANGED");
81
107
  export function getCookies() {
82
108
  return cookies;
83
109
  }
84
- addLocaleData([].concat(_toConsumableArray(arLocale), _toConsumableArray(enLocale), _toConsumableArray(esLocale), _toConsumableArray(frLocale), _toConsumableArray(zhLocale), _toConsumableArray(caLocale), _toConsumableArray(heLocale), _toConsumableArray(idLocale), _toConsumableArray(koLocale), _toConsumableArray(plLocale), _toConsumableArray(ptLocale), _toConsumableArray(ruLocale), _toConsumableArray(thLocale), _toConsumableArray(ukLocale)));
85
110
  /**
86
111
  * Some of our dependencies function on primary language subtags, rather than full locales.
87
112
  * This function strips a locale down to that first subtag. Depending on the code, this
package/i18n/lib.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/i18n/lib.js"],"names":["PropTypes","addLocaleData","arLocale","enLocale","esLocale","frLocale","zhLocale","caLocale","heLocale","idLocale","koLocale","plLocale","ptLocale","ruLocale","thLocale","ukLocale","Cookies","merge","cookies","supportedLocales","rtlLocales","config","loggingService","messages","getLoggingService","LOCALE_TOPIC","LOCALE_CHANGED","getCookies","getPrimaryLanguageSubtag","code","split","findSupportedLocale","locale","undefined","getLocale","Error","cookieLangPref","get","LANGUAGE_PREFERENCE_COOKIE_NAME","toLowerCase","global","navigator","language","getMessages","isRtl","includes","handleRtl","document","getElementsByTagName","setAttribute","messagesShape","ar","objectOf","string","en","fr","ca","he","id","pl","ru","th","uk","optionsShape","object","isRequired","shape","logError","func","oneOfType","arrayOf","mergeMessages","messagesArray","Array","isArray","configure","options","checkPropTypes","ENVIRONMENT","Object","keys","forEach","key","indexOf","console","warn"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,YAAtB;AACA,SAASC,aAAT,QAA8B,YAA9B;AACA,OAAOC,QAAP,MAAqB,2BAArB;AACA,OAAOC,QAAP,MAAqB,2BAArB;AACA,OAAOC,QAAP,MAAqB,2BAArB;AACA,OAAOC,QAAP,MAAqB,2BAArB;AACA,OAAOC,QAAP,MAAqB,2BAArB;AACA,OAAOC,QAAP,MAAqB,2BAArB;AACA,OAAOC,QAAP,MAAqB,2BAArB;AACA,OAAOC,QAAP,MA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,EAAI;AAChD,SAAOC,KAAK,CAACC,OAAN,CAAcF,aAAd,IAA+BvD,KAAK,MAAL,UAAM,EAAN,4BAAauD,aAAb,GAA/B,GAA6D,EAApE;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,SAAT,CAAmBC,OAAnB,EAA4B;AACjC5E,EAAAA,SAAS,CAAC6E,cAAV,CAAyBd,YAAzB,EAAuCa,OAAvC,EAAgD,UAAhD,EAA4D,MAA5D,EADiC,CAEjC;;AACAtD,EAAAA,cAAc,GAAGsD,OAAO,CAACtD,cAAzB,CAHiC,CAIjC;;AACAD,EAAAA,MAAM,GAAGuD,OAAO,CAACvD,MAAjB;AACAE,EAAAA,QAAQ,GAAGkD,KAAK,CAACC,OAAN,CAAcE,OAAO,CAACrD,QAAtB,IAAkCgD,aAAa,CAACK,OAAO,CAACrD,QAAT,CAA/C,GAAoEqD,OAAO,CAACrD,QAAvF;;AAEA,MAAIF,MAAM,CAACyD,WAAP,KAAuB,YAA3B,EAAyC;AACvCC,IAAAA,MAAM,CAACC,IAAP,CAAYzD,QAAZ,EAAsB0D,OAAtB,CAA8B,UAACC,GAAD,EAAS;AACrC,UAAI/D,gBAAgB,CAACgE,OAAjB,CAAyBD,GAAzB,IAAgC,CAApC,EAAuC;AACrCE,QAAAA,OAAO,CAACC,IAAR,8BAAmCH,GAAnC,GADqC,CACM;AAC5C;AACF,KAJD;AAMA/D,IAAAA,gBAAgB,CAAC8D,OAAjB,CAAyB,UAACC,GAAD,EAAS;AAChC,UAAI3D,QAAQ,CAAC2D,GAAD,CAAR,KAAkBjD,SAAtB,EAAiC;AAC/BmD,QAAAA,OAAO,CAACC,IAAR,2BAAgCH,GAAhC,GAD+B,CACS;AACzC;AACF,KAJD;AAKD;;AAEDpC,EAAAA,SAAS;AACV","sourcesContent":["import PropTypes from 'prop-types';\nimport { addLocaleData } from 'react-intl';\nimport arLocale from 'react-intl/locale-data/ar';\nimport enLocale from 'react-intl/locale-data/en';\nimport esLocale from 'react-intl/locale-data/es';\nimport frLocale from 'react-intl/locale-data/fr';\nimport zhLocale from 'react-intl/locale-data/zh';\nimport caLocale from 'react-intl/locale-data/ca';\nimport heLocale from 'react-intl/locale-data/he';\nimport idLocale from 'react-intl/locale-data/id';\nimport koLocale from 'react-intl/locale-data/ko';\nimport plLocale from 'react-intl/locale-data/pl';\nimport ptLocale from 'react-intl/locale-data/pt';\nimport ruLocale from 'react-intl/locale-data/ru';\nimport thLocale from 'react-intl/locale-data/th';\nimport ukLocale from 'react-intl/locale-data/uk';\nimport Cookies from 'universal-cookie';\nimport merge from 'lodash.merge';\n\nconst cookies = new Cookies();\nconst supportedLocales = [\n 'ar', // Arabic\n // NOTE: 'en' is not included in this list intentionally, since it's the fallback.\n 'es-419', // Spanish, Latin American\n 'fr', // French\n 'zh-cn', // Chinese, Simplified\n 'ca', // Catalan\n 'he', // Hebrew\n 'id', // Indonesian\n 'ko-kr', // Korean (Korea)\n 'pl', // Polish\n 'pt-br', // Portuguese (Brazil)\n 'ru', // Russian\n 'th', // Thai\n 'uk', // Ukrainian\n];\nconst rtlLocales = [\n 'ar', // Arabic\n 'he', // Hebrew\n 'fa', // Farsi (not currently supported)\n 'ur', // Urdu (not currently supported)\n];\n\nlet config = null;\nlet loggingService = null;\nlet messages = null;\n\n/**\n *\n * @ignore\n * @returns {LoggingService}\n *\n */\nexport const getLoggingService = () => loggingService;\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_TOPIC = 'LOCALE';\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_CHANGED = `${LOCALE_TOPIC}.CHANGED`;\n\n/**\n *\n * @memberof module:Internationalization\n * @returns {Cookies}\n */\nexport function getCookies() {\n return cookies;\n}\n\naddLocaleData([\n ...arLocale,\n ...enLocale,\n ...esLocale,\n ...frLocale,\n ...zhLocale,\n ...caLocale,\n ...heLocale,\n ...idLocale,\n ...koLocale,\n ...plLocale,\n ...ptLocale,\n ...ruLocale,\n ...thLocale,\n ...ukLocale,\n]);\n\n/**\n * Some of our dependencies function on primary language subtags, rather than full locales.\n * This function strips a locale down to that first subtag. Depending on the code, this\n * may be 2 or more characters.\n *\n * @param {string} code\n * @memberof module:Internationalization\n */\nexport function getPrimaryLanguageSubtag(code) {\n return code.split('-')[0];\n}\n\n/**\n * Finds the closest supported locale to the one provided. This is done in three steps:\n *\n * 1. Returning the locale itself if its exact language code is supported.\n * 2. Returning the primary language subtag of the language code if it is supported (ar for ar-eg,\n * for instance).\n * 3. Returning 'en' if neither of the above produce a supported locale.\n *\n * @param {string} locale\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function findSupportedLocale(locale) {\n if (messages[locale] !== undefined) {\n return locale;\n }\n\n if (messages[getPrimaryLanguageSubtag(locale)] !== undefined) {\n return getPrimaryLanguageSubtag(locale);\n }\n\n return 'en';\n}\n\n/**\n * Get the locale from the cookie or, failing that, the browser setting.\n * Gracefully fall back to a more general primary language subtag or to English (en)\n * if we don't support that language.\n *\n * @param {string} locale If a locale is provided, returns the closest supported locale. Optional.\n * @throws An error if i18n has not yet been configured.\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function getLocale(locale) {\n if (messages === null) {\n throw new Error('getLocale called before configuring i18n. Call configure with messages first.');\n }\n // 1. Explicit application request\n if (locale !== undefined) {\n return findSupportedLocale(locale);\n }\n // 2. User setting in cookie\n const cookieLangPref = cookies\n .get(config.LANGUAGE_PREFERENCE_COOKIE_NAME);\n if (cookieLangPref) {\n return findSupportedLocale(cookieLangPref.toLowerCase());\n }\n // 3. Browser language (default)\n // Note that some browers prefer upper case for the region part of the locale, while others don't.\n // Thus the toLowerCase, for consistency.\n // https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language\n return findSupportedLocale(global.navigator.language.toLowerCase());\n}\n\n/**\n * Returns messages for the provided locale, or the user's preferred locale if no argument is\n * provided.\n *\n * @param {string} [locale=getLocale()]\n * @memberof module:Internationalization\n */\nexport function getMessages(locale = getLocale()) {\n return messages[locale];\n}\n\n/**\n * Determines if the provided locale is a right-to-left language.\n *\n * @param {string} locale\n * @memberof module:Internationalization\n */\nexport function isRtl(locale) {\n return rtlLocales.includes(locale);\n}\n\n/**\n * Handles applying the RTL stylesheet and \"dir=rtl\" attribute to the html tag if the current locale\n * is a RTL language.\n *\n * @memberof module:Internationalization\n */\nexport function handleRtl() {\n if (isRtl(getLocale())) {\n global.document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl');\n } else {\n global.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr');\n }\n}\n\nconst messagesShape = {\n ar: PropTypes.objectOf(PropTypes.string), // Arabic\n en: PropTypes.objectOf(PropTypes.string),\n 'es-419': PropTypes.objectOf(PropTypes.string), // Spanish, Latin American\n fr: PropTypes.objectOf(PropTypes.string), // French\n 'zh-cn': PropTypes.objectOf(PropTypes.string), // Chinese, Simplified\n ca: PropTypes.objectOf(PropTypes.string), // Catalan\n he: PropTypes.objectOf(PropTypes.string), // Hebrew\n id: PropTypes.objectOf(PropTypes.string), // Indonesian\n 'ko-kr': PropTypes.objectOf(PropTypes.string), // Korean (Korea)\n pl: PropTypes.objectOf(PropTypes.string), // Polish\n 'pt-br': PropTypes.objectOf(PropTypes.string), // Portuguese (Brazil)\n ru: PropTypes.objectOf(PropTypes.string), // Russian\n th: PropTypes.objectOf(PropTypes.string), // Thai\n uk: PropTypes.objectOf(PropTypes.string), // Ukrainian\n};\n\nconst optionsShape = {\n config: PropTypes.object.isRequired,\n loggingService: PropTypes.shape({\n logError: PropTypes.func.isRequired,\n }).isRequired,\n messages: PropTypes.oneOfType([\n PropTypes.shape(messagesShape),\n PropTypes.arrayOf(PropTypes.shape(messagesShape)),\n ]).isRequired,\n};\n\n/**\n *\n *\n * @param {Array} [messagesArray=[]]\n * @returns {Object}\n * @memberof module:Internationalization\n */\nexport function mergeMessages(messagesArray = []) {\n return Array.isArray(messagesArray) ? merge({}, ...messagesArray) : {};\n}\n\n/**\n * Configures the i18n library with messages for your application.\n *\n * Logs a warning if it detects a locale it doesn't expect (as defined by the supportedLocales list\n * above), or if an expected locale is not provided.\n *\n * @param {Object} options\n * @param {LoggingService} options.loggingService\n * @param {Object} options.config\n * @param {Object} options.messages\n * @memberof module:Internationalization\n */\nexport function configure(options) {\n PropTypes.checkPropTypes(optionsShape, options, 'property', 'i18n');\n // eslint-disable-next-line prefer-destructuring\n loggingService = options.loggingService;\n // eslint-disable-next-line prefer-destructuring\n config = options.config;\n messages = Array.isArray(options.messages) ? mergeMessages(options.messages) : options.messages;\n\n if (config.ENVIRONMENT !== 'production') {\n Object.keys(messages).forEach((key) => {\n if (supportedLocales.indexOf(key) < 0) {\n console.warn(`Unexpected locale: ${key}`); // eslint-disable-line no-console\n }\n });\n\n supportedLocales.forEach((key) => {\n if (messages[key] === undefined) {\n console.warn(`Missing locale: ${key}`); // eslint-disable-line no-console\n }\n });\n }\n\n handleRtl();\n}\n"],"file":"lib.js"}
1
+ {"version":3,"sources":["../../src/i18n/lib.js"],"names":["PropTypes","Cookies","merge","cookies","supportedLocales","rtlLocales","config","loggingService","messages","intlShape","object","getLoggingService","LOCALE_TOPIC","LOCALE_CHANGED","getCookies","getPrimaryLanguageSubtag","code","split","findSupportedLocale","locale","undefined","getLocale","Error","cookieLangPref","get","LANGUAGE_PREFERENCE_COOKIE_NAME","toLowerCase","global","navigator","language","getMessages","isRtl","includes","handleRtl","document","getElementsByTagName","setAttribute","messagesShape","ar","objectOf","string","en","fr","ca","he","id","pl","ru","th","uk","optionsShape","isRequired","shape","logError","func","oneOfType","arrayOf","mergeMessages","messagesArray","Array","isArray","configure","options","checkPropTypes","ENVIRONMENT","Object","keys","forEach","key","indexOf","console","warn"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,YAAtB;AACA,OAAOC,OAAP,MAAoB,kBAApB;AACA,OAAOC,KAAP,MAAkB,cAAlB;AAEA,OAAO,qCAAP;AACA,OAAO,2CAAP;AACA,OAA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AACV","sourcesContent":["import PropTypes from 'prop-types';\nimport Cookies from 'universal-cookie';\nimport merge from 'lodash.merge';\n\nimport '@formatjs/intl-pluralrules/polyfill';\nimport '@formatjs/intl-pluralrules/locale-data/ar';\nimport '@formatjs/intl-pluralrules/locale-data/en';\nimport '@formatjs/intl-pluralrules/locale-data/es';\nimport '@formatjs/intl-pluralrules/locale-data/fr';\nimport '@formatjs/intl-pluralrules/locale-data/zh';\nimport '@formatjs/intl-pluralrules/locale-data/ca';\nimport '@formatjs/intl-pluralrules/locale-data/he';\nimport '@formatjs/intl-pluralrules/locale-data/id';\nimport '@formatjs/intl-pluralrules/locale-data/ko';\nimport '@formatjs/intl-pluralrules/locale-data/pl';\nimport '@formatjs/intl-pluralrules/locale-data/pt';\nimport '@formatjs/intl-pluralrules/locale-data/ru';\nimport '@formatjs/intl-pluralrules/locale-data/th';\nimport '@formatjs/intl-pluralrules/locale-data/uk';\n\nimport '@formatjs/intl-relativetimeformat/polyfill';\nimport '@formatjs/intl-relativetimeformat/locale-data/ar';\nimport '@formatjs/intl-relativetimeformat/locale-data/en';\nimport '@formatjs/intl-relativetimeformat/locale-data/es';\nimport '@formatjs/intl-relativetimeformat/locale-data/fr';\nimport '@formatjs/intl-relativetimeformat/locale-data/zh';\nimport '@formatjs/intl-relativetimeformat/locale-data/ca';\nimport '@formatjs/intl-relativetimeformat/locale-data/he';\nimport '@formatjs/intl-relativetimeformat/locale-data/id';\nimport '@formatjs/intl-relativetimeformat/locale-data/ko';\nimport '@formatjs/intl-relativetimeformat/locale-data/pl';\nimport '@formatjs/intl-relativetimeformat/locale-data/pt';\nimport '@formatjs/intl-relativetimeformat/locale-data/ru';\nimport '@formatjs/intl-relativetimeformat/locale-data/th';\nimport '@formatjs/intl-relativetimeformat/locale-data/uk';\n\nconst cookies = new Cookies();\nconst supportedLocales = [\n 'ar', // Arabic\n // NOTE: 'en' is not included in this list intentionally, since it's the fallback.\n 'es-419', // Spanish, Latin American\n 'fr', // French\n 'zh-cn', // Chinese, Simplified\n 'ca', // Catalan\n 'he', // Hebrew\n 'id', // Indonesian\n 'ko-kr', // Korean (Korea)\n 'pl', // Polish\n 'pt-br', // Portuguese (Brazil)\n 'ru', // Russian\n 'th', // Thai\n 'uk', // Ukrainian\n];\nconst rtlLocales = [\n 'ar', // Arabic\n 'he', // Hebrew\n 'fa', // Farsi (not currently supported)\n 'ur', // Urdu (not currently supported)\n];\n\nlet config = null;\nlet loggingService = null;\nlet messages = null;\n\n/**\n * @memberof module:Internationalization\n *\n * Prior versions of react-intl (our primary implementation of the i18n service) included a\n * PropTypes-based 'shape' for its `intl` object. This has since been removed. For legacy\n * compatibility, we include an `intlShape` export that is set to PropTypes.object. Usage of this\n * export is deprecated.\n *\n * @deprecated\n */\nexport const intlShape = PropTypes.object;\n\n/**\n *\n * @ignore\n * @returns {LoggingService}\n */\nexport const getLoggingService = () => loggingService;\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_TOPIC = 'LOCALE';\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_CHANGED = `${LOCALE_TOPIC}.CHANGED`;\n\n/**\n *\n * @memberof module:Internationalization\n * @returns {Cookies}\n */\nexport function getCookies() {\n return cookies;\n}\n\n/**\n * Some of our dependencies function on primary language subtags, rather than full locales.\n * This function strips a locale down to that first subtag. Depending on the code, this\n * may be 2 or more characters.\n *\n * @param {string} code\n * @memberof module:Internationalization\n */\nexport function getPrimaryLanguageSubtag(code) {\n return code.split('-')[0];\n}\n\n/**\n * Finds the closest supported locale to the one provided. This is done in three steps:\n *\n * 1. Returning the locale itself if its exact language code is supported.\n * 2. Returning the primary language subtag of the language code if it is supported (ar for ar-eg,\n * for instance).\n * 3. Returning 'en' if neither of the above produce a supported locale.\n *\n * @param {string} locale\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function findSupportedLocale(locale) {\n if (messages[locale] !== undefined) {\n return locale;\n }\n\n if (messages[getPrimaryLanguageSubtag(locale)] !== undefined) {\n return getPrimaryLanguageSubtag(locale);\n }\n\n return 'en';\n}\n\n/**\n * Get the locale from the cookie or, failing that, the browser setting.\n * Gracefully fall back to a more general primary language subtag or to English (en)\n * if we don't support that language.\n *\n * @param {string} locale If a locale is provided, returns the closest supported locale. Optional.\n * @throws An error if i18n has not yet been configured.\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function getLocale(locale) {\n if (messages === null) {\n throw new Error('getLocale called before configuring i18n. Call configure with messages first.');\n }\n // 1. Explicit application request\n if (locale !== undefined) {\n return findSupportedLocale(locale);\n }\n // 2. User setting in cookie\n const cookieLangPref = cookies\n .get(config.LANGUAGE_PREFERENCE_COOKIE_NAME);\n if (cookieLangPref) {\n return findSupportedLocale(cookieLangPref.toLowerCase());\n }\n // 3. Browser language (default)\n // Note that some browers prefer upper case for the region part of the locale, while others don't.\n // Thus the toLowerCase, for consistency.\n // https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language\n return findSupportedLocale(global.navigator.language.toLowerCase());\n}\n\n/**\n * Returns messages for the provided locale, or the user's preferred locale if no argument is\n * provided.\n *\n * @param {string} [locale=getLocale()]\n * @memberof module:Internationalization\n */\nexport function getMessages(locale = getLocale()) {\n return messages[locale];\n}\n\n/**\n * Determines if the provided locale is a right-to-left language.\n *\n * @param {string} locale\n * @memberof module:Internationalization\n */\nexport function isRtl(locale) {\n return rtlLocales.includes(locale);\n}\n\n/**\n * Handles applying the RTL stylesheet and \"dir=rtl\" attribute to the html tag if the current locale\n * is a RTL language.\n *\n * @memberof module:Internationalization\n */\nexport function handleRtl() {\n if (isRtl(getLocale())) {\n global.document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl');\n } else {\n global.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr');\n }\n}\n\nconst messagesShape = {\n ar: PropTypes.objectOf(PropTypes.string), // Arabic\n en: PropTypes.objectOf(PropTypes.string),\n 'es-419': PropTypes.objectOf(PropTypes.string), // Spanish, Latin American\n fr: PropTypes.objectOf(PropTypes.string), // French\n 'zh-cn': PropTypes.objectOf(PropTypes.string), // Chinese, Simplified\n ca: PropTypes.objectOf(PropTypes.string), // Catalan\n he: PropTypes.objectOf(PropTypes.string), // Hebrew\n id: PropTypes.objectOf(PropTypes.string), // Indonesian\n 'ko-kr': PropTypes.objectOf(PropTypes.string), // Korean (Korea)\n pl: PropTypes.objectOf(PropTypes.string), // Polish\n 'pt-br': PropTypes.objectOf(PropTypes.string), // Portuguese (Brazil)\n ru: PropTypes.objectOf(PropTypes.string), // Russian\n th: PropTypes.objectOf(PropTypes.string), // Thai\n uk: PropTypes.objectOf(PropTypes.string), // Ukrainian\n};\n\nconst optionsShape = {\n config: PropTypes.object.isRequired,\n loggingService: PropTypes.shape({\n logError: PropTypes.func.isRequired,\n }).isRequired,\n messages: PropTypes.oneOfType([\n PropTypes.shape(messagesShape),\n PropTypes.arrayOf(PropTypes.shape(messagesShape)),\n ]).isRequired,\n};\n\n/**\n *\n *\n * @param {Array} [messagesArray=[]]\n * @returns {Object}\n * @memberof module:Internationalization\n */\nexport function mergeMessages(messagesArray = []) {\n return Array.isArray(messagesArray) ? merge({}, ...messagesArray) : {};\n}\n\n/**\n * Configures the i18n library with messages for your application.\n *\n * Logs a warning if it detects a locale it doesn't expect (as defined by the supportedLocales list\n * above), or if an expected locale is not provided.\n *\n * @param {Object} options\n * @param {LoggingService} options.loggingService\n * @param {Object} options.config\n * @param {Object} options.messages\n * @memberof module:Internationalization\n */\nexport function configure(options) {\n PropTypes.checkPropTypes(optionsShape, options, 'property', 'i18n');\n // eslint-disable-next-line prefer-destructuring\n loggingService = options.loggingService;\n // eslint-disable-next-line prefer-destructuring\n config = options.config;\n messages = Array.isArray(options.messages) ? mergeMessages(options.messages) : options.messages;\n\n if (config.ENVIRONMENT !== 'production') {\n Object.keys(messages).forEach((key) => {\n if (supportedLocales.indexOf(key) < 0) {\n console.warn(`Unexpected locale: ${key}`); // eslint-disable-line no-console\n }\n });\n\n supportedLocales.forEach((key) => {\n if (messages[key] === undefined) {\n console.warn(`Missing locale: ${key}`); // eslint-disable-line no-console\n }\n });\n }\n\n handleRtl();\n}\n"],"file":"lib.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-platform",
3
- "version": "1.15.4",
3
+ "version": "2.0.0",
4
4
  "description": "Foundational application framework for Open edX micro-frontend applications.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -14,7 +14,8 @@
14
14
  "lint": "fedx-scripts eslint --ext .js --ext .jsx .",
15
15
  "snapshot": "fedx-scripts jest --updateSnapshot",
16
16
  "start": "fedx-scripts webpack-dev-server --progress",
17
- "test": "fedx-scripts jest --coverage"
17
+ "test": "fedx-scripts jest --coverage",
18
+ "test:watch": "npm run test -- --watch"
18
19
  },
19
20
  "bin": {
20
21
  "transifex-utils.js": "i18n/scripts/transifex-utils.js",
@@ -32,8 +33,8 @@
32
33
  "homepage": "https://github.com/edx/frontend-platform#readme",
33
34
  "devDependencies": {
34
35
  "@edx/brand": "npm:@edx/brand-openedx@1.1.0",
35
- "@edx/frontend-build": "9.1.2",
36
- "@edx/paragon": "19.10.1",
36
+ "@edx/frontend-build": "9.1.4",
37
+ "@edx/paragon": "19.19.0",
37
38
  "axios-mock-adapter": "1.20.0",
38
39
  "codecov": "3.8.3",
39
40
  "core-js": "3.21.1",
@@ -41,17 +42,19 @@
41
42
  "enzyme-adapter-react-16": "1.15.6",
42
43
  "husky": "7.0.4",
43
44
  "jsdoc": "3.6.10",
44
- "nodemon": "2.0.15",
45
+ "nodemon": "2.0.16",
45
46
  "prop-types": "15.8.1",
46
47
  "react": "16.14.0",
47
48
  "react-dom": "16.14.0",
48
- "react-redux": "7.2.6",
49
- "react-router-dom": "5.3.0",
49
+ "react-redux": "7.2.8",
50
+ "react-router-dom": "5.3.1",
50
51
  "redux": "4.1.2",
51
52
  "regenerator-runtime": "0.13.9"
52
53
  },
53
54
  "dependencies": {
54
55
  "@cospired/i18n-iso-languages": "2.2.0",
56
+ "@formatjs/intl-pluralrules": "^4.3.3",
57
+ "@formatjs/intl-relativetimeformat": "^10.0.1",
55
58
  "axios": "0.26.1",
56
59
  "axios-cache-adapter": "2.7.3",
57
60
  "form-urlencoded": "4.1.4",
@@ -59,14 +62,14 @@
59
62
  "history": "4.10.1",
60
63
  "i18n-iso-countries": "4.3.1",
61
64
  "jwt-decode": "3.1.2",
62
- "localforage": "1.9.0",
65
+ "localforage": "1.10.0",
63
66
  "localforage-memoryStorageDriver": "0.9.2",
64
67
  "lodash.camelcase": "4.3.0",
65
68
  "lodash.memoize": "4.1.2",
66
69
  "lodash.merge": "4.6.2",
67
70
  "lodash.snakecase": "4.1.1",
68
71
  "pubsub-js": "1.9.4",
69
- "react-intl": "2.9.0",
72
+ "react-intl": "^5.25.0",
70
73
  "universal-cookie": "4.0.4"
71
74
  },
72
75
  "peerDependencies": {
@@ -77,15 +77,15 @@ export default function AppProvider(_ref) {
77
77
  useAppEvent(LOCALE_CHANGED, function () {
78
78
  setLocale(getLocale());
79
79
  });
80
- return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(AppContext.Provider, {
80
+ return /*#__PURE__*/React.createElement(IntlProvider, {
81
+ locale: locale,
82
+ messages: getMessages()
83
+ }, /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(AppContext.Provider, {
81
84
  value: {
82
85
  authenticatedUser: authenticatedUser,
83
86
  config: config,
84
87
  locale: locale
85
88
  }
86
- }, /*#__PURE__*/React.createElement(IntlProvider, {
87
- locale: locale,
88
- messages: getMessages()
89
89
  }, /*#__PURE__*/React.createElement(OptionalReduxProvider, {
90
90
  store: store
91
91
  }, /*#__PURE__*/React.createElement(Router, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/AppProvider.jsx"],"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"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;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;AAAA,MAAnBC,KAAmB,QAAnBA,KAAmB;AAAA,MAAZC,QAAY,QAAZA,QAAY;;AACvD,kBAA4BlB,QAAQ,CAACS,SAAS,EAAV,CAApC;AAAA;AAAA,MAAOU,MAAP;AAAA,MAAeC,SAAf;;AACA,mBAAkDpB,QAAQ,CAACO,oBAAoB,EAArB,CAA1D;AAAA;AAAA,MAAOc,iBAAP;AAAA,MAA0BC,oBAA1B;;AACA,mBAA4BtB,QAAQ,CAACY,SAAS,EAAV,CAApC;AAAA;AAAA,MAAOW,MAAP;AAAA,MAAeC,SAAf;;AAEAlB,EAAAA,WAAW,CAACE,0BAAD,EAA6B,YAAM;AAC5Cc,IAAAA,oBAAoB,CAACf,oBAAoB,EAArB,CAApB;AACD,GAFU,CAAX;AAIAD,EAAAA,WAAW,CAACI,cAAD,EAAiB,YAAM;AAChCU,IAAAA,SAAS,CAACX,SAAS,EAAV,CAAT;AACD,GAFU,CAAX;AAIAH,EAAAA,WAAW,CAACS,cAAD,EAAiB,YAAM;AAChCS,IAAAA,SAAS,CAACZ,SAAS,EAAV,CAAT;AACD,GAFU,CAAX;AAIA,sBACE,oBAAC,aAAD,qBACE,oBAAC,UAAD,CAAY,QAAZ;AACE,IAAA,KAAK,EAAE;AAAES,MAAAA,iBAAiB,EAAjBA,iBAAF;AAAqBF,MAAAA,MAAM,EAANA,MAArB;AAA6BI,MAAAA,MAAM,EAANA;AAA7B;AADT,kBAGE,oBAAC,YAAD;AAAc,IAAA,MAAM,EAAEA,MAAtB;AAA8B,IAAA,QAAQ,EAAEV,WAAW;AAAnD,kBACE,oBAAC,qBAAD;AAAuB,IAAA,KAAK,EAAEI;AAA9B,kBACE,oBAAC,MAAD;AAAQ,IAAA,OAAO,EAAEN;AAAjB,kBACE,0CAAGO,QAAH,CADF,CADF,CADF,CAHF,CADF,CADF;AAeD;AAEDF,WAAW,CAACS,SAAZ,GAAwB;AACtB;AACAR,EAAAA,KAAK,EAAEhB,SAAS,CAACyB,MAFK;AAGtBR,EAAAA,QAAQ,EAAEjB,SAAS,CAAC0B,IAAV,CAAeC;AAHH,CAAxB;AAMAZ,WAAW,CAACa,YAAZ,GAA2B;AACzBZ,EAAAA,KAAK,EAAE;AADkB,CAA3B","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 <ErrorBoundary>\n <AppContext.Provider\n value={{ authenticatedUser, config, locale }}\n >\n <IntlProvider locale={locale} messages={getMessages()}>\n <OptionalReduxProvider store={store}>\n <Router history={history}>\n <>{children}</>\n </Router>\n </OptionalReduxProvider>\n </IntlProvider>\n </AppContext.Provider>\n </ErrorBoundary>\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"],"file":"AppProvider.js"}
1
+ {"version":3,"sources":["../../src/react/AppProvider.jsx"],"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"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;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;AAAA,MAAnBC,KAAmB,QAAnBA,KAAmB;AAAA,MAAZC,QAAY,QAAZA,QAAY;;AACvD,kBAA4BlB,QAAQ,CAACS,SAAS,EAAV,CAApC;AAAA;AAAA,MAAOU,MAAP;AAAA,MAAeC,SAAf;;AACA,mBAAkDpB,QAAQ,CAACO,oBAAoB,EAArB,CAA1D;AAAA;AAAA,MAAOc,iBAAP;AAAA,MAA0BC,oBAA1B;;AACA,mBAA4BtB,QAAQ,CAACY,SAAS,EAAV,CAApC;AAAA;AAAA,MAAOW,MAAP;AAAA,MAAeC,SAAf;;AAEAlB,EAAAA,WAAW,CAACE,0BAAD,EAA6B,YAAM;AAC5Cc,IAAAA,oBAAoB,CAACf,oBAAoB,EAArB,CAApB;AACD,GAFU,CAAX;AAIAD,EAAAA,WAAW,CAACI,cAAD,EAAiB,YAAM;AAChCU,IAAAA,SAAS,CAACX,SAAS,EAAV,CAAT;AACD,GAFU,CAAX;AAIAH,EAAAA,WAAW,CAACS,cAAD,EAAiB,YAAM;AAChCS,IAAAA,SAAS,CAACZ,SAAS,EAAV,CAAT;AACD,GAFU,CAAX;AAIA,sBACE,oBAAC,YAAD;AAAc,IAAA,MAAM,EAAEW,MAAtB;AAA8B,IAAA,QAAQ,EAAEV,WAAW;AAAnD,kBACE,oBAAC,aAAD,qBACE,oBAAC,UAAD,CAAY,QAAZ;AACE,IAAA,KAAK,EAAE;AAAEQ,MAAAA,iBAAiB,EAAjBA,iBAAF;AAAqBF,MAAAA,MAAM,EAANA,MAArB;AAA6BI,MAAAA,MAAM,EAANA;AAA7B;AADT,kBAGE,oBAAC,qBAAD;AAAuB,IAAA,KAAK,EAAEN;AAA9B,kBACE,oBAAC,MAAD;AAAQ,IAAA,OAAO,EAAEN;AAAjB,kBACE,0CAAGO,QAAH,CADF,CADF,CAHF,CADF,CADF,CADF;AAeD;AAEDF,WAAW,CAACS,SAAZ,GAAwB;AACtB;AACAR,EAAAA,KAAK,EAAEhB,SAAS,CAACyB,MAFK;AAGtBR,EAAAA,QAAQ,EAAEjB,SAAS,CAAC0B,IAAV,CAAeC;AAHH,CAAxB;AAMAZ,WAAW,CAACa,YAAZ,GAA2B;AACzBZ,EAAAA,KAAK,EAAE;AADkB,CAA3B","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={{ authenticatedUser, config, locale }}\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"],"file":"AppProvider.js"}