@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.
Files changed (56) hide show
  1. package/README.md +64 -22
  2. package/dist/cache/cdn-adapter-config.d.ts +16 -8
  3. package/dist/cache/cdn-adapter-config.js +57 -17
  4. package/dist/cache/cdn-adapter.d.ts +25 -24
  5. package/dist/cache/cdn-adapter.js +24 -20
  6. package/dist/cache/cdn-adapter.runtime.d.ts +9 -3
  7. package/dist/cache/cdn-adapter.runtime.js +63 -40
  8. package/dist/cache/cdn-adapter.worker.d.ts +31 -0
  9. package/dist/cache/cdn-adapter.worker.js +373 -0
  10. package/dist/cache/cdn-build-id.d.ts +4 -3
  11. package/dist/cache/cdn-build-id.js +5 -1
  12. package/dist/cache/kv-data-adapter.d.ts +25 -5
  13. package/dist/cache/kv-data-adapter.js +5 -1
  14. package/dist/cache/kv-data-adapter.runtime.d.ts +38 -4
  15. package/dist/cache/kv-data-adapter.runtime.js +115 -41
  16. package/dist/cache/kv-key.d.ts +4 -5
  17. package/dist/cache/response-store-adapter.d.ts +70 -0
  18. package/dist/cache/response-store-adapter.js +45 -0
  19. package/dist/cache/response-store-adapter.self-contained.worker.d.ts +18 -0
  20. package/dist/cache/response-store-adapter.self-contained.worker.js +12 -0
  21. package/dist/cache/response-store-adapter.service-binding.worker.d.ts +16 -0
  22. package/dist/cache/response-store-adapter.service-binding.worker.js +11 -0
  23. package/dist/cache/response-store-adapter.worker.d.ts +14 -0
  24. package/dist/cache/response-store-adapter.worker.js +264 -0
  25. package/dist/cache/response-store-cdn.runtime.d.ts +5 -0
  26. package/dist/cache/response-store-cdn.runtime.js +41 -0
  27. package/dist/cache/response-store-data.runtime.d.ts +34 -0
  28. package/dist/cache/response-store-data.runtime.js +289 -0
  29. package/dist/cacheability-artifact.d.ts +2 -3
  30. package/dist/cacheability-artifact.js +27 -1
  31. package/dist/cacheability-manifest-limits.d.ts +3 -4
  32. package/dist/cacheability-manifest-limits.js +1 -1
  33. package/dist/cacheability-probe.d.ts +8 -9
  34. package/dist/cacheability-probe.js +255 -91
  35. package/dist/cdn-warm.d.ts +31 -25
  36. package/dist/cdn-warm.js +228 -54
  37. package/dist/deploy-config.d.ts +11 -12
  38. package/dist/deploy-config.js +8 -3
  39. package/dist/deploy-help.d.ts +3 -4
  40. package/dist/deploy-help.js +20 -14
  41. package/dist/deploy.d.ts +35 -28
  42. package/dist/deploy.js +204 -95
  43. package/dist/images/images-optimizer.d.ts +3 -4
  44. package/dist/prerender-kv-populate.d.ts +3 -4
  45. package/dist/prerender-kv-populate.js +3 -2
  46. package/dist/tpr.d.ts +26 -74
  47. package/dist/tpr.js +45 -603
  48. package/dist/utils/cache-control-metadata.d.ts +3 -4
  49. package/dist/version-deploy.d.ts +17 -17
  50. package/dist/version-deploy.js +10 -5
  51. package/dist/worker-deployment-url.d.ts +3 -4
  52. package/dist/workers-dev-url.d.ts +2 -3
  53. package/dist/wrangler-config.d.ts +19 -0
  54. package/dist/wrangler-config.js +294 -0
  55. package/dist/wrangler-version-metadata.d.ts +2 -3
  56. package/package.json +13 -11
@@ -5,7 +5,6 @@
5
5
  * so the Cloudflare adapters stay self-contained (these mirror the equivalent
6
6
  * helpers in the vinext core).
