@vinext/cloudflare 1.0.0-beta.8 → 1.0.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/README.md +174 -37
- package/dist/cache/cdn-adapter-config.d.ts +2 -1
- package/dist/cache/cdn-adapter-config.js +13 -5
- package/dist/cache/cdn-adapter.d.ts +5 -56
- package/dist/cache/cdn-adapter.js +3 -61
- package/dist/cache/cdn-adapter.runtime.d.ts +1 -0
- package/dist/cache/cdn-adapter.runtime.js +17 -3
- package/dist/cache/cdn-adapter.worker.d.ts +1 -0
- package/dist/cache/cdn-adapter.worker.js +6 -4
- package/dist/cache/cdn-build-id.d.ts +1 -1
- package/dist/cache/cdn-build-id.js +1 -1
- package/dist/cache/config.d.ts +137 -0
- package/dist/cache/config.js +87 -0
- package/dist/cache/kv-data-adapter.d.ts +5 -1
- package/dist/cache/kv-data-adapter.js +6 -2
- package/dist/cache/kv-data-adapter.runtime.js +13 -9
- package/dist/cache/kv-key.d.ts +7 -4
- package/dist/cache/kv-key.js +16 -5
- package/dist/cache/response-store-adapter.d.ts +36 -0
- package/dist/cache/response-store-adapter.js +26 -1
- package/dist/cache/response-store-adapter.self-contained.worker.d.ts +1 -0
- package/dist/cache/response-store-adapter.self-contained.worker.js +3 -1
- package/dist/cache/response-store-adapter.service-binding.worker.d.ts +1 -0
- package/dist/cache/response-store-adapter.service-binding.worker.js +3 -1
- package/dist/cache/response-store-adapter.worker.d.ts +1 -1
- package/dist/cache/response-store-adapter.worker.js +148 -81
- package/dist/cache/response-store-cdn.runtime.js +1 -0
- package/dist/cache/response-store-data.runtime.js +53 -31
- package/dist/cache/static-assets-adapter.build.d.ts +6 -0
- package/dist/cache/static-assets-adapter.build.js +65 -0
- package/dist/cache/static-assets-adapter.d.ts +27 -0
- package/dist/cache/static-assets-adapter.js +26 -0
- package/dist/cache/static-assets-adapter.runtime.d.ts +26 -0
- package/dist/cache/static-assets-adapter.runtime.js +77 -0
- package/dist/cache/static-assets-adapter.shared.d.ts +12 -0
- package/dist/cache/static-assets-adapter.shared.js +4 -0
- package/dist/cache/workers-cache-cdn-adapter.d.ts +58 -0
- package/dist/cache/workers-cache-cdn-adapter.js +65 -0
- package/dist/cacheability-artifact.d.ts +7 -1
- package/dist/cacheability-artifact.js +60 -21
- package/dist/cacheability-probe.d.ts +2 -0
- package/dist/cacheability-probe.js +107 -13
- package/dist/cdn-warm.d.ts +2 -1
- package/dist/cdn-warm.js +25 -8
- package/dist/deploy-config.d.ts +3 -8
- package/dist/deploy-config.js +5 -23
- package/dist/deploy-help.js +58 -47
- package/dist/deploy.d.ts +31 -21
- package/dist/deploy.js +501 -286
- package/dist/tpr.d.ts +29 -72
- package/dist/tpr.js +52 -601
- package/dist/version-deploy.d.ts +27 -0
- package/dist/version-deploy.js +125 -5
- package/dist/wrangler-config.d.ts +19 -0
- package/dist/wrangler-config.js +294 -0
- package/dist/wrangler-version-metadata.js +1 -1
- package/package.json +16 -9
- package/dist/prerender-kv-populate.d.ts +0 -24
- package/dist/prerender-kv-populate.js +0 -153
package/dist/tpr.d.ts
CHANGED
|
@@ -1,71 +1,36 @@
|
|
|
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
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;
|
|
12
|
+
/** Read domains from generated Build Output instead of a Wrangler config. */
|
|
13
|
+
typedConfig?: boolean;
|
|
32
14
|
/** Analytics lookback window in hours. Default: 24. */
|
|
33
15
|
window: number;
|
|
34
16
|
};
|
|
35
|
-
export type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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;
|
|
17
|
+
export type TPRRouteResult = {
|
|
18
|
+
routes: TrafficEntry[];
|
|
19
|
+
/** Custom-domain origin from typed Build Output for staged pre-warming. */
|
|
20
|
+
targetUrl?: string;
|
|
44
21
|
/** If TPR was skipped, the reason. */
|
|
45
22
|
skipped?: string;
|
|
46
23
|
};
|
|
47
|
-
type
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
headers: Record<string, string>;
|
|
24
|
+
export type TrafficEntry = {
|
|
25
|
+
path: string;
|
|
26
|
+
requests: number;
|
|
51
27
|
};
|
|
52
|
-
type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
legacyEnv?: boolean;
|
|
58
|
-
env?: Record<string, WranglerEnvironmentConfig>;
|
|
28
|
+
export type SelectedRoutes = {
|
|
29
|
+
routes: TrafficEntry[];
|
|
30
|
+
totalRequests: number;
|
|
31
|
+
coveredRequests: number;
|
|
32
|
+
coveragePercent: number;
|
|
59
33
|
};
|
|
60
|
-
export 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
|
-
export declare function parseWranglerConfig(root: string, configPath?: string): WranglerConfig | null;
|
|
69
34
|
/**
|
|
70
35
|
* Generate zone lookup candidates from shortest (2-part) to longest.
|
|
71
36
|
* Tries the most common case first (e.g., "example.com") and progressively
|
|
@@ -76,25 +41,17 @@ export declare function parseWranglerConfig(root: string, configPath?: string):
|
|
|
76
41
|
* "example.com" → ["example.com"]
|
|
77
42
|
*/
|
|
78
43
|
export declare function domainCandidates(domain: string): string[];
|
|
79
|
-
|
|
44
|
+
/** Filter out non-page requests (static assets, API routes, internal routes). */
|
|
45
|
+
export declare function filterTrafficPaths(entries: TrafficEntry[]): TrafficEntry[];
|
|
80
46
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* Key format matches the runtime KVCacheHandler exactly:
|
|
84
|
-
* createKvKeySpace().entryKey(isrCacheKey("app", pathname, buildId) + ":html")
|
|
85
|
-
* → "cache:app:<buildId>:<pathname>:html"
|
|
47
|
+
* Walk the ranked traffic list, accumulating request counts until the
|
|
48
|
+
* coverage target is met or the hard cap is reached.
|
|
86
49
|
*/
|
|
87
|
-
export declare function
|
|
88
|
-
key: string;
|
|
89
|
-
value: string;
|
|
90
|
-
expiration_ttl: number;
|
|
91
|
-
}>;
|
|
50
|
+
export declare function selectRoutes(traffic: TrafficEntry[], coverageTarget: number, limit: number): SelectedRoutes;
|
|
92
51
|
/**
|
|
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.
|
|
52
|
+
* Resolve ranked traffic paths. The standard CDN pre-warming flow owns route
|
|
53
|
+
* matching, coverage selection, rendering, and cache admission.
|
|
98
54
|
*/
|
|
99
|
-
export declare function
|
|
100
|
-
//#endregion
|
|
55
|
+
export declare function resolveTPRRoutes(options: TPROptions): Promise<TPRRouteResult>;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { parseWranglerConfig };
|