@bascik/adapter-cloudflare 1.0.0-rc.1 → 1.0.0-rc.10

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/config.js CHANGED
@@ -4,10 +4,11 @@
4
4
  * Structured configuration discovery and parsing for Cloudflare Wrangler configuration files.
5
5
  * Supports jsonc (comments and trailing commas), json, and toml with safe error reporting.
6
6
  */
7
- import { join } from "node:path";
7
+ import { isAbsolute, join, relative, resolve } from "node:path";
8
8
  import { readFile } from "node:fs/promises";
9
- import { parse as parseJsoncRaw, printParseErrorCode } from "jsonc-parser";
9
+ import { parse as parseJsoncRaw, printParseErrorCode, } from "jsonc-parser";
10
10
  import { parse as parseTomlRaw, TomlError } from "smol-toml";
11
+ import { CLOUDFLARE_COMPATIBILITY_DATE, CLOUDFLARE_COMPATIBILITY_FLAGS, } from "./compat.js";
11
12
  /**
12
13
  * Wrangler configuration file discovery order according to Cloudflare Wrangler documentation:
13
14
  * 1. wrangler.jsonc
@@ -67,7 +68,9 @@ function lineAndCharacterAt(text, offset) {
67
68
  export function parseToml(text, filename = "wrangler.toml") {
68
69
  try {
69
70
  const parsed = parseTomlRaw(text);
70
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
71
+ if (typeof parsed !== "object" ||
72
+ parsed === null ||
73
+ Array.isArray(parsed)) {
71
74
  throw new Error(`[bascik] Failed to parse ${filename}: expected a top-level TOML table.`);
72
75
  }
73
76
  return parsed;
@@ -83,6 +86,27 @@ export function parseToml(text, filename = "wrangler.toml") {
83
86
  throw new Error(`[bascik] Failed to parse ${filename}: ${msg}`);
84
87
  }
85
88
  }
89
+ /**
90
+ * Parses package.json as strict JSON (no comments, no trailing commas, as
91
+ * npm reads it). An error is located by line and column and, like the
92
+ * Wrangler parsers, never quotes the file: `JSON.parse`'s own message
93
+ * includes a source excerpt. A value that is not an object has no name.
94
+ */
95
+ function parsePackageJson(text) {
96
+ const errors = [];
97
+ const parsed = parseJsoncRaw(text, errors, {
98
+ allowTrailingComma: false,
99
+ disallowComments: true,
100
+ });
101
+ if (errors.length > 0) {
102
+ const first = errors[0];
103
+ const { line, character } = lineAndCharacterAt(text, first.offset);
104
+ throw new Error(`[bascik] Failed to parse package.json at line ${line}, column ${character}: ${printParseErrorCode(first.error)}.`);
105
+ }
106
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
107
+ ? parsed
108
+ : null;
109
+ }
86
110
  /**
87
111
  * Discovers and parses the highest precedence Wrangler configuration file in the project root.
88
112
  * Returns null if no Wrangler configuration file exists.
@@ -99,7 +123,9 @@ export async function discoverWranglerConfig(projectRoot) {
99
123
  if (err.code === "ENOENT") {
100
124
  continue;
101
125
  }
102
- throw err;
126
+ // The bare fs message (EISDIR, EACCES) names no file.
127
+ const msg = err instanceof Error ? err.message : String(err);
128
+ throw new Error(`[bascik] Failed to read ${filename}: ${msg}`);
103
129
  }
104
130
  // The file exists: parse it according to its extension
105
131
  if (filename.endsWith(".toml")) {
@@ -127,26 +153,285 @@ export async function resolveWorkerName(projectRoot, discoveredConfig) {
127
153
  if (envName && envName.trim()) {
128
154
  return { workerName: envName.trim(), source: "env", discoveredConfig };
129
155
  }
130
- const discovered = discoveredConfig !== undefined ? discoveredConfig : await discoverWranglerConfig(projectRoot);
131
- if (discovered && discovered.values.name && typeof discovered.values.name === "string" && discovered.values.name.trim()) {
132
- return { workerName: discovered.values.name.trim(), source: "config", discoveredConfig: discovered };
156
+ const discovered = discoveredConfig !== undefined
157
+ ? discoveredConfig
158
+ : await discoverWranglerConfig(projectRoot);
159
+ if (discovered &&
160
+ discovered.values.name &&
161
+ typeof discovered.values.name === "string" &&
162
+ discovered.values.name.trim()) {
163
+ return {
164
+ workerName: discovered.values.name.trim(),
165
+ source: "config",
166
+ discoveredConfig: discovered,
167
+ };
133
168
  }
169
+ let pkgJsonRaw;
134
170
  try {
135
- const pkgJsonRaw = await readFile(join(projectRoot, "package.json"), "utf8");
136
- const pkgJson = JSON.parse(pkgJsonRaw);
137
- if (pkgJson.name && typeof pkgJson.name === "string" && pkgJson.name.trim()) {
171
+ pkgJsonRaw = await readFile(join(projectRoot, "package.json"), "utf8");
172
+ }
173
+ catch (err) {
174
+ if (err.code !== "ENOENT") {
175
+ const msg = err instanceof Error ? err.message : String(err);
176
+ throw new Error(`[bascik] Failed to read package.json: ${msg}`);
177
+ }
178
+ }
179
+ if (pkgJsonRaw !== undefined) {
180
+ const pkgJson = parsePackageJson(pkgJsonRaw);
181
+ if (pkgJson?.name &&
182
+ typeof pkgJson.name === "string" &&
183
+ pkgJson.name.trim()) {
138
184
  const name = pkgJson.name.replace(/^@[^/]+\//, "").trim();
139
185
  if (name) {
140
- return { workerName: name, source: "package", discoveredConfig: discovered };
186
+ return {
187
+ workerName: name,
188
+ source: "package",
189
+ discoveredConfig: discovered,
190
+ };
141
191
  }
142
192
  }
143
193
  }
144
- catch (err) {
145
- if (err.code !== "ENOENT") {
146
- const msg = err instanceof Error ? err.message : String(err);
147
- throw new Error(`[bascik] Failed to parse package.json: ${msg}`);
194
+ return {
195
+ workerName: "bascik-site",
196
+ source: "default",
197
+ discoveredConfig: discovered,
198
+ };
199
+ }
200
+ /** The Worker entry the adapter generates beside the generated config. */
201
+ export const GENERATED_WORKER_MAIN = "worker.js";
202
+ /** The binding the generated Worker serves static files through (runtime.ts). */
203
+ export const ASSETS_BINDING = "ASSETS";
204
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
205
+ const toPosix = (path) => path.replace(/\\/g, "/");
206
+ /**
207
+ * Generates the wrangler.jsonc written beside worker.js. The adapter owns
208
+ * `name` (resolved by resolveWorkerName), `main`, `assets.directory`,
209
+ * `assets.binding` and `assets.run_worker_first` (computed from the routes,
210
+ * unioned with an authored list); `compatibility_flags` are the union of the
211
+ * authored flags and the adapter's. Every other authored key, top level or
212
+ * nested, is carried over verbatim, except that path-valued keys Wrangler
213
+ * reads relative to the config file are rebased from the project root to the
214
+ * output directory, so they name the same files. An authored key the adapter
215
+ * replaces is reported as a warning naming the file and key; an authored
216
+ * `assets.binding` other than `ASSETS` is an error, since the generated
217
+ * Worker reads `env.ASSETS`. Unknown keys are carried over without checks:
218
+ * Wrangler validates its own config.
219
+ */
220
+ export function generateWranglerConfig(input) {
221
+ const { authored, projectRoot, outDir, workerName, runWorkerFirst, schemaPath, compatibilityDate = CLOUDFLARE_COMPATIBILITY_DATE, compatibilityFlags = CLOUDFLARE_COMPATIBILITY_FLAGS, } = input;
222
+ const filename = authored?.filename ?? "wrangler.jsonc";
223
+ const values = authored?.values ?? {};
224
+ const warnings = [];
225
+ const at = (key) => `[bascik] ${filename}: "${key}"`;
226
+ const rebase = (value) => {
227
+ if (typeof value !== "string" || value === "")
228
+ return value;
229
+ if (isAbsolute(value) || /^[a-z][a-z0-9+.-]*:/i.test(value))
230
+ return value;
231
+ return toPosix(relative(outDir, resolve(projectRoot, value))) || ".";
232
+ };
233
+ const rebaseList = (value) => Array.isArray(value) ? value.map(rebase) : rebase(value);
234
+ const rebaseMap = (value) => isObject(value)
235
+ ? Object.fromEntries(Object.entries(value).map(([k, v]) => [k, rebase(v)]))
236
+ : value;
237
+ const rebaseItems = (value, fn) => Array.isArray(value)
238
+ ? value.map((item) => (isObject(item) ? fn(item) : item))
239
+ : value;
240
+ const rebaseD1 = (item) => {
241
+ const out = { ...item };
242
+ if ("migrations_dir" in out)
243
+ out.migrations_dir = rebase(out.migrations_dir);
244
+ // Wrangler defaults migrations_dir to ./migrations beside the config file;
245
+ // the generated config sits elsewhere, so the authored folder is named.
246
+ // A migrations_pattern without migrations_dir is left for Wrangler to
247
+ // report, as it would from the project root.
248
+ else if (!("migrations_pattern" in out))
249
+ out.migrations_dir = rebase("migrations");
250
+ if ("migrations_pattern" in out)
251
+ out.migrations_pattern = rebase(out.migrations_pattern);
252
+ return out;
253
+ };
254
+ const rebaseContainer = (item) => {
255
+ const out = { ...item };
256
+ // `image` is a Dockerfile path or a registry reference: only a path
257
+ // spelled as one is rebased.
258
+ if (typeof out.image === "string" &&
259
+ (/^\.\.?[\\/]/.test(out.image) || /dockerfile/i.test(out.image)) &&
260
+ !/^[a-z][a-z0-9+.-]*:/i.test(out.image))
261
+ out.image = rebase(out.image);
262
+ if ("image_build_context" in out)
263
+ out.image_build_context = rebase(out.image_build_context);
264
+ // Named images of a Durable Object-managed container.
265
+ if (isObject(out.images))
266
+ out.images = Object.fromEntries(Object.entries(out.images).map(([imageName, image]) => {
267
+ if (!isObject(image))
268
+ return [imageName, image];
269
+ const rebased = { ...image };
270
+ if ("dockerfile" in rebased)
271
+ rebased.dockerfile = rebase(rebased.dockerfile);
272
+ if ("build_context" in rebased)
273
+ rebased.build_context = rebase(rebased.build_context);
274
+ return [imageName, rebased];
275
+ }));
276
+ return out;
277
+ };
278
+ /** The assets block the adapter writes, merged with an authored one. */
279
+ const mergeAssets = (assets, keyPrefix) => {
280
+ const authoredAssets = isObject(assets) ? assets : {};
281
+ if (assets !== undefined && !isObject(assets))
282
+ warnings.push(`${at(`${keyPrefix}assets`)} is not an object and is ignored: the adapter writes its own assets block.`);
283
+ const { directory, binding, run_worker_first: authoredFirst, not_found_handling, ...rest } = authoredAssets;
284
+ if (directory !== undefined)
285
+ warnings.push(`${at(`${keyPrefix}assets.directory`)} is ignored: the adapter stages the site's files in ./public beside the generated worker.js. Remove the key.`);
286
+ if (binding !== undefined && binding !== ASSETS_BINDING)
287
+ throw new Error(`${at(`${keyPrefix}assets.binding`)} must be "${ASSETS_BINDING}" or left out: the generated Worker serves static files through env.${ASSETS_BINDING}.`);
288
+ // Wrangler takes a boolean or a list of route patterns. Anything else
289
+ // (a string "true", a number in the list) never reaches Wrangler: say
290
+ // so, since the Worker would silently run first for fewer paths.
291
+ const strayFirst = authoredFirst === undefined || typeof authoredFirst === "boolean"
292
+ ? []
293
+ : Array.isArray(authoredFirst)
294
+ ? authoredFirst.filter((p) => typeof p !== "string")
295
+ : [authoredFirst];
296
+ if (strayFirst.length)
297
+ warnings.push(`${at(`${keyPrefix}assets.run_worker_first`)} must be true or a list of route patterns: ${strayFirst.map((v) => JSON.stringify(v)).join(", ")} is ignored, and the Worker runs first only for the routes the build computes${Array.isArray(authoredFirst) ? " and your other patterns" : ""}.`);
298
+ let first;
299
+ // The top-level `true` is resolved by build.ts (it also decides who
300
+ // sends the static files' headers); an env section's own `true` is
301
+ // kept for that environment, as Wrangler would read it.
302
+ if (runWorkerFirst === true || authoredFirst === true)
303
+ first = true;
304
+ else {
305
+ const extra = Array.isArray(authoredFirst)
306
+ ? authoredFirst.filter((p) => typeof p === "string")
307
+ : [];
308
+ first = [...new Set([...runWorkerFirst, ...extra])];
309
+ }
310
+ return {
311
+ directory: "./public",
312
+ binding: ASSETS_BINDING,
313
+ ...rest,
314
+ not_found_handling: not_found_handling ?? "404-page",
315
+ run_worker_first: first,
316
+ };
317
+ };
318
+ const unionFlags = (flags) => [
319
+ ...new Set([
320
+ ...(Array.isArray(flags)
321
+ ? flags.filter((f) => typeof f === "string" && f.trim().length > 0)
322
+ : []),
323
+ ...compatibilityFlags,
324
+ ]),
325
+ ];
326
+ /** Rebases the path-valued keys of a top-level or env section. */
327
+ const rebaseSection = (section) => {
328
+ const out = { ...section };
329
+ if ("tsconfig" in out)
330
+ out.tsconfig = rebase(out.tsconfig);
331
+ if ("base_dir" in out)
332
+ out.base_dir = rebase(out.base_dir);
333
+ if (isObject(out.build)) {
334
+ const build = { ...out.build };
335
+ // Wrangler runs build.command in the config's folder by default: the
336
+ // generated config sits elsewhere, so the authored folder is named.
337
+ if ("cwd" in build)
338
+ build.cwd = rebase(build.cwd);
339
+ else if (build.command !== undefined)
340
+ build.cwd = rebase(".");
341
+ if ("watch_dir" in build)
342
+ build.watch_dir = rebaseList(build.watch_dir);
343
+ out.build = build;
148
344
  }
345
+ if ("d1_databases" in out)
346
+ out.d1_databases = rebaseItems(out.d1_databases, rebaseD1);
347
+ if ("containers" in out)
348
+ out.containers = rebaseItems(out.containers, rebaseContainer);
349
+ if (isObject(out.site) && "bucket" in out.site)
350
+ out.site = { ...out.site, bucket: rebase(out.site.bucket) };
351
+ for (const key of ["wasm_modules", "text_blobs", "data_blobs"])
352
+ if (key in out)
353
+ out[key] = rebaseMap(out[key]);
354
+ if (isObject(out.previews))
355
+ out.previews = rebaseSection(out.previews);
356
+ return out;
357
+ };
358
+ const { $schema: authoredSchema, name: _name, main, compatibility_date, compatibility_flags, assets, env, ...rest } = values;
359
+ if (main !== undefined)
360
+ warnings.push(`${at("main")} is ignored: the adapter generates the Worker entry (${GENERATED_WORKER_MAIN}) from your pages and API routes. Remove the key.`);
361
+ const checkDate = (value, key) => {
362
+ if (value !== undefined && !isCompatibilityDate(value))
363
+ warnings.push(`${at(key)} must be a date like "${compatibilityDate}", but is ${JSON.stringify(value)}: Wrangler will reject it, and the build checks node:* imports against ${compatibilityDate} instead.`);
364
+ };
365
+ checkDate(compatibility_date, "compatibility_date");
366
+ let schema;
367
+ if (typeof authoredSchema === "string")
368
+ schema = rebase(authoredSchema);
369
+ else if (authoredSchema !== undefined)
370
+ schema = authoredSchema;
371
+ else if (schemaPath)
372
+ schema = toPosix(relative(outDir, schemaPath)) || undefined;
373
+ let envOut = env;
374
+ if (isObject(env)) {
375
+ envOut = Object.fromEntries(Object.entries(env).map(([envName, section]) => {
376
+ if (!isObject(section))
377
+ return [envName, section];
378
+ const prefix = `env.${envName}.`;
379
+ const { main: envMain, ...envRest } = section;
380
+ if (envMain !== undefined)
381
+ warnings.push(`${at(`${prefix}main`)} is ignored: every environment runs the generated ${GENERATED_WORKER_MAIN}. Remove the key.`);
382
+ checkDate(envRest.compatibility_date, `${prefix}compatibility_date`);
383
+ const out = rebaseSection(envRest);
384
+ if ("compatibility_flags" in out)
385
+ out.compatibility_flags = unionFlags(out.compatibility_flags);
386
+ if ("assets" in out)
387
+ out.assets = mergeAssets(out.assets, prefix);
388
+ return [envName, out];
389
+ }));
149
390
  }
150
- return { workerName: "bascik-site", source: "default", discoveredConfig: discovered };
391
+ const config = {
392
+ ...(schema !== undefined ? { $schema: schema } : {}),
393
+ name: workerName,
394
+ main: GENERATED_WORKER_MAIN,
395
+ compatibility_date: compatibility_date ?? compatibilityDate,
396
+ compatibility_flags: unionFlags(compatibility_flags),
397
+ ...rebaseSection(rest),
398
+ ...(env !== undefined ? { env: envOut } : {}),
399
+ assets: mergeAssets(assets, ""),
400
+ };
401
+ return { config, warnings };
151
402
  }
