@vinext/cloudflare 1.0.0-beta.7 → 1.0.0-beta.9
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/README.md +64 -22
- package/dist/cache/cdn-adapter-config.d.ts +16 -8
- package/dist/cache/cdn-adapter-config.js +57 -17
- package/dist/cache/cdn-adapter.d.ts +25 -24
- package/dist/cache/cdn-adapter.js +24 -20
- package/dist/cache/cdn-adapter.runtime.d.ts +9 -3
- package/dist/cache/cdn-adapter.runtime.js +63 -40
- package/dist/cache/cdn-adapter.worker.d.ts +31 -0
- package/dist/cache/cdn-adapter.worker.js +373 -0
- package/dist/cache/cdn-build-id.d.ts +4 -3
- package/dist/cache/cdn-build-id.js +5 -1
- package/dist/cache/kv-data-adapter.d.ts +25 -5
- package/dist/cache/kv-data-adapter.js +5 -1
- package/dist/cache/kv-data-adapter.runtime.d.ts +38 -4
- package/dist/cache/kv-data-adapter.runtime.js +115 -41
- package/dist/cache/kv-key.d.ts +4 -5
- package/dist/cache/response-store-adapter.d.ts +70 -0
- package/dist/cache/response-store-adapter.js +45 -0
- package/dist/cache/response-store-adapter.self-contained.worker.d.ts +18 -0
- package/dist/cache/response-store-adapter.self-contained.worker.js +12 -0
- package/dist/cache/response-store-adapter.service-binding.worker.d.ts +16 -0
- package/dist/cache/response-store-adapter.service-binding.worker.js +11 -0
- package/dist/cache/response-store-adapter.worker.d.ts +14 -0
- package/dist/cache/response-store-adapter.worker.js +264 -0
- package/dist/cache/response-store-cdn.runtime.d.ts +5 -0
- package/dist/cache/response-store-cdn.runtime.js +41 -0
- package/dist/cache/response-store-data.runtime.d.ts +34 -0
- package/dist/cache/response-store-data.runtime.js +289 -0
- package/dist/cacheability-artifact.d.ts +2 -3
- package/dist/cacheability-artifact.js +27 -1
- package/dist/cacheability-manifest-limits.d.ts +3 -4
- package/dist/cacheability-manifest-limits.js +1 -1
- package/dist/cacheability-probe.d.ts +8 -9
- package/dist/cacheability-probe.js +255 -91
- package/dist/cdn-warm.d.ts +31 -25
- package/dist/cdn-warm.js +228 -54
- package/dist/deploy-config.d.ts +11 -12
- package/dist/deploy-config.js +8 -3
- package/dist/deploy-help.d.ts +3 -4
- package/dist/deploy-help.js +20 -14
- package/dist/deploy.d.ts +35 -28
- package/dist/deploy.js +204 -95
- package/dist/images/images-optimizer.d.ts +3 -4
- package/dist/prerender-kv-populate.d.ts +3 -4
- package/dist/prerender-kv-populate.js +3 -2
- package/dist/tpr.d.ts +26 -74
- package/dist/tpr.js +45 -603
- package/dist/utils/cache-control-metadata.d.ts +3 -4
- package/dist/version-deploy.d.ts +17 -17
- package/dist/version-deploy.js +10 -5
- package/dist/worker-deployment-url.d.ts +3 -4
- package/dist/workers-dev-url.d.ts +2 -3
- package/dist/wrangler-config.d.ts +19 -0
- package/dist/wrangler-config.js +294 -0
- package/dist/wrangler-version-metadata.d.ts +2 -3
- package/package.json +13 -11
package/dist/tpr.d.ts
CHANGED
|
@@ -1,71 +1,32 @@
|
|
|
1
|
+
import { parseWranglerConfig } from "./wrangler-config.js";
|
|
1
2
|
//#region src/tpr.d.ts
|
|
2
|
-
|
|
3
|
-
* TPR: Traffic-aware Pre-Rendering
|
|
4
|
-
*
|
|
5
|
-
* Uses Cloudflare zone analytics to determine which pages actually get
|
|
6
|
-
* traffic, and pre-renders only those during deploy. The pre-rendered
|
|
7
|
-
* HTML is uploaded to KV in the same format ISR uses at runtime — no
|
|
8
|
-
* runtime changes needed.
|
|
9
|
-
*
|
|
10
|
-
* Flow:
|
|
11
|
-
* 1. Parse wrangler config to find custom domain and KV namespace
|
|
12
|
-
* 2. Resolve the Cloudflare zone for the custom domain
|
|
13
|
-
* 3. Query zone analytics (GraphQL) for top pages by request count
|
|
14
|
-
* 4. Walk ranked list until coverage threshold is met
|
|
15
|
-
* 5. Start the built production server locally
|
|
16
|
-
* 6. Fetch each hot route to produce HTML
|
|
17
|
-
* 7. Upload pre-rendered HTML to KV (same KVCacheEntry format ISR reads)
|
|
18
|
-
*
|
|
19
|
-
* TPR is an experimental feature enabled via --experimental-tpr. It
|
|
20
|
-
* gracefully skips when no custom domain, no API token, no traffic data,
|
|
21
|
-
* or no KV namespace is configured.
|
|
22
|
-
*/
|
|
23
|
-
type TPROptions = {
|
|
3
|
+
export type TPROptions = {
|
|
24
4
|
/** Project root directory. */
|
|
25
5
|
root: string;
|
|
26
6
|
/** Wrangler config path, relative to root unless absolute. */
|
|
27
7
|
config?: string;
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
|
|
8
|
+
/** Wrangler environment whose custom domain should be analyzed. */
|
|
9
|
+
env?: string;
|
|
10
|
+
/** Explicit domain used to resolve the analytics zone, overriding Wrangler routes. */
|
|
11
|
+
hostname?: string;
|
|
32
12
|
/** Analytics lookback window in hours. Default: 24. */
|
|
33
13
|
window: number;
|
|
34
14
|
};
|
|
35
|
-
type
|
|
36
|
-
|
|
37
|
-
totalPaths: number;
|
|
38
|
-
/** Number of pages successfully pre-rendered and uploaded. */
|
|
39
|
-
prerenderedCount: number;
|
|
40
|
-
/** Actual traffic coverage achieved (percentage). */
|
|
41
|
-
coverageAchieved: number;
|
|
42
|
-
/** Wall-clock duration of the TPR step in milliseconds. */
|
|
43
|
-
durationMs: number;
|
|
15
|
+
export type TPRRouteResult = {
|
|
16
|
+
routes: TrafficEntry[];
|
|
44
17
|
/** If TPR was skipped, the reason. */
|
|
45
18
|
skipped?: string;
|
|
46
19
|
};
|
|
47
|
-
type
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
headers: Record<string, string>;
|
|
20
|
+
export type TrafficEntry = {
|
|
21
|
+
path: string;
|
|
22
|
+
requests: number;
|
|
51
23
|
};
|
|
52
|
-
type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
legacyEnv?: boolean;
|
|
58
|
-
env?: Record<string, WranglerEnvironmentConfig>;
|
|
24
|
+
export type SelectedRoutes = {
|
|
25
|
+
routes: TrafficEntry[];
|
|
26
|
+
totalRequests: number;
|
|
27
|
+
coveredRequests: number;
|
|
28
|
+
coveragePercent: number;
|
|
59
29
|
};
|
|
60
|
-
type WranglerEnvironmentConfig = {
|
|
61
|
-
customDomain?: string;
|
|
62
|
-
name?: string;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Parse wrangler config (JSONC or TOML) to extract the fields TPR needs:
|
|
66
|
-
* account_id, VINEXT_KV_CACHE KV namespace ID, and custom domain.
|
|
67
|
-
*/
|
|
68
|
-
declare function parseWranglerConfig(root: string, configPath?: string): WranglerConfig | null;
|
|
69
30
|
/**
|
|
70
31
|
* Generate zone lookup candidates from shortest (2-part) to longest.
|
|
71
32
|
* Tries the most common case first (e.g., "example.com") and progressively
|
|
@@ -75,27 +36,18 @@ declare function parseWranglerConfig(root: string, configPath?: string): Wrangle
|
|
|
75
36
|
* "shop.example.co.uk" → ["co.uk", "example.co.uk", "shop.example.co.uk"]
|
|
76
37
|
* "example.com" → ["example.com"]
|
|
77
38
|
*/
|
|
78
|
-
declare function domainCandidates(domain: string): string[];
|
|
79
|
-
|
|
39
|
+
export declare function domainCandidates(domain: string): string[];
|
|
40
|
+
/** Filter out non-page requests (static assets, API routes, internal routes). */
|
|
41
|
+
export declare function filterTrafficPaths(entries: TrafficEntry[]): TrafficEntry[];
|
|
80
42
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* Key format matches the runtime KVCacheHandler exactly:
|
|
84
|
-
* createKvKeySpace().entryKey(isrCacheKey("app", pathname, buildId) + ":html")
|
|
85
|
-
* → "cache:app:<buildId>:<pathname>:html"
|
|
43
|
+
* Walk the ranked traffic list, accumulating request counts until the
|
|
44
|
+
* coverage target is met or the hard cap is reached.
|
|
86
45
|
*/
|
|
87
|
-
declare function
|
|
88
|
-
key: string;
|
|
89
|
-
value: string;
|
|
90
|
-
expiration_ttl: number;
|
|
91
|
-
}>;
|
|
46
|
+
export declare function selectRoutes(traffic: TrafficEntry[], coverageTarget: number, limit: number): SelectedRoutes;
|
|
92
47
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* Designed to be called between the build step and wrangler deploy in the
|
|
96
|
-
* `vinext-cloudflare deploy` pipeline. Gracefully skips (never errors) when
|
|
97
|
-
* the prerequisites aren't met.
|
|
48
|
+
* Resolve ranked traffic paths. The standard CDN pre-warming flow owns route
|
|
49
|
+
* matching, coverage selection, rendering, and cache admission.
|
|
98
50
|
*/
|
|
99
|
-
declare function
|
|
51
|
+
export declare function resolveTPRRoutes(options: TPROptions): Promise<TPRRouteResult>;
|
|
100
52
|
//#endregion
|
|
101
|
-
export {
|
|
53
|
+
export { parseWranglerConfig };
|