@netlify/cache 1.9.0 → 1.10.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.
@@ -1,5 +1,5 @@
1
- import { E as EnvironmentOptions } from '../cache-BHHI9pin.cjs';
2
- export { N as NetlifyCache, O as Operation, R as RequestContextFactory } from '../cache-BHHI9pin.cjs';
1
+ import { E as EnvironmentOptions } from '../cache-Boq7iRAh.cjs';
2
+ export { N as NetlifyCache, O as Operation, R as RequestContextFactory } from '../cache-Boq7iRAh.cjs';
3
3
 
4
4
  declare class NetlifyCacheStorage {
5
5
  #private;
@@ -8,7 +8,7 @@ declare class NetlifyCacheStorage {
8
8
  has(name: string): Promise<boolean>;
9
9
  delete(name: string): Promise<boolean>;
10
10
  keys(): Promise<string[]>;
11
- match(request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
11
+ match(request: RequestInfo | URL, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
12
12
  }
13
13
 
14
14
  export { NetlifyCacheStorage };
@@ -1,5 +1,5 @@
1
- import { E as EnvironmentOptions } from '../cache-BHHI9pin.js';
2
- export { N as NetlifyCache, O as Operation, R as RequestContextFactory } from '../cache-BHHI9pin.js';
1
+ import { E as EnvironmentOptions } from '../cache-Boq7iRAh.js';
2
+ export { N as NetlifyCache, O as Operation, R as RequestContextFactory } from '../cache-Boq7iRAh.js';
3
3
 
4
4
  declare class NetlifyCacheStorage {
5
5
  #private;
@@ -8,7 +8,7 @@ declare class NetlifyCacheStorage {
8
8
  has(name: string): Promise<boolean>;
9
9
  delete(name: string): Promise<boolean>;
10
10
  keys(): Promise<string[]>;
11
- match(request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
11
+ match(request: RequestInfo | URL, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
12
12
  }
13
13
 
14
14
  export { NetlifyCacheStorage };
@@ -28,13 +28,13 @@ declare class NetlifyCache implements Cache {
28
28
  constructor({ getContext, name, userAgent }: NetlifyCacheOptions);
29
29
  private [getInternalHeaders];
30
30
  private [serializeResourceHeaders];
31
- add(request: RequestInfo): Promise<void>;
31
+ add(request: RequestInfo | URL): Promise<void>;
32
32
  addAll(requests: RequestInfo[]): Promise<void>;
33
- delete(request: RequestInfo): Promise<boolean>;
34
- keys(_request?: Request): Promise<never[]>;
35
- match(request: RequestInfo): Promise<Response | undefined>;
36
- matchAll(request?: RequestInfo, _options?: CacheQueryOptions): Promise<readonly Response[]>;
37
- put(request: RequestInfo | URL | string, response: Response): Promise<void>;
33
+ delete(request: RequestInfo | URL): Promise<boolean>;
34
+ keys(_request?: Request | URL): Promise<never[]>;
35
+ match(request: RequestInfo | URL): Promise<Response | undefined>;
36
+ matchAll(request?: RequestInfo | URL, _options?: CacheQueryOptions): Promise<readonly Response[]>;
37
+ put(request: RequestInfo | URL, response: Response): Promise<void>;
38
38
  }
39
39
 
40
40
  export { type EnvironmentOptions as E, NetlifyCache as N, Operation as O, type RequestContextFactory as R };
@@ -28,13 +28,13 @@ declare class NetlifyCache implements Cache {
28
28
  constructor({ getContext, name, userAgent }: NetlifyCacheOptions);
29
29
  private [getInternalHeaders];
30
30
  private [serializeResourceHeaders];
31
- add(request: RequestInfo): Promise<void>;
31
+ add(request: RequestInfo | URL): Promise<void>;
32
32
  addAll(requests: RequestInfo[]): Promise<void>;
33
- delete(request: RequestInfo): Promise<boolean>;
34
- keys(_request?: Request): Promise<never[]>;
35
- match(request: RequestInfo): Promise<Response | undefined>;
36
- matchAll(request?: RequestInfo, _options?: CacheQueryOptions): Promise<readonly Response[]>;
37
- put(request: RequestInfo | URL | string, response: Response): Promise<void>;
33
+ delete(request: RequestInfo | URL): Promise<boolean>;
34
+ keys(_request?: Request | URL): Promise<never[]>;
35
+ match(request: RequestInfo | URL): Promise<Response | undefined>;
36
+ matchAll(request?: RequestInfo | URL, _options?: CacheQueryOptions): Promise<readonly Response[]>;
37
+ put(request: RequestInfo | URL, response: Response): Promise<void>;
38
38
  }
39
39
 
40
40
  export { type EnvironmentOptions as E, NetlifyCache as N, Operation as O, type RequestContextFactory as R };
package/dist/main.cjs CHANGED
@@ -351,7 +351,12 @@ var fetchWithCache = async (request, optionsOrCacheSettings, cacheOptionsParam)
351
351
  if (onCachePut) {
352
352
  await onCachePut(cachePut);
353
353
  } else {
354
- await cachePut;
354
+ const requestContext = globalThis.Netlify?.context;
355
+ if (requestContext) {
356
+ requestContext.waitUntil(cachePut);
357
+ } else {
358
+ await cachePut;
359
+ }
355
360
  }
356
361
  return clientResponse;
357
362
  };
package/dist/main.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as NetlifyCache } from './cache-BHHI9pin.cjs';
1
+ import { N as NetlifyCache } from './cache-Boq7iRAh.cjs';
2
2
 
3
3
  /**
4
4
  * Polyfill for local development environments where `globalThis.caches` is not
package/dist/main.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as NetlifyCache } from './cache-BHHI9pin.js';
1
+ import { N as NetlifyCache } from './cache-Boq7iRAh.js';
2
2
 
3
3
  /**
4
4
  * Polyfill for local development environments where `globalThis.caches` is not
package/dist/main.js CHANGED
@@ -317,7 +317,12 @@ var fetchWithCache = async (request, optionsOrCacheSettings, cacheOptionsParam)
317
317
  if (onCachePut) {
318
318
  await onCachePut(cachePut);
319
319
  } else {
320
- await cachePut;
320
+ const requestContext = globalThis.Netlify?.context;
321
+ if (requestContext) {
322
+ requestContext.waitUntil(cachePut);
323
+ } else {
324
+ await cachePut;
325
+ }
321
326
  }
322
327
  return clientResponse;
323
328
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/cache",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "TypeScript utilities for interacting with the Netlify cache",
5
5
  "type": "module",
6
6
  "engines": {
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "author": "Netlify Inc.",
69
69
  "devDependencies": {
70
- "@netlify/dev-utils": "2.0.0",
70
+ "@netlify/dev-utils": "2.1.0",
71
71
  "npm-run-all2": "^7.0.2",
72
72
  "semver": "^7.5.3",
73
73
  "tmp-promise": "^3.0.3",
@@ -75,6 +75,6 @@
75
75
  "vitest": "^3.0.0"
76
76
  },
77
77
  "dependencies": {
78
- "@netlify/runtime-utils": "1.1.0"
78
+ "@netlify/runtime-utils": "1.2.0"
79
79
  }
80
80
  }