wrangler 0.0.0-e64812e → 0.0.0-e6c71262
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -4
- package/bin/wrangler.js +170 -62
- package/kv-asset-handler.js +1 -0
- package/miniflare-dist/index.mjs +1637 -81
- package/package.json +198 -152
- package/src/__tests__/access.test.ts +25 -0
- package/src/__tests__/api-dev.test.ts +238 -0
- package/src/__tests__/api-devregistry.test.ts +121 -0
- package/src/__tests__/api.test.ts +102 -0
- package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
- package/src/__tests__/config-cache.test.ts +30 -24
- package/src/__tests__/configuration.test.ts +4660 -3363
- package/src/__tests__/constellation.test.ts +371 -0
- package/src/__tests__/d1/d1.test.ts +82 -0
- package/src/__tests__/d1/execute.test.ts +66 -0
- package/src/__tests__/d1/migrate.test.ts +257 -0
- package/src/__tests__/d1/splitter.test.ts +255 -0
- package/src/__tests__/delete.test.ts +272 -0
- package/src/__tests__/deployments.test.ts +369 -0
- package/src/__tests__/dev.test.tsx +1589 -952
- package/src/__tests__/generate.test.ts +254 -0
- package/src/__tests__/get-host-from-url.test.ts +16 -0
- package/src/__tests__/guess-worker-format.test.ts +103 -68
- package/src/__tests__/helpers/cmd-shim.d.ts +6 -6
- package/src/__tests__/helpers/end-event-loop.ts +6 -0
- package/src/__tests__/helpers/mock-account-id.ts +24 -24
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-bin.ts +20 -20
- package/src/__tests__/helpers/mock-console.ts +64 -39
- package/src/__tests__/helpers/mock-dialogs.ts +88 -79
- package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +11 -0
- package/src/__tests__/helpers/mock-http-server.ts +30 -30
- package/src/__tests__/helpers/mock-istty.ts +65 -18
- package/src/__tests__/helpers/mock-known-routes.ts +12 -0
- package/src/__tests__/helpers/mock-kv.ts +41 -28
- package/src/__tests__/helpers/mock-oauth-flow.ts +241 -233
- package/src/__tests__/helpers/mock-process.ts +34 -0
- package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
- package/src/__tests__/helpers/mock-stdin.ts +82 -77
- package/src/__tests__/helpers/mock-web-socket.ts +21 -21
- package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
- package/src/__tests__/helpers/msw/handlers/access.ts +13 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +160 -0
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +81 -0
- package/src/__tests__/helpers/msw/handlers/oauth.ts +31 -0
- package/src/__tests__/helpers/msw/handlers/r2.ts +60 -0
- package/src/__tests__/helpers/msw/handlers/script.ts +56 -0
- package/src/__tests__/helpers/msw/handlers/user.ts +52 -0
- package/src/__tests__/helpers/msw/handlers/zones.ts +20 -0
- package/src/__tests__/helpers/msw/index.ts +52 -0
- package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
- package/src/__tests__/helpers/run-in-tmp.ts +27 -28
- package/src/__tests__/helpers/run-wrangler.ts +8 -8
- package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
- package/src/__tests__/helpers/worker-scripts/child-wrangler.toml +1 -0
- package/src/__tests__/helpers/worker-scripts/hello-world-worker.js +5 -0
- package/src/__tests__/helpers/worker-scripts/hello-world-wrangler.toml +1 -0
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +11 -0
- package/src/__tests__/helpers/worker-scripts/parent-wrangler.toml +5 -0
- package/src/__tests__/helpers/write-worker-source.ts +16 -16
- package/src/__tests__/helpers/write-wrangler-toml.ts +9 -9
- package/src/__tests__/https-options.test.ts +142 -109
- package/src/__tests__/index.test.ts +262 -236
- package/src/__tests__/init.test.ts +3388 -1603
- package/src/__tests__/jest.setup.ts +152 -50
- package/src/__tests__/kv.test.ts +1789 -1471
- package/src/__tests__/logger.test.ts +167 -75
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +493 -0
- package/src/__tests__/middleware.scheduled.test.ts +145 -0
- package/src/__tests__/middleware.test.ts +816 -0
- package/src/__tests__/mtls-certificates.test.ts +589 -0
- package/src/__tests__/package-manager.test.ts +303 -303
- package/src/__tests__/pages/deployment-list.test.ts +80 -0
- package/src/__tests__/pages/functions-build.test.ts +528 -0
- package/src/__tests__/pages/pages.test.ts +81 -0
- package/src/__tests__/pages/project-create.test.ts +63 -0
- package/src/__tests__/pages/project-list.test.ts +110 -0
- package/src/__tests__/pages/project-upload.test.ts +500 -0
- package/src/__tests__/pages/publish.test.ts +2864 -0
- package/src/__tests__/pages-deployment-tail.test.ts +957 -0
- package/src/__tests__/parse.test.ts +358 -252
- package/src/__tests__/paths.test.ts +39 -0
- package/src/__tests__/publish.test.ts +8736 -5355
- package/src/__tests__/pubsub.test.ts +496 -0
- package/src/__tests__/queues.test.ts +532 -0
- package/src/__tests__/r2.test.ts +369 -228
- package/src/__tests__/route.test.ts +18 -18
- package/src/__tests__/secret.test.ts +681 -469
- package/src/__tests__/tail.test.ts +866 -567
- package/src/__tests__/test-old-node-version.js +31 -0
- package/src/__tests__/traverse-module-graph.test.ts +220 -0
- package/src/__tests__/tsconfig-sanity.ts +12 -0
- package/src/__tests__/tsconfig.json +8 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/type-generation.test.ts +234 -0
- package/src/__tests__/unstableDev.test.ts +61 -0
- package/src/__tests__/user.test.ts +107 -120
- package/src/__tests__/utils-collectKeyValues.test.ts +47 -0
- package/src/__tests__/validate-dev-props.test.ts +56 -0
- package/src/__tests__/version.test.ts +35 -0
- package/src/__tests__/whoami.test.tsx +165 -98
- package/src/__tests__/worker-namespace.test.ts +340 -0
- package/src/abort.d.ts +1 -1
- package/src/api/dev.ts +321 -0
- package/src/api/index.ts +11 -0
- package/src/api/mtls-certificate.ts +148 -0
- package/src/api/pages/create-worker-bundle-contents.ts +79 -0
- package/src/api/pages/index.ts +5 -0
- package/src/api/pages/publish.tsx +371 -0
- package/src/bundle-reporter.ts +68 -0
- package/src/bundle.ts +890 -161
- package/src/cfetch/index.ts +120 -83
- package/src/cfetch/internal.ts +215 -97
- package/src/cli.ts +23 -8
- package/src/config/config.ts +244 -196
- package/src/config/diagnostics.ts +61 -61
- package/src/config/environment.ts +587 -357
- package/src/config/index.ts +395 -196
- package/src/config/validation-helpers.ts +379 -357
- package/src/config/validation.ts +2285 -1367
- package/src/config-cache.ts +81 -41
- package/src/constellation/createProject.tsx +51 -0
- package/src/constellation/deleteProject.ts +51 -0
- package/src/constellation/deleteProjectModel.ts +76 -0
- package/src/constellation/index.ts +75 -0
- package/src/constellation/listCatalog.tsx +35 -0
- package/src/constellation/listModel.tsx +49 -0
- package/src/constellation/listProject.tsx +28 -0
- package/src/constellation/listRuntime.tsx +28 -0
- package/src/constellation/options.ts +17 -0
- package/src/constellation/types.ts +17 -0
- package/src/constellation/uploadModel.tsx +84 -0
- package/src/constellation/utils.ts +90 -0
- package/src/create-worker-preview.ts +250 -142
- package/src/create-worker-upload-form.ts +364 -238
- package/src/d1/backups.tsx +219 -0
- package/src/d1/constants.ts +5 -0
- package/src/d1/create.tsx +102 -0
- package/src/d1/delete.ts +53 -0
- package/src/d1/execute.tsx +371 -0
- package/src/d1/formatTimeAgo.ts +14 -0
- package/src/d1/index.ts +100 -0
- package/src/d1/list.tsx +62 -0
- package/src/d1/migrations/apply.tsx +235 -0
- package/src/d1/migrations/create.tsx +79 -0
- package/src/d1/migrations/helpers.ts +171 -0
- package/src/d1/migrations/index.ts +3 -0
- package/src/d1/migrations/list.tsx +95 -0
- package/src/d1/migrations/options.ts +23 -0
- package/src/d1/options.ts +22 -0
- package/src/d1/splitter.ts +161 -0
- package/src/d1/types.ts +32 -0
- package/src/d1/utils.ts +49 -0
- package/src/delete.ts +100 -0
- package/src/deployments.ts +368 -0
- package/src/deprecated/index.ts +144 -0
- package/src/dev/dev-vars.ts +20 -17
- package/src/dev/dev.tsx +538 -352
- package/src/dev/get-local-persistence-path.ts +31 -0
- package/src/dev/local.tsx +932 -298
- package/src/dev/remote.tsx +623 -215
- package/src/dev/start-server.ts +545 -0
- package/src/dev/use-esbuild.ts +194 -97
- package/src/dev/validate-dev-props.ts +40 -0
- package/src/dev-registry.ts +213 -0
- package/src/dev.tsx +937 -0
- package/src/dialogs.ts +136 -0
- package/src/dispatch-namespace.ts +211 -0
- package/src/docs/helpers.ts +50 -0
- package/src/docs/index.ts +54 -0
- package/src/durable.ts +87 -87
- package/src/entry.ts +253 -231
- package/src/environment-variables/factory.ts +89 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/errors.ts +6 -6
- package/src/generate/index.ts +304 -0
- package/src/git-client.ts +135 -0
- package/src/global-wrangler-config-path.ts +26 -0
- package/src/https-options.ts +84 -80
- package/src/index.ts +769 -0
- package/src/init.ts +1123 -0
- package/src/inspect.ts +816 -595
- package/src/intl-polyfill.d.ts +123 -123
- package/src/is-ci.ts +14 -0
- package/src/is-interactive.ts +16 -0
- package/src/jest.d.ts +4 -0
- package/src/kv/helpers.ts +433 -0
- package/src/kv/index.ts +594 -0
- package/src/logger.ts +100 -43
- package/src/metrics/index.ts +5 -0
- package/src/metrics/metrics-config.ts +239 -0
- package/src/metrics/metrics-dispatcher.ts +96 -0
- package/src/metrics/metrics-usage-headers.ts +24 -0
- package/src/metrics/send-event.ts +99 -0
- package/src/miniflare-cli/assets.ts +251 -0
- package/src/miniflare-cli/index.ts +202 -33
- package/src/miniflare-cli/request-context.ts +18 -18
- package/src/miniflare-cli/tsconfig.json +9 -0
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
- package/src/miniflare-cli/types.ts +11 -0
- package/src/module-collection.ts +290 -215
- package/src/mtls-certificate/cli.ts +155 -0
- package/src/open-in-browser.ts +4 -6
- package/src/package-manager.ts +173 -128
- package/src/pages/build.ts +423 -0
- package/src/pages/buildFunctions.ts +140 -0
- package/src/pages/constants.ts +18 -0
- package/src/pages/deployment-tails.ts +281 -0
- package/src/pages/deployments.tsx +84 -0
- package/src/pages/dev.ts +734 -0
- package/src/pages/errors.ts +67 -0
- package/src/pages/functions/buildPlugin.ts +114 -0
- package/src/pages/functions/buildWorker.ts +350 -0
- package/{pages → src/pages}/functions/filepath-routing.test.ts +113 -113
- package/src/pages/functions/filepath-routing.ts +189 -0
- package/src/pages/functions/identifiers.ts +78 -0
- package/src/pages/functions/routes-consolidation.test.ts +250 -0
- package/src/pages/functions/routes-consolidation.ts +73 -0
- package/src/pages/functions/routes-transformation.test.ts +282 -0
- package/src/pages/functions/routes-transformation.ts +115 -0
- package/src/pages/functions/routes-validation.test.ts +403 -0
- package/src/pages/functions/routes-validation.ts +202 -0
- package/src/pages/functions/routes.ts +151 -0
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/functions.ts +86 -0
- package/src/pages/hash.ts +13 -0
- package/src/pages/index.ts +102 -0
- package/src/pages/projects.tsx +159 -0
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +267 -0
- package/src/pages/types.ts +46 -0
- package/src/pages/upload.tsx +469 -0
- package/src/pages/utils.ts +23 -0
- package/src/parse.ts +232 -126
- package/src/paths.ts +53 -8
- package/src/proxy.ts +623 -394
- package/src/publish/index.ts +274 -0
- package/src/publish/publish.ts +1067 -0
- package/src/pubsub/index.ts +286 -0
- package/src/pubsub/pubsub-commands.ts +623 -0
- package/src/queues/cli/commands/consumer/add.ts +71 -0
- package/src/queues/cli/commands/consumer/index.ts +19 -0
- package/src/queues/cli/commands/consumer/remove.ts +31 -0
- package/src/queues/cli/commands/create.ts +25 -0
- package/src/queues/cli/commands/delete.ts +26 -0
- package/src/queues/cli/commands/index.ts +35 -0
- package/src/queues/cli/commands/list.ts +25 -0
- package/src/queues/client.ts +136 -0
- package/src/queues/utils.ts +18 -0
- package/src/r2/constants.ts +4 -0
- package/src/r2/helpers.ts +132 -0
- package/src/r2/index.ts +289 -0
- package/src/routes.ts +140 -0
- package/src/secret/index.ts +379 -0
- package/src/selfsigned.d.ts +23 -23
- package/src/sites.ts +484 -0
- package/src/tail/createTail.ts +415 -0
- package/src/tail/filters.ts +109 -111
- package/src/tail/index.ts +208 -296
- package/src/tail/printing.ts +116 -51
- package/src/traverse-module-graph.ts +54 -0
- package/src/tsconfig-sanity.ts +16 -0
- package/src/type-generation.ts +187 -0
- package/src/update-check.ts +11 -11
- package/src/user/access.ts +68 -0
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +39 -0
- package/src/user/generate-auth-url.ts +33 -0
- package/src/user/generate-random-state.ts +16 -0
- package/src/user/index.ts +2 -0
- package/src/user/user.ts +1234 -0
- package/src/utils/collectKeyValues.ts +14 -0
- package/src/utils/render.ts +93 -0
- package/src/whoami.ts +135 -0
- package/src/worker.ts +220 -106
- package/src/yargs-types.ts +37 -0
- package/src/zones.ts +191 -0
- package/templates/__tests__/pages-dev-util.test.ts +128 -0
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/checked-fetch.js +23 -0
- package/templates/d1-beta-facade.js +244 -0
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +19 -0
- package/templates/format-dev-errors.ts +34 -0
- package/templates/gitignore +1 -0
- package/templates/init-tests/test-jest-new-worker.js +23 -0
- package/templates/init-tests/test-vitest-new-worker.js +24 -0
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/common.ts +62 -0
- package/templates/middleware/loader-modules.ts +84 -0
- package/templates/middleware/loader-sw.ts +233 -0
- package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
- package/templates/middleware/middleware-pretty-error.ts +40 -0
- package/templates/middleware/middleware-scheduled.ts +15 -0
- package/templates/new-worker-scheduled.js +3 -3
- package/templates/new-worker-scheduled.ts +15 -15
- package/templates/new-worker.js +3 -3
- package/templates/new-worker.ts +18 -15
- package/templates/no-op-worker.js +10 -0
- package/templates/pages-dev-pipeline.ts +31 -0
- package/templates/pages-dev-util.ts +55 -0
- package/templates/pages-shim.ts +12 -0
- package/templates/pages-template-plugin.ts +180 -0
- package/templates/pages-template-worker.ts +189 -0
- package/templates/serve-static-assets.ts +66 -0
- package/templates/service-bindings-module-facade.js +55 -0
- package/templates/service-bindings-sw-facade.js +42 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +105 -0
- package/templates/tsconfig.json +6 -103
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +1673 -0
- package/wrangler-dist/cli.js +119141 -91468
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/pages/functions/buildPlugin.ts +0 -105
- package/pages/functions/buildWorker.ts +0 -151
- package/pages/functions/filepath-routing.ts +0 -189
- package/pages/functions/identifiers.ts +0 -78
- package/pages/functions/routes.ts +0 -156
- package/pages/functions/template-plugin.ts +0 -147
- package/pages/functions/template-worker.ts +0 -143
- package/src/__tests__/helpers/faye-websocket.d.ts +0 -6
- package/src/__tests__/helpers/mock-cfetch.ts +0 -211
- package/src/__tests__/pages.test.ts +0 -754
- package/src/dialogs.tsx +0 -135
- package/src/environment-variables.ts +0 -35
- package/src/index.tsx +0 -2864
- package/src/kv.ts +0 -408
- package/src/miniflare-cli/enum-keys.ts +0 -17
- package/src/pages.tsx +0 -2038
- package/src/publish.ts +0 -583
- package/src/r2.ts +0 -50
- package/src/sites.tsx +0 -295
- package/src/user.tsx +0 -1203
- package/src/whoami.tsx +0 -70
- package/templates/static-asset-facade.js +0 -47
- package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
- package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
- package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
- package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
- package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
- package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
- package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
- package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
- package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
- package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
- package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
- package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
- package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
- package/vendor/wrangler-mime/CHANGELOG.md +0 -289
- package/vendor/wrangler-mime/LICENSE +0 -21
- package/vendor/wrangler-mime/Mime.js +0 -97
- package/vendor/wrangler-mime/README.md +0 -187
- package/vendor/wrangler-mime/cli.js +0 -46
- package/vendor/wrangler-mime/index.js +0 -4
- package/vendor/wrangler-mime/lite.js +0 -4
- package/vendor/wrangler-mime/package.json +0 -52
- package/vendor/wrangler-mime/types/other.js +0 -1
- package/vendor/wrangler-mime/types/standard.js +0 -1
package/miniflare-dist/index.mjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1
7
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
8
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
9
|
}) : x)(function(x) {
|
|
@@ -5,14 +11,816 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
11
|
return require.apply(this, arguments);
|
|
6
12
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
7
13
|
});
|
|
14
|
+
var __esm = (fn, res) => function __init() {
|
|
15
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
+
};
|
|
17
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
+
for (let key of __getOwnPropNames(from))
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
|
|
37
|
+
// ../../node_modules/mime/Mime.js
|
|
38
|
+
var require_Mime = __commonJS({
|
|
39
|
+
"../../node_modules/mime/Mime.js"(exports, module) {
|
|
40
|
+
"use strict";
|
|
41
|
+
function Mime() {
|
|
42
|
+
this._types = /* @__PURE__ */ Object.create(null);
|
|
43
|
+
this._extensions = /* @__PURE__ */ Object.create(null);
|
|
44
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
45
|
+
this.define(arguments[i]);
|
|
46
|
+
}
|
|
47
|
+
this.define = this.define.bind(this);
|
|
48
|
+
this.getType = this.getType.bind(this);
|
|
49
|
+
this.getExtension = this.getExtension.bind(this);
|
|
50
|
+
}
|
|
51
|
+
Mime.prototype.define = function(typeMap, force) {
|
|
52
|
+
for (let type in typeMap) {
|
|
53
|
+
let extensions = typeMap[type].map(function(t) {
|
|
54
|
+
return t.toLowerCase();
|
|
55
|
+
});
|
|
56
|
+
type = type.toLowerCase();
|
|
57
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
58
|
+
const ext = extensions[i];
|
|
59
|
+
if (ext[0] === "*") {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (!force && ext in this._types) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
'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 + '".'
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
this._types[ext] = type;
|
|
68
|
+
}
|
|
69
|
+
if (force || !this._extensions[type]) {
|
|
70
|
+
const ext = extensions[0];
|
|
71
|
+
this._extensions[type] = ext[0] !== "*" ? ext : ext.substr(1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
Mime.prototype.getType = function(path) {
|
|
76
|
+
path = String(path);
|
|
77
|
+
let last = path.replace(/^.*[/\\]/, "").toLowerCase();
|
|
78
|
+
let ext = last.replace(/^.*\./, "").toLowerCase();
|
|
79
|
+
let hasPath = last.length < path.length;
|
|
80
|
+
let hasDot = ext.length < last.length - 1;
|
|
81
|
+
return (hasDot || !hasPath) && this._types[ext] || null;
|
|
82
|
+
};
|
|
83
|
+
Mime.prototype.getExtension = function(type) {
|
|
84
|
+
type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
|
|
85
|
+
return type && this._extensions[type.toLowerCase()] || null;
|
|
86
|
+
};
|
|
87
|
+
module.exports = Mime;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// ../../node_modules/mime/types/standard.js
|
|
92
|
+
var require_standard = __commonJS({
|
|
93
|
+
"../../node_modules/mime/types/standard.js"(exports, module) {
|
|
94
|
+
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": ["es", "ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "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/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/trig": ["trig"], "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-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/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "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"] };
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// ../../node_modules/mime/types/other.js
|
|
99
|
+
var require_other = __commonJS({
|
|
100
|
+
"../../node_modules/mime/types/other.js"(exports, module) {
|
|
101
|
+
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.mapbox-vector-tile": ["mvt"], "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-iwork-keynote-sffkey": ["*key"], "application/x-iwork-numbers-sffnumbers": ["*numbers"], "application/x-iwork-pages-sffpages": ["*pages"], "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.sap.vds": ["vds"], "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"] };
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// ../../node_modules/mime/index.js
|
|
106
|
+
var require_mime = __commonJS({
|
|
107
|
+
"../../node_modules/mime/index.js"(exports, module) {
|
|
108
|
+
"use strict";
|
|
109
|
+
var Mime = require_Mime();
|
|
110
|
+
module.exports = new Mime(require_standard(), require_other());
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// ../pages-shared/environment-polyfills/index.ts
|
|
115
|
+
var polyfill;
|
|
116
|
+
var init_environment_polyfills = __esm({
|
|
117
|
+
"../pages-shared/environment-polyfills/index.ts"() {
|
|
118
|
+
polyfill = (environment) => {
|
|
119
|
+
Object.entries(environment).map(([name, value]) => {
|
|
120
|
+
Object.defineProperty(globalThis, name, {
|
|
121
|
+
value,
|
|
122
|
+
configurable: true,
|
|
123
|
+
enumerable: true,
|
|
124
|
+
writable: true
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// ../pages-shared/environment-polyfills/miniflare-tre.ts
|
|
132
|
+
var miniflare_tre_exports = {};
|
|
133
|
+
__export(miniflare_tre_exports, {
|
|
134
|
+
default: () => miniflare_tre_default
|
|
135
|
+
});
|
|
136
|
+
var miniflare_tre_default;
|
|
137
|
+
var init_miniflare_tre = __esm({
|
|
138
|
+
"../pages-shared/environment-polyfills/miniflare-tre.ts"() {
|
|
139
|
+
init_environment_polyfills();
|
|
140
|
+
miniflare_tre_default = async () => {
|
|
141
|
+
const mf = await import("@miniflare/tre");
|
|
142
|
+
polyfill({
|
|
143
|
+
fetch: mf.fetch,
|
|
144
|
+
Headers: mf.Headers,
|
|
145
|
+
Request: mf.Request,
|
|
146
|
+
Response: mf.Response
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// ../pages-shared/environment-polyfills/miniflare.ts
|
|
153
|
+
var miniflare_exports = {};
|
|
154
|
+
__export(miniflare_exports, {
|
|
155
|
+
default: () => miniflare_default
|
|
156
|
+
});
|
|
157
|
+
var miniflare_default;
|
|
158
|
+
var init_miniflare = __esm({
|
|
159
|
+
"../pages-shared/environment-polyfills/miniflare.ts"() {
|
|
160
|
+
init_environment_polyfills();
|
|
161
|
+
miniflare_default = async () => {
|
|
162
|
+
const mf = await import("@miniflare/core");
|
|
163
|
+
polyfill({
|
|
164
|
+
fetch: mf.fetch,
|
|
165
|
+
Headers: mf.Headers,
|
|
166
|
+
Request: mf.Request,
|
|
167
|
+
Response: mf.Response
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// ../pages-shared/asset-server/responses.ts
|
|
174
|
+
function mergeHeaders(base, extra) {
|
|
175
|
+
base = new Headers(base ?? {});
|
|
176
|
+
extra = new Headers(extra ?? {});
|
|
177
|
+
return new Headers({
|
|
178
|
+
...Object.fromEntries(base.entries()),
|
|
179
|
+
...Object.fromEntries(extra.entries())
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function stripLeadingDoubleSlashes(location) {
|
|
183
|
+
return location.replace(/^(\/|%2F|%2f|%5C|%5c|%09|\s|\\)+(.*)/, "/$2");
|
|
184
|
+
}
|
|
185
|
+
var OkResponse, MovedPermanentlyResponse, FoundResponse, NotModifiedResponse, PermanentRedirectResponse, NotFoundResponse, MethodNotAllowedResponse, NotAcceptableResponse, InternalServerErrorResponse, SeeOtherResponse, TemporaryRedirectResponse;
|
|
186
|
+
var init_responses = __esm({
|
|
187
|
+
"../pages-shared/asset-server/responses.ts"() {
|
|
188
|
+
OkResponse = class extends Response {
|
|
189
|
+
constructor(...[body, init]) {
|
|
190
|
+
super(body, {
|
|
191
|
+
...init,
|
|
192
|
+
status: 200,
|
|
193
|
+
statusText: "OK"
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
MovedPermanentlyResponse = class extends Response {
|
|
198
|
+
constructor(location, init, {
|
|
199
|
+
preventLeadingDoubleSlash = true
|
|
200
|
+
} = {
|
|
201
|
+
preventLeadingDoubleSlash: true
|
|
202
|
+
}) {
|
|
203
|
+
location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
|
|
204
|
+
super(`Redirecting to ${location}`, {
|
|
205
|
+
...init,
|
|
206
|
+
status: 301,
|
|
207
|
+
statusText: "Moved Permanently",
|
|
208
|
+
headers: mergeHeaders(init?.headers, {
|
|
209
|
+
location
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
FoundResponse = class extends Response {
|
|
215
|
+
constructor(location, init, {
|
|
216
|
+
preventLeadingDoubleSlash = true
|
|
217
|
+
} = {
|
|
218
|
+
preventLeadingDoubleSlash: true
|
|
219
|
+
}) {
|
|
220
|
+
location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
|
|
221
|
+
super(`Redirecting to ${location}`, {
|
|
222
|
+
...init,
|
|
223
|
+
status: 302,
|
|
224
|
+
statusText: "Found",
|
|
225
|
+
headers: mergeHeaders(init?.headers, {
|
|
226
|
+
location
|
|
227
|
+
})
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
NotModifiedResponse = class extends Response {
|
|
232
|
+
constructor(...[_body, _init]) {
|
|
233
|
+
super(void 0, {
|
|
234
|
+
status: 304,
|
|
235
|
+
statusText: "Not Modified"
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
PermanentRedirectResponse = class extends Response {
|
|
240
|
+
constructor(location, init, {
|
|
241
|
+
preventLeadingDoubleSlash = true
|
|
242
|
+
} = {
|
|
243
|
+
preventLeadingDoubleSlash: true
|
|
244
|
+
}) {
|
|
245
|
+
location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
|
|
246
|
+
super(void 0, {
|
|
247
|
+
...init,
|
|
248
|
+
status: 308,
|
|
249
|
+
statusText: "Permanent Redirect",
|
|
250
|
+
headers: mergeHeaders(init?.headers, {
|
|
251
|
+
location
|
|
252
|
+
})
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
NotFoundResponse = class extends Response {
|
|
257
|
+
constructor(...[body, init]) {
|
|
258
|
+
super(body, {
|
|
259
|
+
...init,
|
|
260
|
+
status: 404,
|
|
261
|
+
statusText: "Not Found"
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
MethodNotAllowedResponse = class extends Response {
|
|
266
|
+
constructor(...[body, init]) {
|
|
267
|
+
super(body, {
|
|
268
|
+
...init,
|
|
269
|
+
status: 405,
|
|
270
|
+
statusText: "Method Not Allowed"
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
NotAcceptableResponse = class extends Response {
|
|
275
|
+
constructor(...[body, init]) {
|
|
276
|
+
super(body, {
|
|
277
|
+
...init,
|
|
278
|
+
status: 406,
|
|
279
|
+
statusText: "Not Acceptable"
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
InternalServerErrorResponse = class extends Response {
|
|
284
|
+
constructor(err, init) {
|
|
285
|
+
let body = void 0;
|
|
286
|
+
if (globalThis.DEBUG) {
|
|
287
|
+
body = `${err.message}
|
|
288
|
+
|
|
289
|
+
${err.stack}`;
|
|
290
|
+
}
|
|
291
|
+
super(body, {
|
|
292
|
+
...init,
|
|
293
|
+
status: 500,
|
|
294
|
+
statusText: "Internal Server Error"
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
SeeOtherResponse = class extends Response {
|
|
299
|
+
constructor(location, init, {
|
|
300
|
+
preventLeadingDoubleSlash = true
|
|
301
|
+
} = {
|
|
302
|
+
preventLeadingDoubleSlash: true
|
|
303
|
+
}) {
|
|
304
|
+
location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
|
|
305
|
+
super(`Redirecting to ${location}`, {
|
|
306
|
+
...init,
|
|
307
|
+
status: 303,
|
|
308
|
+
statusText: "See Other",
|
|
309
|
+
headers: mergeHeaders(init?.headers, { location })
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
TemporaryRedirectResponse = class extends Response {
|
|
314
|
+
constructor(location, init, {
|
|
315
|
+
preventLeadingDoubleSlash = true
|
|
316
|
+
} = {
|
|
317
|
+
preventLeadingDoubleSlash: true
|
|
318
|
+
}) {
|
|
319
|
+
location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
|
|
320
|
+
super(`Redirecting to ${location}`, {
|
|
321
|
+
...init,
|
|
322
|
+
status: 307,
|
|
323
|
+
statusText: "Temporary Redirect",
|
|
324
|
+
headers: mergeHeaders(init?.headers, { location })
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// ../pages-shared/asset-server/rulesEngine.ts
|
|
332
|
+
var ESCAPE_REGEX_CHARACTERS, escapeRegex, HOST_PLACEHOLDER_REGEX, PLACEHOLDER_REGEX2, replacer, generateRulesMatcher;
|
|
333
|
+
var init_rulesEngine = __esm({
|
|
334
|
+
"../pages-shared/asset-server/rulesEngine.ts"() {
|
|
335
|
+
ESCAPE_REGEX_CHARACTERS = /[-/\\^$*+?.()|[\]{}]/g;
|
|
336
|
+
escapeRegex = (str) => {
|
|
337
|
+
return str.replace(ESCAPE_REGEX_CHARACTERS, "\\$&");
|
|
338
|
+
};
|
|
339
|
+
HOST_PLACEHOLDER_REGEX = /(?<=^https:\\\/\\\/[^/]*?):([^\\]+)(?=\\)/g;
|
|
340
|
+
PLACEHOLDER_REGEX2 = /:(\w+)/g;
|
|
341
|
+
replacer = (str, replacements) => {
|
|
342
|
+
for (const [replacement, value] of Object.entries(replacements)) {
|
|
343
|
+
str = str.replaceAll(`:${replacement}`, value);
|
|
344
|
+
}
|
|
345
|
+
return str;
|
|
346
|
+
};
|
|
347
|
+
generateRulesMatcher = (rules, replacerFn = (match) => match) => {
|
|
348
|
+
if (!rules)
|
|
349
|
+
return () => [];
|
|
350
|
+
const compiledRules = Object.entries(rules).map(([rule, match]) => {
|
|
351
|
+
const crossHost = rule.startsWith("https://");
|
|
352
|
+
rule = rule.split("*").map(escapeRegex).join("(?<splat>.*)");
|
|
353
|
+
const host_matches = rule.matchAll(HOST_PLACEHOLDER_REGEX);
|
|
354
|
+
for (const host_match of host_matches) {
|
|
355
|
+
rule = rule.split(host_match[0]).join(`(?<${host_match[1]}>[^/.]+)`);
|
|
356
|
+
}
|
|
357
|
+
const path_matches = rule.matchAll(PLACEHOLDER_REGEX2);
|
|
358
|
+
for (const path_match of path_matches) {
|
|
359
|
+
rule = rule.split(path_match[0]).join(`(?<${path_match[1]}>[^/]+)`);
|
|
360
|
+
}
|
|
361
|
+
rule = "^" + rule + "$";
|
|
362
|
+
try {
|
|
363
|
+
const regExp = new RegExp(rule);
|
|
364
|
+
return [{ crossHost, regExp }, match];
|
|
365
|
+
} catch {
|
|
366
|
+
}
|
|
367
|
+
}).filter((value) => value !== void 0);
|
|
368
|
+
return ({ request }) => {
|
|
369
|
+
const { pathname, host } = new URL(request.url);
|
|
370
|
+
return compiledRules.map(([{ crossHost, regExp }, match]) => {
|
|
371
|
+
const test = crossHost ? `https://${host}${pathname}` : pathname;
|
|
372
|
+
const result = regExp.exec(test);
|
|
373
|
+
if (result) {
|
|
374
|
+
return replacerFn(match, result.groups || {});
|
|
375
|
+
}
|
|
376
|
+
}).filter((value) => value !== void 0);
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// ../pages-shared/asset-server/handler.ts
|
|
383
|
+
var handler_exports = {};
|
|
384
|
+
__export(handler_exports, {
|
|
385
|
+
ANALYTICS_VERSION: () => ANALYTICS_VERSION2,
|
|
386
|
+
ASSET_PRESERVATION_CACHE: () => ASSET_PRESERVATION_CACHE,
|
|
387
|
+
CACHE_CONTROL_BROWSER: () => CACHE_CONTROL_BROWSER,
|
|
388
|
+
HEADERS_VERSION: () => HEADERS_VERSION2,
|
|
389
|
+
HEADERS_VERSION_V1: () => HEADERS_VERSION_V1,
|
|
390
|
+
REDIRECTS_VERSION: () => REDIRECTS_VERSION2,
|
|
391
|
+
generateHandler: () => generateHandler,
|
|
392
|
+
normaliseHeaders: () => normaliseHeaders,
|
|
393
|
+
parseQualityWeightedList: () => parseQualityWeightedList
|
|
394
|
+
});
|
|
395
|
+
function normaliseHeaders(headers) {
|
|
396
|
+
if (headers.version === HEADERS_VERSION2) {
|
|
397
|
+
return headers.rules;
|
|
398
|
+
} else if (headers.version === HEADERS_VERSION_V1) {
|
|
399
|
+
return Object.keys(headers.rules).reduce(
|
|
400
|
+
(acc, key) => {
|
|
401
|
+
acc[key] = {
|
|
402
|
+
set: headers.rules[key]
|
|
403
|
+
};
|
|
404
|
+
return acc;
|
|
405
|
+
},
|
|
406
|
+
{}
|
|
407
|
+
);
|
|
408
|
+
} else {
|
|
409
|
+
return {};
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
async function generateHandler({
|
|
413
|
+
request,
|
|
414
|
+
metadata,
|
|
415
|
+
xServerEnvHeader,
|
|
416
|
+
logError,
|
|
417
|
+
findAssetEntryForPath,
|
|
418
|
+
getAssetKey,
|
|
419
|
+
negotiateContent,
|
|
420
|
+
fetchAsset,
|
|
421
|
+
generateNotFoundResponse = async (notFoundRequest, notFoundFindAssetEntryForPath, notFoundServeAsset) => {
|
|
422
|
+
let assetEntry;
|
|
423
|
+
if (assetEntry = await notFoundFindAssetEntryForPath("/index.html")) {
|
|
424
|
+
return notFoundServeAsset(assetEntry, { preserve: false });
|
|
425
|
+
}
|
|
426
|
+
return new NotFoundResponse();
|
|
427
|
+
},
|
|
428
|
+
attachAdditionalHeaders = () => {
|
|
429
|
+
},
|
|
430
|
+
caches,
|
|
431
|
+
waitUntil
|
|
432
|
+
}) {
|
|
433
|
+
const url = new URL(request.url);
|
|
434
|
+
const { protocol, host, search } = url;
|
|
435
|
+
let { pathname } = url;
|
|
436
|
+
const earlyHintsCache = metadata.deploymentId ? await caches?.open(`eh:${metadata.deploymentId}`) : void 0;
|
|
437
|
+
const headerRules = metadata.headers ? normaliseHeaders(metadata.headers) : {};
|
|
438
|
+
const staticRules = metadata.redirects?.version === REDIRECTS_VERSION2 ? metadata.redirects.staticRules || {} : {};
|
|
439
|
+
const staticRedirectsMatcher = () => {
|
|
440
|
+
const withHostMatch = staticRules[`https://${host}${pathname}`];
|
|
441
|
+
const withoutHostMatch = staticRules[pathname];
|
|
442
|
+
if (withHostMatch && withoutHostMatch) {
|
|
443
|
+
if (withHostMatch.lineNumber < withoutHostMatch.lineNumber) {
|
|
444
|
+
return withHostMatch;
|
|
445
|
+
} else {
|
|
446
|
+
return withoutHostMatch;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return withHostMatch || withoutHostMatch;
|
|
450
|
+
};
|
|
451
|
+
const generateRedirectsMatcher = () => generateRulesMatcher(
|
|
452
|
+
metadata.redirects?.version === REDIRECTS_VERSION2 ? metadata.redirects.rules : {},
|
|
453
|
+
({ status, to }, replacements) => ({
|
|
454
|
+
status,
|
|
455
|
+
to: replacer(to, replacements)
|
|
456
|
+
})
|
|
457
|
+
);
|
|
458
|
+
let assetEntry;
|
|
459
|
+
async function generateResponse() {
|
|
460
|
+
const match = staticRedirectsMatcher() || generateRedirectsMatcher()({ request })[0];
|
|
461
|
+
if (match) {
|
|
462
|
+
if (match.status === 200) {
|
|
463
|
+
pathname = new URL(match.to, request.url).pathname;
|
|
464
|
+
} else {
|
|
465
|
+
const { status, to } = match;
|
|
466
|
+
const destination = new URL(to, request.url);
|
|
467
|
+
const location = destination.origin === new URL(request.url).origin ? `${destination.pathname}${destination.search || search}${destination.hash}` : `${destination.href}${destination.search ? "" : search}${destination.hash}`;
|
|
468
|
+
switch (status) {
|
|
469
|
+
case 301:
|
|
470
|
+
return new MovedPermanentlyResponse(location, void 0, {
|
|
471
|
+
preventLeadingDoubleSlash: false
|
|
472
|
+
});
|
|
473
|
+
case 303:
|
|
474
|
+
return new SeeOtherResponse(location, void 0, {
|
|
475
|
+
preventLeadingDoubleSlash: false
|
|
476
|
+
});
|
|
477
|
+
case 307:
|
|
478
|
+
return new TemporaryRedirectResponse(location, void 0, {
|
|
479
|
+
preventLeadingDoubleSlash: false
|
|
480
|
+
});
|
|
481
|
+
case 308:
|
|
482
|
+
return new PermanentRedirectResponse(location, void 0, {
|
|
483
|
+
preventLeadingDoubleSlash: false
|
|
484
|
+
});
|
|
485
|
+
case 302:
|
|
486
|
+
default:
|
|
487
|
+
return new FoundResponse(location, void 0, {
|
|
488
|
+
preventLeadingDoubleSlash: false
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (!request.method.match(/^(get|head)$/i)) {
|
|
494
|
+
return new MethodNotAllowedResponse();
|
|
495
|
+
}
|
|
496
|
+
try {
|
|
497
|
+
pathname = globalThis.decodeURIComponent(pathname);
|
|
498
|
+
} catch (err) {
|
|
499
|
+
}
|
|
500
|
+
if (pathname.endsWith("/")) {
|
|
501
|
+
if (assetEntry = await findAssetEntryForPath(`${pathname}index.html`)) {
|
|
502
|
+
return serveAsset(assetEntry);
|
|
503
|
+
} else if (pathname.endsWith("/index/")) {
|
|
504
|
+
return new PermanentRedirectResponse(
|
|
505
|
+
`/${pathname.slice(1, -"index/".length)}${search}`
|
|
506
|
+
);
|
|
507
|
+
} else if (assetEntry = await findAssetEntryForPath(
|
|
508
|
+
`${pathname.replace(/\/$/, ".html")}`
|
|
509
|
+
)) {
|
|
510
|
+
return new PermanentRedirectResponse(
|
|
511
|
+
`/${pathname.slice(1, -1)}${search}`
|
|
512
|
+
);
|
|
513
|
+
} else {
|
|
514
|
+
return notFound();
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (assetEntry = await findAssetEntryForPath(pathname)) {
|
|
518
|
+
if (pathname.endsWith(".html")) {
|
|
519
|
+
const extensionlessPath = pathname.slice(0, -".html".length);
|
|
520
|
+
if (extensionlessPath.endsWith("/index")) {
|
|
521
|
+
return new PermanentRedirectResponse(
|
|
522
|
+
`${extensionlessPath.replace(/\/index$/, "/")}${search}`
|
|
523
|
+
);
|
|
524
|
+
} else if (await findAssetEntryForPath(extensionlessPath) || extensionlessPath === "/") {
|
|
525
|
+
return serveAsset(assetEntry);
|
|
526
|
+
} else {
|
|
527
|
+
return new PermanentRedirectResponse(`${extensionlessPath}${search}`);
|
|
528
|
+
}
|
|
529
|
+
} else {
|
|
530
|
+
return serveAsset(assetEntry);
|
|
531
|
+
}
|
|
532
|
+
} else if (pathname.endsWith("/index")) {
|
|
533
|
+
return new PermanentRedirectResponse(
|
|
534
|
+
`/${pathname.slice(1, -"index".length)}${search}`
|
|
535
|
+
);
|
|
536
|
+
} else if (assetEntry = await findAssetEntryForPath(`${pathname}.html`)) {
|
|
537
|
+
return serveAsset(assetEntry);
|
|
538
|
+
} else if (hasFileExtension(pathname)) {
|
|
539
|
+
return notFound();
|
|
540
|
+
}
|
|
541
|
+
if (assetEntry = await findAssetEntryForPath(`${pathname}/index.html`)) {
|
|
542
|
+
return new PermanentRedirectResponse(`${pathname}/${search}`);
|
|
543
|
+
} else {
|
|
544
|
+
return notFound();
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
async function attachHeaders(response) {
|
|
548
|
+
const existingHeaders = new Headers(response.headers);
|
|
549
|
+
const extraHeaders = new Headers({
|
|
550
|
+
"access-control-allow-origin": "*",
|
|
551
|
+
"referrer-policy": "strict-origin-when-cross-origin",
|
|
552
|
+
...existingHeaders.has("content-type") ? { "x-content-type-options": "nosniff" } : {}
|
|
553
|
+
});
|
|
554
|
+
const headers = new Headers({
|
|
555
|
+
...Object.fromEntries(existingHeaders.entries()),
|
|
556
|
+
...Object.fromEntries(extraHeaders.entries())
|
|
557
|
+
});
|
|
558
|
+
if (earlyHintsCache) {
|
|
559
|
+
const preEarlyHintsHeaders = new Headers(headers);
|
|
560
|
+
const earlyHintsCacheKey = `${protocol}//${host}${pathname}`;
|
|
561
|
+
const earlyHintsResponse = await earlyHintsCache.match(
|
|
562
|
+
earlyHintsCacheKey
|
|
563
|
+
);
|
|
564
|
+
if (earlyHintsResponse) {
|
|
565
|
+
const earlyHintsLinkHeader = earlyHintsResponse.headers.get("Link");
|
|
566
|
+
if (earlyHintsLinkHeader) {
|
|
567
|
+
headers.set("Link", earlyHintsLinkHeader);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
const clonedResponse = response.clone();
|
|
571
|
+
if (waitUntil) {
|
|
572
|
+
waitUntil(
|
|
573
|
+
(async () => {
|
|
574
|
+
try {
|
|
575
|
+
const links = [];
|
|
576
|
+
const transformedResponse = new HTMLRewriter().on("link[rel~=preconnect],link[rel~=preload]", {
|
|
577
|
+
element(element) {
|
|
578
|
+
for (const [attributeName] of element.attributes) {
|
|
579
|
+
if (!ALLOWED_EARLY_HINT_LINK_ATTRIBUTES.includes(
|
|
580
|
+
attributeName.toLowerCase()
|
|
581
|
+
)) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
const href = element.getAttribute("href") || void 0;
|
|
586
|
+
const rel = element.getAttribute("rel") || void 0;
|
|
587
|
+
const as = element.getAttribute("as") || void 0;
|
|
588
|
+
if (href && !href.startsWith("data:") && rel) {
|
|
589
|
+
links.push({ href, rel, as });
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}).transform(clonedResponse);
|
|
593
|
+
await transformedResponse.text();
|
|
594
|
+
links.forEach(({ href, rel, as }) => {
|
|
595
|
+
let link = `<${href}>; rel="${rel}"`;
|
|
596
|
+
if (as) {
|
|
597
|
+
link += `; as=${as}`;
|
|
598
|
+
}
|
|
599
|
+
preEarlyHintsHeaders.append("Link", link);
|
|
600
|
+
});
|
|
601
|
+
const linkHeader = preEarlyHintsHeaders.get("Link");
|
|
602
|
+
if (linkHeader) {
|
|
603
|
+
await earlyHintsCache.put(
|
|
604
|
+
earlyHintsCacheKey,
|
|
605
|
+
new Response(null, { headers: { Link: linkHeader } })
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
} catch (err) {
|
|
609
|
+
}
|
|
610
|
+
})()
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
const headersMatcher = generateRulesMatcher(
|
|
615
|
+
headerRules,
|
|
616
|
+
({ set = {}, unset = [] }, replacements) => {
|
|
617
|
+
const replacedSet = {};
|
|
618
|
+
Object.keys(set).forEach((key) => {
|
|
619
|
+
replacedSet[key] = replacer(set[key], replacements);
|
|
620
|
+
});
|
|
621
|
+
return {
|
|
622
|
+
set: replacedSet,
|
|
623
|
+
unset
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
const matches = headersMatcher({ request });
|
|
628
|
+
const setMap = /* @__PURE__ */ new Set();
|
|
629
|
+
matches.forEach(({ set = {}, unset = [] }) => {
|
|
630
|
+
unset.forEach((key) => {
|
|
631
|
+
headers.delete(key);
|
|
632
|
+
});
|
|
633
|
+
Object.keys(set).forEach((key) => {
|
|
634
|
+
if (setMap.has(key.toLowerCase())) {
|
|
635
|
+
headers.append(key, set[key]);
|
|
636
|
+
} else {
|
|
637
|
+
headers.set(key, set[key]);
|
|
638
|
+
setMap.add(key.toLowerCase());
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
return new Response(
|
|
643
|
+
[101, 204, 205, 304].includes(response.status) ? null : response.body,
|
|
644
|
+
{
|
|
645
|
+
headers,
|
|
646
|
+
status: response.status,
|
|
647
|
+
statusText: response.statusText
|
|
648
|
+
}
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
return await attachHeaders(await generateResponse());
|
|
652
|
+
async function serveAsset(servingAssetEntry, options = { preserve: true }) {
|
|
653
|
+
let content;
|
|
654
|
+
try {
|
|
655
|
+
content = negotiateContent(request, servingAssetEntry);
|
|
656
|
+
} catch (err) {
|
|
657
|
+
return new NotAcceptableResponse();
|
|
658
|
+
}
|
|
659
|
+
const assetKey = getAssetKey(servingAssetEntry, content);
|
|
660
|
+
const etag = `"${assetKey}"`;
|
|
661
|
+
const weakEtag = `W/${etag}`;
|
|
662
|
+
const ifNoneMatch = request.headers.get("if-none-match");
|
|
663
|
+
if (ifNoneMatch === weakEtag || ifNoneMatch === etag) {
|
|
664
|
+
return new NotModifiedResponse();
|
|
665
|
+
}
|
|
666
|
+
try {
|
|
667
|
+
const asset = await fetchAsset(assetKey);
|
|
668
|
+
const headers = {
|
|
669
|
+
etag,
|
|
670
|
+
"content-type": asset.contentType
|
|
671
|
+
};
|
|
672
|
+
let encodeBody = "automatic";
|
|
673
|
+
if (xServerEnvHeader) {
|
|
674
|
+
headers["x-server-env"] = xServerEnvHeader;
|
|
675
|
+
}
|
|
676
|
+
if (content.encoding) {
|
|
677
|
+
encodeBody = "manual";
|
|
678
|
+
headers["cache-control"] = "no-transform";
|
|
679
|
+
headers["content-encoding"] = content.encoding;
|
|
680
|
+
}
|
|
681
|
+
const response = new OkResponse(
|
|
682
|
+
request.method === "HEAD" ? null : asset.body,
|
|
683
|
+
{
|
|
684
|
+
headers,
|
|
685
|
+
encodeBody
|
|
686
|
+
}
|
|
687
|
+
);
|
|
688
|
+
if (isCacheable(request)) {
|
|
689
|
+
response.headers.append("cache-control", CACHE_CONTROL_BROWSER);
|
|
690
|
+
}
|
|
691
|
+
attachAdditionalHeaders(response, content, servingAssetEntry, asset);
|
|
692
|
+
if (isPreview(new URL(request.url))) {
|
|
693
|
+
response.headers.set("x-robots-tag", "noindex");
|
|
694
|
+
}
|
|
695
|
+
if (options.preserve) {
|
|
696
|
+
const preservedResponse = new Response(
|
|
697
|
+
[101, 204, 205, 304].includes(response.status) ? null : response.clone().body,
|
|
698
|
+
response
|
|
699
|
+
);
|
|
700
|
+
preservedResponse.headers.set(
|
|
701
|
+
"cache-control",
|
|
702
|
+
CACHE_CONTROL_PRESERVATION
|
|
703
|
+
);
|
|
704
|
+
preservedResponse.headers.set("x-robots-tag", "noindex");
|
|
705
|
+
if (waitUntil && caches) {
|
|
706
|
+
waitUntil(
|
|
707
|
+
caches.open(ASSET_PRESERVATION_CACHE).then(
|
|
708
|
+
(assetPreservationCache) => assetPreservationCache.put(request.url, preservedResponse)
|
|
709
|
+
).catch((err) => {
|
|
710
|
+
logError(err);
|
|
711
|
+
})
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
if (asset.contentType.startsWith("text/html") && metadata.analytics?.version === ANALYTICS_VERSION2) {
|
|
716
|
+
return new HTMLRewriter().on("body", {
|
|
717
|
+
element(e) {
|
|
718
|
+
e.append(
|
|
719
|
+
`<!-- Cloudflare Pages Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "${metadata.analytics?.token}"}'></script><!-- Cloudflare Pages Analytics -->`,
|
|
720
|
+
{ html: true }
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
}).transform(response);
|
|
724
|
+
}
|
|
725
|
+
return response;
|
|
726
|
+
} catch (err) {
|
|
727
|
+
logError(err);
|
|
728
|
+
return new InternalServerErrorResponse(err);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
async function notFound() {
|
|
732
|
+
if (caches) {
|
|
733
|
+
const assetPreservationCache = await caches.open(
|
|
734
|
+
ASSET_PRESERVATION_CACHE
|
|
735
|
+
);
|
|
736
|
+
const preservedResponse = await assetPreservationCache.match(request.url);
|
|
737
|
+
if (preservedResponse) {
|
|
738
|
+
return preservedResponse;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
let cwd = pathname;
|
|
742
|
+
while (cwd) {
|
|
743
|
+
cwd = cwd.slice(0, cwd.lastIndexOf("/"));
|
|
744
|
+
if (assetEntry = await findAssetEntryForPath(`${cwd}/404.html`)) {
|
|
745
|
+
let content;
|
|
746
|
+
try {
|
|
747
|
+
content = negotiateContent(request, assetEntry);
|
|
748
|
+
} catch (err) {
|
|
749
|
+
return new NotAcceptableResponse();
|
|
750
|
+
}
|
|
751
|
+
const assetKey = getAssetKey(assetEntry, content);
|
|
752
|
+
try {
|
|
753
|
+
const { body, contentType } = await fetchAsset(assetKey);
|
|
754
|
+
const response = new NotFoundResponse(body);
|
|
755
|
+
response.headers.set("content-type", contentType);
|
|
756
|
+
return response;
|
|
757
|
+
} catch (err) {
|
|
758
|
+
logError(err);
|
|
759
|
+
return new InternalServerErrorResponse(err);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
return await generateNotFoundResponse(
|
|
764
|
+
request,
|
|
765
|
+
findAssetEntryForPath,
|
|
766
|
+
serveAsset
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
function parseQualityWeightedList(list = "") {
|
|
771
|
+
const items = {};
|
|
772
|
+
list.replace(/\s/g, "").split(",").forEach((el) => {
|
|
773
|
+
const [item, weight] = el.split(";q=");
|
|
774
|
+
items[item] = weight ? parseFloat(weight) : 1;
|
|
775
|
+
});
|
|
776
|
+
return items;
|
|
777
|
+
}
|
|
778
|
+
function isCacheable(request) {
|
|
779
|
+
return !request.headers.has("authorization") && !request.headers.has("range");
|
|
780
|
+
}
|
|
781
|
+
function hasFileExtension(path) {
|
|
782
|
+
return /\/.+\.[a-z0-9]+$/i.test(path);
|
|
783
|
+
}
|
|
784
|
+
function isPreview(url) {
|
|
785
|
+
if (url.hostname.endsWith(".pages.dev")) {
|
|
786
|
+
return url.hostname.split(".").length > 3 ? true : false;
|
|
787
|
+
}
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
var ASSET_PRESERVATION_CACHE, CACHE_CONTROL_PRESERVATION, CACHE_CONTROL_BROWSER, REDIRECTS_VERSION2, HEADERS_VERSION2, HEADERS_VERSION_V1, ANALYTICS_VERSION2, ALLOWED_EARLY_HINT_LINK_ATTRIBUTES;
|
|
791
|
+
var init_handler = __esm({
|
|
792
|
+
"../pages-shared/asset-server/handler.ts"() {
|
|
793
|
+
init_responses();
|
|
794
|
+
init_rulesEngine();
|
|
795
|
+
ASSET_PRESERVATION_CACHE = "assetPreservationCache";
|
|
796
|
+
CACHE_CONTROL_PRESERVATION = "public, s-maxage=604800";
|
|
797
|
+
CACHE_CONTROL_BROWSER = "public, max-age=0, must-revalidate";
|
|
798
|
+
REDIRECTS_VERSION2 = 1;
|
|
799
|
+
HEADERS_VERSION2 = 2;
|
|
800
|
+
HEADERS_VERSION_V1 = 1;
|
|
801
|
+
ANALYTICS_VERSION2 = 1;
|
|
802
|
+
ALLOWED_EARLY_HINT_LINK_ATTRIBUTES = ["rel", "as", "href"];
|
|
803
|
+
}
|
|
804
|
+
});
|
|
8
805
|
|
|
9
806
|
// src/miniflare-cli/index.ts
|
|
10
|
-
import {
|
|
807
|
+
import {
|
|
808
|
+
DurableObjectNamespace,
|
|
809
|
+
DurableObjectStub
|
|
810
|
+
} from "@miniflare/durable-objects";
|
|
811
|
+
import { upgradingFetch } from "@miniflare/web-sockets";
|
|
812
|
+
import {
|
|
813
|
+
Log as MiniflareLog,
|
|
814
|
+
LogLevel as MiniflareLogLevel,
|
|
815
|
+
Miniflare,
|
|
816
|
+
Request as MiniflareRequest,
|
|
817
|
+
Response as MiniflareResponse
|
|
818
|
+
} from "miniflare";
|
|
11
819
|
|
|
12
820
|
// ../../node_modules/yargs/lib/platform-shims/esm.mjs
|
|
13
821
|
import { notStrictEqual, strictEqual } from "assert";
|
|
14
822
|
|
|
15
|
-
// ../../node_modules/cliui/build/lib/index.js
|
|
823
|
+
// ../../node_modules/yargs/node_modules/cliui/build/lib/index.js
|
|
16
824
|
var align = {
|
|
17
825
|
right: alignRight,
|
|
18
826
|
center: alignCenter
|
|
@@ -23,9 +831,9 @@ var bottom = 2;
|
|
|
23
831
|
var left = 3;
|
|
24
832
|
var UI = class {
|
|
25
833
|
constructor(opts) {
|
|
26
|
-
var
|
|
834
|
+
var _a2;
|
|
27
835
|
this.width = opts.width;
|
|
28
|
-
this.wrap = (
|
|
836
|
+
this.wrap = (_a2 = opts.wrap) !== null && _a2 !== void 0 ? _a2 : true;
|
|
29
837
|
this.rows = [];
|
|
30
838
|
}
|
|
31
839
|
span(...args) {
|
|
@@ -266,7 +1074,7 @@ function cliui(opts, _mixin) {
|
|
|
266
1074
|
});
|
|
267
1075
|
}
|
|
268
1076
|
|
|
269
|
-
// ../../node_modules/cliui/build/lib/string-utils.js
|
|
1077
|
+
// ../../node_modules/yargs/node_modules/cliui/build/lib/string-utils.js
|
|
270
1078
|
var ansi = new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g");
|
|
271
1079
|
function stripAnsi(str) {
|
|
272
1080
|
return str.replace(ansi, "");
|
|
@@ -287,7 +1095,7 @@ function wrap(str, width) {
|
|
|
287
1095
|
return wrapped;
|
|
288
1096
|
}
|
|
289
1097
|
|
|
290
|
-
// ../../node_modules/cliui/index.mjs
|
|
1098
|
+
// ../../node_modules/yargs/node_modules/cliui/index.mjs
|
|
291
1099
|
function ui(opts) {
|
|
292
1100
|
return cliui(opts, {
|
|
293
1101
|
stringWidth: (str) => {
|
|
@@ -578,9 +1386,9 @@ var YargsParser = class {
|
|
|
578
1386
|
let m;
|
|
579
1387
|
let next;
|
|
580
1388
|
let value;
|
|
581
|
-
if (arg !== "--" && isUnknownOptionAsArg(arg)) {
|
|
1389
|
+
if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) {
|
|
582
1390
|
pushPositional(arg);
|
|
583
|
-
} else if (truncatedArg.match(
|
|
1391
|
+
} else if (truncatedArg.match(/^---+(=|$)/)) {
|
|
584
1392
|
pushPositional(arg);
|
|
585
1393
|
continue;
|
|
586
1394
|
} else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
|
|
@@ -1263,9 +2071,13 @@ function stripQuotes(val) {
|
|
|
1263
2071
|
|
|
1264
2072
|
// ../../node_modules/yargs/node_modules/yargs-parser/build/lib/index.js
|
|
1265
2073
|
import { readFileSync } from "fs";
|
|
2074
|
+
var _a;
|
|
2075
|
+
var _b;
|
|
2076
|
+
var _c;
|
|
1266
2077
|
var minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12;
|
|
1267
|
-
|
|
1268
|
-
|
|
2078
|
+
var nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
|
|
2079
|
+
if (nodeVersion) {
|
|
2080
|
+
const major = Number(nodeVersion.match(/^([^.]+)/)[1]);
|
|
1269
2081
|
if (major < minNodeVersion) {
|
|
1270
2082
|
throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
|
|
1271
2083
|
}
|
|
@@ -1328,7 +2140,9 @@ var YError = class extends Error {
|
|
|
1328
2140
|
constructor(msg) {
|
|
1329
2141
|
super(msg || "yargs error");
|
|
1330
2142
|
this.name = "YError";
|
|
1331
|
-
Error.captureStackTrace
|
|
2143
|
+
if (Error.captureStackTrace) {
|
|
2144
|
+
Error.captureStackTrace(this, YError);
|
|
2145
|
+
}
|
|
1332
2146
|
}
|
|
1333
2147
|
};
|
|
1334
2148
|
|
|
@@ -1528,7 +2342,7 @@ try {
|
|
|
1528
2342
|
} catch (e) {
|
|
1529
2343
|
__dirname = process.cwd();
|
|
1530
2344
|
}
|
|
1531
|
-
var mainFilename = __dirname.
|
|
2345
|
+
var mainFilename = __dirname.substring(0, __dirname.lastIndexOf("node_modules"));
|
|
1532
2346
|
var esm_default = {
|
|
1533
2347
|
assert: {
|
|
1534
2348
|
notStrictEqual,
|
|
@@ -1913,6 +2727,7 @@ var CommandInstance = class {
|
|
|
1913
2727
|
const builder = commandHandler.builder;
|
|
1914
2728
|
let innerYargs = yargs;
|
|
1915
2729
|
if (isCommandBuilderCallback(builder)) {
|
|
2730
|
+
yargs.getInternalMethods().getUsageInstance().freeze();
|
|
1916
2731
|
const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet);
|
|
1917
2732
|
if (isPromise(builderOutput)) {
|
|
1918
2733
|
return builderOutput.then((output) => {
|
|
@@ -1921,6 +2736,7 @@ var CommandInstance = class {
|
|
|
1921
2736
|
});
|
|
1922
2737
|
}
|
|
1923
2738
|
} else if (isCommandBuilderOptionDefinitions(builder)) {
|
|
2739
|
+
yargs.getInternalMethods().getUsageInstance().freeze();
|
|
1924
2740
|
innerYargs = yargs.getInternalMethods().reset(aliases);
|
|
1925
2741
|
Object.keys(commandHandler.builder).forEach((key) => {
|
|
1926
2742
|
innerYargs.option(key, builder[key]);
|
|
@@ -1954,15 +2770,7 @@ var CommandInstance = class {
|
|
|
1954
2770
|
pc.push(c);
|
|
1955
2771
|
return `$0 ${pc.join(" ")}`;
|
|
1956
2772
|
}
|
|
1957
|
-
|
|
1958
|
-
let positionalMap = {};
|
|
1959
|
-
if (helpOnly)
|
|
1960
|
-
return innerArgv;
|
|
1961
|
-
if (!yargs.getInternalMethods().getHasOutput()) {
|
|
1962
|
-
positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
|
|
1963
|
-
}
|
|
1964
|
-
const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
|
|
1965
|
-
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
|
|
2773
|
+
handleValidationAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, aliases, yargs, middlewares, positionalMap) {
|
|
1966
2774
|
if (!yargs.getInternalMethods().getHasOutput()) {
|
|
1967
2775
|
const validation2 = yargs.getInternalMethods().runValidation(aliases, positionalMap, yargs.parsed.error, isDefaultCommand);
|
|
1968
2776
|
innerArgv = maybeAsyncResult(innerArgv, (result) => {
|
|
@@ -1997,6 +2805,17 @@ var CommandInstance = class {
|
|
|
1997
2805
|
}
|
|
1998
2806
|
return innerArgv;
|
|
1999
2807
|
}
|
|
2808
|
+
applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
|
|
2809
|
+
let positionalMap = {};
|
|
2810
|
+
if (helpOnly)
|
|
2811
|
+
return innerArgv;
|
|
2812
|
+
if (!yargs.getInternalMethods().getHasOutput()) {
|
|
2813
|
+
positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
|
|
2814
|
+
}
|
|
2815
|
+
const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
|
|
2816
|
+
const maybePromiseArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
|
|
2817
|
+
return isPromise(maybePromiseArgv) ? maybePromiseArgv.then((resolvedInnerArgv) => this.handleValidationAndGetResult(isDefaultCommand, commandHandler, resolvedInnerArgv, currentContext, aliases, yargs, middlewares, positionalMap)) : this.handleValidationAndGetResult(isDefaultCommand, commandHandler, maybePromiseArgv, currentContext, aliases, yargs, middlewares, positionalMap);
|
|
2818
|
+
}
|
|
2000
2819
|
populatePositionals(commandHandler, argv, context, yargs) {
|
|
2001
2820
|
argv._ = argv._.slice(context.commands.length);
|
|
2002
2821
|
const demanded = commandHandler.demanded.slice(0);
|
|
@@ -2083,12 +2902,11 @@ var CommandInstance = class {
|
|
|
2083
2902
|
Object.keys(positionalMap).forEach((key) => {
|
|
2084
2903
|
positionalKeys.push(...parsed.aliases[key]);
|
|
2085
2904
|
});
|
|
2086
|
-
const defaults = yargs.getOptions().default;
|
|
2087
2905
|
Object.keys(parsed.argv).forEach((key) => {
|
|
2088
2906
|
if (positionalKeys.includes(key)) {
|
|
2089
2907
|
if (!positionalMap[key])
|
|
2090
2908
|
positionalMap[key] = parsed.argv[key];
|
|
2091
|
-
if (!
|
|
2909
|
+
if (!this.isInConfigs(yargs, key) && !this.isDefaulted(yargs, key) && Object.prototype.hasOwnProperty.call(argv, key) && Object.prototype.hasOwnProperty.call(parsed.argv, key) && (Array.isArray(argv[key]) || Array.isArray(parsed.argv[key]))) {
|
|
2092
2910
|
argv[key] = [].concat(argv[key], parsed.argv[key]);
|
|
2093
2911
|
} else {
|
|
2094
2912
|
argv[key] = parsed.argv[key];
|
|
@@ -2097,6 +2915,14 @@ var CommandInstance = class {
|
|
|
2097
2915
|
});
|
|
2098
2916
|
}
|
|
2099
2917
|
}
|
|
2918
|
+
isDefaulted(yargs, key) {
|
|
2919
|
+
const { default: defaults } = yargs.getOptions();
|
|
2920
|
+
return Object.prototype.hasOwnProperty.call(defaults, key) || Object.prototype.hasOwnProperty.call(defaults, this.shim.Parser.camelCase(key));
|
|
2921
|
+
}
|
|
2922
|
+
isInConfigs(yargs, key) {
|
|
2923
|
+
const { configObjects } = yargs.getOptions();
|
|
2924
|
+
return configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, key)) || configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, this.shim.Parser.camelCase(key)));
|
|
2925
|
+
}
|
|
2100
2926
|
runDefaultBuilderOn(yargs) {
|
|
2101
2927
|
if (!this.defaultCommand)
|
|
2102
2928
|
return;
|
|
@@ -2324,13 +3150,16 @@ function usage(yargs, shim3) {
|
|
|
2324
3150
|
wrapSet = true;
|
|
2325
3151
|
wrap2 = cols;
|
|
2326
3152
|
};
|
|
2327
|
-
|
|
3153
|
+
self.getWrap = () => {
|
|
3154
|
+
if (shim3.getEnv("YARGS_DISABLE_WRAP")) {
|
|
3155
|
+
return null;
|
|
3156
|
+
}
|
|
2328
3157
|
if (!wrapSet) {
|
|
2329
3158
|
wrap2 = windowWidth();
|
|
2330
3159
|
wrapSet = true;
|
|
2331
3160
|
}
|
|
2332
3161
|
return wrap2;
|
|
2333
|
-
}
|
|
3162
|
+
};
|
|
2334
3163
|
const deferY18nLookupPrefix = "__yargsString__:";
|
|
2335
3164
|
self.deferY18nLookup = (str) => deferY18nLookupPrefix + str;
|
|
2336
3165
|
self.help = function help() {
|
|
@@ -2354,7 +3183,7 @@ function usage(yargs, shim3) {
|
|
|
2354
3183
|
acc[key] = true;
|
|
2355
3184
|
return acc;
|
|
2356
3185
|
}, {}));
|
|
2357
|
-
const theWrap = getWrap();
|
|
3186
|
+
const theWrap = self.getWrap();
|
|
2358
3187
|
const ui2 = shim3.cliui({
|
|
2359
3188
|
width: theWrap,
|
|
2360
3189
|
wrap: !!theWrap
|
|
@@ -2494,7 +3323,8 @@ function usage(yargs, shim3) {
|
|
|
2494
3323
|
padding: [0, 2, 0, 2 + getIndentation(kswitch)],
|
|
2495
3324
|
width: maxWidth(switches, theWrap) + 4
|
|
2496
3325
|
}, desc);
|
|
2497
|
-
|
|
3326
|
+
const shouldHideOptionExtras = yargs.getInternalMethods().getUsageConfiguration()["hide-types"] === true;
|
|
3327
|
+
if (extra && !shouldHideOptionExtras)
|
|
2498
3328
|
ui2.div({ text: extra, padding: [0, 0, 0, 2], align: "right" });
|
|
2499
3329
|
else
|
|
2500
3330
|
ui2.div();
|
|
@@ -2755,7 +3585,7 @@ var completionZshTemplate = `#compdef {{app_name}}
|
|
|
2755
3585
|
# yargs command completion script
|
|
2756
3586
|
#
|
|
2757
3587
|
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
|
|
2758
|
-
# or {{app_path}} {{completion_command}} >> ~/.
|
|
3588
|
+
# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
|
|
2759
3589
|
#
|
|
2760
3590
|
_{{app_name}}_yargs_completions()
|
|
2761
3591
|
{
|
|
@@ -2773,7 +3603,7 @@ compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
|
2773
3603
|
// ../../node_modules/yargs/build/lib/completion.js
|
|
2774
3604
|
var Completion = class {
|
|
2775
3605
|
constructor(yargs, usage2, command2, shim3) {
|
|
2776
|
-
var
|
|
3606
|
+
var _a2, _b2, _c2;
|
|
2777
3607
|
this.yargs = yargs;
|
|
2778
3608
|
this.usage = usage2;
|
|
2779
3609
|
this.command = command2;
|
|
@@ -2782,7 +3612,7 @@ var Completion = class {
|
|
|
2782
3612
|
this.aliases = null;
|
|
2783
3613
|
this.customCompletionFunction = null;
|
|
2784
3614
|
this.indexAfterLastReset = 0;
|
|
2785
|
-
this.zshShell = (
|
|
3615
|
+
this.zshShell = (_c2 = ((_a2 = this.shim.getEnv("SHELL")) === null || _a2 === void 0 ? void 0 : _a2.includes("zsh")) || ((_b2 = this.shim.getEnv("ZSH_NAME")) === null || _b2 === void 0 ? void 0 : _b2.includes("zsh"))) !== null && _c2 !== void 0 ? _c2 : false;
|
|
2786
3616
|
}
|
|
2787
3617
|
defaultCompletion(args, argv, current, done) {
|
|
2788
3618
|
const handlers = this.command.getCommandHandlers();
|
|
@@ -2827,7 +3657,7 @@ var Completion = class {
|
|
|
2827
3657
|
Object.keys(options.key).forEach((key) => {
|
|
2828
3658
|
const negable = !!options.configuration["boolean-negation"] && options.boolean.includes(key);
|
|
2829
3659
|
const isPositionalKey = positionalKeys.includes(key);
|
|
2830
|
-
if (!isPositionalKey && !options.hiddenOptions.includes(key) && !this.argsContainKey(args,
|
|
3660
|
+
if (!isPositionalKey && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, key, negable)) {
|
|
2831
3661
|
this.completeOptionKey(key, completions, current);
|
|
2832
3662
|
if (negable && !!options.default[key])
|
|
2833
3663
|
this.completeOptionKey(`no-${key}`, completions, current);
|
|
@@ -2892,20 +3722,22 @@ var Completion = class {
|
|
|
2892
3722
|
const choices = this.getPreviousArgChoices(args);
|
|
2893
3723
|
return choices !== void 0 && choices.length > 0;
|
|
2894
3724
|
}
|
|
2895
|
-
argsContainKey(args,
|
|
2896
|
-
|
|
3725
|
+
argsContainKey(args, key, negable) {
|
|
3726
|
+
const argsContains = (s) => args.indexOf((/^[^0-9]$/.test(s) ? "-" : "--") + s) !== -1;
|
|
3727
|
+
if (argsContains(key))
|
|
2897
3728
|
return true;
|
|
2898
|
-
if (negable &&
|
|
3729
|
+
if (negable && argsContains(`no-${key}`))
|
|
2899
3730
|
return true;
|
|
2900
3731
|
if (this.aliases) {
|
|
2901
3732
|
for (const alias of this.aliases[key]) {
|
|
2902
|
-
if (
|
|
3733
|
+
if (argsContains(alias))
|
|
2903
3734
|
return true;
|
|
2904
3735
|
}
|
|
2905
3736
|
}
|
|
2906
3737
|
return false;
|
|
2907
3738
|
}
|
|
2908
3739
|
completeOptionKey(key, completions, current) {
|
|
3740
|
+
var _a2, _b2, _c2;
|
|
2909
3741
|
const descs = this.usage.getDescriptions();
|
|
2910
3742
|
const startsByTwoDashes = (s) => /^--/.test(s);
|
|
2911
3743
|
const isShortOption = (s) => /^[^0-9]$/.test(s);
|
|
@@ -2913,8 +3745,13 @@ var Completion = class {
|
|
|
2913
3745
|
if (!this.zshShell) {
|
|
2914
3746
|
completions.push(dashes + key);
|
|
2915
3747
|
} else {
|
|
2916
|
-
const
|
|
2917
|
-
|
|
3748
|
+
const aliasKey = (_a2 = this === null || this === void 0 ? void 0 : this.aliases) === null || _a2 === void 0 ? void 0 : _a2[key].find((alias) => {
|
|
3749
|
+
const desc2 = descs[alias];
|
|
3750
|
+
return typeof desc2 === "string" && desc2.length > 0;
|
|
3751
|
+
});
|
|
3752
|
+
const descFromAlias = aliasKey ? descs[aliasKey] : void 0;
|
|
3753
|
+
const desc = (_c2 = (_b2 = descs[key]) !== null && _b2 !== void 0 ? _b2 : descFromAlias) !== null && _c2 !== void 0 ? _c2 : "";
|
|
3754
|
+
completions.push(dashes + `${key.replace(/:/g, "\\:")}:${desc.replace("__yargsString__:", "").replace(/(\r\n|\n|\r)/gm, " ")}`);
|
|
2918
3755
|
}
|
|
2919
3756
|
}
|
|
2920
3757
|
customCompletion(args, argv, current, done) {
|
|
@@ -3059,7 +3896,7 @@ ${customMsgs.join("\n")}` : "";
|
|
|
3059
3896
|
}
|
|
3060
3897
|
};
|
|
3061
3898
|
self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
|
|
3062
|
-
var
|
|
3899
|
+
var _a2;
|
|
3063
3900
|
const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
|
|
3064
3901
|
const unknown = [];
|
|
3065
3902
|
const currentContext = yargs.getInternalMethods().getContext();
|
|
@@ -3077,7 +3914,7 @@ ${customMsgs.join("\n")}` : "";
|
|
|
3077
3914
|
}
|
|
3078
3915
|
if (checkPositionals) {
|
|
3079
3916
|
const demandedCommands = yargs.getDemandedCommands();
|
|
3080
|
-
const maxNonOptDemanded = ((
|
|
3917
|
+
const maxNonOptDemanded = ((_a2 = demandedCommands._) === null || _a2 === void 0 ? void 0 : _a2.max) || 0;
|
|
3081
3918
|
const expected = currentContext.commands.length + maxNonOptDemanded;
|
|
3082
3919
|
if (expected < argv._.length) {
|
|
3083
3920
|
argv._.slice(expected).forEach((key) => {
|
|
@@ -3377,6 +4214,7 @@ var _YargsInstance_strict;
|
|
|
3377
4214
|
var _YargsInstance_strictCommands;
|
|
3378
4215
|
var _YargsInstance_strictOptions;
|
|
3379
4216
|
var _YargsInstance_usage;
|
|
4217
|
+
var _YargsInstance_usageConfig;
|
|
3380
4218
|
var _YargsInstance_versionOpt;
|
|
3381
4219
|
var _YargsInstance_validation;
|
|
3382
4220
|
function YargsFactory(_shim) {
|
|
@@ -3400,6 +4238,7 @@ var kEmitWarning = Symbol("emitWarning");
|
|
|
3400
4238
|
var kFreeze = Symbol("freeze");
|
|
3401
4239
|
var kGetDollarZero = Symbol("getDollarZero");
|
|
3402
4240
|
var kGetParserConfiguration = Symbol("getParserConfiguration");
|
|
4241
|
+
var kGetUsageConfiguration = Symbol("getUsageConfiguration");
|
|
3403
4242
|
var kGuessLocale = Symbol("guessLocale");
|
|
3404
4243
|
var kGuessVersion = Symbol("guessVersion");
|
|
3405
4244
|
var kParsePositionalNumbers = Symbol("parsePositionalNumbers");
|
|
@@ -3464,6 +4303,7 @@ var YargsInstance = class {
|
|
|
3464
4303
|
_YargsInstance_strictCommands.set(this, false);
|
|
3465
4304
|
_YargsInstance_strictOptions.set(this, false);
|
|
3466
4305
|
_YargsInstance_usage.set(this, void 0);
|
|
4306
|
+
_YargsInstance_usageConfig.set(this, {});
|
|
3467
4307
|
_YargsInstance_versionOpt.set(this, null);
|
|
3468
4308
|
_YargsInstance_validation.set(this, void 0);
|
|
3469
4309
|
__classPrivateFieldSet(this, _YargsInstance_shim, shim3, "f");
|
|
@@ -3573,7 +4413,7 @@ var YargsInstance = class {
|
|
|
3573
4413
|
__classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
|
|
3574
4414
|
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
|
|
3575
4415
|
let aliases;
|
|
3576
|
-
const shouldCoerce = Object.hasOwnProperty.call(argv, keys);
|
|
4416
|
+
const shouldCoerce = Object.prototype.hasOwnProperty.call(argv, keys);
|
|
3577
4417
|
if (!shouldCoerce) {
|
|
3578
4418
|
return argv;
|
|
3579
4419
|
}
|
|
@@ -3888,7 +4728,7 @@ var YargsInstance = class {
|
|
|
3888
4728
|
}
|
|
3889
4729
|
locale(locale) {
|
|
3890
4730
|
argsert("[string]", [locale], arguments.length);
|
|
3891
|
-
if (
|
|
4731
|
+
if (locale === void 0) {
|
|
3892
4732
|
this[kGuessLocale]();
|
|
3893
4733
|
return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
|
|
3894
4734
|
}
|
|
@@ -4010,7 +4850,10 @@ var YargsInstance = class {
|
|
|
4010
4850
|
this.skipValidation(key);
|
|
4011
4851
|
}
|
|
4012
4852
|
const desc = opt.describe || opt.description || opt.desc;
|
|
4013
|
-
this
|
|
4853
|
+
const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions();
|
|
4854
|
+
if (!Object.prototype.hasOwnProperty.call(descriptions, key) || typeof desc === "string") {
|
|
4855
|
+
this.describe(key, desc);
|
|
4856
|
+
}
|
|
4014
4857
|
if (opt.hidden) {
|
|
4015
4858
|
this.hide(key);
|
|
4016
4859
|
}
|
|
@@ -4251,6 +5094,11 @@ var YargsInstance = class {
|
|
|
4251
5094
|
return this;
|
|
4252
5095
|
}
|
|
4253
5096
|
}
|
|
5097
|
+
usageConfiguration(config) {
|
|
5098
|
+
argsert("<object>", [config], arguments.length);
|
|
5099
|
+
__classPrivateFieldSet(this, _YargsInstance_usageConfig, config, "f");
|
|
5100
|
+
return this;
|
|
5101
|
+
}
|
|
4254
5102
|
version(opt, msg, ver) {
|
|
4255
5103
|
const defaultVersionOpt = "version";
|
|
4256
5104
|
argsert("[boolean|string] [string] [string]", [opt, msg, ver], arguments.length);
|
|
@@ -4284,7 +5132,7 @@ var YargsInstance = class {
|
|
|
4284
5132
|
__classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
|
|
4285
5133
|
return this;
|
|
4286
5134
|
}
|
|
4287
|
-
[(_YargsInstance_command = /* @__PURE__ */ new WeakMap(), _YargsInstance_cwd = /* @__PURE__ */ new WeakMap(), _YargsInstance_context = /* @__PURE__ */ new WeakMap(), _YargsInstance_completion = /* @__PURE__ */ new WeakMap(), _YargsInstance_completionCommand = /* @__PURE__ */ new WeakMap(), _YargsInstance_defaultShowHiddenOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitError = /* @__PURE__ */ new WeakMap(), _YargsInstance_detectLocale = /* @__PURE__ */ new WeakMap(), _YargsInstance_emittedWarnings = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitProcess = /* @__PURE__ */ new WeakMap(), _YargsInstance_frozens = /* @__PURE__ */ new WeakMap(), _YargsInstance_globalMiddleware = /* @__PURE__ */ new WeakMap(), _YargsInstance_groups = /* @__PURE__ */ new WeakMap(), _YargsInstance_hasOutput = /* @__PURE__ */ new WeakMap(), _YargsInstance_helpOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_isGlobalContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_logger = /* @__PURE__ */ new WeakMap(), _YargsInstance_output = /* @__PURE__ */ new WeakMap(), _YargsInstance_options = /* @__PURE__ */ new WeakMap(), _YargsInstance_parentRequire = /* @__PURE__ */ new WeakMap(), _YargsInstance_parserConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseFn = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_pkgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_preservedGroups = /* @__PURE__ */ new WeakMap(), _YargsInstance_processArgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_recommendCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_shim = /* @__PURE__ */ new WeakMap(), _YargsInstance_strict = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictOptions = /* @__PURE__ */ new WeakMap(), _YargsInstance_usage = /* @__PURE__ */ new WeakMap(), _YargsInstance_versionOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_validation = /* @__PURE__ */ new WeakMap(), kCopyDoubleDash)](argv) {
|
|
5135
|
+
[(_YargsInstance_command = /* @__PURE__ */ new WeakMap(), _YargsInstance_cwd = /* @__PURE__ */ new WeakMap(), _YargsInstance_context = /* @__PURE__ */ new WeakMap(), _YargsInstance_completion = /* @__PURE__ */ new WeakMap(), _YargsInstance_completionCommand = /* @__PURE__ */ new WeakMap(), _YargsInstance_defaultShowHiddenOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitError = /* @__PURE__ */ new WeakMap(), _YargsInstance_detectLocale = /* @__PURE__ */ new WeakMap(), _YargsInstance_emittedWarnings = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitProcess = /* @__PURE__ */ new WeakMap(), _YargsInstance_frozens = /* @__PURE__ */ new WeakMap(), _YargsInstance_globalMiddleware = /* @__PURE__ */ new WeakMap(), _YargsInstance_groups = /* @__PURE__ */ new WeakMap(), _YargsInstance_hasOutput = /* @__PURE__ */ new WeakMap(), _YargsInstance_helpOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_isGlobalContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_logger = /* @__PURE__ */ new WeakMap(), _YargsInstance_output = /* @__PURE__ */ new WeakMap(), _YargsInstance_options = /* @__PURE__ */ new WeakMap(), _YargsInstance_parentRequire = /* @__PURE__ */ new WeakMap(), _YargsInstance_parserConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseFn = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_pkgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_preservedGroups = /* @__PURE__ */ new WeakMap(), _YargsInstance_processArgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_recommendCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_shim = /* @__PURE__ */ new WeakMap(), _YargsInstance_strict = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictOptions = /* @__PURE__ */ new WeakMap(), _YargsInstance_usage = /* @__PURE__ */ new WeakMap(), _YargsInstance_usageConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_versionOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_validation = /* @__PURE__ */ new WeakMap(), kCopyDoubleDash)](argv) {
|
|
4288
5136
|
if (!argv._ || !argv["--"])
|
|
4289
5137
|
return argv;
|
|
4290
5138
|
argv._.push.apply(argv._, argv["--"]);
|
|
@@ -4376,6 +5224,9 @@ var YargsInstance = class {
|
|
|
4376
5224
|
[kGetParserConfiguration]() {
|
|
4377
5225
|
return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
|
|
4378
5226
|
}
|
|
5227
|
+
[kGetUsageConfiguration]() {
|
|
5228
|
+
return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f");
|
|
5229
|
+
}
|
|
4379
5230
|
[kGuessLocale]() {
|
|
4380
5231
|
if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f"))
|
|
4381
5232
|
return;
|
|
@@ -4459,20 +5310,20 @@ var YargsInstance = class {
|
|
|
4459
5310
|
return this;
|
|
4460
5311
|
}
|
|
4461
5312
|
[kUnfreeze]() {
|
|
4462
|
-
var
|
|
5313
|
+
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
4463
5314
|
const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
|
|
4464
5315
|
assertNotStrictEqual(frozen, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
4465
5316
|
let configObjects;
|
|
4466
|
-
|
|
5317
|
+
_a2 = this, _b2 = this, _c2 = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
|
|
4467
5318
|
options: { set value(_o) {
|
|
4468
|
-
__classPrivateFieldSet(
|
|
5319
|
+
__classPrivateFieldSet(_a2, _YargsInstance_options, _o, "f");
|
|
4469
5320
|
} }.value,
|
|
4470
5321
|
configObjects,
|
|
4471
5322
|
exitProcess: { set value(_o) {
|
|
4472
|
-
__classPrivateFieldSet(
|
|
5323
|
+
__classPrivateFieldSet(_b2, _YargsInstance_exitProcess, _o, "f");
|
|
4473
5324
|
} }.value,
|
|
4474
5325
|
groups: { set value(_o) {
|
|
4475
|
-
__classPrivateFieldSet(
|
|
5326
|
+
__classPrivateFieldSet(_c2, _YargsInstance_groups, _o, "f");
|
|
4476
5327
|
} }.value,
|
|
4477
5328
|
output: { set value(_o) {
|
|
4478
5329
|
__classPrivateFieldSet(_d, _YargsInstance_output, _o, "f");
|
|
@@ -4523,6 +5374,7 @@ var YargsInstance = class {
|
|
|
4523
5374
|
getLoggerInstance: this[kGetLoggerInstance].bind(this),
|
|
4524
5375
|
getParseContext: this[kGetParseContext].bind(this),
|
|
4525
5376
|
getParserConfiguration: this[kGetParserConfiguration].bind(this),
|
|
5377
|
+
getUsageConfiguration: this[kGetUsageConfiguration].bind(this),
|
|
4526
5378
|
getUsageInstance: this[kGetUsageInstance].bind(this),
|
|
4527
5379
|
getValidationInstance: this[kGetValidationInstance].bind(this),
|
|
4528
5380
|
hasParseCallback: this[kHasParseCallback].bind(this),
|
|
@@ -4816,14 +5668,602 @@ function isYargsInstance(y) {
|
|
|
4816
5668
|
var Yargs = YargsFactory(esm_default);
|
|
4817
5669
|
var yargs_default = Yargs;
|
|
4818
5670
|
|
|
4819
|
-
// src/
|
|
4820
|
-
var
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
5671
|
+
// src/errors.ts
|
|
5672
|
+
var FatalError = class extends Error {
|
|
5673
|
+
constructor(message, code) {
|
|
5674
|
+
super(message);
|
|
5675
|
+
this.code = code;
|
|
5676
|
+
}
|
|
5677
|
+
};
|
|
5678
|
+
|
|
5679
|
+
// src/miniflare-cli/assets.ts
|
|
5680
|
+
import { existsSync, lstatSync, readFileSync as readFileSync5 } from "node:fs";
|
|
5681
|
+
import { join } from "node:path";
|
|
5682
|
+
|
|
5683
|
+
// ../pages-shared/metadata-generator/constants.ts
|
|
5684
|
+
var REDIRECTS_VERSION = 1;
|
|
5685
|
+
var HEADERS_VERSION = 2;
|
|
5686
|
+
var ANALYTICS_VERSION = 1;
|
|
5687
|
+
var PERMITTED_STATUS_CODES = /* @__PURE__ */ new Set([200, 301, 302, 303, 307, 308]);
|
|
5688
|
+
var HEADER_SEPARATOR = ":";
|
|
5689
|
+
var MAX_LINE_LENGTH = 2e3;
|
|
5690
|
+
var MAX_HEADER_RULES = 100;
|
|
5691
|
+
var MAX_DYNAMIC_REDIRECT_RULES = 100;
|
|
5692
|
+
var MAX_STATIC_REDIRECT_RULES = 2e3;
|
|
5693
|
+
var UNSET_OPERATOR = "! ";
|
|
5694
|
+
var SPLAT_REGEX = /\*/g;
|
|
5695
|
+
var PLACEHOLDER_REGEX = /:\w+/g;
|
|
5696
|
+
|
|
5697
|
+
// ../pages-shared/metadata-generator/createMetadataObject.ts
|
|
5698
|
+
function createMetadataObject({
|
|
5699
|
+
redirects,
|
|
5700
|
+
headers,
|
|
5701
|
+
webAnalyticsToken,
|
|
5702
|
+
deploymentId,
|
|
5703
|
+
failOpen,
|
|
5704
|
+
logger = (_message) => {
|
|
5705
|
+
}
|
|
5706
|
+
}) {
|
|
5707
|
+
return {
|
|
5708
|
+
...constructRedirects({ redirects, logger }),
|
|
5709
|
+
...constructHeaders({ headers, logger }),
|
|
5710
|
+
...constructWebAnalytics({ webAnalyticsToken, logger }),
|
|
5711
|
+
deploymentId,
|
|
5712
|
+
failOpen
|
|
5713
|
+
};
|
|
5714
|
+
}
|
|
5715
|
+
function constructRedirects({
|
|
5716
|
+
redirects,
|
|
5717
|
+
logger
|
|
5718
|
+
}) {
|
|
5719
|
+
if (!redirects)
|
|
5720
|
+
return {};
|
|
5721
|
+
const num_valid = redirects.rules.length;
|
|
5722
|
+
const num_invalid = redirects.invalid.length;
|
|
5723
|
+
logger(
|
|
5724
|
+
`Parsed ${num_valid} valid redirect rule${num_valid === 1 ? "" : "s"}.`
|
|
5725
|
+
);
|
|
5726
|
+
if (num_invalid > 0) {
|
|
5727
|
+
logger(`Found invalid redirect lines:`);
|
|
5728
|
+
for (const { line, lineNumber, message } of redirects.invalid) {
|
|
5729
|
+
if (line)
|
|
5730
|
+
logger(` - ${lineNumber ? `#${lineNumber}: ` : ""}${line}`);
|
|
5731
|
+
logger(` ${message}`);
|
|
5732
|
+
}
|
|
5733
|
+
}
|
|
5734
|
+
if (num_valid === 0) {
|
|
5735
|
+
return {};
|
|
5736
|
+
}
|
|
5737
|
+
const staticRedirects = {};
|
|
5738
|
+
const dynamicRedirects = {};
|
|
5739
|
+
let canCreateStaticRule = true;
|
|
5740
|
+
for (const rule of redirects.rules) {
|
|
5741
|
+
if (!rule.from.match(SPLAT_REGEX) && !rule.from.match(PLACEHOLDER_REGEX)) {
|
|
5742
|
+
if (canCreateStaticRule) {
|
|
5743
|
+
staticRedirects[rule.from] = {
|
|
5744
|
+
status: rule.status,
|
|
5745
|
+
to: rule.to,
|
|
5746
|
+
lineNumber: rule.lineNumber
|
|
5747
|
+
};
|
|
5748
|
+
continue;
|
|
5749
|
+
} else {
|
|
5750
|
+
logger(
|
|
5751
|
+
`Info: the redirect rule ${rule.from} \u2192 ${rule.status} ${rule.to} could be made more performant by bringing it above any lines with splats or placeholders.`
|
|
5752
|
+
);
|
|
5753
|
+
}
|
|
5754
|
+
}
|
|
5755
|
+
dynamicRedirects[rule.from] = { status: rule.status, to: rule.to };
|
|
5756
|
+
canCreateStaticRule = false;
|
|
5757
|
+
}
|
|
5758
|
+
return {
|
|
5759
|
+
redirects: {
|
|
5760
|
+
version: REDIRECTS_VERSION,
|
|
5761
|
+
staticRules: staticRedirects,
|
|
5762
|
+
rules: dynamicRedirects
|
|
5763
|
+
}
|
|
5764
|
+
};
|
|
5765
|
+
}
|
|
5766
|
+
function constructHeaders({
|
|
5767
|
+
headers,
|
|
5768
|
+
logger
|
|
5769
|
+
}) {
|
|
5770
|
+
if (!headers)
|
|
5771
|
+
return {};
|
|
5772
|
+
const num_valid = headers.rules.length;
|
|
5773
|
+
const num_invalid = headers.invalid.length;
|
|
5774
|
+
logger(`Parsed ${num_valid} valid header rule${num_valid === 1 ? "" : "s"}.`);
|
|
5775
|
+
if (num_invalid > 0) {
|
|
5776
|
+
logger(`Found invalid header lines:`);
|
|
5777
|
+
for (const { line, lineNumber, message } of headers.invalid) {
|
|
5778
|
+
if (line)
|
|
5779
|
+
logger(` - ${lineNumber ? `#${lineNumber}: ` : ""} ${line}`);
|
|
5780
|
+
logger(` ${message}`);
|
|
5781
|
+
}
|
|
5782
|
+
}
|
|
5783
|
+
if (num_valid === 0) {
|
|
5784
|
+
return {};
|
|
5785
|
+
}
|
|
5786
|
+
const rules = {};
|
|
5787
|
+
for (const rule of headers.rules) {
|
|
5788
|
+
rules[rule.path] = {};
|
|
5789
|
+
if (Object.keys(rule.headers).length) {
|
|
5790
|
+
rules[rule.path].set = rule.headers;
|
|
5791
|
+
}
|
|
5792
|
+
if (rule.unsetHeaders.length) {
|
|
5793
|
+
rules[rule.path].unset = rule.unsetHeaders;
|
|
5794
|
+
}
|
|
5795
|
+
}
|
|
5796
|
+
return {
|
|
5797
|
+
headers: {
|
|
5798
|
+
version: HEADERS_VERSION,
|
|
5799
|
+
rules
|
|
5800
|
+
}
|
|
5801
|
+
};
|
|
5802
|
+
}
|
|
5803
|
+
function constructWebAnalytics({
|
|
5804
|
+
webAnalyticsToken
|
|
5805
|
+
}) {
|
|
5806
|
+
if (!webAnalyticsToken)
|
|
5807
|
+
return {};
|
|
5808
|
+
return {
|
|
5809
|
+
analytics: {
|
|
5810
|
+
version: ANALYTICS_VERSION,
|
|
5811
|
+
token: webAnalyticsToken
|
|
5812
|
+
}
|
|
5813
|
+
};
|
|
5814
|
+
}
|
|
5815
|
+
|
|
5816
|
+
// ../pages-shared/metadata-generator/validateURL.ts
|
|
5817
|
+
var extractPathname = (path = "/", includeSearch, includeHash) => {
|
|
5818
|
+
if (!path.startsWith("/"))
|
|
5819
|
+
path = `/${path}`;
|
|
5820
|
+
const url = new URL(`//${path}`, "relative://");
|
|
5821
|
+
return `${url.pathname}${includeSearch ? url.search : ""}${includeHash ? url.hash : ""}`;
|
|
5822
|
+
};
|
|
5823
|
+
var URL_REGEX = /^https:\/\/+(?<host>[^/]+)\/?(?<path>.*)/;
|
|
5824
|
+
var PATH_REGEX = /^\//;
|
|
5825
|
+
var validateUrl = (token, onlyRelative = false, includeSearch = false, includeHash = false) => {
|
|
5826
|
+
const host = URL_REGEX.exec(token);
|
|
5827
|
+
if (host && host.groups && host.groups.host) {
|
|
5828
|
+
if (onlyRelative)
|
|
5829
|
+
return [
|
|
5830
|
+
void 0,
|
|
5831
|
+
`Only relative URLs are allowed. Skipping absolute URL ${token}.`
|
|
5832
|
+
];
|
|
5833
|
+
return [
|
|
5834
|
+
`https://${host.groups.host}${extractPathname(
|
|
5835
|
+
host.groups.path,
|
|
5836
|
+
includeSearch,
|
|
5837
|
+
includeHash
|
|
5838
|
+
)}`,
|
|
5839
|
+
void 0
|
|
5840
|
+
];
|
|
5841
|
+
} else {
|
|
5842
|
+
if (!token.startsWith("/") && onlyRelative)
|
|
5843
|
+
token = `/${token}`;
|
|
5844
|
+
const path = PATH_REGEX.exec(token);
|
|
5845
|
+
if (path) {
|
|
5846
|
+
try {
|
|
5847
|
+
return [extractPathname(token, includeSearch, includeHash), void 0];
|
|
5848
|
+
} catch {
|
|
5849
|
+
return [void 0, `Error parsing URL segment ${token}. Skipping.`];
|
|
5850
|
+
}
|
|
5851
|
+
}
|
|
5852
|
+
}
|
|
5853
|
+
return [
|
|
5854
|
+
void 0,
|
|
5855
|
+
onlyRelative ? "URLs should begin with a forward-slash." : 'URLs should either be relative (e.g. begin with a forward-slash), or use HTTPS (e.g. begin with "https://").'
|
|
5856
|
+
];
|
|
5857
|
+
};
|
|
5858
|
+
function urlHasHost(token) {
|
|
5859
|
+
const host = URL_REGEX.exec(token);
|
|
5860
|
+
return Boolean(host && host.groups && host.groups.host);
|
|
5861
|
+
}
|
|
5862
|
+
|
|
5863
|
+
// ../pages-shared/metadata-generator/parseHeaders.ts
|
|
5864
|
+
var LINE_IS_PROBABLY_A_PATH = new RegExp(/^([^\s]+:\/\/|^\/)/);
|
|
5865
|
+
function parseHeaders(input) {
|
|
5866
|
+
const lines = input.split("\n");
|
|
5867
|
+
const rules = [];
|
|
5868
|
+
const invalid = [];
|
|
5869
|
+
let rule = void 0;
|
|
5870
|
+
for (let i = 0; i < lines.length; i++) {
|
|
5871
|
+
const line = lines[i].trim();
|
|
5872
|
+
if (line.length === 0 || line.startsWith("#"))
|
|
5873
|
+
continue;
|
|
5874
|
+
if (line.length > MAX_LINE_LENGTH) {
|
|
5875
|
+
invalid.push({
|
|
5876
|
+
message: `Ignoring line ${i + 1} as it exceeds the maximum allowed length of ${MAX_LINE_LENGTH}.`
|
|
5877
|
+
});
|
|
5878
|
+
continue;
|
|
5879
|
+
}
|
|
5880
|
+
if (LINE_IS_PROBABLY_A_PATH.test(line)) {
|
|
5881
|
+
if (rules.length >= MAX_HEADER_RULES) {
|
|
5882
|
+
invalid.push({
|
|
5883
|
+
message: `Maximum number of rules supported is ${MAX_HEADER_RULES}. Skipping remaining ${lines.length - i} lines of file.`
|
|
5884
|
+
});
|
|
5885
|
+
break;
|
|
5886
|
+
}
|
|
5887
|
+
if (rule) {
|
|
5888
|
+
if (isValidRule(rule)) {
|
|
5889
|
+
rules.push({
|
|
5890
|
+
path: rule.path,
|
|
5891
|
+
headers: rule.headers,
|
|
5892
|
+
unsetHeaders: rule.unsetHeaders
|
|
5893
|
+
});
|
|
5894
|
+
} else {
|
|
5895
|
+
invalid.push({
|
|
5896
|
+
line: rule.line,
|
|
5897
|
+
lineNumber: i + 1,
|
|
5898
|
+
message: "No headers specified"
|
|
5899
|
+
});
|
|
5900
|
+
}
|
|
5901
|
+
}
|
|
5902
|
+
const [path, pathError] = validateUrl(line);
|
|
5903
|
+
if (pathError) {
|
|
5904
|
+
invalid.push({
|
|
5905
|
+
line,
|
|
5906
|
+
lineNumber: i + 1,
|
|
5907
|
+
message: pathError
|
|
5908
|
+
});
|
|
5909
|
+
rule = void 0;
|
|
5910
|
+
continue;
|
|
5911
|
+
}
|
|
5912
|
+
rule = {
|
|
5913
|
+
path,
|
|
5914
|
+
line,
|
|
5915
|
+
headers: {},
|
|
5916
|
+
unsetHeaders: []
|
|
5917
|
+
};
|
|
5918
|
+
continue;
|
|
5919
|
+
}
|
|
5920
|
+
if (!line.includes(HEADER_SEPARATOR)) {
|
|
5921
|
+
if (!rule) {
|
|
5922
|
+
invalid.push({
|
|
5923
|
+
line,
|
|
5924
|
+
lineNumber: i + 1,
|
|
5925
|
+
message: "Expected a path beginning with at least one forward-slash"
|
|
5926
|
+
});
|
|
5927
|
+
} else {
|
|
5928
|
+
if (line.trim().startsWith(UNSET_OPERATOR)) {
|
|
5929
|
+
rule.unsetHeaders.push(line.trim().replace(UNSET_OPERATOR, ""));
|
|
5930
|
+
} else {
|
|
5931
|
+
invalid.push({
|
|
5932
|
+
line,
|
|
5933
|
+
lineNumber: i + 1,
|
|
5934
|
+
message: "Expected a colon-separated header pair (e.g. name: value)"
|
|
5935
|
+
});
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
5938
|
+
continue;
|
|
5939
|
+
}
|
|
5940
|
+
const [rawName, ...rawValue] = line.split(HEADER_SEPARATOR);
|
|
5941
|
+
const name = rawName.trim().toLowerCase();
|
|
5942
|
+
if (name.includes(" ")) {
|
|
5943
|
+
invalid.push({
|
|
5944
|
+
line,
|
|
5945
|
+
lineNumber: i + 1,
|
|
5946
|
+
message: "Header name cannot include spaces"
|
|
5947
|
+
});
|
|
5948
|
+
continue;
|
|
5949
|
+
}
|
|
5950
|
+
const value = rawValue.join(HEADER_SEPARATOR).trim();
|
|
5951
|
+
if (name === "") {
|
|
5952
|
+
invalid.push({
|
|
5953
|
+
line,
|
|
5954
|
+
lineNumber: i + 1,
|
|
5955
|
+
message: "No header name specified"
|
|
5956
|
+
});
|
|
5957
|
+
continue;
|
|
5958
|
+
}
|
|
5959
|
+
if (value === "") {
|
|
5960
|
+
invalid.push({
|
|
5961
|
+
line,
|
|
5962
|
+
lineNumber: i + 1,
|
|
5963
|
+
message: "No header value specified"
|
|
5964
|
+
});
|
|
5965
|
+
continue;
|
|
5966
|
+
}
|
|
5967
|
+
if (!rule) {
|
|
5968
|
+
invalid.push({
|
|
5969
|
+
line,
|
|
5970
|
+
lineNumber: i + 1,
|
|
5971
|
+
message: `Path should come before header (${name}: ${value})`
|
|
5972
|
+
});
|
|
5973
|
+
continue;
|
|
5974
|
+
}
|
|
5975
|
+
const existingValues = rule.headers[name];
|
|
5976
|
+
rule.headers[name] = existingValues ? `${existingValues}, ${value}` : value;
|
|
5977
|
+
}
|
|
5978
|
+
if (rule) {
|
|
5979
|
+
if (isValidRule(rule)) {
|
|
5980
|
+
rules.push({
|
|
5981
|
+
path: rule.path,
|
|
5982
|
+
headers: rule.headers,
|
|
5983
|
+
unsetHeaders: rule.unsetHeaders
|
|
5984
|
+
});
|
|
5985
|
+
} else {
|
|
5986
|
+
invalid.push({ line: rule.line, message: "No headers specified" });
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
return {
|
|
5990
|
+
rules,
|
|
5991
|
+
invalid
|
|
5992
|
+
};
|
|
5993
|
+
}
|
|
5994
|
+
function isValidRule(rule) {
|
|
5995
|
+
return Object.keys(rule.headers).length > 0 || rule.unsetHeaders.length > 0;
|
|
5996
|
+
}
|
|
5997
|
+
|
|
5998
|
+
// ../pages-shared/metadata-generator/parseRedirects.ts
|
|
5999
|
+
function parseRedirects(input) {
|
|
6000
|
+
const lines = input.split("\n");
|
|
6001
|
+
const rules = [];
|
|
6002
|
+
const seen_paths = /* @__PURE__ */ new Set();
|
|
6003
|
+
const invalid = [];
|
|
6004
|
+
let staticRules = 0;
|
|
6005
|
+
let dynamicRules = 0;
|
|
6006
|
+
let canCreateStaticRule = true;
|
|
6007
|
+
for (let i = 0; i < lines.length; i++) {
|
|
6008
|
+
const line = lines[i].trim();
|
|
6009
|
+
if (line.length === 0 || line.startsWith("#"))
|
|
6010
|
+
continue;
|
|
6011
|
+
if (line.length > MAX_LINE_LENGTH) {
|
|
6012
|
+
invalid.push({
|
|
6013
|
+
message: `Ignoring line ${i + 1} as it exceeds the maximum allowed length of ${MAX_LINE_LENGTH}.`
|
|
6014
|
+
});
|
|
6015
|
+
continue;
|
|
6016
|
+
}
|
|
6017
|
+
const tokens = line.split(/\s+/);
|
|
6018
|
+
if (tokens.length < 2 || tokens.length > 3) {
|
|
6019
|
+
invalid.push({
|
|
6020
|
+
line,
|
|
6021
|
+
lineNumber: i + 1,
|
|
6022
|
+
message: `Expected exactly 2 or 3 whitespace-separated tokens. Got ${tokens.length}.`
|
|
6023
|
+
});
|
|
6024
|
+
continue;
|
|
6025
|
+
}
|
|
6026
|
+
const [str_from, str_to, str_status = "302"] = tokens;
|
|
6027
|
+
const fromResult = validateUrl(str_from, true, false, false);
|
|
6028
|
+
if (fromResult[0] === void 0) {
|
|
6029
|
+
invalid.push({
|
|
6030
|
+
line,
|
|
6031
|
+
lineNumber: i + 1,
|
|
6032
|
+
message: fromResult[1]
|
|
6033
|
+
});
|
|
6034
|
+
continue;
|
|
6035
|
+
}
|
|
6036
|
+
const from = fromResult[0];
|
|
6037
|
+
if (canCreateStaticRule && !from.match(SPLAT_REGEX) && !from.match(PLACEHOLDER_REGEX)) {
|
|
6038
|
+
staticRules += 1;
|
|
6039
|
+
if (staticRules > MAX_STATIC_REDIRECT_RULES) {
|
|
6040
|
+
invalid.push({
|
|
6041
|
+
message: `Maximum number of static rules supported is ${MAX_STATIC_REDIRECT_RULES}. Skipping line.`
|
|
6042
|
+
});
|
|
6043
|
+
continue;
|
|
6044
|
+
}
|
|
6045
|
+
} else {
|
|
6046
|
+
dynamicRules += 1;
|
|
6047
|
+
canCreateStaticRule = false;
|
|
6048
|
+
if (dynamicRules > MAX_DYNAMIC_REDIRECT_RULES) {
|
|
6049
|
+
invalid.push({
|
|
6050
|
+
message: `Maximum number of dynamic rules supported is ${MAX_DYNAMIC_REDIRECT_RULES}. Skipping remaining ${lines.length - i} lines of file.`
|
|
6051
|
+
});
|
|
6052
|
+
break;
|
|
6053
|
+
}
|
|
6054
|
+
}
|
|
6055
|
+
const toResult = validateUrl(str_to, false, true, true);
|
|
6056
|
+
if (toResult[0] === void 0) {
|
|
6057
|
+
invalid.push({
|
|
6058
|
+
line,
|
|
6059
|
+
lineNumber: i + 1,
|
|
6060
|
+
message: toResult[1]
|
|
6061
|
+
});
|
|
6062
|
+
continue;
|
|
6063
|
+
}
|
|
6064
|
+
const to = toResult[0];
|
|
6065
|
+
const status = Number(str_status);
|
|
6066
|
+
if (isNaN(status) || !PERMITTED_STATUS_CODES.has(status)) {
|
|
6067
|
+
invalid.push({
|
|
6068
|
+
line,
|
|
6069
|
+
lineNumber: i + 1,
|
|
6070
|
+
message: `Valid status codes are 200, 301, 302 (default), 303, 307, or 308. Got ${str_status}.`
|
|
6071
|
+
});
|
|
6072
|
+
continue;
|
|
6073
|
+
}
|
|
6074
|
+
if (/\/\*?$/.test(from) && /\/index(.html)?$/.test(to) && !urlHasHost(to)) {
|
|
6075
|
+
invalid.push({
|
|
6076
|
+
line,
|
|
6077
|
+
lineNumber: i + 1,
|
|
6078
|
+
message: "Infinite loop detected in this rule and has been ignored. This will cause a redirect to strip `.html` or `/index` and end up triggering this rule again. Please fix or remove this rule to silence this warning."
|
|
6079
|
+
});
|
|
6080
|
+
continue;
|
|
6081
|
+
}
|
|
6082
|
+
if (seen_paths.has(from)) {
|
|
6083
|
+
invalid.push({
|
|
6084
|
+
line,
|
|
6085
|
+
lineNumber: i + 1,
|
|
6086
|
+
message: `Ignoring duplicate rule for path ${from}.`
|
|
6087
|
+
});
|
|
6088
|
+
continue;
|
|
6089
|
+
}
|
|
6090
|
+
seen_paths.add(from);
|
|
6091
|
+
if (status === 200) {
|
|
6092
|
+
if (urlHasHost(to)) {
|
|
6093
|
+
invalid.push({
|
|
6094
|
+
line,
|
|
6095
|
+
lineNumber: i + 1,
|
|
6096
|
+
message: `Proxy (200) redirects can only point to relative paths. Got ${to}`
|
|
6097
|
+
});
|
|
6098
|
+
continue;
|
|
6099
|
+
}
|
|
6100
|
+
}
|
|
6101
|
+
rules.push({ from, to, status, lineNumber: i + 1 });
|
|
6102
|
+
}
|
|
6103
|
+
return {
|
|
6104
|
+
rules,
|
|
6105
|
+
invalid
|
|
6106
|
+
};
|
|
6107
|
+
}
|
|
6108
|
+
|
|
6109
|
+
// src/miniflare-cli/assets.ts
|
|
6110
|
+
var import_mime = __toESM(require_mime());
|
|
6111
|
+
import { watch } from "chokidar";
|
|
6112
|
+
|
|
6113
|
+
// src/pages/hash.ts
|
|
6114
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
6115
|
+
import { extname as extname2 } from "node:path";
|
|
6116
|
+
import { hash as blake3hash } from "blake3-wasm";
|
|
6117
|
+
var hashFile = (filepath) => {
|
|
6118
|
+
const contents = readFileSync4(filepath);
|
|
6119
|
+
const base64Contents = contents.toString("base64");
|
|
6120
|
+
const extension = extname2(filepath).substring(1);
|
|
6121
|
+
return blake3hash(base64Contents + extension).toString("hex").slice(0, 32);
|
|
4824
6122
|
};
|
|
4825
|
-
|
|
4826
|
-
|
|
6123
|
+
|
|
6124
|
+
// src/miniflare-cli/assets.ts
|
|
6125
|
+
async function generateASSETSBinding(options) {
|
|
6126
|
+
const assetsFetch = options.directory !== void 0 ? await generateAssetsFetch(options.directory, options.log, options.tre) : invalidAssetsFetch;
|
|
6127
|
+
const miniflare = options.tre ? await import("@miniflare/tre") : await import("@miniflare/core");
|
|
6128
|
+
const Request = miniflare.Request;
|
|
6129
|
+
const Response2 = miniflare.Response;
|
|
6130
|
+
const fetch = options.tre ? miniflare.fetch : (await import("@miniflare/web-sockets")).upgradingFetch;
|
|
6131
|
+
return async function(miniflareRequest) {
|
|
6132
|
+
if (options.proxyPort) {
|
|
6133
|
+
try {
|
|
6134
|
+
const url = new URL(miniflareRequest.url);
|
|
6135
|
+
url.host = `localhost:${options.proxyPort}`;
|
|
6136
|
+
const proxyRequest = new Request(url, miniflareRequest);
|
|
6137
|
+
if (proxyRequest.headers.get("Upgrade") === "websocket") {
|
|
6138
|
+
proxyRequest.headers.delete("Sec-WebSocket-Accept");
|
|
6139
|
+
proxyRequest.headers.delete("Sec-WebSocket-Key");
|
|
6140
|
+
}
|
|
6141
|
+
return await fetch(proxyRequest);
|
|
6142
|
+
} catch (thrown) {
|
|
6143
|
+
options.log.error(new Error(`Could not proxy request: ${thrown}`));
|
|
6144
|
+
return new Response2(`[wrangler] Could not proxy request: ${thrown}`, {
|
|
6145
|
+
status: 502
|
|
6146
|
+
});
|
|
6147
|
+
}
|
|
6148
|
+
} else {
|
|
6149
|
+
try {
|
|
6150
|
+
return await assetsFetch(miniflareRequest);
|
|
6151
|
+
} catch (thrown) {
|
|
6152
|
+
options.log.error(new Error(`Could not serve static asset: ${thrown}`));
|
|
6153
|
+
return new Response2(
|
|
6154
|
+
`[wrangler] Could not serve static asset: ${thrown}`,
|
|
6155
|
+
{ status: 502 }
|
|
6156
|
+
);
|
|
6157
|
+
}
|
|
6158
|
+
}
|
|
6159
|
+
};
|
|
6160
|
+
}
|
|
6161
|
+
async function generateAssetsFetch(directory, log, tre) {
|
|
6162
|
+
const polyfill2 = tre ? (await Promise.resolve().then(() => (init_miniflare_tre(), miniflare_tre_exports))).default : (await Promise.resolve().then(() => (init_miniflare(), miniflare_exports))).default;
|
|
6163
|
+
await polyfill2();
|
|
6164
|
+
const miniflare = tre ? await import("@miniflare/tre") : await import("@miniflare/core");
|
|
6165
|
+
const Request = miniflare.Request;
|
|
6166
|
+
const { generateHandler: generateHandler2, parseQualityWeightedList: parseQualityWeightedList2 } = await Promise.resolve().then(() => (init_handler(), handler_exports));
|
|
6167
|
+
const headersFile = join(directory, "_headers");
|
|
6168
|
+
const redirectsFile = join(directory, "_redirects");
|
|
6169
|
+
const workerFile = join(directory, "_worker.js");
|
|
6170
|
+
const ignoredFiles = [headersFile, redirectsFile, workerFile];
|
|
6171
|
+
let redirects;
|
|
6172
|
+
if (existsSync(redirectsFile)) {
|
|
6173
|
+
const contents = readFileSync5(redirectsFile, "utf-8");
|
|
6174
|
+
redirects = parseRedirects(contents);
|
|
6175
|
+
}
|
|
6176
|
+
let headers;
|
|
6177
|
+
if (existsSync(headersFile)) {
|
|
6178
|
+
const contents = readFileSync5(headersFile, "utf-8");
|
|
6179
|
+
headers = parseHeaders(contents);
|
|
6180
|
+
}
|
|
6181
|
+
let metadata = createMetadataObject({
|
|
6182
|
+
redirects,
|
|
6183
|
+
headers,
|
|
6184
|
+
logger: log.warn.bind(log)
|
|
6185
|
+
});
|
|
6186
|
+
watch([headersFile, redirectsFile], { persistent: true }).on(
|
|
6187
|
+
"change",
|
|
6188
|
+
(path) => {
|
|
6189
|
+
switch (path) {
|
|
6190
|
+
case headersFile: {
|
|
6191
|
+
log.log("_headers modified. Re-evaluating...");
|
|
6192
|
+
const contents = readFileSync5(headersFile).toString();
|
|
6193
|
+
headers = parseHeaders(contents);
|
|
6194
|
+
break;
|
|
6195
|
+
}
|
|
6196
|
+
case redirectsFile: {
|
|
6197
|
+
log.log("_redirects modified. Re-evaluating...");
|
|
6198
|
+
const contents = readFileSync5(redirectsFile).toString();
|
|
6199
|
+
redirects = parseRedirects(contents);
|
|
6200
|
+
break;
|
|
6201
|
+
}
|
|
6202
|
+
}
|
|
6203
|
+
metadata = createMetadataObject({
|
|
6204
|
+
redirects,
|
|
6205
|
+
headers,
|
|
6206
|
+
logger: log.warn
|
|
6207
|
+
});
|
|
6208
|
+
}
|
|
6209
|
+
);
|
|
6210
|
+
const generateResponse = async (request) => {
|
|
6211
|
+
const assetKeyEntryMap = /* @__PURE__ */ new Map();
|
|
6212
|
+
return await generateHandler2({
|
|
6213
|
+
request,
|
|
6214
|
+
metadata,
|
|
6215
|
+
xServerEnvHeader: "dev",
|
|
6216
|
+
logError: console.error,
|
|
6217
|
+
findAssetEntryForPath: async (path) => {
|
|
6218
|
+
const filepath = join(directory, path);
|
|
6219
|
+
if (existsSync(filepath) && lstatSync(filepath).isFile() && !ignoredFiles.includes(filepath)) {
|
|
6220
|
+
const hash = hashFile(filepath);
|
|
6221
|
+
assetKeyEntryMap.set(hash, filepath);
|
|
6222
|
+
return hash;
|
|
6223
|
+
}
|
|
6224
|
+
return null;
|
|
6225
|
+
},
|
|
6226
|
+
getAssetKey: (assetEntry) => {
|
|
6227
|
+
return assetEntry;
|
|
6228
|
+
},
|
|
6229
|
+
negotiateContent: (contentRequest) => {
|
|
6230
|
+
let rawAcceptEncoding;
|
|
6231
|
+
if (contentRequest.cf && "clientAcceptEncoding" in contentRequest.cf && contentRequest.cf.clientAcceptEncoding) {
|
|
6232
|
+
rawAcceptEncoding = contentRequest.cf.clientAcceptEncoding;
|
|
6233
|
+
} else {
|
|
6234
|
+
rawAcceptEncoding = contentRequest.headers.get("Accept-Encoding") || void 0;
|
|
6235
|
+
}
|
|
6236
|
+
const acceptEncoding = parseQualityWeightedList2(rawAcceptEncoding);
|
|
6237
|
+
if (acceptEncoding["identity"] === 0 || acceptEncoding["*"] === 0 && acceptEncoding["identity"] === void 0) {
|
|
6238
|
+
throw new Error("No acceptable encodings available");
|
|
6239
|
+
}
|
|
6240
|
+
return { encoding: null };
|
|
6241
|
+
},
|
|
6242
|
+
fetchAsset: async (assetKey) => {
|
|
6243
|
+
const filepath = assetKeyEntryMap.get(assetKey);
|
|
6244
|
+
if (!filepath) {
|
|
6245
|
+
throw new Error(
|
|
6246
|
+
"Could not fetch asset. Please file an issue on GitHub (https://github.com/cloudflare/workers-sdk/issues/new/choose) with reproduction steps."
|
|
6247
|
+
);
|
|
6248
|
+
}
|
|
6249
|
+
const body = readFileSync5(filepath);
|
|
6250
|
+
let contentType = (0, import_mime.getType)(filepath) || "application/octet-stream";
|
|
6251
|
+
if (contentType.startsWith("text/") && !contentType.includes("charset")) {
|
|
6252
|
+
contentType = `${contentType}; charset=utf-8`;
|
|
6253
|
+
}
|
|
6254
|
+
return { body, contentType };
|
|
6255
|
+
}
|
|
6256
|
+
});
|
|
6257
|
+
};
|
|
6258
|
+
return async (input, init) => {
|
|
6259
|
+
const request = new Request(input, init);
|
|
6260
|
+
return await generateResponse(request);
|
|
6261
|
+
};
|
|
6262
|
+
}
|
|
6263
|
+
var invalidAssetsFetch = () => {
|
|
6264
|
+
throw new Error(
|
|
6265
|
+
"Trying to fetch assets directly when there is no `directory` option specified."
|
|
6266
|
+
);
|
|
4827
6267
|
};
|
|
4828
6268
|
|
|
4829
6269
|
// src/miniflare-cli/request-context.ts
|
|
@@ -4846,41 +6286,157 @@ var getRequestContextCheckOptions = async () => {
|
|
|
4846
6286
|
};
|
|
4847
6287
|
|
|
4848
6288
|
// src/miniflare-cli/index.ts
|
|
6289
|
+
var MiniflareNoOpLog = class extends MiniflareLog {
|
|
6290
|
+
log() {
|
|
6291
|
+
}
|
|
6292
|
+
error(message) {
|
|
6293
|
+
throw message;
|
|
6294
|
+
}
|
|
6295
|
+
};
|
|
4849
6296
|
async function main() {
|
|
4850
|
-
const args = await yargs_default(hideBin(process.argv)).help(false).version(false).
|
|
4851
|
-
choices: enumKeys(LogLevel)
|
|
4852
|
-
}).argv;
|
|
4853
|
-
const logLevel = LogLevel[args.log ?? "INFO"];
|
|
6297
|
+
const args = await yargs_default(hideBin(process.argv)).help(false).version(false).argv;
|
|
4854
6298
|
const requestContextCheckOptions = await getRequestContextCheckOptions();
|
|
4855
6299
|
const config = {
|
|
4856
6300
|
...JSON.parse(args._[0] ?? "{}"),
|
|
4857
|
-
...requestContextCheckOptions
|
|
4858
|
-
log: new Log(logLevel)
|
|
6301
|
+
...requestContextCheckOptions
|
|
4859
6302
|
};
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
const
|
|
6303
|
+
let logLevelString = config.logLevel.toUpperCase();
|
|
6304
|
+
if (logLevelString === "LOG")
|
|
6305
|
+
logLevelString = "INFO";
|
|
6306
|
+
const logLevel = MiniflareLogLevel[logLevelString];
|
|
6307
|
+
config.log = logLevel === MiniflareLogLevel.NONE ? new MiniflareNoOpLog() : new MiniflareLog(logLevel);
|
|
6308
|
+
if (logLevel === MiniflareLogLevel.DEBUG) {
|
|
6309
|
+
console.log("MINIFLARE OPTIONS:\n", JSON.stringify(config, null, 2));
|
|
6310
|
+
}
|
|
6311
|
+
config.bindings = {
|
|
6312
|
+
...config.bindings,
|
|
6313
|
+
...config.externalDurableObjects && Object.fromEntries(
|
|
6314
|
+
Object.entries(
|
|
6315
|
+
config.externalDurableObjects
|
|
6316
|
+
).map(([binding, { name, host, port }]) => {
|
|
6317
|
+
const factory = () => {
|
|
6318
|
+
throw new FatalError(
|
|
6319
|
+
"An external Durable Object instance's state has somehow been attempted to be accessed.",
|
|
6320
|
+
1
|
|
6321
|
+
);
|
|
6322
|
+
};
|
|
6323
|
+
const namespace = new DurableObjectNamespace(name, factory);
|
|
6324
|
+
namespace.get = (id) => {
|
|
6325
|
+
const stub = new DurableObjectStub(factory, id);
|
|
6326
|
+
stub.fetch = (...reqArgs) => {
|
|
6327
|
+
const requestFromArgs = new MiniflareRequest(...reqArgs);
|
|
6328
|
+
const url = new URL(requestFromArgs.url);
|
|
6329
|
+
url.host = host;
|
|
6330
|
+
if (port !== void 0)
|
|
6331
|
+
url.port = port.toString();
|
|
6332
|
+
const request = new MiniflareRequest(
|
|
6333
|
+
url.toString(),
|
|
6334
|
+
requestFromArgs
|
|
6335
|
+
);
|
|
6336
|
+
request.headers.set("x-miniflare-durable-object-name", name);
|
|
6337
|
+
request.headers.set(
|
|
6338
|
+
"x-miniflare-durable-object-id",
|
|
6339
|
+
id.toString()
|
|
6340
|
+
);
|
|
6341
|
+
return upgradingFetch(request);
|
|
6342
|
+
};
|
|
6343
|
+
return stub;
|
|
6344
|
+
};
|
|
6345
|
+
return [binding, namespace];
|
|
6346
|
+
})
|
|
6347
|
+
)
|
|
6348
|
+
};
|
|
6349
|
+
let mf;
|
|
6350
|
+
let durableObjectsMf = void 0;
|
|
6351
|
+
let durableObjectsMfPort = void 0;
|
|
4864
6352
|
try {
|
|
4865
|
-
|
|
6353
|
+
if (args._[1]) {
|
|
6354
|
+
const opts = JSON.parse(
|
|
6355
|
+
args._[1]
|
|
6356
|
+
);
|
|
6357
|
+
if (isNaN(opts.proxyPort || NaN) && !opts.directory) {
|
|
6358
|
+
throw new Error(
|
|
6359
|
+
"MiniflareCLIOptions: built in service bindings set to true, but no port or directory provided"
|
|
6360
|
+
);
|
|
6361
|
+
}
|
|
6362
|
+
const options = {
|
|
6363
|
+
log: config.log,
|
|
6364
|
+
proxyPort: opts.proxyPort,
|
|
6365
|
+
directory: opts.directory,
|
|
6366
|
+
tre: false
|
|
6367
|
+
};
|
|
6368
|
+
config.serviceBindings = {
|
|
6369
|
+
...config.serviceBindings,
|
|
6370
|
+
ASSETS: await generateASSETSBinding(options)
|
|
6371
|
+
};
|
|
6372
|
+
}
|
|
6373
|
+
mf = new Miniflare(config);
|
|
6374
|
+
const mfServer = await mf.startServer();
|
|
6375
|
+
const mfPort = mfServer.address().port;
|
|
4866
6376
|
await mf.startScheduler();
|
|
6377
|
+
const internalDurableObjectClassNames = Object.values(
|
|
6378
|
+
config.durableObjects
|
|
6379
|
+
);
|
|
6380
|
+
if (internalDurableObjectClassNames.length > 0) {
|
|
6381
|
+
durableObjectsMf = new Miniflare({
|
|
6382
|
+
host: config.host,
|
|
6383
|
+
port: 0,
|
|
6384
|
+
script: `
|
|
6385
|
+
export default {
|
|
6386
|
+
fetch(request, env) {
|
|
6387
|
+
return env.DO.fetch(request)
|
|
6388
|
+
}
|
|
6389
|
+
}`,
|
|
6390
|
+
serviceBindings: {
|
|
6391
|
+
DO: async (request) => {
|
|
6392
|
+
request = new MiniflareRequest(request);
|
|
6393
|
+
const name = request.headers.get("x-miniflare-durable-object-name");
|
|
6394
|
+
const idString = request.headers.get(
|
|
6395
|
+
"x-miniflare-durable-object-id"
|
|
6396
|
+
);
|
|
6397
|
+
request.headers.delete("x-miniflare-durable-object-name");
|
|
6398
|
+
request.headers.delete("x-miniflare-durable-object-id");
|
|
6399
|
+
if (!name || !idString) {
|
|
6400
|
+
return new MiniflareResponse(
|
|
6401
|
+
"[durable-object-proxy-err] Missing `x-miniflare-durable-object-name` or `x-miniflare-durable-object-id` headers.",
|
|
6402
|
+
{ status: 400 }
|
|
6403
|
+
);
|
|
6404
|
+
}
|
|
6405
|
+
const namespace = await mf?.getDurableObjectNamespace(name);
|
|
6406
|
+
const id = namespace?.idFromString(idString);
|
|
6407
|
+
if (!id) {
|
|
6408
|
+
return new MiniflareResponse(
|
|
6409
|
+
"[durable-object-proxy-err] Could not generate an ID. Possibly due to a mismatched DO name and ID?",
|
|
6410
|
+
{ status: 500 }
|
|
6411
|
+
);
|
|
6412
|
+
}
|
|
6413
|
+
const stub = namespace?.get(id);
|
|
6414
|
+
if (!stub) {
|
|
6415
|
+
return new MiniflareResponse(
|
|
6416
|
+
"[durable-object-proxy-err] Could not generate a stub. Possibly due to a mismatched DO name and ID?",
|
|
6417
|
+
{ status: 500 }
|
|
6418
|
+
);
|
|
6419
|
+
}
|
|
6420
|
+
return stub.fetch(request);
|
|
6421
|
+
}
|
|
6422
|
+
},
|
|
6423
|
+
modules: true
|
|
6424
|
+
});
|
|
6425
|
+
const server = await durableObjectsMf.startServer();
|
|
6426
|
+
durableObjectsMfPort = server.address().port;
|
|
6427
|
+
}
|
|
6428
|
+
process.send && process.send(
|
|
6429
|
+
JSON.stringify({
|
|
6430
|
+
port: mfPort,
|
|
6431
|
+
ready: true,
|
|
6432
|
+
durableObjectsPort: durableObjectsMfPort
|
|
6433
|
+
})
|
|
6434
|
+
);
|
|
4867
6435
|
} catch (e) {
|
|
4868
|
-
mf
|
|
6436
|
+
mf?.log.error(e);
|
|
4869
6437
|
process.exitCode = 1;
|
|
4870
|
-
await mf
|
|
6438
|
+
await mf?.dispose();
|
|
6439
|
+
await durableObjectsMf?.dispose();
|
|
4871
6440
|
}
|
|
4872
6441
|
}
|
|
4873
6442
|
await main();
|
|
4874
|
-
/**
|
|
4875
|
-
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
|
4876
|
-
* CJS and ESM environments.
|
|
4877
|
-
*
|
|
4878
|
-
* @license
|
|
4879
|
-
* Copyright (c) 2016, Contributors
|
|
4880
|
-
* SPDX-License-Identifier: ISC
|
|
4881
|
-
*/
|
|
4882
|
-
/**
|
|
4883
|
-
* @license
|
|
4884
|
-
* Copyright (c) 2016, Contributors
|
|
4885
|
-
* SPDX-License-Identifier: ISC
|
|
4886
|
-
*/
|