@netlify/cache 1.7.1 → 1.8.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 +55 -0
- package/dist/main.d.cts +15 -1
- package/dist/main.d.ts +15 -1
- package/dist/main.js +54 -0
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -25,12 +25,66 @@ __export(main_exports, {
|
|
|
25
25
|
MINUTE: () => MINUTE,
|
|
26
26
|
WEEK: () => WEEK,
|
|
27
27
|
YEAR: () => YEAR,
|
|
28
|
+
caches: () => caches,
|
|
28
29
|
fetchWithCache: () => fetchWithCache,
|
|
29
30
|
getCacheStatus: () => getCacheStatus,
|
|
30
31
|
setCacheHeaders: () => setCacheHeaders
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(main_exports);
|
|
33
34
|
|
|
35
|
+
// src/polyfill.ts
|
|
36
|
+
var NetlifyCacheStorageProxy = class {
|
|
37
|
+
async delete(name) {
|
|
38
|
+
if (globalThis.caches) {
|
|
39
|
+
return globalThis.caches.delete(name);
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
async has(name) {
|
|
44
|
+
if (globalThis.caches) {
|
|
45
|
+
return globalThis.caches.has(name);
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
async keys() {
|
|
50
|
+
if (globalThis.caches) {
|
|
51
|
+
return globalThis.caches.keys();
|
|
52
|
+
}
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
async match(request, options) {
|
|
56
|
+
if (globalThis.caches) {
|
|
57
|
+
return globalThis.caches.match(request, options);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async open(cacheName) {
|
|
61
|
+
if (globalThis.caches) {
|
|
62
|
+
return globalThis.caches.open(cacheName);
|
|
63
|
+
}
|
|
64
|
+
return new NetlifyNoopCache();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var NetlifyNoopCache = class {
|
|
68
|
+
async add(_) {
|
|
69
|
+
}
|
|
70
|
+
async addAll(_) {
|
|
71
|
+
}
|
|
72
|
+
async delete(_) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
async keys(_) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
async match(_) {
|
|
79
|
+
}
|
|
80
|
+
async matchAll(_) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
async put(_, __) {
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var caches = new NetlifyCacheStorageProxy();
|
|
87
|
+
|
|
34
88
|
// src/headers.ts
|
|
35
89
|
var CacheStatus = "cache-status";
|
|
36
90
|
var NetlifyCacheId = "netlify-cache-id";
|
|
@@ -309,6 +363,7 @@ var YEAR = 365 * DAY;
|
|
|
309
363
|
MINUTE,
|
|
310
364
|
WEEK,
|
|
311
365
|
YEAR,
|
|
366
|
+
caches,
|
|
312
367
|
fetchWithCache,
|
|
313
368
|
getCacheStatus,
|
|
314
369
|
setCacheHeaders
|
package/dist/main.d.cts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { N as NetlifyCache } from './cache-7af07baa.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Polyfill for local development environments where `globalThis.caches` is not
|
|
5
|
+
* available. It's a no-op cache. In production it will use the real one that
|
|
6
|
+
* has been set up in the environment by the bootstrap layer.
|
|
7
|
+
*/
|
|
8
|
+
declare class NetlifyCacheStorageProxy implements CacheStorage {
|
|
9
|
+
delete(name: string): Promise<boolean>;
|
|
10
|
+
has(name: string): Promise<boolean>;
|
|
11
|
+
keys(): Promise<string[]>;
|
|
12
|
+
match(request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
|
|
13
|
+
open(cacheName: string): Promise<Cache>;
|
|
14
|
+
}
|
|
15
|
+
declare const caches: NetlifyCacheStorageProxy;
|
|
16
|
+
|
|
3
17
|
interface CacheSettings {
|
|
4
18
|
/**
|
|
5
19
|
* Persist the response in the durable cache, shared across all CDN nodes.
|
|
@@ -174,4 +188,4 @@ declare const WEEK: number;
|
|
|
174
188
|
*/
|
|
175
189
|
declare const YEAR: number;
|
|
176
190
|
|
|
177
|
-
export { DAY, HOUR, MINUTE, WEEK, YEAR, fetchWithCache, getCacheStatus, setCacheHeaders };
|
|
191
|
+
export { DAY, HOUR, MINUTE, WEEK, YEAR, caches, fetchWithCache, getCacheStatus, setCacheHeaders };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { N as NetlifyCache } from './cache-7af07baa.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Polyfill for local development environments where `globalThis.caches` is not
|
|
5
|
+
* available. It's a no-op cache. In production it will use the real one that
|
|
6
|
+
* has been set up in the environment by the bootstrap layer.
|
|
7
|
+
*/
|
|
8
|
+
declare class NetlifyCacheStorageProxy implements CacheStorage {
|
|
9
|
+
delete(name: string): Promise<boolean>;
|
|
10
|
+
has(name: string): Promise<boolean>;
|
|
11
|
+
keys(): Promise<string[]>;
|
|
12
|
+
match(request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>;
|
|
13
|
+
open(cacheName: string): Promise<Cache>;
|
|
14
|
+
}
|
|
15
|
+
declare const caches: NetlifyCacheStorageProxy;
|
|
16
|
+
|
|
3
17
|
interface CacheSettings {
|
|
4
18
|
/**
|
|
5
19
|
* Persist the response in the durable cache, shared across all CDN nodes.
|
|
@@ -174,4 +188,4 @@ declare const WEEK: number;
|
|
|
174
188
|
*/
|
|
175
189
|
declare const YEAR: number;
|
|
176
190
|
|
|
177
|
-
export { DAY, HOUR, MINUTE, WEEK, YEAR, fetchWithCache, getCacheStatus, setCacheHeaders };
|
|
191
|
+
export { DAY, HOUR, MINUTE, WEEK, YEAR, caches, fetchWithCache, getCacheStatus, setCacheHeaders };
|
package/dist/main.js
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
+
// src/polyfill.ts
|
|
2
|
+
var NetlifyCacheStorageProxy = class {
|
|
3
|
+
async delete(name) {
|
|
4
|
+
if (globalThis.caches) {
|
|
5
|
+
return globalThis.caches.delete(name);
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
async has(name) {
|
|
10
|
+
if (globalThis.caches) {
|
|
11
|
+
return globalThis.caches.has(name);
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
async keys() {
|
|
16
|
+
if (globalThis.caches) {
|
|
17
|
+
return globalThis.caches.keys();
|
|
18
|
+
}
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
async match(request, options) {
|
|
22
|
+
if (globalThis.caches) {
|
|
23
|
+
return globalThis.caches.match(request, options);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async open(cacheName) {
|
|
27
|
+
if (globalThis.caches) {
|
|
28
|
+
return globalThis.caches.open(cacheName);
|
|
29
|
+
}
|
|
30
|
+
return new NetlifyNoopCache();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var NetlifyNoopCache = class {
|
|
34
|
+
async add(_) {
|
|
35
|
+
}
|
|
36
|
+
async addAll(_) {
|
|
37
|
+
}
|
|
38
|
+
async delete(_) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
async keys(_) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
async match(_) {
|
|
45
|
+
}
|
|
46
|
+
async matchAll(_) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
async put(_, __) {
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var caches = new NetlifyCacheStorageProxy();
|
|
53
|
+
|
|
1
54
|
// src/headers.ts
|
|
2
55
|
var CacheStatus = "cache-status";
|
|
3
56
|
var NetlifyCacheId = "netlify-cache-id";
|
|
@@ -275,6 +328,7 @@ export {
|
|
|
275
328
|
MINUTE,
|
|
276
329
|
WEEK,
|
|
277
330
|
YEAR,
|
|
331
|
+
caches,
|
|
278
332
|
fetchWithCache,
|
|
279
333
|
getCacheStatus,
|
|
280
334
|
setCacheHeaders
|