@void/isr 1.8.0 → 1.9.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/core.d.mts +1 -1
- package/dist/core.mjs +11 -4
- package/dist/runtime.d.mts +5 -1
- package/dist/runtime.mjs +5 -1
- package/package.json +2 -2
package/dist/core.d.mts
CHANGED
|
@@ -60,7 +60,7 @@ export declare function isStale(entry: IsrCacheEntry, now?: number): boolean;
|
|
|
60
60
|
export declare function isrCacheResponse(entry: IsrCacheEntry, stale: boolean, now?: number): Response;
|
|
61
61
|
/** Resolve an x-revalidate override, falling back for absent or invalid values. */
|
|
62
62
|
export declare function resolveRevalidateTtl(response: Response, defaultTtl: number): number;
|
|
63
|
-
/** Return whether credentials or
|
|
63
|
+
/** Return whether credentials or negotiated media types require an ISR bypass. */
|
|
64
64
|
export declare function shouldBypassIsr(request: Request): boolean;
|
|
65
65
|
/** Only document navigations may read a framework's shared HTML cache. */
|
|
66
66
|
export declare function isFrameworkDocumentRequest(request: Request): boolean;
|
package/dist/core.mjs
CHANGED
|
@@ -144,12 +144,19 @@ function resolveRevalidateTtl(response, defaultTtl) {
|
|
|
144
144
|
const value = Number.parseInt(header, 10);
|
|
145
145
|
return Number.isNaN(value) || value < 0 ? defaultTtl : value;
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Representations a single cached entry per path cannot hold: the entry stores
|
|
149
|
+
* one body, so a request that negotiates one of these reads must render live.
|
|
150
|
+
*/
|
|
151
|
+
const LIVE_ONLY_MEDIA_TYPES = ["text/event-stream", "text/markdown"];
|
|
152
|
+
function negotiatesLiveOnlyMediaType(request) {
|
|
153
|
+
const accept = request.headers.get("Accept")?.toLowerCase();
|
|
154
|
+
if (!accept) return false;
|
|
155
|
+
return accept.split(",").some((part) => LIVE_ONLY_MEDIA_TYPES.some((mediaType) => part.split(";", 1)[0]?.trim() === mediaType));
|
|
149
156
|
}
|
|
150
|
-
/** Return whether credentials or
|
|
157
|
+
/** Return whether credentials or negotiated media types require an ISR bypass. */
|
|
151
158
|
function shouldBypassIsr(request) {
|
|
152
|
-
return request.headers.has("Cookie") || request.headers.has("Authorization") || request.headers.has("Cf-Access-Jwt-Assertion") ||
|
|
159
|
+
return request.headers.has("Cookie") || request.headers.has("Authorization") || request.headers.has("Cf-Access-Jwt-Assertion") || negotiatesLiveOnlyMediaType(request);
|
|
153
160
|
}
|
|
154
161
|
/** Only document navigations may read a framework's shared HTML cache. */
|
|
155
162
|
function isFrameworkDocumentRequest(request) {
|
package/dist/runtime.d.mts
CHANGED
|
@@ -74,7 +74,11 @@ export declare function isEventStreamResponse(response: Response): boolean;
|
|
|
74
74
|
* cache errors are ignored.
|
|
75
75
|
*/
|
|
76
76
|
export declare function populateJsonEdgeCache(cache: Cache | undefined, cacheKey: string, response: Response, ttl: number, state: "HIT" | "MISS"): Promise<void>;
|
|
77
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Copy a request without its Pages protocol headers.
|
|
79
|
+
* @deprecated Unused by ISR. Preserve the original request when rendering so
|
|
80
|
+
* Pages negotiation remains intact. Removed in the next major version.
|
|
81
|
+
*/
|
|
78
82
|
export declare function cloneWithoutVoidPages(request: Request): Request;
|
|
79
83
|
/** Cache only framework document HTML; leave client data requests and other response types live. */
|
|
80
84
|
export declare function handleFrameworkIsr(request: Request, env: IsrCacheEnv, ctx: ExecutionContext, options: HandleIsrOptions, render: RenderFn): Promise<Response | null>;
|
package/dist/runtime.mjs
CHANGED
|
@@ -218,7 +218,11 @@ async function deleteSharedIsrVariants(env, cache, host, pathname, keys, variant
|
|
|
218
218
|
await safeCacheDelete(cache, keys.htmlKey);
|
|
219
219
|
await safeCacheDelete(cache, keys.jsonKey);
|
|
220
220
|
}
|
|
221
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Copy a request without its Pages protocol headers.
|
|
223
|
+
* @deprecated Unused by ISR. Preserve the original request when rendering so
|
|
224
|
+
* Pages negotiation remains intact. Removed in the next major version.
|
|
225
|
+
*/
|
|
222
226
|
function cloneWithoutVoidPages(request) {
|
|
223
227
|
const headers = new Headers(request.headers);
|
|
224
228
|
headers.delete("X-VoidPages");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/isr",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Incremental revalidation and cache helpers for Void runtimes.",
|
|
5
5
|
"homepage": "https://void.cloud",
|
|
6
6
|
"bugs": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@cloudflare/workers-types": "^5.20261110.1",
|
|
38
|
-
"@void/edge": "1.
|
|
38
|
+
"@void/edge": "1.9.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"typescript": "7.0.2",
|