@edx/frontend-platform 2.6.2 → 2.7.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.
@@ -9,7 +9,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
9
9
  /* eslint-disable no-underscore-dangle */
10
10
  import localforage from 'localforage';
11
11
  import memoryDriver from 'localforage-memoryStorageDriver';
12
- import { setup } from 'axios-cache-adapter';
12
+ import { setupCache, defaultKeyGenerator, defaultHeaderInterpreter, buildStorage } from 'axios-cache-interceptor';
13
+ import axios from 'axios';
13
14
  /**
14
15
  * Async function to configure localforage and setup the cache
15
16
  *
@@ -22,13 +23,13 @@ export default function configureCache() {
22
23
  }
23
24
 
24
25
  function _configureCache() {
25
- _configureCache = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
26
- var forageStore;
27
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
26
+ _configureCache = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
27
+ var forageStore, forageStoreAdapter;
28
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
28
29
  while (1) {
29
- switch (_context2.prev = _context2.next) {
30
+ switch (_context4.prev = _context4.next) {
30
31
  case 0:
31
- _context2.next = 2;
32
+ _context4.next = 2;
32
33
  return localforage.defineDriver(memoryDriver);
33
34
 
34
35
  case 2:
@@ -37,52 +38,97 @@ function _configureCache() {
37
38
  // List of drivers used
38
39
  driver: [localforage.INDEXEDDB, localforage.LOCALSTORAGE, memoryDriver._driver],
39
40
  name: 'edx-cache'
40
- }); // Set up the cache with a default maxAge of 5 minutes and using localforage as the storage source
41
+ });
42
+ forageStoreAdapter = buildStorage({
43
+ find: function find(key) {
44
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
45
+ var result;
46
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
47
+ while (1) {
48
+ switch (_context.prev = _context.next) {
49
+ case 0:
50
+ _context.next = 2;
51
+ return forageStore.getItem("axios-cache:".concat(key));
41
52
 
42
- return _context2.abrupt("return", setup({
43
- cache: {
44
- maxAge: 5 * 60 * 1000,
45
- store: forageStore,
46
- exclude: {
47
- query: false
48
- },
49
- invalidate: function () {
50
- var _invalidate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, request) {
51
- return _regeneratorRuntime().wrap(function _callee$(_context) {
52
- while (1) {
53
- switch (_context.prev = _context.next) {
54
- case 0:
55
- if (!request.clearCacheEntry) {
56
- _context.next = 3;
57
- break;
58
- }
53
+ case 2:
54
+ result = _context.sent;
55
+ return _context.abrupt("return", JSON.parse(result));
59
56
 
60
- _context.next = 3;
61
- return config.store.removeItem(config.uuid);
62
-
63
- case 3:
64
- case "end":
65
- return _context.stop();
66
- }
57
+ case 4:
58
+ case "end":
59
+ return _context.stop();
67
60
  }
68
- }, _callee);
69
- }));
61
+ }
62
+ }, _callee);
63
+ }))();
64
+ },
65
+ set: function set(key, value) {
66
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
67
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
68
+ while (1) {
69
+ switch (_context2.prev = _context2.next) {
70
+ case 0:
71
+ _context2.next = 2;
72
+ return forageStore.setItem("axios-cache:".concat(key), JSON.stringify(value));
70
73
 
71
- function invalidate(_x, _x2) {
72
- return _invalidate.apply(this, arguments);
73
- }
74
+ case 2:
75
+ case "end":
76
+ return _context2.stop();
77
+ }
78
+ }
79
+ }, _callee2);
80
+ }))();
81
+ },
82
+ remove: function remove(key) {
83
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
84
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
85
+ while (1) {
86
+ switch (_context3.prev = _context3.next) {
87
+ case 0:
88
+ _context3.next = 2;
89
+ return forageStore.removeItem("axios-cache:".concat(key));
74
90
 
75
- return invalidate;
76
- }()
91
+ case 2:
92
+ case "end":
93
+ return _context3.stop();
94
+ }
95
+ }
96
+ }, _callee3);
97
+ }))();
77
98
  }
99
+ }); // only GET methods are cached by default
100
+
101
+ return _context4.abrupt("return", setupCache( // axios instance
102
+ axios.create(), {
103
+ ttl: 5 * 60 * 1000,
104
+ // default maxAge of 5 minutes
105
+ // The storage to save the cache data. There are more available by default.
106
+ //
107
+ // https://axios-cache-interceptor.js.org/#/pages/storages
108
+ storage: forageStoreAdapter,
109
+ // The mechanism to generate a unique key for each request.
110
+ //
111
+ // https://axios-cache-interceptor.js.org/#/pages/request-id
112
+ generateKey: defaultKeyGenerator,
113
+ // The mechanism to interpret headers (when cache.interpretHeader is true).
114
+ //
115
+ // https://axios-cache-interceptor.js.org/#/pages/global-configuration?id=headerinterpreter
116
+ headerInterpreter: defaultHeaderInterpreter,
117
+ // The function that will receive debug information.
118
+ // NOTE: For this to work, you need to enable development mode.
119
+ //
120
+ // https://axios-cache-interceptor.js.org/#/pages/development-mode
121
+ // https://axios-cache-interceptor.js.org/#/pages/global-configuration?id=debug
122
+ // eslint-disable-next-line no-console
123
+ debug: console.log
78
124
  }));
79
125
 
80
- case 4:
126
+ case 5:
81
127
  case "end":
82
- return _context2.stop();
128
+ return _context4.stop();
83
129
  }
84
130
  }
85
- }, _callee2);
131
+ }, _callee4);
86
132
  }));
87
133
  return _configureCache.apply(this, arguments);
88
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"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"],"sources":["../../src/auth/LocalForageCache.js"],"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"],"mappings":";;+CACA,oJ;;;;;;AADA;AACA,OAAOA,WAAP,MAAwB,aAAxB;AACA,OAAOC,YAAP,MAAyB,iCAAzB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,wBAA8BC,cAA9B;EAAA;AAAA;;;+EAAe;IAAA;IAAA;MAAA;QAAA;UAAA;YAAA;YAAA,OAEPH,WAAW,CAACI,YAAZ,CAAyBH,YAAzB,CAFO;;UAAA;YAIb;YACMI,WALO,GAKOL,WAAW,CAACM,cAAZ,CAA2B;cAC7C;cACAC,MAAM,EAAE,CACNP,WAAW,CAACQ,SADN,EAENR,WAAW,CAACS,YAFN,EAGNR,YAAY,CAACS,OAHP,CAFqC;cAO7CC,IAAI,EAAE;YAPuC,CAA3B,CALP,EAeb;;YAfa,kCAgBNT,KAAK,CAAC;cACXU,KAAK,EAAE;gBACLC,MAAM,EAAE,IAAI,EAAJ,GAAS,IADZ;gBAELC,KAAK,EAAET,WAFF;gBAGLU,OAAO,EAAE;kBAAEC,KAAK,EAAE;gBAAT,CAHJ;gBAILC,UAAU;kBAAA,6EAAE,iBAAOC,MAAP,EAAeC,OAAf;oBAAA;sBAAA;wBAAA;0BAAA;4BAAA,KACNA,OAAO,CAACC,eADF;8BAAA;8BAAA;4BAAA;;4BAAA;4BAAA,OAEFF,MAAM,CAACJ,KAAP,CAAaO,UAAb,CAAwBH,MAAM,CAACI,IAA/B,CAFE;;0BAAA;0BAAA;4BAAA;wBAAA;sBAAA;oBAAA;kBAAA,CAAF;;kBAAA;oBAAA;kBAAA;;kBAAA;gBAAA;cAJL;YADI,CAAD,CAhBC;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C"}
1
+ {"version":3,"file":"LocalForageCache.js","names":["localforage","memoryDriver","setupCache","defaultKeyGenerator","defaultHeaderInterpreter","buildStorage","axios","configureCache","defineDriver","forageStore","createInstance","driver","INDEXEDDB","LOCALSTORAGE","_driver","name","forageStoreAdapter","find","key","getItem","result","JSON","parse","set","value","setItem","stringify","remove","removeItem","create","ttl","storage","generateKey","headerInterpreter","debug","console","log"],"sources":["../../src/auth/LocalForageCache.js"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\nimport localforage from 'localforage';\nimport memoryDriver from 'localforage-memoryStorageDriver';\nimport {\n setupCache,\n defaultKeyGenerator,\n defaultHeaderInterpreter,\n buildStorage,\n} from 'axios-cache-interceptor';\nimport axios from 'axios';\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 const forageStoreAdapter = buildStorage({\n async find(key) {\n const result = await forageStore.getItem(`axios-cache:${key}`);\n return JSON.parse(result);\n },\n\n async set(key, value) {\n await forageStore.setItem(`axios-cache:${key}`, JSON.stringify(value));\n },\n\n async remove(key) {\n await forageStore.removeItem(`axios-cache:${key}`);\n },\n });\n\n // only GET methods are cached by default\n return setupCache(\n // axios instance\n axios.create(),\n {\n ttl: 5 * 60 * 1000, // default maxAge of 5 minutes\n // The storage to save the cache data. There are more available by default.\n //\n // https://axios-cache-interceptor.js.org/#/pages/storages\n storage: forageStoreAdapter,\n\n // The mechanism to generate a unique key for each request.\n //\n // https://axios-cache-interceptor.js.org/#/pages/request-id\n generateKey: defaultKeyGenerator,\n\n // The mechanism to interpret headers (when cache.interpretHeader is true).\n //\n // https://axios-cache-interceptor.js.org/#/pages/global-configuration?id=headerinterpreter\n headerInterpreter: defaultHeaderInterpreter,\n\n // The function that will receive debug information.\n // NOTE: For this to work, you need to enable development mode.\n //\n // https://axios-cache-interceptor.js.org/#/pages/development-mode\n // https://axios-cache-interceptor.js.org/#/pages/global-configuration?id=debug\n // eslint-disable-next-line no-console\n debug: console.log,\n },\n );\n}\n"],"mappings":";;+CACA,oJ;;;;;;AADA;AACA,OAAOA,WAAP,MAAwB,aAAxB;AACA,OAAOC,YAAP,MAAyB,iCAAzB;AACA,SACEC,UADF,EAEEC,mBAFF,EAGEC,wBAHF,EAIEC,YAJF,QAKO,yBALP;AAMA,OAAOC,KAAP,MAAkB,OAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,wBAA8BC,cAA9B;EAAA;AAAA;;;+EAAe;IAAA;IAAA;MAAA;QAAA;UAAA;YAAA;YAAA,OAEPP,WAAW,CAACQ,YAAZ,CAAyBP,YAAzB,CAFO;;UAAA;YAIb;YACMQ,WALO,GAKOT,WAAW,CAACU,cAAZ,CAA2B;cAC7C;cACAC,MAAM,EAAE,CACNX,WAAW,CAACY,SADN,EAENZ,WAAW,CAACa,YAFN,EAGNZ,YAAY,CAACa,OAHP,CAFqC;cAO7CC,IAAI,EAAE;YAPuC,CAA3B,CALP;YAePC,kBAfO,GAecX,YAAY,CAAC;cAChCY,IADgC,gBAC3BC,GAD2B,EACtB;gBAAA;kBAAA;kBAAA;oBAAA;sBAAA;wBAAA;0BAAA;0BAAA,OACOT,WAAW,CAACU,OAAZ,uBAAmCD,GAAnC,EADP;;wBAAA;0BACRE,MADQ;0BAAA,iCAEPC,IAAI,CAACC,KAAL,CAAWF,MAAX,CAFO;;wBAAA;wBAAA;0BAAA;sBAAA;oBAAA;kBAAA;gBAAA;cAGf,CAJqC;cAMhCG,GANgC,eAM5BL,GAN4B,EAMvBM,KANuB,EAMhB;gBAAA;kBAAA;oBAAA;sBAAA;wBAAA;0BAAA;0BAAA,OACdf,WAAW,CAACgB,OAAZ,uBAAmCP,GAAnC,GAA0CG,IAAI,CAACK,SAAL,CAAeF,KAAf,CAA1C,CADc;;wBAAA;wBAAA;0BAAA;sBAAA;oBAAA;kBAAA;gBAAA;cAErB,CARqC;cAUhCG,MAVgC,kBAUzBT,GAVyB,EAUpB;gBAAA;kBAAA;oBAAA;sBAAA;wBAAA;0BAAA;0BAAA,OACVT,WAAW,CAACmB,UAAZ,uBAAsCV,GAAtC,EADU;;wBAAA;wBAAA;0BAAA;sBAAA;oBAAA;kBAAA;gBAAA;cAEjB;YAZqC,CAAD,CAf1B,EA8Bb;;YA9Ba,kCA+BNhB,UAAU,EACf;YACAI,KAAK,CAACuB,MAAN,EAFe,EAGf;cACEC,GAAG,EAAE,IAAI,EAAJ,GAAS,IADhB;cACsB;cACpB;cACA;cACA;cACAC,OAAO,EAAEf,kBALX;cAOE;cACA;cACA;cACAgB,WAAW,EAAE7B,mBAVf;cAYE;cACA;cACA;cACA8B,iBAAiB,EAAE7B,wBAfrB;cAiBE;cACA;cACA;cACA;cACA;cACA;cACA8B,KAAK,EAAEC,OAAO,CAACC;YAvBjB,CAHe,CA/BJ;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-platform",
3
- "version": "2.6.2",
3
+ "version": "2.7.0",
4
4
  "description": "Foundational application framework for Open edX micro-frontend applications.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -31,6 +31,7 @@
31
31
  },
32
32
  "homepage": "https://github.com/edx/frontend-platform#readme",
33
33
  "devDependencies": {
34
+ "@edx/browserslist-config": "^1.1.0",
34
35
  "@edx/brand": "npm:@edx/brand-openedx@1.1.0",
35
36
  "@edx/frontend-build": "^12.0.3",
36
37
  "@edx/paragon": "20.2.0",
@@ -53,8 +54,8 @@
53
54
  "@cospired/i18n-iso-languages": "2.2.0",
54
55
  "@formatjs/intl-pluralrules": "4.3.3",
55
56
  "@formatjs/intl-relativetimeformat": "10.0.1",
56
- "axios": "0.26.1",
57
- "axios-cache-adapter": "2.7.3",
57
+ "axios": "0.27.2",
58
+ "axios-cache-interceptor": "0.10.7",
58
59
  "form-urlencoded": "4.1.4",
59
60
  "glob": "7.2.0",
60
61
  "history": "4.10.1",