diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..9e148565d Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..b512c09d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/.svelte-kit/ambient.d.ts b/.svelte-kit/ambient.d.ts new file mode 100644 index 000000000..c605496de --- /dev/null +++ b/.svelte-kit/ambient.d.ts @@ -0,0 +1,245 @@ + +// this file is generated — do not edit it + + +/// + +/** + * Environment variables [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env`. Like [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), this module cannot be imported into client-side code. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://kit.svelte.dev/docs/configuration#env) (if configured). + * + * _Unlike_ [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), the values exported from this module are statically injected into your bundle at build time, enabling optimisations like dead code elimination. + * + * ```ts + * import { API_KEY } from '$env/static/private'; + * ``` + * + * Note that all environment variables referenced in your code should be declared (for example in an `.env` file), even if they don't have a value until the app is deployed: + * + * ``` + * MY_FEATURE_FLAG="" + * ``` + * + * You can override `.env` values from the command line like so: + * + * ```bash + * MY_FEATURE_FLAG="enabled" npm run dev + * ``` + */ +declare module '$env/static/private' { + export const ALLUSERSPROFILE: string; + export const APPDATA: string; + export const CHROME_CRASHPAD_PIPE_NAME: string; + export const COLOR: string; + export const COLORTERM: string; + export const CommonProgramFiles: string; + export const CommonProgramW6432: string; + export const COMPUTERNAME: string; + export const ComSpec: string; + export const DriverData: string; + export const EDITOR: string; + export const EFC_9224: string; + export const GIT_ASKPASS: string; + export const HOME: string; + export const HOMEDRIVE: string; + export const HOMEPATH: string; + export const INIT_CWD: string; + export const LANG: string; + export const LOCALAPPDATA: string; + export const LOGONSERVER: string; + export const NODE: string; + export const NODE_ENV: string; + export const NODE_EXE: string; + export const NPM_CLI_JS: string; + export const npm_command: string; + export const npm_config_cache: string; + export const npm_config_globalconfig: string; + export const npm_config_global_prefix: string; + export const npm_config_init_module: string; + export const npm_config_local_prefix: string; + export const npm_config_metrics_registry: string; + export const npm_config_node_gyp: string; + export const npm_config_noproxy: string; + export const npm_config_npm_version: string; + export const npm_config_prefix: string; + export const npm_config_userconfig: string; + export const npm_config_user_agent: string; + export const npm_execpath: string; + export const npm_lifecycle_event: string; + export const npm_lifecycle_script: string; + export const npm_node_execpath: string; + export const npm_package_json: string; + export const npm_package_name: string; + export const npm_package_version: string; + export const NPM_PREFIX_NPM_CLI_JS: string; + export const NUMBER_OF_PROCESSORS: string; + export const OculusBase: string; + export const OneDrive: string; + export const OneDriveConsumer: string; + export const ORIGINAL_XDG_CURRENT_DESKTOP: string; + export const OS: string; + export const Path: string; + export const PATHEXT: string; + export const PROCESSOR_ARCHITECTURE: string; + export const PROCESSOR_IDENTIFIER: string; + export const PROCESSOR_LEVEL: string; + export const PROCESSOR_REVISION: string; + export const ProgramData: string; + export const ProgramFiles: string; + export const ProgramW6432: string; + export const PROMPT: string; + export const PSModulePath: string; + export const PUBLIC: string; + export const SESSIONNAME: string; + export const SystemDrive: string; + export const SystemRoot: string; + export const TEMP: string; + export const TERM_PROGRAM: string; + export const TERM_PROGRAM_VERSION: string; + export const TMP: string; + export const USERDOMAIN: string; + export const USERDOMAIN_ROAMINGPROFILE: string; + export const USERNAME: string; + export const USERPROFILE: string; + export const VBOX_HWVIRTEX_IGNORE_SVM_IN_USE: string; + export const VBOX_MSI_INSTALL_PATH: string; + export const VSCODE_GIT_ASKPASS_EXTRA_ARGS: string; + export const VSCODE_GIT_ASKPASS_MAIN: string; + export const VSCODE_GIT_ASKPASS_NODE: string; + export const VSCODE_GIT_IPC_HANDLE: string; + export const VSCODE_INJECTION: string; + export const windir: string; +} + +/** + * Similar to [`$env/static/private`](https://kit.svelte.dev/docs/modules#$env-static-private), except that it only includes environment variables that begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code. + * + * Values are replaced statically at build time. + * + * ```ts + * import { PUBLIC_BASE_URL } from '$env/static/public'; + * ``` + */ +declare module '$env/static/public' { + +} + +/** + * This module provides access to runtime environment variables, as defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://kit.svelte.dev/docs/cli)), this is equivalent to `process.env`. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://kit.svelte.dev/docs/configuration#env) (if configured). + * + * This module cannot be imported into client-side code. + * + * Dynamic environment variables cannot be used during prerendering. + * + * ```ts + * import { env } from '$env/dynamic/private'; + * console.log(env.DEPLOYMENT_SPECIFIC_VARIABLE); + * ``` + * + * > In `dev`, `$env/dynamic` always includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter. + */ +declare module '$env/dynamic/private' { + export const env: { + ALLUSERSPROFILE: string; + APPDATA: string; + CHROME_CRASHPAD_PIPE_NAME: string; + COLOR: string; + COLORTERM: string; + CommonProgramFiles: string; + CommonProgramW6432: string; + COMPUTERNAME: string; + ComSpec: string; + DriverData: string; + EDITOR: string; + EFC_9224: string; + GIT_ASKPASS: string; + HOME: string; + HOMEDRIVE: string; + HOMEPATH: string; + INIT_CWD: string; + LANG: string; + LOCALAPPDATA: string; + LOGONSERVER: string; + NODE: string; + NODE_ENV: string; + NODE_EXE: string; + NPM_CLI_JS: string; + npm_command: string; + npm_config_cache: string; + npm_config_globalconfig: string; + npm_config_global_prefix: string; + npm_config_init_module: string; + npm_config_local_prefix: string; + npm_config_metrics_registry: string; + npm_config_node_gyp: string; + npm_config_noproxy: string; + npm_config_npm_version: string; + npm_config_prefix: string; + npm_config_userconfig: string; + npm_config_user_agent: string; + npm_execpath: string; + npm_lifecycle_event: string; + npm_lifecycle_script: string; + npm_node_execpath: string; + npm_package_json: string; + npm_package_name: string; + npm_package_version: string; + NPM_PREFIX_NPM_CLI_JS: string; + NUMBER_OF_PROCESSORS: string; + OculusBase: string; + OneDrive: string; + OneDriveConsumer: string; + ORIGINAL_XDG_CURRENT_DESKTOP: string; + OS: string; + Path: string; + PATHEXT: string; + PROCESSOR_ARCHITECTURE: string; + PROCESSOR_IDENTIFIER: string; + PROCESSOR_LEVEL: string; + PROCESSOR_REVISION: string; + ProgramData: string; + ProgramFiles: string; + ProgramW6432: string; + PROMPT: string; + PSModulePath: string; + PUBLIC: string; + SESSIONNAME: string; + SystemDrive: string; + SystemRoot: string; + TEMP: string; + TERM_PROGRAM: string; + TERM_PROGRAM_VERSION: string; + TMP: string; + USERDOMAIN: string; + USERDOMAIN_ROAMINGPROFILE: string; + USERNAME: string; + USERPROFILE: string; + VBOX_HWVIRTEX_IGNORE_SVM_IN_USE: string; + VBOX_MSI_INSTALL_PATH: string; + VSCODE_GIT_ASKPASS_EXTRA_ARGS: string; + VSCODE_GIT_ASKPASS_MAIN: string; + VSCODE_GIT_ASKPASS_NODE: string; + VSCODE_GIT_IPC_HANDLE: string; + VSCODE_INJECTION: string; + windir: string; + [key: `PUBLIC_${string}`]: undefined; + [key: `${string}`]: string | undefined; + } +} + +/** + * Similar to [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), but only includes variables that begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code. + * + * Note that public dynamic environment variables must all be sent from the server to the client, causing larger network requests — when possible, use `$env/static/public` instead. + * + * Dynamic environment variables cannot be used during prerendering. + * + * ```ts + * import { env } from '$env/dynamic/public'; + * console.log(env.PUBLIC_DEPLOYMENT_SPECIFIC_VARIABLE); + * ``` + */ +declare module '$env/dynamic/public' { + export const env: { + [key: `PUBLIC_${string}`]: string | undefined; + } +} diff --git a/.svelte-kit/generated/client/app.js b/.svelte-kit/generated/client/app.js new file mode 100644 index 000000000..4422d7a86 --- /dev/null +++ b/.svelte-kit/generated/client/app.js @@ -0,0 +1,29 @@ +export { matchers } from './matchers.js'; + +export const nodes = [ + () => import('./nodes/0'), + () => import('./nodes/1'), + () => import('./nodes/2'), + () => import('./nodes/3'), + () => import('./nodes/4'), + () => import('./nodes/5'), + () => import('./nodes/6'), + () => import('./nodes/7') +]; + +export const server_loads = []; + +export const dictionary = { + "/": [~2], + "/kaart": [~3], + "/kennisbank": [~4], + "/kennisbank/[slug]": [~5], + "/projecten": [~6], + "/projecten/[slug]": [~7] + }; + +export const hooks = { + handleError: (({ error }) => { console.error(error) }), +}; + +export { default as root } from '../root.svelte'; \ No newline at end of file diff --git a/.svelte-kit/generated/client/matchers.js b/.svelte-kit/generated/client/matchers.js new file mode 100644 index 000000000..f6bd30a4e --- /dev/null +++ b/.svelte-kit/generated/client/matchers.js @@ -0,0 +1 @@ +export const matchers = {}; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/0.js b/.svelte-kit/generated/client/nodes/0.js new file mode 100644 index 000000000..45d0407e9 --- /dev/null +++ b/.svelte-kit/generated/client/nodes/0.js @@ -0,0 +1,3 @@ +import * as universal from "../../../../src/routes/+layout.js"; +export { universal }; +export { default as component } from "../../../../src/routes/+layout.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/1.js b/.svelte-kit/generated/client/nodes/1.js new file mode 100644 index 000000000..35bc24b38 --- /dev/null +++ b/.svelte-kit/generated/client/nodes/1.js @@ -0,0 +1 @@ +export { default as component } from "../../../../node_modules/@sveltejs/kit/src/runtime/components/error.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/2.js b/.svelte-kit/generated/client/nodes/2.js new file mode 100644 index 000000000..1cb4f8552 --- /dev/null +++ b/.svelte-kit/generated/client/nodes/2.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/3.js b/.svelte-kit/generated/client/nodes/3.js new file mode 100644 index 000000000..4737ade07 --- /dev/null +++ b/.svelte-kit/generated/client/nodes/3.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/kaart/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/4.js b/.svelte-kit/generated/client/nodes/4.js new file mode 100644 index 000000000..1cf297941 --- /dev/null +++ b/.svelte-kit/generated/client/nodes/4.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/kennisbank/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/5.js b/.svelte-kit/generated/client/nodes/5.js new file mode 100644 index 000000000..2b69cd7bb --- /dev/null +++ b/.svelte-kit/generated/client/nodes/5.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/kennisbank/[slug]/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/6.js b/.svelte-kit/generated/client/nodes/6.js new file mode 100644 index 000000000..1742a1987 --- /dev/null +++ b/.svelte-kit/generated/client/nodes/6.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/projecten/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/7.js b/.svelte-kit/generated/client/nodes/7.js new file mode 100644 index 000000000..588371e69 --- /dev/null +++ b/.svelte-kit/generated/client/nodes/7.js @@ -0,0 +1 @@ +export { default as component } from "../../../../src/routes/projecten/[slug]/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/root.svelte b/.svelte-kit/generated/root.svelte new file mode 100644 index 000000000..1172dda0a --- /dev/null +++ b/.svelte-kit/generated/root.svelte @@ -0,0 +1,57 @@ + + + + +{#if constructors[1]} + + + +{:else} + +{/if} + +{#if mounted} +
+ {#if navigated} + {title} + {/if} +
+{/if} \ No newline at end of file diff --git a/.svelte-kit/generated/server/internal.js b/.svelte-kit/generated/server/internal.js new file mode 100644 index 000000000..69602e032 --- /dev/null +++ b/.svelte-kit/generated/server/internal.js @@ -0,0 +1,30 @@ + +import root from '../root.svelte'; +import { set_building, set_prerendering } from '__sveltekit/environment'; +import { set_assets } from '__sveltekit/paths'; +import { set_private_env, set_public_env, set_safe_public_env } from '../../../node_modules/@sveltejs/kit/src/runtime/shared-server.js'; + +export const options = { + app_dir: "_app", + app_template_contains_nonce: false, + csp: {"mode":"auto","directives":{"upgrade-insecure-requests":false,"block-all-mixed-content":false},"reportOnly":{"upgrade-insecure-requests":false,"block-all-mixed-content":false}}, + csrf_check_origin: true, + embedded: false, + env_public_prefix: 'PUBLIC_', + env_private_prefix: '', + hooks: null, // added lazily, via `get_hooks` + preload_strategy: "modulepreload", + root, + service_worker: false, + templates: { + app: ({ head, body, assets, nonce, env }) => "\n\n\n\n\t\n\t\n\t\n\t\n\n\n\tSPATwater - Een nieuwe generatie hydrologen\n\n\t" + head + "\n\n\t\n\t\n\t\n\n\n\t\n\t\n\n\t\n\t\n\n\t\n\t\n\n\t\n\t\n\t\n\n\n\n\n\t
" + body + "
\n\n\n\n\n", + error: ({ status, message }) => "\n\n\t\n\t\t\n\t\t" + message + "\n\n\t\t\n\t\n\t\n\t\t
\n\t\t\t" + status + "\n\t\t\t
\n\t\t\t\t

" + message + "

\n\t\t\t
\n\t\t
\n\t\n\n" + }, + version_hash: "tyvse0" +}; + +export function get_hooks() { + return {}; +} + +export { set_assets, set_building, set_prerendering, set_private_env, set_public_env, set_safe_public_env }; diff --git a/.svelte-kit/non-ambient.d.ts b/.svelte-kit/non-ambient.d.ts new file mode 100644 index 000000000..46bd7fb07 --- /dev/null +++ b/.svelte-kit/non-ambient.d.ts @@ -0,0 +1,25 @@ + +// this file is generated — do not edit it + + +declare module "svelte/elements" { + export interface HTMLAttributes { + 'data-sveltekit-keepfocus'?: true | '' | 'off' | undefined | null; + 'data-sveltekit-noscroll'?: true | '' | 'off' | undefined | null; + 'data-sveltekit-preload-code'?: + | true + | '' + | 'eager' + | 'viewport' + | 'hover' + | 'tap' + | 'off' + | undefined + | null; + 'data-sveltekit-preload-data'?: true | '' | 'hover' | 'tap' | 'off' | undefined | null; + 'data-sveltekit-reload'?: true | '' | 'off' | undefined | null; + 'data-sveltekit-replacestate'?: true | '' | 'off' | undefined | null; + } +} + +export {}; diff --git a/.svelte-kit/tsconfig.json b/.svelte-kit/tsconfig.json new file mode 100644 index 000000000..456457789 --- /dev/null +++ b/.svelte-kit/tsconfig.json @@ -0,0 +1,46 @@ +{ + "compilerOptions": { + "paths": { + "$lib": [ + "../src/lib" + ], + "$lib/*": [ + "../src/lib/*" + ] + }, + "rootDirs": [ + "..", + "./types" + ], + "verbatimModuleSyntax": true, + "isolatedModules": true, + "lib": [ + "esnext", + "DOM", + "DOM.Iterable" + ], + "moduleResolution": "bundler", + "module": "esnext", + "noEmit": true, + "target": "esnext" + }, + "include": [ + "ambient.d.ts", + "non-ambient.d.ts", + "./types/**/$types.d.ts", + "../vite.config.js", + "../vite.config.ts", + "../src/**/*.js", + "../src/**/*.ts", + "../src/**/*.svelte", + "../tests/**/*.js", + "../tests/**/*.ts", + "../tests/**/*.svelte" + ], + "exclude": [ + "../node_modules/**", + "../src/service-worker.js", + "../src/service-worker.ts", + "../src/service-worker.d.ts" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 446aa5991..e081d86b7 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,59 @@ -> _Fork_ deze leertaak en ga aan de slag. -Onderstaande outline ga je gedurende deze taak in jouw eigen GitHub omgeving uitwerken. -De instructie vind je in: [docs/INSTRUCTIONS.md](docs/INSTRUCTIONS.md) -# Titel - +# SPAT-Water💧 + +## Beschrijving 📃 +Ontwerp en maak een component / website voor een opdrachtgever op basis van een bestaande Headless CMS API. + +![mockup3](https://github.com/sannevanseeventer/SPATwater-2.0/assets/112857444/e668acea-201f-4391-be72-2eb91ce4367d) + + ## Inhoudsopgave - * [Beschrijving](#beschrijving) - * [Kenmerken](#kenmerken) - * [Installatie](#installatie) - * [Gebruik](#gebruik) - * [Bronnen](#bronnen) + * [Beschrijving📃](#beschrijving) + * [Gebruik👥](#gebruik) + * [Kenmerken✅](#kenmerken) + * [Installatie⚙️](#installatie) + * [Bronnen🌐](#bronnen) * [Licentie](#licentie) + +## Gebruik 👥 -## Beschrijving - - -## Kenmerken + +## Kenmerken ✅ -## Installatie -## Gebruik +**TOOLS 🧰:** +* VSCode +* Miro +* Figma + +**GEBRUIKTE TECHNIEKEN 🛠️:** -## Bronnen +* Svelte +* Sveltekit +* Hygragh +* JS +* CSS + +**COMMUNICATIE MIDDELEN 🗣️:** -## Licentie +* Team Canvas +* Microsoft Teams +* Calls + +## Installatie ⚙️ + +1. Clone of download deze repository naar de gewenste folder. +2. Open de root directory van dit project en open het project in een code editor naar keuze. +3. Gebruik npm install om de benodigde packages te downloaden voor dit project. +4. Voor het gebruik van Hygraph om data in te laden gebruik dan het commando npm graphql-request om requesten te fetchen. +5. Start een server met npm run dev. -This project is licensed under the terms of the [MIT license](./LICENSE). +## Bronnen 🌐 + +## Licentie +This project is licensed under the terms of the MIT license. diff --git a/node_modules/.bin/acorn b/node_modules/.bin/acorn new file mode 100644 index 000000000..46a3e61a1 --- /dev/null +++ b/node_modules/.bin/acorn @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../acorn/bin/acorn" "$@" +else + exec node "$basedir/../acorn/bin/acorn" "$@" +fi diff --git a/node_modules/.bin/acorn.cmd b/node_modules/.bin/acorn.cmd new file mode 100644 index 000000000..f38017c45 --- /dev/null +++ b/node_modules/.bin/acorn.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\acorn\bin\acorn" %* diff --git a/node_modules/.bin/acorn.ps1 b/node_modules/.bin/acorn.ps1 new file mode 100644 index 000000000..6f6dcddf3 --- /dev/null +++ b/node_modules/.bin/acorn.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../acorn/bin/acorn" $args + } else { + & "$basedir/node$exe" "$basedir/../acorn/bin/acorn" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../acorn/bin/acorn" $args + } else { + & "node$exe" "$basedir/../acorn/bin/acorn" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.bin/esbuild b/node_modules/.bin/esbuild new file mode 100644 index 000000000..26bef5477 --- /dev/null +++ b/node_modules/.bin/esbuild @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../esbuild/bin/esbuild" "$@" +else + exec node "$basedir/../esbuild/bin/esbuild" "$@" +fi diff --git a/node_modules/.bin/esbuild.cmd b/node_modules/.bin/esbuild.cmd new file mode 100644 index 000000000..d36853926 --- /dev/null +++ b/node_modules/.bin/esbuild.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\esbuild\bin\esbuild" %* diff --git a/node_modules/.bin/esbuild.ps1 b/node_modules/.bin/esbuild.ps1 new file mode 100644 index 000000000..81ffbf9c3 --- /dev/null +++ b/node_modules/.bin/esbuild.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../esbuild/bin/esbuild" $args + } else { + & "$basedir/node$exe" "$basedir/../esbuild/bin/esbuild" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../esbuild/bin/esbuild" $args + } else { + & "node$exe" "$basedir/../esbuild/bin/esbuild" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.bin/nanoid b/node_modules/.bin/nanoid new file mode 100644 index 000000000..23254eb22 --- /dev/null +++ b/node_modules/.bin/nanoid @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../nanoid/bin/nanoid.cjs" "$@" +else + exec node "$basedir/../nanoid/bin/nanoid.cjs" "$@" +fi diff --git a/node_modules/.bin/nanoid.cmd b/node_modules/.bin/nanoid.cmd new file mode 100644 index 000000000..601a2c88c --- /dev/null +++ b/node_modules/.bin/nanoid.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nanoid\bin\nanoid.cjs" %* diff --git a/node_modules/.bin/nanoid.ps1 b/node_modules/.bin/nanoid.ps1 new file mode 100644 index 000000000..d8a4d7ad2 --- /dev/null +++ b/node_modules/.bin/nanoid.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args + } else { + & "$basedir/node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args + } else { + & "node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.bin/rollup b/node_modules/.bin/rollup new file mode 100644 index 000000000..11bd86d07 --- /dev/null +++ b/node_modules/.bin/rollup @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../rollup/dist/bin/rollup" "$@" +else + exec node "$basedir/../rollup/dist/bin/rollup" "$@" +fi diff --git a/node_modules/.bin/rollup.cmd b/node_modules/.bin/rollup.cmd new file mode 100644 index 000000000..d9a0a3593 --- /dev/null +++ b/node_modules/.bin/rollup.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\rollup\dist\bin\rollup" %* diff --git a/node_modules/.bin/rollup.ps1 b/node_modules/.bin/rollup.ps1 new file mode 100644 index 000000000..10f657d72 --- /dev/null +++ b/node_modules/.bin/rollup.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../rollup/dist/bin/rollup" $args + } else { + & "$basedir/node$exe" "$basedir/../rollup/dist/bin/rollup" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../rollup/dist/bin/rollup" $args + } else { + & "node$exe" "$basedir/../rollup/dist/bin/rollup" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.bin/svelte-kit b/node_modules/.bin/svelte-kit new file mode 100644 index 000000000..610e55b5f --- /dev/null +++ b/node_modules/.bin/svelte-kit @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../@sveltejs/kit/svelte-kit.js" "$@" +else + exec node "$basedir/../@sveltejs/kit/svelte-kit.js" "$@" +fi diff --git a/node_modules/.bin/svelte-kit.cmd b/node_modules/.bin/svelte-kit.cmd new file mode 100644 index 000000000..3cf5da1fa --- /dev/null +++ b/node_modules/.bin/svelte-kit.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\@sveltejs\kit\svelte-kit.js" %* diff --git a/node_modules/.bin/svelte-kit.ps1 b/node_modules/.bin/svelte-kit.ps1 new file mode 100644 index 000000000..1ac1f3f72 --- /dev/null +++ b/node_modules/.bin/svelte-kit.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../@sveltejs/kit/svelte-kit.js" $args + } else { + & "$basedir/node$exe" "$basedir/../@sveltejs/kit/svelte-kit.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../@sveltejs/kit/svelte-kit.js" $args + } else { + & "node$exe" "$basedir/../@sveltejs/kit/svelte-kit.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.bin/vite b/node_modules/.bin/vite new file mode 100755 index 000000000..a85d325d8 --- /dev/null +++ b/node_modules/.bin/vite @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@" +else + exec node "$basedir/../vite/bin/vite.js" "$@" +fi diff --git a/node_modules/.bin/vite.cmd b/node_modules/.bin/vite.cmd new file mode 100644 index 000000000..e824f3a62 --- /dev/null +++ b/node_modules/.bin/vite.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\vite\bin\vite.js" %* diff --git a/node_modules/.bin/vite.ps1 b/node_modules/.bin/vite.ps1 new file mode 100644 index 000000000..a7759bcf2 --- /dev/null +++ b/node_modules/.bin/vite.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../vite/bin/vite.js" $args + } else { + & "$basedir/node$exe" "$basedir/../vite/bin/vite.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../vite/bin/vite.js" $args + } else { + & "node$exe" "$basedir/../vite/bin/vite.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 000000000..3feabb98a --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,856 @@ +{ + "name": "spatwater-3.0", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.19.10", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.10.tgz", + "integrity": "sha512-alfGtT+IEICKtNE54hbvPg13xGBe4GkVxyGWtzr+yHO7HIiRJppPDhOKq3zstTcVf8msXb/t4eavW3jCDpMSmA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.19.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.10.tgz", + "integrity": "sha512-whqLG6Sc70AbU73fFYvuYzaE4MNMBIlR1Y/IrUeOXFrWHxBEjjbZaQ3IXIQS8wJdAzue2GwYZCjOrgrU1oUHoA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@graphql-typed-document-node/core": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz", + "integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==", + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@polka/url": { + "version": "1.0.0-next.24", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.24.tgz", + "integrity": "sha512-2LuNTFBIO0m7kKIQvvPHN6UE63VjpmL9rnEEaOOaiSPbZK+zUOYIzBAWcED+3XYzhYsd/0mD57VdxAEqqV52CQ==", + "dev": true + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.1.tgz", + "integrity": "sha512-KyP/byeXu9V+etKO6Lw3E4tW4QdcnzDG/ake031mg42lob5tN+5qfr+lkcT/SGZaH2PdW4Z1NX9GHEkZ8xV7og==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.1.tgz", + "integrity": "sha512-PyJsSsafjmIhVgaI1Zdj7m8BB8mMckFah/xbpplObyHfiXzKcI5UOUXRyOdHW7nz4DpMCuzLnF7v5IWHenCwYA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@sveltejs/adapter-auto": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sveltejs/adapter-auto/-/adapter-auto-3.0.1.tgz", + "integrity": "sha512-OpilmvRN136lUgOa9F0zpSI6g+PouOmk+YvJQrB+/hAtllLghjjYuoyfUsrF7U6oJ52cxCtAJTPXgZdyyCffrQ==", + "dev": true, + "dependencies": { + "import-meta-resolve": "^4.0.0" + }, + "peerDependencies": { + "@sveltejs/kit": "^2.0.0" + } + }, + "node_modules/@sveltejs/adapter-static": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-3.0.1.tgz", + "integrity": "sha512-6lMvf7xYEJ+oGeR5L8DFJJrowkefTK6ZgA4JiMqoClMkKq0s6yvsd3FZfCFvX1fQ0tpCD7fkuRVHsnUVgsHyNg==", + "dev": true, + "peerDependencies": { + "@sveltejs/kit": "^2.0.0" + } + }, + "node_modules/@sveltejs/kit": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.0.6.tgz", + "integrity": "sha512-dnHtyjBLGXx+hrZQ9GuqLlSfTBixewJaByUVWai7LmB4dgV3FwkK155OltEgONDQW6KW64hLNS/uojdx3uC2/g==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@types/cookie": "^0.6.0", + "cookie": "^0.6.0", + "devalue": "^4.3.2", + "esm-env": "^1.0.0", + "kleur": "^4.1.5", + "magic-string": "^0.30.5", + "mrmime": "^2.0.0", + "sade": "^1.8.1", + "set-cookie-parser": "^2.6.0", + "sirv": "^2.0.4", + "tiny-glob": "^0.2.9" + }, + "bin": { + "svelte-kit": "svelte-kit.js" + }, + "engines": { + "node": ">=18.13" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.3" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-3.0.1.tgz", + "integrity": "sha512-CGURX6Ps+TkOovK6xV+Y2rn8JKa8ZPUHPZ/NKgCxAmgBrXReavzFl8aOSCj3kQ1xqT7yGJj53hjcV/gqwDAaWA==", + "dev": true, + "dependencies": { + "@sveltejs/vite-plugin-svelte-inspector": "^2.0.0-next.0 || ^2.0.0", + "debug": "^4.3.4", + "deepmerge": "^4.3.1", + "kleur": "^4.1.5", + "magic-string": "^0.30.5", + "svelte-hmr": "^0.15.3", + "vitefu": "^0.2.5" + }, + "engines": { + "node": "^18.0.0 || >=20" + }, + "peerDependencies": { + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.0" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte-inspector": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-2.0.0.tgz", + "integrity": "sha512-gjr9ZFg1BSlIpfZ4PRewigrvYmHWbDrq2uvvPB1AmTWKuM+dI1JXQSUu2pIrYLb/QncyiIGkFDFKTwJ0XqQZZg==", + "dev": true, + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.0.0 || >=20" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.0" + } + }, + "node_modules/@types/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==", + "dev": true + }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, + "node_modules/acorn": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/axobject-query": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", + "integrity": "sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==", + "dev": true, + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/code-red": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz", + "integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15", + "@types/estree": "^1.0.1", + "acorn": "^8.10.0", + "estree-walker": "^3.0.3", + "periscopic": "^3.1.0" + } + }, + "node_modules/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cross-fetch": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", + "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", + "dependencies": { + "node-fetch": "^2.6.12" + } + }, + "node_modules/css-tree": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", + "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==", + "dev": true, + "dependencies": { + "mdn-data": "2.0.30", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/devalue": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-4.3.2.tgz", + "integrity": "sha512-KqFl6pOgOW+Y6wJgu80rHpo2/3H07vr8ntR9rkkFIRETewbf5GaYYcakYfiKz89K+sLsuPkQIZaXDMjUObZwWg==", + "dev": true + }, + "node_modules/esbuild": { + "version": "0.19.10", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.10.tgz", + "integrity": "sha512-S1Y27QGt/snkNYrRcswgRFqZjaTG5a5xM3EQo97uNBnH505pdzSNe/HLBq1v0RO7iK/ngdbhJB6mDAp0OK+iUA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.19.10", + "@esbuild/android-arm": "0.19.10", + "@esbuild/android-arm64": "0.19.10", + "@esbuild/android-x64": "0.19.10", + "@esbuild/darwin-arm64": "0.19.10", + "@esbuild/darwin-x64": "0.19.10", + "@esbuild/freebsd-arm64": "0.19.10", + "@esbuild/freebsd-x64": "0.19.10", + "@esbuild/linux-arm": "0.19.10", + "@esbuild/linux-arm64": "0.19.10", + "@esbuild/linux-ia32": "0.19.10", + "@esbuild/linux-loong64": "0.19.10", + "@esbuild/linux-mips64el": "0.19.10", + "@esbuild/linux-ppc64": "0.19.10", + "@esbuild/linux-riscv64": "0.19.10", + "@esbuild/linux-s390x": "0.19.10", + "@esbuild/linux-x64": "0.19.10", + "@esbuild/netbsd-x64": "0.19.10", + "@esbuild/openbsd-x64": "0.19.10", + "@esbuild/sunos-x64": "0.19.10", + "@esbuild/win32-arm64": "0.19.10", + "@esbuild/win32-ia32": "0.19.10", + "@esbuild/win32-x64": "0.19.10" + } + }, + "node_modules/esm-env": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.0.0.tgz", + "integrity": "sha512-Cf6VksWPsTuW01vU9Mk/3vRue91Zevka5SjyNf3nEpokFRuqt/KjUQoGAwq9qMmhpLTHmXzSIrFRw8zxWzmFBA==", + "dev": true + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/globalyzer": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz", + "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==", + "dev": true + }, + "node_modules/globrex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", + "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==", + "dev": true + }, + "node_modules/graphql": { + "version": "16.8.1", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz", + "integrity": "sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==", + "peer": true, + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } + }, + "node_modules/graphql-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/graphql-request/-/graphql-request-6.1.0.tgz", + "integrity": "sha512-p+XPfS4q7aIpKVcgmnZKhMNqhltk20hfXtkaIkTfjjmiKMJ5xrt5c743cL03y/K7y1rg3WrIC49xGiEQ4mxdNw==", + "dependencies": { + "@graphql-typed-document-node/core": "^3.2.0", + "cross-fetch": "^3.1.5" + }, + "peerDependencies": { + "graphql": "14 - 16" + } + }, + "node_modules/import-meta-resolve": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.0.0.tgz", + "integrity": "sha512-okYUR7ZQPH+efeuMJGlq4f8ubUgO50kByRPyt/Cy1Io4PSRsPjxME+YlVaCOx+NIToW7hCsZNFJyTPFFKepRSA==", + "dev": true, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-reference": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz", + "integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==", + "dev": true, + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/locate-character": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", + "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==", + "dev": true + }, + "node_modules/magic-string": { + "version": "0.30.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/mdn-data": { + "version": "2.0.30", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", + "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", + "dev": true + }, + "node_modules/mgrs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mgrs/-/mgrs-1.0.0.tgz", + "integrity": "sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA==" + }, + "node_modules/mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/mrmime": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz", + "integrity": "sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/nanoid": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/nodemailer": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.7.tgz", + "integrity": "sha512-rUtR77ksqex/eZRLmQ21LKVH5nAAsVicAtAYudK7JgwenEDZ0UIQ1adUGqErz7sMkWYxWTTU1aeP2Jga6WQyJw==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/periscopic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz", + "integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^3.0.0", + "is-reference": "^3.0.0" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "node_modules/postcss": { + "version": "8.4.32", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.32.tgz", + "integrity": "sha512-D/kj5JNu6oo2EIy+XL/26JEDTlIbB8hw85G8StOE6L74RQAVVP5rej6wxCNqyMbR4RkPfqvezVbPw81Ngd6Kcw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.7", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/proj4": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/proj4/-/proj4-2.9.2.tgz", + "integrity": "sha512-bdyfNmtlWjQN/rHEHEiqFvpTUHhuzDaeQ6Uu1G4sPGqk+Xkxae6ahh865fClJokSGPBmlDOQWWaO6465TCfv5Q==", + "dependencies": { + "mgrs": "1.0.0", + "wkt-parser": "^1.3.3" + } + }, + "node_modules/rollup": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.9.1.tgz", + "integrity": "sha512-pgPO9DWzLoW/vIhlSoDByCzcpX92bKEorbgXuZrqxByte3JFk2xSW2JEeAcyLc9Ru9pqcNNW+Ob7ntsk2oT/Xw==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.9.1", + "@rollup/rollup-android-arm64": "4.9.1", + "@rollup/rollup-darwin-arm64": "4.9.1", + "@rollup/rollup-darwin-x64": "4.9.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.9.1", + "@rollup/rollup-linux-arm64-gnu": "4.9.1", + "@rollup/rollup-linux-arm64-musl": "4.9.1", + "@rollup/rollup-linux-riscv64-gnu": "4.9.1", + "@rollup/rollup-linux-x64-gnu": "4.9.1", + "@rollup/rollup-linux-x64-musl": "4.9.1", + "@rollup/rollup-win32-arm64-msvc": "4.9.1", + "@rollup/rollup-win32-ia32-msvc": "4.9.1", + "@rollup/rollup-win32-x64-msvc": "4.9.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/sade": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz", + "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==", + "dev": true, + "dependencies": { + "mri": "^1.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/set-cookie-parser": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz", + "integrity": "sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==", + "dev": true + }, + "node_modules/sirv": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz", + "integrity": "sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==", + "dev": true, + "dependencies": { + "@polka/url": "^1.0.0-next.24", + "mrmime": "^2.0.0", + "totalist": "^3.0.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/svelte": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.8.tgz", + "integrity": "sha512-hU6dh1MPl8gh6klQZwK/n73GiAHiR95IkFsesLPbMeEZi36ydaXL/ZAb4g9sayT0MXzpxyZjR28yderJHxcmYA==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.1", + "@jridgewell/sourcemap-codec": "^1.4.15", + "@jridgewell/trace-mapping": "^0.3.18", + "acorn": "^8.9.0", + "aria-query": "^5.3.0", + "axobject-query": "^3.2.1", + "code-red": "^1.0.3", + "css-tree": "^2.3.1", + "estree-walker": "^3.0.3", + "is-reference": "^3.0.1", + "locate-character": "^3.0.0", + "magic-string": "^0.30.4", + "periscopic": "^3.1.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/svelte-hmr": { + "version": "0.15.3", + "resolved": "https://registry.npmjs.org/svelte-hmr/-/svelte-hmr-0.15.3.tgz", + "integrity": "sha512-41snaPswvSf8TJUhlkoJBekRrABDXDMdpNpT2tfHIv4JuhgvHqLMhEPGtaQn0BmbNSTkuz2Ed20DF2eHw0SmBQ==", + "dev": true, + "engines": { + "node": "^12.20 || ^14.13.1 || >= 16" + }, + "peerDependencies": { + "svelte": "^3.19.0 || ^4.0.0" + } + }, + "node_modules/tiny-glob": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz", + "integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==", + "dev": true, + "dependencies": { + "globalyzer": "0.1.0", + "globrex": "^0.1.2" + } + }, + "node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/vite": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.10.tgz", + "integrity": "sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==", + "dev": true, + "dependencies": { + "esbuild": "^0.19.3", + "postcss": "^8.4.32", + "rollup": "^4.2.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vitefu": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-0.2.5.tgz", + "integrity": "sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==", + "dev": true, + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/wkt-parser": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/wkt-parser/-/wkt-parser-1.3.3.tgz", + "integrity": "sha512-ZnV3yH8/k58ZPACOXeiHaMuXIiaTk1t0hSUVisbO0t4RjA5wPpUytcxeyiN2h+LZRrmuHIh/1UlrR9e7DHDvTw==" + } + } +} diff --git a/node_modules/.vite/_svelte_metadata.json b/node_modules/.vite/_svelte_metadata.json new file mode 100644 index 000000000..94c9f0647 --- /dev/null +++ b/node_modules/.vite/_svelte_metadata.json @@ -0,0 +1 @@ +{"compilerOptions":{"css":"external","dev":true,"hydratable":true},"configFile":false,"extensions":[".svelte"],"preprocess":{"script":"({ content, filename }) => {\r\n\t\tif (!filename) return;\r\n\r\n\t\tconst basename = path.basename(filename);\r\n\t\tif (basename.startsWith('+page.') || basename.startsWith('+layout.')) {\r\n\t\t\tconst match = content.match(options_regex);\r\n\t\t\tif (match) {\r\n\t\t\t\tconst fixed = basename.replace('.svelte', '(.server).js/ts');\r\n\r\n\t\t\t\tconst message =\r\n\t\t\t\t\t`\\n${colors.bold().red(path.relative('.', filename))}\\n` +\r\n\t\t\t\t\t`\\`${match[1]}\\` will be ignored — move it to ${fixed} instead. See https://kit.svelte.dev/docs/page-options for more information.`;\r\n\r\n\t\t\t\tif (!warned.has(message)) {\r\n\t\t\t\t\tconsole.log(message);\r\n\t\t\t\t\twarned.add(message);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}","markup":"({ content, filename }) => {\r\n\t\tif (!filename) return;\r\n\r\n\t\tconst basename = path.basename(filename);\r\n\t\tconst has_children =\r\n\t\t\tcontent.includes('\\`${isSvelte5Plus() ? ' or `{@render ...}` tag' : ''}` +\r\n\t\t\t\t' missing — inner content will not be rendered';\r\n\r\n\t\t\tif (!warned.has(message)) {\r\n\t\t\t\tconsole.log(message);\r\n\t\t\t\twarned.add(message);\r\n\t\t\t}\r\n\t\t}\r\n\t}"}} \ No newline at end of file diff --git a/node_modules/.vite/deps 2/_metadata.json b/node_modules/.vite/deps 2/_metadata.json new file mode 100644 index 000000000..7e52b4c95 --- /dev/null +++ b/node_modules/.vite/deps 2/_metadata.json @@ -0,0 +1,85 @@ +{ + "hash": "da952cd9", + "configHash": "ddb6ab6c", + "lockfileHash": "c779c783", + "browserHash": "497f1f27", + "optimized": { + "svelte/animate": { + "src": "../../svelte/src/runtime/animate/index.js", + "file": "svelte_animate.js", + "fileHash": "34babf7d", + "needsInterop": false + }, + "svelte/easing": { + "src": "../../svelte/src/runtime/easing/index.js", + "file": "svelte_easing.js", + "fileHash": "7e8b411c", + "needsInterop": false + }, + "svelte/internal": { + "src": "../../svelte/src/runtime/internal/index.js", + "file": "svelte_internal.js", + "fileHash": "4b48776c", + "needsInterop": false + }, + "svelte/internal/disclose-version": { + "src": "../../svelte/src/runtime/internal/disclose-version/index.js", + "file": "svelte_internal_disclose-version.js", + "fileHash": "c5bf46d1", + "needsInterop": false + }, + "svelte/motion": { + "src": "../../svelte/src/runtime/motion/index.js", + "file": "svelte_motion.js", + "fileHash": "170f1750", + "needsInterop": false + }, + "svelte/store": { + "src": "../../svelte/src/runtime/store/index.js", + "file": "svelte_store.js", + "fileHash": "9c94982a", + "needsInterop": false + }, + "svelte/transition": { + "src": "../../svelte/src/runtime/transition/index.js", + "file": "svelte_transition.js", + "fileHash": "92df0870", + "needsInterop": false + }, + "svelte": { + "src": "../../svelte/src/runtime/index.js", + "file": "svelte.js", + "fileHash": "405e13d8", + "needsInterop": false + }, + "devalue": { + "src": "../../devalue/index.js", + "file": "devalue.js", + "fileHash": "7e681b99", + "needsInterop": false + }, + "esm-env": { + "src": "../../esm-env/dev-browser.js", + "file": "esm-env.js", + "fileHash": "50ff36fa", + "needsInterop": false + } + }, + "chunks": { + "chunk-UGRSHENP": { + "file": "chunk-UGRSHENP.js" + }, + "chunk-VFRMSNTO": { + "file": "chunk-VFRMSNTO.js" + }, + "chunk-K76FTQQM": { + "file": "chunk-K76FTQQM.js" + }, + "chunk-ZUGQ3PSC": { + "file": "chunk-ZUGQ3PSC.js" + }, + "chunk-F3FYYIAV": { + "file": "chunk-F3FYYIAV.js" + } + } +} \ No newline at end of file diff --git a/node_modules/.vite/deps/_metadata.json b/node_modules/.vite/deps/_metadata.json new file mode 100644 index 000000000..9d9f785a5 --- /dev/null +++ b/node_modules/.vite/deps/_metadata.json @@ -0,0 +1,91 @@ +{ + "hash": "d5b38d09", + "configHash": "400ec845", + "lockfileHash": "26780c81", + "browserHash": "fe0b4e03", + "optimized": { + "svelte/animate": { + "src": "../../svelte/src/runtime/animate/index.js", + "file": "svelte_animate.js", + "fileHash": "3ed9896e", + "needsInterop": false + }, + "svelte/easing": { + "src": "../../svelte/src/runtime/easing/index.js", + "file": "svelte_easing.js", + "fileHash": "000cc564", + "needsInterop": false + }, + "svelte/internal": { + "src": "../../svelte/src/runtime/internal/index.js", + "file": "svelte_internal.js", + "fileHash": "28db56eb", + "needsInterop": false + }, + "svelte/internal/disclose-version": { + "src": "../../svelte/src/runtime/internal/disclose-version/index.js", + "file": "svelte_internal_disclose-version.js", + "fileHash": "e4a3fbaa", + "needsInterop": false + }, + "svelte/motion": { + "src": "../../svelte/src/runtime/motion/index.js", + "file": "svelte_motion.js", + "fileHash": "50f806b8", + "needsInterop": false + }, + "svelte/store": { + "src": "../../svelte/src/runtime/store/index.js", + "file": "svelte_store.js", + "fileHash": "bcc81276", + "needsInterop": false + }, + "svelte/transition": { + "src": "../../svelte/src/runtime/transition/index.js", + "file": "svelte_transition.js", + "fileHash": "87f803dc", + "needsInterop": false + }, + "svelte": { + "src": "../../svelte/src/runtime/index.js", + "file": "svelte.js", + "fileHash": "f663f548", + "needsInterop": false + }, + "devalue": { + "src": "../../devalue/index.js", + "file": "devalue.js", + "fileHash": "846c627e", + "needsInterop": false + }, + "esm-env": { + "src": "../../esm-env/dev-browser.js", + "file": "esm-env.js", + "fileHash": "30e54d2a", + "needsInterop": false + }, + "proj4": { + "src": "../../proj4/lib/index.js", + "file": "proj4.js", + "fileHash": "ac43f0dd", + "needsInterop": false + } + }, + "chunks": { + "chunk-HLHWFLRS": { + "file": "chunk-HLHWFLRS.js" + }, + "chunk-FI7FPNA6": { + "file": "chunk-FI7FPNA6.js" + }, + "chunk-OWBE2SVS": { + "file": "chunk-OWBE2SVS.js" + }, + "chunk-QGUH75DB": { + "file": "chunk-QGUH75DB.js" + }, + "chunk-F3FYYIAV": { + "file": "chunk-F3FYYIAV.js" + } + } +} \ No newline at end of file diff --git a/node_modules/.vite/deps/chunk-F3FYYIAV.js b/node_modules/.vite/deps/chunk-F3FYYIAV.js new file mode 100644 index 000000000..82ce66a89 --- /dev/null +++ b/node_modules/.vite/deps/chunk-F3FYYIAV.js @@ -0,0 +1,11 @@ +var __defProp = Object.defineProperty; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __publicField = (obj, key, value) => { + __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); + return value; +}; + +export { + __publicField +}; +//# sourceMappingURL=chunk-F3FYYIAV.js.map diff --git a/node_modules/.vite/deps/chunk-F3FYYIAV.js.map b/node_modules/.vite/deps/chunk-F3FYYIAV.js.map new file mode 100644 index 000000000..98652118b --- /dev/null +++ b/node_modules/.vite/deps/chunk-F3FYYIAV.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": [], + "sourcesContent": [], + "mappings": "", + "names": [] +} diff --git a/node_modules/.vite/deps/devalue.js b/node_modules/.vite/deps/devalue.js new file mode 100644 index 000000000..6e94d5c10 --- /dev/null +++ b/node_modules/.vite/deps/devalue.js @@ -0,0 +1,563 @@ +import "./chunk-F3FYYIAV.js"; + +// node_modules/devalue/src/utils.js +var escaped = { + "<": "\\u003C", + "\\": "\\\\", + "\b": "\\b", + "\f": "\\f", + "\n": "\\n", + "\r": "\\r", + " ": "\\t", + "\u2028": "\\u2028", + "\u2029": "\\u2029" +}; +var DevalueError = class extends Error { + /** + * @param {string} message + * @param {string[]} keys + */ + constructor(message, keys) { + super(message); + this.name = "DevalueError"; + this.path = keys.join(""); + } +}; +function is_primitive(thing) { + return Object(thing) !== thing; +} +var object_proto_names = Object.getOwnPropertyNames( + Object.prototype +).sort().join("\0"); +function is_plain_object(thing) { + const proto = Object.getPrototypeOf(thing); + return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names; +} +function get_type(thing) { + return Object.prototype.toString.call(thing).slice(8, -1); +} +function get_escaped_char(char) { + switch (char) { + case '"': + return '\\"'; + case "<": + return "\\u003C"; + case "\\": + return "\\\\"; + case "\n": + return "\\n"; + case "\r": + return "\\r"; + case " ": + return "\\t"; + case "\b": + return "\\b"; + case "\f": + return "\\f"; + case "\u2028": + return "\\u2028"; + case "\u2029": + return "\\u2029"; + default: + return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : ""; + } +} +function stringify_string(str) { + let result = ""; + let last_pos = 0; + const len = str.length; + for (let i = 0; i < len; i += 1) { + const char = str[i]; + const replacement = get_escaped_char(char); + if (replacement) { + result += str.slice(last_pos, i) + replacement; + last_pos = i + 1; + } + } + return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`; +} + +// node_modules/devalue/src/uneval.js +var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$"; +var unsafe_chars = /[<\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)$/; +function uneval(value, replacer) { + const counts = /* @__PURE__ */ new Map(); + const keys = []; + const custom = /* @__PURE__ */ new Map(); + function walk(thing) { + if (typeof thing === "function") { + throw new DevalueError(`Cannot stringify a function`, keys); + } + if (!is_primitive(thing)) { + if (counts.has(thing)) { + counts.set(thing, counts.get(thing) + 1); + return; + } + counts.set(thing, 1); + if (replacer) { + const str2 = replacer(thing); + if (typeof str2 === "string") { + custom.set(thing, str2); + return; + } + } + const type = get_type(thing); + switch (type) { + case "Number": + case "BigInt": + case "String": + case "Boolean": + case "Date": + case "RegExp": + return; + case "Array": + thing.forEach((value2, i) => { + keys.push(`[${i}]`); + walk(value2); + keys.pop(); + }); + break; + case "Set": + Array.from(thing).forEach(walk); + break; + case "Map": + for (const [key, value2] of thing) { + keys.push( + `.get(${is_primitive(key) ? stringify_primitive(key) : "..."})` + ); + walk(value2); + keys.pop(); + } + break; + default: + if (!is_plain_object(thing)) { + throw new DevalueError( + `Cannot stringify arbitrary non-POJOs`, + keys + ); + } + if (Object.getOwnPropertySymbols(thing).length > 0) { + throw new DevalueError( + `Cannot stringify POJOs with symbolic keys`, + keys + ); + } + for (const key in thing) { + keys.push(`.${key}`); + walk(thing[key]); + keys.pop(); + } + } + } + } + walk(value); + const names = /* @__PURE__ */ new Map(); + Array.from(counts).filter((entry) => entry[1] > 1).sort((a, b) => b[1] - a[1]).forEach((entry, i) => { + names.set(entry[0], get_name(i)); + }); + function stringify2(thing) { + if (names.has(thing)) { + return names.get(thing); + } + if (is_primitive(thing)) { + return stringify_primitive(thing); + } + if (custom.has(thing)) { + return custom.get(thing); + } + const type = get_type(thing); + switch (type) { + case "Number": + case "String": + case "Boolean": + return `Object(${stringify2(thing.valueOf())})`; + case "RegExp": + return `new RegExp(${stringify_string(thing.source)}, "${thing.flags}")`; + case "Date": + return `new Date(${thing.getTime()})`; + case "Array": + const members = ( + /** @type {any[]} */ + thing.map( + (v, i) => i in thing ? stringify2(v) : "" + ) + ); + const tail = thing.length === 0 || thing.length - 1 in thing ? "" : ","; + return `[${members.join(",")}${tail}]`; + case "Set": + case "Map": + return `new ${type}([${Array.from(thing).map(stringify2).join(",")}])`; + default: + const obj = `{${Object.keys(thing).map((key) => `${safe_key(key)}:${stringify2(thing[key])}`).join(",")}}`; + const proto = Object.getPrototypeOf(thing); + if (proto === null) { + return Object.keys(thing).length > 0 ? `Object.assign(Object.create(null),${obj})` : `Object.create(null)`; + } + return obj; + } + } + const str = stringify2(value); + if (names.size) { + const params = []; + const statements = []; + const values = []; + names.forEach((name, thing) => { + params.push(name); + if (custom.has(thing)) { + values.push( + /** @type {string} */ + custom.get(thing) + ); + return; + } + if (is_primitive(thing)) { + values.push(stringify_primitive(thing)); + return; + } + const type = get_type(thing); + switch (type) { + case "Number": + case "String": + case "Boolean": + values.push(`Object(${stringify2(thing.valueOf())})`); + break; + case "RegExp": + values.push(thing.toString()); + break; + case "Date": + values.push(`new Date(${thing.getTime()})`); + break; + case "Array": + values.push(`Array(${thing.length})`); + thing.forEach((v, i) => { + statements.push(`${name}[${i}]=${stringify2(v)}`); + }); + break; + case "Set": + values.push(`new Set`); + statements.push( + `${name}.${Array.from(thing).map((v) => `add(${stringify2(v)})`).join(".")}` + ); + break; + case "Map": + values.push(`new Map`); + statements.push( + `${name}.${Array.from(thing).map(([k, v]) => `set(${stringify2(k)}, ${stringify2(v)})`).join(".")}` + ); + break; + default: + values.push( + Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}" + ); + Object.keys(thing).forEach((key) => { + statements.push( + `${name}${safe_prop(key)}=${stringify2(thing[key])}` + ); + }); + } + }); + statements.push(`return ${str}`); + return `(function(${params.join(",")}){${statements.join( + ";" + )}}(${values.join(",")}))`; + } else { + return str; + } +} +function get_name(num) { + let name = ""; + do { + name = chars[num % chars.length] + name; + num = ~~(num / chars.length) - 1; + } while (num >= 0); + return reserved.test(name) ? `${name}0` : name; +} +function escape_unsafe_char(c) { + return escaped[c] || c; +} +function escape_unsafe_chars(str) { + return str.replace(unsafe_chars, escape_unsafe_char); +} +function safe_key(key) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key)); +} +function safe_prop(key) { + return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? `.${key}` : `[${escape_unsafe_chars(JSON.stringify(key))}]`; +} +function stringify_primitive(thing) { + if (typeof thing === "string") + return stringify_string(thing); + if (thing === void 0) + return "void 0"; + if (thing === 0 && 1 / thing < 0) + return "-0"; + const str = String(thing); + if (typeof thing === "number") + return str.replace(/^(-)?0\./, "$1."); + if (typeof thing === "bigint") + return thing + "n"; + return str; +} + +// node_modules/devalue/src/constants.js +var UNDEFINED = -1; +var HOLE = -2; +var NAN = -3; +var POSITIVE_INFINITY = -4; +var NEGATIVE_INFINITY = -5; +var NEGATIVE_ZERO = -6; + +// node_modules/devalue/src/parse.js +function parse(serialized, revivers) { + return unflatten(JSON.parse(serialized), revivers); +} +function unflatten(parsed, revivers) { + if (typeof parsed === "number") + return hydrate(parsed, true); + if (!Array.isArray(parsed) || parsed.length === 0) { + throw new Error("Invalid input"); + } + const values = ( + /** @type {any[]} */ + parsed + ); + const hydrated = Array(values.length); + function hydrate(index, standalone = false) { + if (index === UNDEFINED) + return void 0; + if (index === NAN) + return NaN; + if (index === POSITIVE_INFINITY) + return Infinity; + if (index === NEGATIVE_INFINITY) + return -Infinity; + if (index === NEGATIVE_ZERO) + return -0; + if (standalone) + throw new Error(`Invalid input`); + if (index in hydrated) + return hydrated[index]; + const value = values[index]; + if (!value || typeof value !== "object") { + hydrated[index] = value; + } else if (Array.isArray(value)) { + if (typeof value[0] === "string") { + const type = value[0]; + const reviver = revivers == null ? void 0 : revivers[type]; + if (reviver) { + return hydrated[index] = reviver(hydrate(value[1])); + } + switch (type) { + case "Date": + hydrated[index] = new Date(value[1]); + break; + case "Set": + const set = /* @__PURE__ */ new Set(); + hydrated[index] = set; + for (let i = 1; i < value.length; i += 1) { + set.add(hydrate(value[i])); + } + break; + case "Map": + const map = /* @__PURE__ */ new Map(); + hydrated[index] = map; + for (let i = 1; i < value.length; i += 2) { + map.set(hydrate(value[i]), hydrate(value[i + 1])); + } + break; + case "RegExp": + hydrated[index] = new RegExp(value[1], value[2]); + break; + case "Object": + hydrated[index] = Object(value[1]); + break; + case "BigInt": + hydrated[index] = BigInt(value[1]); + break; + case "null": + const obj = /* @__PURE__ */ Object.create(null); + hydrated[index] = obj; + for (let i = 1; i < value.length; i += 2) { + obj[value[i]] = hydrate(value[i + 1]); + } + break; + default: + throw new Error(`Unknown type ${type}`); + } + } else { + const array = new Array(value.length); + hydrated[index] = array; + for (let i = 0; i < value.length; i += 1) { + const n = value[i]; + if (n === HOLE) + continue; + array[i] = hydrate(n); + } + } + } else { + const object = {}; + hydrated[index] = object; + for (const key in value) { + const n = value[key]; + object[key] = hydrate(n); + } + } + return hydrated[index]; + } + return hydrate(0); +} + +// node_modules/devalue/src/stringify.js +function stringify(value, reducers) { + const stringified = []; + const indexes = /* @__PURE__ */ new Map(); + const custom = []; + for (const key in reducers) { + custom.push({ key, fn: reducers[key] }); + } + const keys = []; + let p = 0; + function flatten(thing) { + if (typeof thing === "function") { + throw new DevalueError(`Cannot stringify a function`, keys); + } + if (indexes.has(thing)) + return indexes.get(thing); + if (thing === void 0) + return UNDEFINED; + if (Number.isNaN(thing)) + return NAN; + if (thing === Infinity) + return POSITIVE_INFINITY; + if (thing === -Infinity) + return NEGATIVE_INFINITY; + if (thing === 0 && 1 / thing < 0) + return NEGATIVE_ZERO; + const index2 = p++; + indexes.set(thing, index2); + for (const { key, fn } of custom) { + const value2 = fn(thing); + if (value2) { + stringified[index2] = `["${key}",${flatten(value2)}]`; + return index2; + } + } + let str = ""; + if (is_primitive(thing)) { + str = stringify_primitive2(thing); + } else { + const type = get_type(thing); + switch (type) { + case "Number": + case "String": + case "Boolean": + str = `["Object",${stringify_primitive2(thing)}]`; + break; + case "BigInt": + str = `["BigInt",${thing}]`; + break; + case "Date": + str = `["Date","${thing.toISOString()}"]`; + break; + case "RegExp": + const { source, flags } = thing; + str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`; + break; + case "Array": + str = "["; + for (let i = 0; i < thing.length; i += 1) { + if (i > 0) + str += ","; + if (i in thing) { + keys.push(`[${i}]`); + str += flatten(thing[i]); + keys.pop(); + } else { + str += HOLE; + } + } + str += "]"; + break; + case "Set": + str = '["Set"'; + for (const value2 of thing) { + str += `,${flatten(value2)}`; + } + str += "]"; + break; + case "Map": + str = '["Map"'; + for (const [key, value2] of thing) { + keys.push( + `.get(${is_primitive(key) ? stringify_primitive2(key) : "..."})` + ); + str += `,${flatten(key)},${flatten(value2)}`; + } + str += "]"; + break; + default: + if (!is_plain_object(thing)) { + throw new DevalueError( + `Cannot stringify arbitrary non-POJOs`, + keys + ); + } + if (Object.getOwnPropertySymbols(thing).length > 0) { + throw new DevalueError( + `Cannot stringify POJOs with symbolic keys`, + keys + ); + } + if (Object.getPrototypeOf(thing) === null) { + str = '["null"'; + for (const key in thing) { + keys.push(`.${key}`); + str += `,${stringify_string(key)},${flatten(thing[key])}`; + keys.pop(); + } + str += "]"; + } else { + str = "{"; + let started = false; + for (const key in thing) { + if (started) + str += ","; + started = true; + keys.push(`.${key}`); + str += `${stringify_string(key)}:${flatten(thing[key])}`; + keys.pop(); + } + str += "}"; + } + } + } + stringified[index2] = str; + return index2; + } + const index = flatten(value); + if (index < 0) + return `${index}`; + return `[${stringified.join(",")}]`; +} +function stringify_primitive2(thing) { + const type = typeof thing; + if (type === "string") + return stringify_string(thing); + if (thing instanceof String) + return stringify_string(thing.toString()); + if (thing === void 0) + return UNDEFINED.toString(); + if (thing === 0 && 1 / thing < 0) + return NEGATIVE_ZERO.toString(); + if (type === "bigint") + return `["BigInt","${thing}"]`; + return String(thing); +} +export { + parse, + stringify, + uneval, + unflatten +}; +//# sourceMappingURL=devalue.js.map diff --git a/node_modules/.vite/deps/devalue.js.map b/node_modules/.vite/deps/devalue.js.map new file mode 100644 index 000000000..39003d0a6 --- /dev/null +++ b/node_modules/.vite/deps/devalue.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../devalue/src/utils.js", "../../devalue/src/uneval.js", "../../devalue/src/constants.js", "../../devalue/src/parse.js", "../../devalue/src/stringify.js"], + "sourcesContent": ["/** @type {Record} */\r\nexport const escaped = {\r\n\t'<': '\\\\u003C',\r\n\t'\\\\': '\\\\\\\\',\r\n\t'\\b': '\\\\b',\r\n\t'\\f': '\\\\f',\r\n\t'\\n': '\\\\n',\r\n\t'\\r': '\\\\r',\r\n\t'\\t': '\\\\t',\r\n\t'\\u2028': '\\\\u2028',\r\n\t'\\u2029': '\\\\u2029'\r\n};\r\n\r\nexport class DevalueError extends Error {\r\n\t/**\r\n\t * @param {string} message\r\n\t * @param {string[]} keys\r\n\t */\r\n\tconstructor(message, keys) {\r\n\t\tsuper(message);\r\n\t\tthis.name = 'DevalueError';\r\n\t\tthis.path = keys.join('');\r\n\t}\r\n}\r\n\r\n/** @param {any} thing */\r\nexport function is_primitive(thing) {\r\n\treturn Object(thing) !== thing;\r\n}\r\n\r\nconst object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(\r\n\tObject.prototype\r\n)\r\n\t.sort()\r\n\t.join('\\0');\r\n\r\n/** @param {any} thing */\r\nexport function is_plain_object(thing) {\r\n\tconst proto = Object.getPrototypeOf(thing);\r\n\r\n\treturn (\r\n\t\tproto === Object.prototype ||\r\n\t\tproto === null ||\r\n\t\tObject.getOwnPropertyNames(proto).sort().join('\\0') === object_proto_names\r\n\t);\r\n}\r\n\r\n/** @param {any} thing */\r\nexport function get_type(thing) {\r\n\treturn Object.prototype.toString.call(thing).slice(8, -1);\r\n}\r\n\r\n/** @param {string} char */\r\nfunction get_escaped_char(char) {\r\n\tswitch (char) {\r\n\t\tcase '\"':\r\n\t\t\treturn '\\\\\"';\r\n\t\tcase '<':\r\n\t\t\treturn '\\\\u003C';\r\n\t\tcase '\\\\':\r\n\t\t\treturn '\\\\\\\\';\r\n\t\tcase '\\n':\r\n\t\t\treturn '\\\\n';\r\n\t\tcase '\\r':\r\n\t\t\treturn '\\\\r';\r\n\t\tcase '\\t':\r\n\t\t\treturn '\\\\t';\r\n\t\tcase '\\b':\r\n\t\t\treturn '\\\\b';\r\n\t\tcase '\\f':\r\n\t\t\treturn '\\\\f';\r\n\t\tcase '\\u2028':\r\n\t\t\treturn '\\\\u2028';\r\n\t\tcase '\\u2029':\r\n\t\t\treturn '\\\\u2029';\r\n\t\tdefault:\r\n\t\t\treturn char < ' '\r\n\t\t\t\t? `\\\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`\r\n\t\t\t\t: '';\r\n\t}\r\n}\r\n\r\n/** @param {string} str */\r\nexport function stringify_string(str) {\r\n\tlet result = '';\r\n\tlet last_pos = 0;\r\n\tconst len = str.length;\r\n\r\n\tfor (let i = 0; i < len; i += 1) {\r\n\t\tconst char = str[i];\r\n\t\tconst replacement = get_escaped_char(char);\r\n\t\tif (replacement) {\r\n\t\t\tresult += str.slice(last_pos, i) + replacement;\r\n\t\t\tlast_pos = i + 1;\r\n\t\t}\r\n\t}\r\n\r\n\treturn `\"${last_pos === 0 ? str : result + str.slice(last_pos)}\"`;\r\n}\r\n", "import {\r\n\tDevalueError,\r\n\tescaped,\r\n\tget_type,\r\n\tis_plain_object,\r\n\tis_primitive,\r\n\tstringify_string\r\n} from './utils.js';\r\n\r\nconst chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';\r\nconst unsafe_chars = /[<\\b\\f\\n\\r\\t\\0\\u2028\\u2029]/g;\r\nconst reserved =\r\n\t/^(?: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)$/;\r\n\r\n/**\r\n * Turn a value into the JavaScript that creates an equivalent value\r\n * @param {any} value\r\n * @param {(value: any) => string | void} [replacer]\r\n */\r\nexport function uneval(value, replacer) {\r\n\tconst counts = new Map();\r\n\r\n\t/** @type {string[]} */\r\n\tconst keys = [];\r\n\r\n\tconst custom = new Map();\r\n\r\n\t/** @param {any} thing */\r\n\tfunction walk(thing) {\r\n\t\tif (typeof thing === 'function') {\r\n\t\t\tthrow new DevalueError(`Cannot stringify a function`, keys);\r\n\t\t}\r\n\r\n\t\tif (!is_primitive(thing)) {\r\n\t\t\tif (counts.has(thing)) {\r\n\t\t\t\tcounts.set(thing, counts.get(thing) + 1);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tcounts.set(thing, 1);\r\n\r\n\t\t\tif (replacer) {\r\n\t\t\t\tconst str = replacer(thing);\r\n\r\n\t\t\t\tif (typeof str === 'string') {\r\n\t\t\t\t\tcustom.set(thing, str);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tconst type = get_type(thing);\r\n\r\n\t\t\tswitch (type) {\r\n\t\t\t\tcase 'Number':\r\n\t\t\t\tcase 'BigInt':\r\n\t\t\t\tcase 'String':\r\n\t\t\t\tcase 'Boolean':\r\n\t\t\t\tcase 'Date':\r\n\t\t\t\tcase 'RegExp':\r\n\t\t\t\t\treturn;\r\n\r\n\t\t\t\tcase 'Array':\r\n\t\t\t\t\t/** @type {any[]} */ (thing).forEach((value, i) => {\r\n\t\t\t\t\t\tkeys.push(`[${i}]`);\r\n\t\t\t\t\t\twalk(value);\r\n\t\t\t\t\t\tkeys.pop();\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Set':\r\n\t\t\t\t\tArray.from(thing).forEach(walk);\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Map':\r\n\t\t\t\t\tfor (const [key, value] of thing) {\r\n\t\t\t\t\t\tkeys.push(\r\n\t\t\t\t\t\t\t`.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\twalk(value);\r\n\t\t\t\t\t\tkeys.pop();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tif (!is_plain_object(thing)) {\r\n\t\t\t\t\t\tthrow new DevalueError(\r\n\t\t\t\t\t\t\t`Cannot stringify arbitrary non-POJOs`,\r\n\t\t\t\t\t\t\tkeys\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (Object.getOwnPropertySymbols(thing).length > 0) {\r\n\t\t\t\t\t\tthrow new DevalueError(\r\n\t\t\t\t\t\t\t`Cannot stringify POJOs with symbolic keys`,\r\n\t\t\t\t\t\t\tkeys\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tfor (const key in thing) {\r\n\t\t\t\t\t\tkeys.push(`.${key}`);\r\n\t\t\t\t\t\twalk(thing[key]);\r\n\t\t\t\t\t\tkeys.pop();\r\n\t\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\twalk(value);\r\n\r\n\tconst names = new Map();\r\n\r\n\tArray.from(counts)\r\n\t\t.filter((entry) => entry[1] > 1)\r\n\t\t.sort((a, b) => b[1] - a[1])\r\n\t\t.forEach((entry, i) => {\r\n\t\t\tnames.set(entry[0], get_name(i));\r\n\t\t});\r\n\r\n\t/**\r\n\t * @param {any} thing\r\n\t * @returns {string}\r\n\t */\r\n\tfunction stringify(thing) {\r\n\t\tif (names.has(thing)) {\r\n\t\t\treturn names.get(thing);\r\n\t\t}\r\n\r\n\t\tif (is_primitive(thing)) {\r\n\t\t\treturn stringify_primitive(thing);\r\n\t\t}\r\n\r\n\t\tif (custom.has(thing)) {\r\n\t\t\treturn custom.get(thing);\r\n\t\t}\r\n\r\n\t\tconst type = get_type(thing);\r\n\r\n\t\tswitch (type) {\r\n\t\t\tcase 'Number':\r\n\t\t\tcase 'String':\r\n\t\t\tcase 'Boolean':\r\n\t\t\t\treturn `Object(${stringify(thing.valueOf())})`;\r\n\r\n\t\t\tcase 'RegExp':\r\n\t\t\t\treturn `new RegExp(${stringify_string(thing.source)}, \"${\r\n\t\t\t\t\tthing.flags\r\n\t\t\t\t}\")`;\r\n\r\n\t\t\tcase 'Date':\r\n\t\t\t\treturn `new Date(${thing.getTime()})`;\r\n\r\n\t\t\tcase 'Array':\r\n\t\t\t\tconst members = /** @type {any[]} */ (thing).map((v, i) =>\r\n\t\t\t\t\ti in thing ? stringify(v) : ''\r\n\t\t\t\t);\r\n\t\t\t\tconst tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';\r\n\t\t\t\treturn `[${members.join(',')}${tail}]`;\r\n\r\n\t\t\tcase 'Set':\r\n\t\t\tcase 'Map':\r\n\t\t\t\treturn `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tconst obj = `{${Object.keys(thing)\r\n\t\t\t\t\t.map((key) => `${safe_key(key)}:${stringify(thing[key])}`)\r\n\t\t\t\t\t.join(',')}}`;\r\n\t\t\t\tconst proto = Object.getPrototypeOf(thing);\r\n\t\t\t\tif (proto === null) {\r\n\t\t\t\t\treturn Object.keys(thing).length > 0\r\n\t\t\t\t\t\t? `Object.assign(Object.create(null),${obj})`\r\n\t\t\t\t\t\t: `Object.create(null)`;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn obj;\r\n\t\t}\r\n\t}\r\n\r\n\tconst str = stringify(value);\r\n\r\n\tif (names.size) {\r\n\t\t/** @type {string[]} */\r\n\t\tconst params = [];\r\n\r\n\t\t/** @type {string[]} */\r\n\t\tconst statements = [];\r\n\r\n\t\t/** @type {string[]} */\r\n\t\tconst values = [];\r\n\r\n\t\tnames.forEach((name, thing) => {\r\n\t\t\tparams.push(name);\r\n\r\n\t\t\tif (custom.has(thing)) {\r\n\t\t\t\tvalues.push(/** @type {string} */ (custom.get(thing)));\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (is_primitive(thing)) {\r\n\t\t\t\tvalues.push(stringify_primitive(thing));\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst type = get_type(thing);\r\n\r\n\t\t\tswitch (type) {\r\n\t\t\t\tcase 'Number':\r\n\t\t\t\tcase 'String':\r\n\t\t\t\tcase 'Boolean':\r\n\t\t\t\t\tvalues.push(`Object(${stringify(thing.valueOf())})`);\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'RegExp':\r\n\t\t\t\t\tvalues.push(thing.toString());\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Date':\r\n\t\t\t\t\tvalues.push(`new Date(${thing.getTime()})`);\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Array':\r\n\t\t\t\t\tvalues.push(`Array(${thing.length})`);\r\n\t\t\t\t\t/** @type {any[]} */ (thing).forEach((v, i) => {\r\n\t\t\t\t\t\tstatements.push(`${name}[${i}]=${stringify(v)}`);\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Set':\r\n\t\t\t\t\tvalues.push(`new Set`);\r\n\t\t\t\t\tstatements.push(\r\n\t\t\t\t\t\t`${name}.${Array.from(thing)\r\n\t\t\t\t\t\t\t.map((v) => `add(${stringify(v)})`)\r\n\t\t\t\t\t\t\t.join('.')}`\r\n\t\t\t\t\t);\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Map':\r\n\t\t\t\t\tvalues.push(`new Map`);\r\n\t\t\t\t\tstatements.push(\r\n\t\t\t\t\t\t`${name}.${Array.from(thing)\r\n\t\t\t\t\t\t\t.map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`)\r\n\t\t\t\t\t\t\t.join('.')}`\r\n\t\t\t\t\t);\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tvalues.push(\r\n\t\t\t\t\t\tObject.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'\r\n\t\t\t\t\t);\r\n\t\t\t\t\tObject.keys(thing).forEach((key) => {\r\n\t\t\t\t\t\tstatements.push(\r\n\t\t\t\t\t\t\t`${name}${safe_prop(key)}=${stringify(thing[key])}`\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tstatements.push(`return ${str}`);\r\n\r\n\t\treturn `(function(${params.join(',')}){${statements.join(\r\n\t\t\t';'\r\n\t\t)}}(${values.join(',')}))`;\r\n\t} else {\r\n\t\treturn str;\r\n\t}\r\n}\r\n\r\n/** @param {number} num */\r\nfunction get_name(num) {\r\n\tlet name = '';\r\n\r\n\tdo {\r\n\t\tname = chars[num % chars.length] + name;\r\n\t\tnum = ~~(num / chars.length) - 1;\r\n\t} while (num >= 0);\r\n\r\n\treturn reserved.test(name) ? `${name}0` : name;\r\n}\r\n\r\n/** @param {string} c */\r\nfunction escape_unsafe_char(c) {\r\n\treturn escaped[c] || c;\r\n}\r\n\r\n/** @param {string} str */\r\nfunction escape_unsafe_chars(str) {\r\n\treturn str.replace(unsafe_chars, escape_unsafe_char);\r\n}\r\n\r\n/** @param {string} key */\r\nfunction safe_key(key) {\r\n\treturn /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)\r\n\t\t? key\r\n\t\t: escape_unsafe_chars(JSON.stringify(key));\r\n}\r\n\r\n/** @param {string} key */\r\nfunction safe_prop(key) {\r\n\treturn /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)\r\n\t\t? `.${key}`\r\n\t\t: `[${escape_unsafe_chars(JSON.stringify(key))}]`;\r\n}\r\n\r\n/** @param {any} thing */\r\nfunction stringify_primitive(thing) {\r\n\tif (typeof thing === 'string') return stringify_string(thing);\r\n\tif (thing === void 0) return 'void 0';\r\n\tif (thing === 0 && 1 / thing < 0) return '-0';\r\n\tconst str = String(thing);\r\n\tif (typeof thing === 'number') return str.replace(/^(-)?0\\./, '$1.');\r\n\tif (typeof thing === 'bigint') return thing + 'n';\r\n\treturn str;\r\n}\r\n", "export const UNDEFINED = -1;\r\nexport const HOLE = -2;\r\nexport const NAN = -3;\r\nexport const POSITIVE_INFINITY = -4;\r\nexport const NEGATIVE_INFINITY = -5;\r\nexport const NEGATIVE_ZERO = -6;\r\n", "import {\r\n\tHOLE,\r\n\tNAN,\r\n\tNEGATIVE_INFINITY,\r\n\tNEGATIVE_ZERO,\r\n\tPOSITIVE_INFINITY,\r\n\tUNDEFINED\r\n} from './constants.js';\r\n\r\n/**\r\n * Revive a value serialized with `devalue.stringify`\r\n * @param {string} serialized\r\n * @param {Record any>} [revivers]\r\n */\r\nexport function parse(serialized, revivers) {\r\n\treturn unflatten(JSON.parse(serialized), revivers);\r\n}\r\n\r\n/**\r\n * Revive a value flattened with `devalue.stringify`\r\n * @param {number | any[]} parsed\r\n * @param {Record any>} [revivers]\r\n */\r\nexport function unflatten(parsed, revivers) {\r\n\tif (typeof parsed === 'number') return hydrate(parsed, true);\r\n\r\n\tif (!Array.isArray(parsed) || parsed.length === 0) {\r\n\t\tthrow new Error('Invalid input');\r\n\t}\r\n\r\n\tconst values = /** @type {any[]} */ (parsed);\r\n\r\n\tconst hydrated = Array(values.length);\r\n\r\n\t/**\r\n\t * @param {number} index\r\n\t * @returns {any}\r\n\t */\r\n\tfunction hydrate(index, standalone = false) {\r\n\t\tif (index === UNDEFINED) return undefined;\r\n\t\tif (index === NAN) return NaN;\r\n\t\tif (index === POSITIVE_INFINITY) return Infinity;\r\n\t\tif (index === NEGATIVE_INFINITY) return -Infinity;\r\n\t\tif (index === NEGATIVE_ZERO) return -0;\r\n\r\n\t\tif (standalone) throw new Error(`Invalid input`);\r\n\r\n\t\tif (index in hydrated) return hydrated[index];\r\n\r\n\t\tconst value = values[index];\r\n\r\n\t\tif (!value || typeof value !== 'object') {\r\n\t\t\thydrated[index] = value;\r\n\t\t} else if (Array.isArray(value)) {\r\n\t\t\tif (typeof value[0] === 'string') {\r\n\t\t\t\tconst type = value[0];\r\n\r\n\t\t\t\tconst reviver = revivers?.[type];\r\n\t\t\t\tif (reviver) {\r\n\t\t\t\t\treturn (hydrated[index] = reviver(hydrate(value[1])));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tswitch (type) {\r\n\t\t\t\t\tcase 'Date':\r\n\t\t\t\t\t\thydrated[index] = new Date(value[1]);\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'Set':\r\n\t\t\t\t\t\tconst set = new Set();\r\n\t\t\t\t\t\thydrated[index] = set;\r\n\t\t\t\t\t\tfor (let i = 1; i < value.length; i += 1) {\r\n\t\t\t\t\t\t\tset.add(hydrate(value[i]));\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'Map':\r\n\t\t\t\t\t\tconst map = new Map();\r\n\t\t\t\t\t\thydrated[index] = map;\r\n\t\t\t\t\t\tfor (let i = 1; i < value.length; i += 2) {\r\n\t\t\t\t\t\t\tmap.set(hydrate(value[i]), hydrate(value[i + 1]));\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'RegExp':\r\n\t\t\t\t\t\thydrated[index] = new RegExp(value[1], value[2]);\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'Object':\r\n\t\t\t\t\t\thydrated[index] = Object(value[1]);\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'BigInt':\r\n\t\t\t\t\t\thydrated[index] = BigInt(value[1]);\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'null':\r\n\t\t\t\t\t\tconst obj = Object.create(null);\r\n\t\t\t\t\t\thydrated[index] = obj;\r\n\t\t\t\t\t\tfor (let i = 1; i < value.length; i += 2) {\r\n\t\t\t\t\t\t\tobj[value[i]] = hydrate(value[i + 1]);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tthrow new Error(`Unknown type ${type}`);\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tconst array = new Array(value.length);\r\n\t\t\t\thydrated[index] = array;\r\n\r\n\t\t\t\tfor (let i = 0; i < value.length; i += 1) {\r\n\t\t\t\t\tconst n = value[i];\r\n\t\t\t\t\tif (n === HOLE) continue;\r\n\r\n\t\t\t\t\tarray[i] = hydrate(n);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t/** @type {Record} */\r\n\t\t\tconst object = {};\r\n\t\t\thydrated[index] = object;\r\n\r\n\t\t\tfor (const key in value) {\r\n\t\t\t\tconst n = value[key];\r\n\t\t\t\tobject[key] = hydrate(n);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn hydrated[index];\r\n\t}\r\n\r\n\treturn hydrate(0);\r\n}\r\n", "import {\r\n\tDevalueError,\r\n\tget_type,\r\n\tis_plain_object,\r\n\tis_primitive,\r\n\tstringify_string\r\n} from './utils.js';\r\nimport {\r\n\tHOLE,\r\n\tNAN,\r\n\tNEGATIVE_INFINITY,\r\n\tNEGATIVE_ZERO,\r\n\tPOSITIVE_INFINITY,\r\n\tUNDEFINED\r\n} from './constants.js';\r\n\r\n/**\r\n * Turn a value into a JSON string that can be parsed with `devalue.parse`\r\n * @param {any} value\r\n * @param {Record any>} [reducers]\r\n */\r\nexport function stringify(value, reducers) {\r\n\t/** @type {any[]} */\r\n\tconst stringified = [];\r\n\r\n\t/** @type {Map} */\r\n\tconst indexes = new Map();\r\n\r\n\t/** @type {Array<{ key: string, fn: (value: any) => any }>} */\r\n\tconst custom = [];\r\n\tfor (const key in reducers) {\r\n\t\tcustom.push({ key, fn: reducers[key] });\r\n\t}\r\n\r\n\t/** @type {string[]} */\r\n\tconst keys = [];\r\n\r\n\tlet p = 0;\r\n\r\n\t/** @param {any} thing */\r\n\tfunction flatten(thing) {\r\n\t\tif (typeof thing === 'function') {\r\n\t\t\tthrow new DevalueError(`Cannot stringify a function`, keys);\r\n\t\t}\r\n\r\n\t\tif (indexes.has(thing)) return indexes.get(thing);\r\n\r\n\t\tif (thing === undefined) return UNDEFINED;\r\n\t\tif (Number.isNaN(thing)) return NAN;\r\n\t\tif (thing === Infinity) return POSITIVE_INFINITY;\r\n\t\tif (thing === -Infinity) return NEGATIVE_INFINITY;\r\n\t\tif (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;\r\n\r\n\t\tconst index = p++;\r\n\t\tindexes.set(thing, index);\r\n\r\n\t\tfor (const { key, fn } of custom) {\r\n\t\t\tconst value = fn(thing);\r\n\t\t\tif (value) {\r\n\t\t\t\tstringified[index] = `[\"${key}\",${flatten(value)}]`;\r\n\t\t\t\treturn index;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlet str = '';\r\n\r\n\t\tif (is_primitive(thing)) {\r\n\t\t\tstr = stringify_primitive(thing);\r\n\t\t} else {\r\n\t\t\tconst type = get_type(thing);\r\n\r\n\t\t\tswitch (type) {\r\n\t\t\t\tcase 'Number':\r\n\t\t\t\tcase 'String':\r\n\t\t\t\tcase 'Boolean':\r\n\t\t\t\t\tstr = `[\"Object\",${stringify_primitive(thing)}]`;\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'BigInt':\r\n\t\t\t\t\tstr = `[\"BigInt\",${thing}]`;\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Date':\r\n\t\t\t\t\tstr = `[\"Date\",\"${thing.toISOString()}\"]`;\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'RegExp':\r\n\t\t\t\t\tconst { source, flags } = thing;\r\n\t\t\t\t\tstr = flags\r\n\t\t\t\t\t\t? `[\"RegExp\",${stringify_string(source)},\"${flags}\"]`\r\n\t\t\t\t\t\t: `[\"RegExp\",${stringify_string(source)}]`;\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Array':\r\n\t\t\t\t\tstr = '[';\r\n\r\n\t\t\t\t\tfor (let i = 0; i < thing.length; i += 1) {\r\n\t\t\t\t\t\tif (i > 0) str += ',';\r\n\r\n\t\t\t\t\t\tif (i in thing) {\r\n\t\t\t\t\t\t\tkeys.push(`[${i}]`);\r\n\t\t\t\t\t\t\tstr += flatten(thing[i]);\r\n\t\t\t\t\t\t\tkeys.pop();\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tstr += HOLE;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tstr += ']';\r\n\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Set':\r\n\t\t\t\t\tstr = '[\"Set\"';\r\n\r\n\t\t\t\t\tfor (const value of thing) {\r\n\t\t\t\t\t\tstr += `,${flatten(value)}`;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tstr += ']';\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'Map':\r\n\t\t\t\t\tstr = '[\"Map\"';\r\n\r\n\t\t\t\t\tfor (const [key, value] of thing) {\r\n\t\t\t\t\t\tkeys.push(\r\n\t\t\t\t\t\t\t`.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tstr += `,${flatten(key)},${flatten(value)}`;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tstr += ']';\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tif (!is_plain_object(thing)) {\r\n\t\t\t\t\t\tthrow new DevalueError(\r\n\t\t\t\t\t\t\t`Cannot stringify arbitrary non-POJOs`,\r\n\t\t\t\t\t\t\tkeys\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (Object.getOwnPropertySymbols(thing).length > 0) {\r\n\t\t\t\t\t\tthrow new DevalueError(\r\n\t\t\t\t\t\t\t`Cannot stringify POJOs with symbolic keys`,\r\n\t\t\t\t\t\t\tkeys\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (Object.getPrototypeOf(thing) === null) {\r\n\t\t\t\t\t\tstr = '[\"null\"';\r\n\t\t\t\t\t\tfor (const key in thing) {\r\n\t\t\t\t\t\t\tkeys.push(`.${key}`);\r\n\t\t\t\t\t\t\tstr += `,${stringify_string(key)},${flatten(thing[key])}`;\r\n\t\t\t\t\t\t\tkeys.pop();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tstr += ']';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tstr = '{';\r\n\t\t\t\t\t\tlet started = false;\r\n\t\t\t\t\t\tfor (const key in thing) {\r\n\t\t\t\t\t\t\tif (started) str += ',';\r\n\t\t\t\t\t\t\tstarted = true;\r\n\t\t\t\t\t\t\tkeys.push(`.${key}`);\r\n\t\t\t\t\t\t\tstr += `${stringify_string(key)}:${flatten(thing[key])}`;\r\n\t\t\t\t\t\t\tkeys.pop();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tstr += '}';\r\n\t\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tstringified[index] = str;\r\n\t\treturn index;\r\n\t}\r\n\r\n\tconst index = flatten(value);\r\n\r\n\t// special case — value is represented as a negative index\r\n\tif (index < 0) return `${index}`;\r\n\r\n\treturn `[${stringified.join(',')}]`;\r\n}\r\n\r\n/**\r\n * @param {any} thing\r\n * @returns {string}\r\n */\r\nfunction stringify_primitive(thing) {\r\n\tconst type = typeof thing;\r\n\tif (type === 'string') return stringify_string(thing);\r\n\tif (thing instanceof String) return stringify_string(thing.toString());\r\n\tif (thing === void 0) return UNDEFINED.toString();\r\n\tif (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();\r\n\tif (type === 'bigint') return `[\"BigInt\",\"${thing}\"]`;\r\n\treturn String(thing);\r\n}\r\n"], + "mappings": ";;;AACO,IAAM,UAAU;AAAA,EACtB,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AACX;AAEO,IAAM,eAAN,cAA2B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKvC,YAAY,SAAS,MAAM;AAC1B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO,KAAK,KAAK,EAAE;AAAA,EACzB;AACD;AAGO,SAAS,aAAa,OAAO;AACnC,SAAO,OAAO,KAAK,MAAM;AAC1B;AAEA,IAAM,qBAAqC,OAAO;AAAA,EACjD,OAAO;AACR,EACE,KAAK,EACL,KAAK,IAAI;AAGJ,SAAS,gBAAgB,OAAO;AACtC,QAA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,MAAM,GAAG,CAAC,CAAC;AACtD,mBAAK,IAAI;AAAA,YACV;AACA,mBAAO;AAAA,UACR;AAAA,MACF;AAAA,IACD;AAEA,gBAAYD,MAAK,IAAI;AACrB,WAAOA;AAAA,EACR;AAEA,QAAM,QAAQ,QAAQ,KAAK;AAG3B,MAAI,QAAQ;AAAG,WAAO,GAAG,KAAK;AAE9B,SAAO,IAAI,YAAY,KAAK,GAAG,CAAC;AACjC;AAMA,SAASE,qBAAoB,OAAO;AACnC,QAAM,OAAO,OAAO;AACpB,MAAI,SAAS;AAAU,WAAO,iBAAiB,KAAK;AACpD,MAAI,iBAAiB;AAAQ,WAAO,iBAAiB,MAAM,SAAS,CAAC;AACrE,MAAI,UAAU;AAAQ,WAAO,UAAU,SAAS;AAChD,MAAI,UAAU,KAAK,IAAI,QAAQ;AAAG,WAAO,cAAc,SAAS;AAChE,MAAI,SAAS;AAAU,WAAO,cAAc,KAAK;AACjD,SAAO,OAAO,KAAK;AACpB;", + "names": ["str", "value", "stringify", "index", "value", "stringify_primitive"] +} diff --git a/node_modules/.vite/deps/esm-env.js b/node_modules/.vite/deps/esm-env.js new file mode 100644 index 000000000..4aed5160d --- /dev/null +++ b/node_modules/.vite/deps/esm-env.js @@ -0,0 +1,10 @@ +import "./chunk-F3FYYIAV.js"; + +// node_modules/esm-env/dev-browser.js +var BROWSER = true; +var DEV = true; +export { + BROWSER, + DEV +}; +//# sourceMappingURL=esm-env.js.map diff --git a/node_modules/.vite/deps/esm-env.js.map b/node_modules/.vite/deps/esm-env.js.map new file mode 100644 index 000000000..bb32e66a1 --- /dev/null +++ b/node_modules/.vite/deps/esm-env.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../esm-env/dev-browser.js"], + "sourcesContent": ["export const BROWSER = true;\r\nexport const DEV = true;\r\n"], + "mappings": ";;;AAAO,IAAM,UAAU;AAChB,IAAM,MAAM;", + "names": [] +} diff --git a/node_modules/.vite/deps/package.json b/node_modules/.vite/deps/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/node_modules/.vite/deps/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/node_modules/.vite/deps/proj4.js b/node_modules/.vite/deps/proj4.js new file mode 100644 index 000000000..5c2367772 --- /dev/null +++ b/node_modules/.vite/deps/proj4.js @@ -0,0 +1,6000 @@ +import "./chunk-F3FYYIAV.js"; + +// node_modules/proj4/lib/global.js +function global_default(defs2) { + defs2("EPSG:4326", "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"); + defs2("EPSG:4269", "+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"); + defs2("EPSG:3857", "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"); + defs2.WGS84 = defs2["EPSG:4326"]; + defs2["EPSG:3785"] = defs2["EPSG:3857"]; + defs2.GOOGLE = defs2["EPSG:3857"]; + defs2["EPSG:900913"] = defs2["EPSG:3857"]; + defs2["EPSG:102113"] = defs2["EPSG:3857"]; +} + +// node_modules/proj4/lib/constants/values.js +var PJD_3PARAM = 1; +var PJD_7PARAM = 2; +var PJD_GRIDSHIFT = 3; +var PJD_WGS84 = 4; +var PJD_NODATUM = 5; +var SRS_WGS84_SEMIMAJOR = 6378137; +var SRS_WGS84_SEMIMINOR = 6356752314e-3; +var SRS_WGS84_ESQUARED = 0.0066943799901413165; +var SEC_TO_RAD = 484813681109536e-20; +var HALF_PI = Math.PI / 2; +var SIXTH = 0.16666666666666666; +var RA4 = 0.04722222222222222; +var RA6 = 0.022156084656084655; +var EPSLN = 1e-10; +var D2R = 0.017453292519943295; +var R2D = 57.29577951308232; +var FORTPI = Math.PI / 4; +var TWO_PI = Math.PI * 2; +var SPI = 3.14159265359; + +// node_modules/proj4/lib/constants/PrimeMeridian.js +var exports = {}; +exports.greenwich = 0; +exports.lisbon = -9.131906111111; +exports.paris = 2.337229166667; +exports.bogota = -74.080916666667; +exports.madrid = -3.687938888889; +exports.rome = 12.452333333333; +exports.bern = 7.439583333333; +exports.jakarta = 106.807719444444; +exports.ferro = -17.666666666667; +exports.brussels = 4.367975; +exports.stockholm = 18.058277777778; +exports.athens = 23.7163375; +exports.oslo = 10.722916666667; + +// node_modules/proj4/lib/constants/units.js +var units_default = { + ft: { to_meter: 0.3048 }, + "us-ft": { to_meter: 1200 / 3937 } +}; + +// node_modules/proj4/lib/match.js +var ignoredChar = /[\s_\-\/\(\)]/g; +function match(obj, key) { + if (obj[key]) { + return obj[key]; + } + var keys = Object.keys(obj); + var lkey = key.toLowerCase().replace(ignoredChar, ""); + var i = -1; + var testkey, processedKey; + while (++i < keys.length) { + testkey = keys[i]; + processedKey = testkey.toLowerCase().replace(ignoredChar, ""); + if (processedKey === lkey) { + return obj[testkey]; + } + } +} + +// node_modules/proj4/lib/projString.js +function projString_default(defData) { + var self = {}; + var paramObj = defData.split("+").map(function(v) { + return v.trim(); + }).filter(function(a) { + return a; + }).reduce(function(p, a) { + var split = a.split("="); + split.push(true); + p[split[0].toLowerCase()] = split[1]; + return p; + }, {}); + var paramName, paramVal, paramOutname; + var params2 = { + proj: "projName", + datum: "datumCode", + rf: function(v) { + self.rf = parseFloat(v); + }, + lat_0: function(v) { + self.lat0 = v * D2R; + }, + lat_1: function(v) { + self.lat1 = v * D2R; + }, + lat_2: function(v) { + self.lat2 = v * D2R; + }, + lat_ts: function(v) { + self.lat_ts = v * D2R; + }, + lon_0: function(v) { + self.long0 = v * D2R; + }, + lon_1: function(v) { + self.long1 = v * D2R; + }, + lon_2: function(v) { + self.long2 = v * D2R; + }, + alpha: function(v) { + self.alpha = parseFloat(v) * D2R; + }, + gamma: function(v) { + self.rectified_grid_angle = parseFloat(v); + }, + lonc: function(v) { + self.longc = v * D2R; + }, + x_0: function(v) { + self.x0 = parseFloat(v); + }, + y_0: function(v) { + self.y0 = parseFloat(v); + }, + k_0: function(v) { + self.k0 = parseFloat(v); + }, + k: function(v) { + self.k0 = parseFloat(v); + }, + a: function(v) { + self.a = parseFloat(v); + }, + b: function(v) { + self.b = parseFloat(v); + }, + r_a: function() { + self.R_A = true; + }, + zone: function(v) { + self.zone = parseInt(v, 10); + }, + south: function() { + self.utmSouth = true; + }, + towgs84: function(v) { + self.datum_params = v.split(",").map(function(a) { + return parseFloat(a); + }); + }, + to_meter: function(v) { + self.to_meter = parseFloat(v); + }, + units: function(v) { + self.units = v; + var unit = match(units_default, v); + if (unit) { + self.to_meter = unit.to_meter; + } + }, + from_greenwich: function(v) { + self.from_greenwich = v * D2R; + }, + pm: function(v) { + var pm = match(exports, v); + self.from_greenwich = (pm ? pm : parseFloat(v)) * D2R; + }, + nadgrids: function(v) { + if (v === "@null") { + self.datumCode = "none"; + } else { + self.nadgrids = v; + } + }, + axis: function(v) { + var legalAxis = "ewnsud"; + if (v.length === 3 && legalAxis.indexOf(v.substr(0, 1)) !== -1 && legalAxis.indexOf(v.substr(1, 1)) !== -1 && legalAxis.indexOf(v.substr(2, 1)) !== -1) { + self.axis = v; + } + }, + approx: function() { + self.approx = true; + } + }; + for (paramName in paramObj) { + paramVal = paramObj[paramName]; + if (paramName in params2) { + paramOutname = params2[paramName]; + if (typeof paramOutname === "function") { + paramOutname(paramVal); + } else { + self[paramOutname] = paramVal; + } + } else { + self[paramName] = paramVal; + } + } + if (typeof self.datumCode === "string" && self.datumCode !== "WGS84") { + self.datumCode = self.datumCode.toLowerCase(); + } + return self; +} + +// node_modules/wkt-parser/parser.js +var parser_default = parseString; +var NEUTRAL = 1; +var KEYWORD = 2; +var NUMBER = 3; +var QUOTED = 4; +var AFTERQUOTE = 5; +var ENDED = -1; +var whitespace = /\s/; +var latin = /[A-Za-z]/; +var keyword = /[A-Za-z84_]/; +var endThings = /[,\]]/; +var digets = /[\d\.E\-\+]/; +function Parser(text) { + if (typeof text !== "string") { + throw new Error("not a string"); + } + this.text = text.trim(); + this.level = 0; + this.place = 0; + this.root = null; + this.stack = []; + this.currentObject = null; + this.state = NEUTRAL; +} +Parser.prototype.readCharicter = function() { + var char = this.text[this.place++]; + if (this.state !== QUOTED) { + while (whitespace.test(char)) { + if (this.place >= this.text.length) { + return; + } + char = this.text[this.place++]; + } + } + switch (this.state) { + case NEUTRAL: + return this.neutral(char); + case KEYWORD: + return this.keyword(char); + case QUOTED: + return this.quoted(char); + case AFTERQUOTE: + return this.afterquote(char); + case NUMBER: + return this.number(char); + case ENDED: + return; + } +}; +Parser.prototype.afterquote = function(char) { + if (char === '"') { + this.word += '"'; + this.state = QUOTED; + return; + } + if (endThings.test(char)) { + this.word = this.word.trim(); + this.afterItem(char); + return; + } + throw new Error(`havn't handled "` + char + '" in afterquote yet, index ' + this.place); +}; +Parser.prototype.afterItem = function(char) { + if (char === ",") { + if (this.word !== null) { + this.currentObject.push(this.word); + } + this.word = null; + this.state = NEUTRAL; + return; + } + if (char === "]") { + this.level--; + if (this.word !== null) { + this.currentObject.push(this.word); + this.word = null; + } + this.state = NEUTRAL; + this.currentObject = this.stack.pop(); + if (!this.currentObject) { + this.state = ENDED; + } + return; + } +}; +Parser.prototype.number = function(char) { + if (digets.test(char)) { + this.word += char; + return; + } + if (endThings.test(char)) { + this.word = parseFloat(this.word); + this.afterItem(char); + return; + } + throw new Error(`havn't handled "` + char + '" in number yet, index ' + this.place); +}; +Parser.prototype.quoted = function(char) { + if (char === '"') { + this.state = AFTERQUOTE; + return; + } + this.word += char; + return; +}; +Parser.prototype.keyword = function(char) { + if (keyword.test(char)) { + this.word += char; + return; + } + if (char === "[") { + var newObjects = []; + newObjects.push(this.word); + this.level++; + if (this.root === null) { + this.root = newObjects; + } else { + this.currentObject.push(newObjects); + } + this.stack.push(this.currentObject); + this.currentObject = newObjects; + this.state = NEUTRAL; + return; + } + if (endThings.test(char)) { + this.afterItem(char); + return; + } + throw new Error(`havn't handled "` + char + '" in keyword yet, index ' + this.place); +}; +Parser.prototype.neutral = function(char) { + if (latin.test(char)) { + this.word = char; + this.state = KEYWORD; + return; + } + if (char === '"') { + this.word = ""; + this.state = QUOTED; + return; + } + if (digets.test(char)) { + this.word = char; + this.state = NUMBER; + return; + } + if (endThings.test(char)) { + this.afterItem(char); + return; + } + throw new Error(`havn't handled "` + char + '" in neutral yet, index ' + this.place); +}; +Parser.prototype.output = function() { + while (this.place < this.text.length) { + this.readCharicter(); + } + if (this.state === ENDED) { + return this.root; + } + throw new Error('unable to parse string "' + this.text + '". State is ' + this.state); +}; +function parseString(txt) { + var parser = new Parser(txt); + return parser.output(); +} + +// node_modules/wkt-parser/process.js +function mapit(obj, key, value) { + if (Array.isArray(key)) { + value.unshift(key); + key = null; + } + var thing = key ? {} : obj; + var out = value.reduce(function(newObj, item) { + sExpr(item, newObj); + return newObj; + }, thing); + if (key) { + obj[key] = out; + } +} +function sExpr(v, obj) { + if (!Array.isArray(v)) { + obj[v] = true; + return; + } + var key = v.shift(); + if (key === "PARAMETER") { + key = v.shift(); + } + if (v.length === 1) { + if (Array.isArray(v[0])) { + obj[key] = {}; + sExpr(v[0], obj[key]); + return; + } + obj[key] = v[0]; + return; + } + if (!v.length) { + obj[key] = true; + return; + } + if (key === "TOWGS84") { + obj[key] = v; + return; + } + if (key === "AXIS") { + if (!(key in obj)) { + obj[key] = []; + } + obj[key].push(v); + return; + } + if (!Array.isArray(key)) { + obj[key] = {}; + } + var i; + switch (key) { + case "UNIT": + case "PRIMEM": + case "VERT_DATUM": + obj[key] = { + name: v[0].toLowerCase(), + convert: v[1] + }; + if (v.length === 3) { + sExpr(v[2], obj[key]); + } + return; + case "SPHEROID": + case "ELLIPSOID": + obj[key] = { + name: v[0], + a: v[1], + rf: v[2] + }; + if (v.length === 4) { + sExpr(v[3], obj[key]); + } + return; + case "PROJECTEDCRS": + case "PROJCRS": + case "GEOGCS": + case "GEOCCS": + case "PROJCS": + case "LOCAL_CS": + case "GEODCRS": + case "GEODETICCRS": + case "GEODETICDATUM": + case "EDATUM": + case "ENGINEERINGDATUM": + case "VERT_CS": + case "VERTCRS": + case "VERTICALCRS": + case "COMPD_CS": + case "COMPOUNDCRS": + case "ENGINEERINGCRS": + case "ENGCRS": + case "FITTED_CS": + case "LOCAL_DATUM": + case "DATUM": + v[0] = ["name", v[0]]; + mapit(obj, key, v); + return; + default: + i = -1; + while (++i < v.length) { + if (!Array.isArray(v[i])) { + return sExpr(v, obj[key]); + } + } + return mapit(obj, key, v); + } +} + +// node_modules/wkt-parser/index.js +var D2R2 = 0.017453292519943295; +function rename(obj, params2) { + var outName = params2[0]; + var inName = params2[1]; + if (!(outName in obj) && inName in obj) { + obj[outName] = obj[inName]; + if (params2.length === 3) { + obj[outName] = params2[2](obj[outName]); + } + } +} +function d2r(input) { + return input * D2R2; +} +function cleanWKT(wkt) { + if (wkt.type === "GEOGCS") { + wkt.projName = "longlat"; + } else if (wkt.type === "LOCAL_CS") { + wkt.projName = "identity"; + wkt.local = true; + } else { + if (typeof wkt.PROJECTION === "object") { + wkt.projName = Object.keys(wkt.PROJECTION)[0]; + } else { + wkt.projName = wkt.PROJECTION; + } + } + if (wkt.AXIS) { + var axisOrder = ""; + for (var i = 0, ii = wkt.AXIS.length; i < ii; ++i) { + var axis = [wkt.AXIS[i][0].toLowerCase(), wkt.AXIS[i][1].toLowerCase()]; + if (axis[0].indexOf("north") !== -1 || (axis[0] === "y" || axis[0] === "lat") && axis[1] === "north") { + axisOrder += "n"; + } else if (axis[0].indexOf("south") !== -1 || (axis[0] === "y" || axis[0] === "lat") && axis[1] === "south") { + axisOrder += "s"; + } else if (axis[0].indexOf("east") !== -1 || (axis[0] === "x" || axis[0] === "lon") && axis[1] === "east") { + axisOrder += "e"; + } else if (axis[0].indexOf("west") !== -1 || (axis[0] === "x" || axis[0] === "lon") && axis[1] === "west") { + axisOrder += "w"; + } + } + if (axisOrder.length === 2) { + axisOrder += "u"; + } + if (axisOrder.length === 3) { + wkt.axis = axisOrder; + } + } + if (wkt.UNIT) { + wkt.units = wkt.UNIT.name.toLowerCase(); + if (wkt.units === "metre") { + wkt.units = "meter"; + } + if (wkt.UNIT.convert) { + if (wkt.type === "GEOGCS") { + if (wkt.DATUM && wkt.DATUM.SPHEROID) { + wkt.to_meter = wkt.UNIT.convert * wkt.DATUM.SPHEROID.a; + } + } else { + wkt.to_meter = wkt.UNIT.convert; + } + } + } + var geogcs = wkt.GEOGCS; + if (wkt.type === "GEOGCS") { + geogcs = wkt; + } + if (geogcs) { + if (geogcs.DATUM) { + wkt.datumCode = geogcs.DATUM.name.toLowerCase(); + } else { + wkt.datumCode = geogcs.name.toLowerCase(); + } + if (wkt.datumCode.slice(0, 2) === "d_") { + wkt.datumCode = wkt.datumCode.slice(2); + } + if (wkt.datumCode === "new_zealand_geodetic_datum_1949" || wkt.datumCode === "new_zealand_1949") { + wkt.datumCode = "nzgd49"; + } + if (wkt.datumCode === "wgs_1984" || wkt.datumCode === "world_geodetic_system_1984") { + if (wkt.PROJECTION === "Mercator_Auxiliary_Sphere") { + wkt.sphere = true; + } + wkt.datumCode = "wgs84"; + } + if (wkt.datumCode.slice(-6) === "_ferro") { + wkt.datumCode = wkt.datumCode.slice(0, -6); + } + if (wkt.datumCode.slice(-8) === "_jakarta") { + wkt.datumCode = wkt.datumCode.slice(0, -8); + } + if (~wkt.datumCode.indexOf("belge")) { + wkt.datumCode = "rnb72"; + } + if (geogcs.DATUM && geogcs.DATUM.SPHEROID) { + wkt.ellps = geogcs.DATUM.SPHEROID.name.replace("_19", "").replace(/[Cc]larke\_18/, "clrk"); + if (wkt.ellps.toLowerCase().slice(0, 13) === "international") { + wkt.ellps = "intl"; + } + wkt.a = geogcs.DATUM.SPHEROID.a; + wkt.rf = parseFloat(geogcs.DATUM.SPHEROID.rf, 10); + } + if (geogcs.DATUM && geogcs.DATUM.TOWGS84) { + wkt.datum_params = geogcs.DATUM.TOWGS84; + } + if (~wkt.datumCode.indexOf("osgb_1936")) { + wkt.datumCode = "osgb36"; + } + if (~wkt.datumCode.indexOf("osni_1952")) { + wkt.datumCode = "osni52"; + } + if (~wkt.datumCode.indexOf("tm65") || ~wkt.datumCode.indexOf("geodetic_datum_of_1965")) { + wkt.datumCode = "ire65"; + } + if (wkt.datumCode === "ch1903+") { + wkt.datumCode = "ch1903"; + } + if (~wkt.datumCode.indexOf("israel")) { + wkt.datumCode = "isr93"; + } + } + if (wkt.b && !isFinite(wkt.b)) { + wkt.b = wkt.a; + } + function toMeter(input) { + var ratio = wkt.to_meter || 1; + return input * ratio; + } + var renamer = function(a) { + return rename(wkt, a); + }; + var list = [ + ["standard_parallel_1", "Standard_Parallel_1"], + ["standard_parallel_1", "Latitude of 1st standard parallel"], + ["standard_parallel_2", "Standard_Parallel_2"], + ["standard_parallel_2", "Latitude of 2nd standard parallel"], + ["false_easting", "False_Easting"], + ["false_easting", "False easting"], + ["false-easting", "Easting at false origin"], + ["false_northing", "False_Northing"], + ["false_northing", "False northing"], + ["false_northing", "Northing at false origin"], + ["central_meridian", "Central_Meridian"], + ["central_meridian", "Longitude of natural origin"], + ["central_meridian", "Longitude of false origin"], + ["latitude_of_origin", "Latitude_Of_Origin"], + ["latitude_of_origin", "Central_Parallel"], + ["latitude_of_origin", "Latitude of natural origin"], + ["latitude_of_origin", "Latitude of false origin"], + ["scale_factor", "Scale_Factor"], + ["k0", "scale_factor"], + ["latitude_of_center", "Latitude_Of_Center"], + ["latitude_of_center", "Latitude_of_center"], + ["lat0", "latitude_of_center", d2r], + ["longitude_of_center", "Longitude_Of_Center"], + ["longitude_of_center", "Longitude_of_center"], + ["longc", "longitude_of_center", d2r], + ["x0", "false_easting", toMeter], + ["y0", "false_northing", toMeter], + ["long0", "central_meridian", d2r], + ["lat0", "latitude_of_origin", d2r], + ["lat0", "standard_parallel_1", d2r], + ["lat1", "standard_parallel_1", d2r], + ["lat2", "standard_parallel_2", d2r], + ["azimuth", "Azimuth"], + ["alpha", "azimuth", d2r], + ["srsCode", "name"] + ]; + list.forEach(renamer); + if (!wkt.long0 && wkt.longc && (wkt.projName === "Albers_Conic_Equal_Area" || wkt.projName === "Lambert_Azimuthal_Equal_Area")) { + wkt.long0 = wkt.longc; + } + if (!wkt.lat_ts && wkt.lat1 && (wkt.projName === "Stereographic_South_Pole" || wkt.projName === "Polar Stereographic (variant B)")) { + wkt.lat0 = d2r(wkt.lat1 > 0 ? 90 : -90); + wkt.lat_ts = wkt.lat1; + } else if (!wkt.lat_ts && wkt.lat0 && wkt.projName === "Polar_Stereographic") { + wkt.lat_ts = wkt.lat0; + wkt.lat0 = d2r(wkt.lat0 > 0 ? 90 : -90); + } +} +function wkt_parser_default(wkt) { + var lisp = parser_default(wkt); + var type = lisp.shift(); + var name = lisp.shift(); + lisp.unshift(["name", name]); + lisp.unshift(["type", type]); + var obj = {}; + sExpr(lisp, obj); + cleanWKT(obj); + return obj; +} + +// node_modules/proj4/lib/defs.js +function defs(name) { + var that = this; + if (arguments.length === 2) { + var def = arguments[1]; + if (typeof def === "string") { + if (def.charAt(0) === "+") { + defs[name] = projString_default(arguments[1]); + } else { + defs[name] = wkt_parser_default(arguments[1]); + } + } else { + defs[name] = def; + } + } else if (arguments.length === 1) { + if (Array.isArray(name)) { + return name.map(function(v) { + if (Array.isArray(v)) { + defs.apply(that, v); + } else { + defs(v); + } + }); + } else if (typeof name === "string") { + if (name in defs) { + return defs[name]; + } + } else if ("EPSG" in name) { + defs["EPSG:" + name.EPSG] = name; + } else if ("ESRI" in name) { + defs["ESRI:" + name.ESRI] = name; + } else if ("IAU2000" in name) { + defs["IAU2000:" + name.IAU2000] = name; + } else { + console.log(name); + } + return; + } +} +global_default(defs); +var defs_default = defs; + +// node_modules/proj4/lib/parseCode.js +function testObj(code) { + return typeof code === "string"; +} +function testDef(code) { + return code in defs_default; +} +var codeWords = ["PROJECTEDCRS", "PROJCRS", "GEOGCS", "GEOCCS", "PROJCS", "LOCAL_CS", "GEODCRS", "GEODETICCRS", "GEODETICDATUM", "ENGCRS", "ENGINEERINGCRS"]; +function testWKT(code) { + return codeWords.some(function(word) { + return code.indexOf(word) > -1; + }); +} +var codes = ["3857", "900913", "3785", "102113"]; +function checkMercator(item) { + var auth = match(item, "authority"); + if (!auth) { + return; + } + var code = match(auth, "epsg"); + return code && codes.indexOf(code) > -1; +} +function checkProjStr(item) { + var ext = match(item, "extension"); + if (!ext) { + return; + } + return match(ext, "proj4"); +} +function testProj(code) { + return code[0] === "+"; +} +function parse(code) { + if (testObj(code)) { + if (testDef(code)) { + return defs_default[code]; + } + if (testWKT(code)) { + var out = wkt_parser_default(code); + if (checkMercator(out)) { + return defs_default["EPSG:3857"]; + } + var maybeProjStr = checkProjStr(out); + if (maybeProjStr) { + return projString_default(maybeProjStr); + } + return out; + } + if (testProj(code)) { + return projString_default(code); + } + } else { + return code; + } +} +var parseCode_default = parse; + +// node_modules/proj4/lib/extend.js +function extend_default(destination, source) { + destination = destination || {}; + var value, property; + if (!source) { + return destination; + } + for (property in source) { + value = source[property]; + if (value !== void 0) { + destination[property] = value; + } + } + return destination; +} + +// node_modules/proj4/lib/common/msfnz.js +function msfnz_default(eccent, sinphi, cosphi) { + var con = eccent * sinphi; + return cosphi / Math.sqrt(1 - con * con); +} + +// node_modules/proj4/lib/common/sign.js +function sign_default(x) { + return x < 0 ? -1 : 1; +} + +// node_modules/proj4/lib/common/adjust_lon.js +function adjust_lon_default(x) { + return Math.abs(x) <= SPI ? x : x - sign_default(x) * TWO_PI; +} + +// node_modules/proj4/lib/common/tsfnz.js +function tsfnz_default(eccent, phi, sinphi) { + var con = eccent * sinphi; + var com = 0.5 * eccent; + con = Math.pow((1 - con) / (1 + con), com); + return Math.tan(0.5 * (HALF_PI - phi)) / con; +} + +// node_modules/proj4/lib/common/phi2z.js +function phi2z_default(eccent, ts) { + var eccnth = 0.5 * eccent; + var con, dphi; + var phi = HALF_PI - 2 * Math.atan(ts); + for (var i = 0; i <= 15; i++) { + con = eccent * Math.sin(phi); + dphi = HALF_PI - 2 * Math.atan(ts * Math.pow((1 - con) / (1 + con), eccnth)) - phi; + phi += dphi; + if (Math.abs(dphi) <= 1e-10) { + return phi; + } + } + return -9999; +} + +// node_modules/proj4/lib/projections/merc.js +function init() { + var con = this.b / this.a; + this.es = 1 - con * con; + if (!("x0" in this)) { + this.x0 = 0; + } + if (!("y0" in this)) { + this.y0 = 0; + } + this.e = Math.sqrt(this.es); + if (this.lat_ts) { + if (this.sphere) { + this.k0 = Math.cos(this.lat_ts); + } else { + this.k0 = msfnz_default(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)); + } + } else { + if (!this.k0) { + if (this.k) { + this.k0 = this.k; + } else { + this.k0 = 1; + } + } + } +} +function forward(p) { + var lon = p.x; + var lat = p.y; + if (lat * R2D > 90 && lat * R2D < -90 && lon * R2D > 180 && lon * R2D < -180) { + return null; + } + var x, y; + if (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) { + return null; + } else { + if (this.sphere) { + x = this.x0 + this.a * this.k0 * adjust_lon_default(lon - this.long0); + y = this.y0 + this.a * this.k0 * Math.log(Math.tan(FORTPI + 0.5 * lat)); + } else { + var sinphi = Math.sin(lat); + var ts = tsfnz_default(this.e, lat, sinphi); + x = this.x0 + this.a * this.k0 * adjust_lon_default(lon - this.long0); + y = this.y0 - this.a * this.k0 * Math.log(ts); + } + p.x = x; + p.y = y; + return p; + } +} +function inverse(p) { + var x = p.x - this.x0; + var y = p.y - this.y0; + var lon, lat; + if (this.sphere) { + lat = HALF_PI - 2 * Math.atan(Math.exp(-y / (this.a * this.k0))); + } else { + var ts = Math.exp(-y / (this.a * this.k0)); + lat = phi2z_default(this.e, ts); + if (lat === -9999) { + return null; + } + } + lon = adjust_lon_default(this.long0 + x / (this.a * this.k0)); + p.x = lon; + p.y = lat; + return p; +} +var names = ["Mercator", "Popular Visualisation Pseudo Mercator", "Mercator_1SP", "Mercator_Auxiliary_Sphere", "merc"]; +var merc_default = { + init, + forward, + inverse, + names +}; + +// node_modules/proj4/lib/projections/longlat.js +function init2() { +} +function identity(pt) { + return pt; +} +var names2 = ["longlat", "identity"]; +var longlat_default = { + init: init2, + forward: identity, + inverse: identity, + names: names2 +}; + +// node_modules/proj4/lib/projections.js +var projs = [merc_default, longlat_default]; +var names3 = {}; +var projStore = []; +function add(proj, i) { + var len = projStore.length; + if (!proj.names) { + console.log(i); + return true; + } + projStore[len] = proj; + proj.names.forEach(function(n) { + names3[n.toLowerCase()] = len; + }); + return this; +} +function get(name) { + if (!name) { + return false; + } + var n = name.toLowerCase(); + if (typeof names3[n] !== "undefined" && projStore[names3[n]]) { + return projStore[names3[n]]; + } +} +function start() { + projs.forEach(add); +} +var projections_default = { + start, + add, + get +}; + +// node_modules/proj4/lib/constants/Ellipsoid.js +var exports2 = {}; +exports2.MERIT = { + a: 6378137, + rf: 298.257, + ellipseName: "MERIT 1983" +}; +exports2.SGS85 = { + a: 6378136, + rf: 298.257, + ellipseName: "Soviet Geodetic System 85" +}; +exports2.GRS80 = { + a: 6378137, + rf: 298.257222101, + ellipseName: "GRS 1980(IUGG, 1980)" +}; +exports2.IAU76 = { + a: 6378140, + rf: 298.257, + ellipseName: "IAU 1976" +}; +exports2.airy = { + a: 6377563396e-3, + b: 635625691e-2, + ellipseName: "Airy 1830" +}; +exports2.APL4 = { + a: 6378137, + rf: 298.25, + ellipseName: "Appl. Physics. 1965" +}; +exports2.NWL9D = { + a: 6378145, + rf: 298.25, + ellipseName: "Naval Weapons Lab., 1965" +}; +exports2.mod_airy = { + a: 6377340189e-3, + b: 6356034446e-3, + ellipseName: "Modified Airy" +}; +exports2.andrae = { + a: 637710443e-2, + rf: 300, + ellipseName: "Andrae 1876 (Den., Iclnd.)" +}; +exports2.aust_SA = { + a: 6378160, + rf: 298.25, + ellipseName: "Australian Natl & S. Amer. 1969" +}; +exports2.GRS67 = { + a: 6378160, + rf: 298.247167427, + ellipseName: "GRS 67(IUGG 1967)" +}; +exports2.bessel = { + a: 6377397155e-3, + rf: 299.1528128, + ellipseName: "Bessel 1841" +}; +exports2.bess_nam = { + a: 6377483865e-3, + rf: 299.1528128, + ellipseName: "Bessel 1841 (Namibia)" +}; +exports2.clrk66 = { + a: 63782064e-1, + b: 63565838e-1, + ellipseName: "Clarke 1866" +}; +exports2.clrk80 = { + a: 6378249145e-3, + rf: 293.4663, + ellipseName: "Clarke 1880 mod." +}; +exports2.clrk80ign = { + a: 63782492e-1, + b: 6356515, + rf: 293.4660213, + ellipseName: "Clarke 1880 (IGN)" +}; +exports2.clrk58 = { + a: 6378293645208759e-9, + rf: 294.2606763692654, + ellipseName: "Clarke 1858" +}; +exports2.CPM = { + a: 63757387e-1, + rf: 334.29, + ellipseName: "Comm. des Poids et Mesures 1799" +}; +exports2.delmbr = { + a: 6376428, + rf: 311.5, + ellipseName: "Delambre 1810 (Belgium)" +}; +exports2.engelis = { + a: 637813605e-2, + rf: 298.2566, + ellipseName: "Engelis 1985" +}; +exports2.evrst30 = { + a: 6377276345e-3, + rf: 300.8017, + ellipseName: "Everest 1830" +}; +exports2.evrst48 = { + a: 6377304063e-3, + rf: 300.8017, + ellipseName: "Everest 1948" +}; +exports2.evrst56 = { + a: 6377301243e-3, + rf: 300.8017, + ellipseName: "Everest 1956" +}; +exports2.evrst69 = { + a: 6377295664e-3, + rf: 300.8017, + ellipseName: "Everest 1969" +}; +exports2.evrstSS = { + a: 6377298556e-3, + rf: 300.8017, + ellipseName: "Everest (Sabah & Sarawak)" +}; +exports2.fschr60 = { + a: 6378166, + rf: 298.3, + ellipseName: "Fischer (Mercury Datum) 1960" +}; +exports2.fschr60m = { + a: 6378155, + rf: 298.3, + ellipseName: "Fischer 1960" +}; +exports2.fschr68 = { + a: 6378150, + rf: 298.3, + ellipseName: "Fischer 1968" +}; +exports2.helmert = { + a: 6378200, + rf: 298.3, + ellipseName: "Helmert 1906" +}; +exports2.hough = { + a: 6378270, + rf: 297, + ellipseName: "Hough" +}; +exports2.intl = { + a: 6378388, + rf: 297, + ellipseName: "International 1909 (Hayford)" +}; +exports2.kaula = { + a: 6378163, + rf: 298.24, + ellipseName: "Kaula 1961" +}; +exports2.lerch = { + a: 6378139, + rf: 298.257, + ellipseName: "Lerch 1979" +}; +exports2.mprts = { + a: 6397300, + rf: 191, + ellipseName: "Maupertius 1738" +}; +exports2.new_intl = { + a: 63781575e-1, + b: 63567722e-1, + ellipseName: "New International 1967" +}; +exports2.plessis = { + a: 6376523, + rf: 6355863, + ellipseName: "Plessis 1817 (France)" +}; +exports2.krass = { + a: 6378245, + rf: 298.3, + ellipseName: "Krassovsky, 1942" +}; +exports2.SEasia = { + a: 6378155, + b: 63567733205e-4, + ellipseName: "Southeast Asia" +}; +exports2.walbeck = { + a: 6376896, + b: 63558348467e-4, + ellipseName: "Walbeck" +}; +exports2.WGS60 = { + a: 6378165, + rf: 298.3, + ellipseName: "WGS 60" +}; +exports2.WGS66 = { + a: 6378145, + rf: 298.25, + ellipseName: "WGS 66" +}; +exports2.WGS7 = { + a: 6378135, + rf: 298.26, + ellipseName: "WGS 72" +}; +var WGS84 = exports2.WGS84 = { + a: 6378137, + rf: 298.257223563, + ellipseName: "WGS 84" +}; +exports2.sphere = { + a: 6370997, + b: 6370997, + ellipseName: "Normal Sphere (r=6370997)" +}; + +// node_modules/proj4/lib/deriveConstants.js +function eccentricity(a, b, rf, R_A) { + var a2 = a * a; + var b2 = b * b; + var es = (a2 - b2) / a2; + var e = 0; + if (R_A) { + a *= 1 - es * (SIXTH + es * (RA4 + es * RA6)); + a2 = a * a; + es = 0; + } else { + e = Math.sqrt(es); + } + var ep2 = (a2 - b2) / b2; + return { + es, + e, + ep2 + }; +} +function sphere(a, b, rf, ellps, sphere2) { + if (!a) { + var ellipse = match(exports2, ellps); + if (!ellipse) { + ellipse = WGS84; + } + a = ellipse.a; + b = ellipse.b; + rf = ellipse.rf; + } + if (rf && !b) { + b = (1 - 1 / rf) * a; + } + if (rf === 0 || Math.abs(a - b) < EPSLN) { + sphere2 = true; + b = a; + } + return { + a, + b, + rf, + sphere: sphere2 + }; +} + +// node_modules/proj4/lib/constants/Datum.js +var exports3 = {}; +exports3.wgs84 = { + towgs84: "0,0,0", + ellipse: "WGS84", + datumName: "WGS84" +}; +exports3.ch1903 = { + towgs84: "674.374,15.056,405.346", + ellipse: "bessel", + datumName: "swiss" +}; +exports3.ggrs87 = { + towgs84: "-199.87,74.79,246.62", + ellipse: "GRS80", + datumName: "Greek_Geodetic_Reference_System_1987" +}; +exports3.nad83 = { + towgs84: "0,0,0", + ellipse: "GRS80", + datumName: "North_American_Datum_1983" +}; +exports3.nad27 = { + nadgrids: "@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat", + ellipse: "clrk66", + datumName: "North_American_Datum_1927" +}; +exports3.potsdam = { + towgs84: "598.1,73.7,418.2,0.202,0.045,-2.455,6.7", + ellipse: "bessel", + datumName: "Potsdam Rauenberg 1950 DHDN" +}; +exports3.carthage = { + towgs84: "-263.0,6.0,431.0", + ellipse: "clark80", + datumName: "Carthage 1934 Tunisia" +}; +exports3.hermannskogel = { + towgs84: "577.326,90.129,463.919,5.137,1.474,5.297,2.4232", + ellipse: "bessel", + datumName: "Hermannskogel" +}; +exports3.osni52 = { + towgs84: "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15", + ellipse: "airy", + datumName: "Irish National" +}; +exports3.ire65 = { + towgs84: "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15", + ellipse: "mod_airy", + datumName: "Ireland 1965" +}; +exports3.rassadiran = { + towgs84: "-133.63,-157.5,-158.62", + ellipse: "intl", + datumName: "Rassadiran" +}; +exports3.nzgd49 = { + towgs84: "59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993", + ellipse: "intl", + datumName: "New Zealand Geodetic Datum 1949" +}; +exports3.osgb36 = { + towgs84: "446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894", + ellipse: "airy", + datumName: "Airy 1830" +}; +exports3.s_jtsk = { + towgs84: "589,76,480", + ellipse: "bessel", + datumName: "S-JTSK (Ferro)" +}; +exports3.beduaram = { + towgs84: "-106,-87,188", + ellipse: "clrk80", + datumName: "Beduaram" +}; +exports3.gunung_segara = { + towgs84: "-403,684,41", + ellipse: "bessel", + datumName: "Gunung Segara Jakarta" +}; +exports3.rnb72 = { + towgs84: "106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1", + ellipse: "intl", + datumName: "Reseau National Belge 1972" +}; + +// node_modules/proj4/lib/datum.js +function datum(datumCode, datum_params, a, b, es, ep2, nadgrids) { + var out = {}; + if (datumCode === void 0 || datumCode === "none") { + out.datum_type = PJD_NODATUM; + } else { + out.datum_type = PJD_WGS84; + } + if (datum_params) { + out.datum_params = datum_params.map(parseFloat); + if (out.datum_params[0] !== 0 || out.datum_params[1] !== 0 || out.datum_params[2] !== 0) { + out.datum_type = PJD_3PARAM; + } + if (out.datum_params.length > 3) { + if (out.datum_params[3] !== 0 || out.datum_params[4] !== 0 || out.datum_params[5] !== 0 || out.datum_params[6] !== 0) { + out.datum_type = PJD_7PARAM; + out.datum_params[3] *= SEC_TO_RAD; + out.datum_params[4] *= SEC_TO_RAD; + out.datum_params[5] *= SEC_TO_RAD; + out.datum_params[6] = out.datum_params[6] / 1e6 + 1; + } + } + } + if (nadgrids) { + out.datum_type = PJD_GRIDSHIFT; + out.grids = nadgrids; + } + out.a = a; + out.b = b; + out.es = es; + out.ep2 = ep2; + return out; +} +var datum_default = datum; + +// node_modules/proj4/lib/nadgrid.js +var loadedNadgrids = {}; +function nadgrid(key, data) { + var view = new DataView(data); + var isLittleEndian = detectLittleEndian(view); + var header = readHeader(view, isLittleEndian); + var subgrids = readSubgrids(view, header, isLittleEndian); + var nadgrid2 = { header, subgrids }; + loadedNadgrids[key] = nadgrid2; + return nadgrid2; +} +function getNadgrids(nadgrids) { + if (nadgrids === void 0) { + return null; + } + var grids = nadgrids.split(","); + return grids.map(parseNadgridString); +} +function parseNadgridString(value) { + if (value.length === 0) { + return null; + } + var optional = value[0] === "@"; + if (optional) { + value = value.slice(1); + } + if (value === "null") { + return { name: "null", mandatory: !optional, grid: null, isNull: true }; + } + return { + name: value, + mandatory: !optional, + grid: loadedNadgrids[value] || null, + isNull: false + }; +} +function secondsToRadians(seconds) { + return seconds / 3600 * Math.PI / 180; +} +function detectLittleEndian(view) { + var nFields = view.getInt32(8, false); + if (nFields === 11) { + return false; + } + nFields = view.getInt32(8, true); + if (nFields !== 11) { + console.warn("Failed to detect nadgrid endian-ness, defaulting to little-endian"); + } + return true; +} +function readHeader(view, isLittleEndian) { + return { + nFields: view.getInt32(8, isLittleEndian), + nSubgridFields: view.getInt32(24, isLittleEndian), + nSubgrids: view.getInt32(40, isLittleEndian), + shiftType: decodeString(view, 56, 56 + 8).trim(), + fromSemiMajorAxis: view.getFloat64(120, isLittleEndian), + fromSemiMinorAxis: view.getFloat64(136, isLittleEndian), + toSemiMajorAxis: view.getFloat64(152, isLittleEndian), + toSemiMinorAxis: view.getFloat64(168, isLittleEndian) + }; +} +function decodeString(view, start2, end) { + return String.fromCharCode.apply(null, new Uint8Array(view.buffer.slice(start2, end))); +} +function readSubgrids(view, header, isLittleEndian) { + var gridOffset = 176; + var grids = []; + for (var i = 0; i < header.nSubgrids; i++) { + var subHeader = readGridHeader(view, gridOffset, isLittleEndian); + var nodes = readGridNodes(view, gridOffset, subHeader, isLittleEndian); + var lngColumnCount = Math.round( + 1 + (subHeader.upperLongitude - subHeader.lowerLongitude) / subHeader.longitudeInterval + ); + var latColumnCount = Math.round( + 1 + (subHeader.upperLatitude - subHeader.lowerLatitude) / subHeader.latitudeInterval + ); + grids.push({ + ll: [secondsToRadians(subHeader.lowerLongitude), secondsToRadians(subHeader.lowerLatitude)], + del: [secondsToRadians(subHeader.longitudeInterval), secondsToRadians(subHeader.latitudeInterval)], + lim: [lngColumnCount, latColumnCount], + count: subHeader.gridNodeCount, + cvs: mapNodes(nodes) + }); + gridOffset += 176 + subHeader.gridNodeCount * 16; + } + return grids; +} +function mapNodes(nodes) { + return nodes.map(function(r) { + return [secondsToRadians(r.longitudeShift), secondsToRadians(r.latitudeShift)]; + }); +} +function readGridHeader(view, offset, isLittleEndian) { + return { + name: decodeString(view, offset + 8, offset + 16).trim(), + parent: decodeString(view, offset + 24, offset + 24 + 8).trim(), + lowerLatitude: view.getFloat64(offset + 72, isLittleEndian), + upperLatitude: view.getFloat64(offset + 88, isLittleEndian), + lowerLongitude: view.getFloat64(offset + 104, isLittleEndian), + upperLongitude: view.getFloat64(offset + 120, isLittleEndian), + latitudeInterval: view.getFloat64(offset + 136, isLittleEndian), + longitudeInterval: view.getFloat64(offset + 152, isLittleEndian), + gridNodeCount: view.getInt32(offset + 168, isLittleEndian) + }; +} +function readGridNodes(view, offset, gridHeader, isLittleEndian) { + var nodesOffset = offset + 176; + var gridRecordLength = 16; + var gridShiftRecords = []; + for (var i = 0; i < gridHeader.gridNodeCount; i++) { + var record = { + latitudeShift: view.getFloat32(nodesOffset + i * gridRecordLength, isLittleEndian), + longitudeShift: view.getFloat32(nodesOffset + i * gridRecordLength + 4, isLittleEndian), + latitudeAccuracy: view.getFloat32(nodesOffset + i * gridRecordLength + 8, isLittleEndian), + longitudeAccuracy: view.getFloat32(nodesOffset + i * gridRecordLength + 12, isLittleEndian) + }; + gridShiftRecords.push(record); + } + return gridShiftRecords; +} + +// node_modules/proj4/lib/Proj.js +function Projection(srsCode, callback) { + if (!(this instanceof Projection)) { + return new Projection(srsCode); + } + callback = callback || function(error) { + if (error) { + throw error; + } + }; + var json = parseCode_default(srsCode); + if (typeof json !== "object") { + callback(srsCode); + return; + } + var ourProj = Projection.projections.get(json.projName); + if (!ourProj) { + callback(srsCode); + return; + } + if (json.datumCode && json.datumCode !== "none") { + var datumDef = match(exports3, json.datumCode); + if (datumDef) { + json.datum_params = json.datum_params || (datumDef.towgs84 ? datumDef.towgs84.split(",") : null); + json.ellps = datumDef.ellipse; + json.datumName = datumDef.datumName ? datumDef.datumName : json.datumCode; + } + } + json.k0 = json.k0 || 1; + json.axis = json.axis || "enu"; + json.ellps = json.ellps || "wgs84"; + json.lat1 = json.lat1 || json.lat0; + var sphere_ = sphere(json.a, json.b, json.rf, json.ellps, json.sphere); + var ecc = eccentricity(sphere_.a, sphere_.b, sphere_.rf, json.R_A); + var nadgrids = getNadgrids(json.nadgrids); + var datumObj = json.datum || datum_default( + json.datumCode, + json.datum_params, + sphere_.a, + sphere_.b, + ecc.es, + ecc.ep2, + nadgrids + ); + extend_default(this, json); + extend_default(this, ourProj); + this.a = sphere_.a; + this.b = sphere_.b; + this.rf = sphere_.rf; + this.sphere = sphere_.sphere; + this.es = ecc.es; + this.e = ecc.e; + this.ep2 = ecc.ep2; + this.datum = datumObj; + this.init(); + callback(null, this); +} +Projection.projections = projections_default; +Projection.projections.start(); +var Proj_default = Projection; + +// node_modules/proj4/lib/datumUtils.js +function compareDatums(source, dest) { + if (source.datum_type !== dest.datum_type) { + return false; + } else if (source.a !== dest.a || Math.abs(source.es - dest.es) > 5e-11) { + return false; + } else if (source.datum_type === PJD_3PARAM) { + return source.datum_params[0] === dest.datum_params[0] && source.datum_params[1] === dest.datum_params[1] && source.datum_params[2] === dest.datum_params[2]; + } else if (source.datum_type === PJD_7PARAM) { + return source.datum_params[0] === dest.datum_params[0] && source.datum_params[1] === dest.datum_params[1] && source.datum_params[2] === dest.datum_params[2] && source.datum_params[3] === dest.datum_params[3] && source.datum_params[4] === dest.datum_params[4] && source.datum_params[5] === dest.datum_params[5] && source.datum_params[6] === dest.datum_params[6]; + } else { + return true; + } +} +function geodeticToGeocentric(p, es, a) { + var Longitude = p.x; + var Latitude = p.y; + var Height = p.z ? p.z : 0; + var Rn; + var Sin_Lat; + var Sin2_Lat; + var Cos_Lat; + if (Latitude < -HALF_PI && Latitude > -1.001 * HALF_PI) { + Latitude = -HALF_PI; + } else if (Latitude > HALF_PI && Latitude < 1.001 * HALF_PI) { + Latitude = HALF_PI; + } else if (Latitude < -HALF_PI) { + return { x: -Infinity, y: -Infinity, z: p.z }; + } else if (Latitude > HALF_PI) { + return { x: Infinity, y: Infinity, z: p.z }; + } + if (Longitude > Math.PI) { + Longitude -= 2 * Math.PI; + } + Sin_Lat = Math.sin(Latitude); + Cos_Lat = Math.cos(Latitude); + Sin2_Lat = Sin_Lat * Sin_Lat; + Rn = a / Math.sqrt(1 - es * Sin2_Lat); + return { + x: (Rn + Height) * Cos_Lat * Math.cos(Longitude), + y: (Rn + Height) * Cos_Lat * Math.sin(Longitude), + z: (Rn * (1 - es) + Height) * Sin_Lat + }; +} +function geocentricToGeodetic(p, es, a, b) { + var genau = 1e-12; + var genau2 = genau * genau; + var maxiter = 30; + var P; + var RR; + var CT; + var ST; + var RX; + var RK; + var RN; + var CPHI0; + var SPHI0; + var CPHI; + var SPHI; + var SDPHI; + var iter; + var X = p.x; + var Y = p.y; + var Z2 = p.z ? p.z : 0; + var Longitude; + var Latitude; + var Height; + P = Math.sqrt(X * X + Y * Y); + RR = Math.sqrt(X * X + Y * Y + Z2 * Z2); + if (P / a < genau) { + Longitude = 0; + if (RR / a < genau) { + Latitude = HALF_PI; + Height = -b; + return { + x: p.x, + y: p.y, + z: p.z + }; + } + } else { + Longitude = Math.atan2(Y, X); + } + CT = Z2 / RR; + ST = P / RR; + RX = 1 / Math.sqrt(1 - es * (2 - es) * ST * ST); + CPHI0 = ST * (1 - es) * RX; + SPHI0 = CT * RX; + iter = 0; + do { + iter++; + RN = a / Math.sqrt(1 - es * SPHI0 * SPHI0); + Height = P * CPHI0 + Z2 * SPHI0 - RN * (1 - es * SPHI0 * SPHI0); + RK = es * RN / (RN + Height); + RX = 1 / Math.sqrt(1 - RK * (2 - RK) * ST * ST); + CPHI = ST * (1 - RK) * RX; + SPHI = CT * RX; + SDPHI = SPHI * CPHI0 - CPHI * SPHI0; + CPHI0 = CPHI; + SPHI0 = SPHI; + } while (SDPHI * SDPHI > genau2 && iter < maxiter); + Latitude = Math.atan(SPHI / Math.abs(CPHI)); + return { + x: Longitude, + y: Latitude, + z: Height + }; +} +function geocentricToWgs84(p, datum_type, datum_params) { + if (datum_type === PJD_3PARAM) { + return { + x: p.x + datum_params[0], + y: p.y + datum_params[1], + z: p.z + datum_params[2] + }; + } else if (datum_type === PJD_7PARAM) { + var Dx_BF = datum_params[0]; + var Dy_BF = datum_params[1]; + var Dz_BF = datum_params[2]; + var Rx_BF = datum_params[3]; + var Ry_BF = datum_params[4]; + var Rz_BF = datum_params[5]; + var M_BF = datum_params[6]; + return { + x: M_BF * (p.x - Rz_BF * p.y + Ry_BF * p.z) + Dx_BF, + y: M_BF * (Rz_BF * p.x + p.y - Rx_BF * p.z) + Dy_BF, + z: M_BF * (-Ry_BF * p.x + Rx_BF * p.y + p.z) + Dz_BF + }; + } +} +function geocentricFromWgs84(p, datum_type, datum_params) { + if (datum_type === PJD_3PARAM) { + return { + x: p.x - datum_params[0], + y: p.y - datum_params[1], + z: p.z - datum_params[2] + }; + } else if (datum_type === PJD_7PARAM) { + var Dx_BF = datum_params[0]; + var Dy_BF = datum_params[1]; + var Dz_BF = datum_params[2]; + var Rx_BF = datum_params[3]; + var Ry_BF = datum_params[4]; + var Rz_BF = datum_params[5]; + var M_BF = datum_params[6]; + var x_tmp = (p.x - Dx_BF) / M_BF; + var y_tmp = (p.y - Dy_BF) / M_BF; + var z_tmp = (p.z - Dz_BF) / M_BF; + return { + x: x_tmp + Rz_BF * y_tmp - Ry_BF * z_tmp, + y: -Rz_BF * x_tmp + y_tmp + Rx_BF * z_tmp, + z: Ry_BF * x_tmp - Rx_BF * y_tmp + z_tmp + }; + } +} + +// node_modules/proj4/lib/datum_transform.js +function checkParams(type) { + return type === PJD_3PARAM || type === PJD_7PARAM; +} +function datum_transform_default(source, dest, point) { + if (compareDatums(source, dest)) { + return point; + } + if (source.datum_type === PJD_NODATUM || dest.datum_type === PJD_NODATUM) { + return point; + } + var source_a = source.a; + var source_es = source.es; + if (source.datum_type === PJD_GRIDSHIFT) { + var gridShiftCode = applyGridShift(source, false, point); + if (gridShiftCode !== 0) { + return void 0; + } + source_a = SRS_WGS84_SEMIMAJOR; + source_es = SRS_WGS84_ESQUARED; + } + var dest_a = dest.a; + var dest_b = dest.b; + var dest_es = dest.es; + if (dest.datum_type === PJD_GRIDSHIFT) { + dest_a = SRS_WGS84_SEMIMAJOR; + dest_b = SRS_WGS84_SEMIMINOR; + dest_es = SRS_WGS84_ESQUARED; + } + if (source_es === dest_es && source_a === dest_a && !checkParams(source.datum_type) && !checkParams(dest.datum_type)) { + return point; + } + point = geodeticToGeocentric(point, source_es, source_a); + if (checkParams(source.datum_type)) { + point = geocentricToWgs84(point, source.datum_type, source.datum_params); + } + if (checkParams(dest.datum_type)) { + point = geocentricFromWgs84(point, dest.datum_type, dest.datum_params); + } + point = geocentricToGeodetic(point, dest_es, dest_a, dest_b); + if (dest.datum_type === PJD_GRIDSHIFT) { + var destGridShiftResult = applyGridShift(dest, true, point); + if (destGridShiftResult !== 0) { + return void 0; + } + } + return point; +} +function applyGridShift(source, inverse32, point) { + if (source.grids === null || source.grids.length === 0) { + console.log("Grid shift grids not found"); + return -1; + } + var input = { x: -point.x, y: point.y }; + var output = { x: Number.NaN, y: Number.NaN }; + var onlyMandatoryGrids = false; + var attemptedGrids = []; + outer: + for (var i = 0; i < source.grids.length; i++) { + var grid = source.grids[i]; + attemptedGrids.push(grid.name); + if (grid.isNull) { + output = input; + break; + } + onlyMandatoryGrids = grid.mandatory; + if (grid.grid === null) { + if (grid.mandatory) { + console.log("Unable to find mandatory grid '" + grid.name + "'"); + return -1; + } + continue; + } + var subgrids = grid.grid.subgrids; + for (var j = 0, jj = subgrids.length; j < jj; j++) { + var subgrid = subgrids[j]; + var epsilon = (Math.abs(subgrid.del[1]) + Math.abs(subgrid.del[0])) / 1e4; + var minX = subgrid.ll[0] - epsilon; + var minY = subgrid.ll[1] - epsilon; + var maxX = subgrid.ll[0] + (subgrid.lim[0] - 1) * subgrid.del[0] + epsilon; + var maxY = subgrid.ll[1] + (subgrid.lim[1] - 1) * subgrid.del[1] + epsilon; + if (minY > input.y || minX > input.x || maxY < input.y || maxX < input.x) { + continue; + } + output = applySubgridShift(input, inverse32, subgrid); + if (!isNaN(output.x)) { + break outer; + } + } + } + if (isNaN(output.x)) { + console.log("Failed to find a grid shift table for location '" + -input.x * R2D + " " + input.y * R2D + " tried: '" + attemptedGrids + "'"); + return -1; + } + point.x = -output.x; + point.y = output.y; + return 0; +} +function applySubgridShift(pin, inverse32, ct) { + var val = { x: Number.NaN, y: Number.NaN }; + if (isNaN(pin.x)) { + return val; + } + var tb = { x: pin.x, y: pin.y }; + tb.x -= ct.ll[0]; + tb.y -= ct.ll[1]; + tb.x = adjust_lon_default(tb.x - Math.PI) + Math.PI; + var t = nadInterpolate(tb, ct); + if (inverse32) { + if (isNaN(t.x)) { + return val; + } + t.x = tb.x - t.x; + t.y = tb.y - t.y; + var i = 9, tol = 1e-12; + var dif, del; + do { + del = nadInterpolate(t, ct); + if (isNaN(del.x)) { + console.log("Inverse grid shift iteration failed, presumably at grid edge. Using first approximation."); + break; + } + dif = { x: tb.x - (del.x + t.x), y: tb.y - (del.y + t.y) }; + t.x += dif.x; + t.y += dif.y; + } while (i-- && Math.abs(dif.x) > tol && Math.abs(dif.y) > tol); + if (i < 0) { + console.log("Inverse grid shift iterator failed to converge."); + return val; + } + val.x = adjust_lon_default(t.x + ct.ll[0]); + val.y = t.y + ct.ll[1]; + } else { + if (!isNaN(t.x)) { + val.x = pin.x + t.x; + val.y = pin.y + t.y; + } + } + return val; +} +function nadInterpolate(pin, ct) { + var t = { x: pin.x / ct.del[0], y: pin.y / ct.del[1] }; + var indx = { x: Math.floor(t.x), y: Math.floor(t.y) }; + var frct = { x: t.x - 1 * indx.x, y: t.y - 1 * indx.y }; + var val = { x: Number.NaN, y: Number.NaN }; + var inx; + if (indx.x < 0 || indx.x >= ct.lim[0]) { + return val; + } + if (indx.y < 0 || indx.y >= ct.lim[1]) { + return val; + } + inx = indx.y * ct.lim[0] + indx.x; + var f00 = { x: ct.cvs[inx][0], y: ct.cvs[inx][1] }; + inx++; + var f10 = { x: ct.cvs[inx][0], y: ct.cvs[inx][1] }; + inx += ct.lim[0]; + var f11 = { x: ct.cvs[inx][0], y: ct.cvs[inx][1] }; + inx--; + var f01 = { x: ct.cvs[inx][0], y: ct.cvs[inx][1] }; + var m11 = frct.x * frct.y, m10 = frct.x * (1 - frct.y), m00 = (1 - frct.x) * (1 - frct.y), m01 = (1 - frct.x) * frct.y; + val.x = m00 * f00.x + m10 * f10.x + m01 * f01.x + m11 * f11.x; + val.y = m00 * f00.y + m10 * f10.y + m01 * f01.y + m11 * f11.y; + return val; +} + +// node_modules/proj4/lib/adjust_axis.js +function adjust_axis_default(crs, denorm, point) { + var xin = point.x, yin = point.y, zin = point.z || 0; + var v, t, i; + var out = {}; + for (i = 0; i < 3; i++) { + if (denorm && i === 2 && point.z === void 0) { + continue; + } + if (i === 0) { + v = xin; + if ("ew".indexOf(crs.axis[i]) !== -1) { + t = "x"; + } else { + t = "y"; + } + } else if (i === 1) { + v = yin; + if ("ns".indexOf(crs.axis[i]) !== -1) { + t = "y"; + } else { + t = "x"; + } + } else { + v = zin; + t = "z"; + } + switch (crs.axis[i]) { + case "e": + out[t] = v; + break; + case "w": + out[t] = -v; + break; + case "n": + out[t] = v; + break; + case "s": + out[t] = -v; + break; + case "u": + if (point[t] !== void 0) { + out.z = v; + } + break; + case "d": + if (point[t] !== void 0) { + out.z = -v; + } + break; + default: + return null; + } + } + return out; +} + +// node_modules/proj4/lib/common/toPoint.js +function toPoint_default(array) { + var out = { + x: array[0], + y: array[1] + }; + if (array.length > 2) { + out.z = array[2]; + } + if (array.length > 3) { + out.m = array[3]; + } + return out; +} + +// node_modules/proj4/lib/checkSanity.js +function checkSanity_default(point) { + checkCoord(point.x); + checkCoord(point.y); +} +function checkCoord(num) { + if (typeof Number.isFinite === "function") { + if (Number.isFinite(num)) { + return; + } + throw new TypeError("coordinates must be finite numbers"); + } + if (typeof num !== "number" || num !== num || !isFinite(num)) { + throw new TypeError("coordinates must be finite numbers"); + } +} + +// node_modules/proj4/lib/transform.js +function checkNotWGS(source, dest) { + return (source.datum.datum_type === PJD_3PARAM || source.datum.datum_type === PJD_7PARAM || source.datum.datum_type === PJD_GRIDSHIFT) && dest.datumCode !== "WGS84" || (dest.datum.datum_type === PJD_3PARAM || dest.datum.datum_type === PJD_7PARAM || dest.datum.datum_type === PJD_GRIDSHIFT) && source.datumCode !== "WGS84"; +} +function transform(source, dest, point, enforceAxis) { + var wgs842; + if (Array.isArray(point)) { + point = toPoint_default(point); + } else { + point = { + x: point.x, + y: point.y, + z: point.z, + m: point.m + }; + } + var hasZ = point.z !== void 0; + checkSanity_default(point); + if (source.datum && dest.datum && checkNotWGS(source, dest)) { + wgs842 = new Proj_default("WGS84"); + point = transform(source, wgs842, point, enforceAxis); + source = wgs842; + } + if (enforceAxis && source.axis !== "enu") { + point = adjust_axis_default(source, false, point); + } + if (source.projName === "longlat") { + point = { + x: point.x * D2R, + y: point.y * D2R, + z: point.z || 0 + }; + } else { + if (source.to_meter) { + point = { + x: point.x * source.to_meter, + y: point.y * source.to_meter, + z: point.z || 0 + }; + } + point = source.inverse(point); + if (!point) { + return; + } + } + if (source.from_greenwich) { + point.x += source.from_greenwich; + } + point = datum_transform_default(source.datum, dest.datum, point); + if (!point) { + return; + } + if (dest.from_greenwich) { + point = { + x: point.x - dest.from_greenwich, + y: point.y, + z: point.z || 0 + }; + } + if (dest.projName === "longlat") { + point = { + x: point.x * R2D, + y: point.y * R2D, + z: point.z || 0 + }; + } else { + point = dest.forward(point); + if (dest.to_meter) { + point = { + x: point.x / dest.to_meter, + y: point.y / dest.to_meter, + z: point.z || 0 + }; + } + } + if (enforceAxis && dest.axis !== "enu") { + return adjust_axis_default(dest, true, point); + } + if (point && !hasZ) { + delete point.z; + } + return point; +} + +// node_modules/proj4/lib/core.js +var wgs84 = Proj_default("WGS84"); +function transformer(from, to, coords, enforceAxis) { + var transformedArray, out, keys; + if (Array.isArray(coords)) { + transformedArray = transform(from, to, coords, enforceAxis) || { x: NaN, y: NaN }; + if (coords.length > 2) { + if (typeof from.name !== "undefined" && from.name === "geocent" || typeof to.name !== "undefined" && to.name === "geocent") { + if (typeof transformedArray.z === "number") { + return [transformedArray.x, transformedArray.y, transformedArray.z].concat(coords.splice(3)); + } else { + return [transformedArray.x, transformedArray.y, coords[2]].concat(coords.splice(3)); + } + } else { + return [transformedArray.x, transformedArray.y].concat(coords.splice(2)); + } + } else { + return [transformedArray.x, transformedArray.y]; + } + } else { + out = transform(from, to, coords, enforceAxis); + keys = Object.keys(coords); + if (keys.length === 2) { + return out; + } + keys.forEach(function(key) { + if (typeof from.name !== "undefined" && from.name === "geocent" || typeof to.name !== "undefined" && to.name === "geocent") { + if (key === "x" || key === "y" || key === "z") { + return; + } + } else { + if (key === "x" || key === "y") { + return; + } + } + out[key] = coords[key]; + }); + return out; + } +} +function checkProj(item) { + if (item instanceof Proj_default) { + return item; + } + if (item.oProj) { + return item.oProj; + } + return Proj_default(item); +} +function proj4(fromProj, toProj, coord) { + fromProj = checkProj(fromProj); + var single = false; + var obj; + if (typeof toProj === "undefined") { + toProj = fromProj; + fromProj = wgs84; + single = true; + } else if (typeof toProj.x !== "undefined" || Array.isArray(toProj)) { + coord = toProj; + toProj = fromProj; + fromProj = wgs84; + single = true; + } + toProj = checkProj(toProj); + if (coord) { + return transformer(fromProj, toProj, coord); + } else { + obj = { + forward: function(coords, enforceAxis) { + return transformer(fromProj, toProj, coords, enforceAxis); + }, + inverse: function(coords, enforceAxis) { + return transformer(toProj, fromProj, coords, enforceAxis); + } + }; + if (single) { + obj.oProj = toProj; + } + return obj; + } +} +var core_default = proj4; + +// node_modules/mgrs/mgrs.js +var NUM_100K_SETS = 6; +var SET_ORIGIN_COLUMN_LETTERS = "AJSAJS"; +var SET_ORIGIN_ROW_LETTERS = "AFAFAF"; +var A = 65; +var I = 73; +var O = 79; +var V = 86; +var Z = 90; +var mgrs_default = { + forward: forward2, + inverse: inverse2, + toPoint +}; +function forward2(ll, accuracy) { + accuracy = accuracy || 5; + return encode(LLtoUTM({ + lat: ll[1], + lon: ll[0] + }), accuracy); +} +function inverse2(mgrs) { + var bbox = UTMtoLL(decode(mgrs.toUpperCase())); + if (bbox.lat && bbox.lon) { + return [bbox.lon, bbox.lat, bbox.lon, bbox.lat]; + } + return [bbox.left, bbox.bottom, bbox.right, bbox.top]; +} +function toPoint(mgrs) { + var bbox = UTMtoLL(decode(mgrs.toUpperCase())); + if (bbox.lat && bbox.lon) { + return [bbox.lon, bbox.lat]; + } + return [(bbox.left + bbox.right) / 2, (bbox.top + bbox.bottom) / 2]; +} +function degToRad(deg) { + return deg * (Math.PI / 180); +} +function radToDeg(rad) { + return 180 * (rad / Math.PI); +} +function LLtoUTM(ll) { + var Lat = ll.lat; + var Long = ll.lon; + var a = 6378137; + var eccSquared = 669438e-8; + var k0 = 0.9996; + var LongOrigin; + var eccPrimeSquared; + var N, T, C, A2, M; + var LatRad = degToRad(Lat); + var LongRad = degToRad(Long); + var LongOriginRad; + var ZoneNumber; + ZoneNumber = Math.floor((Long + 180) / 6) + 1; + if (Long === 180) { + ZoneNumber = 60; + } + if (Lat >= 56 && Lat < 64 && Long >= 3 && Long < 12) { + ZoneNumber = 32; + } + if (Lat >= 72 && Lat < 84) { + if (Long >= 0 && Long < 9) { + ZoneNumber = 31; + } else if (Long >= 9 && Long < 21) { + ZoneNumber = 33; + } else if (Long >= 21 && Long < 33) { + ZoneNumber = 35; + } else if (Long >= 33 && Long < 42) { + ZoneNumber = 37; + } + } + LongOrigin = (ZoneNumber - 1) * 6 - 180 + 3; + LongOriginRad = degToRad(LongOrigin); + eccPrimeSquared = eccSquared / (1 - eccSquared); + N = a / Math.sqrt(1 - eccSquared * Math.sin(LatRad) * Math.sin(LatRad)); + T = Math.tan(LatRad) * Math.tan(LatRad); + C = eccPrimeSquared * Math.cos(LatRad) * Math.cos(LatRad); + A2 = Math.cos(LatRad) * (LongRad - LongOriginRad); + M = a * ((1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256) * LatRad - (3 * eccSquared / 8 + 3 * eccSquared * eccSquared / 32 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(2 * LatRad) + (15 * eccSquared * eccSquared / 256 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(4 * LatRad) - 35 * eccSquared * eccSquared * eccSquared / 3072 * Math.sin(6 * LatRad)); + var UTMEasting = k0 * N * (A2 + (1 - T + C) * A2 * A2 * A2 / 6 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A2 * A2 * A2 * A2 * A2 / 120) + 5e5; + var UTMNorthing = k0 * (M + N * Math.tan(LatRad) * (A2 * A2 / 2 + (5 - T + 9 * C + 4 * C * C) * A2 * A2 * A2 * A2 / 24 + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A2 * A2 * A2 * A2 * A2 * A2 / 720)); + if (Lat < 0) { + UTMNorthing += 1e7; + } + return { + northing: Math.round(UTMNorthing), + easting: Math.round(UTMEasting), + zoneNumber: ZoneNumber, + zoneLetter: getLetterDesignator(Lat) + }; +} +function UTMtoLL(utm) { + var UTMNorthing = utm.northing; + var UTMEasting = utm.easting; + var zoneLetter = utm.zoneLetter; + var zoneNumber = utm.zoneNumber; + if (zoneNumber < 0 || zoneNumber > 60) { + return null; + } + var k0 = 0.9996; + var a = 6378137; + var eccSquared = 669438e-8; + var eccPrimeSquared; + var e1 = (1 - Math.sqrt(1 - eccSquared)) / (1 + Math.sqrt(1 - eccSquared)); + var N1, T1, C12, R1, D, M; + var LongOrigin; + var mu, phi1Rad; + var x = UTMEasting - 5e5; + var y = UTMNorthing; + if (zoneLetter < "N") { + y -= 1e7; + } + LongOrigin = (zoneNumber - 1) * 6 - 180 + 3; + eccPrimeSquared = eccSquared / (1 - eccSquared); + M = y / k0; + mu = M / (a * (1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256)); + phi1Rad = mu + (3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * Math.sin(2 * mu) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * Math.sin(4 * mu) + 151 * e1 * e1 * e1 / 96 * Math.sin(6 * mu); + N1 = a / Math.sqrt(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad)); + T1 = Math.tan(phi1Rad) * Math.tan(phi1Rad); + C12 = eccPrimeSquared * Math.cos(phi1Rad) * Math.cos(phi1Rad); + R1 = a * (1 - eccSquared) / Math.pow(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad), 1.5); + D = x / (N1 * k0); + var lat = phi1Rad - N1 * Math.tan(phi1Rad) / R1 * (D * D / 2 - (5 + 3 * T1 + 10 * C12 - 4 * C12 * C12 - 9 * eccPrimeSquared) * D * D * D * D / 24 + (61 + 90 * T1 + 298 * C12 + 45 * T1 * T1 - 252 * eccPrimeSquared - 3 * C12 * C12) * D * D * D * D * D * D / 720); + lat = radToDeg(lat); + var lon = (D - (1 + 2 * T1 + C12) * D * D * D / 6 + (5 - 2 * C12 + 28 * T1 - 3 * C12 * C12 + 8 * eccPrimeSquared + 24 * T1 * T1) * D * D * D * D * D / 120) / Math.cos(phi1Rad); + lon = LongOrigin + radToDeg(lon); + var result; + if (utm.accuracy) { + var topRight = UTMtoLL({ + northing: utm.northing + utm.accuracy, + easting: utm.easting + utm.accuracy, + zoneLetter: utm.zoneLetter, + zoneNumber: utm.zoneNumber + }); + result = { + top: topRight.lat, + right: topRight.lon, + bottom: lat, + left: lon + }; + } else { + result = { + lat, + lon + }; + } + return result; +} +function getLetterDesignator(lat) { + var LetterDesignator = "Z"; + if (84 >= lat && lat >= 72) { + LetterDesignator = "X"; + } else if (72 > lat && lat >= 64) { + LetterDesignator = "W"; + } else if (64 > lat && lat >= 56) { + LetterDesignator = "V"; + } else if (56 > lat && lat >= 48) { + LetterDesignator = "U"; + } else if (48 > lat && lat >= 40) { + LetterDesignator = "T"; + } else if (40 > lat && lat >= 32) { + LetterDesignator = "S"; + } else if (32 > lat && lat >= 24) { + LetterDesignator = "R"; + } else if (24 > lat && lat >= 16) { + LetterDesignator = "Q"; + } else if (16 > lat && lat >= 8) { + LetterDesignator = "P"; + } else if (8 > lat && lat >= 0) { + LetterDesignator = "N"; + } else if (0 > lat && lat >= -8) { + LetterDesignator = "M"; + } else if (-8 > lat && lat >= -16) { + LetterDesignator = "L"; + } else if (-16 > lat && lat >= -24) { + LetterDesignator = "K"; + } else if (-24 > lat && lat >= -32) { + LetterDesignator = "J"; + } else if (-32 > lat && lat >= -40) { + LetterDesignator = "H"; + } else if (-40 > lat && lat >= -48) { + LetterDesignator = "G"; + } else if (-48 > lat && lat >= -56) { + LetterDesignator = "F"; + } else if (-56 > lat && lat >= -64) { + LetterDesignator = "E"; + } else if (-64 > lat && lat >= -72) { + LetterDesignator = "D"; + } else if (-72 > lat && lat >= -80) { + LetterDesignator = "C"; + } + return LetterDesignator; +} +function encode(utm, accuracy) { + var seasting = "00000" + utm.easting, snorthing = "00000" + utm.northing; + return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthing.length - 5, accuracy); +} +function get100kID(easting, northing, zoneNumber) { + var setParm = get100kSetForZone(zoneNumber); + var setColumn = Math.floor(easting / 1e5); + var setRow = Math.floor(northing / 1e5) % 20; + return getLetter100kID(setColumn, setRow, setParm); +} +function get100kSetForZone(i) { + var setParm = i % NUM_100K_SETS; + if (setParm === 0) { + setParm = NUM_100K_SETS; + } + return setParm; +} +function getLetter100kID(column, row, parm) { + var index = parm - 1; + var colOrigin = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(index); + var rowOrigin = SET_ORIGIN_ROW_LETTERS.charCodeAt(index); + var colInt = colOrigin + column - 1; + var rowInt = rowOrigin + row; + var rollover = false; + if (colInt > Z) { + colInt = colInt - Z + A - 1; + rollover = true; + } + if (colInt === I || colOrigin < I && colInt > I || (colInt > I || colOrigin < I) && rollover) { + colInt++; + } + if (colInt === O || colOrigin < O && colInt > O || (colInt > O || colOrigin < O) && rollover) { + colInt++; + if (colInt === I) { + colInt++; + } + } + if (colInt > Z) { + colInt = colInt - Z + A - 1; + } + if (rowInt > V) { + rowInt = rowInt - V + A - 1; + rollover = true; + } else { + rollover = false; + } + if (rowInt === I || rowOrigin < I && rowInt > I || (rowInt > I || rowOrigin < I) && rollover) { + rowInt++; + } + if (rowInt === O || rowOrigin < O && rowInt > O || (rowInt > O || rowOrigin < O) && rollover) { + rowInt++; + if (rowInt === I) { + rowInt++; + } + } + if (rowInt > V) { + rowInt = rowInt - V + A - 1; + } + var twoLetter = String.fromCharCode(colInt) + String.fromCharCode(rowInt); + return twoLetter; +} +function decode(mgrsString) { + if (mgrsString && mgrsString.length === 0) { + throw "MGRSPoint coverting from nothing"; + } + var length = mgrsString.length; + var hunK = null; + var sb = ""; + var testChar; + var i = 0; + while (!/[A-Z]/.test(testChar = mgrsString.charAt(i))) { + if (i >= 2) { + throw "MGRSPoint bad conversion from: " + mgrsString; + } + sb += testChar; + i++; + } + var zoneNumber = parseInt(sb, 10); + if (i === 0 || i + 3 > length) { + throw "MGRSPoint bad conversion from: " + mgrsString; + } + var zoneLetter = mgrsString.charAt(i++); + if (zoneLetter <= "A" || zoneLetter === "B" || zoneLetter === "Y" || zoneLetter >= "Z" || zoneLetter === "I" || zoneLetter === "O") { + throw "MGRSPoint zone letter " + zoneLetter + " not handled: " + mgrsString; + } + hunK = mgrsString.substring(i, i += 2); + var set = get100kSetForZone(zoneNumber); + var east100k = getEastingFromChar(hunK.charAt(0), set); + var north100k = getNorthingFromChar(hunK.charAt(1), set); + while (north100k < getMinNorthing(zoneLetter)) { + north100k += 2e6; + } + var remainder = length - i; + if (remainder % 2 !== 0) { + throw "MGRSPoint has to have an even number \nof digits after the zone letter and two 100km letters - front \nhalf for easting meters, second half for \nnorthing meters" + mgrsString; + } + var sep = remainder / 2; + var sepEasting = 0; + var sepNorthing = 0; + var accuracyBonus, sepEastingString, sepNorthingString, easting, northing; + if (sep > 0) { + accuracyBonus = 1e5 / Math.pow(10, sep); + sepEastingString = mgrsString.substring(i, i + sep); + sepEasting = parseFloat(sepEastingString) * accuracyBonus; + sepNorthingString = mgrsString.substring(i + sep); + sepNorthing = parseFloat(sepNorthingString) * accuracyBonus; + } + easting = sepEasting + east100k; + northing = sepNorthing + north100k; + return { + easting, + northing, + zoneLetter, + zoneNumber, + accuracy: accuracyBonus + }; +} +function getEastingFromChar(e, set) { + var curCol = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(set - 1); + var eastingValue = 1e5; + var rewindMarker = false; + while (curCol !== e.charCodeAt(0)) { + curCol++; + if (curCol === I) { + curCol++; + } + if (curCol === O) { + curCol++; + } + if (curCol > Z) { + if (rewindMarker) { + throw "Bad character: " + e; + } + curCol = A; + rewindMarker = true; + } + eastingValue += 1e5; + } + return eastingValue; +} +function getNorthingFromChar(n, set) { + if (n > "V") { + throw "MGRSPoint given invalid Northing " + n; + } + var curRow = SET_ORIGIN_ROW_LETTERS.charCodeAt(set - 1); + var northingValue = 0; + var rewindMarker = false; + while (curRow !== n.charCodeAt(0)) { + curRow++; + if (curRow === I) { + curRow++; + } + if (curRow === O) { + curRow++; + } + if (curRow > V) { + if (rewindMarker) { + throw "Bad character: " + n; + } + curRow = A; + rewindMarker = true; + } + northingValue += 1e5; + } + return northingValue; +} +function getMinNorthing(zoneLetter) { + var northing; + switch (zoneLetter) { + case "C": + northing = 11e5; + break; + case "D": + northing = 2e6; + break; + case "E": + northing = 28e5; + break; + case "F": + northing = 37e5; + break; + case "G": + northing = 46e5; + break; + case "H": + northing = 55e5; + break; + case "J": + northing = 64e5; + break; + case "K": + northing = 73e5; + break; + case "L": + northing = 82e5; + break; + case "M": + northing = 91e5; + break; + case "N": + northing = 0; + break; + case "P": + northing = 8e5; + break; + case "Q": + northing = 17e5; + break; + case "R": + northing = 26e5; + break; + case "S": + northing = 35e5; + break; + case "T": + northing = 44e5; + break; + case "U": + northing = 53e5; + break; + case "V": + northing = 62e5; + break; + case "W": + northing = 7e6; + break; + case "X": + northing = 79e5; + break; + default: + northing = -1; + } + if (northing >= 0) { + return northing; + } else { + throw "Invalid zone letter: " + zoneLetter; + } +} + +// node_modules/proj4/lib/Point.js +function Point(x, y, z) { + if (!(this instanceof Point)) { + return new Point(x, y, z); + } + if (Array.isArray(x)) { + this.x = x[0]; + this.y = x[1]; + this.z = x[2] || 0; + } else if (typeof x === "object") { + this.x = x.x; + this.y = x.y; + this.z = x.z || 0; + } else if (typeof x === "string" && typeof y === "undefined") { + var coords = x.split(","); + this.x = parseFloat(coords[0], 10); + this.y = parseFloat(coords[1], 10); + this.z = parseFloat(coords[2], 10) || 0; + } else { + this.x = x; + this.y = y; + this.z = z || 0; + } + console.warn("proj4.Point will be removed in version 3, use proj4.toPoint"); +} +Point.fromMGRS = function(mgrsStr) { + return new Point(toPoint(mgrsStr)); +}; +Point.prototype.toMGRS = function(accuracy) { + return forward2([this.x, this.y], accuracy); +}; +var Point_default = Point; + +// node_modules/proj4/lib/common/pj_enfn.js +var C00 = 1; +var C02 = 0.25; +var C04 = 0.046875; +var C06 = 0.01953125; +var C08 = 0.01068115234375; +var C22 = 0.75; +var C44 = 0.46875; +var C46 = 0.013020833333333334; +var C48 = 0.007120768229166667; +var C66 = 0.3645833333333333; +var C68 = 0.005696614583333333; +var C88 = 0.3076171875; +function pj_enfn_default(es) { + var en = []; + en[0] = C00 - es * (C02 + es * (C04 + es * (C06 + es * C08))); + en[1] = es * (C22 - es * (C04 + es * (C06 + es * C08))); + var t = es * es; + en[2] = t * (C44 - es * (C46 + es * C48)); + t *= es; + en[3] = t * (C66 - es * C68); + en[4] = t * es * C88; + return en; +} + +// node_modules/proj4/lib/common/pj_mlfn.js +function pj_mlfn_default(phi, sphi, cphi, en) { + cphi *= sphi; + sphi *= sphi; + return en[0] * phi - cphi * (en[1] + sphi * (en[2] + sphi * (en[3] + sphi * en[4]))); +} + +// node_modules/proj4/lib/common/pj_inv_mlfn.js +var MAX_ITER = 20; +function pj_inv_mlfn_default(arg, es, en) { + var k = 1 / (1 - es); + var phi = arg; + for (var i = MAX_ITER; i; --i) { + var s = Math.sin(phi); + var t = 1 - es * s * s; + t = (pj_mlfn_default(phi, s, Math.cos(phi), en) - arg) * (t * Math.sqrt(t)) * k; + phi -= t; + if (Math.abs(t) < EPSLN) { + return phi; + } + } + return phi; +} + +// node_modules/proj4/lib/projections/tmerc.js +function init3() { + this.x0 = this.x0 !== void 0 ? this.x0 : 0; + this.y0 = this.y0 !== void 0 ? this.y0 : 0; + this.long0 = this.long0 !== void 0 ? this.long0 : 0; + this.lat0 = this.lat0 !== void 0 ? this.lat0 : 0; + if (this.es) { + this.en = pj_enfn_default(this.es); + this.ml0 = pj_mlfn_default(this.lat0, Math.sin(this.lat0), Math.cos(this.lat0), this.en); + } +} +function forward3(p) { + var lon = p.x; + var lat = p.y; + var delta_lon = adjust_lon_default(lon - this.long0); + var con; + var x, y; + var sin_phi = Math.sin(lat); + var cos_phi = Math.cos(lat); + if (!this.es) { + var b = cos_phi * Math.sin(delta_lon); + if (Math.abs(Math.abs(b) - 1) < EPSLN) { + return 93; + } else { + x = 0.5 * this.a * this.k0 * Math.log((1 + b) / (1 - b)) + this.x0; + y = cos_phi * Math.cos(delta_lon) / Math.sqrt(1 - Math.pow(b, 2)); + b = Math.abs(y); + if (b >= 1) { + if (b - 1 > EPSLN) { + return 93; + } else { + y = 0; + } + } else { + y = Math.acos(y); + } + if (lat < 0) { + y = -y; + } + y = this.a * this.k0 * (y - this.lat0) + this.y0; + } + } else { + var al = cos_phi * delta_lon; + var als = Math.pow(al, 2); + var c = this.ep2 * Math.pow(cos_phi, 2); + var cs = Math.pow(c, 2); + var tq = Math.abs(cos_phi) > EPSLN ? Math.tan(lat) : 0; + var t = Math.pow(tq, 2); + var ts = Math.pow(t, 2); + con = 1 - this.es * Math.pow(sin_phi, 2); + al = al / Math.sqrt(con); + var ml = pj_mlfn_default(lat, sin_phi, cos_phi, this.en); + x = this.a * (this.k0 * al * (1 + als / 6 * (1 - t + c + als / 20 * (5 - 18 * t + ts + 14 * c - 58 * t * c + als / 42 * (61 + 179 * ts - ts * t - 479 * t))))) + this.x0; + y = this.a * (this.k0 * (ml - this.ml0 + sin_phi * delta_lon * al / 2 * (1 + als / 12 * (5 - t + 9 * c + 4 * cs + als / 30 * (61 + ts - 58 * t + 270 * c - 330 * t * c + als / 56 * (1385 + 543 * ts - ts * t - 3111 * t)))))) + this.y0; + } + p.x = x; + p.y = y; + return p; +} +function inverse3(p) { + var con, phi; + var lat, lon; + var x = (p.x - this.x0) * (1 / this.a); + var y = (p.y - this.y0) * (1 / this.a); + if (!this.es) { + var f = Math.exp(x / this.k0); + var g = 0.5 * (f - 1 / f); + var temp = this.lat0 + y / this.k0; + var h = Math.cos(temp); + con = Math.sqrt((1 - Math.pow(h, 2)) / (1 + Math.pow(g, 2))); + lat = Math.asin(con); + if (y < 0) { + lat = -lat; + } + if (g === 0 && h === 0) { + lon = 0; + } else { + lon = adjust_lon_default(Math.atan2(g, h) + this.long0); + } + } else { + con = this.ml0 + y / this.k0; + phi = pj_inv_mlfn_default(con, this.es, this.en); + if (Math.abs(phi) < HALF_PI) { + var sin_phi = Math.sin(phi); + var cos_phi = Math.cos(phi); + var tan_phi = Math.abs(cos_phi) > EPSLN ? Math.tan(phi) : 0; + var c = this.ep2 * Math.pow(cos_phi, 2); + var cs = Math.pow(c, 2); + var t = Math.pow(tan_phi, 2); + var ts = Math.pow(t, 2); + con = 1 - this.es * Math.pow(sin_phi, 2); + var d = x * Math.sqrt(con) / this.k0; + var ds = Math.pow(d, 2); + con = con * tan_phi; + lat = phi - con * ds / (1 - this.es) * 0.5 * (1 - ds / 12 * (5 + 3 * t - 9 * c * t + c - 4 * cs - ds / 30 * (61 + 90 * t - 252 * c * t + 45 * ts + 46 * c - ds / 56 * (1385 + 3633 * t + 4095 * ts + 1574 * ts * t)))); + lon = adjust_lon_default(this.long0 + d * (1 - ds / 6 * (1 + 2 * t + c - ds / 20 * (5 + 28 * t + 24 * ts + 8 * c * t + 6 * c - ds / 42 * (61 + 662 * t + 1320 * ts + 720 * ts * t)))) / cos_phi); + } else { + lat = HALF_PI * sign_default(y); + lon = 0; + } + } + p.x = lon; + p.y = lat; + return p; +} +var names4 = ["Fast_Transverse_Mercator", "Fast Transverse Mercator"]; +var tmerc_default = { + init: init3, + forward: forward3, + inverse: inverse3, + names: names4 +}; + +// node_modules/proj4/lib/common/sinh.js +function sinh_default(x) { + var r = Math.exp(x); + r = (r - 1 / r) / 2; + return r; +} + +// node_modules/proj4/lib/common/hypot.js +function hypot_default(x, y) { + x = Math.abs(x); + y = Math.abs(y); + var a = Math.max(x, y); + var b = Math.min(x, y) / (a ? a : 1); + return a * Math.sqrt(1 + Math.pow(b, 2)); +} + +// node_modules/proj4/lib/common/log1py.js +function log1py_default(x) { + var y = 1 + x; + var z = y - 1; + return z === 0 ? x : x * Math.log(y) / z; +} + +// node_modules/proj4/lib/common/asinhy.js +function asinhy_default(x) { + var y = Math.abs(x); + y = log1py_default(y * (1 + y / (hypot_default(1, y) + 1))); + return x < 0 ? -y : y; +} + +// node_modules/proj4/lib/common/gatg.js +function gatg_default(pp, B) { + var cos_2B = 2 * Math.cos(2 * B); + var i = pp.length - 1; + var h1 = pp[i]; + var h2 = 0; + var h; + while (--i >= 0) { + h = -h2 + cos_2B * h1 + pp[i]; + h2 = h1; + h1 = h; + } + return B + h * Math.sin(2 * B); +} + +// node_modules/proj4/lib/common/clens.js +function clens_default(pp, arg_r) { + var r = 2 * Math.cos(arg_r); + var i = pp.length - 1; + var hr1 = pp[i]; + var hr2 = 0; + var hr; + while (--i >= 0) { + hr = -hr2 + r * hr1 + pp[i]; + hr2 = hr1; + hr1 = hr; + } + return Math.sin(arg_r) * hr; +} + +// node_modules/proj4/lib/common/cosh.js +function cosh_default(x) { + var r = Math.exp(x); + r = (r + 1 / r) / 2; + return r; +} + +// node_modules/proj4/lib/common/clens_cmplx.js +function clens_cmplx_default(pp, arg_r, arg_i) { + var sin_arg_r = Math.sin(arg_r); + var cos_arg_r = Math.cos(arg_r); + var sinh_arg_i = sinh_default(arg_i); + var cosh_arg_i = cosh_default(arg_i); + var r = 2 * cos_arg_r * cosh_arg_i; + var i = -2 * sin_arg_r * sinh_arg_i; + var j = pp.length - 1; + var hr = pp[j]; + var hi1 = 0; + var hr1 = 0; + var hi = 0; + var hr2; + var hi2; + while (--j >= 0) { + hr2 = hr1; + hi2 = hi1; + hr1 = hr; + hi1 = hi; + hr = -hr2 + r * hr1 - i * hi1 + pp[j]; + hi = -hi2 + i * hr1 + r * hi1; + } + r = sin_arg_r * cosh_arg_i; + i = cos_arg_r * sinh_arg_i; + return [r * hr - i * hi, r * hi + i * hr]; +} + +// node_modules/proj4/lib/projections/etmerc.js +function init4() { + if (!this.approx && (isNaN(this.es) || this.es <= 0)) { + throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.'); + } + if (this.approx) { + tmerc_default.init.apply(this); + this.forward = tmerc_default.forward; + this.inverse = tmerc_default.inverse; + } + this.x0 = this.x0 !== void 0 ? this.x0 : 0; + this.y0 = this.y0 !== void 0 ? this.y0 : 0; + this.long0 = this.long0 !== void 0 ? this.long0 : 0; + this.lat0 = this.lat0 !== void 0 ? this.lat0 : 0; + this.cgb = []; + this.cbg = []; + this.utg = []; + this.gtu = []; + var f = this.es / (1 + Math.sqrt(1 - this.es)); + var n = f / (2 - f); + var np = n; + this.cgb[0] = n * (2 + n * (-2 / 3 + n * (-2 + n * (116 / 45 + n * (26 / 45 + n * (-2854 / 675)))))); + this.cbg[0] = n * (-2 + n * (2 / 3 + n * (4 / 3 + n * (-82 / 45 + n * (32 / 45 + n * (4642 / 4725)))))); + np = np * n; + this.cgb[1] = np * (7 / 3 + n * (-8 / 5 + n * (-227 / 45 + n * (2704 / 315 + n * (2323 / 945))))); + this.cbg[1] = np * (5 / 3 + n * (-16 / 15 + n * (-13 / 9 + n * (904 / 315 + n * (-1522 / 945))))); + np = np * n; + this.cgb[2] = np * (56 / 15 + n * (-136 / 35 + n * (-1262 / 105 + n * (73814 / 2835)))); + this.cbg[2] = np * (-26 / 15 + n * (34 / 21 + n * (8 / 5 + n * (-12686 / 2835)))); + np = np * n; + this.cgb[3] = np * (4279 / 630 + n * (-332 / 35 + n * (-399572 / 14175))); + this.cbg[3] = np * (1237 / 630 + n * (-12 / 5 + n * (-24832 / 14175))); + np = np * n; + this.cgb[4] = np * (4174 / 315 + n * (-144838 / 6237)); + this.cbg[4] = np * (-734 / 315 + n * (109598 / 31185)); + np = np * n; + this.cgb[5] = np * (601676 / 22275); + this.cbg[5] = np * (444337 / 155925); + np = Math.pow(n, 2); + this.Qn = this.k0 / (1 + n) * (1 + np * (1 / 4 + np * (1 / 64 + np / 256))); + this.utg[0] = n * (-0.5 + n * (2 / 3 + n * (-37 / 96 + n * (1 / 360 + n * (81 / 512 + n * (-96199 / 604800)))))); + this.gtu[0] = n * (0.5 + n * (-2 / 3 + n * (5 / 16 + n * (41 / 180 + n * (-127 / 288 + n * (7891 / 37800)))))); + this.utg[1] = np * (-1 / 48 + n * (-1 / 15 + n * (437 / 1440 + n * (-46 / 105 + n * (1118711 / 3870720))))); + this.gtu[1] = np * (13 / 48 + n * (-3 / 5 + n * (557 / 1440 + n * (281 / 630 + n * (-1983433 / 1935360))))); + np = np * n; + this.utg[2] = np * (-17 / 480 + n * (37 / 840 + n * (209 / 4480 + n * (-5569 / 90720)))); + this.gtu[2] = np * (61 / 240 + n * (-103 / 140 + n * (15061 / 26880 + n * (167603 / 181440)))); + np = np * n; + this.utg[3] = np * (-4397 / 161280 + n * (11 / 504 + n * (830251 / 7257600))); + this.gtu[3] = np * (49561 / 161280 + n * (-179 / 168 + n * (6601661 / 7257600))); + np = np * n; + this.utg[4] = np * (-4583 / 161280 + n * (108847 / 3991680)); + this.gtu[4] = np * (34729 / 80640 + n * (-3418889 / 1995840)); + np = np * n; + this.utg[5] = np * (-20648693 / 638668800); + this.gtu[5] = np * (212378941 / 319334400); + var Z2 = gatg_default(this.cbg, this.lat0); + this.Zb = -this.Qn * (Z2 + clens_default(this.gtu, 2 * Z2)); +} +function forward4(p) { + var Ce = adjust_lon_default(p.x - this.long0); + var Cn = p.y; + Cn = gatg_default(this.cbg, Cn); + var sin_Cn = Math.sin(Cn); + var cos_Cn = Math.cos(Cn); + var sin_Ce = Math.sin(Ce); + var cos_Ce = Math.cos(Ce); + Cn = Math.atan2(sin_Cn, cos_Ce * cos_Cn); + Ce = Math.atan2(sin_Ce * cos_Cn, hypot_default(sin_Cn, cos_Cn * cos_Ce)); + Ce = asinhy_default(Math.tan(Ce)); + var tmp = clens_cmplx_default(this.gtu, 2 * Cn, 2 * Ce); + Cn = Cn + tmp[0]; + Ce = Ce + tmp[1]; + var x; + var y; + if (Math.abs(Ce) <= 2.623395162778) { + x = this.a * (this.Qn * Ce) + this.x0; + y = this.a * (this.Qn * Cn + this.Zb) + this.y0; + } else { + x = Infinity; + y = Infinity; + } + p.x = x; + p.y = y; + return p; +} +function inverse4(p) { + var Ce = (p.x - this.x0) * (1 / this.a); + var Cn = (p.y - this.y0) * (1 / this.a); + Cn = (Cn - this.Zb) / this.Qn; + Ce = Ce / this.Qn; + var lon; + var lat; + if (Math.abs(Ce) <= 2.623395162778) { + var tmp = clens_cmplx_default(this.utg, 2 * Cn, 2 * Ce); + Cn = Cn + tmp[0]; + Ce = Ce + tmp[1]; + Ce = Math.atan(sinh_default(Ce)); + var sin_Cn = Math.sin(Cn); + var cos_Cn = Math.cos(Cn); + var sin_Ce = Math.sin(Ce); + var cos_Ce = Math.cos(Ce); + Cn = Math.atan2(sin_Cn * cos_Ce, hypot_default(sin_Ce, cos_Ce * cos_Cn)); + Ce = Math.atan2(sin_Ce, cos_Ce * cos_Cn); + lon = adjust_lon_default(Ce + this.long0); + lat = gatg_default(this.cgb, Cn); + } else { + lon = Infinity; + lat = Infinity; + } + p.x = lon; + p.y = lat; + return p; +} +var names5 = ["Extended_Transverse_Mercator", "Extended Transverse Mercator", "etmerc", "Transverse_Mercator", "Transverse Mercator", "tmerc"]; +var etmerc_default = { + init: init4, + forward: forward4, + inverse: inverse4, + names: names5 +}; + +// node_modules/proj4/lib/common/adjust_zone.js +function adjust_zone_default(zone, lon) { + if (zone === void 0) { + zone = Math.floor((adjust_lon_default(lon) + Math.PI) * 30 / Math.PI) + 1; + if (zone < 0) { + return 0; + } else if (zone > 60) { + return 60; + } + } + return zone; +} + +// node_modules/proj4/lib/projections/utm.js +var dependsOn = "etmerc"; +function init5() { + var zone = adjust_zone_default(this.zone, this.long0); + if (zone === void 0) { + throw new Error("unknown utm zone"); + } + this.lat0 = 0; + this.long0 = (6 * Math.abs(zone) - 183) * D2R; + this.x0 = 5e5; + this.y0 = this.utmSouth ? 1e7 : 0; + this.k0 = 0.9996; + etmerc_default.init.apply(this); + this.forward = etmerc_default.forward; + this.inverse = etmerc_default.inverse; +} +var names6 = ["Universal Transverse Mercator System", "utm"]; +var utm_default = { + init: init5, + names: names6, + dependsOn +}; + +// node_modules/proj4/lib/common/srat.js +function srat_default(esinp, exp) { + return Math.pow((1 - esinp) / (1 + esinp), exp); +} + +// node_modules/proj4/lib/projections/gauss.js +var MAX_ITER2 = 20; +function init6() { + var sphi = Math.sin(this.lat0); + var cphi = Math.cos(this.lat0); + cphi *= cphi; + this.rc = Math.sqrt(1 - this.es) / (1 - this.es * sphi * sphi); + this.C = Math.sqrt(1 + this.es * cphi * cphi / (1 - this.es)); + this.phic0 = Math.asin(sphi / this.C); + this.ratexp = 0.5 * this.C * this.e; + this.K = Math.tan(0.5 * this.phic0 + FORTPI) / (Math.pow(Math.tan(0.5 * this.lat0 + FORTPI), this.C) * srat_default(this.e * sphi, this.ratexp)); +} +function forward5(p) { + var lon = p.x; + var lat = p.y; + p.y = 2 * Math.atan(this.K * Math.pow(Math.tan(0.5 * lat + FORTPI), this.C) * srat_default(this.e * Math.sin(lat), this.ratexp)) - HALF_PI; + p.x = this.C * lon; + return p; +} +function inverse5(p) { + var DEL_TOL = 1e-14; + var lon = p.x / this.C; + var lat = p.y; + var num = Math.pow(Math.tan(0.5 * lat + FORTPI) / this.K, 1 / this.C); + for (var i = MAX_ITER2; i > 0; --i) { + lat = 2 * Math.atan(num * srat_default(this.e * Math.sin(p.y), -0.5 * this.e)) - HALF_PI; + if (Math.abs(lat - p.y) < DEL_TOL) { + break; + } + p.y = lat; + } + if (!i) { + return null; + } + p.x = lon; + p.y = lat; + return p; +} +var names7 = ["gauss"]; +var gauss_default = { + init: init6, + forward: forward5, + inverse: inverse5, + names: names7 +}; + +// node_modules/proj4/lib/projections/sterea.js +function init7() { + gauss_default.init.apply(this); + if (!this.rc) { + return; + } + this.sinc0 = Math.sin(this.phic0); + this.cosc0 = Math.cos(this.phic0); + this.R2 = 2 * this.rc; + if (!this.title) { + this.title = "Oblique Stereographic Alternative"; + } +} +function forward6(p) { + var sinc, cosc, cosl, k; + p.x = adjust_lon_default(p.x - this.long0); + gauss_default.forward.apply(this, [p]); + sinc = Math.sin(p.y); + cosc = Math.cos(p.y); + cosl = Math.cos(p.x); + k = this.k0 * this.R2 / (1 + this.sinc0 * sinc + this.cosc0 * cosc * cosl); + p.x = k * cosc * Math.sin(p.x); + p.y = k * (this.cosc0 * sinc - this.sinc0 * cosc * cosl); + p.x = this.a * p.x + this.x0; + p.y = this.a * p.y + this.y0; + return p; +} +function inverse6(p) { + var sinc, cosc, lon, lat, rho; + p.x = (p.x - this.x0) / this.a; + p.y = (p.y - this.y0) / this.a; + p.x /= this.k0; + p.y /= this.k0; + if (rho = Math.sqrt(p.x * p.x + p.y * p.y)) { + var c = 2 * Math.atan2(rho, this.R2); + sinc = Math.sin(c); + cosc = Math.cos(c); + lat = Math.asin(cosc * this.sinc0 + p.y * sinc * this.cosc0 / rho); + lon = Math.atan2(p.x * sinc, rho * this.cosc0 * cosc - p.y * this.sinc0 * sinc); + } else { + lat = this.phic0; + lon = 0; + } + p.x = lon; + p.y = lat; + gauss_default.inverse.apply(this, [p]); + p.x = adjust_lon_default(p.x + this.long0); + return p; +} +var names8 = ["Stereographic_North_Pole", "Oblique_Stereographic", "sterea", "Oblique Stereographic Alternative", "Double_Stereographic"]; +var sterea_default = { + init: init7, + forward: forward6, + inverse: inverse6, + names: names8 +}; + +// node_modules/proj4/lib/projections/stere.js +function ssfn_(phit, sinphi, eccen) { + sinphi *= eccen; + return Math.tan(0.5 * (HALF_PI + phit)) * Math.pow((1 - sinphi) / (1 + sinphi), 0.5 * eccen); +} +function init8() { + this.x0 = this.x0 || 0; + this.y0 = this.y0 || 0; + this.lat0 = this.lat0 || 0; + this.long0 = this.long0 || 0; + this.coslat0 = Math.cos(this.lat0); + this.sinlat0 = Math.sin(this.lat0); + if (this.sphere) { + if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) { + this.k0 = 0.5 * (1 + sign_default(this.lat0) * Math.sin(this.lat_ts)); + } + } else { + if (Math.abs(this.coslat0) <= EPSLN) { + if (this.lat0 > 0) { + this.con = 1; + } else { + this.con = -1; + } + } + this.cons = Math.sqrt(Math.pow(1 + this.e, 1 + this.e) * Math.pow(1 - this.e, 1 - this.e)); + if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN && Math.abs(Math.cos(this.lat_ts)) > EPSLN) { + this.k0 = 0.5 * this.cons * msfnz_default(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) / tsfnz_default(this.e, this.con * this.lat_ts, this.con * Math.sin(this.lat_ts)); + } + this.ms1 = msfnz_default(this.e, this.sinlat0, this.coslat0); + this.X0 = 2 * Math.atan(this.ssfn_(this.lat0, this.sinlat0, this.e)) - HALF_PI; + this.cosX0 = Math.cos(this.X0); + this.sinX0 = Math.sin(this.X0); + } +} +function forward7(p) { + var lon = p.x; + var lat = p.y; + var sinlat = Math.sin(lat); + var coslat = Math.cos(lat); + var A2, X, sinX, cosX, ts, rh; + var dlon = adjust_lon_default(lon - this.long0); + if (Math.abs(Math.abs(lon - this.long0) - Math.PI) <= EPSLN && Math.abs(lat + this.lat0) <= EPSLN) { + p.x = NaN; + p.y = NaN; + return p; + } + if (this.sphere) { + A2 = 2 * this.k0 / (1 + this.sinlat0 * sinlat + this.coslat0 * coslat * Math.cos(dlon)); + p.x = this.a * A2 * coslat * Math.sin(dlon) + this.x0; + p.y = this.a * A2 * (this.coslat0 * sinlat - this.sinlat0 * coslat * Math.cos(dlon)) + this.y0; + return p; + } else { + X = 2 * Math.atan(this.ssfn_(lat, sinlat, this.e)) - HALF_PI; + cosX = Math.cos(X); + sinX = Math.sin(X); + if (Math.abs(this.coslat0) <= EPSLN) { + ts = tsfnz_default(this.e, lat * this.con, this.con * sinlat); + rh = 2 * this.a * this.k0 * ts / this.cons; + p.x = this.x0 + rh * Math.sin(lon - this.long0); + p.y = this.y0 - this.con * rh * Math.cos(lon - this.long0); + return p; + } else if (Math.abs(this.sinlat0) < EPSLN) { + A2 = 2 * this.a * this.k0 / (1 + cosX * Math.cos(dlon)); + p.y = A2 * sinX; + } else { + A2 = 2 * this.a * this.k0 * this.ms1 / (this.cosX0 * (1 + this.sinX0 * sinX + this.cosX0 * cosX * Math.cos(dlon))); + p.y = A2 * (this.cosX0 * sinX - this.sinX0 * cosX * Math.cos(dlon)) + this.y0; + } + p.x = A2 * cosX * Math.sin(dlon) + this.x0; + } + return p; +} +function inverse7(p) { + p.x -= this.x0; + p.y -= this.y0; + var lon, lat, ts, ce, Chi; + var rh = Math.sqrt(p.x * p.x + p.y * p.y); + if (this.sphere) { + var c = 2 * Math.atan(rh / (2 * this.a * this.k0)); + lon = this.long0; + lat = this.lat0; + if (rh <= EPSLN) { + p.x = lon; + p.y = lat; + return p; + } + lat = Math.asin(Math.cos(c) * this.sinlat0 + p.y * Math.sin(c) * this.coslat0 / rh); + if (Math.abs(this.coslat0) < EPSLN) { + if (this.lat0 > 0) { + lon = adjust_lon_default(this.long0 + Math.atan2(p.x, -1 * p.y)); + } else { + lon = adjust_lon_default(this.long0 + Math.atan2(p.x, p.y)); + } + } else { + lon = adjust_lon_default(this.long0 + Math.atan2(p.x * Math.sin(c), rh * this.coslat0 * Math.cos(c) - p.y * this.sinlat0 * Math.sin(c))); + } + p.x = lon; + p.y = lat; + return p; + } else { + if (Math.abs(this.coslat0) <= EPSLN) { + if (rh <= EPSLN) { + lat = this.lat0; + lon = this.long0; + p.x = lon; + p.y = lat; + return p; + } + p.x *= this.con; + p.y *= this.con; + ts = rh * this.cons / (2 * this.a * this.k0); + lat = this.con * phi2z_default(this.e, ts); + lon = this.con * adjust_lon_default(this.con * this.long0 + Math.atan2(p.x, -1 * p.y)); + } else { + ce = 2 * Math.atan(rh * this.cosX0 / (2 * this.a * this.k0 * this.ms1)); + lon = this.long0; + if (rh <= EPSLN) { + Chi = this.X0; + } else { + Chi = Math.asin(Math.cos(ce) * this.sinX0 + p.y * Math.sin(ce) * this.cosX0 / rh); + lon = adjust_lon_default(this.long0 + Math.atan2(p.x * Math.sin(ce), rh * this.cosX0 * Math.cos(ce) - p.y * this.sinX0 * Math.sin(ce))); + } + lat = -1 * phi2z_default(this.e, Math.tan(0.5 * (HALF_PI + Chi))); + } + } + p.x = lon; + p.y = lat; + return p; +} +var names9 = ["stere", "Stereographic_South_Pole", "Polar Stereographic (variant B)", "Polar_Stereographic"]; +var stere_default = { + init: init8, + forward: forward7, + inverse: inverse7, + names: names9, + ssfn_ +}; + +// node_modules/proj4/lib/projections/somerc.js +function init9() { + var phy0 = this.lat0; + this.lambda0 = this.long0; + var sinPhy0 = Math.sin(phy0); + var semiMajorAxis = this.a; + var invF = this.rf; + var flattening = 1 / invF; + var e2 = 2 * flattening - Math.pow(flattening, 2); + var e = this.e = Math.sqrt(e2); + this.R = this.k0 * semiMajorAxis * Math.sqrt(1 - e2) / (1 - e2 * Math.pow(sinPhy0, 2)); + this.alpha = Math.sqrt(1 + e2 / (1 - e2) * Math.pow(Math.cos(phy0), 4)); + this.b0 = Math.asin(sinPhy0 / this.alpha); + var k1 = Math.log(Math.tan(Math.PI / 4 + this.b0 / 2)); + var k2 = Math.log(Math.tan(Math.PI / 4 + phy0 / 2)); + var k3 = Math.log((1 + e * sinPhy0) / (1 - e * sinPhy0)); + this.K = k1 - this.alpha * k2 + this.alpha * e / 2 * k3; +} +function forward8(p) { + var Sa1 = Math.log(Math.tan(Math.PI / 4 - p.y / 2)); + var Sa2 = this.e / 2 * Math.log((1 + this.e * Math.sin(p.y)) / (1 - this.e * Math.sin(p.y))); + var S = -this.alpha * (Sa1 + Sa2) + this.K; + var b = 2 * (Math.atan(Math.exp(S)) - Math.PI / 4); + var I2 = this.alpha * (p.x - this.lambda0); + var rotI = Math.atan(Math.sin(I2) / (Math.sin(this.b0) * Math.tan(b) + Math.cos(this.b0) * Math.cos(I2))); + var rotB = Math.asin(Math.cos(this.b0) * Math.sin(b) - Math.sin(this.b0) * Math.cos(b) * Math.cos(I2)); + p.y = this.R / 2 * Math.log((1 + Math.sin(rotB)) / (1 - Math.sin(rotB))) + this.y0; + p.x = this.R * rotI + this.x0; + return p; +} +function inverse8(p) { + var Y = p.x - this.x0; + var X = p.y - this.y0; + var rotI = Y / this.R; + var rotB = 2 * (Math.atan(Math.exp(X / this.R)) - Math.PI / 4); + var b = Math.asin(Math.cos(this.b0) * Math.sin(rotB) + Math.sin(this.b0) * Math.cos(rotB) * Math.cos(rotI)); + var I2 = Math.atan(Math.sin(rotI) / (Math.cos(this.b0) * Math.cos(rotI) - Math.sin(this.b0) * Math.tan(rotB))); + var lambda = this.lambda0 + I2 / this.alpha; + var S = 0; + var phy = b; + var prevPhy = -1e3; + var iteration = 0; + while (Math.abs(phy - prevPhy) > 1e-7) { + if (++iteration > 20) { + return; + } + S = 1 / this.alpha * (Math.log(Math.tan(Math.PI / 4 + b / 2)) - this.K) + this.e * Math.log(Math.tan(Math.PI / 4 + Math.asin(this.e * Math.sin(phy)) / 2)); + prevPhy = phy; + phy = 2 * Math.atan(Math.exp(S)) - Math.PI / 2; + } + p.x = lambda; + p.y = phy; + return p; +} +var names10 = ["somerc"]; +var somerc_default = { + init: init9, + forward: forward8, + inverse: inverse8, + names: names10 +}; + +// node_modules/proj4/lib/projections/omerc.js +var TOL = 1e-7; +function isTypeA(P) { + var typeAProjections = ["Hotine_Oblique_Mercator", "Hotine_Oblique_Mercator_Azimuth_Natural_Origin"]; + var projectionName = typeof P.PROJECTION === "object" ? Object.keys(P.PROJECTION)[0] : P.PROJECTION; + return "no_uoff" in P || "no_off" in P || typeAProjections.indexOf(projectionName) !== -1; +} +function init10() { + var con, com, cosph0, D, F, H, L, sinph0, p, J, gamma = 0, gamma0, lamc = 0, lam1 = 0, lam2 = 0, phi1 = 0, phi2 = 0, alpha_c = 0, AB; + this.no_off = isTypeA(this); + this.no_rot = "no_rot" in this; + var alp = false; + if ("alpha" in this) { + alp = true; + } + var gam = false; + if ("rectified_grid_angle" in this) { + gam = true; + } + if (alp) { + alpha_c = this.alpha; + } + if (gam) { + gamma = this.rectified_grid_angle * D2R; + } + if (alp || gam) { + lamc = this.longc; + } else { + lam1 = this.long1; + phi1 = this.lat1; + lam2 = this.long2; + phi2 = this.lat2; + if (Math.abs(phi1 - phi2) <= TOL || (con = Math.abs(phi1)) <= TOL || Math.abs(con - HALF_PI) <= TOL || Math.abs(Math.abs(this.lat0) - HALF_PI) <= TOL || Math.abs(Math.abs(phi2) - HALF_PI) <= TOL) { + throw new Error(); + } + } + var one_es = 1 - this.es; + com = Math.sqrt(one_es); + if (Math.abs(this.lat0) > EPSLN) { + sinph0 = Math.sin(this.lat0); + cosph0 = Math.cos(this.lat0); + con = 1 - this.es * sinph0 * sinph0; + this.B = cosph0 * cosph0; + this.B = Math.sqrt(1 + this.es * this.B * this.B / one_es); + this.A = this.B * this.k0 * com / con; + D = this.B * com / (cosph0 * Math.sqrt(con)); + F = D * D - 1; + if (F <= 0) { + F = 0; + } else { + F = Math.sqrt(F); + if (this.lat0 < 0) { + F = -F; + } + } + this.E = F += D; + this.E *= Math.pow(tsfnz_default(this.e, this.lat0, sinph0), this.B); + } else { + this.B = 1 / com; + this.A = this.k0; + this.E = D = F = 1; + } + if (alp || gam) { + if (alp) { + gamma0 = Math.asin(Math.sin(alpha_c) / D); + if (!gam) { + gamma = alpha_c; + } + } else { + gamma0 = gamma; + alpha_c = Math.asin(D * Math.sin(gamma0)); + } + this.lam0 = lamc - Math.asin(0.5 * (F - 1 / F) * Math.tan(gamma0)) / this.B; + } else { + H = Math.pow(tsfnz_default(this.e, phi1, Math.sin(phi1)), this.B); + L = Math.pow(tsfnz_default(this.e, phi2, Math.sin(phi2)), this.B); + F = this.E / H; + p = (L - H) / (L + H); + J = this.E * this.E; + J = (J - L * H) / (J + L * H); + con = lam1 - lam2; + if (con < -Math.pi) { + lam2 -= TWO_PI; + } else if (con > Math.pi) { + lam2 += TWO_PI; + } + this.lam0 = adjust_lon_default(0.5 * (lam1 + lam2) - Math.atan(J * Math.tan(0.5 * this.B * (lam1 - lam2)) / p) / this.B); + gamma0 = Math.atan(2 * Math.sin(this.B * adjust_lon_default(lam1 - this.lam0)) / (F - 1 / F)); + gamma = alpha_c = Math.asin(D * Math.sin(gamma0)); + } + this.singam = Math.sin(gamma0); + this.cosgam = Math.cos(gamma0); + this.sinrot = Math.sin(gamma); + this.cosrot = Math.cos(gamma); + this.rB = 1 / this.B; + this.ArB = this.A * this.rB; + this.BrA = 1 / this.ArB; + AB = this.A * this.B; + if (this.no_off) { + this.u_0 = 0; + } else { + this.u_0 = Math.abs(this.ArB * Math.atan(Math.sqrt(D * D - 1) / Math.cos(alpha_c))); + if (this.lat0 < 0) { + this.u_0 = -this.u_0; + } + } + F = 0.5 * gamma0; + this.v_pole_n = this.ArB * Math.log(Math.tan(FORTPI - F)); + this.v_pole_s = this.ArB * Math.log(Math.tan(FORTPI + F)); +} +function forward9(p) { + var coords = {}; + var S, T, U, V2, W, temp, u, v; + p.x = p.x - this.lam0; + if (Math.abs(Math.abs(p.y) - HALF_PI) > EPSLN) { + W = this.E / Math.pow(tsfnz_default(this.e, p.y, Math.sin(p.y)), this.B); + temp = 1 / W; + S = 0.5 * (W - temp); + T = 0.5 * (W + temp); + V2 = Math.sin(this.B * p.x); + U = (S * this.singam - V2 * this.cosgam) / T; + if (Math.abs(Math.abs(U) - 1) < EPSLN) { + throw new Error(); + } + v = 0.5 * this.ArB * Math.log((1 - U) / (1 + U)); + temp = Math.cos(this.B * p.x); + if (Math.abs(temp) < TOL) { + u = this.A * p.x; + } else { + u = this.ArB * Math.atan2(S * this.cosgam + V2 * this.singam, temp); + } + } else { + v = p.y > 0 ? this.v_pole_n : this.v_pole_s; + u = this.ArB * p.y; + } + if (this.no_rot) { + coords.x = u; + coords.y = v; + } else { + u -= this.u_0; + coords.x = v * this.cosrot + u * this.sinrot; + coords.y = u * this.cosrot - v * this.sinrot; + } + coords.x = this.a * coords.x + this.x0; + coords.y = this.a * coords.y + this.y0; + return coords; +} +function inverse9(p) { + var u, v, Qp, Sp, Tp, Vp, Up; + var coords = {}; + p.x = (p.x - this.x0) * (1 / this.a); + p.y = (p.y - this.y0) * (1 / this.a); + if (this.no_rot) { + v = p.y; + u = p.x; + } else { + v = p.x * this.cosrot - p.y * this.sinrot; + u = p.y * this.cosrot + p.x * this.sinrot + this.u_0; + } + Qp = Math.exp(-this.BrA * v); + Sp = 0.5 * (Qp - 1 / Qp); + Tp = 0.5 * (Qp + 1 / Qp); + Vp = Math.sin(this.BrA * u); + Up = (Vp * this.cosgam + Sp * this.singam) / Tp; + if (Math.abs(Math.abs(Up) - 1) < EPSLN) { + coords.x = 0; + coords.y = Up < 0 ? -HALF_PI : HALF_PI; + } else { + coords.y = this.E / Math.sqrt((1 + Up) / (1 - Up)); + coords.y = phi2z_default(this.e, Math.pow(coords.y, 1 / this.B)); + if (coords.y === Infinity) { + throw new Error(); + } + coords.x = -this.rB * Math.atan2(Sp * this.cosgam - Vp * this.singam, Math.cos(this.BrA * u)); + } + coords.x += this.lam0; + return coords; +} +var names11 = ["Hotine_Oblique_Mercator", "Hotine Oblique Mercator", "Hotine_Oblique_Mercator_Azimuth_Natural_Origin", "Hotine_Oblique_Mercator_Two_Point_Natural_Origin", "Hotine_Oblique_Mercator_Azimuth_Center", "Oblique_Mercator", "omerc"]; +var omerc_default = { + init: init10, + forward: forward9, + inverse: inverse9, + names: names11 +}; + +// node_modules/proj4/lib/projections/lcc.js +function init11() { + if (!this.lat2) { + this.lat2 = this.lat1; + } + if (!this.k0) { + this.k0 = 1; + } + this.x0 = this.x0 || 0; + this.y0 = this.y0 || 0; + if (Math.abs(this.lat1 + this.lat2) < EPSLN) { + return; + } + var temp = this.b / this.a; + this.e = Math.sqrt(1 - temp * temp); + var sin1 = Math.sin(this.lat1); + var cos1 = Math.cos(this.lat1); + var ms1 = msfnz_default(this.e, sin1, cos1); + var ts1 = tsfnz_default(this.e, this.lat1, sin1); + var sin2 = Math.sin(this.lat2); + var cos2 = Math.cos(this.lat2); + var ms2 = msfnz_default(this.e, sin2, cos2); + var ts2 = tsfnz_default(this.e, this.lat2, sin2); + var ts0 = tsfnz_default(this.e, this.lat0, Math.sin(this.lat0)); + if (Math.abs(this.lat1 - this.lat2) > EPSLN) { + this.ns = Math.log(ms1 / ms2) / Math.log(ts1 / ts2); + } else { + this.ns = sin1; + } + if (isNaN(this.ns)) { + this.ns = sin1; + } + this.f0 = ms1 / (this.ns * Math.pow(ts1, this.ns)); + this.rh = this.a * this.f0 * Math.pow(ts0, this.ns); + if (!this.title) { + this.title = "Lambert Conformal Conic"; + } +} +function forward10(p) { + var lon = p.x; + var lat = p.y; + if (Math.abs(2 * Math.abs(lat) - Math.PI) <= EPSLN) { + lat = sign_default(lat) * (HALF_PI - 2 * EPSLN); + } + var con = Math.abs(Math.abs(lat) - HALF_PI); + var ts, rh1; + if (con > EPSLN) { + ts = tsfnz_default(this.e, lat, Math.sin(lat)); + rh1 = this.a * this.f0 * Math.pow(ts, this.ns); + } else { + con = lat * this.ns; + if (con <= 0) { + return null; + } + rh1 = 0; + } + var theta = this.ns * adjust_lon_default(lon - this.long0); + p.x = this.k0 * (rh1 * Math.sin(theta)) + this.x0; + p.y = this.k0 * (this.rh - rh1 * Math.cos(theta)) + this.y0; + return p; +} +function inverse10(p) { + var rh1, con, ts; + var lat, lon; + var x = (p.x - this.x0) / this.k0; + var y = this.rh - (p.y - this.y0) / this.k0; + if (this.ns > 0) { + rh1 = Math.sqrt(x * x + y * y); + con = 1; + } else { + rh1 = -Math.sqrt(x * x + y * y); + con = -1; + } + var theta = 0; + if (rh1 !== 0) { + theta = Math.atan2(con * x, con * y); + } + if (rh1 !== 0 || this.ns > 0) { + con = 1 / this.ns; + ts = Math.pow(rh1 / (this.a * this.f0), con); + lat = phi2z_default(this.e, ts); + if (lat === -9999) { + return null; + } + } else { + lat = -HALF_PI; + } + lon = adjust_lon_default(theta / this.ns + this.long0); + p.x = lon; + p.y = lat; + return p; +} +var names12 = [ + "Lambert Tangential Conformal Conic Projection", + "Lambert_Conformal_Conic", + "Lambert_Conformal_Conic_1SP", + "Lambert_Conformal_Conic_2SP", + "lcc", + "Lambert Conic Conformal (1SP)", + "Lambert Conic Conformal (2SP)" +]; +var lcc_default = { + init: init11, + forward: forward10, + inverse: inverse10, + names: names12 +}; + +// node_modules/proj4/lib/projections/krovak.js +function init12() { + this.a = 6377397155e-3; + this.es = 0.006674372230614; + this.e = Math.sqrt(this.es); + if (!this.lat0) { + this.lat0 = 0.863937979737193; + } + if (!this.long0) { + this.long0 = 0.7417649320975901 - 0.308341501185665; + } + if (!this.k0) { + this.k0 = 0.9999; + } + this.s45 = 0.785398163397448; + this.s90 = 2 * this.s45; + this.fi0 = this.lat0; + this.e2 = this.es; + this.e = Math.sqrt(this.e2); + this.alfa = Math.sqrt(1 + this.e2 * Math.pow(Math.cos(this.fi0), 4) / (1 - this.e2)); + this.uq = 1.04216856380474; + this.u0 = Math.asin(Math.sin(this.fi0) / this.alfa); + this.g = Math.pow((1 + this.e * Math.sin(this.fi0)) / (1 - this.e * Math.sin(this.fi0)), this.alfa * this.e / 2); + this.k = Math.tan(this.u0 / 2 + this.s45) / Math.pow(Math.tan(this.fi0 / 2 + this.s45), this.alfa) * this.g; + this.k1 = this.k0; + this.n0 = this.a * Math.sqrt(1 - this.e2) / (1 - this.e2 * Math.pow(Math.sin(this.fi0), 2)); + this.s0 = 1.37008346281555; + this.n = Math.sin(this.s0); + this.ro0 = this.k1 * this.n0 / Math.tan(this.s0); + this.ad = this.s90 - this.uq; +} +function forward11(p) { + var gfi, u, deltav, s, d, eps, ro; + var lon = p.x; + var lat = p.y; + var delta_lon = adjust_lon_default(lon - this.long0); + gfi = Math.pow((1 + this.e * Math.sin(lat)) / (1 - this.e * Math.sin(lat)), this.alfa * this.e / 2); + u = 2 * (Math.atan(this.k * Math.pow(Math.tan(lat / 2 + this.s45), this.alfa) / gfi) - this.s45); + deltav = -delta_lon * this.alfa; + s = Math.asin(Math.cos(this.ad) * Math.sin(u) + Math.sin(this.ad) * Math.cos(u) * Math.cos(deltav)); + d = Math.asin(Math.cos(u) * Math.sin(deltav) / Math.cos(s)); + eps = this.n * d; + ro = this.ro0 * Math.pow(Math.tan(this.s0 / 2 + this.s45), this.n) / Math.pow(Math.tan(s / 2 + this.s45), this.n); + p.y = ro * Math.cos(eps) / 1; + p.x = ro * Math.sin(eps) / 1; + if (!this.czech) { + p.y *= -1; + p.x *= -1; + } + return p; +} +function inverse11(p) { + var u, deltav, s, d, eps, ro, fi1; + var ok; + var tmp = p.x; + p.x = p.y; + p.y = tmp; + if (!this.czech) { + p.y *= -1; + p.x *= -1; + } + ro = Math.sqrt(p.x * p.x + p.y * p.y); + eps = Math.atan2(p.y, p.x); + d = eps / Math.sin(this.s0); + s = 2 * (Math.atan(Math.pow(this.ro0 / ro, 1 / this.n) * Math.tan(this.s0 / 2 + this.s45)) - this.s45); + u = Math.asin(Math.cos(this.ad) * Math.sin(s) - Math.sin(this.ad) * Math.cos(s) * Math.cos(d)); + deltav = Math.asin(Math.cos(s) * Math.sin(d) / Math.cos(u)); + p.x = this.long0 - deltav / this.alfa; + fi1 = u; + ok = 0; + var iter = 0; + do { + p.y = 2 * (Math.atan(Math.pow(this.k, -1 / this.alfa) * Math.pow(Math.tan(u / 2 + this.s45), 1 / this.alfa) * Math.pow((1 + this.e * Math.sin(fi1)) / (1 - this.e * Math.sin(fi1)), this.e / 2)) - this.s45); + if (Math.abs(fi1 - p.y) < 1e-10) { + ok = 1; + } + fi1 = p.y; + iter += 1; + } while (ok === 0 && iter < 15); + if (iter >= 15) { + return null; + } + return p; +} +var names13 = ["Krovak", "krovak"]; +var krovak_default = { + init: init12, + forward: forward11, + inverse: inverse11, + names: names13 +}; + +// node_modules/proj4/lib/common/mlfn.js +function mlfn_default(e0, e1, e2, e3, phi) { + return e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi); +} + +// node_modules/proj4/lib/common/e0fn.js +function e0fn_default(x) { + return 1 - 0.25 * x * (1 + x / 16 * (3 + 1.25 * x)); +} + +// node_modules/proj4/lib/common/e1fn.js +function e1fn_default(x) { + return 0.375 * x * (1 + 0.25 * x * (1 + 0.46875 * x)); +} + +// node_modules/proj4/lib/common/e2fn.js +function e2fn_default(x) { + return 0.05859375 * x * x * (1 + 0.75 * x); +} + +// node_modules/proj4/lib/common/e3fn.js +function e3fn_default(x) { + return x * x * x * (35 / 3072); +} + +// node_modules/proj4/lib/common/gN.js +function gN_default(a, e, sinphi) { + var temp = e * sinphi; + return a / Math.sqrt(1 - temp * temp); +} + +// node_modules/proj4/lib/common/adjust_lat.js +function adjust_lat_default(x) { + return Math.abs(x) < HALF_PI ? x : x - sign_default(x) * Math.PI; +} + +// node_modules/proj4/lib/common/imlfn.js +function imlfn_default(ml, e0, e1, e2, e3) { + var phi; + var dphi; + phi = ml / e0; + for (var i = 0; i < 15; i++) { + dphi = (ml - (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi))) / (e0 - 2 * e1 * Math.cos(2 * phi) + 4 * e2 * Math.cos(4 * phi) - 6 * e3 * Math.cos(6 * phi)); + phi += dphi; + if (Math.abs(dphi) <= 1e-10) { + return phi; + } + } + return NaN; +} + +// node_modules/proj4/lib/projections/cass.js +function init13() { + if (!this.sphere) { + this.e0 = e0fn_default(this.es); + this.e1 = e1fn_default(this.es); + this.e2 = e2fn_default(this.es); + this.e3 = e3fn_default(this.es); + this.ml0 = this.a * mlfn_default(this.e0, this.e1, this.e2, this.e3, this.lat0); + } +} +function forward12(p) { + var x, y; + var lam = p.x; + var phi = p.y; + lam = adjust_lon_default(lam - this.long0); + if (this.sphere) { + x = this.a * Math.asin(Math.cos(phi) * Math.sin(lam)); + y = this.a * (Math.atan2(Math.tan(phi), Math.cos(lam)) - this.lat0); + } else { + var sinphi = Math.sin(phi); + var cosphi = Math.cos(phi); + var nl = gN_default(this.a, this.e, sinphi); + var tl = Math.tan(phi) * Math.tan(phi); + var al = lam * Math.cos(phi); + var asq = al * al; + var cl = this.es * cosphi * cosphi / (1 - this.es); + var ml = this.a * mlfn_default(this.e0, this.e1, this.e2, this.e3, phi); + x = nl * al * (1 - asq * tl * (1 / 6 - (8 - tl + 8 * cl) * asq / 120)); + y = ml - this.ml0 + nl * sinphi / cosphi * asq * (0.5 + (5 - tl + 6 * cl) * asq / 24); + } + p.x = x + this.x0; + p.y = y + this.y0; + return p; +} +function inverse12(p) { + p.x -= this.x0; + p.y -= this.y0; + var x = p.x / this.a; + var y = p.y / this.a; + var phi, lam; + if (this.sphere) { + var dd = y + this.lat0; + phi = Math.asin(Math.sin(dd) * Math.cos(x)); + lam = Math.atan2(Math.tan(x), Math.cos(dd)); + } else { + var ml1 = this.ml0 / this.a + y; + var phi1 = imlfn_default(ml1, this.e0, this.e1, this.e2, this.e3); + if (Math.abs(Math.abs(phi1) - HALF_PI) <= EPSLN) { + p.x = this.long0; + p.y = HALF_PI; + if (y < 0) { + p.y *= -1; + } + return p; + } + var nl1 = gN_default(this.a, this.e, Math.sin(phi1)); + var rl1 = nl1 * nl1 * nl1 / this.a / this.a * (1 - this.es); + var tl1 = Math.pow(Math.tan(phi1), 2); + var dl = x * this.a / nl1; + var dsq = dl * dl; + phi = phi1 - nl1 * Math.tan(phi1) / rl1 * dl * dl * (0.5 - (1 + 3 * tl1) * dl * dl / 24); + lam = dl * (1 - dsq * (tl1 / 3 + (1 + 3 * tl1) * tl1 * dsq / 15)) / Math.cos(phi1); + } + p.x = adjust_lon_default(lam + this.long0); + p.y = adjust_lat_default(phi); + return p; +} +var names14 = ["Cassini", "Cassini_Soldner", "cass"]; +var cass_default = { + init: init13, + forward: forward12, + inverse: inverse12, + names: names14 +}; + +// node_modules/proj4/lib/common/qsfnz.js +function qsfnz_default(eccent, sinphi) { + var con; + if (eccent > 1e-7) { + con = eccent * sinphi; + return (1 - eccent * eccent) * (sinphi / (1 - con * con) - 0.5 / eccent * Math.log((1 - con) / (1 + con))); + } else { + return 2 * sinphi; + } +} + +// node_modules/proj4/lib/projections/laea.js +var S_POLE = 1; +var N_POLE = 2; +var EQUIT = 3; +var OBLIQ = 4; +function init14() { + var t = Math.abs(this.lat0); + if (Math.abs(t - HALF_PI) < EPSLN) { + this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE; + } else if (Math.abs(t) < EPSLN) { + this.mode = this.EQUIT; + } else { + this.mode = this.OBLIQ; + } + if (this.es > 0) { + var sinphi; + this.qp = qsfnz_default(this.e, 1); + this.mmf = 0.5 / (1 - this.es); + this.apa = authset(this.es); + switch (this.mode) { + case this.N_POLE: + this.dd = 1; + break; + case this.S_POLE: + this.dd = 1; + break; + case this.EQUIT: + this.rq = Math.sqrt(0.5 * this.qp); + this.dd = 1 / this.rq; + this.xmf = 1; + this.ymf = 0.5 * this.qp; + break; + case this.OBLIQ: + this.rq = Math.sqrt(0.5 * this.qp); + sinphi = Math.sin(this.lat0); + this.sinb1 = qsfnz_default(this.e, sinphi) / this.qp; + this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1); + this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * sinphi * sinphi) * this.rq * this.cosb1); + this.ymf = (this.xmf = this.rq) / this.dd; + this.xmf *= this.dd; + break; + } + } else { + if (this.mode === this.OBLIQ) { + this.sinph0 = Math.sin(this.lat0); + this.cosph0 = Math.cos(this.lat0); + } + } +} +function forward13(p) { + var x, y, coslam, sinlam, sinphi, q, sinb, cosb, b, cosphi; + var lam = p.x; + var phi = p.y; + lam = adjust_lon_default(lam - this.long0); + if (this.sphere) { + sinphi = Math.sin(phi); + cosphi = Math.cos(phi); + coslam = Math.cos(lam); + if (this.mode === this.OBLIQ || this.mode === this.EQUIT) { + y = this.mode === this.EQUIT ? 1 + cosphi * coslam : 1 + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam; + if (y <= EPSLN) { + return null; + } + y = Math.sqrt(2 / y); + x = y * cosphi * Math.sin(lam); + y *= this.mode === this.EQUIT ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam; + } else if (this.mode === this.N_POLE || this.mode === this.S_POLE) { + if (this.mode === this.N_POLE) { + coslam = -coslam; + } + if (Math.abs(phi + this.lat0) < EPSLN) { + return null; + } + y = FORTPI - phi * 0.5; + y = 2 * (this.mode === this.S_POLE ? Math.cos(y) : Math.sin(y)); + x = y * Math.sin(lam); + y *= coslam; + } + } else { + sinb = 0; + cosb = 0; + b = 0; + coslam = Math.cos(lam); + sinlam = Math.sin(lam); + sinphi = Math.sin(phi); + q = qsfnz_default(this.e, sinphi); + if (this.mode === this.OBLIQ || this.mode === this.EQUIT) { + sinb = q / this.qp; + cosb = Math.sqrt(1 - sinb * sinb); + } + switch (this.mode) { + case this.OBLIQ: + b = 1 + this.sinb1 * sinb + this.cosb1 * cosb * coslam; + break; + case this.EQUIT: + b = 1 + cosb * coslam; + break; + case this.N_POLE: + b = HALF_PI + phi; + q = this.qp - q; + break; + case this.S_POLE: + b = phi - HALF_PI; + q = this.qp + q; + break; + } + if (Math.abs(b) < EPSLN) { + return null; + } + switch (this.mode) { + case this.OBLIQ: + case this.EQUIT: + b = Math.sqrt(2 / b); + if (this.mode === this.OBLIQ) { + y = this.ymf * b * (this.cosb1 * sinb - this.sinb1 * cosb * coslam); + } else { + y = (b = Math.sqrt(2 / (1 + cosb * coslam))) * sinb * this.ymf; + } + x = this.xmf * b * cosb * sinlam; + break; + case this.N_POLE: + case this.S_POLE: + if (q >= 0) { + x = (b = Math.sqrt(q)) * sinlam; + y = coslam * (this.mode === this.S_POLE ? b : -b); + } else { + x = y = 0; + } + break; + } + } + p.x = this.a * x + this.x0; + p.y = this.a * y + this.y0; + return p; +} +function inverse13(p) { + p.x -= this.x0; + p.y -= this.y0; + var x = p.x / this.a; + var y = p.y / this.a; + var lam, phi, cCe, sCe, q, rho, ab; + if (this.sphere) { + var cosz = 0, rh, sinz = 0; + rh = Math.sqrt(x * x + y * y); + phi = rh * 0.5; + if (phi > 1) { + return null; + } + phi = 2 * Math.asin(phi); + if (this.mode === this.OBLIQ || this.mode === this.EQUIT) { + sinz = Math.sin(phi); + cosz = Math.cos(phi); + } + switch (this.mode) { + case this.EQUIT: + phi = Math.abs(rh) <= EPSLN ? 0 : Math.asin(y * sinz / rh); + x *= sinz; + y = cosz * rh; + break; + case this.OBLIQ: + phi = Math.abs(rh) <= EPSLN ? this.lat0 : Math.asin(cosz * this.sinph0 + y * sinz * this.cosph0 / rh); + x *= sinz * this.cosph0; + y = (cosz - Math.sin(phi) * this.sinph0) * rh; + break; + case this.N_POLE: + y = -y; + phi = HALF_PI - phi; + break; + case this.S_POLE: + phi -= HALF_PI; + break; + } + lam = y === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ) ? 0 : Math.atan2(x, y); + } else { + ab = 0; + if (this.mode === this.OBLIQ || this.mode === this.EQUIT) { + x /= this.dd; + y *= this.dd; + rho = Math.sqrt(x * x + y * y); + if (rho < EPSLN) { + p.x = this.long0; + p.y = this.lat0; + return p; + } + sCe = 2 * Math.asin(0.5 * rho / this.rq); + cCe = Math.cos(sCe); + x *= sCe = Math.sin(sCe); + if (this.mode === this.OBLIQ) { + ab = cCe * this.sinb1 + y * sCe * this.cosb1 / rho; + q = this.qp * ab; + y = rho * this.cosb1 * cCe - y * this.sinb1 * sCe; + } else { + ab = y * sCe / rho; + q = this.qp * ab; + y = rho * cCe; + } + } else if (this.mode === this.N_POLE || this.mode === this.S_POLE) { + if (this.mode === this.N_POLE) { + y = -y; + } + q = x * x + y * y; + if (!q) { + p.x = this.long0; + p.y = this.lat0; + return p; + } + ab = 1 - q / this.qp; + if (this.mode === this.S_POLE) { + ab = -ab; + } + } + lam = Math.atan2(x, y); + phi = authlat(Math.asin(ab), this.apa); + } + p.x = adjust_lon_default(this.long0 + lam); + p.y = phi; + return p; +} +var P00 = 0.3333333333333333; +var P01 = 0.17222222222222222; +var P02 = 0.10257936507936508; +var P10 = 0.06388888888888888; +var P11 = 0.0664021164021164; +var P20 = 0.016415012942191543; +function authset(es) { + var t; + var APA = []; + APA[0] = es * P00; + t = es * es; + APA[0] += t * P01; + APA[1] = t * P10; + t *= es; + APA[0] += t * P02; + APA[1] += t * P11; + APA[2] = t * P20; + return APA; +} +function authlat(beta, APA) { + var t = beta + beta; + return beta + APA[0] * Math.sin(t) + APA[1] * Math.sin(t + t) + APA[2] * Math.sin(t + t + t); +} +var names15 = ["Lambert Azimuthal Equal Area", "Lambert_Azimuthal_Equal_Area", "laea"]; +var laea_default = { + init: init14, + forward: forward13, + inverse: inverse13, + names: names15, + S_POLE, + N_POLE, + EQUIT, + OBLIQ +}; + +// node_modules/proj4/lib/common/asinz.js +function asinz_default(x) { + if (Math.abs(x) > 1) { + x = x > 1 ? 1 : -1; + } + return Math.asin(x); +} + +// node_modules/proj4/lib/projections/aea.js +function init15() { + if (Math.abs(this.lat1 + this.lat2) < EPSLN) { + return; + } + this.temp = this.b / this.a; + this.es = 1 - Math.pow(this.temp, 2); + this.e3 = Math.sqrt(this.es); + this.sin_po = Math.sin(this.lat1); + this.cos_po = Math.cos(this.lat1); + this.t1 = this.sin_po; + this.con = this.sin_po; + this.ms1 = msfnz_default(this.e3, this.sin_po, this.cos_po); + this.qs1 = qsfnz_default(this.e3, this.sin_po); + this.sin_po = Math.sin(this.lat2); + this.cos_po = Math.cos(this.lat2); + this.t2 = this.sin_po; + this.ms2 = msfnz_default(this.e3, this.sin_po, this.cos_po); + this.qs2 = qsfnz_default(this.e3, this.sin_po); + this.sin_po = Math.sin(this.lat0); + this.cos_po = Math.cos(this.lat0); + this.t3 = this.sin_po; + this.qs0 = qsfnz_default(this.e3, this.sin_po); + if (Math.abs(this.lat1 - this.lat2) > EPSLN) { + this.ns0 = (this.ms1 * this.ms1 - this.ms2 * this.ms2) / (this.qs2 - this.qs1); + } else { + this.ns0 = this.con; + } + this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1; + this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0) / this.ns0; +} +function forward14(p) { + var lon = p.x; + var lat = p.y; + this.sin_phi = Math.sin(lat); + this.cos_phi = Math.cos(lat); + var qs = qsfnz_default(this.e3, this.sin_phi); + var rh1 = this.a * Math.sqrt(this.c - this.ns0 * qs) / this.ns0; + var theta = this.ns0 * adjust_lon_default(lon - this.long0); + var x = rh1 * Math.sin(theta) + this.x0; + var y = this.rh - rh1 * Math.cos(theta) + this.y0; + p.x = x; + p.y = y; + return p; +} +function inverse14(p) { + var rh1, qs, con, theta, lon, lat; + p.x -= this.x0; + p.y = this.rh - p.y + this.y0; + if (this.ns0 >= 0) { + rh1 = Math.sqrt(p.x * p.x + p.y * p.y); + con = 1; + } else { + rh1 = -Math.sqrt(p.x * p.x + p.y * p.y); + con = -1; + } + theta = 0; + if (rh1 !== 0) { + theta = Math.atan2(con * p.x, con * p.y); + } + con = rh1 * this.ns0 / this.a; + if (this.sphere) { + lat = Math.asin((this.c - con * con) / (2 * this.ns0)); + } else { + qs = (this.c - con * con) / this.ns0; + lat = this.phi1z(this.e3, qs); + } + lon = adjust_lon_default(theta / this.ns0 + this.long0); + p.x = lon; + p.y = lat; + return p; +} +function phi1z(eccent, qs) { + var sinphi, cosphi, con, com, dphi; + var phi = asinz_default(0.5 * qs); + if (eccent < EPSLN) { + return phi; + } + var eccnts = eccent * eccent; + for (var i = 1; i <= 25; i++) { + sinphi = Math.sin(phi); + cosphi = Math.cos(phi); + con = eccent * sinphi; + com = 1 - con * con; + dphi = 0.5 * com * com / cosphi * (qs / (1 - eccnts) - sinphi / com + 0.5 / eccent * Math.log((1 - con) / (1 + con))); + phi = phi + dphi; + if (Math.abs(dphi) <= 1e-7) { + return phi; + } + } + return null; +} +var names16 = ["Albers_Conic_Equal_Area", "Albers", "aea"]; +var aea_default = { + init: init15, + forward: forward14, + inverse: inverse14, + names: names16, + phi1z +}; + +// node_modules/proj4/lib/projections/gnom.js +function init16() { + this.sin_p14 = Math.sin(this.lat0); + this.cos_p14 = Math.cos(this.lat0); + this.infinity_dist = 1e3 * this.a; + this.rc = 1; +} +function forward15(p) { + var sinphi, cosphi; + var dlon; + var coslon; + var ksp; + var g; + var x, y; + var lon = p.x; + var lat = p.y; + dlon = adjust_lon_default(lon - this.long0); + sinphi = Math.sin(lat); + cosphi = Math.cos(lat); + coslon = Math.cos(dlon); + g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon; + ksp = 1; + if (g > 0 || Math.abs(g) <= EPSLN) { + x = this.x0 + this.a * ksp * cosphi * Math.sin(dlon) / g; + y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon) / g; + } else { + x = this.x0 + this.infinity_dist * cosphi * Math.sin(dlon); + y = this.y0 + this.infinity_dist * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon); + } + p.x = x; + p.y = y; + return p; +} +function inverse15(p) { + var rh; + var sinc, cosc; + var c; + var lon, lat; + p.x = (p.x - this.x0) / this.a; + p.y = (p.y - this.y0) / this.a; + p.x /= this.k0; + p.y /= this.k0; + if (rh = Math.sqrt(p.x * p.x + p.y * p.y)) { + c = Math.atan2(rh, this.rc); + sinc = Math.sin(c); + cosc = Math.cos(c); + lat = asinz_default(cosc * this.sin_p14 + p.y * sinc * this.cos_p14 / rh); + lon = Math.atan2(p.x * sinc, rh * this.cos_p14 * cosc - p.y * this.sin_p14 * sinc); + lon = adjust_lon_default(this.long0 + lon); + } else { + lat = this.phic0; + lon = 0; + } + p.x = lon; + p.y = lat; + return p; +} +var names17 = ["gnom"]; +var gnom_default = { + init: init16, + forward: forward15, + inverse: inverse15, + names: names17 +}; + +// node_modules/proj4/lib/common/iqsfnz.js +function iqsfnz_default(eccent, q) { + var temp = 1 - (1 - eccent * eccent) / (2 * eccent) * Math.log((1 - eccent) / (1 + eccent)); + if (Math.abs(Math.abs(q) - temp) < 1e-6) { + if (q < 0) { + return -1 * HALF_PI; + } else { + return HALF_PI; + } + } + var phi = Math.asin(0.5 * q); + var dphi; + var sin_phi; + var cos_phi; + var con; + for (var i = 0; i < 30; i++) { + sin_phi = Math.sin(phi); + cos_phi = Math.cos(phi); + con = eccent * sin_phi; + dphi = Math.pow(1 - con * con, 2) / (2 * cos_phi) * (q / (1 - eccent * eccent) - sin_phi / (1 - con * con) + 0.5 / eccent * Math.log((1 - con) / (1 + con))); + phi += dphi; + if (Math.abs(dphi) <= 1e-10) { + return phi; + } + } + return NaN; +} + +// node_modules/proj4/lib/projections/cea.js +function init17() { + if (!this.sphere) { + this.k0 = msfnz_default(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)); + } +} +function forward16(p) { + var lon = p.x; + var lat = p.y; + var x, y; + var dlon = adjust_lon_default(lon - this.long0); + if (this.sphere) { + x = this.x0 + this.a * dlon * Math.cos(this.lat_ts); + y = this.y0 + this.a * Math.sin(lat) / Math.cos(this.lat_ts); + } else { + var qs = qsfnz_default(this.e, Math.sin(lat)); + x = this.x0 + this.a * this.k0 * dlon; + y = this.y0 + this.a * qs * 0.5 / this.k0; + } + p.x = x; + p.y = y; + return p; +} +function inverse16(p) { + p.x -= this.x0; + p.y -= this.y0; + var lon, lat; + if (this.sphere) { + lon = adjust_lon_default(this.long0 + p.x / this.a / Math.cos(this.lat_ts)); + lat = Math.asin(p.y / this.a * Math.cos(this.lat_ts)); + } else { + lat = iqsfnz_default(this.e, 2 * p.y * this.k0 / this.a); + lon = adjust_lon_default(this.long0 + p.x / (this.a * this.k0)); + } + p.x = lon; + p.y = lat; + return p; +} +var names18 = ["cea"]; +var cea_default = { + init: init17, + forward: forward16, + inverse: inverse16, + names: names18 +}; + +// node_modules/proj4/lib/projections/eqc.js +function init18() { + this.x0 = this.x0 || 0; + this.y0 = this.y0 || 0; + this.lat0 = this.lat0 || 0; + this.long0 = this.long0 || 0; + this.lat_ts = this.lat_ts || 0; + this.title = this.title || "Equidistant Cylindrical (Plate Carre)"; + this.rc = Math.cos(this.lat_ts); +} +function forward17(p) { + var lon = p.x; + var lat = p.y; + var dlon = adjust_lon_default(lon - this.long0); + var dlat = adjust_lat_default(lat - this.lat0); + p.x = this.x0 + this.a * dlon * this.rc; + p.y = this.y0 + this.a * dlat; + return p; +} +function inverse17(p) { + var x = p.x; + var y = p.y; + p.x = adjust_lon_default(this.long0 + (x - this.x0) / (this.a * this.rc)); + p.y = adjust_lat_default(this.lat0 + (y - this.y0) / this.a); + return p; +} +var names19 = ["Equirectangular", "Equidistant_Cylindrical", "eqc"]; +var eqc_default = { + init: init18, + forward: forward17, + inverse: inverse17, + names: names19 +}; + +// node_modules/proj4/lib/projections/poly.js +var MAX_ITER3 = 20; +function init19() { + this.temp = this.b / this.a; + this.es = 1 - Math.pow(this.temp, 2); + this.e = Math.sqrt(this.es); + this.e0 = e0fn_default(this.es); + this.e1 = e1fn_default(this.es); + this.e2 = e2fn_default(this.es); + this.e3 = e3fn_default(this.es); + this.ml0 = this.a * mlfn_default(this.e0, this.e1, this.e2, this.e3, this.lat0); +} +function forward18(p) { + var lon = p.x; + var lat = p.y; + var x, y, el; + var dlon = adjust_lon_default(lon - this.long0); + el = dlon * Math.sin(lat); + if (this.sphere) { + if (Math.abs(lat) <= EPSLN) { + x = this.a * dlon; + y = -1 * this.a * this.lat0; + } else { + x = this.a * Math.sin(el) / Math.tan(lat); + y = this.a * (adjust_lat_default(lat - this.lat0) + (1 - Math.cos(el)) / Math.tan(lat)); + } + } else { + if (Math.abs(lat) <= EPSLN) { + x = this.a * dlon; + y = -1 * this.ml0; + } else { + var nl = gN_default(this.a, this.e, Math.sin(lat)) / Math.tan(lat); + x = nl * Math.sin(el); + y = this.a * mlfn_default(this.e0, this.e1, this.e2, this.e3, lat) - this.ml0 + nl * (1 - Math.cos(el)); + } + } + p.x = x + this.x0; + p.y = y + this.y0; + return p; +} +function inverse18(p) { + var lon, lat, x, y, i; + var al, bl; + var phi, dphi; + x = p.x - this.x0; + y = p.y - this.y0; + if (this.sphere) { + if (Math.abs(y + this.a * this.lat0) <= EPSLN) { + lon = adjust_lon_default(x / this.a + this.long0); + lat = 0; + } else { + al = this.lat0 + y / this.a; + bl = x * x / this.a / this.a + al * al; + phi = al; + var tanphi; + for (i = MAX_ITER3; i; --i) { + tanphi = Math.tan(phi); + dphi = -1 * (al * (phi * tanphi + 1) - phi - 0.5 * (phi * phi + bl) * tanphi) / ((phi - al) / tanphi - 1); + phi += dphi; + if (Math.abs(dphi) <= EPSLN) { + lat = phi; + break; + } + } + lon = adjust_lon_default(this.long0 + Math.asin(x * Math.tan(phi) / this.a) / Math.sin(lat)); + } + } else { + if (Math.abs(y + this.ml0) <= EPSLN) { + lat = 0; + lon = adjust_lon_default(this.long0 + x / this.a); + } else { + al = (this.ml0 + y) / this.a; + bl = x * x / this.a / this.a + al * al; + phi = al; + var cl, mln, mlnp, ma; + var con; + for (i = MAX_ITER3; i; --i) { + con = this.e * Math.sin(phi); + cl = Math.sqrt(1 - con * con) * Math.tan(phi); + mln = this.a * mlfn_default(this.e0, this.e1, this.e2, this.e3, phi); + mlnp = this.e0 - 2 * this.e1 * Math.cos(2 * phi) + 4 * this.e2 * Math.cos(4 * phi) - 6 * this.e3 * Math.cos(6 * phi); + ma = mln / this.a; + dphi = (al * (cl * ma + 1) - ma - 0.5 * cl * (ma * ma + bl)) / (this.es * Math.sin(2 * phi) * (ma * ma + bl - 2 * al * ma) / (4 * cl) + (al - ma) * (cl * mlnp - 2 / Math.sin(2 * phi)) - mlnp); + phi -= dphi; + if (Math.abs(dphi) <= EPSLN) { + lat = phi; + break; + } + } + cl = Math.sqrt(1 - this.es * Math.pow(Math.sin(lat), 2)) * Math.tan(lat); + lon = adjust_lon_default(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat)); + } + } + p.x = lon; + p.y = lat; + return p; +} +var names20 = ["Polyconic", "poly"]; +var poly_default = { + init: init19, + forward: forward18, + inverse: inverse18, + names: names20 +}; + +// node_modules/proj4/lib/projections/nzmg.js +function init20() { + this.A = []; + this.A[1] = 0.6399175073; + this.A[2] = -0.1358797613; + this.A[3] = 0.063294409; + this.A[4] = -0.02526853; + this.A[5] = 0.0117879; + this.A[6] = -55161e-7; + this.A[7] = 26906e-7; + this.A[8] = -1333e-6; + this.A[9] = 67e-5; + this.A[10] = -34e-5; + this.B_re = []; + this.B_im = []; + this.B_re[1] = 0.7557853228; + this.B_im[1] = 0; + this.B_re[2] = 0.249204646; + this.B_im[2] = 3371507e-9; + this.B_re[3] = -1541739e-9; + this.B_im[3] = 0.04105856; + this.B_re[4] = -0.10162907; + this.B_im[4] = 0.01727609; + this.B_re[5] = -0.26623489; + this.B_im[5] = -0.36249218; + this.B_re[6] = -0.6870983; + this.B_im[6] = -1.1651967; + this.C_re = []; + this.C_im = []; + this.C_re[1] = 1.3231270439; + this.C_im[1] = 0; + this.C_re[2] = -0.577245789; + this.C_im[2] = -7809598e-9; + this.C_re[3] = 0.508307513; + this.C_im[3] = -0.112208952; + this.C_re[4] = -0.15094762; + this.C_im[4] = 0.18200602; + this.C_re[5] = 1.01418179; + this.C_im[5] = 1.64497696; + this.C_re[6] = 1.9660549; + this.C_im[6] = 2.5127645; + this.D = []; + this.D[1] = 1.5627014243; + this.D[2] = 0.5185406398; + this.D[3] = -0.03333098; + this.D[4] = -0.1052906; + this.D[5] = -0.0368594; + this.D[6] = 7317e-6; + this.D[7] = 0.0122; + this.D[8] = 394e-5; + this.D[9] = -13e-4; +} +function forward19(p) { + var n; + var lon = p.x; + var lat = p.y; + var delta_lat = lat - this.lat0; + var delta_lon = lon - this.long0; + var d_phi = delta_lat / SEC_TO_RAD * 1e-5; + var d_lambda = delta_lon; + var d_phi_n = 1; + var d_psi = 0; + for (n = 1; n <= 10; n++) { + d_phi_n = d_phi_n * d_phi; + d_psi = d_psi + this.A[n] * d_phi_n; + } + var th_re = d_psi; + var th_im = d_lambda; + var th_n_re = 1; + var th_n_im = 0; + var th_n_re1; + var th_n_im1; + var z_re = 0; + var z_im = 0; + for (n = 1; n <= 6; n++) { + th_n_re1 = th_n_re * th_re - th_n_im * th_im; + th_n_im1 = th_n_im * th_re + th_n_re * th_im; + th_n_re = th_n_re1; + th_n_im = th_n_im1; + z_re = z_re + this.B_re[n] * th_n_re - this.B_im[n] * th_n_im; + z_im = z_im + this.B_im[n] * th_n_re + this.B_re[n] * th_n_im; + } + p.x = z_im * this.a + this.x0; + p.y = z_re * this.a + this.y0; + return p; +} +function inverse19(p) { + var n; + var x = p.x; + var y = p.y; + var delta_x = x - this.x0; + var delta_y = y - this.y0; + var z_re = delta_y / this.a; + var z_im = delta_x / this.a; + var z_n_re = 1; + var z_n_im = 0; + var z_n_re1; + var z_n_im1; + var th_re = 0; + var th_im = 0; + for (n = 1; n <= 6; n++) { + z_n_re1 = z_n_re * z_re - z_n_im * z_im; + z_n_im1 = z_n_im * z_re + z_n_re * z_im; + z_n_re = z_n_re1; + z_n_im = z_n_im1; + th_re = th_re + this.C_re[n] * z_n_re - this.C_im[n] * z_n_im; + th_im = th_im + this.C_im[n] * z_n_re + this.C_re[n] * z_n_im; + } + for (var i = 0; i < this.iterations; i++) { + var th_n_re = th_re; + var th_n_im = th_im; + var th_n_re1; + var th_n_im1; + var num_re = z_re; + var num_im = z_im; + for (n = 2; n <= 6; n++) { + th_n_re1 = th_n_re * th_re - th_n_im * th_im; + th_n_im1 = th_n_im * th_re + th_n_re * th_im; + th_n_re = th_n_re1; + th_n_im = th_n_im1; + num_re = num_re + (n - 1) * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im); + num_im = num_im + (n - 1) * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im); + } + th_n_re = 1; + th_n_im = 0; + var den_re = this.B_re[1]; + var den_im = this.B_im[1]; + for (n = 2; n <= 6; n++) { + th_n_re1 = th_n_re * th_re - th_n_im * th_im; + th_n_im1 = th_n_im * th_re + th_n_re * th_im; + th_n_re = th_n_re1; + th_n_im = th_n_im1; + den_re = den_re + n * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im); + den_im = den_im + n * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im); + } + var den2 = den_re * den_re + den_im * den_im; + th_re = (num_re * den_re + num_im * den_im) / den2; + th_im = (num_im * den_re - num_re * den_im) / den2; + } + var d_psi = th_re; + var d_lambda = th_im; + var d_psi_n = 1; + var d_phi = 0; + for (n = 1; n <= 9; n++) { + d_psi_n = d_psi_n * d_psi; + d_phi = d_phi + this.D[n] * d_psi_n; + } + var lat = this.lat0 + d_phi * SEC_TO_RAD * 1e5; + var lon = this.long0 + d_lambda; + p.x = lon; + p.y = lat; + return p; +} +var names21 = ["New_Zealand_Map_Grid", "nzmg"]; +var nzmg_default = { + init: init20, + forward: forward19, + inverse: inverse19, + names: names21 +}; + +// node_modules/proj4/lib/projections/mill.js +function init21() { +} +function forward20(p) { + var lon = p.x; + var lat = p.y; + var dlon = adjust_lon_default(lon - this.long0); + var x = this.x0 + this.a * dlon; + var y = this.y0 + this.a * Math.log(Math.tan(Math.PI / 4 + lat / 2.5)) * 1.25; + p.x = x; + p.y = y; + return p; +} +function inverse20(p) { + p.x -= this.x0; + p.y -= this.y0; + var lon = adjust_lon_default(this.long0 + p.x / this.a); + var lat = 2.5 * (Math.atan(Math.exp(0.8 * p.y / this.a)) - Math.PI / 4); + p.x = lon; + p.y = lat; + return p; +} +var names22 = ["Miller_Cylindrical", "mill"]; +var mill_default = { + init: init21, + forward: forward20, + inverse: inverse20, + names: names22 +}; + +// node_modules/proj4/lib/projections/sinu.js +var MAX_ITER4 = 20; +function init22() { + if (!this.sphere) { + this.en = pj_enfn_default(this.es); + } else { + this.n = 1; + this.m = 0; + this.es = 0; + this.C_y = Math.sqrt((this.m + 1) / this.n); + this.C_x = this.C_y / (this.m + 1); + } +} +function forward21(p) { + var x, y; + var lon = p.x; + var lat = p.y; + lon = adjust_lon_default(lon - this.long0); + if (this.sphere) { + if (!this.m) { + lat = this.n !== 1 ? Math.asin(this.n * Math.sin(lat)) : lat; + } else { + var k = this.n * Math.sin(lat); + for (var i = MAX_ITER4; i; --i) { + var V2 = (this.m * lat + Math.sin(lat) - k) / (this.m + Math.cos(lat)); + lat -= V2; + if (Math.abs(V2) < EPSLN) { + break; + } + } + } + x = this.a * this.C_x * lon * (this.m + Math.cos(lat)); + y = this.a * this.C_y * lat; + } else { + var s = Math.sin(lat); + var c = Math.cos(lat); + y = this.a * pj_mlfn_default(lat, s, c, this.en); + x = this.a * lon * c / Math.sqrt(1 - this.es * s * s); + } + p.x = x; + p.y = y; + return p; +} +function inverse21(p) { + var lat, temp, lon, s; + p.x -= this.x0; + lon = p.x / this.a; + p.y -= this.y0; + lat = p.y / this.a; + if (this.sphere) { + lat /= this.C_y; + lon = lon / (this.C_x * (this.m + Math.cos(lat))); + if (this.m) { + lat = asinz_default((this.m * lat + Math.sin(lat)) / this.n); + } else if (this.n !== 1) { + lat = asinz_default(Math.sin(lat) / this.n); + } + lon = adjust_lon_default(lon + this.long0); + lat = adjust_lat_default(lat); + } else { + lat = pj_inv_mlfn_default(p.y / this.a, this.es, this.en); + s = Math.abs(lat); + if (s < HALF_PI) { + s = Math.sin(lat); + temp = this.long0 + p.x * Math.sqrt(1 - this.es * s * s) / (this.a * Math.cos(lat)); + lon = adjust_lon_default(temp); + } else if (s - EPSLN < HALF_PI) { + lon = this.long0; + } + } + p.x = lon; + p.y = lat; + return p; +} +var names23 = ["Sinusoidal", "sinu"]; +var sinu_default = { + init: init22, + forward: forward21, + inverse: inverse21, + names: names23 +}; + +// node_modules/proj4/lib/projections/moll.js +function init23() { +} +function forward22(p) { + var lon = p.x; + var lat = p.y; + var delta_lon = adjust_lon_default(lon - this.long0); + var theta = lat; + var con = Math.PI * Math.sin(lat); + while (true) { + var delta_theta = -(theta + Math.sin(theta) - con) / (1 + Math.cos(theta)); + theta += delta_theta; + if (Math.abs(delta_theta) < EPSLN) { + break; + } + } + theta /= 2; + if (Math.PI / 2 - Math.abs(lat) < EPSLN) { + delta_lon = 0; + } + var x = 0.900316316158 * this.a * delta_lon * Math.cos(theta) + this.x0; + var y = 1.4142135623731 * this.a * Math.sin(theta) + this.y0; + p.x = x; + p.y = y; + return p; +} +function inverse22(p) { + var theta; + var arg; + p.x -= this.x0; + p.y -= this.y0; + arg = p.y / (1.4142135623731 * this.a); + if (Math.abs(arg) > 0.999999999999) { + arg = 0.999999999999; + } + theta = Math.asin(arg); + var lon = adjust_lon_default(this.long0 + p.x / (0.900316316158 * this.a * Math.cos(theta))); + if (lon < -Math.PI) { + lon = -Math.PI; + } + if (lon > Math.PI) { + lon = Math.PI; + } + arg = (2 * theta + Math.sin(2 * theta)) / Math.PI; + if (Math.abs(arg) > 1) { + arg = 1; + } + var lat = Math.asin(arg); + p.x = lon; + p.y = lat; + return p; +} +var names24 = ["Mollweide", "moll"]; +var moll_default = { + init: init23, + forward: forward22, + inverse: inverse22, + names: names24 +}; + +// node_modules/proj4/lib/projections/eqdc.js +function init24() { + if (Math.abs(this.lat1 + this.lat2) < EPSLN) { + return; + } + this.lat2 = this.lat2 || this.lat1; + this.temp = this.b / this.a; + this.es = 1 - Math.pow(this.temp, 2); + this.e = Math.sqrt(this.es); + this.e0 = e0fn_default(this.es); + this.e1 = e1fn_default(this.es); + this.e2 = e2fn_default(this.es); + this.e3 = e3fn_default(this.es); + this.sinphi = Math.sin(this.lat1); + this.cosphi = Math.cos(this.lat1); + this.ms1 = msfnz_default(this.e, this.sinphi, this.cosphi); + this.ml1 = mlfn_default(this.e0, this.e1, this.e2, this.e3, this.lat1); + if (Math.abs(this.lat1 - this.lat2) < EPSLN) { + this.ns = this.sinphi; + } else { + this.sinphi = Math.sin(this.lat2); + this.cosphi = Math.cos(this.lat2); + this.ms2 = msfnz_default(this.e, this.sinphi, this.cosphi); + this.ml2 = mlfn_default(this.e0, this.e1, this.e2, this.e3, this.lat2); + this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1); + } + this.g = this.ml1 + this.ms1 / this.ns; + this.ml0 = mlfn_default(this.e0, this.e1, this.e2, this.e3, this.lat0); + this.rh = this.a * (this.g - this.ml0); +} +function forward23(p) { + var lon = p.x; + var lat = p.y; + var rh1; + if (this.sphere) { + rh1 = this.a * (this.g - lat); + } else { + var ml = mlfn_default(this.e0, this.e1, this.e2, this.e3, lat); + rh1 = this.a * (this.g - ml); + } + var theta = this.ns * adjust_lon_default(lon - this.long0); + var x = this.x0 + rh1 * Math.sin(theta); + var y = this.y0 + this.rh - rh1 * Math.cos(theta); + p.x = x; + p.y = y; + return p; +} +function inverse23(p) { + p.x -= this.x0; + p.y = this.rh - p.y + this.y0; + var con, rh1, lat, lon; + if (this.ns >= 0) { + rh1 = Math.sqrt(p.x * p.x + p.y * p.y); + con = 1; + } else { + rh1 = -Math.sqrt(p.x * p.x + p.y * p.y); + con = -1; + } + var theta = 0; + if (rh1 !== 0) { + theta = Math.atan2(con * p.x, con * p.y); + } + if (this.sphere) { + lon = adjust_lon_default(this.long0 + theta / this.ns); + lat = adjust_lat_default(this.g - rh1 / this.a); + p.x = lon; + p.y = lat; + return p; + } else { + var ml = this.g - rh1 / this.a; + lat = imlfn_default(ml, this.e0, this.e1, this.e2, this.e3); + lon = adjust_lon_default(this.long0 + theta / this.ns); + p.x = lon; + p.y = lat; + return p; + } +} +var names25 = ["Equidistant_Conic", "eqdc"]; +var eqdc_default = { + init: init24, + forward: forward23, + inverse: inverse23, + names: names25 +}; + +// node_modules/proj4/lib/projections/vandg.js +function init25() { + this.R = this.a; +} +function forward24(p) { + var lon = p.x; + var lat = p.y; + var dlon = adjust_lon_default(lon - this.long0); + var x, y; + if (Math.abs(lat) <= EPSLN) { + x = this.x0 + this.R * dlon; + y = this.y0; + } + var theta = asinz_default(2 * Math.abs(lat / Math.PI)); + if (Math.abs(dlon) <= EPSLN || Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) { + x = this.x0; + if (lat >= 0) { + y = this.y0 + Math.PI * this.R * Math.tan(0.5 * theta); + } else { + y = this.y0 + Math.PI * this.R * -Math.tan(0.5 * theta); + } + } + var al = 0.5 * Math.abs(Math.PI / dlon - dlon / Math.PI); + var asq = al * al; + var sinth = Math.sin(theta); + var costh = Math.cos(theta); + var g = costh / (sinth + costh - 1); + var gsq = g * g; + var m = g * (2 / sinth - 1); + var msq = m * m; + var con = Math.PI * this.R * (al * (g - msq) + Math.sqrt(asq * (g - msq) * (g - msq) - (msq + asq) * (gsq - msq))) / (msq + asq); + if (dlon < 0) { + con = -con; + } + x = this.x0 + con; + var q = asq + g; + con = Math.PI * this.R * (m * q - al * Math.sqrt((msq + asq) * (asq + 1) - q * q)) / (msq + asq); + if (lat >= 0) { + y = this.y0 + con; + } else { + y = this.y0 - con; + } + p.x = x; + p.y = y; + return p; +} +function inverse24(p) { + var lon, lat; + var xx, yy, xys, c1, c2, c3; + var a1; + var m1; + var con; + var th1; + var d; + p.x -= this.x0; + p.y -= this.y0; + con = Math.PI * this.R; + xx = p.x / con; + yy = p.y / con; + xys = xx * xx + yy * yy; + c1 = -Math.abs(yy) * (1 + xys); + c2 = c1 - 2 * yy * yy + xx * xx; + c3 = -2 * c1 + 1 + 2 * yy * yy + xys * xys; + d = yy * yy / c3 + (2 * c2 * c2 * c2 / c3 / c3 / c3 - 9 * c1 * c2 / c3 / c3) / 27; + a1 = (c1 - c2 * c2 / 3 / c3) / c3; + m1 = 2 * Math.sqrt(-a1 / 3); + con = 3 * d / a1 / m1; + if (Math.abs(con) > 1) { + if (con >= 0) { + con = 1; + } else { + con = -1; + } + } + th1 = Math.acos(con) / 3; + if (p.y >= 0) { + lat = (-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI; + } else { + lat = -(-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI; + } + if (Math.abs(xx) < EPSLN) { + lon = this.long0; + } else { + lon = adjust_lon_default(this.long0 + Math.PI * (xys - 1 + Math.sqrt(1 + 2 * (xx * xx - yy * yy) + xys * xys)) / 2 / xx); + } + p.x = lon; + p.y = lat; + return p; +} +var names26 = ["Van_der_Grinten_I", "VanDerGrinten", "vandg"]; +var vandg_default = { + init: init25, + forward: forward24, + inverse: inverse24, + names: names26 +}; + +// node_modules/proj4/lib/projections/aeqd.js +function init26() { + this.sin_p12 = Math.sin(this.lat0); + this.cos_p12 = Math.cos(this.lat0); +} +function forward25(p) { + var lon = p.x; + var lat = p.y; + var sinphi = Math.sin(p.y); + var cosphi = Math.cos(p.y); + var dlon = adjust_lon_default(lon - this.long0); + var e0, e1, e2, e3, Mlp, Ml, tanphi, Nl1, Nl, psi, Az, G, H, GH, Hs, c, kp, cos_c, s, s2, s3, s4, s5; + if (this.sphere) { + if (Math.abs(this.sin_p12 - 1) <= EPSLN) { + p.x = this.x0 + this.a * (HALF_PI - lat) * Math.sin(dlon); + p.y = this.y0 - this.a * (HALF_PI - lat) * Math.cos(dlon); + return p; + } else if (Math.abs(this.sin_p12 + 1) <= EPSLN) { + p.x = this.x0 + this.a * (HALF_PI + lat) * Math.sin(dlon); + p.y = this.y0 + this.a * (HALF_PI + lat) * Math.cos(dlon); + return p; + } else { + cos_c = this.sin_p12 * sinphi + this.cos_p12 * cosphi * Math.cos(dlon); + c = Math.acos(cos_c); + kp = c ? c / Math.sin(c) : 1; + p.x = this.x0 + this.a * kp * cosphi * Math.sin(dlon); + p.y = this.y0 + this.a * kp * (this.cos_p12 * sinphi - this.sin_p12 * cosphi * Math.cos(dlon)); + return p; + } + } else { + e0 = e0fn_default(this.es); + e1 = e1fn_default(this.es); + e2 = e2fn_default(this.es); + e3 = e3fn_default(this.es); + if (Math.abs(this.sin_p12 - 1) <= EPSLN) { + Mlp = this.a * mlfn_default(e0, e1, e2, e3, HALF_PI); + Ml = this.a * mlfn_default(e0, e1, e2, e3, lat); + p.x = this.x0 + (Mlp - Ml) * Math.sin(dlon); + p.y = this.y0 - (Mlp - Ml) * Math.cos(dlon); + return p; + } else if (Math.abs(this.sin_p12 + 1) <= EPSLN) { + Mlp = this.a * mlfn_default(e0, e1, e2, e3, HALF_PI); + Ml = this.a * mlfn_default(e0, e1, e2, e3, lat); + p.x = this.x0 + (Mlp + Ml) * Math.sin(dlon); + p.y = this.y0 + (Mlp + Ml) * Math.cos(dlon); + return p; + } else { + tanphi = sinphi / cosphi; + Nl1 = gN_default(this.a, this.e, this.sin_p12); + Nl = gN_default(this.a, this.e, sinphi); + psi = Math.atan((1 - this.es) * tanphi + this.es * Nl1 * this.sin_p12 / (Nl * cosphi)); + Az = Math.atan2(Math.sin(dlon), this.cos_p12 * Math.tan(psi) - this.sin_p12 * Math.cos(dlon)); + if (Az === 0) { + s = Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi)); + } else if (Math.abs(Math.abs(Az) - Math.PI) <= EPSLN) { + s = -Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi)); + } else { + s = Math.asin(Math.sin(dlon) * Math.cos(psi) / Math.sin(Az)); + } + G = this.e * this.sin_p12 / Math.sqrt(1 - this.es); + H = this.e * this.cos_p12 * Math.cos(Az) / Math.sqrt(1 - this.es); + GH = G * H; + Hs = H * H; + s2 = s * s; + s3 = s2 * s; + s4 = s3 * s; + s5 = s4 * s; + c = Nl1 * s * (1 - s2 * Hs * (1 - Hs) / 6 + s3 / 8 * GH * (1 - 2 * Hs) + s4 / 120 * (Hs * (4 - 7 * Hs) - 3 * G * G * (1 - 7 * Hs)) - s5 / 48 * GH); + p.x = this.x0 + c * Math.sin(Az); + p.y = this.y0 + c * Math.cos(Az); + return p; + } + } +} +function inverse25(p) { + p.x -= this.x0; + p.y -= this.y0; + var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, N1, psi, Az, cosAz, tmp, A2, B, D, Ee, F, sinpsi; + if (this.sphere) { + rh = Math.sqrt(p.x * p.x + p.y * p.y); + if (rh > 2 * HALF_PI * this.a) { + return; + } + z = rh / this.a; + sinz = Math.sin(z); + cosz = Math.cos(z); + lon = this.long0; + if (Math.abs(rh) <= EPSLN) { + lat = this.lat0; + } else { + lat = asinz_default(cosz * this.sin_p12 + p.y * sinz * this.cos_p12 / rh); + con = Math.abs(this.lat0) - HALF_PI; + if (Math.abs(con) <= EPSLN) { + if (this.lat0 >= 0) { + lon = adjust_lon_default(this.long0 + Math.atan2(p.x, -p.y)); + } else { + lon = adjust_lon_default(this.long0 - Math.atan2(-p.x, p.y)); + } + } else { + lon = adjust_lon_default(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz)); + } + } + p.x = lon; + p.y = lat; + return p; + } else { + e0 = e0fn_default(this.es); + e1 = e1fn_default(this.es); + e2 = e2fn_default(this.es); + e3 = e3fn_default(this.es); + if (Math.abs(this.sin_p12 - 1) <= EPSLN) { + Mlp = this.a * mlfn_default(e0, e1, e2, e3, HALF_PI); + rh = Math.sqrt(p.x * p.x + p.y * p.y); + M = Mlp - rh; + lat = imlfn_default(M / this.a, e0, e1, e2, e3); + lon = adjust_lon_default(this.long0 + Math.atan2(p.x, -1 * p.y)); + p.x = lon; + p.y = lat; + return p; + } else if (Math.abs(this.sin_p12 + 1) <= EPSLN) { + Mlp = this.a * mlfn_default(e0, e1, e2, e3, HALF_PI); + rh = Math.sqrt(p.x * p.x + p.y * p.y); + M = rh - Mlp; + lat = imlfn_default(M / this.a, e0, e1, e2, e3); + lon = adjust_lon_default(this.long0 + Math.atan2(p.x, p.y)); + p.x = lon; + p.y = lat; + return p; + } else { + rh = Math.sqrt(p.x * p.x + p.y * p.y); + Az = Math.atan2(p.x, p.y); + N1 = gN_default(this.a, this.e, this.sin_p12); + cosAz = Math.cos(Az); + tmp = this.e * this.cos_p12 * cosAz; + A2 = -tmp * tmp / (1 - this.es); + B = 3 * this.es * (1 - A2) * this.sin_p12 * this.cos_p12 * cosAz / (1 - this.es); + D = rh / N1; + Ee = D - A2 * (1 + A2) * Math.pow(D, 3) / 6 - B * (1 + 3 * A2) * Math.pow(D, 4) / 24; + F = 1 - A2 * Ee * Ee / 2 - D * Ee * Ee * Ee / 6; + psi = Math.asin(this.sin_p12 * Math.cos(Ee) + this.cos_p12 * Math.sin(Ee) * cosAz); + lon = adjust_lon_default(this.long0 + Math.asin(Math.sin(Az) * Math.sin(Ee) / Math.cos(psi))); + sinpsi = Math.sin(psi); + lat = Math.atan2((sinpsi - this.es * F * this.sin_p12) * Math.tan(psi), sinpsi * (1 - this.es)); + p.x = lon; + p.y = lat; + return p; + } + } +} +var names27 = ["Azimuthal_Equidistant", "aeqd"]; +var aeqd_default = { + init: init26, + forward: forward25, + inverse: inverse25, + names: names27 +}; + +// node_modules/proj4/lib/projections/ortho.js +function init27() { + this.sin_p14 = Math.sin(this.lat0); + this.cos_p14 = Math.cos(this.lat0); +} +function forward26(p) { + var sinphi, cosphi; + var dlon; + var coslon; + var ksp; + var g, x, y; + var lon = p.x; + var lat = p.y; + dlon = adjust_lon_default(lon - this.long0); + sinphi = Math.sin(lat); + cosphi = Math.cos(lat); + coslon = Math.cos(dlon); + g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon; + ksp = 1; + if (g > 0 || Math.abs(g) <= EPSLN) { + x = this.a * ksp * cosphi * Math.sin(dlon); + y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon); + } + p.x = x; + p.y = y; + return p; +} +function inverse26(p) { + var rh; + var z; + var sinz, cosz; + var con; + var lon, lat; + p.x -= this.x0; + p.y -= this.y0; + rh = Math.sqrt(p.x * p.x + p.y * p.y); + z = asinz_default(rh / this.a); + sinz = Math.sin(z); + cosz = Math.cos(z); + lon = this.long0; + if (Math.abs(rh) <= EPSLN) { + lat = this.lat0; + p.x = lon; + p.y = lat; + return p; + } + lat = asinz_default(cosz * this.sin_p14 + p.y * sinz * this.cos_p14 / rh); + con = Math.abs(this.lat0) - HALF_PI; + if (Math.abs(con) <= EPSLN) { + if (this.lat0 >= 0) { + lon = adjust_lon_default(this.long0 + Math.atan2(p.x, -p.y)); + } else { + lon = adjust_lon_default(this.long0 - Math.atan2(-p.x, p.y)); + } + p.x = lon; + p.y = lat; + return p; + } + lon = adjust_lon_default(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p14 * cosz - p.y * this.sin_p14 * sinz)); + p.x = lon; + p.y = lat; + return p; +} +var names28 = ["ortho"]; +var ortho_default = { + init: init27, + forward: forward26, + inverse: inverse26, + names: names28 +}; + +// node_modules/proj4/lib/projections/qsc.js +var FACE_ENUM = { + FRONT: 1, + RIGHT: 2, + BACK: 3, + LEFT: 4, + TOP: 5, + BOTTOM: 6 +}; +var AREA_ENUM = { + AREA_0: 1, + AREA_1: 2, + AREA_2: 3, + AREA_3: 4 +}; +function init28() { + this.x0 = this.x0 || 0; + this.y0 = this.y0 || 0; + this.lat0 = this.lat0 || 0; + this.long0 = this.long0 || 0; + this.lat_ts = this.lat_ts || 0; + this.title = this.title || "Quadrilateralized Spherical Cube"; + if (this.lat0 >= HALF_PI - FORTPI / 2) { + this.face = FACE_ENUM.TOP; + } else if (this.lat0 <= -(HALF_PI - FORTPI / 2)) { + this.face = FACE_ENUM.BOTTOM; + } else if (Math.abs(this.long0) <= FORTPI) { + this.face = FACE_ENUM.FRONT; + } else if (Math.abs(this.long0) <= HALF_PI + FORTPI) { + this.face = this.long0 > 0 ? FACE_ENUM.RIGHT : FACE_ENUM.LEFT; + } else { + this.face = FACE_ENUM.BACK; + } + if (this.es !== 0) { + this.one_minus_f = 1 - (this.a - this.b) / this.a; + this.one_minus_f_squared = this.one_minus_f * this.one_minus_f; + } +} +function forward27(p) { + var xy = { x: 0, y: 0 }; + var lat, lon; + var theta, phi; + var t, mu; + var area = { value: 0 }; + p.x -= this.long0; + if (this.es !== 0) { + lat = Math.atan(this.one_minus_f_squared * Math.tan(p.y)); + } else { + lat = p.y; + } + lon = p.x; + if (this.face === FACE_ENUM.TOP) { + phi = HALF_PI - lat; + if (lon >= FORTPI && lon <= HALF_PI + FORTPI) { + area.value = AREA_ENUM.AREA_0; + theta = lon - HALF_PI; + } else if (lon > HALF_PI + FORTPI || lon <= -(HALF_PI + FORTPI)) { + area.value = AREA_ENUM.AREA_1; + theta = lon > 0 ? lon - SPI : lon + SPI; + } else if (lon > -(HALF_PI + FORTPI) && lon <= -FORTPI) { + area.value = AREA_ENUM.AREA_2; + theta = lon + HALF_PI; + } else { + area.value = AREA_ENUM.AREA_3; + theta = lon; + } + } else if (this.face === FACE_ENUM.BOTTOM) { + phi = HALF_PI + lat; + if (lon >= FORTPI && lon <= HALF_PI + FORTPI) { + area.value = AREA_ENUM.AREA_0; + theta = -lon + HALF_PI; + } else if (lon < FORTPI && lon >= -FORTPI) { + area.value = AREA_ENUM.AREA_1; + theta = -lon; + } else if (lon < -FORTPI && lon >= -(HALF_PI + FORTPI)) { + area.value = AREA_ENUM.AREA_2; + theta = -lon - HALF_PI; + } else { + area.value = AREA_ENUM.AREA_3; + theta = lon > 0 ? -lon + SPI : -lon - SPI; + } + } else { + var q, r, s; + var sinlat, coslat; + var sinlon, coslon; + if (this.face === FACE_ENUM.RIGHT) { + lon = qsc_shift_lon_origin(lon, +HALF_PI); + } else if (this.face === FACE_ENUM.BACK) { + lon = qsc_shift_lon_origin(lon, +SPI); + } else if (this.face === FACE_ENUM.LEFT) { + lon = qsc_shift_lon_origin(lon, -HALF_PI); + } + sinlat = Math.sin(lat); + coslat = Math.cos(lat); + sinlon = Math.sin(lon); + coslon = Math.cos(lon); + q = coslat * coslon; + r = coslat * sinlon; + s = sinlat; + if (this.face === FACE_ENUM.FRONT) { + phi = Math.acos(q); + theta = qsc_fwd_equat_face_theta(phi, s, r, area); + } else if (this.face === FACE_ENUM.RIGHT) { + phi = Math.acos(r); + theta = qsc_fwd_equat_face_theta(phi, s, -q, area); + } else if (this.face === FACE_ENUM.BACK) { + phi = Math.acos(-q); + theta = qsc_fwd_equat_face_theta(phi, s, -r, area); + } else if (this.face === FACE_ENUM.LEFT) { + phi = Math.acos(-r); + theta = qsc_fwd_equat_face_theta(phi, s, q, area); + } else { + phi = theta = 0; + area.value = AREA_ENUM.AREA_0; + } + } + mu = Math.atan(12 / SPI * (theta + Math.acos(Math.sin(theta) * Math.cos(FORTPI)) - HALF_PI)); + t = Math.sqrt((1 - Math.cos(phi)) / (Math.cos(mu) * Math.cos(mu)) / (1 - Math.cos(Math.atan(1 / Math.cos(theta))))); + if (area.value === AREA_ENUM.AREA_1) { + mu += HALF_PI; + } else if (area.value === AREA_ENUM.AREA_2) { + mu += SPI; + } else if (area.value === AREA_ENUM.AREA_3) { + mu += 1.5 * SPI; + } + xy.x = t * Math.cos(mu); + xy.y = t * Math.sin(mu); + xy.x = xy.x * this.a + this.x0; + xy.y = xy.y * this.a + this.y0; + p.x = xy.x; + p.y = xy.y; + return p; +} +function inverse27(p) { + var lp = { lam: 0, phi: 0 }; + var mu, nu, cosmu, tannu; + var tantheta, theta, cosphi, phi; + var t; + var area = { value: 0 }; + p.x = (p.x - this.x0) / this.a; + p.y = (p.y - this.y0) / this.a; + nu = Math.atan(Math.sqrt(p.x * p.x + p.y * p.y)); + mu = Math.atan2(p.y, p.x); + if (p.x >= 0 && p.x >= Math.abs(p.y)) { + area.value = AREA_ENUM.AREA_0; + } else if (p.y >= 0 && p.y >= Math.abs(p.x)) { + area.value = AREA_ENUM.AREA_1; + mu -= HALF_PI; + } else if (p.x < 0 && -p.x >= Math.abs(p.y)) { + area.value = AREA_ENUM.AREA_2; + mu = mu < 0 ? mu + SPI : mu - SPI; + } else { + area.value = AREA_ENUM.AREA_3; + mu += HALF_PI; + } + t = SPI / 12 * Math.tan(mu); + tantheta = Math.sin(t) / (Math.cos(t) - 1 / Math.sqrt(2)); + theta = Math.atan(tantheta); + cosmu = Math.cos(mu); + tannu = Math.tan(nu); + cosphi = 1 - cosmu * cosmu * tannu * tannu * (1 - Math.cos(Math.atan(1 / Math.cos(theta)))); + if (cosphi < -1) { + cosphi = -1; + } else if (cosphi > 1) { + cosphi = 1; + } + if (this.face === FACE_ENUM.TOP) { + phi = Math.acos(cosphi); + lp.phi = HALF_PI - phi; + if (area.value === AREA_ENUM.AREA_0) { + lp.lam = theta + HALF_PI; + } else if (area.value === AREA_ENUM.AREA_1) { + lp.lam = theta < 0 ? theta + SPI : theta - SPI; + } else if (area.value === AREA_ENUM.AREA_2) { + lp.lam = theta - HALF_PI; + } else { + lp.lam = theta; + } + } else if (this.face === FACE_ENUM.BOTTOM) { + phi = Math.acos(cosphi); + lp.phi = phi - HALF_PI; + if (area.value === AREA_ENUM.AREA_0) { + lp.lam = -theta + HALF_PI; + } else if (area.value === AREA_ENUM.AREA_1) { + lp.lam = -theta; + } else if (area.value === AREA_ENUM.AREA_2) { + lp.lam = -theta - HALF_PI; + } else { + lp.lam = theta < 0 ? -theta - SPI : -theta + SPI; + } + } else { + var q, r, s; + q = cosphi; + t = q * q; + if (t >= 1) { + s = 0; + } else { + s = Math.sqrt(1 - t) * Math.sin(theta); + } + t += s * s; + if (t >= 1) { + r = 0; + } else { + r = Math.sqrt(1 - t); + } + if (area.value === AREA_ENUM.AREA_1) { + t = r; + r = -s; + s = t; + } else if (area.value === AREA_ENUM.AREA_2) { + r = -r; + s = -s; + } else if (area.value === AREA_ENUM.AREA_3) { + t = r; + r = s; + s = -t; + } + if (this.face === FACE_ENUM.RIGHT) { + t = q; + q = -r; + r = t; + } else if (this.face === FACE_ENUM.BACK) { + q = -q; + r = -r; + } else if (this.face === FACE_ENUM.LEFT) { + t = q; + q = r; + r = -t; + } + lp.phi = Math.acos(-s) - HALF_PI; + lp.lam = Math.atan2(r, q); + if (this.face === FACE_ENUM.RIGHT) { + lp.lam = qsc_shift_lon_origin(lp.lam, -HALF_PI); + } else if (this.face === FACE_ENUM.BACK) { + lp.lam = qsc_shift_lon_origin(lp.lam, -SPI); + } else if (this.face === FACE_ENUM.LEFT) { + lp.lam = qsc_shift_lon_origin(lp.lam, +HALF_PI); + } + } + if (this.es !== 0) { + var invert_sign; + var tanphi, xa; + invert_sign = lp.phi < 0 ? 1 : 0; + tanphi = Math.tan(lp.phi); + xa = this.b / Math.sqrt(tanphi * tanphi + this.one_minus_f_squared); + lp.phi = Math.atan(Math.sqrt(this.a * this.a - xa * xa) / (this.one_minus_f * xa)); + if (invert_sign) { + lp.phi = -lp.phi; + } + } + lp.lam += this.long0; + p.x = lp.lam; + p.y = lp.phi; + return p; +} +function qsc_fwd_equat_face_theta(phi, y, x, area) { + var theta; + if (phi < EPSLN) { + area.value = AREA_ENUM.AREA_0; + theta = 0; + } else { + theta = Math.atan2(y, x); + if (Math.abs(theta) <= FORTPI) { + area.value = AREA_ENUM.AREA_0; + } else if (theta > FORTPI && theta <= HALF_PI + FORTPI) { + area.value = AREA_ENUM.AREA_1; + theta -= HALF_PI; + } else if (theta > HALF_PI + FORTPI || theta <= -(HALF_PI + FORTPI)) { + area.value = AREA_ENUM.AREA_2; + theta = theta >= 0 ? theta - SPI : theta + SPI; + } else { + area.value = AREA_ENUM.AREA_3; + theta += HALF_PI; + } + } + return theta; +} +function qsc_shift_lon_origin(lon, offset) { + var slon = lon + offset; + if (slon < -SPI) { + slon += TWO_PI; + } else if (slon > +SPI) { + slon -= TWO_PI; + } + return slon; +} +var names29 = ["Quadrilateralized Spherical Cube", "Quadrilateralized_Spherical_Cube", "qsc"]; +var qsc_default = { + init: init28, + forward: forward27, + inverse: inverse27, + names: names29 +}; + +// node_modules/proj4/lib/projections/robin.js +var COEFS_X = [ + [1, 22199e-21, -715515e-10, 31103e-10], + [0.9986, -482243e-9, -24897e-9, -13309e-10], + [0.9954, -83103e-8, -448605e-10, -986701e-12], + [0.99, -135364e-8, -59661e-9, 36777e-10], + [0.9822, -167442e-8, -449547e-11, -572411e-11], + [0.973, -214868e-8, -903571e-10, 18736e-12], + [0.96, -305085e-8, -900761e-10, 164917e-11], + [0.9427, -382792e-8, -653386e-10, -26154e-10], + [0.9216, -467746e-8, -10457e-8, 481243e-11], + [0.8962, -536223e-8, -323831e-10, -543432e-11], + [0.8679, -609363e-8, -113898e-9, 332484e-11], + [0.835, -698325e-8, -640253e-10, 934959e-12], + [0.7986, -755338e-8, -500009e-10, 935324e-12], + [0.7597, -798324e-8, -35971e-9, -227626e-11], + [0.7186, -851367e-8, -701149e-10, -86303e-10], + [0.6732, -986209e-8, -199569e-9, 191974e-10], + [0.6213, -0.010418, 883923e-10, 624051e-11], + [0.5722, -906601e-8, 182e-6, 624051e-11], + [0.5322, -677797e-8, 275608e-9, 624051e-11] +]; +var COEFS_Y = [ + [-520417e-23, 0.0124, 121431e-23, -845284e-16], + [0.062, 0.0124, -126793e-14, 422642e-15], + [0.124, 0.0124, 507171e-14, -160604e-14], + [0.186, 0.0123999, -190189e-13, 600152e-14], + [0.248, 0.0124002, 710039e-13, -224e-10], + [0.31, 0.0123992, -264997e-12, 835986e-13], + [0.372, 0.0124029, 988983e-12, -311994e-12], + [0.434, 0.0123893, -369093e-11, -435621e-12], + [0.4958, 0.0123198, -102252e-10, -345523e-12], + [0.5571, 0.0121916, -154081e-10, -582288e-12], + [0.6176, 0.0119938, -241424e-10, -525327e-12], + [0.6769, 0.011713, -320223e-10, -516405e-12], + [0.7346, 0.0113541, -397684e-10, -609052e-12], + [0.7903, 0.0109107, -489042e-10, -104739e-11], + [0.8435, 0.0103431, -64615e-9, -140374e-14], + [0.8936, 969686e-8, -64636e-9, -8547e-9], + [0.9394, 840947e-8, -192841e-9, -42106e-10], + [0.9761, 616527e-8, -256e-6, -42106e-10], + [1, 328947e-8, -319159e-9, -42106e-10] +]; +var FXC = 0.8487; +var FYC = 1.3523; +var C1 = R2D / 5; +var RC1 = 1 / C1; +var NODES = 18; +var poly3_val = function(coefs, x) { + return coefs[0] + x * (coefs[1] + x * (coefs[2] + x * coefs[3])); +}; +var poly3_der = function(coefs, x) { + return coefs[1] + x * (2 * coefs[2] + x * 3 * coefs[3]); +}; +function newton_rapshon(f_df, start2, max_err, iters) { + var x = start2; + for (; iters; --iters) { + var upd = f_df(x); + x -= upd; + if (Math.abs(upd) < max_err) { + break; + } + } + return x; +} +function init29() { + this.x0 = this.x0 || 0; + this.y0 = this.y0 || 0; + this.long0 = this.long0 || 0; + this.es = 0; + this.title = this.title || "Robinson"; +} +function forward28(ll) { + var lon = adjust_lon_default(ll.x - this.long0); + var dphi = Math.abs(ll.y); + var i = Math.floor(dphi * C1); + if (i < 0) { + i = 0; + } else if (i >= NODES) { + i = NODES - 1; + } + dphi = R2D * (dphi - RC1 * i); + var xy = { + x: poly3_val(COEFS_X[i], dphi) * lon, + y: poly3_val(COEFS_Y[i], dphi) + }; + if (ll.y < 0) { + xy.y = -xy.y; + } + xy.x = xy.x * this.a * FXC + this.x0; + xy.y = xy.y * this.a * FYC + this.y0; + return xy; +} +function inverse28(xy) { + var ll = { + x: (xy.x - this.x0) / (this.a * FXC), + y: Math.abs(xy.y - this.y0) / (this.a * FYC) + }; + if (ll.y >= 1) { + ll.x /= COEFS_X[NODES][0]; + ll.y = xy.y < 0 ? -HALF_PI : HALF_PI; + } else { + var i = Math.floor(ll.y * NODES); + if (i < 0) { + i = 0; + } else if (i >= NODES) { + i = NODES - 1; + } + for (; ; ) { + if (COEFS_Y[i][0] > ll.y) { + --i; + } else if (COEFS_Y[i + 1][0] <= ll.y) { + ++i; + } else { + break; + } + } + var coefs = COEFS_Y[i]; + var t = 5 * (ll.y - coefs[0]) / (COEFS_Y[i + 1][0] - coefs[0]); + t = newton_rapshon(function(x) { + return (poly3_val(coefs, x) - ll.y) / poly3_der(coefs, x); + }, t, EPSLN, 100); + ll.x /= poly3_val(COEFS_X[i], t); + ll.y = (5 * i + t) * D2R; + if (xy.y < 0) { + ll.y = -ll.y; + } + } + ll.x = adjust_lon_default(ll.x + this.long0); + return ll; +} +var names30 = ["Robinson", "robin"]; +var robin_default = { + init: init29, + forward: forward28, + inverse: inverse28, + names: names30 +}; + +// node_modules/proj4/lib/projections/geocent.js +function init30() { + this.name = "geocent"; +} +function forward29(p) { + var point = geodeticToGeocentric(p, this.es, this.a); + return point; +} +function inverse29(p) { + var point = geocentricToGeodetic(p, this.es, this.a, this.b); + return point; +} +var names31 = ["Geocentric", "geocentric", "geocent", "Geocent"]; +var geocent_default = { + init: init30, + forward: forward29, + inverse: inverse29, + names: names31 +}; + +// node_modules/proj4/lib/projections/tpers.js +var mode = { + N_POLE: 0, + S_POLE: 1, + EQUIT: 2, + OBLIQ: 3 +}; +var params = { + h: { def: 1e5, num: true }, + // default is Karman line, no default in PROJ.7 + azi: { def: 0, num: true, degrees: true }, + // default is North + tilt: { def: 0, num: true, degrees: true }, + // default is Nadir + long0: { def: 0, num: true }, + // default is Greenwich, conversion to rad is automatic + lat0: { def: 0, num: true } + // default is Equator, conversion to rad is automatic +}; +function init31() { + Object.keys(params).forEach((function(p) { + if (typeof this[p] === "undefined") { + this[p] = params[p].def; + } else if (params[p].num && isNaN(this[p])) { + throw new Error("Invalid parameter value, must be numeric " + p + " = " + this[p]); + } else if (params[p].num) { + this[p] = parseFloat(this[p]); + } + if (params[p].degrees) { + this[p] = this[p] * D2R; + } + }).bind(this)); + if (Math.abs(Math.abs(this.lat0) - HALF_PI) < EPSLN) { + this.mode = this.lat0 < 0 ? mode.S_POLE : mode.N_POLE; + } else if (Math.abs(this.lat0) < EPSLN) { + this.mode = mode.EQUIT; + } else { + this.mode = mode.OBLIQ; + this.sinph0 = Math.sin(this.lat0); + this.cosph0 = Math.cos(this.lat0); + } + this.pn1 = this.h / this.a; + if (this.pn1 <= 0 || this.pn1 > 1e10) { + throw new Error("Invalid height"); + } + this.p = 1 + this.pn1; + this.rp = 1 / this.p; + this.h1 = 1 / this.pn1; + this.pfact = (this.p + 1) * this.h1; + this.es = 0; + var omega = this.tilt; + var gamma = this.azi; + this.cg = Math.cos(gamma); + this.sg = Math.sin(gamma); + this.cw = Math.cos(omega); + this.sw = Math.sin(omega); +} +function forward30(p) { + p.x -= this.long0; + var sinphi = Math.sin(p.y); + var cosphi = Math.cos(p.y); + var coslam = Math.cos(p.x); + var x, y; + switch (this.mode) { + case mode.OBLIQ: + y = this.sinph0 * sinphi + this.cosph0 * cosphi * coslam; + break; + case mode.EQUIT: + y = cosphi * coslam; + break; + case mode.S_POLE: + y = -sinphi; + break; + case mode.N_POLE: + y = sinphi; + break; + } + y = this.pn1 / (this.p - y); + x = y * cosphi * Math.sin(p.x); + switch (this.mode) { + case mode.OBLIQ: + y *= this.cosph0 * sinphi - this.sinph0 * cosphi * coslam; + break; + case mode.EQUIT: + y *= sinphi; + break; + case mode.N_POLE: + y *= -(cosphi * coslam); + break; + case mode.S_POLE: + y *= cosphi * coslam; + break; + } + var yt, ba; + yt = y * this.cg + x * this.sg; + ba = 1 / (yt * this.sw * this.h1 + this.cw); + x = (x * this.cg - y * this.sg) * this.cw * ba; + y = yt * ba; + p.x = x * this.a; + p.y = y * this.a; + return p; +} +function inverse30(p) { + p.x /= this.a; + p.y /= this.a; + var r = { x: p.x, y: p.y }; + var bm, bq, yt; + yt = 1 / (this.pn1 - p.y * this.sw); + bm = this.pn1 * p.x * yt; + bq = this.pn1 * p.y * this.cw * yt; + p.x = bm * this.cg + bq * this.sg; + p.y = bq * this.cg - bm * this.sg; + var rh = hypot_default(p.x, p.y); + if (Math.abs(rh) < EPSLN) { + r.x = 0; + r.y = p.y; + } else { + var cosz, sinz; + sinz = 1 - rh * rh * this.pfact; + sinz = (this.p - Math.sqrt(sinz)) / (this.pn1 / rh + rh / this.pn1); + cosz = Math.sqrt(1 - sinz * sinz); + switch (this.mode) { + case mode.OBLIQ: + r.y = Math.asin(cosz * this.sinph0 + p.y * sinz * this.cosph0 / rh); + p.y = (cosz - this.sinph0 * Math.sin(r.y)) * rh; + p.x *= sinz * this.cosph0; + break; + case mode.EQUIT: + r.y = Math.asin(p.y * sinz / rh); + p.y = cosz * rh; + p.x *= sinz; + break; + case mode.N_POLE: + r.y = Math.asin(cosz); + p.y = -p.y; + break; + case mode.S_POLE: + r.y = -Math.asin(cosz); + break; + } + r.x = Math.atan2(p.x, p.y); + } + p.x = r.x + this.long0; + p.y = r.y; + return p; +} +var names32 = ["Tilted_Perspective", "tpers"]; +var tpers_default = { + init: init31, + forward: forward30, + inverse: inverse30, + names: names32 +}; + +// node_modules/proj4/lib/projections/geos.js +function init32() { + this.flip_axis = this.sweep === "x" ? 1 : 0; + this.h = Number(this.h); + this.radius_g_1 = this.h / this.a; + if (this.radius_g_1 <= 0 || this.radius_g_1 > 1e10) { + throw new Error(); + } + this.radius_g = 1 + this.radius_g_1; + this.C = this.radius_g * this.radius_g - 1; + if (this.es !== 0) { + var one_es = 1 - this.es; + var rone_es = 1 / one_es; + this.radius_p = Math.sqrt(one_es); + this.radius_p2 = one_es; + this.radius_p_inv2 = rone_es; + this.shape = "ellipse"; + } else { + this.radius_p = 1; + this.radius_p2 = 1; + this.radius_p_inv2 = 1; + this.shape = "sphere"; + } + if (!this.title) { + this.title = "Geostationary Satellite View"; + } +} +function forward31(p) { + var lon = p.x; + var lat = p.y; + var tmp, v_x, v_y, v_z; + lon = lon - this.long0; + if (this.shape === "ellipse") { + lat = Math.atan(this.radius_p2 * Math.tan(lat)); + var r = this.radius_p / hypot_default(this.radius_p * Math.cos(lat), Math.sin(lat)); + v_x = r * Math.cos(lon) * Math.cos(lat); + v_y = r * Math.sin(lon) * Math.cos(lat); + v_z = r * Math.sin(lat); + if ((this.radius_g - v_x) * v_x - v_y * v_y - v_z * v_z * this.radius_p_inv2 < 0) { + p.x = Number.NaN; + p.y = Number.NaN; + return p; + } + tmp = this.radius_g - v_x; + if (this.flip_axis) { + p.x = this.radius_g_1 * Math.atan(v_y / hypot_default(v_z, tmp)); + p.y = this.radius_g_1 * Math.atan(v_z / tmp); + } else { + p.x = this.radius_g_1 * Math.atan(v_y / tmp); + p.y = this.radius_g_1 * Math.atan(v_z / hypot_default(v_y, tmp)); + } + } else if (this.shape === "sphere") { + tmp = Math.cos(lat); + v_x = Math.cos(lon) * tmp; + v_y = Math.sin(lon) * tmp; + v_z = Math.sin(lat); + tmp = this.radius_g - v_x; + if (this.flip_axis) { + p.x = this.radius_g_1 * Math.atan(v_y / hypot_default(v_z, tmp)); + p.y = this.radius_g_1 * Math.atan(v_z / tmp); + } else { + p.x = this.radius_g_1 * Math.atan(v_y / tmp); + p.y = this.radius_g_1 * Math.atan(v_z / hypot_default(v_y, tmp)); + } + } + p.x = p.x * this.a; + p.y = p.y * this.a; + return p; +} +function inverse31(p) { + var v_x = -1; + var v_y = 0; + var v_z = 0; + var a, b, det, k; + p.x = p.x / this.a; + p.y = p.y / this.a; + if (this.shape === "ellipse") { + if (this.flip_axis) { + v_z = Math.tan(p.y / this.radius_g_1); + v_y = Math.tan(p.x / this.radius_g_1) * hypot_default(1, v_z); + } else { + v_y = Math.tan(p.x / this.radius_g_1); + v_z = Math.tan(p.y / this.radius_g_1) * hypot_default(1, v_y); + } + var v_zp = v_z / this.radius_p; + a = v_y * v_y + v_zp * v_zp + v_x * v_x; + b = 2 * this.radius_g * v_x; + det = b * b - 4 * a * this.C; + if (det < 0) { + p.x = Number.NaN; + p.y = Number.NaN; + return p; + } + k = (-b - Math.sqrt(det)) / (2 * a); + v_x = this.radius_g + k * v_x; + v_y *= k; + v_z *= k; + p.x = Math.atan2(v_y, v_x); + p.y = Math.atan(v_z * Math.cos(p.x) / v_x); + p.y = Math.atan(this.radius_p_inv2 * Math.tan(p.y)); + } else if (this.shape === "sphere") { + if (this.flip_axis) { + v_z = Math.tan(p.y / this.radius_g_1); + v_y = Math.tan(p.x / this.radius_g_1) * Math.sqrt(1 + v_z * v_z); + } else { + v_y = Math.tan(p.x / this.radius_g_1); + v_z = Math.tan(p.y / this.radius_g_1) * Math.sqrt(1 + v_y * v_y); + } + a = v_y * v_y + v_z * v_z + v_x * v_x; + b = 2 * this.radius_g * v_x; + det = b * b - 4 * a * this.C; + if (det < 0) { + p.x = Number.NaN; + p.y = Number.NaN; + return p; + } + k = (-b - Math.sqrt(det)) / (2 * a); + v_x = this.radius_g + k * v_x; + v_y *= k; + v_z *= k; + p.x = Math.atan2(v_y, v_x); + p.y = Math.atan(v_z * Math.cos(p.x) / v_x); + } + p.x = p.x + this.long0; + return p; +} +var names33 = ["Geostationary Satellite View", "Geostationary_Satellite", "geos"]; +var geos_default = { + init: init32, + forward: forward31, + inverse: inverse31, + names: names33 +}; + +// node_modules/proj4/projs.js +function projs_default(proj42) { + proj42.Proj.projections.add(tmerc_default); + proj42.Proj.projections.add(etmerc_default); + proj42.Proj.projections.add(utm_default); + proj42.Proj.projections.add(sterea_default); + proj42.Proj.projections.add(stere_default); + proj42.Proj.projections.add(somerc_default); + proj42.Proj.projections.add(omerc_default); + proj42.Proj.projections.add(lcc_default); + proj42.Proj.projections.add(krovak_default); + proj42.Proj.projections.add(cass_default); + proj42.Proj.projections.add(laea_default); + proj42.Proj.projections.add(aea_default); + proj42.Proj.projections.add(gnom_default); + proj42.Proj.projections.add(cea_default); + proj42.Proj.projections.add(eqc_default); + proj42.Proj.projections.add(poly_default); + proj42.Proj.projections.add(nzmg_default); + proj42.Proj.projections.add(mill_default); + proj42.Proj.projections.add(sinu_default); + proj42.Proj.projections.add(moll_default); + proj42.Proj.projections.add(eqdc_default); + proj42.Proj.projections.add(vandg_default); + proj42.Proj.projections.add(aeqd_default); + proj42.Proj.projections.add(ortho_default); + proj42.Proj.projections.add(qsc_default); + proj42.Proj.projections.add(robin_default); + proj42.Proj.projections.add(geocent_default); + proj42.Proj.projections.add(tpers_default); + proj42.Proj.projections.add(geos_default); +} + +// node_modules/proj4/lib/index.js +core_default.defaultDatum = "WGS84"; +core_default.Proj = Proj_default; +core_default.WGS84 = new core_default.Proj("WGS84"); +core_default.Point = Point_default; +core_default.toPoint = toPoint_default; +core_default.defs = defs_default; +core_default.nadgrid = nadgrid; +core_default.transform = transform; +core_default.mgrs = mgrs_default; +core_default.version = "__VERSION__"; +projs_default(core_default); +var lib_default = core_default; +export { + lib_default as default +}; +//# sourceMappingURL=proj4.js.map diff --git a/node_modules/.vite/deps/proj4.js.map b/node_modules/.vite/deps/proj4.js.map new file mode 100644 index 000000000..6c58a8e1f --- /dev/null +++ b/node_modules/.vite/deps/proj4.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../proj4/lib/global.js", "../../proj4/lib/constants/values.js", "../../proj4/lib/constants/PrimeMeridian.js", "../../proj4/lib/constants/units.js", "../../proj4/lib/match.js", "../../proj4/lib/projString.js", "../../wkt-parser/parser.js", "../../wkt-parser/process.js", "../../wkt-parser/index.js", "../../proj4/lib/defs.js", "../../proj4/lib/parseCode.js", "../../proj4/lib/extend.js", "../../proj4/lib/common/msfnz.js", "../../proj4/lib/common/sign.js", "../../proj4/lib/common/adjust_lon.js", "../../proj4/lib/common/tsfnz.js", "../../proj4/lib/common/phi2z.js", "../../proj4/lib/projections/merc.js", "../../proj4/lib/projections/longlat.js", "../../proj4/lib/projections.js", "../../proj4/lib/constants/Ellipsoid.js", "../../proj4/lib/deriveConstants.js", "../../proj4/lib/constants/Datum.js", "../../proj4/lib/datum.js", "../../proj4/lib/nadgrid.js", "../../proj4/lib/Proj.js", "../../proj4/lib/datumUtils.js", "../../proj4/lib/datum_transform.js", "../../proj4/lib/adjust_axis.js", "../../proj4/lib/common/toPoint.js", "../../proj4/lib/checkSanity.js", "../../proj4/lib/transform.js", "../../proj4/lib/core.js", "../../mgrs/mgrs.js", "../../proj4/lib/Point.js", "../../proj4/lib/common/pj_enfn.js", "../../proj4/lib/common/pj_mlfn.js", "../../proj4/lib/common/pj_inv_mlfn.js", "../../proj4/lib/projections/tmerc.js", "../../proj4/lib/common/sinh.js", "../../proj4/lib/common/hypot.js", "../../proj4/lib/common/log1py.js", "../../proj4/lib/common/asinhy.js", "../../proj4/lib/common/gatg.js", "../../proj4/lib/common/clens.js", "../../proj4/lib/common/cosh.js", "../../proj4/lib/common/clens_cmplx.js", "../../proj4/lib/projections/etmerc.js", "../../proj4/lib/common/adjust_zone.js", "../../proj4/lib/projections/utm.js", "../../proj4/lib/common/srat.js", "../../proj4/lib/projections/gauss.js", "../../proj4/lib/projections/sterea.js", "../../proj4/lib/projections/stere.js", "../../proj4/lib/projections/somerc.js", "../../proj4/lib/projections/omerc.js", "../../proj4/lib/projections/lcc.js", "../../proj4/lib/projections/krovak.js", "../../proj4/lib/common/mlfn.js", "../../proj4/lib/common/e0fn.js", "../../proj4/lib/common/e1fn.js", "../../proj4/lib/common/e2fn.js", "../../proj4/lib/common/e3fn.js", "../../proj4/lib/common/gN.js", "../../proj4/lib/common/adjust_lat.js", "../../proj4/lib/common/imlfn.js", "../../proj4/lib/projections/cass.js", "../../proj4/lib/common/qsfnz.js", "../../proj4/lib/projections/laea.js", "../../proj4/lib/common/asinz.js", "../../proj4/lib/projections/aea.js", "../../proj4/lib/projections/gnom.js", "../../proj4/lib/common/iqsfnz.js", "../../proj4/lib/projections/cea.js", "../../proj4/lib/projections/eqc.js", "../../proj4/lib/projections/poly.js", "../../proj4/lib/projections/nzmg.js", "../../proj4/lib/projections/mill.js", "../../proj4/lib/projections/sinu.js", "../../proj4/lib/projections/moll.js", "../../proj4/lib/projections/eqdc.js", "../../proj4/lib/projections/vandg.js", "../../proj4/lib/projections/aeqd.js", "../../proj4/lib/projections/ortho.js", "../../proj4/lib/projections/qsc.js", "../../proj4/lib/projections/robin.js", "../../proj4/lib/projections/geocent.js", "../../proj4/lib/projections/tpers.js", "../../proj4/lib/projections/geos.js", "../../proj4/projs.js", "../../proj4/lib/index.js"], + "sourcesContent": ["export default function(defs) {\r\n defs('EPSG:4326', \"+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees\");\r\n defs('EPSG:4269', \"+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees\");\r\n defs('EPSG:3857', \"+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs\");\r\n\r\n defs.WGS84 = defs['EPSG:4326'];\r\n defs['EPSG:3785'] = defs['EPSG:3857']; // maintain backward compat, official code is 3857\r\n defs.GOOGLE = defs['EPSG:3857'];\r\n defs['EPSG:900913'] = defs['EPSG:3857'];\r\n defs['EPSG:102113'] = defs['EPSG:3857'];\r\n}\r\n", "export var PJD_3PARAM = 1;\r\nexport var PJD_7PARAM = 2;\r\nexport var PJD_GRIDSHIFT = 3;\r\nexport var PJD_WGS84 = 4; // WGS84 or equivalent\r\nexport var PJD_NODATUM = 5; // WGS84 or equivalent\r\nexport var SRS_WGS84_SEMIMAJOR = 6378137.0; // only used in grid shift transforms\r\nexport var SRS_WGS84_SEMIMINOR = 6356752.314; // only used in grid shift transforms\r\nexport var SRS_WGS84_ESQUARED = 0.0066943799901413165; // only used in grid shift transforms\r\nexport var SEC_TO_RAD = 4.84813681109535993589914102357e-6;\r\nexport var HALF_PI = Math.PI/2;\r\n// ellipoid pj_set_ell.c\r\nexport var SIXTH = 0.1666666666666666667;\r\n/* 1/6 */\r\nexport var RA4 = 0.04722222222222222222;\r\n/* 17/360 */\r\nexport var RA6 = 0.02215608465608465608;\r\nexport var EPSLN = 1.0e-10;\r\n// you'd think you could use Number.EPSILON above but that makes\r\n// Mollweide get into an infinate loop.\r\n\r\nexport var D2R = 0.01745329251994329577;\r\nexport var R2D = 57.29577951308232088;\r\nexport var FORTPI = Math.PI/4;\r\nexport var TWO_PI = Math.PI * 2;\r\n// SPI is slightly greater than Math.PI, so values that exceed the -180..180\r\n// degree range by a tiny amount don't get wrapped. This prevents points that\r\n// have drifted from their original location along the 180th meridian (due to\r\n// floating point error) from changing their sign.\r\nexport var SPI = 3.14159265359;\r\n", "var exports = {};\r\nexport {exports as default};\r\n\r\nexports.greenwich = 0.0; //\"0dE\",\r\nexports.lisbon = -9.131906111111; //\"9d07'54.862\\\"W\",\r\nexports.paris = 2.337229166667; //\"2d20'14.025\\\"E\",\r\nexports.bogota = -74.080916666667; //\"74d04'51.3\\\"W\",\r\nexports.madrid = -3.687938888889; //\"3d41'16.58\\\"W\",\r\nexports.rome = 12.452333333333; //\"12d27'8.4\\\"E\",\r\nexports.bern = 7.439583333333; //\"7d26'22.5\\\"E\",\r\nexports.jakarta = 106.807719444444; //\"106d48'27.79\\\"E\",\r\nexports.ferro = -17.666666666667; //\"17d40'W\",\r\nexports.brussels = 4.367975; //\"4d22'4.71\\\"E\",\r\nexports.stockholm = 18.058277777778; //\"18d3'29.8\\\"E\",\r\nexports.athens = 23.7163375; //\"23d42'58.815\\\"E\",\r\nexports.oslo = 10.722916666667; //\"10d43'22.5\\\"E\"\r\n", "export default {\r\n ft: {to_meter: 0.3048},\r\n 'us-ft': {to_meter: 1200 / 3937}\r\n};\r\n", "var ignoredChar = /[\\s_\\-\\/\\(\\)]/g;\r\nexport default function match(obj, key) {\r\n if (obj[key]) {\r\n return obj[key];\r\n }\r\n var keys = Object.keys(obj);\r\n var lkey = key.toLowerCase().replace(ignoredChar, '');\r\n var i = -1;\r\n var testkey, processedKey;\r\n while (++i < keys.length) {\r\n testkey = keys[i];\r\n processedKey = testkey.toLowerCase().replace(ignoredChar, '');\r\n if (processedKey === lkey) {\r\n return obj[testkey];\r\n }\r\n }\r\n}\r\n", "import {D2R} from './constants/values';\r\nimport PrimeMeridian from './constants/PrimeMeridian';\r\nimport units from './constants/units';\r\nimport match from './match';\r\n\r\nexport default function(defData) {\r\n var self = {};\r\n var paramObj = defData.split('+').map(function(v) {\r\n return v.trim();\r\n }).filter(function(a) {\r\n return a;\r\n }).reduce(function(p, a) {\r\n var split = a.split('=');\r\n split.push(true);\r\n p[split[0].toLowerCase()] = split[1];\r\n return p;\r\n }, {});\r\n var paramName, paramVal, paramOutname;\r\n var params = {\r\n proj: 'projName',\r\n datum: 'datumCode',\r\n rf: function(v) {\r\n self.rf = parseFloat(v);\r\n },\r\n lat_0: function(v) {\r\n self.lat0 = v * D2R;\r\n },\r\n lat_1: function(v) {\r\n self.lat1 = v * D2R;\r\n },\r\n lat_2: function(v) {\r\n self.lat2 = v * D2R;\r\n },\r\n lat_ts: function(v) {\r\n self.lat_ts = v * D2R;\r\n },\r\n lon_0: function(v) {\r\n self.long0 = v * D2R;\r\n },\r\n lon_1: function(v) {\r\n self.long1 = v * D2R;\r\n },\r\n lon_2: function(v) {\r\n self.long2 = v * D2R;\r\n },\r\n alpha: function(v) {\r\n self.alpha = parseFloat(v) * D2R;\r\n },\r\n gamma: function(v) {\r\n self.rectified_grid_angle = parseFloat(v);\r\n },\r\n lonc: function(v) {\r\n self.longc = v * D2R;\r\n },\r\n x_0: function(v) {\r\n self.x0 = parseFloat(v);\r\n },\r\n y_0: function(v) {\r\n self.y0 = parseFloat(v);\r\n },\r\n k_0: function(v) {\r\n self.k0 = parseFloat(v);\r\n },\r\n k: function(v) {\r\n self.k0 = parseFloat(v);\r\n },\r\n a: function(v) {\r\n self.a = parseFloat(v);\r\n },\r\n b: function(v) {\r\n self.b = parseFloat(v);\r\n },\r\n r_a: function() {\r\n self.R_A = true;\r\n },\r\n zone: function(v) {\r\n self.zone = parseInt(v, 10);\r\n },\r\n south: function() {\r\n self.utmSouth = true;\r\n },\r\n towgs84: function(v) {\r\n self.datum_params = v.split(\",\").map(function(a) {\r\n return parseFloat(a);\r\n });\r\n },\r\n to_meter: function(v) {\r\n self.to_meter = parseFloat(v);\r\n },\r\n units: function(v) {\r\n self.units = v;\r\n var unit = match(units, v);\r\n if (unit) {\r\n self.to_meter = unit.to_meter;\r\n }\r\n },\r\n from_greenwich: function(v) {\r\n self.from_greenwich = v * D2R;\r\n },\r\n pm: function(v) {\r\n var pm = match(PrimeMeridian, v);\r\n self.from_greenwich = (pm ? pm : parseFloat(v)) * D2R;\r\n },\r\n nadgrids: function(v) {\r\n if (v === '@null') {\r\n self.datumCode = 'none';\r\n }\r\n else {\r\n self.nadgrids = v;\r\n }\r\n },\r\n axis: function(v) {\r\n var legalAxis = \"ewnsud\";\r\n if (v.length === 3 && legalAxis.indexOf(v.substr(0, 1)) !== -1 && legalAxis.indexOf(v.substr(1, 1)) !== -1 && legalAxis.indexOf(v.substr(2, 1)) !== -1) {\r\n self.axis = v;\r\n }\r\n },\r\n approx: function() {\r\n self.approx = true;\r\n }\r\n };\r\n for (paramName in paramObj) {\r\n paramVal = paramObj[paramName];\r\n if (paramName in params) {\r\n paramOutname = params[paramName];\r\n if (typeof paramOutname === 'function') {\r\n paramOutname(paramVal);\r\n }\r\n else {\r\n self[paramOutname] = paramVal;\r\n }\r\n }\r\n else {\r\n self[paramName] = paramVal;\r\n }\r\n }\r\n if(typeof self.datumCode === 'string' && self.datumCode !== \"WGS84\"){\r\n self.datumCode = self.datumCode.toLowerCase();\r\n }\r\n return self;\r\n}\r\n", "export default parseString;\r\n\r\nvar NEUTRAL = 1;\r\nvar KEYWORD = 2;\r\nvar NUMBER = 3;\r\nvar QUOTED = 4;\r\nvar AFTERQUOTE = 5;\r\nvar ENDED = -1;\r\nvar whitespace = /\\s/;\r\nvar latin = /[A-Za-z]/;\r\nvar keyword = /[A-Za-z84_]/;\r\nvar endThings = /[,\\]]/;\r\nvar digets = /[\\d\\.E\\-\\+]/;\r\n// const ignoredChar = /[\\s_\\-\\/\\(\\)]/g;\r\nfunction Parser(text) {\r\n if (typeof text !== 'string') {\r\n throw new Error('not a string');\r\n }\r\n this.text = text.trim();\r\n this.level = 0;\r\n this.place = 0;\r\n this.root = null;\r\n this.stack = [];\r\n this.currentObject = null;\r\n this.state = NEUTRAL;\r\n}\r\nParser.prototype.readCharicter = function() {\r\n var char = this.text[this.place++];\r\n if (this.state !== QUOTED) {\r\n while (whitespace.test(char)) {\r\n if (this.place >= this.text.length) {\r\n return;\r\n }\r\n char = this.text[this.place++];\r\n }\r\n }\r\n switch (this.state) {\r\n case NEUTRAL:\r\n return this.neutral(char);\r\n case KEYWORD:\r\n return this.keyword(char)\r\n case QUOTED:\r\n return this.quoted(char);\r\n case AFTERQUOTE:\r\n return this.afterquote(char);\r\n case NUMBER:\r\n return this.number(char);\r\n case ENDED:\r\n return;\r\n }\r\n};\r\nParser.prototype.afterquote = function(char) {\r\n if (char === '\"') {\r\n this.word += '\"';\r\n this.state = QUOTED;\r\n return;\r\n }\r\n if (endThings.test(char)) {\r\n this.word = this.word.trim();\r\n this.afterItem(char);\r\n return;\r\n }\r\n throw new Error('havn\\'t handled \"' +char + '\" in afterquote yet, index ' + this.place);\r\n};\r\nParser.prototype.afterItem = function(char) {\r\n if (char === ',') {\r\n if (this.word !== null) {\r\n this.currentObject.push(this.word);\r\n }\r\n this.word = null;\r\n this.state = NEUTRAL;\r\n return;\r\n }\r\n if (char === ']') {\r\n this.level--;\r\n if (this.word !== null) {\r\n this.currentObject.push(this.word);\r\n this.word = null;\r\n }\r\n this.state = NEUTRAL;\r\n this.currentObject = this.stack.pop();\r\n if (!this.currentObject) {\r\n this.state = ENDED;\r\n }\r\n\r\n return;\r\n }\r\n};\r\nParser.prototype.number = function(char) {\r\n if (digets.test(char)) {\r\n this.word += char;\r\n return;\r\n }\r\n if (endThings.test(char)) {\r\n this.word = parseFloat(this.word);\r\n this.afterItem(char);\r\n return;\r\n }\r\n throw new Error('havn\\'t handled \"' +char + '\" in number yet, index ' + this.place);\r\n};\r\nParser.prototype.quoted = function(char) {\r\n if (char === '\"') {\r\n this.state = AFTERQUOTE;\r\n return;\r\n }\r\n this.word += char;\r\n return;\r\n};\r\nParser.prototype.keyword = function(char) {\r\n if (keyword.test(char)) {\r\n this.word += char;\r\n return;\r\n }\r\n if (char === '[') {\r\n var newObjects = [];\r\n newObjects.push(this.word);\r\n this.level++;\r\n if (this.root === null) {\r\n this.root = newObjects;\r\n } else {\r\n this.currentObject.push(newObjects);\r\n }\r\n this.stack.push(this.currentObject);\r\n this.currentObject = newObjects;\r\n this.state = NEUTRAL;\r\n return;\r\n }\r\n if (endThings.test(char)) {\r\n this.afterItem(char);\r\n return;\r\n }\r\n throw new Error('havn\\'t handled \"' +char + '\" in keyword yet, index ' + this.place);\r\n};\r\nParser.prototype.neutral = function(char) {\r\n if (latin.test(char)) {\r\n this.word = char;\r\n this.state = KEYWORD;\r\n return;\r\n }\r\n if (char === '\"') {\r\n this.word = '';\r\n this.state = QUOTED;\r\n return;\r\n }\r\n if (digets.test(char)) {\r\n this.word = char;\r\n this.state = NUMBER;\r\n return;\r\n }\r\n if (endThings.test(char)) {\r\n this.afterItem(char);\r\n return;\r\n }\r\n throw new Error('havn\\'t handled \"' +char + '\" in neutral yet, index ' + this.place);\r\n};\r\nParser.prototype.output = function() {\r\n while (this.place < this.text.length) {\r\n this.readCharicter();\r\n }\r\n if (this.state === ENDED) {\r\n return this.root;\r\n }\r\n throw new Error('unable to parse string \"' +this.text + '\". State is ' + this.state);\r\n};\r\n\r\nfunction parseString(txt) {\r\n var parser = new Parser(txt);\r\n return parser.output();\r\n}\r\n", "\r\n\r\nfunction mapit(obj, key, value) {\r\n if (Array.isArray(key)) {\r\n value.unshift(key);\r\n key = null;\r\n }\r\n var thing = key ? {} : obj;\r\n\r\n var out = value.reduce(function(newObj, item) {\r\n sExpr(item, newObj);\r\n return newObj\r\n }, thing);\r\n if (key) {\r\n obj[key] = out;\r\n }\r\n}\r\n\r\nexport function sExpr(v, obj) {\r\n if (!Array.isArray(v)) {\r\n obj[v] = true;\r\n return;\r\n }\r\n var key = v.shift();\r\n if (key === 'PARAMETER') {\r\n key = v.shift();\r\n }\r\n if (v.length === 1) {\r\n if (Array.isArray(v[0])) {\r\n obj[key] = {};\r\n sExpr(v[0], obj[key]);\r\n return;\r\n }\r\n obj[key] = v[0];\r\n return;\r\n }\r\n if (!v.length) {\r\n obj[key] = true;\r\n return;\r\n }\r\n if (key === 'TOWGS84') {\r\n obj[key] = v;\r\n return;\r\n }\r\n if (key === 'AXIS') {\r\n if (!(key in obj)) {\r\n obj[key] = [];\r\n }\r\n obj[key].push(v);\r\n return;\r\n }\r\n if (!Array.isArray(key)) {\r\n obj[key] = {};\r\n }\r\n\r\n var i;\r\n switch (key) {\r\n case 'UNIT':\r\n case 'PRIMEM':\r\n case 'VERT_DATUM':\r\n obj[key] = {\r\n name: v[0].toLowerCase(),\r\n convert: v[1]\r\n };\r\n if (v.length === 3) {\r\n sExpr(v[2], obj[key]);\r\n }\r\n return;\r\n case 'SPHEROID':\r\n case 'ELLIPSOID':\r\n obj[key] = {\r\n name: v[0],\r\n a: v[1],\r\n rf: v[2]\r\n };\r\n if (v.length === 4) {\r\n sExpr(v[3], obj[key]);\r\n }\r\n return;\r\n case 'PROJECTEDCRS':\r\n case 'PROJCRS':\r\n case 'GEOGCS':\r\n case 'GEOCCS':\r\n case 'PROJCS':\r\n case 'LOCAL_CS':\r\n case 'GEODCRS':\r\n case 'GEODETICCRS':\r\n case 'GEODETICDATUM':\r\n case 'EDATUM':\r\n case 'ENGINEERINGDATUM':\r\n case 'VERT_CS':\r\n case 'VERTCRS':\r\n case 'VERTICALCRS':\r\n case 'COMPD_CS':\r\n case 'COMPOUNDCRS':\r\n case 'ENGINEERINGCRS':\r\n case 'ENGCRS':\r\n case 'FITTED_CS':\r\n case 'LOCAL_DATUM':\r\n case 'DATUM':\r\n v[0] = ['name', v[0]];\r\n mapit(obj, key, v);\r\n return;\r\n default:\r\n i = -1;\r\n while (++i < v.length) {\r\n if (!Array.isArray(v[i])) {\r\n return sExpr(v, obj[key]);\r\n }\r\n }\r\n return mapit(obj, key, v);\r\n }\r\n}\r\n", "var D2R = 0.01745329251994329577;\r\nimport parser from './parser';\r\nimport {sExpr} from './process';\r\n\r\n\r\n\r\nfunction rename(obj, params) {\r\n var outName = params[0];\r\n var inName = params[1];\r\n if (!(outName in obj) && (inName in obj)) {\r\n obj[outName] = obj[inName];\r\n if (params.length === 3) {\r\n obj[outName] = params[2](obj[outName]);\r\n }\r\n }\r\n}\r\n\r\nfunction d2r(input) {\r\n return input * D2R;\r\n}\r\n\r\nfunction cleanWKT(wkt) {\r\n if (wkt.type === 'GEOGCS') {\r\n wkt.projName = 'longlat';\r\n } else if (wkt.type === 'LOCAL_CS') {\r\n wkt.projName = 'identity';\r\n wkt.local = true;\r\n } else {\r\n if (typeof wkt.PROJECTION === 'object') {\r\n wkt.projName = Object.keys(wkt.PROJECTION)[0];\r\n } else {\r\n wkt.projName = wkt.PROJECTION;\r\n }\r\n }\r\n if (wkt.AXIS) {\r\n var axisOrder = '';\r\n for (var i = 0, ii = wkt.AXIS.length; i < ii; ++i) {\r\n var axis = [wkt.AXIS[i][0].toLowerCase(), wkt.AXIS[i][1].toLowerCase()];\r\n if (axis[0].indexOf('north') !== -1 || ((axis[0] === 'y' || axis[0] === 'lat') && axis[1] === 'north')) {\r\n axisOrder += 'n';\r\n } else if (axis[0].indexOf('south') !== -1 || ((axis[0] === 'y' || axis[0] === 'lat') && axis[1] === 'south')) {\r\n axisOrder += 's';\r\n } else if (axis[0].indexOf('east') !== -1 || ((axis[0] === 'x' || axis[0] === 'lon') && axis[1] === 'east')) {\r\n axisOrder += 'e';\r\n } else if (axis[0].indexOf('west') !== -1 || ((axis[0] === 'x' || axis[0] === 'lon') && axis[1] === 'west')) {\r\n axisOrder += 'w';\r\n }\r\n }\r\n if (axisOrder.length === 2) {\r\n axisOrder += 'u';\r\n }\r\n if (axisOrder.length === 3) {\r\n wkt.axis = axisOrder;\r\n }\r\n }\r\n if (wkt.UNIT) {\r\n wkt.units = wkt.UNIT.name.toLowerCase();\r\n if (wkt.units === 'metre') {\r\n wkt.units = 'meter';\r\n }\r\n if (wkt.UNIT.convert) {\r\n if (wkt.type === 'GEOGCS') {\r\n if (wkt.DATUM && wkt.DATUM.SPHEROID) {\r\n wkt.to_meter = wkt.UNIT.convert*wkt.DATUM.SPHEROID.a;\r\n }\r\n } else {\r\n wkt.to_meter = wkt.UNIT.convert;\r\n }\r\n }\r\n }\r\n var geogcs = wkt.GEOGCS;\r\n if (wkt.type === 'GEOGCS') {\r\n geogcs = wkt;\r\n }\r\n if (geogcs) {\r\n //if(wkt.GEOGCS.PRIMEM&&wkt.GEOGCS.PRIMEM.convert){\r\n // wkt.from_greenwich=wkt.GEOGCS.PRIMEM.convert*D2R;\r\n //}\r\n if (geogcs.DATUM) {\r\n wkt.datumCode = geogcs.DATUM.name.toLowerCase();\r\n } else {\r\n wkt.datumCode = geogcs.name.toLowerCase();\r\n }\r\n if (wkt.datumCode.slice(0, 2) === 'd_') {\r\n wkt.datumCode = wkt.datumCode.slice(2);\r\n }\r\n if (wkt.datumCode === 'new_zealand_geodetic_datum_1949' || wkt.datumCode === 'new_zealand_1949') {\r\n wkt.datumCode = 'nzgd49';\r\n }\r\n if (wkt.datumCode === 'wgs_1984' || wkt.datumCode === 'world_geodetic_system_1984') {\r\n if (wkt.PROJECTION === 'Mercator_Auxiliary_Sphere') {\r\n wkt.sphere = true;\r\n }\r\n wkt.datumCode = 'wgs84';\r\n }\r\n if (wkt.datumCode.slice(-6) === '_ferro') {\r\n wkt.datumCode = wkt.datumCode.slice(0, - 6);\r\n }\r\n if (wkt.datumCode.slice(-8) === '_jakarta') {\r\n wkt.datumCode = wkt.datumCode.slice(0, - 8);\r\n }\r\n if (~wkt.datumCode.indexOf('belge')) {\r\n wkt.datumCode = 'rnb72';\r\n }\r\n if (geogcs.DATUM && geogcs.DATUM.SPHEROID) {\r\n wkt.ellps = geogcs.DATUM.SPHEROID.name.replace('_19', '').replace(/[Cc]larke\\_18/, 'clrk');\r\n if (wkt.ellps.toLowerCase().slice(0, 13) === 'international') {\r\n wkt.ellps = 'intl';\r\n }\r\n\r\n wkt.a = geogcs.DATUM.SPHEROID.a;\r\n wkt.rf = parseFloat(geogcs.DATUM.SPHEROID.rf, 10);\r\n }\r\n\r\n if (geogcs.DATUM && geogcs.DATUM.TOWGS84) {\r\n wkt.datum_params = geogcs.DATUM.TOWGS84;\r\n }\r\n if (~wkt.datumCode.indexOf('osgb_1936')) {\r\n wkt.datumCode = 'osgb36';\r\n }\r\n if (~wkt.datumCode.indexOf('osni_1952')) {\r\n wkt.datumCode = 'osni52';\r\n }\r\n if (~wkt.datumCode.indexOf('tm65')\r\n || ~wkt.datumCode.indexOf('geodetic_datum_of_1965')) {\r\n wkt.datumCode = 'ire65';\r\n }\r\n if (wkt.datumCode === 'ch1903+') {\r\n wkt.datumCode = 'ch1903';\r\n }\r\n if (~wkt.datumCode.indexOf('israel')) {\r\n wkt.datumCode = 'isr93';\r\n }\r\n }\r\n if (wkt.b && !isFinite(wkt.b)) {\r\n wkt.b = wkt.a;\r\n }\r\n\r\n function toMeter(input) {\r\n var ratio = wkt.to_meter || 1;\r\n return input * ratio;\r\n }\r\n var renamer = function(a) {\r\n return rename(wkt, a);\r\n };\r\n var list = [\r\n ['standard_parallel_1', 'Standard_Parallel_1'],\r\n ['standard_parallel_1', 'Latitude of 1st standard parallel'],\r\n ['standard_parallel_2', 'Standard_Parallel_2'],\r\n ['standard_parallel_2', 'Latitude of 2nd standard parallel'],\r\n ['false_easting', 'False_Easting'],\r\n ['false_easting', 'False easting'],\r\n ['false-easting', 'Easting at false origin'],\r\n ['false_northing', 'False_Northing'],\r\n ['false_northing', 'False northing'],\r\n ['false_northing', 'Northing at false origin'],\r\n ['central_meridian', 'Central_Meridian'],\r\n ['central_meridian', 'Longitude of natural origin'],\r\n ['central_meridian', 'Longitude of false origin'],\r\n ['latitude_of_origin', 'Latitude_Of_Origin'],\r\n ['latitude_of_origin', 'Central_Parallel'],\r\n ['latitude_of_origin', 'Latitude of natural origin'],\r\n ['latitude_of_origin', 'Latitude of false origin'],\r\n ['scale_factor', 'Scale_Factor'],\r\n ['k0', 'scale_factor'],\r\n ['latitude_of_center', 'Latitude_Of_Center'],\r\n ['latitude_of_center', 'Latitude_of_center'],\r\n ['lat0', 'latitude_of_center', d2r],\r\n ['longitude_of_center', 'Longitude_Of_Center'],\r\n ['longitude_of_center', 'Longitude_of_center'],\r\n ['longc', 'longitude_of_center', d2r],\r\n ['x0', 'false_easting', toMeter],\r\n ['y0', 'false_northing', toMeter],\r\n ['long0', 'central_meridian', d2r],\r\n ['lat0', 'latitude_of_origin', d2r],\r\n ['lat0', 'standard_parallel_1', d2r],\r\n ['lat1', 'standard_parallel_1', d2r],\r\n ['lat2', 'standard_parallel_2', d2r],\r\n ['azimuth', 'Azimuth'],\r\n ['alpha', 'azimuth', d2r],\r\n ['srsCode', 'name']\r\n ];\r\n list.forEach(renamer);\r\n if (!wkt.long0 && wkt.longc && (wkt.projName === 'Albers_Conic_Equal_Area' || wkt.projName === 'Lambert_Azimuthal_Equal_Area')) {\r\n wkt.long0 = wkt.longc;\r\n }\r\n if (!wkt.lat_ts && wkt.lat1 && (wkt.projName === 'Stereographic_South_Pole' || wkt.projName === 'Polar Stereographic (variant B)')) {\r\n wkt.lat0 = d2r(wkt.lat1 > 0 ? 90 : -90);\r\n wkt.lat_ts = wkt.lat1;\r\n } else if (!wkt.lat_ts && wkt.lat0 && wkt.projName === 'Polar_Stereographic') {\r\n wkt.lat_ts = wkt.lat0;\r\n wkt.lat0 = d2r(wkt.lat0 > 0 ? 90 : -90);\r\n }\r\n}\r\nexport default function(wkt) {\r\n var lisp = parser(wkt);\r\n var type = lisp.shift();\r\n var name = lisp.shift();\r\n lisp.unshift(['name', name]);\r\n lisp.unshift(['type', type]);\r\n var obj = {};\r\n sExpr(lisp, obj);\r\n cleanWKT(obj);\r\n return obj;\r\n}\r\n", "import globals from './global';\r\nimport parseProj from './projString';\r\nimport wkt from 'wkt-parser';\r\n\r\nfunction defs(name) {\r\n /*global console*/\r\n var that = this;\r\n if (arguments.length === 2) {\r\n var def = arguments[1];\r\n if (typeof def === 'string') {\r\n if (def.charAt(0) === '+') {\r\n defs[name] = parseProj(arguments[1]);\r\n }\r\n else {\r\n defs[name] = wkt(arguments[1]);\r\n }\r\n } else {\r\n defs[name] = def;\r\n }\r\n }\r\n else if (arguments.length === 1) {\r\n if (Array.isArray(name)) {\r\n return name.map(function(v) {\r\n if (Array.isArray(v)) {\r\n defs.apply(that, v);\r\n }\r\n else {\r\n defs(v);\r\n }\r\n });\r\n }\r\n else if (typeof name === 'string') {\r\n if (name in defs) {\r\n return defs[name];\r\n }\r\n }\r\n else if ('EPSG' in name) {\r\n defs['EPSG:' + name.EPSG] = name;\r\n }\r\n else if ('ESRI' in name) {\r\n defs['ESRI:' + name.ESRI] = name;\r\n }\r\n else if ('IAU2000' in name) {\r\n defs['IAU2000:' + name.IAU2000] = name;\r\n }\r\n else {\r\n console.log(name);\r\n }\r\n return;\r\n }\r\n\r\n\r\n}\r\nglobals(defs);\r\nexport default defs;\r\n", "import defs from './defs';\r\nimport wkt from 'wkt-parser';\r\nimport projStr from './projString';\r\nimport match from './match';\r\nfunction testObj(code){\r\n return typeof code === 'string';\r\n}\r\nfunction testDef(code){\r\n return code in defs;\r\n}\r\nvar codeWords = ['PROJECTEDCRS', 'PROJCRS', 'GEOGCS','GEOCCS','PROJCS','LOCAL_CS', 'GEODCRS', 'GEODETICCRS', 'GEODETICDATUM', 'ENGCRS', 'ENGINEERINGCRS'];\r\nfunction testWKT(code){\r\n return codeWords.some(function (word) {\r\n return code.indexOf(word) > -1;\r\n });\r\n}\r\nvar codes = ['3857', '900913', '3785', '102113'];\r\nfunction checkMercator(item) {\r\n var auth = match(item, 'authority');\r\n if (!auth) {\r\n return;\r\n }\r\n var code = match(auth, 'epsg');\r\n return code && codes.indexOf(code) > -1;\r\n}\r\nfunction checkProjStr(item) {\r\n var ext = match(item, 'extension');\r\n if (!ext) {\r\n return;\r\n }\r\n return match(ext, 'proj4');\r\n}\r\nfunction testProj(code){\r\n return code[0] === '+';\r\n}\r\nfunction parse(code){\r\n if (testObj(code)) {\r\n //check to see if this is a WKT string\r\n if (testDef(code)) {\r\n return defs[code];\r\n }\r\n if (testWKT(code)) {\r\n var out = wkt(code);\r\n // test of spetial case, due to this being a very common and often malformed\r\n if (checkMercator(out)) {\r\n return defs['EPSG:3857'];\r\n }\r\n var maybeProjStr = checkProjStr(out);\r\n if (maybeProjStr) {\r\n return projStr(maybeProjStr);\r\n }\r\n return out;\r\n }\r\n if (testProj(code)) {\r\n return projStr(code);\r\n }\r\n }else{\r\n return code;\r\n }\r\n}\r\n\r\nexport default parse;\r\n", "export default function(destination, source) {\r\n destination = destination || {};\r\n var value, property;\r\n if (!source) {\r\n return destination;\r\n }\r\n for (property in source) {\r\n value = source[property];\r\n if (value !== undefined) {\r\n destination[property] = value;\r\n }\r\n }\r\n return destination;\r\n}\r\n", "export default function(eccent, sinphi, cosphi) {\r\n var con = eccent * sinphi;\r\n return cosphi / (Math.sqrt(1 - con * con));\r\n}", "export default function(x) {\r\n return x<0 ? -1 : 1;\r\n}", "\r\nimport {TWO_PI, SPI} from '../constants/values';\r\nimport sign from './sign';\r\n\r\nexport default function(x) {\r\n return (Math.abs(x) <= SPI) ? x : (x - (sign(x) * TWO_PI));\r\n}\r\n", "import {HALF_PI} from '../constants/values';\r\n\r\nexport default function(eccent, phi, sinphi) {\r\n var con = eccent * sinphi;\r\n var com = 0.5 * eccent;\r\n con = Math.pow(((1 - con) / (1 + con)), com);\r\n return (Math.tan(0.5 * (HALF_PI - phi)) / con);\r\n}\r\n", "import {HALF_PI} from '../constants/values';\r\n\r\nexport default function(eccent, ts) {\r\n var eccnth = 0.5 * eccent;\r\n var con, dphi;\r\n var phi = HALF_PI - 2 * Math.atan(ts);\r\n for (var i = 0; i <= 15; i++) {\r\n con = eccent * Math.sin(phi);\r\n dphi = HALF_PI - 2 * Math.atan(ts * (Math.pow(((1 - con) / (1 + con)), eccnth))) - phi;\r\n phi += dphi;\r\n if (Math.abs(dphi) <= 0.0000000001) {\r\n return phi;\r\n }\r\n }\r\n //console.log(\"phi2z has NoConvergence\");\r\n return -9999;\r\n}\r\n", "import msfnz from '../common/msfnz';\r\n\r\nimport adjust_lon from '../common/adjust_lon';\r\nimport tsfnz from '../common/tsfnz';\r\nimport phi2z from '../common/phi2z';\r\nimport {FORTPI, R2D, EPSLN, HALF_PI} from '../constants/values';\r\nexport function init() {\r\n var con = this.b / this.a;\r\n this.es = 1 - con * con;\r\n if(!('x0' in this)){\r\n this.x0 = 0;\r\n }\r\n if(!('y0' in this)){\r\n this.y0 = 0;\r\n }\r\n this.e = Math.sqrt(this.es);\r\n if (this.lat_ts) {\r\n if (this.sphere) {\r\n this.k0 = Math.cos(this.lat_ts);\r\n }\r\n else {\r\n this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));\r\n }\r\n }\r\n else {\r\n if (!this.k0) {\r\n if (this.k) {\r\n this.k0 = this.k;\r\n }\r\n else {\r\n this.k0 = 1;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/* Mercator forward equations--mapping lat,long to x,y\r\n --------------------------------------------------*/\r\n\r\nexport function forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n // convert to radians\r\n if (lat * R2D > 90 && lat * R2D < -90 && lon * R2D > 180 && lon * R2D < -180) {\r\n return null;\r\n }\r\n\r\n var x, y;\r\n if (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) {\r\n return null;\r\n }\r\n else {\r\n if (this.sphere) {\r\n x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);\r\n y = this.y0 + this.a * this.k0 * Math.log(Math.tan(FORTPI + 0.5 * lat));\r\n }\r\n else {\r\n var sinphi = Math.sin(lat);\r\n var ts = tsfnz(this.e, lat, sinphi);\r\n x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);\r\n y = this.y0 - this.a * this.k0 * Math.log(ts);\r\n }\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n }\r\n}\r\n\r\n/* Mercator inverse equations--mapping x,y to lat/long\r\n --------------------------------------------------*/\r\nexport function inverse(p) {\r\n\r\n var x = p.x - this.x0;\r\n var y = p.y - this.y0;\r\n var lon, lat;\r\n\r\n if (this.sphere) {\r\n lat = HALF_PI - 2 * Math.atan(Math.exp(-y / (this.a * this.k0)));\r\n }\r\n else {\r\n var ts = Math.exp(-y / (this.a * this.k0));\r\n lat = phi2z(this.e, ts);\r\n if (lat === -9999) {\r\n return null;\r\n }\r\n }\r\n lon = adjust_lon(this.long0 + x / (this.a * this.k0));\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"Mercator\", \"Popular Visualisation Pseudo Mercator\", \"Mercator_1SP\", \"Mercator_Auxiliary_Sphere\", \"merc\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "export function init() {\r\n //no-op for longlat\r\n}\r\n\r\nfunction identity(pt) {\r\n return pt;\r\n}\r\nexport {identity as forward};\r\nexport {identity as inverse};\r\nexport var names = [\"longlat\", \"identity\"];\r\nexport default {\r\n init: init,\r\n forward: identity,\r\n inverse: identity,\r\n names: names\r\n};\r\n", "import merc from \"./projections/merc\";\r\nimport longlat from \"./projections/longlat\";\r\nvar projs = [merc, longlat];\r\nvar names = {};\r\nvar projStore = [];\r\n\r\nfunction add(proj, i) {\r\n var len = projStore.length;\r\n if (!proj.names) {\r\n console.log(i);\r\n return true;\r\n }\r\n projStore[len] = proj;\r\n proj.names.forEach(function(n) {\r\n names[n.toLowerCase()] = len;\r\n });\r\n return this;\r\n}\r\n\r\nexport {add};\r\n\r\nexport function get(name) {\r\n if (!name) {\r\n return false;\r\n }\r\n var n = name.toLowerCase();\r\n if (typeof names[n] !== 'undefined' && projStore[names[n]]) {\r\n return projStore[names[n]];\r\n }\r\n}\r\n\r\nexport function start() {\r\n projs.forEach(add);\r\n}\r\nexport default {\r\n start: start,\r\n add: add,\r\n get: get\r\n};\r\n", "var exports = {};\r\nexport {exports as default};\r\nexports.MERIT = {\r\n a: 6378137.0,\r\n rf: 298.257,\r\n ellipseName: \"MERIT 1983\"\r\n};\r\n\r\nexports.SGS85 = {\r\n a: 6378136.0,\r\n rf: 298.257,\r\n ellipseName: \"Soviet Geodetic System 85\"\r\n};\r\n\r\nexports.GRS80 = {\r\n a: 6378137.0,\r\n rf: 298.257222101,\r\n ellipseName: \"GRS 1980(IUGG, 1980)\"\r\n};\r\n\r\nexports.IAU76 = {\r\n a: 6378140.0,\r\n rf: 298.257,\r\n ellipseName: \"IAU 1976\"\r\n};\r\n\r\nexports.airy = {\r\n a: 6377563.396,\r\n b: 6356256.910,\r\n ellipseName: \"Airy 1830\"\r\n};\r\n\r\nexports.APL4 = {\r\n a: 6378137,\r\n rf: 298.25,\r\n ellipseName: \"Appl. Physics. 1965\"\r\n};\r\n\r\nexports.NWL9D = {\r\n a: 6378145.0,\r\n rf: 298.25,\r\n ellipseName: \"Naval Weapons Lab., 1965\"\r\n};\r\n\r\nexports.mod_airy = {\r\n a: 6377340.189,\r\n b: 6356034.446,\r\n ellipseName: \"Modified Airy\"\r\n};\r\n\r\nexports.andrae = {\r\n a: 6377104.43,\r\n rf: 300.0,\r\n ellipseName: \"Andrae 1876 (Den., Iclnd.)\"\r\n};\r\n\r\nexports.aust_SA = {\r\n a: 6378160.0,\r\n rf: 298.25,\r\n ellipseName: \"Australian Natl & S. Amer. 1969\"\r\n};\r\n\r\nexports.GRS67 = {\r\n a: 6378160.0,\r\n rf: 298.2471674270,\r\n ellipseName: \"GRS 67(IUGG 1967)\"\r\n};\r\n\r\nexports.bessel = {\r\n a: 6377397.155,\r\n rf: 299.1528128,\r\n ellipseName: \"Bessel 1841\"\r\n};\r\n\r\nexports.bess_nam = {\r\n a: 6377483.865,\r\n rf: 299.1528128,\r\n ellipseName: \"Bessel 1841 (Namibia)\"\r\n};\r\n\r\nexports.clrk66 = {\r\n a: 6378206.4,\r\n b: 6356583.8,\r\n ellipseName: \"Clarke 1866\"\r\n};\r\n\r\nexports.clrk80 = {\r\n a: 6378249.145,\r\n rf: 293.4663,\r\n ellipseName: \"Clarke 1880 mod.\"\r\n};\r\n\r\nexports.clrk80ign = {\r\n a: 6378249.2,\r\n b: 6356515,\r\n rf: 293.4660213,\r\n ellipseName: \"Clarke 1880 (IGN)\"\r\n};\r\n\r\nexports.clrk58 = {\r\n a: 6378293.645208759,\r\n rf: 294.2606763692654,\r\n ellipseName: \"Clarke 1858\"\r\n};\r\n\r\nexports.CPM = {\r\n a: 6375738.7,\r\n rf: 334.29,\r\n ellipseName: \"Comm. des Poids et Mesures 1799\"\r\n};\r\n\r\nexports.delmbr = {\r\n a: 6376428.0,\r\n rf: 311.5,\r\n ellipseName: \"Delambre 1810 (Belgium)\"\r\n};\r\n\r\nexports.engelis = {\r\n a: 6378136.05,\r\n rf: 298.2566,\r\n ellipseName: \"Engelis 1985\"\r\n};\r\n\r\nexports.evrst30 = {\r\n a: 6377276.345,\r\n rf: 300.8017,\r\n ellipseName: \"Everest 1830\"\r\n};\r\n\r\nexports.evrst48 = {\r\n a: 6377304.063,\r\n rf: 300.8017,\r\n ellipseName: \"Everest 1948\"\r\n};\r\n\r\nexports.evrst56 = {\r\n a: 6377301.243,\r\n rf: 300.8017,\r\n ellipseName: \"Everest 1956\"\r\n};\r\n\r\nexports.evrst69 = {\r\n a: 6377295.664,\r\n rf: 300.8017,\r\n ellipseName: \"Everest 1969\"\r\n};\r\n\r\nexports.evrstSS = {\r\n a: 6377298.556,\r\n rf: 300.8017,\r\n ellipseName: \"Everest (Sabah & Sarawak)\"\r\n};\r\n\r\nexports.fschr60 = {\r\n a: 6378166.0,\r\n rf: 298.3,\r\n ellipseName: \"Fischer (Mercury Datum) 1960\"\r\n};\r\n\r\nexports.fschr60m = {\r\n a: 6378155.0,\r\n rf: 298.3,\r\n ellipseName: \"Fischer 1960\"\r\n};\r\n\r\nexports.fschr68 = {\r\n a: 6378150.0,\r\n rf: 298.3,\r\n ellipseName: \"Fischer 1968\"\r\n};\r\n\r\nexports.helmert = {\r\n a: 6378200.0,\r\n rf: 298.3,\r\n ellipseName: \"Helmert 1906\"\r\n};\r\n\r\nexports.hough = {\r\n a: 6378270.0,\r\n rf: 297.0,\r\n ellipseName: \"Hough\"\r\n};\r\n\r\nexports.intl = {\r\n a: 6378388.0,\r\n rf: 297.0,\r\n ellipseName: \"International 1909 (Hayford)\"\r\n};\r\n\r\nexports.kaula = {\r\n a: 6378163.0,\r\n rf: 298.24,\r\n ellipseName: \"Kaula 1961\"\r\n};\r\n\r\nexports.lerch = {\r\n a: 6378139.0,\r\n rf: 298.257,\r\n ellipseName: \"Lerch 1979\"\r\n};\r\n\r\nexports.mprts = {\r\n a: 6397300.0,\r\n rf: 191.0,\r\n ellipseName: \"Maupertius 1738\"\r\n};\r\n\r\nexports.new_intl = {\r\n a: 6378157.5,\r\n b: 6356772.2,\r\n ellipseName: \"New International 1967\"\r\n};\r\n\r\nexports.plessis = {\r\n a: 6376523.0,\r\n rf: 6355863.0,\r\n ellipseName: \"Plessis 1817 (France)\"\r\n};\r\n\r\nexports.krass = {\r\n a: 6378245.0,\r\n rf: 298.3,\r\n ellipseName: \"Krassovsky, 1942\"\r\n};\r\n\r\nexports.SEasia = {\r\n a: 6378155.0,\r\n b: 6356773.3205,\r\n ellipseName: \"Southeast Asia\"\r\n};\r\n\r\nexports.walbeck = {\r\n a: 6376896.0,\r\n b: 6355834.8467,\r\n ellipseName: \"Walbeck\"\r\n};\r\n\r\nexports.WGS60 = {\r\n a: 6378165.0,\r\n rf: 298.3,\r\n ellipseName: \"WGS 60\"\r\n};\r\n\r\nexports.WGS66 = {\r\n a: 6378145.0,\r\n rf: 298.25,\r\n ellipseName: \"WGS 66\"\r\n};\r\n\r\nexports.WGS7 = {\r\n a: 6378135.0,\r\n rf: 298.26,\r\n ellipseName: \"WGS 72\"\r\n};\r\n\r\nexport var WGS84 = exports.WGS84 = {\r\n a: 6378137.0,\r\n rf: 298.257223563,\r\n ellipseName: \"WGS 84\"\r\n};\r\n\r\nexports.sphere = {\r\n a: 6370997.0,\r\n b: 6370997.0,\r\n ellipseName: \"Normal Sphere (r=6370997)\"\r\n};\r\n", "import {SIXTH, RA4, RA6, EPSLN} from './constants/values';\r\nimport {default as Ellipsoid, WGS84} from './constants/Ellipsoid';\r\nimport match from './match';\r\n\r\nexport function eccentricity(a, b, rf, R_A) {\r\n var a2 = a * a; // used in geocentric\r\n var b2 = b * b; // used in geocentric\r\n var es = (a2 - b2) / a2; // e ^ 2\r\n var e = 0;\r\n if (R_A) {\r\n a *= 1 - es * (SIXTH + es * (RA4 + es * RA6));\r\n a2 = a * a;\r\n es = 0;\r\n } else {\r\n e = Math.sqrt(es); // eccentricity\r\n }\r\n var ep2 = (a2 - b2) / b2; // used in geocentric\r\n return {\r\n es: es,\r\n e: e,\r\n ep2: ep2\r\n };\r\n}\r\nexport function sphere(a, b, rf, ellps, sphere) {\r\n if (!a) { // do we have an ellipsoid?\r\n var ellipse = match(Ellipsoid, ellps);\r\n if (!ellipse) {\r\n ellipse = WGS84;\r\n }\r\n a = ellipse.a;\r\n b = ellipse.b;\r\n rf = ellipse.rf;\r\n }\r\n\r\n if (rf && !b) {\r\n b = (1.0 - 1.0 / rf) * a;\r\n }\r\n if (rf === 0 || Math.abs(a - b) < EPSLN) {\r\n sphere = true;\r\n b = a;\r\n }\r\n return {\r\n a: a,\r\n b: b,\r\n rf: rf,\r\n sphere: sphere\r\n };\r\n}\r\n", "var exports = {};\r\nexport {exports as default};\r\nexports.wgs84 = {\r\n towgs84: \"0,0,0\",\r\n ellipse: \"WGS84\",\r\n datumName: \"WGS84\"\r\n};\r\n\r\nexports.ch1903 = {\r\n towgs84: \"674.374,15.056,405.346\",\r\n ellipse: \"bessel\",\r\n datumName: \"swiss\"\r\n};\r\n\r\nexports.ggrs87 = {\r\n towgs84: \"-199.87,74.79,246.62\",\r\n ellipse: \"GRS80\",\r\n datumName: \"Greek_Geodetic_Reference_System_1987\"\r\n};\r\n\r\nexports.nad83 = {\r\n towgs84: \"0,0,0\",\r\n ellipse: \"GRS80\",\r\n datumName: \"North_American_Datum_1983\"\r\n};\r\n\r\nexports.nad27 = {\r\n nadgrids: \"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat\",\r\n ellipse: \"clrk66\",\r\n datumName: \"North_American_Datum_1927\"\r\n};\r\n\r\nexports.potsdam = {\r\n towgs84: \"598.1,73.7,418.2,0.202,0.045,-2.455,6.7\",\r\n ellipse: \"bessel\",\r\n datumName: \"Potsdam Rauenberg 1950 DHDN\"\r\n};\r\n\r\nexports.carthage = {\r\n towgs84: \"-263.0,6.0,431.0\",\r\n ellipse: \"clark80\",\r\n datumName: \"Carthage 1934 Tunisia\"\r\n};\r\n\r\nexports.hermannskogel = {\r\n towgs84: \"577.326,90.129,463.919,5.137,1.474,5.297,2.4232\",\r\n ellipse: \"bessel\",\r\n datumName: \"Hermannskogel\"\r\n};\r\n\r\nexports.osni52 = {\r\n towgs84: \"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15\",\r\n ellipse: \"airy\",\r\n datumName: \"Irish National\"\r\n};\r\n\r\nexports.ire65 = {\r\n towgs84: \"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15\",\r\n ellipse: \"mod_airy\",\r\n datumName: \"Ireland 1965\"\r\n};\r\n\r\nexports.rassadiran = {\r\n towgs84: \"-133.63,-157.5,-158.62\",\r\n ellipse: \"intl\",\r\n datumName: \"Rassadiran\"\r\n};\r\n\r\nexports.nzgd49 = {\r\n towgs84: \"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993\",\r\n ellipse: \"intl\",\r\n datumName: \"New Zealand Geodetic Datum 1949\"\r\n};\r\n\r\nexports.osgb36 = {\r\n towgs84: \"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894\",\r\n ellipse: \"airy\",\r\n datumName: \"Airy 1830\"\r\n};\r\n\r\nexports.s_jtsk = {\r\n towgs84: \"589,76,480\",\r\n ellipse: 'bessel',\r\n datumName: 'S-JTSK (Ferro)'\r\n};\r\n\r\nexports.beduaram = {\r\n towgs84: '-106,-87,188',\r\n ellipse: 'clrk80',\r\n datumName: 'Beduaram'\r\n};\r\n\r\nexports.gunung_segara = {\r\n towgs84: '-403,684,41',\r\n ellipse: 'bessel',\r\n datumName: 'Gunung Segara Jakarta'\r\n};\r\n\r\nexports.rnb72 = {\r\n towgs84: \"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1\",\r\n ellipse: \"intl\",\r\n datumName: \"Reseau National Belge 1972\"\r\n};\r\n", "import {PJD_3PARAM, PJD_7PARAM, PJD_GRIDSHIFT, PJD_WGS84, PJD_NODATUM, SEC_TO_RAD} from './constants/values';\r\n\r\nfunction datum(datumCode, datum_params, a, b, es, ep2, nadgrids) {\r\n var out = {};\r\n\r\n if (datumCode === undefined || datumCode === 'none') {\r\n out.datum_type = PJD_NODATUM;\r\n } else {\r\n out.datum_type = PJD_WGS84;\r\n }\r\n\r\n if (datum_params) {\r\n out.datum_params = datum_params.map(parseFloat);\r\n if (out.datum_params[0] !== 0 || out.datum_params[1] !== 0 || out.datum_params[2] !== 0) {\r\n out.datum_type = PJD_3PARAM;\r\n }\r\n if (out.datum_params.length > 3) {\r\n if (out.datum_params[3] !== 0 || out.datum_params[4] !== 0 || out.datum_params[5] !== 0 || out.datum_params[6] !== 0) {\r\n out.datum_type = PJD_7PARAM;\r\n out.datum_params[3] *= SEC_TO_RAD;\r\n out.datum_params[4] *= SEC_TO_RAD;\r\n out.datum_params[5] *= SEC_TO_RAD;\r\n out.datum_params[6] = (out.datum_params[6] / 1000000.0) + 1.0;\r\n }\r\n }\r\n }\r\n\r\n if (nadgrids) {\r\n out.datum_type = PJD_GRIDSHIFT;\r\n out.grids = nadgrids;\r\n }\r\n out.a = a; //datum object also uses these values\r\n out.b = b;\r\n out.es = es;\r\n out.ep2 = ep2;\r\n return out;\r\n}\r\n\r\nexport default datum;\r\n", "/**\r\n * Resources for details of NTv2 file formats:\r\n * - https://web.archive.org/web/20140127204822if_/http://www.mgs.gov.on.ca:80/stdprodconsume/groups/content/@mgs/@iandit/documents/resourcelist/stel02_047447.pdf\r\n * - http://mimaka.com/help/gs/html/004_NTV2%20Data%20Format.htm\r\n */\r\n\r\nvar loadedNadgrids = {};\r\n\r\n/**\r\n * Load a binary NTv2 file (.gsb) to a key that can be used in a proj string like +nadgrids=. Pass the NTv2 file\r\n * as an ArrayBuffer.\r\n */\r\nexport default function nadgrid(key, data) {\r\n var view = new DataView(data);\r\n var isLittleEndian = detectLittleEndian(view);\r\n var header = readHeader(view, isLittleEndian);\r\n var subgrids = readSubgrids(view, header, isLittleEndian);\r\n var nadgrid = {header: header, subgrids: subgrids};\r\n loadedNadgrids[key] = nadgrid;\r\n return nadgrid;\r\n}\r\n\r\n/**\r\n * Given a proj4 value for nadgrids, return an array of loaded grids\r\n */\r\nexport function getNadgrids(nadgrids) {\r\n // Format details: http://proj.maptools.org/gen_parms.html\r\n if (nadgrids === undefined) { return null; }\r\n var grids = nadgrids.split(',');\r\n return grids.map(parseNadgridString);\r\n}\r\n\r\nfunction parseNadgridString(value) {\r\n if (value.length === 0) {\r\n return null;\r\n }\r\n var optional = value[0] === '@';\r\n if (optional) {\r\n value = value.slice(1);\r\n }\r\n if (value === 'null') {\r\n return {name: 'null', mandatory: !optional, grid: null, isNull: true};\r\n }\r\n return {\r\n name: value,\r\n mandatory: !optional,\r\n grid: loadedNadgrids[value] || null,\r\n isNull: false\r\n };\r\n}\r\n\r\nfunction secondsToRadians(seconds) {\r\n return (seconds / 3600) * Math.PI / 180;\r\n}\r\n\r\nfunction detectLittleEndian(view) {\r\n var nFields = view.getInt32(8, false);\r\n if (nFields === 11) {\r\n return false;\r\n }\r\n nFields = view.getInt32(8, true);\r\n if (nFields !== 11) {\r\n console.warn('Failed to detect nadgrid endian-ness, defaulting to little-endian');\r\n }\r\n return true;\r\n}\r\n\r\nfunction readHeader(view, isLittleEndian) {\r\n return {\r\n nFields: view.getInt32(8, isLittleEndian),\r\n nSubgridFields: view.getInt32(24, isLittleEndian),\r\n nSubgrids: view.getInt32(40, isLittleEndian),\r\n shiftType: decodeString(view, 56, 56 + 8).trim(),\r\n fromSemiMajorAxis: view.getFloat64(120, isLittleEndian),\r\n fromSemiMinorAxis: view.getFloat64(136, isLittleEndian),\r\n toSemiMajorAxis: view.getFloat64(152, isLittleEndian),\r\n toSemiMinorAxis: view.getFloat64(168, isLittleEndian),\r\n };\r\n}\r\n\r\nfunction decodeString(view, start, end) {\r\n return String.fromCharCode.apply(null, new Uint8Array(view.buffer.slice(start, end)));\r\n}\r\n\r\nfunction readSubgrids(view, header, isLittleEndian) {\r\n var gridOffset = 176;\r\n var grids = [];\r\n for (var i = 0; i < header.nSubgrids; i++) {\r\n var subHeader = readGridHeader(view, gridOffset, isLittleEndian);\r\n var nodes = readGridNodes(view, gridOffset, subHeader, isLittleEndian);\r\n var lngColumnCount = Math.round(\r\n 1 + (subHeader.upperLongitude - subHeader.lowerLongitude) / subHeader.longitudeInterval);\r\n var latColumnCount = Math.round(\r\n 1 + (subHeader.upperLatitude - subHeader.lowerLatitude) / subHeader.latitudeInterval);\r\n // Proj4 operates on radians whereas the coordinates are in seconds in the grid\r\n grids.push({\r\n ll: [secondsToRadians(subHeader.lowerLongitude), secondsToRadians(subHeader.lowerLatitude)],\r\n del: [secondsToRadians(subHeader.longitudeInterval), secondsToRadians(subHeader.latitudeInterval)],\r\n lim: [lngColumnCount, latColumnCount],\r\n count: subHeader.gridNodeCount,\r\n cvs: mapNodes(nodes)\r\n });\r\n gridOffset += 176 + subHeader.gridNodeCount * 16;\r\n }\r\n return grids;\r\n}\r\n\r\nfunction mapNodes(nodes) {\r\n return nodes.map(function (r) {return [secondsToRadians(r.longitudeShift), secondsToRadians(r.latitudeShift)];});\r\n}\r\n\r\nfunction readGridHeader(view, offset, isLittleEndian) {\r\n return {\r\n name: decodeString(view, offset + 8, offset + 16).trim(),\r\n parent: decodeString(view, offset + 24, offset + 24 + 8).trim(),\r\n lowerLatitude: view.getFloat64(offset + 72, isLittleEndian),\r\n upperLatitude: view.getFloat64(offset + 88, isLittleEndian),\r\n lowerLongitude: view.getFloat64(offset + 104, isLittleEndian),\r\n upperLongitude: view.getFloat64(offset + 120, isLittleEndian),\r\n latitudeInterval: view.getFloat64(offset + 136, isLittleEndian),\r\n longitudeInterval: view.getFloat64(offset + 152, isLittleEndian),\r\n gridNodeCount: view.getInt32(offset + 168, isLittleEndian)\r\n };\r\n}\r\n\r\nfunction readGridNodes(view, offset, gridHeader, isLittleEndian) {\r\n var nodesOffset = offset + 176;\r\n var gridRecordLength = 16;\r\n var gridShiftRecords = [];\r\n for (var i = 0; i < gridHeader.gridNodeCount; i++) {\r\n var record = {\r\n latitudeShift: view.getFloat32(nodesOffset + i * gridRecordLength, isLittleEndian),\r\n longitudeShift: view.getFloat32(nodesOffset + i * gridRecordLength + 4, isLittleEndian),\r\n latitudeAccuracy: view.getFloat32(nodesOffset + i * gridRecordLength + 8, isLittleEndian),\r\n longitudeAccuracy: view.getFloat32(nodesOffset + i * gridRecordLength + 12, isLittleEndian),\r\n };\r\n gridShiftRecords.push(record);\r\n }\r\n return gridShiftRecords;\r\n}\r\n", "import parseCode from './parseCode';\r\nimport extend from './extend';\r\nimport projections from './projections';\r\nimport {sphere as dc_sphere, eccentricity as dc_eccentricity} from './deriveConstants';\r\nimport Datum from './constants/Datum';\r\nimport datum from './datum';\r\nimport match from './match';\r\nimport {getNadgrids} from \"./nadgrid\";\r\n\r\nfunction Projection(srsCode,callback) {\r\n if (!(this instanceof Projection)) {\r\n return new Projection(srsCode);\r\n }\r\n callback = callback || function(error){\r\n if(error){\r\n throw error;\r\n }\r\n };\r\n var json = parseCode(srsCode);\r\n if(typeof json !== 'object'){\r\n callback(srsCode);\r\n return;\r\n }\r\n var ourProj = Projection.projections.get(json.projName);\r\n if(!ourProj){\r\n callback(srsCode);\r\n return;\r\n }\r\n if (json.datumCode && json.datumCode !== 'none') {\r\n var datumDef = match(Datum, json.datumCode);\r\n if (datumDef) {\r\n json.datum_params = json.datum_params || (datumDef.towgs84 ? datumDef.towgs84.split(',') : null);\r\n json.ellps = datumDef.ellipse;\r\n json.datumName = datumDef.datumName ? datumDef.datumName : json.datumCode;\r\n }\r\n }\r\n json.k0 = json.k0 || 1.0;\r\n json.axis = json.axis || 'enu';\r\n json.ellps = json.ellps || 'wgs84';\r\n json.lat1 = json.lat1 || json.lat0; // Lambert_Conformal_Conic_1SP, for example, needs this\r\n\r\n var sphere_ = dc_sphere(json.a, json.b, json.rf, json.ellps, json.sphere);\r\n var ecc = dc_eccentricity(sphere_.a, sphere_.b, sphere_.rf, json.R_A);\r\n var nadgrids = getNadgrids(json.nadgrids);\r\n var datumObj = json.datum || datum(json.datumCode, json.datum_params, sphere_.a, sphere_.b, ecc.es, ecc.ep2,\r\n nadgrids);\r\n\r\n extend(this, json); // transfer everything over from the projection because we don't know what we'll need\r\n extend(this, ourProj); // transfer all the methods from the projection\r\n\r\n // copy the 4 things over we calculated in deriveConstants.sphere\r\n this.a = sphere_.a;\r\n this.b = sphere_.b;\r\n this.rf = sphere_.rf;\r\n this.sphere = sphere_.sphere;\r\n\r\n // copy the 3 things we calculated in deriveConstants.eccentricity\r\n this.es = ecc.es;\r\n this.e = ecc.e;\r\n this.ep2 = ecc.ep2;\r\n\r\n // add in the datum object\r\n this.datum = datumObj;\r\n\r\n // init the projection\r\n this.init();\r\n\r\n // legecy callback from back in the day when it went to spatialreference.org\r\n callback(null, this);\r\n\r\n}\r\nProjection.projections = projections;\r\nProjection.projections.start();\r\nexport default Projection;\r\n", "'use strict';\r\nimport {PJD_3PARAM, PJD_7PARAM, HALF_PI} from './constants/values';\r\nexport function compareDatums(source, dest) {\r\n if (source.datum_type !== dest.datum_type) {\r\n return false; // false, datums are not equal\r\n } else if (source.a !== dest.a || Math.abs(source.es - dest.es) > 0.000000000050) {\r\n // the tolerance for es is to ensure that GRS80 and WGS84\r\n // are considered identical\r\n return false;\r\n } else if (source.datum_type === PJD_3PARAM) {\r\n return (source.datum_params[0] === dest.datum_params[0] && source.datum_params[1] === dest.datum_params[1] && source.datum_params[2] === dest.datum_params[2]);\r\n } else if (source.datum_type === PJD_7PARAM) {\r\n return (source.datum_params[0] === dest.datum_params[0] && source.datum_params[1] === dest.datum_params[1] && source.datum_params[2] === dest.datum_params[2] && source.datum_params[3] === dest.datum_params[3] && source.datum_params[4] === dest.datum_params[4] && source.datum_params[5] === dest.datum_params[5] && source.datum_params[6] === dest.datum_params[6]);\r\n } else {\r\n return true; // datums are equal\r\n }\r\n} // cs_compare_datums()\r\n\r\n/*\r\n * The function Convert_Geodetic_To_Geocentric converts geodetic coordinates\r\n * (latitude, longitude, and height) to geocentric coordinates (X, Y, Z),\r\n * according to the current ellipsoid parameters.\r\n *\r\n * Latitude : Geodetic latitude in radians (input)\r\n * Longitude : Geodetic longitude in radians (input)\r\n * Height : Geodetic height, in meters (input)\r\n * X : Calculated Geocentric X coordinate, in meters (output)\r\n * Y : Calculated Geocentric Y coordinate, in meters (output)\r\n * Z : Calculated Geocentric Z coordinate, in meters (output)\r\n *\r\n */\r\nexport function geodeticToGeocentric(p, es, a) {\r\n var Longitude = p.x;\r\n var Latitude = p.y;\r\n var Height = p.z ? p.z : 0; //Z value not always supplied\r\n\r\n var Rn; /* Earth radius at location */\r\n var Sin_Lat; /* Math.sin(Latitude) */\r\n var Sin2_Lat; /* Square of Math.sin(Latitude) */\r\n var Cos_Lat; /* Math.cos(Latitude) */\r\n\r\n /*\r\n ** Don't blow up if Latitude is just a little out of the value\r\n ** range as it may just be a rounding issue. Also removed longitude\r\n ** test, it should be wrapped by Math.cos() and Math.sin(). NFW for PROJ.4, Sep/2001.\r\n */\r\n if (Latitude < -HALF_PI && Latitude > -1.001 * HALF_PI) {\r\n Latitude = -HALF_PI;\r\n } else if (Latitude > HALF_PI && Latitude < 1.001 * HALF_PI) {\r\n Latitude = HALF_PI;\r\n } else if (Latitude < -HALF_PI) {\r\n /* Latitude out of range */\r\n //..reportError('geocent:lat out of range:' + Latitude);\r\n return { x: -Infinity, y: -Infinity, z: p.z };\r\n } else if (Latitude > HALF_PI) {\r\n /* Latitude out of range */\r\n return { x: Infinity, y: Infinity, z: p.z };\r\n }\r\n\r\n if (Longitude > Math.PI) {\r\n Longitude -= (2 * Math.PI);\r\n }\r\n Sin_Lat = Math.sin(Latitude);\r\n Cos_Lat = Math.cos(Latitude);\r\n Sin2_Lat = Sin_Lat * Sin_Lat;\r\n Rn = a / (Math.sqrt(1.0e0 - es * Sin2_Lat));\r\n return {\r\n x: (Rn + Height) * Cos_Lat * Math.cos(Longitude),\r\n y: (Rn + Height) * Cos_Lat * Math.sin(Longitude),\r\n z: ((Rn * (1 - es)) + Height) * Sin_Lat\r\n };\r\n} // cs_geodetic_to_geocentric()\r\n\r\nexport function geocentricToGeodetic(p, es, a, b) {\r\n /* local defintions and variables */\r\n /* end-criterium of loop, accuracy of sin(Latitude) */\r\n var genau = 1e-12;\r\n var genau2 = (genau * genau);\r\n var maxiter = 30;\r\n\r\n var P; /* distance between semi-minor axis and location */\r\n var RR; /* distance between center and location */\r\n var CT; /* sin of geocentric latitude */\r\n var ST; /* cos of geocentric latitude */\r\n var RX;\r\n var RK;\r\n var RN; /* Earth radius at location */\r\n var CPHI0; /* cos of start or old geodetic latitude in iterations */\r\n var SPHI0; /* sin of start or old geodetic latitude in iterations */\r\n var CPHI; /* cos of searched geodetic latitude */\r\n var SPHI; /* sin of searched geodetic latitude */\r\n var SDPHI; /* end-criterium: addition-theorem of sin(Latitude(iter)-Latitude(iter-1)) */\r\n var iter; /* # of continous iteration, max. 30 is always enough (s.a.) */\r\n\r\n var X = p.x;\r\n var Y = p.y;\r\n var Z = p.z ? p.z : 0.0; //Z value not always supplied\r\n var Longitude;\r\n var Latitude;\r\n var Height;\r\n\r\n P = Math.sqrt(X * X + Y * Y);\r\n RR = Math.sqrt(X * X + Y * Y + Z * Z);\r\n\r\n /* special cases for latitude and longitude */\r\n if (P / a < genau) {\r\n\r\n /* special case, if P=0. (X=0., Y=0.) */\r\n Longitude = 0.0;\r\n\r\n /* if (X,Y,Z)=(0.,0.,0.) then Height becomes semi-minor axis\r\n * of ellipsoid (=center of mass), Latitude becomes PI/2 */\r\n if (RR / a < genau) {\r\n Latitude = HALF_PI;\r\n Height = -b;\r\n return {\r\n x: p.x,\r\n y: p.y,\r\n z: p.z\r\n };\r\n }\r\n } else {\r\n /* ellipsoidal (geodetic) longitude\r\n * interval: -PI < Longitude <= +PI */\r\n Longitude = Math.atan2(Y, X);\r\n }\r\n\r\n /* --------------------------------------------------------------\r\n * Following iterative algorithm was developped by\r\n * \"Institut for Erdmessung\", University of Hannover, July 1988.\r\n * Internet: www.ife.uni-hannover.de\r\n * Iterative computation of CPHI,SPHI and Height.\r\n * Iteration of CPHI and SPHI to 10**-12 radian resp.\r\n * 2*10**-7 arcsec.\r\n * --------------------------------------------------------------\r\n */\r\n CT = Z / RR;\r\n ST = P / RR;\r\n RX = 1.0 / Math.sqrt(1.0 - es * (2.0 - es) * ST * ST);\r\n CPHI0 = ST * (1.0 - es) * RX;\r\n SPHI0 = CT * RX;\r\n iter = 0;\r\n\r\n /* loop to find sin(Latitude) resp. Latitude\r\n * until |sin(Latitude(iter)-Latitude(iter-1))| < genau */\r\n do {\r\n iter++;\r\n RN = a / Math.sqrt(1.0 - es * SPHI0 * SPHI0);\r\n\r\n /* ellipsoidal (geodetic) height */\r\n Height = P * CPHI0 + Z * SPHI0 - RN * (1.0 - es * SPHI0 * SPHI0);\r\n\r\n RK = es * RN / (RN + Height);\r\n RX = 1.0 / Math.sqrt(1.0 - RK * (2.0 - RK) * ST * ST);\r\n CPHI = ST * (1.0 - RK) * RX;\r\n SPHI = CT * RX;\r\n SDPHI = SPHI * CPHI0 - CPHI * SPHI0;\r\n CPHI0 = CPHI;\r\n SPHI0 = SPHI;\r\n }\r\n while (SDPHI * SDPHI > genau2 && iter < maxiter);\r\n\r\n /* ellipsoidal (geodetic) latitude */\r\n Latitude = Math.atan(SPHI / Math.abs(CPHI));\r\n return {\r\n x: Longitude,\r\n y: Latitude,\r\n z: Height\r\n };\r\n} // cs_geocentric_to_geodetic()\r\n\r\n/****************************************************************/\r\n// pj_geocentic_to_wgs84( p )\r\n// p = point to transform in geocentric coordinates (x,y,z)\r\n\r\n\r\n/** point object, nothing fancy, just allows values to be\r\n passed back and forth by reference rather than by value.\r\n Other point classes may be used as long as they have\r\n x and y properties, which will get modified in the transform method.\r\n*/\r\nexport function geocentricToWgs84(p, datum_type, datum_params) {\r\n\r\n if (datum_type === PJD_3PARAM) {\r\n // if( x[io] === HUGE_VAL )\r\n // continue;\r\n return {\r\n x: p.x + datum_params[0],\r\n y: p.y + datum_params[1],\r\n z: p.z + datum_params[2],\r\n };\r\n } else if (datum_type === PJD_7PARAM) {\r\n var Dx_BF = datum_params[0];\r\n var Dy_BF = datum_params[1];\r\n var Dz_BF = datum_params[2];\r\n var Rx_BF = datum_params[3];\r\n var Ry_BF = datum_params[4];\r\n var Rz_BF = datum_params[5];\r\n var M_BF = datum_params[6];\r\n // if( x[io] === HUGE_VAL )\r\n // continue;\r\n return {\r\n x: M_BF * (p.x - Rz_BF * p.y + Ry_BF * p.z) + Dx_BF,\r\n y: M_BF * (Rz_BF * p.x + p.y - Rx_BF * p.z) + Dy_BF,\r\n z: M_BF * (-Ry_BF * p.x + Rx_BF * p.y + p.z) + Dz_BF\r\n };\r\n }\r\n} // cs_geocentric_to_wgs84\r\n\r\n/****************************************************************/\r\n// pj_geocentic_from_wgs84()\r\n// coordinate system definition,\r\n// point to transform in geocentric coordinates (x,y,z)\r\nexport function geocentricFromWgs84(p, datum_type, datum_params) {\r\n\r\n if (datum_type === PJD_3PARAM) {\r\n //if( x[io] === HUGE_VAL )\r\n // continue;\r\n return {\r\n x: p.x - datum_params[0],\r\n y: p.y - datum_params[1],\r\n z: p.z - datum_params[2],\r\n };\r\n\r\n } else if (datum_type === PJD_7PARAM) {\r\n var Dx_BF = datum_params[0];\r\n var Dy_BF = datum_params[1];\r\n var Dz_BF = datum_params[2];\r\n var Rx_BF = datum_params[3];\r\n var Ry_BF = datum_params[4];\r\n var Rz_BF = datum_params[5];\r\n var M_BF = datum_params[6];\r\n var x_tmp = (p.x - Dx_BF) / M_BF;\r\n var y_tmp = (p.y - Dy_BF) / M_BF;\r\n var z_tmp = (p.z - Dz_BF) / M_BF;\r\n //if( x[io] === HUGE_VAL )\r\n // continue;\r\n\r\n return {\r\n x: x_tmp + Rz_BF * y_tmp - Ry_BF * z_tmp,\r\n y: -Rz_BF * x_tmp + y_tmp + Rx_BF * z_tmp,\r\n z: Ry_BF * x_tmp - Rx_BF * y_tmp + z_tmp\r\n };\r\n } //cs_geocentric_from_wgs84()\r\n}\r\n", "import {\r\n PJD_3PARAM,\r\n PJD_7PARAM,\r\n PJD_GRIDSHIFT,\r\n PJD_NODATUM,\r\n R2D,\r\n SRS_WGS84_ESQUARED,\r\n SRS_WGS84_SEMIMAJOR, SRS_WGS84_SEMIMINOR\r\n} from './constants/values';\r\n\r\nimport {geodeticToGeocentric, geocentricToGeodetic, geocentricToWgs84, geocentricFromWgs84, compareDatums} from './datumUtils';\r\nimport adjust_lon from \"./common/adjust_lon\";\r\nfunction checkParams(type) {\r\n return (type === PJD_3PARAM || type === PJD_7PARAM);\r\n}\r\n\r\nexport default function(source, dest, point) {\r\n // Short cut if the datums are identical.\r\n if (compareDatums(source, dest)) {\r\n return point; // in this case, zero is sucess,\r\n // whereas cs_compare_datums returns 1 to indicate TRUE\r\n // confusing, should fix this\r\n }\r\n\r\n // Explicitly skip datum transform by setting 'datum=none' as parameter for either source or dest\r\n if (source.datum_type === PJD_NODATUM || dest.datum_type === PJD_NODATUM) {\r\n return point;\r\n }\r\n\r\n // If this datum requires grid shifts, then apply it to geodetic coordinates.\r\n var source_a = source.a;\r\n var source_es = source.es;\r\n if (source.datum_type === PJD_GRIDSHIFT) {\r\n var gridShiftCode = applyGridShift(source, false, point);\r\n if (gridShiftCode !== 0) {\r\n return undefined;\r\n }\r\n source_a = SRS_WGS84_SEMIMAJOR;\r\n source_es = SRS_WGS84_ESQUARED;\r\n }\r\n\r\n var dest_a = dest.a;\r\n var dest_b = dest.b;\r\n var dest_es = dest.es;\r\n if (dest.datum_type === PJD_GRIDSHIFT) {\r\n dest_a = SRS_WGS84_SEMIMAJOR;\r\n dest_b = SRS_WGS84_SEMIMINOR;\r\n dest_es = SRS_WGS84_ESQUARED;\r\n }\r\n\r\n // Do we need to go through geocentric coordinates?\r\n if (source_es === dest_es && source_a === dest_a && !checkParams(source.datum_type) && !checkParams(dest.datum_type)) {\r\n return point;\r\n }\r\n\r\n // Convert to geocentric coordinates.\r\n point = geodeticToGeocentric(point, source_es, source_a);\r\n // Convert between datums\r\n if (checkParams(source.datum_type)) {\r\n point = geocentricToWgs84(point, source.datum_type, source.datum_params);\r\n }\r\n if (checkParams(dest.datum_type)) {\r\n point = geocentricFromWgs84(point, dest.datum_type, dest.datum_params);\r\n }\r\n point = geocentricToGeodetic(point, dest_es, dest_a, dest_b);\r\n\r\n if (dest.datum_type === PJD_GRIDSHIFT) {\r\n var destGridShiftResult = applyGridShift(dest, true, point);\r\n if (destGridShiftResult !== 0) {\r\n return undefined;\r\n }\r\n }\r\n\r\n return point;\r\n}\r\n\r\nexport function applyGridShift(source, inverse, point) {\r\n if (source.grids === null || source.grids.length === 0) {\r\n console.log('Grid shift grids not found');\r\n return -1;\r\n }\r\n var input = {x: -point.x, y: point.y};\r\n var output = {x: Number.NaN, y: Number.NaN};\r\n var onlyMandatoryGrids = false;\r\n var attemptedGrids = [];\r\n outer:\r\n for (var i = 0; i < source.grids.length; i++) {\r\n var grid = source.grids[i];\r\n attemptedGrids.push(grid.name);\r\n if (grid.isNull) {\r\n output = input;\r\n break;\r\n }\r\n onlyMandatoryGrids = grid.mandatory;\r\n if (grid.grid === null) {\r\n if (grid.mandatory) {\r\n console.log(\"Unable to find mandatory grid '\" + grid.name + \"'\");\r\n return -1;\r\n }\r\n continue;\r\n }\r\n var subgrids = grid.grid.subgrids;\r\n for (var j = 0, jj = subgrids.length; j < jj; j++) {\r\n var subgrid = subgrids[j];\r\n // skip tables that don't match our point at all\r\n var epsilon = (Math.abs(subgrid.del[1]) + Math.abs(subgrid.del[0])) / 10000.0;\r\n var minX = subgrid.ll[0] - epsilon;\r\n var minY = subgrid.ll[1] - epsilon;\r\n var maxX = subgrid.ll[0] + (subgrid.lim[0] - 1) * subgrid.del[0] + epsilon;\r\n var maxY = subgrid.ll[1] + (subgrid.lim[1] - 1) * subgrid.del[1] + epsilon;\r\n if (minY > input.y || minX > input.x || maxY < input.y || maxX < input.x ) {\r\n continue;\r\n }\r\n output = applySubgridShift(input, inverse, subgrid);\r\n if (!isNaN(output.x)) {\r\n break outer;\r\n }\r\n }\r\n }\r\n if (isNaN(output.x)) {\r\n console.log(\"Failed to find a grid shift table for location '\"+\r\n -input.x * R2D + \" \" + input.y * R2D + \" tried: '\" + attemptedGrids + \"'\");\r\n return -1;\r\n }\r\n point.x = -output.x;\r\n point.y = output.y;\r\n return 0;\r\n}\r\n\r\nfunction applySubgridShift(pin, inverse, ct) {\r\n var val = {x: Number.NaN, y: Number.NaN};\r\n if (isNaN(pin.x)) { return val; }\r\n var tb = {x: pin.x, y: pin.y};\r\n tb.x -= ct.ll[0];\r\n tb.y -= ct.ll[1];\r\n tb.x = adjust_lon(tb.x - Math.PI) + Math.PI;\r\n var t = nadInterpolate(tb, ct);\r\n if (inverse) {\r\n if (isNaN(t.x)) {\r\n return val;\r\n }\r\n t.x = tb.x - t.x;\r\n t.y = tb.y - t.y;\r\n var i = 9, tol = 1e-12;\r\n var dif, del;\r\n do {\r\n del = nadInterpolate(t, ct);\r\n if (isNaN(del.x)) {\r\n console.log(\"Inverse grid shift iteration failed, presumably at grid edge. Using first approximation.\");\r\n break;\r\n }\r\n dif = {x: tb.x - (del.x + t.x), y: tb.y - (del.y + t.y)};\r\n t.x += dif.x;\r\n t.y += dif.y;\r\n } while (i-- && Math.abs(dif.x) > tol && Math.abs(dif.y) > tol);\r\n if (i < 0) {\r\n console.log(\"Inverse grid shift iterator failed to converge.\");\r\n return val;\r\n }\r\n val.x = adjust_lon(t.x + ct.ll[0]);\r\n val.y = t.y + ct.ll[1];\r\n } else {\r\n if (!isNaN(t.x)) {\r\n val.x = pin.x + t.x;\r\n val.y = pin.y + t.y;\r\n }\r\n }\r\n return val;\r\n}\r\n\r\nfunction nadInterpolate(pin, ct) {\r\n var t = {x: pin.x / ct.del[0], y: pin.y / ct.del[1]};\r\n var indx = {x: Math.floor(t.x), y: Math.floor(t.y)};\r\n var frct = {x: t.x - 1.0 * indx.x, y: t.y - 1.0 * indx.y};\r\n var val= {x: Number.NaN, y: Number.NaN};\r\n var inx;\r\n if (indx.x < 0 || indx.x >= ct.lim[0]) {\r\n return val;\r\n }\r\n if (indx.y < 0 || indx.y >= ct.lim[1]) {\r\n return val;\r\n }\r\n inx = (indx.y * ct.lim[0]) + indx.x;\r\n var f00 = {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};\r\n inx++;\r\n var f10= {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};\r\n inx += ct.lim[0];\r\n var f11 = {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};\r\n inx--;\r\n var f01 = {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};\r\n var m11 = frct.x * frct.y, m10 = frct.x * (1.0 - frct.y),\r\n m00 = (1.0 - frct.x) * (1.0 - frct.y), m01 = (1.0 - frct.x) * frct.y;\r\n val.x = (m00 * f00.x + m10 * f10.x + m01 * f01.x + m11 * f11.x);\r\n val.y = (m00 * f00.y + m10 * f10.y + m01 * f01.y + m11 * f11.y);\r\n return val;\r\n}\r\n", "export default function(crs, denorm, point) {\r\n var xin = point.x,\r\n yin = point.y,\r\n zin = point.z || 0.0;\r\n var v, t, i;\r\n var out = {};\r\n for (i = 0; i < 3; i++) {\r\n if (denorm && i === 2 && point.z === undefined) {\r\n continue;\r\n }\r\n if (i === 0) {\r\n v = xin;\r\n if (\"ew\".indexOf(crs.axis[i]) !== -1) {\r\n t = 'x';\r\n } else {\r\n t = 'y';\r\n }\r\n\r\n }\r\n else if (i === 1) {\r\n v = yin;\r\n if (\"ns\".indexOf(crs.axis[i]) !== -1) {\r\n t = 'y';\r\n } else {\r\n t = 'x';\r\n }\r\n }\r\n else {\r\n v = zin;\r\n t = 'z';\r\n }\r\n switch (crs.axis[i]) {\r\n case 'e':\r\n out[t] = v;\r\n break;\r\n case 'w':\r\n out[t] = -v;\r\n break;\r\n case 'n':\r\n out[t] = v;\r\n break;\r\n case 's':\r\n out[t] = -v;\r\n break;\r\n case 'u':\r\n if (point[t] !== undefined) {\r\n out.z = v;\r\n }\r\n break;\r\n case 'd':\r\n if (point[t] !== undefined) {\r\n out.z = -v;\r\n }\r\n break;\r\n default:\r\n //console.log(\"ERROR: unknow axis (\"+crs.axis[i]+\") - check definition of \"+crs.projName);\r\n return null;\r\n }\r\n }\r\n return out;\r\n}\r\n", "export default function (array){\r\n var out = {\r\n x: array[0],\r\n y: array[1]\r\n };\r\n if (array.length>2) {\r\n out.z = array[2];\r\n }\r\n if (array.length>3) {\r\n out.m = array[3];\r\n }\r\n return out;\r\n}", "export default function (point) {\r\n checkCoord(point.x);\r\n checkCoord(point.y);\r\n}\r\nfunction checkCoord(num) {\r\n if (typeof Number.isFinite === 'function') {\r\n if (Number.isFinite(num)) {\r\n return;\r\n }\r\n throw new TypeError('coordinates must be finite numbers');\r\n }\r\n if (typeof num !== 'number' || num !== num || !isFinite(num)) {\r\n throw new TypeError('coordinates must be finite numbers');\r\n }\r\n}\r\n", "import {D2R, R2D, PJD_3PARAM, PJD_7PARAM, PJD_GRIDSHIFT} from './constants/values';\r\nimport datum_transform from './datum_transform';\r\nimport adjust_axis from './adjust_axis';\r\nimport proj from './Proj';\r\nimport toPoint from './common/toPoint';\r\nimport checkSanity from './checkSanity';\r\n\r\nfunction checkNotWGS(source, dest) {\r\n return (\r\n (source.datum.datum_type === PJD_3PARAM || source.datum.datum_type === PJD_7PARAM || source.datum.datum_type === PJD_GRIDSHIFT) && dest.datumCode !== 'WGS84') ||\r\n ((dest.datum.datum_type === PJD_3PARAM || dest.datum.datum_type === PJD_7PARAM || dest.datum.datum_type === PJD_GRIDSHIFT) && source.datumCode !== 'WGS84');\r\n}\r\n\r\nexport default function transform(source, dest, point, enforceAxis) {\r\n var wgs84;\r\n if (Array.isArray(point)) {\r\n point = toPoint(point);\r\n } else {\r\n // Clone the point object so inputs don't get modified\r\n point = {\r\n x: point.x,\r\n y: point.y,\r\n z: point.z,\r\n m: point.m\r\n };\r\n }\r\n var hasZ = point.z !== undefined;\r\n checkSanity(point);\r\n // Workaround for datum shifts towgs84, if either source or destination projection is not wgs84\r\n if (source.datum && dest.datum && checkNotWGS(source, dest)) {\r\n wgs84 = new proj('WGS84');\r\n point = transform(source, wgs84, point, enforceAxis);\r\n source = wgs84;\r\n }\r\n // DGR, 2010/11/12\r\n if (enforceAxis && source.axis !== 'enu') {\r\n point = adjust_axis(source, false, point);\r\n }\r\n // Transform source points to long/lat, if they aren't already.\r\n if (source.projName === 'longlat') {\r\n point = {\r\n x: point.x * D2R,\r\n y: point.y * D2R,\r\n z: point.z || 0\r\n };\r\n } else {\r\n if (source.to_meter) {\r\n point = {\r\n x: point.x * source.to_meter,\r\n y: point.y * source.to_meter,\r\n z: point.z || 0\r\n };\r\n }\r\n point = source.inverse(point); // Convert Cartesian to longlat\r\n if (!point) {\r\n return;\r\n }\r\n }\r\n // Adjust for the prime meridian if necessary\r\n if (source.from_greenwich) {\r\n point.x += source.from_greenwich;\r\n }\r\n\r\n // Convert datums if needed, and if possible.\r\n point = datum_transform(source.datum, dest.datum, point);\r\n if (!point) {\r\n return;\r\n }\r\n\r\n // Adjust for the prime meridian if necessary\r\n if (dest.from_greenwich) {\r\n point = {\r\n x: point.x - dest.from_greenwich,\r\n y: point.y,\r\n z: point.z || 0\r\n };\r\n }\r\n\r\n if (dest.projName === 'longlat') {\r\n // convert radians to decimal degrees\r\n point = {\r\n x: point.x * R2D,\r\n y: point.y * R2D,\r\n z: point.z || 0\r\n };\r\n } else { // else project\r\n point = dest.forward(point);\r\n if (dest.to_meter) {\r\n point = {\r\n x: point.x / dest.to_meter,\r\n y: point.y / dest.to_meter,\r\n z: point.z || 0\r\n };\r\n }\r\n }\r\n\r\n // DGR, 2010/11/12\r\n if (enforceAxis && dest.axis !== 'enu') {\r\n return adjust_axis(dest, true, point);\r\n }\r\n\r\n if (point && !hasZ) {\r\n delete point.z;\r\n }\r\n return point;\r\n}\r\n", "import proj from './Proj';\r\nimport transform from './transform';\r\nvar wgs84 = proj('WGS84');\r\n\r\nfunction transformer(from, to, coords, enforceAxis) {\r\n var transformedArray, out, keys;\r\n if (Array.isArray(coords)) {\r\n transformedArray = transform(from, to, coords, enforceAxis) || {x: NaN, y: NaN};\r\n if (coords.length > 2) {\r\n if ((typeof from.name !== 'undefined' && from.name === 'geocent') || (typeof to.name !== 'undefined' && to.name === 'geocent')) {\r\n if (typeof transformedArray.z === 'number') {\r\n return [transformedArray.x, transformedArray.y, transformedArray.z].concat(coords.splice(3));\r\n } else {\r\n return [transformedArray.x, transformedArray.y, coords[2]].concat(coords.splice(3));\r\n }\r\n } else {\r\n return [transformedArray.x, transformedArray.y].concat(coords.splice(2));\r\n }\r\n } else {\r\n return [transformedArray.x, transformedArray.y];\r\n }\r\n } else {\r\n out = transform(from, to, coords, enforceAxis);\r\n keys = Object.keys(coords);\r\n if (keys.length === 2) {\r\n return out;\r\n }\r\n keys.forEach(function (key) {\r\n if ((typeof from.name !== 'undefined' && from.name === 'geocent') || (typeof to.name !== 'undefined' && to.name === 'geocent')) {\r\n if (key === 'x' || key === 'y' || key === 'z') {\r\n return;\r\n }\r\n } else {\r\n if (key === 'x' || key === 'y') {\r\n return;\r\n }\r\n }\r\n out[key] = coords[key];\r\n });\r\n return out;\r\n }\r\n}\r\n\r\nfunction checkProj(item) {\r\n if (item instanceof proj) {\r\n return item;\r\n }\r\n if (item.oProj) {\r\n return item.oProj;\r\n }\r\n return proj(item);\r\n}\r\n\r\nfunction proj4(fromProj, toProj, coord) {\r\n fromProj = checkProj(fromProj);\r\n var single = false;\r\n var obj;\r\n if (typeof toProj === 'undefined') {\r\n toProj = fromProj;\r\n fromProj = wgs84;\r\n single = true;\r\n } else if (typeof toProj.x !== 'undefined' || Array.isArray(toProj)) {\r\n coord = toProj;\r\n toProj = fromProj;\r\n fromProj = wgs84;\r\n single = true;\r\n }\r\n toProj = checkProj(toProj);\r\n if (coord) {\r\n return transformer(fromProj, toProj, coord);\r\n } else {\r\n obj = {\r\n forward: function (coords, enforceAxis) {\r\n return transformer(fromProj, toProj, coords, enforceAxis);\r\n },\r\n inverse: function (coords, enforceAxis) {\r\n return transformer(toProj, fromProj, coords, enforceAxis);\r\n }\r\n };\r\n if (single) {\r\n obj.oProj = toProj;\r\n }\r\n return obj;\r\n }\r\n}\r\nexport default proj4;", "\r\n\r\n\r\n/**\r\n * UTM zones are grouped, and assigned to one of a group of 6\r\n * sets.\r\n *\r\n * {int} @private\r\n */\r\nvar NUM_100K_SETS = 6;\r\n\r\n/**\r\n * The column letters (for easting) of the lower left value, per\r\n * set.\r\n *\r\n * {string} @private\r\n */\r\nvar SET_ORIGIN_COLUMN_LETTERS = 'AJSAJS';\r\n\r\n/**\r\n * The row letters (for northing) of the lower left value, per\r\n * set.\r\n *\r\n * {string} @private\r\n */\r\nvar SET_ORIGIN_ROW_LETTERS = 'AFAFAF';\r\n\r\nvar A = 65; // A\r\nvar I = 73; // I\r\nvar O = 79; // O\r\nvar V = 86; // V\r\nvar Z = 90; // Z\r\nexport default {\r\n forward: forward,\r\n inverse: inverse,\r\n toPoint: toPoint\r\n};\r\n/**\r\n * Conversion of lat/lon to MGRS.\r\n *\r\n * @param {object} ll Object literal with lat and lon properties on a\r\n * WGS84 ellipsoid.\r\n * @param {int} accuracy Accuracy in digits (5 for 1 m, 4 for 10 m, 3 for\r\n * 100 m, 2 for 1000 m or 1 for 10000 m). Optional, default is 5.\r\n * @return {string} the MGRS string for the given location and accuracy.\r\n */\r\nexport function forward(ll, accuracy) {\r\n accuracy = accuracy || 5; // default accuracy 1m\r\n return encode(LLtoUTM({\r\n lat: ll[1],\r\n lon: ll[0]\r\n }), accuracy);\r\n};\r\n\r\n/**\r\n * Conversion of MGRS to lat/lon.\r\n *\r\n * @param {string} mgrs MGRS string.\r\n * @return {array} An array with left (longitude), bottom (latitude), right\r\n * (longitude) and top (latitude) values in WGS84, representing the\r\n * bounding box for the provided MGRS reference.\r\n */\r\nexport function inverse(mgrs) {\r\n var bbox = UTMtoLL(decode(mgrs.toUpperCase()));\r\n if (bbox.lat && bbox.lon) {\r\n return [bbox.lon, bbox.lat, bbox.lon, bbox.lat];\r\n }\r\n return [bbox.left, bbox.bottom, bbox.right, bbox.top];\r\n};\r\n\r\nexport function toPoint(mgrs) {\r\n var bbox = UTMtoLL(decode(mgrs.toUpperCase()));\r\n if (bbox.lat && bbox.lon) {\r\n return [bbox.lon, bbox.lat];\r\n }\r\n return [(bbox.left + bbox.right) / 2, (bbox.top + bbox.bottom) / 2];\r\n};\r\n/**\r\n * Conversion from degrees to radians.\r\n *\r\n * @private\r\n * @param {number} deg the angle in degrees.\r\n * @return {number} the angle in radians.\r\n */\r\nfunction degToRad(deg) {\r\n return (deg * (Math.PI / 180.0));\r\n}\r\n\r\n/**\r\n * Conversion from radians to degrees.\r\n *\r\n * @private\r\n * @param {number} rad the angle in radians.\r\n * @return {number} the angle in degrees.\r\n */\r\nfunction radToDeg(rad) {\r\n return (180.0 * (rad / Math.PI));\r\n}\r\n\r\n/**\r\n * Converts a set of Longitude and Latitude co-ordinates to UTM\r\n * using the WGS84 ellipsoid.\r\n *\r\n * @private\r\n * @param {object} ll Object literal with lat and lon properties\r\n * representing the WGS84 coordinate to be converted.\r\n * @return {object} Object literal containing the UTM value with easting,\r\n * northing, zoneNumber and zoneLetter properties, and an optional\r\n * accuracy property in digits. Returns null if the conversion failed.\r\n */\r\nfunction LLtoUTM(ll) {\r\n var Lat = ll.lat;\r\n var Long = ll.lon;\r\n var a = 6378137.0; //ellip.radius;\r\n var eccSquared = 0.00669438; //ellip.eccsq;\r\n var k0 = 0.9996;\r\n var LongOrigin;\r\n var eccPrimeSquared;\r\n var N, T, C, A, M;\r\n var LatRad = degToRad(Lat);\r\n var LongRad = degToRad(Long);\r\n var LongOriginRad;\r\n var ZoneNumber;\r\n // (int)\r\n ZoneNumber = Math.floor((Long + 180) / 6) + 1;\r\n\r\n //Make sure the longitude 180.00 is in Zone 60\r\n if (Long === 180) {\r\n ZoneNumber = 60;\r\n }\r\n\r\n // Special zone for Norway\r\n if (Lat >= 56.0 && Lat < 64.0 && Long >= 3.0 && Long < 12.0) {\r\n ZoneNumber = 32;\r\n }\r\n\r\n // Special zones for Svalbard\r\n if (Lat >= 72.0 && Lat < 84.0) {\r\n if (Long >= 0.0 && Long < 9.0) {\r\n ZoneNumber = 31;\r\n }\r\n else if (Long >= 9.0 && Long < 21.0) {\r\n ZoneNumber = 33;\r\n }\r\n else if (Long >= 21.0 && Long < 33.0) {\r\n ZoneNumber = 35;\r\n }\r\n else if (Long >= 33.0 && Long < 42.0) {\r\n ZoneNumber = 37;\r\n }\r\n }\r\n\r\n LongOrigin = (ZoneNumber - 1) * 6 - 180 + 3; //+3 puts origin\r\n // in middle of\r\n // zone\r\n LongOriginRad = degToRad(LongOrigin);\r\n\r\n eccPrimeSquared = (eccSquared) / (1 - eccSquared);\r\n\r\n N = a / Math.sqrt(1 - eccSquared * Math.sin(LatRad) * Math.sin(LatRad));\r\n T = Math.tan(LatRad) * Math.tan(LatRad);\r\n C = eccPrimeSquared * Math.cos(LatRad) * Math.cos(LatRad);\r\n A = Math.cos(LatRad) * (LongRad - LongOriginRad);\r\n\r\n M = a * ((1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256) * LatRad - (3 * eccSquared / 8 + 3 * eccSquared * eccSquared / 32 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(2 * LatRad) + (15 * eccSquared * eccSquared / 256 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(4 * LatRad) - (35 * eccSquared * eccSquared * eccSquared / 3072) * Math.sin(6 * LatRad));\r\n\r\n var UTMEasting = (k0 * N * (A + (1 - T + C) * A * A * A / 6.0 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120.0) + 500000.0);\r\n\r\n var UTMNorthing = (k0 * (M + N * Math.tan(LatRad) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24.0 + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A * A * A * A * A * A / 720.0)));\r\n if (Lat < 0.0) {\r\n UTMNorthing += 10000000.0; //10000000 meter offset for\r\n // southern hemisphere\r\n }\r\n\r\n return {\r\n northing: Math.round(UTMNorthing),\r\n easting: Math.round(UTMEasting),\r\n zoneNumber: ZoneNumber,\r\n zoneLetter: getLetterDesignator(Lat)\r\n };\r\n}\r\n\r\n/**\r\n * Converts UTM coords to lat/long, using the WGS84 ellipsoid. This is a convenience\r\n * class where the Zone can be specified as a single string eg.\"60N\" which\r\n * is then broken down into the ZoneNumber and ZoneLetter.\r\n *\r\n * @private\r\n * @param {object} utm An object literal with northing, easting, zoneNumber\r\n * and zoneLetter properties. If an optional accuracy property is\r\n * provided (in meters), a bounding box will be returned instead of\r\n * latitude and longitude.\r\n * @return {object} An object literal containing either lat and lon values\r\n * (if no accuracy was provided), or top, right, bottom and left values\r\n * for the bounding box calculated according to the provided accuracy.\r\n * Returns null if the conversion failed.\r\n */\r\nfunction UTMtoLL(utm) {\r\n\r\n var UTMNorthing = utm.northing;\r\n var UTMEasting = utm.easting;\r\n var zoneLetter = utm.zoneLetter;\r\n var zoneNumber = utm.zoneNumber;\r\n // check the ZoneNummber is valid\r\n if (zoneNumber < 0 || zoneNumber > 60) {\r\n return null;\r\n }\r\n\r\n var k0 = 0.9996;\r\n var a = 6378137.0; //ellip.radius;\r\n var eccSquared = 0.00669438; //ellip.eccsq;\r\n var eccPrimeSquared;\r\n var e1 = (1 - Math.sqrt(1 - eccSquared)) / (1 + Math.sqrt(1 - eccSquared));\r\n var N1, T1, C1, R1, D, M;\r\n var LongOrigin;\r\n var mu, phi1Rad;\r\n\r\n // remove 500,000 meter offset for longitude\r\n var x = UTMEasting - 500000.0;\r\n var y = UTMNorthing;\r\n\r\n // We must know somehow if we are in the Northern or Southern\r\n // hemisphere, this is the only time we use the letter So even\r\n // if the Zone letter isn't exactly correct it should indicate\r\n // the hemisphere correctly\r\n if (zoneLetter < 'N') {\r\n y -= 10000000.0; // remove 10,000,000 meter offset used\r\n // for southern hemisphere\r\n }\r\n\r\n // There are 60 zones with zone 1 being at West -180 to -174\r\n LongOrigin = (zoneNumber - 1) * 6 - 180 + 3; // +3 puts origin\r\n // in middle of\r\n // zone\r\n\r\n eccPrimeSquared = (eccSquared) / (1 - eccSquared);\r\n\r\n M = y / k0;\r\n mu = M / (a * (1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256));\r\n\r\n phi1Rad = mu + (3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * Math.sin(2 * mu) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * Math.sin(4 * mu) + (151 * e1 * e1 * e1 / 96) * Math.sin(6 * mu);\r\n // double phi1 = ProjMath.radToDeg(phi1Rad);\r\n\r\n N1 = a / Math.sqrt(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad));\r\n T1 = Math.tan(phi1Rad) * Math.tan(phi1Rad);\r\n C1 = eccPrimeSquared * Math.cos(phi1Rad) * Math.cos(phi1Rad);\r\n R1 = a * (1 - eccSquared) / Math.pow(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad), 1.5);\r\n D = x / (N1 * k0);\r\n\r\n var lat = phi1Rad - (N1 * Math.tan(phi1Rad) / R1) * (D * D / 2 - (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * eccPrimeSquared) * D * D * D * D / 24 + (61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * eccPrimeSquared - 3 * C1 * C1) * D * D * D * D * D * D / 720);\r\n lat = radToDeg(lat);\r\n\r\n var lon = (D - (1 + 2 * T1 + C1) * D * D * D / 6 + (5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * eccPrimeSquared + 24 * T1 * T1) * D * D * D * D * D / 120) / Math.cos(phi1Rad);\r\n lon = LongOrigin + radToDeg(lon);\r\n\r\n var result;\r\n if (utm.accuracy) {\r\n var topRight = UTMtoLL({\r\n northing: utm.northing + utm.accuracy,\r\n easting: utm.easting + utm.accuracy,\r\n zoneLetter: utm.zoneLetter,\r\n zoneNumber: utm.zoneNumber\r\n });\r\n result = {\r\n top: topRight.lat,\r\n right: topRight.lon,\r\n bottom: lat,\r\n left: lon\r\n };\r\n }\r\n else {\r\n result = {\r\n lat: lat,\r\n lon: lon\r\n };\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Calculates the MGRS letter designator for the given latitude.\r\n *\r\n * @private\r\n * @param {number} lat The latitude in WGS84 to get the letter designator\r\n * for.\r\n * @return {char} The letter designator.\r\n */\r\nfunction getLetterDesignator(lat) {\r\n //This is here as an error flag to show that the Latitude is\r\n //outside MGRS limits\r\n var LetterDesignator = 'Z';\r\n\r\n if ((84 >= lat) && (lat >= 72)) {\r\n LetterDesignator = 'X';\r\n }\r\n else if ((72 > lat) && (lat >= 64)) {\r\n LetterDesignator = 'W';\r\n }\r\n else if ((64 > lat) && (lat >= 56)) {\r\n LetterDesignator = 'V';\r\n }\r\n else if ((56 > lat) && (lat >= 48)) {\r\n LetterDesignator = 'U';\r\n }\r\n else if ((48 > lat) && (lat >= 40)) {\r\n LetterDesignator = 'T';\r\n }\r\n else if ((40 > lat) && (lat >= 32)) {\r\n LetterDesignator = 'S';\r\n }\r\n else if ((32 > lat) && (lat >= 24)) {\r\n LetterDesignator = 'R';\r\n }\r\n else if ((24 > lat) && (lat >= 16)) {\r\n LetterDesignator = 'Q';\r\n }\r\n else if ((16 > lat) && (lat >= 8)) {\r\n LetterDesignator = 'P';\r\n }\r\n else if ((8 > lat) && (lat >= 0)) {\r\n LetterDesignator = 'N';\r\n }\r\n else if ((0 > lat) && (lat >= -8)) {\r\n LetterDesignator = 'M';\r\n }\r\n else if ((-8 > lat) && (lat >= -16)) {\r\n LetterDesignator = 'L';\r\n }\r\n else if ((-16 > lat) && (lat >= -24)) {\r\n LetterDesignator = 'K';\r\n }\r\n else if ((-24 > lat) && (lat >= -32)) {\r\n LetterDesignator = 'J';\r\n }\r\n else if ((-32 > lat) && (lat >= -40)) {\r\n LetterDesignator = 'H';\r\n }\r\n else if ((-40 > lat) && (lat >= -48)) {\r\n LetterDesignator = 'G';\r\n }\r\n else if ((-48 > lat) && (lat >= -56)) {\r\n LetterDesignator = 'F';\r\n }\r\n else if ((-56 > lat) && (lat >= -64)) {\r\n LetterDesignator = 'E';\r\n }\r\n else if ((-64 > lat) && (lat >= -72)) {\r\n LetterDesignator = 'D';\r\n }\r\n else if ((-72 > lat) && (lat >= -80)) {\r\n LetterDesignator = 'C';\r\n }\r\n return LetterDesignator;\r\n}\r\n\r\n/**\r\n * Encodes a UTM location as MGRS string.\r\n *\r\n * @private\r\n * @param {object} utm An object literal with easting, northing,\r\n * zoneLetter, zoneNumber\r\n * @param {number} accuracy Accuracy in digits (1-5).\r\n * @return {string} MGRS string for the given UTM location.\r\n */\r\nfunction encode(utm, accuracy) {\r\n // prepend with leading zeroes\r\n var seasting = \"00000\" + utm.easting,\r\n snorthing = \"00000\" + utm.northing;\r\n\r\n return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthing.length - 5, accuracy);\r\n}\r\n\r\n/**\r\n * Get the two letter 100k designator for a given UTM easting,\r\n * northing and zone number value.\r\n *\r\n * @private\r\n * @param {number} easting\r\n * @param {number} northing\r\n * @param {number} zoneNumber\r\n * @return the two letter 100k designator for the given UTM location.\r\n */\r\nfunction get100kID(easting, northing, zoneNumber) {\r\n var setParm = get100kSetForZone(zoneNumber);\r\n var setColumn = Math.floor(easting / 100000);\r\n var setRow = Math.floor(northing / 100000) % 20;\r\n return getLetter100kID(setColumn, setRow, setParm);\r\n}\r\n\r\n/**\r\n * Given a UTM zone number, figure out the MGRS 100K set it is in.\r\n *\r\n * @private\r\n * @param {number} i An UTM zone number.\r\n * @return {number} the 100k set the UTM zone is in.\r\n */\r\nfunction get100kSetForZone(i) {\r\n var setParm = i % NUM_100K_SETS;\r\n if (setParm === 0) {\r\n setParm = NUM_100K_SETS;\r\n }\r\n\r\n return setParm;\r\n}\r\n\r\n/**\r\n * Get the two-letter MGRS 100k designator given information\r\n * translated from the UTM northing, easting and zone number.\r\n *\r\n * @private\r\n * @param {number} column the column index as it relates to the MGRS\r\n * 100k set spreadsheet, created from the UTM easting.\r\n * Values are 1-8.\r\n * @param {number} row the row index as it relates to the MGRS 100k set\r\n * spreadsheet, created from the UTM northing value. Values\r\n * are from 0-19.\r\n * @param {number} parm the set block, as it relates to the MGRS 100k set\r\n * spreadsheet, created from the UTM zone. Values are from\r\n * 1-60.\r\n * @return two letter MGRS 100k code.\r\n */\r\nfunction getLetter100kID(column, row, parm) {\r\n // colOrigin and rowOrigin are the letters at the origin of the set\r\n var index = parm - 1;\r\n var colOrigin = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(index);\r\n var rowOrigin = SET_ORIGIN_ROW_LETTERS.charCodeAt(index);\r\n\r\n // colInt and rowInt are the letters to build to return\r\n var colInt = colOrigin + column - 1;\r\n var rowInt = rowOrigin + row;\r\n var rollover = false;\r\n\r\n if (colInt > Z) {\r\n colInt = colInt - Z + A - 1;\r\n rollover = true;\r\n }\r\n\r\n if (colInt === I || (colOrigin < I && colInt > I) || ((colInt > I || colOrigin < I) && rollover)) {\r\n colInt++;\r\n }\r\n\r\n if (colInt === O || (colOrigin < O && colInt > O) || ((colInt > O || colOrigin < O) && rollover)) {\r\n colInt++;\r\n\r\n if (colInt === I) {\r\n colInt++;\r\n }\r\n }\r\n\r\n if (colInt > Z) {\r\n colInt = colInt - Z + A - 1;\r\n }\r\n\r\n if (rowInt > V) {\r\n rowInt = rowInt - V + A - 1;\r\n rollover = true;\r\n }\r\n else {\r\n rollover = false;\r\n }\r\n\r\n if (((rowInt === I) || ((rowOrigin < I) && (rowInt > I))) || (((rowInt > I) || (rowOrigin < I)) && rollover)) {\r\n rowInt++;\r\n }\r\n\r\n if (((rowInt === O) || ((rowOrigin < O) && (rowInt > O))) || (((rowInt > O) || (rowOrigin < O)) && rollover)) {\r\n rowInt++;\r\n\r\n if (rowInt === I) {\r\n rowInt++;\r\n }\r\n }\r\n\r\n if (rowInt > V) {\r\n rowInt = rowInt - V + A - 1;\r\n }\r\n\r\n var twoLetter = String.fromCharCode(colInt) + String.fromCharCode(rowInt);\r\n return twoLetter;\r\n}\r\n\r\n/**\r\n * Decode the UTM parameters from a MGRS string.\r\n *\r\n * @private\r\n * @param {string} mgrsString an UPPERCASE coordinate string is expected.\r\n * @return {object} An object literal with easting, northing, zoneLetter,\r\n * zoneNumber and accuracy (in meters) properties.\r\n */\r\nfunction decode(mgrsString) {\r\n\r\n if (mgrsString && mgrsString.length === 0) {\r\n throw (\"MGRSPoint coverting from nothing\");\r\n }\r\n\r\n var length = mgrsString.length;\r\n\r\n var hunK = null;\r\n var sb = \"\";\r\n var testChar;\r\n var i = 0;\r\n\r\n // get Zone number\r\n while (!(/[A-Z]/).test(testChar = mgrsString.charAt(i))) {\r\n if (i >= 2) {\r\n throw (\"MGRSPoint bad conversion from: \" + mgrsString);\r\n }\r\n sb += testChar;\r\n i++;\r\n }\r\n\r\n var zoneNumber = parseInt(sb, 10);\r\n\r\n if (i === 0 || i + 3 > length) {\r\n // A good MGRS string has to be 4-5 digits long,\r\n // ##AAA/#AAA at least.\r\n throw (\"MGRSPoint bad conversion from: \" + mgrsString);\r\n }\r\n\r\n var zoneLetter = mgrsString.charAt(i++);\r\n\r\n // Should we check the zone letter here? Why not.\r\n if (zoneLetter <= 'A' || zoneLetter === 'B' || zoneLetter === 'Y' || zoneLetter >= 'Z' || zoneLetter === 'I' || zoneLetter === 'O') {\r\n throw (\"MGRSPoint zone letter \" + zoneLetter + \" not handled: \" + mgrsString);\r\n }\r\n\r\n hunK = mgrsString.substring(i, i += 2);\r\n\r\n var set = get100kSetForZone(zoneNumber);\r\n\r\n var east100k = getEastingFromChar(hunK.charAt(0), set);\r\n var north100k = getNorthingFromChar(hunK.charAt(1), set);\r\n\r\n // We have a bug where the northing may be 2000000 too low.\r\n // How\r\n // do we know when to roll over?\r\n\r\n while (north100k < getMinNorthing(zoneLetter)) {\r\n north100k += 2000000;\r\n }\r\n\r\n // calculate the char index for easting/northing separator\r\n var remainder = length - i;\r\n\r\n if (remainder % 2 !== 0) {\r\n throw (\"MGRSPoint has to have an even number \\nof digits after the zone letter and two 100km letters - front \\nhalf for easting meters, second half for \\nnorthing meters\" + mgrsString);\r\n }\r\n\r\n var sep = remainder / 2;\r\n\r\n var sepEasting = 0.0;\r\n var sepNorthing = 0.0;\r\n var accuracyBonus, sepEastingString, sepNorthingString, easting, northing;\r\n if (sep > 0) {\r\n accuracyBonus = 100000.0 / Math.pow(10, sep);\r\n sepEastingString = mgrsString.substring(i, i + sep);\r\n sepEasting = parseFloat(sepEastingString) * accuracyBonus;\r\n sepNorthingString = mgrsString.substring(i + sep);\r\n sepNorthing = parseFloat(sepNorthingString) * accuracyBonus;\r\n }\r\n\r\n easting = sepEasting + east100k;\r\n northing = sepNorthing + north100k;\r\n\r\n return {\r\n easting: easting,\r\n northing: northing,\r\n zoneLetter: zoneLetter,\r\n zoneNumber: zoneNumber,\r\n accuracy: accuracyBonus\r\n };\r\n}\r\n\r\n/**\r\n * Given the first letter from a two-letter MGRS 100k zone, and given the\r\n * MGRS table set for the zone number, figure out the easting value that\r\n * should be added to the other, secondary easting value.\r\n *\r\n * @private\r\n * @param {char} e The first letter from a two-letter MGRS 100´k zone.\r\n * @param {number} set The MGRS table set for the zone number.\r\n * @return {number} The easting value for the given letter and set.\r\n */\r\nfunction getEastingFromChar(e, set) {\r\n // colOrigin is the letter at the origin of the set for the\r\n // column\r\n var curCol = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(set - 1);\r\n var eastingValue = 100000.0;\r\n var rewindMarker = false;\r\n\r\n while (curCol !== e.charCodeAt(0)) {\r\n curCol++;\r\n if (curCol === I) {\r\n curCol++;\r\n }\r\n if (curCol === O) {\r\n curCol++;\r\n }\r\n if (curCol > Z) {\r\n if (rewindMarker) {\r\n throw (\"Bad character: \" + e);\r\n }\r\n curCol = A;\r\n rewindMarker = true;\r\n }\r\n eastingValue += 100000.0;\r\n }\r\n\r\n return eastingValue;\r\n}\r\n\r\n/**\r\n * Given the second letter from a two-letter MGRS 100k zone, and given the\r\n * MGRS table set for the zone number, figure out the northing value that\r\n * should be added to the other, secondary northing value. You have to\r\n * remember that Northings are determined from the equator, and the vertical\r\n * cycle of letters mean a 2000000 additional northing meters. This happens\r\n * approx. every 18 degrees of latitude. This method does *NOT* count any\r\n * additional northings. You have to figure out how many 2000000 meters need\r\n * to be added for the zone letter of the MGRS coordinate.\r\n *\r\n * @private\r\n * @param {char} n Second letter of the MGRS 100k zone\r\n * @param {number} set The MGRS table set number, which is dependent on the\r\n * UTM zone number.\r\n * @return {number} The northing value for the given letter and set.\r\n */\r\nfunction getNorthingFromChar(n, set) {\r\n\r\n if (n > 'V') {\r\n throw (\"MGRSPoint given invalid Northing \" + n);\r\n }\r\n\r\n // rowOrigin is the letter at the origin of the set for the\r\n // column\r\n var curRow = SET_ORIGIN_ROW_LETTERS.charCodeAt(set - 1);\r\n var northingValue = 0.0;\r\n var rewindMarker = false;\r\n\r\n while (curRow !== n.charCodeAt(0)) {\r\n curRow++;\r\n if (curRow === I) {\r\n curRow++;\r\n }\r\n if (curRow === O) {\r\n curRow++;\r\n }\r\n // fixing a bug making whole application hang in this loop\r\n // when 'n' is a wrong character\r\n if (curRow > V) {\r\n if (rewindMarker) { // making sure that this loop ends\r\n throw (\"Bad character: \" + n);\r\n }\r\n curRow = A;\r\n rewindMarker = true;\r\n }\r\n northingValue += 100000.0;\r\n }\r\n\r\n return northingValue;\r\n}\r\n\r\n/**\r\n * The function getMinNorthing returns the minimum northing value of a MGRS\r\n * zone.\r\n *\r\n * Ported from Geotrans' c Lattitude_Band_Value structure table.\r\n *\r\n * @private\r\n * @param {char} zoneLetter The MGRS zone to get the min northing for.\r\n * @return {number}\r\n */\r\nfunction getMinNorthing(zoneLetter) {\r\n var northing;\r\n switch (zoneLetter) {\r\n case 'C':\r\n northing = 1100000.0;\r\n break;\r\n case 'D':\r\n northing = 2000000.0;\r\n break;\r\n case 'E':\r\n northing = 2800000.0;\r\n break;\r\n case 'F':\r\n northing = 3700000.0;\r\n break;\r\n case 'G':\r\n northing = 4600000.0;\r\n break;\r\n case 'H':\r\n northing = 5500000.0;\r\n break;\r\n case 'J':\r\n northing = 6400000.0;\r\n break;\r\n case 'K':\r\n northing = 7300000.0;\r\n break;\r\n case 'L':\r\n northing = 8200000.0;\r\n break;\r\n case 'M':\r\n northing = 9100000.0;\r\n break;\r\n case 'N':\r\n northing = 0.0;\r\n break;\r\n case 'P':\r\n northing = 800000.0;\r\n break;\r\n case 'Q':\r\n northing = 1700000.0;\r\n break;\r\n case 'R':\r\n northing = 2600000.0;\r\n break;\r\n case 'S':\r\n northing = 3500000.0;\r\n break;\r\n case 'T':\r\n northing = 4400000.0;\r\n break;\r\n case 'U':\r\n northing = 5300000.0;\r\n break;\r\n case 'V':\r\n northing = 6200000.0;\r\n break;\r\n case 'W':\r\n northing = 7000000.0;\r\n break;\r\n case 'X':\r\n northing = 7900000.0;\r\n break;\r\n default:\r\n northing = -1.0;\r\n }\r\n if (northing >= 0.0) {\r\n return northing;\r\n }\r\n else {\r\n throw (\"Invalid zone letter: \" + zoneLetter);\r\n }\r\n\r\n}\r\n", "import {toPoint, forward} from 'mgrs';\r\n\r\nfunction Point(x, y, z) {\r\n if (!(this instanceof Point)) {\r\n return new Point(x, y, z);\r\n }\r\n if (Array.isArray(x)) {\r\n this.x = x[0];\r\n this.y = x[1];\r\n this.z = x[2] || 0.0;\r\n } else if(typeof x === 'object') {\r\n this.x = x.x;\r\n this.y = x.y;\r\n this.z = x.z || 0.0;\r\n } else if (typeof x === 'string' && typeof y === 'undefined') {\r\n var coords = x.split(',');\r\n this.x = parseFloat(coords[0], 10);\r\n this.y = parseFloat(coords[1], 10);\r\n this.z = parseFloat(coords[2], 10) || 0.0;\r\n } else {\r\n this.x = x;\r\n this.y = y;\r\n this.z = z || 0.0;\r\n }\r\n console.warn('proj4.Point will be removed in version 3, use proj4.toPoint');\r\n}\r\n\r\nPoint.fromMGRS = function(mgrsStr) {\r\n return new Point(toPoint(mgrsStr));\r\n};\r\nPoint.prototype.toMGRS = function(accuracy) {\r\n return forward([this.x, this.y], accuracy);\r\n};\r\nexport default Point;\r\n", "var C00 = 1;\r\nvar C02 = 0.25;\r\nvar C04 = 0.046875;\r\nvar C06 = 0.01953125;\r\nvar C08 = 0.01068115234375;\r\nvar C22 = 0.75;\r\nvar C44 = 0.46875;\r\nvar C46 = 0.01302083333333333333;\r\nvar C48 = 0.00712076822916666666;\r\nvar C66 = 0.36458333333333333333;\r\nvar C68 = 0.00569661458333333333;\r\nvar C88 = 0.3076171875;\r\n\r\nexport default function(es) {\r\n var en = [];\r\n en[0] = C00 - es * (C02 + es * (C04 + es * (C06 + es * C08)));\r\n en[1] = es * (C22 - es * (C04 + es * (C06 + es * C08)));\r\n var t = es * es;\r\n en[2] = t * (C44 - es * (C46 + es * C48));\r\n t *= es;\r\n en[3] = t * (C66 - es * C68);\r\n en[4] = t * es * C88;\r\n return en;\r\n}", "export default function(phi, sphi, cphi, en) {\r\n cphi *= sphi;\r\n sphi *= sphi;\r\n return (en[0] * phi - cphi * (en[1] + sphi * (en[2] + sphi * (en[3] + sphi * en[4]))));\r\n}", "import pj_mlfn from \"./pj_mlfn\";\r\nimport {EPSLN} from '../constants/values';\r\n\r\nvar MAX_ITER = 20;\r\n\r\nexport default function(arg, es, en) {\r\n var k = 1 / (1 - es);\r\n var phi = arg;\r\n for (var i = MAX_ITER; i; --i) { /* rarely goes over 2 iterations */\r\n var s = Math.sin(phi);\r\n var t = 1 - es * s * s;\r\n //t = this.pj_mlfn(phi, s, Math.cos(phi), en) - arg;\r\n //phi -= t * (t * Math.sqrt(t)) * k;\r\n t = (pj_mlfn(phi, s, Math.cos(phi), en) - arg) * (t * Math.sqrt(t)) * k;\r\n phi -= t;\r\n if (Math.abs(t) < EPSLN) {\r\n return phi;\r\n }\r\n }\r\n //..reportError(\"cass:pj_inv_mlfn: Convergence error\");\r\n return phi;\r\n}\r\n", "// Heavily based on this tmerc projection implementation\r\n// https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/tmerc.js\r\n\r\nimport pj_enfn from '../common/pj_enfn';\r\nimport pj_mlfn from '../common/pj_mlfn';\r\nimport pj_inv_mlfn from '../common/pj_inv_mlfn';\r\nimport adjust_lon from '../common/adjust_lon';\r\n\r\nimport {EPSLN, HALF_PI} from '../constants/values';\r\nimport sign from '../common/sign';\r\n\r\nexport function init() {\r\n this.x0 = this.x0 !== undefined ? this.x0 : 0;\r\n this.y0 = this.y0 !== undefined ? this.y0 : 0;\r\n this.long0 = this.long0 !== undefined ? this.long0 : 0;\r\n this.lat0 = this.lat0 !== undefined ? this.lat0 : 0;\r\n\r\n if (this.es) {\r\n this.en = pj_enfn(this.es);\r\n this.ml0 = pj_mlfn(this.lat0, Math.sin(this.lat0), Math.cos(this.lat0), this.en);\r\n }\r\n}\r\n\r\n/**\r\n Transverse Mercator Forward - long/lat to x/y\r\n long/lat in radians\r\n */\r\nexport function forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n\r\n var delta_lon = adjust_lon(lon - this.long0);\r\n var con;\r\n var x, y;\r\n var sin_phi = Math.sin(lat);\r\n var cos_phi = Math.cos(lat);\r\n\r\n if (!this.es) {\r\n var b = cos_phi * Math.sin(delta_lon);\r\n\r\n if ((Math.abs(Math.abs(b) - 1)) < EPSLN) {\r\n return (93);\r\n }\r\n else {\r\n x = 0.5 * this.a * this.k0 * Math.log((1 + b) / (1 - b)) + this.x0;\r\n y = cos_phi * Math.cos(delta_lon) / Math.sqrt(1 - Math.pow(b, 2));\r\n b = Math.abs(y);\r\n\r\n if (b >= 1) {\r\n if ((b - 1) > EPSLN) {\r\n return (93);\r\n }\r\n else {\r\n y = 0;\r\n }\r\n }\r\n else {\r\n y = Math.acos(y);\r\n }\r\n\r\n if (lat < 0) {\r\n y = -y;\r\n }\r\n\r\n y = this.a * this.k0 * (y - this.lat0) + this.y0;\r\n }\r\n }\r\n else {\r\n var al = cos_phi * delta_lon;\r\n var als = Math.pow(al, 2);\r\n var c = this.ep2 * Math.pow(cos_phi, 2);\r\n var cs = Math.pow(c, 2);\r\n var tq = Math.abs(cos_phi) > EPSLN ? Math.tan(lat) : 0;\r\n var t = Math.pow(tq, 2);\r\n var ts = Math.pow(t, 2);\r\n con = 1 - this.es * Math.pow(sin_phi, 2);\r\n al = al / Math.sqrt(con);\r\n var ml = pj_mlfn(lat, sin_phi, cos_phi, this.en);\r\n\r\n x = this.a * (this.k0 * al * (1 +\r\n als / 6 * (1 - t + c +\r\n als / 20 * (5 - 18 * t + ts + 14 * c - 58 * t * c +\r\n als / 42 * (61 + 179 * ts - ts * t - 479 * t))))) +\r\n this.x0;\r\n\r\n y = this.a * (this.k0 * (ml - this.ml0 +\r\n sin_phi * delta_lon * al / 2 * (1 +\r\n als / 12 * (5 - t + 9 * c + 4 * cs +\r\n als / 30 * (61 + ts - 58 * t + 270 * c - 330 * t * c +\r\n als / 56 * (1385 + 543 * ts - ts * t - 3111 * t)))))) +\r\n this.y0;\r\n }\r\n\r\n p.x = x;\r\n p.y = y;\r\n\r\n return p;\r\n}\r\n\r\n/**\r\n Transverse Mercator Inverse - x/y to long/lat\r\n */\r\nexport function inverse(p) {\r\n var con, phi;\r\n var lat, lon;\r\n var x = (p.x - this.x0) * (1 / this.a);\r\n var y = (p.y - this.y0) * (1 / this.a);\r\n\r\n if (!this.es) {\r\n var f = Math.exp(x / this.k0);\r\n var g = 0.5 * (f - 1 / f);\r\n var temp = this.lat0 + y / this.k0;\r\n var h = Math.cos(temp);\r\n con = Math.sqrt((1 - Math.pow(h, 2)) / (1 + Math.pow(g, 2)));\r\n lat = Math.asin(con);\r\n\r\n if (y < 0) {\r\n lat = -lat;\r\n }\r\n\r\n if ((g === 0) && (h === 0)) {\r\n lon = 0;\r\n }\r\n else {\r\n lon = adjust_lon(Math.atan2(g, h) + this.long0);\r\n }\r\n }\r\n else { // ellipsoidal form\r\n con = this.ml0 + y / this.k0;\r\n phi = pj_inv_mlfn(con, this.es, this.en);\r\n\r\n if (Math.abs(phi) < HALF_PI) {\r\n var sin_phi = Math.sin(phi);\r\n var cos_phi = Math.cos(phi);\r\n var tan_phi = Math.abs(cos_phi) > EPSLN ? Math.tan(phi) : 0;\r\n var c = this.ep2 * Math.pow(cos_phi, 2);\r\n var cs = Math.pow(c, 2);\r\n var t = Math.pow(tan_phi, 2);\r\n var ts = Math.pow(t, 2);\r\n con = 1 - this.es * Math.pow(sin_phi, 2);\r\n var d = x * Math.sqrt(con) / this.k0;\r\n var ds = Math.pow(d, 2);\r\n con = con * tan_phi;\r\n\r\n lat = phi - (con * ds / (1 - this.es)) * 0.5 * (1 -\r\n ds / 12 * (5 + 3 * t - 9 * c * t + c - 4 * cs -\r\n ds / 30 * (61 + 90 * t - 252 * c * t + 45 * ts + 46 * c -\r\n ds / 56 * (1385 + 3633 * t + 4095 * ts + 1574 * ts * t))));\r\n\r\n lon = adjust_lon(this.long0 + (d * (1 -\r\n ds / 6 * (1 + 2 * t + c -\r\n ds / 20 * (5 + 28 * t + 24 * ts + 8 * c * t + 6 * c -\r\n ds / 42 * (61 + 662 * t + 1320 * ts + 720 * ts * t)))) / cos_phi));\r\n }\r\n else {\r\n lat = HALF_PI * sign(y);\r\n lon = 0;\r\n }\r\n }\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n\r\n return p;\r\n}\r\n\r\nexport var names = [\"Fast_Transverse_Mercator\", \"Fast Transverse Mercator\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "export default function(x) {\r\n var r = Math.exp(x);\r\n r = (r - 1 / r) / 2;\r\n return r;\r\n}", "export default function(x, y) {\r\n x = Math.abs(x);\r\n y = Math.abs(y);\r\n var a = Math.max(x, y);\r\n var b = Math.min(x, y) / (a ? a : 1);\r\n\r\n return a * Math.sqrt(1 + Math.pow(b, 2));\r\n}\r\n", "export default function(x) {\r\n var y = 1 + x;\r\n var z = y - 1;\r\n\r\n return z === 0 ? x : x * Math.log(y) / z;\r\n}\r\n", "import hypot from './hypot';\r\nimport log1py from './log1py';\r\n\r\nexport default function(x) {\r\n var y = Math.abs(x);\r\n y = log1py(y * (1 + y / (hypot(1, y) + 1)));\r\n\r\n return x < 0 ? -y : y;\r\n}\r\n", "export default function(pp, B) {\r\n var cos_2B = 2 * Math.cos(2 * B);\r\n var i = pp.length - 1;\r\n var h1 = pp[i];\r\n var h2 = 0;\r\n var h;\r\n\r\n while (--i >= 0) {\r\n h = -h2 + cos_2B * h1 + pp[i];\r\n h2 = h1;\r\n h1 = h;\r\n }\r\n\r\n return (B + h * Math.sin(2 * B));\r\n}\r\n", "export default function(pp, arg_r) {\r\n var r = 2 * Math.cos(arg_r);\r\n var i = pp.length - 1;\r\n var hr1 = pp[i];\r\n var hr2 = 0;\r\n var hr;\r\n\r\n while (--i >= 0) {\r\n hr = -hr2 + r * hr1 + pp[i];\r\n hr2 = hr1;\r\n hr1 = hr;\r\n }\r\n\r\n return Math.sin(arg_r) * hr;\r\n}\r\n", "export default function(x) {\r\n var r = Math.exp(x);\r\n r = (r + 1 / r) / 2;\r\n return r;\r\n}", "import sinh from './sinh';\r\nimport cosh from './cosh';\r\n\r\nexport default function(pp, arg_r, arg_i) {\r\n var sin_arg_r = Math.sin(arg_r);\r\n var cos_arg_r = Math.cos(arg_r);\r\n var sinh_arg_i = sinh(arg_i);\r\n var cosh_arg_i = cosh(arg_i);\r\n var r = 2 * cos_arg_r * cosh_arg_i;\r\n var i = -2 * sin_arg_r * sinh_arg_i;\r\n var j = pp.length - 1;\r\n var hr = pp[j];\r\n var hi1 = 0;\r\n var hr1 = 0;\r\n var hi = 0;\r\n var hr2;\r\n var hi2;\r\n\r\n while (--j >= 0) {\r\n hr2 = hr1;\r\n hi2 = hi1;\r\n hr1 = hr;\r\n hi1 = hi;\r\n hr = -hr2 + r * hr1 - i * hi1 + pp[j];\r\n hi = -hi2 + i * hr1 + r * hi1;\r\n }\r\n\r\n r = sin_arg_r * cosh_arg_i;\r\n i = cos_arg_r * sinh_arg_i;\r\n\r\n return [r * hr - i * hi, r * hi + i * hr];\r\n}\r\n", "// Heavily based on this etmerc projection implementation\r\n// https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/etmerc.js\r\n\r\nimport tmerc from '../projections/tmerc';\r\nimport sinh from '../common/sinh';\r\nimport hypot from '../common/hypot';\r\nimport asinhy from '../common/asinhy';\r\nimport gatg from '../common/gatg';\r\nimport clens from '../common/clens';\r\nimport clens_cmplx from '../common/clens_cmplx';\r\nimport adjust_lon from '../common/adjust_lon';\r\n\r\nexport function init() {\r\n if (!this.approx && (isNaN(this.es) || this.es <= 0)) {\r\n throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION[\"Fast_Transverse_Mercator\"] in the WKT.');\r\n }\r\n if (this.approx) {\r\n // When '+approx' is set, use tmerc instead\r\n tmerc.init.apply(this);\r\n this.forward = tmerc.forward;\r\n this.inverse = tmerc.inverse;\r\n }\r\n\r\n this.x0 = this.x0 !== undefined ? this.x0 : 0;\r\n this.y0 = this.y0 !== undefined ? this.y0 : 0;\r\n this.long0 = this.long0 !== undefined ? this.long0 : 0;\r\n this.lat0 = this.lat0 !== undefined ? this.lat0 : 0;\r\n\r\n this.cgb = [];\r\n this.cbg = [];\r\n this.utg = [];\r\n this.gtu = [];\r\n\r\n var f = this.es / (1 + Math.sqrt(1 - this.es));\r\n var n = f / (2 - f);\r\n var np = n;\r\n\r\n this.cgb[0] = n * (2 + n * (-2 / 3 + n * (-2 + n * (116 / 45 + n * (26 / 45 + n * (-2854 / 675 ))))));\r\n this.cbg[0] = n * (-2 + n * ( 2 / 3 + n * ( 4 / 3 + n * (-82 / 45 + n * (32 / 45 + n * (4642 / 4725))))));\r\n\r\n np = np * n;\r\n this.cgb[1] = np * (7 / 3 + n * (-8 / 5 + n * (-227 / 45 + n * (2704 / 315 + n * (2323 / 945)))));\r\n this.cbg[1] = np * (5 / 3 + n * (-16 / 15 + n * ( -13 / 9 + n * (904 / 315 + n * (-1522 / 945)))));\r\n\r\n np = np * n;\r\n this.cgb[2] = np * (56 / 15 + n * (-136 / 35 + n * (-1262 / 105 + n * (73814 / 2835))));\r\n this.cbg[2] = np * (-26 / 15 + n * (34 / 21 + n * (8 / 5 + n * (-12686 / 2835))));\r\n\r\n np = np * n;\r\n this.cgb[3] = np * (4279 / 630 + n * (-332 / 35 + n * (-399572 / 14175)));\r\n this.cbg[3] = np * (1237 / 630 + n * (-12 / 5 + n * ( -24832 / 14175)));\r\n\r\n np = np * n;\r\n this.cgb[4] = np * (4174 / 315 + n * (-144838 / 6237));\r\n this.cbg[4] = np * (-734 / 315 + n * (109598 / 31185));\r\n\r\n np = np * n;\r\n this.cgb[5] = np * (601676 / 22275);\r\n this.cbg[5] = np * (444337 / 155925);\r\n\r\n np = Math.pow(n, 2);\r\n this.Qn = this.k0 / (1 + n) * (1 + np * (1 / 4 + np * (1 / 64 + np / 256)));\r\n\r\n this.utg[0] = n * (-0.5 + n * ( 2 / 3 + n * (-37 / 96 + n * ( 1 / 360 + n * (81 / 512 + n * (-96199 / 604800))))));\r\n this.gtu[0] = n * (0.5 + n * (-2 / 3 + n * (5 / 16 + n * (41 / 180 + n * (-127 / 288 + n * (7891 / 37800))))));\r\n\r\n this.utg[1] = np * (-1 / 48 + n * (-1 / 15 + n * (437 / 1440 + n * (-46 / 105 + n * (1118711 / 3870720)))));\r\n this.gtu[1] = np * (13 / 48 + n * (-3 / 5 + n * (557 / 1440 + n * (281 / 630 + n * (-1983433 / 1935360)))));\r\n\r\n np = np * n;\r\n this.utg[2] = np * (-17 / 480 + n * (37 / 840 + n * (209 / 4480 + n * (-5569 / 90720 ))));\r\n this.gtu[2] = np * (61 / 240 + n * (-103 / 140 + n * (15061 / 26880 + n * (167603 / 181440))));\r\n\r\n np = np * n;\r\n this.utg[3] = np * (-4397 / 161280 + n * (11 / 504 + n * (830251 / 7257600)));\r\n this.gtu[3] = np * (49561 / 161280 + n * (-179 / 168 + n * (6601661 / 7257600)));\r\n\r\n np = np * n;\r\n this.utg[4] = np * (-4583 / 161280 + n * (108847 / 3991680));\r\n this.gtu[4] = np * (34729 / 80640 + n * (-3418889 / 1995840));\r\n\r\n np = np * n;\r\n this.utg[5] = np * (-20648693 / 638668800);\r\n this.gtu[5] = np * (212378941 / 319334400);\r\n\r\n var Z = gatg(this.cbg, this.lat0);\r\n this.Zb = -this.Qn * (Z + clens(this.gtu, 2 * Z));\r\n}\r\n\r\nexport function forward(p) {\r\n var Ce = adjust_lon(p.x - this.long0);\r\n var Cn = p.y;\r\n\r\n Cn = gatg(this.cbg, Cn);\r\n var sin_Cn = Math.sin(Cn);\r\n var cos_Cn = Math.cos(Cn);\r\n var sin_Ce = Math.sin(Ce);\r\n var cos_Ce = Math.cos(Ce);\r\n\r\n Cn = Math.atan2(sin_Cn, cos_Ce * cos_Cn);\r\n Ce = Math.atan2(sin_Ce * cos_Cn, hypot(sin_Cn, cos_Cn * cos_Ce));\r\n Ce = asinhy(Math.tan(Ce));\r\n\r\n var tmp = clens_cmplx(this.gtu, 2 * Cn, 2 * Ce);\r\n\r\n Cn = Cn + tmp[0];\r\n Ce = Ce + tmp[1];\r\n\r\n var x;\r\n var y;\r\n\r\n if (Math.abs(Ce) <= 2.623395162778) {\r\n x = this.a * (this.Qn * Ce) + this.x0;\r\n y = this.a * (this.Qn * Cn + this.Zb) + this.y0;\r\n }\r\n else {\r\n x = Infinity;\r\n y = Infinity;\r\n }\r\n\r\n p.x = x;\r\n p.y = y;\r\n\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n var Ce = (p.x - this.x0) * (1 / this.a);\r\n var Cn = (p.y - this.y0) * (1 / this.a);\r\n\r\n Cn = (Cn - this.Zb) / this.Qn;\r\n Ce = Ce / this.Qn;\r\n\r\n var lon;\r\n var lat;\r\n\r\n if (Math.abs(Ce) <= 2.623395162778) {\r\n var tmp = clens_cmplx(this.utg, 2 * Cn, 2 * Ce);\r\n\r\n Cn = Cn + tmp[0];\r\n Ce = Ce + tmp[1];\r\n Ce = Math.atan(sinh(Ce));\r\n\r\n var sin_Cn = Math.sin(Cn);\r\n var cos_Cn = Math.cos(Cn);\r\n var sin_Ce = Math.sin(Ce);\r\n var cos_Ce = Math.cos(Ce);\r\n\r\n Cn = Math.atan2(sin_Cn * cos_Ce, hypot(sin_Ce, cos_Ce * cos_Cn));\r\n Ce = Math.atan2(sin_Ce, cos_Ce * cos_Cn);\r\n\r\n lon = adjust_lon(Ce + this.long0);\r\n lat = gatg(this.cgb, Cn);\r\n }\r\n else {\r\n lon = Infinity;\r\n lat = Infinity;\r\n }\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n\r\n return p;\r\n}\r\n\r\nexport var names = [\"Extended_Transverse_Mercator\", \"Extended Transverse Mercator\", \"etmerc\", \"Transverse_Mercator\", \"Transverse Mercator\", \"tmerc\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import adjust_lon from './adjust_lon';\r\n\r\nexport default function(zone, lon) {\r\n if (zone === undefined) {\r\n zone = Math.floor((adjust_lon(lon) + Math.PI) * 30 / Math.PI) + 1;\r\n\r\n if (zone < 0) {\r\n return 0;\r\n } else if (zone > 60) {\r\n return 60;\r\n }\r\n }\r\n return zone;\r\n}\r\n", "import adjust_zone from '../common/adjust_zone';\r\nimport etmerc from './etmerc';\r\nexport var dependsOn = 'etmerc';\r\nimport {D2R} from '../constants/values';\r\n\r\n\r\nexport function init() {\r\n var zone = adjust_zone(this.zone, this.long0);\r\n if (zone === undefined) {\r\n throw new Error('unknown utm zone');\r\n }\r\n this.lat0 = 0;\r\n this.long0 = ((6 * Math.abs(zone)) - 183) * D2R;\r\n this.x0 = 500000;\r\n this.y0 = this.utmSouth ? 10000000 : 0;\r\n this.k0 = 0.9996;\r\n\r\n etmerc.init.apply(this);\r\n this.forward = etmerc.forward;\r\n this.inverse = etmerc.inverse;\r\n}\r\n\r\nexport var names = [\"Universal Transverse Mercator System\", \"utm\"];\r\nexport default {\r\n init: init,\r\n names: names,\r\n dependsOn: dependsOn\r\n};\r\n", "export default function(esinp, exp) {\r\n return (Math.pow((1 - esinp) / (1 + esinp), exp));\r\n}", "import srat from '../common/srat';\r\nvar MAX_ITER = 20;\r\nimport {HALF_PI, FORTPI} from '../constants/values';\r\n\r\nexport function init() {\r\n var sphi = Math.sin(this.lat0);\r\n var cphi = Math.cos(this.lat0);\r\n cphi *= cphi;\r\n this.rc = Math.sqrt(1 - this.es) / (1 - this.es * sphi * sphi);\r\n this.C = Math.sqrt(1 + this.es * cphi * cphi / (1 - this.es));\r\n this.phic0 = Math.asin(sphi / this.C);\r\n this.ratexp = 0.5 * this.C * this.e;\r\n this.K = Math.tan(0.5 * this.phic0 + FORTPI) / (Math.pow(Math.tan(0.5 * this.lat0 + FORTPI), this.C) * srat(this.e * sphi, this.ratexp));\r\n}\r\n\r\nexport function forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n\r\n p.y = 2 * Math.atan(this.K * Math.pow(Math.tan(0.5 * lat + FORTPI), this.C) * srat(this.e * Math.sin(lat), this.ratexp)) - HALF_PI;\r\n p.x = this.C * lon;\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n var DEL_TOL = 1e-14;\r\n var lon = p.x / this.C;\r\n var lat = p.y;\r\n var num = Math.pow(Math.tan(0.5 * lat + FORTPI) / this.K, 1 / this.C);\r\n for (var i = MAX_ITER; i > 0; --i) {\r\n lat = 2 * Math.atan(num * srat(this.e * Math.sin(p.y), - 0.5 * this.e)) - HALF_PI;\r\n if (Math.abs(lat - p.y) < DEL_TOL) {\r\n break;\r\n }\r\n p.y = lat;\r\n }\r\n /* convergence failed */\r\n if (!i) {\r\n return null;\r\n }\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"gauss\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import gauss from './gauss';\r\nimport adjust_lon from '../common/adjust_lon';\r\n\r\nexport function init() {\r\n gauss.init.apply(this);\r\n if (!this.rc) {\r\n return;\r\n }\r\n this.sinc0 = Math.sin(this.phic0);\r\n this.cosc0 = Math.cos(this.phic0);\r\n this.R2 = 2 * this.rc;\r\n if (!this.title) {\r\n this.title = \"Oblique Stereographic Alternative\";\r\n }\r\n}\r\n\r\nexport function forward(p) {\r\n var sinc, cosc, cosl, k;\r\n p.x = adjust_lon(p.x - this.long0);\r\n gauss.forward.apply(this, [p]);\r\n sinc = Math.sin(p.y);\r\n cosc = Math.cos(p.y);\r\n cosl = Math.cos(p.x);\r\n k = this.k0 * this.R2 / (1 + this.sinc0 * sinc + this.cosc0 * cosc * cosl);\r\n p.x = k * cosc * Math.sin(p.x);\r\n p.y = k * (this.cosc0 * sinc - this.sinc0 * cosc * cosl);\r\n p.x = this.a * p.x + this.x0;\r\n p.y = this.a * p.y + this.y0;\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n var sinc, cosc, lon, lat, rho;\r\n p.x = (p.x - this.x0) / this.a;\r\n p.y = (p.y - this.y0) / this.a;\r\n\r\n p.x /= this.k0;\r\n p.y /= this.k0;\r\n if ((rho = Math.sqrt(p.x * p.x + p.y * p.y))) {\r\n var c = 2 * Math.atan2(rho, this.R2);\r\n sinc = Math.sin(c);\r\n cosc = Math.cos(c);\r\n lat = Math.asin(cosc * this.sinc0 + p.y * sinc * this.cosc0 / rho);\r\n lon = Math.atan2(p.x * sinc, rho * this.cosc0 * cosc - p.y * this.sinc0 * sinc);\r\n }\r\n else {\r\n lat = this.phic0;\r\n lon = 0;\r\n }\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n gauss.inverse.apply(this, [p]);\r\n p.x = adjust_lon(p.x + this.long0);\r\n return p;\r\n}\r\n\r\nexport var names = [\"Stereographic_North_Pole\", \"Oblique_Stereographic\", \"sterea\",\"Oblique Stereographic Alternative\",\"Double_Stereographic\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import {EPSLN, HALF_PI} from '../constants/values';\r\n\r\nimport sign from '../common/sign';\r\nimport msfnz from '../common/msfnz';\r\nimport tsfnz from '../common/tsfnz';\r\nimport phi2z from '../common/phi2z';\r\nimport adjust_lon from '../common/adjust_lon';\r\n\r\nexport function ssfn_(phit, sinphi, eccen) {\r\n sinphi *= eccen;\r\n return (Math.tan(0.5 * (HALF_PI + phit)) * Math.pow((1 - sinphi) / (1 + sinphi), 0.5 * eccen));\r\n}\r\n\r\nexport function init() {\r\n\r\n // setting default parameters\r\n this.x0 = this.x0 || 0;\r\n this.y0 = this.y0 || 0;\r\n this.lat0 = this.lat0 || 0;\r\n this.long0 = this.long0 || 0;\r\n\r\n this.coslat0 = Math.cos(this.lat0);\r\n this.sinlat0 = Math.sin(this.lat0);\r\n if (this.sphere) {\r\n if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {\r\n this.k0 = 0.5 * (1 + sign(this.lat0) * Math.sin(this.lat_ts));\r\n }\r\n }\r\n else {\r\n if (Math.abs(this.coslat0) <= EPSLN) {\r\n if (this.lat0 > 0) {\r\n //North pole\r\n //trace('stere:north pole');\r\n this.con = 1;\r\n }\r\n else {\r\n //South pole\r\n //trace('stere:south pole');\r\n this.con = -1;\r\n }\r\n }\r\n this.cons = Math.sqrt(Math.pow(1 + this.e, 1 + this.e) * Math.pow(1 - this.e, 1 - this.e));\r\n if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN && Math.abs(Math.cos(this.lat_ts)) > EPSLN) {\r\n // When k0 is 1 (default value) and lat_ts is a vaild number and lat0 is at a pole and lat_ts is not at a pole\r\n // Recalculate k0 using formula 21-35 from p161 of Snyder, 1987\r\n this.k0 = 0.5 * this.cons * msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) / tsfnz(this.e, this.con * this.lat_ts, this.con * Math.sin(this.lat_ts));\r\n }\r\n this.ms1 = msfnz(this.e, this.sinlat0, this.coslat0);\r\n this.X0 = 2 * Math.atan(this.ssfn_(this.lat0, this.sinlat0, this.e)) - HALF_PI;\r\n this.cosX0 = Math.cos(this.X0);\r\n this.sinX0 = Math.sin(this.X0);\r\n }\r\n}\r\n\r\n// Stereographic forward equations--mapping lat,long to x,y\r\nexport function forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n var sinlat = Math.sin(lat);\r\n var coslat = Math.cos(lat);\r\n var A, X, sinX, cosX, ts, rh;\r\n var dlon = adjust_lon(lon - this.long0);\r\n\r\n if (Math.abs(Math.abs(lon - this.long0) - Math.PI) <= EPSLN && Math.abs(lat + this.lat0) <= EPSLN) {\r\n //case of the origine point\r\n //trace('stere:this is the origin point');\r\n p.x = NaN;\r\n p.y = NaN;\r\n return p;\r\n }\r\n if (this.sphere) {\r\n //trace('stere:sphere case');\r\n A = 2 * this.k0 / (1 + this.sinlat0 * sinlat + this.coslat0 * coslat * Math.cos(dlon));\r\n p.x = this.a * A * coslat * Math.sin(dlon) + this.x0;\r\n p.y = this.a * A * (this.coslat0 * sinlat - this.sinlat0 * coslat * Math.cos(dlon)) + this.y0;\r\n return p;\r\n }\r\n else {\r\n X = 2 * Math.atan(this.ssfn_(lat, sinlat, this.e)) - HALF_PI;\r\n cosX = Math.cos(X);\r\n sinX = Math.sin(X);\r\n if (Math.abs(this.coslat0) <= EPSLN) {\r\n ts = tsfnz(this.e, lat * this.con, this.con * sinlat);\r\n rh = 2 * this.a * this.k0 * ts / this.cons;\r\n p.x = this.x0 + rh * Math.sin(lon - this.long0);\r\n p.y = this.y0 - this.con * rh * Math.cos(lon - this.long0);\r\n //trace(p.toString());\r\n return p;\r\n }\r\n else if (Math.abs(this.sinlat0) < EPSLN) {\r\n //Eq\r\n //trace('stere:equateur');\r\n A = 2 * this.a * this.k0 / (1 + cosX * Math.cos(dlon));\r\n p.y = A * sinX;\r\n }\r\n else {\r\n //other case\r\n //trace('stere:normal case');\r\n A = 2 * this.a * this.k0 * this.ms1 / (this.cosX0 * (1 + this.sinX0 * sinX + this.cosX0 * cosX * Math.cos(dlon)));\r\n p.y = A * (this.cosX0 * sinX - this.sinX0 * cosX * Math.cos(dlon)) + this.y0;\r\n }\r\n p.x = A * cosX * Math.sin(dlon) + this.x0;\r\n }\r\n //trace(p.toString());\r\n return p;\r\n}\r\n\r\n//* Stereographic inverse equations--mapping x,y to lat/long\r\nexport function inverse(p) {\r\n p.x -= this.x0;\r\n p.y -= this.y0;\r\n var lon, lat, ts, ce, Chi;\r\n var rh = Math.sqrt(p.x * p.x + p.y * p.y);\r\n if (this.sphere) {\r\n var c = 2 * Math.atan(rh / (2 * this.a * this.k0));\r\n lon = this.long0;\r\n lat = this.lat0;\r\n if (rh <= EPSLN) {\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n lat = Math.asin(Math.cos(c) * this.sinlat0 + p.y * Math.sin(c) * this.coslat0 / rh);\r\n if (Math.abs(this.coslat0) < EPSLN) {\r\n if (this.lat0 > 0) {\r\n lon = adjust_lon(this.long0 + Math.atan2(p.x, - 1 * p.y));\r\n }\r\n else {\r\n lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));\r\n }\r\n }\r\n else {\r\n lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(c), rh * this.coslat0 * Math.cos(c) - p.y * this.sinlat0 * Math.sin(c)));\r\n }\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n else {\r\n if (Math.abs(this.coslat0) <= EPSLN) {\r\n if (rh <= EPSLN) {\r\n lat = this.lat0;\r\n lon = this.long0;\r\n p.x = lon;\r\n p.y = lat;\r\n //trace(p.toString());\r\n return p;\r\n }\r\n p.x *= this.con;\r\n p.y *= this.con;\r\n ts = rh * this.cons / (2 * this.a * this.k0);\r\n lat = this.con * phi2z(this.e, ts);\r\n lon = this.con * adjust_lon(this.con * this.long0 + Math.atan2(p.x, - 1 * p.y));\r\n }\r\n else {\r\n ce = 2 * Math.atan(rh * this.cosX0 / (2 * this.a * this.k0 * this.ms1));\r\n lon = this.long0;\r\n if (rh <= EPSLN) {\r\n Chi = this.X0;\r\n }\r\n else {\r\n Chi = Math.asin(Math.cos(ce) * this.sinX0 + p.y * Math.sin(ce) * this.cosX0 / rh);\r\n lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(ce), rh * this.cosX0 * Math.cos(ce) - p.y * this.sinX0 * Math.sin(ce)));\r\n }\r\n lat = -1 * phi2z(this.e, Math.tan(0.5 * (HALF_PI + Chi)));\r\n }\r\n }\r\n p.x = lon;\r\n p.y = lat;\r\n\r\n //trace(p.toString());\r\n return p;\r\n\r\n}\r\n\r\nexport var names = [\"stere\", \"Stereographic_South_Pole\", \"Polar Stereographic (variant B)\", \"Polar_Stereographic\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names,\r\n ssfn_: ssfn_\r\n};\r\n", "/*\r\n references:\r\n Formules et constantes pour le Calcul pour la\r\n projection cylindrique conforme à axe oblique et pour la transformation entre\r\n des systèmes de référence.\r\n http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey/sys/refsys/switzerland.parsysrelated1.31216.downloadList.77004.DownloadFile.tmp/swissprojectionfr.pdf\r\n */\r\n\r\nexport function init() {\r\n var phy0 = this.lat0;\r\n this.lambda0 = this.long0;\r\n var sinPhy0 = Math.sin(phy0);\r\n var semiMajorAxis = this.a;\r\n var invF = this.rf;\r\n var flattening = 1 / invF;\r\n var e2 = 2 * flattening - Math.pow(flattening, 2);\r\n var e = this.e = Math.sqrt(e2);\r\n this.R = this.k0 * semiMajorAxis * Math.sqrt(1 - e2) / (1 - e2 * Math.pow(sinPhy0, 2));\r\n this.alpha = Math.sqrt(1 + e2 / (1 - e2) * Math.pow(Math.cos(phy0), 4));\r\n this.b0 = Math.asin(sinPhy0 / this.alpha);\r\n var k1 = Math.log(Math.tan(Math.PI / 4 + this.b0 / 2));\r\n var k2 = Math.log(Math.tan(Math.PI / 4 + phy0 / 2));\r\n var k3 = Math.log((1 + e * sinPhy0) / (1 - e * sinPhy0));\r\n this.K = k1 - this.alpha * k2 + this.alpha * e / 2 * k3;\r\n}\r\n\r\nexport function forward(p) {\r\n var Sa1 = Math.log(Math.tan(Math.PI / 4 - p.y / 2));\r\n var Sa2 = this.e / 2 * Math.log((1 + this.e * Math.sin(p.y)) / (1 - this.e * Math.sin(p.y)));\r\n var S = -this.alpha * (Sa1 + Sa2) + this.K;\r\n\r\n // spheric latitude\r\n var b = 2 * (Math.atan(Math.exp(S)) - Math.PI / 4);\r\n\r\n // spheric longitude\r\n var I = this.alpha * (p.x - this.lambda0);\r\n\r\n // psoeudo equatorial rotation\r\n var rotI = Math.atan(Math.sin(I) / (Math.sin(this.b0) * Math.tan(b) + Math.cos(this.b0) * Math.cos(I)));\r\n\r\n var rotB = Math.asin(Math.cos(this.b0) * Math.sin(b) - Math.sin(this.b0) * Math.cos(b) * Math.cos(I));\r\n\r\n p.y = this.R / 2 * Math.log((1 + Math.sin(rotB)) / (1 - Math.sin(rotB))) + this.y0;\r\n p.x = this.R * rotI + this.x0;\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n var Y = p.x - this.x0;\r\n var X = p.y - this.y0;\r\n\r\n var rotI = Y / this.R;\r\n var rotB = 2 * (Math.atan(Math.exp(X / this.R)) - Math.PI / 4);\r\n\r\n var b = Math.asin(Math.cos(this.b0) * Math.sin(rotB) + Math.sin(this.b0) * Math.cos(rotB) * Math.cos(rotI));\r\n var I = Math.atan(Math.sin(rotI) / (Math.cos(this.b0) * Math.cos(rotI) - Math.sin(this.b0) * Math.tan(rotB)));\r\n\r\n var lambda = this.lambda0 + I / this.alpha;\r\n\r\n var S = 0;\r\n var phy = b;\r\n var prevPhy = -1000;\r\n var iteration = 0;\r\n while (Math.abs(phy - prevPhy) > 0.0000001) {\r\n if (++iteration > 20) {\r\n //...reportError(\"omercFwdInfinity\");\r\n return;\r\n }\r\n //S = Math.log(Math.tan(Math.PI / 4 + phy / 2));\r\n S = 1 / this.alpha * (Math.log(Math.tan(Math.PI / 4 + b / 2)) - this.K) + this.e * Math.log(Math.tan(Math.PI / 4 + Math.asin(this.e * Math.sin(phy)) / 2));\r\n prevPhy = phy;\r\n phy = 2 * Math.atan(Math.exp(S)) - Math.PI / 2;\r\n }\r\n\r\n p.x = lambda;\r\n p.y = phy;\r\n return p;\r\n}\r\n\r\nexport var names = [\"somerc\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import tsfnz from '../common/tsfnz';\r\nimport adjust_lon from '../common/adjust_lon';\r\nimport phi2z from '../common/phi2z';\r\nimport { D2R, EPSLN, HALF_PI, TWO_PI, FORTPI } from '../constants/values';\r\n\r\nvar TOL = 1e-7;\r\n\r\nfunction isTypeA(P) {\r\n var typeAProjections = ['Hotine_Oblique_Mercator','Hotine_Oblique_Mercator_Azimuth_Natural_Origin'];\r\n var projectionName = typeof P.PROJECTION === \"object\" ? Object.keys(P.PROJECTION)[0] : P.PROJECTION;\r\n \r\n return 'no_uoff' in P || 'no_off' in P || typeAProjections.indexOf(projectionName) !== -1;\r\n}\r\n\r\n\r\n/* Initialize the Oblique Mercator projection\r\n ------------------------------------------*/\r\nexport function init() { \r\n var con, com, cosph0, D, F, H, L, sinph0, p, J, gamma = 0,\r\n gamma0, lamc = 0, lam1 = 0, lam2 = 0, phi1 = 0, phi2 = 0, alpha_c = 0, AB;\r\n \r\n // only Type A uses the no_off or no_uoff property\r\n // https://github.com/OSGeo/proj.4/issues/104\r\n this.no_off = isTypeA(this);\r\n this.no_rot = 'no_rot' in this;\r\n \r\n var alp = false;\r\n if (\"alpha\" in this) {\r\n alp = true;\r\n }\r\n\r\n var gam = false;\r\n if (\"rectified_grid_angle\" in this) {\r\n gam = true;\r\n }\r\n\r\n if (alp) {\r\n alpha_c = this.alpha;\r\n }\r\n \r\n if (gam) {\r\n gamma = (this.rectified_grid_angle * D2R);\r\n }\r\n \r\n if (alp || gam) {\r\n lamc = this.longc;\r\n } else {\r\n lam1 = this.long1;\r\n phi1 = this.lat1;\r\n lam2 = this.long2;\r\n phi2 = this.lat2;\r\n \r\n if (Math.abs(phi1 - phi2) <= TOL || (con = Math.abs(phi1)) <= TOL ||\r\n Math.abs(con - HALF_PI) <= TOL || Math.abs(Math.abs(this.lat0) - HALF_PI) <= TOL ||\r\n Math.abs(Math.abs(phi2) - HALF_PI) <= TOL) {\r\n throw new Error();\r\n }\r\n }\r\n \r\n var one_es = 1.0 - this.es;\r\n com = Math.sqrt(one_es);\r\n \r\n if (Math.abs(this.lat0) > EPSLN) {\r\n sinph0 = Math.sin(this.lat0);\r\n cosph0 = Math.cos(this.lat0);\r\n con = 1 - this.es * sinph0 * sinph0;\r\n this.B = cosph0 * cosph0;\r\n this.B = Math.sqrt(1 + this.es * this.B * this.B / one_es);\r\n this.A = this.B * this.k0 * com / con;\r\n D = this.B * com / (cosph0 * Math.sqrt(con));\r\n F = D * D -1;\r\n \r\n if (F <= 0) {\r\n F = 0;\r\n } else {\r\n F = Math.sqrt(F);\r\n if (this.lat0 < 0) {\r\n F = -F;\r\n }\r\n }\r\n \r\n this.E = F += D;\r\n this.E *= Math.pow(tsfnz(this.e, this.lat0, sinph0), this.B);\r\n } else {\r\n this.B = 1 / com;\r\n this.A = this.k0;\r\n this.E = D = F = 1;\r\n }\r\n \r\n if (alp || gam) {\r\n if (alp) {\r\n gamma0 = Math.asin(Math.sin(alpha_c) / D);\r\n if (!gam) {\r\n gamma = alpha_c;\r\n }\r\n } else {\r\n gamma0 = gamma;\r\n alpha_c = Math.asin(D * Math.sin(gamma0));\r\n }\r\n this.lam0 = lamc - Math.asin(0.5 * (F - 1 / F) * Math.tan(gamma0)) / this.B;\r\n } else {\r\n H = Math.pow(tsfnz(this.e, phi1, Math.sin(phi1)), this.B);\r\n L = Math.pow(tsfnz(this.e, phi2, Math.sin(phi2)), this.B);\r\n F = this.E / H;\r\n p = (L - H) / (L + H);\r\n J = this.E * this.E;\r\n J = (J - L * H) / (J + L * H);\r\n con = lam1 - lam2;\r\n \r\n if (con < -Math.pi) {\r\n lam2 -=TWO_PI;\r\n } else if (con > Math.pi) {\r\n lam2 += TWO_PI;\r\n }\r\n \r\n this.lam0 = adjust_lon(0.5 * (lam1 + lam2) - Math.atan(J * Math.tan(0.5 * this.B * (lam1 - lam2)) / p) / this.B);\r\n gamma0 = Math.atan(2 * Math.sin(this.B * adjust_lon(lam1 - this.lam0)) / (F - 1 / F));\r\n gamma = alpha_c = Math.asin(D * Math.sin(gamma0));\r\n }\r\n \r\n this.singam = Math.sin(gamma0);\r\n this.cosgam = Math.cos(gamma0);\r\n this.sinrot = Math.sin(gamma);\r\n this.cosrot = Math.cos(gamma);\r\n \r\n this.rB = 1 / this.B;\r\n this.ArB = this.A * this.rB;\r\n this.BrA = 1 / this.ArB;\r\n AB = this.A * this.B;\r\n \r\n if (this.no_off) {\r\n this.u_0 = 0;\r\n } else {\r\n this.u_0 = Math.abs(this.ArB * Math.atan(Math.sqrt(D * D - 1) / Math.cos(alpha_c)));\r\n \r\n if (this.lat0 < 0) {\r\n this.u_0 = - this.u_0;\r\n } \r\n }\r\n \r\n F = 0.5 * gamma0;\r\n this.v_pole_n = this.ArB * Math.log(Math.tan(FORTPI - F));\r\n this.v_pole_s = this.ArB * Math.log(Math.tan(FORTPI + F));\r\n}\r\n\r\n\r\n/* Oblique Mercator forward equations--mapping lat,long to x,y\r\n ----------------------------------------------------------*/\r\nexport function forward(p) {\r\n var coords = {};\r\n var S, T, U, V, W, temp, u, v;\r\n p.x = p.x - this.lam0;\r\n \r\n if (Math.abs(Math.abs(p.y) - HALF_PI) > EPSLN) {\r\n W = this.E / Math.pow(tsfnz(this.e, p.y, Math.sin(p.y)), this.B);\r\n \r\n temp = 1 / W;\r\n S = 0.5 * (W - temp);\r\n T = 0.5 * (W + temp);\r\n V = Math.sin(this.B * p.x);\r\n U = (S * this.singam - V * this.cosgam) / T;\r\n \r\n if (Math.abs(Math.abs(U) - 1.0) < EPSLN) {\r\n throw new Error();\r\n }\r\n \r\n v = 0.5 * this.ArB * Math.log((1 - U)/(1 + U));\r\n temp = Math.cos(this.B * p.x);\r\n \r\n if (Math.abs(temp) < TOL) {\r\n u = this.A * p.x;\r\n } else {\r\n u = this.ArB * Math.atan2((S * this.cosgam + V * this.singam), temp);\r\n } \r\n } else {\r\n v = p.y > 0 ? this.v_pole_n : this.v_pole_s;\r\n u = this.ArB * p.y;\r\n }\r\n \r\n if (this.no_rot) {\r\n coords.x = u;\r\n coords.y = v;\r\n } else {\r\n u -= this.u_0;\r\n coords.x = v * this.cosrot + u * this.sinrot;\r\n coords.y = u * this.cosrot - v * this.sinrot;\r\n }\r\n \r\n coords.x = (this.a * coords.x + this.x0);\r\n coords.y = (this.a * coords.y + this.y0);\r\n \r\n return coords;\r\n}\r\n\r\nexport function inverse(p) {\r\n var u, v, Qp, Sp, Tp, Vp, Up;\r\n var coords = {};\r\n \r\n p.x = (p.x - this.x0) * (1.0 / this.a);\r\n p.y = (p.y - this.y0) * (1.0 / this.a);\r\n\r\n if (this.no_rot) {\r\n v = p.y;\r\n u = p.x;\r\n } else {\r\n v = p.x * this.cosrot - p.y * this.sinrot;\r\n u = p.y * this.cosrot + p.x * this.sinrot + this.u_0;\r\n }\r\n \r\n Qp = Math.exp(-this.BrA * v);\r\n Sp = 0.5 * (Qp - 1 / Qp);\r\n Tp = 0.5 * (Qp + 1 / Qp);\r\n Vp = Math.sin(this.BrA * u);\r\n Up = (Vp * this.cosgam + Sp * this.singam) / Tp;\r\n \r\n if (Math.abs(Math.abs(Up) - 1) < EPSLN) {\r\n coords.x = 0;\r\n coords.y = Up < 0 ? -HALF_PI : HALF_PI;\r\n } else {\r\n coords.y = this.E / Math.sqrt((1 + Up) / (1 - Up));\r\n coords.y = phi2z(this.e, Math.pow(coords.y, 1 / this.B));\r\n \r\n if (coords.y === Infinity) {\r\n throw new Error();\r\n }\r\n \r\n coords.x = -this.rB * Math.atan2((Sp * this.cosgam - Vp * this.singam), Math.cos(this.BrA * u));\r\n }\r\n \r\n coords.x += this.lam0;\r\n \r\n return coords;\r\n}\r\n\r\nexport var names = [\"Hotine_Oblique_Mercator\", \"Hotine Oblique Mercator\", \"Hotine_Oblique_Mercator_Azimuth_Natural_Origin\", \"Hotine_Oblique_Mercator_Two_Point_Natural_Origin\", \"Hotine_Oblique_Mercator_Azimuth_Center\", \"Oblique_Mercator\", \"omerc\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import msfnz from '../common/msfnz';\r\nimport tsfnz from '../common/tsfnz';\r\nimport sign from '../common/sign';\r\nimport adjust_lon from '../common/adjust_lon';\r\nimport phi2z from '../common/phi2z';\r\nimport {HALF_PI, EPSLN} from '../constants/values';\r\nexport function init() {\r\n \r\n //double lat0; /* the reference latitude */\r\n //double long0; /* the reference longitude */\r\n //double lat1; /* first standard parallel */\r\n //double lat2; /* second standard parallel */\r\n //double r_maj; /* major axis */\r\n //double r_min; /* minor axis */\r\n //double false_east; /* x offset in meters */\r\n //double false_north; /* y offset in meters */\r\n \r\n //the above value can be set with proj4.defs\r\n //example: proj4.defs(\"EPSG:2154\",\"+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs\");\r\n\r\n if (!this.lat2) {\r\n this.lat2 = this.lat1;\r\n } //if lat2 is not defined\r\n if (!this.k0) {\r\n this.k0 = 1;\r\n }\r\n this.x0 = this.x0 || 0;\r\n this.y0 = this.y0 || 0;\r\n // Standard Parallels cannot be equal and on opposite sides of the equator\r\n if (Math.abs(this.lat1 + this.lat2) < EPSLN) {\r\n return;\r\n }\r\n\r\n var temp = this.b / this.a;\r\n this.e = Math.sqrt(1 - temp * temp);\r\n\r\n var sin1 = Math.sin(this.lat1);\r\n var cos1 = Math.cos(this.lat1);\r\n var ms1 = msfnz(this.e, sin1, cos1);\r\n var ts1 = tsfnz(this.e, this.lat1, sin1);\r\n\r\n var sin2 = Math.sin(this.lat2);\r\n var cos2 = Math.cos(this.lat2);\r\n var ms2 = msfnz(this.e, sin2, cos2);\r\n var ts2 = tsfnz(this.e, this.lat2, sin2);\r\n\r\n var ts0 = tsfnz(this.e, this.lat0, Math.sin(this.lat0));\r\n\r\n if (Math.abs(this.lat1 - this.lat2) > EPSLN) {\r\n this.ns = Math.log(ms1 / ms2) / Math.log(ts1 / ts2);\r\n }\r\n else {\r\n this.ns = sin1;\r\n }\r\n if (isNaN(this.ns)) {\r\n this.ns = sin1;\r\n }\r\n this.f0 = ms1 / (this.ns * Math.pow(ts1, this.ns));\r\n this.rh = this.a * this.f0 * Math.pow(ts0, this.ns);\r\n if (!this.title) {\r\n this.title = \"Lambert Conformal Conic\";\r\n }\r\n}\r\n\r\n// Lambert Conformal conic forward equations--mapping lat,long to x,y\r\n// -----------------------------------------------------------------\r\nexport function forward(p) {\r\n\r\n var lon = p.x;\r\n var lat = p.y;\r\n\r\n // singular cases :\r\n if (Math.abs(2 * Math.abs(lat) - Math.PI) <= EPSLN) {\r\n lat = sign(lat) * (HALF_PI - 2 * EPSLN);\r\n }\r\n\r\n var con = Math.abs(Math.abs(lat) - HALF_PI);\r\n var ts, rh1;\r\n if (con > EPSLN) {\r\n ts = tsfnz(this.e, lat, Math.sin(lat));\r\n rh1 = this.a * this.f0 * Math.pow(ts, this.ns);\r\n }\r\n else {\r\n con = lat * this.ns;\r\n if (con <= 0) {\r\n return null;\r\n }\r\n rh1 = 0;\r\n }\r\n var theta = this.ns * adjust_lon(lon - this.long0);\r\n p.x = this.k0 * (rh1 * Math.sin(theta)) + this.x0;\r\n p.y = this.k0 * (this.rh - rh1 * Math.cos(theta)) + this.y0;\r\n\r\n return p;\r\n}\r\n\r\n// Lambert Conformal Conic inverse equations--mapping x,y to lat/long\r\n// -----------------------------------------------------------------\r\nexport function inverse(p) {\r\n\r\n var rh1, con, ts;\r\n var lat, lon;\r\n var x = (p.x - this.x0) / this.k0;\r\n var y = (this.rh - (p.y - this.y0) / this.k0);\r\n if (this.ns > 0) {\r\n rh1 = Math.sqrt(x * x + y * y);\r\n con = 1;\r\n }\r\n else {\r\n rh1 = -Math.sqrt(x * x + y * y);\r\n con = -1;\r\n }\r\n var theta = 0;\r\n if (rh1 !== 0) {\r\n theta = Math.atan2((con * x), (con * y));\r\n }\r\n if ((rh1 !== 0) || (this.ns > 0)) {\r\n con = 1 / this.ns;\r\n ts = Math.pow((rh1 / (this.a * this.f0)), con);\r\n lat = phi2z(this.e, ts);\r\n if (lat === -9999) {\r\n return null;\r\n }\r\n }\r\n else {\r\n lat = -HALF_PI;\r\n }\r\n lon = adjust_lon(theta / this.ns + this.long0);\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\r\n \"Lambert Tangential Conformal Conic Projection\",\r\n \"Lambert_Conformal_Conic\",\r\n \"Lambert_Conformal_Conic_1SP\",\r\n \"Lambert_Conformal_Conic_2SP\",\r\n \"lcc\",\r\n \"Lambert Conic Conformal (1SP)\",\r\n \"Lambert Conic Conformal (2SP)\"\r\n];\r\n\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import adjust_lon from '../common/adjust_lon';\r\n\r\nexport function init() {\r\n this.a = 6377397.155;\r\n this.es = 0.006674372230614;\r\n this.e = Math.sqrt(this.es);\r\n if (!this.lat0) {\r\n this.lat0 = 0.863937979737193;\r\n }\r\n if (!this.long0) {\r\n this.long0 = 0.7417649320975901 - 0.308341501185665;\r\n }\r\n /* if scale not set default to 0.9999 */\r\n if (!this.k0) {\r\n this.k0 = 0.9999;\r\n }\r\n this.s45 = 0.785398163397448; /* 45 */\r\n this.s90 = 2 * this.s45;\r\n this.fi0 = this.lat0;\r\n this.e2 = this.es;\r\n this.e = Math.sqrt(this.e2);\r\n this.alfa = Math.sqrt(1 + (this.e2 * Math.pow(Math.cos(this.fi0), 4)) / (1 - this.e2));\r\n this.uq = 1.04216856380474;\r\n this.u0 = Math.asin(Math.sin(this.fi0) / this.alfa);\r\n this.g = Math.pow((1 + this.e * Math.sin(this.fi0)) / (1 - this.e * Math.sin(this.fi0)), this.alfa * this.e / 2);\r\n this.k = Math.tan(this.u0 / 2 + this.s45) / Math.pow(Math.tan(this.fi0 / 2 + this.s45), this.alfa) * this.g;\r\n this.k1 = this.k0;\r\n this.n0 = this.a * Math.sqrt(1 - this.e2) / (1 - this.e2 * Math.pow(Math.sin(this.fi0), 2));\r\n this.s0 = 1.37008346281555;\r\n this.n = Math.sin(this.s0);\r\n this.ro0 = this.k1 * this.n0 / Math.tan(this.s0);\r\n this.ad = this.s90 - this.uq;\r\n}\r\n\r\n/* ellipsoid */\r\n/* calculate xy from lat/lon */\r\n/* Constants, identical to inverse transform function */\r\nexport function forward(p) {\r\n var gfi, u, deltav, s, d, eps, ro;\r\n var lon = p.x;\r\n var lat = p.y;\r\n var delta_lon = adjust_lon(lon - this.long0);\r\n /* Transformation */\r\n gfi = Math.pow(((1 + this.e * Math.sin(lat)) / (1 - this.e * Math.sin(lat))), (this.alfa * this.e / 2));\r\n u = 2 * (Math.atan(this.k * Math.pow(Math.tan(lat / 2 + this.s45), this.alfa) / gfi) - this.s45);\r\n deltav = -delta_lon * this.alfa;\r\n s = Math.asin(Math.cos(this.ad) * Math.sin(u) + Math.sin(this.ad) * Math.cos(u) * Math.cos(deltav));\r\n d = Math.asin(Math.cos(u) * Math.sin(deltav) / Math.cos(s));\r\n eps = this.n * d;\r\n ro = this.ro0 * Math.pow(Math.tan(this.s0 / 2 + this.s45), this.n) / Math.pow(Math.tan(s / 2 + this.s45), this.n);\r\n p.y = ro * Math.cos(eps) / 1;\r\n p.x = ro * Math.sin(eps) / 1;\r\n\r\n if (!this.czech) {\r\n p.y *= -1;\r\n p.x *= -1;\r\n }\r\n return (p);\r\n}\r\n\r\n/* calculate lat/lon from xy */\r\nexport function inverse(p) {\r\n var u, deltav, s, d, eps, ro, fi1;\r\n var ok;\r\n\r\n /* Transformation */\r\n /* revert y, x*/\r\n var tmp = p.x;\r\n p.x = p.y;\r\n p.y = tmp;\r\n if (!this.czech) {\r\n p.y *= -1;\r\n p.x *= -1;\r\n }\r\n ro = Math.sqrt(p.x * p.x + p.y * p.y);\r\n eps = Math.atan2(p.y, p.x);\r\n d = eps / Math.sin(this.s0);\r\n s = 2 * (Math.atan(Math.pow(this.ro0 / ro, 1 / this.n) * Math.tan(this.s0 / 2 + this.s45)) - this.s45);\r\n u = Math.asin(Math.cos(this.ad) * Math.sin(s) - Math.sin(this.ad) * Math.cos(s) * Math.cos(d));\r\n deltav = Math.asin(Math.cos(s) * Math.sin(d) / Math.cos(u));\r\n p.x = this.long0 - deltav / this.alfa;\r\n fi1 = u;\r\n ok = 0;\r\n var iter = 0;\r\n do {\r\n p.y = 2 * (Math.atan(Math.pow(this.k, - 1 / this.alfa) * Math.pow(Math.tan(u / 2 + this.s45), 1 / this.alfa) * Math.pow((1 + this.e * Math.sin(fi1)) / (1 - this.e * Math.sin(fi1)), this.e / 2)) - this.s45);\r\n if (Math.abs(fi1 - p.y) < 0.0000000001) {\r\n ok = 1;\r\n }\r\n fi1 = p.y;\r\n iter += 1;\r\n } while (ok === 0 && iter < 15);\r\n if (iter >= 15) {\r\n return null;\r\n }\r\n\r\n return (p);\r\n}\r\n\r\nexport var names = [\"Krovak\", \"krovak\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "export default function(e0, e1, e2, e3, phi) {\r\n return (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi));\r\n}", "export default function(x) {\r\n return (1 - 0.25 * x * (1 + x / 16 * (3 + 1.25 * x)));\r\n}", "export default function(x) {\r\n return (0.375 * x * (1 + 0.25 * x * (1 + 0.46875 * x)));\r\n}", "export default function(x) {\r\n return (0.05859375 * x * x * (1 + 0.75 * x));\r\n}", "export default function(x) {\r\n return (x * x * x * (35 / 3072));\r\n}", "export default function(a, e, sinphi) {\r\n var temp = e * sinphi;\r\n return a / Math.sqrt(1 - temp * temp);\r\n}", "import {HALF_PI} from '../constants/values';\r\nimport sign from './sign';\r\n\r\nexport default function(x) {\r\n return (Math.abs(x) < HALF_PI) ? x : (x - (sign(x) * Math.PI));\r\n}\r\n", "export default function(ml, e0, e1, e2, e3) {\r\n var phi;\r\n var dphi;\r\n\r\n phi = ml / e0;\r\n for (var i = 0; i < 15; i++) {\r\n dphi = (ml - (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi))) / (e0 - 2 * e1 * Math.cos(2 * phi) + 4 * e2 * Math.cos(4 * phi) - 6 * e3 * Math.cos(6 * phi));\r\n phi += dphi;\r\n if (Math.abs(dphi) <= 0.0000000001) {\r\n return phi;\r\n }\r\n }\r\n\r\n //..reportError(\"IMLFN-CONV:Latitude failed to converge after 15 iterations\");\r\n return NaN;\r\n}", "import mlfn from '../common/mlfn';\r\nimport e0fn from '../common/e0fn';\r\nimport e1fn from '../common/e1fn';\r\nimport e2fn from '../common/e2fn';\r\nimport e3fn from '../common/e3fn';\r\nimport gN from '../common/gN';\r\nimport adjust_lon from '../common/adjust_lon';\r\nimport adjust_lat from '../common/adjust_lat';\r\nimport imlfn from '../common/imlfn';\r\nimport {HALF_PI, EPSLN} from '../constants/values';\r\n\r\nexport function init() {\r\n if (!this.sphere) {\r\n this.e0 = e0fn(this.es);\r\n this.e1 = e1fn(this.es);\r\n this.e2 = e2fn(this.es);\r\n this.e3 = e3fn(this.es);\r\n this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);\r\n }\r\n}\r\n\r\n/* Cassini forward equations--mapping lat,long to x,y\r\n -----------------------------------------------------------------------*/\r\nexport function forward(p) {\r\n\r\n /* Forward equations\r\n -----------------*/\r\n var x, y;\r\n var lam = p.x;\r\n var phi = p.y;\r\n lam = adjust_lon(lam - this.long0);\r\n\r\n if (this.sphere) {\r\n x = this.a * Math.asin(Math.cos(phi) * Math.sin(lam));\r\n y = this.a * (Math.atan2(Math.tan(phi), Math.cos(lam)) - this.lat0);\r\n }\r\n else {\r\n //ellipsoid\r\n var sinphi = Math.sin(phi);\r\n var cosphi = Math.cos(phi);\r\n var nl = gN(this.a, this.e, sinphi);\r\n var tl = Math.tan(phi) * Math.tan(phi);\r\n var al = lam * Math.cos(phi);\r\n var asq = al * al;\r\n var cl = this.es * cosphi * cosphi / (1 - this.es);\r\n var ml = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);\r\n\r\n x = nl * al * (1 - asq * tl * (1 / 6 - (8 - tl + 8 * cl) * asq / 120));\r\n y = ml - this.ml0 + nl * sinphi / cosphi * asq * (0.5 + (5 - tl + 6 * cl) * asq / 24);\r\n\r\n\r\n }\r\n\r\n p.x = x + this.x0;\r\n p.y = y + this.y0;\r\n return p;\r\n}\r\n\r\n/* Inverse equations\r\n -----------------*/\r\nexport function inverse(p) {\r\n p.x -= this.x0;\r\n p.y -= this.y0;\r\n var x = p.x / this.a;\r\n var y = p.y / this.a;\r\n var phi, lam;\r\n\r\n if (this.sphere) {\r\n var dd = y + this.lat0;\r\n phi = Math.asin(Math.sin(dd) * Math.cos(x));\r\n lam = Math.atan2(Math.tan(x), Math.cos(dd));\r\n }\r\n else {\r\n /* ellipsoid */\r\n var ml1 = this.ml0 / this.a + y;\r\n var phi1 = imlfn(ml1, this.e0, this.e1, this.e2, this.e3);\r\n if (Math.abs(Math.abs(phi1) - HALF_PI) <= EPSLN) {\r\n p.x = this.long0;\r\n p.y = HALF_PI;\r\n if (y < 0) {\r\n p.y *= -1;\r\n }\r\n return p;\r\n }\r\n var nl1 = gN(this.a, this.e, Math.sin(phi1));\r\n\r\n var rl1 = nl1 * nl1 * nl1 / this.a / this.a * (1 - this.es);\r\n var tl1 = Math.pow(Math.tan(phi1), 2);\r\n var dl = x * this.a / nl1;\r\n var dsq = dl * dl;\r\n phi = phi1 - nl1 * Math.tan(phi1) / rl1 * dl * dl * (0.5 - (1 + 3 * tl1) * dl * dl / 24);\r\n lam = dl * (1 - dsq * (tl1 / 3 + (1 + 3 * tl1) * tl1 * dsq / 15)) / Math.cos(phi1);\r\n\r\n }\r\n\r\n p.x = adjust_lon(lam + this.long0);\r\n p.y = adjust_lat(phi);\r\n return p;\r\n\r\n}\r\n\r\nexport var names = [\"Cassini\", \"Cassini_Soldner\", \"cass\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "export default function(eccent, sinphi) {\r\n var con;\r\n if (eccent > 1.0e-7) {\r\n con = eccent * sinphi;\r\n return ((1 - eccent * eccent) * (sinphi / (1 - con * con) - (0.5 / eccent) * Math.log((1 - con) / (1 + con))));\r\n }\r\n else {\r\n return (2 * sinphi);\r\n }\r\n}", "\r\nimport {HALF_PI, EPSLN, FORTPI} from '../constants/values';\r\n\r\nimport qsfnz from '../common/qsfnz';\r\nimport adjust_lon from '../common/adjust_lon';\r\n\r\n/*\r\n reference\r\n \"New Equal-Area Map Projections for Noncircular Regions\", John P. Snyder,\r\n The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.\r\n */\r\n\r\nexport var S_POLE = 1;\r\n\r\nexport var N_POLE = 2;\r\nexport var EQUIT = 3;\r\nexport var OBLIQ = 4;\r\n\r\n/* Initialize the Lambert Azimuthal Equal Area projection\r\n ------------------------------------------------------*/\r\nexport function init() {\r\n var t = Math.abs(this.lat0);\r\n if (Math.abs(t - HALF_PI) < EPSLN) {\r\n this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE;\r\n }\r\n else if (Math.abs(t) < EPSLN) {\r\n this.mode = this.EQUIT;\r\n }\r\n else {\r\n this.mode = this.OBLIQ;\r\n }\r\n if (this.es > 0) {\r\n var sinphi;\r\n\r\n this.qp = qsfnz(this.e, 1);\r\n this.mmf = 0.5 / (1 - this.es);\r\n this.apa = authset(this.es);\r\n switch (this.mode) {\r\n case this.N_POLE:\r\n this.dd = 1;\r\n break;\r\n case this.S_POLE:\r\n this.dd = 1;\r\n break;\r\n case this.EQUIT:\r\n this.rq = Math.sqrt(0.5 * this.qp);\r\n this.dd = 1 / this.rq;\r\n this.xmf = 1;\r\n this.ymf = 0.5 * this.qp;\r\n break;\r\n case this.OBLIQ:\r\n this.rq = Math.sqrt(0.5 * this.qp);\r\n sinphi = Math.sin(this.lat0);\r\n this.sinb1 = qsfnz(this.e, sinphi) / this.qp;\r\n this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1);\r\n this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * sinphi * sinphi) * this.rq * this.cosb1);\r\n this.ymf = (this.xmf = this.rq) / this.dd;\r\n this.xmf *= this.dd;\r\n break;\r\n }\r\n }\r\n else {\r\n if (this.mode === this.OBLIQ) {\r\n this.sinph0 = Math.sin(this.lat0);\r\n this.cosph0 = Math.cos(this.lat0);\r\n }\r\n }\r\n}\r\n\r\n/* Lambert Azimuthal Equal Area forward equations--mapping lat,long to x,y\r\n -----------------------------------------------------------------------*/\r\nexport function forward(p) {\r\n\r\n /* Forward equations\r\n -----------------*/\r\n var x, y, coslam, sinlam, sinphi, q, sinb, cosb, b, cosphi;\r\n var lam = p.x;\r\n var phi = p.y;\r\n\r\n lam = adjust_lon(lam - this.long0);\r\n if (this.sphere) {\r\n sinphi = Math.sin(phi);\r\n cosphi = Math.cos(phi);\r\n coslam = Math.cos(lam);\r\n if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {\r\n y = (this.mode === this.EQUIT) ? 1 + cosphi * coslam : 1 + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam;\r\n if (y <= EPSLN) {\r\n return null;\r\n }\r\n y = Math.sqrt(2 / y);\r\n x = y * cosphi * Math.sin(lam);\r\n y *= (this.mode === this.EQUIT) ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam;\r\n }\r\n else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {\r\n if (this.mode === this.N_POLE) {\r\n coslam = -coslam;\r\n }\r\n if (Math.abs(phi + this.lat0) < EPSLN) {\r\n return null;\r\n }\r\n y = FORTPI - phi * 0.5;\r\n y = 2 * ((this.mode === this.S_POLE) ? Math.cos(y) : Math.sin(y));\r\n x = y * Math.sin(lam);\r\n y *= coslam;\r\n }\r\n }\r\n else {\r\n sinb = 0;\r\n cosb = 0;\r\n b = 0;\r\n coslam = Math.cos(lam);\r\n sinlam = Math.sin(lam);\r\n sinphi = Math.sin(phi);\r\n q = qsfnz(this.e, sinphi);\r\n if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {\r\n sinb = q / this.qp;\r\n cosb = Math.sqrt(1 - sinb * sinb);\r\n }\r\n switch (this.mode) {\r\n case this.OBLIQ:\r\n b = 1 + this.sinb1 * sinb + this.cosb1 * cosb * coslam;\r\n break;\r\n case this.EQUIT:\r\n b = 1 + cosb * coslam;\r\n break;\r\n case this.N_POLE:\r\n b = HALF_PI + phi;\r\n q = this.qp - q;\r\n break;\r\n case this.S_POLE:\r\n b = phi - HALF_PI;\r\n q = this.qp + q;\r\n break;\r\n }\r\n if (Math.abs(b) < EPSLN) {\r\n return null;\r\n }\r\n switch (this.mode) {\r\n case this.OBLIQ:\r\n case this.EQUIT:\r\n b = Math.sqrt(2 / b);\r\n if (this.mode === this.OBLIQ) {\r\n y = this.ymf * b * (this.cosb1 * sinb - this.sinb1 * cosb * coslam);\r\n }\r\n else {\r\n y = (b = Math.sqrt(2 / (1 + cosb * coslam))) * sinb * this.ymf;\r\n }\r\n x = this.xmf * b * cosb * sinlam;\r\n break;\r\n case this.N_POLE:\r\n case this.S_POLE:\r\n if (q >= 0) {\r\n x = (b = Math.sqrt(q)) * sinlam;\r\n y = coslam * ((this.mode === this.S_POLE) ? b : -b);\r\n }\r\n else {\r\n x = y = 0;\r\n }\r\n break;\r\n }\r\n }\r\n\r\n p.x = this.a * x + this.x0;\r\n p.y = this.a * y + this.y0;\r\n return p;\r\n}\r\n\r\n/* Inverse equations\r\n -----------------*/\r\nexport function inverse(p) {\r\n p.x -= this.x0;\r\n p.y -= this.y0;\r\n var x = p.x / this.a;\r\n var y = p.y / this.a;\r\n var lam, phi, cCe, sCe, q, rho, ab;\r\n if (this.sphere) {\r\n var cosz = 0,\r\n rh, sinz = 0;\r\n\r\n rh = Math.sqrt(x * x + y * y);\r\n phi = rh * 0.5;\r\n if (phi > 1) {\r\n return null;\r\n }\r\n phi = 2 * Math.asin(phi);\r\n if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {\r\n sinz = Math.sin(phi);\r\n cosz = Math.cos(phi);\r\n }\r\n switch (this.mode) {\r\n case this.EQUIT:\r\n phi = (Math.abs(rh) <= EPSLN) ? 0 : Math.asin(y * sinz / rh);\r\n x *= sinz;\r\n y = cosz * rh;\r\n break;\r\n case this.OBLIQ:\r\n phi = (Math.abs(rh) <= EPSLN) ? this.lat0 : Math.asin(cosz * this.sinph0 + y * sinz * this.cosph0 / rh);\r\n x *= sinz * this.cosph0;\r\n y = (cosz - Math.sin(phi) * this.sinph0) * rh;\r\n break;\r\n case this.N_POLE:\r\n y = -y;\r\n phi = HALF_PI - phi;\r\n break;\r\n case this.S_POLE:\r\n phi -= HALF_PI;\r\n break;\r\n }\r\n lam = (y === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ)) ? 0 : Math.atan2(x, y);\r\n }\r\n else {\r\n ab = 0;\r\n if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {\r\n x /= this.dd;\r\n y *= this.dd;\r\n rho = Math.sqrt(x * x + y * y);\r\n if (rho < EPSLN) {\r\n p.x = this.long0;\r\n p.y = this.lat0;\r\n return p;\r\n }\r\n sCe = 2 * Math.asin(0.5 * rho / this.rq);\r\n cCe = Math.cos(sCe);\r\n x *= (sCe = Math.sin(sCe));\r\n if (this.mode === this.OBLIQ) {\r\n ab = cCe * this.sinb1 + y * sCe * this.cosb1 / rho;\r\n q = this.qp * ab;\r\n y = rho * this.cosb1 * cCe - y * this.sinb1 * sCe;\r\n }\r\n else {\r\n ab = y * sCe / rho;\r\n q = this.qp * ab;\r\n y = rho * cCe;\r\n }\r\n }\r\n else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {\r\n if (this.mode === this.N_POLE) {\r\n y = -y;\r\n }\r\n q = (x * x + y * y);\r\n if (!q) {\r\n p.x = this.long0;\r\n p.y = this.lat0;\r\n return p;\r\n }\r\n ab = 1 - q / this.qp;\r\n if (this.mode === this.S_POLE) {\r\n ab = -ab;\r\n }\r\n }\r\n lam = Math.atan2(x, y);\r\n phi = authlat(Math.asin(ab), this.apa);\r\n }\r\n\r\n p.x = adjust_lon(this.long0 + lam);\r\n p.y = phi;\r\n return p;\r\n}\r\n\r\n/* determine latitude from authalic latitude */\r\nvar P00 = 0.33333333333333333333;\r\n\r\nvar P01 = 0.17222222222222222222;\r\nvar P02 = 0.10257936507936507936;\r\nvar P10 = 0.06388888888888888888;\r\nvar P11 = 0.06640211640211640211;\r\nvar P20 = 0.01641501294219154443;\r\n\r\nfunction authset(es) {\r\n var t;\r\n var APA = [];\r\n APA[0] = es * P00;\r\n t = es * es;\r\n APA[0] += t * P01;\r\n APA[1] = t * P10;\r\n t *= es;\r\n APA[0] += t * P02;\r\n APA[1] += t * P11;\r\n APA[2] = t * P20;\r\n return APA;\r\n}\r\n\r\nfunction authlat(beta, APA) {\r\n var t = beta + beta;\r\n return (beta + APA[0] * Math.sin(t) + APA[1] * Math.sin(t + t) + APA[2] * Math.sin(t + t + t));\r\n}\r\n\r\nexport var names = [\"Lambert Azimuthal Equal Area\", \"Lambert_Azimuthal_Equal_Area\", \"laea\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names,\r\n S_POLE: S_POLE,\r\n N_POLE: N_POLE,\r\n EQUIT: EQUIT,\r\n OBLIQ: OBLIQ\r\n};\r\n", "export default function(x) {\r\n if (Math.abs(x) > 1) {\r\n x = (x > 1) ? 1 : -1;\r\n }\r\n return Math.asin(x);\r\n}", "import msfnz from '../common/msfnz';\r\nimport qsfnz from '../common/qsfnz';\r\nimport adjust_lon from '../common/adjust_lon';\r\nimport asinz from '../common/asinz';\r\nimport {EPSLN} from '../constants/values';\r\n\r\nexport function init() {\r\n\r\n if (Math.abs(this.lat1 + this.lat2) < EPSLN) {\r\n return;\r\n }\r\n this.temp = this.b / this.a;\r\n this.es = 1 - Math.pow(this.temp, 2);\r\n this.e3 = Math.sqrt(this.es);\r\n\r\n this.sin_po = Math.sin(this.lat1);\r\n this.cos_po = Math.cos(this.lat1);\r\n this.t1 = this.sin_po;\r\n this.con = this.sin_po;\r\n this.ms1 = msfnz(this.e3, this.sin_po, this.cos_po);\r\n this.qs1 = qsfnz(this.e3, this.sin_po);\r\n\r\n this.sin_po = Math.sin(this.lat2);\r\n this.cos_po = Math.cos(this.lat2);\r\n this.t2 = this.sin_po;\r\n this.ms2 = msfnz(this.e3, this.sin_po, this.cos_po);\r\n this.qs2 = qsfnz(this.e3, this.sin_po);\r\n\r\n this.sin_po = Math.sin(this.lat0);\r\n this.cos_po = Math.cos(this.lat0);\r\n this.t3 = this.sin_po;\r\n this.qs0 = qsfnz(this.e3, this.sin_po);\r\n\r\n if (Math.abs(this.lat1 - this.lat2) > EPSLN) {\r\n this.ns0 = (this.ms1 * this.ms1 - this.ms2 * this.ms2) / (this.qs2 - this.qs1);\r\n }\r\n else {\r\n this.ns0 = this.con;\r\n }\r\n this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1;\r\n this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0) / this.ns0;\r\n}\r\n\r\n/* Albers Conical Equal Area forward equations--mapping lat,long to x,y\r\n -------------------------------------------------------------------*/\r\nexport function forward(p) {\r\n\r\n var lon = p.x;\r\n var lat = p.y;\r\n\r\n this.sin_phi = Math.sin(lat);\r\n this.cos_phi = Math.cos(lat);\r\n\r\n var qs = qsfnz(this.e3, this.sin_phi);\r\n var rh1 = this.a * Math.sqrt(this.c - this.ns0 * qs) / this.ns0;\r\n var theta = this.ns0 * adjust_lon(lon - this.long0);\r\n var x = rh1 * Math.sin(theta) + this.x0;\r\n var y = this.rh - rh1 * Math.cos(theta) + this.y0;\r\n\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n var rh1, qs, con, theta, lon, lat;\r\n\r\n p.x -= this.x0;\r\n p.y = this.rh - p.y + this.y0;\r\n if (this.ns0 >= 0) {\r\n rh1 = Math.sqrt(p.x * p.x + p.y * p.y);\r\n con = 1;\r\n }\r\n else {\r\n rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);\r\n con = -1;\r\n }\r\n theta = 0;\r\n if (rh1 !== 0) {\r\n theta = Math.atan2(con * p.x, con * p.y);\r\n }\r\n con = rh1 * this.ns0 / this.a;\r\n if (this.sphere) {\r\n lat = Math.asin((this.c - con * con) / (2 * this.ns0));\r\n }\r\n else {\r\n qs = (this.c - con * con) / this.ns0;\r\n lat = this.phi1z(this.e3, qs);\r\n }\r\n\r\n lon = adjust_lon(theta / this.ns0 + this.long0);\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\n/* Function to compute phi1, the latitude for the inverse of the\r\n Albers Conical Equal-Area projection.\r\n-------------------------------------------*/\r\nexport function phi1z(eccent, qs) {\r\n var sinphi, cosphi, con, com, dphi;\r\n var phi = asinz(0.5 * qs);\r\n if (eccent < EPSLN) {\r\n return phi;\r\n }\r\n\r\n var eccnts = eccent * eccent;\r\n for (var i = 1; i <= 25; i++) {\r\n sinphi = Math.sin(phi);\r\n cosphi = Math.cos(phi);\r\n con = eccent * sinphi;\r\n com = 1 - con * con;\r\n dphi = 0.5 * com * com / cosphi * (qs / (1 - eccnts) - sinphi / com + 0.5 / eccent * Math.log((1 - con) / (1 + con)));\r\n phi = phi + dphi;\r\n if (Math.abs(dphi) <= 1e-7) {\r\n return phi;\r\n }\r\n }\r\n return null;\r\n}\r\n\r\nexport var names = [\"Albers_Conic_Equal_Area\", \"Albers\", \"aea\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names,\r\n phi1z: phi1z\r\n};\r\n", "import adjust_lon from '../common/adjust_lon';\r\nimport asinz from '../common/asinz';\r\nimport {EPSLN} from '../constants/values';\r\n\r\n/*\r\n reference:\r\n Wolfram Mathworld \"Gnomonic Projection\"\r\n http://mathworld.wolfram.com/GnomonicProjection.html\r\n Accessed: 12th November 2009\r\n */\r\nexport function init() {\r\n\r\n /* Place parameters in static storage for common use\r\n -------------------------------------------------*/\r\n this.sin_p14 = Math.sin(this.lat0);\r\n this.cos_p14 = Math.cos(this.lat0);\r\n // Approximation for projecting points to the horizon (infinity)\r\n this.infinity_dist = 1000 * this.a;\r\n this.rc = 1;\r\n}\r\n\r\n/* Gnomonic forward equations--mapping lat,long to x,y\r\n ---------------------------------------------------*/\r\nexport function forward(p) {\r\n var sinphi, cosphi; /* sin and cos value */\r\n var dlon; /* delta longitude value */\r\n var coslon; /* cos of longitude */\r\n var ksp; /* scale factor */\r\n var g;\r\n var x, y;\r\n var lon = p.x;\r\n var lat = p.y;\r\n /* Forward equations\r\n -----------------*/\r\n dlon = adjust_lon(lon - this.long0);\r\n\r\n sinphi = Math.sin(lat);\r\n cosphi = Math.cos(lat);\r\n\r\n coslon = Math.cos(dlon);\r\n g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon;\r\n ksp = 1;\r\n if ((g > 0) || (Math.abs(g) <= EPSLN)) {\r\n x = this.x0 + this.a * ksp * cosphi * Math.sin(dlon) / g;\r\n y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon) / g;\r\n }\r\n else {\r\n\r\n // Point is in the opposing hemisphere and is unprojectable\r\n // We still need to return a reasonable point, so we project\r\n // to infinity, on a bearing\r\n // equivalent to the northern hemisphere equivalent\r\n // This is a reasonable approximation for short shapes and lines that\r\n // straddle the horizon.\r\n\r\n x = this.x0 + this.infinity_dist * cosphi * Math.sin(dlon);\r\n y = this.y0 + this.infinity_dist * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);\r\n\r\n }\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n var rh; /* Rho */\r\n var sinc, cosc;\r\n var c;\r\n var lon, lat;\r\n\r\n /* Inverse equations\r\n -----------------*/\r\n p.x = (p.x - this.x0) / this.a;\r\n p.y = (p.y - this.y0) / this.a;\r\n\r\n p.x /= this.k0;\r\n p.y /= this.k0;\r\n\r\n if ((rh = Math.sqrt(p.x * p.x + p.y * p.y))) {\r\n c = Math.atan2(rh, this.rc);\r\n sinc = Math.sin(c);\r\n cosc = Math.cos(c);\r\n\r\n lat = asinz(cosc * this.sin_p14 + (p.y * sinc * this.cos_p14) / rh);\r\n lon = Math.atan2(p.x * sinc, rh * this.cos_p14 * cosc - p.y * this.sin_p14 * sinc);\r\n lon = adjust_lon(this.long0 + lon);\r\n }\r\n else {\r\n lat = this.phic0;\r\n lon = 0;\r\n }\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"gnom\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import {HALF_PI} from '../constants/values';\r\n\r\nexport default function(eccent, q) {\r\n var temp = 1 - (1 - eccent * eccent) / (2 * eccent) * Math.log((1 - eccent) / (1 + eccent));\r\n if (Math.abs(Math.abs(q) - temp) < 1.0E-6) {\r\n if (q < 0) {\r\n return (-1 * HALF_PI);\r\n }\r\n else {\r\n return HALF_PI;\r\n }\r\n }\r\n //var phi = 0.5* q/(1-eccent*eccent);\r\n var phi = Math.asin(0.5 * q);\r\n var dphi;\r\n var sin_phi;\r\n var cos_phi;\r\n var con;\r\n for (var i = 0; i < 30; i++) {\r\n sin_phi = Math.sin(phi);\r\n cos_phi = Math.cos(phi);\r\n con = eccent * sin_phi;\r\n dphi = Math.pow(1 - con * con, 2) / (2 * cos_phi) * (q / (1 - eccent * eccent) - sin_phi / (1 - con * con) + 0.5 / eccent * Math.log((1 - con) / (1 + con)));\r\n phi += dphi;\r\n if (Math.abs(dphi) <= 0.0000000001) {\r\n return phi;\r\n }\r\n }\r\n\r\n //console.log(\"IQSFN-CONV:Latitude failed to converge after 30 iterations\");\r\n return NaN;\r\n}\r\n", "import adjust_lon from '../common/adjust_lon';\r\nimport qsfnz from '../common/qsfnz';\r\nimport msfnz from '../common/msfnz';\r\nimport iqsfnz from '../common/iqsfnz';\r\n\r\n/*\r\n reference:\r\n \"Cartographic Projection Procedures for the UNIX Environment-\r\n A User's Manual\" by Gerald I. Evenden,\r\n USGS Open File Report 90-284and Release 4 Interim Reports (2003)\r\n*/\r\nexport function init() {\r\n //no-op\r\n if (!this.sphere) {\r\n this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));\r\n }\r\n}\r\n\r\n/* Cylindrical Equal Area forward equations--mapping lat,long to x,y\r\n ------------------------------------------------------------*/\r\nexport function forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n var x, y;\r\n /* Forward equations\r\n -----------------*/\r\n var dlon = adjust_lon(lon - this.long0);\r\n if (this.sphere) {\r\n x = this.x0 + this.a * dlon * Math.cos(this.lat_ts);\r\n y = this.y0 + this.a * Math.sin(lat) / Math.cos(this.lat_ts);\r\n }\r\n else {\r\n var qs = qsfnz(this.e, Math.sin(lat));\r\n x = this.x0 + this.a * this.k0 * dlon;\r\n y = this.y0 + this.a * qs * 0.5 / this.k0;\r\n }\r\n\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n}\r\n\r\n/* Cylindrical Equal Area inverse equations--mapping x,y to lat/long\r\n ------------------------------------------------------------*/\r\nexport function inverse(p) {\r\n p.x -= this.x0;\r\n p.y -= this.y0;\r\n var lon, lat;\r\n\r\n if (this.sphere) {\r\n lon = adjust_lon(this.long0 + (p.x / this.a) / Math.cos(this.lat_ts));\r\n lat = Math.asin((p.y / this.a) * Math.cos(this.lat_ts));\r\n }\r\n else {\r\n lat = iqsfnz(this.e, 2 * p.y * this.k0 / this.a);\r\n lon = adjust_lon(this.long0 + p.x / (this.a * this.k0));\r\n }\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"cea\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import adjust_lon from '../common/adjust_lon';\r\nimport adjust_lat from '../common/adjust_lat';\r\n\r\nexport function init() {\r\n\r\n this.x0 = this.x0 || 0;\r\n this.y0 = this.y0 || 0;\r\n this.lat0 = this.lat0 || 0;\r\n this.long0 = this.long0 || 0;\r\n this.lat_ts = this.lat_ts || 0;\r\n this.title = this.title || \"Equidistant Cylindrical (Plate Carre)\";\r\n\r\n this.rc = Math.cos(this.lat_ts);\r\n}\r\n\r\n// forward equations--mapping lat,long to x,y\r\n// -----------------------------------------------------------------\r\nexport function forward(p) {\r\n\r\n var lon = p.x;\r\n var lat = p.y;\r\n\r\n var dlon = adjust_lon(lon - this.long0);\r\n var dlat = adjust_lat(lat - this.lat0);\r\n p.x = this.x0 + (this.a * dlon * this.rc);\r\n p.y = this.y0 + (this.a * dlat);\r\n return p;\r\n}\r\n\r\n// inverse equations--mapping x,y to lat/long\r\n// -----------------------------------------------------------------\r\nexport function inverse(p) {\r\n\r\n var x = p.x;\r\n var y = p.y;\r\n\r\n p.x = adjust_lon(this.long0 + ((x - this.x0) / (this.a * this.rc)));\r\n p.y = adjust_lat(this.lat0 + ((y - this.y0) / (this.a)));\r\n return p;\r\n}\r\n\r\nexport var names = [\"Equirectangular\", \"Equidistant_Cylindrical\", \"eqc\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import e0fn from '../common/e0fn';\r\nimport e1fn from '../common/e1fn';\r\nimport e2fn from '../common/e2fn';\r\nimport e3fn from '../common/e3fn';\r\nimport adjust_lon from '../common/adjust_lon';\r\nimport adjust_lat from '../common/adjust_lat';\r\nimport mlfn from '../common/mlfn';\r\nimport {EPSLN} from '../constants/values';\r\n\r\nimport gN from '../common/gN';\r\nvar MAX_ITER = 20;\r\n\r\nexport function init() {\r\n /* Place parameters in static storage for common use\r\n -------------------------------------------------*/\r\n this.temp = this.b / this.a;\r\n this.es = 1 - Math.pow(this.temp, 2); // devait etre dans tmerc.js mais n y est pas donc je commente sinon retour de valeurs nulles\r\n this.e = Math.sqrt(this.es);\r\n this.e0 = e0fn(this.es);\r\n this.e1 = e1fn(this.es);\r\n this.e2 = e2fn(this.es);\r\n this.e3 = e3fn(this.es);\r\n this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0); //si que des zeros le calcul ne se fait pas\r\n}\r\n\r\n/* Polyconic forward equations--mapping lat,long to x,y\r\n ---------------------------------------------------*/\r\nexport function forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n var x, y, el;\r\n var dlon = adjust_lon(lon - this.long0);\r\n el = dlon * Math.sin(lat);\r\n if (this.sphere) {\r\n if (Math.abs(lat) <= EPSLN) {\r\n x = this.a * dlon;\r\n y = -1 * this.a * this.lat0;\r\n }\r\n else {\r\n x = this.a * Math.sin(el) / Math.tan(lat);\r\n y = this.a * (adjust_lat(lat - this.lat0) + (1 - Math.cos(el)) / Math.tan(lat));\r\n }\r\n }\r\n else {\r\n if (Math.abs(lat) <= EPSLN) {\r\n x = this.a * dlon;\r\n y = -1 * this.ml0;\r\n }\r\n else {\r\n var nl = gN(this.a, this.e, Math.sin(lat)) / Math.tan(lat);\r\n x = nl * Math.sin(el);\r\n y = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, lat) - this.ml0 + nl * (1 - Math.cos(el));\r\n }\r\n\r\n }\r\n p.x = x + this.x0;\r\n p.y = y + this.y0;\r\n return p;\r\n}\r\n\r\n/* Inverse equations\r\n -----------------*/\r\nexport function inverse(p) {\r\n var lon, lat, x, y, i;\r\n var al, bl;\r\n var phi, dphi;\r\n x = p.x - this.x0;\r\n y = p.y - this.y0;\r\n\r\n if (this.sphere) {\r\n if (Math.abs(y + this.a * this.lat0) <= EPSLN) {\r\n lon = adjust_lon(x / this.a + this.long0);\r\n lat = 0;\r\n }\r\n else {\r\n al = this.lat0 + y / this.a;\r\n bl = x * x / this.a / this.a + al * al;\r\n phi = al;\r\n var tanphi;\r\n for (i = MAX_ITER; i; --i) {\r\n tanphi = Math.tan(phi);\r\n dphi = -1 * (al * (phi * tanphi + 1) - phi - 0.5 * (phi * phi + bl) * tanphi) / ((phi - al) / tanphi - 1);\r\n phi += dphi;\r\n if (Math.abs(dphi) <= EPSLN) {\r\n lat = phi;\r\n break;\r\n }\r\n }\r\n lon = adjust_lon(this.long0 + (Math.asin(x * Math.tan(phi) / this.a)) / Math.sin(lat));\r\n }\r\n }\r\n else {\r\n if (Math.abs(y + this.ml0) <= EPSLN) {\r\n lat = 0;\r\n lon = adjust_lon(this.long0 + x / this.a);\r\n }\r\n else {\r\n\r\n al = (this.ml0 + y) / this.a;\r\n bl = x * x / this.a / this.a + al * al;\r\n phi = al;\r\n var cl, mln, mlnp, ma;\r\n var con;\r\n for (i = MAX_ITER; i; --i) {\r\n con = this.e * Math.sin(phi);\r\n cl = Math.sqrt(1 - con * con) * Math.tan(phi);\r\n mln = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);\r\n mlnp = this.e0 - 2 * this.e1 * Math.cos(2 * phi) + 4 * this.e2 * Math.cos(4 * phi) - 6 * this.e3 * Math.cos(6 * phi);\r\n ma = mln / this.a;\r\n dphi = (al * (cl * ma + 1) - ma - 0.5 * cl * (ma * ma + bl)) / (this.es * Math.sin(2 * phi) * (ma * ma + bl - 2 * al * ma) / (4 * cl) + (al - ma) * (cl * mlnp - 2 / Math.sin(2 * phi)) - mlnp);\r\n phi -= dphi;\r\n if (Math.abs(dphi) <= EPSLN) {\r\n lat = phi;\r\n break;\r\n }\r\n }\r\n\r\n //lat=phi4z(this.e,this.e0,this.e1,this.e2,this.e3,al,bl,0,0);\r\n cl = Math.sqrt(1 - this.es * Math.pow(Math.sin(lat), 2)) * Math.tan(lat);\r\n lon = adjust_lon(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat));\r\n }\r\n }\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"Polyconic\", \"poly\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import {SEC_TO_RAD} from '../constants/values';\r\n\r\n/*\r\n reference\r\n Department of Land and Survey Technical Circular 1973/32\r\n http://www.linz.govt.nz/docs/miscellaneous/nz-map-definition.pdf\r\n OSG Technical Report 4.1\r\n http://www.linz.govt.nz/docs/miscellaneous/nzmg.pdf\r\n */\r\n\r\n/**\r\n * iterations: Number of iterations to refine inverse transform.\r\n * 0 -> km accuracy\r\n * 1 -> m accuracy -- suitable for most mapping applications\r\n * 2 -> mm accuracy\r\n */\r\nexport var iterations = 1;\r\n\r\nexport function init() {\r\n this.A = [];\r\n this.A[1] = 0.6399175073;\r\n this.A[2] = -0.1358797613;\r\n this.A[3] = 0.063294409;\r\n this.A[4] = -0.02526853;\r\n this.A[5] = 0.0117879;\r\n this.A[6] = -0.0055161;\r\n this.A[7] = 0.0026906;\r\n this.A[8] = -0.001333;\r\n this.A[9] = 0.00067;\r\n this.A[10] = -0.00034;\r\n\r\n this.B_re = [];\r\n this.B_im = [];\r\n this.B_re[1] = 0.7557853228;\r\n this.B_im[1] = 0;\r\n this.B_re[2] = 0.249204646;\r\n this.B_im[2] = 0.003371507;\r\n this.B_re[3] = -0.001541739;\r\n this.B_im[3] = 0.041058560;\r\n this.B_re[4] = -0.10162907;\r\n this.B_im[4] = 0.01727609;\r\n this.B_re[5] = -0.26623489;\r\n this.B_im[5] = -0.36249218;\r\n this.B_re[6] = -0.6870983;\r\n this.B_im[6] = -1.1651967;\r\n\r\n this.C_re = [];\r\n this.C_im = [];\r\n this.C_re[1] = 1.3231270439;\r\n this.C_im[1] = 0;\r\n this.C_re[2] = -0.577245789;\r\n this.C_im[2] = -0.007809598;\r\n this.C_re[3] = 0.508307513;\r\n this.C_im[3] = -0.112208952;\r\n this.C_re[4] = -0.15094762;\r\n this.C_im[4] = 0.18200602;\r\n this.C_re[5] = 1.01418179;\r\n this.C_im[5] = 1.64497696;\r\n this.C_re[6] = 1.9660549;\r\n this.C_im[6] = 2.5127645;\r\n\r\n this.D = [];\r\n this.D[1] = 1.5627014243;\r\n this.D[2] = 0.5185406398;\r\n this.D[3] = -0.03333098;\r\n this.D[4] = -0.1052906;\r\n this.D[5] = -0.0368594;\r\n this.D[6] = 0.007317;\r\n this.D[7] = 0.01220;\r\n this.D[8] = 0.00394;\r\n this.D[9] = -0.0013;\r\n}\r\n\r\n/**\r\n New Zealand Map Grid Forward - long/lat to x/y\r\n long/lat in radians\r\n */\r\nexport function forward(p) {\r\n var n;\r\n var lon = p.x;\r\n var lat = p.y;\r\n\r\n var delta_lat = lat - this.lat0;\r\n var delta_lon = lon - this.long0;\r\n\r\n // 1. Calculate d_phi and d_psi ... // and d_lambda\r\n // For this algorithm, delta_latitude is in seconds of arc x 10-5, so we need to scale to those units. Longitude is radians.\r\n var d_phi = delta_lat / SEC_TO_RAD * 1E-5;\r\n var d_lambda = delta_lon;\r\n var d_phi_n = 1; // d_phi^0\r\n\r\n var d_psi = 0;\r\n for (n = 1; n <= 10; n++) {\r\n d_phi_n = d_phi_n * d_phi;\r\n d_psi = d_psi + this.A[n] * d_phi_n;\r\n }\r\n\r\n // 2. Calculate theta\r\n var th_re = d_psi;\r\n var th_im = d_lambda;\r\n\r\n // 3. Calculate z\r\n var th_n_re = 1;\r\n var th_n_im = 0; // theta^0\r\n var th_n_re1;\r\n var th_n_im1;\r\n\r\n var z_re = 0;\r\n var z_im = 0;\r\n for (n = 1; n <= 6; n++) {\r\n th_n_re1 = th_n_re * th_re - th_n_im * th_im;\r\n th_n_im1 = th_n_im * th_re + th_n_re * th_im;\r\n th_n_re = th_n_re1;\r\n th_n_im = th_n_im1;\r\n z_re = z_re + this.B_re[n] * th_n_re - this.B_im[n] * th_n_im;\r\n z_im = z_im + this.B_im[n] * th_n_re + this.B_re[n] * th_n_im;\r\n }\r\n\r\n // 4. Calculate easting and northing\r\n p.x = (z_im * this.a) + this.x0;\r\n p.y = (z_re * this.a) + this.y0;\r\n\r\n return p;\r\n}\r\n\r\n/**\r\n New Zealand Map Grid Inverse - x/y to long/lat\r\n */\r\nexport function inverse(p) {\r\n var n;\r\n var x = p.x;\r\n var y = p.y;\r\n\r\n var delta_x = x - this.x0;\r\n var delta_y = y - this.y0;\r\n\r\n // 1. Calculate z\r\n var z_re = delta_y / this.a;\r\n var z_im = delta_x / this.a;\r\n\r\n // 2a. Calculate theta - first approximation gives km accuracy\r\n var z_n_re = 1;\r\n var z_n_im = 0; // z^0\r\n var z_n_re1;\r\n var z_n_im1;\r\n\r\n var th_re = 0;\r\n var th_im = 0;\r\n for (n = 1; n <= 6; n++) {\r\n z_n_re1 = z_n_re * z_re - z_n_im * z_im;\r\n z_n_im1 = z_n_im * z_re + z_n_re * z_im;\r\n z_n_re = z_n_re1;\r\n z_n_im = z_n_im1;\r\n th_re = th_re + this.C_re[n] * z_n_re - this.C_im[n] * z_n_im;\r\n th_im = th_im + this.C_im[n] * z_n_re + this.C_re[n] * z_n_im;\r\n }\r\n\r\n // 2b. Iterate to refine the accuracy of the calculation\r\n // 0 iterations gives km accuracy\r\n // 1 iteration gives m accuracy -- good enough for most mapping applications\r\n // 2 iterations bives mm accuracy\r\n for (var i = 0; i < this.iterations; i++) {\r\n var th_n_re = th_re;\r\n var th_n_im = th_im;\r\n var th_n_re1;\r\n var th_n_im1;\r\n\r\n var num_re = z_re;\r\n var num_im = z_im;\r\n for (n = 2; n <= 6; n++) {\r\n th_n_re1 = th_n_re * th_re - th_n_im * th_im;\r\n th_n_im1 = th_n_im * th_re + th_n_re * th_im;\r\n th_n_re = th_n_re1;\r\n th_n_im = th_n_im1;\r\n num_re = num_re + (n - 1) * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);\r\n num_im = num_im + (n - 1) * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);\r\n }\r\n\r\n th_n_re = 1;\r\n th_n_im = 0;\r\n var den_re = this.B_re[1];\r\n var den_im = this.B_im[1];\r\n for (n = 2; n <= 6; n++) {\r\n th_n_re1 = th_n_re * th_re - th_n_im * th_im;\r\n th_n_im1 = th_n_im * th_re + th_n_re * th_im;\r\n th_n_re = th_n_re1;\r\n th_n_im = th_n_im1;\r\n den_re = den_re + n * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);\r\n den_im = den_im + n * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);\r\n }\r\n\r\n // Complex division\r\n var den2 = den_re * den_re + den_im * den_im;\r\n th_re = (num_re * den_re + num_im * den_im) / den2;\r\n th_im = (num_im * den_re - num_re * den_im) / den2;\r\n }\r\n\r\n // 3. Calculate d_phi ... // and d_lambda\r\n var d_psi = th_re;\r\n var d_lambda = th_im;\r\n var d_psi_n = 1; // d_psi^0\r\n\r\n var d_phi = 0;\r\n for (n = 1; n <= 9; n++) {\r\n d_psi_n = d_psi_n * d_psi;\r\n d_phi = d_phi + this.D[n] * d_psi_n;\r\n }\r\n\r\n // 4. Calculate latitude and longitude\r\n // d_phi is calcuated in second of arc * 10^-5, so we need to scale back to radians. d_lambda is in radians.\r\n var lat = this.lat0 + (d_phi * SEC_TO_RAD * 1E5);\r\n var lon = this.long0 + d_lambda;\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n\r\n return p;\r\n}\r\n\r\nexport var names = [\"New_Zealand_Map_Grid\", \"nzmg\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import adjust_lon from '../common/adjust_lon';\r\n\r\n/*\r\n reference\r\n \"New Equal-Area Map Projections for Noncircular Regions\", John P. Snyder,\r\n The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.\r\n */\r\n\r\n\r\n/* Initialize the Miller Cylindrical projection\r\n -------------------------------------------*/\r\nexport function init() {\r\n //no-op\r\n}\r\n\r\n/* Miller Cylindrical forward equations--mapping lat,long to x,y\r\n ------------------------------------------------------------*/\r\nexport function forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n /* Forward equations\r\n -----------------*/\r\n var dlon = adjust_lon(lon - this.long0);\r\n var x = this.x0 + this.a * dlon;\r\n var y = this.y0 + this.a * Math.log(Math.tan((Math.PI / 4) + (lat / 2.5))) * 1.25;\r\n\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n}\r\n\r\n/* Miller Cylindrical inverse equations--mapping x,y to lat/long\r\n ------------------------------------------------------------*/\r\nexport function inverse(p) {\r\n p.x -= this.x0;\r\n p.y -= this.y0;\r\n\r\n var lon = adjust_lon(this.long0 + p.x / this.a);\r\n var lat = 2.5 * (Math.atan(Math.exp(0.8 * p.y / this.a)) - Math.PI / 4);\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"Miller_Cylindrical\", \"mill\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import adjust_lon from '../common/adjust_lon';\r\nimport adjust_lat from '../common/adjust_lat';\r\nimport pj_enfn from '../common/pj_enfn';\r\nvar MAX_ITER = 20;\r\nimport pj_mlfn from '../common/pj_mlfn';\r\nimport pj_inv_mlfn from '../common/pj_inv_mlfn';\r\nimport {EPSLN, HALF_PI} from '../constants/values';\r\n\r\nimport asinz from '../common/asinz';\r\n\r\n\r\nexport function init() {\r\n /* Place parameters in static storage for common use\r\n -------------------------------------------------*/\r\n\r\n\r\n if (!this.sphere) {\r\n this.en = pj_enfn(this.es);\r\n }\r\n else {\r\n this.n = 1;\r\n this.m = 0;\r\n this.es = 0;\r\n this.C_y = Math.sqrt((this.m + 1) / this.n);\r\n this.C_x = this.C_y / (this.m + 1);\r\n }\r\n\r\n}\r\n\r\n/* Sinusoidal forward equations--mapping lat,long to x,y\r\n -----------------------------------------------------*/\r\nexport function forward(p) {\r\n var x, y;\r\n var lon = p.x;\r\n var lat = p.y;\r\n /* Forward equations\r\n -----------------*/\r\n lon = adjust_lon(lon - this.long0);\r\n\r\n if (this.sphere) {\r\n if (!this.m) {\r\n lat = this.n !== 1 ? Math.asin(this.n * Math.sin(lat)) : lat;\r\n }\r\n else {\r\n var k = this.n * Math.sin(lat);\r\n for (var i = MAX_ITER; i; --i) {\r\n var V = (this.m * lat + Math.sin(lat) - k) / (this.m + Math.cos(lat));\r\n lat -= V;\r\n if (Math.abs(V) < EPSLN) {\r\n break;\r\n }\r\n }\r\n }\r\n x = this.a * this.C_x * lon * (this.m + Math.cos(lat));\r\n y = this.a * this.C_y * lat;\r\n\r\n }\r\n else {\r\n\r\n var s = Math.sin(lat);\r\n var c = Math.cos(lat);\r\n y = this.a * pj_mlfn(lat, s, c, this.en);\r\n x = this.a * lon * c / Math.sqrt(1 - this.es * s * s);\r\n }\r\n\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n var lat, temp, lon, s;\r\n\r\n p.x -= this.x0;\r\n lon = p.x / this.a;\r\n p.y -= this.y0;\r\n lat = p.y / this.a;\r\n\r\n if (this.sphere) {\r\n lat /= this.C_y;\r\n lon = lon / (this.C_x * (this.m + Math.cos(lat)));\r\n if (this.m) {\r\n lat = asinz((this.m * lat + Math.sin(lat)) / this.n);\r\n }\r\n else if (this.n !== 1) {\r\n lat = asinz(Math.sin(lat) / this.n);\r\n }\r\n lon = adjust_lon(lon + this.long0);\r\n lat = adjust_lat(lat);\r\n }\r\n else {\r\n lat = pj_inv_mlfn(p.y / this.a, this.es, this.en);\r\n s = Math.abs(lat);\r\n if (s < HALF_PI) {\r\n s = Math.sin(lat);\r\n temp = this.long0 + p.x * Math.sqrt(1 - this.es * s * s) / (this.a * Math.cos(lat));\r\n //temp = this.long0 + p.x / (this.a * Math.cos(lat));\r\n lon = adjust_lon(temp);\r\n }\r\n else if ((s - EPSLN) < HALF_PI) {\r\n lon = this.long0;\r\n }\r\n }\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"Sinusoidal\", \"sinu\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import adjust_lon from '../common/adjust_lon';\r\nexport function init() {}\r\nimport {EPSLN} from '../constants/values';\r\n/* Mollweide forward equations--mapping lat,long to x,y\r\n ----------------------------------------------------*/\r\nexport function forward(p) {\r\n\r\n /* Forward equations\r\n -----------------*/\r\n var lon = p.x;\r\n var lat = p.y;\r\n\r\n var delta_lon = adjust_lon(lon - this.long0);\r\n var theta = lat;\r\n var con = Math.PI * Math.sin(lat);\r\n\r\n /* Iterate using the Newton-Raphson method to find theta\r\n -----------------------------------------------------*/\r\n while (true) {\r\n var delta_theta = -(theta + Math.sin(theta) - con) / (1 + Math.cos(theta));\r\n theta += delta_theta;\r\n if (Math.abs(delta_theta) < EPSLN) {\r\n break;\r\n }\r\n }\r\n theta /= 2;\r\n\r\n /* If the latitude is 90 deg, force the x coordinate to be \"0 + false easting\"\r\n this is done here because of precision problems with \"cos(theta)\"\r\n --------------------------------------------------------------------------*/\r\n if (Math.PI / 2 - Math.abs(lat) < EPSLN) {\r\n delta_lon = 0;\r\n }\r\n var x = 0.900316316158 * this.a * delta_lon * Math.cos(theta) + this.x0;\r\n var y = 1.4142135623731 * this.a * Math.sin(theta) + this.y0;\r\n\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n var theta;\r\n var arg;\r\n\r\n /* Inverse equations\r\n -----------------*/\r\n p.x -= this.x0;\r\n p.y -= this.y0;\r\n arg = p.y / (1.4142135623731 * this.a);\r\n\r\n /* Because of division by zero problems, 'arg' can not be 1. Therefore\r\n a number very close to one is used instead.\r\n -------------------------------------------------------------------*/\r\n if (Math.abs(arg) > 0.999999999999) {\r\n arg = 0.999999999999;\r\n }\r\n theta = Math.asin(arg);\r\n var lon = adjust_lon(this.long0 + (p.x / (0.900316316158 * this.a * Math.cos(theta))));\r\n if (lon < (-Math.PI)) {\r\n lon = -Math.PI;\r\n }\r\n if (lon > Math.PI) {\r\n lon = Math.PI;\r\n }\r\n arg = (2 * theta + Math.sin(2 * theta)) / Math.PI;\r\n if (Math.abs(arg) > 1) {\r\n arg = 1;\r\n }\r\n var lat = Math.asin(arg);\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"Mollweide\", \"moll\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import e0fn from '../common/e0fn';\r\nimport e1fn from '../common/e1fn';\r\nimport e2fn from '../common/e2fn';\r\nimport e3fn from '../common/e3fn';\r\nimport msfnz from '../common/msfnz';\r\nimport mlfn from '../common/mlfn';\r\nimport adjust_lon from '../common/adjust_lon';\r\nimport adjust_lat from '../common/adjust_lat';\r\nimport imlfn from '../common/imlfn';\r\nimport {EPSLN} from '../constants/values';\r\n\r\nexport function init() {\r\n\r\n /* Place parameters in static storage for common use\r\n -------------------------------------------------*/\r\n // Standard Parallels cannot be equal and on opposite sides of the equator\r\n if (Math.abs(this.lat1 + this.lat2) < EPSLN) {\r\n return;\r\n }\r\n this.lat2 = this.lat2 || this.lat1;\r\n this.temp = this.b / this.a;\r\n this.es = 1 - Math.pow(this.temp, 2);\r\n this.e = Math.sqrt(this.es);\r\n this.e0 = e0fn(this.es);\r\n this.e1 = e1fn(this.es);\r\n this.e2 = e2fn(this.es);\r\n this.e3 = e3fn(this.es);\r\n\r\n this.sinphi = Math.sin(this.lat1);\r\n this.cosphi = Math.cos(this.lat1);\r\n\r\n this.ms1 = msfnz(this.e, this.sinphi, this.cosphi);\r\n this.ml1 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat1);\r\n\r\n if (Math.abs(this.lat1 - this.lat2) < EPSLN) {\r\n this.ns = this.sinphi;\r\n }\r\n else {\r\n this.sinphi = Math.sin(this.lat2);\r\n this.cosphi = Math.cos(this.lat2);\r\n this.ms2 = msfnz(this.e, this.sinphi, this.cosphi);\r\n this.ml2 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);\r\n this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);\r\n }\r\n this.g = this.ml1 + this.ms1 / this.ns;\r\n this.ml0 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);\r\n this.rh = this.a * (this.g - this.ml0);\r\n}\r\n\r\n/* Equidistant Conic forward equations--mapping lat,long to x,y\r\n -----------------------------------------------------------*/\r\nexport function forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n var rh1;\r\n\r\n /* Forward equations\r\n -----------------*/\r\n if (this.sphere) {\r\n rh1 = this.a * (this.g - lat);\r\n }\r\n else {\r\n var ml = mlfn(this.e0, this.e1, this.e2, this.e3, lat);\r\n rh1 = this.a * (this.g - ml);\r\n }\r\n var theta = this.ns * adjust_lon(lon - this.long0);\r\n var x = this.x0 + rh1 * Math.sin(theta);\r\n var y = this.y0 + this.rh - rh1 * Math.cos(theta);\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n}\r\n\r\n/* Inverse equations\r\n -----------------*/\r\nexport function inverse(p) {\r\n p.x -= this.x0;\r\n p.y = this.rh - p.y + this.y0;\r\n var con, rh1, lat, lon;\r\n if (this.ns >= 0) {\r\n rh1 = Math.sqrt(p.x * p.x + p.y * p.y);\r\n con = 1;\r\n }\r\n else {\r\n rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);\r\n con = -1;\r\n }\r\n var theta = 0;\r\n if (rh1 !== 0) {\r\n theta = Math.atan2(con * p.x, con * p.y);\r\n }\r\n\r\n if (this.sphere) {\r\n lon = adjust_lon(this.long0 + theta / this.ns);\r\n lat = adjust_lat(this.g - rh1 / this.a);\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n else {\r\n var ml = this.g - rh1 / this.a;\r\n lat = imlfn(ml, this.e0, this.e1, this.e2, this.e3);\r\n lon = adjust_lon(this.long0 + theta / this.ns);\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n\r\n}\r\n\r\nexport var names = [\"Equidistant_Conic\", \"eqdc\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import adjust_lon from '../common/adjust_lon';\r\n\r\nimport {HALF_PI, EPSLN} from '../constants/values';\r\n\r\nimport asinz from '../common/asinz';\r\n\r\n/* Initialize the Van Der Grinten projection\r\n ----------------------------------------*/\r\nexport function init() {\r\n //this.R = 6370997; //Radius of earth\r\n this.R = this.a;\r\n}\r\n\r\nexport function forward(p) {\r\n\r\n var lon = p.x;\r\n var lat = p.y;\r\n\r\n /* Forward equations\r\n -----------------*/\r\n var dlon = adjust_lon(lon - this.long0);\r\n var x, y;\r\n\r\n if (Math.abs(lat) <= EPSLN) {\r\n x = this.x0 + this.R * dlon;\r\n y = this.y0;\r\n }\r\n var theta = asinz(2 * Math.abs(lat / Math.PI));\r\n if ((Math.abs(dlon) <= EPSLN) || (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN)) {\r\n x = this.x0;\r\n if (lat >= 0) {\r\n y = this.y0 + Math.PI * this.R * Math.tan(0.5 * theta);\r\n }\r\n else {\r\n y = this.y0 + Math.PI * this.R * -Math.tan(0.5 * theta);\r\n }\r\n // return(OK);\r\n }\r\n var al = 0.5 * Math.abs((Math.PI / dlon) - (dlon / Math.PI));\r\n var asq = al * al;\r\n var sinth = Math.sin(theta);\r\n var costh = Math.cos(theta);\r\n\r\n var g = costh / (sinth + costh - 1);\r\n var gsq = g * g;\r\n var m = g * (2 / sinth - 1);\r\n var msq = m * m;\r\n var con = Math.PI * this.R * (al * (g - msq) + Math.sqrt(asq * (g - msq) * (g - msq) - (msq + asq) * (gsq - msq))) / (msq + asq);\r\n if (dlon < 0) {\r\n con = -con;\r\n }\r\n x = this.x0 + con;\r\n //con = Math.abs(con / (Math.PI * this.R));\r\n var q = asq + g;\r\n con = Math.PI * this.R * (m * q - al * Math.sqrt((msq + asq) * (asq + 1) - q * q)) / (msq + asq);\r\n if (lat >= 0) {\r\n //y = this.y0 + Math.PI * this.R * Math.sqrt(1 - con * con - 2 * al * con);\r\n y = this.y0 + con;\r\n }\r\n else {\r\n //y = this.y0 - Math.PI * this.R * Math.sqrt(1 - con * con - 2 * al * con);\r\n y = this.y0 - con;\r\n }\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n}\r\n\r\n/* Van Der Grinten inverse equations--mapping x,y to lat/long\r\n ---------------------------------------------------------*/\r\nexport function inverse(p) {\r\n var lon, lat;\r\n var xx, yy, xys, c1, c2, c3;\r\n var a1;\r\n var m1;\r\n var con;\r\n var th1;\r\n var d;\r\n\r\n /* inverse equations\r\n -----------------*/\r\n p.x -= this.x0;\r\n p.y -= this.y0;\r\n con = Math.PI * this.R;\r\n xx = p.x / con;\r\n yy = p.y / con;\r\n xys = xx * xx + yy * yy;\r\n c1 = -Math.abs(yy) * (1 + xys);\r\n c2 = c1 - 2 * yy * yy + xx * xx;\r\n c3 = -2 * c1 + 1 + 2 * yy * yy + xys * xys;\r\n d = yy * yy / c3 + (2 * c2 * c2 * c2 / c3 / c3 / c3 - 9 * c1 * c2 / c3 / c3) / 27;\r\n a1 = (c1 - c2 * c2 / 3 / c3) / c3;\r\n m1 = 2 * Math.sqrt(-a1 / 3);\r\n con = ((3 * d) / a1) / m1;\r\n if (Math.abs(con) > 1) {\r\n if (con >= 0) {\r\n con = 1;\r\n }\r\n else {\r\n con = -1;\r\n }\r\n }\r\n th1 = Math.acos(con) / 3;\r\n if (p.y >= 0) {\r\n lat = (-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;\r\n }\r\n else {\r\n lat = -(-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;\r\n }\r\n\r\n if (Math.abs(xx) < EPSLN) {\r\n lon = this.long0;\r\n }\r\n else {\r\n lon = adjust_lon(this.long0 + Math.PI * (xys - 1 + Math.sqrt(1 + 2 * (xx * xx - yy * yy) + xys * xys)) / 2 / xx);\r\n }\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"Van_der_Grinten_I\", \"VanDerGrinten\", \"vandg\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import adjust_lon from '../common/adjust_lon';\r\nimport {HALF_PI, EPSLN} from '../constants/values';\r\n\r\nimport mlfn from '../common/mlfn';\r\nimport e0fn from '../common/e0fn';\r\nimport e1fn from '../common/e1fn';\r\nimport e2fn from '../common/e2fn';\r\nimport e3fn from '../common/e3fn';\r\nimport gN from '../common/gN';\r\nimport asinz from '../common/asinz';\r\nimport imlfn from '../common/imlfn';\r\n\r\n\r\n\r\nexport function init() {\r\n this.sin_p12 = Math.sin(this.lat0);\r\n this.cos_p12 = Math.cos(this.lat0);\r\n}\r\n\r\nexport function forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n var sinphi = Math.sin(p.y);\r\n var cosphi = Math.cos(p.y);\r\n var dlon = adjust_lon(lon - this.long0);\r\n var e0, e1, e2, e3, Mlp, Ml, tanphi, Nl1, Nl, psi, Az, G, H, GH, Hs, c, kp, cos_c, s, s2, s3, s4, s5;\r\n if (this.sphere) {\r\n if (Math.abs(this.sin_p12 - 1) <= EPSLN) {\r\n //North Pole case\r\n p.x = this.x0 + this.a * (HALF_PI - lat) * Math.sin(dlon);\r\n p.y = this.y0 - this.a * (HALF_PI - lat) * Math.cos(dlon);\r\n return p;\r\n }\r\n else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {\r\n //South Pole case\r\n p.x = this.x0 + this.a * (HALF_PI + lat) * Math.sin(dlon);\r\n p.y = this.y0 + this.a * (HALF_PI + lat) * Math.cos(dlon);\r\n return p;\r\n }\r\n else {\r\n //default case\r\n cos_c = this.sin_p12 * sinphi + this.cos_p12 * cosphi * Math.cos(dlon);\r\n c = Math.acos(cos_c);\r\n kp = c ? c / Math.sin(c) : 1;\r\n p.x = this.x0 + this.a * kp * cosphi * Math.sin(dlon);\r\n p.y = this.y0 + this.a * kp * (this.cos_p12 * sinphi - this.sin_p12 * cosphi * Math.cos(dlon));\r\n return p;\r\n }\r\n }\r\n else {\r\n e0 = e0fn(this.es);\r\n e1 = e1fn(this.es);\r\n e2 = e2fn(this.es);\r\n e3 = e3fn(this.es);\r\n if (Math.abs(this.sin_p12 - 1) <= EPSLN) {\r\n //North Pole case\r\n Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);\r\n Ml = this.a * mlfn(e0, e1, e2, e3, lat);\r\n p.x = this.x0 + (Mlp - Ml) * Math.sin(dlon);\r\n p.y = this.y0 - (Mlp - Ml) * Math.cos(dlon);\r\n return p;\r\n }\r\n else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {\r\n //South Pole case\r\n Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);\r\n Ml = this.a * mlfn(e0, e1, e2, e3, lat);\r\n p.x = this.x0 + (Mlp + Ml) * Math.sin(dlon);\r\n p.y = this.y0 + (Mlp + Ml) * Math.cos(dlon);\r\n return p;\r\n }\r\n else {\r\n //Default case\r\n tanphi = sinphi / cosphi;\r\n Nl1 = gN(this.a, this.e, this.sin_p12);\r\n Nl = gN(this.a, this.e, sinphi);\r\n psi = Math.atan((1 - this.es) * tanphi + this.es * Nl1 * this.sin_p12 / (Nl * cosphi));\r\n Az = Math.atan2(Math.sin(dlon), this.cos_p12 * Math.tan(psi) - this.sin_p12 * Math.cos(dlon));\r\n if (Az === 0) {\r\n s = Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));\r\n }\r\n else if (Math.abs(Math.abs(Az) - Math.PI) <= EPSLN) {\r\n s = -Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));\r\n }\r\n else {\r\n s = Math.asin(Math.sin(dlon) * Math.cos(psi) / Math.sin(Az));\r\n }\r\n G = this.e * this.sin_p12 / Math.sqrt(1 - this.es);\r\n H = this.e * this.cos_p12 * Math.cos(Az) / Math.sqrt(1 - this.es);\r\n GH = G * H;\r\n Hs = H * H;\r\n s2 = s * s;\r\n s3 = s2 * s;\r\n s4 = s3 * s;\r\n s5 = s4 * s;\r\n c = Nl1 * s * (1 - s2 * Hs * (1 - Hs) / 6 + s3 / 8 * GH * (1 - 2 * Hs) + s4 / 120 * (Hs * (4 - 7 * Hs) - 3 * G * G * (1 - 7 * Hs)) - s5 / 48 * GH);\r\n p.x = this.x0 + c * Math.sin(Az);\r\n p.y = this.y0 + c * Math.cos(Az);\r\n return p;\r\n }\r\n }\r\n\r\n\r\n}\r\n\r\nexport function inverse(p) {\r\n p.x -= this.x0;\r\n p.y -= this.y0;\r\n var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, N1, psi, Az, cosAz, tmp, A, B, D, Ee, F, sinpsi;\r\n if (this.sphere) {\r\n rh = Math.sqrt(p.x * p.x + p.y * p.y);\r\n if (rh > (2 * HALF_PI * this.a)) {\r\n return;\r\n }\r\n z = rh / this.a;\r\n\r\n sinz = Math.sin(z);\r\n cosz = Math.cos(z);\r\n\r\n lon = this.long0;\r\n if (Math.abs(rh) <= EPSLN) {\r\n lat = this.lat0;\r\n }\r\n else {\r\n lat = asinz(cosz * this.sin_p12 + (p.y * sinz * this.cos_p12) / rh);\r\n con = Math.abs(this.lat0) - HALF_PI;\r\n if (Math.abs(con) <= EPSLN) {\r\n if (this.lat0 >= 0) {\r\n lon = adjust_lon(this.long0 + Math.atan2(p.x, - p.y));\r\n }\r\n else {\r\n lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));\r\n }\r\n }\r\n else {\r\n /*con = cosz - this.sin_p12 * Math.sin(lat);\r\n if ((Math.abs(con) < EPSLN) && (Math.abs(p.x) < EPSLN)) {\r\n //no-op, just keep the lon value as is\r\n } else {\r\n var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh));\r\n lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh)));\r\n }*/\r\n lon = adjust_lon(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz));\r\n }\r\n }\r\n\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n else {\r\n e0 = e0fn(this.es);\r\n e1 = e1fn(this.es);\r\n e2 = e2fn(this.es);\r\n e3 = e3fn(this.es);\r\n if (Math.abs(this.sin_p12 - 1) <= EPSLN) {\r\n //North pole case\r\n Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);\r\n rh = Math.sqrt(p.x * p.x + p.y * p.y);\r\n M = Mlp - rh;\r\n lat = imlfn(M / this.a, e0, e1, e2, e3);\r\n lon = adjust_lon(this.long0 + Math.atan2(p.x, - 1 * p.y));\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {\r\n //South pole case\r\n Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);\r\n rh = Math.sqrt(p.x * p.x + p.y * p.y);\r\n M = rh - Mlp;\r\n\r\n lat = imlfn(M / this.a, e0, e1, e2, e3);\r\n lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n else {\r\n //default case\r\n rh = Math.sqrt(p.x * p.x + p.y * p.y);\r\n Az = Math.atan2(p.x, p.y);\r\n N1 = gN(this.a, this.e, this.sin_p12);\r\n cosAz = Math.cos(Az);\r\n tmp = this.e * this.cos_p12 * cosAz;\r\n A = -tmp * tmp / (1 - this.es);\r\n B = 3 * this.es * (1 - A) * this.sin_p12 * this.cos_p12 * cosAz / (1 - this.es);\r\n D = rh / N1;\r\n Ee = D - A * (1 + A) * Math.pow(D, 3) / 6 - B * (1 + 3 * A) * Math.pow(D, 4) / 24;\r\n F = 1 - A * Ee * Ee / 2 - D * Ee * Ee * Ee / 6;\r\n psi = Math.asin(this.sin_p12 * Math.cos(Ee) + this.cos_p12 * Math.sin(Ee) * cosAz);\r\n lon = adjust_lon(this.long0 + Math.asin(Math.sin(Az) * Math.sin(Ee) / Math.cos(psi)));\r\n sinpsi = Math.sin(psi);\r\n lat = Math.atan2((sinpsi - this.es * F * this.sin_p12) * Math.tan(psi), sinpsi * (1 - this.es));\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n }\r\n\r\n}\r\n\r\nexport var names = [\"Azimuthal_Equidistant\", \"aeqd\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import adjust_lon from '../common/adjust_lon';\r\nimport asinz from '../common/asinz';\r\nimport {EPSLN, HALF_PI} from '../constants/values';\r\n\r\nexport function init() {\r\n //double temp; /* temporary variable */\r\n\r\n /* Place parameters in static storage for common use\r\n -------------------------------------------------*/\r\n this.sin_p14 = Math.sin(this.lat0);\r\n this.cos_p14 = Math.cos(this.lat0);\r\n}\r\n\r\n/* Orthographic forward equations--mapping lat,long to x,y\r\n ---------------------------------------------------*/\r\nexport function forward(p) {\r\n var sinphi, cosphi; /* sin and cos value */\r\n var dlon; /* delta longitude value */\r\n var coslon; /* cos of longitude */\r\n var ksp; /* scale factor */\r\n var g, x, y;\r\n var lon = p.x;\r\n var lat = p.y;\r\n /* Forward equations\r\n -----------------*/\r\n dlon = adjust_lon(lon - this.long0);\r\n\r\n sinphi = Math.sin(lat);\r\n cosphi = Math.cos(lat);\r\n\r\n coslon = Math.cos(dlon);\r\n g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon;\r\n ksp = 1;\r\n if ((g > 0) || (Math.abs(g) <= EPSLN)) {\r\n x = this.a * ksp * cosphi * Math.sin(dlon);\r\n y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);\r\n }\r\n p.x = x;\r\n p.y = y;\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n var rh; /* height above ellipsoid */\r\n var z; /* angle */\r\n var sinz, cosz; /* sin of z and cos of z */\r\n var con;\r\n var lon, lat;\r\n /* Inverse equations\r\n -----------------*/\r\n p.x -= this.x0;\r\n p.y -= this.y0;\r\n rh = Math.sqrt(p.x * p.x + p.y * p.y);\r\n z = asinz(rh / this.a);\r\n\r\n sinz = Math.sin(z);\r\n cosz = Math.cos(z);\r\n\r\n lon = this.long0;\r\n if (Math.abs(rh) <= EPSLN) {\r\n lat = this.lat0;\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n lat = asinz(cosz * this.sin_p14 + (p.y * sinz * this.cos_p14) / rh);\r\n con = Math.abs(this.lat0) - HALF_PI;\r\n if (Math.abs(con) <= EPSLN) {\r\n if (this.lat0 >= 0) {\r\n lon = adjust_lon(this.long0 + Math.atan2(p.x, - p.y));\r\n }\r\n else {\r\n lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));\r\n }\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n }\r\n lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz), rh * this.cos_p14 * cosz - p.y * this.sin_p14 * sinz));\r\n p.x = lon;\r\n p.y = lat;\r\n return p;\r\n}\r\n\r\nexport var names = [\"ortho\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "// QSC projection rewritten from the original PROJ4\r\n// https://github.com/OSGeo/proj.4/blob/master/src/PJ_qsc.c\r\n\r\nimport {EPSLN, TWO_PI, SPI, HALF_PI, FORTPI} from '../constants/values';\r\n\r\n/* constants */\r\nvar FACE_ENUM = {\r\n FRONT: 1,\r\n RIGHT: 2,\r\n BACK: 3,\r\n LEFT: 4,\r\n TOP: 5,\r\n BOTTOM: 6\r\n};\r\n\r\nvar AREA_ENUM = {\r\n AREA_0: 1,\r\n AREA_1: 2,\r\n AREA_2: 3,\r\n AREA_3: 4\r\n};\r\n\r\nexport function init() {\r\n\r\n this.x0 = this.x0 || 0;\r\n this.y0 = this.y0 || 0;\r\n this.lat0 = this.lat0 || 0;\r\n this.long0 = this.long0 || 0;\r\n this.lat_ts = this.lat_ts || 0;\r\n this.title = this.title || \"Quadrilateralized Spherical Cube\";\r\n\r\n /* Determine the cube face from the center of projection. */\r\n if (this.lat0 >= HALF_PI - FORTPI / 2.0) {\r\n this.face = FACE_ENUM.TOP;\r\n } else if (this.lat0 <= -(HALF_PI - FORTPI / 2.0)) {\r\n this.face = FACE_ENUM.BOTTOM;\r\n } else if (Math.abs(this.long0) <= FORTPI) {\r\n this.face = FACE_ENUM.FRONT;\r\n } else if (Math.abs(this.long0) <= HALF_PI + FORTPI) {\r\n this.face = this.long0 > 0.0 ? FACE_ENUM.RIGHT : FACE_ENUM.LEFT;\r\n } else {\r\n this.face = FACE_ENUM.BACK;\r\n }\r\n\r\n /* Fill in useful values for the ellipsoid <-> sphere shift\r\n * described in [LK12]. */\r\n if (this.es !== 0) {\r\n this.one_minus_f = 1 - (this.a - this.b) / this.a;\r\n this.one_minus_f_squared = this.one_minus_f * this.one_minus_f;\r\n }\r\n}\r\n\r\n// QSC forward equations--mapping lat,long to x,y\r\n// -----------------------------------------------------------------\r\nexport function forward(p) {\r\n var xy = {x: 0, y: 0};\r\n var lat, lon;\r\n var theta, phi;\r\n var t, mu;\r\n /* nu; */\r\n var area = {value: 0};\r\n\r\n // move lon according to projection's lon\r\n p.x -= this.long0;\r\n\r\n /* Convert the geodetic latitude to a geocentric latitude.\r\n * This corresponds to the shift from the ellipsoid to the sphere\r\n * described in [LK12]. */\r\n if (this.es !== 0) {//if (P->es != 0) {\r\n lat = Math.atan(this.one_minus_f_squared * Math.tan(p.y));\r\n } else {\r\n lat = p.y;\r\n }\r\n\r\n /* Convert the input lat, lon into theta, phi as used by QSC.\r\n * This depends on the cube face and the area on it.\r\n * For the top and bottom face, we can compute theta and phi\r\n * directly from phi, lam. For the other faces, we must use\r\n * unit sphere cartesian coordinates as an intermediate step. */\r\n lon = p.x; //lon = lp.lam;\r\n if (this.face === FACE_ENUM.TOP) {\r\n phi = HALF_PI - lat;\r\n if (lon >= FORTPI && lon <= HALF_PI + FORTPI) {\r\n area.value = AREA_ENUM.AREA_0;\r\n theta = lon - HALF_PI;\r\n } else if (lon > HALF_PI + FORTPI || lon <= -(HALF_PI + FORTPI)) {\r\n area.value = AREA_ENUM.AREA_1;\r\n theta = (lon > 0.0 ? lon - SPI : lon + SPI);\r\n } else if (lon > -(HALF_PI + FORTPI) && lon <= -FORTPI) {\r\n area.value = AREA_ENUM.AREA_2;\r\n theta = lon + HALF_PI;\r\n } else {\r\n area.value = AREA_ENUM.AREA_3;\r\n theta = lon;\r\n }\r\n } else if (this.face === FACE_ENUM.BOTTOM) {\r\n phi = HALF_PI + lat;\r\n if (lon >= FORTPI && lon <= HALF_PI + FORTPI) {\r\n area.value = AREA_ENUM.AREA_0;\r\n theta = -lon + HALF_PI;\r\n } else if (lon < FORTPI && lon >= -FORTPI) {\r\n area.value = AREA_ENUM.AREA_1;\r\n theta = -lon;\r\n } else if (lon < -FORTPI && lon >= -(HALF_PI + FORTPI)) {\r\n area.value = AREA_ENUM.AREA_2;\r\n theta = -lon - HALF_PI;\r\n } else {\r\n area.value = AREA_ENUM.AREA_3;\r\n theta = (lon > 0.0 ? -lon + SPI : -lon - SPI);\r\n }\r\n } else {\r\n var q, r, s;\r\n var sinlat, coslat;\r\n var sinlon, coslon;\r\n\r\n if (this.face === FACE_ENUM.RIGHT) {\r\n lon = qsc_shift_lon_origin(lon, +HALF_PI);\r\n } else if (this.face === FACE_ENUM.BACK) {\r\n lon = qsc_shift_lon_origin(lon, +SPI);\r\n } else if (this.face === FACE_ENUM.LEFT) {\r\n lon = qsc_shift_lon_origin(lon, -HALF_PI);\r\n }\r\n sinlat = Math.sin(lat);\r\n coslat = Math.cos(lat);\r\n sinlon = Math.sin(lon);\r\n coslon = Math.cos(lon);\r\n q = coslat * coslon;\r\n r = coslat * sinlon;\r\n s = sinlat;\r\n\r\n if (this.face === FACE_ENUM.FRONT) {\r\n phi = Math.acos(q);\r\n theta = qsc_fwd_equat_face_theta(phi, s, r, area);\r\n } else if (this.face === FACE_ENUM.RIGHT) {\r\n phi = Math.acos(r);\r\n theta = qsc_fwd_equat_face_theta(phi, s, -q, area);\r\n } else if (this.face === FACE_ENUM.BACK) {\r\n phi = Math.acos(-q);\r\n theta = qsc_fwd_equat_face_theta(phi, s, -r, area);\r\n } else if (this.face === FACE_ENUM.LEFT) {\r\n phi = Math.acos(-r);\r\n theta = qsc_fwd_equat_face_theta(phi, s, q, area);\r\n } else {\r\n /* Impossible */\r\n phi = theta = 0;\r\n area.value = AREA_ENUM.AREA_0;\r\n }\r\n }\r\n\r\n /* Compute mu and nu for the area of definition.\r\n * For mu, see Eq. (3-21) in [OL76], but note the typos:\r\n * compare with Eq. (3-14). For nu, see Eq. (3-38). */\r\n mu = Math.atan((12 / SPI) * (theta + Math.acos(Math.sin(theta) * Math.cos(FORTPI)) - HALF_PI));\r\n t = Math.sqrt((1 - Math.cos(phi)) / (Math.cos(mu) * Math.cos(mu)) / (1 - Math.cos(Math.atan(1 / Math.cos(theta)))));\r\n\r\n /* Apply the result to the real area. */\r\n if (area.value === AREA_ENUM.AREA_1) {\r\n mu += HALF_PI;\r\n } else if (area.value === AREA_ENUM.AREA_2) {\r\n mu += SPI;\r\n } else if (area.value === AREA_ENUM.AREA_3) {\r\n mu += 1.5 * SPI;\r\n }\r\n\r\n /* Now compute x, y from mu and nu */\r\n xy.x = t * Math.cos(mu);\r\n xy.y = t * Math.sin(mu);\r\n xy.x = xy.x * this.a + this.x0;\r\n xy.y = xy.y * this.a + this.y0;\r\n\r\n p.x = xy.x;\r\n p.y = xy.y;\r\n return p;\r\n}\r\n\r\n// QSC inverse equations--mapping x,y to lat/long\r\n// -----------------------------------------------------------------\r\nexport function inverse(p) {\r\n var lp = {lam: 0, phi: 0};\r\n var mu, nu, cosmu, tannu;\r\n var tantheta, theta, cosphi, phi;\r\n var t;\r\n var area = {value: 0};\r\n\r\n /* de-offset */\r\n p.x = (p.x - this.x0) / this.a;\r\n p.y = (p.y - this.y0) / this.a;\r\n\r\n /* Convert the input x, y to the mu and nu angles as used by QSC.\r\n * This depends on the area of the cube face. */\r\n nu = Math.atan(Math.sqrt(p.x * p.x + p.y * p.y));\r\n mu = Math.atan2(p.y, p.x);\r\n if (p.x >= 0.0 && p.x >= Math.abs(p.y)) {\r\n area.value = AREA_ENUM.AREA_0;\r\n } else if (p.y >= 0.0 && p.y >= Math.abs(p.x)) {\r\n area.value = AREA_ENUM.AREA_1;\r\n mu -= HALF_PI;\r\n } else if (p.x < 0.0 && -p.x >= Math.abs(p.y)) {\r\n area.value = AREA_ENUM.AREA_2;\r\n mu = (mu < 0.0 ? mu + SPI : mu - SPI);\r\n } else {\r\n area.value = AREA_ENUM.AREA_3;\r\n mu += HALF_PI;\r\n }\r\n\r\n /* Compute phi and theta for the area of definition.\r\n * The inverse projection is not described in the original paper, but some\r\n * good hints can be found here (as of 2011-12-14):\r\n * http://fits.gsfc.nasa.gov/fitsbits/saf.93/saf.9302\r\n * (search for \"Message-Id: <9302181759.AA25477 at fits.cv.nrao.edu>\") */\r\n t = (SPI / 12) * Math.tan(mu);\r\n tantheta = Math.sin(t) / (Math.cos(t) - (1 / Math.sqrt(2)));\r\n theta = Math.atan(tantheta);\r\n cosmu = Math.cos(mu);\r\n tannu = Math.tan(nu);\r\n cosphi = 1 - cosmu * cosmu * tannu * tannu * (1 - Math.cos(Math.atan(1 / Math.cos(theta))));\r\n if (cosphi < -1) {\r\n cosphi = -1;\r\n } else if (cosphi > +1) {\r\n cosphi = +1;\r\n }\r\n\r\n /* Apply the result to the real area on the cube face.\r\n * For the top and bottom face, we can compute phi and lam directly.\r\n * For the other faces, we must use unit sphere cartesian coordinates\r\n * as an intermediate step. */\r\n if (this.face === FACE_ENUM.TOP) {\r\n phi = Math.acos(cosphi);\r\n lp.phi = HALF_PI - phi;\r\n if (area.value === AREA_ENUM.AREA_0) {\r\n lp.lam = theta + HALF_PI;\r\n } else if (area.value === AREA_ENUM.AREA_1) {\r\n lp.lam = (theta < 0.0 ? theta + SPI : theta - SPI);\r\n } else if (area.value === AREA_ENUM.AREA_2) {\r\n lp.lam = theta - HALF_PI;\r\n } else /* area.value == AREA_ENUM.AREA_3 */ {\r\n lp.lam = theta;\r\n }\r\n } else if (this.face === FACE_ENUM.BOTTOM) {\r\n phi = Math.acos(cosphi);\r\n lp.phi = phi - HALF_PI;\r\n if (area.value === AREA_ENUM.AREA_0) {\r\n lp.lam = -theta + HALF_PI;\r\n } else if (area.value === AREA_ENUM.AREA_1) {\r\n lp.lam = -theta;\r\n } else if (area.value === AREA_ENUM.AREA_2) {\r\n lp.lam = -theta - HALF_PI;\r\n } else /* area.value == AREA_ENUM.AREA_3 */ {\r\n lp.lam = (theta < 0.0 ? -theta - SPI : -theta + SPI);\r\n }\r\n } else {\r\n /* Compute phi and lam via cartesian unit sphere coordinates. */\r\n var q, r, s;\r\n q = cosphi;\r\n t = q * q;\r\n if (t >= 1) {\r\n s = 0;\r\n } else {\r\n s = Math.sqrt(1 - t) * Math.sin(theta);\r\n }\r\n t += s * s;\r\n if (t >= 1) {\r\n r = 0;\r\n } else {\r\n r = Math.sqrt(1 - t);\r\n }\r\n /* Rotate q,r,s into the correct area. */\r\n if (area.value === AREA_ENUM.AREA_1) {\r\n t = r;\r\n r = -s;\r\n s = t;\r\n } else if (area.value === AREA_ENUM.AREA_2) {\r\n r = -r;\r\n s = -s;\r\n } else if (area.value === AREA_ENUM.AREA_3) {\r\n t = r;\r\n r = s;\r\n s = -t;\r\n }\r\n /* Rotate q,r,s into the correct cube face. */\r\n if (this.face === FACE_ENUM.RIGHT) {\r\n t = q;\r\n q = -r;\r\n r = t;\r\n } else if (this.face === FACE_ENUM.BACK) {\r\n q = -q;\r\n r = -r;\r\n } else if (this.face === FACE_ENUM.LEFT) {\r\n t = q;\r\n q = r;\r\n r = -t;\r\n }\r\n /* Now compute phi and lam from the unit sphere coordinates. */\r\n lp.phi = Math.acos(-s) - HALF_PI;\r\n lp.lam = Math.atan2(r, q);\r\n if (this.face === FACE_ENUM.RIGHT) {\r\n lp.lam = qsc_shift_lon_origin(lp.lam, -HALF_PI);\r\n } else if (this.face === FACE_ENUM.BACK) {\r\n lp.lam = qsc_shift_lon_origin(lp.lam, -SPI);\r\n } else if (this.face === FACE_ENUM.LEFT) {\r\n lp.lam = qsc_shift_lon_origin(lp.lam, +HALF_PI);\r\n }\r\n }\r\n\r\n /* Apply the shift from the sphere to the ellipsoid as described\r\n * in [LK12]. */\r\n if (this.es !== 0) {\r\n var invert_sign;\r\n var tanphi, xa;\r\n invert_sign = (lp.phi < 0 ? 1 : 0);\r\n tanphi = Math.tan(lp.phi);\r\n xa = this.b / Math.sqrt(tanphi * tanphi + this.one_minus_f_squared);\r\n lp.phi = Math.atan(Math.sqrt(this.a * this.a - xa * xa) / (this.one_minus_f * xa));\r\n if (invert_sign) {\r\n lp.phi = -lp.phi;\r\n }\r\n }\r\n\r\n lp.lam += this.long0;\r\n p.x = lp.lam;\r\n p.y = lp.phi;\r\n return p;\r\n}\r\n\r\n/* Helper function for forward projection: compute the theta angle\r\n * and determine the area number. */\r\nfunction qsc_fwd_equat_face_theta(phi, y, x, area) {\r\n var theta;\r\n if (phi < EPSLN) {\r\n area.value = AREA_ENUM.AREA_0;\r\n theta = 0.0;\r\n } else {\r\n theta = Math.atan2(y, x);\r\n if (Math.abs(theta) <= FORTPI) {\r\n area.value = AREA_ENUM.AREA_0;\r\n } else if (theta > FORTPI && theta <= HALF_PI + FORTPI) {\r\n area.value = AREA_ENUM.AREA_1;\r\n theta -= HALF_PI;\r\n } else if (theta > HALF_PI + FORTPI || theta <= -(HALF_PI + FORTPI)) {\r\n area.value = AREA_ENUM.AREA_2;\r\n theta = (theta >= 0.0 ? theta - SPI : theta + SPI);\r\n } else {\r\n area.value = AREA_ENUM.AREA_3;\r\n theta += HALF_PI;\r\n }\r\n }\r\n return theta;\r\n}\r\n\r\n/* Helper function: shift the longitude. */\r\nfunction qsc_shift_lon_origin(lon, offset) {\r\n var slon = lon + offset;\r\n if (slon < -SPI) {\r\n slon += TWO_PI;\r\n } else if (slon > +SPI) {\r\n slon -= TWO_PI;\r\n }\r\n return slon;\r\n}\r\n\r\nexport var names = [\"Quadrilateralized Spherical Cube\", \"Quadrilateralized_Spherical_Cube\", \"qsc\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n\r\n", "// Robinson projection\r\n// Based on https://github.com/OSGeo/proj.4/blob/master/src/PJ_robin.c\r\n// Polynomial coeficients from http://article.gmane.org/gmane.comp.gis.proj-4.devel/6039\r\n\r\nimport {HALF_PI, D2R, R2D, EPSLN} from '../constants/values';\r\nimport adjust_lon from '../common/adjust_lon';\r\n\r\nvar COEFS_X = [\r\n [1.0000, 2.2199e-17, -7.15515e-05, 3.1103e-06],\r\n [0.9986, -0.000482243, -2.4897e-05, -1.3309e-06],\r\n [0.9954, -0.00083103, -4.48605e-05, -9.86701e-07],\r\n [0.9900, -0.00135364, -5.9661e-05, 3.6777e-06],\r\n [0.9822, -0.00167442, -4.49547e-06, -5.72411e-06],\r\n [0.9730, -0.00214868, -9.03571e-05, 1.8736e-08],\r\n [0.9600, -0.00305085, -9.00761e-05, 1.64917e-06],\r\n [0.9427, -0.00382792, -6.53386e-05, -2.6154e-06],\r\n [0.9216, -0.00467746, -0.00010457, 4.81243e-06],\r\n [0.8962, -0.00536223, -3.23831e-05, -5.43432e-06],\r\n [0.8679, -0.00609363, -0.000113898, 3.32484e-06],\r\n [0.8350, -0.00698325, -6.40253e-05, 9.34959e-07],\r\n [0.7986, -0.00755338, -5.00009e-05, 9.35324e-07],\r\n [0.7597, -0.00798324, -3.5971e-05, -2.27626e-06],\r\n [0.7186, -0.00851367, -7.01149e-05, -8.6303e-06],\r\n [0.6732, -0.00986209, -0.000199569, 1.91974e-05],\r\n [0.6213, -0.010418, 8.83923e-05, 6.24051e-06],\r\n [0.5722, -0.00906601, 0.000182, 6.24051e-06],\r\n [0.5322, -0.00677797, 0.000275608, 6.24051e-06]\r\n];\r\n\r\nvar COEFS_Y = [\r\n [-5.20417e-18, 0.0124, 1.21431e-18, -8.45284e-11],\r\n [0.0620, 0.0124, -1.26793e-09, 4.22642e-10],\r\n [0.1240, 0.0124, 5.07171e-09, -1.60604e-09],\r\n [0.1860, 0.0123999, -1.90189e-08, 6.00152e-09],\r\n [0.2480, 0.0124002, 7.10039e-08, -2.24e-08],\r\n [0.3100, 0.0123992, -2.64997e-07, 8.35986e-08],\r\n [0.3720, 0.0124029, 9.88983e-07, -3.11994e-07],\r\n [0.4340, 0.0123893, -3.69093e-06, -4.35621e-07],\r\n [0.4958, 0.0123198, -1.02252e-05, -3.45523e-07],\r\n [0.5571, 0.0121916, -1.54081e-05, -5.82288e-07],\r\n [0.6176, 0.0119938, -2.41424e-05, -5.25327e-07],\r\n [0.6769, 0.011713, -3.20223e-05, -5.16405e-07],\r\n [0.7346, 0.0113541, -3.97684e-05, -6.09052e-07],\r\n [0.7903, 0.0109107, -4.89042e-05, -1.04739e-06],\r\n [0.8435, 0.0103431, -6.4615e-05, -1.40374e-09],\r\n [0.8936, 0.00969686, -6.4636e-05, -8.547e-06],\r\n [0.9394, 0.00840947, -0.000192841, -4.2106e-06],\r\n [0.9761, 0.00616527, -0.000256, -4.2106e-06],\r\n [1.0000, 0.00328947, -0.000319159, -4.2106e-06]\r\n];\r\n\r\nvar FXC = 0.8487;\r\nvar FYC = 1.3523;\r\nvar C1 = R2D/5; // rad to 5-degree interval\r\nvar RC1 = 1/C1;\r\nvar NODES = 18;\r\n\r\nvar poly3_val = function(coefs, x) {\r\n return coefs[0] + x * (coefs[1] + x * (coefs[2] + x * coefs[3]));\r\n};\r\n\r\nvar poly3_der = function(coefs, x) {\r\n return coefs[1] + x * (2 * coefs[2] + x * 3 * coefs[3]);\r\n};\r\n\r\nfunction newton_rapshon(f_df, start, max_err, iters) {\r\n var x = start;\r\n for (; iters; --iters) {\r\n var upd = f_df(x);\r\n x -= upd;\r\n if (Math.abs(upd) < max_err) {\r\n break;\r\n }\r\n }\r\n return x;\r\n}\r\n\r\nexport function init() {\r\n this.x0 = this.x0 || 0;\r\n this.y0 = this.y0 || 0;\r\n this.long0 = this.long0 || 0;\r\n this.es = 0;\r\n this.title = this.title || \"Robinson\";\r\n}\r\n\r\nexport function forward(ll) {\r\n var lon = adjust_lon(ll.x - this.long0);\r\n\r\n var dphi = Math.abs(ll.y);\r\n var i = Math.floor(dphi * C1);\r\n if (i < 0) {\r\n i = 0;\r\n } else if (i >= NODES) {\r\n i = NODES - 1;\r\n }\r\n dphi = R2D * (dphi - RC1 * i);\r\n var xy = {\r\n x: poly3_val(COEFS_X[i], dphi) * lon,\r\n y: poly3_val(COEFS_Y[i], dphi)\r\n };\r\n if (ll.y < 0) {\r\n xy.y = -xy.y;\r\n }\r\n\r\n xy.x = xy.x * this.a * FXC + this.x0;\r\n xy.y = xy.y * this.a * FYC + this.y0;\r\n return xy;\r\n}\r\n\r\nexport function inverse(xy) {\r\n var ll = {\r\n x: (xy.x - this.x0) / (this.a * FXC),\r\n y: Math.abs(xy.y - this.y0) / (this.a * FYC)\r\n };\r\n\r\n if (ll.y >= 1) { // pathologic case\r\n ll.x /= COEFS_X[NODES][0];\r\n ll.y = xy.y < 0 ? -HALF_PI : HALF_PI;\r\n } else {\r\n // find table interval\r\n var i = Math.floor(ll.y * NODES);\r\n if (i < 0) {\r\n i = 0;\r\n } else if (i >= NODES) {\r\n i = NODES - 1;\r\n }\r\n for (;;) {\r\n if (COEFS_Y[i][0] > ll.y) {\r\n --i;\r\n } else if (COEFS_Y[i+1][0] <= ll.y) {\r\n ++i;\r\n } else {\r\n break;\r\n }\r\n }\r\n // linear interpolation in 5 degree interval\r\n var coefs = COEFS_Y[i];\r\n var t = 5 * (ll.y - coefs[0]) / (COEFS_Y[i+1][0] - coefs[0]);\r\n // find t so that poly3_val(coefs, t) = ll.y\r\n t = newton_rapshon(function(x) {\r\n return (poly3_val(coefs, x) - ll.y) / poly3_der(coefs, x);\r\n }, t, EPSLN, 100);\r\n\r\n ll.x /= poly3_val(COEFS_X[i], t);\r\n ll.y = (5 * i + t) * D2R;\r\n if (xy.y < 0) {\r\n ll.y = -ll.y;\r\n }\r\n }\r\n\r\n ll.x = adjust_lon(ll.x + this.long0);\r\n return ll;\r\n}\r\n\r\nexport var names = [\"Robinson\", \"robin\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import {\r\n geodeticToGeocentric,\r\n geocentricToGeodetic\r\n} from '../datumUtils';\r\n\r\nexport function init() {\r\n this.name = 'geocent';\r\n\r\n}\r\n\r\nexport function forward(p) {\r\n var point = geodeticToGeocentric(p, this.es, this.a);\r\n return point;\r\n}\r\n\r\nexport function inverse(p) {\r\n var point = geocentricToGeodetic(p, this.es, this.a, this.b);\r\n return point;\r\n}\r\n\r\nexport var names = [\"Geocentric\", 'geocentric', \"geocent\", \"Geocent\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};", "\r\nvar mode = {\r\n N_POLE: 0,\r\n S_POLE: 1,\r\n EQUIT: 2,\r\n OBLIQ: 3\r\n};\r\n\r\nimport { D2R, HALF_PI, EPSLN } from \"../constants/values\";\r\nimport hypot from \"../common/hypot\";\r\n\r\nvar params = {\r\n h: { def: 100000, num: true }, // default is Karman line, no default in PROJ.7\r\n azi: { def: 0, num: true, degrees: true }, // default is North\r\n tilt: { def: 0, num: true, degrees: true }, // default is Nadir\r\n long0: { def: 0, num: true }, // default is Greenwich, conversion to rad is automatic\r\n lat0: { def: 0, num: true } // default is Equator, conversion to rad is automatic\r\n};\r\n\r\nexport function init() {\r\n Object.keys(params).forEach(function (p) {\r\n if (typeof this[p] === \"undefined\") {\r\n this[p] = params[p].def;\r\n } else if (params[p].num && isNaN(this[p])) {\r\n throw new Error(\"Invalid parameter value, must be numeric \" + p + \" = \" + this[p]);\r\n } else if (params[p].num) {\r\n this[p] = parseFloat(this[p]);\r\n }\r\n if (params[p].degrees) {\r\n this[p] = this[p] * D2R;\r\n }\r\n }.bind(this));\r\n\r\n if (Math.abs((Math.abs(this.lat0) - HALF_PI)) < EPSLN) {\r\n this.mode = this.lat0 < 0 ? mode.S_POLE : mode.N_POLE;\r\n } else if (Math.abs(this.lat0) < EPSLN) {\r\n this.mode = mode.EQUIT;\r\n } else {\r\n this.mode = mode.OBLIQ;\r\n this.sinph0 = Math.sin(this.lat0);\r\n this.cosph0 = Math.cos(this.lat0);\r\n }\r\n\r\n this.pn1 = this.h / this.a; // Normalize relative to the Earth's radius\r\n\r\n if (this.pn1 <= 0 || this.pn1 > 1e10) {\r\n throw new Error(\"Invalid height\");\r\n }\r\n \r\n this.p = 1 + this.pn1;\r\n this.rp = 1 / this.p;\r\n this.h1 = 1 / this.pn1;\r\n this.pfact = (this.p + 1) * this.h1;\r\n this.es = 0;\r\n\r\n var omega = this.tilt;\r\n var gamma = this.azi;\r\n this.cg = Math.cos(gamma);\r\n this.sg = Math.sin(gamma);\r\n this.cw = Math.cos(omega);\r\n this.sw = Math.sin(omega);\r\n}\r\n\r\nexport function forward(p) {\r\n p.x -= this.long0;\r\n var sinphi = Math.sin(p.y);\r\n var cosphi = Math.cos(p.y);\r\n var coslam = Math.cos(p.x);\r\n var x, y;\r\n switch (this.mode) {\r\n case mode.OBLIQ:\r\n y = this.sinph0 * sinphi + this.cosph0 * cosphi * coslam;\r\n break;\r\n case mode.EQUIT:\r\n y = cosphi * coslam;\r\n break;\r\n case mode.S_POLE:\r\n y = -sinphi;\r\n break;\r\n case mode.N_POLE:\r\n y = sinphi;\r\n break;\r\n }\r\n y = this.pn1 / (this.p - y);\r\n x = y * cosphi * Math.sin(p.x);\r\n\r\n switch (this.mode) {\r\n case mode.OBLIQ:\r\n y *= this.cosph0 * sinphi - this.sinph0 * cosphi * coslam;\r\n break;\r\n case mode.EQUIT:\r\n y *= sinphi;\r\n break;\r\n case mode.N_POLE:\r\n y *= -(cosphi * coslam);\r\n break;\r\n case mode.S_POLE:\r\n y *= cosphi * coslam;\r\n break;\r\n }\r\n\r\n // Tilt \r\n var yt, ba;\r\n yt = y * this.cg + x * this.sg;\r\n ba = 1 / (yt * this.sw * this.h1 + this.cw);\r\n x = (x * this.cg - y * this.sg) * this.cw * ba;\r\n y = yt * ba;\r\n\r\n p.x = x * this.a;\r\n p.y = y * this.a;\r\n return p;\r\n}\r\n\r\nexport function inverse(p) {\r\n p.x /= this.a;\r\n p.y /= this.a;\r\n var r = { x: p.x, y: p.y };\r\n\r\n // Un-Tilt\r\n var bm, bq, yt;\r\n yt = 1 / (this.pn1 - p.y * this.sw);\r\n bm = this.pn1 * p.x * yt;\r\n bq = this.pn1 * p.y * this.cw * yt;\r\n p.x = bm * this.cg + bq * this.sg;\r\n p.y = bq * this.cg - bm * this.sg;\r\n\r\n var rh = hypot(p.x, p.y);\r\n if (Math.abs(rh) < EPSLN) {\r\n r.x = 0;\r\n r.y = p.y;\r\n } else {\r\n var cosz, sinz;\r\n sinz = 1 - rh * rh * this.pfact;\r\n sinz = (this.p - Math.sqrt(sinz)) / (this.pn1 / rh + rh / this.pn1);\r\n cosz = Math.sqrt(1 - sinz * sinz);\r\n switch (this.mode) {\r\n case mode.OBLIQ:\r\n r.y = Math.asin(cosz * this.sinph0 + p.y * sinz * this.cosph0 / rh);\r\n p.y = (cosz - this.sinph0 * Math.sin(r.y)) * rh;\r\n p.x *= sinz * this.cosph0;\r\n break;\r\n case mode.EQUIT:\r\n r.y = Math.asin(p.y * sinz / rh);\r\n p.y = cosz * rh;\r\n p.x *= sinz;\r\n break;\r\n case mode.N_POLE:\r\n r.y = Math.asin(cosz);\r\n p.y = -p.y;\r\n break;\r\n case mode.S_POLE:\r\n r.y = -Math.asin(cosz);\r\n break;\r\n }\r\n r.x = Math.atan2(p.x, p.y);\r\n }\r\n\r\n p.x = r.x + this.long0;\r\n p.y = r.y;\r\n return p;\r\n}\r\n\r\nexport var names = [\"Tilted_Perspective\", \"tpers\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names\r\n};\r\n", "import hypot from '../common/hypot';\r\n\r\nexport function init() {\r\n this.flip_axis = (this.sweep === 'x' ? 1 : 0);\r\n this.h = Number(this.h);\r\n this.radius_g_1 = this.h / this.a;\r\n\r\n if (this.radius_g_1 <= 0 || this.radius_g_1 > 1e10) {\r\n throw new Error();\r\n }\r\n\r\n this.radius_g = 1.0 + this.radius_g_1;\r\n this.C = this.radius_g * this.radius_g - 1.0;\r\n\r\n if (this.es !== 0.0) {\r\n var one_es = 1.0 - this.es;\r\n var rone_es = 1 / one_es;\r\n\r\n this.radius_p = Math.sqrt(one_es);\r\n this.radius_p2 = one_es;\r\n this.radius_p_inv2 = rone_es;\r\n\r\n this.shape = 'ellipse'; // Use as a condition in the forward and inverse functions.\r\n } else {\r\n this.radius_p = 1.0;\r\n this.radius_p2 = 1.0;\r\n this.radius_p_inv2 = 1.0;\r\n\r\n this.shape = 'sphere'; // Use as a condition in the forward and inverse functions.\r\n }\r\n\r\n if (!this.title) {\r\n this.title = \"Geostationary Satellite View\";\r\n }\r\n}\r\n\r\nfunction forward(p) {\r\n var lon = p.x;\r\n var lat = p.y;\r\n var tmp, v_x, v_y, v_z;\r\n lon = lon - this.long0;\r\n\r\n if (this.shape === 'ellipse') {\r\n lat = Math.atan(this.radius_p2 * Math.tan(lat));\r\n var r = this.radius_p / hypot(this.radius_p * Math.cos(lat), Math.sin(lat));\r\n\r\n v_x = r * Math.cos(lon) * Math.cos(lat);\r\n v_y = r * Math.sin(lon) * Math.cos(lat);\r\n v_z = r * Math.sin(lat);\r\n\r\n if (((this.radius_g - v_x) * v_x - v_y * v_y - v_z * v_z * this.radius_p_inv2) < 0.0) {\r\n p.x = Number.NaN;\r\n p.y = Number.NaN;\r\n return p;\r\n }\r\n\r\n tmp = this.radius_g - v_x;\r\n if (this.flip_axis) {\r\n p.x = this.radius_g_1 * Math.atan(v_y / hypot(v_z, tmp));\r\n p.y = this.radius_g_1 * Math.atan(v_z / tmp);\r\n } else {\r\n p.x = this.radius_g_1 * Math.atan(v_y / tmp);\r\n p.y = this.radius_g_1 * Math.atan(v_z / hypot(v_y, tmp));\r\n }\r\n } else if (this.shape === 'sphere') {\r\n tmp = Math.cos(lat);\r\n v_x = Math.cos(lon) * tmp;\r\n v_y = Math.sin(lon) * tmp;\r\n v_z = Math.sin(lat);\r\n tmp = this.radius_g - v_x;\r\n\r\n if (this.flip_axis) {\r\n p.x = this.radius_g_1 * Math.atan(v_y / hypot(v_z, tmp));\r\n p.y = this.radius_g_1 * Math.atan(v_z / tmp);\r\n } else {\r\n p.x = this.radius_g_1 * Math.atan(v_y / tmp);\r\n p.y = this.radius_g_1 * Math.atan(v_z / hypot(v_y, tmp));\r\n }\r\n }\r\n p.x = p.x * this.a;\r\n p.y = p.y * this.a;\r\n return p;\r\n}\r\n\r\nfunction inverse(p) {\r\n var v_x = -1.0;\r\n var v_y = 0.0;\r\n var v_z = 0.0;\r\n var a, b, det, k;\r\n\r\n p.x = p.x / this.a;\r\n p.y = p.y / this.a;\r\n\r\n if (this.shape === 'ellipse') {\r\n if (this.flip_axis) {\r\n v_z = Math.tan(p.y / this.radius_g_1);\r\n v_y = Math.tan(p.x / this.radius_g_1) * hypot(1.0, v_z);\r\n } else {\r\n v_y = Math.tan(p.x / this.radius_g_1);\r\n v_z = Math.tan(p.y / this.radius_g_1) * hypot(1.0, v_y);\r\n }\r\n\r\n var v_zp = v_z / this.radius_p;\r\n a = v_y * v_y + v_zp * v_zp + v_x * v_x;\r\n b = 2 * this.radius_g * v_x;\r\n det = (b * b) - 4 * a * this.C;\r\n\r\n if (det < 0.0) {\r\n p.x = Number.NaN;\r\n p.y = Number.NaN;\r\n return p;\r\n }\r\n\r\n k = (-b - Math.sqrt(det)) / (2.0 * a);\r\n v_x = this.radius_g + k * v_x;\r\n v_y *= k;\r\n v_z *= k;\r\n\r\n p.x = Math.atan2(v_y, v_x);\r\n p.y = Math.atan(v_z * Math.cos(p.x) / v_x);\r\n p.y = Math.atan(this.radius_p_inv2 * Math.tan(p.y));\r\n } else if (this.shape === 'sphere') {\r\n if (this.flip_axis) {\r\n v_z = Math.tan(p.y / this.radius_g_1);\r\n v_y = Math.tan(p.x / this.radius_g_1) * Math.sqrt(1.0 + v_z * v_z);\r\n } else {\r\n v_y = Math.tan(p.x / this.radius_g_1);\r\n v_z = Math.tan(p.y / this.radius_g_1) * Math.sqrt(1.0 + v_y * v_y);\r\n }\r\n\r\n a = v_y * v_y + v_z * v_z + v_x * v_x;\r\n b = 2 * this.radius_g * v_x;\r\n det = (b * b) - 4 * a * this.C;\r\n if (det < 0.0) {\r\n p.x = Number.NaN;\r\n p.y = Number.NaN;\r\n return p;\r\n }\r\n\r\n k = (-b - Math.sqrt(det)) / (2.0 * a);\r\n v_x = this.radius_g + k * v_x;\r\n v_y *= k;\r\n v_z *= k;\r\n\r\n p.x = Math.atan2(v_y, v_x);\r\n p.y = Math.atan(v_z * Math.cos(p.x) / v_x);\r\n }\r\n p.x = p.x + this.long0;\r\n return p;\r\n}\r\n\r\nexport var names = [\"Geostationary Satellite View\", \"Geostationary_Satellite\", \"geos\"];\r\nexport default {\r\n init: init,\r\n forward: forward,\r\n inverse: inverse,\r\n names: names,\r\n};\r\n\r\n", "import tmerc from './lib/projections/tmerc';\r\nimport etmerc from './lib/projections/etmerc';\r\nimport utm from './lib/projections/utm';\r\nimport sterea from './lib/projections/sterea';\r\nimport stere from './lib/projections/stere';\r\nimport somerc from './lib/projections/somerc';\r\nimport omerc from './lib/projections/omerc';\r\nimport lcc from './lib/projections/lcc';\r\nimport krovak from './lib/projections/krovak';\r\nimport cass from './lib/projections/cass';\r\nimport laea from './lib/projections/laea';\r\nimport aea from './lib/projections/aea';\r\nimport gnom from './lib/projections/gnom';\r\nimport cea from './lib/projections/cea';\r\nimport eqc from './lib/projections/eqc';\r\nimport poly from './lib/projections/poly';\r\nimport nzmg from './lib/projections/nzmg';\r\nimport mill from './lib/projections/mill';\r\nimport sinu from './lib/projections/sinu';\r\nimport moll from './lib/projections/moll';\r\nimport eqdc from './lib/projections/eqdc';\r\nimport vandg from './lib/projections/vandg';\r\nimport aeqd from './lib/projections/aeqd';\r\nimport ortho from './lib/projections/ortho';\r\nimport qsc from './lib/projections/qsc';\r\nimport robin from './lib/projections/robin';\r\nimport geocent from './lib/projections/geocent';\r\nimport tpers from './lib/projections/tpers';\r\nimport geos from './lib/projections/geos';\r\nexport default function(proj4){\r\n proj4.Proj.projections.add(tmerc);\r\n proj4.Proj.projections.add(etmerc);\r\n proj4.Proj.projections.add(utm);\r\n proj4.Proj.projections.add(sterea);\r\n proj4.Proj.projections.add(stere);\r\n proj4.Proj.projections.add(somerc);\r\n proj4.Proj.projections.add(omerc);\r\n proj4.Proj.projections.add(lcc);\r\n proj4.Proj.projections.add(krovak);\r\n proj4.Proj.projections.add(cass);\r\n proj4.Proj.projections.add(laea);\r\n proj4.Proj.projections.add(aea);\r\n proj4.Proj.projections.add(gnom);\r\n proj4.Proj.projections.add(cea);\r\n proj4.Proj.projections.add(eqc);\r\n proj4.Proj.projections.add(poly);\r\n proj4.Proj.projections.add(nzmg);\r\n proj4.Proj.projections.add(mill);\r\n proj4.Proj.projections.add(sinu);\r\n proj4.Proj.projections.add(moll);\r\n proj4.Proj.projections.add(eqdc);\r\n proj4.Proj.projections.add(vandg);\r\n proj4.Proj.projections.add(aeqd);\r\n proj4.Proj.projections.add(ortho);\r\n proj4.Proj.projections.add(qsc);\r\n proj4.Proj.projections.add(robin);\r\n proj4.Proj.projections.add(geocent);\r\n proj4.Proj.projections.add(tpers);\r\n proj4.Proj.projections.add(geos);\r\n}", "import proj4 from './core';\r\nimport Proj from \"./Proj\";\r\nimport Point from \"./Point\";\r\nimport common from \"./common/toPoint\";\r\nimport defs from \"./defs\";\r\nimport nadgrid from \"./nadgrid\";\r\nimport transform from \"./transform\";\r\nimport mgrs from \"mgrs\";\r\nimport includedProjections from \"../projs\";\r\n\r\nproj4.defaultDatum = 'WGS84'; //default datum\r\nproj4.Proj = Proj;\r\nproj4.WGS84 = new proj4.Proj('WGS84');\r\nproj4.Point = Point;\r\nproj4.toPoint = common;\r\nproj4.defs = defs;\r\nproj4.nadgrid = nadgrid;\r\nproj4.transform = transform;\r\nproj4.mgrs = mgrs;\r\nproj4.version = '__VERSION__';\r\nincludedProjections(proj4);\r\nexport default proj4;\r\n"], + "mappings": ";;;AAAe,SAAR,eAAiBA,OAAM;AAC5B,EAAAA,MAAK,aAAa,iFAAiF;AACnG,EAAAA,MAAK,aAAa,iHAAiH;AACnI,EAAAA,MAAK,aAAa,kJAAkJ;AAEpK,EAAAA,MAAK,QA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,OAAM,KAAK,YAAY,IAAI,WAAG;AAC9B,EAAAA,OAAM,KAAK,YAAY,IAAI,aAAK;AAChC,EAAAA,OAAM,KAAK,YAAY,IAAI,eAAO;AAClC,EAAAA,OAAM,KAAK,YAAY,IAAI,aAAK;AAChC,EAAAA,OAAM,KAAK,YAAY,IAAI,YAAI;AACjC;;;ACjDA,aAAM,eAAe;AACrB,aAAM,OAAO;AACb,aAAM,QAAQ,IAAI,aAAM,KAAK,OAAO;AACpC,aAAM,QAAQ;AACd,aAAM,UAAU;AAChB,aAAM,OAAO;AACb,aAAM,UAAU;AAChB,aAAM,YAAY;AAClB,aAAM,OAAO;AACb,aAAM,UAAU;AAChB,cAAoB,YAAK;AACzB,IAAO,cAAQ;", + "names": ["defs", "params", "D2R", "params", "init", "names", "init", "names", "names", "exports", "exports", "sphere", "exports", "exports", "exports", "nadgrid", "start", "exports", "Z", "inverse", "wgs84", "forward", "inverse", "inverse", "A", "C1", "forward", "init", "forward", "inverse", "names", "init", "Z", "forward", "inverse", "names", "init", "names", "MAX_ITER", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "A", "inverse", "names", "init", "forward", "I", "inverse", "names", "init", "forward", "V", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "MAX_ITER", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "MAX_ITER", "init", "forward", "V", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "A", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "start", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "init", "forward", "inverse", "names", "proj4"] +} diff --git a/node_modules/.vite/deps/svelte.js b/node_modules/.vite/deps/svelte.js new file mode 100644 index 000000000..a3b6a0729 --- /dev/null +++ b/node_modules/.vite/deps/svelte.js @@ -0,0 +1,31 @@ +import { + SvelteComponentDev, + SvelteComponentTyped, + afterUpdate, + beforeUpdate, + createEventDispatcher, + getAllContexts, + getContext, + hasContext, + onDestroy, + onMount, + setContext, + tick +} from "./chunk-OWBE2SVS.js"; +import "./chunk-QGUH75DB.js"; +import "./chunk-F3FYYIAV.js"; +export { + SvelteComponentDev as SvelteComponent, + SvelteComponentTyped, + afterUpdate, + beforeUpdate, + createEventDispatcher, + getAllContexts, + getContext, + hasContext, + onDestroy, + onMount, + setContext, + tick +}; +//# sourceMappingURL=svelte.js.map diff --git a/node_modules/.vite/deps/svelte.js.map b/node_modules/.vite/deps/svelte.js.map new file mode 100644 index 000000000..98652118b --- /dev/null +++ b/node_modules/.vite/deps/svelte.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": [], + "sourcesContent": [], + "mappings": "", + "names": [] +} diff --git a/node_modules/.vite/deps/svelte_animate.js b/node_modules/.vite/deps/svelte_animate.js new file mode 100644 index 000000000..72c7a04bc --- /dev/null +++ b/node_modules/.vite/deps/svelte_animate.js @@ -0,0 +1,34 @@ +import { + cubicOut +} from "./chunk-FI7FPNA6.js"; +import { + is_function +} from "./chunk-OWBE2SVS.js"; +import "./chunk-QGUH75DB.js"; +import "./chunk-F3FYYIAV.js"; + +// node_modules/svelte/src/runtime/animate/index.js +function flip(node, { from, to }, params = {}) { + const style = getComputedStyle(node); + const transform = style.transform === "none" ? "" : style.transform; + const [ox, oy] = style.transformOrigin.split(" ").map(parseFloat); + const dx = from.left + from.width * ox / to.width - (to.left + ox); + const dy = from.top + from.height * oy / to.height - (to.top + oy); + const { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing = cubicOut } = params; + return { + delay, + duration: is_function(duration) ? duration(Math.sqrt(dx * dx + dy * dy)) : duration, + easing, + css: (t, u) => { + const x = u * dx; + const y = u * dy; + const sx = t + u * from.width / to.width; + const sy = t + u * from.height / to.height; + return `transform: ${transform} translate(${x}px, ${y}px) scale(${sx}, ${sy});`; + } + }; +} +export { + flip +}; +//# sourceMappingURL=svelte_animate.js.map diff --git a/node_modules/.vite/deps/svelte_animate.js.map b/node_modules/.vite/deps/svelte_animate.js.map new file mode 100644 index 000000000..cf888cbd3 --- /dev/null +++ b/node_modules/.vite/deps/svelte_animate.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../svelte/src/runtime/animate/index.js"], + "sourcesContent": ["import { cubicOut } from '../easing/index.js';\r\nimport { is_function } from '../internal/index.js';\r\n\r\n/**\r\n * The flip function calculates the start and end position of an element and animates between them, translating the x and y values.\r\n * `flip` stands for [First, Last, Invert, Play](https://aerotwist.com/blog/flip-your-animations/).\r\n *\r\n * https://svelte.dev/docs/svelte-animate#flip\r\n * @param {Element} node\r\n * @param {{ from: DOMRect; to: DOMRect }} fromTo\r\n * @param {import('./public.js').FlipParams} params\r\n * @returns {import('./public.js').AnimationConfig}\r\n */\r\nexport function flip(node, { from, to }, params = {}) {\r\n\tconst style = getComputedStyle(node);\r\n\tconst transform = style.transform === 'none' ? '' : style.transform;\r\n\tconst [ox, oy] = style.transformOrigin.split(' ').map(parseFloat);\r\n\tconst dx = from.left + (from.width * ox) / to.width - (to.left + ox);\r\n\tconst dy = from.top + (from.height * oy) / to.height - (to.top + oy);\r\n\tconst { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing = cubicOut } = params;\r\n\treturn {\r\n\t\tdelay,\r\n\t\tduration: is_function(duration) ? duration(Math.sqrt(dx * dx + dy * dy)) : duration,\r\n\t\teasing,\r\n\t\tcss: (t, u) => {\r\n\t\t\tconst x = u * dx;\r\n\t\t\tconst y = u * dy;\r\n\t\t\tconst sx = t + (u * from.width) / to.width;\r\n\t\t\tconst sy = t + (u * from.height) / to.height;\r\n\t\t\treturn `transform: ${transform} translate(${x}px, ${y}px) scale(${sx}, ${sy});`;\r\n\t\t}\r\n\t};\r\n}\r\n"], + "mappings": ";;;;;;;;;;AAaO,SAAS,KAAK,MAAM,EAAE,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG;AACrD,QAAM,QAAQ,iBAAiB,IAAI;AACnC,QAAM,YAAY,MAAM,cAAc,SAAS,KAAK,MAAM;AAC1D,QAAM,CAAC,IAAI,EAAE,IAAI,MAAM,gBAAgB,MAAM,GAAG,EAAE,IAAI,UAAU;AAChE,QAAM,KAAK,KAAK,OAAQ,KAAK,QAAQ,KAAM,GAAG,SAAS,GAAG,OAAO;AACjE,QAAM,KAAK,KAAK,MAAO,KAAK,SAAS,KAAM,GAAG,UAAU,GAAG,MAAM;AACjE,QAAM,EAAE,QAAQ,GAAG,WAAW,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,KAAK,SAAS,SAAS,IAAI;AAC/E,SAAO;AAAA,IACN;AAAA,IACA,UAAU,YAAY,QAAQ,IAAI,SAAS,KAAK,KAAK,KAAK,KAAK,KAAK,EAAE,CAAC,IAAI;AAAA,IAC3E;AAAA,IACA,KAAK,CAAC,GAAG,MAAM;AACd,YAAM,IAAI,IAAI;AACd,YAAM,IAAI,IAAI;AACd,YAAM,KAAK,IAAK,IAAI,KAAK,QAAS,GAAG;AACrC,YAAM,KAAK,IAAK,IAAI,KAAK,SAAU,GAAG;AACtC,aAAO,cAAc,SAAS,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,EAAE;AAAA,IAC5E;AAAA,EACD;AACD;", + "names": [] +} diff --git a/node_modules/.vite/deps/svelte_easing.js b/node_modules/.vite/deps/svelte_easing.js new file mode 100644 index 000000000..2f5b67db6 --- /dev/null +++ b/node_modules/.vite/deps/svelte_easing.js @@ -0,0 +1,71 @@ +import { + backIn, + backInOut, + backOut, + bounceIn, + bounceInOut, + bounceOut, + circIn, + circInOut, + circOut, + cubicIn, + cubicInOut, + cubicOut, + elasticIn, + elasticInOut, + elasticOut, + expoIn, + expoInOut, + expoOut, + quadIn, + quadInOut, + quadOut, + quartIn, + quartInOut, + quartOut, + quintIn, + quintInOut, + quintOut, + sineIn, + sineInOut, + sineOut +} from "./chunk-FI7FPNA6.js"; +import { + identity +} from "./chunk-OWBE2SVS.js"; +import "./chunk-QGUH75DB.js"; +import "./chunk-F3FYYIAV.js"; +export { + backIn, + backInOut, + backOut, + bounceIn, + bounceInOut, + bounceOut, + circIn, + circInOut, + circOut, + cubicIn, + cubicInOut, + cubicOut, + elasticIn, + elasticInOut, + elasticOut, + expoIn, + expoInOut, + expoOut, + identity as linear, + quadIn, + quadInOut, + quadOut, + quartIn, + quartInOut, + quartOut, + quintIn, + quintInOut, + quintOut, + sineIn, + sineInOut, + sineOut +}; +//# sourceMappingURL=svelte_easing.js.map diff --git a/node_modules/.vite/deps/svelte_easing.js.map b/node_modules/.vite/deps/svelte_easing.js.map new file mode 100644 index 000000000..98652118b --- /dev/null +++ b/node_modules/.vite/deps/svelte_easing.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": [], + "sourcesContent": [], + "mappings": "", + "names": [] +} diff --git a/node_modules/.vite/deps/svelte_internal.js b/node_modules/.vite/deps/svelte_internal.js new file mode 100644 index 000000000..9d9f89ca2 --- /dev/null +++ b/node_modules/.vite/deps/svelte_internal.js @@ -0,0 +1,413 @@ +import { + HtmlTag, + HtmlTagHydration, + ResizeObserverSingleton, + SvelteComponent, + SvelteComponentDev, + SvelteComponentTyped, + SvelteElement, + action_destroyer, + add_attribute, + add_classes, + add_flush_callback, + add_iframe_resize_listener, + add_location, + add_render_callback, + add_styles, + add_transform, + afterUpdate, + append, + append_dev, + append_empty_stylesheet, + append_hydration, + append_hydration_dev, + append_styles, + assign, + attr, + attr_dev, + attribute_to_object, + beforeUpdate, + bind, + binding_callbacks, + blank_object, + bubble, + check_outros, + children, + claim_comment, + claim_component, + claim_element, + claim_html_tag, + claim_space, + claim_svg_element, + claim_text, + clear_loops, + comment, + component_subscribe, + compute_rest_props, + compute_slots, + construct_svelte_component, + construct_svelte_component_dev, + contenteditable_truthy_values, + createEventDispatcher, + create_animation, + create_bidirectional_transition, + create_component, + create_custom_element, + 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, + end_hydrating, + ensure_array_like, + ensure_array_like_dev, + escape, + escape_attribute_value, + escape_object, + exclude_internal_props, + fix_and_destroy_block, + fix_and_outro_and_destroy_block, + fix_position, + flush, + flush_render_callbacks, + getAllContexts, + getContext, + get_all_dirty_from_scope, + get_binding_group_value, + get_current_component, + get_custom_elements_slots, + get_root_for_style, + get_slot_changes, + get_spread_object, + get_spread_update, + get_store_value, + get_svelte_dataset, + globals, + group_outros, + handle_promise, + hasContext, + has_prop, + head_selector, + identity, + init, + init_binding_group, + init_binding_group_dynamic, + insert, + insert_dev, + insert_hydration, + insert_hydration_dev, + intros, + invalid_attribute_name_character, + is_client, + is_crossorigin, + is_empty, + is_function, + is_promise, + is_void, + listen, + listen_dev, + loop, + loop_guard, + merge_ssr_styles, + 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, + resize_observer_border_box, + resize_observer_content_box, + resize_observer_device_pixel_content_box, + 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_custom_element_data_map, + set_data, + set_data_contenteditable, + set_data_contenteditable_dev, + set_data_dev, + set_data_maybe_contenteditable, + set_data_maybe_contenteditable_dev, + set_dynamic_element_data, + set_input_type, + set_input_value, + set_now, + set_raf, + set_store_value, + set_style, + set_svg_attributes, + space, + split_css_unit, + spread, + src_url_equal, + srcset_url_equal, + start_hydrating, + stop_immediate_propagation, + stop_propagation, + stringify_spread, + subscribe, + svg_element, + text, + tick, + time_ranges_to_array, + to_number, + toggle_class, + transition_in, + transition_out, + trusted, + update_await_block_branch, + update_keyed_each, + update_slot, + update_slot_base, + validate_component, + validate_dynamic_element, + validate_each_keys, + validate_slots, + validate_store, + validate_void_dynamic_element, + xlink_attr +} from "./chunk-OWBE2SVS.js"; +import "./chunk-QGUH75DB.js"; +import "./chunk-F3FYYIAV.js"; +export { + HtmlTag, + HtmlTagHydration, + ResizeObserverSingleton, + SvelteComponent, + SvelteComponentDev, + SvelteComponentTyped, + SvelteElement, + action_destroyer, + add_attribute, + add_classes, + add_flush_callback, + add_iframe_resize_listener, + add_location, + add_render_callback, + add_styles, + add_transform, + afterUpdate, + append, + append_dev, + append_empty_stylesheet, + append_hydration, + append_hydration_dev, + append_styles, + assign, + attr, + attr_dev, + attribute_to_object, + beforeUpdate, + bind, + binding_callbacks, + blank_object, + bubble, + check_outros, + children, + claim_comment, + claim_component, + claim_element, + claim_html_tag, + claim_space, + claim_svg_element, + claim_text, + clear_loops, + comment, + component_subscribe, + compute_rest_props, + compute_slots, + construct_svelte_component, + construct_svelte_component_dev, + contenteditable_truthy_values, + createEventDispatcher, + create_animation, + create_bidirectional_transition, + create_component, + create_custom_element, + 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, + end_hydrating, + ensure_array_like, + ensure_array_like_dev, + escape, + escape_attribute_value, + escape_object, + exclude_internal_props, + fix_and_destroy_block, + fix_and_outro_and_destroy_block, + fix_position, + flush, + flush_render_callbacks, + getAllContexts, + getContext, + get_all_dirty_from_scope, + get_binding_group_value, + get_current_component, + get_custom_elements_slots, + get_root_for_style, + get_slot_changes, + get_spread_object, + get_spread_update, + get_store_value, + get_svelte_dataset, + globals, + group_outros, + handle_promise, + hasContext, + has_prop, + head_selector, + identity, + init, + init_binding_group, + init_binding_group_dynamic, + insert, + insert_dev, + insert_hydration, + insert_hydration_dev, + intros, + invalid_attribute_name_character, + is_client, + is_crossorigin, + is_empty, + is_function, + is_promise, + is_void, + listen, + listen_dev, + loop, + loop_guard, + merge_ssr_styles, + 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, + resize_observer_border_box, + resize_observer_content_box, + resize_observer_device_pixel_content_box, + 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_custom_element_data_map, + set_data, + set_data_contenteditable, + set_data_contenteditable_dev, + set_data_dev, + set_data_maybe_contenteditable, + set_data_maybe_contenteditable_dev, + set_dynamic_element_data, + set_input_type, + set_input_value, + set_now, + set_raf, + set_store_value, + set_style, + set_svg_attributes, + space, + split_css_unit, + spread, + src_url_equal, + srcset_url_equal, + start_hydrating, + stop_immediate_propagation, + stop_propagation, + stringify_spread, + subscribe, + svg_element, + text, + tick, + time_ranges_to_array, + to_number, + toggle_class, + transition_in, + transition_out, + trusted, + update_await_block_branch, + update_keyed_each, + update_slot, + update_slot_base, + validate_component, + validate_dynamic_element, + validate_each_keys, + validate_slots, + validate_store, + validate_void_dynamic_element, + xlink_attr +}; +//# sourceMappingURL=svelte_internal.js.map diff --git a/node_modules/.vite/deps/svelte_internal.js.map b/node_modules/.vite/deps/svelte_internal.js.map new file mode 100644 index 000000000..98652118b --- /dev/null +++ b/node_modules/.vite/deps/svelte_internal.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": [], + "sourcesContent": [], + "mappings": "", + "names": [] +} diff --git a/node_modules/.vite/deps/svelte_internal_disclose-version.js b/node_modules/.vite/deps/svelte_internal_disclose-version.js new file mode 100644 index 000000000..0d7b9eacb --- /dev/null +++ b/node_modules/.vite/deps/svelte_internal_disclose-version.js @@ -0,0 +1,9 @@ +import { + PUBLIC_VERSION +} from "./chunk-QGUH75DB.js"; +import "./chunk-F3FYYIAV.js"; + +// node_modules/svelte/src/runtime/internal/disclose-version/index.js +if (typeof window !== "undefined") + (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION); +//# sourceMappingURL=svelte_internal_disclose-version.js.map diff --git a/node_modules/.vite/deps/svelte_internal_disclose-version.js.map b/node_modules/.vite/deps/svelte_internal_disclose-version.js.map new file mode 100644 index 000000000..a9893b6fe --- /dev/null +++ b/node_modules/.vite/deps/svelte_internal_disclose-version.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../svelte/src/runtime/internal/disclose-version/index.js"], + "sourcesContent": ["import { PUBLIC_VERSION } from '../../../shared/version.js';\r\n\r\nif (typeof window !== 'undefined')\r\n\t// @ts-ignore\r\n\t(window.__svelte || (window.__svelte = { v: new Set() })).v.add(PUBLIC_VERSION);\r\n"], + "mappings": ";;;;;;AAEA,IAAI,OAAO,WAAW;AAErB,GAAC,OAAO,aAAa,OAAO,WAAW,EAAE,GAAG,oBAAI,IAAI,EAAE,IAAI,EAAE,IAAI,cAAc;", + "names": [] +} diff --git a/node_modules/.vite/deps/svelte_motion.js b/node_modules/.vite/deps/svelte_motion.js new file mode 100644 index 000000000..0d24a7fa1 --- /dev/null +++ b/node_modules/.vite/deps/svelte_motion.js @@ -0,0 +1,221 @@ +import { + writable +} from "./chunk-HLHWFLRS.js"; +import "./chunk-FI7FPNA6.js"; +import { + assign, + identity, + loop, + now +} from "./chunk-OWBE2SVS.js"; +import "./chunk-QGUH75DB.js"; +import "./chunk-F3FYYIAV.js"; + +// node_modules/svelte/src/runtime/motion/utils.js +function is_date(obj) { + return Object.prototype.toString.call(obj) === "[object Date]"; +} + +// node_modules/svelte/src/runtime/motion/spring.js +function tick_spring(ctx, last_value, current_value, target_value) { + if (typeof current_value === "number" || is_date(current_value)) { + const delta = target_value - current_value; + const velocity = (current_value - last_value) / (ctx.dt || 1 / 60); + const spring2 = ctx.opts.stiffness * delta; + const damper = ctx.opts.damping * velocity; + const acceleration = (spring2 - damper) * ctx.inv_mass; + const d = (velocity + acceleration) * ctx.dt; + if (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) { + return target_value; + } else { + ctx.settled = false; + return is_date(current_value) ? new Date(current_value.getTime() + d) : current_value + d; + } + } else if (Array.isArray(current_value)) { + return current_value.map( + (_, i) => tick_spring(ctx, last_value[i], current_value[i], target_value[i]) + ); + } else if (typeof current_value === "object") { + const next_value = {}; + for (const k in current_value) { + next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]); + } + return next_value; + } else { + throw new Error(`Cannot spring ${typeof current_value} values`); + } +} +function spring(value, opts = {}) { + const store = writable(value); + const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts; + let last_time; + let task; + let current_token; + let last_value = value; + let target_value = value; + let inv_mass = 1; + let inv_mass_recovery_rate = 0; + let cancel_task = false; + function set(new_value, opts2 = {}) { + target_value = new_value; + const token = current_token = {}; + if (value == null || opts2.hard || spring2.stiffness >= 1 && spring2.damping >= 1) { + cancel_task = true; + last_time = now(); + last_value = new_value; + store.set(value = target_value); + return Promise.resolve(); + } else if (opts2.soft) { + const rate = opts2.soft === true ? 0.5 : +opts2.soft; + inv_mass_recovery_rate = 1 / (rate * 60); + inv_mass = 0; + } + if (!task) { + last_time = now(); + cancel_task = false; + task = loop((now2) => { + if (cancel_task) { + cancel_task = false; + task = null; + return false; + } + inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1); + const ctx = { + inv_mass, + opts: spring2, + settled: true, + dt: (now2 - last_time) * 60 / 1e3 + }; + const next_value = tick_spring(ctx, last_value, value, target_value); + last_time = now2; + last_value = value; + store.set(value = next_value); + if (ctx.settled) { + task = null; + } + return !ctx.settled; + }); + } + return new Promise((fulfil) => { + task.promise.then(() => { + if (token === current_token) + fulfil(); + }); + }); + } + const spring2 = { + set, + update: (fn, opts2) => set(fn(target_value, value), opts2), + subscribe: store.subscribe, + stiffness, + damping, + precision + }; + return spring2; +} + +// node_modules/svelte/src/runtime/motion/tweened.js +function get_interpolator(a, b) { + if (a === b || a !== a) + return () => a; + const type = typeof a; + if (type !== typeof b || Array.isArray(a) !== Array.isArray(b)) { + throw new Error("Cannot interpolate values of different type"); + } + if (Array.isArray(a)) { + const arr = b.map((bi, i) => { + return get_interpolator(a[i], bi); + }); + return (t) => arr.map((fn) => fn(t)); + } + if (type === "object") { + if (!a || !b) + throw new Error("Object cannot be null"); + if (is_date(a) && is_date(b)) { + a = a.getTime(); + b = b.getTime(); + const delta = b - a; + return (t) => new Date(a + t * delta); + } + const keys = Object.keys(b); + const interpolators = {}; + keys.forEach((key) => { + interpolators[key] = get_interpolator(a[key], b[key]); + }); + return (t) => { + const result = {}; + keys.forEach((key) => { + result[key] = interpolators[key](t); + }); + return result; + }; + } + if (type === "number") { + const delta = b - a; + return (t) => a + t * delta; + } + throw new Error(`Cannot interpolate ${type} values`); +} +function tweened(value, defaults = {}) { + const store = writable(value); + let task; + let target_value = value; + function set(new_value, opts) { + if (value == null) { + store.set(value = new_value); + return Promise.resolve(); + } + target_value = new_value; + let previous_task = task; + let started = false; + let { + delay = 0, + duration = 400, + easing = identity, + interpolate = get_interpolator + } = assign(assign({}, defaults), opts); + if (duration === 0) { + if (previous_task) { + previous_task.abort(); + previous_task = null; + } + store.set(value = target_value); + return Promise.resolve(); + } + const start = now() + delay; + let fn; + task = loop((now2) => { + if (now2 < start) + return true; + if (!started) { + fn = interpolate(value, new_value); + if (typeof duration === "function") + duration = duration(value, new_value); + started = true; + } + if (previous_task) { + previous_task.abort(); + previous_task = null; + } + const elapsed = now2 - start; + if (elapsed > /** @type {number} */ + duration) { + store.set(value = new_value); + return false; + } + store.set(value = fn(easing(elapsed / duration))); + return true; + }); + return task.promise; + } + return { + set, + update: (fn, opts) => set(fn(target_value, value), opts), + subscribe: store.subscribe + }; +} +export { + spring, + tweened +}; +//# sourceMappingURL=svelte_motion.js.map diff --git a/node_modules/.vite/deps/svelte_motion.js.map b/node_modules/.vite/deps/svelte_motion.js.map new file mode 100644 index 000000000..4b5c9f7aa --- /dev/null +++ b/node_modules/.vite/deps/svelte_motion.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../svelte/src/runtime/motion/utils.js", "../../svelte/src/runtime/motion/spring.js", "../../svelte/src/runtime/motion/tweened.js"], + "sourcesContent": ["/**\r\n * @param {any} obj\r\n * @returns {boolean}\r\n */\r\nexport function is_date(obj) {\r\n\treturn Object.prototype.toString.call(obj) === '[object Date]';\r\n}\r\n", "import { writable } from '../store/index.js';\r\nimport { loop, now } from '../internal/index.js';\r\nimport { is_date } from './utils.js';\r\n\r\n/**\r\n * @template T\r\n * @param {import('./private.js').TickContext} ctx\r\n * @param {T} last_value\r\n * @param {T} current_value\r\n * @param {T} target_value\r\n * @returns {T}\r\n */\r\nfunction tick_spring(ctx, last_value, current_value, target_value) {\r\n\tif (typeof current_value === 'number' || is_date(current_value)) {\r\n\t\t// @ts-ignore\r\n\t\tconst delta = target_value - current_value;\r\n\t\t// @ts-ignore\r\n\t\tconst velocity = (current_value - last_value) / (ctx.dt || 1 / 60); // guard div by 0\r\n\t\tconst spring = ctx.opts.stiffness * delta;\r\n\t\tconst damper = ctx.opts.damping * velocity;\r\n\t\tconst acceleration = (spring - damper) * ctx.inv_mass;\r\n\t\tconst d = (velocity + acceleration) * ctx.dt;\r\n\t\tif (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) {\r\n\t\t\treturn target_value; // settled\r\n\t\t} else {\r\n\t\t\tctx.settled = false; // signal loop to keep ticking\r\n\t\t\t// @ts-ignore\r\n\t\t\treturn is_date(current_value) ? new Date(current_value.getTime() + d) : current_value + d;\r\n\t\t}\r\n\t} else if (Array.isArray(current_value)) {\r\n\t\t// @ts-ignore\r\n\t\treturn current_value.map((_, i) =>\r\n\t\t\ttick_spring(ctx, last_value[i], current_value[i], target_value[i])\r\n\t\t);\r\n\t} else if (typeof current_value === 'object') {\r\n\t\tconst next_value = {};\r\n\t\tfor (const k in current_value) {\r\n\t\t\t// @ts-ignore\r\n\t\t\tnext_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);\r\n\t\t}\r\n\t\t// @ts-ignore\r\n\t\treturn next_value;\r\n\t} else {\r\n\t\tthrow new Error(`Cannot spring ${typeof current_value} values`);\r\n\t}\r\n}\r\n\r\n/**\r\n * The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it \"bounces\" like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience.\r\n *\r\n * https://svelte.dev/docs/svelte-motion#spring\r\n * @template [T=any]\r\n * @param {T} [value]\r\n * @param {import('./private.js').SpringOpts} [opts]\r\n * @returns {import('./public.js').Spring}\r\n */\r\nexport function spring(value, opts = {}) {\r\n\tconst store = writable(value);\r\n\tconst { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;\r\n\t/** @type {number} */\r\n\tlet last_time;\r\n\t/** @type {import('../internal/private.js').Task} */\r\n\tlet task;\r\n\t/** @type {object} */\r\n\tlet current_token;\r\n\t/** @type {T} */\r\n\tlet last_value = value;\r\n\t/** @type {T} */\r\n\tlet target_value = value;\r\n\tlet inv_mass = 1;\r\n\tlet inv_mass_recovery_rate = 0;\r\n\tlet cancel_task = false;\r\n\t/**\r\n\t * @param {T} new_value\r\n\t * @param {import('./private.js').SpringUpdateOpts} opts\r\n\t * @returns {Promise}\r\n\t */\r\n\tfunction set(new_value, opts = {}) {\r\n\t\ttarget_value = new_value;\r\n\t\tconst token = (current_token = {});\r\n\t\tif (value == null || opts.hard || (spring.stiffness >= 1 && spring.damping >= 1)) {\r\n\t\t\tcancel_task = true; // cancel any running animation\r\n\t\t\tlast_time = now();\r\n\t\t\tlast_value = new_value;\r\n\t\t\tstore.set((value = target_value));\r\n\t\t\treturn Promise.resolve();\r\n\t\t} else if (opts.soft) {\r\n\t\t\tconst rate = opts.soft === true ? 0.5 : +opts.soft;\r\n\t\t\tinv_mass_recovery_rate = 1 / (rate * 60);\r\n\t\t\tinv_mass = 0; // infinite mass, unaffected by spring forces\r\n\t\t}\r\n\t\tif (!task) {\r\n\t\t\tlast_time = now();\r\n\t\t\tcancel_task = false;\r\n\t\t\ttask = loop((now) => {\r\n\t\t\t\tif (cancel_task) {\r\n\t\t\t\t\tcancel_task = false;\r\n\t\t\t\t\ttask = null;\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t\tinv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1);\r\n\t\t\t\tconst ctx = {\r\n\t\t\t\t\tinv_mass,\r\n\t\t\t\t\topts: spring,\r\n\t\t\t\t\tsettled: true,\r\n\t\t\t\t\tdt: ((now - last_time) * 60) / 1000\r\n\t\t\t\t};\r\n\t\t\t\tconst next_value = tick_spring(ctx, last_value, value, target_value);\r\n\t\t\t\tlast_time = now;\r\n\t\t\t\tlast_value = value;\r\n\t\t\t\tstore.set((value = next_value));\r\n\t\t\t\tif (ctx.settled) {\r\n\t\t\t\t\ttask = null;\r\n\t\t\t\t}\r\n\t\t\t\treturn !ctx.settled;\r\n\t\t\t});\r\n\t\t}\r\n\t\treturn new Promise((fulfil) => {\r\n\t\t\ttask.promise.then(() => {\r\n\t\t\t\tif (token === current_token) fulfil();\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\t/** @type {import('./public.js').Spring} */\r\n\tconst spring = {\r\n\t\tset,\r\n\t\tupdate: (fn, opts) => set(fn(target_value, value), opts),\r\n\t\tsubscribe: store.subscribe,\r\n\t\tstiffness,\r\n\t\tdamping,\r\n\t\tprecision\r\n\t};\r\n\treturn spring;\r\n}\r\n", "import { writable } from '../store/index.js';\r\nimport { assign, loop, now } from '../internal/index.js';\r\nimport { linear } from '../easing/index.js';\r\nimport { is_date } from './utils.js';\r\n\r\n/** @returns {(t: any) => any} */\r\nfunction get_interpolator(a, b) {\r\n\tif (a === b || a !== a) return () => a;\r\n\tconst type = typeof a;\r\n\tif (type !== typeof b || Array.isArray(a) !== Array.isArray(b)) {\r\n\t\tthrow new Error('Cannot interpolate values of different type');\r\n\t}\r\n\tif (Array.isArray(a)) {\r\n\t\tconst arr = b.map((bi, i) => {\r\n\t\t\treturn get_interpolator(a[i], bi);\r\n\t\t});\r\n\t\treturn (t) => arr.map((fn) => fn(t));\r\n\t}\r\n\tif (type === 'object') {\r\n\t\tif (!a || !b) throw new Error('Object cannot be null');\r\n\t\tif (is_date(a) && is_date(b)) {\r\n\t\t\ta = a.getTime();\r\n\t\t\tb = b.getTime();\r\n\t\t\tconst delta = b - a;\r\n\t\t\treturn (t) => new Date(a + t * delta);\r\n\t\t}\r\n\t\tconst keys = Object.keys(b);\r\n\t\tconst interpolators = {};\r\n\t\tkeys.forEach((key) => {\r\n\t\t\tinterpolators[key] = get_interpolator(a[key], b[key]);\r\n\t\t});\r\n\t\treturn (t) => {\r\n\t\t\tconst result = {};\r\n\t\t\tkeys.forEach((key) => {\r\n\t\t\t\tresult[key] = interpolators[key](t);\r\n\t\t\t});\r\n\t\t\treturn result;\r\n\t\t};\r\n\t}\r\n\tif (type === 'number') {\r\n\t\tconst delta = b - a;\r\n\t\treturn (t) => a + t * delta;\r\n\t}\r\n\tthrow new Error(`Cannot interpolate ${type} values`);\r\n}\r\n\r\n/**\r\n * A tweened store in Svelte is a special type of store that provides smooth transitions between state values over time.\r\n *\r\n * https://svelte.dev/docs/svelte-motion#tweened\r\n * @template T\r\n * @param {T} [value]\r\n * @param {import('./private.js').TweenedOptions} [defaults]\r\n * @returns {import('./public.js').Tweened}\r\n */\r\nexport function tweened(value, defaults = {}) {\r\n\tconst store = writable(value);\r\n\t/** @type {import('../internal/private.js').Task} */\r\n\tlet task;\r\n\tlet target_value = value;\r\n\t/**\r\n\t * @param {T} new_value\r\n\t * @param {import('./private.js').TweenedOptions} [opts]\r\n\t */\r\n\tfunction set(new_value, opts) {\r\n\t\tif (value == null) {\r\n\t\t\tstore.set((value = new_value));\r\n\t\t\treturn Promise.resolve();\r\n\t\t}\r\n\t\ttarget_value = new_value;\r\n\t\tlet previous_task = task;\r\n\t\tlet started = false;\r\n\t\tlet {\r\n\t\t\tdelay = 0,\r\n\t\t\tduration = 400,\r\n\t\t\teasing = linear,\r\n\t\t\tinterpolate = get_interpolator\r\n\t\t} = assign(assign({}, defaults), opts);\r\n\t\tif (duration === 0) {\r\n\t\t\tif (previous_task) {\r\n\t\t\t\tprevious_task.abort();\r\n\t\t\t\tprevious_task = null;\r\n\t\t\t}\r\n\t\t\tstore.set((value = target_value));\r\n\t\t\treturn Promise.resolve();\r\n\t\t}\r\n\t\tconst start = now() + delay;\r\n\t\tlet fn;\r\n\t\ttask = loop((now) => {\r\n\t\t\tif (now < start) return true;\r\n\t\t\tif (!started) {\r\n\t\t\t\tfn = interpolate(value, new_value);\r\n\t\t\t\tif (typeof duration === 'function') duration = duration(value, new_value);\r\n\t\t\t\tstarted = true;\r\n\t\t\t}\r\n\t\t\tif (previous_task) {\r\n\t\t\t\tprevious_task.abort();\r\n\t\t\t\tprevious_task = null;\r\n\t\t\t}\r\n\t\t\tconst elapsed = now - start;\r\n\t\t\tif (elapsed > /** @type {number} */ (duration)) {\r\n\t\t\t\tstore.set((value = new_value));\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t// @ts-ignore\r\n\t\t\tstore.set((value = fn(easing(elapsed / duration))));\r\n\t\t\treturn true;\r\n\t\t});\r\n\t\treturn task.promise;\r\n\t}\r\n\treturn {\r\n\t\tset,\r\n\t\tupdate: (fn, opts) => set(fn(target_value, value), opts),\r\n\t\tsubscribe: store.subscribe\r\n\t};\r\n}\r\n"], + "mappings": ";;;;;;;;;;;;;;AAIO,SAAS,QAAQ,KAAK;AAC5B,SAAO,OAAO,UAAU,SAAS,KAAK,GAAG,MAAM;AAChD;;;ACMA,SAAS,YAAY,KAAK,YAAY,eAAe,cAAc;AAClE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AK,GAAG,IAAI;AAAA,IACvD,WAAW,MAAM;AAAA,EAClB;AACD;", + "names": ["spring", "opts", "now", "now"] +} diff --git a/node_modules/.vite/deps/svelte_store.js b/node_modules/.vite/deps/svelte_store.js new file mode 100644 index 000000000..7420b3445 --- /dev/null +++ b/node_modules/.vite/deps/svelte_store.js @@ -0,0 +1,19 @@ +import { + derived, + readable, + readonly, + writable +} from "./chunk-HLHWFLRS.js"; +import { + get_store_value +} from "./chunk-OWBE2SVS.js"; +import "./chunk-QGUH75DB.js"; +import "./chunk-F3FYYIAV.js"; +export { + derived, + get_store_value as get, + readable, + readonly, + writable +}; +//# sourceMappingURL=svelte_store.js.map diff --git a/node_modules/.vite/deps/svelte_store.js.map b/node_modules/.vite/deps/svelte_store.js.map new file mode 100644 index 000000000..98652118b --- /dev/null +++ b/node_modules/.vite/deps/svelte_store.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": [], + "sourcesContent": [], + "mappings": "", + "names": [] +} diff --git a/node_modules/.vite/deps/svelte_transition.js b/node_modules/.vite/deps/svelte_transition.js new file mode 100644 index 000000000..b389df3e2 --- /dev/null +++ b/node_modules/.vite/deps/svelte_transition.js @@ -0,0 +1,175 @@ +import { + cubicInOut, + cubicOut +} from "./chunk-FI7FPNA6.js"; +import { + assign, + identity, + is_function, + split_css_unit +} from "./chunk-OWBE2SVS.js"; +import "./chunk-QGUH75DB.js"; +import "./chunk-F3FYYIAV.js"; + +// node_modules/svelte/src/runtime/transition/index.js +function blur(node, { delay = 0, duration = 400, easing = cubicInOut, amount = 5, opacity = 0 } = {}) { + const style = getComputedStyle(node); + const target_opacity = +style.opacity; + const f = style.filter === "none" ? "" : style.filter; + const od = target_opacity * (1 - opacity); + const [value, unit] = split_css_unit(amount); + return { + delay, + duration, + easing, + css: (_t, u) => `opacity: ${target_opacity - od * u}; filter: ${f} blur(${u * value}${unit});` + }; +} +function fade(node, { delay = 0, duration = 400, easing = identity } = {}) { + const o = +getComputedStyle(node).opacity; + return { + delay, + duration, + easing, + css: (t) => `opacity: ${t * o}` + }; +} +function fly(node, { delay = 0, duration = 400, easing = cubicOut, x = 0, y = 0, opacity = 0 } = {}) { + const style = getComputedStyle(node); + const target_opacity = +style.opacity; + const transform = style.transform === "none" ? "" : style.transform; + const od = target_opacity * (1 - opacity); + const [xValue, xUnit] = split_css_unit(x); + const [yValue, yUnit] = split_css_unit(y); + return { + delay, + duration, + easing, + css: (t, u) => ` + transform: ${transform} translate(${(1 - t) * xValue}${xUnit}, ${(1 - t) * yValue}${yUnit}); + opacity: ${target_opacity - od * u}` + }; +} +function slide(node, { delay = 0, duration = 400, easing = cubicOut, axis = "y" } = {}) { + const style = getComputedStyle(node); + const opacity = +style.opacity; + const primary_property = axis === "y" ? "height" : "width"; + const primary_property_value = parseFloat(style[primary_property]); + const secondary_properties = axis === "y" ? ["top", "bottom"] : ["left", "right"]; + const capitalized_secondary_properties = secondary_properties.map( + (e) => `${e[0].toUpperCase()}${e.slice(1)}` + ); + const padding_start_value = parseFloat(style[`padding${capitalized_secondary_properties[0]}`]); + const padding_end_value = parseFloat(style[`padding${capitalized_secondary_properties[1]}`]); + const margin_start_value = parseFloat(style[`margin${capitalized_secondary_properties[0]}`]); + const margin_end_value = parseFloat(style[`margin${capitalized_secondary_properties[1]}`]); + const border_width_start_value = parseFloat( + style[`border${capitalized_secondary_properties[0]}Width`] + ); + const border_width_end_value = parseFloat( + style[`border${capitalized_secondary_properties[1]}Width`] + ); + return { + delay, + duration, + easing, + css: (t) => `overflow: hidden;opacity: ${Math.min(t * 20, 1) * opacity};${primary_property}: ${t * primary_property_value}px;padding-${secondary_properties[0]}: ${t * padding_start_value}px;padding-${secondary_properties[1]}: ${t * padding_end_value}px;margin-${secondary_properties[0]}: ${t * margin_start_value}px;margin-${secondary_properties[1]}: ${t * margin_end_value}px;border-${secondary_properties[0]}-width: ${t * border_width_start_value}px;border-${secondary_properties[1]}-width: ${t * border_width_end_value}px;` + }; +} +function scale(node, { delay = 0, duration = 400, easing = cubicOut, start = 0, opacity = 0 } = {}) { + const style = getComputedStyle(node); + const target_opacity = +style.opacity; + const transform = style.transform === "none" ? "" : style.transform; + const sd = 1 - start; + const od = target_opacity * (1 - opacity); + return { + delay, + duration, + easing, + css: (_t, u) => ` + transform: ${transform} scale(${1 - sd * u}); + opacity: ${target_opacity - od * u} + ` + }; +} +function draw(node, { delay = 0, speed, duration, easing = cubicInOut } = {}) { + let len = node.getTotalLength(); + const style = getComputedStyle(node); + if (style.strokeLinecap !== "butt") { + len += parseInt(style.strokeWidth); + } + if (duration === void 0) { + if (speed === void 0) { + duration = 800; + } else { + duration = len / speed; + } + } else if (typeof duration === "function") { + duration = duration(len); + } + return { + delay, + duration, + easing, + css: (_, u) => ` + stroke-dasharray: ${len}; + stroke-dashoffset: ${u * len}; + ` + }; +} +function crossfade({ fallback, ...defaults }) { + const to_receive = /* @__PURE__ */ new Map(); + const to_send = /* @__PURE__ */ new Map(); + function crossfade2(from_node, node, params) { + const { + delay = 0, + duration = (d2) => Math.sqrt(d2) * 30, + easing = cubicOut + } = assign(assign({}, defaults), params); + const from = from_node.getBoundingClientRect(); + const to = node.getBoundingClientRect(); + const dx = from.left - to.left; + const dy = from.top - to.top; + const dw = from.width / to.width; + const dh = from.height / to.height; + const d = Math.sqrt(dx * dx + dy * dy); + const style = getComputedStyle(node); + const transform = style.transform === "none" ? "" : style.transform; + const opacity = +style.opacity; + return { + delay, + duration: is_function(duration) ? duration(d) : duration, + easing, + css: (t, u) => ` + opacity: ${t * opacity}; + transform-origin: top left; + transform: ${transform} translate(${u * dx}px,${u * dy}px) scale(${t + (1 - t) * dw}, ${t + (1 - t) * dh}); + ` + }; + } + function transition(items, counterparts, intro) { + return (node, params) => { + items.set(params.key, node); + return () => { + if (counterparts.has(params.key)) { + const other_node = counterparts.get(params.key); + counterparts.delete(params.key); + return crossfade2(other_node, node, params); + } + items.delete(params.key); + return fallback && fallback(node, params, intro); + }; + }; + } + return [transition(to_send, to_receive, false), transition(to_receive, to_send, true)]; +} +export { + blur, + crossfade, + draw, + fade, + fly, + scale, + slide +}; +//# sourceMappingURL=svelte_transition.js.map diff --git a/node_modules/.vite/deps/svelte_transition.js.map b/node_modules/.vite/deps/svelte_transition.js.map new file mode 100644 index 000000000..ea35ed1ed --- /dev/null +++ b/node_modules/.vite/deps/svelte_transition.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../svelte/src/runtime/transition/index.js"], + "sourcesContent": ["import { cubicOut, cubicInOut, linear } from '../easing/index.js';\r\nimport { assign, split_css_unit, is_function } from '../internal/index.js';\r\n\r\n/**\r\n * Animates a `blur` filter alongside an element's opacity.\r\n *\r\n * https://svelte.dev/docs/svelte-transition#blur\r\n * @param {Element} node\r\n * @param {import('./public').BlurParams} [params]\r\n * @returns {import('./public').TransitionConfig}\r\n */\r\nexport function blur(\r\n\tnode,\r\n\t{ delay = 0, duration = 400, easing = cubicInOut, amount = 5, opacity = 0 } = {}\r\n) {\r\n\tconst style = getComputedStyle(node);\r\n\tconst target_opacity = +style.opacity;\r\n\tconst f = style.filter === 'none' ? '' : style.filter;\r\n\tconst od = target_opacity * (1 - opacity);\r\n\tconst [value, unit] = split_css_unit(amount);\r\n\treturn {\r\n\t\tdelay,\r\n\t\tduration,\r\n\t\teasing,\r\n\t\tcss: (_t, u) => `opacity: ${target_opacity - od * u}; filter: ${f} blur(${u * value}${unit});`\r\n\t};\r\n}\r\n\r\n/**\r\n * Animates the opacity of an element from 0 to the current opacity for `in` transitions and from the current opacity to 0 for `out` transitions.\r\n *\r\n * https://svelte.dev/docs/svelte-transition#fade\r\n * @param {Element} node\r\n * @param {import('./public').FadeParams} [params]\r\n * @returns {import('./public').TransitionConfig}\r\n */\r\nexport function fade(node, { delay = 0, duration = 400, easing = linear } = {}) {\r\n\tconst o = +getComputedStyle(node).opacity;\r\n\treturn {\r\n\t\tdelay,\r\n\t\tduration,\r\n\t\teasing,\r\n\t\tcss: (t) => `opacity: ${t * o}`\r\n\t};\r\n}\r\n\r\n/**\r\n * Animates the x and y positions and the opacity of an element. `in` transitions animate from the provided values, passed as parameters to the element's default values. `out` transitions animate from the element's default values to the provided values.\r\n *\r\n * https://svelte.dev/docs/svelte-transition#fly\r\n * @param {Element} node\r\n * @param {import('./public').FlyParams} [params]\r\n * @returns {import('./public').TransitionConfig}\r\n */\r\nexport function fly(\r\n\tnode,\r\n\t{ delay = 0, duration = 400, easing = cubicOut, x = 0, y = 0, opacity = 0 } = {}\r\n) {\r\n\tconst style = getComputedStyle(node);\r\n\tconst target_opacity = +style.opacity;\r\n\tconst transform = style.transform === 'none' ? '' : style.transform;\r\n\tconst od = target_opacity * (1 - opacity);\r\n\tconst [xValue, xUnit] = split_css_unit(x);\r\n\tconst [yValue, yUnit] = split_css_unit(y);\r\n\treturn {\r\n\t\tdelay,\r\n\t\tduration,\r\n\t\teasing,\r\n\t\tcss: (t, u) => `\r\n\t\t\ttransform: ${transform} translate(${(1 - t) * xValue}${xUnit}, ${(1 - t) * yValue}${yUnit});\r\n\t\t\topacity: ${target_opacity - od * u}`\r\n\t};\r\n}\r\n\r\n/**\r\n * Slides an element in and out.\r\n *\r\n * https://svelte.dev/docs/svelte-transition#slide\r\n * @param {Element} node\r\n * @param {import('./public').SlideParams} [params]\r\n * @returns {import('./public').TransitionConfig}\r\n */\r\nexport function slide(node, { delay = 0, duration = 400, easing = cubicOut, axis = 'y' } = {}) {\r\n\tconst style = getComputedStyle(node);\r\n\tconst opacity = +style.opacity;\r\n\tconst primary_property = axis === 'y' ? 'height' : 'width';\r\n\tconst primary_property_value = parseFloat(style[primary_property]);\r\n\tconst secondary_properties = axis === 'y' ? ['top', 'bottom'] : ['left', 'right'];\r\n\tconst capitalized_secondary_properties = secondary_properties.map(\r\n\t\t(e) => `${e[0].toUpperCase()}${e.slice(1)}`\r\n\t);\r\n\tconst padding_start_value = parseFloat(style[`padding${capitalized_secondary_properties[0]}`]);\r\n\tconst padding_end_value = parseFloat(style[`padding${capitalized_secondary_properties[1]}`]);\r\n\tconst margin_start_value = parseFloat(style[`margin${capitalized_secondary_properties[0]}`]);\r\n\tconst margin_end_value = parseFloat(style[`margin${capitalized_secondary_properties[1]}`]);\r\n\tconst border_width_start_value = parseFloat(\r\n\t\tstyle[`border${capitalized_secondary_properties[0]}Width`]\r\n\t);\r\n\tconst border_width_end_value = parseFloat(\r\n\t\tstyle[`border${capitalized_secondary_properties[1]}Width`]\r\n\t);\r\n\treturn {\r\n\t\tdelay,\r\n\t\tduration,\r\n\t\teasing,\r\n\t\tcss: (t) =>\r\n\t\t\t'overflow: hidden;' +\r\n\t\t\t`opacity: ${Math.min(t * 20, 1) * opacity};` +\r\n\t\t\t`${primary_property}: ${t * primary_property_value}px;` +\r\n\t\t\t`padding-${secondary_properties[0]}: ${t * padding_start_value}px;` +\r\n\t\t\t`padding-${secondary_properties[1]}: ${t * padding_end_value}px;` +\r\n\t\t\t`margin-${secondary_properties[0]}: ${t * margin_start_value}px;` +\r\n\t\t\t`margin-${secondary_properties[1]}: ${t * margin_end_value}px;` +\r\n\t\t\t`border-${secondary_properties[0]}-width: ${t * border_width_start_value}px;` +\r\n\t\t\t`border-${secondary_properties[1]}-width: ${t * border_width_end_value}px;`\r\n\t};\r\n}\r\n\r\n/**\r\n * Animates the opacity and scale of an element. `in` transitions animate from an element's current (default) values to the provided values, passed as parameters. `out` transitions animate from the provided values to an element's default values.\r\n *\r\n * https://svelte.dev/docs/svelte-transition#scale\r\n * @param {Element} node\r\n * @param {import('./public').ScaleParams} [params]\r\n * @returns {import('./public').TransitionConfig}\r\n */\r\nexport function scale(\r\n\tnode,\r\n\t{ delay = 0, duration = 400, easing = cubicOut, start = 0, opacity = 0 } = {}\r\n) {\r\n\tconst style = getComputedStyle(node);\r\n\tconst target_opacity = +style.opacity;\r\n\tconst transform = style.transform === 'none' ? '' : style.transform;\r\n\tconst sd = 1 - start;\r\n\tconst od = target_opacity * (1 - opacity);\r\n\treturn {\r\n\t\tdelay,\r\n\t\tduration,\r\n\t\teasing,\r\n\t\tcss: (_t, u) => `\r\n\t\t\ttransform: ${transform} scale(${1 - sd * u});\r\n\t\t\topacity: ${target_opacity - od * u}\r\n\t\t`\r\n\t};\r\n}\r\n\r\n/**\r\n * Animates the stroke of an SVG element, like a snake in a tube. `in` transitions begin with the path invisible and draw the path to the screen over time. `out` transitions start in a visible state and gradually erase the path. `draw` only works with elements that have a `getTotalLength` method, like `` and ``.\r\n *\r\n * https://svelte.dev/docs/svelte-transition#draw\r\n * @param {SVGElement & { getTotalLength(): number }} node\r\n * @param {import('./public').DrawParams} [params]\r\n * @returns {import('./public').TransitionConfig}\r\n */\r\nexport function draw(node, { delay = 0, speed, duration, easing = cubicInOut } = {}) {\r\n\tlet len = node.getTotalLength();\r\n\tconst style = getComputedStyle(node);\r\n\tif (style.strokeLinecap !== 'butt') {\r\n\t\tlen += parseInt(style.strokeWidth);\r\n\t}\r\n\tif (duration === undefined) {\r\n\t\tif (speed === undefined) {\r\n\t\t\tduration = 800;\r\n\t\t} else {\r\n\t\t\tduration = len / speed;\r\n\t\t}\r\n\t} else if (typeof duration === 'function') {\r\n\t\tduration = duration(len);\r\n\t}\r\n\treturn {\r\n\t\tdelay,\r\n\t\tduration,\r\n\t\teasing,\r\n\t\tcss: (_, u) => `\r\n\t\t\tstroke-dasharray: ${len};\r\n\t\t\tstroke-dashoffset: ${u * len};\r\n\t\t`\r\n\t};\r\n}\r\n\r\n/**\r\n * The `crossfade` function creates a pair of [transitions](/docs#template-syntax-element-directives-transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used.\r\n *\r\n * https://svelte.dev/docs/svelte-transition#crossfade\r\n * @param {import('./public').CrossfadeParams & {\r\n * \tfallback?: (node: Element, params: import('./public').CrossfadeParams, intro: boolean) => import('./public').TransitionConfig;\r\n * }} params\r\n * @returns {[(node: any, params: import('./public').CrossfadeParams & { key: any; }) => () => import('./public').TransitionConfig, (node: any, params: import('./public').CrossfadeParams & { key: any; }) => () => import('./public').TransitionConfig]}\r\n */\r\nexport function crossfade({ fallback, ...defaults }) {\r\n\t/** @type {Map} */\r\n\tconst to_receive = new Map();\r\n\t/** @type {Map} */\r\n\tconst to_send = new Map();\r\n\t/**\r\n\t * @param {Element} from_node\r\n\t * @param {Element} node\r\n\t * @param {import('./public').CrossfadeParams} params\r\n\t * @returns {import('./public').TransitionConfig}\r\n\t */\r\n\tfunction crossfade(from_node, node, params) {\r\n\t\tconst {\r\n\t\t\tdelay = 0,\r\n\t\t\tduration = (d) => Math.sqrt(d) * 30,\r\n\t\t\teasing = cubicOut\r\n\t\t} = assign(assign({}, defaults), params);\r\n\t\tconst from = from_node.getBoundingClientRect();\r\n\t\tconst to = node.getBoundingClientRect();\r\n\t\tconst dx = from.left - to.left;\r\n\t\tconst dy = from.top - to.top;\r\n\t\tconst dw = from.width / to.width;\r\n\t\tconst dh = from.height / to.height;\r\n\t\tconst d = Math.sqrt(dx * dx + dy * dy);\r\n\t\tconst style = getComputedStyle(node);\r\n\t\tconst transform = style.transform === 'none' ? '' : style.transform;\r\n\t\tconst opacity = +style.opacity;\r\n\t\treturn {\r\n\t\t\tdelay,\r\n\t\t\tduration: is_function(duration) ? duration(d) : duration,\r\n\t\t\teasing,\r\n\t\t\tcss: (t, u) => `\r\n\t\t\t\topacity: ${t * opacity};\r\n\t\t\t\ttransform-origin: top left;\r\n\t\t\t\ttransform: ${transform} translate(${u * dx}px,${u * dy}px) scale(${t + (1 - t) * dw}, ${\r\n\t\t\t\tt + (1 - t) * dh\r\n\t\t\t});\r\n\t\t\t`\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * @param {Map} items\r\n\t * @param {Map} counterparts\r\n\t * @param {boolean} intro\r\n\t * @returns {(node: any, params: import('./public').CrossfadeParams & { key: any; }) => () => import('./public').TransitionConfig}\r\n\t */\r\n\tfunction transition(items, counterparts, intro) {\r\n\t\treturn (node, params) => {\r\n\t\t\titems.set(params.key, node);\r\n\t\t\treturn () => {\r\n\t\t\t\tif (counterparts.has(params.key)) {\r\n\t\t\t\t\tconst other_node = counterparts.get(params.key);\r\n\t\t\t\t\tcounterparts.delete(params.key);\r\n\t\t\t\t\treturn crossfade(other_node, node, params);\r\n\t\t\t\t}\r\n\t\t\t\t// if the node is disappearing altogether\r\n\t\t\t\t// (i.e. wasn't claimed by the other list)\r\n\t\t\t\t// then we need to supply an outro\r\n\t\t\t\titems.delete(params.key);\r\n\t\t\t\treturn fallback && fallback(node, params, intro);\r\n\t\t\t};\r\n\t\t};\r\n\t}\r\n\treturn [transition(to_send, to_receive, false), transition(to_receive, to_send, true)];\r\n}\r\n"], + "mappings": ";;;;;;;;;;;;;;AAWO,SAAS,KACf,MACA,EAAE,QAAQ,GAAG,WAAW,KAAK,SAAS,YAAY,SAAS,GAAG,UAAU,EAAE,IAAI,CAAC,GAC9E;AACD,QAAM,QAAQ,iBAAiB,IAAI;AACnC,QAAM,iBAAiB,CAAC,MAAM;AAC9B,QAAM,IAAI,MAAM,WAAW,SAAS,KAAK,MAAM;AAC/C,QAAM,KAAK,kBAAkB,IAAI;AACjC,QAAM,CAAC,OAAO,IAAI,IAAI,eAAe,MAAM;AAC3C,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK,CAAC,IAAI,MAAM,YAAY,iBAAiB,KAAK,CAAC,aAAa,CAAC,SAAS,IAAI,KAAK,GAAG,IAAI;AAAA,EAC3F;AACD;AAUO,SAAS,KAAK,MAAM,EAAE,QAAQ,GAAG,WAAW,KAAK,SAAS,SAAO,IAAI,CAAC,GAAG;AAC/E,QAAM,IAAI,CAAC,iBAAiB,IAAI,EAAE;AAClC,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK,CAAC,MAAM,YAAY,IAAI,CAAC;AAAA,EAC9B;AACD;AAUO,SAAS,IACf,MACA,EAAE,QAAQ,GAAG,WAAW,K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A,MAChD;AAAA,MACA,KAAK,CAAC,GAAG,MAAM;AAAA,eACH,IAAI,OAAO;AAAA;AAAA,iBAET,SAAS,cAAc,IAAI,EAAE,MAAM,IAAI,EAAE,aAAa,KAAK,IAAI,KAAK,EAAE,KACnF,KAAK,IAAI,KAAK,EACf;AAAA;AAAA,IAED;AAAA,EACD;AAQA,WAAS,WAAW,OAAO,cAAc,OAAO;AAC/C,WAAO,CAAC,MAAM,WAAW;AACxB,YAAM,IAAI,OAAO,KAAK,IAAI;AAC1B,aAAO,MAAM;AACZ,YAAI,aAAa,IAAI,OAAO,GAAG,GAAG;AACjC,gBAAM,aAAa,aAAa,IAAI,OAAO,GAAG;AAC9C,uBAAa,OAAO,OAAO,GAAG;AAC9B,iBAAOD,WAAU,YAAY,MAAM,MAAM;AAAA,QAC1C;AAIA,cAAM,OAAO,OAAO,GAAG;AACvB,eAAO,YAAY,SAAS,MAAM,QAAQ,KAAK;AAAA,MAChD;AAAA,IACD;AAAA,EACD;AACA,SAAO,CAAC,WAAW,SAAS,YAAY,KAAK,GAAG,WAAW,YAAY,SAAS,IAAI,CAAC;AACtF;", + "names": ["crossfade", "d"] +} diff --git a/node_modules/@ampproject/remapping/LICENSE b/node_modules/@ampproject/remapping/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/node_modules/@ampproject/remapping/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/node_modules/@ampproject/remapping/README.md b/node_modules/@ampproject/remapping/README.md new file mode 100644 index 000000000..1463c9f62 --- /dev/null +++ b/node_modules/@ampproject/remapping/README.md @@ -0,0 +1,218 @@ +# @ampproject/remapping + +> Remap sequential sourcemaps through transformations to point at the original source code + +Remapping allows you to take the sourcemaps generated through transforming your code and "remap" +them to the original source locations. Think "my minified code, transformed with babel and bundled +with webpack", all pointing to the correct location in your original source code. + +With remapping, none of your source code transformations need to be aware of the input's sourcemap, +they only need to generate an output sourcemap. This greatly simplifies building custom +transformations (think a find-and-replace). + +## Installation + +```sh +npm install @ampproject/remapping +``` + +## Usage + +```typescript +function remapping( + map: SourceMap | SourceMap[], + loader: (file: string, ctx: LoaderContext) => (SourceMap | null | undefined), + options?: { excludeContent: boolean, decodedMappings: boolean } +): SourceMap; + +// LoaderContext gives the loader the importing sourcemap, tree depth, the ability to override the +// "source" location (where child sources are resolved relative to, or the location of original +// source), and the ability to override the "content" of an original source for inclusion in the +// output sourcemap. +type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; +} +``` + +`remapping` takes the final output sourcemap, and a `loader` function. For every source file pointer +in the sourcemap, the `loader` will be called with the resolved path. If the path itself represents +a transformed file (it has a sourcmap associated with it), then the `loader` should return that +sourcemap. If not, the path will be treated as an original, untransformed source code. + +```js +// Babel transformed "helloworld.js" into "transformed.js" +const transformedMap = JSON.stringify({ + file: 'transformed.js', + // 1st column of 2nd line of output file translates into the 1st source + // file, line 3, column 2 + mappings: ';CAEE', + sources: ['helloworld.js'], + version: 3, +}); + +// Uglify minified "transformed.js" into "transformed.min.js" +const minifiedTransformedMap = JSON.stringify({ + file: 'transformed.min.js', + // 0th column of 1st line of output file translates into the 1st source + // file, line 2, column 1. + mappings: 'AACC', + names: [], + sources: ['transformed.js'], + version: 3, +}); + +const remapped = remapping( + minifiedTransformedMap, + (file, ctx) => { + + // The "transformed.js" file is an transformed file. + if (file === 'transformed.js') { + // The root importer is empty. + console.assert(ctx.importer === ''); + // The depth in the sourcemap tree we're currently loading. + // The root `minifiedTransformedMap` is depth 0, and its source children are depth 1, etc. + console.assert(ctx.depth === 1); + + return transformedMap; + } + + // Loader will be called to load transformedMap's source file pointers as well. + console.assert(file === 'helloworld.js'); + // `transformed.js`'s sourcemap points into `helloworld.js`. + console.assert(ctx.importer === 'transformed.js'); + // This is a source child of `transformed`, which is a source child of `minifiedTransformedMap`. + console.assert(ctx.depth === 2); + return null; + } +); + +console.log(remapped); +// { +// file: 'transpiled.min.js', +// mappings: 'AAEE', +// sources: ['helloworld.js'], +// version: 3, +// }; +``` + +In this example, `loader` will be called twice: + +1. `"transformed.js"`, the first source file pointer in the `minifiedTransformedMap`. We return the + associated sourcemap for it (its a transformed file, after all) so that sourcemap locations can + be traced through it into the source files it represents. +2. `"helloworld.js"`, our original, unmodified source code. This file does not have a sourcemap, so + we return `null`. + +The `remapped` sourcemap now points from `transformed.min.js` into locations in `helloworld.js`. If +you were to read the `mappings`, it says "0th column of the first line output line points to the 1st +column of the 2nd line of the file `helloworld.js`". + +### Multiple transformations of a file + +As a convenience, if you have multiple single-source transformations of a file, you may pass an +array of sourcemap files in the order of most-recent transformation sourcemap first. Note that this +changes the `importer` and `depth` of each call to our loader. So our above example could have been +written as: + +```js +const remapped = remapping( + [minifiedTransformedMap, transformedMap], + () => null +); + +console.log(remapped); +// { +// file: 'transpiled.min.js', +// mappings: 'AAEE', +// sources: ['helloworld.js'], +// version: 3, +// }; +``` + +### Advanced control of the loading graph + +#### `source` + +The `source` property can overridden to any value to change the location of the current load. Eg, +for an original source file, it allows us to change the location to the original source regardless +of what the sourcemap source entry says. And for transformed files, it allows us to change the +relative resolving location for child sources of the loaded sourcemap. + +```js +const remapped = remapping( + minifiedTransformedMap, + (file, ctx) => { + + if (file === 'transformed.js') { + // We pretend the transformed.js file actually exists in the 'src/' directory. When the nested + // source files are loaded, they will now be relative to `src/`. + ctx.source = 'src/transformed.js'; + return transformedMap; + } + + console.assert(file === 'src/helloworld.js'); + // We could futher change the source of this original file, eg, to be inside a nested directory + // itself. This will be reflected in the remapped sourcemap. + ctx.source = 'src/nested/transformed.js'; + return null; + } +); + +console.log(remapped); +// { +// …, +// sources: ['src/nested/helloworld.js'], +// }; +``` + + +#### `content` + +The `content` property can be overridden when we encounter an original source file. Eg, this allows +you to manually provide the source content of the original file regardless of whether the +`sourcesContent` field is present in the parent sourcemap. It can also be set to `null` to remove +the source content. + +```js +const remapped = remapping( + minifiedTransformedMap, + (file, ctx) => { + + if (file === 'transformed.js') { + // transformedMap does not include a `sourcesContent` field, so usually the remapped sourcemap + // would not include any `sourcesContent` values. + return transformedMap; + } + + console.assert(file === 'helloworld.js'); + // We can read the file to provide the source content. + ctx.content = fs.readFileSync(file, 'utf8'); + return null; + } +); + +console.log(remapped); +// { +// …, +// sourcesContent: [ +// 'console.log("Hello world!")', +// ], +// }; +``` + +### Options + +#### excludeContent + +By default, `excludeContent` is `false`. Passing `{ excludeContent: true }` will exclude the +`sourcesContent` field from the returned sourcemap. This is mainly useful when you want to reduce +the size out the sourcemap. + +#### decodedMappings + +By default, `decodedMappings` is `false`. Passing `{ decodedMappings: true }` will leave the +`mappings` field in a [decoded state](https://github.com/rich-harris/sourcemap-codec) instead of +encoding into a VLQ string. diff --git a/node_modules/@ampproject/remapping/dist/remapping.mjs b/node_modules/@ampproject/remapping/dist/remapping.mjs new file mode 100644 index 000000000..b5eddeda5 --- /dev/null +++ b/node_modules/@ampproject/remapping/dist/remapping.mjs @@ -0,0 +1,191 @@ +import { decodedMappings, traceSegment, TraceMap } from '@jridgewell/trace-mapping'; +import { GenMapping, maybeAddSegment, setSourceContent, toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping'; + +const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null); +const EMPTY_SOURCES = []; +function SegmentObject(source, line, column, name, content) { + return { source, line, column, name, content }; +} +function Source(map, sources, source, content) { + return { + map, + sources, + source, + content, + }; +} +/** + * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes + * (which may themselves be SourceMapTrees). + */ +function MapSource(map, sources) { + return Source(map, sources, '', null); +} +/** + * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive + * segment tracing ends at the `OriginalSource`. + */ +function OriginalSource(source, content) { + return Source(null, EMPTY_SOURCES, source, content); +} +/** + * traceMappings is only called on the root level SourceMapTree, and begins the process of + * resolving each mapping in terms of the original source files. + */ +function traceMappings(tree) { + // TODO: Eventually support sourceRoot, which has to be removed because the sources are already + // fully resolved. We'll need to make sources relative to the sourceRoot before adding them. + const gen = new GenMapping({ file: tree.map.file }); + const { sources: rootSources, map } = tree; + const rootNames = map.names; + const rootMappings = decodedMappings(map); + for (let i = 0; i < rootMappings.length; i++) { + const segments = rootMappings[i]; + for (let j = 0; j < segments.length; j++) { + const segment = segments[j]; + const genCol = segment[0]; + let traced = SOURCELESS_MAPPING; + // 1-length segments only move the current generated column, there's no source information + // to gather from it. + if (segment.length !== 1) { + const source = rootSources[segment[1]]; + traced = originalPositionFor(source, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : ''); + // If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a + // respective segment into an original source. + if (traced == null) + continue; + } + const { column, line, name, content, source } = traced; + maybeAddSegment(gen, i, genCol, source, line, column, name); + if (source && content != null) + setSourceContent(gen, source, content); + } + } + return gen; +} +/** + * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own + * child SourceMapTrees, until we find the original source map. + */ +function originalPositionFor(source, line, column, name) { + if (!source.map) { + return SegmentObject(source.source, line, column, name, source.content); + } + const segment = traceSegment(source.map, line, column); + // If we couldn't find a segment, then this doesn't exist in the sourcemap. + if (segment == null) + return null; + // 1-length segments only move the current generated column, there's no source information + // to gather from it. + if (segment.length === 1) + return SOURCELESS_MAPPING; + return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name); +} + +function asArray(value) { + if (Array.isArray(value)) + return value; + return [value]; +} +/** + * Recursively builds a tree structure out of sourcemap files, with each node + * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of + * `OriginalSource`s and `SourceMapTree`s. + * + * Every sourcemap is composed of a collection of source files and mappings + * into locations of those source files. When we generate a `SourceMapTree` for + * the sourcemap, we attempt to load each source file's own sourcemap. If it + * does not have an associated sourcemap, it is considered an original, + * unmodified source file. + */ +function buildSourceMapTree(input, loader) { + const maps = asArray(input).map((m) => new TraceMap(m, '')); + const map = maps.pop(); + for (let i = 0; i < maps.length; i++) { + if (maps[i].sources.length > 1) { + throw new Error(`Transformation map ${i} must have exactly one source file.\n` + + 'Did you specify these with the most recent transformation maps first?'); + } + } + let tree = build(map, loader, '', 0); + for (let i = maps.length - 1; i >= 0; i--) { + tree = MapSource(maps[i], [tree]); + } + return tree; +} +function build(map, loader, importer, importerDepth) { + const { resolvedSources, sourcesContent } = map; + const depth = importerDepth + 1; + const children = resolvedSources.map((sourceFile, i) => { + // The loading context gives the loader more information about why this file is being loaded + // (eg, from which importer). It also allows the loader to override the location of the loaded + // sourcemap/original source, or to override the content in the sourcesContent field if it's + // an unmodified source file. + const ctx = { + importer, + depth, + source: sourceFile || '', + content: undefined, + }; + // Use the provided loader callback to retrieve the file's sourcemap. + // TODO: We should eventually support async loading of sourcemap files. + const sourceMap = loader(ctx.source, ctx); + const { source, content } = ctx; + // If there is a sourcemap, then we need to recurse into it to load its source files. + if (sourceMap) + return build(new TraceMap(sourceMap, source), loader, source, depth); + // Else, it's an an unmodified source file. + // The contents of this unmodified source file can be overridden via the loader context, + // allowing it to be explicitly null or a string. If it remains undefined, we fall back to + // the importing sourcemap's `sourcesContent` field. + const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null; + return OriginalSource(source, sourceContent); + }); + return MapSource(map, children); +} + +/** + * A SourceMap v3 compatible sourcemap, which only includes fields that were + * provided to it. + */ +class SourceMap { + constructor(map, options) { + const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map); + this.version = out.version; // SourceMap spec says this should be first. + this.file = out.file; + this.mappings = out.mappings; + this.names = out.names; + this.sourceRoot = out.sourceRoot; + this.sources = out.sources; + if (!options.excludeContent) { + this.sourcesContent = out.sourcesContent; + } + } + toString() { + return JSON.stringify(this); + } +} + +/** + * Traces through all the mappings in the root sourcemap, through the sources + * (and their sourcemaps), all the way back to the original source location. + * + * `loader` will be called every time we encounter a source file. If it returns + * a sourcemap, we will recurse into that sourcemap to continue the trace. If + * it returns a falsey value, that source file is treated as an original, + * unmodified source file. + * + * Pass `excludeContent` to exclude any self-containing source file content + * from the output sourcemap. + * + * Pass `decodedMappings` to receive a SourceMap with decoded (instead of + * VLQ encoded) mappings. + */ +function remapping(input, loader, options) { + const opts = typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false }; + const tree = buildSourceMapTree(input, loader); + return new SourceMap(traceMappings(tree), opts); +} + +export { remapping as default }; +//# sourceMappingURL=remapping.mjs.map diff --git a/node_modules/@ampproject/remapping/dist/remapping.mjs.map b/node_modules/@ampproject/remapping/dist/remapping.mjs.map new file mode 100644 index 000000000..078a2b73b --- /dev/null +++ b/node_modules/@ampproject/remapping/dist/remapping.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"remapping.mjs","sources":["../src/source-map-tree.ts","../src/build-source-map-tree.ts","../src/source-map.ts","../src/remapping.ts"],"sourcesContent":["import { GenMapping, maybeAddSegment, setSourceContent } from '@jridgewell/gen-mapping';\nimport { traceSegment, decodedMappings } from '@jridgewell/trace-mapping';\n\nimport type { TraceMap } from '@jridgewell/trace-mapping';\n\nexport type SourceMapSegmentObject = {\n column: number;\n line: number;\n name: string;\n source: string;\n content: string | null;\n};\n\nexport type OriginalSource = {\n map: null;\n sources: Sources[];\n source: string;\n content: string | null;\n};\n\nexport type MapSource = {\n map: TraceMap;\n sources: Sources[];\n source: string;\n content: null;\n};\n\nexport type Sources = OriginalSource | MapSource;\n\nconst SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null);\nconst EMPTY_SOURCES: Sources[] = [];\n\nfunction SegmentObject(\n source: string,\n line: number,\n column: number,\n name: string,\n content: string | null\n): SourceMapSegmentObject {\n return { source, line, column, name, content };\n}\n\nfunction Source(map: TraceMap, sources: Sources[], source: '', content: null): MapSource;\nfunction Source(\n map: null,\n sources: Sources[],\n source: string,\n content: string | null\n): OriginalSource;\nfunction Source(\n map: TraceMap | null,\n sources: Sources[],\n source: string | '',\n content: string | null\n): Sources {\n return {\n map,\n sources,\n source,\n content,\n } as any;\n}\n\n/**\n * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes\n * (which may themselves be SourceMapTrees).\n */\nexport function MapSource(map: TraceMap, sources: Sources[]): MapSource {\n return Source(map, sources, '', null);\n}\n\n/**\n * A \"leaf\" node in the sourcemap tree, representing an original, unmodified source file. Recursive\n * segment tracing ends at the `OriginalSource`.\n */\nexport function OriginalSource(source: string, content: string | null): OriginalSource {\n return Source(null, EMPTY_SOURCES, source, content);\n}\n\n/**\n * traceMappings is only called on the root level SourceMapTree, and begins the process of\n * resolving each mapping in terms of the original source files.\n */\nexport function traceMappings(tree: MapSource): GenMapping {\n // TODO: Eventually support sourceRoot, which has to be removed because the sources are already\n // fully resolved. We'll need to make sources relative to the sourceRoot before adding them.\n const gen = new GenMapping({ file: tree.map.file });\n const { sources: rootSources, map } = tree;\n const rootNames = map.names;\n const rootMappings = decodedMappings(map);\n\n for (let i = 0; i < rootMappings.length; i++) {\n const segments = rootMappings[i];\n\n for (let j = 0; j < segments.length; j++) {\n const segment = segments[j];\n const genCol = segment[0];\n let traced: SourceMapSegmentObject | null = SOURCELESS_MAPPING;\n\n // 1-length segments only move the current generated column, there's no source information\n // to gather from it.\n if (segment.length !== 1) {\n const source = rootSources[segment[1]];\n traced = originalPositionFor(\n source,\n segment[2],\n segment[3],\n segment.length === 5 ? rootNames[segment[4]] : ''\n );\n\n // If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a\n // respective segment into an original source.\n if (traced == null) continue;\n }\n\n const { column, line, name, content, source } = traced;\n\n maybeAddSegment(gen, i, genCol, source, line, column, name);\n if (source && content != null) setSourceContent(gen, source, content);\n }\n }\n\n return gen;\n}\n\n/**\n * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own\n * child SourceMapTrees, until we find the original source map.\n */\nexport function originalPositionFor(\n source: Sources,\n line: number,\n column: number,\n name: string\n): SourceMapSegmentObject | null {\n if (!source.map) {\n return SegmentObject(source.source, line, column, name, source.content);\n }\n\n const segment = traceSegment(source.map, line, column);\n\n // If we couldn't find a segment, then this doesn't exist in the sourcemap.\n if (segment == null) return null;\n // 1-length segments only move the current generated column, there's no source information\n // to gather from it.\n if (segment.length === 1) return SOURCELESS_MAPPING;\n\n return originalPositionFor(\n source.sources[segment[1]],\n segment[2],\n segment[3],\n segment.length === 5 ? source.map.names[segment[4]] : name\n );\n}\n","import { TraceMap } from '@jridgewell/trace-mapping';\n\nimport { OriginalSource, MapSource } from './source-map-tree';\n\nimport type { Sources, MapSource as MapSourceType } from './source-map-tree';\nimport type { SourceMapInput, SourceMapLoader, LoaderContext } from './types';\n\nfunction asArray(value: T | T[]): T[] {\n if (Array.isArray(value)) return value;\n return [value];\n}\n\n/**\n * Recursively builds a tree structure out of sourcemap files, with each node\n * being either an `OriginalSource` \"leaf\" or a `SourceMapTree` composed of\n * `OriginalSource`s and `SourceMapTree`s.\n *\n * Every sourcemap is composed of a collection of source files and mappings\n * into locations of those source files. When we generate a `SourceMapTree` for\n * the sourcemap, we attempt to load each source file's own sourcemap. If it\n * does not have an associated sourcemap, it is considered an original,\n * unmodified source file.\n */\nexport default function buildSourceMapTree(\n input: SourceMapInput | SourceMapInput[],\n loader: SourceMapLoader\n): MapSourceType {\n const maps = asArray(input).map((m) => new TraceMap(m, ''));\n const map = maps.pop()!;\n\n for (let i = 0; i < maps.length; i++) {\n if (maps[i].sources.length > 1) {\n throw new Error(\n `Transformation map ${i} must have exactly one source file.\\n` +\n 'Did you specify these with the most recent transformation maps first?'\n );\n }\n }\n\n let tree = build(map, loader, '', 0);\n for (let i = maps.length - 1; i >= 0; i--) {\n tree = MapSource(maps[i], [tree]);\n }\n return tree;\n}\n\nfunction build(\n map: TraceMap,\n loader: SourceMapLoader,\n importer: string,\n importerDepth: number\n): MapSourceType {\n const { resolvedSources, sourcesContent } = map;\n\n const depth = importerDepth + 1;\n const children = resolvedSources.map((sourceFile: string | null, i: number): Sources => {\n // The loading context gives the loader more information about why this file is being loaded\n // (eg, from which importer). It also allows the loader to override the location of the loaded\n // sourcemap/original source, or to override the content in the sourcesContent field if it's\n // an unmodified source file.\n const ctx: LoaderContext = {\n importer,\n depth,\n source: sourceFile || '',\n content: undefined,\n };\n\n // Use the provided loader callback to retrieve the file's sourcemap.\n // TODO: We should eventually support async loading of sourcemap files.\n const sourceMap = loader(ctx.source, ctx);\n\n const { source, content } = ctx;\n\n // If there is a sourcemap, then we need to recurse into it to load its source files.\n if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth);\n\n // Else, it's an an unmodified source file.\n // The contents of this unmodified source file can be overridden via the loader context,\n // allowing it to be explicitly null or a string. If it remains undefined, we fall back to\n // the importing sourcemap's `sourcesContent` field.\n const sourceContent =\n content !== undefined ? content : sourcesContent ? sourcesContent[i] : null;\n return OriginalSource(source, sourceContent);\n });\n\n return MapSource(map, children);\n}\n","import { toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping';\n\nimport type { GenMapping } from '@jridgewell/gen-mapping';\nimport type { DecodedSourceMap, EncodedSourceMap, Options } from './types';\n\n/**\n * A SourceMap v3 compatible sourcemap, which only includes fields that were\n * provided to it.\n */\nexport default class SourceMap {\n declare file?: string | null;\n declare mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings'];\n declare sourceRoot?: string;\n declare names: string[];\n declare sources: (string | null)[];\n declare sourcesContent?: (string | null)[];\n declare version: 3;\n\n constructor(map: GenMapping, options: Options) {\n const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);\n this.version = out.version; // SourceMap spec says this should be first.\n this.file = out.file;\n this.mappings = out.mappings as SourceMap['mappings'];\n this.names = out.names as SourceMap['names'];\n\n this.sourceRoot = out.sourceRoot;\n\n this.sources = out.sources as SourceMap['sources'];\n if (!options.excludeContent) {\n this.sourcesContent = out.sourcesContent as SourceMap['sourcesContent'];\n }\n }\n\n toString(): string {\n return JSON.stringify(this);\n }\n}\n","import buildSourceMapTree from './build-source-map-tree';\nimport { traceMappings } from './source-map-tree';\nimport SourceMap from './source-map';\n\nimport type { SourceMapInput, SourceMapLoader, Options } from './types';\nexport type {\n SourceMapSegment,\n EncodedSourceMap,\n EncodedSourceMap as RawSourceMap,\n DecodedSourceMap,\n SourceMapInput,\n SourceMapLoader,\n LoaderContext,\n Options,\n} from './types';\n\n/**\n * Traces through all the mappings in the root sourcemap, through the sources\n * (and their sourcemaps), all the way back to the original source location.\n *\n * `loader` will be called every time we encounter a source file. If it returns\n * a sourcemap, we will recurse into that sourcemap to continue the trace. If\n * it returns a falsey value, that source file is treated as an original,\n * unmodified source file.\n *\n * Pass `excludeContent` to exclude any self-containing source file content\n * from the output sourcemap.\n *\n * Pass `decodedMappings` to receive a SourceMap with decoded (instead of\n * VLQ encoded) mappings.\n */\nexport default function remapping(\n input: SourceMapInput | SourceMapInput[],\n loader: SourceMapLoader,\n options?: boolean | Options\n): SourceMap {\n const opts =\n typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false };\n const tree = buildSourceMapTree(input, loader);\n return new SourceMap(traceMappings(tree), opts);\n}\n"],"names":[],"mappings":";;;AA6BA,MAAM,kBAAkB,mBAAmB,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AAC/E,MAAM,aAAa,GAAc,EAAE,CAAC;AAEpC,SAAS,aAAa,CACpB,MAAc,EACd,IAAY,EACZ,MAAc,EACd,IAAY,EACZ,OAAsB,EAAA;IAEtB,OAAO,EAAE,MAAM,EAA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,CAAC,CAAC;AAClD;;;;"} \ No newline at end of file diff --git a/node_modules/@ampproject/remapping/dist/remapping.umd.js b/node_modules/@ampproject/remapping/dist/remapping.umd.js new file mode 100644 index 000000000..e292d4c37 --- /dev/null +++ b/node_modules/@ampproject/remapping/dist/remapping.umd.js @@ -0,0 +1,196 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@jridgewell/trace-mapping'), require('@jridgewell/gen-mapping')) : + typeof define === 'function' && define.amd ? define(['@jridgewell/trace-mapping', '@jridgewell/gen-mapping'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.remapping = factory(global.traceMapping, global.genMapping)); +})(this, (function (traceMapping, genMapping) { 'use strict'; + + const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null); + const EMPTY_SOURCES = []; + function SegmentObject(source, line, column, name, content) { + return { source, line, column, name, content }; + } + function Source(map, sources, source, content) { + return { + map, + sources, + source, + content, + }; + } + /** + * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes + * (which may themselves be SourceMapTrees). + */ + function MapSource(map, sources) { + return Source(map, sources, '', null); + } + /** + * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive + * segment tracing ends at the `OriginalSource`. + */ + function OriginalSource(source, content) { + return Source(null, EMPTY_SOURCES, source, content); + } + /** + * traceMappings is only called on the root level SourceMapTree, and begins the process of + * resolving each mapping in terms of the original source files. + */ + function traceMappings(tree) { + // TODO: Eventually support sourceRoot, which has to be removed because the sources are already + // fully resolved. We'll need to make sources relative to the sourceRoot before adding them. + const gen = new genMapping.GenMapping({ file: tree.map.file }); + const { sources: rootSources, map } = tree; + const rootNames = map.names; + const rootMappings = traceMapping.decodedMappings(map); + for (let i = 0; i < rootMappings.length; i++) { + const segments = rootMappings[i]; + for (let j = 0; j < segments.length; j++) { + const segment = segments[j]; + const genCol = segment[0]; + let traced = SOURCELESS_MAPPING; + // 1-length segments only move the current generated column, there's no source information + // to gather from it. + if (segment.length !== 1) { + const source = rootSources[segment[1]]; + traced = originalPositionFor(source, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : ''); + // If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a + // respective segment into an original source. + if (traced == null) + continue; + } + const { column, line, name, content, source } = traced; + genMapping.maybeAddSegment(gen, i, genCol, source, line, column, name); + if (source && content != null) + genMapping.setSourceContent(gen, source, content); + } + } + return gen; + } + /** + * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own + * child SourceMapTrees, until we find the original source map. + */ + function originalPositionFor(source, line, column, name) { + if (!source.map) { + return SegmentObject(source.source, line, column, name, source.content); + } + const segment = traceMapping.traceSegment(source.map, line, column); + // If we couldn't find a segment, then this doesn't exist in the sourcemap. + if (segment == null) + return null; + // 1-length segments only move the current generated column, there's no source information + // to gather from it. + if (segment.length === 1) + return SOURCELESS_MAPPING; + return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name); + } + + function asArray(value) { + if (Array.isArray(value)) + return value; + return [value]; + } + /** + * Recursively builds a tree structure out of sourcemap files, with each node + * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of + * `OriginalSource`s and `SourceMapTree`s. + * + * Every sourcemap is composed of a collection of source files and mappings + * into locations of those source files. When we generate a `SourceMapTree` for + * the sourcemap, we attempt to load each source file's own sourcemap. If it + * does not have an associated sourcemap, it is considered an original, + * unmodified source file. + */ + function buildSourceMapTree(input, loader) { + const maps = asArray(input).map((m) => new traceMapping.TraceMap(m, '')); + const map = maps.pop(); + for (let i = 0; i < maps.length; i++) { + if (maps[i].sources.length > 1) { + throw new Error(`Transformation map ${i} must have exactly one source file.\n` + + 'Did you specify these with the most recent transformation maps first?'); + } + } + let tree = build(map, loader, '', 0); + for (let i = maps.length - 1; i >= 0; i--) { + tree = MapSource(maps[i], [tree]); + } + return tree; + } + function build(map, loader, importer, importerDepth) { + const { resolvedSources, sourcesContent } = map; + const depth = importerDepth + 1; + const children = resolvedSources.map((sourceFile, i) => { + // The loading context gives the loader more information about why this file is being loaded + // (eg, from which importer). It also allows the loader to override the location of the loaded + // sourcemap/original source, or to override the content in the sourcesContent field if it's + // an unmodified source file. + const ctx = { + importer, + depth, + source: sourceFile || '', + content: undefined, + }; + // Use the provided loader callback to retrieve the file's sourcemap. + // TODO: We should eventually support async loading of sourcemap files. + const sourceMap = loader(ctx.source, ctx); + const { source, content } = ctx; + // If there is a sourcemap, then we need to recurse into it to load its source files. + if (sourceMap) + return build(new traceMapping.TraceMap(sourceMap, source), loader, source, depth); + // Else, it's an an unmodified source file. + // The contents of this unmodified source file can be overridden via the loader context, + // allowing it to be explicitly null or a string. If it remains undefined, we fall back to + // the importing sourcemap's `sourcesContent` field. + const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null; + return OriginalSource(source, sourceContent); + }); + return MapSource(map, children); + } + + /** + * A SourceMap v3 compatible sourcemap, which only includes fields that were + * provided to it. + */ + class SourceMap { + constructor(map, options) { + const out = options.decodedMappings ? genMapping.toDecodedMap(map) : genMapping.toEncodedMap(map); + this.version = out.version; // SourceMap spec says this should be first. + this.file = out.file; + this.mappings = out.mappings; + this.names = out.names; + this.sourceRoot = out.sourceRoot; + this.sources = out.sources; + if (!options.excludeContent) { + this.sourcesContent = out.sourcesContent; + } + } + toString() { + return JSON.stringify(this); + } + } + + /** + * Traces through all the mappings in the root sourcemap, through the sources + * (and their sourcemaps), all the way back to the original source location. + * + * `loader` will be called every time we encounter a source file. If it returns + * a sourcemap, we will recurse into that sourcemap to continue the trace. If + * it returns a falsey value, that source file is treated as an original, + * unmodified source file. + * + * Pass `excludeContent` to exclude any self-containing source file content + * from the output sourcemap. + * + * Pass `decodedMappings` to receive a SourceMap with decoded (instead of + * VLQ encoded) mappings. + */ + function remapping(input, loader, options) { + const opts = typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false }; + const tree = buildSourceMapTree(input, loader); + return new SourceMap(traceMappings(tree), opts); + } + + return remapping; + +})); +//# sourceMappingURL=remapping.umd.js.map diff --git a/node_modules/@ampproject/remapping/dist/remapping.umd.js.map b/node_modules/@ampproject/remapping/dist/remapping.umd.js.map new file mode 100644 index 000000000..9c898880b --- /dev/null +++ b/node_modules/@ampproject/remapping/dist/remapping.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"remapping.umd.js","sources":["../src/source-map-tree.ts","../src/build-source-map-tree.ts","../src/source-map.ts","../src/remapping.ts"],"sourcesContent":["import { GenMapping, maybeAddSegment, setSourceContent } from '@jridgewell/gen-mapping';\nimport { traceSegment, decodedMappings } from '@jridgewell/trace-mapping';\n\nimport type { TraceMap } from '@jridgewell/trace-mapping';\n\nexport type SourceMapSegmentObject = {\n column: number;\n line: number;\n name: string;\n source: string;\n content: string | null;\n};\n\nexport type OriginalSource = {\n map: null;\n sources: Sources[];\n source: string;\n content: string | null;\n};\n\nexport type MapSource = {\n map: TraceMap;\n sources: Sources[];\n source: string;\n content: null;\n};\n\nexport type Sources = OriginalSource | MapSource;\n\nconst SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null);\nconst EMPTY_SOURCES: Sources[] = [];\n\nfunction SegmentObject(\n source: string,\n line: number,\n column: number,\n name: string,\n content: string | null\n): SourceMapSegmentObject {\n return { source, line, column, name, content };\n}\n\nfunction Source(map: TraceMap, sources: Sources[], source: '', content: null): MapSource;\nfunction Source(\n map: null,\n sources: Sources[],\n source: string,\n content: string | null\n): OriginalSource;\nfunction Source(\n map: TraceMap | null,\n sources: Sources[],\n source: string | '',\n content: string | null\n): Sources {\n return {\n map,\n sources,\n source,\n content,\n } as any;\n}\n\n/**\n * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes\n * (which may themselves be SourceMapTrees).\n */\nexport function MapSource(map: TraceMap, sources: Sources[]): MapSource {\n return Source(map, sources, '', null);\n}\n\n/**\n * A \"leaf\" node in the sourcemap tree, representing an original, unmodified source file. Recursive\n * segment tracing ends at the `OriginalSource`.\n */\nexport function OriginalSource(source: string, content: string | null): OriginalSource {\n return Source(null, EMPTY_SOURCES, source, content);\n}\n\n/**\n * traceMappings is only called on the root level SourceMapTree, and begins the process of\n * resolving each mapping in terms of the original source files.\n */\nexport function traceMappings(tree: MapSource): GenMapping {\n // TODO: Eventually support sourceRoot, which has to be removed because the sources are already\n // fully resolved. We'll need to make sources relative to the sourceRoot before adding them.\n const gen = new GenMapping({ file: tree.map.file });\n const { sources: rootSources, map } = tree;\n const rootNames = map.names;\n const rootMappings = decodedMappings(map);\n\n for (let i = 0; i < rootMappings.length; i++) {\n const segments = rootMappings[i];\n\n for (let j = 0; j < segments.length; j++) {\n const segment = segments[j];\n const genCol = segment[0];\n let traced: SourceMapSegmentObject | null = SOURCELESS_MAPPING;\n\n // 1-length segments only move the current generated column, there's no source information\n // to gather from it.\n if (segment.length !== 1) {\n const source = rootSources[segment[1]];\n traced = originalPositionFor(\n source,\n segment[2],\n segment[3],\n segment.length === 5 ? rootNames[segment[4]] : ''\n );\n\n // If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a\n // respective segment into an original source.\n if (traced == null) continue;\n }\n\n const { column, line, name, content, source } = traced;\n\n maybeAddSegment(gen, i, genCol, source, line, column, name);\n if (source && content != null) setSourceContent(gen, source, content);\n }\n }\n\n return gen;\n}\n\n/**\n * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own\n * child SourceMapTrees, until we find the original source map.\n */\nexport function originalPositionFor(\n source: Sources,\n line: number,\n column: number,\n name: string\n): SourceMapSegmentObject | null {\n if (!source.map) {\n return SegmentObject(source.source, line, column, name, source.content);\n }\n\n const segment = traceSegment(source.map, line, column);\n\n // If we couldn't find a segment, then this doesn't exist in the sourcemap.\n if (segment == null) return null;\n // 1-length segments only move the current generated column, there's no source information\n // to gather from it.\n if (segment.length === 1) return SOURCELESS_MAPPING;\n\n return originalPositionFor(\n source.sources[segment[1]],\n segment[2],\n segment[3],\n segment.length === 5 ? source.map.names[segment[4]] : name\n );\n}\n","import { TraceMap } from '@jridgewell/trace-mapping';\n\nimport { OriginalSource, MapSource } from './source-map-tree';\n\nimport type { Sources, MapSource as MapSourceType } from './source-map-tree';\nimport type { SourceMapInput, SourceMapLoader, LoaderContext } from './types';\n\nfunction asArray(value: T | T[]): T[] {\n if (Array.isArray(value)) return value;\n return [value];\n}\n\n/**\n * Recursively builds a tree structure out of sourcemap files, with each node\n * being either an `OriginalSource` \"leaf\" or a `SourceMapTree` composed of\n * `OriginalSource`s and `SourceMapTree`s.\n *\n * Every sourcemap is composed of a collection of source files and mappings\n * into locations of those source files. When we generate a `SourceMapTree` for\n * the sourcemap, we attempt to load each source file's own sourcemap. If it\n * does not have an associated sourcemap, it is considered an original,\n * unmodified source file.\n */\nexport default function buildSourceMapTree(\n input: SourceMapInput | SourceMapInput[],\n loader: SourceMapLoader\n): MapSourceType {\n const maps = asArray(input).map((m) => new TraceMap(m, ''));\n const map = maps.pop()!;\n\n for (let i = 0; i < maps.length; i++) {\n if (maps[i].sources.length > 1) {\n throw new Error(\n `Transformation map ${i} must have exactly one source file.\\n` +\n 'Did you specify these with the most recent transformation maps first?'\n );\n }\n }\n\n let tree = build(map, loader, '', 0);\n for (let i = maps.length - 1; i >= 0; i--) {\n tree = MapSource(maps[i], [tree]);\n }\n return tree;\n}\n\nfunction build(\n map: TraceMap,\n loader: SourceMapLoader,\n importer: string,\n importerDepth: number\n): MapSourceType {\n const { resolvedSources, sourcesContent } = map;\n\n const depth = importerDepth + 1;\n const children = resolvedSources.map((sourceFile: string | null, i: number): Sources => {\n // The loading context gives the loader more information about why this file is being loaded\n // (eg, from which importer). It also allows the loader to override the location of the loaded\n // sourcemap/original source, or to override the content in the sourcesContent field if it's\n // an unmodified source file.\n const ctx: LoaderContext = {\n importer,\n depth,\n source: sourceFile || '',\n content: undefined,\n };\n\n // Use the provided loader callback to retrieve the file's sourcemap.\n // TODO: We should eventually support async loading of sourcemap files.\n const sourceMap = loader(ctx.source, ctx);\n\n const { source, content } = ctx;\n\n // If there is a sourcemap, then we need to recurse into it to load its source files.\n if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth);\n\n // Else, it's an an unmodified source file.\n // The contents of this unmodified source file can be overridden via the loader context,\n // allowing it to be explicitly null or a string. If it remains undefined, we fall back to\n // the importing sourcemap's `sourcesContent` field.\n const sourceContent =\n content !== undefined ? content : sourcesContent ? sourcesContent[i] : null;\n return OriginalSource(source, sourceContent);\n });\n\n return MapSource(map, children);\n}\n","import { toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping';\n\nimport type { GenMapping } from '@jridgewell/gen-mapping';\nimport type { DecodedSourceMap, EncodedSourceMap, Options } from './types';\n\n/**\n * A SourceMap v3 compatible sourcemap, which only includes fields that were\n * provided to it.\n */\nexport default class SourceMap {\n declare file?: string | null;\n declare mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings'];\n declare sourceRoot?: string;\n declare names: string[];\n declare sources: (string | null)[];\n declare sourcesContent?: (string | null)[];\n declare version: 3;\n\n constructor(map: GenMapping, options: Options) {\n const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);\n this.version = out.version; // SourceMap spec says this should be first.\n this.file = out.file;\n this.mappings = out.mappings as SourceMap['mappings'];\n this.names = out.names as SourceMap['names'];\n\n this.sourceRoot = out.sourceRoot;\n\n this.sources = out.sources as SourceMap['sources'];\n if (!options.excludeContent) {\n this.sourcesContent = out.sourcesContent as SourceMap['sourcesContent'];\n }\n }\n\n toString(): string {\n return JSON.stringify(this);\n }\n}\n","import buildSourceMapTree from './build-source-map-tree';\nimport { traceMappings } from './source-map-tree';\nimport SourceMap from './source-map';\n\nimport type { SourceMapInput, SourceMapLoader, Options } from './types';\nexport type {\n SourceMapSegment,\n EncodedSourceMap,\n EncodedSourceMap as RawSourceMap,\n DecodedSourceMap,\n SourceMapInput,\n SourceMapLoader,\n LoaderContext,\n Options,\n} from './types';\n\n/**\n * Traces through all the mappings in the root sourcemap, through the sources\n * (and their sourcemaps), all the way back to the original source location.\n *\n * `loader` will be called every time we encounter a source file. If it returns\n * a sourcemap, we will recurse into that sourcemap to continue the trace. If\n * it returns a falsey value, that source file is treated as an original,\n * unmodified source file.\n *\n * Pass `excludeContent` to exclude any self-containing source file content\n * from the output sourcemap.\n *\n * Pass `decodedMappings` to receive a SourceMap with decoded (instead of\n * VLQ encoded) mappings.\n */\nexport default function remapping(\n input: SourceMapInput | SourceMapInput[],\n loader: SourceMapLoader,\n options?: boolean | Options\n): SourceMap {\n const opts =\n typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false };\n const tree = buildSourceMapTree(input, loader);\n return new SourceMap(traceMappings(tree), opts);\n}\n"],"names":["GenMapping","decodedMappings","maybeAddSegment","setSourceContent","traceSegment","TraceMap","toDecodedMap","toEncodedMap"],"mappings":";;;;;;IA6BA,MAAM,kBAAkB,mBAAmB,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC/E,MAAM,aAAa,GAAc,EAAE,CAAC;IAEpC,SAAS,aAAa,CACpB,MAAc,EACd,IAAY,EACZ,MAAc,EACd,IAAY,EACZ,OAAsB,EAAA;QAEtB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACjD,CAAC;IASD,SAAS,MAAM,CACb,GAAoB,EACpB,OAAkB,EAClB,MAAmB,EACnB,OAAsB,EAAA;QAEtB,OAAO;YACL,GAAG;YACH,OAAO;YACP,MAAM;YACN,OAAO;SACD,CAAC;IACX,CAAC;IAED;;;IAGG;IACa,SAAA,SAAS,CAAC,GAAa,EAAE,OAAkB,EAAA;QACzD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;IAED;;;IAGG;IACa,SAAA,cAAc,CAAC,MAAc,EAAE,OAAsB,EAAA;QACnE,OAAO,MAAM,CAAC,IAAI,EA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CAAC,QAAiC,CAAC;IACtD,QAAA,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAA2B,CAAC;IAE7C,QAAA,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAEjC,QAAA,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAA+B,CAAC;IACnD,QAAA,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;IAC3B,YAAA,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,cAA6C,CAAC;IACzE,SAAA;SACF;QAED,QAAQ,GAAA;IACN,QAAA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC7B;IACF;;ICpBD;;;;;;;;;;;;;;IAcG;IACqB,SAAA,SAAS,CAC/B,KAAwC,EACxC,MAAuB,EACvB,OAA2B,EAAA;QAE3B,MAAM,IAAI,GACR,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAChG,MAAM,IAAI,GAAG,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAClD;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/@ampproject/remapping/dist/types/build-source-map-tree.d.ts b/node_modules/@ampproject/remapping/dist/types/build-source-map-tree.d.ts new file mode 100644 index 000000000..f87fceab7 --- /dev/null +++ b/node_modules/@ampproject/remapping/dist/types/build-source-map-tree.d.ts @@ -0,0 +1,14 @@ +import type { MapSource as MapSourceType } from './source-map-tree'; +import type { SourceMapInput, SourceMapLoader } from './types'; +/** + * Recursively builds a tree structure out of sourcemap files, with each node + * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of + * `OriginalSource`s and `SourceMapTree`s. + * + * Every sourcemap is composed of a collection of source files and mappings + * into locations of those source files. When we generate a `SourceMapTree` for + * the sourcemap, we attempt to load each source file's own sourcemap. If it + * does not have an associated sourcemap, it is considered an original, + * unmodified source file. + */ +export default function buildSourceMapTree(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader): MapSourceType; diff --git a/node_modules/@ampproject/remapping/dist/types/remapping.d.ts b/node_modules/@ampproject/remapping/dist/types/remapping.d.ts new file mode 100644 index 000000000..0b58ea9ae --- /dev/null +++ b/node_modules/@ampproject/remapping/dist/types/remapping.d.ts @@ -0,0 +1,19 @@ +import SourceMap from './source-map'; +import type { SourceMapInput, SourceMapLoader, Options } from './types'; +export type { SourceMapSegment, EncodedSourceMap, EncodedSourceMap as RawSourceMap, DecodedSourceMap, SourceMapInput, SourceMapLoader, LoaderContext, Options, } from './types'; +/** + * Traces through all the mappings in the root sourcemap, through the sources + * (and their sourcemaps), all the way back to the original source location. + * + * `loader` will be called every time we encounter a source file. If it returns + * a sourcemap, we will recurse into that sourcemap to continue the trace. If + * it returns a falsey value, that source file is treated as an original, + * unmodified source file. + * + * Pass `excludeContent` to exclude any self-containing source file content + * from the output sourcemap. + * + * Pass `decodedMappings` to receive a SourceMap with decoded (instead of + * VLQ encoded) mappings. + */ +export default function remapping(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader, options?: boolean | Options): SourceMap; diff --git a/node_modules/@ampproject/remapping/dist/types/source-map-tree.d.ts b/node_modules/@ampproject/remapping/dist/types/source-map-tree.d.ts new file mode 100644 index 000000000..3a9f7af65 --- /dev/null +++ b/node_modules/@ampproject/remapping/dist/types/source-map-tree.d.ts @@ -0,0 +1,42 @@ +import { GenMapping } from '@jridgewell/gen-mapping'; +import type { TraceMap } from '@jridgewell/trace-mapping'; +export declare type SourceMapSegmentObject = { + column: number; + line: number; + name: string; + source: string; + content: string | null; +}; +export declare type OriginalSource = { + map: null; + sources: Sources[]; + source: string; + content: string | null; +}; +export declare type MapSource = { + map: TraceMap; + sources: Sources[]; + source: string; + content: null; +}; +export declare type Sources = OriginalSource | MapSource; +/** + * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes + * (which may themselves be SourceMapTrees). + */ +export declare function MapSource(map: TraceMap, sources: Sources[]): MapSource; +/** + * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive + * segment tracing ends at the `OriginalSource`. + */ +export declare function OriginalSource(source: string, content: string | null): OriginalSource; +/** + * traceMappings is only called on the root level SourceMapTree, and begins the process of + * resolving each mapping in terms of the original source files. + */ +export declare function traceMappings(tree: MapSource): GenMapping; +/** + * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own + * child SourceMapTrees, until we find the original source map. + */ +export declare function originalPositionFor(source: Sources, line: number, column: number, name: string): SourceMapSegmentObject | null; diff --git a/node_modules/@ampproject/remapping/dist/types/source-map.d.ts b/node_modules/@ampproject/remapping/dist/types/source-map.d.ts new file mode 100644 index 000000000..ef999b757 --- /dev/null +++ b/node_modules/@ampproject/remapping/dist/types/source-map.d.ts @@ -0,0 +1,17 @@ +import type { GenMapping } from '@jridgewell/gen-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Options } from './types'; +/** + * A SourceMap v3 compatible sourcemap, which only includes fields that were + * provided to it. + */ +export default class SourceMap { + file?: string | null; + mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings']; + sourceRoot?: string; + names: string[]; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; + constructor(map: GenMapping, options: Options); + toString(): string; +} diff --git a/node_modules/@ampproject/remapping/dist/types/types.d.ts b/node_modules/@ampproject/remapping/dist/types/types.d.ts new file mode 100644 index 000000000..730a9637e --- /dev/null +++ b/node_modules/@ampproject/remapping/dist/types/types.d.ts @@ -0,0 +1,14 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +export type { SourceMapSegment, DecodedSourceMap, EncodedSourceMap, } from '@jridgewell/trace-mapping'; +export type { SourceMapInput }; +export declare type LoaderContext = { + readonly importer: string; + readonly depth: number; + source: string; + content: string | null | undefined; +}; +export declare type SourceMapLoader = (file: string, ctx: LoaderContext) => SourceMapInput | null | undefined | void; +export declare type Options = { + excludeContent?: boolean; + decodedMappings?: boolean; +}; diff --git a/node_modules/@ampproject/remapping/package.json b/node_modules/@ampproject/remapping/package.json new file mode 100644 index 000000000..bf3dad29b --- /dev/null +++ b/node_modules/@ampproject/remapping/package.json @@ -0,0 +1,75 @@ +{ + "name": "@ampproject/remapping", + "version": "2.2.1", + "description": "Remap sequential sourcemaps through transformations to point at the original source code", + "keywords": [ + "source", + "map", + "remap" + ], + "main": "dist/remapping.umd.js", + "module": "dist/remapping.mjs", + "types": "dist/types/remapping.d.ts", + "exports": { + ".": [ + { + "types": "./dist/types/remapping.d.ts", + "browser": "./dist/remapping.umd.js", + "require": "./dist/remapping.umd.js", + "import": "./dist/remapping.mjs" + }, + "./dist/remapping.umd.js" + ], + "./package.json": "./package.json" + }, + "files": [ + "dist" + ], + "author": "Justin Ridgewell ", + "repository": { + "type": "git", + "url": "git+https://github.com/ampproject/remapping.git" + }, + "license": "Apache-2.0", + "engines": { + "node": ">=6.0.0" + }, + "scripts": { + "build": "run-s -n build:*", + "build:rollup": "rollup -c rollup.config.js", + "build:ts": "tsc --project tsconfig.build.json", + "lint": "run-s -n lint:*", + "lint:prettier": "npm run test:lint:prettier -- --write", + "lint:ts": "npm run test:lint:ts -- --fix", + "prebuild": "rm -rf dist", + "prepublishOnly": "npm run preversion", + "preversion": "run-s test build", + "test": "run-s -n test:lint test:only", + "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand", + "test:lint": "run-s -n test:lint:*", + "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", + "test:lint:ts": "eslint '{src,test}/**/*.ts'", + "test:only": "jest --coverage", + "test:watch": "jest --coverage --watch" + }, + "devDependencies": { + "@rollup/plugin-typescript": "8.3.2", + "@types/jest": "27.4.1", + "@typescript-eslint/eslint-plugin": "5.20.0", + "@typescript-eslint/parser": "5.20.0", + "eslint": "8.14.0", + "eslint-config-prettier": "8.5.0", + "jest": "27.5.1", + "jest-config": "27.5.1", + "npm-run-all": "4.1.5", + "prettier": "2.6.2", + "rollup": "2.70.2", + "ts-jest": "27.1.4", + "tslib": "2.4.0", + "typescript": "4.6.3" + }, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } +} diff --git a/node_modules/@esbuild/darwin-x64/README.md b/node_modules/@esbuild/darwin-x64/README.md new file mode 100644 index 000000000..a2fd0cbee --- /dev/null +++ b/node_modules/@esbuild/darwin-x64/README.md @@ -0,0 +1,3 @@ +# esbuild + +This is the macOS 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details. diff --git a/node_modules/@esbuild/darwin-x64/bin/esbuild b/node_modules/@esbuild/darwin-x64/bin/esbuild new file mode 100755 index 000000000..b2fd6cf19 Binary files /dev/null and b/node_modules/@esbuild/darwin-x64/bin/esbuild differ diff --git a/node_modules/@esbuild/darwin-x64/package.json b/node_modules/@esbuild/darwin-x64/package.json new file mode 100644 index 000000000..a622e0b4b --- /dev/null +++ b/node_modules/@esbuild/darwin-x64/package.json @@ -0,0 +1,17 @@ +{ + "name": "@esbuild/darwin-x64", + "version": "0.19.10", + "description": "The macOS 64-bit binary for esbuild, a JavaScript bundler.", + "repository": "https://github.com/evanw/esbuild", + "license": "MIT", + "preferUnplugged": true, + "engines": { + "node": ">=12" + }, + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ] +} diff --git a/node_modules/@esbuild/win32-x64/README.md b/node_modules/@esbuild/win32-x64/README.md new file mode 100644 index 000000000..a99ee7cf8 --- /dev/null +++ b/node_modules/@esbuild/win32-x64/README.md @@ -0,0 +1,3 @@ +# esbuild + +This is the Windows 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details. diff --git a/node_modules/@esbuild/win32-x64/esbuild.exe b/node_modules/@esbuild/win32-x64/esbuild.exe new file mode 100644 index 000000000..ee9e06417 Binary files /dev/null and b/node_modules/@esbuild/win32-x64/esbuild.exe differ diff --git a/node_modules/@esbuild/win32-x64/package.json b/node_modules/@esbuild/win32-x64/package.json new file mode 100644 index 000000000..2d73698de --- /dev/null +++ b/node_modules/@esbuild/win32-x64/package.json @@ -0,0 +1,17 @@ +{ + "name": "@esbuild/win32-x64", + "version": "0.19.10", + "description": "The Windows 64-bit binary for esbuild, a JavaScript bundler.", + "repository": "https://github.com/evanw/esbuild", + "license": "MIT", + "preferUnplugged": true, + "engines": { + "node": ">=12" + }, + "os": [ + "win32" + ], + "cpu": [ + "x64" + ] +} diff --git a/node_modules/@graphql-typed-document-node/core/LICENSE b/node_modules/@graphql-typed-document-node/core/LICENSE new file mode 100644 index 000000000..1e90edd3e --- /dev/null +++ b/node_modules/@graphql-typed-document-node/core/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2020-2023 Dotan Simha + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@graphql-typed-document-node/core/package.json b/node_modules/@graphql-typed-document-node/core/package.json new file mode 100644 index 000000000..c8d2e688c --- /dev/null +++ b/node_modules/@graphql-typed-document-node/core/package.json @@ -0,0 +1,15 @@ +{ + "name": "@graphql-typed-document-node/core", + "version": "3.2.0", + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + }, + "repository": "git@github.com:dotansimha/graphql-typed-document-node.git", + "author": "Dotan Simha ", + "license": "MIT", + "main": "", + "typings": "typings/index.d.ts", + "typescript": { + "definition": "typings/index.d.ts" + } +} \ No newline at end of file diff --git a/node_modules/@graphql-typed-document-node/core/typings/index.d.ts b/node_modules/@graphql-typed-document-node/core/typings/index.d.ts new file mode 100644 index 000000000..ac98637a1 --- /dev/null +++ b/node_modules/@graphql-typed-document-node/core/typings/index.d.ts @@ -0,0 +1,29 @@ +import type { DocumentNode } from "graphql"; +export interface DocumentTypeDecoration { + /** + * This type is used to ensure that the variables you pass in to the query are assignable to Variables + * and that the Result is assignable to whatever you pass your result to. The method is never actually + * implemented, but the type is valid because we list it as optional + */ + __apiType?: (variables: TVariables) => TResult; +} +export interface TypedDocumentNode extends DocumentNode, DocumentTypeDecoration { +} +/** + * Helper for extracting a TypeScript type for operation result from a TypedDocumentNode and TypedDocumentString. + * @example + * const myQuery = { ... }; // TypedDocumentNode + * type ResultType = ResultOf; // Now it's R + */ +export type ResultOf = T extends DocumentTypeDecoration ? ResultType : never; +/** + * Helper for extracting a TypeScript type for operation variables from a TypedDocumentNode and TypedDocumentString. + * @example + * const myQuery = { ... }; // TypedDocumentNode + * type VariablesType = VariablesOf; // Now it's V + */ +export type VariablesOf = T extends DocumentTypeDecoration ? VariablesType : never; diff --git a/node_modules/@jridgewell/gen-mapping/LICENSE b/node_modules/@jridgewell/gen-mapping/LICENSE new file mode 100644 index 000000000..352f0715f --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/gen-mapping/README.md b/node_modules/@jridgewell/gen-mapping/README.md new file mode 100644 index 000000000..4066cdbbd --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/README.md @@ -0,0 +1,227 @@ +# @jridgewell/gen-mapping + +> Generate source maps + +`gen-mapping` allows you to generate a source map during transpilation or minification. +With a source map, you're able to trace the original location in the source file, either in Chrome's +DevTools or using a library like [`@jridgewell/trace-mapping`][trace-mapping]. + +You may already be familiar with the [`source-map`][source-map] package's `SourceMapGenerator`. This +provides the same `addMapping` and `setSourceContent` API. + +## Installation + +```sh +npm install @jridgewell/gen-mapping +``` + +## Usage + +```typescript +import { GenMapping, addMapping, setSourceContent, toEncodedMap, toDecodedMap } from '@jridgewell/gen-mapping'; + +const map = new GenMapping({ + file: 'output.js', + sourceRoot: 'https://example.com/', +}); + +setSourceContent(map, 'input.js', `function foo() {}`); + +addMapping(map, { + // Lines start at line 1, columns at column 0. + generated: { line: 1, column: 0 }, + source: 'input.js', + original: { line: 1, column: 0 }, +}); + +addMapping(map, { + generated: { line: 1, column: 9 }, + source: 'input.js', + original: { line: 1, column: 9 }, + name: 'foo', +}); + +assert.deepEqual(toDecodedMap(map), { + version: 3, + file: 'output.js', + names: ['foo'], + sourceRoot: 'https://example.com/', + sources: ['input.js'], + sourcesContent: ['function foo() {}'], + mappings: [ + [ [0, 0, 0, 0], [9, 0, 0, 9, 0] ] + ], +}); + +assert.deepEqual(toEncodedMap(map), { + version: 3, + file: 'output.js', + names: ['foo'], + sourceRoot: 'https://example.com/', + sources: ['input.js'], + sourcesContent: ['function foo() {}'], + mappings: 'AAAA,SAASA', +}); +``` + +### Smaller Sourcemaps + +Not everything needs to be added to a sourcemap, and needless markings can cause signficantly +larger file sizes. `gen-mapping` exposes `maybeAddSegment`/`maybeAddMapping` APIs that will +intelligently determine if this marking adds useful information. If not, the marking will be +skipped. + +```typescript +import { maybeAddMapping } from '@jridgewell/gen-mapping'; + +const map = new GenMapping(); + +// Adding a sourceless marking at the beginning of a line isn't useful. +maybeAddMapping(map, { + generated: { line: 1, column: 0 }, +}); + +// Adding a new source marking is useful. +maybeAddMapping(map, { + generated: { line: 1, column: 0 }, + source: 'input.js', + original: { line: 1, column: 0 }, +}); + +// But adding another marking pointing to the exact same original location isn't, even if the +// generated column changed. +maybeAddMapping(map, { + generated: { line: 1, column: 9 }, + source: 'input.js', + original: { line: 1, column: 0 }, +}); + +assert.deepEqual(toEncodedMap(map), { + version: 3, + names: [], + sources: ['input.js'], + sourcesContent: [null], + mappings: 'AAAA', +}); +``` + +## Benchmarks + +``` +node v18.0.0 + +amp.js.map +Memory Usage: +gen-mapping: addSegment 5852872 bytes +gen-mapping: addMapping 7716042 bytes +source-map-js 6143250 bytes +source-map-0.6.1 6124102 bytes +source-map-0.8.0 6121173 bytes +Smallest memory usage is gen-mapping: addSegment + +Adding speed: +gen-mapping: addSegment x 441 ops/sec ±2.07% (90 runs sampled) +gen-mapping: addMapping x 350 ops/sec ±2.40% (86 runs sampled) +source-map-js: addMapping x 169 ops/sec ±2.42% (80 runs sampled) +source-map-0.6.1: addMapping x 167 ops/sec ±2.56% (80 runs sampled) +source-map-0.8.0: addMapping x 168 ops/sec ±2.52% (80 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 150,824,370 ops/sec ±0.07% (102 runs sampled) +gen-mapping: encoded output x 663 ops/sec ±0.22% (98 runs sampled) +source-map-js: encoded output x 197 ops/sec ±0.45% (84 runs sampled) +source-map-0.6.1: encoded output x 198 ops/sec ±0.33% (85 runs sampled) +source-map-0.8.0: encoded output x 197 ops/sec ±0.06% (93 runs sampled) +Fastest is gen-mapping: decoded output + + +*** + + +babel.min.js.map +Memory Usage: +gen-mapping: addSegment 37578063 bytes +gen-mapping: addMapping 37212897 bytes +source-map-js 47638527 bytes +source-map-0.6.1 47690503 bytes +source-map-0.8.0 47470188 bytes +Smallest memory usage is gen-mapping: addMapping + +Adding speed: +gen-mapping: addSegment x 31.05 ops/sec ±8.31% (43 runs sampled) +gen-mapping: addMapping x 29.83 ops/sec ±7.36% (51 runs sampled) +source-map-js: addMapping x 20.73 ops/sec ±6.22% (38 runs sampled) +source-map-0.6.1: addMapping x 20.03 ops/sec ±10.51% (38 runs sampled) +source-map-0.8.0: addMapping x 19.30 ops/sec ±8.27% (37 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 381,379,234 ops/sec ±0.29% (96 runs sampled) +gen-mapping: encoded output x 95.15 ops/sec ±2.98% (72 runs sampled) +source-map-js: encoded output x 15.20 ops/sec ±7.41% (33 runs sampled) +source-map-0.6.1: encoded output x 16.36 ops/sec ±10.46% (31 runs sampled) +source-map-0.8.0: encoded output x 16.06 ops/sec ±6.45% (31 runs sampled) +Fastest is gen-mapping: decoded output + + +*** + + +preact.js.map +Memory Usage: +gen-mapping: addSegment 416247 bytes +gen-mapping: addMapping 419824 bytes +source-map-js 1024619 bytes +source-map-0.6.1 1146004 bytes +source-map-0.8.0 1113250 bytes +Smallest memory usage is gen-mapping: addSegment + +Adding speed: +gen-mapping: addSegment x 13,755 ops/sec ±0.15% (98 runs sampled) +gen-mapping: addMapping x 13,013 ops/sec ±0.11% (101 runs sampled) +source-map-js: addMapping x 4,564 ops/sec ±0.21% (98 runs sampled) +source-map-0.6.1: addMapping x 4,562 ops/sec ±0.11% (99 runs sampled) +source-map-0.8.0: addMapping x 4,593 ops/sec ±0.11% (100 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 379,864,020 ops/sec ±0.23% (93 runs sampled) +gen-mapping: encoded output x 14,368 ops/sec ±4.07% (82 runs sampled) +source-map-js: encoded output x 5,261 ops/sec ±0.21% (99 runs sampled) +source-map-0.6.1: encoded output x 5,124 ops/sec ±0.58% (99 runs sampled) +source-map-0.8.0: encoded output x 5,434 ops/sec ±0.33% (96 runs sampled) +Fastest is gen-mapping: decoded output + + +*** + + +react.js.map +Memory Usage: +gen-mapping: addSegment 975096 bytes +gen-mapping: addMapping 1102981 bytes +source-map-js 2918836 bytes +source-map-0.6.1 2885435 bytes +source-map-0.8.0 2874336 bytes +Smallest memory usage is gen-mapping: addSegment + +Adding speed: +gen-mapping: addSegment x 4,772 ops/sec ±0.15% (100 runs sampled) +gen-mapping: addMapping x 4,456 ops/sec ±0.13% (97 runs sampled) +source-map-js: addMapping x 1,618 ops/sec ±0.24% (97 runs sampled) +source-map-0.6.1: addMapping x 1,622 ops/sec ±0.12% (99 runs sampled) +source-map-0.8.0: addMapping x 1,631 ops/sec ±0.12% (100 runs sampled) +Fastest is gen-mapping: addSegment + +Generate speed: +gen-mapping: decoded output x 379,107,695 ops/sec ±0.07% (99 runs sampled) +gen-mapping: encoded output x 5,421 ops/sec ±1.60% (89 runs sampled) +source-map-js: encoded output x 2,113 ops/sec ±1.81% (98 runs sampled) +source-map-0.6.1: encoded output x 2,126 ops/sec ±0.10% (100 runs sampled) +source-map-0.8.0: encoded output x 2,176 ops/sec ±0.39% (98 runs sampled) +Fastest is gen-mapping: decoded output +``` + +[source-map]: https://www.npmjs.com/package/source-map +[trace-mapping]: https://github.com/jridgewell/trace-mapping diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs new file mode 100644 index 000000000..5aeb5ccc9 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs @@ -0,0 +1,230 @@ +import { SetArray, put } from '@jridgewell/set-array'; +import { encode } from '@jridgewell/sourcemap-codec'; +import { TraceMap, decodedMappings } from '@jridgewell/trace-mapping'; + +const COLUMN = 0; +const SOURCES_INDEX = 1; +const SOURCE_LINE = 2; +const SOURCE_COLUMN = 3; +const NAMES_INDEX = 4; + +const NO_NAME = -1; +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +let addSegment; +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +let addMapping; +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +let maybeAddSegment; +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +let maybeAddMapping; +/** + * Adds/removes the content of the source file to the source map. + */ +let setSourceContent; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +let toDecodedMap; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +let toEncodedMap; +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +let fromMap; +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +let allMappings; +// This split declaration is only so that terser can elminiate the static initialization block. +let addSegmentInternal; +/** + * Provides the state to generate a sourcemap. + */ +class GenMapping { + constructor({ file, sourceRoot } = {}) { + this._names = new SetArray(); + this._sources = new SetArray(); + this._sourcesContent = []; + this._mappings = []; + this.file = file; + this.sourceRoot = sourceRoot; + } +} +(() => { + addSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + return addSegmentInternal(false, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content); + }; + maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content); + }; + addMapping = (map, mapping) => { + return addMappingInternal(false, map, mapping); + }; + maybeAddMapping = (map, mapping) => { + return addMappingInternal(true, map, mapping); + }; + setSourceContent = (map, source, content) => { + const { _sources: sources, _sourcesContent: sourcesContent } = map; + sourcesContent[put(sources, source)] = content; + }; + toDecodedMap = (map) => { + const { file, sourceRoot, _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map; + removeEmptyFinalLines(mappings); + return { + version: 3, + file: file || undefined, + names: names.array, + sourceRoot: sourceRoot || undefined, + sources: sources.array, + sourcesContent, + mappings, + }; + }; + toEncodedMap = (map) => { + const decoded = toDecodedMap(map); + return Object.assign(Object.assign({}, decoded), { mappings: encode(decoded.mappings) }); + }; + allMappings = (map) => { + const out = []; + const { _mappings: mappings, _sources: sources, _names: names } = map; + for (let i = 0; i < mappings.length; i++) { + const line = mappings[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generated = { line: i + 1, column: seg[COLUMN] }; + let source = undefined; + let original = undefined; + let name = undefined; + if (seg.length !== 1) { + source = sources.array[seg[SOURCES_INDEX]]; + original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; + if (seg.length === 5) + name = names.array[seg[NAMES_INDEX]]; + } + out.push({ generated, source, original, name }); + } + } + return out; + }; + fromMap = (input) => { + const map = new TraceMap(input); + const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); + putAll(gen._names, map.names); + putAll(gen._sources, map.sources); + gen._sourcesContent = map.sourcesContent || map.sources.map(() => null); + gen._mappings = decodedMappings(map); + return gen; + }; + // Internal helpers + addSegmentInternal = (skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map; + const line = getLine(mappings, genLine); + const index = getColumnIndex(line, genColumn); + if (!source) { + if (skipable && skipSourceless(line, index)) + return; + return insert(line, index, [genColumn]); + } + const sourcesIndex = put(sources, source); + const namesIndex = name ? put(names, name) : NO_NAME; + if (sourcesIndex === sourcesContent.length) + sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null; + if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { + return; + } + return insert(line, index, name + ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] + : [genColumn, sourcesIndex, sourceLine, sourceColumn]); + }; +})(); +function getLine(mappings, index) { + for (let i = mappings.length; i <= index; i++) { + mappings[i] = []; + } + return mappings[index]; +} +function getColumnIndex(line, genColumn) { + let index = line.length; + for (let i = index - 1; i >= 0; index = i--) { + const current = line[i]; + if (genColumn >= current[COLUMN]) + break; + } + return index; +} +function insert(array, index, value) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; +} +function removeEmptyFinalLines(mappings) { + const { length } = mappings; + let len = length; + for (let i = len - 1; i >= 0; len = i, i--) { + if (mappings[i].length > 0) + break; + } + if (len < length) + mappings.length = len; +} +function putAll(strarr, array) { + for (let i = 0; i < array.length; i++) + put(strarr, array[i]); +} +function skipSourceless(line, index) { + // The start of a line is already sourceless, so adding a sourceless segment to the beginning + // doesn't generate any useful information. + if (index === 0) + return true; + const prev = line[index - 1]; + // If the previous segment is also sourceless, then adding another sourceless segment doesn't + // genrate any new information. Else, this segment will end the source/named segment and point to + // a sourceless position, which is useful. + return prev.length === 1; +} +function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) { + // A source/named segment at the start of a line gives position at that genColumn + if (index === 0) + return false; + const prev = line[index - 1]; + // If the previous segment is sourceless, then we're transitioning to a source. + if (prev.length === 1) + return false; + // If the previous segment maps to the exact same source position, then this segment doesn't + // provide any new position information. + return (sourcesIndex === prev[SOURCES_INDEX] && + sourceLine === prev[SOURCE_LINE] && + sourceColumn === prev[SOURCE_COLUMN] && + namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME)); +} +function addMappingInternal(skipable, map, mapping) { + const { generated, source, original, name, content } = mapping; + if (!source) { + return addSegmentInternal(skipable, map, generated.line - 1, generated.column, null, null, null, null, null); + } + const s = source; + return addSegmentInternal(skipable, map, generated.line - 1, generated.column, s, original.line - 1, original.column, name, content); +} + +export { GenMapping, addMapping, addSegment, allMappings, fromMap, maybeAddMapping, maybeAddSegment, setSourceContent, toDecodedMap, toEncodedMap }; +//# sourceMappingURL=gen-mapping.mjs.map diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map new file mode 100644 index 000000000..2fee0cd4e --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"gen-mapping.mjs","sources":["../src/sourcemap-segment.ts","../src/gen-mapping.ts"],"sourcesContent":["type GeneratedColumn = number;\ntype SourcesIndex = number;\ntype SourceLine = number;\ntype SourceColumn = number;\ntype NamesIndex = number;\n\nexport type SourceMapSegment =\n | [GeneratedColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];\n\nexport const COLUMN = 0;\nexport const SOURCES_INDEX = 1;\nexport const SOURCE_LINE = 2;\nexport const SOURCE_COLUMN = 3;\nexport const NAMES_INDEX = 4;\n","import { SetArray, put } from '@jridgewell/set-array';\nimport { encode } from '@jridgewell/sourcemap-codec';\nimport { TraceMap, decodedMappings } from '@jridgewell/trace-mapping';\n\nimport {\n COLUMN,\n SOURCES_INDEX,\n SOURCE_LINE,\n SOURCE_COLUMN,\n NAMES_INDEX,\n} from './sourcemap-segment';\n\nimport type { SourceMapInput } from '@jridgewell/trace-mapping';\nimport type { SourceMapSegment } from './sourcemap-segment';\nimport type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types';\n\nexport type { DecodedSourceMap, EncodedSourceMap, Mapping };\n\nexport type Options = {\n file?: string | null;\n sourceRoot?: string | null;\n};\n\nconst NO_NAME = -1;\n\n/**\n * A low-level API to associate a generated position with an original source position. Line and\n * column here are 0-based, unlike `addMapping`.\n */\nexport let addSegment: {\n (\n map: GenMapping,\n genLine: number,\n genColumn: number,\n source?: null,\n sourceLine?: null,\n sourceColumn?: null,\n name?: null,\n content?: null,\n ): void;\n (\n map: GenMapping,\n genLine: number,\n genColumn: number,\n source: string,\n sourceLine: number,\n sourceColumn: number,\n name?: null,\n content?: string | null,\n ): void;\n (\n map: GenMapping,\n genLine: number,\n genColumn: number,\n source: string,\n sourceLine: number,\n sourceColumn: number,\n name: string,\n content?: string | null,\n ): void;\n};\n\n/**\n * A high-level API to associate a generated position with an original source position. Line is\n * 1-based, but column is 0-based, due to legacy behavior in `source-map` library.\n */\nexport let addMapping: {\n (\n map: GenMapping,\n mapping: {\n generated: Pos;\n source?: null;\n original?: null;\n name?: null;\n content?: null;\n },\n ): void;\n (\n map: GenMapping,\n mapping: {\n generated: Pos;\n source: string;\n original: Pos;\n name?: null;\n content?: string | null;\n },\n ): void;\n (\n map: GenMapping,\n mapping: {\n generated: Pos;\n source: string;\n original: Pos;\n name: string;\n content?: string | null;\n },\n ): void;\n};\n\n/**\n * Same as `addSegment`, but will only add the segment if it generates useful information in the\n * resulting map. This only works correctly if segments are added **in order**, meaning you should\n * not add a segment with a lower generated line/column than one that came before.\n */\nexport let maybeAddSegment: typeof addSegment;\n\n/**\n * Same as `addMapping`, but will only add the mapping if it generates useful information in the\n * resulting map. This only works correctly if mappings are added **in order**, meaning you should\n * not add a mapping with a lower generated line/column than one that came before.\n */\nexport let maybeAddMapping: typeof addMapping;\n\n/**\n * Adds/removes the content of the source file to the source map.\n */\nexport let setSourceContent: (map: GenMapping, source: string, content: string | null) => void;\n\n/**\n * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport let toDecodedMap: (map: GenMapping) => DecodedSourceMap;\n\n/**\n * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport let toEncodedMap: (map: GenMapping) => EncodedSourceMap;\n\n/**\n * Constructs a new GenMapping, using the already present mappings of the input.\n */\nexport let fromMap: (input: SourceMapInput) => GenMapping;\n\n/**\n * Returns an array of high-level mapping objects for every recorded segment, which could then be\n * passed to the `source-map` library.\n */\nexport let allMappings: (map: GenMapping) => Mapping[];\n\n// This split declaration is only so that terser can elminiate the static initialization block.\nlet addSegmentInternal: (\n skipable: boolean,\n map: GenMapping,\n genLine: number,\n genColumn: number,\n source: S,\n sourceLine: S extends string ? number : null | undefined,\n sourceColumn: S extends string ? number : null | undefined,\n name: S extends string ? string | null | undefined : null | undefined,\n content: S extends string ? string | null | undefined : null | undefined,\n) => void;\n\n/**\n * Provides the state to generate a sourcemap.\n */\nexport class GenMapping {\n private _names = new SetArray();\n private _sources = new SetArray();\n private _sourcesContent: (string | null)[] = [];\n private _mappings: SourceMapSegment[][] = [];\n declare file: string | null | undefined;\n declare sourceRoot: string | null | undefined;\n\n constructor({ file, sourceRoot }: Options = {}) {\n this.file = file;\n this.sourceRoot = sourceRoot;\n }\n\n static {\n addSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {\n return addSegmentInternal(\n false,\n map,\n genLine,\n genColumn,\n source,\n sourceLine,\n sourceColumn,\n name,\n content,\n );\n };\n\n maybeAddSegment = (\n map,\n genLine,\n genColumn,\n source,\n sourceLine,\n sourceColumn,\n name,\n content,\n ) => {\n return addSegmentInternal(\n true,\n map,\n genLine,\n genColumn,\n source,\n sourceLine,\n sourceColumn,\n name,\n content,\n );\n };\n\n addMapping = (map, mapping) => {\n return addMappingInternal(false, map, mapping as Parameters[2]);\n };\n\n maybeAddMapping = (map, mapping) => {\n return addMappingInternal(true, map, mapping as Parameters[2]);\n };\n\n setSourceContent = (map, source, content) => {\n const { _sources: sources, _sourcesContent: sourcesContent } = map;\n sourcesContent[put(sources, source)] = content;\n };\n\n toDecodedMap = (map) => {\n const {\n file,\n sourceRoot,\n _mappings: mappings,\n _sources: sources,\n _sourcesContent: sourcesContent,\n _names: names,\n } = map;\n removeEmptyFinalLines(mappings);\n\n return {\n version: 3,\n file: file || undefined,\n names: names.array,\n sourceRoot: sourceRoot || undefined,\n sources: sources.array,\n sourcesContent,\n mappings,\n };\n };\n\n toEncodedMap = (map) => {\n const decoded = toDecodedMap(map);\n return {\n ...decoded,\n mappings: encode(decoded.mappings as SourceMapSegment[][]),\n };\n };\n\n allMappings = (map) => {\n const out: Mapping[] = [];\n const { _mappings: mappings, _sources: sources, _names: names } = map;\n\n for (let i = 0; i < mappings.length; i++) {\n const line = mappings[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n\n const generated = { line: i + 1, column: seg[COLUMN] };\n let source: string | undefined = undefined;\n let original: Pos | undefined = undefined;\n let name: string | undefined = undefined;\n\n if (seg.length !== 1) {\n source = sources.array[seg[SOURCES_INDEX]];\n original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };\n\n if (seg.length === 5) name = names.array[seg[NAMES_INDEX]];\n }\n\n out.push({ generated, source, original, name } as Mapping);\n }\n }\n\n return out;\n };\n\n fromMap = (input) => {\n const map = new TraceMap(input);\n const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });\n\n putAll(gen._names, map.names);\n putAll(gen._sources, map.sources as string[]);\n gen._sourcesContent = map.sourcesContent || map.sources.map(() => null);\n gen._mappings = decodedMappings(map) as GenMapping['_mappings'];\n\n return gen;\n };\n\n // Internal helpers\n addSegmentInternal = (\n skipable,\n map,\n genLine,\n genColumn,\n source,\n sourceLine,\n sourceColumn,\n name,\n content,\n ) => {\n const {\n _mappings: mappings,\n _sources: sources,\n _sourcesContent: sourcesContent,\n _names: names,\n } = map;\n const line = getLine(mappings, genLine);\n const index = getColumnIndex(line, genColumn);\n\n if (!source) {\n if (skipable && skipSourceless(line, index)) return;\n return insert(line, index, [genColumn]);\n }\n\n // Sigh, TypeScript can't figure out sourceLine and sourceColumn aren't nullish if source\n // isn't nullish.\n assert(sourceLine);\n assert(sourceColumn);\n\n const sourcesIndex = put(sources, source);\n const namesIndex = name ? put(names, name) : NO_NAME;\n if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content ?? null;\n\n if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {\n return;\n }\n\n return insert(\n line,\n index,\n name\n ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]\n : [genColumn, sourcesIndex, sourceLine, sourceColumn],\n );\n };\n }\n}\n\nfunction assert(_val: unknown): asserts _val is T {\n // noop.\n}\n\nfunction getLine(mappings: SourceMapSegment[][], index: number): SourceMapSegment[] {\n for (let i = mappings.length; i <= index; i++) {\n mappings[i] = [];\n }\n return mappings[index];\n}\n\nfunction getColumnIndex(line: SourceMapSegment[], genColumn: number): number {\n let index = line.length;\n for (let i = index - 1; i >= 0; index = i--) {\n const current = line[i];\n if (genColumn >= current[COLUMN]) break;\n }\n return index;\n}\n\nfunction insert(array: T[], index: number, value: T) {\n for (let i = array.length; i > index; i--) {\n array[i] = array[i - 1];\n }\n array[index] = value;\n}\n\nfunction removeEmptyFinalLines(mappings: SourceMapSegment[][]) {\n const { length } = mappings;\n let len = length;\n for (let i = len - 1; i >= 0; len = i, i--) {\n if (mappings[i].length > 0) break;\n }\n if (len < length) mappings.length = len;\n}\n\nfunction putAll(strarr: SetArray, array: string[]) {\n for (let i = 0; i < array.length; i++) put(strarr, array[i]);\n}\n\nfunction skipSourceless(line: SourceMapSegment[], index: number): boolean {\n // The start of a line is already sourceless, so adding a sourceless segment to the beginning\n // doesn't generate any useful information.\n if (index === 0) return true;\n\n const prev = line[index - 1];\n // If the previous segment is also sourceless, then adding another sourceless segment doesn't\n // genrate any new information. Else, this segment will end the source/named segment and point to\n // a sourceless position, which is useful.\n return prev.length === 1;\n}\n\nfunction skipSource(\n line: SourceMapSegment[],\n index: number,\n sourcesIndex: number,\n sourceLine: number,\n sourceColumn: number,\n namesIndex: number,\n): boolean {\n // A source/named segment at the start of a line gives position at that genColumn\n if (index === 0) return false;\n\n const prev = line[index - 1];\n\n // If the previous segment is sourceless, then we're transitioning to a source.\n if (prev.length === 1) return false;\n\n // If the previous segment maps to the exact same source position, then this segment doesn't\n // provide any new position information.\n return (\n sourcesIndex === prev[SOURCES_INDEX] &&\n sourceLine === prev[SOURCE_LINE] &&\n sourceColumn === prev[SOURCE_COLUMN] &&\n namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME)\n );\n}\n\nfunction addMappingInternal(\n skipable: boolean,\n map: GenMapping,\n mapping: {\n generated: Pos;\n source: S;\n original: S extends string ? Pos : null | undefined;\n name: S extends string ? string | null | undefined : null | undefined;\n content: S extends string ? string | null | undefined : null | undefined;\n },\n) {\n const { generated, source, original, name, content } = mapping;\n if (!source) {\n return addSegmentInternal(\n skipable,\n map,\n generated.line - 1,\n generated.column,\n null,\n null,\n null,\n null,\n null,\n );\n }\n const s: string = source;\n assert(original);\n return addSegmentInternal(\n skipable,\n map,\n generated.line - 1,\n generated.column,\n s,\n original.line - 1,\n original.column,\n name,\n content,\n );\n}\n"],"names":[],"mappings":";;;;AAWO,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,WAAW,GAAG,CAAC;;ACQ5B,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC;AAEnB;;;AAGG;AACQ,I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B,CACvB,QAAQ,EACR,GAAG,EACH,SAAS,CAAC,IAAI,GAAG,CAAC,EAClB,SAAS,CAAC,MAAM,EAChB,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,CACL,CAAC;AACH,KAAA;IACD,MAAM,CAAC,GAAW,MAAM,CAAC;AAEzB,IAAA,OAAO,kBAAkB,CACvB,QAAQ,EACR,GAAG,EACH,SAAS,CAAC,IAAI,GAAG,CAAC,EAClB,SAAS,CAAC,MAAM,EAChB,CAAC,EACD,QAAQ,CAAC,IAAI,GAAG,CAAC,EACjB,QAAQ,CAAC,MAAM,EACf,IAAI,EACJ,OAAO,CACR,CAAC;AACJ;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js new file mode 100644 index 000000000..d9fcf5cff --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js @@ -0,0 +1,236 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/set-array'), require('@jridgewell/sourcemap-codec'), require('@jridgewell/trace-mapping')) : + typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/set-array', '@jridgewell/sourcemap-codec', '@jridgewell/trace-mapping'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.genMapping = {}, global.setArray, global.sourcemapCodec, global.traceMapping)); +})(this, (function (exports, setArray, sourcemapCodec, traceMapping) { 'use strict'; + + const COLUMN = 0; + const SOURCES_INDEX = 1; + const SOURCE_LINE = 2; + const SOURCE_COLUMN = 3; + const NAMES_INDEX = 4; + + const NO_NAME = -1; + /** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ + exports.addSegment = void 0; + /** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ + exports.addMapping = void 0; + /** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ + exports.maybeAddSegment = void 0; + /** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ + exports.maybeAddMapping = void 0; + /** + * Adds/removes the content of the source file to the source map. + */ + exports.setSourceContent = void 0; + /** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ + exports.toDecodedMap = void 0; + /** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ + exports.toEncodedMap = void 0; + /** + * Constructs a new GenMapping, using the already present mappings of the input. + */ + exports.fromMap = void 0; + /** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ + exports.allMappings = void 0; + // This split declaration is only so that terser can elminiate the static initialization block. + let addSegmentInternal; + /** + * Provides the state to generate a sourcemap. + */ + class GenMapping { + constructor({ file, sourceRoot } = {}) { + this._names = new setArray.SetArray(); + this._sources = new setArray.SetArray(); + this._sourcesContent = []; + this._mappings = []; + this.file = file; + this.sourceRoot = sourceRoot; + } + } + (() => { + exports.addSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + return addSegmentInternal(false, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content); + }; + exports.maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content); + }; + exports.addMapping = (map, mapping) => { + return addMappingInternal(false, map, mapping); + }; + exports.maybeAddMapping = (map, mapping) => { + return addMappingInternal(true, map, mapping); + }; + exports.setSourceContent = (map, source, content) => { + const { _sources: sources, _sourcesContent: sourcesContent } = map; + sourcesContent[setArray.put(sources, source)] = content; + }; + exports.toDecodedMap = (map) => { + const { file, sourceRoot, _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map; + removeEmptyFinalLines(mappings); + return { + version: 3, + file: file || undefined, + names: names.array, + sourceRoot: sourceRoot || undefined, + sources: sources.array, + sourcesContent, + mappings, + }; + }; + exports.toEncodedMap = (map) => { + const decoded = exports.toDecodedMap(map); + return Object.assign(Object.assign({}, decoded), { mappings: sourcemapCodec.encode(decoded.mappings) }); + }; + exports.allMappings = (map) => { + const out = []; + const { _mappings: mappings, _sources: sources, _names: names } = map; + for (let i = 0; i < mappings.length; i++) { + const line = mappings[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generated = { line: i + 1, column: seg[COLUMN] }; + let source = undefined; + let original = undefined; + let name = undefined; + if (seg.length !== 1) { + source = sources.array[seg[SOURCES_INDEX]]; + original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; + if (seg.length === 5) + name = names.array[seg[NAMES_INDEX]]; + } + out.push({ generated, source, original, name }); + } + } + return out; + }; + exports.fromMap = (input) => { + const map = new traceMapping.TraceMap(input); + const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); + putAll(gen._names, map.names); + putAll(gen._sources, map.sources); + gen._sourcesContent = map.sourcesContent || map.sources.map(() => null); + gen._mappings = traceMapping.decodedMappings(map); + return gen; + }; + // Internal helpers + addSegmentInternal = (skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { + const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map; + const line = getLine(mappings, genLine); + const index = getColumnIndex(line, genColumn); + if (!source) { + if (skipable && skipSourceless(line, index)) + return; + return insert(line, index, [genColumn]); + } + const sourcesIndex = setArray.put(sources, source); + const namesIndex = name ? setArray.put(names, name) : NO_NAME; + if (sourcesIndex === sourcesContent.length) + sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null; + if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { + return; + } + return insert(line, index, name + ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] + : [genColumn, sourcesIndex, sourceLine, sourceColumn]); + }; + })(); + function getLine(mappings, index) { + for (let i = mappings.length; i <= index; i++) { + mappings[i] = []; + } + return mappings[index]; + } + function getColumnIndex(line, genColumn) { + let index = line.length; + for (let i = index - 1; i >= 0; index = i--) { + const current = line[i]; + if (genColumn >= current[COLUMN]) + break; + } + return index; + } + function insert(array, index, value) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; + } + function removeEmptyFinalLines(mappings) { + const { length } = mappings; + let len = length; + for (let i = len - 1; i >= 0; len = i, i--) { + if (mappings[i].length > 0) + break; + } + if (len < length) + mappings.length = len; + } + function putAll(strarr, array) { + for (let i = 0; i < array.length; i++) + setArray.put(strarr, array[i]); + } + function skipSourceless(line, index) { + // The start of a line is already sourceless, so adding a sourceless segment to the beginning + // doesn't generate any useful information. + if (index === 0) + return true; + const prev = line[index - 1]; + // If the previous segment is also sourceless, then adding another sourceless segment doesn't + // genrate any new information. Else, this segment will end the source/named segment and point to + // a sourceless position, which is useful. + return prev.length === 1; + } + function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) { + // A source/named segment at the start of a line gives position at that genColumn + if (index === 0) + return false; + const prev = line[index - 1]; + // If the previous segment is sourceless, then we're transitioning to a source. + if (prev.length === 1) + return false; + // If the previous segment maps to the exact same source position, then this segment doesn't + // provide any new position information. + return (sourcesIndex === prev[SOURCES_INDEX] && + sourceLine === prev[SOURCE_LINE] && + sourceColumn === prev[SOURCE_COLUMN] && + namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME)); + } + function addMappingInternal(skipable, map, mapping) { + const { generated, source, original, name, content } = mapping; + if (!source) { + return addSegmentInternal(skipable, map, generated.line - 1, generated.column, null, null, null, null, null); + } + const s = source; + return addSegmentInternal(skipable, map, generated.line - 1, generated.column, s, original.line - 1, original.column, name, content); + } + + exports.GenMapping = GenMapping; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); +//# sourceMappingURL=gen-mapping.umd.js.map diff --git a/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map new file mode 100644 index 000000000..7cc8d149d --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"gen-mapping.umd.js","sources":["../src/sourcemap-segment.ts","../src/gen-mapping.ts"],"sourcesContent":["type GeneratedColumn = number;\ntype SourcesIndex = number;\ntype SourceLine = number;\ntype SourceColumn = number;\ntype NamesIndex = number;\n\nexport type SourceMapSegment =\n | [GeneratedColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];\n\nexport const COLUMN = 0;\nexport const SOURCES_INDEX = 1;\nexport const SOURCE_LINE = 2;\nexport const SOURCE_COLUMN = 3;\nexport const NAMES_INDEX = 4;\n","import { SetArray, put } from '@jridgewell/set-array';\nimport { encode } from '@jridgewell/sourcemap-codec';\nimport { TraceMap, decodedMappings } from '@jridgewell/trace-mapping';\n\nimport {\n COLUMN,\n SOURCES_INDEX,\n SOURCE_LINE,\n SOURCE_COLUMN,\n NAMES_INDEX,\n} from './sourcemap-segment';\n\nimport type { SourceMapInput } from '@jridgewell/trace-mapping';\nimport type { SourceMapSegment } from './sourcemap-segment';\nimport type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types';\n\nexport type { DecodedSourceMap, EncodedSourceMap, Mapping };\n\nexport type Options = {\n file?: string | null;\n sourceRoot?: string | null;\n};\n\nconst NO_NAME = -1;\n\n/**\n * A low-level API to associate a generated position with an original source position. Line and\n * column here are 0-based, unlike `addMapping`.\n */\nexport let addSegment: {\n (\n map: GenMapping,\n genLine: number,\n genColumn: number,\n source?: null,\n sourceLine?: null,\n sourceColumn?: null,\n name?: null,\n content?: null,\n ): void;\n (\n map: GenMapping,\n genLine: number,\n genColumn: number,\n source: string,\n sourceLine: number,\n sourceColumn: number,\n name?: null,\n content?: string | null,\n ): void;\n (\n map: GenMapping,\n genLine: number,\n genColumn: number,\n source: string,\n sourceLine: number,\n sourceColumn: number,\n name: string,\n content?: string | null,\n ): void;\n};\n\n/**\n * A high-level API to associate a generated position with an original source position. Line is\n * 1-based, but column is 0-based, due to legacy behavior in `source-map` library.\n */\nexport let addMapping: {\n (\n map: GenMapping,\n mapping: {\n generated: Pos;\n source?: null;\n original?: null;\n name?: null;\n content?: null;\n },\n ): void;\n (\n map: GenMapping,\n mapping: {\n generated: Pos;\n source: string;\n original: Pos;\n name?: null;\n content?: string | null;\n },\n ): void;\n (\n map: GenMapping,\n mapping: {\n generated: Pos;\n source: string;\n original: Pos;\n name: string;\n content?: string | null;\n },\n ): void;\n};\n\n/**\n * Same as `addSegment`, but will only add the segment if it generates useful information in the\n * resulting map. This only works correctly if segments are added **in order**, meaning you should\n * not add a segment with a lower generated line/column than one that came before.\n */\nexport let maybeAddSegment: typeof addSegment;\n\n/**\n * Same as `addMapping`, but will only add the mapping if it generates useful information in the\n * resulting map. This only works correctly if mappings are added **in order**, meaning you should\n * not add a mapping with a lower generated line/column than one that came before.\n */\nexport let maybeAddMapping: typeof addMapping;\n\n/**\n * Adds/removes the content of the source file to the source map.\n */\nexport let setSourceContent: (map: GenMapping, source: string, content: string | null) => void;\n\n/**\n * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport let toDecodedMap: (map: GenMapping) => DecodedSourceMap;\n\n/**\n * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport let toEncodedMap: (map: GenMapping) => EncodedSourceMap;\n\n/**\n * Constructs a new GenMapping, using the already present mappings of the input.\n */\nexport let fromMap: (input: SourceMapInput) => GenMapping;\n\n/**\n * Returns an array of high-level mapping objects for every recorded segment, which could then be\n * passed to the `source-map` library.\n */\nexport let allMappings: (map: GenMapping) => Mapping[];\n\n// This split declaration is only so that terser can elminiate the static initialization block.\nlet addSegmentInternal: (\n skipable: boolean,\n map: GenMapping,\n genLine: number,\n genColumn: number,\n source: S,\n sourceLine: S extends string ? number : null | undefined,\n sourceColumn: S extends string ? number : null | undefined,\n name: S extends string ? string | null | undefined : null | undefined,\n content: S extends string ? string | null | undefined : null | undefined,\n) => void;\n\n/**\n * Provides the state to generate a sourcemap.\n */\nexport class GenMapping {\n private _names = new SetArray();\n private _sources = new SetArray();\n private _sourcesContent: (string | null)[] = [];\n private _mappings: SourceMapSegment[][] = [];\n declare file: string | null | undefined;\n declare sourceRoot: string | null | undefined;\n\n constructor({ file, sourceRoot }: Options = {}) {\n this.file = file;\n this.sourceRoot = sourceRoot;\n }\n\n static {\n addSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {\n return addSegmentInternal(\n false,\n map,\n genLine,\n genColumn,\n source,\n sourceLine,\n sourceColumn,\n name,\n content,\n );\n };\n\n maybeAddSegment = (\n map,\n genLine,\n genColumn,\n source,\n sourceLine,\n sourceColumn,\n name,\n content,\n ) => {\n return addSegmentInternal(\n true,\n map,\n genLine,\n genColumn,\n source,\n sourceLine,\n sourceColumn,\n name,\n content,\n );\n };\n\n addMapping = (map, mapping) => {\n return addMappingInternal(false, map, mapping as Parameters[2]);\n };\n\n maybeAddMapping = (map, mapping) => {\n return addMappingInternal(true, map, mapping as Parameters[2]);\n };\n\n setSourceContent = (map, source, content) => {\n const { _sources: sources, _sourcesContent: sourcesContent } = map;\n sourcesContent[put(sources, source)] = content;\n };\n\n toDecodedMap = (map) => {\n const {\n file,\n sourceRoot,\n _mappings: mappings,\n _sources: sources,\n _sourcesContent: sourcesContent,\n _names: names,\n } = map;\n removeEmptyFinalLines(mappings);\n\n return {\n version: 3,\n file: file || undefined,\n names: names.array,\n sourceRoot: sourceRoot || undefined,\n sources: sources.array,\n sourcesContent,\n mappings,\n };\n };\n\n toEncodedMap = (map) => {\n const decoded = toDecodedMap(map);\n return {\n ...decoded,\n mappings: encode(decoded.mappings as SourceMapSegment[][]),\n };\n };\n\n allMappings = (map) => {\n const out: Mapping[] = [];\n const { _mappings: mappings, _sources: sources, _names: names } = map;\n\n for (let i = 0; i < mappings.length; i++) {\n const line = mappings[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n\n const generated = { line: i + 1, column: seg[COLUMN] };\n let source: string | undefined = undefined;\n let original: Pos | undefined = undefined;\n let name: string | undefined = undefined;\n\n if (seg.length !== 1) {\n source = sources.array[seg[SOURCES_INDEX]];\n original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };\n\n if (seg.length === 5) name = names.array[seg[NAMES_INDEX]];\n }\n\n out.push({ generated, source, original, name } as Mapping);\n }\n }\n\n return out;\n };\n\n fromMap = (input) => {\n const map = new TraceMap(input);\n const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });\n\n putAll(gen._names, map.names);\n putAll(gen._sources, map.sources as string[]);\n gen._sourcesContent = map.sourcesContent || map.sources.map(() => null);\n gen._mappings = decodedMappings(map) as GenMapping['_mappings'];\n\n return gen;\n };\n\n // Internal helpers\n addSegmentInternal = (\n skipable,\n map,\n genLine,\n genColumn,\n source,\n sourceLine,\n sourceColumn,\n name,\n content,\n ) => {\n const {\n _mappings: mappings,\n _sources: sources,\n _sourcesContent: sourcesContent,\n _names: names,\n } = map;\n const line = getLine(mappings, genLine);\n const index = getColumnIndex(line, genColumn);\n\n if (!source) {\n if (skipable && skipSourceless(line, index)) return;\n return insert(line, index, [genColumn]);\n }\n\n // Sigh, TypeScript can't figure out sourceLine and sourceColumn aren't nullish if source\n // isn't nullish.\n assert(sourceLine);\n assert(sourceColumn);\n\n const sourcesIndex = put(sources, source);\n const namesIndex = name ? put(names, name) : NO_NAME;\n if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content ?? null;\n\n if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {\n return;\n }\n\n return insert(\n line,\n index,\n name\n ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]\n : [genColumn, sourcesIndex, sourceLine, sourceColumn],\n );\n };\n }\n}\n\nfunction assert(_val: unknown): asserts _val is T {\n // noop.\n}\n\nfunction getLine(mappings: SourceMapSegment[][], index: number): SourceMapSegment[] {\n for (let i = mappings.length; i <= index; i++) {\n mappings[i] = [];\n }\n return mappings[index];\n}\n\nfunction getColumnIndex(line: SourceMapSegment[], genColumn: number): number {\n let index = line.length;\n for (let i = index - 1; i >= 0; index = i--) {\n const current = line[i];\n if (genColumn >= current[COLUMN]) break;\n }\n return index;\n}\n\nfunction insert(array: T[], index: number, value: T) {\n for (let i = array.length; i > index; i--) {\n array[i] = array[i - 1];\n }\n array[index] = value;\n}\n\nfunction removeEmptyFinalLines(mappings: SourceMapSegment[][]) {\n const { length } = mappings;\n let len = length;\n for (let i = len - 1; i >= 0; len = i, i--) {\n if (mappings[i].length > 0) break;\n }\n if (len < length) mappings.length = len;\n}\n\nfunction putAll(strarr: SetArray, array: string[]) {\n for (let i = 0; i < array.length; i++) put(strarr, array[i]);\n}\n\nfunction skipSourceless(line: SourceMapSegment[], index: number): boolean {\n // The start of a line is already sourceless, so adding a sourceless segment to the beginning\n // doesn't generate any useful information.\n if (index === 0) return true;\n\n const prev = line[index - 1];\n // If the previous segment is also sourceless, then adding another sourceless segment doesn't\n // genrate any new information. Else, this segment will end the source/named segment and point to\n // a sourceless position, which is useful.\n return prev.length === 1;\n}\n\nfunction skipSource(\n line: SourceMapSegment[],\n index: number,\n sourcesIndex: number,\n sourceLine: number,\n sourceColumn: number,\n namesIndex: number,\n): boolean {\n // A source/named segment at the start of a line gives position at that genColumn\n if (index === 0) return false;\n\n const prev = line[index - 1];\n\n // If the previous segment is sourceless, then we're transitioning to a source.\n if (prev.length === 1) return false;\n\n // If the previous segment maps to the exact same source position, then this segment doesn't\n // provide any new position information.\n return (\n sourcesIndex === prev[SOURCES_INDEX] &&\n sourceLine === prev[SOURCE_LINE] &&\n sourceColumn === prev[SOURCE_COLUMN] &&\n namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME)\n );\n}\n\nfunction addMappingInternal(\n skipable: boolean,\n map: GenMapping,\n mapping: {\n generated: Pos;\n source: S;\n original: S extends string ? Pos : null | undefined;\n name: S extends string ? string | null | undefined : null | undefined;\n content: S extends string ? string | null | undefined : null | undefined;\n },\n) {\n const { generated, source, original, name, content } = mapping;\n if (!source) {\n return addSegmentInternal(\n skipable,\n map,\n generated.line - 1,\n generated.column,\n null,\n null,\n null,\n null,\n null,\n );\n }\n const s: string = source;\n assert(original);\n return addSegmentInternal(\n skipable,\n map,\n generated.line - 1,\n generated.column,\n s,\n original.line - 1,\n original.column,\n name,\n content,\n );\n}\n"],"names":["addSegment","addMapping","maybeAddSegment","maybeAddMapping","setSourceContent","toDecodedMap","toEncodedMap","fromMap","allMappings","SetArray","put","encode","TraceMap","decodedMappings"],"mappings":";;;;;;IAWO,MAAM,MAAM,GAAG,CAAC,CAAC;IACjB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,WAAW,GAAG,CAAC,CAAC;IACtB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,WAAW,GAAG,CAAC;;ICQ5B,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC;IAEnB;;;IAGG;AACQA,gCA+BT;IAEF;;;IAGG;AACQC,gCA+BT;IAEF;;;;IAIG;AACQC,qCAAmC;IAE9C;;;;IAIG;AACQC,qCAAmC;IAE9C;;IAEG;AACQC,sCAAoF;IAE/F;;;IAGG;AACQC,kCAAoD;IAE/D;;;IAGG;AACQC,kCAAoD;IAE/D;;IAEG;AACQC,6BAA+C;IAE1D;;;IAGG;AACQC,iCAA4C;IAEvD;IACA,IAAI,kBAUK,CAAC;IAEV;;IAEG;UACU,UAAU,CAAA;IAQrB,IAAA,WAAA,CAAY,EAAE,IAAI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CAAC,IAAI,GAAG,CAAC,EACjB,QAAQ,CAAC,MAAM,EACf,IAAI,EACJ,OAAO,CACR,CAAC;IACJ;;;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts new file mode 100644 index 000000000..d510d74bb --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts @@ -0,0 +1,90 @@ +import type { SourceMapInput } from '@jridgewell/trace-mapping'; +import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types'; +export type { DecodedSourceMap, EncodedSourceMap, Mapping }; +export declare type Options = { + file?: string | null; + sourceRoot?: string | null; +}; +/** + * A low-level API to associate a generated position with an original source position. Line and + * column here are 0-based, unlike `addMapping`. + */ +export declare let addSegment: { + (map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void; + (map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void; + (map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void; +}; +/** + * A high-level API to associate a generated position with an original source position. Line is + * 1-based, but column is 0-based, due to legacy behavior in `source-map` library. + */ +export declare let addMapping: { + (map: GenMapping, mapping: { + generated: Pos; + source?: null; + original?: null; + name?: null; + content?: null; + }): void; + (map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name?: null; + content?: string | null; + }): void; + (map: GenMapping, mapping: { + generated: Pos; + source: string; + original: Pos; + name: string; + content?: string | null; + }): void; +}; +/** + * Same as `addSegment`, but will only add the segment if it generates useful information in the + * resulting map. This only works correctly if segments are added **in order**, meaning you should + * not add a segment with a lower generated line/column than one that came before. + */ +export declare let maybeAddSegment: typeof addSegment; +/** + * Same as `addMapping`, but will only add the mapping if it generates useful information in the + * resulting map. This only works correctly if mappings are added **in order**, meaning you should + * not add a mapping with a lower generated line/column than one that came before. + */ +export declare let maybeAddMapping: typeof addMapping; +/** + * Adds/removes the content of the source file to the source map. + */ +export declare let setSourceContent: (map: GenMapping, source: string, content: string | null) => void; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare let toDecodedMap: (map: GenMapping) => DecodedSourceMap; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare let toEncodedMap: (map: GenMapping) => EncodedSourceMap; +/** + * Constructs a new GenMapping, using the already present mappings of the input. + */ +export declare let fromMap: (input: SourceMapInput) => GenMapping; +/** + * Returns an array of high-level mapping objects for every recorded segment, which could then be + * passed to the `source-map` library. + */ +export declare let allMappings: (map: GenMapping) => Mapping[]; +/** + * Provides the state to generate a sourcemap. + */ +export declare class GenMapping { + private _names; + private _sources; + private _sourcesContent; + private _mappings; + file: string | null | undefined; + sourceRoot: string | null | undefined; + constructor({ file, sourceRoot }?: Options); +} diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts new file mode 100644 index 000000000..e187ba98a --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts @@ -0,0 +1,12 @@ +declare type GeneratedColumn = number; +declare type SourcesIndex = number; +declare type SourceLine = number; +declare type SourceColumn = number; +declare type NamesIndex = number; +export declare type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export {}; diff --git a/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts b/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts new file mode 100644 index 000000000..b309c8111 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts @@ -0,0 +1,35 @@ +import type { SourceMapSegment } from './sourcemap-segment'; +export interface SourceMapV3 { + file?: string | null; + names: readonly string[]; + sourceRoot?: string; + sources: readonly (string | null)[]; + sourcesContent?: readonly (string | null)[]; + version: 3; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: readonly SourceMapSegment[][]; +} +export interface Pos { + line: number; + column: number; +} +export declare type Mapping = { + generated: Pos; + source: undefined; + original: undefined; + name: undefined; +} | { + generated: Pos; + source: string; + original: Pos; + name: string; +} | { + generated: Pos; + source: string; + original: Pos; + name: undefined; +}; diff --git a/node_modules/@jridgewell/gen-mapping/package.json b/node_modules/@jridgewell/gen-mapping/package.json new file mode 100644 index 000000000..69e0ac812 --- /dev/null +++ b/node_modules/@jridgewell/gen-mapping/package.json @@ -0,0 +1,77 @@ +{ + "name": "@jridgewell/gen-mapping", + "version": "0.3.3", + "description": "Generate source maps", + "keywords": [ + "source", + "map" + ], + "author": "Justin Ridgewell ", + "license": "MIT", + "repository": "https://github.com/jridgewell/gen-mapping", + "main": "dist/gen-mapping.umd.js", + "module": "dist/gen-mapping.mjs", + "types": "dist/types/gen-mapping.d.ts", + "exports": { + ".": [ + { + "types": "./dist/types/gen-mapping.d.ts", + "browser": "./dist/gen-mapping.umd.js", + "require": "./dist/gen-mapping.umd.js", + "import": "./dist/gen-mapping.mjs" + }, + "./dist/gen-mapping.umd.js" + ], + "./package.json": "./package.json" + }, + "files": [ + "dist" + ], + "engines": { + "node": ">=6.0.0" + }, + "scripts": { + "benchmark": "run-s build:rollup benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node benchmark/index.mjs", + "prebuild": "rm -rf dist", + "build": "run-s -n build:*", + "build:rollup": "rollup -c rollup.config.js", + "build:ts": "tsc --project tsconfig.build.json", + "lint": "run-s -n lint:*", + "lint:prettier": "npm run test:lint:prettier -- --write", + "lint:ts": "npm run test:lint:ts -- --fix", + "pretest": "run-s build:rollup", + "test": "run-s -n test:lint test:coverage", + "test:debug": "mocha --inspect-brk", + "test:lint": "run-s -n test:lint:*", + "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", + "test:lint:ts": "eslint '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:coverage": "c8 mocha", + "test:watch": "run-p 'build:rollup -- --watch' 'test:only -- --watch'", + "prepublishOnly": "npm run preversion", + "preversion": "run-s test build" + }, + "devDependencies": { + "@rollup/plugin-typescript": "8.3.2", + "@types/mocha": "9.1.1", + "@types/node": "17.0.29", + "@typescript-eslint/eslint-plugin": "5.21.0", + "@typescript-eslint/parser": "5.21.0", + "benchmark": "2.1.4", + "c8": "7.11.2", + "eslint": "8.14.0", + "eslint-config-prettier": "8.5.0", + "mocha": "9.2.2", + "npm-run-all": "4.1.5", + "prettier": "2.6.2", + "rollup": "2.70.2", + "typescript": "4.6.3" + }, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } +} diff --git a/node_modules/@jridgewell/resolve-uri/LICENSE b/node_modules/@jridgewell/resolve-uri/LICENSE new file mode 100644 index 000000000..0a81b2ade --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/LICENSE @@ -0,0 +1,19 @@ +Copyright 2019 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/README.md b/node_modules/@jridgewell/resolve-uri/README.md new file mode 100644 index 000000000..2fe70df77 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/README.md @@ -0,0 +1,40 @@ +# @jridgewell/resolve-uri + +> Resolve a URI relative to an optional base URI + +Resolve any combination of absolute URIs, protocol-realtive URIs, absolute paths, or relative paths. + +## Installation + +```sh +npm install @jridgewell/resolve-uri +``` + +## Usage + +```typescript +function resolve(input: string, base?: string): string; +``` + +```js +import resolve from '@jridgewell/resolve-uri'; + +resolve('foo', 'https://example.com'); // => 'https://example.com/foo' +``` + +| Input | Base | Resolution | Explanation | +|-----------------------|-------------------------|--------------------------------|--------------------------------------------------------------| +| `https://example.com` | _any_ | `https://example.com/` | Input is normalized only | +| `//example.com` | `https://base.com/` | `https://example.com/` | Input inherits the base's protocol | +| `//example.com` | _rest_ | `//example.com/` | Input is normalized only | +| `/example` | `https://base.com/` | `https://base.com/example` | Input inherits the base's origin | +| `/example` | `//base.com/` | `//base.com/example` | Input inherits the base's host and remains protocol relative | +| `/example` | _rest_ | `/example` | Input is normalized only | +| `example` | `https://base.com/dir/` | `https://base.com/dir/example` | Input is joined with the base | +| `example` | `https://base.com/file` | `https://base.com/example` | Input is joined with the base without its file | +| `example` | `//base.com/dir/` | `//base.com/dir/example` | Input is joined with the base's last directory | +| `example` | `//base.com/file` | `//base.com/example` | Input is joined with the base without its file | +| `example` | `/base/dir/` | `/base/dir/example` | Input is joined with the base's last directory | +| `example` | `/base/file` | `/base/example` | Input is joined with the base without its file | +| `example` | `base/dir/` | `base/dir/example` | Input is joined with the base's last directory | +| `example` | `base/file` | `base/example` | Input is joined with the base without its file | diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs new file mode 100644 index 000000000..94d8dceb9 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs @@ -0,0 +1,242 @@ +// Matches the scheme of a URL, eg "http://" +const schemeRegex = /^[\w+.-]+:\/\//; +/** + * Matches the parts of a URL: + * 1. Scheme, including ":", guaranteed. + * 2. User/password, including "@", optional. + * 3. Host, guaranteed. + * 4. Port, including ":", optional. + * 5. Path, including "/", optional. + * 6. Query, including "?", optional. + * 7. Hash, including "#", optional. + */ +const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/; +/** + * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start + * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive). + * + * 1. Host, optional. + * 2. Path, which may include "/", guaranteed. + * 3. Query, including "?", optional. + * 4. Hash, including "#", optional. + */ +const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i; +var UrlType; +(function (UrlType) { + UrlType[UrlType["Empty"] = 1] = "Empty"; + UrlType[UrlType["Hash"] = 2] = "Hash"; + UrlType[UrlType["Query"] = 3] = "Query"; + UrlType[UrlType["RelativePath"] = 4] = "RelativePath"; + UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath"; + UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative"; + UrlType[UrlType["Absolute"] = 7] = "Absolute"; +})(UrlType || (UrlType = {})); +function isAbsoluteUrl(input) { + return schemeRegex.test(input); +} +function isSchemeRelativeUrl(input) { + return input.startsWith('//'); +} +function isAbsolutePath(input) { + return input.startsWith('/'); +} +function isFileUrl(input) { + return input.startsWith('file:'); +} +function isRelative(input) { + return /^[.?#]/.test(input); +} +function parseAbsoluteUrl(input) { + const match = urlRegex.exec(input); + return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || ''); +} +function parseFileUrl(input) { + const match = fileRegex.exec(input); + const path = match[2]; + return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || ''); +} +function makeUrl(scheme, user, host, port, path, query, hash) { + return { + scheme, + user, + host, + port, + path, + query, + hash, + type: UrlType.Absolute, + }; +} +function parseUrl(input) { + if (isSchemeRelativeUrl(input)) { + const url = parseAbsoluteUrl('http:' + input); + url.scheme = ''; + url.type = UrlType.SchemeRelative; + return url; + } + if (isAbsolutePath(input)) { + const url = parseAbsoluteUrl('http://foo.com' + input); + url.scheme = ''; + url.host = ''; + url.type = UrlType.AbsolutePath; + return url; + } + if (isFileUrl(input)) + return parseFileUrl(input); + if (isAbsoluteUrl(input)) + return parseAbsoluteUrl(input); + const url = parseAbsoluteUrl('http://foo.com/' + input); + url.scheme = ''; + url.host = ''; + url.type = input + ? input.startsWith('?') + ? UrlType.Query + : input.startsWith('#') + ? UrlType.Hash + : UrlType.RelativePath + : UrlType.Empty; + return url; +} +function stripPathFilename(path) { + // If a path ends with a parent directory "..", then it's a relative path with excess parent + // paths. It's not a file, so we can't strip it. + if (path.endsWith('/..')) + return path; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); +} +function mergePaths(url, base) { + normalizePath(base, base.type); + // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative + // path). + if (url.path === '/') { + url.path = base.path; + } + else { + // Resolution happens relative to the base path's directory, not the file. + url.path = stripPathFilename(base.path) + url.path; + } +} +/** + * The path can have empty directories "//", unneeded parents "foo/..", or current directory + * "foo/.". We need to normalize to a standard representation. + */ +function normalizePath(url, type) { + const rel = type <= UrlType.RelativePath; + const pieces = url.path.split('/'); + // We need to preserve the first piece always, so that we output a leading slash. The item at + // pieces[0] is an empty string. + let pointer = 1; + // Positive is the number of real directories we've output, used for popping a parent directory. + // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo". + let positive = 0; + // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will + // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a + // real directory, we won't need to append, unless the other conditions happen again. + let addTrailingSlash = false; + for (let i = 1; i < pieces.length; i++) { + const piece = pieces[i]; + // An empty directory, could be a trailing slash, or just a double "//" in the path. + if (!piece) { + addTrailingSlash = true; + continue; + } + // If we encounter a real directory, then we don't need to append anymore. + addTrailingSlash = false; + // A current directory, which we can always drop. + if (piece === '.') + continue; + // A parent directory, we need to see if there are any real directories we can pop. Else, we + // have an excess of parents, and we'll need to keep the "..". + if (piece === '..') { + if (positive) { + addTrailingSlash = true; + positive--; + pointer--; + } + else if (rel) { + // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute + // URL, protocol relative URL, or an absolute path, we don't need to keep excess. + pieces[pointer++] = piece; + } + continue; + } + // We've encountered a real directory. Move it to the next insertion pointer, which accounts for + // any popped or dropped directories. + pieces[pointer++] = piece; + positive++; + } + let path = ''; + for (let i = 1; i < pointer; i++) { + path += '/' + pieces[i]; + } + if (!path || (addTrailingSlash && !path.endsWith('/..'))) { + path += '/'; + } + url.path = path; +} +/** + * Attempts to resolve `input` URL/path relative to `base`. + */ +function resolve(input, base) { + if (!input && !base) + return ''; + const url = parseUrl(input); + let inputType = url.type; + if (base && inputType !== UrlType.Absolute) { + const baseUrl = parseUrl(base); + const baseType = baseUrl.type; + switch (inputType) { + case UrlType.Empty: + url.hash = baseUrl.hash; + // fall through + case UrlType.Hash: + url.query = baseUrl.query; + // fall through + case UrlType.Query: + case UrlType.RelativePath: + mergePaths(url, baseUrl); + // fall through + case UrlType.AbsolutePath: + // The host, user, and port are joined, you can't copy one without the others. + url.user = baseUrl.user; + url.host = baseUrl.host; + url.port = baseUrl.port; + // fall through + case UrlType.SchemeRelative: + // The input doesn't have a schema at least, so we need to copy at least that over. + url.scheme = baseUrl.scheme; + } + if (baseType > inputType) + inputType = baseType; + } + normalizePath(url, inputType); + const queryHash = url.query + url.hash; + switch (inputType) { + // This is impossible, because of the empty checks at the start of the function. + // case UrlType.Empty: + case UrlType.Hash: + case UrlType.Query: + return queryHash; + case UrlType.RelativePath: { + // The first char is always a "/", and we need it to be relative. + const path = url.path.slice(1); + if (!path) + return queryHash || '.'; + if (isRelative(base || input) && !isRelative(path)) { + // If base started with a leading ".", or there is no base and input started with a ".", + // then we need to ensure that the relative path starts with a ".". We don't know if + // relative starts with a "..", though, so check before prepending. + return './' + path + queryHash; + } + return path + queryHash; + } + case UrlType.AbsolutePath: + return url.path + queryHash; + default: + return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash; + } +} + +export { resolve as default }; +//# sourceMappingURL=resolve-uri.mjs.map diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map new file mode 100644 index 000000000..009d0434b --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve-uri.mjs","sources":["../src/resolve-uri.ts"],"sourcesContent":["// Matches the scheme of a URL, eg \"http://\"\nconst schemeRegex = /^[\\w+.-]+:\\/\\//;\n\n/**\n * Matches the parts of a URL:\n * 1. Scheme, including \":\", guaranteed.\n * 2. User/password, including \"@\", optional.\n * 3. Host, guaranteed.\n * 4. Port, including \":\", optional.\n * 5. Path, including \"/\", optional.\n * 6. Query, including \"?\", optional.\n * 7. Hash, including \"#\", optional.\n */\nconst urlRegex = /^([\\w+.-]+:)\\/\\/([^@/#?]*@)?([^:/#?]*)(:\\d+)?(\\/[^#?]*)?(\\?[^#]*)?(#.*)?/;\n\n/**\n * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start\n * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).\n *\n * 1. Host, optional.\n * 2. Path, which may include \"/\", guaranteed.\n * 3. Query, including \"?\", optional.\n * 4. Hash, including \"#\", optional.\n */\nconst fileRegex = /^file:(?:\\/\\/((?![a-z]:)[^/#?]*)?)?(\\/?[^#?]*)(\\?[^#]*)?(#.*)?/i;\n\ntype Url = {\n scheme: string;\n user: string;\n host: string;\n port: string;\n path: string;\n query: string;\n hash: string;\n type: UrlType;\n};\n\nenum UrlType {\n Empty = 1,\n Hash = 2,\n Query = 3,\n RelativePath = 4,\n AbsolutePath = 5,\n SchemeRelative = 6,\n Absolute = 7,\n}\n\nfunction isAbsoluteUrl(input: string): boolean {\n return schemeRegex.test(input);\n}\n\nfunction isSchemeRelativeUrl(input: string): boolean {\n return input.startsWith('//');\n}\n\nfunction isAbsolutePath(input: string): boolean {\n return input.startsWith('/');\n}\n\nfunction isFileUrl(input: string): boolean {\n return input.startsWith('file:');\n}\n\nfunction isRelative(input: string): boolean {\n return /^[.?#]/.test(input);\n}\n\nfunction parseAbsoluteUrl(input: string): Url {\n const match = urlRegex.exec(input)!;\n return makeUrl(\n match[1],\n match[2] || '',\n match[3],\n match[4] || '',\n match[5] || '/',\n match[6] || '',\n match[7] || '',\n );\n}\n\nfunction parseFileUrl(input: string): Url {\n const match = fileRegex.exec(input)!;\n const path = match[2];\n return makeUrl(\n 'file:',\n '',\n match[1] || '',\n '',\n isAbsolutePath(path) ? path : '/' + path,\n match[3] || '',\n match[4] || '',\n );\n}\n\nfunction makeUrl(\n scheme: string,\n user: string,\n host: string,\n port: string,\n path: string,\n query: string,\n hash: string,\n): Url {\n return {\n scheme,\n user,\n host,\n port,\n path,\n query,\n hash,\n type: UrlType.Absolute,\n };\n}\n\nfunction parseUrl(input: string): Url {\n if (isSchemeRelativeUrl(input)) {\n const url = parseAbsoluteUrl('http:' + input);\n url.scheme = '';\n url.type = UrlType.SchemeRelative;\n return url;\n }\n\n if (isAbsolutePath(input)) {\n const url = parseAbsoluteUrl('http://foo.com' + input);\n url.scheme = '';\n url.host = '';\n url.type = UrlType.AbsolutePath;\n return url;\n }\n\n if (isFileUrl(input)) return parseFileUrl(input);\n\n if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);\n\n const url = parseAbsoluteUrl('http://foo.com/' + input);\n url.scheme = '';\n url.host = '';\n url.type = input\n ? input.startsWith('?')\n ? UrlType.Query\n : input.startsWith('#')\n ? UrlType.Hash\n : UrlType.RelativePath\n : UrlType.Empty;\n return url;\n}\n\nfunction stripPathFilename(path: string): string {\n // If a path ends with a parent directory \"..\", then it's a relative path with excess parent\n // paths. It's not a file, so we can't strip it.\n if (path.endsWith('/..')) return path;\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n\nfunction mergePaths(url: Url, base: Url) {\n normalizePath(base, base.type);\n\n // If the path is just a \"/\", then it was an empty path to begin with (remember, we're a relative\n // path).\n if (url.path === '/') {\n url.path = base.path;\n } else {\n // Resolution happens relative to the base path's directory, not the file.\n url.path = stripPathFilename(base.path) + url.path;\n }\n}\n\n/**\n * The path can have empty directories \"//\", unneeded parents \"foo/..\", or current directory\n * \"foo/.\". We need to normalize to a standard representation.\n */\nfunction normalizePath(url: Url, type: UrlType) {\n const rel = type <= UrlType.RelativePath;\n const pieces = url.path.split('/');\n\n // We need to preserve the first piece always, so that we output a leading slash. The item at\n // pieces[0] is an empty string.\n let pointer = 1;\n\n // Positive is the number of real directories we've output, used for popping a parent directory.\n // Eg, \"foo/bar/..\" will have a positive 2, and we can decrement to be left with just \"foo\".\n let positive = 0;\n\n // We need to keep a trailing slash if we encounter an empty directory (eg, splitting \"foo/\" will\n // generate `[\"foo\", \"\"]` pieces). And, if we pop a parent directory. But once we encounter a\n // real directory, we won't need to append, unless the other conditions happen again.\n let addTrailingSlash = false;\n\n for (let i = 1; i < pieces.length; i++) {\n const piece = pieces[i];\n\n // An empty directory, could be a trailing slash, or just a double \"//\" in the path.\n if (!piece) {\n addTrailingSlash = true;\n continue;\n }\n\n // If we encounter a real directory, then we don't need to append anymore.\n addTrailingSlash = false;\n\n // A current directory, which we can always drop.\n if (piece === '.') continue;\n\n // A parent directory, we need to see if there are any real directories we can pop. Else, we\n // have an excess of parents, and we'll need to keep the \"..\".\n if (piece === '..') {\n if (positive) {\n addTrailingSlash = true;\n positive--;\n pointer--;\n } else if (rel) {\n // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute\n // URL, protocol relative URL, or an absolute path, we don't need to keep excess.\n pieces[pointer++] = piece;\n }\n continue;\n }\n\n // We've encountered a real directory. Move it to the next insertion pointer, which accounts for\n // any popped or dropped directories.\n pieces[pointer++] = piece;\n positive++;\n }\n\n let path = '';\n for (let i = 1; i < pointer; i++) {\n path += '/' + pieces[i];\n }\n if (!path || (addTrailingSlash && !path.endsWith('/..'))) {\n path += '/';\n }\n url.path = path;\n}\n\n/**\n * Attempts to resolve `input` URL/path relative to `base`.\n */\nexport default function resolve(input: string, base: string | undefined): string {\n if (!input && !base) return '';\n\n const url = parseUrl(input);\n let inputType = url.type;\n\n if (base && inputType !== UrlType.Absolute) {\n const baseUrl = parseUrl(base);\n const baseType = baseUrl.type;\n\n switch (inputType) {\n case UrlType.Empty:\n url.hash = baseUrl.hash;\n // fall through\n\n case UrlType.Hash:\n url.query = baseUrl.query;\n // fall through\n\n case UrlType.Query:\n case UrlType.RelativePath:\n mergePaths(url, baseUrl);\n // fall through\n\n case UrlType.AbsolutePath:\n // The host, user, and port are joined, you can't copy one without the others.\n url.user = baseUrl.user;\n url.host = baseUrl.host;\n url.port = baseUrl.port;\n // fall through\n\n case UrlType.SchemeRelative:\n // The input doesn't have a schema at least, so we need to copy at least that over.\n url.scheme = baseUrl.scheme;\n }\n if (baseType > inputType) inputType = baseType;\n }\n\n normalizePath(url, inputType);\n\n const queryHash = url.query + url.hash;\n switch (inputType) {\n // This is impossible, because of the empty checks at the start of the function.\n // case UrlType.Empty:\n\n case UrlType.Hash:\n case UrlType.Query:\n return queryHash;\n\n case UrlType.RelativePath: {\n // The first char is always a \"/\", and we need it to be relative.\n const path = url.path.slice(1);\n\n if (!path) return queryHash || '.';\n\n if (isRelative(base || input) && !isRelative(path)) {\n // If base started with a leading \".\", or there is no base and input started with a \".\",\n // then we need to ensure that the relative path starts with a \".\". We don't know if\n // relative starts with a \"..\", though, so check before prepending.\n return './' + path + queryHash;\n }\n\n return path + queryHash;\n }\n\n case UrlType.AbsolutePath:\n return url.path + queryHash;\n\n default:\n return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;\n }\n}\n"],"names":[],"mappings":"AAAA;AACA,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC;;;;;;;;;;AAUA,MAAM,QAAQ,GAAG,0EAA0E,CAAC;AAE5F;;;;;;;;;AASA,MAAM,SAAS,GAAG,iEAAiE,CAAC;AAapF,IAAK,OAQJ;AARD,WAAK,OAAO;IACV,uCAAS,CAAA;IACT,qCAAQ,CAAA;IACR,uCAAS,CAAA;IACT,qDAAgB,CAAA;IAChB,qDAAgB,CAAA;IAChB,yDAAkB,CAAA;IAClB,6CAAY,CAAA;AACd,CAAC,EARI,OAAO,KAAP,OAAO,QAQX;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,KAAK,GA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gBACxB,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;;YAG1B,KAAK,OAAO,CAAC,cAAc;;gBAEzB,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;SAC/B;QACD,IAAI,QAAQ,GAAG,SAAS;YAAE,SAAS,GAAG,QAAQ,CAAC;KAChD;IAED,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAE9B,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC;IACvC,QAAQ,SAAS;;;QAIf,KAAK,OAAO,CAAC,IAAI,CAAC;QAClB,KAAK,OAAO,CAAC,KAAK;YAChB,OAAO,SAAS,CAAC;QAEnB,KAAK,OAAO,CAAC,YAAY,EAAE;;YAEzB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAE/B,IAAI,CAAC,IAAI;gBAAE,OAAO,SAAS,IAAI,GAAG,CAAC;YAEnC,IAAI,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;;;;gBAIlD,OAAO,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;aAChC;YAED,OAAO,IAAI,GAAG,SAAS,CAAC;SACzB;QAED,KAAK,OAAO,CAAC,YAAY;YACvB,OAAO,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;QAE9B;YACE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;KACpF;AACH;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js new file mode 100644 index 000000000..0700a2d60 --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js @@ -0,0 +1,250 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.resolveURI = factory()); +})(this, (function () { 'use strict'; + + // Matches the scheme of a URL, eg "http://" + const schemeRegex = /^[\w+.-]+:\/\//; + /** + * Matches the parts of a URL: + * 1. Scheme, including ":", guaranteed. + * 2. User/password, including "@", optional. + * 3. Host, guaranteed. + * 4. Port, including ":", optional. + * 5. Path, including "/", optional. + * 6. Query, including "?", optional. + * 7. Hash, including "#", optional. + */ + const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/; + /** + * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start + * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive). + * + * 1. Host, optional. + * 2. Path, which may include "/", guaranteed. + * 3. Query, including "?", optional. + * 4. Hash, including "#", optional. + */ + const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i; + var UrlType; + (function (UrlType) { + UrlType[UrlType["Empty"] = 1] = "Empty"; + UrlType[UrlType["Hash"] = 2] = "Hash"; + UrlType[UrlType["Query"] = 3] = "Query"; + UrlType[UrlType["RelativePath"] = 4] = "RelativePath"; + UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath"; + UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative"; + UrlType[UrlType["Absolute"] = 7] = "Absolute"; + })(UrlType || (UrlType = {})); + function isAbsoluteUrl(input) { + return schemeRegex.test(input); + } + function isSchemeRelativeUrl(input) { + return input.startsWith('//'); + } + function isAbsolutePath(input) { + return input.startsWith('/'); + } + function isFileUrl(input) { + return input.startsWith('file:'); + } + function isRelative(input) { + return /^[.?#]/.test(input); + } + function parseAbsoluteUrl(input) { + const match = urlRegex.exec(input); + return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || ''); + } + function parseFileUrl(input) { + const match = fileRegex.exec(input); + const path = match[2]; + return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || ''); + } + function makeUrl(scheme, user, host, port, path, query, hash) { + return { + scheme, + user, + host, + port, + path, + query, + hash, + type: UrlType.Absolute, + }; + } + function parseUrl(input) { + if (isSchemeRelativeUrl(input)) { + const url = parseAbsoluteUrl('http:' + input); + url.scheme = ''; + url.type = UrlType.SchemeRelative; + return url; + } + if (isAbsolutePath(input)) { + const url = parseAbsoluteUrl('http://foo.com' + input); + url.scheme = ''; + url.host = ''; + url.type = UrlType.AbsolutePath; + return url; + } + if (isFileUrl(input)) + return parseFileUrl(input); + if (isAbsoluteUrl(input)) + return parseAbsoluteUrl(input); + const url = parseAbsoluteUrl('http://foo.com/' + input); + url.scheme = ''; + url.host = ''; + url.type = input + ? input.startsWith('?') + ? UrlType.Query + : input.startsWith('#') + ? UrlType.Hash + : UrlType.RelativePath + : UrlType.Empty; + return url; + } + function stripPathFilename(path) { + // If a path ends with a parent directory "..", then it's a relative path with excess parent + // paths. It's not a file, so we can't strip it. + if (path.endsWith('/..')) + return path; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); + } + function mergePaths(url, base) { + normalizePath(base, base.type); + // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative + // path). + if (url.path === '/') { + url.path = base.path; + } + else { + // Resolution happens relative to the base path's directory, not the file. + url.path = stripPathFilename(base.path) + url.path; + } + } + /** + * The path can have empty directories "//", unneeded parents "foo/..", or current directory + * "foo/.". We need to normalize to a standard representation. + */ + function normalizePath(url, type) { + const rel = type <= UrlType.RelativePath; + const pieces = url.path.split('/'); + // We need to preserve the first piece always, so that we output a leading slash. The item at + // pieces[0] is an empty string. + let pointer = 1; + // Positive is the number of real directories we've output, used for popping a parent directory. + // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo". + let positive = 0; + // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will + // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a + // real directory, we won't need to append, unless the other conditions happen again. + let addTrailingSlash = false; + for (let i = 1; i < pieces.length; i++) { + const piece = pieces[i]; + // An empty directory, could be a trailing slash, or just a double "//" in the path. + if (!piece) { + addTrailingSlash = true; + continue; + } + // If we encounter a real directory, then we don't need to append anymore. + addTrailingSlash = false; + // A current directory, which we can always drop. + if (piece === '.') + continue; + // A parent directory, we need to see if there are any real directories we can pop. Else, we + // have an excess of parents, and we'll need to keep the "..". + if (piece === '..') { + if (positive) { + addTrailingSlash = true; + positive--; + pointer--; + } + else if (rel) { + // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute + // URL, protocol relative URL, or an absolute path, we don't need to keep excess. + pieces[pointer++] = piece; + } + continue; + } + // We've encountered a real directory. Move it to the next insertion pointer, which accounts for + // any popped or dropped directories. + pieces[pointer++] = piece; + positive++; + } + let path = ''; + for (let i = 1; i < pointer; i++) { + path += '/' + pieces[i]; + } + if (!path || (addTrailingSlash && !path.endsWith('/..'))) { + path += '/'; + } + url.path = path; + } + /** + * Attempts to resolve `input` URL/path relative to `base`. + */ + function resolve(input, base) { + if (!input && !base) + return ''; + const url = parseUrl(input); + let inputType = url.type; + if (base && inputType !== UrlType.Absolute) { + const baseUrl = parseUrl(base); + const baseType = baseUrl.type; + switch (inputType) { + case UrlType.Empty: + url.hash = baseUrl.hash; + // fall through + case UrlType.Hash: + url.query = baseUrl.query; + // fall through + case UrlType.Query: + case UrlType.RelativePath: + mergePaths(url, baseUrl); + // fall through + case UrlType.AbsolutePath: + // The host, user, and port are joined, you can't copy one without the others. + url.user = baseUrl.user; + url.host = baseUrl.host; + url.port = baseUrl.port; + // fall through + case UrlType.SchemeRelative: + // The input doesn't have a schema at least, so we need to copy at least that over. + url.scheme = baseUrl.scheme; + } + if (baseType > inputType) + inputType = baseType; + } + normalizePath(url, inputType); + const queryHash = url.query + url.hash; + switch (inputType) { + // This is impossible, because of the empty checks at the start of the function. + // case UrlType.Empty: + case UrlType.Hash: + case UrlType.Query: + return queryHash; + case UrlType.RelativePath: { + // The first char is always a "/", and we need it to be relative. + const path = url.path.slice(1); + if (!path) + return queryHash || '.'; + if (isRelative(base || input) && !isRelative(path)) { + // If base started with a leading ".", or there is no base and input started with a ".", + // then we need to ensure that the relative path starts with a ".". We don't know if + // relative starts with a "..", though, so check before prepending. + return './' + path + queryHash; + } + return path + queryHash; + } + case UrlType.AbsolutePath: + return url.path + queryHash; + default: + return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash; + } + } + + return resolve; + +})); +//# sourceMappingURL=resolve-uri.umd.js.map diff --git a/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map new file mode 100644 index 000000000..a3e39ebad --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"resolve-uri.umd.js","sources":["../src/resolve-uri.ts"],"sourcesContent":["// Matches the scheme of a URL, eg \"http://\"\nconst schemeRegex = /^[\\w+.-]+:\\/\\//;\n\n/**\n * Matches the parts of a URL:\n * 1. Scheme, including \":\", guaranteed.\n * 2. User/password, including \"@\", optional.\n * 3. Host, guaranteed.\n * 4. Port, including \":\", optional.\n * 5. Path, including \"/\", optional.\n * 6. Query, including \"?\", optional.\n * 7. Hash, including \"#\", optional.\n */\nconst urlRegex = /^([\\w+.-]+:)\\/\\/([^@/#?]*@)?([^:/#?]*)(:\\d+)?(\\/[^#?]*)?(\\?[^#]*)?(#.*)?/;\n\n/**\n * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start\n * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).\n *\n * 1. Host, optional.\n * 2. Path, which may include \"/\", guaranteed.\n * 3. Query, including \"?\", optional.\n * 4. Hash, including \"#\", optional.\n */\nconst fileRegex = /^file:(?:\\/\\/((?![a-z]:)[^/#?]*)?)?(\\/?[^#?]*)(\\?[^#]*)?(#.*)?/i;\n\ntype Url = {\n scheme: string;\n user: string;\n host: string;\n port: string;\n path: string;\n query: string;\n hash: string;\n type: UrlType;\n};\n\nenum UrlType {\n Empty = 1,\n Hash = 2,\n Query = 3,\n RelativePath = 4,\n AbsolutePath = 5,\n SchemeRelative = 6,\n Absolute = 7,\n}\n\nfunction isAbsoluteUrl(input: string): boolean {\n return schemeRegex.test(input);\n}\n\nfunction isSchemeRelativeUrl(input: string): boolean {\n return input.startsWith('//');\n}\n\nfunction isAbsolutePath(input: string): boolean {\n return input.startsWith('/');\n}\n\nfunction isFileUrl(input: string): boolean {\n return input.startsWith('file:');\n}\n\nfunction isRelative(input: string): boolean {\n return /^[.?#]/.test(input);\n}\n\nfunction parseAbsoluteUrl(input: string): Url {\n const match = urlRegex.exec(input)!;\n return makeUrl(\n match[1],\n match[2] || '',\n match[3],\n match[4] || '',\n match[5] || '/',\n match[6] || '',\n match[7] || '',\n );\n}\n\nfunction parseFileUrl(input: string): Url {\n const match = fileRegex.exec(input)!;\n const path = match[2];\n return makeUrl(\n 'file:',\n '',\n match[1] || '',\n '',\n isAbsolutePath(path) ? path : '/' + path,\n match[3] || '',\n match[4] || '',\n );\n}\n\nfunction makeUrl(\n scheme: string,\n user: string,\n host: string,\n port: string,\n path: string,\n query: string,\n hash: string,\n): Url {\n return {\n scheme,\n user,\n host,\n port,\n path,\n query,\n hash,\n type: UrlType.Absolute,\n };\n}\n\nfunction parseUrl(input: string): Url {\n if (isSchemeRelativeUrl(input)) {\n const url = parseAbsoluteUrl('http:' + input);\n url.scheme = '';\n url.type = UrlType.SchemeRelative;\n return url;\n }\n\n if (isAbsolutePath(input)) {\n const url = parseAbsoluteUrl('http://foo.com' + input);\n url.scheme = '';\n url.host = '';\n url.type = UrlType.AbsolutePath;\n return url;\n }\n\n if (isFileUrl(input)) return parseFileUrl(input);\n\n if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);\n\n const url = parseAbsoluteUrl('http://foo.com/' + input);\n url.scheme = '';\n url.host = '';\n url.type = input\n ? input.startsWith('?')\n ? UrlType.Query\n : input.startsWith('#')\n ? UrlType.Hash\n : UrlType.RelativePath\n : UrlType.Empty;\n return url;\n}\n\nfunction stripPathFilename(path: string): string {\n // If a path ends with a parent directory \"..\", then it's a relative path with excess parent\n // paths. It's not a file, so we can't strip it.\n if (path.endsWith('/..')) return path;\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n\nfunction mergePaths(url: Url, base: Url) {\n normalizePath(base, base.type);\n\n // If the path is just a \"/\", then it was an empty path to begin with (remember, we're a relative\n // path).\n if (url.path === '/') {\n url.path = base.path;\n } else {\n // Resolution happens relative to the base path's directory, not the file.\n url.path = stripPathFilename(base.path) + url.path;\n }\n}\n\n/**\n * The path can have empty directories \"//\", unneeded parents \"foo/..\", or current directory\n * \"foo/.\". We need to normalize to a standard representation.\n */\nfunction normalizePath(url: Url, type: UrlType) {\n const rel = type <= UrlType.RelativePath;\n const pieces = url.path.split('/');\n\n // We need to preserve the first piece always, so that we output a leading slash. The item at\n // pieces[0] is an empty string.\n let pointer = 1;\n\n // Positive is the number of real directories we've output, used for popping a parent directory.\n // Eg, \"foo/bar/..\" will have a positive 2, and we can decrement to be left with just \"foo\".\n let positive = 0;\n\n // We need to keep a trailing slash if we encounter an empty directory (eg, splitting \"foo/\" will\n // generate `[\"foo\", \"\"]` pieces). And, if we pop a parent directory. But once we encounter a\n // real directory, we won't need to append, unless the other conditions happen again.\n let addTrailingSlash = false;\n\n for (let i = 1; i < pieces.length; i++) {\n const piece = pieces[i];\n\n // An empty directory, could be a trailing slash, or just a double \"//\" in the path.\n if (!piece) {\n addTrailingSlash = true;\n continue;\n }\n\n // If we encounter a real directory, then we don't need to append anymore.\n addTrailingSlash = false;\n\n // A current directory, which we can always drop.\n if (piece === '.') continue;\n\n // A parent directory, we need to see if there are any real directories we can pop. Else, we\n // have an excess of parents, and we'll need to keep the \"..\".\n if (piece === '..') {\n if (positive) {\n addTrailingSlash = true;\n positive--;\n pointer--;\n } else if (rel) {\n // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute\n // URL, protocol relative URL, or an absolute path, we don't need to keep excess.\n pieces[pointer++] = piece;\n }\n continue;\n }\n\n // We've encountered a real directory. Move it to the next insertion pointer, which accounts for\n // any popped or dropped directories.\n pieces[pointer++] = piece;\n positive++;\n }\n\n let path = '';\n for (let i = 1; i < pointer; i++) {\n path += '/' + pieces[i];\n }\n if (!path || (addTrailingSlash && !path.endsWith('/..'))) {\n path += '/';\n }\n url.path = path;\n}\n\n/**\n * Attempts to resolve `input` URL/path relative to `base`.\n */\nexport default function resolve(input: string, base: string | undefined): string {\n if (!input && !base) return '';\n\n const url = parseUrl(input);\n let inputType = url.type;\n\n if (base && inputType !== UrlType.Absolute) {\n const baseUrl = parseUrl(base);\n const baseType = baseUrl.type;\n\n switch (inputType) {\n case UrlType.Empty:\n url.hash = baseUrl.hash;\n // fall through\n\n case UrlType.Hash:\n url.query = baseUrl.query;\n // fall through\n\n case UrlType.Query:\n case UrlType.RelativePath:\n mergePaths(url, baseUrl);\n // fall through\n\n case UrlType.AbsolutePath:\n // The host, user, and port are joined, you can't copy one without the others.\n url.user = baseUrl.user;\n url.host = baseUrl.host;\n url.port = baseUrl.port;\n // fall through\n\n case UrlType.SchemeRelative:\n // The input doesn't have a schema at least, so we need to copy at least that over.\n url.scheme = baseUrl.scheme;\n }\n if (baseType > inputType) inputType = baseType;\n }\n\n normalizePath(url, inputType);\n\n const queryHash = url.query + url.hash;\n switch (inputType) {\n // This is impossible, because of the empty checks at the start of the function.\n // case UrlType.Empty:\n\n case UrlType.Hash:\n case UrlType.Query:\n return queryHash;\n\n case UrlType.RelativePath: {\n // The first char is always a \"/\", and we need it to be relative.\n const path = url.path.slice(1);\n\n if (!path) return queryHash || '.';\n\n if (isRelative(base || input) && !isRelative(path)) {\n // If base started with a leading \".\", or there is no base and input started with a \".\",\n // then we need to ensure that the relative path starts with a \".\". We don't know if\n // relative starts with a \"..\", though, so check before prepending.\n return './' + path + queryHash;\n }\n\n return path + queryHash;\n }\n\n case UrlType.AbsolutePath:\n return url.path + queryHash;\n\n default:\n return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;\n }\n}\n"],"names":[],"mappings":";;;;;;IAAA;IACA,MAAM,WAAW,GAAG,gBAAgB,CAAC;IAErC;;;;;;;;;;IAUA,MAAM,QAAQ,GAAG,0EAA0E,CAAC;IAE5F;;;;;;;;;IASA,MAAM,SAAS,GAAG,iEAAiE,CAAC;IAapF,IAAK,OAQJ;IARD,WAAK,OAAO;QACV,uCAAS,CAAA;QACT,qCAAQ,CAAA;QACR,uCAAS,CAAA;QACT,qDAAgB,CAAA;QAChB,qDAAgB,CAAA;QAChB,yDAAkB,CAAA;QAClB,6CAAY,CAAA;IACd,CAAC,EARI,OAAO,KAAP,OAAO,QAQX;IAED,SAAS,aAAa,CAAC,KAAa;QAClC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,SAAS,mBAAmB,CAAC,KAAa;QACxC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,cAAc,CAAC,KAAa;QACnC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,SAAS,CAAC,KAAa;QAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,SAAS,UAAU,CAAC,KAAa;QAC/B,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,gBAAgB,CAAC,KAAa;QACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAE,CAAC;QACpC,OAAO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C,IAAI,CAAC;;gBAG1B,KAAK,OAAO,CAAC,cAAc;;oBAEzB,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;aAC/B;YACD,IAAI,QAAQ,GAAG,SAAS;gBAAE,SAAS,GAAG,QAAQ,CAAC;SAChD;QAED,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAE9B,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC;QACvC,QAAQ,SAAS;;;YAIf,KAAK,OAAO,CAAC,IAAI,CAAC;YAClB,KAAK,OAAO,CAAC,KAAK;gBAChB,OAAO,SAAS,CAAC;YAEnB,KAAK,OAAO,CAAC,YAAY,EAAE;;gBAEzB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE/B,IAAI,CAAC,IAAI;oBAAE,OAAO,SAAS,IAAI,GAAG,CAAC;gBAEnC,IAAI,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;;;;oBAIlD,OAAO,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;iBAChC;gBAED,OAAO,IAAI,GAAG,SAAS,CAAC;aACzB;YAED,KAAK,OAAO,CAAC,YAAY;gBACvB,OAAO,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;YAE9B;gBACE,OAAO,GAAG,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;SACpF;IACH;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts b/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts new file mode 100644 index 000000000..b7f0b3b2d --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts @@ -0,0 +1,4 @@ +/** + * Attempts to resolve `input` URL/path relative to `base`. + */ +export default function resolve(input: string, base: string | undefined): string; diff --git a/node_modules/@jridgewell/resolve-uri/package.json b/node_modules/@jridgewell/resolve-uri/package.json new file mode 100644 index 000000000..6bffa7b7a --- /dev/null +++ b/node_modules/@jridgewell/resolve-uri/package.json @@ -0,0 +1,69 @@ +{ + "name": "@jridgewell/resolve-uri", + "version": "3.1.1", + "description": "Resolve a URI relative to an optional base URI", + "keywords": [ + "resolve", + "uri", + "url", + "path" + ], + "author": "Justin Ridgewell ", + "license": "MIT", + "repository": "https://github.com/jridgewell/resolve-uri", + "main": "dist/resolve-uri.umd.js", + "module": "dist/resolve-uri.mjs", + "types": "dist/types/resolve-uri.d.ts", + "exports": { + ".": [ + { + "types": "./dist/types/resolve-uri.d.ts", + "browser": "./dist/resolve-uri.umd.js", + "require": "./dist/resolve-uri.umd.js", + "import": "./dist/resolve-uri.mjs" + }, + "./dist/resolve-uri.umd.js" + ], + "./package.json": "./package.json" + }, + "files": [ + "dist" + ], + "engines": { + "node": ">=6.0.0" + }, + "scripts": { + "prebuild": "rm -rf dist", + "build": "run-s -n build:*", + "build:rollup": "rollup -c rollup.config.js", + "build:ts": "tsc --project tsconfig.build.json", + "lint": "run-s -n lint:*", + "lint:prettier": "npm run test:lint:prettier -- --write", + "lint:ts": "npm run test:lint:ts -- --fix", + "pretest": "run-s build:rollup", + "test": "run-s -n test:lint test:only", + "test:debug": "mocha --inspect-brk", + "test:lint": "run-s -n test:lint:*", + "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", + "test:lint:ts": "eslint '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:coverage": "c8 mocha", + "test:watch": "mocha --watch", + "prepublishOnly": "npm run preversion", + "preversion": "run-s test build" + }, + "devDependencies": { + "@jridgewell/resolve-uri-latest": "npm:@jridgewell/resolve-uri@*", + "@rollup/plugin-typescript": "8.3.0", + "@typescript-eslint/eslint-plugin": "5.10.0", + "@typescript-eslint/parser": "5.10.0", + "c8": "7.11.0", + "eslint": "8.7.0", + "eslint-config-prettier": "8.3.0", + "mocha": "9.2.0", + "npm-run-all": "4.1.5", + "prettier": "2.5.1", + "rollup": "2.66.0", + "typescript": "4.5.5" + } +} diff --git a/node_modules/@jridgewell/set-array/LICENSE b/node_modules/@jridgewell/set-array/LICENSE new file mode 100644 index 000000000..352f0715f --- /dev/null +++ b/node_modules/@jridgewell/set-array/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/set-array/README.md b/node_modules/@jridgewell/set-array/README.md new file mode 100644 index 000000000..2ed155ff7 --- /dev/null +++ b/node_modules/@jridgewell/set-array/README.md @@ -0,0 +1,37 @@ +# @jridgewell/set-array + +> Like a Set, but provides the index of the `key` in the backing array + +This is designed to allow synchronizing a second array with the contents of the backing array, like +how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, and there +are never duplicates. + +## Installation + +```sh +npm install @jridgewell/set-array +``` + +## Usage + +```js +import { SetArray, get, put, pop } from '@jridgewell/set-array'; + +const sa = new SetArray(); + +let index = put(sa, 'first'); +assert.strictEqual(index, 0); + +index = put(sa, 'second'); +assert.strictEqual(index, 1); + +assert.deepEqual(sa.array, [ 'first', 'second' ]); + +index = get(sa, 'first'); +assert.strictEqual(index, 0); + +pop(sa); +index = get(sa, 'second'); +assert.strictEqual(index, undefined); +assert.deepEqual(sa.array, [ 'first' ]); +``` diff --git a/node_modules/@jridgewell/set-array/dist/set-array.mjs b/node_modules/@jridgewell/set-array/dist/set-array.mjs new file mode 100644 index 000000000..b7f1a9cc6 --- /dev/null +++ b/node_modules/@jridgewell/set-array/dist/set-array.mjs @@ -0,0 +1,48 @@ +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +let get; +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +let put; +/** + * Pops the last added item out of the SetArray. + */ +let pop; +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +class SetArray { + constructor() { + this._indexes = { __proto__: null }; + this.array = []; + } +} +(() => { + get = (strarr, key) => strarr._indexes[key]; + put = (strarr, key) => { + // The key may or may not be present. If it is present, it's a number. + const index = get(strarr, key); + if (index !== undefined) + return index; + const { array, _indexes: indexes } = strarr; + return (indexes[key] = array.push(key) - 1); + }; + pop = (strarr) => { + const { array, _indexes: indexes } = strarr; + if (array.length === 0) + return; + const last = array.pop(); + indexes[last] = undefined; + }; +})(); + +export { SetArray, get, pop, put }; +//# sourceMappingURL=set-array.mjs.map diff --git a/node_modules/@jridgewell/set-array/dist/set-array.mjs.map b/node_modules/@jridgewell/set-array/dist/set-array.mjs.map new file mode 100644 index 000000000..ead56431a --- /dev/null +++ b/node_modules/@jridgewell/set-array/dist/set-array.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"set-array.mjs","sources":["../src/set-array.ts"],"sourcesContent":["/**\n * Gets the index associated with `key` in the backing array, if it is already present.\n */\nexport let get: (strarr: SetArray, key: string) => number | undefined;\n\n/**\n * Puts `key` into the backing array, if it is not already present. Returns\n * the index of the `key` in the backing array.\n */\nexport let put: (strarr: SetArray, key: string) => number;\n\n/**\n * Pops the last added item out of the SetArray.\n */\nexport let pop: (strarr: SetArray) => void;\n\n/**\n * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the\n * index of the `key` in the backing array.\n *\n * This is designed to allow synchronizing a second array with the contents of the backing array,\n * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`,\n * and there are never duplicates.\n */\nexport class SetArray {\n private declare _indexes: { [key: string]: number | undefined };\n declare array: readonly string[];\n\n constructor() {\n this._indexes = { __proto__: null } as any;\n this.array = [];\n }\n\n static {\n get = (strarr, key) => strarr._indexes[key];\n\n put = (strarr, key) => {\n // The key may or may not be present. If it is present, it's a number.\n const index = get(strarr, key);\n if (index !== undefined) return index;\n\n const { array, _indexes: indexes } = strarr;\n\n return (indexes[key] = (array as string[]).push(key) - 1);\n };\n\n pop = (strarr) => {\n const { array, _indexes: indexes } = strarr;\n if (array.length === 0) return;\n\n const last = (array as string[]).pop()!;\n indexes[last] = undefined;\n };\n }\n}\n"],"names":[],"mappings":"AAAA;;;IAGW,IAA2D;AAEtE;;;;IAIW,IAA+C;AAE1D;;;IAGW,IAAgC;AAE3C;;;;;;;;MAQa,QAAQ;IAInB;QACE,IAAI,CAAC,QAAQ,GAAG,EAAE,SAAS,EAAE,IAAI,EAAS,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;KACjB;CAuBF;AArBC;IACE,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE5C,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG;;QAEhB,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAEtC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAE5C,QAAQ,OAAO,CAAC,GAAG,CAAC,GAAI,KAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;KAC3D,CAAC;IAEF,GAAG,GAAG,CAAC,MAAM;QACX,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAC5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAE/B,MAAM,IAAI,GAAI,KAAkB,CAAC,GAAG,EAAG,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;KAC3B,CAAC;AACJ,CAAC,GAAA;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/set-array/dist/set-array.umd.js b/node_modules/@jridgewell/set-array/dist/set-array.umd.js new file mode 100644 index 000000000..a1c200a1c --- /dev/null +++ b/node_modules/@jridgewell/set-array/dist/set-array.umd.js @@ -0,0 +1,58 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.setArray = {})); +})(this, (function (exports) { 'use strict'; + + /** + * Gets the index associated with `key` in the backing array, if it is already present. + */ + exports.get = void 0; + /** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ + exports.put = void 0; + /** + * Pops the last added item out of the SetArray. + */ + exports.pop = void 0; + /** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ + class SetArray { + constructor() { + this._indexes = { __proto__: null }; + this.array = []; + } + } + (() => { + exports.get = (strarr, key) => strarr._indexes[key]; + exports.put = (strarr, key) => { + // The key may or may not be present. If it is present, it's a number. + const index = exports.get(strarr, key); + if (index !== undefined) + return index; + const { array, _indexes: indexes } = strarr; + return (indexes[key] = array.push(key) - 1); + }; + exports.pop = (strarr) => { + const { array, _indexes: indexes } = strarr; + if (array.length === 0) + return; + const last = array.pop(); + indexes[last] = undefined; + }; + })(); + + exports.SetArray = SetArray; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); +//# sourceMappingURL=set-array.umd.js.map diff --git a/node_modules/@jridgewell/set-array/dist/set-array.umd.js.map b/node_modules/@jridgewell/set-array/dist/set-array.umd.js.map new file mode 100644 index 000000000..10005af88 --- /dev/null +++ b/node_modules/@jridgewell/set-array/dist/set-array.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"set-array.umd.js","sources":["../src/set-array.ts"],"sourcesContent":["/**\n * Gets the index associated with `key` in the backing array, if it is already present.\n */\nexport let get: (strarr: SetArray, key: string) => number | undefined;\n\n/**\n * Puts `key` into the backing array, if it is not already present. Returns\n * the index of the `key` in the backing array.\n */\nexport let put: (strarr: SetArray, key: string) => number;\n\n/**\n * Pops the last added item out of the SetArray.\n */\nexport let pop: (strarr: SetArray) => void;\n\n/**\n * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the\n * index of the `key` in the backing array.\n *\n * This is designed to allow synchronizing a second array with the contents of the backing array,\n * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`,\n * and there are never duplicates.\n */\nexport class SetArray {\n private declare _indexes: { [key: string]: number | undefined };\n declare array: readonly string[];\n\n constructor() {\n this._indexes = { __proto__: null } as any;\n this.array = [];\n }\n\n static {\n get = (strarr, key) => strarr._indexes[key];\n\n put = (strarr, key) => {\n // The key may or may not be present. If it is present, it's a number.\n const index = get(strarr, key);\n if (index !== undefined) return index;\n\n const { array, _indexes: indexes } = strarr;\n\n return (indexes[key] = (array as string[]).push(key) - 1);\n };\n\n pop = (strarr) => {\n const { array, _indexes: indexes } = strarr;\n if (array.length === 0) return;\n\n const last = (array as string[]).pop()!;\n indexes[last] = undefined;\n };\n }\n}\n"],"names":["get","put","pop"],"mappings":";;;;;;IAAA;;;AAGWA,yBAA2D;IAEtE;;;;AAIWC,yBAA+C;IAE1D;;;AAGWC,yBAAgC;IAE3C;;;;;;;;UAQa,QAAQ;QAInB;YACE,IAAI,CAAC,QAAQ,GAAG,EAAE,SAAS,EAAE,IAAI,EAAS,CAAC;YAC3C,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;SACjB;KAuBF;IArBC;QACEF,WAAG,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAE5CC,WAAG,GAAG,CAAC,MAAM,EAAE,GAAG;;YAEhB,MAAM,KAAK,GAAGD,WAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC/B,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAC;YAEtC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;YAE5C,QAAQ,OAAO,CAAC,GAAG,CAAC,GAAI,KAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;SAC3D,CAAC;QAEFE,WAAG,GAAG,CAAC,MAAM;YACX,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;YAC5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO;YAE/B,MAAM,IAAI,GAAI,KAAkB,CAAC,GAAG,EAAG,CAAC;YACxC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;SAC3B,CAAC;IACJ,CAAC,GAAA;;;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/set-array/dist/types/set-array.d.ts b/node_modules/@jridgewell/set-array/dist/types/set-array.d.ts new file mode 100644 index 000000000..7ed59b966 --- /dev/null +++ b/node_modules/@jridgewell/set-array/dist/types/set-array.d.ts @@ -0,0 +1,26 @@ +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export declare let get: (strarr: SetArray, key: string) => number | undefined; +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export declare let put: (strarr: SetArray, key: string) => number; +/** + * Pops the last added item out of the SetArray. + */ +export declare let pop: (strarr: SetArray) => void; +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export declare class SetArray { + private _indexes; + array: readonly string[]; + constructor(); +} diff --git a/node_modules/@jridgewell/set-array/package.json b/node_modules/@jridgewell/set-array/package.json new file mode 100644 index 000000000..aec4ee029 --- /dev/null +++ b/node_modules/@jridgewell/set-array/package.json @@ -0,0 +1,66 @@ +{ + "name": "@jridgewell/set-array", + "version": "1.1.2", + "description": "Like a Set, but provides the index of the `key` in the backing array", + "keywords": [], + "author": "Justin Ridgewell ", + "license": "MIT", + "repository": "https://github.com/jridgewell/set-array", + "main": "dist/set-array.umd.js", + "module": "dist/set-array.mjs", + "typings": "dist/types/set-array.d.ts", + "exports": { + ".": [ + { + "types": "./dist/types/set-array.d.ts", + "browser": "./dist/set-array.umd.js", + "require": "./dist/set-array.umd.js", + "import": "./dist/set-array.mjs" + }, + "./dist/set-array.umd.js" + ], + "./package.json": "./package.json" + }, + "files": [ + "dist", + "src" + ], + "engines": { + "node": ">=6.0.0" + }, + "scripts": { + "prebuild": "rm -rf dist", + "build": "run-s -n build:*", + "build:rollup": "rollup -c rollup.config.js", + "build:ts": "tsc --project tsconfig.build.json", + "lint": "run-s -n lint:*", + "lint:prettier": "npm run test:lint:prettier -- --write", + "lint:ts": "npm run test:lint:ts -- --fix", + "pretest": "run-s build:rollup", + "test": "run-s -n test:lint test:only", + "test:debug": "mocha --inspect-brk", + "test:lint": "run-s -n test:lint:*", + "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", + "test:lint:ts": "eslint '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:coverage": "c8 mocha", + "test:watch": "mocha --watch", + "prepublishOnly": "npm run preversion", + "preversion": "run-s test build" + }, + "devDependencies": { + "@rollup/plugin-typescript": "8.3.0", + "@types/mocha": "9.1.1", + "@types/node": "17.0.29", + "@typescript-eslint/eslint-plugin": "5.10.0", + "@typescript-eslint/parser": "5.10.0", + "c8": "7.11.0", + "eslint": "8.7.0", + "eslint-config-prettier": "8.3.0", + "mocha": "9.2.0", + "npm-run-all": "4.1.5", + "prettier": "2.5.1", + "rollup": "2.66.0", + "typescript": "4.5.5" + } +} diff --git a/node_modules/@jridgewell/set-array/src/set-array.ts b/node_modules/@jridgewell/set-array/src/set-array.ts new file mode 100644 index 000000000..f9ff60427 --- /dev/null +++ b/node_modules/@jridgewell/set-array/src/set-array.ts @@ -0,0 +1,55 @@ +/** + * Gets the index associated with `key` in the backing array, if it is already present. + */ +export let get: (strarr: SetArray, key: string) => number | undefined; + +/** + * Puts `key` into the backing array, if it is not already present. Returns + * the index of the `key` in the backing array. + */ +export let put: (strarr: SetArray, key: string) => number; + +/** + * Pops the last added item out of the SetArray. + */ +export let pop: (strarr: SetArray) => void; + +/** + * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the + * index of the `key` in the backing array. + * + * This is designed to allow synchronizing a second array with the contents of the backing array, + * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, + * and there are never duplicates. + */ +export class SetArray { + private declare _indexes: { [key: string]: number | undefined }; + declare array: readonly string[]; + + constructor() { + this._indexes = { __proto__: null } as any; + this.array = []; + } + + static { + get = (strarr, key) => strarr._indexes[key]; + + put = (strarr, key) => { + // The key may or may not be present. If it is present, it's a number. + const index = get(strarr, key); + if (index !== undefined) return index; + + const { array, _indexes: indexes } = strarr; + + return (indexes[key] = (array as string[]).push(key) - 1); + }; + + pop = (strarr) => { + const { array, _indexes: indexes } = strarr; + if (array.length === 0) return; + + const last = (array as string[]).pop()!; + indexes[last] = undefined; + }; + } +} diff --git a/node_modules/@jridgewell/sourcemap-codec/LICENSE b/node_modules/@jridgewell/sourcemap-codec/LICENSE new file mode 100644 index 000000000..a331065a4 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2015 Rich Harris + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/@jridgewell/sourcemap-codec/README.md b/node_modules/@jridgewell/sourcemap-codec/README.md new file mode 100644 index 000000000..5cbb31525 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/README.md @@ -0,0 +1,200 @@ +# @jridgewell/sourcemap-codec + +Encode/decode the `mappings` property of a [sourcemap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit). + + +## Why? + +Sourcemaps are difficult to generate and manipulate, because the `mappings` property – the part that actually links the generated code back to the original source – is encoded using an obscure method called [Variable-length quantity](https://en.wikipedia.org/wiki/Variable-length_quantity). On top of that, each segment in the mapping contains offsets rather than absolute indices, which means that you can't look at a segment in isolation – you have to understand the whole sourcemap. + +This package makes the process slightly easier. + + +## Installation + +```bash +npm install @jridgewell/sourcemap-codec +``` + + +## Usage + +```js +import { encode, decode } from '@jridgewell/sourcemap-codec'; + +var decoded = decode( ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' ); + +assert.deepEqual( decoded, [ + // the first line (of the generated code) has no mappings, + // as shown by the starting semi-colon (which separates lines) + [], + + // the second line contains four (comma-separated) segments + [ + // segments are encoded as you'd expect: + // [ generatedCodeColumn, sourceIndex, sourceCodeLine, sourceCodeColumn, nameIndex ] + + // i.e. the first segment begins at column 2, and maps back to the second column + // of the second line (both zero-based) of the 0th source, and uses the 0th + // name in the `map.names` array + [ 2, 0, 2, 2, 0 ], + + // the remaining segments are 4-length rather than 5-length, + // because they don't map a name + [ 4, 0, 2, 4 ], + [ 6, 0, 2, 5 ], + [ 7, 0, 2, 7 ] + ], + + // the final line contains two segments + [ + [ 2, 1, 10, 19 ], + [ 12, 1, 11, 20 ] + ] +]); + +var encoded = encode( decoded ); +assert.equal( encoded, ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' ); +``` + +## Benchmarks + +``` +node v18.0.0 + +amp.js.map - 45120 segments + +Decode Memory Usage: +@jridgewell/sourcemap-codec 5479160 bytes +sourcemap-codec 5659336 bytes +source-map-0.6.1 17144440 bytes +source-map-0.8.0 6867424 bytes +Smallest memory usage is @jridgewell/sourcemap-codec + +Decode speed: +decode: @jridgewell/sourcemap-codec x 502 ops/sec ±1.03% (90 runs sampled) +decode: sourcemap-codec x 445 ops/sec ±0.97% (92 runs sampled) +decode: source-map-0.6.1 x 36.01 ops/sec ±1.64% (49 runs sampled) +decode: source-map-0.8.0 x 367 ops/sec ±0.04% (95 runs sampled) +Fastest is decode: @jridgewell/sourcemap-codec + +Encode Memory Usage: +@jridgewell/sourcemap-codec 1261620 bytes +sourcemap-codec 9119248 bytes +source-map-0.6.1 8968560 bytes +source-map-0.8.0 8952952 bytes +Smallest memory usage is @jridgewell/sourcemap-codec + +Encode speed: +encode: @jridgewell/sourcemap-codec x 738 ops/sec ±0.42% (98 runs sampled) +encode: sourcemap-codec x 238 ops/sec ±0.73% (88 runs sampled) +encode: source-map-0.6.1 x 162 ops/sec ±0.43% (84 runs sampled) +encode: source-map-0.8.0 x 191 ops/sec ±0.34% (90 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec + + +*** + + +babel.min.js.map - 347793 segments + +Decode Memory Usage: +@jridgewell/sourcemap-codec 35338184 bytes +sourcemap-codec 35922736 bytes +source-map-0.6.1 62366360 bytes +source-map-0.8.0 44337416 bytes +Smallest memory usage is @jridgewell/sourcemap-codec + +Decode speed: +decode: @jridgewell/sourcemap-codec x 40.35 ops/sec ±4.47% (54 runs sampled) +decode: sourcemap-codec x 36.76 ops/sec ±3.67% (51 runs sampled) +decode: source-map-0.6.1 x 4.44 ops/sec ±2.15% (16 runs sampled) +decode: source-map-0.8.0 x 59.35 ops/sec ±0.05% (78 runs sampled) +Fastest is decode: source-map-0.8.0 + +Encode Memory Usage: +@jridgewell/sourcemap-codec 7212604 bytes +sourcemap-codec 21421456 bytes +source-map-0.6.1 25286888 bytes +source-map-0.8.0 25498744 bytes +Smallest memory usage is @jridgewell/sourcemap-codec + +Encode speed: +encode: @jridgewell/sourcemap-codec x 112 ops/sec ±0.13% (84 runs sampled) +encode: sourcemap-codec x 30.23 ops/sec ±2.76% (53 runs sampled) +encode: source-map-0.6.1 x 19.43 ops/sec ±3.70% (37 runs sampled) +encode: source-map-0.8.0 x 19.40 ops/sec ±3.26% (37 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec + + +*** + + +preact.js.map - 1992 segments + +Decode Memory Usage: +@jridgewell/sourcemap-codec 500272 bytes +sourcemap-codec 516864 bytes +source-map-0.6.1 1596672 bytes +source-map-0.8.0 517272 bytes +Smallest memory usage is @jridgewell/sourcemap-codec + +Decode speed: +decode: @jridgewell/sourcemap-codec x 16,137 ops/sec ±0.17% (99 runs sampled) +decode: sourcemap-codec x 12,139 ops/sec ±0.13% (99 runs sampled) +decode: source-map-0.6.1 x 1,264 ops/sec ±0.12% (100 runs sampled) +decode: source-map-0.8.0 x 9,894 ops/sec ±0.08% (101 runs sampled) +Fastest is decode: @jridgewell/sourcemap-codec + +Encode Memory Usage: +@jridgewell/sourcemap-codec 321026 bytes +sourcemap-codec 830832 bytes +source-map-0.6.1 586608 bytes +source-map-0.8.0 586680 bytes +Smallest memory usage is @jridgewell/sourcemap-codec + +Encode speed: +encode: @jridgewell/sourcemap-codec x 19,876 ops/sec ±0.78% (95 runs sampled) +encode: sourcemap-codec x 6,983 ops/sec ±0.15% (100 runs sampled) +encode: source-map-0.6.1 x 5,070 ops/sec ±0.12% (102 runs sampled) +encode: source-map-0.8.0 x 5,641 ops/sec ±0.17% (100 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec + + +*** + + +react.js.map - 5726 segments + +Decode Memory Usage: +@jridgewell/sourcemap-codec 734848 bytes +sourcemap-codec 954200 bytes +source-map-0.6.1 2276432 bytes +source-map-0.8.0 955488 bytes +Smallest memory usage is @jridgewell/sourcemap-codec + +Decode speed: +decode: @jridgewell/sourcemap-codec x 5,723 ops/sec ±0.12% (98 runs sampled) +decode: sourcemap-codec x 4,555 ops/sec ±0.09% (101 runs sampled) +decode: source-map-0.6.1 x 437 ops/sec ±0.11% (93 runs sampled) +decode: source-map-0.8.0 x 3,441 ops/sec ±0.15% (100 runs sampled) +Fastest is decode: @jridgewell/sourcemap-codec + +Encode Memory Usage: +@jridgewell/sourcemap-codec 638672 bytes +sourcemap-codec 1109840 bytes +source-map-0.6.1 1321224 bytes +source-map-0.8.0 1324448 bytes +Smallest memory usage is @jridgewell/sourcemap-codec + +Encode speed: +encode: @jridgewell/sourcemap-codec x 6,801 ops/sec ±0.48% (98 runs sampled) +encode: sourcemap-codec x 2,533 ops/sec ±0.13% (101 runs sampled) +encode: source-map-0.6.1 x 2,248 ops/sec ±0.08% (100 runs sampled) +encode: source-map-0.8.0 x 2,303 ops/sec ±0.15% (100 runs sampled) +Fastest is encode: @jridgewell/sourcemap-codec +``` + +# License + +MIT diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs new file mode 100644 index 000000000..3dff37217 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs @@ -0,0 +1,164 @@ +const comma = ','.charCodeAt(0); +const semicolon = ';'.charCodeAt(0); +const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; +const intToChar = new Uint8Array(64); // 64 possible chars. +const charToInt = new Uint8Array(128); // z is 122 in ASCII +for (let i = 0; i < chars.length; i++) { + const c = chars.charCodeAt(i); + intToChar[i] = c; + charToInt[c] = i; +} +// Provide a fallback for older environments. +const td = typeof TextDecoder !== 'undefined' + ? /* #__PURE__ */ new TextDecoder() + : typeof Buffer !== 'undefined' + ? { + decode(buf) { + const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); + return out.toString(); + }, + } + : { + decode(buf) { + let out = ''; + for (let i = 0; i < buf.length; i++) { + out += String.fromCharCode(buf[i]); + } + return out; + }, + }; +function decode(mappings) { + const state = new Int32Array(5); + const decoded = []; + let index = 0; + do { + const semi = indexOf(mappings, index); + const line = []; + let sorted = true; + let lastCol = 0; + state[0] = 0; + for (let i = index; i < semi; i++) { + let seg; + i = decodeInteger(mappings, i, state, 0); // genColumn + const col = state[0]; + if (col < lastCol) + sorted = false; + lastCol = col; + if (hasMoreVlq(mappings, i, semi)) { + i = decodeInteger(mappings, i, state, 1); // sourcesIndex + i = decodeInteger(mappings, i, state, 2); // sourceLine + i = decodeInteger(mappings, i, state, 3); // sourceColumn + if (hasMoreVlq(mappings, i, semi)) { + i = decodeInteger(mappings, i, state, 4); // namesIndex + seg = [col, state[1], state[2], state[3], state[4]]; + } + else { + seg = [col, state[1], state[2], state[3]]; + } + } + else { + seg = [col]; + } + line.push(seg); + } + if (!sorted) + sort(line); + decoded.push(line); + index = semi + 1; + } while (index <= mappings.length); + return decoded; +} +function indexOf(mappings, index) { + const idx = mappings.indexOf(';', index); + return idx === -1 ? mappings.length : idx; +} +function decodeInteger(mappings, pos, state, j) { + let value = 0; + let shift = 0; + let integer = 0; + do { + const c = mappings.charCodeAt(pos++); + integer = charToInt[c]; + value |= (integer & 31) << shift; + shift += 5; + } while (integer & 32); + const shouldNegate = value & 1; + value >>>= 1; + if (shouldNegate) { + value = -0x80000000 | -value; + } + state[j] += value; + return pos; +} +function hasMoreVlq(mappings, i, length) { + if (i >= length) + return false; + return mappings.charCodeAt(i) !== comma; +} +function sort(line) { + line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[0] - b[0]; +} +function encode(decoded) { + const state = new Int32Array(5); + const bufLength = 1024 * 16; + const subLength = bufLength - 36; + const buf = new Uint8Array(bufLength); + const sub = buf.subarray(0, subLength); + let pos = 0; + let out = ''; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + if (i > 0) { + if (pos === bufLength) { + out += td.decode(buf); + pos = 0; + } + buf[pos++] = semicolon; + } + if (line.length === 0) + continue; + state[0] = 0; + for (let j = 0; j < line.length; j++) { + const segment = line[j]; + // We can push up to 5 ints, each int can take at most 7 chars, and we + // may push a comma. + if (pos > subLength) { + out += td.decode(sub); + buf.copyWithin(0, subLength, pos); + pos -= subLength; + } + if (j > 0) + buf[pos++] = comma; + pos = encodeInteger(buf, pos, state, segment, 0); // genColumn + if (segment.length === 1) + continue; + pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex + pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine + pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn + if (segment.length === 4) + continue; + pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex + } + } + return out + td.decode(buf.subarray(0, pos)); +} +function encodeInteger(buf, pos, state, segment, j) { + const next = segment[j]; + let num = next - state[j]; + state[j] = next; + num = num < 0 ? (-num << 1) | 1 : num << 1; + do { + let clamped = num & 0b011111; + num >>>= 5; + if (num > 0) + clamped |= 0b100000; + buf[pos++] = intToChar[clamped]; + } while (num > 0); + return pos; +} + +export { decode, encode }; +//# sourceMappingURL=sourcemap-codec.mjs.map diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map new file mode 100644 index 000000000..236fd120a --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-codec.mjs","sources":["../src/sourcemap-codec.ts"],"sourcesContent":["export type SourceMapSegment =\n | [number]\n | [number, number, number, number]\n | [number, number, number, number, number];\nexport type SourceMapLine = SourceMapSegment[];\nexport type SourceMapMappings = SourceMapLine[];\n\nconst comma = ','.charCodeAt(0);\nconst semicolon = ';'.charCodeAt(0);\nconst chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst intToChar = new Uint8Array(64); // 64 possible chars.\nconst charToInt = new Uint8Array(128); // z is 122 in ASCII\n\nfor (let i = 0; i < chars.length; i++) {\n const c = chars.charCodeAt(i);\n intToChar[i] = c;\n charToInt[c] = i;\n}\n\n// Provide a fallback for older environments.\nconst td =\n typeof TextDecoder !== 'undefined'\n ? /* #__PURE__ */ new TextDecoder()\n : typeof Buffer !== 'undefined'\n ? {\n decode(buf: Uint8Array) {\n const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);\n return out.toString();\n },\n }\n : {\n decode(buf: Uint8Array) {\n let out = '';\n for (let i = 0; i < buf.length; i++) {\n out += String.fromCharCode(buf[i]);\n }\n return out;\n },\n };\n\nexport function decode(mappings: string): SourceMapMappings {\n const state: [number, number, number, number, number] = new Int32Array(5) as any;\n const decoded: SourceMapMappings = [];\n\n let index = 0;\n do {\n const semi = indexOf(mappings, index);\n const line: SourceMapLine = [];\n let sorted = true;\n let lastCol = 0;\n state[0] = 0;\n\n for (let i = index; i < semi; i++) {\n let seg: SourceMapSegment;\n\n i = decodeInteger(mappings, i, state, 0); // genColumn\n const col = state[0];\n if (col < lastCol) sorted = false;\n lastCol = col;\n\n if (hasMoreVlq(mappings, i, semi)) {\n i = decodeInteger(mappings, i, state, 1); // sourcesIndex\n i = decodeInteger(mappings, i, state, 2); // sourceLine\n i = decodeInteger(mappings, i, state, 3); // sourceColumn\n\n if (hasMoreVlq(mappings, i, semi)) {\n i = decodeInteger(mappings, i, state, 4); // namesIndex\n seg = [col, state[1], state[2], state[3], state[4]];\n } else {\n seg = [col, state[1], state[2], state[3]];\n }\n } else {\n seg = [col];\n }\n\n line.push(seg);\n }\n\n if (!sorted) sort(line);\n decoded.push(line);\n index = semi + 1;\n } while (index <= mappings.length);\n\n return decoded;\n}\n\nfunction indexOf(mappings: string, index: number): number {\n const idx = mappings.indexOf(';', index);\n return idx === -1 ? mappings.length : idx;\n}\n\nfunction decodeInteger(mappings: string, pos: number, state: SourceMapSegment, j: number): number {\n let value = 0;\n let shift = 0;\n let integer = 0;\n\n do {\n const c = mappings.charCodeAt(pos++);\n integer = charToInt[c];\n value |= (integer & 31) << shift;\n shift += 5;\n } while (integer & 32);\n\n const shouldNegate = value & 1;\n value >>>= 1;\n\n if (shouldNegate) {\n value = -0x80000000 | -value;\n }\n\n state[j] += value;\n return pos;\n}\n\nfunction hasMoreVlq(mappings: string, i: number, length: number): boolean {\n if (i >= length) return false;\n return mappings.charCodeAt(i) !== comma;\n}\n\nfunction sort(line: SourceMapSegment[]) {\n line.sort(sortComparator);\n}\n\nfunction sortComparator(a: SourceMapSegment, b: SourceMapSegment): number {\n return a[0] - b[0];\n}\n\nexport function encode(decoded: SourceMapMappings): string;\nexport function encode(decoded: Readonly): string;\nexport function encode(decoded: Readonly): string {\n const state: [number, number, number, number, number] = new Int32Array(5) as any;\n const bufLength = 1024 * 16;\n const subLength = bufLength - 36;\n const buf = new Uint8Array(bufLength);\n const sub = buf.subarray(0, subLength);\n let pos = 0;\n let out = '';\n\n for (let i = 0; i < decoded.length; i++) {\n const line = decoded[i];\n if (i > 0) {\n if (pos === bufLength) {\n out += td.decode(buf);\n pos = 0;\n }\n buf[pos++] = semicolon;\n }\n if (line.length === 0) continue;\n\n state[0] = 0;\n\n for (let j = 0; j < line.length; j++) {\n const segment = line[j];\n // We can push up to 5 ints, each int can take at most 7 chars, and we\n // may push a comma.\n if (pos > subLength) {\n out += td.decode(sub);\n buf.copyWithin(0, subLength, pos);\n pos -= subLength;\n }\n if (j > 0) buf[pos++] = comma;\n\n pos = encodeInteger(buf, pos, state, segment, 0); // genColumn\n\n if (segment.length === 1) continue;\n pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex\n pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine\n pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn\n\n if (segment.length === 4) continue;\n pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex\n }\n }\n\n return out + td.decode(buf.subarray(0, pos));\n}\n\nfunction encodeInteger(\n buf: Uint8Array,\n pos: number,\n state: SourceMapSegment,\n segment: SourceMapSegment,\n j: number,\n): number {\n const next = segment[j];\n let num = next - state[j];\n state[j] = next;\n\n num = num < 0 ? (-num << 1) | 1 : num << 1;\n do {\n let clamped = num & 0b011111;\n num >>>= 5;\n if (num > 0) clamped |= 0b100000;\n buf[pos++] = intToChar[clamped];\n } while (num > 0);\n\n return pos;\n}\n"],"names":[],"mappings":"AAOA,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAChC,MAAM,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC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KACF;IAED,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,aAAa,CACpB,GAAe,EACf,GAAW,EACX,KAAuB,EACvB,OAAyB,EACzB,CAAS;IAET,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,GAAG,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1B,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAEhB,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IAC3C,GAAG;QACD,IAAI,OAAO,GAAG,GAAG,GAAG,QAAQ,CAAC;QAC7B,GAAG,MAAM,CAAC,CAAC;QACX,IAAI,GAAG,GAAG,CAAC;YAAE,OAAO,IAAI,QAAQ,CAAC;QACjC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;KACjC,QAAQ,GAAG,GAAG,CAAC,EAAE;IAElB,OAAO,GAAG,CAAC;AACb;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js new file mode 100644 index 000000000..bec92a9c6 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js @@ -0,0 +1,175 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.sourcemapCodec = {})); +})(this, (function (exports) { 'use strict'; + + const comma = ','.charCodeAt(0); + const semicolon = ';'.charCodeAt(0); + const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + const intToChar = new Uint8Array(64); // 64 possible chars. + const charToInt = new Uint8Array(128); // z is 122 in ASCII + for (let i = 0; i < chars.length; i++) { + const c = chars.charCodeAt(i); + intToChar[i] = c; + charToInt[c] = i; + } + // Provide a fallback for older environments. + const td = typeof TextDecoder !== 'undefined' + ? /* #__PURE__ */ new TextDecoder() + : typeof Buffer !== 'undefined' + ? { + decode(buf) { + const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); + return out.toString(); + }, + } + : { + decode(buf) { + let out = ''; + for (let i = 0; i < buf.length; i++) { + out += String.fromCharCode(buf[i]); + } + return out; + }, + }; + function decode(mappings) { + const state = new Int32Array(5); + const decoded = []; + let index = 0; + do { + const semi = indexOf(mappings, index); + const line = []; + let sorted = true; + let lastCol = 0; + state[0] = 0; + for (let i = index; i < semi; i++) { + let seg; + i = decodeInteger(mappings, i, state, 0); // genColumn + const col = state[0]; + if (col < lastCol) + sorted = false; + lastCol = col; + if (hasMoreVlq(mappings, i, semi)) { + i = decodeInteger(mappings, i, state, 1); // sourcesIndex + i = decodeInteger(mappings, i, state, 2); // sourceLine + i = decodeInteger(mappings, i, state, 3); // sourceColumn + if (hasMoreVlq(mappings, i, semi)) { + i = decodeInteger(mappings, i, state, 4); // namesIndex + seg = [col, state[1], state[2], state[3], state[4]]; + } + else { + seg = [col, state[1], state[2], state[3]]; + } + } + else { + seg = [col]; + } + line.push(seg); + } + if (!sorted) + sort(line); + decoded.push(line); + index = semi + 1; + } while (index <= mappings.length); + return decoded; + } + function indexOf(mappings, index) { + const idx = mappings.indexOf(';', index); + return idx === -1 ? mappings.length : idx; + } + function decodeInteger(mappings, pos, state, j) { + let value = 0; + let shift = 0; + let integer = 0; + do { + const c = mappings.charCodeAt(pos++); + integer = charToInt[c]; + value |= (integer & 31) << shift; + shift += 5; + } while (integer & 32); + const shouldNegate = value & 1; + value >>>= 1; + if (shouldNegate) { + value = -0x80000000 | -value; + } + state[j] += value; + return pos; + } + function hasMoreVlq(mappings, i, length) { + if (i >= length) + return false; + return mappings.charCodeAt(i) !== comma; + } + function sort(line) { + line.sort(sortComparator); + } + function sortComparator(a, b) { + return a[0] - b[0]; + } + function encode(decoded) { + const state = new Int32Array(5); + const bufLength = 1024 * 16; + const subLength = bufLength - 36; + const buf = new Uint8Array(bufLength); + const sub = buf.subarray(0, subLength); + let pos = 0; + let out = ''; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + if (i > 0) { + if (pos === bufLength) { + out += td.decode(buf); + pos = 0; + } + buf[pos++] = semicolon; + } + if (line.length === 0) + continue; + state[0] = 0; + for (let j = 0; j < line.length; j++) { + const segment = line[j]; + // We can push up to 5 ints, each int can take at most 7 chars, and we + // may push a comma. + if (pos > subLength) { + out += td.decode(sub); + buf.copyWithin(0, subLength, pos); + pos -= subLength; + } + if (j > 0) + buf[pos++] = comma; + pos = encodeInteger(buf, pos, state, segment, 0); // genColumn + if (segment.length === 1) + continue; + pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex + pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine + pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn + if (segment.length === 4) + continue; + pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex + } + } + return out + td.decode(buf.subarray(0, pos)); + } + function encodeInteger(buf, pos, state, segment, j) { + const next = segment[j]; + let num = next - state[j]; + state[j] = next; + num = num < 0 ? (-num << 1) | 1 : num << 1; + do { + let clamped = num & 0b011111; + num >>>= 5; + if (num > 0) + clamped |= 0b100000; + buf[pos++] = intToChar[clamped]; + } while (num > 0); + return pos; + } + + exports.decode = decode; + exports.encode = encode; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); +//# sourceMappingURL=sourcemap-codec.umd.js.map diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map new file mode 100644 index 000000000..b6b2003c2 --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sourcemap-codec.umd.js","sources":["../src/sourcemap-codec.ts"],"sourcesContent":["export type SourceMapSegment =\n | [number]\n | [number, number, number, number]\n | [number, number, number, number, number];\nexport type SourceMapLine = SourceMapSegment[];\nexport type SourceMapMappings = SourceMapLine[];\n\nconst comma = ','.charCodeAt(0);\nconst semicolon = ';'.charCodeAt(0);\nconst chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst intToChar = new Uint8Array(64); // 64 possible chars.\nconst charToInt = new Uint8Array(128); // z is 122 in ASCII\n\nfor (let i = 0; i < chars.length; i++) {\n const c = chars.charCodeAt(i);\n intToChar[i] = c;\n charToInt[c] = i;\n}\n\n// Provide a fallback for older environments.\nconst td =\n typeof TextDecoder !== 'undefined'\n ? /* #__PURE__ */ new TextDecoder()\n : typeof Buffer !== 'undefined'\n ? {\n decode(buf: Uint8Array) {\n const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);\n return out.toString();\n },\n }\n : {\n decode(buf: Uint8Array) {\n let out = '';\n for (let i = 0; i < buf.length; i++) {\n out += String.fromCharCode(buf[i]);\n }\n return out;\n },\n };\n\nexport function decode(mappings: string): SourceMapMappings {\n const state: [number, number, number, number, number] = new Int32Array(5) as any;\n const decoded: SourceMapMappings = [];\n\n let index = 0;\n do {\n const semi = indexOf(mappings, index);\n const line: SourceMapLine = [];\n let sorted = true;\n let lastCol = 0;\n state[0] = 0;\n\n for (let i = index; i < semi; i++) {\n let seg: SourceMapSegment;\n\n i = decodeInteger(mappings, i, state, 0); // genColumn\n const col = state[0];\n if (col < lastCol) sorted = false;\n lastCol = col;\n\n if (hasMoreVlq(mappings, i, semi)) {\n i = decodeInteger(mappings, i, state, 1); // sourcesIndex\n i = decodeInteger(mappings, i, state, 2); // sourceLine\n i = decodeInteger(mappings, i, state, 3); // sourceColumn\n\n if (hasMoreVlq(mappings, i, semi)) {\n i = decodeInteger(mappings, i, state, 4); // namesIndex\n seg = [col, state[1], state[2], state[3], state[4]];\n } else {\n seg = [col, state[1], state[2], state[3]];\n }\n } else {\n seg = [col];\n }\n\n line.push(seg);\n }\n\n if (!sorted) sort(line);\n decoded.push(line);\n index = semi + 1;\n } while (index <= mappings.length);\n\n return decoded;\n}\n\nfunction indexOf(mappings: string, index: number): number {\n const idx = mappings.indexOf(';', index);\n return idx === -1 ? mappings.length : idx;\n}\n\nfunction decodeInteger(mappings: string, pos: number, state: SourceMapSegment, j: number): number {\n let value = 0;\n let shift = 0;\n let integer = 0;\n\n do {\n const c = mappings.charCodeAt(pos++);\n integer = charToInt[c];\n value |= (integer & 31) << shift;\n shift += 5;\n } while (integer & 32);\n\n const shouldNegate = value & 1;\n value >>>= 1;\n\n if (shouldNegate) {\n value = -0x80000000 | -value;\n }\n\n state[j] += value;\n return pos;\n}\n\nfunction hasMoreVlq(mappings: string, i: number, length: number): boolean {\n if (i >= length) return false;\n return mappings.charCodeAt(i) !== comma;\n}\n\nfunction sort(line: SourceMapSegment[]) {\n line.sort(sortComparator);\n}\n\nfunction sortComparator(a: SourceMapSegment, b: SourceMapSegment): number {\n return a[0] - b[0];\n}\n\nexport function encode(decoded: SourceMapMappings): string;\nexport function encode(decoded: Readonly): string;\nexport function encode(decoded: Readonly): string {\n const state: [number, number, number, number, number] = new Int32Array(5) as any;\n const bufLength = 1024 * 16;\n const subLength = bufLength - 36;\n const buf = new Uint8Array(bufLength);\n const sub = buf.subarray(0, subLength);\n let pos = 0;\n let out = '';\n\n for (let i = 0; i < decoded.length; i++) {\n const line = decoded[i];\n if (i > 0) {\n if (pos === bufLength) {\n out += td.decode(buf);\n pos = 0;\n }\n buf[pos++] = semicolon;\n }\n if (line.length === 0) continue;\n\n state[0] = 0;\n\n for (let j = 0; j < line.length; j++) {\n const segment = line[j];\n // We can push up to 5 ints, each int can take at most 7 chars, and we\n // may push a comma.\n if (pos > subLength) {\n out += td.decode(sub);\n buf.copyWithin(0, subLength, pos);\n pos -= subLength;\n }\n if (j > 0) buf[pos++] = comma;\n\n pos = encodeInteger(buf, pos, state, segment, 0); // genColumn\n\n if (segment.length === 1) continue;\n pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex\n pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine\n pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn\n\n if (segment.length === 4) continue;\n pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex\n }\n }\n\n return out + td.decode(buf.subarray(0, pos));\n}\n\nfunction encodeInteger(\n buf: Uint8Array,\n pos: number,\n state: SourceMapSegment,\n segment: SourceMapSegment,\n j: number,\n): number {\n const next = segment[j];\n let num = next - state[j];\n state[j] = next;\n\n num = num < 0 ? (-num << 1) | 1 : num << 1;\n do {\n let clamped = num & 0b011111;\n num >>>= 5;\n if (num > 0) clamped |= 0b100000;\n buf[pos++] = intToChar[clamped];\n } while (num > 0);\n\n return pos;\n}\n"],"names":[],"mappings":";;;;;;IAOA,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,kEAAkE,CAAC;IACjF,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9B,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACjB,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;K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AG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;QAC3C,GAAG;YACD,IAAI,OAAO,GAAG,GAAG,GAAG,QAAQ,CAAC;YAC7B,GAAG,MAAM,CAAC,CAAC;YACX,IAAI,GAAG,GAAG,CAAC;gBAAE,OAAO,IAAI,QAAQ,CAAC;YACjC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;SACjC,QAAQ,GAAG,GAAG,CAAC,EAAE;QAElB,OAAO,GAAG,CAAC;IACb;;;;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts b/node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts new file mode 100644 index 000000000..410d3202f --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts @@ -0,0 +1,6 @@ +export declare type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number]; +export declare type SourceMapLine = SourceMapSegment[]; +export declare type SourceMapMappings = SourceMapLine[]; +export declare function decode(mappings: string): SourceMapMappings; +export declare function encode(decoded: SourceMapMappings): string; +export declare function encode(decoded: Readonly): string; diff --git a/node_modules/@jridgewell/sourcemap-codec/package.json b/node_modules/@jridgewell/sourcemap-codec/package.json new file mode 100644 index 000000000..578448f1c --- /dev/null +++ b/node_modules/@jridgewell/sourcemap-codec/package.json @@ -0,0 +1,74 @@ +{ + "name": "@jridgewell/sourcemap-codec", + "version": "1.4.15", + "description": "Encode/decode sourcemap mappings", + "keywords": [ + "sourcemap", + "vlq" + ], + "main": "dist/sourcemap-codec.umd.js", + "module": "dist/sourcemap-codec.mjs", + "types": "dist/types/sourcemap-codec.d.ts", + "files": [ + "dist" + ], + "exports": { + ".": [ + { + "types": "./dist/types/sourcemap-codec.d.ts", + "browser": "./dist/sourcemap-codec.umd.js", + "require": "./dist/sourcemap-codec.umd.js", + "import": "./dist/sourcemap-codec.mjs" + }, + "./dist/sourcemap-codec.umd.js" + ], + "./package.json": "./package.json" + }, + "scripts": { + "benchmark": "run-s build:rollup benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.js", + "build": "run-s -n build:*", + "build:rollup": "rollup -c rollup.config.js", + "build:ts": "tsc --project tsconfig.build.json", + "lint": "run-s -n lint:*", + "lint:prettier": "npm run test:lint:prettier -- --write", + "lint:ts": "npm run test:lint:ts -- --fix", + "prebuild": "rm -rf dist", + "prepublishOnly": "npm run preversion", + "preversion": "run-s test build", + "pretest": "run-s build:rollup", + "test": "run-s -n test:lint test:only", + "test:debug": "mocha --inspect-brk", + "test:lint": "run-s -n test:lint:*", + "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", + "test:lint:ts": "eslint '{src,test}/**/*.ts'", + "test:only": "mocha", + "test:coverage": "c8 mocha", + "test:watch": "mocha --watch" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/sourcemap-codec.git" + }, + "author": "Rich Harris", + "license": "MIT", + "devDependencies": { + "@rollup/plugin-typescript": "8.3.0", + "@types/node": "17.0.15", + "@typescript-eslint/eslint-plugin": "5.10.0", + "@typescript-eslint/parser": "5.10.0", + "benchmark": "2.1.4", + "c8": "7.11.2", + "eslint": "8.7.0", + "eslint-config-prettier": "8.3.0", + "mocha": "9.2.0", + "npm-run-all": "4.1.5", + "prettier": "2.5.1", + "rollup": "2.64.0", + "source-map": "0.6.1", + "source-map-js": "1.0.2", + "sourcemap-codec": "1.4.8", + "typescript": "4.5.4" + } +} diff --git a/node_modules/@jridgewell/trace-mapping/LICENSE b/node_modules/@jridgewell/trace-mapping/LICENSE new file mode 100644 index 000000000..37bb488f0 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 Justin Ridgewell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@jridgewell/trace-mapping/README.md b/node_modules/@jridgewell/trace-mapping/README.md new file mode 100644 index 000000000..cc5e4f915 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/README.md @@ -0,0 +1,252 @@ +# @jridgewell/trace-mapping + +> Trace the original position through a source map + +`trace-mapping` allows you to take the line and column of an output file and trace it to the +original location in the source file through a source map. + +You may already be familiar with the [`source-map`][source-map] package's `SourceMapConsumer`. This +provides the same `originalPositionFor` and `generatedPositionFor` API, without requiring WASM. + +## Installation + +```sh +npm install @jridgewell/trace-mapping +``` + +## Usage + +```typescript +import { + TraceMap, + originalPositionFor, + generatedPositionFor, + sourceContentFor, +} from '@jridgewell/trace-mapping'; + +const tracer = new TraceMap({ + version: 3, + sources: ['input.js'], + sourcesContent: ['content of input.js'], + names: ['foo'], + mappings: 'KAyCIA', +}); + +// Lines start at line 1, columns at column 0. +const traced = originalPositionFor(tracer, { line: 1, column: 5 }); +assert.deepEqual(traced, { + source: 'input.js', + line: 42, + column: 4, + name: 'foo', +}); + +const content = sourceContentFor(tracer, traced.source); +assert.strictEqual(content, 'content for input.js'); + +const generated = generatedPositionFor(tracer, { + source: 'input.js', + line: 42, + column: 4, +}); +assert.deepEqual(generated, { + line: 1, + column: 5, +}); +``` + +We also provide a lower level API to get the actual segment that matches our line and column. Unlike +`originalPositionFor`, `traceSegment` uses a 0-base for `line`: + +```typescript +import { traceSegment } from '@jridgewell/trace-mapping'; + +// line is 0-base. +const traced = traceSegment(tracer, /* line */ 0, /* column */ 5); + +// Segments are [outputColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] +// Again, line is 0-base and so is sourceLine +assert.deepEqual(traced, [5, 0, 41, 4, 0]); +``` + +### SectionedSourceMaps + +The sourcemap spec defines a special `sections` field that's designed to handle concatenation of +output code with associated sourcemaps. This type of sourcemap is rarely used (no major build tool +produces it), but if you are hand coding a concatenation you may need it. We provide an `AnyMap` +helper that can receive either a regular sourcemap or a `SectionedSourceMap` and returns a +`TraceMap` instance: + +```typescript +import { AnyMap } from '@jridgewell/trace-mapping'; +const fooOutput = 'foo'; +const barOutput = 'bar'; +const output = [fooOutput, barOutput].join('\n'); + +const sectioned = new AnyMap({ + version: 3, + sections: [ + { + // 0-base line and column + offset: { line: 0, column: 0 }, + // fooOutput's sourcemap + map: { + version: 3, + sources: ['foo.js'], + names: ['foo'], + mappings: 'AAAAA', + }, + }, + { + // barOutput's sourcemap will not affect the first line, only the second + offset: { line: 1, column: 0 }, + map: { + version: 3, + sources: ['bar.js'], + names: ['bar'], + mappings: 'AAAAA', + }, + }, + ], +}); + +const traced = originalPositionFor(sectioned, { + line: 2, + column: 0, +}); + +assert.deepEqual(traced, { + source: 'bar.js', + line: 1, + column: 0, + name: 'bar', +}); +``` + +## Benchmarks + +``` +node v18.0.0 + +amp.js.map - 45120 segments + +Memory Usage: +trace-mapping decoded 562400 bytes +trace-mapping encoded 5706544 bytes +source-map-js 10717664 bytes +source-map-0.6.1 17446384 bytes +source-map-0.8.0 9701757 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 180 ops/sec ±0.34% (85 runs sampled) +trace-mapping: encoded JSON input x 364 ops/sec ±1.77% (89 runs sampled) +trace-mapping: decoded Object input x 3,116 ops/sec ±0.50% (96 runs sampled) +trace-mapping: encoded Object input x 410 ops/sec ±2.62% (85 runs sampled) +source-map-js: encoded Object input x 84.23 ops/sec ±0.91% (73 runs sampled) +source-map-0.6.1: encoded Object input x 37.21 ops/sec ±2.08% (51 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed: +trace-mapping: decoded originalPositionFor x 3,952,212 ops/sec ±0.17% (98 runs sampled) +trace-mapping: encoded originalPositionFor x 3,487,468 ops/sec ±1.58% (90 runs sampled) +source-map-js: encoded originalPositionFor x 827,730 ops/sec ±0.78% (97 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 748,991 ops/sec ±0.53% (94 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 2,532,894 ops/sec ±0.57% (95 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +babel.min.js.map - 347793 segments + +Memory Usage: +trace-mapping decoded 89832 bytes +trace-mapping encoded 35474640 bytes +source-map-js 51257176 bytes +source-map-0.6.1 63515664 bytes +source-map-0.8.0 42933752 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 15.41 ops/sec ±8.65% (34 runs sampled) +trace-mapping: encoded JSON input x 28.20 ops/sec ±12.87% (42 runs sampled) +trace-mapping: decoded Object input x 964 ops/sec ±0.36% (99 runs sampled) +trace-mapping: encoded Object input x 31.77 ops/sec ±13.79% (45 runs sampled) +source-map-js: encoded Object input x 6.45 ops/sec ±5.16% (21 runs sampled) +source-map-0.6.1: encoded Object input x 4.07 ops/sec ±5.24% (15 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed: +trace-mapping: decoded originalPositionFor x 7,183,038 ops/sec ±0.58% (95 runs sampled) +trace-mapping: encoded originalPositionFor x 5,192,185 ops/sec ±0.41% (100 runs sampled) +source-map-js: encoded originalPositionFor x 4,259,489 ops/sec ±0.79% (94 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 3,742,629 ops/sec ±0.71% (95 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 6,270,211 ops/sec ±0.64% (94 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +preact.js.map - 1992 segments + +Memory Usage: +trace-mapping decoded 37128 bytes +trace-mapping encoded 247280 bytes +source-map-js 1143536 bytes +source-map-0.6.1 1290992 bytes +source-map-0.8.0 96544 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 3,483 ops/sec ±0.30% (98 runs sampled) +trace-mapping: encoded JSON input x 6,092 ops/sec ±0.18% (97 runs sampled) +trace-mapping: decoded Object input x 249,076 ops/sec ±0.24% (98 runs sampled) +trace-mapping: encoded Object input x 14,555 ops/sec ±0.48% (100 runs sampled) +source-map-js: encoded Object input x 2,447 ops/sec ±0.36% (99 runs sampled) +source-map-0.6.1: encoded Object input x 1,201 ops/sec ±0.57% (96 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed: +trace-mapping: decoded originalPositionFor x 7,620,192 ops/sec ±0.09% (99 runs sampled) +trace-mapping: encoded originalPositionFor x 6,872,554 ops/sec ±0.30% (97 runs sampled) +source-map-js: encoded originalPositionFor x 2,489,570 ops/sec ±0.35% (94 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 1,698,633 ops/sec ±0.28% (98 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 4,015,644 ops/sec ±0.22% (98 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor + + +*** + + +react.js.map - 5726 segments + +Memory Usage: +trace-mapping decoded 16176 bytes +trace-mapping encoded 681552 bytes +source-map-js 2418352 bytes +source-map-0.6.1 2443672 bytes +source-map-0.8.0 111768 bytes +Smallest memory usage is trace-mapping decoded + +Init speed: +trace-mapping: decoded JSON input x 1,720 ops/sec ±0.34% (98 runs sampled) +trace-mapping: encoded JSON input x 4,406 ops/sec ±0.35% (100 runs sampled) +trace-mapping: decoded Object input x 92,122 ops/sec ±0.10% (99 runs sampled) +trace-mapping: encoded Object input x 5,385 ops/sec ±0.37% (99 runs sampled) +source-map-js: encoded Object input x 794 ops/sec ±0.40% (98 runs sampled) +source-map-0.6.1: encoded Object input x 416 ops/sec ±0.54% (91 runs sampled) +Fastest is trace-mapping: decoded Object input + +Trace speed: +trace-mapping: decoded originalPositionFor x 32,759,519 ops/sec ±0.33% (100 runs sampled) +trace-mapping: encoded originalPositionFor x 31,116,306 ops/sec ±0.33% (97 runs sampled) +source-map-js: encoded originalPositionFor x 17,458,435 ops/sec ±0.44% (97 runs sampled) +source-map-0.6.1: encoded originalPositionFor x 12,687,097 ops/sec ±0.43% (95 runs sampled) +source-map-0.8.0: encoded originalPositionFor x 23,538,275 ops/sec ±0.38% (95 runs sampled) +Fastest is trace-mapping: decoded originalPositionFor +``` + +[source-map]: https://www.npmjs.com/package/source-map diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs new file mode 100644 index 000000000..d3c1a7aca --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs @@ -0,0 +1,552 @@ +import { encode, decode } from '@jridgewell/sourcemap-codec'; +import resolveUri from '@jridgewell/resolve-uri'; + +function resolve(input, base) { + // The base is always treated as a directory, if it's not empty. + // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327 + // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401 + if (base && !base.endsWith('/')) + base += '/'; + return resolveUri(input, base); +} + +/** + * Removes everything after the last "/", but leaves the slash. + */ +function stripFilename(path) { + if (!path) + return ''; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); +} + +const COLUMN = 0; +const SOURCES_INDEX = 1; +const SOURCE_LINE = 2; +const SOURCE_COLUMN = 3; +const NAMES_INDEX = 4; +const REV_GENERATED_LINE = 1; +const REV_GENERATED_COLUMN = 2; + +function maybeSort(mappings, owned) { + const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); + if (unsortedIndex === mappings.length) + return mappings; + // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If + // not, we do not want to modify the consumer's input array. + if (!owned) + mappings = mappings.slice(); + for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { + mappings[i] = sortSegments(mappings[i], owned); + } + return mappings; +} +function nextUnsortedSegmentLine(mappings, start) { + for (let i = start; i < mappings.length; i++) { + if (!isSorted(mappings[i])) + return i; + } + return mappings.length; +} +function isSorted(line) { + for (let j = 1; j < line.length; j++) { + if (line[j][COLUMN] < line[j - 1][COLUMN]) { + return false; + } + } + return true; +} +function sortSegments(line, owned) { + if (!owned) + line = line.slice(); + return line.sort(sortComparator); +} +function sortComparator(a, b) { + return a[COLUMN] - b[COLUMN]; +} + +let found = false; +/** + * A binary search implementation that returns the index if a match is found. + * If no match is found, then the left-index (the index associated with the item that comes just + * before the desired index) is returned. To maintain proper sort order, a splice would happen at + * the next index: + * + * ```js + * const array = [1, 3]; + * const needle = 2; + * const index = binarySearch(array, needle, (item, needle) => item - needle); + * + * assert.equal(index, 0); + * array.splice(index + 1, 0, needle); + * assert.deepEqual(array, [1, 2, 3]); + * ``` + */ +function binarySearch(haystack, needle, low, high) { + while (low <= high) { + const mid = low + ((high - low) >> 1); + const cmp = haystack[mid][COLUMN] - needle; + if (cmp === 0) { + found = true; + return mid; + } + if (cmp < 0) { + low = mid + 1; + } + else { + high = mid - 1; + } + } + found = false; + return low - 1; +} +function upperBound(haystack, needle, index) { + for (let i = index + 1; i < haystack.length; index = i++) { + if (haystack[i][COLUMN] !== needle) + break; + } + return index; +} +function lowerBound(haystack, needle, index) { + for (let i = index - 1; i >= 0; index = i--) { + if (haystack[i][COLUMN] !== needle) + break; + } + return index; +} +function memoizedState() { + return { + lastKey: -1, + lastNeedle: -1, + lastIndex: -1, + }; +} +/** + * This overly complicated beast is just to record the last tested line/column and the resulting + * index, allowing us to skip a few tests if mappings are monotonically increasing. + */ +function memoizedBinarySearch(haystack, needle, state, key) { + const { lastKey, lastNeedle, lastIndex } = state; + let low = 0; + let high = haystack.length - 1; + if (key === lastKey) { + if (needle === lastNeedle) { + found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; + return lastIndex; + } + if (needle >= lastNeedle) { + // lastIndex may be -1 if the previous needle was not found. + low = lastIndex === -1 ? 0 : lastIndex; + } + else { + high = lastIndex; + } + } + state.lastKey = key; + state.lastNeedle = needle; + return (state.lastIndex = binarySearch(haystack, needle, low, high)); +} + +// Rebuilds the original source files, with mappings that are ordered by source line/column instead +// of generated line/column. +function buildBySources(decoded, memos) { + const sources = memos.map(buildNullArray); + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + if (seg.length === 1) + continue; + const sourceIndex = seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + const originalSource = sources[sourceIndex]; + const originalLine = (originalSource[sourceLine] || (originalSource[sourceLine] = [])); + const memo = memos[sourceIndex]; + // The binary search either found a match, or it found the left-index just before where the + // segment should go. Either way, we want to insert after that. And there may be multiple + // generated segments associated with an original location, so there may need to move several + // indexes before we find where we need to insert. + const index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine)); + insert(originalLine, (memo.lastIndex = index + 1), [sourceColumn, i, seg[COLUMN]]); + } + } + return sources; +} +function insert(array, index, value) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; +} +// Null arrays allow us to use ordered index keys without actually allocating contiguous memory like +// a real array. We use a null-prototype object to avoid prototype pollution and deoptimizations. +// Numeric properties on objects are magically sorted in ascending order by the engine regardless of +// the insertion order. So, by setting any numeric keys, even out of order, we'll get ascending +// order when iterating with for-in. +function buildNullArray() { + return { __proto__: null }; +} + +const AnyMap = function (map, mapUrl) { + const parsed = typeof map === 'string' ? JSON.parse(map) : map; + if (!('sections' in parsed)) + return new TraceMap(parsed, mapUrl); + const mappings = []; + const sources = []; + const sourcesContent = []; + const names = []; + recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, 0, 0, Infinity, Infinity); + const joined = { + version: 3, + file: parsed.file, + names, + sources, + sourcesContent, + mappings, + }; + return presortedDecodedMap(joined); +}; +function recurse(input, mapUrl, mappings, sources, sourcesContent, names, lineOffset, columnOffset, stopLine, stopColumn) { + const { sections } = input; + for (let i = 0; i < sections.length; i++) { + const { map, offset } = sections[i]; + let sl = stopLine; + let sc = stopColumn; + if (i + 1 < sections.length) { + const nextOffset = sections[i + 1].offset; + sl = Math.min(stopLine, lineOffset + nextOffset.line); + if (sl === stopLine) { + sc = Math.min(stopColumn, columnOffset + nextOffset.column); + } + else if (sl < stopLine) { + sc = columnOffset + nextOffset.column; + } + } + addSection(map, mapUrl, mappings, sources, sourcesContent, names, lineOffset + offset.line, columnOffset + offset.column, sl, sc); + } +} +function addSection(input, mapUrl, mappings, sources, sourcesContent, names, lineOffset, columnOffset, stopLine, stopColumn) { + if ('sections' in input) + return recurse(...arguments); + const map = new TraceMap(input, mapUrl); + const sourcesOffset = sources.length; + const namesOffset = names.length; + const decoded = decodedMappings(map); + const { resolvedSources, sourcesContent: contents } = map; + append(sources, resolvedSources); + append(names, map.names); + if (contents) + append(sourcesContent, contents); + else + for (let i = 0; i < resolvedSources.length; i++) + sourcesContent.push(null); + for (let i = 0; i < decoded.length; i++) { + const lineI = lineOffset + i; + // We can only add so many lines before we step into the range that the next section's map + // controls. When we get to the last line, then we'll start checking the segments to see if + // they've crossed into the column range. But it may not have any columns that overstep, so we + // still need to check that we don't overstep lines, too. + if (lineI > stopLine) + return; + // The out line may already exist in mappings (if we're continuing the line started by a + // previous section). Or, we may have jumped ahead several lines to start this section. + const out = getLine(mappings, lineI); + // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the + // map can be multiple lines), it doesn't. + const cOffset = i === 0 ? columnOffset : 0; + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const column = cOffset + seg[COLUMN]; + // If this segment steps into the column range that the next section's map controls, we need + // to stop early. + if (lineI === stopLine && column >= stopColumn) + return; + if (seg.length === 1) { + out.push([column]); + continue; + } + const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + out.push(seg.length === 4 + ? [column, sourcesIndex, sourceLine, sourceColumn] + : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]]); + } + } +} +function append(arr, other) { + for (let i = 0; i < other.length; i++) + arr.push(other[i]); +} +function getLine(arr, index) { + for (let i = arr.length; i <= index; i++) + arr[i] = []; + return arr[index]; +} + +const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)'; +const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)'; +const LEAST_UPPER_BOUND = -1; +const GREATEST_LOWER_BOUND = 1; +/** + * Returns the encoded (VLQ string) form of the SourceMap's mappings field. + */ +let encodedMappings; +/** + * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. + */ +let decodedMappings; +/** + * A low-level API to find the segment associated with a generated line/column (think, from a + * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. + */ +let traceSegment; +/** + * A higher-level API to find the source/line/column associated with a generated line/column + * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in + * `source-map` library. + */ +let originalPositionFor; +/** + * Finds the generated line/column position of the provided source/line/column source position. + */ +let generatedPositionFor; +/** + * Finds all generated line/column positions of the provided source/line/column source position. + */ +let allGeneratedPositionsFor; +/** + * Iterates each mapping in generated position order. + */ +let eachMapping; +/** + * Retrieves the source content for a particular source, if its found. Returns null if not. + */ +let sourceContentFor; +/** + * A helper that skips sorting of the input map's mappings array, which can be expensive for larger + * maps. + */ +let presortedDecodedMap; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +let decodedMap; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +let encodedMap; +class TraceMap { + constructor(map, mapUrl) { + const isString = typeof map === 'string'; + if (!isString && map._decodedMemo) + return map; + const parsed = (isString ? JSON.parse(map) : map); + const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; + this.version = version; + this.file = file; + this.names = names || []; + this.sourceRoot = sourceRoot; + this.sources = sources; + this.sourcesContent = sourcesContent; + const from = resolve(sourceRoot || '', stripFilename(mapUrl)); + this.resolvedSources = sources.map((s) => resolve(s || '', from)); + const { mappings } = parsed; + if (typeof mappings === 'string') { + this._encoded = mappings; + this._decoded = undefined; + } + else { + this._encoded = undefined; + this._decoded = maybeSort(mappings, isString); + } + this._decodedMemo = memoizedState(); + this._bySources = undefined; + this._bySourceMemos = undefined; + } +} +(() => { + encodedMappings = (map) => { + var _a; + return ((_a = map._encoded) !== null && _a !== void 0 ? _a : (map._encoded = encode(map._decoded))); + }; + decodedMappings = (map) => { + return (map._decoded || (map._decoded = decode(map._encoded))); + }; + traceSegment = (map, line, column) => { + const decoded = decodedMappings(map); + // It's common for parent source maps to have pointers to lines that have no + // mapping (like a "//# sourceMappingURL=") at the end of the child file. + if (line >= decoded.length) + return null; + const segments = decoded[line]; + const index = traceSegmentInternal(segments, map._decodedMemo, line, column, GREATEST_LOWER_BOUND); + return index === -1 ? null : segments[index]; + }; + originalPositionFor = (map, { line, column, bias }) => { + line--; + if (line < 0) + throw new Error(LINE_GTR_ZERO); + if (column < 0) + throw new Error(COL_GTR_EQ_ZERO); + const decoded = decodedMappings(map); + // It's common for parent source maps to have pointers to lines that have no + // mapping (like a "//# sourceMappingURL=") at the end of the child file. + if (line >= decoded.length) + return OMapping(null, null, null, null); + const segments = decoded[line]; + const index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND); + if (index === -1) + return OMapping(null, null, null, null); + const segment = segments[index]; + if (segment.length === 1) + return OMapping(null, null, null, null); + const { names, resolvedSources } = map; + return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null); + }; + allGeneratedPositionsFor = (map, { source, line, column, bias }) => { + // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit. + return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); + }; + generatedPositionFor = (map, { source, line, column, bias }) => { + return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); + }; + eachMapping = (map, cb) => { + const decoded = decodedMappings(map); + const { names, resolvedSources } = map; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generatedLine = i + 1; + const generatedColumn = seg[0]; + let source = null; + let originalLine = null; + let originalColumn = null; + let name = null; + if (seg.length !== 1) { + source = resolvedSources[seg[1]]; + originalLine = seg[2] + 1; + originalColumn = seg[3]; + } + if (seg.length === 5) + name = names[seg[4]]; + cb({ + generatedLine, + generatedColumn, + source, + originalLine, + originalColumn, + name, + }); + } + } + }; + sourceContentFor = (map, source) => { + const { sources, resolvedSources, sourcesContent } = map; + if (sourcesContent == null) + return null; + let index = sources.indexOf(source); + if (index === -1) + index = resolvedSources.indexOf(source); + return index === -1 ? null : sourcesContent[index]; + }; + presortedDecodedMap = (map, mapUrl) => { + const tracer = new TraceMap(clone(map, []), mapUrl); + tracer._decoded = map.mappings; + return tracer; + }; + decodedMap = (map) => { + return clone(map, decodedMappings(map)); + }; + encodedMap = (map) => { + return clone(map, encodedMappings(map)); + }; + function generatedPosition(map, source, line, column, bias, all) { + line--; + if (line < 0) + throw new Error(LINE_GTR_ZERO); + if (column < 0) + throw new Error(COL_GTR_EQ_ZERO); + const { sources, resolvedSources } = map; + let sourceIndex = sources.indexOf(source); + if (sourceIndex === -1) + sourceIndex = resolvedSources.indexOf(source); + if (sourceIndex === -1) + return all ? [] : GMapping(null, null); + const generated = (map._bySources || (map._bySources = buildBySources(decodedMappings(map), (map._bySourceMemos = sources.map(memoizedState))))); + const segments = generated[sourceIndex][line]; + if (segments == null) + return all ? [] : GMapping(null, null); + const memo = map._bySourceMemos[sourceIndex]; + if (all) + return sliceGeneratedPositions(segments, memo, line, column, bias); + const index = traceSegmentInternal(segments, memo, line, column, bias); + if (index === -1) + return GMapping(null, null); + const segment = segments[index]; + return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); + } +})(); +function clone(map, mappings) { + return { + version: map.version, + file: map.file, + names: map.names, + sourceRoot: map.sourceRoot, + sources: map.sources, + sourcesContent: map.sourcesContent, + mappings, + }; +} +function OMapping(source, line, column, name) { + return { source, line, column, name }; +} +function GMapping(line, column) { + return { line, column }; +} +function traceSegmentInternal(segments, memo, line, column, bias) { + let index = memoizedBinarySearch(segments, column, memo, line); + if (found) { + index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); + } + else if (bias === LEAST_UPPER_BOUND) + index++; + if (index === -1 || index === segments.length) + return -1; + return index; +} +function sliceGeneratedPositions(segments, memo, line, column, bias) { + let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); + // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in + // insertion order) segment that matched. Even if we did respect the bias when tracing, we would + // still need to call `lowerBound()` to find the first segment, which is slower than just looking + // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the + // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to + // match LEAST_UPPER_BOUND. + if (!found && bias === LEAST_UPPER_BOUND) + min++; + if (min === -1 || min === segments.length) + return []; + // We may have found the segment that started at an earlier column. If this is the case, then we + // need to slice all generated segments that match _that_ column, because all such segments span + // to our desired column. + const matchedColumn = found ? column : segments[min][COLUMN]; + // The binary search is not guaranteed to find the lower bound when a match wasn't found. + if (!found) + min = lowerBound(segments, matchedColumn, min); + const max = upperBound(segments, matchedColumn, min); + const result = []; + for (; min <= max; min++) { + const segment = segments[min]; + result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); + } + return result; +} + +export { AnyMap, GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap, allGeneratedPositionsFor, decodedMap, decodedMappings, eachMapping, encodedMap, encodedMappings, generatedPositionFor, originalPositionFor, presortedDecodedMap, sourceContentFor, traceSegment }; +//# sourceMappingURL=trace-mapping.mjs.map diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map new file mode 100644 index 000000000..8bb980883 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"trace-mapping.mjs","sources":["../src/resolve.ts","../src/strip-filename.ts","../src/sourcemap-segment.ts","../src/sort.ts","../src/binary-search.ts","../src/by-source.ts","../src/any-map.ts","../src/trace-mapping.ts"],"sourcesContent":["import resolveUri from '@jridgewell/resolve-uri';\n\nexport default function resolve(input: string, base: string | undefined): string {\n // The base is always treated as a directory, if it's not empty.\n // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327\n // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401\n if (base && !base.endsWith('/')) base += '/';\n\n return resolveUri(input, base);\n}\n","/**\n * Removes everything after the last \"/\", but leaves the slash.\n */\nexport default function stripFilename(path: string | undefined | null): string {\n if (!path) return '';\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n","type GeneratedColumn = number;\ntype SourcesIndex = number;\ntype SourceLine = number;\ntype SourceColumn = number;\ntype NamesIndex = number;\n\ntype GeneratedLine = number;\n\nexport type SourceMapSegment =\n | [GeneratedColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];\n\nexport type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn];\n\nexport const COLUMN = 0;\nexport const SOURCES_INDEX = 1;\nexport const SOURCE_LINE = 2;\nexport const SOURCE_COLUMN = 3;\nexport const NAMES_INDEX = 4;\n\nexport const REV_GENERATED_LINE = 1;\nexport const REV_GENERATED_COLUMN = 2;\n","import { COLUMN } from './sourcemap-segment';\n\nimport type { SourceMapSegment } from './sourcemap-segment';\n\nexport default function maybeSort(\n mappings: SourceMapSegment[][],\n owned: boolean,\n): SourceMapSegment[][] {\n const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);\n if (unsortedIndex === mappings.length) return mappings;\n\n // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If\n // not, we do not want to modify the consumer's input array.\n if (!owned) mappings = mappings.slice();\n\n for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {\n mappings[i] = sortSegments(mappings[i], owned);\n }\n return mappings;\n}\n\nfunction nextUnsortedSegmentLine(mappings: SourceMapSegment[][], start: number): number {\n for (let i = start; i < mappings.length; i++) {\n if (!isSorted(mappings[i])) return i;\n }\n return mappings.length;\n}\n\nfunction isSorted(line: SourceMapSegment[]): boolean {\n for (let j = 1; j < line.length; j++) {\n if (line[j][COLUMN] < line[j - 1][COLUMN]) {\n return false;\n }\n }\n return true;\n}\n\nfunction sortSegments(line: SourceMapSegment[], owned: boolean): SourceMapSegment[] {\n if (!owned) line = line.slice();\n return line.sort(sortComparator);\n}\n\nfunction sortComparator(a: SourceMapSegment, b: SourceMapSegment): number {\n return a[COLUMN] - b[COLUMN];\n}\n","import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment';\nimport { COLUMN } from './sourcemap-segment';\n\nexport type MemoState = {\n lastKey: number;\n lastNeedle: number;\n lastIndex: number;\n};\n\nexport let found = false;\n\n/**\n * A binary search implementation that returns the index if a match is found.\n * If no match is found, then the left-index (the index associated with the item that comes just\n * before the desired index) is returned. To maintain proper sort order, a splice would happen at\n * the next index:\n *\n * ```js\n * const array = [1, 3];\n * const needle = 2;\n * const index = binarySearch(array, needle, (item, needle) => item - needle);\n *\n * assert.equal(index, 0);\n * array.splice(index + 1, 0, needle);\n * assert.deepEqual(array, [1, 2, 3]);\n * ```\n */\nexport function binarySearch(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n low: number,\n high: number,\n): number {\n while (low <= high) {\n const mid = low + ((high - low) >> 1);\n const cmp = haystack[mid][COLUMN] - needle;\n\n if (cmp === 0) {\n found = true;\n return mid;\n }\n\n if (cmp < 0) {\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n found = false;\n return low - 1;\n}\n\nexport function upperBound(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n index: number,\n): number {\n for (let i = index + 1; i < haystack.length; index = i++) {\n if (haystack[i][COLUMN] !== needle) break;\n }\n return index;\n}\n\nexport function lowerBound(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n index: number,\n): number {\n for (let i = index - 1; i >= 0; index = i--) {\n if (haystack[i][COLUMN] !== needle) break;\n }\n return index;\n}\n\nexport function memoizedState(): MemoState {\n return {\n lastKey: -1,\n lastNeedle: -1,\n lastIndex: -1,\n };\n}\n\n/**\n * This overly complicated beast is just to record the last tested line/column and the resulting\n * index, allowing us to skip a few tests if mappings are monotonically increasing.\n */\nexport function memoizedBinarySearch(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n state: MemoState,\n key: number,\n): number {\n const { lastKey, lastNeedle, lastIndex } = state;\n\n let low = 0;\n let high = haystack.length - 1;\n if (key === lastKey) {\n if (needle === lastNeedle) {\n found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;\n return lastIndex;\n }\n\n if (needle >= lastNeedle) {\n // lastIndex may be -1 if the previous needle was not found.\n low = lastIndex === -1 ? 0 : lastIndex;\n } else {\n high = lastIndex;\n }\n }\n state.lastKey = key;\n state.lastNeedle = needle;\n\n return (state.lastIndex = binarySearch(haystack, needle, low, high));\n}\n","import { COLUMN, SOURCES_INDEX, SOURCE_LINE, SOURCE_COLUMN } from './sourcemap-segment';\nimport { memoizedBinarySearch, upperBound } from './binary-search';\n\nimport type { ReverseSegment, SourceMapSegment } from './sourcemap-segment';\nimport type { MemoState } from './binary-search';\n\nexport type Source = {\n __proto__: null;\n [line: number]: Exclude[];\n};\n\n// Rebuilds the original source files, with mappings that are ordered by source line/column instead\n// of generated line/column.\nexport default function buildBySources(\n decoded: readonly SourceMapSegment[][],\n memos: MemoState[],\n): Source[] {\n const sources: Source[] = memos.map(buildNullArray);\n\n for (let i = 0; i < decoded.length; i++) {\n const line = decoded[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n if (seg.length === 1) continue;\n\n const sourceIndex = seg[SOURCES_INDEX];\n const sourceLine = seg[SOURCE_LINE];\n const sourceColumn = seg[SOURCE_COLUMN];\n const originalSource = sources[sourceIndex];\n const originalLine = (originalSource[sourceLine] ||= []);\n const memo = memos[sourceIndex];\n\n // The binary search either found a match, or it found the left-index just before where the\n // segment should go. Either way, we want to insert after that. And there may be multiple\n // generated segments associated with an original location, so there may need to move several\n // indexes before we find where we need to insert.\n const index = upperBound(\n originalLine,\n sourceColumn,\n memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine),\n );\n\n insert(originalLine, (memo.lastIndex = index + 1), [sourceColumn, i, seg[COLUMN]]);\n }\n }\n\n return sources;\n}\n\nfunction insert(array: T[], index: number, value: T) {\n for (let i = array.length; i > index; i--) {\n array[i] = array[i - 1];\n }\n array[index] = value;\n}\n\n// Null arrays allow us to use ordered index keys without actually allocating contiguous memory like\n// a real array. We use a null-prototype object to avoid prototype pollution and deoptimizations.\n// Numeric properties on objects are magically sorted in ascending order by the engine regardless of\n// the insertion order. So, by setting any numeric keys, even out of order, we'll get ascending\n// order when iterating with for-in.\nfunction buildNullArray(): T {\n return { __proto__: null } as T;\n}\n","import { TraceMap, presortedDecodedMap, decodedMappings } from './trace-mapping';\nimport {\n COLUMN,\n SOURCES_INDEX,\n SOURCE_LINE,\n SOURCE_COLUMN,\n NAMES_INDEX,\n} from './sourcemap-segment';\n\nimport type {\n Section,\n SectionedSourceMap,\n DecodedSourceMap,\n SectionedSourceMapInput,\n Ro,\n} from './types';\nimport type { SourceMapSegment } from './sourcemap-segment';\n\ntype AnyMap = {\n new (map: SectionedSourceMapInput, mapUrl?: string | null): TraceMap;\n (map: SectionedSourceMapInput, mapUrl?: string | null): TraceMap;\n};\n\nexport const AnyMap: AnyMap = function (map, mapUrl) {\n const parsed =\n typeof map === 'string' ? (JSON.parse(map) as Exclude) : map;\n\n if (!('sections' in parsed)) return new TraceMap(parsed, mapUrl);\n\n const mappings: SourceMapSegment[][] = [];\n const sources: string[] = [];\n const sourcesContent: (string | null)[] = [];\n const names: string[] = [];\n\n recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, 0, 0, Infinity, Infinity);\n\n const joined: DecodedSourceMap = {\n version: 3,\n file: parsed.file,\n names,\n sources,\n sourcesContent,\n mappings,\n };\n\n return presortedDecodedMap(joined);\n} as AnyMap;\n\nfunction recurse(\n input: Ro,\n mapUrl: string | null | undefined,\n mappings: SourceMapSegment[][],\n sources: string[],\n sourcesContent: (string | null)[],\n names: string[],\n lineOffset: number,\n columnOffset: number,\n stopLine: number,\n stopColumn: number,\n) {\n const { sections } = input;\n for (let i = 0; i < sections.length; i++) {\n const { map, offset } = sections[i];\n\n let sl = stopLine;\n let sc = stopColumn;\n if (i + 1 < sections.length) {\n const nextOffset = sections[i + 1].offset;\n sl = Math.min(stopLine, lineOffset + nextOffset.line);\n\n if (sl === stopLine) {\n sc = Math.min(stopColumn, columnOffset + nextOffset.column);\n } else if (sl < stopLine) {\n sc = columnOffset + nextOffset.column;\n }\n }\n\n addSection(\n map,\n mapUrl,\n mappings,\n sources,\n sourcesContent,\n names,\n lineOffset + offset.line,\n columnOffset + offset.column,\n sl,\n sc,\n );\n }\n}\n\nfunction addSection(\n input: Ro,\n mapUrl: string | null | undefined,\n mappings: SourceMapSegment[][],\n sources: string[],\n sourcesContent: (string | null)[],\n names: string[],\n lineOffset: number,\n columnOffset: number,\n stopLine: number,\n stopColumn: number,\n) {\n if ('sections' in input) return recurse(...(arguments as unknown as Parameters));\n\n const map = new TraceMap(input, mapUrl);\n const sourcesOffset = sources.length;\n const namesOffset = names.length;\n const decoded = decodedMappings(map);\n const { resolvedSources, sourcesContent: contents } = map;\n\n append(sources, resolvedSources);\n append(names, map.names);\n if (contents) append(sourcesContent, contents);\n else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null);\n\n for (let i = 0; i < decoded.length; i++) {\n const lineI = lineOffset + i;\n\n // We can only add so many lines before we step into the range that the next section's map\n // controls. When we get to the last line, then we'll start checking the segments to see if\n // they've crossed into the column range. But it may not have any columns that overstep, so we\n // still need to check that we don't overstep lines, too.\n if (lineI > stopLine) return;\n\n // The out line may already exist in mappings (if we're continuing the line started by a\n // previous section). Or, we may have jumped ahead several lines to start this section.\n const out = getLine(mappings, lineI);\n // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the\n // map can be multiple lines), it doesn't.\n const cOffset = i === 0 ? columnOffset : 0;\n\n const line = decoded[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n const column = cOffset + seg[COLUMN];\n\n // If this segment steps into the column range that the next section's map controls, we need\n // to stop early.\n if (lineI === stopLine && column >= stopColumn) return;\n\n if (seg.length === 1) {\n out.push([column]);\n continue;\n }\n\n const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];\n const sourceLine = seg[SOURCE_LINE];\n const sourceColumn = seg[SOURCE_COLUMN];\n out.push(\n seg.length === 4\n ? [column, sourcesIndex, sourceLine, sourceColumn]\n : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]],\n );\n }\n }\n}\n\nfunction append(arr: T[], other: T[]) {\n for (let i = 0; i < other.length; i++) arr.push(other[i]);\n}\n\nfunction getLine(arr: T[][], index: number): T[] {\n for (let i = arr.length; i <= index; i++) arr[i] = [];\n return arr[index];\n}\n","import { encode, decode } from '@jridgewell/sourcemap-codec';\n\nimport resolve from './resolve';\nimport stripFilename from './strip-filename';\nimport maybeSort from './sort';\nimport buildBySources from './by-source';\nimport {\n memoizedState,\n memoizedBinarySearch,\n upperBound,\n lowerBound,\n found as bsFound,\n} from './binary-search';\nimport {\n COLUMN,\n SOURCES_INDEX,\n SOURCE_LINE,\n SOURCE_COLUMN,\n NAMES_INDEX,\n REV_GENERATED_LINE,\n REV_GENERATED_COLUMN,\n} from './sourcemap-segment';\n\nimport type { SourceMapSegment, ReverseSegment } from './sourcemap-segment';\nimport type {\n SourceMapV3,\n DecodedSourceMap,\n EncodedSourceMap,\n InvalidOriginalMapping,\n OriginalMapping,\n InvalidGeneratedMapping,\n GeneratedMapping,\n SourceMapInput,\n Needle,\n SourceNeedle,\n SourceMap,\n EachMapping,\n Bias,\n} from './types';\nimport type { Source } from './by-source';\nimport type { MemoState } from './binary-search';\n\nexport type { SourceMapSegment } from './sourcemap-segment';\nexport type {\n SourceMapInput,\n SectionedSourceMapInput,\n DecodedSourceMap,\n EncodedSourceMap,\n SectionedSourceMap,\n InvalidOriginalMapping,\n OriginalMapping as Mapping,\n OriginalMapping,\n InvalidGeneratedMapping,\n GeneratedMapping,\n EachMapping,\n} from './types';\n\nconst LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';\nconst COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';\n\nexport const LEAST_UPPER_BOUND = -1;\nexport const GREATEST_LOWER_BOUND = 1;\n\n/**\n * Returns the encoded (VLQ string) form of the SourceMap's mappings field.\n */\nexport let encodedMappings: (map: TraceMap) => EncodedSourceMap['mappings'];\n\n/**\n * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.\n */\nexport let decodedMappings: (map: TraceMap) => Readonly;\n\n/**\n * A low-level API to find the segment associated with a generated line/column (think, from a\n * stack trace). Line and column here are 0-based, unlike `originalPositionFor`.\n */\nexport let traceSegment: (\n map: TraceMap,\n line: number,\n column: number,\n) => Readonly | null;\n\n/**\n * A higher-level API to find the source/line/column associated with a generated line/column\n * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in\n * `source-map` library.\n */\nexport let originalPositionFor: (\n map: TraceMap,\n needle: Needle,\n) => OriginalMapping | InvalidOriginalMapping;\n\n/**\n * Finds the generated line/column position of the provided source/line/column source position.\n */\nexport let generatedPositionFor: (\n map: TraceMap,\n needle: SourceNeedle,\n) => GeneratedMapping | InvalidGeneratedMapping;\n\n/**\n * Finds all generated line/column positions of the provided source/line/column source position.\n */\nexport let allGeneratedPositionsFor: (map: TraceMap, needle: SourceNeedle) => GeneratedMapping[];\n\n/**\n * Iterates each mapping in generated position order.\n */\nexport let eachMapping: (map: TraceMap, cb: (mapping: EachMapping) => void) => void;\n\n/**\n * Retrieves the source content for a particular source, if its found. Returns null if not.\n */\nexport let sourceContentFor: (map: TraceMap, source: string) => string | null;\n\n/**\n * A helper that skips sorting of the input map's mappings array, which can be expensive for larger\n * maps.\n */\nexport let presortedDecodedMap: (map: DecodedSourceMap, mapUrl?: string) => TraceMap;\n\n/**\n * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport let decodedMap: (\n map: TraceMap,\n) => Omit & { mappings: readonly SourceMapSegment[][] };\n\n/**\n * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport let encodedMap: (map: TraceMap) => EncodedSourceMap;\n\nexport { AnyMap } from './any-map';\n\nexport class TraceMap implements SourceMap {\n declare version: SourceMapV3['version'];\n declare file: SourceMapV3['file'];\n declare names: SourceMapV3['names'];\n declare sourceRoot: SourceMapV3['sourceRoot'];\n declare sources: SourceMapV3['sources'];\n declare sourcesContent: SourceMapV3['sourcesContent'];\n\n declare resolvedSources: string[];\n private declare _encoded: string | undefined;\n\n private declare _decoded: SourceMapSegment[][] | undefined;\n private declare _decodedMemo: MemoState;\n\n private declare _bySources: Source[] | undefined;\n private declare _bySourceMemos: MemoState[] | undefined;\n\n constructor(map: SourceMapInput, mapUrl?: string | null) {\n const isString = typeof map === 'string';\n\n if (!isString && (map as unknown as { _decodedMemo: any })._decodedMemo) return map as TraceMap;\n\n const parsed = (isString ? JSON.parse(map) : map) as DecodedSourceMap | EncodedSourceMap;\n\n const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;\n this.version = version;\n this.file = file;\n this.names = names || [];\n this.sourceRoot = sourceRoot;\n this.sources = sources;\n this.sourcesContent = sourcesContent;\n\n const from = resolve(sourceRoot || '', stripFilename(mapUrl));\n this.resolvedSources = sources.map((s) => resolve(s || '', from));\n\n const { mappings } = parsed;\n if (typeof mappings === 'string') {\n this._encoded = mappings;\n this._decoded = undefined;\n } else {\n this._encoded = undefined;\n this._decoded = maybeSort(mappings, isString);\n }\n\n this._decodedMemo = memoizedState();\n this._bySources = undefined;\n this._bySourceMemos = undefined;\n }\n\n static {\n encodedMappings = (map) => {\n return (map._encoded ??= encode(map._decoded!));\n };\n\n decodedMappings = (map) => {\n return (map._decoded ||= decode(map._encoded!));\n };\n\n traceSegment = (map, line, column) => {\n const decoded = decodedMappings(map);\n\n // It's common for parent source maps to have pointers to lines that have no\n // mapping (like a \"//# sourceMappingURL=\") at the end of the child file.\n if (line >= decoded.length) return null;\n\n const segments = decoded[line];\n const index = traceSegmentInternal(\n segments,\n map._decodedMemo,\n line,\n column,\n GREATEST_LOWER_BOUND,\n );\n\n return index === -1 ? null : segments[index];\n };\n\n originalPositionFor = (map, { line, column, bias }) => {\n line--;\n if (line < 0) throw new Error(LINE_GTR_ZERO);\n if (column < 0) throw new Error(COL_GTR_EQ_ZERO);\n\n const decoded = decodedMappings(map);\n\n // It's common for parent source maps to have pointers to lines that have no\n // mapping (like a \"//# sourceMappingURL=\") at the end of the child file.\n if (line >= decoded.length) return OMapping(null, null, null, null);\n\n const segments = decoded[line];\n const index = traceSegmentInternal(\n segments,\n map._decodedMemo,\n line,\n column,\n bias || GREATEST_LOWER_BOUND,\n );\n\n if (index === -1) return OMapping(null, null, null, null);\n\n const segment = segments[index];\n if (segment.length === 1) return OMapping(null, null, null, null);\n\n const { names, resolvedSources } = map;\n return OMapping(\n resolvedSources[segment[SOURCES_INDEX]],\n segment[SOURCE_LINE] + 1,\n segment[SOURCE_COLUMN],\n segment.length === 5 ? names[segment[NAMES_INDEX]] : null,\n );\n };\n\n allGeneratedPositionsFor = (map, { source, line, column, bias }) => {\n // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit.\n return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);\n };\n\n generatedPositionFor = (map, { source, line, column, bias }) => {\n return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);\n };\n\n eachMapping = (map, cb) => {\n const decoded = decodedMappings(map);\n const { names, resolvedSources } = map;\n\n for (let i = 0; i < decoded.length; i++) {\n const line = decoded[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n\n const generatedLine = i + 1;\n const generatedColumn = seg[0];\n let source = null;\n let originalLine = null;\n let originalColumn = null;\n let name = null;\n if (seg.length !== 1) {\n source = resolvedSources[seg[1]];\n originalLine = seg[2] + 1;\n originalColumn = seg[3];\n }\n if (seg.length === 5) name = names[seg[4]];\n\n cb({\n generatedLine,\n generatedColumn,\n source,\n originalLine,\n originalColumn,\n name,\n } as EachMapping);\n }\n }\n };\n\n sourceContentFor = (map, source) => {\n const { sources, resolvedSources, sourcesContent } = map;\n if (sourcesContent == null) return null;\n\n let index = sources.indexOf(source);\n if (index === -1) index = resolvedSources.indexOf(source);\n\n return index === -1 ? null : sourcesContent[index];\n };\n\n presortedDecodedMap = (map, mapUrl) => {\n const tracer = new TraceMap(clone(map, []), mapUrl);\n tracer._decoded = map.mappings;\n return tracer;\n };\n\n decodedMap = (map) => {\n return clone(map, decodedMappings(map));\n };\n\n encodedMap = (map) => {\n return clone(map, encodedMappings(map));\n };\n\n function generatedPosition(\n map: TraceMap,\n source: string,\n line: number,\n column: number,\n bias: Bias,\n all: false,\n ): GeneratedMapping | InvalidGeneratedMapping;\n function generatedPosition(\n map: TraceMap,\n source: string,\n line: number,\n column: number,\n bias: Bias,\n all: true,\n ): GeneratedMapping[];\n function generatedPosition(\n map: TraceMap,\n source: string,\n line: number,\n column: number,\n bias: Bias,\n all: boolean,\n ): GeneratedMapping | InvalidGeneratedMapping | GeneratedMapping[] {\n line--;\n if (line < 0) throw new Error(LINE_GTR_ZERO);\n if (column < 0) throw new Error(COL_GTR_EQ_ZERO);\n\n const { sources, resolvedSources } = map;\n let sourceIndex = sources.indexOf(source);\n if (sourceIndex === -1) sourceIndex = resolvedSources.indexOf(source);\n if (sourceIndex === -1) return all ? [] : GMapping(null, null);\n\n const generated = (map._bySources ||= buildBySources(\n decodedMappings(map),\n (map._bySourceMemos = sources.map(memoizedState)),\n ));\n\n const segments = generated[sourceIndex][line];\n if (segments == null) return all ? [] : GMapping(null, null);\n\n const memo = map._bySourceMemos![sourceIndex];\n\n if (all) return sliceGeneratedPositions(segments, memo, line, column, bias);\n\n const index = traceSegmentInternal(segments, memo, line, column, bias);\n if (index === -1) return GMapping(null, null);\n\n const segment = segments[index];\n return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);\n }\n }\n}\n\nfunction clone(\n map: TraceMap | DecodedSourceMap | EncodedSourceMap,\n mappings: T,\n): T extends string ? EncodedSourceMap : DecodedSourceMap {\n return {\n version: map.version,\n file: map.file,\n names: map.names,\n sourceRoot: map.sourceRoot,\n sources: map.sources,\n sourcesContent: map.sourcesContent,\n mappings,\n } as any;\n}\n\nfunction OMapping(source: null, line: null, column: null, name: null): InvalidOriginalMapping;\nfunction OMapping(\n source: string,\n line: number,\n column: number,\n name: string | null,\n): OriginalMapping;\nfunction OMapping(\n source: string | null,\n line: number | null,\n column: number | null,\n name: string | null,\n): OriginalMapping | InvalidOriginalMapping {\n return { source, line, column, name } as any;\n}\n\nfunction GMapping(line: null, column: null): InvalidGeneratedMapping;\nfunction GMapping(line: number, column: number): GeneratedMapping;\nfunction GMapping(\n line: number | null,\n column: number | null,\n): GeneratedMapping | InvalidGeneratedMapping {\n return { line, column } as any;\n}\n\nfunction traceSegmentInternal(\n segments: SourceMapSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): number;\nfunction traceSegmentInternal(\n segments: ReverseSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): number;\nfunction traceSegmentInternal(\n segments: SourceMapSegment[] | ReverseSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): number {\n let index = memoizedBinarySearch(segments, column, memo, line);\n if (bsFound) {\n index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);\n } else if (bias === LEAST_UPPER_BOUND) index++;\n\n if (index === -1 || index === segments.length) return -1;\n return index;\n}\n\nfunction sliceGeneratedPositions(\n segments: ReverseSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): GeneratedMapping[] {\n let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);\n\n // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in\n // insertion order) segment that matched. Even if we did respect the bias when tracing, we would\n // still need to call `lowerBound()` to find the first segment, which is slower than just looking\n // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the\n // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to\n // match LEAST_UPPER_BOUND.\n if (!bsFound && bias === LEAST_UPPER_BOUND) min++;\n\n if (min === -1 || min === segments.length) return [];\n\n // We may have found the segment that started at an earlier column. If this is the case, then we\n // need to slice all generated segments that match _that_ column, because all such segments span\n // to our desired column.\n const matchedColumn = bsFound ? column : segments[min][COLUMN];\n\n // The binary search is not guaranteed to find the lower bound when a match wasn't found.\n if (!bsFound) min = lowerBound(segments, matchedColumn, min);\n const max = upperBound(segments, matchedColumn, min);\n\n const result = [];\n for (; min <= max; min++) {\n const segment = segments[min];\n result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));\n }\n return result;\n}\n"],"names":["bsFound"],"mappings":";;;AAEc,SAAU,OAAO,CAAC,KAAa,EAAE,IAAwB,EAAA;;;;IAIrE,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,IAAI,IAAI,GAAG,CAAC;AAE7C,IAAA,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACjC;;ACTA;;AAEG;AACqB,SAAA,aAAa,CAAC,IAA+B,EAAA;AACnE,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,OAAO,EAAE,CAAC;IACrB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AAClC;;ACQO,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,oBAAoB,GAAG,CAAC;;AClBvB,SAAU,SAAS,CAC/B,QAA8B,EAC9B,KAAc,EAAA;IAEd,MAAM,aAAa,GAAG,uBAAuB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;AAC3D,IAAA,IAAI,aAAa,KAAK,QAAQ,CAAC,MAAM;AAAE,QAAA,OAAO,QAAQ,CAAC;;;AAIvD,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,QAAQ,GAA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QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9B,QAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;AACvF,KAAA;AACD,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js new file mode 100644 index 000000000..8b67ffb94 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js @@ -0,0 +1,566 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/sourcemap-codec'), require('@jridgewell/resolve-uri')) : + typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/sourcemap-codec', '@jridgewell/resolve-uri'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.traceMapping = {}, global.sourcemapCodec, global.resolveURI)); +})(this, (function (exports, sourcemapCodec, resolveUri) { 'use strict'; + + function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + + var resolveUri__default = /*#__PURE__*/_interopDefaultLegacy(resolveUri); + + function resolve(input, base) { + // The base is always treated as a directory, if it's not empty. + // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327 + // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401 + if (base && !base.endsWith('/')) + base += '/'; + return resolveUri__default["default"](input, base); + } + + /** + * Removes everything after the last "/", but leaves the slash. + */ + function stripFilename(path) { + if (!path) + return ''; + const index = path.lastIndexOf('/'); + return path.slice(0, index + 1); + } + + const COLUMN = 0; + const SOURCES_INDEX = 1; + const SOURCE_LINE = 2; + const SOURCE_COLUMN = 3; + const NAMES_INDEX = 4; + const REV_GENERATED_LINE = 1; + const REV_GENERATED_COLUMN = 2; + + function maybeSort(mappings, owned) { + const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); + if (unsortedIndex === mappings.length) + return mappings; + // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If + // not, we do not want to modify the consumer's input array. + if (!owned) + mappings = mappings.slice(); + for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { + mappings[i] = sortSegments(mappings[i], owned); + } + return mappings; + } + function nextUnsortedSegmentLine(mappings, start) { + for (let i = start; i < mappings.length; i++) { + if (!isSorted(mappings[i])) + return i; + } + return mappings.length; + } + function isSorted(line) { + for (let j = 1; j < line.length; j++) { + if (line[j][COLUMN] < line[j - 1][COLUMN]) { + return false; + } + } + return true; + } + function sortSegments(line, owned) { + if (!owned) + line = line.slice(); + return line.sort(sortComparator); + } + function sortComparator(a, b) { + return a[COLUMN] - b[COLUMN]; + } + + let found = false; + /** + * A binary search implementation that returns the index if a match is found. + * If no match is found, then the left-index (the index associated with the item that comes just + * before the desired index) is returned. To maintain proper sort order, a splice would happen at + * the next index: + * + * ```js + * const array = [1, 3]; + * const needle = 2; + * const index = binarySearch(array, needle, (item, needle) => item - needle); + * + * assert.equal(index, 0); + * array.splice(index + 1, 0, needle); + * assert.deepEqual(array, [1, 2, 3]); + * ``` + */ + function binarySearch(haystack, needle, low, high) { + while (low <= high) { + const mid = low + ((high - low) >> 1); + const cmp = haystack[mid][COLUMN] - needle; + if (cmp === 0) { + found = true; + return mid; + } + if (cmp < 0) { + low = mid + 1; + } + else { + high = mid - 1; + } + } + found = false; + return low - 1; + } + function upperBound(haystack, needle, index) { + for (let i = index + 1; i < haystack.length; index = i++) { + if (haystack[i][COLUMN] !== needle) + break; + } + return index; + } + function lowerBound(haystack, needle, index) { + for (let i = index - 1; i >= 0; index = i--) { + if (haystack[i][COLUMN] !== needle) + break; + } + return index; + } + function memoizedState() { + return { + lastKey: -1, + lastNeedle: -1, + lastIndex: -1, + }; + } + /** + * This overly complicated beast is just to record the last tested line/column and the resulting + * index, allowing us to skip a few tests if mappings are monotonically increasing. + */ + function memoizedBinarySearch(haystack, needle, state, key) { + const { lastKey, lastNeedle, lastIndex } = state; + let low = 0; + let high = haystack.length - 1; + if (key === lastKey) { + if (needle === lastNeedle) { + found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; + return lastIndex; + } + if (needle >= lastNeedle) { + // lastIndex may be -1 if the previous needle was not found. + low = lastIndex === -1 ? 0 : lastIndex; + } + else { + high = lastIndex; + } + } + state.lastKey = key; + state.lastNeedle = needle; + return (state.lastIndex = binarySearch(haystack, needle, low, high)); + } + + // Rebuilds the original source files, with mappings that are ordered by source line/column instead + // of generated line/column. + function buildBySources(decoded, memos) { + const sources = memos.map(buildNullArray); + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + if (seg.length === 1) + continue; + const sourceIndex = seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + const originalSource = sources[sourceIndex]; + const originalLine = (originalSource[sourceLine] || (originalSource[sourceLine] = [])); + const memo = memos[sourceIndex]; + // The binary search either found a match, or it found the left-index just before where the + // segment should go. Either way, we want to insert after that. And there may be multiple + // generated segments associated with an original location, so there may need to move several + // indexes before we find where we need to insert. + const index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine)); + insert(originalLine, (memo.lastIndex = index + 1), [sourceColumn, i, seg[COLUMN]]); + } + } + return sources; + } + function insert(array, index, value) { + for (let i = array.length; i > index; i--) { + array[i] = array[i - 1]; + } + array[index] = value; + } + // Null arrays allow us to use ordered index keys without actually allocating contiguous memory like + // a real array. We use a null-prototype object to avoid prototype pollution and deoptimizations. + // Numeric properties on objects are magically sorted in ascending order by the engine regardless of + // the insertion order. So, by setting any numeric keys, even out of order, we'll get ascending + // order when iterating with for-in. + function buildNullArray() { + return { __proto__: null }; + } + + const AnyMap = function (map, mapUrl) { + const parsed = typeof map === 'string' ? JSON.parse(map) : map; + if (!('sections' in parsed)) + return new TraceMap(parsed, mapUrl); + const mappings = []; + const sources = []; + const sourcesContent = []; + const names = []; + recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, 0, 0, Infinity, Infinity); + const joined = { + version: 3, + file: parsed.file, + names, + sources, + sourcesContent, + mappings, + }; + return exports.presortedDecodedMap(joined); + }; + function recurse(input, mapUrl, mappings, sources, sourcesContent, names, lineOffset, columnOffset, stopLine, stopColumn) { + const { sections } = input; + for (let i = 0; i < sections.length; i++) { + const { map, offset } = sections[i]; + let sl = stopLine; + let sc = stopColumn; + if (i + 1 < sections.length) { + const nextOffset = sections[i + 1].offset; + sl = Math.min(stopLine, lineOffset + nextOffset.line); + if (sl === stopLine) { + sc = Math.min(stopColumn, columnOffset + nextOffset.column); + } + else if (sl < stopLine) { + sc = columnOffset + nextOffset.column; + } + } + addSection(map, mapUrl, mappings, sources, sourcesContent, names, lineOffset + offset.line, columnOffset + offset.column, sl, sc); + } + } + function addSection(input, mapUrl, mappings, sources, sourcesContent, names, lineOffset, columnOffset, stopLine, stopColumn) { + if ('sections' in input) + return recurse(...arguments); + const map = new TraceMap(input, mapUrl); + const sourcesOffset = sources.length; + const namesOffset = names.length; + const decoded = exports.decodedMappings(map); + const { resolvedSources, sourcesContent: contents } = map; + append(sources, resolvedSources); + append(names, map.names); + if (contents) + append(sourcesContent, contents); + else + for (let i = 0; i < resolvedSources.length; i++) + sourcesContent.push(null); + for (let i = 0; i < decoded.length; i++) { + const lineI = lineOffset + i; + // We can only add so many lines before we step into the range that the next section's map + // controls. When we get to the last line, then we'll start checking the segments to see if + // they've crossed into the column range. But it may not have any columns that overstep, so we + // still need to check that we don't overstep lines, too. + if (lineI > stopLine) + return; + // The out line may already exist in mappings (if we're continuing the line started by a + // previous section). Or, we may have jumped ahead several lines to start this section. + const out = getLine(mappings, lineI); + // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the + // map can be multiple lines), it doesn't. + const cOffset = i === 0 ? columnOffset : 0; + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const column = cOffset + seg[COLUMN]; + // If this segment steps into the column range that the next section's map controls, we need + // to stop early. + if (lineI === stopLine && column >= stopColumn) + return; + if (seg.length === 1) { + out.push([column]); + continue; + } + const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; + const sourceLine = seg[SOURCE_LINE]; + const sourceColumn = seg[SOURCE_COLUMN]; + out.push(seg.length === 4 + ? [column, sourcesIndex, sourceLine, sourceColumn] + : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]]); + } + } + } + function append(arr, other) { + for (let i = 0; i < other.length; i++) + arr.push(other[i]); + } + function getLine(arr, index) { + for (let i = arr.length; i <= index; i++) + arr[i] = []; + return arr[index]; + } + + const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)'; + const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)'; + const LEAST_UPPER_BOUND = -1; + const GREATEST_LOWER_BOUND = 1; + /** + * Returns the encoded (VLQ string) form of the SourceMap's mappings field. + */ + exports.encodedMappings = void 0; + /** + * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. + */ + exports.decodedMappings = void 0; + /** + * A low-level API to find the segment associated with a generated line/column (think, from a + * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. + */ + exports.traceSegment = void 0; + /** + * A higher-level API to find the source/line/column associated with a generated line/column + * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in + * `source-map` library. + */ + exports.originalPositionFor = void 0; + /** + * Finds the generated line/column position of the provided source/line/column source position. + */ + exports.generatedPositionFor = void 0; + /** + * Finds all generated line/column positions of the provided source/line/column source position. + */ + exports.allGeneratedPositionsFor = void 0; + /** + * Iterates each mapping in generated position order. + */ + exports.eachMapping = void 0; + /** + * Retrieves the source content for a particular source, if its found. Returns null if not. + */ + exports.sourceContentFor = void 0; + /** + * A helper that skips sorting of the input map's mappings array, which can be expensive for larger + * maps. + */ + exports.presortedDecodedMap = void 0; + /** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ + exports.decodedMap = void 0; + /** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ + exports.encodedMap = void 0; + class TraceMap { + constructor(map, mapUrl) { + const isString = typeof map === 'string'; + if (!isString && map._decodedMemo) + return map; + const parsed = (isString ? JSON.parse(map) : map); + const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; + this.version = version; + this.file = file; + this.names = names || []; + this.sourceRoot = sourceRoot; + this.sources = sources; + this.sourcesContent = sourcesContent; + const from = resolve(sourceRoot || '', stripFilename(mapUrl)); + this.resolvedSources = sources.map((s) => resolve(s || '', from)); + const { mappings } = parsed; + if (typeof mappings === 'string') { + this._encoded = mappings; + this._decoded = undefined; + } + else { + this._encoded = undefined; + this._decoded = maybeSort(mappings, isString); + } + this._decodedMemo = memoizedState(); + this._bySources = undefined; + this._bySourceMemos = undefined; + } + } + (() => { + exports.encodedMappings = (map) => { + var _a; + return ((_a = map._encoded) !== null && _a !== void 0 ? _a : (map._encoded = sourcemapCodec.encode(map._decoded))); + }; + exports.decodedMappings = (map) => { + return (map._decoded || (map._decoded = sourcemapCodec.decode(map._encoded))); + }; + exports.traceSegment = (map, line, column) => { + const decoded = exports.decodedMappings(map); + // It's common for parent source maps to have pointers to lines that have no + // mapping (like a "//# sourceMappingURL=") at the end of the child file. + if (line >= decoded.length) + return null; + const segments = decoded[line]; + const index = traceSegmentInternal(segments, map._decodedMemo, line, column, GREATEST_LOWER_BOUND); + return index === -1 ? null : segments[index]; + }; + exports.originalPositionFor = (map, { line, column, bias }) => { + line--; + if (line < 0) + throw new Error(LINE_GTR_ZERO); + if (column < 0) + throw new Error(COL_GTR_EQ_ZERO); + const decoded = exports.decodedMappings(map); + // It's common for parent source maps to have pointers to lines that have no + // mapping (like a "//# sourceMappingURL=") at the end of the child file. + if (line >= decoded.length) + return OMapping(null, null, null, null); + const segments = decoded[line]; + const index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND); + if (index === -1) + return OMapping(null, null, null, null); + const segment = segments[index]; + if (segment.length === 1) + return OMapping(null, null, null, null); + const { names, resolvedSources } = map; + return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null); + }; + exports.allGeneratedPositionsFor = (map, { source, line, column, bias }) => { + // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit. + return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); + }; + exports.generatedPositionFor = (map, { source, line, column, bias }) => { + return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); + }; + exports.eachMapping = (map, cb) => { + const decoded = exports.decodedMappings(map); + const { names, resolvedSources } = map; + for (let i = 0; i < decoded.length; i++) { + const line = decoded[i]; + for (let j = 0; j < line.length; j++) { + const seg = line[j]; + const generatedLine = i + 1; + const generatedColumn = seg[0]; + let source = null; + let originalLine = null; + let originalColumn = null; + let name = null; + if (seg.length !== 1) { + source = resolvedSources[seg[1]]; + originalLine = seg[2] + 1; + originalColumn = seg[3]; + } + if (seg.length === 5) + name = names[seg[4]]; + cb({ + generatedLine, + generatedColumn, + source, + originalLine, + originalColumn, + name, + }); + } + } + }; + exports.sourceContentFor = (map, source) => { + const { sources, resolvedSources, sourcesContent } = map; + if (sourcesContent == null) + return null; + let index = sources.indexOf(source); + if (index === -1) + index = resolvedSources.indexOf(source); + return index === -1 ? null : sourcesContent[index]; + }; + exports.presortedDecodedMap = (map, mapUrl) => { + const tracer = new TraceMap(clone(map, []), mapUrl); + tracer._decoded = map.mappings; + return tracer; + }; + exports.decodedMap = (map) => { + return clone(map, exports.decodedMappings(map)); + }; + exports.encodedMap = (map) => { + return clone(map, exports.encodedMappings(map)); + }; + function generatedPosition(map, source, line, column, bias, all) { + line--; + if (line < 0) + throw new Error(LINE_GTR_ZERO); + if (column < 0) + throw new Error(COL_GTR_EQ_ZERO); + const { sources, resolvedSources } = map; + let sourceIndex = sources.indexOf(source); + if (sourceIndex === -1) + sourceIndex = resolvedSources.indexOf(source); + if (sourceIndex === -1) + return all ? [] : GMapping(null, null); + const generated = (map._bySources || (map._bySources = buildBySources(exports.decodedMappings(map), (map._bySourceMemos = sources.map(memoizedState))))); + const segments = generated[sourceIndex][line]; + if (segments == null) + return all ? [] : GMapping(null, null); + const memo = map._bySourceMemos[sourceIndex]; + if (all) + return sliceGeneratedPositions(segments, memo, line, column, bias); + const index = traceSegmentInternal(segments, memo, line, column, bias); + if (index === -1) + return GMapping(null, null); + const segment = segments[index]; + return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); + } + })(); + function clone(map, mappings) { + return { + version: map.version, + file: map.file, + names: map.names, + sourceRoot: map.sourceRoot, + sources: map.sources, + sourcesContent: map.sourcesContent, + mappings, + }; + } + function OMapping(source, line, column, name) { + return { source, line, column, name }; + } + function GMapping(line, column) { + return { line, column }; + } + function traceSegmentInternal(segments, memo, line, column, bias) { + let index = memoizedBinarySearch(segments, column, memo, line); + if (found) { + index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); + } + else if (bias === LEAST_UPPER_BOUND) + index++; + if (index === -1 || index === segments.length) + return -1; + return index; + } + function sliceGeneratedPositions(segments, memo, line, column, bias) { + let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); + // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in + // insertion order) segment that matched. Even if we did respect the bias when tracing, we would + // still need to call `lowerBound()` to find the first segment, which is slower than just looking + // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the + // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to + // match LEAST_UPPER_BOUND. + if (!found && bias === LEAST_UPPER_BOUND) + min++; + if (min === -1 || min === segments.length) + return []; + // We may have found the segment that started at an earlier column. If this is the case, then we + // need to slice all generated segments that match _that_ column, because all such segments span + // to our desired column. + const matchedColumn = found ? column : segments[min][COLUMN]; + // The binary search is not guaranteed to find the lower bound when a match wasn't found. + if (!found) + min = lowerBound(segments, matchedColumn, min); + const max = upperBound(segments, matchedColumn, min); + const result = []; + for (; min <= max; min++) { + const segment = segments[min]; + result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); + } + return result; + } + + exports.AnyMap = AnyMap; + exports.GREATEST_LOWER_BOUND = GREATEST_LOWER_BOUND; + exports.LEAST_UPPER_BOUND = LEAST_UPPER_BOUND; + exports.TraceMap = TraceMap; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); +//# sourceMappingURL=trace-mapping.umd.js.map diff --git a/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map new file mode 100644 index 000000000..4c4ada324 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"trace-mapping.umd.js","sources":["../src/resolve.ts","../src/strip-filename.ts","../src/sourcemap-segment.ts","../src/sort.ts","../src/binary-search.ts","../src/by-source.ts","../src/any-map.ts","../src/trace-mapping.ts"],"sourcesContent":["import resolveUri from '@jridgewell/resolve-uri';\n\nexport default function resolve(input: string, base: string | undefined): string {\n // The base is always treated as a directory, if it's not empty.\n // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327\n // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401\n if (base && !base.endsWith('/')) base += '/';\n\n return resolveUri(input, base);\n}\n","/**\n * Removes everything after the last \"/\", but leaves the slash.\n */\nexport default function stripFilename(path: string | undefined | null): string {\n if (!path) return '';\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n","type GeneratedColumn = number;\ntype SourcesIndex = number;\ntype SourceLine = number;\ntype SourceColumn = number;\ntype NamesIndex = number;\n\ntype GeneratedLine = number;\n\nexport type SourceMapSegment =\n | [GeneratedColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];\n\nexport type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn];\n\nexport const COLUMN = 0;\nexport const SOURCES_INDEX = 1;\nexport const SOURCE_LINE = 2;\nexport const SOURCE_COLUMN = 3;\nexport const NAMES_INDEX = 4;\n\nexport const REV_GENERATED_LINE = 1;\nexport const REV_GENERATED_COLUMN = 2;\n","import { COLUMN } from './sourcemap-segment';\n\nimport type { SourceMapSegment } from './sourcemap-segment';\n\nexport default function maybeSort(\n mappings: SourceMapSegment[][],\n owned: boolean,\n): SourceMapSegment[][] {\n const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);\n if (unsortedIndex === mappings.length) return mappings;\n\n // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If\n // not, we do not want to modify the consumer's input array.\n if (!owned) mappings = mappings.slice();\n\n for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {\n mappings[i] = sortSegments(mappings[i], owned);\n }\n return mappings;\n}\n\nfunction nextUnsortedSegmentLine(mappings: SourceMapSegment[][], start: number): number {\n for (let i = start; i < mappings.length; i++) {\n if (!isSorted(mappings[i])) return i;\n }\n return mappings.length;\n}\n\nfunction isSorted(line: SourceMapSegment[]): boolean {\n for (let j = 1; j < line.length; j++) {\n if (line[j][COLUMN] < line[j - 1][COLUMN]) {\n return false;\n }\n }\n return true;\n}\n\nfunction sortSegments(line: SourceMapSegment[], owned: boolean): SourceMapSegment[] {\n if (!owned) line = line.slice();\n return line.sort(sortComparator);\n}\n\nfunction sortComparator(a: SourceMapSegment, b: SourceMapSegment): number {\n return a[COLUMN] - b[COLUMN];\n}\n","import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment';\nimport { COLUMN } from './sourcemap-segment';\n\nexport type MemoState = {\n lastKey: number;\n lastNeedle: number;\n lastIndex: number;\n};\n\nexport let found = false;\n\n/**\n * A binary search implementation that returns the index if a match is found.\n * If no match is found, then the left-index (the index associated with the item that comes just\n * before the desired index) is returned. To maintain proper sort order, a splice would happen at\n * the next index:\n *\n * ```js\n * const array = [1, 3];\n * const needle = 2;\n * const index = binarySearch(array, needle, (item, needle) => item - needle);\n *\n * assert.equal(index, 0);\n * array.splice(index + 1, 0, needle);\n * assert.deepEqual(array, [1, 2, 3]);\n * ```\n */\nexport function binarySearch(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n low: number,\n high: number,\n): number {\n while (low <= high) {\n const mid = low + ((high - low) >> 1);\n const cmp = haystack[mid][COLUMN] - needle;\n\n if (cmp === 0) {\n found = true;\n return mid;\n }\n\n if (cmp < 0) {\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n found = false;\n return low - 1;\n}\n\nexport function upperBound(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n index: number,\n): number {\n for (let i = index + 1; i < haystack.length; index = i++) {\n if (haystack[i][COLUMN] !== needle) break;\n }\n return index;\n}\n\nexport function lowerBound(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n index: number,\n): number {\n for (let i = index - 1; i >= 0; index = i--) {\n if (haystack[i][COLUMN] !== needle) break;\n }\n return index;\n}\n\nexport function memoizedState(): MemoState {\n return {\n lastKey: -1,\n lastNeedle: -1,\n lastIndex: -1,\n };\n}\n\n/**\n * This overly complicated beast is just to record the last tested line/column and the resulting\n * index, allowing us to skip a few tests if mappings are monotonically increasing.\n */\nexport function memoizedBinarySearch(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n state: MemoState,\n key: number,\n): number {\n const { lastKey, lastNeedle, lastIndex } = state;\n\n let low = 0;\n let high = haystack.length - 1;\n if (key === lastKey) {\n if (needle === lastNeedle) {\n found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;\n return lastIndex;\n }\n\n if (needle >= lastNeedle) {\n // lastIndex may be -1 if the previous needle was not found.\n low = lastIndex === -1 ? 0 : lastIndex;\n } else {\n high = lastIndex;\n }\n }\n state.lastKey = key;\n state.lastNeedle = needle;\n\n return (state.lastIndex = binarySearch(haystack, needle, low, high));\n}\n","import { COLUMN, SOURCES_INDEX, SOURCE_LINE, SOURCE_COLUMN } from './sourcemap-segment';\nimport { memoizedBinarySearch, upperBound } from './binary-search';\n\nimport type { ReverseSegment, SourceMapSegment } from './sourcemap-segment';\nimport type { MemoState } from './binary-search';\n\nexport type Source = {\n __proto__: null;\n [line: number]: Exclude[];\n};\n\n// Rebuilds the original source files, with mappings that are ordered by source line/column instead\n// of generated line/column.\nexport default function buildBySources(\n decoded: readonly SourceMapSegment[][],\n memos: MemoState[],\n): Source[] {\n const sources: Source[] = memos.map(buildNullArray);\n\n for (let i = 0; i < decoded.length; i++) {\n const line = decoded[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n if (seg.length === 1) continue;\n\n const sourceIndex = seg[SOURCES_INDEX];\n const sourceLine = seg[SOURCE_LINE];\n const sourceColumn = seg[SOURCE_COLUMN];\n const originalSource = sources[sourceIndex];\n const originalLine = (originalSource[sourceLine] ||= []);\n const memo = memos[sourceIndex];\n\n // The binary search either found a match, or it found the left-index just before where the\n // segment should go. Either way, we want to insert after that. And there may be multiple\n // generated segments associated with an original location, so there may need to move several\n // indexes before we find where we need to insert.\n const index = upperBound(\n originalLine,\n sourceColumn,\n memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine),\n );\n\n insert(originalLine, (memo.lastIndex = index + 1), [sourceColumn, i, seg[COLUMN]]);\n }\n }\n\n return sources;\n}\n\nfunction insert(array: T[], index: number, value: T) {\n for (let i = array.length; i > index; i--) {\n array[i] = array[i - 1];\n }\n array[index] = value;\n}\n\n// Null arrays allow us to use ordered index keys without actually allocating contiguous memory like\n// a real array. We use a null-prototype object to avoid prototype pollution and deoptimizations.\n// Numeric properties on objects are magically sorted in ascending order by the engine regardless of\n// the insertion order. So, by setting any numeric keys, even out of order, we'll get ascending\n// order when iterating with for-in.\nfunction buildNullArray(): T {\n return { __proto__: null } as T;\n}\n","import { TraceMap, presortedDecodedMap, decodedMappings } from './trace-mapping';\nimport {\n COLUMN,\n SOURCES_INDEX,\n SOURCE_LINE,\n SOURCE_COLUMN,\n NAMES_INDEX,\n} from './sourcemap-segment';\n\nimport type {\n Section,\n SectionedSourceMap,\n DecodedSourceMap,\n SectionedSourceMapInput,\n Ro,\n} from './types';\nimport type { SourceMapSegment } from './sourcemap-segment';\n\ntype AnyMap = {\n new (map: SectionedSourceMapInput, mapUrl?: string | null): TraceMap;\n (map: SectionedSourceMapInput, mapUrl?: string | null): TraceMap;\n};\n\nexport const AnyMap: AnyMap = function (map, mapUrl) {\n const parsed =\n typeof map === 'string' ? (JSON.parse(map) as Exclude) : map;\n\n if (!('sections' in parsed)) return new TraceMap(parsed, mapUrl);\n\n const mappings: SourceMapSegment[][] = [];\n const sources: string[] = [];\n const sourcesContent: (string | null)[] = [];\n const names: string[] = [];\n\n recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, 0, 0, Infinity, Infinity);\n\n const joined: DecodedSourceMap = {\n version: 3,\n file: parsed.file,\n names,\n sources,\n sourcesContent,\n mappings,\n };\n\n return presortedDecodedMap(joined);\n} as AnyMap;\n\nfunction recurse(\n input: Ro,\n mapUrl: string | null | undefined,\n mappings: SourceMapSegment[][],\n sources: string[],\n sourcesContent: (string | null)[],\n names: string[],\n lineOffset: number,\n columnOffset: number,\n stopLine: number,\n stopColumn: number,\n) {\n const { sections } = input;\n for (let i = 0; i < sections.length; i++) {\n const { map, offset } = sections[i];\n\n let sl = stopLine;\n let sc = stopColumn;\n if (i + 1 < sections.length) {\n const nextOffset = sections[i + 1].offset;\n sl = Math.min(stopLine, lineOffset + nextOffset.line);\n\n if (sl === stopLine) {\n sc = Math.min(stopColumn, columnOffset + nextOffset.column);\n } else if (sl < stopLine) {\n sc = columnOffset + nextOffset.column;\n }\n }\n\n addSection(\n map,\n mapUrl,\n mappings,\n sources,\n sourcesContent,\n names,\n lineOffset + offset.line,\n columnOffset + offset.column,\n sl,\n sc,\n );\n }\n}\n\nfunction addSection(\n input: Ro,\n mapUrl: string | null | undefined,\n mappings: SourceMapSegment[][],\n sources: string[],\n sourcesContent: (string | null)[],\n names: string[],\n lineOffset: number,\n columnOffset: number,\n stopLine: number,\n stopColumn: number,\n) {\n if ('sections' in input) return recurse(...(arguments as unknown as Parameters));\n\n const map = new TraceMap(input, mapUrl);\n const sourcesOffset = sources.length;\n const namesOffset = names.length;\n const decoded = decodedMappings(map);\n const { resolvedSources, sourcesContent: contents } = map;\n\n append(sources, resolvedSources);\n append(names, map.names);\n if (contents) append(sourcesContent, contents);\n else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null);\n\n for (let i = 0; i < decoded.length; i++) {\n const lineI = lineOffset + i;\n\n // We can only add so many lines before we step into the range that the next section's map\n // controls. When we get to the last line, then we'll start checking the segments to see if\n // they've crossed into the column range. But it may not have any columns that overstep, so we\n // still need to check that we don't overstep lines, too.\n if (lineI > stopLine) return;\n\n // The out line may already exist in mappings (if we're continuing the line started by a\n // previous section). Or, we may have jumped ahead several lines to start this section.\n const out = getLine(mappings, lineI);\n // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the\n // map can be multiple lines), it doesn't.\n const cOffset = i === 0 ? columnOffset : 0;\n\n const line = decoded[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n const column = cOffset + seg[COLUMN];\n\n // If this segment steps into the column range that the next section's map controls, we need\n // to stop early.\n if (lineI === stopLine && column >= stopColumn) return;\n\n if (seg.length === 1) {\n out.push([column]);\n continue;\n }\n\n const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];\n const sourceLine = seg[SOURCE_LINE];\n const sourceColumn = seg[SOURCE_COLUMN];\n out.push(\n seg.length === 4\n ? [column, sourcesIndex, sourceLine, sourceColumn]\n : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]],\n );\n }\n }\n}\n\nfunction append(arr: T[], other: T[]) {\n for (let i = 0; i < other.length; i++) arr.push(other[i]);\n}\n\nfunction getLine(arr: T[][], index: number): T[] {\n for (let i = arr.length; i <= index; i++) arr[i] = [];\n return arr[index];\n}\n","import { encode, decode } from '@jridgewell/sourcemap-codec';\n\nimport resolve from './resolve';\nimport stripFilename from './strip-filename';\nimport maybeSort from './sort';\nimport buildBySources from './by-source';\nimport {\n memoizedState,\n memoizedBinarySearch,\n upperBound,\n lowerBound,\n found as bsFound,\n} from './binary-search';\nimport {\n COLUMN,\n SOURCES_INDEX,\n SOURCE_LINE,\n SOURCE_COLUMN,\n NAMES_INDEX,\n REV_GENERATED_LINE,\n REV_GENERATED_COLUMN,\n} from './sourcemap-segment';\n\nimport type { SourceMapSegment, ReverseSegment } from './sourcemap-segment';\nimport type {\n SourceMapV3,\n DecodedSourceMap,\n EncodedSourceMap,\n InvalidOriginalMapping,\n OriginalMapping,\n InvalidGeneratedMapping,\n GeneratedMapping,\n SourceMapInput,\n Needle,\n SourceNeedle,\n SourceMap,\n EachMapping,\n Bias,\n} from './types';\nimport type { Source } from './by-source';\nimport type { MemoState } from './binary-search';\n\nexport type { SourceMapSegment } from './sourcemap-segment';\nexport type {\n SourceMapInput,\n SectionedSourceMapInput,\n DecodedSourceMap,\n EncodedSourceMap,\n SectionedSourceMap,\n InvalidOriginalMapping,\n OriginalMapping as Mapping,\n OriginalMapping,\n InvalidGeneratedMapping,\n GeneratedMapping,\n EachMapping,\n} from './types';\n\nconst LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';\nconst COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';\n\nexport const LEAST_UPPER_BOUND = -1;\nexport const GREATEST_LOWER_BOUND = 1;\n\n/**\n * Returns the encoded (VLQ string) form of the SourceMap's mappings field.\n */\nexport let encodedMappings: (map: TraceMap) => EncodedSourceMap['mappings'];\n\n/**\n * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.\n */\nexport let decodedMappings: (map: TraceMap) => Readonly;\n\n/**\n * A low-level API to find the segment associated with a generated line/column (think, from a\n * stack trace). Line and column here are 0-based, unlike `originalPositionFor`.\n */\nexport let traceSegment: (\n map: TraceMap,\n line: number,\n column: number,\n) => Readonly | null;\n\n/**\n * A higher-level API to find the source/line/column associated with a generated line/column\n * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in\n * `source-map` library.\n */\nexport let originalPositionFor: (\n map: TraceMap,\n needle: Needle,\n) => OriginalMapping | InvalidOriginalMapping;\n\n/**\n * Finds the generated line/column position of the provided source/line/column source position.\n */\nexport let generatedPositionFor: (\n map: TraceMap,\n needle: SourceNeedle,\n) => GeneratedMapping | InvalidGeneratedMapping;\n\n/**\n * Finds all generated line/column positions of the provided source/line/column source position.\n */\nexport let allGeneratedPositionsFor: (map: TraceMap, needle: SourceNeedle) => GeneratedMapping[];\n\n/**\n * Iterates each mapping in generated position order.\n */\nexport let eachMapping: (map: TraceMap, cb: (mapping: EachMapping) => void) => void;\n\n/**\n * Retrieves the source content for a particular source, if its found. Returns null if not.\n */\nexport let sourceContentFor: (map: TraceMap, source: string) => string | null;\n\n/**\n * A helper that skips sorting of the input map's mappings array, which can be expensive for larger\n * maps.\n */\nexport let presortedDecodedMap: (map: DecodedSourceMap, mapUrl?: string) => TraceMap;\n\n/**\n * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport let decodedMap: (\n map: TraceMap,\n) => Omit & { mappings: readonly SourceMapSegment[][] };\n\n/**\n * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport let encodedMap: (map: TraceMap) => EncodedSourceMap;\n\nexport { AnyMap } from './any-map';\n\nexport class TraceMap implements SourceMap {\n declare version: SourceMapV3['version'];\n declare file: SourceMapV3['file'];\n declare names: SourceMapV3['names'];\n declare sourceRoot: SourceMapV3['sourceRoot'];\n declare sources: SourceMapV3['sources'];\n declare sourcesContent: SourceMapV3['sourcesContent'];\n\n declare resolvedSources: string[];\n private declare _encoded: string | undefined;\n\n private declare _decoded: SourceMapSegment[][] | undefined;\n private declare _decodedMemo: MemoState;\n\n private declare _bySources: Source[] | undefined;\n private declare _bySourceMemos: MemoState[] | undefined;\n\n constructor(map: SourceMapInput, mapUrl?: string | null) {\n const isString = typeof map === 'string';\n\n if (!isString && (map as unknown as { _decodedMemo: any })._decodedMemo) return map as TraceMap;\n\n const parsed = (isString ? JSON.parse(map) : map) as DecodedSourceMap | EncodedSourceMap;\n\n const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;\n this.version = version;\n this.file = file;\n this.names = names || [];\n this.sourceRoot = sourceRoot;\n this.sources = sources;\n this.sourcesContent = sourcesContent;\n\n const from = resolve(sourceRoot || '', stripFilename(mapUrl));\n this.resolvedSources = sources.map((s) => resolve(s || '', from));\n\n const { mappings } = parsed;\n if (typeof mappings === 'string') {\n this._encoded = mappings;\n this._decoded = undefined;\n } else {\n this._encoded = undefined;\n this._decoded = maybeSort(mappings, isString);\n }\n\n this._decodedMemo = memoizedState();\n this._bySources = undefined;\n this._bySourceMemos = undefined;\n }\n\n static {\n encodedMappings = (map) => {\n return (map._encoded ??= encode(map._decoded!));\n };\n\n decodedMappings = (map) => {\n return (map._decoded ||= decode(map._encoded!));\n };\n\n traceSegment = (map, line, column) => {\n const decoded = decodedMappings(map);\n\n // It's common for parent source maps to have pointers to lines that have no\n // mapping (like a \"//# sourceMappingURL=\") at the end of the child file.\n if (line >= decoded.length) return null;\n\n const segments = decoded[line];\n const index = traceSegmentInternal(\n segments,\n map._decodedMemo,\n line,\n column,\n GREATEST_LOWER_BOUND,\n );\n\n return index === -1 ? null : segments[index];\n };\n\n originalPositionFor = (map, { line, column, bias }) => {\n line--;\n if (line < 0) throw new Error(LINE_GTR_ZERO);\n if (column < 0) throw new Error(COL_GTR_EQ_ZERO);\n\n const decoded = decodedMappings(map);\n\n // It's common for parent source maps to have pointers to lines that have no\n // mapping (like a \"//# sourceMappingURL=\") at the end of the child file.\n if (line >= decoded.length) return OMapping(null, null, null, null);\n\n const segments = decoded[line];\n const index = traceSegmentInternal(\n segments,\n map._decodedMemo,\n line,\n column,\n bias || GREATEST_LOWER_BOUND,\n );\n\n if (index === -1) return OMapping(null, null, null, null);\n\n const segment = segments[index];\n if (segment.length === 1) return OMapping(null, null, null, null);\n\n const { names, resolvedSources } = map;\n return OMapping(\n resolvedSources[segment[SOURCES_INDEX]],\n segment[SOURCE_LINE] + 1,\n segment[SOURCE_COLUMN],\n segment.length === 5 ? names[segment[NAMES_INDEX]] : null,\n );\n };\n\n allGeneratedPositionsFor = (map, { source, line, column, bias }) => {\n // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit.\n return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);\n };\n\n generatedPositionFor = (map, { source, line, column, bias }) => {\n return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);\n };\n\n eachMapping = (map, cb) => {\n const decoded = decodedMappings(map);\n const { names, resolvedSources } = map;\n\n for (let i = 0; i < decoded.length; i++) {\n const line = decoded[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n\n const generatedLine = i + 1;\n const generatedColumn = seg[0];\n let source = null;\n let originalLine = null;\n let originalColumn = null;\n let name = null;\n if (seg.length !== 1) {\n source = resolvedSources[seg[1]];\n originalLine = seg[2] + 1;\n originalColumn = seg[3];\n }\n if (seg.length === 5) name = names[seg[4]];\n\n cb({\n generatedLine,\n generatedColumn,\n source,\n originalLine,\n originalColumn,\n name,\n } as EachMapping);\n }\n }\n };\n\n sourceContentFor = (map, source) => {\n const { sources, resolvedSources, sourcesContent } = map;\n if (sourcesContent == null) return null;\n\n let index = sources.indexOf(source);\n if (index === -1) index = resolvedSources.indexOf(source);\n\n return index === -1 ? null : sourcesContent[index];\n };\n\n presortedDecodedMap = (map, mapUrl) => {\n const tracer = new TraceMap(clone(map, []), mapUrl);\n tracer._decoded = map.mappings;\n return tracer;\n };\n\n decodedMap = (map) => {\n return clone(map, decodedMappings(map));\n };\n\n encodedMap = (map) => {\n return clone(map, encodedMappings(map));\n };\n\n function generatedPosition(\n map: TraceMap,\n source: string,\n line: number,\n column: number,\n bias: Bias,\n all: false,\n ): GeneratedMapping | InvalidGeneratedMapping;\n function generatedPosition(\n map: TraceMap,\n source: string,\n line: number,\n column: number,\n bias: Bias,\n all: true,\n ): GeneratedMapping[];\n function generatedPosition(\n map: TraceMap,\n source: string,\n line: number,\n column: number,\n bias: Bias,\n all: boolean,\n ): GeneratedMapping | InvalidGeneratedMapping | GeneratedMapping[] {\n line--;\n if (line < 0) throw new Error(LINE_GTR_ZERO);\n if (column < 0) throw new Error(COL_GTR_EQ_ZERO);\n\n const { sources, resolvedSources } = map;\n let sourceIndex = sources.indexOf(source);\n if (sourceIndex === -1) sourceIndex = resolvedSources.indexOf(source);\n if (sourceIndex === -1) return all ? [] : GMapping(null, null);\n\n const generated = (map._bySources ||= buildBySources(\n decodedMappings(map),\n (map._bySourceMemos = sources.map(memoizedState)),\n ));\n\n const segments = generated[sourceIndex][line];\n if (segments == null) return all ? [] : GMapping(null, null);\n\n const memo = map._bySourceMemos![sourceIndex];\n\n if (all) return sliceGeneratedPositions(segments, memo, line, column, bias);\n\n const index = traceSegmentInternal(segments, memo, line, column, bias);\n if (index === -1) return GMapping(null, null);\n\n const segment = segments[index];\n return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);\n }\n }\n}\n\nfunction clone(\n map: TraceMap | DecodedSourceMap | EncodedSourceMap,\n mappings: T,\n): T extends string ? EncodedSourceMap : DecodedSourceMap {\n return {\n version: map.version,\n file: map.file,\n names: map.names,\n sourceRoot: map.sourceRoot,\n sources: map.sources,\n sourcesContent: map.sourcesContent,\n mappings,\n } as any;\n}\n\nfunction OMapping(source: null, line: null, column: null, name: null): InvalidOriginalMapping;\nfunction OMapping(\n source: string,\n line: number,\n column: number,\n name: string | null,\n): OriginalMapping;\nfunction OMapping(\n source: string | null,\n line: number | null,\n column: number | null,\n name: string | null,\n): OriginalMapping | InvalidOriginalMapping {\n return { source, line, column, name } as any;\n}\n\nfunction GMapping(line: null, column: null): InvalidGeneratedMapping;\nfunction GMapping(line: number, column: number): GeneratedMapping;\nfunction GMapping(\n line: number | null,\n column: number | null,\n): GeneratedMapping | InvalidGeneratedMapping {\n return { line, column } as any;\n}\n\nfunction traceSegmentInternal(\n segments: SourceMapSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): number;\nfunction traceSegmentInternal(\n segments: ReverseSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): number;\nfunction traceSegmentInternal(\n segments: SourceMapSegment[] | ReverseSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): number {\n let index = memoizedBinarySearch(segments, column, memo, line);\n if (bsFound) {\n index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);\n } else if (bias === LEAST_UPPER_BOUND) index++;\n\n if (index === -1 || index === segments.length) return -1;\n return index;\n}\n\nfunction sliceGeneratedPositions(\n segments: ReverseSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): GeneratedMapping[] {\n let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);\n\n // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in\n // insertion order) segment that matched. Even if we did respect the bias when tracing, we would\n // still need to call `lowerBound()` to find the first segment, which is slower than just looking\n // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the\n // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to\n // match LEAST_UPPER_BOUND.\n if (!bsFound && bias === LEAST_UPPER_BOUND) min++;\n\n if (min === -1 || min === segments.length) return [];\n\n // We may have found the segment that started at an earlier column. If this is the case, then we\n // need to slice all generated segments that match _that_ column, because all such segments span\n // to our desired column.\n const matchedColumn = bsFound ? column : segments[min][COLUMN];\n\n // The binary search is not guaranteed to find the lower bound when a match wasn't found.\n if (!bsFound) min = lowerBound(segments, matchedColumn, min);\n const max = upperBound(segments, matchedColumn, min);\n\n const result = [];\n for (; min <= max; min++) {\n const segment = segments[min];\n result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));\n }\n return result;\n}\n"],"names":["resolveUri","presortedDecodedMap","decodedMappings","encodedMappings","traceSegment","originalPositionFor","generatedPositionFor","allGeneratedPositionsFor","eachMapping","sourceContentFor","decodedMap","encodedMap","encode","decode","bsFound"],"mappings":";;;;;;;;;;IAEc,SAAU,OAAO,CAAC,KAAa,EAAE,IAAwB,EAAA;;;;QAIrE,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,IAAI,IAAI,GAAG,CAAC;IAE7C,IAAA,OAAOA,8BAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACjC;;ICTA;;IAEG;IACqB,SAAA,aAAa,CAAC,IAA+B,EAAA;IACnE,IAAA,IAAI,CAAC,IAAI;IAAE,QAAA,OAAO,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAClC;;ICQO,MAAM,MAAM,GAAG,CAAC,CAAC;IACjB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,WAAW,GAAG,CAAC,CAAC;IACtB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,WAAW,GAAG,CAAC,CAAC;IAEtB,MAAM,kBAAkB,GAAG,CAAC,CAAC;I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AACA,KAAO;YAAE,GAAG,GAAG,UAAU,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;QAC7D,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;QAErD,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,IAAA,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,EAAE;IACxB,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9B,QAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACvF,KAAA;IACD,IAAA,OAAO,MAAM,CAAC;IAChB;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/node_modules/@jridgewell/trace-mapping/dist/types/any-map.d.ts b/node_modules/@jridgewell/trace-mapping/dist/types/any-map.d.ts new file mode 100644 index 000000000..08bca6bfa --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/types/any-map.d.ts @@ -0,0 +1,8 @@ +import { TraceMap } from './trace-mapping'; +import type { SectionedSourceMapInput } from './types'; +declare type AnyMap = { + new (map: SectionedSourceMapInput, mapUrl?: string | null): TraceMap; + (map: SectionedSourceMapInput, mapUrl?: string | null): TraceMap; +}; +export declare const AnyMap: AnyMap; +export {}; diff --git a/node_modules/@jridgewell/trace-mapping/dist/types/binary-search.d.ts b/node_modules/@jridgewell/trace-mapping/dist/types/binary-search.d.ts new file mode 100644 index 000000000..88820e500 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/types/binary-search.d.ts @@ -0,0 +1,32 @@ +import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment'; +export declare type MemoState = { + lastKey: number; + lastNeedle: number; + lastIndex: number; +}; +export declare let found: boolean; +/** + * A binary search implementation that returns the index if a match is found. + * If no match is found, then the left-index (the index associated with the item that comes just + * before the desired index) is returned. To maintain proper sort order, a splice would happen at + * the next index: + * + * ```js + * const array = [1, 3]; + * const needle = 2; + * const index = binarySearch(array, needle, (item, needle) => item - needle); + * + * assert.equal(index, 0); + * array.splice(index + 1, 0, needle); + * assert.deepEqual(array, [1, 2, 3]); + * ``` + */ +export declare function binarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, low: number, high: number): number; +export declare function upperBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function lowerBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number; +export declare function memoizedState(): MemoState; +/** + * This overly complicated beast is just to record the last tested line/column and the resulting + * index, allowing us to skip a few tests if mappings are monotonically increasing. + */ +export declare function memoizedBinarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, state: MemoState, key: number): number; diff --git a/node_modules/@jridgewell/trace-mapping/dist/types/by-source.d.ts b/node_modules/@jridgewell/trace-mapping/dist/types/by-source.d.ts new file mode 100644 index 000000000..8d1e53833 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/types/by-source.d.ts @@ -0,0 +1,7 @@ +import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment'; +import type { MemoState } from './binary-search'; +export declare type Source = { + __proto__: null; + [line: number]: Exclude[]; +}; +export default function buildBySources(decoded: readonly SourceMapSegment[][], memos: MemoState[]): Source[]; diff --git a/node_modules/@jridgewell/trace-mapping/dist/types/resolve.d.ts b/node_modules/@jridgewell/trace-mapping/dist/types/resolve.d.ts new file mode 100644 index 000000000..cf7d4f8a5 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/types/resolve.d.ts @@ -0,0 +1 @@ +export default function resolve(input: string, base: string | undefined): string; diff --git a/node_modules/@jridgewell/trace-mapping/dist/types/sort.d.ts b/node_modules/@jridgewell/trace-mapping/dist/types/sort.d.ts new file mode 100644 index 000000000..2bfb5dc10 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/types/sort.d.ts @@ -0,0 +1,2 @@ +import type { SourceMapSegment } from './sourcemap-segment'; +export default function maybeSort(mappings: SourceMapSegment[][], owned: boolean): SourceMapSegment[][]; diff --git a/node_modules/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts b/node_modules/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts new file mode 100644 index 000000000..6d70924e1 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts @@ -0,0 +1,16 @@ +declare type GeneratedColumn = number; +declare type SourcesIndex = number; +declare type SourceLine = number; +declare type SourceColumn = number; +declare type NamesIndex = number; +declare type GeneratedLine = number; +export declare type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex]; +export declare type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn]; +export declare const COLUMN = 0; +export declare const SOURCES_INDEX = 1; +export declare const SOURCE_LINE = 2; +export declare const SOURCE_COLUMN = 3; +export declare const NAMES_INDEX = 4; +export declare const REV_GENERATED_LINE = 1; +export declare const REV_GENERATED_COLUMN = 2; +export {}; diff --git a/node_modules/@jridgewell/trace-mapping/dist/types/strip-filename.d.ts b/node_modules/@jridgewell/trace-mapping/dist/types/strip-filename.d.ts new file mode 100644 index 000000000..bead5c12c --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/types/strip-filename.d.ts @@ -0,0 +1,4 @@ +/** + * Removes everything after the last "/", but leaves the slash. + */ +export default function stripFilename(path: string | undefined | null): string; diff --git a/node_modules/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts b/node_modules/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts new file mode 100644 index 000000000..c125ead38 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts @@ -0,0 +1,74 @@ +import type { SourceMapSegment } from './sourcemap-segment'; +import type { SourceMapV3, DecodedSourceMap, EncodedSourceMap, InvalidOriginalMapping, OriginalMapping, InvalidGeneratedMapping, GeneratedMapping, SourceMapInput, Needle, SourceNeedle, SourceMap, EachMapping } from './types'; +export type { SourceMapSegment } from './sourcemap-segment'; +export type { SourceMapInput, SectionedSourceMapInput, DecodedSourceMap, EncodedSourceMap, SectionedSourceMap, InvalidOriginalMapping, OriginalMapping as Mapping, OriginalMapping, InvalidGeneratedMapping, GeneratedMapping, EachMapping, } from './types'; +export declare const LEAST_UPPER_BOUND = -1; +export declare const GREATEST_LOWER_BOUND = 1; +/** + * Returns the encoded (VLQ string) form of the SourceMap's mappings field. + */ +export declare let encodedMappings: (map: TraceMap) => EncodedSourceMap['mappings']; +/** + * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. + */ +export declare let decodedMappings: (map: TraceMap) => Readonly; +/** + * A low-level API to find the segment associated with a generated line/column (think, from a + * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. + */ +export declare let traceSegment: (map: TraceMap, line: number, column: number) => Readonly | null; +/** + * A higher-level API to find the source/line/column associated with a generated line/column + * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in + * `source-map` library. + */ +export declare let originalPositionFor: (map: TraceMap, needle: Needle) => OriginalMapping | InvalidOriginalMapping; +/** + * Finds the generated line/column position of the provided source/line/column source position. + */ +export declare let generatedPositionFor: (map: TraceMap, needle: SourceNeedle) => GeneratedMapping | InvalidGeneratedMapping; +/** + * Finds all generated line/column positions of the provided source/line/column source position. + */ +export declare let allGeneratedPositionsFor: (map: TraceMap, needle: SourceNeedle) => GeneratedMapping[]; +/** + * Iterates each mapping in generated position order. + */ +export declare let eachMapping: (map: TraceMap, cb: (mapping: EachMapping) => void) => void; +/** + * Retrieves the source content for a particular source, if its found. Returns null if not. + */ +export declare let sourceContentFor: (map: TraceMap, source: string) => string | null; +/** + * A helper that skips sorting of the input map's mappings array, which can be expensive for larger + * maps. + */ +export declare let presortedDecodedMap: (map: DecodedSourceMap, mapUrl?: string) => TraceMap; +/** + * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare let decodedMap: (map: TraceMap) => Omit & { + mappings: readonly SourceMapSegment[][]; +}; +/** + * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects + * a sourcemap, or to JSON.stringify. + */ +export declare let encodedMap: (map: TraceMap) => EncodedSourceMap; +export { AnyMap } from './any-map'; +export declare class TraceMap implements SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + resolvedSources: string[]; + private _encoded; + private _decoded; + private _decodedMemo; + private _bySources; + private _bySourceMemos; + constructor(map: SourceMapInput, mapUrl?: string | null); +} diff --git a/node_modules/@jridgewell/trace-mapping/dist/types/types.d.ts b/node_modules/@jridgewell/trace-mapping/dist/types/types.d.ts new file mode 100644 index 000000000..2f4fd452d --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/dist/types/types.d.ts @@ -0,0 +1,92 @@ +import type { SourceMapSegment } from './sourcemap-segment'; +import type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping'; +export interface SourceMapV3 { + file?: string | null; + names: string[]; + sourceRoot?: string; + sources: (string | null)[]; + sourcesContent?: (string | null)[]; + version: 3; +} +export interface EncodedSourceMap extends SourceMapV3 { + mappings: string; +} +export interface DecodedSourceMap extends SourceMapV3 { + mappings: SourceMapSegment[][]; +} +export interface Section { + offset: { + line: number; + column: number; + }; + map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap; +} +export interface SectionedSourceMap { + file?: string | null; + sections: Section[]; + version: 3; +} +export declare type OriginalMapping = { + source: string | null; + line: number; + column: number; + name: string | null; +}; +export declare type InvalidOriginalMapping = { + source: null; + line: null; + column: null; + name: null; +}; +export declare type GeneratedMapping = { + line: number; + column: number; +}; +export declare type InvalidGeneratedMapping = { + line: null; + column: null; +}; +export declare type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND; +export declare type SourceMapInput = string | Ro | Ro | TraceMap; +export declare type SectionedSourceMapInput = SourceMapInput | Ro; +export declare type Needle = { + line: number; + column: number; + bias?: Bias; +}; +export declare type SourceNeedle = { + source: string; + line: number; + column: number; + bias?: Bias; +}; +export declare type EachMapping = { + generatedLine: number; + generatedColumn: number; + source: null; + originalLine: null; + originalColumn: null; + name: null; +} | { + generatedLine: number; + generatedColumn: number; + source: string | null; + originalLine: number; + originalColumn: number; + name: string | null; +}; +export declare abstract class SourceMap { + version: SourceMapV3['version']; + file: SourceMapV3['file']; + names: SourceMapV3['names']; + sourceRoot: SourceMapV3['sourceRoot']; + sources: SourceMapV3['sources']; + sourcesContent: SourceMapV3['sourcesContent']; + resolvedSources: SourceMapV3['sources']; +} +export declare type Ro = T extends Array ? V[] | Readonly | RoArray | Readonly> : T extends object ? T | Readonly | RoObject | Readonly> : T; +declare type RoArray = Ro[]; +declare type RoObject = { + [K in keyof T]: T[K] | Ro; +}; +export {}; diff --git a/node_modules/@jridgewell/trace-mapping/package.json b/node_modules/@jridgewell/trace-mapping/package.json new file mode 100644 index 000000000..c06194565 --- /dev/null +++ b/node_modules/@jridgewell/trace-mapping/package.json @@ -0,0 +1,75 @@ +{ + "name": "@jridgewell/trace-mapping", + "version": "0.3.20", + "description": "Trace the original position through a source map", + "keywords": [ + "source", + "map" + ], + "main": "dist/trace-mapping.umd.js", + "module": "dist/trace-mapping.mjs", + "types": "dist/types/trace-mapping.d.ts", + "files": [ + "dist" + ], + "exports": { + ".": [ + { + "types": "./dist/types/trace-mapping.d.ts", + "browser": "./dist/trace-mapping.umd.js", + "require": "./dist/trace-mapping.umd.js", + "import": "./dist/trace-mapping.mjs" + }, + "./dist/trace-mapping.umd.js" + ], + "./package.json": "./package.json" + }, + "author": "Justin Ridgewell ", + "repository": { + "type": "git", + "url": "git+https://github.com/jridgewell/trace-mapping.git" + }, + "license": "MIT", + "scripts": { + "benchmark": "run-s build:rollup benchmark:*", + "benchmark:install": "cd benchmark && npm install", + "benchmark:only": "node --expose-gc benchmark/index.mjs", + "build": "run-s -n build:*", + "build:rollup": "rollup -c rollup.config.js", + "build:ts": "tsc --project tsconfig.build.json", + "lint": "run-s -n lint:*", + "lint:prettier": "npm run test:lint:prettier -- --write", + "lint:ts": "npm run test:lint:ts -- --fix", + "prebuild": "rm -rf dist", + "prepublishOnly": "npm run preversion", + "preversion": "run-s test build", + "test": "run-s -n test:lint test:only", + "test:debug": "ava debug", + "test:lint": "run-s -n test:lint:*", + "test:lint:prettier": "prettier --check '{src,test}/**/*.ts' '**/*.md'", + "test:lint:ts": "eslint '{src,test}/**/*.ts'", + "test:only": "c8 ava", + "test:watch": "ava --watch" + }, + "devDependencies": { + "@rollup/plugin-typescript": "8.5.0", + "@typescript-eslint/eslint-plugin": "5.39.0", + "@typescript-eslint/parser": "5.39.0", + "ava": "4.3.3", + "benchmark": "2.1.4", + "c8": "7.12.0", + "esbuild": "0.15.10", + "eslint": "8.25.0", + "eslint-config-prettier": "8.5.0", + "eslint-plugin-no-only-tests": "3.0.0", + "npm-run-all": "4.1.5", + "prettier": "2.7.1", + "rollup": "2.79.1", + "tsx": "3.10.1", + "typescript": "4.8.4" + }, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } +} diff --git a/node_modules/@polka/url/build.js b/node_modules/@polka/url/build.js new file mode 100644 index 000000000..33dfc56cc --- /dev/null +++ b/node_modules/@polka/url/build.js @@ -0,0 +1,42 @@ +const qs = require('querystring'); + +/** + * @typedef ParsedURL + * @type {import('.').ParsedURL} + */ + +/** + * @typedef Request + * @property {string} url + * @property {ParsedURL} _parsedUrl + */ + +/** + * @param {Request} req + * @returns {ParsedURL|void} + */ +function parse(req) { + let raw = req.url; + if (raw == null) return; + + let prev = req._parsedUrl; + if (prev && prev.raw === raw) return prev; + + let pathname=raw, search='', query; + + if (raw.length > 1) { + let idx = raw.indexOf('?', 1); + + if (idx !== -1) { + search = raw.substring(idx); + pathname = raw.substring(0, idx); + if (search.length > 1) { + query = qs.parse(search.substring(1)); + } + } + } + + return req._parsedUrl = { pathname, search, query, raw }; +} + +exports.parse = parse; \ No newline at end of file diff --git a/node_modules/@polka/url/build.mjs b/node_modules/@polka/url/build.mjs new file mode 100644 index 000000000..9d5e7b911 --- /dev/null +++ b/node_modules/@polka/url/build.mjs @@ -0,0 +1,40 @@ +import * as qs from 'querystring'; + +/** + * @typedef ParsedURL + * @type {import('.').ParsedURL} + */ + +/** + * @typedef Request + * @property {string} url + * @property {ParsedURL} _parsedUrl + */ + +/** + * @param {Request} req + * @returns {ParsedURL|void} + */ +export function parse(req) { + let raw = req.url; + if (raw == null) return; + + let prev = req._parsedUrl; + if (prev && prev.raw === raw) return prev; + + let pathname=raw, search='', query; + + if (raw.length > 1) { + let idx = raw.indexOf('?', 1); + + if (idx !== -1) { + search = raw.substring(idx); + pathname = raw.substring(0, idx); + if (search.length > 1) { + query = qs.parse(search.substring(1)); + } + } + } + + return req._parsedUrl = { pathname, search, query, raw }; +} diff --git a/node_modules/@polka/url/index.d.ts b/node_modules/@polka/url/index.d.ts new file mode 100644 index 000000000..9b27c042e --- /dev/null +++ b/node_modules/@polka/url/index.d.ts @@ -0,0 +1,10 @@ +import type { IncomingMessage } from 'http'; + +export interface ParsedURL { + pathname: string; + search: string; + query: Record | void; + raw: string; +} + +export function parse(req: IncomingMessage): ParsedURL; diff --git a/node_modules/@polka/url/package.json b/node_modules/@polka/url/package.json new file mode 100644 index 000000000..271c892b3 --- /dev/null +++ b/node_modules/@polka/url/package.json @@ -0,0 +1,30 @@ +{ + "version": "1.0.0-next.24", + "name": "@polka/url", + "repository": "lukeed/polka", + "description": "Super fast, memoized `req.url` parser", + "module": "build.mjs", + "types": "index.d.ts", + "main": "build.js", + "license": "MIT", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./build.mjs", + "require": "./build.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "build.*", + "index.d.*" + ], + "author": { + "name": "Luke Edwards", + "email": "luke@lukeed.com", + "url": "https://lukeed.com" + }, + "publishConfig": { + "access": "public" + } +} \ No newline at end of file diff --git a/node_modules/@polka/url/readme.md b/node_modules/@polka/url/readme.md new file mode 100644 index 000000000..69947a7ac --- /dev/null +++ b/node_modules/@polka/url/readme.md @@ -0,0 +1,68 @@ +# @polka/url [![npm](https://badgen.now.sh/npm/v/@polka/url)](https://npmjs.org/package/@polka/url) + +> Super fast, memoized `req.url` parser; _not_ limited to [Polka][polka]! + +Parses the `url` from a [`IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) request. The returned object will always only contain the following keys: `search`, `query`, `pathname`, and `raw`. + +> **Note:** This library does not process `protocol`, `hostname`, `port`, etc.
This is because the incoming `req.url` value only begins with the path information. + +Parsed requests will be mutated with a `_parsedUrl` key, containing the returned output. This is used for future memoization, avoiding the need to fully parse the same `url` value multiple times. + +## Install + +``` +$ npm install --save @polka/url +``` + +## Usage + +```js +const parse = require('@polka/url'); + +let req = { + url: '/foo/bar?fizz=buzz' +}; +let output = parse(req); +//=> { +//=> pathname: '/foo/bar', +//=> raw: '/foo/bar?fizz=buzz', +//=> search: '?fizz=buzz', +//=> query: { +//=> fizz: 'buzz' +//=> }, +//=> } + +// Attaches result for future memoization +assert.deepEqual(output, req._parsedUrl); //=> true +``` + +## API + +### url(req) +Returns: `Object` or `undefined` + +> **Important:** The `req` must have a `url` key, otherwise `undefined` will be returned.
If no input is provided at all, a `TypeError` will be thrown. + +#### req +Type: `IncomingMessage` or `{ url: string }` + +The incoming HTTP request (`req`) or a plain `Object` with a `url` key. + +> **Note:** In Node.js servers, the [`req.url`](https://nodejs.org/api/http.html#http_message_url) begins with a pathname & does not include a `hash`. + + +## Benchmarks + +Check out the [`bench`](/bench) directory for in-depth benchmark results and comparisons. + + +## Support + +Any issues or questions can be sent to the [Polka][polka] repository.
However, please specify that your inquiry is about `@polka/url` specifically. + + +## License + +MIT © [Luke Edwards](https://lukeed.com) + +[polka]: https://github.com/lukeed/polka diff --git a/node_modules/@rollup/rollup-darwin-x64/README.md b/node_modules/@rollup/rollup-darwin-x64/README.md new file mode 100644 index 000000000..156d37a87 --- /dev/null +++ b/node_modules/@rollup/rollup-darwin-x64/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-darwin-x64` + +This is the **x86_64-apple-darwin** binary for `rollup` diff --git a/node_modules/@rollup/rollup-darwin-x64/package.json b/node_modules/@rollup/rollup-darwin-x64/package.json new file mode 100644 index 000000000..7de2f5a49 --- /dev/null +++ b/node_modules/@rollup/rollup-darwin-x64/package.json @@ -0,0 +1,19 @@ +{ + "name": "@rollup/rollup-darwin-x64", + "version": "4.9.1", + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.darwin-x64.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": "rollup/rollup", + "main": "./rollup.darwin-x64.node" +} \ No newline at end of file diff --git a/node_modules/@rollup/rollup-darwin-x64/rollup.darwin-x64.node b/node_modules/@rollup/rollup-darwin-x64/rollup.darwin-x64.node new file mode 100644 index 000000000..e5df5c571 Binary files /dev/null and b/node_modules/@rollup/rollup-darwin-x64/rollup.darwin-x64.node differ diff --git a/node_modules/@rollup/rollup-win32-x64-msvc/README.md b/node_modules/@rollup/rollup-win32-x64-msvc/README.md new file mode 100644 index 000000000..7382dbc4f --- /dev/null +++ b/node_modules/@rollup/rollup-win32-x64-msvc/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-win32-x64-msvc` + +This is the **x86_64-pc-windows-msvc** binary for `rollup` diff --git a/node_modules/@rollup/rollup-win32-x64-msvc/package.json b/node_modules/@rollup/rollup-win32-x64-msvc/package.json new file mode 100644 index 000000000..ce1b92bf0 --- /dev/null +++ b/node_modules/@rollup/rollup-win32-x64-msvc/package.json @@ -0,0 +1,19 @@ +{ + "name": "@rollup/rollup-win32-x64-msvc", + "version": "4.9.1", + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.win32-x64-msvc.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": "rollup/rollup", + "main": "./rollup.win32-x64-msvc.node" +} \ No newline at end of file diff --git a/node_modules/@rollup/rollup-win32-x64-msvc/rollup.win32-x64-msvc.node b/node_modules/@rollup/rollup-win32-x64-msvc/rollup.win32-x64-msvc.node new file mode 100644 index 000000000..565305781 Binary files /dev/null and b/node_modules/@rollup/rollup-win32-x64-msvc/rollup.win32-x64-msvc.node differ diff --git a/node_modules/@sveltejs/adapter-auto/LICENSE b/node_modules/@sveltejs/adapter-auto/LICENSE new file mode 100644 index 000000000..22efd0c0d --- /dev/null +++ b/node_modules/@sveltejs/adapter-auto/LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/@sveltejs/adapter-auto/README.md b/node_modules/@sveltejs/adapter-auto/README.md new file mode 100644 index 000000000..26f861ded --- /dev/null +++ b/node_modules/@sveltejs/adapter-auto/README.md @@ -0,0 +1,11 @@ +# adapter-auto + +Automatically chooses the SvelteKit adapter for your current environment, if possible. + +## Docs + +[Docs](https://kit.svelte.dev/docs/adapter-auto) + +## Changelog + +[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/adapter-auto/CHANGELOG.md). diff --git a/node_modules/@sveltejs/adapter-auto/adapters.js b/node_modules/@sveltejs/adapter-auto/adapters.js new file mode 100644 index 000000000..fa682638d --- /dev/null +++ b/node_modules/@sveltejs/adapter-auto/adapters.js @@ -0,0 +1,34 @@ +// List of adapters to check for. `version` is used to pin the installed adapter version and should point +// to the latest version of the adapter that is compatible with adapter-auto's current peerDependency version of SvelteKit. +export const adapters = [ + { + name: 'Vercel', + test: () => !!process.env.VERCEL, + module: '@sveltejs/adapter-vercel', + version: '4' + }, + { + name: 'Cloudflare Pages', + test: () => !!process.env.CF_PAGES, + module: '@sveltejs/adapter-cloudflare', + version: '3' + }, + { + name: 'Netlify', + test: () => !!process.env.NETLIFY, + module: '@sveltejs/adapter-netlify', + version: '3' + }, + { + name: 'Azure Static Web Apps', + test: () => process.env.GITHUB_ACTION_REPOSITORY === 'Azure/static-web-apps-deploy', + module: 'svelte-adapter-azure-swa', + version: '0.13' + }, + { + name: 'AWS via SST', + test: () => !!process.env.SST, + module: 'svelte-kit-sst', + version: '2' + } +]; diff --git a/node_modules/@sveltejs/adapter-auto/index.d.ts b/node_modules/@sveltejs/adapter-auto/index.d.ts new file mode 100644 index 000000000..90af12a05 --- /dev/null +++ b/node_modules/@sveltejs/adapter-auto/index.d.ts @@ -0,0 +1,3 @@ +import { Adapter } from '@sveltejs/kit'; + +export default function plugin(): Adapter; diff --git a/node_modules/@sveltejs/adapter-auto/index.js b/node_modules/@sveltejs/adapter-auto/index.js new file mode 100644 index 000000000..14115c45b --- /dev/null +++ b/node_modules/@sveltejs/adapter-auto/index.js @@ -0,0 +1,120 @@ +import { execSync } from 'node:child_process'; +import { pathToFileURL } from 'node:url'; +import { resolve } from 'import-meta-resolve'; +import { adapters } from './adapters.js'; +import { dirname, join } from 'node:path'; +import { existsSync } from 'node:fs'; + +/** @type {Record string>} */ +const commands = { + npm: (name, version) => `npm install -D ${name}@${version}`, + pnpm: (name, version) => `pnpm add -D ${name}@${version}`, + yarn: (name, version) => `yarn add -D ${name}@${version}` +}; + +function detect_lockfile() { + let dir = process.cwd(); + + do { + if (existsSync(join(dir, 'pnpm-lock.yaml'))) return 'pnpm'; + if (existsSync(join(dir, 'yarn.lock'))) return 'yarn'; + if (existsSync(join(dir, 'package-lock.json'))) return 'npm'; + } while (dir !== (dir = dirname(dir))); + + return 'npm'; +} + +function detect_package_manager() { + const manager = detect_lockfile(); + + try { + execSync(`${manager} --version`); + return manager; + } catch { + return 'npm'; + } +} + +/** @param {string} name */ +async function import_from_cwd(name) { + const cwd = pathToFileURL(process.cwd()).href; + const url = await resolve(name, cwd + '/x.js'); + + return import(url); +} + +/** @typedef {import('@sveltejs/kit').Adapter} Adapter */ + +/** + * @returns {Promise} The corresponding adapter for the current environment if found otherwise undefined + */ +async function get_adapter() { + const match = adapters.find((candidate) => candidate.test()); + + if (!match) return; + + /** @type {{ default: () => Adapter }} */ + let module; + + try { + module = await import_from_cwd(match.module); + } catch (error) { + if ( + error.code === 'ERR_MODULE_NOT_FOUND' && + error.message.startsWith(`Cannot find package '${match.module}'`) + ) { + const package_manager = detect_package_manager(); + const command = commands[package_manager](match.module, match.version); + + try { + console.log(`Installing ${match.module}...`); + + execSync(command, { + stdio: 'inherit', + env: { + ...process.env, + NODE_ENV: undefined + } + }); + + module = await import_from_cwd(match.module); + + console.log(`Successfully installed ${match.module}.`); + console.warn( + `\nIf you plan on staying on this deployment platform, consider replacing @sveltejs/adapter-auto with ${match.module}. This will give you faster and more robust installs, and more control over deployment configuration.\n` + ); + } catch (e) { + throw new Error( + `Could not install ${match.module}. Please install it yourself by adding it to your package.json's devDependencies and try building your project again.`, + { cause: e } + ); + } + } else { + throw error; + } + } + + const adapter = module.default(); + + return { + ...adapter, + adapt: (builder) => { + builder.log.info(`Detected environment: ${match.name}. Using ${match.module}`); + return adapter.adapt(builder); + } + }; +} + +/** @type {() => Adapter} */ +export default () => ({ + name: '@sveltejs/adapter-auto', + adapt: async (builder) => { + const adapter = await get_adapter(); + + if (adapter) return adapter.adapt(builder); + + builder.log.warn( + 'Could not detect a supported production environment. See https://kit.svelte.dev/docs/adapters to learn how to configure your app to run on the platform of your choosing' + ); + } +}); diff --git a/node_modules/@sveltejs/adapter-auto/package.json b/node_modules/@sveltejs/adapter-auto/package.json new file mode 100644 index 000000000..4ac0f102c --- /dev/null +++ b/node_modules/@sveltejs/adapter-auto/package.json @@ -0,0 +1,44 @@ +{ + "name": "@sveltejs/adapter-auto", + "version": "3.0.1", + "description": "Automatically chooses the SvelteKit adapter for your current environment, if possible.", + "repository": { + "type": "git", + "url": "https://github.com/sveltejs/kit", + "directory": "packages/adapter-auto" + }, + "license": "MIT", + "homepage": "https://kit.svelte.dev", + "type": "module", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.js" + }, + "./package.json": "./package.json" + }, + "types": "index.d.ts", + "files": [ + "files", + "index.js", + "index.d.ts", + "adapters.js" + ], + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@types/node": "^18.19.3", + "typescript": "^5.3.3", + "@sveltejs/kit": "^2.0.4" + }, + "dependencies": { + "import-meta-resolve": "^4.0.0" + }, + "peerDependencies": { + "@sveltejs/kit": "^2.0.0" + }, + "scripts": { + "lint": "prettier --check .", + "format": "pnpm lint --write", + "check": "tsc" + } +} \ No newline at end of file diff --git a/node_modules/@sveltejs/adapter-static/LICENSE b/node_modules/@sveltejs/adapter-static/LICENSE new file mode 100644 index 000000000..22efd0c0d --- /dev/null +++ b/node_modules/@sveltejs/adapter-static/LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/@sveltejs/adapter-static/README.md b/node_modules/@sveltejs/adapter-static/README.md new file mode 100644 index 000000000..0d3aebd93 --- /dev/null +++ b/node_modules/@sveltejs/adapter-static/README.md @@ -0,0 +1,15 @@ +# @sveltejs/adapter-static + +[Adapter](https://kit.svelte.dev/docs/adapters) for SvelteKit apps that prerenders your entire site as a collection of static files. It's also possible to create an SPA with it by specifying a fallback page which renders an empty shell. If you'd like to prerender only some pages and not create an SPA for those left out, you will need to use a different adapter together with [the `prerender` option](https://kit.svelte.dev/docs/page-options#prerender). + +## Docs + +[Docs](https://kit.svelte.dev/docs/adapter-static) + +## Changelog + +[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/adapter-static/CHANGELOG.md). + +## License + +[MIT](LICENSE) diff --git a/node_modules/@sveltejs/adapter-static/index.d.ts b/node_modules/@sveltejs/adapter-static/index.d.ts new file mode 100644 index 000000000..101e02fde --- /dev/null +++ b/node_modules/@sveltejs/adapter-static/index.d.ts @@ -0,0 +1,11 @@ +import { Adapter } from '@sveltejs/kit'; + +export interface AdapterOptions { + pages?: string; + assets?: string; + fallback?: string; + precompress?: boolean; + strict?: boolean; +} + +export default function plugin(options?: AdapterOptions): Adapter; diff --git a/node_modules/@sveltejs/adapter-static/index.js b/node_modules/@sveltejs/adapter-static/index.js new file mode 100644 index 000000000..3ddb1b84e --- /dev/null +++ b/node_modules/@sveltejs/adapter-static/index.js @@ -0,0 +1,91 @@ +import path from 'node:path'; +import { platforms } from './platforms.js'; + +/** @type {import('./index.js').default} */ +export default function (options) { + return { + name: '@sveltejs/adapter-static', + + async adapt(builder) { + if (!options?.fallback) { + const dynamic_routes = builder.routes.filter((route) => route.prerender !== true); + if (dynamic_routes.length > 0 && options?.strict !== false) { + const prefix = path.relative('.', builder.config.kit.files.routes); + const has_param_routes = builder.routes.some((route) => route.id.includes('[')); + const config_option = + has_param_routes || JSON.stringify(builder.config.kit.prerender.entries) !== '["*"]' + ? ` - adjust the \`prerender.entries\` config option ${ + has_param_routes + ? '(routes with parameters are not part of entry points by default)' + : '' + } — see https://kit.svelte.dev/docs/configuration#prerender for more info.` + : ''; + + builder.log.error( + `@sveltejs/adapter-static: all routes must be fully prerenderable, but found the following routes that are dynamic: +${dynamic_routes.map((route) => ` - ${path.posix.join(prefix, route.id)}`).join('\n')} + +You have the following options: + - set the \`fallback\` option — see https://kit.svelte.dev/docs/single-page-apps#usage for more info. + - add \`export const prerender = true\` to your root \`+layout.js/.ts\` or \`+layout.server.js/.ts\` file. This will try to prerender all pages. + - add \`export const prerender = true\` to any \`+server.js/ts\` files that are not fetched by page \`load\` functions. +${config_option} + - pass \`strict: false\` to \`adapter-static\` to ignore this error. Only do this if you are sure you don't need the routes in question in your final app, as they will be unavailable. See https://github.com/sveltejs/kit/tree/main/packages/adapter-static#strict for more info. + +If this doesn't help, you may need to use a different adapter. @sveltejs/adapter-static can only be used for sites that don't need a server for dynamic rendering, and can run on just a static file server. +See https://kit.svelte.dev/docs/page-options#prerender for more details` + ); + throw new Error('Encountered dynamic routes'); + } + } + + const platform = platforms.find((platform) => platform.test()); + + if (platform) { + if (options) { + builder.log.warn( + `Detected ${platform.name}. Please remove adapter-static options to enable zero-config mode` + ); + } else { + builder.log.info(`Detected ${platform.name}, using zero-config mode`); + } + } + + const { + // @ts-ignore + pages = 'build', + assets = pages, + fallback, + precompress + } = options ?? platform?.defaults ?? /** @type {import('./index.js').AdapterOptions} */ ({}); + + builder.rimraf(assets); + builder.rimraf(pages); + + builder.generateEnvModule(); + builder.writeClient(assets); + builder.writePrerendered(pages); + + if (fallback) { + await builder.generateFallback(path.join(pages, fallback)); + } + + if (precompress) { + builder.log.minor('Compressing assets and pages'); + if (pages === assets) { + await builder.compress(assets); + } else { + await Promise.all([builder.compress(assets), builder.compress(pages)]); + } + } + + if (pages === assets) { + builder.log(`Wrote site to "${pages}"`); + } else { + builder.log(`Wrote pages to "${pages}" and assets to "${assets}"`); + } + + if (!options) platform?.done(builder); + } + }; +} diff --git a/node_modules/@sveltejs/adapter-static/package.json b/node_modules/@sveltejs/adapter-static/package.json new file mode 100644 index 000000000..fd645de44 --- /dev/null +++ b/node_modules/@sveltejs/adapter-static/package.json @@ -0,0 +1,45 @@ +{ + "name": "@sveltejs/adapter-static", + "version": "3.0.1", + "description": "Adapter for SvelteKit apps that prerenders your entire site as a collection of static files", + "repository": { + "type": "git", + "url": "https://github.com/sveltejs/kit", + "directory": "packages/adapter-static" + }, + "license": "MIT", + "homepage": "https://kit.svelte.dev", + "type": "module", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.js" + }, + "./package.json": "./package.json" + }, + "types": "index.d.ts", + "files": [ + "index.js", + "index.d.ts", + "platforms.js" + ], + "devDependencies": { + "@playwright/test": "1.30.0", + "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@types/node": "^18.19.3", + "sirv": "^2.0.3", + "svelte": "^4.2.8", + "typescript": "^5.3.3", + "vite": "^5.0.8", + "@sveltejs/kit": "^2.0.4" + }, + "peerDependencies": { + "@sveltejs/kit": "^2.0.0" + }, + "scripts": { + "lint": "prettier --check .", + "check": "tsc", + "format": "pnpm lint --write", + "test": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test" + } +} \ No newline at end of file diff --git a/node_modules/@sveltejs/adapter-static/platforms.js b/node_modules/@sveltejs/adapter-static/platforms.js new file mode 100644 index 000000000..908e74b29 --- /dev/null +++ b/node_modules/@sveltejs/adapter-static/platforms.js @@ -0,0 +1,75 @@ +import fs from 'node:fs'; + +/** + * @typedef {{ + * name: string; + * test: () => boolean; + * defaults: import('./index.js').AdapterOptions; + * done: (builder: import('@sveltejs/kit').Builder) => void; + * }} + * Platform */ + +// This function is duplicated in adapter-vercel +/** @param {import('@sveltejs/kit').Builder} builder */ +function static_vercel_config(builder) { + /** @type {any[]} */ + const prerendered_redirects = []; + + /** @type {Record} */ + const overrides = {}; + + for (const [src, redirect] of builder.prerendered.redirects) { + prerendered_redirects.push({ + src, + headers: { + Location: redirect.location + }, + status: redirect.status + }); + } + + for (const [path, page] of builder.prerendered.pages) { + if (path.endsWith('/') && path !== '/') { + prerendered_redirects.push( + { src: path, dest: path.slice(0, -1) }, + { src: path.slice(0, -1), status: 308, headers: { Location: path } } + ); + + overrides[page.file] = { path: path.slice(1, -1) }; + } else { + overrides[page.file] = { path: path.slice(1) }; + } + } + + return { + version: 3, + routes: [ + ...prerendered_redirects, + { + src: `/${builder.getAppPath()}/immutable/.+`, + headers: { + 'cache-control': 'public, immutable, max-age=31536000' + } + }, + { + handle: 'filesystem' + } + ], + overrides + }; +} + +/** @type {Platform[]} */ +export const platforms = [ + { + name: 'Vercel', + test: () => !!process.env.VERCEL, + defaults: { + pages: '.vercel/output/static' + }, + done: (builder) => { + const config = static_vercel_config(builder); + fs.writeFileSync('.vercel/output/config.json', JSON.stringify(config, null, ' ')); + } + } +]; diff --git a/node_modules/@sveltejs/kit/LICENSE b/node_modules/@sveltejs/kit/LICENSE new file mode 100644 index 000000000..22efd0c0d --- /dev/null +++ b/node_modules/@sveltejs/kit/LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/@sveltejs/kit/README.md b/node_modules/@sveltejs/kit/README.md new file mode 100644 index 000000000..86a454723 --- /dev/null +++ b/node_modules/@sveltejs/kit/README.md @@ -0,0 +1,18 @@ +# The fastest way to build Svelte apps + +This is the [SvelteKit](https://kit.svelte.dev) framework and CLI. + +The quickest way to get started is via the [create-svelte](https://github.com/sveltejs/kit/tree/main/packages/create-svelte) package: + +```bash +npm create svelte@latest my-app +cd my-app +npm install +npm run dev +``` + +See the [documentation](https://kit.svelte.dev/docs) to learn more. + +## Changelog + +[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/main/packages/kit/CHANGELOG.md). diff --git a/node_modules/@sveltejs/kit/package.json b/node_modules/@sveltejs/kit/package.json new file mode 100644 index 000000000..75a38b777 --- /dev/null +++ b/node_modules/@sveltejs/kit/package.json @@ -0,0 +1,99 @@ +{ + "name": "@sveltejs/kit", + "version": "2.0.6", + "description": "The fastest way to build Svelte apps", + "repository": { + "type": "git", + "url": "https://github.com/sveltejs/kit", + "directory": "packages/kit" + }, + "license": "MIT", + "homepage": "https://kit.svelte.dev", + "type": "module", + "dependencies": { + "@types/cookie": "^0.6.0", + "cookie": "^0.6.0", + "devalue": "^4.3.2", + "esm-env": "^1.0.0", + "kleur": "^4.1.5", + "magic-string": "^0.30.5", + "mrmime": "^2.0.0", + "sade": "^1.8.1", + "set-cookie-parser": "^2.6.0", + "sirv": "^2.0.4", + "tiny-glob": "^0.2.9" + }, + "devDependencies": { + "@playwright/test": "1.30.0", + "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@types/connect": "^3.4.38", + "@types/node": "^18.19.3", + "@types/sade": "^1.7.8", + "@types/set-cookie-parser": "^2.4.7", + "dts-buddy": "^0.4.3", + "rollup": "^4.8.0", + "svelte": "^4.2.8", + "svelte-preprocess": "^5.1.2", + "typescript": "^5.3.3", + "vite": "^5.0.8", + "vitest": "^1.0.4" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.3" + }, + "bin": { + "svelte-kit": "svelte-kit.js" + }, + "files": [ + "src", + "!src/**/*.spec.js", + "!src/core/**/fixtures", + "!src/core/**/test", + "types", + "svelte-kit.js", + "postinstall.js" + ], + "exports": { + "./package.json": "./package.json", + ".": { + "types": "./types/index.d.ts", + "import": "./src/exports/index.js" + }, + "./node": { + "types": "./types/index.d.ts", + "import": "./src/exports/node/index.js" + }, + "./node/polyfills": { + "types": "./types/index.d.ts", + "import": "./src/exports/node/polyfills.js" + }, + "./hooks": { + "types": "./types/index.d.ts", + "import": "./src/exports/hooks/index.js" + }, + "./vite": { + "types": "./types/index.d.ts", + "import": "./src/exports/vite/index.js" + } + }, + "types": "types/index.d.ts", + "engines": { + "node": ">=18.13" + }, + "scripts": { + "lint": "prettier --config ../../.prettierrc --check .", + "check": "tsc && cd ./test/types && tsc", + "check:all": "tsc && pnpm -r --filter=\"./**\" check", + "format": "prettier --config ../../.prettierrc --write .", + "test": "pnpm test:unit && pnpm test:integration", + "test:integration": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test", + "test:cross-platform:dev": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:dev", + "test:cross-platform:build": "pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:build", + "test:unit": "vitest --config kit.vitest.config.js run", + "postinstall": "node postinstall.js", + "generate:version": "node scripts/generate-version.js", + "generate:types": "node scripts/generate-dts.js" + } +} \ No newline at end of file diff --git a/node_modules/@sveltejs/kit/postinstall.js b/node_modules/@sveltejs/kit/postinstall.js new file mode 100644 index 000000000..da908bbf8 --- /dev/null +++ b/node_modules/@sveltejs/kit/postinstall.js @@ -0,0 +1,52 @@ +import { load_config } from './src/core/config/index.js'; +import * as sync from './src/core/sync/sync.js'; +import glob from 'tiny-glob/sync.js'; +import fs from 'node:fs'; + +try { + const cwd = process.env.INIT_CWD ?? process.cwd(); + process.chdir(cwd); + + if (fs.existsSync('package.json')) { + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); + + const workspaces = []; + + if (pkg.workspaces) { + // Find all npm and Yarn workspace glob patterns + // https://classic.yarnpkg.com/blog/2018/02/15/nohoist/ + // https://docs.npmjs.com/cli/v9/configuring-npm/package-json#workspaces + const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces.packages; + + for (const pattern of patterns) { + workspaces.push( + ...glob(pattern, { cwd, absolute: true }).filter((path) => + fs.statSync(path).isDirectory() + ) + ); + } + } else { + workspaces.push(cwd); + } + + for (const cwd of workspaces) { + process.chdir(cwd); + + if (!fs.existsSync('package.json')) continue; + if (!fs.existsSync('svelte.config.js')) continue; + + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); + if (!pkg.dependencies?.['@sveltejs/kit'] && !pkg.devDependencies?.['@sveltejs/kit']) continue; + + try { + const config = await load_config(); + await sync.all(config, 'development'); + } catch (error) { + console.error('Error while trying to sync SvelteKit config'); + console.error(error); + } + } + } +} catch (error) { + console.error(error); +} diff --git a/node_modules/@sveltejs/kit/src/cli.js b/node_modules/@sveltejs/kit/src/cli.js new file mode 100644 index 000000000..9cf2cfaf1 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/cli.js @@ -0,0 +1,44 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import colors from 'kleur'; +import sade from 'sade'; +import { load_config } from './core/config/index.js'; +import { coalesce_to_error } from './utils/error.js'; + +/** @param {unknown} e */ +function handle_error(e) { + const error = coalesce_to_error(e); + + if (error.name === 'SyntaxError') throw error; + + console.error(colors.bold().red(`> ${error.message}`)); + if (error.stack) { + console.error(colors.gray(error.stack.split('\n').slice(1).join('\n'))); + } + + process.exit(1); +} + +const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8')); +const prog = sade('svelte-kit').version(pkg.version); + +prog + .command('sync') + .describe('Synchronise generated type definitions') + .option('--mode', 'Specify a mode for loading environment variables', 'development') + .action(async ({ mode }) => { + if (!fs.existsSync('svelte.config.js')) { + console.warn(`Missing ${path.resolve('svelte.config.js')} — skipping`); + return; + } + + try { + const config = await load_config(); + const sync = await import('./core/sync/sync.js'); + await sync.all_types(config, mode); + } catch (error) { + handle_error(error); + } + }); + +prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` }); diff --git a/node_modules/@sveltejs/kit/src/constants.js b/node_modules/@sveltejs/kit/src/constants.js new file mode 100644 index 000000000..7790ab1c6 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/constants.js @@ -0,0 +1,11 @@ +/** + * A fake asset path used in `vite dev` and `vite preview`, so that we can + * serve local assets while verifying that requests are correctly prefixed + */ +export const SVELTE_KIT_ASSETS = '/_svelte_kit_assets'; + +export const GENERATED_COMMENT = '// this file is generated — do not edit it\n'; + +export const ENDPOINT_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD']; + +export const PAGE_METHODS = ['GET', 'POST', 'HEAD']; diff --git a/node_modules/@sveltejs/kit/src/core/adapt/builder.js b/node_modules/@sveltejs/kit/src/core/adapt/builder.js new file mode 100644 index 000000000..2c55f5027 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/adapt/builder.js @@ -0,0 +1,230 @@ +import { existsSync, statSync, createReadStream, createWriteStream } from 'node:fs'; +import { extname, resolve } from 'node:path'; +import { pipeline } from 'node:stream'; +import { promisify } from 'node:util'; +import zlib from 'node:zlib'; +import { copy, rimraf, mkdirp } from '../../utils/filesystem.js'; +import { generate_manifest } from '../generate_manifest/index.js'; +import { get_route_segments } from '../../utils/routing.js'; +import { get_env } from '../../exports/vite/utils.js'; +import generate_fallback from '../postbuild/fallback.js'; +import { write } from '../sync/utils.js'; +import { list_files } from '../utils.js'; + +const pipe = promisify(pipeline); +const extensions = ['.html', '.js', '.mjs', '.json', '.css', '.svg', '.xml', '.wasm']; + +/** + * Creates the Builder which is passed to adapters for building the application. + * @param {{ + * config: import('types').ValidatedConfig; + * build_data: import('types').BuildData; + * server_metadata: import('types').ServerMetadata; + * route_data: import('types').RouteData[]; + * prerendered: import('types').Prerendered; + * prerender_map: import('types').PrerenderMap; + * log: import('types').Logger; + * vite_config: import('vite').ResolvedConfig; + * }} opts + * @returns {import('@sveltejs/kit').Builder} + */ +export function create_builder({ + config, + build_data, + server_metadata, + route_data, + prerendered, + prerender_map, + log, + vite_config +}) { + /** @type {Map} */ + const lookup = new Map(); + + /** + * Rather than exposing the internal `RouteData` type, which is subject to change, + * we expose a stable type that adapters can use to group/filter routes + */ + const routes = route_data.map((route) => { + const { config, methods, page, api } = /** @type {import('types').ServerMetadataRoute} */ ( + server_metadata.routes.get(route.id) + ); + + /** @type {import('@sveltejs/kit').RouteDefinition} */ + const facade = { + id: route.id, + api, + page, + segments: get_route_segments(route.id).map((segment) => ({ + dynamic: segment.includes('['), + rest: segment.includes('[...'), + content: segment + })), + pattern: route.pattern, + prerender: prerender_map.get(route.id) ?? false, + methods, + config + }; + + lookup.set(facade, route); + + return facade; + }); + + return { + log, + rimraf, + mkdirp, + copy, + + config, + prerendered, + routes, + + async compress(directory) { + if (!existsSync(directory)) { + return; + } + + const files = list_files(directory, (file) => extensions.includes(extname(file))).map( + (file) => resolve(directory, file) + ); + + await Promise.all( + files.flatMap((file) => [compress_file(file, 'gz'), compress_file(file, 'br')]) + ); + }, + + async createEntries(fn) { + const seen = new Set(); + + for (let i = 0; i < route_data.length; i += 1) { + const route = route_data[i]; + if (prerender_map.get(route.id) === true) continue; + const { id, filter, complete } = fn(routes[i]); + + if (seen.has(id)) continue; + seen.add(id); + + const group = [route]; + + // figure out which lower priority routes should be considered fallbacks + for (let j = i + 1; j < route_data.length; j += 1) { + if (prerender_map.get(routes[j].id) === true) continue; + if (filter(routes[j])) { + group.push(route_data[j]); + } + } + + const filtered = new Set(group); + + // heuristic: if /foo/[bar] is included, /foo/[bar].json should + // also be included, since the page likely needs the endpoint + // TODO is this still necessary, given the new way of doing things? + filtered.forEach((route) => { + if (route.page) { + const endpoint = route_data.find((candidate) => candidate.id === route.id + '.json'); + + if (endpoint) { + filtered.add(endpoint); + } + } + }); + + if (filtered.size > 0) { + await complete({ + generateManifest: ({ relativePath }) => + generate_manifest({ + build_data, + relative_path: relativePath, + routes: Array.from(filtered) + }) + }); + } + } + }, + + async generateFallback(dest) { + const manifest_path = `${config.kit.outDir}/output/server/manifest-full.js`; + const env = get_env(config.kit.env, vite_config.mode); + + const fallback = await generate_fallback({ + manifest_path, + env: { ...env.private, ...env.public } + }); + + write(dest, fallback); + }, + + generateEnvModule() { + const dest = `${config.kit.outDir}/output/prerendered/dependencies/${config.kit.appDir}/env.js`; + const env = get_env(config.kit.env, vite_config.mode); + + write(dest, `export const env=${JSON.stringify(env.public)}`); + }, + + generateManifest({ relativePath, routes: subset }) { + return generate_manifest({ + build_data, + relative_path: relativePath, + routes: subset + ? subset.map((route) => /** @type {import('types').RouteData} */ (lookup.get(route))) + : route_data.filter((route) => prerender_map.get(route.id) !== true) + }); + }, + + getBuildDirectory(name) { + return `${config.kit.outDir}/${name}`; + }, + + getClientDirectory() { + return `${config.kit.outDir}/output/client`; + }, + + getServerDirectory() { + return `${config.kit.outDir}/output/server`; + }, + + getAppPath() { + return build_data.app_path; + }, + + writeClient(dest) { + return copy(`${config.kit.outDir}/output/client`, dest, { + // avoid making vite build artefacts public + filter: (basename) => basename !== '.vite' + }); + }, + + writePrerendered(dest) { + const source = `${config.kit.outDir}/output/prerendered`; + return [...copy(`${source}/pages`, dest), ...copy(`${source}/dependencies`, dest)]; + }, + + writeServer(dest) { + return copy(`${config.kit.outDir}/output/server`, dest); + } + }; +} + +/** + * @param {string} file + * @param {'gz' | 'br'} format + */ +async function compress_file(file, format = 'gz') { + const compress = + format == 'br' + ? zlib.createBrotliCompress({ + params: { + [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT, + [zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY, + [zlib.constants.BROTLI_PARAM_SIZE_HINT]: statSync(file).size + } + }) + : zlib.createGzip({ level: zlib.constants.Z_BEST_COMPRESSION }); + + const source = createReadStream(file); + const destination = createWriteStream(`${file}.${format}`); + + await pipe(source, compress, destination); +} diff --git a/node_modules/@sveltejs/kit/src/core/adapt/index.js b/node_modules/@sveltejs/kit/src/core/adapt/index.js new file mode 100644 index 000000000..235d18526 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/adapt/index.js @@ -0,0 +1,40 @@ +import colors from 'kleur'; +import { create_builder } from './builder.js'; + +/** + * @param {import('types').ValidatedConfig} config + * @param {import('types').BuildData} build_data + * @param {import('types').ServerMetadata} server_metadata + * @param {import('types').Prerendered} prerendered + * @param {import('types').PrerenderMap} prerender_map + * @param {import('types').Logger} log + * @param {import('vite').ResolvedConfig} vite_config + */ +export async function adapt( + config, + build_data, + server_metadata, + prerendered, + prerender_map, + log, + vite_config +) { + const { name, adapt } = config.kit.adapter; + + console.log(colors.bold().cyan(`\n> Using ${name}`)); + + const builder = create_builder({ + config, + build_data, + server_metadata, + route_data: build_data.manifest_data.routes.filter((route) => route.page || route.endpoint), + prerendered, + prerender_map, + log, + vite_config + }); + + await adapt(builder); + + log.success('done'); +} diff --git a/node_modules/@sveltejs/kit/src/core/config/default-error.html b/node_modules/@sveltejs/kit/src/core/config/default-error.html new file mode 100644 index 000000000..c322e1682 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/config/default-error.html @@ -0,0 +1,80 @@ + + + + + %sveltekit.error.message% + + + + +
+ %sveltekit.status% +
+

%sveltekit.error.message%

+
+
+ + diff --git a/node_modules/@sveltejs/kit/src/core/config/index.js b/node_modules/@sveltejs/kit/src/core/config/index.js new file mode 100644 index 000000000..cb2a44670 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/config/index.js @@ -0,0 +1,117 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import * as url from 'node:url'; +import options from './options.js'; + +/** + * Loads the template (src/app.html by default) and validates that it has the + * required content. + * @param {string} cwd + * @param {import('types').ValidatedConfig} config + */ +export function load_template(cwd, { kit }) { + const { env, files } = kit; + + const relative = path.relative(cwd, files.appTemplate); + + if (!fs.existsSync(files.appTemplate)) { + throw new Error(`${relative} does not exist`); + } + + const contents = fs.readFileSync(files.appTemplate, 'utf8'); + + const expected_tags = ['%sveltekit.head%', '%sveltekit.body%']; + expected_tags.forEach((tag) => { + if (contents.indexOf(tag) === -1) { + throw new Error(`${relative} is missing ${tag}`); + } + }); + + for (const match of contents.matchAll(/%sveltekit\.env\.([^%]+)%/g)) { + if (!match[1].startsWith(env.publicPrefix)) { + throw new Error( + `Environment variables in ${relative} must start with ${env.publicPrefix} (saw %sveltekit.env.${match[1]}%)` + ); + } + } + + return contents; +} + +/** + * Loads the error page (src/error.html by default) if it exists. + * Falls back to a generic error page content. + * @param {import('types').ValidatedConfig} config + */ +export function load_error_page(config) { + let { errorTemplate } = config.kit.files; + + // Don't do this inside resolving the config, because that would mean + // adding/removing error.html isn't detected and would require a restart. + if (!fs.existsSync(config.kit.files.errorTemplate)) { + errorTemplate = url.fileURLToPath(new URL('./default-error.html', import.meta.url)); + } + + return fs.readFileSync(errorTemplate, 'utf-8'); +} + +/** + * Loads and validates svelte.config.js + * @param {{ cwd?: string }} options + * @returns {Promise} + */ +export async function load_config({ cwd = process.cwd() } = {}) { + const config_file = path.join(cwd, 'svelte.config.js'); + + if (!fs.existsSync(config_file)) { + return process_config({}, { cwd }); + } + + const config = await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`); + + try { + return process_config(config.default, { cwd }); + } catch (e) { + const error = /** @type {Error} */ (e); + + // redact the stack trace — it's not helpful to users + error.stack = `Could not load svelte.config.js: ${error.message}\n`; + throw error; + } +} + +/** + * @param {import('@sveltejs/kit').Config} config + * @returns {import('types').ValidatedConfig} + */ +function process_config(config, { cwd = process.cwd() } = {}) { + const validated = validate_config(config); + + validated.kit.outDir = path.resolve(cwd, validated.kit.outDir); + + for (const key in validated.kit.files) { + if (key === 'hooks') { + validated.kit.files.hooks.client = path.resolve(cwd, validated.kit.files.hooks.client); + validated.kit.files.hooks.server = path.resolve(cwd, validated.kit.files.hooks.server); + } else { + // @ts-expect-error + validated.kit.files[key] = path.resolve(cwd, validated.kit.files[key]); + } + } + + return validated; +} + +/** + * @param {import('@sveltejs/kit').Config} config + * @returns {import('types').ValidatedConfig} + */ +export function validate_config(config) { + if (typeof config !== 'object') { + throw new Error( + 'svelte.config.js must have a configuration object as its default export. See https://kit.svelte.dev/docs/configuration' + ); + } + + return options(config, 'config'); +} diff --git a/node_modules/@sveltejs/kit/src/core/config/options.js b/node_modules/@sveltejs/kit/src/core/config/options.js new file mode 100644 index 000000000..dbbb19d97 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/config/options.js @@ -0,0 +1,427 @@ +import { join } from 'node:path'; + +/** @typedef {import('./types.js').Validator} Validator */ + +const directives = object({ + 'child-src': string_array(), + 'default-src': string_array(), + 'frame-src': string_array(), + 'worker-src': string_array(), + 'connect-src': string_array(), + 'font-src': string_array(), + 'img-src': string_array(), + 'manifest-src': string_array(), + 'media-src': string_array(), + 'object-src': string_array(), + 'prefetch-src': string_array(), + 'script-src': string_array(), + 'script-src-elem': string_array(), + 'script-src-attr': string_array(), + 'style-src': string_array(), + 'style-src-elem': string_array(), + 'style-src-attr': string_array(), + 'base-uri': string_array(), + sandbox: string_array(), + 'form-action': string_array(), + 'frame-ancestors': string_array(), + 'navigate-to': string_array(), + 'report-uri': string_array(), + 'report-to': string_array(), + 'require-trusted-types-for': string_array(), + 'trusted-types': string_array(), + 'upgrade-insecure-requests': boolean(false), + 'require-sri-for': string_array(), + 'block-all-mixed-content': boolean(false), + 'plugin-types': string_array(), + referrer: string_array() +}); + +/** @type {Validator} */ +const options = object( + { + extensions: validate(['.svelte'], (input, keypath) => { + if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) { + throw new Error(`${keypath} must be an array of strings`); + } + + input.forEach((extension) => { + if (extension[0] !== '.') { + throw new Error(`Each member of ${keypath} must start with '.' — saw '${extension}'`); + } + + if (!/^(\.[a-z0-9]+)+$/i.test(extension)) { + throw new Error(`File extensions must be alphanumeric — saw '${extension}'`); + } + }); + + return input; + }), + + kit: object({ + adapter: validate(null, (input, keypath) => { + if (typeof input !== 'object' || !input.adapt) { + let message = `${keypath} should be an object with an "adapt" method`; + + if (Array.isArray(input) || typeof input === 'string') { + // for the early adapter adopters + message += ', rather than the name of an adapter'; + } + + throw new Error(`${message}. See https://kit.svelte.dev/docs/adapters`); + } + + return input; + }), + + alias: validate({}, (input, keypath) => { + if (typeof input !== 'object') { + throw new Error(`${keypath} should be an object`); + } + + for (const key in input) { + assert_string(input[key], `${keypath}.${key}`); + } + + return input; + }), + + appDir: validate('_app', (input, keypath) => { + assert_string(input, keypath); + + if (input) { + if (input.startsWith('/') || input.endsWith('/')) { + throw new Error( + "config.kit.appDir cannot start or end with '/'. See https://kit.svelte.dev/docs/configuration" + ); + } + } else { + throw new Error(`${keypath} cannot be empty`); + } + + return input; + }), + + csp: object({ + mode: list(['auto', 'hash', 'nonce']), + directives, + reportOnly: directives + }), + + csrf: object({ + checkOrigin: boolean(true) + }), + + embedded: boolean(false), + + env: object({ + dir: string(process.cwd()), + publicPrefix: string('PUBLIC_'), + privatePrefix: string('') + }), + + files: object({ + assets: string('static'), + hooks: object({ + client: string(join('src', 'hooks.client')), + server: string(join('src', 'hooks.server')) + }), + lib: string(join('src', 'lib')), + params: string(join('src', 'params')), + routes: string(join('src', 'routes')), + serviceWorker: string(join('src', 'service-worker')), + appTemplate: string(join('src', 'app.html')), + errorTemplate: string(join('src', 'error.html')) + }), + + inlineStyleThreshold: number(0), + + moduleExtensions: string_array(['.js', '.ts']), + + outDir: string('.svelte-kit'), + + output: object({ + preloadStrategy: list(['modulepreload', 'preload-js', 'preload-mjs'], 'modulepreload') + }), + + paths: object({ + base: validate('', (input, keypath) => { + assert_string(input, keypath); + + if (input !== '' && (input.endsWith('/') || !input.startsWith('/'))) { + throw new Error( + `${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://kit.svelte.dev/docs/configuration#paths` + ); + } + + return input; + }), + assets: validate('', (input, keypath) => { + assert_string(input, keypath); + + if (input) { + if (!/^[a-z]+:\/\//.test(input)) { + throw new Error( + `${keypath} option must be an absolute path, if specified. See https://kit.svelte.dev/docs/configuration#paths` + ); + } + + if (input.endsWith('/')) { + throw new Error( + `${keypath} option must not end with '/'. See https://kit.svelte.dev/docs/configuration#paths` + ); + } + } + + return input; + }), + relative: boolean(true) + }), + + prerender: object({ + concurrency: number(1), + crawl: boolean(true), + entries: validate(['*'], (input, keypath) => { + if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) { + throw new Error(`${keypath} must be an array of strings`); + } + + input.forEach((page) => { + if (page !== '*' && page[0] !== '/') { + throw new Error( + `Each member of ${keypath} must be either '*' or an absolute path beginning with '/' — saw '${page}'` + ); + } + }); + + return input; + }), + + handleHttpError: validate( + (/** @type {any} */ { message }) => { + throw new Error( + message + + '\nTo suppress or handle this error, implement `handleHttpError` in https://kit.svelte.dev/docs/configuration#prerender' + ); + }, + (input, keypath) => { + if (typeof input === 'function') return input; + if (['fail', 'warn', 'ignore'].includes(input)) return input; + throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`); + } + ), + + handleMissingId: validate( + (/** @type {any} */ { message }) => { + throw new Error( + message + + '\nTo suppress or handle this error, implement `handleMissingId` in https://kit.svelte.dev/docs/configuration#prerender' + ); + }, + (input, keypath) => { + if (typeof input === 'function') return input; + if (['fail', 'warn', 'ignore'].includes(input)) return input; + throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`); + } + ), + + handleEntryGeneratorMismatch: validate( + (/** @type {any} */ { message }) => { + throw new Error( + message + + '\nTo suppress or handle this error, implement `handleEntryGeneratorMismatch` in https://kit.svelte.dev/docs/configuration#prerender' + ); + }, + (input, keypath) => { + if (typeof input === 'function') return input; + if (['fail', 'warn', 'ignore'].includes(input)) return input; + throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`); + } + ), + + origin: validate('http://sveltekit-prerender', (input, keypath) => { + assert_string(input, keypath); + + let origin; + + try { + origin = new URL(input).origin; + } catch (e) { + throw new Error(`${keypath} must be a valid origin`); + } + + if (input !== origin) { + throw new Error(`${keypath} must be a valid origin (${origin} rather than ${input})`); + } + + return origin; + }) + }), + + serviceWorker: object({ + register: boolean(true), + files: fun((filename) => !/\.DS_Store/.test(filename)) + }), + + typescript: object({ + config: fun((config) => config) + }), + + version: object({ + name: string(Date.now().toString()), + pollInterval: number(0) + }) + }) + }, + true +); + +/** + * @param {Record} children + * @param {boolean} [allow_unknown] + * @returns {Validator} + */ +function object(children, allow_unknown = false) { + return (input, keypath) => { + /** @type {Record} */ + const output = {}; + + if ((input && typeof input !== 'object') || Array.isArray(input)) { + throw new Error(`${keypath} should be an object`); + } + + for (const key in input) { + if (!(key in children)) { + if (allow_unknown) { + output[key] = input[key]; + } else { + let message = `Unexpected option ${keypath}.${key}`; + + // special case + if (keypath === 'config.kit' && key in options) { + message += ` (did you mean config.${key}?)`; + } + + throw new Error(message); + } + } + } + + for (const key in children) { + const validator = children[key]; + output[key] = validator(input && input[key], `${keypath}.${key}`); + } + + return output; + }; +} + +/** + * @param {any} fallback + * @param {(value: any, keypath: string) => any} fn + * @returns {Validator} + */ +function validate(fallback, fn) { + return (input, keypath) => { + return input === undefined ? fallback : fn(input, keypath); + }; +} + +/** + * @param {string | null} fallback + * @param {boolean} allow_empty + * @returns {Validator} + */ +function string(fallback, allow_empty = true) { + return validate(fallback, (input, keypath) => { + assert_string(input, keypath); + + if (!allow_empty && input === '') { + throw new Error(`${keypath} cannot be empty`); + } + + return input; + }); +} + +/** + * @param {string[] | undefined} [fallback] + * @returns {Validator} + */ +function string_array(fallback) { + return validate(fallback, (input, keypath) => { + if (!Array.isArray(input) || input.some((value) => typeof value !== 'string')) { + throw new Error(`${keypath} must be an array of strings, if specified`); + } + + return input; + }); +} + +/** + * @param {number} fallback + * @returns {Validator} + */ +function number(fallback) { + return validate(fallback, (input, keypath) => { + if (typeof input !== 'number') { + throw new Error(`${keypath} should be a number, if specified`); + } + return input; + }); +} + +/** + * @param {boolean} fallback + * @returns {Validator} + */ +function boolean(fallback) { + return validate(fallback, (input, keypath) => { + if (typeof input !== 'boolean') { + throw new Error(`${keypath} should be true or false, if specified`); + } + return input; + }); +} + +/** + * @param {string[]} options + * @returns {Validator} + */ +function list(options, fallback = options[0]) { + return validate(fallback, (input, keypath) => { + if (!options.includes(input)) { + // prettier-ignore + const msg = options.length > 2 + ? `${keypath} should be one of ${options.slice(0, -1).map(input => `"${input}"`).join(', ')} or "${options[options.length - 1]}"` + : `${keypath} should be either "${options[0]}" or "${options[1]}"`; + + throw new Error(msg); + } + return input; + }); +} + +/** + * @param {(...args: any) => any} fallback + * @returns {Validator} + */ +function fun(fallback) { + return validate(fallback, (input, keypath) => { + if (typeof input !== 'function') { + throw new Error(`${keypath} should be a function, if specified`); + } + return input; + }); +} + +/** + * @param {string} input + * @param {string} keypath + */ +function assert_string(input, keypath) { + if (typeof input !== 'string') { + throw new Error(`${keypath} should be a string, if specified`); + } +} + +export default options; diff --git a/node_modules/@sveltejs/kit/src/core/config/types.d.ts b/node_modules/@sveltejs/kit/src/core/config/types.d.ts new file mode 100644 index 000000000..00d005c32 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/config/types.d.ts @@ -0,0 +1 @@ +export type Validator = (input: T, keypath: string) => T; diff --git a/node_modules/@sveltejs/kit/src/core/env.js b/node_modules/@sveltejs/kit/src/core/env.js new file mode 100644 index 000000000..455eb0f44 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/env.js @@ -0,0 +1,152 @@ +import { GENERATED_COMMENT } from '../constants.js'; +import { dedent } from './sync/utils.js'; +import { runtime_base } from './utils.js'; + +/** + * @typedef {'public' | 'private'} EnvType + */ + +/** + * @param {string} id + * @param {Record} env + * @returns {string} + */ +export function create_static_module(id, env) { + /** @type {string[]} */ + const declarations = []; + + for (const key in env) { + if (!valid_identifier.test(key) || reserved.has(key)) { + continue; + } + + const comment = `/** @type {import('${id}').${key}} */`; + const declaration = `export const ${key} = ${JSON.stringify(env[key])};`; + + declarations.push(`${comment}\n${declaration}`); + } + + return GENERATED_COMMENT + declarations.join('\n\n'); +} + +/** + * @param {EnvType} type + * @param {Record | undefined} dev_values If in a development mode, values to pre-populate the module with. + */ +export function create_dynamic_module(type, dev_values) { + if (dev_values) { + const keys = Object.entries(dev_values).map( + ([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}` + ); + return `export const env = {\n${keys.join(',\n')}\n}`; + } + return `export { ${type}_env as env } from '${runtime_base}/shared-server.js';`; +} + +/** + * @param {EnvType} id + * @param {import('types').Env} env + * @returns {string} + */ +export function create_static_types(id, env) { + const declarations = Object.keys(env[id]) + .filter((k) => valid_identifier.test(k)) + .map((k) => `export const ${k}: string;`); + + return dedent` + declare module '$env/static/${id}' { + ${declarations.join('\n')} + } + `; +} + +/** + * @param {EnvType} id + * @param {import('types').Env} env + * @param {{ + * public_prefix: string; + * private_prefix: string; + * }} prefixes + * @returns {string} + */ +export function create_dynamic_types(id, env, { public_prefix, private_prefix }) { + const properties = Object.keys(env[id]) + .filter((k) => valid_identifier.test(k)) + .map((k) => `${k}: string;`); + + const public_prefixed = `[key: \`${public_prefix}\${string}\`]`; + const private_prefixed = `[key: \`${private_prefix}\${string}\`]`; + + if (id === 'private') { + if (public_prefix) { + properties.push(`${public_prefixed}: undefined;`); + } + properties.push(`${private_prefixed}: string | undefined;`); + } else { + if (private_prefix) { + properties.push(`${private_prefixed}: undefined;`); + } + properties.push(`${public_prefixed}: string | undefined;`); + } + + return dedent` + declare module '$env/dynamic/${id}' { + export const env: { + ${properties.join('\n')} + } + } + `; +} + +export const reserved = new Set([ + 'do', + 'if', + 'in', + 'for', + 'let', + 'new', + 'try', + 'var', + 'case', + 'else', + 'enum', + 'eval', + 'null', + 'this', + 'true', + 'void', + 'with', + 'await', + 'break', + 'catch', + 'class', + 'const', + 'false', + 'super', + 'throw', + 'while', + 'yield', + 'delete', + 'export', + 'import', + 'public', + 'return', + 'static', + 'switch', + 'typeof', + 'default', + 'extends', + 'finally', + 'package', + 'private', + 'continue', + 'debugger', + 'function', + 'arguments', + 'interface', + 'protected', + 'implements', + 'instanceof' +]); + +export const valid_identifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/; diff --git a/node_modules/@sveltejs/kit/src/core/generate_manifest/index.js b/node_modules/@sveltejs/kit/src/core/generate_manifest/index.js new file mode 100644 index 000000000..272d79e55 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/generate_manifest/index.js @@ -0,0 +1,122 @@ +import { s } from '../../utils/misc.js'; +import { get_mime_lookup } from '../utils.js'; +import { resolve_symlinks } from '../../exports/vite/build/utils.js'; +import { compact } from '../../utils/array.js'; +import { join_relative } from '../../utils/filesystem.js'; +import { dedent } from '../sync/utils.js'; + +/** + * Generates the data used to write the server-side manifest.js file. This data is used in the Vite + * build process, to power routing, etc. + * @param {{ + * build_data: import('types').BuildData; + * relative_path: string; + * routes: import('types').RouteData[]; + * }} opts + */ +export function generate_manifest({ build_data, relative_path, routes }) { + /** + * @type {Map} The new index of each node in the filtered nodes array + */ + const reindexed = new Map(); + /** + * All nodes actually used in the routes definition (prerendered routes are omitted). + * Root layout/error is always included as they are needed for 404 and root errors. + * @type {Set} + */ + const used_nodes = new Set([0, 1]); + + for (const route of routes) { + if (route.page) { + for (const i of route.page.layouts) used_nodes.add(i); + for (const i of route.page.errors) used_nodes.add(i); + used_nodes.add(route.page.leaf); + } + } + + const node_paths = compact( + build_data.manifest_data.nodes.map((_, i) => { + if (used_nodes.has(i)) { + reindexed.set(i, reindexed.size); + return join_relative(relative_path, `/nodes/${i}.js`); + } + }) + ); + + /** @type {(path: string) => string} */ + const loader = (path) => `__memo(() => import('${path}'))`; + + const assets = build_data.manifest_data.assets.map((asset) => asset.file); + if (build_data.service_worker) { + assets.push(build_data.service_worker); + } + + const matchers = new Set(); + + /** @param {Array} indexes */ + function get_nodes(indexes) { + const string = indexes.map((n) => reindexed.get(n) ?? '').join(','); + + // since JavaScript ignores trailing commas, we need to insert a dummy + // comma so that the array has the correct length if the last item + // is undefined + return `[${string},]`; + } + + // prettier-ignore + // String representation of + /** @template {import('@sveltejs/kit').SSRManifest} T */ + const manifest_expr = dedent` + { + appDir: ${s(build_data.app_dir)}, + appPath: ${s(build_data.app_path)}, + assets: new Set(${s(assets)}), + mimeTypes: ${s(get_mime_lookup(build_data.manifest_data))}, + _: { + client: ${s(build_data.client)}, + nodes: [ + ${(node_paths).map(loader).join(',\n')} + ], + routes: [ + ${routes.map(route => { + if (!route.page && !route.endpoint) return; + + route.params.forEach(param => { + if (param.matcher) matchers.add(param.matcher); + }); + + return dedent` + { + id: ${s(route.id)}, + pattern: ${route.pattern}, + params: ${s(route.params)}, + page: ${route.page ? `{ layouts: ${get_nodes(route.page.layouts)}, errors: ${get_nodes(route.page.errors)}, leaf: ${reindexed.get(route.page.leaf)} }` : 'null'}, + endpoint: ${route.endpoint ? loader(join_relative(relative_path, resolve_symlinks(build_data.server_manifest, route.endpoint.file).chunk.file)) : 'null'} + } + `; + }).filter(Boolean).join(',\n')} + ], + matchers: async () => { + ${Array.from( + matchers, + type => `const { match: ${type} } = await import ('${(join_relative(relative_path, `/entries/matchers/${type}.js`))}')` + ).join('\n')} + return { ${Array.from(matchers).join(', ')} }; + } + } + } + `; + + // Memoize the loaders to prevent Node from doing unnecessary work + // on every dynamic import call + return dedent` + (() => { + function __memo(fn) { + let value; + return () => value ??= (value = fn()); + } + + return ${manifest_expr} + })() + `; +} diff --git a/node_modules/@sveltejs/kit/src/core/postbuild/analyse.js b/node_modules/@sveltejs/kit/src/core/postbuild/analyse.js new file mode 100644 index 000000000..e4aac23ec --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/postbuild/analyse.js @@ -0,0 +1,192 @@ +import { join } from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { get_option } from '../../utils/options.js'; +import { + validate_layout_exports, + validate_layout_server_exports, + validate_page_exports, + validate_page_server_exports, + validate_server_exports +} from '../../utils/exports.js'; +import { load_config } from '../config/index.js'; +import { forked } from '../../utils/fork.js'; +import { installPolyfills } from '../../exports/node/polyfills.js'; +import { ENDPOINT_METHODS } from '../../constants.js'; +import { filter_private_env, filter_public_env } from '../../utils/env.js'; +import { resolve_route } from '../../utils/routing.js'; + +export default forked(import.meta.url, analyse); + +/** + * @param {{ + * manifest_path: string; + * env: Record + * }} opts + */ +async function analyse({ manifest_path, env }) { + /** @type {import('@sveltejs/kit').SSRManifest} */ + const manifest = (await import(pathToFileURL(manifest_path).href)).manifest; + + /** @type {import('types').ValidatedKitConfig} */ + const config = (await load_config()).kit; + + const server_root = join(config.outDir, 'output'); + + /** @type {import('types').ServerInternalModule} */ + const internal = await import(pathToFileURL(`${server_root}/server/internal.js`).href); + + installPolyfills(); + + // configure `import { building } from '$app/environment'` — + // essential we do this before analysing the code + internal.set_building(); + + // set env, in case it's used in initialisation + const { publicPrefix: public_prefix, privatePrefix: private_prefix } = config.env; + const private_env = filter_private_env(env, { public_prefix, private_prefix }); + const public_env = filter_public_env(env, { public_prefix, private_prefix }); + internal.set_private_env(private_env); + internal.set_public_env(public_env); + internal.set_safe_public_env(public_env); + + /** @type {import('types').ServerMetadata} */ + const metadata = { + nodes: [], + routes: new Map() + }; + + const nodes = await Promise.all(manifest._.nodes.map((loader) => loader())); + + // analyse nodes + for (const node of nodes) { + metadata.nodes[node.index] = { + has_server_load: node.server?.load !== undefined || node.server?.trailingSlash !== undefined + }; + } + + // analyse routes + for (const route of manifest._.routes) { + const page = + route.page && + analyse_page( + route.page.layouts.map((n) => (n === undefined ? n : nodes[n])), + nodes[route.page.leaf] + ); + + const endpoint = route.endpoint && analyse_endpoint(route, await route.endpoint()); + + if (page?.prerender && endpoint?.prerender) { + throw new Error(`Cannot prerender a route with both +page and +server files (${route.id})`); + } + + if (page?.config && endpoint?.config) { + for (const key in { ...page.config, ...endpoint.config }) { + if (JSON.stringify(page.config[key]) !== JSON.stringify(endpoint.config[key])) { + throw new Error( + `Mismatched route config for ${route.id} — the +page and +server files must export the same config, if any` + ); + } + } + } + + const page_methods = page?.methods ?? []; + const api_methods = endpoint?.methods ?? []; + const entries = page?.entries ?? endpoint?.entries; + + metadata.routes.set(route.id, { + config: page?.config ?? endpoint?.config, + methods: Array.from(new Set([...page_methods, ...api_methods])), + page: { + methods: page_methods + }, + api: { + methods: api_methods + }, + prerender: page?.prerender ?? endpoint?.prerender, + entries: + entries && (await entries()).map((entry_object) => resolve_route(route.id, entry_object)) + }); + } + + return metadata; +} + +/** + * @param {import('types').SSRRoute} route + * @param {import('types').SSREndpoint} mod + */ +function analyse_endpoint(route, mod) { + validate_server_exports(mod, route.id); + + if (mod.prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) { + throw new Error( + `Cannot prerender a +server file with POST, PATCH, PUT, or DELETE (${route.id})` + ); + } + + /** @type {Array} */ + const methods = []; + + for (const method of /** @type {import('types').HttpMethod[]} */ (ENDPOINT_METHODS)) { + if (mod[method]) methods.push(method); + } + + if (mod.fallback) { + methods.push('*'); + } + + return { + config: mod.config, + entries: mod.entries, + methods, + prerender: mod.prerender ?? false + }; +} + +/** + * @param {Array} layouts + * @param {import('types').SSRNode} leaf + */ +function analyse_page(layouts, leaf) { + for (const layout of layouts) { + if (layout) { + validate_layout_server_exports(layout.server, layout.server_id); + validate_layout_exports(layout.universal, layout.universal_id); + } + } + + /** @type {Array<'GET' | 'POST'>} */ + const methods = ['GET']; + if (leaf.server?.actions) methods.push('POST'); + + validate_page_server_exports(leaf.server, leaf.server_id); + validate_page_exports(leaf.universal, leaf.universal_id); + + return { + config: get_config([...layouts, leaf]), + entries: leaf.universal?.entries ?? leaf.server?.entries, + methods, + prerender: get_option([...layouts, leaf], 'prerender') ?? false + }; +} + +/** + * Do a shallow merge (first level) of the config object + * @param {Array} nodes + */ +function get_config(nodes) { + /** @type {any} */ + let current = {}; + + for (const node of nodes) { + if (!node?.universal?.config && !node?.server?.config) continue; + + current = { + ...current, + ...node?.universal?.config, + ...node?.server?.config + }; + } + + return Object.keys(current).length ? current : undefined; +} diff --git a/node_modules/@sveltejs/kit/src/core/postbuild/crawl.js b/node_modules/@sveltejs/kit/src/core/postbuild/crawl.js new file mode 100644 index 000000000..caffef583 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/postbuild/crawl.js @@ -0,0 +1,243 @@ +import { resolve } from '../../utils/url.js'; +import { decode } from './entities.js'; + +const DOCTYPE = 'DOCTYPE'; +const CDATA_OPEN = '[CDATA['; +const CDATA_CLOSE = ']]>'; +const COMMENT_OPEN = '--'; +const COMMENT_CLOSE = '-->'; + +const TAG_OPEN = /[a-zA-Z]/; +const TAG_CHAR = /[a-zA-Z0-9]/; +const ATTRIBUTE_NAME = /[^\t\n\f />"'=]/; + +const WHITESPACE = /[\s\n\r]/; + +const CRAWLABLE_META_NAME_ATTRS = new Set([ + 'og:url', + 'og:image', + 'og:image:url', + 'og:image:secure_url', + 'og:video', + 'og:video:url', + 'og:video:secure_url', + 'og:audio', + 'og:audio:url', + 'og:audio:secure_url', + 'twitter:image' +]); + +/** + * @param {string} html + * @param {string} base + */ +export function crawl(html, base) { + /** @type {string[]} */ + const ids = []; + + /** @type {string[]} */ + const hrefs = []; + + let i = 0; + main: while (i < html.length) { + const char = html[i]; + + if (char === '<') { + if (html[i + 1] === '!') { + i += 2; + + if (html.slice(i, i + DOCTYPE.length).toUpperCase() === DOCTYPE) { + i += DOCTYPE.length; + while (i < html.length) { + if (html[i++] === '>') { + continue main; + } + } + } + + // skip cdata + if (html.slice(i, i + CDATA_OPEN.length) === CDATA_OPEN) { + i += CDATA_OPEN.length; + while (i < html.length) { + if (html.slice(i, i + CDATA_CLOSE.length) === CDATA_CLOSE) { + i += CDATA_CLOSE.length; + continue main; + } + + i += 1; + } + } + + // skip comments + if (html.slice(i, i + COMMENT_OPEN.length) === COMMENT_OPEN) { + i += COMMENT_OPEN.length; + while (i < html.length) { + if (html.slice(i, i + COMMENT_CLOSE.length) === COMMENT_CLOSE) { + i += COMMENT_CLOSE.length; + continue main; + } + + i += 1; + } + } + } + + // parse opening tags + const start = ++i; + if (TAG_OPEN.test(html[start])) { + while (i < html.length) { + if (!TAG_CHAR.test(html[i])) { + break; + } + + i += 1; + } + + const tag = html.slice(start, i).toUpperCase(); + + /** @type {Record} */ + const attributes = {}; + + if (tag === 'SCRIPT' || tag === 'STYLE') { + while (i < html.length) { + if ( + html[i] === '<' && + html[i + 1] === '/' && + html.slice(i + 2, i + 2 + tag.length).toUpperCase() === tag + ) { + continue main; + } + + i += 1; + } + } + + while (i < html.length) { + const start = i; + + const char = html[start]; + if (char === '>') break; + + if (ATTRIBUTE_NAME.test(char)) { + i += 1; + + while (i < html.length) { + if (!ATTRIBUTE_NAME.test(html[i])) { + break; + } + + i += 1; + } + + const name = html.slice(start, i).toLowerCase(); + + while (WHITESPACE.test(html[i])) i += 1; + + if (html[i] === '=') { + i += 1; + while (WHITESPACE.test(html[i])) i += 1; + + let value; + + if (html[i] === "'" || html[i] === '"') { + const quote = html[i++]; + + const start = i; + let escaped = false; + + while (i < html.length) { + if (escaped) { + escaped = false; + } else { + const char = html[i]; + + if (html[i] === quote) { + break; + } + + if (char === '\\') { + escaped = true; + } + } + + i += 1; + } + + value = html.slice(start, i); + } else { + const start = i; + while (html[i] !== '>' && !WHITESPACE.test(html[i])) i += 1; + value = html.slice(start, i); + + i -= 1; + } + + value = decode(value); + attributes[name] = value; + } else { + i -= 1; + } + } + + i += 1; + } + + const { href, id, name, property, rel, src, srcset, content } = attributes; + + if (href) { + if (tag === 'BASE') { + base = resolve(base, href); + } else if (!rel || !/\bexternal\b/i.test(rel)) { + hrefs.push(resolve(base, href)); + } + } + + if (id) { + ids.push(id); + } + + if (name && tag === 'A') { + ids.push(name); + } + + if (src) { + hrefs.push(resolve(base, src)); + } + + if (srcset) { + let value = srcset; + const candidates = []; + let insideURL = true; + value = value.trim(); + for (let i = 0; i < value.length; i++) { + if (value[i] === ',' && (!insideURL || (insideURL && WHITESPACE.test(value[i + 1])))) { + candidates.push(value.slice(0, i)); + value = value.substring(i + 1).trim(); + i = 0; + insideURL = true; + } else if (WHITESPACE.test(value[i])) { + insideURL = false; + } + } + candidates.push(value); + for (const candidate of candidates) { + const src = candidate.split(WHITESPACE)[0]; + if (src) hrefs.push(resolve(base, src)); + } + } + + if (tag === 'META' && content) { + const attr = name ?? property; + + if (attr && CRAWLABLE_META_NAME_ATTRS.has(attr)) { + hrefs.push(resolve(base, content)); + } + } + } + } + + i += 1; + } + + return { ids, hrefs }; +} diff --git a/node_modules/@sveltejs/kit/src/core/postbuild/entities.js b/node_modules/@sveltejs/kit/src/core/postbuild/entities.js new file mode 100644 index 000000000..91888a95b --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/postbuild/entities.js @@ -0,0 +1,2252 @@ +/** + * A list of all named HTML entities, from https://html.spec.whatwg.org/multipage/named-characters.html + * @type {Record} + */ +const entities = { + AElig: 'Æ', + 'AElig;': 'Æ', + AMP: '&', + 'AMP;': '&', + Aacute: 'Á', + 'Aacute;': 'Á', + 'Abreve;': 'Ă', + Acirc: 'Â', + 'Acirc;': 'Â', + 'Acy;': 'А', + 'Afr;': '𝔄', + Agrave: 'À', + 'Agrave;': 'À', + 'Alpha;': 'Α', + 'Amacr;': 'Ā', + 'And;': '⩓', + 'Aogon;': 'Ą', + 'Aopf;': '𝔸', + 'ApplyFunction;': '⁡', + Aring: 'Å', + 'Aring;': 'Å', + 'Ascr;': '𝒜', + 'Assign;': '≔', + Atilde: 'Ã', + 'Atilde;': 'Ã', + Auml: 'Ä', + 'Auml;': 'Ä', + 'Backslash;': '∖', + 'Barv;': '⫧', + 'Barwed;': '⌆', + 'Bcy;': 'Б', + 'Because;': '∵', + 'Bernoullis;': 'ℬ', + 'Beta;': 'Β', + 'Bfr;': '𝔅', + 'Bopf;': '𝔹', + 'Breve;': '˘', + 'Bscr;': 'ℬ', + 'Bumpeq;': '≎', + 'CHcy;': 'Ч', + COPY: '©', + 'COPY;': '©', + 'Cacute;': 'Ć', + 'Cap;': '⋒', + 'CapitalDifferentialD;': 'ⅅ', + 'Cayleys;': 'ℭ', + 'Ccaron;': 'Č', + Ccedil: 'Ç', + 'Ccedil;': 'Ç', + 'Ccirc;': 'Ĉ', + 'Cconint;': '∰', + 'Cdot;': 'Ċ', + 'Cedilla;': '¸', + 'CenterDot;': '·', + 'Cfr;': 'ℭ', + 'Chi;': 'Χ', + 'CircleDot;': '⊙', + 'CircleMinus;': '⊖', + 'CirclePlus;': '⊕', + 'CircleTimes;': '⊗', + 'ClockwiseContourIntegral;': '∲', + 'CloseCurlyDoubleQuote;': '”', + 'CloseCurlyQuote;': '’', + 'Colon;': '∷', + 'Colone;': '⩴', + 'Congruent;': '≡', + 'Conint;': '∯', + 'ContourIntegral;': '∮', + 'Copf;': 'ℂ', + 'Coproduct;': '∐', + 'CounterClockwiseContourIntegral;': '∳', + 'Cross;': '⨯', + 'Cscr;': '𝒞', + 'Cup;': '⋓', + 'CupCap;': '≍', + 'DD;': 'ⅅ', + 'DDotrahd;': '⤑', + 'DJcy;': 'Ђ', + 'DScy;': 'Ѕ', + 'DZcy;': 'Џ', + 'Dagger;': '‡', + 'Darr;': '↡', + 'Dashv;': '⫤', + 'Dcaron;': 'Ď', + 'Dcy;': 'Д', + 'Del;': '∇', + 'Delta;': 'Δ', + 'Dfr;': '𝔇', + 'DiacriticalAcute;': '´', + 'DiacriticalDot;': '˙', + 'DiacriticalDoubleAcute;': '˝', + 'DiacriticalGrave;': '`', + 'DiacriticalTilde;': '˜', + 'Diamond;': '⋄', + 'DifferentialD;': 'ⅆ', + 'Dopf;': '𝔻', + 'Dot;': '¨', + 'DotDot;': '⃜', + 'DotEqual;': '≐', + 'DoubleContourIntegral;': '∯', + 'DoubleDot;': '¨', + 'DoubleDownArrow;': '⇓', + 'DoubleLeftArrow;': '⇐', + 'DoubleLeftRightArrow;': '⇔', + 'DoubleLeftTee;': '⫤', + 'DoubleLongLeftArrow;': '⟸', + 'DoubleLongLeftRightArrow;': '⟺', + 'DoubleLongRightArrow;': '⟹', + 'DoubleRightArrow;': '⇒', + 'DoubleRightTee;': '⊨', + 'DoubleUpArrow;': '⇑', + 'DoubleUpDownArrow;': '⇕', + 'DoubleVerticalBar;': '∥', + 'DownArrow;': '↓', + 'DownArrowBar;': '⤓', + 'DownArrowUpArrow;': '⇵', + 'DownBreve;': '̑', + 'DownLeftRightVector;': '⥐', + 'DownLeftTeeVector;': '⥞', + 'DownLeftVector;': '↽', + 'DownLeftVectorBar;': '⥖', + 'DownRightTeeVector;': '⥟', + 'DownRightVector;': '⇁', + 'DownRightVectorBar;': '⥗', + 'DownTee;': '⊤', + 'DownTeeArrow;': '↧', + 'Downarrow;': '⇓', + 'Dscr;': '𝒟', + 'Dstrok;': 'Đ', + 'ENG;': 'Ŋ', + ETH: 'Ð', + 'ETH;': 'Ð', + Eacute: 'É', + 'Eacute;': 'É', + 'Ecaron;': 'Ě', + Ecirc: 'Ê', + 'Ecirc;': 'Ê', + 'Ecy;': 'Э', + 'Edot;': 'Ė', + 'Efr;': '𝔈', + Egrave: 'È', + 'Egrave;': 'È', + 'Element;': '∈', + 'Emacr;': 'Ē', + 'EmptySmallSquare;': '◻', + 'EmptyVerySmallSquare;': '▫', + 'Eogon;': 'Ę', + 'Eopf;': '𝔼', + 'Epsilon;': 'Ε', + 'Equal;': '⩵', + 'EqualTilde;': '≂', + 'Equilibrium;': '⇌', + 'Escr;': 'ℰ', + 'Esim;': '⩳', + 'Eta;': 'Η', + Euml: 'Ë', + 'Euml;': 'Ë', + 'Exists;': '∃', + 'ExponentialE;': 'ⅇ', + 'Fcy;': 'Ф', + 'Ffr;': '𝔉', + 'FilledSmallSquare;': '◼', + 'FilledVerySmallSquare;': '▪', + 'Fopf;': '𝔽', + 'ForAll;': '∀', + 'Fouriertrf;': 'ℱ', + 'Fscr;': 'ℱ', + 'GJcy;': 'Ѓ', + GT: '>', + 'GT;': '>', + 'Gamma;': 'Γ', + 'Gammad;': 'Ϝ', + 'Gbreve;': 'Ğ', + 'Gcedil;': 'Ģ', + 'Gcirc;': 'Ĝ', + 'Gcy;': 'Г', + 'Gdot;': 'Ġ', + 'Gfr;': '𝔊', + 'Gg;': '⋙', + 'Gopf;': '𝔾', + 'GreaterEqual;': '≥', + 'GreaterEqualLess;': '⋛', + 'GreaterFullEqual;': '≧', + 'GreaterGreater;': '⪢', + 'GreaterLess;': '≷', + 'GreaterSlantEqual;': '⩾', + 'GreaterTilde;': '≳', + 'Gscr;': '𝒢', + 'Gt;': '≫', + 'HARDcy;': 'Ъ', + 'Hacek;': 'ˇ', + 'Hat;': '^', + 'Hcirc;': 'Ĥ', + 'Hfr;': 'ℌ', + 'HilbertSpace;': 'ℋ', + 'Hopf;': 'ℍ', + 'HorizontalLine;': '─', + 'Hscr;': 'ℋ', + 'Hstrok;': 'Ħ', + 'HumpDownHump;': '≎', + 'HumpEqual;': '≏', + 'IEcy;': 'Е', + 'IJlig;': 'IJ', + 'IOcy;': 'Ё', + Iacute: 'Í', + 'Iacute;': 'Í', + Icirc: 'Î', + 'Icirc;': 'Î', + 'Icy;': 'И', + 'Idot;': 'İ', + 'Ifr;': 'ℑ', + Igrave: 'Ì', + 'Igrave;': 'Ì', + 'Im;': 'ℑ', + 'Imacr;': 'Ī', + 'ImaginaryI;': 'ⅈ', + 'Implies;': '⇒', + 'Int;': '∬', + 'Integral;': '∫', + 'Intersection;': '⋂', + 'InvisibleComma;': '⁣', + 'InvisibleTimes;': '⁢', + 'Iogon;': 'Į', + 'Iopf;': '𝕀', + 'Iota;': 'Ι', + 'Iscr;': 'ℐ', + 'Itilde;': 'Ĩ', + 'Iukcy;': 'І', + Iuml: 'Ï', + 'Iuml;': 'Ï', + 'Jcirc;': 'Ĵ', + 'Jcy;': 'Й', + 'Jfr;': '𝔍', + 'Jopf;': '𝕁', + 'Jscr;': '𝒥', + 'Jsercy;': 'Ј', + 'Jukcy;': 'Є', + 'KHcy;': 'Х', + 'KJcy;': 'Ќ', + 'Kappa;': 'Κ', + 'Kcedil;': 'Ķ', + 'Kcy;': 'К', + 'Kfr;': '𝔎', + 'Kopf;': '𝕂', + 'Kscr;': '𝒦', + 'LJcy;': 'Љ', + LT: '<', + 'LT;': '<', + 'Lacute;': 'Ĺ', + 'Lambda;': 'Λ', + 'Lang;': '⟪', + 'Laplacetrf;': 'ℒ', + 'Larr;': '↞', + 'Lcaron;': 'Ľ', + 'Lcedil;': 'Ļ', + 'Lcy;': 'Л', + 'LeftAngleBracket;': '⟨', + 'LeftArrow;': '←', + 'LeftArrowBar;': '⇤', + 'LeftArrowRightArrow;': '⇆', + 'LeftCeiling;': '⌈', + 'LeftDoubleBracket;': '⟦', + 'LeftDownTeeVector;': '⥡', + 'LeftDownVector;': '⇃', + 'LeftDownVectorBar;': '⥙', + 'LeftFloor;': '⌊', + 'LeftRightArrow;': '↔', + 'LeftRightVector;': '⥎', + 'LeftTee;': '⊣', + 'LeftTeeArrow;': '↤', + 'LeftTeeVector;': '⥚', + 'LeftTriangle;': '⊲', + 'LeftTriangleBar;': '⧏', + 'LeftTriangleEqual;': '⊴', + 'LeftUpDownVector;': '⥑', + 'LeftUpTeeVector;': '⥠', + 'LeftUpVector;': '↿', + 'LeftUpVectorBar;': '⥘', + 'LeftVector;': '↼', + 'LeftVectorBar;': '⥒', + 'Leftarrow;': '⇐', + 'Leftrightarrow;': '⇔', + 'LessEqualGreater;': '⋚', + 'LessFullEqual;': '≦', + 'LessGreater;': '≶', + 'LessLess;': '⪡', + 'LessSlantEqual;': '⩽', + 'LessTilde;': '≲', + 'Lfr;': '𝔏', + 'Ll;': '⋘', + 'Lleftarrow;': '⇚', + 'Lmidot;': 'Ŀ', + 'LongLeftArrow;': '⟵', + 'LongLeftRightArrow;': '⟷', + 'LongRightArrow;': '⟶', + 'Longleftarrow;': '⟸', + 'Longleftrightarrow;': '⟺', + 'Longrightarrow;': '⟹', + 'Lopf;': '𝕃', + 'LowerLeftArrow;': '↙', + 'LowerRightArrow;': '↘', + 'Lscr;': 'ℒ', + 'Lsh;': '↰', + 'Lstrok;': 'Ł', + 'Lt;': '≪', + 'Map;': '⤅', + 'Mcy;': 'М', + 'MediumSpace;': ' ', + 'Mellintrf;': 'ℳ', + 'Mfr;': '𝔐', + 'MinusPlus;': '∓', + 'Mopf;': '𝕄', + 'Mscr;': 'ℳ', + 'Mu;': 'Μ', + 'NJcy;': 'Њ', + 'Nacute;': 'Ń', + 'Ncaron;': 'Ň', + 'Ncedil;': 'Ņ', + 'Ncy;': 'Н', + 'NegativeMediumSpace;': '​', + 'NegativeThickSpace;': '​', + 'NegativeThinSpace;': '​', + 'NegativeVeryThinSpace;': '​', + 'NestedGreaterGreater;': '≫', + 'NestedLessLess;': '≪', + 'NewLine;': '\n', + 'Nfr;': '𝔑', + 'NoBreak;': '⁠', + 'NonBreakingSpace;': ' ', + 'Nopf;': 'ℕ', + 'Not;': '⫬', + 'NotCongruent;': '≢', + 'NotCupCap;': '≭', + 'NotDoubleVerticalBar;': '∦', + 'NotElement;': '∉', + 'NotEqual;': '≠', + 'NotEqualTilde;': '≂̸', + 'NotExists;': '∄', + 'NotGreater;': '≯', + 'NotGreaterEqual;': '≱', + 'NotGreaterFullEqual;': '≧̸', + 'NotGreaterGreater;': '≫̸', + 'NotGreaterLess;': '≹', + 'NotGreaterSlantEqual;': '⩾̸', + 'NotGreaterTilde;': '≵', + 'NotHumpDownHump;': '≎̸', + 'NotHumpEqual;': '≏̸', + 'NotLeftTriangle;': '⋪', + 'NotLeftTriangleBar;': '⧏̸', + 'NotLeftTriangleEqual;': '⋬', + 'NotLess;': '≮', + 'NotLessEqual;': '≰', + 'NotLessGreater;': '≸', + 'NotLessLess;': '≪̸', + 'NotLessSlantEqual;': '⩽̸', + 'NotLessTilde;': '≴', + 'NotNestedGreaterGreater;': '⪢̸', + 'NotNestedLessLess;': '⪡̸', + 'NotPrecedes;': '⊀', + 'NotPrecedesEqual;': '⪯̸', + 'NotPrecedesSlantEqual;': '⋠', + 'NotReverseElement;': '∌', + 'NotRightTriangle;': '⋫', + 'NotRightTriangleBar;': '⧐̸', + 'NotRightTriangleEqual;': '⋭', + 'NotSquareSubset;': '⊏̸', + 'NotSquareSubsetEqual;': '⋢', + 'NotSquareSuperset;': '⊐̸', + 'NotSquareSupersetEqual;': '⋣', + 'NotSubset;': '⊂⃒', + 'NotSubsetEqual;': '⊈', + 'NotSucceeds;': '⊁', + 'NotSucceedsEqual;': '⪰̸', + 'NotSucceedsSlantEqual;': '⋡', + 'NotSucceedsTilde;': '≿̸', + 'NotSuperset;': '⊃⃒', + 'NotSupersetEqual;': '⊉', + 'NotTilde;': '≁', + 'NotTildeEqual;': '≄', + 'NotTildeFullEqual;': '≇', + 'NotTildeTilde;': '≉', + 'NotVerticalBar;': '∤', + 'Nscr;': '𝒩', + Ntilde: 'Ñ', + 'Ntilde;': 'Ñ', + 'Nu;': 'Ν', + 'OElig;': 'Œ', + Oacute: 'Ó', + 'Oacute;': 'Ó', + Ocirc: 'Ô', + 'Ocirc;': 'Ô', + 'Ocy;': 'О', + 'Odblac;': 'Ő', + 'Ofr;': '𝔒', + Ograve: 'Ò', + 'Ograve;': 'Ò', + 'Omacr;': 'Ō', + 'Omega;': 'Ω', + 'Omicron;': 'Ο', + 'Oopf;': '𝕆', + 'OpenCurlyDoubleQuote;': '“', + 'OpenCurlyQuote;': '‘', + 'Or;': '⩔', + 'Oscr;': '𝒪', + Oslash: 'Ø', + 'Oslash;': 'Ø', + Otilde: 'Õ', + 'Otilde;': 'Õ', + 'Otimes;': '⨷', + Ouml: 'Ö', + 'Ouml;': 'Ö', + 'OverBar;': '‾', + 'OverBrace;': '⏞', + 'OverBracket;': '⎴', + 'OverParenthesis;': '⏜', + 'PartialD;': '∂', + 'Pcy;': 'П', + 'Pfr;': '𝔓', + 'Phi;': 'Φ', + 'Pi;': 'Π', + 'PlusMinus;': '±', + 'Poincareplane;': 'ℌ', + 'Popf;': 'ℙ', + 'Pr;': '⪻', + 'Precedes;': '≺', + 'PrecedesEqual;': '⪯', + 'PrecedesSlantEqual;': '≼', + 'PrecedesTilde;': '≾', + 'Prime;': '″', + 'Product;': '∏', + 'Proportion;': '∷', + 'Proportional;': '∝', + 'Pscr;': '𝒫', + 'Psi;': 'Ψ', + QUOT: '"', + 'QUOT;': '"', + 'Qfr;': '𝔔', + 'Qopf;': 'ℚ', + 'Qscr;': '𝒬', + 'RBarr;': '⤐', + REG: '®', + 'REG;': '®', + 'Racute;': 'Ŕ', + 'Rang;': '⟫', + 'Rarr;': '↠', + 'Rarrtl;': '⤖', + 'Rcaron;': 'Ř', + 'Rcedil;': 'Ŗ', + 'Rcy;': 'Р', + 'Re;': 'ℜ', + 'ReverseElement;': '∋', + 'ReverseEquilibrium;': '⇋', + 'ReverseUpEquilibrium;': '⥯', + 'Rfr;': 'ℜ', + 'Rho;': 'Ρ', + 'RightAngleBracket;': '⟩', + 'RightArrow;': '→', + 'RightArrowBar;': '⇥', + 'RightArrowLeftArrow;': '⇄', + 'RightCeiling;': '⌉', + 'RightDoubleBracket;': '⟧', + 'RightDownTeeVector;': '⥝', + 'RightDownVector;': '⇂', + 'RightDownVectorBar;': '⥕', + 'RightFloor;': '⌋', + 'RightTee;': '⊢', + 'RightTeeArrow;': '↦', + 'RightTeeVector;': '⥛', + 'RightTriangle;': '⊳', + 'RightTriangleBar;': '⧐', + 'RightTriangleEqual;': '⊵', + 'RightUpDownVector;': '⥏', + 'RightUpTeeVector;': '⥜', + 'RightUpVector;': '↾', + 'RightUpVectorBar;': '⥔', + 'RightVector;': '⇀', + 'RightVectorBar;': '⥓', + 'Rightarrow;': '⇒', + 'Ropf;': 'ℝ', + 'RoundImplies;': '⥰', + 'Rrightarrow;': '⇛', + 'Rscr;': 'ℛ', + 'Rsh;': '↱', + 'RuleDelayed;': '⧴', + 'SHCHcy;': 'Щ', + 'SHcy;': 'Ш', + 'SOFTcy;': 'Ь', + 'Sacute;': 'Ś', + 'Sc;': '⪼', + 'Scaron;': 'Š', + 'Scedil;': 'Ş', + 'Scirc;': 'Ŝ', + 'Scy;': 'С', + 'Sfr;': '𝔖', + 'ShortDownArrow;': '↓', + 'ShortLeftArrow;': '←', + 'ShortRightArrow;': '→', + 'ShortUpArrow;': '↑', + 'Sigma;': 'Σ', + 'SmallCircle;': '∘', + 'Sopf;': '𝕊', + 'Sqrt;': '√', + 'Square;': '□', + 'SquareIntersection;': '⊓', + 'SquareSubset;': '⊏', + 'SquareSubsetEqual;': '⊑', + 'SquareSuperset;': '⊐', + 'SquareSupersetEqual;': '⊒', + 'SquareUnion;': '⊔', + 'Sscr;': '𝒮', + 'Star;': '⋆', + 'Sub;': '⋐', + 'Subset;': '⋐', + 'SubsetEqual;': '⊆', + 'Succeeds;': '≻', + 'SucceedsEqual;': '⪰', + 'SucceedsSlantEqual;': '≽', + 'SucceedsTilde;': '≿', + 'SuchThat;': '∋', + 'Sum;': '∑', + 'Sup;': '⋑', + 'Superset;': '⊃', + 'SupersetEqual;': '⊇', + 'Supset;': '⋑', + THORN: 'Þ', + 'THORN;': 'Þ', + 'TRADE;': '™', + 'TSHcy;': 'Ћ', + 'TScy;': 'Ц', + 'Tab;': '\t', + 'Tau;': 'Τ', + 'Tcaron;': 'Ť', + 'Tcedil;': 'Ţ', + 'Tcy;': 'Т', + 'Tfr;': '𝔗', + 'Therefore;': '∴', + 'Theta;': 'Θ', + 'ThickSpace;': '  ', + 'ThinSpace;': ' ', + 'Tilde;': '∼', + 'TildeEqual;': '≃', + 'TildeFullEqual;': '≅', + 'TildeTilde;': '≈', + 'Topf;': '𝕋', + 'TripleDot;': '⃛', + 'Tscr;': '𝒯', + 'Tstrok;': 'Ŧ', + Uacute: 'Ú', + 'Uacute;': 'Ú', + 'Uarr;': '↟', + 'Uarrocir;': '⥉', + 'Ubrcy;': 'Ў', + 'Ubreve;': 'Ŭ', + Ucirc: 'Û', + 'Ucirc;': 'Û', + 'Ucy;': 'У', + 'Udblac;': 'Ű', + 'Ufr;': '𝔘', + Ugrave: 'Ù', + 'Ugrave;': 'Ù', + 'Umacr;': 'Ū', + 'UnderBar;': '_', + 'UnderBrace;': '⏟', + 'UnderBracket;': '⎵', + 'UnderParenthesis;': '⏝', + 'Union;': '⋃', + 'UnionPlus;': '⊎', + 'Uogon;': 'Ų', + 'Uopf;': '𝕌', + 'UpArrow;': '↑', + 'UpArrowBar;': '⤒', + 'UpArrowDownArrow;': '⇅', + 'UpDownArrow;': '↕', + 'UpEquilibrium;': '⥮', + 'UpTee;': '⊥', + 'UpTeeArrow;': '↥', + 'Uparrow;': '⇑', + 'Updownarrow;': '⇕', + 'UpperLeftArrow;': '↖', + 'UpperRightArrow;': '↗', + 'Upsi;': 'ϒ', + 'Upsilon;': 'Υ', + 'Uring;': 'Ů', + 'Uscr;': '𝒰', + 'Utilde;': 'Ũ', + Uuml: 'Ü', + 'Uuml;': 'Ü', + 'VDash;': '⊫', + 'Vbar;': '⫫', + 'Vcy;': 'В', + 'Vdash;': '⊩', + 'Vdashl;': '⫦', + 'Vee;': '⋁', + 'Verbar;': '‖', + 'Vert;': '‖', + 'VerticalBar;': '∣', + 'VerticalLine;': '|', + 'VerticalSeparator;': '❘', + 'VerticalTilde;': '≀', + 'VeryThinSpace;': ' ', + 'Vfr;': '𝔙', + 'Vopf;': '𝕍', + 'Vscr;': '𝒱', + 'Vvdash;': '⊪', + 'Wcirc;': 'Ŵ', + 'Wedge;': '⋀', + 'Wfr;': '𝔚', + 'Wopf;': '𝕎', + 'Wscr;': '𝒲', + 'Xfr;': '𝔛', + 'Xi;': 'Ξ', + 'Xopf;': '𝕏', + 'Xscr;': '𝒳', + 'YAcy;': 'Я', + 'YIcy;': 'Ї', + 'YUcy;': 'Ю', + Yacute: 'Ý', + 'Yacute;': 'Ý', + 'Ycirc;': 'Ŷ', + 'Ycy;': 'Ы', + 'Yfr;': '𝔜', + 'Yopf;': '𝕐', + 'Yscr;': '𝒴', + 'Yuml;': 'Ÿ', + 'ZHcy;': 'Ж', + 'Zacute;': 'Ź', + 'Zcaron;': 'Ž', + 'Zcy;': 'З', + 'Zdot;': 'Ż', + 'ZeroWidthSpace;': '​', + 'Zeta;': 'Ζ', + 'Zfr;': 'ℨ', + 'Zopf;': 'ℤ', + 'Zscr;': '𝒵', + aacute: 'á', + 'aacute;': 'á', + 'abreve;': 'ă', + 'ac;': '∾', + 'acE;': '∾̳', + 'acd;': '∿', + acirc: 'â', + 'acirc;': 'â', + acute: '´', + 'acute;': '´', + 'acy;': 'а', + aelig: 'æ', + 'aelig;': 'æ', + 'af;': '⁡', + 'afr;': '𝔞', + agrave: 'à', + 'agrave;': 'à', + 'alefsym;': 'ℵ', + 'aleph;': 'ℵ', + 'alpha;': 'α', + 'amacr;': 'ā', + 'amalg;': '⨿', + amp: '&', + 'amp;': '&', + 'and;': '∧', + 'andand;': '⩕', + 'andd;': '⩜', + 'andslope;': '⩘', + 'andv;': '⩚', + 'ang;': '∠', + 'ange;': '⦤', + 'angle;': '∠', + 'angmsd;': '∡', + 'angmsdaa;': '⦨', + 'angmsdab;': '⦩', + 'angmsdac;': '⦪', + 'angmsdad;': '⦫', + 'angmsdae;': '⦬', + 'angmsdaf;': '⦭', + 'angmsdag;': '⦮', + 'angmsdah;': '⦯', + 'angrt;': '∟', + 'angrtvb;': '⊾', + 'angrtvbd;': '⦝', + 'angsph;': '∢', + 'angst;': 'Å', + 'angzarr;': '⍼', + 'aogon;': 'ą', + 'aopf;': '𝕒', + 'ap;': '≈', + 'apE;': '⩰', + 'apacir;': '⩯', + 'ape;': '≊', + 'apid;': '≋', + 'apos;': "'", + 'approx;': '≈', + 'approxeq;': '≊', + aring: 'å', + 'aring;': 'å', + 'ascr;': '𝒶', + 'ast;': '*', + 'asymp;': '≈', + 'asympeq;': '≍', + atilde: 'ã', + 'atilde;': 'ã', + auml: 'ä', + 'auml;': 'ä', + 'awconint;': '∳', + 'awint;': '⨑', + 'bNot;': '⫭', + 'backcong;': '≌', + 'backepsilon;': '϶', + 'backprime;': '‵', + 'backsim;': '∽', + 'backsimeq;': '⋍', + 'barvee;': '⊽', + 'barwed;': '⌅', + 'barwedge;': '⌅', + 'bbrk;': '⎵', + 'bbrktbrk;': '⎶', + 'bcong;': '≌', + 'bcy;': 'б', + 'bdquo;': '„', + 'becaus;': '∵', + 'because;': '∵', + 'bemptyv;': '⦰', + 'bepsi;': '϶', + 'bernou;': 'ℬ', + 'beta;': 'β', + 'beth;': 'ℶ', + 'between;': '≬', + 'bfr;': '𝔟', + 'bigcap;': '⋂', + 'bigcirc;': '◯', + 'bigcup;': '⋃', + 'bigodot;': '⨀', + 'bigoplus;': '⨁', + 'bigotimes;': '⨂', + 'bigsqcup;': '⨆', + 'bigstar;': '★', + 'bigtriangledown;': '▽', + 'bigtriangleup;': '△', + 'biguplus;': '⨄', + 'bigvee;': '⋁', + 'bigwedge;': '⋀', + 'bkarow;': '⤍', + 'blacklozenge;': '⧫', + 'blacksquare;': '▪', + 'blacktriangle;': '▴', + 'blacktriangledown;': '▾', + 'blacktriangleleft;': '◂', + 'blacktriangleright;': '▸', + 'blank;': '␣', + 'blk12;': '▒', + 'blk14;': '░', + 'blk34;': '▓', + 'block;': '█', + 'bne;': '=⃥', + 'bnequiv;': '≡⃥', + 'bnot;': '⌐', + 'bopf;': '𝕓', + 'bot;': '⊥', + 'bottom;': '⊥', + 'bowtie;': '⋈', + 'boxDL;': '╗', + 'boxDR;': '╔', + 'boxDl;': '╖', + 'boxDr;': '╓', + 'boxH;': '═', + 'boxHD;': '╦', + 'boxHU;': '╩', + 'boxHd;': '╤', + 'boxHu;': '╧', + 'boxUL;': '╝', + 'boxUR;': '╚', + 'boxUl;': '╜', + 'boxUr;': '╙', + 'boxV;': '║', + 'boxVH;': '╬', + 'boxVL;': '╣', + 'boxVR;': '╠', + 'boxVh;': '╫', + 'boxVl;': '╢', + 'boxVr;': '╟', + 'boxbox;': '⧉', + 'boxdL;': '╕', + 'boxdR;': '╒', + 'boxdl;': '┐', + 'boxdr;': '┌', + 'boxh;': '─', + 'boxhD;': '╥', + 'boxhU;': '╨', + 'boxhd;': '┬', + 'boxhu;': '┴', + 'boxminus;': '⊟', + 'boxplus;': '⊞', + 'boxtimes;': '⊠', + 'boxuL;': '╛', + 'boxuR;': '╘', + 'boxul;': '┘', + 'boxur;': '└', + 'boxv;': '│', + 'boxvH;': '╪', + 'boxvL;': '╡', + 'boxvR;': '╞', + 'boxvh;': '┼', + 'boxvl;': '┤', + 'boxvr;': '├', + 'bprime;': '‵', + 'breve;': '˘', + brvbar: '¦', + 'brvbar;': '¦', + 'bscr;': '𝒷', + 'bsemi;': '⁏', + 'bsim;': '∽', + 'bsime;': '⋍', + 'bsol;': '\\', + 'bsolb;': '⧅', + 'bsolhsub;': '⟈', + 'bull;': '•', + 'bullet;': '•', + 'bump;': '≎', + 'bumpE;': '⪮', + 'bumpe;': '≏', + 'bumpeq;': '≏', + 'cacute;': 'ć', + 'cap;': '∩', + 'capand;': '⩄', + 'capbrcup;': '⩉', + 'capcap;': '⩋', + 'capcup;': '⩇', + 'capdot;': '⩀', + 'caps;': '∩︀', + 'caret;': '⁁', + 'caron;': 'ˇ', + 'ccaps;': '⩍', + 'ccaron;': 'č', + ccedil: 'ç', + 'ccedil;': 'ç', + 'ccirc;': 'ĉ', + 'ccups;': '⩌', + 'ccupssm;': '⩐', + 'cdot;': 'ċ', + cedil: '¸', + 'cedil;': '¸', + 'cemptyv;': '⦲', + cent: '¢', + 'cent;': '¢', + 'centerdot;': '·', + 'cfr;': '𝔠', + 'chcy;': 'ч', + 'check;': '✓', + 'checkmark;': '✓', + 'chi;': 'χ', + 'cir;': '○', + 'cirE;': '⧃', + 'circ;': 'ˆ', + 'circeq;': '≗', + 'circlearrowleft;': '↺', + 'circlearrowright;': '↻', + 'circledR;': '®', + 'circledS;': 'Ⓢ', + 'circledast;': '⊛', + 'circledcirc;': '⊚', + 'circleddash;': '⊝', + 'cire;': '≗', + 'cirfnint;': '⨐', + 'cirmid;': '⫯', + 'cirscir;': '⧂', + 'clubs;': '♣', + 'clubsuit;': '♣', + 'colon;': ':', + 'colone;': '≔', + 'coloneq;': '≔', + 'comma;': ',', + 'commat;': '@', + 'comp;': '∁', + 'compfn;': '∘', + 'complement;': '∁', + 'complexes;': 'ℂ', + 'cong;': '≅', + 'congdot;': '⩭', + 'conint;': '∮', + 'copf;': '𝕔', + 'coprod;': '∐', + copy: '©', + 'copy;': '©', + 'copysr;': '℗', + 'crarr;': '↵', + 'cross;': '✗', + 'cscr;': '𝒸', + 'csub;': '⫏', + 'csube;': '⫑', + 'csup;': '⫐', + 'csupe;': '⫒', + 'ctdot;': '⋯', + 'cudarrl;': '⤸', + 'cudarrr;': '⤵', + 'cuepr;': '⋞', + 'cuesc;': '⋟', + 'cularr;': '↶', + 'cularrp;': '⤽', + 'cup;': '∪', + 'cupbrcap;': '⩈', + 'cupcap;': '⩆', + 'cupcup;': '⩊', + 'cupdot;': '⊍', + 'cupor;': '⩅', + 'cups;': '∪︀', + 'curarr;': '↷', + 'curarrm;': '⤼', + 'curlyeqprec;': '⋞', + 'curlyeqsucc;': '⋟', + 'curlyvee;': '⋎', + 'curlywedge;': '⋏', + curren: '¤', + 'curren;': '¤', + 'curvearrowleft;': '↶', + 'curvearrowright;': '↷', + 'cuvee;': '⋎', + 'cuwed;': '⋏', + 'cwconint;': '∲', + 'cwint;': '∱', + 'cylcty;': '⌭', + 'dArr;': '⇓', + 'dHar;': '⥥', + 'dagger;': '†', + 'daleth;': 'ℸ', + 'darr;': '↓', + 'dash;': '‐', + 'dashv;': '⊣', + 'dbkarow;': '⤏', + 'dblac;': '˝', + 'dcaron;': 'ď', + 'dcy;': 'д', + 'dd;': 'ⅆ', + 'ddagger;': '‡', + 'ddarr;': '⇊', + 'ddotseq;': '⩷', + deg: '°', + 'deg;': '°', + 'delta;': 'δ', + 'demptyv;': '⦱', + 'dfisht;': '⥿', + 'dfr;': '𝔡', + 'dharl;': '⇃', + 'dharr;': '⇂', + 'diam;': '⋄', + 'diamond;': '⋄', + 'diamondsuit;': '♦', + 'diams;': '♦', + 'die;': '¨', + 'digamma;': 'ϝ', + 'disin;': '⋲', + 'div;': '÷', + divide: '÷', + 'divide;': '÷', + 'divideontimes;': '⋇', + 'divonx;': '⋇', + 'djcy;': 'ђ', + 'dlcorn;': '⌞', + 'dlcrop;': '⌍', + 'dollar;': '$', + 'dopf;': '𝕕', + 'dot;': '˙', + 'doteq;': '≐', + 'doteqdot;': '≑', + 'dotminus;': '∸', + 'dotplus;': '∔', + 'dotsquare;': '⊡', + 'doublebarwedge;': '⌆', + 'downarrow;': '↓', + 'downdownarrows;': '⇊', + 'downharpoonleft;': '⇃', + 'downharpoonright;': '⇂', + 'drbkarow;': '⤐', + 'drcorn;': '⌟', + 'drcrop;': '⌌', + 'dscr;': '𝒹', + 'dscy;': 'ѕ', + 'dsol;': '⧶', + 'dstrok;': 'đ', + 'dtdot;': '⋱', + 'dtri;': '▿', + 'dtrif;': '▾', + 'duarr;': '⇵', + 'duhar;': '⥯', + 'dwangle;': '⦦', + 'dzcy;': 'џ', + 'dzigrarr;': '⟿', + 'eDDot;': '⩷', + 'eDot;': '≑', + eacute: 'é', + 'eacute;': 'é', + 'easter;': '⩮', + 'ecaron;': 'ě', + 'ecir;': '≖', + ecirc: 'ê', + 'ecirc;': 'ê', + 'ecolon;': '≕', + 'ecy;': 'э', + 'edot;': 'ė', + 'ee;': 'ⅇ', + 'efDot;': '≒', + 'efr;': '𝔢', + 'eg;': '⪚', + egrave: 'è', + 'egrave;': 'è', + 'egs;': '⪖', + 'egsdot;': '⪘', + 'el;': '⪙', + 'elinters;': '⏧', + 'ell;': 'ℓ', + 'els;': '⪕', + 'elsdot;': '⪗', + 'emacr;': 'ē', + 'empty;': '∅', + 'emptyset;': '∅', + 'emptyv;': '∅', + 'emsp13;': ' ', + 'emsp14;': ' ', + 'emsp;': ' ', + 'eng;': 'ŋ', + 'ensp;': ' ', + 'eogon;': 'ę', + 'eopf;': '𝕖', + 'epar;': '⋕', + 'eparsl;': '⧣', + 'eplus;': '⩱', + 'epsi;': 'ε', + 'epsilon;': 'ε', + 'epsiv;': 'ϵ', + 'eqcirc;': '≖', + 'eqcolon;': '≕', + 'eqsim;': '≂', + 'eqslantgtr;': '⪖', + 'eqslantless;': '⪕', + 'equals;': '=', + 'equest;': '≟', + 'equiv;': '≡', + 'equivDD;': '⩸', + 'eqvparsl;': '⧥', + 'erDot;': '≓', + 'erarr;': '⥱', + 'escr;': 'ℯ', + 'esdot;': '≐', + 'esim;': '≂', + 'eta;': 'η', + eth: 'ð', + 'eth;': 'ð', + euml: 'ë', + 'euml;': 'ë', + 'euro;': '€', + 'excl;': '!', + 'exist;': '∃', + 'expectation;': 'ℰ', + 'exponentiale;': 'ⅇ', + 'fallingdotseq;': '≒', + 'fcy;': 'ф', + 'female;': '♀', + 'ffilig;': 'ffi', + 'fflig;': 'ff', + 'ffllig;': 'ffl', + 'ffr;': '𝔣', + 'filig;': 'fi', + 'fjlig;': 'fj', + 'flat;': '♭', + 'fllig;': 'fl', + 'fltns;': '▱', + 'fnof;': 'ƒ', + 'fopf;': '𝕗', + 'forall;': '∀', + 'fork;': '⋔', + 'forkv;': '⫙', + 'fpartint;': '⨍', + frac12: '½', + 'frac12;': '½', + 'frac13;': '⅓', + frac14: '¼', + 'frac14;': '¼', + 'frac15;': '⅕', + 'frac16;': '⅙', + 'frac18;': '⅛', + 'frac23;': '⅔', + 'frac25;': '⅖', + frac34: '¾', + 'frac34;': '¾', + 'frac35;': '⅗', + 'frac38;': '⅜', + 'frac45;': '⅘', + 'frac56;': '⅚', + 'frac58;': '⅝', + 'frac78;': '⅞', + 'frasl;': '⁄', + 'frown;': '⌢', + 'fscr;': '𝒻', + 'gE;': '≧', + 'gEl;': '⪌', + 'gacute;': 'ǵ', + 'gamma;': 'γ', + 'gammad;': 'ϝ', + 'gap;': '⪆', + 'gbreve;': 'ğ', + 'gcirc;': 'ĝ', + 'gcy;': 'г', + 'gdot;': 'ġ', + 'ge;': '≥', + 'gel;': '⋛', + 'geq;': '≥', + 'geqq;': '≧', + 'geqslant;': '⩾', + 'ges;': '⩾', + 'gescc;': '⪩', + 'gesdot;': '⪀', + 'gesdoto;': '⪂', + 'gesdotol;': '⪄', + 'gesl;': '⋛︀', + 'gesles;': '⪔', + 'gfr;': '𝔤', + 'gg;': '≫', + 'ggg;': '⋙', + 'gimel;': 'ℷ', + 'gjcy;': 'ѓ', + 'gl;': '≷', + 'glE;': '⪒', + 'gla;': '⪥', + 'glj;': '⪤', + 'gnE;': '≩', + 'gnap;': '⪊', + 'gnapprox;': '⪊', + 'gne;': '⪈', + 'gneq;': '⪈', + 'gneqq;': '≩', + 'gnsim;': '⋧', + 'gopf;': '𝕘', + 'grave;': '`', + 'gscr;': 'ℊ', + 'gsim;': '≳', + 'gsime;': '⪎', + 'gsiml;': '⪐', + gt: '>', + 'gt;': '>', + 'gtcc;': '⪧', + 'gtcir;': '⩺', + 'gtdot;': '⋗', + 'gtlPar;': '⦕', + 'gtquest;': '⩼', + 'gtrapprox;': '⪆', + 'gtrarr;': '⥸', + 'gtrdot;': '⋗', + 'gtreqless;': '⋛', + 'gtreqqless;': '⪌', + 'gtrless;': '≷', + 'gtrsim;': '≳', + 'gvertneqq;': '≩︀', + 'gvnE;': '≩︀', + 'hArr;': '⇔', + 'hairsp;': ' ', + 'half;': '½', + 'hamilt;': 'ℋ', + 'hardcy;': 'ъ', + 'harr;': '↔', + 'harrcir;': '⥈', + 'harrw;': '↭', + 'hbar;': 'ℏ', + 'hcirc;': 'ĥ', + 'hearts;': '♥', + 'heartsuit;': '♥', + 'hellip;': '…', + 'hercon;': '⊹', + 'hfr;': '𝔥', + 'hksearow;': '⤥', + 'hkswarow;': '⤦', + 'hoarr;': '⇿', + 'homtht;': '∻', + 'hookleftarrow;': '↩', + 'hookrightarrow;': '↪', + 'hopf;': '𝕙', + 'horbar;': '―', + 'hscr;': '𝒽', + 'hslash;': 'ℏ', + 'hstrok;': 'ħ', + 'hybull;': '⁃', + 'hyphen;': '‐', + iacute: 'í', + 'iacute;': 'í', + 'ic;': '⁣', + icirc: 'î', + 'icirc;': 'î', + 'icy;': 'и', + 'iecy;': 'е', + iexcl: '¡', + 'iexcl;': '¡', + 'iff;': '⇔', + 'ifr;': '𝔦', + igrave: 'ì', + 'igrave;': 'ì', + 'ii;': 'ⅈ', + 'iiiint;': '⨌', + 'iiint;': '∭', + 'iinfin;': '⧜', + 'iiota;': '℩', + 'ijlig;': 'ij', + 'imacr;': 'ī', + 'image;': 'ℑ', + 'imagline;': 'ℐ', + 'imagpart;': 'ℑ', + 'imath;': 'ı', + 'imof;': '⊷', + 'imped;': 'Ƶ', + 'in;': '∈', + 'incare;': '℅', + 'infin;': '∞', + 'infintie;': '⧝', + 'inodot;': 'ı', + 'int;': '∫', + 'intcal;': '⊺', + 'integers;': 'ℤ', + 'intercal;': '⊺', + 'intlarhk;': '⨗', + 'intprod;': '⨼', + 'iocy;': 'ё', + 'iogon;': 'į', + 'iopf;': '𝕚', + 'iota;': 'ι', + 'iprod;': '⨼', + iquest: '¿', + 'iquest;': '¿', + 'iscr;': '𝒾', + 'isin;': '∈', + 'isinE;': '⋹', + 'isindot;': '⋵', + 'isins;': '⋴', + 'isinsv;': '⋳', + 'isinv;': '∈', + 'it;': '⁢', + 'itilde;': 'ĩ', + 'iukcy;': 'і', + iuml: 'ï', + 'iuml;': 'ï', + 'jcirc;': 'ĵ', + 'jcy;': 'й', + 'jfr;': '𝔧', + 'jmath;': 'ȷ', + 'jopf;': '𝕛', + 'jscr;': '𝒿', + 'jsercy;': 'ј', + 'jukcy;': 'є', + 'kappa;': 'κ', + 'kappav;': 'ϰ', + 'kcedil;': 'ķ', + 'kcy;': 'к', + 'kfr;': '𝔨', + 'kgreen;': 'ĸ', + 'khcy;': 'х', + 'kjcy;': 'ќ', + 'kopf;': '𝕜', + 'kscr;': '𝓀', + 'lAarr;': '⇚', + 'lArr;': '⇐', + 'lAtail;': '⤛', + 'lBarr;': '⤎', + 'lE;': '≦', + 'lEg;': '⪋', + 'lHar;': '⥢', + 'lacute;': 'ĺ', + 'laemptyv;': '⦴', + 'lagran;': 'ℒ', + 'lambda;': 'λ', + 'lang;': '⟨', + 'langd;': '⦑', + 'langle;': '⟨', + 'lap;': '⪅', + laquo: '«', + 'laquo;': '«', + 'larr;': '←', + 'larrb;': '⇤', + 'larrbfs;': '⤟', + 'larrfs;': '⤝', + 'larrhk;': '↩', + 'larrlp;': '↫', + 'larrpl;': '⤹', + 'larrsim;': '⥳', + 'larrtl;': '↢', + 'lat;': '⪫', + 'latail;': '⤙', + 'late;': '⪭', + 'lates;': '⪭︀', + 'lbarr;': '⤌', + 'lbbrk;': '❲', + 'lbrace;': '{', + 'lbrack;': '[', + 'lbrke;': '⦋', + 'lbrksld;': '⦏', + 'lbrkslu;': '⦍', + 'lcaron;': 'ľ', + 'lcedil;': 'ļ', + 'lceil;': '⌈', + 'lcub;': '{', + 'lcy;': 'л', + 'ldca;': '⤶', + 'ldquo;': '“', + 'ldquor;': '„', + 'ldrdhar;': '⥧', + 'ldrushar;': '⥋', + 'ldsh;': '↲', + 'le;': '≤', + 'leftarrow;': '←', + 'leftarrowtail;': '↢', + 'leftharpoondown;': '↽', + 'leftharpoonup;': '↼', + 'leftleftarrows;': '⇇', + 'leftrightarrow;': '↔', + 'leftrightarrows;': '⇆', + 'leftrightharpoons;': '⇋', + 'leftrightsquigarrow;': '↭', + 'leftthreetimes;': '⋋', + 'leg;': '⋚', + 'leq;': '≤', + 'leqq;': '≦', + 'leqslant;': '⩽', + 'les;': '⩽', + 'lescc;': '⪨', + 'lesdot;': '⩿', + 'lesdoto;': '⪁', + 'lesdotor;': '⪃', + 'lesg;': '⋚︀', + 'lesges;': '⪓', + 'lessapprox;': '⪅', + 'lessdot;': '⋖', + 'lesseqgtr;': '⋚', + 'lesseqqgtr;': '⪋', + 'lessgtr;': '≶', + 'lesssim;': '≲', + 'lfisht;': '⥼', + 'lfloor;': '⌊', + 'lfr;': '𝔩', + 'lg;': '≶', + 'lgE;': '⪑', + 'lhard;': '↽', + 'lharu;': '↼', + 'lharul;': '⥪', + 'lhblk;': '▄', + 'ljcy;': 'љ', + 'll;': '≪', + 'llarr;': '⇇', + 'llcorner;': '⌞', + 'llhard;': '⥫', + 'lltri;': '◺', + 'lmidot;': 'ŀ', + 'lmoust;': '⎰', + 'lmoustache;': '⎰', + 'lnE;': '≨', + 'lnap;': '⪉', + 'lnapprox;': '⪉', + 'lne;': '⪇', + 'lneq;': '⪇', + 'lneqq;': '≨', + 'lnsim;': '⋦', + 'loang;': '⟬', + 'loarr;': '⇽', + 'lobrk;': '⟦', + 'longleftarrow;': '⟵', + 'longleftrightarrow;': '⟷', + 'longmapsto;': '⟼', + 'longrightarrow;': '⟶', + 'looparrowleft;': '↫', + 'looparrowright;': '↬', + 'lopar;': '⦅', + 'lopf;': '𝕝', + 'loplus;': '⨭', + 'lotimes;': '⨴', + 'lowast;': '∗', + 'lowbar;': '_', + 'loz;': '◊', + 'lozenge;': '◊', + 'lozf;': '⧫', + 'lpar;': '(', + 'lparlt;': '⦓', + 'lrarr;': '⇆', + 'lrcorner;': '⌟', + 'lrhar;': '⇋', + 'lrhard;': '⥭', + 'lrm;': '‎', + 'lrtri;': '⊿', + 'lsaquo;': '‹', + 'lscr;': '𝓁', + 'lsh;': '↰', + 'lsim;': '≲', + 'lsime;': '⪍', + 'lsimg;': '⪏', + 'lsqb;': '[', + 'lsquo;': '‘', + 'lsquor;': '‚', + 'lstrok;': 'ł', + lt: '<', + 'lt;': '<', + 'ltcc;': '⪦', + 'ltcir;': '⩹', + 'ltdot;': '⋖', + 'lthree;': '⋋', + 'ltimes;': '⋉', + 'ltlarr;': '⥶', + 'ltquest;': '⩻', + 'ltrPar;': '⦖', + 'ltri;': '◃', + 'ltrie;': '⊴', + 'ltrif;': '◂', + 'lurdshar;': '⥊', + 'luruhar;': '⥦', + 'lvertneqq;': '≨︀', + 'lvnE;': '≨︀', + 'mDDot;': '∺', + macr: '¯', + 'macr;': '¯', + 'male;': '♂', + 'malt;': '✠', + 'maltese;': '✠', + 'map;': '↦', + 'mapsto;': '↦', + 'mapstodown;': '↧', + 'mapstoleft;': '↤', + 'mapstoup;': '↥', + 'marker;': '▮', + 'mcomma;': '⨩', + 'mcy;': 'м', + 'mdash;': '—', + 'measuredangle;': '∡', + 'mfr;': '𝔪', + 'mho;': '℧', + micro: 'µ', + 'micro;': 'µ', + 'mid;': '∣', + 'midast;': '*', + 'midcir;': '⫰', + middot: '·', + 'middot;': '·', + 'minus;': '−', + 'minusb;': '⊟', + 'minusd;': '∸', + 'minusdu;': '⨪', + 'mlcp;': '⫛', + 'mldr;': '…', + 'mnplus;': '∓', + 'models;': '⊧', + 'mopf;': '𝕞', + 'mp;': '∓', + 'mscr;': '𝓂', + 'mstpos;': '∾', + 'mu;': 'μ', + 'multimap;': '⊸', + 'mumap;': '⊸', + 'nGg;': '⋙̸', + 'nGt;': '≫⃒', + 'nGtv;': '≫̸', + 'nLeftarrow;': '⇍', + 'nLeftrightarrow;': '⇎', + 'nLl;': '⋘̸', + 'nLt;': '≪⃒', + 'nLtv;': '≪̸', + 'nRightarrow;': '⇏', + 'nVDash;': '⊯', + 'nVdash;': '⊮', + 'nabla;': '∇', + 'nacute;': 'ń', + 'nang;': '∠⃒', + 'nap;': '≉', + 'napE;': '⩰̸', + 'napid;': '≋̸', + 'napos;': 'ʼn', + 'napprox;': '≉', + 'natur;': '♮', + 'natural;': '♮', + 'naturals;': 'ℕ', + nbsp: ' ', + 'nbsp;': ' ', + 'nbump;': '≎̸', + 'nbumpe;': '≏̸', + 'ncap;': '⩃', + 'ncaron;': 'ň', + 'ncedil;': 'ņ', + 'ncong;': '≇', + 'ncongdot;': '⩭̸', + 'ncup;': '⩂', + 'ncy;': 'н', + 'ndash;': '–', + 'ne;': '≠', + 'neArr;': '⇗', + 'nearhk;': '⤤', + 'nearr;': '↗', + 'nearrow;': '↗', + 'nedot;': '≐̸', + 'nequiv;': '≢', + 'nesear;': '⤨', + 'nesim;': '≂̸', + 'nexist;': '∄', + 'nexists;': '∄', + 'nfr;': '𝔫', + 'ngE;': '≧̸', + 'nge;': '≱', + 'ngeq;': '≱', + 'ngeqq;': '≧̸', + 'ngeqslant;': '⩾̸', + 'nges;': '⩾̸', + 'ngsim;': '≵', + 'ngt;': '≯', + 'ngtr;': '≯', + 'nhArr;': '⇎', + 'nharr;': '↮', + 'nhpar;': '⫲', + 'ni;': '∋', + 'nis;': '⋼', + 'nisd;': '⋺', + 'niv;': '∋', + 'njcy;': 'њ', + 'nlArr;': '⇍', + 'nlE;': '≦̸', + 'nlarr;': '↚', + 'nldr;': '‥', + 'nle;': '≰', + 'nleftarrow;': '↚', + 'nleftrightarrow;': '↮', + 'nleq;': '≰', + 'nleqq;': '≦̸', + 'nleqslant;': '⩽̸', + 'nles;': '⩽̸', + 'nless;': '≮', + 'nlsim;': '≴', + 'nlt;': '≮', + 'nltri;': '⋪', + 'nltrie;': '⋬', + 'nmid;': '∤', + 'nopf;': '𝕟', + not: '¬', + 'not;': '¬', + 'notin;': '∉', + 'notinE;': '⋹̸', + 'notindot;': '⋵̸', + 'notinva;': '∉', + 'notinvb;': '⋷', + 'notinvc;': '⋶', + 'notni;': '∌', + 'notniva;': '∌', + 'notnivb;': '⋾', + 'notnivc;': '⋽', + 'npar;': '∦', + 'nparallel;': '∦', + 'nparsl;': '⫽⃥', + 'npart;': '∂̸', + 'npolint;': '⨔', + 'npr;': '⊀', + 'nprcue;': '⋠', + 'npre;': '⪯̸', + 'nprec;': '⊀', + 'npreceq;': '⪯̸', + 'nrArr;': '⇏', + 'nrarr;': '↛', + 'nrarrc;': '⤳̸', + 'nrarrw;': '↝̸', + 'nrightarrow;': '↛', + 'nrtri;': '⋫', + 'nrtrie;': '⋭', + 'nsc;': '⊁', + 'nsccue;': '⋡', + 'nsce;': '⪰̸', + 'nscr;': '𝓃', + 'nshortmid;': '∤', + 'nshortparallel;': '∦', + 'nsim;': '≁', + 'nsime;': '≄', + 'nsimeq;': '≄', + 'nsmid;': '∤', + 'nspar;': '∦', + 'nsqsube;': '⋢', + 'nsqsupe;': '⋣', + 'nsub;': '⊄', + 'nsubE;': '⫅̸', + 'nsube;': '⊈', + 'nsubset;': '⊂⃒', + 'nsubseteq;': '⊈', + 'nsubseteqq;': '⫅̸', + 'nsucc;': '⊁', + 'nsucceq;': '⪰̸', + 'nsup;': '⊅', + 'nsupE;': '⫆̸', + 'nsupe;': '⊉', + 'nsupset;': '⊃⃒', + 'nsupseteq;': '⊉', + 'nsupseteqq;': '⫆̸', + 'ntgl;': '≹', + ntilde: 'ñ', + 'ntilde;': 'ñ', + 'ntlg;': '≸', + 'ntriangleleft;': '⋪', + 'ntrianglelefteq;': '⋬', + 'ntriangleright;': '⋫', + 'ntrianglerighteq;': '⋭', + 'nu;': 'ν', + 'num;': '#', + 'numero;': '№', + 'numsp;': ' ', + 'nvDash;': '⊭', + 'nvHarr;': '⤄', + 'nvap;': '≍⃒', + 'nvdash;': '⊬', + 'nvge;': '≥⃒', + 'nvgt;': '>⃒', + 'nvinfin;': '⧞', + 'nvlArr;': '⤂', + 'nvle;': '≤⃒', + 'nvlt;': '<⃒', + 'nvltrie;': '⊴⃒', + 'nvrArr;': '⤃', + 'nvrtrie;': '⊵⃒', + 'nvsim;': '∼⃒', + 'nwArr;': '⇖', + 'nwarhk;': '⤣', + 'nwarr;': '↖', + 'nwarrow;': '↖', + 'nwnear;': '⤧', + 'oS;': 'Ⓢ', + oacute: 'ó', + 'oacute;': 'ó', + 'oast;': '⊛', + 'ocir;': '⊚', + ocirc: 'ô', + 'ocirc;': 'ô', + 'ocy;': 'о', + 'odash;': '⊝', + 'odblac;': 'ő', + 'odiv;': '⨸', + 'odot;': '⊙', + 'odsold;': '⦼', + 'oelig;': 'œ', + 'ofcir;': '⦿', + 'ofr;': '𝔬', + 'ogon;': '˛', + ograve: 'ò', + 'ograve;': 'ò', + 'ogt;': '⧁', + 'ohbar;': '⦵', + 'ohm;': 'Ω', + 'oint;': '∮', + 'olarr;': '↺', + 'olcir;': '⦾', + 'olcross;': '⦻', + 'oline;': '‾', + 'olt;': '⧀', + 'omacr;': 'ō', + 'omega;': 'ω', + 'omicron;': 'ο', + 'omid;': '⦶', + 'ominus;': '⊖', + 'oopf;': '𝕠', + 'opar;': '⦷', + 'operp;': '⦹', + 'oplus;': '⊕', + 'or;': '∨', + 'orarr;': '↻', + 'ord;': '⩝', + 'order;': 'ℴ', + 'orderof;': 'ℴ', + ordf: 'ª', + 'ordf;': 'ª', + ordm: 'º', + 'ordm;': 'º', + 'origof;': '⊶', + 'oror;': '⩖', + 'orslope;': '⩗', + 'orv;': '⩛', + 'oscr;': 'ℴ', + oslash: 'ø', + 'oslash;': 'ø', + 'osol;': '⊘', + otilde: 'õ', + 'otilde;': 'õ', + 'otimes;': '⊗', + 'otimesas;': '⨶', + ouml: 'ö', + 'ouml;': 'ö', + 'ovbar;': '⌽', + 'par;': '∥', + para: '¶', + 'para;': '¶', + 'parallel;': '∥', + 'parsim;': '⫳', + 'parsl;': '⫽', + 'part;': '∂', + 'pcy;': 'п', + 'percnt;': '%', + 'period;': '.', + 'permil;': '‰', + 'perp;': '⊥', + 'pertenk;': '‱', + 'pfr;': '𝔭', + 'phi;': 'φ', + 'phiv;': 'ϕ', + 'phmmat;': 'ℳ', + 'phone;': '☎', + 'pi;': 'π', + 'pitchfork;': '⋔', + 'piv;': 'ϖ', + 'planck;': 'ℏ', + 'planckh;': 'ℎ', + 'plankv;': 'ℏ', + 'plus;': '+', + 'plusacir;': '⨣', + 'plusb;': '⊞', + 'pluscir;': '⨢', + 'plusdo;': '∔', + 'plusdu;': '⨥', + 'pluse;': '⩲', + plusmn: '±', + 'plusmn;': '±', + 'plussim;': '⨦', + 'plustwo;': '⨧', + 'pm;': '±', + 'pointint;': '⨕', + 'popf;': '𝕡', + pound: '£', + 'pound;': '£', + 'pr;': '≺', + 'prE;': '⪳', + 'prap;': '⪷', + 'prcue;': '≼', + 'pre;': '⪯', + 'prec;': '≺', + 'precapprox;': '⪷', + 'preccurlyeq;': '≼', + 'preceq;': '⪯', + 'precnapprox;': '⪹', + 'precneqq;': '⪵', + 'precnsim;': '⋨', + 'precsim;': '≾', + 'prime;': '′', + 'primes;': 'ℙ', + 'prnE;': '⪵', + 'prnap;': '⪹', + 'prnsim;': '⋨', + 'prod;': '∏', + 'profalar;': '⌮', + 'profline;': '⌒', + 'profsurf;': '⌓', + 'prop;': '∝', + 'propto;': '∝', + 'prsim;': '≾', + 'prurel;': '⊰', + 'pscr;': '𝓅', + 'psi;': 'ψ', + 'puncsp;': ' ', + 'qfr;': '𝔮', + 'qint;': '⨌', + 'qopf;': '𝕢', + 'qprime;': '⁗', + 'qscr;': '𝓆', + 'quaternions;': 'ℍ', + 'quatint;': '⨖', + 'quest;': '?', + 'questeq;': '≟', + quot: '"', + 'quot;': '"', + 'rAarr;': '⇛', + 'rArr;': '⇒', + 'rAtail;': '⤜', + 'rBarr;': '⤏', + 'rHar;': '⥤', + 'race;': '∽̱', + 'racute;': 'ŕ', + 'radic;': '√', + 'raemptyv;': '⦳', + 'rang;': '⟩', + 'rangd;': '⦒', + 'range;': '⦥', + 'rangle;': '⟩', + raquo: '»', + 'raquo;': '»', + 'rarr;': '→', + 'rarrap;': '⥵', + 'rarrb;': '⇥', + 'rarrbfs;': '⤠', + 'rarrc;': '⤳', + 'rarrfs;': '⤞', + 'rarrhk;': '↪', + 'rarrlp;': '↬', + 'rarrpl;': '⥅', + 'rarrsim;': '⥴', + 'rarrtl;': '↣', + 'rarrw;': '↝', + 'ratail;': '⤚', + 'ratio;': '∶', + 'rationals;': 'ℚ', + 'rbarr;': '⤍', + 'rbbrk;': '❳', + 'rbrace;': '}', + 'rbrack;': ']', + 'rbrke;': '⦌', + 'rbrksld;': '⦎', + 'rbrkslu;': '⦐', + 'rcaron;': 'ř', + 'rcedil;': 'ŗ', + 'rceil;': '⌉', + 'rcub;': '}', + 'rcy;': 'р', + 'rdca;': '⤷', + 'rdldhar;': '⥩', + 'rdquo;': '”', + 'rdquor;': '”', + 'rdsh;': '↳', + 'real;': 'ℜ', + 'realine;': 'ℛ', + 'realpart;': 'ℜ', + 'reals;': 'ℝ', + 'rect;': '▭', + reg: '®', + 'reg;': '®', + 'rfisht;': '⥽', + 'rfloor;': '⌋', + 'rfr;': '𝔯', + 'rhard;': '⇁', + 'rharu;': '⇀', + 'rharul;': '⥬', + 'rho;': 'ρ', + 'rhov;': 'ϱ', + 'rightarrow;': '→', + 'rightarrowtail;': '↣', + 'rightharpoondown;': '⇁', + 'rightharpoonup;': '⇀', + 'rightleftarrows;': '⇄', + 'rightleftharpoons;': '⇌', + 'rightrightarrows;': '⇉', + 'rightsquigarrow;': '↝', + 'rightthreetimes;': '⋌', + 'ring;': '˚', + 'risingdotseq;': '≓', + 'rlarr;': '⇄', + 'rlhar;': '⇌', + 'rlm;': '‏', + 'rmoust;': '⎱', + 'rmoustache;': '⎱', + 'rnmid;': '⫮', + 'roang;': '⟭', + 'roarr;': '⇾', + 'robrk;': '⟧', + 'ropar;': '⦆', + 'ropf;': '𝕣', + 'roplus;': '⨮', + 'rotimes;': '⨵', + 'rpar;': ')', + 'rpargt;': '⦔', + 'rppolint;': '⨒', + 'rrarr;': '⇉', + 'rsaquo;': '›', + 'rscr;': '𝓇', + 'rsh;': '↱', + 'rsqb;': ']', + 'rsquo;': '’', + 'rsquor;': '’', + 'rthree;': '⋌', + 'rtimes;': '⋊', + 'rtri;': '▹', + 'rtrie;': '⊵', + 'rtrif;': '▸', + 'rtriltri;': '⧎', + 'ruluhar;': '⥨', + 'rx;': '℞', + 'sacute;': 'ś', + 'sbquo;': '‚', + 'sc;': '≻', + 'scE;': '⪴', + 'scap;': '⪸', + 'scaron;': 'š', + 'sccue;': '≽', + 'sce;': '⪰', + 'scedil;': 'ş', + 'scirc;': 'ŝ', + 'scnE;': '⪶', + 'scnap;': '⪺', + 'scnsim;': '⋩', + 'scpolint;': '⨓', + 'scsim;': '≿', + 'scy;': 'с', + 'sdot;': '⋅', + 'sdotb;': '⊡', + 'sdote;': '⩦', + 'seArr;': '⇘', + 'searhk;': '⤥', + 'searr;': '↘', + 'searrow;': '↘', + sect: '§', + 'sect;': '§', + 'semi;': ';', + 'seswar;': '⤩', + 'setminus;': '∖', + 'setmn;': '∖', + 'sext;': '✶', + 'sfr;': '𝔰', + 'sfrown;': '⌢', + 'sharp;': '♯', + 'shchcy;': 'щ', + 'shcy;': 'ш', + 'shortmid;': '∣', + 'shortparallel;': '∥', + shy: '­', + 'shy;': '­', + 'sigma;': 'σ', + 'sigmaf;': 'ς', + 'sigmav;': 'ς', + 'sim;': '∼', + 'simdot;': '⩪', + 'sime;': '≃', + 'simeq;': '≃', + 'simg;': '⪞', + 'simgE;': '⪠', + 'siml;': '⪝', + 'simlE;': '⪟', + 'simne;': '≆', + 'simplus;': '⨤', + 'simrarr;': '⥲', + 'slarr;': '←', + 'smallsetminus;': '∖', + 'smashp;': '⨳', + 'smeparsl;': '⧤', + 'smid;': '∣', + 'smile;': '⌣', + 'smt;': '⪪', + 'smte;': '⪬', + 'smtes;': '⪬︀', + 'softcy;': 'ь', + 'sol;': '/', + 'solb;': '⧄', + 'solbar;': '⌿', + 'sopf;': '𝕤', + 'spades;': '♠', + 'spadesuit;': '♠', + 'spar;': '∥', + 'sqcap;': '⊓', + 'sqcaps;': '⊓︀', + 'sqcup;': '⊔', + 'sqcups;': '⊔︀', + 'sqsub;': '⊏', + 'sqsube;': '⊑', + 'sqsubset;': '⊏', + 'sqsubseteq;': '⊑', + 'sqsup;': '⊐', + 'sqsupe;': '⊒', + 'sqsupset;': '⊐', + 'sqsupseteq;': '⊒', + 'squ;': '□', + 'square;': '□', + 'squarf;': '▪', + 'squf;': '▪', + 'srarr;': '→', + 'sscr;': '𝓈', + 'ssetmn;': '∖', + 'ssmile;': '⌣', + 'sstarf;': '⋆', + 'star;': '☆', + 'starf;': '★', + 'straightepsilon;': 'ϵ', + 'straightphi;': 'ϕ', + 'strns;': '¯', + 'sub;': '⊂', + 'subE;': '⫅', + 'subdot;': '⪽', + 'sube;': '⊆', + 'subedot;': '⫃', + 'submult;': '⫁', + 'subnE;': '⫋', + 'subne;': '⊊', + 'subplus;': '⪿', + 'subrarr;': '⥹', + 'subset;': '⊂', + 'subseteq;': '⊆', + 'subseteqq;': '⫅', + 'subsetneq;': '⊊', + 'subsetneqq;': '⫋', + 'subsim;': '⫇', + 'subsub;': '⫕', + 'subsup;': '⫓', + 'succ;': '≻', + 'succapprox;': '⪸', + 'succcurlyeq;': '≽', + 'succeq;': '⪰', + 'succnapprox;': '⪺', + 'succneqq;': '⪶', + 'succnsim;': '⋩', + 'succsim;': '≿', + 'sum;': '∑', + 'sung;': '♪', + sup1: '¹', + 'sup1;': '¹', + sup2: '²', + 'sup2;': '²', + sup3: '³', + 'sup3;': '³', + 'sup;': '⊃', + 'supE;': '⫆', + 'supdot;': '⪾', + 'supdsub;': '⫘', + 'supe;': '⊇', + 'supedot;': '⫄', + 'suphsol;': '⟉', + 'suphsub;': '⫗', + 'suplarr;': '⥻', + 'supmult;': '⫂', + 'supnE;': '⫌', + 'supne;': '⊋', + 'supplus;': '⫀', + 'supset;': '⊃', + 'supseteq;': '⊇', + 'supseteqq;': '⫆', + 'supsetneq;': '⊋', + 'supsetneqq;': '⫌', + 'supsim;': '⫈', + 'supsub;': '⫔', + 'supsup;': '⫖', + 'swArr;': '⇙', + 'swarhk;': '⤦', + 'swarr;': '↙', + 'swarrow;': '↙', + 'swnwar;': '⤪', + szlig: 'ß', + 'szlig;': 'ß', + 'target;': '⌖', + 'tau;': 'τ', + 'tbrk;': '⎴', + 'tcaron;': 'ť', + 'tcedil;': 'ţ', + 'tcy;': 'т', + 'tdot;': '⃛', + 'telrec;': '⌕', + 'tfr;': '𝔱', + 'there4;': '∴', + 'therefore;': '∴', + 'theta;': 'θ', + 'thetasym;': 'ϑ', + 'thetav;': 'ϑ', + 'thickapprox;': '≈', + 'thicksim;': '∼', + 'thinsp;': ' ', + 'thkap;': '≈', + 'thksim;': '∼', + thorn: 'þ', + 'thorn;': 'þ', + 'tilde;': '˜', + times: '×', + 'times;': '×', + 'timesb;': '⊠', + 'timesbar;': '⨱', + 'timesd;': '⨰', + 'tint;': '∭', + 'toea;': '⤨', + 'top;': '⊤', + 'topbot;': '⌶', + 'topcir;': '⫱', + 'topf;': '𝕥', + 'topfork;': '⫚', + 'tosa;': '⤩', + 'tprime;': '‴', + 'trade;': '™', + 'triangle;': '▵', + 'triangledown;': '▿', + 'triangleleft;': '◃', + 'trianglelefteq;': '⊴', + 'triangleq;': '≜', + 'triangleright;': '▹', + 'trianglerighteq;': '⊵', + 'tridot;': '◬', + 'trie;': '≜', + 'triminus;': '⨺', + 'triplus;': '⨹', + 'trisb;': '⧍', + 'tritime;': '⨻', + 'trpezium;': '⏢', + 'tscr;': '𝓉', + 'tscy;': 'ц', + 'tshcy;': 'ћ', + 'tstrok;': 'ŧ', + 'twixt;': '≬', + 'twoheadleftarrow;': '↞', + 'twoheadrightarrow;': '↠', + 'uArr;': '⇑', + 'uHar;': '⥣', + uacute: 'ú', + 'uacute;': 'ú', + 'uarr;': '↑', + 'ubrcy;': 'ў', + 'ubreve;': 'ŭ', + ucirc: 'û', + 'ucirc;': 'û', + 'ucy;': 'у', + 'udarr;': '⇅', + 'udblac;': 'ű', + 'udhar;': '⥮', + 'ufisht;': '⥾', + 'ufr;': '𝔲', + ugrave: 'ù', + 'ugrave;': 'ù', + 'uharl;': '↿', + 'uharr;': '↾', + 'uhblk;': '▀', + 'ulcorn;': '⌜', + 'ulcorner;': '⌜', + 'ulcrop;': '⌏', + 'ultri;': '◸', + 'umacr;': 'ū', + uml: '¨', + 'uml;': '¨', + 'uogon;': 'ų', + 'uopf;': '𝕦', + 'uparrow;': '↑', + 'updownarrow;': '↕', + 'upharpoonleft;': '↿', + 'upharpoonright;': '↾', + 'uplus;': '⊎', + 'upsi;': 'υ', + 'upsih;': 'ϒ', + 'upsilon;': 'υ', + 'upuparrows;': '⇈', + 'urcorn;': '⌝', + 'urcorner;': '⌝', + 'urcrop;': '⌎', + 'uring;': 'ů', + 'urtri;': '◹', + 'uscr;': '𝓊', + 'utdot;': '⋰', + 'utilde;': 'ũ', + 'utri;': '▵', + 'utrif;': '▴', + 'uuarr;': '⇈', + uuml: 'ü', + 'uuml;': 'ü', + 'uwangle;': '⦧', + 'vArr;': '⇕', + 'vBar;': '⫨', + 'vBarv;': '⫩', + 'vDash;': '⊨', + 'vangrt;': '⦜', + 'varepsilon;': 'ϵ', + 'varkappa;': 'ϰ', + 'varnothing;': '∅', + 'varphi;': 'ϕ', + 'varpi;': 'ϖ', + 'varpropto;': '∝', + 'varr;': '↕', + 'varrho;': 'ϱ', + 'varsigma;': 'ς', + 'varsubsetneq;': '⊊︀', + 'varsubsetneqq;': '⫋︀', + 'varsupsetneq;': '⊋︀', + 'varsupsetneqq;': '⫌︀', + 'vartheta;': 'ϑ', + 'vartriangleleft;': '⊲', + 'vartriangleright;': '⊳', + 'vcy;': 'в', + 'vdash;': '⊢', + 'vee;': '∨', + 'veebar;': '⊻', + 'veeeq;': '≚', + 'vellip;': '⋮', + 'verbar;': '|', + 'vert;': '|', + 'vfr;': '𝔳', + 'vltri;': '⊲', + 'vnsub;': '⊂⃒', + 'vnsup;': '⊃⃒', + 'vopf;': '𝕧', + 'vprop;': '∝', + 'vrtri;': '⊳', + 'vscr;': '𝓋', + 'vsubnE;': '⫋︀', + 'vsubne;': '⊊︀', + 'vsupnE;': '⫌︀', + 'vsupne;': '⊋︀', + 'vzigzag;': '⦚', + 'wcirc;': 'ŵ', + 'wedbar;': '⩟', + 'wedge;': '∧', + 'wedgeq;': '≙', + 'weierp;': '℘', + 'wfr;': '𝔴', + 'wopf;': '𝕨', + 'wp;': '℘', + 'wr;': '≀', + 'wreath;': '≀', + 'wscr;': '𝓌', + 'xcap;': '⋂', + 'xcirc;': '◯', + 'xcup;': '⋃', + 'xdtri;': '▽', + 'xfr;': '𝔵', + 'xhArr;': '⟺', + 'xharr;': '⟷', + 'xi;': 'ξ', + 'xlArr;': '⟸', + 'xlarr;': '⟵', + 'xmap;': '⟼', + 'xnis;': '⋻', + 'xodot;': '⨀', + 'xopf;': '𝕩', + 'xoplus;': '⨁', + 'xotime;': '⨂', + 'xrArr;': '⟹', + 'xrarr;': '⟶', + 'xscr;': '𝓍', + 'xsqcup;': '⨆', + 'xuplus;': '⨄', + 'xutri;': '△', + 'xvee;': '⋁', + 'xwedge;': '⋀', + yacute: 'ý', + 'yacute;': 'ý', + 'yacy;': 'я', + 'ycirc;': 'ŷ', + 'ycy;': 'ы', + yen: '¥', + 'yen;': '¥', + 'yfr;': '𝔶', + 'yicy;': 'ї', + 'yopf;': '𝕪', + 'yscr;': '𝓎', + 'yucy;': 'ю', + yuml: 'ÿ', + 'yuml;': 'ÿ', + 'zacute;': 'ź', + 'zcaron;': 'ž', + 'zcy;': 'з', + 'zdot;': 'ż', + 'zeetrf;': 'ℨ', + 'zeta;': 'ζ', + 'zfr;': '𝔷', + 'zhcy;': 'ж', + 'zigrarr;': '⇝', + 'zopf;': '𝕫', + 'zscr;': '𝓏', + 'zwj;': '‍', + 'zwnj;': '‌' +}; + +const numeric = /&#(x)?([0-9a-f]+);/i; +const named = new RegExp( + `&(${Object.keys(entities) + .sort((a, b) => b.length - a.length) + .join('|')})`, + 'g' +); + +/** @param {string} str */ +export function decode(str) { + return str + .replace(numeric, (_match, hex, code) => String.fromCharCode(hex ? parseInt(code, 16) : +code)) + .replace(named, (_match, entity) => entities[entity]); +} diff --git a/node_modules/@sveltejs/kit/src/core/postbuild/fallback.js b/node_modules/@sveltejs/kit/src/core/postbuild/fallback.js new file mode 100644 index 000000000..d77400a46 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/postbuild/fallback.js @@ -0,0 +1,54 @@ +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { installPolyfills } from '../../exports/node/polyfills.js'; +import { load_config } from '../config/index.js'; +import { forked } from '../../utils/fork.js'; + +export default forked(import.meta.url, generate_fallback); + +/** + * @param {{ + * manifest_path: string; + * env: Record + * }} opts + */ +async function generate_fallback({ manifest_path, env }) { + /** @type {import('types').ValidatedKitConfig} */ + const config = (await load_config()).kit; + + installPolyfills(); + + const server_root = join(config.outDir, 'output'); + + /** @type {import('types').ServerInternalModule} */ + const { set_building } = await import(pathToFileURL(`${server_root}/server/internal.js`).href); + + /** @type {import('types').ServerModule} */ + const { Server } = await import(pathToFileURL(`${server_root}/server/index.js`).href); + + /** @type {import('@sveltejs/kit').SSRManifest} */ + const manifest = (await import(pathToFileURL(manifest_path).href)).manifest; + + set_building(); + + const server = new Server(manifest); + await server.init({ env }); + + const response = await server.respond(new Request(config.prerender.origin + '/[fallback]'), { + getClientAddress: () => { + throw new Error('Cannot read clientAddress during prerendering'); + }, + prerendering: { + fallback: true, + dependencies: new Map() + }, + read: (file) => readFileSync(join(config.files.assets, file)) + }); + + if (response.ok) { + return await response.text(); + } + + throw new Error(`Could not create a fallback page — failed with status ${response.status}`); +} diff --git a/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js b/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js new file mode 100644 index 000000000..4cf3053fe --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js @@ -0,0 +1,494 @@ +import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs'; +import { dirname, join } from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { installPolyfills } from '../../exports/node/polyfills.js'; +import { mkdirp, posixify, walk } from '../../utils/filesystem.js'; +import { decode_uri, is_root_relative, resolve } from '../../utils/url.js'; +import { escape_html_attr } from '../../utils/escape.js'; +import { logger } from '../utils.js'; +import { load_config } from '../config/index.js'; +import { get_route_segments } from '../../utils/routing.js'; +import { queue } from './queue.js'; +import { crawl } from './crawl.js'; +import { forked } from '../../utils/fork.js'; +import * as devalue from 'devalue'; + +export default forked(import.meta.url, prerender); + +/** + * @param {{ + * out: string; + * manifest_path: string; + * metadata: import('types').ServerMetadata; + * verbose: boolean; + * env: Record + * }} opts + */ +async function prerender({ out, manifest_path, metadata, verbose, env }) { + /** @type {import('@sveltejs/kit').SSRManifest} */ + const manifest = (await import(pathToFileURL(manifest_path).href)).manifest; + + /** @type {import('types').ServerInternalModule} */ + const internal = await import(pathToFileURL(`${out}/server/internal.js`).href); + + /** @type {import('types').ServerModule} */ + const { Server } = await import(pathToFileURL(`${out}/server/index.js`).href); + + // configure `import { building } from '$app/environment'` — + // essential we do this before analysing the code + internal.set_building(); + internal.set_prerendering(); + + /** + * @template {{message: string}} T + * @template {Omit} K + * @param {import('types').Logger} log + * @param {'fail' | 'warn' | 'ignore' | ((details: T) => void)} input + * @param {(details: K) => string} format + * @returns {(details: K) => void} + */ + function normalise_error_handler(log, input, format) { + switch (input) { + case 'fail': + return (details) => { + throw new Error(format(details)); + }; + case 'warn': + return (details) => { + log.error(format(details)); + }; + case 'ignore': + return () => {}; + default: + // @ts-expect-error TS thinks T might be of a different kind, but it's not + return (details) => input({ ...details, message: format(details) }); + } + } + + const OK = 2; + const REDIRECT = 3; + + /** @type {import('types').Prerendered} */ + const prerendered = { + pages: new Map(), + assets: new Map(), + redirects: new Map(), + paths: [] + }; + + /** @type {import('types').PrerenderMap} */ + const prerender_map = new Map(); + + for (const [id, { prerender }] of metadata.routes) { + if (prerender !== undefined) { + prerender_map.set(id, prerender); + } + } + + /** @type {Set} */ + const prerendered_routes = new Set(); + + /** @type {import('types').ValidatedKitConfig} */ + const config = (await load_config()).kit; + + /** @type {import('types').Logger} */ + const log = logger({ verbose }); + + installPolyfills(); + + /** @type {Map} */ + const saved = new Map(); + + const handle_http_error = normalise_error_handler( + log, + config.prerender.handleHttpError, + ({ status, path, referrer, referenceType }) => { + const message = + status === 404 && !path.startsWith(config.paths.base) + ? `${path} does not begin with \`base\`, which is configured in \`paths.base\` and can be imported from \`$app/paths\` - see https://kit.svelte.dev/docs/configuration#paths for more info` + : path; + + return `${status} ${message}${referrer ? ` (${referenceType} from ${referrer})` : ''}`; + } + ); + + const handle_missing_id = normalise_error_handler( + log, + config.prerender.handleMissingId, + ({ path, id, referrers }) => { + return ( + `The following pages contain links to ${path}#${id}, but no element with id="${id}" exists on ${path} - see the \`handleMissingId\` option in https://kit.svelte.dev/docs/configuration#prerender for more info:` + + referrers.map((l) => `\n - ${l}`).join('') + ); + } + ); + + const handle_entry_generator_mismatch = normalise_error_handler( + log, + config.prerender.handleEntryGeneratorMismatch, + ({ generatedFromId, entry, matchedId }) => { + return `The entries export from ${generatedFromId} generated entry ${entry}, which was matched by ${matchedId} - see the \`handleEntryGeneratorMismatch\` option in https://kit.svelte.dev/docs/configuration#prerender for more info.`; + } + ); + + const q = queue(config.prerender.concurrency); + + /** + * @param {string} path + * @param {boolean} is_html + */ + function output_filename(path, is_html) { + const file = path.slice(config.paths.base.length + 1) || 'index.html'; + + if (is_html && !file.endsWith('.html')) { + return file + (file.endsWith('/') ? 'index.html' : '.html'); + } + + return file; + } + + const files = new Set(walk(`${out}/client`).map(posixify)); + files.add(`${config.appDir}/env.js`); + + const immutable = `${config.appDir}/immutable`; + if (existsSync(`${out}/server/${immutable}`)) { + for (const file of walk(`${out}/server/${immutable}`)) { + files.add(posixify(`${config.appDir}/immutable/${file}`)); + } + } + const seen = new Set(); + const written = new Set(); + + /** @type {Map>} */ + const expected_hashlinks = new Map(); + + /** @type {Map} */ + const actual_hashlinks = new Map(); + + /** + * @param {string | null} referrer + * @param {string} decoded + * @param {string} [encoded] + * @param {string} [generated_from_id] + */ + function enqueue(referrer, decoded, encoded, generated_from_id) { + if (seen.has(decoded)) return; + seen.add(decoded); + + const file = decoded.slice(config.paths.base.length + 1); + if (files.has(file)) return; + + return q.add(() => visit(decoded, encoded || encodeURI(decoded), referrer, generated_from_id)); + } + + /** + * @param {string} decoded + * @param {string} encoded + * @param {string?} referrer + * @param {string} [generated_from_id] + */ + async function visit(decoded, encoded, referrer, generated_from_id) { + if (!decoded.startsWith(config.paths.base)) { + handle_http_error({ status: 404, path: decoded, referrer, referenceType: 'linked' }); + return; + } + + /** @type {Map} */ + const dependencies = new Map(); + + const response = await server.respond(new Request(config.prerender.origin + encoded), { + getClientAddress() { + throw new Error('Cannot read clientAddress during prerendering'); + }, + prerendering: { + dependencies + }, + read: (file) => { + // stuff we just wrote + const filepath = saved.get(file); + if (filepath) return readFileSync(filepath); + + // stuff in `static` + return readFileSync(join(config.files.assets, file)); + } + }); + + const encoded_id = response.headers.get('x-sveltekit-routeid'); + const decoded_id = encoded_id && decode_uri(encoded_id); + if ( + decoded_id !== null && + generated_from_id !== undefined && + decoded_id !== generated_from_id + ) { + handle_entry_generator_mismatch({ + generatedFromId: generated_from_id, + entry: decoded, + matchedId: decoded_id + }); + } + + const body = Buffer.from(await response.arrayBuffer()); + + save('pages', response, body, decoded, encoded, referrer, 'linked'); + + for (const [dependency_path, result] of dependencies) { + // this seems circuitous, but using new URL allows us to not care + // whether dependency_path is encoded or not + const encoded_dependency_path = new URL(dependency_path, 'http://localhost').pathname; + const decoded_dependency_path = decode_uri(encoded_dependency_path); + + const headers = Object.fromEntries(result.response.headers); + + const prerender = headers['x-sveltekit-prerender']; + if (prerender) { + const encoded_route_id = headers['x-sveltekit-routeid']; + if (encoded_route_id != null) { + const route_id = decode_uri(encoded_route_id); + const existing_value = prerender_map.get(route_id); + if (existing_value !== 'auto') { + prerender_map.set(route_id, prerender === 'true' ? true : 'auto'); + } + } + } + + const body = result.body ?? new Uint8Array(await result.response.arrayBuffer()); + + save( + 'dependencies', + result.response, + body, + decoded_dependency_path, + encoded_dependency_path, + decoded, + 'fetched' + ); + } + + // avoid triggering `filterSerializeResponseHeaders` guard + const headers = Object.fromEntries(response.headers); + + if (config.prerender.crawl && headers['content-type'] === 'text/html') { + const { ids, hrefs } = crawl(body.toString(), decoded); + + actual_hashlinks.set(decoded, ids); + + for (const href of hrefs) { + if (!is_root_relative(href)) continue; + + const { pathname, search, hash } = new URL(href, 'http://localhost'); + + if (search) { + // TODO warn that query strings have no effect on statically-exported pages + } + + if (hash) { + const key = decode_uri(pathname + hash); + + if (!expected_hashlinks.has(key)) { + expected_hashlinks.set(key, new Set()); + } + + /** @type {Set} */ (expected_hashlinks.get(key)).add(decoded); + } + + enqueue(decoded, decode_uri(pathname), pathname); + } + } + } + + /** + * @param {'pages' | 'dependencies'} category + * @param {Response} response + * @param {string | Uint8Array} body + * @param {string} decoded + * @param {string} encoded + * @param {string | null} referrer + * @param {'linked' | 'fetched'} referenceType + */ + function save(category, response, body, decoded, encoded, referrer, referenceType) { + const response_type = Math.floor(response.status / 100); + const headers = Object.fromEntries(response.headers); + + const type = headers['content-type']; + const is_html = response_type === REDIRECT || type === 'text/html'; + + const file = output_filename(decoded, is_html); + const dest = `${config.outDir}/output/prerendered/${category}/${file}`; + + if (written.has(file)) return; + + const encoded_route_id = response.headers.get('x-sveltekit-routeid'); + const route_id = encoded_route_id != null ? decode_uri(encoded_route_id) : null; + if (route_id !== null) prerendered_routes.add(route_id); + + if (response_type === REDIRECT) { + const location = headers['location']; + + if (location) { + const resolved = resolve(encoded, location); + if (is_root_relative(resolved)) { + enqueue(decoded, decode_uri(resolved), resolved); + } + + if (!headers['x-sveltekit-normalize']) { + mkdirp(dirname(dest)); + + log.warn(`${response.status} ${decoded} -> ${location}`); + + writeFileSync( + dest, + `` + ); + + written.add(file); + + if (!prerendered.redirects.has(decoded)) { + prerendered.redirects.set(decoded, { + status: response.status, + location: resolved + }); + + prerendered.paths.push(decoded); + } + } + } else { + log.warn(`location header missing on redirect received from ${decoded}`); + } + + return; + } + + if (response.status === 200) { + if (existsSync(dest) && statSync(dest).isDirectory()) { + throw new Error( + `Cannot save ${decoded} as it is already a directory. See https://kit.svelte.dev/docs/page-options#prerender-route-conflicts for more information` + ); + } + + const dir = dirname(dest); + + if (existsSync(dir) && !statSync(dir).isDirectory()) { + const parent = decoded.split('/').slice(0, -1).join('/'); + throw new Error( + `Cannot save ${decoded} as ${parent} is already a file. See https://kit.svelte.dev/docs/page-options#prerender-route-conflicts for more information` + ); + } + + mkdirp(dir); + + log.info(`${response.status} ${decoded}`); + writeFileSync(dest, body); + written.add(file); + + if (is_html) { + prerendered.pages.set(decoded, { + file + }); + } else { + prerendered.assets.set(decoded, { + type + }); + } + + prerendered.paths.push(decoded); + } else if (response_type !== OK) { + handle_http_error({ status: response.status, path: decoded, referrer, referenceType }); + } + + manifest.assets.add(file); + saved.set(file, dest); + } + + /** @type {Array<{ id: string, entries: Array}>} */ + const route_level_entries = []; + for (const [id, { entries }] of metadata.routes.entries()) { + if (entries) { + route_level_entries.push({ id, entries }); + } + } + + let has_prerenderable_routes = false; + + for (const value of prerender_map.values()) { + if (value) { + has_prerenderable_routes = true; + break; + } + } + + if ( + (config.prerender.entries.length === 0 && route_level_entries.length === 0) || + !has_prerenderable_routes + ) { + return { prerendered, prerender_map }; + } + + log.info('Prerendering'); + + const server = new Server(manifest); + await server.init({ env }); + + for (const entry of config.prerender.entries) { + if (entry === '*') { + for (const [id, prerender] of prerender_map) { + if (prerender) { + // remove optional parameters from the route + const segments = get_route_segments(id).filter((segment) => !segment.startsWith('[[')); + const processed_id = '/' + segments.join('/'); + + if (processed_id.includes('[')) continue; + const path = `/${get_route_segments(processed_id).join('/')}`; + enqueue(null, config.paths.base + path); + } + } + } else { + enqueue(null, config.paths.base + entry); + } + } + + for (const { id, entries } of route_level_entries) { + for (const entry of entries) { + enqueue(null, config.paths.base + entry, undefined, id); + } + } + + await q.done(); + + // handle invalid fragment links + for (const [key, referrers] of expected_hashlinks) { + const index = key.indexOf('#'); + const path = key.slice(0, index); + const id = key.slice(index + 1); + + const hashlinks = actual_hashlinks.get(path); + // ignore fragment links to pages that were not prerendered + if (!hashlinks) continue; + + if (!hashlinks.includes(id)) { + handle_missing_id({ id, path, referrers: Array.from(referrers) }); + } + } + + /** @type {string[]} */ + const not_prerendered = []; + + for (const [route_id, prerender] of prerender_map) { + if (prerender === true && !prerendered_routes.has(route_id)) { + not_prerendered.push(route_id); + } + } + + if (not_prerendered.length > 0) { + const list = not_prerendered.map((id) => ` - ${id}`).join('\n'); + + throw new Error( + `The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:\n${list}\n\nSee https://kit.svelte.dev/docs/page-options#prerender-troubleshooting for info on how to solve this` + ); + } + + return { prerendered, prerender_map }; +} diff --git a/node_modules/@sveltejs/kit/src/core/postbuild/queue.js b/node_modules/@sveltejs/kit/src/core/postbuild/queue.js new file mode 100644 index 000000000..79a2e9b7c --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/postbuild/queue.js @@ -0,0 +1,80 @@ +/** + * @typedef {{ + * fn: () => Promise, + * fulfil: (value: any) => void, + * reject: (error: Error) => void + * }} Task + */ + +/** @param {number} concurrency */ +export function queue(concurrency) { + /** @type {Task[]} */ + const tasks = []; + + let current = 0; + + /** @type {(value?: any) => void} */ + let fulfil; + + /** @type {(error: Error) => void} */ + let reject; + + let closed = false; + + const done = new Promise((f, r) => { + fulfil = f; + reject = r; + }); + + done.catch(() => { + // this is necessary in case a catch handler is never added + // to the done promise by the user + }); + + function dequeue() { + if (current < concurrency) { + const task = tasks.shift(); + + if (task) { + current += 1; + const promise = Promise.resolve(task.fn()); + + promise + .then(task.fulfil, (err) => { + task.reject(err); + reject(err); + }) + .then(() => { + current -= 1; + dequeue(); + }); + } else if (current === 0) { + closed = true; + fulfil(); + } + } + } + + return { + /** @param {() => any} fn */ + add: (fn) => { + if (closed) throw new Error('Cannot add tasks to a queue that has ended'); + + const promise = new Promise((fulfil, reject) => { + tasks.push({ fn, fulfil, reject }); + }); + + dequeue(); + return promise; + }, + + done: () => { + if (current === 0) { + closed = true; + fulfil(); + } + + return done; + } + }; +} diff --git a/assets/.gitkeep b/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/conflict.js similarity index 100% rename from assets/.gitkeep rename to node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/conflict.js diff --git a/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/index.js b/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/index.js new file mode 100644 index 000000000..5d72686db --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/index.js @@ -0,0 +1,570 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import colors from 'kleur'; +import { lookup } from 'mrmime'; +import { list_files, runtime_directory } from '../../utils.js'; +import { posixify } from '../../../utils/filesystem.js'; +import { parse_route_id } from '../../../utils/routing.js'; +import { sort_routes } from './sort.js'; + +/** + * Generates the manifest data used for the client-side manifest and types generation. + * @param {{ + * config: import('types').ValidatedConfig; + * fallback?: string; + * cwd?: string; + * }} opts + * @returns {import('types').ManifestData} + */ +export default function create_manifest_data({ + config, + fallback = `${runtime_directory}/components`, + cwd = process.cwd() +}) { + const assets = create_assets(config); + const matchers = create_matchers(config, cwd); + const { nodes, routes } = create_routes_and_nodes(cwd, config, fallback); + + for (const route of routes) { + for (const param of route.params) { + if (param.matcher && !matchers[param.matcher]) { + throw new Error(`No matcher found for parameter '${param.matcher}' in route ${route.id}`); + } + } + } + + return { + assets, + matchers, + nodes, + routes + }; +} + +/** + * @param {import('types').ValidatedConfig} config + */ +export function create_assets(config) { + return list_files(config.kit.files.assets).map((file) => ({ + file, + size: fs.statSync(path.resolve(config.kit.files.assets, file)).size, + type: lookup(file) || null + })); +} + +/** + * @param {import('types').ValidatedConfig} config + * @param {string} cwd + */ +function create_matchers(config, cwd) { + const params_base = path.relative(cwd, config.kit.files.params); + + /** @type {Record} */ + const matchers = {}; + if (fs.existsSync(config.kit.files.params)) { + for (const file of fs.readdirSync(config.kit.files.params)) { + const ext = path.extname(file); + if (!config.kit.moduleExtensions.includes(ext)) continue; + const type = file.slice(0, -ext.length); + + if (/^\w+$/.test(type)) { + const matcher_file = path.join(params_base, file); + + // Disallow same matcher with different extensions + if (matchers[type]) { + throw new Error(`Duplicate matchers: ${matcher_file} and ${matchers[type]}`); + } else { + matchers[type] = matcher_file; + } + } else { + // Allow for matcher test collocation + if (type.endsWith('.test') || type.endsWith('.spec')) continue; + + throw new Error( + `Matcher names can only have underscores and alphanumeric characters — "${file}" is invalid` + ); + } + } + } + + return matchers; +} + +/** + * @param {import('types').ValidatedConfig} config + * @param {string} cwd + * @param {string} fallback + */ +function create_routes_and_nodes(cwd, config, fallback) { + /** @type {import('types').RouteData[]} */ + const routes = []; + + const routes_base = posixify(path.relative(cwd, config.kit.files.routes)); + + const valid_extensions = [...config.extensions, ...config.kit.moduleExtensions]; + + /** @type {import('types').PageNode[]} */ + const nodes = []; + + if (fs.existsSync(config.kit.files.routes)) { + /** + * @param {number} depth + * @param {string} id + * @param {string} segment + * @param {import('types').RouteData | null} parent + */ + const walk = (depth, id, segment, parent) => { + const unescaped = id.replace(/\[([ux])\+([^\]]+)\]/gi, (match, type, code) => { + if (match !== match.toLowerCase()) { + throw new Error(`Character escape sequence in ${id} must be lowercase`); + } + + if (!/[0-9a-f]+/.test(code)) { + throw new Error(`Invalid character escape sequence in ${id}`); + } + + if (type === 'x') { + if (code.length !== 2) { + throw new Error(`Hexadecimal escape sequence in ${id} must be two characters`); + } + + return String.fromCharCode(parseInt(code, 16)); + } else { + if (code.length < 4 || code.length > 6) { + throw new Error( + `Unicode escape sequence in ${id} must be between four and six characters` + ); + } + + return String.fromCharCode(parseInt(code, 16)); + } + }); + + if (/\]\[/.test(unescaped)) { + throw new Error(`Invalid route ${id} — parameters must be separated`); + } + + if (count_occurrences('[', id) !== count_occurrences(']', id)) { + throw new Error(`Invalid route ${id} — brackets are unbalanced`); + } + + if (/#/.test(segment)) { + // Vite will barf on files with # in them + throw new Error(`Route ${id} should be renamed to ${id.replace(/#/g, '[x+23]')}`); + } + + if (/\[\.\.\.\w+\]\/\[\[/.test(id)) { + throw new Error( + `Invalid route ${id} — an [[optional]] route segment cannot follow a [...rest] route segment` + ); + } + + if (/\[\[\.\.\./.test(id)) { + throw new Error( + `Invalid route ${id} — a rest route segment is always optional, remove the outer square brackets` + ); + } + + const { pattern, params } = parse_route_id(id); + + /** @type {import('types').RouteData} */ + const route = { + id, + parent, + + segment, + pattern, + params, + + layout: null, + error: null, + leaf: null, + page: null, + endpoint: null + }; + + // important to do this before walking children, so that child + // routes appear later + routes.push(route); + + // if we don't do this, the route map becomes unwieldy to console.log + Object.defineProperty(route, 'parent', { enumerable: false }); + + const dir = path.join(cwd, routes_base, id); + + // We can't use withFileTypes because of a NodeJs bug which returns wrong results + // with isDirectory() in case of symlinks: https://github.com/nodejs/node/issues/30646 + const files = fs.readdirSync(dir).map((name) => ({ + is_dir: fs.statSync(path.join(dir, name)).isDirectory(), + name + })); + + // process files first + for (const file of files) { + if (file.is_dir) continue; + + const ext = valid_extensions.find((ext) => file.name.endsWith(ext)); + if (!ext) continue; + + if (!file.name.startsWith('+')) { + const name = file.name.slice(0, -ext.length); + // check if it is a valid route filename but missing the + prefix + const typo = + /^(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/.test(name) || + /^(?:(server)|(page(?:(@[a-zA-Z0-9_-]*))?(\.server)?)|(layout(?:(@[a-zA-Z0-9_-]*))?(\.server)?))$/.test( + name + ); + if (typo) { + console.log( + colors + .bold() + .yellow( + `Missing route file prefix. Did you mean +${file.name}?` + + ` at ${path.join(dir, file.name)}` + ) + ); + } + + continue; + } + + if (file.name.endsWith('.d.ts')) { + let name = file.name.slice(0, -5); + const ext = valid_extensions.find((ext) => name.endsWith(ext)); + if (ext) name = name.slice(0, -ext.length); + + const valid = + /^\+(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/.test(name) || + /^\+(?:(server)|(page(?:(@[a-zA-Z0-9_-]*))?(\.server)?)|(layout(?:(@[a-zA-Z0-9_-]*))?(\.server)?))$/.test( + name + ); + + if (valid) continue; + } + + const project_relative = posixify(path.relative(cwd, path.join(dir, file.name))); + + const item = analyze( + project_relative, + file.name, + config.extensions, + config.kit.moduleExtensions + ); + + /** + * @param {string} type + * @param {string} existing_file + */ + function duplicate_files_error(type, existing_file) { + return new Error( + `Multiple ${type} files found in ${routes_base}${route.id} : ${path.basename( + existing_file + )} and ${file.name}` + ); + } + + if (item.kind === 'component') { + if (item.is_error) { + route.error = { + depth, + component: project_relative + }; + } else if (item.is_layout) { + if (!route.layout) { + route.layout = { depth, child_pages: [] }; + } else if (route.layout.component) { + throw duplicate_files_error('layout component', route.layout.component); + } + + route.layout.component = project_relative; + if (item.uses_layout !== undefined) route.layout.parent_id = item.uses_layout; + } else { + if (!route.leaf) { + route.leaf = { depth }; + } else if (route.leaf.component) { + throw duplicate_files_error('page component', route.leaf.component); + } + + route.leaf.component = project_relative; + if (item.uses_layout !== undefined) route.leaf.parent_id = item.uses_layout; + } + } else if (item.is_layout) { + if (!route.layout) { + route.layout = { depth, child_pages: [] }; + } else if (route.layout[item.kind]) { + throw duplicate_files_error( + item.kind + ' layout module', + /** @type {string} */ (route.layout[item.kind]) + ); + } + + route.layout[item.kind] = project_relative; + } else if (item.is_page) { + if (!route.leaf) { + route.leaf = { depth }; + } else if (route.leaf[item.kind]) { + throw duplicate_files_error( + item.kind + ' page module', + /** @type {string} */ (route.leaf[item.kind]) + ); + } + + route.leaf[item.kind] = project_relative; + } else { + if (route.endpoint) { + throw duplicate_files_error('endpoint', route.endpoint.file); + } + + route.endpoint = { + file: project_relative + }; + } + } + + // then handle children + for (const file of files) { + if (file.is_dir) { + walk(depth + 1, path.posix.join(id, file.name), file.name, route); + } + } + }; + + walk(0, '/', '', null); + + if (routes.length === 1) { + const root = routes[0]; + if (!root.leaf && !root.error && !root.layout && !root.endpoint) { + throw new Error( + 'No routes found. If you are using a custom src/routes directory, make sure it is specified in svelte.config.js' + ); + } + } + } else { + // If there's no routes directory, we'll just create a single empty route. This ensures the root layout and + // error components are included in the manifest, which is needed for subsequent build/dev commands to work + routes.push({ + id: '/', + segment: '', + pattern: /^$/, + params: [], + parent: null, + layout: null, + error: null, + leaf: null, + page: null, + endpoint: null + }); + } + + prevent_conflicts(routes); + + const root = routes[0]; + + if (!root.layout?.component) { + if (!root.layout) root.layout = { depth: 0, child_pages: [] }; + root.layout.component = posixify(path.relative(cwd, `${fallback}/layout.svelte`)); + } + + if (!root.error?.component) { + if (!root.error) root.error = { depth: 0 }; + root.error.component = posixify(path.relative(cwd, `${fallback}/error.svelte`)); + } + + // we do layouts/errors first as they are more likely to be reused, + // and smaller indexes take fewer bytes. also, this guarantees that + // the default error/layout are 0/1 + for (const route of routes) { + if (route.layout) { + if (!route.layout?.component) { + route.layout.component = posixify(path.relative(cwd, `${fallback}/layout.svelte`)); + } + nodes.push(route.layout); + } + if (route.error) nodes.push(route.error); + } + + for (const route of routes) { + if (route.leaf) nodes.push(route.leaf); + } + + const indexes = new Map(nodes.map((node, i) => [node, i])); + + for (const route of routes) { + if (!route.leaf) continue; + + route.page = { + layouts: [], + errors: [], + leaf: /** @type {number} */ (indexes.get(route.leaf)) + }; + + /** @type {import('types').RouteData | null} */ + let current_route = route; + let current_node = route.leaf; + let parent_id = route.leaf.parent_id; + + while (current_route) { + if (parent_id === undefined || current_route.segment === parent_id) { + if (current_route.layout || current_route.error) { + route.page.layouts.unshift( + current_route.layout ? indexes.get(current_route.layout) : undefined + ); + route.page.errors.unshift( + current_route.error ? indexes.get(current_route.error) : undefined + ); + } + + if (current_route.layout) { + /** @type {import('types').PageNode[]} */ (current_route.layout.child_pages).push( + route.leaf + ); + current_node.parent = current_node = current_route.layout; + parent_id = current_node.parent_id; + } else { + parent_id = undefined; + } + } + + current_route = current_route.parent; + } + + if (parent_id !== undefined) { + throw new Error(`${current_node.component} references missing segment "${parent_id}"`); + } + } + + return { + nodes, + routes: sort_routes(routes) + }; +} + +/** + * @param {string} project_relative + * @param {string} file + * @param {string[]} component_extensions + * @param {string[]} module_extensions + * @returns {import('./types.js').RouteFile} + */ +function analyze(project_relative, file, component_extensions, module_extensions) { + const component_extension = component_extensions.find((ext) => file.endsWith(ext)); + if (component_extension) { + const name = file.slice(0, -component_extension.length); + const pattern = /^\+(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/; + const match = pattern.exec(name); + if (!match) { + throw new Error(`Files prefixed with + are reserved (saw ${project_relative})`); + } + + return { + kind: 'component', + is_page: !!match[1], + is_layout: !!match[3], + is_error: !!match[5], + uses_layout: match[2] ?? match[4] + }; + } + + const module_extension = module_extensions.find((ext) => file.endsWith(ext)); + if (module_extension) { + const name = file.slice(0, -module_extension.length); + const pattern = + /^\+(?:(server)|(page(?:(@[a-zA-Z0-9_-]*))?(\.server)?)|(layout(?:(@[a-zA-Z0-9_-]*))?(\.server)?))$/; + const match = pattern.exec(name); + if (!match) { + throw new Error(`Files prefixed with + are reserved (saw ${project_relative})`); + } else if (match[3] || match[6]) { + throw new Error( + // prettier-ignore + `Only Svelte files can reference named layouts. Remove '${match[3] || match[6]}' from ${file} (at ${project_relative})` + ); + } + + const kind = match[1] || match[4] || match[7] ? 'server' : 'universal'; + + return { + kind, + is_page: !!match[2], + is_layout: !!match[5] + }; + } + + throw new Error(`Files and directories prefixed with + are reserved (saw ${project_relative})`); +} + +/** + * @param {string} needle + * @param {string} haystack + */ +function count_occurrences(needle, haystack) { + let count = 0; + for (let i = 0; i < haystack.length; i += 1) { + if (haystack[i] === needle) count += 1; + } + return count; +} + +/** @param {import('types').RouteData[]} routes */ +function prevent_conflicts(routes) { + /** @type {Map} */ + const lookup = new Map(); + + for (const route of routes) { + if (!route.leaf && !route.endpoint) continue; + + const normalized = normalize_route_id(route.id); + + // find all permutations created by optional parameters + const split = normalized.split(/<\?(.+?)>/g); + + let permutations = [/** @type {string} */ (split[0])]; + + // turn `x/[[optional]]/y` into `x/y` and `x/[required]/y` + for (let i = 1; i < split.length; i += 2) { + const matcher = split[i]; + const next = split[i + 1]; + + permutations = permutations.reduce((a, b) => { + a.push(b + next); + if (!(matcher === '*' && b.endsWith('//'))) a.push(b + `<${matcher}>${next}`); + return a; + }, /** @type {string[]} */ ([])); + } + + for (const permutation of permutations) { + // remove leading/trailing/duplicated slashes caused by prior + // manipulation of optional parameters and (groups) + const key = permutation + .replace(/\/{2,}/, '/') + .replace(/^\//, '') + .replace(/\/$/, ''); + + if (lookup.has(key)) { + throw new Error( + `The "${lookup.get(key)}" and "${route.id}" routes conflict with each other` + ); + } + + lookup.set(key, route.id); + } + } +} + +/** @param {string} id */ +function normalize_route_id(id) { + return ( + id + // remove groups + .replace(/(?<=^|\/)\(.+?\)(?=$|\/)/g, '') + + .replace(/\[[ux]\+([0-9a-f]+)\]/g, (_, x) => + String.fromCharCode(parseInt(x, 16)).replace(/\//g, '%2f') + ) + + // replace `[param]` with `<*>`, `[param=x]` with ``, and `[[param]]` with `` + .replace( + /\[(?:(\[)|(\.\.\.))?.+?(=.+?)?\]\]?/g, + (_, optional, rest, matcher) => `<${optional ? '?' : ''}${rest ?? ''}${matcher ?? '*'}>` + ) + ); +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/sort.js b/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/sort.js new file mode 100644 index 000000000..9addd2c39 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/sort.js @@ -0,0 +1,161 @@ +import { get_route_segments } from '../../../utils/routing.js'; + +/** + * @typedef {{ + * type: 'static' | 'required' | 'optional' | 'rest'; + * content: string; + * matched: boolean; + * }} Part + */ + +/** + * @typedef {Part[]} Segment + */ + +const EMPTY = { type: 'static', content: '', matched: false }; + +/** @param {import('types').RouteData[]} routes */ +export function sort_routes(routes) { + /** @type {Map} */ + const segment_cache = new Map(); + + /** @param {string} segment */ + function get_parts(segment) { + if (!segment_cache.has(segment)) { + segment_cache.set(segment, split(segment)); + } + + return segment_cache.get(segment); + } + + /** @param {string} id */ + function split(id) { + /** @type {Part[]} */ + const parts = []; + + let i = 0; + while (i <= id.length) { + const start = id.indexOf('[', i); + if (start === -1) { + parts.push({ type: 'static', content: id.slice(i), matched: false }); + break; + } + + parts.push({ type: 'static', content: id.slice(i, start), matched: false }); + + const type = id[start + 1] === '[' ? 'optional' : id[start + 1] === '.' ? 'rest' : 'required'; + const delimiter = type === 'optional' ? ']]' : ']'; + const end = id.indexOf(delimiter, start); + + if (end === -1) { + throw new Error(`Invalid route ID ${id}`); + } + + const content = id.slice(start, (i = end + delimiter.length)); + + parts.push({ + type, + content, + matched: content.includes('=') + }); + } + + return parts; + } + + return routes.sort((route_a, route_b) => { + const segments_a = split_route_id(route_a.id).map(get_parts); + const segments_b = split_route_id(route_b.id).map(get_parts); + + for (let i = 0; i < Math.max(segments_a.length, segments_b.length); i += 1) { + const segment_a = segments_a[i] ?? [EMPTY]; + const segment_b = segments_b[i] ?? [EMPTY]; + + for (let j = 0; j < Math.max(segment_a.length, segment_b.length); j += 1) { + const a = segment_a[j]; + const b = segment_b[j]; + + // first part of each segment is always static + // (though it may be the empty string), then + // it alternates between dynamic and static + // (i.e. [foo][bar] is disallowed) + const dynamic = j % 2 === 1; + + if (dynamic) { + if (!a) return -1; + if (!b) return +1; + + // get the next static chunk, so we can handle [...rest] edge cases + const next_a = segment_a[j + 1].content || segments_a[i + 1]?.[0].content; + const next_b = segment_b[j + 1].content || segments_b[i + 1]?.[0].content; + + // `[...rest]/x` outranks `[...rest]` + if (a.type === 'rest' && b.type === 'rest') { + if (next_a && next_b) continue; + if (next_a) return -1; + if (next_b) return +1; + } + + // `[...rest]/x` outranks `[required]` or `[required]/[required]` + // but not `[required]/x` + if (a.type === 'rest') { + return next_a && !next_b ? -1 : +1; + } + + if (b.type === 'rest') { + return next_b && !next_a ? +1 : -1; + } + + // part with matcher outranks one without + if (a.matched !== b.matched) { + return a.matched ? -1 : +1; + } + + if (a.type !== b.type) { + // `[...rest]` has already been accounted for, so here + // we're comparing between `[required]` and `[[optional]]` + if (a.type === 'required') return -1; + if (b.type === 'required') return +1; + } + } else if (a.content !== b.content) { + // shallower path outranks deeper path + if (a === EMPTY) return -1; + if (b === EMPTY) return +1; + + return sort_static(a.content, b.content); + } + } + } + + return route_a.id < route_b.id ? +1 : -1; + }); +} + +/** @param {string} id */ +function split_route_id(id) { + return get_route_segments( + id + // remove all [[optional]] parts unless they're at the very end + .replace(/\[\[[^\]]+\]\](?!$)/g, '') + ).filter(Boolean); +} + +/** + * Sort two strings lexicographically, except `foobar` outranks `foo` + * @param {string} a + * @param {string} b + */ +function sort_static(a, b) { + if (a === b) return 0; + + for (let i = 0; true; i += 1) { + const char_a = a[i]; + const char_b = b[i]; + + if (char_a !== char_b) { + if (char_a === undefined) return +1; + if (char_b === undefined) return -1; + return char_a < char_b ? -1 : +1; + } + } +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/types.d.ts b/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/types.d.ts new file mode 100644 index 000000000..ec5c01b8e --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/create_manifest_data/types.d.ts @@ -0,0 +1,37 @@ +import { PageNode } from 'types'; + +interface Part { + dynamic: boolean; + optional: boolean; + rest: boolean; + type: string | null; +} + +interface RouteTreeNode { + error: PageNode | undefined; + layout: PageNode | undefined; +} + +export type RouteTree = Map; + +interface RouteComponent { + kind: 'component'; + is_page: boolean; + is_layout: boolean; + is_error: boolean; + uses_layout: string | undefined; +} + +interface RouteSharedModule { + kind: 'universal'; + is_page: boolean; + is_layout: boolean; +} + +interface RouteServerModule { + kind: 'server'; + is_page: boolean; + is_layout: boolean; +} + +export type RouteFile = RouteComponent | RouteSharedModule | RouteServerModule; diff --git a/node_modules/@sveltejs/kit/src/core/sync/sync.js b/node_modules/@sveltejs/kit/src/core/sync/sync.js new file mode 100644 index 000000000..d16466818 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/sync.js @@ -0,0 +1,80 @@ +import path from 'node:path'; +import create_manifest_data from './create_manifest_data/index.js'; +import { write_client_manifest } from './write_client_manifest.js'; +import { write_root } from './write_root.js'; +import { write_tsconfig } from './write_tsconfig.js'; +import { write_types, write_all_types } from './write_types/index.js'; +import { write_ambient } from './write_ambient.js'; +import { write_non_ambient } from './write_non_ambient.js'; +import { write_server } from './write_server.js'; + +/** + * Initialize SvelteKit's generated files. + * @param {import('types').ValidatedConfig} config + * @param {string} mode + */ +export function init(config, mode) { + write_tsconfig(config.kit); + write_ambient(config.kit, mode); + write_non_ambient(config.kit); +} + +/** + * Update SvelteKit's generated files + * @param {import('types').ValidatedConfig} config + */ +export async function create(config) { + const manifest_data = create_manifest_data({ config }); + + const output = path.join(config.kit.outDir, 'generated'); + + write_client_manifest(config.kit, manifest_data, `${output}/client`); + write_server(config, output); + write_root(manifest_data, output); + await write_all_types(config, manifest_data); + + return { manifest_data }; +} + +/** + * Update SvelteKit's generated files in response to a single file content update. + * Do not call this when the file in question was created/deleted. + * + * @param {import('types').ValidatedConfig} config + * @param {import('types').ManifestData} manifest_data + * @param {string} file + */ +export async function update(config, manifest_data, file) { + await write_types(config, manifest_data, file); + + return { manifest_data }; +} + +/** + * Run sync.init and sync.create in series, returning the result from sync.create. + * @param {import('types').ValidatedConfig} config + * @param {string} mode The Vite mode + */ +export async function all(config, mode) { + init(config, mode); + return await create(config); +} + +/** + * Run sync.init and then generate all type files. + * @param {import('types').ValidatedConfig} config + * @param {string} mode The Vite mode + */ +export async function all_types(config, mode) { + init(config, mode); + const manifest_data = create_manifest_data({ config }); + await write_all_types(config, manifest_data); +} + +/** + * Regenerate __SERVER__/internal.js in response to src/{app.html,error.html,service-worker.js} changing + * @param {import('types').ValidatedConfig} config + */ +export function server(config) { + write_server(config, path.join(config.kit.outDir, 'generated')); +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/ts.js b/node_modules/@sveltejs/kit/src/core/sync/ts.js new file mode 100644 index 000000000..61c79e37f --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/ts.js @@ -0,0 +1,6 @@ +/** @type {import('typescript')} */ +// @ts-ignore +export let ts = undefined; +try { + ts = (await import('typescript')).default; +} catch {} diff --git a/node_modules/@sveltejs/kit/src/core/sync/utils.js b/node_modules/@sveltejs/kit/src/core/sync/utils.js new file mode 100644 index 000000000..9e75fc074 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/utils.js @@ -0,0 +1,75 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { VERSION } from 'svelte/compiler'; +import { mkdirp } from '../../utils/filesystem.js'; + +/** @type {Map} */ +const previous_contents = new Map(); + +/** + * @param {string} file + * @param {string} code + */ +export function write_if_changed(file, code) { + if (code !== previous_contents.get(file)) { + write(file, code); + } +} + +/** + * @param {string} file + * @param {string} code + */ +export function write(file, code) { + previous_contents.set(file, code); + mkdirp(path.dirname(file)); + fs.writeFileSync(file, code); +} + +/** @type {WeakMap} */ +const dedent_map = new WeakMap(); + +/** + * Allows indenting template strings without the extra indentation ending up in the result. + * Still allows indentation of lines relative to one another in the template string. + * @param {TemplateStringsArray} strings + * @param {any[]} values + */ +export function dedent(strings, ...values) { + let dedented = dedent_map.get(strings); + + if (!dedented) { + const indentation = /** @type {RegExpExecArray} */ (/\n?([ \t]*)/.exec(strings[0]))[1]; + const pattern = new RegExp(`^${indentation}`, 'gm'); + + dedented = { + strings: strings.map((str) => str.replace(pattern, '')), + indents: [] + }; + + let current = '\n'; + + for (let i = 0; i < values.length; i += 1) { + const string = dedented.strings[i]; + const match = /\n([ \t]*)$/.exec(string); + + if (match) current = match[0]; + dedented.indents[i] = current; + } + + dedent_map.set(strings, dedented); + } + + let str = dedented.strings[0]; + for (let i = 0; i < values.length; i += 1) { + str += String(values[i]).replace(/\n/g, dedented.indents[i]) + dedented.strings[i + 1]; + } + + str = str.trim(); + + return str; +} + +export function isSvelte5Plus() { + return Number(VERSION[0]) >= 5; +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/write_ambient.js b/node_modules/@sveltejs/kit/src/core/sync/write_ambient.js new file mode 100644 index 000000000..40a871cb5 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/write_ambient.js @@ -0,0 +1,63 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { get_env } from '../../exports/vite/utils.js'; +import { GENERATED_COMMENT } from '../../constants.js'; +import { create_dynamic_types, create_static_types } from '../env.js'; +import { write_if_changed } from './utils.js'; + +// TODO these types should be described in a neutral place, rather than +// inside either `packages/kit` or `kit.svelte.dev` +const descriptions_dir = fileURLToPath(new URL('../../../src/types/synthetic', import.meta.url)); + +/** @param {string} filename */ +function read_description(filename) { + const content = fs.readFileSync(`${descriptions_dir}/${filename}`, 'utf8'); + return `/**\n${content + .trim() + .split('\n') + .map((line) => ` * ${line}`) + .join('\n')}\n */`; +} + +/** + * @param {import('types').Env} env + * @param {{ + * public_prefix: string; + * private_prefix: string; + * }} prefixes + */ +const template = (env, prefixes) => ` +${GENERATED_COMMENT} + +/// + +${read_description('$env+static+private.md')} +${create_static_types('private', env)} + +${read_description('$env+static+public.md')} +${create_static_types('public', env)} + +${read_description('$env+dynamic+private.md')} +${create_dynamic_types('private', env, prefixes)} + +${read_description('$env+dynamic+public.md')} +${create_dynamic_types('public', env, prefixes)} +`; + +/** + * Writes ambient declarations including types reference to @sveltejs/kit, + * and the existing environment variables in process.env to + * $env/static/private and $env/static/public + * @param {import('types').ValidatedKitConfig} config + * @param {string} mode The Vite mode + */ +export function write_ambient(config, mode) { + const env = get_env(config.env, mode); + const { publicPrefix: public_prefix, privatePrefix: private_prefix } = config.env; + + write_if_changed( + path.join(config.outDir, 'ambient.d.ts'), + template(env, { public_prefix, private_prefix }) + ); +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/write_client_manifest.js b/node_modules/@sveltejs/kit/src/core/sync/write_client_manifest.js new file mode 100644 index 000000000..b8b920ffb --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/write_client_manifest.js @@ -0,0 +1,167 @@ +import path from 'node:path'; +import { relative_path, resolve_entry } from '../../utils/filesystem.js'; +import { s } from '../../utils/misc.js'; +import { dedent, isSvelte5Plus, write_if_changed } from './utils.js'; +import colors from 'kleur'; + +/** + * Writes the client manifest to disk. The manifest is used to power the router. It contains the + * list of routes and corresponding Svelte components (i.e. pages and layouts). + * @param {import('types').ValidatedKitConfig} kit + * @param {import('types').ManifestData} manifest_data + * @param {string} output + * @param {Array<{ has_server_load: boolean }>} [metadata] + */ +export function write_client_manifest(kit, manifest_data, output, metadata) { + /** + * Creates a module that exports a `CSRPageNode` + * @param {import('types').PageNode} node + */ + function generate_node(node) { + const declarations = []; + + if (node.universal) { + declarations.push( + `import * as universal from ${s(relative_path(`${output}/nodes`, node.universal))};`, + 'export { universal };' + ); + } + + if (node.component) { + declarations.push( + `export { default as component } from ${s( + relative_path(`${output}/nodes`, node.component) + )};` + ); + } + + return declarations.join('\n'); + } + + /** @type {Map} */ + const indices = new Map(); + const nodes = manifest_data.nodes + .map((node, i) => { + indices.set(node, i); + + write_if_changed(`${output}/nodes/${i}.js`, generate_node(node)); + return `() => import('./nodes/${i}')`; + }) + .join(',\n'); + + const layouts_with_server_load = new Set(); + + const dictionary = dedent` + { + ${manifest_data.routes + .map((route) => { + if (route.page) { + const errors = route.page.errors.slice(1).map((n) => n ?? ''); + const layouts = route.page.layouts.slice(1).map((n) => n ?? ''); + + while (layouts.at(-1) === '') layouts.pop(); + while (errors.at(-1) === '') errors.pop(); + + let leaf_has_server_load = false; + if (route.leaf) { + if (metadata) { + const i = /** @type {number} */ (indices.get(route.leaf)); + + leaf_has_server_load = metadata[i].has_server_load; + } else if (route.leaf.server) { + leaf_has_server_load = true; + } + } + + // Encode whether or not the route uses server data + // using the ones' complement, to save space + const array = [`${leaf_has_server_load ? '~' : ''}${route.page.leaf}`]; + + // Encode whether or not the layout uses server data. + // It's a different method compared to pages because layouts + // are reused across pages, so we save space by doing it this way. + route.page.layouts.forEach((layout) => { + if (layout == undefined) return; + + let layout_has_server_load = false; + + if (metadata) { + layout_has_server_load = metadata[layout].has_server_load; + } else if (manifest_data.nodes[layout].server) { + layout_has_server_load = true; + } + + if (layout_has_server_load) { + layouts_with_server_load.add(layout); + } + }); + + // only include non-root layout/error nodes if they exist + if (layouts.length > 0 || errors.length > 0) array.push(`[${layouts.join(',')}]`); + if (errors.length > 0) array.push(`[${errors.join(',')}]`); + + return `${s(route.id)}: [${array.join(',')}]`; + } + }) + .filter(Boolean) + .join(',\n')} + } + `; + + const hooks_file = resolve_entry(kit.files.hooks.client); + + const typo = resolve_entry('src/+hooks.client'); + if (typo) { + console.log( + colors + .bold() + .yellow( + `Unexpected + prefix. Did you mean ${typo.split('/').at(-1)?.slice(1)}?` + + ` at ${path.resolve(typo)}` + ) + ); + } + + write_if_changed( + `${output}/app.js`, + dedent` + ${hooks_file ? `import * as client_hooks from '${relative_path(output, hooks_file)}';` : ''} + + export { matchers } from './matchers.js'; + + export const nodes = [ + ${nodes} + ]; + + export const server_loads = [${[...layouts_with_server_load].join(',')}]; + + export const dictionary = ${dictionary}; + + export const hooks = { + handleError: ${ + hooks_file ? 'client_hooks.handleError || ' : '' + }(({ error }) => { console.error(error) }), + }; + + export { default as root } from '../root.${isSvelte5Plus() ? 'js' : 'svelte'}'; + ` + ); + + // write matchers to a separate module so that we don't + // need to worry about name conflicts + const imports = []; + const matchers = []; + + for (const key in manifest_data.matchers) { + const src = manifest_data.matchers[key]; + + imports.push(`import { match as ${key} } from ${s(relative_path(output, src))};`); + matchers.push(key); + } + + const module = imports.length + ? `${imports.join('\n')}\n\nexport const matchers = { ${matchers.join(', ')} };` + : 'export const matchers = {};'; + + write_if_changed(`${output}/matchers.js`, module); +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/write_non_ambient.js b/node_modules/@sveltejs/kit/src/core/sync/write_non_ambient.js new file mode 100644 index 000000000..a191495ac --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/write_non_ambient.js @@ -0,0 +1,42 @@ +import path from 'node:path'; +import { GENERATED_COMMENT } from '../../constants.js'; +import { write_if_changed } from './utils.js'; + +// `declare module "svelte/elements"` needs to happen in a non-ambient module, and dts-buddy generates one big ambient module, +// so we can't add it there - therefore generate the typings ourselves here. +// We're not using the `declare namespace svelteHTML` variant because that one doesn't augment the HTMLAttributes interface +// people could use to type their own components. +// The T generic is needed or else there's a "all declarations must have identical type parameters" error. +const template = ` +${GENERATED_COMMENT} + +declare module "svelte/elements" { + export interface HTMLAttributes { + 'data-sveltekit-keepfocus'?: true | '' | 'off' | undefined | null; + 'data-sveltekit-noscroll'?: true | '' | 'off' | undefined | null; + 'data-sveltekit-preload-code'?: + | true + | '' + | 'eager' + | 'viewport' + | 'hover' + | 'tap' + | 'off' + | undefined + | null; + 'data-sveltekit-preload-data'?: true | '' | 'hover' | 'tap' | 'off' | undefined | null; + 'data-sveltekit-reload'?: true | '' | 'off' | undefined | null; + 'data-sveltekit-replacestate'?: true | '' | 'off' | undefined | null; + } +} + +export {}; +`; + +/** + * Writes non-ambient declarations to the output directory + * @param {import('types').ValidatedKitConfig} config + */ +export function write_non_ambient(config) { + write_if_changed(path.join(config.outDir, 'non-ambient.d.ts'), template); +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/write_root.js b/node_modules/@sveltejs/kit/src/core/sync/write_root.js new file mode 100644 index 000000000..af8cf889b --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/write_root.js @@ -0,0 +1,133 @@ +import { dedent, isSvelte5Plus, write_if_changed } from './utils.js'; + +/** + * @param {import('types').ManifestData} manifest_data + * @param {string} output + */ +export function write_root(manifest_data, output) { + // TODO remove default layout altogether + + const max_depth = Math.max( + ...manifest_data.routes.map((route) => + route.page ? route.page.layouts.filter(Boolean).length + 1 : 0 + ), + 1 + ); + + const levels = []; + for (let i = 0; i <= max_depth; i += 1) { + levels.push(i); + } + + let l = max_depth; + + let pyramid = ``; + + while (l--) { + pyramid = dedent` + {#if constructors[${l + 1}]} + + ${pyramid} + + {:else} + + {/if} + `; + } + + write_if_changed( + `${output}/root.svelte`, + dedent` + + ${isSvelte5Plus() ? '' : ''} + + + ${pyramid} + + {#if mounted} +
+ {#if navigated} + {title} + {/if} +
+ {/if} + ` + ); + + if (isSvelte5Plus()) { + write_if_changed( + `${output}/root.js`, + dedent` + import { asClassComponent } from 'svelte/legacy'; + import Root from './root.svelte'; + export default asClassComponent(Root); + ` + ); + } +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/write_server.js b/node_modules/@sveltejs/kit/src/core/sync/write_server.js new file mode 100644 index 000000000..c73168962 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/write_server.js @@ -0,0 +1,110 @@ +import path from 'node:path'; +import { hash } from '../../runtime/hash.js'; +import { posixify, resolve_entry } from '../../utils/filesystem.js'; +import { s } from '../../utils/misc.js'; +import { load_error_page, load_template } from '../config/index.js'; +import { runtime_directory } from '../utils.js'; +import { isSvelte5Plus, write_if_changed } from './utils.js'; +import colors from 'kleur'; + +/** + * @param {{ + * hooks: string | null; + * config: import('types').ValidatedConfig; + * has_service_worker: boolean; + * runtime_directory: string; + * template: string; + * error_page: string; + * }} opts + */ +const server_template = ({ + config, + hooks, + has_service_worker, + runtime_directory, + template, + error_page +}) => ` +import root from '../root.${isSvelte5Plus() ? 'js' : 'svelte'}'; +import { set_building, set_prerendering } from '__sveltekit/environment'; +import { set_assets } from '__sveltekit/paths'; +import { set_private_env, set_public_env, set_safe_public_env } from '${runtime_directory}/shared-server.js'; + +export const options = { + app_dir: ${s(config.kit.appDir)}, + app_template_contains_nonce: ${template.includes('%sveltekit.nonce%')}, + csp: ${s(config.kit.csp)}, + csrf_check_origin: ${s(config.kit.csrf.checkOrigin)}, + embedded: ${config.kit.embedded}, + env_public_prefix: '${config.kit.env.publicPrefix}', + env_private_prefix: '${config.kit.env.privatePrefix}', + hooks: null, // added lazily, via \`get_hooks\` + preload_strategy: ${s(config.kit.output.preloadStrategy)}, + root, + service_worker: ${has_service_worker}, + templates: { + app: ({ head, body, assets, nonce, env }) => ${s(template) + .replace('%sveltekit.head%', '" + head + "') + .replace('%sveltekit.body%', '" + body + "') + .replace(/%sveltekit\.assets%/g, '" + assets + "') + .replace(/%sveltekit\.nonce%/g, '" + nonce + "') + .replace( + /%sveltekit\.env\.([^%]+)%/g, + (_match, capture) => `" + (env[${s(capture)}] ?? "") + "` + )}, + error: ({ status, message }) => ${s(error_page) + .replace(/%sveltekit\.status%/g, '" + status + "') + .replace(/%sveltekit\.error\.message%/g, '" + message + "')} + }, + version_hash: ${s(hash(config.kit.version.name))} +}; + +export function get_hooks() { + return ${hooks ? `import(${s(hooks)})` : '{}'}; +} + +export { set_assets, set_building, set_prerendering, set_private_env, set_public_env, set_safe_public_env }; +`; + +// TODO need to re-run this whenever src/app.html or src/error.html are +// created or changed, or src/service-worker.js is created or deleted. +// Also, need to check that updating hooks.server.js works + +/** + * Write server configuration to disk + * @param {import('types').ValidatedConfig} config + * @param {string} output + */ +export function write_server(config, output) { + const hooks_file = resolve_entry(config.kit.files.hooks.server); + + const typo = resolve_entry('src/+hooks.server'); + if (typo) { + console.log( + colors + .bold() + .yellow( + `Unexpected + prefix. Did you mean ${typo.split('/').at(-1)?.slice(1)}?` + + ` at ${path.resolve(typo)}` + ) + ); + } + + /** @param {string} file */ + function relative(file) { + return posixify(path.relative(`${output}/server`, file)); + } + + write_if_changed( + `${output}/server/internal.js`, + server_template({ + config, + hooks: hooks_file ? relative(hooks_file) : null, + has_service_worker: + config.kit.serviceWorker.register && !!resolve_entry(config.kit.files.serviceWorker), + runtime_directory: relative(runtime_directory), + template: load_template(process.cwd(), config), + error_page: load_error_page(config) + }) + ); +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/write_tsconfig.js b/node_modules/@sveltejs/kit/src/core/sync/write_tsconfig.js new file mode 100644 index 000000000..8e2747436 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/write_tsconfig.js @@ -0,0 +1,226 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import colors from 'kleur'; +import { posixify } from '../../utils/filesystem.js'; +import { write_if_changed } from './utils.js'; + +/** + * @param {string} cwd + * @param {string} file + */ +function maybe_file(cwd, file) { + const resolved = path.resolve(cwd, file); + if (fs.existsSync(resolved)) { + return resolved; + } +} + +/** + * @param {string} file + */ +function project_relative(file) { + return posixify(path.relative('.', file)); +} + +/** + * @param {string} file + */ +function remove_trailing_slashstar(file) { + if (file.endsWith('/*')) { + return file.slice(0, -2); + } else { + return file; + } +} + +/** + * Generates the tsconfig that the user's tsconfig inherits from. + * @param {import('types').ValidatedKitConfig} kit + */ +export function write_tsconfig(kit, cwd = process.cwd()) { + const out = path.join(kit.outDir, 'tsconfig.json'); + + const user_config = load_user_tsconfig(cwd); + if (user_config) validate_user_config(cwd, out, user_config); + + write_if_changed(out, JSON.stringify(get_tsconfig(kit), null, '\t')); +} + +/** + * Generates the tsconfig that the user's tsconfig inherits from. + * @param {import('types').ValidatedKitConfig} kit + */ +export function get_tsconfig(kit) { + /** @param {string} file */ + const config_relative = (file) => posixify(path.relative(kit.outDir, file)); + + const include = new Set([ + 'ambient.d.ts', + 'non-ambient.d.ts', + './types/**/$types.d.ts', + config_relative('vite.config.js'), + config_relative('vite.config.ts') + ]); + // TODO(v2): find a better way to include all src files. We can't just use routes/lib only because + // people might have other folders/files in src that they want included. + const src_includes = [kit.files.routes, kit.files.lib, path.resolve('src')].filter((dir) => { + const relative = path.relative(path.resolve('src'), dir); + return !relative || relative.startsWith('..'); + }); + for (const dir of src_includes) { + include.add(config_relative(`${dir}/**/*.js`)); + include.add(config_relative(`${dir}/**/*.ts`)); + include.add(config_relative(`${dir}/**/*.svelte`)); + } + + // Test folder is a special case - we advocate putting tests in a top-level test folder + // and it's not configurable (should we make it?) + const test_folder = project_relative('tests'); + include.add(config_relative(`${test_folder}/**/*.js`)); + include.add(config_relative(`${test_folder}/**/*.ts`)); + include.add(config_relative(`${test_folder}/**/*.svelte`)); + + const exclude = [config_relative('node_modules/**')]; + if (path.extname(kit.files.serviceWorker)) { + exclude.push(config_relative(kit.files.serviceWorker)); + } else { + exclude.push(config_relative(`${kit.files.serviceWorker}.js`)); + exclude.push(config_relative(`${kit.files.serviceWorker}.ts`)); + exclude.push(config_relative(`${kit.files.serviceWorker}.d.ts`)); + } + + const config = { + compilerOptions: { + // generated options + paths: get_tsconfig_paths(kit), + rootDirs: [config_relative('.'), './types'], + + // essential options + // svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript + // to enforce using \`import type\` instead of \`import\` for Types. + // Also, TypeScript doesn't know about import usages in the template because it only sees the + // script of a Svelte file. Therefore preserve all value imports. + verbatimModuleSyntax: true, + // Vite compiles modules one at a time + isolatedModules: true, + + // This is required for svelte-package to work as expected + // Can be overwritten + lib: ['esnext', 'DOM', 'DOM.Iterable'], + moduleResolution: 'bundler', + module: 'esnext', + noEmit: true, // prevent tsconfig error "overwriting input files" - Vite handles the build and ignores this + target: 'esnext' + }, + include: [...include], + exclude + }; + + return kit.typescript.config(config) ?? config; +} + +/** @param {string} cwd */ +function load_user_tsconfig(cwd) { + const file = maybe_file(cwd, 'tsconfig.json') || maybe_file(cwd, 'jsconfig.json'); + + if (!file) return; + + // we have to eval the file, since it's not parseable as JSON (contains comments) + const json = fs.readFileSync(file, 'utf-8'); + + return { + kind: path.basename(file), + options: (0, eval)(`(${json})`) + }; +} + +/** + * @param {string} cwd + * @param {string} out + * @param {{ kind: string, options: any }} config + */ +function validate_user_config(cwd, out, config) { + // we need to check that the user's tsconfig extends the framework config + const extend = config.options.extends; + const extends_framework_config = + typeof extend === 'string' + ? path.resolve(cwd, extend) === out + : Array.isArray(extend) + ? extend.some((e) => path.resolve(cwd, e) === out) + : false; + + const options = config.options.compilerOptions || {}; + + if (extends_framework_config) { + const { paths, baseUrl } = options; + + if (baseUrl || paths) { + console.warn( + colors + .bold() + .yellow( + `You have specified a baseUrl and/or paths in your ${config.kind} which interferes with SvelteKit's auto-generated tsconfig.json. ` + + 'Remove it to avoid problems with intellisense. For path aliases, use `kit.alias` instead: https://kit.svelte.dev/docs/configuration#alias' + ) + ); + } + } else { + let relative = posixify(path.relative('.', out)); + if (!relative.startsWith('./')) relative = './' + relative; + + console.warn( + colors + .bold() + .yellow(`Your ${config.kind} should extend the configuration generated by SvelteKit:`) + ); + console.warn(`{\n "extends": "${relative}"\n}`); + } +} + +// +const alias_regex = /^(.+?)(\/\*)?$/; +// +const value_regex = /^(.*?)((\/\*)|(\.\w+))?$/; + +/** + * Generates tsconfig path aliases from kit's aliases. + * Related to vite alias creation. + * + * @param {import('types').ValidatedKitConfig} config + */ +function get_tsconfig_paths(config) { + /** @param {string} file */ + const config_relative = (file) => posixify(path.relative(config.outDir, file)); + + const alias = { ...config.alias }; + if (fs.existsSync(project_relative(config.files.lib))) { + alias['$lib'] = project_relative(config.files.lib); + } + + /** @type {Record} */ + const paths = {}; + + for (const [key, value] of Object.entries(alias)) { + const key_match = alias_regex.exec(key); + if (!key_match) throw new Error(`Invalid alias key: ${key}`); + + const value_match = value_regex.exec(value); + if (!value_match) throw new Error(`Invalid alias value: ${value}`); + + const rel_path = config_relative(remove_trailing_slashstar(value)); + const slashstar = key_match[2]; + + if (slashstar) { + paths[key] = [rel_path + '/*']; + } else { + paths[key] = [rel_path]; + const fileending = value_match[4]; + + if (!fileending && !(key + '/*' in alias)) { + paths[key + '/*'] = [rel_path + '/*']; + } + } + } + + return paths; +} diff --git a/node_modules/@sveltejs/kit/src/core/sync/write_types/index.js b/node_modules/@sveltejs/kit/src/core/sync/write_types/index.js new file mode 100644 index 000000000..2c2f0fa0b --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/sync/write_types/index.js @@ -0,0 +1,853 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import MagicString from 'magic-string'; +import { posixify, rimraf, walk } from '../../../utils/filesystem.js'; +import { compact } from '../../../utils/array.js'; +import { ts } from '../ts.js'; + +/** + * @typedef {{ + * file_name: string; + * modified: boolean; + * code: string; + * exports: any[]; + * } | null} Proxy + * + * @typedef {{ + * server: Proxy, + * universal: Proxy + * }} Proxies + * + * @typedef {Map} RoutesMap + */ + +const cwd = process.cwd(); + +/** + * Creates types for the whole manifest + * @param {import('types').ValidatedConfig} config + * @param {import('types').ManifestData} manifest_data + */ +export async function write_all_types(config, manifest_data) { + if (!ts) return; + + const types_dir = `${config.kit.outDir}/types`; + + // empty out files that no longer need to exist + const routes_dir = posixify(path.relative('.', config.kit.files.routes)).replace(/\.\.\//g, ''); + const expected_directories = new Set( + manifest_data.routes.map((route) => path.join(routes_dir, route.id)) + ); + + if (fs.existsSync(types_dir)) { + for (const file of walk(types_dir)) { + const dir = path.dirname(file); + if (!expected_directories.has(dir)) { + rimraf(path.join(types_dir, file)); + } + } + } + + // Read/write meta data on each invocation, not once per node process, + // it could be invoked by another process in the meantime. + const meta_data_file = `${types_dir}/route_meta_data.json`; + const has_meta_data = fs.existsSync(meta_data_file); + const meta_data = has_meta_data + ? /** @type {Record} */ (JSON.parse(fs.readFileSync(meta_data_file, 'utf-8'))) + : {}; + const routes_map = create_routes_map(manifest_data); + // For each directory, write $types.d.ts + for (const route of manifest_data.routes) { + if (!route.leaf && !route.layout && !route.endpoint) continue; // nothing to do + + const outdir = path.join(config.kit.outDir, 'types', routes_dir, route.id); + + // check if the types are out of date + /** @type {string[]} */ + const input_files = []; + + /** @type {import('types').PageNode | null} */ + let node = route.leaf; + while (node) { + if (node.universal) input_files.push(node.universal); + if (node.server) input_files.push(node.server); + node = node.parent ?? null; + } + + /** @type {import('types').PageNode | null} */ + node = route.layout; + while (node) { + if (node.universal) input_files.push(node.universal); + if (node.server) input_files.push(node.server); + node = node.parent ?? null; + } + + if (route.endpoint) { + input_files.push(route.endpoint.file); + } + + try { + fs.mkdirSync(outdir, { recursive: true }); + } catch {} + + const output_files = compact( + fs.readdirSync(outdir).map((name) => { + const stats = fs.statSync(path.join(outdir, name)); + if (stats.isDirectory()) return; + return { + name, + updated: stats.mtimeMs + }; + }) + ); + + const source_last_updated = Math.max( + // ctimeMs includes move operations whereas mtimeMs does not + ...input_files.map((file) => fs.statSync(file).ctimeMs) + ); + const types_last_updated = Math.max(...output_files.map((file) => file.updated)); + + const should_generate = + // source files were generated more recently than the types + source_last_updated > types_last_updated || + // no meta data file exists yet + !has_meta_data || + // some file was deleted + !meta_data[route.id]?.every((file) => input_files.includes(file)); + + if (should_generate) { + // track which old files end up being surplus to requirements + const to_delete = new Set(output_files.map((file) => file.name)); + update_types(config, routes_map, route, to_delete); + meta_data[route.id] = input_files; + } + } + + fs.writeFileSync(meta_data_file, JSON.stringify(meta_data, null, '\t')); +} + +/** + * Creates types related to the given file. This should only be called + * if the file in question was edited, not if it was created/deleted/moved. + * @param {import('types').ValidatedConfig} config + * @param {import('types').ManifestData} manifest_data + * @param {string} file + */ +export async function write_types(config, manifest_data, file) { + if (!ts) return; + + if (!path.basename(file).startsWith('+')) { + // Not a route file + return; + } + + const id = '/' + posixify(path.relative(config.kit.files.routes, path.dirname(file))); + + const route = manifest_data.routes.find((route) => route.id === id); + if (!route) return; + if (!route.leaf && !route.layout && !route.endpoint) return; // nothing to do + + update_types(config, create_routes_map(manifest_data), route); +} + +/** + * Collect all leafs into a leaf -> route map + * @param {import('types').ManifestData} manifest_data + */ +function create_routes_map(manifest_data) { + /** @type {RoutesMap} */ + const map = new Map(); + for (const route of manifest_data.routes) { + if (route.leaf) { + map.set(route.leaf, { route, proxies: { server: null, universal: null } }); + } + } + return map; +} + +/** + * Update types for a specific route + * @param {import('types').ValidatedConfig} config + * @param {RoutesMap} routes + * @param {import('types').RouteData} route + * @param {Set} [to_delete] + */ +function update_types(config, routes, route, to_delete = new Set()) { + const routes_dir = posixify(path.relative('.', config.kit.files.routes)).replace(/\.\.\//g, ''); + const outdir = path.join(config.kit.outDir, 'types', routes_dir, route.id); + + // now generate new types + const imports = ["import type * as Kit from '@sveltejs/kit';"]; + + /** @type {string[]} */ + const declarations = []; + + /** @type {string[]} */ + const exports = []; + + // add 'Expand' helper + // Makes sure a type is "repackaged" and therefore more readable + declarations.push('type Expand = T extends infer O ? { [K in keyof O]: O[K] } : never;'); + + // returns the predicate of a matcher's type guard - or string if there is no type guard + declarations.push( + // TS complains on infer U, which seems weird, therefore ts-ignore it + [ + '// @ts-ignore', + 'type MatcherParam = M extends (param : string) => param is infer U ? U extends string ? U : string : string;' + ].join('\n') + ); + + declarations.push( + 'type RouteParams = ' + generate_params_type(route.params, outdir, config) + ';' + ); + + if (route.params.length > 0) { + exports.push( + 'export type EntryGenerator = () => Promise> | Array;' + ); + } + + declarations.push(`type RouteId = '${route.id}';`); + + // These could also be placed in our public types, but it would bloat them unnecessarily and we may want to change these in the future + if (route.layout || route.leaf) { + declarations.push( + // If T extends the empty object, void is also allowed as a return type + 'type MaybeWithVoid = {} extends T ? T | void : T;', + + // Returns the key of the object whose values are required. + 'export type RequiredKeys = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K; }[keyof T];', + + // Helper type to get the correct output type for load functions. It should be passed the parent type to check what types from App.PageData are still required. + // If none, void is also allowed as a return type. + 'type OutputDataShape = MaybeWithVoid> & Partial> & Record>', + + // null & {} == null, we need to prevent that in some situations + 'type EnsureDefined = T extends null | undefined ? {} : T;', + + // Takes a union type and returns a union type where each type also has all properties + // of all possible types (typed as undefined), making accessing them more ergonomic + 'type OptionalUnion, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude]?: never } & U : never;', + + // Re-export `Snapshot` from @sveltejs/kit — in future we could use this to infer from the return type of `snapshot.capture` + 'export type Snapshot = Kit.Snapshot;' + ); + } + + if (route.leaf) { + let route_info = routes.get(route.leaf); + if (!route_info) { + // This should be defined, but belts and braces + route_info = { route, proxies: { server: null, universal: null } }; + routes.set(route.leaf, route_info); + } + + const { + declarations: d, + exports: e, + proxies + } = process_node(route.leaf, outdir, true, route_info.proxies); + + exports.push(...e); + declarations.push(...d); + + if (proxies.server) { + route_info.proxies.server = proxies.server; + if (proxies.server?.modified) to_delete.delete(proxies.server.file_name); + } + if (proxies.universal) { + route_info.proxies.universal = proxies.universal; + if (proxies.universal?.modified) to_delete.delete(proxies.universal.file_name); + } + + if (route.leaf.server) { + exports.push( + 'export type Action | void = Record | void> = Kit.Action' + ); + exports.push( + 'export type Actions | void = Record | void> = Kit.Actions' + ); + } + } + + if (route.layout) { + let all_pages_have_load = true; + /** @type {import('types').RouteParam[]} */ + const layout_params = []; + const ids = ['RouteId']; + + route.layout.child_pages?.forEach((page) => { + const leaf = routes.get(page); + if (leaf) { + if (leaf.route.page) ids.push(`"${leaf.route.id}"`); + + for (const param of leaf.route.params) { + // skip if already added + if (layout_params.some((p) => p.name === param.name)) continue; + layout_params.push({ ...param, optional: true }); + } + + ensureProxies(page, leaf.proxies); + + if ( + // Be defensive - if a proxy doesn't exist (because it couldn't be created), assume a load function exists. + // If we didn't and it's a false negative, the user could wrongfully get a type error on layouts. + (leaf.proxies.server && !leaf.proxies.server.exports.includes('load')) || + (leaf.proxies.universal && !leaf.proxies.universal.exports.includes('load')) + ) { + all_pages_have_load = false; + } + } + if (!page.server && !page.universal) { + all_pages_have_load = false; + } + }); + + if (route.id === '/') { + // root layout is used for fallback error page, where ID can be null + ids.push('null'); + } + + declarations.push(`type LayoutRouteId = ${ids.join(' | ')}`); + + declarations.push( + 'type LayoutParams = RouteParams & ' + generate_params_type(layout_params, outdir, config) + ); + + const { + exports: e, + declarations: d, + proxies + } = process_node( + route.layout, + outdir, + false, + { server: null, universal: null }, + all_pages_have_load + ); + + exports.push(...e); + declarations.push(...d); + + if (proxies.server?.modified) to_delete.delete(proxies.server.file_name); + if (proxies.universal?.modified) to_delete.delete(proxies.universal.file_name); + } + + if (route.endpoint) { + exports.push('export type RequestHandler = Kit.RequestHandler;'); + } + + if (route.leaf?.server || route.layout?.server || route.endpoint) { + exports.push('export type RequestEvent = Kit.RequestEvent;'); + } + + const output = [imports.join('\n'), declarations.join('\n'), exports.join('\n')] + .filter(Boolean) + .join('\n\n'); + + fs.writeFileSync(`${outdir}/$types.d.ts`, output); + to_delete.delete('$types.d.ts'); + + for (const file of to_delete) { + fs.unlinkSync(path.join(outdir, file)); + } +} + +/** + * @param {import('types').PageNode} node + * @param {string} outdir + * @param {boolean} is_page + * @param {Proxies} proxies + * @param {boolean} [all_pages_have_load] + */ +function process_node(node, outdir, is_page, proxies, all_pages_have_load = true) { + const params = `${is_page ? 'Route' : 'Layout'}Params`; + const prefix = is_page ? 'Page' : 'Layout'; + + const route_id = is_page ? 'RouteId' : 'LayoutRouteId'; + + /** @type {string[]} */ + const declarations = []; + /** @type {string[]} */ + const exports = []; + + /** @type {string} */ + let server_data; + /** @type {string} */ + let data; + + ensureProxies(node, proxies); + + if (node.server) { + const basename = path.basename(node.server); + const proxy = proxies.server; + if (proxy?.modified) { + fs.writeFileSync(`${outdir}/proxy${basename}`, proxy.code); + } + + server_data = get_data_type(node.server, 'null', proxy, true); + + const parent_type = `${prefix}ServerParentData`; + + declarations.push(`type ${parent_type} = ${get_parent_type(node, 'LayoutServerData')};`); + + // +page.js load present -> server can return all-optional data + const output_data_shape = + node.universal || (!is_page && all_pages_have_load) + ? 'Partial & Record | void' + : `OutputDataShape<${parent_type}>`; + exports.push( + `export type ${prefix}ServerLoad = Kit.ServerLoad<${params}, ${parent_type}, OutputData, ${route_id}>;` + ); + + exports.push(`export type ${prefix}ServerLoadEvent = Parameters<${prefix}ServerLoad>[0];`); + + if (is_page) { + let type = 'unknown'; + if (proxy && proxy.exports.includes('actions')) { + // If the file wasn't tweaked, we can use the return type of the original file. + // The advantage is that type updates are reflected without saving. + const from = proxy.modified + ? `./proxy${replace_ext_with_js(basename)}` + : path_to_original(outdir, node.server); + + exports.push( + 'type ExcludeActionFailure = T extends Kit.ActionFailure ? never : T extends void ? never : T;', + 'type ActionsSuccess any>> = { [Key in keyof T]: ExcludeActionFailure>>; }[keyof T];', + 'type ExtractActionFailure = T extends Kit.ActionFailure ? X extends void ? never : X : never;', + 'type ActionsFailure any>> = { [Key in keyof T]: Exclude>>, void>; }[keyof T];', + `type ActionsExport = typeof import('${from}').actions`, + 'export type SubmitFunction = Kit.SubmitFunction>, Expand>>' + ); + + type = 'Expand> | null'; + } + exports.push(`export type ActionData = ${type};`); + } + } else { + server_data = 'null'; + } + exports.push(`export type ${prefix}ServerData = ${server_data};`); + + const parent_type = `${prefix}ParentData`; + declarations.push(`type ${parent_type} = ${get_parent_type(node, 'LayoutData')};`); + + if (node.universal) { + const proxy = proxies.universal; + if (proxy?.modified) { + fs.writeFileSync(`${outdir}/proxy${path.basename(node.universal)}`, proxy.code); + } + + const type = get_data_type( + node.universal, + `${parent_type} & EnsureDefined<${prefix}ServerData>`, + proxy + ); + + data = `Expand & OptionalUnion>>`; + + const output_data_shape = + !is_page && all_pages_have_load + ? 'Partial & Record | void' + : `OutputDataShape<${parent_type}>`; + exports.push( + `export type ${prefix}Load = Kit.Load<${params}, ${prefix}ServerData, ${parent_type}, OutputData, ${route_id}>;` + ); + + exports.push(`export type ${prefix}LoadEvent = Parameters<${prefix}Load>[0];`); + } else if (server_data === 'null') { + data = `Expand<${parent_type}>`; + } else { + data = `Expand & EnsureDefined<${prefix}ServerData>>`; + } + + exports.push(`export type ${prefix}Data = ${data};`); + + return { declarations, exports, proxies }; + + /** + * @param {string} file_path + * @param {string} fallback + * @param {Proxy} proxy + * @param {boolean} expand + */ + function get_data_type(file_path, fallback, proxy, expand = false) { + if (proxy) { + if (proxy.exports.includes('load')) { + // If the file wasn't tweaked, we can use the return type of the original file. + // The advantage is that type updates are reflected without saving. + const from = proxy.modified + ? `./proxy${replace_ext_with_js(path.basename(file_path))}` + : path_to_original(outdir, file_path); + const type = `Kit.LoadProperties>>`; + return expand ? `Expand>>` : type; + } else { + return fallback; + } + } else { + return 'unknown'; + } + } +} + +/** + * This function populates the proxies object, if necessary and not already done. + * Proxies are used to tweak the code of a file before it's typechecked. + * They are needed in two places - when generating the types for a page or layout. + * To not do the same work twice, we generate the proxies once and pass them around. + * + * @param {import('types').PageNode} node + * @param {Proxies} proxies + */ +function ensureProxies(node, proxies) { + if (node.server && !proxies.server) { + proxies.server = createProxy(node.server, true); + } + + if (node.universal && !proxies.universal) { + proxies.universal = createProxy(node.universal, false); + } +} + +/** + * @param {string} file_path + * @param {boolean} is_server + * @returns {Proxy} + */ +function createProxy(file_path, is_server) { + const proxy = tweak_types(fs.readFileSync(file_path, 'utf8'), is_server); + if (proxy) { + return { + ...proxy, + file_name: `proxy${path.basename(file_path)}` + }; + } else { + return null; + } +} + +/** + * Get the parent type string by recursively looking up the parent layout and accumulate them to one type. + * @param {import('types').PageNode} node + * @param {string} type + */ +function get_parent_type(node, type) { + const parent_imports = []; + + let parent = node.parent; + + while (parent) { + const d = node.depth - parent.depth; + // unshift because we need it the other way round for the import string + parent_imports.unshift( + `${d === 0 ? '' : `import('${'../'.repeat(d)}${'$types.js'}').`}${type}` + ); + parent = parent.parent; + } + + let parent_str = `EnsureDefined<${parent_imports[0] || '{}'}>`; + for (let i = 1; i < parent_imports.length; i++) { + // Omit is necessary because a parent could have a property with the same key which would + // cause a type conflict. At runtime the child overwrites the parent property in this case, + // so reflect that in the type definition. + // EnsureDefined is necessary because {something: string} & null becomes null. + // Output types of server loads can be null but when passed in through the `parent` parameter they are the empty object instead. + parent_str = `Omit<${parent_str}, keyof ${parent_imports[i]}> & EnsureDefined<${parent_imports[i]}>`; + } + return parent_str; +} + +/** + * @param {string} outdir + * @param {string} file_path + */ +function path_to_original(outdir, file_path) { + return posixify(path.relative(outdir, path.join(cwd, replace_ext_with_js(file_path)))); +} + +/** + * @param {string} file_path + */ +function replace_ext_with_js(file_path) { + // Another extension than `.js` (or nothing, but that fails with node16 moduleResolution) + // will result in TS failing to lookup the file + const ext = path.extname(file_path); + return file_path.slice(0, -ext.length) + '.js'; +} + +/** + * @param {import('types').RouteParam[]} params + * @param {string} outdir + * @param {import('types').ValidatedConfig} config + */ +function generate_params_type(params, outdir, config) { + /** @param {string} matcher */ + const path_to_matcher = (matcher) => + posixify(path.relative(outdir, path.join(config.kit.files.params, matcher))); + + return `{ ${params + .map( + (param) => + `${param.name}${param.optional ? '?' : ''}: ${ + param.matcher + ? `MatcherParam` + : 'string' + }` + ) + .join('; ')} }`; +} + +/** + * @param {string} content + * @param {boolean} is_server + * @returns {Omit, 'file_name'> | null} + */ +export function tweak_types(content, is_server) { + const names = new Set(is_server ? ['load', 'actions'] : ['load']); + + try { + let modified = false; + + const ast = ts.createSourceFile( + 'filename.ts', + content, + ts.ScriptTarget.Latest, + false, + ts.ScriptKind.TS + ); + + const code = new MagicString(content); + + const exports = new Map(); + + ast.forEachChild((node) => { + if ( + ts.isExportDeclaration(node) && + node.exportClause && + ts.isNamedExports(node.exportClause) + ) { + node.exportClause.elements.forEach((element) => { + const exported = element.name; + if (names.has(element.name.text)) { + const local = element.propertyName || element.name; + exports.set(exported.text, local.text); + } + }); + } + + if ( + ts.canHaveModifiers(node) && + ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) + ) { + if (ts.isFunctionDeclaration(node) && node.name?.text && names.has(node.name?.text)) { + exports.set(node.name.text, node.name.text); + } + + if (ts.isVariableStatement(node)) { + node.declarationList.declarations.forEach((declaration) => { + if (ts.isIdentifier(declaration.name) && names.has(declaration.name.text)) { + exports.set(declaration.name.text, declaration.name.text); + } + }); + } + } + }); + + /** + * @param {import('typescript').Node} node + * @param {import('typescript').Node} value + */ + function replace_jsdoc_type_tags(node, value) { + let _modified = false; + // @ts-ignore + if (node.jsDoc) { + // @ts-ignore + for (const comment of node.jsDoc) { + for (const tag of comment.tags ?? []) { + if (ts.isJSDocTypeTag(tag)) { + const is_fn = + ts.isFunctionDeclaration(value) || + ts.isFunctionExpression(value) || + ts.isArrowFunction(value); + + if (is_fn && value.parameters?.length > 0) { + const name = ts.isIdentifier(value.parameters[0].name) + ? value.parameters[0].name.text + : 'event'; + code.overwrite(tag.tagName.pos, tag.tagName.end, 'param'); + code.prependRight(tag.typeExpression.pos + 1, 'Parameters<'); + code.appendLeft(tag.typeExpression.end - 1, '>[0]'); + code.appendLeft(tag.typeExpression.end, ` ${name}`); + } else { + code.overwrite(tag.pos, tag.end, ''); + } + _modified = true; + } + } + } + } + modified = modified || _modified; + return _modified; + } + + ast.forEachChild((node) => { + if (ts.isFunctionDeclaration(node) && node.name?.text && node.name?.text === 'load') { + // remove JSDoc comment above `export function load ...` + replace_jsdoc_type_tags(node, node); + } + + if (ts.isVariableStatement(node)) { + // remove JSDoc comment above `export const load = ...` + if ( + ts.isIdentifier(node.declarationList.declarations[0].name) && + names.has(node.declarationList.declarations[0].name.text) && + node.declarationList.declarations[0].initializer + ) { + replace_jsdoc_type_tags(node, node.declarationList.declarations[0].initializer); + } + + for (const declaration of node.declarationList.declarations) { + if ( + ts.isIdentifier(declaration.name) && + declaration.name.text === 'load' && + declaration.initializer + ) { + // edge case — remove JSDoc comment above individual export + replace_jsdoc_type_tags(declaration, declaration.initializer); + + // remove type from `export const load: Load ...` + if (declaration.type) { + let a = declaration.type.pos; + const b = declaration.type.end; + while (/\s/.test(content[a])) a += 1; + + const type = content.slice(a, b); + code.remove(declaration.name.end, declaration.type.end); + + const rhs = declaration.initializer; + + if ( + rhs && + (ts.isArrowFunction(rhs) || ts.isFunctionExpression(rhs)) && + rhs.parameters.length + ) { + const arg = rhs.parameters[0]; + const add_parens = content[arg.pos - 1] !== '('; + + if (add_parens) code.prependRight(arg.pos, '('); + + if (arg && !arg.type) { + code.appendLeft( + arg.name.end, + `: Parameters<${type}>[0]` + (add_parens ? ')' : '') + ); + } else { + // prevent "type X is imported but not used" (isn't silenced by @ts-nocheck) when svelte-check runs + code.append(`;null as any as ${type};`); + } + } else { + // prevent "type X is imported but not used" (isn't silenced by @ts-nocheck) when svelte-check runs + code.append(`;null as any as ${type};`); + } + + modified = true; + } + } else if ( + is_server && + ts.isIdentifier(declaration.name) && + declaration.name?.text === 'actions' && + declaration.initializer + ) { + // remove JSDoc comment from `export const actions = ..` + const removed = replace_jsdoc_type_tags(node, declaration.initializer); + // ... and move type to each individual action + if (removed) { + const rhs = declaration.initializer; + if (ts.isObjectLiteralExpression(rhs)) { + for (const prop of rhs.properties) { + if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) { + const rhs = prop.initializer; + const replaced = replace_jsdoc_type_tags(prop, rhs); + if ( + !replaced && + rhs && + (ts.isArrowFunction(rhs) || ts.isFunctionExpression(rhs)) && + rhs.parameters?.[0] + ) { + const name = ts.isIdentifier(rhs.parameters[0].name) + ? rhs.parameters[0].name.text + : 'event'; + code.prependRight( + rhs.pos, + `/** @param {import('./$types').RequestEvent} ${name} */ ` + ); + } + } + } + } + } + + // remove type from `export const actions: Actions ...` + if (declaration.type) { + let a = declaration.type.pos; + const b = declaration.type.end; + while (/\s/.test(content[a])) a += 1; + + const type = content.slice(a, b); + code.remove(declaration.name.end, declaration.type.end); + code.append(`;null as any as ${type};`); + modified = true; + + // ... and move type to each individual action + const rhs = declaration.initializer; + if (ts.isObjectLiteralExpression(rhs)) { + for (const prop of rhs.properties) { + if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) { + const rhs = prop.initializer; + + if ( + rhs && + (ts.isArrowFunction(rhs) || ts.isFunctionExpression(rhs)) && + rhs.parameters.length + ) { + const arg = rhs.parameters[0]; + const add_parens = content[arg.pos - 1] !== '('; + + if (add_parens) code.prependRight(arg.pos, '('); + + if (arg && !arg.type) { + code.appendLeft( + arg.name.end, + ": import('./$types').RequestEvent" + (add_parens ? ')' : '') + ); + } + } + } + } + } + } + } + } + } + }); + + if (modified) { + // Ignore all type errors so they don't show up twice when svelte-check runs + // Account for possible @ts-check which would overwrite @ts-nocheck + if (code.original.startsWith('// @ts-check')) { + code.prependLeft('// @ts-check'.length, '\n// @ts-nocheck\n'); + } else { + code.prepend('// @ts-nocheck\n'); + } + } + + return { + modified, + code: code.toString(), + exports: Array.from(exports.keys()) + }; + } catch { + return null; + } +} diff --git a/node_modules/@sveltejs/kit/src/core/utils.js b/node_modules/@sveltejs/kit/src/core/utils.js new file mode 100644 index 000000000..6ab57f25c --- /dev/null +++ b/node_modules/@sveltejs/kit/src/core/utils.js @@ -0,0 +1,86 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import colors from 'kleur'; +import { posixify, to_fs } from '../utils/filesystem.js'; + +/** + * Resolved path of the `runtime` directory + * + * TODO Windows issue: + * Vite or sth else somehow sets the driver letter inconsistently to lower or upper case depending on the run environment. + * In playwright debug mode run through VS Code this a root-to-lowercase conversion is needed in order for the tests to run. + * If we do this conversion in other cases it has the opposite effect though and fails. + */ +export const runtime_directory = posixify(fileURLToPath(new URL('../runtime', import.meta.url))); + +/** + * This allows us to import SvelteKit internals that aren't exposed via `pkg.exports` in a + * way that works whether `@sveltejs/kit` is installed inside the project's `node_modules` + * or in a workspace root + */ +export const runtime_base = runtime_directory.startsWith(process.cwd()) + ? `/${path.relative('.', runtime_directory)}` + : to_fs(runtime_directory); + +function noop() {} + +/** @param {{ verbose: boolean }} opts */ +export function logger({ verbose }) { + /** @type {import('types').Logger} */ + const log = (msg) => console.log(msg.replace(/^/gm, ' ')); + + /** @param {string} msg */ + const err = (msg) => console.error(msg.replace(/^/gm, ' ')); + + log.success = (msg) => log(colors.green(`✔ ${msg}`)); + log.error = (msg) => err(colors.bold().red(msg)); + log.warn = (msg) => log(colors.bold().yellow(msg)); + + log.minor = verbose ? (msg) => log(colors.grey(msg)) : noop; + log.info = verbose ? log : noop; + + return log; +} + +/** @param {import('types').ManifestData} manifest_data */ +export function get_mime_lookup(manifest_data) { + /** @type {Record} */ + const mime = {}; + + manifest_data.assets.forEach((asset) => { + if (asset.type) { + const ext = path.extname(asset.file); + mime[ext] = asset.type; + } + }); + + return mime; +} + +/** + * @param {string} dir + * @param {(file: string) => boolean} [filter] + */ +export function list_files(dir, filter) { + /** @type {string[]} */ + const files = []; + + /** @param {string} current */ + function walk(current) { + for (const file of fs.readdirSync(path.resolve(dir, current))) { + const child = path.posix.join(current, file); + if (fs.statSync(path.resolve(dir, child)).isDirectory()) { + walk(child); + } else { + if (!filter || filter(child)) { + files.push(child); + } + } + } + } + + if (fs.existsSync(dir)) walk(''); + + return files; +} diff --git a/node_modules/@sveltejs/kit/src/exports/hooks/index.js b/node_modules/@sveltejs/kit/src/exports/hooks/index.js new file mode 100644 index 000000000..98e1e53a5 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/hooks/index.js @@ -0,0 +1 @@ +export { sequence } from './sequence.js'; diff --git a/node_modules/@sveltejs/kit/src/exports/hooks/sequence.js b/node_modules/@sveltejs/kit/src/exports/hooks/sequence.js new file mode 100644 index 000000000..2e1e32480 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/hooks/sequence.js @@ -0,0 +1,120 @@ +/** + * A helper function for sequencing multiple `handle` calls in a middleware-like manner. + * The behavior for the `handle` options is as follows: + * - `transformPageChunk` is applied in reverse order and merged + * - `preload` is applied in forward order, the first option "wins" and no `preload` options after it are called + * - `filterSerializedResponseHeaders` behaves the same as `preload` + * + * ```js + * /// file: src/hooks.server.js + * import { sequence } from '@sveltejs/kit/hooks'; + * + * /// type: import('@sveltejs/kit').Handle + * async function first({ event, resolve }) { + * console.log('first pre-processing'); + * const result = await resolve(event, { + * transformPageChunk: ({ html }) => { + * // transforms are applied in reverse order + * console.log('first transform'); + * return html; + * }, + * preload: () => { + * // this one wins as it's the first defined in the chain + * console.log('first preload'); + * } + * }); + * console.log('first post-processing'); + * return result; + * } + * + * /// type: import('@sveltejs/kit').Handle + * async function second({ event, resolve }) { + * console.log('second pre-processing'); + * const result = await resolve(event, { + * transformPageChunk: ({ html }) => { + * console.log('second transform'); + * return html; + * }, + * preload: () => { + * console.log('second preload'); + * }, + * filterSerializedResponseHeaders: () => { + * // this one wins as it's the first defined in the chain + * console.log('second filterSerializedResponseHeaders'); + * } + * }); + * console.log('second post-processing'); + * return result; + * } + * + * export const handle = sequence(first, second); + * ``` + * + * The example above would print: + * + * ``` + * first pre-processing + * first preload + * second pre-processing + * second filterSerializedResponseHeaders + * second transform + * first transform + * second post-processing + * first post-processing + * ``` + * + * @param {...import('@sveltejs/kit').Handle} handlers The chain of `handle` functions + * @returns {import('@sveltejs/kit').Handle} + */ +export function sequence(...handlers) { + const length = handlers.length; + if (!length) return ({ event, resolve }) => resolve(event); + + return ({ event, resolve }) => { + return apply_handle(0, event, {}); + + /** + * @param {number} i + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {import('@sveltejs/kit').ResolveOptions | undefined} parent_options + * @returns {import('types').MaybePromise} + */ + function apply_handle(i, event, parent_options) { + const handle = handlers[i]; + + return handle({ + event, + resolve: (event, options) => { + /** @type {import('@sveltejs/kit').ResolveOptions['transformPageChunk']} */ + const transformPageChunk = async ({ html, done }) => { + if (options?.transformPageChunk) { + html = (await options.transformPageChunk({ html, done })) ?? ''; + } + + if (parent_options?.transformPageChunk) { + html = (await parent_options.transformPageChunk({ html, done })) ?? ''; + } + + return html; + }; + + /** @type {import('@sveltejs/kit').ResolveOptions['filterSerializedResponseHeaders']} */ + const filterSerializedResponseHeaders = + parent_options?.filterSerializedResponseHeaders ?? + options?.filterSerializedResponseHeaders; + + /** @type {import('@sveltejs/kit').ResolveOptions['preload']} */ + const preload = parent_options?.preload ?? options?.preload; + + return i < length - 1 + ? apply_handle(i + 1, event, { + transformPageChunk, + filterSerializedResponseHeaders, + preload + }) + : resolve(event, { transformPageChunk, filterSerializedResponseHeaders, preload }); + } + }); + } + }; +} diff --git a/node_modules/@sveltejs/kit/src/exports/index.js b/node_modules/@sveltejs/kit/src/exports/index.js new file mode 100644 index 000000000..283ba840c --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/index.js @@ -0,0 +1,184 @@ +import { HttpError, Redirect, ActionFailure } from '../runtime/control.js'; +import { BROWSER, DEV } from 'esm-env'; + +export { VERSION } from '../version.js'; + +/** + * @template {number} TNumber + * @template {any[]} [TArray=[]] + * @typedef {TNumber extends TArray['length'] ? TArray[number] : LessThan} LessThan + */ + +/** + * @template {number} TStart + * @template {number} TEnd + * @typedef {Exclude, LessThan>} NumericRange + */ + +// we have to repeat the JSDoc because the display for function overloads is broken +// see https://github.com/microsoft/TypeScript/issues/55056 + +/** + * Throws an error with a HTTP status code and an optional message. + * When called during request handling, this will cause SvelteKit to + * return an error response without invoking `handleError`. + * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it. + * @param {NumericRange<400, 599>} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * @param {App.Error} body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property. + * @overload + * @param {NumericRange<400, 599>} status + * @param {App.Error} body + * @return {never} + * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling. + * @throws {Error} If the provided status is invalid (not between 400 and 599). + */ +/** + * Throws an error with a HTTP status code and an optional message. + * When called during request handling, this will cause SvelteKit to + * return an error response without invoking `handleError`. + * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it. + * @param {NumericRange<400, 599>} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} [body] An object that conforms to the App.Error type. If a string is passed, it will be used as the message property. + * @overload + * @param {NumericRange<400, 599>} status + * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} [body] + * @return {never} + * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling. + * @throws {Error} If the provided status is invalid (not between 400 and 599). + */ +/** + * Throws an error with a HTTP status code and an optional message. + * When called during request handling, this will cause SvelteKit to + * return an error response without invoking `handleError`. + * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it. + * @param {NumericRange<400, 599>} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property. + * @return {never} + * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling. + * @throws {Error} If the provided status is invalid (not between 400 and 599). + */ +export function error(status, body) { + if ((!BROWSER || DEV) && (isNaN(status) || status < 400 || status > 599)) { + throw new Error(`HTTP error status codes must be between 400 and 599 — ${status} is invalid`); + } + + throw new HttpError(status, body); +} + +/** + * Checks whether this is an error thrown by {@link error}. + * @template {number} T + * @param {unknown} e + * @param {T} [status] The status to filter for. + * @return {e is (HttpError & { status: T extends undefined ? never : T })} + */ +export function isHttpError(e, status) { + if (!(e instanceof HttpError)) return false; + return !status || e.status === status; +} + +/** + * Redirect a request. When called during request handling, SvelteKit will return a redirect response. + * Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it. + * @param {NumericRange<300, 308>} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308. + * @param {string | URL} location The location to redirect to. + * @throws {Redirect} This error instructs SvelteKit to redirect to the specified location. + * @throws {Error} If the provided status is invalid. + * @return {never} + */ +export function redirect(status, location) { + if ((!BROWSER || DEV) && (isNaN(status) || status < 300 || status > 308)) { + throw new Error('Invalid status code'); + } + + throw new Redirect(status, location.toString()); +} + +/** + * Checks whether this is a redirect thrown by {@link redirect}. + * @param {unknown} e The object to check. + * @return {e is Redirect} + */ +export function isRedirect(e) { + return e instanceof Redirect; +} + +/** + * Create a JSON `Response` object from the supplied data. + * @param {any} data The value that will be serialized as JSON. + * @param {ResponseInit} [init] Options such as `status` and `headers` that will be added to the response. `Content-Type: application/json` and `Content-Length` headers will be added automatically. + */ +export function json(data, init) { + // TODO deprecate this in favour of `Response.json` when it's + // more widely supported + const body = JSON.stringify(data); + + // we can't just do `text(JSON.stringify(data), init)` because + // it will set a default `content-type` header. duplicated code + // means less duplicated work + const headers = new Headers(init?.headers); + if (!headers.has('content-length')) { + headers.set('content-length', encoder.encode(body).byteLength.toString()); + } + + if (!headers.has('content-type')) { + headers.set('content-type', 'application/json'); + } + + return new Response(body, { + ...init, + headers + }); +} + +const encoder = new TextEncoder(); + +/** + * Create a `Response` object from the supplied body. + * @param {string} body The value that will be used as-is. + * @param {ResponseInit} [init] Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically. + */ +export function text(body, init) { + const headers = new Headers(init?.headers); + if (!headers.has('content-length')) { + const encoded = encoder.encode(body); + headers.set('content-length', encoded.byteLength.toString()); + return new Response(encoded, { + ...init, + headers + }); + } + + return new Response(body, { + ...init, + headers + }); +} + +/** + * Create an `ActionFailure` object. + * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * @overload + * @param {number} status + * @returns {import('./public.js').ActionFailure} + */ +/** + * Create an `ActionFailure` object. + * @template {Record | undefined} [T=undefined] + * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * @param {T} data Data associated with the failure (e.g. validation errors) + * @overload + * @param {number} status + * @param {T} data + * @returns {import('./public.js').ActionFailure} + */ +/** + * Create an `ActionFailure` object. + * @param {number} status + * @param {any} [data] + * @returns {import('./public.js').ActionFailure} + */ +export function fail(status, data) { + // @ts-expect-error unique symbol missing + return new ActionFailure(status, data); +} diff --git a/node_modules/@sveltejs/kit/src/exports/node/index.js b/node_modules/@sveltejs/kit/src/exports/node/index.js new file mode 100644 index 000000000..ae3d57afc --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/node/index.js @@ -0,0 +1,187 @@ +import * as set_cookie_parser from 'set-cookie-parser'; +import { SvelteKitError } from '../../runtime/control.js'; + +/** + * @param {import('http').IncomingMessage} req + * @param {number} [body_size_limit] + */ +function get_raw_body(req, body_size_limit) { + const h = req.headers; + + if (!h['content-type']) { + return null; + } + + const content_length = Number(h['content-length']); + + // check if no request body + if ( + (req.httpVersionMajor === 1 && isNaN(content_length) && h['transfer-encoding'] == null) || + content_length === 0 + ) { + return null; + } + + if (req.destroyed) { + const readable = new ReadableStream(); + readable.cancel(); + return readable; + } + + let size = 0; + let cancelled = false; + + return new ReadableStream({ + start(controller) { + if (body_size_limit !== undefined && content_length > body_size_limit) { + const error = new SvelteKitError( + 413, + 'Payload Too Large', + `Content-length of ${content_length} exceeds limit of ${body_size_limit} bytes.` + ); + + controller.error(error); + return; + } + + req.on('error', (error) => { + cancelled = true; + controller.error(error); + }); + + req.on('end', () => { + if (cancelled) return; + controller.close(); + }); + + req.on('data', (chunk) => { + if (cancelled) return; + + size += chunk.length; + if (size > content_length) { + cancelled = true; + + const constraint = content_length ? 'content-length' : 'BODY_SIZE_LIMIT'; + const message = `request body size exceeded ${constraint} of ${content_length}`; + + const error = new SvelteKitError(413, 'Payload Too Large', message); + controller.error(error); + + return; + } + + controller.enqueue(chunk); + + if (controller.desiredSize === null || controller.desiredSize <= 0) { + req.pause(); + } + }); + }, + + pull() { + req.resume(); + }, + + cancel(reason) { + cancelled = true; + req.destroy(reason); + } + }); +} + +/** + * @param {{ + * request: import('http').IncomingMessage; + * base: string; + * bodySizeLimit?: number; + * }} options + * @returns {Promise} + */ +export async function getRequest({ request, base, bodySizeLimit }) { + return new Request(base + request.url, { + // @ts-expect-error + duplex: 'half', + method: request.method, + headers: /** @type {Record} */ (request.headers), + body: get_raw_body(request, bodySizeLimit) + }); +} + +/** + * @param {import('http').ServerResponse} res + * @param {Response} response + * @returns {Promise} + */ +export async function setResponse(res, response) { + for (const [key, value] of response.headers) { + try { + res.setHeader( + key, + key === 'set-cookie' + ? set_cookie_parser.splitCookiesString( + // This is absurd but necessary, TODO: investigate why + /** @type {string}*/ (response.headers.get(key)) + ) + : value + ); + } catch (error) { + res.getHeaderNames().forEach((name) => res.removeHeader(name)); + res.writeHead(500).end(String(error)); + return; + } + } + + res.writeHead(response.status); + + if (!response.body) { + res.end(); + return; + } + + if (response.body.locked) { + res.end( + 'Fatal error: Response body is locked. ' + + "This can happen when the response was already read (for example through 'response.json()' or 'response.text()')." + ); + return; + } + + const reader = response.body.getReader(); + + if (res.destroyed) { + reader.cancel(); + return; + } + + const cancel = (/** @type {Error|undefined} */ error) => { + res.off('close', cancel); + res.off('error', cancel); + + // If the reader has already been interrupted with an error earlier, + // then it will appear here, it is useless, but it needs to be catch. + reader.cancel(error).catch(() => {}); + if (error) res.destroy(error); + }; + + res.on('close', cancel); + res.on('error', cancel); + + next(); + async function next() { + try { + for (;;) { + const { done, value } = await reader.read(); + + if (done) break; + + if (!res.write(value)) { + res.once('drain', next); + return; + } + } + res.end(); + } catch (error) { + cancel(error instanceof Error ? error : new Error(String(error))); + } + } +} diff --git a/node_modules/@sveltejs/kit/src/exports/node/polyfills.js b/node_modules/@sveltejs/kit/src/exports/node/polyfills.js new file mode 100644 index 000000000..347c68cea --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/node/polyfills.js @@ -0,0 +1,30 @@ +import buffer from 'node:buffer'; +import { webcrypto as crypto } from 'node:crypto'; + +// `buffer.File` was added in Node 18.13.0 while the `File` global was added in Node 20.0.0 +const File = /** @type {import('node:buffer') & { File?: File}} */ (buffer).File; + +/** @type {Record} */ +const globals = { + crypto, + File +}; + +// exported for dev/preview and node environments +/** + * Make various web APIs available as globals: + * - `crypto` + * - `File` + */ +export function installPolyfills() { + for (const name in globals) { + if (name in globalThis) continue; + + Object.defineProperty(globalThis, name, { + enumerable: true, + configurable: true, + writable: true, + value: globals[name] + }); + } +} diff --git a/node_modules/@sveltejs/kit/src/exports/public.d.ts b/node_modules/@sveltejs/kit/src/exports/public.d.ts new file mode 100644 index 000000000..7caa0c4bf --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/public.d.ts @@ -0,0 +1,1322 @@ +import 'svelte'; // pick up `declare module "*.svelte"` +import 'vite/client'; // pick up `declare module "*.jpg"`, etc. +import '../types/ambient.js'; + +import { CompileOptions } from 'svelte/compiler'; +import { + AdapterEntry, + CspDirectives, + HttpMethod, + Logger, + MaybePromise, + Prerendered, + PrerenderEntryGeneratorMismatchHandlerValue, + PrerenderHttpErrorHandlerValue, + PrerenderMissingIdHandlerValue, + PrerenderOption, + RequestOptions, + RouteSegment +} from '../types/private.js'; +import { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from 'types'; +import type { PluginOptions } from '@sveltejs/vite-plugin-svelte'; + +export { PrerenderOption } from '../types/private.js'; + +/** + * [Adapters](https://kit.svelte.dev/docs/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing. + */ +export interface Adapter { + /** + * The name of the adapter, using for logging. Will typically correspond to the package name. + */ + name: string; + /** + * This function is called after SvelteKit has built your app. + * @param builder An object provided by SvelteKit that contains methods for adapting the app + */ + adapt(builder: Builder): MaybePromise; +} + +export type LoadProperties | void> = input extends void + ? undefined // needs to be undefined, because void will break intellisense + : input extends Record + ? input + : unknown; + +export type AwaitedActions any>> = OptionalUnion< + { + [Key in keyof T]: UnpackValidationError>>; + }[keyof T] +>; + +// Takes a union type and returns a union type where each type also has all properties +// of all possible types (typed as undefined), making accessing them more ergonomic +type OptionalUnion< + U extends Record, // not unknown, else interfaces don't satisfy this constraint + A extends keyof U = U extends U ? keyof U : never +> = U extends unknown ? { [P in Exclude]?: never } & U : never; + +declare const uniqueSymbol: unique symbol; + +export interface ActionFailure | undefined = undefined> { + status: number; + data: T; + [uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure +} + +type UnpackValidationError = T extends ActionFailure + ? X + : T extends void + ? undefined // needs to be undefined, because void will corrupt union type + : T; + +/** + * This object is passed to the `adapt` function of adapters. + * It contains various methods and properties that are useful for adapting the app. + */ +export interface Builder { + /** Print messages to the console. `log.info` and `log.minor` are silent unless Vite's `logLevel` is `info`. */ + log: Logger; + /** Remove `dir` and all its contents. */ + rimraf(dir: string): void; + /** Create `dir` and any required parent directories. */ + mkdirp(dir: string): void; + + /** The fully resolved `svelte.config.js`. */ + config: ValidatedConfig; + /** Information about prerendered pages and assets, if any. */ + prerendered: Prerendered; + /** An array of all routes (including prerendered) */ + routes: RouteDefinition[]; + + /** + * Create separate functions that map to one or more routes of your app. + * @param fn A function that groups a set of routes into an entry point + * @deprecated Use `builder.routes` instead + */ + createEntries(fn: (route: RouteDefinition) => AdapterEntry): Promise; + + /** + * Generate a fallback page for a static webserver to use when no route is matched. Useful for single-page apps. + */ + generateFallback(dest: string): Promise; + + /** + * Generate a module exposing build-time environment variables as `$env/dynamic/public`. + */ + generateEnvModule(): void; + + /** + * Generate a server-side manifest to initialise the SvelteKit [server](https://kit.svelte.dev/docs/types#public-types-server) with. + * @param opts a relative path to the base directory of the app and optionally in which format (esm or cjs) the manifest should be generated + */ + generateManifest(opts: { relativePath: string; routes?: RouteDefinition[] }): string; + + /** + * Resolve a path to the `name` directory inside `outDir`, e.g. `/path/to/.svelte-kit/my-adapter`. + * @param name path to the file, relative to the build directory + */ + getBuildDirectory(name: string): string; + /** Get the fully resolved path to the directory containing client-side assets, including the contents of your `static` directory. */ + getClientDirectory(): string; + /** Get the fully resolved path to the directory containing server-side code. */ + getServerDirectory(): string; + /** Get the application path including any configured `base` path, e.g. `my-base-path/_app`. */ + getAppPath(): string; + + /** + * Write client assets to `dest`. + * @param dest the destination folder + * @returns an array of files written to `dest` + */ + writeClient(dest: string): string[]; + /** + * Write prerendered files to `dest`. + * @param dest the destination folder + * @returns an array of files written to `dest` + */ + writePrerendered(dest: string): string[]; + /** + * Write server-side code to `dest`. + * @param dest the destination folder + * @returns an array of files written to `dest` + */ + writeServer(dest: string): string[]; + /** + * Copy a file or directory. + * @param from the source file or directory + * @param to the destination file or directory + * @param opts.filter a function to determine whether a file or directory should be copied + * @param opts.replace a map of strings to replace + * @returns an array of files that were copied + */ + copy( + from: string, + to: string, + opts?: { + filter?(basename: string): boolean; + replace?: Record; + } + ): string[]; + + /** + * Compress files in `directory` with gzip and brotli, where appropriate. Generates `.gz` and `.br` files alongside the originals. + * @param {string} directory The directory containing the files to be compressed + */ + compress(directory: string): Promise; +} + +export interface Config { + /** + * Options passed to [`svelte.compile`](https://svelte.dev/docs#compile-time-svelte-compile). + * @default {} + */ + compilerOptions?: CompileOptions; + /** + * List of file extensions that should be treated as Svelte files. + * @default [".svelte"] + */ + extensions?: string[]; + /** SvelteKit options */ + kit?: KitConfig; + /** [`@sveltejs/package`](/docs/packaging) options. */ + package?: { + source?: string; + dir?: string; + emitTypes?: boolean; + exports?(filepath: string): boolean; + files?(filepath: string): boolean; + }; + /** Preprocessor options, if any. Preprocessing can alternatively also be done through Vite's preprocessor capabilities. */ + preprocess?: any; + /** `vite-plugin-svelte` plugin options. */ + vitePlugin?: PluginOptions; + /** Any additional options required by tooling that integrates with Svelte. */ + [key: string]: any; +} + +export interface Cookies { + /** + * Gets a cookie that was previously set with `cookies.set`, or from the request headers. + * @param name the name of the cookie + * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options) + */ + get(name: string, opts?: import('cookie').CookieParseOptions): string | undefined; + + /** + * Gets all cookies that were previously set with `cookies.set`, or from the request headers. + * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options) + */ + getAll(opts?: import('cookie').CookieParseOptions): Array<{ name: string; value: string }>; + + /** + * Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` or `cookies.getAll` during the current request. + * + * The `httpOnly` and `secure` options are `true` by default (except on http://localhost, where `secure` is `false`), and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP. The `sameSite` option defaults to `lax`. + * + * You must specify a `path` for the cookie. In most cases you should explicitly set `path: '/'` to make the cookie available throughout your app. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children + * @param name the name of the cookie + * @param value the cookie value + * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) + */ + set( + name: string, + value: string, + opts: import('cookie').CookieSerializeOptions & { path: string } + ): void; + + /** + * Deletes a cookie by setting its value to an empty string and setting the expiry date in the past. + * + * You must specify a `path` for the cookie. In most cases you should explicitly set `path: '/'` to make the cookie available throughout your app. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children + * @param name the name of the cookie + * @param opts the options, passed directly to `cookie.serialize`. The `path` must match the path of the cookie you want to delete. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) + */ + delete(name: string, opts: import('cookie').CookieSerializeOptions & { path: string }): void; + + /** + * Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response. + * + * The `httpOnly` and `secure` options are `true` by default (except on http://localhost, where `secure` is `false`), and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP. The `sameSite` option defaults to `lax`. + * + * You must specify a `path` for the cookie. In most cases you should explicitly set `path: '/'` to make the cookie available throughout your app. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children + * + * @param name the name of the cookie + * @param value the cookie value + * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) + */ + serialize( + name: string, + value: string, + opts: import('cookie').CookieSerializeOptions & { path: string } + ): string; +} + +export interface KitConfig { + /** + * Your [adapter](https://kit.svelte.dev/docs/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms. + * @default undefined + */ + adapter?: Adapter; + /** + * An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript. + * + * ```js + * /// file: svelte.config.js + * /// type: import('@sveltejs/kit').Config + * const config = { + * kit: { + * alias: { + * // this will match a file + * 'my-file': 'path/to/my-file.js', + * + * // this will match a directory and its contents + * // (`my-directory/x` resolves to `path/to/my-directory/x`) + * 'my-directory': 'path/to/my-directory', + * + * // an alias ending /* will only match + * // the contents of a directory, not the directory itself + * 'my-directory/*': 'path/to/my-directory/*' + * } + * } + * }; + * ``` + * + * > The built-in `$lib` alias is controlled by `config.kit.files.lib` as it is used for packaging. + * + * > You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`. + * @default {} + */ + alias?: Record; + /** + * The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes. + * + * If `paths.assets` is specified, there will be two app directories — `${paths.assets}/${appDir}` and `${paths.base}/${appDir}`. + * @default "_app" + */ + appDir?: string; + /** + * [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) configuration. CSP helps to protect your users against cross-site scripting (XSS) attacks, by limiting the places resources can be loaded from. For example, a configuration like this... + * + * ```js + * /// file: svelte.config.js + * /// type: import('@sveltejs/kit').Config + * const config = { + * kit: { + * csp: { + * directives: { + * 'script-src': ['self'] + * }, + * reportOnly: { + * 'script-src': ['self'] + * } + * } + * } + * }; + * + * export default config; + * ``` + * + * ...would prevent scripts loading from external sites. SvelteKit will augment the specified directives with nonces or hashes (depending on `mode`) for any inline styles and scripts it generates. + * + * To add a nonce for scripts and links manually included in `src/app.html`, you may use the placeholder `%sveltekit.nonce%` (for example ` + * ``` + * + * If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](/docs/modules#$app-stores-updated) store to `true` when it detects one. + */ + version?: { + /** + * The current app version string. If specified, this must be deterministic (e.g. a commit ref rather than `Math.random()` or `Date.now().toString()`), otherwise defaults to a timestamp of the build. + * + * For example, to use the current commit hash, you could do use `git rev-parse HEAD`: + * + * ```js + * /// file: svelte.config.js + * import * as child_process from 'node:child_process'; + * + * export default { + * kit: { + * version: { + * name: child_process.execSync('git rev-parse HEAD').toString().trim() + * } + * } + * }; + * ``` + */ + name?: string; + /** + * The interval in milliseconds to poll for version changes. If this is `0`, no polling occurs. + * @default 0 + */ + pollInterval?: number; + }; +} + +/** + * The [`handle`](https://kit.svelte.dev/docs/hooks#server-hooks-handle) hook runs every time the SvelteKit server receives a [request](https://kit.svelte.dev/docs/web-standards#fetch-apis-request) and + * determines the [response](https://kit.svelte.dev/docs/web-standards#fetch-apis-response). + * It receives an `event` object representing the request and a function called `resolve`, which renders the route and generates a `Response`. + * This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example). + */ +export type Handle = (input: { + event: RequestEvent; + resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise; +}) => MaybePromise; + +/** + * The server-side [`handleError`](https://kit.svelte.dev/docs/hooks#shared-hooks-handleerror) hook runs when an unexpected error is thrown while responding to a request. + * + * If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event. + * Make sure that this function _never_ throws an error. + */ +export type HandleServerError = (input: { + error: unknown; + event: RequestEvent; + status: number; + message: string; +}) => MaybePromise; + +/** + * The client-side [`handleError`](https://kit.svelte.dev/docs/hooks#shared-hooks-handleerror) hook runs when an unexpected error is thrown while navigating. + * + * If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event. + * Make sure that this function _never_ throws an error. + */ +export type HandleClientError = (input: { + error: unknown; + event: NavigationEvent; + status: number; + message: string; +}) => MaybePromise; + +/** + * The [`handleFetch`](https://kit.svelte.dev/docs/hooks#server-hooks-handlefetch) hook allows you to modify (or replace) a `fetch` request that happens inside a `load` function that runs on the server (or during pre-rendering) + */ +export type HandleFetch = (input: { + event: RequestEvent; + request: Request; + fetch: typeof fetch; +}) => MaybePromise; + +/** + * The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types)) + * rather than using `Load` directly. + */ +export type Load< + Params extends Partial> = Partial>, + InputData extends Record | null = Record | null, + ParentData extends Record = Record, + OutputData extends Record | void = Record | void, + RouteId extends string | null = string | null +> = (event: LoadEvent) => MaybePromise; + +/** + * The generic form of `PageLoadEvent` and `LayoutLoadEvent`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types)) + * rather than using `LoadEvent` directly. + */ +export interface LoadEvent< + Params extends Partial> = Partial>, + Data extends Record | null = Record | null, + ParentData extends Record = Record, + RouteId extends string | null = string | null +> extends NavigationEvent { + /** + * `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features: + * + * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request. + * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context). + * - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call. + * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://kit.svelte.dev/docs/hooks#server-hooks-handle) + * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request. + * + * You can learn more about making credentialed requests with cookies [here](https://kit.svelte.dev/docs/load#cookies) + */ + fetch: typeof fetch; + /** + * Contains the data returned by the route's server `load` function (in `+layout.server.js` or `+page.server.js`), if any. + */ + data: Data; + /** + * If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example: + * + * ```js + * /// file: src/routes/blog/+page.js + * export async function load({ fetch, setHeaders }) { + * const url = `https://cms.example.com/articles.json`; + * const response = await fetch(url); + * + * setHeaders({ + * age: response.headers.get('age'), + * 'cache-control': response.headers.get('cache-control') + * }); + * + * return response.json(); + * } + * ``` + * + * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once. + * + * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://kit.svelte.dev/docs/types#public-types-cookies) API in a server-only `load` function instead. + * + * `setHeaders` has no effect when a `load` function runs in the browser. + */ + setHeaders(headers: Record): void; + /** + * `await parent()` returns data from parent `+layout.js` `load` functions. + * Implicitly, a missing `+layout.js` is treated as a `({ data }) => data` function, meaning that it will return and forward data from parent `+layout.server.js` files. + * + * Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data. + */ + parent(): Promise; + /** + * This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun. + * + * Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`. + * + * URLs can be absolute or relative to the page being loaded, and must be [encoded](https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding). + * + * Custom identifiers have to be prefixed with one or more lowercase letters followed by a colon to conform to the [URI specification](https://www.rfc-editor.org/rfc/rfc3986.html). + * + * The following example shows how to use `depends` to register a dependency on a custom identifier, which is `invalidate`d after a button click, making the `load` function rerun. + * + * ```js + * /// file: src/routes/+page.js + * let count = 0; + * export async function load({ depends }) { + * depends('increase:count'); + * + * return { count: count++ }; + * } + * ``` + * + * ```html + * /// file: src/routes/+page.svelte + * + * + *

{data.count}

+ * + * ``` + */ + depends(...deps: Array<`${string}:${string}`>): void; + /** + * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example: + * + * ```js + * /// file: src/routes/+page.server.js + * export async function load({ untrack, url }) { + * // Untrack url.pathname so that path changes don't trigger a rerun + * if (untrack(() => url.pathname === '/')) { + * return { message: 'Welcome!' }; + * } + * } + * ``` + */ + untrack(fn: () => T): T; +} + +export interface NavigationEvent< + Params extends Partial> = Partial>, + RouteId extends string | null = string | null +> { + /** + * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object + */ + params: Params; + /** + * Info about the current route + */ + route: { + /** + * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]` + */ + id: RouteId; + }; + /** + * The URL of the current page + */ + url: URL; +} + +/** + * Information about the target of a specific navigation. + */ +export interface NavigationTarget { + /** + * Parameters of the target page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object. + * Is `null` if the target is not part of the SvelteKit app (could not be resolved to a route). + */ + params: Record | null; + /** + * Info about the target route + */ + route: { id: string | null }; + /** + * The URL that is navigated to + */ + url: URL; +} + +/** + * - `enter`: The app has hydrated + * - `form`: The user submitted a `

` with a GET method + * - `leave`: The user is leaving the app by closing the tab or using the back/forward buttons to go to a different document + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ +export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate'; + +export interface Navigation { + /** + * Where navigation was triggered from + */ + from: NavigationTarget | null; + /** + * Where navigation is going to/has gone to + */ + to: NavigationTarget | null; + /** + * The type of navigation: + * - `form`: The user submitted a `` + * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ + type: Exclude; + /** + * Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation) + */ + willUnload: boolean; + /** + * In case of a history back/forward navigation, the number of steps to go back/forward + */ + delta?: number; + /** + * A promise that resolves once the navigation is complete, and rejects if the navigation + * fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve + */ + complete: Promise; +} + +/** + * The argument passed to [`beforeNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-beforenavigate) callbacks. + */ +export interface BeforeNavigate extends Navigation { + /** + * Call this to prevent the navigation from starting. + */ + cancel(): void; +} + +/** + * The argument passed to [`onNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-onnavigate) callbacks. + */ +export interface OnNavigate extends Navigation { + /** + * The type of navigation: + * - `form`: The user submitted a `` + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ + type: Exclude; + /** + * Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page. + */ + willUnload: false; +} + +/** + * The argument passed to [`afterNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-afternavigate) callbacks. + */ +export interface AfterNavigate extends Omit { + /** + * The type of navigation: + * - `enter`: The app has hydrated + * - `form`: The user submitted a `` + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ + type: Exclude; + /** + * Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page. + */ + willUnload: false; +} + +/** + * The shape of the `$page` store + */ +export interface Page< + Params extends Record = Record, + RouteId extends string | null = string | null +> { + /** + * The URL of the current page + */ + url: URL; + /** + * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object + */ + params: Params; + /** + * Info about the current route + */ + route: { + /** + * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]` + */ + id: RouteId; + }; + /** + * Http status code of the current page + */ + status: number; + /** + * The error object of the current page, if any. Filled from the `handleError` hooks. + */ + error: App.Error | null; + /** + * The merged result of all data from all `load` functions on the current page. You can type a common denominator through `App.PageData`. + */ + data: App.PageData & Record; + /** + * The page state, which can be manipulated using the [`pushState`](https://kit.svelte.dev/docs/modules#$app-navigation-pushstate) and [`replaceState`](https://kit.svelte.dev/docs/modules#$app-navigation-replacestate) functions from `$app/navigation`. + */ + state: App.PageState; + /** + * Filled only after a form submission. See [form actions](https://kit.svelte.dev/docs/form-actions) for more info. + */ + form: any; +} + +/** + * The shape of a param matcher. See [matching](https://kit.svelte.dev/docs/advanced-routing#matching) for more info. + */ +export type ParamMatcher = (param: string) => boolean; + +export interface RequestEvent< + Params extends Partial> = Partial>, + RouteId extends string | null = string | null +> { + /** + * Get or set cookies related to the current request + */ + cookies: Cookies; + /** + * `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features: + * + * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request. + * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context). + * - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call. + * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://kit.svelte.dev/docs/hooks#server-hooks-handle) + * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request. + * + * You can learn more about making credentialed requests with cookies [here](https://kit.svelte.dev/docs/load#cookies) + */ + fetch: typeof fetch; + /** + * The client's IP address, set by the adapter. + */ + getClientAddress(): string; + /** + * Contains custom data that was added to the request within the [`handle hook`](https://kit.svelte.dev/docs/hooks#server-hooks-handle). + */ + locals: App.Locals; + /** + * The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object + */ + params: Params; + /** + * Additional data made available through the adapter. + */ + platform: Readonly | undefined; + /** + * The original request object + */ + request: Request; + /** + * Info about the current route + */ + route: { + /** + * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]` + */ + id: RouteId; + }; + /** + * If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example: + * + * ```js + * /// file: src/routes/blog/+page.js + * export async function load({ fetch, setHeaders }) { + * const url = `https://cms.example.com/articles.json`; + * const response = await fetch(url); + * + * setHeaders({ + * age: response.headers.get('age'), + * 'cache-control': response.headers.get('cache-control') + * }); + * + * return response.json(); + * } + * ``` + * + * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once. + * + * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://kit.svelte.dev/docs/types#public-types-cookies) API instead. + */ + setHeaders(headers: Record): void; + /** + * The requested URL. + */ + url: URL; + /** + * `true` if the request comes from the client asking for `+page/layout.server.js` data. The `url` property will be stripped of the internal information + * related to the data request in this case. Use this property instead if the distinction is important to you. + */ + isDataRequest: boolean; + /** + * `true` for `+server.js` calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin `fetch` requests on the server. + */ + isSubRequest: boolean; +} + +/** + * A `(event: RequestEvent) => Response` function exported from a `+server.js` file that corresponds to an HTTP verb (`GET`, `PUT`, `PATCH`, etc) and handles requests with that method. + * + * It receives `Params` as the first generic argument, which you can skip by using [generated types](https://kit.svelte.dev/docs/types#generated-types) instead. + */ +export type RequestHandler< + Params extends Partial> = Partial>, + RouteId extends string | null = string | null +> = (event: RequestEvent) => MaybePromise; + +export interface ResolveOptions { + /** + * Applies custom transforms to HTML. If `done` is true, it's the final chunk. Chunks are not guaranteed to be well-formed HTML + * (they could include an element's opening tag but not its closing tag, for example) + * but they will always be split at sensible boundaries such as `%sveltekit.head%` or layout/page components. + * @param input the html chunk and the info if this is the last chunk + */ + transformPageChunk?(input: { html: string; done: boolean }): MaybePromise; + /** + * Determines which headers should be included in serialized responses when a `load` function loads a resource with `fetch`. + * By default, none will be included. + * @param name header name + * @param value header value + */ + filterSerializedResponseHeaders?(name: string, value: string): boolean; + /** + * Determines what should be added to the `` tag to preload it. + * By default, `js` and `css` files will be preloaded. + * @param input the type of the file and its path + */ + preload?(input: { type: 'font' | 'css' | 'js' | 'asset'; path: string }): boolean; +} + +export interface RouteDefinition { + id: string; + api: { + methods: Array; + }; + page: { + methods: Array>; + }; + pattern: RegExp; + prerender: PrerenderOption; + segments: RouteSegment[]; + methods: Array; + config: Config; +} + +export class Server { + constructor(manifest: SSRManifest); + init(options: ServerInitOptions): Promise; + respond(request: Request, options: RequestOptions): Promise; +} + +export interface ServerInitOptions { + env: Record; +} + +export interface SSRManifest { + appDir: string; + appPath: string; + assets: Set; + mimeTypes: Record; + + /** private fields */ + _: { + client: NonNullable; + nodes: SSRNodeLoader[]; + routes: SSRRoute[]; + matchers(): Promise>; + }; +} + +/** + * The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types)) + * rather than using `ServerLoad` directly. + */ +export type ServerLoad< + Params extends Partial> = Partial>, + ParentData extends Record = Record, + OutputData extends Record | void = Record | void, + RouteId extends string | null = string | null +> = (event: ServerLoadEvent) => MaybePromise; + +export interface ServerLoadEvent< + Params extends Partial> = Partial>, + ParentData extends Record = Record, + RouteId extends string | null = string | null +> extends RequestEvent { + /** + * `await parent()` returns data from parent `+layout.server.js` `load` functions. + * + * Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data. + */ + parent(): Promise; + /** + * This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun. + * + * Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`. + * + * URLs can be absolute or relative to the page being loaded, and must be [encoded](https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding). + * + * Custom identifiers have to be prefixed with one or more lowercase letters followed by a colon to conform to the [URI specification](https://www.rfc-editor.org/rfc/rfc3986.html). + * + * The following example shows how to use `depends` to register a dependency on a custom identifier, which is `invalidate`d after a button click, making the `load` function rerun. + * + * ```js + * /// file: src/routes/+page.js + * let count = 0; + * export async function load({ depends }) { + * depends('increase:count'); + * + * return { count: count++ }; + * } + * ``` + * + * ```html + * /// file: src/routes/+page.svelte + * + * + *

{data.count}

+ * + * ``` + */ + depends(...deps: string[]): void; + /** + * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example: + * + * ```js + * /// file: src/routes/+page.js + * export async function load({ untrack, url }) { + * // Untrack url.pathname so that path changes don't trigger a rerun + * if (untrack(() => url.pathname === '/')) { + * return { message: 'Welcome!' }; + * } + * } + * ``` + */ + untrack(fn: () => T): T; +} + +/** + * Shape of a form action method that is part of `export const actions = {..}` in `+page.server.js`. + * See [form actions](https://kit.svelte.dev/docs/form-actions) for more information. + */ +export type Action< + Params extends Partial> = Partial>, + OutputData extends Record | void = Record | void, + RouteId extends string | null = string | null +> = (event: RequestEvent) => MaybePromise; + +/** + * Shape of the `export const actions = {..}` object in `+page.server.js`. + * See [form actions](https://kit.svelte.dev/docs/form-actions) for more information. + */ +export type Actions< + Params extends Partial> = Partial>, + OutputData extends Record | void = Record | void, + RouteId extends string | null = string | null +> = Record>; + +/** + * When calling a form action via fetch, the response will be one of these shapes. + * ```svelte + * { + * return ({ result }) => { + * // result is of type ActionResult + * }; + * }} + * ``` + */ +export type ActionResult< + Success extends Record | undefined = Record, + Failure extends Record | undefined = Record +> = + | { type: 'success'; status: number; data?: Success } + | { type: 'failure'; status: number; data?: Failure } + | { type: 'redirect'; status: number; location: string } + | { type: 'error'; status?: number; error: any }; + +/** + * The object returned by the [`error`](https://kit.svelte.dev/docs/modules#sveltejs-kit-error) function. + */ +export interface HttpError { + /** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses), in the range 400-599. */ + status: number; + /** The content of the error. */ + body: App.Error; +} + +/** + * The object returned by the [`redirect`](https://kit.svelte.dev/docs/modules#sveltejs-kit-redirect) function + */ +export interface Redirect { + /** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages), in the range 300-308. */ + status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308; + /** The location to redirect to. */ + location: string; +} + +export type SubmitFunction< + Success extends Record | undefined = Record, + Failure extends Record | undefined = Record +> = (input: { + action: URL; + formData: FormData; + formElement: HTMLFormElement; + controller: AbortController; + submitter: HTMLElement | null; + cancel(): void; +}) => MaybePromise< + | void + | ((opts: { + formData: FormData; + formElement: HTMLFormElement; + action: URL; + result: ActionResult; + /** + * Call this to get the default behavior of a form submission response. + * @param options Set `reset: false` if you don't want the `` values to be reset after a successful submission. + * @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission. + */ + update(options?: { reset?: boolean; invalidateAll?: boolean }): Promise; + }) => void) +>; + +/** + * The type of `export const snapshot` exported from a page or layout component. + */ +export interface Snapshot { + capture: () => T; + restore: (snapshot: T) => void; +} + +export * from './index.js'; diff --git a/node_modules/@sveltejs/kit/src/exports/vite/build/build_server.js b/node_modules/@sveltejs/kit/src/exports/vite/build/build_server.js new file mode 100644 index 000000000..f13c29872 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/build/build_server.js @@ -0,0 +1,111 @@ +import fs from 'node:fs'; +import { mkdirp } from '../../../utils/filesystem.js'; +import { find_deps, resolve_symlinks } from './utils.js'; +import { s } from '../../../utils/misc.js'; +import { normalizePath } from 'vite'; + +/** + * @param {string} out + * @param {import('types').ValidatedKitConfig} kit + * @param {import('types').ManifestData} manifest_data + * @param {import('vite').Manifest} server_manifest + * @param {import('vite').Manifest | null} client_manifest + * @param {import('vite').Rollup.OutputAsset[] | null} css + */ +export function build_server_nodes(out, kit, manifest_data, server_manifest, client_manifest, css) { + mkdirp(`${out}/server/nodes`); + mkdirp(`${out}/server/stylesheets`); + + const stylesheet_lookup = new Map(); + + if (css) { + css.forEach((asset) => { + if (asset.source.length < kit.inlineStyleThreshold) { + const index = stylesheet_lookup.size; + const file = `${out}/server/stylesheets/${index}.js`; + + fs.writeFileSync(file, `// ${asset.fileName}\nexport default ${s(asset.source)};`); + stylesheet_lookup.set(asset.fileName, index); + } + }); + } + + manifest_data.nodes.forEach((node, i) => { + /** @type {string[]} */ + const imports = []; + + // String representation of + /** @type {import('types').SSRNode} */ + /** @type {string[]} */ + const exports = [`export const index = ${i};`]; + + /** @type {string[]} */ + const imported = []; + + /** @type {string[]} */ + const stylesheets = []; + + /** @type {string[]} */ + const fonts = []; + + if (node.component && client_manifest) { + exports.push( + 'let component_cache;', + `export const component = async () => component_cache ??= (await import('../${ + resolve_symlinks(server_manifest, node.component).chunk.file + }')).default;` + ); + } + + if (node.universal) { + imports.push(`import * as universal from '../${server_manifest[node.universal].file}';`); + exports.push('export { universal };'); + exports.push(`export const universal_id = ${s(node.universal)};`); + } + + if (node.server) { + imports.push(`import * as server from '../${server_manifest[node.server].file}';`); + exports.push('export { server };'); + exports.push(`export const server_id = ${s(node.server)};`); + } + + if (client_manifest && (node.universal || node.component)) { + const entry = find_deps( + client_manifest, + `${normalizePath(kit.outDir)}/generated/client-optimized/nodes/${i}.js`, + true + ); + + imported.push(...entry.imports); + stylesheets.push(...entry.stylesheets); + fonts.push(...entry.fonts); + } + + exports.push( + `export const imports = ${s(imported)};`, + `export const stylesheets = ${s(stylesheets)};`, + `export const fonts = ${s(fonts)};` + ); + + /** @type {string[]} */ + const styles = []; + + stylesheets.forEach((file) => { + if (stylesheet_lookup.has(file)) { + const index = stylesheet_lookup.get(file); + const name = `stylesheet_${index}`; + imports.push(`import ${name} from '../stylesheets/${index}.js';`); + styles.push(`\t${s(file)}: ${name}`); + } + }); + + if (styles.length > 0) { + exports.push(`export const inline_styles = () => ({\n${styles.join(',\n')}\n});`); + } + + fs.writeFileSync( + `${out}/server/nodes/${i}.js`, + `${imports.join('\n')}\n\n${exports.join('\n')}\n` + ); + }); +} diff --git a/node_modules/@sveltejs/kit/src/exports/vite/build/build_service_worker.js b/node_modules/@sveltejs/kit/src/exports/vite/build/build_service_worker.js new file mode 100644 index 000000000..3d3849c6d --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/build/build_service_worker.js @@ -0,0 +1,99 @@ +import fs from 'node:fs'; +import * as vite from 'vite'; +import { dedent } from '../../../core/sync/utils.js'; +import { s } from '../../../utils/misc.js'; +import { get_config_aliases } from '../utils.js'; + +/** + * @param {string} out + * @param {import('types').ValidatedKitConfig} kit + * @param {import('vite').ResolvedConfig} vite_config + * @param {import('types').ManifestData} manifest_data + * @param {string} service_worker_entry_file + * @param {import('types').Prerendered} prerendered + * @param {import('vite').Manifest} client_manifest + */ +export async function build_service_worker( + out, + kit, + vite_config, + manifest_data, + service_worker_entry_file, + prerendered, + client_manifest +) { + const build = new Set(); + for (const key in client_manifest) { + const { file, css = [], assets = [] } = client_manifest[key]; + build.add(file); + css.forEach((file) => build.add(file)); + assets.forEach((file) => build.add(file)); + } + + const service_worker = `${kit.outDir}/generated/service-worker.js`; + + // in a service worker, `location` is the location of the service worker itself, + // which is guaranteed to be `/service-worker.js` + const base = "location.pathname.split('/').slice(0, -1).join('/')"; + + fs.writeFileSync( + service_worker, + dedent` + export const base = /*@__PURE__*/ ${base}; + + export const build = [ + ${Array.from(build) + .map((file) => `base + ${s(`/${file}`)}`) + .join(',\n')} + ]; + + export const files = [ + ${manifest_data.assets + .filter((asset) => kit.serviceWorker.files(asset.file)) + .map((asset) => `base + ${s(`/${asset.file}`)}`) + .join(',\n')} + ]; + + export const prerendered = [ + ${prerendered.paths.map((path) => `base + ${s(path.replace(kit.paths.base, ''))}`).join(',\n')} + ]; + + export const version = ${s(kit.version.name)}; + ` + ); + + await vite.build({ + build: { + modulePreload: false, + rollupOptions: { + input: { + 'service-worker': service_worker_entry_file + }, + output: { + // .mjs so that esbuild doesn't incorrectly inject `export` https://github.com/vitejs/vite/issues/15379 + entryFileNames: 'service-worker.mjs', + assetFileNames: `${kit.appDir}/immutable/assets/[name].[hash][extname]`, + inlineDynamicImports: true + } + }, + outDir: `${out}/client`, + emptyOutDir: false + }, + configFile: false, + define: vite_config.define, + publicDir: false, + resolve: { + alias: [...get_config_aliases(kit), { find: '$service-worker', replacement: service_worker }] + }, + experimental: { + renderBuiltUrl(filename) { + return { + runtime: `new URL(${JSON.stringify(filename)}, location.href).pathname` + }; + } + } + }); + + // rename .mjs to .js to avoid incorrect MIME types with ancient webservers + fs.renameSync(`${out}/client/service-worker.mjs`, `${out}/client/service-worker.js`); +} diff --git a/node_modules/@sveltejs/kit/src/exports/vite/build/utils.js b/node_modules/@sveltejs/kit/src/exports/vite/build/utils.js new file mode 100644 index 000000000..7c12c1e21 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/build/utils.js @@ -0,0 +1,103 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { normalizePath } from 'vite'; + +/** + * Adds transitive JS and CSS dependencies to the js and css inputs. + * @param {import('vite').Manifest} manifest + * @param {string} entry + * @param {boolean} add_dynamic_css + * @returns {import('types').AssetDependencies} + */ +export function find_deps(manifest, entry, add_dynamic_css) { + /** @type {Set} */ + const seen = new Set(); + + /** @type {Set} */ + const imports = new Set(); + + /** @type {Set} */ + const stylesheets = new Set(); + + /** @type {Set} */ + const fonts = new Set(); + + /** + * @param {string} current + * @param {boolean} add_js + */ + function traverse(current, add_js) { + if (seen.has(current)) return; + seen.add(current); + + const { chunk } = resolve_symlinks(manifest, current); + + if (add_js) imports.add(chunk.file); + + if (chunk.assets) { + for (const asset of chunk.assets) { + if (/\.(woff2?|ttf|otf)$/.test(asset)) { + fonts.add(asset); + } + } + } + + if (chunk.css) { + chunk.css.forEach((file) => stylesheets.add(file)); + } + + if (chunk.imports) { + chunk.imports.forEach((file) => traverse(file, add_js)); + } + + if (add_dynamic_css && chunk.dynamicImports) { + chunk.dynamicImports.forEach((file) => traverse(file, false)); + } + } + + const { chunk, file } = resolve_symlinks(manifest, entry); + + traverse(file, true); + + return { + file: chunk.file, + imports: Array.from(imports), + stylesheets: Array.from(stylesheets), + fonts: Array.from(fonts) + }; +} + +/** + * @param {import('vite').Manifest} manifest + * @param {string} file + */ +export function resolve_symlinks(manifest, file) { + while (!manifest[file]) { + const next = normalizePath(path.relative('.', fs.realpathSync(file))); + if (next === file) throw new Error(`Could not find file "${file}" in Vite manifest`); + file = next; + } + + const chunk = manifest[file]; + + return { chunk, file }; +} + +const method_names = new Set(['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'OPTIONS']); + +// If we'd written this in TypeScript, it could be easy... +/** + * @param {string} str + * @returns {str is import('types').HttpMethod} + */ +export function is_http_method(str) { + return method_names.has(str); +} + +/** + * @param {import('types').ValidatedKitConfig} config + * @returns {string} + */ +export function assets_base(config) { + return (config.paths.assets || config.paths.base || '.') + '/'; +} diff --git a/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js b/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js new file mode 100644 index 000000000..a80b34447 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js @@ -0,0 +1,603 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { URL } from 'node:url'; +import colors from 'kleur'; +import sirv from 'sirv'; +import { isCSSRequest, loadEnv, buildErrorMessage } from 'vite'; +import { getRequest, setResponse } from '../../../exports/node/index.js'; +import { installPolyfills } from '../../../exports/node/polyfills.js'; +import { coalesce_to_error } from '../../../utils/error.js'; +import { posixify, resolve_entry, to_fs } from '../../../utils/filesystem.js'; +import { load_error_page } from '../../../core/config/index.js'; +import { SVELTE_KIT_ASSETS } from '../../../constants.js'; +import * as sync from '../../../core/sync/sync.js'; +import { get_mime_lookup, runtime_base } from '../../../core/utils.js'; +import { compact } from '../../../utils/array.js'; +import { not_found } from '../utils.js'; +import { SCHEME } from '../../../utils/url.js'; + +const cwd = process.cwd(); + +/** + * @param {import('vite').ViteDevServer} vite + * @param {import('vite').ResolvedConfig} vite_config + * @param {import('types').ValidatedConfig} svelte_config + * @return {Promise void>>} + */ +export async function dev(vite, vite_config, svelte_config) { + installPolyfills(); + + const fetch = globalThis.fetch; + globalThis.fetch = (info, init) => { + if (typeof info === 'string' && !SCHEME.test(info)) { + throw new Error( + `Cannot use relative URL (${info}) with global fetch — use \`event.fetch\` instead: https://kit.svelte.dev/docs/web-standards#fetch-apis` + ); + } + + return fetch(info, init); + }; + + sync.init(svelte_config, vite_config.mode); + + /** @type {import('types').ManifestData} */ + let manifest_data; + /** @type {import('@sveltejs/kit').SSRManifest} */ + let manifest; + + /** @type {Error | null} */ + let manifest_error = null; + + /** @param {string} url */ + async function loud_ssr_load_module(url) { + try { + return await vite.ssrLoadModule(url, { fixStacktrace: true }); + } catch (/** @type {any} */ err) { + const msg = buildErrorMessage(err, [colors.red(`Internal server error: ${err.message}`)]); + + if (!vite.config.logger.hasErrorLogged(err)) { + vite.config.logger.error(msg, { error: err }); + } + + vite.ws.send({ + type: 'error', + err: { + ...err, + // these properties are non-enumerable and will + // not be serialized unless we explicitly include them + message: err.message, + stack: err.stack + } + }); + + throw err; + } + } + + /** @param {string} id */ + async function resolve(id) { + const url = id.startsWith('..') ? `/@fs${path.posix.resolve(id)}` : `/${id}`; + + const module = await loud_ssr_load_module(url); + + const module_node = await vite.moduleGraph.getModuleByUrl(url); + if (!module_node) throw new Error(`Could not find node for ${url}`); + + return { module, module_node, url }; + } + + async function update_manifest() { + try { + ({ manifest_data } = await sync.create(svelte_config)); + + if (manifest_error) { + manifest_error = null; + vite.ws.send({ type: 'full-reload' }); + } + } catch (error) { + manifest_error = /** @type {Error} */ (error); + + console.error(colors.bold().red(manifest_error.message)); + vite.ws.send({ + type: 'error', + err: { + message: manifest_error.message ?? 'Invalid routes', + stack: '' + } + }); + + return; + } + + manifest = { + appDir: svelte_config.kit.appDir, + appPath: svelte_config.kit.appDir, + assets: new Set(manifest_data.assets.map((asset) => asset.file)), + mimeTypes: get_mime_lookup(manifest_data), + _: { + client: { + start: `${runtime_base}/client/start.js`, + app: `${to_fs(svelte_config.kit.outDir)}/generated/client/app.js`, + imports: [], + stylesheets: [], + fonts: [], + uses_env_dynamic_public: true + }, + nodes: manifest_data.nodes.map((node, index) => { + return async () => { + /** @type {import('types').SSRNode} */ + const result = {}; + + /** @type {import('vite').ModuleNode[]} */ + const module_nodes = []; + + result.index = index; + + // these are unused in dev, it's easier to include them + result.imports = []; + result.stylesheets = []; + result.fonts = []; + + if (node.component) { + result.component = async () => { + const { module_node, module } = await resolve( + /** @type {string} */ (node.component) + ); + + module_nodes.push(module_node); + + return module.default; + }; + } + + if (node.universal) { + const { module, module_node } = await resolve(node.universal); + + module_nodes.push(module_node); + + result.universal = module; + result.universal_id = node.universal; + } + + if (node.server) { + const { module } = await resolve(node.server); + result.server = module; + result.server_id = node.server; + } + + // in dev we inline all styles to avoid FOUC. this gets populated lazily so that + // components/stylesheets loaded via import() during `load` are included + result.inline_styles = async () => { + const deps = new Set(); + + for (const module_node of module_nodes) { + await find_deps(vite, module_node, deps); + } + + /** @type {Record} */ + const styles = {}; + + for (const dep of deps) { + const url = new URL(dep.url, 'dummy:/'); + const query = url.searchParams; + + if ( + (isCSSRequest(dep.file) || + (query.has('svelte') && query.get('type') === 'style')) && + !(query.has('raw') || query.has('url') || query.has('inline')) + ) { + try { + query.set('inline', ''); + const mod = await vite.ssrLoadModule( + `${decodeURI(url.pathname)}${url.search}${url.hash}` + ); + styles[dep.url] = mod.default; + } catch { + // this can happen with dynamically imported modules, I think + // because the Vite module graph doesn't distinguish between + // static and dynamic imports? TODO investigate, submit fix + } + } + } + + return styles; + }; + + return result; + }; + }), + routes: compact( + manifest_data.routes.map((route) => { + if (!route.page && !route.endpoint) return null; + + const endpoint = route.endpoint; + + return { + id: route.id, + pattern: route.pattern, + params: route.params, + page: route.page, + endpoint: endpoint + ? async () => { + const url = path.resolve(cwd, endpoint.file); + return await loud_ssr_load_module(url); + } + : null, + endpoint_id: endpoint?.file + }; + }) + ), + matchers: async () => { + /** @type {Record} */ + const matchers = {}; + + for (const key in manifest_data.matchers) { + const file = manifest_data.matchers[key]; + const url = path.resolve(cwd, file); + const module = await vite.ssrLoadModule(url, { fixStacktrace: true }); + + if (module.match) { + matchers[key] = module.match; + } else { + throw new Error(`${file} does not export a \`match\` function`); + } + } + + return matchers; + } + } + }; + } + + /** @param {Error} error */ + function fix_stack_trace(error) { + vite.ssrFixStacktrace(error); + return error.stack; + } + + await update_manifest(); + + /** + * @param {string} event + * @param {(file: string) => void} cb + */ + const watch = (event, cb) => { + vite.watcher.on(event, (file) => { + if ( + file.startsWith(svelte_config.kit.files.routes + path.sep) || + file.startsWith(svelte_config.kit.files.params + path.sep) || + // in contrast to server hooks, client hooks are written to the client manifest + // and therefore need rebuilding when they are added/removed + file.startsWith(svelte_config.kit.files.hooks.client) + ) { + cb(file); + } + }); + }; + /** @type {NodeJS.Timeout | null } */ + let timeout = null; + /** @param {() => void} to_run */ + const debounce = (to_run) => { + timeout && clearTimeout(timeout); + timeout = setTimeout(() => { + timeout = null; + to_run(); + }, 100); + }; + + // flag to skip watchers if server is already restarting + let restarting = false; + + // Debounce add/unlink events because in case of folder deletion or moves + // they fire in rapid succession, causing needless invocations. + watch('add', () => debounce(update_manifest)); + watch('unlink', () => debounce(update_manifest)); + watch('change', (file) => { + // Don't run for a single file if the whole manifest is about to get updated + if (timeout || restarting) return; + + sync.update(svelte_config, manifest_data, file); + }); + + const { appTemplate, errorTemplate, serviceWorker, hooks } = svelte_config.kit.files; + + // vite client only executes a full reload if the triggering html file path is index.html + // kit defaults to src/app.html, so unless user changed that to index.html + // send the vite client a full-reload event without path being set + if (appTemplate !== 'index.html') { + vite.watcher.on('change', (file) => { + if (file === appTemplate && !restarting) { + vite.ws.send({ type: 'full-reload' }); + } + }); + } + + vite.watcher.on('all', (_, file) => { + if ( + file === appTemplate || + file === errorTemplate || + file.startsWith(serviceWorker) || + file.startsWith(hooks.server) + ) { + sync.server(svelte_config); + } + }); + + // changing the svelte config requires restarting the dev server + // the config is only read on start and passed on to vite-plugin-svelte + // which needs up-to-date values to operate correctly + vite.watcher.on('change', (file) => { + if (path.basename(file) === 'svelte.config.js') { + console.log(`svelte config changed, restarting vite dev-server. changed file: ${file}`); + restarting = true; + vite.restart(); + } + }); + + const assets = svelte_config.kit.paths.assets ? SVELTE_KIT_ASSETS : svelte_config.kit.paths.base; + const asset_server = sirv(svelte_config.kit.files.assets, { + dev: true, + etag: true, + maxAge: 0, + extensions: [], + setHeaders: (res) => { + res.setHeader('access-control-allow-origin', '*'); + } + }); + + async function align_exports() { + // This shameful hack allows us to load runtime server code via Vite + // while apps load `HttpError` and `Redirect` in Node, without + // causing `instanceof` checks to fail + const control_module_node = await import('../../../runtime/control.js'); + const control_module_vite = await vite.ssrLoadModule(`${runtime_base}/control.js`); + + control_module_node.replace_implementations({ + ActionFailure: control_module_vite.ActionFailure, + HttpError: control_module_vite.HttpError, + Redirect: control_module_vite.Redirect, + SvelteKitError: control_module_vite.SvelteKitError + }); + } + align_exports(); + const ws_send = vite.ws.send; + /** @param {any} args */ + vite.ws.send = function (...args) { + // We need to reapply the patch after Vite did dependency optimizations + // because that clears the module resolutions + if (args[0]?.type === 'full-reload' && args[0].path === '*') { + align_exports(); + } + return ws_send.apply(vite.ws, args); + }; + + vite.middlewares.use(async (req, res, next) => { + try { + const base = `${vite.config.server.https ? 'https' : 'http'}://${ + req.headers[':authority'] || req.headers.host + }`; + + const decoded = decodeURI(new URL(base + req.url).pathname); + + if (decoded.startsWith(assets)) { + const pathname = decoded.slice(assets.length); + const file = svelte_config.kit.files.assets + pathname; + + if (fs.existsSync(file) && !fs.statSync(file).isDirectory()) { + if (has_correct_case(file, svelte_config.kit.files.assets)) { + req.url = encodeURI(pathname); // don't need query/hash + asset_server(req, res); + return; + } + } + } + + next(); + } catch (e) { + const error = coalesce_to_error(e); + res.statusCode = 500; + res.end(fix_stack_trace(error)); + } + }); + + const env = loadEnv(vite_config.mode, svelte_config.kit.env.dir, ''); + + return () => { + const serve_static_middleware = vite.middlewares.stack.find( + (middleware) => + /** @type {function} */ (middleware.handle).name === 'viteServeStaticMiddleware' + ); + + // Vite will give a 403 on URLs like /test, /static, and /package.json preventing us from + // serving routes with those names. See https://github.com/vitejs/vite/issues/7363 + remove_static_middlewares(vite.middlewares); + + vite.middlewares.use(async (req, res) => { + // Vite's base middleware strips out the base path. Restore it + const original_url = req.url; + req.url = req.originalUrl; + try { + const base = `${vite.config.server.https ? 'https' : 'http'}://${ + req.headers[':authority'] || req.headers.host + }`; + + const decoded = decodeURI(new URL(base + req.url).pathname); + const file = posixify(path.resolve(decoded.slice(svelte_config.kit.paths.base.length + 1))); + const is_file = fs.existsSync(file) && !fs.statSync(file).isDirectory(); + const allowed = + !vite_config.server.fs.strict || + vite_config.server.fs.allow.some((dir) => file.startsWith(dir)); + + if (is_file && allowed) { + req.url = original_url; + // @ts-expect-error + serve_static_middleware.handle(req, res); + return; + } + + if (!decoded.startsWith(svelte_config.kit.paths.base)) { + return not_found(req, res, svelte_config.kit.paths.base); + } + + if (decoded === svelte_config.kit.paths.base + '/service-worker.js') { + const resolved = resolve_entry(svelte_config.kit.files.serviceWorker); + + if (resolved) { + res.writeHead(200, { + 'content-type': 'application/javascript' + }); + res.end(`import '${to_fs(resolved)}';`); + } else { + res.writeHead(404); + res.end('not found'); + } + + return; + } + + // we have to import `Server` before calling `set_assets` + const { Server } = /** @type {import('types').ServerModule} */ ( + await vite.ssrLoadModule(`${runtime_base}/server/index.js`, { fixStacktrace: true }) + ); + + const { set_fix_stack_trace } = await vite.ssrLoadModule( + `${runtime_base}/shared-server.js` + ); + set_fix_stack_trace(fix_stack_trace); + + const { set_assets } = await vite.ssrLoadModule('__sveltekit/paths'); + set_assets(assets); + + const server = new Server(manifest); + + await server.init({ env }); + + const request = await getRequest({ + base, + request: req + }); + + if (manifest_error) { + console.error(colors.bold().red(manifest_error.message)); + + const error_page = load_error_page(svelte_config); + + /** @param {{ status: number; message: string }} opts */ + const error_template = ({ status, message }) => { + return error_page + .replace(/%sveltekit\.status%/g, String(status)) + .replace(/%sveltekit\.error\.message%/g, message); + }; + + res.writeHead(500, { + 'Content-Type': 'text/html; charset=utf-8' + }); + res.end( + error_template({ status: 500, message: manifest_error.message ?? 'Invalid routes' }) + ); + + return; + } + + const rendered = await server.respond(request, { + getClientAddress: () => { + const { remoteAddress } = req.socket; + if (remoteAddress) return remoteAddress; + throw new Error('Could not determine clientAddress'); + }, + read: (file) => fs.readFileSync(path.join(svelte_config.kit.files.assets, file)) + }); + + if (rendered.status === 404) { + // @ts-expect-error + serve_static_middleware.handle(req, res, () => { + setResponse(res, rendered); + }); + } else { + setResponse(res, rendered); + } + } catch (e) { + const error = coalesce_to_error(e); + res.statusCode = 500; + res.end(fix_stack_trace(error)); + } + }); + }; +} + +/** + * @param {import('connect').Server} server + */ +function remove_static_middlewares(server) { + const static_middlewares = ['viteServeStaticMiddleware', 'viteServePublicMiddleware']; + for (let i = server.stack.length - 1; i > 0; i--) { + // @ts-expect-error using internals + if (static_middlewares.includes(server.stack[i].handle.name)) { + server.stack.splice(i, 1); + } + } +} + +/** + * @param {import('vite').ViteDevServer} vite + * @param {import('vite').ModuleNode} node + * @param {Set} deps + */ +async function find_deps(vite, node, deps) { + // since `ssrTransformResult.deps` contains URLs instead of `ModuleNode`s, this process is asynchronous. + // instead of using `await`, we resolve all branches in parallel. + /** @type {Promise[]} */ + const branches = []; + + /** @param {import('vite').ModuleNode} node */ + async function add(node) { + if (!deps.has(node)) { + deps.add(node); + await find_deps(vite, node, deps); + } + } + + /** @param {string} url */ + async function add_by_url(url) { + const node = await vite.moduleGraph.getModuleByUrl(url); + + if (node) { + await add(node); + } + } + + if (node.ssrTransformResult) { + if (node.ssrTransformResult.deps) { + node.ssrTransformResult.deps.forEach((url) => branches.push(add_by_url(url))); + } + + if (node.ssrTransformResult.dynamicDeps) { + node.ssrTransformResult.dynamicDeps.forEach((url) => branches.push(add_by_url(url))); + } + } else { + node.importedModules.forEach((node) => branches.push(add(node))); + } + + await Promise.all(branches); +} + +/** + * Determine if a file is being requested with the correct case, + * to ensure consistent behaviour between dev and prod and across + * operating systems. Note that we can't use realpath here, + * because we don't want to follow symlinks + * @param {string} file + * @param {string} assets + * @returns {boolean} + */ +function has_correct_case(file, assets) { + if (file === assets) return true; + + const parent = path.dirname(file); + + if (fs.readdirSync(parent).includes(path.basename(file))) { + return has_correct_case(parent, assets); + } + + return false; +} diff --git a/node_modules/@sveltejs/kit/src/exports/vite/graph_analysis/index.js b/node_modules/@sveltejs/kit/src/exports/vite/graph_analysis/index.js new file mode 100644 index 000000000..7ab7cd3cd --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/graph_analysis/index.js @@ -0,0 +1,105 @@ +import path from 'node:path'; +import { posixify } from '../../../utils/filesystem.js'; +import { strip_virtual_prefix } from '../utils.js'; +import { env_dynamic_private, env_static_private } from '../module_ids.js'; + +const ILLEGAL_IMPORTS = new Set([env_dynamic_private, env_static_private]); +const ILLEGAL_MODULE_NAME_PATTERN = /.*\.server\..+/; + +/** + * Checks if given id imports a module that is not allowed to be imported into client-side code. + * @param {string} id + * @param {{ + * cwd: string; + * node_modules: string; + * server: string; + * }} dirs + */ +export function is_illegal(id, dirs) { + if (ILLEGAL_IMPORTS.has(id)) return true; + if (!id.startsWith(dirs.cwd) || id.startsWith(dirs.node_modules)) return false; + return ILLEGAL_MODULE_NAME_PATTERN.test(path.basename(id)) || id.startsWith(dirs.server); +} + +/** + * Creates a guard that checks that no id imports a module that is not allowed to be imported into client-side code. + * @param {import('vite').Rollup.PluginContext} context + * @param {{ cwd: string; lib: string }} paths + */ +export function module_guard(context, { cwd, lib }) { + /** @type {Set} */ + const seen = new Set(); + + const dirs = { + // ids will be posixified, so we need to posixify these, too + cwd: posixify(cwd), + node_modules: posixify(path.join(cwd, 'node_modules')), + server: posixify(path.join(lib, 'server')) + }; + + /** + * @param {string} id + * @param {Array<{ id: string; dynamic: boolean }>} chain + */ + function follow(id, chain) { + if (seen.has(id)) return; + seen.add(id); + + if (is_illegal(id, dirs)) { + chain.shift(); // discard the entry point + id = normalize_id(id, lib, cwd); + + const pyramid = + chain.map(({ id, dynamic }, i) => { + id = normalize_id(id, lib, cwd); + + return `${' '.repeat(i * 2)}- ${strip_virtual_prefix(id)} ${ + dynamic ? 'dynamically imports' : 'imports' + }\n`; + }) + `${' '.repeat(chain.length)}- ${strip_virtual_prefix(id)}`; + + const message = `Cannot import ${strip_virtual_prefix( + id + )} into client-side code:\n${pyramid}`; + + throw new Error(message); + } + + const module = context.getModuleInfo(id); + + if (module) { + for (const child of module.importedIds) { + follow(child, [...chain, { id, dynamic: false }]); + } + + for (const child of module.dynamicallyImportedIds) { + follow(child, [...chain, { id, dynamic: true }]); + } + } + } + + return { + /** @param {string} id should be posixified */ + check: (id) => { + follow(id, []); + } + }; +} + +/** + * Removes cwd/lib path from the start of the id + * @param {string} id + * @param {string} lib + * @param {string} cwd + */ +export function normalize_id(id, lib, cwd) { + if (id.startsWith(lib)) { + id = id.replace(lib, '$lib'); + } + + if (id.startsWith(cwd)) { + id = path.relative(cwd, id); + } + + return posixify(id); +} diff --git a/node_modules/@sveltejs/kit/src/exports/vite/graph_analysis/types.d.ts b/node_modules/@sveltejs/kit/src/exports/vite/graph_analysis/types.d.ts new file mode 100644 index 000000000..1239fec43 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/graph_analysis/types.d.ts @@ -0,0 +1,5 @@ +export interface ImportGraph { + readonly id: string; + readonly dynamic: boolean; + readonly children: Generator; +} diff --git a/node_modules/@sveltejs/kit/src/exports/vite/graph_analysis/utils.js b/node_modules/@sveltejs/kit/src/exports/vite/graph_analysis/utils.js new file mode 100644 index 000000000..bdfa7a42b --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/graph_analysis/utils.js @@ -0,0 +1,6 @@ +const query_pattern = /\?.*$/s; + +/** @param {string} path */ +export function remove_query_from_id(path) { + return path.replace(query_pattern, ''); +} diff --git a/node_modules/@sveltejs/kit/src/exports/vite/index.js b/node_modules/@sveltejs/kit/src/exports/vite/index.js new file mode 100644 index 000000000..5d685e8ee --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/index.js @@ -0,0 +1,923 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +import { svelte } from '@sveltejs/vite-plugin-svelte'; +import colors from 'kleur'; +import * as vite from 'vite'; + +import { copy, mkdirp, posixify, read, resolve_entry, rimraf } from '../../utils/filesystem.js'; +import { create_static_module, create_dynamic_module } from '../../core/env.js'; +import * as sync from '../../core/sync/sync.js'; +import { create_assets } from '../../core/sync/create_manifest_data/index.js'; +import { runtime_directory, logger } from '../../core/utils.js'; +import { load_config } from '../../core/config/index.js'; +import { generate_manifest } from '../../core/generate_manifest/index.js'; +import { build_server_nodes } from './build/build_server.js'; +import { build_service_worker } from './build/build_service_worker.js'; +import { assets_base, find_deps } from './build/utils.js'; +import { dev } from './dev/index.js'; +import { is_illegal, module_guard, normalize_id } from './graph_analysis/index.js'; +import { preview } from './preview/index.js'; +import { get_config_aliases, get_env, strip_virtual_prefix } from './utils.js'; +import { write_client_manifest } from '../../core/sync/write_client_manifest.js'; +import prerender from '../../core/postbuild/prerender.js'; +import analyse from '../../core/postbuild/analyse.js'; +import { s } from '../../utils/misc.js'; +import { hash } from '../../runtime/hash.js'; +import { dedent, isSvelte5Plus } from '../../core/sync/utils.js'; +import { + env_dynamic_private, + env_dynamic_public, + env_static_private, + env_static_public, + service_worker, + sveltekit_environment, + sveltekit_paths +} from './module_ids.js'; + +const cwd = process.cwd(); + +/** @type {import('./types.js').EnforcedConfig} */ +const enforced_config = { + appType: true, + base: true, + build: { + cssCodeSplit: true, + emptyOutDir: true, + lib: { + entry: true, + name: true, + formats: true + }, + manifest: true, + outDir: true, + rollupOptions: { + input: true, + output: { + format: true, + entryFileNames: true, + chunkFileNames: true, + assetFileNames: true + }, + preserveEntrySignatures: true + }, + ssr: true + }, + publicDir: true, + resolve: { + alias: { + $app: true, + $lib: true, + '$service-worker': true + } + }, + root: true +}; + +const options_regex = /(export\s+const\s+(prerender|csr|ssr|trailingSlash))\s*=/s; + +/** @type {Set} */ +const warned = new Set(); + +/** @type {import('svelte/compiler').PreprocessorGroup} */ +const warning_preprocessor = { + script: ({ content, filename }) => { + if (!filename) return; + + const basename = path.basename(filename); + if (basename.startsWith('+page.') || basename.startsWith('+layout.')) { + const match = content.match(options_regex); + if (match) { + const fixed = basename.replace('.svelte', '(.server).js/ts'); + + const message = + `\n${colors.bold().red(path.relative('.', filename))}\n` + + `\`${match[1]}\` will be ignored — move it to ${fixed} instead. See https://kit.svelte.dev/docs/page-options for more information.`; + + if (!warned.has(message)) { + console.log(message); + warned.add(message); + } + } + } + }, + markup: ({ content, filename }) => { + if (!filename) return; + + const basename = path.basename(filename); + const has_children = + content.includes('\`${isSvelte5Plus() ? ' or `{@render ...}` tag' : ''}` + + ' missing — inner content will not be rendered'; + + if (!warned.has(message)) { + console.log(message); + warned.add(message); + } + } + } +}; + +/** + * Returns the SvelteKit Vite plugins. + * @returns {Promise} + */ +export async function sveltekit() { + const svelte_config = await load_config(); + + /** @type {import('@sveltejs/vite-plugin-svelte').Options['preprocess']} */ + let preprocess = svelte_config.preprocess; + if (Array.isArray(preprocess)) { + preprocess = [...preprocess, warning_preprocessor]; + } else if (preprocess) { + preprocess = [preprocess, warning_preprocessor]; + } else { + preprocess = warning_preprocessor; + } + + /** @type {import('@sveltejs/vite-plugin-svelte').Options} */ + const vite_plugin_svelte_options = { + configFile: false, + extensions: svelte_config.extensions, + preprocess, + onwarn: svelte_config.onwarn, + compilerOptions: { + // @ts-expect-error SvelteKit requires hydratable true by default + hydratable: isSvelte5Plus() ? undefined : true, + ...svelte_config.compilerOptions + }, + ...svelte_config.vitePlugin + }; + + return [...svelte(vite_plugin_svelte_options), ...kit({ svelte_config })]; +} + +// These variables live outside the `kit()` function because it is re-invoked by each Vite build + +let secondary_build_started = false; + +/** @type {import('types').ManifestData} */ +let manifest_data; + +/** + * Returns the SvelteKit Vite plugin. Vite executes Rollup hooks as well as some of its own. + * Background reading is available at: + * - https://vitejs.dev/guide/api-plugin.html + * - https://rollupjs.org/guide/en/#plugin-development + * + * You can get an idea of the lifecycle by looking at the flow charts here: + * - https://rollupjs.org/guide/en/#build-hooks + * - https://rollupjs.org/guide/en/#output-generation-hooks + * + * @param {{ svelte_config: import('types').ValidatedConfig }} options + * @return {import('vite').Plugin[]} + */ +function kit({ svelte_config }) { + const { kit } = svelte_config; + const out = `${kit.outDir}/output`; + + const version_hash = hash(kit.version.name); + + /** @type {import('vite').ResolvedConfig} */ + let vite_config; + + /** @type {import('vite').ConfigEnv} */ + let vite_config_env; + + /** @type {boolean} */ + let is_build; + + /** @type {{ public: Record; private: Record }} */ + let env; + + /** @type {() => Promise} */ + let finalise; + + /** @type {import('vite').UserConfig} */ + let initial_config; + + const service_worker_entry_file = resolve_entry(kit.files.serviceWorker); + + const sourcemapIgnoreList = /** @param {string} relative_path */ (relative_path) => + relative_path.includes('node_modules') || relative_path.includes(kit.outDir); + + /** @type {import('vite').Plugin} */ + const plugin_setup = { + name: 'vite-plugin-sveltekit-setup', + + /** + * Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file. + * @see https://vitejs.dev/guide/api-plugin.html#config + */ + async config(config, config_env) { + initial_config = config; + vite_config_env = config_env; + is_build = config_env.command === 'build'; + + env = get_env(kit.env, vite_config_env.mode); + + const allow = new Set([ + kit.files.lib, + kit.files.routes, + kit.outDir, + path.resolve('src'), // TODO this isn't correct if user changed all his files to sth else than src (like in test/options) + path.resolve('node_modules'), + path.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules') + ]); + + // We can only add directories to the allow list, so we find out + // if there's a client hooks file and pass its directory + const client_hooks = resolve_entry(kit.files.hooks.client); + if (client_hooks) allow.add(path.dirname(client_hooks)); + + const generated = path.posix.join(kit.outDir, 'generated'); + + // dev and preview config can be shared + /** @type {import('vite').UserConfig} */ + const new_config = { + resolve: { + alias: [ + { find: '__SERVER__', replacement: `${generated}/server` }, + { find: '$app', replacement: `${runtime_directory}/app` }, + ...get_config_aliases(kit) + ] + }, + root: cwd, + server: { + cors: { preflightContinue: true }, + fs: { + allow: [...allow] + }, + sourcemapIgnoreList, + watch: { + ignored: [ + // Ignore all siblings of config.kit.outDir/generated + `${posixify(kit.outDir)}/!(generated)` + ] + } + }, + preview: { + cors: { preflightContinue: true } + }, + optimizeDeps: { + exclude: [ + '@sveltejs/kit', + // exclude kit features so that libraries using them work even when they are prebundled + // this does not affect app code, just handling of imported libraries that use $app or $env + '$app', + '$env' + ] + }, + ssr: { + noExternal: [ + // This ensures that esm-env is inlined into the server output with the + // export conditions resolved correctly through Vite. This prevents adapters + // that bundle later on from resolving the export conditions incorrectly + // and for example include browser-only code in the server output + // because they for example use esbuild.build with `platform: 'browser'` + 'esm-env', + // We need this for two reasons: + // 1. Without this, `@sveltejs/kit` imports are kept as-is in the server output, + // and that causes modules and therefore classes like `Redirect` to be imported twice + // under different IDs, which breaks a bunch of stuff because of failing instanceof checks. + // 2. Vitest bypasses Vite when loading external modules, so we bundle + // when it is detected to keep our virtual modules working. + // See https://github.com/sveltejs/kit/pull/9172 + // and https://vitest.dev/config/#deps-registernodeloader + '@sveltejs/kit' + ] + } + }; + + if (is_build) { + if (!new_config.build) new_config.build = {}; + new_config.build.ssr = !secondary_build_started; + + new_config.define = { + __SVELTEKIT_ADAPTER_NAME__: s(kit.adapter?.name), + __SVELTEKIT_APP_VERSION_FILE__: s(`${kit.appDir}/version.json`), + __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: s(kit.version.pollInterval), + __SVELTEKIT_DEV__: 'false', + __SVELTEKIT_EMBEDDED__: kit.embedded ? 'true' : 'false' + }; + + if (!secondary_build_started) { + manifest_data = (await sync.all(svelte_config, config_env.mode)).manifest_data; + } + } else { + new_config.define = { + __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0', + __SVELTEKIT_DEV__: 'true', + __SVELTEKIT_EMBEDDED__: kit.embedded ? 'true' : 'false' + }; + + // These Kit dependencies are packaged as CommonJS, which means they must always be externalized. + // Without this, the tests will still pass but `pnpm dev` will fail in projects that link `@sveltejs/kit`. + /** @type {NonNullable} */ (new_config.ssr).external = [ + 'cookie', + 'set-cookie-parser' + ]; + } + + warn_overridden_config(config, new_config); + + return new_config; + }, + + /** + * Stores the final config. + */ + configResolved(config) { + vite_config = config; + } + }; + + /** @type {import('vite').Plugin} */ + const plugin_virtual_modules = { + name: 'vite-plugin-sveltekit-virtual-modules', + + async resolveId(id) { + // treat $env/static/[public|private] as virtual + if (id.startsWith('$env/') || id.startsWith('__sveltekit/') || id === '$service-worker') { + return `\0virtual:${id}`; + } + }, + + async load(id, options) { + const browser = !options?.ssr; + + const global = is_build + ? `globalThis.__sveltekit_${version_hash}` + : 'globalThis.__sveltekit_dev'; + + if (options?.ssr === false && process.env.TEST !== 'true') { + const normalized_cwd = vite.normalizePath(cwd); + const normalized_lib = vite.normalizePath(kit.files.lib); + if ( + is_illegal(id, { + cwd: normalized_cwd, + node_modules: vite.normalizePath(path.resolve('node_modules')), + server: vite.normalizePath(path.join(normalized_lib, 'server')) + }) + ) { + const relative = normalize_id(id, normalized_lib, normalized_cwd); + throw new Error(`Cannot import ${strip_virtual_prefix(relative)} into client-side code`); + } + } + + switch (id) { + case env_static_private: + return create_static_module('$env/static/private', env.private); + + case env_static_public: + return create_static_module('$env/static/public', env.public); + + case env_dynamic_private: + return create_dynamic_module( + 'private', + vite_config_env.command === 'serve' ? env.private : undefined + ); + + case env_dynamic_public: + // populate `$env/dynamic/public` from `window` + if (browser) { + return `export const env = ${global}.env ?? (await import(/* @vite-ignore */ ${global}.base + '/' + '${kit.appDir}/env.js')).env;`; + } + + return create_dynamic_module( + 'public', + vite_config_env.command === 'serve' ? env.public : undefined + ); + + case service_worker: + return create_service_worker_module(svelte_config); + + // for internal use only. it's published as $app/paths externally + // we use this alias so that we won't collide with user aliases + case sveltekit_paths: { + const { assets, base } = svelte_config.kit.paths; + + // use the values defined in `global`, but fall back to hard-coded values + // for the sake of things like Vitest which may import this module + // outside the context of a page + if (browser) { + return dedent` + export const base = ${global}?.base ?? ${s(base)}; + export const assets = ${global}?.assets ?? ${assets ? s(assets) : 'base'}; + `; + } + + return dedent` + export let base = ${s(base)}; + export let assets = ${assets ? s(assets) : 'base'}; + + export const relative = ${svelte_config.kit.paths.relative}; + + const initial = { base, assets }; + + export function override(paths) { + base = paths.base; + assets = paths.assets; + } + + export function reset() { + base = initial.base; + assets = initial.assets; + } + + /** @param {string} path */ + export function set_assets(path) { + assets = initial.assets = path; + } + `; + } + + case sveltekit_environment: { + const { version } = svelte_config.kit; + + return dedent` + export const version = ${s(version.name)}; + export let building = false; + export let prerendering = false; + + export function set_building() { + building = true; + } + + export function set_prerendering() { + prerendering = true; + } + `; + } + } + } + }; + + /** + * Ensures that client-side code can't accidentally import server-side code, + * whether in `*.server.js` files, `$lib/server`, or `$env/[static|dynamic]/private` + * @type {import('vite').Plugin} + */ + const plugin_guard = { + name: 'vite-plugin-sveltekit-guard', + + writeBundle: { + sequential: true, + async handler(_options) { + if (vite_config.build.ssr) return; + + const guard = module_guard(this, { + cwd: vite.normalizePath(process.cwd()), + lib: vite.normalizePath(kit.files.lib) + }); + + manifest_data.nodes.forEach((_node, i) => { + const id = vite.normalizePath( + path.resolve(kit.outDir, `generated/client-optimized/nodes/${i}.js`) + ); + + guard.check(id); + }); + } + } + }; + + /** @type {import('vite').Plugin} */ + const plugin_compile = { + name: 'vite-plugin-sveltekit-compile', + + /** + * Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file. + * @see https://vitejs.dev/guide/api-plugin.html#config + */ + async config(config) { + /** @type {import('vite').UserConfig} */ + let new_config; + + if (is_build) { + const ssr = /** @type {boolean} */ (config.build?.ssr); + const prefix = `${kit.appDir}/immutable`; + + /** @type {Record} */ + const input = {}; + + if (ssr) { + input.index = `${runtime_directory}/server/index.js`; + input.internal = `${kit.outDir}/generated/server/internal.js`; + + // add entry points for every endpoint... + manifest_data.routes.forEach((route) => { + if (route.endpoint) { + const resolved = path.resolve(route.endpoint.file); + const relative = decodeURIComponent(path.relative(kit.files.routes, resolved)); + const name = posixify(path.join('entries/endpoints', relative.replace(/\.js$/, ''))); + input[name] = resolved; + } + }); + + // ...and every component used by pages... + manifest_data.nodes.forEach((node) => { + for (const file of [node.component, node.universal, node.server]) { + if (file) { + const resolved = path.resolve(file); + const relative = decodeURIComponent(path.relative(kit.files.routes, resolved)); + + const name = relative.startsWith('..') + ? posixify(path.join('entries/fallbacks', path.basename(file))) + : posixify(path.join('entries/pages', relative.replace(/\.js$/, ''))); + input[name] = resolved; + } + } + }); + + // ...and every matcher + Object.entries(manifest_data.matchers).forEach(([key, file]) => { + const name = posixify(path.join('entries/matchers', key)); + input[name] = path.resolve(file); + }); + } else { + input['entry/start'] = `${runtime_directory}/client/start.js`; + input['entry/app'] = `${kit.outDir}/generated/client-optimized/app.js`; + + manifest_data.nodes.forEach((node, i) => { + if (node.component || node.universal) { + input[`nodes/${i}`] = `${kit.outDir}/generated/client-optimized/nodes/${i}.js`; + } + }); + } + + // see the kit.output.preloadStrategy option for details on why we have multiple options here + const ext = kit.output.preloadStrategy === 'preload-mjs' ? 'mjs' : 'js'; + + // We could always use a relative asset base path here, but it's better for performance not to. + // E.g. Vite generates `new URL('/asset.png', import.meta).href` for a relative path vs just '/asset.png'. + // That's larger and takes longer to run and also causes an HTML diff between SSR and client + // causing us to do a more expensive hydration check. + const client_base = + kit.paths.relative !== false || kit.paths.assets ? './' : kit.paths.base || '/'; + + new_config = { + base: ssr ? assets_base(kit) : client_base, + build: { + copyPublicDir: !ssr, + cssCodeSplit: true, + cssMinify: initial_config.build?.minify == null ? true : !!initial_config.build.minify, + // don't use the default name to avoid collisions with 'static/manifest.json' + manifest: '.vite/manifest.json', // TODO: remove this after bumping peer dep to vite 5 + outDir: `${out}/${ssr ? 'server' : 'client'}`, + rollupOptions: { + input, + output: { + format: 'esm', + entryFileNames: ssr ? '[name].js' : `${prefix}/[name].[hash].${ext}`, + chunkFileNames: ssr ? 'chunks/[name].js' : `${prefix}/chunks/[name].[hash].${ext}`, + assetFileNames: `${prefix}/assets/[name].[hash][extname]`, + hoistTransitiveImports: false, + sourcemapIgnoreList + }, + preserveEntrySignatures: 'strict' + }, + ssrEmitAssets: true, + target: ssr ? 'node18.13' : 'es2022' + }, + publicDir: kit.files.assets, + worker: { + rollupOptions: { + output: { + entryFileNames: `${prefix}/workers/[name]-[hash].js`, + chunkFileNames: `${prefix}/workers/chunks/[name]-[hash].js`, + assetFileNames: `${prefix}/workers/assets/[name]-[hash][extname]`, + hoistTransitiveImports: false + } + } + } + }; + } else { + new_config = { + appType: 'custom', + base: kit.paths.base, + build: { + rollupOptions: { + // Vite dependency crawler needs an explicit JS entry point + // eventhough server otherwise works without it + input: `${runtime_directory}/client/start.js` + } + }, + publicDir: kit.files.assets + }; + } + + warn_overridden_config(config, new_config); + + return new_config; + }, + + /** + * Adds the SvelteKit middleware to do SSR in dev mode. + * @see https://vitejs.dev/guide/api-plugin.html#configureserver + */ + async configureServer(vite) { + return await dev(vite, vite_config, svelte_config); + }, + + /** + * Adds the SvelteKit middleware to do SSR in preview mode. + * @see https://vitejs.dev/guide/api-plugin.html#configurepreviewserver + */ + configurePreviewServer(vite) { + return preview(vite, vite_config, svelte_config); + }, + + /** + * Clears the output directories. + */ + buildStart() { + if (secondary_build_started) return; + + if (is_build) { + if (!vite_config.build.watch) { + rimraf(out); + } + mkdirp(out); + } + }, + + generateBundle() { + if (vite_config.build.ssr) return; + + this.emitFile({ + type: 'asset', + fileName: `${kit.appDir}/version.json`, + source: s({ version: kit.version.name }) + }); + }, + + /** + * Vite builds a single bundle. We need three bundles: client, server, and service worker. + * The user's package.json scripts will invoke the Vite CLI to execute the server build. We + * then use this hook to kick off builds for the client and service worker. + */ + writeBundle: { + sequential: true, + async handler(_options) { + if (secondary_build_started) return; // only run this once + + const verbose = vite_config.logLevel === 'info'; + const log = logger({ verbose }); + + /** @type {import('vite').Manifest} */ + const server_manifest = JSON.parse(read(`${out}/server/${vite_config.build.manifest}`)); + + /** @type {import('types').BuildData} */ + const build_data = { + app_dir: kit.appDir, + app_path: `${kit.paths.base.slice(1)}${kit.paths.base ? '/' : ''}${kit.appDir}`, + manifest_data, + service_worker: service_worker_entry_file ? 'service-worker.js' : null, // TODO make file configurable? + client: null, + server_manifest + }; + + const manifest_path = `${out}/server/manifest-full.js`; + fs.writeFileSync( + manifest_path, + `export const manifest = ${generate_manifest({ + build_data, + relative_path: '.', + routes: manifest_data.routes + })};\n` + ); + + // first, build server nodes without the client manifest so we can analyse it + log.info('Analysing routes'); + + build_server_nodes(out, kit, manifest_data, server_manifest, null, null); + + const metadata = await analyse({ + manifest_path, + env: { ...env.private, ...env.public } + }); + + log.info('Building app'); + + // create client build + write_client_manifest( + kit, + manifest_data, + `${kit.outDir}/generated/client-optimized`, + metadata.nodes + ); + + secondary_build_started = true; + + const { output } = /** @type {import('vite').Rollup.RollupOutput} */ ( + await vite.build({ + configFile: vite_config.configFile, + // CLI args + mode: vite_config_env.mode, + logLevel: vite_config.logLevel, + clearScreen: vite_config.clearScreen, + build: { + minify: initial_config.build?.minify, + assetsInlineLimit: vite_config.build.assetsInlineLimit, + sourcemap: vite_config.build.sourcemap + }, + optimizeDeps: { + force: vite_config.optimizeDeps.force + } + }) + ); + + copy( + `${out}/server/${kit.appDir}/immutable/assets`, + `${out}/client/${kit.appDir}/immutable/assets` + ); + + /** @type {import('vite').Manifest} */ + const client_manifest = JSON.parse(read(`${out}/client/${vite_config.build.manifest}`)); + + const deps_of = /** @param {string} f */ (f) => + find_deps(client_manifest, posixify(path.relative('.', f)), false); + const start = deps_of(`${runtime_directory}/client/start.js`); + const app = deps_of(`${kit.outDir}/generated/client-optimized/app.js`); + + build_data.client = { + start: start.file, + app: app.file, + imports: [...start.imports, ...app.imports], + stylesheets: [...start.stylesheets, ...app.stylesheets], + fonts: [...start.fonts, ...app.fonts], + uses_env_dynamic_public: output.some( + (chunk) => chunk.type === 'chunk' && chunk.modules[env_dynamic_public] + ) + }; + + const css = output.filter( + /** @type {(value: any) => value is import('vite').Rollup.OutputAsset} */ + (value) => value.type === 'asset' && value.fileName.endsWith('.css') + ); + + // regenerate manifest now that we have client entry... + fs.writeFileSync( + manifest_path, + `export const manifest = ${generate_manifest({ + build_data, + relative_path: '.', + routes: manifest_data.routes + })};\n` + ); + + // regenerate nodes with the client manifest... + build_server_nodes(out, kit, manifest_data, server_manifest, client_manifest, css); + + // ...and prerender + const { prerendered, prerender_map } = await prerender({ + out, + manifest_path, + metadata, + verbose, + env: { ...env.private, ...env.public } + }); + + // generate a new manifest that doesn't include prerendered pages + fs.writeFileSync( + `${out}/server/manifest.js`, + `export const manifest = ${generate_manifest({ + build_data, + relative_path: '.', + routes: manifest_data.routes.filter((route) => prerender_map.get(route.id) !== true) + })};\n` + ); + + if (service_worker_entry_file) { + if (kit.paths.assets) { + throw new Error('Cannot use service worker alongside config.kit.paths.assets'); + } + + log.info('Building service worker'); + + await build_service_worker( + out, + kit, + vite_config, + manifest_data, + service_worker_entry_file, + prerendered, + client_manifest + ); + } + + // we need to defer this to closeBundle, so that adapters copy files + // created by other Vite plugins + finalise = async () => { + console.log( + `\nRun ${colors + .bold() + .cyan('npm run preview')} to preview your production build locally.` + ); + + if (kit.adapter) { + const { adapt } = await import('../../core/adapt/index.js'); + await adapt( + svelte_config, + build_data, + metadata, + prerendered, + prerender_map, + log, + vite_config + ); + } else { + console.log(colors.bold().yellow('\nNo adapter specified')); + + const link = colors.bold().cyan('https://kit.svelte.dev/docs/adapters'); + console.log( + `See ${link} to learn how to configure your app to run on the platform of your choosing` + ); + } + + secondary_build_started = false; + }; + } + }, + + /** + * Runs the adapter. + */ + closeBundle: { + sequential: true, + async handler() { + if (!vite_config.build.ssr) return; + await finalise?.(); + } + } + }; + + return [plugin_setup, plugin_virtual_modules, plugin_guard, plugin_compile]; +} + +/** + * @param {Record} config + * @param {Record} resolved_config + */ +function warn_overridden_config(config, resolved_config) { + const overridden = find_overridden_config(config, resolved_config, enforced_config, '', []); + + if (overridden.length > 0) { + console.error( + colors.bold().red('The following Vite config options will be overridden by SvelteKit:') + + overridden.map((key) => `\n - ${key}`).join('') + ); + } +} + +/** + * @param {Record} config + * @param {Record} resolved_config + * @param {import('./types.js').EnforcedConfig} enforced_config + * @param {string} path + * @param {string[]} out used locally to compute the return value + */ +function find_overridden_config(config, resolved_config, enforced_config, path, out) { + if (config == null || resolved_config == null) { + return out; + } + + for (const key in enforced_config) { + if (typeof config === 'object' && key in config && key in resolved_config) { + const enforced = enforced_config[key]; + + if (enforced === true) { + if (config[key] !== resolved_config[key]) { + out.push(path + key); + } + } else { + find_overridden_config(config[key], resolved_config[key], enforced, path + key + '.', out); + } + } + } + return out; +} + +/** + * @param {import('types').ValidatedConfig} config + */ +const create_service_worker_module = (config) => dedent` + if (typeof self === 'undefined' || self instanceof ServiceWorkerGlobalScope === false) { + throw new Error('This module can only be imported inside a service worker'); + } + + export const build = []; + export const files = [ + ${create_assets(config) + .filter((asset) => config.kit.serviceWorker.files(asset.file)) + .map((asset) => `${s(`${config.kit.paths.base}/${asset.file}`)}`) + .join(',\n')} + ]; + export const prerendered = []; + export const version = ${s(config.kit.version.name)}; +`; diff --git a/node_modules/@sveltejs/kit/src/exports/vite/module_ids.js b/node_modules/@sveltejs/kit/src/exports/vite/module_ids.js new file mode 100644 index 000000000..a6097f5b6 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/module_ids.js @@ -0,0 +1,7 @@ +export const env_static_private = '\0virtual:$env/static/private'; +export const env_static_public = '\0virtual:$env/static/public'; +export const env_dynamic_private = '\0virtual:$env/dynamic/private'; +export const env_dynamic_public = '\0virtual:$env/dynamic/public'; +export const service_worker = '\0virtual:$service-worker'; +export const sveltekit_paths = '\0virtual:__sveltekit/paths'; +export const sveltekit_environment = '\0virtual:__sveltekit/environment'; diff --git a/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js b/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js new file mode 100644 index 000000000..997922bb5 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js @@ -0,0 +1,237 @@ +import fs from 'node:fs'; +import { join } from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { lookup } from 'mrmime'; +import sirv from 'sirv'; +import { loadEnv, normalizePath } from 'vite'; +import { getRequest, setResponse } from '../../../exports/node/index.js'; +import { installPolyfills } from '../../../exports/node/polyfills.js'; +import { SVELTE_KIT_ASSETS } from '../../../constants.js'; +import { not_found } from '../utils.js'; + +/** @typedef {import('http').IncomingMessage} Req */ +/** @typedef {import('http').ServerResponse} Res */ +/** @typedef {(req: Req, res: Res, next: () => void) => void} Handler */ + +/** + * @param {{ middlewares: import('connect').Server }} vite + * @param {import('vite').ResolvedConfig} vite_config + * @param {import('types').ValidatedConfig} svelte_config + */ +export async function preview(vite, vite_config, svelte_config) { + installPolyfills(); + + const { paths } = svelte_config.kit; + const base = paths.base; + const assets = paths.assets ? SVELTE_KIT_ASSETS : paths.base; + + const protocol = vite_config.preview.https ? 'https' : 'http'; + + const etag = `"${Date.now()}"`; + + const dir = join(svelte_config.kit.outDir, 'output/server'); + + if (!fs.existsSync(dir)) { + throw new Error(`Server files not found at ${dir}, did you run \`build\` first?`); + } + + /** @type {import('types').ServerInternalModule} */ + const { set_assets } = await import(pathToFileURL(join(dir, 'internal.js')).href); + + /** @type {import('types').ServerModule} */ + const { Server } = await import(pathToFileURL(join(dir, 'index.js')).href); + + const { manifest } = await import(pathToFileURL(join(dir, 'manifest.js')).href); + + set_assets(assets); + + const server = new Server(manifest); + await server.init({ + env: loadEnv(vite_config.mode, svelte_config.kit.env.dir, '') + }); + + return () => { + // Remove the base middleware. It screws with the URL. + // It also only lets through requests beginning with the base path, so that requests beginning + // with the assets URL never reach us. We could serve assets separately before the base + // middleware, but we'd need that to occur after the compression and cors middlewares, so would + // need to insert it manually into the stack, which would be at least as bad as doing this. + for (let i = vite.middlewares.stack.length - 1; i > 0; i--) { + // @ts-expect-error using internals + if (vite.middlewares.stack[i].handle.name === 'viteBaseMiddleware') { + vite.middlewares.stack.splice(i, 1); + } + } + + // generated client assets and the contents of `static` + vite.middlewares.use( + scoped( + assets, + sirv(join(svelte_config.kit.outDir, 'output/client'), { + setHeaders: (res, pathname) => { + // only apply to immutable directory, not e.g. version.json + if (pathname.startsWith(`/${svelte_config.kit.appDir}/immutable`)) { + res.setHeader('cache-control', 'public,max-age=31536000,immutable'); + } + } + }) + ) + ); + + vite.middlewares.use((req, res, next) => { + const original_url = /** @type {string} */ (req.url); + const { pathname, search } = new URL(original_url, 'http://dummy'); + + // if `paths.base === '/a/b/c`, then the root route is `/a/b/c/`, + // regardless of the `trailingSlash` route option + if (base.length > 1 && pathname === base) { + let location = base + '/'; + if (search) location += search; + res.writeHead(307, { + location + }); + res.end(); + return; + } + + if (pathname.startsWith(base)) { + next(); + } else { + res.statusCode = 404; + not_found(req, res, base); + } + }); + + // prerendered dependencies + vite.middlewares.use( + scoped(base, mutable(join(svelte_config.kit.outDir, 'output/prerendered/dependencies'))) + ); + + // prerendered pages (we can't just use sirv because we need to + // preserve the correct trailingSlash behaviour) + vite.middlewares.use( + scoped(base, (req, res, next) => { + let if_none_match_value = req.headers['if-none-match']; + + if (if_none_match_value?.startsWith('W/"')) { + if_none_match_value = if_none_match_value.substring(2); + } + + if (if_none_match_value === etag) { + res.statusCode = 304; + res.end(); + return; + } + + const { pathname, search } = new URL(/** @type {string} */ (req.url), 'http://dummy'); + + let filename = normalizePath( + join(svelte_config.kit.outDir, 'output/prerendered/pages' + pathname) + ); + let prerendered = is_file(filename); + + if (!prerendered) { + const has_trailing_slash = pathname.endsWith('/'); + const html_filename = `${filename}${has_trailing_slash ? 'index.html' : '.html'}`; + + /** @type {string | undefined} */ + let redirect; + + if (is_file(html_filename)) { + filename = html_filename; + prerendered = true; + } else if (has_trailing_slash) { + if (is_file(filename.slice(0, -1) + '.html')) { + redirect = pathname.slice(0, -1); + } + } else if (is_file(filename + '/index.html')) { + redirect = pathname + '/'; + } + + if (redirect) { + if (search) redirect += search; + res.writeHead(307, { + location: redirect + }); + + res.end(); + + return; + } + } + + if (prerendered) { + res.writeHead(200, { + 'content-type': lookup(pathname) || 'text/html', + etag + }); + + fs.createReadStream(filename).pipe(res); + } else { + next(); + } + }) + ); + + // SSR + vite.middlewares.use(async (req, res) => { + const host = req.headers['host']; + + const request = await getRequest({ + base: `${protocol}://${host}`, + request: req + }); + + setResponse( + res, + await server.respond(request, { + getClientAddress: () => { + const { remoteAddress } = req.socket; + if (remoteAddress) return remoteAddress; + throw new Error('Could not determine clientAddress'); + }, + read: (file) => fs.readFileSync(join(svelte_config.kit.files.assets, file)) + }) + ); + }); + }; +} + +/** + * @param {string} dir + * @returns {Handler} + */ +const mutable = (dir) => + fs.existsSync(dir) + ? sirv(dir, { + etag: true, + maxAge: 0 + }) + : (_req, _res, next) => next(); + +/** + * @param {string} scope + * @param {Handler} handler + * @returns {Handler} + */ +function scoped(scope, handler) { + if (scope === '') return handler; + + return (req, res, next) => { + if (req.url?.startsWith(scope)) { + const original_url = req.url; + req.url = req.url.slice(scope.length); + handler(req, res, () => { + req.url = original_url; + next(); + }); + } else { + next(); + } + }; +} + +/** @param {string} path */ +function is_file(path) { + return fs.existsSync(path) && !fs.statSync(path).isDirectory(); +} diff --git a/node_modules/@sveltejs/kit/src/exports/vite/types.d.ts b/node_modules/@sveltejs/kit/src/exports/vite/types.d.ts new file mode 100644 index 000000000..900aa4354 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/types.d.ts @@ -0,0 +1,3 @@ +export interface EnforcedConfig { + [key: string]: EnforcedConfig | true; +} diff --git a/node_modules/@sveltejs/kit/src/exports/vite/utils.js b/node_modules/@sveltejs/kit/src/exports/vite/utils.js new file mode 100644 index 000000000..aaa33971b --- /dev/null +++ b/node_modules/@sveltejs/kit/src/exports/vite/utils.js @@ -0,0 +1,101 @@ +import path from 'node:path'; +import { loadEnv } from 'vite'; +import { posixify } from '../../utils/filesystem.js'; +import { negotiate } from '../../utils/http.js'; +import { filter_private_env, filter_public_env } from '../../utils/env.js'; + +/** + * Transforms kit.alias to a valid vite.resolve.alias array. + * + * Related to tsconfig path alias creation. + * + * @param {import('types').ValidatedKitConfig} config + * */ +export function get_config_aliases(config) { + /** @type {import('vite').Alias[]} */ + const alias = [ + // For now, we handle `$lib` specially here rather than make it a default value for + // `config.kit.alias` since it has special meaning for packaging, etc. + { find: '$lib', replacement: config.files.lib } + ]; + + for (let [key, value] of Object.entries(config.alias)) { + value = posixify(value); + if (value.endsWith('/*')) { + value = value.slice(0, -2); + } + if (key.endsWith('/*')) { + // Doing just `{ find: key.slice(0, -2) ,..}` would mean `import .. from "key"` would also be matched, which we don't want + alias.push({ + find: new RegExp(`^${escape_for_regexp(key.slice(0, -2))}\\/(.+)$`), + replacement: `${path.resolve(value)}/$1` + }); + } else if (key + '/*' in config.alias) { + // key and key/* both exist -> the replacement for key needs to happen _only_ on import .. from "key" + alias.push({ + find: new RegExp(`^${escape_for_regexp(key)}$`), + replacement: path.resolve(value) + }); + } else { + alias.push({ find: key, replacement: path.resolve(value) }); + } + } + + return alias; +} + +/** + * @param {string} str + */ +function escape_for_regexp(str) { + return str.replace(/[.*+?^${}()|[\]\\]/g, (match) => '\\' + match); +} + +/** + * Load environment variables from process.env and .env files + * @param {import('types').ValidatedKitConfig['env']} env_config + * @param {string} mode + */ +export function get_env(env_config, mode) { + const { publicPrefix: public_prefix, privatePrefix: private_prefix } = env_config; + const env = loadEnv(mode, env_config.dir, ''); + + return { + public: filter_public_env(env, { public_prefix, private_prefix }), + private: filter_private_env(env, { public_prefix, private_prefix }) + }; +} + +/** + * @param {import('http').IncomingMessage} req + * @param {import('http').ServerResponse} res + * @param {string} base + */ +export function not_found(req, res, base) { + const type = negotiate(req.headers.accept ?? '*', ['text/plain', 'text/html']); + + // special case — handle `/` request automatically + if (req.url === '/' && type === 'text/html') { + res.statusCode = 307; + res.setHeader('location', base); + res.end(); + return; + } + + res.statusCode = 404; + + const prefixed = base + req.url; + + if (type === 'text/html') { + res.setHeader('Content-Type', 'text/html'); + res.end( + `The server is configured with a public base URL of ${base} - did you mean to visit ${prefixed} instead?` + ); + } else { + res.end( + `The server is configured with a public base URL of ${base} - did you mean to visit ${prefixed} instead?` + ); + } +} + +export const strip_virtual_prefix = /** @param {string} id */ (id) => id.replace('\0virtual:', ''); diff --git a/node_modules/@sveltejs/kit/src/runtime/app/environment.js b/node_modules/@sveltejs/kit/src/runtime/app/environment.js new file mode 100644 index 000000000..8393ee6db --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/app/environment.js @@ -0,0 +1,12 @@ +import { BROWSER, DEV } from 'esm-env'; +export { building, version } from '__sveltekit/environment'; + +/** + * `true` if the app is running in the browser. + */ +export const browser = BROWSER; + +/** + * Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`. + */ +export const dev = DEV; diff --git a/node_modules/@sveltejs/kit/src/runtime/app/forms.js b/node_modules/@sveltejs/kit/src/runtime/app/forms.js new file mode 100644 index 000000000..bd2a81fc8 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/app/forms.js @@ -0,0 +1,221 @@ +import * as devalue from 'devalue'; +import { BROWSER, DEV } from 'esm-env'; +import { client } from '../client/singletons.js'; +import { invalidateAll } from './navigation.js'; + +/** + * This action updates the `form` property of the current page with the given data and updates `$page.status`. + * In case of an error, it redirects to the nearest error page. + * @template {Record | undefined} Success + * @template {Record | undefined} Failure + * @param {import('@sveltejs/kit').ActionResult} result + * @returns {Promise} + */ +export function applyAction(result) { + if (BROWSER) { + return client.apply_action(result); + } else { + throw new Error('Cannot call applyAction(...) on the server'); + } +} + +/** + * Use this function to deserialize the response from a form submission. + * Usage: + * + * ```js + * import { deserialize } from '$app/forms'; + * + * async function handleSubmit(event) { + * const response = await fetch('/form?/action', { + * method: 'POST', + * body: new FormData(event.target) + * }); + * + * const result = deserialize(await response.text()); + * // ... + * } + * ``` + * @template {Record | undefined} Success + * @template {Record | undefined} Failure + * @param {string} result + * @returns {import('@sveltejs/kit').ActionResult} + */ +export function deserialize(result) { + const parsed = JSON.parse(result); + if (parsed.data) { + parsed.data = devalue.parse(parsed.data); + } + return parsed; +} + +/** + * Shallow clone an element, so that we can access e.g. `form.action` without worrying + * that someone has added an `` (https://github.com/sveltejs/kit/issues/7593) + * @template {HTMLElement} T + * @param {T} element + * @returns {T} + */ +function clone(element) { + return /** @type {T} */ (HTMLElement.prototype.cloneNode.call(element)); +} + +/** + * This action enhances a `` element that otherwise would work without JavaScript. + * + * The `submit` function is called upon submission with the given FormData and the `action` that should be triggered. + * If `cancel` is called, the form will not be submitted. + * You can use the abort `controller` to cancel the submission in case another one starts. + * If a function is returned, that function is called with the response from the server. + * If nothing is returned, the fallback will be used. + * + * If this function or its return value isn't set, it + * - falls back to updating the `form` prop with the returned data if the action is one same page as the form + * - updates `$page.status` + * - resets the `` element and invalidates all data in case of successful submission with no redirect response + * - redirects in case of a redirect response + * - redirects to the nearest error page in case of an unexpected error + * + * If you provide a custom function with a callback and want to use the default behavior, invoke `update` in your callback. + * @template {Record | undefined} Success + * @template {Record | undefined} Failure + * @param {HTMLFormElement} form_element The form element + * @param {import('@sveltejs/kit').SubmitFunction} submit Submit callback + */ +export function enhance(form_element, submit = () => {}) { + if (DEV && clone(form_element).method !== 'post') { + throw new Error('use:enhance can only be used on fields with method="POST"'); + } + + /** + * @param {{ + * action: URL; + * invalidateAll?: boolean; + * result: import('@sveltejs/kit').ActionResult; + * reset?: boolean + * }} opts + */ + const fallback_callback = async ({ + action, + result, + reset = true, + invalidateAll: shouldInvalidateAll = true + }) => { + if (result.type === 'success') { + if (reset) { + // We call reset from the prototype to avoid DOM clobbering + HTMLFormElement.prototype.reset.call(form_element); + } + if (shouldInvalidateAll) { + await invalidateAll(); + } + } + + // For success/failure results, only apply action if it belongs to the + // current page, otherwise `form` will be updated erroneously + if ( + location.origin + location.pathname === action.origin + action.pathname || + result.type === 'redirect' || + result.type === 'error' + ) { + applyAction(result); + } + }; + + /** @param {SubmitEvent} event */ + async function handle_submit(event) { + const method = event.submitter?.hasAttribute('formmethod') + ? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formMethod + : clone(form_element).method; + if (method !== 'post') return; + + event.preventDefault(); + + const action = new URL( + // We can't do submitter.formAction directly because that property is always set + event.submitter?.hasAttribute('formaction') + ? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formAction + : clone(form_element).action + ); + + const form_data = new FormData(form_element); + + if (DEV && clone(form_element).enctype !== 'multipart/form-data') { + for (const value of form_data.values()) { + if (value instanceof File) { + throw new Error( + 'Your form contains fields, but is missing the necessary `enctype="multipart/form-data"` attribute. This will lead to inconsistent behavior between enhanced and native forms. For more details, see https://github.com/sveltejs/kit/issues/9819.' + ); + } + } + } + + const submitter_name = event.submitter?.getAttribute('name'); + if (submitter_name) { + form_data.append(submitter_name, event.submitter?.getAttribute('value') ?? ''); + } + + const controller = new AbortController(); + + let cancelled = false; + const cancel = () => (cancelled = true); + + const callback = + (await submit({ + action, + cancel, + controller, + formData: form_data, + formElement: form_element, + submitter: event.submitter + })) ?? fallback_callback; + if (cancelled) return; + + /** @type {import('@sveltejs/kit').ActionResult} */ + let result; + + try { + const response = await fetch(action, { + method: 'POST', + headers: { + accept: 'application/json', + 'x-sveltekit-action': 'true' + }, + cache: 'no-store', + body: form_data, + signal: controller.signal + }); + + result = deserialize(await response.text()); + if (result.type === 'error') result.status = response.status; + } catch (error) { + if (/** @type {any} */ (error)?.name === 'AbortError') return; + result = { type: 'error', error }; + } + + callback({ + action, + formData: form_data, + formElement: form_element, + update: (opts) => + fallback_callback({ + action, + result, + reset: opts?.reset, + invalidateAll: opts?.invalidateAll + }), + // @ts-expect-error generic constraints stuff we don't care about + result + }); + } + + // @ts-expect-error + HTMLFormElement.prototype.addEventListener.call(form_element, 'submit', handle_submit); + + return { + destroy() { + // @ts-expect-error + HTMLFormElement.prototype.removeEventListener.call(form_element, 'submit', handle_submit); + } + }; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/app/navigation.js b/node_modules/@sveltejs/kit/src/runtime/app/navigation.js new file mode 100644 index 000000000..4e38b9966 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/app/navigation.js @@ -0,0 +1,142 @@ +import { client_method } from '../client/singletons.js'; + +/** + * If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling. + * This is generally discouraged, since it breaks user expectations. + * @returns {void} + */ +export const disableScrollHandling = /* @__PURE__ */ client_method('disable_scroll_handling'); + +/** + * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`. + * For external URLs, use `window.location = url` instead of calling `goto(url)`. + * + * @type {(url: string | URL, opts?: { replaceState?: boolean; noScroll?: boolean; keepFocus?: boolean; invalidateAll?: boolean; state?: App.PageState }) => Promise} + * @param {string | URL} url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://kit.svelte.dev/docs/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app. + * @param {Object} [opts] Options related to the navigation + * @param {boolean} [opts.replaceState] If `true`, will replace the current `history` entry rather than creating a new one with `pushState` + * @param {boolean} [opts.noScroll] If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation + * @param {boolean} [opts.keepFocus] If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body + * @param {boolean} [opts.invalidateAll] If `true`, all `load` functions of the page will be rerun. See https://kit.svelte.dev/docs/load#rerunning-load-functions for more info on invalidation. + * @param {App.PageState} [opts.state] An optional object that will be available on the `$page.state` store + * @returns {Promise} + */ +export const goto = /* @__PURE__ */ client_method('goto'); + +/** + * Causes any `load` functions belonging to the currently active page to re-run if they depend on the `url` in question, via `fetch` or `depends`. Returns a `Promise` that resolves when the page is subsequently updated. + * + * If the argument is given as a `string` or `URL`, it must resolve to the same URL that was passed to `fetch` or `depends` (including query parameters). + * To create a custom identifier, use a string beginning with `[a-z]+:` (e.g. `custom:state`) — this is a valid URL. + * + * The `function` argument can be used define a custom predicate. It receives the full `URL` and causes `load` to rerun if `true` is returned. + * This can be useful if you want to invalidate based on a pattern instead of a exact match. + * + * ```ts + * // Example: Match '/path' regardless of the query parameters + * import { invalidate } from '$app/navigation'; + * + * invalidate((url) => url.pathname === '/path'); + * ``` + * @type {(url: string | URL | ((url: URL) => boolean)) => Promise} + * @param {string | URL | ((url: URL) => boolean)} url The invalidated URL + * @returns {Promise} + */ +export const invalidate = /* @__PURE__ */ client_method('invalidate'); + +/** + * Causes all `load` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated. + * @type {() => Promise} + * @returns {Promise} + */ +export const invalidateAll = /* @__PURE__ */ client_method('invalidate_all'); + +/** + * Programmatically preloads the given page, which means + * 1. ensuring that the code for the page is loaded, and + * 2. calling the page's load function with the appropriate options. + * + * This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `` element with `data-sveltekit-preload-data`. + * If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous. + * Returns a Promise that resolves with the result of running the new route's `load` functions once the preload is complete. + * + * @type {(href: string) => Promise>} + * @param {string} href Page to preload + * @returns {Promise<{ type: 'loaded'; status: number; data: Record } | { type: 'redirect'; location: string }>} + */ +export const preloadData = /* @__PURE__ */ client_method('preload_data'); + +/** + * Programmatically imports the code for routes that haven't yet been fetched. + * Typically, you might call this to speed up subsequent navigation. + * + * You can specify routes by any matching pathname such as `/about` (to match `src/routes/about/+page.svelte`) or `/blog/*` (to match `src/routes/blog/[slug]/+page.svelte`). + * + * Unlike `preloadData`, this won't call `load` functions. + * Returns a Promise that resolves when the modules have been imported. + * + * @type {(url: string) => Promise} + * @param {string} url + * @returns {Promise} + */ +export const preloadCode = /* @__PURE__ */ client_method('preload_code'); + +/** + * A navigation interceptor that triggers before we navigate to a new URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls. + * + * Calling `cancel()` will prevent the navigation from completing. If `navigation.type === 'leave'` — meaning the user is navigating away from the app (or closing the tab) — calling `cancel` will trigger the native browser unload confirmation dialog. In this case, the navigation may or may not be cancelled depending on the user's response. + * + * When a navigation isn't to a SvelteKit-owned route (and therefore controlled by SvelteKit's client-side router), `navigation.to.route.id` will be `null`. + * + * If the navigation will (if not cancelled) cause the document to unload — in other words `'leave'` navigations and `'link'` navigations where `navigation.to.route === null` — `navigation.willUnload` is `true`. + * + * `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted. + * @type {(callback: (navigation: import('@sveltejs/kit').BeforeNavigate) => void) => void} + * @param {(navigation: import('@sveltejs/kit').BeforeNavigate) => void} callback + * @returns {void} + */ +export const beforeNavigate = /* @__PURE__ */ client_method('before_navigate'); + +/** + * A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations. + * + * If you return a `Promise`, SvelteKit will wait for it to resolve before completing the navigation. This allows you to — for example — use `document.startViewTransition`. Avoid promises that are slow to resolve, since navigation will appear stalled to the user. + * + * If a function (or a `Promise` that resolves to a function) is returned from the callback, it will be called once the DOM has updated. + * + * `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted. + * @type {(callback: (navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>) => void} + * @param {(navigation: import('@sveltejs/kit').OnNavigate) => void} callback + * @returns {void} + */ +export const onNavigate = /* @__PURE__ */ client_method('on_navigate'); + +/** + * A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a new URL. + * + * `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted. + * @type {(callback: (navigation: import('@sveltejs/kit').AfterNavigate) => void) => void} + * @param {(navigation: import('@sveltejs/kit').AfterNavigate) => void} callback + * @returns {void} + */ +export const afterNavigate = /* @__PURE__ */ client_method('after_navigate'); + +/** + * Programmatically create a new history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://kit.svelte.dev/docs/shallow-routing). + * + * @type {(url: string | URL, state: App.PageState) => void} + * @param {string | URL} url + * @param {App.PageState} state + * @returns {void} + */ +export const pushState = /* @__PURE__ */ client_method('push_state'); + +/** + * Programmatically replace the current history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://kit.svelte.dev/docs/shallow-routing). + * + * @type {(url: string | URL, state: App.PageState) => void} + * @param {string | URL} url + * @param {App.PageState} state + * @returns {void} + */ +export const replaceState = /* @__PURE__ */ client_method('replace_state'); diff --git a/node_modules/@sveltejs/kit/src/runtime/app/paths.js b/node_modules/@sveltejs/kit/src/runtime/app/paths.js new file mode 100644 index 000000000..32df2e1b3 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/app/paths.js @@ -0,0 +1,23 @@ +export { base, assets } from '__sveltekit/paths'; +import { base } from '__sveltekit/paths'; +import { resolve_route } from '../../utils/routing.js'; + +/** + * Populate a route ID with params to resolve a pathname. + * @example + * ```js + * resolveRoute( + * `/blog/[slug]/[...somethingElse]`, + * { + * slug: 'hello-world', + * somethingElse: 'something/else' + * } + * ); // `/blog/hello-world/something/else` + * ``` + * @param {string} id + * @param {Record} params + * @returns {string} + */ +export function resolveRoute(id, params) { + return base + resolve_route(id, params); +} diff --git a/node_modules/@sveltejs/kit/src/runtime/app/stores.js b/node_modules/@sveltejs/kit/src/runtime/app/stores.js new file mode 100644 index 000000000..23ee5cd6c --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/app/stores.js @@ -0,0 +1,94 @@ +import { getContext } from 'svelte'; +import { browser } from './environment.js'; +import { stores as browser_stores } from '../client/singletons.js'; + +/** + * A function that returns all of the contextual stores. On the server, this must be called during component initialization. + * Only use this if you need to defer store subscription until after the component has mounted, for some reason. + */ +export const getStores = () => { + const stores = browser ? browser_stores : getContext('__svelte__'); + + return { + /** @type {typeof page} */ + page: { + subscribe: stores.page.subscribe + }, + /** @type {typeof navigating} */ + navigating: { + subscribe: stores.navigating.subscribe + }, + /** @type {typeof updated} */ + updated: stores.updated + }; +}; + +/** + * A readable store whose value contains page data. + * + * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time. + * + * @type {import('svelte/store').Readable} + */ +export const page = { + subscribe(fn) { + const store = __SVELTEKIT_DEV__ ? get_store('page') : getStores().page; + return store.subscribe(fn); + } +}; + +/** + * A readable store. + * When navigating starts, its value is a `Navigation` object with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties. + * When navigating finishes, its value reverts to `null`. + * + * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time. + * @type {import('svelte/store').Readable} + */ +export const navigating = { + subscribe(fn) { + const store = __SVELTEKIT_DEV__ ? get_store('navigating') : getStores().navigating; + return store.subscribe(fn); + } +}; + +/** + * A readable store whose initial value is `false`. If [`version.pollInterval`](https://kit.svelte.dev/docs/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling. + * + * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time. + * @type {import('svelte/store').Readable & { check(): Promise }} + */ +export const updated = { + subscribe(fn) { + const store = __SVELTEKIT_DEV__ ? get_store('updated') : getStores().updated; + + if (browser) { + updated.check = store.check; + } + + return store.subscribe(fn); + }, + check: () => { + throw new Error( + browser + ? 'Cannot check updated store before subscribing' + : 'Can only check updated store in browser' + ); + } +}; + +/** + * @template {keyof ReturnType} Name + * @param {Name} name + * @returns {ReturnType[Name]} + */ +function get_store(name) { + try { + return getStores()[name]; + } catch (e) { + throw new Error( + `Cannot subscribe to '${name}' store on the server outside of a Svelte component, as it is bound to the current request via component context. This prevents state from leaking between users.` + + 'For more information, see https://kit.svelte.dev/docs/state-management#avoid-shared-state-on-the-server' + ); + } +} diff --git a/node_modules/@sveltejs/kit/src/runtime/client/client.js b/node_modules/@sveltejs/kit/src/runtime/client/client.js new file mode 100644 index 000000000..95668d257 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/client/client.js @@ -0,0 +1,2358 @@ +import { DEV } from 'esm-env'; +import { onMount, tick } from 'svelte'; +import { + add_data_suffix, + decode_params, + decode_pathname, + strip_hash, + make_trackable, + normalize_path +} from '../../utils/url.js'; +import { + initial_fetch, + lock_fetch, + native_fetch, + subsequent_fetch, + unlock_fetch +} from './fetcher.js'; +import { parse } from './parse.js'; +import * as storage from './session-storage.js'; +import { + find_anchor, + resolve_url, + get_link_info, + get_router_options, + is_external_url, + origin, + scroll_state +} from './utils.js'; + +import { base } from '__sveltekit/paths'; +import * as devalue from 'devalue'; +import { + HISTORY_INDEX, + NAVIGATION_INDEX, + PRELOAD_PRIORITIES, + SCROLL_KEY, + STATES_KEY, + SNAPSHOT_KEY, + PAGE_URL_KEY +} from './constants.js'; +import { validate_page_exports } from '../../utils/exports.js'; +import { compact } from '../../utils/array.js'; +import { HttpError, Redirect, SvelteKitError } from '../control.js'; +import { INVALIDATED_PARAM, TRAILING_SLASH_PARAM, validate_depends } from '../shared.js'; +import { stores } from './singletons.js'; +import { get_message, get_status } from '../../utils/error.js'; + +let errored = false; + +/** @typedef {{ x: number; y: number }} ScrollPosition */ + +// We track the scroll position associated with each history entry in sessionStorage, +// rather than on history.state itself, because when navigation is driven by +// popstate it's too late to update the scroll position associated with the +// state we're navigating from +/** + * history index -> { x, y } + * @type {Record} + */ +const scroll_positions = storage.get(SCROLL_KEY) ?? {}; + +/** + * history index -> any + * @type {Record>} + */ +const states = storage.get(STATES_KEY, devalue.parse) ?? {}; + +/** + * navigation index -> any + * @type {Record} + */ +const snapshots = storage.get(SNAPSHOT_KEY) ?? {}; + +const original_push_state = history.pushState; +const original_replace_state = history.replaceState; + +if (DEV) { + let warned = false; + + const warn = () => { + if (warned) return; + warned = true; + + console.warn( + "Avoid using `history.pushState(...)` and `history.replaceState(...)` as these will conflict with SvelteKit's router. Use the `pushState` and `replaceState` imports from `$app/navigation` instead." + ); + }; + + history.pushState = (...args) => { + warn(); + return original_push_state.apply(history, args); + }; + + history.replaceState = (...args) => { + warn(); + return original_replace_state.apply(history, args); + }; +} + +/** @param {number} index */ +function update_scroll_positions(index) { + scroll_positions[index] = scroll_state(); +} + +/** + * @param {number} current_history_index + * @param {number} current_navigation_index + */ +function clear_onward_history(current_history_index, current_navigation_index) { + // if we navigated back, then pushed a new state, we can + // release memory by pruning the scroll/snapshot lookup + let i = current_history_index + 1; + while (scroll_positions[i]) { + delete scroll_positions[i]; + i += 1; + } + + i = current_navigation_index + 1; + while (snapshots[i]) { + delete snapshots[i]; + i += 1; + } +} + +/** + * Loads `href` the old-fashioned way, with a full page reload. + * Returns a `Promise` that never resolves (to prevent any + * subsequent work, e.g. history manipulation, from happening) + * @param {URL} url + */ +function native_navigation(url) { + location.href = url.href; + return new Promise(() => {}); +} + +function noop() {} + +/** + * @param {import('./types.js').SvelteKitApp} app + * @param {HTMLElement} target + * @returns {import('./types.js').Client} + */ +export function create_client(app, target) { + const routes = parse(app); + + const default_layout_loader = app.nodes[0]; + const default_error_loader = app.nodes[1]; + + // we import the root layout/error nodes eagerly, so that + // connectivity errors after initialisation don't nuke the app + default_layout_loader(); + default_error_loader(); + + const container = __SVELTEKIT_EMBEDDED__ ? target : document.documentElement; + + /** @type {Array<((url: URL) => boolean)>} */ + const invalidated = []; + + /** + * An array of the `+layout.svelte` and `+page.svelte` component instances + * that currently live on the page — used for capturing and restoring snapshots. + * It's updated/manipulated through `bind:this` in `Root.svelte`. + * @type {import('svelte').SvelteComponent[]} + */ + const components = []; + + /** @type {{id: string, promise: Promise} | null} */ + let load_cache = null; + + const callbacks = { + /** @type {Array<(navigation: import('@sveltejs/kit').BeforeNavigate) => void>} */ + before_navigate: [], + + /** @type {Array<(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>>} */ + on_navigate: [], + + /** @type {Array<(navigation: import('@sveltejs/kit').AfterNavigate) => void>} */ + after_navigate: [] + }; + + /** @type {import('./types.js').NavigationState} */ + let current = { + branch: [], + error: null, + // @ts-ignore - we need the initial value to be null + url: null + }; + + /** this being true means we SSR'd */ + let hydrated = false; + let started = false; + let autoscroll = true; + let updating = false; + let navigating = false; + let hash_navigating = false; + /** True as soon as there happened one client-side navigation (excluding the SvelteKit-initialized initial one when in SPA mode) */ + let has_navigated = false; + + let force_invalidation = false; + + /** @type {import('svelte').SvelteComponent} */ + let root; + + // keeping track of the history index in order to prevent popstate navigation events if needed + /** @type {number} */ + let current_history_index = history.state?.[HISTORY_INDEX]; + + /** @type {number} */ + let current_navigation_index = history.state?.[NAVIGATION_INDEX]; + + if (!current_history_index) { + // we use Date.now() as an offset so that cross-document navigations + // within the app don't result in data loss + current_history_index = current_navigation_index = Date.now(); + + // create initial history entry, so we can return here + original_replace_state.call( + history, + { + ...history.state, + [HISTORY_INDEX]: current_history_index, + [NAVIGATION_INDEX]: current_navigation_index + }, + '', + location.href + ); + } + + // if we reload the page, or Cmd-Shift-T back to it, + // recover scroll position + const scroll = scroll_positions[current_history_index]; + if (scroll) { + history.scrollRestoration = 'manual'; + scrollTo(scroll.x, scroll.y); + } + + /** @type {import('@sveltejs/kit').Page} */ + let page; + + /** @type {{}} */ + let token; + + /** @type {Promise | null} */ + let pending_invalidate; + + async function invalidate() { + // Accept all invalidations as they come, don't swallow any while another invalidation + // is running because subsequent invalidations may make earlier ones outdated, + // but batch multiple synchronous invalidations. + await (pending_invalidate ||= Promise.resolve()); + if (!pending_invalidate) return; + pending_invalidate = null; + + const intent = get_navigation_intent(current.url, true); + + // Clear preload, it might be affected by the invalidation. + // Also solves an edge case where a preload is triggered, the navigation for it + // was then triggered and is still running while the invalidation kicks in, + // at which point the invalidation should take over and "win". + load_cache = null; + + const nav_token = (token = {}); + const navigation_result = intent && (await load_route(intent)); + if (nav_token !== token) return; + + if (navigation_result) { + if (navigation_result.type === 'redirect') { + await goto(new URL(navigation_result.location, current.url).href, {}, 1, nav_token); + } else { + if (navigation_result.props.page !== undefined) { + page = navigation_result.props.page; + } + root.$set(navigation_result.props); + } + } + + invalidated.length = 0; + } + + /** @param {number} index */ + function capture_snapshot(index) { + if (components.some((c) => c?.snapshot)) { + snapshots[index] = components.map((c) => c?.snapshot?.capture()); + } + } + + /** @param {number} index */ + function restore_snapshot(index) { + snapshots[index]?.forEach((value, i) => { + components[i]?.snapshot?.restore(value); + }); + } + + function persist_state() { + update_scroll_positions(current_history_index); + storage.set(SCROLL_KEY, scroll_positions); + + capture_snapshot(current_navigation_index); + storage.set(SNAPSHOT_KEY, snapshots); + storage.set(STATES_KEY, states, devalue.stringify); + } + + /** + * @param {string | URL} url + * @param {{ replaceState?: boolean; noScroll?: boolean; keepFocus?: boolean; invalidateAll?: boolean; state?: Record }} options + * @param {number} redirect_count + * @param {{}} [nav_token] + */ + async function goto(url, options, redirect_count, nav_token) { + return navigate({ + type: 'goto', + url: resolve_url(url), + keepfocus: options.keepFocus, + noscroll: options.noScroll, + replace_state: options.replaceState, + redirect_count, + state: options.state, + nav_token, + accept: () => { + if (options.invalidateAll) { + force_invalidation = true; + } + } + }); + } + + /** @param {import('./types.js').NavigationIntent} intent */ + async function preload_data(intent) { + load_cache = { + id: intent.id, + promise: load_route(intent).then((result) => { + if (result.type === 'loaded' && result.state.error) { + // Don't cache errors, because they might be transient + load_cache = null; + } + return result; + }) + }; + + return load_cache.promise; + } + + /** @param {string} pathname */ + async function preload_code(pathname) { + const route = routes.find((route) => route.exec(get_url_path(pathname))); + + if (route) { + await Promise.all([...route.layouts, route.leaf].map((load) => load?.[1]())); + } + } + + /** @param {import('./types.js').NavigationFinished} result */ + function initialize(result) { + if (DEV && result.state.error && document.querySelector('vite-error-overlay')) return; + + current = result.state; + + const style = document.querySelector('style[data-sveltekit]'); + if (style) style.remove(); + + page = /** @type {import('@sveltejs/kit').Page} */ (result.props.page); + + root = new app.root({ + target, + props: { ...result.props, stores, components }, + hydrate: true + }); + + restore_snapshot(current_navigation_index); + + /** @type {import('@sveltejs/kit').AfterNavigate} */ + const navigation = { + from: null, + to: { + params: current.params, + route: { id: current.route?.id ?? null }, + url: new URL(location.href) + }, + willUnload: false, + type: 'enter', + complete: Promise.resolve() + }; + callbacks.after_navigate.forEach((fn) => fn(navigation)); + + started = true; + } + + /** + * + * @param {{ + * url: URL; + * params: Record; + * branch: Array; + * status: number; + * error: App.Error | null; + * route: import('types').CSRRoute | null; + * form?: Record | null; + * }} opts + */ + async function get_navigation_result_from_branch({ + url, + params, + branch, + status, + error, + route, + form + }) { + /** @type {import('types').TrailingSlash} */ + let slash = 'never'; + for (const node of branch) { + if (node?.slash !== undefined) slash = node.slash; + } + url.pathname = normalize_path(url.pathname, slash); + // eslint-disable-next-line + url.search = url.search; // turn `/?` into `/` + + /** @type {import('./types.js').NavigationFinished} */ + const result = { + type: 'loaded', + state: { + url, + params, + branch, + error, + route + }, + props: { + // @ts-ignore Somehow it's getting SvelteComponent and SvelteComponentDev mixed up + constructors: compact(branch).map((branch_node) => branch_node.node.component), + page + } + }; + + if (form !== undefined) { + result.props.form = form; + } + + let data = {}; + let data_changed = !page; + + let p = 0; + + for (let i = 0; i < Math.max(branch.length, current.branch.length); i += 1) { + const node = branch[i]; + const prev = current.branch[i]; + + if (node?.data !== prev?.data) data_changed = true; + if (!node) continue; + + data = { ...data, ...node.data }; + + // Only set props if the node actually updated. This prevents needless rerenders. + if (data_changed) { + result.props[`data_${p}`] = data; + } + + p += 1; + } + + const page_changed = + !current.url || + url.href !== current.url.href || + current.error !== error || + (form !== undefined && form !== page.form) || + data_changed; + + if (page_changed) { + result.props.page = { + error, + params, + route: { + id: route?.id ?? null + }, + state: {}, + status, + url: new URL(url), + form: form ?? null, + // The whole page store is updated, but this way the object reference stays the same + data: data_changed ? data : page.data + }; + } + + return result; + } + + /** + * Call the load function of the given node, if it exists. + * If `server_data` is passed, this is treated as the initial run and the page endpoint is not requested. + * + * @param {{ + * loader: import('types').CSRPageNodeLoader; + * parent: () => Promise>; + * url: URL; + * params: Record; + * route: { id: string | null }; + * server_data_node: import('./types.js').DataNode | null; + * }} options + * @returns {Promise} + */ + async function load_node({ loader, parent, url, params, route, server_data_node }) { + /** @type {Record | null} */ + let data = null; + + let is_tracking = true; + + /** @type {import('types').Uses} */ + const uses = { + dependencies: new Set(), + params: new Set(), + parent: false, + route: false, + url: false, + search_params: new Set() + }; + + const node = await loader(); + + if (DEV) { + validate_page_exports(node.universal); + } + + if (node.universal?.load) { + /** @param {string[]} deps */ + function depends(...deps) { + for (const dep of deps) { + if (DEV) validate_depends(/** @type {string} */ (route.id), dep); + + const { href } = new URL(dep, url); + uses.dependencies.add(href); + } + } + + /** @type {import('@sveltejs/kit').LoadEvent} */ + const load_input = { + route: new Proxy(route, { + get: (target, key) => { + if (is_tracking) { + uses.route = true; + } + return target[/** @type {'id'} */ (key)]; + } + }), + params: new Proxy(params, { + get: (target, key) => { + if (is_tracking) { + uses.params.add(/** @type {string} */ (key)); + } + return target[/** @type {string} */ (key)]; + } + }), + data: server_data_node?.data ?? null, + url: make_trackable( + url, + () => { + if (is_tracking) { + uses.url = true; + } + }, + (param) => { + if (is_tracking) { + uses.search_params.add(param); + } + } + ), + async fetch(resource, init) { + /** @type {URL | string} */ + let requested; + + if (resource instanceof Request) { + requested = resource.url; + + // we're not allowed to modify the received `Request` object, so in order + // to fixup relative urls we create a new equivalent `init` object instead + init = { + // the request body must be consumed in memory until browsers + // implement streaming request bodies and/or the body getter + body: + resource.method === 'GET' || resource.method === 'HEAD' + ? undefined + : await resource.blob(), + cache: resource.cache, + credentials: resource.credentials, + headers: resource.headers, + integrity: resource.integrity, + keepalive: resource.keepalive, + method: resource.method, + mode: resource.mode, + redirect: resource.redirect, + referrer: resource.referrer, + referrerPolicy: resource.referrerPolicy, + signal: resource.signal, + ...init + }; + } else { + requested = resource; + } + + // we must fixup relative urls so they are resolved from the target page + const resolved = new URL(requested, url); + if (is_tracking) { + depends(resolved.href); + } + + // match ssr serialized data url, which is important to find cached responses + if (resolved.origin === url.origin) { + requested = resolved.href.slice(url.origin.length); + } + + // prerendered pages may be served from any origin, so `initial_fetch` urls shouldn't be resolved + return started + ? subsequent_fetch(requested, resolved.href, init) + : initial_fetch(requested, init); + }, + setHeaders: () => {}, // noop + depends, + parent() { + if (is_tracking) { + uses.parent = true; + } + return parent(); + }, + untrack(fn) { + is_tracking = false; + try { + return fn(); + } finally { + is_tracking = true; + } + } + }; + + if (DEV) { + try { + lock_fetch(); + data = (await node.universal.load.call(null, load_input)) ?? null; + if (data != null && Object.getPrototypeOf(data) !== Object.prototype) { + throw new Error( + `a load function related to route '${route.id}' returned ${ + typeof data !== 'object' + ? `a ${typeof data}` + : data instanceof Response + ? 'a Response object' + : Array.isArray(data) + ? 'an array' + : 'a non-plain object' + }, but must return a plain object at the top level (i.e. \`return {...}\`)` + ); + } + } finally { + unlock_fetch(); + } + } else { + data = (await node.universal.load.call(null, load_input)) ?? null; + } + } + + return { + node, + loader, + server: server_data_node, + universal: node.universal?.load ? { type: 'data', data, uses } : null, + data: data ?? server_data_node?.data ?? null, + // if `paths.base === '/a/b/c`, then the root route is always `/a/b/c/`, regardless of + // the `trailingSlash` route option, so that relative paths to JS and CSS work + slash: + base && (url.pathname === base || url.pathname === base + '/') + ? 'always' + : node.universal?.trailingSlash ?? server_data_node?.slash + }; + } + + /** + * @param {boolean} parent_changed + * @param {boolean} route_changed + * @param {boolean} url_changed + * @param {Set} search_params_changed + * @param {import('types').Uses | undefined} uses + * @param {Record} params + */ + function has_changed( + parent_changed, + route_changed, + url_changed, + search_params_changed, + uses, + params + ) { + if (force_invalidation) return true; + + if (!uses) return false; + + if (uses.parent && parent_changed) return true; + if (uses.route && route_changed) return true; + if (uses.url && url_changed) return true; + + for (const tracked_params of uses.search_params) { + if (search_params_changed.has(tracked_params)) return true; + } + + for (const param of uses.params) { + if (params[param] !== current.params[param]) return true; + } + + for (const href of uses.dependencies) { + if (invalidated.some((fn) => fn(new URL(href)))) return true; + } + + return false; + } + + /** + * @param {import('types').ServerDataNode | import('types').ServerDataSkippedNode | null} node + * @param {import('./types.js').DataNode | null} [previous] + * @returns {import('./types.js').DataNode | null} + */ + function create_data_node(node, previous) { + if (node?.type === 'data') return node; + if (node?.type === 'skip') return previous ?? null; + return null; + } + + /** + * + * @param {URL | null} old_url + * @param {URL} new_url + */ + function diff_search_params(old_url, new_url) { + if (!old_url) return new Set(new_url.searchParams.keys()); + + const changed = new Set([...old_url.searchParams.keys(), ...new_url.searchParams.keys()]); + + for (const key of changed) { + const old_values = old_url.searchParams.getAll(key); + const new_values = new_url.searchParams.getAll(key); + + if ( + old_values.every((value) => new_values.includes(value)) && + new_values.every((value) => old_values.includes(value)) + ) { + changed.delete(key); + } + } + + return changed; + } + + /** + * @param {import('./types.js').NavigationIntent} intent + * @returns {Promise} + */ + async function load_route({ id, invalidating, url, params, route }) { + if (load_cache?.id === id) { + return load_cache.promise; + } + + const { errors, layouts, leaf } = route; + + const loaders = [...layouts, leaf]; + + // preload modules to avoid waterfall, but handle rejections + // so they don't get reported to Sentry et al (we don't need + // to act on the failures at this point) + errors.forEach((loader) => loader?.().catch(() => {})); + loaders.forEach((loader) => loader?.[1]().catch(() => {})); + + /** @type {import('types').ServerNodesResponse | import('types').ServerRedirectNode | null} */ + let server_data = null; + const url_changed = current.url ? id !== current.url.pathname + current.url.search : false; + const route_changed = current.route ? route.id !== current.route.id : false; + const search_params_changed = diff_search_params(current.url, url); + + let parent_invalid = false; + const invalid_server_nodes = loaders.map((loader, i) => { + const previous = current.branch[i]; + + const invalid = + !!loader?.[0] && + (previous?.loader !== loader[1] || + has_changed( + parent_invalid, + route_changed, + url_changed, + search_params_changed, + previous.server?.uses, + params + )); + + if (invalid) { + // For the next one + parent_invalid = true; + } + + return invalid; + }); + + if (invalid_server_nodes.some(Boolean)) { + try { + server_data = await load_data(url, invalid_server_nodes); + } catch (error) { + return load_root_error_page({ + status: get_status(error), + error: await handle_error(error, { url, params, route: { id: route.id } }), + url, + route + }); + } + + if (server_data.type === 'redirect') { + return server_data; + } + } + + const server_data_nodes = server_data?.nodes; + + let parent_changed = false; + + const branch_promises = loaders.map(async (loader, i) => { + if (!loader) return; + + /** @type {import('./types.js').BranchNode | undefined} */ + const previous = current.branch[i]; + + const server_data_node = server_data_nodes?.[i]; + + // re-use data from previous load if it's still valid + const valid = + (!server_data_node || server_data_node.type === 'skip') && + loader[1] === previous?.loader && + !has_changed( + parent_changed, + route_changed, + url_changed, + search_params_changed, + previous.universal?.uses, + params + ); + if (valid) return previous; + + parent_changed = true; + + if (server_data_node?.type === 'error') { + // rethrow and catch below + throw server_data_node; + } + + return load_node({ + loader: loader[1], + url, + params, + route, + parent: async () => { + const data = {}; + for (let j = 0; j < i; j += 1) { + Object.assign(data, (await branch_promises[j])?.data); + } + return data; + }, + server_data_node: create_data_node( + // server_data_node is undefined if it wasn't reloaded from the server; + // and if current loader uses server data, we want to reuse previous data. + server_data_node === undefined && loader[0] ? { type: 'skip' } : server_data_node ?? null, + loader[0] ? previous?.server : undefined + ) + }); + }); + + // if we don't do this, rejections will be unhandled + for (const p of branch_promises) p.catch(() => {}); + + /** @type {Array} */ + const branch = []; + + for (let i = 0; i < loaders.length; i += 1) { + if (loaders[i]) { + try { + branch.push(await branch_promises[i]); + } catch (err) { + if (err instanceof Redirect) { + return { + type: 'redirect', + location: err.location + }; + } + + let status = get_status(err); + /** @type {App.Error} */ + let error; + + if (server_data_nodes?.includes(/** @type {import('types').ServerErrorNode} */ (err))) { + // this is the server error rethrown above, reconstruct but don't invoke + // the client error handler; it should've already been handled on the server + status = /** @type {import('types').ServerErrorNode} */ (err).status ?? status; + error = /** @type {import('types').ServerErrorNode} */ (err).error; + } else if (err instanceof HttpError) { + error = err.body; + } else { + // Referenced node could have been removed due to redeploy, check + const updated = await stores.updated.check(); + if (updated) { + return await native_navigation(url); + } + + error = await handle_error(err, { params, url, route: { id: route.id } }); + } + + const error_load = await load_nearest_error_page(i, branch, errors); + if (error_load) { + return await get_navigation_result_from_branch({ + url, + params, + branch: branch.slice(0, error_load.idx).concat(error_load.node), + status, + error, + route + }); + } else { + // if we get here, it's because the root `load` function failed, + // and we need to fall back to the server + return await server_fallback(url, { id: route.id }, error, status); + } + } + } else { + // push an empty slot so we can rewind past gaps to the + // layout that corresponds with an +error.svelte page + branch.push(undefined); + } + } + + return await get_navigation_result_from_branch({ + url, + params, + branch, + status: 200, + error: null, + route, + // Reset `form` on navigation, but not invalidation + form: invalidating ? undefined : null + }); + } + + /** + * @param {number} i Start index to backtrack from + * @param {Array} branch Branch to backtrack + * @param {Array} errors All error pages for this branch + * @returns {Promise<{idx: number; node: import('./types.js').BranchNode} | undefined>} + */ + async function load_nearest_error_page(i, branch, errors) { + while (i--) { + if (errors[i]) { + let j = i; + while (!branch[j]) j -= 1; + try { + return { + idx: j + 1, + node: { + node: await /** @type {import('types').CSRPageNodeLoader } */ (errors[i])(), + loader: /** @type {import('types').CSRPageNodeLoader } */ (errors[i]), + data: {}, + server: null, + universal: null + } + }; + } catch (e) { + continue; + } + } + } + } + + /** + * @param {{ + * status: number; + * error: App.Error; + * url: URL; + * route: { id: string | null } + * }} opts + * @returns {Promise} + */ + async function load_root_error_page({ status, error, url, route }) { + /** @type {Record} */ + const params = {}; // error page does not have params + + /** @type {import('types').ServerDataNode | null} */ + let server_data_node = null; + + const default_layout_has_server_load = app.server_loads[0] === 0; + + if (default_layout_has_server_load) { + // TODO post-https://github.com/sveltejs/kit/discussions/6124 we can use + // existing root layout data + try { + const server_data = await load_data(url, [true]); + + if ( + server_data.type !== 'data' || + (server_data.nodes[0] && server_data.nodes[0].type !== 'data') + ) { + throw 0; + } + + server_data_node = server_data.nodes[0] ?? null; + } catch { + // at this point we have no choice but to fall back to the server, if it wouldn't + // bring us right back here, turning this into an endless loop + if (url.origin !== origin || url.pathname !== location.pathname || hydrated) { + await native_navigation(url); + } + } + } + + const root_layout = await load_node({ + loader: default_layout_loader, + url, + params, + route, + parent: () => Promise.resolve({}), + server_data_node: create_data_node(server_data_node) + }); + + /** @type {import('./types.js').BranchNode} */ + const root_error = { + node: await default_error_loader(), + loader: default_error_loader, + universal: null, + server: null, + data: null + }; + + return await get_navigation_result_from_branch({ + url, + params, + branch: [root_layout, root_error], + status, + error, + route: null + }); + } + + /** + * @param {URL} url + * @param {boolean} invalidating + */ + function get_navigation_intent(url, invalidating) { + if (is_external_url(url, base)) return; + + const path = get_url_path(url.pathname); + + for (const route of routes) { + const params = route.exec(path); + + if (params) { + const id = url.pathname + url.search; + /** @type {import('./types.js').NavigationIntent} */ + const intent = { id, invalidating, route, params: decode_params(params), url }; + return intent; + } + } + } + + /** @param {string} pathname */ + function get_url_path(pathname) { + return decode_pathname(pathname.slice(base.length) || '/'); + } + + /** + * @param {{ + * url: URL; + * type: import('@sveltejs/kit').Navigation["type"]; + * intent?: import('./types.js').NavigationIntent; + * delta?: number; + * }} opts + */ + function before_navigate({ url, type, intent, delta }) { + let should_block = false; + + const nav = create_navigation(current, intent, url, type); + + if (delta !== undefined) { + nav.navigation.delta = delta; + } + + const cancellable = { + ...nav.navigation, + cancel: () => { + should_block = true; + nav.reject(new Error('navigation was cancelled')); + } + }; + + if (!navigating) { + // Don't run the event during redirects + callbacks.before_navigate.forEach((fn) => fn(cancellable)); + } + + return should_block ? null : nav; + } + + /** + * @param {{ + * type: import('@sveltejs/kit').Navigation["type"]; + * url: URL; + * popped?: { + * state: Record; + * scroll: { x: number, y: number }; + * delta: number; + * }; + * keepfocus?: boolean; + * noscroll?: boolean; + * replace_state?: boolean; + * state?: Record; + * redirect_count?: number; + * nav_token?: {}; + * accept?: () => void; + * block?: () => void; + * }} opts + */ + async function navigate({ + type, + url, + popped, + keepfocus, + noscroll, + replace_state, + state = {}, + redirect_count = 0, + nav_token = {}, + accept = noop, + block = noop + }) { + const intent = get_navigation_intent(url, false); + const nav = before_navigate({ url, type, delta: popped?.delta, intent }); + + if (!nav) { + block(); + return; + } + + // store this before calling `accept()`, which may change the index + const previous_history_index = current_history_index; + const previous_navigation_index = current_navigation_index; + + accept(); + + navigating = true; + + if (started) { + stores.navigating.set(nav.navigation); + } + + token = nav_token; + let navigation_result = intent && (await load_route(intent)); + + if (!navigation_result) { + if (is_external_url(url, base)) { + return await native_navigation(url); + } + navigation_result = await server_fallback( + url, + { id: null }, + await handle_error(new SvelteKitError(404, 'Not Found', `Not found: ${url.pathname}`), { + url, + params: {}, + route: { id: null } + }), + 404 + ); + } + + // if this is an internal navigation intent, use the normalized + // URL for the rest of the function + url = intent?.url || url; + + // abort if user navigated during update + if (token !== nav_token) { + nav.reject(new Error('navigation was aborted')); + return false; + } + + if (navigation_result.type === 'redirect') { + // whatwg fetch spec https://fetch.spec.whatwg.org/#http-redirect-fetch says to error after 20 redirects + if (redirect_count >= 20) { + navigation_result = await load_root_error_page({ + status: 500, + error: await handle_error(new Error('Redirect loop'), { + url, + params: {}, + route: { id: null } + }), + url, + route: { id: null } + }); + } else { + goto(new URL(navigation_result.location, url).href, {}, redirect_count + 1, nav_token); + return false; + } + } else if (/** @type {number} */ (navigation_result.props.page.status) >= 400) { + const updated = await stores.updated.check(); + if (updated) { + await native_navigation(url); + } + } + + // reset invalidation only after a finished navigation. If there are redirects or + // additional invalidations, they should get the same invalidation treatment + invalidated.length = 0; + force_invalidation = false; + + updating = true; + + update_scroll_positions(previous_history_index); + capture_snapshot(previous_navigation_index); + + // ensure the url pathname matches the page's trailing slash option + if (navigation_result.props.page.url.pathname !== url.pathname) { + url.pathname = navigation_result.props.page.url.pathname; + } + + state = popped ? popped.state : state; + + if (!popped) { + // this is a new navigation, rather than a popstate + const change = replace_state ? 0 : 1; + + const entry = { + [HISTORY_INDEX]: (current_history_index += change), + [NAVIGATION_INDEX]: (current_navigation_index += change) + }; + + const fn = replace_state ? original_replace_state : original_push_state; + fn.call(history, entry, '', url); + + if (!replace_state) { + clear_onward_history(current_history_index, current_navigation_index); + } + } + + states[current_history_index] = state; + + // reset preload synchronously after the history state has been set to avoid race conditions + load_cache = null; + + navigation_result.props.page.state = state; + + if (started) { + current = navigation_result.state; + + // reset url before updating page store + if (navigation_result.props.page) { + navigation_result.props.page.url = url; + } + + const after_navigate = ( + await Promise.all( + callbacks.on_navigate.map((fn) => + fn(/** @type {import('@sveltejs/kit').OnNavigate} */ (nav.navigation)) + ) + ) + ).filter((value) => typeof value === 'function'); + + if (after_navigate.length > 0) { + function cleanup() { + callbacks.after_navigate = callbacks.after_navigate.filter( + // @ts-ignore + (fn) => !after_navigate.includes(fn) + ); + } + + after_navigate.push(cleanup); + + // @ts-ignore + callbacks.after_navigate.push(...after_navigate); + } + + root.$set(navigation_result.props); + has_navigated = true; + } else { + initialize(navigation_result); + } + + const { activeElement } = document; + + // need to render the DOM before we can scroll to the rendered elements and do focus management + await tick(); + + // we reset scroll before dealing with focus, to avoid a flash of unscrolled content + const scroll = popped ? popped.scroll : noscroll ? scroll_state() : null; + + if (autoscroll) { + const deep_linked = + url.hash && document.getElementById(decodeURIComponent(url.hash.slice(1))); + if (scroll) { + scrollTo(scroll.x, scroll.y); + } else if (deep_linked) { + // Here we use `scrollIntoView` on the element instead of `scrollTo` + // because it natively supports the `scroll-margin` and `scroll-behavior` + // CSS properties. + deep_linked.scrollIntoView(); + } else { + scrollTo(0, 0); + } + } + + const changed_focus = + // reset focus only if any manual focus management didn't override it + document.activeElement !== activeElement && + // also refocus when activeElement is body already because the + // focus event might not have been fired on it yet + document.activeElement !== document.body; + + if (!keepfocus && !changed_focus) { + reset_focus(); + } + + autoscroll = true; + + if (navigation_result.props.page) { + page = navigation_result.props.page; + } + + navigating = false; + + if (type === 'popstate') { + restore_snapshot(current_navigation_index); + } + + nav.fulfil(undefined); + + callbacks.after_navigate.forEach((fn) => + fn(/** @type {import('@sveltejs/kit').AfterNavigate} */ (nav.navigation)) + ); + stores.navigating.set(null); + + updating = false; + } + + /** + * Does a full page reload if it wouldn't result in an endless loop in the SPA case + * @param {URL} url + * @param {{ id: string | null }} route + * @param {App.Error} error + * @param {number} status + * @returns {Promise} + */ + async function server_fallback(url, route, error, status) { + if (url.origin === origin && url.pathname === location.pathname && !hydrated) { + // We would reload the same page we're currently on, which isn't hydrated, + // which means no SSR, which means we would end up in an endless loop + return await load_root_error_page({ + status, + error, + url, + route + }); + } + + if (DEV && status !== 404) { + console.error( + 'An error occurred while loading the page. This will cause a full page reload. (This message will only appear during development.)' + ); + + debugger; // eslint-disable-line + } + + return await native_navigation(url); + } + + if (import.meta.hot) { + import.meta.hot.on('vite:beforeUpdate', () => { + if (current.error) location.reload(); + }); + } + + function setup_preload() { + /** @type {NodeJS.Timeout} */ + let mousemove_timeout; + + container.addEventListener('mousemove', (event) => { + const target = /** @type {Element} */ (event.target); + + clearTimeout(mousemove_timeout); + mousemove_timeout = setTimeout(() => { + preload(target, 2); + }, 20); + }); + + /** @param {Event} event */ + function tap(event) { + preload(/** @type {Element} */ (event.composedPath()[0]), 1); + } + + container.addEventListener('mousedown', tap); + container.addEventListener('touchstart', tap, { passive: true }); + + const observer = new IntersectionObserver( + (entries) => { + for (const entry of entries) { + if (entry.isIntersecting) { + preload_code(/** @type {HTMLAnchorElement} */ (entry.target).href); + observer.unobserve(entry.target); + } + } + }, + { threshold: 0 } + ); + + /** + * @param {Element} element + * @param {number} priority + */ + function preload(element, priority) { + const a = find_anchor(element, container); + if (!a) return; + + const { url, external, download } = get_link_info(a, base); + if (external || download) return; + + const options = get_router_options(a); + + if (!options.reload) { + if (priority <= options.preload_data) { + const intent = get_navigation_intent(/** @type {URL} */ (url), false); + if (intent) { + if (DEV) { + preload_data(intent).then((result) => { + if (result.type === 'loaded' && result.state.error) { + console.warn( + `Preloading data for ${intent.url.pathname} failed with the following error: ${result.state.error.message}\n` + + 'If this error is transient, you can ignore it. Otherwise, consider disabling preloading for this route. ' + + 'This route was preloaded due to a data-sveltekit-preload-data attribute. ' + + 'See https://kit.svelte.dev/docs/link-options for more info' + ); + } + }); + } else { + preload_data(intent); + } + } + } else if (priority <= options.preload_code) { + preload_code(/** @type {URL} */ (url).pathname); + } + } + } + + function after_navigate() { + observer.disconnect(); + + for (const a of container.querySelectorAll('a')) { + const { url, external, download } = get_link_info(a, base); + if (external || download) continue; + + const options = get_router_options(a); + if (options.reload) continue; + + if (options.preload_code === PRELOAD_PRIORITIES.viewport) { + observer.observe(a); + } + + if (options.preload_code === PRELOAD_PRIORITIES.eager) { + preload_code(/** @type {URL} */ (url).pathname); + } + } + } + + callbacks.after_navigate.push(after_navigate); + after_navigate(); + } + + /** + * @param {unknown} error + * @param {import('@sveltejs/kit').NavigationEvent} event + * @returns {import('types').MaybePromise} + */ + function handle_error(error, event) { + if (error instanceof HttpError) { + return error.body; + } + + if (DEV) { + errored = true; + console.warn('The next HMR update will cause the page to reload'); + } + + const status = get_status(error); + const message = get_message(error); + + return ( + app.hooks.handleError({ error, event, status, message }) ?? /** @type {any} */ ({ message }) + ); + } + + return { + after_navigate: (fn) => { + onMount(() => { + callbacks.after_navigate.push(fn); + + return () => { + const i = callbacks.after_navigate.indexOf(fn); + callbacks.after_navigate.splice(i, 1); + }; + }); + }, + + before_navigate: (fn) => { + onMount(() => { + callbacks.before_navigate.push(fn); + + return () => { + const i = callbacks.before_navigate.indexOf(fn); + callbacks.before_navigate.splice(i, 1); + }; + }); + }, + + on_navigate: (fn) => { + onMount(() => { + callbacks.on_navigate.push(fn); + + return () => { + const i = callbacks.on_navigate.indexOf(fn); + callbacks.on_navigate.splice(i, 1); + }; + }); + }, + + disable_scroll_handling: () => { + if (DEV && started && !updating) { + throw new Error('Can only disable scroll handling during navigation'); + } + + if (updating || !started) { + autoscroll = false; + } + }, + + goto: (url, opts = {}) => { + url = resolve_url(url); + + if (url.origin !== origin) { + return Promise.reject( + new Error( + DEV + ? `Cannot use \`goto\` with an external URL. Use \`window.location = "${url}"\` instead` + : 'goto: invalid URL' + ) + ); + } + + return goto(url, opts, 0); + }, + + invalidate: (resource) => { + if (typeof resource === 'function') { + invalidated.push(resource); + } else { + const { href } = new URL(resource, location.href); + invalidated.push((url) => url.href === href); + } + + return invalidate(); + }, + + invalidate_all: () => { + force_invalidation = true; + return invalidate(); + }, + + preload_data: async (href) => { + const url = resolve_url(href); + const intent = get_navigation_intent(url, false); + + if (!intent) { + throw new Error(`Attempted to preload a URL that does not belong to this app: ${url}`); + } + + const result = await preload_data(intent); + if (result.type === 'redirect') { + return { + type: result.type, + location: result.location + }; + } + + const { status, data } = result.props.page ?? page; + return { type: result.type, status, data }; + }, + + preload_code: (pathname) => { + if (DEV) { + if (!pathname.startsWith(base)) { + throw new Error( + `pathnames passed to preloadCode must start with \`paths.base\` (i.e. "${base}${pathname}" rather than "${pathname}")` + ); + } + + if (!routes.find((route) => route.exec(get_url_path(pathname)))) { + throw new Error(`'${pathname}' did not match any routes`); + } + } + + return preload_code(pathname); + }, + + push_state: (url, state) => { + if (DEV) { + try { + devalue.stringify(state); + } catch (error) { + // @ts-expect-error + throw new Error(`Could not serialize state${error.path}`); + } + } + + const opts = { + [HISTORY_INDEX]: (current_history_index += 1), + [NAVIGATION_INDEX]: current_navigation_index, + [PAGE_URL_KEY]: page.url.href + }; + + original_push_state.call(history, opts, '', resolve_url(url)); + + page = { ...page, state }; + root.$set({ page }); + + states[current_history_index] = state; + clear_onward_history(current_history_index, current_navigation_index); + }, + + replace_state: (url, state) => { + if (DEV) { + try { + devalue.stringify(state); + } catch (error) { + // @ts-expect-error + throw new Error(`Could not serialize state${error.path}`); + } + } + + const opts = { + [HISTORY_INDEX]: current_history_index, + [NAVIGATION_INDEX]: current_navigation_index, + [PAGE_URL_KEY]: page.url.href + }; + + original_replace_state.call(history, opts, '', resolve_url(url)); + + page = { ...page, state }; + root.$set({ page }); + + states[current_history_index] = state; + }, + + apply_action: async (result) => { + if (result.type === 'error') { + const url = new URL(location.href); + + const { branch, route } = current; + if (!route) return; + + const error_load = await load_nearest_error_page( + current.branch.length, + branch, + route.errors + ); + if (error_load) { + const navigation_result = await get_navigation_result_from_branch({ + url, + params: current.params, + branch: branch.slice(0, error_load.idx).concat(error_load.node), + status: result.status ?? 500, + error: result.error, + route + }); + + current = navigation_result.state; + + root.$set(navigation_result.props); + + tick().then(reset_focus); + } + } else if (result.type === 'redirect') { + goto(result.location, { invalidateAll: true }, 0); + } else { + /** @type {Record} */ + root.$set({ + // this brings Svelte's view of the world in line with SvelteKit's + // after use:enhance reset the form.... + form: null, + page: { ...page, form: result.data, status: result.status } + }); + + // ...so that setting the `form` prop takes effect and isn't ignored + await tick(); + root.$set({ form: result.data }); + + if (result.type === 'success') { + reset_focus(); + } + } + }, + + _start_router: () => { + history.scrollRestoration = 'manual'; + + // Adopted from Nuxt.js + // Reset scrollRestoration to auto when leaving page, allowing page reload + // and back-navigation from other pages to use the browser to restore the + // scrolling position. + addEventListener('beforeunload', (e) => { + let should_block = false; + + persist_state(); + + if (!navigating) { + const nav = create_navigation(current, undefined, null, 'leave'); + + // If we're navigating, beforeNavigate was already called. If we end up in here during navigation, + // it's due to an external or full-page-reload link, for which we don't want to call the hook again. + /** @type {import('@sveltejs/kit').BeforeNavigate} */ + const navigation = { + ...nav.navigation, + cancel: () => { + should_block = true; + nav.reject(new Error('navigation was cancelled')); + } + }; + + callbacks.before_navigate.forEach((fn) => fn(navigation)); + } + + if (should_block) { + e.preventDefault(); + e.returnValue = ''; + } else { + history.scrollRestoration = 'auto'; + } + }); + + addEventListener('visibilitychange', () => { + if (document.visibilityState === 'hidden') { + persist_state(); + } + }); + + // @ts-expect-error this isn't supported everywhere yet + if (!navigator.connection?.saveData) { + setup_preload(); + } + + /** @param {MouseEvent} event */ + container.addEventListener('click', (event) => { + // Adapted from https://github.com/visionmedia/page.js + // MIT license https://github.com/visionmedia/page.js#license + if (event.button || event.which !== 1) return; + if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; + if (event.defaultPrevented) return; + + const a = find_anchor(/** @type {Element} */ (event.composedPath()[0]), container); + if (!a) return; + + const { url, external, target, download } = get_link_info(a, base); + if (!url) return; + + // bail out before `beforeNavigate` if link opens in a different tab + if (target === '_parent' || target === '_top') { + if (window.parent !== window) return; + } else if (target && target !== '_self') { + return; + } + + const options = get_router_options(a); + const is_svg_a_element = a instanceof SVGAElement; + + // Ignore URL protocols that differ to the current one and are not http(s) (e.g. `mailto:`, `tel:`, `myapp:`, etc.) + // This may be wrong when the protocol is x: and the link goes to y:.. which should be treated as an external + // navigation, but it's not clear how to handle that case and it's not likely to come up in practice. + // MEMO: Without this condition, firefox will open mailer twice. + // See: + // - https://github.com/sveltejs/kit/issues/4045 + // - https://github.com/sveltejs/kit/issues/5725 + // - https://github.com/sveltejs/kit/issues/6496 + if ( + !is_svg_a_element && + url.protocol !== location.protocol && + !(url.protocol === 'https:' || url.protocol === 'http:') + ) + return; + + if (download) return; + + // Ignore the following but fire beforeNavigate + if (external || options.reload) { + if (before_navigate({ url, type: 'link' })) { + // set `navigating` to `true` to prevent `beforeNavigate` callbacks + // being called when the page unloads + navigating = true; + } else { + event.preventDefault(); + } + + return; + } + + // Check if new url only differs by hash and use the browser default behavior in that case + // This will ensure the `hashchange` event is fired + // Removing the hash does a full page navigation in the browser, so make sure a hash is present + const [nonhash, hash] = url.href.split('#'); + if (hash !== undefined && nonhash === strip_hash(location)) { + // If we are trying to navigate to the same hash, we should only + // attempt to scroll to that element and avoid any history changes. + // Otherwise, this can cause Firefox to incorrectly assign a null + // history state value without any signal that we can detect. + if (current.url.hash === url.hash) { + event.preventDefault(); + a.ownerDocument.getElementById(hash)?.scrollIntoView(); + return; + } + // set this flag to distinguish between navigations triggered by + // clicking a hash link and those triggered by popstate + hash_navigating = true; + + update_scroll_positions(current_history_index); + + update_url(url); + + if (!options.replace_state) return; + + // hashchange event shouldn't occur if the router is replacing state. + hash_navigating = false; + } + + event.preventDefault(); + + navigate({ + type: 'link', + url, + keepfocus: options.keepfocus, + noscroll: options.noscroll, + replace_state: options.replace_state ?? url.href === location.href + }); + }); + + container.addEventListener('submit', (event) => { + if (event.defaultPrevented) return; + + const form = /** @type {HTMLFormElement} */ ( + HTMLFormElement.prototype.cloneNode.call(event.target) + ); + + const submitter = /** @type {HTMLButtonElement | HTMLInputElement | null} */ ( + event.submitter + ); + + const method = submitter?.formMethod || form.method; + + if (method !== 'get') return; + + const url = new URL( + (submitter?.hasAttribute('formaction') && submitter?.formAction) || form.action + ); + + if (is_external_url(url, base)) return; + + const event_form = /** @type {HTMLFormElement} */ (event.target); + + const options = get_router_options(event_form); + if (options.reload) return; + + event.preventDefault(); + event.stopPropagation(); + + const data = new FormData(event_form); + + const submitter_name = submitter?.getAttribute('name'); + if (submitter_name) { + data.append(submitter_name, submitter?.getAttribute('value') ?? ''); + } + + // @ts-expect-error `URLSearchParams(fd)` is kosher, but typescript doesn't know that + url.search = new URLSearchParams(data).toString(); + + navigate({ + type: 'form', + url, + keepfocus: options.keepfocus, + noscroll: options.noscroll, + replace_state: options.replace_state ?? url.href === location.href + }); + }); + + addEventListener('popstate', async (event) => { + if (event.state?.[HISTORY_INDEX]) { + const history_index = event.state[HISTORY_INDEX]; + token = {}; + + // if a popstate-driven navigation is cancelled, we need to counteract it + // with history.go, which means we end up back here, hence this check + if (history_index === current_history_index) return; + + const scroll = scroll_positions[history_index]; + const state = states[history_index] ?? {}; + const url = new URL(event.state[PAGE_URL_KEY] ?? location.href); + const navigation_index = event.state[NAVIGATION_INDEX]; + const is_hash_change = strip_hash(location) === strip_hash(current.url); + const shallow = + navigation_index === current_navigation_index && (has_navigated || is_hash_change); + + if (shallow) { + // We don't need to navigate, we just need to update scroll and/or state. + // This happens with hash links and `pushState`/`replaceState`. The + // exception is if we haven't navigated yet, since we could have + // got here after a modal navigation then a reload + update_url(url); + + scroll_positions[current_history_index] = scroll_state(); + if (scroll) scrollTo(scroll.x, scroll.y); + + if (state !== page.state) { + page = { ...page, state }; + root.$set({ page }); + } + + current_history_index = history_index; + return; + } + + const delta = history_index - current_history_index; + + await navigate({ + type: 'popstate', + url, + popped: { + state, + scroll, + delta + }, + accept: () => { + current_history_index = history_index; + current_navigation_index = navigation_index; + }, + block: () => { + history.go(-delta); + }, + nav_token: token + }); + } else { + // since popstate event is also emitted when an anchor referencing the same + // document is clicked, we have to check that the router isn't already handling + // the navigation. otherwise we would be updating the page store twice. + if (!hash_navigating) { + const url = new URL(location.href); + update_url(url); + } + } + }); + + addEventListener('hashchange', () => { + // if the hashchange happened as a result of clicking on a link, + // we need to update history, otherwise we have to leave it alone + if (hash_navigating) { + hash_navigating = false; + original_replace_state.call( + history, + { + ...history.state, + [HISTORY_INDEX]: ++current_history_index, + [NAVIGATION_INDEX]: current_navigation_index + }, + '', + location.href + ); + } + }); + + // fix link[rel=icon], because browsers will occasionally try to load relative + // URLs after a pushState/replaceState, resulting in a 404 — see + // https://github.com/sveltejs/kit/issues/3748#issuecomment-1125980897 + for (const link of document.querySelectorAll('link')) { + if (link.rel === 'icon') link.href = link.href; // eslint-disable-line + } + + addEventListener('pageshow', (event) => { + // If the user navigates to another site and then uses the back button and + // bfcache hits, we need to set navigating to null, the site doesn't know + // the navigation away from it was successful. + // Info about bfcache here: https://web.dev/bfcache + if (event.persisted) { + stores.navigating.set(null); + } + }); + + /** + * @param {URL} url + */ + function update_url(url) { + current.url = url; + stores.page.set({ ...page, url }); + stores.page.notify(); + } + }, + + _hydrate: async ({ + status = 200, + error, + node_ids, + params, + route, + data: server_data_nodes, + form + }) => { + hydrated = true; + + const url = new URL(location.href); + + if (!__SVELTEKIT_EMBEDDED__) { + // See https://github.com/sveltejs/kit/pull/4935#issuecomment-1328093358 for one motivation + // of determining the params on the client side. + ({ params = {}, route = { id: null } } = get_navigation_intent(url, false) || {}); + } + + /** @type {import('./types.js').NavigationFinished | undefined} */ + let result; + + try { + const branch_promises = node_ids.map(async (n, i) => { + const server_data_node = server_data_nodes[i]; + // Type isn't completely accurate, we still need to deserialize uses + if (server_data_node?.uses) { + server_data_node.uses = deserialize_uses(server_data_node.uses); + } + + return load_node({ + loader: app.nodes[n], + url, + params, + route, + parent: async () => { + const data = {}; + for (let j = 0; j < i; j += 1) { + Object.assign(data, (await branch_promises[j]).data); + } + return data; + }, + server_data_node: create_data_node(server_data_node) + }); + }); + + /** @type {Array} */ + const branch = await Promise.all(branch_promises); + + const parsed_route = routes.find(({ id }) => id === route.id); + + // server-side will have compacted the branch, reinstate empty slots + // so that error boundaries can be lined up correctly + if (parsed_route) { + const layouts = parsed_route.layouts; + for (let i = 0; i < layouts.length; i++) { + if (!layouts[i]) { + branch.splice(i, 0, undefined); + } + } + } + + result = await get_navigation_result_from_branch({ + url, + params, + branch, + status, + error, + form, + route: parsed_route ?? null + }); + } catch (error) { + if (error instanceof Redirect) { + // this is a real edge case — `load` would need to return + // a redirect but only in the browser + await native_navigation(new URL(error.location, location.href)); + return; + } + + result = await load_root_error_page({ + status: get_status(error), + error: await handle_error(error, { url, params, route }), + url, + route + }); + } + + if (result.props.page) { + result.props.page.state = {}; + } + + initialize(result); + } + }; +} + +/** + * @param {URL} url + * @param {boolean[]} invalid + * @returns {Promise} + */ +async function load_data(url, invalid) { + const data_url = new URL(url); + data_url.pathname = add_data_suffix(url.pathname); + if (url.pathname.endsWith('/')) { + data_url.searchParams.append(TRAILING_SLASH_PARAM, '1'); + } + if (DEV && url.searchParams.has(INVALIDATED_PARAM)) { + throw new Error(`Cannot used reserved query parameter "${INVALIDATED_PARAM}"`); + } + data_url.searchParams.append(INVALIDATED_PARAM, invalid.map((i) => (i ? '1' : '0')).join('')); + + const res = await native_fetch(data_url.href); + + if (!res.ok) { + // error message is a JSON-stringified string which devalue can't handle at the top level + // turn it into a HttpError to not call handleError on the client again (was already handled on the server) + // if `__data.json` doesn't exist or the server has an internal error, + // avoid parsing the HTML error page as a JSON + /** @type {string | undefined} */ + let message; + if (res.headers.get('content-type')?.includes('application/json')) { + message = await res.json(); + } else if (res.status === 404) { + message = 'Not Found'; + } else if (res.status === 500) { + message = 'Internal Error'; + } + throw new HttpError(res.status, message); + } + + // TODO: fix eslint error / figure out if it actually applies to our situation + // eslint-disable-next-line + return new Promise(async (resolve) => { + /** + * Map of deferred promises that will be resolved by a subsequent chunk of data + * @type {Map} + */ + const deferreds = new Map(); + const reader = /** @type {ReadableStream} */ (res.body).getReader(); + const decoder = new TextDecoder(); + + /** + * @param {any} data + */ + function deserialize(data) { + return devalue.unflatten(data, { + Promise: (id) => { + return new Promise((fulfil, reject) => { + deferreds.set(id, { fulfil, reject }); + }); + } + }); + } + + let text = ''; + + while (true) { + // Format follows ndjson (each line is a JSON object) or regular JSON spec + const { done, value } = await reader.read(); + if (done && !text) break; + + text += !value && text ? '\n' : decoder.decode(value); // no value -> final chunk -> add a new line to trigger the last parse + + while (true) { + const split = text.indexOf('\n'); + if (split === -1) { + break; + } + + const node = JSON.parse(text.slice(0, split)); + text = text.slice(split + 1); + + if (node.type === 'redirect') { + return resolve(node); + } + + if (node.type === 'data') { + // This is the first (and possibly only, if no pending promises) chunk + node.nodes?.forEach((/** @type {any} */ node) => { + if (node?.type === 'data') { + node.uses = deserialize_uses(node.uses); + node.data = deserialize(node.data); + } + }); + + resolve(node); + } else if (node.type === 'chunk') { + // This is a subsequent chunk containing deferred data + const { id, data, error } = node; + const deferred = /** @type {import('types').Deferred} */ (deferreds.get(id)); + deferreds.delete(id); + + if (error) { + deferred.reject(deserialize(error)); + } else { + deferred.fulfil(deserialize(data)); + } + } + } + } + }); + + // TODO edge case handling necessary? stream() read fails? +} + +/** + * @param {any} uses + * @return {import('types').Uses} + */ +function deserialize_uses(uses) { + return { + dependencies: new Set(uses?.dependencies ?? []), + params: new Set(uses?.params ?? []), + parent: !!uses?.parent, + route: !!uses?.route, + url: !!uses?.url, + search_params: new Set(uses?.search_params ?? []) + }; +} + +function reset_focus() { + const autofocus = document.querySelector('[autofocus]'); + if (autofocus) { + // @ts-ignore + autofocus.focus(); + } else { + // Reset page selection and focus + // We try to mimic browsers' behaviour as closely as possible by targeting the + // first scrollable region, but unfortunately it's not a perfect match — e.g. + // shift-tabbing won't immediately cycle up from the end of the page on Chromium + // See https://html.spec.whatwg.org/multipage/interaction.html#get-the-focusable-area + const root = document.body; + const tabindex = root.getAttribute('tabindex'); + + root.tabIndex = -1; + // @ts-expect-error + root.focus({ preventScroll: true, focusVisible: false }); + + // restore `tabindex` as to prevent `root` from stealing input from elements + if (tabindex !== null) { + root.setAttribute('tabindex', tabindex); + } else { + root.removeAttribute('tabindex'); + } + + // capture current selection, so we can compare the state after + // snapshot restoration and afterNavigate callbacks have run + const selection = getSelection(); + + if (selection && selection.type !== 'None') { + /** @type {Range[]} */ + const ranges = []; + + for (let i = 0; i < selection.rangeCount; i += 1) { + ranges.push(selection.getRangeAt(i)); + } + + setTimeout(() => { + if (selection.rangeCount !== ranges.length) return; + + for (let i = 0; i < selection.rangeCount; i += 1) { + const a = ranges[i]; + const b = selection.getRangeAt(i); + + // we need to do a deep comparison rather than just `a !== b` because + // Safari behaves differently to other browsers + if ( + a.commonAncestorContainer !== b.commonAncestorContainer || + a.startContainer !== b.startContainer || + a.endContainer !== b.endContainer || + a.startOffset !== b.startOffset || + a.endOffset !== b.endOffset + ) { + return; + } + } + + // if the selection hasn't changed (as a result of an element being (auto)focused, + // or a programmatic selection, we reset everything as part of the navigation) + // fixes https://github.com/sveltejs/kit/issues/8439 + selection.removeAllRanges(); + }); + } + } +} + +/** + * @param {import('./types.js').NavigationState} current + * @param {import('./types.js').NavigationIntent | undefined} intent + * @param {URL | null} url + * @param {Exclude} type + */ +function create_navigation(current, intent, url, type) { + /** @type {(value: any) => void} */ + let fulfil; + + /** @type {(error: any) => void} */ + let reject; + + const complete = new Promise((f, r) => { + fulfil = f; + reject = r; + }); + + // Handle any errors off-chain so that it doesn't show up as an unhandled rejection + complete.catch(() => {}); + + /** @type {import('@sveltejs/kit').Navigation} */ + const navigation = { + from: { + params: current.params, + route: { id: current.route?.id ?? null }, + url: current.url + }, + to: url && { + params: intent?.params ?? null, + route: { id: intent?.route?.id ?? null }, + url + }, + willUnload: !intent, + type, + complete + }; + + return { + navigation, + // @ts-expect-error + fulfil, + // @ts-expect-error + reject + }; +} + +if (DEV) { + // Nasty hack to silence harmless warnings the user can do nothing about + const console_warn = console.warn; + console.warn = function warn(...args) { + if ( + args.length === 1 && + /<(Layout|Page|Error)(_[\w$]+)?> was created (with unknown|without expected) prop '(data|form)'/.test( + args[0] + ) + ) { + return; + } + console_warn(...args); + }; + + if (import.meta.hot) { + import.meta.hot.on('vite:beforeUpdate', () => { + if (errored) { + location.reload(); + } + }); + } +} diff --git a/node_modules/@sveltejs/kit/src/runtime/client/constants.js b/node_modules/@sveltejs/kit/src/runtime/client/constants.js new file mode 100644 index 000000000..982c25d7d --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/client/constants.js @@ -0,0 +1,16 @@ +export const SNAPSHOT_KEY = 'sveltekit:snapshot'; +export const SCROLL_KEY = 'sveltekit:scroll'; +export const STATES_KEY = 'sveltekit:states'; +export const PAGE_URL_KEY = 'sveltekit:pageurl'; + +export const HISTORY_INDEX = 'sveltekit:history'; +export const NAVIGATION_INDEX = 'sveltekit:navigation'; + +export const PRELOAD_PRIORITIES = /** @type {const} */ ({ + tap: 1, + hover: 2, + viewport: 3, + eager: 4, + off: -1, + false: -1 +}); diff --git a/node_modules/@sveltejs/kit/src/runtime/client/fetcher.js b/node_modules/@sveltejs/kit/src/runtime/client/fetcher.js new file mode 100644 index 000000000..6692ea13e --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/client/fetcher.js @@ -0,0 +1,189 @@ +import { DEV } from 'esm-env'; +import { hash } from '../hash.js'; + +let loading = 0; + +export const native_fetch = window.fetch; + +export function lock_fetch() { + loading += 1; +} + +export function unlock_fetch() { + loading -= 1; +} + +if (DEV) { + let can_inspect_stack_trace = false; + + const check_stack_trace = async () => { + const stack = /** @type {string} */ (new Error().stack); + can_inspect_stack_trace = stack.includes('check_stack_trace'); + }; + + check_stack_trace(); + + /** + * @param {RequestInfo | URL} input + * @param {RequestInit & Record | undefined} init + */ + window.fetch = (input, init) => { + // Check if fetch was called via load_node. the lock method only checks if it was called at the + // same time, but not necessarily if it was called from `load`. + // We use just the filename as the method name sometimes does not appear on the CI. + const url = input instanceof Request ? input.url : input.toString(); + const stack_array = /** @type {string} */ (new Error().stack).split('\n'); + // We need to do a cutoff because Safari and Firefox maintain the stack + // across events and for example traces a `fetch` call triggered from a button + // back to the creation of the event listener and the element creation itself, + // where at some point client.js will show up, leading to false positives. + const cutoff = stack_array.findIndex((a) => a.includes('load@') || a.includes('at load')); + const stack = stack_array.slice(0, cutoff + 2).join('\n'); + + const in_load_heuristic = can_inspect_stack_trace + ? stack.includes('src/runtime/client/client.js') + : loading; + + // This flag is set in initial_fetch and subsequent_fetch + const used_kit_fetch = init?.__sveltekit_fetch__; + + if (in_load_heuristic && !used_kit_fetch) { + console.warn( + `Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/load#making-fetch-requests` + ); + } + + const method = input instanceof Request ? input.method : init?.method || 'GET'; + + if (method !== 'GET') { + cache.delete(build_selector(input)); + } + + return native_fetch(input, init); + }; +} else { + window.fetch = (input, init) => { + const method = input instanceof Request ? input.method : init?.method || 'GET'; + + if (method !== 'GET') { + cache.delete(build_selector(input)); + } + + return native_fetch(input, init); + }; +} + +const cache = new Map(); + +/** + * @param {string} text + * @returns {ArrayBufferLike} + */ +function b64_decode(text) { + const d = atob(text); + + const u8 = new Uint8Array(d.length); + + for (let i = 0; i < d.length; i++) { + u8[i] = d.charCodeAt(i); + } + + return u8.buffer; +} + +/** + * Should be called on the initial run of load functions that hydrate the page. + * Saves any requests with cache-control max-age to the cache. + * @param {URL | string} resource + * @param {RequestInit} [opts] + */ +export function initial_fetch(resource, opts) { + const selector = build_selector(resource, opts); + + const script = document.querySelector(selector); + if (script?.textContent) { + let { body, ...init } = JSON.parse(script.textContent); + + const ttl = script.getAttribute('data-ttl'); + if (ttl) cache.set(selector, { body, init, ttl: 1000 * Number(ttl) }); + const b64 = script.getAttribute('data-b64'); + if (b64 !== null) { + // Can't use native_fetch('data:...;base64,${body}') + // csp can block the request + body = b64_decode(body); + } + + return Promise.resolve(new Response(body, init)); + } + + return DEV ? dev_fetch(resource, opts) : window.fetch(resource, opts); +} + +/** + * Tries to get the response from the cache, if max-age allows it, else does a fetch. + * @param {URL | string} resource + * @param {string} resolved + * @param {RequestInit} [opts] + */ +export function subsequent_fetch(resource, resolved, opts) { + if (cache.size > 0) { + const selector = build_selector(resource, opts); + const cached = cache.get(selector); + if (cached) { + // https://developer.mozilla.org/en-US/docs/Web/API/Request/cache#value + if ( + performance.now() < cached.ttl && + ['default', 'force-cache', 'only-if-cached', undefined].includes(opts?.cache) + ) { + return new Response(cached.body, cached.init); + } + + cache.delete(selector); + } + } + + return DEV ? dev_fetch(resolved, opts) : window.fetch(resolved, opts); +} + +/** + * @param {RequestInfo | URL} resource + * @param {RequestInit & Record | undefined} opts + */ +function dev_fetch(resource, opts) { + const patched_opts = { ...opts }; + // This assigns the __sveltekit_fetch__ flag and makes it non-enumerable + Object.defineProperty(patched_opts, '__sveltekit_fetch__', { + value: true, + writable: true, + configurable: true + }); + return window.fetch(resource, patched_opts); +} + +/** + * Build the cache key for a given request + * @param {URL | RequestInfo} resource + * @param {RequestInit} [opts] + */ +function build_selector(resource, opts) { + const url = JSON.stringify(resource instanceof Request ? resource.url : resource); + + let selector = `script[data-sveltekit-fetched][data-url=${url}]`; + + if (opts?.headers || opts?.body) { + /** @type {import('types').StrictBody[]} */ + const values = []; + + if (opts.headers) { + values.push([...new Headers(opts.headers)].join(',')); + } + + if (opts.body && (typeof opts.body === 'string' || ArrayBuffer.isView(opts.body))) { + values.push(opts.body); + } + + selector += `[data-hash="${hash(...values)}"]`; + } + + return selector; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/client/parse.js b/node_modules/@sveltejs/kit/src/runtime/client/parse.js new file mode 100644 index 000000000..5abf1a7e3 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/client/parse.js @@ -0,0 +1,57 @@ +import { exec, parse_route_id } from '../../utils/routing.js'; + +/** + * @param {import('./types.js').SvelteKitApp} app + * @returns {import('types').CSRRoute[]} + */ +export function parse({ nodes, server_loads, dictionary, matchers }) { + const layouts_with_server_load = new Set(server_loads); + + return Object.entries(dictionary).map(([id, [leaf, layouts, errors]]) => { + const { pattern, params } = parse_route_id(id); + + const route = { + id, + /** @param {string} path */ + exec: (path) => { + const match = pattern.exec(path); + if (match) return exec(match, params, matchers); + }, + errors: [1, ...(errors || [])].map((n) => nodes[n]), + layouts: [0, ...(layouts || [])].map(create_layout_loader), + leaf: create_leaf_loader(leaf) + }; + + // bit of a hack, but ensures that layout/error node lists are the same + // length, without which the wrong data will be applied if the route + // manifest looks like `[[a, b], [c,], d]` + route.errors.length = route.layouts.length = Math.max( + route.errors.length, + route.layouts.length + ); + + return route; + }); + + /** + * @param {number} id + * @returns {[boolean, import('types').CSRPageNodeLoader]} + */ + function create_leaf_loader(id) { + // whether or not the route uses the server data is + // encoded using the ones' complement, to save space + const uses_server_data = id < 0; + if (uses_server_data) id = ~id; + return [uses_server_data, nodes[id]]; + } + + /** + * @param {number | undefined} id + * @returns {[boolean, import('types').CSRPageNodeLoader] | undefined} + */ + function create_layout_loader(id) { + // whether or not the layout uses the server data is + // encoded in the layouts array, to save space + return id === undefined ? id : [layouts_with_server_load.has(id), nodes[id]]; + } +} diff --git a/node_modules/@sveltejs/kit/src/runtime/client/session-storage.js b/node_modules/@sveltejs/kit/src/runtime/client/session-storage.js new file mode 100644 index 000000000..e49543bc8 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/client/session-storage.js @@ -0,0 +1,27 @@ +/** + * Read a value from `sessionStorage` + * @param {string} key + * @param {(value: string) => any} parse + */ +export function get(key, parse = JSON.parse) { + try { + return parse(sessionStorage[key]); + } catch { + // do nothing + } +} + +/** + * Write a value to `sessionStorage` + * @param {string} key + * @param {any} value + * @param {(value: any) => string} stringify + */ +export function set(key, value, stringify = JSON.stringify) { + const data = stringify(value); + try { + sessionStorage[key] = data; + } catch { + // do nothing + } +} diff --git a/node_modules/@sveltejs/kit/src/runtime/client/singletons.js b/node_modules/@sveltejs/kit/src/runtime/client/singletons.js new file mode 100644 index 000000000..aacaa0490 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/client/singletons.js @@ -0,0 +1,59 @@ +import { writable } from 'svelte/store'; +import { create_updated_store, notifiable_store } from './utils.js'; +import { BROWSER } from 'esm-env'; + +/** @type {import('./types.js').Client} */ +export let client; + +/** + * @param {{ + * client: import('./types.js').Client; + * }} opts + */ +export function init(opts) { + client = opts.client; +} + +/** + * @template {keyof typeof client} T + * @param {T} key + * @returns {typeof client[T]} + */ +export function client_method(key) { + if (!BROWSER) { + if ( + key === 'before_navigate' || + key === 'after_navigate' || + key === 'on_navigate' || + key === 'push_state' || + key === 'replace_state' + ) { + // @ts-expect-error doesn't recognize that both keys here return void so expects a async function + return () => {}; + } else { + /** @type {Record} */ + const name_lookup = { + disable_scroll_handling: 'disableScrollHandling', + preload_data: 'preloadData', + preload_code: 'preloadCode', + invalidate_all: 'invalidateAll' + }; + + return () => { + throw new Error(`Cannot call ${name_lookup[key] ?? key}(...) on the server`); + }; + } + } else { + // @ts-expect-error + return (...args) => client[key](...args); + } +} + +export const stores = { + url: /* @__PURE__ */ notifiable_store({}), + page: /* @__PURE__ */ notifiable_store({}), + navigating: /* @__PURE__ */ writable( + /** @type {import('@sveltejs/kit').Navigation | null} */ (null) + ), + updated: /* @__PURE__ */ create_updated_store() +}; diff --git a/node_modules/@sveltejs/kit/src/runtime/client/start.js b/node_modules/@sveltejs/kit/src/runtime/client/start.js new file mode 100644 index 000000000..0ef12e627 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/client/start.js @@ -0,0 +1,28 @@ +import { DEV } from 'esm-env'; +import { create_client } from './client.js'; +import { init } from './singletons.js'; + +/** + * @param {import('./types.js').SvelteKitApp} app + * @param {HTMLElement} target + * @param {Parameters[0]} [hydrate] + */ +export async function start(app, target, hydrate) { + if (DEV && target === document.body) { + console.warn( + 'Placing %sveltekit.body% directly inside is not recommended, as your app may break for users who have certain browser extensions installed.\n\nConsider wrapping it in an element:\n\n

' + ); + } + + const client = create_client(app, target); + + init({ client }); + + if (hydrate) { + await client._hydrate(hydrate); + } else { + client.goto(location.href, { replaceState: true }); + } + + client._start_router(); +} diff --git a/node_modules/@sveltejs/kit/src/runtime/client/types.d.ts b/node_modules/@sveltejs/kit/src/runtime/client/types.d.ts new file mode 100644 index 000000000..458c36ddd --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/client/types.d.ts @@ -0,0 +1,127 @@ +import { applyAction } from '../app/forms.js'; +import { + afterNavigate, + beforeNavigate, + onNavigate, + goto, + invalidate, + invalidateAll, + preloadCode, + preloadData, + pushState, + replaceState +} from '../app/navigation.js'; +import { SvelteComponent } from 'svelte'; +import { ClientHooks, CSRPageNode, CSRPageNodeLoader, CSRRoute, TrailingSlash, Uses } from 'types'; +import { Page, ParamMatcher } from '@sveltejs/kit'; + +export interface SvelteKitApp { + /** + * A list of all the error/layout/page nodes used in the app + */ + nodes: CSRPageNodeLoader[]; + + /** + * A list of all layout node ids that have a server load function. + * Pages are not present because it's shorter to encode it on the leaf itself. + */ + server_loads: number[]; + + /** + * A map of `[routeId: string]: [leaf, layouts, errors]` tuples, which + * is parsed into an array of routes on startup. The numbers refer to the indices in `nodes`. + * If the leaf number is negative, it means it does use a server load function and the complement is the node index. + * The route layout and error nodes are not referenced, they are always number 0 and 1 and always apply. + */ + dictionary: Record; + + matchers: Record; + + hooks: ClientHooks; + + root: typeof SvelteComponent; +} + +export interface Client { + // public API, exposed via $app/navigation + after_navigate: typeof afterNavigate; + before_navigate: typeof beforeNavigate; + on_navigate: typeof onNavigate; + disable_scroll_handling(): void; + goto: typeof goto; + invalidate: typeof invalidate; + invalidate_all: typeof invalidateAll; + preload_code: typeof preloadCode; + preload_data: typeof preloadData; + push_state: typeof pushState; + replace_state: typeof replaceState; + apply_action: typeof applyAction; + + // private API + _hydrate(opts: { + status: number; + error: App.Error | null; + node_ids: number[]; + params: Record; + route: { id: string | null }; + data: Array; + form: Record | null; + }): Promise; + _start_router(): void; +} + +export type NavigationIntent = { + /** `url.pathname + url.search` */ + id: string; + /** Whether we are invalidating or navigating */ + invalidating: boolean; + /** The route parameters */ + params: Record; + /** The route that matches `path` */ + route: CSRRoute; + /** The destination URL */ + url: URL; +}; + +export type NavigationResult = NavigationRedirect | NavigationFinished; + +export type NavigationRedirect = { + type: 'redirect'; + location: string; +}; + +export type NavigationFinished = { + type: 'loaded'; + state: NavigationState; + props: { + constructors: Array; + components?: Array; + page: Page; + form?: Record | null; + [key: `data_${number}`]: Record; + }; +}; + +export type BranchNode = { + node: CSRPageNode; + loader: CSRPageNodeLoader; + server: DataNode | null; + universal: DataNode | null; + data: Record | null; + slash?: TrailingSlash; +}; + +export interface DataNode { + type: 'data'; + data: Record | null; + uses: Uses; + slash?: TrailingSlash; +} + +export interface NavigationState { + branch: Array; + error: App.Error | null; + params: Record; + route: CSRRoute | null; + url: URL; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/client/utils.js b/node_modules/@sveltejs/kit/src/runtime/client/utils.js new file mode 100644 index 000000000..d205f48cd --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/client/utils.js @@ -0,0 +1,298 @@ +import { BROWSER, DEV } from 'esm-env'; +import { writable } from 'svelte/store'; +import { assets } from '__sveltekit/paths'; +import { version } from '__sveltekit/environment'; +import { PRELOAD_PRIORITIES } from './constants.js'; + +/* global __SVELTEKIT_APP_VERSION_FILE__, __SVELTEKIT_APP_VERSION_POLL_INTERVAL__ */ + +export const origin = BROWSER ? location.origin : ''; + +/** @param {string | URL} url */ +export function resolve_url(url) { + if (url instanceof URL) return url; + + let baseURI = document.baseURI; + + if (!baseURI) { + const baseTags = document.getElementsByTagName('base'); + baseURI = baseTags.length ? baseTags[0].href : document.URL; + } + + return new URL(url, baseURI); +} + +export function scroll_state() { + return { + x: pageXOffset, + y: pageYOffset + }; +} + +const warned = new WeakSet(); + +/** @typedef {keyof typeof valid_link_options} LinkOptionName */ + +const valid_link_options = /** @type {const} */ ({ + 'preload-code': ['', 'off', 'false', 'tap', 'hover', 'viewport', 'eager'], + 'preload-data': ['', 'off', 'false', 'tap', 'hover'], + keepfocus: ['', 'true', 'off', 'false'], + noscroll: ['', 'true', 'off', 'false'], + reload: ['', 'true', 'off', 'false'], + replacestate: ['', 'true', 'off', 'false'] +}); + +/** + * @template {LinkOptionName} T + * @typedef {typeof valid_link_options[T][number]} ValidLinkOptions + */ + +/** + * @template {LinkOptionName} T + * @param {Element} element + * @param {T} name + */ +function link_option(element, name) { + const value = /** @type {ValidLinkOptions | null} */ ( + element.getAttribute(`data-sveltekit-${name}`) + ); + + if (DEV) { + validate_link_option(element, name, value); + } + + return value; +} + +/** + * @template {LinkOptionName} T + * @template {ValidLinkOptions | null} U + * @param {Element} element + * @param {T} name + * @param {U} value + */ +function validate_link_option(element, name, value) { + if (value === null) return; + + // @ts-expect-error - includes is dumb + if (!warned.has(element) && !valid_link_options[name].includes(value)) { + console.error( + `Unexpected value for ${name} — should be one of ${valid_link_options[name] + .map((option) => JSON.stringify(option)) + .join(', ')}`, + element + ); + + warned.add(element); + } +} + +const levels = { + ...PRELOAD_PRIORITIES, + '': PRELOAD_PRIORITIES.hover +}; + +/** + * @param {Element} element + * @returns {Element | null} + */ +function parent_element(element) { + let parent = element.assignedSlot ?? element.parentNode; + + // @ts-expect-error handle shadow roots + if (parent?.nodeType === 11) parent = parent.host; + + return /** @type {Element} */ (parent); +} + +/** + * @param {Element} element + * @param {Element} target + */ +export function find_anchor(element, target) { + while (element && element !== target) { + if (element.nodeName.toUpperCase() === 'A' && element.hasAttribute('href')) { + return /** @type {HTMLAnchorElement | SVGAElement} */ (element); + } + + element = /** @type {Element} */ (parent_element(element)); + } +} + +/** + * @param {HTMLAnchorElement | SVGAElement} a + * @param {string} base + */ +export function get_link_info(a, base) { + /** @type {URL | undefined} */ + let url; + + try { + url = new URL(a instanceof SVGAElement ? a.href.baseVal : a.href, document.baseURI); + } catch {} + + const target = a instanceof SVGAElement ? a.target.baseVal : a.target; + + const external = + !url || + !!target || + is_external_url(url, base) || + (a.getAttribute('rel') || '').split(/\s+/).includes('external'); + + const download = url?.origin === origin && a.hasAttribute('download'); + + return { url, external, target, download }; +} + +/** + * @param {HTMLFormElement | HTMLAnchorElement | SVGAElement} element + */ +export function get_router_options(element) { + /** @type {ValidLinkOptions<'keepfocus'> | null} */ + let keepfocus = null; + + /** @type {ValidLinkOptions<'noscroll'> | null} */ + let noscroll = null; + + /** @type {ValidLinkOptions<'preload-code'> | null} */ + let preload_code = null; + + /** @type {ValidLinkOptions<'preload-data'> | null} */ + let preload_data = null; + + /** @type {ValidLinkOptions<'reload'> | null} */ + let reload = null; + + /** @type {ValidLinkOptions<'replacestate'> | null} */ + let replace_state = null; + + /** @type {Element} */ + let el = element; + + while (el && el !== document.documentElement) { + if (preload_code === null) preload_code = link_option(el, 'preload-code'); + if (preload_data === null) preload_data = link_option(el, 'preload-data'); + if (keepfocus === null) keepfocus = link_option(el, 'keepfocus'); + if (noscroll === null) noscroll = link_option(el, 'noscroll'); + if (reload === null) reload = link_option(el, 'reload'); + if (replace_state === null) replace_state = link_option(el, 'replacestate'); + + el = /** @type {Element} */ (parent_element(el)); + } + + /** @param {string | null} value */ + function get_option_state(value) { + switch (value) { + case '': + case 'true': + return true; + case 'off': + case 'false': + return false; + default: + return undefined; + } + } + + return { + preload_code: levels[preload_code ?? 'off'], + preload_data: levels[preload_data ?? 'off'], + keepfocus: get_option_state(keepfocus), + noscroll: get_option_state(noscroll), + reload: get_option_state(reload), + replace_state: get_option_state(replace_state) + }; +} + +/** @param {any} value */ +export function notifiable_store(value) { + const store = writable(value); + let ready = true; + + function notify() { + ready = true; + store.update((val) => val); + } + + /** @param {any} new_value */ + function set(new_value) { + ready = false; + store.set(new_value); + } + + /** @param {(value: any) => void} run */ + function subscribe(run) { + /** @type {any} */ + 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 }; +} + +export function create_updated_store() { + const { set, subscribe } = writable(false); + + if (DEV || !BROWSER) { + return { + subscribe, + check: async () => false + }; + } + + const interval = __SVELTEKIT_APP_VERSION_POLL_INTERVAL__; + + /** @type {NodeJS.Timeout} */ + let timeout; + + /** @type {() => Promise} */ + async function check() { + clearTimeout(timeout); + + if (interval) timeout = setTimeout(check, interval); + + try { + const res = await fetch(`${assets}/${__SVELTEKIT_APP_VERSION_FILE__}`, { + headers: { + pragma: 'no-cache', + 'cache-control': 'no-cache' + } + }); + + if (!res.ok) { + return false; + } + + const data = await res.json(); + const updated = data.version !== version; + + if (updated) { + set(true); + clearTimeout(timeout); + } + + return updated; + } catch { + return false; + } + } + + if (interval) timeout = setTimeout(check, interval); + + return { + subscribe, + check + }; +} + +/** + * @param {URL} url + * @param {string} base + */ +export function is_external_url(url, base) { + return url.origin !== origin || !url.pathname.startsWith(base); +} diff --git a/node_modules/@sveltejs/kit/src/runtime/components/error.svelte b/node_modules/@sveltejs/kit/src/runtime/components/error.svelte new file mode 100644 index 000000000..b82ddfaed --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/components/error.svelte @@ -0,0 +1,6 @@ + + +

{$page.status}

+

{$page.error?.message}

diff --git a/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte b/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte new file mode 100644 index 000000000..4fa864ce7 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte @@ -0,0 +1 @@ + diff --git a/node_modules/@sveltejs/kit/src/runtime/control.js b/node_modules/@sveltejs/kit/src/runtime/control.js new file mode 100644 index 000000000..64737a9cf --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/control.js @@ -0,0 +1,87 @@ +export class HttpError { + /** + * @param {number} status + * @param {{message: string} extends App.Error ? (App.Error | string | undefined) : App.Error} body + */ + constructor(status, body) { + this.status = status; + if (typeof body === 'string') { + this.body = { message: body }; + } else if (body) { + this.body = body; + } else { + this.body = { message: `Error: ${status}` }; + } + } + + toString() { + return JSON.stringify(this.body); + } +} + +export class Redirect { + /** + * @param {300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308} status + * @param {string} location + */ + constructor(status, location) { + this.status = status; + this.location = location; + } +} + +/** + * An error that was thrown from within the SvelteKit runtime that is not fatal and doesn't result in a 500, such as a 404. + * `SvelteKitError` goes through `handleError`. + * @extends Error + */ +export class SvelteKitError extends Error { + /** + * @param {number} status + * @param {string} text + * @param {string} message + */ + constructor(status, text, message) { + super(message); + this.status = status; + this.text = text; + } +} + +/** + * @template {Record | undefined} [T=undefined] + */ +export class ActionFailure { + /** + * @param {number} status + * @param {T} data + */ + constructor(status, data) { + this.status = status; + this.data = data; + } +} + +/** + * This is a grotesque hack that, in dev, allows us to replace the implementations + * of these classes that you'd get by importing them from `@sveltejs/kit` with the + * ones that are imported via Vite and loaded internally, so that instanceof + * checks work even though SvelteKit imports this module via Vite and consumers + * import it via Node + * @param {{ + * ActionFailure: typeof ActionFailure; + * HttpError: typeof HttpError; + * Redirect: typeof Redirect; + * SvelteKitError: typeof SvelteKitError; + * }} implementations + */ +export function replace_implementations(implementations) { + // @ts-expect-error + ActionFailure = implementations.ActionFailure; // eslint-disable-line no-class-assign + // @ts-expect-error + HttpError = implementations.HttpError; // eslint-disable-line no-class-assign + // @ts-expect-error + Redirect = implementations.Redirect; // eslint-disable-line no-class-assign + // @ts-expect-error + SvelteKitError = implementations.SvelteKitError; // eslint-disable-line no-class-assign +} diff --git a/node_modules/@sveltejs/kit/src/runtime/env/dynamic/private.js b/node_modules/@sveltejs/kit/src/runtime/env/dynamic/private.js new file mode 100644 index 000000000..1965ee8bc --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/env/dynamic/private.js @@ -0,0 +1 @@ +export { private_env as env } from '../../shared-server.js'; diff --git a/node_modules/@sveltejs/kit/src/runtime/env/dynamic/public.js b/node_modules/@sveltejs/kit/src/runtime/env/dynamic/public.js new file mode 100644 index 000000000..919d034b5 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/env/dynamic/public.js @@ -0,0 +1 @@ +export { public_env as env } from '../../shared-server.js'; diff --git a/node_modules/@sveltejs/kit/src/runtime/hash.js b/node_modules/@sveltejs/kit/src/runtime/hash.js new file mode 100644 index 000000000..cfebacb38 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/hash.js @@ -0,0 +1,22 @@ +/** + * Hash using djb2 + * @param {import('types').StrictBody[]} values + */ +export function hash(...values) { + let hash = 5381; + + for (const value of values) { + if (typeof value === 'string') { + let i = value.length; + while (i) hash = (hash * 33) ^ value.charCodeAt(--i); + } else if (ArrayBuffer.isView(value)) { + const buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength); + let i = buffer.length; + while (i) hash = (hash * 33) ^ buffer[--i]; + } else { + throw new TypeError('value must be a string or TypedArray'); + } + } + + return (hash >>> 0).toString(36); +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/ambient.d.ts b/node_modules/@sveltejs/kit/src/runtime/server/ambient.d.ts new file mode 100644 index 000000000..c893c94ff --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/ambient.d.ts @@ -0,0 +1,8 @@ +declare module '__SERVER__/internal.js' { + export const options: import('types').SSROptions; + export const get_hooks: () => Promise<{ + handle?: import('@sveltejs/kit').Handle; + handleError?: import('@sveltejs/kit').HandleServerError; + handleFetch?: import('@sveltejs/kit').HandleFetch; + }>; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/cookie.js b/node_modules/@sveltejs/kit/src/runtime/server/cookie.js new file mode 100644 index 000000000..7acd24417 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/cookie.js @@ -0,0 +1,265 @@ +import { parse, serialize } from 'cookie'; +import { add_data_suffix, normalize_path, resolve } from '../../utils/url.js'; + +/** + * Tracks all cookies set during dev mode so we can emit warnings + * when we detect that there's likely cookie misusage due to wrong paths + * + * @type {Record>} */ +const cookie_paths = {}; + +/** + * Cookies that are larger than this size (including the name and other + * attributes) are discarded by browsers + */ +const MAX_COOKIE_SIZE = 4129; + +// TODO 3.0 remove this check +/** @param {import('./page/types.js').Cookie['options']} options */ +function validate_options(options) { + if (options?.path === undefined) { + throw new Error('You must specify a `path` when setting, deleting or serializing cookies'); + } +} + +/** + * @param {Request} request + * @param {URL} url + * @param {import('types').TrailingSlash} trailing_slash + */ +export function get_cookies(request, url, trailing_slash) { + const header = request.headers.get('cookie') ?? ''; + const initial_cookies = parse(header, { decode: (value) => value }); + + const normalized_url = normalize_path(url.pathname, trailing_slash); + + /** @type {Record} */ + const new_cookies = {}; + + /** @type {import('cookie').CookieSerializeOptions} */ + const defaults = { + httpOnly: true, + sameSite: 'lax', + secure: url.hostname === 'localhost' && url.protocol === 'http:' ? false : true + }; + + /** @type {import('@sveltejs/kit').Cookies} */ + const cookies = { + // The JSDoc param annotations appearing below for get, set and delete + // are necessary to expose the `cookie` library types to + // typescript users. `@type {import('@sveltejs/kit').Cookies}` above is not + // sufficient to do so. + + /** + * @param {string} name + * @param {import('cookie').CookieParseOptions} opts + */ + get(name, opts) { + const c = new_cookies[name]; + if ( + c && + domain_matches(url.hostname, c.options.domain) && + path_matches(url.pathname, c.options.path) + ) { + return c.value; + } + + const decoder = opts?.decode || decodeURIComponent; + const req_cookies = parse(header, { decode: decoder }); + const cookie = req_cookies[name]; // the decoded string or undefined + + // in development, if the cookie was set during this session with `cookies.set`, + // but at a different path, warn the user. (ignore cookies from request headers, + // since we don't know which path they were set at) + if (__SVELTEKIT_DEV__ && !cookie) { + const paths = Array.from(cookie_paths[name] ?? []).filter((path) => { + // we only care about paths that are _more_ specific than the current path + return path_matches(path, url.pathname) && path !== url.pathname; + }); + + if (paths.length > 0) { + console.warn( + // prettier-ignore + `'${name}' cookie does not exist for ${url.pathname}, but was previously set at ${conjoin([...paths])}. Did you mean to set its 'path' to '/' instead?` + ); + } + } + + return cookie; + }, + + /** + * @param {import('cookie').CookieParseOptions} opts + */ + getAll(opts) { + const decoder = opts?.decode || decodeURIComponent; + const cookies = parse(header, { decode: decoder }); + + for (const c of Object.values(new_cookies)) { + if ( + domain_matches(url.hostname, c.options.domain) && + path_matches(url.pathname, c.options.path) + ) { + cookies[c.name] = c.value; + } + } + + return Object.entries(cookies).map(([name, value]) => ({ name, value })); + }, + + /** + * @param {string} name + * @param {string} value + * @param {import('./page/types.js').Cookie['options']} options + */ + set(name, value, options) { + validate_options(options); + set_internal(name, value, { ...defaults, ...options }); + }, + + /** + * @param {string} name + * @param {import('./page/types.js').Cookie['options']} options + */ + delete(name, options) { + validate_options(options); + cookies.set(name, '', { ...options, maxAge: 0 }); + }, + + /** + * @param {string} name + * @param {string} value + * @param {import('./page/types.js').Cookie['options']} options + */ + serialize(name, value, options) { + validate_options(options); + + let path = options.path; + + if (!options.domain || options.domain === url.hostname) { + path = resolve(normalized_url, path); + } + + return serialize(name, value, { ...defaults, ...options, path }); + } + }; + + /** + * @param {URL} destination + * @param {string | null} header + */ + function get_cookie_header(destination, header) { + /** @type {Record} */ + const combined_cookies = { + // cookies sent by the user agent have lowest precedence + ...initial_cookies + }; + + // cookies previous set during this event with cookies.set have higher precedence + for (const key in new_cookies) { + const cookie = new_cookies[key]; + if (!domain_matches(destination.hostname, cookie.options.domain)) continue; + if (!path_matches(destination.pathname, cookie.options.path)) continue; + + const encoder = cookie.options.encode || encodeURIComponent; + combined_cookies[cookie.name] = encoder(cookie.value); + } + + // explicit header has highest precedence + if (header) { + const parsed = parse(header, { decode: (value) => value }); + for (const name in parsed) { + combined_cookies[name] = parsed[name]; + } + } + + return Object.entries(combined_cookies) + .map(([name, value]) => `${name}=${value}`) + .join('; '); + } + + /** + * @param {string} name + * @param {string} value + * @param {import('./page/types.js').Cookie['options']} options + */ + function set_internal(name, value, options) { + let path = options.path; + + if (!options.domain || options.domain === url.hostname) { + path = resolve(normalized_url, path); + } + + new_cookies[name] = { name, value, options: { ...options, path } }; + + if (__SVELTEKIT_DEV__) { + const serialized = serialize(name, value, new_cookies[name].options); + if (new TextEncoder().encode(serialized).byteLength > MAX_COOKIE_SIZE) { + throw new Error(`Cookie "${name}" is too large, and will be discarded by the browser`); + } + + cookie_paths[name] ??= new Set(); + + if (!value) { + cookie_paths[name].delete(path); + } else { + cookie_paths[name].add(path); + } + } + } + + return { cookies, new_cookies, get_cookie_header, set_internal }; +} + +/** + * @param {string} hostname + * @param {string} [constraint] + */ +export function domain_matches(hostname, constraint) { + if (!constraint) return true; + + const normalized = constraint[0] === '.' ? constraint.slice(1) : constraint; + + if (hostname === normalized) return true; + return hostname.endsWith('.' + normalized); +} + +/** + * @param {string} path + * @param {string} [constraint] + */ +export function path_matches(path, constraint) { + if (!constraint) return true; + + const normalized = constraint.endsWith('/') ? constraint.slice(0, -1) : constraint; + + if (path === normalized) return true; + return path.startsWith(normalized + '/'); +} + +/** + * @param {Headers} headers + * @param {import('./page/types.js').Cookie[]} cookies + */ +export function add_cookies_to_headers(headers, cookies) { + for (const new_cookie of cookies) { + const { name, value, options } = new_cookie; + headers.append('set-cookie', serialize(name, value, options)); + + // special case — for routes ending with .html, the route data lives in a sibling + // `.html__data.json` file rather than a child `/__data.json` file, which means + // we need to duplicate the cookie + if (options.path.endsWith('.html')) { + const path = add_data_suffix(options.path); + headers.append('set-cookie', serialize(name, value, { ...options, path })); + } + } +} + +/** + * @param {string[]} array + */ +function conjoin(array) { + if (array.length <= 2) return array.join(' and '); + return `${array.slice(0, -1).join(', ')} and ${array.at(-1)}`; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/data/index.js b/node_modules/@sveltejs/kit/src/runtime/server/data/index.js new file mode 100644 index 000000000..c0316d278 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/data/index.js @@ -0,0 +1,265 @@ +import { HttpError, SvelteKitError, Redirect } from '../../control.js'; +import { normalize_error } from '../../../utils/error.js'; +import { once } from '../../../utils/functions.js'; +import { load_server_data } from '../page/load_data.js'; +import { clarify_devalue_error, handle_error_and_jsonify, stringify_uses } from '../utils.js'; +import { normalize_path } from '../../../utils/url.js'; +import { text } from '../../../exports/index.js'; +import * as devalue from 'devalue'; +import { create_async_iterator } from '../../../utils/streaming.js'; + +const encoder = new TextEncoder(); + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {import('types').SSRRoute} route + * @param {import('types').SSROptions} options + * @param {import('@sveltejs/kit').SSRManifest} manifest + * @param {import('types').SSRState} state + * @param {boolean[] | undefined} invalidated_data_nodes + * @param {import('types').TrailingSlash} trailing_slash + * @returns {Promise} + */ +export async function render_data( + event, + route, + options, + manifest, + state, + invalidated_data_nodes, + trailing_slash +) { + if (!route.page) { + // requesting /__data.json should fail for a +server.js + return new Response(undefined, { + status: 404 + }); + } + + try { + const node_ids = [...route.page.layouts, route.page.leaf]; + const invalidated = invalidated_data_nodes ?? node_ids.map(() => true); + + let aborted = false; + + const url = new URL(event.url); + url.pathname = normalize_path(url.pathname, trailing_slash); + + const new_event = { ...event, url }; + + const functions = node_ids.map((n, i) => { + return once(async () => { + try { + if (aborted) { + return /** @type {import('types').ServerDataSkippedNode} */ ({ + type: 'skip' + }); + } + + // == because it could be undefined (in dev) or null (in build, because of JSON.stringify) + const node = n == undefined ? n : await manifest._.nodes[n](); + // load this. for the child, return as is. for the final result, stream things + return load_server_data({ + event: new_event, + state, + node, + parent: async () => { + /** @type {Record} */ + const data = {}; + for (let j = 0; j < i; j += 1) { + const parent = /** @type {import('types').ServerDataNode | null} */ ( + await functions[j]() + ); + + if (parent) { + Object.assign(data, parent.data); + } + } + return data; + } + }); + } catch (e) { + aborted = true; + throw e; + } + }); + }); + + const promises = functions.map(async (fn, i) => { + if (!invalidated[i]) { + return /** @type {import('types').ServerDataSkippedNode} */ ({ + type: 'skip' + }); + } + + return fn(); + }); + + let length = promises.length; + const nodes = await Promise.all( + promises.map((p, i) => + p.catch(async (error) => { + if (error instanceof Redirect) { + throw error; + } + + // Math.min because array isn't guaranteed to resolve in order + length = Math.min(length, i + 1); + + return /** @type {import('types').ServerErrorNode} */ ({ + type: 'error', + error: await handle_error_and_jsonify(event, options, error), + status: + error instanceof HttpError || error instanceof SvelteKitError + ? error.status + : undefined + }); + }) + ) + ); + + const { data, chunks } = get_data_json(event, options, nodes); + + if (!chunks) { + // use a normal JSON response where possible, so we get `content-length` + // and can use browser JSON devtools for easier inspecting + return json_response(data); + } + + return new Response( + new ReadableStream({ + async start(controller) { + controller.enqueue(encoder.encode(data)); + for await (const chunk of chunks) { + controller.enqueue(encoder.encode(chunk)); + } + controller.close(); + }, + + type: 'bytes' + }), + { + headers: { + // we use a proprietary content type to prevent buffering. + // the `text` prefix makes it inspectable + 'content-type': 'text/sveltekit-data', + 'cache-control': 'private, no-store' + } + } + ); + } catch (e) { + const error = normalize_error(e); + + if (error instanceof Redirect) { + return redirect_json_response(error); + } else { + return json_response(await handle_error_and_jsonify(event, options, error), 500); + } + } +} + +/** + * @param {Record | string} json + * @param {number} [status] + */ +function json_response(json, status = 200) { + return text(typeof json === 'string' ? json : JSON.stringify(json), { + status, + headers: { + 'content-type': 'application/json', + 'cache-control': 'private, no-store' + } + }); +} + +/** + * @param {Redirect} redirect + */ +export function redirect_json_response(redirect) { + return json_response({ + type: 'redirect', + location: redirect.location + }); +} + +/** + * If the serialized data contains promises, `chunks` will be an + * async iterable containing their resolutions + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {import('types').SSROptions} options + * @param {Array} nodes + * @returns {{ data: string, chunks: AsyncIterable | null }} + */ +export function get_data_json(event, options, nodes) { + let promise_id = 1; + let count = 0; + + const { iterator, push, done } = create_async_iterator(); + + const reducers = { + /** @param {any} thing */ + Promise: (thing) => { + if (typeof thing?.then === 'function') { + const id = promise_id++; + count += 1; + + /** @type {'data' | 'error'} */ + let key = 'data'; + + thing + .catch( + /** @param {any} e */ async (e) => { + key = 'error'; + return handle_error_and_jsonify(event, options, /** @type {any} */ (e)); + } + ) + .then( + /** @param {any} value */ + async (value) => { + let str; + try { + str = devalue.stringify(value, reducers); + } catch (e) { + const error = await handle_error_and_jsonify( + event, + options, + new Error(`Failed to serialize promise while rendering ${event.route.id}`) + ); + + key = 'error'; + str = devalue.stringify(error, reducers); + } + + count -= 1; + + push(`{"type":"chunk","id":${id},"${key}":${str}}\n`); + if (count === 0) done(); + } + ); + + return id; + } + } + }; + + try { + const strings = nodes.map((node) => { + if (!node) return 'null'; + + if (node.type === 'error' || node.type === 'skip') { + return JSON.stringify(node); + } + + return `{"type":"data","data":${devalue.stringify(node.data, reducers)},${stringify_uses( + node + )}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ''}}`; + }); + + return { + data: `{"type":"data","nodes":[${strings.join(',')}]}\n`, + chunks: count > 0 ? iterator : null + }; + } catch (e) { + throw new Error(clarify_devalue_error(event, /** @type {any} */ (e))); + } +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/endpoint.js b/node_modules/@sveltejs/kit/src/runtime/server/endpoint.js new file mode 100644 index 000000000..55bcd8780 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/endpoint.js @@ -0,0 +1,94 @@ +import { ENDPOINT_METHODS, PAGE_METHODS } from '../../constants.js'; +import { negotiate } from '../../utils/http.js'; +import { Redirect } from '../control.js'; +import { method_not_allowed } from './utils.js'; + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {import('types').SSREndpoint} mod + * @param {import('types').SSRState} state + * @returns {Promise} + */ +export async function render_endpoint(event, mod, state) { + const method = /** @type {import('types').HttpMethod} */ (event.request.method); + + let handler = mod[method] || mod.fallback; + + if (method === 'HEAD' && mod.GET && !mod.HEAD) { + handler = mod.GET; + } + + if (!handler) { + return method_not_allowed(mod, method); + } + + const prerender = mod.prerender ?? state.prerender_default; + + if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) { + throw new Error('Cannot prerender endpoints that have mutative methods'); + } + + if (state.prerendering && !prerender) { + if (state.depth > 0) { + // if request came from a prerendered page, bail + throw new Error(`${event.route.id} is not prerenderable`); + } else { + // if request came direct from the crawler, signal that + // this route cannot be prerendered, but don't bail + return new Response(undefined, { status: 204 }); + } + } + + try { + let response = await handler( + /** @type {import('@sveltejs/kit').RequestEvent>} */ (event) + ); + + if (!(response instanceof Response)) { + throw new Error( + `Invalid response from route ${event.url.pathname}: handler should return a Response object` + ); + } + + if (state.prerendering) { + // the returned Response might have immutable Headers + // so we should clone them before trying to mutate them + response = new Response(response.body, { + status: response.status, + statusText: response.statusText, + headers: new Headers(response.headers) + }); + response.headers.set('x-sveltekit-prerender', String(prerender)); + } + + return response; + } catch (e) { + if (e instanceof Redirect) { + return new Response(undefined, { + status: e.status, + headers: { location: e.location } + }); + } + + throw e; + } +} + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + */ +export function is_endpoint_request(event) { + const { method, headers } = event.request; + + // These methods exist exclusively for endpoints + if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) { + return true; + } + + // use:enhance uses a custom header to disambiguate + if (method === 'POST' && headers.get('x-sveltekit-action') === 'true') return false; + + // GET/POST requests may be for endpoints or pages. We prefer endpoints if this isn't a text/html request + const accept = event.request.headers.get('accept') ?? '*/*'; + return negotiate(accept, ['*', 'text/html']) !== 'text/html'; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/env_module.js b/node_modules/@sveltejs/kit/src/runtime/server/env_module.js new file mode 100644 index 000000000..7d37ac6a1 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/env_module.js @@ -0,0 +1,29 @@ +import { public_env } from '../shared-server.js'; + +/** @type {string} */ +let body; + +/** @type {string} */ +let etag; + +/** @type {Headers} */ +let headers; + +/** + * @param {Request} request + * @returns {Response} + */ +export function get_public_env(request) { + body ??= `export const env=${JSON.stringify(public_env)}`; + etag ??= `W/${Date.now()}`; + headers ??= new Headers({ + 'content-type': 'application/javascript; charset=utf-8', + etag + }); + + if (request.headers.get('if-none-match') === etag) { + return new Response(undefined, { status: 304, headers }); + } + + return new Response(body, { headers }); +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/fetch.js b/node_modules/@sveltejs/kit/src/runtime/server/fetch.js new file mode 100644 index 000000000..e59112092 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/fetch.js @@ -0,0 +1,173 @@ +import * as set_cookie_parser from 'set-cookie-parser'; +import { respond } from './respond.js'; +import * as paths from '__sveltekit/paths'; + +/** + * @param {{ + * event: import('@sveltejs/kit').RequestEvent; + * options: import('types').SSROptions; + * manifest: import('@sveltejs/kit').SSRManifest; + * state: import('types').SSRState; + * get_cookie_header: (url: URL, header: string | null) => string; + * set_internal: (name: string, value: string, opts: import('./page/types.js').Cookie['options']) => void; + * }} opts + * @returns {typeof fetch} + */ +export function create_fetch({ event, options, manifest, state, get_cookie_header, set_internal }) { + /** + * @type {typeof fetch} + */ + const server_fetch = async (info, init) => { + const original_request = normalize_fetch_input(info, init, event.url); + + // some runtimes (e.g. Cloudflare) error if you access `request.mode`, + // annoyingly, so we need to read the value from the `init` object instead + let mode = (info instanceof Request ? info.mode : init?.mode) ?? 'cors'; + let credentials = + (info instanceof Request ? info.credentials : init?.credentials) ?? 'same-origin'; + + return options.hooks.handleFetch({ + event, + request: original_request, + fetch: async (info, init) => { + const request = normalize_fetch_input(info, init, event.url); + + const url = new URL(request.url); + + if (!request.headers.has('origin')) { + request.headers.set('origin', event.url.origin); + } + + if (info !== original_request) { + mode = (info instanceof Request ? info.mode : init?.mode) ?? 'cors'; + credentials = + (info instanceof Request ? info.credentials : init?.credentials) ?? 'same-origin'; + } + + // Remove Origin, according to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin#description + if ( + (request.method === 'GET' || request.method === 'HEAD') && + ((mode === 'no-cors' && url.origin !== event.url.origin) || + url.origin === event.url.origin) + ) { + request.headers.delete('origin'); + } + + if (url.origin !== event.url.origin) { + // Allow cookie passthrough for "credentials: same-origin" and "credentials: include" + // if SvelteKit is serving my.domain.com: + // - domain.com WILL NOT receive cookies + // - my.domain.com WILL receive cookies + // - api.domain.dom WILL NOT receive cookies + // - sub.my.domain.com WILL receive cookies + // ports do not affect the resolution + // leading dot prevents mydomain.com matching domain.com + // Do not forward other cookies for "credentials: include" because we don't know + // which cookie belongs to which domain (browser does not pass this info) + if (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== 'omit') { + const cookie = get_cookie_header(url, request.headers.get('cookie')); + if (cookie) request.headers.set('cookie', cookie); + } + + return fetch(request); + } + + // handle fetch requests for static assets. e.g. prebaked data, etc. + // we need to support everything the browser's fetch supports + const prefix = paths.assets || paths.base; + const decoded = decodeURIComponent(url.pathname); + const filename = ( + decoded.startsWith(prefix) ? decoded.slice(prefix.length) : decoded + ).slice(1); + const filename_html = `${filename}/index.html`; // path may also match path/index.html + + const is_asset = manifest.assets.has(filename); + const is_asset_html = manifest.assets.has(filename_html); + + if (is_asset || is_asset_html) { + const file = is_asset ? filename : filename_html; + + if (state.read) { + const type = is_asset + ? manifest.mimeTypes[filename.slice(filename.lastIndexOf('.'))] + : 'text/html'; + + return new Response(state.read(file), { + headers: type ? { 'content-type': type } : {} + }); + } + + return await fetch(request); + } + + if (credentials !== 'omit') { + const cookie = get_cookie_header(url, request.headers.get('cookie')); + if (cookie) { + request.headers.set('cookie', cookie); + } + + const authorization = event.request.headers.get('authorization'); + if (authorization && !request.headers.has('authorization')) { + request.headers.set('authorization', authorization); + } + } + + if (!request.headers.has('accept')) { + request.headers.set('accept', '*/*'); + } + + if (!request.headers.has('accept-language')) { + request.headers.set( + 'accept-language', + /** @type {string} */ (event.request.headers.get('accept-language')) + ); + } + + /** @type {Response} */ + const response = await respond(request, options, manifest, { + ...state, + depth: state.depth + 1 + }); + + const set_cookie = response.headers.get('set-cookie'); + if (set_cookie) { + for (const str of set_cookie_parser.splitCookiesString(set_cookie)) { + const { name, value, ...options } = set_cookie_parser.parseString(str); + + const path = options.path ?? (url.pathname.split('/').slice(0, -1).join('/') || '/'); + + // options.sameSite is string, something more specific is required - type cast is safe + set_internal(name, value, { + path, + .../** @type {import('cookie').CookieSerializeOptions} */ (options) + }); + } + } + + return response; + } + }); + }; + + // Don't make this function `async`! Otherwise, the user has to `catch` promises they use for streaming responses or else + // it will be an unhandled rejection. Instead, we add a `.catch(() => {})` ourselves below to this from happening. + return (input, init) => { + // See docs in fetch.js for why we need to do this + const response = server_fetch(input, init); + response.catch(() => {}); + return response; + }; +} + +/** + * @param {RequestInfo | URL} info + * @param {RequestInit | undefined} init + * @param {URL} url + */ +function normalize_fetch_input(info, init, url) { + if (info instanceof Request) { + return info; + } + + return new Request(typeof info === 'string' ? new URL(info, url) : info, init); +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/index.js b/node_modules/@sveltejs/kit/src/runtime/server/index.js new file mode 100644 index 000000000..37608c28e --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/index.js @@ -0,0 +1,94 @@ +import { respond } from './respond.js'; +import { set_private_env, set_public_env, set_safe_public_env } from '../shared-server.js'; +import { options, get_hooks } from '__SERVER__/internal.js'; +import { DEV } from 'esm-env'; +import { filter_private_env, filter_public_env } from '../../utils/env.js'; +import { prerendering } from '__sveltekit/environment'; + +/** @type {ProxyHandler<{ type: 'public' | 'private' }>} */ +const prerender_env_handler = { + get({ type }, prop) { + throw new Error( + `Cannot read values from $env/dynamic/${type} while prerendering (attempted to read env.${prop.toString()}). Use $env/static/${type} instead` + ); + } +}; + +export class Server { + /** @type {import('types').SSROptions} */ + #options; + + /** @type {import('@sveltejs/kit').SSRManifest} */ + #manifest; + + /** @param {import('@sveltejs/kit').SSRManifest} manifest */ + constructor(manifest) { + /** @type {import('types').SSROptions} */ + this.#options = options; + this.#manifest = manifest; + } + + /** + * @param {{ + * env: Record + * }} opts + */ + async init({ env }) { + // Take care: Some adapters may have to call `Server.init` per-request to set env vars, + // so anything that shouldn't be rerun should be wrapped in an `if` block to make sure it hasn't + // been done already. + + // set env, in case it's used in initialisation + const prefixes = { + public_prefix: this.#options.env_public_prefix, + private_prefix: this.#options.env_private_prefix + }; + + const private_env = filter_private_env(env, prefixes); + const public_env = filter_public_env(env, prefixes); + + set_private_env( + prerendering ? new Proxy({ type: 'private' }, prerender_env_handler) : private_env + ); + set_public_env( + prerendering ? new Proxy({ type: 'public' }, prerender_env_handler) : public_env + ); + set_safe_public_env(public_env); + + if (!this.#options.hooks) { + try { + const module = await get_hooks(); + + this.#options.hooks = { + handle: module.handle || (({ event, resolve }) => resolve(event)), + handleError: module.handleError || (({ error }) => console.error(error)), + handleFetch: module.handleFetch || (({ request, fetch }) => fetch(request)) + }; + } catch (error) { + if (DEV) { + this.#options.hooks = { + handle: () => { + throw error; + }, + handleError: ({ error }) => console.error(error), + handleFetch: ({ request, fetch }) => fetch(request) + }; + } else { + throw error; + } + } + } + } + + /** + * @param {Request} request + * @param {import('types').RequestOptions} options + */ + async respond(request, options) { + return respond(request, this.#options, this.#manifest, { + ...options, + error: false, + depth: 0 + }); + } +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js b/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js new file mode 100644 index 000000000..64db81050 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js @@ -0,0 +1,291 @@ +import * as devalue from 'devalue'; +import { json } from '../../../exports/index.js'; +import { get_status, normalize_error } from '../../../utils/error.js'; +import { is_form_content_type, negotiate } from '../../../utils/http.js'; +import { HttpError, Redirect, ActionFailure, SvelteKitError } from '../../control.js'; +import { handle_error_and_jsonify } from '../utils.js'; + +/** @param {import('@sveltejs/kit').RequestEvent} event */ +export function is_action_json_request(event) { + const accept = negotiate(event.request.headers.get('accept') ?? '*/*', [ + 'application/json', + 'text/html' + ]); + + return accept === 'application/json' && event.request.method === 'POST'; +} + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {import('types').SSROptions} options + * @param {import('types').SSRNode['server'] | undefined} server + */ +export async function handle_action_json_request(event, options, server) { + const actions = server?.actions; + + if (!actions) { + const no_actions_error = new SvelteKitError( + 405, + 'Method Not Allowed', + 'POST method not allowed. No actions exist for this page' + ); + return action_json( + { + type: 'error', + error: await handle_error_and_jsonify(event, options, no_actions_error) + }, + { + status: no_actions_error.status, + headers: { + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 + // "The server must generate an Allow header field in a 405 status code response" + allow: 'GET' + } + } + ); + } + + check_named_default_separate(actions); + + try { + const data = await call_action(event, actions); + + if (__SVELTEKIT_DEV__) { + validate_action_return(data); + } + + if (data instanceof ActionFailure) { + return action_json({ + type: 'failure', + status: data.status, + // @ts-expect-error we assign a string to what is supposed to be an object. That's ok + // because we don't use the object outside, and this way we have better code navigation + // through knowing where the related interface is used. + data: stringify_action_response(data.data, /** @type {string} */ (event.route.id)) + }); + } else { + return action_json({ + type: 'success', + status: data ? 200 : 204, + // @ts-expect-error see comment above + data: stringify_action_response(data, /** @type {string} */ (event.route.id)) + }); + } + } catch (e) { + const err = normalize_error(e); + + if (err instanceof Redirect) { + return action_json_redirect(err); + } + + return action_json( + { + type: 'error', + error: await handle_error_and_jsonify(event, options, check_incorrect_fail_use(err)) + }, + { + status: get_status(err) + } + ); + } +} + +/** + * @param {HttpError | Error} error + */ +function check_incorrect_fail_use(error) { + return error instanceof ActionFailure + ? new Error('Cannot "throw fail()". Use "return fail()"') + : error; +} + +/** + * @param {import('@sveltejs/kit').Redirect} redirect + */ +export function action_json_redirect(redirect) { + return action_json({ + type: 'redirect', + status: redirect.status, + location: redirect.location + }); +} + +/** + * @param {import('@sveltejs/kit').ActionResult} data + * @param {ResponseInit} [init] + */ +function action_json(data, init) { + return json(data, init); +} + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + */ +export function is_action_request(event) { + return event.request.method === 'POST'; +} + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {import('types').SSRNode['server'] | undefined} server + * @returns {Promise} + */ +export async function handle_action_request(event, server) { + const actions = server?.actions; + + if (!actions) { + // TODO should this be a different error altogether? + event.setHeaders({ + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 + // "The server must generate an Allow header field in a 405 status code response" + allow: 'GET' + }); + return { + type: 'error', + error: new SvelteKitError( + 405, + 'Method Not Allowed', + 'POST method not allowed. No actions exist for this page' + ) + }; + } + + check_named_default_separate(actions); + + try { + const data = await call_action(event, actions); + + if (__SVELTEKIT_DEV__) { + validate_action_return(data); + } + + if (data instanceof ActionFailure) { + return { + type: 'failure', + status: data.status, + data: data.data + }; + } else { + return { + type: 'success', + status: 200, + // @ts-expect-error this will be removed upon serialization, so `undefined` is the same as omission + data + }; + } + } catch (e) { + const err = normalize_error(e); + + if (err instanceof Redirect) { + return { + type: 'redirect', + status: err.status, + location: err.location + }; + } + + return { + type: 'error', + error: check_incorrect_fail_use(err) + }; + } +} + +/** + * @param {import('@sveltejs/kit').Actions} actions + */ +function check_named_default_separate(actions) { + if (actions.default && Object.keys(actions).length > 1) { + throw new Error( + 'When using named actions, the default action cannot be used. See the docs for more info: https://kit.svelte.dev/docs/form-actions#named-actions' + ); + } +} + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {NonNullable} actions + * @throws {Redirect | HttpError | SvelteKitError | Error} + */ +async function call_action(event, actions) { + const url = new URL(event.request.url); + + let name = 'default'; + for (const param of url.searchParams) { + if (param[0].startsWith('/')) { + name = param[0].slice(1); + if (name === 'default') { + throw new Error('Cannot use reserved action name "default"'); + } + break; + } + } + + const action = actions[name]; + if (!action) { + throw new SvelteKitError(404, 'Not Found', `No action with name '${name}' found`); + } + + if (!is_form_content_type(event.request)) { + throw new SvelteKitError( + 415, + 'Unsupported Media Type', + `Form actions expect form-encoded data — received ${event.request.headers.get( + 'content-type' + )}` + ); + } + + return action(event); +} + +/** @param {any} data */ +function validate_action_return(data) { + if (data instanceof Redirect) { + throw new Error('Cannot `return redirect(...)` — use `redirect(...)` instead'); + } + + if (data instanceof HttpError) { + throw new Error('Cannot `return error(...)` — use `error(...)` or `return fail(...)` instead'); + } +} + +/** + * Try to `devalue.uneval` the data object, and if it fails, return a proper Error with context + * @param {any} data + * @param {string} route_id + */ +export function uneval_action_response(data, route_id) { + return try_deserialize(data, devalue.uneval, route_id); +} + +/** + * Try to `devalue.stringify` the data object, and if it fails, return a proper Error with context + * @param {any} data + * @param {string} route_id + */ +function stringify_action_response(data, route_id) { + return try_deserialize(data, devalue.stringify, route_id); +} + +/** + * @param {any} data + * @param {(data: any) => string} fn + * @param {string} route_id + */ +function try_deserialize(data, fn, route_id) { + try { + return fn(data); + } catch (e) { + // If we're here, the data could not be serialized with devalue + const error = /** @type {any} */ (e); + + if ('path' in error) { + let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`; + if (error.path !== '') message += ` (data.${error.path})`; + throw new Error(message); + } + + throw error; + } +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/page/crypto.js b/node_modules/@sveltejs/kit/src/runtime/server/page/crypto.js new file mode 100644 index 000000000..9af02da51 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/page/crypto.js @@ -0,0 +1,239 @@ +const encoder = new TextEncoder(); + +/** + * SHA-256 hashing function adapted from https://bitwiseshiftleft.github.io/sjcl + * modified and redistributed under BSD license + * @param {string} data + */ +export function sha256(data) { + if (!key[0]) precompute(); + + const out = init.slice(0); + const array = encode(data); + + for (let i = 0; i < array.length; i += 16) { + const w = array.subarray(i, i + 16); + + let tmp; + let a; + let b; + + let out0 = out[0]; + let out1 = out[1]; + let out2 = out[2]; + let out3 = out[3]; + let out4 = out[4]; + let out5 = out[5]; + let out6 = out[6]; + let out7 = out[7]; + + /* Rationale for placement of |0 : + * If a value can overflow is original 32 bits by a factor of more than a few + * million (2^23 ish), there is a possibility that it might overflow the + * 53-bit mantissa and lose precision. + * + * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that + * propagates around the loop, and on the hash state out[]. I don't believe + * that the clamps on out4 and on out0 are strictly necessary, but it's close + * (for out4 anyway), and better safe than sorry. + * + * The clamps on out[] are necessary for the output to be correct even in the + * common case and for short inputs. + */ + + for (let i = 0; i < 64; i++) { + // load up the input word for this round + + if (i < 16) { + tmp = w[i]; + } else { + a = w[(i + 1) & 15]; + + b = w[(i + 14) & 15]; + + tmp = w[i & 15] = + (((a >>> 7) ^ (a >>> 18) ^ (a >>> 3) ^ (a << 25) ^ (a << 14)) + + ((b >>> 17) ^ (b >>> 19) ^ (b >>> 10) ^ (b << 15) ^ (b << 13)) + + w[i & 15] + + w[(i + 9) & 15]) | + 0; + } + + tmp = + tmp + + out7 + + ((out4 >>> 6) ^ (out4 >>> 11) ^ (out4 >>> 25) ^ (out4 << 26) ^ (out4 << 21) ^ (out4 << 7)) + + (out6 ^ (out4 & (out5 ^ out6))) + + key[i]; // | 0; + + // shift register + out7 = out6; + out6 = out5; + out5 = out4; + + out4 = (out3 + tmp) | 0; + + out3 = out2; + out2 = out1; + out1 = out0; + + out0 = + (tmp + + ((out1 & out2) ^ (out3 & (out1 ^ out2))) + + ((out1 >>> 2) ^ + (out1 >>> 13) ^ + (out1 >>> 22) ^ + (out1 << 30) ^ + (out1 << 19) ^ + (out1 << 10))) | + 0; + } + + out[0] = (out[0] + out0) | 0; + out[1] = (out[1] + out1) | 0; + out[2] = (out[2] + out2) | 0; + out[3] = (out[3] + out3) | 0; + out[4] = (out[4] + out4) | 0; + out[5] = (out[5] + out5) | 0; + out[6] = (out[6] + out6) | 0; + out[7] = (out[7] + out7) | 0; + } + + const bytes = new Uint8Array(out.buffer); + reverse_endianness(bytes); + + return base64(bytes); +} + +/** The SHA-256 initialization vector */ +const init = new Uint32Array(8); + +/** The SHA-256 hash key */ +const key = new Uint32Array(64); + +/** Function to precompute init and key. */ +function precompute() { + /** @param {number} x */ + function frac(x) { + return (x - Math.floor(x)) * 0x100000000; + } + + let prime = 2; + + for (let i = 0; i < 64; prime++) { + let is_prime = true; + + for (let factor = 2; factor * factor <= prime; factor++) { + if (prime % factor === 0) { + is_prime = false; + + break; + } + } + + if (is_prime) { + if (i < 8) { + init[i] = frac(prime ** (1 / 2)); + } + + key[i] = frac(prime ** (1 / 3)); + + i++; + } + } +} + +/** @param {Uint8Array} bytes */ +function reverse_endianness(bytes) { + for (let i = 0; i < bytes.length; i += 4) { + const a = bytes[i + 0]; + const b = bytes[i + 1]; + const c = bytes[i + 2]; + const d = bytes[i + 3]; + + bytes[i + 0] = d; + bytes[i + 1] = c; + bytes[i + 2] = b; + bytes[i + 3] = a; + } +} + +/** @param {string} str */ +function encode(str) { + const encoded = encoder.encode(str); + const length = encoded.length * 8; + + // result should be a multiple of 512 bits in length, + // with room for a 1 (after the data) and two 32-bit + // words containing the original input bit length + const size = 512 * Math.ceil((length + 65) / 512); + const bytes = new Uint8Array(size / 8); + bytes.set(encoded); + + // append a 1 + bytes[encoded.length] = 0b10000000; + + reverse_endianness(bytes); + + // add the input bit length + const words = new Uint32Array(bytes.buffer); + words[words.length - 2] = Math.floor(length / 0x100000000); // this will always be zero for us + words[words.length - 1] = length; + + return words; +} + +/* + Based on https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727 + + MIT License + Copyright (c) 2020 Egor Nepomnyaschih + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); + +/** @param {Uint8Array} bytes */ +export function base64(bytes) { + const l = bytes.length; + + let result = ''; + let i; + + for (i = 2; i < l; i += 3) { + result += chars[bytes[i - 2] >> 2]; + result += chars[((bytes[i - 2] & 0x03) << 4) | (bytes[i - 1] >> 4)]; + result += chars[((bytes[i - 1] & 0x0f) << 2) | (bytes[i] >> 6)]; + result += chars[bytes[i] & 0x3f]; + } + + if (i === l + 1) { + // 1 octet yet to write + result += chars[bytes[i - 2] >> 2]; + result += chars[(bytes[i - 2] & 0x03) << 4]; + result += '=='; + } + + if (i === l) { + // 2 octets yet to write + result += chars[bytes[i - 2] >> 2]; + result += chars[((bytes[i - 2] & 0x03) << 4) | (bytes[i - 1] >> 4)]; + result += chars[(bytes[i - 1] & 0x0f) << 2]; + result += '='; + } + + return result; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/page/csp.js b/node_modules/@sveltejs/kit/src/runtime/server/page/csp.js new file mode 100644 index 000000000..a1a530d9d --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/page/csp.js @@ -0,0 +1,254 @@ +import { escape_html_attr } from '../../../utils/escape.js'; +import { base64, sha256 } from './crypto.js'; + +const array = new Uint8Array(16); + +function generate_nonce() { + crypto.getRandomValues(array); + return base64(array); +} + +const quoted = new Set([ + 'self', + 'unsafe-eval', + 'unsafe-hashes', + 'unsafe-inline', + 'none', + 'strict-dynamic', + 'report-sample', + 'wasm-unsafe-eval', + 'script' +]); + +const crypto_pattern = /^(nonce|sha\d\d\d)-/; + +// CSP and CSP Report Only are extremely similar with a few caveats +// the easiest/DRYest way to express this is with some private encapsulation +class BaseProvider { + /** @type {boolean} */ + #use_hashes; + + /** @type {boolean} */ + #script_needs_csp; + + /** @type {boolean} */ + #style_needs_csp; + + /** @type {import('types').CspDirectives} */ + #directives; + + /** @type {import('types').Csp.Source[]} */ + #script_src; + + /** @type {import('types').Csp.Source[]} */ + #style_src; + + /** @type {string} */ + #nonce; + + /** + * @param {boolean} use_hashes + * @param {import('types').CspDirectives} directives + * @param {string} nonce + */ + constructor(use_hashes, directives, nonce) { + this.#use_hashes = use_hashes; + this.#directives = __SVELTEKIT_DEV__ ? { ...directives } : directives; // clone in dev so we can safely mutate + + const d = this.#directives; + + if (__SVELTEKIT_DEV__) { + // remove strict-dynamic in dev... + // TODO reinstate this if we can figure out how to make strict-dynamic work + // if (d['default-src']) { + // d['default-src'] = d['default-src'].filter((name) => name !== 'strict-dynamic'); + // if (d['default-src'].length === 0) delete d['default-src']; + // } + + // if (d['script-src']) { + // d['script-src'] = d['script-src'].filter((name) => name !== 'strict-dynamic'); + // if (d['script-src'].length === 0) delete d['script-src']; + // } + + const effective_style_src = d['style-src'] || d['default-src']; + + // ...and add unsafe-inline so we can inject `; + } + + for (const dep of stylesheets) { + const path = prefixed(dep); + + const attributes = ['rel="stylesheet"']; + + if (inline_styles.has(dep)) { + // don't load stylesheets that are already inlined + // include them in disabled state so that Vite can detect them and doesn't try to add them + attributes.push('disabled', 'media="(max-width: 0)"'); + } else { + if (resolve_opts.preload({ type: 'css', path })) { + const preload_atts = ['rel="preload"', 'as="style"']; + link_header_preloads.add(`<${encodeURI(path)}>; ${preload_atts.join(';')}; nopush`); + } + } + + head += `\n\t\t`; + } + + for (const dep of fonts) { + const path = prefixed(dep); + + if (resolve_opts.preload({ type: 'font', path })) { + const ext = dep.slice(dep.lastIndexOf('.') + 1); + const attributes = [ + 'rel="preload"', + 'as="font"', + `type="font/${ext}"`, + `href="${path}"`, + 'crossorigin' + ]; + + head += `\n\t\t`; + } + } + + const global = __SVELTEKIT_DEV__ ? '__sveltekit_dev' : `__sveltekit_${options.version_hash}`; + + const { data, chunks } = get_data( + event, + options, + branch.map((b) => b.server_data), + global + ); + + if (page_config.ssr && page_config.csr) { + body += `\n\t\t\t${fetched + .map((item) => + serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!state.prerendering) + ) + .join('\n\t\t\t')}`; + } + + if (page_config.csr) { + if (client.uses_env_dynamic_public && state.prerendering) { + modulepreloads.add(`${options.app_dir}/env.js`); + } + + const included_modulepreloads = Array.from(modulepreloads, (dep) => prefixed(dep)).filter( + (path) => resolve_opts.preload({ type: 'js', path }) + ); + + for (const path of included_modulepreloads) { + // see the kit.output.preloadStrategy option for details on why we have multiple options here + link_header_preloads.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`); + if (options.preload_strategy !== 'modulepreload') { + head += `\n\t\t`; + } else if (state.prerendering) { + head += `\n\t\t`; + } + } + + const blocks = []; + + const properties = [ + paths.assets && `assets: ${s(paths.assets)}`, + `base: ${base_expression}`, + `env: ${!client.uses_env_dynamic_public || state.prerendering ? null : s(public_env)}` + ].filter(Boolean); + + if (chunks) { + blocks.push('const deferred = new Map();'); + + properties.push(`defer: (id) => new Promise((fulfil, reject) => { + deferred.set(id, { fulfil, reject }); + })`); + + properties.push(`resolve: ({ id, data, error }) => { + const { fulfil, reject } = deferred.get(id); + deferred.delete(id); + + if (error) reject(error); + else fulfil(data); + }`); + } + + blocks.push(`${global} = { + ${properties.join(',\n\t\t\t\t\t\t')} + };`); + + const args = ['app', 'element']; + + blocks.push('const element = document.currentScript.parentElement;'); + + if (page_config.ssr) { + const serialized = { form: 'null', error: 'null' }; + + blocks.push(`const data = ${data};`); + + if (form_value) { + serialized.form = uneval_action_response( + form_value, + /** @type {string} */ (event.route.id) + ); + } + + if (error) { + serialized.error = devalue.uneval(error); + } + + const hydrate = [ + `node_ids: [${branch.map(({ node }) => node.index).join(', ')}]`, + 'data', + `form: ${serialized.form}`, + `error: ${serialized.error}` + ]; + + if (status !== 200) { + hydrate.push(`status: ${status}`); + } + + if (options.embedded) { + hydrate.push(`params: ${devalue.uneval(event.params)}`, `route: ${s(event.route)}`); + } + + args.push(`{\n\t\t\t\t\t\t\t${hydrate.join(',\n\t\t\t\t\t\t\t')}\n\t\t\t\t\t\t}`); + } + + blocks.push(`Promise.all([ + import(${s(prefixed(client.start))}), + import(${s(prefixed(client.app))}) + ]).then(([kit, app]) => { + kit.start(${args.join(', ')}); + });`); + + if (options.service_worker) { + const opts = __SVELTEKIT_DEV__ ? ", { type: 'module' }" : ''; + + // we use an anonymous function instead of an arrow function to support + // older browsers (https://github.com/sveltejs/kit/pull/5417) + blocks.push(`if ('serviceWorker' in navigator) { + addEventListener('load', function () { + navigator.serviceWorker.register('${prefixed('service-worker.js')}'${opts}); + }); + }`); + } + + const init_app = ` + { + ${blocks.join('\n\n\t\t\t\t\t')} + } + `; + csp.add_script(init_app); + + body += `\n\t\t\t${init_app}\n\t\t`; + } + + const headers = new Headers({ + 'x-sveltekit-page': 'true', + 'content-type': 'text/html' + }); + + if (state.prerendering) { + // TODO read headers set with setHeaders and convert into http-equiv where possible + const http_equiv = []; + + const csp_headers = csp.csp_provider.get_meta(); + if (csp_headers) { + http_equiv.push(csp_headers); + } + + if (state.prerendering.cache) { + http_equiv.push(``); + } + + if (http_equiv.length > 0) { + head = http_equiv.join('\n') + head; + } + } else { + const csp_header = csp.csp_provider.get_header(); + if (csp_header) { + headers.set('content-security-policy', csp_header); + } + const report_only_header = csp.report_only_provider.get_header(); + if (report_only_header) { + headers.set('content-security-policy-report-only', report_only_header); + } + + if (link_header_preloads.size) { + headers.set('link', Array.from(link_header_preloads).join(', ')); + } + } + + // add the content after the script/css links so the link elements are parsed first + head += rendered.head; + + const html = options.templates.app({ + head, + body, + assets, + nonce: /** @type {string} */ (csp.nonce), + env: safe_public_env + }); + + // TODO flush chunks as early as we can + const transformed = + (await resolve_opts.transformPageChunk({ + html, + done: true + })) || ''; + + if (!chunks) { + headers.set('etag', `"${hash(transformed)}"`); + } + + if (DEV) { + if (page_config.csr) { + if (transformed.split('`, so the script element might be unexpectedly + * kept open until until an unrelated HTML comment in the page. + * + * U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are escaped for the sake of pre-2018 + * browsers. + * + * @see tests for unsafe parsing examples. + * @see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements + * @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions + * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-state + * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escaped-state + * @see https://github.com/tc39/proposal-json-superset + * @type {Record} + */ +const replacements = { + '<': '\\u003C', + '\u2028': '\\u2028', + '\u2029': '\\u2029' +}; + +const pattern = new RegExp(`[${Object.keys(replacements).join('')}]`, 'g'); + +/** + * Generates a raw HTML string containing a safe script element carrying data and associated attributes. + * + * It escapes all the special characters needed to guarantee the element is unbroken, but care must + * be taken to ensure it is inserted in the document at an acceptable position for a script element, + * and that the resulting string isn't further modified. + * + * @param {import('./types.js').Fetched} fetched + * @param {(name: string, value: string) => boolean} filter + * @param {boolean} [prerendering] + * @returns {string} The raw HTML of a script element carrying the JSON payload. + * @example const html = serialize_data('/data.json', null, { foo: 'bar' }); + */ +export function serialize_data(fetched, filter, prerendering = false) { + /** @type {Record} */ + const headers = {}; + + let cache_control = null; + let age = null; + let varyAny = false; + + for (const [key, value] of fetched.response.headers) { + if (filter(key, value)) { + headers[key] = value; + } + + if (key === 'cache-control') cache_control = value; + else if (key === 'age') age = value; + else if (key === 'vary' && value.trim() === '*') varyAny = true; + } + + const payload = { + status: fetched.response.status, + statusText: fetched.response.statusText, + headers, + body: fetched.response_body + }; + + const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]); + + const attrs = [ + 'type="application/json"', + 'data-sveltekit-fetched', + `data-url=${escape_html_attr(fetched.url)}` + ]; + + if (fetched.is_b64) { + attrs.push('data-b64'); + } + + if (fetched.request_headers || fetched.request_body) { + /** @type {import('types').StrictBody[]} */ + const values = []; + + if (fetched.request_headers) { + values.push([...new Headers(fetched.request_headers)].join(',')); + } + + if (fetched.request_body) { + values.push(fetched.request_body); + } + + attrs.push(`data-hash="${hash(...values)}"`); + } + + // Compute the time the response should be cached, taking into account max-age and age. + // Do not cache at all if a `Vary: *` header is present, as this indicates that the + // cache is likely to get busted. + if (!prerendering && fetched.method === 'GET' && cache_control && !varyAny) { + const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control); + if (match) { + const ttl = +match[1] - +(age ?? '0'); + attrs.push(`data-ttl="${ttl}"`); + } + } + + return ``; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/page/types.d.ts b/node_modules/@sveltejs/kit/src/runtime/server/page/types.d.ts new file mode 100644 index 000000000..7e501b1ab --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/page/types.d.ts @@ -0,0 +1,36 @@ +import { CookieSerializeOptions } from 'cookie'; +import { SSRNode, CspDirectives, ServerDataNode } from 'types'; + +export interface Fetched { + url: string; + method: string; + request_body?: string | ArrayBufferView | null; + request_headers?: HeadersInit | undefined; + response_body: string; + response: Response; + is_b64?: boolean; +} + +export type Loaded = { + node: SSRNode; + data: Record | null; + server_data: ServerDataNode | null; +}; + +type CspMode = 'hash' | 'nonce' | 'auto'; + +export interface CspConfig { + mode: CspMode; + directives: CspDirectives; + reportOnly: CspDirectives; +} + +export interface CspOpts { + prerender: boolean; +} + +export interface Cookie { + name: string; + value: string; + options: CookieSerializeOptions & { path: string }; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/respond.js b/node_modules/@sveltejs/kit/src/runtime/server/respond.js new file mode 100644 index 000000000..567097184 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/respond.js @@ -0,0 +1,513 @@ +import { DEV } from 'esm-env'; +import { base } from '__sveltekit/paths'; +import { is_endpoint_request, render_endpoint } from './endpoint.js'; +import { render_page } from './page/index.js'; +import { render_response } from './page/render.js'; +import { respond_with_error } from './page/respond_with_error.js'; +import { is_form_content_type } from '../../utils/http.js'; +import { handle_fatal_error, method_not_allowed, redirect_response } from './utils.js'; +import { + decode_pathname, + decode_params, + disable_search, + has_data_suffix, + normalize_path, + strip_data_suffix +} from '../../utils/url.js'; +import { exec } from '../../utils/routing.js'; +import { redirect_json_response, render_data } from './data/index.js'; +import { add_cookies_to_headers, get_cookies } from './cookie.js'; +import { create_fetch } from './fetch.js'; +import { HttpError, Redirect, SvelteKitError } from '../control.js'; +import { + validate_layout_exports, + validate_layout_server_exports, + validate_page_exports, + validate_page_server_exports, + validate_server_exports +} from '../../utils/exports.js'; +import { get_option } from '../../utils/options.js'; +import { json, text } from '../../exports/index.js'; +import { action_json_redirect, is_action_json_request } from './page/actions.js'; +import { INVALIDATED_PARAM, TRAILING_SLASH_PARAM } from '../shared.js'; +import { get_public_env } from './env_module.js'; + +/* global __SVELTEKIT_ADAPTER_NAME__ */ + +/** @type {import('types').RequiredResolveOptions['transformPageChunk']} */ +const default_transform = ({ html }) => html; + +/** @type {import('types').RequiredResolveOptions['filterSerializedResponseHeaders']} */ +const default_filter = () => false; + +/** @type {import('types').RequiredResolveOptions['preload']} */ +const default_preload = ({ type }) => type === 'js' || type === 'css'; + +const page_methods = new Set(['GET', 'HEAD', 'POST']); + +const allowed_page_methods = new Set(['GET', 'HEAD', 'OPTIONS']); + +/** + * @param {Request} request + * @param {import('types').SSROptions} options + * @param {import('@sveltejs/kit').SSRManifest} manifest + * @param {import('types').SSRState} state + * @returns {Promise} + */ +export async function respond(request, options, manifest, state) { + /** URL but stripped from the potential `/__data.json` suffix and its search param */ + const url = new URL(request.url); + + if (options.csrf_check_origin) { + const forbidden = + is_form_content_type(request) && + (request.method === 'POST' || + request.method === 'PUT' || + request.method === 'PATCH' || + request.method === 'DELETE') && + request.headers.get('origin') !== url.origin; + + if (forbidden) { + const csrf_error = new HttpError( + 403, + `Cross-site ${request.method} form submissions are forbidden` + ); + if (request.headers.get('accept') === 'application/json') { + return json(csrf_error.body, { status: csrf_error.status }); + } + return text(csrf_error.body.message, { status: csrf_error.status }); + } + } + + let decoded; + try { + decoded = decode_pathname(url.pathname); + } catch { + return text('Malformed URI', { status: 400 }); + } + + /** @type {import('types').SSRRoute | null} */ + let route = null; + + /** @type {Record} */ + let params = {}; + + if (base && !state.prerendering?.fallback) { + if (!decoded.startsWith(base)) { + return text('Not found', { status: 404 }); + } + decoded = decoded.slice(base.length) || '/'; + } + + if (decoded === `/${options.app_dir}/env.js`) { + return get_public_env(request); + } + + const is_data_request = has_data_suffix(decoded); + /** @type {boolean[] | undefined} */ + let invalidated_data_nodes; + if (is_data_request) { + decoded = strip_data_suffix(decoded) || '/'; + url.pathname = + strip_data_suffix(url.pathname) + + (url.searchParams.get(TRAILING_SLASH_PARAM) === '1' ? '/' : '') || '/'; + url.searchParams.delete(TRAILING_SLASH_PARAM); + invalidated_data_nodes = url.searchParams + .get(INVALIDATED_PARAM) + ?.split('') + .map((node) => node === '1'); + url.searchParams.delete(INVALIDATED_PARAM); + } + + if (!state.prerendering?.fallback) { + // TODO this could theoretically break — should probably be inside a try-catch + const matchers = await manifest._.matchers(); + + for (const candidate of manifest._.routes) { + const match = candidate.pattern.exec(decoded); + if (!match) continue; + + const matched = exec(match, candidate.params, matchers); + if (matched) { + route = candidate; + params = decode_params(matched); + break; + } + } + } + + /** @type {import('types').TrailingSlash | void} */ + let trailing_slash = undefined; + + /** @type {Record} */ + const headers = {}; + + /** @type {Record} */ + let cookies_to_add = {}; + + /** @type {import('@sveltejs/kit').RequestEvent} */ + const event = { + // @ts-expect-error `cookies` and `fetch` need to be created after the `event` itself + cookies: null, + // @ts-expect-error + fetch: null, + getClientAddress: + state.getClientAddress || + (() => { + throw new Error( + `${__SVELTEKIT_ADAPTER_NAME__} does not specify getClientAddress. Please raise an issue` + ); + }), + locals: {}, + params, + platform: state.platform, + request, + route: { id: route?.id ?? null }, + setHeaders: (new_headers) => { + for (const key in new_headers) { + const lower = key.toLowerCase(); + const value = new_headers[key]; + + if (lower === 'set-cookie') { + throw new Error( + 'Use `event.cookies.set(name, value, options)` instead of `event.setHeaders` to set cookies' + ); + } else if (lower in headers) { + throw new Error(`"${key}" header is already set`); + } else { + headers[lower] = value; + + if (state.prerendering && lower === 'cache-control') { + state.prerendering.cache = /** @type {string} */ (value); + } + } + } + }, + url, + isDataRequest: is_data_request, + isSubRequest: state.depth > 0 + }; + + /** @type {import('types').RequiredResolveOptions} */ + let resolve_opts = { + transformPageChunk: default_transform, + filterSerializedResponseHeaders: default_filter, + preload: default_preload + }; + + try { + // determine whether we need to redirect to add/remove a trailing slash + if (route) { + // if `paths.base === '/a/b/c`, then the root route is `/a/b/c/`, + // regardless of the `trailingSlash` route option + if (url.pathname === base || url.pathname === base + '/') { + trailing_slash = 'always'; + } else if (route.page) { + const nodes = await Promise.all([ + // we use == here rather than === because [undefined] serializes as "[null]" + ...route.page.layouts.map((n) => (n == undefined ? n : manifest._.nodes[n]())), + manifest._.nodes[route.page.leaf]() + ]); + + if (DEV) { + const layouts = nodes.slice(0, -1); + const page = nodes.at(-1); + + for (const layout of layouts) { + if (layout) { + validate_layout_server_exports( + layout.server, + /** @type {string} */ (layout.server_id) + ); + validate_layout_exports( + layout.universal, + /** @type {string} */ (layout.universal_id) + ); + } + } + + if (page) { + validate_page_server_exports(page.server, /** @type {string} */ (page.server_id)); + validate_page_exports(page.universal, /** @type {string} */ (page.universal_id)); + } + } + + trailing_slash = get_option(nodes, 'trailingSlash'); + } else if (route.endpoint) { + const node = await route.endpoint(); + trailing_slash = node.trailingSlash; + + if (DEV) { + validate_server_exports(node, /** @type {string} */ (route.endpoint_id)); + } + } + + if (!is_data_request) { + const normalized = normalize_path(url.pathname, trailing_slash ?? 'never'); + + if (normalized !== url.pathname && !state.prerendering?.fallback) { + return new Response(undefined, { + status: 308, + headers: { + 'x-sveltekit-normalize': '1', + location: + // ensure paths starting with '//' are not treated as protocol-relative + (normalized.startsWith('//') ? url.origin + normalized : normalized) + + (url.search === '?' ? '' : url.search) + } + }); + } + } + } + + const { cookies, new_cookies, get_cookie_header, set_internal } = get_cookies( + request, + url, + trailing_slash ?? 'never' + ); + + cookies_to_add = new_cookies; + event.cookies = cookies; + event.fetch = create_fetch({ + event, + options, + manifest, + state, + get_cookie_header, + set_internal + }); + + if (state.prerendering && !state.prerendering.fallback) disable_search(url); + + const response = await options.hooks.handle({ + event, + resolve: (event, opts) => + resolve(event, opts).then((response) => { + // add headers/cookies here, rather than inside `resolve`, so that we + // can do it once for all responses instead of once per `return` + for (const key in headers) { + const value = headers[key]; + response.headers.set(key, /** @type {string} */ (value)); + } + + add_cookies_to_headers(response.headers, Object.values(cookies_to_add)); + + if (state.prerendering && event.route.id !== null) { + response.headers.set('x-sveltekit-routeid', encodeURI(event.route.id)); + } + + return response; + }) + }); + + // respond with 304 if etag matches + if (response.status === 200 && response.headers.has('etag')) { + let if_none_match_value = request.headers.get('if-none-match'); + + // ignore W/ prefix https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match#directives + if (if_none_match_value?.startsWith('W/"')) { + if_none_match_value = if_none_match_value.substring(2); + } + + const etag = /** @type {string} */ (response.headers.get('etag')); + + if (if_none_match_value === etag) { + const headers = new Headers({ etag }); + + // https://datatracker.ietf.org/doc/html/rfc7232#section-4.1 + set-cookie + for (const key of [ + 'cache-control', + 'content-location', + 'date', + 'expires', + 'vary', + 'set-cookie' + ]) { + const value = response.headers.get(key); + if (value) headers.set(key, value); + } + + return new Response(undefined, { + status: 304, + headers + }); + } + } + + // Edge case: If user does `return Response(30x)` in handle hook while processing a data request, + // we need to transform the redirect response to a corresponding JSON response. + if (is_data_request && response.status >= 300 && response.status <= 308) { + const location = response.headers.get('location'); + if (location) { + return redirect_json_response(new Redirect(/** @type {any} */ (response.status), location)); + } + } + + return response; + } catch (e) { + if (e instanceof Redirect) { + const response = is_data_request + ? redirect_json_response(e) + : route?.page && is_action_json_request(event) + ? action_json_redirect(e) + : redirect_response(e.status, e.location); + add_cookies_to_headers(response.headers, Object.values(cookies_to_add)); + return response; + } + return await handle_fatal_error(event, options, e); + } + + /** + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {import('@sveltejs/kit').ResolveOptions} [opts] + */ + async function resolve(event, opts) { + try { + if (opts) { + resolve_opts = { + transformPageChunk: opts.transformPageChunk || default_transform, + filterSerializedResponseHeaders: opts.filterSerializedResponseHeaders || default_filter, + preload: opts.preload || default_preload + }; + } + + if (state.prerendering?.fallback) { + return await render_response({ + event, + options, + manifest, + state, + page_config: { ssr: false, csr: true }, + status: 200, + error: null, + branch: [], + fetched: [], + resolve_opts + }); + } + + if (route) { + const method = /** @type {import('types').HttpMethod} */ (event.request.method); + + /** @type {Response} */ + let response; + + if (is_data_request) { + response = await render_data( + event, + route, + options, + manifest, + state, + invalidated_data_nodes, + trailing_slash ?? 'never' + ); + } else if (route.endpoint && (!route.page || is_endpoint_request(event))) { + response = await render_endpoint(event, await route.endpoint(), state); + } else if (route.page) { + if (page_methods.has(method)) { + response = await render_page(event, route.page, options, manifest, state, resolve_opts); + } else { + const allowed_methods = new Set(allowed_page_methods); + const node = await manifest._.nodes[route.page.leaf](); + if (node?.server?.actions) { + allowed_methods.add('POST'); + } + + if (method === 'OPTIONS') { + // This will deny CORS preflight requests implicitly because we don't + // add the required CORS headers to the response. + response = new Response(null, { + status: 204, + headers: { + allow: Array.from(allowed_methods.values()).join(', ') + } + }); + } else { + const mod = [...allowed_methods].reduce((acc, curr) => { + acc[curr] = true; + return acc; + }, /** @type {Record} */ ({})); + response = method_not_allowed(mod, method); + } + } + } else { + // a route will always have a page or an endpoint, but TypeScript + // doesn't know that + throw new Error('This should never happen'); + } + + // If the route contains a page and an endpoint, we need to add a + // `Vary: Accept` header to the response because of browser caching + if (request.method === 'GET' && route.page && route.endpoint) { + const vary = response.headers + .get('vary') + ?.split(',') + ?.map((v) => v.trim().toLowerCase()); + if (!(vary?.includes('accept') || vary?.includes('*'))) { + // the returned response might have immutable headers, + // so we have to clone them before trying to mutate them + response = new Response(response.body, { + status: response.status, + statusText: response.statusText, + headers: new Headers(response.headers) + }); + response.headers.append('Vary', 'Accept'); + } + } + + return response; + } + + if (state.error && event.isSubRequest) { + return await fetch(request, { + headers: { + 'x-sveltekit-error': 'true' + } + }); + } + + if (state.error) { + return text('Internal Server Error', { + status: 500 + }); + } + + // if this request came direct from the user, rather than + // via our own `fetch`, render a 404 page + if (state.depth === 0) { + return await respond_with_error({ + event, + options, + manifest, + state, + status: 404, + error: new SvelteKitError(404, 'Not Found', `Not found: ${event.url.pathname}`), + resolve_opts + }); + } + + if (state.prerendering) { + return text('not found', { status: 404 }); + } + + // we can't load the endpoint from our own manifest, + // so we need to make an actual HTTP request + return await fetch(request); + } catch (e) { + // TODO if `e` is instead named `error`, some fucked up Vite transformation happens + // and I don't even know how to describe it. need to investigate at some point + + // HttpError from endpoint can end up here - TODO should it be handled there instead? + return await handle_fatal_error(event, options, e); + } finally { + event.cookies.set = () => { + throw new Error('Cannot use `cookies.set(...)` after the response has been generated'); + }; + + event.setHeaders = () => { + throw new Error('Cannot use `setHeaders(...)` after the response has been generated'); + }; + } + } +} diff --git a/node_modules/@sveltejs/kit/src/runtime/server/utils.js b/node_modules/@sveltejs/kit/src/runtime/server/utils.js new file mode 100644 index 000000000..12cb49288 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/server/utils.js @@ -0,0 +1,178 @@ +import { DEV } from 'esm-env'; +import { json, text } from '../../exports/index.js'; +import { coalesce_to_error, get_message, get_status } from '../../utils/error.js'; +import { negotiate } from '../../utils/http.js'; +import { HttpError } from '../control.js'; +import { fix_stack_trace } from '../shared-server.js'; +import { ENDPOINT_METHODS } from '../../constants.js'; + +/** @param {any} body */ +export function is_pojo(body) { + if (typeof body !== 'object') return false; + + if (body) { + if (body instanceof Uint8Array) return false; + if (body instanceof ReadableStream) return false; + } + + return true; +} + +/** + * @param {Partial>} mod + * @param {import('types').HttpMethod} method + */ +export function method_not_allowed(mod, method) { + return text(`${method} method not allowed`, { + status: 405, + headers: { + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405 + // "The server must generate an Allow header field in a 405 status code response" + allow: allowed_methods(mod).join(', ') + } + }); +} + +/** @param {Partial>} mod */ +export function allowed_methods(mod) { + const allowed = ENDPOINT_METHODS.filter((method) => method in mod); + + if ('GET' in mod || 'HEAD' in mod) allowed.push('HEAD'); + + return allowed; +} + +/** + * Return as a response that renders the error.html + * + * @param {import('types').SSROptions} options + * @param {number} status + * @param {string} message + */ +export function static_error_page(options, status, message) { + let page = options.templates.error({ status, message }); + + if (DEV) { + // inject Vite HMR client, for easier debugging + page = page.replace('', ''); + } + + return text(page, { + headers: { 'content-type': 'text/html; charset=utf-8' }, + status + }); +} + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {import('types').SSROptions} options + * @param {unknown} error + */ +export async function handle_fatal_error(event, options, error) { + error = error instanceof HttpError ? error : coalesce_to_error(error); + const status = get_status(error); + const body = await handle_error_and_jsonify(event, options, error); + + // ideally we'd use sec-fetch-dest instead, but Safari — quelle surprise — doesn't support it + const type = negotiate(event.request.headers.get('accept') || 'text/html', [ + 'application/json', + 'text/html' + ]); + + if (event.isDataRequest || type === 'application/json') { + return json(body, { + status + }); + } + + return static_error_page(options, status, body.message); +} + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {import('types').SSROptions} options + * @param {any} error + * @returns {Promise} + */ +export async function handle_error_and_jsonify(event, options, error) { + if (error instanceof HttpError) { + return error.body; + } + + if (__SVELTEKIT_DEV__ && typeof error == 'object') { + fix_stack_trace(error); + } + + const status = get_status(error); + const message = get_message(error); + + return (await options.hooks.handleError({ error, event, status, message })) ?? { message }; +} + +/** + * @param {number} status + * @param {string} location + */ +export function redirect_response(status, location) { + const response = new Response(undefined, { + status, + headers: { location } + }); + return response; +} + +/** + * @param {import('@sveltejs/kit').RequestEvent} event + * @param {Error & { path: string }} error + */ +export function clarify_devalue_error(event, error) { + if (error.path) { + return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (data${error.path})`; + } + + if (error.path === '') { + return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`; + } + + // belt and braces — this should never happen + return error.message; +} + +/** + * @param {import('types').ServerDataNode} node + */ +export function stringify_uses(node) { + const uses = []; + + if (node.uses && node.uses.dependencies.size > 0) { + uses.push(`"dependencies":${JSON.stringify(Array.from(node.uses.dependencies))}`); + } + + if (node.uses && node.uses.search_params.size > 0) { + uses.push(`"search_params":${JSON.stringify(Array.from(node.uses.search_params))}`); + } + + if (node.uses && node.uses.params.size > 0) { + uses.push(`"params":${JSON.stringify(Array.from(node.uses.params))}`); + } + + if (node.uses?.parent) uses.push('"parent":1'); + if (node.uses?.route) uses.push('"route":1'); + if (node.uses?.url) uses.push('"url":1'); + + return `"uses":{${uses.join(',')}}`; +} + +/** + * @param {string} message + * @param {number} offset + */ +export function warn_with_callsite(message, offset = 0) { + if (DEV) { + const stack = fix_stack_trace(new Error()).split('\n'); + const line = stack.at(3 + offset); + message += `\n${line}`; + } + + console.warn(message); +} diff --git a/node_modules/@sveltejs/kit/src/runtime/shared-server.js b/node_modules/@sveltejs/kit/src/runtime/shared-server.js new file mode 100644 index 000000000..7bd6bde4c --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/shared-server.js @@ -0,0 +1,40 @@ +/** + * `$env/dynamic/private` + * @type {Record} + */ +export let private_env = {}; + +/** + * `$env/dynamic/public`. When prerendering, this will be a proxy that forbids reads + * @type {Record} + */ +export let public_env = {}; + +/** + * The same as `public_env`, but without the proxy. Use for `%sveltekit.env.PUBLIC_FOO%` + * @type {Record} + */ +export let safe_public_env = {}; + +/** @param {any} error */ +export let fix_stack_trace = (error) => error?.stack; + +/** @type {(environment: Record) => void} */ +export function set_private_env(environment) { + private_env = environment; +} + +/** @type {(environment: Record) => void} */ +export function set_public_env(environment) { + public_env = environment; +} + +/** @type {(environment: Record) => void} */ +export function set_safe_public_env(environment) { + safe_public_env = environment; +} + +/** @param {(error: Error) => string} value */ +export function set_fix_stack_trace(value) { + fix_stack_trace = value; +} diff --git a/node_modules/@sveltejs/kit/src/runtime/shared.js b/node_modules/@sveltejs/kit/src/runtime/shared.js new file mode 100644 index 000000000..b5c559b42 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/runtime/shared.js @@ -0,0 +1,16 @@ +/** + * @param {string} route_id + * @param {string} dep + */ +export function validate_depends(route_id, dep) { + const match = /^(moz-icon|view-source|jar):/.exec(dep); + if (match) { + console.warn( + `${route_id}: Calling \`depends('${dep}')\` will throw an error in Firefox because \`${match[1]}\` is a special URI scheme` + ); + } +} + +export const INVALIDATED_PARAM = 'x-sveltekit-invalidated'; + +export const TRAILING_SLASH_PARAM = 'x-sveltekit-trailing-slash'; diff --git a/node_modules/@sveltejs/kit/src/types/ambient-private.d.ts b/node_modules/@sveltejs/kit/src/types/ambient-private.d.ts new file mode 100644 index 000000000..843cc94d3 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/types/ambient-private.d.ts @@ -0,0 +1,11 @@ +declare global { + const __SVELTEKIT_ADAPTER_NAME__: string; + const __SVELTEKIT_APP_VERSION_FILE__: string; + const __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number; + const __SVELTEKIT_DEV__: boolean; + const __SVELTEKIT_EMBEDDED__: boolean; + var Bun: object; + var Deno: object; +} + +export {}; diff --git a/node_modules/@sveltejs/kit/src/types/ambient.d.ts b/node_modules/@sveltejs/kit/src/types/ambient.d.ts new file mode 100644 index 000000000..2c8b7427f --- /dev/null +++ b/node_modules/@sveltejs/kit/src/types/ambient.d.ts @@ -0,0 +1,119 @@ +/** + * It's possible to tell SvelteKit how to type objects inside your app by declaring the `App` namespace. By default, a new project will have a file called `src/app.d.ts` containing the following: + * + * ```ts + * declare global { + * namespace App { + * // interface Error {} + * // interface Locals {} + * // interface PageData {} + * // interface PageState {} + * // interface Platform {} + * } + * } + * + * export {}; + * ``` + * + * The `export {}` line exists because without it, the file would be treated as an _ambient module_ which prevents you from adding `import` declarations. + * If you need to add ambient `declare module` declarations, do so in a separate file like `src/ambient.d.ts`. + * + * By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions. + */ +declare namespace App { + /** + * Defines the common shape of expected and unexpected errors. Expected errors are thrown using the `error` function. Unexpected errors are handled by the `handleError` hooks which should return this shape. + */ + export interface Error { + message: string; + } + + /** + * The interface that defines `event.locals`, which can be accessed in [hooks](https://kit.svelte.dev/docs/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files. + */ + export interface Locals {} + + /** + * Defines the common shape of the [$page.data store](https://kit.svelte.dev/docs/modules#$app-stores-page) - that is, the data that is shared between all pages. + * The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly. + * Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`). + */ + export interface PageData {} + + /** + * The shape of the `$page.state` object, which can be manipulated using the [`pushState`](https://kit.svelte.dev/docs/modules#$app-navigation-pushstate) and [`replaceState`](https://kit.svelte.dev/docs/modules#$app-navigation-replacestate) functions from `$app/navigation`. + */ + export interface PageState {} + + /** + * If your adapter provides [platform-specific context](https://kit.svelte.dev/docs/adapters#platform-specific-context) via `event.platform`, you can specify it here. + */ + export interface Platform {} +} + +/** + * This module is only available to [service workers](https://kit.svelte.dev/docs/service-workers). + */ +declare module '$service-worker' { + /** + * The `base` path of the deployment. Typically this is equivalent to `config.kit.paths.base`, but it is calculated from `location.pathname` meaning that it will continue to work correctly if the site is deployed to a subdirectory. + * Note that there is a `base` but no `assets`, since service workers cannot be used if `config.kit.paths.assets` is specified. + */ + export const base: string; + /** + * An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`. + * During development, this is an empty array. + */ + export const build: string[]; + /** + * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://kit.svelte.dev/docs/configuration) + */ + export const files: string[]; + /** + * An array of pathnames corresponding to prerendered pages and endpoints. + * During development, this is an empty array. + */ + export const prerendered: string[]; + /** + * See [`config.kit.version`](https://kit.svelte.dev/docs/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches. + */ + export const version: string; +} + +/** Internal version of $app/environment */ +declare module '__sveltekit/environment' { + /** + * SvelteKit analyses your app during the `build` step by running it. During this process, `building` is `true`. This also applies during prerendering. + */ + export const building: boolean; + /** + * True during prerendering, false otherwise. + */ + export const prerendering: boolean; + /** + * The value of `config.kit.version.name`. + */ + export const version: string; + export function set_building(): void; + export function set_prerendering(): void; +} + +/** Internal version of $app/paths */ +declare module '__sveltekit/paths' { + /** + * A string that matches [`config.kit.paths.base`](https://kit.svelte.dev/docs/configuration#paths). + * + * Example usage: `
Link` + */ + export let base: '' | `/${string}`; + /** + * An absolute path that matches [`config.kit.paths.assets`](https://kit.svelte.dev/docs/configuration#paths). + * + * > If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during `vite dev` or `vite preview`, since the assets don't yet live at their eventual URL. + */ + export let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit_assets'; + export let relative: boolean; + export function reset(): void; + export function override(paths: { base: string; assets: string }): void; + export function set_assets(path: string): void; +} diff --git a/node_modules/@sveltejs/kit/src/types/internal.d.ts b/node_modules/@sveltejs/kit/src/types/internal.d.ts new file mode 100644 index 000000000..a5d91c4c9 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/types/internal.d.ts @@ -0,0 +1,422 @@ +import { SvelteComponent } from 'svelte'; +import { + Config, + ServerLoad, + Handle, + HandleServerError, + KitConfig, + Load, + RequestHandler, + ResolveOptions, + Server, + ServerInitOptions, + HandleFetch, + Actions, + HandleClientError +} from '@sveltejs/kit'; +import { + HttpMethod, + MaybePromise, + PrerenderOption, + RequestOptions, + TrailingSlash +} from './private.js'; + +export interface ServerModule { + Server: typeof InternalServer; +} + +export interface ServerInternalModule { + set_assets(path: string): void; + set_building(): void; + set_prerendering(): void; + set_private_env(environment: Record): void; + set_public_env(environment: Record): void; + set_safe_public_env(environment: Record): void; + set_version(version: string): void; + set_fix_stack_trace(fix_stack_trace: (error: unknown) => string): void; +} + +export interface Asset { + file: string; + size: number; + type: string | null; +} + +export interface AssetDependencies { + file: string; + imports: string[]; + stylesheets: string[]; + fonts: string[]; +} + +export interface BuildData { + app_dir: string; + app_path: string; + manifest_data: ManifestData; + service_worker: string | null; + client: { + start: string; + app: string; + imports: string[]; + stylesheets: string[]; + fonts: string[]; + uses_env_dynamic_public: boolean; + } | null; + server_manifest: import('vite').Manifest; +} + +export interface CSRPageNode { + component: typeof SvelteComponent; + universal: { + load?: Load; + trailingSlash?: TrailingSlash; + }; +} + +export type CSRPageNodeLoader = () => Promise; + +/** + * Definition of a client side route. + * The boolean in the tuples indicates whether the route has a server load. + */ +export type CSRRoute = { + id: string; + exec(path: string): undefined | Record; + errors: Array; + layouts: Array<[has_server_load: boolean, node_loader: CSRPageNodeLoader] | undefined>; + leaf: [has_server_load: boolean, node_loader: CSRPageNodeLoader]; +}; + +export interface Deferred { + fulfil: (value: any) => void; + reject: (error: Error) => void; +} + +export type GetParams = (match: RegExpExecArray) => Record; + +export interface ServerHooks { + handleFetch: HandleFetch; + handle: Handle; + handleError: HandleServerError; +} + +export interface ClientHooks { + handleError: HandleClientError; +} + +export interface Env { + private: Record; + public: Record; +} + +export class InternalServer extends Server { + init(options: ServerInitOptions): Promise; + respond( + request: Request, + options: RequestOptions & { + prerendering?: PrerenderOptions; + read: (file: string) => Buffer; + } + ): Promise; +} + +export interface ManifestData { + assets: Asset[]; + nodes: PageNode[]; + routes: RouteData[]; + matchers: Record; +} + +export interface PageNode { + depth: number; + component?: string; // TODO supply default component if it's missing (bit of an edge case) + universal?: string; + server?: string; + parent_id?: string; + parent?: PageNode; + /** + * Filled with the pages that reference this layout (if this is a layout) + */ + child_pages?: PageNode[]; +} + +export interface PrerenderDependency { + response: Response; + body: null | string | Uint8Array; +} + +export interface PrerenderOptions { + cache?: string; // including this here is a bit of a hack, but it makes it easy to add + fallback?: boolean; + dependencies: Map; +} + +export type RecursiveRequired = { + // Recursive implementation of TypeScript's Required utility type. + // Will recursively continue until it reaches a primitive or Function + [K in keyof T]-?: Extract extends never // If it does not have a Function type + ? RecursiveRequired // recursively continue through. + : T[K]; // Use the exact type for everything else +}; + +export type RequiredResolveOptions = Required; + +export interface RouteParam { + name: string; + matcher: string; + optional: boolean; + rest: boolean; + chained: boolean; +} + +/** + * Represents a route segment in the app. It can either be an intermediate node + * with only layout/error pages, or a leaf, at which point either `page` and `leaf` + * or `endpoint` is set. + */ +export interface RouteData { + id: string; + parent: RouteData | null; + + segment: string; + pattern: RegExp; + params: RouteParam[]; + + layout: PageNode | null; + error: PageNode | null; + leaf: PageNode | null; + + page: { + layouts: Array; + errors: Array; + leaf: number; + } | null; + + endpoint: { + file: string; + } | null; +} + +export type ServerRedirectNode = { + type: 'redirect'; + location: string; +}; + +export type ServerNodesResponse = { + type: 'data'; + /** + * If `null`, then there was no load function <- TODO is this outdated now with the recent changes? + */ + nodes: Array; +}; + +export type ServerDataResponse = ServerRedirectNode | ServerNodesResponse; + +/** + * Signals a successful response of the server `load` function. + * The `uses` property tells the client when it's possible to reuse this data + * in a subsequent request. + */ +export interface ServerDataNode { + type: 'data'; + /** + * The serialized version of this contains a serialized representation of any deferred promises, + * which will be resolved later through chunk nodes. + */ + data: Record | null; + uses: Uses; + slash?: TrailingSlash; +} + +/** + * Resolved data/error of a deferred promise. + */ +export interface ServerDataChunkNode { + type: 'chunk'; + id: number; + data?: Record; + error?: any; +} + +/** + * Signals that the server `load` function was not run, and the + * client should use what it has in memory + */ +export interface ServerDataSkippedNode { + type: 'skip'; +} + +/** + * Signals that the server `load` function failed + */ +export interface ServerErrorNode { + type: 'error'; + error: App.Error; + /** + * Only set for HttpErrors + */ + status?: number; +} + +export interface ServerMetadataRoute { + config: any; + api: { + methods: Array; + }; + page: { + methods: Array<'GET' | 'POST'>; + }; + methods: Array; + prerender: PrerenderOption | undefined; + entries: string[] | undefined; +} + +export interface ServerMetadata { + nodes: Array<{ has_server_load: boolean }>; + routes: Map; +} + +export interface SSRComponent { + default: { + render(props: Record): { + html: string; + head: string; + css: { + code: string; + map: any; // TODO + }; + }; + }; +} + +export type SSRComponentLoader = () => Promise; + +export interface SSRNode { + component: SSRComponentLoader; + /** index into the `components` array in client/manifest.js */ + index: number; + /** external JS files */ + imports: string[]; + /** external CSS files */ + stylesheets: string[]; + /** external font files */ + fonts: string[]; + /** inlined styles */ + inline_styles?(): MaybePromise>; + + universal: { + load?: Load; + prerender?: PrerenderOption; + ssr?: boolean; + csr?: boolean; + trailingSlash?: TrailingSlash; + config?: any; + entries?: PrerenderEntryGenerator; + }; + + server: { + load?: ServerLoad; + prerender?: PrerenderOption; + ssr?: boolean; + csr?: boolean; + trailingSlash?: TrailingSlash; + actions?: Actions; + config?: any; + entries?: PrerenderEntryGenerator; + }; + + universal_id: string; + server_id: string; +} + +export type SSRNodeLoader = () => Promise; + +export interface SSROptions { + app_dir: string; + app_template_contains_nonce: boolean; + csp: ValidatedConfig['kit']['csp']; + csrf_check_origin: boolean; + embedded: boolean; + env_public_prefix: string; + env_private_prefix: string; + hooks: ServerHooks; + preload_strategy: ValidatedConfig['kit']['output']['preloadStrategy']; + root: SSRComponent['default']; + service_worker: boolean; + templates: { + app(values: { + head: string; + body: string; + assets: string; + nonce: string; + env: Record; + }): string; + error(values: { message: string; status: number }): string; + }; + version_hash: string; +} + +export interface PageNodeIndexes { + errors: Array; + layouts: Array; + leaf: number; +} + +export type PrerenderEntryGenerator = () => MaybePromise>>; + +export type SSREndpoint = Partial> & { + prerender?: PrerenderOption; + trailingSlash?: TrailingSlash; + config?: any; + entries?: PrerenderEntryGenerator; + fallback?: RequestHandler; +}; + +export interface SSRRoute { + id: string; + pattern: RegExp; + params: RouteParam[]; + page: PageNodeIndexes | null; + endpoint: (() => Promise) | null; + endpoint_id?: string; +} + +export interface SSRState { + fallback?: string; + getClientAddress(): string; + /** + * True if we're currently attempting to render an error page + */ + error: boolean; + /** + * Allows us to prevent `event.fetch` from making infinitely looping internal requests + */ + depth: number; + platform?: any; + prerendering?: PrerenderOptions; + /** + * When fetching data from a +server.js endpoint in `load`, the page's + * prerender option is inherited by the endpoint, unless overridden + */ + prerender_default?: PrerenderOption; + read?: (file: string) => Buffer; +} + +export type StrictBody = string | ArrayBufferView; + +export interface Uses { + dependencies: Set; + params: Set; + parent: boolean; + route: boolean; + url: boolean; + search_params: Set; +} + +export type ValidatedConfig = RecursiveRequired; + +export type ValidatedKitConfig = RecursiveRequired; + +export * from '../exports/index.js'; +export * from './private.js'; diff --git a/node_modules/@sveltejs/kit/src/types/private.d.ts b/node_modules/@sveltejs/kit/src/types/private.d.ts new file mode 100644 index 000000000..e84cf1644 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/types/private.d.ts @@ -0,0 +1,235 @@ +// This module contains types that are visible in the documentation, +// but which cannot be imported from `@sveltejs/kit`. Care should +// be taken to avoid breaking changes when editing this file + +import { RouteDefinition } from '@sveltejs/kit'; + +export interface AdapterEntry { + /** + * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication. + * For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both + * be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID + */ + id: string; + + /** + * A function that compares the candidate route with the current route to determine + * if it should be grouped with the current route. + * + * Use cases: + * - Fallback pages: `/foo/[c]` is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes + * - Grouping routes that share a common `config`: `/foo` should be deployed to the edge, `/bar` and `/baz` should be deployed to a serverless function + */ + filter(route: RouteDefinition): boolean; + + /** + * A function that is invoked once the entry has been created. This is where you + * should write the function to the filesystem and generate redirect manifests. + */ + complete(entry: { generateManifest(opts: { relativePath: string }): string }): MaybePromise; +} + +// Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts +// +// MIT License +// +// Copyright (c) 2021-present, Joshua Hemphill +// Copyright (c) 2021, Tecnico Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +export namespace Csp { + type ActionSource = 'strict-dynamic' | 'report-sample'; + type BaseSource = + | 'self' + | 'unsafe-eval' + | 'unsafe-hashes' + | 'unsafe-inline' + | 'wasm-unsafe-eval' + | 'none'; + type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`; + type FrameSource = HostSource | SchemeSource | 'self' | 'none'; + type HostNameScheme = `${string}.${string}` | 'localhost'; + type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`; + type HostProtocolSchemes = `${string}://` | ''; + type HttpDelineator = '/' | '?' | '#' | '\\'; + type PortScheme = `:${number}` | '' | ':*'; + type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:'; + type Source = HostSource | SchemeSource | CryptoSource | BaseSource; + type Sources = Source[]; + type UriPath = `${HttpDelineator}${string}`; +} + +export interface CspDirectives { + 'child-src'?: Csp.Sources; + 'default-src'?: Array; + 'frame-src'?: Csp.Sources; + 'worker-src'?: Csp.Sources; + 'connect-src'?: Csp.Sources; + 'font-src'?: Csp.Sources; + 'img-src'?: Csp.Sources; + 'manifest-src'?: Csp.Sources; + 'media-src'?: Csp.Sources; + 'object-src'?: Csp.Sources; + 'prefetch-src'?: Csp.Sources; + 'script-src'?: Array; + 'script-src-elem'?: Csp.Sources; + 'script-src-attr'?: Csp.Sources; + 'style-src'?: Array; + 'style-src-elem'?: Csp.Sources; + 'style-src-attr'?: Csp.Sources; + 'base-uri'?: Array; + sandbox?: Array< + | 'allow-downloads-without-user-activation' + | 'allow-forms' + | 'allow-modals' + | 'allow-orientation-lock' + | 'allow-pointer-lock' + | 'allow-popups' + | 'allow-popups-to-escape-sandbox' + | 'allow-presentation' + | 'allow-same-origin' + | 'allow-scripts' + | 'allow-storage-access-by-user-activation' + | 'allow-top-navigation' + | 'allow-top-navigation-by-user-activation' + >; + 'form-action'?: Array; + 'frame-ancestors'?: Array; + 'navigate-to'?: Array; + 'report-uri'?: Csp.UriPath[]; + 'report-to'?: string[]; + + 'require-trusted-types-for'?: Array<'script'>; + 'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>; + 'upgrade-insecure-requests'?: boolean; + + /** @deprecated */ + 'require-sri-for'?: Array<'script' | 'style' | 'script style'>; + + /** @deprecated */ + 'block-all-mixed-content'?: boolean; + + /** @deprecated */ + 'plugin-types'?: Array<`${string}/${string}` | 'none'>; + + /** @deprecated */ + referrer?: Array< + | 'no-referrer' + | 'no-referrer-when-downgrade' + | 'origin' + | 'origin-when-cross-origin' + | 'same-origin' + | 'strict-origin' + | 'strict-origin-when-cross-origin' + | 'unsafe-url' + | 'none' + >; +} + +export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS'; + +export interface Logger { + (msg: string): void; + success(msg: string): void; + error(msg: string): void; + warn(msg: string): void; + minor(msg: string): void; + info(msg: string): void; +} + +export type MaybePromise = T | Promise; + +export interface Prerendered { + /** + * A map of `path` to `{ file }` objects, where a path like `/foo` corresponds to `foo.html` and a path like `/bar/` corresponds to `bar/index.html`. + */ + pages: Map< + string, + { + /** The location of the .html file relative to the output directory */ + file: string; + } + >; + /** + * A map of `path` to `{ type }` objects. + */ + assets: Map< + string, + { + /** The MIME type of the asset */ + type: string; + } + >; + /** + * A map of redirects encountered during prerendering. + */ + redirects: Map< + string, + { + status: number; + location: string; + } + >; + /** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */ + paths: string[]; +} + +export interface PrerenderHttpErrorHandler { + (details: { + status: number; + path: string; + referrer: string | null; + referenceType: 'linked' | 'fetched'; + message: string; + }): void; +} + +export interface PrerenderMissingIdHandler { + (details: { path: string; id: string; referrers: string[]; message: string }): void; +} + +export interface PrerenderEntryGeneratorMismatchHandler { + (details: { generatedFromId: string; entry: string; matchedId: string; message: string }): void; +} + +export type PrerenderHttpErrorHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderHttpErrorHandler; +export type PrerenderMissingIdHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderMissingIdHandler; +export type PrerenderEntryGeneratorMismatchHandlerValue = + | 'fail' + | 'warn' + | 'ignore' + | PrerenderEntryGeneratorMismatchHandler; + +export type PrerenderOption = boolean | 'auto'; + +export type PrerenderMap = Map; + +export interface RequestOptions { + getClientAddress(): string; + platform?: App.Platform; +} + +export interface RouteSegment { + content: string; + dynamic: boolean; + rest: boolean; +} + +export type TrailingSlash = 'never' | 'always' | 'ignore'; diff --git a/node_modules/@sveltejs/kit/src/types/synthetic/$env+dynamic+private.md b/node_modules/@sveltejs/kit/src/types/synthetic/$env+dynamic+private.md new file mode 100644 index 000000000..d5cd7239d --- /dev/null +++ b/node_modules/@sveltejs/kit/src/types/synthetic/$env+dynamic+private.md @@ -0,0 +1,12 @@ +This module provides access to runtime environment variables, as defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://kit.svelte.dev/docs/cli)), this is equivalent to `process.env`. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://kit.svelte.dev/docs/configuration#env) (if configured). + +This module cannot be imported into client-side code. + +Dynamic environment variables cannot be used during prerendering. + +```ts +import { env } from '$env/dynamic/private'; +console.log(env.DEPLOYMENT_SPECIFIC_VARIABLE); +``` + +> In `dev`, `$env/dynamic` always includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter. diff --git a/node_modules/@sveltejs/kit/src/types/synthetic/$env+dynamic+public.md b/node_modules/@sveltejs/kit/src/types/synthetic/$env+dynamic+public.md new file mode 100644 index 000000000..ad1cf54d2 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/types/synthetic/$env+dynamic+public.md @@ -0,0 +1,10 @@ +Similar to [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), but only includes variables that begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code. + +Note that public dynamic environment variables must all be sent from the server to the client, causing larger network requests — when possible, use `$env/static/public` instead. + +Dynamic environment variables cannot be used during prerendering. + +```ts +import { env } from '$env/dynamic/public'; +console.log(env.PUBLIC_DEPLOYMENT_SPECIFIC_VARIABLE); +``` diff --git a/node_modules/@sveltejs/kit/src/types/synthetic/$env+static+private.md b/node_modules/@sveltejs/kit/src/types/synthetic/$env+static+private.md new file mode 100644 index 000000000..40704d239 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/types/synthetic/$env+static+private.md @@ -0,0 +1,19 @@ +Environment variables [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env`. Like [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), this module cannot be imported into client-side code. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://kit.svelte.dev/docs/configuration#env) (if configured). + +_Unlike_ [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), the values exported from this module are statically injected into your bundle at build time, enabling optimisations like dead code elimination. + +```ts +import { API_KEY } from '$env/static/private'; +``` + +Note that all environment variables referenced in your code should be declared (for example in an `.env` file), even if they don't have a value until the app is deployed: + +``` +MY_FEATURE_FLAG="" +``` + +You can override `.env` values from the command line like so: + +```bash +MY_FEATURE_FLAG="enabled" npm run dev +``` diff --git a/node_modules/@sveltejs/kit/src/types/synthetic/$env+static+public.md b/node_modules/@sveltejs/kit/src/types/synthetic/$env+static+public.md new file mode 100644 index 000000000..2b55250f0 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/types/synthetic/$env+static+public.md @@ -0,0 +1,7 @@ +Similar to [`$env/static/private`](https://kit.svelte.dev/docs/modules#$env-static-private), except that it only includes environment variables that begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code. + +Values are replaced statically at build time. + +```ts +import { PUBLIC_BASE_URL } from '$env/static/public'; +``` diff --git a/node_modules/@sveltejs/kit/src/types/synthetic/$lib.md b/node_modules/@sveltejs/kit/src/types/synthetic/$lib.md new file mode 100644 index 000000000..9b7600134 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/types/synthetic/$lib.md @@ -0,0 +1,5 @@ +This is a simple alias to `src/lib`, or whatever directory is specified as [`config.kit.files.lib`](https://kit.svelte.dev/docs/configuration#files). It allows you to access common components and utility modules without `../../../../` nonsense. + +### `$lib/server` + +A subdirectory of `$lib`. SvelteKit will prevent you from importing any modules in `$lib/server` into client-side code. See [server-only modules](/docs/server-only-modules). diff --git a/node_modules/@sveltejs/kit/src/utils/array.js b/node_modules/@sveltejs/kit/src/utils/array.js new file mode 100644 index 000000000..08f938451 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/array.js @@ -0,0 +1,9 @@ +/** + * Removes nullish values from an array. + * + * @template T + * @param {Array} arr + */ +export function compact(arr) { + return arr.filter(/** @returns {val is NonNullable} */ (val) => val != null); +} diff --git a/node_modules/@sveltejs/kit/src/utils/env.js b/node_modules/@sveltejs/kit/src/utils/env.js new file mode 100644 index 000000000..e2106f342 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/env.js @@ -0,0 +1,33 @@ +/** + * @param {Record} env + * @param {{ + * public_prefix: string; + * private_prefix: string; + * }} prefixes + * @returns {Record} + */ +export function filter_private_env(env, { public_prefix, private_prefix }) { + return Object.fromEntries( + Object.entries(env).filter( + ([k]) => + k.startsWith(private_prefix) && (public_prefix === '' || !k.startsWith(public_prefix)) + ) + ); +} + +/** + * @param {Record} env + * @param {{ + * public_prefix: string; + * private_prefix: string; + * }} prefixes + * @returns {Record} + */ +export function filter_public_env(env, { public_prefix, private_prefix }) { + return Object.fromEntries( + Object.entries(env).filter( + ([k]) => + k.startsWith(public_prefix) && (private_prefix === '' || !k.startsWith(private_prefix)) + ) + ); +} diff --git a/node_modules/@sveltejs/kit/src/utils/error.js b/node_modules/@sveltejs/kit/src/utils/error.js new file mode 100644 index 000000000..1247b9409 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/error.js @@ -0,0 +1,38 @@ +import { HttpError, SvelteKitError } from '../runtime/control.js'; + +/** + * @param {unknown} err + * @return {Error} + */ +export function coalesce_to_error(err) { + return err instanceof Error || + (err && /** @type {any} */ (err).name && /** @type {any} */ (err).message) + ? /** @type {Error} */ (err) + : new Error(JSON.stringify(err)); +} + +/** + * This is an identity function that exists to make TypeScript less + * paranoid about people throwing things that aren't errors, which + * frankly is not something we should care about + * @param {unknown} error + */ +export function normalize_error(error) { + return /** @type {import('../runtime/control.js').Redirect | HttpError | SvelteKitError | Error} */ ( + error + ); +} + +/** + * @param {unknown} error + */ +export function get_status(error) { + return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500; +} + +/** + * @param {unknown} error + */ +export function get_message(error) { + return error instanceof SvelteKitError ? error.text : 'Internal Error'; +} diff --git a/node_modules/@sveltejs/kit/src/utils/escape.js b/node_modules/@sveltejs/kit/src/utils/escape.js new file mode 100644 index 000000000..543e1a13c --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/escape.js @@ -0,0 +1,46 @@ +/** + * When inside a double-quoted attribute value, only `&` and `"` hold special meaning. + * @see https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(double-quoted)-state + * @type {Record} + */ +const escape_html_attr_dict = { + '&': '&', + '"': '"' +}; + +const escape_html_attr_regex = new RegExp( + // special characters + `[${Object.keys(escape_html_attr_dict).join('')}]|` + + // high surrogate without paired low surrogate + '[\\ud800-\\udbff](?![\\udc00-\\udfff])|' + + // a valid surrogate pair, the only match with 2 code units + // we match it so that we can match unpaired low surrogates in the same pass + // TODO: use lookbehind assertions once they are widely supported: (?...`; + */ +export function escape_html_attr(str) { + const escaped_str = str.replace(escape_html_attr_regex, (match) => { + if (match.length === 2) { + // valid surrogate pair + return match; + } + + return escape_html_attr_dict[match] ?? `&#${match.charCodeAt(0)};`; + }); + + return `"${escaped_str}"`; +} diff --git a/node_modules/@sveltejs/kit/src/utils/exports.js b/node_modules/@sveltejs/kit/src/utils/exports.js new file mode 100644 index 000000000..ed685edb7 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/exports.js @@ -0,0 +1,93 @@ +/** + * @param {Set} expected + */ +function validator(expected) { + /** + * @param {any} module + * @param {string} [file] + */ + function validate(module, file) { + if (!module) return; + + for (const key in module) { + if (key[0] === '_' || expected.has(key)) continue; // key is valid in this module + + const values = [...expected.values()]; + + const hint = + hint_for_supported_files(key, file?.slice(file.lastIndexOf('.'))) ?? + `valid exports are ${values.join(', ')}, or anything with a '_' prefix`; + + throw new Error(`Invalid export '${key}'${file ? ` in ${file}` : ''} (${hint})`); + } + } + + return validate; +} + +/** + * @param {string} key + * @param {string} ext + * @returns {string | void} + */ +function hint_for_supported_files(key, ext = '.js') { + const supported_files = []; + + if (valid_layout_exports.has(key)) { + supported_files.push(`+layout${ext}`); + } + + if (valid_page_exports.has(key)) { + supported_files.push(`+page${ext}`); + } + + if (valid_layout_server_exports.has(key)) { + supported_files.push(`+layout.server${ext}`); + } + + if (valid_page_server_exports.has(key)) { + supported_files.push(`+page.server${ext}`); + } + + if (valid_server_exports.has(key)) { + supported_files.push(`+server${ext}`); + } + + if (supported_files.length > 0) { + return `'${key}' is a valid export in ${supported_files.slice(0, -1).join(', ')}${ + supported_files.length > 1 ? ' or ' : '' + }${supported_files.at(-1)}`; + } +} + +const valid_layout_exports = new Set([ + 'load', + 'prerender', + 'csr', + 'ssr', + 'trailingSlash', + 'config' +]); +const valid_page_exports = new Set([...valid_layout_exports, 'entries']); +const valid_layout_server_exports = new Set([...valid_layout_exports]); +const valid_page_server_exports = new Set([...valid_layout_server_exports, 'actions', 'entries']); +const valid_server_exports = new Set([ + 'GET', + 'POST', + 'PATCH', + 'PUT', + 'DELETE', + 'OPTIONS', + 'HEAD', + 'fallback', + 'prerender', + 'trailingSlash', + 'config', + 'entries' +]); + +export const validate_layout_exports = validator(valid_layout_exports); +export const validate_page_exports = validator(valid_page_exports); +export const validate_layout_server_exports = validator(valid_layout_server_exports); +export const validate_page_server_exports = validator(valid_page_server_exports); +export const validate_server_exports = validator(valid_server_exports); diff --git a/node_modules/@sveltejs/kit/src/utils/filesystem.js b/node_modules/@sveltejs/kit/src/utils/filesystem.js new file mode 100644 index 000000000..d79ead041 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/filesystem.js @@ -0,0 +1,183 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +/** @param {string} dir */ +export function mkdirp(dir) { + try { + fs.mkdirSync(dir, { recursive: true }); + } catch (/** @type {any} */ e) { + if (e.code === 'EEXIST') { + if (!fs.statSync(dir).isDirectory()) { + throw new Error(`Cannot create directory ${dir}, a file already exists at this position`); + } + return; + } + throw e; + } +} + +/** @param {string} path */ +export function rimraf(path) { + fs.rmSync(path, { force: true, recursive: true }); +} + +/** + * @param {string} source + * @param {string} target + * @param {{ + * filter?: (basename: string) => boolean; + * replace?: Record; + * }} opts + */ +export function copy(source, target, opts = {}) { + if (!fs.existsSync(source)) return []; + + /** @type {string[]} */ + const files = []; + + const prefix = posixify(target) + '/'; + + const regex = opts.replace + ? new RegExp(`\\b(${Object.keys(opts.replace).join('|')})\\b`, 'g') + : null; + + /** + * @param {string} from + * @param {string} to + */ + function go(from, to) { + if (opts.filter && !opts.filter(path.basename(from))) return; + + const stats = fs.statSync(from); + + if (stats.isDirectory()) { + fs.readdirSync(from).forEach((file) => { + go(path.join(from, file), path.join(to, file)); + }); + } else { + mkdirp(path.dirname(to)); + + if (opts.replace) { + const data = fs.readFileSync(from, 'utf-8'); + fs.writeFileSync( + to, + data.replace( + /** @type {RegExp} */ (regex), + (_match, key) => /** @type {Record} */ (opts.replace)[key] + ) + ); + } else { + fs.copyFileSync(from, to); + } + + files.push(to === target ? posixify(path.basename(to)) : posixify(to).replace(prefix, '')); + } + } + + go(source, target); + + return files; +} + +/** + * Get a list of all files in a directory + * @param {string} cwd - the directory to walk + * @param {boolean} [dirs] - whether to include directories in the result + * @returns {string[]} a list of all found files (and possibly directories) relative to `cwd` + */ +export function walk(cwd, dirs = false) { + /** @type {string[]} */ + const all_files = []; + + /** @param {string} dir */ + function walk_dir(dir) { + const files = fs.readdirSync(path.join(cwd, dir)); + + for (const file of files) { + const joined = path.join(dir, file); + const stats = fs.statSync(path.join(cwd, joined)); + if (stats.isDirectory()) { + if (dirs) all_files.push(joined); + walk_dir(joined); + } else { + all_files.push(joined); + } + } + } + + return walk_dir(''), all_files; +} + +/** @param {string} str */ +export function posixify(str) { + return str.replace(/\\/g, '/'); +} + +/** + * Like `path.join`, but posixified and with a leading `./` if necessary + * @param {string[]} str + */ +export function join_relative(...str) { + let result = posixify(path.join(...str)); + if (!result.startsWith('.')) { + result = `./${result}`; + } + return result; +} + +/** + * Like `path.relative`, but always posixified and with a leading `./` if necessary. + * Useful for JS imports so the path can safely reside inside of `node_modules`. + * Otherwise paths could be falsely interpreted as package paths. + * @param {string} from + * @param {string} to + */ +export function relative_path(from, to) { + return join_relative(path.relative(from, to)); +} + +/** + * Prepend given path with `/@fs` prefix + * @param {string} str + */ +export function to_fs(str) { + str = posixify(str); + return `/@fs${ + // Windows/Linux separation - Windows starts with a drive letter, we need a / in front there + str.startsWith('/') ? '' : '/' + }${str}`; +} + +/** + * Given an entry point like [cwd]/src/hooks, returns a filename like [cwd]/src/hooks.js or [cwd]/src/hooks/index.js + * @param {string} entry + * @returns {string|null} + */ +export function resolve_entry(entry) { + if (fs.existsSync(entry)) { + const stats = fs.statSync(entry); + if (stats.isDirectory()) { + return resolve_entry(path.join(entry, 'index')); + } + + return entry; + } else { + const dir = path.dirname(entry); + + if (fs.existsSync(dir)) { + const base = path.basename(entry); + const files = fs.readdirSync(dir); + + const found = files.find((file) => file.replace(/\.[^.]+$/, '') === base); + + if (found) return path.join(dir, found); + } + } + + return null; +} + +/** @param {string} file */ +export function read(file) { + return fs.readFileSync(file, 'utf-8'); +} diff --git a/node_modules/@sveltejs/kit/src/utils/fork.js b/node_modules/@sveltejs/kit/src/utils/fork.js new file mode 100644 index 000000000..96d513a21 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/fork.js @@ -0,0 +1,69 @@ +import { fileURLToPath } from 'node:url'; +import { Worker, parentPort } from 'node:worker_threads'; + +/** + * Runs a task in a subprocess so any dangling stuff gets killed upon completion. + * The subprocess needs to be the file `forked` is called in, and `forked` needs to be called eagerly at the top level. + * @template T + * @template U + * @param {string} module `import.meta.url` of the file + * @param {(opts: T) => U} callback The function that is invoked in the subprocess + * @returns {(opts: T) => Promise} A function that when called starts the subprocess + */ +export function forked(module, callback) { + if (process.env.SVELTEKIT_FORK && parentPort) { + parentPort.on( + 'message', + /** @param {any} data */ async (data) => { + if (data?.type === 'args' && data.module === module) { + parentPort?.postMessage({ + type: 'result', + module, + payload: await callback(data.payload) + }); + } + } + ); + + parentPort.postMessage({ type: 'ready', module }); + } + + /** + * @param {T} opts + * @returns {Promise} + */ + return function (opts) { + return new Promise((fulfil, reject) => { + const worker = new Worker(fileURLToPath(module), { + env: { + ...process.env, + SVELTEKIT_FORK: 'true' + } + }); + + worker.on( + 'message', + /** @param {any} data */ (data) => { + if (data?.type === 'ready' && data.module === module) { + worker.postMessage({ + type: 'args', + module, + payload: opts + }); + } + + if (data?.type === 'result' && data.module === module) { + worker.unref(); + fulfil(data.payload); + } + } + ); + + worker.on('exit', (code) => { + if (code) { + reject(new Error(`Failed with code ${code}`)); + } + }); + }); + }; +} diff --git a/node_modules/@sveltejs/kit/src/utils/functions.js b/node_modules/@sveltejs/kit/src/utils/functions.js new file mode 100644 index 000000000..062910784 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/functions.js @@ -0,0 +1,16 @@ +/** + * @template T + * @param {() => T} fn + */ +export function once(fn) { + let done = false; + + /** @type T */ + let result; + + return () => { + if (done) return result; + done = true; + return (result = fn()); + }; +} diff --git a/node_modules/@sveltejs/kit/src/utils/http.js b/node_modules/@sveltejs/kit/src/utils/http.js new file mode 100644 index 000000000..739993449 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/http.js @@ -0,0 +1,79 @@ +/** + * Given an Accept header and a list of possible content types, pick + * the most suitable one to respond with + * @param {string} accept + * @param {string[]} types + */ +export function negotiate(accept, types) { + /** @type {Array<{ type: string, subtype: string, q: number, i: number }>} */ + const parts = []; + + accept.split(',').forEach((str, i) => { + const match = /([^/]+)\/([^;]+)(?:;q=([0-9.]+))?/.exec(str); + + // no match equals invalid header — ignore + if (match) { + const [, type, subtype, q = '1'] = match; + parts.push({ type, subtype, q: +q, i }); + } + }); + + parts.sort((a, b) => { + if (a.q !== b.q) { + return b.q - a.q; + } + + if ((a.subtype === '*') !== (b.subtype === '*')) { + return a.subtype === '*' ? 1 : -1; + } + + if ((a.type === '*') !== (b.type === '*')) { + return a.type === '*' ? 1 : -1; + } + + return a.i - b.i; + }); + + let accepted; + let min_priority = Infinity; + + for (const mimetype of types) { + const [type, subtype] = mimetype.split('/'); + const priority = parts.findIndex( + (part) => + (part.type === type || part.type === '*') && + (part.subtype === subtype || part.subtype === '*') + ); + + if (priority !== -1 && priority < min_priority) { + accepted = mimetype; + min_priority = priority; + } + } + + return accepted; +} + +/** + * Returns `true` if the request contains a `content-type` header with the given type + * @param {Request} request + * @param {...string} types + */ +function is_content_type(request, ...types) { + const type = request.headers.get('content-type')?.split(';', 1)[0].trim() ?? ''; + return types.includes(type.toLowerCase()); +} + +/** + * @param {Request} request + */ +export function is_form_content_type(request) { + // These content types must be protected against CSRF + // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/enctype + return is_content_type( + request, + 'application/x-www-form-urlencoded', + 'multipart/form-data', + 'text/plain' + ); +} diff --git a/node_modules/@sveltejs/kit/src/utils/misc.js b/node_modules/@sveltejs/kit/src/utils/misc.js new file mode 100644 index 000000000..cd64ed212 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/misc.js @@ -0,0 +1 @@ +export const s = JSON.stringify; diff --git a/node_modules/@sveltejs/kit/src/utils/options.js b/node_modules/@sveltejs/kit/src/utils/options.js new file mode 100644 index 000000000..46a325351 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/options.js @@ -0,0 +1,16 @@ +/** + * @template {'prerender' | 'ssr' | 'csr' | 'trailingSlash' | 'entries'} Option + * @template {(import('types').SSRNode['universal'] | import('types').SSRNode['server'])[Option]} Value + * + * @param {Array} nodes + * @param {Option} option + * + * @returns {Value | undefined} + */ +export function get_option(nodes, option) { + return nodes.reduce((value, node) => { + return /** @type {Value} TypeScript's too dumb to understand this */ ( + node?.universal?.[option] ?? node?.server?.[option] ?? value + ); + }, /** @type {Value | undefined} */ (undefined)); +} diff --git a/node_modules/@sveltejs/kit/src/utils/routing.js b/node_modules/@sveltejs/kit/src/utils/routing.js new file mode 100644 index 000000000..66a70c5b3 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/routing.js @@ -0,0 +1,262 @@ +const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/; + +/** + * Creates the regex pattern, extracts parameter names, and generates types for a route + * @param {string} id + */ +export function parse_route_id(id) { + /** @type {import('types').RouteParam[]} */ + const params = []; + + const pattern = + id === '/' + ? /^\/$/ + : new RegExp( + `^${get_route_segments(id) + .map((segment) => { + // special case — /[...rest]/ could contain zero segments + const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment); + if (rest_match) { + params.push({ + name: rest_match[1], + matcher: rest_match[2], + optional: false, + rest: true, + chained: true + }); + return '(?:/(.*))?'; + } + // special case — /[[optional]]/ could contain zero segments + const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment); + if (optional_match) { + params.push({ + name: optional_match[1], + matcher: optional_match[2], + optional: true, + rest: false, + chained: true + }); + return '(?:/([^/]+))?'; + } + + if (!segment) { + return; + } + + const parts = segment.split(/\[(.+?)\](?!\])/); + const result = parts + .map((content, i) => { + if (i % 2) { + if (content.startsWith('x+')) { + return escape(String.fromCharCode(parseInt(content.slice(2), 16))); + } + + if (content.startsWith('u+')) { + return escape( + String.fromCharCode( + ...content + .slice(2) + .split('-') + .map((code) => parseInt(code, 16)) + ) + ); + } + + const match = param_pattern.exec(content); + if (!match) { + throw new Error( + `Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.` + ); + } + + const [, is_optional, is_rest, name, matcher] = match; + // It's assumed that the following invalid route id cases are already checked + // - unbalanced brackets + // - optional param following rest param + + params.push({ + name, + matcher, + optional: !!is_optional, + rest: !!is_rest, + chained: is_rest ? i === 1 && parts[0] === '' : false + }); + return is_rest ? '(.*?)' : is_optional ? '([^/]*)?' : '([^/]+?)'; + } + + return escape(content); + }) + .join(''); + + return '/' + result; + }) + .join('')}/?$` + ); + + return { pattern, params }; +} + +const optional_param_regex = /\/\[\[\w+?(?:=\w+)?\]\]/; + +/** + * Removes optional params from a route ID. + * @param {string} id + * @returns The route id with optional params removed + */ +export function remove_optional_params(id) { + return id.replace(optional_param_regex, ''); +} + +/** + * Returns `false` for `(group)` segments + * @param {string} segment + */ +function affects_path(segment) { + return !/^\([^)]+\)$/.test(segment); +} + +/** + * Splits a route id into its segments, removing segments that + * don't affect the path (i.e. groups). The root route is represented by `/` + * and will be returned as `['']`. + * @param {string} route + * @returns string[] + */ +export function get_route_segments(route) { + return route.slice(1).split('/').filter(affects_path); +} + +/** + * @param {RegExpMatchArray} match + * @param {import('types').RouteParam[]} params + * @param {Record} matchers + */ +export function exec(match, params, matchers) { + /** @type {Record} */ + const result = {}; + + const values = match.slice(1); + const values_needing_match = values.filter((value) => value !== undefined); + + let buffered = 0; + + for (let i = 0; i < params.length; i += 1) { + const param = params[i]; + let value = values[i - buffered]; + + // in the `[[a=b]]/.../[...rest]` case, if one or more optional parameters + // weren't matched, roll the skipped values into the rest + if (param.chained && param.rest && buffered) { + value = values + .slice(i - buffered, i + 1) + .filter((s) => s) + .join('/'); + + buffered = 0; + } + + // if `value` is undefined, it means this is an optional or rest parameter + if (value === undefined) { + if (param.rest) result[param.name] = ''; + continue; + } + + if (!param.matcher || matchers[param.matcher](value)) { + result[param.name] = value; + + // Now that the params match, reset the buffer if the next param isn't the [...rest] + // and the next value is defined, otherwise the buffer will cause us to skip values + const next_param = params[i + 1]; + const next_value = values[i + 1]; + if (next_param && !next_param.rest && next_param.optional && next_value && param.chained) { + buffered = 0; + } + + // There are no more params and no more values, but all non-empty values have been matched + if ( + !next_param && + !next_value && + Object.keys(result).length === values_needing_match.length + ) { + buffered = 0; + } + continue; + } + + // in the `/[[a=b]]/...` case, if the value didn't satisfy the matcher, + // keep track of the number of skipped optional parameters and continue + if (param.optional && param.chained) { + buffered++; + continue; + } + + // otherwise, if the matcher returns `false`, the route did not match + return; + } + + if (buffered) return; + return result; +} + +/** @param {string} str */ +function escape(str) { + return ( + str + .normalize() + // escape [ and ] before escaping other characters, since they are used in the replacements + .replace(/[[\]]/g, '\\$&') + // replace %, /, ? and # with their encoded versions because decode_pathname leaves them untouched + .replace(/%/g, '%25') + .replace(/\//g, '%2[Ff]') + .replace(/\?/g, '%3[Ff]') + .replace(/#/g, '%23') + // escape characters that have special meaning in regex + .replace(/[.*+?^${}()|\\]/g, '\\$&') + ); +} + +const basic_param_pattern = /\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g; + +/** + * Populate a route ID with params to resolve a pathname. + * @example + * ```js + * resolveRoute( + * `/blog/[slug]/[...somethingElse]`, + * { + * slug: 'hello-world', + * somethingElse: 'something/else' + * } + * ); // `/blog/hello-world/something/else` + * ``` + * @param {string} id + * @param {Record} params + * @returns {string} + */ +export function resolve_route(id, params) { + const segments = get_route_segments(id); + return ( + '/' + + segments + .map((segment) => + segment.replace(basic_param_pattern, (_, optional, rest, name) => { + const param_value = params[name]; + + // This is nested so TS correctly narrows the type + if (!param_value) { + if (optional) return ''; + if (rest && param_value !== undefined) return ''; + throw new Error(`Missing parameter '${name}' in route ${id}`); + } + + if (param_value.startsWith('/') || param_value.endsWith('/')) + throw new Error( + `Parameter '${name}' in route ${id} cannot start or end with a slash -- this would cause an invalid route like foo//bar` + ); + return param_value; + }) + ) + .filter(Boolean) + .join('/') + ); +} diff --git a/node_modules/@sveltejs/kit/src/utils/streaming.js b/node_modules/@sveltejs/kit/src/utils/streaming.js new file mode 100644 index 000000000..cfb0d6a04 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/streaming.js @@ -0,0 +1,51 @@ +/** + * @returns {import('types').Deferred & { promise: Promise }}} + */ +function defer() { + let fulfil; + let reject; + + const promise = new Promise((f, r) => { + fulfil = f; + reject = r; + }); + + // @ts-expect-error + return { promise, fulfil, reject }; +} + +/** + * Create an async iterator and a function to push values into it + * @returns {{ + * iterator: AsyncIterable; + * push: (value: any) => void; + * done: () => void; + * }} + */ +export function create_async_iterator() { + const deferred = [defer()]; + + return { + iterator: { + [Symbol.asyncIterator]() { + return { + next: async () => { + const next = await deferred[0].promise; + if (!next.done) deferred.shift(); + return next; + } + }; + } + }, + push: (value) => { + deferred[deferred.length - 1].fulfil({ + value, + done: false + }); + deferred.push(defer()); + }, + done: () => { + deferred[deferred.length - 1].fulfil({ done: true }); + } + }; +} diff --git a/node_modules/@sveltejs/kit/src/utils/url.js b/node_modules/@sveltejs/kit/src/utils/url.js new file mode 100644 index 000000000..9f6391e42 --- /dev/null +++ b/node_modules/@sveltejs/kit/src/utils/url.js @@ -0,0 +1,220 @@ +import { BROWSER } from 'esm-env'; + +/** + * Matches a URI scheme. See https://www.rfc-editor.org/rfc/rfc3986#section-3.1 + * @type {RegExp} + */ +export const SCHEME = /^[a-z][a-z\d+\-.]+:/i; + +const internal = new URL('sveltekit-internal://'); + +/** + * @param {string} base + * @param {string} path + */ +export function resolve(base, path) { + // special case + if (path[0] === '/' && path[1] === '/') return path; + + let url = new URL(base, internal); + url = new URL(path, url); + + return url.protocol === internal.protocol ? url.pathname + url.search + url.hash : url.href; +} + +/** @param {string} path */ +export function is_root_relative(path) { + return path[0] === '/' && path[1] !== '/'; +} + +/** + * @param {string} path + * @param {import('types').TrailingSlash} trailing_slash + */ +export function normalize_path(path, trailing_slash) { + if (path === '/' || trailing_slash === 'ignore') return path; + + if (trailing_slash === 'never') { + return path.endsWith('/') ? path.slice(0, -1) : path; + } else if (trailing_slash === 'always' && !path.endsWith('/')) { + return path + '/'; + } + + return path; +} + +/** + * Decode pathname excluding %25 to prevent further double decoding of params + * @param {string} pathname + */ +export function decode_pathname(pathname) { + return pathname.split('%25').map(decodeURI).join('%25'); +} + +/** @param {Record} params */ +export function decode_params(params) { + for (const key in params) { + // input has already been decoded by decodeURI + // now handle the rest + params[key] = decodeURIComponent(params[key]); + } + + return params; +} + +/** + * The error when a URL is malformed is not very helpful, so we augment it with the URI + * @param {string} uri + */ +export function decode_uri(uri) { + try { + return decodeURI(uri); + } catch (e) { + if (e instanceof Error) { + e.message = `Failed to decode URI: ${uri}\n` + e.message; + } + throw e; + } +} + +/** + * Returns everything up to the first `#` in a URL + * @param {{href: string}} url_like + */ +export function strip_hash({ href }) { + return href.split('#')[0]; +} + +/** + * URL properties that could change during the lifetime of the page, + * which excludes things like `origin` + */ +const tracked_url_properties = /** @type {const} */ ([ + 'href', + 'pathname', + 'search', + 'toString', + 'toJSON' +]); + +/** + * @param {URL} url + * @param {() => void} callback + * @param {(search_param: string) => void} search_params_callback + */ +export function make_trackable(url, callback, search_params_callback) { + const tracked = new URL(url); + + Object.defineProperty(tracked, 'searchParams', { + value: new Proxy(tracked.searchParams, { + get(obj, key) { + if (key === 'get' || key === 'getAll' || key === 'has') { + return (/**@type {string}*/ param) => { + search_params_callback(param); + return obj[key](param); + }; + } + + // if they try to access something different from what is in `tracked_search_params_properties` + // we track the whole url (entries, values, keys etc) + callback(); + + const value = Reflect.get(obj, key); + return typeof value === 'function' ? value.bind(obj) : value; + } + }), + enumerable: true, + configurable: true + }); + + for (const property of tracked_url_properties) { + Object.defineProperty(tracked, property, { + get() { + callback(); + return url[property]; + }, + + enumerable: true, + configurable: true + }); + } + + if (!BROWSER) { + // @ts-ignore + tracked[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => { + return inspect(url, opts); + }; + } + + disable_hash(tracked); + + return tracked; +} + +/** + * Disallow access to `url.hash` on the server and in `load` + * @param {URL} url + */ +export function disable_hash(url) { + allow_nodejs_console_log(url); + + Object.defineProperty(url, 'hash', { + get() { + throw new Error( + 'Cannot access event.url.hash. Consider using `$page.url.hash` inside a component instead' + ); + } + }); +} + +/** + * Disallow access to `url.search` and `url.searchParams` during prerendering + * @param {URL} url + */ +export function disable_search(url) { + allow_nodejs_console_log(url); + + for (const property of ['search', 'searchParams']) { + Object.defineProperty(url, property, { + get() { + throw new Error(`Cannot access url.${property} on a page with prerendering enabled`); + } + }); + } +} + +/** + * Allow URL to be console logged, bypassing disabled properties. + * @param {URL} url + */ +function allow_nodejs_console_log(url) { + if (!BROWSER) { + // @ts-ignore + url[Symbol.for('nodejs.util.inspect.custom')] = (depth, opts, inspect) => { + return inspect(new URL(url), opts); + }; + } +} + +const DATA_SUFFIX = '/__data.json'; +const HTML_DATA_SUFFIX = '.html__data.json'; + +/** @param {string} pathname */ +export function has_data_suffix(pathname) { + return pathname.endsWith(DATA_SUFFIX) || pathname.endsWith(HTML_DATA_SUFFIX); +} + +/** @param {string} pathname */ +export function add_data_suffix(pathname) { + if (pathname.endsWith('.html')) return pathname.replace(/\.html$/, HTML_DATA_SUFFIX); + return pathname.replace(/\/$/, '') + DATA_SUFFIX; +} + +/** @param {string} pathname */ +export function strip_data_suffix(pathname) { + if (pathname.endsWith(HTML_DATA_SUFFIX)) { + return pathname.slice(0, -HTML_DATA_SUFFIX.length) + '.html'; + } + + return pathname.slice(0, -DATA_SUFFIX.length); +} diff --git a/node_modules/@sveltejs/kit/src/version.js b/node_modules/@sveltejs/kit/src/version.js new file mode 100644 index 000000000..31e26aeef --- /dev/null +++ b/node_modules/@sveltejs/kit/src/version.js @@ -0,0 +1,4 @@ +// generated during release, do not modify + +/** @type {string} */ +export const VERSION = '2.0.6'; diff --git a/node_modules/@sveltejs/kit/svelte-kit.js b/node_modules/@sveltejs/kit/svelte-kit.js new file mode 100644 index 000000000..b48389f69 --- /dev/null +++ b/node_modules/@sveltejs/kit/svelte-kit.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +import './src/cli.js'; diff --git a/node_modules/@sveltejs/kit/types/index.d.ts b/node_modules/@sveltejs/kit/types/index.d.ts new file mode 100644 index 000000000..11f94fa85 --- /dev/null +++ b/node_modules/@sveltejs/kit/types/index.d.ts @@ -0,0 +1,2220 @@ +/// +/// + +declare module '@sveltejs/kit' { + import type { CompileOptions } from 'svelte/compiler'; + import type { PluginOptions } from '@sveltejs/vite-plugin-svelte'; + /** + * [Adapters](https://kit.svelte.dev/docs/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing. + */ + export interface Adapter { + /** + * The name of the adapter, using for logging. Will typically correspond to the package name. + */ + name: string; + /** + * This function is called after SvelteKit has built your app. + * @param builder An object provided by SvelteKit that contains methods for adapting the app + */ + adapt(builder: Builder): MaybePromise; + } + + export type LoadProperties | void> = input extends void + ? undefined // needs to be undefined, because void will break intellisense + : input extends Record + ? input + : unknown; + + export type AwaitedActions any>> = OptionalUnion< + { + [Key in keyof T]: UnpackValidationError>>; + }[keyof T] + >; + + // Takes a union type and returns a union type where each type also has all properties + // of all possible types (typed as undefined), making accessing them more ergonomic + type OptionalUnion< + U extends Record, // not unknown, else interfaces don't satisfy this constraint + A extends keyof U = U extends U ? keyof U : never + > = U extends unknown ? { [P in Exclude]?: never } & U : never; + + const uniqueSymbol: unique symbol; + + export interface ActionFailure | undefined = undefined> { + status: number; + data: T; + [uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure + } + + type UnpackValidationError = T extends ActionFailure + ? X + : T extends void + ? undefined // needs to be undefined, because void will corrupt union type + : T; + + /** + * This object is passed to the `adapt` function of adapters. + * It contains various methods and properties that are useful for adapting the app. + */ + export interface Builder { + /** Print messages to the console. `log.info` and `log.minor` are silent unless Vite's `logLevel` is `info`. */ + log: Logger; + /** Remove `dir` and all its contents. */ + rimraf(dir: string): void; + /** Create `dir` and any required parent directories. */ + mkdirp(dir: string): void; + + /** The fully resolved `svelte.config.js`. */ + config: ValidatedConfig; + /** Information about prerendered pages and assets, if any. */ + prerendered: Prerendered; + /** An array of all routes (including prerendered) */ + routes: RouteDefinition[]; + + /** + * Create separate functions that map to one or more routes of your app. + * @param fn A function that groups a set of routes into an entry point + * @deprecated Use `builder.routes` instead + */ + createEntries(fn: (route: RouteDefinition) => AdapterEntry): Promise; + + /** + * Generate a fallback page for a static webserver to use when no route is matched. Useful for single-page apps. + */ + generateFallback(dest: string): Promise; + + /** + * Generate a module exposing build-time environment variables as `$env/dynamic/public`. + */ + generateEnvModule(): void; + + /** + * Generate a server-side manifest to initialise the SvelteKit [server](https://kit.svelte.dev/docs/types#public-types-server) with. + * @param opts a relative path to the base directory of the app and optionally in which format (esm or cjs) the manifest should be generated + */ + generateManifest(opts: { relativePath: string; routes?: RouteDefinition[] }): string; + + /** + * Resolve a path to the `name` directory inside `outDir`, e.g. `/path/to/.svelte-kit/my-adapter`. + * @param name path to the file, relative to the build directory + */ + getBuildDirectory(name: string): string; + /** Get the fully resolved path to the directory containing client-side assets, including the contents of your `static` directory. */ + getClientDirectory(): string; + /** Get the fully resolved path to the directory containing server-side code. */ + getServerDirectory(): string; + /** Get the application path including any configured `base` path, e.g. `my-base-path/_app`. */ + getAppPath(): string; + + /** + * Write client assets to `dest`. + * @param dest the destination folder + * @returns an array of files written to `dest` + */ + writeClient(dest: string): string[]; + /** + * Write prerendered files to `dest`. + * @param dest the destination folder + * @returns an array of files written to `dest` + */ + writePrerendered(dest: string): string[]; + /** + * Write server-side code to `dest`. + * @param dest the destination folder + * @returns an array of files written to `dest` + */ + writeServer(dest: string): string[]; + /** + * Copy a file or directory. + * @param from the source file or directory + * @param to the destination file or directory + * @param opts.filter a function to determine whether a file or directory should be copied + * @param opts.replace a map of strings to replace + * @returns an array of files that were copied + */ + copy( + from: string, + to: string, + opts?: { + filter?(basename: string): boolean; + replace?: Record; + } + ): string[]; + + /** + * Compress files in `directory` with gzip and brotli, where appropriate. Generates `.gz` and `.br` files alongside the originals. + * @param directory The directory containing the files to be compressed + */ + compress(directory: string): Promise; + } + + export interface Config { + /** + * Options passed to [`svelte.compile`](https://svelte.dev/docs#compile-time-svelte-compile). + * @default {} + */ + compilerOptions?: CompileOptions; + /** + * List of file extensions that should be treated as Svelte files. + * @default [".svelte"] + */ + extensions?: string[]; + /** SvelteKit options */ + kit?: KitConfig; + /** [`@sveltejs/package`](/docs/packaging) options. */ + package?: { + source?: string; + dir?: string; + emitTypes?: boolean; + exports?(filepath: string): boolean; + files?(filepath: string): boolean; + }; + /** Preprocessor options, if any. Preprocessing can alternatively also be done through Vite's preprocessor capabilities. */ + preprocess?: any; + /** `vite-plugin-svelte` plugin options. */ + vitePlugin?: PluginOptions; + /** Any additional options required by tooling that integrates with Svelte. */ + [key: string]: any; + } + + export interface Cookies { + /** + * Gets a cookie that was previously set with `cookies.set`, or from the request headers. + * @param name the name of the cookie + * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options) + */ + get(name: string, opts?: import('cookie').CookieParseOptions): string | undefined; + + /** + * Gets all cookies that were previously set with `cookies.set`, or from the request headers. + * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options) + */ + getAll(opts?: import('cookie').CookieParseOptions): Array<{ name: string; value: string }>; + + /** + * Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` or `cookies.getAll` during the current request. + * + * The `httpOnly` and `secure` options are `true` by default (except on http://localhost, where `secure` is `false`), and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP. The `sameSite` option defaults to `lax`. + * + * You must specify a `path` for the cookie. In most cases you should explicitly set `path: '/'` to make the cookie available throughout your app. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children + * @param name the name of the cookie + * @param value the cookie value + * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) + */ + set( + name: string, + value: string, + opts: import('cookie').CookieSerializeOptions & { path: string } + ): void; + + /** + * Deletes a cookie by setting its value to an empty string and setting the expiry date in the past. + * + * You must specify a `path` for the cookie. In most cases you should explicitly set `path: '/'` to make the cookie available throughout your app. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children + * @param name the name of the cookie + * @param opts the options, passed directly to `cookie.serialize`. The `path` must match the path of the cookie you want to delete. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) + */ + delete(name: string, opts: import('cookie').CookieSerializeOptions & { path: string }): void; + + /** + * Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response. + * + * The `httpOnly` and `secure` options are `true` by default (except on http://localhost, where `secure` is `false`), and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP. The `sameSite` option defaults to `lax`. + * + * You must specify a `path` for the cookie. In most cases you should explicitly set `path: '/'` to make the cookie available throughout your app. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children + * + * @param name the name of the cookie + * @param value the cookie value + * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) + */ + serialize( + name: string, + value: string, + opts: import('cookie').CookieSerializeOptions & { path: string } + ): string; + } + + export interface KitConfig { + /** + * Your [adapter](https://kit.svelte.dev/docs/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms. + * @default undefined + */ + adapter?: Adapter; + /** + * An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript. + * + * ```js + * /// file: svelte.config.js + * /// type: import('@sveltejs/kit').Config + * const config = { + * kit: { + * alias: { + * // this will match a file + * 'my-file': 'path/to/my-file.js', + * + * // this will match a directory and its contents + * // (`my-directory/x` resolves to `path/to/my-directory/x`) + * 'my-directory': 'path/to/my-directory', + * + * // an alias ending /* will only match + * // the contents of a directory, not the directory itself + * 'my-directory/*': 'path/to/my-directory/*' + * } + * } + * }; + * ``` + * + * > The built-in `$lib` alias is controlled by `config.kit.files.lib` as it is used for packaging. + * + * > You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`. + * @default {} + */ + alias?: Record; + /** + * The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes. + * + * If `paths.assets` is specified, there will be two app directories — `${paths.assets}/${appDir}` and `${paths.base}/${appDir}`. + * @default "_app" + */ + appDir?: string; + /** + * [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) configuration. CSP helps to protect your users against cross-site scripting (XSS) attacks, by limiting the places resources can be loaded from. For example, a configuration like this... + * + * ```js + * /// file: svelte.config.js + * /// type: import('@sveltejs/kit').Config + * const config = { + * kit: { + * csp: { + * directives: { + * 'script-src': ['self'] + * }, + * reportOnly: { + * 'script-src': ['self'] + * } + * } + * } + * }; + * + * export default config; + * ``` + * + * ...would prevent scripts loading from external sites. SvelteKit will augment the specified directives with nonces or hashes (depending on `mode`) for any inline styles and scripts it generates. + * + * To add a nonce for scripts and links manually included in `src/app.html`, you may use the placeholder `%sveltekit.nonce%` (for example ` + * ``` + * + * If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](/docs/modules#$app-stores-updated) store to `true` when it detects one. + */ + version?: { + /** + * The current app version string. If specified, this must be deterministic (e.g. a commit ref rather than `Math.random()` or `Date.now().toString()`), otherwise defaults to a timestamp of the build. + * + * For example, to use the current commit hash, you could do use `git rev-parse HEAD`: + * + * ```js + * /// file: svelte.config.js + * import * as child_process from 'node:child_process'; + * + * export default { + * kit: { + * version: { + * name: child_process.execSync('git rev-parse HEAD').toString().trim() + * } + * } + * }; + * ``` + */ + name?: string; + /** + * The interval in milliseconds to poll for version changes. If this is `0`, no polling occurs. + * @default 0 + */ + pollInterval?: number; + }; + } + + /** + * The [`handle`](https://kit.svelte.dev/docs/hooks#server-hooks-handle) hook runs every time the SvelteKit server receives a [request](https://kit.svelte.dev/docs/web-standards#fetch-apis-request) and + * determines the [response](https://kit.svelte.dev/docs/web-standards#fetch-apis-response). + * It receives an `event` object representing the request and a function called `resolve`, which renders the route and generates a `Response`. + * This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example). + */ + export type Handle = (input: { + event: RequestEvent; + resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise; + }) => MaybePromise; + + /** + * The server-side [`handleError`](https://kit.svelte.dev/docs/hooks#shared-hooks-handleerror) hook runs when an unexpected error is thrown while responding to a request. + * + * If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event. + * Make sure that this function _never_ throws an error. + */ + export type HandleServerError = (input: { + error: unknown; + event: RequestEvent; + status: number; + message: string; + }) => MaybePromise; + + /** + * The client-side [`handleError`](https://kit.svelte.dev/docs/hooks#shared-hooks-handleerror) hook runs when an unexpected error is thrown while navigating. + * + * If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event. + * Make sure that this function _never_ throws an error. + */ + export type HandleClientError = (input: { + error: unknown; + event: NavigationEvent; + status: number; + message: string; + }) => MaybePromise; + + /** + * The [`handleFetch`](https://kit.svelte.dev/docs/hooks#server-hooks-handlefetch) hook allows you to modify (or replace) a `fetch` request that happens inside a `load` function that runs on the server (or during pre-rendering) + */ + export type HandleFetch = (input: { + event: RequestEvent; + request: Request; + fetch: typeof fetch; + }) => MaybePromise; + + /** + * The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types)) + * rather than using `Load` directly. + */ + export type Load< + Params extends Partial> = Partial>, + InputData extends Record | null = Record | null, + ParentData extends Record = Record, + OutputData extends Record | void = Record | void, + RouteId extends string | null = string | null + > = (event: LoadEvent) => MaybePromise; + + /** + * The generic form of `PageLoadEvent` and `LayoutLoadEvent`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types)) + * rather than using `LoadEvent` directly. + */ + export interface LoadEvent< + Params extends Partial> = Partial>, + Data extends Record | null = Record | null, + ParentData extends Record = Record, + RouteId extends string | null = string | null + > extends NavigationEvent { + /** + * `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features: + * + * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request. + * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context). + * - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call. + * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://kit.svelte.dev/docs/hooks#server-hooks-handle) + * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request. + * + * You can learn more about making credentialed requests with cookies [here](https://kit.svelte.dev/docs/load#cookies) + */ + fetch: typeof fetch; + /** + * Contains the data returned by the route's server `load` function (in `+layout.server.js` or `+page.server.js`), if any. + */ + data: Data; + /** + * If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example: + * + * ```js + * /// file: src/routes/blog/+page.js + * export async function load({ fetch, setHeaders }) { + * const url = `https://cms.example.com/articles.json`; + * const response = await fetch(url); + * + * setHeaders({ + * age: response.headers.get('age'), + * 'cache-control': response.headers.get('cache-control') + * }); + * + * return response.json(); + * } + * ``` + * + * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once. + * + * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://kit.svelte.dev/docs/types#public-types-cookies) API in a server-only `load` function instead. + * + * `setHeaders` has no effect when a `load` function runs in the browser. + */ + setHeaders(headers: Record): void; + /** + * `await parent()` returns data from parent `+layout.js` `load` functions. + * Implicitly, a missing `+layout.js` is treated as a `({ data }) => data` function, meaning that it will return and forward data from parent `+layout.server.js` files. + * + * Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data. + */ + parent(): Promise; + /** + * This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun. + * + * Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`. + * + * URLs can be absolute or relative to the page being loaded, and must be [encoded](https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding). + * + * Custom identifiers have to be prefixed with one or more lowercase letters followed by a colon to conform to the [URI specification](https://www.rfc-editor.org/rfc/rfc3986.html). + * + * The following example shows how to use `depends` to register a dependency on a custom identifier, which is `invalidate`d after a button click, making the `load` function rerun. + * + * ```js + * /// file: src/routes/+page.js + * let count = 0; + * export async function load({ depends }) { + * depends('increase:count'); + * + * return { count: count++ }; + * } + * ``` + * + * ```html + * /// file: src/routes/+page.svelte + * + * + *

{data.count}

+ * + * ``` + */ + depends(...deps: Array<`${string}:${string}`>): void; + /** + * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example: + * + * ```js + * /// file: src/routes/+page.server.js + * export async function load({ untrack, url }) { + * // Untrack url.pathname so that path changes don't trigger a rerun + * if (untrack(() => url.pathname === '/')) { + * return { message: 'Welcome!' }; + * } + * } + * ``` + */ + untrack(fn: () => T): T; + } + + export interface NavigationEvent< + Params extends Partial> = Partial>, + RouteId extends string | null = string | null + > { + /** + * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object + */ + params: Params; + /** + * Info about the current route + */ + route: { + /** + * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]` + */ + id: RouteId; + }; + /** + * The URL of the current page + */ + url: URL; + } + + /** + * Information about the target of a specific navigation. + */ + export interface NavigationTarget { + /** + * Parameters of the target page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object. + * Is `null` if the target is not part of the SvelteKit app (could not be resolved to a route). + */ + params: Record | null; + /** + * Info about the target route + */ + route: { id: string | null }; + /** + * The URL that is navigated to + */ + url: URL; + } + + /** + * - `enter`: The app has hydrated + * - `form`: The user submitted a `` with a GET method + * - `leave`: The user is leaving the app by closing the tab or using the back/forward buttons to go to a different document + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ + export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate'; + + export interface Navigation { + /** + * Where navigation was triggered from + */ + from: NavigationTarget | null; + /** + * Where navigation is going to/has gone to + */ + to: NavigationTarget | null; + /** + * The type of navigation: + * - `form`: The user submitted a `` + * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ + type: Exclude; + /** + * Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation) + */ + willUnload: boolean; + /** + * In case of a history back/forward navigation, the number of steps to go back/forward + */ + delta?: number; + /** + * A promise that resolves once the navigation is complete, and rejects if the navigation + * fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve + */ + complete: Promise; + } + + /** + * The argument passed to [`beforeNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-beforenavigate) callbacks. + */ + export interface BeforeNavigate extends Navigation { + /** + * Call this to prevent the navigation from starting. + */ + cancel(): void; + } + + /** + * The argument passed to [`onNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-onnavigate) callbacks. + */ + export interface OnNavigate extends Navigation { + /** + * The type of navigation: + * - `form`: The user submitted a `` + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ + type: Exclude; + /** + * Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page. + */ + willUnload: false; + } + + /** + * The argument passed to [`afterNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-afternavigate) callbacks. + */ + export interface AfterNavigate extends Omit { + /** + * The type of navigation: + * - `enter`: The app has hydrated + * - `form`: The user submitted a `` + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ + type: Exclude; + /** + * Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page. + */ + willUnload: false; + } + + /** + * The shape of the `$page` store + */ + export interface Page< + Params extends Record = Record, + RouteId extends string | null = string | null + > { + /** + * The URL of the current page + */ + url: URL; + /** + * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object + */ + params: Params; + /** + * Info about the current route + */ + route: { + /** + * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]` + */ + id: RouteId; + }; + /** + * Http status code of the current page + */ + status: number; + /** + * The error object of the current page, if any. Filled from the `handleError` hooks. + */ + error: App.Error | null; + /** + * The merged result of all data from all `load` functions on the current page. You can type a common denominator through `App.PageData`. + */ + data: App.PageData & Record; + /** + * The page state, which can be manipulated using the [`pushState`](https://kit.svelte.dev/docs/modules#$app-navigation-pushstate) and [`replaceState`](https://kit.svelte.dev/docs/modules#$app-navigation-replacestate) functions from `$app/navigation`. + */ + state: App.PageState; + /** + * Filled only after a form submission. See [form actions](https://kit.svelte.dev/docs/form-actions) for more info. + */ + form: any; + } + + /** + * The shape of a param matcher. See [matching](https://kit.svelte.dev/docs/advanced-routing#matching) for more info. + */ + export type ParamMatcher = (param: string) => boolean; + + export interface RequestEvent< + Params extends Partial> = Partial>, + RouteId extends string | null = string | null + > { + /** + * Get or set cookies related to the current request + */ + cookies: Cookies; + /** + * `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features: + * + * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request. + * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context). + * - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call. + * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://kit.svelte.dev/docs/hooks#server-hooks-handle) + * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request. + * + * You can learn more about making credentialed requests with cookies [here](https://kit.svelte.dev/docs/load#cookies) + */ + fetch: typeof fetch; + /** + * The client's IP address, set by the adapter. + */ + getClientAddress(): string; + /** + * Contains custom data that was added to the request within the [`handle hook`](https://kit.svelte.dev/docs/hooks#server-hooks-handle). + */ + locals: App.Locals; + /** + * The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object + */ + params: Params; + /** + * Additional data made available through the adapter. + */ + platform: Readonly | undefined; + /** + * The original request object + */ + request: Request; + /** + * Info about the current route + */ + route: { + /** + * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]` + */ + id: RouteId; + }; + /** + * If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example: + * + * ```js + * /// file: src/routes/blog/+page.js + * export async function load({ fetch, setHeaders }) { + * const url = `https://cms.example.com/articles.json`; + * const response = await fetch(url); + * + * setHeaders({ + * age: response.headers.get('age'), + * 'cache-control': response.headers.get('cache-control') + * }); + * + * return response.json(); + * } + * ``` + * + * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once. + * + * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://kit.svelte.dev/docs/types#public-types-cookies) API instead. + */ + setHeaders(headers: Record): void; + /** + * The requested URL. + */ + url: URL; + /** + * `true` if the request comes from the client asking for `+page/layout.server.js` data. The `url` property will be stripped of the internal information + * related to the data request in this case. Use this property instead if the distinction is important to you. + */ + isDataRequest: boolean; + /** + * `true` for `+server.js` calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin `fetch` requests on the server. + */ + isSubRequest: boolean; + } + + /** + * A `(event: RequestEvent) => Response` function exported from a `+server.js` file that corresponds to an HTTP verb (`GET`, `PUT`, `PATCH`, etc) and handles requests with that method. + * + * It receives `Params` as the first generic argument, which you can skip by using [generated types](https://kit.svelte.dev/docs/types#generated-types) instead. + */ + export type RequestHandler< + Params extends Partial> = Partial>, + RouteId extends string | null = string | null + > = (event: RequestEvent) => MaybePromise; + + export interface ResolveOptions { + /** + * Applies custom transforms to HTML. If `done` is true, it's the final chunk. Chunks are not guaranteed to be well-formed HTML + * (they could include an element's opening tag but not its closing tag, for example) + * but they will always be split at sensible boundaries such as `%sveltekit.head%` or layout/page components. + * @param input the html chunk and the info if this is the last chunk + */ + transformPageChunk?(input: { html: string; done: boolean }): MaybePromise; + /** + * Determines which headers should be included in serialized responses when a `load` function loads a resource with `fetch`. + * By default, none will be included. + * @param name header name + * @param value header value + */ + filterSerializedResponseHeaders?(name: string, value: string): boolean; + /** + * Determines what should be added to the `` tag to preload it. + * By default, `js` and `css` files will be preloaded. + * @param input the type of the file and its path + */ + preload?(input: { type: 'font' | 'css' | 'js' | 'asset'; path: string }): boolean; + } + + export interface RouteDefinition { + id: string; + api: { + methods: Array; + }; + page: { + methods: Array>; + }; + pattern: RegExp; + prerender: PrerenderOption; + segments: RouteSegment[]; + methods: Array; + config: Config; + } + + export class Server { + constructor(manifest: SSRManifest); + init(options: ServerInitOptions): Promise; + respond(request: Request, options: RequestOptions): Promise; + } + + export interface ServerInitOptions { + env: Record; + } + + export interface SSRManifest { + appDir: string; + appPath: string; + assets: Set; + mimeTypes: Record; + + /** private fields */ + _: { + client: NonNullable; + nodes: SSRNodeLoader[]; + routes: SSRRoute[]; + matchers(): Promise>; + }; + } + + /** + * The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types)) + * rather than using `ServerLoad` directly. + */ + export type ServerLoad< + Params extends Partial> = Partial>, + ParentData extends Record = Record, + OutputData extends Record | void = Record | void, + RouteId extends string | null = string | null + > = (event: ServerLoadEvent) => MaybePromise; + + export interface ServerLoadEvent< + Params extends Partial> = Partial>, + ParentData extends Record = Record, + RouteId extends string | null = string | null + > extends RequestEvent { + /** + * `await parent()` returns data from parent `+layout.server.js` `load` functions. + * + * Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data. + */ + parent(): Promise; + /** + * This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](/docs/modules#$app-navigation-invalidate) to cause `load` to rerun. + * + * Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`. + * + * URLs can be absolute or relative to the page being loaded, and must be [encoded](https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding). + * + * Custom identifiers have to be prefixed with one or more lowercase letters followed by a colon to conform to the [URI specification](https://www.rfc-editor.org/rfc/rfc3986.html). + * + * The following example shows how to use `depends` to register a dependency on a custom identifier, which is `invalidate`d after a button click, making the `load` function rerun. + * + * ```js + * /// file: src/routes/+page.js + * let count = 0; + * export async function load({ depends }) { + * depends('increase:count'); + * + * return { count: count++ }; + * } + * ``` + * + * ```html + * /// file: src/routes/+page.svelte + * + * + *

{data.count}

+ * + * ``` + */ + depends(...deps: string[]): void; + /** + * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example: + * + * ```js + * /// file: src/routes/+page.js + * export async function load({ untrack, url }) { + * // Untrack url.pathname so that path changes don't trigger a rerun + * if (untrack(() => url.pathname === '/')) { + * return { message: 'Welcome!' }; + * } + * } + * ``` + */ + untrack(fn: () => T): T; + } + + /** + * Shape of a form action method that is part of `export const actions = {..}` in `+page.server.js`. + * See [form actions](https://kit.svelte.dev/docs/form-actions) for more information. + */ + export type Action< + Params extends Partial> = Partial>, + OutputData extends Record | void = Record | void, + RouteId extends string | null = string | null + > = (event: RequestEvent) => MaybePromise; + + /** + * Shape of the `export const actions = {..}` object in `+page.server.js`. + * See [form actions](https://kit.svelte.dev/docs/form-actions) for more information. + */ + export type Actions< + Params extends Partial> = Partial>, + OutputData extends Record | void = Record | void, + RouteId extends string | null = string | null + > = Record>; + + /** + * When calling a form action via fetch, the response will be one of these shapes. + * ```svelte + * { + * return ({ result }) => { + * // result is of type ActionResult + * }; + * }} + * ``` + */ + export type ActionResult< + Success extends Record | undefined = Record, + Failure extends Record | undefined = Record + > = + | { type: 'success'; status: number; data?: Success } + | { type: 'failure'; status: number; data?: Failure } + | { type: 'redirect'; status: number; location: string } + | { type: 'error'; status?: number; error: any }; + + /** + * The object returned by the [`error`](https://kit.svelte.dev/docs/modules#sveltejs-kit-error) function. + */ + export interface HttpError { + /** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses), in the range 400-599. */ + status: number; + /** The content of the error. */ + body: App.Error; + } + + /** + * The object returned by the [`redirect`](https://kit.svelte.dev/docs/modules#sveltejs-kit-redirect) function + */ + export interface Redirect { + /** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages), in the range 300-308. */ + status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308; + /** The location to redirect to. */ + location: string; + } + + export type SubmitFunction< + Success extends Record | undefined = Record, + Failure extends Record | undefined = Record + > = (input: { + action: URL; + formData: FormData; + formElement: HTMLFormElement; + controller: AbortController; + submitter: HTMLElement | null; + cancel(): void; + }) => MaybePromise< + | void + | ((opts: { + formData: FormData; + formElement: HTMLFormElement; + action: URL; + result: ActionResult; + /** + * Call this to get the default behavior of a form submission response. + * @param options Set `reset: false` if you don't want the `` values to be reset after a successful submission. + * @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission. + */ + update(options?: { reset?: boolean; invalidateAll?: boolean }): Promise; + }) => void) + >; + + /** + * The type of `export const snapshot` exported from a page or layout component. + */ + export interface Snapshot { + capture: () => T; + restore: (snapshot: T) => void; + } + interface AdapterEntry { + /** + * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication. + * For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both + * be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID + */ + id: string; + + /** + * A function that compares the candidate route with the current route to determine + * if it should be grouped with the current route. + * + * Use cases: + * - Fallback pages: `/foo/[c]` is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes + * - Grouping routes that share a common `config`: `/foo` should be deployed to the edge, `/bar` and `/baz` should be deployed to a serverless function + */ + filter(route: RouteDefinition): boolean; + + /** + * A function that is invoked once the entry has been created. This is where you + * should write the function to the filesystem and generate redirect manifests. + */ + complete(entry: { generateManifest(opts: { relativePath: string }): string }): MaybePromise; + } + + // Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts + // + // MIT License + // + // Copyright (c) 2021-present, Joshua Hemphill + // Copyright (c) 2021, Tecnico Corporation + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files (the "Software"), to deal + // in the Software without restriction, including without limitation the rights + // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions: + // + // The above copyright notice and this permission notice shall be included in all + // copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + // SOFTWARE. + + namespace Csp { + type ActionSource = 'strict-dynamic' | 'report-sample'; + type BaseSource = + | 'self' + | 'unsafe-eval' + | 'unsafe-hashes' + | 'unsafe-inline' + | 'wasm-unsafe-eval' + | 'none'; + type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`; + type FrameSource = HostSource | SchemeSource | 'self' | 'none'; + type HostNameScheme = `${string}.${string}` | 'localhost'; + type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`; + type HostProtocolSchemes = `${string}://` | ''; + type HttpDelineator = '/' | '?' | '#' | '\\'; + type PortScheme = `:${number}` | '' | ':*'; + type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:'; + type Source = HostSource | SchemeSource | CryptoSource | BaseSource; + type Sources = Source[]; + type UriPath = `${HttpDelineator}${string}`; + } + + interface CspDirectives { + 'child-src'?: Csp.Sources; + 'default-src'?: Array; + 'frame-src'?: Csp.Sources; + 'worker-src'?: Csp.Sources; + 'connect-src'?: Csp.Sources; + 'font-src'?: Csp.Sources; + 'img-src'?: Csp.Sources; + 'manifest-src'?: Csp.Sources; + 'media-src'?: Csp.Sources; + 'object-src'?: Csp.Sources; + 'prefetch-src'?: Csp.Sources; + 'script-src'?: Array; + 'script-src-elem'?: Csp.Sources; + 'script-src-attr'?: Csp.Sources; + 'style-src'?: Array; + 'style-src-elem'?: Csp.Sources; + 'style-src-attr'?: Csp.Sources; + 'base-uri'?: Array; + sandbox?: Array< + | 'allow-downloads-without-user-activation' + | 'allow-forms' + | 'allow-modals' + | 'allow-orientation-lock' + | 'allow-pointer-lock' + | 'allow-popups' + | 'allow-popups-to-escape-sandbox' + | 'allow-presentation' + | 'allow-same-origin' + | 'allow-scripts' + | 'allow-storage-access-by-user-activation' + | 'allow-top-navigation' + | 'allow-top-navigation-by-user-activation' + >; + 'form-action'?: Array; + 'frame-ancestors'?: Array; + 'navigate-to'?: Array; + 'report-uri'?: Csp.UriPath[]; + 'report-to'?: string[]; + + 'require-trusted-types-for'?: Array<'script'>; + 'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>; + 'upgrade-insecure-requests'?: boolean; + + /** @deprecated */ + 'require-sri-for'?: Array<'script' | 'style' | 'script style'>; + + /** @deprecated */ + 'block-all-mixed-content'?: boolean; + + /** @deprecated */ + 'plugin-types'?: Array<`${string}/${string}` | 'none'>; + + /** @deprecated */ + referrer?: Array< + | 'no-referrer' + | 'no-referrer-when-downgrade' + | 'origin' + | 'origin-when-cross-origin' + | 'same-origin' + | 'strict-origin' + | 'strict-origin-when-cross-origin' + | 'unsafe-url' + | 'none' + >; + } + + type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS'; + + interface Logger { + (msg: string): void; + success(msg: string): void; + error(msg: string): void; + warn(msg: string): void; + minor(msg: string): void; + info(msg: string): void; + } + + type MaybePromise = T | Promise; + + interface Prerendered { + /** + * A map of `path` to `{ file }` objects, where a path like `/foo` corresponds to `foo.html` and a path like `/bar/` corresponds to `bar/index.html`. + */ + pages: Map< + string, + { + /** The location of the .html file relative to the output directory */ + file: string; + } + >; + /** + * A map of `path` to `{ type }` objects. + */ + assets: Map< + string, + { + /** The MIME type of the asset */ + type: string; + } + >; + /** + * A map of redirects encountered during prerendering. + */ + redirects: Map< + string, + { + status: number; + location: string; + } + >; + /** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */ + paths: string[]; + } + + interface PrerenderHttpErrorHandler { + (details: { + status: number; + path: string; + referrer: string | null; + referenceType: 'linked' | 'fetched'; + message: string; + }): void; + } + + interface PrerenderMissingIdHandler { + (details: { path: string; id: string; referrers: string[]; message: string }): void; + } + + interface PrerenderEntryGeneratorMismatchHandler { + (details: { generatedFromId: string; entry: string; matchedId: string; message: string }): void; + } + + type PrerenderHttpErrorHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderHttpErrorHandler; + type PrerenderMissingIdHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderMissingIdHandler; + type PrerenderEntryGeneratorMismatchHandlerValue = + | 'fail' + | 'warn' + | 'ignore' + | PrerenderEntryGeneratorMismatchHandler; + + export type PrerenderOption = boolean | 'auto'; + + interface RequestOptions { + getClientAddress(): string; + platform?: App.Platform; + } + + interface RouteSegment { + content: string; + dynamic: boolean; + rest: boolean; + } + + type TrailingSlash = 'never' | 'always' | 'ignore'; + interface Asset { + file: string; + size: number; + type: string | null; + } + + interface BuildData { + app_dir: string; + app_path: string; + manifest_data: ManifestData; + service_worker: string | null; + client: { + start: string; + app: string; + imports: string[]; + stylesheets: string[]; + fonts: string[]; + uses_env_dynamic_public: boolean; + } | null; + server_manifest: import('vite').Manifest; + } + + interface ManifestData { + assets: Asset[]; + nodes: PageNode[]; + routes: RouteData[]; + matchers: Record; + } + + interface PageNode { + depth: number; + component?: string; // TODO supply default component if it's missing (bit of an edge case) + universal?: string; + server?: string; + parent_id?: string; + parent?: PageNode; + /** + * Filled with the pages that reference this layout (if this is a layout) + */ + child_pages?: PageNode[]; + } + + type RecursiveRequired = { + // Recursive implementation of TypeScript's Required utility type. + // Will recursively continue until it reaches a primitive or Function + [K in keyof T]-?: Extract extends never // If it does not have a Function type + ? RecursiveRequired // recursively continue through. + : T[K]; // Use the exact type for everything else + }; + + interface RouteParam { + name: string; + matcher: string; + optional: boolean; + rest: boolean; + chained: boolean; + } + + /** + * Represents a route segment in the app. It can either be an intermediate node + * with only layout/error pages, or a leaf, at which point either `page` and `leaf` + * or `endpoint` is set. + */ + interface RouteData { + id: string; + parent: RouteData | null; + + segment: string; + pattern: RegExp; + params: RouteParam[]; + + layout: PageNode | null; + error: PageNode | null; + leaf: PageNode | null; + + page: { + layouts: Array; + errors: Array; + leaf: number; + } | null; + + endpoint: { + file: string; + } | null; + } + + interface SSRComponent { + default: { + render(props: Record): { + html: string; + head: string; + css: { + code: string; + map: any; // TODO + }; + }; + }; + } + + type SSRComponentLoader = () => Promise; + + interface SSRNode { + component: SSRComponentLoader; + /** index into the `components` array in client/manifest.js */ + index: number; + /** external JS files */ + imports: string[]; + /** external CSS files */ + stylesheets: string[]; + /** external font files */ + fonts: string[]; + /** inlined styles */ + inline_styles?(): MaybePromise>; + + universal: { + load?: Load; + prerender?: PrerenderOption; + ssr?: boolean; + csr?: boolean; + trailingSlash?: TrailingSlash; + config?: any; + entries?: PrerenderEntryGenerator; + }; + + server: { + load?: ServerLoad; + prerender?: PrerenderOption; + ssr?: boolean; + csr?: boolean; + trailingSlash?: TrailingSlash; + actions?: Actions; + config?: any; + entries?: PrerenderEntryGenerator; + }; + + universal_id: string; + server_id: string; + } + + type SSRNodeLoader = () => Promise; + + interface PageNodeIndexes { + errors: Array; + layouts: Array; + leaf: number; + } + + type PrerenderEntryGenerator = () => MaybePromise>>; + + type SSREndpoint = Partial> & { + prerender?: PrerenderOption; + trailingSlash?: TrailingSlash; + config?: any; + entries?: PrerenderEntryGenerator; + fallback?: RequestHandler; + }; + + interface SSRRoute { + id: string; + pattern: RegExp; + params: RouteParam[]; + page: PageNodeIndexes | null; + endpoint: (() => Promise) | null; + endpoint_id?: string; + } + + type ValidatedConfig = RecursiveRequired; + /** + * Throws an error with a HTTP status code and an optional message. + * When called during request handling, this will cause SvelteKit to + * return an error response without invoking `handleError`. + * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it. + * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * @param body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property. + * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling. + * @throws {Error} If the provided status is invalid (not between 400 and 599). + */ + export function error(status: NumericRange<400, 599>, body: App.Error): never; + /** + * Throws an error with a HTTP status code and an optional message. + * When called during request handling, this will cause SvelteKit to + * return an error response without invoking `handleError`. + * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it. + * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * @param body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property. + * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling. + * @throws {Error} If the provided status is invalid (not between 400 and 599). + */ + export function error(status: NumericRange<400, 599>, body?: { + message: string; + } extends App.Error ? App.Error | string | undefined : never): never; + /** + * Checks whether this is an error thrown by {@link error}. + * @param status The status to filter for. + * */ + export function isHttpError(e: unknown, status?: T | undefined): e is HttpError_1 & { + status: T extends undefined ? never : T; + }; + /** + * Redirect a request. When called during request handling, SvelteKit will return a redirect response. + * Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it. + * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308. + * @param location The location to redirect to. + * @throws {Redirect} This error instructs SvelteKit to redirect to the specified location. + * @throws {Error} If the provided status is invalid. + * */ + export function redirect(status: NumericRange<300, 308>, location: string | URL): never; + /** + * Checks whether this is a redirect thrown by {@link redirect}. + * @param e The object to check. + * */ + export function isRedirect(e: unknown): e is Redirect_1; + /** + * Create a JSON `Response` object from the supplied data. + * @param data The value that will be serialized as JSON. + * @param init Options such as `status` and `headers` that will be added to the response. `Content-Type: application/json` and `Content-Length` headers will be added automatically. + */ + export function json(data: any, init?: ResponseInit | undefined): Response; + /** + * Create a `Response` object from the supplied body. + * @param body The value that will be used as-is. + * @param init Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically. + */ + export function text(body: string, init?: ResponseInit | undefined): Response; + /** + * Create an `ActionFailure` object. + * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * */ + export function fail(status: number): ActionFailure; + /** + * Create an `ActionFailure` object. + * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * @param data Data associated with the failure (e.g. validation errors) + * */ + export function fail | undefined = undefined>(status: number, data: T): ActionFailure; + export type LessThan = TNumber extends TArray['length'] ? TArray[number] : LessThan; + export type NumericRange = Exclude, LessThan>; + export const VERSION: string; + class HttpError_1 { + + constructor(status: number, body: { + message: string; + } extends App.Error ? (App.Error | string | undefined) : App.Error); + status: number; + body: App.Error; + toString(): string; + } + class Redirect_1 { + + constructor(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308, location: string); + status: 301 | 302 | 303 | 307 | 308 | 300 | 304 | 305 | 306; + location: string; + } +} + +declare module '@sveltejs/kit/hooks' { + /** + * A helper function for sequencing multiple `handle` calls in a middleware-like manner. + * The behavior for the `handle` options is as follows: + * - `transformPageChunk` is applied in reverse order and merged + * - `preload` is applied in forward order, the first option "wins" and no `preload` options after it are called + * - `filterSerializedResponseHeaders` behaves the same as `preload` + * + * ```js + * /// file: src/hooks.server.js + * import { sequence } from '@sveltejs/kit/hooks'; + * + * /// type: import('@sveltejs/kit').Handle + * async function first({ event, resolve }) { + * console.log('first pre-processing'); + * const result = await resolve(event, { + * transformPageChunk: ({ html }) => { + * // transforms are applied in reverse order + * console.log('first transform'); + * return html; + * }, + * preload: () => { + * // this one wins as it's the first defined in the chain + * console.log('first preload'); + * } + * }); + * console.log('first post-processing'); + * return result; + * } + * + * /// type: import('@sveltejs/kit').Handle + * async function second({ event, resolve }) { + * console.log('second pre-processing'); + * const result = await resolve(event, { + * transformPageChunk: ({ html }) => { + * console.log('second transform'); + * return html; + * }, + * preload: () => { + * console.log('second preload'); + * }, + * filterSerializedResponseHeaders: () => { + * // this one wins as it's the first defined in the chain + * console.log('second filterSerializedResponseHeaders'); + * } + * }); + * console.log('second post-processing'); + * return result; + * } + * + * export const handle = sequence(first, second); + * ``` + * + * The example above would print: + * + * ``` + * first pre-processing + * first preload + * second pre-processing + * second filterSerializedResponseHeaders + * second transform + * first transform + * second post-processing + * first post-processing + * ``` + * + * @param handlers The chain of `handle` functions + * */ + export function sequence(...handlers: import('@sveltejs/kit').Handle[]): import('@sveltejs/kit').Handle; +} + +declare module '@sveltejs/kit/node' { + export function getRequest({ request, base, bodySizeLimit }: { + request: import('http').IncomingMessage; + base: string; + bodySizeLimit?: number; + }): Promise; + + export function setResponse(res: import('http').ServerResponse, response: Response): Promise; +} + +declare module '@sveltejs/kit/node/polyfills' { + /** + * Make various web APIs available as globals: + * - `crypto` + * - `File` + */ + export function installPolyfills(): void; +} + +declare module '@sveltejs/kit/vite' { + /** + * Returns the SvelteKit Vite plugins. + * */ + export function sveltekit(): Promise; +} + +declare module '$app/environment' { + export { building, version } from '__sveltekit/environment'; + /** + * `true` if the app is running in the browser. + */ + export const browser: boolean; + /** + * Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`. + */ + export const dev: boolean; +} + +declare module '$app/forms' { + /** + * This action updates the `form` property of the current page with the given data and updates `$page.status`. + * In case of an error, it redirects to the nearest error page. + * */ + export function applyAction | undefined, Failure extends Record | undefined>(result: import("@sveltejs/kit").ActionResult): Promise; + /** + * Use this function to deserialize the response from a form submission. + * Usage: + * + * ```js + * import { deserialize } from '$app/forms'; + * + * async function handleSubmit(event) { + * const response = await fetch('/form?/action', { + * method: 'POST', + * body: new FormData(event.target) + * }); + * + * const result = deserialize(await response.text()); + * // ... + * } + * ``` + * */ + export function deserialize | undefined, Failure extends Record | undefined>(result: string): import("@sveltejs/kit").ActionResult; + /** + * This action enhances a `` element that otherwise would work without JavaScript. + * + * The `submit` function is called upon submission with the given FormData and the `action` that should be triggered. + * If `cancel` is called, the form will not be submitted. + * You can use the abort `controller` to cancel the submission in case another one starts. + * If a function is returned, that function is called with the response from the server. + * If nothing is returned, the fallback will be used. + * + * If this function or its return value isn't set, it + * - falls back to updating the `form` prop with the returned data if the action is one same page as the form + * - updates `$page.status` + * - resets the `` element and invalidates all data in case of successful submission with no redirect response + * - redirects in case of a redirect response + * - redirects to the nearest error page in case of an unexpected error + * + * If you provide a custom function with a callback and want to use the default behavior, invoke `update` in your callback. + * @param form_element The form element + * @param submit Submit callback + */ + export function enhance | undefined, Failure extends Record | undefined>(form_element: HTMLFormElement, submit?: import("@sveltejs/kit").SubmitFunction): { + destroy(): void; + }; +} + +declare module '$app/navigation' { + /** + * If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling. + * This is generally discouraged, since it breaks user expectations. + * */ + export const disableScrollHandling: () => void; + /** + * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`. + * For external URLs, use `window.location = url` instead of calling `goto(url)`. + * + * @param url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://kit.svelte.dev/docs/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app. + * @param {Object} opts Options related to the navigation + * */ + export const goto: (url: string | URL, opts?: { + replaceState?: boolean; + noScroll?: boolean; + keepFocus?: boolean; + invalidateAll?: boolean; + state?: App.PageState; + }) => Promise; + /** + * Causes any `load` functions belonging to the currently active page to re-run if they depend on the `url` in question, via `fetch` or `depends`. Returns a `Promise` that resolves when the page is subsequently updated. + * + * If the argument is given as a `string` or `URL`, it must resolve to the same URL that was passed to `fetch` or `depends` (including query parameters). + * To create a custom identifier, use a string beginning with `[a-z]+:` (e.g. `custom:state`) — this is a valid URL. + * + * The `function` argument can be used define a custom predicate. It receives the full `URL` and causes `load` to rerun if `true` is returned. + * This can be useful if you want to invalidate based on a pattern instead of a exact match. + * + * ```ts + * // Example: Match '/path' regardless of the query parameters + * import { invalidate } from '$app/navigation'; + * + * invalidate((url) => url.pathname === '/path'); + * ``` + * @param url The invalidated URL + * */ + export const invalidate: (url: string | URL | ((url: URL) => boolean)) => Promise; + /** + * Causes all `load` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated. + * */ + export const invalidateAll: () => Promise; + /** + * Programmatically preloads the given page, which means + * 1. ensuring that the code for the page is loaded, and + * 2. calling the page's load function with the appropriate options. + * + * This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `` element with `data-sveltekit-preload-data`. + * If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous. + * Returns a Promise that resolves with the result of running the new route's `load` functions once the preload is complete. + * + * @param href Page to preload + * */ + export const preloadData: (href: string) => Promise>; + /** + * Programmatically imports the code for routes that haven't yet been fetched. + * Typically, you might call this to speed up subsequent navigation. + * + * You can specify routes by any matching pathname such as `/about` (to match `src/routes/about/+page.svelte`) or `/blog/*` (to match `src/routes/blog/[slug]/+page.svelte`). + * + * Unlike `preloadData`, this won't call `load` functions. + * Returns a Promise that resolves when the modules have been imported. + * + * */ + export const preloadCode: (url: string) => Promise; + /** + * A navigation interceptor that triggers before we navigate to a new URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls. + * + * Calling `cancel()` will prevent the navigation from completing. If `navigation.type === 'leave'` — meaning the user is navigating away from the app (or closing the tab) — calling `cancel` will trigger the native browser unload confirmation dialog. In this case, the navigation may or may not be cancelled depending on the user's response. + * + * When a navigation isn't to a SvelteKit-owned route (and therefore controlled by SvelteKit's client-side router), `navigation.to.route.id` will be `null`. + * + * If the navigation will (if not cancelled) cause the document to unload — in other words `'leave'` navigations and `'link'` navigations where `navigation.to.route === null` — `navigation.willUnload` is `true`. + * + * `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted. + * */ + export const beforeNavigate: (callback: (navigation: import('@sveltejs/kit').BeforeNavigate) => void) => void; + /** + * A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations. + * + * If you return a `Promise`, SvelteKit will wait for it to resolve before completing the navigation. This allows you to — for example — use `document.startViewTransition`. Avoid promises that are slow to resolve, since navigation will appear stalled to the user. + * + * If a function (or a `Promise` that resolves to a function) is returned from the callback, it will be called once the DOM has updated. + * + * `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted. + * */ + export const onNavigate: (callback: (navigation: import('@sveltejs/kit').OnNavigate) => MaybePromise<(() => void) | void>) => void; + /** + * A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a new URL. + * + * `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted. + * */ + export const afterNavigate: (callback: (navigation: import('@sveltejs/kit').AfterNavigate) => void) => void; + /** + * Programmatically create a new history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://kit.svelte.dev/docs/shallow-routing). + * + * */ + export const pushState: (url: string | URL, state: App.PageState) => void; + /** + * Programmatically replace the current history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://kit.svelte.dev/docs/shallow-routing). + * + * */ + export const replaceState: (url: string | URL, state: App.PageState) => void; + type MaybePromise = T | Promise; +} + +declare module '$app/paths' { + export { base, assets } from '__sveltekit/paths'; + /** + * Populate a route ID with params to resolve a pathname. + * @example + * ```js + * resolveRoute( + * `/blog/[slug]/[...somethingElse]`, + * { + * slug: 'hello-world', + * somethingElse: 'something/else' + * } + * ); // `/blog/hello-world/something/else` + * ``` + * */ + export function resolveRoute(id: string, params: Record): string; +} + +declare module '$app/stores' { + export function getStores(): { + + page: typeof page; + + navigating: typeof navigating; + + updated: typeof updated; + }; + /** + * A readable store whose value contains page data. + * + * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time. + * + * */ + export const page: import('svelte/store').Readable; + /** + * A readable store. + * When navigating starts, its value is a `Navigation` object with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties. + * When navigating finishes, its value reverts to `null`. + * + * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time. + * */ + export const navigating: import('svelte/store').Readable; + /** + * A readable store whose initial value is `false`. If [`version.pollInterval`](https://kit.svelte.dev/docs/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling. + * + * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time. + * */ + export const updated: import('svelte/store').Readable & { + check(): Promise; + }; +}/** + * It's possible to tell SvelteKit how to type objects inside your app by declaring the `App` namespace. By default, a new project will have a file called `src/app.d.ts` containing the following: + * + * ```ts + * declare global { + * namespace App { + * // interface Error {} + * // interface Locals {} + * // interface PageData {} + * // interface PageState {} + * // interface Platform {} + * } + * } + * + * export {}; + * ``` + * + * The `export {}` line exists because without it, the file would be treated as an _ambient module_ which prevents you from adding `import` declarations. + * If you need to add ambient `declare module` declarations, do so in a separate file like `src/ambient.d.ts`. + * + * By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions. + */ +declare namespace App { + /** + * Defines the common shape of expected and unexpected errors. Expected errors are thrown using the `error` function. Unexpected errors are handled by the `handleError` hooks which should return this shape. + */ + export interface Error { + message: string; + } + + /** + * The interface that defines `event.locals`, which can be accessed in [hooks](https://kit.svelte.dev/docs/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files. + */ + export interface Locals {} + + /** + * Defines the common shape of the [$page.data store](https://kit.svelte.dev/docs/modules#$app-stores-page) - that is, the data that is shared between all pages. + * The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly. + * Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`). + */ + export interface PageData {} + + /** + * The shape of the `$page.state` object, which can be manipulated using the [`pushState`](https://kit.svelte.dev/docs/modules#$app-navigation-pushstate) and [`replaceState`](https://kit.svelte.dev/docs/modules#$app-navigation-replacestate) functions from `$app/navigation`. + */ + export interface PageState {} + + /** + * If your adapter provides [platform-specific context](https://kit.svelte.dev/docs/adapters#platform-specific-context) via `event.platform`, you can specify it here. + */ + export interface Platform {} +} + +/** + * This module is only available to [service workers](https://kit.svelte.dev/docs/service-workers). + */ +declare module '$service-worker' { + /** + * The `base` path of the deployment. Typically this is equivalent to `config.kit.paths.base`, but it is calculated from `location.pathname` meaning that it will continue to work correctly if the site is deployed to a subdirectory. + * Note that there is a `base` but no `assets`, since service workers cannot be used if `config.kit.paths.assets` is specified. + */ + export const base: string; + /** + * An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`. + * During development, this is an empty array. + */ + export const build: string[]; + /** + * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://kit.svelte.dev/docs/configuration) + */ + export const files: string[]; + /** + * An array of pathnames corresponding to prerendered pages and endpoints. + * During development, this is an empty array. + */ + export const prerendered: string[]; + /** + * See [`config.kit.version`](https://kit.svelte.dev/docs/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches. + */ + export const version: string; +} + +/** Internal version of $app/environment */ +declare module '__sveltekit/environment' { + /** + * SvelteKit analyses your app during the `build` step by running it. During this process, `building` is `true`. This also applies during prerendering. + */ + export const building: boolean; + /** + * True during prerendering, false otherwise. + */ + export const prerendering: boolean; + /** + * The value of `config.kit.version.name`. + */ + export const version: string; + export function set_building(): void; + export function set_prerendering(): void; +} + +/** Internal version of $app/paths */ +declare module '__sveltekit/paths' { + /** + * A string that matches [`config.kit.paths.base`](https://kit.svelte.dev/docs/configuration#paths). + * + * Example usage: `Link` + */ + export let base: '' | `/${string}`; + /** + * An absolute path that matches [`config.kit.paths.assets`](https://kit.svelte.dev/docs/configuration#paths). + * + * > If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during `vite dev` or `vite preview`, since the assets don't yet live at their eventual URL. + */ + export let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit_assets'; + export let relative: boolean; + export function reset(): void; + export function override(paths: { base: string; assets: string }): void; + export function set_assets(path: string): void; +} + +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@sveltejs/kit/types/index.d.ts.map b/node_modules/@sveltejs/kit/types/index.d.ts.map new file mode 100644 index 000000000..4502c3ae4 --- /dev/null +++ b/node_modules/@sveltejs/kit/types/index.d.ts.map @@ -0,0 +1,147 @@ +{ + "version": 3, + "file": "index.d.ts", + "names": [ + "Adapter", + "LoadProperties", + "AwaitedActions", + "ActionFailure", + "Builder", + "Config", + "Cookies", + "KitConfig", + "Handle", + "HandleServerError", + "HandleClientError", + "HandleFetch", + "Load", + "LoadEvent", + "NavigationEvent", + "NavigationTarget", + "NavigationType", + "Navigation", + "BeforeNavigate", + "OnNavigate", + "AfterNavigate", + "Page", + "ParamMatcher", + "RequestEvent", + "RequestHandler", + "ResolveOptions", + "RouteDefinition", + "Server", + "ServerInitOptions", + "SSRManifest", + "ServerLoad", + "ServerLoadEvent", + "Action", + "Actions", + "ActionResult", + "HttpError", + "Redirect", + "SubmitFunction", + "Snapshot", + "AdapterEntry", + "Csp", + "CspDirectives", + "HttpMethod", + "Logger", + "MaybePromise", + "Prerendered", + "PrerenderHttpErrorHandler", + "PrerenderMissingIdHandler", + "PrerenderEntryGeneratorMismatchHandler", + "PrerenderHttpErrorHandlerValue", + "PrerenderMissingIdHandlerValue", + "PrerenderEntryGeneratorMismatchHandlerValue", + "PrerenderOption", + "RequestOptions", + "RouteSegment", + "TrailingSlash", + "Asset", + "BuildData", + "ManifestData", + "PageNode", + "RecursiveRequired", + "RouteParam", + "RouteData", + "SSRComponent", + "SSRComponentLoader", + "SSRNode", + "SSRNodeLoader", + "PageNodeIndexes", + "PrerenderEntryGenerator", + "SSREndpoint", + "SSRRoute", + "ValidatedConfig", + "isHttpError", + "redirect", + "isRedirect", + "json", + "text", + "LessThan", + "NumericRange", + "VERSION", + "sequence", + "getRequest", + "setResponse", + "installPolyfills", + "sveltekit", + "browser", + "dev", + "applyAction", + "deserialize", + "enhance", + "disableScrollHandling", + "goto", + "invalidate", + "invalidateAll", + "preloadData", + "preloadCode", + "beforeNavigate", + "onNavigate", + "afterNavigate", + "pushState", + "replaceState", + "resolveRoute", + "getStores", + "page", + "navigating", + "updated" + ], + "sources": [ + "../src/exports/public.d.ts", + "../src/runtime/control.js", + "../src/types/private.d.ts", + "../src/types/internal.d.ts", + "../src/exports/index.js", + "../src/version.js", + "../src/exports/hooks/sequence.js", + "../src/exports/node/index.js", + "../src/exports/node/polyfills.js", + "../src/exports/vite/index.js", + "../src/runtime/app/environment.js", + "../src/runtime/app/forms.js", + "../src/runtime/app/navigation.js", + "../src/runtime/app/paths.js", + "../src/runtime/app/stores.js" + ], + "sourcesContent": [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ], + "mappings": ";;;;;;;;;kBA2BiBA,OAAOA;;;;;;;;;;;;aAYZC,cAAcA;;;;;;aAMdC,cAAcA;;;;;;;;;;;;;;;kBAeTC,aAAaA;;;;;;;;;;;;;;;;kBAgBbC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA4FPC,MAAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6BNC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAyDPC,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAuYdC,MAAMA;;;;;;;;;;;aAWNC,iBAAiBA;;;;;;;;;;;;;aAajBC,iBAAiBA;;;;;;;;;;aAUjBC,WAAWA;;;;;;;;;;aAUXC,IAAIA;;;;;;;;;;;;kBAYCC,SAASA;;;;;;;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;;;iBC8GVC,SAASA;;;;;;;;cC1HlBC,OAAOA;;;;cAKPC,GAAGA;;;;;;;;iBCEAC,WAAWA;;;;;;;;;;;;;;;;;;;iBA8BXC,WAAWA;;;;;;;;;;;;;;;;;;;;;iBAyCXC,OAAOA;;;;;;;;;;cC7EVC,qBAAqBA;;;;;;;;cAgBrBC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;cAqBJC,UAAUA;;;;cAOVC,aAAaA;;;;;;;;;;;;cAebC,WAAWA;;;;;;;;;;;cAeXC,WAAWA;;;;;;;;;;;;cAgBXC,cAAcA;;;;;;;;;;cAcdC,UAAUA;;;;;;cAUVC,aAAaA;;;;;cAUbC,SAASA;;;;;cAUTC,YAAYA;MVebxD,YAAYA;;;;;;;;;;;;;;;;;;iBWxIRyD,YAAYA;;;;iBCZfC,SAASA;;;;;;;;;;;;;;cAwBTC,IAAIA;;;;;;;;cAeJC,UAAUA;;;;;;cAaVC,OAAOA" +} \ No newline at end of file diff --git a/node_modules/@sveltejs/vite-plugin-svelte-inspector/LICENSE b/node_modules/@sveltejs/vite-plugin-svelte-inspector/LICENSE new file mode 100644 index 000000000..c1a5d8f07 --- /dev/null +++ b/node_modules/@sveltejs/vite-plugin-svelte-inspector/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 [these people](https://github.com/sveltejs/vite-plugin-svelte/graphs/contributors) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@sveltejs/vite-plugin-svelte-inspector/README.md b/node_modules/@sveltejs/vite-plugin-svelte-inspector/README.md new file mode 100644 index 000000000..bbdf50c80 --- /dev/null +++ b/node_modules/@sveltejs/vite-plugin-svelte-inspector/README.md @@ -0,0 +1,26 @@ +# @sveltejs/vite-plugin-svelte-inspector + +A [Svelte](https://svelte.dev) inspector plugin for [Vite](https://vitejs.dev). + +## Usage + +```js +// vite.config.js +import { defineConfig } from 'vite'; +import { svelte } from '@sveltejs/vite-plugin-svelte'; +import { svelteInspector } from '@sveltejs/vite-plugin-svelte-inspector'; + +export default defineConfig({ + plugins: [ + // the svelte plugin is required to work + svelte(), + svelteInspector({ + /* plugin options */ + }) + ] +}); +``` + +## License + +[MIT](./LICENSE) diff --git a/node_modules/@sveltejs/vite-plugin-svelte-inspector/package.json b/node_modules/@sveltejs/vite-plugin-svelte-inspector/package.json new file mode 100644 index 000000000..34e8ae4ba --- /dev/null +++ b/node_modules/@sveltejs/vite-plugin-svelte-inspector/package.json @@ -0,0 +1,56 @@ +{ + "name": "@sveltejs/vite-plugin-svelte-inspector", + "version": "2.0.0", + "license": "MIT", + "author": "dominikg", + "files": [ + "src", + "types" + ], + "type": "module", + "types": "types/index.d.ts", + "exports": { + ".": { + "import": { + "types": "./types/index.d.ts", + "default": "./src/index.js" + } + } + }, + "engines": { + "node": "^18.0.0 || >=20" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/sveltejs/vite-plugin-svelte.git", + "directory": "packages/vite-plugin-svelte-inspector" + }, + "keywords": [ + "vite-plugin", + "vite plugin", + "vite", + "svelte" + ], + "bugs": { + "url": "https://github.com/sveltejs/vite-plugin-svelte/issues" + }, + "homepage": "https://github.com/sveltejs/vite-plugin-svelte#readme", + "dependencies": { + "debug": "^4.3.4" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.0" + }, + "devDependencies": { + "@types/debug": "^4.1.12", + "svelte": "^4.2.3", + "vite": "^5.0.0" + }, + "scripts": { + "check:publint": "publint --strict", + "check:types": "tsc --noEmit", + "generate:types": "dts-buddy -m \"@sveltejs/vite-plugin-svelte-inspector:src/public.d.ts\"" + } +} \ No newline at end of file diff --git a/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/debug.js b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/debug.js new file mode 100644 index 000000000..0575a83fd --- /dev/null +++ b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/debug.js @@ -0,0 +1,3 @@ +import _debug from 'debug'; + +export const debug = _debug('vite-plugin-svelte-inspector'); diff --git a/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/index.js b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/index.js new file mode 100644 index 000000000..1f2e6ca4c --- /dev/null +++ b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/index.js @@ -0,0 +1,113 @@ +import { normalizePath } from 'vite'; +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { debug } from './debug.js'; +import { defaultInspectorOptions, parseEnvironmentOptions } from './options.js'; +import { cleanUrl } from './utils.js'; + +function getInspectorPath() { + const pluginPath = normalizePath(path.dirname(fileURLToPath(import.meta.url))); + return pluginPath.replace( + /\/vite-plugin-svelte-inspector\/src$/, + '/vite-plugin-svelte-inspector/src/runtime/' + ); +} + +/** + * @param {Partial} [options] + * @returns {import('vite').Plugin} + */ +export function svelteInspector(options) { + const inspectorPath = getInspectorPath(); + debug(`svelte inspector path: ${inspectorPath}`); + + /** @type {import('vite').ResolvedConfig} */ + let viteConfig; + /** @type {import('./public.d.ts').Options} */ + let inspectorOptions; + let disabled = false; + + return { + name: 'vite-plugin-svelte-inspector', + apply: 'serve', + enforce: 'pre', + + configResolved(config) { + viteConfig = config; + + const environmentOptions = parseEnvironmentOptions(config); + if (environmentOptions === false) { + debug('environment options set to false, inspector disabled'); + disabled = true; + return; + } + + // Handle config from svelte.config.js through vite-plugin-svelte + const vps = config.plugins.find((p) => p.name === 'vite-plugin-svelte'); + const configFileOptions = vps?.api?.options?.inspector; + + // vite-plugin-svelte can only pass options through it's `api` instead of `options`. + // that means this plugin could be created but should be disabled, so we check this case here. + if (vps && !options && !configFileOptions && !environmentOptions) { + debug("vite-plugin-svelte didn't pass options, inspector disabled"); + disabled = true; + return; + } + + if (environmentOptions === true) { + inspectorOptions = defaultInspectorOptions; + } else { + inspectorOptions = { + ...defaultInspectorOptions, + ...configFileOptions, + ...options, + ...(environmentOptions || {}) + }; + } + + inspectorOptions.__internal = { + base: config.base?.replace(/\/$/, '') || '' + }; + }, + + async resolveId(importee, _, options) { + if (options?.ssr || disabled) { + return; + } + if (importee.startsWith('virtual:svelte-inspector-options')) { + return importee; + } else if (importee.startsWith('virtual:svelte-inspector-path:')) { + return importee.replace('virtual:svelte-inspector-path:', inspectorPath); + } + }, + + async load(id, options) { + if (options?.ssr || disabled) { + return; + } + if (id === 'virtual:svelte-inspector-options') { + return `export default ${JSON.stringify(inspectorOptions ?? {})}`; + } else if (id.startsWith(inspectorPath)) { + // read file ourselves to avoid getting shut out by vites fs.allow check + const file = cleanUrl(id); + if (fs.existsSync(id)) { + return await fs.promises.readFile(file, 'utf-8'); + } else { + viteConfig.logger.error( + `[vite-plugin-svelte-inspector] failed to find svelte-inspector: ${id}` + ); + } + } + }, + + transform(code, id, options) { + if (options?.ssr || disabled) { + return; + } + if (id.includes('vite/dist/client/client.mjs')) { + return { code: `${code}\nimport('virtual:svelte-inspector-path:load-inspector.js')` }; + } + } + }; +} diff --git a/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/options.js b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/options.js new file mode 100644 index 000000000..d53561520 --- /dev/null +++ b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/options.js @@ -0,0 +1,61 @@ +import { loadEnv } from 'vite'; +import { debug } from './debug.js'; + +/** @type {import('./public.d.ts').Options} */ +export const defaultInspectorOptions = { + toggleKeyCombo: process.platform === 'darwin' ? 'meta-shift' : 'control-shift', + navKeys: { parent: 'ArrowUp', child: 'ArrowDown', next: 'ArrowRight', prev: 'ArrowLeft' }, + openKey: 'Enter', + holdMode: true, + showToggleButton: 'active', + toggleButtonPos: 'top-right', + customStyles: true +}; + +/** + * @param {import('vite').ResolvedConfig} config + * @returns {Partial | boolean | void} + */ +export function parseEnvironmentOptions(config) { + const env = loadEnv(config.mode, config.envDir ?? process.cwd(), 'SVELTE_INSPECTOR'); + const options = env?.SVELTE_INSPECTOR_OPTIONS; + const toggle = env?.SVELTE_INSPECTOR_TOGGLE; + if (options) { + try { + const parsed = JSON.parse(options); + const parsedType = typeof parsed; + if (parsedType === 'boolean') { + return parsed; + } else if (parsedType === 'object') { + if (Array.isArray(parsed)) { + throw new Error('invalid type, expected object map but got array'); + } + const parsedKeys = Object.keys(parsed); + const defaultKeys = Object.keys(defaultInspectorOptions); + const unknownKeys = parsedKeys.filter((k) => !defaultKeys.includes(k)); + if (unknownKeys.length) { + config.logger.warn( + `[vite-plugin-svelte-inspector] ignoring unknown options in environment SVELTE_INSPECTOR_OPTIONS: ${unknownKeys.join( + ', ' + )}` + ); + for (const key of unknownKeys) { + delete parsed[key]; + } + } + debug('loaded environment config', parsed); + return parsed; + } + } catch (e) { + config.logger.error( + `[vite-plugin-svelte-inspector] failed to parse inspector options from environment SVELTE_INSPECTOR_OPTIONS="${options}"\n${e}` + ); + } + } else if (toggle) { + const keyConfig = { + toggleKeyCombo: toggle + }; + debug('loaded environment config', keyConfig); + return keyConfig; + } +} diff --git a/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/public.d.ts b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/public.d.ts new file mode 100644 index 000000000..538d7cb42 --- /dev/null +++ b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/public.d.ts @@ -0,0 +1,72 @@ +export interface Options { + /** + * define a key combo to toggle inspector, + * @default 'meta-shift' on mac, 'control-shift' on other os + * + * any number of modifiers `control` `shift` `alt` `meta` followed by zero or one regular key, separated by - + * examples: control-shift, control-o, control-alt-s meta-x control-meta + * Some keys have native behavior (e.g. alt-s opens history menu on firefox). + * To avoid conflicts or accidentally typing into inputs, modifier only combinations are recommended. + */ + toggleKeyCombo?: string; + + /** + * define keys to select elements with via keyboard + * @default {parent: 'ArrowUp', child: 'ArrowDown', next: 'ArrowRight', prev: 'ArrowLeft' } + * + * improves accessibility and also helps when you want to select elements that do not have a hoverable surface area + * due to tight wrapping + * + * A note for users of screen-readers: + * If you are using arrow keys to navigate the page itself, change the navKeys to avoid conflicts. + * e.g. navKeys: {parent: 'w', prev: 'a', child: 's', next: 'd'} + * + * + * parent: select closest parent + * child: select first child (or grandchild) + * next: next sibling (or parent if no next sibling exists) + * prev: previous sibling (or parent if no prev sibling exists) + */ + navKeys?: { parent: string; child: string; next: string; prev: string }; + + /** + * define key to open the editor for the currently selected dom node + * + * @default 'Enter' + */ + openKey?: string; + + /** + * inspector is automatically disabled when releasing toggleKeyCombo after holding it for a longpress + * @default true + */ + holdMode?: boolean; + + /** + * when to show the toggle button + * @default 'active' + */ + showToggleButton?: 'always' | 'active' | 'never'; + + /** + * where to display the toggle button + * @default top-right + */ + toggleButtonPos?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'; + + /** + * inject custom styles when inspector is active + */ + customStyles?: boolean; + + /** + * internal options that are automatically set, not to be set or used by users + * @internal + */ + __internal?: { + // vite base url + base: string; + }; +} + +export * from './index.js'; diff --git a/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/runtime/Inspector.svelte b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/runtime/Inspector.svelte new file mode 100644 index 000000000..1df2f401d --- /dev/null +++ b/node_modules/@sveltejs/vite-plugin-svelte-inspector/src/runtime/Inspector.svelte @@ -0,0 +1,392 @@ + + +{#if show_toggle} +