7
7
  */
8
- declare function isUnknownRecord(value: unknown): value is Record<string, unknown>;
9
- declare function readCacheControlNumberField(ctx: Record<string, unknown> | undefined, field: string): number | undefined;
10
- //#endregion
11
- export { isUnknownRecord, readCacheControlNumberField };
8
+ export declare function isUnknownRecord(value: unknown): value is Record<string, unknown>;
9
+ export declare function readCacheControlNumberField(ctx: Record<string, unknown> | undefined, field: string): number | undefined;
10
+ //#endregion
@@ -2,21 +2,21 @@ import { parseWorkersDevUrl } from "./workers-dev-url.js";
2
2
  import { DeployOptions } from "./deploy.js";
3
3
  import { execFileSync } from "node:child_process";
4
4
  //#region src/version-deploy.d.ts
5
- type WranglerVersionUploadResult = {
5
+ export type WranglerVersionUploadResult = {
6
6
  versionId: string;
7
7
  previewUrl: string | null;
8
8
  workerName: string | null;
9
9
  output: string;
10
10
  };
11
- type WranglerVersionDeployResult = {
11
+ export type WranglerVersionDeployResult = {
12
12
  deployedUrl: string | null;
13
13
  output: string;
14
14
  };
15
- type WranglerVersionTraffic = {
15
+ export type WranglerVersionTraffic = {
16
16
  versionId: string;
17
17
  percentage: number;
18
18
  };
19
- type WranglerDeploymentStatus = {
19
+ export type WranglerDeploymentStatus = {
20
20
  deploymentId: string | null;
21
21
  versions: WranglerVersionTraffic[];
22
22
  output: string;
@@ -25,21 +25,21 @@ type WranglerVersionArgs = {
25
25
  args: string[];
26
26
  env: string | undefined;
27
27
  };
28
- declare function parseVersionId(output: string): string | null;
29
- declare function parseUploadedWorkerName(output: string): string | null;
30
- declare function parseWranglerVersionUploadOutput(output: string): WranglerVersionUploadResult;
31
- declare function buildWranglerVersionUploadArgs(options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose"> & {
28
+ export declare function parseVersionId(output: string): string | null;
29
+ export declare function parseUploadedWorkerName(output: string): string | null;
30
+ export declare function parseWranglerVersionUploadOutput(output: string): WranglerVersionUploadResult;
31
+ export declare function buildWranglerVersionUploadArgs(options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose"> & {
32
32
  previewAlias?: string;
33
33
  }): WranglerVersionArgs;
34
- declare function buildWranglerVersionDeployArgs(versionTraffic: readonly WranglerVersionTraffic[], options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">): WranglerVersionArgs;
35
- declare function buildWranglerDeploymentsStatusArgs(options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">): WranglerVersionArgs;
36
- declare function buildWranglerTriggersDeployArgs(options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">): WranglerVersionArgs;
37
- declare function parseWranglerDeploymentStatusOutput(output: string): WranglerDeploymentStatus;
38
- declare function runWranglerVersionUpload(root: string, options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose"> & {
34
+ export declare function buildWranglerVersionDeployArgs(versionTraffic: readonly WranglerVersionTraffic[], options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">): WranglerVersionArgs;
35
+ export declare function buildWranglerDeploymentsStatusArgs(options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">): WranglerVersionArgs;
36
+ export declare function buildWranglerTriggersDeployArgs(options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">): WranglerVersionArgs;
37
+ export declare function parseWranglerDeploymentStatusOutput(output: string): WranglerDeploymentStatus;
38
+ export declare function runWranglerVersionUpload(root: string, options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose"> & {
39
39
  previewAlias?: string;
40
40
  }, execute?: typeof execFileSync): WranglerVersionUploadResult;
41
- declare function runWranglerVersionDeploy(root: string, versionTraffic: readonly WranglerVersionTraffic[], options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">, phase?: "stage" | "promote-warmed" | "promote-uploaded", execute?: typeof execFileSync): WranglerVersionDeployResult;
42
- declare function runWranglerDeploymentStatus(root: string, options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">, execute?: typeof execFileSync): WranglerDeploymentStatus;
43
- declare function runWranglerTriggersDeploy(root: string, options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">, execute?: typeof execFileSync): WranglerVersionDeployResult;
41
+ export declare function runWranglerVersionDeploy(root: string, versionTraffic: readonly WranglerVersionTraffic[], options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">, phase?: "stage" | "promote-warmed" | "promote-uploaded", execute?: typeof execFileSync): WranglerVersionDeployResult;
42
+ export declare function runWranglerDeploymentStatus(root: string, options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">, execute?: typeof execFileSync): WranglerDeploymentStatus;
43
+ export declare function runWranglerTriggersDeploy(root: string, options: Pick<DeployOptions, "preview" | "env" | "name" | "config" | "verbose">, execute?: typeof execFileSync): WranglerVersionDeployResult;
44
44
  //#endregion
45
- export { WranglerDeploymentStatus, WranglerVersionDeployResult, WranglerVersionTraffic, WranglerVersionUploadResult, buildWranglerDeploymentsStatusArgs, buildWranglerTriggersDeployArgs, buildWranglerVersionDeployArgs, buildWranglerVersionUploadArgs, parseUploadedWorkerName, parseVersionId, parseWorkersDevUrl, parseWranglerDeploymentStatusOutput, parseWranglerVersionUploadOutput, runWranglerDeploymentStatus, runWranglerTriggersDeploy, runWranglerVersionDeploy, runWranglerVersionUpload };
45
+ export { parseWorkersDevUrl };
@@ -133,7 +133,8 @@ function buildWranglerTriggersDeployArgs(options) {
133
133
  };
134
134
  }
135
135
  function runWranglerCommand(root, args, execute = execFileSync, verbose = false) {
136
- const invocation = buildNodeCliInvocation(resolveWranglerBin(root), args);
136
+ const wranglerBin = resolveWranglerBin(root);
137
+ const invocation = buildNodeCliInvocation(wranglerBin, args);
137
138
  const execOpts = {
138
139
  cwd: root,
139
140
  stdio: "pipe",
@@ -163,7 +164,7 @@ function isMissingWorkerVersionUploadError(error) {
163
164
  return /cannot upload a new version of a Worker that does not yet exist/i.test(errorText(error));
164
165
  }
165
166
  function withInitialDeployRequiredMessage() {
166
- return /* @__PURE__ */ new Error("CDN pre-warm needs an existing Cloudflare Worker before it can upload a new Worker version. Run `vinext-cloudflare deploy` once without `--experimental-warm-cdn-cache` to create the Worker, then rerun your pre-warm deploy.");
167
+ return /* @__PURE__ */ new Error("Version upload needs an existing Cloudflare Worker. Run `vinext-cloudflare deploy` once normally to create the Worker, then rerun the version-based deploy.");
167
168
  }
168
169
  function parseDeploymentVersions(value) {
169
170
  const deployment = Array.isArray(value) ? value.at(-1) : value;
@@ -199,7 +200,9 @@ function runWranglerVersionUpload(root, options, execute = execFileSync) {
199
200
  if (env) console.log(`\n Uploading Worker version for env: ${env}...`);
200
201
  else console.log("\n Uploading Worker version for production...");
201
202
  try {
202
- return parseWranglerVersionUploadOutput(runWranglerCommand(root, args, execute, options.verbose === true));
203
+ const upload = parseWranglerVersionUploadOutput(runWranglerCommand(root, args, execute, options.verbose === true));
204
+ console.log(` Worker version ID: ${upload.versionId}`);
205
+ return upload;
203
206
  } catch (error) {
204
207
  if (isMissingWorkerVersionUploadError(error)) throw withInitialDeployRequiredMessage();
205
208
  throw error;
@@ -219,8 +222,10 @@ function runWranglerVersionDeploy(root, versionTraffic, options, phase = "promot
219
222
  }
220
223
  function runWranglerDeploymentStatus(root, options, execute = execFileSync) {
221
224
  const { args, env } = buildWranglerDeploymentsStatusArgs(options);
222
- if (options.verbose) if (env) console.log(`\n Reading current Worker deployment for env: ${env}...`);
223
- else console.log("\n Reading current Worker deployment...");
225
+ if (options.verbose) {
226
+ if (env) console.log(`\n Reading current Worker deployment for env: ${env}...`);
227
+ else console.log("\n Reading current Worker deployment...");
228
+ }
224
229
  return parseWranglerDeploymentStatusOutput(runWranglerCommand(root, args, execute, options.verbose === true));
225
230
  }
226
231
  function runWranglerTriggersDeploy(root, options, execute = execFileSync) {
@@ -1,10 +1,9 @@
1
1
  //#region src/worker-deployment-url.d.ts
2
- declare function parseWorkerDeploymentUrl(output: string): string | null;
2
+ export declare function parseWorkerDeploymentUrl(output: string): string | null;
3
3
  /**
4
4
  * Parse the concrete hostname that Wrangler reports after applying Worker
5
5
  * triggers. Catch-all routes are valid warmup targets even though they are not
6
6
  * canonical deployment URLs for general CLI reporting.
7
7
  */
8
- declare function parseCdnWarmupDeploymentUrl(output: string): string | null;
9
- //#endregion
10
- export { parseCdnWarmupDeploymentUrl, parseWorkerDeploymentUrl };
8
+ export declare function parseCdnWarmupDeploymentUrl(output: string): string | null;
9
+ //#endregion
@@ -1,4 +1,3 @@
1
1
  //#region src/workers-dev-url.d.ts
2
- declare function parseWorkersDevUrl(output: string): string | null;
3
- //#endregion
4
- export { parseWorkersDevUrl };
2
+ export declare function parseWorkersDevUrl(output: string): string | null;
3
+ //#endregion
@@ -0,0 +1,19 @@
1
+ //#region src/wrangler-config.d.ts
2
+ /** Narrow Wrangler config projection shared by deploy-time features. */
3
+ type WranglerConfig = {
4
+ accountId?: string;
5
+ kvNamespaceId?: string;
6
+ customDomain?: string;
7
+ name?: string;
8
+ legacyEnv?: boolean;
9
+ env?: Record<string, WranglerEnvironmentConfig>;
10
+ };
11
+ type WranglerEnvironmentConfig = {
12
+ customDomain?: string;
13
+ name?: string;
14
+ };
15
+ /**
16
+ * Parse the Wrangler fields used by TPR and staged CDN warming.
17
+ */
18
+ export declare function parseWranglerConfig(root: string, configPath?: string): WranglerConfig | null;
19
+ //#endregion
@@ -0,0 +1,294 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ //#region src/wrangler-config.ts
4
+ /** Narrow Wrangler config projection shared by deploy-time features. */
5
+ /**
6
+ * Parse the Wrangler fields used by TPR and staged CDN warming.
7
+ */
8
+ function parseWranglerConfig(root, configPath) {
9
+ if (configPath) {
10
+ const filepath = path.resolve(root, configPath);
11
+ if (!fs.existsSync(filepath)) return null;
12
+ const content = fs.readFileSync(filepath, "utf-8");
13
+ if (filepath.endsWith(".toml")) return extractFromTOML(content);
14
+ try {
15
+ return extractFromJSON(JSON.parse(stripJsonCommentsAndTrailingCommas(content)));
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+ for (const filename of ["wrangler.jsonc", "wrangler.json"]) {
21
+ const filepath = path.join(root, filename);
22
+ if (fs.existsSync(filepath)) {
23
+ const content = fs.readFileSync(filepath, "utf-8");
24
+ try {
25
+ return extractFromJSON(JSON.parse(stripJsonCommentsAndTrailingCommas(content)));
26
+ } catch {
27
+ continue;
28
+ }
29
+ }
30
+ }
31
+ const tomlPath = path.join(root, "wrangler.toml");
32
+ if (fs.existsSync(tomlPath)) return extractFromTOML(fs.readFileSync(tomlPath, "utf-8"));
33
+ return null;
34
+ }
35
+ /**
36
+ * Strip single-line (//), multi-line comments, and trailing commas from JSONC
37
+ * while preserving strings that contain comment-like text or commas.
38
+ */
39
+ function stripJsonCommentsAndTrailingCommas(str) {
40
+ let result = "";
41
+ let inString = false;
42
+ let inSingleLine = false;
43
+ let inMultiLine = false;
44
+ let escapeNext = false;
45
+ for (let i = 0; i < str.length; i++) {
46
+ const ch = str[i];
47
+ const next = str[i + 1];
48
+ if (escapeNext) {
49
+ if (!inSingleLine && !inMultiLine) result += ch;
50
+ escapeNext = false;
51
+ continue;
52
+ }
53
+ if (ch === "\\" && inString) {
54
+ result += ch;
55
+ escapeNext = true;
56
+ continue;
57
+ }
58
+ if (inSingleLine) {
59
+ if (ch === "\n") {
60
+ inSingleLine = false;
61
+ result += ch;
62
+ }
63
+ continue;
64
+ }
65
+ if (inMultiLine) {
66
+ if (ch === "*" && next === "/") {
67
+ inMultiLine = false;
68
+ i++;
69
+ }
70
+ continue;
71
+ }
72
+ if (ch === "\"" && !inString) {
73
+ inString = true;
74
+ result += ch;
75
+ continue;
76
+ }
77
+ if (ch === "\"" && inString) {
78
+ inString = false;
79
+ result += ch;
80
+ continue;
81
+ }
82
+ if (!inString && ch === "/" && next === "/") {
83
+ inSingleLine = true;
84
+ i++;
85
+ continue;
86
+ }
87
+ if (!inString && ch === "/" && next === "*") {
88
+ inMultiLine = true;
89
+ i++;
90
+ continue;
91
+ }
92
+ if (!inString && ch === "," && isJsonTrailingComma(str, i + 1)) continue;
93
+ result += ch;
94
+ }
95
+ return result;
96
+ }
97
+ function isJsonTrailingComma(str, start) {
98
+ for (let i = start; i < str.length; i++) {
99
+ const ch = str[i];
100
+ const next = str[i + 1];
101
+ if (ch === void 0) return false;
102
+ if (/\s/.test(ch)) continue;
103
+ if (ch === "/" && next === "/") {
104
+ i += 2;
105
+ while (i < str.length && str[i] !== "\n") i++;
106
+ continue;
107
+ }
108
+ if (ch === "/" && next === "*") {
109
+ i += 2;
110
+ while (i < str.length) {
111
+ if (str[i] === "*" && str[i + 1] === "/") {
112
+ i++;
113
+ break;
114
+ }
115
+ i++;
116
+ }
117
+ continue;
118
+ }
119
+ return ch === "}" || ch === "]";
120
+ }
121
+ return false;
122
+ }
123
+ function extractFromJSON(config) {
124
+ const result = {};
125
+ if (typeof config.name === "string" && config.name.length > 0) result.name = config.name;
126
+ if (typeof config.legacy_env === "boolean") result.legacyEnv = config.legacy_env;
127
+ if (typeof config.account_id === "string") result.accountId = config.account_id;
128
+ if (Array.isArray(config.kv_namespaces)) {
129
+ const namespace = config.kv_namespaces.find((value) => value && typeof value === "object" && (value.binding === "VINEXT_KV_CACHE" || value.binding === "VINEXT_CACHE"));
130
+ if (namespace && typeof namespace.id === "string" && namespace.id !== "<your-kv-namespace-id>") result.kvNamespaceId = namespace.id;
131
+ }
132
+ const domain = extractDomainFromRoutes(config.routes) ?? extractDomainFromCustomDomains(config);
133
+ if (domain) result.customDomain = domain;
134
+ const env = extractEnvConfigs(config.env);
135
+ if (env) result.env = env;
136
+ return result;
137
+ }
138
+ function extractEnvConfigs(envs) {
139
+ if (!envs || typeof envs !== "object" || Array.isArray(envs)) return void 0;
140
+ const result = {};
141
+ for (const [envName, rawConfig] of Object.entries(envs)) {
142
+ if (!rawConfig || typeof rawConfig !== "object" || Array.isArray(rawConfig)) continue;
143
+ const envConfig = extractEnvironmentConfig(rawConfig);
144
+ if (envConfig.name || envConfig.customDomain) result[envName] = envConfig;
145
+ }
146
+ return Object.keys(result).length > 0 ? result : void 0;
147
+ }
148
+ function extractEnvironmentConfig(config) {
149
+ const result = {};
150
+ if (typeof config.name === "string" && config.name.length > 0) result.name = config.name;
151
+ const domain = extractDomainFromRoutes(config.routes) ?? extractDomainFromCustomDomains(config);
152
+ if (domain) result.customDomain = domain;
153
+ return result;
154
+ }
155
+ function extractDomainFromRoutes(routes) {
156
+ if (!Array.isArray(routes)) return null;
157
+ for (const route of routes) if (typeof route === "string") {
158
+ const domain = cleanDomain(route);
159
+ if (domain && !domain.includes("workers.dev")) return domain;
160
+ } else if (route && typeof route === "object") {
161
+ const r = route;
162
+ const pattern = typeof r.zone_name === "string" ? r.zone_name : typeof r.pattern === "string" ? r.pattern : null;
163
+ if (pattern) {
164
+ const domain = cleanDomain(pattern);
165
+ if (domain && !domain.includes("workers.dev")) return domain;
166
+ }
167
+ }
168
+ return null;
169
+ }
170
+ function extractDomainFromCustomDomains(config) {
171
+ if (Array.isArray(config.custom_domains)) {
172
+ for (const d of config.custom_domains) if (typeof d === "string" && !d.includes("workers.dev")) return cleanDomain(d);
173
+ }
174
+ return null;
175
+ }
176
+ /** Strip protocol and trailing wildcards from a route pattern to get a bare domain. */
177
+ function cleanDomain(raw) {
178
+ return raw.replace(/^https?:\/\//, "").replace(/\/\*$/, "").replace(/\/+$/, "").split("/")[0] || null;
179
+ }
180
+ /**
181
+ * Simple extraction of specific fields from wrangler.toml content.
182
+ * Not a full TOML parser — just enough for the fields we need.
183
+ */
184
+ function extractFromTOML(content) {
185
+ const result = {};
186
+ const nameMatch = content.match(/^name\s*=\s*"([^"]+)"/m);
187
+ if (nameMatch) result.name = nameMatch[1];
188
+ const legacyEnvMatch = content.match(/^legacy_env\s*=\s*(true|false)\s*$/m);
189
+ if (legacyEnvMatch) result.legacyEnv = legacyEnvMatch[1] === "true";
190
+ const accountMatch = content.match(/^account_id\s*=\s*"([^"]+)"/m);
191
+ if (accountMatch) result.accountId = accountMatch[1];
192
+ for (const block of content.split(/\[\[kv_namespaces\]\]/).slice(1)) {
193
+ const section = block.split(/\[\[/)[0];
194
+ const binding = section.match(/binding\s*=\s*"([^"]+)"/)?.[1];
195
+ const id = section.match(/\bid\s*=\s*"([^"]+)"/)?.[1];
196
+ if ((binding === "VINEXT_KV_CACHE" || binding === "VINEXT_CACHE") && id && id !== "<your-kv-namespace-id>") result.kvNamespaceId = id;
197
+ }
198
+ const routeMatch = content.match(/^route\s*=\s*"([^"]+)"/m);
199
+ if (routeMatch) {
200
+ const domain = cleanDomain(routeMatch[1]);
201
+ if (domain && !domain.includes("workers.dev")) result.customDomain = domain;
202
+ }
203
+ if (!result.customDomain) {
204
+ const routeBlocks = content.split(/\[\[routes\]\]/);
205
+ for (let i = 1; i < routeBlocks.length; i++) {
206
+ const patternMatch = routeBlocks[i].split(/\[\[/)[0].match(/pattern\s*=\s*"([^"]+)"/);
207
+ if (patternMatch) {
208
+ const domain = cleanDomain(patternMatch[1]);
209
+ if (domain && !domain.includes("workers.dev")) {
210
+ result.customDomain = domain;
211
+ break;
212
+ }
213
+ }
214
+ }
215
+ }
216
+ const env = extractEnvConfigsFromTOML(content);
217
+ if (env) result.env = env;
218
+ return result;
219
+ }
220
+ function extractEnvConfigsFromTOML(content) {
221
+ const result = {};
222
+ for (const section of getTomlSections(content)) {
223
+ const envName = section.header.match(/^env\.([^.]+)$/)?.[1];
224
+ if (envName) {
225
+ const envConfig = result[envName] ?? {};
226
+ const nameMatch = section.body.match(/^name\s*=\s*"([^"]+)"/m);
227
+ if (nameMatch) envConfig.name = nameMatch[1];
228
+ const domain = extractTomlScalarRouteDomain(section.body) ?? extractTomlRoutesArrayDomain(section.body);
229
+ if (domain) envConfig.customDomain = domain;
230
+ if (envConfig.name || envConfig.customDomain) result[envName] = envConfig;
231
+ continue;
232
+ }
233
+ const routesEnvName = section.header.match(/^env\.([^.]+)\.routes$/)?.[1];
234
+ if (routesEnvName) {
235
+ const envConfig = result[routesEnvName] ?? {};
236
+ const domain = extractTomlRouteBlockDomain(section.body);
237
+ if (domain) envConfig.customDomain = domain;
238
+ if (envConfig.name || envConfig.customDomain) result[routesEnvName] = envConfig;
239
+ }
240
+ }
241
+ return Object.keys(result).length > 0 ? result : void 0;
242
+ }
243
+ function getTomlSections(content) {
244
+ const sections = [];
245
+ let currentHeader = null;
246
+ let currentBody = [];
247
+ for (const line of content.split("\n")) {
248
+ const header = parseTomlSectionHeader(line);
249
+ if (header) {
250
+ if (currentHeader) sections.push({
251
+ header: currentHeader,
252
+ body: currentBody.join("\n")
253
+ });
254
+ currentHeader = header;
255
+ currentBody = [];
256
+ } else if (currentHeader) currentBody.push(line);
257
+ }
258
+ if (currentHeader) sections.push({
259
+ header: currentHeader,
260
+ body: currentBody.join("\n")
261
+ });
262
+ return sections;
263
+ }
264
+ function parseTomlSectionHeader(line) {
265
+ const trimmed = line.trim();
266
+ if (!trimmed.startsWith("[") || !trimmed.endsWith("]")) return null;
267
+ const isArrayHeader = trimmed.startsWith("[[") && trimmed.endsWith("]]");
268
+ const start = isArrayHeader ? 2 : 1;
269
+ const end = isArrayHeader ? trimmed.length - 2 : trimmed.length - 1;
270
+ const header = trimmed.slice(start, end).trim();
271
+ return header.length > 0 ? header : null;
272
+ }
273
+ function extractTomlScalarRouteDomain(section) {
274
+ const routeMatch = section.match(/^route\s*=\s*"([^"]+)"/m);
275
+ if (!routeMatch) return null;
276
+ const domain = cleanDomain(routeMatch[1]);
277
+ return domain && !domain.includes("workers.dev") ? domain : null;
278
+ }
279
+ function extractTomlRoutesArrayDomain(section) {
280
+ const routesMatch = section.match(/^routes\s*=\s*\[([\s\S]*?)\]/m);
281
+ if (!routesMatch) return null;
282
+ const patternMatch = (routesMatch[1] ?? "").match(/(?:pattern\s*=\s*)?"([^"]+)"/);
283
+ if (!patternMatch) return null;
284
+ const domain = cleanDomain(patternMatch[1]);
285
+ return domain && !domain.includes("workers.dev") ? domain : null;
286
+ }
287
+ function extractTomlRouteBlockDomain(section) {
288
+ const patternMatch = section.match(/^pattern\s*=\s*"([^"]+)"/m) ?? section.match(/^zone_name\s*=\s*"([^"]+)"/m);
289
+ if (!patternMatch) return null;
290
+ const domain = cleanDomain(patternMatch[1]);
291
+ return domain && !domain.includes("workers.dev") ? domain : null;
292
+ }
293
+ //#endregion
294
+ export { parseWranglerConfig };
@@ -1,8 +1,7 @@
1
1
  //#region src/wrangler-version-metadata.d.ts
2
- declare function assertCdnVersionMetadataConfig({ binding, configuredBinding, configPath }: {
2
+ export declare function assertCdnVersionMetadataConfig({ binding, configuredBinding, configPath }: {
3
3
  binding: string;
4
4
  configuredBinding: string | undefined;
5
5
  configPath: string | undefined;
6
6
  }): void;
7
- //#endregion
8
- export { assertCdnVersionMetadataConfig };
7
+ //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vinext/cloudflare",
3
- "version": "1.0.0-beta.7",
4
- "description": "Cloudflare adapters for vinext (KV data cache and Images-backed image optimization).",
3
+ "version": "1.0.0-beta.9",
4
+ "description": "Cloudflare cache and image adapters for vinext.",
5
5
  "homepage": "https://vinext.dev/",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -30,10 +30,6 @@
30
30
  "types": "./dist/deploy-config.d.ts",
31
31
  "import": "./dist/deploy-config.js"
32
32
  },
33
- "./internal/tpr": {
34
- "types": "./dist/tpr.d.ts",
35
- "import": "./dist/tpr.js"
36
- },
37
33
  "./internal/cdn-warm": {
38
34
  "types": "./dist/cdn-warm.d.ts",
39
35
  "import": "./dist/cdn-warm.js"
@@ -51,20 +47,26 @@
51
47
  "import": "./dist/images/*.js"
52
48
  }
53
49
  },
50
+ "dependencies": {
51
+ "@cloudflare/workers-response-store": "0.1.0-beta.1"
52
+ },
54
53
  "devDependencies": {
55
54
  "@types/node": "^25.9.2",
56
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.6",
57
- "vite-plus": "0.2.6",
58
- "vinext": "1.0.0-beta.9"
55
+ "miniflare": "5.20260730.0-alpha",
56
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.3.2",
57
+ "vite-plus": "0.3.2",
58
+ "vitest": "4.1.11",
59
+ "vinext": "1.0.0-beta.11"
59
60
  },
60
61
  "peerDependencies": {
61
- "vinext": "^1.0.0-beta.9"
62
+ "vinext": "^1.0.0-beta.11"
62
63
  },
63
64
  "engines": {
64
65
  "node": ">=22"
65
66
  },
66
67
  "scripts": {
67
68
  "build": "vp pack",
68
- "dev": "vp pack --watch"
69
+ "dev": "vp pack --watch",
70
+ "test": "vp run vinext#build && vp run @cloudflare/workers-response-store#build && vp run @vinext/cloudflare#build && VINEXT_RESPONSE_STORE_MODE=self-contained pnpm --filter response-store-demo run build && pnpm --filter response-store-demo run build && vitest run"
69
71
  }
70
72
  }