From 321c701a23c280d5c6d88593fb9029d81021c13b Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Mon, 13 Jun 2022 08:41:17 +0100 Subject: [PATCH] use `@cloudflare/kv-asset-handler` for `--experimental-public` We'd previously vendored in `@cloudflare/kv-asset-handler` and `mime` for `--experimental-public`. We've since updated `@cloudflare/kv-asset-handler` to support module workers correctly, and don't need the vendored versions anymore. This patch uses the lib as a dependency, and deletes the `vendor` folder. --- .changeset/tender-balloons-shake.md | 7 + package-lock.json | 7 +- packages/wrangler/package.json | 1 + packages/wrangler/src/bundle.ts | 5 +- .../wrangler/templates/static-asset-facade.js | 4 - .../@cloudflare/kv-asset-handler/CHANGELOG.md | 332 ------------- .../kv-asset-handler/LICENSE_APACHE | 176 ------- .../@cloudflare/kv-asset-handler/LICENSE_MIT | 25 - .../@cloudflare/kv-asset-handler/README.md | 245 --------- .../kv-asset-handler/dist/index.d.ts | 32 -- .../kv-asset-handler/dist/index.js | 354 ------------- .../kv-asset-handler/dist/mocks.d.ts | 13 - .../kv-asset-handler/dist/mocks.js | 148 ------ .../dist/test/getAssetFromKV.d.ts | 1 - .../dist/test/getAssetFromKV.js | 436 ---------------- .../dist/test/mapRequestToAsset.d.ts | 1 - .../dist/test/mapRequestToAsset.js | 40 -- .../dist/test/serveSinglePageApp.d.ts | 1 - .../dist/test/serveSinglePageApp.js | 42 -- .../kv-asset-handler/dist/types.d.ts | 26 - .../kv-asset-handler/dist/types.js | 31 -- .../@cloudflare/kv-asset-handler/package.json | 52 -- .../@cloudflare/kv-asset-handler/src/index.ts | 296 ----------- .../@cloudflare/kv-asset-handler/src/mocks.ts | 136 ----- .../src/test/getAssetFromKV.ts | 464 ------------------ .../src/test/mapRequestToAsset.ts | 33 -- .../src/test/serveSinglePageApp.ts | 42 -- .../@cloudflare/kv-asset-handler/src/types.ts | 39 -- .../vendor/wrangler-mime/CHANGELOG.md | 289 ----------- .../wrangler/vendor/wrangler-mime/LICENSE | 21 - .../wrangler/vendor/wrangler-mime/Mime.js | 97 ---- .../wrangler/vendor/wrangler-mime/README.md | 187 ------- packages/wrangler/vendor/wrangler-mime/cli.js | 46 -- .../wrangler/vendor/wrangler-mime/index.js | 4 - .../wrangler/vendor/wrangler-mime/lite.js | 4 - .../vendor/wrangler-mime/package.json | 52 -- .../vendor/wrangler-mime/types/other.js | 1 - .../vendor/wrangler-mime/types/standard.js | 1 - 38 files changed, 15 insertions(+), 3676 deletions(-) create mode 100644 .changeset/tender-balloons-shake.md delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/README.md delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/index.js delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/mocks.js delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/types.js delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/package.json delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/index.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/mocks.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts delete mode 100644 packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/types.ts delete mode 100644 packages/wrangler/vendor/wrangler-mime/CHANGELOG.md delete mode 100644 packages/wrangler/vendor/wrangler-mime/LICENSE delete mode 100644 packages/wrangler/vendor/wrangler-mime/Mime.js delete mode 100644 packages/wrangler/vendor/wrangler-mime/README.md delete mode 100755 packages/wrangler/vendor/wrangler-mime/cli.js delete mode 100644 packages/wrangler/vendor/wrangler-mime/index.js delete mode 100644 packages/wrangler/vendor/wrangler-mime/lite.js delete mode 100644 packages/wrangler/vendor/wrangler-mime/package.json delete mode 100644 packages/wrangler/vendor/wrangler-mime/types/other.js delete mode 100644 packages/wrangler/vendor/wrangler-mime/types/standard.js diff --git a/.changeset/tender-balloons-shake.md b/.changeset/tender-balloons-shake.md new file mode 100644 index 000000000000..0246b5a76eae --- /dev/null +++ b/.changeset/tender-balloons-shake.md @@ -0,0 +1,7 @@ +--- +"wrangler": patch +--- + +use `@cloudflare/kv-asset-handler` for `--experimental-public` + +We'd previously vendored in `@cloudflare/kv-asset-handler` and `mime` for `--experimental-public`. We've since updated `@cloudflare/kv-asset-handler` to support module workers correctly, and don't need the vendored versions anymore. This patch uses the lib as a dependency, and deletes the `vendor` folder. diff --git a/package-lock.json b/package-lock.json index d41ad4f5dcdf..f141008d315f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1214,7 +1214,8 @@ }, "node_modules/@cloudflare/kv-asset-handler": { "version": "0.2.0", - "license": "MIT OR Apache-2.0", + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.2.0.tgz", + "integrity": "sha512-MVbXLbTcAotOPUj0pAMhVtJ+3/kFkwJqc5qNOleOZTv6QkZZABDMS21dSrSlVswEHwrpWC03e4fWytjqKvuE2A==", "dependencies": { "mime": "^3.0.0" } @@ -20671,6 +20672,7 @@ "version": "2.0.9", "license": "MIT OR Apache-2.0", "dependencies": { + "@cloudflare/kv-asset-handler": "^0.2.0", "@esbuild-plugins/node-globals-polyfill": "^0.1.1", "@esbuild-plugins/node-modules-polyfill": "^0.1.4", "blake3-wasm": "^2.1.5", @@ -21768,6 +21770,8 @@ }, "@cloudflare/kv-asset-handler": { "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.2.0.tgz", + "integrity": "sha512-MVbXLbTcAotOPUj0pAMhVtJ+3/kFkwJqc5qNOleOZTv6QkZZABDMS21dSrSlVswEHwrpWC03e4fWytjqKvuE2A==", "requires": { "mime": "^3.0.0" } @@ -35539,6 +35543,7 @@ "wrangler": { "version": "file:packages/wrangler", "requires": { + "@cloudflare/kv-asset-handler": "*", "@esbuild-plugins/node-globals-polyfill": "^0.1.1", "@esbuild-plugins/node-modules-polyfill": "^0.1.4", "@iarna/toml": "^3.0.0", diff --git a/packages/wrangler/package.json b/packages/wrangler/package.json index dbeb53ac55ad..d696081ab7ca 100644 --- a/packages/wrangler/package.json +++ b/packages/wrangler/package.json @@ -36,6 +36,7 @@ "cli" ], "dependencies": { + "@cloudflare/kv-asset-handler": "^0.2.0", "@esbuild-plugins/node-globals-polyfill": "^0.1.1", "@esbuild-plugins/node-modules-polyfill": "^0.1.4", "blake3-wasm": "^2.1.5", diff --git a/packages/wrangler/src/bundle.ts b/packages/wrangler/src/bundle.ts index 024a25eb28c2..2572fffdaf09 100644 --- a/packages/wrangler/src/bundle.ts +++ b/packages/wrangler/src/bundle.ts @@ -154,9 +154,7 @@ export async function bundleWorker( }; } -type EntryPoint = - | { stdin: esbuild.StdinOptions; nodePaths: string[] } - | { entryPoints: string[] }; +type EntryPoint = { stdin: esbuild.StdinOptions } | { entryPoints: string[] }; /** * Create an object that describes the entry point for esbuild. @@ -181,7 +179,6 @@ function getEntryPoint( sourcefile: "static-asset-facade.js", resolveDir: path.dirname(entryFile), }, - nodePaths: [path.join(__dirname, "../vendor")], }; } else { return { entryPoints: [entryFile] }; diff --git a/packages/wrangler/templates/static-asset-facade.js b/packages/wrangler/templates/static-asset-facade.js index fb865c74aeec..06412925d1df 100644 --- a/packages/wrangler/templates/static-asset-facade.js +++ b/packages/wrangler/templates/static-asset-facade.js @@ -4,10 +4,6 @@ import { getAssetFromKV } from "@cloudflare/kv-asset-handler"; import manifest from "__STATIC_CONTENT_MANIFEST"; const ASSET_MANIFEST = JSON.parse(manifest); -// TODO: remove this -globalThis.__STATIC_CONTENT = undefined; -globalThis.__STATIC_CONTENT_MANIFEST = undefined; - export default { async fetch(request, env, ctx) { let options = { diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md deleted file mode 100644 index 07346a7b95d0..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +++ /dev/null @@ -1,332 +0,0 @@ -# Changelog - -## 0.1.2 - -- ### Features - - - **Support for `defaultDocument` configuration - [boemekeld], [pull/161]** - - This PR adds support for customizing the `defaultDocument` option in `getAssetFromKV`. In situations where a project does not use `index.html` as the default document for a path, this can now be customized to values like `index.shtm`: - - ```js - return getAssetFromKV(event, { - defaultDocument: "index.shtm" - }) - ``` - - [boemekeld]: https://github.com/boemekeld - [pull/161]: https://github.com/cloudflare/kv-asset-handler/pull/161 - -- ### Fixes - - - **Fire `mapRequestToAsset` for all requests, if explicitly defined - [Cherry], [pull/159]** - - This PR fixes an issue where a custom `mapRequestToAsset` handler weren't fired if a matching asset path was found in `ASSET_MANIFEST` data. By correctly checking for this handler, we can conditionally handle any assets with this handler _even_ if they exist in the `ASSET_MANIFEST`. - - **Note that this is a breaking change**, as previously, the mapRequestToAsset function was ignored if you set it, and an exact match was found in the `ASSET_MANIFEST`. That being said, this behavior was a bug, and unexpected behavior, as documented in [issue/158]. - - [Cherry]: https://github.com/Cherry - [issue/158]: https://github.com/kv-asset-handler/pull/158 - [pull/159]: https://github.com/kv-asset-handler/pull/159 - - - **Etag logic refactor - [shagamemnon], [pull/133]** - - This PR refactors a great deal of the Etag functionality introduced in [0.0.11](https://github.com/cloudflare/kv-asset-handler/milestone/7?closed=1). `kv-asset-handler` will now correctly set [strong and weak Etags](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) both to the Cloudflare CDN and to client eyeballs, allowing for higher cache percentages with Workers Sites projects. - - [pull/133]: https://github.com/cloudflare/kv-asset-handler/pull/133 - [shagamemnon]: https://github.com/shagamemnon - - - **Fix path decoding issue - [xiaolanglanglang], [pull/142]** - - This PR improves support for non-alphanumeric character paths in `kv-asset-handler`, for instance, if the path requested is in Chinese. - - [xiaolanglanglang]: https://github.com/xiaolanglanglang - [pull/142]: https://github.com/cloudflare/kv-asset-handler/pull/142 - - - **Check HTTP method after mapRequestToAsset - [oliverpool], [pull/178]** - - This PR fixes an issue where the HTTP method for an asset is checked before the `mapRequestToAsset` handler is called. This has caused issues for users in the past, where they need to generate a `requestKey` based on an asset path, even if the request method is not `GET`. This fixes [issue/151]. - - [oliverpool]: https://github.com/oliverpool - [pull/178]: https://github.com/cloudflare/kv-asset-handler/pull/178 - [issue/151]: https://github.com/cloudflare/kv-asset-handler/issues/151 - -- ### Maintenance - - - **Add Markdown linting workflow to GitHub Actions - [jbampton], [pull/135]** - - Our GitHub Actions workflow now includes a linting workflow for Markdown in the project, including the README, this CHANGELOG, and any other `.md` files in the source code. - - [jbampton]: https://github.com/jbampton - [pull/135]: https://github.com/cloudflare/kv-asset-handler/pull/135 - - - **Dependabot updates** - - A number of dependabot patch-level updates have been merged since our last release: - - - Bump @types/node from 15.30.0 to 15.30.1 ([pull/180]) - - Bump hosted-git-info from 2.8.8 to 2.8.9 ([pull/176]) - - Bump ini from 1.3.5 to 1.3.8 ([pull/160]) - - Bump lodash from 4.17.19 to 4.17.21 ([pull/175]) - - Bump urijs from 1.19.2 to 1.19.6 ([pull/168]) - - Bump y18n from 4.0.0 to 4.0.1 ([pull/173]) - - [pull/160]: https://github.com/cloudflare/kv-asset-handler/pull/160 - [pull/168]: https://github.com/cloudflare/kv-asset-handler/pull/168 - [pull/173]: https://github.com/cloudflare/kv-asset-handler/pull/173 - [pull/175]: https://github.com/cloudflare/kv-asset-handler/pull/175 - [pull/176]: https://github.com/cloudflare/kv-asset-handler/pull/176 - [pull/180]: https://github.com/cloudflare/kv-asset-handler/pull/180 - - - **Repository maintenance - [Cherry], [pull/179]** - - New project maintainer Cherry did a ton of maintenance in this release, improving workflows, code quality, and more. Check out the full list in [the PR][pull/179]. - - [Cherry]: https://github.com/Cherry - [pull/179]: https://github.com/cloudflare/kv-asset-handler/pull/179 - -- ### Documentation - - - **Update README.md - [signalnerve], [pull/177]** - - This PR adds context to our README, with mentions about _what_ this project is, how to use it, and some new things since the last version of this package: namely, [Cloudflare Pages](https://pages.dev) and the new [Cloudflare Workers Discord server](https://discord.gg/cloudflaredev) - - [signalnerve]: https://github.com/signalnerve - [pull/177]: https://github.com/cloudflare/kv-asset-handler/pull/177 - - - **Add instructions for updating version in related repos - [caass], [pull/171]** - - This PR adds instructions for updating the `kv-asset-handler` version in related repositories, such as our templates, that use `kv-asset-handler` and are exposed to end-users of Wrangler and Workers. - - [caass]: https://github.com/caass - [pull/177]: https://github.com/cloudflare/kv-asset-handler/pull/171 - -## 0.1.1 - -- ### Fixes - - - **kv-asset-handler can translate 206 responses to 200 - [harrishancock], [pull/166]** - - Fixes [wrangler#1746](https://github.com/cloudflare/wrangler/issues/1746) - - [harrishancock](https://github.com/harrishancock) - [pull/166](https://github.com/cloudflare/kv-asset-handler/pull/166) - -## 0.0.12 - -- ### Features - - - **Add defaultMimeType option to getAssetFromKV - [mgrahamjo], [pull/121]** - - Some static website owners prefer not to create all of their web routes as directories containing index.html files. Instead, they prefer to create pages as extensionless HTML files. Providing a defaultMimeType option will allow users to set the Content-Type header for extensionless files to text/html, which will enable this use case. - - [mgrahamjo]: https://github.com/mgrahamjo - [pull/121]: https://github.com/cloudflare/kv-asset-handler/pull/121 - - - **Add defaultMimeType to types - [shagamemnon], [pull/132]** - - Adds the newly added defaultMimeType to the exported types for this package. - - [pull/132]: https://github.com/cloudflare/kv-asset-handler/pull/132 - -- ### Fixes - - - **Fix text/* charset - [EatonZ], [pull/130]** - - Adds a missing `-` to the `utf-8` charset value in response mime types. - - [EatonZ]: https://github.com/EatonZ - [pull/130]: https://github.com/cloudflare/kv-asset-handler/pull/130 - - - **Cache handling for HEAD requests - [klittlepage], [pull/141]** - - This PR skips caching for incoming HEAD requests, as they should not be able to be edge cached. - - [klittlepage]: https://github.com/klittlepage - [pull/141]: https://github.com/cloudflare/kv-asset-handler/pull/141 - -- ### Maintenance - - - **Markdown linting/typos - [jbampton], [pull/123], [pull/125], [pull/126], [pull/127], [pull/128], [pull/129], [pull/131], [pull/134]** - - These PRs contain various typo fixes and linting of existing Markdown files in our documentation and CHANGELOG. - - [jbampton]: https://github.com/jbampton - [pull/123]: https://github.com/cloudflare/kv-asset-handler/pull/123 - [pull/125]: https://github.com/cloudflare/kv-asset-handler/pull/125 - [pull/126]: https://github.com/cloudflare/kv-asset-handler/pull/126 - [pull/127]: https://github.com/cloudflare/kv-asset-handler/pull/127 - [pull/128]: https://github.com/cloudflare/kv-asset-handler/pull/128 - [pull/129]: https://github.com/cloudflare/kv-asset-handler/pull/129 - [pull/131]: https://github.com/cloudflare/kv-asset-handler/pull/131 - [pull/134]: https://github.com/cloudflare/kv-asset-handler/pull/134 - -## 0.0.11 - -- ### Features - - - **Support cache revalidation using ETags and If-None-Match - [shagamemnon], [issue/62] [pull/94] [pull/113]** - - Previously, cacheable resources were not looked up from the browser cache because `getAssetFromKV` would never return a `304 Not Modified` response. - - Now, `getAssetFromKV` sets an `ETag` header on all cacheable assets before putting them in the Cache API, and therefore will return a `304` response when appropriate. - - [shagamemnon]: https://github.com/shagamemnon - [pull/94]: https://github.com/cloudflare/kv-asset-handler/pull/94 - [pull/113]: https://github.com/cloudflare/kv-asset-handler/issues/113 - [issue/62]: https://github.com/cloudflare/kv-asset-handler/issues/62 - - - **Export TypeScript types - [ispivey], [issue/43] [pull/106]** - - [ispivey]: https://github.com/ispivey - [pull/106]: https://github.com/cloudflare/kv-asset-handler/pull/106 - [issue/43]: https://github.com/cloudflare/kv-asset-handler/issues/43 - -- ### Fixes - - - **Support non-ASCII characters in paths - [SukkaW], [issue/99] [pull/105]** - - Fixes an issue where non-ASCII paths were not URI-decoded before being looked up, causing non-ASCII paths to 404. - - [SukkaW]: https://github.com/SukkaW - [pull/105]: https://github.com/cloudflare/kv-asset-handler/pull/105 - [issue/99]: https://github.com/cloudflare/kv-asset-handler/issues/99 - - - **Support `charset=utf8` in MIME type - [theromis], [issue/92] [pull/97]** - - Fixes an issue where `Content-Type: text/*` was never appended with `; charset=utf8`, meaning clients would not render non-ASCII characters properly. - - [theromis]: https://github.com/theromis - [pull/97]: https://github.com/cloudflare/kv-asset-handler/pull/97 - [issue/92]: https://github.com/cloudflare/kv-asset-handler/issues/92 - - - **Fix bugs in README examples - [kentonv] [bradyjoslin], [issue/93] [pull/102] [issue/88] [pull/116]** - - [kentonv]: https://github.com/kentonv - [bradyjoslin]: https://github.com/bradyjoslin - [pull/102]: https://github.com/cloudflare/kv-asset-handler/pull/102 - [pull/116]: https://github.com/cloudflare/kv-asset-handler/pull/116 - [issue/93]: https://github.com/cloudflare/kv-asset-handler/issues/93 - [issue/88]: https://github.com/cloudflare/kv-asset-handler/issues/88 - -- ### Maintenance - - - **Make `@cloudflare/workers-types` a dependency and update deps - [ispivey], [pull/107]** - - [ispivey]: https://github.com/ispivey - [pull/107]: https://github.com/cloudflare/kv-asset-handler/pull/107 - - - **Add Code of Conduct - [EverlastingBugstopper], [pull/101]** - - [EverlastingBugstopper]: https://github.com/EverlastingBugstopper - [pull/101]: https://github.com/cloudflare/kv-asset-handler/pull/101 - -## 0.0.10 - -- ### Features - - - **Allow extensionless files to be served - [victoriabernard92], [cloudflare/wrangler/issues/980], [pull/73]** - - Prior to this PR, `getAssetFromKv` assumed extensionless requests (e.g. `/some-path`) would be set up to be served as the corresponding HTML file in storage (e.g. `some-path.html`). - This fix checks the `ASSET_MANIFEST` for the extensionless file name _before_ appending the HTML extension. If the extensionless file exists (e.g. `some-path` exists as a key in the ASSET_MANIFEST) then we serve that file first. If the extensionless file does not exist, then the behavior does not change (e.g. it still looks for `some-path.html`). - - [victoriabernard92]: https://github.com/victoriabernard92 - [cloudflare/wrangler/issues/980]: https://github.com/cloudflare/wrangler/issues/980 - [pull/73]: https://github.com/cloudflare/kv-asset-handler/pull/73 - -- ### Fixes - - - **Fix URL parsing in serveSinglePageApp - [signalnerve],[sgiacosa], [issue/72], [pull/82]** - - This fixes an issue in `serveSinglePageApp` where the request.url is used as a string to retrieve static content. For example, - if a query parameter was set, the URL lookup would break. This fix uses a parsed URL instead of the string and adjusts the README. - - [signalnerve]: https://github.com/signalnerve - [sgiacosa]: https://github.com/sgiacosa - [issue/72]: https://github.com/cloudflare/kv-asset-handler/issue/72 - [pull/82]: https://github.com/cloudflare/kv-asset-handler/pull/82 - -## 0.0.9 - -- ### Fixes - - - **Building and publishing to npm - [victoriabernard92], [pull/78], [pull/79]** - - Added a `prepack` step that builds JavaScript files from the TypeScript source. This fixes previously broken `npm` publishes. - - [victoriabernard92]: https://github.com/victoriabernard92 - [issue/78]: https://github.com/cloudflare/kv-asset-handler/issue/78 - [pull/79]: https://github.com/cloudflare/kv-asset-handler/pull/79 - -## 0.0.8 - -- ### Features - - - **Support a variety of errors thrown from `getAssetFromKV` - [victoriabernard92], [issue/59] [pull/64]** - - Previously, `getAssetFromKv` would throw the same error type if anything went wrong. Now it will throw different error types so that clients can catch and differentiate them. - For example, a 404 `NotFoundError` error implies nothing went wrong, the asset just didn't exist while - a 500 `InternalError` means an expected variable was undefined. - - [victoriabernard92]: https://github.com/victoriabernard92 - [issue/44]: https://github.com/cloudflare/kv-asset-handler/issues/44 - [issue/59]: https://github.com/cloudflare/kv-asset-handler/issues/59 - [pull/47]: https://github.com/cloudflare/kv-asset-handler/pull/47 - -- ### Fixes - - - **Range Issue with Safari and videos - [victoriabernard92], [issue/60] [pull/66]** - - Previously, if you wanted to serve a video from Workers KV using `kv-asset-handler`, it would be broken on Safari due to its requirement that all videos support the [`Content-Range` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range). Cloudflare already has a feature that will handle these headers automatically, we just needed to take advantage of it by passing in a `Request` object to the [Cache API](https://developers.cloudflare.com/workers/reference/apis/cache/) rather than a URL string. - videos from not including the range headers. - - [victoriabernard92]: https://github.com/victoriabernard92 - [shagamemnon]: https://github.com/shagamemnon - [issue/60]: https://github.com/cloudflare/kv-asset-handler/issues/60 - [issue/63]: https://github.com/cloudflare/kv-asset-handler/issues/63 - [pull/47]: https://github.com/cloudflare/kv-asset-handler/pull/52 - [pull/66]: https://github.com/cloudflare/kv-asset-handler/pull/66 - - - **Support custom asset namespaces passed into `getAssetFromKV` - [victoriabernard92], [issue/67] [pull/68]** - - This functionality was documented but not properly supported. Tests and implementation fixes applied. - - [victoriabernard92]: https://github.com/victoriabernard92 - [issue/67]: https://github.com/cloudflare/kv-asset-handler/issues/67 - [pull/68]: https://github.com/cloudflare/kv-asset-handler/pull/68 - -## 0.0.7 - -- ### Features - - - **Add handler for SPAs - [ashleymichal], [issue/46] [pull/47]** - - Some browser applications employ client-side routers that handle navigation in the browser rather than on the server. These applications will work as expected until a non-root URL is requested from the server. This PR adds a special handler, `serveSinglePageApp`, that maps all HTML requests to the root index.html. This is similar to setting a static asset route pattern in an Express.js app. - - [ashleymichal]: https://github.com/ashleymichal - [issue/46]: https://github.com/cloudflare/kv-asset-handler/issues/46 - [pull/47]: https://github.com/cloudflare/kv-asset-handler/pull/47 - -- ### Documentation - - - **Add function API for `getAssetFromKV` to README.md - [ashleymichal], [issue/48] [pull/52]** - - This function, used to abstract away the implementation for retrieving static assets from a Workers KV namespace, includes a lot of great options for configuring your own, bespoke "Workers Sites" implementation. This PR adds documentation to the README for use by those who would like to tinker with these options. - - [ashleymichal]: https://github.com/ashleymichal - [issue/46]: https://github.com/cloudflare/kv-asset-handler/issues/48 - [pull/47]: https://github.com/cloudflare/kv-asset-handler/pull/52 - -## 0.0.6 - -- ### Fixes - - - **Improve caching - [victoriabernard92], [issue/38] [pull/37]** - - - Don't use browser cache by default: Previously, `kv-asset-handler` would set a `Cache-Control` header on the response sent back from the Worker to the client. After this fix, the `Cache-Control` header will only be set if `options.cacheControl.browserTTL` is set by the caller. - - - Set default edge caching to 2 days: Previously the default cache time for static assets was 100 days. This PR sets the default to 2 days. This can be overridden with `options.cacheControl.edgeTTL`. - - [victoriabernard92]: https://github.com/victoriabernard92 - [issue/38]: https://github.com/cloudflare/kv-asset-handler/issues/38 - [pull/37]: https://github.com/cloudflare/kv-asset-handler/pull/37 diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE deleted file mode 100644 index a7e77cb28d38..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +++ /dev/null @@ -1,176 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT deleted file mode 100644 index abf2bc736ee4..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2018 Ashley Williams - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/README.md b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/README.md deleted file mode 100644 index 2be1af7ee105..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/README.md +++ /dev/null @@ -1,245 +0,0 @@ -# @cloudflare/kv-asset-handler - -[![npm](https://img.shields.io/npm/v/@cloudflare/kv-asset-handler.svg)](https://www.npmjs.com/package/@cloudflare/kv-asset-handler)   -[![Run npm tests](https://github.com/cloudflare/kv-asset-handler/actions/workflows/test.yml/badge.svg)](https://github.com/cloudflare/kv-asset-handler/actions/workflows/test.yml)   -[![Lint Markdown](https://github.com/cloudflare/kv-asset-handler/actions/workflows/lint.yml/badge.svg)](https://github.com/cloudflare/kv-asset-handler/actions/workflows/lint.yml)   - -`kv-asset-handler` is an open-source library for managing the retrieval of static assets from [Workers KV](https://developers.cloudflare.com/workers/runtime-apis/kv) inside of a [Cloudflare Workers](https://workers.dev) function. `kv-asset-handler` is designed for use with [Workers Sites](https://developers.cloudflare.com/workers/platform/sites), a feature included in [Wrangler](https://github.com/cloudflare/wrangler), our command-line tool for deploying Workers projects. - -`kv-asset-handler` runs as part of a Cloudflare Workers function, so it allows you to customize _how_ and _when_ your static assets are loaded, as well as customize how those assets behave before they're sent to the client. - -Most users and sites will not need these customizations, and just want to serve their statically built applications. For that simple use-case, you can check out [Cloudflare Pages](https://pages.cloudflare.com), our batteries-included approach to deploying static sites on Cloudflare's edge network. Workers Sites was designed as a precursor to Cloudflare Pages, so check out Pages if you just want to deploy your static site without any special customizations! - -For users who _do_ want to customize their assets, and want to build complex experiences on top of their static assets, `kv-asset-handler` (and the default [Workers Sites template](https://github.com/cloudflare/worker-sites-template), which is provided for use with Wrangler + Workers Sites) allows you to customize caching behavior, headers, and anything else about how your Workers function loads the static assets for your site stored in Workers KV. - -The Cloudflare Workers Discord server is an active place where Workers users get help, share feedback, and collaborate on making our platform better. The `#workers-sites` channel in particular is a great place to chat about `kv-asset-handler`, and building cool experiences for your users using these tools! If you have questions, want to share what you're working on, or give feedback, [join us in Discord and say hello](https://discord.gg/cloudflaredev)! - -- [Installation](#installation) -- [Usage](#usage) -- [`getAssetFromKV`](#-getassetfromkv) - - [Example](#example) - * [Return](#return) - * [Optional Arguments](#optional-arguments) - - [`mapRequestToAsset`](#-maprequesttoasset) - - [Example](#example-1) - - [`cacheControl`](#-cachecontrol) - - [`browserTTL`](#-browserttl) - - [`edgeTTL`](#-edgettl) - - [`bypassCache`](#-bypasscache) - - [`ASSET_NAMESPACE`](#-asset-namespace) - - [`ASSET_MANIFEST` (optional)](#-asset-manifest---optional) - -* [Helper functions](#helper-functions) - - [`mapRequestToAsset`](#-maprequesttoasset-1) - - [`serveSinglePageApp`](#-servesinglepageapp) -* [Cache revalidation and etags](#cache-revalidation-and-etags) - -## Installation - -Add this package to your `package.json` by running this in the root of your -project's directory: - -``` -npm i @cloudflare/kv-asset-handler -``` - -## Usage - -This package was designed to work with [Worker Sites](https://workers.cloudflare.com/sites). - -## `getAssetFromKV` - -getAssetFromKV(FetchEvent) => Promise - -`getAssetFromKV` is an async function that takes a `FetchEvent` object and returns a `Response` object if the request matches an asset in KV, otherwise it will throw a `KVError`. - -#### Example - -This example checks for the existence of a value in KV, and returns it if it's there, and returns a 404 if it is not. It also serves index.html from `/`. - -### Return - -`getAssetFromKV` returns a `Promise` with `Response` being the body of the asset requested. - -Known errors to be thrown are: - -- MethodNotAllowedError -- NotFoundError -- InternalError - -```js -import { getAssetFromKV, NotFoundError, MethodNotAllowedError } from '@cloudflare/kv-asset-handler' - -addEventListener('fetch', (event) => { - event.respondWith(handleEvent(event)) -}) - -async function handleEvent(event) { - if (event.request.url.includes('/docs')) { - try { - return await getAssetFromKV(event) - } catch (e) { - if (e instanceof NotFoundError) { - // ... - } else if (e instanceof MethodNotAllowedError) { - // ... - } else { - return new Response('An unexpected error occurred', { status: 500 }) - } - } - } else return fetch(event.request) -} -``` - -### Optional Arguments - -You can customize the behavior of `getAssetFromKV` by passing the following properties as an object into the second argument. - -``` -getAssetFromKV(event, { mapRequestToAsset: ... }) -``` - -#### `mapRequestToAsset` - -mapRequestToAsset(Request) => Request - -Maps the incoming request to the value that will be looked up in Cloudflare's KV - -By default, mapRequestToAsset is set to the exported function [`mapRequestToAsset`](#maprequesttoasset-1). This works for most static site generators, but you can customize this behavior by passing your own function as `mapRequestToAsset`. The function should take a `Request` object as its only argument, and return a new `Request` object with an updated path to be looked up in the asset manifest/KV. - -For SPA mapping pass in the [`serveSinglePageApp`](#servesinglepageapp) function - -#### Example - -Strip `/docs` from any incoming request before looking up an asset in Cloudflare's KV. - -```js -import { getAssetFromKV, mapRequestToAsset } from '@cloudflare/kv-asset-handler' -... -const customKeyModifier = request => { - let url = request.url - //custom key mapping optional - url = url.replace('/docs', '').replace(/^\/+/, '') - return mapRequestToAsset(new Request(url, request)) -} -let asset = await getAssetFromKV(event, { mapRequestToAsset: customKeyModifier }) -``` - -#### `cacheControl` - -type: object - -`cacheControl` allows you to configure options for both the Cloudflare Cache accessed by your Worker, and the browser cache headers sent along with your Workers' responses. The default values are as follows: - -```javascript -let cacheControl = { - browserTTL: null, // do not set cache control ttl on responses - edgeTTL: 2 * 60 * 60 * 24, // 2 days - bypassCache: false, // do not bypass Cloudflare's cache -} -``` - -##### `browserTTL` - -type: number | null -nullable: true - -Sets the `Cache-Control: max-age` header on the response returned from the Worker. By default set to `null` which will not add the header at all. - -##### `edgeTTL` - -type: number | null -nullable: true - -Sets the `Cache-Control: max-age` header on the response used as the edge cache key. By default set to 2 days (`2 * 60 * 60 * 24`). When null will not cache on the edge at all. - -##### `bypassCache` - -type: boolean - -Determines whether to cache requests on Cloudflare's edge cache. By default set to `false` (recommended for production builds). Useful for development when you need to eliminate the cache's effect on testing. - -#### `ASSET_NAMESPACE` - -type: KV Namespace Binding - -The binding name to the KV Namespace populated with key/value entries of files for the Worker to serve. By default, Workers Sites uses a [binding to a Workers KV Namespace](https://developers.cloudflare.com/workers/reference/storage/api/#namespaces) named `__STATIC_CONTENT`. - -It is further assumed that this namespace consists of static assets such as HTML, CSS, JavaScript, or image files, keyed off of a relative path that roughly matches the assumed URL pathname of the incoming request. - -``` -return getAssetFromKV(event, { ASSET_NAMESPACE: MY_NAMESPACE }) -``` - -#### `ASSET_MANIFEST` (optional) - -type: text blob (JSON formatted) - -The mapping of requested file path to the key stored on Cloudflare. - -Workers Sites with Wrangler bundles up a text blob that maps request paths to content-hashed keys that are generated by Wrangler as a cache-busting measure. If this option/binding is not present, the function will fallback to using the raw pathname to look up your asset in KV. If, for whatever reason, you have rolled your own implementation of this, you can include your own by passing a stringified JSON object where the keys are expected paths, and the values are the expected keys in your KV namespace. - -``` -let assetManifest = { "index.html": "index.special.html" } -return getAssetFromKV(event, { ASSET_MANIFEST: JSON.stringify(assetManifest) }) -``` - -#### `defaultMimeType` (optional) - -type: string - -This is the mime type that will be used for files with unrecognized or missing extensions. The default value is `'text/plain'`. - -If you are serving a static site and would like to use extensionless HTML files instead of index.html files, set this to `'text/html'`. - -#### `defaultDocument` (optional) - -type: string - -This is the default document that will be concatenated for requests ends in `'/'` or without a valid mime type like `'/about'` or `'/about.me'`. The default value is `'index.html'`. - -# Helper functions - -## `mapRequestToAsset` - -mapRequestToAsset(Request) => Request - -The default function for mapping incoming requests to keys in Cloudflare's KV. - -Takes any path that ends in `/` or evaluates to an HTML file and appends `index.html` or `/index.html` for lookup in your Workers KV namespace. - -## `serveSinglePageApp` - -serveSinglePageApp(Request) => Request - -A custom handler for mapping requests to a single root: `index.html`. The most common use case is single-page applications - frameworks with in-app routing - such as React Router, VueJS, etc. It takes zero arguments. - -```js -import { getAssetFromKV, serveSinglePageApp } from '@cloudflare/kv-asset-handler' -... -let asset = await getAssetFromKV(event, { mapRequestToAsset: serveSinglePageApp }) -``` - -# Cache revalidation and etags - -All responses served from cache (including those with `cf-cache-status: MISS`) include an `etag` response header that identifies the version of the resource. The `etag` value is identical to the path key used in the `ASSET_MANIFEST`. It is updated each time an asset changes and looks like this: `etag: ..` (ex. `etag: index.54321.html`). - -Resources served with an `etag` allow browsers to use the `if-none-match` request header to make conditional requests for that resource in the future. This has two major benefits: - -- When a request's `if-none-match` value matches the `etag` of the resource in Cloudflare cache, Cloudflare will send a `304 Not Modified` response without a body, saving bandwidth. -- Changes to a file on the server are immediately reflected in the browser - even when the cache control directive `max-age` is unexpired. - -#### Disable the `etag` - -To turn `etags` **off**, you must bypass cache: - -```js -/* Turn etags off */ -let cacheControl = { - bypassCache: true, -} -``` - -#### Syntax and comparison context - -`kv-asset-handler` sets and evaluates etags as [strong validators](https://developer.mozilla.org/en-US/docs/Web/HTTP/Conditional_requests#Strong_validation). To preserve `etag` integrity, the format of the value deviates from the [RFC2616 recommendation to enclose the `etag` with quotation marks](https://tools.ietf.org/html/rfc2616#section-3.11). This is intentional. Cloudflare cache applies the `W/` prefix to all `etags` that use quoted-strings -- a process that converts the `etag` to a "weak validator" when served to a client. diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts deleted file mode 100644 index ce706c68ccc3..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Options, CacheControl, MethodNotAllowedError, NotFoundError, InternalError } from './types'; -declare global { - var __STATIC_CONTENT: any, __STATIC_CONTENT_MANIFEST: string; -} -/** - * maps the path of incoming request to the request pathKey to look up - * in bucket and in cache - * e.g. for a path '/' returns '/index.html' which serves - * the content of bucket/index.html - * @param {Request} request incoming request - */ -declare const mapRequestToAsset: (request: Request, options?: Partial) => Request; -/** - * maps the path of incoming request to /index.html if it evaluates to - * any HTML file. - * @param {Request} request incoming request - */ -declare function serveSinglePageApp(request: Request, options?: Partial): Request; -/** - * takes the path of the incoming request, gathers the appropriate content from KV, and returns - * the response - * - * @param {FetchEvent} event the fetch event of the triggered request - * @param {{mapRequestToAsset: (string: Request) => Request, cacheControl: {bypassCache:boolean, edgeTTL: number, browserTTL:number}, ASSET_NAMESPACE: any, ASSET_MANIFEST:any}} [options] configurable options - * @param {CacheControl} [options.cacheControl] determine how to cache on Cloudflare and the browser - * @param {typeof(options.mapRequestToAsset)} [options.mapRequestToAsset] maps the path of incoming request to the request pathKey to look up - * @param {Object | string} [options.ASSET_NAMESPACE] the binding to the namespace that script references - * @param {any} [options.ASSET_MANIFEST] the map of the key to cache and store in KV - * */ -declare const getAssetFromKV: (event: FetchEvent, options?: Partial) => Promise; -export { getAssetFromKV, mapRequestToAsset, serveSinglePageApp }; -export { Options, CacheControl, MethodNotAllowedError, NotFoundError, InternalError }; diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/index.js b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/index.js deleted file mode 100644 index 71254ea19f91..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/index.js +++ /dev/null @@ -1,354 +0,0 @@ -"use strict"; -var __awaiter = - (this && this.__awaiter) || - function (thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P - ? value - : new P(function (resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done - ? resolve(result.value) - : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.InternalError = - exports.NotFoundError = - exports.MethodNotAllowedError = - exports.serveSinglePageApp = - exports.mapRequestToAsset = - exports.getAssetFromKV = - void 0; -const mime = require("wrangler-mime"); -const types_1 = require("./types"); -Object.defineProperty(exports, "MethodNotAllowedError", { - enumerable: true, - get: function () { - return types_1.MethodNotAllowedError; - }, -}); -Object.defineProperty(exports, "NotFoundError", { - enumerable: true, - get: function () { - return types_1.NotFoundError; - }, -}); -Object.defineProperty(exports, "InternalError", { - enumerable: true, - get: function () { - return types_1.InternalError; - }, -}); -const defaultCacheControl = { - browserTTL: null, - edgeTTL: 2 * 60 * 60 * 24, - bypassCache: false, // do not bypass Cloudflare's cache -}; -function assignOptions(options) { - // Assign any missing options passed in to the default - // options.mapRequestToAsset is handled manually later - return Object.assign( - { - ASSET_NAMESPACE: __STATIC_CONTENT, - ASSET_MANIFEST: __STATIC_CONTENT_MANIFEST, - cacheControl: defaultCacheControl, - defaultMimeType: "text/plain", - defaultDocument: "index.html", - }, - options - ); -} -/** - * maps the path of incoming request to the request pathKey to look up - * in bucket and in cache - * e.g. for a path '/' returns '/index.html' which serves - * the content of bucket/index.html - * @param {Request} request incoming request - */ -const mapRequestToAsset = (request, options) => { - options = assignOptions(options); - const parsedUrl = new URL(request.url); - let pathname = parsedUrl.pathname; - if (pathname.endsWith("/")) { - // If path looks like a directory append options.defaultDocument - // e.g. If path is /about/ -> /about/index.html - pathname = pathname.concat(options.defaultDocument); - } else if (!mime.getType(pathname)) { - // If path doesn't look like valid content - // e.g. /about.me -> /about.me/index.html - pathname = pathname.concat("/" + options.defaultDocument); - } - parsedUrl.pathname = pathname; - return new Request(parsedUrl.toString(), request); -}; -exports.mapRequestToAsset = mapRequestToAsset; -/** - * maps the path of incoming request to /index.html if it evaluates to - * any HTML file. - * @param {Request} request incoming request - */ -function serveSinglePageApp(request, options) { - options = assignOptions(options); - // First apply the default handler, which already has logic to detect - // paths that should map to HTML files. - request = mapRequestToAsset(request, options); - const parsedUrl = new URL(request.url); - // Detect if the default handler decided to map to - // a HTML file in some specific directory. - if (parsedUrl.pathname.endsWith(".html")) { - // If expected HTML file was missing, just return the root index.html (or options.defaultDocument) - return new Request( - `${parsedUrl.origin}/${options.defaultDocument}`, - request - ); - } else { - // The default handler decided this is not an HTML page. It's probably - // an image, CSS, or JS file. Leave it as-is. - return request; - } -} -exports.serveSinglePageApp = serveSinglePageApp; -/** - * takes the path of the incoming request, gathers the appropriate content from KV, and returns - * the response - * - * @param {FetchEvent} event the fetch event of the triggered request - * @param {{mapRequestToAsset: (string: Request) => Request, cacheControl: {bypassCache:boolean, edgeTTL: number, browserTTL:number}, ASSET_NAMESPACE: any, ASSET_MANIFEST:any}} [options] configurable options - * @param {CacheControl} [options.cacheControl] determine how to cache on Cloudflare and the browser - * @param {typeof(options.mapRequestToAsset)} [options.mapRequestToAsset] maps the path of incoming request to the request pathKey to look up - * @param {Object | string} [options.ASSET_NAMESPACE] the binding to the namespace that script references - * @param {any} [options.ASSET_MANIFEST] the map of the key to cache and store in KV - * */ -const getAssetFromKV = (event, options) => - __awaiter(void 0, void 0, void 0, function* () { - options = assignOptions(options); - const request = event.request; - const ASSET_NAMESPACE = options.ASSET_NAMESPACE; - const ASSET_MANIFEST = - typeof options.ASSET_MANIFEST === "string" - ? JSON.parse(options.ASSET_MANIFEST) - : options.ASSET_MANIFEST; - if (typeof ASSET_NAMESPACE === "undefined") { - throw new types_1.InternalError( - `there is no KV namespace bound to the script` - ); - } - const rawPathKey = new URL(request.url).pathname.replace(/^\/+/, ""); // strip any preceding /'s - let pathIsEncoded = false; - let requestKey; - // if options.mapRequestToAsset is explicitly passed in, always use it and assume user has own intentions - // otherwise handle request as normal, with default mapRequestToAsset below - if (options.mapRequestToAsset) { - requestKey = options.mapRequestToAsset(request); - } else if (ASSET_MANIFEST[rawPathKey]) { - requestKey = request; - } else if (ASSET_MANIFEST[decodeURIComponent(rawPathKey)]) { - pathIsEncoded = true; - requestKey = request; - } else { - const mappedRequest = mapRequestToAsset(request); - const mappedRawPathKey = new URL(mappedRequest.url).pathname.replace( - /^\/+/, - "" - ); - if (ASSET_MANIFEST[decodeURIComponent(mappedRawPathKey)]) { - pathIsEncoded = true; - requestKey = mappedRequest; - } else { - // use default mapRequestToAsset - requestKey = mapRequestToAsset(request, options); - } - } - const SUPPORTED_METHODS = ["GET", "HEAD"]; - if (!SUPPORTED_METHODS.includes(requestKey.method)) { - throw new types_1.MethodNotAllowedError( - `${requestKey.method} is not a valid request method` - ); - } - const parsedUrl = new URL(requestKey.url); - const pathname = pathIsEncoded - ? decodeURIComponent(parsedUrl.pathname) - : parsedUrl.pathname; // decode percentage encoded path only when necessary - // pathKey is the file path to look up in the manifest - let pathKey = pathname.replace(/^\/+/, ""); // remove prepended / - // @ts-ignore - const cache = caches.default; - let mimeType = mime.getType(pathKey) || options.defaultMimeType; - if (mimeType.startsWith("text") || mimeType === "application/javascript") { - mimeType += "; charset=utf-8"; - } - let shouldEdgeCache = false; // false if storing in KV by raw file path i.e. no hash - // check manifest for map from file path to hash - if (typeof ASSET_MANIFEST !== "undefined") { - if (ASSET_MANIFEST[pathKey]) { - pathKey = ASSET_MANIFEST[pathKey]; - // if path key is in asset manifest, we can assume it contains a content hash and can be cached - shouldEdgeCache = true; - } - } - // TODO this excludes search params from cache, investigate ideal behavior - let cacheKey = new Request(`${parsedUrl.origin}/${pathKey}`, request); - // if argument passed in for cacheControl is a function then - // evaluate that function. otherwise return the Object passed in - // or default Object - const evalCacheOpts = (() => { - switch (typeof options.cacheControl) { - case "function": - return options.cacheControl(request); - case "object": - return options.cacheControl; - default: - return defaultCacheControl; - } - })(); - // formats the etag depending on the response context. if the entityId - // is invalid, returns an empty string (instead of null) to prevent the - // the potentially disastrous scenario where the value of the Etag resp - // header is "null". Could be modified in future to base64 encode etc - const formatETag = (entityId = pathKey, validatorType = "strong") => { - if (!entityId) { - return ""; - } - switch (validatorType) { - case "weak": - if (!entityId.startsWith("W/")) { - return `W/${entityId}`; - } - return entityId; - case "strong": - if (entityId.startsWith(`W/"`)) { - entityId = entityId.replace("W/", ""); - } - if (!entityId.endsWith(`"`)) { - entityId = `"${entityId}"`; - } - return entityId; - default: - return ""; - } - }; - options.cacheControl = Object.assign( - {}, - defaultCacheControl, - evalCacheOpts - ); - // override shouldEdgeCache if options say to bypassCache - if ( - options.cacheControl.bypassCache || - options.cacheControl.edgeTTL === null || - request.method == "HEAD" - ) { - shouldEdgeCache = false; - } - // only set max-age if explicitly passed in a number as an arg - const shouldSetBrowserCache = - typeof options.cacheControl.browserTTL === "number"; - let response = null; - if (shouldEdgeCache) { - response = yield cache.match(cacheKey); - } - if (response) { - if (response.status > 300 && response.status < 400) { - if (response.body && "cancel" in Object.getPrototypeOf(response.body)) { - response.body.cancel(); - console.log( - "Body exists and environment supports readable streams. Body cancelled" - ); - } else { - console.log("Environment doesnt support readable streams"); - } - response = new Response(null, response); - } else { - // fixes #165 - let opts = { - headers: new Headers(response.headers), - status: 0, - statusText: "", - }; - opts.headers.set("cf-cache-status", "HIT"); - if (response.status) { - opts.status = response.status; - opts.statusText = response.statusText; - } else if (opts.headers.has("Content-Range")) { - opts.status = 206; - opts.statusText = "Partial Content"; - } else { - opts.status = 200; - opts.statusText = "OK"; - } - response = new Response(response.body, opts); - } - } else { - const body = yield ASSET_NAMESPACE.get(pathKey, "arrayBuffer"); - if (body === null) { - throw new types_1.NotFoundError( - `could not find ${pathKey} in your content namespace` - ); - } - response = new Response(body); - if (shouldEdgeCache) { - response.headers.set("Accept-Ranges", "bytes"); - response.headers.set("Content-Length", body.length); - // set etag before cache insertion - if (!response.headers.has("etag")) { - response.headers.set("etag", formatETag(pathKey, "strong")); - } - // determine Cloudflare cache behavior - response.headers.set( - "Cache-Control", - `max-age=${options.cacheControl.edgeTTL}` - ); - event.waitUntil(cache.put(cacheKey, response.clone())); - response.headers.set("CF-Cache-Status", "MISS"); - } - } - response.headers.set("Content-Type", mimeType); - if (response.status === 304) { - let etag = formatETag(response.headers.get("etag"), "strong"); - let ifNoneMatch = cacheKey.headers.get("if-none-match"); - let proxyCacheStatus = response.headers.get("CF-Cache-Status"); - if (etag) { - if ( - ifNoneMatch && - ifNoneMatch === etag && - proxyCacheStatus === "MISS" - ) { - response.headers.set("CF-Cache-Status", "EXPIRED"); - } else { - response.headers.set("CF-Cache-Status", "REVALIDATED"); - } - response.headers.set("etag", formatETag(etag, "weak")); - } - } - if (shouldSetBrowserCache) { - response.headers.set( - "Cache-Control", - `max-age=${options.cacheControl.browserTTL}` - ); - } else { - response.headers.delete("Cache-Control"); - } - return response; - }); -exports.getAssetFromKV = getAssetFromKV; diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts deleted file mode 100644 index 6025feb15d12..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -export declare const getEvent: (request: Request) => any; -export declare const mockKV: (store: any) => { - get: (path: string) => any; -}; -export declare const mockManifest: () => string; -export declare const mockCaches: () => { - default: { - match(key: any): Promise; - put(key: any, val: Response): Promise; - }; -}; -export declare function mockGlobal(): void; -export declare const sleep: (milliseconds: number) => Promise; diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/mocks.js b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/mocks.js deleted file mode 100644 index 71fcd3f87ad1..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +++ /dev/null @@ -1,148 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.sleep = exports.mockGlobal = exports.mockCaches = exports.mockManifest = exports.mockKV = exports.getEvent = void 0; -const makeServiceWorkerEnv = require('service-worker-mock'); -const HASH = '123HASHBROWN'; -const getEvent = (request) => { - const waitUntil = (callback) => __awaiter(void 0, void 0, void 0, function* () { - yield callback; - }); - return { - request, - waitUntil, - }; -}; -exports.getEvent = getEvent; -const store = { - 'key1.123HASHBROWN.txt': 'val1', - 'key1.123HASHBROWN.png': 'val1', - 'index.123HASHBROWN.html': 'index.html', - 'cache.123HASHBROWN.html': 'cache me if you can', - '测试.123HASHBROWN.html': 'My filename is non-ascii', - '%not-really-percent-encoded.123HASHBROWN.html': 'browser percent encoded', - '%2F.123HASHBROWN.html': 'user percent encoded', - '你好.123HASHBROWN.html': 'I shouldnt be served', - '%E4%BD%A0%E5%A5%BD.123HASHBROWN.html': 'Im important', - 'nohash.txt': 'no hash but still got some result', - 'sub/blah.123HASHBROWN.png': 'picturedis', - 'sub/index.123HASHBROWN.html': 'picturedis', - 'client.123HASHBROWN': 'important file', - 'client.123HASHBROWN/index.html': 'Im here but serve my big bro above', - '你好/index.123HASHBROWN.html': 'My path is non-ascii', -}; -const mockKV = (store) => { - return { - get: (path) => store[path] || null, - }; -}; -exports.mockKV = mockKV; -const mockManifest = () => { - return JSON.stringify({ - 'key1.txt': `key1.${HASH}.txt`, - 'key1.png': `key1.${HASH}.png`, - 'cache.html': `cache.${HASH}.html`, - '测试.html': `测试.${HASH}.html`, - '你好.html': `你好.${HASH}.html`, - '%not-really-percent-encoded.html': `%not-really-percent-encoded.${HASH}.html`, - '%2F.html': `%2F.${HASH}.html`, - '%E4%BD%A0%E5%A5%BD.html': `%E4%BD%A0%E5%A5%BD.${HASH}.html`, - 'index.html': `index.${HASH}.html`, - 'sub/blah.png': `sub/blah.${HASH}.png`, - 'sub/index.html': `sub/index.${HASH}.html`, - client: `client.${HASH}`, - 'client/index.html': `client.${HASH}`, - '你好/index.html': `你好/index.${HASH}.html`, - }); -}; -exports.mockManifest = mockManifest; -let cacheStore = new Map(); -const mockCaches = () => { - return { - default: { - match(key) { - return __awaiter(this, void 0, void 0, function* () { - let cacheKey = { - url: key.url, - headers: {}, - }; - let response; - if (key.headers.has('if-none-match')) { - let makeStrongEtag = key.headers.get('if-none-match').replace('W/', ''); - Reflect.set(cacheKey.headers, 'etag', makeStrongEtag); - response = cacheStore.get(JSON.stringify(cacheKey)); - } - else { - // if client doesn't send if-none-match, we need to iterate through these keys - // and just test the URL - const activeCacheKeys = Array.from(cacheStore.keys()); - for (const cacheStoreKey of activeCacheKeys) { - if (JSON.parse(cacheStoreKey).url === key.url) { - response = cacheStore.get(cacheStoreKey); - } - } - } - // TODO: write test to accomodate for rare scenarios with where range requests accomodate etags - if (response && !key.headers.has('if-none-match')) { - // this appears overly verbose, but is necessary to document edge cache behavior - // The Range request header triggers the response header Content-Range ... - const range = key.headers.get('range'); - if (range) { - response.headers.set('content-range', `bytes ${range.split('=').pop()}/${response.headers.get('content-length')}`); - } - // ... which we are using in this repository to set status 206 - if (response.headers.has('content-range')) { - response.status = 206; - } - else { - response.status = 200; - } - let etag = response.headers.get('etag'); - if (etag && !etag.includes('W/')) { - response.headers.set('etag', `W/${etag}`); - } - } - return response; - }); - }, - put(key, val) { - return __awaiter(this, void 0, void 0, function* () { - let headers = new Headers(val.headers); - let url = new URL(key.url); - let resWithBody = new Response(val.body, { headers, status: 200 }); - let resNoBody = new Response(null, { headers, status: 304 }); - let cacheKey = { - url: key.url, - headers: { - etag: `"${url.pathname.replace('/', '')}"`, - }, - }; - cacheStore.set(JSON.stringify(cacheKey), resNoBody); - cacheKey.headers = {}; - cacheStore.set(JSON.stringify(cacheKey), resWithBody); - return; - }); - }, - }, - }; -}; -exports.mockCaches = mockCaches; -function mockGlobal() { - Object.assign(global, makeServiceWorkerEnv()); - Object.assign(global, { __STATIC_CONTENT_MANIFEST: exports.mockManifest() }); - Object.assign(global, { __STATIC_CONTENT: exports.mockKV(store) }); - Object.assign(global, { caches: exports.mockCaches() }); -} -exports.mockGlobal = mockGlobal; -const sleep = (milliseconds) => { - return new Promise((resolve) => setTimeout(resolve, milliseconds)); -}; -exports.sleep = sleep; diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts deleted file mode 100644 index cb0ff5c3b541..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js deleted file mode 100644 index b905c41a853f..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +++ /dev/null @@ -1,436 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const ava_1 = require("ava"); -const mocks_1 = require("../mocks"); -const index_1 = require("../index"); -ava_1.default('getAssetFromKV return correct val from KV and default caching', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/key1.txt')); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(res.headers.get('cache-control'), null); - t.is(res.headers.get('cf-cache-status'), 'MISS'); - t.is(yield res.text(), 'val1'); - t.true(res.headers.get('content-type').includes('text')); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV evaluated the file matching the extensionless path first /client/ -> client', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request(`https://foo.com/client/`)); - const res = yield index_1.getAssetFromKV(event); - t.is(yield res.text(), 'important file'); - t.true(res.headers.get('content-type').includes('text')); -})); -ava_1.default('getAssetFromKV evaluated the file matching the extensionless path first /client -> client', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request(`https://foo.com/client`)); - const res = yield index_1.getAssetFromKV(event); - t.is(yield res.text(), 'important file'); - t.true(res.headers.get('content-type').includes('text')); -})); -ava_1.default('getAssetFromKV if not in asset manifest still returns nohash.txt', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/nohash.txt')); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(yield res.text(), 'no hash but still got some result'); - t.true(res.headers.get('content-type').includes('text')); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV if no asset manifest /client -> client fails', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request(`https://foo.com/client`)); - const error = yield t.throwsAsync(index_1.getAssetFromKV(event, { ASSET_MANIFEST: {} })); - t.is(error.status, 404); -})); -ava_1.default('getAssetFromKV if sub/ -> sub/index.html served', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request(`https://foo.com/sub`)); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(yield res.text(), 'picturedis'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV gets index.html by default for / requests', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/')); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(yield res.text(), 'index.html'); - t.true(res.headers.get('content-type').includes('html')); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV non ASCII path support', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/测试.html')); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(yield res.text(), 'My filename is non-ascii'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV supports browser percent encoded URLs', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://example.com/%not-really-percent-encoded.html')); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(yield res.text(), 'browser percent encoded'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV supports user percent encoded URLs', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/%2F.html')); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(yield res.text(), 'user percent encoded'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV only decode URL when necessary', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event1 = mocks_1.getEvent(new Request('https://blah.com/%E4%BD%A0%E5%A5%BD.html')); - const event2 = mocks_1.getEvent(new Request('https://blah.com/你好.html')); - const res1 = yield index_1.getAssetFromKV(event1); - const res2 = yield index_1.getAssetFromKV(event2); - if (res1 && res2) { - t.is(yield res1.text(), 'Im important'); - t.is(yield res2.text(), 'Im important'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV Support for user decode url path', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event1 = mocks_1.getEvent(new Request('https://blah.com/%E4%BD%A0%E5%A5%BD/')); - const event2 = mocks_1.getEvent(new Request('https://blah.com/你好/')); - const res1 = yield index_1.getAssetFromKV(event1); - const res2 = yield index_1.getAssetFromKV(event2); - if (res1 && res2) { - t.is(yield res1.text(), 'My path is non-ascii'); - t.is(yield res2.text(), 'My path is non-ascii'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV custom key modifier', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/docs/sub/blah.png')); - const customRequestMapper = (request) => { - let defaultModifiedRequest = index_1.mapRequestToAsset(request); - let url = new URL(defaultModifiedRequest.url); - url.pathname = url.pathname.replace('/docs', ''); - return new Request(url.toString(), request); - }; - const res = yield index_1.getAssetFromKV(event, { mapRequestToAsset: customRequestMapper }); - if (res) { - t.is(yield res.text(), 'picturedis'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV when setting browser caching', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/')); - const res = yield index_1.getAssetFromKV(event, { cacheControl: { browserTTL: 22 } }); - if (res) { - t.is(res.headers.get('cache-control'), 'max-age=22'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV when setting custom cache setting', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event1 = mocks_1.getEvent(new Request('https://blah.com/')); - const event2 = mocks_1.getEvent(new Request('https://blah.com/key1.png?blah=34')); - const cacheOnlyPngs = (req) => { - if (new URL(req.url).pathname.endsWith('.png')) - return { - browserTTL: 720, - edgeTTL: 720, - }; - else - return { - bypassCache: true, - }; - }; - const res1 = yield index_1.getAssetFromKV(event1, { cacheControl: cacheOnlyPngs }); - const res2 = yield index_1.getAssetFromKV(event2, { cacheControl: cacheOnlyPngs }); - if (res1 && res2) { - t.is(res1.headers.get('cache-control'), null); - t.true(res2.headers.get('content-type').includes('png')); - t.is(res2.headers.get('cache-control'), 'max-age=720'); - t.is(res2.headers.get('cf-cache-status'), 'MISS'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV caches on two sequential requests', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const resourceKey = 'cache.html'; - const resourceVersion = JSON.parse(mocks_1.mockManifest())[resourceKey]; - const event1 = mocks_1.getEvent(new Request(`https://blah.com/${resourceKey}`)); - const event2 = mocks_1.getEvent(new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}"`, - }, - })); - const res1 = yield index_1.getAssetFromKV(event1, { cacheControl: { edgeTTL: 720, browserTTL: 720 } }); - yield mocks_1.sleep(1); - const res2 = yield index_1.getAssetFromKV(event2); - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS'); - t.is(res1.headers.get('cache-control'), 'max-age=720'); - t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV does not store max-age on two sequential requests', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const resourceKey = 'cache.html'; - const resourceVersion = JSON.parse(mocks_1.mockManifest())[resourceKey]; - const event1 = mocks_1.getEvent(new Request(`https://blah.com/${resourceKey}`)); - const event2 = mocks_1.getEvent(new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}"`, - }, - })); - const res1 = yield index_1.getAssetFromKV(event1, { cacheControl: { edgeTTL: 720 } }); - yield mocks_1.sleep(100); - const res2 = yield index_1.getAssetFromKV(event2); - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS'); - t.is(res1.headers.get('cache-control'), null); - t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED'); - t.is(res2.headers.get('cache-control'), null); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV does not cache on Cloudflare when bypass cache set', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/')); - const res = yield index_1.getAssetFromKV(event, { cacheControl: { bypassCache: true } }); - if (res) { - t.is(res.headers.get('cache-control'), null); - t.is(res.headers.get('cf-cache-status'), null); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV with no trailing slash on root', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com')); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(yield res.text(), 'index.html'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV with no trailing slash on a subdirectory', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/sub/blah.png')); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(yield res.text(), 'picturedis'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV no result throws an error', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/random')); - const error = yield t.throwsAsync(index_1.getAssetFromKV(event)); - t.is(error.status, 404); -})); -ava_1.default('getAssetFromKV TTls set to null should not cache on browser or edge', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const event = mocks_1.getEvent(new Request('https://blah.com/')); - const res1 = yield index_1.getAssetFromKV(event, { cacheControl: { browserTTL: null, edgeTTL: null } }); - yield mocks_1.sleep(100); - const res2 = yield index_1.getAssetFromKV(event, { cacheControl: { browserTTL: null, edgeTTL: null } }); - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), null); - t.is(res1.headers.get('cache-control'), null); - t.is(res2.headers.get('cf-cache-status'), null); - t.is(res2.headers.get('cache-control'), null); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV passing in a custom NAMESPACE serves correct asset', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - let CUSTOM_NAMESPACE = mocks_1.mockKV({ - 'key1.123HASHBROWN.txt': 'val1', - }); - Object.assign(global, { CUSTOM_NAMESPACE }); - const event = mocks_1.getEvent(new Request('https://blah.com/')); - const res = yield index_1.getAssetFromKV(event); - if (res) { - t.is(yield res.text(), 'index.html'); - t.true(res.headers.get('content-type').includes('html')); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV when custom namespace without the asset should fail', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - let CUSTOM_NAMESPACE = mocks_1.mockKV({ - 'key5.123HASHBROWN.txt': 'customvalu', - }); - const event = mocks_1.getEvent(new Request('https://blah.com')); - const error = yield t.throwsAsync(index_1.getAssetFromKV(event, { ASSET_NAMESPACE: CUSTOM_NAMESPACE })); - t.is(error.status, 404); -})); -ava_1.default('getAssetFromKV when namespace not bound fails', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - var MY_CUSTOM_NAMESPACE = undefined; - Object.assign(global, { MY_CUSTOM_NAMESPACE }); - const event = mocks_1.getEvent(new Request('https://blah.com/')); - const error = yield t.throwsAsync(index_1.getAssetFromKV(event, { ASSET_NAMESPACE: MY_CUSTOM_NAMESPACE })); - t.is(error.status, 500); -})); -ava_1.default('getAssetFromKV when if-none-match === active resource version, should revalidate', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const resourceKey = 'key1.png'; - const resourceVersion = JSON.parse(mocks_1.mockManifest())[resourceKey]; - const event1 = mocks_1.getEvent(new Request(`https://blah.com/${resourceKey}`)); - const event2 = mocks_1.getEvent(new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `W/"${resourceVersion}"`, - }, - })); - const res1 = yield index_1.getAssetFromKV(event1, { cacheControl: { edgeTTL: 720 } }); - yield mocks_1.sleep(100); - const res2 = yield index_1.getAssetFromKV(event2); - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS'); - t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV when if-none-match equals etag of stale resource then should bypass cache', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const resourceKey = 'key1.png'; - const resourceVersion = JSON.parse(mocks_1.mockManifest())[resourceKey]; - const req1 = new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}"`, - }, - }); - const req2 = new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}-another-version"`, - }, - }); - const event = mocks_1.getEvent(req1); - const event2 = mocks_1.getEvent(req2); - const res1 = yield index_1.getAssetFromKV(event, { cacheControl: { edgeTTL: 720 } }); - const res2 = yield index_1.getAssetFromKV(event); - const res3 = yield index_1.getAssetFromKV(event2); - if (res1 && res2 && res3) { - t.is(res1.headers.get('cf-cache-status'), 'MISS'); - t.is(res2.headers.get('etag'), `W/${req1.headers.get('if-none-match')}`); - t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED'); - t.not(res3.headers.get('etag'), req2.headers.get('if-none-match')); - t.is(res3.headers.get('cf-cache-status'), 'MISS'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV when resource in cache, etag should be weakened before returned to eyeball', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - const resourceKey = 'key1.png'; - const resourceVersion = JSON.parse(mocks_1.mockManifest())[resourceKey]; - const req1 = new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}"`, - }, - }); - const event = mocks_1.getEvent(req1); - const res1 = yield index_1.getAssetFromKV(event, { cacheControl: { edgeTTL: 720 } }); - const res2 = yield index_1.getAssetFromKV(event); - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS'); - t.is(res2.headers.get('etag'), `W/${req1.headers.get('if-none-match')}`); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV if-none-match not sent but resource in cache, should return cache hit 200 OK', (t) => __awaiter(void 0, void 0, void 0, function* () { - const resourceKey = 'cache.html'; - const event = mocks_1.getEvent(new Request(`https://blah.com/${resourceKey}`)); - const res1 = yield index_1.getAssetFromKV(event, { cacheControl: { edgeTTL: 720 } }); - yield mocks_1.sleep(1); - const res2 = yield index_1.getAssetFromKV(event); - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS'); - t.is(res1.headers.get('cache-control'), null); - t.is(res2.status, 200); - t.is(res2.headers.get('cf-cache-status'), 'HIT'); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default('getAssetFromKV if range request submitted and resource in cache, request fulfilled', (t) => __awaiter(void 0, void 0, void 0, function* () { - const resourceKey = 'cache.html'; - const event1 = mocks_1.getEvent(new Request(`https://blah.com/${resourceKey}`)); - const event2 = mocks_1.getEvent(new Request(`https://blah.com/${resourceKey}`, { headers: { range: 'bytes=0-10' } })); - const res1 = index_1.getAssetFromKV(event1, { cacheControl: { edgeTTL: 720 } }); - yield res1; - yield mocks_1.sleep(2); - const res2 = yield index_1.getAssetFromKV(event2); - if (res2.headers.has('content-range')) { - t.is(res2.status, 206); - } - else { - t.fail('Response was undefined'); - } -})); -ava_1.default.todo('getAssetFromKV when body not empty, should invoke .cancel()'); diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts deleted file mode 100644 index cb0ff5c3b541..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js deleted file mode 100644 index 1fc0ea11aa31..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const ava_1 = require("ava"); -const mocks_1 = require("../mocks"); -const index_1 = require("../index"); -ava_1.default('mapRequestToAsset() correctly changes /about -> /about/index.html', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - let path = '/about'; - let request = new Request(`https://foo.com${path}`); - let newRequest = index_1.mapRequestToAsset(request); - t.is(newRequest.url, request.url + '/index.html'); -})); -ava_1.default('mapRequestToAsset() correctly changes /about/ -> /about/index.html', (t) => __awaiter(void 0, void 0, void 0, function* () { - let path = '/about/'; - let request = new Request(`https://foo.com${path}`); - let newRequest = index_1.mapRequestToAsset(request); - t.is(newRequest.url, request.url + 'index.html'); -})); -ava_1.default('mapRequestToAsset() correctly changes /about.me/ -> /about.me/index.html', (t) => __awaiter(void 0, void 0, void 0, function* () { - let path = '/about.me/'; - let request = new Request(`https://foo.com${path}`); - let newRequest = index_1.mapRequestToAsset(request); - t.is(newRequest.url, request.url + 'index.html'); -})); -ava_1.default('mapRequestToAsset() correctly changes /about -> /about/default.html', (t) => __awaiter(void 0, void 0, void 0, function* () { - mocks_1.mockGlobal(); - let path = '/about'; - let request = new Request(`https://foo.com${path}`); - let newRequest = index_1.mapRequestToAsset(request, { defaultDocument: 'default.html' }); - t.is(newRequest.url, request.url + '/default.html'); -})); diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts deleted file mode 100644 index cb0ff5c3b541..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js deleted file mode 100644 index 6b607f44049d..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +++ /dev/null @@ -1,42 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const ava_1 = require("ava"); -const mocks_1 = require("../mocks"); -const index_1 = require("../index"); -function testRequest(path) { - mocks_1.mockGlobal(); - let url = new URL('https://example.com'); - url.pathname = path; - let request = new Request(url.toString()); - return request; -} -ava_1.default('serveSinglePageApp returns root asset path when request path ends in .html', (t) => __awaiter(void 0, void 0, void 0, function* () { - let path = '/foo/thing.html'; - let request = testRequest(path); - let expected_request = testRequest('/index.html'); - let actual_request = index_1.serveSinglePageApp(request); - t.deepEqual(expected_request, actual_request); -})); -ava_1.default('serveSinglePageApp returns root asset path when request path does not have extension', (t) => __awaiter(void 0, void 0, void 0, function* () { - let path = '/foo/thing'; - let request = testRequest(path); - let expected_request = testRequest('/index.html'); - let actual_request = index_1.serveSinglePageApp(request); - t.deepEqual(expected_request, actual_request); -})); -ava_1.default('serveSinglePageApp returns requested asset when request path has non-html extension', (t) => __awaiter(void 0, void 0, void 0, function* () { - let path = '/foo/thing.js'; - let request = testRequest(path); - let expected_request = request; - let actual_request = index_1.serveSinglePageApp(request); - t.deepEqual(expected_request, actual_request); -})); diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts deleted file mode 100644 index e3609d774220..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -export declare type CacheControl = { - browserTTL: number; - edgeTTL: number; - bypassCache: boolean; -}; -export declare type Options = { - cacheControl: ((req: Request) => Partial) | Partial; - ASSET_NAMESPACE: any; - ASSET_MANIFEST: Object | string; - mapRequestToAsset?: (req: Request, options?: Partial) => Request; - defaultMimeType: string; - defaultDocument: string; -}; -export declare class KVError extends Error { - constructor(message?: string, status?: number); - status: number; -} -export declare class MethodNotAllowedError extends KVError { - constructor(message?: string, status?: number); -} -export declare class NotFoundError extends KVError { - constructor(message?: string, status?: number); -} -export declare class InternalError extends KVError { - constructor(message?: string, status?: number); -} diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/types.js b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/types.js deleted file mode 100644 index ba08c1babad3..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/dist/types.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.InternalError = exports.NotFoundError = exports.MethodNotAllowedError = exports.KVError = void 0; -class KVError extends Error { - constructor(message, status = 500) { - super(message); - // see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html - Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain - this.name = KVError.name; // stack traces display correctly now - this.status = status; - } -} -exports.KVError = KVError; -class MethodNotAllowedError extends KVError { - constructor(message = `Not a valid request method`, status = 405) { - super(message, status); - } -} -exports.MethodNotAllowedError = MethodNotAllowedError; -class NotFoundError extends KVError { - constructor(message = `Not Found`, status = 404) { - super(message, status); - } -} -exports.NotFoundError = NotFoundError; -class InternalError extends KVError { - constructor(message = `Internal Error in KV Asset Handler`, status = 500) { - super(message, status); - } -} -exports.InternalError = InternalError; diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/package.json b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/package.json deleted file mode 100644 index 9be00971d203..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@cloudflare/kv-asset-handler", - "version": "0.1.2", - "description": "Routes requests to KV assets", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "prepack": "npm run build", - "build": "tsc -d", - "format": "prettier --write \"**/*.{js,ts,json,md}\"", - "pretest": "npm run build", - "lint:code": "prettier --check \"**/*.{js,ts,json,md}\"", - "lint:markdown": "markdownlint \"**/*.md\" --ignore node_modules", - "test": "ava dist/test/*.js --verbose" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/cloudflare/kv-asset-handler.git" - }, - "keywords": [ - "kv", - "cloudflare", - "workers", - "wrangler", - "assets" - ], - "files": [ - "src", - "dist", - "LICENSE_APACHE", - "LICENSE_MIT" - ], - "author": "wrangler@cloudflare.com", - "license": "MIT OR Apache-2.0", - "bugs": { - "url": "https://github.com/cloudflare/kv-asset-handler/issues" - }, - "homepage": "https://github.com/cloudflare/kv-asset-handler#readme", - "dependencies": { - "wrangler-mime": "^2.5.2" - }, - "devDependencies": { - "@ava/typescript": "^1.1.1", - "@cloudflare/workers-types": "^2.2.2", - "@types/mime": "^2.0.3", - "@types/node": "^15.3.0", - "ava": "^3.15.0", - "prettier": "^2.3.0", - "service-worker-mock": "^2.0.5", - "typescript": "^4.2.4" - } -} diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/index.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/index.ts deleted file mode 100644 index ebbb96733596..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/index.ts +++ /dev/null @@ -1,296 +0,0 @@ -import * as mime from 'mime' -import { Options, CacheControl, MethodNotAllowedError, NotFoundError, InternalError } from './types' - -declare global { - var __STATIC_CONTENT: any, __STATIC_CONTENT_MANIFEST: string -} - -const defaultCacheControl: CacheControl = { - browserTTL: null, - edgeTTL: 2 * 60 * 60 * 24, // 2 days - bypassCache: false, // do not bypass Cloudflare's cache -} - -function assignOptions(options?: Partial): Options { - // Assign any missing options passed in to the default - // options.mapRequestToAsset is handled manually later - return Object.assign( - { - ASSET_NAMESPACE: __STATIC_CONTENT, - ASSET_MANIFEST: __STATIC_CONTENT_MANIFEST, - cacheControl: defaultCacheControl, - defaultMimeType: 'text/plain', - defaultDocument: 'index.html', - }, - options, - ) -} - -/** - * maps the path of incoming request to the request pathKey to look up - * in bucket and in cache - * e.g. for a path '/' returns '/index.html' which serves - * the content of bucket/index.html - * @param {Request} request incoming request - */ -const mapRequestToAsset = (request: Request, options?: Partial) => { - options = assignOptions(options) - - const parsedUrl = new URL(request.url) - let pathname = parsedUrl.pathname - - if (pathname.endsWith('/')) { - // If path looks like a directory append options.defaultDocument - // e.g. If path is /about/ -> /about/index.html - pathname = pathname.concat(options.defaultDocument) - } else if (!mime.getType(pathname)) { - // If path doesn't look like valid content - // e.g. /about.me -> /about.me/index.html - pathname = pathname.concat('/' + options.defaultDocument) - } - - parsedUrl.pathname = pathname - return new Request(parsedUrl.toString(), request) -} - -/** - * maps the path of incoming request to /index.html if it evaluates to - * any HTML file. - * @param {Request} request incoming request - */ -function serveSinglePageApp(request: Request, options?: Partial): Request { - options = assignOptions(options) - - // First apply the default handler, which already has logic to detect - // paths that should map to HTML files. - request = mapRequestToAsset(request, options) - - const parsedUrl = new URL(request.url) - - // Detect if the default handler decided to map to - // a HTML file in some specific directory. - if (parsedUrl.pathname.endsWith('.html')) { - // If expected HTML file was missing, just return the root index.html (or options.defaultDocument) - return new Request(`${parsedUrl.origin}/${options.defaultDocument}`, request) - } else { - // The default handler decided this is not an HTML page. It's probably - // an image, CSS, or JS file. Leave it as-is. - return request - } -} - -/** - * takes the path of the incoming request, gathers the appropriate content from KV, and returns - * the response - * - * @param {FetchEvent} event the fetch event of the triggered request - * @param {{mapRequestToAsset: (string: Request) => Request, cacheControl: {bypassCache:boolean, edgeTTL: number, browserTTL:number}, ASSET_NAMESPACE: any, ASSET_MANIFEST:any}} [options] configurable options - * @param {CacheControl} [options.cacheControl] determine how to cache on Cloudflare and the browser - * @param {typeof(options.mapRequestToAsset)} [options.mapRequestToAsset] maps the path of incoming request to the request pathKey to look up - * @param {Object | string} [options.ASSET_NAMESPACE] the binding to the namespace that script references - * @param {any} [options.ASSET_MANIFEST] the map of the key to cache and store in KV - * */ -const getAssetFromKV = async (event: FetchEvent, options?: Partial): Promise => { - options = assignOptions(options) - - const request = event.request - const ASSET_NAMESPACE = options.ASSET_NAMESPACE - const ASSET_MANIFEST = - typeof options.ASSET_MANIFEST === 'string' - ? JSON.parse(options.ASSET_MANIFEST) - : options.ASSET_MANIFEST - - if (typeof ASSET_NAMESPACE === 'undefined') { - throw new InternalError(`there is no KV namespace bound to the script`) - } - - const rawPathKey = new URL(request.url).pathname.replace(/^\/+/, '') // strip any preceding /'s - let pathIsEncoded = false - let requestKey - // if options.mapRequestToAsset is explicitly passed in, always use it and assume user has own intentions - // otherwise handle request as normal, with default mapRequestToAsset below - if (options.mapRequestToAsset) { - requestKey = options.mapRequestToAsset(request) - } else if (ASSET_MANIFEST[rawPathKey]) { - requestKey = request - } else if (ASSET_MANIFEST[decodeURIComponent(rawPathKey)]) { - pathIsEncoded = true - requestKey = request - } else { - const mappedRequest = mapRequestToAsset(request) - const mappedRawPathKey = new URL(mappedRequest.url).pathname.replace(/^\/+/, '') - if (ASSET_MANIFEST[decodeURIComponent(mappedRawPathKey)]) { - pathIsEncoded = true - requestKey = mappedRequest - } else { - // use default mapRequestToAsset - requestKey = mapRequestToAsset(request, options) - } - } - - const SUPPORTED_METHODS = ['GET', 'HEAD'] - if (!SUPPORTED_METHODS.includes(requestKey.method)) { - throw new MethodNotAllowedError(`${requestKey.method} is not a valid request method`) - } - - const parsedUrl = new URL(requestKey.url) - const pathname = pathIsEncoded ? decodeURIComponent(parsedUrl.pathname) : parsedUrl.pathname // decode percentage encoded path only when necessary - - // pathKey is the file path to look up in the manifest - let pathKey = pathname.replace(/^\/+/, '') // remove prepended / - - // @ts-ignore - const cache = caches.default - let mimeType = mime.getType(pathKey) || options.defaultMimeType - if (mimeType.startsWith('text') || mimeType === 'application/javascript') { - mimeType += '; charset=utf-8' - } - - let shouldEdgeCache = false // false if storing in KV by raw file path i.e. no hash - // check manifest for map from file path to hash - if (typeof ASSET_MANIFEST !== 'undefined') { - if (ASSET_MANIFEST[pathKey]) { - pathKey = ASSET_MANIFEST[pathKey] - // if path key is in asset manifest, we can assume it contains a content hash and can be cached - shouldEdgeCache = true - } - } - - // TODO this excludes search params from cache, investigate ideal behavior - let cacheKey = new Request(`${parsedUrl.origin}/${pathKey}`, request) - - // if argument passed in for cacheControl is a function then - // evaluate that function. otherwise return the Object passed in - // or default Object - const evalCacheOpts = (() => { - switch (typeof options.cacheControl) { - case 'function': - return options.cacheControl(request) - case 'object': - return options.cacheControl - default: - return defaultCacheControl - } - })() - - // formats the etag depending on the response context. if the entityId - // is invalid, returns an empty string (instead of null) to prevent the - // the potentially disastrous scenario where the value of the Etag resp - // header is "null". Could be modified in future to base64 encode etc - const formatETag = (entityId: any = pathKey, validatorType: string = 'strong') => { - if (!entityId) { - return '' - } - switch (validatorType) { - case 'weak': - if (!entityId.startsWith('W/')) { - return `W/${entityId}` - } - return entityId - case 'strong': - if (entityId.startsWith(`W/"`)) { - entityId = entityId.replace('W/', '') - } - if (!entityId.endsWith(`"`)) { - entityId = `"${entityId}"` - } - return entityId - default: - return '' - } - } - - options.cacheControl = Object.assign({}, defaultCacheControl, evalCacheOpts) - - // override shouldEdgeCache if options say to bypassCache - if ( - options.cacheControl.bypassCache || - options.cacheControl.edgeTTL === null || - request.method == 'HEAD' - ) { - shouldEdgeCache = false - } - // only set max-age if explicitly passed in a number as an arg - const shouldSetBrowserCache = typeof options.cacheControl.browserTTL === 'number' - - let response = null - if (shouldEdgeCache) { - response = await cache.match(cacheKey) - } - - if (response) { - if (response.status > 300 && response.status < 400) { - if (response.body && 'cancel' in Object.getPrototypeOf(response.body)) { - response.body.cancel() - console.log('Body exists and environment supports readable streams. Body cancelled') - } else { - console.log('Environment doesnt support readable streams') - } - response = new Response(null, response) - } else { - // fixes #165 - let opts = { - headers: new Headers(response.headers), - status: 0, - statusText: '', - } - - opts.headers.set('cf-cache-status', 'HIT') - - if (response.status) { - opts.status = response.status - opts.statusText = response.statusText - } else if (opts.headers.has('Content-Range')) { - opts.status = 206 - opts.statusText = 'Partial Content' - } else { - opts.status = 200 - opts.statusText = 'OK' - } - response = new Response(response.body, opts) - } - } else { - const body = await ASSET_NAMESPACE.get(pathKey, 'arrayBuffer') - if (body === null) { - throw new NotFoundError(`could not find ${pathKey} in your content namespace`) - } - response = new Response(body) - - if (shouldEdgeCache) { - response.headers.set('Accept-Ranges', 'bytes') - response.headers.set('Content-Length', body.length) - // set etag before cache insertion - if (!response.headers.has('etag')) { - response.headers.set('etag', formatETag(pathKey, 'strong')) - } - // determine Cloudflare cache behavior - response.headers.set('Cache-Control', `max-age=${options.cacheControl.edgeTTL}`) - event.waitUntil(cache.put(cacheKey, response.clone())) - response.headers.set('CF-Cache-Status', 'MISS') - } - } - response.headers.set('Content-Type', mimeType) - - if (response.status === 304) { - let etag = formatETag(response.headers.get('etag'), 'strong') - let ifNoneMatch = cacheKey.headers.get('if-none-match') - let proxyCacheStatus = response.headers.get('CF-Cache-Status') - if (etag) { - if (ifNoneMatch && ifNoneMatch === etag && proxyCacheStatus === 'MISS') { - response.headers.set('CF-Cache-Status', 'EXPIRED') - } else { - response.headers.set('CF-Cache-Status', 'REVALIDATED') - } - response.headers.set('etag', formatETag(etag, 'weak')) - } - } - if (shouldSetBrowserCache) { - response.headers.set('Cache-Control', `max-age=${options.cacheControl.browserTTL}`) - } else { - response.headers.delete('Cache-Control') - } - return response -} - -export { getAssetFromKV, mapRequestToAsset, serveSinglePageApp } -export { Options, CacheControl, MethodNotAllowedError, NotFoundError, InternalError } diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/mocks.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/mocks.ts deleted file mode 100644 index c36b67740bf0..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +++ /dev/null @@ -1,136 +0,0 @@ -const makeServiceWorkerEnv = require('service-worker-mock') - -const HASH = '123HASHBROWN' - -export const getEvent = (request: Request): any => { - const waitUntil = async (callback: any) => { - await callback - } - return { - request, - waitUntil, - } -} -const store: any = { - 'key1.123HASHBROWN.txt': 'val1', - 'key1.123HASHBROWN.png': 'val1', - 'index.123HASHBROWN.html': 'index.html', - 'cache.123HASHBROWN.html': 'cache me if you can', - '测试.123HASHBROWN.html': 'My filename is non-ascii', - '%not-really-percent-encoded.123HASHBROWN.html': 'browser percent encoded', - '%2F.123HASHBROWN.html': 'user percent encoded', - '你好.123HASHBROWN.html': 'I shouldnt be served', - '%E4%BD%A0%E5%A5%BD.123HASHBROWN.html': 'Im important', - 'nohash.txt': 'no hash but still got some result', - 'sub/blah.123HASHBROWN.png': 'picturedis', - 'sub/index.123HASHBROWN.html': 'picturedis', - 'client.123HASHBROWN': 'important file', - 'client.123HASHBROWN/index.html': 'Im here but serve my big bro above', - '你好/index.123HASHBROWN.html': 'My path is non-ascii', -} -export const mockKV = (store: any) => { - return { - get: (path: string) => store[path] || null, - } -} - -export const mockManifest = () => { - return JSON.stringify({ - 'key1.txt': `key1.${HASH}.txt`, - 'key1.png': `key1.${HASH}.png`, - 'cache.html': `cache.${HASH}.html`, - '测试.html': `测试.${HASH}.html`, - '你好.html': `你好.${HASH}.html`, - '%not-really-percent-encoded.html': `%not-really-percent-encoded.${HASH}.html`, - '%2F.html': `%2F.${HASH}.html`, - '%E4%BD%A0%E5%A5%BD.html': `%E4%BD%A0%E5%A5%BD.${HASH}.html`, - 'index.html': `index.${HASH}.html`, - 'sub/blah.png': `sub/blah.${HASH}.png`, - 'sub/index.html': `sub/index.${HASH}.html`, - client: `client.${HASH}`, - 'client/index.html': `client.${HASH}`, - '你好/index.html': `你好/index.${HASH}.html`, - }) -} - -let cacheStore: any = new Map() -interface CacheKey { - url: object - headers: object -} -export const mockCaches = () => { - return { - default: { - async match(key: any) { - let cacheKey: CacheKey = { - url: key.url, - headers: {}, - } - let response - if (key.headers.has('if-none-match')) { - let makeStrongEtag = key.headers.get('if-none-match').replace('W/', '') - Reflect.set(cacheKey.headers, 'etag', makeStrongEtag) - response = cacheStore.get(JSON.stringify(cacheKey)) - } else { - // if client doesn't send if-none-match, we need to iterate through these keys - // and just test the URL - const activeCacheKeys: Array = Array.from(cacheStore.keys()) - for (const cacheStoreKey of activeCacheKeys) { - if (JSON.parse(cacheStoreKey).url === key.url) { - response = cacheStore.get(cacheStoreKey) - } - } - } - // TODO: write test to accomodate for rare scenarios with where range requests accomodate etags - if (response && !key.headers.has('if-none-match')) { - // this appears overly verbose, but is necessary to document edge cache behavior - // The Range request header triggers the response header Content-Range ... - const range = key.headers.get('range') - if (range) { - response.headers.set( - 'content-range', - `bytes ${range.split('=').pop()}/${response.headers.get('content-length')}`, - ) - } - // ... which we are using in this repository to set status 206 - if (response.headers.has('content-range')) { - response.status = 206 - } else { - response.status = 200 - } - let etag = response.headers.get('etag') - if (etag && !etag.includes('W/')) { - response.headers.set('etag', `W/${etag}`) - } - } - return response - }, - async put(key: any, val: Response) { - let headers = new Headers(val.headers) - let url = new URL(key.url) - let resWithBody = new Response(val.body, { headers, status: 200 }) - let resNoBody = new Response(null, { headers, status: 304 }) - let cacheKey: CacheKey = { - url: key.url, - headers: { - etag: `"${url.pathname.replace('/', '')}"`, - }, - } - cacheStore.set(JSON.stringify(cacheKey), resNoBody) - cacheKey.headers = {} - cacheStore.set(JSON.stringify(cacheKey), resWithBody) - return - }, - }, - } -} - -export function mockGlobal() { - Object.assign(global, makeServiceWorkerEnv()) - Object.assign(global, { __STATIC_CONTENT_MANIFEST: mockManifest() }) - Object.assign(global, { __STATIC_CONTENT: mockKV(store) }) - Object.assign(global, { caches: mockCaches() }) -} -export const sleep = (milliseconds: number) => { - return new Promise((resolve) => setTimeout(resolve, milliseconds)) -} diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts deleted file mode 100644 index e840a57a9253..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +++ /dev/null @@ -1,464 +0,0 @@ -import test from 'ava' -import { mockGlobal, getEvent, sleep, mockKV, mockManifest } from '../mocks' -import { getAssetFromKV, mapRequestToAsset } from '../index' -import { KVError } from '../types' - -test('getAssetFromKV return correct val from KV and default caching', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/key1.txt')) - const res = await getAssetFromKV(event) - - if (res) { - t.is(res.headers.get('cache-control'), null) - t.is(res.headers.get('cf-cache-status'), 'MISS') - t.is(await res.text(), 'val1') - t.true(res.headers.get('content-type').includes('text')) - } else { - t.fail('Response was undefined') - } -}) -test('getAssetFromKV evaluated the file matching the extensionless path first /client/ -> client', async (t) => { - mockGlobal() - const event = getEvent(new Request(`https://foo.com/client/`)) - const res = await getAssetFromKV(event) - t.is(await res.text(), 'important file') - t.true(res.headers.get('content-type').includes('text')) -}) -test('getAssetFromKV evaluated the file matching the extensionless path first /client -> client', async (t) => { - mockGlobal() - const event = getEvent(new Request(`https://foo.com/client`)) - const res = await getAssetFromKV(event) - t.is(await res.text(), 'important file') - t.true(res.headers.get('content-type').includes('text')) -}) - -test('getAssetFromKV if not in asset manifest still returns nohash.txt', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/nohash.txt')) - const res = await getAssetFromKV(event) - - if (res) { - t.is(await res.text(), 'no hash but still got some result') - t.true(res.headers.get('content-type').includes('text')) - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV if no asset manifest /client -> client fails', async (t) => { - mockGlobal() - const event = getEvent(new Request(`https://foo.com/client`)) - const error: KVError = await t.throwsAsync(getAssetFromKV(event, { ASSET_MANIFEST: {} })) - t.is(error.status, 404) -}) - -test('getAssetFromKV if sub/ -> sub/index.html served', async (t) => { - mockGlobal() - const event = getEvent(new Request(`https://foo.com/sub`)) - const res = await getAssetFromKV(event) - if (res) { - t.is(await res.text(), 'picturedis') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV gets index.html by default for / requests', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/')) - const res = await getAssetFromKV(event) - - if (res) { - t.is(await res.text(), 'index.html') - t.true(res.headers.get('content-type').includes('html')) - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV non ASCII path support', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/测试.html')) - const res = await getAssetFromKV(event) - - if (res) { - t.is(await res.text(), 'My filename is non-ascii') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV supports browser percent encoded URLs', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://example.com/%not-really-percent-encoded.html')) - const res = await getAssetFromKV(event) - - if (res) { - t.is(await res.text(), 'browser percent encoded') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV supports user percent encoded URLs', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/%2F.html')) - const res = await getAssetFromKV(event) - - if (res) { - t.is(await res.text(), 'user percent encoded') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV only decode URL when necessary', async (t) => { - mockGlobal() - const event1 = getEvent(new Request('https://blah.com/%E4%BD%A0%E5%A5%BD.html')) - const event2 = getEvent(new Request('https://blah.com/你好.html')) - const res1 = await getAssetFromKV(event1) - const res2 = await getAssetFromKV(event2) - - if (res1 && res2) { - t.is(await res1.text(), 'Im important') - t.is(await res2.text(), 'Im important') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV Support for user decode url path', async (t) => { - mockGlobal() - const event1 = getEvent(new Request('https://blah.com/%E4%BD%A0%E5%A5%BD/')) - const event2 = getEvent(new Request('https://blah.com/你好/')) - const res1 = await getAssetFromKV(event1) - const res2 = await getAssetFromKV(event2) - - if (res1 && res2) { - t.is(await res1.text(), 'My path is non-ascii') - t.is(await res2.text(), 'My path is non-ascii') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV custom key modifier', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/docs/sub/blah.png')) - - const customRequestMapper = (request: Request) => { - let defaultModifiedRequest = mapRequestToAsset(request) - - let url = new URL(defaultModifiedRequest.url) - url.pathname = url.pathname.replace('/docs', '') - return new Request(url.toString(), request) - } - - const res = await getAssetFromKV(event, { mapRequestToAsset: customRequestMapper }) - - if (res) { - t.is(await res.text(), 'picturedis') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV when setting browser caching', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/')) - - const res = await getAssetFromKV(event, { cacheControl: { browserTTL: 22 } }) - - if (res) { - t.is(res.headers.get('cache-control'), 'max-age=22') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV when setting custom cache setting', async (t) => { - mockGlobal() - const event1 = getEvent(new Request('https://blah.com/')) - const event2 = getEvent(new Request('https://blah.com/key1.png?blah=34')) - const cacheOnlyPngs = (req: Request) => { - if (new URL(req.url).pathname.endsWith('.png')) - return { - browserTTL: 720, - edgeTTL: 720, - } - else - return { - bypassCache: true, - } - } - - const res1 = await getAssetFromKV(event1, { cacheControl: cacheOnlyPngs }) - const res2 = await getAssetFromKV(event2, { cacheControl: cacheOnlyPngs }) - - if (res1 && res2) { - t.is(res1.headers.get('cache-control'), null) - t.true(res2.headers.get('content-type').includes('png')) - t.is(res2.headers.get('cache-control'), 'max-age=720') - t.is(res2.headers.get('cf-cache-status'), 'MISS') - } else { - t.fail('Response was undefined') - } -}) -test('getAssetFromKV caches on two sequential requests', async (t) => { - mockGlobal() - const resourceKey = 'cache.html' - const resourceVersion = JSON.parse(mockManifest())[resourceKey] - const event1 = getEvent(new Request(`https://blah.com/${resourceKey}`)) - const event2 = getEvent( - new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}"`, - }, - }), - ) - - const res1 = await getAssetFromKV(event1, { cacheControl: { edgeTTL: 720, browserTTL: 720 } }) - await sleep(1) - const res2 = await getAssetFromKV(event2) - - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS') - t.is(res1.headers.get('cache-control'), 'max-age=720') - t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED') - } else { - t.fail('Response was undefined') - } -}) -test('getAssetFromKV does not store max-age on two sequential requests', async (t) => { - mockGlobal() - const resourceKey = 'cache.html' - const resourceVersion = JSON.parse(mockManifest())[resourceKey] - const event1 = getEvent(new Request(`https://blah.com/${resourceKey}`)) - const event2 = getEvent( - new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}"`, - }, - }), - ) - - const res1 = await getAssetFromKV(event1, { cacheControl: { edgeTTL: 720 } }) - await sleep(100) - const res2 = await getAssetFromKV(event2) - - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS') - t.is(res1.headers.get('cache-control'), null) - t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED') - t.is(res2.headers.get('cache-control'), null) - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV does not cache on Cloudflare when bypass cache set', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/')) - - const res = await getAssetFromKV(event, { cacheControl: { bypassCache: true } }) - - if (res) { - t.is(res.headers.get('cache-control'), null) - t.is(res.headers.get('cf-cache-status'), null) - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV with no trailing slash on root', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com')) - const res = await getAssetFromKV(event) - if (res) { - t.is(await res.text(), 'index.html') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV with no trailing slash on a subdirectory', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/sub/blah.png')) - const res = await getAssetFromKV(event) - if (res) { - t.is(await res.text(), 'picturedis') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV no result throws an error', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/random')) - const error: KVError = await t.throwsAsync(getAssetFromKV(event)) - t.is(error.status, 404) -}) -test('getAssetFromKV TTls set to null should not cache on browser or edge', async (t) => { - mockGlobal() - const event = getEvent(new Request('https://blah.com/')) - - const res1 = await getAssetFromKV(event, { cacheControl: { browserTTL: null, edgeTTL: null } }) - await sleep(100) - const res2 = await getAssetFromKV(event, { cacheControl: { browserTTL: null, edgeTTL: null } }) - - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), null) - t.is(res1.headers.get('cache-control'), null) - t.is(res2.headers.get('cf-cache-status'), null) - t.is(res2.headers.get('cache-control'), null) - } else { - t.fail('Response was undefined') - } -}) -test('getAssetFromKV passing in a custom NAMESPACE serves correct asset', async (t) => { - mockGlobal() - let CUSTOM_NAMESPACE = mockKV({ - 'key1.123HASHBROWN.txt': 'val1', - }) - Object.assign(global, { CUSTOM_NAMESPACE }) - const event = getEvent(new Request('https://blah.com/')) - const res = await getAssetFromKV(event) - if (res) { - t.is(await res.text(), 'index.html') - t.true(res.headers.get('content-type').includes('html')) - } else { - t.fail('Response was undefined') - } -}) -test('getAssetFromKV when custom namespace without the asset should fail', async (t) => { - mockGlobal() - let CUSTOM_NAMESPACE = mockKV({ - 'key5.123HASHBROWN.txt': 'customvalu', - }) - - const event = getEvent(new Request('https://blah.com')) - const error: KVError = await t.throwsAsync( - getAssetFromKV(event, { ASSET_NAMESPACE: CUSTOM_NAMESPACE }), - ) - t.is(error.status, 404) -}) -test('getAssetFromKV when namespace not bound fails', async (t) => { - mockGlobal() - var MY_CUSTOM_NAMESPACE = undefined - Object.assign(global, { MY_CUSTOM_NAMESPACE }) - - const event = getEvent(new Request('https://blah.com/')) - const error: KVError = await t.throwsAsync( - getAssetFromKV(event, { ASSET_NAMESPACE: MY_CUSTOM_NAMESPACE }), - ) - t.is(error.status, 500) -}) - -test('getAssetFromKV when if-none-match === active resource version, should revalidate', async (t) => { - mockGlobal() - const resourceKey = 'key1.png' - const resourceVersion = JSON.parse(mockManifest())[resourceKey] - const event1 = getEvent(new Request(`https://blah.com/${resourceKey}`)) - const event2 = getEvent( - new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `W/"${resourceVersion}"`, - }, - }), - ) - - const res1 = await getAssetFromKV(event1, { cacheControl: { edgeTTL: 720 } }) - await sleep(100) - const res2 = await getAssetFromKV(event2) - - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS') - t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV when if-none-match equals etag of stale resource then should bypass cache', async (t) => { - mockGlobal() - const resourceKey = 'key1.png' - const resourceVersion = JSON.parse(mockManifest())[resourceKey] - const req1 = new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}"`, - }, - }) - const req2 = new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}-another-version"`, - }, - }) - const event = getEvent(req1) - const event2 = getEvent(req2) - const res1 = await getAssetFromKV(event, { cacheControl: { edgeTTL: 720 } }) - const res2 = await getAssetFromKV(event) - const res3 = await getAssetFromKV(event2) - if (res1 && res2 && res3) { - t.is(res1.headers.get('cf-cache-status'), 'MISS') - t.is(res2.headers.get('etag'), `W/${req1.headers.get('if-none-match')}`) - t.is(res2.headers.get('cf-cache-status'), 'REVALIDATED') - t.not(res3.headers.get('etag'), req2.headers.get('if-none-match')) - t.is(res3.headers.get('cf-cache-status'), 'MISS') - } else { - t.fail('Response was undefined') - } -}) -test('getAssetFromKV when resource in cache, etag should be weakened before returned to eyeball', async (t) => { - mockGlobal() - const resourceKey = 'key1.png' - const resourceVersion = JSON.parse(mockManifest())[resourceKey] - const req1 = new Request(`https://blah.com/${resourceKey}`, { - headers: { - 'if-none-match': `"${resourceVersion}"`, - }, - }) - const event = getEvent(req1) - const res1 = await getAssetFromKV(event, { cacheControl: { edgeTTL: 720 } }) - const res2 = await getAssetFromKV(event) - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS') - t.is(res2.headers.get('etag'), `W/${req1.headers.get('if-none-match')}`) - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV if-none-match not sent but resource in cache, should return cache hit 200 OK', async (t) => { - const resourceKey = 'cache.html' - const event = getEvent(new Request(`https://blah.com/${resourceKey}`)) - const res1 = await getAssetFromKV(event, { cacheControl: { edgeTTL: 720 } }) - await sleep(1) - const res2 = await getAssetFromKV(event) - if (res1 && res2) { - t.is(res1.headers.get('cf-cache-status'), 'MISS') - t.is(res1.headers.get('cache-control'), null) - t.is(res2.status, 200) - t.is(res2.headers.get('cf-cache-status'), 'HIT') - } else { - t.fail('Response was undefined') - } -}) - -test('getAssetFromKV if range request submitted and resource in cache, request fulfilled', async (t) => { - const resourceKey = 'cache.html' - const event1 = getEvent(new Request(`https://blah.com/${resourceKey}`)) - const event2 = getEvent( - new Request(`https://blah.com/${resourceKey}`, { headers: { range: 'bytes=0-10' } }), - ) - const res1 = getAssetFromKV(event1, { cacheControl: { edgeTTL: 720 } }) - await res1 - await sleep(2) - const res2 = await getAssetFromKV(event2) - if (res2.headers.has('content-range')) { - t.is(res2.status, 206) - } else { - t.fail('Response was undefined') - } -}) - -test.todo('getAssetFromKV when body not empty, should invoke .cancel()') diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts deleted file mode 100644 index 2b23d93af4e4..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +++ /dev/null @@ -1,33 +0,0 @@ -import test from 'ava' -import { mockGlobal } from '../mocks' -import { mapRequestToAsset } from '../index' - -test('mapRequestToAsset() correctly changes /about -> /about/index.html', async (t) => { - mockGlobal() - let path = '/about' - let request = new Request(`https://foo.com${path}`) - let newRequest = mapRequestToAsset(request) - t.is(newRequest.url, request.url + '/index.html') -}) - -test('mapRequestToAsset() correctly changes /about/ -> /about/index.html', async (t) => { - let path = '/about/' - let request = new Request(`https://foo.com${path}`) - let newRequest = mapRequestToAsset(request) - t.is(newRequest.url, request.url + 'index.html') -}) - -test('mapRequestToAsset() correctly changes /about.me/ -> /about.me/index.html', async (t) => { - let path = '/about.me/' - let request = new Request(`https://foo.com${path}`) - let newRequest = mapRequestToAsset(request) - t.is(newRequest.url, request.url + 'index.html') -}) - -test('mapRequestToAsset() correctly changes /about -> /about/default.html', async (t) => { - mockGlobal() - let path = '/about' - let request = new Request(`https://foo.com${path}`) - let newRequest = mapRequestToAsset(request, { defaultDocument: 'default.html' }) - t.is(newRequest.url, request.url + '/default.html') -}) diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts deleted file mode 100644 index 9b95b6d0c765..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +++ /dev/null @@ -1,42 +0,0 @@ -import test from 'ava' -import { mockGlobal } from '../mocks' -import { serveSinglePageApp } from '../index' - -function testRequest(path: string) { - mockGlobal() - let url = new URL('https://example.com') - url.pathname = path - let request = new Request(url.toString()) - - return request -} - -test('serveSinglePageApp returns root asset path when request path ends in .html', async (t) => { - let path = '/foo/thing.html' - let request = testRequest(path) - - let expected_request = testRequest('/index.html') - let actual_request = serveSinglePageApp(request) - - t.deepEqual(expected_request, actual_request) -}) - -test('serveSinglePageApp returns root asset path when request path does not have extension', async (t) => { - let path = '/foo/thing' - let request = testRequest(path) - - let expected_request = testRequest('/index.html') - let actual_request = serveSinglePageApp(request) - - t.deepEqual(expected_request, actual_request) -}) - -test('serveSinglePageApp returns requested asset when request path has non-html extension', async (t) => { - let path = '/foo/thing.js' - let request = testRequest(path) - - let expected_request = request - let actual_request = serveSinglePageApp(request) - - t.deepEqual(expected_request, actual_request) -}) diff --git a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/types.ts b/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/types.ts deleted file mode 100644 index ace5ffd511aa..000000000000 --- a/packages/wrangler/vendor/@cloudflare/kv-asset-handler/src/types.ts +++ /dev/null @@ -1,39 +0,0 @@ -export type CacheControl = { - browserTTL: number - edgeTTL: number - bypassCache: boolean -} -export type Options = { - cacheControl: ((req: Request) => Partial) | Partial - ASSET_NAMESPACE: any - ASSET_MANIFEST: Object | string - mapRequestToAsset?: (req: Request, options?: Partial) => Request - defaultMimeType: string - defaultDocument: string -} - -export class KVError extends Error { - constructor(message?: string, status: number = 500) { - super(message) - // see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html - Object.setPrototypeOf(this, new.target.prototype) // restore prototype chain - this.name = KVError.name // stack traces display correctly now - this.status = status - } - status: number -} -export class MethodNotAllowedError extends KVError { - constructor(message: string = `Not a valid request method`, status: number = 405) { - super(message, status) - } -} -export class NotFoundError extends KVError { - constructor(message: string = `Not Found`, status: number = 404) { - super(message, status) - } -} -export class InternalError extends KVError { - constructor(message: string = `Internal Error in KV Asset Handler`, status: number = 500) { - super(message, status) - } -} diff --git a/packages/wrangler/vendor/wrangler-mime/CHANGELOG.md b/packages/wrangler/vendor/wrangler-mime/CHANGELOG.md deleted file mode 100644 index 5d0fae936b3d..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/CHANGELOG.md +++ /dev/null @@ -1,289 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - -### [2.5.2](https://github.com/broofa/mime/compare/v2.5.0...v2.5.2) (2021-02-17) - - -### Bug Fixes - -* update to mime-db@1.46.0, fixes [#253](https://github.com/broofa/mime/issues/253) ([f10e6aa](https://github.com/broofa/mime/commit/f10e6aa62e1356de7e2491d7fb4374c8dac65800)) - -## [2.5.0](https://github.com/broofa/mime/compare/v2.4.7...v2.5.0) (2021-01-16) - - -### Features - -* improved CLI ([#244](https://github.com/broofa/mime/issues/244)) ([c8a8356](https://github.com/broofa/mime/commit/c8a8356e3b27f3ef46b64b89b428fdb547b14d5f)) - -### [2.4.7](https://github.com/broofa/mime/compare/v2.4.6...v2.4.7) (2020-12-16) - - -### Bug Fixes - -* update to latest mime-db ([43b09ef](https://github.com/broofa/mime/commit/43b09eff0233eacc449af2b1f99a19ba9e104a44)) - -### [2.4.6](https://github.com/broofa/mime/compare/v2.4.5...v2.4.6) (2020-05-27) - - -### Bug Fixes - -* add cli.js to package.json files ([#237](https://github.com/broofa/mime/issues/237)) ([6c070bc](https://github.com/broofa/mime/commit/6c070bc298fa12a48e2ed126fbb9de641a1e7ebc)) - -### [2.4.5](https://github.com/broofa/mime/compare/v2.4.4...v2.4.5) (2020-05-01) - - -### Bug Fixes - -* fix [#236](https://github.com/broofa/mime/issues/236) ([7f4ecd0](https://github.com/broofa/mime/commit/7f4ecd0d850ed22c9e3bfda2c11fc74e4dde12a7)) -* update to latest mime-db ([c5cb3f2](https://github.com/broofa/mime/commit/c5cb3f2ab8b07642a066efbde1142af1b90c927b)) - -### [2.4.4](https://github.com/broofa/mime/compare/v2.4.3...v2.4.4) (2019-06-07) - - - -### [2.4.3](https://github.com/broofa/mime/compare/v2.4.2...v2.4.3) (2019-05-15) - - - -### [2.4.2](https://github.com/broofa/mime/compare/v2.4.1...v2.4.2) (2019-04-07) - - -### Bug Fixes - -* don't use arrow function introduced in 2.4.1 ([2e00b5c](https://github.com/broofa/mime/commit/2e00b5c)) - - - -### [2.4.1](https://github.com/broofa/mime/compare/v2.4.0...v2.4.1) (2019-04-03) - - -### Bug Fixes - -* update MDN and mime-db types ([3e567a9](https://github.com/broofa/mime/commit/3e567a9)) - - - -# [2.4.0](https://github.com/broofa/mime/compare/v2.3.1...v2.4.0) (2018-11-26) - - -### Features - -* Bind exported methods ([9d2a7b8](https://github.com/broofa/mime/commit/9d2a7b8)) -* update to mime-db@1.37.0 ([49e6e41](https://github.com/broofa/mime/commit/49e6e41)) - - - -### [2.3.1](https://github.com/broofa/mime/compare/v2.3.0...v2.3.1) (2018-04-11) - - -### Bug Fixes - -* fix [#198](https://github.com/broofa/mime/issues/198) ([25ca180](https://github.com/broofa/mime/commit/25ca180)) - - - -# [2.3.0](https://github.com/broofa/mime/compare/v2.2.2...v2.3.0) (2018-04-11) - - -### Bug Fixes - -* fix [#192](https://github.com/broofa/mime/issues/192) ([5c35df6](https://github.com/broofa/mime/commit/5c35df6)) - - -### Features - -* add travis-ci testing ([d64160f](https://github.com/broofa/mime/commit/d64160f)) - - - -### [2.2.2](https://github.com/broofa/mime/compare/v2.2.1...v2.2.2) (2018-03-30) - - -### Bug Fixes - -* update types files to mime-db@1.32.0 ([85aac16](https://github.com/broofa/mime/commit/85aac16)) - - -### [2.2.1](https://github.com/broofa/mime/compare/v2.2.0...v2.2.1) (2018-03-30) - - -### Bug Fixes - -* Retain type->extension mappings for non-default types. Fixes [#180](https://github.com/broofa/mime/issues/180) ([b5c83fb](https://github.com/broofa/mime/commit/b5c83fb)) - - - -# [2.2.0](https://github.com/broofa/mime/compare/v2.1.0...v2.2.0) (2018-01-04) - - -### Features - -* Retain type->extension mappings for non-default types. Fixes [#180](https://github.com/broofa/mime/issues/180) ([10f82ac](https://github.com/broofa/mime/commit/10f82ac)) - - - -# [2.1.0](https://github.com/broofa/mime/compare/v2.0.5...v2.1.0) (2017-12-22) - - -### Features - -* Upgrade to mime-db@1.32.0. Fixes [#185](https://github.com/broofa/mime/issues/185) ([3f775ba](https://github.com/broofa/mime/commit/3f775ba)) - - - -### [2.0.5](https://github.com/broofa/mime/compare/v2.0.1...v2.0.5) (2017-12-22) - - -### Bug Fixes - -* ES5 support (back to node v0.4) ([f14ccb6](https://github.com/broofa/mime/commit/f14ccb6)) - - - -# Changelog - -### v2.0.4 (24/11/2017) -- [**closed**] Switch to mime-score module for resolving extension contention issues. [#182](https://github.com/broofa/mime/issues/182) -- [**closed**] Update mime-db to 1.31.0 in v1.x branch [#181](https://github.com/broofa/mime/issues/181) - ---- - -## v1.5.0 (22/11/2017) -- [**closed**] need ES5 version ready in npm package [#179](https://github.com/broofa/mime/issues/179) -- [**closed**] mime-db no trace of iWork - pages / numbers / etc. [#178](https://github.com/broofa/mime/issues/178) -- [**closed**] How it works in brownser ? [#176](https://github.com/broofa/mime/issues/176) -- [**closed**] Missing `./Mime` [#175](https://github.com/broofa/mime/issues/175) -- [**closed**] Vulnerable Regular Expression [#167](https://github.com/broofa/mime/issues/167) - ---- - -### v2.0.3 (25/09/2017) -*No changelog for this release.* - ---- - -### v1.4.1 (25/09/2017) -- [**closed**] Issue when bundling with webpack [#172](https://github.com/broofa/mime/issues/172) - ---- - -### v2.0.2 (15/09/2017) -- [**V2**] fs.readFileSync is not a function [#165](https://github.com/broofa/mime/issues/165) -- [**closed**] The extension for video/quicktime should map to .mov, not .qt [#164](https://github.com/broofa/mime/issues/164) -- [**V2**] [v2 Feedback request] Mime class API [#163](https://github.com/broofa/mime/issues/163) -- [**V2**] [v2 Feedback request] Resolving conflicts over extensions [#162](https://github.com/broofa/mime/issues/162) -- [**V2**] Allow callers to load module with official, full, or no defined types. [#161](https://github.com/broofa/mime/issues/161) -- [**V2**] Use "facets" to resolve extension conflicts [#160](https://github.com/broofa/mime/issues/160) -- [**V2**] Remove fs and path dependencies [#152](https://github.com/broofa/mime/issues/152) -- [**V2**] Default content-type should not be application/octet-stream [#139](https://github.com/broofa/mime/issues/139) -- [**V2**] reset mime-types [#124](https://github.com/broofa/mime/issues/124) -- [**V2**] Extensionless paths should return null or false [#113](https://github.com/broofa/mime/issues/113) - ---- - -### v2.0.1 (14/09/2017) -- [**closed**] Changelog for v2.0 does not mention breaking changes [#171](https://github.com/broofa/mime/issues/171) -- [**closed**] MIME breaking with 'class' declaration as it is without 'use strict mode' [#170](https://github.com/broofa/mime/issues/170) - ---- - -## v2.0.0 (12/09/2017) -- [**closed**] woff and woff2 [#168](https://github.com/broofa/mime/issues/168) - ---- - -## v1.4.0 (28/08/2017) -- [**closed**] support for ac3 voc files [#159](https://github.com/broofa/mime/issues/159) -- [**closed**] Help understanding change from application/xml to text/xml [#158](https://github.com/broofa/mime/issues/158) -- [**closed**] no longer able to override mimetype [#157](https://github.com/broofa/mime/issues/157) -- [**closed**] application/vnd.adobe.photoshop [#147](https://github.com/broofa/mime/issues/147) -- [**closed**] Directories should appear as something other than application/octet-stream [#135](https://github.com/broofa/mime/issues/135) -- [**closed**] requested features [#131](https://github.com/broofa/mime/issues/131) -- [**closed**] Make types.json loading optional? [#129](https://github.com/broofa/mime/issues/129) -- [**closed**] Cannot find module './types.json' [#120](https://github.com/broofa/mime/issues/120) -- [**V2**] .wav files show up as "audio/x-wav" instead of "audio/x-wave" [#118](https://github.com/broofa/mime/issues/118) -- [**closed**] Don't be a pain in the ass for node community [#108](https://github.com/broofa/mime/issues/108) -- [**closed**] don't make default_type global [#78](https://github.com/broofa/mime/issues/78) -- [**closed**] mime.extension() fails if the content-type is parameterized [#74](https://github.com/broofa/mime/issues/74) - ---- - -### v1.3.6 (11/05/2017) -- [**closed**] .md should be text/markdown as of March 2016 [#154](https://github.com/broofa/mime/issues/154) -- [**closed**] Error while installing mime [#153](https://github.com/broofa/mime/issues/153) -- [**closed**] application/manifest+json [#149](https://github.com/broofa/mime/issues/149) -- [**closed**] Dynamic adaptive streaming over HTTP (DASH) file extension typo [#141](https://github.com/broofa/mime/issues/141) -- [**closed**] charsets image/png undefined [#140](https://github.com/broofa/mime/issues/140) -- [**closed**] Mime-db dependency out of date [#130](https://github.com/broofa/mime/issues/130) -- [**closed**] how to support plist? [#126](https://github.com/broofa/mime/issues/126) -- [**closed**] how does .types file format look like? [#123](https://github.com/broofa/mime/issues/123) -- [**closed**] Feature: support for expanding MIME patterns [#121](https://github.com/broofa/mime/issues/121) -- [**closed**] DEBUG_MIME doesn't work [#117](https://github.com/broofa/mime/issues/117) - ---- - -### v1.3.4 (06/02/2015) -*No changelog for this release.* - ---- - -### v1.3.3 (06/02/2015) -*No changelog for this release.* - ---- - -### v1.3.1 (05/02/2015) -- [**closed**] Consider adding support for Handlebars .hbs file ending [#111](https://github.com/broofa/mime/issues/111) -- [**closed**] Consider adding support for hjson. [#110](https://github.com/broofa/mime/issues/110) -- [**closed**] Add mime type for Opus audio files [#94](https://github.com/broofa/mime/issues/94) -- [**closed**] Consider making the `Requesting New Types` information more visible [#77](https://github.com/broofa/mime/issues/77) - ---- - -## v1.3.0 (05/02/2015) -- [**closed**] Add common name? [#114](https://github.com/broofa/mime/issues/114) -- [**closed**] application/x-yaml [#104](https://github.com/broofa/mime/issues/104) -- [**closed**] Add mime type for WOFF file format 2.0 [#102](https://github.com/broofa/mime/issues/102) -- [**closed**] application/x-msi for .msi [#99](https://github.com/broofa/mime/issues/99) -- [**closed**] Add mimetype for gettext translation files [#98](https://github.com/broofa/mime/issues/98) -- [**closed**] collaborators [#88](https://github.com/broofa/mime/issues/88) -- [**closed**] getting errot in installation of mime module...any1 can help? [#87](https://github.com/broofa/mime/issues/87) -- [**closed**] should application/json's charset be utf8? [#86](https://github.com/broofa/mime/issues/86) -- [**closed**] Add "license" and "licenses" to package.json [#81](https://github.com/broofa/mime/issues/81) -- [**closed**] lookup with extension-less file on Windows returns wrong type [#68](https://github.com/broofa/mime/issues/68) - ---- - -### v1.2.11 (15/08/2013) -- [**closed**] Update mime.types [#65](https://github.com/broofa/mime/issues/65) -- [**closed**] Publish a new version [#63](https://github.com/broofa/mime/issues/63) -- [**closed**] README should state upfront that "application/octet-stream" is default for unknown extension [#55](https://github.com/broofa/mime/issues/55) -- [**closed**] Suggested improvement to the charset API [#52](https://github.com/broofa/mime/issues/52) - ---- - -### v1.2.10 (25/07/2013) -- [**closed**] Mime type for woff files should be application/font-woff and not application/x-font-woff [#62](https://github.com/broofa/mime/issues/62) -- [**closed**] node.types in conflict with mime.types [#51](https://github.com/broofa/mime/issues/51) - ---- - -### v1.2.9 (17/01/2013) -- [**closed**] Please update "mime" NPM [#49](https://github.com/broofa/mime/issues/49) -- [**closed**] Please add semicolon [#46](https://github.com/broofa/mime/issues/46) -- [**closed**] parse full mime types [#43](https://github.com/broofa/mime/issues/43) - ---- - -### v1.2.8 (10/01/2013) -- [**closed**] /js directory mime is application/javascript. Is it correct? [#47](https://github.com/broofa/mime/issues/47) -- [**closed**] Add mime types for lua code. [#45](https://github.com/broofa/mime/issues/45) - ---- - -### v1.2.7 (19/10/2012) -- [**closed**] cannot install 1.2.7 via npm [#41](https://github.com/broofa/mime/issues/41) -- [**closed**] Transfer ownership to @broofa [#36](https://github.com/broofa/mime/issues/36) -- [**closed**] it's wrong to set charset to UTF-8 for text [#30](https://github.com/broofa/mime/issues/30) -- [**closed**] Allow multiple instances of MIME types container [#27](https://github.com/broofa/mime/issues/27) diff --git a/packages/wrangler/vendor/wrangler-mime/LICENSE b/packages/wrangler/vendor/wrangler-mime/LICENSE deleted file mode 100644 index d3f46f7e1459..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2010 Benjamin Thomas, Robert Kieffer - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/packages/wrangler/vendor/wrangler-mime/Mime.js b/packages/wrangler/vendor/wrangler-mime/Mime.js deleted file mode 100644 index 969a66e41fbb..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/Mime.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -/** - * @param typeMap [Object] Map of MIME type -> Array[extensions] - * @param ... - */ -function Mime() { - this._types = Object.create(null); - this._extensions = Object.create(null); - - for (let i = 0; i < arguments.length; i++) { - this.define(arguments[i]); - } - - this.define = this.define.bind(this); - this.getType = this.getType.bind(this); - this.getExtension = this.getExtension.bind(this); -} - -/** - * Define mimetype -> extension mappings. Each key is a mime-type that maps - * to an array of extensions associated with the type. The first extension is - * used as the default extension for the type. - * - * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); - * - * If a type declares an extension that has already been defined, an error will - * be thrown. To suppress this error and force the extension to be associated - * with the new type, pass `force`=true. Alternatively, you may prefix the - * extension with "*" to map the type to extension, without mapping the - * extension to the type. - * - * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']}); - * - * - * @param map (Object) type definitions - * @param force (Boolean) if true, force overriding of existing definitions - */ -Mime.prototype.define = function(typeMap, force) { - for (let type in typeMap) { - let extensions = typeMap[type].map(function(t) { - return t.toLowerCase(); - }); - type = type.toLowerCase(); - - for (let i = 0; i < extensions.length; i++) { - const ext = extensions[i]; - - // '*' prefix = not the preferred type for this extension. So fixup the - // extension, and skip it. - if (ext[0] === '*') { - continue; - } - - if (!force && (ext in this._types)) { - throw new Error( - 'Attempt to change mapping for "' + ext + - '" extension from "' + this._types[ext] + '" to "' + type + - '". Pass `force=true` to allow this, otherwise remove "' + ext + - '" from the list of extensions for "' + type + '".' - ); - } - - this._types[ext] = type; - } - - // Use first extension as default - if (force || !this._extensions[type]) { - const ext = extensions[0]; - this._extensions[type] = (ext[0] !== '*') ? ext : ext.substr(1); - } - } -}; - -/** - * Lookup a mime type based on extension - */ -Mime.prototype.getType = function(path) { - path = String(path); - let last = path.replace(/^.*[/\\]/, '').toLowerCase(); - let ext = last.replace(/^.*\./, '').toLowerCase(); - - let hasPath = last.length < path.length; - let hasDot = ext.length < last.length - 1; - - return (hasDot || !hasPath) && this._types[ext] || null; -}; - -/** - * Return file extension associated with a mime type - */ -Mime.prototype.getExtension = function(type) { - type = /^\s*([^;\s]*)/.test(type) && RegExp.$1; - return type && this._extensions[type.toLowerCase()] || null; -}; - -module.exports = Mime; diff --git a/packages/wrangler/vendor/wrangler-mime/README.md b/packages/wrangler/vendor/wrangler-mime/README.md deleted file mode 100644 index b08316f24b10..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/README.md +++ /dev/null @@ -1,187 +0,0 @@ - -# Mime - -A comprehensive, compact MIME type module. - -[![Build Status](https://travis-ci.org/broofa/mime.svg?branch=master)](https://travis-ci.org/broofa/mime) - -## Version 2 Notes - -Version 2 is a breaking change from 1.x as the semver implies. Specifically: - -* `lookup()` renamed to `getType()` -* `extension()` renamed to `getExtension()` -* `charset()` and `load()` methods have been removed - -If you prefer the legacy version of this module please `npm install mime@^1`. Version 1 docs may be found [here](https://github.com/broofa/mime/tree/v1.4.0). - -## Install - -### NPM -``` -npm install mime -``` - -### Browser - -It is recommended that you use a bundler such as -[webpack](https://webpack.github.io/) or [browserify](http://browserify.org/) to -package your code. However, browser-ready versions are available via wzrd.in. -E.g. For the full version: - - - - -Or, for the `mime/lite` version: - - - - -## Quick Start - -For the full version (800+ MIME types, 1,000+ extensions): - -```javascript -const mime = require('mime'); - -mime.getType('txt'); // ⇨ 'text/plain' -mime.getExtension('text/plain'); // ⇨ 'txt' -``` - -See [Mime API](#mime-api) below for API details. - -## Lite Version - -There is also a "lite" version of this module that omits vendor-specific -(`*/vnd.*`) and experimental (`*/x-*`) types. It weighs in at ~2.5KB, compared -to 8KB for the full version. To load the lite version: - -```javascript -const mime = require('mime/lite'); -``` - -## Mime .vs. mime-types .vs. mime-db modules - -For those of you wondering about the difference between these [popular] NPM modules, -here's a brief rundown ... - -[`mime-db`](https://github.com/jshttp/mime-db) is "the source of -truth" for MIME type information. It is not an API. Rather, it is a canonical -dataset of mime type definitions pulled from IANA, Apache, NGINX, and custom mappings -submitted by the Node.js community. - -[`mime-types`](https://github.com/jshttp/mime-types) is a thin -wrapper around mime-db that provides an API drop-in compatible(ish) with `mime @ < v1.3.6` API. - -`mime` is, as of v2, a self-contained module bundled with a pre-optimized version -of the `mime-db` dataset. It provides a simplified API with the following characteristics: - -* Intelligently resolved type conflicts (See [mime-score](https://github.com/broofa/mime-score) for details) -* Method naming consistent with industry best-practices -* Compact footprint. E.g. The minified+compressed sizes of the various modules: - -Module | Size ---- | --- -`mime-db` | 18 KB -`mime-types` | same as mime-db -`mime` | 8 KB -`mime/lite` | 2 KB - -## Mime API - -Both `require('mime')` and `require('mime/lite')` return instances of the MIME -class, documented below. - -Note: Inputs to this API are case-insensitive. Outputs (returned values) will -be lowercase. - -### new Mime(typeMap, ... more maps) - -Most users of this module will not need to create Mime instances directly. -However if you would like to create custom mappings, you may do so as follows -... - -```javascript -// Require Mime class -const Mime = require('mime/Mime'); - -// Define mime type -> extensions map -const typeMap = { - 'text/abc': ['abc', 'alpha', 'bet'], - 'text/def': ['leppard'] -}; - -// Create and use Mime instance -const myMime = new Mime(typeMap); -myMime.getType('abc'); // ⇨ 'text/abc' -myMime.getExtension('text/def'); // ⇨ 'leppard' -``` - -If more than one map argument is provided, each map is `define()`ed (see below), in order. - -### mime.getType(pathOrExtension) - -Get mime type for the given path or extension. E.g. - -```javascript -mime.getType('js'); // ⇨ 'application/javascript' -mime.getType('json'); // ⇨ 'application/json' - -mime.getType('txt'); // ⇨ 'text/plain' -mime.getType('dir/text.txt'); // ⇨ 'text/plain' -mime.getType('dir\\text.txt'); // ⇨ 'text/plain' -mime.getType('.text.txt'); // ⇨ 'text/plain' -mime.getType('.txt'); // ⇨ 'text/plain' -``` - -`null` is returned in cases where an extension is not detected or recognized - -```javascript -mime.getType('foo/txt'); // ⇨ null -mime.getType('bogus_type'); // ⇨ null -``` - -### mime.getExtension(type) -Get extension for the given mime type. Charset options (often included in -Content-Type headers) are ignored. - -```javascript -mime.getExtension('text/plain'); // ⇨ 'txt' -mime.getExtension('application/json'); // ⇨ 'json' -mime.getExtension('text/html; charset=utf8'); // ⇨ 'html' -``` - -### mime.define(typeMap[, force = false]) - -Define [more] type mappings. - -`typeMap` is a map of type -> extensions, as documented in `new Mime`, above. - -By default this method will throw an error if you try to map a type to an -extension that is already assigned to another type. Passing `true` for the -`force` argument will suppress this behavior (overriding any previous mapping). - -```javascript -mime.define({'text/x-abc': ['abc', 'abcd']}); - -mime.getType('abcd'); // ⇨ 'text/x-abc' -mime.getExtension('text/x-abc') // ⇨ 'abc' -``` - -## Command Line - - mime [path_or_extension] - -E.g. - - > mime scripts/jquery.js - application/javascript - ----- -Markdown generated from [src/README_js.md](src/README_js.md) by [![RunMD Logo](http://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd) \ No newline at end of file diff --git a/packages/wrangler/vendor/wrangler-mime/cli.js b/packages/wrangler/vendor/wrangler-mime/cli.js deleted file mode 100755 index ab70a49c41ae..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/cli.js +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -process.title = 'mime'; -let mime = require('.'); -let pkg = require('./package.json'); -let args = process.argv.splice(2); - -if (args.includes('--version') || args.includes('-v') || args.includes('--v')) { - console.log(pkg.version); - process.exit(0); -} else if (args.includes('--name') || args.includes('-n') || args.includes('--n')) { - console.log(pkg.name); - process.exit(0); -} else if (args.includes('--help') || args.includes('-h') || args.includes('--h')) { - console.log(pkg.name + ' - ' + pkg.description + '\n'); - console.log(`Usage: - - mime [flags] [path_or_extension] - - Flags: - --help, -h Show this message - --version, -v Display the version - --name, -n Print the name of the program - - Note: the command will exit after it executes if a command is specified - The path_or_extension is the path to the file or the extension of the file. - - Examples: - mime --help - mime --version - mime --name - mime -v - mime src/log.js - mime new.py - mime foo.sh - `); - process.exit(0); -} - -let file = args[0]; -let type = mime.getType(file); - -process.stdout.write(type + '\n'); - diff --git a/packages/wrangler/vendor/wrangler-mime/index.js b/packages/wrangler/vendor/wrangler-mime/index.js deleted file mode 100644 index fadcf8d63cb0..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -let Mime = require('./Mime'); -module.exports = new Mime(require('./types/standard'), require('./types/other')); diff --git a/packages/wrangler/vendor/wrangler-mime/lite.js b/packages/wrangler/vendor/wrangler-mime/lite.js deleted file mode 100644 index 835cffb306af..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/lite.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -let Mime = require('./Mime'); -module.exports = new Mime(require('./types/standard')); diff --git a/packages/wrangler/vendor/wrangler-mime/package.json b/packages/wrangler/vendor/wrangler-mime/package.json deleted file mode 100644 index 2d430bec097f..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "author": { - "name": "Robert Kieffer", - "url": "http://github.com/broofa", - "email": "robert@broofa.com" - }, - "engines": { - "node": ">=4.0.0" - }, - "bin": { - "mime": "cli.js" - }, - "contributors": [], - "description": "A comprehensive library for mime-type mapping", - "license": "MIT", - "dependencies": {}, - "devDependencies": { - "benchmark": "*", - "chalk": "4.1.0", - "eslint": "7.20.0", - "mime-db": "1.46.0", - "mime-score": "1.2.0", - "mime-types": "2.1.28", - "mocha": "8.3.0", - "runmd": "*", - "standard-version": "9.1.0" - }, - "files": [ - "index.js", - "lite.js", - "Mime.js", - "cli.js", - "/types" - ], - "scripts": { - "prepare": "node src/build.js && runmd --output README.md src/README_js.md", - "release": "standard-version", - "benchmark": "node src/benchmark.js", - "md": "runmd --watch --output README.md src/README_js.md", - "test": "mocha src/test.js" - }, - "keywords": [ - "util", - "mime" - ], - "name": "wrangler-mime", - "repository": { - "url": "https://github.com/broofa/mime", - "type": "git" - }, - "version": "2.5.2" -} diff --git a/packages/wrangler/vendor/wrangler-mime/types/other.js b/packages/wrangler/vendor/wrangler-mime/types/other.js deleted file mode 100644 index 7c831d18f76b..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/types/other.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {"application/prs.cww":["cww"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}; \ No newline at end of file diff --git a/packages/wrangler/vendor/wrangler-mime/types/standard.js b/packages/wrangler/vendor/wrangler-mime/types/standard.js deleted file mode 100644 index cf282761d1a4..000000000000 --- a/packages/wrangler/vendor/wrangler-mime/types/standard.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]}; \ No newline at end of file