@modern-js/runtime-utils 2.65.4 → 2.65.5

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.
@@ -142,17 +142,22 @@ function cache(fn, options) {
142
142
  requestCache = /* @__PURE__ */ new Map();
143
143
  requestCacheMap.set(request, requestCache);
144
144
  }
145
+ let fnCache = requestCache.get(fn);
146
+ if (!fnCache) {
147
+ fnCache = /* @__PURE__ */ new Map();
148
+ requestCache.set(fn, fnCache);
149
+ }
145
150
  const key = generateKey(args);
146
- if (requestCache.has(key)) {
147
- return requestCache.get(key);
151
+ if (fnCache.has(key)) {
152
+ return fnCache.get(key);
148
153
  }
149
154
  const promise = fn(...args);
150
- requestCache.set(key, promise);
155
+ fnCache.set(key, promise);
151
156
  try {
152
157
  const data = await promise;
153
158
  return data;
154
159
  } catch (error) {
155
- requestCache.delete(key);
160
+ fnCache.delete(key);
156
161
  throw error;
157
162
  }
158
163
  }
@@ -130,7 +130,7 @@ function cache(fn, options) {
130
130
  return addTagFnRelation(t, fn);
131
131
  });
132
132
  return /* @__PURE__ */ _async_to_generator(function() {
133
- var _len, args, _key, _storage_useContext, storage, request, requestCache, key, promise, data, error, tagCache, key1, cached, now, age, data1;
133
+ var _len, args, _key, _storage_useContext, storage, request, requestCache, fnCache, key, promise, data, error, tagCache, key1, cached, now, age, data1;
134
134
  var _arguments = arguments;
135
135
  return _ts_generator(this, function(_state) {
136
136
  switch (_state.label) {
@@ -155,15 +155,20 @@ function cache(fn, options) {
155
155
  requestCache = /* @__PURE__ */ new Map();
156
156
  requestCacheMap.set(request, requestCache);
157
157
  }
158
+ fnCache = requestCache.get(fn);
159
+ if (!fnCache) {
160
+ fnCache = /* @__PURE__ */ new Map();
161
+ requestCache.set(fn, fnCache);
162
+ }
158
163
  key = generateKey(args);
159
- if (requestCache.has(key)) {
164
+ if (fnCache.has(key)) {
160
165
  return [
161
166
  2,
162
- requestCache.get(key)
167
+ fnCache.get(key)
163
168
  ];
164
169
  }
165
170
  promise = fn.apply(void 0, _to_consumable_array(args));
166
- requestCache.set(key, promise);
171
+ fnCache.set(key, promise);
167
172
  _state.label = 1;
168
173
  case 1:
169
174
  _state.trys.push([
@@ -184,7 +189,7 @@ function cache(fn, options) {
184
189
  ];
185
190
  case 3:
186
191
  error = _state.sent();
187
- requestCache.delete(key);
192
+ fnCache.delete(key);
188
193
  throw error;
189
194
  case 4:
190
195
  return [
@@ -112,17 +112,22 @@ function cache(fn, options) {
112
112
  requestCache = /* @__PURE__ */ new Map();
113
113
  requestCacheMap.set(request, requestCache);
114
114
  }
115
+ let fnCache = requestCache.get(fn);
116
+ if (!fnCache) {
117
+ fnCache = /* @__PURE__ */ new Map();
118
+ requestCache.set(fn, fnCache);
119
+ }
115
120
  const key = generateKey(args);
116
- if (requestCache.has(key)) {
117
- return requestCache.get(key);
121
+ if (fnCache.has(key)) {
122
+ return fnCache.get(key);
118
123
  }
119
124
  const promise = fn(...args);
120
- requestCache.set(key, promise);
125
+ fnCache.set(key, promise);
121
126
  try {
122
127
  const data = await promise;
123
128
  return data;
124
129
  } catch (error) {
125
- requestCache.delete(key);
130
+ fnCache.delete(key);
126
131
  throw error;
127
132
  }
128
133
  }
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.65.4",
18
+ "version": "2.65.5",
19
19
  "_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
20
20
  "exports": {
21
21
  "./router": {
@@ -91,8 +91,7 @@
91
91
  },
92
92
  "publishConfig": {
93
93
  "registry": "https://registry.npmjs.org/",
94
- "access": "public",
95
- "provenance": true
94
+ "access": "public"
96
95
  },
97
96
  "typesVersions": {
98
97
  "*": {
@@ -146,8 +145,8 @@
146
145
  "lru-cache": "^10.4.3",
147
146
  "react-router-dom": "6.27.0",
148
147
  "serialize-javascript": "^6.0.0",
149
- "@modern-js/types": "2.65.4",
150
- "@modern-js/utils": "2.65.4"
148
+ "@modern-js/utils": "2.65.5",
149
+ "@modern-js/types": "2.65.5"
151
150
  },
152
151
  "peerDependencies": {
153
152
  "react": ">=17.0.0",
@@ -169,8 +168,8 @@
169
168
  "react": "^18.3.1",
170
169
  "react-dom": "^18.3.1",
171
170
  "typescript": "^5",
172
- "@scripts/build": "2.65.4",
173
- "@scripts/jest-config": "2.65.4"
171
+ "@scripts/jest-config": "2.65.5",
172
+ "@scripts/build": "2.65.5"
174
173
  },
175
174
  "sideEffects": false,
176
175
  "scripts": {