@netlify/cache 3.2.0 → 3.3.1

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/dist/main.cjs CHANGED
@@ -338,6 +338,7 @@ var fetchWithCache = async (requestOrURL, optionsOrCacheSettings, cacheOptionsPa
338
338
  if (cached) {
339
339
  return cached;
340
340
  }
341
+ const { fetch = globalThis.fetch } = cacheOptions;
341
342
  const fresh = await fetch(request);
342
343
  if (!fresh.body) {
343
344
  return fresh;
@@ -346,7 +347,8 @@ var fetchWithCache = async (requestOrURL, optionsOrCacheSettings, cacheOptionsPa
346
347
  const clientResponse = new Response(clientStream, fresh);
347
348
  const cacheResponse = new Response(cacheStream, fresh);
348
349
  applyHeaders(cacheResponse.headers, cacheHeaders(cacheSettings));
349
- const cachePut = cache.put(request, cacheResponse);
350
+ const cachePut = cache.put(request, cacheResponse).catch(() => {
351
+ });
350
352
  if (onCachePut) {
351
353
  await onCachePut(cachePut);
352
354
  } else {
package/dist/main.d.cts CHANGED
@@ -142,6 +142,10 @@ type CacheOptions = CacheSettings & {
142
142
  * set, a cache without a name (i.e. `""`) will be used.
143
143
  */
144
144
  cache?: NetlifyCache | string;
145
+ /**
146
+ * A custom `fetch` implementation to be used instead of the native one.
147
+ */
148
+ fetch?: typeof globalThis.fetch;
145
149
  /**
146
150
  * When `fetchWithCache` fetches a new response and adds it to the cache, the
147
151
  * `Promise` it returns waits for both the network call to finish and for the
package/dist/main.d.ts CHANGED
@@ -142,6 +142,10 @@ type CacheOptions = CacheSettings & {
142
142
  * set, a cache without a name (i.e. `""`) will be used.
143
143
  */
144
144
  cache?: NetlifyCache | string;
145
+ /**
146
+ * A custom `fetch` implementation to be used instead of the native one.
147
+ */
148
+ fetch?: typeof globalThis.fetch;
145
149
  /**
146
150
  * When `fetchWithCache` fetches a new response and adds it to the cache, the
147
151
  * `Promise` it returns waits for both the network call to finish and for the
package/dist/main.js CHANGED
@@ -303,6 +303,7 @@ var fetchWithCache = async (requestOrURL, optionsOrCacheSettings, cacheOptionsPa
303
303
  if (cached) {
304
304
  return cached;
305
305
  }
306
+ const { fetch = globalThis.fetch } = cacheOptions;
306
307
  const fresh = await fetch(request);
307
308
  if (!fresh.body) {
308
309
  return fresh;
@@ -311,7 +312,8 @@ var fetchWithCache = async (requestOrURL, optionsOrCacheSettings, cacheOptionsPa
311
312
  const clientResponse = new Response(clientStream, fresh);
312
313
  const cacheResponse = new Response(cacheStream, fresh);
313
314
  applyHeaders(cacheResponse.headers, cacheHeaders(cacheSettings));
314
- const cachePut = cache.put(request, cacheResponse);
315
+ const cachePut = cache.put(request, cacheResponse).catch(() => {
316
+ });
315
317
  if (onCachePut) {
316
318
  await onCachePut(cachePut);
317
319
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/cache",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
4
4
  "description": "TypeScript utilities for interacting with the Netlify cache",
5
5
  "type": "module",
6
6
  "engines": {
@@ -62,7 +62,11 @@
62
62
  "cachestorage"
63
63
  ],
64
64
  "license": "MIT",
65
- "repository": "netlify/primitives",
65
+ "repository": {
66
+ "type": "git",
67
+ "url": "https://github.com/netlify/primitives.git",
68
+ "directory": "packages/cache"
69
+ },
66
70
  "bugs": {
67
71
  "url": "https://github.com/netlify/primitives/issues"
68
72
  },
@@ -75,6 +79,6 @@
75
79
  "vitest": "^3.0.0"
76
80
  },
77
81
  "dependencies": {
78
- "@netlify/runtime-utils": "2.2.0"
82
+ "@netlify/runtime-utils": "2.2.1"
79
83
  }
80
84
  }