From 57a237ee268d53377281a9a0efa2f0b9cfd0e4d7 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 12:54:54 -0500 Subject: [PATCH 01/30] start work on #166 --- .../app-utils/src/renderer/render/index.ts | 2 +- .../app-utils/src/renderer/render/page.ts | 2 +- packages/app-utils/src/types/index.ts | 2 +- packages/kit/package.json | 7 ++- packages/kit/src/api/build/Builder.ts | 60 ++++++++++++++++++ packages/kit/src/api/build/index.ts | 22 ++++--- .../basic/.svelte/build/optimized/client.json | 1 + .../.svelte/build/optimized/client/root.js | 0 .../build/optimized/client/routes/index.js | 0 .../.svelte/build/optimized/client/setup.js | 0 .../test/fixtures/basic/static/answer.md | 1 + packages/kit/src/api/build/test/index.ts | 63 +++++++++++++++++++ .../kit/src/api/build/test/output/client.json | 1 + .../src/api/build/test/output/client/root.js | 0 .../build/test/output/client/routes/index.js | 0 .../src/api/build/test/output/client/setup.js | 0 packages/kit/src/core/create_manifest_data.ts | 2 - packages/kit/src/runtime/stores/index.ts | 6 +- packages/kit/tsconfig.json | 10 ++- pnpm-lock.yaml | 47 +++++++++++++- 20 files changed, 206 insertions(+), 20 deletions(-) create mode 100644 packages/kit/src/api/build/Builder.ts create mode 100644 packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client.json create mode 100644 packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/root.js create mode 100644 packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/routes/index.js create mode 100644 packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/setup.js create mode 100644 packages/kit/src/api/build/test/fixtures/basic/static/answer.md create mode 100644 packages/kit/src/api/build/test/index.ts create mode 100644 packages/kit/src/api/build/test/output/client.json create mode 100644 packages/kit/src/api/build/test/output/client/root.js create mode 100644 packages/kit/src/api/build/test/output/client/routes/index.js create mode 100644 packages/kit/src/api/build/test/output/client/setup.js diff --git a/packages/app-utils/src/renderer/render/index.ts b/packages/app-utils/src/renderer/render/index.ts index 7187597e77f7..240ceb48385b 100644 --- a/packages/app-utils/src/renderer/render/index.ts +++ b/packages/app-utils/src/renderer/render/index.ts @@ -11,7 +11,7 @@ export async function render( request: IncomingRequest, options: RenderOptions ): Promise { - const { context, headers = {} } = (await options.setup.prepare?.(request.headers)) || {}; + const { context, headers = {} } = (await (options.setup.prepare && options.setup.prepare(request.headers))) || {}; try { const response = await (render_endpoint(request, context, options) || diff --git a/packages/app-utils/src/renderer/render/page.ts b/packages/app-utils/src/renderer/render/page.ts index b59d5afd3e1d..c24f31b50755 100644 --- a/packages/app-utils/src/renderer/render/page.ts +++ b/packages/app-utils/src/renderer/render/page.ts @@ -49,7 +49,7 @@ export default async function render_page( const baseUrl = ''; // TODO - const session = await options.setup.getSession?.(context); + const session = await (options.setup.getSession && options.setup.getSession(context)); const serialized_session = try_serialize(session, (err: Error) => { throw new Error(`Failed to serialize session data: ${err.message}`); diff --git a/packages/app-utils/src/types/index.ts b/packages/app-utils/src/types/index.ts index c3619d15b3a6..23e3c1576753 100644 --- a/packages/app-utils/src/types/index.ts +++ b/packages/app-utils/src/types/index.ts @@ -63,9 +63,9 @@ export type RouteParams = Record; export interface PageComponentManifest { default?: boolean; type?: string; + file?: string; url: string; name: string; - file: string; } export interface PageManifestPart { diff --git a/packages/kit/package.json b/packages/kit/package.json index 74bacb514d23..ade0fd742e97 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -15,6 +15,7 @@ }, "devDependencies": { "@types/node": "^14.11.10", + "@types/rimraf": "^3.0.0", "@types/sade": "^1.7.2", "estree-walker": "^2.0.1", "kleur": "^4.1.3", @@ -24,9 +25,12 @@ "periscopic": "^2.0.2", "port-authority": "^1.1.1", "require-relative": "^0.8.7", + "rimraf": "^3.0.2", "sirv": "^1.0.7", "source-map-support": "^0.5.19", "svelte": "^3.29.0", + "tiny-glob": "^0.2.8", + "ts-node": "^9.0.0", "typescript": "^4.0.5" }, "bin": { @@ -43,6 +47,7 @@ "lint": "eslint --ignore-pattern node_modules/ --ignore-pattern dist/ \"**/*.{ts,mjs,js,svelte}\" && npm run check-format", "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore", "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", - "prepublishOnly": "npm run build" + "prepublishOnly": "npm run build", + "test": "uvu -r ts-node/register" } } diff --git a/packages/kit/src/api/build/Builder.ts b/packages/kit/src/api/build/Builder.ts new file mode 100644 index 000000000000..653bb16d3e50 --- /dev/null +++ b/packages/kit/src/api/build/Builder.ts @@ -0,0 +1,60 @@ +import { copy } from '@sveltejs/app-utils/files'; +import { prerender } from '@sveltejs/app-utils/renderer'; +import { Logger } from '@sveltejs/app-utils/renderer/prerender'; // TODO this is in the wrong place +import { ManifestData } from '../../interfaces'; + +export type BuilderOptions = { + generated_files: string; + static_files: string; + log: Logger, + manifest: ManifestData; +}; + +export default class Builder { + log: Logger; + + #generated_files: string; + #static_files: string; + #manifest: ManifestData; + + constructor({ + generated_files, + static_files, + log, + manifest + }: BuilderOptions) { + this.#generated_files = generated_files; + this.#static_files = static_files; + this.#manifest = manifest; + + this.log = log; + } + + copy_generated_files(dest: string) { + copy(this.#generated_files, dest); + } + + copy_static_files(dest: string) { + copy(this.#static_files, dest); + } + + prerender({ + force = false, + dest + }: { + force: boolean; + dest: string; + }) { + prerender({ + out: dest, + force, + dir: this.#generated_files, + manifest: this.#manifest, + log: this.log + }); + } + + foo() { + console.log(this.#manifest); + } +} diff --git a/packages/kit/src/api/build/index.ts b/packages/kit/src/api/build/index.ts index 7ee87db634d6..694c89514d31 100644 --- a/packages/kit/src/api/build/index.ts +++ b/packages/kit/src/api/build/index.ts @@ -13,12 +13,13 @@ import { copy_assets } from '../utils'; import { create_app } from '../../core/create_app'; import { SvelteAppConfig } from '../../interfaces'; import { css_injection } from './css_injection'; +import Builder from './Builder'; const exec = promisify(child_process.exec); const snowpack_main = require.resolve('snowpack'); const snowpack_pkg_file = path.join(snowpack_main, '../../package.json'); -const snowpack_pkg = require(snowpack_pkg_file); +const snowpack_pkg = require(snowpack_pkg_file); // eslint-disable-line const snowpack_bin = path.resolve(path.dirname(snowpack_pkg_file), snowpack_pkg.bin.snowpack); const ignorable_warnings = new Set(['EMPTY_BUNDLE', 'CIRCULAR_DEPENDENCY', 'MISSING_EXPORT']); @@ -30,6 +31,9 @@ const onwarn = (warning, handler) => { handler(warning); }; +// TODO adapters need access to Adapter/Builder types +type Adapter = (builder: Builder) => void | Promise; + export async function build(config: SvelteAppConfig) { if (!config.adapter) { throw new Error('No adapter specified'); @@ -52,7 +56,7 @@ export async function build(config: SvelteAppConfig) { log.minor = (msg) => log(colors.grey(msg)); log.info = log; - const unoptimized = `.svelte/build/unoptimized`; + const unoptimized = '.svelte/build/unoptimized'; { // phase one — build with Snowpack @@ -136,7 +140,7 @@ export async function build(config: SvelteAppConfig) { sourcemap: true }); - log.success(`server`); + log.success('server'); const entry = path.resolve(`${unoptimized}/client/_app/main/runtime/navigation.js`); @@ -267,20 +271,22 @@ export async function build(config: SvelteAppConfig) { sourcemap: true }); - log.success(`client`); + log.success('client'); } { // phase three — adapter header(`Generating app (${config.adapter})...`); - await rimraf('build'); // TODO customize - const adapter = relative(config.adapter); - await adapter({ - dir: '.svelte/build/optimized', + const builder = new Builder({ + generated_files: '.svelte/build/optimized', + static_files: 'static', manifest, log }); + + const adapter: Adapter = relative(config.adapter); + await adapter(builder); } log.success('done'); diff --git a/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client.json b/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client.json new file mode 100644 index 000000000000..9e26dfeeb6e6 --- /dev/null +++ b/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/root.js b/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/root.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/routes/index.js b/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/routes/index.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/setup.js b/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/setup.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/kit/src/api/build/test/fixtures/basic/static/answer.md b/packages/kit/src/api/build/test/fixtures/basic/static/answer.md new file mode 100644 index 000000000000..f70d7bba4ae1 --- /dev/null +++ b/packages/kit/src/api/build/test/fixtures/basic/static/answer.md @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/packages/kit/src/api/build/test/index.ts b/packages/kit/src/api/build/test/index.ts new file mode 100644 index 000000000000..9dbfea19566c --- /dev/null +++ b/packages/kit/src/api/build/test/index.ts @@ -0,0 +1,63 @@ +// import { mkdtempSync, writeFileSync, readdirSync, mkdirSync } from 'fs'; +// import { tmpdir } from 'os'; +import { join } from 'path'; +import * as uvu from 'uvu'; +import * as assert from 'uvu/assert'; +import rimraf from 'rimraf'; +import glob from 'tiny-glob/sync'; +import Builder from '../Builder'; + +const suite = uvu.suite('Builder'); + +suite('builder ', () => { + assert.ok(Builder); +}); + +suite('copy_static_files', () => { + const generated_files = join(__dirname, 'fixtures/basic/.svelte/build/optimized'); + const static_files = join(__dirname, 'fixtures/basic/static'); + + const builder = new Builder({ + generated_files, + static_files, + manifest: { + error: { + name: '$default_error', + url: '/_app/main/components/error.svelte' + }, + layout: { + name: '$default_layout', + url: '/_app/main/components/layout.svelte' + }, + components: [], + pages: [], + endpoints: [] + }, + log: Object.assign((_msg: string) => {}, { + info: (_msg: string) => {}, + warn: (_msg: string) => {}, + error: (_msg: string) => {}, + success: (_msg: string) => {} + }) + }); + + const dest = join(__dirname, 'output'); + + rimraf.sync(dest); + builder.copy_static_files(dest); + + assert.equal( + glob('**', { cwd: static_files }), + glob('**', { cwd: dest }) + ); + + rimraf.sync(dest); + builder.copy_generated_files(dest); + + assert.equal( + glob('**', { cwd: generated_files }), + glob('**', { cwd: dest }) + ); +}); + +suite.run(); diff --git a/packages/kit/src/api/build/test/output/client.json b/packages/kit/src/api/build/test/output/client.json new file mode 100644 index 000000000000..9e26dfeeb6e6 --- /dev/null +++ b/packages/kit/src/api/build/test/output/client.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/kit/src/api/build/test/output/client/root.js b/packages/kit/src/api/build/test/output/client/root.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/kit/src/api/build/test/output/client/routes/index.js b/packages/kit/src/api/build/test/output/client/routes/index.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/kit/src/api/build/test/output/client/setup.js b/packages/kit/src/api/build/test/output/client/setup.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/kit/src/core/create_manifest_data.ts b/packages/kit/src/core/create_manifest_data.ts index 18ae78a25b27..f4e4a94be471 100644 --- a/packages/kit/src/core/create_manifest_data.ts +++ b/packages/kit/src/core/create_manifest_data.ts @@ -32,13 +32,11 @@ export default function create_manifest_data( const default_layout: PageComponentManifest = { name: '$default_layout', - file: null, url: '/_app/main/components/layout.svelte' }; const default_error: PageComponentManifest = { name: '$default_error', - file: null, url: '/_app/main/components/error.svelte' }; diff --git a/packages/kit/src/runtime/stores/index.ts b/packages/kit/src/runtime/stores/index.ts index 5b5cf8f49d84..90bb429e44f2 100644 --- a/packages/kit/src/runtime/stores/index.ts +++ b/packages/kit/src/runtime/stores/index.ts @@ -29,7 +29,7 @@ export const preloading = { } }; -const error = (verb) => { +const error = (verb: string) => { throw new Error( ssr ? `Can only ${verb} session store in browser` @@ -48,10 +48,10 @@ export const session = { return store.subscribe(fn); }, - set: (updater: Updater) => { + set: (_value: any) => { error('set'); }, - update: (updater: Updater) => { + update: (_updater: Updater) => { error('update'); } }; diff --git a/packages/kit/tsconfig.json b/packages/kit/tsconfig.json index 2a454d44b896..891da25ebbd0 100644 --- a/packages/kit/tsconfig.json +++ b/packages/kit/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { "resolveJsonModule": true, "module": "esnext", @@ -10,5 +11,10 @@ }, "include": ["src/**/*"], "lib": ["ES2020", "dom", "node"], - "strict": true -} + "strict": true, + "ts-node": { + "compilerOptions": { + "module": "commonjs" + } + } +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0010bcb87aa..bf6cc285cdf7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -167,6 +167,7 @@ importers: snowpack: 2.17.0 devDependencies: '@types/node': 14.11.10 + '@types/rimraf': 3.0.0 '@types/sade': 1.7.2 estree-walker: 2.0.1 kleur: 4.1.3 @@ -176,13 +177,17 @@ importers: periscopic: 2.0.2 port-authority: 1.1.1 require-relative: 0.8.7 + rimraf: 3.0.2 sirv: 1.0.7 source-map-support: 0.5.19 svelte: 3.29.0 + tiny-glob: 0.2.8 + ts-node: 9.0.0_typescript@4.0.5 typescript: 4.0.5 specifiers: '@sveltejs/app-utils': 'workspace:*' '@types/node': ^14.11.10 + '@types/rimraf': ^3.0.0 '@types/sade': ^1.7.2 cheap-watch: ^1.0.2 estree-walker: ^2.0.1 @@ -194,6 +199,7 @@ importers: periscopic: ^2.0.2 port-authority: ^1.1.1 require-relative: ^0.8.7 + rimraf: ^3.0.2 rollup: ^2.32.0 rollup-dependency-tree: 0.0.14 rollup-plugin-css-chunks: ^1.2.8 @@ -204,6 +210,8 @@ importers: snowpack: ^2.17.0 source-map-support: ^0.5.19 svelte: ^3.29.0 + tiny-glob: ^0.2.8 + ts-node: ^9.0.0 typescript: ^4.0.5 packages/snowpack-config: dependencies: @@ -655,6 +663,13 @@ packages: /@types/estree/0.0.45: resolution: integrity: sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g== + /@types/glob/7.1.3: + dependencies: + '@types/minimatch': 3.0.3 + '@types/node': 14.14.9 + dev: true + resolution: + integrity: sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w== /@types/json-schema/7.0.6: dev: true resolution: @@ -667,6 +682,10 @@ packages: dev: true resolution: integrity: sha512-Jus9s4CDbqwocc5pOAnh8ShfrnMcPHuJYzVcSUU7lrh8Ni5HuIqX3oilL86p3dlTrk0LzHRCgA/GQ7uNCw6l2Q== + /@types/minimatch/3.0.3: + dev: true + resolution: + integrity: sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== /@types/minimist/1.2.0: dev: true resolution: @@ -696,6 +715,10 @@ packages: /@types/node/14.14.5: resolution: integrity: sha512-H5Wn24s/ZOukBmDn03nnGTp18A60ny9AmCwnEcgJiTgSGsCO7k+NWP7zjCCbhlcnVCoI+co52dUAt9GMhOSULw== + /@types/node/14.14.9: + dev: true + resolution: + integrity: sha512-JsoLXFppG62tWTklIoO4knA+oDTYsmqWxHRvd4lpmfQRNhX6osheUOWETP2jMoV/2bEHuMra8Pp3Dmo/stBFcw== /@types/normalize-package-data/2.4.0: dev: true resolution: @@ -709,6 +732,13 @@ packages: '@types/node': 14.14.5 resolution: integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw== + /@types/rimraf/3.0.0: + dependencies: + '@types/glob': 7.1.3 + '@types/node': 14.14.9 + dev: true + resolution: + integrity: sha512-7WhJ0MdpFgYQPXlF4Dx+DhgvlPCfz/x5mHaeDQAKhcenvQP1KCpLQ18JklAqeGMYSAT2PxLpzd0g2/HE7fj7hQ== /@types/sade/1.7.2: dependencies: '@types/mri': 1.1.0 @@ -3260,7 +3290,6 @@ packages: /rimraf/3.0.2: dependencies: glob: 7.1.6 - dev: false hasBin: true resolution: integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== @@ -3858,6 +3887,22 @@ packages: typescript: '>=2.7' resolution: integrity: sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg== + /ts-node/9.0.0_typescript@4.0.5: + dependencies: + arg: 4.1.3 + diff: 4.0.2 + make-error: 1.3.6 + source-map-support: 0.5.19 + typescript: 4.0.5 + yn: 3.1.1 + dev: true + engines: + node: '>=10.0.0' + hasBin: true + peerDependencies: + typescript: '>=2.7' + resolution: + integrity: sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg== /tsconfig-paths/3.9.0: dependencies: '@types/json5': 0.0.29 From 87e60e2c2f011f111615a9ed10dec7fdc35c5bae Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 13:37:46 -0500 Subject: [PATCH 02/30] remove typescript --- package.json | 7 +- packages/adapter-netlify/rollup.config.js | 9 +- packages/adapter-netlify/src/index.ts | 97 --------- packages/adapter-netlify/src/render.ts | 68 ------- packages/adapter-netlify/tsconfig.json | 3 - packages/adapter-node/rollup.config.js | 9 +- packages/adapter-node/src/index.ts | 58 ------ packages/adapter-node/src/server.ts | 77 ------- packages/adapter-node/tsconfig.json | 3 - packages/adapter-static/rollup.config.js | 5 +- packages/adapter-static/src/index.ts | 27 --- packages/adapter-static/tsconfig.json | 3 - packages/adapter-vercel/index.d.js | 7 + packages/adapter-vercel/rollup.config.js | 9 +- packages/adapter-vercel/server.d.js | 2 + packages/adapter-vercel/src/index.ts | 68 ------- packages/adapter-vercel/src/server.ts | 68 ------- packages/adapter-vercel/tsconfig.json | 3 - packages/app-utils/rollup.config.js | 8 +- .../src/files/{index.ts => index.js} | 10 +- .../files/{index.spec.ts => index.spec.js} | 4 +- .../src/http/get_body/{index.ts => index.js} | 28 +-- ...ly_form_data.ts => read_only_form_data.js} | 20 +- .../app-utils/src/http/{index.ts => index.js} | 0 packages/app-utils/src/{index.ts => index.js} | 0 .../src/renderer/{index.ts => index.js} | 0 .../renderer/manifest/{index.ts => index.js} | 10 +- ...{index.spec.data.ts => index.spec.data.js} | 10 +- .../manifest/{index.spec.ts => index.spec.js} | 0 .../renderer/prerender/{index.ts => index.js} | 54 ++--- .../render/{endpoint.ts => endpoint.js} | 28 +-- .../renderer/render/{index.ts => index.js} | 14 +- .../src/renderer/render/{page.ts => page.js} | 124 ++++++------ packages/app-utils/src/types/index.js | 121 +++++++++++ packages/app-utils/src/types/index.ts | 121 ----------- packages/app-utils/tsconfig.json | 8 - packages/create-svelte/cli/ambient.d.ts | 5 - .../create-svelte/cli/{index.ts => index.js} | 4 +- .../modifications/{add_css.ts => add_css.js} | 2 +- .../{add_typescript.ts => add_typescript.js} | 6 +- .../cli/modifications/{utils.ts => utils.js} | 20 +- packages/create-svelte/rollup.config.js | 4 +- packages/create-svelte/tsconfig.json | 11 - packages/kit/client/tsconfig.json | 14 -- packages/kit/index.d.ts | 0 packages/kit/package.json | 5 +- packages/kit/rollup.config.js | 54 +---- packages/kit/src/ambient.d.ts | 27 --- .../{css_injection.ts => css_injection.js} | 48 ++--- .../kit/src/api/build/{index.ts => index.js} | 34 ++-- .../kit/src/api/dev/{index.ts => index.js} | 48 ++--- .../kit/src/api/dev/{loader.ts => loader.js} | 30 +-- ..._stacktrace.ts => sourcemap_stacktrace.js} | 24 +-- packages/kit/src/api/dev/types.js | 46 +++++ packages/kit/src/api/dev/types.ts | 46 ----- packages/kit/src/api/{utils.ts => utils.js} | 0 packages/kit/src/{cli.ts => cli.js} | 10 +- .../src/core/{create_app.ts => create_app.js} | 40 ++-- ...nifest_data.ts => create_manifest_data.js} | 64 +++--- packages/kit/src/interfaces.js | 81 ++++++++ packages/kit/src/interfaces.ts | 81 -------- .../navigation/goto/{index.ts => index.js} | 6 +- .../runtime/navigation/{index.ts => index.js} | 0 .../navigation/{internal.ts => internal.js} | 50 ++--- .../prefetch/{index.ts => index.js} | 22 +- .../prefetchRoutes/{index.ts => index.js} | 2 +- .../navigation/start/{index.ts => index.js} | 50 ++--- .../runtime/navigation/start/page_store.js | 47 +++++ .../runtime/navigation/start/page_store.ts | 47 ----- packages/kit/src/runtime/navigation/types.js | 51 +++++ packages/kit/src/runtime/navigation/types.ts | 51 ----- .../runtime/navigation/{utils.ts => utils.js} | 2 +- .../src/runtime/stores/{index.ts => index.js} | 28 +-- packages/kit/src/{utils.ts => utils.js} | 18 +- packages/kit/tsconfig.json | 14 -- pnpm-lock.yaml | 189 +----------------- 76 files changed, 791 insertions(+), 1573 deletions(-) delete mode 100644 packages/adapter-netlify/src/index.ts delete mode 100644 packages/adapter-netlify/src/render.ts delete mode 100644 packages/adapter-netlify/tsconfig.json delete mode 100644 packages/adapter-node/src/index.ts delete mode 100644 packages/adapter-node/src/server.ts delete mode 100644 packages/adapter-node/tsconfig.json delete mode 100644 packages/adapter-static/src/index.ts delete mode 100644 packages/adapter-static/tsconfig.json create mode 100644 packages/adapter-vercel/index.d.js create mode 100644 packages/adapter-vercel/server.d.js delete mode 100644 packages/adapter-vercel/src/index.ts delete mode 100644 packages/adapter-vercel/src/server.ts delete mode 100644 packages/adapter-vercel/tsconfig.json rename packages/app-utils/src/files/{index.ts => index.js} (80%) rename packages/app-utils/src/files/{index.spec.ts => index.spec.js} (98%) rename packages/app-utils/src/http/get_body/{index.ts => index.js} (81%) rename packages/app-utils/src/http/get_body/{read_only_form_data.ts => read_only_form_data.js} (51%) rename packages/app-utils/src/http/{index.ts => index.js} (100%) rename packages/app-utils/src/{index.ts => index.js} (100%) rename packages/app-utils/src/renderer/{index.ts => index.js} (100%) rename packages/app-utils/src/renderer/manifest/{index.ts => index.js} (72%) rename packages/app-utils/src/renderer/manifest/{index.spec.data.ts => index.spec.data.js} (64%) rename packages/app-utils/src/renderer/manifest/{index.spec.ts => index.spec.js} (100%) rename packages/app-utils/src/renderer/prerender/{index.ts => index.js} (83%) rename packages/app-utils/src/renderer/render/{endpoint.ts => endpoint.js} (71%) rename packages/app-utils/src/renderer/render/{index.ts => index.js} (54%) rename packages/app-utils/src/renderer/render/{page.ts => page.js} (79%) create mode 100644 packages/app-utils/src/types/index.js delete mode 100644 packages/app-utils/src/types/index.ts delete mode 100644 packages/app-utils/tsconfig.json delete mode 100644 packages/create-svelte/cli/ambient.d.ts rename packages/create-svelte/cli/{index.ts => index.js} (97%) rename packages/create-svelte/cli/modifications/{add_css.ts => add_css.js} (93%) rename packages/create-svelte/cli/modifications/{add_typescript.ts => add_typescript.js} (94%) rename packages/create-svelte/cli/modifications/{utils.ts => utils.js} (82%) delete mode 100644 packages/create-svelte/tsconfig.json delete mode 100644 packages/kit/client/tsconfig.json delete mode 100644 packages/kit/index.d.ts delete mode 100644 packages/kit/src/ambient.d.ts rename packages/kit/src/api/build/{css_injection.ts => css_injection.js} (78%) rename packages/kit/src/api/build/{index.ts => index.js} (89%) rename packages/kit/src/api/dev/{index.ts => index.js} (81%) rename packages/kit/src/api/dev/{loader.ts => loader.js} (87%) rename packages/kit/src/api/dev/{sourcemap_stacktrace.ts => sourcemap_stacktrace.js} (81%) create mode 100644 packages/kit/src/api/dev/types.js delete mode 100644 packages/kit/src/api/dev/types.ts rename packages/kit/src/api/{utils.ts => utils.js} (100%) rename packages/kit/src/{cli.ts => cli.js} (85%) rename packages/kit/src/core/{create_app.ts => create_app.js} (83%) rename packages/kit/src/core/{create_manifest_data.ts => create_manifest_data.js} (86%) create mode 100644 packages/kit/src/interfaces.js delete mode 100644 packages/kit/src/interfaces.ts rename packages/kit/src/runtime/navigation/goto/{index.ts => index.js} (77%) rename packages/kit/src/runtime/navigation/{index.ts => index.js} (100%) rename packages/kit/src/runtime/navigation/{internal.ts => internal.js} (81%) rename packages/kit/src/runtime/navigation/prefetch/{index.ts => index.js} (64%) rename packages/kit/src/runtime/navigation/prefetchRoutes/{index.ts => index.js} (79%) rename packages/kit/src/runtime/navigation/start/{index.ts => index.js} (82%) create mode 100644 packages/kit/src/runtime/navigation/start/page_store.js delete mode 100644 packages/kit/src/runtime/navigation/start/page_store.ts create mode 100644 packages/kit/src/runtime/navigation/types.js delete mode 100644 packages/kit/src/runtime/navigation/types.ts rename packages/kit/src/runtime/navigation/{utils.ts => utils.js} (90%) rename packages/kit/src/runtime/stores/{index.ts => index.js} (61%) rename packages/kit/src/{utils.ts => utils.js} (80%) delete mode 100644 packages/kit/tsconfig.json diff --git a/package.json b/package.json index 297a7a35ae70..b221e44965c8 100644 --- a/package.json +++ b/package.json @@ -24,15 +24,10 @@ "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^9.0.0", "@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.6.0", - "@typescript-eslint/eslint-plugin": "^4.6.0", - "@typescript-eslint/parser": "^4.6.0", "eslint": "^7.11.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-svelte3": "^2.7.3", "prettier": "2.1.2", - "rollup": "^2.32.0", - "rollup-plugin-typescript2": "^0.29.0", - "tslib": "^2.0.3", - "typescript": "^4.0.3" + "rollup": "^2.32.0" } } diff --git a/packages/adapter-netlify/rollup.config.js b/packages/adapter-netlify/rollup.config.js index d35e1d6cc73b..4fece9aa4a88 100644 --- a/packages/adapter-netlify/rollup.config.js +++ b/packages/adapter-netlify/rollup.config.js @@ -1,24 +1,23 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; -import typescript from 'rollup-plugin-typescript2'; export default [ { - input: 'src/index.ts', + input: 'src/index.js', output: { file: 'index.js', format: 'cjs' }, - plugins: [nodeResolve(), commonjs(), typescript()], + plugins: [nodeResolve(), commonjs()], external: require('module').builtinModules }, { - input: 'src/render.ts', + input: 'src/render.js', output: { file: 'render.js', format: 'cjs' }, - plugins: [nodeResolve(), commonjs(), typescript()], + plugins: [nodeResolve(), commonjs()], external: require('module').builtinModules } ]; diff --git a/packages/adapter-netlify/src/index.ts b/packages/adapter-netlify/src/index.ts deleted file mode 100644 index 3be14ca0f3cb..000000000000 --- a/packages/adapter-netlify/src/index.ts +++ /dev/null @@ -1,97 +0,0 @@ -import fs from 'fs'; -import path from 'path'; -import toml from 'toml'; -import glob from 'tiny-glob/sync'; -import { RouteManifest } from '@sveltejs/app-utils'; -import { mkdirp } from '@sveltejs/app-utils/files'; -import { prerender, generate_manifest_module } from '@sveltejs/app-utils/renderer'; -import { Logger } from '@sveltejs/app-utils/renderer/prerender'; - -module.exports = async function builder({ - dir, - manifest, - log -}: { - dir: string; - manifest: RouteManifest; - log: Logger; -}) { - let netlify_config; - - if (fs.existsSync('netlify.toml')) { - try { - netlify_config = toml.parse(fs.readFileSync('netlify.toml', 'utf-8')); - } catch (err) { - err.message = `Error parsing netlify.toml: ${err.message}`; - throw err; - } - } else { - throw new Error( - 'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration' - ); - } - - if (!netlify_config.build || !netlify_config.build.publish || !netlify_config.build.functions) { - throw new Error( - 'You must specify build.publish and build.functions in netlify.toml. Consult https://github.com/sveltejs/adapter-netlify#configuration' - ); - } - - const publish = path.resolve(netlify_config.build.publish); - const functions = path.resolve(netlify_config.build.functions); - - mkdirp(`${publish}/_app`); - mkdirp(`${functions}/render`); - - // copy everything in `static` - glob('**/*', { cwd: 'static', filesOnly: true }).forEach((file) => { - mkdirp(path.dirname(`${publish}/${file}`)); - fs.copyFileSync(`static/${file}`, `${publish}/${file}`); - }); - - // copy client code - const client_code = path.resolve(dir, 'client'); - glob('**/*', { cwd: client_code, filesOnly: true }).forEach((file) => { - if (file[0] !== '.') { - mkdirp(path.dirname(`${publish}/_app/${file}`)); - fs.copyFileSync(`${client_code}/${file}`, `${publish}/_app/${file}`); - } - }); - - // prerender - log.info('Prerendering static pages...'); - await prerender({ - force: true, - dir, - out: publish, - manifest, - log - }); - - // copy server code - const server_code = path.resolve(dir, 'server'); - glob('**/*', { cwd: server_code, filesOnly: true }).forEach((file) => { - if (file[0] !== '.') { - mkdirp(path.dirname(`${functions}/render/${file}`)); - fs.copyFileSync(`${server_code}/${file}`, `${functions}/render/${file}`); - } - }); - - // copy the renderer - fs.copyFileSync(path.resolve(__dirname, 'render.js'), `${functions}/render/index.js`); - - // write manifest - fs.writeFileSync(`${functions}/render/manifest.js`, generate_manifest_module(manifest)); - - // copy client manifest - fs.copyFileSync(`${dir}/client.json`, `${functions}/render/client.json`); - - // copy template - fs.writeFileSync( - `${functions}/render/template.js`, - `module.exports = ${JSON.stringify(fs.readFileSync('src/app.html', 'utf-8'))};` - ); - - // create _redirects - fs.writeFileSync(`${publish}/_redirects`, '/* /.netlify/functions/render 200'); -}; diff --git a/packages/adapter-netlify/src/render.ts b/packages/adapter-netlify/src/render.ts deleted file mode 100644 index 2a9900686011..000000000000 --- a/packages/adapter-netlify/src/render.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { APIGatewayProxyHandler } from 'aws-lambda'; -import { URLSearchParams } from 'url'; -import { render } from '@sveltejs/app-utils/renderer'; -import type { PageComponentManifest, EndpointManifest, Method } from '@sveltejs/app-utils'; - -const manifest = require('./manifest.js'); -const client = require('./client.json'); -const root = require('./root.js'); -const setup = require('./setup.js'); -const template = require('./template.js'); - -// TODO this is a generic AWS lambda handler, and could be -// reused by other adapters - -export const handler: APIGatewayProxyHandler = async (event) => { - const { - path, - httpMethod, - headers, - queryStringParameters - // body, // TODO pass this to renderer - // isBase64Encoded // TODO is this useful? - } = event; - - const query = new URLSearchParams(); - for (const k in queryStringParameters) { - const value = queryStringParameters[k]; - value.split(', ').forEach((v) => { - query.append(k, v); - }); - } - - const rendered = await render( - { - host: null, // TODO - method: httpMethod as Method, - headers, - path, - query - }, - { - static_dir: 'static', - template, - manifest, - client, - root, - setup, - load: (route: PageComponentManifest | EndpointManifest) => - require(`./routes/${route.name}.js`), - dev: false, - only_prerender: false - } - ); - - if (rendered) { - return { - isBase64Encoded: false, - statusCode: rendered.status, - headers: rendered.headers, - body: rendered.body - }; - } - - return { - statusCode: 404, - body: 'Not found' - }; -}; diff --git a/packages/adapter-netlify/tsconfig.json b/packages/adapter-netlify/tsconfig.json deleted file mode 100644 index 1864d58c1554..000000000000 --- a/packages/adapter-netlify/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../tsconfig.json" -} diff --git a/packages/adapter-node/rollup.config.js b/packages/adapter-node/rollup.config.js index 73dfc2880973..c40c1e98ccec 100644 --- a/packages/adapter-node/rollup.config.js +++ b/packages/adapter-node/rollup.config.js @@ -1,24 +1,23 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; -import typescript from 'rollup-plugin-typescript2'; export default [ { - input: 'src/index.ts', + input: 'src/index.js', output: { file: 'index.js', format: 'cjs' }, - plugins: [nodeResolve(), commonjs(), typescript()], + plugins: [nodeResolve(), commonjs()], external: require('module').builtinModules }, { - input: 'src/server.ts', + input: 'src/server.js', output: { file: 'server.js', format: 'cjs' }, - plugins: [nodeResolve(), commonjs(), typescript()], + plugins: [nodeResolve(), commonjs()], external: require('module').builtinModules } ]; diff --git a/packages/adapter-node/src/index.ts b/packages/adapter-node/src/index.ts deleted file mode 100644 index 918f8b7fc95d..000000000000 --- a/packages/adapter-node/src/index.ts +++ /dev/null @@ -1,58 +0,0 @@ -import fs from 'fs'; -import { RouteManifest } from '@sveltejs/app-utils'; -import { copy } from '@sveltejs/app-utils/files'; -import { prerender } from '@sveltejs/app-utils/renderer'; -import { Logger } from '@sveltejs/app-utils/renderer/prerender'; - -module.exports = async function adapter({ - dir, - manifest, - log -}: { - dir: string; - manifest: RouteManifest; - log: Logger; -}) { - const out = 'build'; // TODO implement adapter options - - copy(`${dir}/client`, `${out}/assets/_app`, (file) => !!file && file[0] !== '.'); - copy(`${dir}/server`, out); - copy(`${__dirname}/server.js`, `${out}/index.js`); - copy(`${dir}/client.json`, `${out}/client.json`); - copy('src/app.html', `${out}/app.html`); - - log.info('Prerendering static pages...'); - - await prerender({ - force: true, - dir, - out: `${out}/prerendered`, - assets: `${out}/assets`, - manifest, - log - }); - - // generate manifest - const written_manifest = `module.exports = { - layout: ${JSON.stringify(manifest.layout)}, - error: ${JSON.stringify(manifest.error)}, - components: ${JSON.stringify(manifest.components)}, - pages: [ - ${manifest.pages - .map((page) => `{ pattern: ${page.pattern}, parts: ${JSON.stringify(page.parts)} }`) - .join(',\n\t\t\t')} - ], - endpoints: [ - ${manifest.endpoints - .map( - (route) => - `{ name: '${route.name}', pattern: ${route.pattern}, file: '${ - route.file - }', params: ${JSON.stringify(route.params)} }` - ) - .join(',\n\t\t\t')} - ] - };`.replace(/^\t/gm, ''); - - fs.writeFileSync(`${out}/manifest.js`, written_manifest); -}; diff --git a/packages/adapter-node/src/server.ts b/packages/adapter-node/src/server.ts deleted file mode 100644 index 5b6d48d9fd2c..000000000000 --- a/packages/adapter-node/src/server.ts +++ /dev/null @@ -1,77 +0,0 @@ -import * as fs from 'fs'; -import * as http from 'http'; -import { parse, URLSearchParams } from 'url'; -import sirv from 'sirv'; -import { render } from '@sveltejs/app-utils/renderer'; -import { get_body } from '@sveltejs/app-utils/http'; -import type { PageComponentManifest, EndpointManifest, Method } from '@sveltejs/app-utils'; - -const manifest = require('./manifest.js'); -const client = require('./client.json'); - -const { PORT = 3000 } = process.env; - -const mutable = (dir: string) => - sirv(dir, { - etag: true, - maxAge: 0 - }); - -const static_handler = mutable('static'); -const prerendered_handler = fs.existsSync('build/prerendered') - ? mutable('build/prerendered') - : (_req: http.IncomingMessage, _res: http.ServerResponse, next: () => void) => next(); - -const assets_handler = sirv('build/assets', { - maxAge: 31536000, - immutable: true -}); - -const root = require('./root.js'); -const setup = require('./setup.js'); -const template = fs.readFileSync('build/app.html', 'utf-8'); - -const server = http.createServer((req, res) => { - assets_handler(req, res, () => { - static_handler(req, res, () => { - prerendered_handler(req, res, async () => { - const parsed = parse(req.url || ''); - - const rendered = await render( - { - host: null, // TODO - method: req.method as Method, - headers: req.headers as Record, // TODO: what about repeated headers, i.e. string[] - path: parsed.pathname as string, - body: await get_body(req), - query: new URLSearchParams(parsed.query || '') - }, - { - static_dir: 'static', - template, - manifest, - client, - root, - setup, - load: (route: PageComponentManifest | EndpointManifest) => - require(`./routes/${route.name}.js`), - dev: false, - only_prerender: false - } - ); - - if (rendered) { - res.writeHead(rendered.status, rendered.headers); - res.end(rendered.body); - } else { - res.statusCode = 404; - res.end('Not found'); - } - }); - }); - }); -}); - -server.listen(PORT, () => { - console.log(`Listening on port ${PORT}`); -}); diff --git a/packages/adapter-node/tsconfig.json b/packages/adapter-node/tsconfig.json deleted file mode 100644 index 1864d58c1554..000000000000 --- a/packages/adapter-node/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../tsconfig.json" -} diff --git a/packages/adapter-static/rollup.config.js b/packages/adapter-static/rollup.config.js index a7b68cb044c5..6be1c1d5d3e4 100644 --- a/packages/adapter-static/rollup.config.js +++ b/packages/adapter-static/rollup.config.js @@ -1,13 +1,12 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; -import typescript from 'rollup-plugin-typescript2'; export default { - input: 'src/index.ts', + input: 'src/index.js', output: { file: 'server.js', format: 'cjs' }, - plugins: [nodeResolve(), commonjs(), typescript()], + plugins: [nodeResolve(), commonjs()], external: require('module').builtinModules }; diff --git a/packages/adapter-static/src/index.ts b/packages/adapter-static/src/index.ts deleted file mode 100644 index b01ad04e561e..000000000000 --- a/packages/adapter-static/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { RouteManifest } from '@sveltejs/app-utils'; -import { copy } from '@sveltejs/app-utils/files'; -import { prerender } from '@sveltejs/app-utils/renderer'; -import { Logger } from '@sveltejs/app-utils/renderer/prerender'; - -module.exports = async function adapter({ - dir, - manifest, - log -}: { - dir: string; - manifest: RouteManifest; - log: Logger; -}) { - const out = 'build'; // TODO implement adapter options - - copy('static', out); - copy(`${dir}/client`, `${out}/_app`); - - prerender({ - force: true, - dir, - out, - manifest, - log - }); -}; diff --git a/packages/adapter-static/tsconfig.json b/packages/adapter-static/tsconfig.json deleted file mode 100644 index 1864d58c1554..000000000000 --- a/packages/adapter-static/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../tsconfig.json" -} diff --git a/packages/adapter-vercel/index.d.js b/packages/adapter-vercel/index.d.js new file mode 100644 index 000000000000..2be8ffc5ce05 --- /dev/null +++ b/packages/adapter-vercel/index.d.js @@ -0,0 +1,7 @@ + + + + + + + diff --git a/packages/adapter-vercel/rollup.config.js b/packages/adapter-vercel/rollup.config.js index 73dfc2880973..c40c1e98ccec 100644 --- a/packages/adapter-vercel/rollup.config.js +++ b/packages/adapter-vercel/rollup.config.js @@ -1,24 +1,23 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; -import typescript from 'rollup-plugin-typescript2'; export default [ { - input: 'src/index.ts', + input: 'src/index.js', output: { file: 'index.js', format: 'cjs' }, - plugins: [nodeResolve(), commonjs(), typescript()], + plugins: [nodeResolve(), commonjs()], external: require('module').builtinModules }, { - input: 'src/server.ts', + input: 'src/server.js', output: { file: 'server.js', format: 'cjs' }, - plugins: [nodeResolve(), commonjs(), typescript()], + plugins: [nodeResolve(), commonjs()], external: require('module').builtinModules } ]; diff --git a/packages/adapter-vercel/server.d.js b/packages/adapter-vercel/server.d.js new file mode 100644 index 000000000000..99a8091366e2 --- /dev/null +++ b/packages/adapter-vercel/server.d.js @@ -0,0 +1,2 @@ + + diff --git a/packages/adapter-vercel/src/index.ts b/packages/adapter-vercel/src/index.ts deleted file mode 100644 index b5f016bcdb35..000000000000 --- a/packages/adapter-vercel/src/index.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { writeFileSync, readFileSync } from 'fs'; -import { resolve, join } from 'path'; -import { RouteManifest } from '@sveltejs/app-utils'; -import { copy } from '@sveltejs/app-utils/files'; -import { prerender, generate_manifest_module } from '@sveltejs/app-utils/renderer'; -import { Logger } from '@sveltejs/app-utils/renderer/prerender'; - -export async function builder({ - dir, - manifest, - log -}: { - dir: string; - manifest: RouteManifest; - log: Logger; -}) { - const lambda_directory = resolve('api'); - const static_directory = resolve('public'); - const server_directory = resolve(join('api', 'server')); - - log.info('Writing client application...'); - copy('static', static_directory); - copy(resolve(dir, 'client'), join(static_directory, '_app')); - - log.info('Building lambda...'); - copy(resolve(__dirname, 'src'), lambda_directory); - copy(join(resolve(dir), 'client.json'), join(server_directory, 'client.json')); - const written_manifest = generate_manifest_module(manifest); - const htmlPath = resolve('src', 'app.html'); - const appHtml = readFileSync(htmlPath, 'utf-8'); - writeFileSync(join(server_directory, 'manifest.js'), written_manifest); - writeFileSync( - join(server_directory, 'template.js'), - `module.exports = ${JSON.stringify(appHtml)};` - ); - - log.info('Prerendering static pages...'); - await prerender({ - force: true, - dir, - out: static_directory, - manifest, - log - }); - - log.info('Writing server application...'); - copy(resolve(dir, 'server'), server_directory); - - // TODO: Merge this, rather than write it - log.info('Rewriting vercel configuration...'); - writeFileSync( - 'vercel.json', - JSON.stringify({ - public: true, - build: { - env: { - NODEJS_AWS_HANDLER_NAME: 'handler' - } - }, - rewrites: [ - { - source: '/(.*)', - destination: '/api/render/' - } - ] - }) - ); -} diff --git a/packages/adapter-vercel/src/server.ts b/packages/adapter-vercel/src/server.ts deleted file mode 100644 index f0cbd8ca41cc..000000000000 --- a/packages/adapter-vercel/src/server.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { URLSearchParams } from 'url'; -import { render } from '@sveltejs/app-utils/renderer'; -import type { APIGatewayProxyHandler } from 'aws-lambda'; -import type { PageComponentManifest, EndpointManifest, Method } from '@sveltejs/app-utils'; - -const client = require('./server/client.json'); -const manifest = require('./server/manifest.js'); -const root = require('./server/root.js'); -const setup = require('./server/setup.js'); -const template = require('./server/template.js'); - -// TODO: This is the same as netlify's render function, and basically just builds an AWS lambda. -// We should extract it into some sort of lambda rendering package -export const handler: APIGatewayProxyHandler = async (event) => { - const { - path, - httpMethod, - headers, - queryStringParameters, - body - // isBase64Encoded // TODO is this useful? - } = event; - - const query = new URLSearchParams(); - for (const k in queryStringParameters) { - const value = queryStringParameters[k]; - value.split(', ').forEach((v) => { - query.append(k, v); - }); - } - - const rendered = await render( - { - host: null, // TODO - method: httpMethod as Method, - headers, - path, - body, - query - }, - { - static_dir: 'static', - template, - manifest, - client, - root, - setup, - load: (route: PageComponentManifest | EndpointManifest) => - require(`./server/routes/${route.name}.js`), - dev: false, - only_prerender: false - } - ); - - if (rendered) { - return { - isBase64Encoded: false, - statusCode: rendered.status, - headers: rendered.headers, - body: rendered.body - }; - } - - return { - statusCode: 404, - body: 'Not found' - }; -}; diff --git a/packages/adapter-vercel/tsconfig.json b/packages/adapter-vercel/tsconfig.json deleted file mode 100644 index 1864d58c1554..000000000000 --- a/packages/adapter-vercel/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../tsconfig.json" -} diff --git a/packages/app-utils/rollup.config.js b/packages/app-utils/rollup.config.js index 2051a3c01901..00e6b31e1e5c 100644 --- a/packages/app-utils/rollup.config.js +++ b/packages/app-utils/rollup.config.js @@ -1,12 +1,9 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; -import typescript from 'rollup-plugin-typescript2'; import pkg from './package.json'; -const fs = require('fs'); -const path = require('path'); const input = {}; Object.keys(pkg.exports).forEach((key) => { - input[key.replace(/^\.\//, '')] = `src/${key}/index.ts`; + input[key.replace(/^\.\//, '')] = `src/${key}/index.js`; }); export default { @@ -28,8 +25,7 @@ export default { } ], plugins: [ - nodeResolve(), - typescript() + nodeResolve() ], external: [...require('module').builtinModules, ...Object.keys(pkg.dependencies)] }; diff --git a/packages/app-utils/src/files/index.ts b/packages/app-utils/src/files/index.js similarity index 80% rename from packages/app-utils/src/files/index.ts rename to packages/app-utils/src/files/index.js index cc540690544c..45aff70bbbe6 100644 --- a/packages/app-utils/src/files/index.ts +++ b/packages/app-utils/src/files/index.js @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; -export function mkdirp(dir: string) { +export function mkdirp(dir) { try { fs.mkdirSync(dir, { recursive: true }); } catch (e) { @@ -11,10 +11,10 @@ export function mkdirp(dir: string) { } export function copy( - from: string, - to: string, - filter: (file?: string) => boolean = () => true -): string[] { + from, + to, + filter = () => true +) { if (!filter(path.basename(from))) return []; const files = []; diff --git a/packages/app-utils/src/files/index.spec.ts b/packages/app-utils/src/files/index.spec.js similarity index 98% rename from packages/app-utils/src/files/index.spec.ts rename to packages/app-utils/src/files/index.spec.js index 3248b42e4a6f..e0e0d8f4a225 100644 --- a/packages/app-utils/src/files/index.spec.ts +++ b/packages/app-utils/src/files/index.spec.js @@ -7,8 +7,8 @@ import { copy } from '.'; const suite_copy = suite('#copy()'); -let source_dir: string; -let dest_dir: string; +let source_dir; +let dest_dir; suite_copy.before.each(() => { const temp_dir = mkdtempSync(join(tmpdir(), 'app-utils-')); diff --git a/packages/app-utils/src/http/get_body/index.ts b/packages/app-utils/src/http/get_body/index.js similarity index 81% rename from packages/app-utils/src/http/get_body/index.ts rename to packages/app-utils/src/http/get_body/index.js index 4625c906d285..d72bd855072b 100644 --- a/packages/app-utils/src/http/get_body/index.ts +++ b/packages/app-utils/src/http/get_body/index.js @@ -1,7 +1,7 @@ -import { IncomingMessage } from 'http'; + import { read_only_form_data } from './read_only_form_data'; -export function get_body(req: IncomingMessage) { +export function get_body(req) { const headers = req.headers; const has_body = headers['content-type'] !== undefined && @@ -10,7 +10,7 @@ export function get_body(req: IncomingMessage) { if (!has_body) return Promise.resolve(undefined); - const [type, ...directives] = (headers['content-type'] as string).split(/;\s*/); + const [type, ...directives] = (headers['content-type'] ).split(/;\s*/); switch (type) { case 'application/octet-stream': @@ -35,11 +35,11 @@ export function get_body(req: IncomingMessage) { } } -async function get_json(req: IncomingMessage) { +async function get_json(req) { return JSON.parse(await get_text(req)); } -async function get_urlencoded(req: IncomingMessage) { +async function get_urlencoded(req) { const text = await get_text(req); const { data, append } = read_only_form_data(); @@ -55,7 +55,7 @@ async function get_urlencoded(req: IncomingMessage) { return data; } -async function get_multipart(req: IncomingMessage, boundary: string) { +async function get_multipart(req, boundary) { const text = await get_text(req); const parts = text.split(`--${boundary}`); @@ -70,13 +70,13 @@ async function get_multipart(req: IncomingMessage, boundary: string) { const { data, append } = read_only_form_data(); parts.slice(1, -1).forEach((part) => { - const match = /\s*([\s\S]+?)\r\n\r\n([\s\S]*)\s*/.exec(part) as RegExpMatchArray; + const match = /\s*([\s\S]+?)\r\n\r\n([\s\S]*)\s*/.exec(part) ; const raw_headers = match[1]; const body = match[2].trim(); - let key: string; + let key; - const headers: Record = {}; + const headers = {}; raw_headers.split('\r\n').forEach((str) => { const [raw_header, ...raw_directives] = str.split('; '); let [name, value] = raw_header.split(': '); @@ -84,7 +84,7 @@ async function get_multipart(req: IncomingMessage, boundary: string) { name = name.toLowerCase(); headers[name] = value; - const directives: Record = {}; + const directives = {}; raw_directives.forEach((raw_directive) => { const [name, value] = raw_directive.split('='); directives[name] = JSON.parse(value); // TODO is this right? @@ -104,15 +104,15 @@ async function get_multipart(req: IncomingMessage, boundary: string) { } }); - if (!key!) nope(); + if (!key) nope(); - append(key!, body); + append(key, body); }); return data; } -function get_text(req: IncomingMessage): Promise { +function get_text(req) { return new Promise((fulfil, reject) => { let data = ''; @@ -128,7 +128,7 @@ function get_text(req: IncomingMessage): Promise { }); } -function get_buffer(req: IncomingMessage): Promise { +function get_buffer(req) { return new Promise((fulfil, reject) => { let data = new Uint8Array(0); diff --git a/packages/app-utils/src/http/get_body/read_only_form_data.ts b/packages/app-utils/src/http/get_body/read_only_form_data.js similarity index 51% rename from packages/app-utils/src/http/get_body/read_only_form_data.ts rename to packages/app-utils/src/http/get_body/read_only_form_data.js index 721f7a3499bb..bbbeee5f3891 100644 --- a/packages/app-utils/src/http/get_body/read_only_form_data.ts +++ b/packages/app-utils/src/http/get_body/read_only_form_data.js @@ -1,12 +1,12 @@ -type FormDataMap = Map; + function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } export function read_only_form_data() { - const map: FormDataMap = new Map(); + const map = new Map(); return { - append(key: string, value: string) { + append(key, value) { if (map.has(key)) { - (map.get(key) as string[]).push(value); + (map.get(key) ).push(value); } else { map.set(key, [value]); } @@ -17,21 +17,21 @@ export function read_only_form_data() { } class ReadOnlyFormData { - #map: FormDataMap; + #map - constructor(map: FormDataMap) { + constructor(map) { this.#map = map; } - get(key: string) { - return this.#map.get(key)?.[0]; + get(key) { + return _optionalChain([this, 'access', _ => _.#map, 'access', _2 => _2.get, 'call', _3 => _3(key), 'optionalAccess', _4 => _4[0]]); } - getAll(key: string) { + getAll(key) { return this.#map.get(key); } - has(key: string) { + has(key) { return this.#map.has(key); } diff --git a/packages/app-utils/src/http/index.ts b/packages/app-utils/src/http/index.js similarity index 100% rename from packages/app-utils/src/http/index.ts rename to packages/app-utils/src/http/index.js diff --git a/packages/app-utils/src/index.ts b/packages/app-utils/src/index.js similarity index 100% rename from packages/app-utils/src/index.ts rename to packages/app-utils/src/index.js diff --git a/packages/app-utils/src/renderer/index.ts b/packages/app-utils/src/renderer/index.js similarity index 100% rename from packages/app-utils/src/renderer/index.ts rename to packages/app-utils/src/renderer/index.js diff --git a/packages/app-utils/src/renderer/manifest/index.ts b/packages/app-utils/src/renderer/manifest/index.js similarity index 72% rename from packages/app-utils/src/renderer/manifest/index.ts rename to packages/app-utils/src/renderer/manifest/index.js index 73959f6ad808..3ea1b8cb6a66 100644 --- a/packages/app-utils/src/renderer/manifest/index.ts +++ b/packages/app-utils/src/renderer/manifest/index.js @@ -1,8 +1,8 @@ -import { RouteManifest, PageManifest, EndpointManifest } from '../../types'; + const array_item_delimiter = ','; -function map_pages(pages: PageManifest[]) { +function map_pages(pages) { return pages .map(({ pattern, parts: json_parts }) => { const parts = JSON.stringify(json_parts); @@ -11,7 +11,7 @@ function map_pages(pages: PageManifest[]) { .join(array_item_delimiter); } -function map_endpoints(endpoints: EndpointManifest[]) { +function map_endpoints(endpoints) { return endpoints .map(({ name, pattern, file, params: json_params }) => { const params = JSON.stringify(json_params); @@ -20,8 +20,8 @@ function map_endpoints(endpoints: EndpointManifest[]) { .join(array_item_delimiter); } -export function generate_manifest_module(manifest: RouteManifest) { - const strings: (keyof RouteManifest)[] = ['layout', 'error', 'components']; +export function generate_manifest_module(manifest) { + const strings = ['layout', 'error', 'components']; const [layout, error, components] = strings.map((b) => JSON.stringify(manifest[b])); const pages = map_pages(manifest.pages); const endpoints = map_endpoints(manifest.endpoints); diff --git a/packages/app-utils/src/renderer/manifest/index.spec.data.ts b/packages/app-utils/src/renderer/manifest/index.spec.data.js similarity index 64% rename from packages/app-utils/src/renderer/manifest/index.spec.data.ts rename to packages/app-utils/src/renderer/manifest/index.spec.data.js index baccd856e7c6..66fb6adfc717 100644 --- a/packages/app-utils/src/renderer/manifest/index.spec.data.ts +++ b/packages/app-utils/src/renderer/manifest/index.spec.data.js @@ -1,6 +1,6 @@ -import { PageComponentManifest, RouteManifest, PageManifest, EndpointManifest } from '../../types'; -const examplePageComponentManifest: PageComponentManifest = { + +const examplePageComponentManifest = { default: true, type: 'foo', name: 'bar', @@ -8,7 +8,7 @@ const examplePageComponentManifest: PageComponentManifest = { url: 'boo' }; -const examplePageManifest: PageManifest = { +const examplePageManifest = { pattern: /a/, path: 'qux', parts: [ @@ -19,7 +19,7 @@ const examplePageManifest: PageManifest = { ] }; -const exampleEndpointManifest: EndpointManifest = { +const exampleEndpointManifest = { name: 'grault', pattern: /b/, file: 'garply', @@ -27,7 +27,7 @@ const exampleEndpointManifest: EndpointManifest = { params: ['waldo', 'fred'] }; -export const exampleRouteManifest: RouteManifest = { +export const exampleRouteManifest = { layout: examplePageComponentManifest, error: examplePageComponentManifest, components: [examplePageComponentManifest, examplePageComponentManifest], diff --git a/packages/app-utils/src/renderer/manifest/index.spec.ts b/packages/app-utils/src/renderer/manifest/index.spec.js similarity index 100% rename from packages/app-utils/src/renderer/manifest/index.spec.ts rename to packages/app-utils/src/renderer/manifest/index.spec.js diff --git a/packages/app-utils/src/renderer/prerender/index.ts b/packages/app-utils/src/renderer/prerender/index.js similarity index 83% rename from packages/app-utils/src/renderer/prerender/index.ts rename to packages/app-utils/src/renderer/prerender/index.js index 9b430e29fcd7..e0ac87ab0f67 100644 --- a/packages/app-utils/src/renderer/prerender/index.ts +++ b/packages/app-utils/src/renderer/prerender/index.js @@ -1,11 +1,11 @@ -import fs from 'fs'; + function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }import fs from 'fs'; import { dirname, resolve as resolve_path } from 'path'; import { parse, resolve, URLSearchParams } from 'url'; import { mkdirp } from '../../files'; import { render } from '../render'; -import { PageResponse, RouteManifest } from '../../types'; -function clean_html(html: string) { + +function clean_html(html) { return html .replace(//gm, '') .replace(/()[\s\S]*?<\/script>/gm, '$1') @@ -13,17 +13,17 @@ function clean_html(html: string) { .replace(//gm, ''); } -function get_href(attrs: string) { +function get_href(attrs) { const match = /href\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/.exec(attrs); return match && (match[1] || match[2] || match[3]); } -function get_src(attrs: string) { +function get_src(attrs) { const match = /src\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/.exec(attrs); return match && (match[1] || match[2] || match[3]); } -function get_srcset_urls(attrs: string) { +function get_srcset_urls(attrs) { const results = []; // Note that the srcset allows any ASCII whitespace, including newlines. const match = /srcset\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/s.exec(attrs); @@ -44,13 +44,13 @@ function get_srcset_urls(attrs: string) { const OK = 2; const REDIRECT = 3; -export type Logger = { - (msg: string): void; - error: (msg: string) => void; - warn: (msg: string) => void; - info: (msg: string) => void; - success: (msg: string) => void; -}; + + + + + + + export async function prerender({ dir, @@ -59,14 +59,14 @@ export async function prerender({ manifest, force, log -}: { - dir: string; - out: string; - assets?: string; - manifest: RouteManifest; - force: boolean; - log: Logger; -}) { +} + + + + + + +) { const seen = new Set(); const template = fs.readFileSync('src/app.html', 'utf-8'); @@ -76,7 +76,7 @@ export async function prerender({ const root = require(`${server_root}/server/root.js`); const setup = require(`${server_root}/server/setup.js`); - async function crawl(path: string) { + async function crawl(path) { if (seen.has(path)) return; seen.add(path); @@ -105,7 +105,7 @@ export async function prerender({ if (rendered) { const response_type = Math.floor(rendered.status / 100); const headers = rendered.headers; - const is_html = response_type === REDIRECT || headers?.['content-type'] === 'text/html'; + const is_html = response_type === REDIRECT || _optionalChain([headers, 'optionalAccess', _ => _['content-type']]) === 'text/html'; const parts = path.split('/'); if (is_html && parts[parts.length - 1] !== 'index.html') { @@ -135,7 +135,7 @@ export async function prerender({ log.error(`${rendered.status} ${path}`); } - const { dependencies } = rendered as PageResponse; + const { dependencies } = rendered ; if (dependencies) { for (const path in dependencies) { @@ -185,12 +185,12 @@ export async function prerender({ hrefs = hrefs.filter(Boolean); for (const href of hrefs) { - const resolved = resolve(path, href!); + const resolved = resolve(path, href); if (resolved[0] !== '/') continue; const parsed = parse(resolved); - const parts = parsed.pathname!.slice(1).split('/').filter(Boolean); + const parts = parsed.pathname.slice(1).split('/').filter(Boolean); if (parts[parts.length - 1] === 'index.html') parts.pop(); // TODO this feels iffy @@ -206,7 +206,7 @@ export async function prerender({ // TODO warn that query strings have no effect on statically-exported pages } - await crawl(parsed.pathname!); + await crawl(parsed.pathname); } } } diff --git a/packages/app-utils/src/renderer/render/endpoint.ts b/packages/app-utils/src/renderer/render/endpoint.js similarity index 71% rename from packages/app-utils/src/renderer/render/endpoint.ts rename to packages/app-utils/src/renderer/render/endpoint.js index b33097003b13..3b10c92b72dd 100644 --- a/packages/app-utils/src/renderer/render/endpoint.ts +++ b/packages/app-utils/src/renderer/render/endpoint.js @@ -1,15 +1,15 @@ -import { IncomingRequest, RenderOptions, EndpointManifest, Headers } from '../../types'; + export default function render_route( - request: IncomingRequest, - context: any, - options: RenderOptions -): Promise<{ - status: number; - body: string; - headers: Headers; -}> | null { - const route: EndpointManifest | undefined = options.manifest.endpoints.find((route) => + request, + context, + options +) + + + + { + const route = options.manifest.endpoints.find((route) => route.pattern.test(request.path) ); if (!route) return null; @@ -18,8 +18,8 @@ export default function render_route( const handler = mod[request.method.toLowerCase().replace('delete', 'del')]; // 'delete' is a reserved word if (handler) { - const params: Record = {}; - const match = route.pattern.exec(request.path)!; + const params = {}; + const match = route.pattern.exec(request.path); route.params.forEach((name, i) => { params[name] = match[i + 1]; }); @@ -64,8 +64,8 @@ export default function render_route( }); } -function lowercase_keys(obj: Record) { - const clone: Record = {}; +function lowercase_keys(obj) { + const clone = {}; for (const key in obj) { clone[key.toLowerCase()] = obj[key]; } diff --git a/packages/app-utils/src/renderer/render/index.ts b/packages/app-utils/src/renderer/render/index.js similarity index 54% rename from packages/app-utils/src/renderer/render/index.ts rename to packages/app-utils/src/renderer/render/index.js index 7187597e77f7..500c025bcdf7 100644 --- a/packages/app-utils/src/renderer/render/index.ts +++ b/packages/app-utils/src/renderer/render/index.js @@ -1,17 +1,17 @@ -import { createHash } from 'crypto'; + function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }import { createHash } from 'crypto'; import render_page from './page'; import render_endpoint from './endpoint'; -import { EndpointResponse, IncomingRequest, PageResponse, RenderOptions } from '../../types'; -function md5(body: string) { + +function md5(body) { return createHash('md5').update(body).digest('hex'); } export async function render( - request: IncomingRequest, - options: RenderOptions -): Promise { - const { context, headers = {} } = (await options.setup.prepare?.(request.headers)) || {}; + request, + options +) { + const { context, headers = {} } = (await _optionalChain([options, 'access', _ => _.setup, 'access', _2 => _2.prepare, 'optionalCall', _3 => _3(request.headers)])) || {}; try { const response = await (render_endpoint(request, context, options) || diff --git a/packages/app-utils/src/renderer/render/page.ts b/packages/app-utils/src/renderer/render/page.js similarity index 79% rename from packages/app-utils/src/renderer/render/page.ts rename to packages/app-utils/src/renderer/render/page.js index b59d5afd3e1d..61c5c8b330b6 100644 --- a/packages/app-utils/src/renderer/render/page.ts +++ b/packages/app-utils/src/renderer/render/page.js @@ -1,63 +1,63 @@ -import devalue from 'devalue'; + function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }import devalue from 'devalue'; import { createReadStream, existsSync } from 'fs'; import * as mime from 'mime'; import fetch, { Response } from 'node-fetch'; import { readable, writable } from 'svelte/store'; import { parse, resolve, URLSearchParams } from 'url'; -import { - EndpointResponse, - Headers, - IncomingRequest, - PageContext, - PageManifest, - PageManifestPart, - PageResponse, - RenderOptions, - RouteParams -} from '../../types'; + + + + + + + + + + + import { render } from './index'; const noop = () => {}; -type FetchOpts = { - method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS'; - headers?: Headers; - body?: any; -}; + + + + + export default async function render_page( - request: IncomingRequest, - context: any, - options: RenderOptions, - status: number = 200, - error: Error | null = null -): Promise< - | { - status: number; - body: string; - headers: Headers; - dependencies: Record; - } - | undefined -> { - let redirected: PageResponse; + request, + context, + options, + status = 200, + error = null +) + + + + + + + + { + let redirected; let preload_error; - const page: PageManifest | undefined = options.manifest.pages.find((page) => + const page = options.manifest.pages.find((page) => page.pattern.test(request.path) ); const baseUrl = ''; // TODO - const session = await options.setup.getSession?.(context); + const session = await _optionalChain([options, 'access', _ => _.setup, 'access', _2 => _2.getSession, 'optionalCall', _3 => _3(context)]); - const serialized_session = try_serialize(session, (err: Error) => { + const serialized_session = try_serialize(session, (err) => { throw new Error(`Failed to serialize session data: ${err.message}`); }); try { if (!page) { - const error: any = new Error(`Not found: ${request.path}`); + const error = new Error(`Not found: ${request.path}`); error.status = 404; throw error; } @@ -74,10 +74,10 @@ export default async function render_page( l++; }); - const dependencies: Record = {}; + const dependencies = {}; const preload_context = { - redirect: (status: number, location: string) => { + redirect: (status, location) => { if ( redirected && (redirected.status !== status || redirected.headers.location !== location) @@ -92,13 +92,13 @@ export default async function render_page( dependencies: {} }; }, - error: (status: number, error: Error | string) => { + error: (status, error) => { if (typeof error === 'string') { error = new Error(error); } preload_error = { ...error, status }; }, - fetch: async (url: string, opts: FetchOpts = {}) => { + fetch: async (url, opts = {}) => { const parsed = parse(url); if (parsed.protocol) { @@ -110,7 +110,7 @@ export default async function render_page( // probably no advantage to using fetch here — we should replace // `this.fetch` with `this.load` or whatever - const resolved = resolve(request.path, parsed.pathname!); + const resolved = resolve(request.path, parsed.pathname); // edge case — fetching a static file const candidates = [ @@ -121,7 +121,7 @@ export default async function render_page( if (existsSync(file)) { return new Response(createReadStream(file), { headers: { - 'content-type': mime.getType(file)! + 'content-type': mime.getType(file) } }); } @@ -157,12 +157,12 @@ export default async function render_page( } }; - const match = page.pattern.exec(request.path)!; + const match = page.pattern.exec(request.path); // the last part has all parameters from any segment in the URL - const params = parts_to_params(match, page.parts[page.parts.length - 1] as PageManifestPart); + const params = parts_to_params(match, page.parts[page.parts.length - 1] ); - const preloaded: any[] = []; + const preloaded = []; let can_prerender = true; const parts = await Promise.all( @@ -200,13 +200,13 @@ export default async function render_page( if (options.only_prerender && !can_prerender) return; if (preload_error) throw preload_error; - if (redirected!) return redirected!; + if (redirected) return redirected; + + const branches + + - const branches: Array<{ - component: any; // TODO - props: any; - segment: string; - }> = []; + = []; parts.forEach((part, i) => { if (part) { branches.push({ @@ -217,15 +217,15 @@ export default async function render_page( } }); - const pageContext: PageContext = { - host: request.host as string, + const pageContext = { + host: request.host , path: request.path, query: search_params_to_map(request.query), params, error: error || undefined }; - const props: Record = { + const props = { status, error, stores: { @@ -260,7 +260,7 @@ export default async function render_page( const serialized_preloads = `[${preloaded .map((data) => - try_serialize(data, (err: Error) => { + try_serialize(data, (err) => { const path = '/' + segments.join('/'); console.error( `Failed to serialize preloaded data to transmit to the client at the ${path} route: ${err.message}` @@ -278,7 +278,7 @@ export default async function render_page( const js_deps = new Set(deps.__entry__ ? [...deps.__entry__.js] : []); const css_deps = new Set(deps.__entry__ ? [...deps.__entry__.css] : []); - (page.parts.filter(Boolean) as PageManifestPart[]).forEach((part) => { + (page.parts.filter(Boolean) ).forEach((part) => { const page_deps = deps[part.component.name]; if (!page_deps) return; // we don't have this info during dev @@ -344,8 +344,8 @@ export default async function render_page( } } -function parts_to_params(match: RegExpMatchArray, part: PageManifestPart): RouteParams { - const params: RouteParams = {}; +function parts_to_params(match, part) { + const params = {}; part.params.forEach((name, i) => { const is_spread = /^\.{3}.+$/.test(name); @@ -360,7 +360,7 @@ function parts_to_params(match: RegExpMatchArray, part: PageManifestPart): Route return params; } -function try_serialize(data: any, fail?: (err: Error) => void) { +function try_serialize(data, fail) { try { return devalue(data); } catch (err) { @@ -370,7 +370,7 @@ function try_serialize(data: any, fail?: (err: Error) => void) { } // Ensure we return something truthy so the client will not re-render the page over the error -function serialize_error(error?: Error | null) { +function serialize_error(error) { if (!error) return null; let serialized = try_serialize(error); if (!serialized) { @@ -383,8 +383,8 @@ function serialize_error(error?: Error | null) { return serialized; } -function search_params_to_map(params: URLSearchParams) { - const map: Record = {}; +function search_params_to_map(params) { + const map = {}; for (const key of params.keys()) { const values = params.getAll(key); diff --git a/packages/app-utils/src/types/index.js b/packages/app-utils/src/types/index.js new file mode 100644 index 000000000000..76fe47c37a9f --- /dev/null +++ b/packages/app-utils/src/types/index.js @@ -0,0 +1,121 @@ + + +// do not import this file from outside app-utils +// these types are re-exported in /index.d.ts and should be imported from "@sveltejs/app-utils" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/app-utils/src/types/index.ts b/packages/app-utils/src/types/index.ts deleted file mode 100644 index c3619d15b3a6..000000000000 --- a/packages/app-utils/src/types/index.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { URLSearchParams } from 'url'; - -// do not import this file from outside app-utils -// these types are re-exported in /index.d.ts and should be imported from "@sveltejs/app-utils" - -export type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS'; - -export type Headers = Record; - -export interface IncomingRequest { - host: string | null; // TODO is this actually necessary? - method: Method; - headers: Headers; - body?: any; // TODO - path: string; - query: URLSearchParams; -} - -export interface EndpointResponse { - status: number; - headers: Headers; - body: any; // TODO what types can body be? -} - -export interface PageResponse extends EndpointResponse { - dependencies: Record; -} - -export interface SetupModule { - prepare?: (headers: Headers) => Promise<{ context: Context; headers: Headers }>; - getSession?: (context: Context) => Promise | Session; - setSession?: (context: Context, session: Session) => Promise | Session; -} - -export interface SSRComponentModule { - default: SSRComponent; -} - -export interface SSRComponent { - render( - props: unknown - ): { - html: string; - head: string; - css: { code: string; map: unknown }; - }; -} - -export interface RenderOptions { - only_prerender: boolean; // TODO this shouldn't really be part of the public API - static_dir: string; - template: string; - manifest: RouteManifest; - client: ClientManifest; - root: SSRComponentModule; - setup: SetupModule; - load: (route: PageComponentManifest | EndpointManifest) => Promise; // TODO - dev: boolean; // TODO this is awkward -} - -export type RouteParams = Record; - -export interface PageComponentManifest { - default?: boolean; - type?: string; - url: string; - name: string; - file: string; -} - -export interface PageManifestPart { - component: PageComponentManifest; - params: string[]; -} - -export interface PageManifest { - pattern: RegExp; - path: string; - /** - * Each part contains the parameters for the page (last part) or layout (earlier parts) - * corresponding to a URL segment any part except the last may be null - * if there is no layout for that segment. - */ - parts: Array; -} - -export interface EndpointManifest { - name: string; - pattern: RegExp; - file: string; - url: string; - params: string[]; -} - -export interface RouteManifest { - error: PageComponentManifest; - layout: PageComponentManifest; - components: PageComponentManifest[]; - pages: PageManifest[]; - endpoints: EndpointManifest[]; -} - -export interface ClientManifest { - entry: string; - deps: Record; -} - -export type Loader = (item: PageComponentManifest | EndpointManifest) => Promise; // TODO types for modules - -export type Query = Record; - -export interface Page { - host: string; - path: string; - params: RouteParams; - query: Query; -} - -export interface PageContext extends Page { - error?: Error; -} diff --git a/packages/app-utils/tsconfig.json b/packages/app-utils/tsconfig.json deleted file mode 100644 index bc0aae8bfe91..000000000000 --- a/packages/app-utils/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "ts-node": { - "compilerOptions": { - "module": "commonjs" - } - } -} diff --git a/packages/create-svelte/cli/ambient.d.ts b/packages/create-svelte/cli/ambient.d.ts deleted file mode 100644 index 900cabef1fae..000000000000 --- a/packages/create-svelte/cli/ambient.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare module '*.gitignore'; - -declare module 'gitignore-parser'; - -declare module 'prompts/lib/index'; diff --git a/packages/create-svelte/cli/index.ts b/packages/create-svelte/cli/index.js similarity index 97% rename from packages/create-svelte/cli/index.ts rename to packages/create-svelte/cli/index.js index d717152a675e..b53d083d4442 100644 --- a/packages/create-svelte/cli/index.ts +++ b/packages/create-svelte/cli/index.js @@ -33,7 +33,7 @@ you're on your own for now. We'll have something to show soon. `; -async function main(): Promise { +async function main() { console.log(red(disclaimer)); const target = process.argv[2] || '.'; @@ -102,7 +102,7 @@ async function main(): Promise { console.log('\nStuck? Visit us at https://svelte.dev/chat\n'); } -async function prompt_modifications(target: string) { +async function prompt_modifications(target) { const ts_response = await prompts({ type: 'confirm', name: 'value', diff --git a/packages/create-svelte/cli/modifications/add_css.ts b/packages/create-svelte/cli/modifications/add_css.js similarity index 93% rename from packages/create-svelte/cli/modifications/add_css.ts rename to packages/create-svelte/cli/modifications/add_css.js index 9a6dd6f754ff..5eb3780c1dbf 100644 --- a/packages/create-svelte/cli/modifications/add_css.ts +++ b/packages/create-svelte/cli/modifications/add_css.js @@ -1,7 +1,7 @@ import { bold, green } from 'kleur/colors'; import { add_svelte_prepocess_to_config, update_component, update_package_json } from './utils'; -export default async function add_css(cwd: string, which: 'css' | 'less' | 'scss'): Promise { +export default async function add_css(cwd, which) { if (which === 'css') { console.log(`You can add support for CSS preprocessors like SCSS/Less/PostCSS later.`); } else if (which === 'less') { diff --git a/packages/create-svelte/cli/modifications/add_typescript.ts b/packages/create-svelte/cli/modifications/add_typescript.js similarity index 94% rename from packages/create-svelte/cli/modifications/add_typescript.ts rename to packages/create-svelte/cli/modifications/add_typescript.js index 1009d0ce2eb3..09fefa8052ff 100644 --- a/packages/create-svelte/cli/modifications/add_typescript.ts +++ b/packages/create-svelte/cli/modifications/add_typescript.js @@ -8,7 +8,7 @@ import { update_package_json } from './utils'; -export default async function add_typescript(cwd: string, yes: boolean): Promise { +export default async function add_typescript(cwd, yes) { if (yes) { update_package_json(cwd, { typescript: '^4.0.0', @@ -38,7 +38,7 @@ export default async function add_typescript(cwd: string, yes: boolean): Promise } } -function add_tsconfig(cwd: string): void { +function add_tsconfig(cwd) { fs.writeFileSync( path.join(cwd, 'tsconfig.json'), `{ @@ -70,7 +70,7 @@ function add_tsconfig(cwd: string): void { ); } -function add_d_ts_file(cwd: string): void { +function add_d_ts_file(cwd) { fs.writeFileSync( path.join(cwd, 'src', 'globals.d.ts'), `/// diff --git a/packages/create-svelte/cli/modifications/utils.ts b/packages/create-svelte/cli/modifications/utils.js similarity index 82% rename from packages/create-svelte/cli/modifications/utils.ts rename to packages/create-svelte/cli/modifications/utils.js index 1d04a2377513..d241eb5e6efe 100644 --- a/packages/create-svelte/cli/modifications/utils.ts +++ b/packages/create-svelte/cli/modifications/utils.js @@ -4,7 +4,7 @@ import path from 'path'; /** * Updates package.json with given devDependencies */ -export function update_package_json(cwd: string, newDevDeps: Record): void { +export function update_package_json(cwd, newDevDeps) { const pkg_file = path.join(cwd, 'package.json'); const pkg_json = fs.readFileSync(pkg_file, 'utf-8'); const pkg = JSON.parse(pkg_json); @@ -21,10 +21,10 @@ export function update_package_json(cwd: string, newDevDeps: Record(obj: T): T { +function sortObj(obj) { return Object.keys(obj).reduce((newObj, key) => { - newObj[key] = obj[key]; + newObj[key] = obj[key]; return newObj; - }, {}); + }, {}); } diff --git a/packages/create-svelte/rollup.config.js b/packages/create-svelte/rollup.config.js index 576decd8d812..446ecbdcc1a8 100644 --- a/packages/create-svelte/rollup.config.js +++ b/packages/create-svelte/rollup.config.js @@ -1,9 +1,8 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; -import typescript from 'rollup-plugin-typescript2'; export default { - input: 'cli/index.ts', + input: 'cli/index.js', output: { file: 'bin', format: 'cjs', @@ -13,7 +12,6 @@ export default { plugins: [ nodeResolve(), commonjs(), - typescript(), { transform(code, id) { if (id.endsWith('.gitignore')) { diff --git a/packages/create-svelte/tsconfig.json b/packages/create-svelte/tsconfig.json deleted file mode 100644 index fed0ed269ea1..000000000000 --- a/packages/create-svelte/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "resolveJsonModule": true, - "module": "esnext", - "moduleResolution": "node", - "target": "ES2017", - "esModuleInterop": true - }, - "include": ["cli/**/*"], - "lib": ["ES2020", "dom", "node"] -} diff --git a/packages/kit/client/tsconfig.json b/packages/kit/client/tsconfig.json deleted file mode 100644 index 1de91c9dabc8..000000000000 --- a/packages/kit/client/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - /* Generates the typings for client code */ - "compilerOptions": { - "resolveJsonModule": true, - "module": "esnext", - "moduleResolution": "node", - "target": "ES6", - "esModuleInterop": true, - "declaration": true, - "outDir": "." - }, - "include": ["../src/client/**/*", "../src/ambient.d.ts"], - "lib": ["ES2020", "dom", "node"] -} diff --git a/packages/kit/index.d.ts b/packages/kit/index.d.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/kit/package.json b/packages/kit/package.json index 74bacb514d23..73261b067209 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -26,8 +26,7 @@ "require-relative": "^0.8.7", "sirv": "^1.0.7", "source-map-support": "^0.5.19", - "svelte": "^3.29.0", - "typescript": "^4.0.5" + "svelte": "^3.29.0" }, "bin": { "svelte": "svelte-kit" @@ -39,7 +38,7 @@ ], "scripts": { "dev": "rollup -cw", - "build": "rollup -c && cd client && tsc", + "build": "rollup -c", "lint": "eslint --ignore-pattern node_modules/ --ignore-pattern dist/ \"**/*.{ts,mjs,js,svelte}\" && npm run check-format", "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore", "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", diff --git a/packages/kit/rollup.config.js b/packages/kit/rollup.config.js index 3021be4e6a43..189cab99c17c 100644 --- a/packages/kit/rollup.config.js +++ b/packages/kit/rollup.config.js @@ -1,9 +1,7 @@ import commonjs from '@rollup/plugin-commonjs'; import json from '@rollup/plugin-json'; import resolve from '@rollup/plugin-node-resolve'; -import typescript from 'rollup-plugin-typescript2'; import pkg from './package.json'; -import { readFileSync, writeFileSync } from 'fs'; const external = [].concat( Object.keys(pkg.dependencies || {}), @@ -14,8 +12,8 @@ const external = [].concat( export default [ { input: { - navigation: 'src/runtime/navigation/index.ts', - stores: 'src/runtime/stores/index.ts' + navigation: 'src/runtime/navigation/index.js', + stores: 'src/runtime/stores/index.js' }, output: { dir: 'assets/runtime', @@ -30,29 +28,12 @@ export default [ plugins: [ resolve({ extensions: ['.mjs', '.js', '.ts'] - }), - typescript(/*{ - tsconfigDefaults: { - compilerOptions: { - // create typings. these options do not apply to the other build target - declaration: true, - emitDeclarationOnly: true, - outFile: './index.js' - } - }, - useTsconfigDeclarationDir: true - }*/), - /*{ - name: 'adjust-typings', - resolveId: () => null, - load: () => null, - writeBundle: adjust_typings - }*/ + }) ] }, { - input: [`src/cli.ts`], + input: ['src/cli.js'], output: { dir: 'dist', format: 'cjs', @@ -68,31 +49,8 @@ export default [ resolve({ extensions: ['.mjs', '.js', '.ts'] }), - commonjs(), - typescript() + commonjs() ], preserveEntrySignatures: false } -]; - -/** - * Remove the typings that do not refer to the runtime and fix the module names - * (e.g. change "src/runtime/navigation/goto/index" to "$app/navigation/goto") - */ -function adjust_typings() { - const alias = '$app'; - - const typings_file = 'index.d.ts'; - - const only_runtime = (code) => - Array.from(code.matchAll(/declare module "src\/runtime\/.*?\n}/gms)) - .map((m) => m[0]) - .join('\n\n'); - - const code = only_runtime(readFileSync(typings_file, 'utf8')).replace( - / (module|from) ['"]src\/runtime\/(.+?)(\/index)?['"]/g, - ` $1 "${alias}/$2"` - ); - - writeFileSync(typings_file, code); -} +]; \ No newline at end of file diff --git a/packages/kit/src/ambient.d.ts b/packages/kit/src/ambient.d.ts deleted file mode 100644 index 90164201ade0..000000000000 --- a/packages/kit/src/ambient.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -declare module 'MANIFEST' { - import { SvelteComponent } from 'svelte'; - - export type Route = { - pattern: RegExp; - parts: { - params: (match: RegExpExecArray) => Record; - i: number; - }[]; - }; - - export const components: (() => SvelteComponent)[]; - export const routes: Route[]; - export const layout: SvelteComponent; - export const ErrorComponent: SvelteComponent; -} - -declare module 'ROOT' { - import { SvelteComponent } from 'svelte'; - - type Constructor = { - new (...args: any[]): T; - }; - - const root: Constructor; - export default root; -} diff --git a/packages/kit/src/api/build/css_injection.ts b/packages/kit/src/api/build/css_injection.js similarity index 78% rename from packages/kit/src/api/build/css_injection.ts rename to packages/kit/src/api/build/css_injection.js index 7a97cbcce3bd..510c0f8f599b 100644 --- a/packages/kit/src/api/build/css_injection.ts +++ b/packages/kit/src/api/build/css_injection.js @@ -1,11 +1,11 @@ -import { - Plugin, - PluginContext, - NormalizedOutputOptions, - OutputBundle, - OutputChunk, - RenderedChunk -} from 'rollup'; + + + + + + + + const inject_styles = ` export default function(files) { @@ -37,11 +37,11 @@ export default function(files) { const INJECT_STYLES_NAME = 'inject_styles'; const INJECT_STYLES_ID = 'inject_styles.js'; -const find_css = (chunk: RenderedChunk, bundle: OutputBundle) => { - const css_files = new Set(); - const visited = new Set(); +const find_css = (chunk, bundle) => { + const css_files = new Set(); + const visited = new Set(); - const recurse = (c: RenderedChunk) => { + const recurse = (c) => { if (visited.has(c)) return; visited.add(c); @@ -50,7 +50,7 @@ const find_css = (chunk: RenderedChunk, bundle: OutputBundle) => { if (file.endsWith('.css')) { css_files.add(file); } else { - const imported_chunk = bundle[file]; + const imported_chunk = bundle[file]; if (imported_chunk) { recurse(imported_chunk); } @@ -63,9 +63,9 @@ const find_css = (chunk: RenderedChunk, bundle: OutputBundle) => { return Array.from(css_files); }; -export const css_injection: Plugin = { +export const css_injection = { name: 'svelte-css-injection', - buildStart(this: PluginContext): void { + buildStart() { this.emitFile({ type: 'chunk', id: INJECT_STYLES_ID, @@ -73,10 +73,10 @@ export const css_injection: Plugin = { preserveSignature: 'allow-extension' }); }, - load(id: string) { + load(id) { return id === INJECT_STYLES_ID ? inject_styles : null; }, - resolveId(importee: string) { + resolveId(importee) { return importee === INJECT_STYLES_ID ? INJECT_STYLES_ID : null; }, renderDynamicImport({ targetModuleId }) { @@ -94,24 +94,24 @@ export const css_injection: Plugin = { } }, async generateBundle( - this: PluginContext, - _options: NormalizedOutputOptions, - bundle: OutputBundle - ): Promise { + + _options, + bundle + ) { const inject_styles_file = Object.keys(bundle).find((f) => f.startsWith('inject_styles')); let has_css = false; for (const name in bundle) { - const chunk = bundle[name]; + const chunk = bundle[name]; let chunk_has_css = false; if (chunk.code) { chunk.code = chunk.code.replace(/___SVELTE_CSS_INJECTION___([0-9a-f]+)___/g, (_m, id) => { id = Buffer.from(id, 'hex').toString(); - const target = ( + const target = ( Object.values(bundle).find( - (c) => (c).modules && (c).modules[id] + (c) => (c).modules && (c).modules[id] ) ); diff --git a/packages/kit/src/api/build/index.ts b/packages/kit/src/api/build/index.js similarity index 89% rename from packages/kit/src/api/build/index.ts rename to packages/kit/src/api/build/index.js index 7ee87db634d6..31ea8c704f57 100644 --- a/packages/kit/src/api/build/index.ts +++ b/packages/kit/src/api/build/index.js @@ -6,12 +6,12 @@ import colors from 'kleur'; import relative from 'require-relative'; import { mkdirp } from '@sveltejs/app-utils/files'; import create_manifest_data from '../../core/create_manifest_data'; -import { rollup, OutputChunk } from 'rollup'; +import { rollup, } from 'rollup'; import { terser } from 'rollup-plugin-terser'; import css_chunks from 'rollup-plugin-css-chunks'; import { copy_assets } from '../utils'; import { create_app } from '../../core/create_app'; -import { SvelteAppConfig } from '../../interfaces'; + import { css_injection } from './css_injection'; const exec = promisify(child_process.exec); @@ -30,7 +30,7 @@ const onwarn = (warning, handler) => { handler(warning); }; -export async function build(config: SvelteAppConfig) { +export async function build(config) { if (!config.adapter) { throw new Error('No adapter specified'); } @@ -167,25 +167,25 @@ export async function build(config: SvelteAppConfig) { const reverse_lookup = new Map(); const routes = path.resolve(`${unoptimized}/client/_app/routes`); - const client: { - entry: string; - deps: Record; - } = { + const client + + + = { entry: null, deps: {} }; - let inject_styles: string; + let inject_styles; for (const key in bundle) { const chunk = bundle[key]; - if ((chunk as OutputChunk).facadeModuleId === entry) { + if ((chunk ).facadeModuleId === entry) { client.entry = key; - } else if ((chunk as OutputChunk).facadeModuleId === 'inject_styles.js') { + } else if ((chunk ).facadeModuleId === 'inject_styles.js') { inject_styles = key; - } else if ((chunk as OutputChunk).modules) { - for (const id in (chunk as OutputChunk).modules) { + } else if ((chunk ).modules) { + for (const id in (chunk ).modules) { if (id.startsWith(routes) && id.endsWith('.js')) { const file = id.slice(routes.length + 1); reverse_lookup.set(file, key); @@ -202,7 +202,7 @@ export async function build(config: SvelteAppConfig) { const chunk = bundle[key]; if (chunk) { - const imports = (chunk as OutputChunk).imports; + const imports = (chunk ).imports; if (imports) { imports.forEach((key) => { @@ -222,8 +222,8 @@ export async function build(config: SvelteAppConfig) { }; const get_deps = (key) => { - const js: Set = new Set(); - const css: Set = new Set(); + const js = new Set(); + const css = new Set(); find_deps(key, js, css); @@ -286,8 +286,8 @@ export async function build(config: SvelteAppConfig) { log.success('done'); } -async function rimraf(path: string): Promise { +async function rimraf(path) { return new Promise((resolve) => { - ((fs).rm || fs.rmdir)(path, { recursive: true, force: true }, () => resolve()); + ((fs).rm || fs.rmdir)(path, { recursive: true, force: true }, () => resolve()); }); } diff --git a/packages/kit/src/api/dev/index.ts b/packages/kit/src/api/dev/index.js similarity index 81% rename from packages/kit/src/api/dev/index.ts rename to packages/kit/src/api/dev/index.js index 45fb87b059cc..3f5431008747 100644 --- a/packages/kit/src/api/dev/index.ts +++ b/packages/kit/src/api/dev/index.js @@ -5,40 +5,40 @@ import { scorta } from 'scorta/sync'; import * as ports from 'port-authority'; import sirv from 'sirv'; import create_manifest_data from '../../core/create_manifest_data'; -import { createServer, Server } from 'http'; +import { createServer, } from 'http'; import { create_app } from '../../core/create_app'; -import snowpack, { SnowpackDevServer, SnowpackConfig } from 'snowpack'; +import snowpack, { } from 'snowpack'; import pkg from '../../../package.json'; import loader from './loader'; -import { ManifestData, ReadyEvent } from '../../interfaces'; + import { mkdirp } from '@sveltejs/app-utils/files'; import { render } from '@sveltejs/app-utils/renderer'; import { get_body } from '@sveltejs/app-utils/http'; -import { SSRComponentModule, SetupModule, Method } from '@sveltejs/app-utils'; -import { DevConfig, Loader } from './types'; + + import { copy_assets } from '../utils'; import { readFileSync } from 'fs'; -export function dev(opts: DevConfig): Promise { +export function dev(opts) { return new Watcher(opts).init(); } class Watcher extends EventEmitter { - cachedir: string; - opts: DevConfig; - manifest: ManifestData; + + + - cheapwatch: CheapWatch; + - snowpack_port: number; - snowpack_config: SnowpackConfig; - snowpack: SnowpackDevServer; - server: Server; + + + + - constructor(opts: DevConfig) { + constructor(opts) { super(); - this.cachedir = scorta('svelte') as string; + this.cachedir = scorta('svelte') ; this.opts = opts; this.update(); @@ -58,7 +58,7 @@ class Watcher extends EventEmitter { this.emit('ready', { port: this.opts.port - } as ReadyEvent); + } ); return this; } @@ -74,11 +74,11 @@ class Watcher extends EventEmitter { await this.init_server(); // not sure why TS doesn't understand that CheapWatch extends EventEmitter - ((this.cheapwatch as any) as EventEmitter).on('+', ({ isNew }) => { + ((this.cheapwatch ) ).on('+', ({ isNew }) => { if (isNew) this.update(); }); - ((this.cheapwatch as any) as EventEmitter).on('-', () => { + ((this.cheapwatch ) ).on('-', () => { this.update(); }); } @@ -104,7 +104,7 @@ class Watcher extends EventEmitter { async init_server() { const { port } = this.opts; const { snowpack_port } = this; - const load: Loader = loader(this.snowpack, this.snowpack_config); + const load = loader(this.snowpack, this.snowpack_config); const static_handler = sirv('static', { dev: true @@ -136,7 +136,7 @@ class Watcher extends EventEmitter { ); const parsed = parse(req.url); - let setup: SetupModule; + let setup; try { setup = await load('/_app/setup/index.js'); @@ -145,7 +145,7 @@ class Watcher extends EventEmitter { setup = {}; } - let root: SSRComponentModule; + let root; try { root = await load('/_app/main/generated/root.js'); @@ -160,8 +160,8 @@ class Watcher extends EventEmitter { const rendered = await render( { host: req.headers.host, - headers: req.headers as Record, - method: req.method as Method, + headers: req.headers , + method: req.method , path: parsed.pathname, query: new URLSearchParams(parsed.query), body diff --git a/packages/kit/src/api/dev/loader.ts b/packages/kit/src/api/dev/loader.js similarity index 87% rename from packages/kit/src/api/dev/loader.ts rename to packages/kit/src/api/dev/loader.js index 24dd3640100d..26556d322076 100644 --- a/packages/kit/src/api/dev/loader.ts +++ b/packages/kit/src/api/dev/loader.js @@ -3,17 +3,17 @@ import { resolve, relative } from 'path'; import * as meriyah from 'meriyah'; import MagicString from 'magic-string'; import { extract_names } from 'periscopic'; -import { Loader } from './types'; -import { SnowpackConfig, SnowpackDevServer } from 'snowpack'; + + import { walk } from 'estree-walker'; // This function makes it possible to load modules from the 'server' // snowpack server, for the sake of SSR -export default function loader(snowpack: SnowpackDevServer, config: SnowpackConfig): Loader { - const cache = new Map>(); - const graph = new Map>(); +export default function loader(snowpack, config) { + const cache = new Map(); + const graph = new Map(); - const get_module = (importer: string, imported: string, url_stack: string[]) => { + const get_module = (importer, imported, url_stack) => { if (imported[0] === '/' || imported[0] === '.') { const { pathname } = new URL(imported, `http://localhost${importer}`); @@ -48,7 +48,7 @@ export default function loader(snowpack: SnowpackDevServer, config: SnowpackConf } }); - async function load(url: string, url_stack: string[]) { + async function load(url, url_stack) { // TODO: meriyah (JS parser) doesn't support `import.meta.hot = ...` used in HMR setup code. if (url.endsWith('.css.proxy.js')) { return null; @@ -77,7 +77,7 @@ export default function loader(snowpack: SnowpackDevServer, config: SnowpackConf return exports; } - async function initialize_module(url: string, data: string, url_stack: string[]) { + async function initialize_module(url, data, url_stack) { const code = new MagicString(data); const ast = meriyah.parseModule(data, { ranges: true, @@ -124,7 +124,7 @@ export default function loader(snowpack: SnowpackDevServer, config: SnowpackConf if (node.specifiers && node.specifiers.length > 0) { code.remove(node.start, node.specifiers[0].start); - node.specifiers.forEach((specifier: meriyah.ESTree.ExportSpecifier) => { + node.specifiers.forEach((specifier) => { const lhs = `exports.${specifier.exported.name}`; const rhs = node.source ? `${export_from_identifiers.get(node.source)}.${specifier.local.name}` @@ -141,7 +141,7 @@ export default function loader(snowpack: SnowpackDevServer, config: SnowpackConf const names = []; node.declaration.declarations.forEach((declarator) => { - names.push(...extract_names(declarator.id as any)); + names.push(...extract_names(declarator.id )); }); code.appendLeft(node.end, names.map((name) => ` exports.${name} = ${name};`).join('')); @@ -159,7 +159,7 @@ export default function loader(snowpack: SnowpackDevServer, config: SnowpackConf // replace import.meta and import(dynamic) if (/import\s*\.\s*meta/.test(data) || /import\s*\(/.test(data)) { walk(ast.body, { - enter(node: any) { + enter(node) { if (node.type === 'MetaProperty' && node.meta.name === 'import') { code.overwrite(node.start, node.end, '__importmeta__'); } else if (node.type === 'ImportExpression') { @@ -244,7 +244,7 @@ export default function loader(snowpack: SnowpackDevServer, config: SnowpackConf return (url) => load(url, []); } -function load_node(source: string) { +function load_node(source) { // mirror Rollup's interop by allowing both of these: // import fs from 'fs'; // import { readFileSync } from 'fs'; @@ -256,10 +256,10 @@ function load_node(source: string) { }); } -function map_keys(object: Record, map: (key: string) => string): Record { - return Object.entries(object).reduce((new_object, [k, v]) => { +function map_keys(object, map) { + return Object.entries(object).reduce((new_object, [k, v]) => { new_object[map(k)] = v; return new_object; - }, {} as Record); + }, {} ); } diff --git a/packages/kit/src/api/dev/sourcemap_stacktrace.ts b/packages/kit/src/api/dev/sourcemap_stacktrace.js similarity index 81% rename from packages/kit/src/api/dev/sourcemap_stacktrace.ts rename to packages/kit/src/api/dev/sourcemap_stacktrace.js index fe574c9cc21f..6e98294736c8 100644 --- a/packages/kit/src/api/dev/sourcemap_stacktrace.ts +++ b/packages/kit/src/api/dev/sourcemap_stacktrace.js @@ -1,8 +1,8 @@ import fs from 'fs'; import path from 'path'; -import { SourceMapConsumer, RawSourceMap } from 'source-map'; +import { SourceMapConsumer, } from 'source-map'; -function get_sourcemap_url(contents: string) { +function get_sourcemap_url(contents) { const reversed = contents.split('\n').reverse().join('\n'); const match = /\/[/*]#[ \t]+sourceMappingURL=([^\s'"]+?)(?:[ \t]+|$)/gm.exec(reversed); @@ -11,9 +11,9 @@ function get_sourcemap_url(contents: string) { return undefined; } -const file_cache = new Map(); +const file_cache = new Map(); -function get_file_contents(path: string) { +function get_file_contents(path) { if (file_cache.has(path)) { return file_cache.get(path); } @@ -22,13 +22,13 @@ function get_file_contents(path: string) { const data = fs.readFileSync(path, 'utf8'); file_cache.set(path, data); return data; - } catch { + } catch (e) { return undefined; } } -export function sourcemap_stacktrace(stack: string) { - const replace = (line: string) => +export function sourcemap_stacktrace(stack) { + const replace = (line) => line.replace( /^ {4}at (?:(.+?)\s+\()?(?:(.+?):(\d+)(?::(\d+))?)\)?/, (input, var_name, file_path, line, column) => { @@ -41,13 +41,13 @@ export function sourcemap_stacktrace(stack: string) { if (!sourcemap_url) return input; let dir = path.dirname(file_path); - let sourcemap_data: string; + let sourcemap_data; if (/^data:application\/json[^,]+base64,/.test(sourcemap_url)) { const raw_data = sourcemap_url.slice(sourcemap_url.indexOf(',') + 1); try { sourcemap_data = Buffer.from(raw_data, 'base64').toString(); - } catch { + } catch (e2) { return input; } } else { @@ -60,16 +60,16 @@ export function sourcemap_stacktrace(stack: string) { dir = path.dirname(sourcemap_path); } - let raw_sourcemap: RawSourceMap; + let raw_sourcemap; try { raw_sourcemap = JSON.parse(sourcemap_data); - } catch { + } catch (e3) { return input; } // TODO: according to typings, this code cannot work; // the constructor returns a promise that needs to be awaited - const consumer = new (SourceMapConsumer as any)(raw_sourcemap); + const consumer = new (SourceMapConsumer )(raw_sourcemap); const pos = consumer.originalPositionFor({ line: Number(line), column: Number(column), diff --git a/packages/kit/src/api/dev/types.js b/packages/kit/src/api/dev/types.js new file mode 100644 index 000000000000..db9976f08894 --- /dev/null +++ b/packages/kit/src/api/dev/types.js @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/kit/src/api/dev/types.ts b/packages/kit/src/api/dev/types.ts deleted file mode 100644 index f00d189d0ed4..000000000000 --- a/packages/kit/src/api/dev/types.ts +++ /dev/null @@ -1,46 +0,0 @@ -export type Loader = (url: string) => Promise; - -export type Query = Record; - -export type Params = Record; - -export interface Request { - host: string; - path: string; - query: Query; - params: Params; -} - -export interface Response { - status?: number; - text?: string; - headers?: Record; - body: any; -} - -export interface ServerRoute { - get?: (request?: Request, session?: any) => Response | Promise; - post?: (request?: Request, session?: any) => Response | Promise; - put?: (request?: Request, session?: any) => Response | Promise; - del?: (request?: Request, session?: any) => Response | Promise; -} - -export interface PageComponent { - default: { - render: ( - props: Record - ) => { - html: string; - head: string; - css: { - code: string; - map: any; // TODO - }; - }; - }; - preload?: (page?: Request, session?: any) => Record; -} - -export interface DevConfig { - port: number; -} diff --git a/packages/kit/src/api/utils.ts b/packages/kit/src/api/utils.js similarity index 100% rename from packages/kit/src/api/utils.ts rename to packages/kit/src/api/utils.js diff --git a/packages/kit/src/cli.ts b/packages/kit/src/cli.js similarity index 85% rename from packages/kit/src/cli.ts rename to packages/kit/src/cli.js index 4bb11be2850c..31e322e5fee1 100644 --- a/packages/kit/src/cli.ts +++ b/packages/kit/src/cli.js @@ -2,9 +2,9 @@ import relative from 'require-relative'; import sade from 'sade'; import colors from 'kleur'; import * as pkg from '../package.json'; -import { ReadyEvent, SvelteAppConfig } from './interfaces'; -let config: SvelteAppConfig; + +let config; try { config = relative('./svelte.config.js', process.cwd()); @@ -23,7 +23,7 @@ prog .describe('Start a development server') .option('-p, --port', 'Dev server port', 3000) .option('-o, --open', 'Open a browser tab', false) - .action(async (opts: { port: number; open: boolean }) => { + .action(async (opts) => { const { dev } = await import('./api/dev'); try { @@ -41,7 +41,7 @@ prog process.stderr.write(data); }); - watcher.on('ready', async (event: ReadyEvent) => { + watcher.on('ready', async (event) => { if (first) { console.log(colors.bold().cyan(`> Listening on http://localhost:${event.port}`)); if (opts.open) { @@ -73,4 +73,4 @@ prog } }); -prog.parse(process.argv, { unknown: (arg: string) => `Unknown option: ${arg}` }); +prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` }); diff --git a/packages/kit/src/core/create_app.ts b/packages/kit/src/core/create_app.js similarity index 83% rename from packages/kit/src/core/create_app.ts rename to packages/kit/src/core/create_app.js index 58049c173611..38e7e9c02c7b 100644 --- a/packages/kit/src/core/create_app.ts +++ b/packages/kit/src/core/create_app.js @@ -1,16 +1,16 @@ import * as fs from 'fs'; import { mkdirp } from '@sveltejs/app-utils/files'; import { stringify, walk, write_if_changed } from '../utils'; -import { ManifestData } from '../interfaces'; -import { PageManifest } from '@sveltejs/app-utils'; + + export function create_app({ manifest_data, output -}: { - manifest_data: ManifestData; - output: string; -}) { +} + + +) { if (!fs.existsSync(output)) mkdirp(output); const client_manifest = generate_client_manifest(manifest_data); @@ -26,13 +26,13 @@ export function create_serviceworker_manifest({ output, client_files, static_files -}: { - manifest_data: ManifestData; - output: string; - client_files: string[]; - static_files: string; -}) { - let files: string[] = ['service-worker-index.html']; +} + + + + +) { + let files = ['service-worker-index.html']; if (fs.existsSync(static_files)) { files = files.concat(walk(static_files)); @@ -42,13 +42,13 @@ export function create_serviceworker_manifest({ // This file is generated by @sveltejs/kit — do not edit it! export const timestamp = ${Date.now()}; - export const files = [\n\t${files.map((x: string) => stringify('/' + x)).join(',\n\t')}\n]; + export const files = [\n\t${files.map((x) => stringify('/' + x)).join(',\n\t')}\n]; export { files as assets }; // legacy - export const shell = [\n\t${client_files.map((x: string) => stringify('/' + x)).join(',\n\t')}\n]; + export const shell = [\n\t${client_files.map((x) => stringify('/' + x)).join(',\n\t')}\n]; export const routes = [\n\t${manifest_data.pages - .map((r: PageManifest) => `{ pattern: ${r.pattern} }`) + .map((r) => `{ pattern: ${r.pattern} }`) .join(',\n\t')}\n]; ` .replace(/^\t\t/gm, '') @@ -57,14 +57,14 @@ export function create_serviceworker_manifest({ write_if_changed(`${output}/service-worker.js`, code); } -function create_param_match(param: string, i: number) { +function create_param_match(param, i) { return /^\.{3}.+$/.test(param) ? `${param.replace(/.{3}/, '')}: d(match[${i + 1}]).split('/')` : `${param}: d(match[${i + 1}])`; } -function generate_client_manifest(manifest_data: ManifestData) { - const component_indexes: Record = {}; +function generate_client_manifest(manifest_data) { + const component_indexes = {}; const components = `[ ${manifest_data.components @@ -124,7 +124,7 @@ function generate_client_manifest(manifest_data: ManifestData) { .trim(); } -function generate_app(manifest_data: ManifestData) { +function generate_app(manifest_data) { // TODO remove default layout altogether const max_depth = Math.max( diff --git a/packages/kit/src/core/create_manifest_data.ts b/packages/kit/src/core/create_manifest_data.js similarity index 86% rename from packages/kit/src/core/create_manifest_data.ts rename to packages/kit/src/core/create_manifest_data.js index 18ae78a25b27..14b4237cf216 100644 --- a/packages/kit/src/core/create_manifest_data.ts +++ b/packages/kit/src/core/create_manifest_data.js @@ -1,16 +1,16 @@ import * as fs from 'fs'; import * as path from 'path'; -import { ManifestData } from '../interfaces'; -import { PageManifest, PageComponentManifest, EndpointManifest } from '@sveltejs/app-utils'; + + import { posixify, reserved_words } from '../utils'; export default function create_manifest_data( - cwd: string, - extensions: string = '.svelte .html' -): ManifestData { + cwd, + extensions = '.svelte .html' +) { const component_extensions = extensions.split(' '); - function find_layout(file_name: string, component_name: string, dir: string = '') { + function find_layout(file_name, component_name, dir = '') { const ext = component_extensions.find((ext) => fs.existsSync(path.join(cwd, dir, `${file_name}${ext}`)) ); @@ -26,30 +26,30 @@ export default function create_manifest_data( : null; } - const components: PageComponentManifest[] = []; - const pages: PageManifest[] = []; - const endpoints: EndpointManifest[] = []; + const components = []; + const pages = []; + const endpoints = []; - const default_layout: PageComponentManifest = { + const default_layout = { name: '$default_layout', file: null, url: '/_app/main/components/layout.svelte' }; - const default_error: PageComponentManifest = { + const default_error = { name: '$default_error', file: null, url: '/_app/main/components/error.svelte' }; function walk( - dir: string, - parent_segments: Part[][], - parent_params: string[], - stack: Array<{ - component: PageComponentManifest; - params: string[]; - }> + dir, + parent_segments, + parent_params, + stack + + + ) { const items = fs .readdirSync(dir) @@ -179,7 +179,7 @@ export default function create_manifest_data( walk(cwd, [], [], []); // check for clashes - const seen_pages: Map = new Map(); + const seen_pages = new Map(); pages.forEach((page) => { const pattern = page.pattern.toString(); if (seen_pages.has(pattern)) { @@ -193,7 +193,7 @@ export default function create_manifest_data( seen_pages.set(pattern, page); }); - const seen_routes: Map = new Map(); + const seen_routes = new Map(); endpoints.forEach((route) => { const pattern = route.pattern.toString(); if (seen_routes.has(pattern)) { @@ -213,21 +213,21 @@ export default function create_manifest_data( }; } -type Part = { - content: string; - dynamic: boolean; - qualifier?: string; - spread?: boolean; -}; -function is_spread(path: string) { + + + + + + +function is_spread(path) { const spread_pattern = /\[\.{3}/g; return spread_pattern.test(path); } function comparator( - a: { basename: string; parts: Part[]; file: string; is_index: boolean }, - b: { basename: string; parts: Part[]; file: string; is_index: boolean } + a, + b ) { if (a.is_index !== b.is_index) { if (a.is_index) return is_spread(a.file) ? 1 : -1; @@ -282,7 +282,7 @@ function comparator( } } -function get_parts(part: string): Part[] { +function get_parts(part) { return part .split(/\[(.+?\(.+?\)|.+?)\]/) .map((str, i) => { @@ -301,7 +301,7 @@ function get_parts(part: string): Part[] { .filter(Boolean); } -function get_slug(file: string) { +function get_slug(file) { let name = file .replace(/[\\/]index/, '') .replace(/[/\\]/g, '_') @@ -315,7 +315,7 @@ function get_slug(file: string) { return name; } -function get_pattern(segments: Part[][], add_trailing_slash: boolean) { +function get_pattern(segments, add_trailing_slash) { const path = segments .map((segment) => { return segment diff --git a/packages/kit/src/interfaces.js b/packages/kit/src/interfaces.js new file mode 100644 index 000000000000..874c19839ab8 --- /dev/null +++ b/packages/kit/src/interfaces.js @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// export interface BuildEvent { +// type: string; +// errors: Array<{ file: string; message: string; duplicate: boolean }>; +// warnings: Array<{ file: string; message: string; duplicate: boolean }>; +// duration: number; +// result: CompileResult; +// } diff --git a/packages/kit/src/interfaces.ts b/packages/kit/src/interfaces.ts deleted file mode 100644 index f8305c154c3a..000000000000 --- a/packages/kit/src/interfaces.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { PageComponentManifest, PageManifest, EndpointManifest } from '@sveltejs/app-utils'; - -export interface SvelteAppConfig { - adapter: string; -} - -export interface Route { - id: string; - handlers: Array<{ - type: 'page' | 'route'; - file: string; - }>; - pattern: RegExp; - test: (url: string) => boolean; - exec: (url: string) => Record; - parts: string[]; - params: string[]; -} - -export interface Template { - render: (data: Record) => string; - stream: (req, res, data: Record>) => void; -} - -export interface WritableStore { - set: (value: T) => void; - update: (fn: (value: T) => T) => void; - subscribe: (fn: (T: any) => void) => () => void; -} - -export interface Dirs { - dest: string; - src: string; - routes: string; -} - -export interface ManifestData { - error: PageComponentManifest; - layout: PageComponentManifest; - components: PageComponentManifest[]; - pages: PageManifest[]; - endpoints: EndpointManifest[]; -} - -export interface ReadyEvent { - port: number; -} - -export interface ErrorEvent { - type: string; - error: Error & { - frame?: unknown; - loc?: { - file?: string; - line: number; - column: number; - }; - }; -} - -export interface FatalEvent { - message: string; - log?: unknown; -} - -export interface InvalidEvent { - changed: string[]; - invalid: { - client: boolean; - server: boolean; - serviceworker: boolean; - }; -} - -// export interface BuildEvent { -// type: string; -// errors: Array<{ file: string; message: string; duplicate: boolean }>; -// warnings: Array<{ file: string; message: string; duplicate: boolean }>; -// duration: number; -// result: CompileResult; -// } diff --git a/packages/kit/src/runtime/navigation/goto/index.ts b/packages/kit/src/runtime/navigation/goto/index.js similarity index 77% rename from packages/kit/src/runtime/navigation/goto/index.ts rename to packages/kit/src/runtime/navigation/goto/index.js index 87c120b10077..f8f4de01ce65 100644 --- a/packages/kit/src/runtime/navigation/goto/index.ts +++ b/packages/kit/src/runtime/navigation/goto/index.js @@ -2,9 +2,9 @@ import { cid, history, navigate, select_target } from '../internal'; import { get_base_uri } from '../utils'; export default function goto( - href: string, - opts: { noscroll?: boolean; replaceState?: boolean } = { noscroll: false, replaceState: false } -): Promise { + href, + opts = { noscroll: false, replaceState: false } +) { const target = select_target(new URL(href, get_base_uri(document))); if (target) { diff --git a/packages/kit/src/runtime/navigation/index.ts b/packages/kit/src/runtime/navigation/index.js similarity index 100% rename from packages/kit/src/runtime/navigation/index.ts rename to packages/kit/src/runtime/navigation/index.js diff --git a/packages/kit/src/runtime/navigation/internal.ts b/packages/kit/src/runtime/navigation/internal.js similarity index 81% rename from packages/kit/src/runtime/navigation/internal.ts rename to packages/kit/src/runtime/navigation/internal.js index f66f7558d5be..f42b2a95e5ae 100644 --- a/packages/kit/src/runtime/navigation/internal.ts +++ b/packages/kit/src/runtime/navigation/internal.js @@ -1,28 +1,28 @@ -import { ScrollPosition, Target, Page, Query } from './types'; + import { find_anchor } from './utils'; import { routes } from 'MANIFEST'; export let uid = 1; -export function set_uid(n: number) { +export function set_uid(n) { uid = n; } -export let cid: number; -export function set_cid(n: number) { +export let cid; +export function set_cid(n) { cid = n; } -const _history: History = +const _history = typeof history !== 'undefined' ? history : (({ pushState: () => {}, replaceState: () => {}, scrollRestoration: 'auto' - } as Partial) as any); + } ) ); export { _history as history }; -export const scroll_history: Record = {}; +export const scroll_history = {}; export async function load_current_page() { const { hash, href } = location; @@ -33,10 +33,10 @@ export async function load_current_page() { if (target) return navigate(target, uid, true, hash); } -let base_url: string; -let handle_target: (dest: Target) => Promise; +let base_url; +let handle_target; -export function init(base: string, handler: (dest: Target) => Promise): void { +export function init(base, handler) { base_url = base; handle_target = handler; @@ -61,8 +61,8 @@ export function init(base: string, handler: (dest: Target) => Promise): vo addEventListener('popstate', handle_popstate); } -export function extract_query(search: string): Query { - const query: Query = Object.create(null); +export function extract_query(search) { + const query = Object.create(null); search .slice(1) @@ -80,7 +80,7 @@ export function extract_query(search: string): Query { return query; } -export function select_target(url: URL): Target { +export function select_target(url) { if (url.origin !== location.origin) return null; if (!url.pathname.startsWith(base_url)) return null; @@ -103,21 +103,21 @@ export function select_target(url: URL): Target { const part = route.parts[route.parts.length - 1]; const params = part.params ? part.params(match) : {}; - const page: Page = { host: location.host, path, query, params }; + const page = { host: location.host, path, query, params }; return { href: url.href, route, match, page }; } } } -function handle_click(event: MouseEvent) { +function handle_click(event) { // Adapted from https://github.com/visionmedia/page.js // MIT license https://github.com/visionmedia/page.js#license if (which(event) !== 1) return; if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; if (event.defaultPrevented) return; - const a = find_anchor(event.target); + const a = find_anchor(event.target); if (!a) return; if (!a.href) return; @@ -125,7 +125,7 @@ function handle_click(event: MouseEvent) { // check if link is inside an svg // in this case, both href and target are always inside an object const svg = typeof a.href === 'object' && a.href.constructor.name === 'SVGAnimatedString'; - const href = String(svg ? (a).href.baseVal : a.href); + const href = String(svg ? (a).href.baseVal : a.href); if (href === location.href) { if (!location.hash) event.preventDefault(); @@ -138,7 +138,7 @@ function handle_click(event: MouseEvent) { if (a.hasAttribute('download') || a.getAttribute('rel') === 'external') return; // Ignore if has a target - if (svg ? (a).target.baseVal : a.target) return; + if (svg ? (a).target.baseVal : a.target) return; const url = new URL(href); @@ -154,7 +154,7 @@ function handle_click(event: MouseEvent) { } } -function which(event: MouseEvent) { +function which(event) { return event.which === null ? event.button : event.which; } @@ -165,7 +165,7 @@ function scroll_state() { }; } -function handle_popstate(event: PopStateEvent) { +function handle_popstate(event) { scroll_history[cid] = scroll_state(); if (event.state) { @@ -186,11 +186,11 @@ function handle_popstate(event: PopStateEvent) { } export async function navigate( - dest: Target, - id: number, - noscroll?: boolean, - hash?: string -): Promise { + dest, + id, + noscroll, + hash +) { const popstate = !!id; if (popstate) { cid = id; diff --git a/packages/kit/src/runtime/navigation/prefetch/index.ts b/packages/kit/src/runtime/navigation/prefetch/index.js similarity index 64% rename from packages/kit/src/runtime/navigation/prefetch/index.ts rename to packages/kit/src/runtime/navigation/prefetch/index.js index 543f37b6c829..bb5639e58834 100644 --- a/packages/kit/src/runtime/navigation/prefetch/index.ts +++ b/packages/kit/src/runtime/navigation/prefetch/index.js @@ -1,21 +1,21 @@ import { hydrate_target } from '../start'; // TODO does this belong here? import { select_target } from '../internal'; import { find_anchor, get_base_uri } from '../utils'; -import { HydratedTarget, Target } from '../types'; -let prefetching: { - href: string; - promise: Promise; -} = null; -let mousemove_timeout: NodeJS.Timer; +let prefetching + + + = null; + +let mousemove_timeout; export function start() { addEventListener('touchstart', trigger_prefetch); addEventListener('mousemove', handle_mousemove); } -export default function prefetch(href: string) { +export default function prefetch(href) { const target = select_target(new URL(href, get_base_uri(document))); if (target) { @@ -27,7 +27,7 @@ export default function prefetch(href: string) { } } -export function get_prefetched(target: Target): Promise { +export function get_prefetched(target) { if (prefetching && prefetching.href === target.href) { return prefetching.promise; } else { @@ -35,15 +35,15 @@ export function get_prefetched(target: Target): Promise { } } -function trigger_prefetch(event: MouseEvent | TouchEvent) { - const a: HTMLAnchorElement = find_anchor(event.target); +function trigger_prefetch(event) { + const a = find_anchor(event.target); if (a && a.rel === 'prefetch') { prefetch(a.href); } } -function handle_mousemove(event: MouseEvent) { +function handle_mousemove(event) { clearTimeout(mousemove_timeout); mousemove_timeout = setTimeout(() => { trigger_prefetch(event); diff --git a/packages/kit/src/runtime/navigation/prefetchRoutes/index.ts b/packages/kit/src/runtime/navigation/prefetchRoutes/index.js similarity index 79% rename from packages/kit/src/runtime/navigation/prefetchRoutes/index.ts rename to packages/kit/src/runtime/navigation/prefetchRoutes/index.js index e2030bd0b136..ee6243379d4c 100644 --- a/packages/kit/src/runtime/navigation/prefetchRoutes/index.ts +++ b/packages/kit/src/runtime/navigation/prefetchRoutes/index.js @@ -1,6 +1,6 @@ import { components, routes } from 'MANIFEST'; -export default async function prefetchRoutes(pathnames: string[]): Promise { +export default async function prefetchRoutes(pathnames) { const path_routes = pathnames ? routes.filter((route) => pathnames.some((pathname) => route.pattern.test(pathname))) : routes; diff --git a/packages/kit/src/runtime/navigation/start/index.ts b/packages/kit/src/runtime/navigation/start/index.js similarity index 82% rename from packages/kit/src/runtime/navigation/start/index.ts rename to packages/kit/src/runtime/navigation/start/index.js index 3e58221e6b76..0f6420058fb4 100644 --- a/packages/kit/src/runtime/navigation/start/index.ts +++ b/packages/kit/src/runtime/navigation/start/index.js @@ -1,31 +1,31 @@ import { writable } from 'svelte/store'; import { extract_query, init as init_router, load_current_page, select_target } from '../internal'; import { get_prefetched, start as start_prefetching } from '../prefetch'; -import { HydratedTarget, Target, Redirect, Branch, Page, InitialData } from '../types'; + import goto from '../goto'; import { page_store } from './page_store'; import { layout, ErrorComponent, components } from 'MANIFEST'; import root from 'ROOT'; -import { PageContext } from '../types'; -declare const __SVELTE__; -export const initial_data: InitialData = typeof __SVELTE__ !== 'undefined' && __SVELTE__; + + +export const initial_data = typeof __SVELTE__ !== 'undefined' && __SVELTE__; let ready = false; -let root_component: InstanceType; -let current_token: {}; -let root_preloaded: object | Promise; -let current_branch: Branch = []; +let root_component; +let current_token; +let root_preloaded; +let current_branch = []; let current_query = '{}'; const stores = { - page: page_store({} as any), - preloading: writable(false), + page: page_store({} ), + preloading: writable(false), session: writable(initial_data && initial_data.session) }; -let $session: any; -let session_dirty: boolean; +let $session; +let session_dirty; stores.session.subscribe(async (value) => { $session = value; @@ -46,12 +46,12 @@ stores.session.subscribe(async (value) => { } }); -export let target: Node; -export function set_target(node: Node) { +export let target; +export function set_target(node) { target = node; } -export default async function start(opts: { target: Node }) { +export default async function start(opts) { set_target(opts.target); init_router(initial_data.baseUrl, handle_target); @@ -93,13 +93,13 @@ function handle_error() { render([], props, { host, path: pathname, query, params: {}, error }); } -function buildPageContext(props: any, page: Page): PageContext { +function buildPageContext(props, page) { const { error } = props; return { error, ...page }; } -async function handle_target(dest: Target): Promise { +async function handle_target(dest) { if (root_component) stores.preloading.set(true); const hydrating = get_prefetched(dest); @@ -117,7 +117,7 @@ async function handle_target(dest: Target): Promise { } } -async function render(branch: Branch, props: any, page: PageContext) { +async function render(branch, props, page) { stores.page.set(page); stores.preloading.set(false); @@ -164,23 +164,23 @@ function part_changed(i, segment, match, stringified_query) { } } -export async function hydrate_target(dest: Target): Promise { +export async function hydrate_target(dest) { const { route, page } = dest; const segments = page.path.split('/').filter(Boolean); - let redirect: Redirect = null; + let redirect = null; const props = { error: null, status: 200, segments: [segments[0]] }; const preload_context = { - fetch: (url: string, opts?: any) => fetch(url, opts), - redirect: (statusCode: number, location: string) => { + fetch: (url, opts) => fetch(url, opts), + redirect: (statusCode, location) => { if (redirect && (redirect.statusCode !== statusCode || redirect.location !== location)) { throw new Error('Conflicting redirects'); } redirect = { statusCode, location }; }, - error: (status: number, error: Error | string) => { + error: (status, error) => { props.error = typeof error === 'string' ? new Error(error) : error; props.status = status; } @@ -203,7 +203,7 @@ export async function hydrate_target(dest: Target): Promise { : {}); } - let branch: Branch; + let branch; let l = 1; try { @@ -236,7 +236,7 @@ export async function hydrate_target(dest: Target): Promise { const { default: component, preload } = await components[part.i](); - let preloaded: object; + let preloaded; if (ready || !initial_data.preloaded[i + 1]) { preloaded = preload ? await preload.call( diff --git a/packages/kit/src/runtime/navigation/start/page_store.js b/packages/kit/src/runtime/navigation/start/page_store.js new file mode 100644 index 000000000000..eb2ca1c7f979 --- /dev/null +++ b/packages/kit/src/runtime/navigation/start/page_store.js @@ -0,0 +1,47 @@ +import { writable, } from 'svelte/store'; + +/** Callback to inform of a value updates. */ + + + + + + + + + + + + + + + + + + + +export function page_store(value) { + const store = writable(value); + let ready = true; + + function notify() { + ready = true; + store.update((val) => val); + } + + function set(new_value) { + ready = false; + store.set(new_value); + } + + function subscribe(run) { + let old_value; + return store.subscribe((new_value) => { + if (old_value === undefined || (ready && new_value !== old_value)) { + run((old_value = new_value)); + } + }); + } + + return { notify, set, subscribe }; +} diff --git a/packages/kit/src/runtime/navigation/start/page_store.ts b/packages/kit/src/runtime/navigation/start/page_store.ts deleted file mode 100644 index b9f269f0cc37..000000000000 --- a/packages/kit/src/runtime/navigation/start/page_store.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { writable, Readable } from 'svelte/store'; - -/** Callback to inform of a value updates. */ -type Subscriber = (value: T) => void; - -/** Unsubscribes from value updates. */ -type Unsubscriber = () => void; - -/** Writable interface for both updating and subscribing. */ -interface PageStore extends Readable { - /** - * Inform subscribers. - */ - notify(): void; - - /** - * Set value without informing subscribers. - * @param value to set - */ - set(value: T): void; -} - -export function page_store(value: T): PageStore { - const store = writable(value); - let ready = true; - - function notify(): void { - ready = true; - store.update((val) => val); - } - - function set(new_value: T): void { - ready = false; - store.set(new_value); - } - - function subscribe(run: Subscriber): Unsubscriber { - let old_value; - return store.subscribe((new_value) => { - if (old_value === undefined || (ready && new_value !== old_value)) { - run((old_value = new_value)); - } - }); - } - - return { notify, set, subscribe }; -} diff --git a/packages/kit/src/runtime/navigation/types.js b/packages/kit/src/runtime/navigation/types.js new file mode 100644 index 000000000000..c1173cd83923 --- /dev/null +++ b/packages/kit/src/runtime/navigation/types.js @@ -0,0 +1,51 @@ +import { Page } from '@sveltejs/app-utils'; +export { Page, Query, PageContext } from '@sveltejs/app-utils'; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/kit/src/runtime/navigation/types.ts b/packages/kit/src/runtime/navigation/types.ts deleted file mode 100644 index 9518abfeb2c8..000000000000 --- a/packages/kit/src/runtime/navigation/types.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Page } from '@sveltejs/app-utils'; -export { Page, Query, PageContext } from '@sveltejs/app-utils'; - -export interface HydratedTarget { - redirect?: Redirect; - preload_error?: any; - props: any; - branch: Branch; -} - -export type Branch = Array<{ - segment: string; - match?: RegExpExecArray; - component?: any; // TODO DOMComponentConstructor; - part?: number; -}>; - -export interface InitialData { - session: any; - preloaded?: object[]; - status: number; - error: Error; - baseUrl: string; -} - -export interface ScrollPosition { - x: number; - y: number; -} - -export type RouteParams = Record; - -export interface Route { - pattern: RegExp; - parts: Array<{ - params: (match: RegExpExecArray) => RouteParams; - i: number; - }>; -} - -export interface Target { - href: string; - route: Route; - match: RegExpExecArray; - page: Page; -} - -export interface Redirect { - statusCode: number; - location: string; -} diff --git a/packages/kit/src/runtime/navigation/utils.ts b/packages/kit/src/runtime/navigation/utils.js similarity index 90% rename from packages/kit/src/runtime/navigation/utils.ts rename to packages/kit/src/runtime/navigation/utils.js index 2fcf5574e725..9d783122a9ee 100644 --- a/packages/kit/src/runtime/navigation/utils.ts +++ b/packages/kit/src/runtime/navigation/utils.js @@ -9,7 +9,7 @@ export function get_base_uri(window_document) { return baseURI; } -export function find_anchor(node: Node) { +export function find_anchor(node) { while (node && node.nodeName.toUpperCase() !== 'A') node = node.parentNode; // SVG elements have a lowercase name return node; } diff --git a/packages/kit/src/runtime/stores/index.ts b/packages/kit/src/runtime/stores/index.js similarity index 61% rename from packages/kit/src/runtime/stores/index.ts rename to packages/kit/src/runtime/stores/index.js index 5b5cf8f49d84..8a2fbd6765bd 100644 --- a/packages/kit/src/runtime/stores/index.ts +++ b/packages/kit/src/runtime/stores/index.js @@ -1,29 +1,29 @@ import { getContext } from 'svelte'; -import { Readable, Writable } from 'svelte/store'; -import { PageContext } from '../navigation/types'; + + // these Svelte types are not exported, so repeating them here. -type Subscriber = (value: T) => void; -type Updater = (value: T) => T; + + // const ssr = (import.meta as any).env.SSR; const ssr = typeof window === 'undefined'; // TODO why doesn't previous line work in build? -export const getStores: () => { - page: Readable; - preloading: Readable; - session: Writable; -} = () => getContext('__svelte__'); +export const getStores + + + + = () => getContext('__svelte__'); export const page = { - subscribe(fn: Subscriber) { + subscribe(fn) { const store = getStores().page; return store.subscribe(fn); } }; export const preloading = { - subscribe(fn: Subscriber) { + subscribe(fn) { const store = getStores().preloading; return store.subscribe(fn); } @@ -38,7 +38,7 @@ const error = (verb) => { }; export const session = { - subscribe(fn: Subscriber) { + subscribe(fn) { const store = getStores().session; if (!ssr) { @@ -48,10 +48,10 @@ export const session = { return store.subscribe(fn); }, - set: (updater: Updater) => { + set: (updater) => { error('set'); }, - update: (updater: Updater) => { + update: (updater) => { error('update'); } }; diff --git a/packages/kit/src/utils.ts b/packages/kit/src/utils.js similarity index 80% rename from packages/kit/src/utils.ts rename to packages/kit/src/utils.js index c9031bbb5de1..d1c01ae4ae75 100644 --- a/packages/kit/src/utils.ts +++ b/packages/kit/src/utils.js @@ -2,18 +2,18 @@ import * as fs from 'fs'; import * as path from 'path'; import { mkdirp } from '@sveltejs/app-utils/files'; -export function left_pad(str: string, len: number) { +export function left_pad(str, len) { while (str.length < len) str = ` ${str}`; return str; } -export function repeat(str: string, i: number) { +export function repeat(str, i) { let result = ''; while (i--) result += str; return result; } -export function format_milliseconds(ms: number) { +export function format_milliseconds(ms) { if (ms < 1000) return `${ms}ms`; if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`; @@ -22,11 +22,11 @@ export function format_milliseconds(ms: number) { return `${minutes}m${seconds < 10 ? '0' : ''}${seconds}s`; } -export function elapsed(start: number) { +export function elapsed(start) { return format_milliseconds(Date.now() - start); } -export function walk(cwd: string, dir = cwd, files: string[] = []) { +export function walk(cwd, dir = cwd, files = []) { fs.readdirSync(dir).forEach((file) => { const resolved = path.resolve(dir, file); if (fs.statSync(resolved).isDirectory()) { @@ -39,13 +39,13 @@ export function walk(cwd: string, dir = cwd, files: string[] = []) { return files; } -export function posixify(str: string) { +export function posixify(str) { return str.replace(/\\/g, '/'); } const previous_contents = new Map(); -export function write_if_changed(file: string, code: string) { +export function write_if_changed(file, code) { if (code !== previous_contents.get(file)) { previous_contents.set(file, code); mkdirp(path.dirname(file)); @@ -54,12 +54,12 @@ export function write_if_changed(file: string, code: string) { } } -export function stringify(string: string, includeQuotes: boolean = true) { +export function stringify(string, includeQuotes = true) { const quoted = JSON.stringify(string); return includeQuotes ? quoted : quoted.slice(1, -1); } -export function fudge_mtime(file: string) { +export function fudge_mtime(file) { // need to fudge the mtime so that webpack doesn't go doolally const { atime, mtime } = fs.statSync(file); fs.utimesSync(file, new Date(atime.getTime() - 999999), new Date(mtime.getTime() - 999999)); diff --git a/packages/kit/tsconfig.json b/packages/kit/tsconfig.json deleted file mode 100644 index 2a454d44b896..000000000000 --- a/packages/kit/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "resolveJsonModule": true, - "module": "esnext", - "moduleResolution": "node", - "target": "ES6", - "esModuleInterop": true, - "skipLibCheck": true, - "noEmitOnError": true - }, - "include": ["src/**/*"], - "lib": ["ES2020", "dom", "node"], - "strict": true -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0010bcb87aa..11c027420ef0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,33 +5,23 @@ importers: '@rollup/plugin-commonjs': 15.1.0_rollup@2.32.0 '@rollup/plugin-json': 4.1.0_rollup@2.32.0 '@rollup/plugin-node-resolve': 9.0.0_rollup@2.32.0 - '@sveltejs/eslint-config': github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f_aa0d6b64385e65baa59ec3d0ba654ef0 - '@typescript-eslint/eslint-plugin': 4.6.0_f414f6c88b79e375ea6c4ff6443d1d22 - '@typescript-eslint/parser': 4.6.0_eslint@7.11.0+typescript@4.0.3 + '@sveltejs/eslint-config': github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f_9ee733401bef03657849a7355d21b2a8 eslint: 7.11.0 eslint-plugin-import: 2.22.1_eslint@7.11.0 eslint-plugin-svelte3: 2.7.3_eslint@7.11.0 prettier: 2.1.2 rollup: 2.32.0 - rollup-plugin-typescript2: 0.29.0_rollup@2.32.0+typescript@4.0.3 - tslib: 2.0.3 - typescript: 4.0.3 specifiers: '@changesets/cli': ^2.11.1 '@rollup/plugin-commonjs': ^15.1.0 '@rollup/plugin-json': ^4.1.0 '@rollup/plugin-node-resolve': ^9.0.0 '@sveltejs/eslint-config': 'github:sveltejs/eslint-config#v5.6.0' - '@typescript-eslint/eslint-plugin': ^4.6.0 - '@typescript-eslint/parser': ^4.6.0 eslint: ^7.11.0 eslint-plugin-import: ^2.22.1 eslint-plugin-svelte3: ^2.7.3 prettier: 2.1.2 rollup: ^2.32.0 - rollup-plugin-typescript2: ^0.29.0 - tslib: ^2.0.3 - typescript: ^4.0.3 examples/hn.svelte.dev: devDependencies: '@sveltejs/adapter-node': 'link:../../packages/adapter-node' @@ -179,7 +169,6 @@ importers: sirv: 1.0.7 source-map-support: 0.5.19 svelte: 3.29.0 - typescript: 4.0.5 specifiers: '@sveltejs/app-utils': 'workspace:*' '@types/node': ^14.11.10 @@ -204,7 +193,6 @@ importers: snowpack: ^2.17.0 source-map-support: ^0.5.19 svelte: ^3.29.0 - typescript: ^4.0.5 packages/snowpack-config: dependencies: '@snowpack/plugin-svelte': 3.0.0 @@ -655,10 +643,6 @@ packages: /@types/estree/0.0.45: resolution: integrity: sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g== - /@types/json-schema/7.0.6: - dev: true - resolution: - integrity: sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== /@types/json5/0.0.29: dev: true resolution: @@ -719,111 +703,6 @@ packages: dev: true resolution: integrity: sha512-RxAwYt4rGwK5GyoRwuP0jT6ZHAVTdz2EqgsHmX0PYNjGsko+OeT4WFXXTs/lM3teJUJodM+SNtAL5/pXIJ61IQ== - /@typescript-eslint/eslint-plugin/4.6.0_f414f6c88b79e375ea6c4ff6443d1d22: - dependencies: - '@typescript-eslint/experimental-utils': 4.6.0_eslint@7.11.0+typescript@4.0.3 - '@typescript-eslint/parser': 4.6.0_eslint@7.11.0+typescript@4.0.3 - '@typescript-eslint/scope-manager': 4.6.0 - debug: 4.2.0 - eslint: 7.11.0 - functional-red-black-tree: 1.0.1 - regexpp: 3.1.0 - semver: 7.3.2 - tsutils: 3.17.1_typescript@4.0.3 - typescript: 4.0.3 - dev: true - engines: - node: ^10.12.0 || >=12.0.0 - peerDependencies: - '@typescript-eslint/parser': ^4.0.0 - eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - resolution: - integrity: sha512-1+419X+Ynijytr1iWI+/IcX/kJryc78YNpdaXR1aRO1sU3bC0vZrIAF1tIX7rudVI84W7o7M4zo5p1aVt70fAg== - /@typescript-eslint/experimental-utils/4.6.0_eslint@7.11.0+typescript@4.0.3: - dependencies: - '@types/json-schema': 7.0.6 - '@typescript-eslint/scope-manager': 4.6.0 - '@typescript-eslint/types': 4.6.0 - '@typescript-eslint/typescript-estree': 4.6.0_typescript@4.0.3 - eslint: 7.11.0 - eslint-scope: 5.1.1 - eslint-utils: 2.1.0 - dev: true - engines: - node: ^10.12.0 || >=12.0.0 - peerDependencies: - eslint: '*' - typescript: '*' - resolution: - integrity: sha512-pnh6Beh2/4xjJVNL+keP49DFHk3orDHHFylSp3WEjtgW3y1U+6l+jNnJrGlbs6qhAz5z96aFmmbUyKhunXKvKw== - /@typescript-eslint/parser/4.6.0_eslint@7.11.0+typescript@4.0.3: - dependencies: - '@typescript-eslint/scope-manager': 4.6.0 - '@typescript-eslint/types': 4.6.0 - '@typescript-eslint/typescript-estree': 4.6.0_typescript@4.0.3 - debug: 4.2.0 - eslint: 7.11.0 - typescript: 4.0.3 - dev: true - engines: - node: ^10.12.0 || >=12.0.0 - peerDependencies: - eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - resolution: - integrity: sha512-Dj6NJxBhbdbPSZ5DYsQqpR32MwujF772F2H3VojWU6iT4AqL4BKuoNWOPFCoSZvCcADDvQjDpa6OLDAaiZPz2Q== - /@typescript-eslint/scope-manager/4.6.0: - dependencies: - '@typescript-eslint/types': 4.6.0 - '@typescript-eslint/visitor-keys': 4.6.0 - dev: true - engines: - node: ^8.10.0 || ^10.13.0 || >=11.10.1 - resolution: - integrity: sha512-uZx5KvStXP/lwrMrfQQwDNvh2ppiXzz5TmyTVHb+5TfZ3sUP7U1onlz3pjoWrK9konRyFe1czyxObWTly27Ang== - /@typescript-eslint/types/4.6.0: - dev: true - engines: - node: ^8.10.0 || ^10.13.0 || >=11.10.1 - resolution: - integrity: sha512-5FAgjqH68SfFG4UTtIFv+rqYJg0nLjfkjD0iv+5O27a0xEeNZ5rZNDvFGZDizlCD1Ifj7MAbSW2DPMrf0E9zjA== - /@typescript-eslint/typescript-estree/4.6.0_typescript@4.0.3: - dependencies: - '@typescript-eslint/types': 4.6.0 - '@typescript-eslint/visitor-keys': 4.6.0 - debug: 4.2.0 - globby: 11.0.1 - is-glob: 4.0.1 - lodash: 4.17.20 - semver: 7.3.2 - tsutils: 3.17.1_typescript@4.0.3 - typescript: 4.0.3 - dev: true - engines: - node: ^10.12.0 || >=12.0.0 - peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - resolution: - integrity: sha512-s4Z9qubMrAo/tw0CbN0IN4AtfwuehGXVZM0CHNMdfYMGBDhPdwTEpBrecwhP7dRJu6d9tT9ECYNaWDHvlFSngA== - /@typescript-eslint/visitor-keys/4.6.0: - dependencies: - '@typescript-eslint/types': 4.6.0 - eslint-visitor-keys: 2.0.0 - dev: true - engines: - node: ^8.10.0 || ^10.13.0 || >=11.10.1 - resolution: - integrity: sha512-38Aa9Ztl0XyFPVzmutHXqDMCu15Xx8yKvUo38Gu3GhsuckCh3StPI5t2WIO9LHEsOH7MLmlGfKUisU8eW1Sjhg== /acorn-jsx/5.3.1_acorn@7.4.1: dependencies: acorn: 7.4.1 @@ -1852,6 +1731,7 @@ packages: commondir: 1.0.1 make-dir: 3.1.0 pkg-dir: 4.2.0 + dev: false engines: node: '>=8' resolution: @@ -2491,6 +2371,7 @@ packages: /make-dir/3.1.0: dependencies: semver: 6.3.0 + dev: false engines: node: '>=8' resolution: @@ -3231,12 +3112,6 @@ packages: node: '>=8' resolution: integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== - /resolve/1.17.0: - dependencies: - path-parse: 1.0.6 - dev: true - resolution: - integrity: sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== /resolve/1.18.1: dependencies: is-core-module: 2.0.0 @@ -3316,21 +3191,6 @@ packages: rollup: ^2.0.0 resolution: integrity: sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ== - /rollup-plugin-typescript2/0.29.0_rollup@2.32.0+typescript@4.0.3: - dependencies: - '@rollup/pluginutils': 3.1.0_rollup@2.32.0 - find-cache-dir: 3.3.1 - fs-extra: 8.1.0 - resolve: 1.17.0 - rollup: 2.32.0 - tslib: 2.0.1 - typescript: 4.0.3 - dev: true - peerDependencies: - rollup: '>=1.26.3' - typescript: '>=2.4.0' - resolution: - integrity: sha512-YytahBSZCIjn/elFugEGQR5qTsVhxhUwGZIsA9TmrSsC88qroGo65O5HZP/TTArH2dm0vUmYWhKchhwi2wL9bw== /rollup-pluginutils/2.8.2: dependencies: estree-walker: 0.6.1 @@ -3387,6 +3247,7 @@ packages: resolution: integrity: sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== /semver/6.3.0: + dev: false hasBin: true resolution: integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== @@ -3867,29 +3728,6 @@ packages: dev: true resolution: integrity: sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw== - /tslib/1.14.1: - dev: true - resolution: - integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - /tslib/2.0.1: - dev: true - resolution: - integrity: sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ== - /tslib/2.0.3: - dev: true - resolution: - integrity: sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ== - /tsutils/3.17.1_typescript@4.0.3: - dependencies: - tslib: 1.14.1 - typescript: 4.0.3 - dev: true - engines: - node: '>= 6' - peerDependencies: - typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' - resolution: - integrity: sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== /tty-table/2.8.13: dependencies: chalk: 3.0.0 @@ -3930,20 +3768,6 @@ packages: node: '>=8' resolution: integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== - /typescript/4.0.3: - dev: true - engines: - node: '>=4.2.0' - hasBin: true - resolution: - integrity: sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg== - /typescript/4.0.5: - dev: true - engines: - node: '>=4.2.0' - hasBin: true - resolution: - integrity: sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ== /unique-filename/1.1.1: dependencies: unique-slug: 2.0.2 @@ -4138,14 +3962,11 @@ packages: node: '>=6' resolution: integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== - github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f_aa0d6b64385e65baa59ec3d0ba654ef0: + github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f_9ee733401bef03657849a7355d21b2a8: dependencies: - '@typescript-eslint/eslint-plugin': 4.6.0_f414f6c88b79e375ea6c4ff6443d1d22 - '@typescript-eslint/parser': 4.6.0_eslint@7.11.0+typescript@4.0.3 eslint: 7.11.0 eslint-plugin-import: 2.22.1_eslint@7.11.0 eslint-plugin-svelte3: 2.7.3_eslint@7.11.0 - typescript: 4.0.3 dev: true id: github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f name: '@sveltejs/eslint-config' From c3db751b1a5feee1eafb804cc9d5fcc0f5a87648 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 13:39:07 -0500 Subject: [PATCH 03/30] remove ts-node in favour of esm --- packages/app-utils/package.json | 4 ++-- pnpm-lock.yaml | 39 +++++++-------------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/packages/app-utils/package.json b/packages/app-utils/package.json index c5d22597c431..9eaa9623a33c 100644 --- a/packages/app-utils/package.json +++ b/packages/app-utils/package.json @@ -9,7 +9,7 @@ "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore", "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", "prepublishOnly": "npm run build", - "test": "uvu -r ts-node/register" + "test": "uvu -r esm" }, "dependencies": { "mime": "^2.4.6" @@ -19,10 +19,10 @@ "@types/node": "^14.14.0", "@types/node-fetch": "^2.5.7", "devalue": "^2.0.1", + "esm": "^3.2.25", "node-fetch": "^2.6.1", "rollup": "^2.32.0", "svelte": "^3.29.0", - "ts-node": "^9.0.0", "uvu": "^0.3.4" }, "exports": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 11c027420ef0..e06fa301cc27 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -112,21 +112,21 @@ importers: '@types/node': 14.14.0 '@types/node-fetch': 2.5.7 devalue: 2.0.1 + esm: 3.2.25 node-fetch: 2.6.1 rollup: 2.32.0 svelte: 3.29.0 - ts-node: 9.0.0 uvu: 0.3.4 specifiers: '@types/mime': ^2.0.3 '@types/node': ^14.14.0 '@types/node-fetch': ^2.5.7 devalue: ^2.0.1 + esm: ^3.2.25 mime: ^2.4.6 node-fetch: ^2.6.1 rollup: ^2.32.0 svelte: ^3.29.0 - ts-node: ^9.0.0 uvu: ^0.3.4 packages/create-svelte: devDependencies: @@ -807,10 +807,6 @@ packages: node: '>= 8' resolution: integrity: sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg== - /arg/4.1.3: - dev: true - resolution: - integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== /argparse/1.0.10: dependencies: sprintf-js: 1.0.3 @@ -1561,6 +1557,12 @@ packages: hasBin: true resolution: integrity: sha512-G9+qtYVCHaDi1ZuWzBsOWo2wSwd70TXnU6UHA3cTYHp7gCTXZcpggWFoUVAMRarg68qtPoNfFbzPh+VdOgmwmw== + /esm/3.2.25: + dev: true + engines: + node: '>=6' + resolution: + integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA== /espree/7.3.0: dependencies: acorn: 7.4.1 @@ -2376,10 +2378,6 @@ packages: node: '>=8' resolution: integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== - /make-error/1.3.6: - dev: true - resolution: - integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== /map-obj/1.0.1: dev: true engines: @@ -3704,21 +3702,6 @@ packages: node: '>=8' resolution: integrity: sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA== - /ts-node/9.0.0: - dependencies: - arg: 4.1.3 - diff: 4.0.2 - make-error: 1.3.6 - source-map-support: 0.5.19 - yn: 3.1.1 - dev: true - engines: - node: '>=10.0.0' - hasBin: true - peerDependencies: - typescript: '>=2.7' - resolution: - integrity: sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg== /tsconfig-paths/3.9.0: dependencies: '@types/json5': 0.0.29 @@ -3956,12 +3939,6 @@ packages: node: '>=8' resolution: integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== - /yn/3.1.1: - dev: true - engines: - node: '>=6' - resolution: - integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f_9ee733401bef03657849a7355d21b2a8: dependencies: eslint: 7.11.0 From f2476b3ebe9aaaa4a3b72401d8b84f8570132672 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Wed, 25 Nov 2020 12:23:43 -0800 Subject: [PATCH 04/30] Build kit package with sucrase --- package.json | 3 + packages/kit/rollup.config.js | 16 +++-- packages/kit/src/api/build/Builder.ts | 22 +++---- pnpm-lock.yaml | 86 ++++++++++++++++++++++++++- 4 files changed, 110 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 297a7a35ae70..6dfc7c1cc529 100644 --- a/package.json +++ b/package.json @@ -34,5 +34,8 @@ "rollup-plugin-typescript2": "^0.29.0", "tslib": "^2.0.3", "typescript": "^4.0.3" + }, + "dependencies": { + "@rollup/plugin-sucrase": "^3.1.0" } } diff --git a/packages/kit/rollup.config.js b/packages/kit/rollup.config.js index 3021be4e6a43..f1e7f7f2aa6e 100644 --- a/packages/kit/rollup.config.js +++ b/packages/kit/rollup.config.js @@ -1,7 +1,7 @@ import commonjs from '@rollup/plugin-commonjs'; import json from '@rollup/plugin-json'; import resolve from '@rollup/plugin-node-resolve'; -import typescript from 'rollup-plugin-typescript2'; +import sucrase from '@rollup/plugin-sucrase'; import pkg from './package.json'; import { readFileSync, writeFileSync } from 'fs'; @@ -31,7 +31,10 @@ export default [ resolve({ extensions: ['.mjs', '.js', '.ts'] }), - typescript(/*{ + sucrase({ + transforms: ['typescript'] + }) + /*typescript({ tsconfigDefaults: { compilerOptions: { // create typings. these options do not apply to the other build target @@ -41,8 +44,8 @@ export default [ } }, useTsconfigDeclarationDir: true - }*/), - /*{ + }), + { name: 'adjust-typings', resolveId: () => null, load: () => null, @@ -69,7 +72,10 @@ export default [ extensions: ['.mjs', '.js', '.ts'] }), commonjs(), - typescript() + sucrase({ + transforms: ['typescript'] + }) + //typescript() ], preserveEntrySignatures: false } diff --git a/packages/kit/src/api/build/Builder.ts b/packages/kit/src/api/build/Builder.ts index 653bb16d3e50..c985dd589d73 100644 --- a/packages/kit/src/api/build/Builder.ts +++ b/packages/kit/src/api/build/Builder.ts @@ -13,9 +13,9 @@ export type BuilderOptions = { export default class Builder { log: Logger; - #generated_files: string; - #static_files: string; - #manifest: ManifestData; + private generated_files: string; + private static_files: string; + private manifest: ManifestData; constructor({ generated_files, @@ -23,19 +23,19 @@ export default class Builder { log, manifest }: BuilderOptions) { - this.#generated_files = generated_files; - this.#static_files = static_files; - this.#manifest = manifest; + this.generated_files = generated_files; + this.static_files = static_files; + this.manifest = manifest; this.log = log; } copy_generated_files(dest: string) { - copy(this.#generated_files, dest); + copy(this.generated_files, dest); } copy_static_files(dest: string) { - copy(this.#static_files, dest); + copy(this.static_files, dest); } prerender({ @@ -48,13 +48,13 @@ export default class Builder { prerender({ out: dest, force, - dir: this.#generated_files, - manifest: this.#manifest, + dir: this.generated_files, + manifest: this.manifest, log: this.log }); } foo() { - console.log(this.#manifest); + console.log(this.manifest); } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf6cc285cdf7..70351b3fdf17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,7 @@ importers: .: + dependencies: + '@rollup/plugin-sucrase': 3.1.0_rollup@2.32.0 devDependencies: '@changesets/cli': 2.11.1 '@rollup/plugin-commonjs': 15.1.0_rollup@2.32.0 @@ -21,6 +23,7 @@ importers: '@rollup/plugin-commonjs': ^15.1.0 '@rollup/plugin-json': ^4.1.0 '@rollup/plugin-node-resolve': ^9.0.0 + '@rollup/plugin-sucrase': ^3.1.0 '@sveltejs/eslint-config': 'github:sveltejs/eslint-config#v5.6.0' '@typescript-eslint/eslint-plugin': ^4.6.0 '@typescript-eslint/parser': ^4.6.0 @@ -604,13 +607,24 @@ packages: rollup: ^1.20.0 || ^2.0.0 resolution: integrity: sha512-XPmVXZ7IlaoWaJLkSCDaa0Y6uVo5XQYHhiMFzOd5qSv5rE+t/UJToPIOE56flKIxBFQI27ONsxb7dqHnwSsjKQ== + /@rollup/plugin-sucrase/3.1.0_rollup@2.32.0: + dependencies: + '@rollup/pluginutils': 3.1.0_rollup@2.32.0 + rollup: 2.32.0 + sucrase: 3.16.0 + dev: false + engines: + node: '>=8.0.0' + peerDependencies: + rollup: ^1.20.0 || ^2.0.0 + resolution: + integrity: sha512-PZ70LDNgIj8rL+3pKwKwTBOQ2c9JofXeLbWz+2V4/nCt4LqwYTNqxJJf1riTJsVARVzJdA0woIzUzjKZvL8TfA== /@rollup/pluginutils/3.1.0_rollup@2.32.0: dependencies: '@types/estree': 0.0.39 estree-walker: 1.0.1 picomatch: 2.2.2 rollup: 2.32.0 - dev: true engines: node: '>= 8.0.0' peerDependencies: @@ -949,6 +963,10 @@ packages: node: '>=8' resolution: integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + /any-promise/1.3.0: + dev: false + resolution: + integrity: sha1-q8av7tzqUugJzcA3au0845Y10X8= /anymatch/3.1.1: dependencies: normalize-path: 3.0.0 @@ -1265,6 +1283,12 @@ packages: dev: false resolution: integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + /commander/4.1.1: + dev: false + engines: + node: '>= 6' + resolution: + integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== /commondir/1.0.1: resolution: integrity: sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= @@ -2712,6 +2736,14 @@ packages: dev: true resolution: integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + /mz/2.7.0: + dependencies: + any-promise: 1.3.0 + object-assign: 4.1.1 + thenify-all: 1.6.0 + dev: false + resolution: + integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== /natural-compare/1.4.0: dev: true resolution: @@ -2722,6 +2754,12 @@ packages: node: 4.x || >=6.0.0 resolution: integrity: sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== + /node-modules-regexp/1.0.0: + dev: false + engines: + node: '>=0.10.0' + resolution: + integrity: sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA= /normalize-package-data/2.5.0: dependencies: hosted-git-info: 2.8.8 @@ -2753,6 +2791,12 @@ packages: node: '>=8' resolution: integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== + /object-assign/4.1.1: + dev: false + engines: + node: '>=0.10.0' + resolution: + integrity: sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= /object-inspect/1.8.0: dev: true resolution: @@ -3021,6 +3065,14 @@ packages: node: '>=6' resolution: integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== + /pirates/4.0.1: + dependencies: + node-modules-regexp: 1.0.0 + dev: false + engines: + node: '>= 6' + resolution: + integrity: sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA== /pkg-dir/2.0.0: dependencies: find-up: 2.1.0 @@ -3736,6 +3788,20 @@ packages: node: '>=8' resolution: integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + /sucrase/3.16.0: + dependencies: + commander: 4.1.1 + glob: 7.1.6 + lines-and-columns: 1.1.6 + mz: 2.7.0 + pirates: 4.0.1 + ts-interface-checker: 0.1.13 + dev: false + engines: + node: '>=8' + hasBin: true + resolution: + integrity: sha512-ovVuswxV5TayCPXfTk8bgBgk6uNRvsinIkEpq0J6zS1xXCx5N/LLGcbsKdRhqn/ToZylMX6+yXaR1LSn1I42Pg== /supports-color/2.0.0: dev: false engines: @@ -3829,6 +3895,20 @@ packages: dev: true resolution: integrity: sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= + /thenify-all/1.6.0: + dependencies: + thenify: 3.3.1 + dev: false + engines: + node: '>=0.8' + resolution: + integrity: sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY= + /thenify/3.3.1: + dependencies: + any-promise: 1.3.0 + dev: false + resolution: + integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== /tiny-glob/0.2.8: dependencies: globalyzer: 0.1.0 @@ -3872,6 +3952,10 @@ packages: node: '>=8' resolution: integrity: sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA== + /ts-interface-checker/0.1.13: + dev: false + resolution: + integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA== /ts-node/9.0.0: dependencies: arg: 4.1.3 From 205358869ff4d6ff271d458fadf3cea415eb1f64 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Wed, 25 Nov 2020 14:21:29 -0800 Subject: [PATCH 05/30] Convert tests to use sucrase --- packages/kit/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kit/package.json b/packages/kit/package.json index ade0fd742e97..2910013ec545 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -48,6 +48,6 @@ "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore", "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", "prepublishOnly": "npm run build", - "test": "uvu -r ts-node/register" + "test": "uvu -r sucrase/register/ts" } } From cd247319d38a57fae9a042122d2bd62b791a2edb Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 17:58:57 -0500 Subject: [PATCH 06/30] get build working again --- packages/kit/src/api/build/index.js | 2 +- packages/kit/src/runtime/stores/index.js | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/kit/src/api/build/index.js b/packages/kit/src/api/build/index.js index f3f1b09079db..2e393918e445 100644 --- a/packages/kit/src/api/build/index.js +++ b/packages/kit/src/api/build/index.js @@ -282,7 +282,7 @@ export async function build(config) { log }); - const adapter: Adapter = relative(config.adapter); + const adapter = relative(config.adapter); await adapter(builder); } diff --git a/packages/kit/src/runtime/stores/index.js b/packages/kit/src/runtime/stores/index.js index 7f2b3d8f52db..8a2fbd6765bd 100644 --- a/packages/kit/src/runtime/stores/index.js +++ b/packages/kit/src/runtime/stores/index.js @@ -29,7 +29,7 @@ export const preloading = { } }; -const error = (verb: string) => { +const error = (verb) => { throw new Error( ssr ? `Can only ${verb} session store in browser` @@ -48,17 +48,10 @@ export const session = { return store.subscribe(fn); }, -<<<<<<< HEAD:packages/kit/src/runtime/stores/index.ts - set: (_value: any) => { - error('set'); - }, - update: (_updater: Updater) => { -======= set: (updater) => { error('set'); }, update: (updater) => { ->>>>>>> liberation:packages/kit/src/runtime/stores/index.js error('update'); } }; From d258973a4bd15c7dc34d1e57e29ccbea3eb1708a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 18:08:55 -0500 Subject: [PATCH 07/30] fix gitignore files --- packages/adapter-netlify/.gitignore | 6 +- packages/adapter-netlify/src/index.js | 97 + packages/adapter-netlify/src/render.js | 68 + packages/adapter-node/.gitignore | 5 +- packages/adapter-node/server.js | 3063 +++++++++++++++++ packages/adapter-node/src/index.js | 58 + packages/adapter-node/src/server.js | 77 + packages/adapter-static/.gitignore | 5 +- packages/adapter-static/rollup.config.js | 2 +- packages/adapter-static/src/index.js | 27 + packages/adapter-vercel/.gitignore | 6 +- packages/adapter-vercel/index.d.js | 7 - packages/adapter-vercel/server.d.js | 2 - packages/adapter-vercel/src/index.js | 68 + packages/adapter-vercel/src/server.js | 68 + .../app-utils/src/renderer/render/index.js | 2 +- .../app-utils/src/renderer/render/page.js | 2 +- 17 files changed, 3535 insertions(+), 28 deletions(-) create mode 100644 packages/adapter-netlify/src/index.js create mode 100644 packages/adapter-netlify/src/render.js create mode 100644 packages/adapter-node/server.js create mode 100644 packages/adapter-node/src/index.js create mode 100644 packages/adapter-node/src/server.js create mode 100644 packages/adapter-static/src/index.js delete mode 100644 packages/adapter-vercel/index.d.js delete mode 100644 packages/adapter-vercel/server.d.js create mode 100644 packages/adapter-vercel/src/index.js create mode 100644 packages/adapter-vercel/src/server.js diff --git a/packages/adapter-netlify/.gitignore b/packages/adapter-netlify/.gitignore index 80faee3407c0..4fd626439822 100644 --- a/packages/adapter-netlify/.gitignore +++ b/packages/adapter-netlify/.gitignore @@ -1,6 +1,4 @@ .DS_Store node_modules -index.js -index.d.ts -render.js -render.d.ts +/index.js +/render.js \ No newline at end of file diff --git a/packages/adapter-netlify/src/index.js b/packages/adapter-netlify/src/index.js new file mode 100644 index 000000000000..a8c81adf2b7b --- /dev/null +++ b/packages/adapter-netlify/src/index.js @@ -0,0 +1,97 @@ +import fs from 'fs'; +import path from 'path'; +import toml from 'toml'; +import glob from 'tiny-glob/sync'; + +import { mkdirp } from '@sveltejs/app-utils/files'; +import { prerender, generate_manifest_module } from '@sveltejs/app-utils/renderer'; + + +module.exports = async function builder({ + dir, + manifest, + log +} + + + +) { + let netlify_config; + + if (fs.existsSync('netlify.toml')) { + try { + netlify_config = toml.parse(fs.readFileSync('netlify.toml', 'utf-8')); + } catch (err) { + err.message = `Error parsing netlify.toml: ${err.message}`; + throw err; + } + } else { + throw new Error( + 'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration' + ); + } + + if (!netlify_config.build || !netlify_config.build.publish || !netlify_config.build.functions) { + throw new Error( + 'You must specify build.publish and build.functions in netlify.toml. Consult https://github.com/sveltejs/adapter-netlify#configuration' + ); + } + + const publish = path.resolve(netlify_config.build.publish); + const functions = path.resolve(netlify_config.build.functions); + + mkdirp(`${publish}/_app`); + mkdirp(`${functions}/render`); + + // copy everything in `static` + glob('**/*', { cwd: 'static', filesOnly: true }).forEach((file) => { + mkdirp(path.dirname(`${publish}/${file}`)); + fs.copyFileSync(`static/${file}`, `${publish}/${file}`); + }); + + // copy client code + const client_code = path.resolve(dir, 'client'); + glob('**/*', { cwd: client_code, filesOnly: true }).forEach((file) => { + if (file[0] !== '.') { + mkdirp(path.dirname(`${publish}/_app/${file}`)); + fs.copyFileSync(`${client_code}/${file}`, `${publish}/_app/${file}`); + } + }); + + // prerender + log.info('Prerendering static pages...'); + await prerender({ + force: true, + dir, + out: publish, + manifest, + log + }); + + // copy server code + const server_code = path.resolve(dir, 'server'); + glob('**/*', { cwd: server_code, filesOnly: true }).forEach((file) => { + if (file[0] !== '.') { + mkdirp(path.dirname(`${functions}/render/${file}`)); + fs.copyFileSync(`${server_code}/${file}`, `${functions}/render/${file}`); + } + }); + + // copy the renderer + fs.copyFileSync(path.resolve(__dirname, 'render.js'), `${functions}/render/index.js`); + + // write manifest + fs.writeFileSync(`${functions}/render/manifest.js`, generate_manifest_module(manifest)); + + // copy client manifest + fs.copyFileSync(`${dir}/client.json`, `${functions}/render/client.json`); + + // copy template + fs.writeFileSync( + `${functions}/render/template.js`, + `module.exports = ${JSON.stringify(fs.readFileSync('src/app.html', 'utf-8'))};` + ); + + // create _redirects + fs.writeFileSync(`${publish}/_redirects`, '/* /.netlify/functions/render 200'); +}; diff --git a/packages/adapter-netlify/src/render.js b/packages/adapter-netlify/src/render.js new file mode 100644 index 000000000000..04fce0b86c83 --- /dev/null +++ b/packages/adapter-netlify/src/render.js @@ -0,0 +1,68 @@ + +import { URLSearchParams } from 'url'; +import { render } from '@sveltejs/app-utils/renderer'; + + +const manifest = require('./manifest.js'); +const client = require('./client.json'); +const root = require('./root.js'); +const setup = require('./setup.js'); +const template = require('./template.js'); + +// TODO this is a generic AWS lambda handler, and could be +// reused by other adapters + +export const handler = async (event) => { + const { + path, + httpMethod, + headers, + queryStringParameters + // body, // TODO pass this to renderer + // isBase64Encoded // TODO is this useful? + } = event; + + const query = new URLSearchParams(); + for (const k in queryStringParameters) { + const value = queryStringParameters[k]; + value.split(', ').forEach((v) => { + query.append(k, v); + }); + } + + const rendered = await render( + { + host: null, // TODO + method: httpMethod , + headers, + path, + query + }, + { + static_dir: 'static', + template, + manifest, + client, + root, + setup, + load: (route) => + require(`./routes/${route.name}.js`), + dev: false, + only_prerender: false + } + ); + + if (rendered) { + return { + isBase64Encoded: false, + statusCode: rendered.status, + headers: rendered.headers, + body: rendered.body + }; + } + + return { + statusCode: 404, + body: 'Not found' + }; +}; diff --git a/packages/adapter-node/.gitignore b/packages/adapter-node/.gitignore index 7fad62f488a3..6e2e5caf77b0 100644 --- a/packages/adapter-node/.gitignore +++ b/packages/adapter-node/.gitignore @@ -1,6 +1,3 @@ .DS_Store node_modules -index.js -index.d.ts -server.js -server.d.ts +/index.js \ No newline at end of file diff --git a/packages/adapter-node/server.js b/packages/adapter-node/server.js new file mode 100644 index 000000000000..374da637cf23 --- /dev/null +++ b/packages/adapter-node/server.js @@ -0,0 +1,3063 @@ +'use strict'; + +var fs = require('fs'); +var http = require('http'); +var Url = require('url'); +var path = require('path'); +var crypto = require('crypto'); +var Stream = require('stream'); +var https = require('https'); +var zlib = require('zlib'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var http__default = /*#__PURE__*/_interopDefaultLegacy(http); +var Url__default = /*#__PURE__*/_interopDefaultLegacy(Url); +var Stream__default = /*#__PURE__*/_interopDefaultLegacy(Stream); +var https__default = /*#__PURE__*/_interopDefaultLegacy(https); +var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib); + +function list(dir, callback, pre='') { + dir = path.resolve('.', dir); + let arr = fs.readdirSync(dir); + let i=0, abs, stats; + for (; i < arr.length; i++) { + abs = path.join(dir, arr[i]); + stats = fs.statSync(abs); + stats.isDirectory() + ? list(abs, callback, path.join(pre, arr[i])) + : callback(path.join(pre, arr[i]), abs, stats); + } +} + +function parse(str) { + let i=0, j=0, k, v; + let out={}, arr=str.split('&'); + for (; i < arr.length; i++) { + j = arr[i].indexOf('='); + v = !!~j && arr[i].substring(j+1) || ''; + k = !!~j ? arr[i].substring(0, j) : arr[i]; + out[k] = out[k] !== void 0 ? [].concat(out[k], v) : v; + } + return out; +} + +function parser (req, toDecode) { + let url = req.url; + if (url == null) return; + + let obj = req._parsedUrl; + if (obj && obj._raw === url) return obj; + + obj = { + path: url, + pathname: url, + search: null, + query: null, + href: url, + _raw: url + }; + + if (url.length > 1) { + if (toDecode && !req._decoded && !!~url.indexOf('%', 1)) { + let nxt = url; + try { nxt = decodeURIComponent(url); } catch (e) {/* bad */} + url = req.url = obj.href = obj.path = obj.pathname = obj._raw = nxt; + req._decoded = true; + } + + let idx = url.indexOf('?', 1); + + if (idx !== -1) { + obj.search = url.substring(idx); + obj.query = obj.search.substring(1); + obj.pathname = url.substring(0, idx); + if (toDecode && obj.query.length > 0) { + obj.query = parse(obj.query); + } + } + } + + return (req._parsedUrl = obj); +} + +/** + * @param typeMap [Object] Map of MIME type -> Array[extensions] + * @param ... + */ +function Mime() { + this._types = Object.create(null); + this._extensions = Object.create(null); + + for (var i = 0; i < arguments.length; i++) { + this.define(arguments[i]); + } + + this.define = this.define.bind(this); + this.getType = this.getType.bind(this); + this.getExtension = this.getExtension.bind(this); +} + +/** + * Define mimetype -> extension mappings. Each key is a mime-type that maps + * to an array of extensions associated with the type. The first extension is + * used as the default extension for the type. + * + * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); + * + * If a type declares an extension that has already been defined, an error will + * be thrown. To suppress this error and force the extension to be associated + * with the new type, pass `force`=true. Alternatively, you may prefix the + * extension with "*" to map the type to extension, without mapping the + * extension to the type. + * + * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']}); + * + * + * @param map (Object) type definitions + * @param force (Boolean) if true, force overriding of existing definitions + */ +Mime.prototype.define = function(typeMap, force) { + for (var type in typeMap) { + var extensions = typeMap[type].map(function(t) {return t.toLowerCase()}); + type = type.toLowerCase(); + + for (var i = 0; i < extensions.length; i++) { + var ext = extensions[i]; + + // '*' prefix = not the preferred type for this extension. So fixup the + // extension, and skip it. + if (ext[0] == '*') { + continue; + } + + if (!force && (ext in this._types)) { + throw new Error( + 'Attempt to change mapping for "' + ext + + '" extension from "' + this._types[ext] + '" to "' + type + + '". Pass `force=true` to allow this, otherwise remove "' + ext + + '" from the list of extensions for "' + type + '".' + ); + } + + this._types[ext] = type; + } + + // Use first extension as default + if (force || !this._extensions[type]) { + var ext = extensions[0]; + this._extensions[type] = (ext[0] != '*') ? ext : ext.substr(1); + } + } +}; + +/** + * Lookup a mime type based on extension + */ +Mime.prototype.getType = function(path) { + path = String(path); + var last = path.replace(/^.*[/\\]/, '').toLowerCase(); + var ext = last.replace(/^.*\./, '').toLowerCase(); + + var hasPath = last.length < path.length; + var hasDot = ext.length < last.length - 1; + + return (hasDot || !hasPath) && this._types[ext] || null; +}; + +/** + * Return file extension associated with a mime type + */ +Mime.prototype.getExtension = function(type) { + type = /^\s*([^;\s]*)/.test(type) && RegExp.$1; + return type && this._extensions[type.toLowerCase()] || null; +}; + +var Mime_1 = Mime; + +var standard = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/urc-ressheet+xml":["rsheet"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["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/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"],"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/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/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/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/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"]}; + +var lite = new Mime_1(standard); + +const noop = () => {}; + +function isMatch(uri, arr) { + for (let i=0; i < arr.length; i++) { + if (arr[i].test(uri)) return true; + } +} + +function toAssume(uri, extns) { + let i=0, x, len=uri.length - 1; + if (uri.charCodeAt(len) === 47) { + uri = uri.substring(0, len); + } + + let arr=[], tmp=`${uri}/index`; + for (; i < extns.length; i++) { + x = extns[i] ? `.${extns[i]}` : ''; + if (uri) arr.push(uri + x); + arr.push(tmp + x); + } + + return arr; +} + +function viaCache(cache, uri, extns) { + let i=0, data, arr=toAssume(uri, extns); + for (; i < arr.length; i++) { + if (data = cache[arr[i]]) return data; + } +} + +function viaLocal(dir, isEtag, uri, extns) { + let i=0, arr=toAssume(uri, extns); + let abs, stats, name, headers; + for (; i < arr.length; i++) { + abs = path.normalize(path.join(dir, name=arr[i])); + if (abs.startsWith(dir) && fs.existsSync(abs)) { + stats = fs.statSync(abs); + if (stats.isDirectory()) continue; + headers = toHeaders(name, stats, isEtag); + headers['Cache-Control'] = 'no-store'; + return { abs, stats, headers }; + } + } +} + +function is404(req, res) { + return (res.statusCode=404,res.end()); +} + +function send(req, res, file, stats, headers) { + let code=200, tmp, opts={}; + headers = { ...headers }; + + for (let key in headers) { + tmp = res.getHeader(key); + if (tmp) headers[key] = tmp; + } + + if (tmp = res.getHeader('content-type')) { + headers['Content-Type'] = tmp; + } + + if (req.headers.range) { + code = 206; + let [x, y] = req.headers.range.replace('bytes=', '').split('-'); + let end = opts.end = parseInt(y, 10) || stats.size - 1; + let start = opts.start = parseInt(x, 10) || 0; + + if (start >= stats.size || end >= stats.size) { + res.setHeader('Content-Range', `bytes */${stats.size}`); + res.statusCode = 416; + return res.end(); + } + + headers['Content-Range'] = `bytes ${start}-${end}/${stats.size}`; + headers['Content-Length'] = (end - start + 1); + headers['Accept-Ranges'] = 'bytes'; + } + + res.writeHead(code, headers); + fs.createReadStream(file, opts).pipe(res); +} + +function isEncoding(name, type, headers) { + headers['Content-Encoding'] = type; + headers['Content-Type'] = lite.getType(name.replace(/\.([^.]*)$/, '')) || ''; +} + +function toHeaders(name, stats, isEtag) { + let headers = { + 'Content-Length': stats.size, + 'Content-Type': lite.getType(name) || '', + 'Last-Modified': stats.mtime.toUTCString(), + }; + if (isEtag) headers['ETag'] = `W/"${stats.size}-${stats.mtime.getTime()}"`; + if (/\.br$/.test(name)) isEncoding(name, 'br', headers); + if (/\.gz$/.test(name)) isEncoding(name, 'gzip', headers); + return headers; +} + +function sirv (dir, opts={}) { + dir = path.resolve(dir || '.'); + + let isNotFound = opts.onNoMatch || is404; + let setHeaders = opts.setHeaders || noop; + + let extensions = opts.extensions || ['html', 'htm']; + let gzips = opts.gzip && extensions.map(x => `${x}.gz`).concat('gz'); + let brots = opts.brotli && extensions.map(x => `${x}.br`).concat('br'); + + const FILES = {}; + + let fallback = '/'; + let isEtag = !!opts.etag; + let isSPA = !!opts.single; + if (typeof opts.single === 'string') { + let idx = opts.single.lastIndexOf('.'); + fallback += !!~idx ? opts.single.substring(0, idx) : opts.single; + } + + let ignores = []; + if (opts.ignores !== false) { + ignores.push(/\w\.\w+$/); // any extn + if (opts.dotfiles) ignores.push(/\/\.\w/); + else ignores.push(/\/\.well-known/); + [].concat(opts.ignores || []).forEach(x => { + ignores.push(new RegExp(x, 'i')); + }); + } + + let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`; + if (cc && opts.immutable) cc += ',immutable'; + else if (cc && opts.maxAge === 0) cc += ',must-revalidate'; + + if (!opts.dev) { + list(dir, (name, abs, stats) => { + if (/\.well-known[\\+\/]/.test(name)) ; // keep + else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name)) return; + + let headers = toHeaders(name, stats, isEtag); + if (cc) headers['Cache-Control'] = cc; + + FILES['/' + name.normalize().replace(/\\+/g, '/')] = { abs, stats, headers }; + }); + } + + let lookup = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES); + + return function (req, res, next) { + let extns = ['']; + let val = req.headers['accept-encoding'] || ''; + if (gzips && val.includes('gzip')) extns.unshift(...gzips); + if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots); + extns.push(...extensions); // [...br, ...gz, orig, ...exts] + + let pathname = req.path || parser(req, true).pathname; + let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns); + if (!data) return next ? next() : isNotFound(req, res); + + if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) { + res.writeHead(304); + return res.end(); + } + + setHeaders(res, pathname, data.stats); + send(req, res, data.abs, data.stats, data.headers); + }; +} + +var other = {"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":["keynote"],"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.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}; + +var mime = new Mime_1(standard, other); + +var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'; +var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g; +var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/; +var escaped = { + '<': '\\u003C', + '>': '\\u003E', + '/': '\\u002F', + '\\': '\\\\', + '\b': '\\b', + '\f': '\\f', + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\0': '\\0', + '\u2028': '\\u2028', + '\u2029': '\\u2029' +}; +var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join('\0'); +function devalue(value) { + var counts = new Map(); + function walk(thing) { + if (typeof thing === 'function') { + throw new Error("Cannot stringify a function"); + } + if (counts.has(thing)) { + counts.set(thing, counts.get(thing) + 1); + return; + } + counts.set(thing, 1); + if (!isPrimitive(thing)) { + var type = getType(thing); + switch (type) { + case 'Number': + case 'String': + case 'Boolean': + case 'Date': + case 'RegExp': + return; + case 'Array': + thing.forEach(walk); + break; + case 'Set': + case 'Map': + Array.from(thing).forEach(walk); + break; + default: + var proto = Object.getPrototypeOf(thing); + if (proto !== Object.prototype && + proto !== null && + Object.getOwnPropertyNames(proto).sort().join('\0') !== objectProtoOwnPropertyNames) { + throw new Error("Cannot stringify arbitrary non-POJOs"); + } + if (Object.getOwnPropertySymbols(thing).length > 0) { + throw new Error("Cannot stringify POJOs with symbolic keys"); + } + Object.keys(thing).forEach(function (key) { return walk(thing[key]); }); + } + } + } + walk(value); + var names = new Map(); + Array.from(counts) + .filter(function (entry) { return entry[1] > 1; }) + .sort(function (a, b) { return b[1] - a[1]; }) + .forEach(function (entry, i) { + names.set(entry[0], getName(i)); + }); + function stringify(thing) { + if (names.has(thing)) { + return names.get(thing); + } + if (isPrimitive(thing)) { + return stringifyPrimitive(thing); + } + var type = getType(thing); + switch (type) { + case 'Number': + case 'String': + case 'Boolean': + return "Object(" + stringify(thing.valueOf()) + ")"; + case 'RegExp': + return "new RegExp(" + stringifyString(thing.source) + ", \"" + thing.flags + "\")"; + case 'Date': + return "new Date(" + thing.getTime() + ")"; + case 'Array': + var members = thing.map(function (v, i) { return i in thing ? stringify(v) : ''; }); + var tail = thing.length === 0 || (thing.length - 1 in thing) ? '' : ','; + return "[" + members.join(',') + tail + "]"; + case 'Set': + case 'Map': + return "new " + type + "([" + Array.from(thing).map(stringify).join(',') + "])"; + default: + var obj = "{" + Object.keys(thing).map(function (key) { return safeKey(key) + ":" + stringify(thing[key]); }).join(',') + "}"; + var proto = Object.getPrototypeOf(thing); + if (proto === null) { + return Object.keys(thing).length > 0 + ? "Object.assign(Object.create(null)," + obj + ")" + : "Object.create(null)"; + } + return obj; + } + } + var str = stringify(value); + if (names.size) { + var params_1 = []; + var statements_1 = []; + var values_1 = []; + names.forEach(function (name, thing) { + params_1.push(name); + if (isPrimitive(thing)) { + values_1.push(stringifyPrimitive(thing)); + return; + } + var type = getType(thing); + switch (type) { + case 'Number': + case 'String': + case 'Boolean': + values_1.push("Object(" + stringify(thing.valueOf()) + ")"); + break; + case 'RegExp': + values_1.push(thing.toString()); + break; + case 'Date': + values_1.push("new Date(" + thing.getTime() + ")"); + break; + case 'Array': + values_1.push("Array(" + thing.length + ")"); + thing.forEach(function (v, i) { + statements_1.push(name + "[" + i + "]=" + stringify(v)); + }); + break; + case 'Set': + values_1.push("new Set"); + statements_1.push(name + "." + Array.from(thing).map(function (v) { return "add(" + stringify(v) + ")"; }).join('.')); + break; + case 'Map': + values_1.push("new Map"); + statements_1.push(name + "." + Array.from(thing).map(function (_a) { + var k = _a[0], v = _a[1]; + return "set(" + stringify(k) + ", " + stringify(v) + ")"; + }).join('.')); + break; + default: + values_1.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'); + Object.keys(thing).forEach(function (key) { + statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key])); + }); + } + }); + statements_1.push("return " + str); + return "(function(" + params_1.join(',') + "){" + statements_1.join(';') + "}(" + values_1.join(',') + "))"; + } + else { + return str; + } +} +function getName(num) { + var name = ''; + do { + name = chars[num % chars.length] + name; + num = ~~(num / chars.length) - 1; + } while (num >= 0); + return reserved.test(name) ? name + "_" : name; +} +function isPrimitive(thing) { + return Object(thing) !== thing; +} +function stringifyPrimitive(thing) { + if (typeof thing === 'string') + return stringifyString(thing); + if (thing === void 0) + return 'void 0'; + if (thing === 0 && 1 / thing < 0) + return '-0'; + var str = String(thing); + if (typeof thing === 'number') + return str.replace(/^(-)?0\./, '$1.'); + return str; +} +function getType(thing) { + return Object.prototype.toString.call(thing).slice(8, -1); +} +function escapeUnsafeChar(c) { + return escaped[c] || c; +} +function escapeUnsafeChars(str) { + return str.replace(unsafeChars, escapeUnsafeChar); +} +function safeKey(key) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key)); +} +function safeProp(key) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]"; +} +function stringifyString(str) { + var result = '"'; + for (var i = 0; i < str.length; i += 1) { + var char = str.charAt(i); + var code = char.charCodeAt(0); + if (char === '"') { + result += '\\"'; + } + else if (char in escaped) { + result += escaped[char]; + } + else if (code >= 0xd800 && code <= 0xdfff) { + var next = str.charCodeAt(i + 1); + // If this is the beginning of a [high, low] surrogate pair, + // add the next two characters, otherwise escape + if (code <= 0xdbff && (next >= 0xdc00 && next <= 0xdfff)) { + result += char + str[++i]; + } + else { + result += "\\u" + code.toString(16).toUpperCase(); + } + } + else { + result += char; + } + } + result += '"'; + return result; +} + +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js + +// fix for "Readable" isn't a named export issue +const Readable = Stream__default['default'].Readable; + +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); + +class Blob { + constructor() { + this[TYPE] = ''; + + const blobParts = arguments[0]; + const options = arguments[1]; + + const buffers = []; + let size = 0; + + if (blobParts) { + const a = blobParts; + const length = Number(a.length); + for (let i = 0; i < length; i++) { + const element = a[i]; + let buffer; + if (element instanceof Buffer) { + buffer = element; + } else if (ArrayBuffer.isView(element)) { + buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); + } else if (element instanceof ArrayBuffer) { + buffer = Buffer.from(element); + } else if (element instanceof Blob) { + buffer = element[BUFFER]; + } else { + buffer = Buffer.from(typeof element === 'string' ? element : String(element)); + } + size += buffer.length; + buffers.push(buffer); + } + } + + this[BUFFER] = Buffer.concat(buffers); + + let type = options && options.type !== undefined && String(options.type).toLowerCase(); + if (type && !/[^\u0020-\u007E]/.test(type)) { + this[TYPE] = type; + } + } + get size() { + return this[BUFFER].length; + } + get type() { + return this[TYPE]; + } + text() { + return Promise.resolve(this[BUFFER].toString()); + } + arrayBuffer() { + const buf = this[BUFFER]; + const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + return Promise.resolve(ab); + } + stream() { + const readable = new Readable(); + readable._read = function () {}; + readable.push(this[BUFFER]); + readable.push(null); + return readable; + } + toString() { + return '[object Blob]'; + } + slice() { + const size = this.size; + + const start = arguments[0]; + const end = arguments[1]; + let relativeStart, relativeEnd; + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + const span = Math.max(relativeEnd - relativeStart, 0); + + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +} + +Object.defineProperties(Blob.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); + +Object.defineProperty(Blob.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * fetch-error.js + * + * FetchError interface for operational errors + */ + +/** + * Create FetchError instance + * + * @param String message Error message for human + * @param String type Error type for machine + * @param String systemError For Node.js system error + * @return FetchError + */ +function FetchError(message, type, systemError) { + Error.call(this, message); + + this.message = message; + this.type = type; + + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; + +let convert; +try { + convert = require('encoding').convert; +} catch (e) {} + +const INTERNALS = Symbol('Body internals'); + +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream__default['default'].PassThrough; + +/** + * Body mixin + * + * Ref: https://fetch.spec.whatwg.org/#body + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +function Body(body) { + var _this = this; + + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; + + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + + if (body == null) { + // body is undefined or null + body = null; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + body = Buffer.from(body.toString()); + } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + body = Buffer.from(body); + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); + } else if (body instanceof Stream__default['default']) ; else { + // none of the above + // coerce to string then buffer + body = Buffer.from(String(body)); + } + this[INTERNALS] = { + body, + disturbed: false, + error: null + }; + this.size = size; + this.timeout = timeout; + + if (body instanceof Stream__default['default']) { + body.on('error', function (err) { + const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); + _this[INTERNALS].error = error; + }); + } +} + +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, + + get bodyUsed() { + return this[INTERNALS].disturbed; + }, + + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, + + /** + * Return raw response as Blob + * + * @return Promise + */ + blob() { + let ct = this.headers && this.headers.get('content-type') || ''; + return consumeBody.call(this).then(function (buf) { + return Object.assign( + // Prevent copying + new Blob([], { + type: ct.toLowerCase() + }), { + [BUFFER]: buf + }); + }); + }, + + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; + + return consumeBody.call(this).then(function (buffer) { + try { + return JSON.parse(buffer.toString()); + } catch (err) { + return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + } + }); + }, + + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, + + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, + + /** + * Decode response as text, while automatically detecting the encoding and + * trying to decode to UTF-8 (non-spec api) + * + * @return Promise + */ + textConverted() { + var _this3 = this; + + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; + +// In browsers, all properties are enumerable. +Object.defineProperties(Body.prototype, { + body: { enumerable: true }, + bodyUsed: { enumerable: true }, + arrayBuffer: { enumerable: true }, + blob: { enumerable: true }, + json: { enumerable: true }, + text: { enumerable: true } +}); + +Body.mixIn = function (proto) { + for (const name of Object.getOwnPropertyNames(Body.prototype)) { + // istanbul ignore else: future proof + if (!(name in proto)) { + const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); + Object.defineProperty(proto, name, desc); + } + } +}; + +/** + * Consume and convert an entire Body to a Buffer. + * + * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * + * @return Promise + */ +function consumeBody() { + var _this4 = this; + + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } + + this[INTERNALS].disturbed = true; + + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } + + let body = this.body; + + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is blob + if (isBlob(body)) { + body = body.stream(); + } + + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } + + // istanbul ignore if: should never happen + if (!(body instanceof Stream__default['default'])) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; + + return new Body.Promise(function (resolve, reject) { + let resTimeout; + + // allow timeout on slow response body + if (_this4.timeout) { + resTimeout = setTimeout(function () { + abort = true; + reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); + }, _this4.timeout); + } + + // handle stream errors + body.on('error', function (err) { + if (err.name === 'AbortError') { + // if the request was aborted, reject with this Error + abort = true; + reject(err); + } else { + // other errors, such as incorrect content-encoding + reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } + + if (_this4.size && accumBytes + chunk.length > _this4.size) { + abort = true; + reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + return; + } + + accumBytes += chunk.length; + accum.push(chunk); + }); + + body.on('end', function () { + if (abort) { + return; + } + + clearTimeout(resTimeout); + + try { + resolve(Buffer.concat(accum, accumBytes)); + } catch (err) { + // handle streams that have accumulated too much data (issue #414) + reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + }); +} + +/** + * Detect buffer encoding and convert to target encoding + * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * + * @param Buffer buffer Incoming buffer + * @param String encoding Target encoding + * @return String + */ +function convertBody(buffer, headers) { + if (typeof convert !== 'function') { + throw new Error('The package `encoding` must be installed to use the textConverted() function'); + } + + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; + + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } + + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); + + // html5 + if (!res && str) { + res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; + + this[MAP] = Object.create(null); + + if (init instanceof Headers) { + const rawHeaders = init.raw(); + const headerNames = Object.keys(rawHeaders); + + for (const headerName of headerNames) { + for (const value of rawHeaders[headerName]) { + this.append(headerName, value); + } + } + + return; + } + + // We don't worry about converting prop to ByteString here as append() + // will handle it. + if (init == null) ; else if (typeof init === 'object') { + const method = init[Symbol.iterator]; + if (method != null) { + if (typeof method !== 'function') { + throw new TypeError('Header pairs must be iterable'); + } + + // sequence> + // Note: per spec we have to first exhaust the lists then process them + const pairs = []; + for (const pair of init) { + if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { + throw new TypeError('Each header pair must be iterable'); + } + pairs.push(Array.from(pair)); + } + + for (const pair of pairs) { + if (pair.length !== 2) { + throw new TypeError('Each header pair must be a name/value tuple'); + } + this.append(pair[0], pair[1]); + } + } else { + // record + for (const key of Object.keys(init)) { + const value = init[key]; + this.append(key, value); + } + } + } else { + throw new TypeError('Provided initializer must be an object'); + } + } + + /** + * Return combined header value given name + * + * @param String name Header name + * @return Mixed + */ + get(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key === undefined) { + return null; + } + + return this[MAP][key].join(', '); + } + + /** + * Iterate over all headers + * + * @param Function callback Executed for each item with parameters (value, name, thisArg) + * @param Boolean thisArg `this` context for callback function + * @return Void + */ + forEach(callback) { + let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + + let pairs = getHeaders(this); + let i = 0; + while (i < pairs.length) { + var _pairs$i = pairs[i]; + const name = _pairs$i[0], + value = _pairs$i[1]; + + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } + } + + /** + * Overwrite header values given name + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + set(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + this[MAP][key !== undefined ? key : name] = [value]; + } + + /** + * Append a value onto existing header + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + append(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + if (key !== undefined) { + this[MAP][key].push(value); + } else { + this[MAP][name] = [value]; + } + } + + /** + * Check for header name existence + * + * @param String name Header name + * @return Boolean + */ + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } + + /** + * Delete all header values given name + * + * @param String name Header name + * @return Void + */ + delete(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key !== undefined) { + delete this[MAP][key]; + } + } + + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } + + /** + * Get an iterator on keys. + * + * @return Iterator + */ + keys() { + return createHeadersIterator(this, 'key'); + } + + /** + * Get an iterator on values. + * + * @return Iterator + */ + values() { + return createHeadersIterator(this, 'value'); + } + + /** + * Get an iterator on entries. + * + * This is the default iterator of the Headers object. + * + * @return Iterator + */ + [Symbol.iterator]() { + return createHeadersIterator(this, 'key+value'); + } +} +Headers.prototype.entries = Headers.prototype[Symbol.iterator]; + +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Headers.prototype, { + get: { enumerable: true }, + forEach: { enumerable: true }, + set: { enumerable: true }, + append: { enumerable: true }, + has: { enumerable: true }, + delete: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true } +}); + +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + + const keys = Object.keys(headers[MAP]).sort(); + return keys.map(kind === 'key' ? function (k) { + return k.toLowerCase(); + } : kind === 'value' ? function (k) { + return headers[MAP][k].join(', '); + } : function (k) { + return [k.toLowerCase(), headers[MAP][k].join(', ')]; + }); +} + +const INTERNAL = Symbol('internal'); + +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; +} + +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } + + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; + + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } + + this[INTERNAL].index = index + 1; + + return { + value: values[index], + done: false + }; + } +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); + +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * Export the Headers object in a form that Node.js can consume. + * + * @param Headers headers + * @return Object + */ +function exportNodeCompatibleHeaders(headers) { + const obj = Object.assign({ __proto__: null }, headers[MAP]); + + // http.request() only supports string as Host header. This hack makes + // specifying custom Host header possible. + const hostHeaderKey = find(headers[MAP], 'Host'); + if (hostHeaderKey !== undefined) { + obj[hostHeaderKey] = obj[hostHeaderKey][0]; + } + + return obj; +} + +/** + * Create a Headers object from an object of headers, ignoring those that do + * not conform to HTTP grammar productions. + * + * @param Object obj Object of headers + * @return Headers + */ +function createHeadersLenient(obj) { + const headers = new Headers(); + for (const name of Object.keys(obj)) { + if (invalidTokenRegex.test(name)) { + continue; + } + if (Array.isArray(obj[name])) { + for (const val of obj[name]) { + if (invalidHeaderCharRegex.test(val)) { + continue; + } + if (headers[MAP][name] === undefined) { + headers[MAP][name] = [val]; + } else { + headers[MAP][name].push(val); + } + } + } else if (!invalidHeaderCharRegex.test(obj[name])) { + headers[MAP][name] = [obj[name]]; + } + } + return headers; +} + +const INTERNALS$1 = Symbol('Response internals'); + +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http__default['default'].STATUS_CODES; + +/** + * Response class + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +class Response { + constructor() { + let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + Body.call(this, body, opts); + + const status = opts.status || 200; + const headers = new Headers(opts.headers); + + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; + } + + get url() { + return this[INTERNALS$1].url || ''; + } + + get status() { + return this[INTERNALS$1].status; + } + + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + } + + get redirected() { + return this[INTERNALS$1].counter > 0; + } + + get statusText() { + return this[INTERNALS$1].statusText; + } + + get headers() { + return this[INTERNALS$1].headers; + } + + /** + * Clone this response + * + * @return Response + */ + clone() { + return new Response(clone(this), { + url: this.url, + status: this.status, + statusText: this.statusText, + headers: this.headers, + ok: this.ok, + redirected: this.redirected + }); + } +} + +Body.mixIn(Response.prototype); + +Object.defineProperties(Response.prototype, { + url: { enumerable: true }, + status: { enumerable: true }, + ok: { enumerable: true }, + redirected: { enumerable: true }, + statusText: { enumerable: true }, + headers: { enumerable: true }, + clone: { enumerable: true } +}); + +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); + +const INTERNALS$2 = Symbol('Request internals'); + +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url__default['default'].parse; +const format_url = Url__default['default'].format; + +const streamDestructionSupported = 'destroy' in Stream__default['default'].Readable.prototype; + +/** + * Check if a value is an instance of Request. + * + * @param Mixed input + * @return Boolean + */ +function isRequest(input) { + return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; +} + +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); +} + +/** + * Request class + * + * @param Mixed input Url or Request instance + * @param Object init Custom options + * @return Void + */ +class Request { + constructor(input) { + let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + let parsedURL; + + // normalize input + if (!isRequest(input)) { + if (input && input.href) { + // in order to support Node.js' Url objects; though WHATWG's URL objects + // will fall into this branch also (since their `toString()` will return + // `href` property anyway) + parsedURL = parse_url(input.href); + } else { + // coerce input to a string before attempting to parse + parsedURL = parse_url(`${input}`); + } + input = {}; + } else { + parsedURL = parse_url(input.url); + } + + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); + + if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { + throw new TypeError('Request with GET/HEAD method cannot have body'); + } + + let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; + + Body.call(this, inputBody, { + timeout: init.timeout || input.timeout || 0, + size: init.size || input.size || 0 + }); + + const headers = new Headers(init.headers || input.headers || {}); + + if (inputBody != null && !headers.has('Content-Type')) { + const contentType = extractContentType(inputBody); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + let signal = isRequest(input) ? input.signal : null; + if ('signal' in init) signal = init.signal; + + if (signal != null && !isAbortSignal(signal)) { + throw new TypeError('Expected signal to be an instanceof AbortSignal'); + } + + this[INTERNALS$2] = { + method, + redirect: init.redirect || input.redirect || 'follow', + headers, + parsedURL, + signal + }; + + // node-fetch-only options + this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; + this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; + this.counter = init.counter || input.counter || 0; + this.agent = init.agent || input.agent; + } + + get method() { + return this[INTERNALS$2].method; + } + + get url() { + return format_url(this[INTERNALS$2].parsedURL); + } + + get headers() { + return this[INTERNALS$2].headers; + } + + get redirect() { + return this[INTERNALS$2].redirect; + } + + get signal() { + return this[INTERNALS$2].signal; + } + + /** + * Clone this request + * + * @return Request + */ + clone() { + return new Request(this); + } +} + +Body.mixIn(Request.prototype); + +Object.defineProperty(Request.prototype, Symbol.toStringTag, { + value: 'Request', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Request.prototype, { + method: { enumerable: true }, + url: { enumerable: true }, + headers: { enumerable: true }, + redirect: { enumerable: true }, + clone: { enumerable: true }, + signal: { enumerable: true } +}); + +/** + * Convert a Request to Node.js http request options. + * + * @param Request A Request instance + * @return Object The options object to be passed to http.request + */ +function getNodeRequestOptions(request) { + const parsedURL = request[INTERNALS$2].parsedURL; + const headers = new Headers(request[INTERNALS$2].headers); + + // fetch step 1.3 + if (!headers.has('Accept')) { + headers.set('Accept', '*/*'); + } + + // Basic fetch + if (!parsedURL.protocol || !parsedURL.hostname) { + throw new TypeError('Only absolute URLs are supported'); + } + + if (!/^https?:$/.test(parsedURL.protocol)) { + throw new TypeError('Only HTTP(S) protocols are supported'); + } + + if (request.signal && request.body instanceof Stream__default['default'].Readable && !streamDestructionSupported) { + throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); + } + + // HTTP-network-or-cache fetch steps 2.4-2.7 + let contentLengthValue = null; + if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { + contentLengthValue = '0'; + } + if (request.body != null) { + const totalBytes = getTotalBytes(request); + if (typeof totalBytes === 'number') { + contentLengthValue = String(totalBytes); + } + } + if (contentLengthValue) { + headers.set('Content-Length', contentLengthValue); + } + + // HTTP-network-or-cache fetch step 2.11 + if (!headers.has('User-Agent')) { + headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); + } + + // HTTP-network-or-cache fetch step 2.15 + if (request.compress && !headers.has('Accept-Encoding')) { + headers.set('Accept-Encoding', 'gzip,deflate'); + } + + let agent = request.agent; + if (typeof agent === 'function') { + agent = agent(parsedURL); + } + + if (!headers.has('Connection') && !agent) { + headers.set('Connection', 'close'); + } + + // HTTP-network fetch step 4.2 + // chunked encoding is handled by Node.js + + return Object.assign({}, parsedURL, { + method: request.method, + headers: exportNodeCompatibleHeaders(headers), + agent + }); +} + +/** + * abort-error.js + * + * AbortError interface for cancelled requests + */ + +/** + * Create AbortError instance + * + * @param String message Error message for human + * @return AbortError + */ +function AbortError(message) { + Error.call(this, message); + + this.type = 'aborted'; + this.message = message; + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +AbortError.prototype = Object.create(Error.prototype); +AbortError.prototype.constructor = AbortError; +AbortError.prototype.name = 'AbortError'; + +// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 +const PassThrough$1 = Stream__default['default'].PassThrough; +const resolve_url = Url__default['default'].resolve; + +/** + * Fetch function + * + * @param Mixed url Absolute url or Request instance + * @param Object opts Fetch options + * @return Promise + */ +function fetch(url, opts) { + + // allow custom promise + if (!fetch.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } + + Body.Promise = fetch.Promise; + + // wrap http.request into fetch + return new fetch.Promise(function (resolve, reject) { + // build request object + const request = new Request(url, opts); + const options = getNodeRequestOptions(request); + + const send = (options.protocol === 'https:' ? https__default['default'] : http__default['default']).request; + const signal = request.signal; + + let response = null; + + const abort = function abort() { + let error = new AbortError('The user aborted a request.'); + reject(error); + if (request.body && request.body instanceof Stream__default['default'].Readable) { + request.body.destroy(error); + } + if (!response || !response.body) return; + response.body.emit('error', error); + }; + + if (signal && signal.aborted) { + abort(); + return; + } + + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; + + // send request + const req = send(options); + let reqTimeout; + + if (signal) { + signal.addEventListener('abort', abortAndFinalize); + } + + function finalize() { + req.abort(); + if (signal) signal.removeEventListener('abort', abortAndFinalize); + clearTimeout(reqTimeout); + } + + if (request.timeout) { + req.once('socket', function (socket) { + reqTimeout = setTimeout(function () { + reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); + finalize(); + }, request.timeout); + }); + } + + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + finalize(); + }); + + req.on('response', function (res) { + clearTimeout(reqTimeout); + + const headers = createHeadersLenient(res.headers); + + // HTTP fetch step 5 + if (fetch.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); + + // HTTP fetch step 5.3 + const locationURL = location === null ? null : resolve_url(request.url, location); + + // HTTP fetch step 5.5 + switch (request.redirect) { + case 'error': + reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); + finalize(); + return; + case 'manual': + // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. + if (locationURL !== null) { + // handle corrupted header + try { + headers.set('Location', locationURL); + } catch (err) { + // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request + reject(err); + } + } + break; + case 'follow': + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } + + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOpts = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: request.body, + signal: request.signal, + timeout: request.timeout, + size: request.size + }; + + // HTTP-redirect fetch step 9 + if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { + reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 11 + if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { + requestOpts.method = 'GET'; + requestOpts.body = undefined; + requestOpts.headers.delete('content-length'); + } + + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOpts))); + finalize(); + return; + } + } + + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); + + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter + }; + + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); + + // HTTP-network fetch step 12.1.1.4: handle content codings + + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { + response = new Response(body, response_options); + resolve(response); + return; + } + + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib__default['default'].Z_SYNC_FLUSH, + finishFlush: zlib__default['default'].Z_SYNC_FLUSH + }; + + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib__default['default'].createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); + return; + } + + // for deflate + if (codings == 'deflate' || codings == 'x-deflate') { + // handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = res.pipe(new PassThrough$1()); + raw.once('data', function (chunk) { + // see http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0F) === 0x08) { + body = body.pipe(zlib__default['default'].createInflate()); + } else { + body = body.pipe(zlib__default['default'].createInflateRaw()); + } + response = new Response(body, response_options); + resolve(response); + }); + return; + } + + // for br + if (codings == 'br' && typeof zlib__default['default'].createBrotliDecompress === 'function') { + body = body.pipe(zlib__default['default'].createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; + } + + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); + }); + + writeToStream(req, request); + }); +} +/** + * Redirect code matching + * + * @param Number code Status code + * @return Boolean + */ +fetch.isRedirect = function (code) { + return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; +}; + +// expose Promise +fetch.Promise = global.Promise; + +function noop$1() { } +function safe_not_equal(a, b) { + return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + +const subscriber_queue = []; +/** + * Creates a `Readable` store that allows reading by subscription. + * @param value initial value + * @param {StartStopNotifier}start start and stop notifications for subscriptions + */ +function readable(value, start) { + return { + subscribe: writable(value, start).subscribe + }; +} +/** + * Create a `Writable` store that allows both updating and reading by subscription. + * @param {*=}value initial value + * @param {StartStopNotifier=}start start and stop notifications for subscriptions + */ +function writable(value, start = noop$1) { + let stop; + const subscribers = []; + function set(new_value) { + if (safe_not_equal(value, new_value)) { + value = new_value; + if (stop) { // store is ready + const run_queue = !subscriber_queue.length; + for (let i = 0; i < subscribers.length; i += 1) { + const s = subscribers[i]; + s[1](); + subscriber_queue.push(s, value); + } + if (run_queue) { + for (let i = 0; i < subscriber_queue.length; i += 2) { + subscriber_queue[i][0](subscriber_queue[i + 1]); + } + subscriber_queue.length = 0; + } + } + } + } + function update(fn) { + set(fn(value)); + } + function subscribe(run, invalidate = noop$1) { + const subscriber = [run, invalidate]; + subscribers.push(subscriber); + if (subscribers.length === 1) { + stop = start(set) || noop$1; + } + run(value); + return () => { + const index = subscribers.indexOf(subscriber); + if (index !== -1) { + subscribers.splice(index, 1); + } + if (subscribers.length === 0) { + stop(); + stop = null; + } + }; + } + return { set, update, subscribe }; +} + +const noop$1$1 = () => {}; + + + + + + + +async function render_page( + request, + context, + options, + status = 200, + error = null +) + + + + + + + + { + let redirected; + let preload_error; + + const page = options.manifest.pages.find((page) => + page.pattern.test(request.path) + ); + + const baseUrl = ''; // TODO + + const session = await (options.setup.getSession && options.setup.getSession(context)); + + const serialized_session = try_serialize(session, (err) => { + throw new Error(`Failed to serialize session data: ${err.message}`); + }); + + try { + if (!page) { + const error = new Error(`Not found: ${request.path}`); + error.status = 404; + throw error; + } + + const segments = request.path.split('/').filter(Boolean); + + // TODO make this less confusing + const layout_segments = [segments[0]]; + let l = 1; + + page.parts.forEach((part, i) => { + layout_segments[l] = segments[i + 1]; + if (!part) return; + l++; + }); + + const dependencies = {}; + + const preload_context = { + redirect: (status, location) => { + if ( + redirected && + (redirected.status !== status || redirected.headers.location !== location) + ) { + throw new Error(`Conflicting redirects`); + } + location = location.replace(/^\//g, ''); // leading slash (only) + redirected = { + status, + headers: { location }, + body: null, + dependencies: {} + }; + }, + error: (status, error) => { + if (typeof error === 'string') { + error = new Error(error); + } + preload_error = { ...error, status }; + }, + fetch: async (url, opts = {}) => { + const parsed = Url.parse(url); + + if (parsed.protocol) { + // external fetch + return fetch(parsed.href, opts); + } + + // otherwise we're dealing with an internal fetch. TODO there's + // probably no advantage to using fetch here — we should replace + // `this.fetch` with `this.load` or whatever + + const resolved = Url.resolve(request.path, parsed.pathname); + + // edge case — fetching a static file + const candidates = [ + `${options.static_dir}${resolved}`, + `${options.static_dir}${resolved}/index.html` + ]; + for (const file of candidates) { + if (fs.existsSync(file)) { + return new Response(fs.createReadStream(file), { + headers: { + 'content-type': mime.getType(file) + } + }); + } + } + + // TODO this doesn't take account of opts.body + const rendered = await render( + { + host: request.host, + method: opts.method || 'GET', + headers: opts.headers || {}, // TODO inject credentials... + path: resolved, + body: opts.body, + query: new Url.URLSearchParams(parsed.query || '') + }, + options + ); + + if (rendered) { + // TODO this is primarily for the benefit of the static case, + // but could it be used elsewhere? + dependencies[resolved] = rendered; + + return new Response(rendered.body, { + status: rendered.status, + headers: rendered.headers + }); + } else { + return new Response('Not found', { + status: 404 + }); + } + } + }; + + const match = page.pattern.exec(request.path); + + // the last part has all parameters from any segment in the URL + const params = parts_to_params(match, page.parts[page.parts.length - 1] ); + + const preloaded = []; + let can_prerender = true; + + const parts = await Promise.all( + [{ component: options.manifest.layout, params: [] }, ...page.parts].map(async (part, i) => { + if (!part) return null; + + const mod = await options.load(part.component); + + if (options.only_prerender && !mod.prerender) { + can_prerender = false; + return; + } + + // these are only the parameters up to the current URL segment + const params = parts_to_params(match, part); + + const props = mod.preload + ? await mod.preload.call( + preload_context, + { + host: request.host, + path: request.path, + query: request.query, + params + }, + session + ) + : {}; + + preloaded[i] = props; + return { component: mod.default, props }; + }) + ); + + if (options.only_prerender && !can_prerender) return; + + if (preload_error) throw preload_error; + if (redirected) return redirected; + + const branches + + + + = []; + parts.forEach((part, i) => { + if (part) { + branches.push({ + component: part.component, + props: preloaded[i], + segment: segments[i] + }); + } + }); + + const pageContext = { + host: request.host , + path: request.path, + query: search_params_to_map(request.query), + params, + error: error || undefined + }; + + const props = { + status, + error, + stores: { + page: readable(pageContext, noop$1$1), + preloading: readable(null, noop$1$1), + session: writable(session) + }, + // TODO stores, status, segments, notify, CONTEXT_KEY + segments: layout_segments, + branches, + level0: { + props: preloaded[0] + }, + level1: { + segment: segments[0], + props: {} + } + }; + + // TODO this is highly confusing. replace the leveln thing with an array of branches + l = 1; + for (let i = 1; i < parts.length; i += 1) { + const part = parts[i]; + if (!part) continue; + + props[`level${l++}`] = { + component: part.component, + props: preloaded[i] || {}, + segment: segments[i] + }; + } + + const serialized_preloads = `[${preloaded + .map((data) => + try_serialize(data, (err) => { + const path = '/' + segments.join('/'); + console.error( + `Failed to serialize preloaded data to transmit to the client at the ${path} route: ${err.message}` + ); + console.warn( + 'The client will re-render over the server-rendered page fresh instead of continuing where it left off. See https://sapper.svelte.dev/docs#Return_value for more information' + ); + }) + ) + .join(',')}]`; + + const rendered = options.root.default.render(props); + + const deps = options.client.deps; + const js_deps = new Set(deps.__entry__ ? [...deps.__entry__.js] : []); + const css_deps = new Set(deps.__entry__ ? [...deps.__entry__.css] : []); + + (page.parts.filter(Boolean) ).forEach((part) => { + const page_deps = deps[part.component.name]; + + if (!page_deps) return; // we don't have this info during dev + + page_deps.js.forEach((dep) => js_deps.add(dep)); + page_deps.css.forEach((dep) => css_deps.add(dep)); + }); + + const head = `${rendered.head} + + ${Array.from(js_deps) + .map((dep) => ``) + .join('\n\t\t\t')} + ${Array.from(css_deps) + .map((dep) => ``) + .join('\n\t\t\t')} + ${options.dev ? `` : ''} + + `.replace(/^\t{2}/gm, ''); // TODO add links + + const body = `${rendered.html} + `.replace(/^\t{3}/gm, ''); + + const html = options.template.replace('%svelte.head%', head).replace('%svelte.body%', body); + + return { + status: 200, + headers: { + 'content-type': 'text/html' + }, + body: html, + dependencies + }; + } catch (thrown) { + console.error(thrown.stack); + + if (!error) { + const status = thrown.status || 500; + return render_page(request, context, options, status, thrown); + } else { + // oh lawd now you've done it + return { + status: 500, + headers: {}, + body: thrown.stack, // TODO probably not in prod? + dependencies: {} + }; + } + } +} + +function parts_to_params(match, part) { + const params = {}; + + part.params.forEach((name, i) => { + const is_spread = /^\.{3}.+$/.test(name); + + if (is_spread) { + params[name.slice(3)] = match[i + 1].split('/'); + } else { + params[name] = match[i + 1]; + } + }); + + return params; +} + +function try_serialize(data, fail) { + try { + return devalue(data); + } catch (err) { + if (fail) fail(err); + return null; + } +} + +// Ensure we return something truthy so the client will not re-render the page over the error +function serialize_error(error) { + if (!error) return null; + let serialized = try_serialize(error); + if (!serialized) { + const { name, message, stack } = error; + serialized = try_serialize({ name, message, stack }); + } + if (!serialized) { + serialized = '{}'; + } + return serialized; +} + +function search_params_to_map(params) { + const map = {}; + + for (const key of params.keys()) { + const values = params.getAll(key); + + map[key] = values.length > 1 ? values : values[0]; + } + + return map; +} + +function render_route( + request, + context, + options +) + + + + { + const route = options.manifest.endpoints.find((route) => + route.pattern.test(request.path) + ); + if (!route) return null; + + return Promise.resolve(options.load(route)).then(async (mod) => { + const handler = mod[request.method.toLowerCase().replace('delete', 'del')]; // 'delete' is a reserved word + + if (handler) { + const params = {}; + const match = route.pattern.exec(request.path); + route.params.forEach((name, i) => { + params[name] = match[i + 1]; + }); + + try { + let { status = 200, body, headers = {} } = await handler( + { + host: request.host, + path: request.path, + query: request.query, + body: request.body, + params + }, + context + ); + + headers = lowercase_keys(headers); + + if ( + (typeof body === 'object' && !('content-type' in headers)) || + headers['content-type'] === 'application/json' + ) { + headers = { ...headers, 'content-type': 'application/json' }; + body = JSON.stringify(body); + } + + return { status, body, headers }; + } catch (err) { + return { + status: 500, + body: err.message, + headers: {} + }; + } + } else { + return { + status: 501, + body: `${request.method} is not implemented for ${request.path}`, + headers: {} + }; + } + }); +} + +function lowercase_keys(obj) { + const clone = {}; + for (const key in obj) { + clone[key.toLowerCase()] = obj[key]; + } + return clone; +} + +function md5(body) { + return crypto.createHash('md5').update(body).digest('hex'); +} + +async function render( + request, + options +) { + const { context, headers = {} } = (await (options.setup.prepare && options.setup.prepare(request.headers))) || {}; + + try { + const response = await (render_route(request, context, options) || + render_page(request, context, options)); + + if (response) { + // inject ETags for 200 responses + if (response.status === 200) { + if (!/(no-store|immutable)/.test(response.headers['cache-control'])) { + const etag = `"${md5(response.body)}"`; + + if (request.headers['if-none-match'] === etag) { + return { + status: 304, + headers: {}, + body: null + }; + } + + response.headers['etag'] = etag; + } + } + + return { + status: response.status, + headers: { ...headers, ...response.headers }, + body: response.body + }; + } + } catch (err) { + return { + status: 500, + headers: {}, + body: options.dev ? err.stack : err.message + }; + } +} + +function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } + +function read_only_form_data() { + const map = new Map(); + + return { + append(key, value) { + if (map.has(key)) { + (map.get(key) ).push(value); + } else { + map.set(key, [value]); + } + }, + + data: new ReadOnlyFormData(map) + }; +} + +class ReadOnlyFormData { + #map + + constructor(map) { + this.#map = map; + } + + get(key) { + return _optionalChain([this, 'access', _ => _.#map, 'access', _2 => _2.get, 'call', _3 => _3(key), 'optionalAccess', _4 => _4[0]]); + } + + getAll(key) { + return this.#map.get(key); + } + + has(key) { + return this.#map.has(key); + } + + *[Symbol.iterator]() { + for (const [key, value] of this.#map) { + for (let i = 0; i < value.length; i += 1) { + yield [key, value[i]]; + } + } + } + + *entries() { + for (const [key, value] of this.#map) { + for (let i = 0; i < value.length; i += 1) { + yield [key, value[i]]; + } + } + } + + *keys() { + for (const [key, value] of this.#map) { + for (let i = 0; i < value.length; i += 1) { + yield key; + } + } + } + + *values() { + for (const [, value] of this.#map) { + for (let i = 0; i < value.length; i += 1) { + yield value; + } + } + } +} + +function get_body(req) { + const headers = req.headers; + const has_body = + headers['content-type'] !== undefined && + // https://github.com/jshttp/type-is/blob/c1f4388c71c8a01f79934e68f630ca4a15fffcd6/index.js#L81-L95 + (headers['transfer-encoding'] !== undefined || !isNaN(Number(headers['content-length']))); + + if (!has_body) return Promise.resolve(undefined); + + const [type, ...directives] = (headers['content-type'] ).split(/;\s*/); + + switch (type) { + case 'application/octet-stream': + return get_buffer(req); + + case 'text/plain': + return get_text(req); + + case 'application/json': + return get_json(req); + + case 'application/x-www-form-urlencoded': + return get_urlencoded(req); + + case 'multipart/form-data': + const boundary = directives.find((directive) => directive.startsWith('boundary=')); + if (!boundary) throw new Error(`Missing boundary`); + return get_multipart(req, boundary.slice('boundary='.length)); + + default: + throw new Error(`Invalid Content-Type ${type}`); + } +} + +async function get_json(req) { + return JSON.parse(await get_text(req)); +} + +async function get_urlencoded(req) { + const text = await get_text(req); + + const { data, append } = read_only_form_data(); + + text + .replace(/\+/g, ' ') + .split('&') + .forEach((str) => { + const [key, value] = str.split('='); + append(decodeURIComponent(key), decodeURIComponent(value)); + }); + + return data; +} + +async function get_multipart(req, boundary) { + const text = await get_text(req); + const parts = text.split(`--${boundary}`); + + const nope = () => { + throw new Error('Malformed form data'); + }; + + if (parts[0] !== '' || parts[parts.length - 1].trim() !== '--') { + nope(); + } + + const { data, append } = read_only_form_data(); + + parts.slice(1, -1).forEach((part) => { + const match = /\s*([\s\S]+?)\r\n\r\n([\s\S]*)\s*/.exec(part) ; + const raw_headers = match[1]; + const body = match[2].trim(); + + let key; + raw_headers.split('\r\n').forEach((str) => { + const [raw_header, ...raw_directives] = str.split('; '); + let [name, value] = raw_header.split(': '); + + name = name.toLowerCase(); + + const directives = {}; + raw_directives.forEach((raw_directive) => { + const [name, value] = raw_directive.split('='); + directives[name] = JSON.parse(value); // TODO is this right? + }); + + if (name === 'content-disposition') { + if (value !== 'form-data') nope(); + + if (directives.filename) { + // TODO we probably don't want to do this automatically + throw new Error('File upload is not yet implemented'); + } + + if (directives.name) { + key = directives.name; + } + } + }); + + if (!key) nope(); + + append(key, body); + }); + + return data; +} + +function get_text(req) { + return new Promise((fulfil, reject) => { + let data = ''; + + req.on('error', reject); + + req.on('data', (chunk) => { + data += chunk; + }); + + req.on('end', () => { + fulfil(data); + }); + }); +} + +function get_buffer(req) { + return new Promise((fulfil, reject) => { + let data = new Uint8Array(0); + + req.on('error', reject); + + req.on('data', (chunk) => { + const new_data = new Uint8Array(data.length + chunk.length); + + for (let i = 0; i < data.length; i += 1) { + new_data[i] = data[i]; + } + + for (let i = 0; i < chunk.length; i += 1) { + new_data[i + data.length] = chunk[i]; + } + + data = new_data; + }); + + req.on('end', () => { + fulfil(data.buffer); + }); + }); +} + +const manifest = require('./manifest.js'); +const client = require('./client.json'); + +const { PORT = 3000 } = process.env; + +const mutable = (dir) => + sirv(dir, { + etag: true, + maxAge: 0 + }); + +const static_handler = mutable('static'); +const prerendered_handler = fs.existsSync('build/prerendered') + ? mutable('build/prerendered') + : (_req, _res, next) => next(); + +const assets_handler = sirv('build/assets', { + maxAge: 31536000, + immutable: true +}); + +const root = require('./root.js'); +const setup = require('./setup.js'); +const template = fs.readFileSync('build/app.html', 'utf-8'); + +const server = http.createServer((req, res) => { + assets_handler(req, res, () => { + static_handler(req, res, () => { + prerendered_handler(req, res, async () => { + const parsed = Url.parse(req.url || ''); + + const rendered = await render( + { + host: null, // TODO + method: req.method , + headers: req.headers , // TODO: what about repeated headers, i.e. string[] + path: parsed.pathname , + body: await get_body(req), + query: new Url.URLSearchParams(parsed.query || '') + }, + { + static_dir: 'static', + template, + manifest, + client, + root, + setup, + load: (route) => + require(`./routes/${route.name}.js`), + dev: false, + only_prerender: false + } + ); + + if (rendered) { + res.writeHead(rendered.status, rendered.headers); + res.end(rendered.body); + } else { + res.statusCode = 404; + res.end('Not found'); + } + }); + }); + }); +}); + +server.listen(PORT, () => { + console.log(`Listening on port ${PORT}`); +}); diff --git a/packages/adapter-node/src/index.js b/packages/adapter-node/src/index.js new file mode 100644 index 000000000000..87f2b15e09f9 --- /dev/null +++ b/packages/adapter-node/src/index.js @@ -0,0 +1,58 @@ +import fs from 'fs'; + +import { copy } from '@sveltejs/app-utils/files'; +import { prerender } from '@sveltejs/app-utils/renderer'; + + +module.exports = async function adapter({ + dir, + manifest, + log +} + + + +) { + const out = 'build'; // TODO implement adapter options + + copy(`${dir}/client`, `${out}/assets/_app`, (file) => !!file && file[0] !== '.'); + copy(`${dir}/server`, out); + copy(`${__dirname}/server.js`, `${out}/index.js`); + copy(`${dir}/client.json`, `${out}/client.json`); + copy('src/app.html', `${out}/app.html`); + + log.info('Prerendering static pages...'); + + await prerender({ + force: true, + dir, + out: `${out}/prerendered`, + assets: `${out}/assets`, + manifest, + log + }); + + // generate manifest + const written_manifest = `module.exports = { + layout: ${JSON.stringify(manifest.layout)}, + error: ${JSON.stringify(manifest.error)}, + components: ${JSON.stringify(manifest.components)}, + pages: [ + ${manifest.pages + .map((page) => `{ pattern: ${page.pattern}, parts: ${JSON.stringify(page.parts)} }`) + .join(',\n\t\t\t')} + ], + endpoints: [ + ${manifest.endpoints + .map( + (route) => + `{ name: '${route.name}', pattern: ${route.pattern}, file: '${ + route.file + }', params: ${JSON.stringify(route.params)} }` + ) + .join(',\n\t\t\t')} + ] + };`.replace(/^\t/gm, ''); + + fs.writeFileSync(`${out}/manifest.js`, written_manifest); +}; diff --git a/packages/adapter-node/src/server.js b/packages/adapter-node/src/server.js new file mode 100644 index 000000000000..552f60400f9e --- /dev/null +++ b/packages/adapter-node/src/server.js @@ -0,0 +1,77 @@ +import * as fs from 'fs'; +import * as http from 'http'; +import { parse, URLSearchParams } from 'url'; +import sirv from 'sirv'; +import { render } from '@sveltejs/app-utils/renderer'; +import { get_body } from '@sveltejs/app-utils/http'; + + +const manifest = require('./manifest.js'); +const client = require('./client.json'); + +const { PORT = 3000 } = process.env; + +const mutable = (dir) => + sirv(dir, { + etag: true, + maxAge: 0 + }); + +const static_handler = mutable('static'); +const prerendered_handler = fs.existsSync('build/prerendered') + ? mutable('build/prerendered') + : (_req, _res, next) => next(); + +const assets_handler = sirv('build/assets', { + maxAge: 31536000, + immutable: true +}); + +const root = require('./root.js'); +const setup = require('./setup.js'); +const template = fs.readFileSync('build/app.html', 'utf-8'); + +const server = http.createServer((req, res) => { + assets_handler(req, res, () => { + static_handler(req, res, () => { + prerendered_handler(req, res, async () => { + const parsed = parse(req.url || ''); + + const rendered = await render( + { + host: null, // TODO + method: req.method , + headers: req.headers , // TODO: what about repeated headers, i.e. string[] + path: parsed.pathname , + body: await get_body(req), + query: new URLSearchParams(parsed.query || '') + }, + { + static_dir: 'static', + template, + manifest, + client, + root, + setup, + load: (route) => + require(`./routes/${route.name}.js`), + dev: false, + only_prerender: false + } + ); + + if (rendered) { + res.writeHead(rendered.status, rendered.headers); + res.end(rendered.body); + } else { + res.statusCode = 404; + res.end('Not found'); + } + }); + }); + }); +}); + +server.listen(PORT, () => { + console.log(`Listening on port ${PORT}`); +}); diff --git a/packages/adapter-static/.gitignore b/packages/adapter-static/.gitignore index 7fad62f488a3..e7565e1a9807 100644 --- a/packages/adapter-static/.gitignore +++ b/packages/adapter-static/.gitignore @@ -1,6 +1,3 @@ .DS_Store node_modules -index.js -index.d.ts -server.js -server.d.ts +/server.js diff --git a/packages/adapter-static/rollup.config.js b/packages/adapter-static/rollup.config.js index 6be1c1d5d3e4..d944379c4d9b 100644 --- a/packages/adapter-static/rollup.config.js +++ b/packages/adapter-static/rollup.config.js @@ -4,7 +4,7 @@ import commonjs from '@rollup/plugin-commonjs'; export default { input: 'src/index.js', output: { - file: 'server.js', + file: 'index.js', format: 'cjs' }, plugins: [nodeResolve(), commonjs()], diff --git a/packages/adapter-static/src/index.js b/packages/adapter-static/src/index.js new file mode 100644 index 000000000000..7d1442ebd3ac --- /dev/null +++ b/packages/adapter-static/src/index.js @@ -0,0 +1,27 @@ + +import { copy } from '@sveltejs/app-utils/files'; +import { prerender } from '@sveltejs/app-utils/renderer'; + + +module.exports = async function adapter({ + dir, + manifest, + log +} + + + +) { + const out = 'build'; // TODO implement adapter options + + copy('static', out); + copy(`${dir}/client`, `${out}/_app`); + + prerender({ + force: true, + dir, + out, + manifest, + log + }); +}; diff --git a/packages/adapter-vercel/.gitignore b/packages/adapter-vercel/.gitignore index 7fad62f488a3..84229219b559 100644 --- a/packages/adapter-vercel/.gitignore +++ b/packages/adapter-vercel/.gitignore @@ -1,6 +1,4 @@ .DS_Store node_modules -index.js -index.d.ts -server.js -server.d.ts +/index.js +/server.js diff --git a/packages/adapter-vercel/index.d.js b/packages/adapter-vercel/index.d.js deleted file mode 100644 index 2be8ffc5ce05..000000000000 --- a/packages/adapter-vercel/index.d.js +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/packages/adapter-vercel/server.d.js b/packages/adapter-vercel/server.d.js deleted file mode 100644 index 99a8091366e2..000000000000 --- a/packages/adapter-vercel/server.d.js +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/packages/adapter-vercel/src/index.js b/packages/adapter-vercel/src/index.js new file mode 100644 index 000000000000..05bd5bfee004 --- /dev/null +++ b/packages/adapter-vercel/src/index.js @@ -0,0 +1,68 @@ +import { writeFileSync, readFileSync } from 'fs'; +import { resolve, join } from 'path'; + +import { copy } from '@sveltejs/app-utils/files'; +import { prerender, generate_manifest_module } from '@sveltejs/app-utils/renderer'; + + +export async function builder({ + dir, + manifest, + log +} + + + +) { + const lambda_directory = resolve('api'); + const static_directory = resolve('public'); + const server_directory = resolve(join('api', 'server')); + + log.info('Writing client application...'); + copy('static', static_directory); + copy(resolve(dir, 'client'), join(static_directory, '_app')); + + log.info('Building lambda...'); + copy(resolve(__dirname, 'src'), lambda_directory); + copy(join(resolve(dir), 'client.json'), join(server_directory, 'client.json')); + const written_manifest = generate_manifest_module(manifest); + const htmlPath = resolve('src', 'app.html'); + const appHtml = readFileSync(htmlPath, 'utf-8'); + writeFileSync(join(server_directory, 'manifest.js'), written_manifest); + writeFileSync( + join(server_directory, 'template.js'), + `module.exports = ${JSON.stringify(appHtml)};` + ); + + log.info('Prerendering static pages...'); + await prerender({ + force: true, + dir, + out: static_directory, + manifest, + log + }); + + log.info('Writing server application...'); + copy(resolve(dir, 'server'), server_directory); + + // TODO: Merge this, rather than write it + log.info('Rewriting vercel configuration...'); + writeFileSync( + 'vercel.json', + JSON.stringify({ + public: true, + build: { + env: { + NODEJS_AWS_HANDLER_NAME: 'handler' + } + }, + rewrites: [ + { + source: '/(.*)', + destination: '/api/render/' + } + ] + }) + ); +} diff --git a/packages/adapter-vercel/src/server.js b/packages/adapter-vercel/src/server.js new file mode 100644 index 000000000000..68f85082b8a8 --- /dev/null +++ b/packages/adapter-vercel/src/server.js @@ -0,0 +1,68 @@ +import { URLSearchParams } from 'url'; +import { render } from '@sveltejs/app-utils/renderer'; + + + +const client = require('./server/client.json'); +const manifest = require('./server/manifest.js'); +const root = require('./server/root.js'); +const setup = require('./server/setup.js'); +const template = require('./server/template.js'); + +// TODO: This is the same as netlify's render function, and basically just builds an AWS lambda. +// We should extract it into some sort of lambda rendering package +export const handler = async (event) => { + const { + path, + httpMethod, + headers, + queryStringParameters, + body + // isBase64Encoded // TODO is this useful? + } = event; + + const query = new URLSearchParams(); + for (const k in queryStringParameters) { + const value = queryStringParameters[k]; + value.split(', ').forEach((v) => { + query.append(k, v); + }); + } + + const rendered = await render( + { + host: null, // TODO + method: httpMethod , + headers, + path, + body, + query + }, + { + static_dir: 'static', + template, + manifest, + client, + root, + setup, + load: (route) => + require(`./server/routes/${route.name}.js`), + dev: false, + only_prerender: false + } + ); + + if (rendered) { + return { + isBase64Encoded: false, + statusCode: rendered.status, + headers: rendered.headers, + body: rendered.body + }; + } + + return { + statusCode: 404, + body: 'Not found' + }; +}; diff --git a/packages/app-utils/src/renderer/render/index.js b/packages/app-utils/src/renderer/render/index.js index d2dd29cd865b..e90ba9cb8c93 100644 --- a/packages/app-utils/src/renderer/render/index.js +++ b/packages/app-utils/src/renderer/render/index.js @@ -1,4 +1,4 @@ - function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }import { createHash } from 'crypto'; +import { createHash } from 'crypto'; import render_page from './page'; import render_endpoint from './endpoint'; diff --git a/packages/app-utils/src/renderer/render/page.js b/packages/app-utils/src/renderer/render/page.js index e99da6cfaf45..2fdfd2c05adb 100644 --- a/packages/app-utils/src/renderer/render/page.js +++ b/packages/app-utils/src/renderer/render/page.js @@ -1,4 +1,4 @@ - function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }import devalue from 'devalue'; +import devalue from 'devalue'; import { createReadStream, existsSync } from 'fs'; import * as mime from 'mime'; import fetch, { Response } from 'node-fetch'; From b13560b29e7fd941c60fcf4f07a49f07f643cf53 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 18:20:28 -0500 Subject: [PATCH 08/30] add back some missing files --- packages/adapter-netlify/.gitignore | 6 +- packages/adapter-netlify/src/index.js | 97 ++++++++++++++++++++++++ packages/adapter-netlify/src/render.js | 68 +++++++++++++++++ packages/adapter-node/src/index.js | 58 ++++++++++++++ packages/adapter-node/src/server.js | 77 +++++++++++++++++++ packages/adapter-static/.gitignore | 5 +- packages/adapter-static/rollup.config.js | 2 +- packages/adapter-static/src/index.js | 27 +++++++ packages/adapter-vercel/.gitignore | 6 +- packages/adapter-vercel/index.d.js | 7 -- packages/adapter-vercel/server.d.js | 2 - packages/adapter-vercel/src/index.js | 68 +++++++++++++++++ packages/adapter-vercel/src/server.js | 68 +++++++++++++++++ 13 files changed, 469 insertions(+), 22 deletions(-) create mode 100644 packages/adapter-netlify/src/index.js create mode 100644 packages/adapter-netlify/src/render.js create mode 100644 packages/adapter-node/src/index.js create mode 100644 packages/adapter-node/src/server.js create mode 100644 packages/adapter-static/src/index.js delete mode 100644 packages/adapter-vercel/index.d.js delete mode 100644 packages/adapter-vercel/server.d.js create mode 100644 packages/adapter-vercel/src/index.js create mode 100644 packages/adapter-vercel/src/server.js diff --git a/packages/adapter-netlify/.gitignore b/packages/adapter-netlify/.gitignore index 80faee3407c0..4fd626439822 100644 --- a/packages/adapter-netlify/.gitignore +++ b/packages/adapter-netlify/.gitignore @@ -1,6 +1,4 @@ .DS_Store node_modules -index.js -index.d.ts -render.js -render.d.ts +/index.js +/render.js \ No newline at end of file diff --git a/packages/adapter-netlify/src/index.js b/packages/adapter-netlify/src/index.js new file mode 100644 index 000000000000..a8c81adf2b7b --- /dev/null +++ b/packages/adapter-netlify/src/index.js @@ -0,0 +1,97 @@ +import fs from 'fs'; +import path from 'path'; +import toml from 'toml'; +import glob from 'tiny-glob/sync'; + +import { mkdirp } from '@sveltejs/app-utils/files'; +import { prerender, generate_manifest_module } from '@sveltejs/app-utils/renderer'; + + +module.exports = async function builder({ + dir, + manifest, + log +} + + + +) { + let netlify_config; + + if (fs.existsSync('netlify.toml')) { + try { + netlify_config = toml.parse(fs.readFileSync('netlify.toml', 'utf-8')); + } catch (err) { + err.message = `Error parsing netlify.toml: ${err.message}`; + throw err; + } + } else { + throw new Error( + 'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration' + ); + } + + if (!netlify_config.build || !netlify_config.build.publish || !netlify_config.build.functions) { + throw new Error( + 'You must specify build.publish and build.functions in netlify.toml. Consult https://github.com/sveltejs/adapter-netlify#configuration' + ); + } + + const publish = path.resolve(netlify_config.build.publish); + const functions = path.resolve(netlify_config.build.functions); + + mkdirp(`${publish}/_app`); + mkdirp(`${functions}/render`); + + // copy everything in `static` + glob('**/*', { cwd: 'static', filesOnly: true }).forEach((file) => { + mkdirp(path.dirname(`${publish}/${file}`)); + fs.copyFileSync(`static/${file}`, `${publish}/${file}`); + }); + + // copy client code + const client_code = path.resolve(dir, 'client'); + glob('**/*', { cwd: client_code, filesOnly: true }).forEach((file) => { + if (file[0] !== '.') { + mkdirp(path.dirname(`${publish}/_app/${file}`)); + fs.copyFileSync(`${client_code}/${file}`, `${publish}/_app/${file}`); + } + }); + + // prerender + log.info('Prerendering static pages...'); + await prerender({ + force: true, + dir, + out: publish, + manifest, + log + }); + + // copy server code + const server_code = path.resolve(dir, 'server'); + glob('**/*', { cwd: server_code, filesOnly: true }).forEach((file) => { + if (file[0] !== '.') { + mkdirp(path.dirname(`${functions}/render/${file}`)); + fs.copyFileSync(`${server_code}/${file}`, `${functions}/render/${file}`); + } + }); + + // copy the renderer + fs.copyFileSync(path.resolve(__dirname, 'render.js'), `${functions}/render/index.js`); + + // write manifest + fs.writeFileSync(`${functions}/render/manifest.js`, generate_manifest_module(manifest)); + + // copy client manifest + fs.copyFileSync(`${dir}/client.json`, `${functions}/render/client.json`); + + // copy template + fs.writeFileSync( + `${functions}/render/template.js`, + `module.exports = ${JSON.stringify(fs.readFileSync('src/app.html', 'utf-8'))};` + ); + + // create _redirects + fs.writeFileSync(`${publish}/_redirects`, '/* /.netlify/functions/render 200'); +}; diff --git a/packages/adapter-netlify/src/render.js b/packages/adapter-netlify/src/render.js new file mode 100644 index 000000000000..04fce0b86c83 --- /dev/null +++ b/packages/adapter-netlify/src/render.js @@ -0,0 +1,68 @@ + +import { URLSearchParams } from 'url'; +import { render } from '@sveltejs/app-utils/renderer'; + + +const manifest = require('./manifest.js'); +const client = require('./client.json'); +const root = require('./root.js'); +const setup = require('./setup.js'); +const template = require('./template.js'); + +// TODO this is a generic AWS lambda handler, and could be +// reused by other adapters + +export const handler = async (event) => { + const { + path, + httpMethod, + headers, + queryStringParameters + // body, // TODO pass this to renderer + // isBase64Encoded // TODO is this useful? + } = event; + + const query = new URLSearchParams(); + for (const k in queryStringParameters) { + const value = queryStringParameters[k]; + value.split(', ').forEach((v) => { + query.append(k, v); + }); + } + + const rendered = await render( + { + host: null, // TODO + method: httpMethod , + headers, + path, + query + }, + { + static_dir: 'static', + template, + manifest, + client, + root, + setup, + load: (route) => + require(`./routes/${route.name}.js`), + dev: false, + only_prerender: false + } + ); + + if (rendered) { + return { + isBase64Encoded: false, + statusCode: rendered.status, + headers: rendered.headers, + body: rendered.body + }; + } + + return { + statusCode: 404, + body: 'Not found' + }; +}; diff --git a/packages/adapter-node/src/index.js b/packages/adapter-node/src/index.js new file mode 100644 index 000000000000..87f2b15e09f9 --- /dev/null +++ b/packages/adapter-node/src/index.js @@ -0,0 +1,58 @@ +import fs from 'fs'; + +import { copy } from '@sveltejs/app-utils/files'; +import { prerender } from '@sveltejs/app-utils/renderer'; + + +module.exports = async function adapter({ + dir, + manifest, + log +} + + + +) { + const out = 'build'; // TODO implement adapter options + + copy(`${dir}/client`, `${out}/assets/_app`, (file) => !!file && file[0] !== '.'); + copy(`${dir}/server`, out); + copy(`${__dirname}/server.js`, `${out}/index.js`); + copy(`${dir}/client.json`, `${out}/client.json`); + copy('src/app.html', `${out}/app.html`); + + log.info('Prerendering static pages...'); + + await prerender({ + force: true, + dir, + out: `${out}/prerendered`, + assets: `${out}/assets`, + manifest, + log + }); + + // generate manifest + const written_manifest = `module.exports = { + layout: ${JSON.stringify(manifest.layout)}, + error: ${JSON.stringify(manifest.error)}, + components: ${JSON.stringify(manifest.components)}, + pages: [ + ${manifest.pages + .map((page) => `{ pattern: ${page.pattern}, parts: ${JSON.stringify(page.parts)} }`) + .join(',\n\t\t\t')} + ], + endpoints: [ + ${manifest.endpoints + .map( + (route) => + `{ name: '${route.name}', pattern: ${route.pattern}, file: '${ + route.file + }', params: ${JSON.stringify(route.params)} }` + ) + .join(',\n\t\t\t')} + ] + };`.replace(/^\t/gm, ''); + + fs.writeFileSync(`${out}/manifest.js`, written_manifest); +}; diff --git a/packages/adapter-node/src/server.js b/packages/adapter-node/src/server.js new file mode 100644 index 000000000000..552f60400f9e --- /dev/null +++ b/packages/adapter-node/src/server.js @@ -0,0 +1,77 @@ +import * as fs from 'fs'; +import * as http from 'http'; +import { parse, URLSearchParams } from 'url'; +import sirv from 'sirv'; +import { render } from '@sveltejs/app-utils/renderer'; +import { get_body } from '@sveltejs/app-utils/http'; + + +const manifest = require('./manifest.js'); +const client = require('./client.json'); + +const { PORT = 3000 } = process.env; + +const mutable = (dir) => + sirv(dir, { + etag: true, + maxAge: 0 + }); + +const static_handler = mutable('static'); +const prerendered_handler = fs.existsSync('build/prerendered') + ? mutable('build/prerendered') + : (_req, _res, next) => next(); + +const assets_handler = sirv('build/assets', { + maxAge: 31536000, + immutable: true +}); + +const root = require('./root.js'); +const setup = require('./setup.js'); +const template = fs.readFileSync('build/app.html', 'utf-8'); + +const server = http.createServer((req, res) => { + assets_handler(req, res, () => { + static_handler(req, res, () => { + prerendered_handler(req, res, async () => { + const parsed = parse(req.url || ''); + + const rendered = await render( + { + host: null, // TODO + method: req.method , + headers: req.headers , // TODO: what about repeated headers, i.e. string[] + path: parsed.pathname , + body: await get_body(req), + query: new URLSearchParams(parsed.query || '') + }, + { + static_dir: 'static', + template, + manifest, + client, + root, + setup, + load: (route) => + require(`./routes/${route.name}.js`), + dev: false, + only_prerender: false + } + ); + + if (rendered) { + res.writeHead(rendered.status, rendered.headers); + res.end(rendered.body); + } else { + res.statusCode = 404; + res.end('Not found'); + } + }); + }); + }); +}); + +server.listen(PORT, () => { + console.log(`Listening on port ${PORT}`); +}); diff --git a/packages/adapter-static/.gitignore b/packages/adapter-static/.gitignore index 7fad62f488a3..6e2e5caf77b0 100644 --- a/packages/adapter-static/.gitignore +++ b/packages/adapter-static/.gitignore @@ -1,6 +1,3 @@ .DS_Store node_modules -index.js -index.d.ts -server.js -server.d.ts +/index.js \ No newline at end of file diff --git a/packages/adapter-static/rollup.config.js b/packages/adapter-static/rollup.config.js index 6be1c1d5d3e4..d944379c4d9b 100644 --- a/packages/adapter-static/rollup.config.js +++ b/packages/adapter-static/rollup.config.js @@ -4,7 +4,7 @@ import commonjs from '@rollup/plugin-commonjs'; export default { input: 'src/index.js', output: { - file: 'server.js', + file: 'index.js', format: 'cjs' }, plugins: [nodeResolve(), commonjs()], diff --git a/packages/adapter-static/src/index.js b/packages/adapter-static/src/index.js new file mode 100644 index 000000000000..7d1442ebd3ac --- /dev/null +++ b/packages/adapter-static/src/index.js @@ -0,0 +1,27 @@ + +import { copy } from '@sveltejs/app-utils/files'; +import { prerender } from '@sveltejs/app-utils/renderer'; + + +module.exports = async function adapter({ + dir, + manifest, + log +} + + + +) { + const out = 'build'; // TODO implement adapter options + + copy('static', out); + copy(`${dir}/client`, `${out}/_app`); + + prerender({ + force: true, + dir, + out, + manifest, + log + }); +}; diff --git a/packages/adapter-vercel/.gitignore b/packages/adapter-vercel/.gitignore index 7fad62f488a3..84229219b559 100644 --- a/packages/adapter-vercel/.gitignore +++ b/packages/adapter-vercel/.gitignore @@ -1,6 +1,4 @@ .DS_Store node_modules -index.js -index.d.ts -server.js -server.d.ts +/index.js +/server.js diff --git a/packages/adapter-vercel/index.d.js b/packages/adapter-vercel/index.d.js deleted file mode 100644 index 2be8ffc5ce05..000000000000 --- a/packages/adapter-vercel/index.d.js +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/packages/adapter-vercel/server.d.js b/packages/adapter-vercel/server.d.js deleted file mode 100644 index 99a8091366e2..000000000000 --- a/packages/adapter-vercel/server.d.js +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/packages/adapter-vercel/src/index.js b/packages/adapter-vercel/src/index.js new file mode 100644 index 000000000000..05bd5bfee004 --- /dev/null +++ b/packages/adapter-vercel/src/index.js @@ -0,0 +1,68 @@ +import { writeFileSync, readFileSync } from 'fs'; +import { resolve, join } from 'path'; + +import { copy } from '@sveltejs/app-utils/files'; +import { prerender, generate_manifest_module } from '@sveltejs/app-utils/renderer'; + + +export async function builder({ + dir, + manifest, + log +} + + + +) { + const lambda_directory = resolve('api'); + const static_directory = resolve('public'); + const server_directory = resolve(join('api', 'server')); + + log.info('Writing client application...'); + copy('static', static_directory); + copy(resolve(dir, 'client'), join(static_directory, '_app')); + + log.info('Building lambda...'); + copy(resolve(__dirname, 'src'), lambda_directory); + copy(join(resolve(dir), 'client.json'), join(server_directory, 'client.json')); + const written_manifest = generate_manifest_module(manifest); + const htmlPath = resolve('src', 'app.html'); + const appHtml = readFileSync(htmlPath, 'utf-8'); + writeFileSync(join(server_directory, 'manifest.js'), written_manifest); + writeFileSync( + join(server_directory, 'template.js'), + `module.exports = ${JSON.stringify(appHtml)};` + ); + + log.info('Prerendering static pages...'); + await prerender({ + force: true, + dir, + out: static_directory, + manifest, + log + }); + + log.info('Writing server application...'); + copy(resolve(dir, 'server'), server_directory); + + // TODO: Merge this, rather than write it + log.info('Rewriting vercel configuration...'); + writeFileSync( + 'vercel.json', + JSON.stringify({ + public: true, + build: { + env: { + NODEJS_AWS_HANDLER_NAME: 'handler' + } + }, + rewrites: [ + { + source: '/(.*)', + destination: '/api/render/' + } + ] + }) + ); +} diff --git a/packages/adapter-vercel/src/server.js b/packages/adapter-vercel/src/server.js new file mode 100644 index 000000000000..68f85082b8a8 --- /dev/null +++ b/packages/adapter-vercel/src/server.js @@ -0,0 +1,68 @@ +import { URLSearchParams } from 'url'; +import { render } from '@sveltejs/app-utils/renderer'; + + + +const client = require('./server/client.json'); +const manifest = require('./server/manifest.js'); +const root = require('./server/root.js'); +const setup = require('./server/setup.js'); +const template = require('./server/template.js'); + +// TODO: This is the same as netlify's render function, and basically just builds an AWS lambda. +// We should extract it into some sort of lambda rendering package +export const handler = async (event) => { + const { + path, + httpMethod, + headers, + queryStringParameters, + body + // isBase64Encoded // TODO is this useful? + } = event; + + const query = new URLSearchParams(); + for (const k in queryStringParameters) { + const value = queryStringParameters[k]; + value.split(', ').forEach((v) => { + query.append(k, v); + }); + } + + const rendered = await render( + { + host: null, // TODO + method: httpMethod , + headers, + path, + body, + query + }, + { + static_dir: 'static', + template, + manifest, + client, + root, + setup, + load: (route) => + require(`./server/routes/${route.name}.js`), + dev: false, + only_prerender: false + } + ); + + if (rendered) { + return { + isBase64Encoded: false, + statusCode: rendered.status, + headers: rendered.headers, + body: rendered.body + }; + } + + return { + statusCode: 404, + body: 'Not found' + }; +}; From bfed3aa505af3156da39d0ae477f19bc1a7cc348 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 18:45:05 -0500 Subject: [PATCH 09/30] tidy up --- packages/adapter-netlify/src/index.js | 8 +- packages/adapter-netlify/src/render.js | 4 +- packages/adapter-node/src/index.js | 8 +- packages/adapter-node/src/server.js | 7 +- packages/adapter-static/src/index.js | 7 +- packages/adapter-vercel/src/index.js | 8 +- packages/adapter-vercel/src/server.js | 4 +- .../src/http/get_body/read_only_form_data.js | 5 +- .../app-utils/src/renderer/manifest/index.js | 2 - .../src/renderer/manifest/index.spec.data.js | 2 - .../app-utils/src/renderer/prerender/index.js | 23 +--- .../app-utils/src/renderer/render/endpoint.js | 8 +- .../app-utils/src/renderer/render/index.js | 5 +- .../app-utils/src/renderer/render/page.js | 39 +----- packages/app-utils/src/types/index.js | 121 ------------------ packages/kit/src/api/build/index.js | 22 ++-- packages/kit/src/api/dev/index.js | 26 +--- packages/kit/src/api/dev/loader.js | 6 +- packages/kit/src/api/dev/types.js | 46 ------- packages/kit/src/core/create_app.js | 14 +- packages/kit/src/core/create_manifest_data.js | 17 +-- packages/kit/src/interfaces.js | 81 ------------ .../kit/src/runtime/navigation/internal.js | 1 - .../src/runtime/navigation/prefetch/index.js | 6 +- .../kit/src/runtime/navigation/start/index.js | 3 - .../runtime/navigation/start/page_store.js | 21 +-- packages/kit/src/runtime/navigation/types.js | 51 -------- packages/kit/src/runtime/stores/index.js | 14 +- 28 files changed, 47 insertions(+), 512 deletions(-) delete mode 100644 packages/app-utils/src/types/index.js delete mode 100644 packages/kit/src/api/dev/types.js delete mode 100644 packages/kit/src/interfaces.js delete mode 100644 packages/kit/src/runtime/navigation/types.js diff --git a/packages/adapter-netlify/src/index.js b/packages/adapter-netlify/src/index.js index a8c81adf2b7b..9c31ff7303f7 100644 --- a/packages/adapter-netlify/src/index.js +++ b/packages/adapter-netlify/src/index.js @@ -2,20 +2,14 @@ import fs from 'fs'; import path from 'path'; import toml from 'toml'; import glob from 'tiny-glob/sync'; - import { mkdirp } from '@sveltejs/app-utils/files'; import { prerender, generate_manifest_module } from '@sveltejs/app-utils/renderer'; - module.exports = async function builder({ dir, manifest, log -} - - - -) { +}) { let netlify_config; if (fs.existsSync('netlify.toml')) { diff --git a/packages/adapter-netlify/src/render.js b/packages/adapter-netlify/src/render.js index 04fce0b86c83..015b4d308bf4 100644 --- a/packages/adapter-netlify/src/render.js +++ b/packages/adapter-netlify/src/render.js @@ -1,8 +1,6 @@ - import { URLSearchParams } from 'url'; import { render } from '@sveltejs/app-utils/renderer'; - const manifest = require('./manifest.js'); const client = require('./client.json'); const root = require('./root.js'); @@ -33,7 +31,7 @@ export const handler = async (event) => { const rendered = await render( { host: null, // TODO - method: httpMethod , + method: httpMethod, headers, path, query diff --git a/packages/adapter-node/src/index.js b/packages/adapter-node/src/index.js index 87f2b15e09f9..6029803240ed 100644 --- a/packages/adapter-node/src/index.js +++ b/packages/adapter-node/src/index.js @@ -1,18 +1,12 @@ import fs from 'fs'; - import { copy } from '@sveltejs/app-utils/files'; import { prerender } from '@sveltejs/app-utils/renderer'; - module.exports = async function adapter({ dir, manifest, log -} - - - -) { +}) { const out = 'build'; // TODO implement adapter options copy(`${dir}/client`, `${out}/assets/_app`, (file) => !!file && file[0] !== '.'); diff --git a/packages/adapter-node/src/server.js b/packages/adapter-node/src/server.js index 552f60400f9e..07eac31e58bc 100644 --- a/packages/adapter-node/src/server.js +++ b/packages/adapter-node/src/server.js @@ -5,7 +5,6 @@ import sirv from 'sirv'; import { render } from '@sveltejs/app-utils/renderer'; import { get_body } from '@sveltejs/app-utils/http'; - const manifest = require('./manifest.js'); const client = require('./client.json'); @@ -40,9 +39,9 @@ const server = http.createServer((req, res) => { const rendered = await render( { host: null, // TODO - method: req.method , - headers: req.headers , // TODO: what about repeated headers, i.e. string[] - path: parsed.pathname , + method: req.method, + headers: req.headers, // TODO: what about repeated headers, i.e. string[] + path: parsed.pathname, body: await get_body(req), query: new URLSearchParams(parsed.query || '') }, diff --git a/packages/adapter-static/src/index.js b/packages/adapter-static/src/index.js index 7d1442ebd3ac..945cf8576b77 100644 --- a/packages/adapter-static/src/index.js +++ b/packages/adapter-static/src/index.js @@ -2,16 +2,11 @@ import { copy } from '@sveltejs/app-utils/files'; import { prerender } from '@sveltejs/app-utils/renderer'; - module.exports = async function adapter({ dir, manifest, log -} - - - -) { +}) { const out = 'build'; // TODO implement adapter options copy('static', out); diff --git a/packages/adapter-vercel/src/index.js b/packages/adapter-vercel/src/index.js index 05bd5bfee004..0af7338c0c19 100644 --- a/packages/adapter-vercel/src/index.js +++ b/packages/adapter-vercel/src/index.js @@ -1,19 +1,13 @@ import { writeFileSync, readFileSync } from 'fs'; import { resolve, join } from 'path'; - import { copy } from '@sveltejs/app-utils/files'; import { prerender, generate_manifest_module } from '@sveltejs/app-utils/renderer'; - export async function builder({ dir, manifest, log -} - - - -) { +}) { const lambda_directory = resolve('api'); const static_directory = resolve('public'); const server_directory = resolve(join('api', 'server')); diff --git a/packages/adapter-vercel/src/server.js b/packages/adapter-vercel/src/server.js index 68f85082b8a8..c6c0e2a1650d 100644 --- a/packages/adapter-vercel/src/server.js +++ b/packages/adapter-vercel/src/server.js @@ -1,8 +1,6 @@ import { URLSearchParams } from 'url'; import { render } from '@sveltejs/app-utils/renderer'; - - const client = require('./server/client.json'); const manifest = require('./server/manifest.js'); const root = require('./server/root.js'); @@ -32,7 +30,7 @@ export const handler = async (event) => { const rendered = await render( { host: null, // TODO - method: httpMethod , + method: httpMethod, headers, path, body, diff --git a/packages/app-utils/src/http/get_body/read_only_form_data.js b/packages/app-utils/src/http/get_body/read_only_form_data.js index bbbeee5f3891..ccbaa7c589b7 100644 --- a/packages/app-utils/src/http/get_body/read_only_form_data.js +++ b/packages/app-utils/src/http/get_body/read_only_form_data.js @@ -1,5 +1,3 @@ - function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } - export function read_only_form_data() { const map = new Map(); @@ -24,7 +22,8 @@ class ReadOnlyFormData { } get(key) { - return _optionalChain([this, 'access', _ => _.#map, 'access', _2 => _2.get, 'call', _3 => _3(key), 'optionalAccess', _4 => _4[0]]); + const value = this.#map.get(key); + return value && value[0]; } getAll(key) { diff --git a/packages/app-utils/src/renderer/manifest/index.js b/packages/app-utils/src/renderer/manifest/index.js index 3ea1b8cb6a66..4f393d28a1a3 100644 --- a/packages/app-utils/src/renderer/manifest/index.js +++ b/packages/app-utils/src/renderer/manifest/index.js @@ -1,5 +1,3 @@ - - const array_item_delimiter = ','; function map_pages(pages) { diff --git a/packages/app-utils/src/renderer/manifest/index.spec.data.js b/packages/app-utils/src/renderer/manifest/index.spec.data.js index 66fb6adfc717..6da7b58107d9 100644 --- a/packages/app-utils/src/renderer/manifest/index.spec.data.js +++ b/packages/app-utils/src/renderer/manifest/index.spec.data.js @@ -1,5 +1,3 @@ - - const examplePageComponentManifest = { default: true, type: 'foo', diff --git a/packages/app-utils/src/renderer/prerender/index.js b/packages/app-utils/src/renderer/prerender/index.js index e0ac87ab0f67..3e86fd2cedd0 100644 --- a/packages/app-utils/src/renderer/prerender/index.js +++ b/packages/app-utils/src/renderer/prerender/index.js @@ -1,10 +1,9 @@ - function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }import fs from 'fs'; +import fs from 'fs'; import { dirname, resolve as resolve_path } from 'path'; import { parse, resolve, URLSearchParams } from 'url'; import { mkdirp } from '../../files'; import { render } from '../render'; - function clean_html(html) { return html .replace(//gm, '') @@ -44,14 +43,6 @@ function get_srcset_urls(attrs) { const OK = 2; const REDIRECT = 3; - - - - - - - - export async function prerender({ dir, out, @@ -59,14 +50,7 @@ export async function prerender({ manifest, force, log -} - - - - - - -) { +}) { const seen = new Set(); const template = fs.readFileSync('src/app.html', 'utf-8'); @@ -105,7 +89,8 @@ export async function prerender({ if (rendered) { const response_type = Math.floor(rendered.status / 100); const headers = rendered.headers; - const is_html = response_type === REDIRECT || _optionalChain([headers, 'optionalAccess', _ => _['content-type']]) === 'text/html'; + const type = headers && headers['content-type']; + const is_html = response_type === REDIRECT || type === 'text/html'; const parts = path.split('/'); if (is_html && parts[parts.length - 1] !== 'index.html') { diff --git a/packages/app-utils/src/renderer/render/endpoint.js b/packages/app-utils/src/renderer/render/endpoint.js index 3b10c92b72dd..b20f67b242ea 100644 --- a/packages/app-utils/src/renderer/render/endpoint.js +++ b/packages/app-utils/src/renderer/render/endpoint.js @@ -1,14 +1,8 @@ - - export default function render_route( request, context, options -) - - - - { +) { const route = options.manifest.endpoints.find((route) => route.pattern.test(request.path) ); diff --git a/packages/app-utils/src/renderer/render/index.js b/packages/app-utils/src/renderer/render/index.js index 500c025bcdf7..71a00ff5d4a4 100644 --- a/packages/app-utils/src/renderer/render/index.js +++ b/packages/app-utils/src/renderer/render/index.js @@ -1,8 +1,7 @@ - function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }import { createHash } from 'crypto'; +import { createHash } from 'crypto'; import render_page from './page'; import render_endpoint from './endpoint'; - function md5(body) { return createHash('md5').update(body).digest('hex'); } @@ -11,7 +10,7 @@ export async function render( request, options ) { - const { context, headers = {} } = (await _optionalChain([options, 'access', _ => _.setup, 'access', _2 => _2.prepare, 'optionalCall', _3 => _3(request.headers)])) || {}; + const { context, headers = {} } = (await (options.setup.prepare && options.setup.prepare(request.headers))) || {}; try { const response = await (render_endpoint(request, context, options) || diff --git a/packages/app-utils/src/renderer/render/page.js b/packages/app-utils/src/renderer/render/page.js index 61c5c8b330b6..3d6c602d8826 100644 --- a/packages/app-utils/src/renderer/render/page.js +++ b/packages/app-utils/src/renderer/render/page.js @@ -1,45 +1,20 @@ - function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }import devalue from 'devalue'; + import devalue from 'devalue'; import { createReadStream, existsSync } from 'fs'; import * as mime from 'mime'; import fetch, { Response } from 'node-fetch'; import { readable, writable } from 'svelte/store'; import { parse, resolve, URLSearchParams } from 'url'; - - - - - - - - - - - import { render } from './index'; const noop = () => {}; - - - - - - export default async function render_page( request, context, options, status = 200, error = null -) - - - - - - - - { +) { let redirected; let preload_error; @@ -49,7 +24,7 @@ export default async function render_page( const baseUrl = ''; // TODO - const session = await _optionalChain([options, 'access', _ => _.setup, 'access', _2 => _2.getSession, 'optionalCall', _3 => _3(context)]); + const session = await (options.setup.getSession && options.setup.getSession(context)); const serialized_session = try_serialize(session, (err) => { throw new Error(`Failed to serialize session data: ${err.message}`); @@ -82,7 +57,7 @@ export default async function render_page( redirected && (redirected.status !== status || redirected.headers.location !== location) ) { - throw new Error(`Conflicting redirects`); + throw new Error('Conflicting redirects'); } location = location.replace(/^\//g, ''); // leading slash (only) redirected = { @@ -202,11 +177,7 @@ export default async function render_page( if (preload_error) throw preload_error; if (redirected) return redirected; - const branches - - - - = []; + const branches = []; parts.forEach((part, i) => { if (part) { branches.push({ diff --git a/packages/app-utils/src/types/index.js b/packages/app-utils/src/types/index.js deleted file mode 100644 index 76fe47c37a9f..000000000000 --- a/packages/app-utils/src/types/index.js +++ /dev/null @@ -1,121 +0,0 @@ - - -// do not import this file from outside app-utils -// these types are re-exported in /index.d.ts and should be imported from "@sveltejs/app-utils" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/kit/src/api/build/index.js b/packages/kit/src/api/build/index.js index 31ea8c704f57..13dad0fa6da1 100644 --- a/packages/kit/src/api/build/index.js +++ b/packages/kit/src/api/build/index.js @@ -11,7 +11,6 @@ import { terser } from 'rollup-plugin-terser'; import css_chunks from 'rollup-plugin-css-chunks'; import { copy_assets } from '../utils'; import { create_app } from '../../core/create_app'; - import { css_injection } from './css_injection'; const exec = promisify(child_process.exec); @@ -52,7 +51,7 @@ export async function build(config) { log.minor = (msg) => log(colors.grey(msg)); log.info = log; - const unoptimized = `.svelte/build/unoptimized`; + const unoptimized = '.svelte/build/unoptimized'; { // phase one — build with Snowpack @@ -136,7 +135,7 @@ export async function build(config) { sourcemap: true }); - log.success(`server`); + log.success('server'); const entry = path.resolve(`${unoptimized}/client/_app/main/runtime/navigation.js`); @@ -167,10 +166,7 @@ export async function build(config) { const reverse_lookup = new Map(); const routes = path.resolve(`${unoptimized}/client/_app/routes`); - const client - - - = { + const client = { entry: null, deps: {} }; @@ -180,12 +176,12 @@ export async function build(config) { for (const key in bundle) { const chunk = bundle[key]; - if ((chunk ).facadeModuleId === entry) { + if (chunk.facadeModuleId === entry) { client.entry = key; - } else if ((chunk ).facadeModuleId === 'inject_styles.js') { + } else if (chunk.facadeModuleId === 'inject_styles.js') { inject_styles = key; - } else if ((chunk ).modules) { - for (const id in (chunk ).modules) { + } else if (chunk.modules) { + for (const id in chunk.modules) { if (id.startsWith(routes) && id.endsWith('.js')) { const file = id.slice(routes.length + 1); reverse_lookup.set(file, key); @@ -202,7 +198,7 @@ export async function build(config) { const chunk = bundle[key]; if (chunk) { - const imports = (chunk ).imports; + const imports = chunk.imports; if (imports) { imports.forEach((key) => { @@ -267,7 +263,7 @@ export async function build(config) { sourcemap: true }); - log.success(`client`); + log.success('client'); } { diff --git a/packages/kit/src/api/dev/index.js b/packages/kit/src/api/dev/index.js index 3f5431008747..a4e5ff361ae9 100644 --- a/packages/kit/src/api/dev/index.js +++ b/packages/kit/src/api/dev/index.js @@ -5,17 +5,14 @@ import { scorta } from 'scorta/sync'; import * as ports from 'port-authority'; import sirv from 'sirv'; import create_manifest_data from '../../core/create_manifest_data'; -import { createServer, } from 'http'; +import { createServer } from 'http'; import { create_app } from '../../core/create_app'; -import snowpack, { } from 'snowpack'; +import snowpack from 'snowpack'; import pkg from '../../../package.json'; import loader from './loader'; - import { mkdirp } from '@sveltejs/app-utils/files'; import { render } from '@sveltejs/app-utils/renderer'; import { get_body } from '@sveltejs/app-utils/http'; - - import { copy_assets } from '../utils'; import { readFileSync } from 'fs'; @@ -24,17 +21,6 @@ export function dev(opts) { } class Watcher extends EventEmitter { - - - - - - - - - - - constructor(opts) { super(); @@ -74,11 +60,11 @@ class Watcher extends EventEmitter { await this.init_server(); // not sure why TS doesn't understand that CheapWatch extends EventEmitter - ((this.cheapwatch ) ).on('+', ({ isNew }) => { + this.cheapwatch.on('+', ({ isNew }) => { if (isNew) this.update(); }); - ((this.cheapwatch ) ).on('-', () => { + this.cheapwatch.on('-', () => { this.update(); }); } @@ -160,8 +146,8 @@ class Watcher extends EventEmitter { const rendered = await render( { host: req.headers.host, - headers: req.headers , - method: req.method , + headers: req.headers, + method: req.method, path: parsed.pathname, query: new URLSearchParams(parsed.query), body diff --git a/packages/kit/src/api/dev/loader.js b/packages/kit/src/api/dev/loader.js index 26556d322076..e4f1fe3415d8 100644 --- a/packages/kit/src/api/dev/loader.js +++ b/packages/kit/src/api/dev/loader.js @@ -3,8 +3,6 @@ import { resolve, relative } from 'path'; import * as meriyah from 'meriyah'; import MagicString from 'magic-string'; import { extract_names } from 'periscopic'; - - import { walk } from 'estree-walker'; // This function makes it possible to load modules from the 'server' @@ -217,7 +215,7 @@ export default function loader(snowpack, config) { ); const values = await Promise.all(deps.map((d) => d.promise)); - let exports = {}; + const exports = {}; fn( exports, @@ -261,5 +259,5 @@ function map_keys(object, map) { new_object[map(k)] = v; return new_object; - }, {} ); + }, {}); } diff --git a/packages/kit/src/api/dev/types.js b/packages/kit/src/api/dev/types.js deleted file mode 100644 index db9976f08894..000000000000 --- a/packages/kit/src/api/dev/types.js +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/kit/src/core/create_app.js b/packages/kit/src/core/create_app.js index 38e7e9c02c7b..e3ae8e50a007 100644 --- a/packages/kit/src/core/create_app.js +++ b/packages/kit/src/core/create_app.js @@ -2,15 +2,10 @@ import * as fs from 'fs'; import { mkdirp } from '@sveltejs/app-utils/files'; import { stringify, walk, write_if_changed } from '../utils'; - - export function create_app({ manifest_data, output -} - - -) { +}) { if (!fs.existsSync(output)) mkdirp(output); const client_manifest = generate_client_manifest(manifest_data); @@ -26,12 +21,7 @@ export function create_serviceworker_manifest({ output, client_files, static_files -} - - - - -) { +}) { let files = ['service-worker-index.html']; if (fs.existsSync(static_files)) { diff --git a/packages/kit/src/core/create_manifest_data.js b/packages/kit/src/core/create_manifest_data.js index 14b4237cf216..3ff08d0ad121 100644 --- a/packages/kit/src/core/create_manifest_data.js +++ b/packages/kit/src/core/create_manifest_data.js @@ -1,7 +1,5 @@ import * as fs from 'fs'; import * as path from 'path'; - - import { posixify, reserved_words } from '../utils'; export default function create_manifest_data( @@ -47,9 +45,6 @@ export default function create_manifest_data( parent_segments, parent_params, stack - - - ) { const items = fs .readdirSync(dir) @@ -213,22 +208,12 @@ export default function create_manifest_data( }; } - - - - - - - function is_spread(path) { const spread_pattern = /\[\.{3}/g; return spread_pattern.test(path); } -function comparator( - a, - b -) { +function comparator(a, b) { if (a.is_index !== b.is_index) { if (a.is_index) return is_spread(a.file) ? 1 : -1; diff --git a/packages/kit/src/interfaces.js b/packages/kit/src/interfaces.js deleted file mode 100644 index 874c19839ab8..000000000000 --- a/packages/kit/src/interfaces.js +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// export interface BuildEvent { -// type: string; -// errors: Array<{ file: string; message: string; duplicate: boolean }>; -// warnings: Array<{ file: string; message: string; duplicate: boolean }>; -// duration: number; -// result: CompileResult; -// } diff --git a/packages/kit/src/runtime/navigation/internal.js b/packages/kit/src/runtime/navigation/internal.js index f42b2a95e5ae..94c3452e7943 100644 --- a/packages/kit/src/runtime/navigation/internal.js +++ b/packages/kit/src/runtime/navigation/internal.js @@ -1,4 +1,3 @@ - import { find_anchor } from './utils'; import { routes } from 'MANIFEST'; diff --git a/packages/kit/src/runtime/navigation/prefetch/index.js b/packages/kit/src/runtime/navigation/prefetch/index.js index bb5639e58834..d6192b1dbb8e 100644 --- a/packages/kit/src/runtime/navigation/prefetch/index.js +++ b/packages/kit/src/runtime/navigation/prefetch/index.js @@ -2,11 +2,7 @@ import { hydrate_target } from '../start'; // TODO does this belong here? import { select_target } from '../internal'; import { find_anchor, get_base_uri } from '../utils'; - -let prefetching - - - = null; +let prefetching = null; let mousemove_timeout; diff --git a/packages/kit/src/runtime/navigation/start/index.js b/packages/kit/src/runtime/navigation/start/index.js index 0f6420058fb4..0d1316ef1741 100644 --- a/packages/kit/src/runtime/navigation/start/index.js +++ b/packages/kit/src/runtime/navigation/start/index.js @@ -1,14 +1,11 @@ import { writable } from 'svelte/store'; import { extract_query, init as init_router, load_current_page, select_target } from '../internal'; import { get_prefetched, start as start_prefetching } from '../prefetch'; - import goto from '../goto'; import { page_store } from './page_store'; import { layout, ErrorComponent, components } from 'MANIFEST'; import root from 'ROOT'; - - export const initial_data = typeof __SVELTE__ !== 'undefined' && __SVELTE__; let ready = false; diff --git a/packages/kit/src/runtime/navigation/start/page_store.js b/packages/kit/src/runtime/navigation/start/page_store.js index eb2ca1c7f979..9df1822c244a 100644 --- a/packages/kit/src/runtime/navigation/start/page_store.js +++ b/packages/kit/src/runtime/navigation/start/page_store.js @@ -1,25 +1,6 @@ -import { writable, } from 'svelte/store'; +import { writable } from 'svelte/store'; /** Callback to inform of a value updates. */ - - - - - - - - - - - - - - - - - - - export function page_store(value) { const store = writable(value); let ready = true; diff --git a/packages/kit/src/runtime/navigation/types.js b/packages/kit/src/runtime/navigation/types.js deleted file mode 100644 index c1173cd83923..000000000000 --- a/packages/kit/src/runtime/navigation/types.js +++ /dev/null @@ -1,51 +0,0 @@ -import { Page } from '@sveltejs/app-utils'; -export { Page, Query, PageContext } from '@sveltejs/app-utils'; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/kit/src/runtime/stores/index.js b/packages/kit/src/runtime/stores/index.js index 8a2fbd6765bd..3abf1d61c46d 100644 --- a/packages/kit/src/runtime/stores/index.js +++ b/packages/kit/src/runtime/stores/index.js @@ -1,19 +1,9 @@ import { getContext } from 'svelte'; - - -// these Svelte types are not exported, so repeating them here. - - - // const ssr = (import.meta as any).env.SSR; const ssr = typeof window === 'undefined'; // TODO why doesn't previous line work in build? -export const getStores - - - - = () => getContext('__svelte__'); +export const getStores = () => getContext('__svelte__'); export const page = { subscribe(fn) { @@ -48,7 +38,7 @@ export const session = { return store.subscribe(fn); }, - set: (updater) => { + set: (value) => { error('set'); }, update: (updater) => { From 5a88c5d4b5ee0d3e7c01270322ab9b69573ee02f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 19:12:06 -0500 Subject: [PATCH 10/30] bit more tidying --- packages/kit/src/api/build/index.js | 4 ++-- packages/kit/src/api/dev/index.js | 2 +- packages/kit/src/api/dev/loader.js | 2 +- packages/kit/src/api/dev/sourcemap_stacktrace.js | 10 +++++----- packages/kit/src/cli.js | 1 - packages/kit/src/runtime/navigation/internal.js | 14 +++++++------- packages/kit/src/runtime/navigation/start/index.js | 2 +- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/packages/kit/src/api/build/index.js b/packages/kit/src/api/build/index.js index 13dad0fa6da1..8c80e28bd0ee 100644 --- a/packages/kit/src/api/build/index.js +++ b/packages/kit/src/api/build/index.js @@ -6,7 +6,7 @@ import colors from 'kleur'; import relative from 'require-relative'; import { mkdirp } from '@sveltejs/app-utils/files'; import create_manifest_data from '../../core/create_manifest_data'; -import { rollup, } from 'rollup'; +import { rollup } from 'rollup'; import { terser } from 'rollup-plugin-terser'; import css_chunks from 'rollup-plugin-css-chunks'; import { copy_assets } from '../utils'; @@ -284,6 +284,6 @@ export async function build(config) { async function rimraf(path) { return new Promise((resolve) => { - ((fs).rm || fs.rmdir)(path, { recursive: true, force: true }, () => resolve()); + (fs.rm || fs.rmdir)(path, { recursive: true, force: true }, () => resolve()); }); } diff --git a/packages/kit/src/api/dev/index.js b/packages/kit/src/api/dev/index.js index a4e5ff361ae9..6992d57fb8c2 100644 --- a/packages/kit/src/api/dev/index.js +++ b/packages/kit/src/api/dev/index.js @@ -44,7 +44,7 @@ class Watcher extends EventEmitter { this.emit('ready', { port: this.opts.port - } ); + }); return this; } diff --git a/packages/kit/src/api/dev/loader.js b/packages/kit/src/api/dev/loader.js index e4f1fe3415d8..e65d6a859bd8 100644 --- a/packages/kit/src/api/dev/loader.js +++ b/packages/kit/src/api/dev/loader.js @@ -139,7 +139,7 @@ export default function loader(snowpack, config) { const names = []; node.declaration.declarations.forEach((declarator) => { - names.push(...extract_names(declarator.id )); + names.push(...extract_names(declarator.id)); }); code.appendLeft(node.end, names.map((name) => ` exports.${name} = ${name};`).join('')); diff --git a/packages/kit/src/api/dev/sourcemap_stacktrace.js b/packages/kit/src/api/dev/sourcemap_stacktrace.js index 6e98294736c8..fb35d712ff89 100644 --- a/packages/kit/src/api/dev/sourcemap_stacktrace.js +++ b/packages/kit/src/api/dev/sourcemap_stacktrace.js @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import { SourceMapConsumer, } from 'source-map'; +import { SourceMapConsumer } from 'source-map'; function get_sourcemap_url(contents) { const reversed = contents.split('\n').reverse().join('\n'); @@ -22,7 +22,7 @@ function get_file_contents(path) { const data = fs.readFileSync(path, 'utf8'); file_cache.set(path, data); return data; - } catch (e) { + } catch { return undefined; } } @@ -47,7 +47,7 @@ export function sourcemap_stacktrace(stack) { const raw_data = sourcemap_url.slice(sourcemap_url.indexOf(',') + 1); try { sourcemap_data = Buffer.from(raw_data, 'base64').toString(); - } catch (e2) { + } catch { return input; } } else { @@ -63,13 +63,13 @@ export function sourcemap_stacktrace(stack) { let raw_sourcemap; try { raw_sourcemap = JSON.parse(sourcemap_data); - } catch (e3) { + } catch { return input; } // TODO: according to typings, this code cannot work; // the constructor returns a promise that needs to be awaited - const consumer = new (SourceMapConsumer )(raw_sourcemap); + const consumer = new SourceMapConsumer(raw_sourcemap); const pos = consumer.originalPositionFor({ line: Number(line), column: Number(column), diff --git a/packages/kit/src/cli.js b/packages/kit/src/cli.js index 31e322e5fee1..af88f4a844a5 100644 --- a/packages/kit/src/cli.js +++ b/packages/kit/src/cli.js @@ -3,7 +3,6 @@ import sade from 'sade'; import colors from 'kleur'; import * as pkg from '../package.json'; - let config; try { diff --git a/packages/kit/src/runtime/navigation/internal.js b/packages/kit/src/runtime/navigation/internal.js index 94c3452e7943..4e60c791ab47 100644 --- a/packages/kit/src/runtime/navigation/internal.js +++ b/packages/kit/src/runtime/navigation/internal.js @@ -14,11 +14,11 @@ export function set_cid(n) { const _history = typeof history !== 'undefined' ? history - : (({ - pushState: () => {}, - replaceState: () => {}, - scrollRestoration: 'auto' - } ) ); + : { + pushState: () => {}, + replaceState: () => {}, + scrollRestoration: 'auto' + }; export { _history as history }; export const scroll_history = {}; @@ -116,7 +116,7 @@ function handle_click(event) { if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; if (event.defaultPrevented) return; - const a = find_anchor(event.target); + const a = find_anchor(event.target); if (!a) return; if (!a.href) return; @@ -124,7 +124,7 @@ function handle_click(event) { // check if link is inside an svg // in this case, both href and target are always inside an object const svg = typeof a.href === 'object' && a.href.constructor.name === 'SVGAnimatedString'; - const href = String(svg ? (a).href.baseVal : a.href); + const href = String(svg ? a.href.baseVal : a.href); if (href === location.href) { if (!location.hash) event.preventDefault(); diff --git a/packages/kit/src/runtime/navigation/start/index.js b/packages/kit/src/runtime/navigation/start/index.js index 0d1316ef1741..3c1b91b8c7b1 100644 --- a/packages/kit/src/runtime/navigation/start/index.js +++ b/packages/kit/src/runtime/navigation/start/index.js @@ -16,7 +16,7 @@ let current_branch = []; let current_query = '{}'; const stores = { - page: page_store({} ), + page: page_store({}), preloading: writable(false), session: writable(initial_data && initial_data.session) }; From 39e7a94acfa1287183470066f64f2cdbf77e2fd2 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 19:35:01 -0500 Subject: [PATCH 11/30] restrict uvu pattern --- packages/kit/package.json | 2 +- packages/kit/src/api/build/test/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/kit/package.json b/packages/kit/package.json index 95fbda52411f..550d6c7c8a8a 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -47,6 +47,6 @@ "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore", "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", "prepublishOnly": "npm run build", - "test": "uvu -r esm" + "test": "uvu src \"(spec.js|test/index.js)\" -r esm" } } diff --git a/packages/kit/src/api/build/test/index.js b/packages/kit/src/api/build/test/index.js index f9815a6d5371..6df1b7fa6bbb 100644 --- a/packages/kit/src/api/build/test/index.js +++ b/packages/kit/src/api/build/test/index.js @@ -13,7 +13,7 @@ suite('builder ', () => { assert.ok(Builder); }); -suite('copy_static_files', () => { +suite('copy files', () => { const generated_files = join(__dirname, 'fixtures/basic/.svelte/build/optimized'); const static_files = join(__dirname, 'fixtures/basic/static'); From d5d77c450ef55f341d144672461445ad617bc089 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 19:51:17 -0500 Subject: [PATCH 12/30] copy client files, not everything --- packages/kit/src/api/build/Builder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kit/src/api/build/Builder.js b/packages/kit/src/api/build/Builder.js index 08bc93ce8599..1bc4db6a432f 100644 --- a/packages/kit/src/api/build/Builder.js +++ b/packages/kit/src/api/build/Builder.js @@ -20,7 +20,7 @@ export default class Builder { } copy_generated_files(dest) { - copy(this.#generated_files, dest); + copy(`${this.#generated_files}/client`, dest); } copy_static_files(dest) { From d4eb98076f2ad81ee8f0deeede89b224f335e97c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 19:52:14 -0500 Subject: [PATCH 13/30] remove generated file --- packages/adapter-node/server.js | 3063 ------------------------------- 1 file changed, 3063 deletions(-) delete mode 100644 packages/adapter-node/server.js diff --git a/packages/adapter-node/server.js b/packages/adapter-node/server.js deleted file mode 100644 index 374da637cf23..000000000000 --- a/packages/adapter-node/server.js +++ /dev/null @@ -1,3063 +0,0 @@ -'use strict'; - -var fs = require('fs'); -var http = require('http'); -var Url = require('url'); -var path = require('path'); -var crypto = require('crypto'); -var Stream = require('stream'); -var https = require('https'); -var zlib = require('zlib'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var http__default = /*#__PURE__*/_interopDefaultLegacy(http); -var Url__default = /*#__PURE__*/_interopDefaultLegacy(Url); -var Stream__default = /*#__PURE__*/_interopDefaultLegacy(Stream); -var https__default = /*#__PURE__*/_interopDefaultLegacy(https); -var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib); - -function list(dir, callback, pre='') { - dir = path.resolve('.', dir); - let arr = fs.readdirSync(dir); - let i=0, abs, stats; - for (; i < arr.length; i++) { - abs = path.join(dir, arr[i]); - stats = fs.statSync(abs); - stats.isDirectory() - ? list(abs, callback, path.join(pre, arr[i])) - : callback(path.join(pre, arr[i]), abs, stats); - } -} - -function parse(str) { - let i=0, j=0, k, v; - let out={}, arr=str.split('&'); - for (; i < arr.length; i++) { - j = arr[i].indexOf('='); - v = !!~j && arr[i].substring(j+1) || ''; - k = !!~j ? arr[i].substring(0, j) : arr[i]; - out[k] = out[k] !== void 0 ? [].concat(out[k], v) : v; - } - return out; -} - -function parser (req, toDecode) { - let url = req.url; - if (url == null) return; - - let obj = req._parsedUrl; - if (obj && obj._raw === url) return obj; - - obj = { - path: url, - pathname: url, - search: null, - query: null, - href: url, - _raw: url - }; - - if (url.length > 1) { - if (toDecode && !req._decoded && !!~url.indexOf('%', 1)) { - let nxt = url; - try { nxt = decodeURIComponent(url); } catch (e) {/* bad */} - url = req.url = obj.href = obj.path = obj.pathname = obj._raw = nxt; - req._decoded = true; - } - - let idx = url.indexOf('?', 1); - - if (idx !== -1) { - obj.search = url.substring(idx); - obj.query = obj.search.substring(1); - obj.pathname = url.substring(0, idx); - if (toDecode && obj.query.length > 0) { - obj.query = parse(obj.query); - } - } - } - - return (req._parsedUrl = obj); -} - -/** - * @param typeMap [Object] Map of MIME type -> Array[extensions] - * @param ... - */ -function Mime() { - this._types = Object.create(null); - this._extensions = Object.create(null); - - for (var i = 0; i < arguments.length; i++) { - this.define(arguments[i]); - } - - this.define = this.define.bind(this); - this.getType = this.getType.bind(this); - this.getExtension = this.getExtension.bind(this); -} - -/** - * Define mimetype -> extension mappings. Each key is a mime-type that maps - * to an array of extensions associated with the type. The first extension is - * used as the default extension for the type. - * - * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); - * - * If a type declares an extension that has already been defined, an error will - * be thrown. To suppress this error and force the extension to be associated - * with the new type, pass `force`=true. Alternatively, you may prefix the - * extension with "*" to map the type to extension, without mapping the - * extension to the type. - * - * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']}); - * - * - * @param map (Object) type definitions - * @param force (Boolean) if true, force overriding of existing definitions - */ -Mime.prototype.define = function(typeMap, force) { - for (var type in typeMap) { - var extensions = typeMap[type].map(function(t) {return t.toLowerCase()}); - type = type.toLowerCase(); - - for (var i = 0; i < extensions.length; i++) { - var ext = extensions[i]; - - // '*' prefix = not the preferred type for this extension. So fixup the - // extension, and skip it. - if (ext[0] == '*') { - continue; - } - - if (!force && (ext in this._types)) { - throw new Error( - 'Attempt to change mapping for "' + ext + - '" extension from "' + this._types[ext] + '" to "' + type + - '". Pass `force=true` to allow this, otherwise remove "' + ext + - '" from the list of extensions for "' + type + '".' - ); - } - - this._types[ext] = type; - } - - // Use first extension as default - if (force || !this._extensions[type]) { - var ext = extensions[0]; - this._extensions[type] = (ext[0] != '*') ? ext : ext.substr(1); - } - } -}; - -/** - * Lookup a mime type based on extension - */ -Mime.prototype.getType = function(path) { - path = String(path); - var last = path.replace(/^.*[/\\]/, '').toLowerCase(); - var ext = last.replace(/^.*\./, '').toLowerCase(); - - var hasPath = last.length < path.length; - var hasDot = ext.length < last.length - 1; - - return (hasDot || !hasPath) && this._types[ext] || null; -}; - -/** - * Return file extension associated with a mime type - */ -Mime.prototype.getExtension = function(type) { - type = /^\s*([^;\s]*)/.test(type) && RegExp.$1; - return type && this._extensions[type.toLowerCase()] || null; -}; - -var Mime_1 = Mime; - -var standard = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/urc-ressheet+xml":["rsheet"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["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/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"],"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/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/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/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/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"]}; - -var lite = new Mime_1(standard); - -const noop = () => {}; - -function isMatch(uri, arr) { - for (let i=0; i < arr.length; i++) { - if (arr[i].test(uri)) return true; - } -} - -function toAssume(uri, extns) { - let i=0, x, len=uri.length - 1; - if (uri.charCodeAt(len) === 47) { - uri = uri.substring(0, len); - } - - let arr=[], tmp=`${uri}/index`; - for (; i < extns.length; i++) { - x = extns[i] ? `.${extns[i]}` : ''; - if (uri) arr.push(uri + x); - arr.push(tmp + x); - } - - return arr; -} - -function viaCache(cache, uri, extns) { - let i=0, data, arr=toAssume(uri, extns); - for (; i < arr.length; i++) { - if (data = cache[arr[i]]) return data; - } -} - -function viaLocal(dir, isEtag, uri, extns) { - let i=0, arr=toAssume(uri, extns); - let abs, stats, name, headers; - for (; i < arr.length; i++) { - abs = path.normalize(path.join(dir, name=arr[i])); - if (abs.startsWith(dir) && fs.existsSync(abs)) { - stats = fs.statSync(abs); - if (stats.isDirectory()) continue; - headers = toHeaders(name, stats, isEtag); - headers['Cache-Control'] = 'no-store'; - return { abs, stats, headers }; - } - } -} - -function is404(req, res) { - return (res.statusCode=404,res.end()); -} - -function send(req, res, file, stats, headers) { - let code=200, tmp, opts={}; - headers = { ...headers }; - - for (let key in headers) { - tmp = res.getHeader(key); - if (tmp) headers[key] = tmp; - } - - if (tmp = res.getHeader('content-type')) { - headers['Content-Type'] = tmp; - } - - if (req.headers.range) { - code = 206; - let [x, y] = req.headers.range.replace('bytes=', '').split('-'); - let end = opts.end = parseInt(y, 10) || stats.size - 1; - let start = opts.start = parseInt(x, 10) || 0; - - if (start >= stats.size || end >= stats.size) { - res.setHeader('Content-Range', `bytes */${stats.size}`); - res.statusCode = 416; - return res.end(); - } - - headers['Content-Range'] = `bytes ${start}-${end}/${stats.size}`; - headers['Content-Length'] = (end - start + 1); - headers['Accept-Ranges'] = 'bytes'; - } - - res.writeHead(code, headers); - fs.createReadStream(file, opts).pipe(res); -} - -function isEncoding(name, type, headers) { - headers['Content-Encoding'] = type; - headers['Content-Type'] = lite.getType(name.replace(/\.([^.]*)$/, '')) || ''; -} - -function toHeaders(name, stats, isEtag) { - let headers = { - 'Content-Length': stats.size, - 'Content-Type': lite.getType(name) || '', - 'Last-Modified': stats.mtime.toUTCString(), - }; - if (isEtag) headers['ETag'] = `W/"${stats.size}-${stats.mtime.getTime()}"`; - if (/\.br$/.test(name)) isEncoding(name, 'br', headers); - if (/\.gz$/.test(name)) isEncoding(name, 'gzip', headers); - return headers; -} - -function sirv (dir, opts={}) { - dir = path.resolve(dir || '.'); - - let isNotFound = opts.onNoMatch || is404; - let setHeaders = opts.setHeaders || noop; - - let extensions = opts.extensions || ['html', 'htm']; - let gzips = opts.gzip && extensions.map(x => `${x}.gz`).concat('gz'); - let brots = opts.brotli && extensions.map(x => `${x}.br`).concat('br'); - - const FILES = {}; - - let fallback = '/'; - let isEtag = !!opts.etag; - let isSPA = !!opts.single; - if (typeof opts.single === 'string') { - let idx = opts.single.lastIndexOf('.'); - fallback += !!~idx ? opts.single.substring(0, idx) : opts.single; - } - - let ignores = []; - if (opts.ignores !== false) { - ignores.push(/\w\.\w+$/); // any extn - if (opts.dotfiles) ignores.push(/\/\.\w/); - else ignores.push(/\/\.well-known/); - [].concat(opts.ignores || []).forEach(x => { - ignores.push(new RegExp(x, 'i')); - }); - } - - let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`; - if (cc && opts.immutable) cc += ',immutable'; - else if (cc && opts.maxAge === 0) cc += ',must-revalidate'; - - if (!opts.dev) { - list(dir, (name, abs, stats) => { - if (/\.well-known[\\+\/]/.test(name)) ; // keep - else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name)) return; - - let headers = toHeaders(name, stats, isEtag); - if (cc) headers['Cache-Control'] = cc; - - FILES['/' + name.normalize().replace(/\\+/g, '/')] = { abs, stats, headers }; - }); - } - - let lookup = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES); - - return function (req, res, next) { - let extns = ['']; - let val = req.headers['accept-encoding'] || ''; - if (gzips && val.includes('gzip')) extns.unshift(...gzips); - if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots); - extns.push(...extensions); // [...br, ...gz, orig, ...exts] - - let pathname = req.path || parser(req, true).pathname; - let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns); - if (!data) return next ? next() : isNotFound(req, res); - - if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) { - res.writeHead(304); - return res.end(); - } - - setHeaders(res, pathname, data.stats); - send(req, res, data.abs, data.stats, data.headers); - }; -} - -var other = {"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":["keynote"],"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.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}; - -var mime = new Mime_1(standard, other); - -var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'; -var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g; -var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/; -var escaped = { - '<': '\\u003C', - '>': '\\u003E', - '/': '\\u002F', - '\\': '\\\\', - '\b': '\\b', - '\f': '\\f', - '\n': '\\n', - '\r': '\\r', - '\t': '\\t', - '\0': '\\0', - '\u2028': '\\u2028', - '\u2029': '\\u2029' -}; -var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join('\0'); -function devalue(value) { - var counts = new Map(); - function walk(thing) { - if (typeof thing === 'function') { - throw new Error("Cannot stringify a function"); - } - if (counts.has(thing)) { - counts.set(thing, counts.get(thing) + 1); - return; - } - counts.set(thing, 1); - if (!isPrimitive(thing)) { - var type = getType(thing); - switch (type) { - case 'Number': - case 'String': - case 'Boolean': - case 'Date': - case 'RegExp': - return; - case 'Array': - thing.forEach(walk); - break; - case 'Set': - case 'Map': - Array.from(thing).forEach(walk); - break; - default: - var proto = Object.getPrototypeOf(thing); - if (proto !== Object.prototype && - proto !== null && - Object.getOwnPropertyNames(proto).sort().join('\0') !== objectProtoOwnPropertyNames) { - throw new Error("Cannot stringify arbitrary non-POJOs"); - } - if (Object.getOwnPropertySymbols(thing).length > 0) { - throw new Error("Cannot stringify POJOs with symbolic keys"); - } - Object.keys(thing).forEach(function (key) { return walk(thing[key]); }); - } - } - } - walk(value); - var names = new Map(); - Array.from(counts) - .filter(function (entry) { return entry[1] > 1; }) - .sort(function (a, b) { return b[1] - a[1]; }) - .forEach(function (entry, i) { - names.set(entry[0], getName(i)); - }); - function stringify(thing) { - if (names.has(thing)) { - return names.get(thing); - } - if (isPrimitive(thing)) { - return stringifyPrimitive(thing); - } - var type = getType(thing); - switch (type) { - case 'Number': - case 'String': - case 'Boolean': - return "Object(" + stringify(thing.valueOf()) + ")"; - case 'RegExp': - return "new RegExp(" + stringifyString(thing.source) + ", \"" + thing.flags + "\")"; - case 'Date': - return "new Date(" + thing.getTime() + ")"; - case 'Array': - var members = thing.map(function (v, i) { return i in thing ? stringify(v) : ''; }); - var tail = thing.length === 0 || (thing.length - 1 in thing) ? '' : ','; - return "[" + members.join(',') + tail + "]"; - case 'Set': - case 'Map': - return "new " + type + "([" + Array.from(thing).map(stringify).join(',') + "])"; - default: - var obj = "{" + Object.keys(thing).map(function (key) { return safeKey(key) + ":" + stringify(thing[key]); }).join(',') + "}"; - var proto = Object.getPrototypeOf(thing); - if (proto === null) { - return Object.keys(thing).length > 0 - ? "Object.assign(Object.create(null)," + obj + ")" - : "Object.create(null)"; - } - return obj; - } - } - var str = stringify(value); - if (names.size) { - var params_1 = []; - var statements_1 = []; - var values_1 = []; - names.forEach(function (name, thing) { - params_1.push(name); - if (isPrimitive(thing)) { - values_1.push(stringifyPrimitive(thing)); - return; - } - var type = getType(thing); - switch (type) { - case 'Number': - case 'String': - case 'Boolean': - values_1.push("Object(" + stringify(thing.valueOf()) + ")"); - break; - case 'RegExp': - values_1.push(thing.toString()); - break; - case 'Date': - values_1.push("new Date(" + thing.getTime() + ")"); - break; - case 'Array': - values_1.push("Array(" + thing.length + ")"); - thing.forEach(function (v, i) { - statements_1.push(name + "[" + i + "]=" + stringify(v)); - }); - break; - case 'Set': - values_1.push("new Set"); - statements_1.push(name + "." + Array.from(thing).map(function (v) { return "add(" + stringify(v) + ")"; }).join('.')); - break; - case 'Map': - values_1.push("new Map"); - statements_1.push(name + "." + Array.from(thing).map(function (_a) { - var k = _a[0], v = _a[1]; - return "set(" + stringify(k) + ", " + stringify(v) + ")"; - }).join('.')); - break; - default: - values_1.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'); - Object.keys(thing).forEach(function (key) { - statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key])); - }); - } - }); - statements_1.push("return " + str); - return "(function(" + params_1.join(',') + "){" + statements_1.join(';') + "}(" + values_1.join(',') + "))"; - } - else { - return str; - } -} -function getName(num) { - var name = ''; - do { - name = chars[num % chars.length] + name; - num = ~~(num / chars.length) - 1; - } while (num >= 0); - return reserved.test(name) ? name + "_" : name; -} -function isPrimitive(thing) { - return Object(thing) !== thing; -} -function stringifyPrimitive(thing) { - if (typeof thing === 'string') - return stringifyString(thing); - if (thing === void 0) - return 'void 0'; - if (thing === 0 && 1 / thing < 0) - return '-0'; - var str = String(thing); - if (typeof thing === 'number') - return str.replace(/^(-)?0\./, '$1.'); - return str; -} -function getType(thing) { - return Object.prototype.toString.call(thing).slice(8, -1); -} -function escapeUnsafeChar(c) { - return escaped[c] || c; -} -function escapeUnsafeChars(str) { - return str.replace(unsafeChars, escapeUnsafeChar); -} -function safeKey(key) { - return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key)); -} -function safeProp(key) { - return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]"; -} -function stringifyString(str) { - var result = '"'; - for (var i = 0; i < str.length; i += 1) { - var char = str.charAt(i); - var code = char.charCodeAt(0); - if (char === '"') { - result += '\\"'; - } - else if (char in escaped) { - result += escaped[char]; - } - else if (code >= 0xd800 && code <= 0xdfff) { - var next = str.charCodeAt(i + 1); - // If this is the beginning of a [high, low] surrogate pair, - // add the next two characters, otherwise escape - if (code <= 0xdbff && (next >= 0xdc00 && next <= 0xdfff)) { - result += char + str[++i]; - } - else { - result += "\\u" + code.toString(16).toUpperCase(); - } - } - else { - result += char; - } - } - result += '"'; - return result; -} - -// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js - -// fix for "Readable" isn't a named export issue -const Readable = Stream__default['default'].Readable; - -const BUFFER = Symbol('buffer'); -const TYPE = Symbol('type'); - -class Blob { - constructor() { - this[TYPE] = ''; - - const blobParts = arguments[0]; - const options = arguments[1]; - - const buffers = []; - let size = 0; - - if (blobParts) { - const a = blobParts; - const length = Number(a.length); - for (let i = 0; i < length; i++) { - const element = a[i]; - let buffer; - if (element instanceof Buffer) { - buffer = element; - } else if (ArrayBuffer.isView(element)) { - buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); - } else if (element instanceof ArrayBuffer) { - buffer = Buffer.from(element); - } else if (element instanceof Blob) { - buffer = element[BUFFER]; - } else { - buffer = Buffer.from(typeof element === 'string' ? element : String(element)); - } - size += buffer.length; - buffers.push(buffer); - } - } - - this[BUFFER] = Buffer.concat(buffers); - - let type = options && options.type !== undefined && String(options.type).toLowerCase(); - if (type && !/[^\u0020-\u007E]/.test(type)) { - this[TYPE] = type; - } - } - get size() { - return this[BUFFER].length; - } - get type() { - return this[TYPE]; - } - text() { - return Promise.resolve(this[BUFFER].toString()); - } - arrayBuffer() { - const buf = this[BUFFER]; - const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - return Promise.resolve(ab); - } - stream() { - const readable = new Readable(); - readable._read = function () {}; - readable.push(this[BUFFER]); - readable.push(null); - return readable; - } - toString() { - return '[object Blob]'; - } - slice() { - const size = this.size; - - const start = arguments[0]; - const end = arguments[1]; - let relativeStart, relativeEnd; - if (start === undefined) { - relativeStart = 0; - } else if (start < 0) { - relativeStart = Math.max(size + start, 0); - } else { - relativeStart = Math.min(start, size); - } - if (end === undefined) { - relativeEnd = size; - } else if (end < 0) { - relativeEnd = Math.max(size + end, 0); - } else { - relativeEnd = Math.min(end, size); - } - const span = Math.max(relativeEnd - relativeStart, 0); - - const buffer = this[BUFFER]; - const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); - const blob = new Blob([], { type: arguments[2] }); - blob[BUFFER] = slicedBuffer; - return blob; - } -} - -Object.defineProperties(Blob.prototype, { - size: { enumerable: true }, - type: { enumerable: true }, - slice: { enumerable: true } -}); - -Object.defineProperty(Blob.prototype, Symbol.toStringTag, { - value: 'Blob', - writable: false, - enumerable: false, - configurable: true -}); - -/** - * fetch-error.js - * - * FetchError interface for operational errors - */ - -/** - * Create FetchError instance - * - * @param String message Error message for human - * @param String type Error type for machine - * @param String systemError For Node.js system error - * @return FetchError - */ -function FetchError(message, type, systemError) { - Error.call(this, message); - - this.message = message; - this.type = type; - - // when err.type is `system`, err.code contains system error code - if (systemError) { - this.code = this.errno = systemError.code; - } - - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); -} - -FetchError.prototype = Object.create(Error.prototype); -FetchError.prototype.constructor = FetchError; -FetchError.prototype.name = 'FetchError'; - -let convert; -try { - convert = require('encoding').convert; -} catch (e) {} - -const INTERNALS = Symbol('Body internals'); - -// fix an issue where "PassThrough" isn't a named export for node <10 -const PassThrough = Stream__default['default'].PassThrough; - -/** - * Body mixin - * - * Ref: https://fetch.spec.whatwg.org/#body - * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void - */ -function Body(body) { - var _this = this; - - var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref$size = _ref.size; - - let size = _ref$size === undefined ? 0 : _ref$size; - var _ref$timeout = _ref.timeout; - let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; - - if (body == null) { - // body is undefined or null - body = null; - } else if (isURLSearchParams(body)) { - // body is a URLSearchParams - body = Buffer.from(body.toString()); - } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { - // body is ArrayBuffer - body = Buffer.from(body); - } else if (ArrayBuffer.isView(body)) { - // body is ArrayBufferView - body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); - } else if (body instanceof Stream__default['default']) ; else { - // none of the above - // coerce to string then buffer - body = Buffer.from(String(body)); - } - this[INTERNALS] = { - body, - disturbed: false, - error: null - }; - this.size = size; - this.timeout = timeout; - - if (body instanceof Stream__default['default']) { - body.on('error', function (err) { - const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); - _this[INTERNALS].error = error; - }); - } -} - -Body.prototype = { - get body() { - return this[INTERNALS].body; - }, - - get bodyUsed() { - return this[INTERNALS].disturbed; - }, - - /** - * Decode response as ArrayBuffer - * - * @return Promise - */ - arrayBuffer() { - return consumeBody.call(this).then(function (buf) { - return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - }); - }, - - /** - * Return raw response as Blob - * - * @return Promise - */ - blob() { - let ct = this.headers && this.headers.get('content-type') || ''; - return consumeBody.call(this).then(function (buf) { - return Object.assign( - // Prevent copying - new Blob([], { - type: ct.toLowerCase() - }), { - [BUFFER]: buf - }); - }); - }, - - /** - * Decode response as json - * - * @return Promise - */ - json() { - var _this2 = this; - - return consumeBody.call(this).then(function (buffer) { - try { - return JSON.parse(buffer.toString()); - } catch (err) { - return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); - } - }); - }, - - /** - * Decode response as text - * - * @return Promise - */ - text() { - return consumeBody.call(this).then(function (buffer) { - return buffer.toString(); - }); - }, - - /** - * Decode response as buffer (non-spec api) - * - * @return Promise - */ - buffer() { - return consumeBody.call(this); - }, - - /** - * Decode response as text, while automatically detecting the encoding and - * trying to decode to UTF-8 (non-spec api) - * - * @return Promise - */ - textConverted() { - var _this3 = this; - - return consumeBody.call(this).then(function (buffer) { - return convertBody(buffer, _this3.headers); - }); - } -}; - -// In browsers, all properties are enumerable. -Object.defineProperties(Body.prototype, { - body: { enumerable: true }, - bodyUsed: { enumerable: true }, - arrayBuffer: { enumerable: true }, - blob: { enumerable: true }, - json: { enumerable: true }, - text: { enumerable: true } -}); - -Body.mixIn = function (proto) { - for (const name of Object.getOwnPropertyNames(Body.prototype)) { - // istanbul ignore else: future proof - if (!(name in proto)) { - const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); - Object.defineProperty(proto, name, desc); - } - } -}; - -/** - * Consume and convert an entire Body to a Buffer. - * - * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body - * - * @return Promise - */ -function consumeBody() { - var _this4 = this; - - if (this[INTERNALS].disturbed) { - return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); - } - - this[INTERNALS].disturbed = true; - - if (this[INTERNALS].error) { - return Body.Promise.reject(this[INTERNALS].error); - } - - let body = this.body; - - // body is null - if (body === null) { - return Body.Promise.resolve(Buffer.alloc(0)); - } - - // body is blob - if (isBlob(body)) { - body = body.stream(); - } - - // body is buffer - if (Buffer.isBuffer(body)) { - return Body.Promise.resolve(body); - } - - // istanbul ignore if: should never happen - if (!(body instanceof Stream__default['default'])) { - return Body.Promise.resolve(Buffer.alloc(0)); - } - - // body is stream - // get ready to actually consume the body - let accum = []; - let accumBytes = 0; - let abort = false; - - return new Body.Promise(function (resolve, reject) { - let resTimeout; - - // allow timeout on slow response body - if (_this4.timeout) { - resTimeout = setTimeout(function () { - abort = true; - reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); - }, _this4.timeout); - } - - // handle stream errors - body.on('error', function (err) { - if (err.name === 'AbortError') { - // if the request was aborted, reject with this Error - abort = true; - reject(err); - } else { - // other errors, such as incorrect content-encoding - reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); - } - }); - - body.on('data', function (chunk) { - if (abort || chunk === null) { - return; - } - - if (_this4.size && accumBytes + chunk.length > _this4.size) { - abort = true; - reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); - return; - } - - accumBytes += chunk.length; - accum.push(chunk); - }); - - body.on('end', function () { - if (abort) { - return; - } - - clearTimeout(resTimeout); - - try { - resolve(Buffer.concat(accum, accumBytes)); - } catch (err) { - // handle streams that have accumulated too much data (issue #414) - reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); - } - }); - }); -} - -/** - * Detect buffer encoding and convert to target encoding - * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding - * - * @param Buffer buffer Incoming buffer - * @param String encoding Target encoding - * @return String - */ -function convertBody(buffer, headers) { - if (typeof convert !== 'function') { - throw new Error('The package `encoding` must be installed to use the textConverted() function'); - } - - const ct = headers.get('content-type'); - let charset = 'utf-8'; - let res, str; - - // header - if (ct) { - res = /charset=([^;]*)/i.exec(ct); - } - - // no charset in content type, peek at response body for at most 1024 bytes - str = buffer.slice(0, 1024).toString(); - - // html5 - if (!res && str) { - res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; - - this[MAP] = Object.create(null); - - if (init instanceof Headers) { - const rawHeaders = init.raw(); - const headerNames = Object.keys(rawHeaders); - - for (const headerName of headerNames) { - for (const value of rawHeaders[headerName]) { - this.append(headerName, value); - } - } - - return; - } - - // We don't worry about converting prop to ByteString here as append() - // will handle it. - if (init == null) ; else if (typeof init === 'object') { - const method = init[Symbol.iterator]; - if (method != null) { - if (typeof method !== 'function') { - throw new TypeError('Header pairs must be iterable'); - } - - // sequence> - // Note: per spec we have to first exhaust the lists then process them - const pairs = []; - for (const pair of init) { - if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { - throw new TypeError('Each header pair must be iterable'); - } - pairs.push(Array.from(pair)); - } - - for (const pair of pairs) { - if (pair.length !== 2) { - throw new TypeError('Each header pair must be a name/value tuple'); - } - this.append(pair[0], pair[1]); - } - } else { - // record - for (const key of Object.keys(init)) { - const value = init[key]; - this.append(key, value); - } - } - } else { - throw new TypeError('Provided initializer must be an object'); - } - } - - /** - * Return combined header value given name - * - * @param String name Header name - * @return Mixed - */ - get(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key === undefined) { - return null; - } - - return this[MAP][key].join(', '); - } - - /** - * Iterate over all headers - * - * @param Function callback Executed for each item with parameters (value, name, thisArg) - * @param Boolean thisArg `this` context for callback function - * @return Void - */ - forEach(callback) { - let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; - - let pairs = getHeaders(this); - let i = 0; - while (i < pairs.length) { - var _pairs$i = pairs[i]; - const name = _pairs$i[0], - value = _pairs$i[1]; - - callback.call(thisArg, value, name, this); - pairs = getHeaders(this); - i++; - } - } - - /** - * Overwrite header values given name - * - * @param String name Header name - * @param String value Header value - * @return Void - */ - set(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - this[MAP][key !== undefined ? key : name] = [value]; - } - - /** - * Append a value onto existing header - * - * @param String name Header name - * @param String value Header value - * @return Void - */ - append(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - if (key !== undefined) { - this[MAP][key].push(value); - } else { - this[MAP][name] = [value]; - } - } - - /** - * Check for header name existence - * - * @param String name Header name - * @return Boolean - */ - has(name) { - name = `${name}`; - validateName(name); - return find(this[MAP], name) !== undefined; - } - - /** - * Delete all header values given name - * - * @param String name Header name - * @return Void - */ - delete(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key !== undefined) { - delete this[MAP][key]; - } - } - - /** - * Return raw headers (non-spec api) - * - * @return Object - */ - raw() { - return this[MAP]; - } - - /** - * Get an iterator on keys. - * - * @return Iterator - */ - keys() { - return createHeadersIterator(this, 'key'); - } - - /** - * Get an iterator on values. - * - * @return Iterator - */ - values() { - return createHeadersIterator(this, 'value'); - } - - /** - * Get an iterator on entries. - * - * This is the default iterator of the Headers object. - * - * @return Iterator - */ - [Symbol.iterator]() { - return createHeadersIterator(this, 'key+value'); - } -} -Headers.prototype.entries = Headers.prototype[Symbol.iterator]; - -Object.defineProperty(Headers.prototype, Symbol.toStringTag, { - value: 'Headers', - writable: false, - enumerable: false, - configurable: true -}); - -Object.defineProperties(Headers.prototype, { - get: { enumerable: true }, - forEach: { enumerable: true }, - set: { enumerable: true }, - append: { enumerable: true }, - has: { enumerable: true }, - delete: { enumerable: true }, - keys: { enumerable: true }, - values: { enumerable: true }, - entries: { enumerable: true } -}); - -function getHeaders(headers) { - let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; - - const keys = Object.keys(headers[MAP]).sort(); - return keys.map(kind === 'key' ? function (k) { - return k.toLowerCase(); - } : kind === 'value' ? function (k) { - return headers[MAP][k].join(', '); - } : function (k) { - return [k.toLowerCase(), headers[MAP][k].join(', ')]; - }); -} - -const INTERNAL = Symbol('internal'); - -function createHeadersIterator(target, kind) { - const iterator = Object.create(HeadersIteratorPrototype); - iterator[INTERNAL] = { - target, - kind, - index: 0 - }; - return iterator; -} - -const HeadersIteratorPrototype = Object.setPrototypeOf({ - next() { - // istanbul ignore if - if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { - throw new TypeError('Value of `this` is not a HeadersIterator'); - } - - var _INTERNAL = this[INTERNAL]; - const target = _INTERNAL.target, - kind = _INTERNAL.kind, - index = _INTERNAL.index; - - const values = getHeaders(target, kind); - const len = values.length; - if (index >= len) { - return { - value: undefined, - done: true - }; - } - - this[INTERNAL].index = index + 1; - - return { - value: values[index], - done: false - }; - } -}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); - -Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { - value: 'HeadersIterator', - writable: false, - enumerable: false, - configurable: true -}); - -/** - * Export the Headers object in a form that Node.js can consume. - * - * @param Headers headers - * @return Object - */ -function exportNodeCompatibleHeaders(headers) { - const obj = Object.assign({ __proto__: null }, headers[MAP]); - - // http.request() only supports string as Host header. This hack makes - // specifying custom Host header possible. - const hostHeaderKey = find(headers[MAP], 'Host'); - if (hostHeaderKey !== undefined) { - obj[hostHeaderKey] = obj[hostHeaderKey][0]; - } - - return obj; -} - -/** - * Create a Headers object from an object of headers, ignoring those that do - * not conform to HTTP grammar productions. - * - * @param Object obj Object of headers - * @return Headers - */ -function createHeadersLenient(obj) { - const headers = new Headers(); - for (const name of Object.keys(obj)) { - if (invalidTokenRegex.test(name)) { - continue; - } - if (Array.isArray(obj[name])) { - for (const val of obj[name]) { - if (invalidHeaderCharRegex.test(val)) { - continue; - } - if (headers[MAP][name] === undefined) { - headers[MAP][name] = [val]; - } else { - headers[MAP][name].push(val); - } - } - } else if (!invalidHeaderCharRegex.test(obj[name])) { - headers[MAP][name] = [obj[name]]; - } - } - return headers; -} - -const INTERNALS$1 = Symbol('Response internals'); - -// fix an issue where "STATUS_CODES" aren't a named export for node <10 -const STATUS_CODES = http__default['default'].STATUS_CODES; - -/** - * Response class - * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void - */ -class Response { - constructor() { - let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - Body.call(this, body, opts); - - const status = opts.status || 200; - const headers = new Headers(opts.headers); - - if (body != null && !headers.has('Content-Type')) { - const contentType = extractContentType(body); - if (contentType) { - headers.append('Content-Type', contentType); - } - } - - this[INTERNALS$1] = { - url: opts.url, - status, - statusText: opts.statusText || STATUS_CODES[status], - headers, - counter: opts.counter - }; - } - - get url() { - return this[INTERNALS$1].url || ''; - } - - get status() { - return this[INTERNALS$1].status; - } - - /** - * Convenience property representing if the request ended normally - */ - get ok() { - return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; - } - - get redirected() { - return this[INTERNALS$1].counter > 0; - } - - get statusText() { - return this[INTERNALS$1].statusText; - } - - get headers() { - return this[INTERNALS$1].headers; - } - - /** - * Clone this response - * - * @return Response - */ - clone() { - return new Response(clone(this), { - url: this.url, - status: this.status, - statusText: this.statusText, - headers: this.headers, - ok: this.ok, - redirected: this.redirected - }); - } -} - -Body.mixIn(Response.prototype); - -Object.defineProperties(Response.prototype, { - url: { enumerable: true }, - status: { enumerable: true }, - ok: { enumerable: true }, - redirected: { enumerable: true }, - statusText: { enumerable: true }, - headers: { enumerable: true }, - clone: { enumerable: true } -}); - -Object.defineProperty(Response.prototype, Symbol.toStringTag, { - value: 'Response', - writable: false, - enumerable: false, - configurable: true -}); - -const INTERNALS$2 = Symbol('Request internals'); - -// fix an issue where "format", "parse" aren't a named export for node <10 -const parse_url = Url__default['default'].parse; -const format_url = Url__default['default'].format; - -const streamDestructionSupported = 'destroy' in Stream__default['default'].Readable.prototype; - -/** - * Check if a value is an instance of Request. - * - * @param Mixed input - * @return Boolean - */ -function isRequest(input) { - return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; -} - -function isAbortSignal(signal) { - const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); - return !!(proto && proto.constructor.name === 'AbortSignal'); -} - -/** - * Request class - * - * @param Mixed input Url or Request instance - * @param Object init Custom options - * @return Void - */ -class Request { - constructor(input) { - let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - let parsedURL; - - // normalize input - if (!isRequest(input)) { - if (input && input.href) { - // in order to support Node.js' Url objects; though WHATWG's URL objects - // will fall into this branch also (since their `toString()` will return - // `href` property anyway) - parsedURL = parse_url(input.href); - } else { - // coerce input to a string before attempting to parse - parsedURL = parse_url(`${input}`); - } - input = {}; - } else { - parsedURL = parse_url(input.url); - } - - let method = init.method || input.method || 'GET'; - method = method.toUpperCase(); - - if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { - throw new TypeError('Request with GET/HEAD method cannot have body'); - } - - let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; - - Body.call(this, inputBody, { - timeout: init.timeout || input.timeout || 0, - size: init.size || input.size || 0 - }); - - const headers = new Headers(init.headers || input.headers || {}); - - if (inputBody != null && !headers.has('Content-Type')) { - const contentType = extractContentType(inputBody); - if (contentType) { - headers.append('Content-Type', contentType); - } - } - - let signal = isRequest(input) ? input.signal : null; - if ('signal' in init) signal = init.signal; - - if (signal != null && !isAbortSignal(signal)) { - throw new TypeError('Expected signal to be an instanceof AbortSignal'); - } - - this[INTERNALS$2] = { - method, - redirect: init.redirect || input.redirect || 'follow', - headers, - parsedURL, - signal - }; - - // node-fetch-only options - this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; - this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; - this.counter = init.counter || input.counter || 0; - this.agent = init.agent || input.agent; - } - - get method() { - return this[INTERNALS$2].method; - } - - get url() { - return format_url(this[INTERNALS$2].parsedURL); - } - - get headers() { - return this[INTERNALS$2].headers; - } - - get redirect() { - return this[INTERNALS$2].redirect; - } - - get signal() { - return this[INTERNALS$2].signal; - } - - /** - * Clone this request - * - * @return Request - */ - clone() { - return new Request(this); - } -} - -Body.mixIn(Request.prototype); - -Object.defineProperty(Request.prototype, Symbol.toStringTag, { - value: 'Request', - writable: false, - enumerable: false, - configurable: true -}); - -Object.defineProperties(Request.prototype, { - method: { enumerable: true }, - url: { enumerable: true }, - headers: { enumerable: true }, - redirect: { enumerable: true }, - clone: { enumerable: true }, - signal: { enumerable: true } -}); - -/** - * Convert a Request to Node.js http request options. - * - * @param Request A Request instance - * @return Object The options object to be passed to http.request - */ -function getNodeRequestOptions(request) { - const parsedURL = request[INTERNALS$2].parsedURL; - const headers = new Headers(request[INTERNALS$2].headers); - - // fetch step 1.3 - if (!headers.has('Accept')) { - headers.set('Accept', '*/*'); - } - - // Basic fetch - if (!parsedURL.protocol || !parsedURL.hostname) { - throw new TypeError('Only absolute URLs are supported'); - } - - if (!/^https?:$/.test(parsedURL.protocol)) { - throw new TypeError('Only HTTP(S) protocols are supported'); - } - - if (request.signal && request.body instanceof Stream__default['default'].Readable && !streamDestructionSupported) { - throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); - } - - // HTTP-network-or-cache fetch steps 2.4-2.7 - let contentLengthValue = null; - if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { - contentLengthValue = '0'; - } - if (request.body != null) { - const totalBytes = getTotalBytes(request); - if (typeof totalBytes === 'number') { - contentLengthValue = String(totalBytes); - } - } - if (contentLengthValue) { - headers.set('Content-Length', contentLengthValue); - } - - // HTTP-network-or-cache fetch step 2.11 - if (!headers.has('User-Agent')) { - headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); - } - - // HTTP-network-or-cache fetch step 2.15 - if (request.compress && !headers.has('Accept-Encoding')) { - headers.set('Accept-Encoding', 'gzip,deflate'); - } - - let agent = request.agent; - if (typeof agent === 'function') { - agent = agent(parsedURL); - } - - if (!headers.has('Connection') && !agent) { - headers.set('Connection', 'close'); - } - - // HTTP-network fetch step 4.2 - // chunked encoding is handled by Node.js - - return Object.assign({}, parsedURL, { - method: request.method, - headers: exportNodeCompatibleHeaders(headers), - agent - }); -} - -/** - * abort-error.js - * - * AbortError interface for cancelled requests - */ - -/** - * Create AbortError instance - * - * @param String message Error message for human - * @return AbortError - */ -function AbortError(message) { - Error.call(this, message); - - this.type = 'aborted'; - this.message = message; - - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); -} - -AbortError.prototype = Object.create(Error.prototype); -AbortError.prototype.constructor = AbortError; -AbortError.prototype.name = 'AbortError'; - -// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 -const PassThrough$1 = Stream__default['default'].PassThrough; -const resolve_url = Url__default['default'].resolve; - -/** - * Fetch function - * - * @param Mixed url Absolute url or Request instance - * @param Object opts Fetch options - * @return Promise - */ -function fetch(url, opts) { - - // allow custom promise - if (!fetch.Promise) { - throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); - } - - Body.Promise = fetch.Promise; - - // wrap http.request into fetch - return new fetch.Promise(function (resolve, reject) { - // build request object - const request = new Request(url, opts); - const options = getNodeRequestOptions(request); - - const send = (options.protocol === 'https:' ? https__default['default'] : http__default['default']).request; - const signal = request.signal; - - let response = null; - - const abort = function abort() { - let error = new AbortError('The user aborted a request.'); - reject(error); - if (request.body && request.body instanceof Stream__default['default'].Readable) { - request.body.destroy(error); - } - if (!response || !response.body) return; - response.body.emit('error', error); - }; - - if (signal && signal.aborted) { - abort(); - return; - } - - const abortAndFinalize = function abortAndFinalize() { - abort(); - finalize(); - }; - - // send request - const req = send(options); - let reqTimeout; - - if (signal) { - signal.addEventListener('abort', abortAndFinalize); - } - - function finalize() { - req.abort(); - if (signal) signal.removeEventListener('abort', abortAndFinalize); - clearTimeout(reqTimeout); - } - - if (request.timeout) { - req.once('socket', function (socket) { - reqTimeout = setTimeout(function () { - reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); - finalize(); - }, request.timeout); - }); - } - - req.on('error', function (err) { - reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); - finalize(); - }); - - req.on('response', function (res) { - clearTimeout(reqTimeout); - - const headers = createHeadersLenient(res.headers); - - // HTTP fetch step 5 - if (fetch.isRedirect(res.statusCode)) { - // HTTP fetch step 5.2 - const location = headers.get('Location'); - - // HTTP fetch step 5.3 - const locationURL = location === null ? null : resolve_url(request.url, location); - - // HTTP fetch step 5.5 - switch (request.redirect) { - case 'error': - reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); - finalize(); - return; - case 'manual': - // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. - if (locationURL !== null) { - // handle corrupted header - try { - headers.set('Location', locationURL); - } catch (err) { - // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request - reject(err); - } - } - break; - case 'follow': - // HTTP-redirect fetch step 2 - if (locationURL === null) { - break; - } - - // HTTP-redirect fetch step 5 - if (request.counter >= request.follow) { - reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); - finalize(); - return; - } - - // HTTP-redirect fetch step 6 (counter increment) - // Create a new Request object. - const requestOpts = { - headers: new Headers(request.headers), - follow: request.follow, - counter: request.counter + 1, - agent: request.agent, - compress: request.compress, - method: request.method, - body: request.body, - signal: request.signal, - timeout: request.timeout, - size: request.size - }; - - // HTTP-redirect fetch step 9 - if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { - reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); - finalize(); - return; - } - - // HTTP-redirect fetch step 11 - if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { - requestOpts.method = 'GET'; - requestOpts.body = undefined; - requestOpts.headers.delete('content-length'); - } - - // HTTP-redirect fetch step 15 - resolve(fetch(new Request(locationURL, requestOpts))); - finalize(); - return; - } - } - - // prepare response - res.once('end', function () { - if (signal) signal.removeEventListener('abort', abortAndFinalize); - }); - let body = res.pipe(new PassThrough$1()); - - const response_options = { - url: request.url, - status: res.statusCode, - statusText: res.statusMessage, - headers: headers, - size: request.size, - timeout: request.timeout, - counter: request.counter - }; - - // HTTP-network fetch step 12.1.1.3 - const codings = headers.get('Content-Encoding'); - - // HTTP-network fetch step 12.1.1.4: handle content codings - - // in following scenarios we ignore compression support - // 1. compression support is disabled - // 2. HEAD request - // 3. no Content-Encoding header - // 4. no content response (204) - // 5. content not modified response (304) - if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { - response = new Response(body, response_options); - resolve(response); - return; - } - - // For Node v6+ - // Be less strict when decoding compressed responses, since sometimes - // servers send slightly invalid responses that are still accepted - // by common browsers. - // Always using Z_SYNC_FLUSH is what cURL does. - const zlibOptions = { - flush: zlib__default['default'].Z_SYNC_FLUSH, - finishFlush: zlib__default['default'].Z_SYNC_FLUSH - }; - - // for gzip - if (codings == 'gzip' || codings == 'x-gzip') { - body = body.pipe(zlib__default['default'].createGunzip(zlibOptions)); - response = new Response(body, response_options); - resolve(response); - return; - } - - // for deflate - if (codings == 'deflate' || codings == 'x-deflate') { - // handle the infamous raw deflate response from old servers - // a hack for old IIS and Apache servers - const raw = res.pipe(new PassThrough$1()); - raw.once('data', function (chunk) { - // see http://stackoverflow.com/questions/37519828 - if ((chunk[0] & 0x0F) === 0x08) { - body = body.pipe(zlib__default['default'].createInflate()); - } else { - body = body.pipe(zlib__default['default'].createInflateRaw()); - } - response = new Response(body, response_options); - resolve(response); - }); - return; - } - - // for br - if (codings == 'br' && typeof zlib__default['default'].createBrotliDecompress === 'function') { - body = body.pipe(zlib__default['default'].createBrotliDecompress()); - response = new Response(body, response_options); - resolve(response); - return; - } - - // otherwise, use response as-is - response = new Response(body, response_options); - resolve(response); - }); - - writeToStream(req, request); - }); -} -/** - * Redirect code matching - * - * @param Number code Status code - * @return Boolean - */ -fetch.isRedirect = function (code) { - return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; -}; - -// expose Promise -fetch.Promise = global.Promise; - -function noop$1() { } -function safe_not_equal(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -const subscriber_queue = []; -/** - * Creates a `Readable` store that allows reading by subscription. - * @param value initial value - * @param {StartStopNotifier}start start and stop notifications for subscriptions - */ -function readable(value, start) { - return { - subscribe: writable(value, start).subscribe - }; -} -/** - * Create a `Writable` store that allows both updating and reading by subscription. - * @param {*=}value initial value - * @param {StartStopNotifier=}start start and stop notifications for subscriptions - */ -function writable(value, start = noop$1) { - let stop; - const subscribers = []; - function set(new_value) { - if (safe_not_equal(value, new_value)) { - value = new_value; - if (stop) { // store is ready - const run_queue = !subscriber_queue.length; - for (let i = 0; i < subscribers.length; i += 1) { - const s = subscribers[i]; - s[1](); - subscriber_queue.push(s, value); - } - if (run_queue) { - for (let i = 0; i < subscriber_queue.length; i += 2) { - subscriber_queue[i][0](subscriber_queue[i + 1]); - } - subscriber_queue.length = 0; - } - } - } - } - function update(fn) { - set(fn(value)); - } - function subscribe(run, invalidate = noop$1) { - const subscriber = [run, invalidate]; - subscribers.push(subscriber); - if (subscribers.length === 1) { - stop = start(set) || noop$1; - } - run(value); - return () => { - const index = subscribers.indexOf(subscriber); - if (index !== -1) { - subscribers.splice(index, 1); - } - if (subscribers.length === 0) { - stop(); - stop = null; - } - }; - } - return { set, update, subscribe }; -} - -const noop$1$1 = () => {}; - - - - - - - -async function render_page( - request, - context, - options, - status = 200, - error = null -) - - - - - - - - { - let redirected; - let preload_error; - - const page = options.manifest.pages.find((page) => - page.pattern.test(request.path) - ); - - const baseUrl = ''; // TODO - - const session = await (options.setup.getSession && options.setup.getSession(context)); - - const serialized_session = try_serialize(session, (err) => { - throw new Error(`Failed to serialize session data: ${err.message}`); - }); - - try { - if (!page) { - const error = new Error(`Not found: ${request.path}`); - error.status = 404; - throw error; - } - - const segments = request.path.split('/').filter(Boolean); - - // TODO make this less confusing - const layout_segments = [segments[0]]; - let l = 1; - - page.parts.forEach((part, i) => { - layout_segments[l] = segments[i + 1]; - if (!part) return; - l++; - }); - - const dependencies = {}; - - const preload_context = { - redirect: (status, location) => { - if ( - redirected && - (redirected.status !== status || redirected.headers.location !== location) - ) { - throw new Error(`Conflicting redirects`); - } - location = location.replace(/^\//g, ''); // leading slash (only) - redirected = { - status, - headers: { location }, - body: null, - dependencies: {} - }; - }, - error: (status, error) => { - if (typeof error === 'string') { - error = new Error(error); - } - preload_error = { ...error, status }; - }, - fetch: async (url, opts = {}) => { - const parsed = Url.parse(url); - - if (parsed.protocol) { - // external fetch - return fetch(parsed.href, opts); - } - - // otherwise we're dealing with an internal fetch. TODO there's - // probably no advantage to using fetch here — we should replace - // `this.fetch` with `this.load` or whatever - - const resolved = Url.resolve(request.path, parsed.pathname); - - // edge case — fetching a static file - const candidates = [ - `${options.static_dir}${resolved}`, - `${options.static_dir}${resolved}/index.html` - ]; - for (const file of candidates) { - if (fs.existsSync(file)) { - return new Response(fs.createReadStream(file), { - headers: { - 'content-type': mime.getType(file) - } - }); - } - } - - // TODO this doesn't take account of opts.body - const rendered = await render( - { - host: request.host, - method: opts.method || 'GET', - headers: opts.headers || {}, // TODO inject credentials... - path: resolved, - body: opts.body, - query: new Url.URLSearchParams(parsed.query || '') - }, - options - ); - - if (rendered) { - // TODO this is primarily for the benefit of the static case, - // but could it be used elsewhere? - dependencies[resolved] = rendered; - - return new Response(rendered.body, { - status: rendered.status, - headers: rendered.headers - }); - } else { - return new Response('Not found', { - status: 404 - }); - } - } - }; - - const match = page.pattern.exec(request.path); - - // the last part has all parameters from any segment in the URL - const params = parts_to_params(match, page.parts[page.parts.length - 1] ); - - const preloaded = []; - let can_prerender = true; - - const parts = await Promise.all( - [{ component: options.manifest.layout, params: [] }, ...page.parts].map(async (part, i) => { - if (!part) return null; - - const mod = await options.load(part.component); - - if (options.only_prerender && !mod.prerender) { - can_prerender = false; - return; - } - - // these are only the parameters up to the current URL segment - const params = parts_to_params(match, part); - - const props = mod.preload - ? await mod.preload.call( - preload_context, - { - host: request.host, - path: request.path, - query: request.query, - params - }, - session - ) - : {}; - - preloaded[i] = props; - return { component: mod.default, props }; - }) - ); - - if (options.only_prerender && !can_prerender) return; - - if (preload_error) throw preload_error; - if (redirected) return redirected; - - const branches - - - - = []; - parts.forEach((part, i) => { - if (part) { - branches.push({ - component: part.component, - props: preloaded[i], - segment: segments[i] - }); - } - }); - - const pageContext = { - host: request.host , - path: request.path, - query: search_params_to_map(request.query), - params, - error: error || undefined - }; - - const props = { - status, - error, - stores: { - page: readable(pageContext, noop$1$1), - preloading: readable(null, noop$1$1), - session: writable(session) - }, - // TODO stores, status, segments, notify, CONTEXT_KEY - segments: layout_segments, - branches, - level0: { - props: preloaded[0] - }, - level1: { - segment: segments[0], - props: {} - } - }; - - // TODO this is highly confusing. replace the leveln thing with an array of branches - l = 1; - for (let i = 1; i < parts.length; i += 1) { - const part = parts[i]; - if (!part) continue; - - props[`level${l++}`] = { - component: part.component, - props: preloaded[i] || {}, - segment: segments[i] - }; - } - - const serialized_preloads = `[${preloaded - .map((data) => - try_serialize(data, (err) => { - const path = '/' + segments.join('/'); - console.error( - `Failed to serialize preloaded data to transmit to the client at the ${path} route: ${err.message}` - ); - console.warn( - 'The client will re-render over the server-rendered page fresh instead of continuing where it left off. See https://sapper.svelte.dev/docs#Return_value for more information' - ); - }) - ) - .join(',')}]`; - - const rendered = options.root.default.render(props); - - const deps = options.client.deps; - const js_deps = new Set(deps.__entry__ ? [...deps.__entry__.js] : []); - const css_deps = new Set(deps.__entry__ ? [...deps.__entry__.css] : []); - - (page.parts.filter(Boolean) ).forEach((part) => { - const page_deps = deps[part.component.name]; - - if (!page_deps) return; // we don't have this info during dev - - page_deps.js.forEach((dep) => js_deps.add(dep)); - page_deps.css.forEach((dep) => css_deps.add(dep)); - }); - - const head = `${rendered.head} - - ${Array.from(js_deps) - .map((dep) => ``) - .join('\n\t\t\t')} - ${Array.from(css_deps) - .map((dep) => ``) - .join('\n\t\t\t')} - ${options.dev ? `` : ''} - - `.replace(/^\t{2}/gm, ''); // TODO add links - - const body = `${rendered.html} - `.replace(/^\t{3}/gm, ''); - - const html = options.template.replace('%svelte.head%', head).replace('%svelte.body%', body); - - return { - status: 200, - headers: { - 'content-type': 'text/html' - }, - body: html, - dependencies - }; - } catch (thrown) { - console.error(thrown.stack); - - if (!error) { - const status = thrown.status || 500; - return render_page(request, context, options, status, thrown); - } else { - // oh lawd now you've done it - return { - status: 500, - headers: {}, - body: thrown.stack, // TODO probably not in prod? - dependencies: {} - }; - } - } -} - -function parts_to_params(match, part) { - const params = {}; - - part.params.forEach((name, i) => { - const is_spread = /^\.{3}.+$/.test(name); - - if (is_spread) { - params[name.slice(3)] = match[i + 1].split('/'); - } else { - params[name] = match[i + 1]; - } - }); - - return params; -} - -function try_serialize(data, fail) { - try { - return devalue(data); - } catch (err) { - if (fail) fail(err); - return null; - } -} - -// Ensure we return something truthy so the client will not re-render the page over the error -function serialize_error(error) { - if (!error) return null; - let serialized = try_serialize(error); - if (!serialized) { - const { name, message, stack } = error; - serialized = try_serialize({ name, message, stack }); - } - if (!serialized) { - serialized = '{}'; - } - return serialized; -} - -function search_params_to_map(params) { - const map = {}; - - for (const key of params.keys()) { - const values = params.getAll(key); - - map[key] = values.length > 1 ? values : values[0]; - } - - return map; -} - -function render_route( - request, - context, - options -) - - - - { - const route = options.manifest.endpoints.find((route) => - route.pattern.test(request.path) - ); - if (!route) return null; - - return Promise.resolve(options.load(route)).then(async (mod) => { - const handler = mod[request.method.toLowerCase().replace('delete', 'del')]; // 'delete' is a reserved word - - if (handler) { - const params = {}; - const match = route.pattern.exec(request.path); - route.params.forEach((name, i) => { - params[name] = match[i + 1]; - }); - - try { - let { status = 200, body, headers = {} } = await handler( - { - host: request.host, - path: request.path, - query: request.query, - body: request.body, - params - }, - context - ); - - headers = lowercase_keys(headers); - - if ( - (typeof body === 'object' && !('content-type' in headers)) || - headers['content-type'] === 'application/json' - ) { - headers = { ...headers, 'content-type': 'application/json' }; - body = JSON.stringify(body); - } - - return { status, body, headers }; - } catch (err) { - return { - status: 500, - body: err.message, - headers: {} - }; - } - } else { - return { - status: 501, - body: `${request.method} is not implemented for ${request.path}`, - headers: {} - }; - } - }); -} - -function lowercase_keys(obj) { - const clone = {}; - for (const key in obj) { - clone[key.toLowerCase()] = obj[key]; - } - return clone; -} - -function md5(body) { - return crypto.createHash('md5').update(body).digest('hex'); -} - -async function render( - request, - options -) { - const { context, headers = {} } = (await (options.setup.prepare && options.setup.prepare(request.headers))) || {}; - - try { - const response = await (render_route(request, context, options) || - render_page(request, context, options)); - - if (response) { - // inject ETags for 200 responses - if (response.status === 200) { - if (!/(no-store|immutable)/.test(response.headers['cache-control'])) { - const etag = `"${md5(response.body)}"`; - - if (request.headers['if-none-match'] === etag) { - return { - status: 304, - headers: {}, - body: null - }; - } - - response.headers['etag'] = etag; - } - } - - return { - status: response.status, - headers: { ...headers, ...response.headers }, - body: response.body - }; - } - } catch (err) { - return { - status: 500, - headers: {}, - body: options.dev ? err.stack : err.message - }; - } -} - -function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } - -function read_only_form_data() { - const map = new Map(); - - return { - append(key, value) { - if (map.has(key)) { - (map.get(key) ).push(value); - } else { - map.set(key, [value]); - } - }, - - data: new ReadOnlyFormData(map) - }; -} - -class ReadOnlyFormData { - #map - - constructor(map) { - this.#map = map; - } - - get(key) { - return _optionalChain([this, 'access', _ => _.#map, 'access', _2 => _2.get, 'call', _3 => _3(key), 'optionalAccess', _4 => _4[0]]); - } - - getAll(key) { - return this.#map.get(key); - } - - has(key) { - return this.#map.has(key); - } - - *[Symbol.iterator]() { - for (const [key, value] of this.#map) { - for (let i = 0; i < value.length; i += 1) { - yield [key, value[i]]; - } - } - } - - *entries() { - for (const [key, value] of this.#map) { - for (let i = 0; i < value.length; i += 1) { - yield [key, value[i]]; - } - } - } - - *keys() { - for (const [key, value] of this.#map) { - for (let i = 0; i < value.length; i += 1) { - yield key; - } - } - } - - *values() { - for (const [, value] of this.#map) { - for (let i = 0; i < value.length; i += 1) { - yield value; - } - } - } -} - -function get_body(req) { - const headers = req.headers; - const has_body = - headers['content-type'] !== undefined && - // https://github.com/jshttp/type-is/blob/c1f4388c71c8a01f79934e68f630ca4a15fffcd6/index.js#L81-L95 - (headers['transfer-encoding'] !== undefined || !isNaN(Number(headers['content-length']))); - - if (!has_body) return Promise.resolve(undefined); - - const [type, ...directives] = (headers['content-type'] ).split(/;\s*/); - - switch (type) { - case 'application/octet-stream': - return get_buffer(req); - - case 'text/plain': - return get_text(req); - - case 'application/json': - return get_json(req); - - case 'application/x-www-form-urlencoded': - return get_urlencoded(req); - - case 'multipart/form-data': - const boundary = directives.find((directive) => directive.startsWith('boundary=')); - if (!boundary) throw new Error(`Missing boundary`); - return get_multipart(req, boundary.slice('boundary='.length)); - - default: - throw new Error(`Invalid Content-Type ${type}`); - } -} - -async function get_json(req) { - return JSON.parse(await get_text(req)); -} - -async function get_urlencoded(req) { - const text = await get_text(req); - - const { data, append } = read_only_form_data(); - - text - .replace(/\+/g, ' ') - .split('&') - .forEach((str) => { - const [key, value] = str.split('='); - append(decodeURIComponent(key), decodeURIComponent(value)); - }); - - return data; -} - -async function get_multipart(req, boundary) { - const text = await get_text(req); - const parts = text.split(`--${boundary}`); - - const nope = () => { - throw new Error('Malformed form data'); - }; - - if (parts[0] !== '' || parts[parts.length - 1].trim() !== '--') { - nope(); - } - - const { data, append } = read_only_form_data(); - - parts.slice(1, -1).forEach((part) => { - const match = /\s*([\s\S]+?)\r\n\r\n([\s\S]*)\s*/.exec(part) ; - const raw_headers = match[1]; - const body = match[2].trim(); - - let key; - raw_headers.split('\r\n').forEach((str) => { - const [raw_header, ...raw_directives] = str.split('; '); - let [name, value] = raw_header.split(': '); - - name = name.toLowerCase(); - - const directives = {}; - raw_directives.forEach((raw_directive) => { - const [name, value] = raw_directive.split('='); - directives[name] = JSON.parse(value); // TODO is this right? - }); - - if (name === 'content-disposition') { - if (value !== 'form-data') nope(); - - if (directives.filename) { - // TODO we probably don't want to do this automatically - throw new Error('File upload is not yet implemented'); - } - - if (directives.name) { - key = directives.name; - } - } - }); - - if (!key) nope(); - - append(key, body); - }); - - return data; -} - -function get_text(req) { - return new Promise((fulfil, reject) => { - let data = ''; - - req.on('error', reject); - - req.on('data', (chunk) => { - data += chunk; - }); - - req.on('end', () => { - fulfil(data); - }); - }); -} - -function get_buffer(req) { - return new Promise((fulfil, reject) => { - let data = new Uint8Array(0); - - req.on('error', reject); - - req.on('data', (chunk) => { - const new_data = new Uint8Array(data.length + chunk.length); - - for (let i = 0; i < data.length; i += 1) { - new_data[i] = data[i]; - } - - for (let i = 0; i < chunk.length; i += 1) { - new_data[i + data.length] = chunk[i]; - } - - data = new_data; - }); - - req.on('end', () => { - fulfil(data.buffer); - }); - }); -} - -const manifest = require('./manifest.js'); -const client = require('./client.json'); - -const { PORT = 3000 } = process.env; - -const mutable = (dir) => - sirv(dir, { - etag: true, - maxAge: 0 - }); - -const static_handler = mutable('static'); -const prerendered_handler = fs.existsSync('build/prerendered') - ? mutable('build/prerendered') - : (_req, _res, next) => next(); - -const assets_handler = sirv('build/assets', { - maxAge: 31536000, - immutable: true -}); - -const root = require('./root.js'); -const setup = require('./setup.js'); -const template = fs.readFileSync('build/app.html', 'utf-8'); - -const server = http.createServer((req, res) => { - assets_handler(req, res, () => { - static_handler(req, res, () => { - prerendered_handler(req, res, async () => { - const parsed = Url.parse(req.url || ''); - - const rendered = await render( - { - host: null, // TODO - method: req.method , - headers: req.headers , // TODO: what about repeated headers, i.e. string[] - path: parsed.pathname , - body: await get_body(req), - query: new Url.URLSearchParams(parsed.query || '') - }, - { - static_dir: 'static', - template, - manifest, - client, - root, - setup, - load: (route) => - require(`./routes/${route.name}.js`), - dev: false, - only_prerender: false - } - ); - - if (rendered) { - res.writeHead(rendered.status, rendered.headers); - res.end(rendered.body); - } else { - res.statusCode = 404; - res.end('Not found'); - } - }); - }); - }); -}); - -server.listen(PORT, () => { - console.log(`Listening on port ${PORT}`); -}); From a0b8f61957940f30b824d413daa977a2b478c0ac Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 19:53:00 -0500 Subject: [PATCH 14/30] implement adapter-static using builder API --- packages/adapter-static/.gitignore | 1 - packages/adapter-static/index.js | 15 +++++++++++++++ packages/adapter-static/package.json | 1 - packages/adapter-static/rollup.config.js | 12 ------------ packages/adapter-static/src/index.js | 22 ---------------------- 5 files changed, 15 insertions(+), 36 deletions(-) create mode 100644 packages/adapter-static/index.js delete mode 100644 packages/adapter-static/rollup.config.js delete mode 100644 packages/adapter-static/src/index.js diff --git a/packages/adapter-static/.gitignore b/packages/adapter-static/.gitignore index 2f46fdca1f80..9daa8247da45 100644 --- a/packages/adapter-static/.gitignore +++ b/packages/adapter-static/.gitignore @@ -1,3 +1,2 @@ .DS_Store node_modules -/index.js diff --git a/packages/adapter-static/index.js b/packages/adapter-static/index.js new file mode 100644 index 000000000000..cf6212487873 --- /dev/null +++ b/packages/adapter-static/index.js @@ -0,0 +1,15 @@ +module.exports = async function adapter(builder) { + // TODO implement adapter options, allow 'build' to be specified + + builder.log('hello!'); + + builder.copy_static_files('build'); + builder.copy_generated_files('build/_app'); + + await builder.prerender({ + force: true, + dest: 'build' + }); + + builder.log('hello!'); +}; diff --git a/packages/adapter-static/package.json b/packages/adapter-static/package.json index dc38d0dcdb3b..b8341d769886 100644 --- a/packages/adapter-static/package.json +++ b/packages/adapter-static/package.json @@ -2,7 +2,6 @@ "name": "@sveltejs/adapter-static", "version": "0.0.14", "scripts": { - "build": "rollup -c", "lint": "eslint --ignore-pattern node_modules/ \"**/*.{ts,js,svelte}\" && npm run check-format", "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore", "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", diff --git a/packages/adapter-static/rollup.config.js b/packages/adapter-static/rollup.config.js deleted file mode 100644 index d944379c4d9b..000000000000 --- a/packages/adapter-static/rollup.config.js +++ /dev/null @@ -1,12 +0,0 @@ -import { nodeResolve } from '@rollup/plugin-node-resolve'; -import commonjs from '@rollup/plugin-commonjs'; - -export default { - input: 'src/index.js', - output: { - file: 'index.js', - format: 'cjs' - }, - plugins: [nodeResolve(), commonjs()], - external: require('module').builtinModules -}; diff --git a/packages/adapter-static/src/index.js b/packages/adapter-static/src/index.js deleted file mode 100644 index 945cf8576b77..000000000000 --- a/packages/adapter-static/src/index.js +++ /dev/null @@ -1,22 +0,0 @@ - -import { copy } from '@sveltejs/app-utils/files'; -import { prerender } from '@sveltejs/app-utils/renderer'; - -module.exports = async function adapter({ - dir, - manifest, - log -}) { - const out = 'build'; // TODO implement adapter options - - copy('static', out); - copy(`${dir}/client`, `${out}/_app`); - - prerender({ - force: true, - dir, - out, - manifest, - log - }); -}; From 0e784553d69938ee2ea555b9482f985d201cec8e Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 19:53:38 -0500 Subject: [PATCH 15/30] ignore generated file --- packages/adapter-node/.gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/adapter-node/.gitignore b/packages/adapter-node/.gitignore index 6e2e5caf77b0..079be49c392a 100644 --- a/packages/adapter-node/.gitignore +++ b/packages/adapter-node/.gitignore @@ -1,3 +1,4 @@ .DS_Store node_modules -/index.js \ No newline at end of file +/index.js +/server.js \ No newline at end of file From 4c4f9f6cf99ec94c5bfc056179ce13c33cec33a9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 19:54:05 -0500 Subject: [PATCH 16/30] get svelte-kit-demo example working --- examples/svelte-kit-demo/src/setup/index.js | 0 examples/svelte-kit-demo/svelte.config.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 examples/svelte-kit-demo/src/setup/index.js diff --git a/examples/svelte-kit-demo/src/setup/index.js b/examples/svelte-kit-demo/src/setup/index.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/examples/svelte-kit-demo/svelte.config.js b/examples/svelte-kit-demo/svelte.config.js index c63e6d4a27a2..5937ba031fff 100644 --- a/examples/svelte-kit-demo/svelte.config.js +++ b/examples/svelte-kit-demo/svelte.config.js @@ -2,5 +2,5 @@ module.exports = { // By default, `npm run build` will create a standard Node app. // You can create optimized builds for different platforms by // specifying a different adapter - adapter: '@sveltejs/adapter-node' + adapter: '@sveltejs/adapter-static' }; \ No newline at end of file From 1712fa8932017a525bae0181a7c3a34d91179fc0 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 25 Nov 2020 19:54:13 -0500 Subject: [PATCH 17/30] update lockfile --- pnpm-lock.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b03b9d9c319d..6bef4c40e4c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,6 +22,8 @@ importers: eslint-plugin-svelte3: ^2.7.3 prettier: 2.1.2 rollup: ^2.32.0 + ../../../../.nvm/versions/node/v12.18.3/pnpm-global: + specifiers: {} examples/hn.svelte.dev: devDependencies: '@sveltejs/adapter-node': 'link:../../packages/adapter-node' From 702cf69a6faa15d80a089b4170766496845278f6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 10:05:32 -0500 Subject: [PATCH 18/30] add back svelte eslint config peer dependencies --- package.json | 5 +- pnpm-lock.yaml | 157 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 159 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b221e44965c8..4e8865889f59 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,13 @@ "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^9.0.0", "@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.6.0", + "@typescript-eslint/eslint-plugin": "^4.8.2", + "@typescript-eslint/parser": "^4.8.2", "eslint": "^7.11.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-svelte3": "^2.7.3", "prettier": "2.1.2", - "rollup": "^2.32.0" + "rollup": "^2.32.0", + "typescript": "^4.1.2" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6bef4c40e4c7..ea2706c4c923 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,23 +5,29 @@ importers: '@rollup/plugin-commonjs': 15.1.0_rollup@2.32.0 '@rollup/plugin-json': 4.1.0_rollup@2.32.0 '@rollup/plugin-node-resolve': 9.0.0_rollup@2.32.0 - '@sveltejs/eslint-config': github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f_9ee733401bef03657849a7355d21b2a8 + '@sveltejs/eslint-config': github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f_1b15e19ea7698126a709280ea6e700d3 + '@typescript-eslint/eslint-plugin': 4.8.2_f9d49e058d7a244a64cfc7d6f997e32c + '@typescript-eslint/parser': 4.8.2_eslint@7.11.0+typescript@4.1.2 eslint: 7.11.0 eslint-plugin-import: 2.22.1_eslint@7.11.0 eslint-plugin-svelte3: 2.7.3_eslint@7.11.0 prettier: 2.1.2 rollup: 2.32.0 + typescript: 4.1.2 specifiers: '@changesets/cli': ^2.11.1 '@rollup/plugin-commonjs': ^15.1.0 '@rollup/plugin-json': ^4.1.0 '@rollup/plugin-node-resolve': ^9.0.0 '@sveltejs/eslint-config': 'github:sveltejs/eslint-config#v5.6.0' + '@typescript-eslint/eslint-plugin': ^4.8.2 + '@typescript-eslint/parser': ^4.8.2 eslint: ^7.11.0 eslint-plugin-import: ^2.22.1 eslint-plugin-svelte3: ^2.7.3 prettier: 2.1.2 rollup: ^2.32.0 + typescript: ^4.1.2 ../../../../.nvm/versions/node/v12.18.3/pnpm-global: specifiers: {} examples/hn.svelte.dev: @@ -660,6 +666,10 @@ packages: dev: true resolution: integrity: sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w== + /@types/json-schema/7.0.6: + dev: true + resolution: + integrity: sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== /@types/json5/0.0.29: dev: true resolution: @@ -735,6 +745,111 @@ packages: dev: true resolution: integrity: sha512-RxAwYt4rGwK5GyoRwuP0jT6ZHAVTdz2EqgsHmX0PYNjGsko+OeT4WFXXTs/lM3teJUJodM+SNtAL5/pXIJ61IQ== + /@typescript-eslint/eslint-plugin/4.8.2_f9d49e058d7a244a64cfc7d6f997e32c: + dependencies: + '@typescript-eslint/experimental-utils': 4.8.2_eslint@7.11.0+typescript@4.1.2 + '@typescript-eslint/parser': 4.8.2_eslint@7.11.0+typescript@4.1.2 + '@typescript-eslint/scope-manager': 4.8.2 + debug: 4.3.1 + eslint: 7.11.0 + functional-red-black-tree: 1.0.1 + regexpp: 3.1.0 + semver: 7.3.2 + tsutils: 3.17.1_typescript@4.1.2 + typescript: 4.1.2 + dev: true + engines: + node: ^10.12.0 || >=12.0.0 + peerDependencies: + '@typescript-eslint/parser': ^4.0.0 + eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + resolution: + integrity: sha512-gQ06QLV5l1DtvYtqOyFLXD9PdcILYqlrJj2l+CGDlPtmgLUzc1GpqciJFIRvyfvgLALpnxYINFuw+n9AZhPBKQ== + /@typescript-eslint/experimental-utils/4.8.2_eslint@7.11.0+typescript@4.1.2: + dependencies: + '@types/json-schema': 7.0.6 + '@typescript-eslint/scope-manager': 4.8.2 + '@typescript-eslint/types': 4.8.2 + '@typescript-eslint/typescript-estree': 4.8.2_typescript@4.1.2 + eslint: 7.11.0 + eslint-scope: 5.1.1 + eslint-utils: 2.1.0 + dev: true + engines: + node: ^10.12.0 || >=12.0.0 + peerDependencies: + eslint: '*' + typescript: '*' + resolution: + integrity: sha512-hpTw6o6IhBZEsQsjuw/4RWmceRyESfAiEzAEnXHKG1X7S5DXFaZ4IO1JO7CW1aQ604leQBzjZmuMI9QBCAJX8Q== + /@typescript-eslint/parser/4.8.2_eslint@7.11.0+typescript@4.1.2: + dependencies: + '@typescript-eslint/scope-manager': 4.8.2 + '@typescript-eslint/types': 4.8.2 + '@typescript-eslint/typescript-estree': 4.8.2_typescript@4.1.2 + debug: 4.3.1 + eslint: 7.11.0 + typescript: 4.1.2 + dev: true + engines: + node: ^10.12.0 || >=12.0.0 + peerDependencies: + eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + resolution: + integrity: sha512-u0leyJqmclYr3KcXOqd2fmx6SDGBO0MUNHHAjr0JS4Crbb3C3d8dwAdlazy133PLCcPn+aOUFiHn72wcuc5wYw== + /@typescript-eslint/scope-manager/4.8.2: + dependencies: + '@typescript-eslint/types': 4.8.2 + '@typescript-eslint/visitor-keys': 4.8.2 + dev: true + engines: + node: ^8.10.0 || ^10.13.0 || >=11.10.1 + resolution: + integrity: sha512-qHQ8ODi7mMin4Sq2eh/6eu03uVzsf5TX+J43xRmiq8ujng7ViQSHNPLOHGw/Wr5dFEoxq/ubKhzClIIdQy5q3g== + /@typescript-eslint/types/4.8.2: + dev: true + engines: + node: ^8.10.0 || ^10.13.0 || >=11.10.1 + resolution: + integrity: sha512-z1/AVcVF8ju5ObaHe2fOpZYEQrwHyZ7PTOlmjd3EoFeX9sv7UekQhfrCmgUO7PruLNfSHrJGQvrW3Q7xQ8EoAw== + /@typescript-eslint/typescript-estree/4.8.2_typescript@4.1.2: + dependencies: + '@typescript-eslint/types': 4.8.2 + '@typescript-eslint/visitor-keys': 4.8.2 + debug: 4.3.1 + globby: 11.0.1 + is-glob: 4.0.1 + lodash: 4.17.20 + semver: 7.3.2 + tsutils: 3.17.1_typescript@4.1.2 + typescript: 4.1.2 + dev: true + engines: + node: ^10.12.0 || >=12.0.0 + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + resolution: + integrity: sha512-HToGNwI6fekH0dOw3XEVESUm71Onfam0AKin6f26S2FtUmO7o3cLlWgrIaT1q3vjB3wCTdww3Dx2iGq5wtUOCg== + /@typescript-eslint/visitor-keys/4.8.2: + dependencies: + '@typescript-eslint/types': 4.8.2 + eslint-visitor-keys: 2.0.0 + dev: true + engines: + node: ^8.10.0 || ^10.13.0 || >=11.10.1 + resolution: + integrity: sha512-Vg+/SJTMZJEKKGHW7YC21QxgKJrSbxoYYd3MEUGtW7zuytHuEcksewq0DUmo4eh/CTNrVJGSdIY9AtRb6riWFw== /acorn-jsx/5.3.1_acorn@7.4.1: dependencies: acorn: 7.4.1 @@ -1257,6 +1372,19 @@ packages: optional: true resolution: integrity: sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg== + /debug/4.3.1: + dependencies: + ms: 2.1.2 + dev: true + engines: + node: '>=6.0' + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + resolution: + integrity: sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== /decamelize-keys/1.1.0: dependencies: decamelize: 1.2.0 @@ -3742,6 +3870,21 @@ packages: dev: true resolution: integrity: sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw== + /tslib/1.14.1: + dev: true + resolution: + integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== + /tsutils/3.17.1_typescript@4.1.2: + dependencies: + tslib: 1.14.1 + typescript: 4.1.2 + dev: true + engines: + node: '>= 6' + peerDependencies: + typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' + resolution: + integrity: sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== /tty-table/2.8.13: dependencies: chalk: 3.0.0 @@ -3782,6 +3925,13 @@ packages: node: '>=8' resolution: integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== + /typescript/4.1.2: + dev: true + engines: + node: '>=4.2.0' + hasBin: true + resolution: + integrity: sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ== /unique-filename/1.1.1: dependencies: unique-slug: 2.0.2 @@ -3970,11 +4120,14 @@ packages: node: '>=8' resolution: integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== - github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f_9ee733401bef03657849a7355d21b2a8: + github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f_1b15e19ea7698126a709280ea6e700d3: dependencies: + '@typescript-eslint/eslint-plugin': 4.8.2_f9d49e058d7a244a64cfc7d6f997e32c + '@typescript-eslint/parser': 4.8.2_eslint@7.11.0+typescript@4.1.2 eslint: 7.11.0 eslint-plugin-import: 2.22.1_eslint@7.11.0 eslint-plugin-svelte3: 2.7.3_eslint@7.11.0 + typescript: 4.1.2 dev: true id: github.com/sveltejs/eslint-config/7224f2bba6ac40407c332b41fa2bede946f4868f name: '@sveltejs/eslint-config' From 47b313eed8e80c6aa789c084e003cae33605e48a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 10:16:06 -0500 Subject: [PATCH 19/30] move render logic into kit --- examples/svelte-kit-demo/svelte.config.js | 2 +- packages/adapter-node/.gitignore | 3 +- packages/adapter-node/index.js | 15 + packages/adapter-node/rollup.config.js | 28 +- packages/adapter-node/src/index.js | 52 - packages/adapter-node/src/server.js | 38 +- packages/adapter-static/index.js | 6 +- packages/app-utils/package.json | 4 - packages/app-utils/src/renderer/index.js | 3 - .../app-utils/src/renderer/manifest/index.js | 37 - .../src/renderer/manifest/index.spec.data.js | 34 - .../src/renderer/manifest/index.spec.js | 22 - packages/kit/assets/renderer/index.js | 2519 +++++++++++++++++ packages/kit/assets/renderer/index.js.map | 1 + packages/kit/rollup.config.js | 13 + packages/kit/src/api/build/Builder.js | 19 +- packages/kit/src/api/build/index.js | 158 +- .../src/api/build/prerender.js} | 43 +- .../render => kit/src/renderer}/endpoint.js | 0 .../render => kit/src/renderer}/index.js | 0 .../render => kit/src/renderer}/page.js | 2 +- 21 files changed, 2691 insertions(+), 308 deletions(-) create mode 100644 packages/adapter-node/index.js delete mode 100644 packages/adapter-node/src/index.js delete mode 100644 packages/app-utils/src/renderer/index.js delete mode 100644 packages/app-utils/src/renderer/manifest/index.js delete mode 100644 packages/app-utils/src/renderer/manifest/index.spec.data.js delete mode 100644 packages/app-utils/src/renderer/manifest/index.spec.js create mode 100644 packages/kit/assets/renderer/index.js create mode 100644 packages/kit/assets/renderer/index.js.map rename packages/{app-utils/src/renderer/prerender/index.js => kit/src/api/build/prerender.js} (84%) rename packages/{app-utils/src/renderer/render => kit/src/renderer}/endpoint.js (100%) rename packages/{app-utils/src/renderer/render => kit/src/renderer}/index.js (100%) rename packages/{app-utils/src/renderer/render => kit/src/renderer}/page.js (99%) diff --git a/examples/svelte-kit-demo/svelte.config.js b/examples/svelte-kit-demo/svelte.config.js index 5937ba031fff..c63e6d4a27a2 100644 --- a/examples/svelte-kit-demo/svelte.config.js +++ b/examples/svelte-kit-demo/svelte.config.js @@ -2,5 +2,5 @@ module.exports = { // By default, `npm run build` will create a standard Node app. // You can create optimized builds for different platforms by // specifying a different adapter - adapter: '@sveltejs/adapter-static' + adapter: '@sveltejs/adapter-node' }; \ No newline at end of file diff --git a/packages/adapter-node/.gitignore b/packages/adapter-node/.gitignore index 079be49c392a..1f664acc2b82 100644 --- a/packages/adapter-node/.gitignore +++ b/packages/adapter-node/.gitignore @@ -1,4 +1,3 @@ .DS_Store node_modules -/index.js -/server.js \ No newline at end of file +/files \ No newline at end of file diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js new file mode 100644 index 000000000000..0a4c41a65bae --- /dev/null +++ b/packages/adapter-node/index.js @@ -0,0 +1,15 @@ +const fs = require('fs'); + +module.exports = async function adapter(builder) { + const out = 'build'; // TODO implement adapter options + + builder.copy_server_files(out); + builder.copy_client_files(`${out}/assets/_app`); + + fs.copyFileSync(`${__dirname}/files/server.js`, `${out}/index.js`); + + builder.log.info('Prerendering static pages...'); + await builder.prerender({ + dest: `${out}/prerendered` + }); +}; diff --git a/packages/adapter-node/rollup.config.js b/packages/adapter-node/rollup.config.js index c40c1e98ccec..22990ab35d59 100644 --- a/packages/adapter-node/rollup.config.js +++ b/packages/adapter-node/rollup.config.js @@ -1,23 +1,13 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; -export default [ - { - input: 'src/index.js', - output: { - file: 'index.js', - format: 'cjs' - }, - plugins: [nodeResolve(), commonjs()], - external: require('module').builtinModules +export default { + input: 'src/server.js', + output: { + file: 'files/server.js', + format: 'cjs', + sourcemap: true }, - { - input: 'src/server.js', - output: { - file: 'server.js', - format: 'cjs' - }, - plugins: [nodeResolve(), commonjs()], - external: require('module').builtinModules - } -]; + plugins: [nodeResolve(), commonjs()], + external: require('module').builtinModules +}; diff --git a/packages/adapter-node/src/index.js b/packages/adapter-node/src/index.js deleted file mode 100644 index 6029803240ed..000000000000 --- a/packages/adapter-node/src/index.js +++ /dev/null @@ -1,52 +0,0 @@ -import fs from 'fs'; -import { copy } from '@sveltejs/app-utils/files'; -import { prerender } from '@sveltejs/app-utils/renderer'; - -module.exports = async function adapter({ - dir, - manifest, - log -}) { - const out = 'build'; // TODO implement adapter options - - copy(`${dir}/client`, `${out}/assets/_app`, (file) => !!file && file[0] !== '.'); - copy(`${dir}/server`, out); - copy(`${__dirname}/server.js`, `${out}/index.js`); - copy(`${dir}/client.json`, `${out}/client.json`); - copy('src/app.html', `${out}/app.html`); - - log.info('Prerendering static pages...'); - - await prerender({ - force: true, - dir, - out: `${out}/prerendered`, - assets: `${out}/assets`, - manifest, - log - }); - - // generate manifest - const written_manifest = `module.exports = { - layout: ${JSON.stringify(manifest.layout)}, - error: ${JSON.stringify(manifest.error)}, - components: ${JSON.stringify(manifest.components)}, - pages: [ - ${manifest.pages - .map((page) => `{ pattern: ${page.pattern}, parts: ${JSON.stringify(page.parts)} }`) - .join(',\n\t\t\t')} - ], - endpoints: [ - ${manifest.endpoints - .map( - (route) => - `{ name: '${route.name}', pattern: ${route.pattern}, file: '${ - route.file - }', params: ${JSON.stringify(route.params)} }` - ) - .join(',\n\t\t\t')} - ] - };`.replace(/^\t/gm, ''); - - fs.writeFileSync(`${out}/manifest.js`, written_manifest); -}; diff --git a/packages/adapter-node/src/server.js b/packages/adapter-node/src/server.js index 07eac31e58bc..be99f6b46478 100644 --- a/packages/adapter-node/src/server.js +++ b/packages/adapter-node/src/server.js @@ -2,11 +2,9 @@ import * as fs from 'fs'; import * as http from 'http'; import { parse, URLSearchParams } from 'url'; import sirv from 'sirv'; -import { render } from '@sveltejs/app-utils/renderer'; import { get_body } from '@sveltejs/app-utils/http'; -const manifest = require('./manifest.js'); -const client = require('./client.json'); +const app = require('./app.js'); const { PORT = 3000 } = process.env; @@ -26,38 +24,20 @@ const assets_handler = sirv('build/assets', { immutable: true }); -const root = require('./root.js'); -const setup = require('./setup.js'); -const template = fs.readFileSync('build/app.html', 'utf-8'); - const server = http.createServer((req, res) => { assets_handler(req, res, () => { static_handler(req, res, () => { prerendered_handler(req, res, async () => { const parsed = parse(req.url || ''); - const rendered = await render( - { - host: null, // TODO - method: req.method, - headers: req.headers, // TODO: what about repeated headers, i.e. string[] - path: parsed.pathname, - body: await get_body(req), - query: new URLSearchParams(parsed.query || '') - }, - { - static_dir: 'static', - template, - manifest, - client, - root, - setup, - load: (route) => - require(`./routes/${route.name}.js`), - dev: false, - only_prerender: false - } - ); + const rendered = await app.render({ + host: null, // TODO + method: req.method, + headers: req.headers, // TODO: what about repeated headers, i.e. string[] + path: parsed.pathname, + body: await get_body(req), + query: new URLSearchParams(parsed.query || '') + }); if (rendered) { res.writeHead(rendered.status, rendered.headers); diff --git a/packages/adapter-static/index.js b/packages/adapter-static/index.js index cf6212487873..96e080a891f5 100644 --- a/packages/adapter-static/index.js +++ b/packages/adapter-static/index.js @@ -1,15 +1,11 @@ module.exports = async function adapter(builder) { // TODO implement adapter options, allow 'build' to be specified - builder.log('hello!'); - builder.copy_static_files('build'); - builder.copy_generated_files('build/_app'); + builder.copy_client_files('build/_app'); await builder.prerender({ force: true, dest: 'build' }); - - builder.log('hello!'); }; diff --git a/packages/app-utils/package.json b/packages/app-utils/package.json index 9eaa9623a33c..4180a3d88cbe 100644 --- a/packages/app-utils/package.json +++ b/packages/app-utils/package.json @@ -33,10 +33,6 @@ "./http": { "require": "./http/index.js", "import": "./http/index.mjs" - }, - "./renderer": { - "require": "./renderer/index.js", - "import": "./renderer/index.mjs" } }, "files": [ diff --git a/packages/app-utils/src/renderer/index.js b/packages/app-utils/src/renderer/index.js deleted file mode 100644 index fae2e3ddbddc..000000000000 --- a/packages/app-utils/src/renderer/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { render } from './render'; -export { prerender } from './prerender'; -export { generate_manifest_module } from './manifest'; diff --git a/packages/app-utils/src/renderer/manifest/index.js b/packages/app-utils/src/renderer/manifest/index.js deleted file mode 100644 index 4f393d28a1a3..000000000000 --- a/packages/app-utils/src/renderer/manifest/index.js +++ /dev/null @@ -1,37 +0,0 @@ -const array_item_delimiter = ','; - -function map_pages(pages) { - return pages - .map(({ pattern, parts: json_parts }) => { - const parts = JSON.stringify(json_parts); - return `{ pattern: ${pattern}, parts: ${parts} }`; - }) - .join(array_item_delimiter); -} - -function map_endpoints(endpoints) { - return endpoints - .map(({ name, pattern, file, params: json_params }) => { - const params = JSON.stringify(json_params); - return `{ name: '${name}', pattern: ${pattern}, file: '${file}', params: ${params} }`; - }) - .join(array_item_delimiter); -} - -export function generate_manifest_module(manifest) { - const strings = ['layout', 'error', 'components']; - const [layout, error, components] = strings.map((b) => JSON.stringify(manifest[b])); - const pages = map_pages(manifest.pages); - const endpoints = map_endpoints(manifest.endpoints); - - return ` -module.exports = { - layout: ${layout}, - error: ${error}, - components: ${components}, - pages: [${pages}], - endpoints: [${endpoints}] -};` - .replace(/^\t/gm, '') - .trim(); -} diff --git a/packages/app-utils/src/renderer/manifest/index.spec.data.js b/packages/app-utils/src/renderer/manifest/index.spec.data.js deleted file mode 100644 index 6da7b58107d9..000000000000 --- a/packages/app-utils/src/renderer/manifest/index.spec.data.js +++ /dev/null @@ -1,34 +0,0 @@ -const examplePageComponentManifest = { - default: true, - type: 'foo', - name: 'bar', - file: 'baz', - url: 'boo' -}; - -const examplePageManifest = { - pattern: /a/, - path: 'qux', - parts: [ - { - component: examplePageComponentManifest, - params: ['quux', 'corge'] - } - ] -}; - -const exampleEndpointManifest = { - name: 'grault', - pattern: /b/, - file: 'garply', - url: 'bla', - params: ['waldo', 'fred'] -}; - -export const exampleRouteManifest = { - layout: examplePageComponentManifest, - error: examplePageComponentManifest, - components: [examplePageComponentManifest, examplePageComponentManifest], - pages: [examplePageManifest, examplePageManifest], - endpoints: [exampleEndpointManifest, exampleEndpointManifest] -}; diff --git a/packages/app-utils/src/renderer/manifest/index.spec.js b/packages/app-utils/src/renderer/manifest/index.spec.js deleted file mode 100644 index a983bcfc9c62..000000000000 --- a/packages/app-utils/src/renderer/manifest/index.spec.js +++ /dev/null @@ -1,22 +0,0 @@ -import { suite } from 'uvu'; -import * as assert from 'uvu/assert'; -import { exampleRouteManifest } from './index.spec.data'; -import { generate_manifest_module } from '.'; - -const generate_manifest_module_suite = suite('#generate_manifest_module()'); - -generate_manifest_module_suite('writes manifest', () => { - const actual = generate_manifest_module(exampleRouteManifest); - const expected = ` -module.exports = { - layout: {"default":true,"type":"foo","name":"bar","file":"baz","url":"boo"}, - error: {"default":true,"type":"foo","name":"bar","file":"baz","url":"boo"}, - components: [{"default":true,"type":"foo","name":"bar","file":"baz","url":"boo"},{"default":true,"type":"foo","name":"bar","file":"baz","url":"boo"}], - pages: [{ pattern: /a/, parts: [{"component":{"default":true,"type":"foo","name":"bar","file":"baz","url":"boo"},"params":["quux","corge"]}] },{ pattern: /a/, parts: [{"component":{"default":true,"type":"foo","name":"bar","file":"baz","url":"boo"},"params":["quux","corge"]}] }], - endpoints: [{ name: 'grault', pattern: /b/, file: 'garply', params: ["waldo","fred"] },{ name: 'grault', pattern: /b/, file: 'garply', params: ["waldo","fred"] }] -}; - `; - assert.equal(actual, expected.trim()); -}); - -generate_manifest_module_suite.run(); diff --git a/packages/kit/assets/renderer/index.js b/packages/kit/assets/renderer/index.js new file mode 100644 index 000000000000..a503115f5200 --- /dev/null +++ b/packages/kit/assets/renderer/index.js @@ -0,0 +1,2519 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var crypto = require('crypto'); +var fs = require('fs'); +var Stream = require('stream'); +var http = require('http'); +var Url = require('url'); +var https = require('https'); +var zlib = require('zlib'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var Stream__default = /*#__PURE__*/_interopDefaultLegacy(Stream); +var http__default = /*#__PURE__*/_interopDefaultLegacy(http); +var Url__default = /*#__PURE__*/_interopDefaultLegacy(Url); +var https__default = /*#__PURE__*/_interopDefaultLegacy(https); +var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib); + +var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'; +var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g; +var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/; +var escaped = { + '<': '\\u003C', + '>': '\\u003E', + '/': '\\u002F', + '\\': '\\\\', + '\b': '\\b', + '\f': '\\f', + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\0': '\\0', + '\u2028': '\\u2028', + '\u2029': '\\u2029' +}; +var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join('\0'); +function devalue(value) { + var counts = new Map(); + function walk(thing) { + if (typeof thing === 'function') { + throw new Error("Cannot stringify a function"); + } + if (counts.has(thing)) { + counts.set(thing, counts.get(thing) + 1); + return; + } + counts.set(thing, 1); + if (!isPrimitive(thing)) { + var type = getType(thing); + switch (type) { + case 'Number': + case 'String': + case 'Boolean': + case 'Date': + case 'RegExp': + return; + case 'Array': + thing.forEach(walk); + break; + case 'Set': + case 'Map': + Array.from(thing).forEach(walk); + break; + default: + var proto = Object.getPrototypeOf(thing); + if (proto !== Object.prototype && + proto !== null && + Object.getOwnPropertyNames(proto).sort().join('\0') !== objectProtoOwnPropertyNames) { + throw new Error("Cannot stringify arbitrary non-POJOs"); + } + if (Object.getOwnPropertySymbols(thing).length > 0) { + throw new Error("Cannot stringify POJOs with symbolic keys"); + } + Object.keys(thing).forEach(function (key) { return walk(thing[key]); }); + } + } + } + walk(value); + var names = new Map(); + Array.from(counts) + .filter(function (entry) { return entry[1] > 1; }) + .sort(function (a, b) { return b[1] - a[1]; }) + .forEach(function (entry, i) { + names.set(entry[0], getName(i)); + }); + function stringify(thing) { + if (names.has(thing)) { + return names.get(thing); + } + if (isPrimitive(thing)) { + return stringifyPrimitive(thing); + } + var type = getType(thing); + switch (type) { + case 'Number': + case 'String': + case 'Boolean': + return "Object(" + stringify(thing.valueOf()) + ")"; + case 'RegExp': + return "new RegExp(" + stringifyString(thing.source) + ", \"" + thing.flags + "\")"; + case 'Date': + return "new Date(" + thing.getTime() + ")"; + case 'Array': + var members = thing.map(function (v, i) { return i in thing ? stringify(v) : ''; }); + var tail = thing.length === 0 || (thing.length - 1 in thing) ? '' : ','; + return "[" + members.join(',') + tail + "]"; + case 'Set': + case 'Map': + return "new " + type + "([" + Array.from(thing).map(stringify).join(',') + "])"; + default: + var obj = "{" + Object.keys(thing).map(function (key) { return safeKey(key) + ":" + stringify(thing[key]); }).join(',') + "}"; + var proto = Object.getPrototypeOf(thing); + if (proto === null) { + return Object.keys(thing).length > 0 + ? "Object.assign(Object.create(null)," + obj + ")" + : "Object.create(null)"; + } + return obj; + } + } + var str = stringify(value); + if (names.size) { + var params_1 = []; + var statements_1 = []; + var values_1 = []; + names.forEach(function (name, thing) { + params_1.push(name); + if (isPrimitive(thing)) { + values_1.push(stringifyPrimitive(thing)); + return; + } + var type = getType(thing); + switch (type) { + case 'Number': + case 'String': + case 'Boolean': + values_1.push("Object(" + stringify(thing.valueOf()) + ")"); + break; + case 'RegExp': + values_1.push(thing.toString()); + break; + case 'Date': + values_1.push("new Date(" + thing.getTime() + ")"); + break; + case 'Array': + values_1.push("Array(" + thing.length + ")"); + thing.forEach(function (v, i) { + statements_1.push(name + "[" + i + "]=" + stringify(v)); + }); + break; + case 'Set': + values_1.push("new Set"); + statements_1.push(name + "." + Array.from(thing).map(function (v) { return "add(" + stringify(v) + ")"; }).join('.')); + break; + case 'Map': + values_1.push("new Map"); + statements_1.push(name + "." + Array.from(thing).map(function (_a) { + var k = _a[0], v = _a[1]; + return "set(" + stringify(k) + ", " + stringify(v) + ")"; + }).join('.')); + break; + default: + values_1.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'); + Object.keys(thing).forEach(function (key) { + statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key])); + }); + } + }); + statements_1.push("return " + str); + return "(function(" + params_1.join(',') + "){" + statements_1.join(';') + "}(" + values_1.join(',') + "))"; + } + else { + return str; + } +} +function getName(num) { + var name = ''; + do { + name = chars[num % chars.length] + name; + num = ~~(num / chars.length) - 1; + } while (num >= 0); + return reserved.test(name) ? name + "_" : name; +} +function isPrimitive(thing) { + return Object(thing) !== thing; +} +function stringifyPrimitive(thing) { + if (typeof thing === 'string') + return stringifyString(thing); + if (thing === void 0) + return 'void 0'; + if (thing === 0 && 1 / thing < 0) + return '-0'; + var str = String(thing); + if (typeof thing === 'number') + return str.replace(/^(-)?0\./, '$1.'); + return str; +} +function getType(thing) { + return Object.prototype.toString.call(thing).slice(8, -1); +} +function escapeUnsafeChar(c) { + return escaped[c] || c; +} +function escapeUnsafeChars(str) { + return str.replace(unsafeChars, escapeUnsafeChar); +} +function safeKey(key) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key)); +} +function safeProp(key) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]"; +} +function stringifyString(str) { + var result = '"'; + for (var i = 0; i < str.length; i += 1) { + var char = str.charAt(i); + var code = char.charCodeAt(0); + if (char === '"') { + result += '\\"'; + } + else if (char in escaped) { + result += escaped[char]; + } + else if (code >= 0xd800 && code <= 0xdfff) { + var next = str.charCodeAt(i + 1); + // If this is the beginning of a [high, low] surrogate pair, + // add the next two characters, otherwise escape + if (code <= 0xdbff && (next >= 0xdc00 && next <= 0xdfff)) { + result += char + str[++i]; + } + else { + result += "\\u" + code.toString(16).toUpperCase(); + } + } + else { + result += char; + } + } + result += '"'; + return result; +} + +/** + * @param typeMap [Object] Map of MIME type -> Array[extensions] + * @param ... + */ +function Mime() { + this._types = Object.create(null); + this._extensions = Object.create(null); + + for (var i = 0; i < arguments.length; i++) { + this.define(arguments[i]); + } + + this.define = this.define.bind(this); + this.getType = this.getType.bind(this); + this.getExtension = this.getExtension.bind(this); +} + +/** + * Define mimetype -> extension mappings. Each key is a mime-type that maps + * to an array of extensions associated with the type. The first extension is + * used as the default extension for the type. + * + * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); + * + * If a type declares an extension that has already been defined, an error will + * be thrown. To suppress this error and force the extension to be associated + * with the new type, pass `force`=true. Alternatively, you may prefix the + * extension with "*" to map the type to extension, without mapping the + * extension to the type. + * + * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']}); + * + * + * @param map (Object) type definitions + * @param force (Boolean) if true, force overriding of existing definitions + */ +Mime.prototype.define = function(typeMap, force) { + for (var type in typeMap) { + var extensions = typeMap[type].map(function(t) {return t.toLowerCase()}); + type = type.toLowerCase(); + + for (var i = 0; i < extensions.length; i++) { + var ext = extensions[i]; + + // '*' prefix = not the preferred type for this extension. So fixup the + // extension, and skip it. + if (ext[0] == '*') { + continue; + } + + if (!force && (ext in this._types)) { + throw new Error( + 'Attempt to change mapping for "' + ext + + '" extension from "' + this._types[ext] + '" to "' + type + + '". Pass `force=true` to allow this, otherwise remove "' + ext + + '" from the list of extensions for "' + type + '".' + ); + } + + this._types[ext] = type; + } + + // Use first extension as default + if (force || !this._extensions[type]) { + var ext = extensions[0]; + this._extensions[type] = (ext[0] != '*') ? ext : ext.substr(1); + } + } +}; + +/** + * Lookup a mime type based on extension + */ +Mime.prototype.getType = function(path) { + path = String(path); + var last = path.replace(/^.*[/\\]/, '').toLowerCase(); + var ext = last.replace(/^.*\./, '').toLowerCase(); + + var hasPath = last.length < path.length; + var hasDot = ext.length < last.length - 1; + + return (hasDot || !hasPath) && this._types[ext] || null; +}; + +/** + * Return file extension associated with a mime type + */ +Mime.prototype.getExtension = function(type) { + type = /^\s*([^;\s]*)/.test(type) && RegExp.$1; + return type && this._extensions[type.toLowerCase()] || null; +}; + +var Mime_1 = Mime; + +var standard = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/urc-ressheet+xml":["rsheet"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["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/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"],"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/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/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/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/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"]}; + +var other = {"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":["keynote"],"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.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}; + +var mime = new Mime_1(standard, other); + +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js + +// fix for "Readable" isn't a named export issue +const Readable = Stream__default['default'].Readable; + +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); + +class Blob { + constructor() { + this[TYPE] = ''; + + const blobParts = arguments[0]; + const options = arguments[1]; + + const buffers = []; + let size = 0; + + if (blobParts) { + const a = blobParts; + const length = Number(a.length); + for (let i = 0; i < length; i++) { + const element = a[i]; + let buffer; + if (element instanceof Buffer) { + buffer = element; + } else if (ArrayBuffer.isView(element)) { + buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); + } else if (element instanceof ArrayBuffer) { + buffer = Buffer.from(element); + } else if (element instanceof Blob) { + buffer = element[BUFFER]; + } else { + buffer = Buffer.from(typeof element === 'string' ? element : String(element)); + } + size += buffer.length; + buffers.push(buffer); + } + } + + this[BUFFER] = Buffer.concat(buffers); + + let type = options && options.type !== undefined && String(options.type).toLowerCase(); + if (type && !/[^\u0020-\u007E]/.test(type)) { + this[TYPE] = type; + } + } + get size() { + return this[BUFFER].length; + } + get type() { + return this[TYPE]; + } + text() { + return Promise.resolve(this[BUFFER].toString()); + } + arrayBuffer() { + const buf = this[BUFFER]; + const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + return Promise.resolve(ab); + } + stream() { + const readable = new Readable(); + readable._read = function () {}; + readable.push(this[BUFFER]); + readable.push(null); + return readable; + } + toString() { + return '[object Blob]'; + } + slice() { + const size = this.size; + + const start = arguments[0]; + const end = arguments[1]; + let relativeStart, relativeEnd; + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + const span = Math.max(relativeEnd - relativeStart, 0); + + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +} + +Object.defineProperties(Blob.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); + +Object.defineProperty(Blob.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * fetch-error.js + * + * FetchError interface for operational errors + */ + +/** + * Create FetchError instance + * + * @param String message Error message for human + * @param String type Error type for machine + * @param String systemError For Node.js system error + * @return FetchError + */ +function FetchError(message, type, systemError) { + Error.call(this, message); + + this.message = message; + this.type = type; + + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; + +let convert; +try { + convert = require('encoding').convert; +} catch (e) {} + +const INTERNALS = Symbol('Body internals'); + +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream__default['default'].PassThrough; + +/** + * Body mixin + * + * Ref: https://fetch.spec.whatwg.org/#body + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +function Body(body) { + var _this = this; + + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; + + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + + if (body == null) { + // body is undefined or null + body = null; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + body = Buffer.from(body.toString()); + } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + body = Buffer.from(body); + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); + } else if (body instanceof Stream__default['default']) ; else { + // none of the above + // coerce to string then buffer + body = Buffer.from(String(body)); + } + this[INTERNALS] = { + body, + disturbed: false, + error: null + }; + this.size = size; + this.timeout = timeout; + + if (body instanceof Stream__default['default']) { + body.on('error', function (err) { + const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); + _this[INTERNALS].error = error; + }); + } +} + +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, + + get bodyUsed() { + return this[INTERNALS].disturbed; + }, + + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, + + /** + * Return raw response as Blob + * + * @return Promise + */ + blob() { + let ct = this.headers && this.headers.get('content-type') || ''; + return consumeBody.call(this).then(function (buf) { + return Object.assign( + // Prevent copying + new Blob([], { + type: ct.toLowerCase() + }), { + [BUFFER]: buf + }); + }); + }, + + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; + + return consumeBody.call(this).then(function (buffer) { + try { + return JSON.parse(buffer.toString()); + } catch (err) { + return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + } + }); + }, + + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, + + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, + + /** + * Decode response as text, while automatically detecting the encoding and + * trying to decode to UTF-8 (non-spec api) + * + * @return Promise + */ + textConverted() { + var _this3 = this; + + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; + +// In browsers, all properties are enumerable. +Object.defineProperties(Body.prototype, { + body: { enumerable: true }, + bodyUsed: { enumerable: true }, + arrayBuffer: { enumerable: true }, + blob: { enumerable: true }, + json: { enumerable: true }, + text: { enumerable: true } +}); + +Body.mixIn = function (proto) { + for (const name of Object.getOwnPropertyNames(Body.prototype)) { + // istanbul ignore else: future proof + if (!(name in proto)) { + const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); + Object.defineProperty(proto, name, desc); + } + } +}; + +/** + * Consume and convert an entire Body to a Buffer. + * + * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * + * @return Promise + */ +function consumeBody() { + var _this4 = this; + + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } + + this[INTERNALS].disturbed = true; + + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } + + let body = this.body; + + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is blob + if (isBlob(body)) { + body = body.stream(); + } + + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } + + // istanbul ignore if: should never happen + if (!(body instanceof Stream__default['default'])) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; + + return new Body.Promise(function (resolve, reject) { + let resTimeout; + + // allow timeout on slow response body + if (_this4.timeout) { + resTimeout = setTimeout(function () { + abort = true; + reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); + }, _this4.timeout); + } + + // handle stream errors + body.on('error', function (err) { + if (err.name === 'AbortError') { + // if the request was aborted, reject with this Error + abort = true; + reject(err); + } else { + // other errors, such as incorrect content-encoding + reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } + + if (_this4.size && accumBytes + chunk.length > _this4.size) { + abort = true; + reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + return; + } + + accumBytes += chunk.length; + accum.push(chunk); + }); + + body.on('end', function () { + if (abort) { + return; + } + + clearTimeout(resTimeout); + + try { + resolve(Buffer.concat(accum, accumBytes)); + } catch (err) { + // handle streams that have accumulated too much data (issue #414) + reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + }); +} + +/** + * Detect buffer encoding and convert to target encoding + * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * + * @param Buffer buffer Incoming buffer + * @param String encoding Target encoding + * @return String + */ +function convertBody(buffer, headers) { + if (typeof convert !== 'function') { + throw new Error('The package `encoding` must be installed to use the textConverted() function'); + } + + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; + + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } + + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); + + // html5 + if (!res && str) { + res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; + + this[MAP] = Object.create(null); + + if (init instanceof Headers) { + const rawHeaders = init.raw(); + const headerNames = Object.keys(rawHeaders); + + for (const headerName of headerNames) { + for (const value of rawHeaders[headerName]) { + this.append(headerName, value); + } + } + + return; + } + + // We don't worry about converting prop to ByteString here as append() + // will handle it. + if (init == null) ; else if (typeof init === 'object') { + const method = init[Symbol.iterator]; + if (method != null) { + if (typeof method !== 'function') { + throw new TypeError('Header pairs must be iterable'); + } + + // sequence> + // Note: per spec we have to first exhaust the lists then process them + const pairs = []; + for (const pair of init) { + if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { + throw new TypeError('Each header pair must be iterable'); + } + pairs.push(Array.from(pair)); + } + + for (const pair of pairs) { + if (pair.length !== 2) { + throw new TypeError('Each header pair must be a name/value tuple'); + } + this.append(pair[0], pair[1]); + } + } else { + // record + for (const key of Object.keys(init)) { + const value = init[key]; + this.append(key, value); + } + } + } else { + throw new TypeError('Provided initializer must be an object'); + } + } + + /** + * Return combined header value given name + * + * @param String name Header name + * @return Mixed + */ + get(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key === undefined) { + return null; + } + + return this[MAP][key].join(', '); + } + + /** + * Iterate over all headers + * + * @param Function callback Executed for each item with parameters (value, name, thisArg) + * @param Boolean thisArg `this` context for callback function + * @return Void + */ + forEach(callback) { + let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + + let pairs = getHeaders(this); + let i = 0; + while (i < pairs.length) { + var _pairs$i = pairs[i]; + const name = _pairs$i[0], + value = _pairs$i[1]; + + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } + } + + /** + * Overwrite header values given name + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + set(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + this[MAP][key !== undefined ? key : name] = [value]; + } + + /** + * Append a value onto existing header + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + append(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + if (key !== undefined) { + this[MAP][key].push(value); + } else { + this[MAP][name] = [value]; + } + } + + /** + * Check for header name existence + * + * @param String name Header name + * @return Boolean + */ + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } + + /** + * Delete all header values given name + * + * @param String name Header name + * @return Void + */ + delete(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key !== undefined) { + delete this[MAP][key]; + } + } + + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } + + /** + * Get an iterator on keys. + * + * @return Iterator + */ + keys() { + return createHeadersIterator(this, 'key'); + } + + /** + * Get an iterator on values. + * + * @return Iterator + */ + values() { + return createHeadersIterator(this, 'value'); + } + + /** + * Get an iterator on entries. + * + * This is the default iterator of the Headers object. + * + * @return Iterator + */ + [Symbol.iterator]() { + return createHeadersIterator(this, 'key+value'); + } +} +Headers.prototype.entries = Headers.prototype[Symbol.iterator]; + +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Headers.prototype, { + get: { enumerable: true }, + forEach: { enumerable: true }, + set: { enumerable: true }, + append: { enumerable: true }, + has: { enumerable: true }, + delete: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true } +}); + +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + + const keys = Object.keys(headers[MAP]).sort(); + return keys.map(kind === 'key' ? function (k) { + return k.toLowerCase(); + } : kind === 'value' ? function (k) { + return headers[MAP][k].join(', '); + } : function (k) { + return [k.toLowerCase(), headers[MAP][k].join(', ')]; + }); +} + +const INTERNAL = Symbol('internal'); + +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; +} + +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } + + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; + + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } + + this[INTERNAL].index = index + 1; + + return { + value: values[index], + done: false + }; + } +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); + +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * Export the Headers object in a form that Node.js can consume. + * + * @param Headers headers + * @return Object + */ +function exportNodeCompatibleHeaders(headers) { + const obj = Object.assign({ __proto__: null }, headers[MAP]); + + // http.request() only supports string as Host header. This hack makes + // specifying custom Host header possible. + const hostHeaderKey = find(headers[MAP], 'Host'); + if (hostHeaderKey !== undefined) { + obj[hostHeaderKey] = obj[hostHeaderKey][0]; + } + + return obj; +} + +/** + * Create a Headers object from an object of headers, ignoring those that do + * not conform to HTTP grammar productions. + * + * @param Object obj Object of headers + * @return Headers + */ +function createHeadersLenient(obj) { + const headers = new Headers(); + for (const name of Object.keys(obj)) { + if (invalidTokenRegex.test(name)) { + continue; + } + if (Array.isArray(obj[name])) { + for (const val of obj[name]) { + if (invalidHeaderCharRegex.test(val)) { + continue; + } + if (headers[MAP][name] === undefined) { + headers[MAP][name] = [val]; + } else { + headers[MAP][name].push(val); + } + } + } else if (!invalidHeaderCharRegex.test(obj[name])) { + headers[MAP][name] = [obj[name]]; + } + } + return headers; +} + +const INTERNALS$1 = Symbol('Response internals'); + +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http__default['default'].STATUS_CODES; + +/** + * Response class + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +class Response { + constructor() { + let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + Body.call(this, body, opts); + + const status = opts.status || 200; + const headers = new Headers(opts.headers); + + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; + } + + get url() { + return this[INTERNALS$1].url || ''; + } + + get status() { + return this[INTERNALS$1].status; + } + + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + } + + get redirected() { + return this[INTERNALS$1].counter > 0; + } + + get statusText() { + return this[INTERNALS$1].statusText; + } + + get headers() { + return this[INTERNALS$1].headers; + } + + /** + * Clone this response + * + * @return Response + */ + clone() { + return new Response(clone(this), { + url: this.url, + status: this.status, + statusText: this.statusText, + headers: this.headers, + ok: this.ok, + redirected: this.redirected + }); + } +} + +Body.mixIn(Response.prototype); + +Object.defineProperties(Response.prototype, { + url: { enumerable: true }, + status: { enumerable: true }, + ok: { enumerable: true }, + redirected: { enumerable: true }, + statusText: { enumerable: true }, + headers: { enumerable: true }, + clone: { enumerable: true } +}); + +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); + +const INTERNALS$2 = Symbol('Request internals'); + +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url__default['default'].parse; +const format_url = Url__default['default'].format; + +const streamDestructionSupported = 'destroy' in Stream__default['default'].Readable.prototype; + +/** + * Check if a value is an instance of Request. + * + * @param Mixed input + * @return Boolean + */ +function isRequest(input) { + return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; +} + +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); +} + +/** + * Request class + * + * @param Mixed input Url or Request instance + * @param Object init Custom options + * @return Void + */ +class Request { + constructor(input) { + let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + let parsedURL; + + // normalize input + if (!isRequest(input)) { + if (input && input.href) { + // in order to support Node.js' Url objects; though WHATWG's URL objects + // will fall into this branch also (since their `toString()` will return + // `href` property anyway) + parsedURL = parse_url(input.href); + } else { + // coerce input to a string before attempting to parse + parsedURL = parse_url(`${input}`); + } + input = {}; + } else { + parsedURL = parse_url(input.url); + } + + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); + + if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { + throw new TypeError('Request with GET/HEAD method cannot have body'); + } + + let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; + + Body.call(this, inputBody, { + timeout: init.timeout || input.timeout || 0, + size: init.size || input.size || 0 + }); + + const headers = new Headers(init.headers || input.headers || {}); + + if (inputBody != null && !headers.has('Content-Type')) { + const contentType = extractContentType(inputBody); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + let signal = isRequest(input) ? input.signal : null; + if ('signal' in init) signal = init.signal; + + if (signal != null && !isAbortSignal(signal)) { + throw new TypeError('Expected signal to be an instanceof AbortSignal'); + } + + this[INTERNALS$2] = { + method, + redirect: init.redirect || input.redirect || 'follow', + headers, + parsedURL, + signal + }; + + // node-fetch-only options + this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; + this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; + this.counter = init.counter || input.counter || 0; + this.agent = init.agent || input.agent; + } + + get method() { + return this[INTERNALS$2].method; + } + + get url() { + return format_url(this[INTERNALS$2].parsedURL); + } + + get headers() { + return this[INTERNALS$2].headers; + } + + get redirect() { + return this[INTERNALS$2].redirect; + } + + get signal() { + return this[INTERNALS$2].signal; + } + + /** + * Clone this request + * + * @return Request + */ + clone() { + return new Request(this); + } +} + +Body.mixIn(Request.prototype); + +Object.defineProperty(Request.prototype, Symbol.toStringTag, { + value: 'Request', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Request.prototype, { + method: { enumerable: true }, + url: { enumerable: true }, + headers: { enumerable: true }, + redirect: { enumerable: true }, + clone: { enumerable: true }, + signal: { enumerable: true } +}); + +/** + * Convert a Request to Node.js http request options. + * + * @param Request A Request instance + * @return Object The options object to be passed to http.request + */ +function getNodeRequestOptions(request) { + const parsedURL = request[INTERNALS$2].parsedURL; + const headers = new Headers(request[INTERNALS$2].headers); + + // fetch step 1.3 + if (!headers.has('Accept')) { + headers.set('Accept', '*/*'); + } + + // Basic fetch + if (!parsedURL.protocol || !parsedURL.hostname) { + throw new TypeError('Only absolute URLs are supported'); + } + + if (!/^https?:$/.test(parsedURL.protocol)) { + throw new TypeError('Only HTTP(S) protocols are supported'); + } + + if (request.signal && request.body instanceof Stream__default['default'].Readable && !streamDestructionSupported) { + throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); + } + + // HTTP-network-or-cache fetch steps 2.4-2.7 + let contentLengthValue = null; + if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { + contentLengthValue = '0'; + } + if (request.body != null) { + const totalBytes = getTotalBytes(request); + if (typeof totalBytes === 'number') { + contentLengthValue = String(totalBytes); + } + } + if (contentLengthValue) { + headers.set('Content-Length', contentLengthValue); + } + + // HTTP-network-or-cache fetch step 2.11 + if (!headers.has('User-Agent')) { + headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); + } + + // HTTP-network-or-cache fetch step 2.15 + if (request.compress && !headers.has('Accept-Encoding')) { + headers.set('Accept-Encoding', 'gzip,deflate'); + } + + let agent = request.agent; + if (typeof agent === 'function') { + agent = agent(parsedURL); + } + + if (!headers.has('Connection') && !agent) { + headers.set('Connection', 'close'); + } + + // HTTP-network fetch step 4.2 + // chunked encoding is handled by Node.js + + return Object.assign({}, parsedURL, { + method: request.method, + headers: exportNodeCompatibleHeaders(headers), + agent + }); +} + +/** + * abort-error.js + * + * AbortError interface for cancelled requests + */ + +/** + * Create AbortError instance + * + * @param String message Error message for human + * @return AbortError + */ +function AbortError(message) { + Error.call(this, message); + + this.type = 'aborted'; + this.message = message; + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +AbortError.prototype = Object.create(Error.prototype); +AbortError.prototype.constructor = AbortError; +AbortError.prototype.name = 'AbortError'; + +// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 +const PassThrough$1 = Stream__default['default'].PassThrough; +const resolve_url = Url__default['default'].resolve; + +/** + * Fetch function + * + * @param Mixed url Absolute url or Request instance + * @param Object opts Fetch options + * @return Promise + */ +function fetch(url, opts) { + + // allow custom promise + if (!fetch.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } + + Body.Promise = fetch.Promise; + + // wrap http.request into fetch + return new fetch.Promise(function (resolve, reject) { + // build request object + const request = new Request(url, opts); + const options = getNodeRequestOptions(request); + + const send = (options.protocol === 'https:' ? https__default['default'] : http__default['default']).request; + const signal = request.signal; + + let response = null; + + const abort = function abort() { + let error = new AbortError('The user aborted a request.'); + reject(error); + if (request.body && request.body instanceof Stream__default['default'].Readable) { + request.body.destroy(error); + } + if (!response || !response.body) return; + response.body.emit('error', error); + }; + + if (signal && signal.aborted) { + abort(); + return; + } + + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; + + // send request + const req = send(options); + let reqTimeout; + + if (signal) { + signal.addEventListener('abort', abortAndFinalize); + } + + function finalize() { + req.abort(); + if (signal) signal.removeEventListener('abort', abortAndFinalize); + clearTimeout(reqTimeout); + } + + if (request.timeout) { + req.once('socket', function (socket) { + reqTimeout = setTimeout(function () { + reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); + finalize(); + }, request.timeout); + }); + } + + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + finalize(); + }); + + req.on('response', function (res) { + clearTimeout(reqTimeout); + + const headers = createHeadersLenient(res.headers); + + // HTTP fetch step 5 + if (fetch.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); + + // HTTP fetch step 5.3 + const locationURL = location === null ? null : resolve_url(request.url, location); + + // HTTP fetch step 5.5 + switch (request.redirect) { + case 'error': + reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); + finalize(); + return; + case 'manual': + // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. + if (locationURL !== null) { + // handle corrupted header + try { + headers.set('Location', locationURL); + } catch (err) { + // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request + reject(err); + } + } + break; + case 'follow': + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } + + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOpts = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: request.body, + signal: request.signal, + timeout: request.timeout, + size: request.size + }; + + // HTTP-redirect fetch step 9 + if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { + reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 11 + if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { + requestOpts.method = 'GET'; + requestOpts.body = undefined; + requestOpts.headers.delete('content-length'); + } + + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOpts))); + finalize(); + return; + } + } + + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); + + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter + }; + + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); + + // HTTP-network fetch step 12.1.1.4: handle content codings + + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { + response = new Response(body, response_options); + resolve(response); + return; + } + + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib__default['default'].Z_SYNC_FLUSH, + finishFlush: zlib__default['default'].Z_SYNC_FLUSH + }; + + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib__default['default'].createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); + return; + } + + // for deflate + if (codings == 'deflate' || codings == 'x-deflate') { + // handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = res.pipe(new PassThrough$1()); + raw.once('data', function (chunk) { + // see http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0F) === 0x08) { + body = body.pipe(zlib__default['default'].createInflate()); + } else { + body = body.pipe(zlib__default['default'].createInflateRaw()); + } + response = new Response(body, response_options); + resolve(response); + }); + return; + } + + // for br + if (codings == 'br' && typeof zlib__default['default'].createBrotliDecompress === 'function') { + body = body.pipe(zlib__default['default'].createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; + } + + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); + }); + + writeToStream(req, request); + }); +} +/** + * Redirect code matching + * + * @param Number code Status code + * @return Boolean + */ +fetch.isRedirect = function (code) { + return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; +}; + +// expose Promise +fetch.Promise = global.Promise; + +function noop() { } +function safe_not_equal(a, b) { + return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + +const subscriber_queue = []; +/** + * Creates a `Readable` store that allows reading by subscription. + * @param value initial value + * @param {StartStopNotifier}start start and stop notifications for subscriptions + */ +function readable(value, start) { + return { + subscribe: writable(value, start).subscribe + }; +} +/** + * Create a `Writable` store that allows both updating and reading by subscription. + * @param {*=}value initial value + * @param {StartStopNotifier=}start start and stop notifications for subscriptions + */ +function writable(value, start = noop) { + let stop; + const subscribers = []; + function set(new_value) { + if (safe_not_equal(value, new_value)) { + value = new_value; + if (stop) { // store is ready + const run_queue = !subscriber_queue.length; + for (let i = 0; i < subscribers.length; i += 1) { + const s = subscribers[i]; + s[1](); + subscriber_queue.push(s, value); + } + if (run_queue) { + for (let i = 0; i < subscriber_queue.length; i += 2) { + subscriber_queue[i][0](subscriber_queue[i + 1]); + } + subscriber_queue.length = 0; + } + } + } + } + function update(fn) { + set(fn(value)); + } + function subscribe(run, invalidate = noop) { + const subscriber = [run, invalidate]; + subscribers.push(subscriber); + if (subscribers.length === 1) { + stop = start(set) || noop; + } + run(value); + return () => { + const index = subscribers.indexOf(subscriber); + if (index !== -1) { + subscribers.splice(index, 1); + } + if (subscribers.length === 0) { + stop(); + stop = null; + } + }; + } + return { set, update, subscribe }; +} + +const noop$1 = () => {}; + +async function render_page( + request, + context, + options, + status = 200, + error = null +) { + let redirected; + let preload_error; + + const page = options.manifest.pages.find((page) => + page.pattern.test(request.path) + ); + + const baseUrl = ''; // TODO + + const session = await (options.setup.getSession && options.setup.getSession(context)); + + const serialized_session = try_serialize(session, (err) => { + throw new Error(`Failed to serialize session data: ${err.message}`); + }); + + try { + if (!page) { + const error = new Error(`Not found: ${request.path}`); + error.status = 404; + throw error; + } + + const segments = request.path.split('/').filter(Boolean); + + // TODO make this less confusing + const layout_segments = [segments[0]]; + let l = 1; + + page.parts.forEach((part, i) => { + layout_segments[l] = segments[i + 1]; + if (!part) return; + l++; + }); + + const dependencies = {}; + + const preload_context = { + redirect: (status, location) => { + if ( + redirected && + (redirected.status !== status || redirected.headers.location !== location) + ) { + throw new Error('Conflicting redirects'); + } + location = location.replace(/^\//g, ''); // leading slash (only) + redirected = { + status, + headers: { location }, + body: null, + dependencies: {} + }; + }, + error: (status, error) => { + if (typeof error === 'string') { + error = new Error(error); + } + preload_error = { ...error, status }; + }, + fetch: async (url, opts = {}) => { + const parsed = Url.parse(url); + + if (parsed.protocol) { + // external fetch + return fetch(parsed.href, opts); + } + + // otherwise we're dealing with an internal fetch. TODO there's + // probably no advantage to using fetch here — we should replace + // `this.fetch` with `this.load` or whatever + + const resolved = Url.resolve(request.path, parsed.pathname); + + // edge case — fetching a static file + const candidates = [ + `${options.static_dir}${resolved}`, + `${options.static_dir}${resolved}/index.html` + ]; + for (const file of candidates) { + if (fs.existsSync(file)) { + return new Response(fs.createReadStream(file), { + headers: { + 'content-type': mime.getType(file) + } + }); + } + } + + // TODO this doesn't take account of opts.body + const rendered = await render( + { + host: request.host, + method: opts.method || 'GET', + headers: opts.headers || {}, // TODO inject credentials... + path: resolved, + body: opts.body, + query: new Url.URLSearchParams(parsed.query || '') + }, + options + ); + + if (rendered) { + // TODO this is primarily for the benefit of the static case, + // but could it be used elsewhere? + dependencies[resolved] = rendered; + + return new Response(rendered.body, { + status: rendered.status, + headers: rendered.headers + }); + } else { + return new Response('Not found', { + status: 404 + }); + } + } + }; + + const match = page.pattern.exec(request.path); + + // the last part has all parameters from any segment in the URL + const params = parts_to_params(match, page.parts[page.parts.length - 1] ); + + const preloaded = []; + let can_prerender = true; + + const parts = await Promise.all( + [{ component: options.manifest.layout, params: [] }, ...page.parts].map(async (part, i) => { + if (!part) return null; + + const mod = await options.load(part.component); + + if (options.only_prerender && !mod.prerender) { + can_prerender = false; + return; + } + + // these are only the parameters up to the current URL segment + const params = parts_to_params(match, part); + + const props = mod.preload + ? await mod.preload.call( + preload_context, + { + host: request.host, + path: request.path, + query: request.query, + params + }, + session + ) + : {}; + + preloaded[i] = props; + return { component: mod.default, props }; + }) + ); + + if (options.only_prerender && !can_prerender) return; + + if (preload_error) throw preload_error; + if (redirected) return redirected; + + const branches = []; + parts.forEach((part, i) => { + if (part) { + branches.push({ + component: part.component, + props: preloaded[i], + segment: segments[i] + }); + } + }); + + const pageContext = { + host: request.host , + path: request.path, + query: search_params_to_map(request.query), + params, + error: error || undefined + }; + + const props = { + status, + error, + stores: { + page: readable(pageContext, noop$1), + preloading: readable(null, noop$1), + session: writable(session) + }, + // TODO stores, status, segments, notify, CONTEXT_KEY + segments: layout_segments, + branches, + level0: { + props: preloaded[0] + }, + level1: { + segment: segments[0], + props: {} + } + }; + + // TODO this is highly confusing. replace the leveln thing with an array of branches + l = 1; + for (let i = 1; i < parts.length; i += 1) { + const part = parts[i]; + if (!part) continue; + + props[`level${l++}`] = { + component: part.component, + props: preloaded[i] || {}, + segment: segments[i] + }; + } + + const serialized_preloads = `[${preloaded + .map((data) => + try_serialize(data, (err) => { + const path = '/' + segments.join('/'); + console.error( + `Failed to serialize preloaded data to transmit to the client at the ${path} route: ${err.message}` + ); + console.warn( + 'The client will re-render over the server-rendered page fresh instead of continuing where it left off. See https://sapper.svelte.dev/docs#Return_value for more information' + ); + }) + ) + .join(',')}]`; + + const rendered = options.root.render(props); + + const deps = options.client.deps; + const js_deps = new Set(deps.__entry__ ? [...deps.__entry__.js] : []); + const css_deps = new Set(deps.__entry__ ? [...deps.__entry__.css] : []); + + (page.parts.filter(Boolean) ).forEach((part) => { + const page_deps = deps[part.component.name]; + + if (!page_deps) return; // we don't have this info during dev + + page_deps.js.forEach((dep) => js_deps.add(dep)); + page_deps.css.forEach((dep) => css_deps.add(dep)); + }); + + const head = `${rendered.head} + + ${Array.from(js_deps) + .map((dep) => ``) + .join('\n\t\t\t')} + ${Array.from(css_deps) + .map((dep) => ``) + .join('\n\t\t\t')} + ${options.dev ? `` : ''} + + `.replace(/^\t{2}/gm, ''); // TODO add links + + const body = `${rendered.html} + `.replace(/^\t{3}/gm, ''); + + const html = options.template.replace('%svelte.head%', head).replace('%svelte.body%', body); + + return { + status: 200, + headers: { + 'content-type': 'text/html' + }, + body: html, + dependencies + }; + } catch (thrown) { + console.error(thrown.stack); + + if (!error) { + const status = thrown.status || 500; + return render_page(request, context, options, status, thrown); + } else { + // oh lawd now you've done it + return { + status: 500, + headers: {}, + body: thrown.stack, // TODO probably not in prod? + dependencies: {} + }; + } + } +} + +function parts_to_params(match, part) { + const params = {}; + + part.params.forEach((name, i) => { + const is_spread = /^\.{3}.+$/.test(name); + + if (is_spread) { + params[name.slice(3)] = match[i + 1].split('/'); + } else { + params[name] = match[i + 1]; + } + }); + + return params; +} + +function try_serialize(data, fail) { + try { + return devalue(data); + } catch (err) { + if (fail) fail(err); + return null; + } +} + +// Ensure we return something truthy so the client will not re-render the page over the error +function serialize_error(error) { + if (!error) return null; + let serialized = try_serialize(error); + if (!serialized) { + const { name, message, stack } = error; + serialized = try_serialize({ name, message, stack }); + } + if (!serialized) { + serialized = '{}'; + } + return serialized; +} + +function search_params_to_map(params) { + const map = {}; + + for (const key of params.keys()) { + const values = params.getAll(key); + + map[key] = values.length > 1 ? values : values[0]; + } + + return map; +} + +function render_route( + request, + context, + options +) { + const route = options.manifest.endpoints.find((route) => + route.pattern.test(request.path) + ); + if (!route) return null; + + return Promise.resolve(options.load(route)).then(async (mod) => { + const handler = mod[request.method.toLowerCase().replace('delete', 'del')]; // 'delete' is a reserved word + + if (handler) { + const params = {}; + const match = route.pattern.exec(request.path); + route.params.forEach((name, i) => { + params[name] = match[i + 1]; + }); + + try { + let { status = 200, body, headers = {} } = await handler( + { + host: request.host, + path: request.path, + query: request.query, + body: request.body, + params + }, + context + ); + + headers = lowercase_keys(headers); + + if ( + (typeof body === 'object' && !('content-type' in headers)) || + headers['content-type'] === 'application/json' + ) { + headers = { ...headers, 'content-type': 'application/json' }; + body = JSON.stringify(body); + } + + return { status, body, headers }; + } catch (err) { + return { + status: 500, + body: err.message, + headers: {} + }; + } + } else { + return { + status: 501, + body: `${request.method} is not implemented for ${request.path}`, + headers: {} + }; + } + }); +} + +function lowercase_keys(obj) { + const clone = {}; + for (const key in obj) { + clone[key.toLowerCase()] = obj[key]; + } + return clone; +} + +function md5(body) { + return crypto.createHash('md5').update(body).digest('hex'); +} + +async function render( + request, + options +) { + const { context, headers = {} } = (await (options.setup.prepare && options.setup.prepare(request.headers))) || {}; + + try { + const response = await (render_route(request, context, options) || + render_page(request, context, options)); + + if (response) { + // inject ETags for 200 responses + if (response.status === 200) { + if (!/(no-store|immutable)/.test(response.headers['cache-control'])) { + const etag = `"${md5(response.body)}"`; + + if (request.headers['if-none-match'] === etag) { + return { + status: 304, + headers: {}, + body: null + }; + } + + response.headers['etag'] = etag; + } + } + + return { + status: response.status, + headers: { ...headers, ...response.headers }, + body: response.body + }; + } + } catch (err) { + return { + status: 500, + headers: {}, + body: options.dev ? err.stack : err.message + }; + } +} + +exports.render = render; +//# sourceMappingURL=index.js.map diff --git a/packages/kit/assets/renderer/index.js.map b/packages/kit/assets/renderer/index.js.map new file mode 100644 index 000000000000..8c7982479be3 --- /dev/null +++ b/packages/kit/assets/renderer/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../../../../node_modules/.pnpm/devalue@2.0.1/node_modules/devalue/dist/devalue.esm.js","../../../../node_modules/.pnpm/mime@2.4.6/node_modules/mime/Mime.js","../../../../node_modules/.pnpm/mime@2.4.6/node_modules/mime/types/standard.js","../../../../node_modules/.pnpm/mime@2.4.6/node_modules/mime/types/other.js","../../../../node_modules/.pnpm/mime@2.4.6/node_modules/mime/index.js","../../../../node_modules/.pnpm/node-fetch@2.6.1/node_modules/node-fetch/lib/index.mjs","../../../../node_modules/.pnpm/svelte@3.29.0/node_modules/svelte/internal/index.mjs","../../../../node_modules/.pnpm/svelte@3.29.0/node_modules/svelte/store/index.mjs","../../src/renderer/page.js","../../src/renderer/endpoint.js","../../src/renderer/index.js"],"sourcesContent":["var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';\nvar unsafeChars = /[<>\\b\\f\\n\\r\\t\\0\\u2028\\u2029]/g;\nvar reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;\nvar escaped = {\n '<': '\\\\u003C',\n '>': '\\\\u003E',\n '/': '\\\\u002F',\n '\\\\': '\\\\\\\\',\n '\\b': '\\\\b',\n '\\f': '\\\\f',\n '\\n': '\\\\n',\n '\\r': '\\\\r',\n '\\t': '\\\\t',\n '\\0': '\\\\0',\n '\\u2028': '\\\\u2028',\n '\\u2029': '\\\\u2029'\n};\nvar objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join('\\0');\nfunction devalue(value) {\n var counts = new Map();\n function walk(thing) {\n if (typeof thing === 'function') {\n throw new Error(\"Cannot stringify a function\");\n }\n if (counts.has(thing)) {\n counts.set(thing, counts.get(thing) + 1);\n return;\n }\n counts.set(thing, 1);\n if (!isPrimitive(thing)) {\n var type = getType(thing);\n switch (type) {\n case 'Number':\n case 'String':\n case 'Boolean':\n case 'Date':\n case 'RegExp':\n return;\n case 'Array':\n thing.forEach(walk);\n break;\n case 'Set':\n case 'Map':\n Array.from(thing).forEach(walk);\n break;\n default:\n var proto = Object.getPrototypeOf(thing);\n if (proto !== Object.prototype &&\n proto !== null &&\n Object.getOwnPropertyNames(proto).sort().join('\\0') !== objectProtoOwnPropertyNames) {\n throw new Error(\"Cannot stringify arbitrary non-POJOs\");\n }\n if (Object.getOwnPropertySymbols(thing).length > 0) {\n throw new Error(\"Cannot stringify POJOs with symbolic keys\");\n }\n Object.keys(thing).forEach(function (key) { return walk(thing[key]); });\n }\n }\n }\n walk(value);\n var names = new Map();\n Array.from(counts)\n .filter(function (entry) { return entry[1] > 1; })\n .sort(function (a, b) { return b[1] - a[1]; })\n .forEach(function (entry, i) {\n names.set(entry[0], getName(i));\n });\n function stringify(thing) {\n if (names.has(thing)) {\n return names.get(thing);\n }\n if (isPrimitive(thing)) {\n return stringifyPrimitive(thing);\n }\n var type = getType(thing);\n switch (type) {\n case 'Number':\n case 'String':\n case 'Boolean':\n return \"Object(\" + stringify(thing.valueOf()) + \")\";\n case 'RegExp':\n return \"new RegExp(\" + stringifyString(thing.source) + \", \\\"\" + thing.flags + \"\\\")\";\n case 'Date':\n return \"new Date(\" + thing.getTime() + \")\";\n case 'Array':\n var members = thing.map(function (v, i) { return i in thing ? stringify(v) : ''; });\n var tail = thing.length === 0 || (thing.length - 1 in thing) ? '' : ',';\n return \"[\" + members.join(',') + tail + \"]\";\n case 'Set':\n case 'Map':\n return \"new \" + type + \"([\" + Array.from(thing).map(stringify).join(',') + \"])\";\n default:\n var obj = \"{\" + Object.keys(thing).map(function (key) { return safeKey(key) + \":\" + stringify(thing[key]); }).join(',') + \"}\";\n var proto = Object.getPrototypeOf(thing);\n if (proto === null) {\n return Object.keys(thing).length > 0\n ? \"Object.assign(Object.create(null),\" + obj + \")\"\n : \"Object.create(null)\";\n }\n return obj;\n }\n }\n var str = stringify(value);\n if (names.size) {\n var params_1 = [];\n var statements_1 = [];\n var values_1 = [];\n names.forEach(function (name, thing) {\n params_1.push(name);\n if (isPrimitive(thing)) {\n values_1.push(stringifyPrimitive(thing));\n return;\n }\n var type = getType(thing);\n switch (type) {\n case 'Number':\n case 'String':\n case 'Boolean':\n values_1.push(\"Object(\" + stringify(thing.valueOf()) + \")\");\n break;\n case 'RegExp':\n values_1.push(thing.toString());\n break;\n case 'Date':\n values_1.push(\"new Date(\" + thing.getTime() + \")\");\n break;\n case 'Array':\n values_1.push(\"Array(\" + thing.length + \")\");\n thing.forEach(function (v, i) {\n statements_1.push(name + \"[\" + i + \"]=\" + stringify(v));\n });\n break;\n case 'Set':\n values_1.push(\"new Set\");\n statements_1.push(name + \".\" + Array.from(thing).map(function (v) { return \"add(\" + stringify(v) + \")\"; }).join('.'));\n break;\n case 'Map':\n values_1.push(\"new Map\");\n statements_1.push(name + \".\" + Array.from(thing).map(function (_a) {\n var k = _a[0], v = _a[1];\n return \"set(\" + stringify(k) + \", \" + stringify(v) + \")\";\n }).join('.'));\n break;\n default:\n values_1.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}');\n Object.keys(thing).forEach(function (key) {\n statements_1.push(\"\" + name + safeProp(key) + \"=\" + stringify(thing[key]));\n });\n }\n });\n statements_1.push(\"return \" + str);\n return \"(function(\" + params_1.join(',') + \"){\" + statements_1.join(';') + \"}(\" + values_1.join(',') + \"))\";\n }\n else {\n return str;\n }\n}\nfunction getName(num) {\n var name = '';\n do {\n name = chars[num % chars.length] + name;\n num = ~~(num / chars.length) - 1;\n } while (num >= 0);\n return reserved.test(name) ? name + \"_\" : name;\n}\nfunction isPrimitive(thing) {\n return Object(thing) !== thing;\n}\nfunction stringifyPrimitive(thing) {\n if (typeof thing === 'string')\n return stringifyString(thing);\n if (thing === void 0)\n return 'void 0';\n if (thing === 0 && 1 / thing < 0)\n return '-0';\n var str = String(thing);\n if (typeof thing === 'number')\n return str.replace(/^(-)?0\\./, '$1.');\n return str;\n}\nfunction getType(thing) {\n return Object.prototype.toString.call(thing).slice(8, -1);\n}\nfunction escapeUnsafeChar(c) {\n return escaped[c] || c;\n}\nfunction escapeUnsafeChars(str) {\n return str.replace(unsafeChars, escapeUnsafeChar);\n}\nfunction safeKey(key) {\n return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key));\n}\nfunction safeProp(key) {\n return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? \".\" + key : \"[\" + escapeUnsafeChars(JSON.stringify(key)) + \"]\";\n}\nfunction stringifyString(str) {\n var result = '\"';\n for (var i = 0; i < str.length; i += 1) {\n var char = str.charAt(i);\n var code = char.charCodeAt(0);\n if (char === '\"') {\n result += '\\\\\"';\n }\n else if (char in escaped) {\n result += escaped[char];\n }\n else if (code >= 0xd800 && code <= 0xdfff) {\n var next = str.charCodeAt(i + 1);\n // If this is the beginning of a [high, low] surrogate pair,\n // add the next two characters, otherwise escape\n if (code <= 0xdbff && (next >= 0xdc00 && next <= 0xdfff)) {\n result += char + str[++i];\n }\n else {\n result += \"\\\\u\" + code.toString(16).toUpperCase();\n }\n }\n else {\n result += char;\n }\n }\n result += '\"';\n return result;\n}\n\nexport default devalue;\n","'use strict';\n\n/**\n * @param typeMap [Object] Map of MIME type -> Array[extensions]\n * @param ...\n */\nfunction Mime() {\n this._types = Object.create(null);\n this._extensions = Object.create(null);\n\n for (var i = 0; i < arguments.length; i++) {\n this.define(arguments[i]);\n }\n\n this.define = this.define.bind(this);\n this.getType = this.getType.bind(this);\n this.getExtension = this.getExtension.bind(this);\n}\n\n/**\n * Define mimetype -> extension mappings. Each key is a mime-type that maps\n * to an array of extensions associated with the type. The first extension is\n * used as the default extension for the type.\n *\n * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});\n *\n * If a type declares an extension that has already been defined, an error will\n * be thrown. To suppress this error and force the extension to be associated\n * with the new type, pass `force`=true. Alternatively, you may prefix the\n * extension with \"*\" to map the type to extension, without mapping the\n * extension to the type.\n *\n * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});\n *\n *\n * @param map (Object) type definitions\n * @param force (Boolean) if true, force overriding of existing definitions\n */\nMime.prototype.define = function(typeMap, force) {\n for (var type in typeMap) {\n var extensions = typeMap[type].map(function(t) {return t.toLowerCase()});\n type = type.toLowerCase();\n\n for (var i = 0; i < extensions.length; i++) {\n var ext = extensions[i];\n\n // '*' prefix = not the preferred type for this extension. So fixup the\n // extension, and skip it.\n if (ext[0] == '*') {\n continue;\n }\n\n if (!force && (ext in this._types)) {\n throw new Error(\n 'Attempt to change mapping for \"' + ext +\n '\" extension from \"' + this._types[ext] + '\" to \"' + type +\n '\". Pass `force=true` to allow this, otherwise remove \"' + ext +\n '\" from the list of extensions for \"' + type + '\".'\n );\n }\n\n this._types[ext] = type;\n }\n\n // Use first extension as default\n if (force || !this._extensions[type]) {\n var ext = extensions[0];\n this._extensions[type] = (ext[0] != '*') ? ext : ext.substr(1)\n }\n }\n};\n\n/**\n * Lookup a mime type based on extension\n */\nMime.prototype.getType = function(path) {\n path = String(path);\n var last = path.replace(/^.*[/\\\\]/, '').toLowerCase();\n var ext = last.replace(/^.*\\./, '').toLowerCase();\n\n var hasPath = last.length < path.length;\n var hasDot = ext.length < last.length - 1;\n\n return (hasDot || !hasPath) && this._types[ext] || null;\n};\n\n/**\n * Return file extension associated with a mime type\n */\nMime.prototype.getExtension = function(type) {\n type = /^\\s*([^;\\s]*)/.test(type) && RegExp.$1;\n return type && this._extensions[type.toLowerCase()] || null;\n};\n\nmodule.exports = Mime;\n","module.exports = {\"application/andrew-inset\":[\"ez\"],\"application/applixware\":[\"aw\"],\"application/atom+xml\":[\"atom\"],\"application/atomcat+xml\":[\"atomcat\"],\"application/atomdeleted+xml\":[\"atomdeleted\"],\"application/atomsvc+xml\":[\"atomsvc\"],\"application/atsc-dwd+xml\":[\"dwd\"],\"application/atsc-held+xml\":[\"held\"],\"application/atsc-rsat+xml\":[\"rsat\"],\"application/bdoc\":[\"bdoc\"],\"application/calendar+xml\":[\"xcs\"],\"application/ccxml+xml\":[\"ccxml\"],\"application/cdfx+xml\":[\"cdfx\"],\"application/cdmi-capability\":[\"cdmia\"],\"application/cdmi-container\":[\"cdmic\"],\"application/cdmi-domain\":[\"cdmid\"],\"application/cdmi-object\":[\"cdmio\"],\"application/cdmi-queue\":[\"cdmiq\"],\"application/cu-seeme\":[\"cu\"],\"application/dash+xml\":[\"mpd\"],\"application/davmount+xml\":[\"davmount\"],\"application/docbook+xml\":[\"dbk\"],\"application/dssc+der\":[\"dssc\"],\"application/dssc+xml\":[\"xdssc\"],\"application/ecmascript\":[\"ecma\",\"es\"],\"application/emma+xml\":[\"emma\"],\"application/emotionml+xml\":[\"emotionml\"],\"application/epub+zip\":[\"epub\"],\"application/exi\":[\"exi\"],\"application/fdt+xml\":[\"fdt\"],\"application/font-tdpfr\":[\"pfr\"],\"application/geo+json\":[\"geojson\"],\"application/gml+xml\":[\"gml\"],\"application/gpx+xml\":[\"gpx\"],\"application/gxf\":[\"gxf\"],\"application/gzip\":[\"gz\"],\"application/hjson\":[\"hjson\"],\"application/hyperstudio\":[\"stk\"],\"application/inkml+xml\":[\"ink\",\"inkml\"],\"application/ipfix\":[\"ipfix\"],\"application/its+xml\":[\"its\"],\"application/java-archive\":[\"jar\",\"war\",\"ear\"],\"application/java-serialized-object\":[\"ser\"],\"application/java-vm\":[\"class\"],\"application/javascript\":[\"js\",\"mjs\"],\"application/json\":[\"json\",\"map\"],\"application/json5\":[\"json5\"],\"application/jsonml+json\":[\"jsonml\"],\"application/ld+json\":[\"jsonld\"],\"application/lgr+xml\":[\"lgr\"],\"application/lost+xml\":[\"lostxml\"],\"application/mac-binhex40\":[\"hqx\"],\"application/mac-compactpro\":[\"cpt\"],\"application/mads+xml\":[\"mads\"],\"application/manifest+json\":[\"webmanifest\"],\"application/marc\":[\"mrc\"],\"application/marcxml+xml\":[\"mrcx\"],\"application/mathematica\":[\"ma\",\"nb\",\"mb\"],\"application/mathml+xml\":[\"mathml\"],\"application/mbox\":[\"mbox\"],\"application/mediaservercontrol+xml\":[\"mscml\"],\"application/metalink+xml\":[\"metalink\"],\"application/metalink4+xml\":[\"meta4\"],\"application/mets+xml\":[\"mets\"],\"application/mmt-aei+xml\":[\"maei\"],\"application/mmt-usd+xml\":[\"musd\"],\"application/mods+xml\":[\"mods\"],\"application/mp21\":[\"m21\",\"mp21\"],\"application/mp4\":[\"mp4s\",\"m4p\"],\"application/mrb-consumer+xml\":[\"*xdf\"],\"application/mrb-publish+xml\":[\"*xdf\"],\"application/msword\":[\"doc\",\"dot\"],\"application/mxf\":[\"mxf\"],\"application/n-quads\":[\"nq\"],\"application/n-triples\":[\"nt\"],\"application/node\":[\"cjs\"],\"application/octet-stream\":[\"bin\",\"dms\",\"lrf\",\"mar\",\"so\",\"dist\",\"distz\",\"pkg\",\"bpk\",\"dump\",\"elc\",\"deploy\",\"exe\",\"dll\",\"deb\",\"dmg\",\"iso\",\"img\",\"msi\",\"msp\",\"msm\",\"buffer\"],\"application/oda\":[\"oda\"],\"application/oebps-package+xml\":[\"opf\"],\"application/ogg\":[\"ogx\"],\"application/omdoc+xml\":[\"omdoc\"],\"application/onenote\":[\"onetoc\",\"onetoc2\",\"onetmp\",\"onepkg\"],\"application/oxps\":[\"oxps\"],\"application/p2p-overlay+xml\":[\"relo\"],\"application/patch-ops-error+xml\":[\"*xer\"],\"application/pdf\":[\"pdf\"],\"application/pgp-encrypted\":[\"pgp\"],\"application/pgp-signature\":[\"asc\",\"sig\"],\"application/pics-rules\":[\"prf\"],\"application/pkcs10\":[\"p10\"],\"application/pkcs7-mime\":[\"p7m\",\"p7c\"],\"application/pkcs7-signature\":[\"p7s\"],\"application/pkcs8\":[\"p8\"],\"application/pkix-attr-cert\":[\"ac\"],\"application/pkix-cert\":[\"cer\"],\"application/pkix-crl\":[\"crl\"],\"application/pkix-pkipath\":[\"pkipath\"],\"application/pkixcmp\":[\"pki\"],\"application/pls+xml\":[\"pls\"],\"application/postscript\":[\"ai\",\"eps\",\"ps\"],\"application/provenance+xml\":[\"provx\"],\"application/pskc+xml\":[\"pskcxml\"],\"application/raml+yaml\":[\"raml\"],\"application/rdf+xml\":[\"rdf\",\"owl\"],\"application/reginfo+xml\":[\"rif\"],\"application/relax-ng-compact-syntax\":[\"rnc\"],\"application/resource-lists+xml\":[\"rl\"],\"application/resource-lists-diff+xml\":[\"rld\"],\"application/rls-services+xml\":[\"rs\"],\"application/route-apd+xml\":[\"rapd\"],\"application/route-s-tsid+xml\":[\"sls\"],\"application/route-usd+xml\":[\"rusd\"],\"application/rpki-ghostbusters\":[\"gbr\"],\"application/rpki-manifest\":[\"mft\"],\"application/rpki-roa\":[\"roa\"],\"application/rsd+xml\":[\"rsd\"],\"application/rss+xml\":[\"rss\"],\"application/rtf\":[\"rtf\"],\"application/sbml+xml\":[\"sbml\"],\"application/scvp-cv-request\":[\"scq\"],\"application/scvp-cv-response\":[\"scs\"],\"application/scvp-vp-request\":[\"spq\"],\"application/scvp-vp-response\":[\"spp\"],\"application/sdp\":[\"sdp\"],\"application/senml+xml\":[\"senmlx\"],\"application/sensml+xml\":[\"sensmlx\"],\"application/set-payment-initiation\":[\"setpay\"],\"application/set-registration-initiation\":[\"setreg\"],\"application/shf+xml\":[\"shf\"],\"application/sieve\":[\"siv\",\"sieve\"],\"application/smil+xml\":[\"smi\",\"smil\"],\"application/sparql-query\":[\"rq\"],\"application/sparql-results+xml\":[\"srx\"],\"application/srgs\":[\"gram\"],\"application/srgs+xml\":[\"grxml\"],\"application/sru+xml\":[\"sru\"],\"application/ssdl+xml\":[\"ssdl\"],\"application/ssml+xml\":[\"ssml\"],\"application/swid+xml\":[\"swidtag\"],\"application/tei+xml\":[\"tei\",\"teicorpus\"],\"application/thraud+xml\":[\"tfi\"],\"application/timestamped-data\":[\"tsd\"],\"application/toml\":[\"toml\"],\"application/ttml+xml\":[\"ttml\"],\"application/urc-ressheet+xml\":[\"rsheet\"],\"application/voicexml+xml\":[\"vxml\"],\"application/wasm\":[\"wasm\"],\"application/widget\":[\"wgt\"],\"application/winhlp\":[\"hlp\"],\"application/wsdl+xml\":[\"wsdl\"],\"application/wspolicy+xml\":[\"wspolicy\"],\"application/xaml+xml\":[\"xaml\"],\"application/xcap-att+xml\":[\"xav\"],\"application/xcap-caps+xml\":[\"xca\"],\"application/xcap-diff+xml\":[\"xdf\"],\"application/xcap-el+xml\":[\"xel\"],\"application/xcap-error+xml\":[\"xer\"],\"application/xcap-ns+xml\":[\"xns\"],\"application/xenc+xml\":[\"xenc\"],\"application/xhtml+xml\":[\"xhtml\",\"xht\"],\"application/xliff+xml\":[\"xlf\"],\"application/xml\":[\"xml\",\"xsl\",\"xsd\",\"rng\"],\"application/xml-dtd\":[\"dtd\"],\"application/xop+xml\":[\"xop\"],\"application/xproc+xml\":[\"xpl\"],\"application/xslt+xml\":[\"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/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\"],\"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/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/png\":[\"png\"],\"image/sgi\":[\"sgi\"],\"image/svg+xml\":[\"svg\",\"svgz\"],\"image/t38\":[\"t38\"],\"image/tiff\":[\"tif\",\"tiff\"],\"image/tiff-fx\":[\"tfx\"],\"image/webp\":[\"webp\"],\"image/wmf\":[\"wmf\"],\"message/disposition-notification\":[\"disposition-notification\"],\"message/global\":[\"u8msg\"],\"message/global-delivery-status\":[\"u8dsn\"],\"message/global-disposition-notification\":[\"u8mdn\"],\"message/global-headers\":[\"u8hdr\"],\"message/rfc822\":[\"eml\",\"mime\"],\"model/3mf\":[\"3mf\"],\"model/gltf+json\":[\"gltf\"],\"model/gltf-binary\":[\"glb\"],\"model/iges\":[\"igs\",\"iges\"],\"model/mesh\":[\"msh\",\"mesh\",\"silo\"],\"model/mtl\":[\"mtl\"],\"model/obj\":[\"obj\"],\"model/stl\":[\"stl\"],\"model/vrml\":[\"wrl\",\"vrml\"],\"model/x3d+binary\":[\"*x3db\",\"x3dbz\"],\"model/x3d+fastinfoset\":[\"x3db\"],\"model/x3d+vrml\":[\"*x3dv\",\"x3dvz\"],\"model/x3d+xml\":[\"x3d\",\"x3dz\"],\"model/x3d-vrml\":[\"x3dv\"],\"text/cache-manifest\":[\"appcache\",\"manifest\"],\"text/calendar\":[\"ics\",\"ifb\"],\"text/coffeescript\":[\"coffee\",\"litcoffee\"],\"text/css\":[\"css\"],\"text/csv\":[\"csv\"],\"text/html\":[\"html\",\"htm\",\"shtml\"],\"text/jade\":[\"jade\"],\"text/jsx\":[\"jsx\"],\"text/less\":[\"less\"],\"text/markdown\":[\"markdown\",\"md\"],\"text/mathml\":[\"mml\"],\"text/mdx\":[\"mdx\"],\"text/n3\":[\"n3\"],\"text/plain\":[\"txt\",\"text\",\"conf\",\"def\",\"list\",\"log\",\"in\",\"ini\"],\"text/richtext\":[\"rtx\"],\"text/rtf\":[\"*rtf\"],\"text/sgml\":[\"sgml\",\"sgm\"],\"text/shex\":[\"shex\"],\"text/slim\":[\"slim\",\"slm\"],\"text/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/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\"]};","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\":[\"keynote\"],\"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.dece.data\":[\"uvf\",\"uvvf\",\"uvd\",\"uvvd\"],\"application/vnd.dece.ttml+xml\":[\"uvt\",\"uvvt\"],\"application/vnd.dece.unspecified\":[\"uvx\",\"uvvx\"],\"application/vnd.dece.zip\":[\"uvz\",\"uvvz\"],\"application/vnd.denovo.fcselayout-link\":[\"fe_launch\"],\"application/vnd.dna\":[\"dna\"],\"application/vnd.dolby.mlp\":[\"mlp\"],\"application/vnd.dpgraph\":[\"dpg\"],\"application/vnd.dreamfactory\":[\"dfac\"],\"application/vnd.ds-keypoint\":[\"kpxx\"],\"application/vnd.dvb.ait\":[\"ait\"],\"application/vnd.dvb.service\":[\"svc\"],\"application/vnd.dynageo\":[\"geo\"],\"application/vnd.ecowin.chart\":[\"mag\"],\"application/vnd.enliven\":[\"nml\"],\"application/vnd.epson.esf\":[\"esf\"],\"application/vnd.epson.msf\":[\"msf\"],\"application/vnd.epson.quickanime\":[\"qam\"],\"application/vnd.epson.salt\":[\"slt\"],\"application/vnd.epson.ssf\":[\"ssf\"],\"application/vnd.eszigno3+xml\":[\"es3\",\"et3\"],\"application/vnd.ezpix-album\":[\"ez2\"],\"application/vnd.ezpix-package\":[\"ez3\"],\"application/vnd.fdf\":[\"fdf\"],\"application/vnd.fdsn.mseed\":[\"mseed\"],\"application/vnd.fdsn.seed\":[\"seed\",\"dataless\"],\"application/vnd.flographit\":[\"gph\"],\"application/vnd.fluxtime.clip\":[\"ftc\"],\"application/vnd.framemaker\":[\"fm\",\"frame\",\"maker\",\"book\"],\"application/vnd.frogans.fnc\":[\"fnc\"],\"application/vnd.frogans.ltf\":[\"ltf\"],\"application/vnd.fsc.weblaunch\":[\"fsc\"],\"application/vnd.fujitsu.oasys\":[\"oas\"],\"application/vnd.fujitsu.oasys2\":[\"oa2\"],\"application/vnd.fujitsu.oasys3\":[\"oa3\"],\"application/vnd.fujitsu.oasysgp\":[\"fg5\"],\"application/vnd.fujitsu.oasysprs\":[\"bh2\"],\"application/vnd.fujixerox.ddd\":[\"ddd\"],\"application/vnd.fujixerox.docuworks\":[\"xdw\"],\"application/vnd.fujixerox.docuworks.binder\":[\"xbd\"],\"application/vnd.fuzzysheet\":[\"fzs\"],\"application/vnd.genomatix.tuxedo\":[\"txd\"],\"application/vnd.geogebra.file\":[\"ggb\"],\"application/vnd.geogebra.tool\":[\"ggt\"],\"application/vnd.geometry-explorer\":[\"gex\",\"gre\"],\"application/vnd.geonext\":[\"gxt\"],\"application/vnd.geoplan\":[\"g2w\"],\"application/vnd.geospace\":[\"g3w\"],\"application/vnd.gmx\":[\"gmx\"],\"application/vnd.google-apps.document\":[\"gdoc\"],\"application/vnd.google-apps.presentation\":[\"gslides\"],\"application/vnd.google-apps.spreadsheet\":[\"gsheet\"],\"application/vnd.google-earth.kml+xml\":[\"kml\"],\"application/vnd.google-earth.kmz\":[\"kmz\"],\"application/vnd.grafeq\":[\"gqf\",\"gqs\"],\"application/vnd.groove-account\":[\"gac\"],\"application/vnd.groove-help\":[\"ghf\"],\"application/vnd.groove-identity-message\":[\"gim\"],\"application/vnd.groove-injector\":[\"grv\"],\"application/vnd.groove-tool-message\":[\"gtm\"],\"application/vnd.groove-tool-template\":[\"tpl\"],\"application/vnd.groove-vcard\":[\"vcg\"],\"application/vnd.hal+xml\":[\"hal\"],\"application/vnd.handheld-entertainment+xml\":[\"zmm\"],\"application/vnd.hbci\":[\"hbci\"],\"application/vnd.hhe.lesson-player\":[\"les\"],\"application/vnd.hp-hpgl\":[\"hpgl\"],\"application/vnd.hp-hpid\":[\"hpid\"],\"application/vnd.hp-hps\":[\"hps\"],\"application/vnd.hp-jlyt\":[\"jlt\"],\"application/vnd.hp-pcl\":[\"pcl\"],\"application/vnd.hp-pclxl\":[\"pclxl\"],\"application/vnd.hydrostatix.sof-data\":[\"sfd-hdstx\"],\"application/vnd.ibm.minipay\":[\"mpy\"],\"application/vnd.ibm.modcap\":[\"afp\",\"listafp\",\"list3820\"],\"application/vnd.ibm.rights-management\":[\"irm\"],\"application/vnd.ibm.secure-container\":[\"sc\"],\"application/vnd.iccprofile\":[\"icc\",\"icm\"],\"application/vnd.igloader\":[\"igl\"],\"application/vnd.immervision-ivp\":[\"ivp\"],\"application/vnd.immervision-ivu\":[\"ivu\"],\"application/vnd.insors.igm\":[\"igm\"],\"application/vnd.intercon.formnet\":[\"xpw\",\"xpx\"],\"application/vnd.intergeo\":[\"i2g\"],\"application/vnd.intu.qbo\":[\"qbo\"],\"application/vnd.intu.qfx\":[\"qfx\"],\"application/vnd.ipunplugged.rcprofile\":[\"rcprofile\"],\"application/vnd.irepository.package+xml\":[\"irp\"],\"application/vnd.is-xpr\":[\"xpr\"],\"application/vnd.isac.fcs\":[\"fcs\"],\"application/vnd.jam\":[\"jam\"],\"application/vnd.jcp.javame.midlet-rms\":[\"rms\"],\"application/vnd.jisp\":[\"jisp\"],\"application/vnd.joost.joda-archive\":[\"joda\"],\"application/vnd.kahootz\":[\"ktz\",\"ktr\"],\"application/vnd.kde.karbon\":[\"karbon\"],\"application/vnd.kde.kchart\":[\"chrt\"],\"application/vnd.kde.kformula\":[\"kfo\"],\"application/vnd.kde.kivio\":[\"flw\"],\"application/vnd.kde.kontour\":[\"kon\"],\"application/vnd.kde.kpresenter\":[\"kpr\",\"kpt\"],\"application/vnd.kde.kspread\":[\"ksp\"],\"application/vnd.kde.kword\":[\"kwd\",\"kwt\"],\"application/vnd.kenameaapp\":[\"htke\"],\"application/vnd.kidspiration\":[\"kia\"],\"application/vnd.kinar\":[\"kne\",\"knp\"],\"application/vnd.koan\":[\"skp\",\"skd\",\"skt\",\"skm\"],\"application/vnd.kodak-descriptor\":[\"sse\"],\"application/vnd.las.las+xml\":[\"lasxml\"],\"application/vnd.llamagraphics.life-balance.desktop\":[\"lbd\"],\"application/vnd.llamagraphics.life-balance.exchange+xml\":[\"lbe\"],\"application/vnd.lotus-1-2-3\":[\"123\"],\"application/vnd.lotus-approach\":[\"apr\"],\"application/vnd.lotus-freelance\":[\"pre\"],\"application/vnd.lotus-notes\":[\"nsf\"],\"application/vnd.lotus-organizer\":[\"org\"],\"application/vnd.lotus-screencam\":[\"scm\"],\"application/vnd.lotus-wordpro\":[\"lwp\"],\"application/vnd.macports.portpkg\":[\"portpkg\"],\"application/vnd.mcd\":[\"mcd\"],\"application/vnd.medcalcdata\":[\"mc1\"],\"application/vnd.mediastation.cdkey\":[\"cdkey\"],\"application/vnd.mfer\":[\"mwf\"],\"application/vnd.mfmp\":[\"mfm\"],\"application/vnd.micrografx.flo\":[\"flo\"],\"application/vnd.micrografx.igx\":[\"igx\"],\"application/vnd.mif\":[\"mif\"],\"application/vnd.mobius.daf\":[\"daf\"],\"application/vnd.mobius.dis\":[\"dis\"],\"application/vnd.mobius.mbk\":[\"mbk\"],\"application/vnd.mobius.mqy\":[\"mqy\"],\"application/vnd.mobius.msl\":[\"msl\"],\"application/vnd.mobius.plc\":[\"plc\"],\"application/vnd.mobius.txf\":[\"txf\"],\"application/vnd.mophun.application\":[\"mpn\"],\"application/vnd.mophun.certificate\":[\"mpc\"],\"application/vnd.mozilla.xul+xml\":[\"xul\"],\"application/vnd.ms-artgalry\":[\"cil\"],\"application/vnd.ms-cab-compressed\":[\"cab\"],\"application/vnd.ms-excel\":[\"xls\",\"xlm\",\"xla\",\"xlc\",\"xlt\",\"xlw\"],\"application/vnd.ms-excel.addin.macroenabled.12\":[\"xlam\"],\"application/vnd.ms-excel.sheet.binary.macroenabled.12\":[\"xlsb\"],\"application/vnd.ms-excel.sheet.macroenabled.12\":[\"xlsm\"],\"application/vnd.ms-excel.template.macroenabled.12\":[\"xltm\"],\"application/vnd.ms-fontobject\":[\"eot\"],\"application/vnd.ms-htmlhelp\":[\"chm\"],\"application/vnd.ms-ims\":[\"ims\"],\"application/vnd.ms-lrm\":[\"lrm\"],\"application/vnd.ms-officetheme\":[\"thmx\"],\"application/vnd.ms-outlook\":[\"msg\"],\"application/vnd.ms-pki.seccat\":[\"cat\"],\"application/vnd.ms-pki.stl\":[\"*stl\"],\"application/vnd.ms-powerpoint\":[\"ppt\",\"pps\",\"pot\"],\"application/vnd.ms-powerpoint.addin.macroenabled.12\":[\"ppam\"],\"application/vnd.ms-powerpoint.presentation.macroenabled.12\":[\"pptm\"],\"application/vnd.ms-powerpoint.slide.macroenabled.12\":[\"sldm\"],\"application/vnd.ms-powerpoint.slideshow.macroenabled.12\":[\"ppsm\"],\"application/vnd.ms-powerpoint.template.macroenabled.12\":[\"potm\"],\"application/vnd.ms-project\":[\"mpp\",\"mpt\"],\"application/vnd.ms-word.document.macroenabled.12\":[\"docm\"],\"application/vnd.ms-word.template.macroenabled.12\":[\"dotm\"],\"application/vnd.ms-works\":[\"wps\",\"wks\",\"wcm\",\"wdb\"],\"application/vnd.ms-wpl\":[\"wpl\"],\"application/vnd.ms-xpsdocument\":[\"xps\"],\"application/vnd.mseq\":[\"mseq\"],\"application/vnd.musician\":[\"mus\"],\"application/vnd.muvee.style\":[\"msty\"],\"application/vnd.mynfc\":[\"taglet\"],\"application/vnd.neurolanguage.nlu\":[\"nlu\"],\"application/vnd.nitf\":[\"ntf\",\"nitf\"],\"application/vnd.noblenet-directory\":[\"nnd\"],\"application/vnd.noblenet-sealer\":[\"nns\"],\"application/vnd.noblenet-web\":[\"nnw\"],\"application/vnd.nokia.n-gage.ac+xml\":[\"*ac\"],\"application/vnd.nokia.n-gage.data\":[\"ngdat\"],\"application/vnd.nokia.n-gage.symbian.install\":[\"n-gage\"],\"application/vnd.nokia.radio-preset\":[\"rpst\"],\"application/vnd.nokia.radio-presets\":[\"rpss\"],\"application/vnd.novadigm.edm\":[\"edm\"],\"application/vnd.novadigm.edx\":[\"edx\"],\"application/vnd.novadigm.ext\":[\"ext\"],\"application/vnd.oasis.opendocument.chart\":[\"odc\"],\"application/vnd.oasis.opendocument.chart-template\":[\"otc\"],\"application/vnd.oasis.opendocument.database\":[\"odb\"],\"application/vnd.oasis.opendocument.formula\":[\"odf\"],\"application/vnd.oasis.opendocument.formula-template\":[\"odft\"],\"application/vnd.oasis.opendocument.graphics\":[\"odg\"],\"application/vnd.oasis.opendocument.graphics-template\":[\"otg\"],\"application/vnd.oasis.opendocument.image\":[\"odi\"],\"application/vnd.oasis.opendocument.image-template\":[\"oti\"],\"application/vnd.oasis.opendocument.presentation\":[\"odp\"],\"application/vnd.oasis.opendocument.presentation-template\":[\"otp\"],\"application/vnd.oasis.opendocument.spreadsheet\":[\"ods\"],\"application/vnd.oasis.opendocument.spreadsheet-template\":[\"ots\"],\"application/vnd.oasis.opendocument.text\":[\"odt\"],\"application/vnd.oasis.opendocument.text-master\":[\"odm\"],\"application/vnd.oasis.opendocument.text-template\":[\"ott\"],\"application/vnd.oasis.opendocument.text-web\":[\"oth\"],\"application/vnd.olpc-sugar\":[\"xo\"],\"application/vnd.oma.dd2+xml\":[\"dd2\"],\"application/vnd.openblox.game+xml\":[\"obgx\"],\"application/vnd.openofficeorg.extension\":[\"oxt\"],\"application/vnd.openstreetmap.data+xml\":[\"osm\"],\"application/vnd.openxmlformats-officedocument.presentationml.presentation\":[\"pptx\"],\"application/vnd.openxmlformats-officedocument.presentationml.slide\":[\"sldx\"],\"application/vnd.openxmlformats-officedocument.presentationml.slideshow\":[\"ppsx\"],\"application/vnd.openxmlformats-officedocument.presentationml.template\":[\"potx\"],\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\":[\"xlsx\"],\"application/vnd.openxmlformats-officedocument.spreadsheetml.template\":[\"xltx\"],\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\":[\"docx\"],\"application/vnd.openxmlformats-officedocument.wordprocessingml.template\":[\"dotx\"],\"application/vnd.osgeo.mapguide.package\":[\"mgp\"],\"application/vnd.osgi.dp\":[\"dp\"],\"application/vnd.osgi.subsystem\":[\"esa\"],\"application/vnd.palm\":[\"pdb\",\"pqa\",\"oprc\"],\"application/vnd.pawaafile\":[\"paw\"],\"application/vnd.pg.format\":[\"str\"],\"application/vnd.pg.osasli\":[\"ei6\"],\"application/vnd.picsel\":[\"efif\"],\"application/vnd.pmi.widget\":[\"wg\"],\"application/vnd.pocketlearn\":[\"plf\"],\"application/vnd.powerbuilder6\":[\"pbd\"],\"application/vnd.previewsystems.box\":[\"box\"],\"application/vnd.proteus.magazine\":[\"mgz\"],\"application/vnd.publishare-delta-tree\":[\"qps\"],\"application/vnd.pvi.ptid1\":[\"ptid\"],\"application/vnd.quark.quarkxpress\":[\"qxd\",\"qxt\",\"qwd\",\"qwt\",\"qxl\",\"qxb\"],\"application/vnd.realvnc.bed\":[\"bed\"],\"application/vnd.recordare.musicxml\":[\"mxl\"],\"application/vnd.recordare.musicxml+xml\":[\"musicxml\"],\"application/vnd.rig.cryptonote\":[\"cryptonote\"],\"application/vnd.rim.cod\":[\"cod\"],\"application/vnd.rn-realmedia\":[\"rm\"],\"application/vnd.rn-realmedia-vbr\":[\"rmvb\"],\"application/vnd.route66.link66+xml\":[\"link66\"],\"application/vnd.sailingtracker.track\":[\"st\"],\"application/vnd.seemail\":[\"see\"],\"application/vnd.sema\":[\"sema\"],\"application/vnd.semd\":[\"semd\"],\"application/vnd.semf\":[\"semf\"],\"application/vnd.shana.informed.formdata\":[\"ifm\"],\"application/vnd.shana.informed.formtemplate\":[\"itp\"],\"application/vnd.shana.informed.interchange\":[\"iif\"],\"application/vnd.shana.informed.package\":[\"ipk\"],\"application/vnd.simtech-mindmapper\":[\"twd\",\"twds\"],\"application/vnd.smaf\":[\"mmf\"],\"application/vnd.smart.teacher\":[\"teacher\"],\"application/vnd.software602.filler.form+xml\":[\"fo\"],\"application/vnd.solent.sdkm+xml\":[\"sdkm\",\"sdkd\"],\"application/vnd.spotfire.dxp\":[\"dxp\"],\"application/vnd.spotfire.sfs\":[\"sfs\"],\"application/vnd.stardivision.calc\":[\"sdc\"],\"application/vnd.stardivision.draw\":[\"sda\"],\"application/vnd.stardivision.impress\":[\"sdd\"],\"application/vnd.stardivision.math\":[\"smf\"],\"application/vnd.stardivision.writer\":[\"sdw\",\"vor\"],\"application/vnd.stardivision.writer-global\":[\"sgl\"],\"application/vnd.stepmania.package\":[\"smzip\"],\"application/vnd.stepmania.stepchart\":[\"sm\"],\"application/vnd.sun.wadl+xml\":[\"wadl\"],\"application/vnd.sun.xml.calc\":[\"sxc\"],\"application/vnd.sun.xml.calc.template\":[\"stc\"],\"application/vnd.sun.xml.draw\":[\"sxd\"],\"application/vnd.sun.xml.draw.template\":[\"std\"],\"application/vnd.sun.xml.impress\":[\"sxi\"],\"application/vnd.sun.xml.impress.template\":[\"sti\"],\"application/vnd.sun.xml.math\":[\"sxm\"],\"application/vnd.sun.xml.writer\":[\"sxw\"],\"application/vnd.sun.xml.writer.global\":[\"sxg\"],\"application/vnd.sun.xml.writer.template\":[\"stw\"],\"application/vnd.sus-calendar\":[\"sus\",\"susp\"],\"application/vnd.svd\":[\"svd\"],\"application/vnd.symbian.install\":[\"sis\",\"sisx\"],\"application/vnd.syncml+xml\":[\"xsm\"],\"application/vnd.syncml.dm+wbxml\":[\"bdm\"],\"application/vnd.syncml.dm+xml\":[\"xdm\"],\"application/vnd.syncml.dmddf+xml\":[\"ddf\"],\"application/vnd.tao.intent-module-archive\":[\"tao\"],\"application/vnd.tcpdump.pcap\":[\"pcap\",\"cap\",\"dmp\"],\"application/vnd.tmobile-livetv\":[\"tmo\"],\"application/vnd.trid.tpt\":[\"tpt\"],\"application/vnd.triscape.mxs\":[\"mxs\"],\"application/vnd.trueapp\":[\"tra\"],\"application/vnd.ufdl\":[\"ufd\",\"ufdl\"],\"application/vnd.uiq.theme\":[\"utz\"],\"application/vnd.umajin\":[\"umj\"],\"application/vnd.unity\":[\"unityweb\"],\"application/vnd.uoml+xml\":[\"uoml\"],\"application/vnd.vcx\":[\"vcx\"],\"application/vnd.visio\":[\"vsd\",\"vst\",\"vss\",\"vsw\"],\"application/vnd.visionary\":[\"vis\"],\"application/vnd.vsf\":[\"vsf\"],\"application/vnd.wap.wbxml\":[\"wbxml\"],\"application/vnd.wap.wmlc\":[\"wmlc\"],\"application/vnd.wap.wmlscriptc\":[\"wmlsc\"],\"application/vnd.webturbo\":[\"wtb\"],\"application/vnd.wolfram.player\":[\"nbp\"],\"application/vnd.wordperfect\":[\"wpd\"],\"application/vnd.wqd\":[\"wqd\"],\"application/vnd.wt.stf\":[\"stf\"],\"application/vnd.xara\":[\"xar\"],\"application/vnd.xfdl\":[\"xfdl\"],\"application/vnd.yamaha.hv-dic\":[\"hvd\"],\"application/vnd.yamaha.hv-script\":[\"hvs\"],\"application/vnd.yamaha.hv-voice\":[\"hvp\"],\"application/vnd.yamaha.openscoreformat\":[\"osf\"],\"application/vnd.yamaha.openscoreformat.osfpvg+xml\":[\"osfpvg\"],\"application/vnd.yamaha.smaf-audio\":[\"saf\"],\"application/vnd.yamaha.smaf-phrase\":[\"spf\"],\"application/vnd.yellowriver-custom-menu\":[\"cmp\"],\"application/vnd.zul\":[\"zir\",\"zirz\"],\"application/vnd.zzazz.deck+xml\":[\"zaz\"],\"application/x-7z-compressed\":[\"7z\"],\"application/x-abiword\":[\"abw\"],\"application/x-ace-compressed\":[\"ace\"],\"application/x-apple-diskimage\":[\"*dmg\"],\"application/x-arj\":[\"arj\"],\"application/x-authorware-bin\":[\"aab\",\"x32\",\"u32\",\"vox\"],\"application/x-authorware-map\":[\"aam\"],\"application/x-authorware-seg\":[\"aas\"],\"application/x-bcpio\":[\"bcpio\"],\"application/x-bdoc\":[\"*bdoc\"],\"application/x-bittorrent\":[\"torrent\"],\"application/x-blorb\":[\"blb\",\"blorb\"],\"application/x-bzip\":[\"bz\"],\"application/x-bzip2\":[\"bz2\",\"boz\"],\"application/x-cbr\":[\"cbr\",\"cba\",\"cbt\",\"cbz\",\"cb7\"],\"application/x-cdlink\":[\"vcd\"],\"application/x-cfs-compressed\":[\"cfs\"],\"application/x-chat\":[\"chat\"],\"application/x-chess-pgn\":[\"pgn\"],\"application/x-chrome-extension\":[\"crx\"],\"application/x-cocoa\":[\"cco\"],\"application/x-conference\":[\"nsc\"],\"application/x-cpio\":[\"cpio\"],\"application/x-csh\":[\"csh\"],\"application/x-debian-package\":[\"*deb\",\"udeb\"],\"application/x-dgc-compressed\":[\"dgc\"],\"application/x-director\":[\"dir\",\"dcr\",\"dxr\",\"cst\",\"cct\",\"cxt\",\"w3d\",\"fgd\",\"swa\"],\"application/x-doom\":[\"wad\"],\"application/x-dtbncx+xml\":[\"ncx\"],\"application/x-dtbook+xml\":[\"dtb\"],\"application/x-dtbresource+xml\":[\"res\"],\"application/x-dvi\":[\"dvi\"],\"application/x-envoy\":[\"evy\"],\"application/x-eva\":[\"eva\"],\"application/x-font-bdf\":[\"bdf\"],\"application/x-font-ghostscript\":[\"gsf\"],\"application/x-font-linux-psf\":[\"psf\"],\"application/x-font-pcf\":[\"pcf\"],\"application/x-font-snf\":[\"snf\"],\"application/x-font-type1\":[\"pfa\",\"pfb\",\"pfm\",\"afm\"],\"application/x-freearc\":[\"arc\"],\"application/x-futuresplash\":[\"spl\"],\"application/x-gca-compressed\":[\"gca\"],\"application/x-glulx\":[\"ulx\"],\"application/x-gnumeric\":[\"gnumeric\"],\"application/x-gramps-xml\":[\"gramps\"],\"application/x-gtar\":[\"gtar\"],\"application/x-hdf\":[\"hdf\"],\"application/x-httpd-php\":[\"php\"],\"application/x-install-instructions\":[\"install\"],\"application/x-iso9660-image\":[\"*iso\"],\"application/x-java-archive-diff\":[\"jardiff\"],\"application/x-java-jnlp-file\":[\"jnlp\"],\"application/x-keepass2\":[\"kdbx\"],\"application/x-latex\":[\"latex\"],\"application/x-lua-bytecode\":[\"luac\"],\"application/x-lzh-compressed\":[\"lzh\",\"lha\"],\"application/x-makeself\":[\"run\"],\"application/x-mie\":[\"mie\"],\"application/x-mobipocket-ebook\":[\"prc\",\"mobi\"],\"application/x-ms-application\":[\"application\"],\"application/x-ms-shortcut\":[\"lnk\"],\"application/x-ms-wmd\":[\"wmd\"],\"application/x-ms-wmz\":[\"wmz\"],\"application/x-ms-xbap\":[\"xbap\"],\"application/x-msaccess\":[\"mdb\"],\"application/x-msbinder\":[\"obd\"],\"application/x-mscardfile\":[\"crd\"],\"application/x-msclip\":[\"clp\"],\"application/x-msdos-program\":[\"*exe\"],\"application/x-msdownload\":[\"*exe\",\"*dll\",\"com\",\"bat\",\"*msi\"],\"application/x-msmediaview\":[\"mvb\",\"m13\",\"m14\"],\"application/x-msmetafile\":[\"*wmf\",\"*wmz\",\"*emf\",\"emz\"],\"application/x-msmoney\":[\"mny\"],\"application/x-mspublisher\":[\"pub\"],\"application/x-msschedule\":[\"scd\"],\"application/x-msterminal\":[\"trm\"],\"application/x-mswrite\":[\"wri\"],\"application/x-netcdf\":[\"nc\",\"cdf\"],\"application/x-ns-proxy-autoconfig\":[\"pac\"],\"application/x-nzb\":[\"nzb\"],\"application/x-perl\":[\"pl\",\"pm\"],\"application/x-pilot\":[\"*prc\",\"*pdb\"],\"application/x-pkcs12\":[\"p12\",\"pfx\"],\"application/x-pkcs7-certificates\":[\"p7b\",\"spc\"],\"application/x-pkcs7-certreqresp\":[\"p7r\"],\"application/x-rar-compressed\":[\"rar\"],\"application/x-redhat-package-manager\":[\"rpm\"],\"application/x-research-info-systems\":[\"ris\"],\"application/x-sea\":[\"sea\"],\"application/x-sh\":[\"sh\"],\"application/x-shar\":[\"shar\"],\"application/x-shockwave-flash\":[\"swf\"],\"application/x-silverlight-app\":[\"xap\"],\"application/x-sql\":[\"sql\"],\"application/x-stuffit\":[\"sit\"],\"application/x-stuffitx\":[\"sitx\"],\"application/x-subrip\":[\"srt\"],\"application/x-sv4cpio\":[\"sv4cpio\"],\"application/x-sv4crc\":[\"sv4crc\"],\"application/x-t3vm-image\":[\"t3\"],\"application/x-tads\":[\"gam\"],\"application/x-tar\":[\"tar\"],\"application/x-tcl\":[\"tcl\",\"tk\"],\"application/x-tex\":[\"tex\"],\"application/x-tex-tfm\":[\"tfm\"],\"application/x-texinfo\":[\"texinfo\",\"texi\"],\"application/x-tgif\":[\"*obj\"],\"application/x-ustar\":[\"ustar\"],\"application/x-virtualbox-hdd\":[\"hdd\"],\"application/x-virtualbox-ova\":[\"ova\"],\"application/x-virtualbox-ovf\":[\"ovf\"],\"application/x-virtualbox-vbox\":[\"vbox\"],\"application/x-virtualbox-vbox-extpack\":[\"vbox-extpack\"],\"application/x-virtualbox-vdi\":[\"vdi\"],\"application/x-virtualbox-vhd\":[\"vhd\"],\"application/x-virtualbox-vmdk\":[\"vmdk\"],\"application/x-wais-source\":[\"src\"],\"application/x-web-app-manifest+json\":[\"webapp\"],\"application/x-x509-ca-cert\":[\"der\",\"crt\",\"pem\"],\"application/x-xfig\":[\"fig\"],\"application/x-xliff+xml\":[\"*xlf\"],\"application/x-xpinstall\":[\"xpi\"],\"application/x-xz\":[\"xz\"],\"application/x-zmachine\":[\"z1\",\"z2\",\"z3\",\"z4\",\"z5\",\"z6\",\"z7\",\"z8\"],\"audio/vnd.dece.audio\":[\"uva\",\"uvva\"],\"audio/vnd.digital-winds\":[\"eol\"],\"audio/vnd.dra\":[\"dra\"],\"audio/vnd.dts\":[\"dts\"],\"audio/vnd.dts.hd\":[\"dtshd\"],\"audio/vnd.lucent.voice\":[\"lvp\"],\"audio/vnd.ms-playready.media.pya\":[\"pya\"],\"audio/vnd.nuera.ecelp4800\":[\"ecelp4800\"],\"audio/vnd.nuera.ecelp7470\":[\"ecelp7470\"],\"audio/vnd.nuera.ecelp9600\":[\"ecelp9600\"],\"audio/vnd.rip\":[\"rip\"],\"audio/x-aac\":[\"aac\"],\"audio/x-aiff\":[\"aif\",\"aiff\",\"aifc\"],\"audio/x-caf\":[\"caf\"],\"audio/x-flac\":[\"flac\"],\"audio/x-m4a\":[\"*m4a\"],\"audio/x-matroska\":[\"mka\"],\"audio/x-mpegurl\":[\"m3u\"],\"audio/x-ms-wax\":[\"wax\"],\"audio/x-ms-wma\":[\"wma\"],\"audio/x-pn-realaudio\":[\"ram\",\"ra\"],\"audio/x-pn-realaudio-plugin\":[\"rmp\"],\"audio/x-realaudio\":[\"*ra\"],\"audio/x-wav\":[\"*wav\"],\"chemical/x-cdx\":[\"cdx\"],\"chemical/x-cif\":[\"cif\"],\"chemical/x-cmdf\":[\"cmdf\"],\"chemical/x-cml\":[\"cml\"],\"chemical/x-csml\":[\"csml\"],\"chemical/x-xyz\":[\"xyz\"],\"image/prs.btif\":[\"btif\"],\"image/prs.pti\":[\"pti\"],\"image/vnd.adobe.photoshop\":[\"psd\"],\"image/vnd.airzip.accelerator.azv\":[\"azv\"],\"image/vnd.dece.graphic\":[\"uvi\",\"uvvi\",\"uvg\",\"uvvg\"],\"image/vnd.djvu\":[\"djvu\",\"djv\"],\"image/vnd.dvb.subtitle\":[\"*sub\"],\"image/vnd.dwg\":[\"dwg\"],\"image/vnd.dxf\":[\"dxf\"],\"image/vnd.fastbidsheet\":[\"fbs\"],\"image/vnd.fpx\":[\"fpx\"],\"image/vnd.fst\":[\"fst\"],\"image/vnd.fujixerox.edmics-mmr\":[\"mmr\"],\"image/vnd.fujixerox.edmics-rlc\":[\"rlc\"],\"image/vnd.microsoft.icon\":[\"ico\"],\"image/vnd.ms-dds\":[\"dds\"],\"image/vnd.ms-modi\":[\"mdi\"],\"image/vnd.ms-photo\":[\"wdp\"],\"image/vnd.net-fpx\":[\"npx\"],\"image/vnd.tencent.tap\":[\"tap\"],\"image/vnd.valve.source.texture\":[\"vtf\"],\"image/vnd.wap.wbmp\":[\"wbmp\"],\"image/vnd.xiff\":[\"xif\"],\"image/vnd.zbrush.pcx\":[\"pcx\"],\"image/x-3ds\":[\"3ds\"],\"image/x-cmu-raster\":[\"ras\"],\"image/x-cmx\":[\"cmx\"],\"image/x-freehand\":[\"fh\",\"fhc\",\"fh4\",\"fh5\",\"fh7\"],\"image/x-icon\":[\"*ico\"],\"image/x-jng\":[\"jng\"],\"image/x-mrsid-image\":[\"sid\"],\"image/x-ms-bmp\":[\"*bmp\"],\"image/x-pcx\":[\"*pcx\"],\"image/x-pict\":[\"pic\",\"pct\"],\"image/x-portable-anymap\":[\"pnm\"],\"image/x-portable-bitmap\":[\"pbm\"],\"image/x-portable-graymap\":[\"pgm\"],\"image/x-portable-pixmap\":[\"ppm\"],\"image/x-rgb\":[\"rgb\"],\"image/x-tga\":[\"tga\"],\"image/x-xbitmap\":[\"xbm\"],\"image/x-xpixmap\":[\"xpm\"],\"image/x-xwindowdump\":[\"xwd\"],\"message/vnd.wfa.wsc\":[\"wsc\"],\"model/vnd.collada+xml\":[\"dae\"],\"model/vnd.dwf\":[\"dwf\"],\"model/vnd.gdl\":[\"gdl\"],\"model/vnd.gtw\":[\"gtw\"],\"model/vnd.mts\":[\"mts\"],\"model/vnd.opengex\":[\"ogex\"],\"model/vnd.parasolid.transmit.binary\":[\"x_b\"],\"model/vnd.parasolid.transmit.text\":[\"x_t\"],\"model/vnd.usdz+zip\":[\"usdz\"],\"model/vnd.valve.source.compiled-map\":[\"bsp\"],\"model/vnd.vtu\":[\"vtu\"],\"text/prs.lines.tag\":[\"dsc\"],\"text/vnd.curl\":[\"curl\"],\"text/vnd.curl.dcurl\":[\"dcurl\"],\"text/vnd.curl.mcurl\":[\"mcurl\"],\"text/vnd.curl.scurl\":[\"scurl\"],\"text/vnd.dvb.subtitle\":[\"sub\"],\"text/vnd.fly\":[\"fly\"],\"text/vnd.fmi.flexstor\":[\"flx\"],\"text/vnd.graphviz\":[\"gv\"],\"text/vnd.in3d.3dml\":[\"3dml\"],\"text/vnd.in3d.spot\":[\"spot\"],\"text/vnd.sun.j2me.app-descriptor\":[\"jad\"],\"text/vnd.wap.wml\":[\"wml\"],\"text/vnd.wap.wmlscript\":[\"wmls\"],\"text/x-asm\":[\"s\",\"asm\"],\"text/x-c\":[\"c\",\"cc\",\"cxx\",\"cpp\",\"h\",\"hh\",\"dic\"],\"text/x-component\":[\"htc\"],\"text/x-fortran\":[\"f\",\"for\",\"f77\",\"f90\"],\"text/x-handlebars-template\":[\"hbs\"],\"text/x-java-source\":[\"java\"],\"text/x-lua\":[\"lua\"],\"text/x-markdown\":[\"mkd\"],\"text/x-nfo\":[\"nfo\"],\"text/x-opml\":[\"opml\"],\"text/x-org\":[\"*org\"],\"text/x-pascal\":[\"p\",\"pas\"],\"text/x-processing\":[\"pde\"],\"text/x-sass\":[\"sass\"],\"text/x-scss\":[\"scss\"],\"text/x-setext\":[\"etx\"],\"text/x-sfv\":[\"sfv\"],\"text/x-suse-ymp\":[\"ymp\"],\"text/x-uuencode\":[\"uu\"],\"text/x-vcalendar\":[\"vcs\"],\"text/x-vcard\":[\"vcf\"],\"video/vnd.dece.hd\":[\"uvh\",\"uvvh\"],\"video/vnd.dece.mobile\":[\"uvm\",\"uvvm\"],\"video/vnd.dece.pd\":[\"uvp\",\"uvvp\"],\"video/vnd.dece.sd\":[\"uvs\",\"uvvs\"],\"video/vnd.dece.video\":[\"uvv\",\"uvvv\"],\"video/vnd.dvb.file\":[\"dvb\"],\"video/vnd.fvt\":[\"fvt\"],\"video/vnd.mpegurl\":[\"mxu\",\"m4u\"],\"video/vnd.ms-playready.media.pyv\":[\"pyv\"],\"video/vnd.uvvu.mp4\":[\"uvu\",\"uvvu\"],\"video/vnd.vivo\":[\"viv\"],\"video/x-f4v\":[\"f4v\"],\"video/x-fli\":[\"fli\"],\"video/x-flv\":[\"flv\"],\"video/x-m4v\":[\"m4v\"],\"video/x-matroska\":[\"mkv\",\"mk3d\",\"mks\"],\"video/x-mng\":[\"mng\"],\"video/x-ms-asf\":[\"asf\",\"asx\"],\"video/x-ms-vob\":[\"vob\"],\"video/x-ms-wm\":[\"wm\"],\"video/x-ms-wmv\":[\"wmv\"],\"video/x-ms-wmx\":[\"wmx\"],\"video/x-ms-wvx\":[\"wvx\"],\"video/x-msvideo\":[\"avi\"],\"video/x-sgi-movie\":[\"movie\"],\"video/x-smv\":[\"smv\"],\"x-conference/x-cooltalk\":[\"ice\"]};","'use strict';\n\nvar Mime = require('./Mime');\nmodule.exports = new Mime(require('./types/standard'), require('./types/other'));\n","import Stream from 'stream';\nimport http from 'http';\nimport Url from 'url';\nimport https from 'https';\nimport zlib from 'zlib';\n\n// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js\n\n// fix for \"Readable\" isn't a named export issue\nconst Readable = Stream.Readable;\n\nconst BUFFER = Symbol('buffer');\nconst TYPE = Symbol('type');\n\nclass Blob {\n\tconstructor() {\n\t\tthis[TYPE] = '';\n\n\t\tconst blobParts = arguments[0];\n\t\tconst options = arguments[1];\n\n\t\tconst buffers = [];\n\t\tlet size = 0;\n\n\t\tif (blobParts) {\n\t\t\tconst a = blobParts;\n\t\t\tconst length = Number(a.length);\n\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\tconst element = a[i];\n\t\t\t\tlet buffer;\n\t\t\t\tif (element instanceof Buffer) {\n\t\t\t\t\tbuffer = element;\n\t\t\t\t} else if (ArrayBuffer.isView(element)) {\n\t\t\t\t\tbuffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength);\n\t\t\t\t} else if (element instanceof ArrayBuffer) {\n\t\t\t\t\tbuffer = Buffer.from(element);\n\t\t\t\t} else if (element instanceof Blob) {\n\t\t\t\t\tbuffer = element[BUFFER];\n\t\t\t\t} else {\n\t\t\t\t\tbuffer = Buffer.from(typeof element === 'string' ? element : String(element));\n\t\t\t\t}\n\t\t\t\tsize += buffer.length;\n\t\t\t\tbuffers.push(buffer);\n\t\t\t}\n\t\t}\n\n\t\tthis[BUFFER] = Buffer.concat(buffers);\n\n\t\tlet type = options && options.type !== undefined && String(options.type).toLowerCase();\n\t\tif (type && !/[^\\u0020-\\u007E]/.test(type)) {\n\t\t\tthis[TYPE] = type;\n\t\t}\n\t}\n\tget size() {\n\t\treturn this[BUFFER].length;\n\t}\n\tget type() {\n\t\treturn this[TYPE];\n\t}\n\ttext() {\n\t\treturn Promise.resolve(this[BUFFER].toString());\n\t}\n\tarrayBuffer() {\n\t\tconst buf = this[BUFFER];\n\t\tconst ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n\t\treturn Promise.resolve(ab);\n\t}\n\tstream() {\n\t\tconst readable = new Readable();\n\t\treadable._read = function () {};\n\t\treadable.push(this[BUFFER]);\n\t\treadable.push(null);\n\t\treturn readable;\n\t}\n\ttoString() {\n\t\treturn '[object Blob]';\n\t}\n\tslice() {\n\t\tconst size = this.size;\n\n\t\tconst start = arguments[0];\n\t\tconst end = arguments[1];\n\t\tlet relativeStart, relativeEnd;\n\t\tif (start === undefined) {\n\t\t\trelativeStart = 0;\n\t\t} else if (start < 0) {\n\t\t\trelativeStart = Math.max(size + start, 0);\n\t\t} else {\n\t\t\trelativeStart = Math.min(start, size);\n\t\t}\n\t\tif (end === undefined) {\n\t\t\trelativeEnd = size;\n\t\t} else if (end < 0) {\n\t\t\trelativeEnd = Math.max(size + end, 0);\n\t\t} else {\n\t\t\trelativeEnd = Math.min(end, size);\n\t\t}\n\t\tconst span = Math.max(relativeEnd - relativeStart, 0);\n\n\t\tconst buffer = this[BUFFER];\n\t\tconst slicedBuffer = buffer.slice(relativeStart, relativeStart + span);\n\t\tconst blob = new Blob([], { type: arguments[2] });\n\t\tblob[BUFFER] = slicedBuffer;\n\t\treturn blob;\n\t}\n}\n\nObject.defineProperties(Blob.prototype, {\n\tsize: { enumerable: true },\n\ttype: { enumerable: true },\n\tslice: { enumerable: true }\n});\n\nObject.defineProperty(Blob.prototype, Symbol.toStringTag, {\n\tvalue: 'Blob',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\n/**\n * fetch-error.js\n *\n * FetchError interface for operational errors\n */\n\n/**\n * Create FetchError instance\n *\n * @param String message Error message for human\n * @param String type Error type for machine\n * @param String systemError For Node.js system error\n * @return FetchError\n */\nfunction FetchError(message, type, systemError) {\n Error.call(this, message);\n\n this.message = message;\n this.type = type;\n\n // when err.type is `system`, err.code contains system error code\n if (systemError) {\n this.code = this.errno = systemError.code;\n }\n\n // hide custom error implementation details from end-users\n Error.captureStackTrace(this, this.constructor);\n}\n\nFetchError.prototype = Object.create(Error.prototype);\nFetchError.prototype.constructor = FetchError;\nFetchError.prototype.name = 'FetchError';\n\nlet convert;\ntry {\n\tconvert = require('encoding').convert;\n} catch (e) {}\n\nconst INTERNALS = Symbol('Body internals');\n\n// fix an issue where \"PassThrough\" isn't a named export for node <10\nconst PassThrough = Stream.PassThrough;\n\n/**\n * Body mixin\n *\n * Ref: https://fetch.spec.whatwg.org/#body\n *\n * @param Stream body Readable stream\n * @param Object opts Response options\n * @return Void\n */\nfunction Body(body) {\n\tvar _this = this;\n\n\tvar _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n\t _ref$size = _ref.size;\n\n\tlet size = _ref$size === undefined ? 0 : _ref$size;\n\tvar _ref$timeout = _ref.timeout;\n\tlet timeout = _ref$timeout === undefined ? 0 : _ref$timeout;\n\n\tif (body == null) {\n\t\t// body is undefined or null\n\t\tbody = null;\n\t} else if (isURLSearchParams(body)) {\n\t\t// body is a URLSearchParams\n\t\tbody = Buffer.from(body.toString());\n\t} else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {\n\t\t// body is ArrayBuffer\n\t\tbody = Buffer.from(body);\n\t} else if (ArrayBuffer.isView(body)) {\n\t\t// body is ArrayBufferView\n\t\tbody = Buffer.from(body.buffer, body.byteOffset, body.byteLength);\n\t} else if (body instanceof Stream) ; else {\n\t\t// none of the above\n\t\t// coerce to string then buffer\n\t\tbody = Buffer.from(String(body));\n\t}\n\tthis[INTERNALS] = {\n\t\tbody,\n\t\tdisturbed: false,\n\t\terror: null\n\t};\n\tthis.size = size;\n\tthis.timeout = timeout;\n\n\tif (body instanceof Stream) {\n\t\tbody.on('error', function (err) {\n\t\t\tconst error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err);\n\t\t\t_this[INTERNALS].error = error;\n\t\t});\n\t}\n}\n\nBody.prototype = {\n\tget body() {\n\t\treturn this[INTERNALS].body;\n\t},\n\n\tget bodyUsed() {\n\t\treturn this[INTERNALS].disturbed;\n\t},\n\n\t/**\n * Decode response as ArrayBuffer\n *\n * @return Promise\n */\n\tarrayBuffer() {\n\t\treturn consumeBody.call(this).then(function (buf) {\n\t\t\treturn buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n\t\t});\n\t},\n\n\t/**\n * Return raw response as Blob\n *\n * @return Promise\n */\n\tblob() {\n\t\tlet ct = this.headers && this.headers.get('content-type') || '';\n\t\treturn consumeBody.call(this).then(function (buf) {\n\t\t\treturn Object.assign(\n\t\t\t// Prevent copying\n\t\t\tnew Blob([], {\n\t\t\t\ttype: ct.toLowerCase()\n\t\t\t}), {\n\t\t\t\t[BUFFER]: buf\n\t\t\t});\n\t\t});\n\t},\n\n\t/**\n * Decode response as json\n *\n * @return Promise\n */\n\tjson() {\n\t\tvar _this2 = this;\n\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(buffer.toString());\n\t\t\t} catch (err) {\n\t\t\t\treturn Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));\n\t\t\t}\n\t\t});\n\t},\n\n\t/**\n * Decode response as text\n *\n * @return Promise\n */\n\ttext() {\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\treturn buffer.toString();\n\t\t});\n\t},\n\n\t/**\n * Decode response as buffer (non-spec api)\n *\n * @return Promise\n */\n\tbuffer() {\n\t\treturn consumeBody.call(this);\n\t},\n\n\t/**\n * Decode response as text, while automatically detecting the encoding and\n * trying to decode to UTF-8 (non-spec api)\n *\n * @return Promise\n */\n\ttextConverted() {\n\t\tvar _this3 = this;\n\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\treturn convertBody(buffer, _this3.headers);\n\t\t});\n\t}\n};\n\n// In browsers, all properties are enumerable.\nObject.defineProperties(Body.prototype, {\n\tbody: { enumerable: true },\n\tbodyUsed: { enumerable: true },\n\tarrayBuffer: { enumerable: true },\n\tblob: { enumerable: true },\n\tjson: { enumerable: true },\n\ttext: { enumerable: true }\n});\n\nBody.mixIn = function (proto) {\n\tfor (const name of Object.getOwnPropertyNames(Body.prototype)) {\n\t\t// istanbul ignore else: future proof\n\t\tif (!(name in proto)) {\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(Body.prototype, name);\n\t\t\tObject.defineProperty(proto, name, desc);\n\t\t}\n\t}\n};\n\n/**\n * Consume and convert an entire Body to a Buffer.\n *\n * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body\n *\n * @return Promise\n */\nfunction consumeBody() {\n\tvar _this4 = this;\n\n\tif (this[INTERNALS].disturbed) {\n\t\treturn Body.Promise.reject(new TypeError(`body used already for: ${this.url}`));\n\t}\n\n\tthis[INTERNALS].disturbed = true;\n\n\tif (this[INTERNALS].error) {\n\t\treturn Body.Promise.reject(this[INTERNALS].error);\n\t}\n\n\tlet body = this.body;\n\n\t// body is null\n\tif (body === null) {\n\t\treturn Body.Promise.resolve(Buffer.alloc(0));\n\t}\n\n\t// body is blob\n\tif (isBlob(body)) {\n\t\tbody = body.stream();\n\t}\n\n\t// body is buffer\n\tif (Buffer.isBuffer(body)) {\n\t\treturn Body.Promise.resolve(body);\n\t}\n\n\t// istanbul ignore if: should never happen\n\tif (!(body instanceof Stream)) {\n\t\treturn Body.Promise.resolve(Buffer.alloc(0));\n\t}\n\n\t// body is stream\n\t// get ready to actually consume the body\n\tlet accum = [];\n\tlet accumBytes = 0;\n\tlet abort = false;\n\n\treturn new Body.Promise(function (resolve, reject) {\n\t\tlet resTimeout;\n\n\t\t// allow timeout on slow response body\n\t\tif (_this4.timeout) {\n\t\t\tresTimeout = setTimeout(function () {\n\t\t\t\tabort = true;\n\t\t\t\treject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout'));\n\t\t\t}, _this4.timeout);\n\t\t}\n\n\t\t// handle stream errors\n\t\tbody.on('error', function (err) {\n\t\t\tif (err.name === 'AbortError') {\n\t\t\t\t// if the request was aborted, reject with this Error\n\t\t\t\tabort = true;\n\t\t\t\treject(err);\n\t\t\t} else {\n\t\t\t\t// other errors, such as incorrect content-encoding\n\t\t\t\treject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));\n\t\t\t}\n\t\t});\n\n\t\tbody.on('data', function (chunk) {\n\t\t\tif (abort || chunk === null) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (_this4.size && accumBytes + chunk.length > _this4.size) {\n\t\t\t\tabort = true;\n\t\t\t\treject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size'));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\taccumBytes += chunk.length;\n\t\t\taccum.push(chunk);\n\t\t});\n\n\t\tbody.on('end', function () {\n\t\t\tif (abort) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tclearTimeout(resTimeout);\n\n\t\t\ttry {\n\t\t\t\tresolve(Buffer.concat(accum, accumBytes));\n\t\t\t} catch (err) {\n\t\t\t\t// handle streams that have accumulated too much data (issue #414)\n\t\t\t\treject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err));\n\t\t\t}\n\t\t});\n\t});\n}\n\n/**\n * Detect buffer encoding and convert to target encoding\n * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding\n *\n * @param Buffer buffer Incoming buffer\n * @param String encoding Target encoding\n * @return String\n */\nfunction convertBody(buffer, headers) {\n\tif (typeof convert !== 'function') {\n\t\tthrow new Error('The package `encoding` must be installed to use the textConverted() function');\n\t}\n\n\tconst ct = headers.get('content-type');\n\tlet charset = 'utf-8';\n\tlet res, str;\n\n\t// header\n\tif (ct) {\n\t\tres = /charset=([^;]*)/i.exec(ct);\n\t}\n\n\t// no charset in content type, peek at response body for at most 1024 bytes\n\tstr = buffer.slice(0, 1024).toString();\n\n\t// html5\n\tif (!res && str) {\n\t\tres = / 0 && arguments[0] !== undefined ? arguments[0] : undefined;\n\n\t\tthis[MAP] = Object.create(null);\n\n\t\tif (init instanceof Headers) {\n\t\t\tconst rawHeaders = init.raw();\n\t\t\tconst headerNames = Object.keys(rawHeaders);\n\n\t\t\tfor (const headerName of headerNames) {\n\t\t\t\tfor (const value of rawHeaders[headerName]) {\n\t\t\t\t\tthis.append(headerName, value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't worry about converting prop to ByteString here as append()\n\t\t// will handle it.\n\t\tif (init == null) ; else if (typeof init === 'object') {\n\t\t\tconst method = init[Symbol.iterator];\n\t\t\tif (method != null) {\n\t\t\t\tif (typeof method !== 'function') {\n\t\t\t\t\tthrow new TypeError('Header pairs must be iterable');\n\t\t\t\t}\n\n\t\t\t\t// sequence>\n\t\t\t\t// Note: per spec we have to first exhaust the lists then process them\n\t\t\t\tconst pairs = [];\n\t\t\t\tfor (const pair of init) {\n\t\t\t\t\tif (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') {\n\t\t\t\t\t\tthrow new TypeError('Each header pair must be iterable');\n\t\t\t\t\t}\n\t\t\t\t\tpairs.push(Array.from(pair));\n\t\t\t\t}\n\n\t\t\t\tfor (const pair of pairs) {\n\t\t\t\t\tif (pair.length !== 2) {\n\t\t\t\t\t\tthrow new TypeError('Each header pair must be a name/value tuple');\n\t\t\t\t\t}\n\t\t\t\t\tthis.append(pair[0], pair[1]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// record\n\t\t\t\tfor (const key of Object.keys(init)) {\n\t\t\t\t\tconst value = init[key];\n\t\t\t\t\tthis.append(key, value);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Provided initializer must be an object');\n\t\t}\n\t}\n\n\t/**\n * Return combined header value given name\n *\n * @param String name Header name\n * @return Mixed\n */\n\tget(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key === undefined) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this[MAP][key].join(', ');\n\t}\n\n\t/**\n * Iterate over all headers\n *\n * @param Function callback Executed for each item with parameters (value, name, thisArg)\n * @param Boolean thisArg `this` context for callback function\n * @return Void\n */\n\tforEach(callback) {\n\t\tlet thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;\n\n\t\tlet pairs = getHeaders(this);\n\t\tlet i = 0;\n\t\twhile (i < pairs.length) {\n\t\t\tvar _pairs$i = pairs[i];\n\t\t\tconst name = _pairs$i[0],\n\t\t\t value = _pairs$i[1];\n\n\t\t\tcallback.call(thisArg, value, name, this);\n\t\t\tpairs = getHeaders(this);\n\t\t\ti++;\n\t\t}\n\t}\n\n\t/**\n * Overwrite header values given name\n *\n * @param String name Header name\n * @param String value Header value\n * @return Void\n */\n\tset(name, value) {\n\t\tname = `${name}`;\n\t\tvalue = `${value}`;\n\t\tvalidateName(name);\n\t\tvalidateValue(value);\n\t\tconst key = find(this[MAP], name);\n\t\tthis[MAP][key !== undefined ? key : name] = [value];\n\t}\n\n\t/**\n * Append a value onto existing header\n *\n * @param String name Header name\n * @param String value Header value\n * @return Void\n */\n\tappend(name, value) {\n\t\tname = `${name}`;\n\t\tvalue = `${value}`;\n\t\tvalidateName(name);\n\t\tvalidateValue(value);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tthis[MAP][key].push(value);\n\t\t} else {\n\t\t\tthis[MAP][name] = [value];\n\t\t}\n\t}\n\n\t/**\n * Check for header name existence\n *\n * @param String name Header name\n * @return Boolean\n */\n\thas(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\treturn find(this[MAP], name) !== undefined;\n\t}\n\n\t/**\n * Delete all header values given name\n *\n * @param String name Header name\n * @return Void\n */\n\tdelete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}\n\n\t/**\n * Return raw headers (non-spec api)\n *\n * @return Object\n */\n\traw() {\n\t\treturn this[MAP];\n\t}\n\n\t/**\n * Get an iterator on keys.\n *\n * @return Iterator\n */\n\tkeys() {\n\t\treturn createHeadersIterator(this, 'key');\n\t}\n\n\t/**\n * Get an iterator on values.\n *\n * @return Iterator\n */\n\tvalues() {\n\t\treturn createHeadersIterator(this, 'value');\n\t}\n\n\t/**\n * Get an iterator on entries.\n *\n * This is the default iterator of the Headers object.\n *\n * @return Iterator\n */\n\t[Symbol.iterator]() {\n\t\treturn createHeadersIterator(this, 'key+value');\n\t}\n}\nHeaders.prototype.entries = Headers.prototype[Symbol.iterator];\n\nObject.defineProperty(Headers.prototype, Symbol.toStringTag, {\n\tvalue: 'Headers',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nObject.defineProperties(Headers.prototype, {\n\tget: { enumerable: true },\n\tforEach: { enumerable: true },\n\tset: { enumerable: true },\n\tappend: { enumerable: true },\n\thas: { enumerable: true },\n\tdelete: { enumerable: true },\n\tkeys: { enumerable: true },\n\tvalues: { enumerable: true },\n\tentries: { enumerable: true }\n});\n\nfunction getHeaders(headers) {\n\tlet kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value';\n\n\tconst keys = Object.keys(headers[MAP]).sort();\n\treturn keys.map(kind === 'key' ? function (k) {\n\t\treturn k.toLowerCase();\n\t} : kind === 'value' ? function (k) {\n\t\treturn headers[MAP][k].join(', ');\n\t} : function (k) {\n\t\treturn [k.toLowerCase(), headers[MAP][k].join(', ')];\n\t});\n}\n\nconst INTERNAL = Symbol('internal');\n\nfunction createHeadersIterator(target, kind) {\n\tconst iterator = Object.create(HeadersIteratorPrototype);\n\titerator[INTERNAL] = {\n\t\ttarget,\n\t\tkind,\n\t\tindex: 0\n\t};\n\treturn iterator;\n}\n\nconst HeadersIteratorPrototype = Object.setPrototypeOf({\n\tnext() {\n\t\t// istanbul ignore if\n\t\tif (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) {\n\t\t\tthrow new TypeError('Value of `this` is not a HeadersIterator');\n\t\t}\n\n\t\tvar _INTERNAL = this[INTERNAL];\n\t\tconst target = _INTERNAL.target,\n\t\t kind = _INTERNAL.kind,\n\t\t index = _INTERNAL.index;\n\n\t\tconst values = getHeaders(target, kind);\n\t\tconst len = values.length;\n\t\tif (index >= len) {\n\t\t\treturn {\n\t\t\t\tvalue: undefined,\n\t\t\t\tdone: true\n\t\t\t};\n\t\t}\n\n\t\tthis[INTERNAL].index = index + 1;\n\n\t\treturn {\n\t\t\tvalue: values[index],\n\t\t\tdone: false\n\t\t};\n\t}\n}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));\n\nObject.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, {\n\tvalue: 'HeadersIterator',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\n/**\n * Export the Headers object in a form that Node.js can consume.\n *\n * @param Headers headers\n * @return Object\n */\nfunction exportNodeCompatibleHeaders(headers) {\n\tconst obj = Object.assign({ __proto__: null }, headers[MAP]);\n\n\t// http.request() only supports string as Host header. This hack makes\n\t// specifying custom Host header possible.\n\tconst hostHeaderKey = find(headers[MAP], 'Host');\n\tif (hostHeaderKey !== undefined) {\n\t\tobj[hostHeaderKey] = obj[hostHeaderKey][0];\n\t}\n\n\treturn obj;\n}\n\n/**\n * Create a Headers object from an object of headers, ignoring those that do\n * not conform to HTTP grammar productions.\n *\n * @param Object obj Object of headers\n * @return Headers\n */\nfunction createHeadersLenient(obj) {\n\tconst headers = new Headers();\n\tfor (const name of Object.keys(obj)) {\n\t\tif (invalidTokenRegex.test(name)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (Array.isArray(obj[name])) {\n\t\t\tfor (const val of obj[name]) {\n\t\t\t\tif (invalidHeaderCharRegex.test(val)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (headers[MAP][name] === undefined) {\n\t\t\t\t\theaders[MAP][name] = [val];\n\t\t\t\t} else {\n\t\t\t\t\theaders[MAP][name].push(val);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!invalidHeaderCharRegex.test(obj[name])) {\n\t\t\theaders[MAP][name] = [obj[name]];\n\t\t}\n\t}\n\treturn headers;\n}\n\nconst INTERNALS$1 = Symbol('Response internals');\n\n// fix an issue where \"STATUS_CODES\" aren't a named export for node <10\nconst STATUS_CODES = http.STATUS_CODES;\n\n/**\n * Response class\n *\n * @param Stream body Readable stream\n * @param Object opts Response options\n * @return Void\n */\nclass Response {\n\tconstructor() {\n\t\tlet body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\t\tlet opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\t\tBody.call(this, body, opts);\n\n\t\tconst status = opts.status || 200;\n\t\tconst headers = new Headers(opts.headers);\n\n\t\tif (body != null && !headers.has('Content-Type')) {\n\t\t\tconst contentType = extractContentType(body);\n\t\t\tif (contentType) {\n\t\t\t\theaders.append('Content-Type', contentType);\n\t\t\t}\n\t\t}\n\n\t\tthis[INTERNALS$1] = {\n\t\t\turl: opts.url,\n\t\t\tstatus,\n\t\t\tstatusText: opts.statusText || STATUS_CODES[status],\n\t\t\theaders,\n\t\t\tcounter: opts.counter\n\t\t};\n\t}\n\n\tget url() {\n\t\treturn this[INTERNALS$1].url || '';\n\t}\n\n\tget status() {\n\t\treturn this[INTERNALS$1].status;\n\t}\n\n\t/**\n * Convenience property representing if the request ended normally\n */\n\tget ok() {\n\t\treturn this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;\n\t}\n\n\tget redirected() {\n\t\treturn this[INTERNALS$1].counter > 0;\n\t}\n\n\tget statusText() {\n\t\treturn this[INTERNALS$1].statusText;\n\t}\n\n\tget headers() {\n\t\treturn this[INTERNALS$1].headers;\n\t}\n\n\t/**\n * Clone this response\n *\n * @return Response\n */\n\tclone() {\n\t\treturn new Response(clone(this), {\n\t\t\turl: this.url,\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t\theaders: this.headers,\n\t\t\tok: this.ok,\n\t\t\tredirected: this.redirected\n\t\t});\n\t}\n}\n\nBody.mixIn(Response.prototype);\n\nObject.defineProperties(Response.prototype, {\n\turl: { enumerable: true },\n\tstatus: { enumerable: true },\n\tok: { enumerable: true },\n\tredirected: { enumerable: true },\n\tstatusText: { enumerable: true },\n\theaders: { enumerable: true },\n\tclone: { enumerable: true }\n});\n\nObject.defineProperty(Response.prototype, Symbol.toStringTag, {\n\tvalue: 'Response',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nconst INTERNALS$2 = Symbol('Request internals');\n\n// fix an issue where \"format\", \"parse\" aren't a named export for node <10\nconst parse_url = Url.parse;\nconst format_url = Url.format;\n\nconst streamDestructionSupported = 'destroy' in Stream.Readable.prototype;\n\n/**\n * Check if a value is an instance of Request.\n *\n * @param Mixed input\n * @return Boolean\n */\nfunction isRequest(input) {\n\treturn typeof input === 'object' && typeof input[INTERNALS$2] === 'object';\n}\n\nfunction isAbortSignal(signal) {\n\tconst proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal);\n\treturn !!(proto && proto.constructor.name === 'AbortSignal');\n}\n\n/**\n * Request class\n *\n * @param Mixed input Url or Request instance\n * @param Object init Custom options\n * @return Void\n */\nclass Request {\n\tconstructor(input) {\n\t\tlet init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\t\tlet parsedURL;\n\n\t\t// normalize input\n\t\tif (!isRequest(input)) {\n\t\t\tif (input && input.href) {\n\t\t\t\t// in order to support Node.js' Url objects; though WHATWG's URL objects\n\t\t\t\t// will fall into this branch also (since their `toString()` will return\n\t\t\t\t// `href` property anyway)\n\t\t\t\tparsedURL = parse_url(input.href);\n\t\t\t} else {\n\t\t\t\t// coerce input to a string before attempting to parse\n\t\t\t\tparsedURL = parse_url(`${input}`);\n\t\t\t}\n\t\t\tinput = {};\n\t\t} else {\n\t\t\tparsedURL = parse_url(input.url);\n\t\t}\n\n\t\tlet method = init.method || input.method || 'GET';\n\t\tmethod = method.toUpperCase();\n\n\t\tif ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) {\n\t\t\tthrow new TypeError('Request with GET/HEAD method cannot have body');\n\t\t}\n\n\t\tlet inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;\n\n\t\tBody.call(this, inputBody, {\n\t\t\ttimeout: init.timeout || input.timeout || 0,\n\t\t\tsize: init.size || input.size || 0\n\t\t});\n\n\t\tconst headers = new Headers(init.headers || input.headers || {});\n\n\t\tif (inputBody != null && !headers.has('Content-Type')) {\n\t\t\tconst contentType = extractContentType(inputBody);\n\t\t\tif (contentType) {\n\t\t\t\theaders.append('Content-Type', contentType);\n\t\t\t}\n\t\t}\n\n\t\tlet signal = isRequest(input) ? input.signal : null;\n\t\tif ('signal' in init) signal = init.signal;\n\n\t\tif (signal != null && !isAbortSignal(signal)) {\n\t\t\tthrow new TypeError('Expected signal to be an instanceof AbortSignal');\n\t\t}\n\n\t\tthis[INTERNALS$2] = {\n\t\t\tmethod,\n\t\t\tredirect: init.redirect || input.redirect || 'follow',\n\t\t\theaders,\n\t\t\tparsedURL,\n\t\t\tsignal\n\t\t};\n\n\t\t// node-fetch-only options\n\t\tthis.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20;\n\t\tthis.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true;\n\t\tthis.counter = init.counter || input.counter || 0;\n\t\tthis.agent = init.agent || input.agent;\n\t}\n\n\tget method() {\n\t\treturn this[INTERNALS$2].method;\n\t}\n\n\tget url() {\n\t\treturn format_url(this[INTERNALS$2].parsedURL);\n\t}\n\n\tget headers() {\n\t\treturn this[INTERNALS$2].headers;\n\t}\n\n\tget redirect() {\n\t\treturn this[INTERNALS$2].redirect;\n\t}\n\n\tget signal() {\n\t\treturn this[INTERNALS$2].signal;\n\t}\n\n\t/**\n * Clone this request\n *\n * @return Request\n */\n\tclone() {\n\t\treturn new Request(this);\n\t}\n}\n\nBody.mixIn(Request.prototype);\n\nObject.defineProperty(Request.prototype, Symbol.toStringTag, {\n\tvalue: 'Request',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nObject.defineProperties(Request.prototype, {\n\tmethod: { enumerable: true },\n\turl: { enumerable: true },\n\theaders: { enumerable: true },\n\tredirect: { enumerable: true },\n\tclone: { enumerable: true },\n\tsignal: { enumerable: true }\n});\n\n/**\n * Convert a Request to Node.js http request options.\n *\n * @param Request A Request instance\n * @return Object The options object to be passed to http.request\n */\nfunction getNodeRequestOptions(request) {\n\tconst parsedURL = request[INTERNALS$2].parsedURL;\n\tconst headers = new Headers(request[INTERNALS$2].headers);\n\n\t// fetch step 1.3\n\tif (!headers.has('Accept')) {\n\t\theaders.set('Accept', '*/*');\n\t}\n\n\t// Basic fetch\n\tif (!parsedURL.protocol || !parsedURL.hostname) {\n\t\tthrow new TypeError('Only absolute URLs are supported');\n\t}\n\n\tif (!/^https?:$/.test(parsedURL.protocol)) {\n\t\tthrow new TypeError('Only HTTP(S) protocols are supported');\n\t}\n\n\tif (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) {\n\t\tthrow new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8');\n\t}\n\n\t// HTTP-network-or-cache fetch steps 2.4-2.7\n\tlet contentLengthValue = null;\n\tif (request.body == null && /^(POST|PUT)$/i.test(request.method)) {\n\t\tcontentLengthValue = '0';\n\t}\n\tif (request.body != null) {\n\t\tconst totalBytes = getTotalBytes(request);\n\t\tif (typeof totalBytes === 'number') {\n\t\t\tcontentLengthValue = String(totalBytes);\n\t\t}\n\t}\n\tif (contentLengthValue) {\n\t\theaders.set('Content-Length', contentLengthValue);\n\t}\n\n\t// HTTP-network-or-cache fetch step 2.11\n\tif (!headers.has('User-Agent')) {\n\t\theaders.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)');\n\t}\n\n\t// HTTP-network-or-cache fetch step 2.15\n\tif (request.compress && !headers.has('Accept-Encoding')) {\n\t\theaders.set('Accept-Encoding', 'gzip,deflate');\n\t}\n\n\tlet agent = request.agent;\n\tif (typeof agent === 'function') {\n\t\tagent = agent(parsedURL);\n\t}\n\n\tif (!headers.has('Connection') && !agent) {\n\t\theaders.set('Connection', 'close');\n\t}\n\n\t// HTTP-network fetch step 4.2\n\t// chunked encoding is handled by Node.js\n\n\treturn Object.assign({}, parsedURL, {\n\t\tmethod: request.method,\n\t\theaders: exportNodeCompatibleHeaders(headers),\n\t\tagent\n\t});\n}\n\n/**\n * abort-error.js\n *\n * AbortError interface for cancelled requests\n */\n\n/**\n * Create AbortError instance\n *\n * @param String message Error message for human\n * @return AbortError\n */\nfunction AbortError(message) {\n Error.call(this, message);\n\n this.type = 'aborted';\n this.message = message;\n\n // hide custom error implementation details from end-users\n Error.captureStackTrace(this, this.constructor);\n}\n\nAbortError.prototype = Object.create(Error.prototype);\nAbortError.prototype.constructor = AbortError;\nAbortError.prototype.name = 'AbortError';\n\n// fix an issue where \"PassThrough\", \"resolve\" aren't a named export for node <10\nconst PassThrough$1 = Stream.PassThrough;\nconst resolve_url = Url.resolve;\n\n/**\n * Fetch function\n *\n * @param Mixed url Absolute url or Request instance\n * @param Object opts Fetch options\n * @return Promise\n */\nfunction fetch(url, opts) {\n\n\t// allow custom promise\n\tif (!fetch.Promise) {\n\t\tthrow new Error('native promise missing, set fetch.Promise to your favorite alternative');\n\t}\n\n\tBody.Promise = fetch.Promise;\n\n\t// wrap http.request into fetch\n\treturn new fetch.Promise(function (resolve, reject) {\n\t\t// build request object\n\t\tconst request = new Request(url, opts);\n\t\tconst options = getNodeRequestOptions(request);\n\n\t\tconst send = (options.protocol === 'https:' ? https : http).request;\n\t\tconst signal = request.signal;\n\n\t\tlet response = null;\n\n\t\tconst abort = function abort() {\n\t\t\tlet error = new AbortError('The user aborted a request.');\n\t\t\treject(error);\n\t\t\tif (request.body && request.body instanceof Stream.Readable) {\n\t\t\t\trequest.body.destroy(error);\n\t\t\t}\n\t\t\tif (!response || !response.body) return;\n\t\t\tresponse.body.emit('error', error);\n\t\t};\n\n\t\tif (signal && signal.aborted) {\n\t\t\tabort();\n\t\t\treturn;\n\t\t}\n\n\t\tconst abortAndFinalize = function abortAndFinalize() {\n\t\t\tabort();\n\t\t\tfinalize();\n\t\t};\n\n\t\t// send request\n\t\tconst req = send(options);\n\t\tlet reqTimeout;\n\n\t\tif (signal) {\n\t\t\tsignal.addEventListener('abort', abortAndFinalize);\n\t\t}\n\n\t\tfunction finalize() {\n\t\t\treq.abort();\n\t\t\tif (signal) signal.removeEventListener('abort', abortAndFinalize);\n\t\t\tclearTimeout(reqTimeout);\n\t\t}\n\n\t\tif (request.timeout) {\n\t\t\treq.once('socket', function (socket) {\n\t\t\t\treqTimeout = setTimeout(function () {\n\t\t\t\t\treject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout'));\n\t\t\t\t\tfinalize();\n\t\t\t\t}, request.timeout);\n\t\t\t});\n\t\t}\n\n\t\treq.on('error', function (err) {\n\t\t\treject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));\n\t\t\tfinalize();\n\t\t});\n\n\t\treq.on('response', function (res) {\n\t\t\tclearTimeout(reqTimeout);\n\n\t\t\tconst headers = createHeadersLenient(res.headers);\n\n\t\t\t// HTTP fetch step 5\n\t\t\tif (fetch.isRedirect(res.statusCode)) {\n\t\t\t\t// HTTP fetch step 5.2\n\t\t\t\tconst location = headers.get('Location');\n\n\t\t\t\t// HTTP fetch step 5.3\n\t\t\t\tconst locationURL = location === null ? null : resolve_url(request.url, location);\n\n\t\t\t\t// HTTP fetch step 5.5\n\t\t\t\tswitch (request.redirect) {\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\treject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));\n\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase 'manual':\n\t\t\t\t\t\t// node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL.\n\t\t\t\t\t\tif (locationURL !== null) {\n\t\t\t\t\t\t\t// handle corrupted header\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\theaders.set('Location', locationURL);\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\t// istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request\n\t\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'follow':\n\t\t\t\t\t\t// HTTP-redirect fetch step 2\n\t\t\t\t\t\tif (locationURL === null) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 5\n\t\t\t\t\t\tif (request.counter >= request.follow) {\n\t\t\t\t\t\t\treject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect'));\n\t\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 6 (counter increment)\n\t\t\t\t\t\t// Create a new Request object.\n\t\t\t\t\t\tconst requestOpts = {\n\t\t\t\t\t\t\theaders: new Headers(request.headers),\n\t\t\t\t\t\t\tfollow: request.follow,\n\t\t\t\t\t\t\tcounter: request.counter + 1,\n\t\t\t\t\t\t\tagent: request.agent,\n\t\t\t\t\t\t\tcompress: request.compress,\n\t\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\t\tbody: request.body,\n\t\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\t\ttimeout: request.timeout,\n\t\t\t\t\t\t\tsize: request.size\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 9\n\t\t\t\t\t\tif (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {\n\t\t\t\t\t\t\treject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));\n\t\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 11\n\t\t\t\t\t\tif (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') {\n\t\t\t\t\t\t\trequestOpts.method = 'GET';\n\t\t\t\t\t\t\trequestOpts.body = undefined;\n\t\t\t\t\t\t\trequestOpts.headers.delete('content-length');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 15\n\t\t\t\t\t\tresolve(fetch(new Request(locationURL, requestOpts)));\n\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// prepare response\n\t\t\tres.once('end', function () {\n\t\t\t\tif (signal) signal.removeEventListener('abort', abortAndFinalize);\n\t\t\t});\n\t\t\tlet body = res.pipe(new PassThrough$1());\n\n\t\t\tconst response_options = {\n\t\t\t\turl: request.url,\n\t\t\t\tstatus: res.statusCode,\n\t\t\t\tstatusText: res.statusMessage,\n\t\t\t\theaders: headers,\n\t\t\t\tsize: request.size,\n\t\t\t\ttimeout: request.timeout,\n\t\t\t\tcounter: request.counter\n\t\t\t};\n\n\t\t\t// HTTP-network fetch step 12.1.1.3\n\t\t\tconst codings = headers.get('Content-Encoding');\n\n\t\t\t// HTTP-network fetch step 12.1.1.4: handle content codings\n\n\t\t\t// in following scenarios we ignore compression support\n\t\t\t// 1. compression support is disabled\n\t\t\t// 2. HEAD request\n\t\t\t// 3. no Content-Encoding header\n\t\t\t// 4. no content response (204)\n\t\t\t// 5. content not modified response (304)\n\t\t\tif (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) {\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For Node v6+\n\t\t\t// Be less strict when decoding compressed responses, since sometimes\n\t\t\t// servers send slightly invalid responses that are still accepted\n\t\t\t// by common browsers.\n\t\t\t// Always using Z_SYNC_FLUSH is what cURL does.\n\t\t\tconst zlibOptions = {\n\t\t\t\tflush: zlib.Z_SYNC_FLUSH,\n\t\t\t\tfinishFlush: zlib.Z_SYNC_FLUSH\n\t\t\t};\n\n\t\t\t// for gzip\n\t\t\tif (codings == 'gzip' || codings == 'x-gzip') {\n\t\t\t\tbody = body.pipe(zlib.createGunzip(zlibOptions));\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// for deflate\n\t\t\tif (codings == 'deflate' || codings == 'x-deflate') {\n\t\t\t\t// handle the infamous raw deflate response from old servers\n\t\t\t\t// a hack for old IIS and Apache servers\n\t\t\t\tconst raw = res.pipe(new PassThrough$1());\n\t\t\t\traw.once('data', function (chunk) {\n\t\t\t\t\t// see http://stackoverflow.com/questions/37519828\n\t\t\t\t\tif ((chunk[0] & 0x0F) === 0x08) {\n\t\t\t\t\t\tbody = body.pipe(zlib.createInflate());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbody = body.pipe(zlib.createInflateRaw());\n\t\t\t\t\t}\n\t\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\t\tresolve(response);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// for br\n\t\t\tif (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') {\n\t\t\t\tbody = body.pipe(zlib.createBrotliDecompress());\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// otherwise, use response as-is\n\t\t\tresponse = new Response(body, response_options);\n\t\t\tresolve(response);\n\t\t});\n\n\t\twriteToStream(req, request);\n\t});\n}\n/**\n * Redirect code matching\n *\n * @param Number code Status code\n * @return Boolean\n */\nfetch.isRedirect = function (code) {\n\treturn code === 301 || code === 302 || code === 303 || code === 307 || code === 308;\n};\n\n// expose Promise\nfetch.Promise = global.Promise;\n\nexport default fetch;\nexport { Headers, Request, Response, FetchError };\n","function noop() { }\nconst identity = x => x;\nfunction assign(tar, src) {\n // @ts-ignore\n for (const k in src)\n tar[k] = src[k];\n return tar;\n}\nfunction is_promise(value) {\n return value && typeof value === 'object' && typeof value.then === 'function';\n}\nfunction add_location(element, file, line, column, char) {\n element.__svelte_meta = {\n loc: { file, line, column, char }\n };\n}\nfunction run(fn) {\n return fn();\n}\nfunction blank_object() {\n return Object.create(null);\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === 'function';\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');\n}\nfunction not_equal(a, b) {\n return a != a ? b == b : a !== b;\n}\nfunction is_empty(obj) {\n return Object.keys(obj).length === 0;\n}\nfunction validate_store(store, name) {\n if (store != null && typeof store.subscribe !== 'function') {\n throw new Error(`'${name}' is not a store with a 'subscribe' method`);\n }\n}\nfunction subscribe(store, ...callbacks) {\n if (store == null) {\n return noop;\n }\n const unsub = store.subscribe(...callbacks);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, _ => value = _)();\n return value;\n}\nfunction component_subscribe(component, store, callback) {\n component.$$.on_destroy.push(subscribe(store, callback));\n}\nfunction create_slot(definition, ctx, $$scope, fn) {\n if (definition) {\n const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n return definition[0](slot_ctx);\n }\n}\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n return definition[1] && fn\n ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))\n : $$scope.ctx;\n}\nfunction get_slot_changes(definition, $$scope, dirty, fn) {\n if (definition[2] && fn) {\n const lets = definition[2](fn(dirty));\n if ($$scope.dirty === undefined) {\n return lets;\n }\n if (typeof lets === 'object') {\n const merged = [];\n const len = Math.max($$scope.dirty.length, lets.length);\n for (let i = 0; i < len; i += 1) {\n merged[i] = $$scope.dirty[i] | lets[i];\n }\n return merged;\n }\n return $$scope.dirty | lets;\n }\n return $$scope.dirty;\n}\nfunction update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {\n const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n if (slot_changes) {\n const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n slot.p(slot_context, slot_changes);\n }\n}\nfunction exclude_internal_props(props) {\n const result = {};\n for (const k in props)\n if (k[0] !== '$')\n result[k] = props[k];\n return result;\n}\nfunction compute_rest_props(props, keys) {\n const rest = {};\n keys = new Set(keys);\n for (const k in props)\n if (!keys.has(k) && k[0] !== '$')\n rest[k] = props[k];\n return rest;\n}\nfunction compute_slots(slots) {\n const result = {};\n for (const key in slots) {\n result[key] = true;\n }\n return result;\n}\nfunction once(fn) {\n let ran = false;\n return function (...args) {\n if (ran)\n return;\n ran = true;\n fn.call(this, ...args);\n };\n}\nfunction null_to_empty(value) {\n return value == null ? '' : value;\n}\nfunction set_store_value(store, ret, value = ret) {\n store.set(value);\n return ret;\n}\nconst has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\nfunction action_destroyer(action_result) {\n return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\n\nconst is_client = typeof window !== 'undefined';\nlet now = is_client\n ? () => window.performance.now()\n : () => Date.now();\nlet raf = is_client ? cb => requestAnimationFrame(cb) : noop;\n// used internally for testing\nfunction set_now(fn) {\n now = fn;\n}\nfunction set_raf(fn) {\n raf = fn;\n}\n\nconst tasks = new Set();\nfunction run_tasks(now) {\n tasks.forEach(task => {\n if (!task.c(now)) {\n tasks.delete(task);\n task.f();\n }\n });\n if (tasks.size !== 0)\n raf(run_tasks);\n}\n/**\n * For testing purposes only!\n */\nfunction clear_loops() {\n tasks.clear();\n}\n/**\n * Creates a new task that runs on each raf frame\n * until it returns a falsy value or is aborted\n */\nfunction loop(callback) {\n let task;\n if (tasks.size === 0)\n raf(run_tasks);\n return {\n promise: new Promise(fulfill => {\n tasks.add(task = { c: callback, f: fulfill });\n }),\n abort() {\n tasks.delete(task);\n }\n };\n}\n\nfunction append(target, node) {\n target.appendChild(node);\n}\nfunction insert(target, node, anchor) {\n target.insertBefore(node, anchor || null);\n}\nfunction detach(node) {\n node.parentNode.removeChild(node);\n}\nfunction destroy_each(iterations, detaching) {\n for (let i = 0; i < iterations.length; i += 1) {\n if (iterations[i])\n iterations[i].d(detaching);\n }\n}\nfunction element(name) {\n return document.createElement(name);\n}\nfunction element_is(name, is) {\n return document.createElement(name, { is });\n}\nfunction object_without_properties(obj, exclude) {\n const target = {};\n for (const k in obj) {\n if (has_prop(obj, k)\n // @ts-ignore\n && exclude.indexOf(k) === -1) {\n // @ts-ignore\n target[k] = obj[k];\n }\n }\n return target;\n}\nfunction svg_element(name) {\n return document.createElementNS('http://www.w3.org/2000/svg', name);\n}\nfunction text(data) {\n return document.createTextNode(data);\n}\nfunction space() {\n return text(' ');\n}\nfunction empty() {\n return text('');\n}\nfunction listen(node, event, handler, options) {\n node.addEventListener(event, handler, options);\n return () => node.removeEventListener(event, handler, options);\n}\nfunction prevent_default(fn) {\n return function (event) {\n event.preventDefault();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_propagation(fn) {\n return function (event) {\n event.stopPropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction self(fn) {\n return function (event) {\n // @ts-ignore\n if (event.target === this)\n fn.call(this, event);\n };\n}\nfunction attr(node, attribute, value) {\n if (value == null)\n node.removeAttribute(attribute);\n else if (node.getAttribute(attribute) !== value)\n node.setAttribute(attribute, value);\n}\nfunction set_attributes(node, attributes) {\n // @ts-ignore\n const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n for (const key in attributes) {\n if (attributes[key] == null) {\n node.removeAttribute(key);\n }\n else if (key === 'style') {\n node.style.cssText = attributes[key];\n }\n else if (key === '__value') {\n node.value = node[key] = attributes[key];\n }\n else if (descriptors[key] && descriptors[key].set) {\n node[key] = attributes[key];\n }\n else {\n attr(node, key, attributes[key]);\n }\n }\n}\nfunction set_svg_attributes(node, attributes) {\n for (const key in attributes) {\n attr(node, key, attributes[key]);\n }\n}\nfunction set_custom_element_data(node, prop, value) {\n if (prop in node) {\n node[prop] = value;\n }\n else {\n attr(node, prop, value);\n }\n}\nfunction xlink_attr(node, attribute, value) {\n node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\nfunction get_binding_group_value(group, __value, checked) {\n const value = new Set();\n for (let i = 0; i < group.length; i += 1) {\n if (group[i].checked)\n value.add(group[i].__value);\n }\n if (!checked) {\n value.delete(__value);\n }\n return Array.from(value);\n}\nfunction to_number(value) {\n return value === '' ? null : +value;\n}\nfunction time_ranges_to_array(ranges) {\n const array = [];\n for (let i = 0; i < ranges.length; i += 1) {\n array.push({ start: ranges.start(i), end: ranges.end(i) });\n }\n return array;\n}\nfunction children(element) {\n return Array.from(element.childNodes);\n}\nfunction claim_element(nodes, name, attributes, svg) {\n for (let i = 0; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeName === name) {\n let j = 0;\n const remove = [];\n while (j < node.attributes.length) {\n const attribute = node.attributes[j++];\n if (!attributes[attribute.name]) {\n remove.push(attribute.name);\n }\n }\n for (let k = 0; k < remove.length; k++) {\n node.removeAttribute(remove[k]);\n }\n return nodes.splice(i, 1)[0];\n }\n }\n return svg ? svg_element(name) : element(name);\n}\nfunction claim_text(nodes, data) {\n for (let i = 0; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeType === 3) {\n node.data = '' + data;\n return nodes.splice(i, 1)[0];\n }\n }\n return text(data);\n}\nfunction claim_space(nodes) {\n return claim_text(nodes, ' ');\n}\nfunction set_data(text, data) {\n data = '' + data;\n if (text.wholeText !== data)\n text.data = data;\n}\nfunction set_input_value(input, value) {\n input.value = value == null ? '' : value;\n}\nfunction set_input_type(input, type) {\n try {\n input.type = type;\n }\n catch (e) {\n // do nothing\n }\n}\nfunction set_style(node, key, value, important) {\n node.style.setProperty(key, value, important ? 'important' : '');\n}\nfunction select_option(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n if (option.__value === value) {\n option.selected = true;\n return;\n }\n }\n}\nfunction select_options(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n option.selected = ~value.indexOf(option.__value);\n }\n}\nfunction select_value(select) {\n const selected_option = select.querySelector(':checked') || select.options[0];\n return selected_option && selected_option.__value;\n}\nfunction select_multiple_value(select) {\n return [].map.call(select.querySelectorAll(':checked'), option => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\nlet crossorigin;\nfunction is_crossorigin() {\n if (crossorigin === undefined) {\n crossorigin = false;\n try {\n if (typeof window !== 'undefined' && window.parent) {\n void window.parent.document;\n }\n }\n catch (error) {\n crossorigin = true;\n }\n }\n return crossorigin;\n}\nfunction add_resize_listener(node, fn) {\n const computed_style = getComputedStyle(node);\n const z_index = (parseInt(computed_style.zIndex) || 0) - 1;\n if (computed_style.position === 'static') {\n node.style.position = 'relative';\n }\n const iframe = element('iframe');\n iframe.setAttribute('style', `display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ` +\n `overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: ${z_index};`);\n iframe.setAttribute('aria-hidden', 'true');\n iframe.tabIndex = -1;\n const crossorigin = is_crossorigin();\n let unsubscribe;\n if (crossorigin) {\n iframe.src = `data:text/html,`;\n unsubscribe = listen(window, 'message', (event) => {\n if (event.source === iframe.contentWindow)\n fn();\n });\n }\n else {\n iframe.src = 'about:blank';\n iframe.onload = () => {\n unsubscribe = listen(iframe.contentWindow, 'resize', fn);\n };\n }\n append(node, iframe);\n return () => {\n if (crossorigin) {\n unsubscribe();\n }\n else if (unsubscribe && iframe.contentWindow) {\n unsubscribe();\n }\n detach(iframe);\n };\n}\nfunction toggle_class(element, name, toggle) {\n element.classList[toggle ? 'add' : 'remove'](name);\n}\nfunction custom_event(type, detail) {\n const e = document.createEvent('CustomEvent');\n e.initCustomEvent(type, false, false, detail);\n return e;\n}\nfunction query_selector_all(selector, parent = document.body) {\n return Array.from(parent.querySelectorAll(selector));\n}\nclass HtmlTag {\n constructor(anchor = null) {\n this.a = anchor;\n this.e = this.n = null;\n }\n m(html, target, anchor = null) {\n if (!this.e) {\n this.e = element(target.nodeName);\n this.t = target;\n this.h(html);\n }\n this.i(anchor);\n }\n h(html) {\n this.e.innerHTML = html;\n this.n = Array.from(this.e.childNodes);\n }\n i(anchor) {\n for (let i = 0; i < this.n.length; i += 1) {\n insert(this.t, this.n[i], anchor);\n }\n }\n p(html) {\n this.d();\n this.h(html);\n this.i(this.a);\n }\n d() {\n this.n.forEach(detach);\n }\n}\n\nconst active_docs = new Set();\nlet active = 0;\n// https://github.com/darkskyapp/string-hash/blob/master/index.js\nfunction hash(str) {\n let hash = 5381;\n let i = str.length;\n while (i--)\n hash = ((hash << 5) - hash) ^ str.charCodeAt(i);\n return hash >>> 0;\n}\nfunction create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {\n const step = 16.666 / duration;\n let keyframes = '{\\n';\n for (let p = 0; p <= 1; p += step) {\n const t = a + (b - a) * ease(p);\n keyframes += p * 100 + `%{${fn(t, 1 - t)}}\\n`;\n }\n const rule = keyframes + `100% {${fn(b, 1 - b)}}\\n}`;\n const name = `__svelte_${hash(rule)}_${uid}`;\n const doc = node.ownerDocument;\n active_docs.add(doc);\n const stylesheet = doc.__svelte_stylesheet || (doc.__svelte_stylesheet = doc.head.appendChild(element('style')).sheet);\n const current_rules = doc.__svelte_rules || (doc.__svelte_rules = {});\n if (!current_rules[name]) {\n current_rules[name] = true;\n stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);\n }\n const animation = node.style.animation || '';\n node.style.animation = `${animation ? `${animation}, ` : ``}${name} ${duration}ms linear ${delay}ms 1 both`;\n active += 1;\n return name;\n}\nfunction delete_rule(node, name) {\n const previous = (node.style.animation || '').split(', ');\n const next = previous.filter(name\n ? anim => anim.indexOf(name) < 0 // remove specific animation\n : anim => anim.indexOf('__svelte') === -1 // remove all Svelte animations\n );\n const deleted = previous.length - next.length;\n if (deleted) {\n node.style.animation = next.join(', ');\n active -= deleted;\n if (!active)\n clear_rules();\n }\n}\nfunction clear_rules() {\n raf(() => {\n if (active)\n return;\n active_docs.forEach(doc => {\n const stylesheet = doc.__svelte_stylesheet;\n let i = stylesheet.cssRules.length;\n while (i--)\n stylesheet.deleteRule(i);\n doc.__svelte_rules = {};\n });\n active_docs.clear();\n });\n}\n\nfunction create_animation(node, from, fn, params) {\n if (!from)\n return noop;\n const to = node.getBoundingClientRect();\n if (from.left === to.left && from.right === to.right && from.top === to.top && from.bottom === to.bottom)\n return noop;\n const { delay = 0, duration = 300, easing = identity, \n // @ts-ignore todo: should this be separated from destructuring? Or start/end added to public api and documentation?\n start: start_time = now() + delay, \n // @ts-ignore todo:\n end = start_time + duration, tick = noop, css } = fn(node, { from, to }, params);\n let running = true;\n let started = false;\n let name;\n function start() {\n if (css) {\n name = create_rule(node, 0, 1, duration, delay, easing, css);\n }\n if (!delay) {\n started = true;\n }\n }\n function stop() {\n if (css)\n delete_rule(node, name);\n running = false;\n }\n loop(now => {\n if (!started && now >= start_time) {\n started = true;\n }\n if (started && now >= end) {\n tick(1, 0);\n stop();\n }\n if (!running) {\n return false;\n }\n if (started) {\n const p = now - start_time;\n const t = 0 + 1 * easing(p / duration);\n tick(t, 1 - t);\n }\n return true;\n });\n start();\n tick(0, 1);\n return stop;\n}\nfunction fix_position(node) {\n const style = getComputedStyle(node);\n if (style.position !== 'absolute' && style.position !== 'fixed') {\n const { width, height } = style;\n const a = node.getBoundingClientRect();\n node.style.position = 'absolute';\n node.style.width = width;\n node.style.height = height;\n add_transform(node, a);\n }\n}\nfunction add_transform(node, a) {\n const b = node.getBoundingClientRect();\n if (a.left !== b.left || a.top !== b.top) {\n const style = getComputedStyle(node);\n const transform = style.transform === 'none' ? '' : style.transform;\n node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`;\n }\n}\n\nlet current_component;\nfunction set_current_component(component) {\n current_component = component;\n}\nfunction get_current_component() {\n if (!current_component)\n throw new Error(`Function called outside component initialization`);\n return current_component;\n}\nfunction beforeUpdate(fn) {\n get_current_component().$$.before_update.push(fn);\n}\nfunction onMount(fn) {\n get_current_component().$$.on_mount.push(fn);\n}\nfunction afterUpdate(fn) {\n get_current_component().$$.after_update.push(fn);\n}\nfunction onDestroy(fn) {\n get_current_component().$$.on_destroy.push(fn);\n}\nfunction createEventDispatcher() {\n const component = get_current_component();\n return (type, detail) => {\n const callbacks = component.$$.callbacks[type];\n if (callbacks) {\n // TODO are there situations where events could be dispatched\n // in a server (non-DOM) environment?\n const event = custom_event(type, detail);\n callbacks.slice().forEach(fn => {\n fn.call(component, event);\n });\n }\n };\n}\nfunction setContext(key, context) {\n get_current_component().$$.context.set(key, context);\n}\nfunction getContext(key) {\n return get_current_component().$$.context.get(key);\n}\n// TODO figure out if we still want to support\n// shorthand events, or if we want to implement\n// a real bubbling mechanism\nfunction bubble(component, event) {\n const callbacks = component.$$.callbacks[event.type];\n if (callbacks) {\n callbacks.slice().forEach(fn => fn(event));\n }\n}\n\nconst dirty_components = [];\nconst intros = { enabled: false };\nconst binding_callbacks = [];\nconst render_callbacks = [];\nconst flush_callbacks = [];\nconst resolved_promise = Promise.resolve();\nlet update_scheduled = false;\nfunction schedule_update() {\n if (!update_scheduled) {\n update_scheduled = true;\n resolved_promise.then(flush);\n }\n}\nfunction tick() {\n schedule_update();\n return resolved_promise;\n}\nfunction add_render_callback(fn) {\n render_callbacks.push(fn);\n}\nfunction add_flush_callback(fn) {\n flush_callbacks.push(fn);\n}\nlet flushing = false;\nconst seen_callbacks = new Set();\nfunction flush() {\n if (flushing)\n return;\n flushing = true;\n do {\n // first, call beforeUpdate functions\n // and update components\n for (let i = 0; i < dirty_components.length; i += 1) {\n const component = dirty_components[i];\n set_current_component(component);\n update(component.$$);\n }\n set_current_component(null);\n dirty_components.length = 0;\n while (binding_callbacks.length)\n binding_callbacks.pop()();\n // then, once components are updated, call\n // afterUpdate functions. This may cause\n // subsequent updates...\n for (let i = 0; i < render_callbacks.length; i += 1) {\n const callback = render_callbacks[i];\n if (!seen_callbacks.has(callback)) {\n // ...so guard against infinite loops\n seen_callbacks.add(callback);\n callback();\n }\n }\n render_callbacks.length = 0;\n } while (dirty_components.length);\n while (flush_callbacks.length) {\n flush_callbacks.pop()();\n }\n update_scheduled = false;\n flushing = false;\n seen_callbacks.clear();\n}\nfunction update($$) {\n if ($$.fragment !== null) {\n $$.update();\n run_all($$.before_update);\n const dirty = $$.dirty;\n $$.dirty = [-1];\n $$.fragment && $$.fragment.p($$.ctx, dirty);\n $$.after_update.forEach(add_render_callback);\n }\n}\n\nlet promise;\nfunction wait() {\n if (!promise) {\n promise = Promise.resolve();\n promise.then(() => {\n promise = null;\n });\n }\n return promise;\n}\nfunction dispatch(node, direction, kind) {\n node.dispatchEvent(custom_event(`${direction ? 'intro' : 'outro'}${kind}`));\n}\nconst outroing = new Set();\nlet outros;\nfunction group_outros() {\n outros = {\n r: 0,\n c: [],\n p: outros // parent group\n };\n}\nfunction check_outros() {\n if (!outros.r) {\n run_all(outros.c);\n }\n outros = outros.p;\n}\nfunction transition_in(block, local) {\n if (block && block.i) {\n outroing.delete(block);\n block.i(local);\n }\n}\nfunction transition_out(block, local, detach, callback) {\n if (block && block.o) {\n if (outroing.has(block))\n return;\n outroing.add(block);\n outros.c.push(() => {\n outroing.delete(block);\n if (callback) {\n if (detach)\n block.d(1);\n callback();\n }\n });\n block.o(local);\n }\n}\nconst null_transition = { duration: 0 };\nfunction create_in_transition(node, fn, params) {\n let config = fn(node, params);\n let running = false;\n let animation_name;\n let task;\n let uid = 0;\n function cleanup() {\n if (animation_name)\n delete_rule(node, animation_name);\n }\n function go() {\n const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;\n if (css)\n animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++);\n tick(0, 1);\n const start_time = now() + delay;\n const end_time = start_time + duration;\n if (task)\n task.abort();\n running = true;\n add_render_callback(() => dispatch(node, true, 'start'));\n task = loop(now => {\n if (running) {\n if (now >= end_time) {\n tick(1, 0);\n dispatch(node, true, 'end');\n cleanup();\n return running = false;\n }\n if (now >= start_time) {\n const t = easing((now - start_time) / duration);\n tick(t, 1 - t);\n }\n }\n return running;\n });\n }\n let started = false;\n return {\n start() {\n if (started)\n return;\n delete_rule(node);\n if (is_function(config)) {\n config = config();\n wait().then(go);\n }\n else {\n go();\n }\n },\n invalidate() {\n started = false;\n },\n end() {\n if (running) {\n cleanup();\n running = false;\n }\n }\n };\n}\nfunction create_out_transition(node, fn, params) {\n let config = fn(node, params);\n let running = true;\n let animation_name;\n const group = outros;\n group.r += 1;\n function go() {\n const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;\n if (css)\n animation_name = create_rule(node, 1, 0, duration, delay, easing, css);\n const start_time = now() + delay;\n const end_time = start_time + duration;\n add_render_callback(() => dispatch(node, false, 'start'));\n loop(now => {\n if (running) {\n if (now >= end_time) {\n tick(0, 1);\n dispatch(node, false, 'end');\n if (!--group.r) {\n // this will result in `end()` being called,\n // so we don't need to clean up here\n run_all(group.c);\n }\n return false;\n }\n if (now >= start_time) {\n const t = easing((now - start_time) / duration);\n tick(1 - t, t);\n }\n }\n return running;\n });\n }\n if (is_function(config)) {\n wait().then(() => {\n // @ts-ignore\n config = config();\n go();\n });\n }\n else {\n go();\n }\n return {\n end(reset) {\n if (reset && config.tick) {\n config.tick(1, 0);\n }\n if (running) {\n if (animation_name)\n delete_rule(node, animation_name);\n running = false;\n }\n }\n };\n}\nfunction create_bidirectional_transition(node, fn, params, intro) {\n let config = fn(node, params);\n let t = intro ? 0 : 1;\n let running_program = null;\n let pending_program = null;\n let animation_name = null;\n function clear_animation() {\n if (animation_name)\n delete_rule(node, animation_name);\n }\n function init(program, duration) {\n const d = program.b - t;\n duration *= Math.abs(d);\n return {\n a: t,\n b: program.b,\n d,\n duration,\n start: program.start,\n end: program.start + duration,\n group: program.group\n };\n }\n function go(b) {\n const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;\n const program = {\n start: now() + delay,\n b\n };\n if (!b) {\n // @ts-ignore todo: improve typings\n program.group = outros;\n outros.r += 1;\n }\n if (running_program || pending_program) {\n pending_program = program;\n }\n else {\n // if this is an intro, and there's a delay, we need to do\n // an initial tick and/or apply CSS animation immediately\n if (css) {\n clear_animation();\n animation_name = create_rule(node, t, b, duration, delay, easing, css);\n }\n if (b)\n tick(0, 1);\n running_program = init(program, duration);\n add_render_callback(() => dispatch(node, b, 'start'));\n loop(now => {\n if (pending_program && now > pending_program.start) {\n running_program = init(pending_program, duration);\n pending_program = null;\n dispatch(node, running_program.b, 'start');\n if (css) {\n clear_animation();\n animation_name = create_rule(node, t, running_program.b, running_program.duration, 0, easing, config.css);\n }\n }\n if (running_program) {\n if (now >= running_program.end) {\n tick(t = running_program.b, 1 - t);\n dispatch(node, running_program.b, 'end');\n if (!pending_program) {\n // we're done\n if (running_program.b) {\n // intro — we can tidy up immediately\n clear_animation();\n }\n else {\n // outro — needs to be coordinated\n if (!--running_program.group.r)\n run_all(running_program.group.c);\n }\n }\n running_program = null;\n }\n else if (now >= running_program.start) {\n const p = now - running_program.start;\n t = running_program.a + running_program.d * easing(p / running_program.duration);\n tick(t, 1 - t);\n }\n }\n return !!(running_program || pending_program);\n });\n }\n }\n return {\n run(b) {\n if (is_function(config)) {\n wait().then(() => {\n // @ts-ignore\n config = config();\n go(b);\n });\n }\n else {\n go(b);\n }\n },\n end() {\n clear_animation();\n running_program = pending_program = null;\n }\n };\n}\n\nfunction handle_promise(promise, info) {\n const token = info.token = {};\n function update(type, index, key, value) {\n if (info.token !== token)\n return;\n info.resolved = value;\n let child_ctx = info.ctx;\n if (key !== undefined) {\n child_ctx = child_ctx.slice();\n child_ctx[key] = value;\n }\n const block = type && (info.current = type)(child_ctx);\n let needs_flush = false;\n if (info.block) {\n if (info.blocks) {\n info.blocks.forEach((block, i) => {\n if (i !== index && block) {\n group_outros();\n transition_out(block, 1, 1, () => {\n info.blocks[i] = null;\n });\n check_outros();\n }\n });\n }\n else {\n info.block.d(1);\n }\n block.c();\n transition_in(block, 1);\n block.m(info.mount(), info.anchor);\n needs_flush = true;\n }\n info.block = block;\n if (info.blocks)\n info.blocks[index] = block;\n if (needs_flush) {\n flush();\n }\n }\n if (is_promise(promise)) {\n const current_component = get_current_component();\n promise.then(value => {\n set_current_component(current_component);\n update(info.then, 1, info.value, value);\n set_current_component(null);\n }, error => {\n set_current_component(current_component);\n update(info.catch, 2, info.error, error);\n set_current_component(null);\n if (!info.hasCatch) {\n throw error;\n }\n });\n // if we previously had a then/catch block, destroy it\n if (info.current !== info.pending) {\n update(info.pending, 0);\n return true;\n }\n }\n else {\n if (info.current !== info.then) {\n update(info.then, 1, info.value, promise);\n return true;\n }\n info.resolved = promise;\n }\n}\n\nconst globals = (typeof window !== 'undefined'\n ? window\n : typeof globalThis !== 'undefined'\n ? globalThis\n : global);\n\nfunction destroy_block(block, lookup) {\n block.d(1);\n lookup.delete(block.key);\n}\nfunction outro_and_destroy_block(block, lookup) {\n transition_out(block, 1, 1, () => {\n lookup.delete(block.key);\n });\n}\nfunction fix_and_destroy_block(block, lookup) {\n block.f();\n destroy_block(block, lookup);\n}\nfunction fix_and_outro_and_destroy_block(block, lookup) {\n block.f();\n outro_and_destroy_block(block, lookup);\n}\nfunction update_keyed_each(old_blocks, dirty, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) {\n let o = old_blocks.length;\n let n = list.length;\n let i = o;\n const old_indexes = {};\n while (i--)\n old_indexes[old_blocks[i].key] = i;\n const new_blocks = [];\n const new_lookup = new Map();\n const deltas = new Map();\n i = n;\n while (i--) {\n const child_ctx = get_context(ctx, list, i);\n const key = get_key(child_ctx);\n let block = lookup.get(key);\n if (!block) {\n block = create_each_block(key, child_ctx);\n block.c();\n }\n else if (dynamic) {\n block.p(child_ctx, dirty);\n }\n new_lookup.set(key, new_blocks[i] = block);\n if (key in old_indexes)\n deltas.set(key, Math.abs(i - old_indexes[key]));\n }\n const will_move = new Set();\n const did_move = new Set();\n function insert(block) {\n transition_in(block, 1);\n block.m(node, next);\n lookup.set(block.key, block);\n next = block.first;\n n--;\n }\n while (o && n) {\n const new_block = new_blocks[n - 1];\n const old_block = old_blocks[o - 1];\n const new_key = new_block.key;\n const old_key = old_block.key;\n if (new_block === old_block) {\n // do nothing\n next = new_block.first;\n o--;\n n--;\n }\n else if (!new_lookup.has(old_key)) {\n // remove old block\n destroy(old_block, lookup);\n o--;\n }\n else if (!lookup.has(new_key) || will_move.has(new_key)) {\n insert(new_block);\n }\n else if (did_move.has(old_key)) {\n o--;\n }\n else if (deltas.get(new_key) > deltas.get(old_key)) {\n did_move.add(new_key);\n insert(new_block);\n }\n else {\n will_move.add(old_key);\n o--;\n }\n }\n while (o--) {\n const old_block = old_blocks[o];\n if (!new_lookup.has(old_block.key))\n destroy(old_block, lookup);\n }\n while (n)\n insert(new_blocks[n - 1]);\n return new_blocks;\n}\nfunction validate_each_keys(ctx, list, get_context, get_key) {\n const keys = new Set();\n for (let i = 0; i < list.length; i++) {\n const key = get_key(get_context(ctx, list, i));\n if (keys.has(key)) {\n throw new Error(`Cannot have duplicate keys in a keyed each`);\n }\n keys.add(key);\n }\n}\n\nfunction get_spread_update(levels, updates) {\n const update = {};\n const to_null_out = {};\n const accounted_for = { $$scope: 1 };\n let i = levels.length;\n while (i--) {\n const o = levels[i];\n const n = updates[i];\n if (n) {\n for (const key in o) {\n if (!(key in n))\n to_null_out[key] = 1;\n }\n for (const key in n) {\n if (!accounted_for[key]) {\n update[key] = n[key];\n accounted_for[key] = 1;\n }\n }\n levels[i] = n;\n }\n else {\n for (const key in o) {\n accounted_for[key] = 1;\n }\n }\n }\n for (const key in to_null_out) {\n if (!(key in update))\n update[key] = undefined;\n }\n return update;\n}\nfunction get_spread_object(spread_props) {\n return typeof spread_props === 'object' && spread_props !== null ? spread_props : {};\n}\n\n// source: https://html.spec.whatwg.org/multipage/indices.html\nconst boolean_attributes = new Set([\n 'allowfullscreen',\n 'allowpaymentrequest',\n 'async',\n 'autofocus',\n 'autoplay',\n 'checked',\n 'controls',\n 'default',\n 'defer',\n 'disabled',\n 'formnovalidate',\n 'hidden',\n 'ismap',\n 'loop',\n 'multiple',\n 'muted',\n 'nomodule',\n 'novalidate',\n 'open',\n 'playsinline',\n 'readonly',\n 'required',\n 'reversed',\n 'selected'\n]);\n\nconst invalid_attribute_name_character = /[\\s'\">/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;\n// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2\n// https://infra.spec.whatwg.org/#noncharacter\nfunction spread(args, classes_to_add) {\n const attributes = Object.assign({}, ...args);\n if (classes_to_add) {\n if (attributes.class == null) {\n attributes.class = classes_to_add;\n }\n else {\n attributes.class += ' ' + classes_to_add;\n }\n }\n let str = '';\n Object.keys(attributes).forEach(name => {\n if (invalid_attribute_name_character.test(name))\n return;\n const value = attributes[name];\n if (value === true)\n str += \" \" + name;\n else if (boolean_attributes.has(name.toLowerCase())) {\n if (value)\n str += \" \" + name;\n }\n else if (value != null) {\n str += ` ${name}=\"${String(value).replace(/\"/g, '"').replace(/'/g, ''')}\"`;\n }\n });\n return str;\n}\nconst escaped = {\n '\"': '"',\n \"'\": ''',\n '&': '&',\n '<': '<',\n '>': '>'\n};\nfunction escape(html) {\n return String(html).replace(/[\"'&<>]/g, match => escaped[match]);\n}\nfunction each(items, fn) {\n let str = '';\n for (let i = 0; i < items.length; i += 1) {\n str += fn(items[i], i);\n }\n return str;\n}\nconst missing_component = {\n $$render: () => ''\n};\nfunction validate_component(component, name) {\n if (!component || !component.$$render) {\n if (name === 'svelte:component')\n name += ' this={...}';\n throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);\n }\n return component;\n}\nfunction debug(file, line, column, values) {\n console.log(`{@debug} ${file ? file + ' ' : ''}(${line}:${column})`); // eslint-disable-line no-console\n console.log(values); // eslint-disable-line no-console\n return '';\n}\nlet on_destroy;\nfunction create_ssr_component(fn) {\n function $$render(result, props, bindings, slots) {\n const parent_component = current_component;\n const $$ = {\n on_destroy,\n context: new Map(parent_component ? parent_component.$$.context : []),\n // these will be immediately discarded\n on_mount: [],\n before_update: [],\n after_update: [],\n callbacks: blank_object()\n };\n set_current_component({ $$ });\n const html = fn(result, props, bindings, slots);\n set_current_component(parent_component);\n return html;\n }\n return {\n render: (props = {}, options = {}) => {\n on_destroy = [];\n const result = { title: '', head: '', css: new Set() };\n const html = $$render(result, props, {}, options);\n run_all(on_destroy);\n return {\n html,\n css: {\n code: Array.from(result.css).map(css => css.code).join('\\n'),\n map: null // TODO\n },\n head: result.title + result.head\n };\n },\n $$render\n };\n}\nfunction add_attribute(name, value, boolean) {\n if (value == null || (boolean && !value))\n return '';\n return ` ${name}${value === true ? '' : `=${typeof value === 'string' ? JSON.stringify(escape(value)) : `\"${value}\"`}`}`;\n}\nfunction add_classes(classes) {\n return classes ? ` class=\"${classes}\"` : ``;\n}\n\nfunction bind(component, name, callback) {\n const index = component.$$.props[name];\n if (index !== undefined) {\n component.$$.bound[index] = callback;\n callback(component.$$.ctx[index]);\n }\n}\nfunction create_component(block) {\n block && block.c();\n}\nfunction claim_component(block, parent_nodes) {\n block && block.l(parent_nodes);\n}\nfunction mount_component(component, target, anchor) {\n const { fragment, on_mount, on_destroy, after_update } = component.$$;\n fragment && fragment.m(target, anchor);\n // onMount happens before the initial afterUpdate\n add_render_callback(() => {\n const new_on_destroy = on_mount.map(run).filter(is_function);\n if (on_destroy) {\n on_destroy.push(...new_on_destroy);\n }\n else {\n // Edge case - component was destroyed immediately,\n // most likely as a result of a binding initialising\n run_all(new_on_destroy);\n }\n component.$$.on_mount = [];\n });\n after_update.forEach(add_render_callback);\n}\nfunction destroy_component(component, detaching) {\n const $$ = component.$$;\n if ($$.fragment !== null) {\n run_all($$.on_destroy);\n $$.fragment && $$.fragment.d(detaching);\n // TODO null out other refs, including component.$$ (but need to\n // preserve final state?)\n $$.on_destroy = $$.fragment = null;\n $$.ctx = [];\n }\n}\nfunction make_dirty(component, i) {\n if (component.$$.dirty[0] === -1) {\n dirty_components.push(component);\n schedule_update();\n component.$$.dirty.fill(0);\n }\n component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));\n}\nfunction init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {\n const parent_component = current_component;\n set_current_component(component);\n const prop_values = options.props || {};\n const $$ = component.$$ = {\n fragment: null,\n ctx: null,\n // state\n props,\n update: noop,\n not_equal,\n bound: blank_object(),\n // lifecycle\n on_mount: [],\n on_destroy: [],\n before_update: [],\n after_update: [],\n context: new Map(parent_component ? parent_component.$$.context : []),\n // everything else\n callbacks: blank_object(),\n dirty,\n skip_bound: false\n };\n let ready = false;\n $$.ctx = instance\n ? instance(component, prop_values, (i, ret, ...rest) => {\n const value = rest.length ? rest[0] : ret;\n if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {\n if (!$$.skip_bound && $$.bound[i])\n $$.bound[i](value);\n if (ready)\n make_dirty(component, i);\n }\n return ret;\n })\n : [];\n $$.update();\n ready = true;\n run_all($$.before_update);\n // `false` as a special case of no DOM component\n $$.fragment = create_fragment ? create_fragment($$.ctx) : false;\n if (options.target) {\n if (options.hydrate) {\n const nodes = children(options.target);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n $$.fragment && $$.fragment.l(nodes);\n nodes.forEach(detach);\n }\n else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n $$.fragment && $$.fragment.c();\n }\n if (options.intro)\n transition_in(component.$$.fragment);\n mount_component(component, options.target, options.anchor);\n flush();\n }\n set_current_component(parent_component);\n}\nlet SvelteElement;\nif (typeof HTMLElement === 'function') {\n SvelteElement = class extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n connectedCallback() {\n // @ts-ignore todo: improve typings\n for (const key in this.$$.slotted) {\n // @ts-ignore todo: improve typings\n this.appendChild(this.$$.slotted[key]);\n }\n }\n attributeChangedCallback(attr, _oldValue, newValue) {\n this[attr] = newValue;\n }\n $destroy() {\n destroy_component(this, 1);\n this.$destroy = noop;\n }\n $on(type, callback) {\n // TODO should this delegate to addEventListener?\n const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));\n callbacks.push(callback);\n return () => {\n const index = callbacks.indexOf(callback);\n if (index !== -1)\n callbacks.splice(index, 1);\n };\n }\n $set($$props) {\n if (this.$$set && !is_empty($$props)) {\n this.$$.skip_bound = true;\n this.$$set($$props);\n this.$$.skip_bound = false;\n }\n }\n };\n}\nclass SvelteComponent {\n $destroy() {\n destroy_component(this, 1);\n this.$destroy = noop;\n }\n $on(type, callback) {\n const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));\n callbacks.push(callback);\n return () => {\n const index = callbacks.indexOf(callback);\n if (index !== -1)\n callbacks.splice(index, 1);\n };\n }\n $set($$props) {\n if (this.$$set && !is_empty($$props)) {\n this.$$.skip_bound = true;\n this.$$set($$props);\n this.$$.skip_bound = false;\n }\n }\n}\n\nfunction dispatch_dev(type, detail) {\n document.dispatchEvent(custom_event(type, Object.assign({ version: '3.29.0' }, detail)));\n}\nfunction append_dev(target, node) {\n dispatch_dev(\"SvelteDOMInsert\", { target, node });\n append(target, node);\n}\nfunction insert_dev(target, node, anchor) {\n dispatch_dev(\"SvelteDOMInsert\", { target, node, anchor });\n insert(target, node, anchor);\n}\nfunction detach_dev(node) {\n dispatch_dev(\"SvelteDOMRemove\", { node });\n detach(node);\n}\nfunction detach_between_dev(before, after) {\n while (before.nextSibling && before.nextSibling !== after) {\n detach_dev(before.nextSibling);\n }\n}\nfunction detach_before_dev(after) {\n while (after.previousSibling) {\n detach_dev(after.previousSibling);\n }\n}\nfunction detach_after_dev(before) {\n while (before.nextSibling) {\n detach_dev(before.nextSibling);\n }\n}\nfunction listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) {\n const modifiers = options === true ? [\"capture\"] : options ? Array.from(Object.keys(options)) : [];\n if (has_prevent_default)\n modifiers.push('preventDefault');\n if (has_stop_propagation)\n modifiers.push('stopPropagation');\n dispatch_dev(\"SvelteDOMAddEventListener\", { node, event, handler, modifiers });\n const dispose = listen(node, event, handler, options);\n return () => {\n dispatch_dev(\"SvelteDOMRemoveEventListener\", { node, event, handler, modifiers });\n dispose();\n };\n}\nfunction attr_dev(node, attribute, value) {\n attr(node, attribute, value);\n if (value == null)\n dispatch_dev(\"SvelteDOMRemoveAttribute\", { node, attribute });\n else\n dispatch_dev(\"SvelteDOMSetAttribute\", { node, attribute, value });\n}\nfunction prop_dev(node, property, value) {\n node[property] = value;\n dispatch_dev(\"SvelteDOMSetProperty\", { node, property, value });\n}\nfunction dataset_dev(node, property, value) {\n node.dataset[property] = value;\n dispatch_dev(\"SvelteDOMSetDataset\", { node, property, value });\n}\nfunction set_data_dev(text, data) {\n data = '' + data;\n if (text.wholeText === data)\n return;\n dispatch_dev(\"SvelteDOMSetData\", { node: text, data });\n text.data = data;\n}\nfunction validate_each_argument(arg) {\n if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) {\n let msg = '{#each} only iterates over array-like objects.';\n if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) {\n msg += ' You can use a spread to convert this iterable into an array.';\n }\n throw new Error(msg);\n }\n}\nfunction validate_slots(name, slot, keys) {\n for (const slot_key of Object.keys(slot)) {\n if (!~keys.indexOf(slot_key)) {\n console.warn(`<${name}> received an unexpected slot \"${slot_key}\".`);\n }\n }\n}\nclass SvelteComponentDev extends SvelteComponent {\n constructor(options) {\n if (!options || (!options.target && !options.$$inline)) {\n throw new Error(`'target' is a required option`);\n }\n super();\n }\n $destroy() {\n super.$destroy();\n this.$destroy = () => {\n console.warn(`Component was already destroyed`); // eslint-disable-line no-console\n };\n }\n $capture_state() { }\n $inject_state() { }\n}\nfunction loop_guard(timeout) {\n const start = Date.now();\n return () => {\n if (Date.now() - start > timeout) {\n throw new Error(`Infinite loop detected`);\n }\n };\n}\n\nexport { HtmlTag, SvelteComponent, SvelteComponentDev, SvelteElement, action_destroyer, add_attribute, add_classes, add_flush_callback, add_location, add_render_callback, add_resize_listener, add_transform, afterUpdate, append, append_dev, assign, attr, attr_dev, beforeUpdate, bind, binding_callbacks, blank_object, bubble, check_outros, children, claim_component, claim_element, claim_space, claim_text, clear_loops, component_subscribe, compute_rest_props, compute_slots, createEventDispatcher, create_animation, create_bidirectional_transition, create_component, create_in_transition, create_out_transition, create_slot, create_ssr_component, current_component, custom_event, dataset_dev, debug, destroy_block, destroy_component, destroy_each, detach, detach_after_dev, detach_before_dev, detach_between_dev, detach_dev, dirty_components, dispatch_dev, each, element, element_is, empty, escape, escaped, exclude_internal_props, fix_and_destroy_block, fix_and_outro_and_destroy_block, fix_position, flush, getContext, get_binding_group_value, get_current_component, get_slot_changes, get_slot_context, get_spread_object, get_spread_update, get_store_value, globals, group_outros, handle_promise, has_prop, identity, init, insert, insert_dev, intros, invalid_attribute_name_character, is_client, is_crossorigin, is_empty, is_function, is_promise, listen, listen_dev, loop, loop_guard, missing_component, mount_component, noop, not_equal, now, null_to_empty, object_without_properties, onDestroy, onMount, once, outro_and_destroy_block, prevent_default, prop_dev, query_selector_all, raf, run, run_all, safe_not_equal, schedule_update, select_multiple_value, select_option, select_options, select_value, self, setContext, set_attributes, set_current_component, set_custom_element_data, set_data, set_data_dev, set_input_type, set_input_value, set_now, set_raf, set_store_value, set_style, set_svg_attributes, space, spread, stop_propagation, subscribe, svg_element, text, tick, time_ranges_to_array, to_number, toggle_class, transition_in, transition_out, update_keyed_each, update_slot, validate_component, validate_each_argument, validate_each_keys, validate_slots, validate_store, xlink_attr };\n","import { noop, safe_not_equal, subscribe, run_all, is_function } from '../internal';\nexport { get_store_value as get } from '../internal';\n\nconst subscriber_queue = [];\n/**\n * Creates a `Readable` store that allows reading by subscription.\n * @param value initial value\n * @param {StartStopNotifier}start start and stop notifications for subscriptions\n */\nfunction readable(value, start) {\n return {\n subscribe: writable(value, start).subscribe\n };\n}\n/**\n * Create a `Writable` store that allows both updating and reading by subscription.\n * @param {*=}value initial value\n * @param {StartStopNotifier=}start start and stop notifications for subscriptions\n */\nfunction writable(value, start = noop) {\n let stop;\n const subscribers = [];\n function set(new_value) {\n if (safe_not_equal(value, new_value)) {\n value = new_value;\n if (stop) { // store is ready\n const run_queue = !subscriber_queue.length;\n for (let i = 0; i < subscribers.length; i += 1) {\n const s = subscribers[i];\n s[1]();\n subscriber_queue.push(s, value);\n }\n if (run_queue) {\n for (let i = 0; i < subscriber_queue.length; i += 2) {\n subscriber_queue[i][0](subscriber_queue[i + 1]);\n }\n subscriber_queue.length = 0;\n }\n }\n }\n }\n function update(fn) {\n set(fn(value));\n }\n function subscribe(run, invalidate = noop) {\n const subscriber = [run, invalidate];\n subscribers.push(subscriber);\n if (subscribers.length === 1) {\n stop = start(set) || noop;\n }\n run(value);\n return () => {\n const index = subscribers.indexOf(subscriber);\n if (index !== -1) {\n subscribers.splice(index, 1);\n }\n if (subscribers.length === 0) {\n stop();\n stop = null;\n }\n };\n }\n return { set, update, subscribe };\n}\nfunction derived(stores, fn, initial_value) {\n const single = !Array.isArray(stores);\n const stores_array = single\n ? [stores]\n : stores;\n const auto = fn.length < 2;\n return readable(initial_value, (set) => {\n let inited = false;\n const values = [];\n let pending = 0;\n let cleanup = noop;\n const sync = () => {\n if (pending) {\n return;\n }\n cleanup();\n const result = fn(single ? values[0] : values, set);\n if (auto) {\n set(result);\n }\n else {\n cleanup = is_function(result) ? result : noop;\n }\n };\n const unsubscribers = stores_array.map((store, i) => subscribe(store, (value) => {\n values[i] = value;\n pending &= ~(1 << i);\n if (inited) {\n sync();\n }\n }, () => {\n pending |= (1 << i);\n }));\n inited = true;\n sync();\n return function stop() {\n run_all(unsubscribers);\n cleanup();\n };\n });\n}\n\nexport { derived, readable, writable };\n","import devalue from 'devalue';\nimport { createReadStream, existsSync } from 'fs';\nimport * as mime from 'mime';\nimport fetch, { Response } from 'node-fetch';\nimport { readable, writable } from 'svelte/store';\nimport { parse, resolve, URLSearchParams } from 'url';\nimport { render } from './index';\n\nconst noop = () => {};\n\nexport default async function render_page(\n\trequest,\n\tcontext,\n\toptions,\n\tstatus = 200,\n\terror = null\n) {\n\tlet redirected;\n\tlet preload_error;\n\n\tconst page = options.manifest.pages.find((page) =>\n\t\tpage.pattern.test(request.path)\n\t);\n\n\tconst baseUrl = ''; // TODO\n\n\tconst session = await (options.setup.getSession && options.setup.getSession(context));\n\n\tconst serialized_session = try_serialize(session, (err) => {\n\t\tthrow new Error(`Failed to serialize session data: ${err.message}`);\n\t});\n\n\ttry {\n\t\tif (!page) {\n\t\t\tconst error = new Error(`Not found: ${request.path}`);\n\t\t\terror.status = 404;\n\t\t\tthrow error;\n\t\t}\n\n\t\tconst segments = request.path.split('/').filter(Boolean);\n\n\t\t// TODO make this less confusing\n\t\tconst layout_segments = [segments[0]];\n\t\tlet l = 1;\n\n\t\tpage.parts.forEach((part, i) => {\n\t\t\tlayout_segments[l] = segments[i + 1];\n\t\t\tif (!part) return;\n\t\t\tl++;\n\t\t});\n\n\t\tconst dependencies = {};\n\n\t\tconst preload_context = {\n\t\t\tredirect: (status, location) => {\n\t\t\t\tif (\n\t\t\t\t\tredirected &&\n\t\t\t\t\t(redirected.status !== status || redirected.headers.location !== location)\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error('Conflicting redirects');\n\t\t\t\t}\n\t\t\t\tlocation = location.replace(/^\\//g, ''); // leading slash (only)\n\t\t\t\tredirected = {\n\t\t\t\t\tstatus,\n\t\t\t\t\theaders: { location },\n\t\t\t\t\tbody: null,\n\t\t\t\t\tdependencies: {}\n\t\t\t\t};\n\t\t\t},\n\t\t\terror: (status, error) => {\n\t\t\t\tif (typeof error === 'string') {\n\t\t\t\t\terror = new Error(error);\n\t\t\t\t}\n\t\t\t\tpreload_error = { ...error, status };\n\t\t\t},\n\t\t\tfetch: async (url, opts = {}) => {\n\t\t\t\tconst parsed = parse(url);\n\n\t\t\t\tif (parsed.protocol) {\n\t\t\t\t\t// external fetch\n\t\t\t\t\treturn fetch(parsed.href, opts);\n\t\t\t\t}\n\n\t\t\t\t// otherwise we're dealing with an internal fetch. TODO there's\n\t\t\t\t// probably no advantage to using fetch here — we should replace\n\t\t\t\t// `this.fetch` with `this.load` or whatever\n\n\t\t\t\tconst resolved = resolve(request.path, parsed.pathname);\n\n\t\t\t\t// edge case — fetching a static file\n\t\t\t\tconst candidates = [\n\t\t\t\t\t`${options.static_dir}${resolved}`,\n\t\t\t\t\t`${options.static_dir}${resolved}/index.html`\n\t\t\t\t];\n\t\t\t\tfor (const file of candidates) {\n\t\t\t\t\tif (existsSync(file)) {\n\t\t\t\t\t\treturn new Response(createReadStream(file), {\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t'content-type': mime.getType(file)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// TODO this doesn't take account of opts.body\n\t\t\t\tconst rendered = await render(\n\t\t\t\t\t{\n\t\t\t\t\t\thost: request.host,\n\t\t\t\t\t\tmethod: opts.method || 'GET',\n\t\t\t\t\t\theaders: opts.headers || {}, // TODO inject credentials...\n\t\t\t\t\t\tpath: resolved,\n\t\t\t\t\t\tbody: opts.body,\n\t\t\t\t\t\tquery: new URLSearchParams(parsed.query || '')\n\t\t\t\t\t},\n\t\t\t\t\toptions\n\t\t\t\t);\n\n\t\t\t\tif (rendered) {\n\t\t\t\t\t// TODO this is primarily for the benefit of the static case,\n\t\t\t\t\t// but could it be used elsewhere?\n\t\t\t\t\tdependencies[resolved] = rendered;\n\n\t\t\t\t\treturn new Response(rendered.body, {\n\t\t\t\t\t\tstatus: rendered.status,\n\t\t\t\t\t\theaders: rendered.headers\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn new Response('Not found', {\n\t\t\t\t\t\tstatus: 404\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst match = page.pattern.exec(request.path);\n\n\t\t// the last part has all parameters from any segment in the URL\n\t\tconst params = parts_to_params(match, page.parts[page.parts.length - 1] );\n\n\t\tconst preloaded = [];\n\t\tlet can_prerender = true;\n\n\t\tconst parts = await Promise.all(\n\t\t\t[{ component: options.manifest.layout, params: [] }, ...page.parts].map(async (part, i) => {\n\t\t\t\tif (!part) return null;\n\n\t\t\t\tconst mod = await options.load(part.component);\n\n\t\t\t\tif (options.only_prerender && !mod.prerender) {\n\t\t\t\t\tcan_prerender = false;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// these are only the parameters up to the current URL segment\n\t\t\t\tconst params = parts_to_params(match, part);\n\n\t\t\t\tconst props = mod.preload\n\t\t\t\t\t? await mod.preload.call(\n\t\t\t\t\t\t\tpreload_context,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\thost: request.host,\n\t\t\t\t\t\t\t\tpath: request.path,\n\t\t\t\t\t\t\t\tquery: request.query,\n\t\t\t\t\t\t\t\tparams\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tsession\n\t\t\t\t\t )\n\t\t\t\t\t: {};\n\n\t\t\t\tpreloaded[i] = props;\n\t\t\t\treturn { component: mod.default, props };\n\t\t\t})\n\t\t);\n\n\t\tif (options.only_prerender && !can_prerender) return;\n\n\t\tif (preload_error) throw preload_error;\n\t\tif (redirected) return redirected;\n\n\t\tconst branches = [];\n\t\tparts.forEach((part, i) => {\n\t\t\tif (part) {\n\t\t\t\tbranches.push({\n\t\t\t\t\tcomponent: part.component,\n\t\t\t\t\tprops: preloaded[i],\n\t\t\t\t\tsegment: segments[i]\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tconst pageContext = {\n\t\t\thost: request.host ,\n\t\t\tpath: request.path,\n\t\t\tquery: search_params_to_map(request.query),\n\t\t\tparams,\n\t\t\terror: error || undefined\n\t\t};\n\n\t\tconst props = {\n\t\t\tstatus,\n\t\t\terror,\n\t\t\tstores: {\n\t\t\t\tpage: readable(pageContext, noop),\n\t\t\t\tpreloading: readable(null, noop),\n\t\t\t\tsession: writable(session)\n\t\t\t},\n\t\t\t// TODO stores, status, segments, notify, CONTEXT_KEY\n\t\t\tsegments: layout_segments,\n\t\t\tbranches,\n\t\t\tlevel0: {\n\t\t\t\tprops: preloaded[0]\n\t\t\t},\n\t\t\tlevel1: {\n\t\t\t\tsegment: segments[0],\n\t\t\t\tprops: {}\n\t\t\t}\n\t\t};\n\n\t\t// TODO this is highly confusing. replace the leveln thing with an array of branches\n\t\tl = 1;\n\t\tfor (let i = 1; i < parts.length; i += 1) {\n\t\t\tconst part = parts[i];\n\t\t\tif (!part) continue;\n\n\t\t\tprops[`level${l++}`] = {\n\t\t\t\tcomponent: part.component,\n\t\t\t\tprops: preloaded[i] || {},\n\t\t\t\tsegment: segments[i]\n\t\t\t};\n\t\t}\n\n\t\tconst serialized_preloads = `[${preloaded\n\t\t\t.map((data) =>\n\t\t\t\ttry_serialize(data, (err) => {\n\t\t\t\t\tconst path = '/' + segments.join('/');\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`Failed to serialize preloaded data to transmit to the client at the ${path} route: ${err.message}`\n\t\t\t\t\t);\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t'The client will re-render over the server-rendered page fresh instead of continuing where it left off. See https://sapper.svelte.dev/docs#Return_value for more information'\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t)\n\t\t\t.join(',')}]`;\n\n\t\tconst rendered = options.root.render(props);\n\n\t\tconst deps = options.client.deps;\n\t\tconst js_deps = new Set(deps.__entry__ ? [...deps.__entry__.js] : []);\n\t\tconst css_deps = new Set(deps.__entry__ ? [...deps.__entry__.css] : []);\n\n\t\t(page.parts.filter(Boolean) ).forEach((part) => {\n\t\t\tconst page_deps = deps[part.component.name];\n\n\t\t\tif (!page_deps) return; // we don't have this info during dev\n\n\t\t\tpage_deps.js.forEach((dep) => js_deps.add(dep));\n\t\t\tpage_deps.css.forEach((dep) => css_deps.add(dep));\n\t\t});\n\n\t\tconst head = `${rendered.head}\n\n\t\t\t${Array.from(js_deps)\n\t\t\t\t.map((dep) => ``)\n\t\t\t\t.join('\\n\\t\\t\\t')}\n\t\t\t${Array.from(css_deps)\n\t\t\t\t.map((dep) => ``)\n\t\t\t\t.join('\\n\\t\\t\\t')}\n\t\t\t${options.dev ? `` : ''}\n\n\t\t\t`.replace(/^\\t{2}/gm, ''); // TODO add links\n\n\t\tconst body = `${rendered.html}\n\t\t\t`.replace(/^\\t{3}/gm, '');\n\n\t\tconst html = options.template.replace('%svelte.head%', head).replace('%svelte.body%', body);\n\n\t\treturn {\n\t\t\tstatus: 200,\n\t\t\theaders: {\n\t\t\t\t'content-type': 'text/html'\n\t\t\t},\n\t\t\tbody: html,\n\t\t\tdependencies\n\t\t};\n\t} catch (thrown) {\n\t\tconsole.error(thrown.stack);\n\n\t\tif (!error) {\n\t\t\tconst status = thrown.status || 500;\n\t\t\treturn render_page(request, context, options, status, thrown);\n\t\t} else {\n\t\t\t// oh lawd now you've done it\n\t\t\treturn {\n\t\t\t\tstatus: 500,\n\t\t\t\theaders: {},\n\t\t\t\tbody: thrown.stack, // TODO probably not in prod?\n\t\t\t\tdependencies: {}\n\t\t\t};\n\t\t}\n\t}\n}\n\nfunction parts_to_params(match, part) {\n\tconst params = {};\n\n\tpart.params.forEach((name, i) => {\n\t\tconst is_spread = /^\\.{3}.+$/.test(name);\n\n\t\tif (is_spread) {\n\t\t\tparams[name.slice(3)] = match[i + 1].split('/');\n\t\t} else {\n\t\t\tparams[name] = match[i + 1];\n\t\t}\n\t});\n\n\treturn params;\n}\n\nfunction try_serialize(data, fail) {\n\ttry {\n\t\treturn devalue(data);\n\t} catch (err) {\n\t\tif (fail) fail(err);\n\t\treturn null;\n\t}\n}\n\n// Ensure we return something truthy so the client will not re-render the page over the error\nfunction serialize_error(error) {\n\tif (!error) return null;\n\tlet serialized = try_serialize(error);\n\tif (!serialized) {\n\t\tconst { name, message, stack } = error;\n\t\tserialized = try_serialize({ name, message, stack });\n\t}\n\tif (!serialized) {\n\t\tserialized = '{}';\n\t}\n\treturn serialized;\n}\n\nfunction search_params_to_map(params) {\n\tconst map = {};\n\n\tfor (const key of params.keys()) {\n\t\tconst values = params.getAll(key);\n\n\t\tmap[key] = values.length > 1 ? values : values[0];\n\t}\n\n\treturn map;\n}\n","export default function render_route(\n\trequest,\n\tcontext,\n\toptions\n) {\n\tconst route = options.manifest.endpoints.find((route) =>\n\t\troute.pattern.test(request.path)\n\t);\n\tif (!route) return null;\n\n\treturn Promise.resolve(options.load(route)).then(async (mod) => {\n\t\tconst handler = mod[request.method.toLowerCase().replace('delete', 'del')]; // 'delete' is a reserved word\n\n\t\tif (handler) {\n\t\t\tconst params = {};\n\t\t\tconst match = route.pattern.exec(request.path);\n\t\t\troute.params.forEach((name, i) => {\n\t\t\t\tparams[name] = match[i + 1];\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tlet { status = 200, body, headers = {} } = await handler(\n\t\t\t\t\t{\n\t\t\t\t\t\thost: request.host,\n\t\t\t\t\t\tpath: request.path,\n\t\t\t\t\t\tquery: request.query,\n\t\t\t\t\t\tbody: request.body,\n\t\t\t\t\t\tparams\n\t\t\t\t\t},\n\t\t\t\t\tcontext\n\t\t\t\t);\n\n\t\t\t\theaders = lowercase_keys(headers);\n\n\t\t\t\tif (\n\t\t\t\t\t(typeof body === 'object' && !('content-type' in headers)) ||\n\t\t\t\t\theaders['content-type'] === 'application/json'\n\t\t\t\t) {\n\t\t\t\t\theaders = { ...headers, 'content-type': 'application/json' };\n\t\t\t\t\tbody = JSON.stringify(body);\n\t\t\t\t}\n\n\t\t\t\treturn { status, body, headers };\n\t\t\t} catch (err) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 500,\n\t\t\t\t\tbody: err.message,\n\t\t\t\t\theaders: {}\n\t\t\t\t};\n\t\t\t}\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tstatus: 501,\n\t\t\t\tbody: `${request.method} is not implemented for ${request.path}`,\n\t\t\t\theaders: {}\n\t\t\t};\n\t\t}\n\t});\n}\n\nfunction lowercase_keys(obj) {\n\tconst clone = {};\n\tfor (const key in obj) {\n\t\tclone[key.toLowerCase()] = obj[key];\n\t}\n\treturn clone;\n}\n","import { createHash } from 'crypto';\nimport render_page from './page';\nimport render_endpoint from './endpoint';\n\nfunction md5(body) {\n\treturn createHash('md5').update(body).digest('hex');\n}\n\nexport async function render(\n\trequest,\n\toptions\n) {\n\tconst { context, headers = {} } = (await (options.setup.prepare && options.setup.prepare(request.headers))) || {};\n\n\ttry {\n\t\tconst response = await (render_endpoint(request, context, options) ||\n\t\t\trender_page(request, context, options));\n\n\t\tif (response) {\n\t\t\t// inject ETags for 200 responses\n\t\t\tif (response.status === 200) {\n\t\t\t\tif (!/(no-store|immutable)/.test(response.headers['cache-control'])) {\n\t\t\t\t\tconst etag = `\"${md5(response.body)}\"`;\n\n\t\t\t\t\tif (request.headers['if-none-match'] === etag) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tstatus: 304,\n\t\t\t\t\t\t\theaders: {},\n\t\t\t\t\t\t\tbody: null\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tresponse.headers['etag'] = etag;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: { ...headers, ...response.headers },\n\t\t\t\tbody: response.body\n\t\t\t};\n\t\t}\n\t} catch (err) {\n\t\treturn {\n\t\t\tstatus: 500,\n\t\t\theaders: {},\n\t\t\tbody: options.dev ? err.stack : err.message\n\t\t};\n\t}\n}\n"],"names":["Mime","require$$0","require$$1","Stream","http","Url","https","zlib","noop","parse","resolve","existsSync","createReadStream","mime.getType","URLSearchParams","createHash","render_endpoint"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAI,KAAK,GAAG,wDAAwD,CAAC;AACrE,IAAI,WAAW,GAAG,+BAA+B,CAAC;AAClD,IAAI,QAAQ,GAAG,+XAA+X,CAAC;AAC/Y,IAAI,OAAO,GAAG;AACd,IAAI,GAAG,EAAE,SAAS;AAClB,IAAI,GAAG,EAAE,SAAS;AAClB,IAAI,GAAG,EAAE,SAAS;AAClB,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,IAAI,EAAE,KAAK;AACf,IAAI,IAAI,EAAE,KAAK;AACf,IAAI,IAAI,EAAE,KAAK;AACf,IAAI,IAA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K,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AACrC,KAAK;AACL,IAAI;AACJ;AACA,GAAG,OAAO;AACV,IAAI,MAAM,EAAE,QAAQ,CAAC,MAAM;AAC3B,IAAI,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE;AAChD,IAAI,IAAI,EAAE,QAAQ,CAAC,IAAI;AACvB,IAAI,CAAC;AACL,GAAG;AACH,EAAE,CAAC,OAAO,GAAG,EAAE;AACf,EAAE,OAAO;AACT,GAAG,MAAM,EAAE,GAAG;AACd,GAAG,OAAO,EAAE,EAAE;AACd,GAAG,IAAI,EAAE,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,OAAO;AAC9C,GAAG,CAAC;AACJ,EAAE;AACF;;;;"} \ No newline at end of file diff --git a/packages/kit/rollup.config.js b/packages/kit/rollup.config.js index 189cab99c17c..f0bbb810272a 100644 --- a/packages/kit/rollup.config.js +++ b/packages/kit/rollup.config.js @@ -32,6 +32,19 @@ export default [ ] }, + { + input: 'src/renderer/index.js', + output: { + dir: 'assets/renderer', + format: 'cjs', + sourcemap: true + }, + plugins: [ + resolve(), + commonjs() + ] + }, + { input: ['src/cli.js'], output: { diff --git a/packages/kit/src/api/build/Builder.js b/packages/kit/src/api/build/Builder.js index 1bc4db6a432f..847778a0f479 100644 --- a/packages/kit/src/api/build/Builder.js +++ b/packages/kit/src/api/build/Builder.js @@ -1,5 +1,6 @@ +import { rollup } from 'rollup'; import { copy } from '@sveltejs/app-utils/files'; -import { prerender } from '@sveltejs/app-utils/renderer'; +import { prerender } from './prerender'; export default class Builder { #generated_files; @@ -19,19 +20,23 @@ export default class Builder { this.log = log; } - copy_generated_files(dest) { - copy(`${this.#generated_files}/client`, dest); + copy_client_files(dest) { + copy(`${this.#generated_files}/client`, dest, (file) => file[0] !== '.'); + } + + copy_server_files(dest) { + copy(`${this.#generated_files}/server`, dest, (file) => file[0] !== '.'); } copy_static_files(dest) { copy(this.#static_files, dest); } - prerender({ + async prerender({ force = false, dest }) { - prerender({ + await prerender({ out: dest, force, dir: this.#generated_files, @@ -39,8 +44,4 @@ export default class Builder { log: this.log }); } - - foo() { - console.log(this.#manifest); - } } diff --git a/packages/kit/src/api/build/index.js b/packages/kit/src/api/build/index.js index 8297f334b0d8..8e4dc6e86532 100644 --- a/packages/kit/src/api/build/index.js +++ b/packages/kit/src/api/build/index.js @@ -78,21 +78,14 @@ export async function build(config) { header('Optimizing...'); await rimraf('.svelte/build/optimized'); - const server_input = { - root: `${unoptimized}/server/_app/main/generated/root.js`, - setup: `${unoptimized}/server/_app/setup/index.js` + const s = JSON.stringify; + + const client = { + entry: null, + deps: {} }; - [ - manifest.layout, // TODO is this necessary? if so why isn't manifest.error? - ...manifest.components, - ...manifest.endpoints - ].forEach((item) => { - server_input[`routes/${item.name}`] = `${unoptimized}/server${item.url.replace( - /\.\w+$/, - '.js' - )}`; - }); + const entry = path.resolve(`${unoptimized}/client/_app/main/runtime/navigation.js`); // https://github.com/snowpackjs/snowpack/discussions/1395 const re = /(\.\.\/)+_app\/main\/runtime\//; @@ -105,41 +98,6 @@ export async function build(config) { } }); - const server_chunks = await rollup({ - input: server_input, - plugins: [ - work_around_alias_bug('server'), - { - name: 'remove-css', - load(id) { - if (/\.css\.proxy\.js$/.test(id)) return ''; - } - }, - // TODO add server manifest generation so we can prune - // imports before zipping for cloud functions - terser() - ], - - onwarn, - - // TODO ensure this works with external node modules (on server) - external: (id) => id[0] !== '.' && !path.isAbsolute(id) - }); - - await server_chunks.write({ - dir: '.svelte/build/optimized/server', - format: 'cjs', // TODO some adapters might want ESM? - exports: 'named', - entryFileNames: '[name].js', - chunkFileNames: 'chunks/[name].js', - assetFileNames: 'assets/[name].js', - sourcemap: true - }); - - log.success('server'); - - const entry = path.resolve(`${unoptimized}/client/_app/main/runtime/navigation.js`); - const client_chunks = await rollup({ input: { entry @@ -167,10 +125,6 @@ export async function build(config) { const reverse_lookup = new Map(); const routes = path.resolve(`${unoptimized}/client/_app/routes`); - const client = { - entry: null, - deps: {} - }; let inject_styles; @@ -238,12 +192,6 @@ export async function build(config) { client.deps[component.name] = get_deps(key); }); - - // not using this.emitFile because the manifest doesn't belong with client code - fs.writeFileSync( - '.svelte/build/optimized/client.json', - JSON.stringify(client, null, ' ') - ); } }, terser() @@ -265,6 +213,100 @@ export async function build(config) { }); log.success('client'); + + fs.writeFileSync(`${unoptimized}/server/app.js`, ` + import * as renderer from '@sveltejs/kit/assets/renderer'; + import root from './_app/main/generated/root.js'; + import * as setup from './_app/setup/index.js'; + + const template = ${s(fs.readFileSync('src/app.html' /* TODO parameterise */, 'utf-8'))}; + + const manifest = { + layout: ${s(manifest.layout)}, + error: ${s(manifest.error)}, + components: ${s(manifest.components)}, + pages: [ + ${manifest.pages + .map(({ pattern, parts: json_parts }) => { + const parts = JSON.stringify(json_parts); + return `{ pattern: ${pattern}, parts: ${parts} }`; + }) + .join(',')} + ], + endpoints: [ + ${manifest.endpoints + .map(({ name, pattern, file, params: json_params }) => { + const params = JSON.stringify(json_params); + return `{ name: '${name}', pattern: ${pattern}, file: '${file}', params: ${params} }`; + }) + .join(',')} + ] + }; + + const client = ${s(client)}; + + export function render(request) { + return renderer.render(request, { + static_dir: 'static', + template, + manifest, + client, + root, + setup, + load: (route) => require(\`./routes/\${route.name}.js\`), + dev: false, + only_prerender: false + }); + } + `.replace(/^\t{3}/gm, '').trim()); + + const server_input = { + app: `${unoptimized}/server/app.js` + }; + + [ + manifest.layout, // TODO is this necessary? if so why isn't manifest.error? + ...manifest.components, + ...manifest.endpoints + ].forEach((item) => { + server_input[`routes/${item.name}`] = `${unoptimized}/server${item.url.replace( + /\.\w+$/, + '.js' + )}`; + }); + + const server_chunks = await rollup({ + input: server_input, + plugins: [ + work_around_alias_bug('server'), + { + name: 'remove-css', + load(id) { + if (/\.css\.proxy\.js$/.test(id)) return ''; + } + }, + // TODO add server manifest generation so we can prune + // imports before zipping for cloud functions + terser() + ], + + onwarn, + + // TODO ensure this works with external node modules (on server) + external: (id) => id[0] !== '.' && !path.isAbsolute(id) + }); + + await server_chunks.write({ + dir: '.svelte/build/optimized/server', + format: 'cjs', // TODO some adapters might want ESM? + exports: 'named', + entryFileNames: '[name].js', + chunkFileNames: 'chunks/[name].js', + assetFileNames: 'assets/[name].js', + sourcemap: true + }); + + log.success('server'); } { diff --git a/packages/app-utils/src/renderer/prerender/index.js b/packages/kit/src/api/build/prerender.js similarity index 84% rename from packages/app-utils/src/renderer/prerender/index.js rename to packages/kit/src/api/build/prerender.js index 3e86fd2cedd0..98d98179fa55 100644 --- a/packages/app-utils/src/renderer/prerender/index.js +++ b/packages/kit/src/api/build/prerender.js @@ -1,8 +1,7 @@ import fs from 'fs'; import { dirname, resolve as resolve_path } from 'path'; import { parse, resolve, URLSearchParams } from 'url'; -import { mkdirp } from '../../files'; -import { render } from '../render'; +import { mkdirp } from '@sveltejs/app-utils/files'; function clean_html(html) { return html @@ -46,45 +45,26 @@ const REDIRECT = 3; export async function prerender({ dir, out, - assets, manifest, - force, log }) { const seen = new Set(); - const template = fs.readFileSync('src/app.html', 'utf-8'); - const client = JSON.parse(fs.readFileSync(`${dir}/client.json`, 'utf-8')); - const server_root = resolve_path(dir); - const root = require(`${server_root}/server/root.js`); - const setup = require(`${server_root}/server/setup.js`); + const app = require(`${server_root}/server/app.js`); async function crawl(path) { if (seen.has(path)) return; seen.add(path); - const rendered = await render( - { - host: null, // TODO ??? - method: 'GET', - headers: {}, - path, - body: null, - query: new URLSearchParams() - }, - { - only_prerender: !force, - template, - manifest, - client, - static_dir: 'static', - root, - setup, - load: (route) => require(`${server_root}/server/routes/${route.name}.js`), - dev: false - } - ); + const rendered = await app.render({ + host: null, // TODO ??? + method: 'GET', + headers: {}, + path, + body: null, + query: new URLSearchParams() + }); if (rendered) { const response_type = Math.floor(rendered.status / 100); @@ -178,9 +158,8 @@ export async function prerender({ const parts = parsed.pathname.slice(1).split('/').filter(Boolean); if (parts[parts.length - 1] === 'index.html') parts.pop(); - // TODO this feels iffy const file_exists = - (assets && fs.existsSync(`${assets}${parsed.pathname}`)) || + (parsed.pathname.startsWith('/_app/') && fs.existsSync(`${dir}/client/${parsed.pathname.replace('/_app/', '')}`)) || fs.existsSync(`${out}${parsed.pathname}`) || fs.existsSync(`static${parsed.pathname}`) || fs.existsSync(`static${parsed.pathname}/index.html`); diff --git a/packages/app-utils/src/renderer/render/endpoint.js b/packages/kit/src/renderer/endpoint.js similarity index 100% rename from packages/app-utils/src/renderer/render/endpoint.js rename to packages/kit/src/renderer/endpoint.js diff --git a/packages/app-utils/src/renderer/render/index.js b/packages/kit/src/renderer/index.js similarity index 100% rename from packages/app-utils/src/renderer/render/index.js rename to packages/kit/src/renderer/index.js diff --git a/packages/app-utils/src/renderer/render/page.js b/packages/kit/src/renderer/page.js similarity index 99% rename from packages/app-utils/src/renderer/render/page.js rename to packages/kit/src/renderer/page.js index 3e2d785d3d84..e9e864da9e34 100644 --- a/packages/app-utils/src/renderer/render/page.js +++ b/packages/kit/src/renderer/page.js @@ -243,7 +243,7 @@ export default async function render_page( ) .join(',')}]`; - const rendered = options.root.default.render(props); + const rendered = options.root.render(props); const deps = options.client.deps; const js_deps = new Set(deps.__entry__ ? [...deps.__entry__.js] : []); From 83b13f5ba749008e62e0c77e7064025964b49eec Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 12:40:53 -0500 Subject: [PATCH 20/30] update test --- .../optimized/{client/root.js => server/app.js} | 0 .../.svelte/build/optimized/server}/routes/index.js | 0 packages/kit/src/api/build/test/index.js | 12 ++++++++++-- .../optimized/client/setup.js => output/app.js} | 0 packages/kit/src/api/build/test/output/client.json | 1 - .../kit/src/api/build/test/output/client/setup.js | 0 .../test/output/{client/root.js => routes/index.js} | 0 7 files changed, 10 insertions(+), 3 deletions(-) rename packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/{client/root.js => server/app.js} (100%) rename packages/kit/src/api/build/test/{output/client => fixtures/basic/.svelte/build/optimized/server}/routes/index.js (100%) rename packages/kit/src/api/build/test/{fixtures/basic/.svelte/build/optimized/client/setup.js => output/app.js} (100%) delete mode 100644 packages/kit/src/api/build/test/output/client.json delete mode 100644 packages/kit/src/api/build/test/output/client/setup.js rename packages/kit/src/api/build/test/output/{client/root.js => routes/index.js} (100%) diff --git a/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/root.js b/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/server/app.js similarity index 100% rename from packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/root.js rename to packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/server/app.js diff --git a/packages/kit/src/api/build/test/output/client/routes/index.js b/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/server/routes/index.js similarity index 100% rename from packages/kit/src/api/build/test/output/client/routes/index.js rename to packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/server/routes/index.js diff --git a/packages/kit/src/api/build/test/index.js b/packages/kit/src/api/build/test/index.js index 6df1b7fa6bbb..e620e0871791 100644 --- a/packages/kit/src/api/build/test/index.js +++ b/packages/kit/src/api/build/test/index.js @@ -52,10 +52,18 @@ suite('copy files', () => { ); rimraf.sync(dest); - builder.copy_generated_files(dest); + builder.copy_client_files(dest); assert.equal( - glob('**', { cwd: generated_files }), + glob('**', { cwd: `${generated_files}/client` }), + glob('**', { cwd: dest }) + ); + + rimraf.sync(dest); + builder.copy_server_files(dest); + + assert.equal( + glob('**', { cwd: `${generated_files}/server` }), glob('**', { cwd: dest }) ); }); diff --git a/packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/setup.js b/packages/kit/src/api/build/test/output/app.js similarity index 100% rename from packages/kit/src/api/build/test/fixtures/basic/.svelte/build/optimized/client/setup.js rename to packages/kit/src/api/build/test/output/app.js diff --git a/packages/kit/src/api/build/test/output/client.json b/packages/kit/src/api/build/test/output/client.json deleted file mode 100644 index 9e26dfeeb6e6..000000000000 --- a/packages/kit/src/api/build/test/output/client.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/packages/kit/src/api/build/test/output/client/setup.js b/packages/kit/src/api/build/test/output/client/setup.js deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/kit/src/api/build/test/output/client/root.js b/packages/kit/src/api/build/test/output/routes/index.js similarity index 100% rename from packages/kit/src/api/build/test/output/client/root.js rename to packages/kit/src/api/build/test/output/routes/index.js From 7f52979e5f54a18f130cebb5256a17c0ef2ba7e8 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 13:00:16 -0500 Subject: [PATCH 21/30] update adapter-netlify --- packages/adapter-netlify/.gitignore | 3 +- packages/adapter-netlify/index.js | 45 + packages/adapter-netlify/package.json | 2 - packages/adapter-netlify/render.js | 2583 +++++++++++++++++++++ packages/adapter-netlify/rollup.config.js | 27 +- packages/adapter-netlify/src/index.js | 91 - packages/adapter-netlify/src/render.js | 35 +- 7 files changed, 2645 insertions(+), 141 deletions(-) create mode 100644 packages/adapter-netlify/index.js create mode 100644 packages/adapter-netlify/render.js delete mode 100644 packages/adapter-netlify/src/index.js diff --git a/packages/adapter-netlify/.gitignore b/packages/adapter-netlify/.gitignore index 4fd626439822..1f664acc2b82 100644 --- a/packages/adapter-netlify/.gitignore +++ b/packages/adapter-netlify/.gitignore @@ -1,4 +1,3 @@ .DS_Store node_modules -/index.js -/render.js \ No newline at end of file +/files \ No newline at end of file diff --git a/packages/adapter-netlify/index.js b/packages/adapter-netlify/index.js new file mode 100644 index 000000000000..387df4423a8b --- /dev/null +++ b/packages/adapter-netlify/index.js @@ -0,0 +1,45 @@ +import fs from 'fs'; +import path from 'path'; +import toml from 'toml'; + +module.exports = async function adapter(builder) { + let netlify_config; + + if (fs.existsSync('netlify.toml')) { + try { + netlify_config = toml.parse(fs.readFileSync('netlify.toml', 'utf-8')); + } catch (err) { + err.message = `Error parsing netlify.toml: ${err.message}`; + throw err; + } + } else { + throw new Error( + 'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration' + ); + } + + if (!netlify_config.build || !netlify_config.build.publish || !netlify_config.build.functions) { + throw new Error( + 'You must specify build.publish and build.functions in netlify.toml. Consult https://github.com/sveltejs/adapter-netlify#configuration' + ); + } + + const publish = path.resolve(netlify_config.build.publish); + const functions = path.resolve(netlify_config.build.functions); + + builder.copy_static_files(publish); + builder.copy_client_files(`${publish}/_app`); + builder.copy_server_files(`${functions}/render`); + + // copy the renderer + fs.copyFileSync(path.resolve(__dirname, 'render.js'), `${functions}/render/index.js`); + + // create _redirects + fs.writeFileSync(`${publish}/_redirects`, '/* /.netlify/functions/render 200'); + + // prerender + builder.log.info('Prerendering static pages...'); + await builder.prerender({ + dest: publish + }); +}; diff --git a/packages/adapter-netlify/package.json b/packages/adapter-netlify/package.json index 8a8610b59822..9be7b46734a6 100644 --- a/packages/adapter-netlify/package.json +++ b/packages/adapter-netlify/package.json @@ -20,8 +20,6 @@ "prepublishOnly": "npm run build" }, "dependencies": { - "kleur": "^4.1.3", - "tiny-glob": "^0.2.8", "toml": "^3.0.0" } } diff --git a/packages/adapter-netlify/render.js b/packages/adapter-netlify/render.js new file mode 100644 index 000000000000..6baf9ac14437 --- /dev/null +++ b/packages/adapter-netlify/render.js @@ -0,0 +1,2583 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var Url = require('url'); +var fs = require('fs'); +require('path'); +var crypto = require('crypto'); +var Stream = require('stream'); +var http = require('http'); +var https = require('https'); +var zlib = require('zlib'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var Url__default = /*#__PURE__*/_interopDefaultLegacy(Url); +var Stream__default = /*#__PURE__*/_interopDefaultLegacy(Stream); +var http__default = /*#__PURE__*/_interopDefaultLegacy(http); +var https__default = /*#__PURE__*/_interopDefaultLegacy(https); +var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib); + +/** + * @param typeMap [Object] Map of MIME type -> Array[extensions] + * @param ... + */ +function Mime() { + this._types = Object.create(null); + this._extensions = Object.create(null); + + for (var i = 0; i < arguments.length; i++) { + this.define(arguments[i]); + } + + this.define = this.define.bind(this); + this.getType = this.getType.bind(this); + this.getExtension = this.getExtension.bind(this); +} + +/** + * Define mimetype -> extension mappings. Each key is a mime-type that maps + * to an array of extensions associated with the type. The first extension is + * used as the default extension for the type. + * + * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); + * + * If a type declares an extension that has already been defined, an error will + * be thrown. To suppress this error and force the extension to be associated + * with the new type, pass `force`=true. Alternatively, you may prefix the + * extension with "*" to map the type to extension, without mapping the + * extension to the type. + * + * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']}); + * + * + * @param map (Object) type definitions + * @param force (Boolean) if true, force overriding of existing definitions + */ +Mime.prototype.define = function(typeMap, force) { + for (var type in typeMap) { + var extensions = typeMap[type].map(function(t) {return t.toLowerCase()}); + type = type.toLowerCase(); + + for (var i = 0; i < extensions.length; i++) { + var ext = extensions[i]; + + // '*' prefix = not the preferred type for this extension. So fixup the + // extension, and skip it. + if (ext[0] == '*') { + continue; + } + + if (!force && (ext in this._types)) { + throw new Error( + 'Attempt to change mapping for "' + ext + + '" extension from "' + this._types[ext] + '" to "' + type + + '". Pass `force=true` to allow this, otherwise remove "' + ext + + '" from the list of extensions for "' + type + '".' + ); + } + + this._types[ext] = type; + } + + // Use first extension as default + if (force || !this._extensions[type]) { + var ext = extensions[0]; + this._extensions[type] = (ext[0] != '*') ? ext : ext.substr(1); + } + } +}; + +/** + * Lookup a mime type based on extension + */ +Mime.prototype.getType = function(path) { + path = String(path); + var last = path.replace(/^.*[/\\]/, '').toLowerCase(); + var ext = last.replace(/^.*\./, '').toLowerCase(); + + var hasPath = last.length < path.length; + var hasDot = ext.length < last.length - 1; + + return (hasDot || !hasPath) && this._types[ext] || null; +}; + +/** + * Return file extension associated with a mime type + */ +Mime.prototype.getExtension = function(type) { + type = /^\s*([^;\s]*)/.test(type) && RegExp.$1; + return type && this._extensions[type.toLowerCase()] || null; +}; + +var Mime_1 = Mime; + +var standard = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/urc-ressheet+xml":["rsheet"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["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/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"],"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/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/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/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/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"]}; + +var other = {"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":["keynote"],"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.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}; + +var mime = new Mime_1(standard, other); + +var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'; +var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g; +var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/; +var escaped = { + '<': '\\u003C', + '>': '\\u003E', + '/': '\\u002F', + '\\': '\\\\', + '\b': '\\b', + '\f': '\\f', + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\0': '\\0', + '\u2028': '\\u2028', + '\u2029': '\\u2029' +}; +var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join('\0'); +function devalue(value) { + var counts = new Map(); + function walk(thing) { + if (typeof thing === 'function') { + throw new Error("Cannot stringify a function"); + } + if (counts.has(thing)) { + counts.set(thing, counts.get(thing) + 1); + return; + } + counts.set(thing, 1); + if (!isPrimitive(thing)) { + var type = getType(thing); + switch (type) { + case 'Number': + case 'String': + case 'Boolean': + case 'Date': + case 'RegExp': + return; + case 'Array': + thing.forEach(walk); + break; + case 'Set': + case 'Map': + Array.from(thing).forEach(walk); + break; + default: + var proto = Object.getPrototypeOf(thing); + if (proto !== Object.prototype && + proto !== null && + Object.getOwnPropertyNames(proto).sort().join('\0') !== objectProtoOwnPropertyNames) { + throw new Error("Cannot stringify arbitrary non-POJOs"); + } + if (Object.getOwnPropertySymbols(thing).length > 0) { + throw new Error("Cannot stringify POJOs with symbolic keys"); + } + Object.keys(thing).forEach(function (key) { return walk(thing[key]); }); + } + } + } + walk(value); + var names = new Map(); + Array.from(counts) + .filter(function (entry) { return entry[1] > 1; }) + .sort(function (a, b) { return b[1] - a[1]; }) + .forEach(function (entry, i) { + names.set(entry[0], getName(i)); + }); + function stringify(thing) { + if (names.has(thing)) { + return names.get(thing); + } + if (isPrimitive(thing)) { + return stringifyPrimitive(thing); + } + var type = getType(thing); + switch (type) { + case 'Number': + case 'String': + case 'Boolean': + return "Object(" + stringify(thing.valueOf()) + ")"; + case 'RegExp': + return "new RegExp(" + stringifyString(thing.source) + ", \"" + thing.flags + "\")"; + case 'Date': + return "new Date(" + thing.getTime() + ")"; + case 'Array': + var members = thing.map(function (v, i) { return i in thing ? stringify(v) : ''; }); + var tail = thing.length === 0 || (thing.length - 1 in thing) ? '' : ','; + return "[" + members.join(',') + tail + "]"; + case 'Set': + case 'Map': + return "new " + type + "([" + Array.from(thing).map(stringify).join(',') + "])"; + default: + var obj = "{" + Object.keys(thing).map(function (key) { return safeKey(key) + ":" + stringify(thing[key]); }).join(',') + "}"; + var proto = Object.getPrototypeOf(thing); + if (proto === null) { + return Object.keys(thing).length > 0 + ? "Object.assign(Object.create(null)," + obj + ")" + : "Object.create(null)"; + } + return obj; + } + } + var str = stringify(value); + if (names.size) { + var params_1 = []; + var statements_1 = []; + var values_1 = []; + names.forEach(function (name, thing) { + params_1.push(name); + if (isPrimitive(thing)) { + values_1.push(stringifyPrimitive(thing)); + return; + } + var type = getType(thing); + switch (type) { + case 'Number': + case 'String': + case 'Boolean': + values_1.push("Object(" + stringify(thing.valueOf()) + ")"); + break; + case 'RegExp': + values_1.push(thing.toString()); + break; + case 'Date': + values_1.push("new Date(" + thing.getTime() + ")"); + break; + case 'Array': + values_1.push("Array(" + thing.length + ")"); + thing.forEach(function (v, i) { + statements_1.push(name + "[" + i + "]=" + stringify(v)); + }); + break; + case 'Set': + values_1.push("new Set"); + statements_1.push(name + "." + Array.from(thing).map(function (v) { return "add(" + stringify(v) + ")"; }).join('.')); + break; + case 'Map': + values_1.push("new Map"); + statements_1.push(name + "." + Array.from(thing).map(function (_a) { + var k = _a[0], v = _a[1]; + return "set(" + stringify(k) + ", " + stringify(v) + ")"; + }).join('.')); + break; + default: + values_1.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'); + Object.keys(thing).forEach(function (key) { + statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key])); + }); + } + }); + statements_1.push("return " + str); + return "(function(" + params_1.join(',') + "){" + statements_1.join(';') + "}(" + values_1.join(',') + "))"; + } + else { + return str; + } +} +function getName(num) { + var name = ''; + do { + name = chars[num % chars.length] + name; + num = ~~(num / chars.length) - 1; + } while (num >= 0); + return reserved.test(name) ? name + "_" : name; +} +function isPrimitive(thing) { + return Object(thing) !== thing; +} +function stringifyPrimitive(thing) { + if (typeof thing === 'string') + return stringifyString(thing); + if (thing === void 0) + return 'void 0'; + if (thing === 0 && 1 / thing < 0) + return '-0'; + var str = String(thing); + if (typeof thing === 'number') + return str.replace(/^(-)?0\./, '$1.'); + return str; +} +function getType(thing) { + return Object.prototype.toString.call(thing).slice(8, -1); +} +function escapeUnsafeChar(c) { + return escaped[c] || c; +} +function escapeUnsafeChars(str) { + return str.replace(unsafeChars, escapeUnsafeChar); +} +function safeKey(key) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key)); +} +function safeProp(key) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]"; +} +function stringifyString(str) { + var result = '"'; + for (var i = 0; i < str.length; i += 1) { + var char = str.charAt(i); + var code = char.charCodeAt(0); + if (char === '"') { + result += '\\"'; + } + else if (char in escaped) { + result += escaped[char]; + } + else if (code >= 0xd800 && code <= 0xdfff) { + var next = str.charCodeAt(i + 1); + // If this is the beginning of a [high, low] surrogate pair, + // add the next two characters, otherwise escape + if (code <= 0xdbff && (next >= 0xdc00 && next <= 0xdfff)) { + result += char + str[++i]; + } + else { + result += "\\u" + code.toString(16).toUpperCase(); + } + } + else { + result += char; + } + } + result += '"'; + return result; +} + +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js + +// fix for "Readable" isn't a named export issue +const Readable = Stream__default['default'].Readable; + +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); + +class Blob { + constructor() { + this[TYPE] = ''; + + const blobParts = arguments[0]; + const options = arguments[1]; + + const buffers = []; + let size = 0; + + if (blobParts) { + const a = blobParts; + const length = Number(a.length); + for (let i = 0; i < length; i++) { + const element = a[i]; + let buffer; + if (element instanceof Buffer) { + buffer = element; + } else if (ArrayBuffer.isView(element)) { + buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); + } else if (element instanceof ArrayBuffer) { + buffer = Buffer.from(element); + } else if (element instanceof Blob) { + buffer = element[BUFFER]; + } else { + buffer = Buffer.from(typeof element === 'string' ? element : String(element)); + } + size += buffer.length; + buffers.push(buffer); + } + } + + this[BUFFER] = Buffer.concat(buffers); + + let type = options && options.type !== undefined && String(options.type).toLowerCase(); + if (type && !/[^\u0020-\u007E]/.test(type)) { + this[TYPE] = type; + } + } + get size() { + return this[BUFFER].length; + } + get type() { + return this[TYPE]; + } + text() { + return Promise.resolve(this[BUFFER].toString()); + } + arrayBuffer() { + const buf = this[BUFFER]; + const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + return Promise.resolve(ab); + } + stream() { + const readable = new Readable(); + readable._read = function () {}; + readable.push(this[BUFFER]); + readable.push(null); + return readable; + } + toString() { + return '[object Blob]'; + } + slice() { + const size = this.size; + + const start = arguments[0]; + const end = arguments[1]; + let relativeStart, relativeEnd; + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + const span = Math.max(relativeEnd - relativeStart, 0); + + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +} + +Object.defineProperties(Blob.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); + +Object.defineProperty(Blob.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * fetch-error.js + * + * FetchError interface for operational errors + */ + +/** + * Create FetchError instance + * + * @param String message Error message for human + * @param String type Error type for machine + * @param String systemError For Node.js system error + * @return FetchError + */ +function FetchError(message, type, systemError) { + Error.call(this, message); + + this.message = message; + this.type = type; + + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; + +let convert; +try { + convert = require('encoding').convert; +} catch (e) {} + +const INTERNALS = Symbol('Body internals'); + +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream__default['default'].PassThrough; + +/** + * Body mixin + * + * Ref: https://fetch.spec.whatwg.org/#body + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +function Body(body) { + var _this = this; + + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; + + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + + if (body == null) { + // body is undefined or null + body = null; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + body = Buffer.from(body.toString()); + } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + body = Buffer.from(body); + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); + } else if (body instanceof Stream__default['default']) ; else { + // none of the above + // coerce to string then buffer + body = Buffer.from(String(body)); + } + this[INTERNALS] = { + body, + disturbed: false, + error: null + }; + this.size = size; + this.timeout = timeout; + + if (body instanceof Stream__default['default']) { + body.on('error', function (err) { + const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); + _this[INTERNALS].error = error; + }); + } +} + +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, + + get bodyUsed() { + return this[INTERNALS].disturbed; + }, + + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, + + /** + * Return raw response as Blob + * + * @return Promise + */ + blob() { + let ct = this.headers && this.headers.get('content-type') || ''; + return consumeBody.call(this).then(function (buf) { + return Object.assign( + // Prevent copying + new Blob([], { + type: ct.toLowerCase() + }), { + [BUFFER]: buf + }); + }); + }, + + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; + + return consumeBody.call(this).then(function (buffer) { + try { + return JSON.parse(buffer.toString()); + } catch (err) { + return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + } + }); + }, + + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, + + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, + + /** + * Decode response as text, while automatically detecting the encoding and + * trying to decode to UTF-8 (non-spec api) + * + * @return Promise + */ + textConverted() { + var _this3 = this; + + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; + +// In browsers, all properties are enumerable. +Object.defineProperties(Body.prototype, { + body: { enumerable: true }, + bodyUsed: { enumerable: true }, + arrayBuffer: { enumerable: true }, + blob: { enumerable: true }, + json: { enumerable: true }, + text: { enumerable: true } +}); + +Body.mixIn = function (proto) { + for (const name of Object.getOwnPropertyNames(Body.prototype)) { + // istanbul ignore else: future proof + if (!(name in proto)) { + const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); + Object.defineProperty(proto, name, desc); + } + } +}; + +/** + * Consume and convert an entire Body to a Buffer. + * + * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * + * @return Promise + */ +function consumeBody() { + var _this4 = this; + + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } + + this[INTERNALS].disturbed = true; + + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } + + let body = this.body; + + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is blob + if (isBlob(body)) { + body = body.stream(); + } + + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } + + // istanbul ignore if: should never happen + if (!(body instanceof Stream__default['default'])) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; + + return new Body.Promise(function (resolve, reject) { + let resTimeout; + + // allow timeout on slow response body + if (_this4.timeout) { + resTimeout = setTimeout(function () { + abort = true; + reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); + }, _this4.timeout); + } + + // handle stream errors + body.on('error', function (err) { + if (err.name === 'AbortError') { + // if the request was aborted, reject with this Error + abort = true; + reject(err); + } else { + // other errors, such as incorrect content-encoding + reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } + + if (_this4.size && accumBytes + chunk.length > _this4.size) { + abort = true; + reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + return; + } + + accumBytes += chunk.length; + accum.push(chunk); + }); + + body.on('end', function () { + if (abort) { + return; + } + + clearTimeout(resTimeout); + + try { + resolve(Buffer.concat(accum, accumBytes)); + } catch (err) { + // handle streams that have accumulated too much data (issue #414) + reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + }); +} + +/** + * Detect buffer encoding and convert to target encoding + * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * + * @param Buffer buffer Incoming buffer + * @param String encoding Target encoding + * @return String + */ +function convertBody(buffer, headers) { + if (typeof convert !== 'function') { + throw new Error('The package `encoding` must be installed to use the textConverted() function'); + } + + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; + + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } + + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); + + // html5 + if (!res && str) { + res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; + + this[MAP] = Object.create(null); + + if (init instanceof Headers) { + const rawHeaders = init.raw(); + const headerNames = Object.keys(rawHeaders); + + for (const headerName of headerNames) { + for (const value of rawHeaders[headerName]) { + this.append(headerName, value); + } + } + + return; + } + + // We don't worry about converting prop to ByteString here as append() + // will handle it. + if (init == null) ; else if (typeof init === 'object') { + const method = init[Symbol.iterator]; + if (method != null) { + if (typeof method !== 'function') { + throw new TypeError('Header pairs must be iterable'); + } + + // sequence> + // Note: per spec we have to first exhaust the lists then process them + const pairs = []; + for (const pair of init) { + if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { + throw new TypeError('Each header pair must be iterable'); + } + pairs.push(Array.from(pair)); + } + + for (const pair of pairs) { + if (pair.length !== 2) { + throw new TypeError('Each header pair must be a name/value tuple'); + } + this.append(pair[0], pair[1]); + } + } else { + // record + for (const key of Object.keys(init)) { + const value = init[key]; + this.append(key, value); + } + } + } else { + throw new TypeError('Provided initializer must be an object'); + } + } + + /** + * Return combined header value given name + * + * @param String name Header name + * @return Mixed + */ + get(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key === undefined) { + return null; + } + + return this[MAP][key].join(', '); + } + + /** + * Iterate over all headers + * + * @param Function callback Executed for each item with parameters (value, name, thisArg) + * @param Boolean thisArg `this` context for callback function + * @return Void + */ + forEach(callback) { + let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + + let pairs = getHeaders(this); + let i = 0; + while (i < pairs.length) { + var _pairs$i = pairs[i]; + const name = _pairs$i[0], + value = _pairs$i[1]; + + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } + } + + /** + * Overwrite header values given name + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + set(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + this[MAP][key !== undefined ? key : name] = [value]; + } + + /** + * Append a value onto existing header + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + append(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + if (key !== undefined) { + this[MAP][key].push(value); + } else { + this[MAP][name] = [value]; + } + } + + /** + * Check for header name existence + * + * @param String name Header name + * @return Boolean + */ + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } + + /** + * Delete all header values given name + * + * @param String name Header name + * @return Void + */ + delete(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key !== undefined) { + delete this[MAP][key]; + } + } + + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } + + /** + * Get an iterator on keys. + * + * @return Iterator + */ + keys() { + return createHeadersIterator(this, 'key'); + } + + /** + * Get an iterator on values. + * + * @return Iterator + */ + values() { + return createHeadersIterator(this, 'value'); + } + + /** + * Get an iterator on entries. + * + * This is the default iterator of the Headers object. + * + * @return Iterator + */ + [Symbol.iterator]() { + return createHeadersIterator(this, 'key+value'); + } +} +Headers.prototype.entries = Headers.prototype[Symbol.iterator]; + +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Headers.prototype, { + get: { enumerable: true }, + forEach: { enumerable: true }, + set: { enumerable: true }, + append: { enumerable: true }, + has: { enumerable: true }, + delete: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true } +}); + +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + + const keys = Object.keys(headers[MAP]).sort(); + return keys.map(kind === 'key' ? function (k) { + return k.toLowerCase(); + } : kind === 'value' ? function (k) { + return headers[MAP][k].join(', '); + } : function (k) { + return [k.toLowerCase(), headers[MAP][k].join(', ')]; + }); +} + +const INTERNAL = Symbol('internal'); + +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; +} + +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } + + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; + + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } + + this[INTERNAL].index = index + 1; + + return { + value: values[index], + done: false + }; + } +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); + +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * Export the Headers object in a form that Node.js can consume. + * + * @param Headers headers + * @return Object + */ +function exportNodeCompatibleHeaders(headers) { + const obj = Object.assign({ __proto__: null }, headers[MAP]); + + // http.request() only supports string as Host header. This hack makes + // specifying custom Host header possible. + const hostHeaderKey = find(headers[MAP], 'Host'); + if (hostHeaderKey !== undefined) { + obj[hostHeaderKey] = obj[hostHeaderKey][0]; + } + + return obj; +} + +/** + * Create a Headers object from an object of headers, ignoring those that do + * not conform to HTTP grammar productions. + * + * @param Object obj Object of headers + * @return Headers + */ +function createHeadersLenient(obj) { + const headers = new Headers(); + for (const name of Object.keys(obj)) { + if (invalidTokenRegex.test(name)) { + continue; + } + if (Array.isArray(obj[name])) { + for (const val of obj[name]) { + if (invalidHeaderCharRegex.test(val)) { + continue; + } + if (headers[MAP][name] === undefined) { + headers[MAP][name] = [val]; + } else { + headers[MAP][name].push(val); + } + } + } else if (!invalidHeaderCharRegex.test(obj[name])) { + headers[MAP][name] = [obj[name]]; + } + } + return headers; +} + +const INTERNALS$1 = Symbol('Response internals'); + +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http__default['default'].STATUS_CODES; + +/** + * Response class + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +class Response { + constructor() { + let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + Body.call(this, body, opts); + + const status = opts.status || 200; + const headers = new Headers(opts.headers); + + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; + } + + get url() { + return this[INTERNALS$1].url || ''; + } + + get status() { + return this[INTERNALS$1].status; + } + + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + } + + get redirected() { + return this[INTERNALS$1].counter > 0; + } + + get statusText() { + return this[INTERNALS$1].statusText; + } + + get headers() { + return this[INTERNALS$1].headers; + } + + /** + * Clone this response + * + * @return Response + */ + clone() { + return new Response(clone(this), { + url: this.url, + status: this.status, + statusText: this.statusText, + headers: this.headers, + ok: this.ok, + redirected: this.redirected + }); + } +} + +Body.mixIn(Response.prototype); + +Object.defineProperties(Response.prototype, { + url: { enumerable: true }, + status: { enumerable: true }, + ok: { enumerable: true }, + redirected: { enumerable: true }, + statusText: { enumerable: true }, + headers: { enumerable: true }, + clone: { enumerable: true } +}); + +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); + +const INTERNALS$2 = Symbol('Request internals'); + +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url__default['default'].parse; +const format_url = Url__default['default'].format; + +const streamDestructionSupported = 'destroy' in Stream__default['default'].Readable.prototype; + +/** + * Check if a value is an instance of Request. + * + * @param Mixed input + * @return Boolean + */ +function isRequest(input) { + return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; +} + +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); +} + +/** + * Request class + * + * @param Mixed input Url or Request instance + * @param Object init Custom options + * @return Void + */ +class Request { + constructor(input) { + let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + let parsedURL; + + // normalize input + if (!isRequest(input)) { + if (input && input.href) { + // in order to support Node.js' Url objects; though WHATWG's URL objects + // will fall into this branch also (since their `toString()` will return + // `href` property anyway) + parsedURL = parse_url(input.href); + } else { + // coerce input to a string before attempting to parse + parsedURL = parse_url(`${input}`); + } + input = {}; + } else { + parsedURL = parse_url(input.url); + } + + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); + + if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { + throw new TypeError('Request with GET/HEAD method cannot have body'); + } + + let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; + + Body.call(this, inputBody, { + timeout: init.timeout || input.timeout || 0, + size: init.size || input.size || 0 + }); + + const headers = new Headers(init.headers || input.headers || {}); + + if (inputBody != null && !headers.has('Content-Type')) { + const contentType = extractContentType(inputBody); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + let signal = isRequest(input) ? input.signal : null; + if ('signal' in init) signal = init.signal; + + if (signal != null && !isAbortSignal(signal)) { + throw new TypeError('Expected signal to be an instanceof AbortSignal'); + } + + this[INTERNALS$2] = { + method, + redirect: init.redirect || input.redirect || 'follow', + headers, + parsedURL, + signal + }; + + // node-fetch-only options + this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; + this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; + this.counter = init.counter || input.counter || 0; + this.agent = init.agent || input.agent; + } + + get method() { + return this[INTERNALS$2].method; + } + + get url() { + return format_url(this[INTERNALS$2].parsedURL); + } + + get headers() { + return this[INTERNALS$2].headers; + } + + get redirect() { + return this[INTERNALS$2].redirect; + } + + get signal() { + return this[INTERNALS$2].signal; + } + + /** + * Clone this request + * + * @return Request + */ + clone() { + return new Request(this); + } +} + +Body.mixIn(Request.prototype); + +Object.defineProperty(Request.prototype, Symbol.toStringTag, { + value: 'Request', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Request.prototype, { + method: { enumerable: true }, + url: { enumerable: true }, + headers: { enumerable: true }, + redirect: { enumerable: true }, + clone: { enumerable: true }, + signal: { enumerable: true } +}); + +/** + * Convert a Request to Node.js http request options. + * + * @param Request A Request instance + * @return Object The options object to be passed to http.request + */ +function getNodeRequestOptions(request) { + const parsedURL = request[INTERNALS$2].parsedURL; + const headers = new Headers(request[INTERNALS$2].headers); + + // fetch step 1.3 + if (!headers.has('Accept')) { + headers.set('Accept', '*/*'); + } + + // Basic fetch + if (!parsedURL.protocol || !parsedURL.hostname) { + throw new TypeError('Only absolute URLs are supported'); + } + + if (!/^https?:$/.test(parsedURL.protocol)) { + throw new TypeError('Only HTTP(S) protocols are supported'); + } + + if (request.signal && request.body instanceof Stream__default['default'].Readable && !streamDestructionSupported) { + throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); + } + + // HTTP-network-or-cache fetch steps 2.4-2.7 + let contentLengthValue = null; + if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { + contentLengthValue = '0'; + } + if (request.body != null) { + const totalBytes = getTotalBytes(request); + if (typeof totalBytes === 'number') { + contentLengthValue = String(totalBytes); + } + } + if (contentLengthValue) { + headers.set('Content-Length', contentLengthValue); + } + + // HTTP-network-or-cache fetch step 2.11 + if (!headers.has('User-Agent')) { + headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); + } + + // HTTP-network-or-cache fetch step 2.15 + if (request.compress && !headers.has('Accept-Encoding')) { + headers.set('Accept-Encoding', 'gzip,deflate'); + } + + let agent = request.agent; + if (typeof agent === 'function') { + agent = agent(parsedURL); + } + + if (!headers.has('Connection') && !agent) { + headers.set('Connection', 'close'); + } + + // HTTP-network fetch step 4.2 + // chunked encoding is handled by Node.js + + return Object.assign({}, parsedURL, { + method: request.method, + headers: exportNodeCompatibleHeaders(headers), + agent + }); +} + +/** + * abort-error.js + * + * AbortError interface for cancelled requests + */ + +/** + * Create AbortError instance + * + * @param String message Error message for human + * @return AbortError + */ +function AbortError(message) { + Error.call(this, message); + + this.type = 'aborted'; + this.message = message; + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +AbortError.prototype = Object.create(Error.prototype); +AbortError.prototype.constructor = AbortError; +AbortError.prototype.name = 'AbortError'; + +// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 +const PassThrough$1 = Stream__default['default'].PassThrough; +const resolve_url = Url__default['default'].resolve; + +/** + * Fetch function + * + * @param Mixed url Absolute url or Request instance + * @param Object opts Fetch options + * @return Promise + */ +function fetch(url, opts) { + + // allow custom promise + if (!fetch.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } + + Body.Promise = fetch.Promise; + + // wrap http.request into fetch + return new fetch.Promise(function (resolve, reject) { + // build request object + const request = new Request(url, opts); + const options = getNodeRequestOptions(request); + + const send = (options.protocol === 'https:' ? https__default['default'] : http__default['default']).request; + const signal = request.signal; + + let response = null; + + const abort = function abort() { + let error = new AbortError('The user aborted a request.'); + reject(error); + if (request.body && request.body instanceof Stream__default['default'].Readable) { + request.body.destroy(error); + } + if (!response || !response.body) return; + response.body.emit('error', error); + }; + + if (signal && signal.aborted) { + abort(); + return; + } + + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; + + // send request + const req = send(options); + let reqTimeout; + + if (signal) { + signal.addEventListener('abort', abortAndFinalize); + } + + function finalize() { + req.abort(); + if (signal) signal.removeEventListener('abort', abortAndFinalize); + clearTimeout(reqTimeout); + } + + if (request.timeout) { + req.once('socket', function (socket) { + reqTimeout = setTimeout(function () { + reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); + finalize(); + }, request.timeout); + }); + } + + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + finalize(); + }); + + req.on('response', function (res) { + clearTimeout(reqTimeout); + + const headers = createHeadersLenient(res.headers); + + // HTTP fetch step 5 + if (fetch.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); + + // HTTP fetch step 5.3 + const locationURL = location === null ? null : resolve_url(request.url, location); + + // HTTP fetch step 5.5 + switch (request.redirect) { + case 'error': + reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); + finalize(); + return; + case 'manual': + // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. + if (locationURL !== null) { + // handle corrupted header + try { + headers.set('Location', locationURL); + } catch (err) { + // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request + reject(err); + } + } + break; + case 'follow': + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } + + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOpts = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: request.body, + signal: request.signal, + timeout: request.timeout, + size: request.size + }; + + // HTTP-redirect fetch step 9 + if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { + reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 11 + if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { + requestOpts.method = 'GET'; + requestOpts.body = undefined; + requestOpts.headers.delete('content-length'); + } + + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOpts))); + finalize(); + return; + } + } + + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); + + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter + }; + + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); + + // HTTP-network fetch step 12.1.1.4: handle content codings + + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { + response = new Response(body, response_options); + resolve(response); + return; + } + + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib__default['default'].Z_SYNC_FLUSH, + finishFlush: zlib__default['default'].Z_SYNC_FLUSH + }; + + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib__default['default'].createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); + return; + } + + // for deflate + if (codings == 'deflate' || codings == 'x-deflate') { + // handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = res.pipe(new PassThrough$1()); + raw.once('data', function (chunk) { + // see http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0F) === 0x08) { + body = body.pipe(zlib__default['default'].createInflate()); + } else { + body = body.pipe(zlib__default['default'].createInflateRaw()); + } + response = new Response(body, response_options); + resolve(response); + }); + return; + } + + // for br + if (codings == 'br' && typeof zlib__default['default'].createBrotliDecompress === 'function') { + body = body.pipe(zlib__default['default'].createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; + } + + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); + }); + + writeToStream(req, request); + }); +} +/** + * Redirect code matching + * + * @param Number code Status code + * @return Boolean + */ +fetch.isRedirect = function (code) { + return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; +}; + +// expose Promise +fetch.Promise = global.Promise; + +function noop() { } +function safe_not_equal(a, b) { + return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} + +const subscriber_queue = []; +/** + * Creates a `Readable` store that allows reading by subscription. + * @param value initial value + * @param {StartStopNotifier}start start and stop notifications for subscriptions + */ +function readable(value, start) { + return { + subscribe: writable(value, start).subscribe + }; +} +/** + * Create a `Writable` store that allows both updating and reading by subscription. + * @param {*=}value initial value + * @param {StartStopNotifier=}start start and stop notifications for subscriptions + */ +function writable(value, start = noop) { + let stop; + const subscribers = []; + function set(new_value) { + if (safe_not_equal(value, new_value)) { + value = new_value; + if (stop) { // store is ready + const run_queue = !subscriber_queue.length; + for (let i = 0; i < subscribers.length; i += 1) { + const s = subscribers[i]; + s[1](); + subscriber_queue.push(s, value); + } + if (run_queue) { + for (let i = 0; i < subscriber_queue.length; i += 2) { + subscriber_queue[i][0](subscriber_queue[i + 1]); + } + subscriber_queue.length = 0; + } + } + } + } + function update(fn) { + set(fn(value)); + } + function subscribe(run, invalidate = noop) { + const subscriber = [run, invalidate]; + subscribers.push(subscriber); + if (subscribers.length === 1) { + stop = start(set) || noop; + } + run(value); + return () => { + const index = subscribers.indexOf(subscriber); + if (index !== -1) { + subscribers.splice(index, 1); + } + if (subscribers.length === 0) { + stop(); + stop = null; + } + }; + } + return { set, update, subscribe }; +} + +const noop$1 = () => {}; + +async function render_page( + request, + context, + options, + status = 200, + error = null +) { + let redirected; + let preload_error; + + const page = options.manifest.pages.find((page) => + page.pattern.test(request.path) + ); + + const baseUrl = ''; // TODO + + const session = await (options.setup.getSession && options.setup.getSession(context)); + + const serialized_session = try_serialize(session, (err) => { + throw new Error(`Failed to serialize session data: ${err.message}`); + }); + + try { + if (!page) { + const error = new Error(`Not found: ${request.path}`); + error.status = 404; + throw error; + } + + const segments = request.path.split('/').filter(Boolean); + + // TODO make this less confusing + const layout_segments = [segments[0]]; + let l = 1; + + page.parts.forEach((part, i) => { + layout_segments[l] = segments[i + 1]; + if (!part) return; + l++; + }); + + const dependencies = {}; + + const preload_context = { + redirect: (status, location) => { + if ( + redirected && + (redirected.status !== status || redirected.headers.location !== location) + ) { + throw new Error('Conflicting redirects'); + } + location = location.replace(/^\//g, ''); // leading slash (only) + redirected = { + status, + headers: { location }, + body: null, + dependencies: {} + }; + }, + error: (status, error) => { + if (typeof error === 'string') { + error = new Error(error); + } + preload_error = { ...error, status }; + }, + fetch: async (url, opts = {}) => { + const parsed = Url.parse(url); + + if (parsed.protocol) { + // external fetch + return fetch(parsed.href, opts); + } + + // otherwise we're dealing with an internal fetch. TODO there's + // probably no advantage to using fetch here — we should replace + // `this.fetch` with `this.load` or whatever + + const resolved = Url.resolve(request.path, parsed.pathname); + + // edge case — fetching a static file + const candidates = [ + `${options.static_dir}${resolved}`, + `${options.static_dir}${resolved}/index.html` + ]; + for (const file of candidates) { + if (fs.existsSync(file)) { + return new Response(fs.createReadStream(file), { + headers: { + 'content-type': mime.getType(file) + } + }); + } + } + + // TODO this doesn't take account of opts.body + const rendered = await render( + { + host: request.host, + method: opts.method || 'GET', + headers: opts.headers || {}, // TODO inject credentials... + path: resolved, + body: opts.body, + query: new Url.URLSearchParams(parsed.query || '') + }, + options + ); + + if (rendered) { + // TODO this is primarily for the benefit of the static case, + // but could it be used elsewhere? + dependencies[resolved] = rendered; + + return new Response(rendered.body, { + status: rendered.status, + headers: rendered.headers + }); + } else { + return new Response('Not found', { + status: 404 + }); + } + } + }; + + const match = page.pattern.exec(request.path); + + // the last part has all parameters from any segment in the URL + const params = parts_to_params(match, page.parts[page.parts.length - 1] ); + + const preloaded = []; + let can_prerender = true; + + const parts = await Promise.all( + [{ component: options.manifest.layout, params: [] }, ...page.parts].map(async (part, i) => { + if (!part) return null; + + const mod = await options.load(part.component); + + if (options.only_prerender && !mod.prerender) { + can_prerender = false; + return; + } + + // these are only the parameters up to the current URL segment + const params = parts_to_params(match, part); + + const props = mod.preload + ? await mod.preload.call( + preload_context, + { + host: request.host, + path: request.path, + query: request.query, + params + }, + session + ) + : {}; + + preloaded[i] = props; + return { component: mod.default, props }; + }) + ); + + if (options.only_prerender && !can_prerender) return; + + if (preload_error) throw preload_error; + if (redirected) return redirected; + + const branches = []; + parts.forEach((part, i) => { + if (part) { + branches.push({ + component: part.component, + props: preloaded[i], + segment: segments[i] + }); + } + }); + + const pageContext = { + host: request.host , + path: request.path, + query: search_params_to_map(request.query), + params, + error: error || undefined + }; + + const props = { + status, + error, + stores: { + page: readable(pageContext, noop$1), + preloading: readable(null, noop$1), + session: writable(session) + }, + // TODO stores, status, segments, notify, CONTEXT_KEY + segments: layout_segments, + branches, + level0: { + props: preloaded[0] + }, + level1: { + segment: segments[0], + props: {} + } + }; + + // TODO this is highly confusing. replace the leveln thing with an array of branches + l = 1; + for (let i = 1; i < parts.length; i += 1) { + const part = parts[i]; + if (!part) continue; + + props[`level${l++}`] = { + component: part.component, + props: preloaded[i] || {}, + segment: segments[i] + }; + } + + const serialized_preloads = `[${preloaded + .map((data) => + try_serialize(data, (err) => { + const path = '/' + segments.join('/'); + console.error( + `Failed to serialize preloaded data to transmit to the client at the ${path} route: ${err.message}` + ); + console.warn( + 'The client will re-render over the server-rendered page fresh instead of continuing where it left off. See https://sapper.svelte.dev/docs#Return_value for more information' + ); + }) + ) + .join(',')}]`; + + const rendered = options.root.default.render(props); + + const deps = options.client.deps; + const js_deps = new Set(deps.__entry__ ? [...deps.__entry__.js] : []); + const css_deps = new Set(deps.__entry__ ? [...deps.__entry__.css] : []); + + (page.parts.filter(Boolean) ).forEach((part) => { + const page_deps = deps[part.component.name]; + + if (!page_deps) return; // we don't have this info during dev + + page_deps.js.forEach((dep) => js_deps.add(dep)); + page_deps.css.forEach((dep) => css_deps.add(dep)); + }); + + const head = `${rendered.head} + + ${Array.from(js_deps) + .map((dep) => ``) + .join('\n\t\t\t')} + ${Array.from(css_deps) + .map((dep) => ``) + .join('\n\t\t\t')} + ${options.dev ? `` : ''} + + `.replace(/^\t{2}/gm, ''); // TODO add links + + const body = `${rendered.html} + `.replace(/^\t{3}/gm, ''); + + const html = options.template.replace('%svelte.head%', head).replace('%svelte.body%', body); + + return { + status: 200, + headers: { + 'content-type': 'text/html' + }, + body: html, + dependencies + }; + } catch (thrown) { + console.error(thrown.stack); + + if (!error) { + const status = thrown.status || 500; + return render_page(request, context, options, status, thrown); + } else { + // oh lawd now you've done it + return { + status: 500, + headers: {}, + body: thrown.stack, // TODO probably not in prod? + dependencies: {} + }; + } + } +} + +function parts_to_params(match, part) { + const params = {}; + + part.params.forEach((name, i) => { + const is_spread = /^\.{3}.+$/.test(name); + + if (is_spread) { + params[name.slice(3)] = match[i + 1].split('/'); + } else { + params[name] = match[i + 1]; + } + }); + + return params; +} + +function try_serialize(data, fail) { + try { + return devalue(data); + } catch (err) { + if (fail) fail(err); + return null; + } +} + +// Ensure we return something truthy so the client will not re-render the page over the error +function serialize_error(error) { + if (!error) return null; + let serialized = try_serialize(error); + if (!serialized) { + const { name, message, stack } = error; + serialized = try_serialize({ name, message, stack }); + } + if (!serialized) { + serialized = '{}'; + } + return serialized; +} + +function search_params_to_map(params) { + const map = {}; + + for (const key of params.keys()) { + const values = params.getAll(key); + + map[key] = values.length > 1 ? values : values[0]; + } + + return map; +} + +function render_route( + request, + context, + options +) { + const route = options.manifest.endpoints.find((route) => + route.pattern.test(request.path) + ); + if (!route) return null; + + return Promise.resolve(options.load(route)).then(async (mod) => { + const handler = mod[request.method.toLowerCase().replace('delete', 'del')]; // 'delete' is a reserved word + + if (handler) { + const params = {}; + const match = route.pattern.exec(request.path); + route.params.forEach((name, i) => { + params[name] = match[i + 1]; + }); + + try { + let { status = 200, body, headers = {} } = await handler( + { + host: request.host, + path: request.path, + query: request.query, + body: request.body, + params + }, + context + ); + + headers = lowercase_keys(headers); + + if ( + (typeof body === 'object' && !('content-type' in headers)) || + headers['content-type'] === 'application/json' + ) { + headers = { ...headers, 'content-type': 'application/json' }; + body = JSON.stringify(body); + } + + return { status, body, headers }; + } catch (err) { + return { + status: 500, + body: err.message, + headers: {} + }; + } + } else { + return { + status: 501, + body: `${request.method} is not implemented for ${request.path}`, + headers: {} + }; + } + }); +} + +function lowercase_keys(obj) { + const clone = {}; + for (const key in obj) { + clone[key.toLowerCase()] = obj[key]; + } + return clone; +} + +function md5(body) { + return crypto.createHash('md5').update(body).digest('hex'); +} + +async function render( + request, + options +) { + const { context, headers = {} } = (await (options.setup.prepare && options.setup.prepare(request.headers))) || {}; + + try { + const response = await (render_route(request, context, options) || + render_page(request, context, options)); + + if (response) { + // inject ETags for 200 responses + if (response.status === 200) { + if (!/(no-store|immutable)/.test(response.headers['cache-control'])) { + const etag = `"${md5(response.body)}"`; + + if (request.headers['if-none-match'] === etag) { + return { + status: 304, + headers: {}, + body: null + }; + } + + response.headers['etag'] = etag; + } + } + + return { + status: response.status, + headers: { ...headers, ...response.headers }, + body: response.body + }; + } + } catch (err) { + return { + status: 500, + headers: {}, + body: options.dev ? err.stack : err.message + }; + } +} + +const manifest = require('./manifest.js'); +const client = require('./client.json'); +const root = require('./root.js'); +const setup = require('./setup.js'); +const template = require('./template.js'); + +// TODO this is a generic AWS lambda handler, and could be +// reused by other adapters + +const handler = async (event) => { + const { + path, + httpMethod, + headers, + queryStringParameters + // body, // TODO pass this to renderer + // isBase64Encoded // TODO is this useful? + } = event; + + const query = new Url.URLSearchParams(); + for (const k in queryStringParameters) { + const value = queryStringParameters[k]; + value.split(', ').forEach((v) => { + query.append(k, v); + }); + } + + const rendered = await render( + { + host: null, // TODO + method: httpMethod, + headers, + path, + query + }, + { + static_dir: 'static', + template, + manifest, + client, + root, + setup, + load: (route) => + require(`./routes/${route.name}.js`), + dev: false, + only_prerender: false + } + ); + + if (rendered) { + return { + isBase64Encoded: false, + statusCode: rendered.status, + headers: rendered.headers, + body: rendered.body + }; + } + + return { + statusCode: 404, + body: 'Not found' + }; +}; + +exports.handler = handler; diff --git a/packages/adapter-netlify/rollup.config.js b/packages/adapter-netlify/rollup.config.js index 4fece9aa4a88..f4d29d931e4b 100644 --- a/packages/adapter-netlify/rollup.config.js +++ b/packages/adapter-netlify/rollup.config.js @@ -1,23 +1,12 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; -export default [ - { - input: 'src/index.js', - output: { - file: 'index.js', - format: 'cjs' - }, - plugins: [nodeResolve(), commonjs()], - external: require('module').builtinModules +export default { + input: 'src/render.js', + output: { + file: 'files/render.js', + format: 'cjs' }, - { - input: 'src/render.js', - output: { - file: 'render.js', - format: 'cjs' - }, - plugins: [nodeResolve(), commonjs()], - external: require('module').builtinModules - } -]; + plugins: [nodeResolve(), commonjs()], + external: require('module').builtinModules +}; diff --git a/packages/adapter-netlify/src/index.js b/packages/adapter-netlify/src/index.js deleted file mode 100644 index 9c31ff7303f7..000000000000 --- a/packages/adapter-netlify/src/index.js +++ /dev/null @@ -1,91 +0,0 @@ -import fs from 'fs'; -import path from 'path'; -import toml from 'toml'; -import glob from 'tiny-glob/sync'; -import { mkdirp } from '@sveltejs/app-utils/files'; -import { prerender, generate_manifest_module } from '@sveltejs/app-utils/renderer'; - -module.exports = async function builder({ - dir, - manifest, - log -}) { - let netlify_config; - - if (fs.existsSync('netlify.toml')) { - try { - netlify_config = toml.parse(fs.readFileSync('netlify.toml', 'utf-8')); - } catch (err) { - err.message = `Error parsing netlify.toml: ${err.message}`; - throw err; - } - } else { - throw new Error( - 'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration' - ); - } - - if (!netlify_config.build || !netlify_config.build.publish || !netlify_config.build.functions) { - throw new Error( - 'You must specify build.publish and build.functions in netlify.toml. Consult https://github.com/sveltejs/adapter-netlify#configuration' - ); - } - - const publish = path.resolve(netlify_config.build.publish); - const functions = path.resolve(netlify_config.build.functions); - - mkdirp(`${publish}/_app`); - mkdirp(`${functions}/render`); - - // copy everything in `static` - glob('**/*', { cwd: 'static', filesOnly: true }).forEach((file) => { - mkdirp(path.dirname(`${publish}/${file}`)); - fs.copyFileSync(`static/${file}`, `${publish}/${file}`); - }); - - // copy client code - const client_code = path.resolve(dir, 'client'); - glob('**/*', { cwd: client_code, filesOnly: true }).forEach((file) => { - if (file[0] !== '.') { - mkdirp(path.dirname(`${publish}/_app/${file}`)); - fs.copyFileSync(`${client_code}/${file}`, `${publish}/_app/${file}`); - } - }); - - // prerender - log.info('Prerendering static pages...'); - await prerender({ - force: true, - dir, - out: publish, - manifest, - log - }); - - // copy server code - const server_code = path.resolve(dir, 'server'); - glob('**/*', { cwd: server_code, filesOnly: true }).forEach((file) => { - if (file[0] !== '.') { - mkdirp(path.dirname(`${functions}/render/${file}`)); - fs.copyFileSync(`${server_code}/${file}`, `${functions}/render/${file}`); - } - }); - - // copy the renderer - fs.copyFileSync(path.resolve(__dirname, 'render.js'), `${functions}/render/index.js`); - - // write manifest - fs.writeFileSync(`${functions}/render/manifest.js`, generate_manifest_module(manifest)); - - // copy client manifest - fs.copyFileSync(`${dir}/client.json`, `${functions}/render/client.json`); - - // copy template - fs.writeFileSync( - `${functions}/render/template.js`, - `module.exports = ${JSON.stringify(fs.readFileSync('src/app.html', 'utf-8'))};` - ); - - // create _redirects - fs.writeFileSync(`${publish}/_redirects`, '/* /.netlify/functions/render 200'); -}; diff --git a/packages/adapter-netlify/src/render.js b/packages/adapter-netlify/src/render.js index 015b4d308bf4..dabfdc254b7c 100644 --- a/packages/adapter-netlify/src/render.js +++ b/packages/adapter-netlify/src/render.js @@ -1,11 +1,6 @@ import { URLSearchParams } from 'url'; -import { render } from '@sveltejs/app-utils/renderer'; -const manifest = require('./manifest.js'); -const client = require('./client.json'); -const root = require('./root.js'); -const setup = require('./setup.js'); -const template = require('./template.js'); +const app = require('./app.js'); // TODO this is a generic AWS lambda handler, and could be // reused by other adapters @@ -28,27 +23,13 @@ export const handler = async (event) => { }); } - const rendered = await render( - { - host: null, // TODO - method: httpMethod, - headers, - path, - query - }, - { - static_dir: 'static', - template, - manifest, - client, - root, - setup, - load: (route) => - require(`./routes/${route.name}.js`), - dev: false, - only_prerender: false - } - ); + const rendered = await app.render({ + host: null, // TODO + method: httpMethod, + headers, + path, + query + }); if (rendered) { return { From b9c0b461394b103b1ed6673a7a95220c82d9f532 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 13:47:40 -0500 Subject: [PATCH 22/30] fixes --- packages/kit/src/api/build/index.js | 4 ++-- packages/kit/src/api/build/prerender.js | 5 ++++- packages/kit/src/api/dev/index.js | 4 ++-- packages/kit/src/api/dev/loader.js | 1 - 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/kit/src/api/build/index.js b/packages/kit/src/api/build/index.js index 8e4dc6e86532..3b2c7277499f 100644 --- a/packages/kit/src/api/build/index.js +++ b/packages/kit/src/api/build/index.js @@ -245,7 +245,7 @@ export async function build(config) { const client = ${s(client)}; - export function render(request) { + export function render(request, { only_prerender = false } = {}) { return renderer.render(request, { static_dir: 'static', template, @@ -255,7 +255,7 @@ export async function build(config) { setup, load: (route) => require(\`./routes/\${route.name}.js\`), dev: false, - only_prerender: false + only_prerender }); } `.replace(/^\t{3}/gm, '').trim()); diff --git a/packages/kit/src/api/build/prerender.js b/packages/kit/src/api/build/prerender.js index 98d98179fa55..9eb851a20fe5 100644 --- a/packages/kit/src/api/build/prerender.js +++ b/packages/kit/src/api/build/prerender.js @@ -46,7 +46,8 @@ export async function prerender({ dir, out, manifest, - log + log, + force }) { const seen = new Set(); @@ -64,6 +65,8 @@ export async function prerender({ path, body: null, query: new URLSearchParams() + }, { + only_prerender: !force }); if (rendered) { diff --git a/packages/kit/src/api/dev/index.js b/packages/kit/src/api/dev/index.js index 6992d57fb8c2..795bf4437efd 100644 --- a/packages/kit/src/api/dev/index.js +++ b/packages/kit/src/api/dev/index.js @@ -11,7 +11,7 @@ import snowpack from 'snowpack'; import pkg from '../../../package.json'; import loader from './loader'; import { mkdirp } from '@sveltejs/app-utils/files'; -import { render } from '@sveltejs/app-utils/renderer'; +import { render } from '../../renderer'; import { get_body } from '@sveltejs/app-utils/http'; import { copy_assets } from '../utils'; import { readFileSync } from 'fs'; @@ -134,7 +134,7 @@ class Watcher extends EventEmitter { let root; try { - root = await load('/_app/main/generated/root.js'); + root = (await load('/_app/main/generated/root.js')).default; } catch (e) { res.statusCode = 500; res.end(e.toString()); diff --git a/packages/kit/src/api/dev/loader.js b/packages/kit/src/api/dev/loader.js index e65d6a859bd8..d07e2b08fb73 100644 --- a/packages/kit/src/api/dev/loader.js +++ b/packages/kit/src/api/dev/loader.js @@ -67,7 +67,6 @@ export default function loader(snowpack, config) { .then((result) => initialize_module(url, result.contents, url_stack.concat(url))) .catch((e) => { cache.delete(url); - console.error(e); throw e; }); From 5efcdfc910d0f6fcadf31fc61ce38ac8b8fcd3a8 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 13:47:50 -0500 Subject: [PATCH 23/30] simplify adapter-netlify --- packages/adapter-netlify/.gitignore | 3 +- .../adapter-netlify/{src => files}/render.js | 12 +- packages/adapter-netlify/index.js | 11 +- packages/adapter-netlify/package.json | 13 +- packages/adapter-netlify/render.js | 2583 ----------------- packages/adapter-netlify/rollup.config.js | 12 - 6 files changed, 15 insertions(+), 2619 deletions(-) rename packages/adapter-netlify/{src => files}/render.js (76%) delete mode 100644 packages/adapter-netlify/render.js delete mode 100644 packages/adapter-netlify/rollup.config.js diff --git a/packages/adapter-netlify/.gitignore b/packages/adapter-netlify/.gitignore index 1f664acc2b82..91dfed8d4a8b 100644 --- a/packages/adapter-netlify/.gitignore +++ b/packages/adapter-netlify/.gitignore @@ -1,3 +1,2 @@ .DS_Store -node_modules -/files \ No newline at end of file +node_modules \ No newline at end of file diff --git a/packages/adapter-netlify/src/render.js b/packages/adapter-netlify/files/render.js similarity index 76% rename from packages/adapter-netlify/src/render.js rename to packages/adapter-netlify/files/render.js index dabfdc254b7c..25f9fc1f4f08 100644 --- a/packages/adapter-netlify/src/render.js +++ b/packages/adapter-netlify/files/render.js @@ -1,11 +1,9 @@ -import { URLSearchParams } from 'url'; +'use strict'; +const url = require('url'); const app = require('./app.js'); -// TODO this is a generic AWS lambda handler, and could be -// reused by other adapters - -export const handler = async (event) => { +exports.handler = async (event) => { const { path, httpMethod, @@ -15,7 +13,7 @@ export const handler = async (event) => { // isBase64Encoded // TODO is this useful? } = event; - const query = new URLSearchParams(); + const query = new url.URLSearchParams(); for (const k in queryStringParameters) { const value = queryStringParameters[k]; value.split(', ').forEach((v) => { @@ -44,4 +42,4 @@ export const handler = async (event) => { statusCode: 404, body: 'Not found' }; -}; +}; \ No newline at end of file diff --git a/packages/adapter-netlify/index.js b/packages/adapter-netlify/index.js index 387df4423a8b..97b617cdc320 100644 --- a/packages/adapter-netlify/index.js +++ b/packages/adapter-netlify/index.js @@ -1,6 +1,8 @@ -import fs from 'fs'; -import path from 'path'; -import toml from 'toml'; +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const toml = require('toml'); module.exports = async function adapter(builder) { let netlify_config; @@ -13,6 +15,7 @@ module.exports = async function adapter(builder) { throw err; } } else { + // TODO offer to create one? throw new Error( 'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration' ); @@ -32,7 +35,7 @@ module.exports = async function adapter(builder) { builder.copy_server_files(`${functions}/render`); // copy the renderer - fs.copyFileSync(path.resolve(__dirname, 'render.js'), `${functions}/render/index.js`); + fs.copyFileSync(path.resolve(__dirname, 'files/render.js'), `${functions}/render/index.js`); // create _redirects fs.writeFileSync(`${publish}/_redirects`, '/* /.netlify/functions/render 200'); diff --git a/packages/adapter-netlify/package.json b/packages/adapter-netlify/package.json index 9be7b46734a6..fffaf9770416 100644 --- a/packages/adapter-netlify/package.json +++ b/packages/adapter-netlify/package.json @@ -1,23 +1,14 @@ { "name": "@sveltejs/adapter-netlify", "version": "0.0.11", - "devDependencies": { - "@sveltejs/app-utils": "workspace:*", - "@types/aws-lambda": "^8.10.64", - "devalue": "^2.0.1", - "rollup": "^2.32.0" - }, "main": "index.js", "files": [ - "render.js" + "files" ], "scripts": { - "dev": "rollup -cw", - "build": "rollup -c", "lint": "eslint --ignore-pattern node_modules/ --ignore-pattern render.js \"**/*.{ts,js,svelte}\" && npm run check-format", "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore", - "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", - "prepublishOnly": "npm run build" + "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore" }, "dependencies": { "toml": "^3.0.0" diff --git a/packages/adapter-netlify/render.js b/packages/adapter-netlify/render.js deleted file mode 100644 index 6baf9ac14437..000000000000 --- a/packages/adapter-netlify/render.js +++ /dev/null @@ -1,2583 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var Url = require('url'); -var fs = require('fs'); -require('path'); -var crypto = require('crypto'); -var Stream = require('stream'); -var http = require('http'); -var https = require('https'); -var zlib = require('zlib'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var Url__default = /*#__PURE__*/_interopDefaultLegacy(Url); -var Stream__default = /*#__PURE__*/_interopDefaultLegacy(Stream); -var http__default = /*#__PURE__*/_interopDefaultLegacy(http); -var https__default = /*#__PURE__*/_interopDefaultLegacy(https); -var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib); - -/** - * @param typeMap [Object] Map of MIME type -> Array[extensions] - * @param ... - */ -function Mime() { - this._types = Object.create(null); - this._extensions = Object.create(null); - - for (var i = 0; i < arguments.length; i++) { - this.define(arguments[i]); - } - - this.define = this.define.bind(this); - this.getType = this.getType.bind(this); - this.getExtension = this.getExtension.bind(this); -} - -/** - * Define mimetype -> extension mappings. Each key is a mime-type that maps - * to an array of extensions associated with the type. The first extension is - * used as the default extension for the type. - * - * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); - * - * If a type declares an extension that has already been defined, an error will - * be thrown. To suppress this error and force the extension to be associated - * with the new type, pass `force`=true. Alternatively, you may prefix the - * extension with "*" to map the type to extension, without mapping the - * extension to the type. - * - * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']}); - * - * - * @param map (Object) type definitions - * @param force (Boolean) if true, force overriding of existing definitions - */ -Mime.prototype.define = function(typeMap, force) { - for (var type in typeMap) { - var extensions = typeMap[type].map(function(t) {return t.toLowerCase()}); - type = type.toLowerCase(); - - for (var i = 0; i < extensions.length; i++) { - var ext = extensions[i]; - - // '*' prefix = not the preferred type for this extension. So fixup the - // extension, and skip it. - if (ext[0] == '*') { - continue; - } - - if (!force && (ext in this._types)) { - throw new Error( - 'Attempt to change mapping for "' + ext + - '" extension from "' + this._types[ext] + '" to "' + type + - '". Pass `force=true` to allow this, otherwise remove "' + ext + - '" from the list of extensions for "' + type + '".' - ); - } - - this._types[ext] = type; - } - - // Use first extension as default - if (force || !this._extensions[type]) { - var ext = extensions[0]; - this._extensions[type] = (ext[0] != '*') ? ext : ext.substr(1); - } - } -}; - -/** - * Lookup a mime type based on extension - */ -Mime.prototype.getType = function(path) { - path = String(path); - var last = path.replace(/^.*[/\\]/, '').toLowerCase(); - var ext = last.replace(/^.*\./, '').toLowerCase(); - - var hasPath = last.length < path.length; - var hasDot = ext.length < last.length - 1; - - return (hasDot || !hasPath) && this._types[ext] || null; -}; - -/** - * Return file extension associated with a mime type - */ -Mime.prototype.getExtension = function(type) { - type = /^\s*([^;\s]*)/.test(type) && RegExp.$1; - return type && this._extensions[type.toLowerCase()] || null; -}; - -var Mime_1 = Mime; - -var standard = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/urc-ressheet+xml":["rsheet"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["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/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"],"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/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/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/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/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"]}; - -var other = {"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":["keynote"],"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.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}; - -var mime = new Mime_1(standard, other); - -var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'; -var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g; -var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/; -var escaped = { - '<': '\\u003C', - '>': '\\u003E', - '/': '\\u002F', - '\\': '\\\\', - '\b': '\\b', - '\f': '\\f', - '\n': '\\n', - '\r': '\\r', - '\t': '\\t', - '\0': '\\0', - '\u2028': '\\u2028', - '\u2029': '\\u2029' -}; -var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join('\0'); -function devalue(value) { - var counts = new Map(); - function walk(thing) { - if (typeof thing === 'function') { - throw new Error("Cannot stringify a function"); - } - if (counts.has(thing)) { - counts.set(thing, counts.get(thing) + 1); - return; - } - counts.set(thing, 1); - if (!isPrimitive(thing)) { - var type = getType(thing); - switch (type) { - case 'Number': - case 'String': - case 'Boolean': - case 'Date': - case 'RegExp': - return; - case 'Array': - thing.forEach(walk); - break; - case 'Set': - case 'Map': - Array.from(thing).forEach(walk); - break; - default: - var proto = Object.getPrototypeOf(thing); - if (proto !== Object.prototype && - proto !== null && - Object.getOwnPropertyNames(proto).sort().join('\0') !== objectProtoOwnPropertyNames) { - throw new Error("Cannot stringify arbitrary non-POJOs"); - } - if (Object.getOwnPropertySymbols(thing).length > 0) { - throw new Error("Cannot stringify POJOs with symbolic keys"); - } - Object.keys(thing).forEach(function (key) { return walk(thing[key]); }); - } - } - } - walk(value); - var names = new Map(); - Array.from(counts) - .filter(function (entry) { return entry[1] > 1; }) - .sort(function (a, b) { return b[1] - a[1]; }) - .forEach(function (entry, i) { - names.set(entry[0], getName(i)); - }); - function stringify(thing) { - if (names.has(thing)) { - return names.get(thing); - } - if (isPrimitive(thing)) { - return stringifyPrimitive(thing); - } - var type = getType(thing); - switch (type) { - case 'Number': - case 'String': - case 'Boolean': - return "Object(" + stringify(thing.valueOf()) + ")"; - case 'RegExp': - return "new RegExp(" + stringifyString(thing.source) + ", \"" + thing.flags + "\")"; - case 'Date': - return "new Date(" + thing.getTime() + ")"; - case 'Array': - var members = thing.map(function (v, i) { return i in thing ? stringify(v) : ''; }); - var tail = thing.length === 0 || (thing.length - 1 in thing) ? '' : ','; - return "[" + members.join(',') + tail + "]"; - case 'Set': - case 'Map': - return "new " + type + "([" + Array.from(thing).map(stringify).join(',') + "])"; - default: - var obj = "{" + Object.keys(thing).map(function (key) { return safeKey(key) + ":" + stringify(thing[key]); }).join(',') + "}"; - var proto = Object.getPrototypeOf(thing); - if (proto === null) { - return Object.keys(thing).length > 0 - ? "Object.assign(Object.create(null)," + obj + ")" - : "Object.create(null)"; - } - return obj; - } - } - var str = stringify(value); - if (names.size) { - var params_1 = []; - var statements_1 = []; - var values_1 = []; - names.forEach(function (name, thing) { - params_1.push(name); - if (isPrimitive(thing)) { - values_1.push(stringifyPrimitive(thing)); - return; - } - var type = getType(thing); - switch (type) { - case 'Number': - case 'String': - case 'Boolean': - values_1.push("Object(" + stringify(thing.valueOf()) + ")"); - break; - case 'RegExp': - values_1.push(thing.toString()); - break; - case 'Date': - values_1.push("new Date(" + thing.getTime() + ")"); - break; - case 'Array': - values_1.push("Array(" + thing.length + ")"); - thing.forEach(function (v, i) { - statements_1.push(name + "[" + i + "]=" + stringify(v)); - }); - break; - case 'Set': - values_1.push("new Set"); - statements_1.push(name + "." + Array.from(thing).map(function (v) { return "add(" + stringify(v) + ")"; }).join('.')); - break; - case 'Map': - values_1.push("new Map"); - statements_1.push(name + "." + Array.from(thing).map(function (_a) { - var k = _a[0], v = _a[1]; - return "set(" + stringify(k) + ", " + stringify(v) + ")"; - }).join('.')); - break; - default: - values_1.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'); - Object.keys(thing).forEach(function (key) { - statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key])); - }); - } - }); - statements_1.push("return " + str); - return "(function(" + params_1.join(',') + "){" + statements_1.join(';') + "}(" + values_1.join(',') + "))"; - } - else { - return str; - } -} -function getName(num) { - var name = ''; - do { - name = chars[num % chars.length] + name; - num = ~~(num / chars.length) - 1; - } while (num >= 0); - return reserved.test(name) ? name + "_" : name; -} -function isPrimitive(thing) { - return Object(thing) !== thing; -} -function stringifyPrimitive(thing) { - if (typeof thing === 'string') - return stringifyString(thing); - if (thing === void 0) - return 'void 0'; - if (thing === 0 && 1 / thing < 0) - return '-0'; - var str = String(thing); - if (typeof thing === 'number') - return str.replace(/^(-)?0\./, '$1.'); - return str; -} -function getType(thing) { - return Object.prototype.toString.call(thing).slice(8, -1); -} -function escapeUnsafeChar(c) { - return escaped[c] || c; -} -function escapeUnsafeChars(str) { - return str.replace(unsafeChars, escapeUnsafeChar); -} -function safeKey(key) { - return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key)); -} -function safeProp(key) { - return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]"; -} -function stringifyString(str) { - var result = '"'; - for (var i = 0; i < str.length; i += 1) { - var char = str.charAt(i); - var code = char.charCodeAt(0); - if (char === '"') { - result += '\\"'; - } - else if (char in escaped) { - result += escaped[char]; - } - else if (code >= 0xd800 && code <= 0xdfff) { - var next = str.charCodeAt(i + 1); - // If this is the beginning of a [high, low] surrogate pair, - // add the next two characters, otherwise escape - if (code <= 0xdbff && (next >= 0xdc00 && next <= 0xdfff)) { - result += char + str[++i]; - } - else { - result += "\\u" + code.toString(16).toUpperCase(); - } - } - else { - result += char; - } - } - result += '"'; - return result; -} - -// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js - -// fix for "Readable" isn't a named export issue -const Readable = Stream__default['default'].Readable; - -const BUFFER = Symbol('buffer'); -const TYPE = Symbol('type'); - -class Blob { - constructor() { - this[TYPE] = ''; - - const blobParts = arguments[0]; - const options = arguments[1]; - - const buffers = []; - let size = 0; - - if (blobParts) { - const a = blobParts; - const length = Number(a.length); - for (let i = 0; i < length; i++) { - const element = a[i]; - let buffer; - if (element instanceof Buffer) { - buffer = element; - } else if (ArrayBuffer.isView(element)) { - buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); - } else if (element instanceof ArrayBuffer) { - buffer = Buffer.from(element); - } else if (element instanceof Blob) { - buffer = element[BUFFER]; - } else { - buffer = Buffer.from(typeof element === 'string' ? element : String(element)); - } - size += buffer.length; - buffers.push(buffer); - } - } - - this[BUFFER] = Buffer.concat(buffers); - - let type = options && options.type !== undefined && String(options.type).toLowerCase(); - if (type && !/[^\u0020-\u007E]/.test(type)) { - this[TYPE] = type; - } - } - get size() { - return this[BUFFER].length; - } - get type() { - return this[TYPE]; - } - text() { - return Promise.resolve(this[BUFFER].toString()); - } - arrayBuffer() { - const buf = this[BUFFER]; - const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - return Promise.resolve(ab); - } - stream() { - const readable = new Readable(); - readable._read = function () {}; - readable.push(this[BUFFER]); - readable.push(null); - return readable; - } - toString() { - return '[object Blob]'; - } - slice() { - const size = this.size; - - const start = arguments[0]; - const end = arguments[1]; - let relativeStart, relativeEnd; - if (start === undefined) { - relativeStart = 0; - } else if (start < 0) { - relativeStart = Math.max(size + start, 0); - } else { - relativeStart = Math.min(start, size); - } - if (end === undefined) { - relativeEnd = size; - } else if (end < 0) { - relativeEnd = Math.max(size + end, 0); - } else { - relativeEnd = Math.min(end, size); - } - const span = Math.max(relativeEnd - relativeStart, 0); - - const buffer = this[BUFFER]; - const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); - const blob = new Blob([], { type: arguments[2] }); - blob[BUFFER] = slicedBuffer; - return blob; - } -} - -Object.defineProperties(Blob.prototype, { - size: { enumerable: true }, - type: { enumerable: true }, - slice: { enumerable: true } -}); - -Object.defineProperty(Blob.prototype, Symbol.toStringTag, { - value: 'Blob', - writable: false, - enumerable: false, - configurable: true -}); - -/** - * fetch-error.js - * - * FetchError interface for operational errors - */ - -/** - * Create FetchError instance - * - * @param String message Error message for human - * @param String type Error type for machine - * @param String systemError For Node.js system error - * @return FetchError - */ -function FetchError(message, type, systemError) { - Error.call(this, message); - - this.message = message; - this.type = type; - - // when err.type is `system`, err.code contains system error code - if (systemError) { - this.code = this.errno = systemError.code; - } - - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); -} - -FetchError.prototype = Object.create(Error.prototype); -FetchError.prototype.constructor = FetchError; -FetchError.prototype.name = 'FetchError'; - -let convert; -try { - convert = require('encoding').convert; -} catch (e) {} - -const INTERNALS = Symbol('Body internals'); - -// fix an issue where "PassThrough" isn't a named export for node <10 -const PassThrough = Stream__default['default'].PassThrough; - -/** - * Body mixin - * - * Ref: https://fetch.spec.whatwg.org/#body - * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void - */ -function Body(body) { - var _this = this; - - var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref$size = _ref.size; - - let size = _ref$size === undefined ? 0 : _ref$size; - var _ref$timeout = _ref.timeout; - let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; - - if (body == null) { - // body is undefined or null - body = null; - } else if (isURLSearchParams(body)) { - // body is a URLSearchParams - body = Buffer.from(body.toString()); - } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { - // body is ArrayBuffer - body = Buffer.from(body); - } else if (ArrayBuffer.isView(body)) { - // body is ArrayBufferView - body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); - } else if (body instanceof Stream__default['default']) ; else { - // none of the above - // coerce to string then buffer - body = Buffer.from(String(body)); - } - this[INTERNALS] = { - body, - disturbed: false, - error: null - }; - this.size = size; - this.timeout = timeout; - - if (body instanceof Stream__default['default']) { - body.on('error', function (err) { - const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); - _this[INTERNALS].error = error; - }); - } -} - -Body.prototype = { - get body() { - return this[INTERNALS].body; - }, - - get bodyUsed() { - return this[INTERNALS].disturbed; - }, - - /** - * Decode response as ArrayBuffer - * - * @return Promise - */ - arrayBuffer() { - return consumeBody.call(this).then(function (buf) { - return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - }); - }, - - /** - * Return raw response as Blob - * - * @return Promise - */ - blob() { - let ct = this.headers && this.headers.get('content-type') || ''; - return consumeBody.call(this).then(function (buf) { - return Object.assign( - // Prevent copying - new Blob([], { - type: ct.toLowerCase() - }), { - [BUFFER]: buf - }); - }); - }, - - /** - * Decode response as json - * - * @return Promise - */ - json() { - var _this2 = this; - - return consumeBody.call(this).then(function (buffer) { - try { - return JSON.parse(buffer.toString()); - } catch (err) { - return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); - } - }); - }, - - /** - * Decode response as text - * - * @return Promise - */ - text() { - return consumeBody.call(this).then(function (buffer) { - return buffer.toString(); - }); - }, - - /** - * Decode response as buffer (non-spec api) - * - * @return Promise - */ - buffer() { - return consumeBody.call(this); - }, - - /** - * Decode response as text, while automatically detecting the encoding and - * trying to decode to UTF-8 (non-spec api) - * - * @return Promise - */ - textConverted() { - var _this3 = this; - - return consumeBody.call(this).then(function (buffer) { - return convertBody(buffer, _this3.headers); - }); - } -}; - -// In browsers, all properties are enumerable. -Object.defineProperties(Body.prototype, { - body: { enumerable: true }, - bodyUsed: { enumerable: true }, - arrayBuffer: { enumerable: true }, - blob: { enumerable: true }, - json: { enumerable: true }, - text: { enumerable: true } -}); - -Body.mixIn = function (proto) { - for (const name of Object.getOwnPropertyNames(Body.prototype)) { - // istanbul ignore else: future proof - if (!(name in proto)) { - const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); - Object.defineProperty(proto, name, desc); - } - } -}; - -/** - * Consume and convert an entire Body to a Buffer. - * - * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body - * - * @return Promise - */ -function consumeBody() { - var _this4 = this; - - if (this[INTERNALS].disturbed) { - return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); - } - - this[INTERNALS].disturbed = true; - - if (this[INTERNALS].error) { - return Body.Promise.reject(this[INTERNALS].error); - } - - let body = this.body; - - // body is null - if (body === null) { - return Body.Promise.resolve(Buffer.alloc(0)); - } - - // body is blob - if (isBlob(body)) { - body = body.stream(); - } - - // body is buffer - if (Buffer.isBuffer(body)) { - return Body.Promise.resolve(body); - } - - // istanbul ignore if: should never happen - if (!(body instanceof Stream__default['default'])) { - return Body.Promise.resolve(Buffer.alloc(0)); - } - - // body is stream - // get ready to actually consume the body - let accum = []; - let accumBytes = 0; - let abort = false; - - return new Body.Promise(function (resolve, reject) { - let resTimeout; - - // allow timeout on slow response body - if (_this4.timeout) { - resTimeout = setTimeout(function () { - abort = true; - reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); - }, _this4.timeout); - } - - // handle stream errors - body.on('error', function (err) { - if (err.name === 'AbortError') { - // if the request was aborted, reject with this Error - abort = true; - reject(err); - } else { - // other errors, such as incorrect content-encoding - reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); - } - }); - - body.on('data', function (chunk) { - if (abort || chunk === null) { - return; - } - - if (_this4.size && accumBytes + chunk.length > _this4.size) { - abort = true; - reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); - return; - } - - accumBytes += chunk.length; - accum.push(chunk); - }); - - body.on('end', function () { - if (abort) { - return; - } - - clearTimeout(resTimeout); - - try { - resolve(Buffer.concat(accum, accumBytes)); - } catch (err) { - // handle streams that have accumulated too much data (issue #414) - reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); - } - }); - }); -} - -/** - * Detect buffer encoding and convert to target encoding - * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding - * - * @param Buffer buffer Incoming buffer - * @param String encoding Target encoding - * @return String - */ -function convertBody(buffer, headers) { - if (typeof convert !== 'function') { - throw new Error('The package `encoding` must be installed to use the textConverted() function'); - } - - const ct = headers.get('content-type'); - let charset = 'utf-8'; - let res, str; - - // header - if (ct) { - res = /charset=([^;]*)/i.exec(ct); - } - - // no charset in content type, peek at response body for at most 1024 bytes - str = buffer.slice(0, 1024).toString(); - - // html5 - if (!res && str) { - res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; - - this[MAP] = Object.create(null); - - if (init instanceof Headers) { - const rawHeaders = init.raw(); - const headerNames = Object.keys(rawHeaders); - - for (const headerName of headerNames) { - for (const value of rawHeaders[headerName]) { - this.append(headerName, value); - } - } - - return; - } - - // We don't worry about converting prop to ByteString here as append() - // will handle it. - if (init == null) ; else if (typeof init === 'object') { - const method = init[Symbol.iterator]; - if (method != null) { - if (typeof method !== 'function') { - throw new TypeError('Header pairs must be iterable'); - } - - // sequence> - // Note: per spec we have to first exhaust the lists then process them - const pairs = []; - for (const pair of init) { - if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { - throw new TypeError('Each header pair must be iterable'); - } - pairs.push(Array.from(pair)); - } - - for (const pair of pairs) { - if (pair.length !== 2) { - throw new TypeError('Each header pair must be a name/value tuple'); - } - this.append(pair[0], pair[1]); - } - } else { - // record - for (const key of Object.keys(init)) { - const value = init[key]; - this.append(key, value); - } - } - } else { - throw new TypeError('Provided initializer must be an object'); - } - } - - /** - * Return combined header value given name - * - * @param String name Header name - * @return Mixed - */ - get(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key === undefined) { - return null; - } - - return this[MAP][key].join(', '); - } - - /** - * Iterate over all headers - * - * @param Function callback Executed for each item with parameters (value, name, thisArg) - * @param Boolean thisArg `this` context for callback function - * @return Void - */ - forEach(callback) { - let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; - - let pairs = getHeaders(this); - let i = 0; - while (i < pairs.length) { - var _pairs$i = pairs[i]; - const name = _pairs$i[0], - value = _pairs$i[1]; - - callback.call(thisArg, value, name, this); - pairs = getHeaders(this); - i++; - } - } - - /** - * Overwrite header values given name - * - * @param String name Header name - * @param String value Header value - * @return Void - */ - set(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - this[MAP][key !== undefined ? key : name] = [value]; - } - - /** - * Append a value onto existing header - * - * @param String name Header name - * @param String value Header value - * @return Void - */ - append(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - if (key !== undefined) { - this[MAP][key].push(value); - } else { - this[MAP][name] = [value]; - } - } - - /** - * Check for header name existence - * - * @param String name Header name - * @return Boolean - */ - has(name) { - name = `${name}`; - validateName(name); - return find(this[MAP], name) !== undefined; - } - - /** - * Delete all header values given name - * - * @param String name Header name - * @return Void - */ - delete(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key !== undefined) { - delete this[MAP][key]; - } - } - - /** - * Return raw headers (non-spec api) - * - * @return Object - */ - raw() { - return this[MAP]; - } - - /** - * Get an iterator on keys. - * - * @return Iterator - */ - keys() { - return createHeadersIterator(this, 'key'); - } - - /** - * Get an iterator on values. - * - * @return Iterator - */ - values() { - return createHeadersIterator(this, 'value'); - } - - /** - * Get an iterator on entries. - * - * This is the default iterator of the Headers object. - * - * @return Iterator - */ - [Symbol.iterator]() { - return createHeadersIterator(this, 'key+value'); - } -} -Headers.prototype.entries = Headers.prototype[Symbol.iterator]; - -Object.defineProperty(Headers.prototype, Symbol.toStringTag, { - value: 'Headers', - writable: false, - enumerable: false, - configurable: true -}); - -Object.defineProperties(Headers.prototype, { - get: { enumerable: true }, - forEach: { enumerable: true }, - set: { enumerable: true }, - append: { enumerable: true }, - has: { enumerable: true }, - delete: { enumerable: true }, - keys: { enumerable: true }, - values: { enumerable: true }, - entries: { enumerable: true } -}); - -function getHeaders(headers) { - let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; - - const keys = Object.keys(headers[MAP]).sort(); - return keys.map(kind === 'key' ? function (k) { - return k.toLowerCase(); - } : kind === 'value' ? function (k) { - return headers[MAP][k].join(', '); - } : function (k) { - return [k.toLowerCase(), headers[MAP][k].join(', ')]; - }); -} - -const INTERNAL = Symbol('internal'); - -function createHeadersIterator(target, kind) { - const iterator = Object.create(HeadersIteratorPrototype); - iterator[INTERNAL] = { - target, - kind, - index: 0 - }; - return iterator; -} - -const HeadersIteratorPrototype = Object.setPrototypeOf({ - next() { - // istanbul ignore if - if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { - throw new TypeError('Value of `this` is not a HeadersIterator'); - } - - var _INTERNAL = this[INTERNAL]; - const target = _INTERNAL.target, - kind = _INTERNAL.kind, - index = _INTERNAL.index; - - const values = getHeaders(target, kind); - const len = values.length; - if (index >= len) { - return { - value: undefined, - done: true - }; - } - - this[INTERNAL].index = index + 1; - - return { - value: values[index], - done: false - }; - } -}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); - -Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { - value: 'HeadersIterator', - writable: false, - enumerable: false, - configurable: true -}); - -/** - * Export the Headers object in a form that Node.js can consume. - * - * @param Headers headers - * @return Object - */ -function exportNodeCompatibleHeaders(headers) { - const obj = Object.assign({ __proto__: null }, headers[MAP]); - - // http.request() only supports string as Host header. This hack makes - // specifying custom Host header possible. - const hostHeaderKey = find(headers[MAP], 'Host'); - if (hostHeaderKey !== undefined) { - obj[hostHeaderKey] = obj[hostHeaderKey][0]; - } - - return obj; -} - -/** - * Create a Headers object from an object of headers, ignoring those that do - * not conform to HTTP grammar productions. - * - * @param Object obj Object of headers - * @return Headers - */ -function createHeadersLenient(obj) { - const headers = new Headers(); - for (const name of Object.keys(obj)) { - if (invalidTokenRegex.test(name)) { - continue; - } - if (Array.isArray(obj[name])) { - for (const val of obj[name]) { - if (invalidHeaderCharRegex.test(val)) { - continue; - } - if (headers[MAP][name] === undefined) { - headers[MAP][name] = [val]; - } else { - headers[MAP][name].push(val); - } - } - } else if (!invalidHeaderCharRegex.test(obj[name])) { - headers[MAP][name] = [obj[name]]; - } - } - return headers; -} - -const INTERNALS$1 = Symbol('Response internals'); - -// fix an issue where "STATUS_CODES" aren't a named export for node <10 -const STATUS_CODES = http__default['default'].STATUS_CODES; - -/** - * Response class - * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void - */ -class Response { - constructor() { - let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - Body.call(this, body, opts); - - const status = opts.status || 200; - const headers = new Headers(opts.headers); - - if (body != null && !headers.has('Content-Type')) { - const contentType = extractContentType(body); - if (contentType) { - headers.append('Content-Type', contentType); - } - } - - this[INTERNALS$1] = { - url: opts.url, - status, - statusText: opts.statusText || STATUS_CODES[status], - headers, - counter: opts.counter - }; - } - - get url() { - return this[INTERNALS$1].url || ''; - } - - get status() { - return this[INTERNALS$1].status; - } - - /** - * Convenience property representing if the request ended normally - */ - get ok() { - return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; - } - - get redirected() { - return this[INTERNALS$1].counter > 0; - } - - get statusText() { - return this[INTERNALS$1].statusText; - } - - get headers() { - return this[INTERNALS$1].headers; - } - - /** - * Clone this response - * - * @return Response - */ - clone() { - return new Response(clone(this), { - url: this.url, - status: this.status, - statusText: this.statusText, - headers: this.headers, - ok: this.ok, - redirected: this.redirected - }); - } -} - -Body.mixIn(Response.prototype); - -Object.defineProperties(Response.prototype, { - url: { enumerable: true }, - status: { enumerable: true }, - ok: { enumerable: true }, - redirected: { enumerable: true }, - statusText: { enumerable: true }, - headers: { enumerable: true }, - clone: { enumerable: true } -}); - -Object.defineProperty(Response.prototype, Symbol.toStringTag, { - value: 'Response', - writable: false, - enumerable: false, - configurable: true -}); - -const INTERNALS$2 = Symbol('Request internals'); - -// fix an issue where "format", "parse" aren't a named export for node <10 -const parse_url = Url__default['default'].parse; -const format_url = Url__default['default'].format; - -const streamDestructionSupported = 'destroy' in Stream__default['default'].Readable.prototype; - -/** - * Check if a value is an instance of Request. - * - * @param Mixed input - * @return Boolean - */ -function isRequest(input) { - return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; -} - -function isAbortSignal(signal) { - const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); - return !!(proto && proto.constructor.name === 'AbortSignal'); -} - -/** - * Request class - * - * @param Mixed input Url or Request instance - * @param Object init Custom options - * @return Void - */ -class Request { - constructor(input) { - let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - let parsedURL; - - // normalize input - if (!isRequest(input)) { - if (input && input.href) { - // in order to support Node.js' Url objects; though WHATWG's URL objects - // will fall into this branch also (since their `toString()` will return - // `href` property anyway) - parsedURL = parse_url(input.href); - } else { - // coerce input to a string before attempting to parse - parsedURL = parse_url(`${input}`); - } - input = {}; - } else { - parsedURL = parse_url(input.url); - } - - let method = init.method || input.method || 'GET'; - method = method.toUpperCase(); - - if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { - throw new TypeError('Request with GET/HEAD method cannot have body'); - } - - let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; - - Body.call(this, inputBody, { - timeout: init.timeout || input.timeout || 0, - size: init.size || input.size || 0 - }); - - const headers = new Headers(init.headers || input.headers || {}); - - if (inputBody != null && !headers.has('Content-Type')) { - const contentType = extractContentType(inputBody); - if (contentType) { - headers.append('Content-Type', contentType); - } - } - - let signal = isRequest(input) ? input.signal : null; - if ('signal' in init) signal = init.signal; - - if (signal != null && !isAbortSignal(signal)) { - throw new TypeError('Expected signal to be an instanceof AbortSignal'); - } - - this[INTERNALS$2] = { - method, - redirect: init.redirect || input.redirect || 'follow', - headers, - parsedURL, - signal - }; - - // node-fetch-only options - this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; - this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; - this.counter = init.counter || input.counter || 0; - this.agent = init.agent || input.agent; - } - - get method() { - return this[INTERNALS$2].method; - } - - get url() { - return format_url(this[INTERNALS$2].parsedURL); - } - - get headers() { - return this[INTERNALS$2].headers; - } - - get redirect() { - return this[INTERNALS$2].redirect; - } - - get signal() { - return this[INTERNALS$2].signal; - } - - /** - * Clone this request - * - * @return Request - */ - clone() { - return new Request(this); - } -} - -Body.mixIn(Request.prototype); - -Object.defineProperty(Request.prototype, Symbol.toStringTag, { - value: 'Request', - writable: false, - enumerable: false, - configurable: true -}); - -Object.defineProperties(Request.prototype, { - method: { enumerable: true }, - url: { enumerable: true }, - headers: { enumerable: true }, - redirect: { enumerable: true }, - clone: { enumerable: true }, - signal: { enumerable: true } -}); - -/** - * Convert a Request to Node.js http request options. - * - * @param Request A Request instance - * @return Object The options object to be passed to http.request - */ -function getNodeRequestOptions(request) { - const parsedURL = request[INTERNALS$2].parsedURL; - const headers = new Headers(request[INTERNALS$2].headers); - - // fetch step 1.3 - if (!headers.has('Accept')) { - headers.set('Accept', '*/*'); - } - - // Basic fetch - if (!parsedURL.protocol || !parsedURL.hostname) { - throw new TypeError('Only absolute URLs are supported'); - } - - if (!/^https?:$/.test(parsedURL.protocol)) { - throw new TypeError('Only HTTP(S) protocols are supported'); - } - - if (request.signal && request.body instanceof Stream__default['default'].Readable && !streamDestructionSupported) { - throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); - } - - // HTTP-network-or-cache fetch steps 2.4-2.7 - let contentLengthValue = null; - if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { - contentLengthValue = '0'; - } - if (request.body != null) { - const totalBytes = getTotalBytes(request); - if (typeof totalBytes === 'number') { - contentLengthValue = String(totalBytes); - } - } - if (contentLengthValue) { - headers.set('Content-Length', contentLengthValue); - } - - // HTTP-network-or-cache fetch step 2.11 - if (!headers.has('User-Agent')) { - headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); - } - - // HTTP-network-or-cache fetch step 2.15 - if (request.compress && !headers.has('Accept-Encoding')) { - headers.set('Accept-Encoding', 'gzip,deflate'); - } - - let agent = request.agent; - if (typeof agent === 'function') { - agent = agent(parsedURL); - } - - if (!headers.has('Connection') && !agent) { - headers.set('Connection', 'close'); - } - - // HTTP-network fetch step 4.2 - // chunked encoding is handled by Node.js - - return Object.assign({}, parsedURL, { - method: request.method, - headers: exportNodeCompatibleHeaders(headers), - agent - }); -} - -/** - * abort-error.js - * - * AbortError interface for cancelled requests - */ - -/** - * Create AbortError instance - * - * @param String message Error message for human - * @return AbortError - */ -function AbortError(message) { - Error.call(this, message); - - this.type = 'aborted'; - this.message = message; - - // hide custom error implementation details from end-users - Error.captureStackTrace(this, this.constructor); -} - -AbortError.prototype = Object.create(Error.prototype); -AbortError.prototype.constructor = AbortError; -AbortError.prototype.name = 'AbortError'; - -// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 -const PassThrough$1 = Stream__default['default'].PassThrough; -const resolve_url = Url__default['default'].resolve; - -/** - * Fetch function - * - * @param Mixed url Absolute url or Request instance - * @param Object opts Fetch options - * @return Promise - */ -function fetch(url, opts) { - - // allow custom promise - if (!fetch.Promise) { - throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); - } - - Body.Promise = fetch.Promise; - - // wrap http.request into fetch - return new fetch.Promise(function (resolve, reject) { - // build request object - const request = new Request(url, opts); - const options = getNodeRequestOptions(request); - - const send = (options.protocol === 'https:' ? https__default['default'] : http__default['default']).request; - const signal = request.signal; - - let response = null; - - const abort = function abort() { - let error = new AbortError('The user aborted a request.'); - reject(error); - if (request.body && request.body instanceof Stream__default['default'].Readable) { - request.body.destroy(error); - } - if (!response || !response.body) return; - response.body.emit('error', error); - }; - - if (signal && signal.aborted) { - abort(); - return; - } - - const abortAndFinalize = function abortAndFinalize() { - abort(); - finalize(); - }; - - // send request - const req = send(options); - let reqTimeout; - - if (signal) { - signal.addEventListener('abort', abortAndFinalize); - } - - function finalize() { - req.abort(); - if (signal) signal.removeEventListener('abort', abortAndFinalize); - clearTimeout(reqTimeout); - } - - if (request.timeout) { - req.once('socket', function (socket) { - reqTimeout = setTimeout(function () { - reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); - finalize(); - }, request.timeout); - }); - } - - req.on('error', function (err) { - reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); - finalize(); - }); - - req.on('response', function (res) { - clearTimeout(reqTimeout); - - const headers = createHeadersLenient(res.headers); - - // HTTP fetch step 5 - if (fetch.isRedirect(res.statusCode)) { - // HTTP fetch step 5.2 - const location = headers.get('Location'); - - // HTTP fetch step 5.3 - const locationURL = location === null ? null : resolve_url(request.url, location); - - // HTTP fetch step 5.5 - switch (request.redirect) { - case 'error': - reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); - finalize(); - return; - case 'manual': - // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. - if (locationURL !== null) { - // handle corrupted header - try { - headers.set('Location', locationURL); - } catch (err) { - // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request - reject(err); - } - } - break; - case 'follow': - // HTTP-redirect fetch step 2 - if (locationURL === null) { - break; - } - - // HTTP-redirect fetch step 5 - if (request.counter >= request.follow) { - reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); - finalize(); - return; - } - - // HTTP-redirect fetch step 6 (counter increment) - // Create a new Request object. - const requestOpts = { - headers: new Headers(request.headers), - follow: request.follow, - counter: request.counter + 1, - agent: request.agent, - compress: request.compress, - method: request.method, - body: request.body, - signal: request.signal, - timeout: request.timeout, - size: request.size - }; - - // HTTP-redirect fetch step 9 - if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { - reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); - finalize(); - return; - } - - // HTTP-redirect fetch step 11 - if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { - requestOpts.method = 'GET'; - requestOpts.body = undefined; - requestOpts.headers.delete('content-length'); - } - - // HTTP-redirect fetch step 15 - resolve(fetch(new Request(locationURL, requestOpts))); - finalize(); - return; - } - } - - // prepare response - res.once('end', function () { - if (signal) signal.removeEventListener('abort', abortAndFinalize); - }); - let body = res.pipe(new PassThrough$1()); - - const response_options = { - url: request.url, - status: res.statusCode, - statusText: res.statusMessage, - headers: headers, - size: request.size, - timeout: request.timeout, - counter: request.counter - }; - - // HTTP-network fetch step 12.1.1.3 - const codings = headers.get('Content-Encoding'); - - // HTTP-network fetch step 12.1.1.4: handle content codings - - // in following scenarios we ignore compression support - // 1. compression support is disabled - // 2. HEAD request - // 3. no Content-Encoding header - // 4. no content response (204) - // 5. content not modified response (304) - if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { - response = new Response(body, response_options); - resolve(response); - return; - } - - // For Node v6+ - // Be less strict when decoding compressed responses, since sometimes - // servers send slightly invalid responses that are still accepted - // by common browsers. - // Always using Z_SYNC_FLUSH is what cURL does. - const zlibOptions = { - flush: zlib__default['default'].Z_SYNC_FLUSH, - finishFlush: zlib__default['default'].Z_SYNC_FLUSH - }; - - // for gzip - if (codings == 'gzip' || codings == 'x-gzip') { - body = body.pipe(zlib__default['default'].createGunzip(zlibOptions)); - response = new Response(body, response_options); - resolve(response); - return; - } - - // for deflate - if (codings == 'deflate' || codings == 'x-deflate') { - // handle the infamous raw deflate response from old servers - // a hack for old IIS and Apache servers - const raw = res.pipe(new PassThrough$1()); - raw.once('data', function (chunk) { - // see http://stackoverflow.com/questions/37519828 - if ((chunk[0] & 0x0F) === 0x08) { - body = body.pipe(zlib__default['default'].createInflate()); - } else { - body = body.pipe(zlib__default['default'].createInflateRaw()); - } - response = new Response(body, response_options); - resolve(response); - }); - return; - } - - // for br - if (codings == 'br' && typeof zlib__default['default'].createBrotliDecompress === 'function') { - body = body.pipe(zlib__default['default'].createBrotliDecompress()); - response = new Response(body, response_options); - resolve(response); - return; - } - - // otherwise, use response as-is - response = new Response(body, response_options); - resolve(response); - }); - - writeToStream(req, request); - }); -} -/** - * Redirect code matching - * - * @param Number code Status code - * @return Boolean - */ -fetch.isRedirect = function (code) { - return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; -}; - -// expose Promise -fetch.Promise = global.Promise; - -function noop() { } -function safe_not_equal(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -const subscriber_queue = []; -/** - * Creates a `Readable` store that allows reading by subscription. - * @param value initial value - * @param {StartStopNotifier}start start and stop notifications for subscriptions - */ -function readable(value, start) { - return { - subscribe: writable(value, start).subscribe - }; -} -/** - * Create a `Writable` store that allows both updating and reading by subscription. - * @param {*=}value initial value - * @param {StartStopNotifier=}start start and stop notifications for subscriptions - */ -function writable(value, start = noop) { - let stop; - const subscribers = []; - function set(new_value) { - if (safe_not_equal(value, new_value)) { - value = new_value; - if (stop) { // store is ready - const run_queue = !subscriber_queue.length; - for (let i = 0; i < subscribers.length; i += 1) { - const s = subscribers[i]; - s[1](); - subscriber_queue.push(s, value); - } - if (run_queue) { - for (let i = 0; i < subscriber_queue.length; i += 2) { - subscriber_queue[i][0](subscriber_queue[i + 1]); - } - subscriber_queue.length = 0; - } - } - } - } - function update(fn) { - set(fn(value)); - } - function subscribe(run, invalidate = noop) { - const subscriber = [run, invalidate]; - subscribers.push(subscriber); - if (subscribers.length === 1) { - stop = start(set) || noop; - } - run(value); - return () => { - const index = subscribers.indexOf(subscriber); - if (index !== -1) { - subscribers.splice(index, 1); - } - if (subscribers.length === 0) { - stop(); - stop = null; - } - }; - } - return { set, update, subscribe }; -} - -const noop$1 = () => {}; - -async function render_page( - request, - context, - options, - status = 200, - error = null -) { - let redirected; - let preload_error; - - const page = options.manifest.pages.find((page) => - page.pattern.test(request.path) - ); - - const baseUrl = ''; // TODO - - const session = await (options.setup.getSession && options.setup.getSession(context)); - - const serialized_session = try_serialize(session, (err) => { - throw new Error(`Failed to serialize session data: ${err.message}`); - }); - - try { - if (!page) { - const error = new Error(`Not found: ${request.path}`); - error.status = 404; - throw error; - } - - const segments = request.path.split('/').filter(Boolean); - - // TODO make this less confusing - const layout_segments = [segments[0]]; - let l = 1; - - page.parts.forEach((part, i) => { - layout_segments[l] = segments[i + 1]; - if (!part) return; - l++; - }); - - const dependencies = {}; - - const preload_context = { - redirect: (status, location) => { - if ( - redirected && - (redirected.status !== status || redirected.headers.location !== location) - ) { - throw new Error('Conflicting redirects'); - } - location = location.replace(/^\//g, ''); // leading slash (only) - redirected = { - status, - headers: { location }, - body: null, - dependencies: {} - }; - }, - error: (status, error) => { - if (typeof error === 'string') { - error = new Error(error); - } - preload_error = { ...error, status }; - }, - fetch: async (url, opts = {}) => { - const parsed = Url.parse(url); - - if (parsed.protocol) { - // external fetch - return fetch(parsed.href, opts); - } - - // otherwise we're dealing with an internal fetch. TODO there's - // probably no advantage to using fetch here — we should replace - // `this.fetch` with `this.load` or whatever - - const resolved = Url.resolve(request.path, parsed.pathname); - - // edge case — fetching a static file - const candidates = [ - `${options.static_dir}${resolved}`, - `${options.static_dir}${resolved}/index.html` - ]; - for (const file of candidates) { - if (fs.existsSync(file)) { - return new Response(fs.createReadStream(file), { - headers: { - 'content-type': mime.getType(file) - } - }); - } - } - - // TODO this doesn't take account of opts.body - const rendered = await render( - { - host: request.host, - method: opts.method || 'GET', - headers: opts.headers || {}, // TODO inject credentials... - path: resolved, - body: opts.body, - query: new Url.URLSearchParams(parsed.query || '') - }, - options - ); - - if (rendered) { - // TODO this is primarily for the benefit of the static case, - // but could it be used elsewhere? - dependencies[resolved] = rendered; - - return new Response(rendered.body, { - status: rendered.status, - headers: rendered.headers - }); - } else { - return new Response('Not found', { - status: 404 - }); - } - } - }; - - const match = page.pattern.exec(request.path); - - // the last part has all parameters from any segment in the URL - const params = parts_to_params(match, page.parts[page.parts.length - 1] ); - - const preloaded = []; - let can_prerender = true; - - const parts = await Promise.all( - [{ component: options.manifest.layout, params: [] }, ...page.parts].map(async (part, i) => { - if (!part) return null; - - const mod = await options.load(part.component); - - if (options.only_prerender && !mod.prerender) { - can_prerender = false; - return; - } - - // these are only the parameters up to the current URL segment - const params = parts_to_params(match, part); - - const props = mod.preload - ? await mod.preload.call( - preload_context, - { - host: request.host, - path: request.path, - query: request.query, - params - }, - session - ) - : {}; - - preloaded[i] = props; - return { component: mod.default, props }; - }) - ); - - if (options.only_prerender && !can_prerender) return; - - if (preload_error) throw preload_error; - if (redirected) return redirected; - - const branches = []; - parts.forEach((part, i) => { - if (part) { - branches.push({ - component: part.component, - props: preloaded[i], - segment: segments[i] - }); - } - }); - - const pageContext = { - host: request.host , - path: request.path, - query: search_params_to_map(request.query), - params, - error: error || undefined - }; - - const props = { - status, - error, - stores: { - page: readable(pageContext, noop$1), - preloading: readable(null, noop$1), - session: writable(session) - }, - // TODO stores, status, segments, notify, CONTEXT_KEY - segments: layout_segments, - branches, - level0: { - props: preloaded[0] - }, - level1: { - segment: segments[0], - props: {} - } - }; - - // TODO this is highly confusing. replace the leveln thing with an array of branches - l = 1; - for (let i = 1; i < parts.length; i += 1) { - const part = parts[i]; - if (!part) continue; - - props[`level${l++}`] = { - component: part.component, - props: preloaded[i] || {}, - segment: segments[i] - }; - } - - const serialized_preloads = `[${preloaded - .map((data) => - try_serialize(data, (err) => { - const path = '/' + segments.join('/'); - console.error( - `Failed to serialize preloaded data to transmit to the client at the ${path} route: ${err.message}` - ); - console.warn( - 'The client will re-render over the server-rendered page fresh instead of continuing where it left off. See https://sapper.svelte.dev/docs#Return_value for more information' - ); - }) - ) - .join(',')}]`; - - const rendered = options.root.default.render(props); - - const deps = options.client.deps; - const js_deps = new Set(deps.__entry__ ? [...deps.__entry__.js] : []); - const css_deps = new Set(deps.__entry__ ? [...deps.__entry__.css] : []); - - (page.parts.filter(Boolean) ).forEach((part) => { - const page_deps = deps[part.component.name]; - - if (!page_deps) return; // we don't have this info during dev - - page_deps.js.forEach((dep) => js_deps.add(dep)); - page_deps.css.forEach((dep) => css_deps.add(dep)); - }); - - const head = `${rendered.head} - - ${Array.from(js_deps) - .map((dep) => ``) - .join('\n\t\t\t')} - ${Array.from(css_deps) - .map((dep) => ``) - .join('\n\t\t\t')} - ${options.dev ? `` : ''} - - `.replace(/^\t{2}/gm, ''); // TODO add links - - const body = `${rendered.html} - `.replace(/^\t{3}/gm, ''); - - const html = options.template.replace('%svelte.head%', head).replace('%svelte.body%', body); - - return { - status: 200, - headers: { - 'content-type': 'text/html' - }, - body: html, - dependencies - }; - } catch (thrown) { - console.error(thrown.stack); - - if (!error) { - const status = thrown.status || 500; - return render_page(request, context, options, status, thrown); - } else { - // oh lawd now you've done it - return { - status: 500, - headers: {}, - body: thrown.stack, // TODO probably not in prod? - dependencies: {} - }; - } - } -} - -function parts_to_params(match, part) { - const params = {}; - - part.params.forEach((name, i) => { - const is_spread = /^\.{3}.+$/.test(name); - - if (is_spread) { - params[name.slice(3)] = match[i + 1].split('/'); - } else { - params[name] = match[i + 1]; - } - }); - - return params; -} - -function try_serialize(data, fail) { - try { - return devalue(data); - } catch (err) { - if (fail) fail(err); - return null; - } -} - -// Ensure we return something truthy so the client will not re-render the page over the error -function serialize_error(error) { - if (!error) return null; - let serialized = try_serialize(error); - if (!serialized) { - const { name, message, stack } = error; - serialized = try_serialize({ name, message, stack }); - } - if (!serialized) { - serialized = '{}'; - } - return serialized; -} - -function search_params_to_map(params) { - const map = {}; - - for (const key of params.keys()) { - const values = params.getAll(key); - - map[key] = values.length > 1 ? values : values[0]; - } - - return map; -} - -function render_route( - request, - context, - options -) { - const route = options.manifest.endpoints.find((route) => - route.pattern.test(request.path) - ); - if (!route) return null; - - return Promise.resolve(options.load(route)).then(async (mod) => { - const handler = mod[request.method.toLowerCase().replace('delete', 'del')]; // 'delete' is a reserved word - - if (handler) { - const params = {}; - const match = route.pattern.exec(request.path); - route.params.forEach((name, i) => { - params[name] = match[i + 1]; - }); - - try { - let { status = 200, body, headers = {} } = await handler( - { - host: request.host, - path: request.path, - query: request.query, - body: request.body, - params - }, - context - ); - - headers = lowercase_keys(headers); - - if ( - (typeof body === 'object' && !('content-type' in headers)) || - headers['content-type'] === 'application/json' - ) { - headers = { ...headers, 'content-type': 'application/json' }; - body = JSON.stringify(body); - } - - return { status, body, headers }; - } catch (err) { - return { - status: 500, - body: err.message, - headers: {} - }; - } - } else { - return { - status: 501, - body: `${request.method} is not implemented for ${request.path}`, - headers: {} - }; - } - }); -} - -function lowercase_keys(obj) { - const clone = {}; - for (const key in obj) { - clone[key.toLowerCase()] = obj[key]; - } - return clone; -} - -function md5(body) { - return crypto.createHash('md5').update(body).digest('hex'); -} - -async function render( - request, - options -) { - const { context, headers = {} } = (await (options.setup.prepare && options.setup.prepare(request.headers))) || {}; - - try { - const response = await (render_route(request, context, options) || - render_page(request, context, options)); - - if (response) { - // inject ETags for 200 responses - if (response.status === 200) { - if (!/(no-store|immutable)/.test(response.headers['cache-control'])) { - const etag = `"${md5(response.body)}"`; - - if (request.headers['if-none-match'] === etag) { - return { - status: 304, - headers: {}, - body: null - }; - } - - response.headers['etag'] = etag; - } - } - - return { - status: response.status, - headers: { ...headers, ...response.headers }, - body: response.body - }; - } - } catch (err) { - return { - status: 500, - headers: {}, - body: options.dev ? err.stack : err.message - }; - } -} - -const manifest = require('./manifest.js'); -const client = require('./client.json'); -const root = require('./root.js'); -const setup = require('./setup.js'); -const template = require('./template.js'); - -// TODO this is a generic AWS lambda handler, and could be -// reused by other adapters - -const handler = async (event) => { - const { - path, - httpMethod, - headers, - queryStringParameters - // body, // TODO pass this to renderer - // isBase64Encoded // TODO is this useful? - } = event; - - const query = new Url.URLSearchParams(); - for (const k in queryStringParameters) { - const value = queryStringParameters[k]; - value.split(', ').forEach((v) => { - query.append(k, v); - }); - } - - const rendered = await render( - { - host: null, // TODO - method: httpMethod, - headers, - path, - query - }, - { - static_dir: 'static', - template, - manifest, - client, - root, - setup, - load: (route) => - require(`./routes/${route.name}.js`), - dev: false, - only_prerender: false - } - ); - - if (rendered) { - return { - isBase64Encoded: false, - statusCode: rendered.status, - headers: rendered.headers, - body: rendered.body - }; - } - - return { - statusCode: 404, - body: 'Not found' - }; -}; - -exports.handler = handler; diff --git a/packages/adapter-netlify/rollup.config.js b/packages/adapter-netlify/rollup.config.js deleted file mode 100644 index f4d29d931e4b..000000000000 --- a/packages/adapter-netlify/rollup.config.js +++ /dev/null @@ -1,12 +0,0 @@ -import { nodeResolve } from '@rollup/plugin-node-resolve'; -import commonjs from '@rollup/plugin-commonjs'; - -export default { - input: 'src/render.js', - output: { - file: 'files/render.js', - format: 'cjs' - }, - plugins: [nodeResolve(), commonjs()], - external: require('module').builtinModules -}; From e4955c0e102668c2cc098413a87f83347b0931cf Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 13:48:42 -0500 Subject: [PATCH 24/30] use netlify in hn example --- examples/hn.svelte.dev/netlify.toml | 4 ++++ examples/hn.svelte.dev/package.json | 2 +- examples/hn.svelte.dev/svelte.config.js | 2 +- pnpm-lock.yaml | 20 +++++--------------- 4 files changed, 11 insertions(+), 17 deletions(-) create mode 100644 examples/hn.svelte.dev/netlify.toml diff --git a/examples/hn.svelte.dev/netlify.toml b/examples/hn.svelte.dev/netlify.toml new file mode 100644 index 000000000000..cbd944d3a1e8 --- /dev/null +++ b/examples/hn.svelte.dev/netlify.toml @@ -0,0 +1,4 @@ +[build] + command = "npm run build" + publish = "build/" + functions = "functions/" \ No newline at end of file diff --git a/examples/hn.svelte.dev/package.json b/examples/hn.svelte.dev/package.json index 650d3de2982c..6ad6a3e363ae 100644 --- a/examples/hn.svelte.dev/package.json +++ b/examples/hn.svelte.dev/package.json @@ -6,7 +6,7 @@ "build": "svelte build" }, "devDependencies": { - "@sveltejs/adapter-node": "workspace:*", + "@sveltejs/adapter-netlify": "workspace:*", "@sveltejs/kit": "workspace:*", "@sveltejs/snowpack-config": "workspace:*", "svelte": "^3.29.0" diff --git a/examples/hn.svelte.dev/svelte.config.js b/examples/hn.svelte.dev/svelte.config.js index c63e6d4a27a2..ba01daa31ca9 100644 --- a/examples/hn.svelte.dev/svelte.config.js +++ b/examples/hn.svelte.dev/svelte.config.js @@ -2,5 +2,5 @@ module.exports = { // By default, `npm run build` will create a standard Node app. // You can create optimized builds for different platforms by // specifying a different adapter - adapter: '@sveltejs/adapter-node' + adapter: '@sveltejs/adapter-netlify' }; \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4b65be20de5e..3c23d2361feb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,12 +30,12 @@ importers: typescript: ^4.1.2 examples/hn.svelte.dev: devDependencies: - '@sveltejs/adapter-node': 'link:../../packages/adapter-node' + '@sveltejs/adapter-netlify': 'link:../../packages/adapter-netlify' '@sveltejs/kit': 'link:../../packages/kit' '@sveltejs/snowpack-config': 'link:../../packages/snowpack-config' svelte: 3.29.0 specifiers: - '@sveltejs/adapter-node': 'workspace:*' + '@sveltejs/adapter-netlify': 'workspace:*' '@sveltejs/kit': 'workspace:*' '@sveltejs/snowpack-config': 'workspace:*' svelte: ^3.29.0 @@ -72,21 +72,8 @@ importers: '@sveltejs/app-utils': 'workspace:*' packages/adapter-netlify: dependencies: - kleur: 4.1.3 - tiny-glob: 0.2.8 toml: 3.0.0 - devDependencies: - '@sveltejs/app-utils': 'link:../app-utils' - '@types/aws-lambda': 8.10.64 - devalue: 2.0.1 - rollup: 2.32.0 specifiers: - '@sveltejs/app-utils': 'workspace:*' - '@types/aws-lambda': ^8.10.64 - devalue: ^2.0.1 - kleur: ^4.1.3 - rollup: ^2.32.0 - tiny-glob: ^0.2.8 toml: ^3.0.0 packages/adapter-node: dependencies: @@ -2051,6 +2038,7 @@ packages: resolution: integrity: sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg== /globalyzer/0.1.0: + dev: true resolution: integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q== /globby/11.0.1: @@ -2067,6 +2055,7 @@ packages: resolution: integrity: sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ== /globrex/0.1.2: + dev: true resolution: integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg== /graceful-fs/4.2.4: @@ -3816,6 +3805,7 @@ packages: dependencies: globalyzer: 0.1.0 globrex: 0.1.2 + dev: true resolution: integrity: sha512-vkQP7qOslq63XRX9kMswlby99kyO5OvKptw7AMwBVMjXEI7Tb61eoI5DydyEMOseyGS5anDN1VPoVxEvH01q8w== /tmp/0.0.33: From b9791d57f5af45ca5ab012f5018f5c14e9b69b90 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 13:49:41 -0500 Subject: [PATCH 25/30] add use strict pragmas --- packages/adapter-node/index.js | 2 ++ packages/adapter-static/index.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js index 0a4c41a65bae..ed64938da062 100644 --- a/packages/adapter-node/index.js +++ b/packages/adapter-node/index.js @@ -1,3 +1,5 @@ +'use strict'; + const fs = require('fs'); module.exports = async function adapter(builder) { diff --git a/packages/adapter-static/index.js b/packages/adapter-static/index.js index 96e080a891f5..a09547ec2bc7 100644 --- a/packages/adapter-static/index.js +++ b/packages/adapter-static/index.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = async function adapter(builder) { // TODO implement adapter options, allow 'build' to be specified From df57dd135fd4be18fbe3812d9001a9e9637dceb2 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 13:50:51 -0500 Subject: [PATCH 26/30] remove unused dependency --- packages/adapter-static/package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/adapter-static/package.json b/packages/adapter-static/package.json index b8341d769886..bf39c1822461 100644 --- a/packages/adapter-static/package.json +++ b/packages/adapter-static/package.json @@ -6,8 +6,5 @@ "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore", "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", "prepublishOnly": "npm run build" - }, - "dependencies": { - "@sveltejs/app-utils": "workspace:*" } } From 39f36476dc2496d27ecacba4e4f95de396a79b9d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 13:51:10 -0500 Subject: [PATCH 27/30] update lockfile --- pnpm-lock.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3c23d2361feb..014593df9324 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -86,10 +86,7 @@ importers: rollup: ^2.32.0 sirv: ^1.0.7 packages/adapter-static: - dependencies: - '@sveltejs/app-utils': 'link:../app-utils' - specifiers: - '@sveltejs/app-utils': 'workspace:*' + specifiers: {} packages/adapter-vercel: devDependencies: '@sveltejs/app-utils': 'link:../app-utils' From 46fb674a55384d53d29747cd947e96b90125dd57 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 14:13:48 -0500 Subject: [PATCH 28/30] tidy up --- packages/kit/src/api/build/Builder.js | 1 - packages/kit/src/renderer/page.js | 2 -- 2 files changed, 3 deletions(-) diff --git a/packages/kit/src/api/build/Builder.js b/packages/kit/src/api/build/Builder.js index 847778a0f479..7c96c85d3fbe 100644 --- a/packages/kit/src/api/build/Builder.js +++ b/packages/kit/src/api/build/Builder.js @@ -1,4 +1,3 @@ -import { rollup } from 'rollup'; import { copy } from '@sveltejs/app-utils/files'; import { prerender } from './prerender'; diff --git a/packages/kit/src/renderer/page.js b/packages/kit/src/renderer/page.js index 774099436df5..6f835c2487ea 100644 --- a/packages/kit/src/renderer/page.js +++ b/packages/kit/src/renderer/page.js @@ -298,8 +298,6 @@ export default async function render_page( dependencies }; } catch (thrown) { - console.error(thrown.stack); - if (!error) { const status = thrown.status || 500; return render_page(request, context, options, status, thrown); From 6a56c16654e99ea4e8f92f75862cdd47b8009d41 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 14:19:50 -0500 Subject: [PATCH 29/30] update snowpack config --- packages/snowpack-config/snowpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/snowpack-config/snowpack.config.js b/packages/snowpack-config/snowpack.config.js index 709b7b9d2d37..0e6603bdd3e0 100644 --- a/packages/snowpack-config/snowpack.config.js +++ b/packages/snowpack-config/snowpack.config.js @@ -28,7 +28,7 @@ module.exports = { 'src/setup': '/_app/setup' }, alias: { - $app: '/_app/main/runtime', + $app: './.svelte/main/runtime', $components: './src/components' } }; From e644180b4a60e8a32120844bb3f180156e737f37 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Nov 2020 14:20:47 -0500 Subject: [PATCH 30/30] add changeset --- .changeset/gold-readers-sit.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/gold-readers-sit.md diff --git a/.changeset/gold-readers-sit.md b/.changeset/gold-readers-sit.md new file mode 100644 index 000000000000..9f3e334e225c --- /dev/null +++ b/.changeset/gold-readers-sit.md @@ -0,0 +1,12 @@ +--- +'hn.svelte.dev': patch +'svelte-kit-demo': patch +'@sveltejs/adapter-netlify': patch +'@sveltejs/adapter-node': patch +'@sveltejs/adapter-static': patch +'@sveltejs/app-utils': patch +'@sveltejs/kit': patch +'@sveltejs/snowpack-config': patch +--- + +Overhaul adapter API - fixes #166