@void/isr 1.6.2 → 1.7.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.
- package/dist/core.mjs +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +8 -5
- package/package.json +4 -4
package/dist/core.mjs
CHANGED
|
@@ -167,7 +167,7 @@ function isFrameworkDocumentRequest(request) {
|
|
|
167
167
|
function hasSharedCacheOptOut(response) {
|
|
168
168
|
if (response.headers.get("Vary")?.split(",").some((name) => {
|
|
169
169
|
const header = name.trim().toLowerCase();
|
|
170
|
-
return header !== "" && header !== "x-voidpages";
|
|
170
|
+
return header !== "" && header !== "x-voidpages" && header !== "x-voidpages-version";
|
|
171
171
|
})) return true;
|
|
172
172
|
if (response.headers.has("Set-Cookie")) return true;
|
|
173
173
|
const cacheControl = response.headers.get("Cache-Control");
|
package/dist/runtime.d.mts
CHANGED
|
@@ -74,7 +74,7 @@ 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
|
-
/** Copy a request without its
|
|
77
|
+
/** Copy a request without its Pages protocol headers. */
|
|
78
78
|
export declare function cloneWithoutVoidPages(request: Request): Request;
|
|
79
79
|
/** Cache only framework document HTML; leave client data requests and other response types live. */
|
|
80
80
|
export declare function handleFrameworkIsr(request: Request, env: IsrCacheEnv, ctx: ExecutionContext, options: HandleIsrOptions, render: RenderFn): Promise<Response | null>;
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { canonicalIsrPathname, denormalizeIsrPath, isrCacheKey, isrCachePrefix, isrCacheVariantPrefix, isrEdgeCacheUrl, normalizeIsrPath } from "./index.mjs";
|
|
2
1
|
import { SHARED_CACHE_POLICY_HEADER, SHARED_CACHE_POLICY_VERSION, buildVariantOriginalUrl, decodeIsrCacheEntry, extractPageDataFromHtml, hasCurrentSharedCachePolicy, hasSharedCacheOptOut, hasUnlistedQueryParams, isFrameworkDocumentRequest, isSharedCacheableResponse, isStale, isrCacheResponse, markSharedCachePolicy, normalizePageDataForJsonCache, packIsrValue, resolvePageTtl, resolvePathTtl, resolveRevalidateTtl, serializeHeaders, shouldBypassIsr, unpackIsrValue } from "./core.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { canonicalIsrPathname, denormalizeIsrPath, isrCacheKey, isrCachePrefix, isrCacheVariantPrefix, isrEdgeCacheUrl, normalizeIsrPath } from "./index.mjs";
|
|
3
|
+
import { PAGES_PROTOCOL_VERSION, matchSegmentPattern } from "@void/edge";
|
|
4
4
|
// src/runtime.ts
|
|
5
5
|
const MAX_ISR_VARIANTS_PER_PATH = 200;
|
|
6
6
|
const ISR_STALE_EVICT_GRACE_MS = 864e5;
|
|
@@ -171,7 +171,8 @@ function jsonCacheResponse(pageData, ttl, state) {
|
|
|
171
171
|
const response = new Response(pageData, { headers: {
|
|
172
172
|
"content-type": "application/json",
|
|
173
173
|
"X-VoidPages": "true",
|
|
174
|
-
|
|
174
|
+
"X-VoidPages-Version": PAGES_PROTOCOL_VERSION,
|
|
175
|
+
Vary: "X-VoidPages, X-VoidPages-Version",
|
|
175
176
|
"Cache-Control": `public, s-maxage=${ttl}, max-age=0, must-revalidate`,
|
|
176
177
|
"x-isr-cache": state
|
|
177
178
|
} });
|
|
@@ -217,10 +218,11 @@ async function deleteSharedIsrVariants(env, cache, host, pathname, keys, variant
|
|
|
217
218
|
await safeCacheDelete(cache, keys.htmlKey);
|
|
218
219
|
await safeCacheDelete(cache, keys.jsonKey);
|
|
219
220
|
}
|
|
220
|
-
/** Copy a request without its
|
|
221
|
+
/** Copy a request without its Pages protocol headers. */
|
|
221
222
|
function cloneWithoutVoidPages(request) {
|
|
222
223
|
const headers = new Headers(request.headers);
|
|
223
224
|
headers.delete("X-VoidPages");
|
|
225
|
+
headers.delete("X-VoidPages-Version");
|
|
224
226
|
return new Request(request, { headers });
|
|
225
227
|
}
|
|
226
228
|
/**
|
|
@@ -288,6 +290,7 @@ async function handleIsrInternal(request, env, ctx, options, render, htmlOnly) {
|
|
|
288
290
|
const htmlKey = htmlEdgeKey(host, pathname, deploymentId, variantUrl);
|
|
289
291
|
const jsonKey = jsonEdgeKey(host, pathname, deploymentId, variantUrl);
|
|
290
292
|
if (request.headers.has("X-VoidPages")) {
|
|
293
|
+
if (request.headers.get("X-VoidPages-Version") !== PAGES_PROTOCOL_VERSION) return render(request);
|
|
291
294
|
let jsonCached;
|
|
292
295
|
try {
|
|
293
296
|
jsonCached = await cache?.match(jsonKey);
|
|
@@ -354,4 +357,4 @@ async function handleIsrInternal(request, env, ctx, options, render, htmlOnly) {
|
|
|
354
357
|
}, variantUrl));
|
|
355
358
|
return response;
|
|
356
359
|
}
|
|
357
|
-
export { MAX_ISR_VARIANTS_PER_PATH, SHARED_CACHE_POLICY_HEADER, SHARED_CACHE_POLICY_VERSION, canonicalIsrPathname, clientRevalidateResponse, cloneWithoutVoidPages, deleteIsrCache, denormalizeIsrPath, extractPageDataFromHtml, handleFrameworkIsr, handleIsr, hasCurrentSharedCachePolicy, hasSharedCacheOptOut, hostRegistryKey, htmlEdgeKey, isEventStreamResponse, isSharedCacheableResponse, isStale, isrCacheResponse, isrKey, isrPrefix, isrVariantPrefix, jsonEdgeKey, listIsrHosts, markSharedCachePolicy, matchLiteralPattern, normalizeIsrPath, normalizePageDataForJsonCache, packIsrValue, populateJsonEdgeCache, readIsrCache, resolvePathTtl, resolveRevalidateTtl, serializeHeaders, shouldBypassIsr, unpackIsrValue, writeIsrCache };
|
|
360
|
+
export { MAX_ISR_VARIANTS_PER_PATH, SHARED_CACHE_POLICY_HEADER, SHARED_CACHE_POLICY_VERSION, canonicalIsrPathname, clientRevalidateResponse, cloneWithoutVoidPages, deleteIsrCache, denormalizeIsrPath, extractPageDataFromHtml, handleFrameworkIsr, handleIsr, hasCurrentSharedCachePolicy, hasSharedCacheOptOut, hostRegistryKey, htmlEdgeKey, isEventStreamResponse, isSharedCacheableResponse, isStale, isrCacheResponse, isrKey, isrPrefix, isrVariantPrefix, jsonEdgeKey, listIsrHosts, markSharedCachePolicy, matchSegmentPattern as matchLiteralPattern, normalizeIsrPath, normalizePageDataForJsonCache, packIsrValue, populateJsonEdgeCache, readIsrCache, resolvePathTtl, resolveRevalidateTtl, serializeHeaders, shouldBypassIsr, unpackIsrValue, writeIsrCache };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/isr",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Incremental revalidation and cache helpers for Void runtimes.",
|
|
5
5
|
"homepage": "https://void.cloud",
|
|
6
6
|
"bugs": {
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@cloudflare/workers-types": "^5.
|
|
38
|
-
"@void/edge": "1.
|
|
37
|
+
"@cloudflare/workers-types": "^5.20261109.1",
|
|
38
|
+
"@void/edge": "1.7.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"typescript": "7.0.2",
|
|
42
|
-
"vite-plus": "1.
|
|
42
|
+
"vite-plus": "1.5.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "vp pack",
|