403
+ /** A compatibility date as Wrangler takes it: `YYYY-MM-DD`. */
404
+ const isCompatibilityDate = (value) => typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value);
405
+ /**
406
+ * The compatibility settings each deployment of a generated config runs
407
+ * under: the top level, then every `env.<name>` section (its own date and
408
+ * flags, or the top level's, which Wrangler gives a section without them).
409
+ * A malformed date (reported by generateWranglerConfig) counts as `fallback`.
410
+ */
411
+ export const deploymentCompatSettings = (config, filename, fallback) => {
412
+ const flagsOf = (value) => Array.isArray(value)
413
+ ? value.filter((f) => typeof f === "string")
414
+ : undefined;
415
+ const top = {
416
+ compatibilityDate: isCompatibilityDate(config.compatibility_date)
417
+ ? config.compatibility_date
418
+ : fallback.compatibilityDate,
419
+ compatibilityFlags: flagsOf(config.compatibility_flags) ?? fallback.compatibilityFlags,
420
+ ...(filename ? { source: filename } : {}),
421
+ };
422
+ const settings = [top];
423
+ if (isObject(config.env))
424
+ for (const [envName, section] of Object.entries(config.env)) {
425
+ if (!isObject(section))
426
+ continue;
427
+ settings.push({
428
+ compatibilityDate: isCompatibilityDate(section.compatibility_date)
429
+ ? section.compatibility_date
430
+ : top.compatibilityDate,
431
+ compatibilityFlags: flagsOf(section.compatibility_flags) ?? top.compatibilityFlags,
432
+ source: `${filename ?? "wrangler.jsonc"} env.${envName}`,
433
+ });
434
+ }
435
+ return settings;
436
+ };
152
437
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE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AAQ,CAAC,MAAM,CAAC,GAAG,CAAC;QACtB,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,SAAS;YACjC,QAAQ,CAAC,IAAI,CAAC;gBACZ,iBAAiB,EAAE,mBAAmB,CAAC,OAAO,CAAC,kBAAkB,CAAC;oBAChE,CAAC,CAAC,OAAO,CAAC,kBAAkB;oBAC5B,CAAC,CAAC,GAAG,CAAC,iBAAiB;gBACzB,kBAAkB,EAChB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,GAAG,CAAC,kBAAkB;gBAChE,MAAM,EAAE,GAAG,QAAQ,IAAI,gBAAgB,QAAQ,OAAO,EAAE;aACzD,CAAC,CAAC;QACL,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * The generated public/_headers on Cloudflare.
3
+ *
4
+ * Static files are served by the asset layer without the Worker, so the
5
+ * headers the Worker sends on what it answers have to be written here for
6
+ * them: the security headers (`security.headers`, `security.hsts`) as one
7
+ * site-wide `/*` rule, and the opt-in `contentSecurityPolicy` as one
8
+ * exact-path rule per static page (from the same pkg function the Node
9
+ * servers and the Worker use, with the build's hashes). Responses the Worker
10
+ * makes itself never get `_headers` rules, and an asset it forwards gets them
11
+ * once, from the asset layer, so no header is sent twice.
12
+ *
13
+ * How Cloudflare reads the file (workers-shared, which miniflare runs): rules
14
+ * are a record keyed by path, so a second rule with a path the author used
15
+ * replaces the author's, at the place of the first; the rules that match a
16
+ * URL apply in file order; a header two of them set is joined with a comma;
17
+ * `! Name` in a rule removes what earlier rules set, before that rule's own
18
+ * values; a line over 2000 characters is skipped; and it stops reading at the
19
+ * 101st path line.
20
+ *
21
+ * So, whenever Bascik writes anything into the file:
22
+ * 1. the site-wide rule comes first (Bascik's, or the author's own `/*`
23
+ * moved to the top with Bascik's headers it does not set added);
24
+ * 2. the static pages' CSP rules come next, never as a second rule for a
25
+ * path the author has (the line goes into the author's rule), and not at
26
+ * all for a page an author rule already sets or removes the CSP header
27
+ * on: the author's value wins there;
28
+ * 3. the author's other rules follow, and each one that sets a security
29
+ * header (any Bascik can write, whatever the toggles say) or a header
30
+ * the author's `/*` sets gets a `! Name` line first: a later, more
31
+ * specific rule replaces the value instead of being joined to it, the
32
+ * same way under every security setting.
33
+ * When Bascik writes nothing (headers, HSTS and CSP all off), the author's
34
+ * file ships as written.
35
+ */
36
+ import { type ContentSecurityPolicyConfig, type CspRouteHashes, type ResponseSecurity } from "@bascik/bascik/runtime";
37
+ /** Cloudflare reads at most this many rules (path lines) from _headers. */
38
+ export declare const CLOUDFLARE_HEADERS_RULE_LIMIT = 100;
39
+ /** Cloudflare skips any _headers line longer than this, with no error. */
40
+ export declare const CLOUDFLARE_HEADERS_LINE_LIMIT = 2000;
41
+ /**
42
+ * How many rules Cloudflare reads from a _headers text: one per path line
43
+ * that has a header or a `! Name` under it. A path written twice counts
44
+ * twice, because Cloudflare stops at a count of path lines, not of paths.
45
+ */
46
+ export declare const countHeadersRules: (text: string) => number;
47
+ export interface HeadersFileCsp {
48
+ policy: ContentSecurityPolicyConfig;
49
+ hashes: Record<string, CspRouteHashes>;
50
+ /** HTTP paths of the static pages (`/`, `/docs`, `/blog/`). */
51
+ staticRoutes: readonly string[];
52
+ }
53
+ export interface HeadersFileInput {
54
+ /** The author's _headers (copied from dist/), or "" when there is none. */
55
+ authored: string;
56
+ /** The build's resolved `security` headers. Absent: every default, as in the Worker. */
57
+ security?: ResponseSecurity;
58
+ /** Normalized base path (`/` or `/shop/`). */
59
+ base: string;
60
+ /** The opt-in `contentSecurityPolicy`, for the static pages. */
61
+ csp?: HeadersFileCsp;
62
+ /** Which deploy the file is for; it decides the fix an error suggests. */
63
+ variant?: "pages" | "workers";
64
+ }
65
+ /**
66
+ * The whole public/_headers text: the site-wide security rule, the static
67
+ * pages' CSP rules, and the author's rules. The author's text unchanged when
68
+ * Bascik has nothing to write; "" when there is no file at all.
69
+ */
70
+ export declare const buildHeadersFile: ({ authored, security, base, csp, variant, }: HeadersFileInput) => string;
71
+ /**
72
+ * The author's _headers rules that set or remove a security header on a page
73
+ * the Worker renders. `_headers` reaches static files only, so on those pages
74
+ * the Worker keeps `security.headers`' value: one warning per rule, naming a
75
+ * page, so the author can move the value into the config.
76
+ */
77
+ export declare const workerPageHeaderOverrides: ({ authored, security, base, workerPages, }: {
78
+ authored: string;
79
+ security?: ResponseSecurity;
80
+ base: string;
81
+ /** HTTP paths of the pages the Worker renders, without the base. */
82
+ workerPages: readonly string[];
83
+ }) => string[];