@cloudflare/pages-shared 0.13.70 → 0.13.72

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 (46) hide show
  1. package/dist/__tests__/asset-server/handler.test.d.ts +2 -0
  2. package/dist/__tests__/asset-server/handler.test.d.ts.map +1 -0
  3. package/dist/__tests__/asset-server/responses.test.d.ts +2 -0
  4. package/dist/__tests__/asset-server/responses.test.d.ts.map +1 -0
  5. package/dist/__tests__/metadata-generator/createMetadataObject.test.d.ts +2 -0
  6. package/dist/__tests__/metadata-generator/createMetadataObject.test.d.ts.map +1 -0
  7. package/dist/asset-server/handler.d.ts +62 -0
  8. package/dist/asset-server/handler.d.ts.map +1 -0
  9. package/dist/asset-server/handler.js +890 -0
  10. package/dist/asset-server/handler.js.map +7 -0
  11. package/dist/asset-server/metadata.d.ts +52 -0
  12. package/dist/asset-server/metadata.d.ts.map +1 -0
  13. package/dist/asset-server/metadata.js +0 -0
  14. package/dist/asset-server/metadata.js.map +7 -0
  15. package/dist/asset-server/patchUrl.d.ts +2 -0
  16. package/dist/asset-server/patchUrl.d.ts.map +1 -0
  17. package/dist/asset-server/patchUrl.js +15 -0
  18. package/dist/asset-server/patchUrl.js.map +7 -0
  19. package/dist/asset-server/responses.d.ts +45 -0
  20. package/dist/asset-server/responses.d.ts.map +1 -0
  21. package/dist/asset-server/responses.js +166 -0
  22. package/dist/asset-server/responses.js.map +7 -0
  23. package/dist/environment-polyfills/html-rewriter.d.ts +9 -0
  24. package/dist/environment-polyfills/html-rewriter.d.ts.map +1 -0
  25. package/dist/environment-polyfills/index.d.ts +3 -0
  26. package/dist/environment-polyfills/index.d.ts.map +1 -0
  27. package/dist/environment-polyfills/miniflare.d.ts +3 -0
  28. package/dist/environment-polyfills/miniflare.d.ts.map +1 -0
  29. package/dist/environment-polyfills/types.d.ts +11 -0
  30. package/dist/environment-polyfills/types.d.ts.map +1 -0
  31. package/dist/metadata-generator/constants.d.ts +14 -0
  32. package/dist/metadata-generator/constants.d.ts.map +1 -0
  33. package/dist/metadata-generator/constants.js +29 -0
  34. package/dist/metadata-generator/constants.js.map +7 -0
  35. package/dist/metadata-generator/createMetadataObject.d.ts +13 -0
  36. package/dist/metadata-generator/createMetadataObject.d.ts.map +1 -0
  37. package/dist/metadata-generator/createMetadataObject.js +174 -0
  38. package/dist/metadata-generator/createMetadataObject.js.map +7 -0
  39. package/dist/metadata-generator/types.d.ts +42 -0
  40. package/dist/metadata-generator/types.d.ts.map +1 -0
  41. package/dist/metadata-generator/types.js +0 -0
  42. package/dist/metadata-generator/types.js.map +7 -0
  43. package/dist/scripts/build.d.ts +2 -0
  44. package/dist/scripts/build.d.ts.map +1 -0
  45. package/dist/tsconfig.build.tsbuildinfo +1 -0
  46. package/package.json +10 -5
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../workers-shared/utils/responses.ts", "../../../workers-shared/asset-worker/src/utils/rules-engine.ts", "../../asset-server/responses.ts", "../../asset-server/handler.ts"],
4
+ "sourcesContent": ["export class OkResponse extends Response {\n\tstatic readonly status = 200;\n\n\tconstructor(body: BodyInit | null, init?: ResponseInit) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: OkResponse.status,\n\t\t});\n\t}\n}\n\nexport class NotFoundResponse extends Response {\n\tstatic readonly status = 404;\n\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: NotFoundResponse.status,\n\t\t\tstatusText: \"Not Found\",\n\t\t});\n\t}\n}\n\n// A magical response type which is used to signal that a user worker should be invoked if one is present.\nexport class NoIntentResponse extends NotFoundResponse {\n\tconstructor() {\n\t\tsuper();\n\t}\n}\n\nexport class MethodNotAllowedResponse extends Response {\n\tstatic readonly status = 405;\n\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: MethodNotAllowedResponse.status,\n\t\t\tstatusText: \"Method Not Allowed\",\n\t\t});\n\t}\n}\n\nexport class InternalServerErrorResponse extends Response {\n\tstatic readonly status = 500;\n\n\tconstructor(_: Error, init?: ResponseInit) {\n\t\tsuper(null, {\n\t\t\t...init,\n\t\t\tstatus: InternalServerErrorResponse.status,\n\t\t});\n\t}\n}\n\nexport class NotModifiedResponse extends Response {\n\tstatic readonly status = 304;\n\n\tconstructor(...[_body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(null, {\n\t\t\t...init,\n\t\t\tstatus: NotModifiedResponse.status,\n\t\t\tstatusText: \"Not Modified\",\n\t\t});\n\t}\n}\n\nexport class MovedPermanentlyResponse extends Response {\n\tstatic readonly status = 301;\n\n\tconstructor(location: string, init?: ResponseInit) {\n\t\tsuper(null, {\n\t\t\t...init,\n\t\t\tstatus: MovedPermanentlyResponse.status,\n\t\t\tstatusText: \"Moved Permanently\",\n\t\t\theaders: {\n\t\t\t\t...init?.headers,\n\t\t\t\tLocation: location,\n\t\t\t},\n\t\t});\n\t}\n}\n\nexport class FoundResponse extends Response {\n\tstatic readonly status = 302;\n\n\tconstructor(location: string, init?: ResponseInit) {\n\t\tsuper(null, {\n\t\t\t...init,\n\t\t\tstatus: FoundResponse.status,\n\t\t\tstatusText: \"Found\",\n\t\t\theaders: {\n\t\t\t\t...init?.headers,\n\t\t\t\tLocation: location,\n\t\t\t},\n\t\t});\n\t}\n}\n\nexport class SeeOtherResponse extends Response {\n\tstatic readonly status = 303;\n\n\tconstructor(location: string, init?: ResponseInit) {\n\t\tsuper(null, {\n\t\t\t...init,\n\t\t\tstatus: SeeOtherResponse.status,\n\t\t\tstatusText: \"See Other\",\n\t\t\theaders: {\n\t\t\t\t...init?.headers,\n\t\t\t\tLocation: location,\n\t\t\t},\n\t\t});\n\t}\n}\n\nexport class TemporaryRedirectResponse extends Response {\n\tstatic readonly status = 307;\n\n\tconstructor(location: string, init?: ResponseInit) {\n\t\tsuper(null, {\n\t\t\t...init,\n\t\t\tstatus: TemporaryRedirectResponse.status,\n\t\t\tstatusText: \"Temporary Redirect\",\n\t\t\theaders: {\n\t\t\t\t...init?.headers,\n\t\t\t\tLocation: location,\n\t\t\t},\n\t\t});\n\t}\n}\n\nexport class PermanentRedirectResponse extends Response {\n\tstatic readonly status = 308;\n\n\tconstructor(location: string, init?: ResponseInit) {\n\t\tsuper(null, {\n\t\t\t...init,\n\t\t\tstatus: PermanentRedirectResponse.status,\n\t\t\tstatusText: \"Permanent Redirect\",\n\t\t\theaders: {\n\t\t\t\t...init?.headers,\n\t\t\t\tLocation: location,\n\t\t\t},\n\t\t});\n\t}\n}\n", "// Taken from https://stackoverflow.com/a/3561711\n// which is everything from the tc39 proposal, plus the following two characters: ^/\n// It's also everything included in the URLPattern escape (https://wicg.github.io/urlpattern/#escape-a-regexp-string), plus the following: -\n\nimport { REDIRECTS_VERSION } from \"../handler\";\nimport type { AssetConfig } from \"../../../utils/types\";\n\n// As the answer says, there's no downside to escaping these extra characters, so better safe than sorry\nconst ESCAPE_REGEX_CHARACTERS = /[-/\\\\^$*+?.()|[\\]{}]/g;\nconst escapeRegex = (str: string) => {\n\treturn str.replace(ESCAPE_REGEX_CHARACTERS, \"\\\\$&\");\n};\n\n// Placeholder names must begin with a colon then a letter, be alphanumeric and optionally contain underscores.\n// e.g. :place_123_holder\nconst HOST_PLACEHOLDER_REGEX =\n\t/(?<=^https:\\\\\\/\\\\\\/[^/]*?):([A-Za-z]\\w*)(?=\\\\)/g;\nconst PLACEHOLDER_REGEX = /:([A-Za-z]\\w*)/g;\n\nexport type Replacements = Record<string, string>;\n\nexport type Removals = string[];\n\nexport const replacer = (str: string, replacements: Replacements) => {\n\tfor (const [replacement, value] of Object.entries(replacements)) {\n\t\tstr = str.replaceAll(`:${replacement}`, value);\n\t}\n\treturn str;\n};\n\nexport const generateGlobOnlyRuleRegExp = (rule: string) => {\n\t// Escape all regex characters other than globs (the \"*\" character) since that's all that's supported.\n\trule = rule.split(\"*\").map(escapeRegex).join(\".*\");\n\n\t// Wrap in line terminators to be safe.\n\trule = \"^\" + rule + \"$\";\n\n\treturn RegExp(rule);\n};\n\nexport const generateRuleRegExp = (rule: string) => {\n\t// Create :splat capturer then escape.\n\trule = rule.split(\"*\").map(escapeRegex).join(\"(?<splat>.*)\");\n\n\t// Create :placeholder capturers (already escaped).\n\t// For placeholders in the host, we separate at forward slashes and periods.\n\t// For placeholders in the path, we separate at forward slashes.\n\t// This matches the behavior of URLPattern.\n\t// e.g. https://:subdomain.domain/ -> https://(here).domain/\n\t// e.g. /static/:file -> /static/(image.jpg)\n\t// e.g. /blog/:post -> /blog/(an-exciting-post)\n\tconst host_matches = rule.matchAll(HOST_PLACEHOLDER_REGEX);\n\tfor (const host_match of host_matches) {\n\t\trule = rule.split(host_match[0]).join(`(?<${host_match[1]}>[^/.]+)`);\n\t}\n\n\tconst path_matches = rule.matchAll(PLACEHOLDER_REGEX);\n\tfor (const path_match of path_matches) {\n\t\trule = rule.split(path_match[0]).join(`(?<${path_match[1]}>[^/]+)`);\n\t}\n\n\t// Wrap in line terminators to be safe.\n\trule = \"^\" + rule + \"$\";\n\n\treturn RegExp(rule);\n};\n\nexport const generateRulesMatcher = <T>(\n\trules?: Record<string, T>,\n\treplacerFn: (match: T, replacements: Replacements) => T = (match) => match\n) => {\n\tif (!rules) {\n\t\treturn () => [];\n\t}\n\n\tconst compiledRules = Object.entries(rules)\n\t\t.map(([rule, match]) => {\n\t\t\tconst crossHost = rule.startsWith(\"https://\");\n\n\t\t\ttry {\n\t\t\t\tconst regExp = generateRuleRegExp(rule);\n\t\t\t\treturn [{ crossHost, regExp }, match];\n\t\t\t} catch {}\n\t\t})\n\t\t.filter((value) => value !== undefined) as [\n\t\t{ crossHost: boolean; regExp: RegExp },\n\t\tT,\n\t][];\n\n\treturn ({ request }: { request: Request }) => {\n\t\tconst { pathname, hostname } = new URL(request.url);\n\n\t\treturn compiledRules\n\t\t\t.map(([{ crossHost, regExp }, match]) => {\n\t\t\t\t// This, rather confusingly, means that although we enforce `https://` protocols in\n\t\t\t\t// the rules of `_headers`/`_redirects`, we don't actually respect that at all at runtime.\n\t\t\t\t// When processing a request against an absolute URL rule, we rewrite the protocol to `https://`.\n\t\t\t\t// This has the benefit of ensuring attackers can't specify a different protocol\n\t\t\t\t// to circumvent a developer's security rules (e.g. CORS), but it isn't obvious behavior.\n\t\t\t\t// We should consider different syntax in the future for developers when they specify rules.\n\t\t\t\t// For example, `*://example.com/path`, `://example.com/path` or `//example.com/`.\n\t\t\t\t// Though we'd need to be careful with that last one\n\t\t\t\t// as that would currently be read as a relative URL.\n\t\t\t\t// Perhaps, if we ever move the `_headers`/`_redirects` files to acting ahead of Functions,\n\t\t\t\t// this might be a good time for this change.\n\t\t\t\tconst test = crossHost ? `https://${hostname}${pathname}` : pathname;\n\t\t\t\tconst result = regExp.exec(test);\n\t\t\t\tif (result) {\n\t\t\t\t\treturn replacerFn(match, result.groups || {});\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((value) => value !== undefined) as T[];\n\t};\n};\n\nexport const staticRedirectsMatcher = (\n\tconfiguration: Required<AssetConfig>,\n\thost: string,\n\tpathname: string\n) => {\n\tconst withHostMatch =\n\t\tconfiguration.redirects.staticRules[`https://${host}${pathname}`];\n\tconst withoutHostMatch = configuration.redirects.staticRules[pathname];\n\n\tif (withHostMatch && withoutHostMatch) {\n\t\tif (withHostMatch.lineNumber < withoutHostMatch.lineNumber) {\n\t\t\treturn withHostMatch;\n\t\t} else {\n\t\t\treturn withoutHostMatch;\n\t\t}\n\t}\n\n\treturn withHostMatch || withoutHostMatch;\n};\n\nexport const generateRedirectsMatcher = (\n\tconfiguration: Required<AssetConfig>\n) =>\n\tgenerateRulesMatcher(\n\t\tconfiguration.redirects.version === REDIRECTS_VERSION\n\t\t\t? configuration.redirects.rules\n\t\t\t: {},\n\t\t({ status, to }, replacements) => {\n\t\t\tconst target = replacer(to, replacements).trim();\n\t\t\tconst protoPattern = /^(\\w+:\\/\\/)/;\n\t\t\tif (protoPattern.test(target)) {\n\t\t\t\t// External redirects are not modified.\n\t\t\t\treturn {\n\t\t\t\t\tstatus,\n\t\t\t\t\tto: target,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// Relative redirects are modified to remove multiple slashes.\n\t\t\t\treturn {\n\t\t\t\t\tstatus,\n\t\t\t\t\tto: target.replace(/\\/+/g, \"/\"),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t);\n\nexport const generateStaticRoutingRuleMatcher =\n\t(rules: string[]) =>\n\t({ request }: { request: Request }) => {\n\t\tconst { pathname } = new URL(request.url);\n\t\tfor (const rule of rules) {\n\t\t\ttry {\n\t\t\t\tconst regExp = generateGlobOnlyRuleRegExp(rule);\n\t\t\t\tif (regExp.test(pathname)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\treturn false;\n\t};\n", "type HeadersInit = ConstructorParameters<typeof Headers>[0];\n\nfunction mergeHeaders(base: HeadersInit, extra: HeadersInit) {\n\tconst baseHeaders = new Headers(base ?? {});\n\tconst extraHeaders = new Headers(extra ?? {});\n\n\treturn new Headers({\n\t\t...Object.fromEntries(baseHeaders.entries()),\n\t\t...Object.fromEntries(extraHeaders.entries()),\n\t});\n}\n\nexport function stripLeadingDoubleSlashes(location: string) {\n\treturn location.replace(/^(\\/|%2F|%2f|%5C|%5c|%09|\\s|\\\\)+(.*)/, \"/$2\");\n}\n\nexport class OkResponse extends Response {\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 200,\n\t\t\tstatusText: \"OK\",\n\t\t});\n\t}\n}\n\nexport class MovedPermanentlyResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(`Redirecting to ${location}`, {\n\t\t\t...init,\n\t\t\tstatus: 301,\n\t\t\tstatusText: \"Moved Permanently\",\n\t\t\theaders: mergeHeaders(init?.headers, {\n\t\t\t\tlocation,\n\t\t\t}),\n\t\t});\n\t}\n}\n\nexport class FoundResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(`Redirecting to ${location}`, {\n\t\t\t...init,\n\t\t\tstatus: 302,\n\t\t\tstatusText: \"Found\",\n\t\t\theaders: mergeHeaders(init?.headers, {\n\t\t\t\tlocation,\n\t\t\t}),\n\t\t});\n\t}\n}\n\nexport class NotModifiedResponse extends Response {\n\tconstructor(...[_body, _init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(undefined, {\n\t\t\tstatus: 304,\n\t\t\tstatusText: \"Not Modified\",\n\t\t});\n\t}\n}\n\nexport class PermanentRedirectResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(undefined, {\n\t\t\t...init,\n\t\t\tstatus: 308,\n\t\t\tstatusText: \"Permanent Redirect\",\n\t\t\theaders: mergeHeaders(init?.headers, {\n\t\t\t\tlocation,\n\t\t\t}),\n\t\t});\n\t}\n}\n\nexport class NotFoundResponse extends Response {\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 404,\n\t\t\tstatusText: \"Not Found\",\n\t\t});\n\t}\n}\n\nexport class MethodNotAllowedResponse extends Response {\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 405,\n\t\t\tstatusText: \"Method Not Allowed\",\n\t\t});\n\t}\n}\n\nexport class NotAcceptableResponse extends Response {\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 406,\n\t\t\tstatusText: \"Not Acceptable\",\n\t\t});\n\t}\n}\n\nexport class InternalServerErrorResponse extends Response {\n\tconstructor(err: Error, init?: ConstructorParameters<typeof Response>[1]) {\n\t\tlet body: string | undefined = undefined;\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tif ((globalThis as any).DEBUG) {\n\t\t\tbody = `${err.message}\\n\\n${err.stack}`;\n\t\t}\n\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 500,\n\t\t\tstatusText: \"Internal Server Error\",\n\t\t});\n\t}\n}\n\nexport class SeeOtherResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(`Redirecting to ${location}`, {\n\t\t\t...init,\n\t\t\tstatus: 303,\n\t\t\tstatusText: \"See Other\",\n\t\t\theaders: mergeHeaders(init?.headers, { location }),\n\t\t});\n\t}\n}\n\nexport class TemporaryRedirectResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(`Redirecting to ${location}`, {\n\t\t\t...init,\n\t\t\tstatus: 307,\n\t\t\tstatusText: \"Temporary Redirect\",\n\t\t\theaders: mergeHeaders(init?.headers, { location }),\n\t\t});\n\t}\n}\n", "import {\n\tgenerateRulesMatcher,\n\treplacer,\n} from \"@cloudflare/workers-shared/asset-worker/src/utils/rules-engine\";\nimport {\n\tFoundResponse,\n\tInternalServerErrorResponse,\n\tMethodNotAllowedResponse,\n\tMovedPermanentlyResponse,\n\tNotAcceptableResponse,\n\tNotFoundResponse,\n\tNotModifiedResponse,\n\tOkResponse,\n\tPermanentRedirectResponse,\n\tSeeOtherResponse,\n\tTemporaryRedirectResponse,\n} from \"./responses\";\nimport type {\n\tMetadata,\n\tMetadataHeadersEntries,\n\tMetadataHeadersRulesV2,\n\tMetadataHeadersV1,\n\tMetadataHeadersV2,\n} from \"./metadata\";\n\ntype BodyEncoding = \"manual\" | \"automatic\";\n\n// Before serving a 404, we check the cache to see if we've served this asset recently\n// and if so, serve it from the cache instead of responding with a 404.\n// This gives a bit of a grace period between deployments for any clients browsing the old deployment.\n// Only the content hash is actually stored in the body.\nexport const ASSET_PRESERVATION_CACHE = \"assetPreservationCacheV2\";\nconst CACHE_CONTROL_PRESERVATION = \"public, s-maxage=604800\"; // 1 week\n\n/** The preservation cache should be periodically\n * written to so that the age / expiration is reset.\n * Note: Up to 12 hours of jitter added to this value.\n */\nexport const CACHE_PRESERVATION_WRITE_FREQUENCY = 86_400; // 1 day\n\nexport const CACHE_CONTROL_BROWSER = \"public, max-age=0, must-revalidate\"; // have the browser check in with the server to make sure its local cache is valid before using it\nexport const REDIRECTS_VERSION = 1;\nexport const HEADERS_VERSION = 2;\nexport const HEADERS_VERSION_V1 = 1;\nexport const ANALYTICS_VERSION = 1;\n\n// In rolling this out, we're taking a conservative approach to only generate these Link headers from <link> elements that have these attributes.\n// We'll ignore any <link> elements that contain other attributes (e.g. `fetchpriority`, `crossorigin` or `data-please-dont-generate-a-header`).\n// We're not confident in browser support for all of these additional attributes, so we'll wait until we have that information before proceeding further.\nconst ALLOWED_EARLY_HINT_LINK_ATTRIBUTES = [\"rel\", \"as\", \"href\"];\n\n// Takes metadata headers and \"normalise\" them\n// to the latest version\nexport function normaliseHeaders(\n\theaders: MetadataHeadersV1 | MetadataHeadersV2\n): MetadataHeadersRulesV2 {\n\tif (headers.version === HEADERS_VERSION) {\n\t\treturn headers.rules;\n\t} else if (headers.version === HEADERS_VERSION_V1) {\n\t\treturn Object.keys(headers.rules).reduce(\n\t\t\t(acc: MetadataHeadersRulesV2, key) => {\n\t\t\t\tacc[key] = {\n\t\t\t\t\tset: headers.rules[key] as MetadataHeadersEntries,\n\t\t\t\t};\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t} else {\n\t\treturn {};\n\t}\n}\n\ntype FindAssetEntryForPath<AssetEntry> = (\n\tpath: string\n) => Promise<null | AssetEntry>;\n\nfunction generateETagHeader(assetKey: string) {\n\t// https://support.cloudflare.com/hc/en-us/articles/218505467-Using-ETag-Headers-with-Cloudflare\n\t// We sometimes remove etags unless they are wrapped in quotes\n\tconst strongETag = `\"${assetKey}\"`;\n\tconst weakETag = `W/\"${assetKey}\"`;\n\treturn { strongETag, weakETag };\n}\n\nfunction checkIfNoneMatch(\n\trequest: Request,\n\tstrongETag: string,\n\tweakETag: string\n) {\n\tconst ifNoneMatch = request.headers.get(\"if-none-match\");\n\n\t// We sometimes downgrade strong etags to a weak ones, so we need to check for both\n\treturn ifNoneMatch === weakETag || ifNoneMatch === strongETag;\n}\n\ntype ServeAsset<AssetEntry> = (\n\tassetEntry: AssetEntry,\n\toptions?: { preserve: boolean }\n) => Promise<Response>;\n\ntype CacheStatus = \"hit\" | \"miss\";\ntype CacheResult<A extends string> = `${A}-${CacheStatus}`;\nexport type HandlerMetrics = {\n\tpreservationCacheResult?:\n\t\t| CacheResult<\"checked\">\n\t\t| \"not-modified\"\n\t\t| \"disabled\";\n\tearlyHintsResult?: CacheResult<\"used\" | \"notused\"> | \"disabled\";\n};\n\ntype FullHandlerContext<AssetEntry, ContentNegotiation, Asset> = {\n\trequest: Request;\n\tmetadata: Metadata;\n\txServerEnvHeader?: string;\n\txDeploymentIdHeader?: boolean;\n\txWebAnalyticsHeader?: boolean;\n\tlogError: (err: Error) => void;\n\tsetMetrics?: (metrics: HandlerMetrics) => void;\n\tfindAssetEntryForPath: FindAssetEntryForPath<AssetEntry>;\n\tgetAssetKey(assetEntry: AssetEntry, content: ContentNegotiation): string;\n\tnegotiateContent(\n\t\trequest: Request,\n\t\tassetEntry: AssetEntry\n\t): ContentNegotiation;\n\tfetchAsset: (assetKey: string) => Promise<Asset>;\n\tgenerateNotFoundResponse?: (\n\t\trequest: Request,\n\t\tfindAssetEntryForPath: FindAssetEntryForPath<AssetEntry>,\n\t\tserveAsset: ServeAsset<AssetEntry>\n\t) => Promise<Response>;\n\tattachAdditionalHeaders?: (\n\t\tresponse: Response,\n\t\tcontent: ContentNegotiation,\n\t\tassetEntry: AssetEntry,\n\t\tasset: Asset\n\t) => void;\n\tcaches: CacheStorage;\n\twaitUntil: (promise: Promise<unknown>) => void;\n};\n\nexport type HandlerContext<AssetEntry, ContentNegotiation, Asset> =\n\t| FullHandlerContext<AssetEntry, ContentNegotiation, Asset>\n\t| (Omit<\n\t\t\tFullHandlerContext<AssetEntry, ContentNegotiation, Asset>,\n\t\t\t\"caches\" | \"waitUntil\"\n\t > & {\n\t\t\tcaches?: undefined;\n\t\t\twaitUntil?: undefined;\n\t });\n\nexport async function generateHandler<\n\tAssetEntry,\n\tContentNegotiation extends { encoding: string | null } = {\n\t\tencoding: string | null;\n\t},\n\tAsset extends { body: ReadableStream | null; contentType: string } = {\n\t\tbody: ReadableStream | null;\n\t\tcontentType: string;\n\t},\n>({\n\trequest,\n\tmetadata,\n\txServerEnvHeader,\n\txDeploymentIdHeader,\n\txWebAnalyticsHeader,\n\tlogError,\n\tsetMetrics,\n\tfindAssetEntryForPath,\n\tgetAssetKey,\n\tnegotiateContent,\n\tfetchAsset,\n\tgenerateNotFoundResponse = async (\n\t\tnotFoundRequest,\n\t\tnotFoundFindAssetEntryForPath,\n\t\tnotFoundServeAsset\n\t) => {\n\t\tlet assetEntry: AssetEntry | null;\n\t\t// No custom 404 page, so try serving as a single-page app\n\t\tif ((assetEntry = await notFoundFindAssetEntryForPath(\"/index.html\"))) {\n\t\t\treturn notFoundServeAsset(assetEntry, { preserve: false });\n\t\t}\n\n\t\treturn new NotFoundResponse();\n\t},\n\tattachAdditionalHeaders = () => {},\n\tcaches,\n\twaitUntil,\n}: HandlerContext<AssetEntry, ContentNegotiation, Asset>) {\n\tconst url = new URL(request.url);\n\tconst { protocol, host, search } = url;\n\tlet { pathname } = url;\n\n\tconst earlyHintsCache = metadata.deploymentId\n\t\t? await caches?.open(`eh:${metadata.deploymentId}`)\n\t\t: undefined;\n\n\tconst headerRules = metadata.headers\n\t\t? normaliseHeaders(metadata.headers)\n\t\t: {};\n\n\tconst staticRules =\n\t\tmetadata.redirects?.version === REDIRECTS_VERSION\n\t\t\t? metadata.redirects.staticRules || {}\n\t\t\t: {};\n\n\tconst staticRedirectsMatcher = () => {\n\t\tconst withHostMatch = staticRules[`https://${host}${pathname}`];\n\t\tconst withoutHostMatch = staticRules[pathname];\n\n\t\tif (withHostMatch && withoutHostMatch) {\n\t\t\tif (withHostMatch.lineNumber < withoutHostMatch.lineNumber) {\n\t\t\t\treturn withHostMatch;\n\t\t\t} else {\n\t\t\t\treturn withoutHostMatch;\n\t\t\t}\n\t\t}\n\n\t\treturn withHostMatch || withoutHostMatch;\n\t};\n\n\tconst generateRedirectsMatcher = () =>\n\t\tgenerateRulesMatcher(\n\t\t\tmetadata.redirects?.version === REDIRECTS_VERSION\n\t\t\t\t? metadata.redirects.rules\n\t\t\t\t: {},\n\t\t\t({ status, to }, replacements) => ({\n\t\t\t\tstatus,\n\t\t\t\tto: replacer(to, replacements),\n\t\t\t})\n\t\t);\n\n\tlet assetEntry: AssetEntry | null;\n\n\tasync function generateResponse(): Promise<Response> {\n\t\tconst match =\n\t\t\tstaticRedirectsMatcher() || generateRedirectsMatcher()({ request })[0];\n\n\t\tif (match) {\n\t\t\tif (match.status === 200) {\n\t\t\t\t// A 200 redirect means that we are proxying to a different asset, for example,\n\t\t\t\t// a request with url /users/12345 could be pointed to /users/id.html. In order to\n\t\t\t\t// do this, we overwrite the pathname, and instead match for assets with that url,\n\t\t\t\t// and importantly, do not use the regular redirect handler - as the url visible to\n\t\t\t\t// the user does not change\n\t\t\t\tpathname = new URL(match.to, request.url).pathname;\n\t\t\t} else {\n\t\t\t\tconst { status, to } = match;\n\t\t\t\tconst destination = new URL(to, request.url);\n\t\t\t\tconst location =\n\t\t\t\t\tdestination.origin === new URL(request.url).origin\n\t\t\t\t\t\t? `${destination.pathname}${destination.search || search}${\n\t\t\t\t\t\t\t\tdestination.hash\n\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t: `${destination.href.slice(0, destination.href.length - (destination.search.length + destination.hash.length))}${\n\t\t\t\t\t\t\t\tdestination.search ? destination.search : search\n\t\t\t\t\t\t\t}${destination.hash}`;\n\n\t\t\t\tswitch (status) {\n\t\t\t\t\tcase 301:\n\t\t\t\t\t\treturn new MovedPermanentlyResponse(location, undefined, {\n\t\t\t\t\t\t\tpreventLeadingDoubleSlash: false,\n\t\t\t\t\t\t});\n\t\t\t\t\tcase 303:\n\t\t\t\t\t\treturn new SeeOtherResponse(location, undefined, {\n\t\t\t\t\t\t\tpreventLeadingDoubleSlash: false,\n\t\t\t\t\t\t});\n\t\t\t\t\tcase 307:\n\t\t\t\t\t\treturn new TemporaryRedirectResponse(location, undefined, {\n\t\t\t\t\t\t\tpreventLeadingDoubleSlash: false,\n\t\t\t\t\t\t});\n\t\t\t\t\tcase 308:\n\t\t\t\t\t\treturn new PermanentRedirectResponse(location, undefined, {\n\t\t\t\t\t\t\tpreventLeadingDoubleSlash: false,\n\t\t\t\t\t\t});\n\t\t\t\t\tcase 302:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn new FoundResponse(location, undefined, {\n\t\t\t\t\t\t\tpreventLeadingDoubleSlash: false,\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!request.method.match(/^(get|head)$/i)) {\n\t\t\treturn new MethodNotAllowedResponse();\n\t\t}\n\n\t\ttry {\n\t\t\tpathname = globalThis.decodeURIComponent(pathname);\n\t\t} catch {}\n\n\t\tif (pathname.endsWith(\"/\")) {\n\t\t\tif ((assetEntry = await findAssetEntryForPath(`${pathname}index.html`))) {\n\t\t\t\treturn serveAsset(assetEntry);\n\t\t\t} else if (pathname.endsWith(\"/index/\")) {\n\t\t\t\treturn new PermanentRedirectResponse(\n\t\t\t\t\t`/${pathname.slice(1, -\"index/\".length)}${search}`\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\t(assetEntry = await findAssetEntryForPath(\n\t\t\t\t\t`${pathname.replace(/\\/$/, \".html\")}`\n\t\t\t\t))\n\t\t\t) {\n\t\t\t\treturn new PermanentRedirectResponse(\n\t\t\t\t\t`/${pathname.slice(1, -1)}${search}`\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn notFound();\n\t\t\t}\n\t\t}\n\n\t\tif ((assetEntry = await findAssetEntryForPath(pathname))) {\n\t\t\tif (pathname.endsWith(\".html\")) {\n\t\t\t\tconst extensionlessPath = pathname.slice(0, -\".html\".length);\n\t\t\t\t// Don't redirect to an extensionless URL if another asset exists there\n\t\t\t\t// or if pathname is /.html\n\t\t\t\t// FIXME: this doesn't handle files in directories ie: /foobar/.html\n\t\t\t\tif (extensionlessPath.endsWith(\"/index\")) {\n\t\t\t\t\treturn new PermanentRedirectResponse(\n\t\t\t\t\t\t`${extensionlessPath.replace(/\\/index$/, \"/\")}${search}`\n\t\t\t\t\t);\n\t\t\t\t} else if (\n\t\t\t\t\t(await findAssetEntryForPath(extensionlessPath)) ||\n\t\t\t\t\textensionlessPath === \"/\"\n\t\t\t\t) {\n\t\t\t\t\treturn serveAsset(assetEntry);\n\t\t\t\t} else {\n\t\t\t\t\treturn new PermanentRedirectResponse(`${extensionlessPath}${search}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn serveAsset(assetEntry);\n\t\t\t}\n\t\t} else if (pathname.endsWith(\"/index\")) {\n\t\t\treturn new PermanentRedirectResponse(\n\t\t\t\t`/${pathname.slice(1, -\"index\".length)}${search}`\n\t\t\t);\n\t\t} else if ((assetEntry = await findAssetEntryForPath(`${pathname}.html`))) {\n\t\t\treturn serveAsset(assetEntry);\n\t\t}\n\n\t\tif ((assetEntry = await findAssetEntryForPath(`${pathname}/index.html`))) {\n\t\t\treturn new PermanentRedirectResponse(`${pathname}/${search}`);\n\t\t} else {\n\t\t\treturn notFound();\n\t\t}\n\t}\n\n\tfunction isNullBodyStatus(status: number): boolean {\n\t\treturn [101, 204, 205, 304].includes(status);\n\t}\n\n\tasync function attachHeaders(response: Response) {\n\t\tconst existingHeaders = new Headers(response.headers);\n\t\tconst eTag = existingHeaders.get(\"eTag\")?.match(/^\"(.*)\"$/)?.[1];\n\n\t\tconst extraHeaders = new Headers({\n\t\t\t\"access-control-allow-origin\": \"*\",\n\t\t\t\"referrer-policy\": \"strict-origin-when-cross-origin\",\n\t\t\t...(existingHeaders.has(\"content-type\")\n\t\t\t\t? { \"x-content-type-options\": \"nosniff\" }\n\t\t\t\t: {}),\n\t\t});\n\n\t\tconst headers = new Headers({\n\t\t\t// But we intentionally override existing headers\n\t\t\t...Object.fromEntries(existingHeaders.entries()),\n\t\t\t...Object.fromEntries(extraHeaders.entries()),\n\t\t});\n\n\t\tif (\n\t\t\tearlyHintsCache &&\n\t\t\tisHTMLContentType(response.headers.get(\"Content-Type\")) &&\n\t\t\teTag\n\t\t) {\n\t\t\tconst preEarlyHintsHeaders = new Headers(headers);\n\n\t\t\t// \"Early Hints cache entries are keyed by request URI and ignore query strings.\"\n\t\t\t// https://developers.cloudflare.com/cache/about/early-hints/\n\t\t\tconst earlyHintsCacheKey = `${protocol}//${host}/${eTag}`;\n\t\t\tconst earlyHintsResponse =\n\t\t\t\tawait earlyHintsCache.match(earlyHintsCacheKey);\n\t\t\tif (earlyHintsResponse) {\n\t\t\t\tconst earlyHintsLinkHeader = earlyHintsResponse.headers.get(\"Link\");\n\t\t\t\tif (earlyHintsLinkHeader) {\n\t\t\t\t\theaders.set(\"Link\", earlyHintsLinkHeader);\n\t\t\t\t\tif (setMetrics) {\n\t\t\t\t\t\tsetMetrics({ earlyHintsResult: \"used-hit\" });\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (setMetrics) {\n\t\t\t\t\t\tsetMetrics({ earlyHintsResult: \"notused-hit\" });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (setMetrics) {\n\t\t\t\t\tsetMetrics({ earlyHintsResult: \"notused-miss\" });\n\t\t\t\t}\n\n\t\t\t\tconst clonedResponse = response.clone();\n\n\t\t\t\tif (waitUntil) {\n\t\t\t\t\twaitUntil(\n\t\t\t\t\t\t(async () => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst links: { href: string; rel: string; as?: string }[] = [];\n\n\t\t\t\t\t\t\t\tconst transformedResponse = new HTMLRewriter()\n\t\t\t\t\t\t\t\t\t.on(\n\t\t\t\t\t\t\t\t\t\t\"link[rel~=preconnect],link[rel~=preload],link[rel~=modulepreload]\",\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\telement(element) {\n\t\t\t\t\t\t\t\t\t\t\t\tfor (const [attributeName] of element.attributes) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t!ALLOWED_EARLY_HINT_LINK_ATTRIBUTES.includes(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tattributeName.toLowerCase()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tconst href = element.getAttribute(\"href\") || undefined;\n\t\t\t\t\t\t\t\t\t\t\t\tconst rel = element.getAttribute(\"rel\") || undefined;\n\t\t\t\t\t\t\t\t\t\t\t\tconst as = element.getAttribute(\"as\") || undefined;\n\t\t\t\t\t\t\t\t\t\t\t\tif (href && !href.startsWith(\"data:\") && rel) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlinks.push({ href, rel, as });\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.transform(clonedResponse);\n\n\t\t\t\t\t\t\t\t// Needed to actually execute the HTMLRewriter handlers\n\t\t\t\t\t\t\t\tawait transformedResponse.text();\n\n\t\t\t\t\t\t\t\tlinks.forEach(({ href, rel, as }) => {\n\t\t\t\t\t\t\t\t\tlet link = `<${href}>; rel=\"${rel}\"`;\n\t\t\t\t\t\t\t\t\tif (as) {\n\t\t\t\t\t\t\t\t\t\tlink += `; as=${as}`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tpreEarlyHintsHeaders.append(\"Link\", link);\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tconst linkHeader = preEarlyHintsHeaders.get(\"Link\");\n\t\t\t\t\t\t\t\tconst earlyHintsHeaders = new Headers({\n\t\t\t\t\t\t\t\t\t\"Cache-Control\": \"max-age=2592000\", // 30 days\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (linkHeader) {\n\t\t\t\t\t\t\t\t\tearlyHintsHeaders.append(\"Link\", linkHeader);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tawait earlyHintsCache.put(\n\t\t\t\t\t\t\t\t\tearlyHintsCacheKey,\n\t\t\t\t\t\t\t\t\tnew Response(null, { headers: earlyHintsHeaders })\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t// Nbd if we fail here in the deferred 'waitUntil' work. We're probably trying to parse a malformed page or something.\n\t\t\t\t\t\t\t\t// Totally fine to skip over any errors.\n\t\t\t\t\t\t\t\t// If we need to debug something, you can uncomment the following:\n\t\t\t\t\t\t\t\t// logError(err)\n\t\t\t\t\t\t\t\t// In any case, let's not bother checking again for another day.\n\t\t\t\t\t\t\t\tawait earlyHintsCache.put(\n\t\t\t\t\t\t\t\t\tearlyHintsCacheKey,\n\t\t\t\t\t\t\t\t\tnew Response(null, {\n\t\t\t\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t\t\t\t\"Cache-Control\": \"max-age=86400\", // 1 day\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})()\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (setMetrics) {\n\t\t\t\tsetMetrics({ earlyHintsResult: \"disabled\" });\n\t\t\t}\n\t\t}\n\n\t\t// Iterate through rules and find rules that match the path\n\t\tconst headersMatcher = generateRulesMatcher(\n\t\t\theaderRules,\n\t\t\t({ set = {}, unset = [] }, replacements) => {\n\t\t\t\tconst replacedSet: Record<string, string> = {};\n\t\t\t\tObject.keys(set).forEach((key) => {\n\t\t\t\t\treplacedSet[key] = replacer(set[key], replacements);\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tset: replacedSet,\n\t\t\t\t\tunset,\n\t\t\t\t};\n\t\t\t}\n\t\t);\n\t\tconst matches = headersMatcher({ request });\n\n\t\t// This keeps track of every header that we've set from _headers\n\t\t// because we want to combine user declared headers but overwrite\n\t\t// existing and extra ones\n\t\tconst setMap = new Set();\n\t\t// Apply every matched rule in order\n\t\tmatches.forEach(({ set = {}, unset = [] }) => {\n\t\t\tunset.forEach((key) => {\n\t\t\t\theaders.delete(key);\n\t\t\t});\n\t\t\tObject.keys(set).forEach((key) => {\n\t\t\t\tif (setMap.has(key.toLowerCase())) {\n\t\t\t\t\theaders.append(key, set[key]);\n\t\t\t\t} else {\n\t\t\t\t\theaders.set(key, set[key]);\n\t\t\t\t\tsetMap.add(key.toLowerCase());\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t// https://fetch.spec.whatwg.org/#null-body-status\n\t\treturn new Response(\n\t\t\tisNullBodyStatus(response.status) ? null : response.body,\n\t\t\t{\n\t\t\t\theaders: headers,\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t}\n\t\t);\n\t}\n\n\tconst responseWithoutHeaders = await generateResponse();\n\tif (responseWithoutHeaders.status >= 500) {\n\t\treturn responseWithoutHeaders;\n\t}\n\n\tconst responseWithHeaders = await attachHeaders(responseWithoutHeaders);\n\tif (responseWithHeaders.status === 404) {\n\t\t// Remove any user-controlled cache-control headers\n\t\t// This is to prevent the footgun of potentionally caching this 404 for a long time\n\t\tif (responseWithHeaders.headers.has(\"cache-control\")) {\n\t\t\tresponseWithHeaders.headers.delete(\"cache-control\");\n\t\t}\n\t\t// Add cache-control: no-store to prevent this from being cached on the responding zones.\n\t\tresponseWithHeaders.headers.append(\"cache-control\", \"no-store\");\n\t}\n\n\treturn responseWithHeaders;\n\n\tasync function serveAsset(\n\t\tservingAssetEntry: AssetEntry,\n\t\toptions = { preserve: true }\n\t): Promise<Response> {\n\t\tlet content: ContentNegotiation;\n\t\ttry {\n\t\t\tcontent = negotiateContent(request, servingAssetEntry);\n\t\t} catch {\n\t\t\treturn new NotAcceptableResponse();\n\t\t}\n\n\t\tconst assetKey = getAssetKey(servingAssetEntry, content);\n\n\t\tconst { strongETag, weakETag } = generateETagHeader(assetKey);\n\t\tconst isIfNoneMatch = checkIfNoneMatch(request, strongETag, weakETag);\n\t\tif (isIfNoneMatch) {\n\t\t\treturn new NotModifiedResponse();\n\t\t}\n\n\t\ttry {\n\t\t\tconst asset = await fetchAsset(assetKey);\n\t\t\tconst headers: Record<string, string> = {\n\t\t\t\tetag: strongETag,\n\t\t\t\t\"content-type\": asset.contentType,\n\t\t\t};\n\t\t\tlet encodeBody: BodyEncoding = \"automatic\";\n\n\t\t\tif (xServerEnvHeader) {\n\t\t\t\theaders[\"x-server-env\"] = xServerEnvHeader;\n\t\t\t}\n\n\t\t\tif (xDeploymentIdHeader && metadata.deploymentId) {\n\t\t\t\theaders[\"x-deployment-id\"] = metadata.deploymentId;\n\t\t\t}\n\n\t\t\tif (content.encoding) {\n\t\t\t\tencodeBody = \"manual\";\n\t\t\t\theaders[\"cache-control\"] = \"no-transform\";\n\t\t\t\theaders[\"content-encoding\"] = content.encoding;\n\t\t\t}\n\n\t\t\tconst response = new OkResponse(\n\t\t\t\trequest.method === \"HEAD\" ? null : asset.body,\n\t\t\t\t{\n\t\t\t\t\theaders,\n\t\t\t\t\tencodeBody,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif (isCacheable(request)) {\n\t\t\t\tresponse.headers.append(\"cache-control\", CACHE_CONTROL_BROWSER);\n\t\t\t}\n\n\t\t\tattachAdditionalHeaders(response, content, servingAssetEntry, asset);\n\n\t\t\tif (isPreview(new URL(request.url))) {\n\t\t\t\tresponse.headers.set(\"x-robots-tag\", \"noindex\");\n\t\t\t}\n\n\t\t\tif (options.preserve && waitUntil && caches) {\n\t\t\t\twaitUntil(\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst assetPreservationCache = await caches.open(\n\t\t\t\t\t\t\t\tASSET_PRESERVATION_CACHE\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Check if the asset has changed since last written to cache\n\t\t\t\t\t\t\t// or if the cached entry is getting too old and should have\n\t\t\t\t\t\t\t// it's expiration reset.\n\t\t\t\t\t\t\tconst match = await assetPreservationCache.match(request);\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!match ||\n\t\t\t\t\t\t\t\tassetKey !== (await match.text()) ||\n\t\t\t\t\t\t\t\tisPreservationCacheResponseExpiring(match)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// cache the asset key in the cache with all the headers.\n\t\t\t\t\t\t\t\t// When we read it back, we'll re-fetch the body but use the\n\t\t\t\t\t\t\t\t// cached headers.\n\t\t\t\t\t\t\t\tconst preservedResponse = new Response(assetKey, response);\n\t\t\t\t\t\t\t\tpreservedResponse.headers.set(\n\t\t\t\t\t\t\t\t\t\"cache-control\",\n\t\t\t\t\t\t\t\t\tCACHE_CONTROL_PRESERVATION\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tpreservedResponse.headers.set(\"x-robots-tag\", \"noindex\");\n\n\t\t\t\t\t\t\t\tawait assetPreservationCache.put(\n\t\t\t\t\t\t\t\t\trequest.url,\n\t\t\t\t\t\t\t\t\tpreservedResponse\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tlogError(err as Error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})()\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tisHTMLContentType(asset.contentType) &&\n\t\t\t\tmetadata.analytics?.version === ANALYTICS_VERSION\n\t\t\t) {\n\t\t\t\tif (xWebAnalyticsHeader) {\n\t\t\t\t\tresponse.headers.set(\"x-cf-pages-analytics\", \"1\");\n\t\t\t\t}\n\t\t\t\treturn new HTMLRewriter()\n\t\t\t\t\t.on(\"body\", {\n\t\t\t\t\t\telement(e) {\n\t\t\t\t\t\t\te.append(\n\t\t\t\t\t\t\t\t`<!-- Cloudflare Pages Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{\"token\": \"${metadata.analytics?.token}\"}'></script><!-- Cloudflare Pages Analytics -->`,\n\t\t\t\t\t\t\t\t{ html: true }\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\t.transform(response);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t} catch (err) {\n\t\t\tlogError(err as Error);\n\t\t\treturn new InternalServerErrorResponse(err as Error);\n\t\t}\n\t}\n\n\tasync function notFound(): Promise<Response> {\n\t\tif (caches) {\n\t\t\ttry {\n\t\t\t\tconst assetPreservationCache = await caches.open(\n\t\t\t\t\tASSET_PRESERVATION_CACHE\n\t\t\t\t);\n\t\t\t\tconst preservedResponse = await assetPreservationCache.match(\n\t\t\t\t\trequest.url\n\t\t\t\t);\n\n\t\t\t\t// V2 cache only contains the asset key, rather than the asset body:\n\t\t\t\tif (preservedResponse) {\n\t\t\t\t\tif (setMetrics) {\n\t\t\t\t\t\tsetMetrics({ preservationCacheResult: \"checked-hit\" });\n\t\t\t\t\t}\n\t\t\t\t\t// Always read the asset key to prevent hanging responses\n\t\t\t\t\tconst assetKey = await preservedResponse.text();\n\t\t\t\t\tif (isNullBodyStatus(preservedResponse.status)) {\n\t\t\t\t\t\t// We know the asset hasn't changed, so use the cached headers.\n\t\t\t\t\t\treturn new Response(null, preservedResponse);\n\t\t\t\t\t}\n\t\t\t\t\tif (assetKey) {\n\t\t\t\t\t\tconst { strongETag, weakETag } = generateETagHeader(assetKey);\n\t\t\t\t\t\tconst isIfNoneMatch = checkIfNoneMatch(\n\t\t\t\t\t\t\trequest,\n\t\t\t\t\t\t\tstrongETag,\n\t\t\t\t\t\t\tweakETag\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (isIfNoneMatch) {\n\t\t\t\t\t\t\tif (setMetrics) {\n\t\t\t\t\t\t\t\tsetMetrics({ preservationCacheResult: \"not-modified\" });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn new NotModifiedResponse();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst asset = await fetchAsset(assetKey);\n\n\t\t\t\t\t\tif (asset) {\n\t\t\t\t\t\t\t// We know the asset hasn't changed, so use the cached headers.\n\t\t\t\t\t\t\treturn new Response(asset.body, preservedResponse);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlogError(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t`preservation cache contained assetKey that does not exist in storage: ${assetKey}`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogError(new Error(`cached response had no assetKey: ${assetKey}`));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (setMetrics) {\n\t\t\t\t\t\tsetMetrics({ preservationCacheResult: \"checked-miss\" });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t// Don't throw an error because preservation cache is best effort.\n\t\t\t\t// But log it because we should be able to fetch the asset here.\n\t\t\t\tlogError(err as Error);\n\t\t\t}\n\t\t} else {\n\t\t\tif (setMetrics) {\n\t\t\t\tsetMetrics({ preservationCacheResult: \"disabled\" });\n\t\t\t}\n\t\t}\n\n\t\t// Traverse upwards from the current path looking for a custom 404 page\n\t\tlet cwd = pathname;\n\t\twhile (cwd) {\n\t\t\tcwd = cwd.slice(0, cwd.lastIndexOf(\"/\"));\n\n\t\t\tif ((assetEntry = await findAssetEntryForPath(`${cwd}/404.html`))) {\n\t\t\t\tlet content: ContentNegotiation;\n\t\t\t\ttry {\n\t\t\t\t\tcontent = negotiateContent(request, assetEntry);\n\t\t\t\t} catch {\n\t\t\t\t\treturn new NotAcceptableResponse();\n\t\t\t\t}\n\n\t\t\t\tconst assetKey = getAssetKey(assetEntry, content);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst { body, contentType } = await fetchAsset(assetKey);\n\t\t\t\t\tconst response = new NotFoundResponse(body);\n\t\t\t\t\tresponse.headers.set(\"content-type\", contentType);\n\t\t\t\t\treturn response;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tlogError(err as Error);\n\t\t\t\t\treturn new InternalServerErrorResponse(err as Error);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn await generateNotFoundResponse(\n\t\t\trequest,\n\t\t\tfindAssetEntryForPath,\n\t\t\tserveAsset\n\t\t);\n\t}\n}\n\n// Parses a list such as \"deflate, gzip;q=1.0, *;q=0.5\" into\n// {deflate: 1, gzip: 1, *: 0.5}\nexport function parseQualityWeightedList(list = \"\") {\n\tconst items: Record<string, number> = {};\n\tlist\n\t\t.replace(/\\s/g, \"\")\n\t\t.split(\",\")\n\t\t.forEach((el) => {\n\t\t\tconst [item, weight] = el.split(\";q=\");\n\t\t\titems[item] = weight ? parseFloat(weight) : 1;\n\t\t});\n\n\treturn items;\n}\n\nfunction isCacheable(request: Request) {\n\treturn !request.headers.has(\"authorization\") && !request.headers.has(\"range\");\n}\n\n// Parses a request URL hostname to determine if the request\n// is from a project served in \"preview\" mode.\nfunction isPreview(url: URL): boolean {\n\tif (url.hostname.endsWith(\".pages.dev\")) {\n\t\treturn url.hostname.split(\".\").length > 3 ? true : false;\n\t}\n\treturn false;\n}\n\n/** Checks if a response is older than CACHE_PRESERVATION_WRITE_FREQUENCY\n * and should be written to cache again to reset it's expiration.\n */\nexport function isPreservationCacheResponseExpiring(\n\tresponse: Response\n): boolean {\n\tconst ageHeader = response.headers.get(\"age\");\n\tif (!ageHeader) {\n\t\treturn false;\n\t}\n\ttry {\n\t\tconst age = parseInt(ageHeader);\n\t\t// Add up to 12 hours of jitter to help prevent a\n\t\t// thundering heard when a lot of assets expire at once.\n\t\tconst jitter = Math.floor(Math.random() * 43_200);\n\t\tif (age > CACHE_PRESERVATION_WRITE_FREQUENCY + jitter) {\n\t\t\treturn true;\n\t\t}\n\t} catch {\n\t\treturn false;\n\t}\n\treturn false;\n}\n\n/**\n * Whether or not the passed in string looks like an HTML\n * Content-Type header\n */\nfunction isHTMLContentType(contentType?: string | null) {\n\treturn contentType?.toLowerCase().startsWith(\"text/html\") || false;\n}\n"],
5
+ "mappings": ";AAAO,IAAM,aAAN,MAAM,oBAAmB,SAAS;AAAA,EACxC;AAAA,SAAgB,SAAS;AAAA;AAAA,EAEzB,YAAY,MAAuB,MAAqB;AACvD,UAAM,MAAM;AAAA,MACX,GAAG;AAAA,MACH,QAAQ,YAAW;AAAA,IACpB,CAAC;AAAA,EACF;AACD;AAEO,IAAM,mBAAN,MAAM,0BAAyB,SAAS;AAAA,EAC9C;AAAA,SAAgB,SAAS;AAAA;AAAA,EAEzB,eAAe,CAAC,MAAM,IAAI,GAA2C;AACpE,UAAM,MAAM;AAAA,MACX,GAAG;AAAA,MACH,QAAQ,kBAAiB;AAAA,MACzB,YAAY;AAAA,IACb,CAAC;AAAA,EACF;AACD;AASO,IAAM,2BAAN,MAAM,kCAAiC,SAAS;AAAA,EACtD;AAAA,SAAgB,SAAS;AAAA;AAAA,EAEzB,eAAe,CAAC,MAAM,IAAI,GAA2C;AACpE,UAAM,MAAM;AAAA,MACX,GAAG;AAAA,MACH,QAAQ,0BAAyB;AAAA,MACjC,YAAY;AAAA,IACb,CAAC;AAAA,EACF;AACD;AAEO,IAAM,8BAAN,MAAM,qCAAoC,SAAS;AAAA,EACzD;AAAA,SAAgB,SAAS;AAAA;AAAA,EAEzB,YAAY,GAAU,MAAqB;AAC1C,UAAM,MAAM;AAAA,MACX,GAAG;AAAA,MACH,QAAQ,6BAA4B;AAAA,IACrC,CAAC;AAAA,EACF;AACD;AA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A,EAC7C,CAAC;AAEF,SAAO;AACR;AAEA,SAAS,YAAY,SAAkB;AACtC,SAAO,CAAC,QAAQ,QAAQ,IAAI,eAAe,KAAK,CAAC,QAAQ,QAAQ,IAAI,OAAO;AAC7E;AAIA,SAAS,UAAU,KAAmB;AACrC,MAAI,IAAI,SAAS,SAAS,YAAY,GAAG;AACxC,WAAO,IAAI,SAAS,MAAM,GAAG,EAAE,SAAS,IAAI,OAAO;AAAA,EACpD;AACA,SAAO;AACR;AAKO,SAAS,oCACf,UACU;AACV,QAAM,YAAY,SAAS,QAAQ,IAAI,KAAK;AAC5C,MAAI,CAAC,WAAW;AACf,WAAO;AAAA,EACR;AACA,MAAI;AACH,UAAM,MAAM,SAAS,SAAS;AAG9B,UAAM,SAAS,KAAK,MAAM,KAAK,OAAO,IAAI,KAAM;AAChD,QAAI,MAAM,qCAAqC,QAAQ;AACtD,aAAO;AAAA,IACR;AAAA,EACD,QAAQ;AACP,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAMA,SAAS,kBAAkB,aAA6B;AACvD,SAAO,aAAa,YAAY,EAAE,WAAW,WAAW,KAAK;AAC9D;",
6
+ "names": ["OkResponse", "MovedPermanentlyResponse", "FoundResponse", "NotModifiedResponse", "PermanentRedirectResponse", "NotFoundResponse", "MethodNotAllowedResponse", "InternalServerErrorResponse", "SeeOtherResponse", "TemporaryRedirectResponse", "CACHE_CONTROL_BROWSER", "REDIRECTS_VERSION", "HEADERS_VERSION", "NotFoundResponse", "staticRedirectsMatcher", "generateRedirectsMatcher", "MovedPermanentlyResponse", "SeeOtherResponse", "TemporaryRedirectResponse", "PermanentRedirectResponse", "FoundResponse", "MethodNotAllowedResponse", "NotModifiedResponse", "OkResponse", "InternalServerErrorResponse"]
7
+ }
@@ -0,0 +1,52 @@
1
+ export type MetadataStaticRedirectEntry = {
2
+ status: number;
3
+ to: string;
4
+ lineNumber: number;
5
+ };
6
+ export type MetadataRedirectEntry = {
7
+ status: number;
8
+ to: string;
9
+ lineNumber?: number;
10
+ };
11
+ export type MetadataStaticRedirects = {
12
+ [path: string]: MetadataStaticRedirectEntry;
13
+ };
14
+ export type MetadataRedirects = {
15
+ [path: string]: MetadataRedirectEntry;
16
+ };
17
+ export type MetadataHeadersEntries = Record<string, string>;
18
+ export type MetadataHeadersRulesV1 = {
19
+ [path: string]: MetadataHeadersEntries;
20
+ };
21
+ export type MetadataHeadersV1 = {
22
+ version: number;
23
+ rules: MetadataHeadersRulesV1;
24
+ };
25
+ export type SetHeaders = MetadataHeadersEntries;
26
+ export type UnsetHeaders = Array<string>;
27
+ export type MetadataHeadersRulesV2 = {
28
+ [path: string]: MetadataHeaderEntry;
29
+ };
30
+ export type MetadataHeaderEntry = {
31
+ set?: SetHeaders;
32
+ unset?: UnsetHeaders;
33
+ };
34
+ export type MetadataHeadersV2 = {
35
+ version: number;
36
+ rules: MetadataHeadersRulesV2;
37
+ };
38
+ export type Metadata = {
39
+ redirects?: {
40
+ version: number;
41
+ staticRules?: MetadataStaticRedirects;
42
+ rules: MetadataRedirects;
43
+ };
44
+ headers?: MetadataHeadersV1 | MetadataHeadersV2;
45
+ analytics?: {
46
+ version: number;
47
+ token: string;
48
+ };
49
+ deploymentId?: string;
50
+ failOpen?: boolean;
51
+ };
52
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../asset-server/metadata.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,2BAA2B,GAAG;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACrC,CAAC,IAAI,EAAE,MAAM,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AC"}
File without changes
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=patchUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patchUrl.d.ts","sourceRoot":"","sources":["../../asset-server/patchUrl.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ // asset-server/patchUrl.ts
2
+ globalThis.URL = function(globalURL) {
3
+ PatchedURL.prototype = globalURL.prototype;
4
+ PatchedURL.createObjectURL = globalURL.createObjectURL;
5
+ PatchedURL.revokeObjectURL = globalURL.revokeObjectURL;
6
+ return PatchedURL;
7
+ function PatchedURL(input, base) {
8
+ const url = new globalURL(encodeURI(input), base);
9
+ return new Proxy(url, {
10
+ get(target, prop) {
11
+ return globalThis.decodeURIComponent(target[prop]);
12
+ }
13
+ });
14
+ }
15
+ }(URL);
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../asset-server/patchUrl.ts"],
4
+ "sourcesContent": ["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nglobalThis.URL = (function (globalURL) {\n\tPatchedURL.prototype = globalURL.prototype;\n\tPatchedURL.createObjectURL = globalURL.createObjectURL;\n\tPatchedURL.revokeObjectURL = globalURL.revokeObjectURL;\n\n\treturn PatchedURL as unknown as typeof globalURL;\n\n\tfunction PatchedURL(input: string, base?: string | URL) {\n\t\tconst url = new globalURL(encodeURI(input), base);\n\n\t\treturn new Proxy(url, {\n\t\t\tget(target, prop) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\treturn globalThis.decodeURIComponent((target as any)[prop]);\n\t\t\t},\n\t\t});\n\t}\n})(URL);\n\nexport {};\n"],
5
+ "mappings": ";AAEA,WAAW,MAAO,SAAU,WAAW;AACtC,aAAW,YAAY,UAAU;AACjC,aAAW,kBAAkB,UAAU;AACvC,aAAW,kBAAkB,UAAU;AAEvC,SAAO;AAEP,WAAS,WAAW,OAAe,MAAqB;AACvD,UAAM,MAAM,IAAI,UAAU,UAAU,KAAK,GAAG,IAAI;AAEhD,WAAO,IAAI,MAAM,KAAK;AAAA,MACrB,IAAI,QAAQ,MAAM;AAEjB,eAAO,WAAW,mBAAoB,OAAe,IAAI,CAAC;AAAA,MAC3D;AAAA,IACD,CAAC;AAAA,EACF;AACD,EAAG,GAAG;",
6
+ "names": []
7
+ }
@@ -0,0 +1,45 @@
1
+ export declare function stripLeadingDoubleSlashes(location: string): string;
2
+ export declare class OkResponse extends Response {
3
+ constructor(...[body, init]: ConstructorParameters<typeof Response>);
4
+ }
5
+ export declare class MovedPermanentlyResponse extends Response {
6
+ constructor(location: string, init?: ConstructorParameters<typeof Response>[1], { preventLeadingDoubleSlash, }?: {
7
+ preventLeadingDoubleSlash: boolean;
8
+ });
9
+ }
10
+ export declare class FoundResponse extends Response {
11
+ constructor(location: string, init?: ConstructorParameters<typeof Response>[1], { preventLeadingDoubleSlash, }?: {
12
+ preventLeadingDoubleSlash: boolean;
13
+ });
14
+ }
15
+ export declare class NotModifiedResponse extends Response {
16
+ constructor(...[_body, _init]: ConstructorParameters<typeof Response>);
17
+ }
18
+ export declare class PermanentRedirectResponse extends Response {
19
+ constructor(location: string, init?: ConstructorParameters<typeof Response>[1], { preventLeadingDoubleSlash, }?: {
20
+ preventLeadingDoubleSlash: boolean;
21
+ });
22
+ }
23
+ export declare class NotFoundResponse extends Response {
24
+ constructor(...[body, init]: ConstructorParameters<typeof Response>);
25
+ }
26
+ export declare class MethodNotAllowedResponse extends Response {
27
+ constructor(...[body, init]: ConstructorParameters<typeof Response>);
28
+ }
29
+ export declare class NotAcceptableResponse extends Response {
30
+ constructor(...[body, init]: ConstructorParameters<typeof Response>);
31
+ }
32
+ export declare class InternalServerErrorResponse extends Response {
33
+ constructor(err: Error, init?: ConstructorParameters<typeof Response>[1]);
34
+ }
35
+ export declare class SeeOtherResponse extends Response {
36
+ constructor(location: string, init?: ConstructorParameters<typeof Response>[1], { preventLeadingDoubleSlash, }?: {
37
+ preventLeadingDoubleSlash: boolean;
38
+ });
39
+ }
40
+ export declare class TemporaryRedirectResponse extends Response {
41
+ constructor(location: string, init?: ConstructorParameters<typeof Response>[1], { preventLeadingDoubleSlash, }?: {
42
+ preventLeadingDoubleSlash: boolean;
43
+ });
44
+ }
45
+ //# sourceMappingURL=responses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../asset-server/responses.ts"],"names":[],"mappings":"AAYA,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,UAEzD;AAED,qBAAa,UAAW,SAAQ,QAAQ;gBAC3B,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC;CAOnE;AAED,qBAAa,wBAAyB,SAAQ,QAAQ;gBAEpD,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAChD,EACC,yBAAgC,GAChC,GAAE;QAAE,yBAAyB,EAAE,OAAO,CAAA;KAEtC;CAcF;AAED,qBAAa,aAAc,SAAQ,QAAQ;gBAEzC,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAChD,EACC,yBAAgC,GAChC,GAAE;QAAE,yBAAyB,EAAE,OAAO,CAAA;KAEtC;CAcF;AAED,qBAAa,mBAAoB,SAAQ,QAAQ;gBACpC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC;CAMrE;AAED,qBAAa,yBAA0B,SAAQ,QAAQ;gBAErD,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAChD,EACC,yBAAgC,GAChC,GAAE;QAAE,yBAAyB,EAAE,OAAO,CAAA;KAEtC;CAcF;AAED,qBAAa,gBAAiB,SAAQ,QAAQ;gBACjC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC;CAOnE;AAED,qBAAa,wBAAyB,SAAQ,QAAQ;gBACzC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC;CAOnE;AAED,qBAAa,qBAAsB,SAAQ,QAAQ;gBACtC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC;CAOnE;AAED,qBAAa,2BAA4B,SAAQ,QAAQ;gBAC5C,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;CAaxE;AAED,qBAAa,gBAAiB,SAAQ,QAAQ;gBAE5C,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAChD,EACC,yBAAgC,GAChC,GAAE;QAAE,yBAAyB,EAAE,OAAO,CAAA;KAEtC;CAYF;AAED,qBAAa,yBAA0B,SAAQ,QAAQ;gBAErD,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAChD,EACC,yBAAgC,GAChC,GAAE;QAAE,yBAAyB,EAAE,OAAO,CAAA;KAEtC;CAYF"}
@@ -0,0 +1,166 @@
1
+ // asset-server/responses.ts
2
+ function mergeHeaders(base, extra) {
3
+ const baseHeaders = new Headers(base ?? {});
4
+ const extraHeaders = new Headers(extra ?? {});
5
+ return new Headers({
6
+ ...Object.fromEntries(baseHeaders.entries()),
7
+ ...Object.fromEntries(extraHeaders.entries())
8
+ });
9
+ }
10
+ function stripLeadingDoubleSlashes(location) {
11
+ return location.replace(/^(\/|%2F|%2f|%5C|%5c|%09|\s|\\)+(.*)/, "/$2");
12
+ }
13
+ var OkResponse = class extends Response {
14
+ constructor(...[body, init]) {
15
+ super(body, {
16
+ ...init,
17
+ status: 200,
18
+ statusText: "OK"
19
+ });
20
+ }
21
+ };
22
+ var MovedPermanentlyResponse = class extends Response {
23
+ constructor(location, init, {
24
+ preventLeadingDoubleSlash = true
25
+ } = {
26
+ preventLeadingDoubleSlash: true
27
+ }) {
28
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
29
+ super(`Redirecting to ${location}`, {
30
+ ...init,
31
+ status: 301,
32
+ statusText: "Moved Permanently",
33
+ headers: mergeHeaders(init?.headers, {
34
+ location
35
+ })
36
+ });
37
+ }
38
+ };
39
+ var FoundResponse = class extends Response {
40
+ constructor(location, init, {
41
+ preventLeadingDoubleSlash = true
42
+ } = {
43
+ preventLeadingDoubleSlash: true
44
+ }) {
45
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
46
+ super(`Redirecting to ${location}`, {
47
+ ...init,
48
+ status: 302,
49
+ statusText: "Found",
50
+ headers: mergeHeaders(init?.headers, {
51
+ location
52
+ })
53
+ });
54
+ }
55
+ };
56
+ var NotModifiedResponse = class extends Response {
57
+ constructor(...[_body, _init]) {
58
+ super(void 0, {
59
+ status: 304,
60
+ statusText: "Not Modified"
61
+ });
62
+ }
63
+ };
64
+ var PermanentRedirectResponse = class extends Response {
65
+ constructor(location, init, {
66
+ preventLeadingDoubleSlash = true
67
+ } = {
68
+ preventLeadingDoubleSlash: true
69
+ }) {
70
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
71
+ super(void 0, {
72
+ ...init,
73
+ status: 308,
74
+ statusText: "Permanent Redirect",
75
+ headers: mergeHeaders(init?.headers, {
76
+ location
77
+ })
78
+ });
79
+ }
80
+ };
81
+ var NotFoundResponse = class extends Response {
82
+ constructor(...[body, init]) {
83
+ super(body, {
84
+ ...init,
85
+ status: 404,
86
+ statusText: "Not Found"
87
+ });
88
+ }
89
+ };
90
+ var MethodNotAllowedResponse = class extends Response {
91
+ constructor(...[body, init]) {
92
+ super(body, {
93
+ ...init,
94
+ status: 405,
95
+ statusText: "Method Not Allowed"
96
+ });
97
+ }
98
+ };
99
+ var NotAcceptableResponse = class extends Response {
100
+ constructor(...[body, init]) {
101
+ super(body, {
102
+ ...init,
103
+ status: 406,
104
+ statusText: "Not Acceptable"
105
+ });
106
+ }
107
+ };
108
+ var InternalServerErrorResponse = class extends Response {
109
+ constructor(err, init) {
110
+ let body = void 0;
111
+ if (globalThis.DEBUG) {
112
+ body = `${err.message}
113
+
114
+ ${err.stack}`;
115
+ }
116
+ super(body, {
117
+ ...init,
118
+ status: 500,
119
+ statusText: "Internal Server Error"
120
+ });
121
+ }
122
+ };
123
+ var SeeOtherResponse = class extends Response {
124
+ constructor(location, init, {
125
+ preventLeadingDoubleSlash = true
126
+ } = {
127
+ preventLeadingDoubleSlash: true
128
+ }) {
129
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
130
+ super(`Redirecting to ${location}`, {
131
+ ...init,
132
+ status: 303,
133
+ statusText: "See Other",
134
+ headers: mergeHeaders(init?.headers, { location })
135
+ });
136
+ }
137
+ };
138
+ var TemporaryRedirectResponse = class extends Response {
139
+ constructor(location, init, {
140
+ preventLeadingDoubleSlash = true
141
+ } = {
142
+ preventLeadingDoubleSlash: true
143
+ }) {
144
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
145
+ super(`Redirecting to ${location}`, {
146
+ ...init,
147
+ status: 307,
148
+ statusText: "Temporary Redirect",
149
+ headers: mergeHeaders(init?.headers, { location })
150
+ });
151
+ }
152
+ };
153
+ export {
154
+ FoundResponse,
155
+ InternalServerErrorResponse,
156
+ MethodNotAllowedResponse,
157
+ MovedPermanentlyResponse,
158
+ NotAcceptableResponse,
159
+ NotFoundResponse,
160
+ NotModifiedResponse,
161
+ OkResponse,
162
+ PermanentRedirectResponse,
163
+ SeeOtherResponse,
164
+ TemporaryRedirectResponse,
165
+ stripLeadingDoubleSlashes
166
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../asset-server/responses.ts"],
4
+ "sourcesContent": ["type HeadersInit = ConstructorParameters<typeof Headers>[0];\n\nfunction mergeHeaders(base: HeadersInit, extra: HeadersInit) {\n\tconst baseHeaders = new Headers(base ?? {});\n\tconst extraHeaders = new Headers(extra ?? {});\n\n\treturn new Headers({\n\t\t...Object.fromEntries(baseHeaders.entries()),\n\t\t...Object.fromEntries(extraHeaders.entries()),\n\t});\n}\n\nexport function stripLeadingDoubleSlashes(location: string) {\n\treturn location.replace(/^(\\/|%2F|%2f|%5C|%5c|%09|\\s|\\\\)+(.*)/, \"/$2\");\n}\n\nexport class OkResponse extends Response {\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 200,\n\t\t\tstatusText: \"OK\",\n\t\t});\n\t}\n}\n\nexport class MovedPermanentlyResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(`Redirecting to ${location}`, {\n\t\t\t...init,\n\t\t\tstatus: 301,\n\t\t\tstatusText: \"Moved Permanently\",\n\t\t\theaders: mergeHeaders(init?.headers, {\n\t\t\t\tlocation,\n\t\t\t}),\n\t\t});\n\t}\n}\n\nexport class FoundResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(`Redirecting to ${location}`, {\n\t\t\t...init,\n\t\t\tstatus: 302,\n\t\t\tstatusText: \"Found\",\n\t\t\theaders: mergeHeaders(init?.headers, {\n\t\t\t\tlocation,\n\t\t\t}),\n\t\t});\n\t}\n}\n\nexport class NotModifiedResponse extends Response {\n\tconstructor(...[_body, _init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(undefined, {\n\t\t\tstatus: 304,\n\t\t\tstatusText: \"Not Modified\",\n\t\t});\n\t}\n}\n\nexport class PermanentRedirectResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(undefined, {\n\t\t\t...init,\n\t\t\tstatus: 308,\n\t\t\tstatusText: \"Permanent Redirect\",\n\t\t\theaders: mergeHeaders(init?.headers, {\n\t\t\t\tlocation,\n\t\t\t}),\n\t\t});\n\t}\n}\n\nexport class NotFoundResponse extends Response {\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 404,\n\t\t\tstatusText: \"Not Found\",\n\t\t});\n\t}\n}\n\nexport class MethodNotAllowedResponse extends Response {\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 405,\n\t\t\tstatusText: \"Method Not Allowed\",\n\t\t});\n\t}\n}\n\nexport class NotAcceptableResponse extends Response {\n\tconstructor(...[body, init]: ConstructorParameters<typeof Response>) {\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 406,\n\t\t\tstatusText: \"Not Acceptable\",\n\t\t});\n\t}\n}\n\nexport class InternalServerErrorResponse extends Response {\n\tconstructor(err: Error, init?: ConstructorParameters<typeof Response>[1]) {\n\t\tlet body: string | undefined = undefined;\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tif ((globalThis as any).DEBUG) {\n\t\t\tbody = `${err.message}\\n\\n${err.stack}`;\n\t\t}\n\n\t\tsuper(body, {\n\t\t\t...init,\n\t\t\tstatus: 500,\n\t\t\tstatusText: \"Internal Server Error\",\n\t\t});\n\t}\n}\n\nexport class SeeOtherResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(`Redirecting to ${location}`, {\n\t\t\t...init,\n\t\t\tstatus: 303,\n\t\t\tstatusText: \"See Other\",\n\t\t\theaders: mergeHeaders(init?.headers, { location }),\n\t\t});\n\t}\n}\n\nexport class TemporaryRedirectResponse extends Response {\n\tconstructor(\n\t\tlocation: string,\n\t\tinit?: ConstructorParameters<typeof Response>[1],\n\t\t{\n\t\t\tpreventLeadingDoubleSlash = true,\n\t\t}: { preventLeadingDoubleSlash: boolean } = {\n\t\t\tpreventLeadingDoubleSlash: true,\n\t\t}\n\t) {\n\t\tlocation = preventLeadingDoubleSlash\n\t\t\t? stripLeadingDoubleSlashes(location)\n\t\t\t: location;\n\t\tsuper(`Redirecting to ${location}`, {\n\t\t\t...init,\n\t\t\tstatus: 307,\n\t\t\tstatusText: \"Temporary Redirect\",\n\t\t\theaders: mergeHeaders(init?.headers, { location }),\n\t\t});\n\t}\n}\n"],
5
+ "mappings": ";AAEA,SAAS,aAAa,MAAmB,OAAoB;AAC5D,QAAM,cAAc,IAAI,QAAQ,QAAQ,CAAC,CAAC;AAC1C,QAAM,eAAe,IAAI,QAAQ,SAAS,CAAC,CAAC;AAE5C,SAAO,IAAI,QAAQ;AAAA,IAClB,GAAG,OAAO,YAAY,YAAY,QAAQ,CAAC;AAAA,IAC3C,GAAG,OAAO,YAAY,aAAa,QAAQ,CAAC;AAAA,EAC7C,CAAC;AACF;AAEO,SAAS,0BAA0B,UAAkB;AAC3D,SAAO,SAAS,QAAQ,wCAAwC,KAAK;AACtE;AAEO,IAAM,aAAN,cAAyB,SAAS;AAAA,EACxC,eAAe,CAAC,MAAM,IAAI,GAA2C;AACpE,UAAM,MAAM;AAAA,MACX,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,YAAY;AAAA,IACb,CAAC;AAAA,EACF;AACD;AAEO,IAAM,2BAAN,cAAuC,SAAS;AAAA,EACtD,YACC,UACA,MACA;AAAA,IACC,4BAA4B;AAAA,EAC7B,IAA4C;AAAA,IAC3C,2BAA2B;AAAA,EAC5B,GACC;AACD,eAAW,4BACR,0BAA0B,QAAQ,IAClC;AACH,UAAM,kBAAkB,QAAQ,IAAI;AAAA,MACnC,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,SAAS,aAAa,MAAM,SAAS;AAAA,QACpC;AAAA,MACD,CAAC;AAAA,IACF,CAAC;AAAA,EACF;AACD;AAEO,IAAM,gBAAN,cAA4B,SAAS;AAAA,EAC3C,YACC,UACA,MACA;AAAA,IACC,4BAA4B;AAAA,EAC7B,IAA4C;AAAA,IAC3C,2BAA2B;AAAA,EAC5B,GACC;AACD,eAAW,4BACR,0BA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,EACF;AACD;AAEO,IAAM,8BAAN,cAA0C,SAAS;AAAA,EACzD,YAAY,KAAY,MAAkD;AACzE,QAAI,OAA2B;AAE/B,QAAK,WAAmB,OAAO;AAC9B,aAAO,GAAG,IAAI,OAAO;AAAA;AAAA,EAAO,IAAI,KAAK;AAAA,IACtC;AAEA,UAAM,MAAM;AAAA,MACX,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,YAAY;AAAA,IACb,CAAC;AAAA,EACF;AACD;AAEO,IAAM,mBAAN,cAA+B,SAAS;AAAA,EAC9C,YACC,UACA,MACA;AAAA,IACC,4BAA4B;AAAA,EAC7B,IAA4C;AAAA,IAC3C,2BAA2B;AAAA,EAC5B,GACC;AACD,eAAW,4BACR,0BAA0B,QAAQ,IAClC;AACH,UAAM,kBAAkB,QAAQ,IAAI;AAAA,MACnC,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,SAAS,aAAa,MAAM,SAAS,EAAE,SAAS,CAAC;AAAA,IAClD,CAAC;AAAA,EACF;AACD;AAEO,IAAM,4BAAN,cAAwC,SAAS;AAAA,EACvD,YACC,UACA,MACA;AAAA,IACC,4BAA4B;AAAA,EAC7B,IAA4C;AAAA,IAC3C,2BAA2B;AAAA,EAC5B,GACC;AACD,eAAW,4BACR,0BAA0B,QAAQ,IAClC;AACH,UAAM,kBAAkB,QAAQ,IAAI;AAAA,MACnC,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,SAAS,aAAa,MAAM,SAAS,EAAE,SAAS,CAAC;AAAA,IAClD,CAAC;AAAA,EACF;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,9 @@
1
+ import { Response } from "miniflare";
2
+ import type { DocumentHandlers, ElementHandlers } from "html-rewriter-wasm";
3
+ export declare class HTMLRewriter {
4
+ #private;
5
+ on(selector: string, handlers: ElementHandlers): this;
6
+ onDocument(handlers: DocumentHandlers): this;
7
+ transform(response: Response): Response;
8
+ }
9
+ //# sourceMappingURL=html-rewriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-rewriter.d.ts","sourceRoot":"","sources":["../../environment-polyfills/html-rewriter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAEX,gBAAgB,EAChB,eAAe,EACf,MAAM,oBAAoB,CAAC;AAO5B,qBAAa,YAAY;;IAIxB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI;IAKrD,UAAU,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAK5C,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ;CAyDvC"}
@@ -0,0 +1,3 @@
1
+ import type { PolyfilledRuntimeEnvironment } from "./types";
2
+ export declare const polyfill: (environment: Record<keyof PolyfilledRuntimeEnvironment, unknown>) => void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../environment-polyfills/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAE5D,eAAO,MAAM,QAAQ,GACpB,aAAa,MAAM,CAAC,MAAM,4BAA4B,EAAE,OAAO,CAAC,SAUhE,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
3
+ //# sourceMappingURL=miniflare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"miniflare.d.ts","sourceRoot":"","sources":["../../environment-polyfills/miniflare.ts"],"names":[],"mappings":";AAEA,wBAUE"}
@@ -0,0 +1,11 @@
1
+ import { Headers as WorkerHeaders, Request as WorkerRequest, Response as WorkerResponse } from "@cloudflare/workers-types/experimental";
2
+ import type { fetch as workerFetch } from "@cloudflare/workers-types/experimental";
3
+ export type PolyfilledRuntimeEnvironment = {
4
+ fetch: typeof workerFetch;
5
+ Headers: typeof Headers;
6
+ Request: typeof Request;
7
+ Response: typeof Response;
8
+ HTMLRewriter: typeof HTMLRewriter;
9
+ };
10
+ export { workerFetch as fetch, WorkerHeaders as Headers, WorkerRequest as Request, WorkerResponse as Response, };
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../environment-polyfills/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,OAAO,IAAI,aAAa,EACxB,OAAO,IAAI,aAAa,EACxB,QAAQ,IAAI,cAAc,EAC1B,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAEnF,MAAM,MAAM,4BAA4B,GAAG;IAC1C,KAAK,EAAE,OAAO,WAAW,CAAC;IAC1B,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,QAAQ,EAAE,OAAO,QAAQ,CAAC;IAC1B,YAAY,EAAE,OAAO,YAAY,CAAC;CAClC,CAAC;AAEF,OAAO,EACN,WAAW,IAAI,KAAK,EACpB,aAAa,IAAI,OAAO,EACxB,aAAa,IAAI,OAAO,EACxB,cAAc,IAAI,QAAQ,GAC1B,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare const REDIRECTS_VERSION = 1;
2
+ export declare const HEADERS_VERSION = 2;
3
+ export declare const ANALYTICS_VERSION = 1;
4
+ export declare const ROUTES_JSON_VERSION = 1;
5
+ export declare const PERMITTED_STATUS_CODES: Set<number>;
6
+ export declare const HEADER_SEPARATOR = ":";
7
+ export declare const MAX_LINE_LENGTH = 2000;
8
+ export declare const MAX_HEADER_RULES = 100;
9
+ export declare const MAX_DYNAMIC_REDIRECT_RULES = 100;
10
+ export declare const MAX_STATIC_REDIRECT_RULES = 2000;
11
+ export declare const UNSET_OPERATOR = "! ";
12
+ export declare const SPLAT_REGEX: RegExp;
13
+ export declare const PLACEHOLDER_REGEX: RegExp;
14
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../metadata-generator/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,eAAO,MAAM,sBAAsB,aAA0C,CAAC;AAC9E,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,eAAe,OAAO,CAAC;AACpC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,eAAO,MAAM,WAAW,QAAQ,CAAC;AACjC,eAAO,MAAM,iBAAiB,QAAkB,CAAC"}
@@ -0,0 +1,29 @@
1
+ // metadata-generator/constants.ts
2
+ var REDIRECTS_VERSION = 1;
3
+ var HEADERS_VERSION = 2;
4
+ var ANALYTICS_VERSION = 1;
5
+ var ROUTES_JSON_VERSION = 1;
6
+ var PERMITTED_STATUS_CODES = /* @__PURE__ */ new Set([200, 301, 302, 303, 307, 308]);
7
+ var HEADER_SEPARATOR = ":";
8
+ var MAX_LINE_LENGTH = 2e3;
9
+ var MAX_HEADER_RULES = 100;
10
+ var MAX_DYNAMIC_REDIRECT_RULES = 100;
11
+ var MAX_STATIC_REDIRECT_RULES = 2e3;
12
+ var UNSET_OPERATOR = "! ";
13
+ var SPLAT_REGEX = /\*/g;
14
+ var PLACEHOLDER_REGEX = /:[A-Za-z]\w*/g;
15
+ export {
16
+ ANALYTICS_VERSION,
17
+ HEADERS_VERSION,
18
+ HEADER_SEPARATOR,
19
+ MAX_DYNAMIC_REDIRECT_RULES,
20
+ MAX_HEADER_RULES,
21
+ MAX_LINE_LENGTH,
22
+ MAX_STATIC_REDIRECT_RULES,
23
+ PERMITTED_STATUS_CODES,
24
+ PLACEHOLDER_REGEX,
25
+ REDIRECTS_VERSION,
26
+ ROUTES_JSON_VERSION,
27
+ SPLAT_REGEX,
28
+ UNSET_OPERATOR
29
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../metadata-generator/constants.ts"],
4
+ "sourcesContent": ["export const REDIRECTS_VERSION = 1;\nexport const HEADERS_VERSION = 2;\nexport const ANALYTICS_VERSION = 1;\nexport const ROUTES_JSON_VERSION = 1;\n\nexport const PERMITTED_STATUS_CODES = new Set([200, 301, 302, 303, 307, 308]);\nexport const HEADER_SEPARATOR = \":\";\nexport const MAX_LINE_LENGTH = 2000;\nexport const MAX_HEADER_RULES = 100;\nexport const MAX_DYNAMIC_REDIRECT_RULES = 100;\nexport const MAX_STATIC_REDIRECT_RULES = 2000;\nexport const UNSET_OPERATOR = \"! \";\n\nexport const SPLAT_REGEX = /\\*/g;\nexport const PLACEHOLDER_REGEX = /:[A-Za-z]\\w*/g;\n"],
5
+ "mappings": ";AAAO,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AACxB,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAE5B,IAAM,yBAAyB,oBAAI,IAAI,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG,CAAC;AACrE,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AACzB,IAAM,6BAA6B;AACnC,IAAM,4BAA4B;AAClC,IAAM,iBAAiB;AAEvB,IAAM,cAAc;AACpB,IAAM,oBAAoB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
1
+ import type { Metadata } from "./types";
2
+ import type { Logger, ParsedHeaders, ParsedRedirects } from "@cloudflare/workers-shared/utils/configuration/types";
3
+ export declare function createMetadataObject({ redirects, headers, redirectsFile, headersFile, webAnalyticsToken, deploymentId, failOpen, logger, }: {
4
+ redirects?: ParsedRedirects;
5
+ headers?: ParsedHeaders;
6
+ redirectsFile?: string;
7
+ headersFile?: string;
8
+ webAnalyticsToken?: string;
9
+ deploymentId?: string;
10
+ failOpen?: boolean;
11
+ logger?: Logger;
12
+ }): Metadata;
13
+ //# sourceMappingURL=createMetadataObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createMetadataObject.d.ts","sourceRoot":"","sources":["../../metadata-generator/createMetadataObject.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EACX,MAAM,EACN,aAAa,EACb,eAAe,EACf,MAAM,sDAAsD,CAAC;AAU9D,wBAAgB,oBAAoB,CAAC,EACpC,SAAS,EACT,OAAO,EACP,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,MAAmB,GACnB,EAAE;IACF,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,QAAQ,CAQX"}